@workglow/util 0.0.103 → 0.0.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/common.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ export * from "./crypto/Crypto";
6
7
  export * from "./di";
7
8
  export * from "./events/EventEmitter";
8
9
  export * from "./logging";
@@ -24,4 +25,6 @@ export * from "./vector/VectorSimilarityUtils";
24
25
  export * from "./vector/VectorUtils";
25
26
  export * from "./worker/WorkerManager";
26
27
  export * from "./worker/WorkerServer";
28
+ export * from "./credentials";
29
+ export * from "./crypto/WebCrypto";
27
30
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,MAAM,CAAC;AACrB,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,MAAM,CAAC;AACrB,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { CredentialPutOptions, ICredentialStore } from "./ICredentialStore";
7
+ /**
8
+ * A credential store that chains multiple stores together, trying each
9
+ * in order until a value is found.
10
+ *
11
+ * Writes always go to the first (primary) store. Reads cascade through
12
+ * the chain, returning the first match. This enables layered resolution:
13
+ * explicit config → encrypted store → environment variables.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const store = new ChainedCredentialStore([
18
+ * new InMemoryCredentialStore(), // runtime overrides
19
+ * new EncryptedKvCredentialStore(kv, passphrase), // persistent encrypted
20
+ * new EnvCredentialStore({ ... }), // environment fallback
21
+ * ]);
22
+ * ```
23
+ */
24
+ export declare class ChainedCredentialStore implements ICredentialStore {
25
+ private readonly stores;
26
+ constructor(stores: readonly ICredentialStore[]);
27
+ get(key: string): Promise<string | undefined>;
28
+ put(key: string, value: string, options?: CredentialPutOptions): Promise<void>;
29
+ delete(key: string): Promise<boolean>;
30
+ has(key: string): Promise<boolean>;
31
+ keys(): Promise<readonly string[]>;
32
+ deleteAll(): Promise<void>;
33
+ }
34
+ //# sourceMappingURL=ChainedCredentialStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChainedCredentialStore.d.ts","sourceRoot":"","sources":["../../src/credentials/ChainedCredentialStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEjF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,sBAAuB,YAAW,gBAAgB;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS,gBAAgB,EAAE;IAM1D,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAQ7C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAUrC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOlC,IAAI,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC;IAUlC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAGjC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { ServiceRegistry } from "../di/ServiceRegistry";
7
+ import type { ICredentialStore } from "./ICredentialStore";
8
+ /**
9
+ * Gets the global credential store instance
10
+ */
11
+ export declare function getGlobalCredentialStore(): ICredentialStore;
12
+ /**
13
+ * Sets the global credential store instance
14
+ */
15
+ export declare function setGlobalCredentialStore(store: ICredentialStore): void;
16
+ /**
17
+ * Resolves a credential from the store registered in the given registry,
18
+ * falling back to the global credential store.
19
+ *
20
+ * Intended for use in provider `getClient` functions and tasks.
21
+ *
22
+ * @param key The credential key to resolve
23
+ * @param registry Optional service registry (e.g., from task context)
24
+ * @returns The credential value, or undefined if not found
25
+ */
26
+ export declare function resolveCredential(key: string, registry?: ServiceRegistry): Promise<string | undefined>;
27
+ //# sourceMappingURL=CredentialStoreRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CredentialStoreRegistry.d.ts","sourceRoot":"","sources":["../../src/credentials/CredentialStoreRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAY3D;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,gBAAgB,CAE3D;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAEtE;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,eAAe,GACzB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAO7B"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { CredentialPutOptions, ICredentialStore } from "./ICredentialStore";
7
+ /**
8
+ * Credential store backed by environment variables.
9
+ *
10
+ * Keys are mapped to environment variable names via an explicit mapping
11
+ * or an optional prefix convention. This store is read-only for env vars
12
+ * that already exist, but `put` can be used to set them for the current
13
+ * process lifetime.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const store = new EnvCredentialStore({
18
+ * "anthropic-api-key": "ANTHROPIC_API_KEY",
19
+ * "openai-api-key": "OPENAI_API_KEY",
20
+ * });
21
+ * const key = await store.get("anthropic-api-key"); // reads process.env.ANTHROPIC_API_KEY
22
+ * ```
23
+ */
24
+ export declare class EnvCredentialStore implements ICredentialStore {
25
+ private readonly keyToEnvVar;
26
+ private readonly prefix;
27
+ /**
28
+ * @param mapping Explicit credential-key → env-var-name mapping
29
+ * @param prefix Optional prefix: if a key has no explicit mapping, try `PREFIX_KEY` (uppercased, hyphens → underscores)
30
+ */
31
+ constructor(mapping?: Record<string, string>, prefix?: string);
32
+ private resolveEnvVar;
33
+ private getEnv;
34
+ get(key: string): Promise<string | undefined>;
35
+ put(key: string, value: string, _options?: CredentialPutOptions): Promise<void>;
36
+ delete(key: string): Promise<boolean>;
37
+ has(key: string): Promise<boolean>;
38
+ keys(): Promise<readonly string[]>;
39
+ deleteAll(): Promise<void>;
40
+ }
41
+ //# sourceMappingURL=EnvCredentialStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvCredentialStore.d.ts","sourceRoot":"","sources":["../../src/credentials/EnvCredentialStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEjF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,kBAAmB,YAAW,gBAAgB;IACzD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsB;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C;;;OAGG;gBACS,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAKjE,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,MAAM;IAOR,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK7C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASrC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKlC,IAAI,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC;IAUlC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAKjC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Metadata associated with a stored credential
8
+ */
9
+ export interface CredentialMetadata {
10
+ /** Human-readable label for the credential */
11
+ readonly label: string | undefined;
12
+ /** The provider this credential is associated with (e.g., "anthropic", "openai") */
13
+ readonly provider: string | undefined;
14
+ /** When the credential was created */
15
+ readonly createdAt: Date;
16
+ /** When the credential was last updated */
17
+ readonly updatedAt: Date;
18
+ /** When the credential expires (undefined = never) */
19
+ readonly expiresAt: Date | undefined;
20
+ }
21
+ /**
22
+ * A stored credential entry combining the secret value with its metadata
23
+ */
24
+ export interface CredentialEntry {
25
+ /** The credential key/name */
26
+ readonly key: string;
27
+ /** The secret value */
28
+ readonly value: string;
29
+ /** Associated metadata */
30
+ readonly metadata: CredentialMetadata;
31
+ }
32
+ /**
33
+ * Options for storing a credential
34
+ */
35
+ export interface CredentialPutOptions {
36
+ /** Human-readable label */
37
+ readonly label?: string;
38
+ /** Associated provider name */
39
+ readonly provider?: string;
40
+ /** Expiration date */
41
+ readonly expiresAt?: Date;
42
+ }
43
+ /**
44
+ * Interface defining the contract for credential/secret storage.
45
+ *
46
+ * Provides a unified abstraction for storing and retrieving sensitive values
47
+ * (API keys, tokens, passwords) across different backends: in-memory,
48
+ * environment variables, encrypted KV stores, or external secret managers
49
+ * (AWS Secrets Manager, HashiCorp Vault, GCP Secret Manager).
50
+ *
51
+ * Implementations MUST NOT log or expose credential values in error messages.
52
+ */
53
+ export interface ICredentialStore {
54
+ /**
55
+ * Retrieve a credential value by key.
56
+ *
57
+ * Returns the secret value if found and not expired, or `undefined` if the
58
+ * credential does not exist or is expired.
59
+ *
60
+ * Implementations MAY reject the returned promise on backend, storage, or
61
+ * cryptographic errors (e.g., I/O failure, decryption failure, corrupt data).
62
+ * Such errors MUST NOT include credential secret values in their messages or
63
+ * metadata.
64
+ */
65
+ get(key: string): Promise<string | undefined>;
66
+ /**
67
+ * Store a credential value.
68
+ * @param key Unique identifier for the credential
69
+ * @param value The secret value to store
70
+ * @param options Optional metadata
71
+ */
72
+ put(key: string, value: string, options?: CredentialPutOptions): Promise<void>;
73
+ /**
74
+ * Delete a credential by key.
75
+ * @returns true if the credential existed and was deleted, false otherwise.
76
+ */
77
+ delete(key: string): Promise<boolean>;
78
+ /**
79
+ * Check whether a credential exists (and is not expired).
80
+ */
81
+ has(key: string): Promise<boolean>;
82
+ /**
83
+ * List all credential keys (does NOT expose values).
84
+ */
85
+ keys(): Promise<readonly string[]>;
86
+ /**
87
+ * Delete all credentials.
88
+ */
89
+ deleteAll(): Promise<void>;
90
+ }
91
+ /**
92
+ * Service token for the global credential store
93
+ */
94
+ export declare const CREDENTIAL_STORE: import("../di").ServiceToken<ICredentialStore>;
95
+ //# sourceMappingURL=ICredentialStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICredentialStore.d.ts","sourceRoot":"","sources":["../../src/credentials/ICredentialStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,2CAA2C;IAC3C,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,sDAAsD;IACtD,QAAQ,CAAC,SAAS,EAAE,IAAI,GAAG,SAAS,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0BAA0B;IAC1B,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,sBAAsB;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAE9C;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/E;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;IAEnC;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,gDAA2D,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { CredentialPutOptions, ICredentialStore } from "./ICredentialStore";
7
+ /**
8
+ * In-memory credential store for development and testing.
9
+ *
10
+ * Credentials are stored in a plain Map and lost when the process exits.
11
+ * NOT suitable for production use — use {@link EncryptedKvCredentialStore}
12
+ * or an external secret manager integration instead.
13
+ */
14
+ export declare class InMemoryCredentialStore implements ICredentialStore {
15
+ private readonly store;
16
+ get(key: string): Promise<string | undefined>;
17
+ put(key: string, value: string, options?: CredentialPutOptions): Promise<void>;
18
+ delete(key: string): Promise<boolean>;
19
+ has(key: string): Promise<boolean>;
20
+ keys(): Promise<readonly string[]>;
21
+ deleteAll(): Promise<void>;
22
+ }
23
+ //# sourceMappingURL=InMemoryCredentialStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InMemoryCredentialStore.d.ts","sourceRoot":"","sources":["../../src/credentials/InMemoryCredentialStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAGV,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAC9D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsC;IAEtD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAU7C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAa9E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAUlC,IAAI,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC;IAalC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAGjC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export * from "./ICredentialStore";
7
+ export * from "./InMemoryCredentialStore";
8
+ export * from "./EnvCredentialStore";
9
+ export * from "./ChainedCredentialStore";
10
+ export * from "./CredentialStoreRegistry";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/credentials/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC"}
@@ -7,4 +7,4 @@ export declare function sha256(data: string): Promise<string>;
7
7
  export declare function makeFingerprint(input: any): Promise<string>;
8
8
  export type uuid4 = `${string}-${string}-${string}-${string}-${string}`;
9
9
  export declare function uuid4(): uuid4;
10
- //# sourceMappingURL=Crypto.bun.d.ts.map
10
+ //# sourceMappingURL=Crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Crypto.d.ts","sourceRoot":"","sources":["../../src/crypto/Crypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK1D;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAIjE;AAED,MAAM,MAAM,KAAK,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;AAExE,wBAAgB,KAAK,IAAI,KAAK,CAE7B"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Derives a 256-bit AES-GCM key from a passphrase using PBKDF2.
8
+ */
9
+ export declare function deriveKey(passphrase: string, salt: Uint8Array): Promise<CryptoKey>;
10
+ /**
11
+ * Encrypts plaintext using AES-256-GCM with a random salt and IV.
12
+ * The salt is prepended to the ciphertext bytes and stored in the `encrypted` field
13
+ * so that decryption can reconstruct the same key.
14
+ *
15
+ * @param keyCache - Per-store cache of derived CryptoKey instances keyed by base64(salt).
16
+ */
17
+ export declare function encrypt(plaintext: string, passphrase: string, keyCache: Map<string, CryptoKey>): Promise<{
18
+ encrypted: string;
19
+ iv: string;
20
+ }>;
21
+ /**
22
+ * Decrypts ciphertext encrypted with {@link encrypt}.
23
+ *
24
+ * @param keyCache - Per-store cache of derived CryptoKey instances keyed by base64(salt).
25
+ */
26
+ export declare function decrypt(encrypted: string, iv: string, passphrase: string, keyCache: Map<string, CryptoKey>): Promise<string>;
27
+ export declare function bufToBase64(buf: Uint8Array): string;
28
+ export declare function base64ToBuf(b64: string): Uint8Array;
29
+ //# sourceMappingURL=WebCrypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebCrypto.d.ts","sourceRoot":"","sources":["../../src/crypto/WebCrypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,wBAAsB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAYxF;AAED;;;;;;GAMG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAC/B,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAwB5C;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAMnD;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAOnD"}