@frontmcp/auth 0.12.2 → 1.0.0-beta.1

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 (43) 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 +673 -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 +745 -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 +54 -56
  28. package/options/orchestrated.schema.d.ts.map +1 -1
  29. package/options/schema.d.ts +30 -38
  30. package/options/schema.d.ts.map +1 -1
  31. package/options/shared.schemas.d.ts +61 -9
  32. package/options/shared.schemas.d.ts.map +1 -1
  33. package/options/transparent.schema.d.ts +15 -15
  34. package/options/typecheck.d.ts.map +1 -1
  35. package/options/utils.d.ts +16 -7
  36. package/options/utils.d.ts.map +1 -1
  37. package/package.json +4 -4
  38. package/session/session-crypto.d.ts.map +1 -1
  39. package/session/session.transport.d.ts +3 -4
  40. package/session/session.transport.d.ts.map +1 -1
  41. package/session/utils/session-crypto.utils.d.ts.map +1 -1
  42. package/jwks/dev-key-persistence.d.ts +0 -70
  43. 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,94 @@ 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()
2163
2022
  });
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)
2023
+ var redisConfigSchema = z4.object({
2024
+ host: z4.string().min(1),
2025
+ port: z4.number().int().positive().optional().default(6379),
2026
+ password: z4.string().optional(),
2027
+ db: z4.number().int().nonnegative().optional().default(0),
2028
+ tls: z4.boolean().optional().default(false),
2029
+ keyPrefix: z4.string().optional().default("mcp:session:"),
2030
+ defaultTtlMs: z4.number().int().positive().optional().default(36e5)
2172
2031
  // 1 hour default
2173
2032
  });
2174
2033
 
@@ -2177,11 +2036,13 @@ import {
2177
2036
  signData,
2178
2037
  verifyData,
2179
2038
  isSignedData,
2180
- verifyOrParseData
2039
+ verifyOrParseData,
2040
+ getEnv,
2041
+ isProduction as isProduction2
2181
2042
  } from "@frontmcp/utils";
2182
2043
 
2183
2044
  // libs/auth/src/errors/auth-internal.error.ts
2184
- import { randomBytes as randomBytes5, bytesToHex as bytesToHex2 } from "@frontmcp/utils";
2045
+ import { randomBytes as randomBytes4, bytesToHex as bytesToHex2 } from "@frontmcp/utils";
2185
2046
  var AuthInternalError = class extends Error {
2186
2047
  /**
2187
2048
  * Unique error ID for tracking in logs.
@@ -2203,7 +2064,7 @@ var AuthInternalError = class extends Error {
2203
2064
  super(message);
2204
2065
  this.name = this.constructor.name;
2205
2066
  this.code = code;
2206
- this.errorId = `err_${bytesToHex2(randomBytes5(8))}`;
2067
+ this.errorId = `err_${bytesToHex2(randomBytes4(8))}`;
2207
2068
  Error.captureStackTrace(this, this.constructor);
2208
2069
  }
2209
2070
  /**
@@ -2326,9 +2187,9 @@ var AuthFlowError = class extends AuthInternalError {
2326
2187
 
2327
2188
  // libs/auth/src/session/session-crypto.ts
2328
2189
  function getSigningSecret(config) {
2329
- const secret = config?.secret || process.env["MCP_SESSION_SECRET"];
2190
+ const secret = config?.secret || getEnv("MCP_SESSION_SECRET");
2330
2191
  if (!secret) {
2331
- if (process.env["NODE_ENV"] === "production") {
2192
+ if (isProduction2()) {
2332
2193
  throw new SessionSecretRequiredError("session signing");
2333
2194
  }
2334
2195
  console.warn("[SessionCrypto] MCP_SESSION_SECRET not set. Using insecure default for development only.");
@@ -2361,7 +2222,7 @@ var SessionRateLimiter = class {
2361
2222
  const cleanupIntervalMs = config.cleanupIntervalMs ?? 6e4;
2362
2223
  if (cleanupIntervalMs > 0) {
2363
2224
  this.cleanupTimer = setInterval(() => this.cleanup(), cleanupIntervalMs);
2364
- this.cleanupTimer.unref();
2225
+ if (typeof this.cleanupTimer.unref === "function") this.cleanupTimer.unref();
2365
2226
  }
2366
2227
  }
2367
2228
  /**
@@ -2469,12 +2330,11 @@ import { randomUUID as randomUUID2 } from "@frontmcp/utils";
2469
2330
  var TransportIdGenerator = class {
2470
2331
  /**
2471
2332
  * Create a transport session ID.
2472
- * Always generates JWT-style IDs for distributed session support.
2333
+ * Generates JWT-style IDs for distributed session support.
2473
2334
  *
2474
- * @param _mode - Deprecated parameter, kept for backwards compatibility
2475
- * @returns A JWT-style transport session ID (UUID without dashes)
2335
+ * @returns A transport session ID (UUID without dashes)
2476
2336
  */
2477
- static createId(_mode) {
2337
+ static createId() {
2478
2338
  return randomUUID2().replace(/-/g, "");
2479
2339
  }
2480
2340
  };
@@ -2565,18 +2425,20 @@ function extractBearerToken(header) {
2565
2425
  }
2566
2426
 
2567
2427
  // libs/auth/src/session/utils/session-crypto.utils.ts
2568
- import { sha256, encryptValue, decryptValue } from "@frontmcp/utils";
2428
+ import { sha256, encryptValue, decryptValue, getEnv as getEnv3, isProduction as isProduction4 } from "@frontmcp/utils";
2569
2429
 
2570
2430
  // 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";
2431
+ import { randomUUID as randomUUID3, mkdir, writeFile, readFileSync, getEnv as getEnv2, getCwd, isProduction as isProduction3, isBrowser } from "@frontmcp/utils";
2573
2432
  var DEFAULT_MACHINE_ID_PATH = ".frontmcp/machine-id";
2574
2433
  function isDevPersistenceEnabled() {
2575
- return process.env["NODE_ENV"] !== "production";
2434
+ if (isBrowser()) return false;
2435
+ return !isProduction3();
2576
2436
  }
2577
2437
  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);
2438
+ if (isBrowser()) return DEFAULT_MACHINE_ID_PATH;
2439
+ const path = __require("path");
2440
+ const machineIdPath = getEnv2("MACHINE_ID_PATH") ?? DEFAULT_MACHINE_ID_PATH;
2441
+ return path.isAbsolute(machineIdPath) ? machineIdPath : path.resolve(getCwd(), machineIdPath);
2580
2442
  }
2581
2443
  function loadMachineIdSync() {
2582
2444
  if (!isDevPersistenceEnabled()) {
@@ -2602,18 +2464,19 @@ function saveMachineIdAsync(machineId2) {
2602
2464
  return;
2603
2465
  }
2604
2466
  const machineIdPath = resolveMachineIdPath();
2605
- const dir = path2.dirname(machineIdPath);
2467
+ const path = __require("path");
2468
+ const dir = path.dirname(machineIdPath);
2606
2469
  (async () => {
2607
2470
  try {
2608
- await mkdir2(dir, { recursive: true, mode: 448 });
2609
- await writeFile2(machineIdPath, machineId2, { mode: 384 });
2471
+ await mkdir(dir, { recursive: true, mode: 448 });
2472
+ await writeFile(machineIdPath, machineId2, { mode: 384 });
2610
2473
  } catch (error) {
2611
2474
  console.warn(`[MachineId] Failed to save to ${machineIdPath}: ${error.message}`);
2612
2475
  }
2613
2476
  })();
2614
2477
  }
2615
2478
  var machineId = (() => {
2616
- const envMachineId = process.env["MACHINE_ID"];
2479
+ const envMachineId = getEnv2("MACHINE_ID");
2617
2480
  if (envMachineId) {
2618
2481
  return envMachineId;
2619
2482
  }
@@ -2637,10 +2500,9 @@ function setMachineIdOverride(id) {
2637
2500
  var cachedKey = null;
2638
2501
  function getKey() {
2639
2502
  if (cachedKey) return cachedKey;
2640
- const secret = process.env["MCP_SESSION_SECRET"];
2641
- const nodeEnv = process.env["NODE_ENV"];
2503
+ const secret = getEnv3("MCP_SESSION_SECRET");
2642
2504
  if (!secret) {
2643
- if (nodeEnv === "production") {
2505
+ if (isProduction4()) {
2644
2506
  throw new SessionSecretRequiredError("session ID encryption");
2645
2507
  }
2646
2508
  console.warn(
@@ -3554,7 +3416,7 @@ var VercelKvSessionStore = class {
3554
3416
  };
3555
3417
 
3556
3418
  // 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";
3419
+ import { encryptAesGcm as encryptAesGcm3, decryptAesGcm as decryptAesGcm3, randomBytes as randomBytes5, hkdfSha256 as hkdfSha2562 } from "@frontmcp/utils";
3558
3420
  var InMemoryOrchestratedTokenStore = class {
3559
3421
  /** Token storage: Map<compositeKey, ProviderTokenRecord> */
3560
3422
  tokens = /* @__PURE__ */ new Map();
@@ -3606,7 +3468,7 @@ var InMemoryOrchestratedTokenStore = class {
3606
3468
  async encryptRecord(compositeKey, record) {
3607
3469
  const key = await this.deriveKeyForRecord(compositeKey);
3608
3470
  const plaintext = JSON.stringify(record);
3609
- const iv = randomBytes6(12);
3471
+ const iv = randomBytes5(12);
3610
3472
  const { ciphertext, tag } = encryptAesGcm3(key, new TextEncoder().encode(plaintext), iv);
3611
3473
  return JSON.stringify({
3612
3474
  iv: Buffer.from(iv).toString("base64url"),
@@ -3989,30 +3851,30 @@ function startNextProvider(session, pkce, state) {
3989
3851
  }
3990
3852
 
3991
3853
  // libs/auth/src/session/encrypted-authorization-vault.ts
3992
- import { z as z6 } from "zod";
3854
+ import { z as z5 } from "zod";
3993
3855
  import { randomUUID as randomUUID9 } from "@frontmcp/utils";
3994
- import { AsyncLocalStorage } from "node:async_hooks";
3995
- var redisVaultEntrySchema = z6.object({
3856
+ import { AsyncLocalStorage } from "@frontmcp/utils";
3857
+ var redisVaultEntrySchema = z5.object({
3996
3858
  /** Vault ID */
3997
- id: z6.string(),
3859
+ id: z5.string(),
3998
3860
  /** User sub (for lookup) */
3999
- userSub: z6.string(),
3861
+ userSub: z5.string(),
4000
3862
  /** User email (optional, for display) */
4001
- userEmail: z6.string().optional(),
3863
+ userEmail: z5.string().optional(),
4002
3864
  /** User name (optional, for display) */
4003
- userName: z6.string().optional(),
3865
+ userName: z5.string().optional(),
4004
3866
  /** Client ID */
4005
- clientId: z6.string(),
3867
+ clientId: z5.string(),
4006
3868
  /** Creation timestamp */
4007
- createdAt: z6.number(),
3869
+ createdAt: z5.number(),
4008
3870
  /** Last access timestamp */
4009
- lastAccessAt: z6.number(),
3871
+ lastAccessAt: z5.number(),
4010
3872
  /** Authorized app IDs (unencrypted for quick auth checks) */
4011
- authorizedAppIds: z6.array(z6.string()),
3873
+ authorizedAppIds: z5.array(z5.string()),
4012
3874
  /** Skipped app IDs (unencrypted for quick checks) */
4013
- skippedAppIds: z6.array(z6.string()),
3875
+ skippedAppIds: z5.array(z5.string()),
4014
3876
  /** Pending auth request IDs (unencrypted for lookup) */
4015
- pendingAuthIds: z6.array(z6.string()),
3877
+ pendingAuthIds: z5.array(z5.string()),
4016
3878
  /** Encrypted sensitive data blob */
4017
3879
  encrypted: encryptedDataSchema
4018
3880
  });
@@ -4417,37 +4279,37 @@ function tryJwtExp(token) {
4417
4279
  }
4418
4280
 
4419
4281
  // 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()
4282
+ import { z as z6 } from "zod";
4283
+ var authModeSchema = z6.enum(["public", "transparent", "orchestrated"]);
4284
+ var authUserSchema = z6.object({
4285
+ sub: z6.string(),
4286
+ name: z6.string().optional(),
4287
+ email: z6.string().email().optional(),
4288
+ picture: z6.string().url().optional(),
4289
+ anonymous: z6.boolean().optional()
4428
4290
  });
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()
4291
+ var authorizedToolSchema = z6.object({
4292
+ executionPath: z6.tuple([z6.string(), z6.string()]),
4293
+ scopes: z6.array(z6.string()).optional(),
4294
+ details: z6.record(z6.string(), z6.unknown()).optional()
4433
4295
  });
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()
4296
+ var authorizedPromptSchema = z6.object({
4297
+ executionPath: z6.tuple([z6.string(), z6.string()]),
4298
+ scopes: z6.array(z6.string()).optional(),
4299
+ details: z6.record(z6.string(), z6.unknown()).optional()
4438
4300
  });
4439
- var llmSafeAuthContextSchema = z7.object({
4440
- authorizationId: z7.string(),
4441
- sessionId: z7.string(),
4301
+ var llmSafeAuthContextSchema = z6.object({
4302
+ authorizationId: z6.string(),
4303
+ sessionId: z6.string(),
4442
4304
  mode: authModeSchema,
4443
- isAnonymous: z7.boolean(),
4444
- user: z7.object({
4445
- sub: z7.string(),
4446
- name: z7.string().optional()
4305
+ isAnonymous: z6.boolean(),
4306
+ user: z6.object({
4307
+ sub: z6.string(),
4308
+ name: z6.string().optional()
4447
4309
  }),
4448
- scopes: z7.array(z7.string()),
4449
- authorizedToolIds: z7.array(z7.string()),
4450
- authorizedPromptIds: z7.array(z7.string())
4310
+ scopes: z6.array(z6.string()),
4311
+ authorizedToolIds: z6.array(z6.string()),
4312
+ authorizedPromptIds: z6.array(z6.string())
4451
4313
  });
4452
4314
  var AppAuthState = /* @__PURE__ */ ((AppAuthState2) => {
4453
4315
  AppAuthState2["AUTHORIZED"] = "authorized";
@@ -4455,19 +4317,19 @@ var AppAuthState = /* @__PURE__ */ ((AppAuthState2) => {
4455
4317
  AppAuthState2["PENDING"] = "pending";
4456
4318
  return AppAuthState2;
4457
4319
  })(AppAuthState || {});
4458
- var appAuthStateSchema = z7.nativeEnum(AppAuthState);
4459
- var appAuthorizationRecordSchema = z7.object({
4460
- appId: z7.string(),
4320
+ var appAuthStateSchema = z6.nativeEnum(AppAuthState);
4321
+ var appAuthorizationRecordSchema = z6.object({
4322
+ appId: z6.string(),
4461
4323
  state: appAuthStateSchema,
4462
- stateChangedAt: z7.number(),
4463
- grantedScopes: z7.array(z7.string()).optional(),
4464
- authProviderId: z7.string().optional(),
4465
- toolIds: z7.array(z7.string())
4324
+ stateChangedAt: z6.number(),
4325
+ grantedScopes: z6.array(z6.string()).optional(),
4326
+ authProviderId: z6.string().optional(),
4327
+ toolIds: z6.array(z6.string())
4466
4328
  });
4467
- var progressiveAuthStateSchema = z7.object({
4468
- apps: z7.record(z7.string(), appAuthorizationRecordSchema),
4469
- initiallyAuthorized: z7.array(z7.string()),
4470
- initiallySkipped: z7.array(z7.string())
4329
+ var progressiveAuthStateSchema = z6.object({
4330
+ apps: z6.record(z6.string(), appAuthorizationRecordSchema),
4331
+ initiallyAuthorized: z6.array(z6.string()),
4332
+ initiallySkipped: z6.array(z6.string())
4471
4333
  });
4472
4334
 
4473
4335
  // libs/auth/src/authorization/authorization.class.ts
@@ -5326,42 +5188,42 @@ var OrchestratedAuthAccessorAdapter = class {
5326
5188
  };
5327
5189
 
5328
5190
  // 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()
5191
+ import { z as z7 } from "zod";
5192
+ var jwkParametersSchema = z7.object({
5193
+ kty: z7.string().optional(),
5194
+ alg: z7.string().optional(),
5195
+ key_ops: z7.array(z7.string()).optional(),
5196
+ ext: z7.boolean().optional(),
5197
+ use: z7.string().optional(),
5198
+ x5c: z7.array(z7.string()).optional(),
5199
+ x5t: z7.string().optional(),
5200
+ "x5t#S256": z7.string().optional(),
5201
+ x5u: z7.string().optional(),
5202
+ kid: z7.string().optional()
5341
5203
  });
5342
5204
  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()
5205
+ crv: z7.string().optional(),
5206
+ d: z7.string().optional(),
5207
+ dp: z7.string().optional(),
5208
+ dq: z7.string().optional(),
5209
+ e: z7.string().optional(),
5210
+ k: z7.string().optional(),
5211
+ n: z7.string().optional(),
5212
+ p: z7.string().optional(),
5213
+ q: z7.string().optional(),
5214
+ qi: z7.string().optional(),
5215
+ x: z7.string().optional(),
5216
+ y: z7.string().optional(),
5217
+ pub: z7.string().optional(),
5218
+ priv: z7.string().optional()
5357
5219
  });
5358
- var jsonWebKeySetSchema = z8.object({
5359
- keys: z8.array(jwkSchema)
5220
+ var jsonWebKeySetSchema = z7.object({
5221
+ keys: z7.array(jwkSchema)
5360
5222
  });
5361
5223
 
5362
5224
  // libs/auth/src/common/session.types.ts
5363
- import { z as z9 } from "zod";
5364
- var aiPlatformTypeSchema = z9.enum([
5225
+ import { z as z8 } from "zod";
5226
+ var aiPlatformTypeSchema = z8.enum([
5365
5227
  "openai",
5366
5228
  "claude",
5367
5229
  "gemini",
@@ -5372,45 +5234,45 @@ var aiPlatformTypeSchema = z9.enum([
5372
5234
  "ext-apps",
5373
5235
  "unknown"
5374
5236
  ]);
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()
5237
+ var userClaimSchema = z8.object({
5238
+ iss: z8.string(),
5239
+ sid: z8.string().optional(),
5240
+ sub: z8.string(),
5241
+ exp: z8.number().optional(),
5242
+ iat: z8.number().optional(),
5243
+ aud: z8.union([z8.string(), z8.array(z8.string())]).optional(),
5244
+ email: z8.string().optional(),
5245
+ username: z8.string().optional(),
5246
+ preferred_username: z8.string().optional(),
5247
+ name: z8.string().optional(),
5248
+ picture: z8.string().optional()
5387
5249
  }).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(),
5250
+ var sessionIdPayloadSchema = z8.object({
5251
+ nodeId: z8.string(),
5252
+ authSig: z8.string(),
5253
+ uuid: z8.string().uuid(),
5254
+ iat: z8.number(),
5255
+ protocol: z8.enum(["legacy-sse", "sse", "streamable-http", "stateful-http", "stateless-http"]).optional(),
5256
+ isPublic: z8.boolean().optional(),
5395
5257
  platformType: aiPlatformTypeSchema.optional(),
5396
- clientName: z9.string().optional(),
5397
- clientVersion: z9.string().optional(),
5398
- supportsElicitation: z9.boolean().optional(),
5399
- skillsOnlyMode: z9.boolean().optional()
5258
+ clientName: z8.string().optional(),
5259
+ clientVersion: z8.string().optional(),
5260
+ supportsElicitation: z8.boolean().optional(),
5261
+ skillsOnlyMode: z8.boolean().optional()
5400
5262
  });
5401
- var sessionIdSchema = z9.object({
5402
- id: z9.string(),
5263
+ var sessionIdSchema = z8.object({
5264
+ id: z8.string(),
5403
5265
  /** Payload is optional - may be undefined when session validation failed but ID is passed for transport lookup */
5404
5266
  payload: sessionIdPayloadSchema.optional()
5405
5267
  });
5406
- var authorizationSchema = z9.object({
5407
- token: z9.string(),
5268
+ var authorizationSchema = z8.object({
5269
+ token: z8.string(),
5408
5270
  session: sessionIdSchema.optional(),
5409
5271
  user: userClaimSchema
5410
5272
  });
5411
5273
 
5412
5274
  // libs/auth/src/options/shared.schemas.ts
5413
- import { z as z11 } from "zod";
5275
+ import { z as z10 } from "zod";
5414
5276
 
5415
5277
  // libs/auth/src/cimd/cimd.logger.ts
5416
5278
  var noopLogger = {
@@ -5426,169 +5288,169 @@ var noopLogger = {
5426
5288
  };
5427
5289
 
5428
5290
  // libs/auth/src/cimd/cimd.types.ts
5429
- import { z as z10 } from "zod";
5430
- var clientMetadataDocumentSchema = z10.object({
5291
+ import { z as z9 } from "zod";
5292
+ var clientMetadataDocumentSchema = z9.object({
5431
5293
  // REQUIRED per CIMD spec
5432
5294
  /**
5433
5295
  * Client identifier - MUST match the URL from which this document was fetched.
5434
5296
  */
5435
- client_id: z10.string().url(),
5297
+ client_id: z9.string().url(),
5436
5298
  /**
5437
5299
  * Human-readable name of the client.
5438
5300
  */
5439
- client_name: z10.string().min(1),
5301
+ client_name: z9.string().min(1),
5440
5302
  /**
5441
5303
  * Array of redirect URIs for authorization responses.
5442
5304
  * At least one is required.
5443
5305
  */
5444
- redirect_uris: z10.array(z10.string().url()).min(1),
5306
+ redirect_uris: z9.array(z9.string().url()).min(1),
5445
5307
  // OPTIONAL per RFC 7591
5446
5308
  /**
5447
5309
  * Token endpoint authentication method.
5448
5310
  * @default 'none'
5449
5311
  */
5450
- token_endpoint_auth_method: z10.enum(["none", "client_secret_basic", "client_secret_post", "private_key_jwt"]).default("none"),
5312
+ token_endpoint_auth_method: z9.enum(["none", "client_secret_basic", "client_secret_post", "private_key_jwt"]).default("none"),
5451
5313
  /**
5452
5314
  * OAuth grant types the client can use.
5453
5315
  * @default ['authorization_code']
5454
5316
  */
5455
- grant_types: z10.array(z10.string()).default(["authorization_code"]),
5317
+ grant_types: z9.array(z9.string()).default(["authorization_code"]),
5456
5318
  /**
5457
5319
  * OAuth response types the client can request.
5458
5320
  * @default ['code']
5459
5321
  */
5460
- response_types: z10.array(z10.string()).default(["code"]),
5322
+ response_types: z9.array(z9.string()).default(["code"]),
5461
5323
  /**
5462
5324
  * URL of the client's home page.
5463
5325
  */
5464
- client_uri: z10.string().url().optional(),
5326
+ client_uri: z9.string().url().optional(),
5465
5327
  /**
5466
5328
  * URL of the client's logo image.
5467
5329
  */
5468
- logo_uri: z10.string().url().optional(),
5330
+ logo_uri: z9.string().url().optional(),
5469
5331
  /**
5470
5332
  * URL of the client's JWKS (for private_key_jwt).
5471
5333
  */
5472
- jwks_uri: z10.string().url().optional(),
5334
+ jwks_uri: z9.string().url().optional(),
5473
5335
  /**
5474
5336
  * Inline JWKS (for private_key_jwt).
5475
5337
  */
5476
- jwks: z10.object({
5477
- keys: z10.array(z10.record(z10.string(), z10.unknown()))
5338
+ jwks: z9.object({
5339
+ keys: z9.array(z9.record(z9.string(), z9.unknown()))
5478
5340
  }).optional(),
5479
5341
  /**
5480
5342
  * URL of the client's terms of service.
5481
5343
  */
5482
- tos_uri: z10.string().url().optional(),
5344
+ tos_uri: z9.string().url().optional(),
5483
5345
  /**
5484
5346
  * URL of the client's privacy policy.
5485
5347
  */
5486
- policy_uri: z10.string().url().optional(),
5348
+ policy_uri: z9.string().url().optional(),
5487
5349
  /**
5488
5350
  * Requested OAuth scopes.
5489
5351
  */
5490
- scope: z10.string().optional(),
5352
+ scope: z9.string().optional(),
5491
5353
  /**
5492
5354
  * Array of contact emails for the client.
5493
5355
  */
5494
- contacts: z10.array(z10.string().email()).optional(),
5356
+ contacts: z9.array(z9.string().email()).optional(),
5495
5357
  /**
5496
5358
  * Software statement (signed JWT).
5497
5359
  */
5498
- software_statement: z10.string().optional(),
5360
+ software_statement: z9.string().optional(),
5499
5361
  /**
5500
5362
  * Unique identifier for the client software.
5501
5363
  */
5502
- software_id: z10.string().optional(),
5364
+ software_id: z9.string().optional(),
5503
5365
  /**
5504
5366
  * Version of the client software.
5505
5367
  */
5506
- software_version: z10.string().optional()
5368
+ software_version: z9.string().optional()
5507
5369
  });
5508
- var cimdRedisCacheConfigSchema = z10.object({
5370
+ var cimdRedisCacheConfigSchema = z9.object({
5509
5371
  /**
5510
5372
  * Redis connection URL.
5511
5373
  * e.g., "redis://user:pass@host:6379/0"
5512
5374
  */
5513
- url: z10.string().optional(),
5375
+ url: z9.string().optional(),
5514
5376
  /**
5515
5377
  * Redis host.
5516
5378
  */
5517
- host: z10.string().optional(),
5379
+ host: z9.string().optional(),
5518
5380
  /**
5519
5381
  * Redis port.
5520
5382
  * @default 6379
5521
5383
  */
5522
- port: z10.number().optional(),
5384
+ port: z9.number().optional(),
5523
5385
  /**
5524
5386
  * Redis password.
5525
5387
  */
5526
- password: z10.string().optional(),
5388
+ password: z9.string().optional(),
5527
5389
  /**
5528
5390
  * Redis database number.
5529
5391
  * @default 0
5530
5392
  */
5531
- db: z10.number().optional(),
5393
+ db: z9.number().optional(),
5532
5394
  /**
5533
5395
  * Enable TLS for Redis connection.
5534
5396
  * @default false
5535
5397
  */
5536
- tls: z10.boolean().optional(),
5398
+ tls: z9.boolean().optional(),
5537
5399
  /**
5538
5400
  * Key prefix for CIMD cache entries.
5539
5401
  * @default 'cimd:'
5540
5402
  */
5541
- keyPrefix: z10.string().default("cimd:")
5403
+ keyPrefix: z9.string().default("cimd:")
5542
5404
  });
5543
- var cimdCacheConfigSchema = z10.object({
5405
+ var cimdCacheConfigSchema = z9.object({
5544
5406
  /**
5545
5407
  * Cache storage type.
5546
5408
  * - 'memory': In-memory cache (default, suitable for dev/single-instance)
5547
5409
  * - 'redis': Redis-backed cache (for production/distributed deployments)
5548
5410
  * @default 'memory'
5549
5411
  */
5550
- type: z10.enum(["memory", "redis"]).default("memory"),
5412
+ type: z9.enum(["memory", "redis"]).default("memory"),
5551
5413
  /**
5552
5414
  * Default TTL for cached metadata documents.
5553
5415
  * @default 3600000 (1 hour)
5554
5416
  */
5555
- defaultTtlMs: z10.number().min(0).default(36e5),
5417
+ defaultTtlMs: z9.number().min(0).default(36e5),
5556
5418
  /**
5557
5419
  * Maximum TTL (even if server suggests longer).
5558
5420
  * @default 86400000 (24 hours)
5559
5421
  */
5560
- maxTtlMs: z10.number().min(0).default(864e5),
5422
+ maxTtlMs: z9.number().min(0).default(864e5),
5561
5423
  /**
5562
5424
  * Minimum TTL (even if server suggests shorter).
5563
5425
  * @default 60000 (1 minute)
5564
5426
  */
5565
- minTtlMs: z10.number().min(0).default(6e4),
5427
+ minTtlMs: z9.number().min(0).default(6e4),
5566
5428
  /**
5567
5429
  * Redis configuration (required when type is 'redis').
5568
5430
  */
5569
5431
  redis: cimdRedisCacheConfigSchema.optional()
5570
5432
  });
5571
- var cimdSecurityConfigSchema = z10.object({
5433
+ var cimdSecurityConfigSchema = z9.object({
5572
5434
  /**
5573
5435
  * Block fetching from private/internal IP addresses (SSRF protection).
5574
5436
  * @default true
5575
5437
  */
5576
- blockPrivateIPs: z10.boolean().default(true),
5438
+ blockPrivateIPs: z9.boolean().default(true),
5577
5439
  /**
5578
5440
  * Explicit list of allowed domains.
5579
5441
  * If set, only these domains can host CIMD documents.
5580
5442
  */
5581
- allowedDomains: z10.array(z10.string()).optional(),
5443
+ allowedDomains: z9.array(z9.string()).optional(),
5582
5444
  /**
5583
5445
  * Explicit list of blocked domains.
5584
5446
  * These domains cannot host CIMD documents.
5585
5447
  */
5586
- blockedDomains: z10.array(z10.string()).optional(),
5448
+ blockedDomains: z9.array(z9.string()).optional(),
5587
5449
  /**
5588
5450
  * Warn when a client has only localhost redirect URIs.
5589
5451
  * @default true
5590
5452
  */
5591
- warnOnLocalhostRedirects: z10.boolean().default(true),
5453
+ warnOnLocalhostRedirects: z9.boolean().default(true),
5592
5454
  /**
5593
5455
  * Allow HTTP (instead of HTTPS) for localhost CIMD URLs.
5594
5456
  *
@@ -5599,19 +5461,19 @@ var cimdSecurityConfigSchema = z10.object({
5599
5461
  *
5600
5462
  * @default false
5601
5463
  */
5602
- allowInsecureForTesting: z10.boolean().default(false)
5464
+ allowInsecureForTesting: z9.boolean().default(false)
5603
5465
  });
5604
- var cimdNetworkConfigSchema = z10.object({
5466
+ var cimdNetworkConfigSchema = z9.object({
5605
5467
  /**
5606
5468
  * Request timeout in milliseconds.
5607
5469
  * @default 5000 (5 seconds)
5608
5470
  */
5609
- timeoutMs: z10.number().min(100).default(5e3),
5471
+ timeoutMs: z9.number().min(100).default(5e3),
5610
5472
  /**
5611
5473
  * Maximum response body size in bytes.
5612
5474
  * @default 65536 (64KB)
5613
5475
  */
5614
- maxResponseSizeBytes: z10.number().min(1024).default(65536),
5476
+ maxResponseSizeBytes: z9.number().min(1024).default(65536),
5615
5477
  /**
5616
5478
  * Redirect handling policy for CIMD fetches.
5617
5479
  * - 'deny': reject redirects (default, safest)
@@ -5619,19 +5481,19 @@ var cimdNetworkConfigSchema = z10.object({
5619
5481
  * - 'allow': allow redirects to any origin
5620
5482
  * @default 'deny'
5621
5483
  */
5622
- redirectPolicy: z10.enum(["deny", "same-origin", "allow"]).default("deny"),
5484
+ redirectPolicy: z9.enum(["deny", "same-origin", "allow"]).default("deny"),
5623
5485
  /**
5624
5486
  * Maximum number of redirects to follow when redirects are allowed.
5625
5487
  * @default 5
5626
5488
  */
5627
- maxRedirects: z10.number().int().min(0).default(5)
5489
+ maxRedirects: z9.number().int().min(0).default(5)
5628
5490
  });
5629
- var cimdConfigSchema = z10.object({
5491
+ var cimdConfigSchema = z9.object({
5630
5492
  /**
5631
5493
  * Enable CIMD support.
5632
5494
  * @default true
5633
5495
  */
5634
- enabled: z10.boolean().default(true),
5496
+ enabled: z9.boolean().default(true),
5635
5497
  /**
5636
5498
  * Cache configuration.
5637
5499
  */
@@ -5994,7 +5856,7 @@ var CimdService = class {
5994
5856
  this.cacheConfig = cimdCacheConfigSchema.parse(this.config.cache ?? {});
5995
5857
  this.securityConfig = cimdSecurityConfigSchema.parse(this.config.security ?? {});
5996
5858
  this.networkConfig = cimdNetworkConfigSchema.parse(this.config.network ?? {});
5997
- this.cache = new CimdCache(this.cacheConfig);
5859
+ this.cache = new InMemoryCimdCache(this.cacheConfig);
5998
5860
  this.logger.debug("CimdService initialized", {
5999
5861
  enabled: this.config.enabled,
6000
5862
  cacheDefaultTtlMs: this.cacheConfig.defaultTtlMs,
@@ -6262,8 +6124,8 @@ var CimdService = class {
6262
6124
  const result = clientMetadataDocumentSchema.safeParse(document);
6263
6125
  if (!result.success) {
6264
6126
  const errors = result.error.issues.map((issue) => {
6265
- const path3 = issue.path.length > 0 ? `${issue.path.join(".")}: ` : "";
6266
- return `${path3}${issue.message}`;
6127
+ const path = issue.path.length > 0 ? `${issue.path.join(".")}: ` : "";
6128
+ return `${path}${issue.message}`;
6267
6129
  });
6268
6130
  throw new CimdValidationError(clientId, errors);
6269
6131
  }
@@ -6285,55 +6147,84 @@ function normalizeRedirectUri(uri) {
6285
6147
  }
6286
6148
 
6287
6149
  // libs/auth/src/options/shared.schemas.ts
6288
- var publicAccessConfigSchema = z11.object({
6150
+ var publicAccessConfigSchema = z10.object({
6289
6151
  /**
6290
6152
  * Allow all tools or explicit whitelist
6291
6153
  * @default 'all'
6292
6154
  */
6293
- tools: z11.union([z11.literal("all"), z11.array(z11.string())]).default("all"),
6155
+ tools: z10.union([z10.literal("all"), z10.array(z10.string())]).default("all"),
6294
6156
  /**
6295
6157
  * Allow all prompts or explicit whitelist
6296
6158
  * @default 'all'
6297
6159
  */
6298
- prompts: z11.union([z11.literal("all"), z11.array(z11.string())]).default("all"),
6160
+ prompts: z10.union([z10.literal("all"), z10.array(z10.string())]).default("all"),
6299
6161
  /**
6300
6162
  * Rate limit per IP per minute
6301
6163
  * @default 60
6302
6164
  */
6303
- rateLimit: z11.number().default(60)
6165
+ rateLimit: z10.number().default(60)
6304
6166
  });
6305
- var localSigningConfigSchema = z11.object({
6167
+ var localSigningConfigSchema = z10.object({
6306
6168
  /**
6307
- * Private key for signing orchestrated tokens
6169
+ * Private key for signing tokens
6308
6170
  * @default auto-generated
6309
6171
  */
6310
- signKey: jwkSchema.or(z11.instanceof(Uint8Array)).optional(),
6172
+ signKey: jwkSchema.or(z10.instanceof(Uint8Array)).optional(),
6311
6173
  /**
6312
6174
  * JWKS for token verification
6313
6175
  * @default auto-generated
6314
6176
  */
6315
6177
  jwks: jsonWebKeySetSchema.optional(),
6316
6178
  /**
6317
- * Issuer identifier for orchestrated tokens
6179
+ * Issuer identifier for tokens
6318
6180
  * @default auto-derived from server URL
6319
6181
  */
6320
- issuer: z11.string().optional()
6182
+ issuer: z10.string().optional()
6321
6183
  });
6322
- var remoteProviderConfigSchema = z11.object({
6184
+ var providerConfigSchema = z10.object({
6185
+ /** Provider display name */
6186
+ name: z10.string().optional(),
6187
+ /**
6188
+ * Unique identifier for this provider
6189
+ * @default derived from provider URL
6190
+ */
6191
+ id: z10.string().optional(),
6192
+ /**
6193
+ * Inline JWKS for offline token verification
6194
+ * Falls back to fetching from provider's /.well-known/jwks.json
6195
+ */
6196
+ jwks: jsonWebKeySetSchema.optional(),
6197
+ /** Custom JWKS URI if not at standard path */
6198
+ jwksUri: z10.string().url().optional(),
6199
+ /**
6200
+ * Enable Dynamic Client Registration (DCR)
6201
+ * @default false
6202
+ */
6203
+ dcrEnabled: z10.boolean().default(false),
6204
+ /** Authorization endpoint override */
6205
+ authEndpoint: z10.string().url().optional(),
6206
+ /** Token endpoint override */
6207
+ tokenEndpoint: z10.string().url().optional(),
6208
+ /** Registration endpoint override (for DCR) */
6209
+ registrationEndpoint: z10.string().url().optional(),
6210
+ /** User info endpoint override */
6211
+ userInfoEndpoint: z10.string().url().optional()
6212
+ });
6213
+ var remoteProviderConfigSchema = z10.object({
6323
6214
  /**
6324
6215
  * OAuth provider base URL
6325
6216
  * @example 'https://auth.example.com'
6326
6217
  */
6327
- provider: z11.string().url(),
6218
+ provider: z10.string().url(),
6328
6219
  /**
6329
6220
  * Provider display name
6330
6221
  */
6331
- name: z11.string().optional(),
6222
+ name: z10.string().optional(),
6332
6223
  /**
6333
6224
  * Unique identifier for this provider
6334
6225
  * @default derived from provider URL
6335
6226
  */
6336
- id: z11.string().optional(),
6227
+ id: z10.string().optional(),
6337
6228
  /**
6338
6229
  * Inline JWKS for offline token verification
6339
6230
  * Falls back to fetching from provider's /.well-known/jwks.json
@@ -6342,121 +6233,133 @@ var remoteProviderConfigSchema = z11.object({
6342
6233
  /**
6343
6234
  * Custom JWKS URI if not at standard path
6344
6235
  */
6345
- jwksUri: z11.string().url().optional(),
6236
+ jwksUri: z10.string().url().optional(),
6346
6237
  /**
6347
- * Client ID for this MCP server (for orchestrated mode)
6238
+ * Client ID for this MCP server
6348
6239
  */
6349
- clientId: z11.string().optional(),
6240
+ clientId: z10.string().optional(),
6350
6241
  /**
6351
- * Client secret (for confidential clients in orchestrated mode)
6242
+ * Client secret (for confidential clients)
6352
6243
  */
6353
- clientSecret: z11.string().optional(),
6244
+ clientSecret: z10.string().optional(),
6354
6245
  /**
6355
6246
  * Scopes to request from the upstream provider
6356
6247
  */
6357
- scopes: z11.array(z11.string()).optional(),
6248
+ scopes: z10.array(z10.string()).optional(),
6358
6249
  /**
6359
6250
  * Enable Dynamic Client Registration (DCR)
6360
6251
  * @default false
6361
6252
  */
6362
- dcrEnabled: z11.boolean().default(false),
6253
+ dcrEnabled: z10.boolean().default(false),
6363
6254
  /**
6364
6255
  * Authorization endpoint override
6365
6256
  */
6366
- authEndpoint: z11.string().url().optional(),
6257
+ authEndpoint: z10.string().url().optional(),
6367
6258
  /**
6368
6259
  * Token endpoint override
6369
6260
  */
6370
- tokenEndpoint: z11.string().url().optional(),
6261
+ tokenEndpoint: z10.string().url().optional(),
6371
6262
  /**
6372
6263
  * Registration endpoint override (for DCR)
6373
6264
  */
6374
- registrationEndpoint: z11.string().url().optional(),
6265
+ registrationEndpoint: z10.string().url().optional(),
6375
6266
  /**
6376
6267
  * User info endpoint override
6377
6268
  */
6378
- userInfoEndpoint: z11.string().url().optional()
6269
+ userInfoEndpoint: z10.string().url().optional()
6379
6270
  });
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({
6271
+ var flatRemoteProviderFields = {
6272
+ /**
6273
+ * OAuth provider base URL (required)
6274
+ * @example 'https://auth.example.com'
6275
+ */
6276
+ provider: z10.string().url(),
6277
+ /** Client ID for this MCP server */
6278
+ clientId: z10.string().optional(),
6279
+ /** Client secret (for confidential clients) */
6280
+ clientSecret: z10.string().optional(),
6281
+ /** Scopes to request from the upstream provider */
6282
+ scopes: z10.array(z10.string()).optional(),
6283
+ /** Advanced provider configuration */
6284
+ providerConfig: providerConfigSchema.optional()
6285
+ };
6286
+ var tokenStorageConfigSchema = z10.union([z10.literal("memory"), z10.object({ redis: redisConfigSchema })]);
6287
+ var tokenRefreshConfigSchema = z10.object({
6385
6288
  /**
6386
6289
  * Enable automatic token refresh
6387
6290
  * @default true
6388
6291
  */
6389
- enabled: z11.boolean().default(true),
6292
+ enabled: z10.boolean().default(true),
6390
6293
  /**
6391
6294
  * Refresh token before expiry by this many seconds
6392
6295
  * @default 60
6393
6296
  */
6394
- skewSeconds: z11.number().default(60)
6297
+ skewSeconds: z10.number().default(60)
6395
6298
  });
6396
- var skippedAppBehaviorSchema = z11.enum(["anonymous", "require-auth"]);
6397
- var consentConfigSchema = z11.object({
6299
+ var skippedAppBehaviorSchema = z10.enum(["anonymous", "require-auth"]);
6300
+ var consentConfigSchema = z10.object({
6398
6301
  /**
6399
6302
  * Enable consent flow for tool selection
6400
6303
  * When enabled, users can choose which tools to expose to the LLM
6401
6304
  * @default false
6402
6305
  */
6403
- enabled: z11.boolean().default(false),
6306
+ enabled: z10.boolean().default(false),
6404
6307
  /**
6405
6308
  * Group tools by app in the consent UI
6406
6309
  * @default true
6407
6310
  */
6408
- groupByApp: z11.boolean().default(true),
6311
+ groupByApp: z10.boolean().default(true),
6409
6312
  /**
6410
6313
  * Show tool descriptions in consent UI
6411
6314
  * @default true
6412
6315
  */
6413
- showDescriptions: z11.boolean().default(true),
6316
+ showDescriptions: z10.boolean().default(true),
6414
6317
  /**
6415
6318
  * Allow selecting all tools at once
6416
6319
  * @default true
6417
6320
  */
6418
- allowSelectAll: z11.boolean().default(true),
6321
+ allowSelectAll: z10.boolean().default(true),
6419
6322
  /**
6420
6323
  * Require at least one tool to be selected
6421
6324
  * @default true
6422
6325
  */
6423
- requireSelection: z11.boolean().default(true),
6326
+ requireSelection: z10.boolean().default(true),
6424
6327
  /**
6425
6328
  * Custom message to display on consent page
6426
6329
  */
6427
- customMessage: z11.string().optional(),
6330
+ customMessage: z10.string().optional(),
6428
6331
  /**
6429
6332
  * Remember consent for future sessions
6430
6333
  * @default true
6431
6334
  */
6432
- rememberConsent: z11.boolean().default(true),
6335
+ rememberConsent: z10.boolean().default(true),
6433
6336
  /**
6434
6337
  * Tools to exclude from consent (always available)
6435
6338
  * Useful for essential tools that should always be accessible
6436
6339
  */
6437
- excludedTools: z11.array(z11.string()).optional(),
6340
+ excludedTools: z10.array(z10.string()).optional(),
6438
6341
  /**
6439
6342
  * Tools to always include in consent (pre-selected)
6440
6343
  */
6441
- defaultSelectedTools: z11.array(z11.string()).optional()
6344
+ defaultSelectedTools: z10.array(z10.string()).optional()
6442
6345
  });
6443
- var federatedAuthConfigSchema = z11.object({
6346
+ var federatedAuthConfigSchema = z10.object({
6444
6347
  /**
6445
6348
  * How strictly to validate the OAuth state parameter on provider callbacks.
6446
6349
  * - 'strict': require exact match to stored state (default, safest)
6447
6350
  * - 'format': validate only "federated:{sessionId}:{nonce}" format
6448
6351
  * @default 'strict'
6449
6352
  */
6450
- stateValidation: z11.enum(["strict", "format"]).default("strict")
6353
+ stateValidation: z10.enum(["strict", "format"]).default("strict")
6451
6354
  });
6452
- var incrementalAuthConfigSchema = z11.object({
6355
+ var incrementalAuthConfigSchema = z10.object({
6453
6356
  /**
6454
6357
  * Enable incremental (progressive) authorization
6455
6358
  * When enabled, users can skip app authorizations during initial auth
6456
6359
  * and authorize individual apps later when needed
6457
6360
  * @default true
6458
6361
  */
6459
- enabled: z11.boolean().default(true),
6362
+ enabled: z10.boolean().default(true),
6460
6363
  /**
6461
6364
  * Behavior when a tool from a skipped app is called
6462
6365
  * - 'anonymous': If app supports anonymous access, use it; otherwise require auth
@@ -6468,33 +6371,33 @@ var incrementalAuthConfigSchema = z11.object({
6468
6371
  * Allow users to skip app authorization during initial auth flow
6469
6372
  * @default true
6470
6373
  */
6471
- allowSkip: z11.boolean().default(true),
6374
+ allowSkip: z10.boolean().default(true),
6472
6375
  /**
6473
6376
  * Show all apps in a single authorization page (vs step-by-step)
6474
6377
  * @default true
6475
6378
  */
6476
- showAllAppsAtOnce: z11.boolean().default(true)
6379
+ showAllAppsAtOnce: z10.boolean().default(true)
6477
6380
  });
6478
6381
 
6479
6382
  // libs/auth/src/options/public.schema.ts
6480
- import { z as z12 } from "zod";
6481
- var publicAuthOptionsSchema = z12.object({
6482
- mode: z12.literal("public"),
6383
+ import { z as z11 } from "zod";
6384
+ var publicAuthOptionsSchema = z11.object({
6385
+ mode: z11.literal("public"),
6483
6386
  /**
6484
6387
  * Issuer identifier for anonymous JWTs
6485
6388
  * @default auto-derived from server URL
6486
6389
  */
6487
- issuer: z12.string().optional(),
6390
+ issuer: z11.string().optional(),
6488
6391
  /**
6489
6392
  * Anonymous session TTL in seconds
6490
6393
  * @default 3600 (1 hour)
6491
6394
  */
6492
- sessionTtl: z12.number().default(3600),
6395
+ sessionTtl: z11.number().default(3600),
6493
6396
  /**
6494
6397
  * Scopes granted to anonymous sessions
6495
6398
  * @default ['anonymous']
6496
6399
  */
6497
- anonymousScopes: z12.array(z12.string()).default(["anonymous"]),
6400
+ anonymousScopes: z11.array(z11.string()).default(["anonymous"]),
6498
6401
  /**
6499
6402
  * Tool/prompt access configuration for anonymous users
6500
6403
  */
@@ -6508,38 +6411,38 @@ var publicAuthOptionsSchema = z12.object({
6508
6411
  * Private key for signing anonymous tokens
6509
6412
  * @default auto-generated
6510
6413
  */
6511
- signKey: jwkSchema.or(z12.instanceof(Uint8Array)).optional()
6414
+ signKey: jwkSchema.or(z11.instanceof(Uint8Array)).optional()
6512
6415
  });
6513
6416
 
6514
6417
  // libs/auth/src/options/transparent.schema.ts
6515
- import { z as z13 } from "zod";
6516
- var transparentAuthOptionsSchema = z13.object({
6517
- mode: z13.literal("transparent"),
6418
+ import { z as z12 } from "zod";
6419
+ var transparentAuthOptionsSchema = z12.object({
6420
+ mode: z12.literal("transparent"),
6518
6421
  /**
6519
- * Remote OAuth provider configuration (required)
6422
+ * Flattened remote provider fields (provider, clientId, clientSecret, scopes, providerConfig)
6520
6423
  */
6521
- remote: remoteProviderConfigSchema,
6424
+ ...flatRemoteProviderFields,
6522
6425
  /**
6523
6426
  * Expected token audience
6524
6427
  * If not set, defaults to the resource URL
6525
6428
  */
6526
- expectedAudience: z13.union([z13.string(), z13.array(z13.string())]).optional(),
6429
+ expectedAudience: z12.union([z12.string(), z12.array(z12.string())]).optional(),
6527
6430
  /**
6528
6431
  * Required scopes for access
6529
6432
  * Empty array means any valid token is accepted
6530
6433
  * @default []
6531
6434
  */
6532
- requiredScopes: z13.array(z13.string()).default([]),
6435
+ requiredScopes: z12.array(z12.string()).default([]),
6533
6436
  /**
6534
6437
  * Allow anonymous fallback when no token is provided
6535
6438
  * @default false
6536
6439
  */
6537
- allowAnonymous: z13.boolean().default(false),
6440
+ allowAnonymous: z12.boolean().default(false),
6538
6441
  /**
6539
6442
  * Scopes granted to anonymous sessions (when allowAnonymous=true)
6540
6443
  * @default ['anonymous']
6541
6444
  */
6542
- anonymousScopes: z13.array(z13.string()).default(["anonymous"]),
6445
+ anonymousScopes: z12.array(z12.string()).default(["anonymous"]),
6543
6446
  /**
6544
6447
  * Public access config for anonymous users (when allowAnonymous=true)
6545
6448
  */
@@ -6547,56 +6450,52 @@ var transparentAuthOptionsSchema = z13.object({
6547
6450
  });
6548
6451
 
6549
6452
  // libs/auth/src/options/orchestrated.schema.ts
6550
- import { z as z14 } from "zod";
6551
- var orchestratedSharedFields = {
6453
+ import { z as z13 } from "zod";
6454
+ var sharedAuthFields = {
6552
6455
  local: localSigningConfigSchema.optional(),
6553
- tokenStorage: tokenStorageConfigSchema.default({ type: "memory" }),
6554
- allowDefaultPublic: z14.boolean().default(false),
6555
- anonymousScopes: z14.array(z14.string()).default(["anonymous"]),
6456
+ tokenStorage: tokenStorageConfigSchema.default("memory"),
6457
+ allowDefaultPublic: z13.boolean().default(false),
6458
+ anonymousScopes: z13.array(z13.string()).default(["anonymous"]),
6556
6459
  publicAccess: publicAccessConfigSchema.optional(),
6557
6460
  consent: consentConfigSchema.optional(),
6558
6461
  federatedAuth: federatedAuthConfigSchema.optional(),
6559
6462
  refresh: tokenRefreshConfigSchema.optional(),
6560
- expectedAudience: z14.union([z14.string(), z14.array(z14.string())]).optional(),
6463
+ expectedAudience: z13.union([z13.string(), z13.array(z13.string())]).optional(),
6561
6464
  incrementalAuth: incrementalAuthConfigSchema.optional(),
6562
6465
  cimd: cimdConfigSchema.optional()
6563
6466
  };
6564
- var orchestratedLocalSchema = z14.object({
6565
- mode: z14.literal("orchestrated"),
6566
- type: z14.literal("local"),
6567
- ...orchestratedSharedFields
6467
+ var localAuthSchema = z13.object({
6468
+ mode: z13.literal("local"),
6469
+ ...sharedAuthFields
6568
6470
  });
6569
- var orchestratedRemoteSchema = z14.object({
6570
- mode: z14.literal("orchestrated"),
6571
- type: z14.literal("remote"),
6572
- remote: remoteProviderConfigSchema,
6573
- ...orchestratedSharedFields
6471
+ var remoteAuthSchema = z13.object({
6472
+ mode: z13.literal("remote"),
6473
+ ...flatRemoteProviderFields,
6474
+ ...sharedAuthFields
6574
6475
  });
6575
- var orchestratedAuthOptionsSchema = z14.discriminatedUnion("type", [
6576
- orchestratedLocalSchema,
6577
- orchestratedRemoteSchema
6578
- ]);
6476
+ var orchestratedLocalSchema = localAuthSchema;
6477
+ var orchestratedRemoteSchema = remoteAuthSchema;
6579
6478
 
6580
6479
  // libs/auth/src/options/schema.ts
6581
- import { z as z15 } from "zod";
6582
- var authOptionsSchema = z15.union([
6480
+ import { z as z14 } from "zod";
6481
+ var authOptionsSchema = z14.union([
6583
6482
  publicAuthOptionsSchema,
6584
6483
  transparentAuthOptionsSchema,
6585
- orchestratedLocalSchema,
6586
- orchestratedRemoteSchema
6484
+ localAuthSchema,
6485
+ remoteAuthSchema
6587
6486
  ]);
6588
6487
 
6589
6488
  // libs/auth/src/options/app-auth.schema.ts
6590
- import { z as z16 } from "zod";
6489
+ import { z as z15 } from "zod";
6591
6490
  var standaloneOptionSchema = {
6592
- standalone: z16.boolean().optional(),
6593
- excludeFromParent: z16.boolean().optional()
6491
+ standalone: z15.boolean().optional(),
6492
+ excludeFromParent: z15.boolean().optional()
6594
6493
  };
6595
- var appAuthOptionsSchema = z16.union([
6494
+ var appAuthOptionsSchema = z15.union([
6596
6495
  publicAuthOptionsSchema.extend(standaloneOptionSchema),
6597
6496
  transparentAuthOptionsSchema.extend(standaloneOptionSchema),
6598
- orchestratedLocalSchema.extend(standaloneOptionSchema),
6599
- orchestratedRemoteSchema.extend(standaloneOptionSchema)
6497
+ localAuthSchema.extend(standaloneOptionSchema),
6498
+ remoteAuthSchema.extend(standaloneOptionSchema)
6600
6499
  ]);
6601
6500
 
6602
6501
  // libs/auth/src/options/utils.ts
@@ -6609,136 +6508,142 @@ function isPublicMode(options) {
6609
6508
  function isTransparentMode(options) {
6610
6509
  return options.mode === "transparent";
6611
6510
  }
6511
+ function isLocalMode(options) {
6512
+ return options.mode === "local";
6513
+ }
6514
+ function isRemoteMode(options) {
6515
+ return options.mode === "remote";
6516
+ }
6612
6517
  function isOrchestratedMode(options) {
6613
- return options.mode === "orchestrated";
6518
+ return options.mode === "local" || options.mode === "remote";
6614
6519
  }
6615
6520
  function isOrchestratedLocal(options) {
6616
- return options.type === "local";
6521
+ return options.mode === "local";
6617
6522
  }
6618
6523
  function isOrchestratedRemote(options) {
6619
- return options.type === "remote";
6524
+ return options.mode === "remote";
6620
6525
  }
6621
6526
  function allowsPublicAccess(options) {
6622
6527
  if (options.mode === "public") return true;
6623
6528
  if (options.mode === "transparent") return options.allowAnonymous;
6624
- if (options.mode === "orchestrated") return options.allowDefaultPublic;
6529
+ if (options.mode === "local" || options.mode === "remote") return options.allowDefaultPublic;
6625
6530
  return false;
6626
6531
  }
6627
6532
 
6628
6533
  // libs/auth/src/consent/consent.types.ts
6629
- import { z as z17 } from "zod";
6630
- var consentToolItemSchema = z17.object({
6534
+ import { z as z16 } from "zod";
6535
+ var consentToolItemSchema = z16.object({
6631
6536
  /** Tool ID (e.g., 'slack:send_message') */
6632
- id: z17.string().min(1),
6537
+ id: z16.string().min(1),
6633
6538
  /** Tool name for display */
6634
- name: z17.string().min(1),
6539
+ name: z16.string().min(1),
6635
6540
  /** Tool description */
6636
- description: z17.string().optional(),
6541
+ description: z16.string().optional(),
6637
6542
  /** App ID this tool belongs to */
6638
- appId: z17.string().min(1),
6543
+ appId: z16.string().min(1),
6639
6544
  /** App name for display */
6640
- appName: z17.string().min(1),
6545
+ appName: z16.string().min(1),
6641
6546
  /** Whether the tool is selected by default */
6642
- defaultSelected: z17.boolean().default(true),
6547
+ defaultSelected: z16.boolean().default(true),
6643
6548
  /** Whether this tool requires specific scopes */
6644
- requiredScopes: z17.array(z17.string()).optional(),
6549
+ requiredScopes: z16.array(z16.string()).optional(),
6645
6550
  /** Category for grouping (e.g., 'read', 'write', 'admin') */
6646
- category: z17.string().optional()
6551
+ category: z16.string().optional()
6647
6552
  });
6648
- var consentSelectionSchema = z17.object({
6553
+ var consentSelectionSchema = z16.object({
6649
6554
  /** Selected tool IDs */
6650
- selectedTools: z17.array(z17.string()),
6555
+ selectedTools: z16.array(z16.string()),
6651
6556
  /** Whether all tools were selected */
6652
- allSelected: z17.boolean(),
6557
+ allSelected: z16.boolean(),
6653
6558
  /** Timestamp when consent was given */
6654
- consentedAt: z17.string().datetime(),
6559
+ consentedAt: z16.string().datetime(),
6655
6560
  /** Consent version for tracking changes */
6656
- consentVersion: z17.string().default("1.0")
6561
+ consentVersion: z16.string().default("1.0")
6657
6562
  });
6658
- var consentStateSchema = z17.object({
6563
+ var consentStateSchema = z16.object({
6659
6564
  /** Whether consent flow is enabled */
6660
- enabled: z17.boolean(),
6565
+ enabled: z16.boolean(),
6661
6566
  /** Available tools for consent */
6662
- availableTools: z17.array(consentToolItemSchema),
6567
+ availableTools: z16.array(consentToolItemSchema),
6663
6568
  /** Pre-selected tools (from previous consent or defaults) */
6664
- preselectedTools: z17.array(z17.string()).optional(),
6569
+ preselectedTools: z16.array(z16.string()).optional(),
6665
6570
  /** Whether to show all tools or group by app */
6666
- groupByApp: z17.boolean().default(true),
6571
+ groupByApp: z16.boolean().default(true),
6667
6572
  /** Custom consent message */
6668
- customMessage: z17.string().optional()
6573
+ customMessage: z16.string().optional()
6669
6574
  });
6670
- var federatedProviderItemSchema = z17.object({
6575
+ var federatedProviderItemSchema = z16.object({
6671
6576
  /** Provider ID (derived or explicit) */
6672
- id: z17.string().min(1),
6577
+ id: z16.string().min(1),
6673
6578
  /** Provider display name */
6674
- name: z17.string().min(1),
6579
+ name: z16.string().min(1),
6675
6580
  /** Provider description */
6676
- description: z17.string().optional(),
6581
+ description: z16.string().optional(),
6677
6582
  /** Provider icon URL or emoji */
6678
- icon: z17.string().optional(),
6583
+ icon: z16.string().optional(),
6679
6584
  /** Provider type */
6680
- type: z17.enum(["local", "remote", "transparent"]),
6585
+ type: z16.enum(["local", "remote", "transparent"]),
6681
6586
  /** OAuth provider URL (for remote providers) */
6682
- providerUrl: z17.string().url().optional(),
6587
+ providerUrl: z16.string().url().optional(),
6683
6588
  /** Apps using this provider */
6684
- appIds: z17.array(z17.string()),
6589
+ appIds: z16.array(z16.string()),
6685
6590
  /** App names using this provider */
6686
- appNames: z17.array(z17.string()),
6591
+ appNames: z16.array(z16.string()),
6687
6592
  /** Scopes required by this provider */
6688
- scopes: z17.array(z17.string()),
6593
+ scopes: z16.array(z16.string()),
6689
6594
  /** Whether this is the primary/parent provider */
6690
- isPrimary: z17.boolean(),
6595
+ isPrimary: z16.boolean(),
6691
6596
  /** Whether this provider is optional (can be skipped) */
6692
- isOptional: z17.boolean().default(false)
6597
+ isOptional: z16.boolean().default(false)
6693
6598
  });
6694
- var federatedLoginStateSchema = z17.object({
6599
+ var federatedLoginStateSchema = z16.object({
6695
6600
  /** All available providers */
6696
- providers: z17.array(federatedProviderItemSchema),
6601
+ providers: z16.array(federatedProviderItemSchema),
6697
6602
  /** Primary provider ID (if any) */
6698
- primaryProviderId: z17.string().optional(),
6603
+ primaryProviderId: z16.string().optional(),
6699
6604
  /** Whether user can skip optional providers */
6700
- allowSkip: z17.boolean().default(true),
6605
+ allowSkip: z16.boolean().default(true),
6701
6606
  /** Pre-selected provider IDs (from previous session) */
6702
- preselectedProviders: z17.array(z17.string()).optional()
6607
+ preselectedProviders: z16.array(z16.string()).optional()
6703
6608
  });
6704
- var federatedSelectionSchema = z17.object({
6609
+ var federatedSelectionSchema = z16.object({
6705
6610
  /** Selected provider IDs */
6706
- selectedProviders: z17.array(z17.string()),
6611
+ selectedProviders: z16.array(z16.string()),
6707
6612
  /** Skipped provider IDs */
6708
- skippedProviders: z17.array(z17.string()),
6613
+ skippedProviders: z16.array(z16.string()),
6709
6614
  /** Provider-specific metadata */
6710
- providerMetadata: z17.record(z17.string(), z17.unknown()).optional()
6615
+ providerMetadata: z16.record(z16.string(), z16.unknown()).optional()
6711
6616
  });
6712
6617
 
6713
6618
  // 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()
6619
+ import { z as z17 } from "zod";
6620
+ var detectedAuthProviderSchema = z17.object({
6621
+ id: z17.string(),
6622
+ providerUrl: z17.string().optional(),
6623
+ mode: z17.enum(["public", "transparent", "local", "remote"]),
6624
+ appIds: z17.array(z17.string()),
6625
+ scopes: z17.array(z17.string()),
6626
+ isParentProvider: z17.boolean()
6722
6627
  });
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())
6628
+ var authProviderDetectionResultSchema = z17.object({
6629
+ providers: z17.map(z17.string(), detectedAuthProviderSchema),
6630
+ requiresOrchestration: z17.boolean(),
6631
+ parentProviderId: z17.string().optional(),
6632
+ childProviderIds: z17.array(z17.string()),
6633
+ uniqueProviderCount: z17.number(),
6634
+ validationErrors: z17.array(z17.string()),
6635
+ warnings: z17.array(z17.string())
6731
6636
  });
6732
6637
  function deriveProviderId(options) {
6733
6638
  if (isPublicMode(options)) {
6734
6639
  return options.issuer ?? "public";
6735
6640
  }
6736
6641
  if (isTransparentMode(options)) {
6737
- return options.remote.id ?? urlToProviderId(options.remote.provider);
6642
+ return options.providerConfig?.id ?? urlToProviderId(options.provider);
6738
6643
  }
6739
6644
  if (isOrchestratedMode(options)) {
6740
6645
  if (isOrchestratedRemote(options)) {
6741
- return options.remote.id ?? urlToProviderId(options.remote.provider);
6646
+ return options.providerConfig?.id ?? urlToProviderId(options.provider);
6742
6647
  }
6743
6648
  return options.local?.issuer ?? "local";
6744
6649
  }
@@ -6758,7 +6663,7 @@ function extractScopes(options) {
6758
6663
  }
6759
6664
  if (isOrchestratedMode(options)) {
6760
6665
  if (isOrchestratedRemote(options)) {
6761
- return options.remote.scopes || [];
6666
+ return options.scopes || [];
6762
6667
  }
6763
6668
  }
6764
6669
  return [];
@@ -6807,12 +6712,12 @@ function detectAuthProviders(parentAuth, apps) {
6807
6712
  const requiresOrchestration = hasMultipleProviders || hasChildOnlyProviders || childProviderIds.length > 0 && parentProviderId !== void 0;
6808
6713
  if (requiresOrchestration && parentAuth && isTransparentMode(parentAuth)) {
6809
6714
  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(", ")}`
6715
+ `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
6716
  );
6812
6717
  }
6813
6718
  if (uniqueProviderCount > 1 && parentAuth && isPublicMode(parentAuth)) {
6814
6719
  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.`
6720
+ `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
6721
  );
6817
6722
  }
6818
6723
  return {
@@ -6827,10 +6732,10 @@ function detectAuthProviders(parentAuth, apps) {
6827
6732
  }
6828
6733
  function getProviderUrl(options) {
6829
6734
  if (isTransparentMode(options)) {
6830
- return options.remote.provider;
6735
+ return options.provider;
6831
6736
  }
6832
6737
  if (isOrchestratedMode(options) && isOrchestratedRemote(options)) {
6833
- return options.remote.provider;
6738
+ return options.provider;
6834
6739
  }
6835
6740
  return void 0;
6836
6741
  }
@@ -7000,9 +6905,9 @@ function escapeQuotedString(value) {
7000
6905
  function unescapeQuotedString(value) {
7001
6906
  return value.replace(/\\(.)/g, "$1");
7002
6907
  }
7003
- function normalizePathSegment(path3) {
7004
- if (!path3 || path3 === "/") return "";
7005
- const normalized = path3.startsWith("/") ? path3 : `/${path3}`;
6908
+ function normalizePathSegment(path) {
6909
+ if (!path || path === "/") return "";
6910
+ const normalized = path.startsWith("/") ? path : `/${path}`;
7006
6911
  let end = normalized.length;
7007
6912
  while (end > 0 && normalized[end - 1] === "/") {
7008
6913
  end--;
@@ -7117,43 +7022,43 @@ var AudienceValidator = class _AudienceValidator {
7117
7022
  };
7118
7023
 
7119
7024
  // 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()
7025
+ import { z as z18 } from "zod";
7026
+ var credentialScopeSchema = z18.enum(["global", "user", "session"]);
7027
+ var loadingStrategySchema = z18.enum(["eager", "lazy"]);
7028
+ var getCredentialOptionsSchema = z18.object({
7029
+ forceRefresh: z18.boolean().optional(),
7030
+ scopes: z18.array(z18.string()).optional(),
7031
+ timeout: z18.number().positive().optional()
7127
7032
  }).strict();
7128
- var credentialProviderConfigSchema = z19.object({
7129
- name: z19.string().min(1),
7130
- description: z19.string().optional(),
7033
+ var credentialProviderConfigSchema = z18.object({
7034
+ name: z18.string().min(1),
7035
+ description: z18.string().optional(),
7131
7036
  scope: credentialScopeSchema,
7132
7037
  loading: loadingStrategySchema,
7133
- cacheTtl: z19.number().nonnegative().optional(),
7038
+ cacheTtl: z18.number().nonnegative().optional(),
7134
7039
  // 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()
7040
+ factory: z18.any(),
7041
+ refresh: z18.any().optional(),
7042
+ toHeaders: z18.any().optional(),
7043
+ metadata: z18.record(z18.string(), z18.unknown()).optional(),
7044
+ required: z18.boolean().optional()
7140
7045
  }).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()
7046
+ var authProviderMappingSchema = z18.union([
7047
+ z18.string(),
7048
+ z18.object({
7049
+ name: z18.string().min(1),
7050
+ required: z18.boolean().optional().default(true),
7051
+ scopes: z18.array(z18.string()).optional(),
7052
+ alias: z18.string().optional()
7148
7053
  }).strict()
7149
7054
  ]);
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()
7055
+ var authProvidersVaultOptionsSchema = z18.object({
7056
+ enabled: z18.boolean().optional(),
7057
+ useSharedStorage: z18.boolean().optional().default(true),
7058
+ namespace: z18.string().optional().default("authproviders:"),
7059
+ defaultCacheTtl: z18.number().nonnegative().optional().default(36e5),
7060
+ maxCredentialsPerSession: z18.number().positive().optional().default(100),
7061
+ providers: z18.array(credentialProviderConfigSchema).optional()
7157
7062
  }).strict();
7158
7063
 
7159
7064
  // libs/auth/src/vault/credential-helpers.ts
@@ -8132,7 +8037,6 @@ export {
8132
8037
  AuthProvidersVault,
8133
8038
  AuthorizationBase,
8134
8039
  CDN,
8135
- CimdCache,
8136
8040
  CimdClientIdMismatchError,
8137
8041
  CimdDisabledError,
8138
8042
  CimdError,
@@ -8154,6 +8058,7 @@ export {
8154
8058
  EncryptionKeyNotConfiguredError,
8155
8059
  InMemoryAuthorizationStore,
8156
8060
  InMemoryAuthorizationVault,
8061
+ InMemoryCimdCache,
8157
8062
  InMemoryFederatedAuthSessionStore,
8158
8063
  InMemoryOrchestratedTokenStore,
8159
8064
  InMemoryStoreRequiredError,
@@ -8249,7 +8154,6 @@ export {
8249
8154
  decryptSessionJson,
8250
8155
  decryptValue2 as decryptValue,
8251
8156
  defaultSessionRateLimiter,
8252
- deleteDevKey,
8253
8157
  deriveAuthorizationId,
8254
8158
  deriveExpectedAudience,
8255
8159
  deriveProviderId,
@@ -8271,6 +8175,7 @@ export {
8271
8175
  federatedLoginStateSchema,
8272
8176
  federatedProviderItemSchema,
8273
8177
  federatedSelectionSchema,
8178
+ flatRemoteProviderFields,
8274
8179
  fromSessionRecord,
8275
8180
  generatePkceChallenge,
8276
8181
  getCredentialOptionsSchema,
@@ -8284,12 +8189,13 @@ export {
8284
8189
  hkdfSha2563 as hkdfSha256,
8285
8190
  incrementalAuthConfigSchema,
8286
8191
  isCimdClientId,
8287
- isDevKeyPersistenceEnabled,
8288
8192
  isJwt,
8193
+ isLocalMode,
8289
8194
  isOrchestratedLocal,
8290
8195
  isOrchestratedMode,
8291
8196
  isOrchestratedRemote,
8292
8197
  isPublicMode,
8198
+ isRemoteMode,
8293
8199
  isSessionComplete,
8294
8200
  isSignedData as isSignedSession,
8295
8201
  isSoonExpiring,
@@ -8300,14 +8206,13 @@ export {
8300
8206
  jwkSchema,
8301
8207
  legacySseTransportStateSchema,
8302
8208
  llmSafeAuthContextSchema,
8303
- loadDevKey,
8304
8209
  loadingStrategySchema,
8210
+ localAuthSchema,
8305
8211
  localSigningConfigSchema,
8306
8212
  mtlsCredentialSchema,
8307
8213
  noopLogger,
8308
8214
  normalizeIssuer,
8309
8215
  oauthCredentialSchema,
8310
- orchestratedAuthOptionsSchema,
8311
8216
  orchestratedLocalSchema,
8312
8217
  orchestratedRemoteSchema,
8313
8218
  parseAuthOptions,
@@ -8318,16 +8223,16 @@ export {
8318
8223
  pkceOAuthCredentialSchema,
8319
8224
  privateKeyCredentialSchema,
8320
8225
  progressiveAuthStateSchema,
8226
+ providerConfigSchema,
8321
8227
  publicAccessConfigSchema,
8322
8228
  publicAuthOptionsSchema,
8323
8229
  redisConfigSchema,
8324
8230
  redisVaultEntrySchema,
8231
+ remoteAuthSchema,
8325
8232
  remoteProviderConfigSchema,
8326
8233
  renderToHtml,
8327
8234
  resetCachedKey,
8328
- resolveKeyPath,
8329
8235
  safeDecrypt,
8330
- saveDevKey,
8331
8236
  serviceAccountCredentialSchema,
8332
8237
  sessionIdPayloadSchema,
8333
8238
  sessionJwtPayloadSchema,