@frontmcp/auth 0.0.1 → 0.8.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 (81) hide show
  1. package/README.md +11 -0
  2. package/authorization/authorization.types.d.ts +236 -0
  3. package/authorization/authorization.types.d.ts.map +1 -0
  4. package/authorization/index.d.ts +9 -0
  5. package/authorization/index.d.ts.map +1 -0
  6. package/cimd/cimd-redis.cache.d.ts +111 -0
  7. package/cimd/cimd-redis.cache.d.ts.map +1 -0
  8. package/cimd/cimd.cache.d.ts +200 -0
  9. package/cimd/cimd.cache.d.ts.map +1 -0
  10. package/cimd/cimd.errors.d.ts +124 -0
  11. package/cimd/cimd.errors.d.ts.map +1 -0
  12. package/cimd/cimd.logger.d.ts +39 -0
  13. package/cimd/cimd.logger.d.ts.map +1 -0
  14. package/cimd/cimd.service.d.ts +88 -0
  15. package/cimd/cimd.service.d.ts.map +1 -0
  16. package/cimd/cimd.types.d.ts +178 -0
  17. package/cimd/cimd.types.d.ts.map +1 -0
  18. package/cimd/cimd.validator.d.ts +49 -0
  19. package/cimd/cimd.validator.d.ts.map +1 -0
  20. package/cimd/index.d.ts +17 -0
  21. package/cimd/index.d.ts.map +1 -0
  22. package/esm/index.mjs +4001 -0
  23. package/esm/package.json +59 -0
  24. package/index.d.ts +44 -0
  25. package/index.d.ts.map +1 -0
  26. package/index.js +4131 -0
  27. package/jwks/dev-key-persistence.d.ts +70 -0
  28. package/jwks/dev-key-persistence.d.ts.map +1 -0
  29. package/jwks/index.d.ts +20 -0
  30. package/jwks/index.d.ts.map +1 -0
  31. package/jwks/jwks.service.d.ts +69 -0
  32. package/jwks/jwks.service.d.ts.map +1 -0
  33. package/jwks/jwks.types.d.ts +33 -0
  34. package/jwks/jwks.types.d.ts.map +1 -0
  35. package/jwks/jwks.utils.d.ts +5 -0
  36. package/jwks/jwks.utils.d.ts.map +1 -0
  37. package/package.json +2 -2
  38. package/session/authorization-vault.d.ts +667 -0
  39. package/session/authorization-vault.d.ts.map +1 -0
  40. package/session/authorization.store.d.ts +311 -0
  41. package/session/authorization.store.d.ts.map +1 -0
  42. package/session/index.d.ts +19 -0
  43. package/session/index.d.ts.map +1 -0
  44. package/session/storage/in-memory-authorization-vault.d.ts +53 -0
  45. package/session/storage/in-memory-authorization-vault.d.ts.map +1 -0
  46. package/session/storage/index.d.ts +17 -0
  47. package/session/storage/index.d.ts.map +1 -0
  48. package/session/storage/storage-authorization-vault.d.ts +107 -0
  49. package/session/storage/storage-authorization-vault.d.ts.map +1 -0
  50. package/session/storage/storage-token-store.d.ts +92 -0
  51. package/session/storage/storage-token-store.d.ts.map +1 -0
  52. package/session/token.store.d.ts +39 -0
  53. package/session/token.store.d.ts.map +1 -0
  54. package/session/token.vault.d.ts +33 -0
  55. package/session/token.vault.d.ts.map +1 -0
  56. package/session/utils/index.d.ts +5 -0
  57. package/session/utils/index.d.ts.map +1 -0
  58. package/session/utils/tiny-ttl-cache.d.ts +20 -0
  59. package/session/utils/tiny-ttl-cache.d.ts.map +1 -0
  60. package/session/vault-encryption.d.ts +190 -0
  61. package/session/vault-encryption.d.ts.map +1 -0
  62. package/ui/base-layout.d.ts +170 -0
  63. package/ui/base-layout.d.ts.map +1 -0
  64. package/ui/index.d.ts +10 -0
  65. package/ui/index.d.ts.map +1 -0
  66. package/ui/templates.d.ts +134 -0
  67. package/ui/templates.d.ts.map +1 -0
  68. package/utils/audience.validator.d.ts +130 -0
  69. package/utils/audience.validator.d.ts.map +1 -0
  70. package/utils/index.d.ts +8 -0
  71. package/utils/index.d.ts.map +1 -0
  72. package/utils/www-authenticate.utils.d.ts +98 -0
  73. package/utils/www-authenticate.utils.d.ts.map +1 -0
  74. package/vault/auth-providers.types.d.ts +262 -0
  75. package/vault/auth-providers.types.d.ts.map +1 -0
  76. package/vault/credential-cache.d.ts +98 -0
  77. package/vault/credential-cache.d.ts.map +1 -0
  78. package/vault/credential-helpers.d.ts +14 -0
  79. package/vault/credential-helpers.d.ts.map +1 -0
  80. package/vault/index.d.ts +10 -0
  81. package/vault/index.d.ts.map +1 -0
@@ -0,0 +1,70 @@
1
+ import { JSONWebKeySet } from 'jose';
2
+ /**
3
+ * Data structure for persisted development keys
4
+ * @deprecated Use `AsymmetricKeyData` from `@frontmcp/utils` instead.
5
+ */
6
+ export interface DevKeyData {
7
+ /** Key ID (kid) */
8
+ kid: string;
9
+ /** Private key in JWK format (portable) */
10
+ privateKey: JsonWebKey;
11
+ /** Public JWKS for verification */
12
+ publicJwk: JSONWebKeySet;
13
+ /** Key creation timestamp (ms) */
14
+ createdAt: number;
15
+ /** Algorithm used */
16
+ alg: 'RS256' | 'ES256';
17
+ }
18
+ /**
19
+ * Options for dev key persistence
20
+ */
21
+ export interface DevKeyPersistenceOptions {
22
+ /**
23
+ * Path to store dev keys
24
+ * @default '.frontmcp/dev-keys.json'
25
+ */
26
+ keyPath?: string;
27
+ /**
28
+ * Enable persistence in production (NOT RECOMMENDED)
29
+ * @default false
30
+ */
31
+ forceEnable?: boolean;
32
+ }
33
+ /**
34
+ * Check if dev key persistence is enabled based on environment and options
35
+ * @deprecated Use `createKeyPersistence` from `@frontmcp/utils` instead.
36
+ */
37
+ export declare function isDevKeyPersistenceEnabled(options?: DevKeyPersistenceOptions): boolean;
38
+ /**
39
+ * Resolve the key file path
40
+ * @deprecated Use `createKeyPersistence` from `@frontmcp/utils` instead.
41
+ */
42
+ export declare function resolveKeyPath(options?: DevKeyPersistenceOptions): string;
43
+ /**
44
+ * Load persisted dev key from file
45
+ *
46
+ * @param options - Persistence options
47
+ * @returns The loaded key data or null if not found/invalid
48
+ * @deprecated Use `createKeyPersistence` from `@frontmcp/utils` and call `getAsymmetric(kid)` instead.
49
+ */
50
+ export declare function loadDevKey(options?: DevKeyPersistenceOptions): Promise<DevKeyData | null>;
51
+ /**
52
+ * Save dev key to file
53
+ *
54
+ * Uses atomic write (temp file + rename) to prevent corruption.
55
+ * Sets file permissions to 0o600 (owner read/write only) for security.
56
+ *
57
+ * @param keyData - Key data to persist
58
+ * @param options - Persistence options
59
+ * @returns true if save succeeded, false otherwise
60
+ * @deprecated Use `createKeyPersistence` from `@frontmcp/utils` and call `set(asymmetricKeyData)` instead.
61
+ */
62
+ export declare function saveDevKey(keyData: DevKeyData, options?: DevKeyPersistenceOptions): Promise<boolean>;
63
+ /**
64
+ * Delete persisted dev key
65
+ *
66
+ * @param options - Persistence options
67
+ * @deprecated Use `createKeyPersistence` from `@frontmcp/utils` and call `delete(kid)` instead.
68
+ */
69
+ export declare function deleteDevKey(options?: DevKeyPersistenceOptions): Promise<void>;
70
+ //# sourceMappingURL=dev-key-persistence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-key-persistence.d.ts","sourceRoot":"","sources":["../../src/jwks/dev-key-persistence.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAIrC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,mBAAmB;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,UAAU,EAAE,UAAU,CAAC;IACvB,mCAAmC;IACnC,SAAS,EAAE,aAAa,CAAC;IACzB,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACrB,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AA2GD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAUtF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,MAAM,CAUzE;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA6B/F;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,OAAO,CAAC,CAgC1G;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAWpF"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * JWKS Module
3
+ *
4
+ * JSON Web Key Set management for JWT signing and verification.
5
+ */
6
+ export type { JwksServiceOptions, ProviderVerifyRef, VerifyResult, DevKeyPersistenceOptions } from './jwks.types';
7
+ export { JwksService } from './jwks.service';
8
+ export { trimSlash, normalizeIssuer, decodeJwtPayloadSafe } from './jwks.utils';
9
+ /**
10
+ * Dev Key Persistence (DEPRECATED)
11
+ *
12
+ * These exports are deprecated. Use `createKeyPersistence` from `@frontmcp/utils` instead.
13
+ * They are kept for backwards compatibility and will be removed in a future major version.
14
+ *
15
+ * @deprecated Use `createKeyPersistence` from `@frontmcp/utils` instead.
16
+ */
17
+ export { isDevKeyPersistenceEnabled, resolveKeyPath, loadDevKey, saveDevKey, deleteDevKey, } from './dev-key-persistence';
18
+ /** @deprecated Use `AsymmetricKeyData` from `@frontmcp/utils` instead. */
19
+ export type { DevKeyData } from './dev-key-persistence';
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jwks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGlH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEhF;;;;;;;GAOG;AACH,OAAO,EACL,0BAA0B,EAC1B,cAAc,EACd,UAAU,EACV,UAAU,EACV,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,0EAA0E;AAC1E,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { JSONWebKeySet } from 'jose';
2
+ import { JwksServiceOptions, ProviderVerifyRef, VerifyResult } from './jwks.types';
3
+ export declare class JwksService {
4
+ private readonly opts;
5
+ private warnedProviders;
6
+ private orchestratorKey;
7
+ private providerJwks;
8
+ private keyInitialized;
9
+ private keyInitPromise;
10
+ private keyPersistence?;
11
+ constructor(opts?: JwksServiceOptions);
12
+ /**
13
+ * Check if key persistence should be enabled.
14
+ * Enabled in development by default, disabled in production unless forceEnable.
15
+ */
16
+ private shouldEnablePersistence;
17
+ /**
18
+ * Get or create the KeyPersistence instance.
19
+ * Returns null if persistence is disabled.
20
+ */
21
+ private getKeyPersistence;
22
+ /** Gateway's public JWKS (publish at /.well-known/jwks.json when orchestrated). */
23
+ getPublicJwks(): Promise<JSONWebKeySet>;
24
+ /** Verify a token issued by the gateway itself (orchestrated mode). */
25
+ verifyGatewayToken(token: string, expectedIssuer: string): Promise<VerifyResult>;
26
+ /**
27
+ * Verify a token against candidate transparent providers.
28
+ * Ensures JWKS are available (cached/TTL/AS discovery) per provider.
29
+ */
30
+ verifyTransparentToken(token: string, candidates: ProviderVerifyRef[]): Promise<VerifyResult>;
31
+ /**
32
+ * Check if the error is due to weak RSA key (< 2048 bits)
33
+ */
34
+ private isWeakKeyError;
35
+ /**
36
+ * Fallback verification for providers using RSA keys smaller than 2048 bits.
37
+ * Logs a security warning but allows verification to proceed.
38
+ */
39
+ private verifyWithWeakKey;
40
+ /**
41
+ * Find a matching key from JWKS based on token header
42
+ */
43
+ private findMatchingKey;
44
+ /** Directly set provider JWKS (e.g., inline keys from config). */
45
+ setProviderJwks(providerId: string, jwks: JSONWebKeySet): void;
46
+ /**
47
+ * Ensure JWKS for a provider:
48
+ * 1) inline jwks (if provided) → cache & return
49
+ * 2) cached & fresh (TTL) → return
50
+ * 3) explicit jwksUri → fetch, cache, return
51
+ * 4) discover jwks_uri via AS → fetch AS metadata, then jwks_uri, cache, return
52
+ */
53
+ getJwksForProvider(ref: ProviderVerifyRef): Promise<JSONWebKeySet | undefined>;
54
+ /** Return the orchestrator public JWKS (generates/rotates as needed). */
55
+ getOrchestratorJwks(): Promise<JSONWebKeySet>;
56
+ /** Return private signing key + kid for issuing orchestrator tokens. */
57
+ getOrchestratorSigningKey(): Promise<{
58
+ kid: string;
59
+ key: import('node:crypto').KeyObject;
60
+ alg: string;
61
+ }>;
62
+ private tryFetchJwks;
63
+ private tryFetchAsMeta;
64
+ private fetchJson;
65
+ private ensureOrchestratorKey;
66
+ private initializeOrchestratorKey;
67
+ private generateKey;
68
+ }
69
+ //# sourceMappingURL=jwks.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwks.service.d.ts","sourceRoot":"","sources":["../../src/jwks/jwks.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAuD,aAAa,EAAO,MAAM,MAAM,CAAC;AAE/F,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAWnF,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAEnB;IAEF,OAAO,CAAC,eAAe,CAAqB;IAG5C,OAAO,CAAC,eAAe,CAKrB;IAGF,OAAO,CAAC,YAAY,CAAiE;IAGrF,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,cAAc,CAA4B;IAElD,OAAO,CAAC,cAAc,CAAC,CAAiB;gBAE5B,IAAI,CAAC,EAAE,kBAAkB;IAcrC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAM/B;;;OAGG;YACW,iBAAiB;IAc/B,mFAAmF;IAC7E,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAQ7C,uEAAuE;IACjE,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAsCtF;;;OAGG;IACG,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAqDnG;;OAEG;IACH,OAAO,CAAC,cAAc;IAatB;;;OAGG;YACW,iBAAiB;IA4E/B;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB,kEAAkE;IAClE,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa;IAIvD;;;;;;OAMG;IACG,kBAAkB,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAmCpF,yEAAyE;IACnE,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC;IAKnD,wEAAwE;IAClE,yBAAyB,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,OAAO,aAAa,EAAE,SAAS,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;YAShG,YAAY;YAaZ,cAAc;YAQd,SAAS;YAgBT,qBAAqB;YAyBrB,yBAAyB;IA0DvC,OAAO,CAAC,WAAW;CAgBpB"}
@@ -0,0 +1,33 @@
1
+ import { JSONWebKeySet } from 'jose';
2
+ import { DevKeyPersistenceOptions } from './dev-key-persistence';
3
+ export type JwksServiceOptions = {
4
+ orchestratorAlg?: 'RS256' | 'ES256';
5
+ rotateDays?: number;
6
+ /** TTL (ms) for cached provider JWKS before attempting refresh. Default: 6h */
7
+ providerJwksTtlMs?: number;
8
+ /** Timeout (ms) for network metadata/JWKS fetches. Default: 5s */
9
+ networkTimeoutMs?: number;
10
+ /**
11
+ * Options for dev key persistence (development mode only by default).
12
+ * When enabled, keys are saved to a file and reloaded on server restart.
13
+ */
14
+ devKeyPersistence?: DevKeyPersistenceOptions;
15
+ };
16
+ export type { DevKeyPersistenceOptions };
17
+ /** Rich descriptor used by verification & fetching */
18
+ export type ProviderVerifyRef = {
19
+ id: string;
20
+ issuerUrl: string;
21
+ jwksUri?: string;
22
+ jwks?: JSONWebKeySet;
23
+ };
24
+ export type VerifyResult = {
25
+ ok: boolean;
26
+ issuer?: string;
27
+ sub?: string;
28
+ providerId?: string;
29
+ header?: Record<string, unknown>;
30
+ payload?: Record<string, unknown>;
31
+ error?: string;
32
+ };
33
+ //# sourceMappingURL=jwks.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwks.types.d.ts","sourceRoot":"","sources":["../../src/jwks/jwks.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;CAC9C,CAAC;AAEF,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAEzC,sDAAsD;AACtD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function trimSlash(s: string): string;
2
+ export declare function normalizeIssuer(u?: string): string;
3
+ /** Safe, no-verify JWT payload decode (returns undefined on error). */
4
+ export declare function decodeJwtPayloadSafe(token?: string): Record<string, unknown> | undefined;
5
+ //# sourceMappingURL=jwks.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwks.utils.d.ts","sourceRoot":"","sources":["../../src/jwks/jwks.utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,UAElC;AACD,wBAAgB,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,UAEzC;AAED,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAgBxF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/auth",
3
- "version": "0.0.1",
3
+ "version": "0.8.0",
4
4
  "description": "FrontMCP Auth - Authentication, session management, and credential vault",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "homepage": "https://docs.agentfront.dev",
@@ -50,7 +50,7 @@
50
50
  "zod": "^4.0.0"
51
51
  },
52
52
  "dependencies": {
53
- "@frontmcp/utils": "0.7.2",
53
+ "@frontmcp/utils": "0.8.0",
54
54
  "jose": "^6.0.0"
55
55
  },
56
56
  "devDependencies": {