@feelflow/ffid-sdk 5.24.2 → 5.24.3
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-QMWUOVZK.cjs → chunk-AMVL7J2G.cjs} +51 -31
- package/dist/{chunk-Q7ZEF3EN.js → chunk-O3HGRALD.js} +51 -31
- 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-DX2PTTFr.d.ts → ffid-client-B-xjtrCb.d.ts} +69 -41
- package/dist/{ffid-client-D0Jh4bO7.d.cts → ffid-client-BjZphrz9.d.cts} +69 -41
- package/dist/{index-GqflEaKi.d.cts → index-BRMn6xT0.d.cts} +77 -1
- package/dist/{index-GqflEaKi.d.ts → index-BRMn6xT0.d.ts} +77 -1
- package/dist/index.cjs +42 -42
- package/dist/index.d.cts +17 -45
- package/dist/index.d.ts +17 -45
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +41 -49
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +41 -49
- 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 FFIDPrompt, b as FFIDConfig, c as FFIDApiResponse, d as FFIDSessionResponse, e as FFIDSignOutResult, f as FFIDRedirectResult, 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, 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 FFIDOAuthUserInfoSubscription, x as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, y as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, z as FFIDAnnouncementsLogger } from './index-
|
|
2
|
-
export { B as Announcement, C as AnnouncementStatus, D as AnnouncementType, G as EFFECTIVE_SUBSCRIPTION_STATUSES, H as FFIDAnnouncementBadge, I as FFIDAnnouncementList, J as FFIDAnnouncementsError, K as FFIDAnnouncementsErrorCode, M as FFIDAnnouncementsServerResponse, N as FFIDApiResponseMeta, O as FFIDCacheConfig, P as FFIDContextValue, Q as FFIDInquiryCategory, R as FFIDInquiryCategorySite2026, S as FFIDInquiryForm,
|
|
1
|
+
import { F as FFIDSubscriptionStatus, a as FFIDPrompt, b as FFIDConfig, c as FFIDApiResponse, d as FFIDSessionResponse, e as FFIDSignOutResult, f as FFIDRedirectResult, 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 FFIDOAuthUserInfoSubscription, x as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, y as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, z as FFIDAnnouncementsLogger } from './index-BRMn6xT0.js';
|
|
2
|
+
export { B as Announcement, C as AnnouncementStatus, D as AnnouncementType, G as EFFECTIVE_SUBSCRIPTION_STATUSES, H as FFIDAnnouncementBadge, I as FFIDAnnouncementList, J as FFIDAnnouncementsError, K as FFIDAnnouncementsErrorCode, M as FFIDAnnouncementsServerResponse, N as FFIDApiResponseMeta, O as FFIDCacheConfig, P as FFIDContextValue, Q as FFIDInquiryCategory, R as FFIDInquiryCategorySite2026, S as FFIDInquiryForm, U as FFIDInquiryFormCategoryItem, V as FFIDInquiryFormClassNames, W as FFIDInquiryFormLegalLayout, X as FFIDInquiryFormOrganization, Y as FFIDInquiryFormPlaceholderContext, Z as FFIDInquiryFormPrefill, _ as FFIDInquiryFormProps, $ as FFIDInquiryFormSubmitData, a0 as FFIDInquiryFormSubmitResult, a1 as FFIDJwtClaims, a2 as FFIDLoginButton, a3 as FFIDOAuthTokenResponse, a4 as FFIDOAuthUserInfoMemberRole, a5 as FFIDOrganizationSwitcher, a6 as FFIDRedirectErrorCode, a7 as FFIDSeatModel, a8 as FFIDServiceAccessDenialReason, a9 as FFIDServiceAccessFailPolicy, aa as FFIDSubscriptionBadge, ab as FFIDTokenIntrospectionResponse, ac as FFIDUserMenu, ad as FFID_INQUIRY_CATEGORIES, ae as FFID_INQUIRY_CATEGORIES_SITE_2026, af as TokenData, ag as UseFFIDAnnouncementsOptions, ah as UseFFIDAnnouncementsReturn, ai as createTokenStore, aj as isFFIDInquiryCategorySite2026, ak as useFFIDAnnouncements } from './index-BRMn6xT0.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
|
*
|
|
@@ -1478,6 +1437,11 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
1478
1437
|
};
|
|
1479
1438
|
/** Token store (token mode only) */
|
|
1480
1439
|
tokenStore: TokenStore;
|
|
1440
|
+
/**
|
|
1441
|
+
* Return the currently-valid access token, or null (token mode only; #4318).
|
|
1442
|
+
* Live-reads the store and applies the 30s expiry buffer.
|
|
1443
|
+
*/
|
|
1444
|
+
getAccessToken: () => string | null;
|
|
1481
1445
|
/** Resolved auth mode */
|
|
1482
1446
|
authMode: FFIDAuthMode;
|
|
1483
1447
|
/** Resolved logger instance */
|
|
@@ -1643,7 +1607,7 @@ interface FFIDProviderProps extends FFIDConfig {
|
|
|
1643
1607
|
* - Automatic session refresh
|
|
1644
1608
|
* - Token mode: automatic code exchange and token refresh
|
|
1645
1609
|
*/
|
|
1646
|
-
declare function FFIDProvider({ children, serviceCode, scope, apiBaseUrl, debug, logger, refreshInterval, onAuthStateChange, onError, authMode, clientId, timeout, cleanCallbackUrl, }: FFIDProviderProps): react_jsx_runtime.JSX.Element;
|
|
1610
|
+
declare function FFIDProvider({ children, serviceCode, scope, apiBaseUrl, debug, logger, refreshInterval, onAuthStateChange, onError, authMode, clientId, timeout, tokenStore, cleanCallbackUrl, }: FFIDProviderProps): react_jsx_runtime.JSX.Element;
|
|
1647
1611
|
|
|
1648
1612
|
/**
|
|
1649
1613
|
* Return type for useFFID hook
|
|
@@ -1707,6 +1671,14 @@ interface UseFFIDReturn {
|
|
|
1707
1671
|
switchOrganization: (organizationId: string) => void;
|
|
1708
1672
|
/** Refresh session data */
|
|
1709
1673
|
refresh: () => Promise<void>;
|
|
1674
|
+
/**
|
|
1675
|
+
* Token mode: return the currently-valid access token, or `null` when there is
|
|
1676
|
+
* none or it is expired (30s buffer). Live-reads the shared token store on each
|
|
1677
|
+
* call, so a token refreshed in the background — or cleared on logout — is
|
|
1678
|
+
* reflected without the host caching or polling it. Always `null` in
|
|
1679
|
+
* cookie / service-key mode. Stable function reference (#4318).
|
|
1680
|
+
*/
|
|
1681
|
+
getAccessToken: () => string | null;
|
|
1710
1682
|
/** Get login URL with redirect parameter */
|
|
1711
1683
|
getLoginUrl: (redirectUrl?: string) => string;
|
|
1712
1684
|
/** Get signup URL with redirect parameter */
|
|
@@ -2316,4 +2288,4 @@ declare function createInquiryMethods(deps: InquiryMethodsDeps): {
|
|
|
2316
2288
|
};
|
|
2317
2289
|
type FFIDInquiryClient = ReturnType<typeof createInquiryMethods>;
|
|
2318
2290
|
|
|
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,
|
|
2291
|
+
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, 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-O3HGRALD.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-O3HGRALD.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
|
@@ -1223,8 +1223,35 @@ function createNonContractMethods(deps) {
|
|
|
1223
1223
|
};
|
|
1224
1224
|
}
|
|
1225
1225
|
|
|
1226
|
+
// src/shared/token-response.ts
|
|
1227
|
+
function invalidTokenFields(tokenResponse) {
|
|
1228
|
+
const invalid = [];
|
|
1229
|
+
if (typeof tokenResponse.access_token !== "string" || tokenResponse.access_token.length === 0) {
|
|
1230
|
+
invalid.push("access_token");
|
|
1231
|
+
}
|
|
1232
|
+
if (typeof tokenResponse.refresh_token !== "string" || tokenResponse.refresh_token.length === 0) {
|
|
1233
|
+
invalid.push("refresh_token");
|
|
1234
|
+
}
|
|
1235
|
+
if (typeof tokenResponse.expires_in !== "number" || !Number.isFinite(tokenResponse.expires_in) || tokenResponse.expires_in <= 0) {
|
|
1236
|
+
invalid.push("expires_in");
|
|
1237
|
+
}
|
|
1238
|
+
return invalid;
|
|
1239
|
+
}
|
|
1240
|
+
function hasValidatedTokens(tokenResponse) {
|
|
1241
|
+
return invalidTokenFields(tokenResponse).length === 0;
|
|
1242
|
+
}
|
|
1243
|
+
function validateTokenResponse(tokenResponse) {
|
|
1244
|
+
if (hasValidatedTokens(tokenResponse)) {
|
|
1245
|
+
return { ok: true, tokens: tokenResponse };
|
|
1246
|
+
}
|
|
1247
|
+
return {
|
|
1248
|
+
ok: false,
|
|
1249
|
+
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(", ")}`
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1226
1253
|
// src/client/version-check.ts
|
|
1227
|
-
var SDK_VERSION = "5.24.
|
|
1254
|
+
var SDK_VERSION = "5.24.3";
|
|
1228
1255
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
1229
1256
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
1230
1257
|
function sdkHeaders() {
|
|
@@ -1271,31 +1298,6 @@ npm install @feelflow/ffid-sdk@latest \u3067\u30A2\u30C3\u30D7\u30C7\u30FC\u30C8
|
|
|
1271
1298
|
var OAUTH_TOKEN_ENDPOINT = "/api/v1/oauth/token";
|
|
1272
1299
|
var OAUTH_REVOKE_ENDPOINT = "/api/v1/oauth/revoke";
|
|
1273
1300
|
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
1301
|
function createOAuthTokenMethods(deps) {
|
|
1300
1302
|
const {
|
|
1301
1303
|
baseUrl,
|
|
@@ -2846,10 +2848,16 @@ function createFFIDClient(config) {
|
|
|
2846
2848
|
}
|
|
2847
2849
|
const logger = config.logger ?? (config.debug ? consoleLogger : noopLogger);
|
|
2848
2850
|
const resolvedRedirectUri = resolveRedirectUri(rawRedirectUri, logger);
|
|
2849
|
-
const tokenStore = authMode === "token" ? createTokenStore() : createTokenStore("memory");
|
|
2851
|
+
const tokenStore = authMode === "token" ? config.tokenStore ?? createTokenStore() : createTokenStore("memory");
|
|
2850
2852
|
function createError(code, message) {
|
|
2851
2853
|
return { code, message };
|
|
2852
2854
|
}
|
|
2855
|
+
function getAccessToken() {
|
|
2856
|
+
if (authMode !== "token") return null;
|
|
2857
|
+
if (tokenStore.isAccessTokenExpired()) return null;
|
|
2858
|
+
const accessToken = tokenStore.getTokens()?.accessToken;
|
|
2859
|
+
return accessToken && accessToken.length > 0 ? accessToken : null;
|
|
2860
|
+
}
|
|
2853
2861
|
function buildFetchOptions(options, authOverride) {
|
|
2854
2862
|
if (authOverride) {
|
|
2855
2863
|
return {
|
|
@@ -3259,6 +3267,11 @@ function createFFIDClient(config) {
|
|
|
3259
3267
|
inquiry,
|
|
3260
3268
|
/** Token store (token mode only) */
|
|
3261
3269
|
tokenStore,
|
|
3270
|
+
/**
|
|
3271
|
+
* Return the currently-valid access token, or null (token mode only; #4318).
|
|
3272
|
+
* Live-reads the store and applies the 30s expiry buffer.
|
|
3273
|
+
*/
|
|
3274
|
+
getAccessToken,
|
|
3262
3275
|
/** Resolved auth mode */
|
|
3263
3276
|
authMode,
|
|
3264
3277
|
/** Resolved logger instance */
|
|
@@ -3420,27 +3433,6 @@ function withTimeout(init, timeout) {
|
|
|
3420
3433
|
}
|
|
3421
3434
|
return init;
|
|
3422
3435
|
}
|
|
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
3436
|
function toTokens(r) {
|
|
3445
3437
|
return {
|
|
3446
3438
|
accessToken: r.access_token,
|
|
@@ -3486,7 +3478,7 @@ async function postToken(deps, body, fallbackErrorCode) {
|
|
|
3486
3478
|
const errorBody = json;
|
|
3487
3479
|
return fail(errorBody.error ?? fallbackErrorCode, errorBody.error_description ?? "\u30C8\u30FC\u30AF\u30F3\u51E6\u7406\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
3488
3480
|
}
|
|
3489
|
-
const validation =
|
|
3481
|
+
const validation = validateTokenResponse(json);
|
|
3490
3482
|
if (!validation.ok) {
|
|
3491
3483
|
return fail(fallbackErrorCode, validation.message);
|
|
3492
3484
|
}
|
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-BjZphrz9.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-BjZphrz9.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-B-xjtrCb.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-B-xjtrCb.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
|
@@ -1222,8 +1222,35 @@ function createNonContractMethods(deps) {
|
|
|
1222
1222
|
};
|
|
1223
1223
|
}
|
|
1224
1224
|
|
|
1225
|
+
// src/shared/token-response.ts
|
|
1226
|
+
function invalidTokenFields(tokenResponse) {
|
|
1227
|
+
const invalid = [];
|
|
1228
|
+
if (typeof tokenResponse.access_token !== "string" || tokenResponse.access_token.length === 0) {
|
|
1229
|
+
invalid.push("access_token");
|
|
1230
|
+
}
|
|
1231
|
+
if (typeof tokenResponse.refresh_token !== "string" || tokenResponse.refresh_token.length === 0) {
|
|
1232
|
+
invalid.push("refresh_token");
|
|
1233
|
+
}
|
|
1234
|
+
if (typeof tokenResponse.expires_in !== "number" || !Number.isFinite(tokenResponse.expires_in) || tokenResponse.expires_in <= 0) {
|
|
1235
|
+
invalid.push("expires_in");
|
|
1236
|
+
}
|
|
1237
|
+
return invalid;
|
|
1238
|
+
}
|
|
1239
|
+
function hasValidatedTokens(tokenResponse) {
|
|
1240
|
+
return invalidTokenFields(tokenResponse).length === 0;
|
|
1241
|
+
}
|
|
1242
|
+
function validateTokenResponse(tokenResponse) {
|
|
1243
|
+
if (hasValidatedTokens(tokenResponse)) {
|
|
1244
|
+
return { ok: true, tokens: tokenResponse };
|
|
1245
|
+
}
|
|
1246
|
+
return {
|
|
1247
|
+
ok: false,
|
|
1248
|
+
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(", ")}`
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1225
1252
|
// src/client/version-check.ts
|
|
1226
|
-
var SDK_VERSION = "5.24.
|
|
1253
|
+
var SDK_VERSION = "5.24.3";
|
|
1227
1254
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
1228
1255
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
1229
1256
|
function sdkHeaders() {
|
|
@@ -1270,31 +1297,6 @@ npm install @feelflow/ffid-sdk@latest \u3067\u30A2\u30C3\u30D7\u30C7\u30FC\u30C8
|
|
|
1270
1297
|
var OAUTH_TOKEN_ENDPOINT = "/api/v1/oauth/token";
|
|
1271
1298
|
var OAUTH_REVOKE_ENDPOINT = "/api/v1/oauth/revoke";
|
|
1272
1299
|
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
1300
|
function createOAuthTokenMethods(deps) {
|
|
1299
1301
|
const {
|
|
1300
1302
|
baseUrl,
|
|
@@ -2845,10 +2847,16 @@ function createFFIDClient(config) {
|
|
|
2845
2847
|
}
|
|
2846
2848
|
const logger = config.logger ?? (config.debug ? consoleLogger : noopLogger);
|
|
2847
2849
|
const resolvedRedirectUri = resolveRedirectUri(rawRedirectUri, logger);
|
|
2848
|
-
const tokenStore = authMode === "token" ? createTokenStore() : createTokenStore("memory");
|
|
2850
|
+
const tokenStore = authMode === "token" ? config.tokenStore ?? createTokenStore() : createTokenStore("memory");
|
|
2849
2851
|
function createError(code, message) {
|
|
2850
2852
|
return { code, message };
|
|
2851
2853
|
}
|
|
2854
|
+
function getAccessToken() {
|
|
2855
|
+
if (authMode !== "token") return null;
|
|
2856
|
+
if (tokenStore.isAccessTokenExpired()) return null;
|
|
2857
|
+
const accessToken = tokenStore.getTokens()?.accessToken;
|
|
2858
|
+
return accessToken && accessToken.length > 0 ? accessToken : null;
|
|
2859
|
+
}
|
|
2852
2860
|
function buildFetchOptions(options, authOverride) {
|
|
2853
2861
|
if (authOverride) {
|
|
2854
2862
|
return {
|
|
@@ -3258,6 +3266,11 @@ function createFFIDClient(config) {
|
|
|
3258
3266
|
inquiry,
|
|
3259
3267
|
/** Token store (token mode only) */
|
|
3260
3268
|
tokenStore,
|
|
3269
|
+
/**
|
|
3270
|
+
* Return the currently-valid access token, or null (token mode only; #4318).
|
|
3271
|
+
* Live-reads the store and applies the 30s expiry buffer.
|
|
3272
|
+
*/
|
|
3273
|
+
getAccessToken,
|
|
3261
3274
|
/** Resolved auth mode */
|
|
3262
3275
|
authMode,
|
|
3263
3276
|
/** Resolved logger instance */
|
|
@@ -3419,27 +3432,6 @@ function withTimeout(init, timeout) {
|
|
|
3419
3432
|
}
|
|
3420
3433
|
return init;
|
|
3421
3434
|
}
|
|
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
3435
|
function toTokens(r) {
|
|
3444
3436
|
return {
|
|
3445
3437
|
accessToken: r.access_token,
|
|
@@ -3485,7 +3477,7 @@ async function postToken(deps, body, fallbackErrorCode) {
|
|
|
3485
3477
|
const errorBody = json;
|
|
3486
3478
|
return fail(errorBody.error ?? fallbackErrorCode, errorBody.error_description ?? "\u30C8\u30FC\u30AF\u30F3\u51E6\u7406\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
3487
3479
|
}
|
|
3488
|
-
const validation =
|
|
3480
|
+
const validation = validateTokenResponse(json);
|
|
3489
3481
|
if (!validation.ok) {
|
|
3490
3482
|
return fail(fallbackErrorCode, validation.message);
|
|
3491
3483
|
}
|