@frontmcp/auth 0.12.2 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +674 -768
- package/esm/package.json +4 -4
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +746 -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 +55 -56
- package/options/orchestrated.schema.d.ts.map +1 -1
- package/options/public.schema.d.ts +2 -1
- package/options/public.schema.d.ts.map +1 -1
- package/options/schema.d.ts +36 -39
- 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 +17 -16
- package/options/transparent.schema.d.ts.map +1 -1
- 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/transport-session.types.d.ts +3 -0
- package/session/transport-session.types.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/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __esm = (fn, res) => function __init() {
|
|
9
7
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -20,14 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
18
|
}
|
|
21
19
|
return to;
|
|
22
20
|
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
22
|
|
|
33
23
|
// libs/auth/src/cimd/cimd.cache.ts
|
|
@@ -95,7 +85,7 @@ function parseCacheControlHeader(value) {
|
|
|
95
85
|
}
|
|
96
86
|
return result;
|
|
97
87
|
}
|
|
98
|
-
var InMemoryCimdCache
|
|
88
|
+
var InMemoryCimdCache;
|
|
99
89
|
var init_cimd_cache = __esm({
|
|
100
90
|
"libs/auth/src/cimd/cimd.cache.ts"() {
|
|
101
91
|
"use strict";
|
|
@@ -230,7 +220,6 @@ var init_cimd_cache = __esm({
|
|
|
230
220
|
return removed;
|
|
231
221
|
}
|
|
232
222
|
};
|
|
233
|
-
CimdCache = InMemoryCimdCache;
|
|
234
223
|
}
|
|
235
224
|
});
|
|
236
225
|
|
|
@@ -250,7 +239,6 @@ __export(index_exports, {
|
|
|
250
239
|
AuthProvidersVault: () => AuthProvidersVault,
|
|
251
240
|
AuthorizationBase: () => AuthorizationBase,
|
|
252
241
|
CDN: () => CDN,
|
|
253
|
-
CimdCache: () => CimdCache,
|
|
254
242
|
CimdClientIdMismatchError: () => CimdClientIdMismatchError,
|
|
255
243
|
CimdDisabledError: () => CimdDisabledError,
|
|
256
244
|
CimdError: () => CimdError,
|
|
@@ -266,12 +254,13 @@ __export(index_exports, {
|
|
|
266
254
|
EagerCredentialLoader: () => EagerCredentialLoader,
|
|
267
255
|
ElicitationSecretRequiredError: () => ElicitationSecretRequiredError,
|
|
268
256
|
EncryptedRedisVault: () => EncryptedRedisVault,
|
|
269
|
-
EncryptedStorageError: () =>
|
|
270
|
-
EncryptedTypedStorage: () =>
|
|
257
|
+
EncryptedStorageError: () => import_utils17.EncryptedStorageError,
|
|
258
|
+
EncryptedTypedStorage: () => import_utils17.EncryptedTypedStorage,
|
|
271
259
|
EncryptionContextNotSetError: () => EncryptionContextNotSetError,
|
|
272
260
|
EncryptionKeyNotConfiguredError: () => EncryptionKeyNotConfiguredError,
|
|
273
261
|
InMemoryAuthorizationStore: () => InMemoryAuthorizationStore,
|
|
274
262
|
InMemoryAuthorizationVault: () => InMemoryAuthorizationVault,
|
|
263
|
+
InMemoryCimdCache: () => InMemoryCimdCache,
|
|
275
264
|
InMemoryFederatedAuthSessionStore: () => InMemoryFederatedAuthSessionStore,
|
|
276
265
|
InMemoryOrchestratedTokenStore: () => InMemoryOrchestratedTokenStore,
|
|
277
266
|
InMemoryStoreRequiredError: () => InMemoryStoreRequiredError,
|
|
@@ -302,7 +291,7 @@ __export(index_exports, {
|
|
|
302
291
|
TokenVault: () => TokenVault,
|
|
303
292
|
TransparentAuthorization: () => TransparentAuthorization,
|
|
304
293
|
TransportIdGenerator: () => TransportIdGenerator,
|
|
305
|
-
TypedStorage: () =>
|
|
294
|
+
TypedStorage: () => import_utils16.TypedStorage,
|
|
306
295
|
VaultEncryption: () => VaultEncryption,
|
|
307
296
|
VaultLoadError: () => VaultLoadError,
|
|
308
297
|
VaultNotFoundError: () => VaultNotFoundError,
|
|
@@ -367,7 +356,6 @@ __export(index_exports, {
|
|
|
367
356
|
decryptSessionJson: () => decryptSessionJson,
|
|
368
357
|
decryptValue: () => import_utils25.decryptValue,
|
|
369
358
|
defaultSessionRateLimiter: () => defaultSessionRateLimiter,
|
|
370
|
-
deleteDevKey: () => deleteDevKey,
|
|
371
359
|
deriveAuthorizationId: () => deriveAuthorizationId,
|
|
372
360
|
deriveExpectedAudience: () => deriveExpectedAudience,
|
|
373
361
|
deriveProviderId: () => deriveProviderId,
|
|
@@ -380,7 +368,7 @@ __export(index_exports, {
|
|
|
380
368
|
encryptedBlobSchema: () => encryptedBlobSchema,
|
|
381
369
|
encryptedDataSchema: () => encryptedDataSchema,
|
|
382
370
|
encryptedVaultEntrySchema: () => encryptedVaultEntrySchema,
|
|
383
|
-
escapeHtml: () =>
|
|
371
|
+
escapeHtml: () => import_utils3.escapeHtml,
|
|
384
372
|
extraWideLayout: () => extraWideLayout,
|
|
385
373
|
extractBearerToken: () => extractBearerToken,
|
|
386
374
|
extractCacheHeaders: () => extractCacheHeaders,
|
|
@@ -389,6 +377,7 @@ __export(index_exports, {
|
|
|
389
377
|
federatedLoginStateSchema: () => federatedLoginStateSchema,
|
|
390
378
|
federatedProviderItemSchema: () => federatedProviderItemSchema,
|
|
391
379
|
federatedSelectionSchema: () => federatedSelectionSchema,
|
|
380
|
+
flatRemoteProviderFields: () => flatRemoteProviderFields,
|
|
392
381
|
fromSessionRecord: () => fromSessionRecord,
|
|
393
382
|
generatePkceChallenge: () => generatePkceChallenge,
|
|
394
383
|
getCredentialOptionsSchema: () => getCredentialOptionsSchema,
|
|
@@ -402,14 +391,15 @@ __export(index_exports, {
|
|
|
402
391
|
hkdfSha256: () => import_utils25.hkdfSha256,
|
|
403
392
|
incrementalAuthConfigSchema: () => incrementalAuthConfigSchema,
|
|
404
393
|
isCimdClientId: () => isCimdClientId,
|
|
405
|
-
isDevKeyPersistenceEnabled: () => isDevKeyPersistenceEnabled,
|
|
406
394
|
isJwt: () => isJwt,
|
|
395
|
+
isLocalMode: () => isLocalMode,
|
|
407
396
|
isOrchestratedLocal: () => isOrchestratedLocal,
|
|
408
397
|
isOrchestratedMode: () => isOrchestratedMode,
|
|
409
398
|
isOrchestratedRemote: () => isOrchestratedRemote,
|
|
410
399
|
isPublicMode: () => isPublicMode,
|
|
400
|
+
isRemoteMode: () => isRemoteMode,
|
|
411
401
|
isSessionComplete: () => isSessionComplete,
|
|
412
|
-
isSignedSession: () =>
|
|
402
|
+
isSignedSession: () => import_utils8.isSignedData,
|
|
413
403
|
isSoonExpiring: () => isSoonExpiring,
|
|
414
404
|
isSoonExpiringProvider: () => isSoonExpiringProvider,
|
|
415
405
|
isTransparentMode: () => isTransparentMode,
|
|
@@ -418,14 +408,13 @@ __export(index_exports, {
|
|
|
418
408
|
jwkSchema: () => jwkSchema,
|
|
419
409
|
legacySseTransportStateSchema: () => legacySseTransportStateSchema,
|
|
420
410
|
llmSafeAuthContextSchema: () => llmSafeAuthContextSchema,
|
|
421
|
-
loadDevKey: () => loadDevKey,
|
|
422
411
|
loadingStrategySchema: () => loadingStrategySchema,
|
|
412
|
+
localAuthSchema: () => localAuthSchema,
|
|
423
413
|
localSigningConfigSchema: () => localSigningConfigSchema,
|
|
424
414
|
mtlsCredentialSchema: () => mtlsCredentialSchema,
|
|
425
415
|
noopLogger: () => noopLogger,
|
|
426
416
|
normalizeIssuer: () => normalizeIssuer,
|
|
427
417
|
oauthCredentialSchema: () => oauthCredentialSchema,
|
|
428
|
-
orchestratedAuthOptionsSchema: () => orchestratedAuthOptionsSchema,
|
|
429
418
|
orchestratedLocalSchema: () => orchestratedLocalSchema,
|
|
430
419
|
orchestratedRemoteSchema: () => orchestratedRemoteSchema,
|
|
431
420
|
parseAuthOptions: () => parseAuthOptions,
|
|
@@ -436,16 +425,16 @@ __export(index_exports, {
|
|
|
436
425
|
pkceOAuthCredentialSchema: () => pkceOAuthCredentialSchema,
|
|
437
426
|
privateKeyCredentialSchema: () => privateKeyCredentialSchema,
|
|
438
427
|
progressiveAuthStateSchema: () => progressiveAuthStateSchema,
|
|
428
|
+
providerConfigSchema: () => providerConfigSchema,
|
|
439
429
|
publicAccessConfigSchema: () => publicAccessConfigSchema,
|
|
440
430
|
publicAuthOptionsSchema: () => publicAuthOptionsSchema,
|
|
441
431
|
redisConfigSchema: () => redisConfigSchema,
|
|
442
432
|
redisVaultEntrySchema: () => redisVaultEntrySchema,
|
|
433
|
+
remoteAuthSchema: () => remoteAuthSchema,
|
|
443
434
|
remoteProviderConfigSchema: () => remoteProviderConfigSchema,
|
|
444
435
|
renderToHtml: () => renderToHtml,
|
|
445
436
|
resetCachedKey: () => resetCachedKey,
|
|
446
|
-
resolveKeyPath: () => resolveKeyPath,
|
|
447
437
|
safeDecrypt: () => safeDecrypt,
|
|
448
|
-
saveDevKey: () => saveDevKey,
|
|
449
438
|
serviceAccountCredentialSchema: () => serviceAccountCredentialSchema,
|
|
450
439
|
sessionIdPayloadSchema: () => sessionIdPayloadSchema,
|
|
451
440
|
sessionJwtPayloadSchema: () => sessionJwtPayloadSchema,
|
|
@@ -554,29 +543,19 @@ var JwksService = class {
|
|
|
554
543
|
rotateDays: opts?.rotateDays ?? 30,
|
|
555
544
|
providerJwksTtlMs: opts?.providerJwksTtlMs ?? 6 * 60 * 60 * 1e3,
|
|
556
545
|
// 6h
|
|
557
|
-
networkTimeoutMs: opts?.networkTimeoutMs ?? 5e3
|
|
546
|
+
networkTimeoutMs: opts?.networkTimeoutMs ?? 5e3
|
|
558
547
|
// 5s
|
|
559
|
-
devKeyPersistence: opts?.devKeyPersistence
|
|
560
548
|
};
|
|
561
549
|
}
|
|
562
550
|
// ===========================================================================
|
|
563
551
|
// Key Persistence Helpers
|
|
564
552
|
// ===========================================================================
|
|
565
|
-
/**
|
|
566
|
-
* Check if key persistence should be enabled.
|
|
567
|
-
* Enabled in development by default, disabled in production unless forceEnable.
|
|
568
|
-
*/
|
|
569
|
-
shouldEnablePersistence() {
|
|
570
|
-
const isProd = process.env["NODE_ENV"] === "production";
|
|
571
|
-
if (this.opts.devKeyPersistence?.forceEnable) return true;
|
|
572
|
-
return !isProd;
|
|
573
|
-
}
|
|
574
553
|
/**
|
|
575
554
|
* Get or create the KeyPersistence instance.
|
|
576
|
-
* Returns null if persistence is disabled.
|
|
555
|
+
* Returns null if persistence is disabled (production).
|
|
577
556
|
*/
|
|
578
557
|
async getKeyPersistence() {
|
|
579
|
-
if (
|
|
558
|
+
if ((0, import_utils.isProduction)()) return null;
|
|
580
559
|
if (!this.keyPersistence) {
|
|
581
560
|
this.keyPersistence = await (0, import_utils.createKeyPersistence)({
|
|
582
561
|
baseDir: ".frontmcp/keys"
|
|
@@ -694,7 +673,12 @@ var JwksService = class {
|
|
|
694
673
|
if (!jwtAlg) {
|
|
695
674
|
return { ok: false, error: "missing_alg" };
|
|
696
675
|
}
|
|
697
|
-
const isValid = (0, import_utils.rsaVerify)(
|
|
676
|
+
const isValid = await (0, import_utils.rsaVerify)(
|
|
677
|
+
jwtAlg,
|
|
678
|
+
Buffer.from(signatureInput),
|
|
679
|
+
matchingKey,
|
|
680
|
+
signature
|
|
681
|
+
);
|
|
698
682
|
if (!isValid) {
|
|
699
683
|
return { ok: false, error: "signature_invalid" };
|
|
700
684
|
}
|
|
@@ -915,150 +899,9 @@ var JwksService = class {
|
|
|
915
899
|
}
|
|
916
900
|
};
|
|
917
901
|
|
|
918
|
-
// libs/auth/src/jwks/dev-key-persistence.ts
|
|
919
|
-
var path = __toESM(require("path"));
|
|
920
|
-
var crypto = __toESM(require("crypto"));
|
|
921
|
-
var import_zod = require("zod");
|
|
922
|
-
var import_utils2 = require("@frontmcp/utils");
|
|
923
|
-
var DEFAULT_KEY_PATH = ".frontmcp/dev-keys.json";
|
|
924
|
-
var rsaPrivateKeySchema = import_zod.z.object({
|
|
925
|
-
kty: import_zod.z.literal("RSA"),
|
|
926
|
-
n: import_zod.z.string().min(1),
|
|
927
|
-
e: import_zod.z.string().min(1),
|
|
928
|
-
d: import_zod.z.string().min(1),
|
|
929
|
-
p: import_zod.z.string().optional(),
|
|
930
|
-
q: import_zod.z.string().optional(),
|
|
931
|
-
dp: import_zod.z.string().optional(),
|
|
932
|
-
dq: import_zod.z.string().optional(),
|
|
933
|
-
qi: import_zod.z.string().optional()
|
|
934
|
-
}).passthrough();
|
|
935
|
-
var ecPrivateKeySchema = import_zod.z.object({
|
|
936
|
-
kty: import_zod.z.literal("EC"),
|
|
937
|
-
crv: import_zod.z.string().min(1),
|
|
938
|
-
x: import_zod.z.string().min(1),
|
|
939
|
-
y: import_zod.z.string().min(1),
|
|
940
|
-
d: import_zod.z.string().min(1)
|
|
941
|
-
}).passthrough();
|
|
942
|
-
var publicJwkSchema = import_zod.z.object({
|
|
943
|
-
kty: import_zod.z.enum(["RSA", "EC"]),
|
|
944
|
-
kid: import_zod.z.string().min(1),
|
|
945
|
-
alg: import_zod.z.enum(["RS256", "ES256"]),
|
|
946
|
-
use: import_zod.z.literal("sig")
|
|
947
|
-
}).passthrough();
|
|
948
|
-
var jwksSchema = import_zod.z.object({
|
|
949
|
-
keys: import_zod.z.array(publicJwkSchema).min(1)
|
|
950
|
-
});
|
|
951
|
-
var devKeyDataSchema = import_zod.z.object({
|
|
952
|
-
kid: import_zod.z.string().min(1),
|
|
953
|
-
privateKey: import_zod.z.union([rsaPrivateKeySchema, ecPrivateKeySchema]),
|
|
954
|
-
publicJwk: jwksSchema,
|
|
955
|
-
createdAt: import_zod.z.number().positive().int(),
|
|
956
|
-
alg: import_zod.z.enum(["RS256", "ES256"])
|
|
957
|
-
});
|
|
958
|
-
function validateJwkStructure(data) {
|
|
959
|
-
const result = devKeyDataSchema.safeParse(data);
|
|
960
|
-
if (!result.success) {
|
|
961
|
-
return { valid: false, error: result.error.issues[0]?.message ?? "Invalid JWK structure" };
|
|
962
|
-
}
|
|
963
|
-
const parsed = result.data;
|
|
964
|
-
if (parsed.alg === "RS256" && parsed.privateKey.kty !== "RSA") {
|
|
965
|
-
return { valid: false, error: "Algorithm RS256 requires RSA key type" };
|
|
966
|
-
}
|
|
967
|
-
if (parsed.alg === "ES256" && parsed.privateKey.kty !== "EC") {
|
|
968
|
-
return { valid: false, error: "Algorithm ES256 requires EC key type" };
|
|
969
|
-
}
|
|
970
|
-
const publicKey = parsed.publicJwk.keys[0];
|
|
971
|
-
if (publicKey.kty !== parsed.privateKey.kty) {
|
|
972
|
-
return { valid: false, error: "Public and private key types do not match" };
|
|
973
|
-
}
|
|
974
|
-
if (publicKey.kid !== parsed.kid) {
|
|
975
|
-
return { valid: false, error: "kid mismatch between top-level and publicJwk" };
|
|
976
|
-
}
|
|
977
|
-
const now = Date.now();
|
|
978
|
-
const hundredYearsMs = 100 * 365 * 24 * 60 * 60 * 1e3;
|
|
979
|
-
if (parsed.createdAt > now) {
|
|
980
|
-
return { valid: false, error: "createdAt is in the future" };
|
|
981
|
-
}
|
|
982
|
-
if (parsed.createdAt < now - hundredYearsMs) {
|
|
983
|
-
return { valid: false, error: "createdAt is too old" };
|
|
984
|
-
}
|
|
985
|
-
return { valid: true };
|
|
986
|
-
}
|
|
987
|
-
function isDevKeyPersistenceEnabled(options) {
|
|
988
|
-
const isProduction = process.env["NODE_ENV"] === "production";
|
|
989
|
-
if (isProduction) {
|
|
990
|
-
return options?.forceEnable === true;
|
|
991
|
-
}
|
|
992
|
-
return true;
|
|
993
|
-
}
|
|
994
|
-
function resolveKeyPath(options) {
|
|
995
|
-
const keyPath = options?.keyPath ?? DEFAULT_KEY_PATH;
|
|
996
|
-
if (path.isAbsolute(keyPath)) {
|
|
997
|
-
return keyPath;
|
|
998
|
-
}
|
|
999
|
-
return path.resolve(process.cwd(), keyPath);
|
|
1000
|
-
}
|
|
1001
|
-
async function loadDevKey(options) {
|
|
1002
|
-
if (!isDevKeyPersistenceEnabled(options)) {
|
|
1003
|
-
return null;
|
|
1004
|
-
}
|
|
1005
|
-
const keyPath = resolveKeyPath(options);
|
|
1006
|
-
try {
|
|
1007
|
-
const content = await (0, import_utils2.readFile)(keyPath, "utf8");
|
|
1008
|
-
const data = JSON.parse(content);
|
|
1009
|
-
const validation = validateJwkStructure(data);
|
|
1010
|
-
if (!validation.valid) {
|
|
1011
|
-
console.warn(`[DevKeyPersistence] Invalid key file format at ${keyPath}: ${validation.error}, will regenerate`);
|
|
1012
|
-
return null;
|
|
1013
|
-
}
|
|
1014
|
-
console.log(`[DevKeyPersistence] Loaded key (kid=${data.kid}) from ${keyPath}`);
|
|
1015
|
-
return data;
|
|
1016
|
-
} catch (error) {
|
|
1017
|
-
if (error.code === "ENOENT") {
|
|
1018
|
-
return null;
|
|
1019
|
-
}
|
|
1020
|
-
console.warn(`[DevKeyPersistence] Failed to load key from ${keyPath}: ${error.message}`);
|
|
1021
|
-
return null;
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
async function saveDevKey(keyData, options) {
|
|
1025
|
-
if (!isDevKeyPersistenceEnabled(options)) {
|
|
1026
|
-
return true;
|
|
1027
|
-
}
|
|
1028
|
-
const keyPath = resolveKeyPath(options);
|
|
1029
|
-
const dir = path.dirname(keyPath);
|
|
1030
|
-
const tempPath = `${keyPath}.tmp.${Date.now()}.${crypto.randomBytes(8).toString("hex")}`;
|
|
1031
|
-
try {
|
|
1032
|
-
await (0, import_utils2.mkdir)(dir, { recursive: true, mode: 448 });
|
|
1033
|
-
const content = JSON.stringify(keyData, null, 2);
|
|
1034
|
-
await (0, import_utils2.writeFile)(tempPath, content, { mode: 384 });
|
|
1035
|
-
await (0, import_utils2.rename)(tempPath, keyPath);
|
|
1036
|
-
console.log(`[DevKeyPersistence] Saved key (kid=${keyData.kid}) to ${keyPath}`);
|
|
1037
|
-
return true;
|
|
1038
|
-
} catch (error) {
|
|
1039
|
-
console.error(`[DevKeyPersistence] Failed to save key to ${keyPath}: ${error.message}`);
|
|
1040
|
-
try {
|
|
1041
|
-
await (0, import_utils2.unlink)(tempPath);
|
|
1042
|
-
} catch {
|
|
1043
|
-
}
|
|
1044
|
-
return false;
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
async function deleteDevKey(options) {
|
|
1048
|
-
const keyPath = resolveKeyPath(options);
|
|
1049
|
-
try {
|
|
1050
|
-
await (0, import_utils2.unlink)(keyPath);
|
|
1051
|
-
console.log(`[DevKeyPersistence] Deleted key at ${keyPath}`);
|
|
1052
|
-
} catch (error) {
|
|
1053
|
-
if (error.code !== "ENOENT") {
|
|
1054
|
-
console.warn(`[DevKeyPersistence] Failed to delete key at ${keyPath}: ${error.message}`);
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
902
|
// libs/auth/src/ui/base-layout.ts
|
|
903
|
+
var import_utils2 = require("@frontmcp/utils");
|
|
1060
904
|
var import_utils3 = require("@frontmcp/utils");
|
|
1061
|
-
var import_utils4 = require("@frontmcp/utils");
|
|
1062
905
|
var CDN = {
|
|
1063
906
|
/** Tailwind CSS v4 Browser CDN - generates styles on-the-fly with @theme support */
|
|
1064
907
|
tailwind: "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",
|
|
@@ -1137,13 +980,13 @@ function baseLayout(content, options) {
|
|
|
1137
980
|
}
|
|
1138
981
|
${customCss}
|
|
1139
982
|
</style>` : "";
|
|
1140
|
-
const metaDescription = description ? `<meta name="description" content="${(0,
|
|
983
|
+
const metaDescription = description ? `<meta name="description" content="${(0, import_utils2.escapeHtml)(description)}">` : "";
|
|
1141
984
|
return `<!DOCTYPE html>
|
|
1142
985
|
<html lang="en">
|
|
1143
986
|
<head>
|
|
1144
987
|
<meta charset="UTF-8">
|
|
1145
988
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1146
|
-
<title>${(0,
|
|
989
|
+
<title>${(0, import_utils2.escapeHtml)(title)} - FrontMCP</title>
|
|
1147
990
|
${metaDescription}
|
|
1148
991
|
|
|
1149
992
|
<!-- Google Fonts CDN - Inter (modern UI font) -->
|
|
@@ -1154,7 +997,7 @@ function baseLayout(content, options) {
|
|
|
1154
997
|
${tailwindBlock}
|
|
1155
998
|
${headExtra}
|
|
1156
999
|
</head>
|
|
1157
|
-
<body class="${(0,
|
|
1000
|
+
<body class="${(0, import_utils2.escapeHtml)(bodyClass)}">
|
|
1158
1001
|
${content}
|
|
1159
1002
|
</body>
|
|
1160
1003
|
</html>`;
|
|
@@ -1209,7 +1052,7 @@ function extraWideLayout(content, options) {
|
|
|
1209
1052
|
}
|
|
1210
1053
|
|
|
1211
1054
|
// libs/auth/src/ui/templates.ts
|
|
1212
|
-
var escapeHtml3 =
|
|
1055
|
+
var escapeHtml3 = import_utils3.escapeHtml;
|
|
1213
1056
|
function buildConsentPage(params) {
|
|
1214
1057
|
const { apps, clientName, pendingAuthId, csrfToken, callbackPath } = params;
|
|
1215
1058
|
const appCards = apps.map((app) => buildAppCardHtml(app, pendingAuthId, csrfToken, callbackPath)).join("\n");
|
|
@@ -1558,43 +1401,43 @@ function renderToHtml(html, _options) {
|
|
|
1558
1401
|
}
|
|
1559
1402
|
|
|
1560
1403
|
// libs/auth/src/session/authorization.store.ts
|
|
1561
|
-
var
|
|
1562
|
-
var
|
|
1563
|
-
var pkceChallengeSchema =
|
|
1564
|
-
challenge:
|
|
1565
|
-
method:
|
|
1404
|
+
var import_utils4 = require("@frontmcp/utils");
|
|
1405
|
+
var import_zod = require("zod");
|
|
1406
|
+
var pkceChallengeSchema = import_zod.z.object({
|
|
1407
|
+
challenge: import_zod.z.string().min(43).max(128),
|
|
1408
|
+
method: import_zod.z.literal("S256")
|
|
1566
1409
|
});
|
|
1567
|
-
var authorizationCodeRecordSchema =
|
|
1568
|
-
code:
|
|
1569
|
-
clientId:
|
|
1570
|
-
redirectUri:
|
|
1571
|
-
scopes:
|
|
1410
|
+
var authorizationCodeRecordSchema = import_zod.z.object({
|
|
1411
|
+
code: import_zod.z.string().min(1),
|
|
1412
|
+
clientId: import_zod.z.string().min(1),
|
|
1413
|
+
redirectUri: import_zod.z.string().url(),
|
|
1414
|
+
scopes: import_zod.z.array(import_zod.z.string()),
|
|
1572
1415
|
pkce: pkceChallengeSchema,
|
|
1573
|
-
userSub:
|
|
1574
|
-
userEmail:
|
|
1575
|
-
userName:
|
|
1576
|
-
state:
|
|
1577
|
-
createdAt:
|
|
1578
|
-
expiresAt:
|
|
1579
|
-
used:
|
|
1580
|
-
resource:
|
|
1416
|
+
userSub: import_zod.z.string().min(1),
|
|
1417
|
+
userEmail: import_zod.z.string().email().optional(),
|
|
1418
|
+
userName: import_zod.z.string().optional(),
|
|
1419
|
+
state: import_zod.z.string().optional(),
|
|
1420
|
+
createdAt: import_zod.z.number(),
|
|
1421
|
+
expiresAt: import_zod.z.number(),
|
|
1422
|
+
used: import_zod.z.boolean(),
|
|
1423
|
+
resource: import_zod.z.string().url().optional(),
|
|
1581
1424
|
// Consent and federated login fields
|
|
1582
|
-
selectedToolIds:
|
|
1583
|
-
selectedProviderIds:
|
|
1584
|
-
skippedProviderIds:
|
|
1585
|
-
consentEnabled:
|
|
1586
|
-
federatedLoginUsed:
|
|
1587
|
-
pendingAuthId:
|
|
1425
|
+
selectedToolIds: import_zod.z.array(import_zod.z.string()).optional(),
|
|
1426
|
+
selectedProviderIds: import_zod.z.array(import_zod.z.string()).optional(),
|
|
1427
|
+
skippedProviderIds: import_zod.z.array(import_zod.z.string()).optional(),
|
|
1428
|
+
consentEnabled: import_zod.z.boolean().optional(),
|
|
1429
|
+
federatedLoginUsed: import_zod.z.boolean().optional(),
|
|
1430
|
+
pendingAuthId: import_zod.z.string().optional()
|
|
1588
1431
|
});
|
|
1589
1432
|
function verifyPkce(codeVerifier, challenge) {
|
|
1590
1433
|
if (challenge.method !== "S256") {
|
|
1591
1434
|
return false;
|
|
1592
1435
|
}
|
|
1593
|
-
const hash = (0,
|
|
1436
|
+
const hash = (0, import_utils4.sha256Base64url)(codeVerifier);
|
|
1594
1437
|
return hash === challenge.challenge;
|
|
1595
1438
|
}
|
|
1596
1439
|
function generatePkceChallenge(codeVerifier) {
|
|
1597
|
-
const challenge = (0,
|
|
1440
|
+
const challenge = (0, import_utils4.sha256Base64url)(codeVerifier);
|
|
1598
1441
|
return { challenge, method: "S256" };
|
|
1599
1442
|
}
|
|
1600
1443
|
var InMemoryAuthorizationStore = class {
|
|
@@ -1608,10 +1451,10 @@ var InMemoryAuthorizationStore = class {
|
|
|
1608
1451
|
/** Default TTL for refresh tokens (30 days) */
|
|
1609
1452
|
refreshTtlMs = 30 * 24 * 60 * 60 * 1e3;
|
|
1610
1453
|
generateCode() {
|
|
1611
|
-
return (0,
|
|
1454
|
+
return (0, import_utils4.randomUUID)().replace(/-/g, "") + (0, import_utils4.randomUUID)().replace(/-/g, "");
|
|
1612
1455
|
}
|
|
1613
1456
|
generateRefreshToken() {
|
|
1614
|
-
return (0,
|
|
1457
|
+
return (0, import_utils4.randomUUID)() + "-" + (0, import_utils4.randomUUID)();
|
|
1615
1458
|
}
|
|
1616
1459
|
async storeAuthorizationCode(record) {
|
|
1617
1460
|
this.codes.set(record.code, record);
|
|
@@ -1724,7 +1567,7 @@ var InMemoryAuthorizationStore = class {
|
|
|
1724
1567
|
createPendingRecord(params) {
|
|
1725
1568
|
const now = Date.now();
|
|
1726
1569
|
return {
|
|
1727
|
-
id: (0,
|
|
1570
|
+
id: (0, import_utils4.randomUUID)(),
|
|
1728
1571
|
clientId: params.clientId,
|
|
1729
1572
|
redirectUri: params.redirectUri,
|
|
1730
1573
|
scopes: params.scopes,
|
|
@@ -1771,10 +1614,10 @@ var RedisAuthorizationStore = class {
|
|
|
1771
1614
|
return `${this.namespace}${type}:${id}`;
|
|
1772
1615
|
}
|
|
1773
1616
|
generateCode() {
|
|
1774
|
-
return (0,
|
|
1617
|
+
return (0, import_utils4.randomUUID)().replace(/-/g, "") + (0, import_utils4.randomUUID)().replace(/-/g, "");
|
|
1775
1618
|
}
|
|
1776
1619
|
generateRefreshToken() {
|
|
1777
|
-
return (0,
|
|
1620
|
+
return (0, import_utils4.randomUUID)() + "-" + (0, import_utils4.randomUUID)();
|
|
1778
1621
|
}
|
|
1779
1622
|
async storeAuthorizationCode(record) {
|
|
1780
1623
|
const ttl = Math.max(Math.ceil((record.expiresAt - Date.now()) / 1e3), 1);
|
|
@@ -1837,8 +1680,8 @@ var RedisAuthorizationStore = class {
|
|
|
1837
1680
|
};
|
|
1838
1681
|
|
|
1839
1682
|
// libs/auth/src/session/authorization-vault.ts
|
|
1840
|
-
var
|
|
1841
|
-
var credentialTypeSchema =
|
|
1683
|
+
var import_zod2 = require("zod");
|
|
1684
|
+
var credentialTypeSchema = import_zod2.z.enum([
|
|
1842
1685
|
"oauth",
|
|
1843
1686
|
// OAuth 2.0 tokens
|
|
1844
1687
|
"api_key",
|
|
@@ -1860,135 +1703,135 @@ var credentialTypeSchema = import_zod3.z.enum([
|
|
|
1860
1703
|
"oauth_pkce"
|
|
1861
1704
|
// OAuth 2.0 with PKCE for public clients
|
|
1862
1705
|
]);
|
|
1863
|
-
var oauthCredentialSchema =
|
|
1864
|
-
type:
|
|
1706
|
+
var oauthCredentialSchema = import_zod2.z.object({
|
|
1707
|
+
type: import_zod2.z.literal("oauth"),
|
|
1865
1708
|
/** Access token */
|
|
1866
|
-
accessToken:
|
|
1709
|
+
accessToken: import_zod2.z.string(),
|
|
1867
1710
|
/** Refresh token (optional) */
|
|
1868
|
-
refreshToken:
|
|
1711
|
+
refreshToken: import_zod2.z.string().optional(),
|
|
1869
1712
|
/** Token type (usually 'Bearer') */
|
|
1870
|
-
tokenType:
|
|
1713
|
+
tokenType: import_zod2.z.string().default("Bearer"),
|
|
1871
1714
|
/** Token expiration timestamp (epoch ms) */
|
|
1872
|
-
expiresAt:
|
|
1715
|
+
expiresAt: import_zod2.z.number().optional(),
|
|
1873
1716
|
/** Granted scopes */
|
|
1874
|
-
scopes:
|
|
1717
|
+
scopes: import_zod2.z.array(import_zod2.z.string()).default([]),
|
|
1875
1718
|
/** ID token for OIDC (optional) */
|
|
1876
|
-
idToken:
|
|
1719
|
+
idToken: import_zod2.z.string().optional()
|
|
1877
1720
|
});
|
|
1878
|
-
var apiKeyCredentialSchema =
|
|
1879
|
-
type:
|
|
1721
|
+
var apiKeyCredentialSchema = import_zod2.z.object({
|
|
1722
|
+
type: import_zod2.z.literal("api_key"),
|
|
1880
1723
|
/** The API key value */
|
|
1881
|
-
key:
|
|
1724
|
+
key: import_zod2.z.string().min(1),
|
|
1882
1725
|
/** Header name to use (e.g., 'X-API-Key', 'Authorization') */
|
|
1883
|
-
headerName:
|
|
1726
|
+
headerName: import_zod2.z.string().default("X-API-Key"),
|
|
1884
1727
|
/** Prefix for the header value (e.g., 'Bearer ', 'Api-Key ') */
|
|
1885
|
-
headerPrefix:
|
|
1728
|
+
headerPrefix: import_zod2.z.string().optional(),
|
|
1886
1729
|
/** Alternative: send as query parameter */
|
|
1887
|
-
queryParam:
|
|
1730
|
+
queryParam: import_zod2.z.string().optional()
|
|
1888
1731
|
});
|
|
1889
|
-
var basicAuthCredentialSchema =
|
|
1890
|
-
type:
|
|
1732
|
+
var basicAuthCredentialSchema = import_zod2.z.object({
|
|
1733
|
+
type: import_zod2.z.literal("basic"),
|
|
1891
1734
|
/** Username */
|
|
1892
|
-
username:
|
|
1735
|
+
username: import_zod2.z.string().min(1),
|
|
1893
1736
|
/** Password */
|
|
1894
|
-
password:
|
|
1737
|
+
password: import_zod2.z.string(),
|
|
1895
1738
|
/** Pre-computed base64 encoded value (optional, for caching) */
|
|
1896
|
-
encodedValue:
|
|
1739
|
+
encodedValue: import_zod2.z.string().optional()
|
|
1897
1740
|
});
|
|
1898
|
-
var bearerCredentialSchema =
|
|
1899
|
-
type:
|
|
1741
|
+
var bearerCredentialSchema = import_zod2.z.object({
|
|
1742
|
+
type: import_zod2.z.literal("bearer"),
|
|
1900
1743
|
/** The bearer token value */
|
|
1901
|
-
token:
|
|
1744
|
+
token: import_zod2.z.string().min(1),
|
|
1902
1745
|
/** Token expiration (optional, for static tokens that expire) */
|
|
1903
|
-
expiresAt:
|
|
1746
|
+
expiresAt: import_zod2.z.number().optional()
|
|
1904
1747
|
});
|
|
1905
|
-
var privateKeyCredentialSchema =
|
|
1906
|
-
type:
|
|
1748
|
+
var privateKeyCredentialSchema = import_zod2.z.object({
|
|
1749
|
+
type: import_zod2.z.literal("private_key"),
|
|
1907
1750
|
/** Key format */
|
|
1908
|
-
format:
|
|
1751
|
+
format: import_zod2.z.enum(["pem", "jwk", "pkcs8", "pkcs12"]),
|
|
1909
1752
|
/** The key data (PEM string or JWK JSON) */
|
|
1910
|
-
keyData:
|
|
1753
|
+
keyData: import_zod2.z.string(),
|
|
1911
1754
|
/** Key ID (for JWK) */
|
|
1912
|
-
keyId:
|
|
1755
|
+
keyId: import_zod2.z.string().optional(),
|
|
1913
1756
|
/** Algorithm to use for signing */
|
|
1914
|
-
algorithm:
|
|
1757
|
+
algorithm: import_zod2.z.string().optional(),
|
|
1915
1758
|
/** Passphrase if key is encrypted */
|
|
1916
|
-
passphrase:
|
|
1759
|
+
passphrase: import_zod2.z.string().optional(),
|
|
1917
1760
|
/** Associated certificate (for mTLS) */
|
|
1918
|
-
certificate:
|
|
1761
|
+
certificate: import_zod2.z.string().optional()
|
|
1919
1762
|
});
|
|
1920
|
-
var mtlsCredentialSchema =
|
|
1921
|
-
type:
|
|
1763
|
+
var mtlsCredentialSchema = import_zod2.z.object({
|
|
1764
|
+
type: import_zod2.z.literal("mtls"),
|
|
1922
1765
|
/** Client certificate (PEM format) */
|
|
1923
|
-
certificate:
|
|
1766
|
+
certificate: import_zod2.z.string(),
|
|
1924
1767
|
/** Private key (PEM format) */
|
|
1925
|
-
privateKey:
|
|
1768
|
+
privateKey: import_zod2.z.string(),
|
|
1926
1769
|
/** Passphrase if private key is encrypted */
|
|
1927
|
-
passphrase:
|
|
1770
|
+
passphrase: import_zod2.z.string().optional(),
|
|
1928
1771
|
/** CA certificate chain (optional) */
|
|
1929
|
-
caCertificate:
|
|
1772
|
+
caCertificate: import_zod2.z.string().optional()
|
|
1930
1773
|
});
|
|
1931
|
-
var customCredentialSchema =
|
|
1932
|
-
type:
|
|
1774
|
+
var customCredentialSchema = import_zod2.z.object({
|
|
1775
|
+
type: import_zod2.z.literal("custom"),
|
|
1933
1776
|
/** Custom type identifier */
|
|
1934
|
-
customType:
|
|
1777
|
+
customType: import_zod2.z.string().min(1),
|
|
1935
1778
|
/** Arbitrary credential data */
|
|
1936
|
-
data:
|
|
1779
|
+
data: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
|
|
1937
1780
|
/** Headers to include in requests */
|
|
1938
|
-
headers:
|
|
1781
|
+
headers: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.string()).optional()
|
|
1939
1782
|
});
|
|
1940
|
-
var sshKeyCredentialSchema =
|
|
1941
|
-
type:
|
|
1783
|
+
var sshKeyCredentialSchema = import_zod2.z.object({
|
|
1784
|
+
type: import_zod2.z.literal("ssh_key"),
|
|
1942
1785
|
/** Private key (PEM format) */
|
|
1943
|
-
privateKey:
|
|
1786
|
+
privateKey: import_zod2.z.string().min(1),
|
|
1944
1787
|
/** Public key (optional, can be derived from private key) */
|
|
1945
|
-
publicKey:
|
|
1788
|
+
publicKey: import_zod2.z.string().optional(),
|
|
1946
1789
|
/** Passphrase if private key is encrypted */
|
|
1947
|
-
passphrase:
|
|
1790
|
+
passphrase: import_zod2.z.string().optional(),
|
|
1948
1791
|
/** Key type */
|
|
1949
|
-
keyType:
|
|
1792
|
+
keyType: import_zod2.z.enum(["rsa", "ed25519", "ecdsa", "dsa"]).default("ed25519"),
|
|
1950
1793
|
/** Key fingerprint (SHA256 hash) */
|
|
1951
|
-
fingerprint:
|
|
1794
|
+
fingerprint: import_zod2.z.string().optional(),
|
|
1952
1795
|
/** Username for SSH connections */
|
|
1953
|
-
username:
|
|
1796
|
+
username: import_zod2.z.string().optional()
|
|
1954
1797
|
});
|
|
1955
|
-
var serviceAccountCredentialSchema =
|
|
1956
|
-
type:
|
|
1798
|
+
var serviceAccountCredentialSchema = import_zod2.z.object({
|
|
1799
|
+
type: import_zod2.z.literal("service_account"),
|
|
1957
1800
|
/** Cloud provider */
|
|
1958
|
-
provider:
|
|
1801
|
+
provider: import_zod2.z.enum(["gcp", "aws", "azure", "custom"]),
|
|
1959
1802
|
/** Raw credentials (JSON key file content, access keys, etc.) */
|
|
1960
|
-
credentials:
|
|
1803
|
+
credentials: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()),
|
|
1961
1804
|
/** Project/Account ID */
|
|
1962
|
-
projectId:
|
|
1805
|
+
projectId: import_zod2.z.string().optional(),
|
|
1963
1806
|
/** Region for regional services */
|
|
1964
|
-
region:
|
|
1807
|
+
region: import_zod2.z.string().optional(),
|
|
1965
1808
|
/** AWS: Role ARN to assume */
|
|
1966
|
-
assumeRoleArn:
|
|
1809
|
+
assumeRoleArn: import_zod2.z.string().optional(),
|
|
1967
1810
|
/** AWS: External ID for cross-account access */
|
|
1968
|
-
externalId:
|
|
1811
|
+
externalId: import_zod2.z.string().optional(),
|
|
1969
1812
|
/** Service account email (GCP) or ARN (AWS) */
|
|
1970
|
-
serviceAccountId:
|
|
1813
|
+
serviceAccountId: import_zod2.z.string().optional(),
|
|
1971
1814
|
/** Expiration timestamp for temporary credentials */
|
|
1972
|
-
expiresAt:
|
|
1815
|
+
expiresAt: import_zod2.z.number().optional()
|
|
1973
1816
|
});
|
|
1974
|
-
var pkceOAuthCredentialSchema =
|
|
1975
|
-
type:
|
|
1817
|
+
var pkceOAuthCredentialSchema = import_zod2.z.object({
|
|
1818
|
+
type: import_zod2.z.literal("oauth_pkce"),
|
|
1976
1819
|
/** Access token */
|
|
1977
|
-
accessToken:
|
|
1820
|
+
accessToken: import_zod2.z.string(),
|
|
1978
1821
|
/** Refresh token (optional) */
|
|
1979
|
-
refreshToken:
|
|
1822
|
+
refreshToken: import_zod2.z.string().optional(),
|
|
1980
1823
|
/** Token type (usually 'Bearer') */
|
|
1981
|
-
tokenType:
|
|
1824
|
+
tokenType: import_zod2.z.string().default("Bearer"),
|
|
1982
1825
|
/** Token expiration timestamp (epoch ms) */
|
|
1983
|
-
expiresAt:
|
|
1826
|
+
expiresAt: import_zod2.z.number().optional(),
|
|
1984
1827
|
/** Granted scopes */
|
|
1985
|
-
scopes:
|
|
1828
|
+
scopes: import_zod2.z.array(import_zod2.z.string()).default([]),
|
|
1986
1829
|
/** ID token for OIDC (optional) */
|
|
1987
|
-
idToken:
|
|
1830
|
+
idToken: import_zod2.z.string().optional(),
|
|
1988
1831
|
/** Authorization server issuer */
|
|
1989
|
-
issuer:
|
|
1832
|
+
issuer: import_zod2.z.string().optional()
|
|
1990
1833
|
});
|
|
1991
|
-
var credentialSchema =
|
|
1834
|
+
var credentialSchema = import_zod2.z.discriminatedUnion("type", [
|
|
1992
1835
|
oauthCredentialSchema,
|
|
1993
1836
|
apiKeyCredentialSchema,
|
|
1994
1837
|
basicAuthCredentialSchema,
|
|
@@ -2000,117 +1843,117 @@ var credentialSchema = import_zod3.z.discriminatedUnion("type", [
|
|
|
2000
1843
|
serviceAccountCredentialSchema,
|
|
2001
1844
|
pkceOAuthCredentialSchema
|
|
2002
1845
|
]);
|
|
2003
|
-
var appCredentialSchema =
|
|
1846
|
+
var appCredentialSchema = import_zod2.z.object({
|
|
2004
1847
|
/** App ID this credential belongs to */
|
|
2005
|
-
appId:
|
|
1848
|
+
appId: import_zod2.z.string().min(1),
|
|
2006
1849
|
/** Provider ID within the app (for apps with multiple auth providers) */
|
|
2007
|
-
providerId:
|
|
1850
|
+
providerId: import_zod2.z.string().min(1),
|
|
2008
1851
|
/** The credential data */
|
|
2009
1852
|
credential: credentialSchema,
|
|
2010
1853
|
/** Timestamp when credential was acquired */
|
|
2011
|
-
acquiredAt:
|
|
1854
|
+
acquiredAt: import_zod2.z.number(),
|
|
2012
1855
|
/** Timestamp when credential was last used */
|
|
2013
|
-
lastUsedAt:
|
|
1856
|
+
lastUsedAt: import_zod2.z.number().optional(),
|
|
2014
1857
|
/** Credential expiration (if applicable) */
|
|
2015
|
-
expiresAt:
|
|
1858
|
+
expiresAt: import_zod2.z.number().optional(),
|
|
2016
1859
|
/** Whether this credential is currently valid */
|
|
2017
|
-
isValid:
|
|
1860
|
+
isValid: import_zod2.z.boolean().default(true),
|
|
2018
1861
|
/** Error message if credential is invalid */
|
|
2019
|
-
invalidReason:
|
|
1862
|
+
invalidReason: import_zod2.z.string().optional(),
|
|
2020
1863
|
/** User info associated with this credential */
|
|
2021
|
-
userInfo:
|
|
2022
|
-
sub:
|
|
2023
|
-
email:
|
|
2024
|
-
name:
|
|
1864
|
+
userInfo: import_zod2.z.object({
|
|
1865
|
+
sub: import_zod2.z.string().optional(),
|
|
1866
|
+
email: import_zod2.z.string().optional(),
|
|
1867
|
+
name: import_zod2.z.string().optional()
|
|
2025
1868
|
}).optional(),
|
|
2026
1869
|
/** Metadata for tracking/debugging */
|
|
2027
|
-
metadata:
|
|
1870
|
+
metadata: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()).optional()
|
|
2028
1871
|
});
|
|
2029
|
-
var vaultConsentRecordSchema =
|
|
1872
|
+
var vaultConsentRecordSchema = import_zod2.z.object({
|
|
2030
1873
|
/** Whether consent was enabled */
|
|
2031
|
-
enabled:
|
|
1874
|
+
enabled: import_zod2.z.boolean(),
|
|
2032
1875
|
/** Selected tool IDs (user approved these) */
|
|
2033
|
-
selectedToolIds:
|
|
1876
|
+
selectedToolIds: import_zod2.z.array(import_zod2.z.string()),
|
|
2034
1877
|
/** Available tool IDs at time of consent */
|
|
2035
|
-
availableToolIds:
|
|
1878
|
+
availableToolIds: import_zod2.z.array(import_zod2.z.string()),
|
|
2036
1879
|
/** Timestamp when consent was given */
|
|
2037
|
-
consentedAt:
|
|
1880
|
+
consentedAt: import_zod2.z.number(),
|
|
2038
1881
|
/** Consent version for tracking changes */
|
|
2039
|
-
version:
|
|
1882
|
+
version: import_zod2.z.string().default("1.0")
|
|
2040
1883
|
});
|
|
2041
|
-
var vaultFederatedRecordSchema =
|
|
1884
|
+
var vaultFederatedRecordSchema = import_zod2.z.object({
|
|
2042
1885
|
/** Provider IDs that were selected */
|
|
2043
|
-
selectedProviderIds:
|
|
1886
|
+
selectedProviderIds: import_zod2.z.array(import_zod2.z.string()),
|
|
2044
1887
|
/** Provider IDs that were skipped (can be authorized later) */
|
|
2045
|
-
skippedProviderIds:
|
|
1888
|
+
skippedProviderIds: import_zod2.z.array(import_zod2.z.string()),
|
|
2046
1889
|
/** Primary provider ID */
|
|
2047
|
-
primaryProviderId:
|
|
1890
|
+
primaryProviderId: import_zod2.z.string().optional(),
|
|
2048
1891
|
/** Timestamp when federated login was completed */
|
|
2049
|
-
completedAt:
|
|
1892
|
+
completedAt: import_zod2.z.number()
|
|
2050
1893
|
});
|
|
2051
|
-
var pendingIncrementalAuthSchema =
|
|
1894
|
+
var pendingIncrementalAuthSchema = import_zod2.z.object({
|
|
2052
1895
|
/** Unique ID for this request */
|
|
2053
|
-
id:
|
|
1896
|
+
id: import_zod2.z.string(),
|
|
2054
1897
|
/** App ID being authorized */
|
|
2055
|
-
appId:
|
|
1898
|
+
appId: import_zod2.z.string(),
|
|
2056
1899
|
/** Tool ID that triggered the auth request */
|
|
2057
|
-
toolId:
|
|
1900
|
+
toolId: import_zod2.z.string().optional(),
|
|
2058
1901
|
/** Authorization URL */
|
|
2059
|
-
authUrl:
|
|
1902
|
+
authUrl: import_zod2.z.string(),
|
|
2060
1903
|
/** Required scopes */
|
|
2061
|
-
requiredScopes:
|
|
1904
|
+
requiredScopes: import_zod2.z.array(import_zod2.z.string()).optional(),
|
|
2062
1905
|
/** Whether elicit is being used */
|
|
2063
|
-
elicitId:
|
|
1906
|
+
elicitId: import_zod2.z.string().optional(),
|
|
2064
1907
|
/** Timestamp when request was created */
|
|
2065
|
-
createdAt:
|
|
1908
|
+
createdAt: import_zod2.z.number(),
|
|
2066
1909
|
/** Expiration timestamp */
|
|
2067
|
-
expiresAt:
|
|
1910
|
+
expiresAt: import_zod2.z.number(),
|
|
2068
1911
|
/** Status of the request */
|
|
2069
|
-
status:
|
|
1912
|
+
status: import_zod2.z.enum(["pending", "completed", "cancelled", "expired"])
|
|
2070
1913
|
});
|
|
2071
|
-
var authorizationVaultEntrySchema =
|
|
1914
|
+
var authorizationVaultEntrySchema = import_zod2.z.object({
|
|
2072
1915
|
/** Vault ID (maps to access token jti claim) */
|
|
2073
|
-
id:
|
|
1916
|
+
id: import_zod2.z.string(),
|
|
2074
1917
|
/** User subject identifier */
|
|
2075
|
-
userSub:
|
|
1918
|
+
userSub: import_zod2.z.string(),
|
|
2076
1919
|
/** User email */
|
|
2077
|
-
userEmail:
|
|
1920
|
+
userEmail: import_zod2.z.string().optional(),
|
|
2078
1921
|
/** User name */
|
|
2079
|
-
userName:
|
|
1922
|
+
userName: import_zod2.z.string().optional(),
|
|
2080
1923
|
/** Client ID that created this session */
|
|
2081
|
-
clientId:
|
|
1924
|
+
clientId: import_zod2.z.string(),
|
|
2082
1925
|
/** Creation timestamp */
|
|
2083
|
-
createdAt:
|
|
1926
|
+
createdAt: import_zod2.z.number(),
|
|
2084
1927
|
/** Last access timestamp */
|
|
2085
|
-
lastAccessAt:
|
|
1928
|
+
lastAccessAt: import_zod2.z.number(),
|
|
2086
1929
|
/** App credentials (keyed by `${appId}:${providerId}`) */
|
|
2087
|
-
appCredentials:
|
|
1930
|
+
appCredentials: import_zod2.z.record(import_zod2.z.string(), appCredentialSchema).default({}),
|
|
2088
1931
|
/** Consent record */
|
|
2089
1932
|
consent: vaultConsentRecordSchema.optional(),
|
|
2090
1933
|
/** Federated login record */
|
|
2091
1934
|
federated: vaultFederatedRecordSchema.optional(),
|
|
2092
1935
|
/** Pending incremental authorization requests */
|
|
2093
|
-
pendingAuths:
|
|
1936
|
+
pendingAuths: import_zod2.z.array(pendingIncrementalAuthSchema),
|
|
2094
1937
|
/** Apps that are fully authorized */
|
|
2095
|
-
authorizedAppIds:
|
|
1938
|
+
authorizedAppIds: import_zod2.z.array(import_zod2.z.string()),
|
|
2096
1939
|
/** Apps that were skipped (not yet authorized) */
|
|
2097
|
-
skippedAppIds:
|
|
1940
|
+
skippedAppIds: import_zod2.z.array(import_zod2.z.string())
|
|
2098
1941
|
});
|
|
2099
1942
|
|
|
2100
1943
|
// libs/auth/src/session/vault-encryption.ts
|
|
2101
|
-
var
|
|
2102
|
-
var
|
|
2103
|
-
var encryptedDataSchema =
|
|
1944
|
+
var import_zod3 = require("zod");
|
|
1945
|
+
var import_utils5 = require("@frontmcp/utils");
|
|
1946
|
+
var encryptedDataSchema = import_zod3.z.object({
|
|
2104
1947
|
/** Version for future algorithm changes */
|
|
2105
|
-
v:
|
|
1948
|
+
v: import_zod3.z.literal(1),
|
|
2106
1949
|
/** Algorithm identifier */
|
|
2107
|
-
alg:
|
|
1950
|
+
alg: import_zod3.z.literal("aes-256-gcm"),
|
|
2108
1951
|
/** Initialization vector (base64) */
|
|
2109
|
-
iv:
|
|
1952
|
+
iv: import_zod3.z.string(),
|
|
2110
1953
|
/** Ciphertext (base64) */
|
|
2111
|
-
ct:
|
|
1954
|
+
ct: import_zod3.z.string(),
|
|
2112
1955
|
/** Authentication tag (base64) */
|
|
2113
|
-
tag:
|
|
1956
|
+
tag: import_zod3.z.string()
|
|
2114
1957
|
});
|
|
2115
1958
|
var VaultEncryption = class {
|
|
2116
1959
|
pepper;
|
|
@@ -2139,7 +1982,7 @@ var VaultEncryption = class {
|
|
|
2139
1982
|
];
|
|
2140
1983
|
const ikm = new TextEncoder().encode(ikmParts.join(""));
|
|
2141
1984
|
const infoBytes = new TextEncoder().encode(this.hkdfInfo);
|
|
2142
|
-
const key = await (0,
|
|
1985
|
+
const key = await (0, import_utils5.hkdfSha256)(ikm, new Uint8Array(0), infoBytes, 32);
|
|
2143
1986
|
return key;
|
|
2144
1987
|
}
|
|
2145
1988
|
/**
|
|
@@ -2166,7 +2009,7 @@ var VaultEncryption = class {
|
|
|
2166
2009
|
];
|
|
2167
2010
|
const ikm = new TextEncoder().encode(ikmParts.join(""));
|
|
2168
2011
|
const infoBytes = new TextEncoder().encode(this.hkdfInfo);
|
|
2169
|
-
const key = await (0,
|
|
2012
|
+
const key = await (0, import_utils5.hkdfSha256)(ikm, new Uint8Array(0), infoBytes, 32);
|
|
2170
2013
|
return key;
|
|
2171
2014
|
}
|
|
2172
2015
|
/**
|
|
@@ -2180,14 +2023,14 @@ var VaultEncryption = class {
|
|
|
2180
2023
|
if (key.length !== 32) {
|
|
2181
2024
|
throw new Error("Encryption key must be 32 bytes");
|
|
2182
2025
|
}
|
|
2183
|
-
const iv = (0,
|
|
2184
|
-
const { ciphertext, tag } = await (0,
|
|
2026
|
+
const iv = (0, import_utils5.randomBytes)(12);
|
|
2027
|
+
const { ciphertext, tag } = await (0, import_utils5.encryptAesGcm)(key, new TextEncoder().encode(plaintext), iv);
|
|
2185
2028
|
return {
|
|
2186
2029
|
v: 1,
|
|
2187
2030
|
alg: "aes-256-gcm",
|
|
2188
|
-
iv: (0,
|
|
2189
|
-
ct: (0,
|
|
2190
|
-
tag: (0,
|
|
2031
|
+
iv: (0, import_utils5.base64urlEncode)(iv),
|
|
2032
|
+
ct: (0, import_utils5.base64urlEncode)(ciphertext),
|
|
2033
|
+
tag: (0, import_utils5.base64urlEncode)(tag)
|
|
2191
2034
|
};
|
|
2192
2035
|
}
|
|
2193
2036
|
/**
|
|
@@ -2207,11 +2050,11 @@ var VaultEncryption = class {
|
|
|
2207
2050
|
throw new Error("Invalid encrypted data format");
|
|
2208
2051
|
}
|
|
2209
2052
|
const { iv, ct, tag } = parsed.data;
|
|
2210
|
-
const ivBuffer = (0,
|
|
2211
|
-
const ciphertext = (0,
|
|
2212
|
-
const tagBuffer = (0,
|
|
2053
|
+
const ivBuffer = (0, import_utils5.base64urlDecode)(iv);
|
|
2054
|
+
const ciphertext = (0, import_utils5.base64urlDecode)(ct);
|
|
2055
|
+
const tagBuffer = (0, import_utils5.base64urlDecode)(tag);
|
|
2213
2056
|
try {
|
|
2214
|
-
const plaintext = await (0,
|
|
2057
|
+
const plaintext = await (0, import_utils5.decryptAesGcm)(key, ciphertext, ivBuffer, tagBuffer);
|
|
2215
2058
|
return new TextDecoder().decode(plaintext);
|
|
2216
2059
|
} catch (_error) {
|
|
2217
2060
|
throw new Error("Decryption failed: invalid key or corrupted data");
|
|
@@ -2248,33 +2091,33 @@ var VaultEncryption = class {
|
|
|
2248
2091
|
return encryptedDataSchema.safeParse(data).success;
|
|
2249
2092
|
}
|
|
2250
2093
|
};
|
|
2251
|
-
var encryptedVaultEntrySchema =
|
|
2094
|
+
var encryptedVaultEntrySchema = import_zod3.z.object({
|
|
2252
2095
|
/** Vault ID (maps to JWT jti claim) */
|
|
2253
|
-
id:
|
|
2096
|
+
id: import_zod3.z.string(),
|
|
2254
2097
|
/** User subject identifier */
|
|
2255
|
-
userSub:
|
|
2098
|
+
userSub: import_zod3.z.string(),
|
|
2256
2099
|
/** User email (unencrypted for display) */
|
|
2257
|
-
userEmail:
|
|
2100
|
+
userEmail: import_zod3.z.string().optional(),
|
|
2258
2101
|
/** User name (unencrypted for display) */
|
|
2259
|
-
userName:
|
|
2102
|
+
userName: import_zod3.z.string().optional(),
|
|
2260
2103
|
/** Client ID that created this session */
|
|
2261
|
-
clientId:
|
|
2104
|
+
clientId: import_zod3.z.string(),
|
|
2262
2105
|
/** Creation timestamp */
|
|
2263
|
-
createdAt:
|
|
2106
|
+
createdAt: import_zod3.z.number(),
|
|
2264
2107
|
/** Last access timestamp */
|
|
2265
|
-
lastAccessAt:
|
|
2108
|
+
lastAccessAt: import_zod3.z.number(),
|
|
2266
2109
|
/** Encrypted sensitive data (provider tokens, credentials, consent) */
|
|
2267
2110
|
encryptedData: encryptedDataSchema,
|
|
2268
2111
|
/** Apps that are fully authorized (unencrypted for quick lookup) */
|
|
2269
|
-
authorizedAppIds:
|
|
2112
|
+
authorizedAppIds: import_zod3.z.array(import_zod3.z.string()),
|
|
2270
2113
|
/** Apps that were skipped (unencrypted for quick lookup) */
|
|
2271
|
-
skippedAppIds:
|
|
2114
|
+
skippedAppIds: import_zod3.z.array(import_zod3.z.string()),
|
|
2272
2115
|
/** Pending auth IDs (unencrypted for lookup, actual URLs encrypted) */
|
|
2273
|
-
pendingAuthIds:
|
|
2116
|
+
pendingAuthIds: import_zod3.z.array(import_zod3.z.string()).default([])
|
|
2274
2117
|
});
|
|
2275
2118
|
|
|
2276
2119
|
// libs/auth/src/session/token.vault.ts
|
|
2277
|
-
var
|
|
2120
|
+
var import_utils6 = require("@frontmcp/utils");
|
|
2278
2121
|
var TokenVault = class {
|
|
2279
2122
|
/** Active key used for new encryptions */
|
|
2280
2123
|
active;
|
|
@@ -2303,14 +2146,14 @@ var TokenVault = class {
|
|
|
2303
2146
|
this.keys.set(k.kid, k.key);
|
|
2304
2147
|
}
|
|
2305
2148
|
async encrypt(plaintext, opts) {
|
|
2306
|
-
const iv = (0,
|
|
2307
|
-
const { ciphertext, tag } = await (0,
|
|
2149
|
+
const iv = (0, import_utils6.randomBytes)(12);
|
|
2150
|
+
const { ciphertext, tag } = await (0, import_utils6.encryptAesGcm)(this.active.key, new TextEncoder().encode(plaintext), iv);
|
|
2308
2151
|
return {
|
|
2309
2152
|
alg: "A256GCM",
|
|
2310
2153
|
kid: this.active.kid,
|
|
2311
|
-
iv: (0,
|
|
2312
|
-
tag: (0,
|
|
2313
|
-
data: (0,
|
|
2154
|
+
iv: (0, import_utils6.base64urlEncode)(iv),
|
|
2155
|
+
tag: (0, import_utils6.base64urlEncode)(tag),
|
|
2156
|
+
data: (0, import_utils6.base64urlEncode)(ciphertext),
|
|
2314
2157
|
exp: opts?.exp,
|
|
2315
2158
|
meta: opts?.meta
|
|
2316
2159
|
};
|
|
@@ -2324,10 +2167,10 @@ var TokenVault = class {
|
|
|
2324
2167
|
}
|
|
2325
2168
|
const key = this.keys.get(blob.kid);
|
|
2326
2169
|
if (!key) throw new Error(`vault_unknown_kid:${blob.kid}`);
|
|
2327
|
-
const iv = (0,
|
|
2328
|
-
const tag = (0,
|
|
2329
|
-
const data = (0,
|
|
2330
|
-
const plaintext = await (0,
|
|
2170
|
+
const iv = (0, import_utils6.base64urlDecode)(blob.iv);
|
|
2171
|
+
const tag = (0, import_utils6.base64urlDecode)(blob.tag);
|
|
2172
|
+
const data = (0, import_utils6.base64urlDecode)(blob.data);
|
|
2173
|
+
const plaintext = await (0, import_utils6.decryptAesGcm)(key, data, iv, tag);
|
|
2331
2174
|
return new TextDecoder().decode(plaintext);
|
|
2332
2175
|
}
|
|
2333
2176
|
};
|
|
@@ -2336,102 +2179,103 @@ var TokenVault = class {
|
|
|
2336
2179
|
var import_utils25 = require("@frontmcp/utils");
|
|
2337
2180
|
|
|
2338
2181
|
// libs/auth/src/session/transport-session.types.ts
|
|
2339
|
-
var
|
|
2340
|
-
var transportProtocolSchema =
|
|
2182
|
+
var import_zod4 = require("zod");
|
|
2183
|
+
var transportProtocolSchema = import_zod4.z.enum([
|
|
2341
2184
|
"legacy-sse",
|
|
2342
2185
|
"sse",
|
|
2343
2186
|
"streamable-http",
|
|
2344
2187
|
"stateful-http",
|
|
2345
2188
|
"stateless-http"
|
|
2346
2189
|
]);
|
|
2347
|
-
var sseTransportStateSchema =
|
|
2348
|
-
type:
|
|
2349
|
-
lastEventId:
|
|
2350
|
-
lastPing:
|
|
2351
|
-
connectionState:
|
|
2190
|
+
var sseTransportStateSchema = import_zod4.z.object({
|
|
2191
|
+
type: import_zod4.z.literal("sse"),
|
|
2192
|
+
lastEventId: import_zod4.z.string().optional(),
|
|
2193
|
+
lastPing: import_zod4.z.number().optional(),
|
|
2194
|
+
connectionState: import_zod4.z.enum(["connecting", "open", "closed"]).optional()
|
|
2352
2195
|
});
|
|
2353
|
-
var streamableHttpTransportStateSchema =
|
|
2354
|
-
type:
|
|
2355
|
-
requestSeq:
|
|
2356
|
-
activeStreamId:
|
|
2357
|
-
pendingRequests:
|
|
2196
|
+
var streamableHttpTransportStateSchema = import_zod4.z.object({
|
|
2197
|
+
type: import_zod4.z.literal("streamable-http"),
|
|
2198
|
+
requestSeq: import_zod4.z.number(),
|
|
2199
|
+
activeStreamId: import_zod4.z.string().optional(),
|
|
2200
|
+
pendingRequests: import_zod4.z.array(import_zod4.z.string()).optional()
|
|
2358
2201
|
});
|
|
2359
|
-
var statefulHttpTransportStateSchema =
|
|
2360
|
-
type:
|
|
2361
|
-
requestSeq:
|
|
2362
|
-
pendingResponses:
|
|
2363
|
-
lastActivity:
|
|
2202
|
+
var statefulHttpTransportStateSchema = import_zod4.z.object({
|
|
2203
|
+
type: import_zod4.z.literal("stateful-http"),
|
|
2204
|
+
requestSeq: import_zod4.z.number(),
|
|
2205
|
+
pendingResponses: import_zod4.z.array(import_zod4.z.string()).optional(),
|
|
2206
|
+
lastActivity: import_zod4.z.number().optional()
|
|
2364
2207
|
});
|
|
2365
|
-
var statelessHttpTransportStateSchema =
|
|
2366
|
-
type:
|
|
2367
|
-
requestCount:
|
|
2368
|
-
windowStart:
|
|
2208
|
+
var statelessHttpTransportStateSchema = import_zod4.z.object({
|
|
2209
|
+
type: import_zod4.z.literal("stateless-http"),
|
|
2210
|
+
requestCount: import_zod4.z.number(),
|
|
2211
|
+
windowStart: import_zod4.z.number().optional()
|
|
2369
2212
|
});
|
|
2370
|
-
var legacySseTransportStateSchema =
|
|
2371
|
-
type:
|
|
2372
|
-
messagePath:
|
|
2373
|
-
lastEventId:
|
|
2374
|
-
connectionState:
|
|
2213
|
+
var legacySseTransportStateSchema = import_zod4.z.object({
|
|
2214
|
+
type: import_zod4.z.literal("legacy-sse"),
|
|
2215
|
+
messagePath: import_zod4.z.string(),
|
|
2216
|
+
lastEventId: import_zod4.z.string().optional(),
|
|
2217
|
+
connectionState: import_zod4.z.enum(["connecting", "open", "closed"]).optional()
|
|
2375
2218
|
});
|
|
2376
|
-
var transportStateSchema =
|
|
2219
|
+
var transportStateSchema = import_zod4.z.discriminatedUnion("type", [
|
|
2377
2220
|
sseTransportStateSchema,
|
|
2378
2221
|
streamableHttpTransportStateSchema,
|
|
2379
2222
|
statefulHttpTransportStateSchema,
|
|
2380
2223
|
statelessHttpTransportStateSchema,
|
|
2381
2224
|
legacySseTransportStateSchema
|
|
2382
2225
|
]);
|
|
2383
|
-
var transportSessionSchema =
|
|
2384
|
-
id:
|
|
2385
|
-
authorizationId:
|
|
2226
|
+
var transportSessionSchema = import_zod4.z.object({
|
|
2227
|
+
id: import_zod4.z.string(),
|
|
2228
|
+
authorizationId: import_zod4.z.string(),
|
|
2386
2229
|
protocol: transportProtocolSchema,
|
|
2387
|
-
createdAt:
|
|
2388
|
-
expiresAt:
|
|
2389
|
-
nodeId:
|
|
2390
|
-
clientFingerprint:
|
|
2230
|
+
createdAt: import_zod4.z.number(),
|
|
2231
|
+
expiresAt: import_zod4.z.number().optional(),
|
|
2232
|
+
nodeId: import_zod4.z.string(),
|
|
2233
|
+
clientFingerprint: import_zod4.z.string().optional(),
|
|
2391
2234
|
transportState: transportStateSchema.optional()
|
|
2392
2235
|
});
|
|
2393
|
-
var sessionJwtPayloadSchema =
|
|
2394
|
-
sid:
|
|
2395
|
-
aid:
|
|
2236
|
+
var sessionJwtPayloadSchema = import_zod4.z.object({
|
|
2237
|
+
sid: import_zod4.z.string(),
|
|
2238
|
+
aid: import_zod4.z.string(),
|
|
2396
2239
|
proto: transportProtocolSchema,
|
|
2397
|
-
nid:
|
|
2398
|
-
iat:
|
|
2399
|
-
exp:
|
|
2240
|
+
nid: import_zod4.z.string(),
|
|
2241
|
+
iat: import_zod4.z.number(),
|
|
2242
|
+
exp: import_zod4.z.number().optional()
|
|
2400
2243
|
});
|
|
2401
|
-
var encryptedBlobSchema =
|
|
2402
|
-
alg:
|
|
2403
|
-
kid:
|
|
2404
|
-
iv:
|
|
2405
|
-
tag:
|
|
2406
|
-
data:
|
|
2407
|
-
exp:
|
|
2408
|
-
meta:
|
|
2244
|
+
var encryptedBlobSchema = import_zod4.z.object({
|
|
2245
|
+
alg: import_zod4.z.literal("A256GCM"),
|
|
2246
|
+
kid: import_zod4.z.string().optional(),
|
|
2247
|
+
iv: import_zod4.z.string(),
|
|
2248
|
+
tag: import_zod4.z.string(),
|
|
2249
|
+
data: import_zod4.z.string(),
|
|
2250
|
+
exp: import_zod4.z.number().optional(),
|
|
2251
|
+
meta: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()).optional()
|
|
2409
2252
|
});
|
|
2410
|
-
var storedSessionSchema =
|
|
2253
|
+
var storedSessionSchema = import_zod4.z.object({
|
|
2411
2254
|
session: transportSessionSchema,
|
|
2412
|
-
authorizationId:
|
|
2413
|
-
tokens:
|
|
2414
|
-
createdAt:
|
|
2415
|
-
lastAccessedAt:
|
|
2416
|
-
initialized:
|
|
2417
|
-
maxLifetimeAt:
|
|
2255
|
+
authorizationId: import_zod4.z.string(),
|
|
2256
|
+
tokens: import_zod4.z.record(import_zod4.z.string(), encryptedBlobSchema).optional(),
|
|
2257
|
+
createdAt: import_zod4.z.number(),
|
|
2258
|
+
lastAccessedAt: import_zod4.z.number(),
|
|
2259
|
+
initialized: import_zod4.z.boolean().optional(),
|
|
2260
|
+
maxLifetimeAt: import_zod4.z.number().optional(),
|
|
2261
|
+
clientCapabilities: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()).optional()
|
|
2418
2262
|
});
|
|
2419
|
-
var redisConfigSchema =
|
|
2420
|
-
host:
|
|
2421
|
-
port:
|
|
2422
|
-
password:
|
|
2423
|
-
db:
|
|
2424
|
-
tls:
|
|
2425
|
-
keyPrefix:
|
|
2426
|
-
defaultTtlMs:
|
|
2263
|
+
var redisConfigSchema = import_zod4.z.object({
|
|
2264
|
+
host: import_zod4.z.string().min(1),
|
|
2265
|
+
port: import_zod4.z.number().int().positive().optional().default(6379),
|
|
2266
|
+
password: import_zod4.z.string().optional(),
|
|
2267
|
+
db: import_zod4.z.number().int().nonnegative().optional().default(0),
|
|
2268
|
+
tls: import_zod4.z.boolean().optional().default(false),
|
|
2269
|
+
keyPrefix: import_zod4.z.string().optional().default("mcp:session:"),
|
|
2270
|
+
defaultTtlMs: import_zod4.z.number().int().positive().optional().default(36e5)
|
|
2427
2271
|
// 1 hour default
|
|
2428
2272
|
});
|
|
2429
2273
|
|
|
2430
2274
|
// libs/auth/src/session/session-crypto.ts
|
|
2431
|
-
var
|
|
2275
|
+
var import_utils8 = require("@frontmcp/utils");
|
|
2432
2276
|
|
|
2433
2277
|
// libs/auth/src/errors/auth-internal.error.ts
|
|
2434
|
-
var
|
|
2278
|
+
var import_utils7 = require("@frontmcp/utils");
|
|
2435
2279
|
var AuthInternalError = class extends Error {
|
|
2436
2280
|
/**
|
|
2437
2281
|
* Unique error ID for tracking in logs.
|
|
@@ -2453,7 +2297,7 @@ var AuthInternalError = class extends Error {
|
|
|
2453
2297
|
super(message);
|
|
2454
2298
|
this.name = this.constructor.name;
|
|
2455
2299
|
this.code = code;
|
|
2456
|
-
this.errorId = `err_${(0,
|
|
2300
|
+
this.errorId = `err_${(0, import_utils7.bytesToHex)((0, import_utils7.randomBytes)(8))}`;
|
|
2457
2301
|
Error.captureStackTrace(this, this.constructor);
|
|
2458
2302
|
}
|
|
2459
2303
|
/**
|
|
@@ -2576,9 +2420,9 @@ var AuthFlowError = class extends AuthInternalError {
|
|
|
2576
2420
|
|
|
2577
2421
|
// libs/auth/src/session/session-crypto.ts
|
|
2578
2422
|
function getSigningSecret(config) {
|
|
2579
|
-
const secret = config?.secret ||
|
|
2423
|
+
const secret = config?.secret || (0, import_utils8.getEnv)("MCP_SESSION_SECRET");
|
|
2580
2424
|
if (!secret) {
|
|
2581
|
-
if (
|
|
2425
|
+
if ((0, import_utils8.isProduction)()) {
|
|
2582
2426
|
throw new SessionSecretRequiredError("session signing");
|
|
2583
2427
|
}
|
|
2584
2428
|
console.warn("[SessionCrypto] MCP_SESSION_SECRET not set. Using insecure default for development only.");
|
|
@@ -2590,13 +2434,13 @@ function resolveConfig(config) {
|
|
|
2590
2434
|
return { secret: getSigningSecret(config) };
|
|
2591
2435
|
}
|
|
2592
2436
|
function signSession(session, config) {
|
|
2593
|
-
return (0,
|
|
2437
|
+
return (0, import_utils8.signData)(session, resolveConfig(config));
|
|
2594
2438
|
}
|
|
2595
2439
|
function verifySession(signedData, config) {
|
|
2596
|
-
return (0,
|
|
2440
|
+
return (0, import_utils8.verifyData)(signedData, resolveConfig(config));
|
|
2597
2441
|
}
|
|
2598
2442
|
function verifyOrParseSession(data, config) {
|
|
2599
|
-
return (0,
|
|
2443
|
+
return (0, import_utils8.verifyOrParseData)(data, resolveConfig(config));
|
|
2600
2444
|
}
|
|
2601
2445
|
|
|
2602
2446
|
// libs/auth/src/session/session-rate-limiter.ts
|
|
@@ -2611,7 +2455,7 @@ var SessionRateLimiter = class {
|
|
|
2611
2455
|
const cleanupIntervalMs = config.cleanupIntervalMs ?? 6e4;
|
|
2612
2456
|
if (cleanupIntervalMs > 0) {
|
|
2613
2457
|
this.cleanupTimer = setInterval(() => this.cleanup(), cleanupIntervalMs);
|
|
2614
|
-
this.cleanupTimer.unref();
|
|
2458
|
+
if (typeof this.cleanupTimer.unref === "function") this.cleanupTimer.unref();
|
|
2615
2459
|
}
|
|
2616
2460
|
}
|
|
2617
2461
|
/**
|
|
@@ -2715,17 +2559,16 @@ var SessionRateLimiter = class {
|
|
|
2715
2559
|
var defaultSessionRateLimiter = new SessionRateLimiter();
|
|
2716
2560
|
|
|
2717
2561
|
// libs/auth/src/session/session.transport.ts
|
|
2718
|
-
var
|
|
2562
|
+
var import_utils9 = require("@frontmcp/utils");
|
|
2719
2563
|
var TransportIdGenerator = class {
|
|
2720
2564
|
/**
|
|
2721
2565
|
* Create a transport session ID.
|
|
2722
|
-
*
|
|
2566
|
+
* Generates JWT-style IDs for distributed session support.
|
|
2723
2567
|
*
|
|
2724
|
-
* @
|
|
2725
|
-
* @returns A JWT-style transport session ID (UUID without dashes)
|
|
2568
|
+
* @returns A transport session ID (UUID without dashes)
|
|
2726
2569
|
*/
|
|
2727
|
-
static createId(
|
|
2728
|
-
return (0,
|
|
2570
|
+
static createId() {
|
|
2571
|
+
return (0, import_utils9.randomUUID)().replace(/-/g, "");
|
|
2729
2572
|
}
|
|
2730
2573
|
};
|
|
2731
2574
|
|
|
@@ -2773,7 +2616,7 @@ var TinyTtlCache = class {
|
|
|
2773
2616
|
};
|
|
2774
2617
|
|
|
2775
2618
|
// libs/auth/src/session/utils/auth-token.utils.ts
|
|
2776
|
-
var
|
|
2619
|
+
var import_utils10 = require("@frontmcp/utils");
|
|
2777
2620
|
function isJwt(token) {
|
|
2778
2621
|
if (!token) return false;
|
|
2779
2622
|
return token.split(".").length === 3;
|
|
@@ -2783,7 +2626,7 @@ function getTokenSignatureFingerprint(token) {
|
|
|
2783
2626
|
const sig = token.split(".")[2];
|
|
2784
2627
|
if (sig) return sig;
|
|
2785
2628
|
}
|
|
2786
|
-
return (0,
|
|
2629
|
+
return (0, import_utils10.sha256Base64url)(token);
|
|
2787
2630
|
}
|
|
2788
2631
|
function extractClaimValue(claims, key, validator) {
|
|
2789
2632
|
const value = claims[key];
|
|
@@ -2815,18 +2658,20 @@ function extractBearerToken(header) {
|
|
|
2815
2658
|
}
|
|
2816
2659
|
|
|
2817
2660
|
// libs/auth/src/session/utils/session-crypto.utils.ts
|
|
2818
|
-
var
|
|
2661
|
+
var import_utils12 = require("@frontmcp/utils");
|
|
2819
2662
|
|
|
2820
2663
|
// libs/auth/src/machine-id/machine-id.ts
|
|
2821
|
-
var
|
|
2822
|
-
var import_utils12 = require("@frontmcp/utils");
|
|
2664
|
+
var import_utils11 = require("@frontmcp/utils");
|
|
2823
2665
|
var DEFAULT_MACHINE_ID_PATH = ".frontmcp/machine-id";
|
|
2824
2666
|
function isDevPersistenceEnabled() {
|
|
2825
|
-
|
|
2667
|
+
if ((0, import_utils11.isBrowser)()) return false;
|
|
2668
|
+
return !(0, import_utils11.isProduction)();
|
|
2826
2669
|
}
|
|
2827
2670
|
function resolveMachineIdPath() {
|
|
2828
|
-
|
|
2829
|
-
|
|
2671
|
+
if ((0, import_utils11.isBrowser)()) return DEFAULT_MACHINE_ID_PATH;
|
|
2672
|
+
const path = require("path");
|
|
2673
|
+
const machineIdPath = (0, import_utils11.getEnv)("MACHINE_ID_PATH") ?? DEFAULT_MACHINE_ID_PATH;
|
|
2674
|
+
return path.isAbsolute(machineIdPath) ? machineIdPath : path.resolve((0, import_utils11.getCwd)(), machineIdPath);
|
|
2830
2675
|
}
|
|
2831
2676
|
function loadMachineIdSync() {
|
|
2832
2677
|
if (!isDevPersistenceEnabled()) {
|
|
@@ -2834,7 +2679,7 @@ function loadMachineIdSync() {
|
|
|
2834
2679
|
}
|
|
2835
2680
|
const machineIdPath = resolveMachineIdPath();
|
|
2836
2681
|
try {
|
|
2837
|
-
const content = (0,
|
|
2682
|
+
const content = (0, import_utils11.readFileSync)(machineIdPath, "utf8").trim();
|
|
2838
2683
|
if (/^[0-9a-f-]{32,36}$/i.test(content)) {
|
|
2839
2684
|
return content;
|
|
2840
2685
|
}
|
|
@@ -2852,18 +2697,19 @@ function saveMachineIdAsync(machineId2) {
|
|
|
2852
2697
|
return;
|
|
2853
2698
|
}
|
|
2854
2699
|
const machineIdPath = resolveMachineIdPath();
|
|
2855
|
-
const
|
|
2700
|
+
const path = require("path");
|
|
2701
|
+
const dir = path.dirname(machineIdPath);
|
|
2856
2702
|
(async () => {
|
|
2857
2703
|
try {
|
|
2858
|
-
await (0,
|
|
2859
|
-
await (0,
|
|
2704
|
+
await (0, import_utils11.mkdir)(dir, { recursive: true, mode: 448 });
|
|
2705
|
+
await (0, import_utils11.writeFile)(machineIdPath, machineId2, { mode: 384 });
|
|
2860
2706
|
} catch (error) {
|
|
2861
2707
|
console.warn(`[MachineId] Failed to save to ${machineIdPath}: ${error.message}`);
|
|
2862
2708
|
}
|
|
2863
2709
|
})();
|
|
2864
2710
|
}
|
|
2865
2711
|
var machineId = (() => {
|
|
2866
|
-
const envMachineId =
|
|
2712
|
+
const envMachineId = (0, import_utils11.getEnv)("MACHINE_ID");
|
|
2867
2713
|
if (envMachineId) {
|
|
2868
2714
|
return envMachineId;
|
|
2869
2715
|
}
|
|
@@ -2871,7 +2717,7 @@ var machineId = (() => {
|
|
|
2871
2717
|
if (loadedId) {
|
|
2872
2718
|
return loadedId;
|
|
2873
2719
|
}
|
|
2874
|
-
const newId = (0,
|
|
2720
|
+
const newId = (0, import_utils11.randomUUID)();
|
|
2875
2721
|
saveMachineIdAsync(newId);
|
|
2876
2722
|
return newId;
|
|
2877
2723
|
})();
|
|
@@ -2887,10 +2733,9 @@ function setMachineIdOverride(id) {
|
|
|
2887
2733
|
var cachedKey = null;
|
|
2888
2734
|
function getKey() {
|
|
2889
2735
|
if (cachedKey) return cachedKey;
|
|
2890
|
-
const secret =
|
|
2891
|
-
const nodeEnv = process.env["NODE_ENV"];
|
|
2736
|
+
const secret = (0, import_utils12.getEnv)("MCP_SESSION_SECRET");
|
|
2892
2737
|
if (!secret) {
|
|
2893
|
-
if (
|
|
2738
|
+
if ((0, import_utils12.isProduction)()) {
|
|
2894
2739
|
throw new SessionSecretRequiredError("session ID encryption");
|
|
2895
2740
|
}
|
|
2896
2741
|
console.warn(
|
|
@@ -2898,12 +2743,12 @@ function getKey() {
|
|
|
2898
2743
|
);
|
|
2899
2744
|
}
|
|
2900
2745
|
const base = secret || getMachineId();
|
|
2901
|
-
cachedKey = (0,
|
|
2746
|
+
cachedKey = (0, import_utils12.sha256)(new TextEncoder().encode(base));
|
|
2902
2747
|
return cachedKey;
|
|
2903
2748
|
}
|
|
2904
2749
|
function encryptJson(obj) {
|
|
2905
2750
|
const key = getKey();
|
|
2906
|
-
const encrypted = (0,
|
|
2751
|
+
const encrypted = (0, import_utils12.encryptValue)(obj, key);
|
|
2907
2752
|
return `${encrypted.iv}.${encrypted.tag}.${encrypted.data}`;
|
|
2908
2753
|
}
|
|
2909
2754
|
function decryptSessionJson(sessionId) {
|
|
@@ -2912,7 +2757,7 @@ function decryptSessionJson(sessionId) {
|
|
|
2912
2757
|
const [ivB64, tagB64, ctB64] = parts;
|
|
2913
2758
|
if (!ivB64 || !tagB64 || !ctB64) return null;
|
|
2914
2759
|
const key = getKey();
|
|
2915
|
-
return (0,
|
|
2760
|
+
return (0, import_utils12.decryptValue)({ alg: "A256GCM", iv: ivB64, tag: tagB64, data: ctB64 }, key);
|
|
2916
2761
|
}
|
|
2917
2762
|
function safeDecrypt(sessionId) {
|
|
2918
2763
|
try {
|
|
@@ -2926,11 +2771,11 @@ function resetCachedKey() {
|
|
|
2926
2771
|
}
|
|
2927
2772
|
|
|
2928
2773
|
// libs/auth/src/session/storage/index.ts
|
|
2774
|
+
var import_utils16 = require("@frontmcp/utils");
|
|
2929
2775
|
var import_utils17 = require("@frontmcp/utils");
|
|
2930
|
-
var import_utils18 = require("@frontmcp/utils");
|
|
2931
2776
|
|
|
2932
2777
|
// libs/auth/src/session/storage/storage-token-store.ts
|
|
2933
|
-
var
|
|
2778
|
+
var import_utils13 = require("@frontmcp/utils");
|
|
2934
2779
|
var StorageTokenStore = class {
|
|
2935
2780
|
storage;
|
|
2936
2781
|
namespace;
|
|
@@ -2942,13 +2787,13 @@ var StorageTokenStore = class {
|
|
|
2942
2787
|
this.defaultTtlSeconds = options.defaultTtlSeconds;
|
|
2943
2788
|
this.storageIsNamespaced = "namespace" in storage && typeof storage.namespace === "function";
|
|
2944
2789
|
const namespacedStorage = this.storageIsNamespaced ? storage.namespace(this.namespace) : storage;
|
|
2945
|
-
this.storage = new
|
|
2790
|
+
this.storage = new import_utils13.TypedStorage(namespacedStorage);
|
|
2946
2791
|
}
|
|
2947
2792
|
/**
|
|
2948
2793
|
* Allocate a new unique ID for a token record.
|
|
2949
2794
|
*/
|
|
2950
2795
|
allocId() {
|
|
2951
|
-
return (0,
|
|
2796
|
+
return (0, import_utils13.randomUUID)();
|
|
2952
2797
|
}
|
|
2953
2798
|
/**
|
|
2954
2799
|
* Store an encrypted token blob.
|
|
@@ -3011,7 +2856,7 @@ var StorageTokenStore = class {
|
|
|
3011
2856
|
};
|
|
3012
2857
|
|
|
3013
2858
|
// libs/auth/src/session/storage/storage-authorization-vault.ts
|
|
3014
|
-
var
|
|
2859
|
+
var import_utils14 = require("@frontmcp/utils");
|
|
3015
2860
|
var StorageAuthorizationVault = class {
|
|
3016
2861
|
storage;
|
|
3017
2862
|
namespace;
|
|
@@ -3020,7 +2865,7 @@ var StorageAuthorizationVault = class {
|
|
|
3020
2865
|
this.namespace = options.namespace ?? "vault";
|
|
3021
2866
|
this.pendingAuthTtlMs = options.pendingAuthTtlMs ?? 10 * 60 * 1e3;
|
|
3022
2867
|
const namespacedStorage = this.isNamespacedStorage(storage) ? storage.namespace(this.namespace) : storage;
|
|
3023
|
-
this.storage = new
|
|
2868
|
+
this.storage = new import_utils14.TypedStorage(namespacedStorage, {
|
|
3024
2869
|
schema: options.validateOnRead ? authorizationVaultEntrySchema : void 0,
|
|
3025
2870
|
throwOnInvalid: false
|
|
3026
2871
|
});
|
|
@@ -3031,7 +2876,7 @@ var StorageAuthorizationVault = class {
|
|
|
3031
2876
|
async create(params) {
|
|
3032
2877
|
const now = Date.now();
|
|
3033
2878
|
const entry = {
|
|
3034
|
-
id: (0,
|
|
2879
|
+
id: (0, import_utils14.randomUUID)(),
|
|
3035
2880
|
userSub: params.userSub,
|
|
3036
2881
|
userEmail: params.userEmail,
|
|
3037
2882
|
userName: params.userName,
|
|
@@ -3105,7 +2950,7 @@ var StorageAuthorizationVault = class {
|
|
|
3105
2950
|
}
|
|
3106
2951
|
const now = Date.now();
|
|
3107
2952
|
const pendingAuth = {
|
|
3108
|
-
id: (0,
|
|
2953
|
+
id: (0, import_utils14.randomUUID)(),
|
|
3109
2954
|
appId: params.appId,
|
|
3110
2955
|
toolId: params.toolId,
|
|
3111
2956
|
authUrl: params.authUrl,
|
|
@@ -3309,11 +3154,11 @@ var StorageAuthorizationVault = class {
|
|
|
3309
3154
|
};
|
|
3310
3155
|
|
|
3311
3156
|
// libs/auth/src/session/storage/in-memory-authorization-vault.ts
|
|
3312
|
-
var
|
|
3157
|
+
var import_utils15 = require("@frontmcp/utils");
|
|
3313
3158
|
var InMemoryAuthorizationVault = class extends StorageAuthorizationVault {
|
|
3314
3159
|
memoryAdapter;
|
|
3315
3160
|
constructor(options = {}) {
|
|
3316
|
-
const memoryAdapter = new
|
|
3161
|
+
const memoryAdapter = new import_utils15.MemoryStorageAdapter();
|
|
3317
3162
|
super(memoryAdapter, {
|
|
3318
3163
|
namespace: options.namespace ?? "vault",
|
|
3319
3164
|
pendingAuthTtlMs: options.pendingAuthTtlMs
|
|
@@ -3334,7 +3179,7 @@ var InMemoryAuthorizationVault = class extends StorageAuthorizationVault {
|
|
|
3334
3179
|
};
|
|
3335
3180
|
|
|
3336
3181
|
// libs/auth/src/session/redis-session.store.ts
|
|
3337
|
-
var
|
|
3182
|
+
var import_utils18 = require("@frontmcp/utils");
|
|
3338
3183
|
var RedisSessionStore = class {
|
|
3339
3184
|
storage;
|
|
3340
3185
|
keyPrefix;
|
|
@@ -3356,14 +3201,14 @@ var RedisSessionStore = class {
|
|
|
3356
3201
|
});
|
|
3357
3202
|
}
|
|
3358
3203
|
if ("redis" in config && config.redis) {
|
|
3359
|
-
this.storage = new
|
|
3204
|
+
this.storage = new import_utils18.RedisStorageAdapter({
|
|
3360
3205
|
client: config.redis,
|
|
3361
3206
|
keyPrefix: this.keyPrefix
|
|
3362
3207
|
});
|
|
3363
3208
|
this.externalInstance = true;
|
|
3364
3209
|
} else {
|
|
3365
3210
|
const redisConfig = config;
|
|
3366
|
-
this.storage = new
|
|
3211
|
+
this.storage = new import_utils18.RedisStorageAdapter({
|
|
3367
3212
|
config: {
|
|
3368
3213
|
host: redisConfig.host,
|
|
3369
3214
|
port: redisConfig.port ?? 6379,
|
|
@@ -3545,7 +3390,7 @@ var RedisSessionStore = class {
|
|
|
3545
3390
|
* Allocate a new session ID
|
|
3546
3391
|
*/
|
|
3547
3392
|
allocId() {
|
|
3548
|
-
return (0,
|
|
3393
|
+
return (0, import_utils18.randomUUID)();
|
|
3549
3394
|
}
|
|
3550
3395
|
/**
|
|
3551
3396
|
* Disconnect from Redis (only if we created the connection)
|
|
@@ -3581,7 +3426,7 @@ var RedisSessionStore = class {
|
|
|
3581
3426
|
};
|
|
3582
3427
|
|
|
3583
3428
|
// libs/auth/src/session/vercel-kv-session.store.ts
|
|
3584
|
-
var
|
|
3429
|
+
var import_utils19 = require("@frontmcp/utils");
|
|
3585
3430
|
var VercelKvSessionStore = class {
|
|
3586
3431
|
storage;
|
|
3587
3432
|
keyPrefix;
|
|
@@ -3601,7 +3446,7 @@ var VercelKvSessionStore = class {
|
|
|
3601
3446
|
maxRequests: this.security.rateLimiting?.maxRequests
|
|
3602
3447
|
});
|
|
3603
3448
|
}
|
|
3604
|
-
this.storage = new
|
|
3449
|
+
this.storage = new import_utils19.VercelKvStorageAdapter({
|
|
3605
3450
|
url: config.url,
|
|
3606
3451
|
token: config.token,
|
|
3607
3452
|
keyPrefix: this.keyPrefix
|
|
@@ -3775,7 +3620,7 @@ var VercelKvSessionStore = class {
|
|
|
3775
3620
|
* Allocate a new session ID
|
|
3776
3621
|
*/
|
|
3777
3622
|
allocId() {
|
|
3778
|
-
return (0,
|
|
3623
|
+
return (0, import_utils19.randomUUID)();
|
|
3779
3624
|
}
|
|
3780
3625
|
/**
|
|
3781
3626
|
* Disconnect from Vercel KV
|
|
@@ -3804,7 +3649,7 @@ var VercelKvSessionStore = class {
|
|
|
3804
3649
|
};
|
|
3805
3650
|
|
|
3806
3651
|
// libs/auth/src/session/orchestrated-token.store.ts
|
|
3807
|
-
var
|
|
3652
|
+
var import_utils20 = require("@frontmcp/utils");
|
|
3808
3653
|
var InMemoryOrchestratedTokenStore = class {
|
|
3809
3654
|
/** Token storage: Map<compositeKey, ProviderTokenRecord> */
|
|
3810
3655
|
tokens = /* @__PURE__ */ new Map();
|
|
@@ -3846,7 +3691,7 @@ var InMemoryOrchestratedTokenStore = class {
|
|
|
3846
3691
|
}
|
|
3847
3692
|
const info = new TextEncoder().encode(`orchestrated-token:${compositeKey}`);
|
|
3848
3693
|
const salt = new TextEncoder().encode("frontmcp-token-store");
|
|
3849
|
-
const derivedKey = (0,
|
|
3694
|
+
const derivedKey = (0, import_utils20.hkdfSha256)(this.encryptionKey, salt, info, 32);
|
|
3850
3695
|
this.derivedKeys.set(compositeKey, derivedKey);
|
|
3851
3696
|
return derivedKey;
|
|
3852
3697
|
}
|
|
@@ -3856,8 +3701,8 @@ var InMemoryOrchestratedTokenStore = class {
|
|
|
3856
3701
|
async encryptRecord(compositeKey, record) {
|
|
3857
3702
|
const key = await this.deriveKeyForRecord(compositeKey);
|
|
3858
3703
|
const plaintext = JSON.stringify(record);
|
|
3859
|
-
const iv = (0,
|
|
3860
|
-
const { ciphertext, tag } = (0,
|
|
3704
|
+
const iv = (0, import_utils20.randomBytes)(12);
|
|
3705
|
+
const { ciphertext, tag } = (0, import_utils20.encryptAesGcm)(key, new TextEncoder().encode(plaintext), iv);
|
|
3861
3706
|
return JSON.stringify({
|
|
3862
3707
|
iv: Buffer.from(iv).toString("base64url"),
|
|
3863
3708
|
tag: Buffer.from(tag).toString("base64url"),
|
|
@@ -3873,7 +3718,7 @@ var InMemoryOrchestratedTokenStore = class {
|
|
|
3873
3718
|
const ivBytes = Buffer.from(iv, "base64url");
|
|
3874
3719
|
const tagBytes = Buffer.from(tag, "base64url");
|
|
3875
3720
|
const ciphertextBytes = Buffer.from(data, "base64url");
|
|
3876
|
-
const plaintext = (0,
|
|
3721
|
+
const plaintext = (0, import_utils20.decryptAesGcm)(key, ciphertextBytes, ivBytes, tagBytes);
|
|
3877
3722
|
return JSON.parse(new TextDecoder().decode(plaintext));
|
|
3878
3723
|
}
|
|
3879
3724
|
/**
|
|
@@ -4075,7 +3920,7 @@ var InMemoryOrchestratedTokenStore = class {
|
|
|
4075
3920
|
};
|
|
4076
3921
|
|
|
4077
3922
|
// libs/auth/src/session/federated-auth.session.ts
|
|
4078
|
-
var
|
|
3923
|
+
var import_utils21 = require("@frontmcp/utils");
|
|
4079
3924
|
function toSessionRecord(session) {
|
|
4080
3925
|
return {
|
|
4081
3926
|
...session,
|
|
@@ -4150,7 +3995,7 @@ var InMemoryFederatedAuthSessionStore = class {
|
|
|
4150
3995
|
createSession(params) {
|
|
4151
3996
|
const now = Date.now();
|
|
4152
3997
|
return {
|
|
4153
|
-
id: (0,
|
|
3998
|
+
id: (0, import_utils21.randomUUID)(),
|
|
4154
3999
|
pendingAuthId: params.pendingAuthId,
|
|
4155
4000
|
clientId: params.clientId,
|
|
4156
4001
|
redirectUri: params.redirectUri,
|
|
@@ -4182,7 +4027,7 @@ var InMemoryFederatedAuthSessionStore = class {
|
|
|
4182
4027
|
function createFederatedAuthSession(params, ttlMs = 15 * 60 * 1e3) {
|
|
4183
4028
|
const now = Date.now();
|
|
4184
4029
|
return {
|
|
4185
|
-
id: (0,
|
|
4030
|
+
id: (0, import_utils21.randomUUID)(),
|
|
4186
4031
|
pendingAuthId: params.pendingAuthId,
|
|
4187
4032
|
clientId: params.clientId,
|
|
4188
4033
|
redirectUri: params.redirectUri,
|
|
@@ -4239,34 +4084,34 @@ function startNextProvider(session, pkce, state) {
|
|
|
4239
4084
|
}
|
|
4240
4085
|
|
|
4241
4086
|
// libs/auth/src/session/encrypted-authorization-vault.ts
|
|
4242
|
-
var
|
|
4087
|
+
var import_zod5 = require("zod");
|
|
4088
|
+
var import_utils22 = require("@frontmcp/utils");
|
|
4243
4089
|
var import_utils23 = require("@frontmcp/utils");
|
|
4244
|
-
var
|
|
4245
|
-
var redisVaultEntrySchema = import_zod6.z.object({
|
|
4090
|
+
var redisVaultEntrySchema = import_zod5.z.object({
|
|
4246
4091
|
/** Vault ID */
|
|
4247
|
-
id:
|
|
4092
|
+
id: import_zod5.z.string(),
|
|
4248
4093
|
/** User sub (for lookup) */
|
|
4249
|
-
userSub:
|
|
4094
|
+
userSub: import_zod5.z.string(),
|
|
4250
4095
|
/** User email (optional, for display) */
|
|
4251
|
-
userEmail:
|
|
4096
|
+
userEmail: import_zod5.z.string().optional(),
|
|
4252
4097
|
/** User name (optional, for display) */
|
|
4253
|
-
userName:
|
|
4098
|
+
userName: import_zod5.z.string().optional(),
|
|
4254
4099
|
/** Client ID */
|
|
4255
|
-
clientId:
|
|
4100
|
+
clientId: import_zod5.z.string(),
|
|
4256
4101
|
/** Creation timestamp */
|
|
4257
|
-
createdAt:
|
|
4102
|
+
createdAt: import_zod5.z.number(),
|
|
4258
4103
|
/** Last access timestamp */
|
|
4259
|
-
lastAccessAt:
|
|
4104
|
+
lastAccessAt: import_zod5.z.number(),
|
|
4260
4105
|
/** Authorized app IDs (unencrypted for quick auth checks) */
|
|
4261
|
-
authorizedAppIds:
|
|
4106
|
+
authorizedAppIds: import_zod5.z.array(import_zod5.z.string()),
|
|
4262
4107
|
/** Skipped app IDs (unencrypted for quick checks) */
|
|
4263
|
-
skippedAppIds:
|
|
4108
|
+
skippedAppIds: import_zod5.z.array(import_zod5.z.string()),
|
|
4264
4109
|
/** Pending auth request IDs (unencrypted for lookup) */
|
|
4265
|
-
pendingAuthIds:
|
|
4110
|
+
pendingAuthIds: import_zod5.z.array(import_zod5.z.string()),
|
|
4266
4111
|
/** Encrypted sensitive data blob */
|
|
4267
4112
|
encrypted: encryptedDataSchema
|
|
4268
4113
|
});
|
|
4269
|
-
var encryptionContextStorage = new
|
|
4114
|
+
var encryptionContextStorage = new import_utils23.AsyncLocalStorage();
|
|
4270
4115
|
var EncryptedRedisVault = class {
|
|
4271
4116
|
constructor(redis, encryption, namespace = "vault:") {
|
|
4272
4117
|
this.redis = redis;
|
|
@@ -4399,7 +4244,7 @@ var EncryptedRedisVault = class {
|
|
|
4399
4244
|
async create(params) {
|
|
4400
4245
|
const now = Date.now();
|
|
4401
4246
|
const entry = {
|
|
4402
|
-
id: (0,
|
|
4247
|
+
id: (0, import_utils22.randomUUID)(),
|
|
4403
4248
|
userSub: params.userSub,
|
|
4404
4249
|
userEmail: params.userEmail,
|
|
4405
4250
|
userName: params.userName,
|
|
@@ -4458,7 +4303,7 @@ var EncryptedRedisVault = class {
|
|
|
4458
4303
|
}
|
|
4459
4304
|
const now = Date.now();
|
|
4460
4305
|
const pendingAuth = {
|
|
4461
|
-
id: (0,
|
|
4306
|
+
id: (0, import_utils22.randomUUID)(),
|
|
4462
4307
|
appId: params.appId,
|
|
4463
4308
|
toolId: params.toolId,
|
|
4464
4309
|
authUrl: params.authUrl,
|
|
@@ -4667,37 +4512,37 @@ function tryJwtExp(token) {
|
|
|
4667
4512
|
}
|
|
4668
4513
|
|
|
4669
4514
|
// libs/auth/src/authorization/authorization.types.ts
|
|
4670
|
-
var
|
|
4671
|
-
var authModeSchema =
|
|
4672
|
-
var authUserSchema =
|
|
4673
|
-
sub:
|
|
4674
|
-
name:
|
|
4675
|
-
email:
|
|
4676
|
-
picture:
|
|
4677
|
-
anonymous:
|
|
4515
|
+
var import_zod6 = require("zod");
|
|
4516
|
+
var authModeSchema = import_zod6.z.enum(["public", "transparent", "orchestrated"]);
|
|
4517
|
+
var authUserSchema = import_zod6.z.object({
|
|
4518
|
+
sub: import_zod6.z.string(),
|
|
4519
|
+
name: import_zod6.z.string().optional(),
|
|
4520
|
+
email: import_zod6.z.string().email().optional(),
|
|
4521
|
+
picture: import_zod6.z.string().url().optional(),
|
|
4522
|
+
anonymous: import_zod6.z.boolean().optional()
|
|
4678
4523
|
});
|
|
4679
|
-
var authorizedToolSchema =
|
|
4680
|
-
executionPath:
|
|
4681
|
-
scopes:
|
|
4682
|
-
details:
|
|
4524
|
+
var authorizedToolSchema = import_zod6.z.object({
|
|
4525
|
+
executionPath: import_zod6.z.tuple([import_zod6.z.string(), import_zod6.z.string()]),
|
|
4526
|
+
scopes: import_zod6.z.array(import_zod6.z.string()).optional(),
|
|
4527
|
+
details: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).optional()
|
|
4683
4528
|
});
|
|
4684
|
-
var authorizedPromptSchema =
|
|
4685
|
-
executionPath:
|
|
4686
|
-
scopes:
|
|
4687
|
-
details:
|
|
4529
|
+
var authorizedPromptSchema = import_zod6.z.object({
|
|
4530
|
+
executionPath: import_zod6.z.tuple([import_zod6.z.string(), import_zod6.z.string()]),
|
|
4531
|
+
scopes: import_zod6.z.array(import_zod6.z.string()).optional(),
|
|
4532
|
+
details: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).optional()
|
|
4688
4533
|
});
|
|
4689
|
-
var llmSafeAuthContextSchema =
|
|
4690
|
-
authorizationId:
|
|
4691
|
-
sessionId:
|
|
4534
|
+
var llmSafeAuthContextSchema = import_zod6.z.object({
|
|
4535
|
+
authorizationId: import_zod6.z.string(),
|
|
4536
|
+
sessionId: import_zod6.z.string(),
|
|
4692
4537
|
mode: authModeSchema,
|
|
4693
|
-
isAnonymous:
|
|
4694
|
-
user:
|
|
4695
|
-
sub:
|
|
4696
|
-
name:
|
|
4538
|
+
isAnonymous: import_zod6.z.boolean(),
|
|
4539
|
+
user: import_zod6.z.object({
|
|
4540
|
+
sub: import_zod6.z.string(),
|
|
4541
|
+
name: import_zod6.z.string().optional()
|
|
4697
4542
|
}),
|
|
4698
|
-
scopes:
|
|
4699
|
-
authorizedToolIds:
|
|
4700
|
-
authorizedPromptIds:
|
|
4543
|
+
scopes: import_zod6.z.array(import_zod6.z.string()),
|
|
4544
|
+
authorizedToolIds: import_zod6.z.array(import_zod6.z.string()),
|
|
4545
|
+
authorizedPromptIds: import_zod6.z.array(import_zod6.z.string())
|
|
4701
4546
|
});
|
|
4702
4547
|
var AppAuthState = /* @__PURE__ */ ((AppAuthState2) => {
|
|
4703
4548
|
AppAuthState2["AUTHORIZED"] = "authorized";
|
|
@@ -4705,19 +4550,19 @@ var AppAuthState = /* @__PURE__ */ ((AppAuthState2) => {
|
|
|
4705
4550
|
AppAuthState2["PENDING"] = "pending";
|
|
4706
4551
|
return AppAuthState2;
|
|
4707
4552
|
})(AppAuthState || {});
|
|
4708
|
-
var appAuthStateSchema =
|
|
4709
|
-
var appAuthorizationRecordSchema =
|
|
4710
|
-
appId:
|
|
4553
|
+
var appAuthStateSchema = import_zod6.z.nativeEnum(AppAuthState);
|
|
4554
|
+
var appAuthorizationRecordSchema = import_zod6.z.object({
|
|
4555
|
+
appId: import_zod6.z.string(),
|
|
4711
4556
|
state: appAuthStateSchema,
|
|
4712
|
-
stateChangedAt:
|
|
4713
|
-
grantedScopes:
|
|
4714
|
-
authProviderId:
|
|
4715
|
-
toolIds:
|
|
4557
|
+
stateChangedAt: import_zod6.z.number(),
|
|
4558
|
+
grantedScopes: import_zod6.z.array(import_zod6.z.string()).optional(),
|
|
4559
|
+
authProviderId: import_zod6.z.string().optional(),
|
|
4560
|
+
toolIds: import_zod6.z.array(import_zod6.z.string())
|
|
4716
4561
|
});
|
|
4717
|
-
var progressiveAuthStateSchema =
|
|
4718
|
-
apps:
|
|
4719
|
-
initiallyAuthorized:
|
|
4720
|
-
initiallySkipped:
|
|
4562
|
+
var progressiveAuthStateSchema = import_zod6.z.object({
|
|
4563
|
+
apps: import_zod6.z.record(import_zod6.z.string(), appAuthorizationRecordSchema),
|
|
4564
|
+
initiallyAuthorized: import_zod6.z.array(import_zod6.z.string()),
|
|
4565
|
+
initiallySkipped: import_zod6.z.array(import_zod6.z.string())
|
|
4721
4566
|
});
|
|
4722
4567
|
|
|
4723
4568
|
// libs/auth/src/authorization/authorization.class.ts
|
|
@@ -5576,42 +5421,42 @@ var OrchestratedAuthAccessorAdapter = class {
|
|
|
5576
5421
|
};
|
|
5577
5422
|
|
|
5578
5423
|
// libs/auth/src/common/jwt.types.ts
|
|
5579
|
-
var
|
|
5580
|
-
var jwkParametersSchema =
|
|
5581
|
-
kty:
|
|
5582
|
-
alg:
|
|
5583
|
-
key_ops:
|
|
5584
|
-
ext:
|
|
5585
|
-
use:
|
|
5586
|
-
x5c:
|
|
5587
|
-
x5t:
|
|
5588
|
-
"x5t#S256":
|
|
5589
|
-
x5u:
|
|
5590
|
-
kid:
|
|
5424
|
+
var import_zod7 = require("zod");
|
|
5425
|
+
var jwkParametersSchema = import_zod7.z.object({
|
|
5426
|
+
kty: import_zod7.z.string().optional(),
|
|
5427
|
+
alg: import_zod7.z.string().optional(),
|
|
5428
|
+
key_ops: import_zod7.z.array(import_zod7.z.string()).optional(),
|
|
5429
|
+
ext: import_zod7.z.boolean().optional(),
|
|
5430
|
+
use: import_zod7.z.string().optional(),
|
|
5431
|
+
x5c: import_zod7.z.array(import_zod7.z.string()).optional(),
|
|
5432
|
+
x5t: import_zod7.z.string().optional(),
|
|
5433
|
+
"x5t#S256": import_zod7.z.string().optional(),
|
|
5434
|
+
x5u: import_zod7.z.string().optional(),
|
|
5435
|
+
kid: import_zod7.z.string().optional()
|
|
5591
5436
|
});
|
|
5592
5437
|
var jwkSchema = jwkParametersSchema.extend({
|
|
5593
|
-
crv:
|
|
5594
|
-
d:
|
|
5595
|
-
dp:
|
|
5596
|
-
dq:
|
|
5597
|
-
e:
|
|
5598
|
-
k:
|
|
5599
|
-
n:
|
|
5600
|
-
p:
|
|
5601
|
-
q:
|
|
5602
|
-
qi:
|
|
5603
|
-
x:
|
|
5604
|
-
y:
|
|
5605
|
-
pub:
|
|
5606
|
-
priv:
|
|
5438
|
+
crv: import_zod7.z.string().optional(),
|
|
5439
|
+
d: import_zod7.z.string().optional(),
|
|
5440
|
+
dp: import_zod7.z.string().optional(),
|
|
5441
|
+
dq: import_zod7.z.string().optional(),
|
|
5442
|
+
e: import_zod7.z.string().optional(),
|
|
5443
|
+
k: import_zod7.z.string().optional(),
|
|
5444
|
+
n: import_zod7.z.string().optional(),
|
|
5445
|
+
p: import_zod7.z.string().optional(),
|
|
5446
|
+
q: import_zod7.z.string().optional(),
|
|
5447
|
+
qi: import_zod7.z.string().optional(),
|
|
5448
|
+
x: import_zod7.z.string().optional(),
|
|
5449
|
+
y: import_zod7.z.string().optional(),
|
|
5450
|
+
pub: import_zod7.z.string().optional(),
|
|
5451
|
+
priv: import_zod7.z.string().optional()
|
|
5607
5452
|
});
|
|
5608
|
-
var jsonWebKeySetSchema =
|
|
5609
|
-
keys:
|
|
5453
|
+
var jsonWebKeySetSchema = import_zod7.z.object({
|
|
5454
|
+
keys: import_zod7.z.array(jwkSchema)
|
|
5610
5455
|
});
|
|
5611
5456
|
|
|
5612
5457
|
// libs/auth/src/common/session.types.ts
|
|
5613
|
-
var
|
|
5614
|
-
var aiPlatformTypeSchema =
|
|
5458
|
+
var import_zod8 = require("zod");
|
|
5459
|
+
var aiPlatformTypeSchema = import_zod8.z.enum([
|
|
5615
5460
|
"openai",
|
|
5616
5461
|
"claude",
|
|
5617
5462
|
"gemini",
|
|
@@ -5622,45 +5467,45 @@ var aiPlatformTypeSchema = import_zod9.z.enum([
|
|
|
5622
5467
|
"ext-apps",
|
|
5623
5468
|
"unknown"
|
|
5624
5469
|
]);
|
|
5625
|
-
var userClaimSchema =
|
|
5626
|
-
iss:
|
|
5627
|
-
sid:
|
|
5628
|
-
sub:
|
|
5629
|
-
exp:
|
|
5630
|
-
iat:
|
|
5631
|
-
aud:
|
|
5632
|
-
email:
|
|
5633
|
-
username:
|
|
5634
|
-
preferred_username:
|
|
5635
|
-
name:
|
|
5636
|
-
picture:
|
|
5470
|
+
var userClaimSchema = import_zod8.z.object({
|
|
5471
|
+
iss: import_zod8.z.string(),
|
|
5472
|
+
sid: import_zod8.z.string().optional(),
|
|
5473
|
+
sub: import_zod8.z.string(),
|
|
5474
|
+
exp: import_zod8.z.number().optional(),
|
|
5475
|
+
iat: import_zod8.z.number().optional(),
|
|
5476
|
+
aud: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.array(import_zod8.z.string())]).optional(),
|
|
5477
|
+
email: import_zod8.z.string().optional(),
|
|
5478
|
+
username: import_zod8.z.string().optional(),
|
|
5479
|
+
preferred_username: import_zod8.z.string().optional(),
|
|
5480
|
+
name: import_zod8.z.string().optional(),
|
|
5481
|
+
picture: import_zod8.z.string().optional()
|
|
5637
5482
|
}).passthrough();
|
|
5638
|
-
var sessionIdPayloadSchema =
|
|
5639
|
-
nodeId:
|
|
5640
|
-
authSig:
|
|
5641
|
-
uuid:
|
|
5642
|
-
iat:
|
|
5643
|
-
protocol:
|
|
5644
|
-
isPublic:
|
|
5483
|
+
var sessionIdPayloadSchema = import_zod8.z.object({
|
|
5484
|
+
nodeId: import_zod8.z.string(),
|
|
5485
|
+
authSig: import_zod8.z.string(),
|
|
5486
|
+
uuid: import_zod8.z.string().uuid(),
|
|
5487
|
+
iat: import_zod8.z.number(),
|
|
5488
|
+
protocol: import_zod8.z.enum(["legacy-sse", "sse", "streamable-http", "stateful-http", "stateless-http"]).optional(),
|
|
5489
|
+
isPublic: import_zod8.z.boolean().optional(),
|
|
5645
5490
|
platformType: aiPlatformTypeSchema.optional(),
|
|
5646
|
-
clientName:
|
|
5647
|
-
clientVersion:
|
|
5648
|
-
supportsElicitation:
|
|
5649
|
-
skillsOnlyMode:
|
|
5491
|
+
clientName: import_zod8.z.string().optional(),
|
|
5492
|
+
clientVersion: import_zod8.z.string().optional(),
|
|
5493
|
+
supportsElicitation: import_zod8.z.boolean().optional(),
|
|
5494
|
+
skillsOnlyMode: import_zod8.z.boolean().optional()
|
|
5650
5495
|
});
|
|
5651
|
-
var sessionIdSchema =
|
|
5652
|
-
id:
|
|
5496
|
+
var sessionIdSchema = import_zod8.z.object({
|
|
5497
|
+
id: import_zod8.z.string(),
|
|
5653
5498
|
/** Payload is optional - may be undefined when session validation failed but ID is passed for transport lookup */
|
|
5654
5499
|
payload: sessionIdPayloadSchema.optional()
|
|
5655
5500
|
});
|
|
5656
|
-
var authorizationSchema =
|
|
5657
|
-
token:
|
|
5501
|
+
var authorizationSchema = import_zod8.z.object({
|
|
5502
|
+
token: import_zod8.z.string(),
|
|
5658
5503
|
session: sessionIdSchema.optional(),
|
|
5659
5504
|
user: userClaimSchema
|
|
5660
5505
|
});
|
|
5661
5506
|
|
|
5662
5507
|
// libs/auth/src/options/shared.schemas.ts
|
|
5663
|
-
var
|
|
5508
|
+
var import_zod10 = require("zod");
|
|
5664
5509
|
|
|
5665
5510
|
// libs/auth/src/cimd/cimd.logger.ts
|
|
5666
5511
|
var noopLogger = {
|
|
@@ -5676,169 +5521,169 @@ var noopLogger = {
|
|
|
5676
5521
|
};
|
|
5677
5522
|
|
|
5678
5523
|
// libs/auth/src/cimd/cimd.types.ts
|
|
5679
|
-
var
|
|
5680
|
-
var clientMetadataDocumentSchema =
|
|
5524
|
+
var import_zod9 = require("zod");
|
|
5525
|
+
var clientMetadataDocumentSchema = import_zod9.z.object({
|
|
5681
5526
|
// REQUIRED per CIMD spec
|
|
5682
5527
|
/**
|
|
5683
5528
|
* Client identifier - MUST match the URL from which this document was fetched.
|
|
5684
5529
|
*/
|
|
5685
|
-
client_id:
|
|
5530
|
+
client_id: import_zod9.z.string().url(),
|
|
5686
5531
|
/**
|
|
5687
5532
|
* Human-readable name of the client.
|
|
5688
5533
|
*/
|
|
5689
|
-
client_name:
|
|
5534
|
+
client_name: import_zod9.z.string().min(1),
|
|
5690
5535
|
/**
|
|
5691
5536
|
* Array of redirect URIs for authorization responses.
|
|
5692
5537
|
* At least one is required.
|
|
5693
5538
|
*/
|
|
5694
|
-
redirect_uris:
|
|
5539
|
+
redirect_uris: import_zod9.z.array(import_zod9.z.string().url()).min(1),
|
|
5695
5540
|
// OPTIONAL per RFC 7591
|
|
5696
5541
|
/**
|
|
5697
5542
|
* Token endpoint authentication method.
|
|
5698
5543
|
* @default 'none'
|
|
5699
5544
|
*/
|
|
5700
|
-
token_endpoint_auth_method:
|
|
5545
|
+
token_endpoint_auth_method: import_zod9.z.enum(["none", "client_secret_basic", "client_secret_post", "private_key_jwt"]).default("none"),
|
|
5701
5546
|
/**
|
|
5702
5547
|
* OAuth grant types the client can use.
|
|
5703
5548
|
* @default ['authorization_code']
|
|
5704
5549
|
*/
|
|
5705
|
-
grant_types:
|
|
5550
|
+
grant_types: import_zod9.z.array(import_zod9.z.string()).default(["authorization_code"]),
|
|
5706
5551
|
/**
|
|
5707
5552
|
* OAuth response types the client can request.
|
|
5708
5553
|
* @default ['code']
|
|
5709
5554
|
*/
|
|
5710
|
-
response_types:
|
|
5555
|
+
response_types: import_zod9.z.array(import_zod9.z.string()).default(["code"]),
|
|
5711
5556
|
/**
|
|
5712
5557
|
* URL of the client's home page.
|
|
5713
5558
|
*/
|
|
5714
|
-
client_uri:
|
|
5559
|
+
client_uri: import_zod9.z.string().url().optional(),
|
|
5715
5560
|
/**
|
|
5716
5561
|
* URL of the client's logo image.
|
|
5717
5562
|
*/
|
|
5718
|
-
logo_uri:
|
|
5563
|
+
logo_uri: import_zod9.z.string().url().optional(),
|
|
5719
5564
|
/**
|
|
5720
5565
|
* URL of the client's JWKS (for private_key_jwt).
|
|
5721
5566
|
*/
|
|
5722
|
-
jwks_uri:
|
|
5567
|
+
jwks_uri: import_zod9.z.string().url().optional(),
|
|
5723
5568
|
/**
|
|
5724
5569
|
* Inline JWKS (for private_key_jwt).
|
|
5725
5570
|
*/
|
|
5726
|
-
jwks:
|
|
5727
|
-
keys:
|
|
5571
|
+
jwks: import_zod9.z.object({
|
|
5572
|
+
keys: import_zod9.z.array(import_zod9.z.record(import_zod9.z.string(), import_zod9.z.unknown()))
|
|
5728
5573
|
}).optional(),
|
|
5729
5574
|
/**
|
|
5730
5575
|
* URL of the client's terms of service.
|
|
5731
5576
|
*/
|
|
5732
|
-
tos_uri:
|
|
5577
|
+
tos_uri: import_zod9.z.string().url().optional(),
|
|
5733
5578
|
/**
|
|
5734
5579
|
* URL of the client's privacy policy.
|
|
5735
5580
|
*/
|
|
5736
|
-
policy_uri:
|
|
5581
|
+
policy_uri: import_zod9.z.string().url().optional(),
|
|
5737
5582
|
/**
|
|
5738
5583
|
* Requested OAuth scopes.
|
|
5739
5584
|
*/
|
|
5740
|
-
scope:
|
|
5585
|
+
scope: import_zod9.z.string().optional(),
|
|
5741
5586
|
/**
|
|
5742
5587
|
* Array of contact emails for the client.
|
|
5743
5588
|
*/
|
|
5744
|
-
contacts:
|
|
5589
|
+
contacts: import_zod9.z.array(import_zod9.z.string().email()).optional(),
|
|
5745
5590
|
/**
|
|
5746
5591
|
* Software statement (signed JWT).
|
|
5747
5592
|
*/
|
|
5748
|
-
software_statement:
|
|
5593
|
+
software_statement: import_zod9.z.string().optional(),
|
|
5749
5594
|
/**
|
|
5750
5595
|
* Unique identifier for the client software.
|
|
5751
5596
|
*/
|
|
5752
|
-
software_id:
|
|
5597
|
+
software_id: import_zod9.z.string().optional(),
|
|
5753
5598
|
/**
|
|
5754
5599
|
* Version of the client software.
|
|
5755
5600
|
*/
|
|
5756
|
-
software_version:
|
|
5601
|
+
software_version: import_zod9.z.string().optional()
|
|
5757
5602
|
});
|
|
5758
|
-
var cimdRedisCacheConfigSchema =
|
|
5603
|
+
var cimdRedisCacheConfigSchema = import_zod9.z.object({
|
|
5759
5604
|
/**
|
|
5760
5605
|
* Redis connection URL.
|
|
5761
5606
|
* e.g., "redis://user:pass@host:6379/0"
|
|
5762
5607
|
*/
|
|
5763
|
-
url:
|
|
5608
|
+
url: import_zod9.z.string().optional(),
|
|
5764
5609
|
/**
|
|
5765
5610
|
* Redis host.
|
|
5766
5611
|
*/
|
|
5767
|
-
host:
|
|
5612
|
+
host: import_zod9.z.string().optional(),
|
|
5768
5613
|
/**
|
|
5769
5614
|
* Redis port.
|
|
5770
5615
|
* @default 6379
|
|
5771
5616
|
*/
|
|
5772
|
-
port:
|
|
5617
|
+
port: import_zod9.z.number().optional(),
|
|
5773
5618
|
/**
|
|
5774
5619
|
* Redis password.
|
|
5775
5620
|
*/
|
|
5776
|
-
password:
|
|
5621
|
+
password: import_zod9.z.string().optional(),
|
|
5777
5622
|
/**
|
|
5778
5623
|
* Redis database number.
|
|
5779
5624
|
* @default 0
|
|
5780
5625
|
*/
|
|
5781
|
-
db:
|
|
5626
|
+
db: import_zod9.z.number().optional(),
|
|
5782
5627
|
/**
|
|
5783
5628
|
* Enable TLS for Redis connection.
|
|
5784
5629
|
* @default false
|
|
5785
5630
|
*/
|
|
5786
|
-
tls:
|
|
5631
|
+
tls: import_zod9.z.boolean().optional(),
|
|
5787
5632
|
/**
|
|
5788
5633
|
* Key prefix for CIMD cache entries.
|
|
5789
5634
|
* @default 'cimd:'
|
|
5790
5635
|
*/
|
|
5791
|
-
keyPrefix:
|
|
5636
|
+
keyPrefix: import_zod9.z.string().default("cimd:")
|
|
5792
5637
|
});
|
|
5793
|
-
var cimdCacheConfigSchema =
|
|
5638
|
+
var cimdCacheConfigSchema = import_zod9.z.object({
|
|
5794
5639
|
/**
|
|
5795
5640
|
* Cache storage type.
|
|
5796
5641
|
* - 'memory': In-memory cache (default, suitable for dev/single-instance)
|
|
5797
5642
|
* - 'redis': Redis-backed cache (for production/distributed deployments)
|
|
5798
5643
|
* @default 'memory'
|
|
5799
5644
|
*/
|
|
5800
|
-
type:
|
|
5645
|
+
type: import_zod9.z.enum(["memory", "redis"]).default("memory"),
|
|
5801
5646
|
/**
|
|
5802
5647
|
* Default TTL for cached metadata documents.
|
|
5803
5648
|
* @default 3600000 (1 hour)
|
|
5804
5649
|
*/
|
|
5805
|
-
defaultTtlMs:
|
|
5650
|
+
defaultTtlMs: import_zod9.z.number().min(0).default(36e5),
|
|
5806
5651
|
/**
|
|
5807
5652
|
* Maximum TTL (even if server suggests longer).
|
|
5808
5653
|
* @default 86400000 (24 hours)
|
|
5809
5654
|
*/
|
|
5810
|
-
maxTtlMs:
|
|
5655
|
+
maxTtlMs: import_zod9.z.number().min(0).default(864e5),
|
|
5811
5656
|
/**
|
|
5812
5657
|
* Minimum TTL (even if server suggests shorter).
|
|
5813
5658
|
* @default 60000 (1 minute)
|
|
5814
5659
|
*/
|
|
5815
|
-
minTtlMs:
|
|
5660
|
+
minTtlMs: import_zod9.z.number().min(0).default(6e4),
|
|
5816
5661
|
/**
|
|
5817
5662
|
* Redis configuration (required when type is 'redis').
|
|
5818
5663
|
*/
|
|
5819
5664
|
redis: cimdRedisCacheConfigSchema.optional()
|
|
5820
5665
|
});
|
|
5821
|
-
var cimdSecurityConfigSchema =
|
|
5666
|
+
var cimdSecurityConfigSchema = import_zod9.z.object({
|
|
5822
5667
|
/**
|
|
5823
5668
|
* Block fetching from private/internal IP addresses (SSRF protection).
|
|
5824
5669
|
* @default true
|
|
5825
5670
|
*/
|
|
5826
|
-
blockPrivateIPs:
|
|
5671
|
+
blockPrivateIPs: import_zod9.z.boolean().default(true),
|
|
5827
5672
|
/**
|
|
5828
5673
|
* Explicit list of allowed domains.
|
|
5829
5674
|
* If set, only these domains can host CIMD documents.
|
|
5830
5675
|
*/
|
|
5831
|
-
allowedDomains:
|
|
5676
|
+
allowedDomains: import_zod9.z.array(import_zod9.z.string()).optional(),
|
|
5832
5677
|
/**
|
|
5833
5678
|
* Explicit list of blocked domains.
|
|
5834
5679
|
* These domains cannot host CIMD documents.
|
|
5835
5680
|
*/
|
|
5836
|
-
blockedDomains:
|
|
5681
|
+
blockedDomains: import_zod9.z.array(import_zod9.z.string()).optional(),
|
|
5837
5682
|
/**
|
|
5838
5683
|
* Warn when a client has only localhost redirect URIs.
|
|
5839
5684
|
* @default true
|
|
5840
5685
|
*/
|
|
5841
|
-
warnOnLocalhostRedirects:
|
|
5686
|
+
warnOnLocalhostRedirects: import_zod9.z.boolean().default(true),
|
|
5842
5687
|
/**
|
|
5843
5688
|
* Allow HTTP (instead of HTTPS) for localhost CIMD URLs.
|
|
5844
5689
|
*
|
|
@@ -5849,19 +5694,19 @@ var cimdSecurityConfigSchema = import_zod10.z.object({
|
|
|
5849
5694
|
*
|
|
5850
5695
|
* @default false
|
|
5851
5696
|
*/
|
|
5852
|
-
allowInsecureForTesting:
|
|
5697
|
+
allowInsecureForTesting: import_zod9.z.boolean().default(false)
|
|
5853
5698
|
});
|
|
5854
|
-
var cimdNetworkConfigSchema =
|
|
5699
|
+
var cimdNetworkConfigSchema = import_zod9.z.object({
|
|
5855
5700
|
/**
|
|
5856
5701
|
* Request timeout in milliseconds.
|
|
5857
5702
|
* @default 5000 (5 seconds)
|
|
5858
5703
|
*/
|
|
5859
|
-
timeoutMs:
|
|
5704
|
+
timeoutMs: import_zod9.z.number().min(100).default(5e3),
|
|
5860
5705
|
/**
|
|
5861
5706
|
* Maximum response body size in bytes.
|
|
5862
5707
|
* @default 65536 (64KB)
|
|
5863
5708
|
*/
|
|
5864
|
-
maxResponseSizeBytes:
|
|
5709
|
+
maxResponseSizeBytes: import_zod9.z.number().min(1024).default(65536),
|
|
5865
5710
|
/**
|
|
5866
5711
|
* Redirect handling policy for CIMD fetches.
|
|
5867
5712
|
* - 'deny': reject redirects (default, safest)
|
|
@@ -5869,19 +5714,19 @@ var cimdNetworkConfigSchema = import_zod10.z.object({
|
|
|
5869
5714
|
* - 'allow': allow redirects to any origin
|
|
5870
5715
|
* @default 'deny'
|
|
5871
5716
|
*/
|
|
5872
|
-
redirectPolicy:
|
|
5717
|
+
redirectPolicy: import_zod9.z.enum(["deny", "same-origin", "allow"]).default("deny"),
|
|
5873
5718
|
/**
|
|
5874
5719
|
* Maximum number of redirects to follow when redirects are allowed.
|
|
5875
5720
|
* @default 5
|
|
5876
5721
|
*/
|
|
5877
|
-
maxRedirects:
|
|
5722
|
+
maxRedirects: import_zod9.z.number().int().min(0).default(5)
|
|
5878
5723
|
});
|
|
5879
|
-
var cimdConfigSchema =
|
|
5724
|
+
var cimdConfigSchema = import_zod9.z.object({
|
|
5880
5725
|
/**
|
|
5881
5726
|
* Enable CIMD support.
|
|
5882
5727
|
* @default true
|
|
5883
5728
|
*/
|
|
5884
|
-
enabled:
|
|
5729
|
+
enabled: import_zod9.z.boolean().default(true),
|
|
5885
5730
|
/**
|
|
5886
5731
|
* Cache configuration.
|
|
5887
5732
|
*/
|
|
@@ -6244,7 +6089,7 @@ var CimdService = class {
|
|
|
6244
6089
|
this.cacheConfig = cimdCacheConfigSchema.parse(this.config.cache ?? {});
|
|
6245
6090
|
this.securityConfig = cimdSecurityConfigSchema.parse(this.config.security ?? {});
|
|
6246
6091
|
this.networkConfig = cimdNetworkConfigSchema.parse(this.config.network ?? {});
|
|
6247
|
-
this.cache = new
|
|
6092
|
+
this.cache = new InMemoryCimdCache(this.cacheConfig);
|
|
6248
6093
|
this.logger.debug("CimdService initialized", {
|
|
6249
6094
|
enabled: this.config.enabled,
|
|
6250
6095
|
cacheDefaultTtlMs: this.cacheConfig.defaultTtlMs,
|
|
@@ -6512,8 +6357,8 @@ var CimdService = class {
|
|
|
6512
6357
|
const result = clientMetadataDocumentSchema.safeParse(document);
|
|
6513
6358
|
if (!result.success) {
|
|
6514
6359
|
const errors = result.error.issues.map((issue) => {
|
|
6515
|
-
const
|
|
6516
|
-
return `${
|
|
6360
|
+
const path = issue.path.length > 0 ? `${issue.path.join(".")}: ` : "";
|
|
6361
|
+
return `${path}${issue.message}`;
|
|
6517
6362
|
});
|
|
6518
6363
|
throw new CimdValidationError(clientId, errors);
|
|
6519
6364
|
}
|
|
@@ -6535,55 +6380,84 @@ function normalizeRedirectUri(uri) {
|
|
|
6535
6380
|
}
|
|
6536
6381
|
|
|
6537
6382
|
// libs/auth/src/options/shared.schemas.ts
|
|
6538
|
-
var publicAccessConfigSchema =
|
|
6383
|
+
var publicAccessConfigSchema = import_zod10.z.object({
|
|
6539
6384
|
/**
|
|
6540
6385
|
* Allow all tools or explicit whitelist
|
|
6541
6386
|
* @default 'all'
|
|
6542
6387
|
*/
|
|
6543
|
-
tools:
|
|
6388
|
+
tools: import_zod10.z.union([import_zod10.z.literal("all"), import_zod10.z.array(import_zod10.z.string())]).default("all"),
|
|
6544
6389
|
/**
|
|
6545
6390
|
* Allow all prompts or explicit whitelist
|
|
6546
6391
|
* @default 'all'
|
|
6547
6392
|
*/
|
|
6548
|
-
prompts:
|
|
6393
|
+
prompts: import_zod10.z.union([import_zod10.z.literal("all"), import_zod10.z.array(import_zod10.z.string())]).default("all"),
|
|
6549
6394
|
/**
|
|
6550
6395
|
* Rate limit per IP per minute
|
|
6551
6396
|
* @default 60
|
|
6552
6397
|
*/
|
|
6553
|
-
rateLimit:
|
|
6398
|
+
rateLimit: import_zod10.z.number().default(60)
|
|
6554
6399
|
});
|
|
6555
|
-
var localSigningConfigSchema =
|
|
6400
|
+
var localSigningConfigSchema = import_zod10.z.object({
|
|
6556
6401
|
/**
|
|
6557
|
-
* Private key for signing
|
|
6402
|
+
* Private key for signing tokens
|
|
6558
6403
|
* @default auto-generated
|
|
6559
6404
|
*/
|
|
6560
|
-
signKey: jwkSchema.or(
|
|
6405
|
+
signKey: jwkSchema.or(import_zod10.z.instanceof(Uint8Array)).optional(),
|
|
6561
6406
|
/**
|
|
6562
6407
|
* JWKS for token verification
|
|
6563
6408
|
* @default auto-generated
|
|
6564
6409
|
*/
|
|
6565
6410
|
jwks: jsonWebKeySetSchema.optional(),
|
|
6566
6411
|
/**
|
|
6567
|
-
* Issuer identifier for
|
|
6412
|
+
* Issuer identifier for tokens
|
|
6568
6413
|
* @default auto-derived from server URL
|
|
6569
6414
|
*/
|
|
6570
|
-
issuer:
|
|
6415
|
+
issuer: import_zod10.z.string().optional()
|
|
6571
6416
|
});
|
|
6572
|
-
var
|
|
6417
|
+
var providerConfigSchema = import_zod10.z.object({
|
|
6418
|
+
/** Provider display name */
|
|
6419
|
+
name: import_zod10.z.string().optional(),
|
|
6420
|
+
/**
|
|
6421
|
+
* Unique identifier for this provider
|
|
6422
|
+
* @default derived from provider URL
|
|
6423
|
+
*/
|
|
6424
|
+
id: import_zod10.z.string().optional(),
|
|
6425
|
+
/**
|
|
6426
|
+
* Inline JWKS for offline token verification
|
|
6427
|
+
* Falls back to fetching from provider's /.well-known/jwks.json
|
|
6428
|
+
*/
|
|
6429
|
+
jwks: jsonWebKeySetSchema.optional(),
|
|
6430
|
+
/** Custom JWKS URI if not at standard path */
|
|
6431
|
+
jwksUri: import_zod10.z.string().url().optional(),
|
|
6432
|
+
/**
|
|
6433
|
+
* Enable Dynamic Client Registration (DCR)
|
|
6434
|
+
* @default false
|
|
6435
|
+
*/
|
|
6436
|
+
dcrEnabled: import_zod10.z.boolean().default(false),
|
|
6437
|
+
/** Authorization endpoint override */
|
|
6438
|
+
authEndpoint: import_zod10.z.string().url().optional(),
|
|
6439
|
+
/** Token endpoint override */
|
|
6440
|
+
tokenEndpoint: import_zod10.z.string().url().optional(),
|
|
6441
|
+
/** Registration endpoint override (for DCR) */
|
|
6442
|
+
registrationEndpoint: import_zod10.z.string().url().optional(),
|
|
6443
|
+
/** User info endpoint override */
|
|
6444
|
+
userInfoEndpoint: import_zod10.z.string().url().optional()
|
|
6445
|
+
});
|
|
6446
|
+
var remoteProviderConfigSchema = import_zod10.z.object({
|
|
6573
6447
|
/**
|
|
6574
6448
|
* OAuth provider base URL
|
|
6575
6449
|
* @example 'https://auth.example.com'
|
|
6576
6450
|
*/
|
|
6577
|
-
provider:
|
|
6451
|
+
provider: import_zod10.z.string().url(),
|
|
6578
6452
|
/**
|
|
6579
6453
|
* Provider display name
|
|
6580
6454
|
*/
|
|
6581
|
-
name:
|
|
6455
|
+
name: import_zod10.z.string().optional(),
|
|
6582
6456
|
/**
|
|
6583
6457
|
* Unique identifier for this provider
|
|
6584
6458
|
* @default derived from provider URL
|
|
6585
6459
|
*/
|
|
6586
|
-
id:
|
|
6460
|
+
id: import_zod10.z.string().optional(),
|
|
6587
6461
|
/**
|
|
6588
6462
|
* Inline JWKS for offline token verification
|
|
6589
6463
|
* Falls back to fetching from provider's /.well-known/jwks.json
|
|
@@ -6592,121 +6466,133 @@ var remoteProviderConfigSchema = import_zod11.z.object({
|
|
|
6592
6466
|
/**
|
|
6593
6467
|
* Custom JWKS URI if not at standard path
|
|
6594
6468
|
*/
|
|
6595
|
-
jwksUri:
|
|
6469
|
+
jwksUri: import_zod10.z.string().url().optional(),
|
|
6596
6470
|
/**
|
|
6597
|
-
* Client ID for this MCP server
|
|
6471
|
+
* Client ID for this MCP server
|
|
6598
6472
|
*/
|
|
6599
|
-
clientId:
|
|
6473
|
+
clientId: import_zod10.z.string().optional(),
|
|
6600
6474
|
/**
|
|
6601
|
-
* Client secret (for confidential clients
|
|
6475
|
+
* Client secret (for confidential clients)
|
|
6602
6476
|
*/
|
|
6603
|
-
clientSecret:
|
|
6477
|
+
clientSecret: import_zod10.z.string().optional(),
|
|
6604
6478
|
/**
|
|
6605
6479
|
* Scopes to request from the upstream provider
|
|
6606
6480
|
*/
|
|
6607
|
-
scopes:
|
|
6481
|
+
scopes: import_zod10.z.array(import_zod10.z.string()).optional(),
|
|
6608
6482
|
/**
|
|
6609
6483
|
* Enable Dynamic Client Registration (DCR)
|
|
6610
6484
|
* @default false
|
|
6611
6485
|
*/
|
|
6612
|
-
dcrEnabled:
|
|
6486
|
+
dcrEnabled: import_zod10.z.boolean().default(false),
|
|
6613
6487
|
/**
|
|
6614
6488
|
* Authorization endpoint override
|
|
6615
6489
|
*/
|
|
6616
|
-
authEndpoint:
|
|
6490
|
+
authEndpoint: import_zod10.z.string().url().optional(),
|
|
6617
6491
|
/**
|
|
6618
6492
|
* Token endpoint override
|
|
6619
6493
|
*/
|
|
6620
|
-
tokenEndpoint:
|
|
6494
|
+
tokenEndpoint: import_zod10.z.string().url().optional(),
|
|
6621
6495
|
/**
|
|
6622
6496
|
* Registration endpoint override (for DCR)
|
|
6623
6497
|
*/
|
|
6624
|
-
registrationEndpoint:
|
|
6498
|
+
registrationEndpoint: import_zod10.z.string().url().optional(),
|
|
6625
6499
|
/**
|
|
6626
6500
|
* User info endpoint override
|
|
6627
6501
|
*/
|
|
6628
|
-
userInfoEndpoint:
|
|
6502
|
+
userInfoEndpoint: import_zod10.z.string().url().optional()
|
|
6629
6503
|
});
|
|
6630
|
-
var
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6504
|
+
var flatRemoteProviderFields = {
|
|
6505
|
+
/**
|
|
6506
|
+
* OAuth provider base URL (required)
|
|
6507
|
+
* @example 'https://auth.example.com'
|
|
6508
|
+
*/
|
|
6509
|
+
provider: import_zod10.z.string().url(),
|
|
6510
|
+
/** Client ID for this MCP server */
|
|
6511
|
+
clientId: import_zod10.z.string().optional(),
|
|
6512
|
+
/** Client secret (for confidential clients) */
|
|
6513
|
+
clientSecret: import_zod10.z.string().optional(),
|
|
6514
|
+
/** Scopes to request from the upstream provider */
|
|
6515
|
+
scopes: import_zod10.z.array(import_zod10.z.string()).optional(),
|
|
6516
|
+
/** Advanced provider configuration */
|
|
6517
|
+
providerConfig: providerConfigSchema.optional()
|
|
6518
|
+
};
|
|
6519
|
+
var tokenStorageConfigSchema = import_zod10.z.union([import_zod10.z.literal("memory"), import_zod10.z.object({ redis: redisConfigSchema })]);
|
|
6520
|
+
var tokenRefreshConfigSchema = import_zod10.z.object({
|
|
6635
6521
|
/**
|
|
6636
6522
|
* Enable automatic token refresh
|
|
6637
6523
|
* @default true
|
|
6638
6524
|
*/
|
|
6639
|
-
enabled:
|
|
6525
|
+
enabled: import_zod10.z.boolean().default(true),
|
|
6640
6526
|
/**
|
|
6641
6527
|
* Refresh token before expiry by this many seconds
|
|
6642
6528
|
* @default 60
|
|
6643
6529
|
*/
|
|
6644
|
-
skewSeconds:
|
|
6530
|
+
skewSeconds: import_zod10.z.number().default(60)
|
|
6645
6531
|
});
|
|
6646
|
-
var skippedAppBehaviorSchema =
|
|
6647
|
-
var consentConfigSchema =
|
|
6532
|
+
var skippedAppBehaviorSchema = import_zod10.z.enum(["anonymous", "require-auth"]);
|
|
6533
|
+
var consentConfigSchema = import_zod10.z.object({
|
|
6648
6534
|
/**
|
|
6649
6535
|
* Enable consent flow for tool selection
|
|
6650
6536
|
* When enabled, users can choose which tools to expose to the LLM
|
|
6651
6537
|
* @default false
|
|
6652
6538
|
*/
|
|
6653
|
-
enabled:
|
|
6539
|
+
enabled: import_zod10.z.boolean().default(false),
|
|
6654
6540
|
/**
|
|
6655
6541
|
* Group tools by app in the consent UI
|
|
6656
6542
|
* @default true
|
|
6657
6543
|
*/
|
|
6658
|
-
groupByApp:
|
|
6544
|
+
groupByApp: import_zod10.z.boolean().default(true),
|
|
6659
6545
|
/**
|
|
6660
6546
|
* Show tool descriptions in consent UI
|
|
6661
6547
|
* @default true
|
|
6662
6548
|
*/
|
|
6663
|
-
showDescriptions:
|
|
6549
|
+
showDescriptions: import_zod10.z.boolean().default(true),
|
|
6664
6550
|
/**
|
|
6665
6551
|
* Allow selecting all tools at once
|
|
6666
6552
|
* @default true
|
|
6667
6553
|
*/
|
|
6668
|
-
allowSelectAll:
|
|
6554
|
+
allowSelectAll: import_zod10.z.boolean().default(true),
|
|
6669
6555
|
/**
|
|
6670
6556
|
* Require at least one tool to be selected
|
|
6671
6557
|
* @default true
|
|
6672
6558
|
*/
|
|
6673
|
-
requireSelection:
|
|
6559
|
+
requireSelection: import_zod10.z.boolean().default(true),
|
|
6674
6560
|
/**
|
|
6675
6561
|
* Custom message to display on consent page
|
|
6676
6562
|
*/
|
|
6677
|
-
customMessage:
|
|
6563
|
+
customMessage: import_zod10.z.string().optional(),
|
|
6678
6564
|
/**
|
|
6679
6565
|
* Remember consent for future sessions
|
|
6680
6566
|
* @default true
|
|
6681
6567
|
*/
|
|
6682
|
-
rememberConsent:
|
|
6568
|
+
rememberConsent: import_zod10.z.boolean().default(true),
|
|
6683
6569
|
/**
|
|
6684
6570
|
* Tools to exclude from consent (always available)
|
|
6685
6571
|
* Useful for essential tools that should always be accessible
|
|
6686
6572
|
*/
|
|
6687
|
-
excludedTools:
|
|
6573
|
+
excludedTools: import_zod10.z.array(import_zod10.z.string()).optional(),
|
|
6688
6574
|
/**
|
|
6689
6575
|
* Tools to always include in consent (pre-selected)
|
|
6690
6576
|
*/
|
|
6691
|
-
defaultSelectedTools:
|
|
6577
|
+
defaultSelectedTools: import_zod10.z.array(import_zod10.z.string()).optional()
|
|
6692
6578
|
});
|
|
6693
|
-
var federatedAuthConfigSchema =
|
|
6579
|
+
var federatedAuthConfigSchema = import_zod10.z.object({
|
|
6694
6580
|
/**
|
|
6695
6581
|
* How strictly to validate the OAuth state parameter on provider callbacks.
|
|
6696
6582
|
* - 'strict': require exact match to stored state (default, safest)
|
|
6697
6583
|
* - 'format': validate only "federated:{sessionId}:{nonce}" format
|
|
6698
6584
|
* @default 'strict'
|
|
6699
6585
|
*/
|
|
6700
|
-
stateValidation:
|
|
6586
|
+
stateValidation: import_zod10.z.enum(["strict", "format"]).default("strict")
|
|
6701
6587
|
});
|
|
6702
|
-
var incrementalAuthConfigSchema =
|
|
6588
|
+
var incrementalAuthConfigSchema = import_zod10.z.object({
|
|
6703
6589
|
/**
|
|
6704
6590
|
* Enable incremental (progressive) authorization
|
|
6705
6591
|
* When enabled, users can skip app authorizations during initial auth
|
|
6706
6592
|
* and authorize individual apps later when needed
|
|
6707
6593
|
* @default true
|
|
6708
6594
|
*/
|
|
6709
|
-
enabled:
|
|
6595
|
+
enabled: import_zod10.z.boolean().default(true),
|
|
6710
6596
|
/**
|
|
6711
6597
|
* Behavior when a tool from a skipped app is called
|
|
6712
6598
|
* - 'anonymous': If app supports anonymous access, use it; otherwise require auth
|
|
@@ -6718,33 +6604,33 @@ var incrementalAuthConfigSchema = import_zod11.z.object({
|
|
|
6718
6604
|
* Allow users to skip app authorization during initial auth flow
|
|
6719
6605
|
* @default true
|
|
6720
6606
|
*/
|
|
6721
|
-
allowSkip:
|
|
6607
|
+
allowSkip: import_zod10.z.boolean().default(true),
|
|
6722
6608
|
/**
|
|
6723
6609
|
* Show all apps in a single authorization page (vs step-by-step)
|
|
6724
6610
|
* @default true
|
|
6725
6611
|
*/
|
|
6726
|
-
showAllAppsAtOnce:
|
|
6612
|
+
showAllAppsAtOnce: import_zod10.z.boolean().default(true)
|
|
6727
6613
|
});
|
|
6728
6614
|
|
|
6729
6615
|
// libs/auth/src/options/public.schema.ts
|
|
6730
|
-
var
|
|
6731
|
-
var publicAuthOptionsSchema =
|
|
6732
|
-
mode:
|
|
6616
|
+
var import_zod11 = require("zod");
|
|
6617
|
+
var publicAuthOptionsSchema = import_zod11.z.object({
|
|
6618
|
+
mode: import_zod11.z.literal("public"),
|
|
6733
6619
|
/**
|
|
6734
6620
|
* Issuer identifier for anonymous JWTs
|
|
6735
6621
|
* @default auto-derived from server URL
|
|
6736
6622
|
*/
|
|
6737
|
-
issuer:
|
|
6623
|
+
issuer: import_zod11.z.string().optional(),
|
|
6738
6624
|
/**
|
|
6739
6625
|
* Anonymous session TTL in seconds
|
|
6740
6626
|
* @default 3600 (1 hour)
|
|
6741
6627
|
*/
|
|
6742
|
-
sessionTtl:
|
|
6628
|
+
sessionTtl: import_zod11.z.number().default(3600),
|
|
6743
6629
|
/**
|
|
6744
6630
|
* Scopes granted to anonymous sessions
|
|
6745
6631
|
* @default ['anonymous']
|
|
6746
6632
|
*/
|
|
6747
|
-
anonymousScopes:
|
|
6633
|
+
anonymousScopes: import_zod11.z.array(import_zod11.z.string()).default(["anonymous"]),
|
|
6748
6634
|
/**
|
|
6749
6635
|
* Tool/prompt access configuration for anonymous users
|
|
6750
6636
|
*/
|
|
@@ -6758,38 +6644,38 @@ var publicAuthOptionsSchema = import_zod12.z.object({
|
|
|
6758
6644
|
* Private key for signing anonymous tokens
|
|
6759
6645
|
* @default auto-generated
|
|
6760
6646
|
*/
|
|
6761
|
-
signKey: jwkSchema.or(
|
|
6647
|
+
signKey: jwkSchema.or(import_zod11.z.instanceof(Uint8Array)).optional()
|
|
6762
6648
|
});
|
|
6763
6649
|
|
|
6764
6650
|
// libs/auth/src/options/transparent.schema.ts
|
|
6765
|
-
var
|
|
6766
|
-
var transparentAuthOptionsSchema =
|
|
6767
|
-
mode:
|
|
6651
|
+
var import_zod12 = require("zod");
|
|
6652
|
+
var transparentAuthOptionsSchema = import_zod12.z.object({
|
|
6653
|
+
mode: import_zod12.z.literal("transparent"),
|
|
6768
6654
|
/**
|
|
6769
|
-
*
|
|
6655
|
+
* Flattened remote provider fields (provider, clientId, clientSecret, scopes, providerConfig)
|
|
6770
6656
|
*/
|
|
6771
|
-
|
|
6657
|
+
...flatRemoteProviderFields,
|
|
6772
6658
|
/**
|
|
6773
6659
|
* Expected token audience
|
|
6774
6660
|
* If not set, defaults to the resource URL
|
|
6775
6661
|
*/
|
|
6776
|
-
expectedAudience:
|
|
6662
|
+
expectedAudience: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.array(import_zod12.z.string())]).optional(),
|
|
6777
6663
|
/**
|
|
6778
6664
|
* Required scopes for access
|
|
6779
6665
|
* Empty array means any valid token is accepted
|
|
6780
6666
|
* @default []
|
|
6781
6667
|
*/
|
|
6782
|
-
requiredScopes:
|
|
6668
|
+
requiredScopes: import_zod12.z.array(import_zod12.z.string()).default([]),
|
|
6783
6669
|
/**
|
|
6784
6670
|
* Allow anonymous fallback when no token is provided
|
|
6785
6671
|
* @default false
|
|
6786
6672
|
*/
|
|
6787
|
-
allowAnonymous:
|
|
6673
|
+
allowAnonymous: import_zod12.z.boolean().default(false),
|
|
6788
6674
|
/**
|
|
6789
6675
|
* Scopes granted to anonymous sessions (when allowAnonymous=true)
|
|
6790
6676
|
* @default ['anonymous']
|
|
6791
6677
|
*/
|
|
6792
|
-
anonymousScopes:
|
|
6678
|
+
anonymousScopes: import_zod12.z.array(import_zod12.z.string()).default(["anonymous"]),
|
|
6793
6679
|
/**
|
|
6794
6680
|
* Public access config for anonymous users (when allowAnonymous=true)
|
|
6795
6681
|
*/
|
|
@@ -6797,56 +6683,52 @@ var transparentAuthOptionsSchema = import_zod13.z.object({
|
|
|
6797
6683
|
});
|
|
6798
6684
|
|
|
6799
6685
|
// libs/auth/src/options/orchestrated.schema.ts
|
|
6800
|
-
var
|
|
6801
|
-
var
|
|
6686
|
+
var import_zod13 = require("zod");
|
|
6687
|
+
var sharedAuthFields = {
|
|
6802
6688
|
local: localSigningConfigSchema.optional(),
|
|
6803
|
-
tokenStorage: tokenStorageConfigSchema.default(
|
|
6804
|
-
allowDefaultPublic:
|
|
6805
|
-
anonymousScopes:
|
|
6689
|
+
tokenStorage: tokenStorageConfigSchema.default("memory"),
|
|
6690
|
+
allowDefaultPublic: import_zod13.z.boolean().default(false),
|
|
6691
|
+
anonymousScopes: import_zod13.z.array(import_zod13.z.string()).default(["anonymous"]),
|
|
6806
6692
|
publicAccess: publicAccessConfigSchema.optional(),
|
|
6807
6693
|
consent: consentConfigSchema.optional(),
|
|
6808
6694
|
federatedAuth: federatedAuthConfigSchema.optional(),
|
|
6809
6695
|
refresh: tokenRefreshConfigSchema.optional(),
|
|
6810
|
-
expectedAudience:
|
|
6696
|
+
expectedAudience: import_zod13.z.union([import_zod13.z.string(), import_zod13.z.array(import_zod13.z.string())]).optional(),
|
|
6811
6697
|
incrementalAuth: incrementalAuthConfigSchema.optional(),
|
|
6812
6698
|
cimd: cimdConfigSchema.optional()
|
|
6813
6699
|
};
|
|
6814
|
-
var
|
|
6815
|
-
mode:
|
|
6816
|
-
|
|
6817
|
-
...orchestratedSharedFields
|
|
6700
|
+
var localAuthSchema = import_zod13.z.object({
|
|
6701
|
+
mode: import_zod13.z.literal("local"),
|
|
6702
|
+
...sharedAuthFields
|
|
6818
6703
|
});
|
|
6819
|
-
var
|
|
6820
|
-
mode:
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
...orchestratedSharedFields
|
|
6704
|
+
var remoteAuthSchema = import_zod13.z.object({
|
|
6705
|
+
mode: import_zod13.z.literal("remote"),
|
|
6706
|
+
...flatRemoteProviderFields,
|
|
6707
|
+
...sharedAuthFields
|
|
6824
6708
|
});
|
|
6825
|
-
var
|
|
6826
|
-
|
|
6827
|
-
orchestratedRemoteSchema
|
|
6828
|
-
]);
|
|
6709
|
+
var orchestratedLocalSchema = localAuthSchema;
|
|
6710
|
+
var orchestratedRemoteSchema = remoteAuthSchema;
|
|
6829
6711
|
|
|
6830
6712
|
// libs/auth/src/options/schema.ts
|
|
6831
|
-
var
|
|
6832
|
-
var authOptionsSchema =
|
|
6713
|
+
var import_zod14 = require("zod");
|
|
6714
|
+
var authOptionsSchema = import_zod14.z.union([
|
|
6833
6715
|
publicAuthOptionsSchema,
|
|
6834
6716
|
transparentAuthOptionsSchema,
|
|
6835
|
-
|
|
6836
|
-
|
|
6717
|
+
localAuthSchema,
|
|
6718
|
+
remoteAuthSchema
|
|
6837
6719
|
]);
|
|
6838
6720
|
|
|
6839
6721
|
// libs/auth/src/options/app-auth.schema.ts
|
|
6840
|
-
var
|
|
6722
|
+
var import_zod15 = require("zod");
|
|
6841
6723
|
var standaloneOptionSchema = {
|
|
6842
|
-
standalone:
|
|
6843
|
-
excludeFromParent:
|
|
6724
|
+
standalone: import_zod15.z.boolean().optional(),
|
|
6725
|
+
excludeFromParent: import_zod15.z.boolean().optional()
|
|
6844
6726
|
};
|
|
6845
|
-
var appAuthOptionsSchema =
|
|
6727
|
+
var appAuthOptionsSchema = import_zod15.z.union([
|
|
6846
6728
|
publicAuthOptionsSchema.extend(standaloneOptionSchema),
|
|
6847
6729
|
transparentAuthOptionsSchema.extend(standaloneOptionSchema),
|
|
6848
|
-
|
|
6849
|
-
|
|
6730
|
+
localAuthSchema.extend(standaloneOptionSchema),
|
|
6731
|
+
remoteAuthSchema.extend(standaloneOptionSchema)
|
|
6850
6732
|
]);
|
|
6851
6733
|
|
|
6852
6734
|
// libs/auth/src/options/utils.ts
|
|
@@ -6859,136 +6741,142 @@ function isPublicMode(options) {
|
|
|
6859
6741
|
function isTransparentMode(options) {
|
|
6860
6742
|
return options.mode === "transparent";
|
|
6861
6743
|
}
|
|
6744
|
+
function isLocalMode(options) {
|
|
6745
|
+
return options.mode === "local";
|
|
6746
|
+
}
|
|
6747
|
+
function isRemoteMode(options) {
|
|
6748
|
+
return options.mode === "remote";
|
|
6749
|
+
}
|
|
6862
6750
|
function isOrchestratedMode(options) {
|
|
6863
|
-
return options.mode === "
|
|
6751
|
+
return options.mode === "local" || options.mode === "remote";
|
|
6864
6752
|
}
|
|
6865
6753
|
function isOrchestratedLocal(options) {
|
|
6866
|
-
return options.
|
|
6754
|
+
return options.mode === "local";
|
|
6867
6755
|
}
|
|
6868
6756
|
function isOrchestratedRemote(options) {
|
|
6869
|
-
return options.
|
|
6757
|
+
return options.mode === "remote";
|
|
6870
6758
|
}
|
|
6871
6759
|
function allowsPublicAccess(options) {
|
|
6872
6760
|
if (options.mode === "public") return true;
|
|
6873
6761
|
if (options.mode === "transparent") return options.allowAnonymous;
|
|
6874
|
-
if (options.mode === "
|
|
6762
|
+
if (options.mode === "local" || options.mode === "remote") return options.allowDefaultPublic;
|
|
6875
6763
|
return false;
|
|
6876
6764
|
}
|
|
6877
6765
|
|
|
6878
6766
|
// libs/auth/src/consent/consent.types.ts
|
|
6879
|
-
var
|
|
6880
|
-
var consentToolItemSchema =
|
|
6767
|
+
var import_zod16 = require("zod");
|
|
6768
|
+
var consentToolItemSchema = import_zod16.z.object({
|
|
6881
6769
|
/** Tool ID (e.g., 'slack:send_message') */
|
|
6882
|
-
id:
|
|
6770
|
+
id: import_zod16.z.string().min(1),
|
|
6883
6771
|
/** Tool name for display */
|
|
6884
|
-
name:
|
|
6772
|
+
name: import_zod16.z.string().min(1),
|
|
6885
6773
|
/** Tool description */
|
|
6886
|
-
description:
|
|
6774
|
+
description: import_zod16.z.string().optional(),
|
|
6887
6775
|
/** App ID this tool belongs to */
|
|
6888
|
-
appId:
|
|
6776
|
+
appId: import_zod16.z.string().min(1),
|
|
6889
6777
|
/** App name for display */
|
|
6890
|
-
appName:
|
|
6778
|
+
appName: import_zod16.z.string().min(1),
|
|
6891
6779
|
/** Whether the tool is selected by default */
|
|
6892
|
-
defaultSelected:
|
|
6780
|
+
defaultSelected: import_zod16.z.boolean().default(true),
|
|
6893
6781
|
/** Whether this tool requires specific scopes */
|
|
6894
|
-
requiredScopes:
|
|
6782
|
+
requiredScopes: import_zod16.z.array(import_zod16.z.string()).optional(),
|
|
6895
6783
|
/** Category for grouping (e.g., 'read', 'write', 'admin') */
|
|
6896
|
-
category:
|
|
6784
|
+
category: import_zod16.z.string().optional()
|
|
6897
6785
|
});
|
|
6898
|
-
var consentSelectionSchema =
|
|
6786
|
+
var consentSelectionSchema = import_zod16.z.object({
|
|
6899
6787
|
/** Selected tool IDs */
|
|
6900
|
-
selectedTools:
|
|
6788
|
+
selectedTools: import_zod16.z.array(import_zod16.z.string()),
|
|
6901
6789
|
/** Whether all tools were selected */
|
|
6902
|
-
allSelected:
|
|
6790
|
+
allSelected: import_zod16.z.boolean(),
|
|
6903
6791
|
/** Timestamp when consent was given */
|
|
6904
|
-
consentedAt:
|
|
6792
|
+
consentedAt: import_zod16.z.string().datetime(),
|
|
6905
6793
|
/** Consent version for tracking changes */
|
|
6906
|
-
consentVersion:
|
|
6794
|
+
consentVersion: import_zod16.z.string().default("1.0")
|
|
6907
6795
|
});
|
|
6908
|
-
var consentStateSchema =
|
|
6796
|
+
var consentStateSchema = import_zod16.z.object({
|
|
6909
6797
|
/** Whether consent flow is enabled */
|
|
6910
|
-
enabled:
|
|
6798
|
+
enabled: import_zod16.z.boolean(),
|
|
6911
6799
|
/** Available tools for consent */
|
|
6912
|
-
availableTools:
|
|
6800
|
+
availableTools: import_zod16.z.array(consentToolItemSchema),
|
|
6913
6801
|
/** Pre-selected tools (from previous consent or defaults) */
|
|
6914
|
-
preselectedTools:
|
|
6802
|
+
preselectedTools: import_zod16.z.array(import_zod16.z.string()).optional(),
|
|
6915
6803
|
/** Whether to show all tools or group by app */
|
|
6916
|
-
groupByApp:
|
|
6804
|
+
groupByApp: import_zod16.z.boolean().default(true),
|
|
6917
6805
|
/** Custom consent message */
|
|
6918
|
-
customMessage:
|
|
6806
|
+
customMessage: import_zod16.z.string().optional()
|
|
6919
6807
|
});
|
|
6920
|
-
var federatedProviderItemSchema =
|
|
6808
|
+
var federatedProviderItemSchema = import_zod16.z.object({
|
|
6921
6809
|
/** Provider ID (derived or explicit) */
|
|
6922
|
-
id:
|
|
6810
|
+
id: import_zod16.z.string().min(1),
|
|
6923
6811
|
/** Provider display name */
|
|
6924
|
-
name:
|
|
6812
|
+
name: import_zod16.z.string().min(1),
|
|
6925
6813
|
/** Provider description */
|
|
6926
|
-
description:
|
|
6814
|
+
description: import_zod16.z.string().optional(),
|
|
6927
6815
|
/** Provider icon URL or emoji */
|
|
6928
|
-
icon:
|
|
6816
|
+
icon: import_zod16.z.string().optional(),
|
|
6929
6817
|
/** Provider type */
|
|
6930
|
-
type:
|
|
6818
|
+
type: import_zod16.z.enum(["local", "remote", "transparent"]),
|
|
6931
6819
|
/** OAuth provider URL (for remote providers) */
|
|
6932
|
-
providerUrl:
|
|
6820
|
+
providerUrl: import_zod16.z.string().url().optional(),
|
|
6933
6821
|
/** Apps using this provider */
|
|
6934
|
-
appIds:
|
|
6822
|
+
appIds: import_zod16.z.array(import_zod16.z.string()),
|
|
6935
6823
|
/** App names using this provider */
|
|
6936
|
-
appNames:
|
|
6824
|
+
appNames: import_zod16.z.array(import_zod16.z.string()),
|
|
6937
6825
|
/** Scopes required by this provider */
|
|
6938
|
-
scopes:
|
|
6826
|
+
scopes: import_zod16.z.array(import_zod16.z.string()),
|
|
6939
6827
|
/** Whether this is the primary/parent provider */
|
|
6940
|
-
isPrimary:
|
|
6828
|
+
isPrimary: import_zod16.z.boolean(),
|
|
6941
6829
|
/** Whether this provider is optional (can be skipped) */
|
|
6942
|
-
isOptional:
|
|
6830
|
+
isOptional: import_zod16.z.boolean().default(false)
|
|
6943
6831
|
});
|
|
6944
|
-
var federatedLoginStateSchema =
|
|
6832
|
+
var federatedLoginStateSchema = import_zod16.z.object({
|
|
6945
6833
|
/** All available providers */
|
|
6946
|
-
providers:
|
|
6834
|
+
providers: import_zod16.z.array(federatedProviderItemSchema),
|
|
6947
6835
|
/** Primary provider ID (if any) */
|
|
6948
|
-
primaryProviderId:
|
|
6836
|
+
primaryProviderId: import_zod16.z.string().optional(),
|
|
6949
6837
|
/** Whether user can skip optional providers */
|
|
6950
|
-
allowSkip:
|
|
6838
|
+
allowSkip: import_zod16.z.boolean().default(true),
|
|
6951
6839
|
/** Pre-selected provider IDs (from previous session) */
|
|
6952
|
-
preselectedProviders:
|
|
6840
|
+
preselectedProviders: import_zod16.z.array(import_zod16.z.string()).optional()
|
|
6953
6841
|
});
|
|
6954
|
-
var federatedSelectionSchema =
|
|
6842
|
+
var federatedSelectionSchema = import_zod16.z.object({
|
|
6955
6843
|
/** Selected provider IDs */
|
|
6956
|
-
selectedProviders:
|
|
6844
|
+
selectedProviders: import_zod16.z.array(import_zod16.z.string()),
|
|
6957
6845
|
/** Skipped provider IDs */
|
|
6958
|
-
skippedProviders:
|
|
6846
|
+
skippedProviders: import_zod16.z.array(import_zod16.z.string()),
|
|
6959
6847
|
/** Provider-specific metadata */
|
|
6960
|
-
providerMetadata:
|
|
6848
|
+
providerMetadata: import_zod16.z.record(import_zod16.z.string(), import_zod16.z.unknown()).optional()
|
|
6961
6849
|
});
|
|
6962
6850
|
|
|
6963
6851
|
// libs/auth/src/detection/auth-provider-detection.ts
|
|
6964
|
-
var
|
|
6965
|
-
var detectedAuthProviderSchema =
|
|
6966
|
-
id:
|
|
6967
|
-
providerUrl:
|
|
6968
|
-
mode:
|
|
6969
|
-
appIds:
|
|
6970
|
-
scopes:
|
|
6971
|
-
isParentProvider:
|
|
6852
|
+
var import_zod17 = require("zod");
|
|
6853
|
+
var detectedAuthProviderSchema = import_zod17.z.object({
|
|
6854
|
+
id: import_zod17.z.string(),
|
|
6855
|
+
providerUrl: import_zod17.z.string().optional(),
|
|
6856
|
+
mode: import_zod17.z.enum(["public", "transparent", "local", "remote"]),
|
|
6857
|
+
appIds: import_zod17.z.array(import_zod17.z.string()),
|
|
6858
|
+
scopes: import_zod17.z.array(import_zod17.z.string()),
|
|
6859
|
+
isParentProvider: import_zod17.z.boolean()
|
|
6972
6860
|
});
|
|
6973
|
-
var authProviderDetectionResultSchema =
|
|
6974
|
-
providers:
|
|
6975
|
-
requiresOrchestration:
|
|
6976
|
-
parentProviderId:
|
|
6977
|
-
childProviderIds:
|
|
6978
|
-
uniqueProviderCount:
|
|
6979
|
-
validationErrors:
|
|
6980
|
-
warnings:
|
|
6861
|
+
var authProviderDetectionResultSchema = import_zod17.z.object({
|
|
6862
|
+
providers: import_zod17.z.map(import_zod17.z.string(), detectedAuthProviderSchema),
|
|
6863
|
+
requiresOrchestration: import_zod17.z.boolean(),
|
|
6864
|
+
parentProviderId: import_zod17.z.string().optional(),
|
|
6865
|
+
childProviderIds: import_zod17.z.array(import_zod17.z.string()),
|
|
6866
|
+
uniqueProviderCount: import_zod17.z.number(),
|
|
6867
|
+
validationErrors: import_zod17.z.array(import_zod17.z.string()),
|
|
6868
|
+
warnings: import_zod17.z.array(import_zod17.z.string())
|
|
6981
6869
|
});
|
|
6982
6870
|
function deriveProviderId(options) {
|
|
6983
6871
|
if (isPublicMode(options)) {
|
|
6984
6872
|
return options.issuer ?? "public";
|
|
6985
6873
|
}
|
|
6986
6874
|
if (isTransparentMode(options)) {
|
|
6987
|
-
return options.
|
|
6875
|
+
return options.providerConfig?.id ?? urlToProviderId(options.provider);
|
|
6988
6876
|
}
|
|
6989
6877
|
if (isOrchestratedMode(options)) {
|
|
6990
6878
|
if (isOrchestratedRemote(options)) {
|
|
6991
|
-
return options.
|
|
6879
|
+
return options.providerConfig?.id ?? urlToProviderId(options.provider);
|
|
6992
6880
|
}
|
|
6993
6881
|
return options.local?.issuer ?? "local";
|
|
6994
6882
|
}
|
|
@@ -7008,7 +6896,7 @@ function extractScopes(options) {
|
|
|
7008
6896
|
}
|
|
7009
6897
|
if (isOrchestratedMode(options)) {
|
|
7010
6898
|
if (isOrchestratedRemote(options)) {
|
|
7011
|
-
return options.
|
|
6899
|
+
return options.scopes || [];
|
|
7012
6900
|
}
|
|
7013
6901
|
}
|
|
7014
6902
|
return [];
|
|
@@ -7057,12 +6945,12 @@ function detectAuthProviders(parentAuth, apps) {
|
|
|
7057
6945
|
const requiresOrchestration = hasMultipleProviders || hasChildOnlyProviders || childProviderIds.length > 0 && parentProviderId !== void 0;
|
|
7058
6946
|
if (requiresOrchestration && parentAuth && isTransparentMode(parentAuth)) {
|
|
7059
6947
|
validationErrors.push(
|
|
7060
|
-
`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
|
|
6948
|
+
`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(", ")}`
|
|
7061
6949
|
);
|
|
7062
6950
|
}
|
|
7063
6951
|
if (uniqueProviderCount > 1 && parentAuth && isPublicMode(parentAuth)) {
|
|
7064
6952
|
warnings.push(
|
|
7065
|
-
`Parent uses public mode but apps have auth providers configured. App-level auth will be used, but consider using
|
|
6953
|
+
`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.`
|
|
7066
6954
|
);
|
|
7067
6955
|
}
|
|
7068
6956
|
return {
|
|
@@ -7077,10 +6965,10 @@ function detectAuthProviders(parentAuth, apps) {
|
|
|
7077
6965
|
}
|
|
7078
6966
|
function getProviderUrl(options) {
|
|
7079
6967
|
if (isTransparentMode(options)) {
|
|
7080
|
-
return options.
|
|
6968
|
+
return options.provider;
|
|
7081
6969
|
}
|
|
7082
6970
|
if (isOrchestratedMode(options) && isOrchestratedRemote(options)) {
|
|
7083
|
-
return options.
|
|
6971
|
+
return options.provider;
|
|
7084
6972
|
}
|
|
7085
6973
|
return void 0;
|
|
7086
6974
|
}
|
|
@@ -7250,9 +7138,9 @@ function escapeQuotedString(value) {
|
|
|
7250
7138
|
function unescapeQuotedString(value) {
|
|
7251
7139
|
return value.replace(/\\(.)/g, "$1");
|
|
7252
7140
|
}
|
|
7253
|
-
function normalizePathSegment(
|
|
7254
|
-
if (!
|
|
7255
|
-
const normalized =
|
|
7141
|
+
function normalizePathSegment(path) {
|
|
7142
|
+
if (!path || path === "/") return "";
|
|
7143
|
+
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
7256
7144
|
let end = normalized.length;
|
|
7257
7145
|
while (end > 0 && normalized[end - 1] === "/") {
|
|
7258
7146
|
end--;
|
|
@@ -7367,43 +7255,43 @@ var AudienceValidator = class _AudienceValidator {
|
|
|
7367
7255
|
};
|
|
7368
7256
|
|
|
7369
7257
|
// libs/auth/src/vault/auth-providers.types.ts
|
|
7370
|
-
var
|
|
7371
|
-
var credentialScopeSchema =
|
|
7372
|
-
var loadingStrategySchema =
|
|
7373
|
-
var getCredentialOptionsSchema =
|
|
7374
|
-
forceRefresh:
|
|
7375
|
-
scopes:
|
|
7376
|
-
timeout:
|
|
7258
|
+
var import_zod18 = require("zod");
|
|
7259
|
+
var credentialScopeSchema = import_zod18.z.enum(["global", "user", "session"]);
|
|
7260
|
+
var loadingStrategySchema = import_zod18.z.enum(["eager", "lazy"]);
|
|
7261
|
+
var getCredentialOptionsSchema = import_zod18.z.object({
|
|
7262
|
+
forceRefresh: import_zod18.z.boolean().optional(),
|
|
7263
|
+
scopes: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
7264
|
+
timeout: import_zod18.z.number().positive().optional()
|
|
7377
7265
|
}).strict();
|
|
7378
|
-
var credentialProviderConfigSchema =
|
|
7379
|
-
name:
|
|
7380
|
-
description:
|
|
7266
|
+
var credentialProviderConfigSchema = import_zod18.z.object({
|
|
7267
|
+
name: import_zod18.z.string().min(1),
|
|
7268
|
+
description: import_zod18.z.string().optional(),
|
|
7381
7269
|
scope: credentialScopeSchema,
|
|
7382
7270
|
loading: loadingStrategySchema,
|
|
7383
|
-
cacheTtl:
|
|
7271
|
+
cacheTtl: import_zod18.z.number().nonnegative().optional(),
|
|
7384
7272
|
// Functions validated at runtime, not via Zod (Zod 4 compatibility)
|
|
7385
|
-
factory:
|
|
7386
|
-
refresh:
|
|
7387
|
-
toHeaders:
|
|
7388
|
-
metadata:
|
|
7389
|
-
required:
|
|
7273
|
+
factory: import_zod18.z.any(),
|
|
7274
|
+
refresh: import_zod18.z.any().optional(),
|
|
7275
|
+
toHeaders: import_zod18.z.any().optional(),
|
|
7276
|
+
metadata: import_zod18.z.record(import_zod18.z.string(), import_zod18.z.unknown()).optional(),
|
|
7277
|
+
required: import_zod18.z.boolean().optional()
|
|
7390
7278
|
}).strict();
|
|
7391
|
-
var authProviderMappingSchema =
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
name:
|
|
7395
|
-
required:
|
|
7396
|
-
scopes:
|
|
7397
|
-
alias:
|
|
7279
|
+
var authProviderMappingSchema = import_zod18.z.union([
|
|
7280
|
+
import_zod18.z.string(),
|
|
7281
|
+
import_zod18.z.object({
|
|
7282
|
+
name: import_zod18.z.string().min(1),
|
|
7283
|
+
required: import_zod18.z.boolean().optional().default(true),
|
|
7284
|
+
scopes: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
7285
|
+
alias: import_zod18.z.string().optional()
|
|
7398
7286
|
}).strict()
|
|
7399
7287
|
]);
|
|
7400
|
-
var authProvidersVaultOptionsSchema =
|
|
7401
|
-
enabled:
|
|
7402
|
-
useSharedStorage:
|
|
7403
|
-
namespace:
|
|
7404
|
-
defaultCacheTtl:
|
|
7405
|
-
maxCredentialsPerSession:
|
|
7406
|
-
providers:
|
|
7288
|
+
var authProvidersVaultOptionsSchema = import_zod18.z.object({
|
|
7289
|
+
enabled: import_zod18.z.boolean().optional(),
|
|
7290
|
+
useSharedStorage: import_zod18.z.boolean().optional().default(true),
|
|
7291
|
+
namespace: import_zod18.z.string().optional().default("authproviders:"),
|
|
7292
|
+
defaultCacheTtl: import_zod18.z.number().nonnegative().optional().default(36e5),
|
|
7293
|
+
maxCredentialsPerSession: import_zod18.z.number().positive().optional().default(100),
|
|
7294
|
+
providers: import_zod18.z.array(credentialProviderConfigSchema).optional()
|
|
7407
7295
|
}).strict();
|
|
7408
7296
|
|
|
7409
7297
|
// libs/auth/src/vault/credential-helpers.ts
|
|
@@ -8383,7 +8271,6 @@ var LazyCredentialLoader = class {
|
|
|
8383
8271
|
AuthProvidersVault,
|
|
8384
8272
|
AuthorizationBase,
|
|
8385
8273
|
CDN,
|
|
8386
|
-
CimdCache,
|
|
8387
8274
|
CimdClientIdMismatchError,
|
|
8388
8275
|
CimdDisabledError,
|
|
8389
8276
|
CimdError,
|
|
@@ -8405,6 +8292,7 @@ var LazyCredentialLoader = class {
|
|
|
8405
8292
|
EncryptionKeyNotConfiguredError,
|
|
8406
8293
|
InMemoryAuthorizationStore,
|
|
8407
8294
|
InMemoryAuthorizationVault,
|
|
8295
|
+
InMemoryCimdCache,
|
|
8408
8296
|
InMemoryFederatedAuthSessionStore,
|
|
8409
8297
|
InMemoryOrchestratedTokenStore,
|
|
8410
8298
|
InMemoryStoreRequiredError,
|
|
@@ -8500,7 +8388,6 @@ var LazyCredentialLoader = class {
|
|
|
8500
8388
|
decryptSessionJson,
|
|
8501
8389
|
decryptValue,
|
|
8502
8390
|
defaultSessionRateLimiter,
|
|
8503
|
-
deleteDevKey,
|
|
8504
8391
|
deriveAuthorizationId,
|
|
8505
8392
|
deriveExpectedAudience,
|
|
8506
8393
|
deriveProviderId,
|
|
@@ -8522,6 +8409,7 @@ var LazyCredentialLoader = class {
|
|
|
8522
8409
|
federatedLoginStateSchema,
|
|
8523
8410
|
federatedProviderItemSchema,
|
|
8524
8411
|
federatedSelectionSchema,
|
|
8412
|
+
flatRemoteProviderFields,
|
|
8525
8413
|
fromSessionRecord,
|
|
8526
8414
|
generatePkceChallenge,
|
|
8527
8415
|
getCredentialOptionsSchema,
|
|
@@ -8535,12 +8423,13 @@ var LazyCredentialLoader = class {
|
|
|
8535
8423
|
hkdfSha256,
|
|
8536
8424
|
incrementalAuthConfigSchema,
|
|
8537
8425
|
isCimdClientId,
|
|
8538
|
-
isDevKeyPersistenceEnabled,
|
|
8539
8426
|
isJwt,
|
|
8427
|
+
isLocalMode,
|
|
8540
8428
|
isOrchestratedLocal,
|
|
8541
8429
|
isOrchestratedMode,
|
|
8542
8430
|
isOrchestratedRemote,
|
|
8543
8431
|
isPublicMode,
|
|
8432
|
+
isRemoteMode,
|
|
8544
8433
|
isSessionComplete,
|
|
8545
8434
|
isSignedSession,
|
|
8546
8435
|
isSoonExpiring,
|
|
@@ -8551,14 +8440,13 @@ var LazyCredentialLoader = class {
|
|
|
8551
8440
|
jwkSchema,
|
|
8552
8441
|
legacySseTransportStateSchema,
|
|
8553
8442
|
llmSafeAuthContextSchema,
|
|
8554
|
-
loadDevKey,
|
|
8555
8443
|
loadingStrategySchema,
|
|
8444
|
+
localAuthSchema,
|
|
8556
8445
|
localSigningConfigSchema,
|
|
8557
8446
|
mtlsCredentialSchema,
|
|
8558
8447
|
noopLogger,
|
|
8559
8448
|
normalizeIssuer,
|
|
8560
8449
|
oauthCredentialSchema,
|
|
8561
|
-
orchestratedAuthOptionsSchema,
|
|
8562
8450
|
orchestratedLocalSchema,
|
|
8563
8451
|
orchestratedRemoteSchema,
|
|
8564
8452
|
parseAuthOptions,
|
|
@@ -8569,16 +8457,16 @@ var LazyCredentialLoader = class {
|
|
|
8569
8457
|
pkceOAuthCredentialSchema,
|
|
8570
8458
|
privateKeyCredentialSchema,
|
|
8571
8459
|
progressiveAuthStateSchema,
|
|
8460
|
+
providerConfigSchema,
|
|
8572
8461
|
publicAccessConfigSchema,
|
|
8573
8462
|
publicAuthOptionsSchema,
|
|
8574
8463
|
redisConfigSchema,
|
|
8575
8464
|
redisVaultEntrySchema,
|
|
8465
|
+
remoteAuthSchema,
|
|
8576
8466
|
remoteProviderConfigSchema,
|
|
8577
8467
|
renderToHtml,
|
|
8578
8468
|
resetCachedKey,
|
|
8579
|
-
resolveKeyPath,
|
|
8580
8469
|
safeDecrypt,
|
|
8581
|
-
saveDevKey,
|
|
8582
8470
|
serviceAccountCredentialSchema,
|
|
8583
8471
|
sessionIdPayloadSchema,
|
|
8584
8472
|
sessionJwtPayloadSchema,
|