@frontmcp/auth 1.2.1 → 1.4.0

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.
Files changed (74) hide show
  1. package/authorities/authorities.profiles.d.ts +14 -1
  2. package/authorities/authorities.profiles.d.ts.map +1 -1
  3. package/authorization/dcr-client.registry.d.ts +83 -0
  4. package/authorization/dcr-client.registry.d.ts.map +1 -0
  5. package/authorization/index.d.ts +2 -0
  6. package/authorization/index.d.ts.map +1 -1
  7. package/cimd/cimd.service.d.ts +2 -9
  8. package/cimd/cimd.service.d.ts.map +1 -1
  9. package/common/session.types.d.ts +4 -4
  10. package/esm/index.mjs +1821 -214
  11. package/esm/package.json +5 -5
  12. package/index.d.ts +5 -5
  13. package/index.d.ts.map +1 -1
  14. package/index.js +2030 -383
  15. package/jwks/jwks.service.d.ts +2 -4
  16. package/jwks/jwks.service.d.ts.map +1 -1
  17. package/options/app-auth.schema.d.ts +226 -0
  18. package/options/app-auth.schema.d.ts.map +1 -1
  19. package/options/index.d.ts +4 -4
  20. package/options/index.d.ts.map +1 -1
  21. package/options/interfaces.d.ts +580 -4
  22. package/options/interfaces.d.ts.map +1 -1
  23. package/options/orchestrated.schema.d.ts +492 -1
  24. package/options/orchestrated.schema.d.ts.map +1 -1
  25. package/options/schema.d.ts +226 -0
  26. package/options/schema.d.ts.map +1 -1
  27. package/options/shared.schemas.d.ts +237 -2
  28. package/options/shared.schemas.d.ts.map +1 -1
  29. package/package.json +5 -5
  30. package/session/authorization.store.d.ts +117 -47
  31. package/session/authorization.store.d.ts.map +1 -1
  32. package/session/consent.store.d.ts +86 -0
  33. package/session/consent.store.d.ts.map +1 -0
  34. package/session/credential-resume-link.d.ts +64 -0
  35. package/session/credential-resume-link.d.ts.map +1 -0
  36. package/session/credentials-accessor.d.ts +102 -0
  37. package/session/credentials-accessor.d.ts.map +1 -0
  38. package/session/credentials-accessor.impl.d.ts +46 -0
  39. package/session/credentials-accessor.impl.d.ts.map +1 -0
  40. package/session/index.d.ts +32 -2
  41. package/session/index.d.ts.map +1 -1
  42. package/session/orchestrated-token.crypto.d.ts +33 -0
  43. package/session/orchestrated-token.crypto.d.ts.map +1 -0
  44. package/session/secure-store-accessor.d.ts +77 -0
  45. package/session/secure-store-accessor.d.ts.map +1 -0
  46. package/session/secure-store-accessor.impl.d.ts +61 -0
  47. package/session/secure-store-accessor.impl.d.ts.map +1 -0
  48. package/session/secure-store-backends.d.ts +75 -0
  49. package/session/secure-store-backends.d.ts.map +1 -0
  50. package/session/secure-store.d.ts +89 -0
  51. package/session/secure-store.d.ts.map +1 -0
  52. package/session/secure-store.factory.d.ts +62 -0
  53. package/session/secure-store.factory.d.ts.map +1 -0
  54. package/session/session-credential-vault.d.ts +153 -0
  55. package/session/session-credential-vault.d.ts.map +1 -0
  56. package/session/session-credential-vault.factory.d.ts +50 -0
  57. package/session/session-credential-vault.factory.d.ts.map +1 -0
  58. package/session/storage-authorization.store.d.ts +51 -0
  59. package/session/storage-authorization.store.d.ts.map +1 -0
  60. package/session/storage-consent.store.d.ts +33 -0
  61. package/session/storage-consent.store.d.ts.map +1 -0
  62. package/session/storage-federated-auth.session.d.ts +36 -0
  63. package/session/storage-federated-auth.session.d.ts.map +1 -0
  64. package/session/storage-orchestrated-token.store.d.ts +72 -0
  65. package/session/storage-orchestrated-token.store.d.ts.map +1 -0
  66. package/session/token-storage.factory.d.ts +46 -0
  67. package/session/token-storage.factory.d.ts.map +1 -0
  68. package/ui/index.d.ts +3 -2
  69. package/ui/index.d.ts.map +1 -1
  70. package/ui/local-login.helper.d.ts +31 -0
  71. package/ui/local-login.helper.d.ts.map +1 -0
  72. package/ui/templates.d.ts +118 -2
  73. package/ui/templates.d.ts.map +1 -1
  74. package/vault/auth-providers.types.d.ts +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAEL,0BAA0B,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B,0BAA0B,EAC1B,yBAAyB,EACzB,gCAAgC,GACjC,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACpF,YAAY,EAAE,uCAAuC,EAAE,MAAM,kCAAkC,CAAC;AAGhG,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,YAAY,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAG1E,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACnH,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAG1F,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpG,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Orchestrated token-record encryption helpers.
3
+ *
4
+ * Shared by {@link InMemoryOrchestratedTokenStore} and
5
+ * {@link StorageOrchestratedTokenStore} so both apply byte-for-byte identical
6
+ * AES-256-GCM encryption: a per-composite-key subkey is derived from the master
7
+ * `encryptionKey` via HKDF-SHA256, and the record JSON is sealed with a random
8
+ * 12-byte IV. The envelope is a base64url JSON `{ iv, tag, data }`.
9
+ */
10
+ /**
11
+ * Internal token record structure (upstream provider tokens).
12
+ */
13
+ export interface ProviderTokenRecord {
14
+ accessToken: string;
15
+ refreshToken?: string;
16
+ expiresAt?: number;
17
+ createdAt: number;
18
+ updatedAt: number;
19
+ }
20
+ /**
21
+ * Derive a per-record AES key from the master key + composite key via HKDF.
22
+ * Results are cached in `cache` (keyed by composite key) to avoid recomputation.
23
+ */
24
+ export declare function deriveKeyForRecord(masterKey: Uint8Array, compositeKey: string, cache: Map<string, Uint8Array>): Uint8Array;
25
+ /**
26
+ * Encrypt a token record into a base64url JSON envelope string.
27
+ */
28
+ export declare function encryptRecord(key: Uint8Array, record: ProviderTokenRecord): string;
29
+ /**
30
+ * Decrypt a base64url JSON envelope string back into a token record.
31
+ */
32
+ export declare function decryptRecord(key: Uint8Array, encrypted: string): ProviderTokenRecord;
33
+ //# sourceMappingURL=orchestrated-token.crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrated-token.crypto.d.ts","sourceRoot":"","sources":["../../src/session/orchestrated-token.crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAID;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAC7B,UAAU,CASZ;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM,CASlF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,mBAAmB,CAOrF"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * SecureStoreAccessor — the `this.secureStore` ToolContext / auth-UI API (#470).
3
+ *
4
+ * A typed accessor over a {@link SecureStoreBackend} that tools (and the auth
5
+ * UI) read/write user-typed secrets through, scoped to the current
6
+ * session/subject. It owns scope resolution, JSON (de)serialization of typed
7
+ * values, and TTLs — so server authors never re-implement crypto, key
8
+ * derivation, scope, or persistence (the whole point of #470).
9
+ *
10
+ * This is the GENERAL secret store. It is distinct from `this.credentials`,
11
+ * which remains the OAuth-credential-centric vault (`requireConnect` resume
12
+ * URLs, per-authorize vault rotation). #464's `this.credentials` is unchanged.
13
+ */
14
+ import { type Token } from '@frontmcp/di';
15
+ /**
16
+ * Runtime accessor for session-scoped secure secrets, available on tool
17
+ * contexts (and the auth UI) as `this.secureStore`:
18
+ *
19
+ * ```typescript
20
+ * @Tool({ name: 'call_api' })
21
+ * class CallApiTool extends ToolContext {
22
+ * async execute(input: Input): Promise<Output> {
23
+ * await this.secureStore.set('stg.api-key', input.apiKey);
24
+ * const key = await this.secureStore.get<string>('stg.api-key');
25
+ * const all = await this.secureStore.list();
26
+ * // …
27
+ * }
28
+ * }
29
+ * ```
30
+ *
31
+ * Values are JSON-serialized, so any JSON-safe type round-trips. The namespace
32
+ * is resolved from the configured `auth.secureStore.scope` (the authenticated
33
+ * `sub` for `user`, the transport `sessionId` for `session`, or a fixed
34
+ * server-wide namespace for `global`).
35
+ */
36
+ export interface SecureStoreAccessor {
37
+ /**
38
+ * Read a secret by key for the current scope, JSON-parsed into `T`. Returns
39
+ * `undefined` when the key is absent, when the scope cannot be resolved (e.g.
40
+ * an anonymous request under `user` scope), or when decryption/parse fails.
41
+ */
42
+ get<T = string>(key: string): Promise<T | undefined>;
43
+ /**
44
+ * Store a JSON-serializable `value` under `key` for the current scope.
45
+ * Optionally bounded by `ttlMs`. Resolves without writing (and logs at debug)
46
+ * when the scope cannot be resolved for the current request.
47
+ */
48
+ set<T = string>(key: string, value: T, options?: SecureStoreSetOptions): Promise<void>;
49
+ /**
50
+ * Delete a secret by key for the current scope. Returns `true` when a value
51
+ * existed and was removed; `false` otherwise (including when the scope cannot
52
+ * be resolved).
53
+ */
54
+ delete(key: string): Promise<boolean>;
55
+ /**
56
+ * List the secret keys present for the current scope. Empty when the scope
57
+ * cannot be resolved or when no secrets are stored.
58
+ */
59
+ list(): Promise<string[]>;
60
+ }
61
+ /**
62
+ * Options for {@link SecureStoreAccessor.set}.
63
+ */
64
+ export interface SecureStoreSetOptions {
65
+ /**
66
+ * Time-to-live in milliseconds. Backends that cannot honor a TTL (e.g. an OS
67
+ * keychain) ignore it. Falls back to the configured `auth.secureStore.ttlMs`
68
+ * when omitted.
69
+ */
70
+ ttlMs?: number;
71
+ }
72
+ /**
73
+ * DI token for {@link SecureStoreAccessor}. Resolved by the `this.secureStore`
74
+ * context extension.
75
+ */
76
+ export declare const SECURE_STORE_ACCESSOR: Token<SecureStoreAccessor>;
77
+ //# sourceMappingURL=secure-store-accessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-store-accessor.d.ts","sourceRoot":"","sources":["../../src/session/secure-store-accessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAErD;;;;OAIG;IACH,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvF;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAmD,KAAK,CAAC,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * SecureStoreAccessorImpl — request-scoped implementation of the
3
+ * `this.secureStore` accessor (#470).
4
+ *
5
+ * Binds a {@link SecureStoreBackend} to the current request's resolved scope
6
+ * namespace and handles JSON (de)serialization of typed values. The namespace
7
+ * is derived from the configured {@link SecureStoreScope}:
8
+ * - `user`: the authenticated `sub` (resolved lazily via `resolveSub`),
9
+ * - `session`: the transport `sessionId` (resolved via `resolveSessionId`),
10
+ * - `global`: a single fixed server-wide namespace.
11
+ *
12
+ * Identities are hashed into the namespace (never stored raw) so storage keys
13
+ * carry no PII, and so the backend cannot correlate the raw subject/session.
14
+ */
15
+ import { type AuthLogger } from '../common/auth-logger.interface';
16
+ import { type SecureStoreBackend, type SecureStoreScope } from './secure-store';
17
+ import { type SecureStoreAccessor, type SecureStoreSetOptions } from './secure-store-accessor';
18
+ /**
19
+ * Dependencies for {@link SecureStoreAccessorImpl}.
20
+ */
21
+ export interface SecureStoreAccessorDeps {
22
+ /** The secure-store backing (built-in encrypted-storage, or a custom one). */
23
+ backend: SecureStoreBackend;
24
+ /** Configured scope strategy. @default 'user' */
25
+ scope?: SecureStoreScope;
26
+ /**
27
+ * Resolve the current request's authenticated subject. Returns undefined for
28
+ * anonymous/unauthenticated requests (so `user` scope is unavailable then).
29
+ */
30
+ resolveSub: () => string | undefined;
31
+ /**
32
+ * Resolve the current request's transport session id. Returns undefined when
33
+ * there is no session (so `session` scope is unavailable then).
34
+ */
35
+ resolveSessionId: () => string | undefined;
36
+ /** Default TTL (ms) applied to writes when `set` omits one. */
37
+ ttlMs?: number;
38
+ /** Scoped logger. */
39
+ logger?: AuthLogger;
40
+ }
41
+ export declare class SecureStoreAccessorImpl implements SecureStoreAccessor {
42
+ private readonly backend;
43
+ private readonly scope;
44
+ private readonly resolveSub;
45
+ private readonly resolveSessionId;
46
+ private readonly ttlMs?;
47
+ private readonly logger;
48
+ constructor(deps: SecureStoreAccessorDeps);
49
+ /**
50
+ * Resolve the namespace for the current request from the configured scope.
51
+ * Returns undefined when the scope's identity is unavailable (anonymous user
52
+ * under `user` scope, or no session under `session` scope), in which case
53
+ * reads return empty and writes are skipped.
54
+ */
55
+ private resolveNamespace;
56
+ get<T = string>(key: string): Promise<T | undefined>;
57
+ set<T = string>(key: string, value: T, options?: SecureStoreSetOptions): Promise<void>;
58
+ delete(key: string): Promise<boolean>;
59
+ list(): Promise<string[]>;
60
+ }
61
+ //# sourceMappingURL=secure-store-accessor.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-store-accessor.impl.d.ts","sourceRoot":"","sources":["../../src/session/secure-store-accessor.impl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAK/F;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,8EAA8E;IAC9E,OAAO,EAAE,kBAAkB,CAAC;IAC5B,iDAAiD;IACjD,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB;;;OAGG;IACH,UAAU,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACrC;;;OAGG;IACH,gBAAgB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAC3C,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,qBAAa,uBAAwB,YAAW,mBAAmB;IACjE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA2B;IACtD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA2B;IAC5D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;gBAExB,IAAI,EAAE,uBAAuB;IASzC;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAgBlB,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAapD,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAUtF,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMrC,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAKhC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Built-in {@link SecureStoreBackend} implementations for the session-scoped
3
+ * secure-secret store (#470).
4
+ *
5
+ * Both built-ins REUSE existing infra rather than re-implementing crypto:
6
+ * - {@link EncryptedStorageSecureStoreBackend} wraps any `StorageAdapter`
7
+ * (memory / sqlite / redis — built via {@link createTokenStorageAdapter}) and
8
+ * encrypts every value at rest with the shared {@link VaultEncryption}
9
+ * primitive (AES-256-GCM, HKDF-SHA256). The in-memory backing is simply this
10
+ * backend over a `MemoryStorageAdapter`, so even the `'memory'` backing keeps
11
+ * secrets encrypted in the process heap (closing the in-memory side of #464).
12
+ *
13
+ * A backend keys solely on the `(namespace, key)` pair it is handed; the
14
+ * accessor resolves `namespace` from the request scope before calling in.
15
+ */
16
+ import { type StorageAdapter } from '@frontmcp/utils';
17
+ import { type AuthLogger } from '../common/auth-logger.interface';
18
+ import { type SecureStoreBackend } from './secure-store';
19
+ /**
20
+ * Options for {@link EncryptedStorageSecureStoreBackend}.
21
+ */
22
+ export interface EncryptedStorageSecureStoreBackendOptions {
23
+ /** Connected storage adapter backing the store (memory / sqlite / redis). */
24
+ storage: StorageAdapter;
25
+ /**
26
+ * Master pepper for key derivation. Defense-in-depth: even with the stored
27
+ * ciphertext an attacker still needs this pepper to derive the AES key. When
28
+ * omitted, an empty pepper is used (the caller — LocalPrimaryAuth — passes the
29
+ * server JWT/VAULT secret).
30
+ */
31
+ pepper?: string;
32
+ /** Key prefix for all stored keys. @default 'mcp:secret:' */
33
+ keyPrefix?: string;
34
+ /** Scoped logger. @default noop */
35
+ logger?: AuthLogger;
36
+ }
37
+ /**
38
+ * `StorageAdapter`-backed secure-store backend with AES-256-GCM at-rest
39
+ * encryption via {@link VaultEncryption}.
40
+ *
41
+ * Storage key layout (no PII; the namespace is an opaque hash/identity handed in
42
+ * by the accessor):
43
+ * - `secret:keys:<namespace>` → JSON array of key names (the key SET).
44
+ * - `secret:data:<namespace>:<key>` → encrypted {@link EncryptedSecretRecord}.
45
+ *
46
+ * The per-namespace AES key is derived (and cached) from the namespace + pepper,
47
+ * so a value written under one namespace cannot be decrypted under another.
48
+ */
49
+ export declare class EncryptedStorageSecureStoreBackend implements SecureStoreBackend {
50
+ private readonly storage;
51
+ private readonly encryption;
52
+ private readonly keyPrefix;
53
+ private readonly logger;
54
+ /** Cache of derived AES keys, keyed by namespace. */
55
+ private readonly keyCache;
56
+ constructor(options: EncryptedStorageSecureStoreBackendOptions);
57
+ /** `secret:keys:<namespace>` → JSON array of key names. */
58
+ private keysKey;
59
+ /** `secret:data:<namespace>:<key>` → encrypted record. */
60
+ private dataKey;
61
+ /**
62
+ * Derive (and cache) the AES-256 key for a namespace. The namespace acts as
63
+ * the HKDF salt material, so values are cryptographically isolated per scope.
64
+ */
65
+ private deriveKey;
66
+ private setOpts;
67
+ get(namespace: string, key: string): Promise<string | null>;
68
+ set(namespace: string, key: string, value: string, ttlMs?: number): Promise<void>;
69
+ delete(namespace: string, key: string): Promise<boolean>;
70
+ list(namespace: string): Promise<string[]>;
71
+ private readKeySet;
72
+ private writeKeySet;
73
+ private addKeyToSet;
74
+ }
75
+ //# sourceMappingURL=secure-store-backends.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-store-backends.d.ts","sourceRoot":"","sources":["../../src/session/secure-store-backends.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAYzD;;GAEG;AACH,MAAM,WAAW,yCAAyC;IACxD,6EAA6E;IAC7E,OAAO,EAAE,cAAc,CAAC;IACxB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,kCAAmC,YAAW,kBAAkB;IAC3E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0C;gBAEvD,OAAO,EAAE,yCAAyC;IAc9D,2DAA2D;IAC3D,OAAO,CAAC,OAAO;IAIf,0DAA0D;IAC1D,OAAO,CAAC,OAAO;IAIf;;;OAGG;IACH,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,OAAO;IAQT,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAc3D,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASjF,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAUxD,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YAQlC,UAAU;YAWV,WAAW;YAKX,WAAW;CAO1B"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * SecureStoreBackend — the pluggable backing contract for the general
3
+ * session-scoped secure-secret store (#470).
4
+ *
5
+ * Unlike {@link SessionCredentialVault} (which is OAuth-credential-centric:
6
+ * `sub`-keyed, vault-rotation on every authorize, resume-URL `requireConnect`),
7
+ * this is a GENERAL key→secret store for arbitrary user-typed secrets that a
8
+ * tool or auth-UI reads/writes through `this.secureStore`. The backing is
9
+ * selectable per deployment (memory / sqlite / redis / a custom — e.g.
10
+ * OS-keychain — backend) WITHOUT the framework bundling any native dependency.
11
+ *
12
+ * Security model
13
+ * --------------
14
+ * - Every value is namespaced by a `ScopeRef` ({@link SecureStoreScopeRef}) so a
15
+ * `user`-scoped secret keys by the authenticated `sub`, a `session`-scoped one
16
+ * by the transport `sessionId`, and a `global`-scoped one by a fixed
17
+ * namespace. The accessor (`this.secureStore`) resolves the namespace from the
18
+ * request before calling a backend, so a backend NEVER sees raw identities it
19
+ * has not been handed.
20
+ * - Built-in backends encrypt values at rest with the shared
21
+ * {@link VaultEncryption} primitive (AES-256-GCM, HKDF-SHA256 keyed by the
22
+ * namespace + a server pepper). A CUSTOM backend (e.g. an OS keychain) owns
23
+ * its own at-rest protection — the OS keychain is encrypted by the OS, so the
24
+ * keychain backend stores the plaintext value and relies on the OS for
25
+ * confidentiality.
26
+ *
27
+ * A backend deals ONLY in `(namespace, key) → string` — JSON serialization of
28
+ * typed values is handled one layer up by the accessor.
29
+ */
30
+ /**
31
+ * The resolved namespace a {@link SecureStoreBackend} operates within. Produced
32
+ * by the accessor from the current request + configured scope, NEVER by the
33
+ * backend itself. Carries the scope kind purely for diagnostics/logging; a
34
+ * backend keys solely on {@link namespace}.
35
+ */
36
+ export interface SecureStoreScopeRef {
37
+ /** The resolved namespace (already incorporates the scope + identity). */
38
+ namespace: string;
39
+ /** Which scope produced this namespace (for diagnostics only). */
40
+ scope: SecureStoreScope;
41
+ }
42
+ /**
43
+ * How a secure-store namespace is derived from the current request:
44
+ * - `user` (default): keyed by the authenticated subject (`sub`). Survives a
45
+ * reconnect for the same user.
46
+ * - `session`: keyed by the transport `sessionId`. Disappears when the session
47
+ * ends.
48
+ * - `global`: a single shared namespace (server-wide). Use for operator-level
49
+ * secrets that are not tied to any one user/session.
50
+ */
51
+ export type SecureStoreScope = 'user' | 'session' | 'global';
52
+ /**
53
+ * Pluggable backing for the session-scoped secure-secret store.
54
+ *
55
+ * Implement this to provide a custom backing (e.g. an OS keychain) and wire it
56
+ * via `auth.secureStore: { backend: myBackend }`. All four methods operate
57
+ * within an explicit, already-resolved `namespace` so the same backend instance
58
+ * can safely serve every scope/identity.
59
+ */
60
+ export interface SecureStoreBackend {
61
+ /**
62
+ * Read a stored value by key within `namespace`. Returns `null` when the key
63
+ * is absent (mirrors `StorageAdapter.get`).
64
+ */
65
+ get(namespace: string, key: string): Promise<string | null>;
66
+ /**
67
+ * Store `value` under `key` within `namespace`. `ttlMs` (when supported by
68
+ * the backend) bounds the lifetime; backends that cannot honor a TTL (e.g. an
69
+ * OS keychain) MUST ignore it rather than reject the write.
70
+ */
71
+ set(namespace: string, key: string, value: string, ttlMs?: number): Promise<void>;
72
+ /**
73
+ * Delete `key` within `namespace`. Returns `true` when a value existed and was
74
+ * removed, `false` otherwise. Idempotent.
75
+ */
76
+ delete(namespace: string, key: string): Promise<boolean>;
77
+ /**
78
+ * List the keys present within `namespace`. Returns an empty array when the
79
+ * namespace is empty.
80
+ */
81
+ list(namespace: string): Promise<string[]>;
82
+ /**
83
+ * Optional lifecycle hook. Backends that own a connection/handle (e.g. a
84
+ * keychain session) may close it here. The built-in adapter-backed backend
85
+ * does NOT dispose the shared adapter (it is owned by the auth layer).
86
+ */
87
+ dispose?(): Promise<void>;
88
+ }
89
+ //# sourceMappingURL=secure-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-store.d.ts","sourceRoot":"","sources":["../../src/session/secure-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE5D;;;;OAIG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElF;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEzD;;;OAGG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAE3C;;;;OAIG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Secure-store backend factory (#470).
3
+ *
4
+ * Builds a {@link SecureStoreBackend} from an `auth.secureStore`
5
+ * {@link SecureStoreConfig}, mirroring {@link createTokenStorageAdapter}'s
6
+ * selection pattern:
7
+ *
8
+ * - `'memory'` / object-without-backing → in-memory `StorageAdapter` wrapped in
9
+ * the AES-256-GCM-encrypted {@link EncryptedStorageSecureStoreBackend}.
10
+ * - `{ sqlite }` / `{ redis }` → persistent `StorageAdapter` (via
11
+ * {@link createTokenStorageAdapter}) wrapped in the same encrypted backend.
12
+ * - `{ backend }` → the user-supplied custom backing is used AS-IS (e.g. an OS
13
+ * keychain). The framework bundles NO native dependency for this path.
14
+ *
15
+ * The dependency direction matches the CLAUDE.md storage-factory pattern: SQLite
16
+ * is reached lazily through `createTokenStorageAdapter`, so `better-sqlite3` /
17
+ * `ioredis` stay out of bundles that don't use them.
18
+ */
19
+ import { type StorageAdapter } from '@frontmcp/utils';
20
+ import { type AuthLogger } from '../common/auth-logger.interface';
21
+ import { type SecureStoreConfig } from '../options/interfaces';
22
+ import { type SecureStoreBackend, type SecureStoreScope } from './secure-store';
23
+ /** The backing kind a {@link SecureStoreConfig} resolves to. */
24
+ export type SecureStoreBackendKind = 'memory' | 'sqlite' | 'redis' | 'custom';
25
+ /**
26
+ * Resolved view of a {@link SecureStoreConfig}: the constructed backend, the
27
+ * namespace scope, the default TTL, and the backing kind (for diagnostics).
28
+ */
29
+ export interface ResolvedSecureStore {
30
+ backend: SecureStoreBackend;
31
+ scope: SecureStoreScope;
32
+ ttlMs?: number;
33
+ kind: SecureStoreBackendKind;
34
+ }
35
+ /**
36
+ * Options for {@link createSecureStore}.
37
+ */
38
+ export interface CreateSecureStoreOptions {
39
+ /** The `auth.secureStore` config. `undefined` → in-memory default. */
40
+ config: SecureStoreConfig | undefined;
41
+ /**
42
+ * Master pepper for the built-in encrypted backings. Used when the config
43
+ * does not carry an explicit `encryption.pepper`. Typically the server
44
+ * JWT/VAULT secret.
45
+ */
46
+ pepper?: string;
47
+ /**
48
+ * Optionally reuse an already-connected adapter for the built-in encrypted
49
+ * backing instead of building one from the config. When provided, the
50
+ * sqlite/redis selection is NOT used to build an adapter (it still informs the
51
+ * reported `kind`). Ignored for the `{ backend }` (custom) path.
52
+ */
53
+ storage?: StorageAdapter;
54
+ /** Scoped logger. */
55
+ logger?: AuthLogger;
56
+ }
57
+ /**
58
+ * Create a {@link SecureStoreBackend} (plus resolved scope/ttl/kind) for the
59
+ * given `auth.secureStore` config.
60
+ */
61
+ export declare function createSecureStore(options: CreateSecureStoreOptions): Promise<ResolvedSecureStore>;
62
+ //# sourceMappingURL=secure-store.factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-store.factory.d.ts","sourceRoot":"","sources":["../../src/session/secure-store.factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,KAAK,iBAAiB,EAA0D,MAAM,uBAAuB,CAAC;AACvH,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKhF,gEAAgE;AAChE,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE9E;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,sBAAsB,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,sEAAsE;IACtE,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACtC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,qBAAqB;IACrB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AA8DD;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA8BvG"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * SessionCredentialVault — per-session, AES-256-GCM-encrypted credential store
3
+ * (Checkpoint 3b).
4
+ *
5
+ * Persists the `credentials` a local `authenticate()` verifier returns
6
+ * (Checkpoint 3a accepted-and-ignored them) and exposes them to tools via the
7
+ * `this.credentials` ToolContext accessor.
8
+ *
9
+ * Security model
10
+ * --------------
11
+ * - Credentials are keyed by the authenticated subject (`sub`) behind a
12
+ * `sub → vaultId` indirection. Every fresh authorize mints a NEW random
13
+ * `vaultId` ({@link SessionCredentialVault.rotateVault}); the per-record
14
+ * encryption key is derived (HKDF salt) from that `vaultId`, so when a user
15
+ * disconnects and reconnects the old ciphertext becomes undecryptable and the
16
+ * reconnected session sees an EMPTY vault (per-session rotation).
17
+ * - At-rest encryption is AES-256-GCM via the shared {@link VaultEncryption}
18
+ * primitive. The master pepper comes from `VAULT_SECRET ?? JWT_SECRET`; when
19
+ * neither is set a random per-process pepper is used and a warning is logged
20
+ * (credentials then do not survive a restart — fail-safe, never plaintext).
21
+ * - The plaintext `secret` and `metadata` are NEVER written unencrypted. Only
22
+ * the unencrypted index (key names, vaultId pointer) is stored in the clear,
23
+ * and it carries no PII.
24
+ *
25
+ * Construct via {@link createSessionCredentialVault} (CLAUDE.md storage-factory
26
+ * pattern) so the same `auth.tokenStorage` config backs both the token stores
27
+ * and this vault.
28
+ */
29
+ import { type StorageAdapter } from '@frontmcp/utils';
30
+ import { type AuthLogger } from '../common/auth-logger.interface';
31
+ /**
32
+ * A stored credential value: the secret plus optional non-secret metadata.
33
+ */
34
+ export interface StoredCredential {
35
+ /** The secret value (token, api key, …). Encrypted at rest. */
36
+ secret: string;
37
+ /** Optional non-secret metadata stored alongside the credential (encrypted). */
38
+ metadata?: Record<string, unknown>;
39
+ }
40
+ /**
41
+ * Options for {@link SessionCredentialVault}.
42
+ */
43
+ export interface SessionCredentialVaultOptions {
44
+ /** Connected storage adapter backing the vault (memory / Redis / SQLite). */
45
+ storage: StorageAdapter;
46
+ /**
47
+ * Master pepper for key derivation. When omitted, falls back to
48
+ * `VAULT_SECRET ?? JWT_SECRET`, and finally a random per-process value (with a
49
+ * warning). Defense-in-depth: even with a stolen vaultId an attacker still
50
+ * needs this pepper to derive the AES key.
51
+ */
52
+ pepper?: string;
53
+ /** Key prefix for all stored keys. @default 'mcp:cred:' */
54
+ keyPrefix?: string;
55
+ /** TTL (ms) for credential entries. @default undefined (no expiry) */
56
+ ttlMs?: number;
57
+ /** TTL (ms) for the pending-authorize accumulator. @default 600000 (10 min) */
58
+ pendingTtlMs?: number;
59
+ /** Scoped logger. @default noop */
60
+ logger?: AuthLogger;
61
+ }
62
+ /**
63
+ * Per-session encrypted credential vault.
64
+ *
65
+ * @see createSessionCredentialVault for the factory entry point.
66
+ */
67
+ export declare class SessionCredentialVault {
68
+ private readonly storage;
69
+ private readonly encryption;
70
+ private readonly keyPrefix;
71
+ private readonly ttlMs?;
72
+ private readonly pendingTtlMs;
73
+ private readonly logger;
74
+ /** Cache of derived AES keys, keyed by `${sub}:${vaultId}`. */
75
+ private readonly keyCache;
76
+ constructor(options: SessionCredentialVaultOptions);
77
+ /** `cred:idx:<sub>` → current vaultId (the sub → vaultId indirection). */
78
+ private indexKey;
79
+ /** `cred:keys:<sub>:<vaultId>` → JSON array of credential key names (the SET). */
80
+ private keysKey;
81
+ /** `cred:data:<sub>:<vaultId>:<key>` → encrypted credential record. */
82
+ private dataKey;
83
+ /** `cred:pending:<pendingId>` → encrypted pending-authorize accumulator. */
84
+ private pendingKey;
85
+ /** Convert the configured `ttlMs` into `SetOptions` (storage uses `ttlSeconds`). */
86
+ private get credentialSetOpts();
87
+ /**
88
+ * Derive (and cache) the AES-256 key for a `(sub, vaultId)` pair. The vaultId
89
+ * acts as the HKDF salt, so rotating it makes prior ciphertext undecryptable.
90
+ */
91
+ private deriveKey;
92
+ /**
93
+ * Read the current vaultId for a subject, or undefined when the subject has no
94
+ * live vault (never authorized, or rotated away).
95
+ */
96
+ getVaultId(sub: string): Promise<string | undefined>;
97
+ /**
98
+ * Mint a FRESH vaultId for a subject and point the indirection at it. Called
99
+ * at the start of each authorize so reconnect = empty vault. Returns the new
100
+ * vaultId. The old vaultId's ciphertext is left in storage but is
101
+ * unreachable (no index pointer) and undecryptable (different derived key);
102
+ * it expires via TTL when configured.
103
+ */
104
+ rotateVault(sub: string): Promise<string>;
105
+ /**
106
+ * Encrypt + store a single credential into the vault identified by
107
+ * `(sub, vaultId)` and add its key to the key set. Used both to commit
108
+ * authorize-time credentials and to additively add a credential mid-session.
109
+ */
110
+ store(sub: string, vaultId: string, key: string, value: StoredCredential): Promise<void>;
111
+ /**
112
+ * Decrypt and return a credential by key for a subject's CURRENT vault.
113
+ * Returns undefined when there is no live vault or no such key, or when
114
+ * decryption fails (e.g. a stale pointer to rotated-away ciphertext).
115
+ */
116
+ get(sub: string, key: string): Promise<StoredCredential | undefined>;
117
+ /**
118
+ * List the credential keys available in a subject's current vault. Returns an
119
+ * empty array when there is no live vault (e.g. after rotation on reconnect).
120
+ */
121
+ list(sub: string): Promise<string[]>;
122
+ /**
123
+ * Remove a credential by key from a subject's current vault (deletes the
124
+ * ciphertext and drops the key from the set). No-op when absent.
125
+ */
126
+ remove(sub: string, key: string): Promise<void>;
127
+ /**
128
+ * Stage credentials returned by `authenticate()` under a pending id, encrypted
129
+ * against a freshly-rotated vaultId for `sub`. They are NOT visible to tools
130
+ * until {@link commit} flushes them — this lets the authorize flow accumulate
131
+ * credentials before the subject's identity is final.
132
+ *
133
+ * @returns the vaultId the credentials were staged against.
134
+ */
135
+ stage(pendingId: string, sub: string, credentials: Array<{
136
+ key: string;
137
+ } & StoredCredential>): Promise<string>;
138
+ /**
139
+ * Flush a staged batch into the live vault, binding it to `sub`. The staged
140
+ * batch's `sub` must equal the supplied `sub` (the one baked into the minted
141
+ * token) — a mismatch is refused so credentials can never be committed under a
142
+ * different identity than the one that will read them.
143
+ *
144
+ * @returns true when a batch was committed, false when none was staged.
145
+ */
146
+ commit(pendingId: string, sub: string): Promise<boolean>;
147
+ private readKeySet;
148
+ private writeKeySet;
149
+ private addKeyToSet;
150
+ /** Strip undefined metadata so the encrypted JSON stays minimal. */
151
+ private normalize;
152
+ }
153
+ //# sourceMappingURL=session-credential-vault.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-credential-vault.d.ts","sourceRoot":"","sources":["../../src/session/session-credential-vault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAuC,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE3F,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,6EAA6E;IAC7E,OAAO,EAAE,cAAc,CAAC;IACxB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,MAA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