@naylence/runtime 0.3.5-test.925 → 0.3.5-test.927
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/browser/index.cjs +46 -52
- package/dist/browser/index.mjs +46 -52
- package/dist/cjs/naylence/fame/node/upstream-session-manager.js +13 -0
- package/dist/cjs/naylence/fame/security/auth/oauth2-pkce-token-provider.js +31 -50
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/node/upstream-session-manager.js +13 -0
- package/dist/esm/naylence/fame/security/auth/oauth2-pkce-token-provider.js +31 -50
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +46 -52
- package/dist/node/index.mjs +46 -52
- package/dist/node/node.cjs +46 -52
- package/dist/node/node.mjs +46 -52
- package/dist/types/naylence/fame/security/auth/oauth2-pkce-token-provider.d.ts +5 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -98,12 +98,12 @@ installProcessEnvShim();
|
|
|
98
98
|
// --- END ENV SHIM ---
|
|
99
99
|
|
|
100
100
|
// This file is auto-generated during build - do not edit manually
|
|
101
|
-
// Generated from package.json version: 0.3.5-test.
|
|
101
|
+
// Generated from package.json version: 0.3.5-test.927
|
|
102
102
|
/**
|
|
103
103
|
* The package version, injected at build time.
|
|
104
104
|
* @internal
|
|
105
105
|
*/
|
|
106
|
-
const VERSION = '0.3.5-test.
|
|
106
|
+
const VERSION = '0.3.5-test.927';
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -10457,6 +10457,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10457
10457
|
await connector.start(this.wrappedHandler);
|
|
10458
10458
|
this.connector = connector;
|
|
10459
10459
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
10460
|
+
// Include admission client's connection grants as callback grants
|
|
10461
|
+
// This ensures DirectAdmissionClient grants are available for grant selection
|
|
10462
|
+
if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
|
|
10463
|
+
for (const grant of welcome.frame.connectionGrants) {
|
|
10464
|
+
if (grant && typeof grant === 'object') {
|
|
10465
|
+
// Avoid duplicates by checking if grant already exists
|
|
10466
|
+
const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
|
|
10467
|
+
if (!isDuplicate) {
|
|
10468
|
+
callbackGrants.push(grant);
|
|
10469
|
+
}
|
|
10470
|
+
}
|
|
10471
|
+
}
|
|
10472
|
+
}
|
|
10460
10473
|
if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
10461
10474
|
const augmented = this.createBroadcastCallbackGrant(grant);
|
|
10462
10475
|
if (augmented) {
|
|
@@ -39008,14 +39021,18 @@ function ensureFinitePositive(value, label) {
|
|
|
39008
39021
|
}
|
|
39009
39022
|
return Math.max(1, Math.floor(value));
|
|
39010
39023
|
}
|
|
39024
|
+
/**
|
|
39025
|
+
* In-memory token cache for PKCE tokens.
|
|
39026
|
+
*
|
|
39027
|
+
* Tokens are intentionally NOT persisted to localStorage or sessionStorage to avoid
|
|
39028
|
+
* stale-token issues when the OAuth2 server restarts and generates new signing keys.
|
|
39029
|
+
* Each fresh page load triggers a new PKCE flow when a token is needed.
|
|
39030
|
+
*/
|
|
39031
|
+
let inMemoryTokenCache = new Map();
|
|
39011
39032
|
const STORAGE_NAMESPACE = 'naylence.oauth2_pkce.';
|
|
39012
|
-
const TOKEN_STORAGE_SUFFIX = '.token';
|
|
39013
39033
|
function getStorageKey(clientId) {
|
|
39014
39034
|
return `${STORAGE_NAMESPACE}${clientId}`;
|
|
39015
39035
|
}
|
|
39016
|
-
function getTokenStorageKey(clientId) {
|
|
39017
|
-
return `${STORAGE_NAMESPACE}${clientId}${TOKEN_STORAGE_SUFFIX}`;
|
|
39018
|
-
}
|
|
39019
39036
|
function isBrowserEnvironment() {
|
|
39020
39037
|
return (typeof window !== 'undefined' &&
|
|
39021
39038
|
typeof window.location !== 'undefined' &&
|
|
@@ -39067,57 +39084,23 @@ function stableScopeKey(scopes) {
|
|
|
39067
39084
|
}
|
|
39068
39085
|
return [...scopes].sort().join(' ');
|
|
39069
39086
|
}
|
|
39087
|
+
/**
|
|
39088
|
+
* Read token from in-memory cache.
|
|
39089
|
+
* Returns null if no cached token exists for the given clientId.
|
|
39090
|
+
*/
|
|
39070
39091
|
function readPersistedToken(clientId) {
|
|
39071
|
-
|
|
39072
|
-
return null;
|
|
39073
|
-
}
|
|
39074
|
-
try {
|
|
39075
|
-
const raw = window.sessionStorage.getItem(getTokenStorageKey(clientId));
|
|
39076
|
-
if (!raw) {
|
|
39077
|
-
return null;
|
|
39078
|
-
}
|
|
39079
|
-
const parsed = JSON.parse(raw);
|
|
39080
|
-
const value = coerceString(parsed.value);
|
|
39081
|
-
if (!value) {
|
|
39082
|
-
return null;
|
|
39083
|
-
}
|
|
39084
|
-
const expiresAt = coerceNumber(parsed.expiresAt);
|
|
39085
|
-
const scopes = normalizeScopes(parsed.scopes);
|
|
39086
|
-
const audience = coerceString(parsed.audience);
|
|
39087
|
-
const record = {
|
|
39088
|
-
value,
|
|
39089
|
-
scopes,
|
|
39090
|
-
audience,
|
|
39091
|
-
};
|
|
39092
|
-
if (typeof expiresAt === 'number') {
|
|
39093
|
-
record.expiresAt = expiresAt;
|
|
39094
|
-
}
|
|
39095
|
-
return record;
|
|
39096
|
-
}
|
|
39097
|
-
catch (error) {
|
|
39098
|
-
logger.debug('pkce_token_storage_read_failed', {
|
|
39099
|
-
error: error instanceof Error ? error.message : String(error),
|
|
39100
|
-
});
|
|
39101
|
-
return null;
|
|
39102
|
-
}
|
|
39092
|
+
return inMemoryTokenCache.get(clientId) ?? null;
|
|
39103
39093
|
}
|
|
39094
|
+
/**
|
|
39095
|
+
* Write token to in-memory cache.
|
|
39096
|
+
* If token is null, removes the cached token for the given clientId.
|
|
39097
|
+
*/
|
|
39104
39098
|
function writePersistedToken(clientId, token) {
|
|
39105
|
-
if (!
|
|
39099
|
+
if (!token) {
|
|
39100
|
+
inMemoryTokenCache.delete(clientId);
|
|
39106
39101
|
return;
|
|
39107
39102
|
}
|
|
39108
|
-
|
|
39109
|
-
try {
|
|
39110
|
-
if (!token) {
|
|
39111
|
-
window.sessionStorage.removeItem(key);
|
|
39112
|
-
return;
|
|
39113
|
-
}
|
|
39114
|
-
window.sessionStorage.setItem(key, JSON.stringify(token));
|
|
39115
|
-
}
|
|
39116
|
-
catch (error) {
|
|
39117
|
-
logger.debug('pkce_token_storage_write_failed', {
|
|
39118
|
-
error: error instanceof Error ? error.message : String(error),
|
|
39119
|
-
});
|
|
39120
|
-
}
|
|
39103
|
+
inMemoryTokenCache.set(clientId, token);
|
|
39121
39104
|
}
|
|
39122
39105
|
function clearOAuthParamsFromUrl(url) {
|
|
39123
39106
|
if (!isBrowserEnvironment()) {
|
|
@@ -39418,6 +39401,17 @@ class OAuth2PkceTokenProvider {
|
|
|
39418
39401
|
});
|
|
39419
39402
|
return token;
|
|
39420
39403
|
}
|
|
39404
|
+
/**
|
|
39405
|
+
* Clear the cached token for this provider instance.
|
|
39406
|
+
* This clears both the instance cache and the in-memory module cache.
|
|
39407
|
+
*/
|
|
39408
|
+
clearToken() {
|
|
39409
|
+
this.cachedToken = undefined;
|
|
39410
|
+
writePersistedToken(this.options.clientId, null);
|
|
39411
|
+
logger.debug('oauth2_pkce_token_cleared', {
|
|
39412
|
+
authorize_url: this.options.authorizeUrl,
|
|
39413
|
+
});
|
|
39414
|
+
}
|
|
39421
39415
|
}
|
|
39422
39416
|
|
|
39423
39417
|
var oauth2PkceTokenProvider = /*#__PURE__*/Object.freeze({
|
package/dist/browser/index.mjs
CHANGED
|
@@ -96,12 +96,12 @@ installProcessEnvShim();
|
|
|
96
96
|
// --- END ENV SHIM ---
|
|
97
97
|
|
|
98
98
|
// This file is auto-generated during build - do not edit manually
|
|
99
|
-
// Generated from package.json version: 0.3.5-test.
|
|
99
|
+
// Generated from package.json version: 0.3.5-test.927
|
|
100
100
|
/**
|
|
101
101
|
* The package version, injected at build time.
|
|
102
102
|
* @internal
|
|
103
103
|
*/
|
|
104
|
-
const VERSION = '0.3.5-test.
|
|
104
|
+
const VERSION = '0.3.5-test.927';
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -10455,6 +10455,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10455
10455
|
await connector.start(this.wrappedHandler);
|
|
10456
10456
|
this.connector = connector;
|
|
10457
10457
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
10458
|
+
// Include admission client's connection grants as callback grants
|
|
10459
|
+
// This ensures DirectAdmissionClient grants are available for grant selection
|
|
10460
|
+
if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
|
|
10461
|
+
for (const grant of welcome.frame.connectionGrants) {
|
|
10462
|
+
if (grant && typeof grant === 'object') {
|
|
10463
|
+
// Avoid duplicates by checking if grant already exists
|
|
10464
|
+
const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
|
|
10465
|
+
if (!isDuplicate) {
|
|
10466
|
+
callbackGrants.push(grant);
|
|
10467
|
+
}
|
|
10468
|
+
}
|
|
10469
|
+
}
|
|
10470
|
+
}
|
|
10458
10471
|
if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
10459
10472
|
const augmented = this.createBroadcastCallbackGrant(grant);
|
|
10460
10473
|
if (augmented) {
|
|
@@ -39006,14 +39019,18 @@ function ensureFinitePositive(value, label) {
|
|
|
39006
39019
|
}
|
|
39007
39020
|
return Math.max(1, Math.floor(value));
|
|
39008
39021
|
}
|
|
39022
|
+
/**
|
|
39023
|
+
* In-memory token cache for PKCE tokens.
|
|
39024
|
+
*
|
|
39025
|
+
* Tokens are intentionally NOT persisted to localStorage or sessionStorage to avoid
|
|
39026
|
+
* stale-token issues when the OAuth2 server restarts and generates new signing keys.
|
|
39027
|
+
* Each fresh page load triggers a new PKCE flow when a token is needed.
|
|
39028
|
+
*/
|
|
39029
|
+
let inMemoryTokenCache = new Map();
|
|
39009
39030
|
const STORAGE_NAMESPACE = 'naylence.oauth2_pkce.';
|
|
39010
|
-
const TOKEN_STORAGE_SUFFIX = '.token';
|
|
39011
39031
|
function getStorageKey(clientId) {
|
|
39012
39032
|
return `${STORAGE_NAMESPACE}${clientId}`;
|
|
39013
39033
|
}
|
|
39014
|
-
function getTokenStorageKey(clientId) {
|
|
39015
|
-
return `${STORAGE_NAMESPACE}${clientId}${TOKEN_STORAGE_SUFFIX}`;
|
|
39016
|
-
}
|
|
39017
39034
|
function isBrowserEnvironment() {
|
|
39018
39035
|
return (typeof window !== 'undefined' &&
|
|
39019
39036
|
typeof window.location !== 'undefined' &&
|
|
@@ -39065,57 +39082,23 @@ function stableScopeKey(scopes) {
|
|
|
39065
39082
|
}
|
|
39066
39083
|
return [...scopes].sort().join(' ');
|
|
39067
39084
|
}
|
|
39085
|
+
/**
|
|
39086
|
+
* Read token from in-memory cache.
|
|
39087
|
+
* Returns null if no cached token exists for the given clientId.
|
|
39088
|
+
*/
|
|
39068
39089
|
function readPersistedToken(clientId) {
|
|
39069
|
-
|
|
39070
|
-
return null;
|
|
39071
|
-
}
|
|
39072
|
-
try {
|
|
39073
|
-
const raw = window.sessionStorage.getItem(getTokenStorageKey(clientId));
|
|
39074
|
-
if (!raw) {
|
|
39075
|
-
return null;
|
|
39076
|
-
}
|
|
39077
|
-
const parsed = JSON.parse(raw);
|
|
39078
|
-
const value = coerceString(parsed.value);
|
|
39079
|
-
if (!value) {
|
|
39080
|
-
return null;
|
|
39081
|
-
}
|
|
39082
|
-
const expiresAt = coerceNumber(parsed.expiresAt);
|
|
39083
|
-
const scopes = normalizeScopes(parsed.scopes);
|
|
39084
|
-
const audience = coerceString(parsed.audience);
|
|
39085
|
-
const record = {
|
|
39086
|
-
value,
|
|
39087
|
-
scopes,
|
|
39088
|
-
audience,
|
|
39089
|
-
};
|
|
39090
|
-
if (typeof expiresAt === 'number') {
|
|
39091
|
-
record.expiresAt = expiresAt;
|
|
39092
|
-
}
|
|
39093
|
-
return record;
|
|
39094
|
-
}
|
|
39095
|
-
catch (error) {
|
|
39096
|
-
logger.debug('pkce_token_storage_read_failed', {
|
|
39097
|
-
error: error instanceof Error ? error.message : String(error),
|
|
39098
|
-
});
|
|
39099
|
-
return null;
|
|
39100
|
-
}
|
|
39090
|
+
return inMemoryTokenCache.get(clientId) ?? null;
|
|
39101
39091
|
}
|
|
39092
|
+
/**
|
|
39093
|
+
* Write token to in-memory cache.
|
|
39094
|
+
* If token is null, removes the cached token for the given clientId.
|
|
39095
|
+
*/
|
|
39102
39096
|
function writePersistedToken(clientId, token) {
|
|
39103
|
-
if (!
|
|
39097
|
+
if (!token) {
|
|
39098
|
+
inMemoryTokenCache.delete(clientId);
|
|
39104
39099
|
return;
|
|
39105
39100
|
}
|
|
39106
|
-
|
|
39107
|
-
try {
|
|
39108
|
-
if (!token) {
|
|
39109
|
-
window.sessionStorage.removeItem(key);
|
|
39110
|
-
return;
|
|
39111
|
-
}
|
|
39112
|
-
window.sessionStorage.setItem(key, JSON.stringify(token));
|
|
39113
|
-
}
|
|
39114
|
-
catch (error) {
|
|
39115
|
-
logger.debug('pkce_token_storage_write_failed', {
|
|
39116
|
-
error: error instanceof Error ? error.message : String(error),
|
|
39117
|
-
});
|
|
39118
|
-
}
|
|
39101
|
+
inMemoryTokenCache.set(clientId, token);
|
|
39119
39102
|
}
|
|
39120
39103
|
function clearOAuthParamsFromUrl(url) {
|
|
39121
39104
|
if (!isBrowserEnvironment()) {
|
|
@@ -39416,6 +39399,17 @@ class OAuth2PkceTokenProvider {
|
|
|
39416
39399
|
});
|
|
39417
39400
|
return token;
|
|
39418
39401
|
}
|
|
39402
|
+
/**
|
|
39403
|
+
* Clear the cached token for this provider instance.
|
|
39404
|
+
* This clears both the instance cache and the in-memory module cache.
|
|
39405
|
+
*/
|
|
39406
|
+
clearToken() {
|
|
39407
|
+
this.cachedToken = undefined;
|
|
39408
|
+
writePersistedToken(this.options.clientId, null);
|
|
39409
|
+
logger.debug('oauth2_pkce_token_cleared', {
|
|
39410
|
+
authorize_url: this.options.authorizeUrl,
|
|
39411
|
+
});
|
|
39412
|
+
}
|
|
39419
39413
|
}
|
|
39420
39414
|
|
|
39421
39415
|
var oauth2PkceTokenProvider = /*#__PURE__*/Object.freeze({
|
|
@@ -304,6 +304,19 @@ class UpstreamSessionManager extends task_spawner_js_1.TaskSpawner {
|
|
|
304
304
|
await connector.start(this.wrappedHandler);
|
|
305
305
|
this.connector = connector;
|
|
306
306
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
307
|
+
// Include admission client's connection grants as callback grants
|
|
308
|
+
// This ensures DirectAdmissionClient grants are available for grant selection
|
|
309
|
+
if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
|
|
310
|
+
for (const grant of welcome.frame.connectionGrants) {
|
|
311
|
+
if (grant && typeof grant === 'object') {
|
|
312
|
+
// Avoid duplicates by checking if grant already exists
|
|
313
|
+
const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
|
|
314
|
+
if (!isDuplicate) {
|
|
315
|
+
callbackGrants.push(grant);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
307
320
|
if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
308
321
|
const augmented = this.createBroadcastCallbackGrant(grant);
|
|
309
322
|
if (augmented) {
|
|
@@ -145,14 +145,18 @@ function ensureFinitePositive(value, label) {
|
|
|
145
145
|
}
|
|
146
146
|
return Math.max(1, Math.floor(value));
|
|
147
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* In-memory token cache for PKCE tokens.
|
|
150
|
+
*
|
|
151
|
+
* Tokens are intentionally NOT persisted to localStorage or sessionStorage to avoid
|
|
152
|
+
* stale-token issues when the OAuth2 server restarts and generates new signing keys.
|
|
153
|
+
* Each fresh page load triggers a new PKCE flow when a token is needed.
|
|
154
|
+
*/
|
|
155
|
+
let inMemoryTokenCache = new Map();
|
|
148
156
|
const STORAGE_NAMESPACE = 'naylence.oauth2_pkce.';
|
|
149
|
-
const TOKEN_STORAGE_SUFFIX = '.token';
|
|
150
157
|
function getStorageKey(clientId) {
|
|
151
158
|
return `${STORAGE_NAMESPACE}${clientId}`;
|
|
152
159
|
}
|
|
153
|
-
function getTokenStorageKey(clientId) {
|
|
154
|
-
return `${STORAGE_NAMESPACE}${clientId}${TOKEN_STORAGE_SUFFIX}`;
|
|
155
|
-
}
|
|
156
160
|
function isBrowserEnvironment() {
|
|
157
161
|
return (typeof window !== 'undefined' &&
|
|
158
162
|
typeof window.location !== 'undefined' &&
|
|
@@ -204,57 +208,23 @@ function stableScopeKey(scopes) {
|
|
|
204
208
|
}
|
|
205
209
|
return [...scopes].sort().join(' ');
|
|
206
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Read token from in-memory cache.
|
|
213
|
+
* Returns null if no cached token exists for the given clientId.
|
|
214
|
+
*/
|
|
207
215
|
function readPersistedToken(clientId) {
|
|
208
|
-
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
try {
|
|
212
|
-
const raw = window.sessionStorage.getItem(getTokenStorageKey(clientId));
|
|
213
|
-
if (!raw) {
|
|
214
|
-
return null;
|
|
215
|
-
}
|
|
216
|
-
const parsed = JSON.parse(raw);
|
|
217
|
-
const value = coerceString(parsed.value);
|
|
218
|
-
if (!value) {
|
|
219
|
-
return null;
|
|
220
|
-
}
|
|
221
|
-
const expiresAt = coerceNumber(parsed.expiresAt);
|
|
222
|
-
const scopes = normalizeScopes(parsed.scopes);
|
|
223
|
-
const audience = coerceString(parsed.audience);
|
|
224
|
-
const record = {
|
|
225
|
-
value,
|
|
226
|
-
scopes,
|
|
227
|
-
audience,
|
|
228
|
-
};
|
|
229
|
-
if (typeof expiresAt === 'number') {
|
|
230
|
-
record.expiresAt = expiresAt;
|
|
231
|
-
}
|
|
232
|
-
return record;
|
|
233
|
-
}
|
|
234
|
-
catch (error) {
|
|
235
|
-
logger.debug('pkce_token_storage_read_failed', {
|
|
236
|
-
error: error instanceof Error ? error.message : String(error),
|
|
237
|
-
});
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
216
|
+
return inMemoryTokenCache.get(clientId) ?? null;
|
|
240
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Write token to in-memory cache.
|
|
220
|
+
* If token is null, removes the cached token for the given clientId.
|
|
221
|
+
*/
|
|
241
222
|
function writePersistedToken(clientId, token) {
|
|
242
|
-
if (!
|
|
223
|
+
if (!token) {
|
|
224
|
+
inMemoryTokenCache.delete(clientId);
|
|
243
225
|
return;
|
|
244
226
|
}
|
|
245
|
-
|
|
246
|
-
try {
|
|
247
|
-
if (!token) {
|
|
248
|
-
window.sessionStorage.removeItem(key);
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
window.sessionStorage.setItem(key, JSON.stringify(token));
|
|
252
|
-
}
|
|
253
|
-
catch (error) {
|
|
254
|
-
logger.debug('pkce_token_storage_write_failed', {
|
|
255
|
-
error: error instanceof Error ? error.message : String(error),
|
|
256
|
-
});
|
|
257
|
-
}
|
|
227
|
+
inMemoryTokenCache.set(clientId, token);
|
|
258
228
|
}
|
|
259
229
|
function clearOAuthParamsFromUrl(url) {
|
|
260
230
|
if (!isBrowserEnvironment()) {
|
|
@@ -556,5 +526,16 @@ class OAuth2PkceTokenProvider {
|
|
|
556
526
|
});
|
|
557
527
|
return token;
|
|
558
528
|
}
|
|
529
|
+
/**
|
|
530
|
+
* Clear the cached token for this provider instance.
|
|
531
|
+
* This clears both the instance cache and the in-memory module cache.
|
|
532
|
+
*/
|
|
533
|
+
clearToken() {
|
|
534
|
+
this.cachedToken = undefined;
|
|
535
|
+
writePersistedToken(this.options.clientId, null);
|
|
536
|
+
logger.debug('oauth2_pkce_token_cleared', {
|
|
537
|
+
authorize_url: this.options.authorizeUrl,
|
|
538
|
+
});
|
|
539
|
+
}
|
|
559
540
|
}
|
|
560
541
|
exports.OAuth2PkceTokenProvider = OAuth2PkceTokenProvider;
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated during build - do not edit manually
|
|
3
|
-
// Generated from package.json version: 0.3.5-test.
|
|
3
|
+
// Generated from package.json version: 0.3.5-test.927
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.VERSION = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* The package version, injected at build time.
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
exports.VERSION = '0.3.5-test.
|
|
10
|
+
exports.VERSION = '0.3.5-test.927';
|
|
@@ -301,6 +301,19 @@ export class UpstreamSessionManager extends TaskSpawner {
|
|
|
301
301
|
await connector.start(this.wrappedHandler);
|
|
302
302
|
this.connector = connector;
|
|
303
303
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
304
|
+
// Include admission client's connection grants as callback grants
|
|
305
|
+
// This ensures DirectAdmissionClient grants are available for grant selection
|
|
306
|
+
if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
|
|
307
|
+
for (const grant of welcome.frame.connectionGrants) {
|
|
308
|
+
if (grant && typeof grant === 'object') {
|
|
309
|
+
// Avoid duplicates by checking if grant already exists
|
|
310
|
+
const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
|
|
311
|
+
if (!isDuplicate) {
|
|
312
|
+
callbackGrants.push(grant);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
304
317
|
if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
305
318
|
const augmented = this.createBroadcastCallbackGrant(grant);
|
|
306
319
|
if (augmented) {
|
|
@@ -142,14 +142,18 @@ function ensureFinitePositive(value, label) {
|
|
|
142
142
|
}
|
|
143
143
|
return Math.max(1, Math.floor(value));
|
|
144
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* In-memory token cache for PKCE tokens.
|
|
147
|
+
*
|
|
148
|
+
* Tokens are intentionally NOT persisted to localStorage or sessionStorage to avoid
|
|
149
|
+
* stale-token issues when the OAuth2 server restarts and generates new signing keys.
|
|
150
|
+
* Each fresh page load triggers a new PKCE flow when a token is needed.
|
|
151
|
+
*/
|
|
152
|
+
let inMemoryTokenCache = new Map();
|
|
145
153
|
const STORAGE_NAMESPACE = 'naylence.oauth2_pkce.';
|
|
146
|
-
const TOKEN_STORAGE_SUFFIX = '.token';
|
|
147
154
|
function getStorageKey(clientId) {
|
|
148
155
|
return `${STORAGE_NAMESPACE}${clientId}`;
|
|
149
156
|
}
|
|
150
|
-
function getTokenStorageKey(clientId) {
|
|
151
|
-
return `${STORAGE_NAMESPACE}${clientId}${TOKEN_STORAGE_SUFFIX}`;
|
|
152
|
-
}
|
|
153
157
|
function isBrowserEnvironment() {
|
|
154
158
|
return (typeof window !== 'undefined' &&
|
|
155
159
|
typeof window.location !== 'undefined' &&
|
|
@@ -201,57 +205,23 @@ function stableScopeKey(scopes) {
|
|
|
201
205
|
}
|
|
202
206
|
return [...scopes].sort().join(' ');
|
|
203
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Read token from in-memory cache.
|
|
210
|
+
* Returns null if no cached token exists for the given clientId.
|
|
211
|
+
*/
|
|
204
212
|
function readPersistedToken(clientId) {
|
|
205
|
-
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
try {
|
|
209
|
-
const raw = window.sessionStorage.getItem(getTokenStorageKey(clientId));
|
|
210
|
-
if (!raw) {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
const parsed = JSON.parse(raw);
|
|
214
|
-
const value = coerceString(parsed.value);
|
|
215
|
-
if (!value) {
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
const expiresAt = coerceNumber(parsed.expiresAt);
|
|
219
|
-
const scopes = normalizeScopes(parsed.scopes);
|
|
220
|
-
const audience = coerceString(parsed.audience);
|
|
221
|
-
const record = {
|
|
222
|
-
value,
|
|
223
|
-
scopes,
|
|
224
|
-
audience,
|
|
225
|
-
};
|
|
226
|
-
if (typeof expiresAt === 'number') {
|
|
227
|
-
record.expiresAt = expiresAt;
|
|
228
|
-
}
|
|
229
|
-
return record;
|
|
230
|
-
}
|
|
231
|
-
catch (error) {
|
|
232
|
-
logger.debug('pkce_token_storage_read_failed', {
|
|
233
|
-
error: error instanceof Error ? error.message : String(error),
|
|
234
|
-
});
|
|
235
|
-
return null;
|
|
236
|
-
}
|
|
213
|
+
return inMemoryTokenCache.get(clientId) ?? null;
|
|
237
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Write token to in-memory cache.
|
|
217
|
+
* If token is null, removes the cached token for the given clientId.
|
|
218
|
+
*/
|
|
238
219
|
function writePersistedToken(clientId, token) {
|
|
239
|
-
if (!
|
|
220
|
+
if (!token) {
|
|
221
|
+
inMemoryTokenCache.delete(clientId);
|
|
240
222
|
return;
|
|
241
223
|
}
|
|
242
|
-
|
|
243
|
-
try {
|
|
244
|
-
if (!token) {
|
|
245
|
-
window.sessionStorage.removeItem(key);
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
window.sessionStorage.setItem(key, JSON.stringify(token));
|
|
249
|
-
}
|
|
250
|
-
catch (error) {
|
|
251
|
-
logger.debug('pkce_token_storage_write_failed', {
|
|
252
|
-
error: error instanceof Error ? error.message : String(error),
|
|
253
|
-
});
|
|
254
|
-
}
|
|
224
|
+
inMemoryTokenCache.set(clientId, token);
|
|
255
225
|
}
|
|
256
226
|
function clearOAuthParamsFromUrl(url) {
|
|
257
227
|
if (!isBrowserEnvironment()) {
|
|
@@ -552,4 +522,15 @@ export class OAuth2PkceTokenProvider {
|
|
|
552
522
|
});
|
|
553
523
|
return token;
|
|
554
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* Clear the cached token for this provider instance.
|
|
527
|
+
* This clears both the instance cache and the in-memory module cache.
|
|
528
|
+
*/
|
|
529
|
+
clearToken() {
|
|
530
|
+
this.cachedToken = undefined;
|
|
531
|
+
writePersistedToken(this.options.clientId, null);
|
|
532
|
+
logger.debug('oauth2_pkce_token_cleared', {
|
|
533
|
+
authorize_url: this.options.authorizeUrl,
|
|
534
|
+
});
|
|
535
|
+
}
|
|
555
536
|
}
|
package/dist/esm/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is auto-generated during build - do not edit manually
|
|
2
|
-
// Generated from package.json version: 0.3.5-test.
|
|
2
|
+
// Generated from package.json version: 0.3.5-test.927
|
|
3
3
|
/**
|
|
4
4
|
* The package version, injected at build time.
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export const VERSION = '0.3.5-test.
|
|
7
|
+
export const VERSION = '0.3.5-test.927';
|
package/dist/node/index.cjs
CHANGED
|
@@ -14,12 +14,12 @@ var fastify = require('fastify');
|
|
|
14
14
|
var websocketPlugin = require('@fastify/websocket');
|
|
15
15
|
|
|
16
16
|
// This file is auto-generated during build - do not edit manually
|
|
17
|
-
// Generated from package.json version: 0.3.5-test.
|
|
17
|
+
// Generated from package.json version: 0.3.5-test.927
|
|
18
18
|
/**
|
|
19
19
|
* The package version, injected at build time.
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
const VERSION = '0.3.5-test.
|
|
22
|
+
const VERSION = '0.3.5-test.927';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -10373,6 +10373,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10373
10373
|
await connector.start(this.wrappedHandler);
|
|
10374
10374
|
this.connector = connector;
|
|
10375
10375
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
10376
|
+
// Include admission client's connection grants as callback grants
|
|
10377
|
+
// This ensures DirectAdmissionClient grants are available for grant selection
|
|
10378
|
+
if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
|
|
10379
|
+
for (const grant of welcome.frame.connectionGrants) {
|
|
10380
|
+
if (grant && typeof grant === 'object') {
|
|
10381
|
+
// Avoid duplicates by checking if grant already exists
|
|
10382
|
+
const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
|
|
10383
|
+
if (!isDuplicate) {
|
|
10384
|
+
callbackGrants.push(grant);
|
|
10385
|
+
}
|
|
10386
|
+
}
|
|
10387
|
+
}
|
|
10388
|
+
}
|
|
10376
10389
|
if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
10377
10390
|
const augmented = this.createBroadcastCallbackGrant(grant);
|
|
10378
10391
|
if (augmented) {
|
|
@@ -38922,14 +38935,18 @@ function ensureFinitePositive(value, label) {
|
|
|
38922
38935
|
}
|
|
38923
38936
|
return Math.max(1, Math.floor(value));
|
|
38924
38937
|
}
|
|
38938
|
+
/**
|
|
38939
|
+
* In-memory token cache for PKCE tokens.
|
|
38940
|
+
*
|
|
38941
|
+
* Tokens are intentionally NOT persisted to localStorage or sessionStorage to avoid
|
|
38942
|
+
* stale-token issues when the OAuth2 server restarts and generates new signing keys.
|
|
38943
|
+
* Each fresh page load triggers a new PKCE flow when a token is needed.
|
|
38944
|
+
*/
|
|
38945
|
+
let inMemoryTokenCache = new Map();
|
|
38925
38946
|
const STORAGE_NAMESPACE = 'naylence.oauth2_pkce.';
|
|
38926
|
-
const TOKEN_STORAGE_SUFFIX = '.token';
|
|
38927
38947
|
function getStorageKey(clientId) {
|
|
38928
38948
|
return `${STORAGE_NAMESPACE}${clientId}`;
|
|
38929
38949
|
}
|
|
38930
|
-
function getTokenStorageKey(clientId) {
|
|
38931
|
-
return `${STORAGE_NAMESPACE}${clientId}${TOKEN_STORAGE_SUFFIX}`;
|
|
38932
|
-
}
|
|
38933
38950
|
function isBrowserEnvironment() {
|
|
38934
38951
|
return (typeof window !== 'undefined' &&
|
|
38935
38952
|
typeof window.location !== 'undefined' &&
|
|
@@ -38981,57 +38998,23 @@ function stableScopeKey(scopes) {
|
|
|
38981
38998
|
}
|
|
38982
38999
|
return [...scopes].sort().join(' ');
|
|
38983
39000
|
}
|
|
39001
|
+
/**
|
|
39002
|
+
* Read token from in-memory cache.
|
|
39003
|
+
* Returns null if no cached token exists for the given clientId.
|
|
39004
|
+
*/
|
|
38984
39005
|
function readPersistedToken(clientId) {
|
|
38985
|
-
|
|
38986
|
-
return null;
|
|
38987
|
-
}
|
|
38988
|
-
try {
|
|
38989
|
-
const raw = window.sessionStorage.getItem(getTokenStorageKey(clientId));
|
|
38990
|
-
if (!raw) {
|
|
38991
|
-
return null;
|
|
38992
|
-
}
|
|
38993
|
-
const parsed = JSON.parse(raw);
|
|
38994
|
-
const value = coerceString(parsed.value);
|
|
38995
|
-
if (!value) {
|
|
38996
|
-
return null;
|
|
38997
|
-
}
|
|
38998
|
-
const expiresAt = coerceNumber(parsed.expiresAt);
|
|
38999
|
-
const scopes = normalizeScopes(parsed.scopes);
|
|
39000
|
-
const audience = coerceString(parsed.audience);
|
|
39001
|
-
const record = {
|
|
39002
|
-
value,
|
|
39003
|
-
scopes,
|
|
39004
|
-
audience,
|
|
39005
|
-
};
|
|
39006
|
-
if (typeof expiresAt === 'number') {
|
|
39007
|
-
record.expiresAt = expiresAt;
|
|
39008
|
-
}
|
|
39009
|
-
return record;
|
|
39010
|
-
}
|
|
39011
|
-
catch (error) {
|
|
39012
|
-
logger.debug('pkce_token_storage_read_failed', {
|
|
39013
|
-
error: error instanceof Error ? error.message : String(error),
|
|
39014
|
-
});
|
|
39015
|
-
return null;
|
|
39016
|
-
}
|
|
39006
|
+
return inMemoryTokenCache.get(clientId) ?? null;
|
|
39017
39007
|
}
|
|
39008
|
+
/**
|
|
39009
|
+
* Write token to in-memory cache.
|
|
39010
|
+
* If token is null, removes the cached token for the given clientId.
|
|
39011
|
+
*/
|
|
39018
39012
|
function writePersistedToken(clientId, token) {
|
|
39019
|
-
if (!
|
|
39013
|
+
if (!token) {
|
|
39014
|
+
inMemoryTokenCache.delete(clientId);
|
|
39020
39015
|
return;
|
|
39021
39016
|
}
|
|
39022
|
-
|
|
39023
|
-
try {
|
|
39024
|
-
if (!token) {
|
|
39025
|
-
window.sessionStorage.removeItem(key);
|
|
39026
|
-
return;
|
|
39027
|
-
}
|
|
39028
|
-
window.sessionStorage.setItem(key, JSON.stringify(token));
|
|
39029
|
-
}
|
|
39030
|
-
catch (error) {
|
|
39031
|
-
logger.debug('pkce_token_storage_write_failed', {
|
|
39032
|
-
error: error instanceof Error ? error.message : String(error),
|
|
39033
|
-
});
|
|
39034
|
-
}
|
|
39017
|
+
inMemoryTokenCache.set(clientId, token);
|
|
39035
39018
|
}
|
|
39036
39019
|
function clearOAuthParamsFromUrl(url) {
|
|
39037
39020
|
if (!isBrowserEnvironment()) {
|
|
@@ -39332,6 +39315,17 @@ class OAuth2PkceTokenProvider {
|
|
|
39332
39315
|
});
|
|
39333
39316
|
return token;
|
|
39334
39317
|
}
|
|
39318
|
+
/**
|
|
39319
|
+
* Clear the cached token for this provider instance.
|
|
39320
|
+
* This clears both the instance cache and the in-memory module cache.
|
|
39321
|
+
*/
|
|
39322
|
+
clearToken() {
|
|
39323
|
+
this.cachedToken = undefined;
|
|
39324
|
+
writePersistedToken(this.options.clientId, null);
|
|
39325
|
+
logger.debug('oauth2_pkce_token_cleared', {
|
|
39326
|
+
authorize_url: this.options.authorizeUrl,
|
|
39327
|
+
});
|
|
39328
|
+
}
|
|
39335
39329
|
}
|
|
39336
39330
|
|
|
39337
39331
|
var oauth2PkceTokenProvider = /*#__PURE__*/Object.freeze({
|
package/dist/node/index.mjs
CHANGED
|
@@ -13,12 +13,12 @@ import fastify from 'fastify';
|
|
|
13
13
|
import websocketPlugin from '@fastify/websocket';
|
|
14
14
|
|
|
15
15
|
// This file is auto-generated during build - do not edit manually
|
|
16
|
-
// Generated from package.json version: 0.3.5-test.
|
|
16
|
+
// Generated from package.json version: 0.3.5-test.927
|
|
17
17
|
/**
|
|
18
18
|
* The package version, injected at build time.
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
|
-
const VERSION = '0.3.5-test.
|
|
21
|
+
const VERSION = '0.3.5-test.927';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -10372,6 +10372,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10372
10372
|
await connector.start(this.wrappedHandler);
|
|
10373
10373
|
this.connector = connector;
|
|
10374
10374
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
10375
|
+
// Include admission client's connection grants as callback grants
|
|
10376
|
+
// This ensures DirectAdmissionClient grants are available for grant selection
|
|
10377
|
+
if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
|
|
10378
|
+
for (const grant of welcome.frame.connectionGrants) {
|
|
10379
|
+
if (grant && typeof grant === 'object') {
|
|
10380
|
+
// Avoid duplicates by checking if grant already exists
|
|
10381
|
+
const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
|
|
10382
|
+
if (!isDuplicate) {
|
|
10383
|
+
callbackGrants.push(grant);
|
|
10384
|
+
}
|
|
10385
|
+
}
|
|
10386
|
+
}
|
|
10387
|
+
}
|
|
10375
10388
|
if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
10376
10389
|
const augmented = this.createBroadcastCallbackGrant(grant);
|
|
10377
10390
|
if (augmented) {
|
|
@@ -38921,14 +38934,18 @@ function ensureFinitePositive(value, label) {
|
|
|
38921
38934
|
}
|
|
38922
38935
|
return Math.max(1, Math.floor(value));
|
|
38923
38936
|
}
|
|
38937
|
+
/**
|
|
38938
|
+
* In-memory token cache for PKCE tokens.
|
|
38939
|
+
*
|
|
38940
|
+
* Tokens are intentionally NOT persisted to localStorage or sessionStorage to avoid
|
|
38941
|
+
* stale-token issues when the OAuth2 server restarts and generates new signing keys.
|
|
38942
|
+
* Each fresh page load triggers a new PKCE flow when a token is needed.
|
|
38943
|
+
*/
|
|
38944
|
+
let inMemoryTokenCache = new Map();
|
|
38924
38945
|
const STORAGE_NAMESPACE = 'naylence.oauth2_pkce.';
|
|
38925
|
-
const TOKEN_STORAGE_SUFFIX = '.token';
|
|
38926
38946
|
function getStorageKey(clientId) {
|
|
38927
38947
|
return `${STORAGE_NAMESPACE}${clientId}`;
|
|
38928
38948
|
}
|
|
38929
|
-
function getTokenStorageKey(clientId) {
|
|
38930
|
-
return `${STORAGE_NAMESPACE}${clientId}${TOKEN_STORAGE_SUFFIX}`;
|
|
38931
|
-
}
|
|
38932
38949
|
function isBrowserEnvironment() {
|
|
38933
38950
|
return (typeof window !== 'undefined' &&
|
|
38934
38951
|
typeof window.location !== 'undefined' &&
|
|
@@ -38980,57 +38997,23 @@ function stableScopeKey(scopes) {
|
|
|
38980
38997
|
}
|
|
38981
38998
|
return [...scopes].sort().join(' ');
|
|
38982
38999
|
}
|
|
39000
|
+
/**
|
|
39001
|
+
* Read token from in-memory cache.
|
|
39002
|
+
* Returns null if no cached token exists for the given clientId.
|
|
39003
|
+
*/
|
|
38983
39004
|
function readPersistedToken(clientId) {
|
|
38984
|
-
|
|
38985
|
-
return null;
|
|
38986
|
-
}
|
|
38987
|
-
try {
|
|
38988
|
-
const raw = window.sessionStorage.getItem(getTokenStorageKey(clientId));
|
|
38989
|
-
if (!raw) {
|
|
38990
|
-
return null;
|
|
38991
|
-
}
|
|
38992
|
-
const parsed = JSON.parse(raw);
|
|
38993
|
-
const value = coerceString(parsed.value);
|
|
38994
|
-
if (!value) {
|
|
38995
|
-
return null;
|
|
38996
|
-
}
|
|
38997
|
-
const expiresAt = coerceNumber(parsed.expiresAt);
|
|
38998
|
-
const scopes = normalizeScopes(parsed.scopes);
|
|
38999
|
-
const audience = coerceString(parsed.audience);
|
|
39000
|
-
const record = {
|
|
39001
|
-
value,
|
|
39002
|
-
scopes,
|
|
39003
|
-
audience,
|
|
39004
|
-
};
|
|
39005
|
-
if (typeof expiresAt === 'number') {
|
|
39006
|
-
record.expiresAt = expiresAt;
|
|
39007
|
-
}
|
|
39008
|
-
return record;
|
|
39009
|
-
}
|
|
39010
|
-
catch (error) {
|
|
39011
|
-
logger.debug('pkce_token_storage_read_failed', {
|
|
39012
|
-
error: error instanceof Error ? error.message : String(error),
|
|
39013
|
-
});
|
|
39014
|
-
return null;
|
|
39015
|
-
}
|
|
39005
|
+
return inMemoryTokenCache.get(clientId) ?? null;
|
|
39016
39006
|
}
|
|
39007
|
+
/**
|
|
39008
|
+
* Write token to in-memory cache.
|
|
39009
|
+
* If token is null, removes the cached token for the given clientId.
|
|
39010
|
+
*/
|
|
39017
39011
|
function writePersistedToken(clientId, token) {
|
|
39018
|
-
if (!
|
|
39012
|
+
if (!token) {
|
|
39013
|
+
inMemoryTokenCache.delete(clientId);
|
|
39019
39014
|
return;
|
|
39020
39015
|
}
|
|
39021
|
-
|
|
39022
|
-
try {
|
|
39023
|
-
if (!token) {
|
|
39024
|
-
window.sessionStorage.removeItem(key);
|
|
39025
|
-
return;
|
|
39026
|
-
}
|
|
39027
|
-
window.sessionStorage.setItem(key, JSON.stringify(token));
|
|
39028
|
-
}
|
|
39029
|
-
catch (error) {
|
|
39030
|
-
logger.debug('pkce_token_storage_write_failed', {
|
|
39031
|
-
error: error instanceof Error ? error.message : String(error),
|
|
39032
|
-
});
|
|
39033
|
-
}
|
|
39016
|
+
inMemoryTokenCache.set(clientId, token);
|
|
39034
39017
|
}
|
|
39035
39018
|
function clearOAuthParamsFromUrl(url) {
|
|
39036
39019
|
if (!isBrowserEnvironment()) {
|
|
@@ -39331,6 +39314,17 @@ class OAuth2PkceTokenProvider {
|
|
|
39331
39314
|
});
|
|
39332
39315
|
return token;
|
|
39333
39316
|
}
|
|
39317
|
+
/**
|
|
39318
|
+
* Clear the cached token for this provider instance.
|
|
39319
|
+
* This clears both the instance cache and the in-memory module cache.
|
|
39320
|
+
*/
|
|
39321
|
+
clearToken() {
|
|
39322
|
+
this.cachedToken = undefined;
|
|
39323
|
+
writePersistedToken(this.options.clientId, null);
|
|
39324
|
+
logger.debug('oauth2_pkce_token_cleared', {
|
|
39325
|
+
authorize_url: this.options.authorizeUrl,
|
|
39326
|
+
});
|
|
39327
|
+
}
|
|
39334
39328
|
}
|
|
39335
39329
|
|
|
39336
39330
|
var oauth2PkceTokenProvider = /*#__PURE__*/Object.freeze({
|
package/dist/node/node.cjs
CHANGED
|
@@ -5372,12 +5372,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
|
|
|
5372
5372
|
}
|
|
5373
5373
|
|
|
5374
5374
|
// This file is auto-generated during build - do not edit manually
|
|
5375
|
-
// Generated from package.json version: 0.3.5-test.
|
|
5375
|
+
// Generated from package.json version: 0.3.5-test.927
|
|
5376
5376
|
/**
|
|
5377
5377
|
* The package version, injected at build time.
|
|
5378
5378
|
* @internal
|
|
5379
5379
|
*/
|
|
5380
|
-
const VERSION = '0.3.5-test.
|
|
5380
|
+
const VERSION = '0.3.5-test.927';
|
|
5381
5381
|
|
|
5382
5382
|
/**
|
|
5383
5383
|
* Fame errors module - Fame protocol specific error classes
|
|
@@ -12065,6 +12065,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12065
12065
|
await connector.start(this.wrappedHandler);
|
|
12066
12066
|
this.connector = connector;
|
|
12067
12067
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
12068
|
+
// Include admission client's connection grants as callback grants
|
|
12069
|
+
// This ensures DirectAdmissionClient grants are available for grant selection
|
|
12070
|
+
if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
|
|
12071
|
+
for (const grant of welcome.frame.connectionGrants) {
|
|
12072
|
+
if (grant && typeof grant === 'object') {
|
|
12073
|
+
// Avoid duplicates by checking if grant already exists
|
|
12074
|
+
const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
|
|
12075
|
+
if (!isDuplicate) {
|
|
12076
|
+
callbackGrants.push(grant);
|
|
12077
|
+
}
|
|
12078
|
+
}
|
|
12079
|
+
}
|
|
12080
|
+
}
|
|
12068
12081
|
if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
12069
12082
|
const augmented = this.createBroadcastCallbackGrant(grant);
|
|
12070
12083
|
if (augmented) {
|
|
@@ -41140,14 +41153,18 @@ function ensureFinitePositive(value, label) {
|
|
|
41140
41153
|
}
|
|
41141
41154
|
return Math.max(1, Math.floor(value));
|
|
41142
41155
|
}
|
|
41156
|
+
/**
|
|
41157
|
+
* In-memory token cache for PKCE tokens.
|
|
41158
|
+
*
|
|
41159
|
+
* Tokens are intentionally NOT persisted to localStorage or sessionStorage to avoid
|
|
41160
|
+
* stale-token issues when the OAuth2 server restarts and generates new signing keys.
|
|
41161
|
+
* Each fresh page load triggers a new PKCE flow when a token is needed.
|
|
41162
|
+
*/
|
|
41163
|
+
let inMemoryTokenCache = new Map();
|
|
41143
41164
|
const STORAGE_NAMESPACE = 'naylence.oauth2_pkce.';
|
|
41144
|
-
const TOKEN_STORAGE_SUFFIX = '.token';
|
|
41145
41165
|
function getStorageKey(clientId) {
|
|
41146
41166
|
return `${STORAGE_NAMESPACE}${clientId}`;
|
|
41147
41167
|
}
|
|
41148
|
-
function getTokenStorageKey(clientId) {
|
|
41149
|
-
return `${STORAGE_NAMESPACE}${clientId}${TOKEN_STORAGE_SUFFIX}`;
|
|
41150
|
-
}
|
|
41151
41168
|
function isBrowserEnvironment() {
|
|
41152
41169
|
return (typeof window !== 'undefined' &&
|
|
41153
41170
|
typeof window.location !== 'undefined' &&
|
|
@@ -41199,57 +41216,23 @@ function stableScopeKey(scopes) {
|
|
|
41199
41216
|
}
|
|
41200
41217
|
return [...scopes].sort().join(' ');
|
|
41201
41218
|
}
|
|
41219
|
+
/**
|
|
41220
|
+
* Read token from in-memory cache.
|
|
41221
|
+
* Returns null if no cached token exists for the given clientId.
|
|
41222
|
+
*/
|
|
41202
41223
|
function readPersistedToken(clientId) {
|
|
41203
|
-
|
|
41204
|
-
return null;
|
|
41205
|
-
}
|
|
41206
|
-
try {
|
|
41207
|
-
const raw = window.sessionStorage.getItem(getTokenStorageKey(clientId));
|
|
41208
|
-
if (!raw) {
|
|
41209
|
-
return null;
|
|
41210
|
-
}
|
|
41211
|
-
const parsed = JSON.parse(raw);
|
|
41212
|
-
const value = coerceString(parsed.value);
|
|
41213
|
-
if (!value) {
|
|
41214
|
-
return null;
|
|
41215
|
-
}
|
|
41216
|
-
const expiresAt = coerceNumber(parsed.expiresAt);
|
|
41217
|
-
const scopes = normalizeScopes(parsed.scopes);
|
|
41218
|
-
const audience = coerceString(parsed.audience);
|
|
41219
|
-
const record = {
|
|
41220
|
-
value,
|
|
41221
|
-
scopes,
|
|
41222
|
-
audience,
|
|
41223
|
-
};
|
|
41224
|
-
if (typeof expiresAt === 'number') {
|
|
41225
|
-
record.expiresAt = expiresAt;
|
|
41226
|
-
}
|
|
41227
|
-
return record;
|
|
41228
|
-
}
|
|
41229
|
-
catch (error) {
|
|
41230
|
-
logger.debug('pkce_token_storage_read_failed', {
|
|
41231
|
-
error: error instanceof Error ? error.message : String(error),
|
|
41232
|
-
});
|
|
41233
|
-
return null;
|
|
41234
|
-
}
|
|
41224
|
+
return inMemoryTokenCache.get(clientId) ?? null;
|
|
41235
41225
|
}
|
|
41226
|
+
/**
|
|
41227
|
+
* Write token to in-memory cache.
|
|
41228
|
+
* If token is null, removes the cached token for the given clientId.
|
|
41229
|
+
*/
|
|
41236
41230
|
function writePersistedToken(clientId, token) {
|
|
41237
|
-
if (!
|
|
41231
|
+
if (!token) {
|
|
41232
|
+
inMemoryTokenCache.delete(clientId);
|
|
41238
41233
|
return;
|
|
41239
41234
|
}
|
|
41240
|
-
|
|
41241
|
-
try {
|
|
41242
|
-
if (!token) {
|
|
41243
|
-
window.sessionStorage.removeItem(key);
|
|
41244
|
-
return;
|
|
41245
|
-
}
|
|
41246
|
-
window.sessionStorage.setItem(key, JSON.stringify(token));
|
|
41247
|
-
}
|
|
41248
|
-
catch (error) {
|
|
41249
|
-
logger.debug('pkce_token_storage_write_failed', {
|
|
41250
|
-
error: error instanceof Error ? error.message : String(error),
|
|
41251
|
-
});
|
|
41252
|
-
}
|
|
41235
|
+
inMemoryTokenCache.set(clientId, token);
|
|
41253
41236
|
}
|
|
41254
41237
|
function clearOAuthParamsFromUrl(url) {
|
|
41255
41238
|
if (!isBrowserEnvironment()) {
|
|
@@ -41550,6 +41533,17 @@ class OAuth2PkceTokenProvider {
|
|
|
41550
41533
|
});
|
|
41551
41534
|
return token;
|
|
41552
41535
|
}
|
|
41536
|
+
/**
|
|
41537
|
+
* Clear the cached token for this provider instance.
|
|
41538
|
+
* This clears both the instance cache and the in-memory module cache.
|
|
41539
|
+
*/
|
|
41540
|
+
clearToken() {
|
|
41541
|
+
this.cachedToken = undefined;
|
|
41542
|
+
writePersistedToken(this.options.clientId, null);
|
|
41543
|
+
logger.debug('oauth2_pkce_token_cleared', {
|
|
41544
|
+
authorize_url: this.options.authorizeUrl,
|
|
41545
|
+
});
|
|
41546
|
+
}
|
|
41553
41547
|
}
|
|
41554
41548
|
|
|
41555
41549
|
var oauth2PkceTokenProvider = /*#__PURE__*/Object.freeze({
|
package/dist/node/node.mjs
CHANGED
|
@@ -5371,12 +5371,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
|
|
|
5371
5371
|
}
|
|
5372
5372
|
|
|
5373
5373
|
// This file is auto-generated during build - do not edit manually
|
|
5374
|
-
// Generated from package.json version: 0.3.5-test.
|
|
5374
|
+
// Generated from package.json version: 0.3.5-test.927
|
|
5375
5375
|
/**
|
|
5376
5376
|
* The package version, injected at build time.
|
|
5377
5377
|
* @internal
|
|
5378
5378
|
*/
|
|
5379
|
-
const VERSION = '0.3.5-test.
|
|
5379
|
+
const VERSION = '0.3.5-test.927';
|
|
5380
5380
|
|
|
5381
5381
|
/**
|
|
5382
5382
|
* Fame errors module - Fame protocol specific error classes
|
|
@@ -12064,6 +12064,19 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12064
12064
|
await connector.start(this.wrappedHandler);
|
|
12065
12065
|
this.connector = connector;
|
|
12066
12066
|
const callbackGrants = this.node.gatherSupportedCallbackGrants();
|
|
12067
|
+
// Include admission client's connection grants as callback grants
|
|
12068
|
+
// This ensures DirectAdmissionClient grants are available for grant selection
|
|
12069
|
+
if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
|
|
12070
|
+
for (const grant of welcome.frame.connectionGrants) {
|
|
12071
|
+
if (grant && typeof grant === 'object') {
|
|
12072
|
+
// Avoid duplicates by checking if grant already exists
|
|
12073
|
+
const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
|
|
12074
|
+
if (!isDuplicate) {
|
|
12075
|
+
callbackGrants.push(grant);
|
|
12076
|
+
}
|
|
12077
|
+
}
|
|
12078
|
+
}
|
|
12079
|
+
}
|
|
12067
12080
|
if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
|
|
12068
12081
|
const augmented = this.createBroadcastCallbackGrant(grant);
|
|
12069
12082
|
if (augmented) {
|
|
@@ -41139,14 +41152,18 @@ function ensureFinitePositive(value, label) {
|
|
|
41139
41152
|
}
|
|
41140
41153
|
return Math.max(1, Math.floor(value));
|
|
41141
41154
|
}
|
|
41155
|
+
/**
|
|
41156
|
+
* In-memory token cache for PKCE tokens.
|
|
41157
|
+
*
|
|
41158
|
+
* Tokens are intentionally NOT persisted to localStorage or sessionStorage to avoid
|
|
41159
|
+
* stale-token issues when the OAuth2 server restarts and generates new signing keys.
|
|
41160
|
+
* Each fresh page load triggers a new PKCE flow when a token is needed.
|
|
41161
|
+
*/
|
|
41162
|
+
let inMemoryTokenCache = new Map();
|
|
41142
41163
|
const STORAGE_NAMESPACE = 'naylence.oauth2_pkce.';
|
|
41143
|
-
const TOKEN_STORAGE_SUFFIX = '.token';
|
|
41144
41164
|
function getStorageKey(clientId) {
|
|
41145
41165
|
return `${STORAGE_NAMESPACE}${clientId}`;
|
|
41146
41166
|
}
|
|
41147
|
-
function getTokenStorageKey(clientId) {
|
|
41148
|
-
return `${STORAGE_NAMESPACE}${clientId}${TOKEN_STORAGE_SUFFIX}`;
|
|
41149
|
-
}
|
|
41150
41167
|
function isBrowserEnvironment() {
|
|
41151
41168
|
return (typeof window !== 'undefined' &&
|
|
41152
41169
|
typeof window.location !== 'undefined' &&
|
|
@@ -41198,57 +41215,23 @@ function stableScopeKey(scopes) {
|
|
|
41198
41215
|
}
|
|
41199
41216
|
return [...scopes].sort().join(' ');
|
|
41200
41217
|
}
|
|
41218
|
+
/**
|
|
41219
|
+
* Read token from in-memory cache.
|
|
41220
|
+
* Returns null if no cached token exists for the given clientId.
|
|
41221
|
+
*/
|
|
41201
41222
|
function readPersistedToken(clientId) {
|
|
41202
|
-
|
|
41203
|
-
return null;
|
|
41204
|
-
}
|
|
41205
|
-
try {
|
|
41206
|
-
const raw = window.sessionStorage.getItem(getTokenStorageKey(clientId));
|
|
41207
|
-
if (!raw) {
|
|
41208
|
-
return null;
|
|
41209
|
-
}
|
|
41210
|
-
const parsed = JSON.parse(raw);
|
|
41211
|
-
const value = coerceString(parsed.value);
|
|
41212
|
-
if (!value) {
|
|
41213
|
-
return null;
|
|
41214
|
-
}
|
|
41215
|
-
const expiresAt = coerceNumber(parsed.expiresAt);
|
|
41216
|
-
const scopes = normalizeScopes(parsed.scopes);
|
|
41217
|
-
const audience = coerceString(parsed.audience);
|
|
41218
|
-
const record = {
|
|
41219
|
-
value,
|
|
41220
|
-
scopes,
|
|
41221
|
-
audience,
|
|
41222
|
-
};
|
|
41223
|
-
if (typeof expiresAt === 'number') {
|
|
41224
|
-
record.expiresAt = expiresAt;
|
|
41225
|
-
}
|
|
41226
|
-
return record;
|
|
41227
|
-
}
|
|
41228
|
-
catch (error) {
|
|
41229
|
-
logger.debug('pkce_token_storage_read_failed', {
|
|
41230
|
-
error: error instanceof Error ? error.message : String(error),
|
|
41231
|
-
});
|
|
41232
|
-
return null;
|
|
41233
|
-
}
|
|
41223
|
+
return inMemoryTokenCache.get(clientId) ?? null;
|
|
41234
41224
|
}
|
|
41225
|
+
/**
|
|
41226
|
+
* Write token to in-memory cache.
|
|
41227
|
+
* If token is null, removes the cached token for the given clientId.
|
|
41228
|
+
*/
|
|
41235
41229
|
function writePersistedToken(clientId, token) {
|
|
41236
|
-
if (!
|
|
41230
|
+
if (!token) {
|
|
41231
|
+
inMemoryTokenCache.delete(clientId);
|
|
41237
41232
|
return;
|
|
41238
41233
|
}
|
|
41239
|
-
|
|
41240
|
-
try {
|
|
41241
|
-
if (!token) {
|
|
41242
|
-
window.sessionStorage.removeItem(key);
|
|
41243
|
-
return;
|
|
41244
|
-
}
|
|
41245
|
-
window.sessionStorage.setItem(key, JSON.stringify(token));
|
|
41246
|
-
}
|
|
41247
|
-
catch (error) {
|
|
41248
|
-
logger.debug('pkce_token_storage_write_failed', {
|
|
41249
|
-
error: error instanceof Error ? error.message : String(error),
|
|
41250
|
-
});
|
|
41251
|
-
}
|
|
41234
|
+
inMemoryTokenCache.set(clientId, token);
|
|
41252
41235
|
}
|
|
41253
41236
|
function clearOAuthParamsFromUrl(url) {
|
|
41254
41237
|
if (!isBrowserEnvironment()) {
|
|
@@ -41549,6 +41532,17 @@ class OAuth2PkceTokenProvider {
|
|
|
41549
41532
|
});
|
|
41550
41533
|
return token;
|
|
41551
41534
|
}
|
|
41535
|
+
/**
|
|
41536
|
+
* Clear the cached token for this provider instance.
|
|
41537
|
+
* This clears both the instance cache and the in-memory module cache.
|
|
41538
|
+
*/
|
|
41539
|
+
clearToken() {
|
|
41540
|
+
this.cachedToken = undefined;
|
|
41541
|
+
writePersistedToken(this.options.clientId, null);
|
|
41542
|
+
logger.debug('oauth2_pkce_token_cleared', {
|
|
41543
|
+
authorize_url: this.options.authorizeUrl,
|
|
41544
|
+
});
|
|
41545
|
+
}
|
|
41552
41546
|
}
|
|
41553
41547
|
|
|
41554
41548
|
var oauth2PkceTokenProvider = /*#__PURE__*/Object.freeze({
|
|
@@ -38,5 +38,10 @@ export declare class OAuth2PkceTokenProvider implements TokenProvider {
|
|
|
38
38
|
private resolveFetch;
|
|
39
39
|
private resolveOptionalSecret;
|
|
40
40
|
private exchangeToken;
|
|
41
|
+
/**
|
|
42
|
+
* Clear the cached token for this provider instance.
|
|
43
|
+
* This clears both the instance cache and the in-memory module cache.
|
|
44
|
+
*/
|
|
45
|
+
clearToken(): void;
|
|
41
46
|
}
|
|
42
47
|
export {};
|
package/dist/types/version.d.ts
CHANGED