@naylence/agent-sdk 0.3.4-test.723 → 0.3.4-test.725

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.
@@ -15671,12 +15671,12 @@
15671
15671
  // --- END ENV SHIM ---
15672
15672
 
15673
15673
  // This file is auto-generated during build - do not edit manually
15674
- // Generated from package.json version: 0.3.5-test.925
15674
+ // Generated from package.json version: 0.3.5-test.927
15675
15675
  /**
15676
15676
  * The package version, injected at build time.
15677
15677
  * @internal
15678
15678
  */
15679
- const VERSION$1 = '0.3.5-test.925';
15679
+ const VERSION$1 = '0.3.5-test.927';
15680
15680
 
15681
15681
  /**
15682
15682
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -25088,6 +25088,19 @@
25088
25088
  await connector.start(this.wrappedHandler);
25089
25089
  this.connector = connector;
25090
25090
  const callbackGrants = this.node.gatherSupportedCallbackGrants();
25091
+ // Include admission client's connection grants as callback grants
25092
+ // This ensures DirectAdmissionClient grants are available for grant selection
25093
+ if (welcome.frame.connectionGrants && Array.isArray(welcome.frame.connectionGrants)) {
25094
+ for (const grant of welcome.frame.connectionGrants) {
25095
+ if (grant && typeof grant === 'object') {
25096
+ // Avoid duplicates by checking if grant already exists
25097
+ const isDuplicate = callbackGrants.some(existing => JSON.stringify(existing) === JSON.stringify(grant));
25098
+ if (!isDuplicate) {
25099
+ callbackGrants.push(grant);
25100
+ }
25101
+ }
25102
+ }
25103
+ }
25091
25104
  if (this.shouldAdvertiseBroadcastGrant(grant, callbackGrants)) {
25092
25105
  const augmented = this.createBroadcastCallbackGrant(grant);
25093
25106
  if (augmented) {
@@ -52959,14 +52972,18 @@
52959
52972
  }
52960
52973
  return Math.max(1, Math.floor(value));
52961
52974
  }
52975
+ /**
52976
+ * In-memory token cache for PKCE tokens.
52977
+ *
52978
+ * Tokens are intentionally NOT persisted to localStorage or sessionStorage to avoid
52979
+ * stale-token issues when the OAuth2 server restarts and generates new signing keys.
52980
+ * Each fresh page load triggers a new PKCE flow when a token is needed.
52981
+ */
52982
+ let inMemoryTokenCache = new Map();
52962
52983
  const STORAGE_NAMESPACE = 'naylence.oauth2_pkce.';
52963
- const TOKEN_STORAGE_SUFFIX = '.token';
52964
52984
  function getStorageKey(clientId) {
52965
52985
  return `${STORAGE_NAMESPACE}${clientId}`;
52966
52986
  }
52967
- function getTokenStorageKey(clientId) {
52968
- return `${STORAGE_NAMESPACE}${clientId}${TOKEN_STORAGE_SUFFIX}`;
52969
- }
52970
52987
  function isBrowserEnvironment() {
52971
52988
  return (typeof window !== 'undefined' &&
52972
52989
  typeof window.location !== 'undefined' &&
@@ -53018,57 +53035,23 @@
53018
53035
  }
53019
53036
  return [...scopes].sort().join(' ');
53020
53037
  }
53038
+ /**
53039
+ * Read token from in-memory cache.
53040
+ * Returns null if no cached token exists for the given clientId.
53041
+ */
53021
53042
  function readPersistedToken(clientId) {
53022
- if (!isBrowserEnvironment()) {
53023
- return null;
53024
- }
53025
- try {
53026
- const raw = window.sessionStorage.getItem(getTokenStorageKey(clientId));
53027
- if (!raw) {
53028
- return null;
53029
- }
53030
- const parsed = JSON.parse(raw);
53031
- const value = coerceString(parsed.value);
53032
- if (!value) {
53033
- return null;
53034
- }
53035
- const expiresAt = coerceNumber(parsed.expiresAt);
53036
- const scopes = normalizeScopes(parsed.scopes);
53037
- const audience = coerceString(parsed.audience);
53038
- const record = {
53039
- value,
53040
- scopes,
53041
- audience,
53042
- };
53043
- if (typeof expiresAt === 'number') {
53044
- record.expiresAt = expiresAt;
53045
- }
53046
- return record;
53047
- }
53048
- catch (error) {
53049
- logger$r.debug('pkce_token_storage_read_failed', {
53050
- error: error instanceof Error ? error.message : String(error),
53051
- });
53052
- return null;
53053
- }
53043
+ return inMemoryTokenCache.get(clientId) ?? null;
53054
53044
  }
53045
+ /**
53046
+ * Write token to in-memory cache.
53047
+ * If token is null, removes the cached token for the given clientId.
53048
+ */
53055
53049
  function writePersistedToken(clientId, token) {
53056
- if (!isBrowserEnvironment()) {
53050
+ if (!token) {
53051
+ inMemoryTokenCache.delete(clientId);
53057
53052
  return;
53058
53053
  }
53059
- const key = getTokenStorageKey(clientId);
53060
- try {
53061
- if (!token) {
53062
- window.sessionStorage.removeItem(key);
53063
- return;
53064
- }
53065
- window.sessionStorage.setItem(key, JSON.stringify(token));
53066
- }
53067
- catch (error) {
53068
- logger$r.debug('pkce_token_storage_write_failed', {
53069
- error: error instanceof Error ? error.message : String(error),
53070
- });
53071
- }
53054
+ inMemoryTokenCache.set(clientId, token);
53072
53055
  }
53073
53056
  function clearOAuthParamsFromUrl(url) {
53074
53057
  if (!isBrowserEnvironment()) {
@@ -53369,6 +53352,17 @@
53369
53352
  });
53370
53353
  return token;
53371
53354
  }
53355
+ /**
53356
+ * Clear the cached token for this provider instance.
53357
+ * This clears both the instance cache and the in-memory module cache.
53358
+ */
53359
+ clearToken() {
53360
+ this.cachedToken = undefined;
53361
+ writePersistedToken(this.options.clientId, null);
53362
+ logger$r.debug('oauth2_pkce_token_cleared', {
53363
+ authorize_url: this.options.authorizeUrl,
53364
+ });
53365
+ }
53372
53366
  }
53373
53367
 
53374
53368
  var oauth2PkceTokenProvider = /*#__PURE__*/Object.freeze({