Skip to content

Commit

Permalink
chore: add reset to iddb store
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Oct 27, 2022
1 parent 50d77db commit 2a5e15a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/access/src/stores/store-indexeddb.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,25 @@ export class StoreIndexedDB {
async createAccount() {
return await Signer.generate({ extractable: false })
}

async reset() {
if (this.#db) {
withObjectStore(this.#db, 'readwrite', this.#dbStoreName, (s) => {
/** @type {import('p-defer').DeferredPromise<void>} */
const { resolve, reject, promise } = defer()
const req = s.clear()
req.addEventListener('success', () => {
resolve()
})

req.addEventListener('error', () =>
reject(new Error('failed to query DB', { cause: req.error }))
)

return promise
})
}
}
}

/**
Expand Down

0 comments on commit 2a5e15a

Please sign in to comment.