@enterprisestandard/react 0.0.5-beta.20260114.2 → 0.0.5-beta.20260115.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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +144 -115
- package/dist/index.js.map +10 -10
- package/dist/sso-server.d.ts +13 -0
- package/dist/sso-server.d.ts.map +1 -0
- package/dist/sso.d.ts +1 -1
- package/dist/sso.d.ts.map +1 -1
- package/dist/tenant.d.ts.map +1 -1
- package/dist/workload-server.d.ts +7 -6
- package/dist/workload-server.d.ts.map +1 -1
- package/dist/workload.d.ts +1 -1
- package/dist/workload.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/server.d.ts +0 -9
- package/dist/server.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type { GroupStore, StoredGroup } from './group-store';
|
|
|
24
24
|
export { InMemoryGroupStore } from './group-store';
|
|
25
25
|
export type { CreateGroupOptions, CreateUserOptions, GroupsInboundHandlerConfig, IAM, IAMConfig, IAMGroupsInbound, IAMGroupsOutbound, IAMHandlerConfig, IAMUsersInbound, ScimError, ScimListResponse, ScimResult, UsersInboundHandlerConfig, } from './iam';
|
|
26
26
|
export { iam } from './iam';
|
|
27
|
-
export * from './server';
|
|
27
|
+
export * from './sso-server';
|
|
28
28
|
export type { SessionStore } from './session-store';
|
|
29
29
|
export { InMemorySessionStore } from './session-store';
|
|
30
30
|
export type { SSO, SSOConfig, SSOHandlerConfig } from './sso';
|
|
@@ -47,7 +47,7 @@ export { SignedOut } from './ui/signed-out';
|
|
|
47
47
|
export * from './ui/sso-provider';
|
|
48
48
|
export type { StoredUser, UserStore } from './user-store';
|
|
49
49
|
export { InMemoryUserStore } from './user-store';
|
|
50
|
-
export { getDefaultInstance
|
|
50
|
+
export { getDefaultInstance } from './utils';
|
|
51
51
|
export type { Vault } from './vault';
|
|
52
52
|
export { vault } from './vault';
|
|
53
53
|
export type { ClientCredentialsWorkloadConfig, JwtBearerWorkloadConfig, ServerOnlyWorkloadConfig, Workload, WorkloadConfig, WorkloadIdentity, } from './workload';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAO,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAO,MAAM,OAAO,CAAC;AAE7E,OAAO,EAAE,KAAK,KAAK,EAAS,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAY,MAAM,YAAY,CAAC;AAE1E,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG;IAC1C,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,KAAK,QAAQ,GAAG;IACd,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,UAAU,CAAC,EACP;QACE,GAAG,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;QACrC,QAAQ,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;KACzC,GACD,gBAAgB,CAAC,YAAY,CAAC,GAC9B,cAAc,CAAC,YAAY,CAAC,CAAC;CAClC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EA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AY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAEhG,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAElC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,YAAY,EACV,+BAA+B,EAC/B,uBAAuB,EACvB,wBAAwB,EACxB,QAAQ,EACR,cAAc,EACd,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1930,7 +1930,7 @@ function sso(config) {
|
|
|
1930
1930
|
const str = atob(val);
|
|
1931
1931
|
return JSON.parse(str);
|
|
1932
1932
|
}
|
|
1933
|
-
async function handler(request,
|
|
1933
|
+
async function handler(request, es) {
|
|
1934
1934
|
const {
|
|
1935
1935
|
loginUrl,
|
|
1936
1936
|
userUrl,
|
|
@@ -1942,7 +1942,7 @@ function sso(config) {
|
|
|
1942
1942
|
logoutBackChannelUrl,
|
|
1943
1943
|
jwksUrl,
|
|
1944
1944
|
validation
|
|
1945
|
-
} = { ...handlerDefaults, ...
|
|
1945
|
+
} = { ...handlerDefaults, ...es?.sso };
|
|
1946
1946
|
if (!configWithDefaults) {
|
|
1947
1947
|
throw new Error("Enterprise Standard SSO Manager not initialized");
|
|
1948
1948
|
}
|
|
@@ -2292,39 +2292,47 @@ function validateWorkloadConfig(config) {
|
|
|
2292
2292
|
}
|
|
2293
2293
|
}
|
|
2294
2294
|
function workload(config) {
|
|
2295
|
-
validateWorkloadConfig(config);
|
|
2296
2295
|
let configWithDefaults;
|
|
2297
|
-
if (
|
|
2298
|
-
configWithDefaults =
|
|
2299
|
-
...config,
|
|
2300
|
-
token_url: must(config.token_url, "Missing 'token_url' from Workload Config"),
|
|
2301
|
-
workload_id: must(config.workload_id, "Missing 'workload_id' from Workload Config"),
|
|
2302
|
-
audience: must(config.audience, "Missing 'audience' from Workload Config"),
|
|
2303
|
-
scope: config.scope ?? "",
|
|
2304
|
-
algorithm: config.algorithm ?? "RS256",
|
|
2305
|
-
token_lifetime: config.token_lifetime ?? 300,
|
|
2306
|
-
refresh_threshold: config.refresh_threshold ?? 60,
|
|
2307
|
-
auto_refresh: config.auto_refresh !== undefined ? config.auto_refresh : true,
|
|
2308
|
-
token_store: config.token_store ?? new InMemoryWorkloadTokenStore
|
|
2309
|
-
};
|
|
2310
|
-
} else if (isClientCredentialsConfig(config)) {
|
|
2311
|
-
configWithDefaults = {
|
|
2312
|
-
...config,
|
|
2313
|
-
token_url: must(config.token_url, "Missing 'token_url' from Workload Config"),
|
|
2314
|
-
client_id: must(config.client_id, "Missing 'client_id' from Workload Config"),
|
|
2315
|
-
client_secret: must(config.client_secret, "Missing 'client_secret' from Workload Config"),
|
|
2316
|
-
scope: config.scope ?? "",
|
|
2317
|
-
token_lifetime: config.token_lifetime ?? 300,
|
|
2318
|
-
refresh_threshold: config.refresh_threshold ?? 60,
|
|
2319
|
-
auto_refresh: config.auto_refresh !== undefined ? config.auto_refresh : true,
|
|
2320
|
-
token_store: config.token_store ?? new InMemoryWorkloadTokenStore
|
|
2321
|
-
};
|
|
2296
|
+
if (!config) {
|
|
2297
|
+
configWithDefaults = undefined;
|
|
2322
2298
|
} else {
|
|
2323
|
-
|
|
2299
|
+
try {
|
|
2300
|
+
validateWorkloadConfig(config);
|
|
2301
|
+
if (isJwtBearerConfig(config)) {
|
|
2302
|
+
configWithDefaults = {
|
|
2303
|
+
...config,
|
|
2304
|
+
token_url: must(config.token_url, "Missing 'token_url' from Workload Config"),
|
|
2305
|
+
workload_id: must(config.workload_id, "Missing 'workload_id' from Workload Config"),
|
|
2306
|
+
audience: must(config.audience, "Missing 'audience' from Workload Config"),
|
|
2307
|
+
scope: config.scope ?? "",
|
|
2308
|
+
algorithm: config.algorithm ?? "RS256",
|
|
2309
|
+
token_lifetime: config.token_lifetime ?? 300,
|
|
2310
|
+
refresh_threshold: config.refresh_threshold ?? 60,
|
|
2311
|
+
auto_refresh: config.auto_refresh !== undefined ? config.auto_refresh : true,
|
|
2312
|
+
token_store: config.token_store ?? new InMemoryWorkloadTokenStore
|
|
2313
|
+
};
|
|
2314
|
+
} else if (isClientCredentialsConfig(config)) {
|
|
2315
|
+
configWithDefaults = {
|
|
2316
|
+
...config,
|
|
2317
|
+
token_url: must(config.token_url, "Missing 'token_url' from Workload Config"),
|
|
2318
|
+
client_id: must(config.client_id, "Missing 'client_id' from Workload Config"),
|
|
2319
|
+
client_secret: must(config.client_secret, "Missing 'client_secret' from Workload Config"),
|
|
2320
|
+
scope: config.scope ?? "",
|
|
2321
|
+
token_lifetime: config.token_lifetime ?? 300,
|
|
2322
|
+
refresh_threshold: config.refresh_threshold ?? 60,
|
|
2323
|
+
auto_refresh: config.auto_refresh !== undefined ? config.auto_refresh : true,
|
|
2324
|
+
token_store: config.token_store ?? new InMemoryWorkloadTokenStore
|
|
2325
|
+
};
|
|
2326
|
+
} else {
|
|
2327
|
+
configWithDefaults = config;
|
|
2328
|
+
}
|
|
2329
|
+
} catch {
|
|
2330
|
+
configWithDefaults = undefined;
|
|
2331
|
+
}
|
|
2324
2332
|
}
|
|
2325
2333
|
const initialized = true;
|
|
2326
|
-
function
|
|
2327
|
-
if (!initialized) {
|
|
2334
|
+
function _ensureInitialized() {
|
|
2335
|
+
if (!initialized || !configWithDefaults) {
|
|
2328
2336
|
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2329
2337
|
}
|
|
2330
2338
|
}
|
|
@@ -2394,8 +2402,10 @@ function workload(config) {
|
|
|
2394
2402
|
throw lastError;
|
|
2395
2403
|
}
|
|
2396
2404
|
async function generateJWTAssertion(scope) {
|
|
2397
|
-
|
|
2398
|
-
|
|
2405
|
+
if (!configWithDefaults) {
|
|
2406
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2407
|
+
}
|
|
2408
|
+
if (!isJwtBearerConfig(configWithDefaults)) {
|
|
2399
2409
|
throw new Error("generateJWTAssertion is only available in JWT Bearer Grant mode");
|
|
2400
2410
|
}
|
|
2401
2411
|
const cfg = configWithDefaults;
|
|
@@ -2421,6 +2431,9 @@ function workload(config) {
|
|
|
2421
2431
|
return `${signatureInput}.${signature}`;
|
|
2422
2432
|
}
|
|
2423
2433
|
async function acquireTokenJwtBearer(scope, validation) {
|
|
2434
|
+
if (!configWithDefaults) {
|
|
2435
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2436
|
+
}
|
|
2424
2437
|
const cfg = configWithDefaults;
|
|
2425
2438
|
return retryWithBackoff(async () => {
|
|
2426
2439
|
const tokenUrl = cfg.token_url;
|
|
@@ -2466,6 +2479,9 @@ function workload(config) {
|
|
|
2466
2479
|
});
|
|
2467
2480
|
}
|
|
2468
2481
|
async function acquireTokenClientCredentials(scope, validation) {
|
|
2482
|
+
if (!configWithDefaults) {
|
|
2483
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2484
|
+
}
|
|
2469
2485
|
const cfg = configWithDefaults;
|
|
2470
2486
|
return retryWithBackoff(async () => {
|
|
2471
2487
|
const tokenUrl = cfg.token_url;
|
|
@@ -2511,8 +2527,10 @@ function workload(config) {
|
|
|
2511
2527
|
});
|
|
2512
2528
|
}
|
|
2513
2529
|
async function getToken(scope) {
|
|
2514
|
-
|
|
2515
|
-
|
|
2530
|
+
if (!configWithDefaults) {
|
|
2531
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2532
|
+
}
|
|
2533
|
+
if (isServerOnlyConfig(configWithDefaults)) {
|
|
2516
2534
|
throw new Error("Cannot acquire tokens: Workload is configured in server-only mode (validation only). " + "To acquire tokens, configure client_id + client_secret for OAuth2 Client Credentials, " + "or workload_id + private_key for JWT Bearer Grant.");
|
|
2517
2535
|
}
|
|
2518
2536
|
if (!configWithDefaults.token_url) {
|
|
@@ -2548,7 +2566,7 @@ function workload(config) {
|
|
|
2548
2566
|
}
|
|
2549
2567
|
if (cfg.auto_refresh) {
|
|
2550
2568
|
try {
|
|
2551
|
-
const newToken = isJwtBearerConfig(
|
|
2569
|
+
const newToken = isJwtBearerConfig(configWithDefaults) ? await acquireTokenJwtBearer(requestedScope) : await acquireTokenClientCredentials(requestedScope);
|
|
2552
2570
|
return newToken.access_token;
|
|
2553
2571
|
} catch (error) {
|
|
2554
2572
|
if (now < expiresAt) {
|
|
@@ -2560,35 +2578,39 @@ function workload(config) {
|
|
|
2560
2578
|
}
|
|
2561
2579
|
}
|
|
2562
2580
|
}
|
|
2563
|
-
const tokenResponse = isJwtBearerConfig(
|
|
2581
|
+
const tokenResponse = isJwtBearerConfig(configWithDefaults) ? await acquireTokenJwtBearer(requestedScope) : await acquireTokenClientCredentials(requestedScope);
|
|
2564
2582
|
return tokenResponse.access_token;
|
|
2565
2583
|
}
|
|
2566
2584
|
async function refreshToken() {
|
|
2567
|
-
|
|
2568
|
-
|
|
2585
|
+
if (!configWithDefaults) {
|
|
2586
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2587
|
+
}
|
|
2588
|
+
if (isServerOnlyConfig(configWithDefaults)) {
|
|
2569
2589
|
throw new Error("Cannot refresh tokens: Workload is configured in server-only mode (validation only).");
|
|
2570
2590
|
}
|
|
2571
2591
|
const cfg = configWithDefaults;
|
|
2572
2592
|
return isJwtBearerConfig(cfg) ? await acquireTokenJwtBearer(cfg.scope) : await acquireTokenClientCredentials(cfg.scope);
|
|
2573
2593
|
}
|
|
2574
2594
|
async function revokeToken(token) {
|
|
2575
|
-
|
|
2595
|
+
if (!configWithDefaults) {
|
|
2596
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2597
|
+
}
|
|
2576
2598
|
try {
|
|
2577
|
-
if (!
|
|
2599
|
+
if (!configWithDefaults.revocation_endpoint) {
|
|
2578
2600
|
return;
|
|
2579
2601
|
}
|
|
2580
2602
|
const body = new URLSearchParams;
|
|
2581
2603
|
body.append("token", token);
|
|
2582
2604
|
body.append("token_type_hint", "access_token");
|
|
2583
|
-
if (isJwtBearerConfig(
|
|
2605
|
+
if (isJwtBearerConfig(configWithDefaults)) {
|
|
2584
2606
|
const cfg = configWithDefaults;
|
|
2585
2607
|
body.append("client_id", cfg.workload_id);
|
|
2586
|
-
} else if (isClientCredentialsConfig(
|
|
2608
|
+
} else if (isClientCredentialsConfig(configWithDefaults)) {
|
|
2587
2609
|
const cfg = configWithDefaults;
|
|
2588
2610
|
body.append("client_id", cfg.client_id);
|
|
2589
2611
|
body.append("client_secret", cfg.client_secret);
|
|
2590
2612
|
}
|
|
2591
|
-
const response = await fetch(
|
|
2613
|
+
const response = await fetch(configWithDefaults.revocation_endpoint, {
|
|
2592
2614
|
method: "POST",
|
|
2593
2615
|
headers: {
|
|
2594
2616
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -2600,24 +2622,26 @@ function workload(config) {
|
|
|
2600
2622
|
} else {
|
|
2601
2623
|
console.log("Token revoked successfully");
|
|
2602
2624
|
}
|
|
2603
|
-
if (
|
|
2625
|
+
if (configWithDefaults.token_store) {
|
|
2604
2626
|
let cacheKey;
|
|
2605
|
-
if (isJwtBearerConfig(
|
|
2627
|
+
if (isJwtBearerConfig(configWithDefaults)) {
|
|
2606
2628
|
cacheKey = configWithDefaults.workload_id;
|
|
2607
|
-
} else if (isClientCredentialsConfig(
|
|
2629
|
+
} else if (isClientCredentialsConfig(configWithDefaults)) {
|
|
2608
2630
|
cacheKey = configWithDefaults.client_id;
|
|
2609
2631
|
} else {
|
|
2610
2632
|
return;
|
|
2611
2633
|
}
|
|
2612
|
-
await
|
|
2634
|
+
await configWithDefaults.token_store.delete(cacheKey);
|
|
2613
2635
|
}
|
|
2614
2636
|
} catch (error) {
|
|
2615
2637
|
console.warn("Error revoking token:", error);
|
|
2616
2638
|
}
|
|
2617
2639
|
}
|
|
2618
2640
|
async function fetchJwks() {
|
|
2619
|
-
|
|
2620
|
-
|
|
2641
|
+
if (!configWithDefaults) {
|
|
2642
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2643
|
+
}
|
|
2644
|
+
const url = configWithDefaults.jwks_uri;
|
|
2621
2645
|
if (!url) {
|
|
2622
2646
|
throw new Error("Cannot validate tokens: Missing jwks_uri in WorkloadConfig. " + "Server role requires jwks_uri to be configured in vault to fetch public keys for token validation.");
|
|
2623
2647
|
}
|
|
@@ -2634,16 +2658,21 @@ function workload(config) {
|
|
|
2634
2658
|
});
|
|
2635
2659
|
}
|
|
2636
2660
|
async function getPublicKey(kid) {
|
|
2661
|
+
if (!configWithDefaults) {
|
|
2662
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2663
|
+
}
|
|
2637
2664
|
const jwks = await fetchJwks();
|
|
2638
2665
|
const key = jwks.keys.find((k) => k.kid === kid);
|
|
2639
2666
|
if (!key)
|
|
2640
2667
|
throw new Error("Public key not found");
|
|
2641
|
-
const defaultAlg = isJwtBearerConfig(
|
|
2668
|
+
const defaultAlg = isJwtBearerConfig(configWithDefaults) ? configWithDefaults.algorithm : "RS256";
|
|
2642
2669
|
const algorithmParams = getAlgorithmParams(key.alg || defaultAlg);
|
|
2643
2670
|
return crypto.subtle.importKey("jwk", key, algorithmParams, false, ["verify"]);
|
|
2644
2671
|
}
|
|
2645
2672
|
async function parseJWT(token, validation) {
|
|
2646
|
-
|
|
2673
|
+
if (!configWithDefaults) {
|
|
2674
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2675
|
+
}
|
|
2647
2676
|
try {
|
|
2648
2677
|
const parts = token.split(".");
|
|
2649
2678
|
if (parts.length !== 3)
|
|
@@ -2672,26 +2701,28 @@ function workload(config) {
|
|
|
2672
2701
|
}
|
|
2673
2702
|
}
|
|
2674
2703
|
async function validateToken(token, validation) {
|
|
2675
|
-
|
|
2704
|
+
if (!configWithDefaults) {
|
|
2705
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2706
|
+
}
|
|
2676
2707
|
try {
|
|
2677
2708
|
const claims = await parseJWT(token, validation);
|
|
2678
2709
|
const now = Math.floor(Date.now() / 1000);
|
|
2679
2710
|
if (claims.exp && claims.exp < now) {
|
|
2680
2711
|
return { valid: false, error: "Token expired" };
|
|
2681
2712
|
}
|
|
2682
|
-
if (isJwtBearerConfig(
|
|
2683
|
-
if (
|
|
2713
|
+
if (isJwtBearerConfig(configWithDefaults)) {
|
|
2714
|
+
if (configWithDefaults.audience && claims.aud !== configWithDefaults.audience) {
|
|
2684
2715
|
return { valid: false, error: "Invalid audience" };
|
|
2685
2716
|
}
|
|
2686
|
-
} else if (isClientCredentialsConfig(
|
|
2687
|
-
if (
|
|
2717
|
+
} else if (isClientCredentialsConfig(configWithDefaults)) {
|
|
2718
|
+
if (configWithDefaults.issuer && claims.iss !== configWithDefaults.issuer) {
|
|
2688
2719
|
return { valid: false, error: "Invalid issuer" };
|
|
2689
2720
|
}
|
|
2690
|
-
if (
|
|
2721
|
+
if (configWithDefaults.audience && claims.aud !== configWithDefaults.audience) {
|
|
2691
2722
|
return { valid: false, error: "Invalid audience" };
|
|
2692
2723
|
}
|
|
2693
2724
|
} else {
|
|
2694
|
-
const serverConfig =
|
|
2725
|
+
const serverConfig = configWithDefaults;
|
|
2695
2726
|
if (serverConfig.issuer && claims.iss !== serverConfig.issuer) {
|
|
2696
2727
|
return { valid: false, error: "Invalid issuer" };
|
|
2697
2728
|
}
|
|
@@ -2709,8 +2740,10 @@ function workload(config) {
|
|
|
2709
2740
|
}
|
|
2710
2741
|
}
|
|
2711
2742
|
async function getWorkload(request) {
|
|
2712
|
-
|
|
2713
|
-
|
|
2743
|
+
if (!configWithDefaults) {
|
|
2744
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2745
|
+
}
|
|
2746
|
+
if (!configWithDefaults.jwks_uri) {
|
|
2714
2747
|
throw new Error("Cannot validate tokens: Missing jwks_uri in WorkloadConfig. " + "Server role requires jwks_uri to be configured in vault to fetch public keys for token validation.");
|
|
2715
2748
|
}
|
|
2716
2749
|
const authHeader = request.headers.get("Authorization");
|
|
@@ -2730,7 +2763,9 @@ function workload(config) {
|
|
|
2730
2763
|
};
|
|
2731
2764
|
}
|
|
2732
2765
|
async function handler(request) {
|
|
2733
|
-
|
|
2766
|
+
if (!configWithDefaults) {
|
|
2767
|
+
throw new Error("Enterprise Standard Workload Manager not initialized");
|
|
2768
|
+
}
|
|
2734
2769
|
const tokenUrl = configWithDefaults.tokenUrl;
|
|
2735
2770
|
const validateUrl = configWithDefaults.validateUrl;
|
|
2736
2771
|
const jwksUrl = configWithDefaults.jwksUrl;
|
|
@@ -2775,7 +2810,7 @@ function workload(config) {
|
|
|
2775
2810
|
return new Response("Not Found", { status: 404 });
|
|
2776
2811
|
}
|
|
2777
2812
|
return {
|
|
2778
|
-
...configWithDefaults,
|
|
2813
|
+
...configWithDefaults ?? {},
|
|
2779
2814
|
getToken,
|
|
2780
2815
|
refreshToken,
|
|
2781
2816
|
generateJWTAssertion,
|
|
@@ -2897,7 +2932,7 @@ function serializeESConfig(configOrES) {
|
|
|
2897
2932
|
}
|
|
2898
2933
|
const serialized = {};
|
|
2899
2934
|
for (const key in config) {
|
|
2900
|
-
if (Object.
|
|
2935
|
+
if (Object.hasOwn(config, key)) {
|
|
2901
2936
|
if (key === "session_store" || key === "user_store" || key === "token_store" || key === "group_store" || key === "validation" || key === "vault" || key === "getUser" || key === "getRequiredUser" || key === "getJwt" || key === "initiateLogin" || key === "logout" || key === "callbackHandler" || key === "handler" || key === "getToken" || key === "refreshToken" || key === "generateJWTAssertion" || key === "revokeToken" || key === "validateToken" || key === "getWorkload" || key === "parseJWT" || key === "createUser" || key === "getBaseUrl" || key === "groups_outbound" || key === "groups_inbound") {
|
|
2902
2937
|
continue;
|
|
2903
2938
|
}
|
|
@@ -3039,36 +3074,29 @@ class InMemoryTenantStore {
|
|
|
3039
3074
|
}
|
|
3040
3075
|
}
|
|
3041
3076
|
// packages/react/src/workload-server.ts
|
|
3042
|
-
function
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
console.error("Workload authentication not configured in EnterpriseStandard");
|
|
3046
|
-
return;
|
|
3047
|
-
}
|
|
3048
|
-
return es.workload;
|
|
3049
|
-
}
|
|
3050
|
-
function unavailable() {
|
|
3051
|
-
return new Response(JSON.stringify({ error: "Workload authentication unavailable" }), {
|
|
3077
|
+
function unavailable(error) {
|
|
3078
|
+
error = error ?? "Workload authentication unavailable";
|
|
3079
|
+
new Response(JSON.stringify({ error }), {
|
|
3052
3080
|
status: 503,
|
|
3053
|
-
statusText:
|
|
3081
|
+
statusText: error,
|
|
3054
3082
|
headers: { "Content-Type": "application/json" }
|
|
3055
3083
|
});
|
|
3056
3084
|
}
|
|
3057
|
-
async function getWorkload(request,
|
|
3058
|
-
const workloadAuth =
|
|
3085
|
+
async function getWorkload(request, es) {
|
|
3086
|
+
const workloadAuth = getES(es)?.workload;
|
|
3059
3087
|
if (!workloadAuth) {
|
|
3060
3088
|
return;
|
|
3061
3089
|
}
|
|
3062
3090
|
return workloadAuth.getWorkload(request);
|
|
3063
3091
|
}
|
|
3064
|
-
async function getWorkloadToken(scope,
|
|
3065
|
-
const workloadAuth =
|
|
3092
|
+
async function getWorkloadToken(scope, es) {
|
|
3093
|
+
const workloadAuth = getES(es)?.workload;
|
|
3066
3094
|
if (!workloadAuth)
|
|
3067
3095
|
throw unavailable();
|
|
3068
3096
|
return workloadAuth.getToken(scope);
|
|
3069
3097
|
}
|
|
3070
|
-
async function validateWorkloadToken(request,
|
|
3071
|
-
const workloadAuth =
|
|
3098
|
+
async function validateWorkloadToken(request, es) {
|
|
3099
|
+
const workloadAuth = getES(es)?.workload;
|
|
3072
3100
|
if (!workloadAuth) {
|
|
3073
3101
|
return { valid: false, error: "Workload authentication unavailable" };
|
|
3074
3102
|
}
|
|
@@ -3079,61 +3107,54 @@ async function validateWorkloadToken(request, config) {
|
|
|
3079
3107
|
const token = authHeader.substring(7);
|
|
3080
3108
|
return workloadAuth.validateToken(token);
|
|
3081
3109
|
}
|
|
3082
|
-
async function revokeWorkloadToken(token,
|
|
3083
|
-
const workloadAuth =
|
|
3110
|
+
async function revokeWorkloadToken(token, es) {
|
|
3111
|
+
const workloadAuth = getES(es)?.workload;
|
|
3084
3112
|
if (!workloadAuth)
|
|
3085
3113
|
throw unavailable();
|
|
3086
3114
|
return workloadAuth.revokeToken(token);
|
|
3087
3115
|
}
|
|
3088
|
-
async function workloadHandler(request,
|
|
3089
|
-
const workloadAuth =
|
|
3116
|
+
async function workloadHandler(request, es) {
|
|
3117
|
+
const workloadAuth = getES(es)?.workload;
|
|
3090
3118
|
if (!workloadAuth)
|
|
3091
3119
|
throw unavailable();
|
|
3092
3120
|
return workloadAuth.handler(request);
|
|
3093
3121
|
}
|
|
3094
3122
|
|
|
3095
|
-
// packages/react/src/server.ts
|
|
3096
|
-
function
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
console.error("TODO tell them how to connect SSO");
|
|
3100
|
-
return;
|
|
3101
|
-
}
|
|
3102
|
-
return es.sso;
|
|
3103
|
-
}
|
|
3104
|
-
function unavailable2() {
|
|
3105
|
-
new Response(JSON.stringify({ error: "SSO Unavailable" }), {
|
|
3123
|
+
// packages/react/src/sso-server.ts
|
|
3124
|
+
function unavailable2(error) {
|
|
3125
|
+
error = error ?? "SSO Unavailable";
|
|
3126
|
+
new Response(JSON.stringify({ error }), {
|
|
3106
3127
|
status: 503,
|
|
3107
|
-
statusText:
|
|
3128
|
+
statusText: error,
|
|
3108
3129
|
headers: { "Content-Type": "application/json" }
|
|
3109
3130
|
});
|
|
3110
3131
|
}
|
|
3111
|
-
async function getUser(request,
|
|
3112
|
-
return
|
|
3132
|
+
async function getUser(request, es) {
|
|
3133
|
+
return getES(es)?.sso.getUser(request);
|
|
3113
3134
|
}
|
|
3114
|
-
async function getRequiredUser(request,
|
|
3115
|
-
const sso2 =
|
|
3135
|
+
async function getRequiredUser(request, es) {
|
|
3136
|
+
const sso2 = getES(es)?.sso;
|
|
3116
3137
|
if (!sso2)
|
|
3117
3138
|
throw unavailable2();
|
|
3118
3139
|
return sso2.getRequiredUser(request);
|
|
3119
3140
|
}
|
|
3120
|
-
async function initiateLogin(config) {
|
|
3121
|
-
const sso2 =
|
|
3141
|
+
async function initiateLogin(config, es) {
|
|
3142
|
+
const sso2 = getES(es)?.sso;
|
|
3122
3143
|
if (!sso2)
|
|
3123
3144
|
throw unavailable2();
|
|
3124
3145
|
return sso2.initiateLogin(config);
|
|
3125
3146
|
}
|
|
3126
|
-
async function callback(request,
|
|
3127
|
-
const sso2 =
|
|
3147
|
+
async function callback(request, es) {
|
|
3148
|
+
const sso2 = getES(es)?.sso;
|
|
3128
3149
|
if (!sso2)
|
|
3129
3150
|
throw unavailable2();
|
|
3130
3151
|
return sso2.callbackHandler(request);
|
|
3131
3152
|
}
|
|
3132
|
-
async function handler(request,
|
|
3133
|
-
|
|
3134
|
-
if (!
|
|
3153
|
+
async function handler(request, es) {
|
|
3154
|
+
es = getES(es);
|
|
3155
|
+
if (!es)
|
|
3135
3156
|
throw unavailable2();
|
|
3136
|
-
return
|
|
3157
|
+
return es.sso.handler(request, es);
|
|
3137
3158
|
}
|
|
3138
3159
|
// packages/react/src/session-store.ts
|
|
3139
3160
|
class InMemorySessionStore {
|
|
@@ -3550,10 +3571,19 @@ async function enterpriseStandard(appId, initConfig) {
|
|
|
3550
3571
|
token: vaultToken
|
|
3551
3572
|
};
|
|
3552
3573
|
} else if (!vaultUrl || !vaultToken || !vaultPath) {
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
For development, login with the ionite CLI using "${cmd}" or visit ${ioniteUrl}/api/applications/apiKeys/create?appId=${appId}
|
|
3574
|
+
const msg = "@enterprisestandard configuration missing.";
|
|
3575
|
+
if (true) {
|
|
3576
|
+
const cmd = `${process.versions.bun ? "bun" : "npm"} ionite login --app ${appId}`;
|
|
3577
|
+
console.warn(`${msg} For development, login with the ionite CLI using "${cmd}" or visit ${ioniteUrl}/api/applications/apiKeys/create?appId=${appId}.`);
|
|
3578
|
+
const wl = workload(undefined);
|
|
3579
|
+
return {
|
|
3580
|
+
defaultInstance: false,
|
|
3581
|
+
vault: vault(""),
|
|
3582
|
+
sso: sso(undefined),
|
|
3583
|
+
iam: iam({}, wl),
|
|
3584
|
+
workload: wl
|
|
3585
|
+
};
|
|
3586
|
+
} else {}
|
|
3557
3587
|
}
|
|
3558
3588
|
const defaultInstance2 = getDefaultInstance();
|
|
3559
3589
|
const vaultClient = vault(vaultUrl);
|
|
@@ -3632,7 +3662,6 @@ export {
|
|
|
3632
3662
|
getWorkload,
|
|
3633
3663
|
getUser,
|
|
3634
3664
|
getRequiredUser,
|
|
3635
|
-
getES,
|
|
3636
3665
|
getDefaultInstance,
|
|
3637
3666
|
enterpriseStandard,
|
|
3638
3667
|
callback,
|
|
@@ -3648,4 +3677,4 @@ export {
|
|
|
3648
3677
|
InMemoryGroupStore
|
|
3649
3678
|
};
|
|
3650
3679
|
|
|
3651
|
-
//# debugId=
|
|
3680
|
+
//# debugId=7CF5D49401EA27DC64756E2164756E21
|