]> git.codecow.com Git - libnemo.git/commitdiff
Reduce worker dependencies.
authorChris Duncan <chris@zoso.dev>
Sun, 27 Jul 2025 04:45:05 +0000 (21:45 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 27 Jul 2025 04:45:05 +0000 (21:45 -0700)
src/lib/workers/passkey.ts

index baf0e4af4b8c2fe97ec40e976ee1b6b78ee67cf5..e98f79d8346478c4ef0a298904cace1b17f95494 100644 (file)
@@ -4,9 +4,6 @@
 'use strict'
 
 import { WorkerInterface } from './worker-interface'
-import { PBKDF2_ITERATIONS } from '#src/lib/constants.js'
-import { default as Convert, bytes } from '#src/lib/convert.js'
-import { Entropy } from '#src/lib/entropy.js'
 import { NamedData } from '#types'
 
 /**
@@ -44,7 +41,7 @@ export class Passkey extends WorkerInterface {
                        salt = dataObject.salt
                }
                try {
-                       salt ??= (await Entropy.create()).buffer
+                       salt ??= globalThis.crypto.getRandomValues(new Uint8Array(32)).buffer
                        const key = await this.#createAesKey(method, password, salt)
                        return { salt, key }
                } catch (err) {
@@ -59,7 +56,7 @@ export class Passkey extends WorkerInterface {
                const derivationAlgorithm: Pbkdf2Params = {
                        name: 'PBKDF2',
                        hash: 'SHA-512',
-                       iterations: PBKDF2_ITERATIONS,
+                       iterations: 210000,
                        salt
                }
                const derivedKeyType: AesKeyGenParams = {
@@ -74,9 +71,6 @@ let importWorkerThreads = ''
 NODE: importWorkerThreads = `import { parentPort } from 'node:worker_threads'`
 export default `
        ${importWorkerThreads}
-       ${Convert}
-       const PBKDF2_ITERATIONS = ${PBKDF2_ITERATIONS}
-       const Entropy = ${Entropy}
        const WorkerInterface = ${WorkerInterface}
        const Passkey = ${Passkey}
 `