@feelflow/ffid-sdk 5.10.0 → 5.13.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/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkIZSL6DI7_cjs = require('./chunk-IZSL6DI7.cjs');
3
+ var chunkJFFRO2Q5_cjs = require('./chunk-JFFRO2Q5.cjs');
4
4
  var chunkR5WSZMUL_cjs = require('./chunk-R5WSZMUL.cjs');
5
5
  var react = require('react');
6
6
  var jsxRuntime = require('react/jsx-runtime');
@@ -54,8 +54,8 @@ function defaultRedirect(url) {
54
54
  }
55
55
  function useRequireActiveSubscription(options) {
56
56
  const { redirectTo, allowGrace = true, onRedirect } = options;
57
- const { isLoading, error } = chunkIZSL6DI7_cjs.useFFIDContext();
58
- const { effectiveStatus, isBlocked, isGrace } = chunkIZSL6DI7_cjs.useSubscription();
57
+ const { isLoading, error } = chunkJFFRO2Q5_cjs.useFFIDContext();
58
+ const { effectiveStatus, isBlocked, isGrace } = chunkJFFRO2Q5_cjs.useSubscription();
59
59
  const hasFetchError = error !== null && effectiveStatus === null;
60
60
  const shouldRedirect = !isLoading && !hasFetchError && (isBlocked || !allowGrace && isGrace || effectiveStatus === null);
61
61
  react.useEffect(() => {
@@ -76,7 +76,7 @@ function useRequireActiveSubscription(options) {
76
76
  }
77
77
  function withFFIDAuth(Component, options = {}) {
78
78
  const WrappedComponent = (props) => {
79
- const { isLoading, isAuthenticated, login } = chunkIZSL6DI7_cjs.useFFIDContext();
79
+ const { isLoading, isAuthenticated, login } = chunkJFFRO2Q5_cjs.useFFIDContext();
80
80
  const hasRedirected = react.useRef(false);
81
81
  react.useEffect(() => {
82
82
  if (!isLoading && !isAuthenticated && options.redirectToLogin && !hasRedirected.current) {
@@ -105,131 +105,151 @@ var FFID_NEWSLETTER_DISPATCH_MAX_RECIPIENTS = 1e3;
105
105
 
106
106
  Object.defineProperty(exports, "ACCESS_GRANTING_EFFECTIVE_STATUSES", {
107
107
  enumerable: true,
108
- get: function () { return chunkIZSL6DI7_cjs.ACCESS_GRANTING_EFFECTIVE_STATUSES; }
108
+ get: function () { return chunkJFFRO2Q5_cjs.ACCESS_GRANTING_EFFECTIVE_STATUSES; }
109
109
  });
110
110
  Object.defineProperty(exports, "BLOCKING_EFFECTIVE_STATUSES", {
111
111
  enumerable: true,
112
- get: function () { return chunkIZSL6DI7_cjs.BLOCKING_EFFECTIVE_STATUSES; }
112
+ get: function () { return chunkJFFRO2Q5_cjs.BLOCKING_EFFECTIVE_STATUSES; }
113
113
  });
114
114
  Object.defineProperty(exports, "DEFAULT_API_BASE_URL", {
115
115
  enumerable: true,
116
- get: function () { return chunkIZSL6DI7_cjs.DEFAULT_API_BASE_URL; }
116
+ get: function () { return chunkJFFRO2Q5_cjs.DEFAULT_API_BASE_URL; }
117
117
  });
118
118
  Object.defineProperty(exports, "DEFAULT_OAUTH_SCOPES", {
119
119
  enumerable: true,
120
- get: function () { return chunkIZSL6DI7_cjs.DEFAULT_OAUTH_SCOPES; }
120
+ get: function () { return chunkJFFRO2Q5_cjs.DEFAULT_OAUTH_SCOPES; }
121
+ });
122
+ Object.defineProperty(exports, "EFFECTIVE_SUBSCRIPTION_STATUSES", {
123
+ enumerable: true,
124
+ get: function () { return chunkJFFRO2Q5_cjs.EFFECTIVE_SUBSCRIPTION_STATUSES; }
121
125
  });
122
126
  Object.defineProperty(exports, "FFIDAnnouncementBadge", {
123
127
  enumerable: true,
124
- get: function () { return chunkIZSL6DI7_cjs.FFIDAnnouncementBadge; }
128
+ get: function () { return chunkJFFRO2Q5_cjs.FFIDAnnouncementBadge; }
125
129
  });
126
130
  Object.defineProperty(exports, "FFIDAnnouncementList", {
127
131
  enumerable: true,
128
- get: function () { return chunkIZSL6DI7_cjs.FFIDAnnouncementList; }
132
+ get: function () { return chunkJFFRO2Q5_cjs.FFIDAnnouncementList; }
129
133
  });
130
134
  Object.defineProperty(exports, "FFIDInquiryForm", {
131
135
  enumerable: true,
132
- get: function () { return chunkIZSL6DI7_cjs.FFIDInquiryForm; }
136
+ get: function () { return chunkJFFRO2Q5_cjs.FFIDInquiryForm; }
133
137
  });
134
138
  Object.defineProperty(exports, "FFIDLoginButton", {
135
139
  enumerable: true,
136
- get: function () { return chunkIZSL6DI7_cjs.FFIDLoginButton; }
140
+ get: function () { return chunkJFFRO2Q5_cjs.FFIDLoginButton; }
137
141
  });
138
142
  Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
139
143
  enumerable: true,
140
- get: function () { return chunkIZSL6DI7_cjs.FFIDOrganizationSwitcher; }
144
+ get: function () { return chunkJFFRO2Q5_cjs.FFIDOrganizationSwitcher; }
141
145
  });
142
146
  Object.defineProperty(exports, "FFIDProvider", {
143
147
  enumerable: true,
144
- get: function () { return chunkIZSL6DI7_cjs.FFIDProvider; }
148
+ get: function () { return chunkJFFRO2Q5_cjs.FFIDProvider; }
145
149
  });
146
150
  Object.defineProperty(exports, "FFIDSDKError", {
147
151
  enumerable: true,
148
- get: function () { return chunkIZSL6DI7_cjs.FFIDSDKError; }
152
+ get: function () { return chunkJFFRO2Q5_cjs.FFIDSDKError; }
149
153
  });
150
154
  Object.defineProperty(exports, "FFIDSubscriptionBadge", {
151
155
  enumerable: true,
152
- get: function () { return chunkIZSL6DI7_cjs.FFIDSubscriptionBadge; }
156
+ get: function () { return chunkJFFRO2Q5_cjs.FFIDSubscriptionBadge; }
153
157
  });
154
158
  Object.defineProperty(exports, "FFIDUserMenu", {
155
159
  enumerable: true,
156
- get: function () { return chunkIZSL6DI7_cjs.FFIDUserMenu; }
160
+ get: function () { return chunkJFFRO2Q5_cjs.FFIDUserMenu; }
157
161
  });
158
162
  Object.defineProperty(exports, "FFID_ANNOUNCEMENTS_ERROR_CODES", {
159
163
  enumerable: true,
160
- get: function () { return chunkIZSL6DI7_cjs.FFID_ANNOUNCEMENTS_ERROR_CODES; }
164
+ get: function () { return chunkJFFRO2Q5_cjs.FFID_ANNOUNCEMENTS_ERROR_CODES; }
161
165
  });
162
166
  Object.defineProperty(exports, "FFID_INQUIRY_CATEGORIES", {
163
167
  enumerable: true,
164
- get: function () { return chunkIZSL6DI7_cjs.FFID_INQUIRY_CATEGORIES; }
168
+ get: function () { return chunkJFFRO2Q5_cjs.FFID_INQUIRY_CATEGORIES; }
165
169
  });
166
170
  Object.defineProperty(exports, "FFID_INQUIRY_CATEGORIES_SITE_2026", {
167
171
  enumerable: true,
168
- get: function () { return chunkIZSL6DI7_cjs.FFID_INQUIRY_CATEGORIES_SITE_2026; }
172
+ get: function () { return chunkJFFRO2Q5_cjs.FFID_INQUIRY_CATEGORIES_SITE_2026; }
173
+ });
174
+ Object.defineProperty(exports, "clearState", {
175
+ enumerable: true,
176
+ get: function () { return chunkJFFRO2Q5_cjs.cleanupStateStorage; }
169
177
  });
170
178
  Object.defineProperty(exports, "computeEffectiveStatusFromSession", {
171
179
  enumerable: true,
172
- get: function () { return chunkIZSL6DI7_cjs.computeEffectiveStatusFromSession; }
180
+ get: function () { return chunkJFFRO2Q5_cjs.computeEffectiveStatusFromSession; }
173
181
  });
174
182
  Object.defineProperty(exports, "createFFIDAnnouncementsClient", {
175
183
  enumerable: true,
176
- get: function () { return chunkIZSL6DI7_cjs.createFFIDAnnouncementsClient; }
184
+ get: function () { return chunkJFFRO2Q5_cjs.createFFIDAnnouncementsClient; }
177
185
  });
178
186
  Object.defineProperty(exports, "createFFIDClient", {
179
187
  enumerable: true,
180
- get: function () { return chunkIZSL6DI7_cjs.createFFIDClient; }
188
+ get: function () { return chunkJFFRO2Q5_cjs.createFFIDClient; }
181
189
  });
182
190
  Object.defineProperty(exports, "createTokenStore", {
183
191
  enumerable: true,
184
- get: function () { return chunkIZSL6DI7_cjs.createTokenStore; }
192
+ get: function () { return chunkJFFRO2Q5_cjs.createTokenStore; }
185
193
  });
186
194
  Object.defineProperty(exports, "generateCodeChallenge", {
187
195
  enumerable: true,
188
- get: function () { return chunkIZSL6DI7_cjs.generateCodeChallenge; }
196
+ get: function () { return chunkJFFRO2Q5_cjs.generateCodeChallenge; }
189
197
  });
190
198
  Object.defineProperty(exports, "generateCodeVerifier", {
191
199
  enumerable: true,
192
- get: function () { return chunkIZSL6DI7_cjs.generateCodeVerifier; }
200
+ get: function () { return chunkJFFRO2Q5_cjs.generateCodeVerifier; }
201
+ });
202
+ Object.defineProperty(exports, "handleRedirectCallback", {
203
+ enumerable: true,
204
+ get: function () { return chunkJFFRO2Q5_cjs.handleRedirectCallback; }
193
205
  });
194
206
  Object.defineProperty(exports, "hasAccessFromUserinfo", {
195
207
  enumerable: true,
196
- get: function () { return chunkIZSL6DI7_cjs.hasAccessFromUserinfo; }
208
+ get: function () { return chunkJFFRO2Q5_cjs.hasAccessFromUserinfo; }
197
209
  });
198
210
  Object.defineProperty(exports, "isBlockedFromUserinfo", {
199
211
  enumerable: true,
200
- get: function () { return chunkIZSL6DI7_cjs.isBlockedFromUserinfo; }
212
+ get: function () { return chunkJFFRO2Q5_cjs.isBlockedFromUserinfo; }
201
213
  });
202
214
  Object.defineProperty(exports, "isFFIDInquiryCategorySite2026", {
203
215
  enumerable: true,
204
- get: function () { return chunkIZSL6DI7_cjs.isFFIDInquiryCategorySite2026; }
216
+ get: function () { return chunkJFFRO2Q5_cjs.isFFIDInquiryCategorySite2026; }
205
217
  });
206
218
  Object.defineProperty(exports, "normalizeRedirectUri", {
207
219
  enumerable: true,
208
- get: function () { return chunkIZSL6DI7_cjs.normalizeRedirectUri; }
220
+ get: function () { return chunkJFFRO2Q5_cjs.normalizeRedirectUri; }
209
221
  });
210
222
  Object.defineProperty(exports, "retrieveCodeVerifier", {
211
223
  enumerable: true,
212
- get: function () { return chunkIZSL6DI7_cjs.retrieveCodeVerifier; }
224
+ get: function () { return chunkJFFRO2Q5_cjs.retrieveCodeVerifier; }
225
+ });
226
+ Object.defineProperty(exports, "retrieveState", {
227
+ enumerable: true,
228
+ get: function () { return chunkJFFRO2Q5_cjs.retrieveState; }
213
229
  });
214
230
  Object.defineProperty(exports, "storeCodeVerifier", {
215
231
  enumerable: true,
216
- get: function () { return chunkIZSL6DI7_cjs.storeCodeVerifier; }
232
+ get: function () { return chunkJFFRO2Q5_cjs.storeCodeVerifier; }
233
+ });
234
+ Object.defineProperty(exports, "storeState", {
235
+ enumerable: true,
236
+ get: function () { return chunkJFFRO2Q5_cjs.storeState; }
217
237
  });
218
238
  Object.defineProperty(exports, "useFFID", {
219
239
  enumerable: true,
220
- get: function () { return chunkIZSL6DI7_cjs.useFFID; }
240
+ get: function () { return chunkJFFRO2Q5_cjs.useFFID; }
221
241
  });
222
242
  Object.defineProperty(exports, "useFFIDAnnouncements", {
223
243
  enumerable: true,
224
- get: function () { return chunkIZSL6DI7_cjs.useFFIDAnnouncements; }
244
+ get: function () { return chunkJFFRO2Q5_cjs.useFFIDAnnouncements; }
225
245
  });
226
246
  Object.defineProperty(exports, "useSubscription", {
227
247
  enumerable: true,
228
- get: function () { return chunkIZSL6DI7_cjs.useSubscription; }
248
+ get: function () { return chunkJFFRO2Q5_cjs.useSubscription; }
229
249
  });
230
250
  Object.defineProperty(exports, "withSubscription", {
231
251
  enumerable: true,
232
- get: function () { return chunkIZSL6DI7_cjs.withSubscription; }
252
+ get: function () { return chunkJFFRO2Q5_cjs.withSubscription; }
233
253
  });
234
254
  Object.defineProperty(exports, "ALL_DENIED_EXCEPT_NECESSARY", {
235
255
  enumerable: true,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FFIDSubscriptionStatus, a as FFIDConfig, b as FFIDApiResponse, c as FFIDSessionResponse, d as FFIDRedirectResult, e as FFIDError, f as FFIDSubscriptionCheckResponse, g as FFIDCheckServiceAccessParams, h as FFIDServiceAccessDecision, i as FFIDProfileCallOptions, j as FFIDUserProfile, k as FFIDUpdateUserProfileRequest, l as FFIDAnalyticsConfig, m as FFIDCreateCheckoutParams, n as FFIDCheckoutSessionResponse, o as FFIDCreatePortalParams, p as FFIDPortalSessionResponse, q as FFIDVerifyAccessTokenOptions, r as FFIDOAuthUserInfo, s as FFIDInquiryCreateParams, t as FFIDInquiryCreateResponse, u as FFIDAuthMode, v as FFIDLogger, w as FFIDCacheAdapter, x as FFIDUser, y as FFIDOrganization, z as FFIDSubscription, A as FFIDSubscriptionContextValue, E as EffectiveSubscriptionStatus, B as FFIDOAuthUserInfoSubscription, C as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, D as FFIDAnnouncementsApiResponse, G as AnnouncementListResponse, H as FFIDAnnouncementsLogger } from './index-DSvX4q8E.cjs';
2
- export { I as Announcement, J as AnnouncementStatus, K as AnnouncementType, M as FFIDAnnouncementBadge, N as FFIDAnnouncementList, O as FFIDAnnouncementsError, P as FFIDAnnouncementsErrorCode, Q as FFIDAnnouncementsServerResponse, R as FFIDCacheConfig, S as FFIDContextValue, T as FFIDInquiryCategory, U as FFIDInquiryCategorySite2026, V as FFIDInquiryForm, W as FFIDInquiryFormCategoryItem, X as FFIDInquiryFormClassNames, Y as FFIDInquiryFormLegalLayout, Z as FFIDInquiryFormOrganization, _ as FFIDInquiryFormPlaceholderContext, $ as FFIDInquiryFormPrefill, a0 as FFIDInquiryFormProps, a1 as FFIDInquiryFormSubmitData, a2 as FFIDInquiryFormSubmitResult, a3 as FFIDJwtClaims, a4 as FFIDLoginButton, a5 as FFIDOAuthTokenResponse, a6 as FFIDOAuthUserInfoMemberRole, a7 as FFIDOrganizationSwitcher, a8 as FFIDRedirectErrorCode, a9 as FFIDSeatModel, aa as FFIDServiceAccessDenialReason, ab as FFIDServiceAccessFailPolicy, ac as FFIDSubscriptionBadge, ad as FFIDTokenIntrospectionResponse, ae as FFIDUserMenu, af as FFID_INQUIRY_CATEGORIES, ag as FFID_INQUIRY_CATEGORIES_SITE_2026, ah as UseFFIDAnnouncementsOptions, ai as UseFFIDAnnouncementsReturn, aj as isFFIDInquiryCategorySite2026, ak as useFFIDAnnouncements } from './index-DSvX4q8E.cjs';
1
+ import { F as FFIDSubscriptionStatus, a as FFIDConfig, b as FFIDApiResponse, c as FFIDSessionResponse, d as FFIDRedirectResult, e as FFIDError, f as FFIDSubscriptionCheckResponse, g as FFIDCheckServiceAccessParams, h as FFIDServiceAccessDecision, i as FFIDProfileCallOptions, j as FFIDUserProfile, k as FFIDUpdateUserProfileRequest, l as FFIDAnalyticsConfig, m as FFIDVerifyAccessTokenOptions, n as FFIDOAuthUserInfo, o as FFIDInquiryCreateParams, p as FFIDInquiryCreateResponse, q as FFIDAuthMode, r as FFIDLogger, s as FFIDCacheAdapter, t as FFIDUser, u as FFIDOrganization, v as FFIDSubscription, w as FFIDSubscriptionContextValue, E as EffectiveSubscriptionStatus, x as FFIDOAuthUserInfoSubscription, y as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, z as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, B as FFIDAnnouncementsLogger } from './index-C6dnexXf.cjs';
2
+ export { C as Announcement, D as AnnouncementStatus, G as AnnouncementType, H as EFFECTIVE_SUBSCRIPTION_STATUSES, I as FFIDAnnouncementBadge, J as FFIDAnnouncementList, K as FFIDAnnouncementsError, M as FFIDAnnouncementsErrorCode, N as FFIDAnnouncementsServerResponse, O as FFIDCacheConfig, P as FFIDContextValue, Q as FFIDInquiryCategory, R as FFIDInquiryCategorySite2026, S as FFIDInquiryForm, T 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 FFIDOAuthTokenResponse, a3 as FFIDOAuthUserInfoMemberRole, a4 as FFIDOrganizationSwitcher, a5 as FFIDRedirectErrorCode, a6 as FFIDSeatModel, a7 as FFIDServiceAccessDenialReason, a8 as FFIDServiceAccessFailPolicy, a9 as FFIDSubscriptionBadge, aa as FFIDTokenIntrospectionResponse, ab as FFIDUserMenu, ac as FFID_INQUIRY_CATEGORIES, ad as FFID_INQUIRY_CATEGORIES_SITE_2026, ae as UseFFIDAnnouncementsOptions, af as UseFFIDAnnouncementsReturn, ag as isFFIDInquiryCategorySite2026, ah as useFFIDAnnouncements } from './index-C6dnexXf.cjs';
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-D1WwE_ZO.cjs';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { ReactNode, ComponentType, FC } from 'react';
@@ -122,6 +122,81 @@ declare function storeCodeVerifier(verifier: string, logger?: PKCELogger): boole
122
122
  */
123
123
  declare function retrieveCodeVerifier(logger?: PKCELogger): string | null;
124
124
 
125
+ /** Logger interface matching FFIDLogger for optional warning output */
126
+ interface StateLogger {
127
+ warn: (...args: unknown[]) => void;
128
+ }
129
+ /**
130
+ * Store the OAuth `state` for later retrieval.
131
+ *
132
+ * Writes to both sessionStorage (primary) and localStorage (fallback for iOS
133
+ * WebKit sessionStorage eviction during external OAuth bounces). Returns true
134
+ * if at least one write succeeded.
135
+ *
136
+ * @param state - The OAuth state value to store
137
+ * @param logger - Optional logger for warning on storage failure
138
+ * @returns true if stored in at least one storage, false otherwise
139
+ */
140
+ declare function storeState(state: string, logger?: StateLogger): boolean;
141
+ /**
142
+ * Retrieve and remove the OAuth `state`.
143
+ *
144
+ * Reads from sessionStorage first, falls back to localStorage (with 5-minute TTL).
145
+ * Removes from all storages after retrieval (one-time use). Returns null if no
146
+ * state is stored, the fallback is stale (>5 min), or storage is unavailable.
147
+ *
148
+ * @param logger - Optional logger for warning on storage failure
149
+ */
150
+ declare function retrieveState(logger?: StateLogger): string | null;
151
+
152
+ declare function cleanupStateStorage(logger?: StateLogger): void;
153
+
154
+ /**
155
+ * Billing checkout / portal session types.
156
+ *
157
+ * types/index.ts のサイズ上限対応で切り出し(中身は逐語移設、#3787 Phase A)。
158
+ */
159
+ /**
160
+ * Checkout session response from billing checkout endpoint
161
+ */
162
+ interface FFIDCheckoutSessionResponse {
163
+ /** Stripe Checkout session ID */
164
+ sessionId: string;
165
+ /** Stripe Checkout session URL (null if session creation had issues) */
166
+ url: string | null;
167
+ }
168
+ /**
169
+ * Portal session response from billing portal endpoint
170
+ */
171
+ interface FFIDPortalSessionResponse {
172
+ /** Stripe Billing Portal URL */
173
+ url: string;
174
+ }
175
+ /**
176
+ * Parameters for creating a checkout session
177
+ */
178
+ interface FFIDCreateCheckoutParams {
179
+ /** Organization ID (UUID) */
180
+ organizationId: string;
181
+ /** Subscription ID (UUID) */
182
+ subscriptionId: string;
183
+ /** URL to redirect after successful checkout */
184
+ successUrl: string;
185
+ /** URL to redirect after cancelled checkout */
186
+ cancelUrl: string;
187
+ /** Optional plan ID for upgrade or resubscription */
188
+ planId?: string;
189
+ }
190
+ /**
191
+ * Parameters for creating a billing portal session
192
+ */
193
+ interface FFIDCreatePortalParams {
194
+ /** Organization ID (UUID) */
195
+ organizationId: string;
196
+ /** URL to redirect when user exits the portal */
197
+ returnUrl: string;
198
+ }
199
+
125
200
  /** Billing interval for subscriptions */
126
201
  type FFIDBillingInterval = 'monthly' | 'yearly';
127
202
  /**
@@ -489,6 +564,122 @@ interface FFIDRemoveMemberResponse {
489
564
  message: string;
490
565
  }
491
566
 
567
+ /**
568
+ * Contract resource types (#3787 Phase A)
569
+ *
570
+ * シート割り当て・請求書・支払い再試行の ext API 型。
571
+ * サーバー側の sanitize 済みレスポンス(Stripe 内部 ID を含まない)と対になる。
572
+ */
573
+ /** シート割り当て 1 件(ユーザー情報付き、一覧用) */
574
+ interface FFIDSeatAssignmentWithUser {
575
+ userId: string;
576
+ email: string;
577
+ name: string | null;
578
+ role: string;
579
+ assignedAt: string;
580
+ assignedBy: string | null;
581
+ }
582
+ /** シート割り当てレコード(割り当て直後のレスポンス用) */
583
+ interface FFIDSeatAssignmentRecord {
584
+ id: string;
585
+ subscriptionId: string;
586
+ userId: string;
587
+ assignedBy: string | null;
588
+ assignedAt: string;
589
+ createdAt: string;
590
+ updatedAt: string;
591
+ }
592
+ /** GET /api/v1/subscriptions/ext/{id}/seats/assignments のレスポンス */
593
+ interface FFIDListSeatAssignmentsResponse {
594
+ assignments: FFIDSeatAssignmentWithUser[];
595
+ totalSeats: number;
596
+ assignedSeats: number;
597
+ availableSeats: number;
598
+ }
599
+ /** listSeatAssignments のパラメータ */
600
+ interface FFIDListSeatAssignmentsParams {
601
+ subscriptionId: string;
602
+ }
603
+ /** assignSeats のパラメータ */
604
+ interface FFIDAssignSeatsParams {
605
+ subscriptionId: string;
606
+ userIds: string[];
607
+ }
608
+ /** POST /api/v1/subscriptions/ext/{id}/seats/assignments のレスポンス */
609
+ interface FFIDAssignSeatsResponse {
610
+ message: string;
611
+ assignments: FFIDSeatAssignmentRecord[];
612
+ }
613
+ /** unassignSeat のパラメータ */
614
+ interface FFIDUnassignSeatParams {
615
+ subscriptionId: string;
616
+ userId: string;
617
+ }
618
+ /** DELETE /api/v1/subscriptions/ext/{id}/seats/assignments/{userId} のレスポンス */
619
+ interface FFIDUnassignSeatResponse {
620
+ message: string;
621
+ }
622
+ /** 請求書サマリー(一覧用) */
623
+ interface FFIDInvoiceSummary {
624
+ id: string;
625
+ organizationId: string;
626
+ subscriptionId: string | null;
627
+ invoiceNumber: string;
628
+ description: string | null;
629
+ subtotal: number;
630
+ taxRate: number;
631
+ taxAmount: number;
632
+ totalAmount: number;
633
+ currency: string;
634
+ status: string;
635
+ issuedAt: string | null;
636
+ dueDate: string | null;
637
+ paidAt: string | null;
638
+ pdfUrl: string | null;
639
+ createdAt: string;
640
+ }
641
+ /** 請求書詳細(請求先情報・備考を含む) */
642
+ interface FFIDInvoiceDetail extends FFIDInvoiceSummary {
643
+ billingName: string | null;
644
+ billingEmail: string | null;
645
+ notes: string | null;
646
+ }
647
+ /** listInvoices のパラメータ */
648
+ interface FFIDListInvoicesParams {
649
+ organizationId: string;
650
+ }
651
+ /** GET /api/v1/billing/ext/invoices のレスポンス */
652
+ interface FFIDListInvoicesResponse {
653
+ invoices: FFIDInvoiceSummary[];
654
+ count: number;
655
+ }
656
+ /** getInvoice のパラメータ */
657
+ interface FFIDGetInvoiceParams {
658
+ invoiceId: string;
659
+ }
660
+ /** GET /api/v1/billing/ext/invoices/{id} のレスポンス */
661
+ interface FFIDGetInvoiceResponse {
662
+ invoice: FFIDInvoiceDetail;
663
+ }
664
+ /** retryPayment のパラメータ */
665
+ interface FFIDRetryPaymentParams {
666
+ organizationId: string;
667
+ }
668
+ /** 再試行に失敗した契約の詳細 */
669
+ interface FFIDRetryPaymentFailure {
670
+ subscriptionId: string;
671
+ reason: string;
672
+ stripeCode?: string;
673
+ }
674
+ /** POST /api/v1/billing/ext/retry-payment のレスポンス */
675
+ interface FFIDRetryPaymentSummary {
676
+ totalAttempted: number;
677
+ succeeded: number;
678
+ failed: number;
679
+ noOpenInvoice: number;
680
+ failures: FFIDRetryPaymentFailure[];
681
+ }
682
+
492
683
  /** OTP / magic link methods - sendOtp / verifyOtp */
493
684
 
494
685
  /** Response from sendOtp */
@@ -554,6 +745,25 @@ interface ContractWizardSubscriptionOptions {
554
745
  organizationId?: string;
555
746
  }
556
747
 
748
+ /** OAuth token operations - exchangeCodeForTokens / refreshAccessToken / signOutToken */
749
+
750
+ /**
751
+ * Optional OAuth `state` validation for {@link exchangeCodeForTokens}.
752
+ *
753
+ * If a `state` is supplied on EITHER side — `expectedState` (the value persisted
754
+ * at `redirectToAuthorize`) or `actualState` (the value returned on the callback
755
+ * URL) — both must be present and equal before any token exchange. A mismatch
756
+ * OR an omitted counterpart fails closed (no exchange) to defend against CSRF
757
+ * (RFC 6749 §10.12 / #3841). Validation is skipped only when BOTH are omitted
758
+ * (backward compatible — callers that don't opt in are unaffected).
759
+ */
760
+ interface ExchangeCodeForTokensOptions {
761
+ /** Stored state from `redirectToAuthorize` (e.g. `retrieveState()`) */
762
+ expectedState?: string;
763
+ /** State returned on the OAuth callback URL */
764
+ actualState?: string;
765
+ }
766
+
557
767
  /** Redirect and URL generation - redirectToLogin / redirectToAuthorize / redirectToLogout / getLoginUrl / getSignupUrl / getLogoutUrl */
558
768
 
559
769
  /**
@@ -593,7 +803,7 @@ declare function createFFIDClient(config: FFIDConfig): {
593
803
  getLogoutUrl: (postLogoutRedirectUri?: string) => string;
594
804
  getSignupUrl: (redirectUrl?: string) => string;
595
805
  createError: (code: string, message: string) => FFIDError;
596
- exchangeCodeForTokens: (code: string, codeVerifier?: string) => Promise<FFIDApiResponse<void>>;
806
+ exchangeCodeForTokens: (code: string, codeVerifier?: string, opts?: ExchangeCodeForTokensOptions) => Promise<FFIDApiResponse<void>>;
597
807
  refreshAccessToken: () => Promise<FFIDApiResponse<void>>;
598
808
  checkSubscription: (params: {
599
809
  userId?: string;
@@ -622,6 +832,12 @@ declare function createFFIDClient(config: FFIDConfig): {
622
832
  getAnalyticsConfig: (serviceCode: string, options?: FFIDProfileCallOptions) => Promise<FFIDApiResponse<FFIDAnalyticsConfig>>;
623
833
  createCheckoutSession: (params: FFIDCreateCheckoutParams) => Promise<FFIDApiResponse<FFIDCheckoutSessionResponse>>;
624
834
  createPortalSession: (params: FFIDCreatePortalParams) => Promise<FFIDApiResponse<FFIDPortalSessionResponse>>;
835
+ listInvoices: (params: FFIDListInvoicesParams) => Promise<FFIDApiResponse<FFIDListInvoicesResponse>>;
836
+ getInvoice: (params: FFIDGetInvoiceParams) => Promise<FFIDApiResponse<FFIDGetInvoiceResponse>>;
837
+ retryPayment: (params: FFIDRetryPaymentParams) => Promise<FFIDApiResponse<FFIDRetryPaymentSummary>>;
838
+ listSeatAssignments: (params: FFIDListSeatAssignmentsParams) => Promise<FFIDApiResponse<FFIDListSeatAssignmentsResponse>>;
839
+ assignSeats: (params: FFIDAssignSeatsParams) => Promise<FFIDApiResponse<FFIDAssignSeatsResponse>>;
840
+ unassignSeat: (params: FFIDUnassignSeatParams) => Promise<FFIDApiResponse<FFIDUnassignSeatResponse>>;
625
841
  listPlans: () => Promise<FFIDApiResponse<FFIDListPlansResponse>>;
626
842
  getSubscription: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDSubscriptionDetail>>;
627
843
  subscribe: (params: FFIDSubscribeParams) => Promise<FFIDApiResponse<FFIDSubscribeResponse>>;
@@ -689,6 +905,52 @@ declare class FFIDSDKError extends Error {
689
905
  constructor(code: string, message: string);
690
906
  }
691
907
 
908
+ /**
909
+ * OAuth redirect callback handler
910
+ *
911
+ * `handleRedirectCallback` is the convenience counterpart to
912
+ * `redirectToAuthorize`: it reads `code` + `state` from the callback URL,
913
+ * validates the OAuth `state` against the value persisted at authorize time
914
+ * (CSRF protection, RFC 6749 §10.12), retrieves the PKCE verifier, exchanges
915
+ * the code for tokens, and cleans the params out of the URL on success.
916
+ */
917
+
918
+ /**
919
+ * Minimal client surface required by {@link handleRedirectCallback}.
920
+ * A full {@link FFIDClient} satisfies this structurally.
921
+ */
922
+ type HandleRedirectCallbackClient = Pick<FFIDClient, 'exchangeCodeForTokens' | 'createError' | 'logger'>;
923
+ /** Options for {@link handleRedirectCallback} */
924
+ interface HandleRedirectCallbackOptions {
925
+ /**
926
+ * Callback URL (or query string) to read `code` / `state` from. Accepts an
927
+ * absolute URL, a relative URL, or a bare query string. Defaults to
928
+ * `window.location.search` in the browser.
929
+ */
930
+ url?: string;
931
+ }
932
+ /**
933
+ * Complete an OAuth authorization-code redirect.
934
+ *
935
+ * Behavior:
936
+ * 1. Reads `code` + `state` from `options.url ?? window.location.search`.
937
+ * 2. CSRF guard: if a `state` exists on EITHER side (a stored state from
938
+ * authorize OR a `state` on the callback URL), the two MUST match — mismatch,
939
+ * a missing stored state, or an **omitted** callback `state` all **fail closed**
940
+ * (returns an error, performs no exchange). Validation is skipped ONLY when
941
+ * neither side has any state (a genuine no-state flow). Omitting the callback
942
+ * `state` does NOT bypass the check (#3841).
943
+ * 3. Retrieves the PKCE verifier and exchanges the code for tokens.
944
+ * 4. On success, removes `code` + `state` from the browser URL.
945
+ *
946
+ * SSR-safe: when there is no `window` and no `options.url`, no exchange is
947
+ * attempted and an error result is returned.
948
+ *
949
+ * @param client - FFID client (or any object exposing exchangeCodeForTokens / createError / logger)
950
+ * @param options - Optional callback URL override
951
+ */
952
+ declare function handleRedirectCallback(client: HandleRedirectCallbackClient, options?: HandleRedirectCallbackOptions): Promise<FFIDApiResponse<void>>;
953
+
692
954
  /**
693
955
  * Redirect URI normalization (SDK copy)
694
956
  *
@@ -1397,4 +1659,4 @@ declare function createInquiryMethods(deps: InquiryMethodsDeps): {
1397
1659
  };
1398
1660
  type FFIDInquiryClient = ReturnType<typeof createInquiryMethods>;
1399
1661
 
1400
- 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 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, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, type FFIDInquiryClient, FFIDInquiryCreateParams, FFIDInquiryCreateResponse, type FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, 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 FFIDOrganizationMember, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreview, type FFIDPlanChangePreviewResponse, type FFIDPlanInfo, FFIDPortalSessionResponse, type FFIDPreviewPlanChangeParams, type FFIDPreviewSeatChangeParams, FFIDProfileCallOptions, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, type FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSDKError, type FFIDSeatChangeLineItem, type FFIDSeatChangePreview, type FFIDSeatChangePreviewResponse, FFIDServiceAccessDecision, type FFIDServiceInfo, FFIDSessionResponse, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, type FFIDSupportedCurrency, type FFIDUpdateMemberRoleResponse, FFIDUpdateUserProfileRequest, FFIDUser, FFIDUserProfile, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_NEWSLETTER_DISPATCH_MAX_RECIPIENTS, FFID_NEWSLETTER_TYPES, type KVNamespaceLike, ListAnnouncementsOptions, type NormalizeRedirectUriResult, type RedirectToAuthorizeOptions, type TokenData, type TokenStore, type UseFFIDReturn, type UseRequireActiveSubscriptionOptions, type UseRequireActiveSubscriptionReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, hasAccessFromUserinfo, isBlockedFromUserinfo, normalizeRedirectUri, retrieveCodeVerifier, storeCodeVerifier, useFFID, useRequireActiveSubscription, useSubscription, withFFIDAuth, withSubscription };
1662
+ export { ACCESS_GRANTING_EFFECTIVE_STATUSES, AnnouncementListResponse, BLOCKING_EFFECTIVE_STATUSES, type ComputeEffectiveStatusInput, type ContractWizardFlowType, type ContractWizardResubscribeOptions, type ContractWizardSubscribeOptions, type ContractWizardSubscriptionOptions, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EffectiveSubscriptionStatus, type ExchangeCodeForTokensOptions, type FFIDAddMemberParams, type FFIDAddMemberRequest, type FFIDAddMemberResponse, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, type FFIDAssignableMemberRole, type FFIDBillingInterval, FFIDCacheAdapter, type FFIDCancelPendingDowngradeResponse, type FFIDCancelSubscriptionParams, type FFIDCancelSubscriptionResponse, type FFIDChangePlanParams, type FFIDChangePlanResponse, FFIDCheckServiceAccessParams, type FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, type FFIDCreateCheckoutParams, type FFIDCreatePortalParams, FFIDError, type FFIDInquiryClient, FFIDInquiryCreateParams, FFIDInquiryCreateResponse, type FFIDListMembersResponse, type FFIDListPlansResponse, FFIDLogger, 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 FFIDOrganizationMember, type FFIDOtpSendResponse, type FFIDOtpVerifyResponse, type FFIDPasswordResetConfirmResponse, type FFIDPasswordResetResponse, type FFIDPasswordResetVerifyResponse, type FFIDPlanChangeLineItem, type FFIDPlanChangePreview, type FFIDPlanChangePreviewResponse, type FFIDPlanInfo, type FFIDPortalSessionResponse, type FFIDPreviewPlanChangeParams, type FFIDPreviewSeatChangeParams, FFIDProfileCallOptions, FFIDProvider, type FFIDProviderProps, FFIDRedirectResult, type FFIDRemoveMemberResponse, type FFIDResetSessionResponse, FFIDSDKError, type FFIDSeatChangeLineItem, type FFIDSeatChangePreview, type FFIDSeatChangePreviewResponse, FFIDServiceAccessDecision, type FFIDServiceInfo, FFIDSessionResponse, type FFIDSubscribeParams, type FFIDSubscribeResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, type FFIDSubscriptionDetail, FFIDSubscriptionStatus, type FFIDSubscriptionSummary, type FFIDSupportedCurrency, type FFIDUpdateMemberRoleResponse, FFIDUpdateUserProfileRequest, FFIDUser, FFIDUserProfile, FFIDVerifyAccessTokenOptions, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_NEWSLETTER_DISPATCH_MAX_RECIPIENTS, FFID_NEWSLETTER_TYPES, type HandleRedirectCallbackClient, type HandleRedirectCallbackOptions, type KVNamespaceLike, ListAnnouncementsOptions, type NormalizeRedirectUriResult, type RedirectToAuthorizeOptions, type TokenData, type TokenStore, type UseFFIDReturn, type UseRequireActiveSubscriptionOptions, type UseRequireActiveSubscriptionReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, cleanupStateStorage as clearState, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, isBlockedFromUserinfo, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, storeCodeVerifier, storeState, useFFID, useRequireActiveSubscription, useSubscription, withFFIDAuth, withSubscription };