@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
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ButtonHTMLAttributes, ReactNode, CSSProperties } from 'react';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Token Store
|
|
6
|
+
*
|
|
7
|
+
* Manages OAuth 2.0 tokens (access + refresh) with dual-storage support.
|
|
8
|
+
* Falls back to in-memory storage when localStorage is unavailable
|
|
9
|
+
* (e.g., Safari private browsing mode).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Token data stored by the token store
|
|
13
|
+
*/
|
|
14
|
+
interface TokenData {
|
|
15
|
+
/** OAuth 2.0 access token */
|
|
16
|
+
accessToken: string;
|
|
17
|
+
/** OAuth 2.0 refresh token */
|
|
18
|
+
refreshToken: string;
|
|
19
|
+
/** Expiration timestamp in milliseconds (Unix epoch) */
|
|
20
|
+
expiresAt: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Token store interface for managing OAuth tokens
|
|
24
|
+
*/
|
|
25
|
+
interface TokenStore {
|
|
26
|
+
/** Get stored tokens (null if not stored) */
|
|
27
|
+
getTokens(): TokenData | null;
|
|
28
|
+
/** Store new tokens */
|
|
29
|
+
setTokens(tokens: TokenData): void;
|
|
30
|
+
/** Clear all stored tokens */
|
|
31
|
+
clearTokens(): void;
|
|
32
|
+
/** Check if access token is expired (with 30s buffer) */
|
|
33
|
+
isAccessTokenExpired(): boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a token store with the specified storage type.
|
|
37
|
+
*
|
|
38
|
+
* When storageType is 'localStorage' (default in browser), falls back
|
|
39
|
+
* to memory if localStorage is not available (e.g., Safari private mode).
|
|
40
|
+
*
|
|
41
|
+
* @param storageType - 'localStorage' (default) or 'memory'
|
|
42
|
+
*/
|
|
43
|
+
declare function createTokenStore(storageType?: 'localStorage' | 'memory'): TokenStore;
|
|
44
|
+
|
|
4
45
|
/** Cache adapter interface for FFID SDK token verification */
|
|
5
46
|
/**
|
|
6
47
|
* Pluggable cache adapter interface.
|
|
@@ -313,6 +354,19 @@ interface FFIDOAuthUserInfoSubscription {
|
|
|
313
354
|
* round-trip.
|
|
314
355
|
*/
|
|
315
356
|
currentPeriodEnd: string | null;
|
|
357
|
+
/**
|
|
358
|
+
* Per-service entitlement codes (e.g. `praxis.pack.<slug>.access`) granting
|
|
359
|
+
* access to one-time / single-pack purchases not encoded in the plan tier
|
|
360
|
+
* (#4333, SDK 5.25.0). Read this list to gate per-pack access; an empty
|
|
361
|
+
* array means "no pack entitlements" (the normal case for Pro / Team tiers
|
|
362
|
+
* that unlock packs via `planCode`).
|
|
363
|
+
*
|
|
364
|
+
* The `normalizeUserinfo` boundary defaults this to `[]` when the server
|
|
365
|
+
* omits it (older FFID pre-#4333) or when the introspect path uses a service
|
|
366
|
+
* API key without `subscription:read`, so consumers always see a plain
|
|
367
|
+
* `readonly string[]` and never branch on an "unknown" sentinel.
|
|
368
|
+
*/
|
|
369
|
+
entitlements: readonly string[];
|
|
316
370
|
}
|
|
317
371
|
/**
|
|
318
372
|
* Unified user-identity shape returned by `getSession()` (→ `/oauth/userinfo`)
|
|
@@ -474,6 +528,29 @@ interface FFIDConfig {
|
|
|
474
528
|
* @default undefined (no timeout, uses fetch default)
|
|
475
529
|
*/
|
|
476
530
|
timeout?: number | undefined;
|
|
531
|
+
/**
|
|
532
|
+
* Token mode only: inject a shared {@link TokenStore} instance so the SDK and
|
|
533
|
+
* the host app read/write the *same* token source (#4318).
|
|
534
|
+
*
|
|
535
|
+
* By default the client creates its own store internally
|
|
536
|
+
* (`createTokenStore()` in `token` mode, `createTokenStore('memory')`
|
|
537
|
+
* otherwise). That is fine when `localStorage` is available, because a
|
|
538
|
+
* separately-created `localStorage` store still points at the same
|
|
539
|
+
* `ffid_tokens` key. But when `localStorage` is unavailable (e.g. Safari
|
|
540
|
+
* Private Mode) the SDK falls back to an *in-memory* store, and a store the
|
|
541
|
+
* host app creates independently is a **different** object — so the app would
|
|
542
|
+
* see the user as signed-out even though the SDK holds valid tokens.
|
|
543
|
+
*
|
|
544
|
+
* Passing a single instance here (typically `createTokenStore()` created once
|
|
545
|
+
* by the host) guarantees both sides share one source of truth regardless of
|
|
546
|
+
* storage backend. Prefer reading the token via `useFFID().getAccessToken()`
|
|
547
|
+
* so refresh/logout stay reflected without the host polling the store.
|
|
548
|
+
*
|
|
549
|
+
* Ignored in `cookie` and `service-key` modes (neither exposes a browser
|
|
550
|
+
* access-token store). When omitted, behavior is unchanged from previous
|
|
551
|
+
* versions.
|
|
552
|
+
*/
|
|
553
|
+
tokenStore?: TokenStore | undefined;
|
|
477
554
|
}
|
|
478
555
|
/**
|
|
479
556
|
* FFID JWT claims structure (minimal payload).
|
|
@@ -556,6 +633,18 @@ interface FFIDContextValue {
|
|
|
556
633
|
switchOrganization: (organizationId: string) => void;
|
|
557
634
|
/** Refresh session data */
|
|
558
635
|
refresh: () => Promise<void>;
|
|
636
|
+
/**
|
|
637
|
+
* Token mode: return the currently-stored access token, or `null` when there
|
|
638
|
+
* is none, it is empty, or it is expired (30s buffer, same as
|
|
639
|
+
* `TokenStore.isAccessTokenExpired`). Reads the store live on every call, so a
|
|
640
|
+
* token the SDK refreshed in the background is reflected without the host
|
|
641
|
+
* caching or polling it (#4318).
|
|
642
|
+
*
|
|
643
|
+
* Always returns `null` in `cookie` / `service-key` mode (no browser access
|
|
644
|
+
* token to expose). This is a stable function reference — safe to call in
|
|
645
|
+
* render or event handlers without adding it to effect dependency arrays.
|
|
646
|
+
*/
|
|
647
|
+
getAccessToken: () => string | null;
|
|
559
648
|
}
|
|
560
649
|
/**
|
|
561
650
|
* Subscription context value
|
|
@@ -735,97 +824,6 @@ interface FFIDAnalyticsConfig {
|
|
|
735
824
|
*/
|
|
736
825
|
isActive: boolean;
|
|
737
826
|
}
|
|
738
|
-
/**
|
|
739
|
-
* Discriminant for redirect failures that callers need to handle
|
|
740
|
-
* programmatically (vs. logging the human-readable `error` string).
|
|
741
|
-
*
|
|
742
|
-
* - `'redirect_loop_detected'`: `redirectToAuthorize()` detected that the
|
|
743
|
-
* same authorize URL (keyed by `baseUrl + client_id + organization_id`)
|
|
744
|
-
* has been fired **3 times within 60 seconds**. Caller should surface a
|
|
745
|
-
* manual "再度ログインする" UI rather than retry automatically (#2406 / #2411).
|
|
746
|
-
*
|
|
747
|
-
* - `'state_persistence_failed'`: `redirectToAuthorize()` could not persist
|
|
748
|
-
* the OAuth CSRF `state` (storage unavailable / quota). Redirect is aborted
|
|
749
|
-
* fail-closed (#4136) — callers should surface a manual retry UI.
|
|
750
|
-
*
|
|
751
|
-
* Other failure paths (SSR environment, PKCE generation failure, empty
|
|
752
|
-
* organizationId) currently return `error` without a `code`. Treat this union
|
|
753
|
-
* as forward-extensible and do NOT exhaustively `switch` over it without a
|
|
754
|
-
* `default` branch for consumer code that must stay compatible across SDK
|
|
755
|
-
* upgrades.
|
|
756
|
-
*/
|
|
757
|
-
type FFIDRedirectErrorCode = 'redirect_loop_detected' | 'state_persistence_failed';
|
|
758
|
-
/**
|
|
759
|
-
* Result of a redirect operation (redirectToLogin / redirectToAuthorize / redirectToLogout)
|
|
760
|
-
*
|
|
761
|
-
* Structured return type so callers can inspect failure reasons
|
|
762
|
-
* instead of receiving a bare `false`. When `code` is set, branch on it
|
|
763
|
-
* for programmatic handling; otherwise log `error` for humans.
|
|
764
|
-
*
|
|
765
|
-
* `loopDetectionDisabled` (#4119): set to `true` when sessionStorage is
|
|
766
|
-
* unavailable (iOS WebKit private mode / eviction) so redirect-loop detection
|
|
767
|
-
* ran **fail-open** — the redirect fired, but repeated-redirect protection is
|
|
768
|
-
* disabled for this browser session. Callers that need loop protection on
|
|
769
|
-
* such browsers should add their own max-retry guard.
|
|
770
|
-
*/
|
|
771
|
-
type FFIDRedirectResult = {
|
|
772
|
-
success: true;
|
|
773
|
-
loopDetectionDisabled?: boolean;
|
|
774
|
-
} | {
|
|
775
|
-
success: false;
|
|
776
|
-
error: string;
|
|
777
|
-
code?: FFIDRedirectErrorCode;
|
|
778
|
-
};
|
|
779
|
-
/**
|
|
780
|
-
* OAuth 2.0 token response from FFID token endpoint
|
|
781
|
-
*/
|
|
782
|
-
interface FFIDOAuthTokenResponse {
|
|
783
|
-
access_token: string;
|
|
784
|
-
token_type: 'Bearer';
|
|
785
|
-
expires_in: number;
|
|
786
|
-
refresh_token: string;
|
|
787
|
-
}
|
|
788
|
-
/**
|
|
789
|
-
* RFC 7662 Token Introspection response (raw format from server)
|
|
790
|
-
*
|
|
791
|
-
* Used internally by verifyAccessToken(). Consumers receive the normalized
|
|
792
|
-
* FFIDOAuthUserInfo type instead.
|
|
793
|
-
*
|
|
794
|
-
* @see https://tools.ietf.org/html/rfc7662
|
|
795
|
-
*/
|
|
796
|
-
interface FFIDTokenIntrospectionResponse {
|
|
797
|
-
active: boolean;
|
|
798
|
-
sub?: string;
|
|
799
|
-
email?: string;
|
|
800
|
-
/** Whether the user's email is verified (#3791). Optional for backward compat with older FFID. */
|
|
801
|
-
email_verified?: boolean;
|
|
802
|
-
name?: string;
|
|
803
|
-
picture?: string | null;
|
|
804
|
-
company_name?: string | null;
|
|
805
|
-
department?: string | null;
|
|
806
|
-
position?: string | null;
|
|
807
|
-
phone_number?: string | null;
|
|
808
|
-
scope?: string | null;
|
|
809
|
-
exp?: number;
|
|
810
|
-
iat?: number;
|
|
811
|
-
iss?: string;
|
|
812
|
-
token_type?: 'Bearer';
|
|
813
|
-
client_id?: string;
|
|
814
|
-
organization_id?: string | null;
|
|
815
|
-
organization_name?: string | null;
|
|
816
|
-
subscription?: {
|
|
817
|
-
subscription_id: string | null;
|
|
818
|
-
status: FFIDOAuthUserInfoSubscription['status'];
|
|
819
|
-
/** Optional for backward compat with older FFID (< 5.3.0 / #3353). */
|
|
820
|
-
effective_status?: FFIDOAuthUserInfoSubscription['effectiveStatus'];
|
|
821
|
-
plan_code: string | null;
|
|
822
|
-
seat_model: FFIDOAuthUserInfoSubscription['seatModel'];
|
|
823
|
-
member_role: FFIDOAuthUserInfoSubscription['memberRole'];
|
|
824
|
-
organization_id: string | null;
|
|
825
|
-
organization_name?: string | null;
|
|
826
|
-
has_seat_assignment?: boolean;
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
827
|
|
|
830
828
|
/**
|
|
831
829
|
* FFID Announcements SDK Type Definitions
|
|
@@ -1526,4 +1524,4 @@ interface FFIDInquiryFormPlaceholderContext {
|
|
|
1526
1524
|
}
|
|
1527
1525
|
declare function FFIDInquiryForm({ mode, prefill, organizations, preselectedOrganizationId, categories, termsVersion, privacyVersion, termsHref, privacyHref, turnstileToken, turnstileSlot, onSubmit, onChange, legalLayout, messagePlaceholder, requireCategorySelection, unstyled, classNames, locale, className, }: FFIDInquiryFormProps): react_jsx_runtime.JSX.Element;
|
|
1528
1526
|
|
|
1529
|
-
export { type FFIDInquiryFormSubmitResult as $, type AnnouncementListResponse as A, type
|
|
1527
|
+
export { type FFIDInquiryFormSubmitResult as $, type AnnouncementListResponse as A, type AnnouncementStatus as B, type AnnouncementType as C, EFFECTIVE_SUBSCRIPTION_STATUSES as D, type EffectiveSubscriptionStatus as E, type FFIDSubscriptionStatus as F, FFIDAnnouncementBadge as G, FFIDAnnouncementList as H, type FFIDAnnouncementsError as I, type FFIDAnnouncementsErrorCode as J, type FFIDAnnouncementsServerResponse as K, type ListAnnouncementsOptions as L, type FFIDApiResponseMeta as M, type FFIDCacheConfig as N, type FFIDContextValue as O, type FFIDInquiryCategory as P, type FFIDInquiryCategorySite2026 as Q, FFIDInquiryForm as R, type FFIDInquiryFormCategoryItem as S, type TokenStore as T, type FFIDInquiryFormClassNames as U, type FFIDInquiryFormLegalLayout as V, type FFIDInquiryFormOrganization as W, type FFIDInquiryFormPlaceholderContext as X, type FFIDInquiryFormPrefill as Y, type FFIDInquiryFormProps as Z, type FFIDInquiryFormSubmitData as _, type FFIDOAuthUserInfoSubscription as a, type FFIDJwtClaims as a0, FFIDLoginButton as a1, type FFIDOAuthUserInfoMemberRole as a2, FFIDOrganizationSwitcher as a3, type FFIDSeatModel as a4, type FFIDServiceAccessDenialReason as a5, type FFIDServiceAccessFailPolicy as a6, FFIDSubscriptionBadge as a7, FFIDUserMenu as a8, FFID_INQUIRY_CATEGORIES as a9, FFID_INQUIRY_CATEGORIES_SITE_2026 as aa, type TokenData as ab, type UseFFIDAnnouncementsOptions as ac, type UseFFIDAnnouncementsReturn as ad, createTokenStore as ae, isFFIDInquiryCategorySite2026 as af, useFFIDAnnouncements as ag, type FFIDAnnouncementBadgeClassNames as ah, type FFIDAnnouncementBadgeProps as ai, type FFIDAnnouncementListClassNames as aj, type FFIDAnnouncementListProps as ak, type FFIDLoginButtonProps as al, type FFIDOrganizationSwitcherClassNames as am, type FFIDOrganizationSwitcherProps as an, type FFIDSubscriptionBadgeClassNames as ao, type FFIDSubscriptionBadgeProps as ap, type FFIDUserMenuClassNames as aq, type FFIDUserMenuProps as ar, type FFIDPrompt as b, type FFIDConfig as c, type FFIDApiResponse as d, type FFIDSessionResponse as e, type FFIDSignOutResult as f, type FFIDError as g, type FFIDSubscriptionCheckResponse as h, type FFIDCheckServiceAccessParams as i, type FFIDServiceAccessDecision as j, type FFIDAnalyticsConfig as k, type FFIDVerifyAccessTokenOptions as l, type FFIDOAuthUserInfo as m, type FFIDInquiryCreateParams as n, type FFIDInquiryCreateResponse as o, type FFIDAuthMode as p, type FFIDLogger as q, type FFIDCacheAdapter as r, type FFIDUser as s, type FFIDOrganization as t, type FFIDSubscription as u, type FFIDSubscriptionContextValue as v, type FFIDAnnouncementsClientConfig as w, type FFIDAnnouncementsApiResponse as x, type FFIDAnnouncementsLogger as y, type Announcement as z };
|
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ButtonHTMLAttributes, ReactNode, CSSProperties } from 'react';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Token Store
|
|
6
|
+
*
|
|
7
|
+
* Manages OAuth 2.0 tokens (access + refresh) with dual-storage support.
|
|
8
|
+
* Falls back to in-memory storage when localStorage is unavailable
|
|
9
|
+
* (e.g., Safari private browsing mode).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Token data stored by the token store
|
|
13
|
+
*/
|
|
14
|
+
interface TokenData {
|
|
15
|
+
/** OAuth 2.0 access token */
|
|
16
|
+
accessToken: string;
|
|
17
|
+
/** OAuth 2.0 refresh token */
|
|
18
|
+
refreshToken: string;
|
|
19
|
+
/** Expiration timestamp in milliseconds (Unix epoch) */
|
|
20
|
+
expiresAt: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Token store interface for managing OAuth tokens
|
|
24
|
+
*/
|
|
25
|
+
interface TokenStore {
|
|
26
|
+
/** Get stored tokens (null if not stored) */
|
|
27
|
+
getTokens(): TokenData | null;
|
|
28
|
+
/** Store new tokens */
|
|
29
|
+
setTokens(tokens: TokenData): void;
|
|
30
|
+
/** Clear all stored tokens */
|
|
31
|
+
clearTokens(): void;
|
|
32
|
+
/** Check if access token is expired (with 30s buffer) */
|
|
33
|
+
isAccessTokenExpired(): boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a token store with the specified storage type.
|
|
37
|
+
*
|
|
38
|
+
* When storageType is 'localStorage' (default in browser), falls back
|
|
39
|
+
* to memory if localStorage is not available (e.g., Safari private mode).
|
|
40
|
+
*
|
|
41
|
+
* @param storageType - 'localStorage' (default) or 'memory'
|
|
42
|
+
*/
|
|
43
|
+
declare function createTokenStore(storageType?: 'localStorage' | 'memory'): TokenStore;
|
|
44
|
+
|
|
4
45
|
/** Cache adapter interface for FFID SDK token verification */
|
|
5
46
|
/**
|
|
6
47
|
* Pluggable cache adapter interface.
|
|
@@ -313,6 +354,19 @@ interface FFIDOAuthUserInfoSubscription {
|
|
|
313
354
|
* round-trip.
|
|
314
355
|
*/
|
|
315
356
|
currentPeriodEnd: string | null;
|
|
357
|
+
/**
|
|
358
|
+
* Per-service entitlement codes (e.g. `praxis.pack.<slug>.access`) granting
|
|
359
|
+
* access to one-time / single-pack purchases not encoded in the plan tier
|
|
360
|
+
* (#4333, SDK 5.25.0). Read this list to gate per-pack access; an empty
|
|
361
|
+
* array means "no pack entitlements" (the normal case for Pro / Team tiers
|
|
362
|
+
* that unlock packs via `planCode`).
|
|
363
|
+
*
|
|
364
|
+
* The `normalizeUserinfo` boundary defaults this to `[]` when the server
|
|
365
|
+
* omits it (older FFID pre-#4333) or when the introspect path uses a service
|
|
366
|
+
* API key without `subscription:read`, so consumers always see a plain
|
|
367
|
+
* `readonly string[]` and never branch on an "unknown" sentinel.
|
|
368
|
+
*/
|
|
369
|
+
entitlements: readonly string[];
|
|
316
370
|
}
|
|
317
371
|
/**
|
|
318
372
|
* Unified user-identity shape returned by `getSession()` (→ `/oauth/userinfo`)
|
|
@@ -474,6 +528,29 @@ interface FFIDConfig {
|
|
|
474
528
|
* @default undefined (no timeout, uses fetch default)
|
|
475
529
|
*/
|
|
476
530
|
timeout?: number | undefined;
|
|
531
|
+
/**
|
|
532
|
+
* Token mode only: inject a shared {@link TokenStore} instance so the SDK and
|
|
533
|
+
* the host app read/write the *same* token source (#4318).
|
|
534
|
+
*
|
|
535
|
+
* By default the client creates its own store internally
|
|
536
|
+
* (`createTokenStore()` in `token` mode, `createTokenStore('memory')`
|
|
537
|
+
* otherwise). That is fine when `localStorage` is available, because a
|
|
538
|
+
* separately-created `localStorage` store still points at the same
|
|
539
|
+
* `ffid_tokens` key. But when `localStorage` is unavailable (e.g. Safari
|
|
540
|
+
* Private Mode) the SDK falls back to an *in-memory* store, and a store the
|
|
541
|
+
* host app creates independently is a **different** object — so the app would
|
|
542
|
+
* see the user as signed-out even though the SDK holds valid tokens.
|
|
543
|
+
*
|
|
544
|
+
* Passing a single instance here (typically `createTokenStore()` created once
|
|
545
|
+
* by the host) guarantees both sides share one source of truth regardless of
|
|
546
|
+
* storage backend. Prefer reading the token via `useFFID().getAccessToken()`
|
|
547
|
+
* so refresh/logout stay reflected without the host polling the store.
|
|
548
|
+
*
|
|
549
|
+
* Ignored in `cookie` and `service-key` modes (neither exposes a browser
|
|
550
|
+
* access-token store). When omitted, behavior is unchanged from previous
|
|
551
|
+
* versions.
|
|
552
|
+
*/
|
|
553
|
+
tokenStore?: TokenStore | undefined;
|
|
477
554
|
}
|
|
478
555
|
/**
|
|
479
556
|
* FFID JWT claims structure (minimal payload).
|
|
@@ -556,6 +633,18 @@ interface FFIDContextValue {
|
|
|
556
633
|
switchOrganization: (organizationId: string) => void;
|
|
557
634
|
/** Refresh session data */
|
|
558
635
|
refresh: () => Promise<void>;
|
|
636
|
+
/**
|
|
637
|
+
* Token mode: return the currently-stored access token, or `null` when there
|
|
638
|
+
* is none, it is empty, or it is expired (30s buffer, same as
|
|
639
|
+
* `TokenStore.isAccessTokenExpired`). Reads the store live on every call, so a
|
|
640
|
+
* token the SDK refreshed in the background is reflected without the host
|
|
641
|
+
* caching or polling it (#4318).
|
|
642
|
+
*
|
|
643
|
+
* Always returns `null` in `cookie` / `service-key` mode (no browser access
|
|
644
|
+
* token to expose). This is a stable function reference — safe to call in
|
|
645
|
+
* render or event handlers without adding it to effect dependency arrays.
|
|
646
|
+
*/
|
|
647
|
+
getAccessToken: () => string | null;
|
|
559
648
|
}
|
|
560
649
|
/**
|
|
561
650
|
* Subscription context value
|
|
@@ -735,97 +824,6 @@ interface FFIDAnalyticsConfig {
|
|
|
735
824
|
*/
|
|
736
825
|
isActive: boolean;
|
|
737
826
|
}
|
|
738
|
-
/**
|
|
739
|
-
* Discriminant for redirect failures that callers need to handle
|
|
740
|
-
* programmatically (vs. logging the human-readable `error` string).
|
|
741
|
-
*
|
|
742
|
-
* - `'redirect_loop_detected'`: `redirectToAuthorize()` detected that the
|
|
743
|
-
* same authorize URL (keyed by `baseUrl + client_id + organization_id`)
|
|
744
|
-
* has been fired **3 times within 60 seconds**. Caller should surface a
|
|
745
|
-
* manual "再度ログインする" UI rather than retry automatically (#2406 / #2411).
|
|
746
|
-
*
|
|
747
|
-
* - `'state_persistence_failed'`: `redirectToAuthorize()` could not persist
|
|
748
|
-
* the OAuth CSRF `state` (storage unavailable / quota). Redirect is aborted
|
|
749
|
-
* fail-closed (#4136) — callers should surface a manual retry UI.
|
|
750
|
-
*
|
|
751
|
-
* Other failure paths (SSR environment, PKCE generation failure, empty
|
|
752
|
-
* organizationId) currently return `error` without a `code`. Treat this union
|
|
753
|
-
* as forward-extensible and do NOT exhaustively `switch` over it without a
|
|
754
|
-
* `default` branch for consumer code that must stay compatible across SDK
|
|
755
|
-
* upgrades.
|
|
756
|
-
*/
|
|
757
|
-
type FFIDRedirectErrorCode = 'redirect_loop_detected' | 'state_persistence_failed';
|
|
758
|
-
/**
|
|
759
|
-
* Result of a redirect operation (redirectToLogin / redirectToAuthorize / redirectToLogout)
|
|
760
|
-
*
|
|
761
|
-
* Structured return type so callers can inspect failure reasons
|
|
762
|
-
* instead of receiving a bare `false`. When `code` is set, branch on it
|
|
763
|
-
* for programmatic handling; otherwise log `error` for humans.
|
|
764
|
-
*
|
|
765
|
-
* `loopDetectionDisabled` (#4119): set to `true` when sessionStorage is
|
|
766
|
-
* unavailable (iOS WebKit private mode / eviction) so redirect-loop detection
|
|
767
|
-
* ran **fail-open** — the redirect fired, but repeated-redirect protection is
|
|
768
|
-
* disabled for this browser session. Callers that need loop protection on
|
|
769
|
-
* such browsers should add their own max-retry guard.
|
|
770
|
-
*/
|
|
771
|
-
type FFIDRedirectResult = {
|
|
772
|
-
success: true;
|
|
773
|
-
loopDetectionDisabled?: boolean;
|
|
774
|
-
} | {
|
|
775
|
-
success: false;
|
|
776
|
-
error: string;
|
|
777
|
-
code?: FFIDRedirectErrorCode;
|
|
778
|
-
};
|
|
779
|
-
/**
|
|
780
|
-
* OAuth 2.0 token response from FFID token endpoint
|
|
781
|
-
*/
|
|
782
|
-
interface FFIDOAuthTokenResponse {
|
|
783
|
-
access_token: string;
|
|
784
|
-
token_type: 'Bearer';
|
|
785
|
-
expires_in: number;
|
|
786
|
-
refresh_token: string;
|
|
787
|
-
}
|
|
788
|
-
/**
|
|
789
|
-
* RFC 7662 Token Introspection response (raw format from server)
|
|
790
|
-
*
|
|
791
|
-
* Used internally by verifyAccessToken(). Consumers receive the normalized
|
|
792
|
-
* FFIDOAuthUserInfo type instead.
|
|
793
|
-
*
|
|
794
|
-
* @see https://tools.ietf.org/html/rfc7662
|
|
795
|
-
*/
|
|
796
|
-
interface FFIDTokenIntrospectionResponse {
|
|
797
|
-
active: boolean;
|
|
798
|
-
sub?: string;
|
|
799
|
-
email?: string;
|
|
800
|
-
/** Whether the user's email is verified (#3791). Optional for backward compat with older FFID. */
|
|
801
|
-
email_verified?: boolean;
|
|
802
|
-
name?: string;
|
|
803
|
-
picture?: string | null;
|
|
804
|
-
company_name?: string | null;
|
|
805
|
-
department?: string | null;
|
|
806
|
-
position?: string | null;
|
|
807
|
-
phone_number?: string | null;
|
|
808
|
-
scope?: string | null;
|
|
809
|
-
exp?: number;
|
|
810
|
-
iat?: number;
|
|
811
|
-
iss?: string;
|
|
812
|
-
token_type?: 'Bearer';
|
|
813
|
-
client_id?: string;
|
|
814
|
-
organization_id?: string | null;
|
|
815
|
-
organization_name?: string | null;
|
|
816
|
-
subscription?: {
|
|
817
|
-
subscription_id: string | null;
|
|
818
|
-
status: FFIDOAuthUserInfoSubscription['status'];
|
|
819
|
-
/** Optional for backward compat with older FFID (< 5.3.0 / #3353). */
|
|
820
|
-
effective_status?: FFIDOAuthUserInfoSubscription['effectiveStatus'];
|
|
821
|
-
plan_code: string | null;
|
|
822
|
-
seat_model: FFIDOAuthUserInfoSubscription['seatModel'];
|
|
823
|
-
member_role: FFIDOAuthUserInfoSubscription['memberRole'];
|
|
824
|
-
organization_id: string | null;
|
|
825
|
-
organization_name?: string | null;
|
|
826
|
-
has_seat_assignment?: boolean;
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
827
|
|
|
830
828
|
/**
|
|
831
829
|
* FFID Announcements SDK Type Definitions
|
|
@@ -1526,4 +1524,4 @@ interface FFIDInquiryFormPlaceholderContext {
|
|
|
1526
1524
|
}
|
|
1527
1525
|
declare function FFIDInquiryForm({ mode, prefill, organizations, preselectedOrganizationId, categories, termsVersion, privacyVersion, termsHref, privacyHref, turnstileToken, turnstileSlot, onSubmit, onChange, legalLayout, messagePlaceholder, requireCategorySelection, unstyled, classNames, locale, className, }: FFIDInquiryFormProps): react_jsx_runtime.JSX.Element;
|
|
1528
1526
|
|
|
1529
|
-
export { type FFIDInquiryFormSubmitResult as $, type AnnouncementListResponse as A, type
|
|
1527
|
+
export { type FFIDInquiryFormSubmitResult as $, type AnnouncementListResponse as A, type AnnouncementStatus as B, type AnnouncementType as C, EFFECTIVE_SUBSCRIPTION_STATUSES as D, type EffectiveSubscriptionStatus as E, type FFIDSubscriptionStatus as F, FFIDAnnouncementBadge as G, FFIDAnnouncementList as H, type FFIDAnnouncementsError as I, type FFIDAnnouncementsErrorCode as J, type FFIDAnnouncementsServerResponse as K, type ListAnnouncementsOptions as L, type FFIDApiResponseMeta as M, type FFIDCacheConfig as N, type FFIDContextValue as O, type FFIDInquiryCategory as P, type FFIDInquiryCategorySite2026 as Q, FFIDInquiryForm as R, type FFIDInquiryFormCategoryItem as S, type TokenStore as T, type FFIDInquiryFormClassNames as U, type FFIDInquiryFormLegalLayout as V, type FFIDInquiryFormOrganization as W, type FFIDInquiryFormPlaceholderContext as X, type FFIDInquiryFormPrefill as Y, type FFIDInquiryFormProps as Z, type FFIDInquiryFormSubmitData as _, type FFIDOAuthUserInfoSubscription as a, type FFIDJwtClaims as a0, FFIDLoginButton as a1, type FFIDOAuthUserInfoMemberRole as a2, FFIDOrganizationSwitcher as a3, type FFIDSeatModel as a4, type FFIDServiceAccessDenialReason as a5, type FFIDServiceAccessFailPolicy as a6, FFIDSubscriptionBadge as a7, FFIDUserMenu as a8, FFID_INQUIRY_CATEGORIES as a9, FFID_INQUIRY_CATEGORIES_SITE_2026 as aa, type TokenData as ab, type UseFFIDAnnouncementsOptions as ac, type UseFFIDAnnouncementsReturn as ad, createTokenStore as ae, isFFIDInquiryCategorySite2026 as af, useFFIDAnnouncements as ag, type FFIDAnnouncementBadgeClassNames as ah, type FFIDAnnouncementBadgeProps as ai, type FFIDAnnouncementListClassNames as aj, type FFIDAnnouncementListProps as ak, type FFIDLoginButtonProps as al, type FFIDOrganizationSwitcherClassNames as am, type FFIDOrganizationSwitcherProps as an, type FFIDSubscriptionBadgeClassNames as ao, type FFIDSubscriptionBadgeProps as ap, type FFIDUserMenuClassNames as aq, type FFIDUserMenuProps as ar, type FFIDPrompt as b, type FFIDConfig as c, type FFIDApiResponse as d, type FFIDSessionResponse as e, type FFIDSignOutResult as f, type FFIDError as g, type FFIDSubscriptionCheckResponse as h, type FFIDCheckServiceAccessParams as i, type FFIDServiceAccessDecision as j, type FFIDAnalyticsConfig as k, type FFIDVerifyAccessTokenOptions as l, type FFIDOAuthUserInfo as m, type FFIDInquiryCreateParams as n, type FFIDInquiryCreateResponse as o, type FFIDAuthMode as p, type FFIDLogger as q, type FFIDCacheAdapter as r, type FFIDUser as s, type FFIDOrganization as t, type FFIDSubscription as u, type FFIDSubscriptionContextValue as v, type FFIDAnnouncementsClientConfig as w, type FFIDAnnouncementsApiResponse as x, type FFIDAnnouncementsLogger as y, type Announcement as z };
|