@frontmcp/auth 0.12.2 → 1.0.0-beta.2

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 (48) hide show
  1. package/cimd/cimd.cache.d.ts +0 -5
  2. package/cimd/cimd.cache.d.ts.map +1 -1
  3. package/cimd/index.d.ts +1 -2
  4. package/cimd/index.d.ts.map +1 -1
  5. package/consent/index.d.ts +2 -1
  6. package/consent/index.d.ts.map +1 -1
  7. package/detection/auth-provider-detection.d.ts +4 -2
  8. package/detection/auth-provider-detection.d.ts.map +1 -1
  9. package/esm/index.mjs +674 -768
  10. package/esm/package.json +4 -4
  11. package/index.d.ts +3 -3
  12. package/index.d.ts.map +1 -1
  13. package/index.js +746 -858
  14. package/jwks/index.d.ts +1 -12
  15. package/jwks/index.d.ts.map +1 -1
  16. package/jwks/jwks.service.d.ts +1 -6
  17. package/jwks/jwks.service.d.ts.map +1 -1
  18. package/jwks/jwks.types.d.ts +0 -7
  19. package/jwks/jwks.types.d.ts.map +1 -1
  20. package/machine-id/machine-id.d.ts.map +1 -1
  21. package/options/app-auth.schema.d.ts +29 -37
  22. package/options/app-auth.schema.d.ts.map +1 -1
  23. package/options/index.d.ts +6 -6
  24. package/options/index.d.ts.map +1 -1
  25. package/options/interfaces.d.ts +72 -32
  26. package/options/interfaces.d.ts.map +1 -1
  27. package/options/orchestrated.schema.d.ts +55 -56
  28. package/options/orchestrated.schema.d.ts.map +1 -1
  29. package/options/public.schema.d.ts +2 -1
  30. package/options/public.schema.d.ts.map +1 -1
  31. package/options/schema.d.ts +36 -39
  32. package/options/schema.d.ts.map +1 -1
  33. package/options/shared.schemas.d.ts +61 -9
  34. package/options/shared.schemas.d.ts.map +1 -1
  35. package/options/transparent.schema.d.ts +17 -16
  36. package/options/transparent.schema.d.ts.map +1 -1
  37. package/options/typecheck.d.ts.map +1 -1
  38. package/options/utils.d.ts +16 -7
  39. package/options/utils.d.ts.map +1 -1
  40. package/package.json +4 -4
  41. package/session/session-crypto.d.ts.map +1 -1
  42. package/session/session.transport.d.ts +3 -4
  43. package/session/session.transport.d.ts.map +1 -1
  44. package/session/transport-session.types.d.ts +3 -0
  45. package/session/transport-session.types.d.ts.map +1 -1
  46. package/session/utils/session-crypto.utils.d.ts.map +1 -1
  47. package/jwks/dev-key-persistence.d.ts +0 -70
  48. package/jwks/dev-key-persistence.d.ts.map +0 -1
package/esm/index.mjs CHANGED
@@ -74,7 +74,7 @@ function parseCacheControlHeader(value) {
74
74
  }
75
75
  return result;
76
76
  }
77
- var InMemoryCimdCache, CimdCache;
77
+ var InMemoryCimdCache;
78
78
  var init_cimd_cache = __esm({
79
79
  "libs/auth/src/cimd/cimd.cache.ts"() {
80
80
  "use strict";
@@ -209,13 +209,18 @@ var init_cimd_cache = __esm({
209
209
  return removed;
210
210
  }
211
211
  };
212
- CimdCache = InMemoryCimdCache;
213
212
  }
214
213
  });
215
214
 
216
215
  // libs/auth/src/jwks/jwks.service.ts
217
216
  import { jwtVerify, createLocalJWKSet, decodeProtectedHeader } from "jose";
218
- import { bytesToHex, randomBytes, rsaVerify, createKeyPersistence } from "@frontmcp/utils";
217
+ import {
218
+ bytesToHex,
219
+ randomBytes,
220
+ rsaVerify,
221
+ createKeyPersistence,
222
+ isProduction
223
+ } from "@frontmcp/utils";
219
224
 
220
225
  // libs/auth/src/jwks/jwks.utils.ts
221
226
  function trimSlash(s) {
@@ -286,29 +291,19 @@ var JwksService = class {
286
291
  rotateDays: opts?.rotateDays ?? 30,
287
292
  providerJwksTtlMs: opts?.providerJwksTtlMs ?? 6 * 60 * 60 * 1e3,
288
293
  // 6h
289
- networkTimeoutMs: opts?.networkTimeoutMs ?? 5e3,
294
+ networkTimeoutMs: opts?.networkTimeoutMs ?? 5e3
290
295
  // 5s
291
- devKeyPersistence: opts?.devKeyPersistence
292
296
  };
293
297
  }
294
298
  // ===========================================================================
295
299
  // Key Persistence Helpers
296
300
  // ===========================================================================
297
- /**
298
- * Check if key persistence should be enabled.
299
- * Enabled in development by default, disabled in production unless forceEnable.
300
- */
301
- shouldEnablePersistence() {
302
- const isProd = process.env["NODE_ENV"] === "production";
303
- if (this.opts.devKeyPersistence?.forceEnable) return true;
304
- return !isProd;
305
- }
306
301
  /**
307
302
  * Get or create the KeyPersistence instance.
308
- * Returns null if persistence is disabled.
303
+ * Returns null if persistence is disabled (production).
309
304
  */
310
305
  async getKeyPersistence() {
311
- if (!this.shouldEnablePersistence()) return null;
306
+ if (isProduction()) return null;
312
307
  if (!this.keyPersistence) {
313
308
  this.keyPersistence = await createKeyPersistence({
314
309
  baseDir: ".frontmcp/keys"
@@ -426,7 +421,12 @@ var JwksService = class {
426
421
  if (!jwtAlg) {
427
422
  return { ok: false, error: "missing_alg" };
428
423
  }
429
- const isValid = rsaVerify(jwtAlg, Buffer.from(signatureInput), matchingKey, signature);
424
+ const isValid = await rsaVerify(
425
+ jwtAlg,
426
+ Buffer.from(signatureInput),
427
+ matchingKey,
428
+ signature
429
+ );
430
430
  if (!isValid) {
431
431
  return { ok: false, error: "signature_invalid" };
432
432
  }
@@ -647,147 +647,6 @@ var JwksService = class {
647
647
  }
648
648
  };
649
649
 
650
- // libs/auth/src/jwks/dev-key-persistence.ts
651
- import * as path from "path";
652
- import * as crypto from "crypto";
653
- import { z } from "zod";
654
- import { readFile, mkdir, writeFile, rename, unlink } from "@frontmcp/utils";
655
- var DEFAULT_KEY_PATH = ".frontmcp/dev-keys.json";
656
- var rsaPrivateKeySchema = z.object({
657
- kty: z.literal("RSA"),
658
- n: z.string().min(1),
659
- e: z.string().min(1),
660
- d: z.string().min(1),
661
- p: z.string().optional(),
662
- q: z.string().optional(),
663
- dp: z.string().optional(),
664
- dq: z.string().optional(),
665
- qi: z.string().optional()
666
- }).passthrough();
667
- var ecPrivateKeySchema = z.object({
668
- kty: z.literal("EC"),
669
- crv: z.string().min(1),
670
- x: z.string().min(1),
671
- y: z.string().min(1),
672
- d: z.string().min(1)
673
- }).passthrough();
674
- var publicJwkSchema = z.object({
675
- kty: z.enum(["RSA", "EC"]),
676
- kid: z.string().min(1),
677
- alg: z.enum(["RS256", "ES256"]),
678
- use: z.literal("sig")
679
- }).passthrough();
680
- var jwksSchema = z.object({
681
- keys: z.array(publicJwkSchema).min(1)
682
- });
683
- var devKeyDataSchema = z.object({
684
- kid: z.string().min(1),
685
- privateKey: z.union([rsaPrivateKeySchema, ecPrivateKeySchema]),
686
- publicJwk: jwksSchema,
687
- createdAt: z.number().positive().int(),
688
- alg: z.enum(["RS256", "ES256"])
689
- });
690
- function validateJwkStructure(data) {
691
- const result = devKeyDataSchema.safeParse(data);
692
- if (!result.success) {
693
- return { valid: false, error: result.error.issues[0]?.message ?? "Invalid JWK structure" };
694
- }
695
- const parsed = result.data;
696
- if (parsed.alg === "RS256" && parsed.privateKey.kty !== "RSA") {
697
- return { valid: false, error: "Algorithm RS256 requires RSA key type" };
698
- }
699
- if (parsed.alg === "ES256" && parsed.privateKey.kty !== "EC") {
700
- return { valid: false, error: "Algorithm ES256 requires EC key type" };
701
- }
702
- const publicKey = parsed.publicJwk.keys[0];
703
- if (publicKey.kty !== parsed.privateKey.kty) {
704
- return { valid: false, error: "Public and private key types do not match" };
705
- }
706
- if (publicKey.kid !== parsed.kid) {
707
- return { valid: false, error: "kid mismatch between top-level and publicJwk" };
708
- }
709
- const now = Date.now();
710
- const hundredYearsMs = 100 * 365 * 24 * 60 * 60 * 1e3;
711
- if (parsed.createdAt > now) {
712
- return { valid: false, error: "createdAt is in the future" };
713
- }
714
- if (parsed.createdAt < now - hundredYearsMs) {
715
- return { valid: false, error: "createdAt is too old" };
716
- }
717
- return { valid: true };
718
- }
719
- function isDevKeyPersistenceEnabled(options) {
720
- const isProduction = process.env["NODE_ENV"] === "production";
721
- if (isProduction) {
722
- return options?.forceEnable === true;
723
- }
724
- return true;
725
- }
726
- function resolveKeyPath(options) {
727
- const keyPath = options?.keyPath ?? DEFAULT_KEY_PATH;
728
- if (path.isAbsolute(keyPath)) {
729
- return keyPath;
730
- }
731
- return path.resolve(process.cwd(), keyPath);
732
- }
733
- async function loadDevKey(options) {
734
- if (!isDevKeyPersistenceEnabled(options)) {
735
- return null;
736
- }
737
- const keyPath = resolveKeyPath(options);
738
- try {
739
- const content = await readFile(keyPath, "utf8");
740
- const data = JSON.parse(content);
741
- const validation = validateJwkStructure(data);
742
- if (!validation.valid) {
743
- console.warn(`[DevKeyPersistence] Invalid key file format at ${keyPath}: ${validation.error}, will regenerate`);
744
- return null;
745
- }
746
- console.log(`[DevKeyPersistence] Loaded key (kid=${data.kid}) from ${keyPath}`);
747
- return data;
748
- } catch (error) {
749
- if (error.code === "ENOENT") {
750
- return null;
751
- }
752
- console.warn(`[DevKeyPersistence] Failed to load key from ${keyPath}: ${error.message}`);
753
- return null;
754
- }
755
- }
756
- async function saveDevKey(keyData, options) {
757
- if (!isDevKeyPersistenceEnabled(options)) {
758
- return true;
759
- }
760
- const keyPath = resolveKeyPath(options);
761
- const dir = path.dirname(keyPath);
762
- const tempPath = `${keyPath}.tmp.${Date.now()}.${crypto.randomBytes(8).toString("hex")}`;
763
- try {
764
- await mkdir(dir, { recursive: true, mode: 448 });
765
- const content = JSON.stringify(keyData, null, 2);
766
- await writeFile(tempPath, content, { mode: 384 });
767
- await rename(tempPath, keyPath);
768
- console.log(`[DevKeyPersistence] Saved key (kid=${keyData.kid}) to ${keyPath}`);
769
- return true;
770
- } catch (error) {
771
- console.error(`[DevKeyPersistence] Failed to save key to ${keyPath}: ${error.message}`);
772
- try {
773
- await unlink(tempPath);
774
- } catch {
775
- }
776
- return false;
777
- }
778
- }
779
- async function deleteDevKey(options) {
780
- const keyPath = resolveKeyPath(options);
781
- try {
782
- await unlink(keyPath);
783
- console.log(`[DevKeyPersistence] Deleted key at ${keyPath}`);
784
- } catch (error) {
785
- if (error.code !== "ENOENT") {
786
- console.warn(`[DevKeyPersistence] Failed to delete key at ${keyPath}: ${error.message}`);
787
- }
788
- }
789
- }
790
-
791
650
  // libs/auth/src/ui/base-layout.ts
792
651
  import { escapeHtml } from "@frontmcp/utils";
793
652
  import { escapeHtml as escapeHtml2 } from "@frontmcp/utils";
@@ -1291,32 +1150,32 @@ function renderToHtml(html, _options) {
1291
1150
 
1292
1151
  // libs/auth/src/session/authorization.store.ts
1293
1152
  import { randomUUID, sha256Base64url } from "@frontmcp/utils";
1294
- import { z as z2 } from "zod";
1295
- var pkceChallengeSchema = z2.object({
1296
- challenge: z2.string().min(43).max(128),
1297
- method: z2.literal("S256")
1153
+ import { z } from "zod";
1154
+ var pkceChallengeSchema = z.object({
1155
+ challenge: z.string().min(43).max(128),
1156
+ method: z.literal("S256")
1298
1157
  });
1299
- var authorizationCodeRecordSchema = z2.object({
1300
- code: z2.string().min(1),
1301
- clientId: z2.string().min(1),
1302
- redirectUri: z2.string().url(),
1303
- scopes: z2.array(z2.string()),
1158
+ var authorizationCodeRecordSchema = z.object({
1159
+ code: z.string().min(1),
1160
+ clientId: z.string().min(1),
1161
+ redirectUri: z.string().url(),
1162
+ scopes: z.array(z.string()),
1304
1163
  pkce: pkceChallengeSchema,
1305
- userSub: z2.string().min(1),
1306
- userEmail: z2.string().email().optional(),
1307
- userName: z2.string().optional(),
1308
- state: z2.string().optional(),
1309
- createdAt: z2.number(),
1310
- expiresAt: z2.number(),
1311
- used: z2.boolean(),
1312
- resource: z2.string().url().optional(),
1164
+ userSub: z.string().min(1),
1165
+ userEmail: z.string().email().optional(),
1166
+ userName: z.string().optional(),
1167
+ state: z.string().optional(),
1168
+ createdAt: z.number(),
1169
+ expiresAt: z.number(),
1170
+ used: z.boolean(),
1171
+ resource: z.string().url().optional(),
1313
1172
  // Consent and federated login fields
1314
- selectedToolIds: z2.array(z2.string()).optional(),
1315
- selectedProviderIds: z2.array(z2.string()).optional(),
1316
- skippedProviderIds: z2.array(z2.string()).optional(),
1317
- consentEnabled: z2.boolean().optional(),
1318
- federatedLoginUsed: z2.boolean().optional(),
1319
- pendingAuthId: z2.string().optional()
1173
+ selectedToolIds: z.array(z.string()).optional(),
1174
+ selectedProviderIds: z.array(z.string()).optional(),
1175
+ skippedProviderIds: z.array(z.string()).optional(),
1176
+ consentEnabled: z.boolean().optional(),
1177
+ federatedLoginUsed: z.boolean().optional(),
1178
+ pendingAuthId: z.string().optional()
1320
1179
  });
1321
1180
  function verifyPkce(codeVerifier, challenge) {
1322
1181
  if (challenge.method !== "S256") {
@@ -1569,8 +1428,8 @@ var RedisAuthorizationStore = class {
1569
1428
  };
1570
1429
 
1571
1430
  // libs/auth/src/session/authorization-vault.ts
1572
- import { z as z3 } from "zod";
1573
- var credentialTypeSchema = z3.enum([
1431
+ import { z as z2 } from "zod";
1432
+ var credentialTypeSchema = z2.enum([
1574
1433
  "oauth",
1575
1434
  // OAuth 2.0 tokens
1576
1435
  "api_key",
@@ -1592,135 +1451,135 @@ var credentialTypeSchema = z3.enum([
1592
1451
  "oauth_pkce"
1593
1452
  // OAuth 2.0 with PKCE for public clients
1594
1453
  ]);
1595
- var oauthCredentialSchema = z3.object({
1596
- type: z3.literal("oauth"),
1454
+ var oauthCredentialSchema = z2.object({
1455
+ type: z2.literal("oauth"),
1597
1456
  /** Access token */
1598
- accessToken: z3.string(),
1457
+ accessToken: z2.string(),
1599
1458
  /** Refresh token (optional) */
1600
- refreshToken: z3.string().optional(),
1459
+ refreshToken: z2.string().optional(),
1601
1460
  /** Token type (usually 'Bearer') */
1602
- tokenType: z3.string().default("Bearer"),
1461
+ tokenType: z2.string().default("Bearer"),
1603
1462
  /** Token expiration timestamp (epoch ms) */
1604
- expiresAt: z3.number().optional(),
1463
+ expiresAt: z2.number().optional(),
1605
1464
  /** Granted scopes */
1606
- scopes: z3.array(z3.string()).default([]),
1465
+ scopes: z2.array(z2.string()).default([]),
1607
1466
  /** ID token for OIDC (optional) */
1608
- idToken: z3.string().optional()
1467
+ idToken: z2.string().optional()
1609
1468
  });
1610
- var apiKeyCredentialSchema = z3.object({
1611
- type: z3.literal("api_key"),
1469
+ var apiKeyCredentialSchema = z2.object({
1470
+ type: z2.literal("api_key"),
1612
1471
  /** The API key value */
1613
- key: z3.string().min(1),
1472
+ key: z2.string().min(1),
1614
1473
  /** Header name to use (e.g., 'X-API-Key', 'Authorization') */
1615
- headerName: z3.string().default("X-API-Key"),
1474
+ headerName: z2.string().default("X-API-Key"),
1616
1475
  /** Prefix for the header value (e.g., 'Bearer ', 'Api-Key ') */
1617
- headerPrefix: z3.string().optional(),
1476
+ headerPrefix: z2.string().optional(),
1618
1477
  /** Alternative: send as query parameter */
1619
- queryParam: z3.string().optional()
1478
+ queryParam: z2.string().optional()
1620
1479
  });
1621
- var basicAuthCredentialSchema = z3.object({
1622
- type: z3.literal("basic"),
1480
+ var basicAuthCredentialSchema = z2.object({
1481
+ type: z2.literal("basic"),
1623
1482
  /** Username */
1624
- username: z3.string().min(1),
1483
+ username: z2.string().min(1),
1625
1484
  /** Password */
1626
- password: z3.string(),
1485
+ password: z2.string(),
1627
1486
  /** Pre-computed base64 encoded value (optional, for caching) */
1628
- encodedValue: z3.string().optional()
1487
+ encodedValue: z2.string().optional()
1629
1488
  });
1630
- var bearerCredentialSchema = z3.object({
1631
- type: z3.literal("bearer"),
1489
+ var bearerCredentialSchema = z2.object({
1490
+ type: z2.literal("bearer"),
1632
1491
  /** The bearer token value */
1633
- token: z3.string().min(1),
1492
+ token: z2.string().min(1),
1634
1493
  /** Token expiration (optional, for static tokens that expire) */
1635
- expiresAt: z3.number().optional()
1494
+ expiresAt: z2.number().optional()
1636
1495
  });
1637
- var privateKeyCredentialSchema = z3.object({
1638
- type: z3.literal("private_key"),
1496
+ var privateKeyCredentialSchema = z2.object({
1497
+ type: z2.literal("private_key"),
1639
1498
  /** Key format */
1640
- format: z3.enum(["pem", "jwk", "pkcs8", "pkcs12"]),
1499
+ format: z2.enum(["pem", "jwk", "pkcs8", "pkcs12"]),
1641
1500
  /** The key data (PEM string or JWK JSON) */
1642
- keyData: z3.string(),
1501
+ keyData: z2.string(),
1643
1502
  /** Key ID (for JWK) */
1644
- keyId: z3.string().optional(),
1503
+ keyId: z2.string().optional(),
1645
1504
  /** Algorithm to use for signing */
1646
- algorithm: z3.string().optional(),
1505
+ algorithm: z2.string().optional(),
1647
1506
  /** Passphrase if key is encrypted */
1648
- passphrase: z3.string().optional(),
1507
+ passphrase: z2.string().optional(),
1649
1508
  /** Associated certificate (for mTLS) */
1650
- certificate: z3.string().optional()
1509
+ certificate: z2.string().optional()
1651
1510
  });
1652
- var mtlsCredentialSchema = z3.object({
1653
- type: z3.literal("mtls"),
1511
+ var mtlsCredentialSchema = z2.object({
1512
+ type: z2.literal("mtls"),
1654
1513
  /** Client certificate (PEM format) */
1655
- certificate: z3.string(),
1514
+ certificate: z2.string(),
1656
1515
  /** Private key (PEM format) */
1657
- privateKey: z3.string(),
1516
+ privateKey: z2.string(),
1658
1517
  /** Passphrase if private key is encrypted */
1659
- passphrase: z3.string().optional(),
1518
+ passphrase: z2.string().optional(),
1660
1519
  /** CA certificate chain (optional) */
1661
- caCertificate: z3.string().optional()
1520
+ caCertificate: z2.string().optional()
1662
1521
  });
1663
- var customCredentialSchema = z3.object({
1664
- type: z3.literal("custom"),
1522
+ var customCredentialSchema = z2.object({
1523
+ type: z2.literal("custom"),
1665
1524
  /** Custom type identifier */
1666
- customType: z3.string().min(1),
1525
+ customType: z2.string().min(1),
1667
1526
  /** Arbitrary credential data */
1668
- data: z3.record(z3.string(), z3.unknown()),
1527
+ data: z2.record(z2.string(), z2.unknown()),
1669
1528
  /** Headers to include in requests */
1670
- headers: z3.record(z3.string(), z3.string()).optional()
1529
+ headers: z2.record(z2.string(), z2.string()).optional()
1671
1530
  });
1672
- var sshKeyCredentialSchema = z3.object({
1673
- type: z3.literal("ssh_key"),
1531
+ var sshKeyCredentialSchema = z2.object({
1532
+ type: z2.literal("ssh_key"),
1674
1533
  /** Private key (PEM format) */
1675
- privateKey: z3.string().min(1),
1534
+ privateKey: z2.string().min(1),
1676
1535
  /** Public key (optional, can be derived from private key) */
1677
- publicKey: z3.string().optional(),
1536
+ publicKey: z2.string().optional(),
1678
1537
  /** Passphrase if private key is encrypted */
1679
- passphrase: z3.string().optional(),
1538
+ passphrase: z2.string().optional(),
1680
1539
  /** Key type */
1681
- keyType: z3.enum(["rsa", "ed25519", "ecdsa", "dsa"]).default("ed25519"),
1540
+ keyType: z2.enum(["rsa", "ed25519", "ecdsa", "dsa"]).default("ed25519"),
1682
1541
  /** Key fingerprint (SHA256 hash) */
1683
- fingerprint: z3.string().optional(),
1542
+ fingerprint: z2.string().optional(),
1684
1543
  /** Username for SSH connections */
1685
- username: z3.string().optional()
1544
+ username: z2.string().optional()
1686
1545
  });
1687
- var serviceAccountCredentialSchema = z3.object({
1688
- type: z3.literal("service_account"),
1546
+ var serviceAccountCredentialSchema = z2.object({
1547
+ type: z2.literal("service_account"),
1689
1548
  /** Cloud provider */
1690
- provider: z3.enum(["gcp", "aws", "azure", "custom"]),
1549
+ provider: z2.enum(["gcp", "aws", "azure", "custom"]),
1691
1550
  /** Raw credentials (JSON key file content, access keys, etc.) */
1692
- credentials: z3.record(z3.string(), z3.unknown()),
1551
+ credentials: z2.record(z2.string(), z2.unknown()),
1693
1552
  /** Project/Account ID */
1694
- projectId: z3.string().optional(),
1553
+ projectId: z2.string().optional(),
1695
1554
  /** Region for regional services */
1696
- region: z3.string().optional(),
1555
+ region: z2.string().optional(),
1697
1556
  /** AWS: Role ARN to assume */
1698
- assumeRoleArn: z3.string().optional(),
1557
+ assumeRoleArn: z2.string().optional(),
1699
1558
  /** AWS: External ID for cross-account access */
1700
- externalId: z3.string().optional(),
1559
+ externalId: z2.string().optional(),
1701
1560
  /** Service account email (GCP) or ARN (AWS) */
1702
- serviceAccountId: z3.string().optional(),
1561
+ serviceAccountId: z2.string().optional(),
1703
1562
  /** Expiration timestamp for temporary credentials */
1704
- expiresAt: z3.number().optional()
1563
+ expiresAt: z2.number().optional()
1705
1564
  });
1706
- var pkceOAuthCredentialSchema = z3.object({
1707
- type: z3.literal("oauth_pkce"),
1565
+ var pkceOAuthCredentialSchema = z2.object({
1566
+ type: z2.literal("oauth_pkce"),
1708
1567
  /** Access token */
1709
- accessToken: z3.string(),
1568
+ accessToken: z2.string(),
1710
1569
  /** Refresh token (optional) */
1711
- refreshToken: z3.string().optional(),
1570
+ refreshToken: z2.string().optional(),
1712
1571
  /** Token type (usually 'Bearer') */
1713
- tokenType: z3.string().default("Bearer"),
1572
+ tokenType: z2.string().default("Bearer"),
1714
1573
  /** Token expiration timestamp (epoch ms) */
1715
- expiresAt: z3.number().optional(),
1574
+ expiresAt: z2.number().optional(),
1716
1575
  /** Granted scopes */
1717
- scopes: z3.array(z3.string()).default([]),
1576
+ scopes: z2.array(z2.string()).default([]),
1718
1577
  /** ID token for OIDC (optional) */
1719
- idToken: z3.string().optional(),
1578
+ idToken: z2.string().optional(),
1720
1579
  /** Authorization server issuer */
1721
- issuer: z3.string().optional()
1580
+ issuer: z2.string().optional()
1722
1581
  });
1723
- var credentialSchema = z3.discriminatedUnion("type", [
1582
+ var credentialSchema = z2.discriminatedUnion("type", [
1724
1583
  oauthCredentialSchema,
1725
1584
  apiKeyCredentialSchema,
1726
1585
  basicAuthCredentialSchema,
@@ -1732,124 +1591,124 @@ var credentialSchema = z3.discriminatedUnion("type", [
1732
1591
  serviceAccountCredentialSchema,
1733
1592
  pkceOAuthCredentialSchema
1734
1593
  ]);
1735
- var appCredentialSchema = z3.object({
1594
+ var appCredentialSchema = z2.object({
1736
1595
  /** App ID this credential belongs to */
1737
- appId: z3.string().min(1),
1596
+ appId: z2.string().min(1),
1738
1597
  /** Provider ID within the app (for apps with multiple auth providers) */
1739
- providerId: z3.string().min(1),
1598
+ providerId: z2.string().min(1),
1740
1599
  /** The credential data */
1741
1600
  credential: credentialSchema,
1742
1601
  /** Timestamp when credential was acquired */
1743
- acquiredAt: z3.number(),
1602
+ acquiredAt: z2.number(),
1744
1603
  /** Timestamp when credential was last used */
1745
- lastUsedAt: z3.number().optional(),
1604
+ lastUsedAt: z2.number().optional(),
1746
1605
  /** Credential expiration (if applicable) */
1747
- expiresAt: z3.number().optional(),
1606
+ expiresAt: z2.number().optional(),
1748
1607
  /** Whether this credential is currently valid */
1749
- isValid: z3.boolean().default(true),
1608
+ isValid: z2.boolean().default(true),
1750
1609
  /** Error message if credential is invalid */
1751
- invalidReason: z3.string().optional(),
1610
+ invalidReason: z2.string().optional(),
1752
1611
  /** User info associated with this credential */
1753
- userInfo: z3.object({
1754
- sub: z3.string().optional(),
1755
- email: z3.string().optional(),
1756
- name: z3.string().optional()
1612
+ userInfo: z2.object({
1613
+ sub: z2.string().optional(),
1614
+ email: z2.string().optional(),
1615
+ name: z2.string().optional()
1757
1616
  }).optional(),
1758
1617
  /** Metadata for tracking/debugging */
1759
- metadata: z3.record(z3.string(), z3.unknown()).optional()
1618
+ metadata: z2.record(z2.string(), z2.unknown()).optional()
1760
1619
  });
1761
- var vaultConsentRecordSchema = z3.object({
1620
+ var vaultConsentRecordSchema = z2.object({
1762
1621
  /** Whether consent was enabled */
1763
- enabled: z3.boolean(),
1622
+ enabled: z2.boolean(),
1764
1623
  /** Selected tool IDs (user approved these) */
1765
- selectedToolIds: z3.array(z3.string()),
1624
+ selectedToolIds: z2.array(z2.string()),
1766
1625
  /** Available tool IDs at time of consent */
1767
- availableToolIds: z3.array(z3.string()),
1626
+ availableToolIds: z2.array(z2.string()),
1768
1627
  /** Timestamp when consent was given */
1769
- consentedAt: z3.number(),
1628
+ consentedAt: z2.number(),
1770
1629
  /** Consent version for tracking changes */
1771
- version: z3.string().default("1.0")
1630
+ version: z2.string().default("1.0")
1772
1631
  });
1773
- var vaultFederatedRecordSchema = z3.object({
1632
+ var vaultFederatedRecordSchema = z2.object({
1774
1633
  /** Provider IDs that were selected */
1775
- selectedProviderIds: z3.array(z3.string()),
1634
+ selectedProviderIds: z2.array(z2.string()),
1776
1635
  /** Provider IDs that were skipped (can be authorized later) */
1777
- skippedProviderIds: z3.array(z3.string()),
1636
+ skippedProviderIds: z2.array(z2.string()),
1778
1637
  /** Primary provider ID */
1779
- primaryProviderId: z3.string().optional(),
1638
+ primaryProviderId: z2.string().optional(),
1780
1639
  /** Timestamp when federated login was completed */
1781
- completedAt: z3.number()
1640
+ completedAt: z2.number()
1782
1641
  });
1783
- var pendingIncrementalAuthSchema = z3.object({
1642
+ var pendingIncrementalAuthSchema = z2.object({
1784
1643
  /** Unique ID for this request */
1785
- id: z3.string(),
1644
+ id: z2.string(),
1786
1645
  /** App ID being authorized */
1787
- appId: z3.string(),
1646
+ appId: z2.string(),
1788
1647
  /** Tool ID that triggered the auth request */
1789
- toolId: z3.string().optional(),
1648
+ toolId: z2.string().optional(),
1790
1649
  /** Authorization URL */
1791
- authUrl: z3.string(),
1650
+ authUrl: z2.string(),
1792
1651
  /** Required scopes */
1793
- requiredScopes: z3.array(z3.string()).optional(),
1652
+ requiredScopes: z2.array(z2.string()).optional(),
1794
1653
  /** Whether elicit is being used */
1795
- elicitId: z3.string().optional(),
1654
+ elicitId: z2.string().optional(),
1796
1655
  /** Timestamp when request was created */
1797
- createdAt: z3.number(),
1656
+ createdAt: z2.number(),
1798
1657
  /** Expiration timestamp */
1799
- expiresAt: z3.number(),
1658
+ expiresAt: z2.number(),
1800
1659
  /** Status of the request */
1801
- status: z3.enum(["pending", "completed", "cancelled", "expired"])
1660
+ status: z2.enum(["pending", "completed", "cancelled", "expired"])
1802
1661
  });
1803
- var authorizationVaultEntrySchema = z3.object({
1662
+ var authorizationVaultEntrySchema = z2.object({
1804
1663
  /** Vault ID (maps to access token jti claim) */
1805
- id: z3.string(),
1664
+ id: z2.string(),
1806
1665
  /** User subject identifier */
1807
- userSub: z3.string(),
1666
+ userSub: z2.string(),
1808
1667
  /** User email */
1809
- userEmail: z3.string().optional(),
1668
+ userEmail: z2.string().optional(),
1810
1669
  /** User name */
1811
- userName: z3.string().optional(),
1670
+ userName: z2.string().optional(),
1812
1671
  /** Client ID that created this session */
1813
- clientId: z3.string(),
1672
+ clientId: z2.string(),
1814
1673
  /** Creation timestamp */
1815
- createdAt: z3.number(),
1674
+ createdAt: z2.number(),
1816
1675
  /** Last access timestamp */
1817
- lastAccessAt: z3.number(),
1676
+ lastAccessAt: z2.number(),
1818
1677
  /** App credentials (keyed by `${appId}:${providerId}`) */
1819
- appCredentials: z3.record(z3.string(), appCredentialSchema).default({}),
1678
+ appCredentials: z2.record(z2.string(), appCredentialSchema).default({}),
1820
1679
  /** Consent record */
1821
1680
  consent: vaultConsentRecordSchema.optional(),
1822
1681
  /** Federated login record */
1823
1682
  federated: vaultFederatedRecordSchema.optional(),
1824
1683
  /** Pending incremental authorization requests */
1825
- pendingAuths: z3.array(pendingIncrementalAuthSchema),
1684
+ pendingAuths: z2.array(pendingIncrementalAuthSchema),
1826
1685
  /** Apps that are fully authorized */
1827
- authorizedAppIds: z3.array(z3.string()),
1686
+ authorizedAppIds: z2.array(z2.string()),
1828
1687
  /** Apps that were skipped (not yet authorized) */
1829
- skippedAppIds: z3.array(z3.string())
1688
+ skippedAppIds: z2.array(z2.string())
1830
1689
  });
1831
1690
 
1832
1691
  // libs/auth/src/session/vault-encryption.ts
1833
- import { z as z4 } from "zod";
1692
+ import { z as z3 } from "zod";
1834
1693
  import {
1835
1694
  hkdfSha256,
1836
1695
  encryptAesGcm,
1837
1696
  decryptAesGcm,
1838
- randomBytes as randomBytes3,
1697
+ randomBytes as randomBytes2,
1839
1698
  base64urlEncode,
1840
1699
  base64urlDecode
1841
1700
  } from "@frontmcp/utils";
1842
- var encryptedDataSchema = z4.object({
1701
+ var encryptedDataSchema = z3.object({
1843
1702
  /** Version for future algorithm changes */
1844
- v: z4.literal(1),
1703
+ v: z3.literal(1),
1845
1704
  /** Algorithm identifier */
1846
- alg: z4.literal("aes-256-gcm"),
1705
+ alg: z3.literal("aes-256-gcm"),
1847
1706
  /** Initialization vector (base64) */
1848
- iv: z4.string(),
1707
+ iv: z3.string(),
1849
1708
  /** Ciphertext (base64) */
1850
- ct: z4.string(),
1709
+ ct: z3.string(),
1851
1710
  /** Authentication tag (base64) */
1852
- tag: z4.string()
1711
+ tag: z3.string()
1853
1712
  });
1854
1713
  var VaultEncryption = class {
1855
1714
  pepper;
@@ -1919,7 +1778,7 @@ var VaultEncryption = class {
1919
1778
  if (key.length !== 32) {
1920
1779
  throw new Error("Encryption key must be 32 bytes");
1921
1780
  }
1922
- const iv = randomBytes3(12);
1781
+ const iv = randomBytes2(12);
1923
1782
  const { ciphertext, tag } = await encryptAesGcm(key, new TextEncoder().encode(plaintext), iv);
1924
1783
  return {
1925
1784
  v: 1,
@@ -1987,33 +1846,33 @@ var VaultEncryption = class {
1987
1846
  return encryptedDataSchema.safeParse(data).success;
1988
1847
  }
1989
1848
  };
1990
- var encryptedVaultEntrySchema = z4.object({
1849
+ var encryptedVaultEntrySchema = z3.object({
1991
1850
  /** Vault ID (maps to JWT jti claim) */
1992
- id: z4.string(),
1851
+ id: z3.string(),
1993
1852
  /** User subject identifier */
1994
- userSub: z4.string(),
1853
+ userSub: z3.string(),
1995
1854
  /** User email (unencrypted for display) */
1996
- userEmail: z4.string().optional(),
1855
+ userEmail: z3.string().optional(),
1997
1856
  /** User name (unencrypted for display) */
1998
- userName: z4.string().optional(),
1857
+ userName: z3.string().optional(),
1999
1858
  /** Client ID that created this session */
2000
- clientId: z4.string(),
1859
+ clientId: z3.string(),
2001
1860
  /** Creation timestamp */
2002
- createdAt: z4.number(),
1861
+ createdAt: z3.number(),
2003
1862
  /** Last access timestamp */
2004
- lastAccessAt: z4.number(),
1863
+ lastAccessAt: z3.number(),
2005
1864
  /** Encrypted sensitive data (provider tokens, credentials, consent) */
2006
1865
  encryptedData: encryptedDataSchema,
2007
1866
  /** Apps that are fully authorized (unencrypted for quick lookup) */
2008
- authorizedAppIds: z4.array(z4.string()),
1867
+ authorizedAppIds: z3.array(z3.string()),
2009
1868
  /** Apps that were skipped (unencrypted for quick lookup) */
2010
- skippedAppIds: z4.array(z4.string()),
1869
+ skippedAppIds: z3.array(z3.string()),
2011
1870
  /** Pending auth IDs (unencrypted for lookup, actual URLs encrypted) */
2012
- pendingAuthIds: z4.array(z4.string()).default([])
1871
+ pendingAuthIds: z3.array(z3.string()).default([])
2013
1872
  });
2014
1873
 
2015
1874
  // libs/auth/src/session/token.vault.ts
2016
- import { encryptAesGcm as encryptAesGcm2, decryptAesGcm as decryptAesGcm2, randomBytes as randomBytes4, base64urlEncode as base64urlEncode2, base64urlDecode as base64urlDecode2 } from "@frontmcp/utils";
1875
+ import { encryptAesGcm as encryptAesGcm2, decryptAesGcm as decryptAesGcm2, randomBytes as randomBytes3, base64urlEncode as base64urlEncode2, base64urlDecode as base64urlDecode2 } from "@frontmcp/utils";
2017
1876
  var TokenVault = class {
2018
1877
  /** Active key used for new encryptions */
2019
1878
  active;
@@ -2042,7 +1901,7 @@ var TokenVault = class {
2042
1901
  this.keys.set(k.kid, k.key);
2043
1902
  }
2044
1903
  async encrypt(plaintext, opts) {
2045
- const iv = randomBytes4(12);
1904
+ const iv = randomBytes3(12);
2046
1905
  const { ciphertext, tag } = await encryptAesGcm2(this.active.key, new TextEncoder().encode(plaintext), iv);
2047
1906
  return {
2048
1907
  alg: "A256GCM",
@@ -2081,94 +1940,95 @@ import {
2081
1940
  } from "@frontmcp/utils";
2082
1941
 
2083
1942
  // libs/auth/src/session/transport-session.types.ts
2084
- import { z as z5 } from "zod";
2085
- var transportProtocolSchema = z5.enum([
1943
+ import { z as z4 } from "zod";
1944
+ var transportProtocolSchema = z4.enum([
2086
1945
  "legacy-sse",
2087
1946
  "sse",
2088
1947
  "streamable-http",
2089
1948
  "stateful-http",
2090
1949
  "stateless-http"
2091
1950
  ]);
2092
- var sseTransportStateSchema = z5.object({
2093
- type: z5.literal("sse"),
2094
- lastEventId: z5.string().optional(),
2095
- lastPing: z5.number().optional(),
2096
- connectionState: z5.enum(["connecting", "open", "closed"]).optional()
1951
+ var sseTransportStateSchema = z4.object({
1952
+ type: z4.literal("sse"),
1953
+ lastEventId: z4.string().optional(),
1954
+ lastPing: z4.number().optional(),
1955
+ connectionState: z4.enum(["connecting", "open", "closed"]).optional()
2097
1956
  });
2098
- var streamableHttpTransportStateSchema = z5.object({
2099
- type: z5.literal("streamable-http"),
2100
- requestSeq: z5.number(),
2101
- activeStreamId: z5.string().optional(),
2102
- pendingRequests: z5.array(z5.string()).optional()
1957
+ var streamableHttpTransportStateSchema = z4.object({
1958
+ type: z4.literal("streamable-http"),
1959
+ requestSeq: z4.number(),
1960
+ activeStreamId: z4.string().optional(),
1961
+ pendingRequests: z4.array(z4.string()).optional()
2103
1962
  });
2104
- var statefulHttpTransportStateSchema = z5.object({
2105
- type: z5.literal("stateful-http"),
2106
- requestSeq: z5.number(),
2107
- pendingResponses: z5.array(z5.string()).optional(),
2108
- lastActivity: z5.number().optional()
1963
+ var statefulHttpTransportStateSchema = z4.object({
1964
+ type: z4.literal("stateful-http"),
1965
+ requestSeq: z4.number(),
1966
+ pendingResponses: z4.array(z4.string()).optional(),
1967
+ lastActivity: z4.number().optional()
2109
1968
  });
2110
- var statelessHttpTransportStateSchema = z5.object({
2111
- type: z5.literal("stateless-http"),
2112
- requestCount: z5.number(),
2113
- windowStart: z5.number().optional()
1969
+ var statelessHttpTransportStateSchema = z4.object({
1970
+ type: z4.literal("stateless-http"),
1971
+ requestCount: z4.number(),
1972
+ windowStart: z4.number().optional()
2114
1973
  });
2115
- var legacySseTransportStateSchema = z5.object({
2116
- type: z5.literal("legacy-sse"),
2117
- messagePath: z5.string(),
2118
- lastEventId: z5.string().optional(),
2119
- connectionState: z5.enum(["connecting", "open", "closed"]).optional()
1974
+ var legacySseTransportStateSchema = z4.object({
1975
+ type: z4.literal("legacy-sse"),
1976
+ messagePath: z4.string(),
1977
+ lastEventId: z4.string().optional(),
1978
+ connectionState: z4.enum(["connecting", "open", "closed"]).optional()
2120
1979
  });
2121
- var transportStateSchema = z5.discriminatedUnion("type", [
1980
+ var transportStateSchema = z4.discriminatedUnion("type", [
2122
1981
  sseTransportStateSchema,
2123
1982
  streamableHttpTransportStateSchema,
2124
1983
  statefulHttpTransportStateSchema,
2125
1984
  statelessHttpTransportStateSchema,
2126
1985
  legacySseTransportStateSchema
2127
1986
  ]);
2128
- var transportSessionSchema = z5.object({
2129
- id: z5.string(),
2130
- authorizationId: z5.string(),
1987
+ var transportSessionSchema = z4.object({
1988
+ id: z4.string(),
1989
+ authorizationId: z4.string(),
2131
1990
  protocol: transportProtocolSchema,
2132
- createdAt: z5.number(),
2133
- expiresAt: z5.number().optional(),
2134
- nodeId: z5.string(),
2135
- clientFingerprint: z5.string().optional(),
1991
+ createdAt: z4.number(),
1992
+ expiresAt: z4.number().optional(),
1993
+ nodeId: z4.string(),
1994
+ clientFingerprint: z4.string().optional(),
2136
1995
  transportState: transportStateSchema.optional()
2137
1996
  });
2138
- var sessionJwtPayloadSchema = z5.object({
2139
- sid: z5.string(),
2140
- aid: z5.string(),
1997
+ var sessionJwtPayloadSchema = z4.object({
1998
+ sid: z4.string(),
1999
+ aid: z4.string(),
2141
2000
  proto: transportProtocolSchema,
2142
- nid: z5.string(),
2143
- iat: z5.number(),
2144
- exp: z5.number().optional()
2001
+ nid: z4.string(),
2002
+ iat: z4.number(),
2003
+ exp: z4.number().optional()
2145
2004
  });
2146
- var encryptedBlobSchema = z5.object({
2147
- alg: z5.literal("A256GCM"),
2148
- kid: z5.string().optional(),
2149
- iv: z5.string(),
2150
- tag: z5.string(),
2151
- data: z5.string(),
2152
- exp: z5.number().optional(),
2153
- meta: z5.record(z5.string(), z5.unknown()).optional()
2005
+ var encryptedBlobSchema = z4.object({
2006
+ alg: z4.literal("A256GCM"),
2007
+ kid: z4.string().optional(),
2008
+ iv: z4.string(),
2009
+ tag: z4.string(),
2010
+ data: z4.string(),
2011
+ exp: z4.number().optional(),
2012
+ meta: z4.record(z4.string(), z4.unknown()).optional()
2154
2013
  });
2155
- var storedSessionSchema = z5.object({
2014
+ var storedSessionSchema = z4.object({
2156
2015
  session: transportSessionSchema,
2157
- authorizationId: z5.string(),
2158
- tokens: z5.record(z5.string(), encryptedBlobSchema).optional(),
2159
- createdAt: z5.number(),
2160
- lastAccessedAt: z5.number(),
2161
- initialized: z5.boolean().optional(),
2162
- maxLifetimeAt: z5.number().optional()
2016
+ authorizationId: z4.string(),
2017
+ tokens: z4.record(z4.string(), encryptedBlobSchema).optional(),
2018
+ createdAt: z4.number(),
2019
+ lastAccessedAt: z4.number(),
2020
+ initialized: z4.boolean().optional(),
2021
+ maxLifetimeAt: z4.number().optional(),
2022
+ clientCapabilities: z4.record(z4.string(), z4.unknown()).optional()
2163
2023
  });
2164
- var redisConfigSchema = z5.object({
2165
- host: z5.string().min(1),
2166
- port: z5.number().int().positive().optional().default(6379),
2167
- password: z5.string().optional(),
2168
- db: z5.number().int().nonnegative().optional().default(0),
2169
- tls: z5.boolean().optional().default(false),
2170
- keyPrefix: z5.string().optional().default("mcp:session:"),
2171
- defaultTtlMs: z5.number().int().positive().optional().default(36e5)
2024
+ var redisConfigSchema = z4.object({
2025
+ host: z4.string().min(1),
2026
+ port: z4.number().int().positive().optional().default(6379),
2027
+ password: z4.string().optional(),
2028
+ db: z4.number().int().nonnegative().optional().default(0),
2029
+ tls: z4.boolean().optional().default(false),
2030
+ keyPrefix: z4.string().optional().default("mcp:session:"),
2031
+ defaultTtlMs: z4.number().int().positive().optional().default(36e5)
2172
2032
  // 1 hour default
2173
2033
  });
2174
2034
 
@@ -2177,11 +2037,13 @@ import {
2177
2037
  signData,
2178
2038
  verifyData,
2179
2039
  isSignedData,
2180
- verifyOrParseData
2040
+ verifyOrParseData,
2041
+ getEnv,
2042
+ isProduction as isProduction2
2181
2043
  } from "@frontmcp/utils";
2182
2044
 
2183
2045
  // libs/auth/src/errors/auth-internal.error.ts
2184
- import { randomBytes as randomBytes5, bytesToHex as bytesToHex2 } from "@frontmcp/utils";
2046
+ import { randomBytes as randomBytes4, bytesToHex as bytesToHex2 } from "@frontmcp/utils";
2185
2047
  var AuthInternalError = class extends Error {
2186
2048
  /**
2187
2049
  * Unique error ID for tracking in logs.
@@ -2203,7 +2065,7 @@ var AuthInternalError = class extends Error {
2203
2065
  super(message);
2204
2066
  this.name = this.constructor.name;
2205
2067
  this.code = code;
2206
- this.errorId = `err_${bytesToHex2(randomBytes5(8))}`;
2068
+ this.errorId = `err_${bytesToHex2(randomBytes4(8))}`;
2207
2069
  Error.captureStackTrace(this, this.constructor);
2208
2070
  }
2209
2071
  /**
@@ -2326,9 +2188,9 @@ var AuthFlowError = class extends AuthInternalError {
2326
2188
 
2327
2189
  // libs/auth/src/session/session-crypto.ts
2328
2190
  function getSigningSecret(config) {
2329
- const secret = config?.secret || process.env["MCP_SESSION_SECRET"];
2191
+ const secret = config?.secret || getEnv("MCP_SESSION_SECRET");
2330
2192
  if (!secret) {
2331
- if (process.env["NODE_ENV"] === "production") {
2193
+ if (isProduction2()) {
2332
2194
  throw new SessionSecretRequiredError("session signing");
2333
2195
  }
2334
2196
  console.warn("[SessionCrypto] MCP_SESSION_SECRET not set. Using insecure default for development only.");
@@ -2361,7 +2223,7 @@ var SessionRateLimiter = class {
2361
2223
  const cleanupIntervalMs = config.cleanupIntervalMs ?? 6e4;
2362
2224
  if (cleanupIntervalMs > 0) {
2363
2225
  this.cleanupTimer = setInterval(() => this.cleanup(), cleanupIntervalMs);
2364
- this.cleanupTimer.unref();
2226
+ if (typeof this.cleanupTimer.unref === "function") this.cleanupTimer.unref();
2365
2227
  }
2366
2228
  }
2367
2229
  /**
@@ -2469,12 +2331,11 @@ import { randomUUID as randomUUID2 } from "@frontmcp/utils";
2469
2331
  var TransportIdGenerator = class {
2470
2332
  /**
2471
2333
  * Create a transport session ID.
2472
- * Always generates JWT-style IDs for distributed session support.
2334
+ * Generates JWT-style IDs for distributed session support.
2473
2335
  *
2474
- * @param _mode - Deprecated parameter, kept for backwards compatibility
2475
- * @returns A JWT-style transport session ID (UUID without dashes)
2336
+ * @returns A transport session ID (UUID without dashes)
2476
2337
  */
2477
- static createId(_mode) {
2338
+ static createId() {
2478
2339
  return randomUUID2().replace(/-/g, "");
2479
2340
  }
2480
2341
  };
@@ -2565,18 +2426,20 @@ function extractBearerToken(header) {
2565
2426
  }
2566
2427
 
2567
2428
  // libs/auth/src/session/utils/session-crypto.utils.ts
2568
- import { sha256, encryptValue, decryptValue } from "@frontmcp/utils";
2429
+ import { sha256, encryptValue, decryptValue, getEnv as getEnv3, isProduction as isProduction4 } from "@frontmcp/utils";
2569
2430
 
2570
2431
  // libs/auth/src/machine-id/machine-id.ts
2571
- import * as path2 from "path";
2572
- import { randomUUID as randomUUID3, mkdir as mkdir2, writeFile as writeFile2, readFileSync } from "@frontmcp/utils";
2432
+ import { randomUUID as randomUUID3, mkdir, writeFile, readFileSync, getEnv as getEnv2, getCwd, isProduction as isProduction3, isBrowser } from "@frontmcp/utils";
2573
2433
  var DEFAULT_MACHINE_ID_PATH = ".frontmcp/machine-id";
2574
2434
  function isDevPersistenceEnabled() {
2575
- return process.env["NODE_ENV"] !== "production";
2435
+ if (isBrowser()) return false;
2436
+ return !isProduction3();
2576
2437
  }
2577
2438
  function resolveMachineIdPath() {
2578
- const machineIdPath = process.env["MACHINE_ID_PATH"] ?? DEFAULT_MACHINE_ID_PATH;
2579
- return path2.isAbsolute(machineIdPath) ? machineIdPath : path2.resolve(process.cwd(), machineIdPath);
2439
+ if (isBrowser()) return DEFAULT_MACHINE_ID_PATH;
2440
+ const path = __require("path");
2441
+ const machineIdPath = getEnv2("MACHINE_ID_PATH") ?? DEFAULT_MACHINE_ID_PATH;
2442
+ return path.isAbsolute(machineIdPath) ? machineIdPath : path.resolve(getCwd(), machineIdPath);
2580
2443
  }
2581
2444
  function loadMachineIdSync() {
2582
2445
  if (!isDevPersistenceEnabled()) {
@@ -2602,18 +2465,19 @@ function saveMachineIdAsync(machineId2) {
2602
2465
  return;
2603
2466
  }
2604
2467
  const machineIdPath = resolveMachineIdPath();
2605
- const dir = path2.dirname(machineIdPath);
2468
+ const path = __require("path");
2469
+ const dir = path.dirname(machineIdPath);
2606
2470
  (async () => {
2607
2471
  try {
2608
- await mkdir2(dir, { recursive: true, mode: 448 });
2609
- await writeFile2(machineIdPath, machineId2, { mode: 384 });
2472
+ await mkdir(dir, { recursive: true, mode: 448 });
2473
+ await writeFile(machineIdPath, machineId2, { mode: 384 });
2610
2474
  } catch (error) {
2611
2475
  console.warn(`[MachineId] Failed to save to ${machineIdPath}: ${error.message}`);
2612
2476
  }
2613
2477
  })();
2614
2478
  }
2615
2479
  var machineId = (() => {
2616
- const envMachineId = process.env["MACHINE_ID"];
2480
+ const envMachineId = getEnv2("MACHINE_ID");
2617
2481
  if (envMachineId) {
2618
2482
  return envMachineId;
2619
2483
  }
@@ -2637,10 +2501,9 @@ function setMachineIdOverride(id) {
2637
2501
  var cachedKey = null;
2638
2502
  function getKey() {
2639
2503
  if (cachedKey) return cachedKey;
2640
- const secret = process.env["MCP_SESSION_SECRET"];
2641
- const nodeEnv = process.env["NODE_ENV"];
2504
+ const secret = getEnv3("MCP_SESSION_SECRET");
2642
2505
  if (!secret) {
2643
- if (nodeEnv === "production") {
2506
+ if (isProduction4()) {
2644
2507
  throw new SessionSecretRequiredError("session ID encryption");
2645
2508
  }
2646
2509
  console.warn(
@@ -3554,7 +3417,7 @@ var VercelKvSessionStore = class {
3554
3417
  };
3555
3418
 
3556
3419
  // libs/auth/src/session/orchestrated-token.store.ts
3557
- import { encryptAesGcm as encryptAesGcm3, decryptAesGcm as decryptAesGcm3, randomBytes as randomBytes6, hkdfSha256 as hkdfSha2562 } from "@frontmcp/utils";
3420
+ import { encryptAesGcm as encryptAesGcm3, decryptAesGcm as decryptAesGcm3, randomBytes as randomBytes5, hkdfSha256 as hkdfSha2562 } from "@frontmcp/utils";
3558
3421
  var InMemoryOrchestratedTokenStore = class {
3559
3422
  /** Token storage: Map<compositeKey, ProviderTokenRecord> */
3560
3423
  tokens = /* @__PURE__ */ new Map();
@@ -3606,7 +3469,7 @@ var InMemoryOrchestratedTokenStore = class {
3606
3469
  async encryptRecord(compositeKey, record) {
3607
3470
  const key = await this.deriveKeyForRecord(compositeKey);
3608
3471
  const plaintext = JSON.stringify(record);
3609
- const iv = randomBytes6(12);
3472
+ const iv = randomBytes5(12);
3610
3473
  const { ciphertext, tag } = encryptAesGcm3(key, new TextEncoder().encode(plaintext), iv);
3611
3474
  return JSON.stringify({
3612
3475
  iv: Buffer.from(iv).toString("base64url"),
@@ -3989,30 +3852,30 @@ function startNextProvider(session, pkce, state) {
3989
3852
  }
3990
3853
 
3991
3854
  // libs/auth/src/session/encrypted-authorization-vault.ts
3992
- import { z as z6 } from "zod";
3855
+ import { z as z5 } from "zod";
3993
3856
  import { randomUUID as randomUUID9 } from "@frontmcp/utils";
3994
- import { AsyncLocalStorage } from "node:async_hooks";
3995
- var redisVaultEntrySchema = z6.object({
3857
+ import { AsyncLocalStorage } from "@frontmcp/utils";
3858
+ var redisVaultEntrySchema = z5.object({
3996
3859
  /** Vault ID */
3997
- id: z6.string(),
3860
+ id: z5.string(),
3998
3861
  /** User sub (for lookup) */
3999
- userSub: z6.string(),
3862
+ userSub: z5.string(),
4000
3863
  /** User email (optional, for display) */
4001
- userEmail: z6.string().optional(),
3864
+ userEmail: z5.string().optional(),
4002
3865
  /** User name (optional, for display) */
4003
- userName: z6.string().optional(),
3866
+ userName: z5.string().optional(),
4004
3867
  /** Client ID */
4005
- clientId: z6.string(),
3868
+ clientId: z5.string(),
4006
3869
  /** Creation timestamp */
4007
- createdAt: z6.number(),
3870
+ createdAt: z5.number(),
4008
3871
  /** Last access timestamp */
4009
- lastAccessAt: z6.number(),
3872
+ lastAccessAt: z5.number(),
4010
3873
  /** Authorized app IDs (unencrypted for quick auth checks) */
4011
- authorizedAppIds: z6.array(z6.string()),
3874
+ authorizedAppIds: z5.array(z5.string()),
4012
3875
  /** Skipped app IDs (unencrypted for quick checks) */
4013
- skippedAppIds: z6.array(z6.string()),
3876
+ skippedAppIds: z5.array(z5.string()),
4014
3877
  /** Pending auth request IDs (unencrypted for lookup) */
4015
- pendingAuthIds: z6.array(z6.string()),
3878
+ pendingAuthIds: z5.array(z5.string()),
4016
3879
  /** Encrypted sensitive data blob */
4017
3880
  encrypted: encryptedDataSchema
4018
3881
  });
@@ -4417,37 +4280,37 @@ function tryJwtExp(token) {
4417
4280
  }
4418
4281
 
4419
4282
  // libs/auth/src/authorization/authorization.types.ts
4420
- import { z as z7 } from "zod";
4421
- var authModeSchema = z7.enum(["public", "transparent", "orchestrated"]);
4422
- var authUserSchema = z7.object({
4423
- sub: z7.string(),
4424
- name: z7.string().optional(),
4425
- email: z7.string().email().optional(),
4426
- picture: z7.string().url().optional(),
4427
- anonymous: z7.boolean().optional()
4283
+ import { z as z6 } from "zod";
4284
+ var authModeSchema = z6.enum(["public", "transparent", "orchestrated"]);
4285
+ var authUserSchema = z6.object({
4286
+ sub: z6.string(),
4287
+ name: z6.string().optional(),
4288
+ email: z6.string().email().optional(),
4289
+ picture: z6.string().url().optional(),
4290
+ anonymous: z6.boolean().optional()
4428
4291
  });
4429
- var authorizedToolSchema = z7.object({
4430
- executionPath: z7.tuple([z7.string(), z7.string()]),
4431
- scopes: z7.array(z7.string()).optional(),
4432
- details: z7.record(z7.string(), z7.unknown()).optional()
4292
+ var authorizedToolSchema = z6.object({
4293
+ executionPath: z6.tuple([z6.string(), z6.string()]),
4294
+ scopes: z6.array(z6.string()).optional(),
4295
+ details: z6.record(z6.string(), z6.unknown()).optional()
4433
4296
  });
4434
- var authorizedPromptSchema = z7.object({
4435
- executionPath: z7.tuple([z7.string(), z7.string()]),
4436
- scopes: z7.array(z7.string()).optional(),
4437
- details: z7.record(z7.string(), z7.unknown()).optional()
4297
+ var authorizedPromptSchema = z6.object({
4298
+ executionPath: z6.tuple([z6.string(), z6.string()]),
4299
+ scopes: z6.array(z6.string()).optional(),
4300
+ details: z6.record(z6.string(), z6.unknown()).optional()
4438
4301
  });
4439
- var llmSafeAuthContextSchema = z7.object({
4440
- authorizationId: z7.string(),
4441
- sessionId: z7.string(),
4302
+ var llmSafeAuthContextSchema = z6.object({
4303
+ authorizationId: z6.string(),
4304
+ sessionId: z6.string(),
4442
4305
  mode: authModeSchema,
4443
- isAnonymous: z7.boolean(),
4444
- user: z7.object({
4445
- sub: z7.string(),
4446
- name: z7.string().optional()
4306
+ isAnonymous: z6.boolean(),
4307
+ user: z6.object({
4308
+ sub: z6.string(),
4309
+ name: z6.string().optional()
4447
4310
  }),
4448
- scopes: z7.array(z7.string()),
4449
- authorizedToolIds: z7.array(z7.string()),
4450
- authorizedPromptIds: z7.array(z7.string())
4311
+ scopes: z6.array(z6.string()),
4312
+ authorizedToolIds: z6.array(z6.string()),
4313
+ authorizedPromptIds: z6.array(z6.string())
4451
4314
  });
4452
4315
  var AppAuthState = /* @__PURE__ */ ((AppAuthState2) => {
4453
4316
  AppAuthState2["AUTHORIZED"] = "authorized";
@@ -4455,19 +4318,19 @@ var AppAuthState = /* @__PURE__ */ ((AppAuthState2) => {
4455
4318
  AppAuthState2["PENDING"] = "pending";
4456
4319
  return AppAuthState2;
4457
4320
  })(AppAuthState || {});
4458
- var appAuthStateSchema = z7.nativeEnum(AppAuthState);
4459
- var appAuthorizationRecordSchema = z7.object({
4460
- appId: z7.string(),
4321
+ var appAuthStateSchema = z6.nativeEnum(AppAuthState);
4322
+ var appAuthorizationRecordSchema = z6.object({
4323
+ appId: z6.string(),
4461
4324
  state: appAuthStateSchema,
4462
- stateChangedAt: z7.number(),
4463
- grantedScopes: z7.array(z7.string()).optional(),
4464
- authProviderId: z7.string().optional(),
4465
- toolIds: z7.array(z7.string())
4325
+ stateChangedAt: z6.number(),
4326
+ grantedScopes: z6.array(z6.string()).optional(),
4327
+ authProviderId: z6.string().optional(),
4328
+ toolIds: z6.array(z6.string())
4466
4329
  });
4467
- var progressiveAuthStateSchema = z7.object({
4468
- apps: z7.record(z7.string(), appAuthorizationRecordSchema),
4469
- initiallyAuthorized: z7.array(z7.string()),
4470
- initiallySkipped: z7.array(z7.string())
4330
+ var progressiveAuthStateSchema = z6.object({
4331
+ apps: z6.record(z6.string(), appAuthorizationRecordSchema),
4332
+ initiallyAuthorized: z6.array(z6.string()),
4333
+ initiallySkipped: z6.array(z6.string())
4471
4334
  });
4472
4335
 
4473
4336
  // libs/auth/src/authorization/authorization.class.ts
@@ -5326,42 +5189,42 @@ var OrchestratedAuthAccessorAdapter = class {
5326
5189
  };
5327
5190
 
5328
5191
  // libs/auth/src/common/jwt.types.ts
5329
- import { z as z8 } from "zod";
5330
- var jwkParametersSchema = z8.object({
5331
- kty: z8.string().optional(),
5332
- alg: z8.string().optional(),
5333
- key_ops: z8.array(z8.string()).optional(),
5334
- ext: z8.boolean().optional(),
5335
- use: z8.string().optional(),
5336
- x5c: z8.array(z8.string()).optional(),
5337
- x5t: z8.string().optional(),
5338
- "x5t#S256": z8.string().optional(),
5339
- x5u: z8.string().optional(),
5340
- kid: z8.string().optional()
5192
+ import { z as z7 } from "zod";
5193
+ var jwkParametersSchema = z7.object({
5194
+ kty: z7.string().optional(),
5195
+ alg: z7.string().optional(),
5196
+ key_ops: z7.array(z7.string()).optional(),
5197
+ ext: z7.boolean().optional(),
5198
+ use: z7.string().optional(),
5199
+ x5c: z7.array(z7.string()).optional(),
5200
+ x5t: z7.string().optional(),
5201
+ "x5t#S256": z7.string().optional(),
5202
+ x5u: z7.string().optional(),
5203
+ kid: z7.string().optional()
5341
5204
  });
5342
5205
  var jwkSchema = jwkParametersSchema.extend({
5343
- crv: z8.string().optional(),
5344
- d: z8.string().optional(),
5345
- dp: z8.string().optional(),
5346
- dq: z8.string().optional(),
5347
- e: z8.string().optional(),
5348
- k: z8.string().optional(),
5349
- n: z8.string().optional(),
5350
- p: z8.string().optional(),
5351
- q: z8.string().optional(),
5352
- qi: z8.string().optional(),
5353
- x: z8.string().optional(),
5354
- y: z8.string().optional(),
5355
- pub: z8.string().optional(),
5356
- priv: z8.string().optional()
5206
+ crv: z7.string().optional(),
5207
+ d: z7.string().optional(),
5208
+ dp: z7.string().optional(),
5209
+ dq: z7.string().optional(),
5210
+ e: z7.string().optional(),
5211
+ k: z7.string().optional(),
5212
+ n: z7.string().optional(),
5213
+ p: z7.string().optional(),
5214
+ q: z7.string().optional(),
5215
+ qi: z7.string().optional(),
5216
+ x: z7.string().optional(),
5217
+ y: z7.string().optional(),
5218
+ pub: z7.string().optional(),
5219
+ priv: z7.string().optional()
5357
5220
  });
5358
- var jsonWebKeySetSchema = z8.object({
5359
- keys: z8.array(jwkSchema)
5221
+ var jsonWebKeySetSchema = z7.object({
5222
+ keys: z7.array(jwkSchema)
5360
5223
  });
5361
5224
 
5362
5225
  // libs/auth/src/common/session.types.ts
5363
- import { z as z9 } from "zod";
5364
- var aiPlatformTypeSchema = z9.enum([
5226
+ import { z as z8 } from "zod";
5227
+ var aiPlatformTypeSchema = z8.enum([
5365
5228
  "openai",
5366
5229
  "claude",
5367
5230
  "gemini",
@@ -5372,45 +5235,45 @@ var aiPlatformTypeSchema = z9.enum([
5372
5235
  "ext-apps",
5373
5236
  "unknown"
5374
5237
  ]);
5375
- var userClaimSchema = z9.object({
5376
- iss: z9.string(),
5377
- sid: z9.string().optional(),
5378
- sub: z9.string(),
5379
- exp: z9.number().optional(),
5380
- iat: z9.number().optional(),
5381
- aud: z9.union([z9.string(), z9.array(z9.string())]).optional(),
5382
- email: z9.string().optional(),
5383
- username: z9.string().optional(),
5384
- preferred_username: z9.string().optional(),
5385
- name: z9.string().optional(),
5386
- picture: z9.string().optional()
5238
+ var userClaimSchema = z8.object({
5239
+ iss: z8.string(),
5240
+ sid: z8.string().optional(),
5241
+ sub: z8.string(),
5242
+ exp: z8.number().optional(),
5243
+ iat: z8.number().optional(),
5244
+ aud: z8.union([z8.string(), z8.array(z8.string())]).optional(),
5245
+ email: z8.string().optional(),
5246
+ username: z8.string().optional(),
5247
+ preferred_username: z8.string().optional(),
5248
+ name: z8.string().optional(),
5249
+ picture: z8.string().optional()
5387
5250
  }).passthrough();
5388
- var sessionIdPayloadSchema = z9.object({
5389
- nodeId: z9.string(),
5390
- authSig: z9.string(),
5391
- uuid: z9.string().uuid(),
5392
- iat: z9.number(),
5393
- protocol: z9.enum(["legacy-sse", "sse", "streamable-http", "stateful-http", "stateless-http"]).optional(),
5394
- isPublic: z9.boolean().optional(),
5251
+ var sessionIdPayloadSchema = z8.object({
5252
+ nodeId: z8.string(),
5253
+ authSig: z8.string(),
5254
+ uuid: z8.string().uuid(),
5255
+ iat: z8.number(),
5256
+ protocol: z8.enum(["legacy-sse", "sse", "streamable-http", "stateful-http", "stateless-http"]).optional(),
5257
+ isPublic: z8.boolean().optional(),
5395
5258
  platformType: aiPlatformTypeSchema.optional(),
5396
- clientName: z9.string().optional(),
5397
- clientVersion: z9.string().optional(),
5398
- supportsElicitation: z9.boolean().optional(),
5399
- skillsOnlyMode: z9.boolean().optional()
5259
+ clientName: z8.string().optional(),
5260
+ clientVersion: z8.string().optional(),
5261
+ supportsElicitation: z8.boolean().optional(),
5262
+ skillsOnlyMode: z8.boolean().optional()
5400
5263
  });
5401
- var sessionIdSchema = z9.object({
5402
- id: z9.string(),
5264
+ var sessionIdSchema = z8.object({
5265
+ id: z8.string(),
5403
5266
  /** Payload is optional - may be undefined when session validation failed but ID is passed for transport lookup */
5404
5267
  payload: sessionIdPayloadSchema.optional()
5405
5268
  });
5406
- var authorizationSchema = z9.object({
5407
- token: z9.string(),
5269
+ var authorizationSchema = z8.object({
5270
+ token: z8.string(),
5408
5271
  session: sessionIdSchema.optional(),
5409
5272
  user: userClaimSchema
5410
5273
  });
5411
5274
 
5412
5275
  // libs/auth/src/options/shared.schemas.ts
5413
- import { z as z11 } from "zod";
5276
+ import { z as z10 } from "zod";
5414
5277
 
5415
5278
  // libs/auth/src/cimd/cimd.logger.ts
5416
5279
  var noopLogger = {
@@ -5426,169 +5289,169 @@ var noopLogger = {
5426
5289
  };
5427
5290
 
5428
5291
  // libs/auth/src/cimd/cimd.types.ts
5429
- import { z as z10 } from "zod";
5430
- var clientMetadataDocumentSchema = z10.object({
5292
+ import { z as z9 } from "zod";
5293
+ var clientMetadataDocumentSchema = z9.object({
5431
5294
  // REQUIRED per CIMD spec
5432
5295
  /**
5433
5296
  * Client identifier - MUST match the URL from which this document was fetched.
5434
5297
  */
5435
- client_id: z10.string().url(),
5298
+ client_id: z9.string().url(),
5436
5299
  /**
5437
5300
  * Human-readable name of the client.
5438
5301
  */
5439
- client_name: z10.string().min(1),
5302
+ client_name: z9.string().min(1),
5440
5303
  /**
5441
5304
  * Array of redirect URIs for authorization responses.
5442
5305
  * At least one is required.
5443
5306
  */
5444
- redirect_uris: z10.array(z10.string().url()).min(1),
5307
+ redirect_uris: z9.array(z9.string().url()).min(1),
5445
5308
  // OPTIONAL per RFC 7591
5446
5309
  /**
5447
5310
  * Token endpoint authentication method.
5448
5311
  * @default 'none'
5449
5312
  */
5450
- token_endpoint_auth_method: z10.enum(["none", "client_secret_basic", "client_secret_post", "private_key_jwt"]).default("none"),
5313
+ token_endpoint_auth_method: z9.enum(["none", "client_secret_basic", "client_secret_post", "private_key_jwt"]).default("none"),
5451
5314
  /**
5452
5315
  * OAuth grant types the client can use.
5453
5316
  * @default ['authorization_code']
5454
5317
  */
5455
- grant_types: z10.array(z10.string()).default(["authorization_code"]),
5318
+ grant_types: z9.array(z9.string()).default(["authorization_code"]),
5456
5319
  /**
5457
5320
  * OAuth response types the client can request.
5458
5321
  * @default ['code']
5459
5322
  */
5460
- response_types: z10.array(z10.string()).default(["code"]),
5323
+ response_types: z9.array(z9.string()).default(["code"]),
5461
5324
  /**
5462
5325
  * URL of the client's home page.
5463
5326
  */
5464
- client_uri: z10.string().url().optional(),
5327
+ client_uri: z9.string().url().optional(),
5465
5328
  /**
5466
5329
  * URL of the client's logo image.
5467
5330
  */
5468
- logo_uri: z10.string().url().optional(),
5331
+ logo_uri: z9.string().url().optional(),
5469
5332
  /**
5470
5333
  * URL of the client's JWKS (for private_key_jwt).
5471
5334
  */
5472
- jwks_uri: z10.string().url().optional(),
5335
+ jwks_uri: z9.string().url().optional(),
5473
5336
  /**
5474
5337
  * Inline JWKS (for private_key_jwt).
5475
5338
  */
5476
- jwks: z10.object({
5477
- keys: z10.array(z10.record(z10.string(), z10.unknown()))
5339
+ jwks: z9.object({
5340
+ keys: z9.array(z9.record(z9.string(), z9.unknown()))
5478
5341
  }).optional(),
5479
5342
  /**
5480
5343
  * URL of the client's terms of service.
5481
5344
  */
5482
- tos_uri: z10.string().url().optional(),
5345
+ tos_uri: z9.string().url().optional(),
5483
5346
  /**
5484
5347
  * URL of the client's privacy policy.
5485
5348
  */
5486
- policy_uri: z10.string().url().optional(),
5349
+ policy_uri: z9.string().url().optional(),
5487
5350
  /**
5488
5351
  * Requested OAuth scopes.
5489
5352
  */
5490
- scope: z10.string().optional(),
5353
+ scope: z9.string().optional(),
5491
5354
  /**
5492
5355
  * Array of contact emails for the client.
5493
5356
  */
5494
- contacts: z10.array(z10.string().email()).optional(),
5357
+ contacts: z9.array(z9.string().email()).optional(),
5495
5358
  /**
5496
5359
  * Software statement (signed JWT).
5497
5360
  */
5498
- software_statement: z10.string().optional(),
5361
+ software_statement: z9.string().optional(),
5499
5362
  /**
5500
5363
  * Unique identifier for the client software.
5501
5364
  */
5502
- software_id: z10.string().optional(),
5365
+ software_id: z9.string().optional(),
5503
5366
  /**
5504
5367
  * Version of the client software.
5505
5368
  */
5506
- software_version: z10.string().optional()
5369
+ software_version: z9.string().optional()
5507
5370
  });
5508
- var cimdRedisCacheConfigSchema = z10.object({
5371
+ var cimdRedisCacheConfigSchema = z9.object({
5509
5372
  /**
5510
5373
  * Redis connection URL.
5511
5374
  * e.g., "redis://user:pass@host:6379/0"
5512
5375
  */
5513
- url: z10.string().optional(),
5376
+ url: z9.string().optional(),
5514
5377
  /**
5515
5378
  * Redis host.
5516
5379
  */
5517
- host: z10.string().optional(),
5380
+ host: z9.string().optional(),
5518
5381
  /**
5519
5382
  * Redis port.
5520
5383
  * @default 6379
5521
5384
  */
5522
- port: z10.number().optional(),
5385
+ port: z9.number().optional(),
5523
5386
  /**
5524
5387
  * Redis password.
5525
5388
  */
5526
- password: z10.string().optional(),
5389
+ password: z9.string().optional(),
5527
5390
  /**
5528
5391
  * Redis database number.
5529
5392
  * @default 0
5530
5393
  */
5531
- db: z10.number().optional(),
5394
+ db: z9.number().optional(),
5532
5395
  /**
5533
5396
  * Enable TLS for Redis connection.
5534
5397
  * @default false
5535
5398
  */
5536
- tls: z10.boolean().optional(),
5399
+ tls: z9.boolean().optional(),
5537
5400
  /**
5538
5401
  * Key prefix for CIMD cache entries.
5539
5402
  * @default 'cimd:'
5540
5403
  */
5541
- keyPrefix: z10.string().default("cimd:")
5404
+ keyPrefix: z9.string().default("cimd:")
5542
5405
  });
5543
- var cimdCacheConfigSchema = z10.object({
5406
+ var cimdCacheConfigSchema = z9.object({
5544
5407
  /**
5545
5408
  * Cache storage type.
5546
5409
  * - 'memory': In-memory cache (default, suitable for dev/single-instance)
5547
5410
  * - 'redis': Redis-backed cache (for production/distributed deployments)
5548
5411
  * @default 'memory'
5549
5412
  */
5550
- type: z10.enum(["memory", "redis"]).default("memory"),
5413
+ type: z9.enum(["memory", "redis"]).default("memory"),
5551
5414
  /**
5552
5415
  * Default TTL for cached metadata documents.
5553
5416
  * @default 3600000 (1 hour)
5554
5417
  */
5555
- defaultTtlMs: z10.number().min(0).default(36e5),
5418
+ defaultTtlMs: z9.number().min(0).default(36e5),
5556
5419
  /**
5557
5420
  * Maximum TTL (even if server suggests longer).
5558
5421
  * @default 86400000 (24 hours)
5559
5422
  */
5560
- maxTtlMs: z10.number().min(0).default(864e5),
5423
+ maxTtlMs: z9.number().min(0).default(864e5),
5561
5424
  /**
5562
5425
  * Minimum TTL (even if server suggests shorter).
5563
5426
  * @default 60000 (1 minute)
5564
5427
  */
5565
- minTtlMs: z10.number().min(0).default(6e4),
5428
+ minTtlMs: z9.number().min(0).default(6e4),
5566
5429
  /**
5567
5430
  * Redis configuration (required when type is 'redis').
5568
5431
  */
5569
5432
  redis: cimdRedisCacheConfigSchema.optional()
5570
5433
  });
5571
- var cimdSecurityConfigSchema = z10.object({
5434
+ var cimdSecurityConfigSchema = z9.object({
5572
5435
  /**
5573
5436
  * Block fetching from private/internal IP addresses (SSRF protection).
5574
5437
  * @default true
5575
5438
  */
5576
- blockPrivateIPs: z10.boolean().default(true),
5439
+ blockPrivateIPs: z9.boolean().default(true),
5577
5440
  /**
5578
5441
  * Explicit list of allowed domains.
5579
5442
  * If set, only these domains can host CIMD documents.
5580
5443
  */
5581
- allowedDomains: z10.array(z10.string()).optional(),
5444
+ allowedDomains: z9.array(z9.string()).optional(),
5582
5445
  /**
5583
5446
  * Explicit list of blocked domains.
5584
5447
  * These domains cannot host CIMD documents.
5585
5448
  */
5586
- blockedDomains: z10.array(z10.string()).optional(),
5449
+ blockedDomains: z9.array(z9.string()).optional(),
5587
5450
  /**
5588
5451
  * Warn when a client has only localhost redirect URIs.
5589
5452
  * @default true
5590
5453
  */
5591
- warnOnLocalhostRedirects: z10.boolean().default(true),
5454
+ warnOnLocalhostRedirects: z9.boolean().default(true),
5592
5455
  /**
5593
5456
  * Allow HTTP (instead of HTTPS) for localhost CIMD URLs.
5594
5457
  *
@@ -5599,19 +5462,19 @@ var cimdSecurityConfigSchema = z10.object({
5599
5462
  *
5600
5463
  * @default false
5601
5464
  */
5602
- allowInsecureForTesting: z10.boolean().default(false)
5465
+ allowInsecureForTesting: z9.boolean().default(false)
5603
5466
  });
5604
- var cimdNetworkConfigSchema = z10.object({
5467
+ var cimdNetworkConfigSchema = z9.object({
5605
5468
  /**
5606
5469
  * Request timeout in milliseconds.
5607
5470
  * @default 5000 (5 seconds)
5608
5471
  */
5609
- timeoutMs: z10.number().min(100).default(5e3),
5472
+ timeoutMs: z9.number().min(100).default(5e3),
5610
5473
  /**
5611
5474
  * Maximum response body size in bytes.
5612
5475
  * @default 65536 (64KB)
5613
5476
  */
5614
- maxResponseSizeBytes: z10.number().min(1024).default(65536),
5477
+ maxResponseSizeBytes: z9.number().min(1024).default(65536),
5615
5478
  /**
5616
5479
  * Redirect handling policy for CIMD fetches.
5617
5480
  * - 'deny': reject redirects (default, safest)
@@ -5619,19 +5482,19 @@ var cimdNetworkConfigSchema = z10.object({
5619
5482
  * - 'allow': allow redirects to any origin
5620
5483
  * @default 'deny'
5621
5484
  */
5622
- redirectPolicy: z10.enum(["deny", "same-origin", "allow"]).default("deny"),
5485
+ redirectPolicy: z9.enum(["deny", "same-origin", "allow"]).default("deny"),
5623
5486
  /**
5624
5487
  * Maximum number of redirects to follow when redirects are allowed.
5625
5488
  * @default 5
5626
5489
  */
5627
- maxRedirects: z10.number().int().min(0).default(5)
5490
+ maxRedirects: z9.number().int().min(0).default(5)
5628
5491
  });
5629
- var cimdConfigSchema = z10.object({
5492
+ var cimdConfigSchema = z9.object({
5630
5493
  /**
5631
5494
  * Enable CIMD support.
5632
5495
  * @default true
5633
5496
  */
5634
- enabled: z10.boolean().default(true),
5497
+ enabled: z9.boolean().default(true),
5635
5498
  /**
5636
5499
  * Cache configuration.
5637
5500
  */
@@ -5994,7 +5857,7 @@ var CimdService = class {
5994
5857
  this.cacheConfig = cimdCacheConfigSchema.parse(this.config.cache ?? {});
5995
5858
  this.securityConfig = cimdSecurityConfigSchema.parse(this.config.security ?? {});
5996
5859
  this.networkConfig = cimdNetworkConfigSchema.parse(this.config.network ?? {});
5997
- this.cache = new CimdCache(this.cacheConfig);
5860
+ this.cache = new InMemoryCimdCache(this.cacheConfig);
5998
5861
  this.logger.debug("CimdService initialized", {
5999
5862
  enabled: this.config.enabled,
6000
5863
  cacheDefaultTtlMs: this.cacheConfig.defaultTtlMs,
@@ -6262,8 +6125,8 @@ var CimdService = class {
6262
6125
  const result = clientMetadataDocumentSchema.safeParse(document);
6263
6126
  if (!result.success) {
6264
6127
  const errors = result.error.issues.map((issue) => {
6265
- const path3 = issue.path.length > 0 ? `${issue.path.join(".")}: ` : "";
6266
- return `${path3}${issue.message}`;
6128
+ const path = issue.path.length > 0 ? `${issue.path.join(".")}: ` : "";
6129
+ return `${path}${issue.message}`;
6267
6130
  });
6268
6131
  throw new CimdValidationError(clientId, errors);
6269
6132
  }
@@ -6285,55 +6148,84 @@ function normalizeRedirectUri(uri) {
6285
6148
  }
6286
6149
 
6287
6150
  // libs/auth/src/options/shared.schemas.ts
6288
- var publicAccessConfigSchema = z11.object({
6151
+ var publicAccessConfigSchema = z10.object({
6289
6152
  /**
6290
6153
  * Allow all tools or explicit whitelist
6291
6154
  * @default 'all'
6292
6155
  */
6293
- tools: z11.union([z11.literal("all"), z11.array(z11.string())]).default("all"),
6156
+ tools: z10.union([z10.literal("all"), z10.array(z10.string())]).default("all"),
6294
6157
  /**
6295
6158
  * Allow all prompts or explicit whitelist
6296
6159
  * @default 'all'
6297
6160
  */
6298
- prompts: z11.union([z11.literal("all"), z11.array(z11.string())]).default("all"),
6161
+ prompts: z10.union([z10.literal("all"), z10.array(z10.string())]).default("all"),
6299
6162
  /**
6300
6163
  * Rate limit per IP per minute
6301
6164
  * @default 60
6302
6165
  */
6303
- rateLimit: z11.number().default(60)
6166
+ rateLimit: z10.number().default(60)
6304
6167
  });
6305
- var localSigningConfigSchema = z11.object({
6168
+ var localSigningConfigSchema = z10.object({
6306
6169
  /**
6307
- * Private key for signing orchestrated tokens
6170
+ * Private key for signing tokens
6308
6171
  * @default auto-generated
6309
6172
  */
6310
- signKey: jwkSchema.or(z11.instanceof(Uint8Array)).optional(),
6173
+ signKey: jwkSchema.or(z10.instanceof(Uint8Array)).optional(),
6311
6174
  /**
6312
6175
  * JWKS for token verification
6313
6176
  * @default auto-generated
6314
6177
  */
6315
6178
  jwks: jsonWebKeySetSchema.optional(),
6316
6179
  /**
6317
- * Issuer identifier for orchestrated tokens
6180
+ * Issuer identifier for tokens
6318
6181
  * @default auto-derived from server URL
6319
6182
  */
6320
- issuer: z11.string().optional()
6183
+ issuer: z10.string().optional()
6321
6184
  });
6322
- var remoteProviderConfigSchema = z11.object({
6185
+ var providerConfigSchema = z10.object({
6186
+ /** Provider display name */
6187
+ name: z10.string().optional(),
6188
+ /**
6189
+ * Unique identifier for this provider
6190
+ * @default derived from provider URL
6191
+ */
6192
+ id: z10.string().optional(),
6193
+ /**
6194
+ * Inline JWKS for offline token verification
6195
+ * Falls back to fetching from provider's /.well-known/jwks.json
6196
+ */
6197
+ jwks: jsonWebKeySetSchema.optional(),
6198
+ /** Custom JWKS URI if not at standard path */
6199
+ jwksUri: z10.string().url().optional(),
6200
+ /**
6201
+ * Enable Dynamic Client Registration (DCR)
6202
+ * @default false
6203
+ */
6204
+ dcrEnabled: z10.boolean().default(false),
6205
+ /** Authorization endpoint override */
6206
+ authEndpoint: z10.string().url().optional(),
6207
+ /** Token endpoint override */
6208
+ tokenEndpoint: z10.string().url().optional(),
6209
+ /** Registration endpoint override (for DCR) */
6210
+ registrationEndpoint: z10.string().url().optional(),
6211
+ /** User info endpoint override */
6212
+ userInfoEndpoint: z10.string().url().optional()
6213
+ });
6214
+ var remoteProviderConfigSchema = z10.object({
6323
6215
  /**
6324
6216
  * OAuth provider base URL
6325
6217
  * @example 'https://auth.example.com'
6326
6218
  */
6327
- provider: z11.string().url(),
6219
+ provider: z10.string().url(),
6328
6220
  /**
6329
6221
  * Provider display name
6330
6222
  */
6331
- name: z11.string().optional(),
6223
+ name: z10.string().optional(),
6332
6224
  /**
6333
6225
  * Unique identifier for this provider
6334
6226
  * @default derived from provider URL
6335
6227
  */
6336
- id: z11.string().optional(),
6228
+ id: z10.string().optional(),
6337
6229
  /**
6338
6230
  * Inline JWKS for offline token verification
6339
6231
  * Falls back to fetching from provider's /.well-known/jwks.json
@@ -6342,121 +6234,133 @@ var remoteProviderConfigSchema = z11.object({
6342
6234
  /**
6343
6235
  * Custom JWKS URI if not at standard path
6344
6236
  */
6345
- jwksUri: z11.string().url().optional(),
6237
+ jwksUri: z10.string().url().optional(),
6346
6238
  /**
6347
- * Client ID for this MCP server (for orchestrated mode)
6239
+ * Client ID for this MCP server
6348
6240
  */
6349
- clientId: z11.string().optional(),
6241
+ clientId: z10.string().optional(),
6350
6242
  /**
6351
- * Client secret (for confidential clients in orchestrated mode)
6243
+ * Client secret (for confidential clients)
6352
6244
  */
6353
- clientSecret: z11.string().optional(),
6245
+ clientSecret: z10.string().optional(),
6354
6246
  /**
6355
6247
  * Scopes to request from the upstream provider
6356
6248
  */
6357
- scopes: z11.array(z11.string()).optional(),
6249
+ scopes: z10.array(z10.string()).optional(),
6358
6250
  /**
6359
6251
  * Enable Dynamic Client Registration (DCR)
6360
6252
  * @default false
6361
6253
  */
6362
- dcrEnabled: z11.boolean().default(false),
6254
+ dcrEnabled: z10.boolean().default(false),
6363
6255
  /**
6364
6256
  * Authorization endpoint override
6365
6257
  */
6366
- authEndpoint: z11.string().url().optional(),
6258
+ authEndpoint: z10.string().url().optional(),
6367
6259
  /**
6368
6260
  * Token endpoint override
6369
6261
  */
6370
- tokenEndpoint: z11.string().url().optional(),
6262
+ tokenEndpoint: z10.string().url().optional(),
6371
6263
  /**
6372
6264
  * Registration endpoint override (for DCR)
6373
6265
  */
6374
- registrationEndpoint: z11.string().url().optional(),
6266
+ registrationEndpoint: z10.string().url().optional(),
6375
6267
  /**
6376
6268
  * User info endpoint override
6377
6269
  */
6378
- userInfoEndpoint: z11.string().url().optional()
6270
+ userInfoEndpoint: z10.string().url().optional()
6379
6271
  });
6380
- var tokenStorageConfigSchema = z11.discriminatedUnion("type", [
6381
- z11.object({ type: z11.literal("memory") }),
6382
- z11.object({ type: z11.literal("redis"), config: redisConfigSchema })
6383
- ]);
6384
- var tokenRefreshConfigSchema = z11.object({
6272
+ var flatRemoteProviderFields = {
6273
+ /**
6274
+ * OAuth provider base URL (required)
6275
+ * @example 'https://auth.example.com'
6276
+ */
6277
+ provider: z10.string().url(),
6278
+ /** Client ID for this MCP server */
6279
+ clientId: z10.string().optional(),
6280
+ /** Client secret (for confidential clients) */
6281
+ clientSecret: z10.string().optional(),
6282
+ /** Scopes to request from the upstream provider */
6283
+ scopes: z10.array(z10.string()).optional(),
6284
+ /** Advanced provider configuration */
6285
+ providerConfig: providerConfigSchema.optional()
6286
+ };
6287
+ var tokenStorageConfigSchema = z10.union([z10.literal("memory"), z10.object({ redis: redisConfigSchema })]);
6288
+ var tokenRefreshConfigSchema = z10.object({
6385
6289
  /**
6386
6290
  * Enable automatic token refresh
6387
6291
  * @default true
6388
6292
  */
6389
- enabled: z11.boolean().default(true),
6293
+ enabled: z10.boolean().default(true),
6390
6294
  /**
6391
6295
  * Refresh token before expiry by this many seconds
6392
6296
  * @default 60
6393
6297
  */
6394
- skewSeconds: z11.number().default(60)
6298
+ skewSeconds: z10.number().default(60)
6395
6299
  });
6396
- var skippedAppBehaviorSchema = z11.enum(["anonymous", "require-auth"]);
6397
- var consentConfigSchema = z11.object({
6300
+ var skippedAppBehaviorSchema = z10.enum(["anonymous", "require-auth"]);
6301
+ var consentConfigSchema = z10.object({
6398
6302
  /**
6399
6303
  * Enable consent flow for tool selection
6400
6304
  * When enabled, users can choose which tools to expose to the LLM
6401
6305
  * @default false
6402
6306
  */
6403
- enabled: z11.boolean().default(false),
6307
+ enabled: z10.boolean().default(false),
6404
6308
  /**
6405
6309
  * Group tools by app in the consent UI
6406
6310
  * @default true
6407
6311
  */
6408
- groupByApp: z11.boolean().default(true),
6312
+ groupByApp: z10.boolean().default(true),
6409
6313
  /**
6410
6314
  * Show tool descriptions in consent UI
6411
6315
  * @default true
6412
6316
  */
6413
- showDescriptions: z11.boolean().default(true),
6317
+ showDescriptions: z10.boolean().default(true),
6414
6318
  /**
6415
6319
  * Allow selecting all tools at once
6416
6320
  * @default true
6417
6321
  */
6418
- allowSelectAll: z11.boolean().default(true),
6322
+ allowSelectAll: z10.boolean().default(true),
6419
6323
  /**
6420
6324
  * Require at least one tool to be selected
6421
6325
  * @default true
6422
6326
  */
6423
- requireSelection: z11.boolean().default(true),
6327
+ requireSelection: z10.boolean().default(true),
6424
6328
  /**
6425
6329
  * Custom message to display on consent page
6426
6330
  */
6427
- customMessage: z11.string().optional(),
6331
+ customMessage: z10.string().optional(),
6428
6332
  /**
6429
6333
  * Remember consent for future sessions
6430
6334
  * @default true
6431
6335
  */
6432
- rememberConsent: z11.boolean().default(true),
6336
+ rememberConsent: z10.boolean().default(true),
6433
6337
  /**
6434
6338
  * Tools to exclude from consent (always available)
6435
6339
  * Useful for essential tools that should always be accessible
6436
6340
  */
6437
- excludedTools: z11.array(z11.string()).optional(),
6341
+ excludedTools: z10.array(z10.string()).optional(),
6438
6342
  /**
6439
6343
  * Tools to always include in consent (pre-selected)
6440
6344
  */
6441
- defaultSelectedTools: z11.array(z11.string()).optional()
6345
+ defaultSelectedTools: z10.array(z10.string()).optional()
6442
6346
  });
6443
- var federatedAuthConfigSchema = z11.object({
6347
+ var federatedAuthConfigSchema = z10.object({
6444
6348
  /**
6445
6349
  * How strictly to validate the OAuth state parameter on provider callbacks.
6446
6350
  * - 'strict': require exact match to stored state (default, safest)
6447
6351
  * - 'format': validate only "federated:{sessionId}:{nonce}" format
6448
6352
  * @default 'strict'
6449
6353
  */
6450
- stateValidation: z11.enum(["strict", "format"]).default("strict")
6354
+ stateValidation: z10.enum(["strict", "format"]).default("strict")
6451
6355
  });
6452
- var incrementalAuthConfigSchema = z11.object({
6356
+ var incrementalAuthConfigSchema = z10.object({
6453
6357
  /**
6454
6358
  * Enable incremental (progressive) authorization
6455
6359
  * When enabled, users can skip app authorizations during initial auth
6456
6360
  * and authorize individual apps later when needed
6457
6361
  * @default true
6458
6362
  */
6459
- enabled: z11.boolean().default(true),
6363
+ enabled: z10.boolean().default(true),
6460
6364
  /**
6461
6365
  * Behavior when a tool from a skipped app is called
6462
6366
  * - 'anonymous': If app supports anonymous access, use it; otherwise require auth
@@ -6468,33 +6372,33 @@ var incrementalAuthConfigSchema = z11.object({
6468
6372
  * Allow users to skip app authorization during initial auth flow
6469
6373
  * @default true
6470
6374
  */
6471
- allowSkip: z11.boolean().default(true),
6375
+ allowSkip: z10.boolean().default(true),
6472
6376
  /**
6473
6377
  * Show all apps in a single authorization page (vs step-by-step)
6474
6378
  * @default true
6475
6379
  */
6476
- showAllAppsAtOnce: z11.boolean().default(true)
6380
+ showAllAppsAtOnce: z10.boolean().default(true)
6477
6381
  });
6478
6382
 
6479
6383
  // libs/auth/src/options/public.schema.ts
6480
- import { z as z12 } from "zod";
6481
- var publicAuthOptionsSchema = z12.object({
6482
- mode: z12.literal("public"),
6384
+ import { z as z11 } from "zod";
6385
+ var publicAuthOptionsSchema = z11.object({
6386
+ mode: z11.literal("public"),
6483
6387
  /**
6484
6388
  * Issuer identifier for anonymous JWTs
6485
6389
  * @default auto-derived from server URL
6486
6390
  */
6487
- issuer: z12.string().optional(),
6391
+ issuer: z11.string().optional(),
6488
6392
  /**
6489
6393
  * Anonymous session TTL in seconds
6490
6394
  * @default 3600 (1 hour)
6491
6395
  */
6492
- sessionTtl: z12.number().default(3600),
6396
+ sessionTtl: z11.number().default(3600),
6493
6397
  /**
6494
6398
  * Scopes granted to anonymous sessions
6495
6399
  * @default ['anonymous']
6496
6400
  */
6497
- anonymousScopes: z12.array(z12.string()).default(["anonymous"]),
6401
+ anonymousScopes: z11.array(z11.string()).default(["anonymous"]),
6498
6402
  /**
6499
6403
  * Tool/prompt access configuration for anonymous users
6500
6404
  */
@@ -6508,38 +6412,38 @@ var publicAuthOptionsSchema = z12.object({
6508
6412
  * Private key for signing anonymous tokens
6509
6413
  * @default auto-generated
6510
6414
  */
6511
- signKey: jwkSchema.or(z12.instanceof(Uint8Array)).optional()
6415
+ signKey: jwkSchema.or(z11.instanceof(Uint8Array)).optional()
6512
6416
  });
6513
6417
 
6514
6418
  // libs/auth/src/options/transparent.schema.ts
6515
- import { z as z13 } from "zod";
6516
- var transparentAuthOptionsSchema = z13.object({
6517
- mode: z13.literal("transparent"),
6419
+ import { z as z12 } from "zod";
6420
+ var transparentAuthOptionsSchema = z12.object({
6421
+ mode: z12.literal("transparent"),
6518
6422
  /**
6519
- * Remote OAuth provider configuration (required)
6423
+ * Flattened remote provider fields (provider, clientId, clientSecret, scopes, providerConfig)
6520
6424
  */
6521
- remote: remoteProviderConfigSchema,
6425
+ ...flatRemoteProviderFields,
6522
6426
  /**
6523
6427
  * Expected token audience
6524
6428
  * If not set, defaults to the resource URL
6525
6429
  */
6526
- expectedAudience: z13.union([z13.string(), z13.array(z13.string())]).optional(),
6430
+ expectedAudience: z12.union([z12.string(), z12.array(z12.string())]).optional(),
6527
6431
  /**
6528
6432
  * Required scopes for access
6529
6433
  * Empty array means any valid token is accepted
6530
6434
  * @default []
6531
6435
  */
6532
- requiredScopes: z13.array(z13.string()).default([]),
6436
+ requiredScopes: z12.array(z12.string()).default([]),
6533
6437
  /**
6534
6438
  * Allow anonymous fallback when no token is provided
6535
6439
  * @default false
6536
6440
  */
6537
- allowAnonymous: z13.boolean().default(false),
6441
+ allowAnonymous: z12.boolean().default(false),
6538
6442
  /**
6539
6443
  * Scopes granted to anonymous sessions (when allowAnonymous=true)
6540
6444
  * @default ['anonymous']
6541
6445
  */
6542
- anonymousScopes: z13.array(z13.string()).default(["anonymous"]),
6446
+ anonymousScopes: z12.array(z12.string()).default(["anonymous"]),
6543
6447
  /**
6544
6448
  * Public access config for anonymous users (when allowAnonymous=true)
6545
6449
  */
@@ -6547,56 +6451,52 @@ var transparentAuthOptionsSchema = z13.object({
6547
6451
  });
6548
6452
 
6549
6453
  // libs/auth/src/options/orchestrated.schema.ts
6550
- import { z as z14 } from "zod";
6551
- var orchestratedSharedFields = {
6454
+ import { z as z13 } from "zod";
6455
+ var sharedAuthFields = {
6552
6456
  local: localSigningConfigSchema.optional(),
6553
- tokenStorage: tokenStorageConfigSchema.default({ type: "memory" }),
6554
- allowDefaultPublic: z14.boolean().default(false),
6555
- anonymousScopes: z14.array(z14.string()).default(["anonymous"]),
6457
+ tokenStorage: tokenStorageConfigSchema.default("memory"),
6458
+ allowDefaultPublic: z13.boolean().default(false),
6459
+ anonymousScopes: z13.array(z13.string()).default(["anonymous"]),
6556
6460
  publicAccess: publicAccessConfigSchema.optional(),
6557
6461
  consent: consentConfigSchema.optional(),
6558
6462
  federatedAuth: federatedAuthConfigSchema.optional(),
6559
6463
  refresh: tokenRefreshConfigSchema.optional(),
6560
- expectedAudience: z14.union([z14.string(), z14.array(z14.string())]).optional(),
6464
+ expectedAudience: z13.union([z13.string(), z13.array(z13.string())]).optional(),
6561
6465
  incrementalAuth: incrementalAuthConfigSchema.optional(),
6562
6466
  cimd: cimdConfigSchema.optional()
6563
6467
  };
6564
- var orchestratedLocalSchema = z14.object({
6565
- mode: z14.literal("orchestrated"),
6566
- type: z14.literal("local"),
6567
- ...orchestratedSharedFields
6468
+ var localAuthSchema = z13.object({
6469
+ mode: z13.literal("local"),
6470
+ ...sharedAuthFields
6568
6471
  });
6569
- var orchestratedRemoteSchema = z14.object({
6570
- mode: z14.literal("orchestrated"),
6571
- type: z14.literal("remote"),
6572
- remote: remoteProviderConfigSchema,
6573
- ...orchestratedSharedFields
6472
+ var remoteAuthSchema = z13.object({
6473
+ mode: z13.literal("remote"),
6474
+ ...flatRemoteProviderFields,
6475
+ ...sharedAuthFields
6574
6476
  });
6575
- var orchestratedAuthOptionsSchema = z14.discriminatedUnion("type", [
6576
- orchestratedLocalSchema,
6577
- orchestratedRemoteSchema
6578
- ]);
6477
+ var orchestratedLocalSchema = localAuthSchema;
6478
+ var orchestratedRemoteSchema = remoteAuthSchema;
6579
6479
 
6580
6480
  // libs/auth/src/options/schema.ts
6581
- import { z as z15 } from "zod";
6582
- var authOptionsSchema = z15.union([
6481
+ import { z as z14 } from "zod";
6482
+ var authOptionsSchema = z14.union([
6583
6483
  publicAuthOptionsSchema,
6584
6484
  transparentAuthOptionsSchema,
6585
- orchestratedLocalSchema,
6586
- orchestratedRemoteSchema
6485
+ localAuthSchema,
6486
+ remoteAuthSchema
6587
6487
  ]);
6588
6488
 
6589
6489
  // libs/auth/src/options/app-auth.schema.ts
6590
- import { z as z16 } from "zod";
6490
+ import { z as z15 } from "zod";
6591
6491
  var standaloneOptionSchema = {
6592
- standalone: z16.boolean().optional(),
6593
- excludeFromParent: z16.boolean().optional()
6492
+ standalone: z15.boolean().optional(),
6493
+ excludeFromParent: z15.boolean().optional()
6594
6494
  };
6595
- var appAuthOptionsSchema = z16.union([
6495
+ var appAuthOptionsSchema = z15.union([
6596
6496
  publicAuthOptionsSchema.extend(standaloneOptionSchema),
6597
6497
  transparentAuthOptionsSchema.extend(standaloneOptionSchema),
6598
- orchestratedLocalSchema.extend(standaloneOptionSchema),
6599
- orchestratedRemoteSchema.extend(standaloneOptionSchema)
6498
+ localAuthSchema.extend(standaloneOptionSchema),
6499
+ remoteAuthSchema.extend(standaloneOptionSchema)
6600
6500
  ]);
6601
6501
 
6602
6502
  // libs/auth/src/options/utils.ts
@@ -6609,136 +6509,142 @@ function isPublicMode(options) {
6609
6509
  function isTransparentMode(options) {
6610
6510
  return options.mode === "transparent";
6611
6511
  }
6512
+ function isLocalMode(options) {
6513
+ return options.mode === "local";
6514
+ }
6515
+ function isRemoteMode(options) {
6516
+ return options.mode === "remote";
6517
+ }
6612
6518
  function isOrchestratedMode(options) {
6613
- return options.mode === "orchestrated";
6519
+ return options.mode === "local" || options.mode === "remote";
6614
6520
  }
6615
6521
  function isOrchestratedLocal(options) {
6616
- return options.type === "local";
6522
+ return options.mode === "local";
6617
6523
  }
6618
6524
  function isOrchestratedRemote(options) {
6619
- return options.type === "remote";
6525
+ return options.mode === "remote";
6620
6526
  }
6621
6527
  function allowsPublicAccess(options) {
6622
6528
  if (options.mode === "public") return true;
6623
6529
  if (options.mode === "transparent") return options.allowAnonymous;
6624
- if (options.mode === "orchestrated") return options.allowDefaultPublic;
6530
+ if (options.mode === "local" || options.mode === "remote") return options.allowDefaultPublic;
6625
6531
  return false;
6626
6532
  }
6627
6533
 
6628
6534
  // libs/auth/src/consent/consent.types.ts
6629
- import { z as z17 } from "zod";
6630
- var consentToolItemSchema = z17.object({
6535
+ import { z as z16 } from "zod";
6536
+ var consentToolItemSchema = z16.object({
6631
6537
  /** Tool ID (e.g., 'slack:send_message') */
6632
- id: z17.string().min(1),
6538
+ id: z16.string().min(1),
6633
6539
  /** Tool name for display */
6634
- name: z17.string().min(1),
6540
+ name: z16.string().min(1),
6635
6541
  /** Tool description */
6636
- description: z17.string().optional(),
6542
+ description: z16.string().optional(),
6637
6543
  /** App ID this tool belongs to */
6638
- appId: z17.string().min(1),
6544
+ appId: z16.string().min(1),
6639
6545
  /** App name for display */
6640
- appName: z17.string().min(1),
6546
+ appName: z16.string().min(1),
6641
6547
  /** Whether the tool is selected by default */
6642
- defaultSelected: z17.boolean().default(true),
6548
+ defaultSelected: z16.boolean().default(true),
6643
6549
  /** Whether this tool requires specific scopes */
6644
- requiredScopes: z17.array(z17.string()).optional(),
6550
+ requiredScopes: z16.array(z16.string()).optional(),
6645
6551
  /** Category for grouping (e.g., 'read', 'write', 'admin') */
6646
- category: z17.string().optional()
6552
+ category: z16.string().optional()
6647
6553
  });
6648
- var consentSelectionSchema = z17.object({
6554
+ var consentSelectionSchema = z16.object({
6649
6555
  /** Selected tool IDs */
6650
- selectedTools: z17.array(z17.string()),
6556
+ selectedTools: z16.array(z16.string()),
6651
6557
  /** Whether all tools were selected */
6652
- allSelected: z17.boolean(),
6558
+ allSelected: z16.boolean(),
6653
6559
  /** Timestamp when consent was given */
6654
- consentedAt: z17.string().datetime(),
6560
+ consentedAt: z16.string().datetime(),
6655
6561
  /** Consent version for tracking changes */
6656
- consentVersion: z17.string().default("1.0")
6562
+ consentVersion: z16.string().default("1.0")
6657
6563
  });
6658
- var consentStateSchema = z17.object({
6564
+ var consentStateSchema = z16.object({
6659
6565
  /** Whether consent flow is enabled */
6660
- enabled: z17.boolean(),
6566
+ enabled: z16.boolean(),
6661
6567
  /** Available tools for consent */
6662
- availableTools: z17.array(consentToolItemSchema),
6568
+ availableTools: z16.array(consentToolItemSchema),
6663
6569
  /** Pre-selected tools (from previous consent or defaults) */
6664
- preselectedTools: z17.array(z17.string()).optional(),
6570
+ preselectedTools: z16.array(z16.string()).optional(),
6665
6571
  /** Whether to show all tools or group by app */
6666
- groupByApp: z17.boolean().default(true),
6572
+ groupByApp: z16.boolean().default(true),
6667
6573
  /** Custom consent message */
6668
- customMessage: z17.string().optional()
6574
+ customMessage: z16.string().optional()
6669
6575
  });
6670
- var federatedProviderItemSchema = z17.object({
6576
+ var federatedProviderItemSchema = z16.object({
6671
6577
  /** Provider ID (derived or explicit) */
6672
- id: z17.string().min(1),
6578
+ id: z16.string().min(1),
6673
6579
  /** Provider display name */
6674
- name: z17.string().min(1),
6580
+ name: z16.string().min(1),
6675
6581
  /** Provider description */
6676
- description: z17.string().optional(),
6582
+ description: z16.string().optional(),
6677
6583
  /** Provider icon URL or emoji */
6678
- icon: z17.string().optional(),
6584
+ icon: z16.string().optional(),
6679
6585
  /** Provider type */
6680
- type: z17.enum(["local", "remote", "transparent"]),
6586
+ type: z16.enum(["local", "remote", "transparent"]),
6681
6587
  /** OAuth provider URL (for remote providers) */
6682
- providerUrl: z17.string().url().optional(),
6588
+ providerUrl: z16.string().url().optional(),
6683
6589
  /** Apps using this provider */
6684
- appIds: z17.array(z17.string()),
6590
+ appIds: z16.array(z16.string()),
6685
6591
  /** App names using this provider */
6686
- appNames: z17.array(z17.string()),
6592
+ appNames: z16.array(z16.string()),
6687
6593
  /** Scopes required by this provider */
6688
- scopes: z17.array(z17.string()),
6594
+ scopes: z16.array(z16.string()),
6689
6595
  /** Whether this is the primary/parent provider */
6690
- isPrimary: z17.boolean(),
6596
+ isPrimary: z16.boolean(),
6691
6597
  /** Whether this provider is optional (can be skipped) */
6692
- isOptional: z17.boolean().default(false)
6598
+ isOptional: z16.boolean().default(false)
6693
6599
  });
6694
- var federatedLoginStateSchema = z17.object({
6600
+ var federatedLoginStateSchema = z16.object({
6695
6601
  /** All available providers */
6696
- providers: z17.array(federatedProviderItemSchema),
6602
+ providers: z16.array(federatedProviderItemSchema),
6697
6603
  /** Primary provider ID (if any) */
6698
- primaryProviderId: z17.string().optional(),
6604
+ primaryProviderId: z16.string().optional(),
6699
6605
  /** Whether user can skip optional providers */
6700
- allowSkip: z17.boolean().default(true),
6606
+ allowSkip: z16.boolean().default(true),
6701
6607
  /** Pre-selected provider IDs (from previous session) */
6702
- preselectedProviders: z17.array(z17.string()).optional()
6608
+ preselectedProviders: z16.array(z16.string()).optional()
6703
6609
  });
6704
- var federatedSelectionSchema = z17.object({
6610
+ var federatedSelectionSchema = z16.object({
6705
6611
  /** Selected provider IDs */
6706
- selectedProviders: z17.array(z17.string()),
6612
+ selectedProviders: z16.array(z16.string()),
6707
6613
  /** Skipped provider IDs */
6708
- skippedProviders: z17.array(z17.string()),
6614
+ skippedProviders: z16.array(z16.string()),
6709
6615
  /** Provider-specific metadata */
6710
- providerMetadata: z17.record(z17.string(), z17.unknown()).optional()
6616
+ providerMetadata: z16.record(z16.string(), z16.unknown()).optional()
6711
6617
  });
6712
6618
 
6713
6619
  // libs/auth/src/detection/auth-provider-detection.ts
6714
- import { z as z18 } from "zod";
6715
- var detectedAuthProviderSchema = z18.object({
6716
- id: z18.string(),
6717
- providerUrl: z18.string().optional(),
6718
- mode: z18.enum(["public", "transparent", "orchestrated"]),
6719
- appIds: z18.array(z18.string()),
6720
- scopes: z18.array(z18.string()),
6721
- isParentProvider: z18.boolean()
6620
+ import { z as z17 } from "zod";
6621
+ var detectedAuthProviderSchema = z17.object({
6622
+ id: z17.string(),
6623
+ providerUrl: z17.string().optional(),
6624
+ mode: z17.enum(["public", "transparent", "local", "remote"]),
6625
+ appIds: z17.array(z17.string()),
6626
+ scopes: z17.array(z17.string()),
6627
+ isParentProvider: z17.boolean()
6722
6628
  });
6723
- var authProviderDetectionResultSchema = z18.object({
6724
- providers: z18.map(z18.string(), detectedAuthProviderSchema),
6725
- requiresOrchestration: z18.boolean(),
6726
- parentProviderId: z18.string().optional(),
6727
- childProviderIds: z18.array(z18.string()),
6728
- uniqueProviderCount: z18.number(),
6729
- validationErrors: z18.array(z18.string()),
6730
- warnings: z18.array(z18.string())
6629
+ var authProviderDetectionResultSchema = z17.object({
6630
+ providers: z17.map(z17.string(), detectedAuthProviderSchema),
6631
+ requiresOrchestration: z17.boolean(),
6632
+ parentProviderId: z17.string().optional(),
6633
+ childProviderIds: z17.array(z17.string()),
6634
+ uniqueProviderCount: z17.number(),
6635
+ validationErrors: z17.array(z17.string()),
6636
+ warnings: z17.array(z17.string())
6731
6637
  });
6732
6638
  function deriveProviderId(options) {
6733
6639
  if (isPublicMode(options)) {
6734
6640
  return options.issuer ?? "public";
6735
6641
  }
6736
6642
  if (isTransparentMode(options)) {
6737
- return options.remote.id ?? urlToProviderId(options.remote.provider);
6643
+ return options.providerConfig?.id ?? urlToProviderId(options.provider);
6738
6644
  }
6739
6645
  if (isOrchestratedMode(options)) {
6740
6646
  if (isOrchestratedRemote(options)) {
6741
- return options.remote.id ?? urlToProviderId(options.remote.provider);
6647
+ return options.providerConfig?.id ?? urlToProviderId(options.provider);
6742
6648
  }
6743
6649
  return options.local?.issuer ?? "local";
6744
6650
  }
@@ -6758,7 +6664,7 @@ function extractScopes(options) {
6758
6664
  }
6759
6665
  if (isOrchestratedMode(options)) {
6760
6666
  if (isOrchestratedRemote(options)) {
6761
- return options.remote.scopes || [];
6667
+ return options.scopes || [];
6762
6668
  }
6763
6669
  }
6764
6670
  return [];
@@ -6807,12 +6713,12 @@ function detectAuthProviders(parentAuth, apps) {
6807
6713
  const requiresOrchestration = hasMultipleProviders || hasChildOnlyProviders || childProviderIds.length > 0 && parentProviderId !== void 0;
6808
6714
  if (requiresOrchestration && parentAuth && isTransparentMode(parentAuth)) {
6809
6715
  validationErrors.push(
6810
- `Invalid auth configuration: Parent uses transparent mode but apps have their own auth providers. Transparent mode passes tokens through without modification, which is incompatible with multi-provider setups. Change parent auth to orchestrated mode to properly manage tokens for each provider. Detected providers: ${[...providers.keys()].join(", ")}`
6716
+ `Invalid auth configuration: Parent uses transparent mode but apps have their own auth providers. Transparent mode passes tokens through without modification, which is incompatible with multi-provider setups. Change parent auth to local or remote mode to properly manage tokens for each provider. Detected providers: ${[...providers.keys()].join(", ")}`
6811
6717
  );
6812
6718
  }
6813
6719
  if (uniqueProviderCount > 1 && parentAuth && isPublicMode(parentAuth)) {
6814
6720
  warnings.push(
6815
- `Parent uses public mode but apps have auth providers configured. App-level auth will be used, but consider using orchestrated mode at parent for unified auth management.`
6721
+ `Parent uses public mode but apps have auth providers configured. App-level auth will be used, but consider using local or remote mode at parent for unified auth management.`
6816
6722
  );
6817
6723
  }
6818
6724
  return {
@@ -6827,10 +6733,10 @@ function detectAuthProviders(parentAuth, apps) {
6827
6733
  }
6828
6734
  function getProviderUrl(options) {
6829
6735
  if (isTransparentMode(options)) {
6830
- return options.remote.provider;
6736
+ return options.provider;
6831
6737
  }
6832
6738
  if (isOrchestratedMode(options) && isOrchestratedRemote(options)) {
6833
- return options.remote.provider;
6739
+ return options.provider;
6834
6740
  }
6835
6741
  return void 0;
6836
6742
  }
@@ -7000,9 +6906,9 @@ function escapeQuotedString(value) {
7000
6906
  function unescapeQuotedString(value) {
7001
6907
  return value.replace(/\\(.)/g, "$1");
7002
6908
  }
7003
- function normalizePathSegment(path3) {
7004
- if (!path3 || path3 === "/") return "";
7005
- const normalized = path3.startsWith("/") ? path3 : `/${path3}`;
6909
+ function normalizePathSegment(path) {
6910
+ if (!path || path === "/") return "";
6911
+ const normalized = path.startsWith("/") ? path : `/${path}`;
7006
6912
  let end = normalized.length;
7007
6913
  while (end > 0 && normalized[end - 1] === "/") {
7008
6914
  end--;
@@ -7117,43 +7023,43 @@ var AudienceValidator = class _AudienceValidator {
7117
7023
  };
7118
7024
 
7119
7025
  // libs/auth/src/vault/auth-providers.types.ts
7120
- import { z as z19 } from "zod";
7121
- var credentialScopeSchema = z19.enum(["global", "user", "session"]);
7122
- var loadingStrategySchema = z19.enum(["eager", "lazy"]);
7123
- var getCredentialOptionsSchema = z19.object({
7124
- forceRefresh: z19.boolean().optional(),
7125
- scopes: z19.array(z19.string()).optional(),
7126
- timeout: z19.number().positive().optional()
7026
+ import { z as z18 } from "zod";
7027
+ var credentialScopeSchema = z18.enum(["global", "user", "session"]);
7028
+ var loadingStrategySchema = z18.enum(["eager", "lazy"]);
7029
+ var getCredentialOptionsSchema = z18.object({
7030
+ forceRefresh: z18.boolean().optional(),
7031
+ scopes: z18.array(z18.string()).optional(),
7032
+ timeout: z18.number().positive().optional()
7127
7033
  }).strict();
7128
- var credentialProviderConfigSchema = z19.object({
7129
- name: z19.string().min(1),
7130
- description: z19.string().optional(),
7034
+ var credentialProviderConfigSchema = z18.object({
7035
+ name: z18.string().min(1),
7036
+ description: z18.string().optional(),
7131
7037
  scope: credentialScopeSchema,
7132
7038
  loading: loadingStrategySchema,
7133
- cacheTtl: z19.number().nonnegative().optional(),
7039
+ cacheTtl: z18.number().nonnegative().optional(),
7134
7040
  // Functions validated at runtime, not via Zod (Zod 4 compatibility)
7135
- factory: z19.any(),
7136
- refresh: z19.any().optional(),
7137
- toHeaders: z19.any().optional(),
7138
- metadata: z19.record(z19.string(), z19.unknown()).optional(),
7139
- required: z19.boolean().optional()
7041
+ factory: z18.any(),
7042
+ refresh: z18.any().optional(),
7043
+ toHeaders: z18.any().optional(),
7044
+ metadata: z18.record(z18.string(), z18.unknown()).optional(),
7045
+ required: z18.boolean().optional()
7140
7046
  }).strict();
7141
- var authProviderMappingSchema = z19.union([
7142
- z19.string(),
7143
- z19.object({
7144
- name: z19.string().min(1),
7145
- required: z19.boolean().optional().default(true),
7146
- scopes: z19.array(z19.string()).optional(),
7147
- alias: z19.string().optional()
7047
+ var authProviderMappingSchema = z18.union([
7048
+ z18.string(),
7049
+ z18.object({
7050
+ name: z18.string().min(1),
7051
+ required: z18.boolean().optional().default(true),
7052
+ scopes: z18.array(z18.string()).optional(),
7053
+ alias: z18.string().optional()
7148
7054
  }).strict()
7149
7055
  ]);
7150
- var authProvidersVaultOptionsSchema = z19.object({
7151
- enabled: z19.boolean().optional(),
7152
- useSharedStorage: z19.boolean().optional().default(true),
7153
- namespace: z19.string().optional().default("authproviders:"),
7154
- defaultCacheTtl: z19.number().nonnegative().optional().default(36e5),
7155
- maxCredentialsPerSession: z19.number().positive().optional().default(100),
7156
- providers: z19.array(credentialProviderConfigSchema).optional()
7056
+ var authProvidersVaultOptionsSchema = z18.object({
7057
+ enabled: z18.boolean().optional(),
7058
+ useSharedStorage: z18.boolean().optional().default(true),
7059
+ namespace: z18.string().optional().default("authproviders:"),
7060
+ defaultCacheTtl: z18.number().nonnegative().optional().default(36e5),
7061
+ maxCredentialsPerSession: z18.number().positive().optional().default(100),
7062
+ providers: z18.array(credentialProviderConfigSchema).optional()
7157
7063
  }).strict();
7158
7064
 
7159
7065
  // libs/auth/src/vault/credential-helpers.ts
@@ -8132,7 +8038,6 @@ export {
8132
8038
  AuthProvidersVault,
8133
8039
  AuthorizationBase,
8134
8040
  CDN,
8135
- CimdCache,
8136
8041
  CimdClientIdMismatchError,
8137
8042
  CimdDisabledError,
8138
8043
  CimdError,
@@ -8154,6 +8059,7 @@ export {
8154
8059
  EncryptionKeyNotConfiguredError,
8155
8060
  InMemoryAuthorizationStore,
8156
8061
  InMemoryAuthorizationVault,
8062
+ InMemoryCimdCache,
8157
8063
  InMemoryFederatedAuthSessionStore,
8158
8064
  InMemoryOrchestratedTokenStore,
8159
8065
  InMemoryStoreRequiredError,
@@ -8249,7 +8155,6 @@ export {
8249
8155
  decryptSessionJson,
8250
8156
  decryptValue2 as decryptValue,
8251
8157
  defaultSessionRateLimiter,
8252
- deleteDevKey,
8253
8158
  deriveAuthorizationId,
8254
8159
  deriveExpectedAudience,
8255
8160
  deriveProviderId,
@@ -8271,6 +8176,7 @@ export {
8271
8176
  federatedLoginStateSchema,
8272
8177
  federatedProviderItemSchema,
8273
8178
  federatedSelectionSchema,
8179
+ flatRemoteProviderFields,
8274
8180
  fromSessionRecord,
8275
8181
  generatePkceChallenge,
8276
8182
  getCredentialOptionsSchema,
@@ -8284,12 +8190,13 @@ export {
8284
8190
  hkdfSha2563 as hkdfSha256,
8285
8191
  incrementalAuthConfigSchema,
8286
8192
  isCimdClientId,
8287
- isDevKeyPersistenceEnabled,
8288
8193
  isJwt,
8194
+ isLocalMode,
8289
8195
  isOrchestratedLocal,
8290
8196
  isOrchestratedMode,
8291
8197
  isOrchestratedRemote,
8292
8198
  isPublicMode,
8199
+ isRemoteMode,
8293
8200
  isSessionComplete,
8294
8201
  isSignedData as isSignedSession,
8295
8202
  isSoonExpiring,
@@ -8300,14 +8207,13 @@ export {
8300
8207
  jwkSchema,
8301
8208
  legacySseTransportStateSchema,
8302
8209
  llmSafeAuthContextSchema,
8303
- loadDevKey,
8304
8210
  loadingStrategySchema,
8211
+ localAuthSchema,
8305
8212
  localSigningConfigSchema,
8306
8213
  mtlsCredentialSchema,
8307
8214
  noopLogger,
8308
8215
  normalizeIssuer,
8309
8216
  oauthCredentialSchema,
8310
- orchestratedAuthOptionsSchema,
8311
8217
  orchestratedLocalSchema,
8312
8218
  orchestratedRemoteSchema,
8313
8219
  parseAuthOptions,
@@ -8318,16 +8224,16 @@ export {
8318
8224
  pkceOAuthCredentialSchema,
8319
8225
  privateKeyCredentialSchema,
8320
8226
  progressiveAuthStateSchema,
8227
+ providerConfigSchema,
8321
8228
  publicAccessConfigSchema,
8322
8229
  publicAuthOptionsSchema,
8323
8230
  redisConfigSchema,
8324
8231
  redisVaultEntrySchema,
8232
+ remoteAuthSchema,
8325
8233
  remoteProviderConfigSchema,
8326
8234
  renderToHtml,
8327
8235
  resetCachedKey,
8328
- resolveKeyPath,
8329
8236
  safeDecrypt,
8330
- saveDevKey,
8331
8237
  serviceAccountCredentialSchema,
8332
8238
  sessionIdPayloadSchema,
8333
8239
  sessionJwtPayloadSchema,