@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.
- package/cimd/cimd.cache.d.ts +0 -5
- package/cimd/cimd.cache.d.ts.map +1 -1
- package/cimd/index.d.ts +1 -2
- package/cimd/index.d.ts.map +1 -1
- package/consent/index.d.ts +2 -1
- package/consent/index.d.ts.map +1 -1
- package/detection/auth-provider-detection.d.ts +4 -2
- package/detection/auth-provider-detection.d.ts.map +1 -1
- package/esm/index.mjs +673 -768
- package/esm/package.json +4 -4
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +745 -858
- package/jwks/index.d.ts +1 -12
- package/jwks/index.d.ts.map +1 -1
- package/jwks/jwks.service.d.ts +1 -6
- package/jwks/jwks.service.d.ts.map +1 -1
- package/jwks/jwks.types.d.ts +0 -7
- package/jwks/jwks.types.d.ts.map +1 -1
- package/machine-id/machine-id.d.ts.map +1 -1
- package/options/app-auth.schema.d.ts +29 -37
- package/options/app-auth.schema.d.ts.map +1 -1
- package/options/index.d.ts +6 -6
- package/options/index.d.ts.map +1 -1
- package/options/interfaces.d.ts +72 -32
- package/options/interfaces.d.ts.map +1 -1
- package/options/orchestrated.schema.d.ts +54 -56
- package/options/orchestrated.schema.d.ts.map +1 -1
- package/options/schema.d.ts +30 -38
- package/options/schema.d.ts.map +1 -1
- package/options/shared.schemas.d.ts +61 -9
- package/options/shared.schemas.d.ts.map +1 -1
- package/options/transparent.schema.d.ts +15 -15
- package/options/typecheck.d.ts.map +1 -1
- package/options/utils.d.ts +16 -7
- package/options/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/session/session-crypto.d.ts.map +1 -1
- package/session/session.transport.d.ts +3 -4
- package/session/session.transport.d.ts.map +1 -1
- package/session/utils/session-crypto.utils.d.ts.map +1 -1
- package/jwks/dev-key-persistence.d.ts +0 -70
- 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
|
|
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 {
|
|
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 (
|
|
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(
|
|
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
|
|
1295
|
-
var pkceChallengeSchema =
|
|
1296
|
-
challenge:
|
|
1297
|
-
method:
|
|
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 =
|
|
1300
|
-
code:
|
|
1301
|
-
clientId:
|
|
1302
|
-
redirectUri:
|
|
1303
|
-
scopes:
|
|
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:
|
|
1306
|
-
userEmail:
|
|
1307
|
-
userName:
|
|
1308
|
-
state:
|
|
1309
|
-
createdAt:
|
|
1310
|
-
expiresAt:
|
|
1311
|
-
used:
|
|
1312
|
-
resource:
|
|
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:
|
|
1315
|
-
selectedProviderIds:
|
|
1316
|
-
skippedProviderIds:
|
|
1317
|
-
consentEnabled:
|
|
1318
|
-
federatedLoginUsed:
|
|
1319
|
-
pendingAuthId:
|
|
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
|
|
1573
|
-
var credentialTypeSchema =
|
|
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 =
|
|
1596
|
-
type:
|
|
1454
|
+
var oauthCredentialSchema = z2.object({
|
|
1455
|
+
type: z2.literal("oauth"),
|
|
1597
1456
|
/** Access token */
|
|
1598
|
-
accessToken:
|
|
1457
|
+
accessToken: z2.string(),
|
|
1599
1458
|
/** Refresh token (optional) */
|
|
1600
|
-
refreshToken:
|
|
1459
|
+
refreshToken: z2.string().optional(),
|
|
1601
1460
|
/** Token type (usually 'Bearer') */
|
|
1602
|
-
tokenType:
|
|
1461
|
+
tokenType: z2.string().default("Bearer"),
|
|
1603
1462
|
/** Token expiration timestamp (epoch ms) */
|
|
1604
|
-
expiresAt:
|
|
1463
|
+
expiresAt: z2.number().optional(),
|
|
1605
1464
|
/** Granted scopes */
|
|
1606
|
-
scopes:
|
|
1465
|
+
scopes: z2.array(z2.string()).default([]),
|
|
1607
1466
|
/** ID token for OIDC (optional) */
|
|
1608
|
-
idToken:
|
|
1467
|
+
idToken: z2.string().optional()
|
|
1609
1468
|
});
|
|
1610
|
-
var apiKeyCredentialSchema =
|
|
1611
|
-
type:
|
|
1469
|
+
var apiKeyCredentialSchema = z2.object({
|
|
1470
|
+
type: z2.literal("api_key"),
|
|
1612
1471
|
/** The API key value */
|
|
1613
|
-
key:
|
|
1472
|
+
key: z2.string().min(1),
|
|
1614
1473
|
/** Header name to use (e.g., 'X-API-Key', 'Authorization') */
|
|
1615
|
-
headerName:
|
|
1474
|
+
headerName: z2.string().default("X-API-Key"),
|
|
1616
1475
|
/** Prefix for the header value (e.g., 'Bearer ', 'Api-Key ') */
|
|
1617
|
-
headerPrefix:
|
|
1476
|
+
headerPrefix: z2.string().optional(),
|
|
1618
1477
|
/** Alternative: send as query parameter */
|
|
1619
|
-
queryParam:
|
|
1478
|
+
queryParam: z2.string().optional()
|
|
1620
1479
|
});
|
|
1621
|
-
var basicAuthCredentialSchema =
|
|
1622
|
-
type:
|
|
1480
|
+
var basicAuthCredentialSchema = z2.object({
|
|
1481
|
+
type: z2.literal("basic"),
|
|
1623
1482
|
/** Username */
|
|
1624
|
-
username:
|
|
1483
|
+
username: z2.string().min(1),
|
|
1625
1484
|
/** Password */
|
|
1626
|
-
password:
|
|
1485
|
+
password: z2.string(),
|
|
1627
1486
|
/** Pre-computed base64 encoded value (optional, for caching) */
|
|
1628
|
-
encodedValue:
|
|
1487
|
+
encodedValue: z2.string().optional()
|
|
1629
1488
|
});
|
|
1630
|
-
var bearerCredentialSchema =
|
|
1631
|
-
type:
|
|
1489
|
+
var bearerCredentialSchema = z2.object({
|
|
1490
|
+
type: z2.literal("bearer"),
|
|
1632
1491
|
/** The bearer token value */
|
|
1633
|
-
token:
|
|
1492
|
+
token: z2.string().min(1),
|
|
1634
1493
|
/** Token expiration (optional, for static tokens that expire) */
|
|
1635
|
-
expiresAt:
|
|
1494
|
+
expiresAt: z2.number().optional()
|
|
1636
1495
|
});
|
|
1637
|
-
var privateKeyCredentialSchema =
|
|
1638
|
-
type:
|
|
1496
|
+
var privateKeyCredentialSchema = z2.object({
|
|
1497
|
+
type: z2.literal("private_key"),
|
|
1639
1498
|
/** Key format */
|
|
1640
|
-
format:
|
|
1499
|
+
format: z2.enum(["pem", "jwk", "pkcs8", "pkcs12"]),
|
|
1641
1500
|
/** The key data (PEM string or JWK JSON) */
|
|
1642
|
-
keyData:
|
|
1501
|
+
keyData: z2.string(),
|
|
1643
1502
|
/** Key ID (for JWK) */
|
|
1644
|
-
keyId:
|
|
1503
|
+
keyId: z2.string().optional(),
|
|
1645
1504
|
/** Algorithm to use for signing */
|
|
1646
|
-
algorithm:
|
|
1505
|
+
algorithm: z2.string().optional(),
|
|
1647
1506
|
/** Passphrase if key is encrypted */
|
|
1648
|
-
passphrase:
|
|
1507
|
+
passphrase: z2.string().optional(),
|
|
1649
1508
|
/** Associated certificate (for mTLS) */
|
|
1650
|
-
certificate:
|
|
1509
|
+
certificate: z2.string().optional()
|
|
1651
1510
|
});
|
|
1652
|
-
var mtlsCredentialSchema =
|
|
1653
|
-
type:
|
|
1511
|
+
var mtlsCredentialSchema = z2.object({
|
|
1512
|
+
type: z2.literal("mtls"),
|
|
1654
1513
|
/** Client certificate (PEM format) */
|
|
1655
|
-
certificate:
|
|
1514
|
+
certificate: z2.string(),
|
|
1656
1515
|
/** Private key (PEM format) */
|
|
1657
|
-
privateKey:
|
|
1516
|
+
privateKey: z2.string(),
|
|
1658
1517
|
/** Passphrase if private key is encrypted */
|
|
1659
|
-
passphrase:
|
|
1518
|
+
passphrase: z2.string().optional(),
|
|
1660
1519
|
/** CA certificate chain (optional) */
|
|
1661
|
-
caCertificate:
|
|
1520
|
+
caCertificate: z2.string().optional()
|
|
1662
1521
|
});
|
|
1663
|
-
var customCredentialSchema =
|
|
1664
|
-
type:
|
|
1522
|
+
var customCredentialSchema = z2.object({
|
|
1523
|
+
type: z2.literal("custom"),
|
|
1665
1524
|
/** Custom type identifier */
|
|
1666
|
-
customType:
|
|
1525
|
+
customType: z2.string().min(1),
|
|
1667
1526
|
/** Arbitrary credential data */
|
|
1668
|
-
data:
|
|
1527
|
+
data: z2.record(z2.string(), z2.unknown()),
|
|
1669
1528
|
/** Headers to include in requests */
|
|
1670
|
-
headers:
|
|
1529
|
+
headers: z2.record(z2.string(), z2.string()).optional()
|
|
1671
1530
|
});
|
|
1672
|
-
var sshKeyCredentialSchema =
|
|
1673
|
-
type:
|
|
1531
|
+
var sshKeyCredentialSchema = z2.object({
|
|
1532
|
+
type: z2.literal("ssh_key"),
|
|
1674
1533
|
/** Private key (PEM format) */
|
|
1675
|
-
privateKey:
|
|
1534
|
+
privateKey: z2.string().min(1),
|
|
1676
1535
|
/** Public key (optional, can be derived from private key) */
|
|
1677
|
-
publicKey:
|
|
1536
|
+
publicKey: z2.string().optional(),
|
|
1678
1537
|
/** Passphrase if private key is encrypted */
|
|
1679
|
-
passphrase:
|
|
1538
|
+
passphrase: z2.string().optional(),
|
|
1680
1539
|
/** Key type */
|
|
1681
|
-
keyType:
|
|
1540
|
+
keyType: z2.enum(["rsa", "ed25519", "ecdsa", "dsa"]).default("ed25519"),
|
|
1682
1541
|
/** Key fingerprint (SHA256 hash) */
|
|
1683
|
-
fingerprint:
|
|
1542
|
+
fingerprint: z2.string().optional(),
|
|
1684
1543
|
/** Username for SSH connections */
|
|
1685
|
-
username:
|
|
1544
|
+
username: z2.string().optional()
|
|
1686
1545
|
});
|
|
1687
|
-
var serviceAccountCredentialSchema =
|
|
1688
|
-
type:
|
|
1546
|
+
var serviceAccountCredentialSchema = z2.object({
|
|
1547
|
+
type: z2.literal("service_account"),
|
|
1689
1548
|
/** Cloud provider */
|
|
1690
|
-
provider:
|
|
1549
|
+
provider: z2.enum(["gcp", "aws", "azure", "custom"]),
|
|
1691
1550
|
/** Raw credentials (JSON key file content, access keys, etc.) */
|
|
1692
|
-
credentials:
|
|
1551
|
+
credentials: z2.record(z2.string(), z2.unknown()),
|
|
1693
1552
|
/** Project/Account ID */
|
|
1694
|
-
projectId:
|
|
1553
|
+
projectId: z2.string().optional(),
|
|
1695
1554
|
/** Region for regional services */
|
|
1696
|
-
region:
|
|
1555
|
+
region: z2.string().optional(),
|
|
1697
1556
|
/** AWS: Role ARN to assume */
|
|
1698
|
-
assumeRoleArn:
|
|
1557
|
+
assumeRoleArn: z2.string().optional(),
|
|
1699
1558
|
/** AWS: External ID for cross-account access */
|
|
1700
|
-
externalId:
|
|
1559
|
+
externalId: z2.string().optional(),
|
|
1701
1560
|
/** Service account email (GCP) or ARN (AWS) */
|
|
1702
|
-
serviceAccountId:
|
|
1561
|
+
serviceAccountId: z2.string().optional(),
|
|
1703
1562
|
/** Expiration timestamp for temporary credentials */
|
|
1704
|
-
expiresAt:
|
|
1563
|
+
expiresAt: z2.number().optional()
|
|
1705
1564
|
});
|
|
1706
|
-
var pkceOAuthCredentialSchema =
|
|
1707
|
-
type:
|
|
1565
|
+
var pkceOAuthCredentialSchema = z2.object({
|
|
1566
|
+
type: z2.literal("oauth_pkce"),
|
|
1708
1567
|
/** Access token */
|
|
1709
|
-
accessToken:
|
|
1568
|
+
accessToken: z2.string(),
|
|
1710
1569
|
/** Refresh token (optional) */
|
|
1711
|
-
refreshToken:
|
|
1570
|
+
refreshToken: z2.string().optional(),
|
|
1712
1571
|
/** Token type (usually 'Bearer') */
|
|
1713
|
-
tokenType:
|
|
1572
|
+
tokenType: z2.string().default("Bearer"),
|
|
1714
1573
|
/** Token expiration timestamp (epoch ms) */
|
|
1715
|
-
expiresAt:
|
|
1574
|
+
expiresAt: z2.number().optional(),
|
|
1716
1575
|
/** Granted scopes */
|
|
1717
|
-
scopes:
|
|
1576
|
+
scopes: z2.array(z2.string()).default([]),
|
|
1718
1577
|
/** ID token for OIDC (optional) */
|
|
1719
|
-
idToken:
|
|
1578
|
+
idToken: z2.string().optional(),
|
|
1720
1579
|
/** Authorization server issuer */
|
|
1721
|
-
issuer:
|
|
1580
|
+
issuer: z2.string().optional()
|
|
1722
1581
|
});
|
|
1723
|
-
var credentialSchema =
|
|
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 =
|
|
1594
|
+
var appCredentialSchema = z2.object({
|
|
1736
1595
|
/** App ID this credential belongs to */
|
|
1737
|
-
appId:
|
|
1596
|
+
appId: z2.string().min(1),
|
|
1738
1597
|
/** Provider ID within the app (for apps with multiple auth providers) */
|
|
1739
|
-
providerId:
|
|
1598
|
+
providerId: z2.string().min(1),
|
|
1740
1599
|
/** The credential data */
|
|
1741
1600
|
credential: credentialSchema,
|
|
1742
1601
|
/** Timestamp when credential was acquired */
|
|
1743
|
-
acquiredAt:
|
|
1602
|
+
acquiredAt: z2.number(),
|
|
1744
1603
|
/** Timestamp when credential was last used */
|
|
1745
|
-
lastUsedAt:
|
|
1604
|
+
lastUsedAt: z2.number().optional(),
|
|
1746
1605
|
/** Credential expiration (if applicable) */
|
|
1747
|
-
expiresAt:
|
|
1606
|
+
expiresAt: z2.number().optional(),
|
|
1748
1607
|
/** Whether this credential is currently valid */
|
|
1749
|
-
isValid:
|
|
1608
|
+
isValid: z2.boolean().default(true),
|
|
1750
1609
|
/** Error message if credential is invalid */
|
|
1751
|
-
invalidReason:
|
|
1610
|
+
invalidReason: z2.string().optional(),
|
|
1752
1611
|
/** User info associated with this credential */
|
|
1753
|
-
userInfo:
|
|
1754
|
-
sub:
|
|
1755
|
-
email:
|
|
1756
|
-
name:
|
|
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:
|
|
1618
|
+
metadata: z2.record(z2.string(), z2.unknown()).optional()
|
|
1760
1619
|
});
|
|
1761
|
-
var vaultConsentRecordSchema =
|
|
1620
|
+
var vaultConsentRecordSchema = z2.object({
|
|
1762
1621
|
/** Whether consent was enabled */
|
|
1763
|
-
enabled:
|
|
1622
|
+
enabled: z2.boolean(),
|
|
1764
1623
|
/** Selected tool IDs (user approved these) */
|
|
1765
|
-
selectedToolIds:
|
|
1624
|
+
selectedToolIds: z2.array(z2.string()),
|
|
1766
1625
|
/** Available tool IDs at time of consent */
|
|
1767
|
-
availableToolIds:
|
|
1626
|
+
availableToolIds: z2.array(z2.string()),
|
|
1768
1627
|
/** Timestamp when consent was given */
|
|
1769
|
-
consentedAt:
|
|
1628
|
+
consentedAt: z2.number(),
|
|
1770
1629
|
/** Consent version for tracking changes */
|
|
1771
|
-
version:
|
|
1630
|
+
version: z2.string().default("1.0")
|
|
1772
1631
|
});
|
|
1773
|
-
var vaultFederatedRecordSchema =
|
|
1632
|
+
var vaultFederatedRecordSchema = z2.object({
|
|
1774
1633
|
/** Provider IDs that were selected */
|
|
1775
|
-
selectedProviderIds:
|
|
1634
|
+
selectedProviderIds: z2.array(z2.string()),
|
|
1776
1635
|
/** Provider IDs that were skipped (can be authorized later) */
|
|
1777
|
-
skippedProviderIds:
|
|
1636
|
+
skippedProviderIds: z2.array(z2.string()),
|
|
1778
1637
|
/** Primary provider ID */
|
|
1779
|
-
primaryProviderId:
|
|
1638
|
+
primaryProviderId: z2.string().optional(),
|
|
1780
1639
|
/** Timestamp when federated login was completed */
|
|
1781
|
-
completedAt:
|
|
1640
|
+
completedAt: z2.number()
|
|
1782
1641
|
});
|
|
1783
|
-
var pendingIncrementalAuthSchema =
|
|
1642
|
+
var pendingIncrementalAuthSchema = z2.object({
|
|
1784
1643
|
/** Unique ID for this request */
|
|
1785
|
-
id:
|
|
1644
|
+
id: z2.string(),
|
|
1786
1645
|
/** App ID being authorized */
|
|
1787
|
-
appId:
|
|
1646
|
+
appId: z2.string(),
|
|
1788
1647
|
/** Tool ID that triggered the auth request */
|
|
1789
|
-
toolId:
|
|
1648
|
+
toolId: z2.string().optional(),
|
|
1790
1649
|
/** Authorization URL */
|
|
1791
|
-
authUrl:
|
|
1650
|
+
authUrl: z2.string(),
|
|
1792
1651
|
/** Required scopes */
|
|
1793
|
-
requiredScopes:
|
|
1652
|
+
requiredScopes: z2.array(z2.string()).optional(),
|
|
1794
1653
|
/** Whether elicit is being used */
|
|
1795
|
-
elicitId:
|
|
1654
|
+
elicitId: z2.string().optional(),
|
|
1796
1655
|
/** Timestamp when request was created */
|
|
1797
|
-
createdAt:
|
|
1656
|
+
createdAt: z2.number(),
|
|
1798
1657
|
/** Expiration timestamp */
|
|
1799
|
-
expiresAt:
|
|
1658
|
+
expiresAt: z2.number(),
|
|
1800
1659
|
/** Status of the request */
|
|
1801
|
-
status:
|
|
1660
|
+
status: z2.enum(["pending", "completed", "cancelled", "expired"])
|
|
1802
1661
|
});
|
|
1803
|
-
var authorizationVaultEntrySchema =
|
|
1662
|
+
var authorizationVaultEntrySchema = z2.object({
|
|
1804
1663
|
/** Vault ID (maps to access token jti claim) */
|
|
1805
|
-
id:
|
|
1664
|
+
id: z2.string(),
|
|
1806
1665
|
/** User subject identifier */
|
|
1807
|
-
userSub:
|
|
1666
|
+
userSub: z2.string(),
|
|
1808
1667
|
/** User email */
|
|
1809
|
-
userEmail:
|
|
1668
|
+
userEmail: z2.string().optional(),
|
|
1810
1669
|
/** User name */
|
|
1811
|
-
userName:
|
|
1670
|
+
userName: z2.string().optional(),
|
|
1812
1671
|
/** Client ID that created this session */
|
|
1813
|
-
clientId:
|
|
1672
|
+
clientId: z2.string(),
|
|
1814
1673
|
/** Creation timestamp */
|
|
1815
|
-
createdAt:
|
|
1674
|
+
createdAt: z2.number(),
|
|
1816
1675
|
/** Last access timestamp */
|
|
1817
|
-
lastAccessAt:
|
|
1676
|
+
lastAccessAt: z2.number(),
|
|
1818
1677
|
/** App credentials (keyed by `${appId}:${providerId}`) */
|
|
1819
|
-
appCredentials:
|
|
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:
|
|
1684
|
+
pendingAuths: z2.array(pendingIncrementalAuthSchema),
|
|
1826
1685
|
/** Apps that are fully authorized */
|
|
1827
|
-
authorizedAppIds:
|
|
1686
|
+
authorizedAppIds: z2.array(z2.string()),
|
|
1828
1687
|
/** Apps that were skipped (not yet authorized) */
|
|
1829
|
-
skippedAppIds:
|
|
1688
|
+
skippedAppIds: z2.array(z2.string())
|
|
1830
1689
|
});
|
|
1831
1690
|
|
|
1832
1691
|
// libs/auth/src/session/vault-encryption.ts
|
|
1833
|
-
import { z as
|
|
1692
|
+
import { z as z3 } from "zod";
|
|
1834
1693
|
import {
|
|
1835
1694
|
hkdfSha256,
|
|
1836
1695
|
encryptAesGcm,
|
|
1837
1696
|
decryptAesGcm,
|
|
1838
|
-
randomBytes as
|
|
1697
|
+
randomBytes as randomBytes2,
|
|
1839
1698
|
base64urlEncode,
|
|
1840
1699
|
base64urlDecode
|
|
1841
1700
|
} from "@frontmcp/utils";
|
|
1842
|
-
var encryptedDataSchema =
|
|
1701
|
+
var encryptedDataSchema = z3.object({
|
|
1843
1702
|
/** Version for future algorithm changes */
|
|
1844
|
-
v:
|
|
1703
|
+
v: z3.literal(1),
|
|
1845
1704
|
/** Algorithm identifier */
|
|
1846
|
-
alg:
|
|
1705
|
+
alg: z3.literal("aes-256-gcm"),
|
|
1847
1706
|
/** Initialization vector (base64) */
|
|
1848
|
-
iv:
|
|
1707
|
+
iv: z3.string(),
|
|
1849
1708
|
/** Ciphertext (base64) */
|
|
1850
|
-
ct:
|
|
1709
|
+
ct: z3.string(),
|
|
1851
1710
|
/** Authentication tag (base64) */
|
|
1852
|
-
tag:
|
|
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 =
|
|
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 =
|
|
1849
|
+
var encryptedVaultEntrySchema = z3.object({
|
|
1991
1850
|
/** Vault ID (maps to JWT jti claim) */
|
|
1992
|
-
id:
|
|
1851
|
+
id: z3.string(),
|
|
1993
1852
|
/** User subject identifier */
|
|
1994
|
-
userSub:
|
|
1853
|
+
userSub: z3.string(),
|
|
1995
1854
|
/** User email (unencrypted for display) */
|
|
1996
|
-
userEmail:
|
|
1855
|
+
userEmail: z3.string().optional(),
|
|
1997
1856
|
/** User name (unencrypted for display) */
|
|
1998
|
-
userName:
|
|
1857
|
+
userName: z3.string().optional(),
|
|
1999
1858
|
/** Client ID that created this session */
|
|
2000
|
-
clientId:
|
|
1859
|
+
clientId: z3.string(),
|
|
2001
1860
|
/** Creation timestamp */
|
|
2002
|
-
createdAt:
|
|
1861
|
+
createdAt: z3.number(),
|
|
2003
1862
|
/** Last access timestamp */
|
|
2004
|
-
lastAccessAt:
|
|
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:
|
|
1867
|
+
authorizedAppIds: z3.array(z3.string()),
|
|
2009
1868
|
/** Apps that were skipped (unencrypted for quick lookup) */
|
|
2010
|
-
skippedAppIds:
|
|
1869
|
+
skippedAppIds: z3.array(z3.string()),
|
|
2011
1870
|
/** Pending auth IDs (unencrypted for lookup, actual URLs encrypted) */
|
|
2012
|
-
pendingAuthIds:
|
|
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
|
|
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 =
|
|
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
|
|
2085
|
-
var transportProtocolSchema =
|
|
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 =
|
|
2093
|
-
type:
|
|
2094
|
-
lastEventId:
|
|
2095
|
-
lastPing:
|
|
2096
|
-
connectionState:
|
|
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 =
|
|
2099
|
-
type:
|
|
2100
|
-
requestSeq:
|
|
2101
|
-
activeStreamId:
|
|
2102
|
-
pendingRequests:
|
|
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 =
|
|
2105
|
-
type:
|
|
2106
|
-
requestSeq:
|
|
2107
|
-
pendingResponses:
|
|
2108
|
-
lastActivity:
|
|
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 =
|
|
2111
|
-
type:
|
|
2112
|
-
requestCount:
|
|
2113
|
-
windowStart:
|
|
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 =
|
|
2116
|
-
type:
|
|
2117
|
-
messagePath:
|
|
2118
|
-
lastEventId:
|
|
2119
|
-
connectionState:
|
|
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 =
|
|
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 =
|
|
2129
|
-
id:
|
|
2130
|
-
authorizationId:
|
|
1987
|
+
var transportSessionSchema = z4.object({
|
|
1988
|
+
id: z4.string(),
|
|
1989
|
+
authorizationId: z4.string(),
|
|
2131
1990
|
protocol: transportProtocolSchema,
|
|
2132
|
-
createdAt:
|
|
2133
|
-
expiresAt:
|
|
2134
|
-
nodeId:
|
|
2135
|
-
clientFingerprint:
|
|
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 =
|
|
2139
|
-
sid:
|
|
2140
|
-
aid:
|
|
1997
|
+
var sessionJwtPayloadSchema = z4.object({
|
|
1998
|
+
sid: z4.string(),
|
|
1999
|
+
aid: z4.string(),
|
|
2141
2000
|
proto: transportProtocolSchema,
|
|
2142
|
-
nid:
|
|
2143
|
-
iat:
|
|
2144
|
-
exp:
|
|
2001
|
+
nid: z4.string(),
|
|
2002
|
+
iat: z4.number(),
|
|
2003
|
+
exp: z4.number().optional()
|
|
2145
2004
|
});
|
|
2146
|
-
var encryptedBlobSchema =
|
|
2147
|
-
alg:
|
|
2148
|
-
kid:
|
|
2149
|
-
iv:
|
|
2150
|
-
tag:
|
|
2151
|
-
data:
|
|
2152
|
-
exp:
|
|
2153
|
-
meta:
|
|
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 =
|
|
2014
|
+
var storedSessionSchema = z4.object({
|
|
2156
2015
|
session: transportSessionSchema,
|
|
2157
|
-
authorizationId:
|
|
2158
|
-
tokens:
|
|
2159
|
-
createdAt:
|
|
2160
|
-
lastAccessedAt:
|
|
2161
|
-
initialized:
|
|
2162
|
-
maxLifetimeAt:
|
|
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 =
|
|
2165
|
-
host:
|
|
2166
|
-
port:
|
|
2167
|
-
password:
|
|
2168
|
-
db:
|
|
2169
|
-
tls:
|
|
2170
|
-
keyPrefix:
|
|
2171
|
-
defaultTtlMs:
|
|
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
|
|
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(
|
|
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 ||
|
|
2190
|
+
const secret = config?.secret || getEnv("MCP_SESSION_SECRET");
|
|
2330
2191
|
if (!secret) {
|
|
2331
|
-
if (
|
|
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
|
-
*
|
|
2333
|
+
* Generates JWT-style IDs for distributed session support.
|
|
2473
2334
|
*
|
|
2474
|
-
* @
|
|
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(
|
|
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
|
|
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
|
-
|
|
2434
|
+
if (isBrowser()) return false;
|
|
2435
|
+
return !isProduction3();
|
|
2576
2436
|
}
|
|
2577
2437
|
function resolveMachineIdPath() {
|
|
2578
|
-
|
|
2579
|
-
|
|
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
|
|
2467
|
+
const path = __require("path");
|
|
2468
|
+
const dir = path.dirname(machineIdPath);
|
|
2606
2469
|
(async () => {
|
|
2607
2470
|
try {
|
|
2608
|
-
await
|
|
2609
|
-
await
|
|
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 =
|
|
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 =
|
|
2641
|
-
const nodeEnv = process.env["NODE_ENV"];
|
|
2503
|
+
const secret = getEnv3("MCP_SESSION_SECRET");
|
|
2642
2504
|
if (!secret) {
|
|
2643
|
-
if (
|
|
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
|
|
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 =
|
|
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
|
|
3854
|
+
import { z as z5 } from "zod";
|
|
3993
3855
|
import { randomUUID as randomUUID9 } from "@frontmcp/utils";
|
|
3994
|
-
import { AsyncLocalStorage } from "
|
|
3995
|
-
var redisVaultEntrySchema =
|
|
3856
|
+
import { AsyncLocalStorage } from "@frontmcp/utils";
|
|
3857
|
+
var redisVaultEntrySchema = z5.object({
|
|
3996
3858
|
/** Vault ID */
|
|
3997
|
-
id:
|
|
3859
|
+
id: z5.string(),
|
|
3998
3860
|
/** User sub (for lookup) */
|
|
3999
|
-
userSub:
|
|
3861
|
+
userSub: z5.string(),
|
|
4000
3862
|
/** User email (optional, for display) */
|
|
4001
|
-
userEmail:
|
|
3863
|
+
userEmail: z5.string().optional(),
|
|
4002
3864
|
/** User name (optional, for display) */
|
|
4003
|
-
userName:
|
|
3865
|
+
userName: z5.string().optional(),
|
|
4004
3866
|
/** Client ID */
|
|
4005
|
-
clientId:
|
|
3867
|
+
clientId: z5.string(),
|
|
4006
3868
|
/** Creation timestamp */
|
|
4007
|
-
createdAt:
|
|
3869
|
+
createdAt: z5.number(),
|
|
4008
3870
|
/** Last access timestamp */
|
|
4009
|
-
lastAccessAt:
|
|
3871
|
+
lastAccessAt: z5.number(),
|
|
4010
3872
|
/** Authorized app IDs (unencrypted for quick auth checks) */
|
|
4011
|
-
authorizedAppIds:
|
|
3873
|
+
authorizedAppIds: z5.array(z5.string()),
|
|
4012
3874
|
/** Skipped app IDs (unencrypted for quick checks) */
|
|
4013
|
-
skippedAppIds:
|
|
3875
|
+
skippedAppIds: z5.array(z5.string()),
|
|
4014
3876
|
/** Pending auth request IDs (unencrypted for lookup) */
|
|
4015
|
-
pendingAuthIds:
|
|
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
|
|
4421
|
-
var authModeSchema =
|
|
4422
|
-
var authUserSchema =
|
|
4423
|
-
sub:
|
|
4424
|
-
name:
|
|
4425
|
-
email:
|
|
4426
|
-
picture:
|
|
4427
|
-
anonymous:
|
|
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 =
|
|
4430
|
-
executionPath:
|
|
4431
|
-
scopes:
|
|
4432
|
-
details:
|
|
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 =
|
|
4435
|
-
executionPath:
|
|
4436
|
-
scopes:
|
|
4437
|
-
details:
|
|
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 =
|
|
4440
|
-
authorizationId:
|
|
4441
|
-
sessionId:
|
|
4301
|
+
var llmSafeAuthContextSchema = z6.object({
|
|
4302
|
+
authorizationId: z6.string(),
|
|
4303
|
+
sessionId: z6.string(),
|
|
4442
4304
|
mode: authModeSchema,
|
|
4443
|
-
isAnonymous:
|
|
4444
|
-
user:
|
|
4445
|
-
sub:
|
|
4446
|
-
name:
|
|
4305
|
+
isAnonymous: z6.boolean(),
|
|
4306
|
+
user: z6.object({
|
|
4307
|
+
sub: z6.string(),
|
|
4308
|
+
name: z6.string().optional()
|
|
4447
4309
|
}),
|
|
4448
|
-
scopes:
|
|
4449
|
-
authorizedToolIds:
|
|
4450
|
-
authorizedPromptIds:
|
|
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 =
|
|
4459
|
-
var appAuthorizationRecordSchema =
|
|
4460
|
-
appId:
|
|
4320
|
+
var appAuthStateSchema = z6.nativeEnum(AppAuthState);
|
|
4321
|
+
var appAuthorizationRecordSchema = z6.object({
|
|
4322
|
+
appId: z6.string(),
|
|
4461
4323
|
state: appAuthStateSchema,
|
|
4462
|
-
stateChangedAt:
|
|
4463
|
-
grantedScopes:
|
|
4464
|
-
authProviderId:
|
|
4465
|
-
toolIds:
|
|
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 =
|
|
4468
|
-
apps:
|
|
4469
|
-
initiallyAuthorized:
|
|
4470
|
-
initiallySkipped:
|
|
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
|
|
5330
|
-
var jwkParametersSchema =
|
|
5331
|
-
kty:
|
|
5332
|
-
alg:
|
|
5333
|
-
key_ops:
|
|
5334
|
-
ext:
|
|
5335
|
-
use:
|
|
5336
|
-
x5c:
|
|
5337
|
-
x5t:
|
|
5338
|
-
"x5t#S256":
|
|
5339
|
-
x5u:
|
|
5340
|
-
kid:
|
|
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:
|
|
5344
|
-
d:
|
|
5345
|
-
dp:
|
|
5346
|
-
dq:
|
|
5347
|
-
e:
|
|
5348
|
-
k:
|
|
5349
|
-
n:
|
|
5350
|
-
p:
|
|
5351
|
-
q:
|
|
5352
|
-
qi:
|
|
5353
|
-
x:
|
|
5354
|
-
y:
|
|
5355
|
-
pub:
|
|
5356
|
-
priv:
|
|
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 =
|
|
5359
|
-
keys:
|
|
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
|
|
5364
|
-
var aiPlatformTypeSchema =
|
|
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 =
|
|
5376
|
-
iss:
|
|
5377
|
-
sid:
|
|
5378
|
-
sub:
|
|
5379
|
-
exp:
|
|
5380
|
-
iat:
|
|
5381
|
-
aud:
|
|
5382
|
-
email:
|
|
5383
|
-
username:
|
|
5384
|
-
preferred_username:
|
|
5385
|
-
name:
|
|
5386
|
-
picture:
|
|
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 =
|
|
5389
|
-
nodeId:
|
|
5390
|
-
authSig:
|
|
5391
|
-
uuid:
|
|
5392
|
-
iat:
|
|
5393
|
-
protocol:
|
|
5394
|
-
isPublic:
|
|
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:
|
|
5397
|
-
clientVersion:
|
|
5398
|
-
supportsElicitation:
|
|
5399
|
-
skillsOnlyMode:
|
|
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 =
|
|
5402
|
-
id:
|
|
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 =
|
|
5407
|
-
token:
|
|
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
|
|
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
|
|
5430
|
-
var clientMetadataDocumentSchema =
|
|
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:
|
|
5297
|
+
client_id: z9.string().url(),
|
|
5436
5298
|
/**
|
|
5437
5299
|
* Human-readable name of the client.
|
|
5438
5300
|
*/
|
|
5439
|
-
client_name:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
5326
|
+
client_uri: z9.string().url().optional(),
|
|
5465
5327
|
/**
|
|
5466
5328
|
* URL of the client's logo image.
|
|
5467
5329
|
*/
|
|
5468
|
-
logo_uri:
|
|
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:
|
|
5334
|
+
jwks_uri: z9.string().url().optional(),
|
|
5473
5335
|
/**
|
|
5474
5336
|
* Inline JWKS (for private_key_jwt).
|
|
5475
5337
|
*/
|
|
5476
|
-
jwks:
|
|
5477
|
-
keys:
|
|
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:
|
|
5344
|
+
tos_uri: z9.string().url().optional(),
|
|
5483
5345
|
/**
|
|
5484
5346
|
* URL of the client's privacy policy.
|
|
5485
5347
|
*/
|
|
5486
|
-
policy_uri:
|
|
5348
|
+
policy_uri: z9.string().url().optional(),
|
|
5487
5349
|
/**
|
|
5488
5350
|
* Requested OAuth scopes.
|
|
5489
5351
|
*/
|
|
5490
|
-
scope:
|
|
5352
|
+
scope: z9.string().optional(),
|
|
5491
5353
|
/**
|
|
5492
5354
|
* Array of contact emails for the client.
|
|
5493
5355
|
*/
|
|
5494
|
-
contacts:
|
|
5356
|
+
contacts: z9.array(z9.string().email()).optional(),
|
|
5495
5357
|
/**
|
|
5496
5358
|
* Software statement (signed JWT).
|
|
5497
5359
|
*/
|
|
5498
|
-
software_statement:
|
|
5360
|
+
software_statement: z9.string().optional(),
|
|
5499
5361
|
/**
|
|
5500
5362
|
* Unique identifier for the client software.
|
|
5501
5363
|
*/
|
|
5502
|
-
software_id:
|
|
5364
|
+
software_id: z9.string().optional(),
|
|
5503
5365
|
/**
|
|
5504
5366
|
* Version of the client software.
|
|
5505
5367
|
*/
|
|
5506
|
-
software_version:
|
|
5368
|
+
software_version: z9.string().optional()
|
|
5507
5369
|
});
|
|
5508
|
-
var cimdRedisCacheConfigSchema =
|
|
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:
|
|
5375
|
+
url: z9.string().optional(),
|
|
5514
5376
|
/**
|
|
5515
5377
|
* Redis host.
|
|
5516
5378
|
*/
|
|
5517
|
-
host:
|
|
5379
|
+
host: z9.string().optional(),
|
|
5518
5380
|
/**
|
|
5519
5381
|
* Redis port.
|
|
5520
5382
|
* @default 6379
|
|
5521
5383
|
*/
|
|
5522
|
-
port:
|
|
5384
|
+
port: z9.number().optional(),
|
|
5523
5385
|
/**
|
|
5524
5386
|
* Redis password.
|
|
5525
5387
|
*/
|
|
5526
|
-
password:
|
|
5388
|
+
password: z9.string().optional(),
|
|
5527
5389
|
/**
|
|
5528
5390
|
* Redis database number.
|
|
5529
5391
|
* @default 0
|
|
5530
5392
|
*/
|
|
5531
|
-
db:
|
|
5393
|
+
db: z9.number().optional(),
|
|
5532
5394
|
/**
|
|
5533
5395
|
* Enable TLS for Redis connection.
|
|
5534
5396
|
* @default false
|
|
5535
5397
|
*/
|
|
5536
|
-
tls:
|
|
5398
|
+
tls: z9.boolean().optional(),
|
|
5537
5399
|
/**
|
|
5538
5400
|
* Key prefix for CIMD cache entries.
|
|
5539
5401
|
* @default 'cimd:'
|
|
5540
5402
|
*/
|
|
5541
|
-
keyPrefix:
|
|
5403
|
+
keyPrefix: z9.string().default("cimd:")
|
|
5542
5404
|
});
|
|
5543
|
-
var cimdCacheConfigSchema =
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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 =
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
5464
|
+
allowInsecureForTesting: z9.boolean().default(false)
|
|
5603
5465
|
});
|
|
5604
|
-
var cimdNetworkConfigSchema =
|
|
5466
|
+
var cimdNetworkConfigSchema = z9.object({
|
|
5605
5467
|
/**
|
|
5606
5468
|
* Request timeout in milliseconds.
|
|
5607
5469
|
* @default 5000 (5 seconds)
|
|
5608
5470
|
*/
|
|
5609
|
-
timeoutMs:
|
|
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:
|
|
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:
|
|
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:
|
|
5489
|
+
maxRedirects: z9.number().int().min(0).default(5)
|
|
5628
5490
|
});
|
|
5629
|
-
var cimdConfigSchema =
|
|
5491
|
+
var cimdConfigSchema = z9.object({
|
|
5630
5492
|
/**
|
|
5631
5493
|
* Enable CIMD support.
|
|
5632
5494
|
* @default true
|
|
5633
5495
|
*/
|
|
5634
|
-
enabled:
|
|
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
|
|
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
|
|
6266
|
-
return `${
|
|
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 =
|
|
6150
|
+
var publicAccessConfigSchema = z10.object({
|
|
6289
6151
|
/**
|
|
6290
6152
|
* Allow all tools or explicit whitelist
|
|
6291
6153
|
* @default 'all'
|
|
6292
6154
|
*/
|
|
6293
|
-
tools:
|
|
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:
|
|
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:
|
|
6165
|
+
rateLimit: z10.number().default(60)
|
|
6304
6166
|
});
|
|
6305
|
-
var localSigningConfigSchema =
|
|
6167
|
+
var localSigningConfigSchema = z10.object({
|
|
6306
6168
|
/**
|
|
6307
|
-
* Private key for signing
|
|
6169
|
+
* Private key for signing tokens
|
|
6308
6170
|
* @default auto-generated
|
|
6309
6171
|
*/
|
|
6310
|
-
signKey: jwkSchema.or(
|
|
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
|
|
6179
|
+
* Issuer identifier for tokens
|
|
6318
6180
|
* @default auto-derived from server URL
|
|
6319
6181
|
*/
|
|
6320
|
-
issuer:
|
|
6182
|
+
issuer: z10.string().optional()
|
|
6321
6183
|
});
|
|
6322
|
-
var
|
|
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:
|
|
6218
|
+
provider: z10.string().url(),
|
|
6328
6219
|
/**
|
|
6329
6220
|
* Provider display name
|
|
6330
6221
|
*/
|
|
6331
|
-
name:
|
|
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:
|
|
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:
|
|
6236
|
+
jwksUri: z10.string().url().optional(),
|
|
6346
6237
|
/**
|
|
6347
|
-
* Client ID for this MCP server
|
|
6238
|
+
* Client ID for this MCP server
|
|
6348
6239
|
*/
|
|
6349
|
-
clientId:
|
|
6240
|
+
clientId: z10.string().optional(),
|
|
6350
6241
|
/**
|
|
6351
|
-
* Client secret (for confidential clients
|
|
6242
|
+
* Client secret (for confidential clients)
|
|
6352
6243
|
*/
|
|
6353
|
-
clientSecret:
|
|
6244
|
+
clientSecret: z10.string().optional(),
|
|
6354
6245
|
/**
|
|
6355
6246
|
* Scopes to request from the upstream provider
|
|
6356
6247
|
*/
|
|
6357
|
-
scopes:
|
|
6248
|
+
scopes: z10.array(z10.string()).optional(),
|
|
6358
6249
|
/**
|
|
6359
6250
|
* Enable Dynamic Client Registration (DCR)
|
|
6360
6251
|
* @default false
|
|
6361
6252
|
*/
|
|
6362
|
-
dcrEnabled:
|
|
6253
|
+
dcrEnabled: z10.boolean().default(false),
|
|
6363
6254
|
/**
|
|
6364
6255
|
* Authorization endpoint override
|
|
6365
6256
|
*/
|
|
6366
|
-
authEndpoint:
|
|
6257
|
+
authEndpoint: z10.string().url().optional(),
|
|
6367
6258
|
/**
|
|
6368
6259
|
* Token endpoint override
|
|
6369
6260
|
*/
|
|
6370
|
-
tokenEndpoint:
|
|
6261
|
+
tokenEndpoint: z10.string().url().optional(),
|
|
6371
6262
|
/**
|
|
6372
6263
|
* Registration endpoint override (for DCR)
|
|
6373
6264
|
*/
|
|
6374
|
-
registrationEndpoint:
|
|
6265
|
+
registrationEndpoint: z10.string().url().optional(),
|
|
6375
6266
|
/**
|
|
6376
6267
|
* User info endpoint override
|
|
6377
6268
|
*/
|
|
6378
|
-
userInfoEndpoint:
|
|
6269
|
+
userInfoEndpoint: z10.string().url().optional()
|
|
6379
6270
|
});
|
|
6380
|
-
var
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
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:
|
|
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:
|
|
6297
|
+
skewSeconds: z10.number().default(60)
|
|
6395
6298
|
});
|
|
6396
|
-
var skippedAppBehaviorSchema =
|
|
6397
|
-
var consentConfigSchema =
|
|
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:
|
|
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:
|
|
6311
|
+
groupByApp: z10.boolean().default(true),
|
|
6409
6312
|
/**
|
|
6410
6313
|
* Show tool descriptions in consent UI
|
|
6411
6314
|
* @default true
|
|
6412
6315
|
*/
|
|
6413
|
-
showDescriptions:
|
|
6316
|
+
showDescriptions: z10.boolean().default(true),
|
|
6414
6317
|
/**
|
|
6415
6318
|
* Allow selecting all tools at once
|
|
6416
6319
|
* @default true
|
|
6417
6320
|
*/
|
|
6418
|
-
allowSelectAll:
|
|
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:
|
|
6326
|
+
requireSelection: z10.boolean().default(true),
|
|
6424
6327
|
/**
|
|
6425
6328
|
* Custom message to display on consent page
|
|
6426
6329
|
*/
|
|
6427
|
-
customMessage:
|
|
6330
|
+
customMessage: z10.string().optional(),
|
|
6428
6331
|
/**
|
|
6429
6332
|
* Remember consent for future sessions
|
|
6430
6333
|
* @default true
|
|
6431
6334
|
*/
|
|
6432
|
-
rememberConsent:
|
|
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:
|
|
6340
|
+
excludedTools: z10.array(z10.string()).optional(),
|
|
6438
6341
|
/**
|
|
6439
6342
|
* Tools to always include in consent (pre-selected)
|
|
6440
6343
|
*/
|
|
6441
|
-
defaultSelectedTools:
|
|
6344
|
+
defaultSelectedTools: z10.array(z10.string()).optional()
|
|
6442
6345
|
});
|
|
6443
|
-
var federatedAuthConfigSchema =
|
|
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:
|
|
6353
|
+
stateValidation: z10.enum(["strict", "format"]).default("strict")
|
|
6451
6354
|
});
|
|
6452
|
-
var incrementalAuthConfigSchema =
|
|
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:
|
|
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:
|
|
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:
|
|
6379
|
+
showAllAppsAtOnce: z10.boolean().default(true)
|
|
6477
6380
|
});
|
|
6478
6381
|
|
|
6479
6382
|
// libs/auth/src/options/public.schema.ts
|
|
6480
|
-
import { z as
|
|
6481
|
-
var publicAuthOptionsSchema =
|
|
6482
|
-
mode:
|
|
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:
|
|
6390
|
+
issuer: z11.string().optional(),
|
|
6488
6391
|
/**
|
|
6489
6392
|
* Anonymous session TTL in seconds
|
|
6490
6393
|
* @default 3600 (1 hour)
|
|
6491
6394
|
*/
|
|
6492
|
-
sessionTtl:
|
|
6395
|
+
sessionTtl: z11.number().default(3600),
|
|
6493
6396
|
/**
|
|
6494
6397
|
* Scopes granted to anonymous sessions
|
|
6495
6398
|
* @default ['anonymous']
|
|
6496
6399
|
*/
|
|
6497
|
-
anonymousScopes:
|
|
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(
|
|
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
|
|
6516
|
-
var transparentAuthOptionsSchema =
|
|
6517
|
-
mode:
|
|
6418
|
+
import { z as z12 } from "zod";
|
|
6419
|
+
var transparentAuthOptionsSchema = z12.object({
|
|
6420
|
+
mode: z12.literal("transparent"),
|
|
6518
6421
|
/**
|
|
6519
|
-
*
|
|
6422
|
+
* Flattened remote provider fields (provider, clientId, clientSecret, scopes, providerConfig)
|
|
6520
6423
|
*/
|
|
6521
|
-
|
|
6424
|
+
...flatRemoteProviderFields,
|
|
6522
6425
|
/**
|
|
6523
6426
|
* Expected token audience
|
|
6524
6427
|
* If not set, defaults to the resource URL
|
|
6525
6428
|
*/
|
|
6526
|
-
expectedAudience:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
6551
|
-
var
|
|
6453
|
+
import { z as z13 } from "zod";
|
|
6454
|
+
var sharedAuthFields = {
|
|
6552
6455
|
local: localSigningConfigSchema.optional(),
|
|
6553
|
-
tokenStorage: tokenStorageConfigSchema.default(
|
|
6554
|
-
allowDefaultPublic:
|
|
6555
|
-
anonymousScopes:
|
|
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:
|
|
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
|
|
6565
|
-
mode:
|
|
6566
|
-
|
|
6567
|
-
...orchestratedSharedFields
|
|
6467
|
+
var localAuthSchema = z13.object({
|
|
6468
|
+
mode: z13.literal("local"),
|
|
6469
|
+
...sharedAuthFields
|
|
6568
6470
|
});
|
|
6569
|
-
var
|
|
6570
|
-
mode:
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
...orchestratedSharedFields
|
|
6471
|
+
var remoteAuthSchema = z13.object({
|
|
6472
|
+
mode: z13.literal("remote"),
|
|
6473
|
+
...flatRemoteProviderFields,
|
|
6474
|
+
...sharedAuthFields
|
|
6574
6475
|
});
|
|
6575
|
-
var
|
|
6576
|
-
|
|
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
|
|
6582
|
-
var authOptionsSchema =
|
|
6480
|
+
import { z as z14 } from "zod";
|
|
6481
|
+
var authOptionsSchema = z14.union([
|
|
6583
6482
|
publicAuthOptionsSchema,
|
|
6584
6483
|
transparentAuthOptionsSchema,
|
|
6585
|
-
|
|
6586
|
-
|
|
6484
|
+
localAuthSchema,
|
|
6485
|
+
remoteAuthSchema
|
|
6587
6486
|
]);
|
|
6588
6487
|
|
|
6589
6488
|
// libs/auth/src/options/app-auth.schema.ts
|
|
6590
|
-
import { z as
|
|
6489
|
+
import { z as z15 } from "zod";
|
|
6591
6490
|
var standaloneOptionSchema = {
|
|
6592
|
-
standalone:
|
|
6593
|
-
excludeFromParent:
|
|
6491
|
+
standalone: z15.boolean().optional(),
|
|
6492
|
+
excludeFromParent: z15.boolean().optional()
|
|
6594
6493
|
};
|
|
6595
|
-
var appAuthOptionsSchema =
|
|
6494
|
+
var appAuthOptionsSchema = z15.union([
|
|
6596
6495
|
publicAuthOptionsSchema.extend(standaloneOptionSchema),
|
|
6597
6496
|
transparentAuthOptionsSchema.extend(standaloneOptionSchema),
|
|
6598
|
-
|
|
6599
|
-
|
|
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 === "
|
|
6518
|
+
return options.mode === "local" || options.mode === "remote";
|
|
6614
6519
|
}
|
|
6615
6520
|
function isOrchestratedLocal(options) {
|
|
6616
|
-
return options.
|
|
6521
|
+
return options.mode === "local";
|
|
6617
6522
|
}
|
|
6618
6523
|
function isOrchestratedRemote(options) {
|
|
6619
|
-
return options.
|
|
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 === "
|
|
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
|
|
6630
|
-
var consentToolItemSchema =
|
|
6534
|
+
import { z as z16 } from "zod";
|
|
6535
|
+
var consentToolItemSchema = z16.object({
|
|
6631
6536
|
/** Tool ID (e.g., 'slack:send_message') */
|
|
6632
|
-
id:
|
|
6537
|
+
id: z16.string().min(1),
|
|
6633
6538
|
/** Tool name for display */
|
|
6634
|
-
name:
|
|
6539
|
+
name: z16.string().min(1),
|
|
6635
6540
|
/** Tool description */
|
|
6636
|
-
description:
|
|
6541
|
+
description: z16.string().optional(),
|
|
6637
6542
|
/** App ID this tool belongs to */
|
|
6638
|
-
appId:
|
|
6543
|
+
appId: z16.string().min(1),
|
|
6639
6544
|
/** App name for display */
|
|
6640
|
-
appName:
|
|
6545
|
+
appName: z16.string().min(1),
|
|
6641
6546
|
/** Whether the tool is selected by default */
|
|
6642
|
-
defaultSelected:
|
|
6547
|
+
defaultSelected: z16.boolean().default(true),
|
|
6643
6548
|
/** Whether this tool requires specific scopes */
|
|
6644
|
-
requiredScopes:
|
|
6549
|
+
requiredScopes: z16.array(z16.string()).optional(),
|
|
6645
6550
|
/** Category for grouping (e.g., 'read', 'write', 'admin') */
|
|
6646
|
-
category:
|
|
6551
|
+
category: z16.string().optional()
|
|
6647
6552
|
});
|
|
6648
|
-
var consentSelectionSchema =
|
|
6553
|
+
var consentSelectionSchema = z16.object({
|
|
6649
6554
|
/** Selected tool IDs */
|
|
6650
|
-
selectedTools:
|
|
6555
|
+
selectedTools: z16.array(z16.string()),
|
|
6651
6556
|
/** Whether all tools were selected */
|
|
6652
|
-
allSelected:
|
|
6557
|
+
allSelected: z16.boolean(),
|
|
6653
6558
|
/** Timestamp when consent was given */
|
|
6654
|
-
consentedAt:
|
|
6559
|
+
consentedAt: z16.string().datetime(),
|
|
6655
6560
|
/** Consent version for tracking changes */
|
|
6656
|
-
consentVersion:
|
|
6561
|
+
consentVersion: z16.string().default("1.0")
|
|
6657
6562
|
});
|
|
6658
|
-
var consentStateSchema =
|
|
6563
|
+
var consentStateSchema = z16.object({
|
|
6659
6564
|
/** Whether consent flow is enabled */
|
|
6660
|
-
enabled:
|
|
6565
|
+
enabled: z16.boolean(),
|
|
6661
6566
|
/** Available tools for consent */
|
|
6662
|
-
availableTools:
|
|
6567
|
+
availableTools: z16.array(consentToolItemSchema),
|
|
6663
6568
|
/** Pre-selected tools (from previous consent or defaults) */
|
|
6664
|
-
preselectedTools:
|
|
6569
|
+
preselectedTools: z16.array(z16.string()).optional(),
|
|
6665
6570
|
/** Whether to show all tools or group by app */
|
|
6666
|
-
groupByApp:
|
|
6571
|
+
groupByApp: z16.boolean().default(true),
|
|
6667
6572
|
/** Custom consent message */
|
|
6668
|
-
customMessage:
|
|
6573
|
+
customMessage: z16.string().optional()
|
|
6669
6574
|
});
|
|
6670
|
-
var federatedProviderItemSchema =
|
|
6575
|
+
var federatedProviderItemSchema = z16.object({
|
|
6671
6576
|
/** Provider ID (derived or explicit) */
|
|
6672
|
-
id:
|
|
6577
|
+
id: z16.string().min(1),
|
|
6673
6578
|
/** Provider display name */
|
|
6674
|
-
name:
|
|
6579
|
+
name: z16.string().min(1),
|
|
6675
6580
|
/** Provider description */
|
|
6676
|
-
description:
|
|
6581
|
+
description: z16.string().optional(),
|
|
6677
6582
|
/** Provider icon URL or emoji */
|
|
6678
|
-
icon:
|
|
6583
|
+
icon: z16.string().optional(),
|
|
6679
6584
|
/** Provider type */
|
|
6680
|
-
type:
|
|
6585
|
+
type: z16.enum(["local", "remote", "transparent"]),
|
|
6681
6586
|
/** OAuth provider URL (for remote providers) */
|
|
6682
|
-
providerUrl:
|
|
6587
|
+
providerUrl: z16.string().url().optional(),
|
|
6683
6588
|
/** Apps using this provider */
|
|
6684
|
-
appIds:
|
|
6589
|
+
appIds: z16.array(z16.string()),
|
|
6685
6590
|
/** App names using this provider */
|
|
6686
|
-
appNames:
|
|
6591
|
+
appNames: z16.array(z16.string()),
|
|
6687
6592
|
/** Scopes required by this provider */
|
|
6688
|
-
scopes:
|
|
6593
|
+
scopes: z16.array(z16.string()),
|
|
6689
6594
|
/** Whether this is the primary/parent provider */
|
|
6690
|
-
isPrimary:
|
|
6595
|
+
isPrimary: z16.boolean(),
|
|
6691
6596
|
/** Whether this provider is optional (can be skipped) */
|
|
6692
|
-
isOptional:
|
|
6597
|
+
isOptional: z16.boolean().default(false)
|
|
6693
6598
|
});
|
|
6694
|
-
var federatedLoginStateSchema =
|
|
6599
|
+
var federatedLoginStateSchema = z16.object({
|
|
6695
6600
|
/** All available providers */
|
|
6696
|
-
providers:
|
|
6601
|
+
providers: z16.array(federatedProviderItemSchema),
|
|
6697
6602
|
/** Primary provider ID (if any) */
|
|
6698
|
-
primaryProviderId:
|
|
6603
|
+
primaryProviderId: z16.string().optional(),
|
|
6699
6604
|
/** Whether user can skip optional providers */
|
|
6700
|
-
allowSkip:
|
|
6605
|
+
allowSkip: z16.boolean().default(true),
|
|
6701
6606
|
/** Pre-selected provider IDs (from previous session) */
|
|
6702
|
-
preselectedProviders:
|
|
6607
|
+
preselectedProviders: z16.array(z16.string()).optional()
|
|
6703
6608
|
});
|
|
6704
|
-
var federatedSelectionSchema =
|
|
6609
|
+
var federatedSelectionSchema = z16.object({
|
|
6705
6610
|
/** Selected provider IDs */
|
|
6706
|
-
selectedProviders:
|
|
6611
|
+
selectedProviders: z16.array(z16.string()),
|
|
6707
6612
|
/** Skipped provider IDs */
|
|
6708
|
-
skippedProviders:
|
|
6613
|
+
skippedProviders: z16.array(z16.string()),
|
|
6709
6614
|
/** Provider-specific metadata */
|
|
6710
|
-
providerMetadata:
|
|
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
|
|
6715
|
-
var detectedAuthProviderSchema =
|
|
6716
|
-
id:
|
|
6717
|
-
providerUrl:
|
|
6718
|
-
mode:
|
|
6719
|
-
appIds:
|
|
6720
|
-
scopes:
|
|
6721
|
-
isParentProvider:
|
|
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 =
|
|
6724
|
-
providers:
|
|
6725
|
-
requiresOrchestration:
|
|
6726
|
-
parentProviderId:
|
|
6727
|
-
childProviderIds:
|
|
6728
|
-
uniqueProviderCount:
|
|
6729
|
-
validationErrors:
|
|
6730
|
-
warnings:
|
|
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.
|
|
6642
|
+
return options.providerConfig?.id ?? urlToProviderId(options.provider);
|
|
6738
6643
|
}
|
|
6739
6644
|
if (isOrchestratedMode(options)) {
|
|
6740
6645
|
if (isOrchestratedRemote(options)) {
|
|
6741
|
-
return options.
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
6735
|
+
return options.provider;
|
|
6831
6736
|
}
|
|
6832
6737
|
if (isOrchestratedMode(options) && isOrchestratedRemote(options)) {
|
|
6833
|
-
return options.
|
|
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(
|
|
7004
|
-
if (!
|
|
7005
|
-
const normalized =
|
|
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
|
|
7121
|
-
var credentialScopeSchema =
|
|
7122
|
-
var loadingStrategySchema =
|
|
7123
|
-
var getCredentialOptionsSchema =
|
|
7124
|
-
forceRefresh:
|
|
7125
|
-
scopes:
|
|
7126
|
-
timeout:
|
|
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 =
|
|
7129
|
-
name:
|
|
7130
|
-
description:
|
|
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:
|
|
7038
|
+
cacheTtl: z18.number().nonnegative().optional(),
|
|
7134
7039
|
// Functions validated at runtime, not via Zod (Zod 4 compatibility)
|
|
7135
|
-
factory:
|
|
7136
|
-
refresh:
|
|
7137
|
-
toHeaders:
|
|
7138
|
-
metadata:
|
|
7139
|
-
required:
|
|
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 =
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
name:
|
|
7145
|
-
required:
|
|
7146
|
-
scopes:
|
|
7147
|
-
alias:
|
|
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 =
|
|
7151
|
-
enabled:
|
|
7152
|
-
useSharedStorage:
|
|
7153
|
-
namespace:
|
|
7154
|
-
defaultCacheTtl:
|
|
7155
|
-
maxCredentialsPerSession:
|
|
7156
|
-
providers:
|
|
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,
|