@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.
@@ -1,4 +1,4 @@
1
- import { E as EffectiveSubscriptionStatus } from './types-BYdtyO_2.cjs';
1
+ import { E as EffectiveSubscriptionStatus } from './types-BeVl-z12.js';
2
2
 
3
3
  /**
4
4
  * Inquiry types exposed by the FFID SDK.
@@ -270,6 +270,52 @@ interface FFIDServiceAccessDecision {
270
270
  error?: FFIDServiceAccessError;
271
271
  }
272
272
 
273
+ /**
274
+ * Billing checkout / portal session types.
275
+ *
276
+ * types/index.ts のサイズ上限対応で切り出し(中身は逐語移設、#3787 Phase A)。
277
+ */
278
+ /**
279
+ * Checkout session response from billing checkout endpoint
280
+ */
281
+ interface FFIDCheckoutSessionResponse {
282
+ /** Stripe Checkout session ID */
283
+ sessionId: string;
284
+ /** Stripe Checkout session URL (null if session creation had issues) */
285
+ url: string | null;
286
+ }
287
+ /**
288
+ * Portal session response from billing portal endpoint
289
+ */
290
+ interface FFIDPortalSessionResponse {
291
+ /** Stripe Billing Portal URL */
292
+ url: string;
293
+ }
294
+ /**
295
+ * Parameters for creating a checkout session
296
+ */
297
+ interface FFIDCreateCheckoutParams {
298
+ /** Organization ID (UUID) */
299
+ organizationId: string;
300
+ /** Subscription ID (UUID) */
301
+ subscriptionId: string;
302
+ /** URL to redirect after successful checkout */
303
+ successUrl: string;
304
+ /** URL to redirect after cancelled checkout */
305
+ cancelUrl: string;
306
+ /** Optional plan ID for upgrade or resubscription */
307
+ planId?: string;
308
+ }
309
+ /**
310
+ * Parameters for creating a billing portal session
311
+ */
312
+ interface FFIDCreatePortalParams {
313
+ /** Organization ID (UUID) */
314
+ organizationId: string;
315
+ /** URL to redirect when user exits the portal */
316
+ returnUrl: string;
317
+ }
318
+
273
319
  /** Billing interval for subscriptions */
274
320
  type FFIDBillingInterval = 'monthly' | 'yearly';
275
321
  /**
@@ -637,6 +683,122 @@ interface FFIDRemoveMemberResponse {
637
683
  message: string;
638
684
  }
639
685
 
686
+ /**
687
+ * Contract resource types (#3787 Phase A)
688
+ *
689
+ * シート割り当て・請求書・支払い再試行の ext API 型。
690
+ * サーバー側の sanitize 済みレスポンス(Stripe 内部 ID を含まない)と対になる。
691
+ */
692
+ /** シート割り当て 1 件(ユーザー情報付き、一覧用) */
693
+ interface FFIDSeatAssignmentWithUser {
694
+ userId: string;
695
+ email: string;
696
+ name: string | null;
697
+ role: string;
698
+ assignedAt: string;
699
+ assignedBy: string | null;
700
+ }
701
+ /** シート割り当てレコード(割り当て直後のレスポンス用) */
702
+ interface FFIDSeatAssignmentRecord {
703
+ id: string;
704
+ subscriptionId: string;
705
+ userId: string;
706
+ assignedBy: string | null;
707
+ assignedAt: string;
708
+ createdAt: string;
709
+ updatedAt: string;
710
+ }
711
+ /** GET /api/v1/subscriptions/ext/{id}/seats/assignments のレスポンス */
712
+ interface FFIDListSeatAssignmentsResponse {
713
+ assignments: FFIDSeatAssignmentWithUser[];
714
+ totalSeats: number;
715
+ assignedSeats: number;
716
+ availableSeats: number;
717
+ }
718
+ /** listSeatAssignments のパラメータ */
719
+ interface FFIDListSeatAssignmentsParams {
720
+ subscriptionId: string;
721
+ }
722
+ /** assignSeats のパラメータ */
723
+ interface FFIDAssignSeatsParams {
724
+ subscriptionId: string;
725
+ userIds: string[];
726
+ }
727
+ /** POST /api/v1/subscriptions/ext/{id}/seats/assignments のレスポンス */
728
+ interface FFIDAssignSeatsResponse {
729
+ message: string;
730
+ assignments: FFIDSeatAssignmentRecord[];
731
+ }
732
+ /** unassignSeat のパラメータ */
733
+ interface FFIDUnassignSeatParams {
734
+ subscriptionId: string;
735
+ userId: string;
736
+ }
737
+ /** DELETE /api/v1/subscriptions/ext/{id}/seats/assignments/{userId} のレスポンス */
738
+ interface FFIDUnassignSeatResponse {
739
+ message: string;
740
+ }
741
+ /** 請求書サマリー(一覧用) */
742
+ interface FFIDInvoiceSummary {
743
+ id: string;
744
+ organizationId: string;
745
+ subscriptionId: string | null;
746
+ invoiceNumber: string;
747
+ description: string | null;
748
+ subtotal: number;
749
+ taxRate: number;
750
+ taxAmount: number;
751
+ totalAmount: number;
752
+ currency: string;
753
+ status: string;
754
+ issuedAt: string | null;
755
+ dueDate: string | null;
756
+ paidAt: string | null;
757
+ pdfUrl: string | null;
758
+ createdAt: string;
759
+ }
760
+ /** 請求書詳細(請求先情報・備考を含む) */
761
+ interface FFIDInvoiceDetail extends FFIDInvoiceSummary {
762
+ billingName: string | null;
763
+ billingEmail: string | null;
764
+ notes: string | null;
765
+ }
766
+ /** listInvoices のパラメータ */
767
+ interface FFIDListInvoicesParams {
768
+ organizationId: string;
769
+ }
770
+ /** GET /api/v1/billing/ext/invoices のレスポンス */
771
+ interface FFIDListInvoicesResponse {
772
+ invoices: FFIDInvoiceSummary[];
773
+ count: number;
774
+ }
775
+ /** getInvoice のパラメータ */
776
+ interface FFIDGetInvoiceParams {
777
+ invoiceId: string;
778
+ }
779
+ /** GET /api/v1/billing/ext/invoices/{id} のレスポンス */
780
+ interface FFIDGetInvoiceResponse {
781
+ invoice: FFIDInvoiceDetail;
782
+ }
783
+ /** retryPayment のパラメータ */
784
+ interface FFIDRetryPaymentParams {
785
+ organizationId: string;
786
+ }
787
+ /** 再試行に失敗した契約の詳細 */
788
+ interface FFIDRetryPaymentFailure {
789
+ subscriptionId: string;
790
+ reason: string;
791
+ stripeCode?: string;
792
+ }
793
+ /** POST /api/v1/billing/ext/retry-payment のレスポンス */
794
+ interface FFIDRetryPaymentSummary {
795
+ totalAttempted: number;
796
+ succeeded: number;
797
+ failed: number;
798
+ noOpenInvoice: number;
799
+ failures: FFIDRetryPaymentFailure[];
800
+ }
801
+
640
802
  /**
641
803
  * FFID SDK Type Definitions
642
804
  *
@@ -793,6 +955,17 @@ interface FFIDOAuthUserInfoSubscription {
793
955
  interface FFIDOAuthUserInfo {
794
956
  sub: string;
795
957
  email: string | null;
958
+ /**
959
+ * Whether the user's email is verified on the FFID side (#3791). Use this to
960
+ * safely gate email-based auto account-linking (account-takeover prevention):
961
+ * never auto-link on an unverified email.
962
+ *
963
+ * `undefined` means the FFID server predates the field (older deployment) or
964
+ * the verification path could not populate it — NOT "unverified". Treat
965
+ * `undefined` as "unknown" and fall back to a stricter linking policy rather
966
+ * than coercing it to `false`/`true`.
967
+ */
968
+ emailVerified?: boolean | undefined;
796
969
  name: string | null;
797
970
  picture: string | null;
798
971
  companyName?: string | null | undefined;
@@ -962,47 +1135,6 @@ type FFIDApiResponse<T> = {
962
1135
  error: FFIDError;
963
1136
  };
964
1137
 
965
- /**
966
- * Checkout session response from billing checkout endpoint
967
- */
968
- interface FFIDCheckoutSessionResponse {
969
- /** Stripe Checkout session ID */
970
- sessionId: string;
971
- /** Stripe Checkout session URL (null if session creation had issues) */
972
- url: string | null;
973
- }
974
- /**
975
- * Portal session response from billing portal endpoint
976
- */
977
- interface FFIDPortalSessionResponse {
978
- /** Stripe Billing Portal URL */
979
- url: string;
980
- }
981
- /**
982
- * Parameters for creating a checkout session
983
- */
984
- interface FFIDCreateCheckoutParams {
985
- /** Organization ID (UUID) */
986
- organizationId: string;
987
- /** Subscription ID (UUID) */
988
- subscriptionId: string;
989
- /** URL to redirect after successful checkout */
990
- successUrl: string;
991
- /** URL to redirect after cancelled checkout */
992
- cancelUrl: string;
993
- /** Optional plan ID for upgrade or resubscription */
994
- planId?: string;
995
- }
996
- /**
997
- * Parameters for creating a billing portal session
998
- */
999
- interface FFIDCreatePortalParams {
1000
- /** Organization ID (UUID) */
1001
- organizationId: string;
1002
- /** URL to redirect when user exits the portal */
1003
- returnUrl: string;
1004
- }
1005
-
1006
1138
  /**
1007
1139
  * User profile for the authenticated user (returned by `getProfile` / `updateProfile`).
1008
1140
  *
@@ -1232,34 +1364,6 @@ interface ContractWizardSubscriptionOptions {
1232
1364
  organizationId?: string;
1233
1365
  }
1234
1366
 
1235
- /** Redirect and URL generation - redirectToLogin / redirectToAuthorize / redirectToLogout / getLoginUrl / getSignupUrl / getLogoutUrl */
1236
-
1237
- /**
1238
- * `screen_hint=signup` query value for `/oauth/authorize` (#2908 / #2911).
1239
- * Forwards to Supabase Auth signup screen; only the `'signup'` value is
1240
- * propagated (no-op when `'login'` or omitted).
1241
- */
1242
- declare const SCREEN_HINT_SIGNUP: "signup";
1243
- /** Options for redirectToAuthorize */
1244
- interface RedirectToAuthorizeOptions {
1245
- /** Target organization ID — triggers org-scoped OAuth re-authorization */
1246
- organizationId?: string;
1247
- /**
1248
- * Initial Supabase Auth screen hint (#2908 / #2911).
1249
- *
1250
- * - `'signup'`: forwards `?screen_hint=signup` so the FFID OAuth flow lands
1251
- * on the signup screen (used by external services that want to deep-link
1252
- * new users into the signup CTA).
1253
- * - `'login'` / `undefined`: no `screen_hint` param is added — the default
1254
- * login screen is shown.
1255
- *
1256
- * In cookie mode, `'signup'` redirects to the FFID `/signup` page instead
1257
- * of `/login` so the SDK contract (signup-screen intent) stays consistent
1258
- * regardless of `authMode`.
1259
- */
1260
- screenHint?: typeof SCREEN_HINT_SIGNUP | 'login';
1261
- }
1262
-
1263
1367
  /**
1264
1368
  * Token Store
1265
1369
  *
@@ -1301,6 +1405,53 @@ interface TokenStore {
1301
1405
  */
1302
1406
  declare function createTokenStore(storageType?: 'localStorage' | 'memory'): TokenStore;
1303
1407
 
1408
+ /** OAuth token operations - exchangeCodeForTokens / refreshAccessToken / signOutToken */
1409
+
1410
+ /**
1411
+ * Optional OAuth `state` validation for {@link exchangeCodeForTokens}.
1412
+ *
1413
+ * If a `state` is supplied on EITHER side — `expectedState` (the value persisted
1414
+ * at `redirectToAuthorize`) or `actualState` (the value returned on the callback
1415
+ * URL) — both must be present and equal before any token exchange. A mismatch
1416
+ * OR an omitted counterpart fails closed (no exchange) to defend against CSRF
1417
+ * (RFC 6749 §10.12 / #3841). Validation is skipped only when BOTH are omitted
1418
+ * (backward compatible — callers that don't opt in are unaffected).
1419
+ */
1420
+ interface ExchangeCodeForTokensOptions {
1421
+ /** Stored state from `redirectToAuthorize` (e.g. `retrieveState()`) */
1422
+ expectedState?: string;
1423
+ /** State returned on the OAuth callback URL */
1424
+ actualState?: string;
1425
+ }
1426
+
1427
+ /** Redirect and URL generation - redirectToLogin / redirectToAuthorize / redirectToLogout / getLoginUrl / getSignupUrl / getLogoutUrl */
1428
+
1429
+ /**
1430
+ * `screen_hint=signup` query value for `/oauth/authorize` (#2908 / #2911).
1431
+ * Forwards to Supabase Auth signup screen; only the `'signup'` value is
1432
+ * propagated (no-op when `'login'` or omitted).
1433
+ */
1434
+ declare const SCREEN_HINT_SIGNUP: "signup";
1435
+ /** Options for redirectToAuthorize */
1436
+ interface RedirectToAuthorizeOptions {
1437
+ /** Target organization ID — triggers org-scoped OAuth re-authorization */
1438
+ organizationId?: string;
1439
+ /**
1440
+ * Initial Supabase Auth screen hint (#2908 / #2911).
1441
+ *
1442
+ * - `'signup'`: forwards `?screen_hint=signup` so the FFID OAuth flow lands
1443
+ * on the signup screen (used by external services that want to deep-link
1444
+ * new users into the signup CTA).
1445
+ * - `'login'` / `undefined`: no `screen_hint` param is added — the default
1446
+ * login screen is shown.
1447
+ *
1448
+ * In cookie mode, `'signup'` redirects to the FFID `/signup` page instead
1449
+ * of `/login` so the SDK contract (signup-screen intent) stays consistent
1450
+ * regardless of `authMode`.
1451
+ */
1452
+ screenHint?: typeof SCREEN_HINT_SIGNUP | 'login';
1453
+ }
1454
+
1304
1455
  /** Creates an FFID API client instance */
1305
1456
  declare function createFFIDClient(config: FFIDConfig): {
1306
1457
  getSession: () => Promise<FFIDApiResponse<FFIDSessionResponse>>;
@@ -1312,7 +1463,7 @@ declare function createFFIDClient(config: FFIDConfig): {
1312
1463
  getLogoutUrl: (postLogoutRedirectUri?: string) => string;
1313
1464
  getSignupUrl: (redirectUrl?: string) => string;
1314
1465
  createError: (code: string, message: string) => FFIDError;
1315
- exchangeCodeForTokens: (code: string, codeVerifier?: string) => Promise<FFIDApiResponse<void>>;
1466
+ exchangeCodeForTokens: (code: string, codeVerifier?: string, opts?: ExchangeCodeForTokensOptions) => Promise<FFIDApiResponse<void>>;
1316
1467
  refreshAccessToken: () => Promise<FFIDApiResponse<void>>;
1317
1468
  checkSubscription: (params: {
1318
1469
  userId?: string;
@@ -1341,6 +1492,12 @@ declare function createFFIDClient(config: FFIDConfig): {
1341
1492
  getAnalyticsConfig: (serviceCode: string, options?: FFIDProfileCallOptions) => Promise<FFIDApiResponse<FFIDAnalyticsConfig>>;
1342
1493
  createCheckoutSession: (params: FFIDCreateCheckoutParams) => Promise<FFIDApiResponse<FFIDCheckoutSessionResponse>>;
1343
1494
  createPortalSession: (params: FFIDCreatePortalParams) => Promise<FFIDApiResponse<FFIDPortalSessionResponse>>;
1495
+ listInvoices: (params: FFIDListInvoicesParams) => Promise<FFIDApiResponse<FFIDListInvoicesResponse>>;
1496
+ getInvoice: (params: FFIDGetInvoiceParams) => Promise<FFIDApiResponse<FFIDGetInvoiceResponse>>;
1497
+ retryPayment: (params: FFIDRetryPaymentParams) => Promise<FFIDApiResponse<FFIDRetryPaymentSummary>>;
1498
+ listSeatAssignments: (params: FFIDListSeatAssignmentsParams) => Promise<FFIDApiResponse<FFIDListSeatAssignmentsResponse>>;
1499
+ assignSeats: (params: FFIDAssignSeatsParams) => Promise<FFIDApiResponse<FFIDAssignSeatsResponse>>;
1500
+ unassignSeat: (params: FFIDUnassignSeatParams) => Promise<FFIDApiResponse<FFIDUnassignSeatResponse>>;
1344
1501
  listPlans: () => Promise<FFIDApiResponse<FFIDListPlansResponse>>;
1345
1502
  getSubscription: (subscriptionId: string) => Promise<FFIDApiResponse<FFIDSubscriptionDetail>>;
1346
1503
  subscribe: (params: FFIDSubscribeParams) => Promise<FFIDApiResponse<FFIDSubscribeResponse>>;