@feelflow/ffid-sdk 5.17.1 → 5.19.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.d.ts CHANGED
@@ -564,6 +564,217 @@ interface FFIDRemoveMemberResponse {
564
564
  message: string;
565
565
  }
566
566
 
567
+ /**
568
+ * Provisioning types (ext API) — service-key-authenticated, idempotent user /
569
+ * organization provisioning for external batch migration (#3790 / #4127).
570
+ *
571
+ * Mirrors the server contract of `POST /api/v1/ext/users/provision` and
572
+ * `POST /api/v1/ext/organizations/provision`. Responses are modelled as
573
+ * discriminated unions on `dryRun` so consumers narrow with `if (res.dryRun)`
574
+ * and the compiler enforces which fields are present on each branch
575
+ * (`wouldCreate` on dry-run, `created` on a real call).
576
+ */
577
+
578
+ /** Optional business-profile fields applied to a freshly provisioned user. */
579
+ interface FFIDProvisionUserProfileInput {
580
+ /** Display name (1–255 chars). */
581
+ displayName?: string;
582
+ /** Company name (≤255 chars). */
583
+ companyName?: string;
584
+ /** Department (≤255 chars). */
585
+ department?: string;
586
+ /** Job title (≤255 chars). */
587
+ jobTitle?: string;
588
+ /** Phone number (≤30 chars). */
589
+ phone?: string;
590
+ }
591
+ /** Parameters for `provisionUser`. */
592
+ interface FFIDProvisionUserParams {
593
+ /**
594
+ * Email of the user to provision. Normalized (trim + lowercase) server-side
595
+ * before the idempotency lookup, so re-runs with different casing resolve to
596
+ * the same user.
597
+ */
598
+ email: string;
599
+ /** Optional business profile applied only when a new user is created. */
600
+ profile?: FFIDProvisionUserProfileInput;
601
+ /**
602
+ * When `true`, the server performs no writes and returns a
603
+ * {@link FFIDProvisionUserDryRun} describing what a real call would do.
604
+ * @default false
605
+ */
606
+ dryRun?: boolean;
607
+ }
608
+ /** Minimal identity returned for a provisioned / resolved user. */
609
+ interface FFIDProvisionedUser {
610
+ /** User ID (UUID). */
611
+ id: string;
612
+ /** Email address (normalized). */
613
+ email: string;
614
+ }
615
+ /**
616
+ * Real (non-dry-run) user provisioning outcome.
617
+ *
618
+ * Idempotent: an existing email resolves to `created: false` (HTTP 200) instead
619
+ * of creating a duplicate; a new email yields `created: true` (HTTP 201) for a
620
+ * passwordless, email-confirmed user.
621
+ */
622
+ interface FFIDProvisionUserOutcome {
623
+ /** Discriminant — absent/`false` for a real call. */
624
+ dryRun?: false;
625
+ /**
626
+ * `true` → a new passwordless, email-confirmed user was created (HTTP 201).
627
+ * `false` → a user with this email already existed; idempotent no-op (HTTP 200).
628
+ */
629
+ created: boolean;
630
+ user: FFIDProvisionedUser;
631
+ /**
632
+ * Present only when a new user was created **and** a `profile` was supplied.
633
+ * `false` means the user row was created but the authoritative profile write
634
+ * did not complete — some profile fields may not be fully applied, so
635
+ * re-issue the profile to be sure. Absent on the idempotent-existing branch
636
+ * and when no profile was requested.
637
+ */
638
+ profileWritten?: boolean;
639
+ }
640
+ /** Dry-run user provisioning outcome — no writes performed. */
641
+ interface FFIDProvisionUserDryRun {
642
+ /** Discriminant — always `true` for a dry-run. */
643
+ dryRun: true;
644
+ /** Whether a real call would create a new user. */
645
+ wouldCreate: boolean;
646
+ /** `id` is present only when the user already exists. */
647
+ user: {
648
+ id?: string;
649
+ email: string;
650
+ };
651
+ }
652
+ /**
653
+ * Response from `provisionUser`. Narrow with the truthiness of `dryRun`:
654
+ *
655
+ * ```ts
656
+ * if (res.dryRun) {
657
+ * // FFIDProvisionUserDryRun — inspect res.wouldCreate
658
+ * } else {
659
+ * // FFIDProvisionUserOutcome — inspect res.created
660
+ * }
661
+ * ```
662
+ *
663
+ * A real (non-dry-run) response omits `dryRun` on the wire (it is `undefined`,
664
+ * not `false`), so narrow with `if (res.dryRun)` — do **not** use
665
+ * `res.dryRun === false` or `switch (res.dryRun)`, which would miss every real
666
+ * response. This mirrors how `FFIDApiResponse` is narrowed on `data` / `error`.
667
+ */
668
+ type FFIDProvisionUserResponse = FFIDProvisionUserOutcome | FFIDProvisionUserDryRun;
669
+ /** A member to add to the provisioned organization. */
670
+ interface FFIDProvisionOrganizationMemberInput {
671
+ email: string;
672
+ /** `owner` is intentionally excluded — the owner is set via `ownerEmail`. */
673
+ role: FFIDAssignableMemberRole;
674
+ }
675
+ /** Parameters for `provisionOrganization`. */
676
+ interface FFIDProvisionOrganizationParams {
677
+ /** Organization display name (1–255 chars). */
678
+ name: string;
679
+ /**
680
+ * Email of the organization owner. The owner **must** already be an FFID user
681
+ * — provision them via `provisionUser` first, otherwise the call returns an
682
+ * `OWNER_NOT_FOUND` error (HTTP 422).
683
+ */
684
+ ownerEmail: string;
685
+ /** Optional billing contact email. */
686
+ billingEmail?: string;
687
+ /** Members to add idempotently (≤100 per request; validated client-side). */
688
+ members?: FFIDProvisionOrganizationMemberInput[];
689
+ /**
690
+ * When `true`, the server performs no writes and returns a
691
+ * {@link FFIDProvisionOrganizationDryRun} describing what a real call would do.
692
+ * @default false
693
+ */
694
+ dryRun?: boolean;
695
+ }
696
+ /** Minimal organization shape returned by the org provisioning helper. */
697
+ interface FFIDProvisionedOrganization {
698
+ /** Organization ID (UUID). */
699
+ id: string;
700
+ /** Organization display name. */
701
+ name: string;
702
+ /** URL-safe slug. */
703
+ slug: string;
704
+ }
705
+ /** Per-member outcome status of a real (non-dry-run) organization provision. */
706
+ type FFIDProvisionMemberStatus = 'added' | 'already_member' | 'user_not_found';
707
+ /** Per-member outcome status of a dry-run organization provision. */
708
+ type FFIDProvisionMemberPlanStatus = 'would_add' | 'already_member' | 'user_not_found';
709
+ /** Per-member outcome of a real (non-dry-run) organization provision. */
710
+ interface FFIDProvisionMemberResult {
711
+ email: string;
712
+ role: FFIDAssignableMemberRole;
713
+ /**
714
+ * - `added` — membership was inserted.
715
+ * - `already_member` — user was already a member (idempotent no-op).
716
+ * - `user_not_found` — no FFID user exists for this email (skipped).
717
+ */
718
+ status: FFIDProvisionMemberStatus;
719
+ }
720
+ /** Per-member plan of a dry-run organization provision. */
721
+ interface FFIDProvisionMemberPlan {
722
+ email: string;
723
+ role: FFIDAssignableMemberRole;
724
+ /**
725
+ * - `would_add` — user exists and is not yet a member.
726
+ * - `already_member` — user is already a member of the existing org.
727
+ * - `user_not_found` — no FFID user exists for this email.
728
+ */
729
+ status: FFIDProvisionMemberPlanStatus;
730
+ }
731
+ /** Real (non-dry-run) organization provisioning outcome. */
732
+ interface FFIDProvisionOrganizationOutcome {
733
+ /** Discriminant — absent/`false` for a real call. */
734
+ dryRun?: false;
735
+ /**
736
+ * `true` → a brand-new organization was created (HTTP 201).
737
+ * `false` → the owner already owned an org with this name; idempotent (HTTP 200).
738
+ */
739
+ created: boolean;
740
+ organization: FFIDProvisionedOrganization;
741
+ /** Per-member results (added / already_member / user_not_found). */
742
+ members: FFIDProvisionMemberResult[];
743
+ }
744
+ /** Dry-run organization provisioning outcome — no writes performed. */
745
+ interface FFIDProvisionOrganizationDryRun {
746
+ /** Discriminant — always `true` for a dry-run. */
747
+ dryRun: true;
748
+ /**
749
+ * Whether a real call would create a new organization. Coupled to
750
+ * `organization`: `wouldCreate === (organization === null)` — the server
751
+ * returns `organization: null` exactly when it would create a new org.
752
+ */
753
+ wouldCreate: boolean;
754
+ /** `null` when the org does not exist yet (would be created) — see `wouldCreate`. */
755
+ organization: FFIDProvisionedOrganization | null;
756
+ /** Per-member plans (would_add / already_member / user_not_found). */
757
+ members: FFIDProvisionMemberPlan[];
758
+ }
759
+ /**
760
+ * Response from `provisionOrganization`. Narrow on `dryRun`:
761
+ *
762
+ * ```ts
763
+ * if (res.dryRun) {
764
+ * // FFIDProvisionOrganizationDryRun — inspect res.wouldCreate / res.organization (nullable)
765
+ * } else {
766
+ * // FFIDProvisionOrganizationOutcome — inspect res.created / res.members
767
+ * }
768
+ * ```
769
+ *
770
+ * As with `FFIDProvisionUserResponse`, a real response omits `dryRun` on the
771
+ * wire, so narrow with `if (res.dryRun)` — not `res.dryRun === false`.
772
+ *
773
+ * When `ownerEmail` has no FFID user, the call resolves to
774
+ * `{ error: { code: 'OWNER_NOT_FOUND' } }` (HTTP 422) rather than a data branch.
775
+ */
776
+ type FFIDProvisionOrganizationResponse = FFIDProvisionOrganizationOutcome | FFIDProvisionOrganizationDryRun;
777
+
567
778
  /**
568
779
  * Contract resource types (#3787 Phase A)
569
780
  *
@@ -1127,6 +1338,33 @@ interface RedirectToAuthorizeOptions {
1127
1338
  prompt?: FFIDPrompt;
1128
1339
  }
1129
1340
 
1341
+ /**
1342
+ * FFID SDK error codes
1343
+ *
1344
+ * Codes the SDK itself attaches to `FFIDError.code`. Exported from the
1345
+ * package entry points so consumers can branch on codes (e.g.
1346
+ * `TOKEN_EXPIRED` vs `TOKEN_VERIFICATION_ERROR`) without hardcoding strings.
1347
+ */
1348
+ /** Error codes used by the SDK */
1349
+ declare const FFID_ERROR_CODES: {
1350
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
1351
+ readonly PARSE_ERROR: "PARSE_ERROR";
1352
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
1353
+ readonly TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR";
1354
+ readonly TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR";
1355
+ readonly NO_TOKENS: "NO_TOKENS";
1356
+ readonly TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR";
1357
+ readonly TOKEN_EXPIRED: "TOKEN_EXPIRED";
1358
+ readonly STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR";
1359
+ };
1360
+ /**
1361
+ * Union of the error code literals the SDK itself produces.
1362
+ *
1363
+ * Note: `FFIDError.code` intentionally stays `string` — server-provided
1364
+ * error codes pass through verbatim and must not be narrowed away.
1365
+ */
1366
+ type FFIDErrorCode = (typeof FFID_ERROR_CODES)[keyof typeof FFID_ERROR_CODES];
1367
+
1130
1368
  /** Creates an FFID API client instance */
1131
1369
  declare function createFFIDClient(config: FFIDConfig): {
1132
1370
  getSession: () => Promise<FFIDApiResponse<FFIDSessionResponse>>;
@@ -1167,6 +1405,8 @@ declare function createFFIDClient(config: FFIDConfig): {
1167
1405
  organizationId: string;
1168
1406
  userId: string;
1169
1407
  }) => Promise<FFIDApiResponse<FFIDRemoveMemberResponse>>;
1408
+ provisionUser: (params: FFIDProvisionUserParams) => Promise<FFIDApiResponse<FFIDProvisionUserResponse>>;
1409
+ provisionOrganization: (params: FFIDProvisionOrganizationParams) => Promise<FFIDApiResponse<FFIDProvisionOrganizationResponse>>;
1170
1410
  getProfile: (options?: FFIDProfileCallOptions) => Promise<FFIDApiResponse<FFIDUserProfile>>;
1171
1411
  updateProfile: (data: FFIDUpdateUserProfileRequest, options?: FFIDProfileCallOptions) => Promise<FFIDApiResponse<FFIDUserProfile>>;
1172
1412
  getLoginHistory: (params?: FFIDGetLoginHistoryParams) => Promise<FFIDApiResponse<FFIDLoginHistoryResponse>>;
@@ -2040,4 +2280,4 @@ declare function createInquiryMethods(deps: InquiryMethodsDeps): {
2040
2280
  };
2041
2281
  type FFIDInquiryClient = ReturnType<typeof createInquiryMethods>;
2042
2282
 
2043
- 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 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, 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, type FFIDUpdateNotificationPreferencesRequest, type FFIDUpdateUserProfileRequest, FFIDUser, type 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 };
2283
+ 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, 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, 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 };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useFFIDContext, useSubscription } from './chunk-26X62P76.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_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-26X62P76.js';
1
+ import { useFFIDContext, useSubscription } from './chunk-D3PZ6SZB.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-D3PZ6SZB.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';
@@ -225,10 +225,29 @@ function createJwtVerifier(deps) {
225
225
  return { data: userInfo };
226
226
  } catch (error) {
227
227
  const message = error instanceof Error ? error.message : "JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F";
228
- logger.error("JWT verification failed:", message);
228
+ if (error instanceof jose.errors.JWTExpired) {
229
+ logger.debug("JWT verification failed (token expired):", message);
230
+ return {
231
+ error: createError(
232
+ errorCodes.TOKEN_EXPIRED,
233
+ "\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u306E\u6709\u52B9\u671F\u9650\u304C\u5207\u308C\u3066\u3044\u307E\u3059"
234
+ )
235
+ };
236
+ }
237
+ const isTokenLevelError = error instanceof jose.errors.JWTClaimValidationFailed || error instanceof jose.errors.JWTInvalid || error instanceof jose.errors.JWSInvalid || error instanceof jose.errors.JWSSignatureVerificationFailed || error instanceof jose.errors.JOSEAlgNotAllowed || error instanceof jose.errors.JOSENotSupported || error instanceof jose.errors.JWKSNoMatchingKey || error instanceof jose.errors.JWKSMultipleMatchingKeys;
238
+ if (isTokenLevelError) {
239
+ logger.warn("JWT verification failed:", message);
240
+ return {
241
+ error: createError(
242
+ errorCodes.TOKEN_VERIFICATION_ERROR,
243
+ `JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
244
+ )
245
+ };
246
+ }
247
+ logger.error("JWT verification failed (JWKS fetch):", message);
229
248
  return {
230
249
  error: createError(
231
- errorCodes.TOKEN_VERIFICATION_ERROR,
250
+ errorCodes.NETWORK_ERROR,
232
251
  `JWT\u691C\u8A3C\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${message}`
233
252
  )
234
253
  };
@@ -253,7 +272,9 @@ function createVerifyAccessToken(deps) {
253
272
  serviceCode,
254
273
  logger,
255
274
  createError,
256
- errorCodes: { TOKEN_VERIFICATION_ERROR: errorCodes.TOKEN_VERIFICATION_ERROR }
275
+ // structural superset of JwtVerifierDeps.errorCodes — passing it
276
+ // wholesale removes the hand-transcription drift point
277
+ errorCodes
257
278
  });
258
279
  }
259
280
  return jwtVerify2;
@@ -849,6 +870,93 @@ function createMembersMethods(deps) {
849
870
  return { listMembers, addMember, updateMemberRole, removeMember };
850
871
  }
851
872
 
873
+ // src/client/provisioning-methods.ts
874
+ var USER_PROVISION_ENDPOINT = "/api/v1/ext/users/provision";
875
+ var ORGANIZATION_PROVISION_ENDPOINT = "/api/v1/ext/organizations/provision";
876
+ var MAX_PROVISION_MEMBERS = 100;
877
+ var ASSIGNABLE_MEMBER_ROLES = {
878
+ admin: true,
879
+ member: true,
880
+ viewer: true
881
+ };
882
+ function isAssignableMemberRole(role) {
883
+ return Object.hasOwn(ASSIGNABLE_MEMBER_ROLES, role);
884
+ }
885
+ function createProvisioningMethods(deps) {
886
+ const { fetchWithAuth, createError, authMode } = deps;
887
+ function serviceKeyModeError() {
888
+ if (authMode === "service-key") return null;
889
+ return createError(
890
+ "VALIDATION_ERROR",
891
+ "provisionUser / provisionOrganization \u306F service-key \u8A8D\u8A3C\uFF08X-Service-Api-Key\uFF09\u3067\u306E\u307F\u5229\u7528\u3067\u304D\u307E\u3059\u3002Bearer / cookie \u30E2\u30FC\u30C9\u3067\u306F\u547C\u3073\u51FA\u305B\u307E\u305B\u3093"
892
+ );
893
+ }
894
+ async function provisionUser(params) {
895
+ const modeError = serviceKeyModeError();
896
+ if (modeError) return { error: modeError };
897
+ if (!params.email || !params.email.trim()) {
898
+ return { error: createError("VALIDATION_ERROR", "email \u306F\u5FC5\u9808\u3067\u3059") };
899
+ }
900
+ const body = { email: params.email.trim() };
901
+ if (params.profile !== void 0) body.profile = params.profile;
902
+ if (params.dryRun !== void 0) body.dryRun = params.dryRun;
903
+ return fetchWithAuth(USER_PROVISION_ENDPOINT, {
904
+ method: "POST",
905
+ body: JSON.stringify(body)
906
+ });
907
+ }
908
+ async function provisionOrganization(params) {
909
+ const modeError = serviceKeyModeError();
910
+ if (modeError) return { error: modeError };
911
+ if (!params.name || !params.name.trim()) {
912
+ return { error: createError("VALIDATION_ERROR", "name \u306F\u5FC5\u9808\u3067\u3059") };
913
+ }
914
+ if (!params.ownerEmail || !params.ownerEmail.trim()) {
915
+ return { error: createError("VALIDATION_ERROR", "ownerEmail \u306F\u5FC5\u9808\u3067\u3059") };
916
+ }
917
+ if (params.members) {
918
+ if (params.members.length > MAX_PROVISION_MEMBERS) {
919
+ return {
920
+ error: createError(
921
+ "VALIDATION_ERROR",
922
+ `members \u306F1\u30EA\u30AF\u30A8\u30B9\u30C8\u3042\u305F\u308A\u6700\u5927 ${MAX_PROVISION_MEMBERS} \u4EF6\u307E\u3067\u3067\u3059`
923
+ )
924
+ };
925
+ }
926
+ for (const member of params.members) {
927
+ if (!member.email || !member.email.trim()) {
928
+ return { error: createError("VALIDATION_ERROR", "members[].email \u306F\u5FC5\u9808\u3067\u3059") };
929
+ }
930
+ if (!isAssignableMemberRole(member.role)) {
931
+ return {
932
+ error: createError(
933
+ "VALIDATION_ERROR",
934
+ "members[].role \u306F admin\u3001member\u3001viewer \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044"
935
+ )
936
+ };
937
+ }
938
+ }
939
+ }
940
+ const body = {
941
+ name: params.name.trim(),
942
+ ownerEmail: params.ownerEmail.trim()
943
+ };
944
+ if (params.billingEmail !== void 0) body.billingEmail = params.billingEmail.trim();
945
+ if (params.members !== void 0) {
946
+ body.members = params.members.map((member) => ({
947
+ email: member.email.trim(),
948
+ role: member.role
949
+ }));
950
+ }
951
+ if (params.dryRun !== void 0) body.dryRun = params.dryRun;
952
+ return fetchWithAuth(ORGANIZATION_PROVISION_ENDPOINT, {
953
+ method: "POST",
954
+ body: JSON.stringify(body)
955
+ });
956
+ }
957
+ return { provisionUser, provisionOrganization };
958
+ }
959
+
852
960
  // src/client/seat-methods.ts
853
961
  function seatsEndpoint(subscriptionId) {
854
962
  return `/api/v1/subscriptions/ext/${encodeURIComponent(subscriptionId)}/seats/assignments`;
@@ -1093,7 +1201,7 @@ function createNonContractMethods(deps) {
1093
1201
  }
1094
1202
 
1095
1203
  // src/client/version-check.ts
1096
- var SDK_VERSION = "5.17.1";
1204
+ var SDK_VERSION = "5.19.0";
1097
1205
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
1098
1206
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
1099
1207
  function sdkHeaders() {
@@ -2520,6 +2628,19 @@ var BLOCKING_EFFECTIVE_STATUSES = [
2520
2628
  "trial_expired"
2521
2629
  ];
2522
2630
 
2631
+ // src/client/error-codes.ts
2632
+ var FFID_ERROR_CODES = {
2633
+ NETWORK_ERROR: "NETWORK_ERROR",
2634
+ PARSE_ERROR: "PARSE_ERROR",
2635
+ UNKNOWN_ERROR: "UNKNOWN_ERROR",
2636
+ TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
2637
+ TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
2638
+ NO_TOKENS: "NO_TOKENS",
2639
+ TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
2640
+ TOKEN_EXPIRED: "TOKEN_EXPIRED",
2641
+ STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
2642
+ };
2643
+
2523
2644
  // src/client/ffid-client.ts
2524
2645
  var UNAUTHORIZED_STATUS2 = 401;
2525
2646
  var SDK_LOG_PREFIX = "[FFID SDK]";
@@ -2528,8 +2649,10 @@ var noopLogger = {
2528
2649
  },
2529
2650
  info: () => {
2530
2651
  },
2531
- warn: (...args) => console.warn(SDK_LOG_PREFIX, ...args),
2532
- error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
2652
+ warn: () => {
2653
+ },
2654
+ error: () => {
2655
+ }
2533
2656
  };
2534
2657
  var consoleLogger = {
2535
2658
  debug: (...args) => console.debug(SDK_LOG_PREFIX, ...args),
@@ -2537,16 +2660,6 @@ var consoleLogger = {
2537
2660
  warn: (...args) => console.warn(SDK_LOG_PREFIX, ...args),
2538
2661
  error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
2539
2662
  };
2540
- var FFID_ERROR_CODES = {
2541
- NETWORK_ERROR: "NETWORK_ERROR",
2542
- PARSE_ERROR: "PARSE_ERROR",
2543
- UNKNOWN_ERROR: "UNKNOWN_ERROR",
2544
- TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
2545
- TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
2546
- NO_TOKENS: "NO_TOKENS",
2547
- TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
2548
- STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
2549
- };
2550
2663
  var EXT_CHECK_ENDPOINT = "/api/v1/subscriptions/ext/check";
2551
2664
  var DEFAULT_ALLOW_GRACE = true;
2552
2665
  var DEFAULT_SERVICE_ACCESS_FAIL_POLICY = "failClosed";
@@ -2929,6 +3042,11 @@ function createFFIDClient(config) {
2929
3042
  createError,
2930
3043
  serviceCode: config.serviceCode
2931
3044
  });
3045
+ const { provisionUser, provisionOrganization } = createProvisioningMethods({
3046
+ fetchWithAuth,
3047
+ createError,
3048
+ authMode
3049
+ });
2932
3050
  const { getProfile, updateProfile } = createProfileMethods({
2933
3051
  fetchWithAuth,
2934
3052
  createError
@@ -3024,6 +3142,8 @@ function createFFIDClient(config) {
3024
3142
  addMember,
3025
3143
  updateMemberRole,
3026
3144
  removeMember,
3145
+ provisionUser,
3146
+ provisionOrganization,
3027
3147
  getProfile,
3028
3148
  updateProfile,
3029
3149
  // Non-contract ext API coverage (#3783)
@@ -3227,6 +3347,7 @@ Object.defineProperty(exports, "DEFAULT_OAUTH_SCOPES", {
3227
3347
  exports.ALL_DENIED_EXCEPT_NECESSARY = ALL_DENIED_EXCEPT_NECESSARY;
3228
3348
  exports.CONSENT_COOKIE_NAME = CONSENT_COOKIE_NAME;
3229
3349
  exports.COOKIE_VERSION = COOKIE_VERSION;
3350
+ exports.FFID_ERROR_CODES = FFID_ERROR_CODES;
3230
3351
  exports.createFFIDClient = createFFIDClient;
3231
3352
  exports.createKVCacheAdapter = createKVCacheAdapter;
3232
3353
  exports.createMemoryCacheAdapter = createMemoryCacheAdapter;
@@ -1,9 +1,36 @@
1
- import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-Cwk6cG3b.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 FFIDRemoveMemberResponse, x as FFIDResetSessionResponse, y as FFIDSubscription, z as FFIDUpdateMemberRoleResponse, A as FFIDUpdateUserProfileRequest, B as FFIDUser, C as FFIDUserProfile, T as TokenData, D as TokenStore, E as createFFIDClient, G as createTokenStore } from '../ffid-client-Cwk6cG3b.cjs';
1
+ import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-BuDM5tmq.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-BuDM5tmq.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-BeVl-z12.cjs';
6
6
 
7
+ /**
8
+ * FFID SDK error codes
9
+ *
10
+ * Codes the SDK itself attaches to `FFIDError.code`. Exported from the
11
+ * package entry points so consumers can branch on codes (e.g.
12
+ * `TOKEN_EXPIRED` vs `TOKEN_VERIFICATION_ERROR`) without hardcoding strings.
13
+ */
14
+ /** Error codes used by the SDK */
15
+ declare const FFID_ERROR_CODES: {
16
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
17
+ readonly PARSE_ERROR: "PARSE_ERROR";
18
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
19
+ readonly TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR";
20
+ readonly TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR";
21
+ readonly NO_TOKENS: "NO_TOKENS";
22
+ readonly TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR";
23
+ readonly TOKEN_EXPIRED: "TOKEN_EXPIRED";
24
+ readonly STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR";
25
+ };
26
+ /**
27
+ * Union of the error code literals the SDK itself produces.
28
+ *
29
+ * Note: `FFIDError.code` intentionally stays `string` — server-provided
30
+ * error codes pass through verbatim and must not be narrowed away.
31
+ */
32
+ type FFIDErrorCode = (typeof FFID_ERROR_CODES)[keyof typeof FFID_ERROR_CODES];
33
+
7
34
  /** Token verification - verifyAccessToken() implementation */
8
35
 
9
36
  /** Dependencies required by verifyAccessToken */
@@ -16,9 +43,10 @@ interface VerifyAccessTokenDeps {
16
43
  logger: FFIDLogger;
17
44
  createError: (code: string, message: string) => FFIDError;
18
45
  errorCodes: {
19
- NETWORK_ERROR: string;
20
- PARSE_ERROR: string;
21
- TOKEN_VERIFICATION_ERROR: string;
46
+ NETWORK_ERROR: 'NETWORK_ERROR';
47
+ PARSE_ERROR: 'PARSE_ERROR';
48
+ TOKEN_VERIFICATION_ERROR: 'TOKEN_VERIFICATION_ERROR';
49
+ TOKEN_EXPIRED: 'TOKEN_EXPIRED';
22
50
  };
23
51
  cache?: {
24
52
  adapter: FFIDCacheAdapter;
@@ -205,4 +233,4 @@ declare function decodeConsentCookie(raw: string | null | undefined): FFIDConsen
205
233
 
206
234
  declare const CONSENT_COOKIE_NAME = "ffid_consent";
207
235
 
208
- export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, FFIDCacheAdapter, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, FFIDOAuthUserInfo, FFIDVerifyAccessTokenOptions, type KVNamespaceLike, createKVCacheAdapter, createMemoryCacheAdapter, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };
236
+ export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, FFIDCacheAdapter, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, type FFIDErrorCode, FFIDOAuthUserInfo, FFIDVerifyAccessTokenOptions, FFID_ERROR_CODES, type KVNamespaceLike, createKVCacheAdapter, createMemoryCacheAdapter, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };
@@ -1,9 +1,36 @@
1
- import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-w8Twi5lD.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 FFIDRemoveMemberResponse, x as FFIDResetSessionResponse, y as FFIDSubscription, z as FFIDUpdateMemberRoleResponse, A as FFIDUpdateUserProfileRequest, B as FFIDUser, C as FFIDUserProfile, T as TokenData, D as TokenStore, E as createFFIDClient, G as createTokenStore } from '../ffid-client-w8Twi5lD.js';
1
+ import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-D0x8TBS5.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-D0x8TBS5.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-BeVl-z12.js';
6
6
 
7
+ /**
8
+ * FFID SDK error codes
9
+ *
10
+ * Codes the SDK itself attaches to `FFIDError.code`. Exported from the
11
+ * package entry points so consumers can branch on codes (e.g.
12
+ * `TOKEN_EXPIRED` vs `TOKEN_VERIFICATION_ERROR`) without hardcoding strings.
13
+ */
14
+ /** Error codes used by the SDK */
15
+ declare const FFID_ERROR_CODES: {
16
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
17
+ readonly PARSE_ERROR: "PARSE_ERROR";
18
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
19
+ readonly TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR";
20
+ readonly TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR";
21
+ readonly NO_TOKENS: "NO_TOKENS";
22
+ readonly TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR";
23
+ readonly TOKEN_EXPIRED: "TOKEN_EXPIRED";
24
+ readonly STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR";
25
+ };
26
+ /**
27
+ * Union of the error code literals the SDK itself produces.
28
+ *
29
+ * Note: `FFIDError.code` intentionally stays `string` — server-provided
30
+ * error codes pass through verbatim and must not be narrowed away.
31
+ */
32
+ type FFIDErrorCode = (typeof FFID_ERROR_CODES)[keyof typeof FFID_ERROR_CODES];
33
+
7
34
  /** Token verification - verifyAccessToken() implementation */
8
35
 
9
36
  /** Dependencies required by verifyAccessToken */
@@ -16,9 +43,10 @@ interface VerifyAccessTokenDeps {
16
43
  logger: FFIDLogger;
17
44
  createError: (code: string, message: string) => FFIDError;
18
45
  errorCodes: {
19
- NETWORK_ERROR: string;
20
- PARSE_ERROR: string;
21
- TOKEN_VERIFICATION_ERROR: string;
46
+ NETWORK_ERROR: 'NETWORK_ERROR';
47
+ PARSE_ERROR: 'PARSE_ERROR';
48
+ TOKEN_VERIFICATION_ERROR: 'TOKEN_VERIFICATION_ERROR';
49
+ TOKEN_EXPIRED: 'TOKEN_EXPIRED';
22
50
  };
23
51
  cache?: {
24
52
  adapter: FFIDCacheAdapter;
@@ -205,4 +233,4 @@ declare function decodeConsentCookie(raw: string | null | undefined): FFIDConsen
205
233
 
206
234
  declare const CONSENT_COOKIE_NAME = "ffid_consent";
207
235
 
208
- export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, FFIDCacheAdapter, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, FFIDOAuthUserInfo, FFIDVerifyAccessTokenOptions, type KVNamespaceLike, createKVCacheAdapter, createMemoryCacheAdapter, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };
236
+ export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, FFIDCacheAdapter, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, type FFIDErrorCode, FFIDOAuthUserInfo, FFIDVerifyAccessTokenOptions, FFID_ERROR_CODES, type KVNamespaceLike, createKVCacheAdapter, createMemoryCacheAdapter, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };