if (typeof id !== 'string') {
throw new TypeError('Retrieved invalid ID', { cause: id })
}
- if (type !== 'BIP-44' && type !== 'BLAKE2b') {
+ if (type !== 'BIP-44' && type !== 'BLAKE2b' && type !== 'Ledger') {
throw new TypeError('Retrieved invalid type', { cause: type })
}
- if (!(iv instanceof ArrayBuffer)) {
- throw new TypeError('Retrieved invalid iv', { cause: iv })
- }
- if (!(salt instanceof ArrayBuffer)) {
- throw new TypeError('Retrieved invalid salt', { cause: salt })
- }
- if (!(encrypted instanceof ArrayBuffer)) {
- throw new TypeError('Retrieved invalid encrypted data', { cause: encrypted })
+ if (type !== 'Ledger') {
+ if (!(iv instanceof ArrayBuffer)) {
+ throw new TypeError('Retrieved invalid iv', { cause: iv })
+ }
+ if (!(salt instanceof ArrayBuffer)) {
+ throw new TypeError('Retrieved invalid salt', { cause: salt })
+ }
+ if (!(encrypted instanceof ArrayBuffer)) {
+ throw new TypeError('Retrieved invalid encrypted data', { cause: encrypted })
+ }
}
return { id, type, iv, salt, encrypted } as const
} catch (err) {
import { _config } from './config'\r
import { _create } from './create'\r
import { _destroy } from './destroy'\r
-import { _get } from './get'\r
import { _load } from './load'\r
import { _lock } from './lock'\r
import { _refresh } from './refresh'\r
type: wallet.type
}
if (wallet.type === 'Ledger') {
-
if (Ledger.isUnsupported) {
throw new Error('Failed to initialize Ledger wallet', { cause: 'Browser is unsupported' })
}
import { Database } from '../database'
import { Vault } from '../vault'
import { Wallet } from '../wallet'
-import { _get } from './get'
export async function _update (wallet: Wallet, vault: Vault, password?: string): Promise<void>
export async function _update (wallet: Wallet, vault: Vault, password: unknown): Promise<void> {
const { LEDGER_MNEMONIC, LEDGER_SEED, LEDGER_PUBLIC_0, LEDGER_ADDRESS_0 } = CUSTOM_TEST_VECTORS
const { OPEN_BLOCK, RECEIVE_BLOCK, SEND_BLOCK } = NANO_TEST_VECTORS
- let wallet, account, openBlock, sendBlock, receiveBlock
+ let wallet, account, openBlock, sendBlock, receiveBlock, restored
try {
wallet = await Wallet.create('Ledger')
} catch {
})
await test('verify mnemonic', async () => {
+ await click(
+ 'Open Nano app, then click to continue',
+ async () => wallet.unlock()
+ )
const isVerified = await wallet.verify(LEDGER_MNEMONIC)
assert.exists(isVerified)
await assert.rejects(sendBlock.sign(wallet, 0))
})
- await test('destroy wallet', async () => {
+ await test('restore from db then destroy', async () => {
+ restored = await Wallet.restore(wallet.id)
+
+ assert.exists(restored)
+ await assert.resolves(restored.unlock())
+ assert.equal(await restored.verify(LEDGER_MNEMONIC), true)
+
await click(
'Click to finish Ledger tests by destroying wallet',
async () => new Promise(r => setTimeout(r))
await assert.resolves(wallet.destroy())
await assert.rejects(wallet.unlock())
await wallet.destroy()
+ await restored.destroy()
})
})
])
await assert.rejects(wallet.config({ timeout: 0 }))\r
await assert.rejects(wallet.config({ timeout: 9 }))\r
await assert.rejects(wallet.config({ timeout: 601 }))\r
+\r
+ await assert.resolves(wallet.destroy())\r
})\r
})\r
])\r