@feelflow/ffid-sdk 5.18.0 → 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.cts 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
  *
@@ -1194,6 +1405,8 @@ declare function createFFIDClient(config: FFIDConfig): {
1194
1405
  organizationId: string;
1195
1406
  userId: string;
1196
1407
  }) => Promise<FFIDApiResponse<FFIDRemoveMemberResponse>>;
1408
+ provisionUser: (params: FFIDProvisionUserParams) => Promise<FFIDApiResponse<FFIDProvisionUserResponse>>;
1409
+ provisionOrganization: (params: FFIDProvisionOrganizationParams) => Promise<FFIDApiResponse<FFIDProvisionOrganizationResponse>>;
1197
1410
  getProfile: (options?: FFIDProfileCallOptions) => Promise<FFIDApiResponse<FFIDUserProfile>>;
1198
1411
  updateProfile: (data: FFIDUpdateUserProfileRequest, options?: FFIDProfileCallOptions) => Promise<FFIDApiResponse<FFIDUserProfile>>;
1199
1412
  getLoginHistory: (params?: FFIDGetLoginHistoryParams) => Promise<FFIDApiResponse<FFIDLoginHistoryResponse>>;
@@ -2067,4 +2280,4 @@ declare function createInquiryMethods(deps: InquiryMethodsDeps): {
2067
2280
  };
2068
2281
  type FFIDInquiryClient = ReturnType<typeof createInquiryMethods>;
2069
2282
 
2070
- 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, 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 };
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.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
  *
@@ -1194,6 +1405,8 @@ declare function createFFIDClient(config: FFIDConfig): {
1194
1405
  organizationId: string;
1195
1406
  userId: string;
1196
1407
  }) => Promise<FFIDApiResponse<FFIDRemoveMemberResponse>>;
1408
+ provisionUser: (params: FFIDProvisionUserParams) => Promise<FFIDApiResponse<FFIDProvisionUserResponse>>;
1409
+ provisionOrganization: (params: FFIDProvisionOrganizationParams) => Promise<FFIDApiResponse<FFIDProvisionOrganizationResponse>>;
1197
1410
  getProfile: (options?: FFIDProfileCallOptions) => Promise<FFIDApiResponse<FFIDUserProfile>>;
1198
1411
  updateProfile: (data: FFIDUpdateUserProfileRequest, options?: FFIDProfileCallOptions) => Promise<FFIDApiResponse<FFIDUserProfile>>;
1199
1412
  getLoginHistory: (params?: FFIDGetLoginHistoryParams) => Promise<FFIDApiResponse<FFIDLoginHistoryResponse>>;
@@ -2067,4 +2280,4 @@ declare function createInquiryMethods(deps: InquiryMethodsDeps): {
2067
2280
  };
2068
2281
  type FFIDInquiryClient = ReturnType<typeof createInquiryMethods>;
2069
2282
 
2070
- 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, 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 };
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-L2H56C4W.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-L2H56C4W.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';
@@ -870,6 +870,93 @@ function createMembersMethods(deps) {
870
870
  return { listMembers, addMember, updateMemberRole, removeMember };
871
871
  }
872
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
+
873
960
  // src/client/seat-methods.ts
874
961
  function seatsEndpoint(subscriptionId) {
875
962
  return `/api/v1/subscriptions/ext/${encodeURIComponent(subscriptionId)}/seats/assignments`;
@@ -1114,7 +1201,7 @@ function createNonContractMethods(deps) {
1114
1201
  }
1115
1202
 
1116
1203
  // src/client/version-check.ts
1117
- var SDK_VERSION = "5.18.0";
1204
+ var SDK_VERSION = "5.19.0";
1118
1205
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
1119
1206
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
1120
1207
  function sdkHeaders() {
@@ -2955,6 +3042,11 @@ function createFFIDClient(config) {
2955
3042
  createError,
2956
3043
  serviceCode: config.serviceCode
2957
3044
  });
3045
+ const { provisionUser, provisionOrganization } = createProvisioningMethods({
3046
+ fetchWithAuth,
3047
+ createError,
3048
+ authMode
3049
+ });
2958
3050
  const { getProfile, updateProfile } = createProfileMethods({
2959
3051
  fetchWithAuth,
2960
3052
  createError
@@ -3050,6 +3142,8 @@ function createFFIDClient(config) {
3050
3142
  addMember,
3051
3143
  updateMemberRole,
3052
3144
  removeMember,
3145
+ provisionUser,
3146
+ provisionOrganization,
3053
3147
  getProfile,
3054
3148
  updateProfile,
3055
3149
  // Non-contract ext API coverage (#3783)
@@ -1,5 +1,5 @@
1
- import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-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';
@@ -1,5 +1,5 @@
1
- import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-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';