@feelflow/ffid-sdk 5.24.2 → 5.25.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-Q7ZEF3EN.js → chunk-HIKX4AVY.js} +68 -33
- package/dist/{chunk-QMWUOVZK.cjs → chunk-ZFKXOTFF.cjs} +68 -33
- package/dist/components/index.cjs +8 -8
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/{ffid-client-D0Jh4bO7.d.cts → ffid-client-BZERrMAF.d.cts} +133 -82
- package/dist/{ffid-client-DX2PTTFr.d.ts → ffid-client-CFZPX5ej.d.ts} +133 -82
- package/dist/{index-GqflEaKi.d.cts → index-Dd6CMIBd.d.cts} +90 -92
- package/dist/{index-GqflEaKi.d.ts → index-Dd6CMIBd.d.ts} +90 -92
- package/dist/index.cjs +42 -42
- package/dist/index.d.cts +123 -45
- package/dist/index.d.ts +123 -45
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +58 -51
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +58 -51
- package/dist/server/test/index.d.cts +1 -1
- package/dist/server/test/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FFIDSubscriptionStatus, a as
|
|
2
|
-
export {
|
|
1
|
+
import { F as FFIDSubscriptionStatus, a as FFIDOAuthUserInfoSubscription, b as FFIDPrompt, c as FFIDConfig, d as FFIDApiResponse, e as FFIDSessionResponse, f as FFIDSignOutResult, g as FFIDError, h as FFIDSubscriptionCheckResponse, i as FFIDCheckServiceAccessParams, j as FFIDServiceAccessDecision, k as FFIDAnalyticsConfig, l as FFIDVerifyAccessTokenOptions, m as FFIDOAuthUserInfo, n as FFIDInquiryCreateParams, o as FFIDInquiryCreateResponse, T as TokenStore, p as FFIDAuthMode, q as FFIDLogger, r as FFIDCacheAdapter, s as FFIDUser, t as FFIDOrganization, u as FFIDSubscription, v as FFIDSubscriptionContextValue, E as EffectiveSubscriptionStatus, w as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, x as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, y as FFIDAnnouncementsLogger } from './index-Dd6CMIBd.js';
|
|
2
|
+
export { z as Announcement, B as AnnouncementStatus, C as AnnouncementType, D as EFFECTIVE_SUBSCRIPTION_STATUSES, G as FFIDAnnouncementBadge, H as FFIDAnnouncementList, I as FFIDAnnouncementsError, J as FFIDAnnouncementsErrorCode, K as FFIDAnnouncementsServerResponse, M as FFIDApiResponseMeta, N as FFIDCacheConfig, O as FFIDContextValue, P as FFIDInquiryCategory, Q as FFIDInquiryCategorySite2026, R as FFIDInquiryForm, S as FFIDInquiryFormCategoryItem, U as FFIDInquiryFormClassNames, V as FFIDInquiryFormLegalLayout, W as FFIDInquiryFormOrganization, X as FFIDInquiryFormPlaceholderContext, Y as FFIDInquiryFormPrefill, Z as FFIDInquiryFormProps, _ as FFIDInquiryFormSubmitData, $ as FFIDInquiryFormSubmitResult, a0 as FFIDJwtClaims, a1 as FFIDLoginButton, a2 as FFIDOAuthUserInfoMemberRole, a3 as FFIDOrganizationSwitcher, a4 as FFIDSeatModel, a5 as FFIDServiceAccessDenialReason, a6 as FFIDServiceAccessFailPolicy, a7 as FFIDSubscriptionBadge, a8 as FFIDUserMenu, a9 as FFID_INQUIRY_CATEGORIES, aa as FFID_INQUIRY_CATEGORIES_SITE_2026, ab as TokenData, ac as UseFFIDAnnouncementsOptions, ad as UseFFIDAnnouncementsReturn, ae as createTokenStore, af as isFFIDInquiryCategorySite2026, ag as useFFIDAnnouncements } from './index-Dd6CMIBd.js';
|
|
3
3
|
export { A as ALL_DENIED_EXCEPT_NECESSARY, i as CONSENT_COOKIE_NAME, j as CONSENT_DISMISSAL_TIMESTAMP_KEY, l as COOKIE_VERSION, D as DEFAULT_CONSENT_ERROR_MESSAGES, o as FFIDAnalyticsProvider, p as FFIDAnalyticsProviderProps, c as FFIDConsentCategories, r as FFIDConsentCategoryCode, e as FFIDConsentCategoryMetadata, w as FFIDConsentError, x as FFIDConsentErrorCode, y as FFIDConsentMergeStrategy, B as FFIDConsentMergeWarning, E as FFIDConsentMergeWarningEvent, F as FFIDConsentResult, I as FFIDConsentSource, a as FFIDConsentState, d as FFIDConsentSyncResult, M as FFIDCookieBanner, N as FFIDCookieBannerClassNames, O as FFIDCookieBannerProps, Q as FFIDCookieLink, R as FFIDCookieLinkProps, f as FFIDCookiePolicy, T as FFIDCookieSettings, U as FFIDCookieSettingsClassNames, V as FFIDCookieSettingsProps, _ as FFID_CONSENT_ERROR_CODES, ae as UseFFIDConsentPreferencesReturn, af as UseFFIDConsentReturn, ag as clearConsentDismissalTimestamp, aj as decodeConsentCookie, al as encodeConsentCookie, an as readConsentCookie, ao as readConsentDismissalTimestamp, aq as useFFIDConsent, ar as useFFIDConsentPreferences, as as writeConsentCookie, at as writeConsentDismissalTimestamp } from './FFIDCookieLink-BJgVcJyw.js';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import { ReactNode, ComponentType, FC } from 'react';
|
|
@@ -39,47 +39,6 @@ declare const DEFAULT_API_BASE_URL = "https://id.feelflow.net";
|
|
|
39
39
|
*/
|
|
40
40
|
declare const DEFAULT_OAUTH_SCOPES = "openid email profile subscription:read legal:read";
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* Token Store
|
|
44
|
-
*
|
|
45
|
-
* Manages OAuth 2.0 tokens (access + refresh) with dual-storage support.
|
|
46
|
-
* Falls back to in-memory storage when localStorage is unavailable
|
|
47
|
-
* (e.g., Safari private browsing mode).
|
|
48
|
-
*/
|
|
49
|
-
/**
|
|
50
|
-
* Token data stored by the token store
|
|
51
|
-
*/
|
|
52
|
-
interface TokenData {
|
|
53
|
-
/** OAuth 2.0 access token */
|
|
54
|
-
accessToken: string;
|
|
55
|
-
/** OAuth 2.0 refresh token */
|
|
56
|
-
refreshToken: string;
|
|
57
|
-
/** Expiration timestamp in milliseconds (Unix epoch) */
|
|
58
|
-
expiresAt: number;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Token store interface for managing OAuth tokens
|
|
62
|
-
*/
|
|
63
|
-
interface TokenStore {
|
|
64
|
-
/** Get stored tokens (null if not stored) */
|
|
65
|
-
getTokens(): TokenData | null;
|
|
66
|
-
/** Store new tokens */
|
|
67
|
-
setTokens(tokens: TokenData): void;
|
|
68
|
-
/** Clear all stored tokens */
|
|
69
|
-
clearTokens(): void;
|
|
70
|
-
/** Check if access token is expired (with 30s buffer) */
|
|
71
|
-
isAccessTokenExpired(): boolean;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Create a token store with the specified storage type.
|
|
75
|
-
*
|
|
76
|
-
* When storageType is 'localStorage' (default in browser), falls back
|
|
77
|
-
* to memory if localStorage is not available (e.g., Safari private mode).
|
|
78
|
-
*
|
|
79
|
-
* @param storageType - 'localStorage' (default) or 'memory'
|
|
80
|
-
*/
|
|
81
|
-
declare function createTokenStore(storageType?: 'localStorage' | 'memory'): TokenStore;
|
|
82
|
-
|
|
83
42
|
/**
|
|
84
43
|
* Generate a random code verifier (43-128 characters, RFC 7636 Section 4.1).
|
|
85
44
|
*
|
|
@@ -1192,6 +1151,112 @@ interface FFIDUpdateUserProfileRequest {
|
|
|
1192
1151
|
preferences?: Record<string, unknown> | null;
|
|
1193
1152
|
}
|
|
1194
1153
|
|
|
1154
|
+
/**
|
|
1155
|
+
* OAuth flow types: client-side redirect results and OAuth token / RFC 7662
|
|
1156
|
+
* introspection payloads.
|
|
1157
|
+
*
|
|
1158
|
+
* Extracted from `types/index.ts` to keep that barrel under the 800-line hard
|
|
1159
|
+
* limit (`scripts/check-file-size.sh`). Re-exported from `types/index.ts`, so
|
|
1160
|
+
* the public API is unchanged — import from `@feelflow/ffid-sdk` as before.
|
|
1161
|
+
*/
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* Discriminant for redirect failures that callers need to handle
|
|
1165
|
+
* programmatically (vs. logging the human-readable `error` string).
|
|
1166
|
+
*
|
|
1167
|
+
* - `'redirect_loop_detected'`: `redirectToAuthorize()` detected that the
|
|
1168
|
+
* same authorize URL (keyed by `baseUrl + client_id + organization_id`)
|
|
1169
|
+
* has been fired **3 times within 60 seconds**. Caller should surface a
|
|
1170
|
+
* manual "再度ログインする" UI rather than retry automatically (#2406 / #2411).
|
|
1171
|
+
*
|
|
1172
|
+
* - `'state_persistence_failed'`: `redirectToAuthorize()` could not persist
|
|
1173
|
+
* the OAuth CSRF `state` (storage unavailable / quota). Redirect is aborted
|
|
1174
|
+
* fail-closed (#4136) — callers should surface a manual retry UI.
|
|
1175
|
+
*
|
|
1176
|
+
* Other failure paths (SSR environment, PKCE generation failure, empty
|
|
1177
|
+
* organizationId) currently return `error` without a `code`. Treat this union
|
|
1178
|
+
* as forward-extensible and do NOT exhaustively `switch` over it without a
|
|
1179
|
+
* `default` branch for consumer code that must stay compatible across SDK
|
|
1180
|
+
* upgrades.
|
|
1181
|
+
*/
|
|
1182
|
+
type FFIDRedirectErrorCode = 'redirect_loop_detected' | 'state_persistence_failed';
|
|
1183
|
+
/**
|
|
1184
|
+
* Result of a redirect operation (redirectToLogin / redirectToAuthorize / redirectToLogout)
|
|
1185
|
+
*
|
|
1186
|
+
* Structured return type so callers can inspect failure reasons
|
|
1187
|
+
* instead of receiving a bare `false`. When `code` is set, branch on it
|
|
1188
|
+
* for programmatic handling; otherwise log `error` for humans.
|
|
1189
|
+
*
|
|
1190
|
+
* `loopDetectionDisabled` (#4119): set to `true` when sessionStorage is
|
|
1191
|
+
* unavailable (iOS WebKit private mode / eviction) so redirect-loop detection
|
|
1192
|
+
* ran **fail-open** — the redirect fired, but repeated-redirect protection is
|
|
1193
|
+
* disabled for this browser session. Callers that need loop protection on
|
|
1194
|
+
* such browsers should add their own max-retry guard.
|
|
1195
|
+
*/
|
|
1196
|
+
type FFIDRedirectResult = {
|
|
1197
|
+
success: true;
|
|
1198
|
+
loopDetectionDisabled?: boolean;
|
|
1199
|
+
} | {
|
|
1200
|
+
success: false;
|
|
1201
|
+
error: string;
|
|
1202
|
+
code?: FFIDRedirectErrorCode;
|
|
1203
|
+
};
|
|
1204
|
+
/**
|
|
1205
|
+
* OAuth 2.0 token response from FFID token endpoint
|
|
1206
|
+
*/
|
|
1207
|
+
interface FFIDOAuthTokenResponse {
|
|
1208
|
+
access_token: string;
|
|
1209
|
+
token_type: 'Bearer';
|
|
1210
|
+
expires_in: number;
|
|
1211
|
+
refresh_token: string;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* RFC 7662 Token Introspection response (raw format from server)
|
|
1215
|
+
*
|
|
1216
|
+
* Used internally by verifyAccessToken(). Consumers receive the normalized
|
|
1217
|
+
* FFIDOAuthUserInfo type instead.
|
|
1218
|
+
*
|
|
1219
|
+
* @see https://tools.ietf.org/html/rfc7662
|
|
1220
|
+
*/
|
|
1221
|
+
interface FFIDTokenIntrospectionResponse {
|
|
1222
|
+
active: boolean;
|
|
1223
|
+
sub?: string;
|
|
1224
|
+
email?: string;
|
|
1225
|
+
/** Whether the user's email is verified (#3791). Optional for backward compat with older FFID. */
|
|
1226
|
+
email_verified?: boolean;
|
|
1227
|
+
name?: string;
|
|
1228
|
+
picture?: string | null;
|
|
1229
|
+
company_name?: string | null;
|
|
1230
|
+
department?: string | null;
|
|
1231
|
+
position?: string | null;
|
|
1232
|
+
phone_number?: string | null;
|
|
1233
|
+
scope?: string | null;
|
|
1234
|
+
exp?: number;
|
|
1235
|
+
iat?: number;
|
|
1236
|
+
iss?: string;
|
|
1237
|
+
token_type?: 'Bearer';
|
|
1238
|
+
client_id?: string;
|
|
1239
|
+
organization_id?: string | null;
|
|
1240
|
+
organization_name?: string | null;
|
|
1241
|
+
subscription?: {
|
|
1242
|
+
subscription_id: string | null;
|
|
1243
|
+
status: FFIDOAuthUserInfoSubscription['status'];
|
|
1244
|
+
/** Optional for backward compat with older FFID (< 5.3.0 / #3353). */
|
|
1245
|
+
effective_status?: FFIDOAuthUserInfoSubscription['effectiveStatus'];
|
|
1246
|
+
plan_code: string | null;
|
|
1247
|
+
seat_model: FFIDOAuthUserInfoSubscription['seatModel'];
|
|
1248
|
+
member_role: FFIDOAuthUserInfoSubscription['memberRole'];
|
|
1249
|
+
organization_id: string | null;
|
|
1250
|
+
organization_name?: string | null;
|
|
1251
|
+
has_seat_assignment?: boolean;
|
|
1252
|
+
/**
|
|
1253
|
+
* Optional for backward compat with older FFID (< #4333), and omitted when
|
|
1254
|
+
* the service API key has `token:introspect` without `subscription:read`.
|
|
1255
|
+
*/
|
|
1256
|
+
entitlements?: readonly string[];
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1195
1260
|
/** OTP / magic link methods - sendOtp / verifyOtp */
|
|
1196
1261
|
|
|
1197
1262
|
/** Response from sendOtp */
|
|
@@ -1478,6 +1543,11 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
1478
1543
|
};
|
|
1479
1544
|
/** Token store (token mode only) */
|
|
1480
1545
|
tokenStore: TokenStore;
|
|
1546
|
+
/**
|
|
1547
|
+
* Return the currently-valid access token, or null (token mode only; #4318).
|
|
1548
|
+
* Live-reads the store and applies the 30s expiry buffer.
|
|
1549
|
+
*/
|
|
1550
|
+
getAccessToken: () => string | null;
|
|
1481
1551
|
/** Resolved auth mode */
|
|
1482
1552
|
authMode: FFIDAuthMode;
|
|
1483
1553
|
/** Resolved logger instance */
|
|
@@ -1643,7 +1713,7 @@ interface FFIDProviderProps extends FFIDConfig {
|
|
|
1643
1713
|
* - Automatic session refresh
|
|
1644
1714
|
* - Token mode: automatic code exchange and token refresh
|
|
1645
1715
|
*/
|
|
1646
|
-
declare function FFIDProvider({ children, serviceCode, scope, apiBaseUrl, debug, logger, refreshInterval, onAuthStateChange, onError, authMode, clientId, timeout, cleanCallbackUrl, }: FFIDProviderProps): react_jsx_runtime.JSX.Element;
|
|
1716
|
+
declare function FFIDProvider({ children, serviceCode, scope, apiBaseUrl, debug, logger, refreshInterval, onAuthStateChange, onError, authMode, clientId, timeout, tokenStore, cleanCallbackUrl, }: FFIDProviderProps): react_jsx_runtime.JSX.Element;
|
|
1647
1717
|
|
|
1648
1718
|
/**
|
|
1649
1719
|
* Return type for useFFID hook
|
|
@@ -1707,6 +1777,14 @@ interface UseFFIDReturn {
|
|
|
1707
1777
|
switchOrganization: (organizationId: string) => void;
|
|
1708
1778
|
/** Refresh session data */
|
|
1709
1779
|
refresh: () => Promise<void>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Token mode: return the currently-valid access token, or `null` when there is
|
|
1782
|
+
* none or it is expired (30s buffer). Live-reads the shared token store on each
|
|
1783
|
+
* call, so a token refreshed in the background — or cleared on logout — is
|
|
1784
|
+
* reflected without the host caching or polling it. Always `null` in
|
|
1785
|
+
* cookie / service-key mode. Stable function reference (#4318).
|
|
1786
|
+
*/
|
|
1787
|
+
getAccessToken: () => string | null;
|
|
1710
1788
|
/** Get login URL with redirect parameter */
|
|
1711
1789
|
getLoginUrl: (redirectUrl?: string) => string;
|
|
1712
1790
|
/** Get signup URL with redirect parameter */
|
|
@@ -2316,4 +2394,4 @@ declare function createInquiryMethods(deps: InquiryMethodsDeps): {
|
|
|
2316
2394
|
};
|
|
2317
2395
|
type FFIDInquiryClient = ReturnType<typeof createInquiryMethods>;
|
|
2318
2396
|
|
|
2319
|
-
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, type FFIDProvisionMemberPlan, type FFIDProvisionMemberPlanStatus, type FFIDProvisionMemberResult, type FFIDProvisionMemberStatus, type FFIDProvisionOrganizationDryRun, type FFIDProvisionOrganizationMemberInput, type FFIDProvisionOrganizationOutcome, type FFIDProvisionOrganizationParams, type FFIDProvisionOrganizationResponse, type FFIDProvisionUserDryRun, type FFIDProvisionUserOutcome, type FFIDProvisionUserParams, type FFIDProvisionUserProfileInput, type FFIDProvisionUserResponse, type FFIDProvisionedOrganization, type FFIDProvisionedUser, FFIDRedirectResult, type FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSDKError, type FFIDSeatChangeLineItem, type FFIDSeatChangePreview, type FFIDSeatChangePreviewResponse, FFIDServiceAccessDecision, type FFIDServiceInfo, FFIDSessionResponse, FFIDSignOutResult, 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,
|
|
2397
|
+
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, type FFIDOAuthTokenResponse, 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, type FFIDProvisionMemberPlan, type FFIDProvisionMemberPlanStatus, type FFIDProvisionMemberResult, type FFIDProvisionMemberStatus, type FFIDProvisionOrganizationDryRun, type FFIDProvisionOrganizationMemberInput, type FFIDProvisionOrganizationOutcome, type FFIDProvisionOrganizationParams, type FFIDProvisionOrganizationResponse, type FFIDProvisionUserDryRun, type FFIDProvisionUserOutcome, type FFIDProvisionUserParams, type FFIDProvisionUserProfileInput, type FFIDProvisionUserResponse, type FFIDProvisionedOrganization, type FFIDProvisionedUser, type FFIDRedirectErrorCode, type FFIDRedirectResult, type FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSDKError, type FFIDSeatChangeLineItem, type FFIDSeatChangePreview, type FFIDSeatChangePreviewResponse, FFIDServiceAccessDecision, type FFIDServiceInfo, FFIDSessionResponse, FFIDSignOutResult, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, type FFIDSupportedCurrency, type FFIDTokenIntrospectionResponse, 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, TokenStore, type UseFFIDReturn, type UseRequireActiveSubscriptionOptions, type UseRequireActiveSubscriptionReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, cleanupStateStorage as clearState, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, 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_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-HIKX4AVY.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-HIKX4AVY.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
|
@@ -111,6 +111,14 @@ function isSessionEligibleSubscriptionStatus(value) {
|
|
|
111
111
|
function hasOwnKey(value, key) {
|
|
112
112
|
return Object.prototype.hasOwnProperty.call(value, key);
|
|
113
113
|
}
|
|
114
|
+
function normalizeEntitlements(raw) {
|
|
115
|
+
if (!Array.isArray(raw)) return [];
|
|
116
|
+
return raw.flatMap((code) => {
|
|
117
|
+
if (typeof code !== "string") return [];
|
|
118
|
+
const trimmed = code.trim();
|
|
119
|
+
return trimmed.length > 0 ? [trimmed] : [];
|
|
120
|
+
});
|
|
121
|
+
}
|
|
114
122
|
function normalizeUserinfo(raw) {
|
|
115
123
|
const hasOrganizationId = hasOwnKey(raw, "organization_id");
|
|
116
124
|
const hasOrganizationName = hasOwnKey(raw, "organization_name");
|
|
@@ -151,7 +159,10 @@ function normalizeUserinfo(raw) {
|
|
|
151
159
|
// `'active_canceling'`) for legacy backends. Defaulting to `false`
|
|
152
160
|
// here keeps the downstream contract a plain boolean.
|
|
153
161
|
cancelAtPeriodEnd: raw.subscription.cancel_at_period_end ?? false,
|
|
154
|
-
currentPeriodEnd: raw.subscription.current_period_end ?? null
|
|
162
|
+
currentPeriodEnd: raw.subscription.current_period_end ?? null,
|
|
163
|
+
// #4333: legacy FFID (< this issue) omits the field on the wire; the
|
|
164
|
+
// guard defaults to `[]` so consumers always get a plain string[].
|
|
165
|
+
entitlements: normalizeEntitlements(raw.subscription.entitlements)
|
|
155
166
|
} : void 0
|
|
156
167
|
};
|
|
157
168
|
}
|
|
@@ -438,7 +449,11 @@ function createVerifyAccessToken(deps) {
|
|
|
438
449
|
member_role: introspectResponse.subscription.member_role,
|
|
439
450
|
organization_id: introspectResponse.subscription.organization_id,
|
|
440
451
|
organization_name: introspectResponse.subscription.organization_name ?? null,
|
|
441
|
-
has_seat_assignment: introspectResponse.subscription.has_seat_assignment ?? false
|
|
452
|
+
has_seat_assignment: introspectResponse.subscription.has_seat_assignment ?? false,
|
|
453
|
+
// #4333: forward pack entitlement codes through the introspect →
|
|
454
|
+
// userinfo normalization boundary. normalizeUserinfo guards the
|
|
455
|
+
// value, so an older FFID that omits it degrades to `[]`.
|
|
456
|
+
entitlements: introspectResponse.subscription.entitlements
|
|
442
457
|
}
|
|
443
458
|
} : base;
|
|
444
459
|
const userinfo = normalizeUserinfo(raw);
|
|
@@ -1223,8 +1238,35 @@ function createNonContractMethods(deps) {
|
|
|
1223
1238
|
};
|
|
1224
1239
|
}
|
|
1225
1240
|
|
|
1241
|
+
// src/shared/token-response.ts
|
|
1242
|
+
function invalidTokenFields(tokenResponse) {
|
|
1243
|
+
const invalid = [];
|
|
1244
|
+
if (typeof tokenResponse.access_token !== "string" || tokenResponse.access_token.length === 0) {
|
|
1245
|
+
invalid.push("access_token");
|
|
1246
|
+
}
|
|
1247
|
+
if (typeof tokenResponse.refresh_token !== "string" || tokenResponse.refresh_token.length === 0) {
|
|
1248
|
+
invalid.push("refresh_token");
|
|
1249
|
+
}
|
|
1250
|
+
if (typeof tokenResponse.expires_in !== "number" || !Number.isFinite(tokenResponse.expires_in) || tokenResponse.expires_in <= 0) {
|
|
1251
|
+
invalid.push("expires_in");
|
|
1252
|
+
}
|
|
1253
|
+
return invalid;
|
|
1254
|
+
}
|
|
1255
|
+
function hasValidatedTokens(tokenResponse) {
|
|
1256
|
+
return invalidTokenFields(tokenResponse).length === 0;
|
|
1257
|
+
}
|
|
1258
|
+
function validateTokenResponse(tokenResponse) {
|
|
1259
|
+
if (hasValidatedTokens(tokenResponse)) {
|
|
1260
|
+
return { ok: true, tokens: tokenResponse };
|
|
1261
|
+
}
|
|
1262
|
+
return {
|
|
1263
|
+
ok: false,
|
|
1264
|
+
message: `\u30C8\u30FC\u30AF\u30F3\u30EC\u30B9\u30DD\u30F3\u30B9\u306B\u4E0D\u6B63\u306A\u30D5\u30A3\u30FC\u30EB\u30C9\u304C\u3042\u308A\u307E\u3059: ${invalidTokenFields(tokenResponse).join(", ")}`
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1226
1268
|
// src/client/version-check.ts
|
|
1227
|
-
var SDK_VERSION = "5.
|
|
1269
|
+
var SDK_VERSION = "5.25.0";
|
|
1228
1270
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
1229
1271
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
1230
1272
|
function sdkHeaders() {
|
|
@@ -1271,31 +1313,6 @@ npm install @feelflow/ffid-sdk@latest \u3067\u30A2\u30C3\u30D7\u30C7\u30FC\u30C8
|
|
|
1271
1313
|
var OAUTH_TOKEN_ENDPOINT = "/api/v1/oauth/token";
|
|
1272
1314
|
var OAUTH_REVOKE_ENDPOINT = "/api/v1/oauth/revoke";
|
|
1273
1315
|
var MS_PER_SECOND = 1e3;
|
|
1274
|
-
function invalidTokenFields(tokenResponse) {
|
|
1275
|
-
const invalid = [];
|
|
1276
|
-
if (!tokenResponse.access_token) {
|
|
1277
|
-
invalid.push("access_token");
|
|
1278
|
-
}
|
|
1279
|
-
if (!tokenResponse.refresh_token) {
|
|
1280
|
-
invalid.push("refresh_token");
|
|
1281
|
-
}
|
|
1282
|
-
if (typeof tokenResponse.expires_in !== "number" || !Number.isFinite(tokenResponse.expires_in) || tokenResponse.expires_in <= 0) {
|
|
1283
|
-
invalid.push("expires_in");
|
|
1284
|
-
}
|
|
1285
|
-
return invalid;
|
|
1286
|
-
}
|
|
1287
|
-
function hasValidatedTokens(tokenResponse) {
|
|
1288
|
-
return invalidTokenFields(tokenResponse).length === 0;
|
|
1289
|
-
}
|
|
1290
|
-
function validateTokenResponse(tokenResponse) {
|
|
1291
|
-
if (hasValidatedTokens(tokenResponse)) {
|
|
1292
|
-
return { ok: true, tokens: tokenResponse };
|
|
1293
|
-
}
|
|
1294
|
-
return {
|
|
1295
|
-
ok: false,
|
|
1296
|
-
message: `\u30C8\u30FC\u30AF\u30F3\u30EC\u30B9\u30DD\u30F3\u30B9\u306B\u4E0D\u6B63\u306A\u30D5\u30A3\u30FC\u30EB\u30C9\u304C\u3042\u308A\u307E\u3059: ${invalidTokenFields(tokenResponse).join(", ")}`
|
|
1297
|
-
};
|
|
1298
|
-
}
|
|
1299
1316
|
function createOAuthTokenMethods(deps) {
|
|
1300
1317
|
const {
|
|
1301
1318
|
baseUrl,
|
|
@@ -2846,10 +2863,16 @@ function createFFIDClient(config) {
|
|
|
2846
2863
|
}
|
|
2847
2864
|
const logger = config.logger ?? (config.debug ? consoleLogger : noopLogger);
|
|
2848
2865
|
const resolvedRedirectUri = resolveRedirectUri(rawRedirectUri, logger);
|
|
2849
|
-
const tokenStore = authMode === "token" ? createTokenStore() : createTokenStore("memory");
|
|
2866
|
+
const tokenStore = authMode === "token" ? config.tokenStore ?? createTokenStore() : createTokenStore("memory");
|
|
2850
2867
|
function createError(code, message) {
|
|
2851
2868
|
return { code, message };
|
|
2852
2869
|
}
|
|
2870
|
+
function getAccessToken() {
|
|
2871
|
+
if (authMode !== "token") return null;
|
|
2872
|
+
if (tokenStore.isAccessTokenExpired()) return null;
|
|
2873
|
+
const accessToken = tokenStore.getTokens()?.accessToken;
|
|
2874
|
+
return accessToken && accessToken.length > 0 ? accessToken : null;
|
|
2875
|
+
}
|
|
2853
2876
|
function buildFetchOptions(options, authOverride) {
|
|
2854
2877
|
if (authOverride) {
|
|
2855
2878
|
return {
|
|
@@ -3259,6 +3282,11 @@ function createFFIDClient(config) {
|
|
|
3259
3282
|
inquiry,
|
|
3260
3283
|
/** Token store (token mode only) */
|
|
3261
3284
|
tokenStore,
|
|
3285
|
+
/**
|
|
3286
|
+
* Return the currently-valid access token, or null (token mode only; #4318).
|
|
3287
|
+
* Live-reads the store and applies the 30s expiry buffer.
|
|
3288
|
+
*/
|
|
3289
|
+
getAccessToken,
|
|
3262
3290
|
/** Resolved auth mode */
|
|
3263
3291
|
authMode,
|
|
3264
3292
|
/** Resolved logger instance */
|
|
@@ -3420,27 +3448,6 @@ function withTimeout(init, timeout) {
|
|
|
3420
3448
|
}
|
|
3421
3449
|
return init;
|
|
3422
3450
|
}
|
|
3423
|
-
function invalidTokenFields2(r) {
|
|
3424
|
-
const invalid = [];
|
|
3425
|
-
if (!r.access_token) invalid.push("access_token");
|
|
3426
|
-
if (!r.refresh_token) invalid.push("refresh_token");
|
|
3427
|
-
if (typeof r.expires_in !== "number" || !Number.isFinite(r.expires_in) || r.expires_in <= 0) {
|
|
3428
|
-
invalid.push("expires_in");
|
|
3429
|
-
}
|
|
3430
|
-
return invalid;
|
|
3431
|
-
}
|
|
3432
|
-
function hasValidatedTokens2(r) {
|
|
3433
|
-
return invalidTokenFields2(r).length === 0;
|
|
3434
|
-
}
|
|
3435
|
-
function validateTokenResponse2(r) {
|
|
3436
|
-
if (hasValidatedTokens2(r)) {
|
|
3437
|
-
return { ok: true, tokens: r };
|
|
3438
|
-
}
|
|
3439
|
-
return {
|
|
3440
|
-
ok: false,
|
|
3441
|
-
message: `\u30C8\u30FC\u30AF\u30F3\u30EC\u30B9\u30DD\u30F3\u30B9\u306B\u4E0D\u6B63\u306A\u30D5\u30A3\u30FC\u30EB\u30C9\u304C\u3042\u308A\u307E\u3059: ${invalidTokenFields2(r).join(", ")}`
|
|
3442
|
-
};
|
|
3443
|
-
}
|
|
3444
3451
|
function toTokens(r) {
|
|
3445
3452
|
return {
|
|
3446
3453
|
accessToken: r.access_token,
|
|
@@ -3486,7 +3493,7 @@ async function postToken(deps, body, fallbackErrorCode) {
|
|
|
3486
3493
|
const errorBody = json;
|
|
3487
3494
|
return fail(errorBody.error ?? fallbackErrorCode, errorBody.error_description ?? "\u30C8\u30FC\u30AF\u30F3\u51E6\u7406\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
3488
3495
|
}
|
|
3489
|
-
const validation =
|
|
3496
|
+
const validation = validateTokenResponse(json);
|
|
3490
3497
|
if (!validation.ok) {
|
|
3491
3498
|
return fail(fallbackErrorCode, validation.message);
|
|
3492
3499
|
}
|
package/dist/server/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-
|
|
2
|
-
export { f as FFIDAddMemberParams, g as FFIDAddMemberRequest, h as FFIDAddMemberResponse, i as FFIDAssignableMemberRole, j as FFIDCacheConfig, k as FFIDClient, l as FFIDConfig, m as FFIDListMembersResponse, n as FFIDMemberRole, o as FFIDOrganization, p as FFIDOrganizationMember, q as FFIDOtpSendResponse, r as FFIDOtpVerifyResponse, s as FFIDPasswordResetConfirmResponse, t as FFIDPasswordResetResponse, u as FFIDPasswordResetVerifyResponse, v as FFIDProfileCallOptions, w as FFIDProvisionMemberPlan, x as FFIDProvisionMemberPlanStatus, y as FFIDProvisionMemberResult, z as FFIDProvisionMemberStatus, A as FFIDProvisionOrganizationDryRun, B as FFIDProvisionOrganizationMemberInput, C as FFIDProvisionOrganizationOutcome, D as FFIDProvisionOrganizationParams, E as FFIDProvisionOrganizationResponse, G as FFIDProvisionUserDryRun, H as FFIDProvisionUserOutcome, I as FFIDProvisionUserParams, J as FFIDProvisionUserProfileInput, K as FFIDProvisionUserResponse, L as FFIDProvisionedOrganization, M as FFIDProvisionedUser, N as FFIDRemoveMemberResponse, O as FFIDResetSessionResponse, P as FFIDSubscription, Q as FFIDUpdateMemberRoleResponse, R as FFIDUpdateUserProfileRequest, S as FFIDUser, T as FFIDUserProfile, U as TokenData, V as TokenStore, W as createFFIDClient, X as createTokenStore } from '../ffid-client-
|
|
1
|
+
import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-BZERrMAF.cjs';
|
|
2
|
+
export { f as FFIDAddMemberParams, g as FFIDAddMemberRequest, h as FFIDAddMemberResponse, i as FFIDAssignableMemberRole, j as FFIDCacheConfig, k as FFIDClient, l as FFIDConfig, m as FFIDListMembersResponse, n as FFIDMemberRole, o as FFIDOrganization, p as FFIDOrganizationMember, q as FFIDOtpSendResponse, r as FFIDOtpVerifyResponse, s as FFIDPasswordResetConfirmResponse, t as FFIDPasswordResetResponse, u as FFIDPasswordResetVerifyResponse, v as FFIDProfileCallOptions, w as FFIDProvisionMemberPlan, x as FFIDProvisionMemberPlanStatus, y as FFIDProvisionMemberResult, z as FFIDProvisionMemberStatus, A as FFIDProvisionOrganizationDryRun, B as FFIDProvisionOrganizationMemberInput, C as FFIDProvisionOrganizationOutcome, D as FFIDProvisionOrganizationParams, E as FFIDProvisionOrganizationResponse, G as FFIDProvisionUserDryRun, H as FFIDProvisionUserOutcome, I as FFIDProvisionUserParams, J as FFIDProvisionUserProfileInput, K as FFIDProvisionUserResponse, L as FFIDProvisionedOrganization, M as FFIDProvisionedUser, N as FFIDRemoveMemberResponse, O as FFIDResetSessionResponse, P as FFIDSubscription, Q as FFIDUpdateMemberRoleResponse, R as FFIDUpdateUserProfileRequest, S as FFIDUser, T as FFIDUserProfile, U as TokenData, V as TokenStore, W as createFFIDClient, X as createTokenStore } from '../ffid-client-BZERrMAF.cjs';
|
|
3
3
|
export { D as DEFAULT_API_BASE_URL, a as DEFAULT_OAUTH_SCOPES } from '../constants-D61jqRIO.cjs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import '../types-Cjb9J0rL.cjs';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-
|
|
2
|
-
export { f as FFIDAddMemberParams, g as FFIDAddMemberRequest, h as FFIDAddMemberResponse, i as FFIDAssignableMemberRole, j as FFIDCacheConfig, k as FFIDClient, l as FFIDConfig, m as FFIDListMembersResponse, n as FFIDMemberRole, o as FFIDOrganization, p as FFIDOrganizationMember, q as FFIDOtpSendResponse, r as FFIDOtpVerifyResponse, s as FFIDPasswordResetConfirmResponse, t as FFIDPasswordResetResponse, u as FFIDPasswordResetVerifyResponse, v as FFIDProfileCallOptions, w as FFIDProvisionMemberPlan, x as FFIDProvisionMemberPlanStatus, y as FFIDProvisionMemberResult, z as FFIDProvisionMemberStatus, A as FFIDProvisionOrganizationDryRun, B as FFIDProvisionOrganizationMemberInput, C as FFIDProvisionOrganizationOutcome, D as FFIDProvisionOrganizationParams, E as FFIDProvisionOrganizationResponse, G as FFIDProvisionUserDryRun, H as FFIDProvisionUserOutcome, I as FFIDProvisionUserParams, J as FFIDProvisionUserProfileInput, K as FFIDProvisionUserResponse, L as FFIDProvisionedOrganization, M as FFIDProvisionedUser, N as FFIDRemoveMemberResponse, O as FFIDResetSessionResponse, P as FFIDSubscription, Q as FFIDUpdateMemberRoleResponse, R as FFIDUpdateUserProfileRequest, S as FFIDUser, T as FFIDUserProfile, U as TokenData, V as TokenStore, W as createFFIDClient, X as createTokenStore } from '../ffid-client-
|
|
1
|
+
import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-CFZPX5ej.js';
|
|
2
|
+
export { f as FFIDAddMemberParams, g as FFIDAddMemberRequest, h as FFIDAddMemberResponse, i as FFIDAssignableMemberRole, j as FFIDCacheConfig, k as FFIDClient, l as FFIDConfig, m as FFIDListMembersResponse, n as FFIDMemberRole, o as FFIDOrganization, p as FFIDOrganizationMember, q as FFIDOtpSendResponse, r as FFIDOtpVerifyResponse, s as FFIDPasswordResetConfirmResponse, t as FFIDPasswordResetResponse, u as FFIDPasswordResetVerifyResponse, v as FFIDProfileCallOptions, w as FFIDProvisionMemberPlan, x as FFIDProvisionMemberPlanStatus, y as FFIDProvisionMemberResult, z as FFIDProvisionMemberStatus, A as FFIDProvisionOrganizationDryRun, B as FFIDProvisionOrganizationMemberInput, C as FFIDProvisionOrganizationOutcome, D as FFIDProvisionOrganizationParams, E as FFIDProvisionOrganizationResponse, G as FFIDProvisionUserDryRun, H as FFIDProvisionUserOutcome, I as FFIDProvisionUserParams, J as FFIDProvisionUserProfileInput, K as FFIDProvisionUserResponse, L as FFIDProvisionedOrganization, M as FFIDProvisionedUser, N as FFIDRemoveMemberResponse, O as FFIDResetSessionResponse, P as FFIDSubscription, Q as FFIDUpdateMemberRoleResponse, R as FFIDUpdateUserProfileRequest, S as FFIDUser, T as FFIDUserProfile, U as TokenData, V as TokenStore, W as createFFIDClient, X as createTokenStore } from '../ffid-client-CFZPX5ej.js';
|
|
3
3
|
export { D as DEFAULT_API_BASE_URL, a as DEFAULT_OAUTH_SCOPES } from '../constants-D61jqRIO.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import '../types-Cjb9J0rL.js';
|
package/dist/server/index.js
CHANGED
|
@@ -110,6 +110,14 @@ function isSessionEligibleSubscriptionStatus(value) {
|
|
|
110
110
|
function hasOwnKey(value, key) {
|
|
111
111
|
return Object.prototype.hasOwnProperty.call(value, key);
|
|
112
112
|
}
|
|
113
|
+
function normalizeEntitlements(raw) {
|
|
114
|
+
if (!Array.isArray(raw)) return [];
|
|
115
|
+
return raw.flatMap((code) => {
|
|
116
|
+
if (typeof code !== "string") return [];
|
|
117
|
+
const trimmed = code.trim();
|
|
118
|
+
return trimmed.length > 0 ? [trimmed] : [];
|
|
119
|
+
});
|
|
120
|
+
}
|
|
113
121
|
function normalizeUserinfo(raw) {
|
|
114
122
|
const hasOrganizationId = hasOwnKey(raw, "organization_id");
|
|
115
123
|
const hasOrganizationName = hasOwnKey(raw, "organization_name");
|
|
@@ -150,7 +158,10 @@ function normalizeUserinfo(raw) {
|
|
|
150
158
|
// `'active_canceling'`) for legacy backends. Defaulting to `false`
|
|
151
159
|
// here keeps the downstream contract a plain boolean.
|
|
152
160
|
cancelAtPeriodEnd: raw.subscription.cancel_at_period_end ?? false,
|
|
153
|
-
currentPeriodEnd: raw.subscription.current_period_end ?? null
|
|
161
|
+
currentPeriodEnd: raw.subscription.current_period_end ?? null,
|
|
162
|
+
// #4333: legacy FFID (< this issue) omits the field on the wire; the
|
|
163
|
+
// guard defaults to `[]` so consumers always get a plain string[].
|
|
164
|
+
entitlements: normalizeEntitlements(raw.subscription.entitlements)
|
|
154
165
|
} : void 0
|
|
155
166
|
};
|
|
156
167
|
}
|
|
@@ -437,7 +448,11 @@ function createVerifyAccessToken(deps) {
|
|
|
437
448
|
member_role: introspectResponse.subscription.member_role,
|
|
438
449
|
organization_id: introspectResponse.subscription.organization_id,
|
|
439
450
|
organization_name: introspectResponse.subscription.organization_name ?? null,
|
|
440
|
-
has_seat_assignment: introspectResponse.subscription.has_seat_assignment ?? false
|
|
451
|
+
has_seat_assignment: introspectResponse.subscription.has_seat_assignment ?? false,
|
|
452
|
+
// #4333: forward pack entitlement codes through the introspect →
|
|
453
|
+
// userinfo normalization boundary. normalizeUserinfo guards the
|
|
454
|
+
// value, so an older FFID that omits it degrades to `[]`.
|
|
455
|
+
entitlements: introspectResponse.subscription.entitlements
|
|
441
456
|
}
|
|
442
457
|
} : base;
|
|
443
458
|
const userinfo = normalizeUserinfo(raw);
|
|
@@ -1222,8 +1237,35 @@ function createNonContractMethods(deps) {
|
|
|
1222
1237
|
};
|
|
1223
1238
|
}
|
|
1224
1239
|
|
|
1240
|
+
// src/shared/token-response.ts
|
|
1241
|
+
function invalidTokenFields(tokenResponse) {
|
|
1242
|
+
const invalid = [];
|
|
1243
|
+
if (typeof tokenResponse.access_token !== "string" || tokenResponse.access_token.length === 0) {
|
|
1244
|
+
invalid.push("access_token");
|
|
1245
|
+
}
|
|
1246
|
+
if (typeof tokenResponse.refresh_token !== "string" || tokenResponse.refresh_token.length === 0) {
|
|
1247
|
+
invalid.push("refresh_token");
|
|
1248
|
+
}
|
|
1249
|
+
if (typeof tokenResponse.expires_in !== "number" || !Number.isFinite(tokenResponse.expires_in) || tokenResponse.expires_in <= 0) {
|
|
1250
|
+
invalid.push("expires_in");
|
|
1251
|
+
}
|
|
1252
|
+
return invalid;
|
|
1253
|
+
}
|
|
1254
|
+
function hasValidatedTokens(tokenResponse) {
|
|
1255
|
+
return invalidTokenFields(tokenResponse).length === 0;
|
|
1256
|
+
}
|
|
1257
|
+
function validateTokenResponse(tokenResponse) {
|
|
1258
|
+
if (hasValidatedTokens(tokenResponse)) {
|
|
1259
|
+
return { ok: true, tokens: tokenResponse };
|
|
1260
|
+
}
|
|
1261
|
+
return {
|
|
1262
|
+
ok: false,
|
|
1263
|
+
message: `\u30C8\u30FC\u30AF\u30F3\u30EC\u30B9\u30DD\u30F3\u30B9\u306B\u4E0D\u6B63\u306A\u30D5\u30A3\u30FC\u30EB\u30C9\u304C\u3042\u308A\u307E\u3059: ${invalidTokenFields(tokenResponse).join(", ")}`
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1225
1267
|
// src/client/version-check.ts
|
|
1226
|
-
var SDK_VERSION = "5.
|
|
1268
|
+
var SDK_VERSION = "5.25.0";
|
|
1227
1269
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
1228
1270
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
1229
1271
|
function sdkHeaders() {
|
|
@@ -1270,31 +1312,6 @@ npm install @feelflow/ffid-sdk@latest \u3067\u30A2\u30C3\u30D7\u30C7\u30FC\u30C8
|
|
|
1270
1312
|
var OAUTH_TOKEN_ENDPOINT = "/api/v1/oauth/token";
|
|
1271
1313
|
var OAUTH_REVOKE_ENDPOINT = "/api/v1/oauth/revoke";
|
|
1272
1314
|
var MS_PER_SECOND = 1e3;
|
|
1273
|
-
function invalidTokenFields(tokenResponse) {
|
|
1274
|
-
const invalid = [];
|
|
1275
|
-
if (!tokenResponse.access_token) {
|
|
1276
|
-
invalid.push("access_token");
|
|
1277
|
-
}
|
|
1278
|
-
if (!tokenResponse.refresh_token) {
|
|
1279
|
-
invalid.push("refresh_token");
|
|
1280
|
-
}
|
|
1281
|
-
if (typeof tokenResponse.expires_in !== "number" || !Number.isFinite(tokenResponse.expires_in) || tokenResponse.expires_in <= 0) {
|
|
1282
|
-
invalid.push("expires_in");
|
|
1283
|
-
}
|
|
1284
|
-
return invalid;
|
|
1285
|
-
}
|
|
1286
|
-
function hasValidatedTokens(tokenResponse) {
|
|
1287
|
-
return invalidTokenFields(tokenResponse).length === 0;
|
|
1288
|
-
}
|
|
1289
|
-
function validateTokenResponse(tokenResponse) {
|
|
1290
|
-
if (hasValidatedTokens(tokenResponse)) {
|
|
1291
|
-
return { ok: true, tokens: tokenResponse };
|
|
1292
|
-
}
|
|
1293
|
-
return {
|
|
1294
|
-
ok: false,
|
|
1295
|
-
message: `\u30C8\u30FC\u30AF\u30F3\u30EC\u30B9\u30DD\u30F3\u30B9\u306B\u4E0D\u6B63\u306A\u30D5\u30A3\u30FC\u30EB\u30C9\u304C\u3042\u308A\u307E\u3059: ${invalidTokenFields(tokenResponse).join(", ")}`
|
|
1296
|
-
};
|
|
1297
|
-
}
|
|
1298
1315
|
function createOAuthTokenMethods(deps) {
|
|
1299
1316
|
const {
|
|
1300
1317
|
baseUrl,
|
|
@@ -2845,10 +2862,16 @@ function createFFIDClient(config) {
|
|
|
2845
2862
|
}
|
|
2846
2863
|
const logger = config.logger ?? (config.debug ? consoleLogger : noopLogger);
|
|
2847
2864
|
const resolvedRedirectUri = resolveRedirectUri(rawRedirectUri, logger);
|
|
2848
|
-
const tokenStore = authMode === "token" ? createTokenStore() : createTokenStore("memory");
|
|
2865
|
+
const tokenStore = authMode === "token" ? config.tokenStore ?? createTokenStore() : createTokenStore("memory");
|
|
2849
2866
|
function createError(code, message) {
|
|
2850
2867
|
return { code, message };
|
|
2851
2868
|
}
|
|
2869
|
+
function getAccessToken() {
|
|
2870
|
+
if (authMode !== "token") return null;
|
|
2871
|
+
if (tokenStore.isAccessTokenExpired()) return null;
|
|
2872
|
+
const accessToken = tokenStore.getTokens()?.accessToken;
|
|
2873
|
+
return accessToken && accessToken.length > 0 ? accessToken : null;
|
|
2874
|
+
}
|
|
2852
2875
|
function buildFetchOptions(options, authOverride) {
|
|
2853
2876
|
if (authOverride) {
|
|
2854
2877
|
return {
|
|
@@ -3258,6 +3281,11 @@ function createFFIDClient(config) {
|
|
|
3258
3281
|
inquiry,
|
|
3259
3282
|
/** Token store (token mode only) */
|
|
3260
3283
|
tokenStore,
|
|
3284
|
+
/**
|
|
3285
|
+
* Return the currently-valid access token, or null (token mode only; #4318).
|
|
3286
|
+
* Live-reads the store and applies the 30s expiry buffer.
|
|
3287
|
+
*/
|
|
3288
|
+
getAccessToken,
|
|
3261
3289
|
/** Resolved auth mode */
|
|
3262
3290
|
authMode,
|
|
3263
3291
|
/** Resolved logger instance */
|
|
@@ -3419,27 +3447,6 @@ function withTimeout(init, timeout) {
|
|
|
3419
3447
|
}
|
|
3420
3448
|
return init;
|
|
3421
3449
|
}
|
|
3422
|
-
function invalidTokenFields2(r) {
|
|
3423
|
-
const invalid = [];
|
|
3424
|
-
if (!r.access_token) invalid.push("access_token");
|
|
3425
|
-
if (!r.refresh_token) invalid.push("refresh_token");
|
|
3426
|
-
if (typeof r.expires_in !== "number" || !Number.isFinite(r.expires_in) || r.expires_in <= 0) {
|
|
3427
|
-
invalid.push("expires_in");
|
|
3428
|
-
}
|
|
3429
|
-
return invalid;
|
|
3430
|
-
}
|
|
3431
|
-
function hasValidatedTokens2(r) {
|
|
3432
|
-
return invalidTokenFields2(r).length === 0;
|
|
3433
|
-
}
|
|
3434
|
-
function validateTokenResponse2(r) {
|
|
3435
|
-
if (hasValidatedTokens2(r)) {
|
|
3436
|
-
return { ok: true, tokens: r };
|
|
3437
|
-
}
|
|
3438
|
-
return {
|
|
3439
|
-
ok: false,
|
|
3440
|
-
message: `\u30C8\u30FC\u30AF\u30F3\u30EC\u30B9\u30DD\u30F3\u30B9\u306B\u4E0D\u6B63\u306A\u30D5\u30A3\u30FC\u30EB\u30C9\u304C\u3042\u308A\u307E\u3059: ${invalidTokenFields2(r).join(", ")}`
|
|
3441
|
-
};
|
|
3442
|
-
}
|
|
3443
3450
|
function toTokens(r) {
|
|
3444
3451
|
return {
|
|
3445
3452
|
accessToken: r.access_token,
|
|
@@ -3485,7 +3492,7 @@ async function postToken(deps, body, fallbackErrorCode) {
|
|
|
3485
3492
|
const errorBody = json;
|
|
3486
3493
|
return fail(errorBody.error ?? fallbackErrorCode, errorBody.error_description ?? "\u30C8\u30FC\u30AF\u30F3\u51E6\u7406\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
3487
3494
|
}
|
|
3488
|
-
const validation =
|
|
3495
|
+
const validation = validateTokenResponse(json);
|
|
3489
3496
|
if (!validation.ok) {
|
|
3490
3497
|
return fail(fallbackErrorCode, validation.message);
|
|
3491
3498
|
}
|