import type { RecoveryCode, PasswordMemLimit, PasswordOpsLimit } from '../keys/types.js'; type PolykeyWorkerManifest = { sleep({ delay }: { delay: number; }): Promise<{ data: undefined; }>; hashPassword({ password, salt, opsLimit, memLimit, }: { password: string; salt?: ArrayBuffer; opsLimit?: PasswordOpsLimit; memLimit?: PasswordMemLimit; }, transferList?: Array): Promise<{ data: [ArrayBuffer, ArrayBuffer]; transferList: [ArrayBuffer, ArrayBuffer]; }>; checkPassword({ password, hash, salt, opsLimit, memLimit, }: { password: string; hash: ArrayBuffer; salt: ArrayBuffer; opsLimit?: PasswordOpsLimit; memLimit?: PasswordMemLimit; }, transferList?: Array): Promise<{ data: boolean; }>; generateDeterministicKeyPair({ recoveryCode, }: { recoveryCode: RecoveryCode; }): Promise<{ data: { publicKey: ArrayBuffer; privateKey: ArrayBuffer; secretKey: ArrayBuffer; }; transferList: [ArrayBuffer, ArrayBuffer, ArrayBuffer]; }>; generateCertificate({ certId, subjectKeyPair, issuerPrivateKey, duration, subjectAttrsExtra, issuerAttrsExtra, now, }: { certId: ArrayBuffer; subjectKeyPair: { publicKey: ArrayBuffer; privateKey: ArrayBuffer; }; issuerPrivateKey: ArrayBuffer; duration: number; subjectAttrsExtra?: Array<{ [key: string]: Array; }>; issuerAttrsExtra?: Array<{ [key: string]: Array; }>; now?: Date; }, transferList?: Array): Promise<{ data: ArrayBuffer; transferList: [ArrayBuffer]; }>; encrypt(data: { key: ArrayBuffer; plainText: ArrayBuffer; }, transferList: Array): Promise<{ data: ArrayBuffer; transferList: [ArrayBuffer]; }>; decrypt(data: { key: ArrayBuffer; cipherText: ArrayBuffer; }, transferList: Array): Promise<{ data: ArrayBuffer; transferList: [ArrayBuffer]; } | { data: undefined; transferList: []; }>; }; /** * Worker object that contains all functions that will be executed in parallel. * Functions should be using CPU-parallelism not IO-parallelism. * Most functions should be synchronous, not asynchronous. * Making them asynchronous does not make a difference to the caller. * The caller must always await because the fucntions will run on the pool. * * When passing in `Buffer`, it is coerced into an `Uint8Array`. To avoid * confusion, do not pass in `Buffer` and instead use `ArrayBuffer`. * * If you are passing the underlying `ArrayBuffer`, ensure that the containing * `Buffer` is unpooled, or make a slice copy of the underlying `ArrayBuffer` * with the `Buffer.byteOffset` and `Buffer.byteLength`. * * Remember the subtyping relationship of buffers: * Buffers < Uint8Array < ArrayBuffer < BufferSource * * Only the `ArrayBuffer` is "transferrable" which means they can be zero-copy * transferred. When transferring a structure that contains `ArrayBuffer`, you * must pass the array of transferrable objects as the second parameter to * `Transfer`. * * Only transfer things that you don't expect to be using in the sending thread. * * Note that `Buffer.from(ArrayBuffer)` is a zero-copy wrapper. */ declare const polykeyWorkerManifest: PolykeyWorkerManifest; export type { PolykeyWorkerManifest }; export default polykeyWorkerManifest;