@feelflow/ffid-sdk 5.17.0 → 5.18.0

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.
@@ -1,6 +1,6 @@
1
1
  import { DEFAULT_API_BASE_URL } from '../chunk-JEVK2XUM.js';
2
2
  export { DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES } from '../chunk-JEVK2XUM.js';
3
- import { createRemoteJWKSet, jwtVerify } from 'jose';
3
+ import { createRemoteJWKSet, jwtVerify, errors } from 'jose';
4
4
 
5
5
  // src/auth/token-store.ts
6
6
  var STORAGE_KEY = "ffid_tokens";
@@ -111,10 +111,13 @@ function hasOwnKey(value, key) {
111
111
  function normalizeUserinfo(raw) {
112
112
  const hasOrganizationId = hasOwnKey(raw, "organization_id");
113
113
  const hasOrganizationName = hasOwnKey(raw, "organization_name");
114
- const organizationFields = hasOrganizationId ? {
115
- organizationId: raw.organization_id ?? null,
116
- organizationName: hasOrganizationName ? raw.organization_name ?? null : null
117
- } : hasOrganizationName ? { organizationName: raw.organization_name ?? null } : {};
114
+ const hasOrganizationMemberRole = hasOwnKey(raw, "organization_member_role");
115
+ const organizationMemberRole = hasOrganizationMemberRole ? raw.organization_member_role ?? null : raw.subscription ? raw.subscription.member_role ?? null : void 0;
116
+ const organizationFields = {
117
+ ...hasOrganizationId ? { organizationId: raw.organization_id ?? null } : {},
118
+ ...hasOrganizationId || hasOrganizationName ? { organizationName: raw.organization_name ?? null } : {},
119
+ ...organizationMemberRole !== void 0 ? { organizationMemberRole } : {}
120
+ };
118
121
  return {
119
122
  sub: raw.sub,
120
123
  email: raw.email,
@@ -221,10 +224,29 @@ function createJwtVerifier(deps) {
221
224
  return { data: userInfo };
222
225
  } catch (error) {
223
226
  const message = error instanceof Error ? error.message : "JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F";
224
- logger.error("JWT verification failed:", message);
227
+ if (error instanceof errors.JWTExpired) {
228
+ logger.debug("JWT verification failed (token expired):", message);
229
+ return {
230
+ error: createError(
231
+ errorCodes.TOKEN_EXPIRED,
232
+ "\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u306E\u6709\u52B9\u671F\u9650\u304C\u5207\u308C\u3066\u3044\u307E\u3059"
233
+ )
234
+ };
235
+ }
236
+ const isTokenLevelError = error instanceof errors.JWTClaimValidationFailed || error instanceof errors.JWTInvalid || error instanceof errors.JWSInvalid || error instanceof errors.JWSSignatureVerificationFailed || error instanceof errors.JOSEAlgNotAllowed || error instanceof errors.JOSENotSupported || error instanceof errors.JWKSNoMatchingKey || error instanceof errors.JWKSMultipleMatchingKeys;
237
+ if (isTokenLevelError) {
238
+ logger.warn("JWT verification failed:", message);
239
+ return {
240
+ error: createError(
241
+ errorCodes.TOKEN_VERIFICATION_ERROR,
242
+ `JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
243
+ )
244
+ };
245
+ }
246
+ logger.error("JWT verification failed (JWKS fetch):", message);
225
247
  return {
226
248
  error: createError(
227
- errorCodes.TOKEN_VERIFICATION_ERROR,
249
+ errorCodes.NETWORK_ERROR,
228
250
  `JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
229
251
  )
230
252
  };
@@ -249,7 +271,9 @@ function createVerifyAccessToken(deps) {
249
271
  serviceCode,
250
272
  logger,
251
273
  createError,
252
- errorCodes: { TOKEN_VERIFICATION_ERROR: errorCodes.TOKEN_VERIFICATION_ERROR }
274
+ // structural superset of JwtVerifierDeps.errorCodes — passing it
275
+ // wholesale removes the hand-transcription drift point
276
+ errorCodes
253
277
  });
254
278
  }
255
279
  return jwtVerify2;
@@ -1089,7 +1113,7 @@ function createNonContractMethods(deps) {
1089
1113
  }
1090
1114
 
1091
1115
  // src/client/version-check.ts
1092
- var SDK_VERSION = "5.17.0";
1116
+ var SDK_VERSION = "5.18.0";
1093
1117
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
1094
1118
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
1095
1119
  function sdkHeaders() {
@@ -2516,6 +2540,19 @@ var BLOCKING_EFFECTIVE_STATUSES = [
2516
2540
  "trial_expired"
2517
2541
  ];
2518
2542
 
2543
+ // src/client/error-codes.ts
2544
+ var FFID_ERROR_CODES = {
2545
+ NETWORK_ERROR: "NETWORK_ERROR",
2546
+ PARSE_ERROR: "PARSE_ERROR",
2547
+ UNKNOWN_ERROR: "UNKNOWN_ERROR",
2548
+ TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
2549
+ TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
2550
+ NO_TOKENS: "NO_TOKENS",
2551
+ TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
2552
+ TOKEN_EXPIRED: "TOKEN_EXPIRED",
2553
+ STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
2554
+ };
2555
+
2519
2556
  // src/client/ffid-client.ts
2520
2557
  var UNAUTHORIZED_STATUS2 = 401;
2521
2558
  var SDK_LOG_PREFIX = "[FFID SDK]";
@@ -2524,8 +2561,10 @@ var noopLogger = {
2524
2561
  },
2525
2562
  info: () => {
2526
2563
  },
2527
- warn: (...args) => console.warn(SDK_LOG_PREFIX, ...args),
2528
- error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
2564
+ warn: () => {
2565
+ },
2566
+ error: () => {
2567
+ }
2529
2568
  };
2530
2569
  var consoleLogger = {
2531
2570
  debug: (...args) => console.debug(SDK_LOG_PREFIX, ...args),
@@ -2533,16 +2572,6 @@ var consoleLogger = {
2533
2572
  warn: (...args) => console.warn(SDK_LOG_PREFIX, ...args),
2534
2573
  error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
2535
2574
  };
2536
- var FFID_ERROR_CODES = {
2537
- NETWORK_ERROR: "NETWORK_ERROR",
2538
- PARSE_ERROR: "PARSE_ERROR",
2539
- UNKNOWN_ERROR: "UNKNOWN_ERROR",
2540
- TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
2541
- TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
2542
- NO_TOKENS: "NO_TOKENS",
2543
- TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
2544
- STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
2545
- };
2546
2575
  var EXT_CHECK_ENDPOINT = "/api/v1/subscriptions/ext/check";
2547
2576
  var DEFAULT_ALLOW_GRACE = true;
2548
2577
  var DEFAULT_SERVICE_ACCESS_FAIL_POLICY = "failClosed";
@@ -3212,4 +3241,4 @@ function getFFIDConsentFromCookieHeader(cookieHeader) {
3212
3241
  return decodeConsentCookie(decodeURIComponent(value));
3213
3242
  }
3214
3243
 
3215
- export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };
3244
+ export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, FFID_ERROR_CODES, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };
@@ -1,4 +1,4 @@
1
- import { k as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-DZEK3tkP.cjs';
1
+ import { k as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-Cwk6cG3b.cjs';
2
2
  import '../../types-BeVl-z12.cjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { k as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-BtS84epg.js';
1
+ import { k as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-w8Twi5lD.js';
2
2
  import '../../types-BeVl-z12.js';
3
3
 
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feelflow/ffid-sdk",
3
- "version": "5.17.0",
3
+ "version": "5.18.0",
4
4
  "description": "FeelFlow ID Platform SDK for React/Next.js applications",
5
5
  "keywords": [
6
6
  "feelflow",