@feelflow/ffid-sdk 5.17.1 → 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.
- package/dist/{chunk-A2KK6L63.cjs → chunk-55S5VUWR.cjs} +43 -16
- package/dist/{chunk-26X62P76.js → chunk-L2H56C4W.js} +44 -18
- package/dist/components/index.cjs +8 -8
- package/dist/components/index.js +1 -1
- package/dist/index.cjs +45 -41
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +43 -16
- package/dist/server/index.d.cts +32 -4
- package/dist/server/index.d.ts +32 -4
- package/dist/server/index.js +44 -18
- package/package.json +1 -1
|
@@ -230,10 +230,29 @@ function createJwtVerifier(deps) {
|
|
|
230
230
|
return { data: userInfo };
|
|
231
231
|
} catch (error) {
|
|
232
232
|
const message = error instanceof Error ? error.message : "JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F";
|
|
233
|
-
|
|
233
|
+
if (error instanceof jose.errors.JWTExpired) {
|
|
234
|
+
logger.debug("JWT verification failed (token expired):", message);
|
|
235
|
+
return {
|
|
236
|
+
error: createError(
|
|
237
|
+
errorCodes.TOKEN_EXPIRED,
|
|
238
|
+
"\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u306E\u6709\u52B9\u671F\u9650\u304C\u5207\u308C\u3066\u3044\u307E\u3059"
|
|
239
|
+
)
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
const isTokenLevelError = error instanceof jose.errors.JWTClaimValidationFailed || error instanceof jose.errors.JWTInvalid || error instanceof jose.errors.JWSInvalid || error instanceof jose.errors.JWSSignatureVerificationFailed || error instanceof jose.errors.JOSEAlgNotAllowed || error instanceof jose.errors.JOSENotSupported || error instanceof jose.errors.JWKSNoMatchingKey || error instanceof jose.errors.JWKSMultipleMatchingKeys;
|
|
243
|
+
if (isTokenLevelError) {
|
|
244
|
+
logger.warn("JWT verification failed:", message);
|
|
245
|
+
return {
|
|
246
|
+
error: createError(
|
|
247
|
+
errorCodes.TOKEN_VERIFICATION_ERROR,
|
|
248
|
+
`JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
|
|
249
|
+
)
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
logger.error("JWT verification failed (JWKS fetch):", message);
|
|
234
253
|
return {
|
|
235
254
|
error: createError(
|
|
236
|
-
errorCodes.
|
|
255
|
+
errorCodes.NETWORK_ERROR,
|
|
237
256
|
`JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
|
|
238
257
|
)
|
|
239
258
|
};
|
|
@@ -258,7 +277,9 @@ function createVerifyAccessToken(deps) {
|
|
|
258
277
|
serviceCode,
|
|
259
278
|
logger,
|
|
260
279
|
createError,
|
|
261
|
-
|
|
280
|
+
// structural superset of JwtVerifierDeps.errorCodes — passing it
|
|
281
|
+
// wholesale removes the hand-transcription drift point
|
|
282
|
+
errorCodes
|
|
262
283
|
});
|
|
263
284
|
}
|
|
264
285
|
return jwtVerify2;
|
|
@@ -1098,7 +1119,7 @@ function createNonContractMethods(deps) {
|
|
|
1098
1119
|
}
|
|
1099
1120
|
|
|
1100
1121
|
// src/client/version-check.ts
|
|
1101
|
-
var SDK_VERSION = "5.
|
|
1122
|
+
var SDK_VERSION = "5.18.0";
|
|
1102
1123
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
1103
1124
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
1104
1125
|
function sdkHeaders() {
|
|
@@ -2695,6 +2716,19 @@ function isBlockedFromUserinfo(sub) {
|
|
|
2695
2716
|
return BLOCKING_EFFECTIVE_STATUSES.includes(effectiveStatus);
|
|
2696
2717
|
}
|
|
2697
2718
|
|
|
2719
|
+
// src/client/error-codes.ts
|
|
2720
|
+
var FFID_ERROR_CODES = {
|
|
2721
|
+
NETWORK_ERROR: "NETWORK_ERROR",
|
|
2722
|
+
PARSE_ERROR: "PARSE_ERROR",
|
|
2723
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
2724
|
+
TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
|
|
2725
|
+
TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
|
|
2726
|
+
NO_TOKENS: "NO_TOKENS",
|
|
2727
|
+
TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
|
|
2728
|
+
TOKEN_EXPIRED: "TOKEN_EXPIRED",
|
|
2729
|
+
STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
|
|
2730
|
+
};
|
|
2731
|
+
|
|
2698
2732
|
// src/client/ffid-client.ts
|
|
2699
2733
|
var UNAUTHORIZED_STATUS2 = 401;
|
|
2700
2734
|
var SDK_LOG_PREFIX = "[FFID SDK]";
|
|
@@ -2703,8 +2737,10 @@ var noopLogger = {
|
|
|
2703
2737
|
},
|
|
2704
2738
|
info: () => {
|
|
2705
2739
|
},
|
|
2706
|
-
warn: (
|
|
2707
|
-
|
|
2740
|
+
warn: () => {
|
|
2741
|
+
},
|
|
2742
|
+
error: () => {
|
|
2743
|
+
}
|
|
2708
2744
|
};
|
|
2709
2745
|
var consoleLogger = {
|
|
2710
2746
|
debug: (...args) => console.debug(SDK_LOG_PREFIX, ...args),
|
|
@@ -2712,16 +2748,6 @@ var consoleLogger = {
|
|
|
2712
2748
|
warn: (...args) => console.warn(SDK_LOG_PREFIX, ...args),
|
|
2713
2749
|
error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
|
|
2714
2750
|
};
|
|
2715
|
-
var FFID_ERROR_CODES = {
|
|
2716
|
-
NETWORK_ERROR: "NETWORK_ERROR",
|
|
2717
|
-
PARSE_ERROR: "PARSE_ERROR",
|
|
2718
|
-
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
2719
|
-
TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
|
|
2720
|
-
TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
|
|
2721
|
-
NO_TOKENS: "NO_TOKENS",
|
|
2722
|
-
TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
|
|
2723
|
-
STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
|
|
2724
|
-
};
|
|
2725
2751
|
var EXT_CHECK_ENDPOINT = "/api/v1/subscriptions/ext/check";
|
|
2726
2752
|
var DEFAULT_ALLOW_GRACE = true;
|
|
2727
2753
|
var DEFAULT_SERVICE_ACCESS_FAIL_POLICY = "failClosed";
|
|
@@ -5351,6 +5377,7 @@ exports.FFIDSDKError = FFIDSDKError;
|
|
|
5351
5377
|
exports.FFIDSubscriptionBadge = FFIDSubscriptionBadge;
|
|
5352
5378
|
exports.FFIDUserMenu = FFIDUserMenu;
|
|
5353
5379
|
exports.FFID_ANNOUNCEMENTS_ERROR_CODES = FFID_ANNOUNCEMENTS_ERROR_CODES;
|
|
5380
|
+
exports.FFID_ERROR_CODES = FFID_ERROR_CODES;
|
|
5354
5381
|
exports.FFID_INQUIRY_CATEGORIES = FFID_INQUIRY_CATEGORIES;
|
|
5355
5382
|
exports.FFID_INQUIRY_CATEGORIES_SITE_2026 = FFID_INQUIRY_CATEGORIES_SITE_2026;
|
|
5356
5383
|
exports.cleanupStateStorage = cleanupStateStorage;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, useState, useRef, useEffect, useMemo, useCallback, useContext } from 'react';
|
|
2
|
-
import { createRemoteJWKSet, jwtVerify } from 'jose';
|
|
2
|
+
import { createRemoteJWKSet, jwtVerify, errors } from 'jose';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
// src/constants.ts
|
|
@@ -228,10 +228,29 @@ function createJwtVerifier(deps) {
|
|
|
228
228
|
return { data: userInfo };
|
|
229
229
|
} catch (error) {
|
|
230
230
|
const message = error instanceof Error ? error.message : "JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F";
|
|
231
|
-
|
|
231
|
+
if (error instanceof errors.JWTExpired) {
|
|
232
|
+
logger.debug("JWT verification failed (token expired):", message);
|
|
233
|
+
return {
|
|
234
|
+
error: createError(
|
|
235
|
+
errorCodes.TOKEN_EXPIRED,
|
|
236
|
+
"\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u306E\u6709\u52B9\u671F\u9650\u304C\u5207\u308C\u3066\u3044\u307E\u3059"
|
|
237
|
+
)
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
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;
|
|
241
|
+
if (isTokenLevelError) {
|
|
242
|
+
logger.warn("JWT verification failed:", message);
|
|
243
|
+
return {
|
|
244
|
+
error: createError(
|
|
245
|
+
errorCodes.TOKEN_VERIFICATION_ERROR,
|
|
246
|
+
`JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
|
|
247
|
+
)
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
logger.error("JWT verification failed (JWKS fetch):", message);
|
|
232
251
|
return {
|
|
233
252
|
error: createError(
|
|
234
|
-
errorCodes.
|
|
253
|
+
errorCodes.NETWORK_ERROR,
|
|
235
254
|
`JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
|
|
236
255
|
)
|
|
237
256
|
};
|
|
@@ -256,7 +275,9 @@ function createVerifyAccessToken(deps) {
|
|
|
256
275
|
serviceCode,
|
|
257
276
|
logger,
|
|
258
277
|
createError,
|
|
259
|
-
|
|
278
|
+
// structural superset of JwtVerifierDeps.errorCodes — passing it
|
|
279
|
+
// wholesale removes the hand-transcription drift point
|
|
280
|
+
errorCodes
|
|
260
281
|
});
|
|
261
282
|
}
|
|
262
283
|
return jwtVerify2;
|
|
@@ -1096,7 +1117,7 @@ function createNonContractMethods(deps) {
|
|
|
1096
1117
|
}
|
|
1097
1118
|
|
|
1098
1119
|
// src/client/version-check.ts
|
|
1099
|
-
var SDK_VERSION = "5.
|
|
1120
|
+
var SDK_VERSION = "5.18.0";
|
|
1100
1121
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
1101
1122
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
1102
1123
|
function sdkHeaders() {
|
|
@@ -2693,6 +2714,19 @@ function isBlockedFromUserinfo(sub) {
|
|
|
2693
2714
|
return BLOCKING_EFFECTIVE_STATUSES.includes(effectiveStatus);
|
|
2694
2715
|
}
|
|
2695
2716
|
|
|
2717
|
+
// src/client/error-codes.ts
|
|
2718
|
+
var FFID_ERROR_CODES = {
|
|
2719
|
+
NETWORK_ERROR: "NETWORK_ERROR",
|
|
2720
|
+
PARSE_ERROR: "PARSE_ERROR",
|
|
2721
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
2722
|
+
TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
|
|
2723
|
+
TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
|
|
2724
|
+
NO_TOKENS: "NO_TOKENS",
|
|
2725
|
+
TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
|
|
2726
|
+
TOKEN_EXPIRED: "TOKEN_EXPIRED",
|
|
2727
|
+
STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
|
|
2728
|
+
};
|
|
2729
|
+
|
|
2696
2730
|
// src/client/ffid-client.ts
|
|
2697
2731
|
var UNAUTHORIZED_STATUS2 = 401;
|
|
2698
2732
|
var SDK_LOG_PREFIX = "[FFID SDK]";
|
|
@@ -2701,8 +2735,10 @@ var noopLogger = {
|
|
|
2701
2735
|
},
|
|
2702
2736
|
info: () => {
|
|
2703
2737
|
},
|
|
2704
|
-
warn: (
|
|
2705
|
-
|
|
2738
|
+
warn: () => {
|
|
2739
|
+
},
|
|
2740
|
+
error: () => {
|
|
2741
|
+
}
|
|
2706
2742
|
};
|
|
2707
2743
|
var consoleLogger = {
|
|
2708
2744
|
debug: (...args) => console.debug(SDK_LOG_PREFIX, ...args),
|
|
@@ -2710,16 +2746,6 @@ var consoleLogger = {
|
|
|
2710
2746
|
warn: (...args) => console.warn(SDK_LOG_PREFIX, ...args),
|
|
2711
2747
|
error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
|
|
2712
2748
|
};
|
|
2713
|
-
var FFID_ERROR_CODES = {
|
|
2714
|
-
NETWORK_ERROR: "NETWORK_ERROR",
|
|
2715
|
-
PARSE_ERROR: "PARSE_ERROR",
|
|
2716
|
-
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
2717
|
-
TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
|
|
2718
|
-
TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
|
|
2719
|
-
NO_TOKENS: "NO_TOKENS",
|
|
2720
|
-
TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
|
|
2721
|
-
STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
|
|
2722
|
-
};
|
|
2723
2749
|
var EXT_CHECK_ENDPOINT = "/api/v1/subscriptions/ext/check";
|
|
2724
2750
|
var DEFAULT_ALLOW_GRACE = true;
|
|
2725
2751
|
var DEFAULT_SERVICE_ACCESS_FAIL_POLICY = "failClosed";
|
|
@@ -5334,4 +5360,4 @@ function FFIDInquiryForm({
|
|
|
5334
5360
|
);
|
|
5335
5361
|
}
|
|
5336
5362
|
|
|
5337
|
-
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, BLOCKING_EFFECTIVE_STATUSES, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EFFECTIVE_SUBSCRIPTION_STATUSES, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSDKError, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_INQUIRY_CATEGORIES, FFID_INQUIRY_CATEGORIES_SITE_2026, cleanupStateStorage, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, isBlockedFromUserinfo, isFFIDInquiryCategorySite2026, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, storeCodeVerifier, storeState, useFFID, useFFIDAnnouncements, useFFIDContext, useSubscription, withSubscription };
|
|
5363
|
+
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, BLOCKING_EFFECTIVE_STATUSES, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EFFECTIVE_SUBSCRIPTION_STATUSES, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSDKError, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_ERROR_CODES, FFID_INQUIRY_CATEGORIES, FFID_INQUIRY_CATEGORIES_SITE_2026, cleanupStateStorage, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, isBlockedFromUserinfo, isFFIDInquiryCategorySite2026, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, storeCodeVerifier, storeState, useFFID, useFFIDAnnouncements, useFFIDContext, useSubscription, withSubscription };
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk55S5VUWR_cjs = require('../chunk-55S5VUWR.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "FFIDAnnouncementBadge", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDAnnouncementBadge; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "FFIDAnnouncementList", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDAnnouncementList; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "FFIDInquiryForm", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDInquiryForm; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "FFIDLoginButton", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDLoginButton; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDOrganizationSwitcher; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "FFIDSubscriptionBadge", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDSubscriptionBadge; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "FFIDUserMenu", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDUserMenu; }
|
|
34
34
|
});
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-
|
|
1
|
+
export { FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-L2H56C4W.js';
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk55S5VUWR_cjs = require('./chunk-55S5VUWR.cjs');
|
|
4
4
|
var chunkH5O2CCAY_cjs = require('./chunk-H5O2CCAY.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -54,8 +54,8 @@ function defaultRedirect(url) {
|
|
|
54
54
|
}
|
|
55
55
|
function useRequireActiveSubscription(options) {
|
|
56
56
|
const { redirectTo, allowGrace = true, onRedirect } = options;
|
|
57
|
-
const { isLoading, error } =
|
|
58
|
-
const { effectiveStatus, isBlocked, isGrace } =
|
|
57
|
+
const { isLoading, error } = chunk55S5VUWR_cjs.useFFIDContext();
|
|
58
|
+
const { effectiveStatus, isBlocked, isGrace } = chunk55S5VUWR_cjs.useSubscription();
|
|
59
59
|
const hasFetchError = error !== null && effectiveStatus === null;
|
|
60
60
|
const shouldRedirect = !isLoading && !hasFetchError && (isBlocked || !allowGrace && isGrace || effectiveStatus === null);
|
|
61
61
|
react.useEffect(() => {
|
|
@@ -76,7 +76,7 @@ function useRequireActiveSubscription(options) {
|
|
|
76
76
|
}
|
|
77
77
|
function withFFIDAuth(Component, options = {}) {
|
|
78
78
|
const WrappedComponent = (props) => {
|
|
79
|
-
const { isLoading, isAuthenticated, login } =
|
|
79
|
+
const { isLoading, isAuthenticated, login } = chunk55S5VUWR_cjs.useFFIDContext();
|
|
80
80
|
const hasRedirected = react.useRef(false);
|
|
81
81
|
react.useEffect(() => {
|
|
82
82
|
if (!isLoading && !isAuthenticated && options.redirectToLogin && !hasRedirected.current) {
|
|
@@ -105,151 +105,155 @@ var FFID_NEWSLETTER_DISPATCH_MAX_RECIPIENTS = 1e3;
|
|
|
105
105
|
|
|
106
106
|
Object.defineProperty(exports, "ACCESS_GRANTING_EFFECTIVE_STATUSES", {
|
|
107
107
|
enumerable: true,
|
|
108
|
-
get: function () { return
|
|
108
|
+
get: function () { return chunk55S5VUWR_cjs.ACCESS_GRANTING_EFFECTIVE_STATUSES; }
|
|
109
109
|
});
|
|
110
110
|
Object.defineProperty(exports, "BLOCKING_EFFECTIVE_STATUSES", {
|
|
111
111
|
enumerable: true,
|
|
112
|
-
get: function () { return
|
|
112
|
+
get: function () { return chunk55S5VUWR_cjs.BLOCKING_EFFECTIVE_STATUSES; }
|
|
113
113
|
});
|
|
114
114
|
Object.defineProperty(exports, "DEFAULT_API_BASE_URL", {
|
|
115
115
|
enumerable: true,
|
|
116
|
-
get: function () { return
|
|
116
|
+
get: function () { return chunk55S5VUWR_cjs.DEFAULT_API_BASE_URL; }
|
|
117
117
|
});
|
|
118
118
|
Object.defineProperty(exports, "DEFAULT_OAUTH_SCOPES", {
|
|
119
119
|
enumerable: true,
|
|
120
|
-
get: function () { return
|
|
120
|
+
get: function () { return chunk55S5VUWR_cjs.DEFAULT_OAUTH_SCOPES; }
|
|
121
121
|
});
|
|
122
122
|
Object.defineProperty(exports, "EFFECTIVE_SUBSCRIPTION_STATUSES", {
|
|
123
123
|
enumerable: true,
|
|
124
|
-
get: function () { return
|
|
124
|
+
get: function () { return chunk55S5VUWR_cjs.EFFECTIVE_SUBSCRIPTION_STATUSES; }
|
|
125
125
|
});
|
|
126
126
|
Object.defineProperty(exports, "FFIDAnnouncementBadge", {
|
|
127
127
|
enumerable: true,
|
|
128
|
-
get: function () { return
|
|
128
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDAnnouncementBadge; }
|
|
129
129
|
});
|
|
130
130
|
Object.defineProperty(exports, "FFIDAnnouncementList", {
|
|
131
131
|
enumerable: true,
|
|
132
|
-
get: function () { return
|
|
132
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDAnnouncementList; }
|
|
133
133
|
});
|
|
134
134
|
Object.defineProperty(exports, "FFIDInquiryForm", {
|
|
135
135
|
enumerable: true,
|
|
136
|
-
get: function () { return
|
|
136
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDInquiryForm; }
|
|
137
137
|
});
|
|
138
138
|
Object.defineProperty(exports, "FFIDLoginButton", {
|
|
139
139
|
enumerable: true,
|
|
140
|
-
get: function () { return
|
|
140
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDLoginButton; }
|
|
141
141
|
});
|
|
142
142
|
Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
|
|
143
143
|
enumerable: true,
|
|
144
|
-
get: function () { return
|
|
144
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDOrganizationSwitcher; }
|
|
145
145
|
});
|
|
146
146
|
Object.defineProperty(exports, "FFIDProvider", {
|
|
147
147
|
enumerable: true,
|
|
148
|
-
get: function () { return
|
|
148
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDProvider; }
|
|
149
149
|
});
|
|
150
150
|
Object.defineProperty(exports, "FFIDSDKError", {
|
|
151
151
|
enumerable: true,
|
|
152
|
-
get: function () { return
|
|
152
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDSDKError; }
|
|
153
153
|
});
|
|
154
154
|
Object.defineProperty(exports, "FFIDSubscriptionBadge", {
|
|
155
155
|
enumerable: true,
|
|
156
|
-
get: function () { return
|
|
156
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDSubscriptionBadge; }
|
|
157
157
|
});
|
|
158
158
|
Object.defineProperty(exports, "FFIDUserMenu", {
|
|
159
159
|
enumerable: true,
|
|
160
|
-
get: function () { return
|
|
160
|
+
get: function () { return chunk55S5VUWR_cjs.FFIDUserMenu; }
|
|
161
161
|
});
|
|
162
162
|
Object.defineProperty(exports, "FFID_ANNOUNCEMENTS_ERROR_CODES", {
|
|
163
163
|
enumerable: true,
|
|
164
|
-
get: function () { return
|
|
164
|
+
get: function () { return chunk55S5VUWR_cjs.FFID_ANNOUNCEMENTS_ERROR_CODES; }
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(exports, "FFID_ERROR_CODES", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function () { return chunk55S5VUWR_cjs.FFID_ERROR_CODES; }
|
|
165
169
|
});
|
|
166
170
|
Object.defineProperty(exports, "FFID_INQUIRY_CATEGORIES", {
|
|
167
171
|
enumerable: true,
|
|
168
|
-
get: function () { return
|
|
172
|
+
get: function () { return chunk55S5VUWR_cjs.FFID_INQUIRY_CATEGORIES; }
|
|
169
173
|
});
|
|
170
174
|
Object.defineProperty(exports, "FFID_INQUIRY_CATEGORIES_SITE_2026", {
|
|
171
175
|
enumerable: true,
|
|
172
|
-
get: function () { return
|
|
176
|
+
get: function () { return chunk55S5VUWR_cjs.FFID_INQUIRY_CATEGORIES_SITE_2026; }
|
|
173
177
|
});
|
|
174
178
|
Object.defineProperty(exports, "clearState", {
|
|
175
179
|
enumerable: true,
|
|
176
|
-
get: function () { return
|
|
180
|
+
get: function () { return chunk55S5VUWR_cjs.cleanupStateStorage; }
|
|
177
181
|
});
|
|
178
182
|
Object.defineProperty(exports, "computeEffectiveStatusFromSession", {
|
|
179
183
|
enumerable: true,
|
|
180
|
-
get: function () { return
|
|
184
|
+
get: function () { return chunk55S5VUWR_cjs.computeEffectiveStatusFromSession; }
|
|
181
185
|
});
|
|
182
186
|
Object.defineProperty(exports, "createFFIDAnnouncementsClient", {
|
|
183
187
|
enumerable: true,
|
|
184
|
-
get: function () { return
|
|
188
|
+
get: function () { return chunk55S5VUWR_cjs.createFFIDAnnouncementsClient; }
|
|
185
189
|
});
|
|
186
190
|
Object.defineProperty(exports, "createFFIDClient", {
|
|
187
191
|
enumerable: true,
|
|
188
|
-
get: function () { return
|
|
192
|
+
get: function () { return chunk55S5VUWR_cjs.createFFIDClient; }
|
|
189
193
|
});
|
|
190
194
|
Object.defineProperty(exports, "createTokenStore", {
|
|
191
195
|
enumerable: true,
|
|
192
|
-
get: function () { return
|
|
196
|
+
get: function () { return chunk55S5VUWR_cjs.createTokenStore; }
|
|
193
197
|
});
|
|
194
198
|
Object.defineProperty(exports, "generateCodeChallenge", {
|
|
195
199
|
enumerable: true,
|
|
196
|
-
get: function () { return
|
|
200
|
+
get: function () { return chunk55S5VUWR_cjs.generateCodeChallenge; }
|
|
197
201
|
});
|
|
198
202
|
Object.defineProperty(exports, "generateCodeVerifier", {
|
|
199
203
|
enumerable: true,
|
|
200
|
-
get: function () { return
|
|
204
|
+
get: function () { return chunk55S5VUWR_cjs.generateCodeVerifier; }
|
|
201
205
|
});
|
|
202
206
|
Object.defineProperty(exports, "handleRedirectCallback", {
|
|
203
207
|
enumerable: true,
|
|
204
|
-
get: function () { return
|
|
208
|
+
get: function () { return chunk55S5VUWR_cjs.handleRedirectCallback; }
|
|
205
209
|
});
|
|
206
210
|
Object.defineProperty(exports, "hasAccessFromUserinfo", {
|
|
207
211
|
enumerable: true,
|
|
208
|
-
get: function () { return
|
|
212
|
+
get: function () { return chunk55S5VUWR_cjs.hasAccessFromUserinfo; }
|
|
209
213
|
});
|
|
210
214
|
Object.defineProperty(exports, "isBlockedFromUserinfo", {
|
|
211
215
|
enumerable: true,
|
|
212
|
-
get: function () { return
|
|
216
|
+
get: function () { return chunk55S5VUWR_cjs.isBlockedFromUserinfo; }
|
|
213
217
|
});
|
|
214
218
|
Object.defineProperty(exports, "isFFIDInquiryCategorySite2026", {
|
|
215
219
|
enumerable: true,
|
|
216
|
-
get: function () { return
|
|
220
|
+
get: function () { return chunk55S5VUWR_cjs.isFFIDInquiryCategorySite2026; }
|
|
217
221
|
});
|
|
218
222
|
Object.defineProperty(exports, "normalizeRedirectUri", {
|
|
219
223
|
enumerable: true,
|
|
220
|
-
get: function () { return
|
|
224
|
+
get: function () { return chunk55S5VUWR_cjs.normalizeRedirectUri; }
|
|
221
225
|
});
|
|
222
226
|
Object.defineProperty(exports, "retrieveCodeVerifier", {
|
|
223
227
|
enumerable: true,
|
|
224
|
-
get: function () { return
|
|
228
|
+
get: function () { return chunk55S5VUWR_cjs.retrieveCodeVerifier; }
|
|
225
229
|
});
|
|
226
230
|
Object.defineProperty(exports, "retrieveState", {
|
|
227
231
|
enumerable: true,
|
|
228
|
-
get: function () { return
|
|
232
|
+
get: function () { return chunk55S5VUWR_cjs.retrieveState; }
|
|
229
233
|
});
|
|
230
234
|
Object.defineProperty(exports, "storeCodeVerifier", {
|
|
231
235
|
enumerable: true,
|
|
232
|
-
get: function () { return
|
|
236
|
+
get: function () { return chunk55S5VUWR_cjs.storeCodeVerifier; }
|
|
233
237
|
});
|
|
234
238
|
Object.defineProperty(exports, "storeState", {
|
|
235
239
|
enumerable: true,
|
|
236
|
-
get: function () { return
|
|
240
|
+
get: function () { return chunk55S5VUWR_cjs.storeState; }
|
|
237
241
|
});
|
|
238
242
|
Object.defineProperty(exports, "useFFID", {
|
|
239
243
|
enumerable: true,
|
|
240
|
-
get: function () { return
|
|
244
|
+
get: function () { return chunk55S5VUWR_cjs.useFFID; }
|
|
241
245
|
});
|
|
242
246
|
Object.defineProperty(exports, "useFFIDAnnouncements", {
|
|
243
247
|
enumerable: true,
|
|
244
|
-
get: function () { return
|
|
248
|
+
get: function () { return chunk55S5VUWR_cjs.useFFIDAnnouncements; }
|
|
245
249
|
});
|
|
246
250
|
Object.defineProperty(exports, "useSubscription", {
|
|
247
251
|
enumerable: true,
|
|
248
|
-
get: function () { return
|
|
252
|
+
get: function () { return chunk55S5VUWR_cjs.useSubscription; }
|
|
249
253
|
});
|
|
250
254
|
Object.defineProperty(exports, "withSubscription", {
|
|
251
255
|
enumerable: true,
|
|
252
|
-
get: function () { return
|
|
256
|
+
get: function () { return chunk55S5VUWR_cjs.withSubscription; }
|
|
253
257
|
});
|
|
254
258
|
Object.defineProperty(exports, "ALL_DENIED_EXCEPT_NECESSARY", {
|
|
255
259
|
enumerable: true,
|
package/dist/index.d.cts
CHANGED
|
@@ -1127,6 +1127,33 @@ interface RedirectToAuthorizeOptions {
|
|
|
1127
1127
|
prompt?: FFIDPrompt;
|
|
1128
1128
|
}
|
|
1129
1129
|
|
|
1130
|
+
/**
|
|
1131
|
+
* FFID SDK error codes
|
|
1132
|
+
*
|
|
1133
|
+
* Codes the SDK itself attaches to `FFIDError.code`. Exported from the
|
|
1134
|
+
* package entry points so consumers can branch on codes (e.g.
|
|
1135
|
+
* `TOKEN_EXPIRED` vs `TOKEN_VERIFICATION_ERROR`) without hardcoding strings.
|
|
1136
|
+
*/
|
|
1137
|
+
/** Error codes used by the SDK */
|
|
1138
|
+
declare const FFID_ERROR_CODES: {
|
|
1139
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
1140
|
+
readonly PARSE_ERROR: "PARSE_ERROR";
|
|
1141
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
1142
|
+
readonly TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR";
|
|
1143
|
+
readonly TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR";
|
|
1144
|
+
readonly NO_TOKENS: "NO_TOKENS";
|
|
1145
|
+
readonly TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR";
|
|
1146
|
+
readonly TOKEN_EXPIRED: "TOKEN_EXPIRED";
|
|
1147
|
+
readonly STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR";
|
|
1148
|
+
};
|
|
1149
|
+
/**
|
|
1150
|
+
* Union of the error code literals the SDK itself produces.
|
|
1151
|
+
*
|
|
1152
|
+
* Note: `FFIDError.code` intentionally stays `string` — server-provided
|
|
1153
|
+
* error codes pass through verbatim and must not be narrowed away.
|
|
1154
|
+
*/
|
|
1155
|
+
type FFIDErrorCode = (typeof FFID_ERROR_CODES)[keyof typeof FFID_ERROR_CODES];
|
|
1156
|
+
|
|
1130
1157
|
/** Creates an FFID API client instance */
|
|
1131
1158
|
declare function createFFIDClient(config: FFIDConfig): {
|
|
1132
1159
|
getSession: () => Promise<FFIDApiResponse<FFIDSessionResponse>>;
|
|
@@ -2040,4 +2067,4 @@ declare function createInquiryMethods(deps: InquiryMethodsDeps): {
|
|
|
2040
2067
|
};
|
|
2041
2068
|
type FFIDInquiryClient = ReturnType<typeof createInquiryMethods>;
|
|
2042
2069
|
|
|
2043
|
-
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, AnnouncementListResponse, BLOCKING_EFFECTIVE_STATUSES, type ComputeEffectiveStatusInput, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EffectiveSubscriptionStatus, type ExchangeCodeForTokensOptions, type FFIDAddMemberParams, type FFIDAddMemberRequest, type FFIDAddMemberResponse, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDAssignableMemberRole, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelPendingDowngradeResponse, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckServiceAccessParams, type FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, type FFIDCreateCheckoutParams, type FFIDCreatePortalParams, FFIDError, type FFIDInquiryClient, FFIDInquiryCreateParams, FFIDInquiryCreateResponse, type FFIDInvitationStatus, type FFIDInviteMemberRequest, type FFIDInviteMemberResponse, type FFIDLeaveOrganizationParams, type FFIDLeaveOrganizationResponse, type FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, type FFIDLoginHistoryEntry, type FFIDLoginHistoryResponse, type FFIDMemberRole, type FFIDMemberStatus, type FFIDNewsletterBodySource, type FFIDNewsletterCampaignStatus, type FFIDNewsletterClient, type FFIDNewsletterConfirmParams, type FFIDNewsletterConfirmResponse, type FFIDNewsletterDispatchParams, type FFIDNewsletterDispatchResponse, type FFIDNewsletterSegment, type FFIDNewsletterSubscribeParams, type FFIDNewsletterSubscribeResponse, type FFIDNewsletterType, type FFIDNewsletterUnsubscribeParams, type FFIDNewsletterUnsubscribeResponse, FFIDOAuthUserInfo, FFIDOAuthUserInfoSubscription, FFIDOrganization, type FFIDOrganizationDomain, type FFIDOrganizationDomainsResponse, type FFIDOrganizationMember, type FFIDOrganizationNotificationPreferences, type FFIDOrganizationNotificationPreferencesResponse, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreview, type FFIDPlanChangePreviewResponse, type FFIDPlanInfo, type FFIDPortalSessionResponse, type FFIDPreviewPlanChangeParams, type FFIDPreviewSeatChangeParams, type FFIDProfileCallOptions, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, type FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSDKError, type FFIDSeatChangeLineItem, type FFIDSeatChangePreview, type FFIDSeatChangePreviewResponse, FFIDServiceAccessDecision, type FFIDServiceInfo, FFIDSessionResponse, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, type FFIDSupportedCurrency, type FFIDUpdateMemberRoleResponse, type FFIDUpdateNotificationPreferencesRequest, type FFIDUpdateUserProfileRequest, FFIDUser, type FFIDUserProfile, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_NEWSLETTER_DISPATCH_MAX_RECIPIENTS, FFID_NEWSLETTER_TYPES, type HandleRedirectCallbackClient, type HandleRedirectCallbackOptions, type KVNamespaceLike, ListAnnouncementsOptions, type NormalizeRedirectUriResult, type RedirectToAuthorizeOptions, type TokenData, type TokenStore, type UseFFIDReturn, type UseRequireActiveSubscriptionOptions, type UseRequireActiveSubscriptionReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, cleanupStateStorage as clearState, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, isBlockedFromUserinfo, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, storeCodeVerifier, storeState, useFFID, useRequireActiveSubscription, useSubscription, withFFIDAuth, withSubscription };
|
|
2070
|
+
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, AnnouncementListResponse, BLOCKING_EFFECTIVE_STATUSES, type ComputeEffectiveStatusInput, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EffectiveSubscriptionStatus, type ExchangeCodeForTokensOptions, type FFIDAddMemberParams, type FFIDAddMemberRequest, type FFIDAddMemberResponse, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDAssignableMemberRole, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelPendingDowngradeResponse, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckServiceAccessParams, type FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, type FFIDCreateCheckoutParams, type FFIDCreatePortalParams, FFIDError, type FFIDErrorCode, type FFIDInquiryClient, FFIDInquiryCreateParams, FFIDInquiryCreateResponse, type FFIDInvitationStatus, type FFIDInviteMemberRequest, type FFIDInviteMemberResponse, type FFIDLeaveOrganizationParams, type FFIDLeaveOrganizationResponse, type FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, type FFIDLoginHistoryEntry, type FFIDLoginHistoryResponse, type FFIDMemberRole, type FFIDMemberStatus, type FFIDNewsletterBodySource, type FFIDNewsletterCampaignStatus, type FFIDNewsletterClient, type FFIDNewsletterConfirmParams, type FFIDNewsletterConfirmResponse, type FFIDNewsletterDispatchParams, type FFIDNewsletterDispatchResponse, type FFIDNewsletterSegment, type FFIDNewsletterSubscribeParams, type FFIDNewsletterSubscribeResponse, type FFIDNewsletterType, type FFIDNewsletterUnsubscribeParams, type FFIDNewsletterUnsubscribeResponse, FFIDOAuthUserInfo, FFIDOAuthUserInfoSubscription, FFIDOrganization, type FFIDOrganizationDomain, type FFIDOrganizationDomainsResponse, type FFIDOrganizationMember, type FFIDOrganizationNotificationPreferences, type FFIDOrganizationNotificationPreferencesResponse, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreview, type FFIDPlanChangePreviewResponse, type FFIDPlanInfo, type FFIDPortalSessionResponse, type FFIDPreviewPlanChangeParams, type FFIDPreviewSeatChangeParams, type FFIDProfileCallOptions, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, type FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSDKError, type FFIDSeatChangeLineItem, type FFIDSeatChangePreview, type FFIDSeatChangePreviewResponse, FFIDServiceAccessDecision, type FFIDServiceInfo, FFIDSessionResponse, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, type FFIDSupportedCurrency, type FFIDUpdateMemberRoleResponse, type FFIDUpdateNotificationPreferencesRequest, type FFIDUpdateUserProfileRequest, FFIDUser, type FFIDUserProfile, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_ERROR_CODES, FFID_NEWSLETTER_DISPATCH_MAX_RECIPIENTS, FFID_NEWSLETTER_TYPES, type HandleRedirectCallbackClient, type HandleRedirectCallbackOptions, type KVNamespaceLike, ListAnnouncementsOptions, type NormalizeRedirectUriResult, type RedirectToAuthorizeOptions, type TokenData, type TokenStore, type UseFFIDReturn, type UseRequireActiveSubscriptionOptions, type UseRequireActiveSubscriptionReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, cleanupStateStorage as clearState, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, isBlockedFromUserinfo, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, storeCodeVerifier, storeState, useFFID, useRequireActiveSubscription, useSubscription, withFFIDAuth, withSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -1127,6 +1127,33 @@ interface RedirectToAuthorizeOptions {
|
|
|
1127
1127
|
prompt?: FFIDPrompt;
|
|
1128
1128
|
}
|
|
1129
1129
|
|
|
1130
|
+
/**
|
|
1131
|
+
* FFID SDK error codes
|
|
1132
|
+
*
|
|
1133
|
+
* Codes the SDK itself attaches to `FFIDError.code`. Exported from the
|
|
1134
|
+
* package entry points so consumers can branch on codes (e.g.
|
|
1135
|
+
* `TOKEN_EXPIRED` vs `TOKEN_VERIFICATION_ERROR`) without hardcoding strings.
|
|
1136
|
+
*/
|
|
1137
|
+
/** Error codes used by the SDK */
|
|
1138
|
+
declare const FFID_ERROR_CODES: {
|
|
1139
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
1140
|
+
readonly PARSE_ERROR: "PARSE_ERROR";
|
|
1141
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
1142
|
+
readonly TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR";
|
|
1143
|
+
readonly TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR";
|
|
1144
|
+
readonly NO_TOKENS: "NO_TOKENS";
|
|
1145
|
+
readonly TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR";
|
|
1146
|
+
readonly TOKEN_EXPIRED: "TOKEN_EXPIRED";
|
|
1147
|
+
readonly STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR";
|
|
1148
|
+
};
|
|
1149
|
+
/**
|
|
1150
|
+
* Union of the error code literals the SDK itself produces.
|
|
1151
|
+
*
|
|
1152
|
+
* Note: `FFIDError.code` intentionally stays `string` — server-provided
|
|
1153
|
+
* error codes pass through verbatim and must not be narrowed away.
|
|
1154
|
+
*/
|
|
1155
|
+
type FFIDErrorCode = (typeof FFID_ERROR_CODES)[keyof typeof FFID_ERROR_CODES];
|
|
1156
|
+
|
|
1130
1157
|
/** Creates an FFID API client instance */
|
|
1131
1158
|
declare function createFFIDClient(config: FFIDConfig): {
|
|
1132
1159
|
getSession: () => Promise<FFIDApiResponse<FFIDSessionResponse>>;
|
|
@@ -2040,4 +2067,4 @@ declare function createInquiryMethods(deps: InquiryMethodsDeps): {
|
|
|
2040
2067
|
};
|
|
2041
2068
|
type FFIDInquiryClient = ReturnType<typeof createInquiryMethods>;
|
|
2042
2069
|
|
|
2043
|
-
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, AnnouncementListResponse, BLOCKING_EFFECTIVE_STATUSES, type ComputeEffectiveStatusInput, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EffectiveSubscriptionStatus, type ExchangeCodeForTokensOptions, type FFIDAddMemberParams, type FFIDAddMemberRequest, type FFIDAddMemberResponse, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDAssignableMemberRole, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelPendingDowngradeResponse, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckServiceAccessParams, type FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, type FFIDCreateCheckoutParams, type FFIDCreatePortalParams, FFIDError, type FFIDInquiryClient, FFIDInquiryCreateParams, FFIDInquiryCreateResponse, type FFIDInvitationStatus, type FFIDInviteMemberRequest, type FFIDInviteMemberResponse, type FFIDLeaveOrganizationParams, type FFIDLeaveOrganizationResponse, type FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, type FFIDLoginHistoryEntry, type FFIDLoginHistoryResponse, type FFIDMemberRole, type FFIDMemberStatus, type FFIDNewsletterBodySource, type FFIDNewsletterCampaignStatus, type FFIDNewsletterClient, type FFIDNewsletterConfirmParams, type FFIDNewsletterConfirmResponse, type FFIDNewsletterDispatchParams, type FFIDNewsletterDispatchResponse, type FFIDNewsletterSegment, type FFIDNewsletterSubscribeParams, type FFIDNewsletterSubscribeResponse, type FFIDNewsletterType, type FFIDNewsletterUnsubscribeParams, type FFIDNewsletterUnsubscribeResponse, FFIDOAuthUserInfo, FFIDOAuthUserInfoSubscription, FFIDOrganization, type FFIDOrganizationDomain, type FFIDOrganizationDomainsResponse, type FFIDOrganizationMember, type FFIDOrganizationNotificationPreferences, type FFIDOrganizationNotificationPreferencesResponse, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreview, type FFIDPlanChangePreviewResponse, type FFIDPlanInfo, type FFIDPortalSessionResponse, type FFIDPreviewPlanChangeParams, type FFIDPreviewSeatChangeParams, type FFIDProfileCallOptions, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, type FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSDKError, type FFIDSeatChangeLineItem, type FFIDSeatChangePreview, type FFIDSeatChangePreviewResponse, FFIDServiceAccessDecision, type FFIDServiceInfo, FFIDSessionResponse, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, type FFIDSupportedCurrency, type FFIDUpdateMemberRoleResponse, type FFIDUpdateNotificationPreferencesRequest, type FFIDUpdateUserProfileRequest, FFIDUser, type FFIDUserProfile, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_NEWSLETTER_DISPATCH_MAX_RECIPIENTS, FFID_NEWSLETTER_TYPES, type HandleRedirectCallbackClient, type HandleRedirectCallbackOptions, type KVNamespaceLike, ListAnnouncementsOptions, type NormalizeRedirectUriResult, type RedirectToAuthorizeOptions, type TokenData, type TokenStore, type UseFFIDReturn, type UseRequireActiveSubscriptionOptions, type UseRequireActiveSubscriptionReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, cleanupStateStorage as clearState, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, isBlockedFromUserinfo, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, storeCodeVerifier, storeState, useFFID, useRequireActiveSubscription, useSubscription, withFFIDAuth, withSubscription };
|
|
2070
|
+
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, AnnouncementListResponse, BLOCKING_EFFECTIVE_STATUSES, type ComputeEffectiveStatusInput, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EffectiveSubscriptionStatus, type ExchangeCodeForTokensOptions, type FFIDAddMemberParams, type FFIDAddMemberRequest, type FFIDAddMemberResponse, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDAssignableMemberRole, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelPendingDowngradeResponse, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckServiceAccessParams, type FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, type FFIDCreateCheckoutParams, type FFIDCreatePortalParams, FFIDError, type FFIDErrorCode, type FFIDInquiryClient, FFIDInquiryCreateParams, FFIDInquiryCreateResponse, type FFIDInvitationStatus, type FFIDInviteMemberRequest, type FFIDInviteMemberResponse, type FFIDLeaveOrganizationParams, type FFIDLeaveOrganizationResponse, type FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, type FFIDLoginHistoryEntry, type FFIDLoginHistoryResponse, type FFIDMemberRole, type FFIDMemberStatus, type FFIDNewsletterBodySource, type FFIDNewsletterCampaignStatus, type FFIDNewsletterClient, type FFIDNewsletterConfirmParams, type FFIDNewsletterConfirmResponse, type FFIDNewsletterDispatchParams, type FFIDNewsletterDispatchResponse, type FFIDNewsletterSegment, type FFIDNewsletterSubscribeParams, type FFIDNewsletterSubscribeResponse, type FFIDNewsletterType, type FFIDNewsletterUnsubscribeParams, type FFIDNewsletterUnsubscribeResponse, FFIDOAuthUserInfo, FFIDOAuthUserInfoSubscription, FFIDOrganization, type FFIDOrganizationDomain, type FFIDOrganizationDomainsResponse, type FFIDOrganizationMember, type FFIDOrganizationNotificationPreferences, type FFIDOrganizationNotificationPreferencesResponse, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreview, type FFIDPlanChangePreviewResponse, type FFIDPlanInfo, type FFIDPortalSessionResponse, type FFIDPreviewPlanChangeParams, type FFIDPreviewSeatChangeParams, type FFIDProfileCallOptions, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, type FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSDKError, type FFIDSeatChangeLineItem, type FFIDSeatChangePreview, type FFIDSeatChangePreviewResponse, FFIDServiceAccessDecision, type FFIDServiceInfo, FFIDSessionResponse, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, type FFIDSupportedCurrency, type FFIDUpdateMemberRoleResponse, type FFIDUpdateNotificationPreferencesRequest, type FFIDUpdateUserProfileRequest, FFIDUser, type FFIDUserProfile, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_ERROR_CODES, FFID_NEWSLETTER_DISPATCH_MAX_RECIPIENTS, FFID_NEWSLETTER_TYPES, type HandleRedirectCallbackClient, type HandleRedirectCallbackOptions, type KVNamespaceLike, ListAnnouncementsOptions, type NormalizeRedirectUriResult, type RedirectToAuthorizeOptions, type TokenData, type TokenStore, type UseFFIDReturn, type UseRequireActiveSubscriptionOptions, type UseRequireActiveSubscriptionReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, cleanupStateStorage as clearState, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, isBlockedFromUserinfo, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, storeCodeVerifier, storeState, useFFID, useRequireActiveSubscription, useSubscription, withFFIDAuth, withSubscription };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useFFIDContext, useSubscription } from './chunk-
|
|
2
|
-
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, BLOCKING_EFFECTIVE_STATUSES, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EFFECTIVE_SUBSCRIPTION_STATUSES, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSDKError, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_INQUIRY_CATEGORIES, FFID_INQUIRY_CATEGORIES_SITE_2026, cleanupStateStorage as clearState, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, isBlockedFromUserinfo, isFFIDInquiryCategorySite2026, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, storeCodeVerifier, storeState, useFFID, useFFIDAnnouncements, useSubscription, withSubscription } from './chunk-
|
|
1
|
+
import { useFFIDContext, useSubscription } from './chunk-L2H56C4W.js';
|
|
2
|
+
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, BLOCKING_EFFECTIVE_STATUSES, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EFFECTIVE_SUBSCRIPTION_STATUSES, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSDKError, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_ERROR_CODES, FFID_INQUIRY_CATEGORIES, FFID_INQUIRY_CATEGORIES_SITE_2026, cleanupStateStorage as clearState, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, isBlockedFromUserinfo, isFFIDInquiryCategorySite2026, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, storeCodeVerifier, storeState, useFFID, useFFIDAnnouncements, useSubscription, withSubscription } from './chunk-L2H56C4W.js';
|
|
3
3
|
export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, CONSENT_DISMISSAL_TIMESTAMP_KEY, COOKIE_VERSION, DEFAULT_CONSENT_ERROR_MESSAGES, FFIDAnalyticsProvider, FFIDConsentError, FFIDCookieBanner, FFIDCookieLink, FFIDCookieSettings, FFID_CONSENT_ERROR_CODES, clearConsentDismissalTimestamp, decodeConsentCookie, encodeConsentCookie, readConsentCookie, readConsentDismissalTimestamp, useFFIDConsent, useFFIDConsentPreferences, writeConsentCookie, writeConsentDismissalTimestamp } from './chunk-G7VOX64X.js';
|
|
4
4
|
import { useEffect, useRef } from 'react';
|
|
5
5
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
package/dist/server/index.cjs
CHANGED
|
@@ -225,10 +225,29 @@ function createJwtVerifier(deps) {
|
|
|
225
225
|
return { data: userInfo };
|
|
226
226
|
} catch (error) {
|
|
227
227
|
const message = error instanceof Error ? error.message : "JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F";
|
|
228
|
-
|
|
228
|
+
if (error instanceof jose.errors.JWTExpired) {
|
|
229
|
+
logger.debug("JWT verification failed (token expired):", message);
|
|
230
|
+
return {
|
|
231
|
+
error: createError(
|
|
232
|
+
errorCodes.TOKEN_EXPIRED,
|
|
233
|
+
"\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u306E\u6709\u52B9\u671F\u9650\u304C\u5207\u308C\u3066\u3044\u307E\u3059"
|
|
234
|
+
)
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const isTokenLevelError = error instanceof jose.errors.JWTClaimValidationFailed || error instanceof jose.errors.JWTInvalid || error instanceof jose.errors.JWSInvalid || error instanceof jose.errors.JWSSignatureVerificationFailed || error instanceof jose.errors.JOSEAlgNotAllowed || error instanceof jose.errors.JOSENotSupported || error instanceof jose.errors.JWKSNoMatchingKey || error instanceof jose.errors.JWKSMultipleMatchingKeys;
|
|
238
|
+
if (isTokenLevelError) {
|
|
239
|
+
logger.warn("JWT verification failed:", message);
|
|
240
|
+
return {
|
|
241
|
+
error: createError(
|
|
242
|
+
errorCodes.TOKEN_VERIFICATION_ERROR,
|
|
243
|
+
`JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
|
|
244
|
+
)
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
logger.error("JWT verification failed (JWKS fetch):", message);
|
|
229
248
|
return {
|
|
230
249
|
error: createError(
|
|
231
|
-
errorCodes.
|
|
250
|
+
errorCodes.NETWORK_ERROR,
|
|
232
251
|
`JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
|
|
233
252
|
)
|
|
234
253
|
};
|
|
@@ -253,7 +272,9 @@ function createVerifyAccessToken(deps) {
|
|
|
253
272
|
serviceCode,
|
|
254
273
|
logger,
|
|
255
274
|
createError,
|
|
256
|
-
|
|
275
|
+
// structural superset of JwtVerifierDeps.errorCodes — passing it
|
|
276
|
+
// wholesale removes the hand-transcription drift point
|
|
277
|
+
errorCodes
|
|
257
278
|
});
|
|
258
279
|
}
|
|
259
280
|
return jwtVerify2;
|
|
@@ -1093,7 +1114,7 @@ function createNonContractMethods(deps) {
|
|
|
1093
1114
|
}
|
|
1094
1115
|
|
|
1095
1116
|
// src/client/version-check.ts
|
|
1096
|
-
var SDK_VERSION = "5.
|
|
1117
|
+
var SDK_VERSION = "5.18.0";
|
|
1097
1118
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
1098
1119
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
1099
1120
|
function sdkHeaders() {
|
|
@@ -2520,6 +2541,19 @@ var BLOCKING_EFFECTIVE_STATUSES = [
|
|
|
2520
2541
|
"trial_expired"
|
|
2521
2542
|
];
|
|
2522
2543
|
|
|
2544
|
+
// src/client/error-codes.ts
|
|
2545
|
+
var FFID_ERROR_CODES = {
|
|
2546
|
+
NETWORK_ERROR: "NETWORK_ERROR",
|
|
2547
|
+
PARSE_ERROR: "PARSE_ERROR",
|
|
2548
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
2549
|
+
TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
|
|
2550
|
+
TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
|
|
2551
|
+
NO_TOKENS: "NO_TOKENS",
|
|
2552
|
+
TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
|
|
2553
|
+
TOKEN_EXPIRED: "TOKEN_EXPIRED",
|
|
2554
|
+
STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
|
|
2555
|
+
};
|
|
2556
|
+
|
|
2523
2557
|
// src/client/ffid-client.ts
|
|
2524
2558
|
var UNAUTHORIZED_STATUS2 = 401;
|
|
2525
2559
|
var SDK_LOG_PREFIX = "[FFID SDK]";
|
|
@@ -2528,8 +2562,10 @@ var noopLogger = {
|
|
|
2528
2562
|
},
|
|
2529
2563
|
info: () => {
|
|
2530
2564
|
},
|
|
2531
|
-
warn: (
|
|
2532
|
-
|
|
2565
|
+
warn: () => {
|
|
2566
|
+
},
|
|
2567
|
+
error: () => {
|
|
2568
|
+
}
|
|
2533
2569
|
};
|
|
2534
2570
|
var consoleLogger = {
|
|
2535
2571
|
debug: (...args) => console.debug(SDK_LOG_PREFIX, ...args),
|
|
@@ -2537,16 +2573,6 @@ var consoleLogger = {
|
|
|
2537
2573
|
warn: (...args) => console.warn(SDK_LOG_PREFIX, ...args),
|
|
2538
2574
|
error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
|
|
2539
2575
|
};
|
|
2540
|
-
var FFID_ERROR_CODES = {
|
|
2541
|
-
NETWORK_ERROR: "NETWORK_ERROR",
|
|
2542
|
-
PARSE_ERROR: "PARSE_ERROR",
|
|
2543
|
-
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
2544
|
-
TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
|
|
2545
|
-
TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
|
|
2546
|
-
NO_TOKENS: "NO_TOKENS",
|
|
2547
|
-
TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
|
|
2548
|
-
STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
|
|
2549
|
-
};
|
|
2550
2576
|
var EXT_CHECK_ENDPOINT = "/api/v1/subscriptions/ext/check";
|
|
2551
2577
|
var DEFAULT_ALLOW_GRACE = true;
|
|
2552
2578
|
var DEFAULT_SERVICE_ACCESS_FAIL_POLICY = "failClosed";
|
|
@@ -3227,6 +3253,7 @@ Object.defineProperty(exports, "DEFAULT_OAUTH_SCOPES", {
|
|
|
3227
3253
|
exports.ALL_DENIED_EXCEPT_NECESSARY = ALL_DENIED_EXCEPT_NECESSARY;
|
|
3228
3254
|
exports.CONSENT_COOKIE_NAME = CONSENT_COOKIE_NAME;
|
|
3229
3255
|
exports.COOKIE_VERSION = COOKIE_VERSION;
|
|
3256
|
+
exports.FFID_ERROR_CODES = FFID_ERROR_CODES;
|
|
3230
3257
|
exports.createFFIDClient = createFFIDClient;
|
|
3231
3258
|
exports.createKVCacheAdapter = createKVCacheAdapter;
|
|
3232
3259
|
exports.createMemoryCacheAdapter = createMemoryCacheAdapter;
|
package/dist/server/index.d.cts
CHANGED
|
@@ -4,6 +4,33 @@ export { D as DEFAULT_API_BASE_URL, a as DEFAULT_OAUTH_SCOPES } from '../constan
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import '../types-BeVl-z12.cjs';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* FFID SDK error codes
|
|
9
|
+
*
|
|
10
|
+
* Codes the SDK itself attaches to `FFIDError.code`. Exported from the
|
|
11
|
+
* package entry points so consumers can branch on codes (e.g.
|
|
12
|
+
* `TOKEN_EXPIRED` vs `TOKEN_VERIFICATION_ERROR`) without hardcoding strings.
|
|
13
|
+
*/
|
|
14
|
+
/** Error codes used by the SDK */
|
|
15
|
+
declare const FFID_ERROR_CODES: {
|
|
16
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
17
|
+
readonly PARSE_ERROR: "PARSE_ERROR";
|
|
18
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
19
|
+
readonly TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR";
|
|
20
|
+
readonly TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR";
|
|
21
|
+
readonly NO_TOKENS: "NO_TOKENS";
|
|
22
|
+
readonly TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR";
|
|
23
|
+
readonly TOKEN_EXPIRED: "TOKEN_EXPIRED";
|
|
24
|
+
readonly STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Union of the error code literals the SDK itself produces.
|
|
28
|
+
*
|
|
29
|
+
* Note: `FFIDError.code` intentionally stays `string` — server-provided
|
|
30
|
+
* error codes pass through verbatim and must not be narrowed away.
|
|
31
|
+
*/
|
|
32
|
+
type FFIDErrorCode = (typeof FFID_ERROR_CODES)[keyof typeof FFID_ERROR_CODES];
|
|
33
|
+
|
|
7
34
|
/** Token verification - verifyAccessToken() implementation */
|
|
8
35
|
|
|
9
36
|
/** Dependencies required by verifyAccessToken */
|
|
@@ -16,9 +43,10 @@ interface VerifyAccessTokenDeps {
|
|
|
16
43
|
logger: FFIDLogger;
|
|
17
44
|
createError: (code: string, message: string) => FFIDError;
|
|
18
45
|
errorCodes: {
|
|
19
|
-
NETWORK_ERROR:
|
|
20
|
-
PARSE_ERROR:
|
|
21
|
-
TOKEN_VERIFICATION_ERROR:
|
|
46
|
+
NETWORK_ERROR: 'NETWORK_ERROR';
|
|
47
|
+
PARSE_ERROR: 'PARSE_ERROR';
|
|
48
|
+
TOKEN_VERIFICATION_ERROR: 'TOKEN_VERIFICATION_ERROR';
|
|
49
|
+
TOKEN_EXPIRED: 'TOKEN_EXPIRED';
|
|
22
50
|
};
|
|
23
51
|
cache?: {
|
|
24
52
|
adapter: FFIDCacheAdapter;
|
|
@@ -205,4 +233,4 @@ declare function decodeConsentCookie(raw: string | null | undefined): FFIDConsen
|
|
|
205
233
|
|
|
206
234
|
declare const CONSENT_COOKIE_NAME = "ffid_consent";
|
|
207
235
|
|
|
208
|
-
export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, FFIDCacheAdapter, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, FFIDOAuthUserInfo, FFIDVerifyAccessTokenOptions, type KVNamespaceLike, createKVCacheAdapter, createMemoryCacheAdapter, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };
|
|
236
|
+
export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, FFIDCacheAdapter, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, type FFIDErrorCode, FFIDOAuthUserInfo, FFIDVerifyAccessTokenOptions, FFID_ERROR_CODES, type KVNamespaceLike, createKVCacheAdapter, createMemoryCacheAdapter, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -4,6 +4,33 @@ export { D as DEFAULT_API_BASE_URL, a as DEFAULT_OAUTH_SCOPES } from '../constan
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import '../types-BeVl-z12.js';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* FFID SDK error codes
|
|
9
|
+
*
|
|
10
|
+
* Codes the SDK itself attaches to `FFIDError.code`. Exported from the
|
|
11
|
+
* package entry points so consumers can branch on codes (e.g.
|
|
12
|
+
* `TOKEN_EXPIRED` vs `TOKEN_VERIFICATION_ERROR`) without hardcoding strings.
|
|
13
|
+
*/
|
|
14
|
+
/** Error codes used by the SDK */
|
|
15
|
+
declare const FFID_ERROR_CODES: {
|
|
16
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
17
|
+
readonly PARSE_ERROR: "PARSE_ERROR";
|
|
18
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
19
|
+
readonly TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR";
|
|
20
|
+
readonly TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR";
|
|
21
|
+
readonly NO_TOKENS: "NO_TOKENS";
|
|
22
|
+
readonly TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR";
|
|
23
|
+
readonly TOKEN_EXPIRED: "TOKEN_EXPIRED";
|
|
24
|
+
readonly STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Union of the error code literals the SDK itself produces.
|
|
28
|
+
*
|
|
29
|
+
* Note: `FFIDError.code` intentionally stays `string` — server-provided
|
|
30
|
+
* error codes pass through verbatim and must not be narrowed away.
|
|
31
|
+
*/
|
|
32
|
+
type FFIDErrorCode = (typeof FFID_ERROR_CODES)[keyof typeof FFID_ERROR_CODES];
|
|
33
|
+
|
|
7
34
|
/** Token verification - verifyAccessToken() implementation */
|
|
8
35
|
|
|
9
36
|
/** Dependencies required by verifyAccessToken */
|
|
@@ -16,9 +43,10 @@ interface VerifyAccessTokenDeps {
|
|
|
16
43
|
logger: FFIDLogger;
|
|
17
44
|
createError: (code: string, message: string) => FFIDError;
|
|
18
45
|
errorCodes: {
|
|
19
|
-
NETWORK_ERROR:
|
|
20
|
-
PARSE_ERROR:
|
|
21
|
-
TOKEN_VERIFICATION_ERROR:
|
|
46
|
+
NETWORK_ERROR: 'NETWORK_ERROR';
|
|
47
|
+
PARSE_ERROR: 'PARSE_ERROR';
|
|
48
|
+
TOKEN_VERIFICATION_ERROR: 'TOKEN_VERIFICATION_ERROR';
|
|
49
|
+
TOKEN_EXPIRED: 'TOKEN_EXPIRED';
|
|
22
50
|
};
|
|
23
51
|
cache?: {
|
|
24
52
|
adapter: FFIDCacheAdapter;
|
|
@@ -205,4 +233,4 @@ declare function decodeConsentCookie(raw: string | null | undefined): FFIDConsen
|
|
|
205
233
|
|
|
206
234
|
declare const CONSENT_COOKIE_NAME = "ffid_consent";
|
|
207
235
|
|
|
208
|
-
export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, FFIDCacheAdapter, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, FFIDOAuthUserInfo, FFIDVerifyAccessTokenOptions, type KVNamespaceLike, createKVCacheAdapter, createMemoryCacheAdapter, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };
|
|
236
|
+
export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, FFIDCacheAdapter, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, type FFIDErrorCode, FFIDOAuthUserInfo, FFIDVerifyAccessTokenOptions, FFID_ERROR_CODES, type KVNamespaceLike, createKVCacheAdapter, createMemoryCacheAdapter, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };
|
package/dist/server/index.js
CHANGED
|
@@ -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";
|
|
@@ -224,10 +224,29 @@ function createJwtVerifier(deps) {
|
|
|
224
224
|
return { data: userInfo };
|
|
225
225
|
} catch (error) {
|
|
226
226
|
const message = error instanceof Error ? error.message : "JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F";
|
|
227
|
-
|
|
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);
|
|
228
247
|
return {
|
|
229
248
|
error: createError(
|
|
230
|
-
errorCodes.
|
|
249
|
+
errorCodes.NETWORK_ERROR,
|
|
231
250
|
`JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
|
|
232
251
|
)
|
|
233
252
|
};
|
|
@@ -252,7 +271,9 @@ function createVerifyAccessToken(deps) {
|
|
|
252
271
|
serviceCode,
|
|
253
272
|
logger,
|
|
254
273
|
createError,
|
|
255
|
-
|
|
274
|
+
// structural superset of JwtVerifierDeps.errorCodes — passing it
|
|
275
|
+
// wholesale removes the hand-transcription drift point
|
|
276
|
+
errorCodes
|
|
256
277
|
});
|
|
257
278
|
}
|
|
258
279
|
return jwtVerify2;
|
|
@@ -1092,7 +1113,7 @@ function createNonContractMethods(deps) {
|
|
|
1092
1113
|
}
|
|
1093
1114
|
|
|
1094
1115
|
// src/client/version-check.ts
|
|
1095
|
-
var SDK_VERSION = "5.
|
|
1116
|
+
var SDK_VERSION = "5.18.0";
|
|
1096
1117
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
1097
1118
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
1098
1119
|
function sdkHeaders() {
|
|
@@ -2519,6 +2540,19 @@ var BLOCKING_EFFECTIVE_STATUSES = [
|
|
|
2519
2540
|
"trial_expired"
|
|
2520
2541
|
];
|
|
2521
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
|
+
|
|
2522
2556
|
// src/client/ffid-client.ts
|
|
2523
2557
|
var UNAUTHORIZED_STATUS2 = 401;
|
|
2524
2558
|
var SDK_LOG_PREFIX = "[FFID SDK]";
|
|
@@ -2527,8 +2561,10 @@ var noopLogger = {
|
|
|
2527
2561
|
},
|
|
2528
2562
|
info: () => {
|
|
2529
2563
|
},
|
|
2530
|
-
warn: (
|
|
2531
|
-
|
|
2564
|
+
warn: () => {
|
|
2565
|
+
},
|
|
2566
|
+
error: () => {
|
|
2567
|
+
}
|
|
2532
2568
|
};
|
|
2533
2569
|
var consoleLogger = {
|
|
2534
2570
|
debug: (...args) => console.debug(SDK_LOG_PREFIX, ...args),
|
|
@@ -2536,16 +2572,6 @@ var consoleLogger = {
|
|
|
2536
2572
|
warn: (...args) => console.warn(SDK_LOG_PREFIX, ...args),
|
|
2537
2573
|
error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
|
|
2538
2574
|
};
|
|
2539
|
-
var FFID_ERROR_CODES = {
|
|
2540
|
-
NETWORK_ERROR: "NETWORK_ERROR",
|
|
2541
|
-
PARSE_ERROR: "PARSE_ERROR",
|
|
2542
|
-
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
2543
|
-
TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
|
|
2544
|
-
TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
|
|
2545
|
-
NO_TOKENS: "NO_TOKENS",
|
|
2546
|
-
TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
|
|
2547
|
-
STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
|
|
2548
|
-
};
|
|
2549
2575
|
var EXT_CHECK_ENDPOINT = "/api/v1/subscriptions/ext/check";
|
|
2550
2576
|
var DEFAULT_ALLOW_GRACE = true;
|
|
2551
2577
|
var DEFAULT_SERVICE_ACCESS_FAIL_POLICY = "failClosed";
|
|
@@ -3215,4 +3241,4 @@ function getFFIDConsentFromCookieHeader(cookieHeader) {
|
|
|
3215
3241
|
return decodeConsentCookie(decodeURIComponent(value));
|
|
3216
3242
|
}
|
|
3217
3243
|
|
|
3218
|
-
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 };
|