]> git.codecow.com Git - libnemo.git/commitdiff
Remove async keyword and format comment docs.
authorChris Duncan <chris@codecow.com>
Sat, 4 Jul 2026 08:44:55 +0000 (01:44 -0700)
committerChris Duncan <chris@codecow.com>
Sat, 4 Jul 2026 08:44:55 +0000 (01:44 -0700)
src/lib/vault/vault-worker.ts

index 6c242c4c78f5835c682d05a550cb82fcb1c5c2ac..621493c440b26f6b19effdd028c719c1fb6fc712 100644 (file)
@@ -114,7 +114,7 @@ NODE: parentPort?.on('message', listener)
  * Configures vault settings. The wallet must be unlocked prior to
  * configuration.
  */
-async function config (timeout?: number): Promise<void> {
+function config (timeout?: number): Promise<void> {
        try {
                _timer?.pause()
                if (_locked) {
@@ -139,10 +139,10 @@ async function config (timeout?: number): Promise<void> {
 }
 
 /**
-* Generates a new mnemonic and seed and then returns the initialization vector
-* vector, salt, and encrypted data representing the wallet in a locked state.
-*/
-async function create (type?: WalletType, key?: CryptoKey, keySalt?: ArrayBuffer, mnemonicSalt?: string): Promise<Record<string, ArrayBuffer>> {
+ * Generates a new mnemonic and seed and then returns the initialization vector
+ * vector, salt, and encrypted data representing the wallet in a locked state.
+ */
+function create (type?: WalletType, key?: CryptoKey, keySalt?: ArrayBuffer, mnemonicSalt?: string): Promise<Record<string, ArrayBuffer>> {
        if (type !== 'BIP-44' && type !== 'BLAKE2b') {
                throw new TypeError('Unsupported software wallet algorithm', { cause: type })
        }
@@ -166,11 +166,11 @@ async function create (type?: WalletType, key?: CryptoKey, keySalt?: ArrayBuffer
 }
 
 /**
-* Derives the private and public keys of a child account from the current
-* wallet seed at a specified index and then returns the public key. The wallet
-* must be unlocked prior to derivation.
-*/
-async function derive (index?: number): Promise<Record<string, number | ArrayBuffer>> {
+ * Derives the private and public keys of a child account from the current
+ * wallet seed at a specified index and then returns the public key. The wallet
+ * must be unlocked prior to derivation.
+ */
+function derive (index?: number): Promise<Record<string, number | ArrayBuffer>> {
        try {
                _timer.pause()
                if (_locked) {
@@ -200,10 +200,10 @@ async function derive (index?: number): Promise<Record<string, number | ArrayBuf
 }
 
 /**
-* Encrypts an existing seed or mnemonic+salt and returns the initialization
-* vector, salt, and encrypted data representing the wallet in a locked state.
-*/
-async function load (type?: WalletType, key?: CryptoKey, keySalt?: ArrayBuffer, secret?: string | ArrayBuffer, mnemonicSalt?: string): Promise<Record<string, ArrayBuffer>> {
+ * Encrypts an existing seed or mnemonic+salt and returns the initialization
+ * vector, salt, and encrypted data representing the wallet in a locked state.
+ */
+function load (type?: WalletType, key?: CryptoKey, keySalt?: ArrayBuffer, secret?: string | ArrayBuffer, mnemonicSalt?: string): Promise<Record<string, ArrayBuffer>> {
        if (type !== 'BIP-44' && type !== 'BLAKE2b' && type !== 'Exodus') {
                throw new TypeError('Unsupported software wallet algorithm', { cause: type })
        }
@@ -221,7 +221,7 @@ async function load (type?: WalletType, key?: CryptoKey, keySalt?: ArrayBuffer,
                .finally(() => lock())
 }
 
-async function lock (): Promise<Record<string, boolean>> {
+function lock (): Promise<Record<string, boolean>> {
        _mnemonic = undefined
        _seed = undefined
        _locked = true
@@ -230,10 +230,10 @@ async function lock (): Promise<Record<string, boolean>> {
 }
 
 /**
-* Derives the account private key at a specified index, signs the input data,
-* and returns a signature. The wallet must be unlocked prior to verification.
-*/
-async function sign (index?: number, data?: ArrayBuffer): Promise<Record<string, ArrayBuffer>> {
+ * Derives the account private key at a specified index, signs the input data,
+ * and returns a signature. The wallet must be unlocked prior to verification.
+ */
+function sign (index?: number, data?: ArrayBuffer): Promise<Record<string, ArrayBuffer>> {
        try {
                _timer.pause()
                if (_locked) {
@@ -264,9 +264,9 @@ async function sign (index?: number, data?: ArrayBuffer): Promise<Record<string,
 }
 
 /**
-* Decrypts the input and sets the seed and, if it is included, the mnemonic.
-*/
-async function unlock (type?: WalletType, key?: CryptoKey, iv?: ArrayBuffer, encrypted?: ArrayBuffer): Promise<Record<string, boolean>> {
+ * Decrypts the input and sets the seed and, if it is included, the mnemonic.
+ */
+function unlock (type?: WalletType, key?: CryptoKey, iv?: ArrayBuffer, encrypted?: ArrayBuffer): Promise<Record<string, boolean>> {
        if (type == null) {
                throw new TypeError('Wallet type is required')
        }
@@ -307,9 +307,9 @@ async function unlock (type?: WalletType, key?: CryptoKey, iv?: ArrayBuffer, enc
 }
 
 /**
-* Re-encrypts the wallet with a new password.
-*/
-async function update (key?: CryptoKey, salt?: ArrayBuffer): Promise<Record<string, ArrayBuffer>> {
+ * Re-encrypts the wallet with a new password.
+ */
+function update (key?: CryptoKey, salt?: ArrayBuffer): Promise<Record<string, ArrayBuffer>> {
        try {
                _timer.pause()
                if (_locked) {
@@ -337,9 +337,9 @@ async function update (key?: CryptoKey, salt?: ArrayBuffer): Promise<Record<stri
 }
 
 /**
-* Checks the seed and, if it exists, the mnemonic against input. The wallet
-* must be unlocked prior to verification.
-*/
+ * Checks the seed and, if it exists, the mnemonic against input. The wallet
+ * must be unlocked prior to verification.
+ */
 function verify (seed?: ArrayBuffer, mnemonicPhrase?: string): Promise<Record<string, boolean>> {
        try {
                if (_locked) {
@@ -380,11 +380,13 @@ function verify (seed?: ArrayBuffer, mnemonicPhrase?: string): Promise<Record<st
        }
 }
 
-async function _autolock (): Promise<void> {
-       const { isLocked } = await lock()
-       const id = 'autolock'
-       BROWSER: self.postMessage({ url: location.href, id, isLocked })
-       NODE: parentPort?.postMessage({ data: { url: dec.toString(threadId), id, isLocked } })
+function _autolock (): Promise<void> {
+       return lock()
+               .then(isLocked => {
+                       const id = 'autolock'
+                       BROWSER: self.postMessage({ url: location.href, id, isLocked })
+                       NODE: parentPort?.postMessage({ data: { url: dec.toString(threadId), id, isLocked } })
+               })
 }
 
 const _index = new DataView(new ArrayBuffer(4))
@@ -400,7 +402,7 @@ const _index = new DataView(new ArrayBuffer(4))
  *
  * @param {number} index - 4-byte index of account to derive
  * @returns {Promise<ArrayBuffer>} Private key for the account
-*/
+ */
 function _ckd (index: number): Promise<ArrayBuffer> {
        if (_seed == null) {
                throw new Error('Wallet seed not found')
@@ -422,9 +424,9 @@ function _ckd (index: number): Promise<ArrayBuffer> {
 }
 
 /**
-* Encrypts an existing seed or mnemonic+salt and returns the initialization
-* vector, salt, and encrypted data representing the wallet in a locked state.
-*/
+ * Encrypts an existing seed or mnemonic+salt and returns the initialization
+ * vector, salt, and encrypted data representing the wallet in a locked state.
+ */
 function _load (type?: 'BIP-44' | 'BLAKE2b' | 'Exodus', key?: CryptoKey, keySalt?: ArrayBuffer, secret?: string | ArrayBuffer, mnemonicSalt?: string): Promise<Record<string, ArrayBuffer>> {
        try {
                if (!_locked) {