(opts?: { encryptAll?: boolean })
| 300 | } |
| 301 | |
| 302 | async save(opts?: { encryptAll?: boolean }) { |
| 303 | const { encryptAll } = opts || {}; |
| 304 | try { |
| 305 | if (!this.#walletData) { |
| 306 | throw new Error('No wallet data to save. Wallet not created or loaded'); |
| 307 | } |
| 308 | let data: WalletData | EncryptionTypes.IEncrypted = { key: this.#walletData.key?.toObj(), credentials: this.#walletData.credentials.toObj() }; |
| 309 | if (encryptAll) { |
| 310 | const password = await getPassword('Enter password to encrypt:', { minLength: 6 }); |
| 311 | await prompt.password({ |
| 312 | message: 'Confirm password:', |
| 313 | mask: '*', |
| 314 | validate: (val) => val === password ? undefined : 'Passwords do not match' |
| 315 | }); |
| 316 | |
| 317 | data = Encryption.encryptWithPassword(JSON.stringify(data), password, WALLET_ENCRYPTION_OPTS); |
| 318 | } |
| 319 | await this.storage.save(JSON.stringify(data)); |
| 320 | return; |
| 321 | } catch (err) { |
| 322 | Utils.die(err); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | async export(args: { |
| 327 | filename: string; |
no test coverage detected