@frontmcp/auth 0.12.1 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cimd/cimd.cache.d.ts +0 -5
- package/cimd/cimd.cache.d.ts.map +1 -1
- package/cimd/index.d.ts +1 -2
- package/cimd/index.d.ts.map +1 -1
- package/consent/index.d.ts +2 -1
- package/consent/index.d.ts.map +1 -1
- package/detection/auth-provider-detection.d.ts +4 -2
- package/detection/auth-provider-detection.d.ts.map +1 -1
- package/esm/index.mjs +673 -768
- package/esm/package.json +4 -4
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +745 -858
- package/jwks/index.d.ts +1 -12
- package/jwks/index.d.ts.map +1 -1
- package/jwks/jwks.service.d.ts +1 -6
- package/jwks/jwks.service.d.ts.map +1 -1
- package/jwks/jwks.types.d.ts +0 -7
- package/jwks/jwks.types.d.ts.map +1 -1
- package/machine-id/machine-id.d.ts.map +1 -1
- package/options/app-auth.schema.d.ts +29 -37
- package/options/app-auth.schema.d.ts.map +1 -1
- package/options/index.d.ts +6 -6
- package/options/index.d.ts.map +1 -1
- package/options/interfaces.d.ts +72 -32
- package/options/interfaces.d.ts.map +1 -1
- package/options/orchestrated.schema.d.ts +54 -56
- package/options/orchestrated.schema.d.ts.map +1 -1
- package/options/schema.d.ts +30 -38
- package/options/schema.d.ts.map +1 -1
- package/options/shared.schemas.d.ts +61 -9
- package/options/shared.schemas.d.ts.map +1 -1
- package/options/transparent.schema.d.ts +15 -15
- package/options/typecheck.d.ts.map +1 -1
- package/options/utils.d.ts +16 -7
- package/options/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/session/session-crypto.d.ts.map +1 -1
- package/session/session.transport.d.ts +3 -4
- package/session/session.transport.d.ts.map +1 -1
- package/session/utils/session-crypto.utils.d.ts.map +1 -1
- package/jwks/dev-key-persistence.d.ts +0 -70
- package/jwks/dev-key-persistence.d.ts.map +0 -1
package/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,102 @@ 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()
|
|
2418
2261
|
});
|
|
2419
|
-
var redisConfigSchema =
|
|
2420
|
-
host:
|
|
2421
|
-
port:
|
|
2422
|
-
password:
|
|
2423
|
-
db:
|
|
2424
|
-
tls:
|
|
2425
|
-
keyPrefix:
|
|
2426
|
-
defaultTtlMs:
|
|
2262
|
+
var redisConfigSchema = import_zod4.z.object({
|
|
2263
|
+
host: import_zod4.z.string().min(1),
|
|
2264
|
+
port: import_zod4.z.number().int().positive().optional().default(6379),
|
|
2265
|
+
password: import_zod4.z.string().optional(),
|
|
2266
|
+
db: import_zod4.z.number().int().nonnegative().optional().default(0),
|
|
2267
|
+
tls: import_zod4.z.boolean().optional().default(false),
|
|
2268
|
+
keyPrefix: import_zod4.z.string().optional().default("mcp:session:"),
|
|
2269
|
+
defaultTtlMs: import_zod4.z.number().int().positive().optional().default(36e5)
|
|
2427
2270
|
// 1 hour default
|
|
2428
2271
|
});
|
|
2429
2272
|
|
|
2430
2273
|
// libs/auth/src/session/session-crypto.ts
|
|
2431
|
-
var
|
|
2274
|
+
var import_utils8 = require("@frontmcp/utils");
|
|
2432
2275
|
|
|
2433
2276
|
// libs/auth/src/errors/auth-internal.error.ts
|
|
2434
|
-
var
|
|
2277
|
+
var import_utils7 = require("@frontmcp/utils");
|
|
2435
2278
|
var AuthInternalError = class extends Error {
|
|
2436
2279
|
/**
|
|
2437
2280
|
* Unique error ID for tracking in logs.
|
|
@@ -2453,7 +2296,7 @@ var AuthInternalError = class extends Error {
|
|
|
2453
2296
|
super(message);
|
|
2454
2297
|
this.name = this.constructor.name;
|
|
2455
2298
|
this.code = code;
|
|
2456
|
-
this.errorId = `err_${(0,
|
|
2299
|
+
this.errorId = `err_${(0, import_utils7.bytesToHex)((0, import_utils7.randomBytes)(8))}`;
|
|
2457
2300
|
Error.captureStackTrace(this, this.constructor);
|
|
2458
2301
|
}
|
|
2459
2302
|
/**
|
|
@@ -2576,9 +2419,9 @@ var AuthFlowError = class extends AuthInternalError {
|
|
|
2576
2419
|
|
|
2577
2420
|
// libs/auth/src/session/session-crypto.ts
|
|
2578
2421
|
function getSigningSecret(config) {
|
|
2579
|
-
const secret = config?.secret ||
|
|
2422
|
+
const secret = config?.secret || (0, import_utils8.getEnv)("MCP_SESSION_SECRET");
|
|
2580
2423
|
if (!secret) {
|
|
2581
|
-
if (
|
|
2424
|
+
if ((0, import_utils8.isProduction)()) {
|
|
2582
2425
|
throw new SessionSecretRequiredError("session signing");
|
|
2583
2426
|
}
|
|
2584
2427
|
console.warn("[SessionCrypto] MCP_SESSION_SECRET not set. Using insecure default for development only.");
|
|
@@ -2590,13 +2433,13 @@ function resolveConfig(config) {
|
|
|
2590
2433
|
return { secret: getSigningSecret(config) };
|
|
2591
2434
|
}
|
|
2592
2435
|
function signSession(session, config) {
|
|
2593
|
-
return (0,
|
|
2436
|
+
return (0, import_utils8.signData)(session, resolveConfig(config));
|
|
2594
2437
|
}
|
|
2595
2438
|
function verifySession(signedData, config) {
|
|
2596
|
-
return (0,
|
|
2439
|
+
return (0, import_utils8.verifyData)(signedData, resolveConfig(config));
|
|
2597
2440
|
}
|
|
2598
2441
|
function verifyOrParseSession(data, config) {
|
|
2599
|
-
return (0,
|
|
2442
|
+
return (0, import_utils8.verifyOrParseData)(data, resolveConfig(config));
|
|
2600
2443
|
}
|
|
2601
2444
|
|
|
2602
2445
|
// libs/auth/src/session/session-rate-limiter.ts
|
|
@@ -2611,7 +2454,7 @@ var SessionRateLimiter = class {
|
|
|
2611
2454
|
const cleanupIntervalMs = config.cleanupIntervalMs ?? 6e4;
|
|
2612
2455
|
if (cleanupIntervalMs > 0) {
|
|
2613
2456
|
this.cleanupTimer = setInterval(() => this.cleanup(), cleanupIntervalMs);
|
|
2614
|
-
this.cleanupTimer.unref();
|
|
2457
|
+
if (typeof this.cleanupTimer.unref === "function") this.cleanupTimer.unref();
|
|
2615
2458
|
}
|
|
2616
2459
|
}
|
|
2617
2460
|
/**
|
|
@@ -2715,17 +2558,16 @@ var SessionRateLimiter = class {
|
|
|
2715
2558
|
var defaultSessionRateLimiter = new SessionRateLimiter();
|
|
2716
2559
|
|
|
2717
2560
|
// libs/auth/src/session/session.transport.ts
|
|
2718
|
-
var
|
|
2561
|
+
var import_utils9 = require("@frontmcp/utils");
|
|
2719
2562
|
var TransportIdGenerator = class {
|
|
2720
2563
|
/**
|
|
2721
2564
|
* Create a transport session ID.
|
|
2722
|
-
*
|
|
2565
|
+
* Generates JWT-style IDs for distributed session support.
|
|
2723
2566
|
*
|
|
2724
|
-
* @
|
|
2725
|
-
* @returns A JWT-style transport session ID (UUID without dashes)
|
|
2567
|
+
* @returns A transport session ID (UUID without dashes)
|
|
2726
2568
|
*/
|
|
2727
|
-
static createId(
|
|
2728
|
-
return (0,
|
|
2569
|
+
static createId() {
|
|
2570
|
+
return (0, import_utils9.randomUUID)().replace(/-/g, "");
|
|
2729
2571
|
}
|
|
2730
2572
|
};
|
|
2731
2573
|
|
|
@@ -2773,7 +2615,7 @@ var TinyTtlCache = class {
|
|
|
2773
2615
|
};
|
|
2774
2616
|
|
|
2775
2617
|
// libs/auth/src/session/utils/auth-token.utils.ts
|
|
2776
|
-
var
|
|
2618
|
+
var import_utils10 = require("@frontmcp/utils");
|
|
2777
2619
|
function isJwt(token) {
|
|
2778
2620
|
if (!token) return false;
|
|
2779
2621
|
return token.split(".").length === 3;
|
|
@@ -2783,7 +2625,7 @@ function getTokenSignatureFingerprint(token) {
|
|
|
2783
2625
|
const sig = token.split(".")[2];
|
|
2784
2626
|
if (sig) return sig;
|
|
2785
2627
|
}
|
|
2786
|
-
return (0,
|
|
2628
|
+
return (0, import_utils10.sha256Base64url)(token);
|
|
2787
2629
|
}
|
|
2788
2630
|
function extractClaimValue(claims, key, validator) {
|
|
2789
2631
|
const value = claims[key];
|
|
@@ -2815,18 +2657,20 @@ function extractBearerToken(header) {
|
|
|
2815
2657
|
}
|
|
2816
2658
|
|
|
2817
2659
|
// libs/auth/src/session/utils/session-crypto.utils.ts
|
|
2818
|
-
var
|
|
2660
|
+
var import_utils12 = require("@frontmcp/utils");
|
|
2819
2661
|
|
|
2820
2662
|
// libs/auth/src/machine-id/machine-id.ts
|
|
2821
|
-
var
|
|
2822
|
-
var import_utils12 = require("@frontmcp/utils");
|
|
2663
|
+
var import_utils11 = require("@frontmcp/utils");
|
|
2823
2664
|
var DEFAULT_MACHINE_ID_PATH = ".frontmcp/machine-id";
|
|
2824
2665
|
function isDevPersistenceEnabled() {
|
|
2825
|
-
|
|
2666
|
+
if ((0, import_utils11.isBrowser)()) return false;
|
|
2667
|
+
return !(0, import_utils11.isProduction)();
|
|
2826
2668
|
}
|
|
2827
2669
|
function resolveMachineIdPath() {
|
|
2828
|
-
|
|
2829
|
-
|
|
2670
|
+
if ((0, import_utils11.isBrowser)()) return DEFAULT_MACHINE_ID_PATH;
|
|
2671
|
+
const path = require("path");
|
|
2672
|
+
const machineIdPath = (0, import_utils11.getEnv)("MACHINE_ID_PATH") ?? DEFAULT_MACHINE_ID_PATH;
|
|
2673
|
+
return path.isAbsolute(machineIdPath) ? machineIdPath : path.resolve((0, import_utils11.getCwd)(), machineIdPath);
|
|
2830
2674
|
}
|
|
2831
2675
|
function loadMachineIdSync() {
|
|
2832
2676
|
if (!isDevPersistenceEnabled()) {
|
|
@@ -2834,7 +2678,7 @@ function loadMachineIdSync() {
|
|
|
2834
2678
|
}
|
|
2835
2679
|
const machineIdPath = resolveMachineIdPath();
|
|
2836
2680
|
try {
|
|
2837
|
-
const content = (0,
|
|
2681
|
+
const content = (0, import_utils11.readFileSync)(machineIdPath, "utf8").trim();
|
|
2838
2682
|
if (/^[0-9a-f-]{32,36}$/i.test(content)) {
|
|
2839
2683
|
return content;
|
|
2840
2684
|
}
|
|
@@ -2852,18 +2696,19 @@ function saveMachineIdAsync(machineId2) {
|
|
|
2852
2696
|
return;
|
|
2853
2697
|
}
|
|
2854
2698
|
const machineIdPath = resolveMachineIdPath();
|
|
2855
|
-
const
|
|
2699
|
+
const path = require("path");
|
|
2700
|
+
const dir = path.dirname(machineIdPath);
|
|
2856
2701
|
(async () => {
|
|
2857
2702
|
try {
|
|
2858
|
-
await (0,
|
|
2859
|
-
await (0,
|
|
2703
|
+
await (0, import_utils11.mkdir)(dir, { recursive: true, mode: 448 });
|
|
2704
|
+
await (0, import_utils11.writeFile)(machineIdPath, machineId2, { mode: 384 });
|
|
2860
2705
|
} catch (error) {
|
|
2861
2706
|
console.warn(`[MachineId] Failed to save to ${machineIdPath}: ${error.message}`);
|
|
2862
2707
|
}
|
|
2863
2708
|
})();
|
|
2864
2709
|
}
|
|
2865
2710
|
var machineId = (() => {
|
|
2866
|
-
const envMachineId =
|
|
2711
|
+
const envMachineId = (0, import_utils11.getEnv)("MACHINE_ID");
|
|
2867
2712
|
if (envMachineId) {
|
|
2868
2713
|
return envMachineId;
|
|
2869
2714
|
}
|
|
@@ -2871,7 +2716,7 @@ var machineId = (() => {
|
|
|
2871
2716
|
if (loadedId) {
|
|
2872
2717
|
return loadedId;
|
|
2873
2718
|
}
|
|
2874
|
-
const newId = (0,
|
|
2719
|
+
const newId = (0, import_utils11.randomUUID)();
|
|
2875
2720
|
saveMachineIdAsync(newId);
|
|
2876
2721
|
return newId;
|
|
2877
2722
|
})();
|
|
@@ -2887,10 +2732,9 @@ function setMachineIdOverride(id) {
|
|
|
2887
2732
|
var cachedKey = null;
|
|
2888
2733
|
function getKey() {
|
|
2889
2734
|
if (cachedKey) return cachedKey;
|
|
2890
|
-
const secret =
|
|
2891
|
-
const nodeEnv = process.env["NODE_ENV"];
|
|
2735
|
+
const secret = (0, import_utils12.getEnv)("MCP_SESSION_SECRET");
|
|
2892
2736
|
if (!secret) {
|
|
2893
|
-
if (
|
|
2737
|
+
if ((0, import_utils12.isProduction)()) {
|
|
2894
2738
|
throw new SessionSecretRequiredError("session ID encryption");
|
|
2895
2739
|
}
|
|
2896
2740
|
console.warn(
|
|
@@ -2898,12 +2742,12 @@ function getKey() {
|
|
|
2898
2742
|
);
|
|
2899
2743
|
}
|
|
2900
2744
|
const base = secret || getMachineId();
|
|
2901
|
-
cachedKey = (0,
|
|
2745
|
+
cachedKey = (0, import_utils12.sha256)(new TextEncoder().encode(base));
|
|
2902
2746
|
return cachedKey;
|
|
2903
2747
|
}
|
|
2904
2748
|
function encryptJson(obj) {
|
|
2905
2749
|
const key = getKey();
|
|
2906
|
-
const encrypted = (0,
|
|
2750
|
+
const encrypted = (0, import_utils12.encryptValue)(obj, key);
|
|
2907
2751
|
return `${encrypted.iv}.${encrypted.tag}.${encrypted.data}`;
|
|
2908
2752
|
}
|
|
2909
2753
|
function decryptSessionJson(sessionId) {
|
|
@@ -2912,7 +2756,7 @@ function decryptSessionJson(sessionId) {
|
|
|
2912
2756
|
const [ivB64, tagB64, ctB64] = parts;
|
|
2913
2757
|
if (!ivB64 || !tagB64 || !ctB64) return null;
|
|
2914
2758
|
const key = getKey();
|
|
2915
|
-
return (0,
|
|
2759
|
+
return (0, import_utils12.decryptValue)({ alg: "A256GCM", iv: ivB64, tag: tagB64, data: ctB64 }, key);
|
|
2916
2760
|
}
|
|
2917
2761
|
function safeDecrypt(sessionId) {
|
|
2918
2762
|
try {
|
|
@@ -2926,11 +2770,11 @@ function resetCachedKey() {
|
|
|
2926
2770
|
}
|
|
2927
2771
|
|
|
2928
2772
|
// libs/auth/src/session/storage/index.ts
|
|
2773
|
+
var import_utils16 = require("@frontmcp/utils");
|
|
2929
2774
|
var import_utils17 = require("@frontmcp/utils");
|
|
2930
|
-
var import_utils18 = require("@frontmcp/utils");
|
|
2931
2775
|
|
|
2932
2776
|
// libs/auth/src/session/storage/storage-token-store.ts
|
|
2933
|
-
var
|
|
2777
|
+
var import_utils13 = require("@frontmcp/utils");
|
|
2934
2778
|
var StorageTokenStore = class {
|
|
2935
2779
|
storage;
|
|
2936
2780
|
namespace;
|
|
@@ -2942,13 +2786,13 @@ var StorageTokenStore = class {
|
|
|
2942
2786
|
this.defaultTtlSeconds = options.defaultTtlSeconds;
|
|
2943
2787
|
this.storageIsNamespaced = "namespace" in storage && typeof storage.namespace === "function";
|
|
2944
2788
|
const namespacedStorage = this.storageIsNamespaced ? storage.namespace(this.namespace) : storage;
|
|
2945
|
-
this.storage = new
|
|
2789
|
+
this.storage = new import_utils13.TypedStorage(namespacedStorage);
|
|
2946
2790
|
}
|
|
2947
2791
|
/**
|
|
2948
2792
|
* Allocate a new unique ID for a token record.
|
|
2949
2793
|
*/
|
|
2950
2794
|
allocId() {
|
|
2951
|
-
return (0,
|
|
2795
|
+
return (0, import_utils13.randomUUID)();
|
|
2952
2796
|
}
|
|
2953
2797
|
/**
|
|
2954
2798
|
* Store an encrypted token blob.
|
|
@@ -3011,7 +2855,7 @@ var StorageTokenStore = class {
|
|
|
3011
2855
|
};
|
|
3012
2856
|
|
|
3013
2857
|
// libs/auth/src/session/storage/storage-authorization-vault.ts
|
|
3014
|
-
var
|
|
2858
|
+
var import_utils14 = require("@frontmcp/utils");
|
|
3015
2859
|
var StorageAuthorizationVault = class {
|
|
3016
2860
|
storage;
|
|
3017
2861
|
namespace;
|
|
@@ -3020,7 +2864,7 @@ var StorageAuthorizationVault = class {
|
|
|
3020
2864
|
this.namespace = options.namespace ?? "vault";
|
|
3021
2865
|
this.pendingAuthTtlMs = options.pendingAuthTtlMs ?? 10 * 60 * 1e3;
|
|
3022
2866
|
const namespacedStorage = this.isNamespacedStorage(storage) ? storage.namespace(this.namespace) : storage;
|
|
3023
|
-
this.storage = new
|
|
2867
|
+
this.storage = new import_utils14.TypedStorage(namespacedStorage, {
|
|
3024
2868
|
schema: options.validateOnRead ? authorizationVaultEntrySchema : void 0,
|
|
3025
2869
|
throwOnInvalid: false
|
|
3026
2870
|
});
|
|
@@ -3031,7 +2875,7 @@ var StorageAuthorizationVault = class {
|
|
|
3031
2875
|
async create(params) {
|
|
3032
2876
|
const now = Date.now();
|
|
3033
2877
|
const entry = {
|
|
3034
|
-
id: (0,
|
|
2878
|
+
id: (0, import_utils14.randomUUID)(),
|
|
3035
2879
|
userSub: params.userSub,
|
|
3036
2880
|
userEmail: params.userEmail,
|
|
3037
2881
|
userName: params.userName,
|
|
@@ -3105,7 +2949,7 @@ var StorageAuthorizationVault = class {
|
|
|
3105
2949
|
}
|
|
3106
2950
|
const now = Date.now();
|
|
3107
2951
|
const pendingAuth = {
|
|
3108
|
-
id: (0,
|
|
2952
|
+
id: (0, import_utils14.randomUUID)(),
|
|
3109
2953
|
appId: params.appId,
|
|
3110
2954
|
toolId: params.toolId,
|
|
3111
2955
|
authUrl: params.authUrl,
|
|
@@ -3309,11 +3153,11 @@ var StorageAuthorizationVault = class {
|
|
|
3309
3153
|
};
|
|
3310
3154
|
|
|
3311
3155
|
// libs/auth/src/session/storage/in-memory-authorization-vault.ts
|
|
3312
|
-
var
|
|
3156
|
+
var import_utils15 = require("@frontmcp/utils");
|
|
3313
3157
|
var InMemoryAuthorizationVault = class extends StorageAuthorizationVault {
|
|
3314
3158
|
memoryAdapter;
|
|
3315
3159
|
constructor(options = {}) {
|
|
3316
|
-
const memoryAdapter = new
|
|
3160
|
+
const memoryAdapter = new import_utils15.MemoryStorageAdapter();
|
|
3317
3161
|
super(memoryAdapter, {
|
|
3318
3162
|
namespace: options.namespace ?? "vault",
|
|
3319
3163
|
pendingAuthTtlMs: options.pendingAuthTtlMs
|
|
@@ -3334,7 +3178,7 @@ var InMemoryAuthorizationVault = class extends StorageAuthorizationVault {
|
|
|
3334
3178
|
};
|
|
3335
3179
|
|
|
3336
3180
|
// libs/auth/src/session/redis-session.store.ts
|
|
3337
|
-
var
|
|
3181
|
+
var import_utils18 = require("@frontmcp/utils");
|
|
3338
3182
|
var RedisSessionStore = class {
|
|
3339
3183
|
storage;
|
|
3340
3184
|
keyPrefix;
|
|
@@ -3356,14 +3200,14 @@ var RedisSessionStore = class {
|
|
|
3356
3200
|
});
|
|
3357
3201
|
}
|
|
3358
3202
|
if ("redis" in config && config.redis) {
|
|
3359
|
-
this.storage = new
|
|
3203
|
+
this.storage = new import_utils18.RedisStorageAdapter({
|
|
3360
3204
|
client: config.redis,
|
|
3361
3205
|
keyPrefix: this.keyPrefix
|
|
3362
3206
|
});
|
|
3363
3207
|
this.externalInstance = true;
|
|
3364
3208
|
} else {
|
|
3365
3209
|
const redisConfig = config;
|
|
3366
|
-
this.storage = new
|
|
3210
|
+
this.storage = new import_utils18.RedisStorageAdapter({
|
|
3367
3211
|
config: {
|
|
3368
3212
|
host: redisConfig.host,
|
|
3369
3213
|
port: redisConfig.port ?? 6379,
|
|
@@ -3545,7 +3389,7 @@ var RedisSessionStore = class {
|
|
|
3545
3389
|
* Allocate a new session ID
|
|
3546
3390
|
*/
|
|
3547
3391
|
allocId() {
|
|
3548
|
-
return (0,
|
|
3392
|
+
return (0, import_utils18.randomUUID)();
|
|
3549
3393
|
}
|
|
3550
3394
|
/**
|
|
3551
3395
|
* Disconnect from Redis (only if we created the connection)
|
|
@@ -3581,7 +3425,7 @@ var RedisSessionStore = class {
|
|
|
3581
3425
|
};
|
|
3582
3426
|
|
|
3583
3427
|
// libs/auth/src/session/vercel-kv-session.store.ts
|
|
3584
|
-
var
|
|
3428
|
+
var import_utils19 = require("@frontmcp/utils");
|
|
3585
3429
|
var VercelKvSessionStore = class {
|
|
3586
3430
|
storage;
|
|
3587
3431
|
keyPrefix;
|
|
@@ -3601,7 +3445,7 @@ var VercelKvSessionStore = class {
|
|
|
3601
3445
|
maxRequests: this.security.rateLimiting?.maxRequests
|
|
3602
3446
|
});
|
|
3603
3447
|
}
|
|
3604
|
-
this.storage = new
|
|
3448
|
+
this.storage = new import_utils19.VercelKvStorageAdapter({
|
|
3605
3449
|
url: config.url,
|
|
3606
3450
|
token: config.token,
|
|
3607
3451
|
keyPrefix: this.keyPrefix
|
|
@@ -3775,7 +3619,7 @@ var VercelKvSessionStore = class {
|
|
|
3775
3619
|
* Allocate a new session ID
|
|
3776
3620
|
*/
|
|
3777
3621
|
allocId() {
|
|
3778
|
-
return (0,
|
|
3622
|
+
return (0, import_utils19.randomUUID)();
|
|
3779
3623
|
}
|
|
3780
3624
|
/**
|
|
3781
3625
|
* Disconnect from Vercel KV
|
|
@@ -3804,7 +3648,7 @@ var VercelKvSessionStore = class {
|
|
|
3804
3648
|
};
|
|
3805
3649
|
|
|
3806
3650
|
// libs/auth/src/session/orchestrated-token.store.ts
|
|
3807
|
-
var
|
|
3651
|
+
var import_utils20 = require("@frontmcp/utils");
|
|
3808
3652
|
var InMemoryOrchestratedTokenStore = class {
|
|
3809
3653
|
/** Token storage: Map<compositeKey, ProviderTokenRecord> */
|
|
3810
3654
|
tokens = /* @__PURE__ */ new Map();
|
|
@@ -3846,7 +3690,7 @@ var InMemoryOrchestratedTokenStore = class {
|
|
|
3846
3690
|
}
|
|
3847
3691
|
const info = new TextEncoder().encode(`orchestrated-token:${compositeKey}`);
|
|
3848
3692
|
const salt = new TextEncoder().encode("frontmcp-token-store");
|
|
3849
|
-
const derivedKey = (0,
|
|
3693
|
+
const derivedKey = (0, import_utils20.hkdfSha256)(this.encryptionKey, salt, info, 32);
|
|
3850
3694
|
this.derivedKeys.set(compositeKey, derivedKey);
|
|
3851
3695
|
return derivedKey;
|
|
3852
3696
|
}
|
|
@@ -3856,8 +3700,8 @@ var InMemoryOrchestratedTokenStore = class {
|
|
|
3856
3700
|
async encryptRecord(compositeKey, record) {
|
|
3857
3701
|
const key = await this.deriveKeyForRecord(compositeKey);
|
|
3858
3702
|
const plaintext = JSON.stringify(record);
|
|
3859
|
-
const iv = (0,
|
|
3860
|
-
const { ciphertext, tag } = (0,
|
|
3703
|
+
const iv = (0, import_utils20.randomBytes)(12);
|
|
3704
|
+
const { ciphertext, tag } = (0, import_utils20.encryptAesGcm)(key, new TextEncoder().encode(plaintext), iv);
|
|
3861
3705
|
return JSON.stringify({
|
|
3862
3706
|
iv: Buffer.from(iv).toString("base64url"),
|
|
3863
3707
|
tag: Buffer.from(tag).toString("base64url"),
|
|
@@ -3873,7 +3717,7 @@ var InMemoryOrchestratedTokenStore = class {
|
|
|
3873
3717
|
const ivBytes = Buffer.from(iv, "base64url");
|
|
3874
3718
|
const tagBytes = Buffer.from(tag, "base64url");
|
|
3875
3719
|
const ciphertextBytes = Buffer.from(data, "base64url");
|
|
3876
|
-
const plaintext = (0,
|
|
3720
|
+
const plaintext = (0, import_utils20.decryptAesGcm)(key, ciphertextBytes, ivBytes, tagBytes);
|
|
3877
3721
|
return JSON.parse(new TextDecoder().decode(plaintext));
|
|
3878
3722
|
}
|
|
3879
3723
|
/**
|
|
@@ -4075,7 +3919,7 @@ var InMemoryOrchestratedTokenStore = class {
|
|
|
4075
3919
|
};
|
|
4076
3920
|
|
|
4077
3921
|
// libs/auth/src/session/federated-auth.session.ts
|
|
4078
|
-
var
|
|
3922
|
+
var import_utils21 = require("@frontmcp/utils");
|
|
4079
3923
|
function toSessionRecord(session) {
|
|
4080
3924
|
return {
|
|
4081
3925
|
...session,
|
|
@@ -4150,7 +3994,7 @@ var InMemoryFederatedAuthSessionStore = class {
|
|
|
4150
3994
|
createSession(params) {
|
|
4151
3995
|
const now = Date.now();
|
|
4152
3996
|
return {
|
|
4153
|
-
id: (0,
|
|
3997
|
+
id: (0, import_utils21.randomUUID)(),
|
|
4154
3998
|
pendingAuthId: params.pendingAuthId,
|
|
4155
3999
|
clientId: params.clientId,
|
|
4156
4000
|
redirectUri: params.redirectUri,
|
|
@@ -4182,7 +4026,7 @@ var InMemoryFederatedAuthSessionStore = class {
|
|
|
4182
4026
|
function createFederatedAuthSession(params, ttlMs = 15 * 60 * 1e3) {
|
|
4183
4027
|
const now = Date.now();
|
|
4184
4028
|
return {
|
|
4185
|
-
id: (0,
|
|
4029
|
+
id: (0, import_utils21.randomUUID)(),
|
|
4186
4030
|
pendingAuthId: params.pendingAuthId,
|
|
4187
4031
|
clientId: params.clientId,
|
|
4188
4032
|
redirectUri: params.redirectUri,
|
|
@@ -4239,34 +4083,34 @@ function startNextProvider(session, pkce, state) {
|
|
|
4239
4083
|
}
|
|
4240
4084
|
|
|
4241
4085
|
// libs/auth/src/session/encrypted-authorization-vault.ts
|
|
4242
|
-
var
|
|
4086
|
+
var import_zod5 = require("zod");
|
|
4087
|
+
var import_utils22 = require("@frontmcp/utils");
|
|
4243
4088
|
var import_utils23 = require("@frontmcp/utils");
|
|
4244
|
-
var
|
|
4245
|
-
var redisVaultEntrySchema = import_zod6.z.object({
|
|
4089
|
+
var redisVaultEntrySchema = import_zod5.z.object({
|
|
4246
4090
|
/** Vault ID */
|
|
4247
|
-
id:
|
|
4091
|
+
id: import_zod5.z.string(),
|
|
4248
4092
|
/** User sub (for lookup) */
|
|
4249
|
-
userSub:
|
|
4093
|
+
userSub: import_zod5.z.string(),
|
|
4250
4094
|
/** User email (optional, for display) */
|
|
4251
|
-
userEmail:
|
|
4095
|
+
userEmail: import_zod5.z.string().optional(),
|
|
4252
4096
|
/** User name (optional, for display) */
|
|
4253
|
-
userName:
|
|
4097
|
+
userName: import_zod5.z.string().optional(),
|
|
4254
4098
|
/** Client ID */
|
|
4255
|
-
clientId:
|
|
4099
|
+
clientId: import_zod5.z.string(),
|
|
4256
4100
|
/** Creation timestamp */
|
|
4257
|
-
createdAt:
|
|
4101
|
+
createdAt: import_zod5.z.number(),
|
|
4258
4102
|
/** Last access timestamp */
|
|
4259
|
-
lastAccessAt:
|
|
4103
|
+
lastAccessAt: import_zod5.z.number(),
|
|
4260
4104
|
/** Authorized app IDs (unencrypted for quick auth checks) */
|
|
4261
|
-
authorizedAppIds:
|
|
4105
|
+
authorizedAppIds: import_zod5.z.array(import_zod5.z.string()),
|
|
4262
4106
|
/** Skipped app IDs (unencrypted for quick checks) */
|
|
4263
|
-
skippedAppIds:
|
|
4107
|
+
skippedAppIds: import_zod5.z.array(import_zod5.z.string()),
|
|
4264
4108
|
/** Pending auth request IDs (unencrypted for lookup) */
|
|
4265
|
-
pendingAuthIds:
|
|
4109
|
+
pendingAuthIds: import_zod5.z.array(import_zod5.z.string()),
|
|
4266
4110
|
/** Encrypted sensitive data blob */
|
|
4267
4111
|
encrypted: encryptedDataSchema
|
|
4268
4112
|
});
|
|
4269
|
-
var encryptionContextStorage = new
|
|
4113
|
+
var encryptionContextStorage = new import_utils23.AsyncLocalStorage();
|
|
4270
4114
|
var EncryptedRedisVault = class {
|
|
4271
4115
|
constructor(redis, encryption, namespace = "vault:") {
|
|
4272
4116
|
this.redis = redis;
|
|
@@ -4399,7 +4243,7 @@ var EncryptedRedisVault = class {
|
|
|
4399
4243
|
async create(params) {
|
|
4400
4244
|
const now = Date.now();
|
|
4401
4245
|
const entry = {
|
|
4402
|
-
id: (0,
|
|
4246
|
+
id: (0, import_utils22.randomUUID)(),
|
|
4403
4247
|
userSub: params.userSub,
|
|
4404
4248
|
userEmail: params.userEmail,
|
|
4405
4249
|
userName: params.userName,
|
|
@@ -4458,7 +4302,7 @@ var EncryptedRedisVault = class {
|
|
|
4458
4302
|
}
|
|
4459
4303
|
const now = Date.now();
|
|
4460
4304
|
const pendingAuth = {
|
|
4461
|
-
id: (0,
|
|
4305
|
+
id: (0, import_utils22.randomUUID)(),
|
|
4462
4306
|
appId: params.appId,
|
|
4463
4307
|
toolId: params.toolId,
|
|
4464
4308
|
authUrl: params.authUrl,
|
|
@@ -4667,37 +4511,37 @@ function tryJwtExp(token) {
|
|
|
4667
4511
|
}
|
|
4668
4512
|
|
|
4669
4513
|
// 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:
|
|
4514
|
+
var import_zod6 = require("zod");
|
|
4515
|
+
var authModeSchema = import_zod6.z.enum(["public", "transparent", "orchestrated"]);
|
|
4516
|
+
var authUserSchema = import_zod6.z.object({
|
|
4517
|
+
sub: import_zod6.z.string(),
|
|
4518
|
+
name: import_zod6.z.string().optional(),
|
|
4519
|
+
email: import_zod6.z.string().email().optional(),
|
|
4520
|
+
picture: import_zod6.z.string().url().optional(),
|
|
4521
|
+
anonymous: import_zod6.z.boolean().optional()
|
|
4678
4522
|
});
|
|
4679
|
-
var authorizedToolSchema =
|
|
4680
|
-
executionPath:
|
|
4681
|
-
scopes:
|
|
4682
|
-
details:
|
|
4523
|
+
var authorizedToolSchema = import_zod6.z.object({
|
|
4524
|
+
executionPath: import_zod6.z.tuple([import_zod6.z.string(), import_zod6.z.string()]),
|
|
4525
|
+
scopes: import_zod6.z.array(import_zod6.z.string()).optional(),
|
|
4526
|
+
details: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).optional()
|
|
4683
4527
|
});
|
|
4684
|
-
var authorizedPromptSchema =
|
|
4685
|
-
executionPath:
|
|
4686
|
-
scopes:
|
|
4687
|
-
details:
|
|
4528
|
+
var authorizedPromptSchema = import_zod6.z.object({
|
|
4529
|
+
executionPath: import_zod6.z.tuple([import_zod6.z.string(), import_zod6.z.string()]),
|
|
4530
|
+
scopes: import_zod6.z.array(import_zod6.z.string()).optional(),
|
|
4531
|
+
details: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).optional()
|
|
4688
4532
|
});
|
|
4689
|
-
var llmSafeAuthContextSchema =
|
|
4690
|
-
authorizationId:
|
|
4691
|
-
sessionId:
|
|
4533
|
+
var llmSafeAuthContextSchema = import_zod6.z.object({
|
|
4534
|
+
authorizationId: import_zod6.z.string(),
|
|
4535
|
+
sessionId: import_zod6.z.string(),
|
|
4692
4536
|
mode: authModeSchema,
|
|
4693
|
-
isAnonymous:
|
|
4694
|
-
user:
|
|
4695
|
-
sub:
|
|
4696
|
-
name:
|
|
4537
|
+
isAnonymous: import_zod6.z.boolean(),
|
|
4538
|
+
user: import_zod6.z.object({
|
|
4539
|
+
sub: import_zod6.z.string(),
|
|
4540
|
+
name: import_zod6.z.string().optional()
|
|
4697
4541
|
}),
|
|
4698
|
-
scopes:
|
|
4699
|
-
authorizedToolIds:
|
|
4700
|
-
authorizedPromptIds:
|
|
4542
|
+
scopes: import_zod6.z.array(import_zod6.z.string()),
|
|
4543
|
+
authorizedToolIds: import_zod6.z.array(import_zod6.z.string()),
|
|
4544
|
+
authorizedPromptIds: import_zod6.z.array(import_zod6.z.string())
|
|
4701
4545
|
});
|
|
4702
4546
|
var AppAuthState = /* @__PURE__ */ ((AppAuthState2) => {
|
|
4703
4547
|
AppAuthState2["AUTHORIZED"] = "authorized";
|
|
@@ -4705,19 +4549,19 @@ var AppAuthState = /* @__PURE__ */ ((AppAuthState2) => {
|
|
|
4705
4549
|
AppAuthState2["PENDING"] = "pending";
|
|
4706
4550
|
return AppAuthState2;
|
|
4707
4551
|
})(AppAuthState || {});
|
|
4708
|
-
var appAuthStateSchema =
|
|
4709
|
-
var appAuthorizationRecordSchema =
|
|
4710
|
-
appId:
|
|
4552
|
+
var appAuthStateSchema = import_zod6.z.nativeEnum(AppAuthState);
|
|
4553
|
+
var appAuthorizationRecordSchema = import_zod6.z.object({
|
|
4554
|
+
appId: import_zod6.z.string(),
|
|
4711
4555
|
state: appAuthStateSchema,
|
|
4712
|
-
stateChangedAt:
|
|
4713
|
-
grantedScopes:
|
|
4714
|
-
authProviderId:
|
|
4715
|
-
toolIds:
|
|
4556
|
+
stateChangedAt: import_zod6.z.number(),
|
|
4557
|
+
grantedScopes: import_zod6.z.array(import_zod6.z.string()).optional(),
|
|
4558
|
+
authProviderId: import_zod6.z.string().optional(),
|
|
4559
|
+
toolIds: import_zod6.z.array(import_zod6.z.string())
|
|
4716
4560
|
});
|
|
4717
|
-
var progressiveAuthStateSchema =
|
|
4718
|
-
apps:
|
|
4719
|
-
initiallyAuthorized:
|
|
4720
|
-
initiallySkipped:
|
|
4561
|
+
var progressiveAuthStateSchema = import_zod6.z.object({
|
|
4562
|
+
apps: import_zod6.z.record(import_zod6.z.string(), appAuthorizationRecordSchema),
|
|
4563
|
+
initiallyAuthorized: import_zod6.z.array(import_zod6.z.string()),
|
|
4564
|
+
initiallySkipped: import_zod6.z.array(import_zod6.z.string())
|
|
4721
4565
|
});
|
|
4722
4566
|
|
|
4723
4567
|
// libs/auth/src/authorization/authorization.class.ts
|
|
@@ -5576,42 +5420,42 @@ var OrchestratedAuthAccessorAdapter = class {
|
|
|
5576
5420
|
};
|
|
5577
5421
|
|
|
5578
5422
|
// 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:
|
|
5423
|
+
var import_zod7 = require("zod");
|
|
5424
|
+
var jwkParametersSchema = import_zod7.z.object({
|
|
5425
|
+
kty: import_zod7.z.string().optional(),
|
|
5426
|
+
alg: import_zod7.z.string().optional(),
|
|
5427
|
+
key_ops: import_zod7.z.array(import_zod7.z.string()).optional(),
|
|
5428
|
+
ext: import_zod7.z.boolean().optional(),
|
|
5429
|
+
use: import_zod7.z.string().optional(),
|
|
5430
|
+
x5c: import_zod7.z.array(import_zod7.z.string()).optional(),
|
|
5431
|
+
x5t: import_zod7.z.string().optional(),
|
|
5432
|
+
"x5t#S256": import_zod7.z.string().optional(),
|
|
5433
|
+
x5u: import_zod7.z.string().optional(),
|
|
5434
|
+
kid: import_zod7.z.string().optional()
|
|
5591
5435
|
});
|
|
5592
5436
|
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:
|
|
5437
|
+
crv: import_zod7.z.string().optional(),
|
|
5438
|
+
d: import_zod7.z.string().optional(),
|
|
5439
|
+
dp: import_zod7.z.string().optional(),
|
|
5440
|
+
dq: import_zod7.z.string().optional(),
|
|
5441
|
+
e: import_zod7.z.string().optional(),
|
|
5442
|
+
k: import_zod7.z.string().optional(),
|
|
5443
|
+
n: import_zod7.z.string().optional(),
|
|
5444
|
+
p: import_zod7.z.string().optional(),
|
|
5445
|
+
q: import_zod7.z.string().optional(),
|
|
5446
|
+
qi: import_zod7.z.string().optional(),
|
|
5447
|
+
x: import_zod7.z.string().optional(),
|
|
5448
|
+
y: import_zod7.z.string().optional(),
|
|
5449
|
+
pub: import_zod7.z.string().optional(),
|
|
5450
|
+
priv: import_zod7.z.string().optional()
|
|
5607
5451
|
});
|
|
5608
|
-
var jsonWebKeySetSchema =
|
|
5609
|
-
keys:
|
|
5452
|
+
var jsonWebKeySetSchema = import_zod7.z.object({
|
|
5453
|
+
keys: import_zod7.z.array(jwkSchema)
|
|
5610
5454
|
});
|
|
5611
5455
|
|
|
5612
5456
|
// libs/auth/src/common/session.types.ts
|
|
5613
|
-
var
|
|
5614
|
-
var aiPlatformTypeSchema =
|
|
5457
|
+
var import_zod8 = require("zod");
|
|
5458
|
+
var aiPlatformTypeSchema = import_zod8.z.enum([
|
|
5615
5459
|
"openai",
|
|
5616
5460
|
"claude",
|
|
5617
5461
|
"gemini",
|
|
@@ -5622,45 +5466,45 @@ var aiPlatformTypeSchema = import_zod9.z.enum([
|
|
|
5622
5466
|
"ext-apps",
|
|
5623
5467
|
"unknown"
|
|
5624
5468
|
]);
|
|
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:
|
|
5469
|
+
var userClaimSchema = import_zod8.z.object({
|
|
5470
|
+
iss: import_zod8.z.string(),
|
|
5471
|
+
sid: import_zod8.z.string().optional(),
|
|
5472
|
+
sub: import_zod8.z.string(),
|
|
5473
|
+
exp: import_zod8.z.number().optional(),
|
|
5474
|
+
iat: import_zod8.z.number().optional(),
|
|
5475
|
+
aud: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.array(import_zod8.z.string())]).optional(),
|
|
5476
|
+
email: import_zod8.z.string().optional(),
|
|
5477
|
+
username: import_zod8.z.string().optional(),
|
|
5478
|
+
preferred_username: import_zod8.z.string().optional(),
|
|
5479
|
+
name: import_zod8.z.string().optional(),
|
|
5480
|
+
picture: import_zod8.z.string().optional()
|
|
5637
5481
|
}).passthrough();
|
|
5638
|
-
var sessionIdPayloadSchema =
|
|
5639
|
-
nodeId:
|
|
5640
|
-
authSig:
|
|
5641
|
-
uuid:
|
|
5642
|
-
iat:
|
|
5643
|
-
protocol:
|
|
5644
|
-
isPublic:
|
|
5482
|
+
var sessionIdPayloadSchema = import_zod8.z.object({
|
|
5483
|
+
nodeId: import_zod8.z.string(),
|
|
5484
|
+
authSig: import_zod8.z.string(),
|
|
5485
|
+
uuid: import_zod8.z.string().uuid(),
|
|
5486
|
+
iat: import_zod8.z.number(),
|
|
5487
|
+
protocol: import_zod8.z.enum(["legacy-sse", "sse", "streamable-http", "stateful-http", "stateless-http"]).optional(),
|
|
5488
|
+
isPublic: import_zod8.z.boolean().optional(),
|
|
5645
5489
|
platformType: aiPlatformTypeSchema.optional(),
|
|
5646
|
-
clientName:
|
|
5647
|
-
clientVersion:
|
|
5648
|
-
supportsElicitation:
|
|
5649
|
-
skillsOnlyMode:
|
|
5490
|
+
clientName: import_zod8.z.string().optional(),
|
|
5491
|
+
clientVersion: import_zod8.z.string().optional(),
|
|
5492
|
+
supportsElicitation: import_zod8.z.boolean().optional(),
|
|
5493
|
+
skillsOnlyMode: import_zod8.z.boolean().optional()
|
|
5650
5494
|
});
|
|
5651
|
-
var sessionIdSchema =
|
|
5652
|
-
id:
|
|
5495
|
+
var sessionIdSchema = import_zod8.z.object({
|
|
5496
|
+
id: import_zod8.z.string(),
|
|
5653
5497
|
/** Payload is optional - may be undefined when session validation failed but ID is passed for transport lookup */
|
|
5654
5498
|
payload: sessionIdPayloadSchema.optional()
|
|
5655
5499
|
});
|
|
5656
|
-
var authorizationSchema =
|
|
5657
|
-
token:
|
|
5500
|
+
var authorizationSchema = import_zod8.z.object({
|
|
5501
|
+
token: import_zod8.z.string(),
|
|
5658
5502
|
session: sessionIdSchema.optional(),
|
|
5659
5503
|
user: userClaimSchema
|
|
5660
5504
|
});
|
|
5661
5505
|
|
|
5662
5506
|
// libs/auth/src/options/shared.schemas.ts
|
|
5663
|
-
var
|
|
5507
|
+
var import_zod10 = require("zod");
|
|
5664
5508
|
|
|
5665
5509
|
// libs/auth/src/cimd/cimd.logger.ts
|
|
5666
5510
|
var noopLogger = {
|
|
@@ -5676,169 +5520,169 @@ var noopLogger = {
|
|
|
5676
5520
|
};
|
|
5677
5521
|
|
|
5678
5522
|
// libs/auth/src/cimd/cimd.types.ts
|
|
5679
|
-
var
|
|
5680
|
-
var clientMetadataDocumentSchema =
|
|
5523
|
+
var import_zod9 = require("zod");
|
|
5524
|
+
var clientMetadataDocumentSchema = import_zod9.z.object({
|
|
5681
5525
|
// REQUIRED per CIMD spec
|
|
5682
5526
|
/**
|
|
5683
5527
|
* Client identifier - MUST match the URL from which this document was fetched.
|
|
5684
5528
|
*/
|
|
5685
|
-
client_id:
|
|
5529
|
+
client_id: import_zod9.z.string().url(),
|
|
5686
5530
|
/**
|
|
5687
5531
|
* Human-readable name of the client.
|
|
5688
5532
|
*/
|
|
5689
|
-
client_name:
|
|
5533
|
+
client_name: import_zod9.z.string().min(1),
|
|
5690
5534
|
/**
|
|
5691
5535
|
* Array of redirect URIs for authorization responses.
|
|
5692
5536
|
* At least one is required.
|
|
5693
5537
|
*/
|
|
5694
|
-
redirect_uris:
|
|
5538
|
+
redirect_uris: import_zod9.z.array(import_zod9.z.string().url()).min(1),
|
|
5695
5539
|
// OPTIONAL per RFC 7591
|
|
5696
5540
|
/**
|
|
5697
5541
|
* Token endpoint authentication method.
|
|
5698
5542
|
* @default 'none'
|
|
5699
5543
|
*/
|
|
5700
|
-
token_endpoint_auth_method:
|
|
5544
|
+
token_endpoint_auth_method: import_zod9.z.enum(["none", "client_secret_basic", "client_secret_post", "private_key_jwt"]).default("none"),
|
|
5701
5545
|
/**
|
|
5702
5546
|
* OAuth grant types the client can use.
|
|
5703
5547
|
* @default ['authorization_code']
|
|
5704
5548
|
*/
|
|
5705
|
-
grant_types:
|
|
5549
|
+
grant_types: import_zod9.z.array(import_zod9.z.string()).default(["authorization_code"]),
|
|
5706
5550
|
/**
|
|
5707
5551
|
* OAuth response types the client can request.
|
|
5708
5552
|
* @default ['code']
|
|
5709
5553
|
*/
|
|
5710
|
-
response_types:
|
|
5554
|
+
response_types: import_zod9.z.array(import_zod9.z.string()).default(["code"]),
|
|
5711
5555
|
/**
|
|
5712
5556
|
* URL of the client's home page.
|
|
5713
5557
|
*/
|
|
5714
|
-
client_uri:
|
|
5558
|
+
client_uri: import_zod9.z.string().url().optional(),
|
|
5715
5559
|
/**
|
|
5716
5560
|
* URL of the client's logo image.
|
|
5717
5561
|
*/
|
|
5718
|
-
logo_uri:
|
|
5562
|
+
logo_uri: import_zod9.z.string().url().optional(),
|
|
5719
5563
|
/**
|
|
5720
5564
|
* URL of the client's JWKS (for private_key_jwt).
|
|
5721
5565
|
*/
|
|
5722
|
-
jwks_uri:
|
|
5566
|
+
jwks_uri: import_zod9.z.string().url().optional(),
|
|
5723
5567
|
/**
|
|
5724
5568
|
* Inline JWKS (for private_key_jwt).
|
|
5725
5569
|
*/
|
|
5726
|
-
jwks:
|
|
5727
|
-
keys:
|
|
5570
|
+
jwks: import_zod9.z.object({
|
|
5571
|
+
keys: import_zod9.z.array(import_zod9.z.record(import_zod9.z.string(), import_zod9.z.unknown()))
|
|
5728
5572
|
}).optional(),
|
|
5729
5573
|
/**
|
|
5730
5574
|
* URL of the client's terms of service.
|
|
5731
5575
|
*/
|
|
5732
|
-
tos_uri:
|
|
5576
|
+
tos_uri: import_zod9.z.string().url().optional(),
|
|
5733
5577
|
/**
|
|
5734
5578
|
* URL of the client's privacy policy.
|
|
5735
5579
|
*/
|
|
5736
|
-
policy_uri:
|
|
5580
|
+
policy_uri: import_zod9.z.string().url().optional(),
|
|
5737
5581
|
/**
|
|
5738
5582
|
* Requested OAuth scopes.
|
|
5739
5583
|
*/
|
|
5740
|
-
scope:
|
|
5584
|
+
scope: import_zod9.z.string().optional(),
|
|
5741
5585
|
/**
|
|
5742
5586
|
* Array of contact emails for the client.
|
|
5743
5587
|
*/
|
|
5744
|
-
contacts:
|
|
5588
|
+
contacts: import_zod9.z.array(import_zod9.z.string().email()).optional(),
|
|
5745
5589
|
/**
|
|
5746
5590
|
* Software statement (signed JWT).
|
|
5747
5591
|
*/
|
|
5748
|
-
software_statement:
|
|
5592
|
+
software_statement: import_zod9.z.string().optional(),
|
|
5749
5593
|
/**
|
|
5750
5594
|
* Unique identifier for the client software.
|
|
5751
5595
|
*/
|
|
5752
|
-
software_id:
|
|
5596
|
+
software_id: import_zod9.z.string().optional(),
|
|
5753
5597
|
/**
|
|
5754
5598
|
* Version of the client software.
|
|
5755
5599
|
*/
|
|
5756
|
-
software_version:
|
|
5600
|
+
software_version: import_zod9.z.string().optional()
|
|
5757
5601
|
});
|
|
5758
|
-
var cimdRedisCacheConfigSchema =
|
|
5602
|
+
var cimdRedisCacheConfigSchema = import_zod9.z.object({
|
|
5759
5603
|
/**
|
|
5760
5604
|
* Redis connection URL.
|
|
5761
5605
|
* e.g., "redis://user:pass@host:6379/0"
|
|
5762
5606
|
*/
|
|
5763
|
-
url:
|
|
5607
|
+
url: import_zod9.z.string().optional(),
|
|
5764
5608
|
/**
|
|
5765
5609
|
* Redis host.
|
|
5766
5610
|
*/
|
|
5767
|
-
host:
|
|
5611
|
+
host: import_zod9.z.string().optional(),
|
|
5768
5612
|
/**
|
|
5769
5613
|
* Redis port.
|
|
5770
5614
|
* @default 6379
|
|
5771
5615
|
*/
|
|
5772
|
-
port:
|
|
5616
|
+
port: import_zod9.z.number().optional(),
|
|
5773
5617
|
/**
|
|
5774
5618
|
* Redis password.
|
|
5775
5619
|
*/
|
|
5776
|
-
password:
|
|
5620
|
+
password: import_zod9.z.string().optional(),
|
|
5777
5621
|
/**
|
|
5778
5622
|
* Redis database number.
|
|
5779
5623
|
* @default 0
|
|
5780
5624
|
*/
|
|
5781
|
-
db:
|
|
5625
|
+
db: import_zod9.z.number().optional(),
|
|
5782
5626
|
/**
|
|
5783
5627
|
* Enable TLS for Redis connection.
|
|
5784
5628
|
* @default false
|
|
5785
5629
|
*/
|
|
5786
|
-
tls:
|
|
5630
|
+
tls: import_zod9.z.boolean().optional(),
|
|
5787
5631
|
/**
|
|
5788
5632
|
* Key prefix for CIMD cache entries.
|
|
5789
5633
|
* @default 'cimd:'
|
|
5790
5634
|
*/
|
|
5791
|
-
keyPrefix:
|
|
5635
|
+
keyPrefix: import_zod9.z.string().default("cimd:")
|
|
5792
5636
|
});
|
|
5793
|
-
var cimdCacheConfigSchema =
|
|
5637
|
+
var cimdCacheConfigSchema = import_zod9.z.object({
|
|
5794
5638
|
/**
|
|
5795
5639
|
* Cache storage type.
|
|
5796
5640
|
* - 'memory': In-memory cache (default, suitable for dev/single-instance)
|
|
5797
5641
|
* - 'redis': Redis-backed cache (for production/distributed deployments)
|
|
5798
5642
|
* @default 'memory'
|
|
5799
5643
|
*/
|
|
5800
|
-
type:
|
|
5644
|
+
type: import_zod9.z.enum(["memory", "redis"]).default("memory"),
|
|
5801
5645
|
/**
|
|
5802
5646
|
* Default TTL for cached metadata documents.
|
|
5803
5647
|
* @default 3600000 (1 hour)
|
|
5804
5648
|
*/
|
|
5805
|
-
defaultTtlMs:
|
|
5649
|
+
defaultTtlMs: import_zod9.z.number().min(0).default(36e5),
|
|
5806
5650
|
/**
|
|
5807
5651
|
* Maximum TTL (even if server suggests longer).
|
|
5808
5652
|
* @default 86400000 (24 hours)
|
|
5809
5653
|
*/
|
|
5810
|
-
maxTtlMs:
|
|
5654
|
+
maxTtlMs: import_zod9.z.number().min(0).default(864e5),
|
|
5811
5655
|
/**
|
|
5812
5656
|
* Minimum TTL (even if server suggests shorter).
|
|
5813
5657
|
* @default 60000 (1 minute)
|
|
5814
5658
|
*/
|
|
5815
|
-
minTtlMs:
|
|
5659
|
+
minTtlMs: import_zod9.z.number().min(0).default(6e4),
|
|
5816
5660
|
/**
|
|
5817
5661
|
* Redis configuration (required when type is 'redis').
|
|
5818
5662
|
*/
|
|
5819
5663
|
redis: cimdRedisCacheConfigSchema.optional()
|
|
5820
5664
|
});
|
|
5821
|
-
var cimdSecurityConfigSchema =
|
|
5665
|
+
var cimdSecurityConfigSchema = import_zod9.z.object({
|
|
5822
5666
|
/**
|
|
5823
5667
|
* Block fetching from private/internal IP addresses (SSRF protection).
|
|
5824
5668
|
* @default true
|
|
5825
5669
|
*/
|
|
5826
|
-
blockPrivateIPs:
|
|
5670
|
+
blockPrivateIPs: import_zod9.z.boolean().default(true),
|
|
5827
5671
|
/**
|
|
5828
5672
|
* Explicit list of allowed domains.
|
|
5829
5673
|
* If set, only these domains can host CIMD documents.
|
|
5830
5674
|
*/
|
|
5831
|
-
allowedDomains:
|
|
5675
|
+
allowedDomains: import_zod9.z.array(import_zod9.z.string()).optional(),
|
|
5832
5676
|
/**
|
|
5833
5677
|
* Explicit list of blocked domains.
|
|
5834
5678
|
* These domains cannot host CIMD documents.
|
|
5835
5679
|
*/
|
|
5836
|
-
blockedDomains:
|
|
5680
|
+
blockedDomains: import_zod9.z.array(import_zod9.z.string()).optional(),
|
|
5837
5681
|
/**
|
|
5838
5682
|
* Warn when a client has only localhost redirect URIs.
|
|
5839
5683
|
* @default true
|
|
5840
5684
|
*/
|
|
5841
|
-
warnOnLocalhostRedirects:
|
|
5685
|
+
warnOnLocalhostRedirects: import_zod9.z.boolean().default(true),
|
|
5842
5686
|
/**
|
|
5843
5687
|
* Allow HTTP (instead of HTTPS) for localhost CIMD URLs.
|
|
5844
5688
|
*
|
|
@@ -5849,19 +5693,19 @@ var cimdSecurityConfigSchema = import_zod10.z.object({
|
|
|
5849
5693
|
*
|
|
5850
5694
|
* @default false
|
|
5851
5695
|
*/
|
|
5852
|
-
allowInsecureForTesting:
|
|
5696
|
+
allowInsecureForTesting: import_zod9.z.boolean().default(false)
|
|
5853
5697
|
});
|
|
5854
|
-
var cimdNetworkConfigSchema =
|
|
5698
|
+
var cimdNetworkConfigSchema = import_zod9.z.object({
|
|
5855
5699
|
/**
|
|
5856
5700
|
* Request timeout in milliseconds.
|
|
5857
5701
|
* @default 5000 (5 seconds)
|
|
5858
5702
|
*/
|
|
5859
|
-
timeoutMs:
|
|
5703
|
+
timeoutMs: import_zod9.z.number().min(100).default(5e3),
|
|
5860
5704
|
/**
|
|
5861
5705
|
* Maximum response body size in bytes.
|
|
5862
5706
|
* @default 65536 (64KB)
|
|
5863
5707
|
*/
|
|
5864
|
-
maxResponseSizeBytes:
|
|
5708
|
+
maxResponseSizeBytes: import_zod9.z.number().min(1024).default(65536),
|
|
5865
5709
|
/**
|
|
5866
5710
|
* Redirect handling policy for CIMD fetches.
|
|
5867
5711
|
* - 'deny': reject redirects (default, safest)
|
|
@@ -5869,19 +5713,19 @@ var cimdNetworkConfigSchema = import_zod10.z.object({
|
|
|
5869
5713
|
* - 'allow': allow redirects to any origin
|
|
5870
5714
|
* @default 'deny'
|
|
5871
5715
|
*/
|
|
5872
|
-
redirectPolicy:
|
|
5716
|
+
redirectPolicy: import_zod9.z.enum(["deny", "same-origin", "allow"]).default("deny"),
|
|
5873
5717
|
/**
|
|
5874
5718
|
* Maximum number of redirects to follow when redirects are allowed.
|
|
5875
5719
|
* @default 5
|
|
5876
5720
|
*/
|
|
5877
|
-
maxRedirects:
|
|
5721
|
+
maxRedirects: import_zod9.z.number().int().min(0).default(5)
|
|
5878
5722
|
});
|
|
5879
|
-
var cimdConfigSchema =
|
|
5723
|
+
var cimdConfigSchema = import_zod9.z.object({
|
|
5880
5724
|
/**
|
|
5881
5725
|
* Enable CIMD support.
|
|
5882
5726
|
* @default true
|
|
5883
5727
|
*/
|
|
5884
|
-
enabled:
|
|
5728
|
+
enabled: import_zod9.z.boolean().default(true),
|
|
5885
5729
|
/**
|
|
5886
5730
|
* Cache configuration.
|
|
5887
5731
|
*/
|
|
@@ -6244,7 +6088,7 @@ var CimdService = class {
|
|
|
6244
6088
|
this.cacheConfig = cimdCacheConfigSchema.parse(this.config.cache ?? {});
|
|
6245
6089
|
this.securityConfig = cimdSecurityConfigSchema.parse(this.config.security ?? {});
|
|
6246
6090
|
this.networkConfig = cimdNetworkConfigSchema.parse(this.config.network ?? {});
|
|
6247
|
-
this.cache = new
|
|
6091
|
+
this.cache = new InMemoryCimdCache(this.cacheConfig);
|
|
6248
6092
|
this.logger.debug("CimdService initialized", {
|
|
6249
6093
|
enabled: this.config.enabled,
|
|
6250
6094
|
cacheDefaultTtlMs: this.cacheConfig.defaultTtlMs,
|
|
@@ -6512,8 +6356,8 @@ var CimdService = class {
|
|
|
6512
6356
|
const result = clientMetadataDocumentSchema.safeParse(document);
|
|
6513
6357
|
if (!result.success) {
|
|
6514
6358
|
const errors = result.error.issues.map((issue) => {
|
|
6515
|
-
const
|
|
6516
|
-
return `${
|
|
6359
|
+
const path = issue.path.length > 0 ? `${issue.path.join(".")}: ` : "";
|
|
6360
|
+
return `${path}${issue.message}`;
|
|
6517
6361
|
});
|
|
6518
6362
|
throw new CimdValidationError(clientId, errors);
|
|
6519
6363
|
}
|
|
@@ -6535,55 +6379,84 @@ function normalizeRedirectUri(uri) {
|
|
|
6535
6379
|
}
|
|
6536
6380
|
|
|
6537
6381
|
// libs/auth/src/options/shared.schemas.ts
|
|
6538
|
-
var publicAccessConfigSchema =
|
|
6382
|
+
var publicAccessConfigSchema = import_zod10.z.object({
|
|
6539
6383
|
/**
|
|
6540
6384
|
* Allow all tools or explicit whitelist
|
|
6541
6385
|
* @default 'all'
|
|
6542
6386
|
*/
|
|
6543
|
-
tools:
|
|
6387
|
+
tools: import_zod10.z.union([import_zod10.z.literal("all"), import_zod10.z.array(import_zod10.z.string())]).default("all"),
|
|
6544
6388
|
/**
|
|
6545
6389
|
* Allow all prompts or explicit whitelist
|
|
6546
6390
|
* @default 'all'
|
|
6547
6391
|
*/
|
|
6548
|
-
prompts:
|
|
6392
|
+
prompts: import_zod10.z.union([import_zod10.z.literal("all"), import_zod10.z.array(import_zod10.z.string())]).default("all"),
|
|
6549
6393
|
/**
|
|
6550
6394
|
* Rate limit per IP per minute
|
|
6551
6395
|
* @default 60
|
|
6552
6396
|
*/
|
|
6553
|
-
rateLimit:
|
|
6397
|
+
rateLimit: import_zod10.z.number().default(60)
|
|
6554
6398
|
});
|
|
6555
|
-
var localSigningConfigSchema =
|
|
6399
|
+
var localSigningConfigSchema = import_zod10.z.object({
|
|
6556
6400
|
/**
|
|
6557
|
-
* Private key for signing
|
|
6401
|
+
* Private key for signing tokens
|
|
6558
6402
|
* @default auto-generated
|
|
6559
6403
|
*/
|
|
6560
|
-
signKey: jwkSchema.or(
|
|
6404
|
+
signKey: jwkSchema.or(import_zod10.z.instanceof(Uint8Array)).optional(),
|
|
6561
6405
|
/**
|
|
6562
6406
|
* JWKS for token verification
|
|
6563
6407
|
* @default auto-generated
|
|
6564
6408
|
*/
|
|
6565
6409
|
jwks: jsonWebKeySetSchema.optional(),
|
|
6566
6410
|
/**
|
|
6567
|
-
* Issuer identifier for
|
|
6411
|
+
* Issuer identifier for tokens
|
|
6568
6412
|
* @default auto-derived from server URL
|
|
6569
6413
|
*/
|
|
6570
|
-
issuer:
|
|
6414
|
+
issuer: import_zod10.z.string().optional()
|
|
6571
6415
|
});
|
|
6572
|
-
var
|
|
6416
|
+
var providerConfigSchema = import_zod10.z.object({
|
|
6417
|
+
/** Provider display name */
|
|
6418
|
+
name: import_zod10.z.string().optional(),
|
|
6419
|
+
/**
|
|
6420
|
+
* Unique identifier for this provider
|
|
6421
|
+
* @default derived from provider URL
|
|
6422
|
+
*/
|
|
6423
|
+
id: import_zod10.z.string().optional(),
|
|
6424
|
+
/**
|
|
6425
|
+
* Inline JWKS for offline token verification
|
|
6426
|
+
* Falls back to fetching from provider's /.well-known/jwks.json
|
|
6427
|
+
*/
|
|
6428
|
+
jwks: jsonWebKeySetSchema.optional(),
|
|
6429
|
+
/** Custom JWKS URI if not at standard path */
|
|
6430
|
+
jwksUri: import_zod10.z.string().url().optional(),
|
|
6431
|
+
/**
|
|
6432
|
+
* Enable Dynamic Client Registration (DCR)
|
|
6433
|
+
* @default false
|
|
6434
|
+
*/
|
|
6435
|
+
dcrEnabled: import_zod10.z.boolean().default(false),
|
|
6436
|
+
/** Authorization endpoint override */
|
|
6437
|
+
authEndpoint: import_zod10.z.string().url().optional(),
|
|
6438
|
+
/** Token endpoint override */
|
|
6439
|
+
tokenEndpoint: import_zod10.z.string().url().optional(),
|
|
6440
|
+
/** Registration endpoint override (for DCR) */
|
|
6441
|
+
registrationEndpoint: import_zod10.z.string().url().optional(),
|
|
6442
|
+
/** User info endpoint override */
|
|
6443
|
+
userInfoEndpoint: import_zod10.z.string().url().optional()
|
|
6444
|
+
});
|
|
6445
|
+
var remoteProviderConfigSchema = import_zod10.z.object({
|
|
6573
6446
|
/**
|
|
6574
6447
|
* OAuth provider base URL
|
|
6575
6448
|
* @example 'https://auth.example.com'
|
|
6576
6449
|
*/
|
|
6577
|
-
provider:
|
|
6450
|
+
provider: import_zod10.z.string().url(),
|
|
6578
6451
|
/**
|
|
6579
6452
|
* Provider display name
|
|
6580
6453
|
*/
|
|
6581
|
-
name:
|
|
6454
|
+
name: import_zod10.z.string().optional(),
|
|
6582
6455
|
/**
|
|
6583
6456
|
* Unique identifier for this provider
|
|
6584
6457
|
* @default derived from provider URL
|
|
6585
6458
|
*/
|
|
6586
|
-
id:
|
|
6459
|
+
id: import_zod10.z.string().optional(),
|
|
6587
6460
|
/**
|
|
6588
6461
|
* Inline JWKS for offline token verification
|
|
6589
6462
|
* Falls back to fetching from provider's /.well-known/jwks.json
|
|
@@ -6592,121 +6465,133 @@ var remoteProviderConfigSchema = import_zod11.z.object({
|
|
|
6592
6465
|
/**
|
|
6593
6466
|
* Custom JWKS URI if not at standard path
|
|
6594
6467
|
*/
|
|
6595
|
-
jwksUri:
|
|
6468
|
+
jwksUri: import_zod10.z.string().url().optional(),
|
|
6596
6469
|
/**
|
|
6597
|
-
* Client ID for this MCP server
|
|
6470
|
+
* Client ID for this MCP server
|
|
6598
6471
|
*/
|
|
6599
|
-
clientId:
|
|
6472
|
+
clientId: import_zod10.z.string().optional(),
|
|
6600
6473
|
/**
|
|
6601
|
-
* Client secret (for confidential clients
|
|
6474
|
+
* Client secret (for confidential clients)
|
|
6602
6475
|
*/
|
|
6603
|
-
clientSecret:
|
|
6476
|
+
clientSecret: import_zod10.z.string().optional(),
|
|
6604
6477
|
/**
|
|
6605
6478
|
* Scopes to request from the upstream provider
|
|
6606
6479
|
*/
|
|
6607
|
-
scopes:
|
|
6480
|
+
scopes: import_zod10.z.array(import_zod10.z.string()).optional(),
|
|
6608
6481
|
/**
|
|
6609
6482
|
* Enable Dynamic Client Registration (DCR)
|
|
6610
6483
|
* @default false
|
|
6611
6484
|
*/
|
|
6612
|
-
dcrEnabled:
|
|
6485
|
+
dcrEnabled: import_zod10.z.boolean().default(false),
|
|
6613
6486
|
/**
|
|
6614
6487
|
* Authorization endpoint override
|
|
6615
6488
|
*/
|
|
6616
|
-
authEndpoint:
|
|
6489
|
+
authEndpoint: import_zod10.z.string().url().optional(),
|
|
6617
6490
|
/**
|
|
6618
6491
|
* Token endpoint override
|
|
6619
6492
|
*/
|
|
6620
|
-
tokenEndpoint:
|
|
6493
|
+
tokenEndpoint: import_zod10.z.string().url().optional(),
|
|
6621
6494
|
/**
|
|
6622
6495
|
* Registration endpoint override (for DCR)
|
|
6623
6496
|
*/
|
|
6624
|
-
registrationEndpoint:
|
|
6497
|
+
registrationEndpoint: import_zod10.z.string().url().optional(),
|
|
6625
6498
|
/**
|
|
6626
6499
|
* User info endpoint override
|
|
6627
6500
|
*/
|
|
6628
|
-
userInfoEndpoint:
|
|
6501
|
+
userInfoEndpoint: import_zod10.z.string().url().optional()
|
|
6629
6502
|
});
|
|
6630
|
-
var
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6503
|
+
var flatRemoteProviderFields = {
|
|
6504
|
+
/**
|
|
6505
|
+
* OAuth provider base URL (required)
|
|
6506
|
+
* @example 'https://auth.example.com'
|
|
6507
|
+
*/
|
|
6508
|
+
provider: import_zod10.z.string().url(),
|
|
6509
|
+
/** Client ID for this MCP server */
|
|
6510
|
+
clientId: import_zod10.z.string().optional(),
|
|
6511
|
+
/** Client secret (for confidential clients) */
|
|
6512
|
+
clientSecret: import_zod10.z.string().optional(),
|
|
6513
|
+
/** Scopes to request from the upstream provider */
|
|
6514
|
+
scopes: import_zod10.z.array(import_zod10.z.string()).optional(),
|
|
6515
|
+
/** Advanced provider configuration */
|
|
6516
|
+
providerConfig: providerConfigSchema.optional()
|
|
6517
|
+
};
|
|
6518
|
+
var tokenStorageConfigSchema = import_zod10.z.union([import_zod10.z.literal("memory"), import_zod10.z.object({ redis: redisConfigSchema })]);
|
|
6519
|
+
var tokenRefreshConfigSchema = import_zod10.z.object({
|
|
6635
6520
|
/**
|
|
6636
6521
|
* Enable automatic token refresh
|
|
6637
6522
|
* @default true
|
|
6638
6523
|
*/
|
|
6639
|
-
enabled:
|
|
6524
|
+
enabled: import_zod10.z.boolean().default(true),
|
|
6640
6525
|
/**
|
|
6641
6526
|
* Refresh token before expiry by this many seconds
|
|
6642
6527
|
* @default 60
|
|
6643
6528
|
*/
|
|
6644
|
-
skewSeconds:
|
|
6529
|
+
skewSeconds: import_zod10.z.number().default(60)
|
|
6645
6530
|
});
|
|
6646
|
-
var skippedAppBehaviorSchema =
|
|
6647
|
-
var consentConfigSchema =
|
|
6531
|
+
var skippedAppBehaviorSchema = import_zod10.z.enum(["anonymous", "require-auth"]);
|
|
6532
|
+
var consentConfigSchema = import_zod10.z.object({
|
|
6648
6533
|
/**
|
|
6649
6534
|
* Enable consent flow for tool selection
|
|
6650
6535
|
* When enabled, users can choose which tools to expose to the LLM
|
|
6651
6536
|
* @default false
|
|
6652
6537
|
*/
|
|
6653
|
-
enabled:
|
|
6538
|
+
enabled: import_zod10.z.boolean().default(false),
|
|
6654
6539
|
/**
|
|
6655
6540
|
* Group tools by app in the consent UI
|
|
6656
6541
|
* @default true
|
|
6657
6542
|
*/
|
|
6658
|
-
groupByApp:
|
|
6543
|
+
groupByApp: import_zod10.z.boolean().default(true),
|
|
6659
6544
|
/**
|
|
6660
6545
|
* Show tool descriptions in consent UI
|
|
6661
6546
|
* @default true
|
|
6662
6547
|
*/
|
|
6663
|
-
showDescriptions:
|
|
6548
|
+
showDescriptions: import_zod10.z.boolean().default(true),
|
|
6664
6549
|
/**
|
|
6665
6550
|
* Allow selecting all tools at once
|
|
6666
6551
|
* @default true
|
|
6667
6552
|
*/
|
|
6668
|
-
allowSelectAll:
|
|
6553
|
+
allowSelectAll: import_zod10.z.boolean().default(true),
|
|
6669
6554
|
/**
|
|
6670
6555
|
* Require at least one tool to be selected
|
|
6671
6556
|
* @default true
|
|
6672
6557
|
*/
|
|
6673
|
-
requireSelection:
|
|
6558
|
+
requireSelection: import_zod10.z.boolean().default(true),
|
|
6674
6559
|
/**
|
|
6675
6560
|
* Custom message to display on consent page
|
|
6676
6561
|
*/
|
|
6677
|
-
customMessage:
|
|
6562
|
+
customMessage: import_zod10.z.string().optional(),
|
|
6678
6563
|
/**
|
|
6679
6564
|
* Remember consent for future sessions
|
|
6680
6565
|
* @default true
|
|
6681
6566
|
*/
|
|
6682
|
-
rememberConsent:
|
|
6567
|
+
rememberConsent: import_zod10.z.boolean().default(true),
|
|
6683
6568
|
/**
|
|
6684
6569
|
* Tools to exclude from consent (always available)
|
|
6685
6570
|
* Useful for essential tools that should always be accessible
|
|
6686
6571
|
*/
|
|
6687
|
-
excludedTools:
|
|
6572
|
+
excludedTools: import_zod10.z.array(import_zod10.z.string()).optional(),
|
|
6688
6573
|
/**
|
|
6689
6574
|
* Tools to always include in consent (pre-selected)
|
|
6690
6575
|
*/
|
|
6691
|
-
defaultSelectedTools:
|
|
6576
|
+
defaultSelectedTools: import_zod10.z.array(import_zod10.z.string()).optional()
|
|
6692
6577
|
});
|
|
6693
|
-
var federatedAuthConfigSchema =
|
|
6578
|
+
var federatedAuthConfigSchema = import_zod10.z.object({
|
|
6694
6579
|
/**
|
|
6695
6580
|
* How strictly to validate the OAuth state parameter on provider callbacks.
|
|
6696
6581
|
* - 'strict': require exact match to stored state (default, safest)
|
|
6697
6582
|
* - 'format': validate only "federated:{sessionId}:{nonce}" format
|
|
6698
6583
|
* @default 'strict'
|
|
6699
6584
|
*/
|
|
6700
|
-
stateValidation:
|
|
6585
|
+
stateValidation: import_zod10.z.enum(["strict", "format"]).default("strict")
|
|
6701
6586
|
});
|
|
6702
|
-
var incrementalAuthConfigSchema =
|
|
6587
|
+
var incrementalAuthConfigSchema = import_zod10.z.object({
|
|
6703
6588
|
/**
|
|
6704
6589
|
* Enable incremental (progressive) authorization
|
|
6705
6590
|
* When enabled, users can skip app authorizations during initial auth
|
|
6706
6591
|
* and authorize individual apps later when needed
|
|
6707
6592
|
* @default true
|
|
6708
6593
|
*/
|
|
6709
|
-
enabled:
|
|
6594
|
+
enabled: import_zod10.z.boolean().default(true),
|
|
6710
6595
|
/**
|
|
6711
6596
|
* Behavior when a tool from a skipped app is called
|
|
6712
6597
|
* - 'anonymous': If app supports anonymous access, use it; otherwise require auth
|
|
@@ -6718,33 +6603,33 @@ var incrementalAuthConfigSchema = import_zod11.z.object({
|
|
|
6718
6603
|
* Allow users to skip app authorization during initial auth flow
|
|
6719
6604
|
* @default true
|
|
6720
6605
|
*/
|
|
6721
|
-
allowSkip:
|
|
6606
|
+
allowSkip: import_zod10.z.boolean().default(true),
|
|
6722
6607
|
/**
|
|
6723
6608
|
* Show all apps in a single authorization page (vs step-by-step)
|
|
6724
6609
|
* @default true
|
|
6725
6610
|
*/
|
|
6726
|
-
showAllAppsAtOnce:
|
|
6611
|
+
showAllAppsAtOnce: import_zod10.z.boolean().default(true)
|
|
6727
6612
|
});
|
|
6728
6613
|
|
|
6729
6614
|
// libs/auth/src/options/public.schema.ts
|
|
6730
|
-
var
|
|
6731
|
-
var publicAuthOptionsSchema =
|
|
6732
|
-
mode:
|
|
6615
|
+
var import_zod11 = require("zod");
|
|
6616
|
+
var publicAuthOptionsSchema = import_zod11.z.object({
|
|
6617
|
+
mode: import_zod11.z.literal("public"),
|
|
6733
6618
|
/**
|
|
6734
6619
|
* Issuer identifier for anonymous JWTs
|
|
6735
6620
|
* @default auto-derived from server URL
|
|
6736
6621
|
*/
|
|
6737
|
-
issuer:
|
|
6622
|
+
issuer: import_zod11.z.string().optional(),
|
|
6738
6623
|
/**
|
|
6739
6624
|
* Anonymous session TTL in seconds
|
|
6740
6625
|
* @default 3600 (1 hour)
|
|
6741
6626
|
*/
|
|
6742
|
-
sessionTtl:
|
|
6627
|
+
sessionTtl: import_zod11.z.number().default(3600),
|
|
6743
6628
|
/**
|
|
6744
6629
|
* Scopes granted to anonymous sessions
|
|
6745
6630
|
* @default ['anonymous']
|
|
6746
6631
|
*/
|
|
6747
|
-
anonymousScopes:
|
|
6632
|
+
anonymousScopes: import_zod11.z.array(import_zod11.z.string()).default(["anonymous"]),
|
|
6748
6633
|
/**
|
|
6749
6634
|
* Tool/prompt access configuration for anonymous users
|
|
6750
6635
|
*/
|
|
@@ -6758,38 +6643,38 @@ var publicAuthOptionsSchema = import_zod12.z.object({
|
|
|
6758
6643
|
* Private key for signing anonymous tokens
|
|
6759
6644
|
* @default auto-generated
|
|
6760
6645
|
*/
|
|
6761
|
-
signKey: jwkSchema.or(
|
|
6646
|
+
signKey: jwkSchema.or(import_zod11.z.instanceof(Uint8Array)).optional()
|
|
6762
6647
|
});
|
|
6763
6648
|
|
|
6764
6649
|
// libs/auth/src/options/transparent.schema.ts
|
|
6765
|
-
var
|
|
6766
|
-
var transparentAuthOptionsSchema =
|
|
6767
|
-
mode:
|
|
6650
|
+
var import_zod12 = require("zod");
|
|
6651
|
+
var transparentAuthOptionsSchema = import_zod12.z.object({
|
|
6652
|
+
mode: import_zod12.z.literal("transparent"),
|
|
6768
6653
|
/**
|
|
6769
|
-
*
|
|
6654
|
+
* Flattened remote provider fields (provider, clientId, clientSecret, scopes, providerConfig)
|
|
6770
6655
|
*/
|
|
6771
|
-
|
|
6656
|
+
...flatRemoteProviderFields,
|
|
6772
6657
|
/**
|
|
6773
6658
|
* Expected token audience
|
|
6774
6659
|
* If not set, defaults to the resource URL
|
|
6775
6660
|
*/
|
|
6776
|
-
expectedAudience:
|
|
6661
|
+
expectedAudience: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.array(import_zod12.z.string())]).optional(),
|
|
6777
6662
|
/**
|
|
6778
6663
|
* Required scopes for access
|
|
6779
6664
|
* Empty array means any valid token is accepted
|
|
6780
6665
|
* @default []
|
|
6781
6666
|
*/
|
|
6782
|
-
requiredScopes:
|
|
6667
|
+
requiredScopes: import_zod12.z.array(import_zod12.z.string()).default([]),
|
|
6783
6668
|
/**
|
|
6784
6669
|
* Allow anonymous fallback when no token is provided
|
|
6785
6670
|
* @default false
|
|
6786
6671
|
*/
|
|
6787
|
-
allowAnonymous:
|
|
6672
|
+
allowAnonymous: import_zod12.z.boolean().default(false),
|
|
6788
6673
|
/**
|
|
6789
6674
|
* Scopes granted to anonymous sessions (when allowAnonymous=true)
|
|
6790
6675
|
* @default ['anonymous']
|
|
6791
6676
|
*/
|
|
6792
|
-
anonymousScopes:
|
|
6677
|
+
anonymousScopes: import_zod12.z.array(import_zod12.z.string()).default(["anonymous"]),
|
|
6793
6678
|
/**
|
|
6794
6679
|
* Public access config for anonymous users (when allowAnonymous=true)
|
|
6795
6680
|
*/
|
|
@@ -6797,56 +6682,52 @@ var transparentAuthOptionsSchema = import_zod13.z.object({
|
|
|
6797
6682
|
});
|
|
6798
6683
|
|
|
6799
6684
|
// libs/auth/src/options/orchestrated.schema.ts
|
|
6800
|
-
var
|
|
6801
|
-
var
|
|
6685
|
+
var import_zod13 = require("zod");
|
|
6686
|
+
var sharedAuthFields = {
|
|
6802
6687
|
local: localSigningConfigSchema.optional(),
|
|
6803
|
-
tokenStorage: tokenStorageConfigSchema.default(
|
|
6804
|
-
allowDefaultPublic:
|
|
6805
|
-
anonymousScopes:
|
|
6688
|
+
tokenStorage: tokenStorageConfigSchema.default("memory"),
|
|
6689
|
+
allowDefaultPublic: import_zod13.z.boolean().default(false),
|
|
6690
|
+
anonymousScopes: import_zod13.z.array(import_zod13.z.string()).default(["anonymous"]),
|
|
6806
6691
|
publicAccess: publicAccessConfigSchema.optional(),
|
|
6807
6692
|
consent: consentConfigSchema.optional(),
|
|
6808
6693
|
federatedAuth: federatedAuthConfigSchema.optional(),
|
|
6809
6694
|
refresh: tokenRefreshConfigSchema.optional(),
|
|
6810
|
-
expectedAudience:
|
|
6695
|
+
expectedAudience: import_zod13.z.union([import_zod13.z.string(), import_zod13.z.array(import_zod13.z.string())]).optional(),
|
|
6811
6696
|
incrementalAuth: incrementalAuthConfigSchema.optional(),
|
|
6812
6697
|
cimd: cimdConfigSchema.optional()
|
|
6813
6698
|
};
|
|
6814
|
-
var
|
|
6815
|
-
mode:
|
|
6816
|
-
|
|
6817
|
-
...orchestratedSharedFields
|
|
6699
|
+
var localAuthSchema = import_zod13.z.object({
|
|
6700
|
+
mode: import_zod13.z.literal("local"),
|
|
6701
|
+
...sharedAuthFields
|
|
6818
6702
|
});
|
|
6819
|
-
var
|
|
6820
|
-
mode:
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
...orchestratedSharedFields
|
|
6703
|
+
var remoteAuthSchema = import_zod13.z.object({
|
|
6704
|
+
mode: import_zod13.z.literal("remote"),
|
|
6705
|
+
...flatRemoteProviderFields,
|
|
6706
|
+
...sharedAuthFields
|
|
6824
6707
|
});
|
|
6825
|
-
var
|
|
6826
|
-
|
|
6827
|
-
orchestratedRemoteSchema
|
|
6828
|
-
]);
|
|
6708
|
+
var orchestratedLocalSchema = localAuthSchema;
|
|
6709
|
+
var orchestratedRemoteSchema = remoteAuthSchema;
|
|
6829
6710
|
|
|
6830
6711
|
// libs/auth/src/options/schema.ts
|
|
6831
|
-
var
|
|
6832
|
-
var authOptionsSchema =
|
|
6712
|
+
var import_zod14 = require("zod");
|
|
6713
|
+
var authOptionsSchema = import_zod14.z.union([
|
|
6833
6714
|
publicAuthOptionsSchema,
|
|
6834
6715
|
transparentAuthOptionsSchema,
|
|
6835
|
-
|
|
6836
|
-
|
|
6716
|
+
localAuthSchema,
|
|
6717
|
+
remoteAuthSchema
|
|
6837
6718
|
]);
|
|
6838
6719
|
|
|
6839
6720
|
// libs/auth/src/options/app-auth.schema.ts
|
|
6840
|
-
var
|
|
6721
|
+
var import_zod15 = require("zod");
|
|
6841
6722
|
var standaloneOptionSchema = {
|
|
6842
|
-
standalone:
|
|
6843
|
-
excludeFromParent:
|
|
6723
|
+
standalone: import_zod15.z.boolean().optional(),
|
|
6724
|
+
excludeFromParent: import_zod15.z.boolean().optional()
|
|
6844
6725
|
};
|
|
6845
|
-
var appAuthOptionsSchema =
|
|
6726
|
+
var appAuthOptionsSchema = import_zod15.z.union([
|
|
6846
6727
|
publicAuthOptionsSchema.extend(standaloneOptionSchema),
|
|
6847
6728
|
transparentAuthOptionsSchema.extend(standaloneOptionSchema),
|
|
6848
|
-
|
|
6849
|
-
|
|
6729
|
+
localAuthSchema.extend(standaloneOptionSchema),
|
|
6730
|
+
remoteAuthSchema.extend(standaloneOptionSchema)
|
|
6850
6731
|
]);
|
|
6851
6732
|
|
|
6852
6733
|
// libs/auth/src/options/utils.ts
|
|
@@ -6859,136 +6740,142 @@ function isPublicMode(options) {
|
|
|
6859
6740
|
function isTransparentMode(options) {
|
|
6860
6741
|
return options.mode === "transparent";
|
|
6861
6742
|
}
|
|
6743
|
+
function isLocalMode(options) {
|
|
6744
|
+
return options.mode === "local";
|
|
6745
|
+
}
|
|
6746
|
+
function isRemoteMode(options) {
|
|
6747
|
+
return options.mode === "remote";
|
|
6748
|
+
}
|
|
6862
6749
|
function isOrchestratedMode(options) {
|
|
6863
|
-
return options.mode === "
|
|
6750
|
+
return options.mode === "local" || options.mode === "remote";
|
|
6864
6751
|
}
|
|
6865
6752
|
function isOrchestratedLocal(options) {
|
|
6866
|
-
return options.
|
|
6753
|
+
return options.mode === "local";
|
|
6867
6754
|
}
|
|
6868
6755
|
function isOrchestratedRemote(options) {
|
|
6869
|
-
return options.
|
|
6756
|
+
return options.mode === "remote";
|
|
6870
6757
|
}
|
|
6871
6758
|
function allowsPublicAccess(options) {
|
|
6872
6759
|
if (options.mode === "public") return true;
|
|
6873
6760
|
if (options.mode === "transparent") return options.allowAnonymous;
|
|
6874
|
-
if (options.mode === "
|
|
6761
|
+
if (options.mode === "local" || options.mode === "remote") return options.allowDefaultPublic;
|
|
6875
6762
|
return false;
|
|
6876
6763
|
}
|
|
6877
6764
|
|
|
6878
6765
|
// libs/auth/src/consent/consent.types.ts
|
|
6879
|
-
var
|
|
6880
|
-
var consentToolItemSchema =
|
|
6766
|
+
var import_zod16 = require("zod");
|
|
6767
|
+
var consentToolItemSchema = import_zod16.z.object({
|
|
6881
6768
|
/** Tool ID (e.g., 'slack:send_message') */
|
|
6882
|
-
id:
|
|
6769
|
+
id: import_zod16.z.string().min(1),
|
|
6883
6770
|
/** Tool name for display */
|
|
6884
|
-
name:
|
|
6771
|
+
name: import_zod16.z.string().min(1),
|
|
6885
6772
|
/** Tool description */
|
|
6886
|
-
description:
|
|
6773
|
+
description: import_zod16.z.string().optional(),
|
|
6887
6774
|
/** App ID this tool belongs to */
|
|
6888
|
-
appId:
|
|
6775
|
+
appId: import_zod16.z.string().min(1),
|
|
6889
6776
|
/** App name for display */
|
|
6890
|
-
appName:
|
|
6777
|
+
appName: import_zod16.z.string().min(1),
|
|
6891
6778
|
/** Whether the tool is selected by default */
|
|
6892
|
-
defaultSelected:
|
|
6779
|
+
defaultSelected: import_zod16.z.boolean().default(true),
|
|
6893
6780
|
/** Whether this tool requires specific scopes */
|
|
6894
|
-
requiredScopes:
|
|
6781
|
+
requiredScopes: import_zod16.z.array(import_zod16.z.string()).optional(),
|
|
6895
6782
|
/** Category for grouping (e.g., 'read', 'write', 'admin') */
|
|
6896
|
-
category:
|
|
6783
|
+
category: import_zod16.z.string().optional()
|
|
6897
6784
|
});
|
|
6898
|
-
var consentSelectionSchema =
|
|
6785
|
+
var consentSelectionSchema = import_zod16.z.object({
|
|
6899
6786
|
/** Selected tool IDs */
|
|
6900
|
-
selectedTools:
|
|
6787
|
+
selectedTools: import_zod16.z.array(import_zod16.z.string()),
|
|
6901
6788
|
/** Whether all tools were selected */
|
|
6902
|
-
allSelected:
|
|
6789
|
+
allSelected: import_zod16.z.boolean(),
|
|
6903
6790
|
/** Timestamp when consent was given */
|
|
6904
|
-
consentedAt:
|
|
6791
|
+
consentedAt: import_zod16.z.string().datetime(),
|
|
6905
6792
|
/** Consent version for tracking changes */
|
|
6906
|
-
consentVersion:
|
|
6793
|
+
consentVersion: import_zod16.z.string().default("1.0")
|
|
6907
6794
|
});
|
|
6908
|
-
var consentStateSchema =
|
|
6795
|
+
var consentStateSchema = import_zod16.z.object({
|
|
6909
6796
|
/** Whether consent flow is enabled */
|
|
6910
|
-
enabled:
|
|
6797
|
+
enabled: import_zod16.z.boolean(),
|
|
6911
6798
|
/** Available tools for consent */
|
|
6912
|
-
availableTools:
|
|
6799
|
+
availableTools: import_zod16.z.array(consentToolItemSchema),
|
|
6913
6800
|
/** Pre-selected tools (from previous consent or defaults) */
|
|
6914
|
-
preselectedTools:
|
|
6801
|
+
preselectedTools: import_zod16.z.array(import_zod16.z.string()).optional(),
|
|
6915
6802
|
/** Whether to show all tools or group by app */
|
|
6916
|
-
groupByApp:
|
|
6803
|
+
groupByApp: import_zod16.z.boolean().default(true),
|
|
6917
6804
|
/** Custom consent message */
|
|
6918
|
-
customMessage:
|
|
6805
|
+
customMessage: import_zod16.z.string().optional()
|
|
6919
6806
|
});
|
|
6920
|
-
var federatedProviderItemSchema =
|
|
6807
|
+
var federatedProviderItemSchema = import_zod16.z.object({
|
|
6921
6808
|
/** Provider ID (derived or explicit) */
|
|
6922
|
-
id:
|
|
6809
|
+
id: import_zod16.z.string().min(1),
|
|
6923
6810
|
/** Provider display name */
|
|
6924
|
-
name:
|
|
6811
|
+
name: import_zod16.z.string().min(1),
|
|
6925
6812
|
/** Provider description */
|
|
6926
|
-
description:
|
|
6813
|
+
description: import_zod16.z.string().optional(),
|
|
6927
6814
|
/** Provider icon URL or emoji */
|
|
6928
|
-
icon:
|
|
6815
|
+
icon: import_zod16.z.string().optional(),
|
|
6929
6816
|
/** Provider type */
|
|
6930
|
-
type:
|
|
6817
|
+
type: import_zod16.z.enum(["local", "remote", "transparent"]),
|
|
6931
6818
|
/** OAuth provider URL (for remote providers) */
|
|
6932
|
-
providerUrl:
|
|
6819
|
+
providerUrl: import_zod16.z.string().url().optional(),
|
|
6933
6820
|
/** Apps using this provider */
|
|
6934
|
-
appIds:
|
|
6821
|
+
appIds: import_zod16.z.array(import_zod16.z.string()),
|
|
6935
6822
|
/** App names using this provider */
|
|
6936
|
-
appNames:
|
|
6823
|
+
appNames: import_zod16.z.array(import_zod16.z.string()),
|
|
6937
6824
|
/** Scopes required by this provider */
|
|
6938
|
-
scopes:
|
|
6825
|
+
scopes: import_zod16.z.array(import_zod16.z.string()),
|
|
6939
6826
|
/** Whether this is the primary/parent provider */
|
|
6940
|
-
isPrimary:
|
|
6827
|
+
isPrimary: import_zod16.z.boolean(),
|
|
6941
6828
|
/** Whether this provider is optional (can be skipped) */
|
|
6942
|
-
isOptional:
|
|
6829
|
+
isOptional: import_zod16.z.boolean().default(false)
|
|
6943
6830
|
});
|
|
6944
|
-
var federatedLoginStateSchema =
|
|
6831
|
+
var federatedLoginStateSchema = import_zod16.z.object({
|
|
6945
6832
|
/** All available providers */
|
|
6946
|
-
providers:
|
|
6833
|
+
providers: import_zod16.z.array(federatedProviderItemSchema),
|
|
6947
6834
|
/** Primary provider ID (if any) */
|
|
6948
|
-
primaryProviderId:
|
|
6835
|
+
primaryProviderId: import_zod16.z.string().optional(),
|
|
6949
6836
|
/** Whether user can skip optional providers */
|
|
6950
|
-
allowSkip:
|
|
6837
|
+
allowSkip: import_zod16.z.boolean().default(true),
|
|
6951
6838
|
/** Pre-selected provider IDs (from previous session) */
|
|
6952
|
-
preselectedProviders:
|
|
6839
|
+
preselectedProviders: import_zod16.z.array(import_zod16.z.string()).optional()
|
|
6953
6840
|
});
|
|
6954
|
-
var federatedSelectionSchema =
|
|
6841
|
+
var federatedSelectionSchema = import_zod16.z.object({
|
|
6955
6842
|
/** Selected provider IDs */
|
|
6956
|
-
selectedProviders:
|
|
6843
|
+
selectedProviders: import_zod16.z.array(import_zod16.z.string()),
|
|
6957
6844
|
/** Skipped provider IDs */
|
|
6958
|
-
skippedProviders:
|
|
6845
|
+
skippedProviders: import_zod16.z.array(import_zod16.z.string()),
|
|
6959
6846
|
/** Provider-specific metadata */
|
|
6960
|
-
providerMetadata:
|
|
6847
|
+
providerMetadata: import_zod16.z.record(import_zod16.z.string(), import_zod16.z.unknown()).optional()
|
|
6961
6848
|
});
|
|
6962
6849
|
|
|
6963
6850
|
// 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:
|
|
6851
|
+
var import_zod17 = require("zod");
|
|
6852
|
+
var detectedAuthProviderSchema = import_zod17.z.object({
|
|
6853
|
+
id: import_zod17.z.string(),
|
|
6854
|
+
providerUrl: import_zod17.z.string().optional(),
|
|
6855
|
+
mode: import_zod17.z.enum(["public", "transparent", "local", "remote"]),
|
|
6856
|
+
appIds: import_zod17.z.array(import_zod17.z.string()),
|
|
6857
|
+
scopes: import_zod17.z.array(import_zod17.z.string()),
|
|
6858
|
+
isParentProvider: import_zod17.z.boolean()
|
|
6972
6859
|
});
|
|
6973
|
-
var authProviderDetectionResultSchema =
|
|
6974
|
-
providers:
|
|
6975
|
-
requiresOrchestration:
|
|
6976
|
-
parentProviderId:
|
|
6977
|
-
childProviderIds:
|
|
6978
|
-
uniqueProviderCount:
|
|
6979
|
-
validationErrors:
|
|
6980
|
-
warnings:
|
|
6860
|
+
var authProviderDetectionResultSchema = import_zod17.z.object({
|
|
6861
|
+
providers: import_zod17.z.map(import_zod17.z.string(), detectedAuthProviderSchema),
|
|
6862
|
+
requiresOrchestration: import_zod17.z.boolean(),
|
|
6863
|
+
parentProviderId: import_zod17.z.string().optional(),
|
|
6864
|
+
childProviderIds: import_zod17.z.array(import_zod17.z.string()),
|
|
6865
|
+
uniqueProviderCount: import_zod17.z.number(),
|
|
6866
|
+
validationErrors: import_zod17.z.array(import_zod17.z.string()),
|
|
6867
|
+
warnings: import_zod17.z.array(import_zod17.z.string())
|
|
6981
6868
|
});
|
|
6982
6869
|
function deriveProviderId(options) {
|
|
6983
6870
|
if (isPublicMode(options)) {
|
|
6984
6871
|
return options.issuer ?? "public";
|
|
6985
6872
|
}
|
|
6986
6873
|
if (isTransparentMode(options)) {
|
|
6987
|
-
return options.
|
|
6874
|
+
return options.providerConfig?.id ?? urlToProviderId(options.provider);
|
|
6988
6875
|
}
|
|
6989
6876
|
if (isOrchestratedMode(options)) {
|
|
6990
6877
|
if (isOrchestratedRemote(options)) {
|
|
6991
|
-
return options.
|
|
6878
|
+
return options.providerConfig?.id ?? urlToProviderId(options.provider);
|
|
6992
6879
|
}
|
|
6993
6880
|
return options.local?.issuer ?? "local";
|
|
6994
6881
|
}
|
|
@@ -7008,7 +6895,7 @@ function extractScopes(options) {
|
|
|
7008
6895
|
}
|
|
7009
6896
|
if (isOrchestratedMode(options)) {
|
|
7010
6897
|
if (isOrchestratedRemote(options)) {
|
|
7011
|
-
return options.
|
|
6898
|
+
return options.scopes || [];
|
|
7012
6899
|
}
|
|
7013
6900
|
}
|
|
7014
6901
|
return [];
|
|
@@ -7057,12 +6944,12 @@ function detectAuthProviders(parentAuth, apps) {
|
|
|
7057
6944
|
const requiresOrchestration = hasMultipleProviders || hasChildOnlyProviders || childProviderIds.length > 0 && parentProviderId !== void 0;
|
|
7058
6945
|
if (requiresOrchestration && parentAuth && isTransparentMode(parentAuth)) {
|
|
7059
6946
|
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
|
|
6947
|
+
`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
6948
|
);
|
|
7062
6949
|
}
|
|
7063
6950
|
if (uniqueProviderCount > 1 && parentAuth && isPublicMode(parentAuth)) {
|
|
7064
6951
|
warnings.push(
|
|
7065
|
-
`Parent uses public mode but apps have auth providers configured. App-level auth will be used, but consider using
|
|
6952
|
+
`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
6953
|
);
|
|
7067
6954
|
}
|
|
7068
6955
|
return {
|
|
@@ -7077,10 +6964,10 @@ function detectAuthProviders(parentAuth, apps) {
|
|
|
7077
6964
|
}
|
|
7078
6965
|
function getProviderUrl(options) {
|
|
7079
6966
|
if (isTransparentMode(options)) {
|
|
7080
|
-
return options.
|
|
6967
|
+
return options.provider;
|
|
7081
6968
|
}
|
|
7082
6969
|
if (isOrchestratedMode(options) && isOrchestratedRemote(options)) {
|
|
7083
|
-
return options.
|
|
6970
|
+
return options.provider;
|
|
7084
6971
|
}
|
|
7085
6972
|
return void 0;
|
|
7086
6973
|
}
|
|
@@ -7250,9 +7137,9 @@ function escapeQuotedString(value) {
|
|
|
7250
7137
|
function unescapeQuotedString(value) {
|
|
7251
7138
|
return value.replace(/\\(.)/g, "$1");
|
|
7252
7139
|
}
|
|
7253
|
-
function normalizePathSegment(
|
|
7254
|
-
if (!
|
|
7255
|
-
const normalized =
|
|
7140
|
+
function normalizePathSegment(path) {
|
|
7141
|
+
if (!path || path === "/") return "";
|
|
7142
|
+
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
7256
7143
|
let end = normalized.length;
|
|
7257
7144
|
while (end > 0 && normalized[end - 1] === "/") {
|
|
7258
7145
|
end--;
|
|
@@ -7367,43 +7254,43 @@ var AudienceValidator = class _AudienceValidator {
|
|
|
7367
7254
|
};
|
|
7368
7255
|
|
|
7369
7256
|
// 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:
|
|
7257
|
+
var import_zod18 = require("zod");
|
|
7258
|
+
var credentialScopeSchema = import_zod18.z.enum(["global", "user", "session"]);
|
|
7259
|
+
var loadingStrategySchema = import_zod18.z.enum(["eager", "lazy"]);
|
|
7260
|
+
var getCredentialOptionsSchema = import_zod18.z.object({
|
|
7261
|
+
forceRefresh: import_zod18.z.boolean().optional(),
|
|
7262
|
+
scopes: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
7263
|
+
timeout: import_zod18.z.number().positive().optional()
|
|
7377
7264
|
}).strict();
|
|
7378
|
-
var credentialProviderConfigSchema =
|
|
7379
|
-
name:
|
|
7380
|
-
description:
|
|
7265
|
+
var credentialProviderConfigSchema = import_zod18.z.object({
|
|
7266
|
+
name: import_zod18.z.string().min(1),
|
|
7267
|
+
description: import_zod18.z.string().optional(),
|
|
7381
7268
|
scope: credentialScopeSchema,
|
|
7382
7269
|
loading: loadingStrategySchema,
|
|
7383
|
-
cacheTtl:
|
|
7270
|
+
cacheTtl: import_zod18.z.number().nonnegative().optional(),
|
|
7384
7271
|
// Functions validated at runtime, not via Zod (Zod 4 compatibility)
|
|
7385
|
-
factory:
|
|
7386
|
-
refresh:
|
|
7387
|
-
toHeaders:
|
|
7388
|
-
metadata:
|
|
7389
|
-
required:
|
|
7272
|
+
factory: import_zod18.z.any(),
|
|
7273
|
+
refresh: import_zod18.z.any().optional(),
|
|
7274
|
+
toHeaders: import_zod18.z.any().optional(),
|
|
7275
|
+
metadata: import_zod18.z.record(import_zod18.z.string(), import_zod18.z.unknown()).optional(),
|
|
7276
|
+
required: import_zod18.z.boolean().optional()
|
|
7390
7277
|
}).strict();
|
|
7391
|
-
var authProviderMappingSchema =
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
name:
|
|
7395
|
-
required:
|
|
7396
|
-
scopes:
|
|
7397
|
-
alias:
|
|
7278
|
+
var authProviderMappingSchema = import_zod18.z.union([
|
|
7279
|
+
import_zod18.z.string(),
|
|
7280
|
+
import_zod18.z.object({
|
|
7281
|
+
name: import_zod18.z.string().min(1),
|
|
7282
|
+
required: import_zod18.z.boolean().optional().default(true),
|
|
7283
|
+
scopes: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
7284
|
+
alias: import_zod18.z.string().optional()
|
|
7398
7285
|
}).strict()
|
|
7399
7286
|
]);
|
|
7400
|
-
var authProvidersVaultOptionsSchema =
|
|
7401
|
-
enabled:
|
|
7402
|
-
useSharedStorage:
|
|
7403
|
-
namespace:
|
|
7404
|
-
defaultCacheTtl:
|
|
7405
|
-
maxCredentialsPerSession:
|
|
7406
|
-
providers:
|
|
7287
|
+
var authProvidersVaultOptionsSchema = import_zod18.z.object({
|
|
7288
|
+
enabled: import_zod18.z.boolean().optional(),
|
|
7289
|
+
useSharedStorage: import_zod18.z.boolean().optional().default(true),
|
|
7290
|
+
namespace: import_zod18.z.string().optional().default("authproviders:"),
|
|
7291
|
+
defaultCacheTtl: import_zod18.z.number().nonnegative().optional().default(36e5),
|
|
7292
|
+
maxCredentialsPerSession: import_zod18.z.number().positive().optional().default(100),
|
|
7293
|
+
providers: import_zod18.z.array(credentialProviderConfigSchema).optional()
|
|
7407
7294
|
}).strict();
|
|
7408
7295
|
|
|
7409
7296
|
// libs/auth/src/vault/credential-helpers.ts
|
|
@@ -8383,7 +8270,6 @@ var LazyCredentialLoader = class {
|
|
|
8383
8270
|
AuthProvidersVault,
|
|
8384
8271
|
AuthorizationBase,
|
|
8385
8272
|
CDN,
|
|
8386
|
-
CimdCache,
|
|
8387
8273
|
CimdClientIdMismatchError,
|
|
8388
8274
|
CimdDisabledError,
|
|
8389
8275
|
CimdError,
|
|
@@ -8405,6 +8291,7 @@ var LazyCredentialLoader = class {
|
|
|
8405
8291
|
EncryptionKeyNotConfiguredError,
|
|
8406
8292
|
InMemoryAuthorizationStore,
|
|
8407
8293
|
InMemoryAuthorizationVault,
|
|
8294
|
+
InMemoryCimdCache,
|
|
8408
8295
|
InMemoryFederatedAuthSessionStore,
|
|
8409
8296
|
InMemoryOrchestratedTokenStore,
|
|
8410
8297
|
InMemoryStoreRequiredError,
|
|
@@ -8500,7 +8387,6 @@ var LazyCredentialLoader = class {
|
|
|
8500
8387
|
decryptSessionJson,
|
|
8501
8388
|
decryptValue,
|
|
8502
8389
|
defaultSessionRateLimiter,
|
|
8503
|
-
deleteDevKey,
|
|
8504
8390
|
deriveAuthorizationId,
|
|
8505
8391
|
deriveExpectedAudience,
|
|
8506
8392
|
deriveProviderId,
|
|
@@ -8522,6 +8408,7 @@ var LazyCredentialLoader = class {
|
|
|
8522
8408
|
federatedLoginStateSchema,
|
|
8523
8409
|
federatedProviderItemSchema,
|
|
8524
8410
|
federatedSelectionSchema,
|
|
8411
|
+
flatRemoteProviderFields,
|
|
8525
8412
|
fromSessionRecord,
|
|
8526
8413
|
generatePkceChallenge,
|
|
8527
8414
|
getCredentialOptionsSchema,
|
|
@@ -8535,12 +8422,13 @@ var LazyCredentialLoader = class {
|
|
|
8535
8422
|
hkdfSha256,
|
|
8536
8423
|
incrementalAuthConfigSchema,
|
|
8537
8424
|
isCimdClientId,
|
|
8538
|
-
isDevKeyPersistenceEnabled,
|
|
8539
8425
|
isJwt,
|
|
8426
|
+
isLocalMode,
|
|
8540
8427
|
isOrchestratedLocal,
|
|
8541
8428
|
isOrchestratedMode,
|
|
8542
8429
|
isOrchestratedRemote,
|
|
8543
8430
|
isPublicMode,
|
|
8431
|
+
isRemoteMode,
|
|
8544
8432
|
isSessionComplete,
|
|
8545
8433
|
isSignedSession,
|
|
8546
8434
|
isSoonExpiring,
|
|
@@ -8551,14 +8439,13 @@ var LazyCredentialLoader = class {
|
|
|
8551
8439
|
jwkSchema,
|
|
8552
8440
|
legacySseTransportStateSchema,
|
|
8553
8441
|
llmSafeAuthContextSchema,
|
|
8554
|
-
loadDevKey,
|
|
8555
8442
|
loadingStrategySchema,
|
|
8443
|
+
localAuthSchema,
|
|
8556
8444
|
localSigningConfigSchema,
|
|
8557
8445
|
mtlsCredentialSchema,
|
|
8558
8446
|
noopLogger,
|
|
8559
8447
|
normalizeIssuer,
|
|
8560
8448
|
oauthCredentialSchema,
|
|
8561
|
-
orchestratedAuthOptionsSchema,
|
|
8562
8449
|
orchestratedLocalSchema,
|
|
8563
8450
|
orchestratedRemoteSchema,
|
|
8564
8451
|
parseAuthOptions,
|
|
@@ -8569,16 +8456,16 @@ var LazyCredentialLoader = class {
|
|
|
8569
8456
|
pkceOAuthCredentialSchema,
|
|
8570
8457
|
privateKeyCredentialSchema,
|
|
8571
8458
|
progressiveAuthStateSchema,
|
|
8459
|
+
providerConfigSchema,
|
|
8572
8460
|
publicAccessConfigSchema,
|
|
8573
8461
|
publicAuthOptionsSchema,
|
|
8574
8462
|
redisConfigSchema,
|
|
8575
8463
|
redisVaultEntrySchema,
|
|
8464
|
+
remoteAuthSchema,
|
|
8576
8465
|
remoteProviderConfigSchema,
|
|
8577
8466
|
renderToHtml,
|
|
8578
8467
|
resetCachedKey,
|
|
8579
|
-
resolveKeyPath,
|
|
8580
8468
|
safeDecrypt,
|
|
8581
|
-
saveDevKey,
|
|
8582
8469
|
serviceAccountCredentialSchema,
|
|
8583
8470
|
sessionIdPayloadSchema,
|
|
8584
8471
|
sessionJwtPayloadSchema,
|