@authowl/react 0.18.9 → 0.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
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { AuthConfig, Locale, AuthOwlClient, PublicConfig, ConsentStatus, OrganizationDetails, OrganizationMembership, HasParams, AuthUser, AuthClientError, SessionState, Organization, AuthOwlErrorCode } from '@authowl/core';
2
+ import { AuthConfig, Locale, AuthOwlClient, PublicConfig, ConsentStatus, OrganizationInvitationDetails, OrganizationDetails, OrganizationMembership, HasParams, AuthUser, AuthClientError, SessionState, Organization, AuthOwlErrorCode } from '@authowl/core';
3
3
  export { AuthOwlError, AuthPasskey, ConsentStatus, HasParams, InvalidKeyError, Organization, OrganizationDetails, OrganizationInvitation, OrganizationMember, OrganizationMemberWithUser, OrganizationMembership, OrganizationRoleSummary, OrganizationTeam, OrganizationUserInvitation, PublicConfig, RateLimitedError, createMembershipHas, membershipHas, membershipHasPermission, membershipHasTeam } from '@authowl/core';
4
4
 
5
5
  type Appearance = {
@@ -26,9 +26,19 @@ type AuthOwlProviderProps = AuthConfig & {
26
26
  * project's default from public-config ('en' until the config loads).
27
27
  */
28
28
  locale?: Locale | 'auto';
29
+ /**
30
+ * Render the organization-invitation prompt when this browser arrives from an
31
+ * invitation link. Default true, because the link is otherwise inert: the
32
+ * emailed URL lands on the operator's own page and nothing else redeems it.
33
+ *
34
+ * Pass false for a headless app - it never imports our stylesheet, so the
35
+ * modal would render unstyled - and drive `useOrganizationInvitation()`
36
+ * instead.
37
+ */
38
+ invitationPrompt?: boolean;
29
39
  children: React.ReactNode;
30
40
  };
31
- declare function AuthOwlProvider({ publishableKey, apiUrl, fetch, appearance, locale: localeProp, children, }: AuthOwlProviderProps): React.JSX.Element;
41
+ declare function AuthOwlProvider({ publishableKey, apiUrl, fetch, appearance, locale: localeProp, invitationPrompt, children, }: AuthOwlProviderProps): React.JSX.Element;
32
42
  declare function useAuthOwlContext(): Ctx;
33
43
 
34
44
  /** The active component locale (resolved by <AuthOwlProvider>). */
@@ -149,6 +159,30 @@ type UseOrganizationResult = {
149
159
  * the active org when one is set. Advisory, like the rest of the client surface.
150
160
  */
151
161
  declare function useOrganization(): UseOrganizationResult;
162
+ type InvitationPromptStatus = 'idle' | 'loading' | 'ready' | 'joining' | 'wrong_account' | 'verify_email' | 'gone' | 'error';
163
+ type UseOrganizationInvitationResult = {
164
+ /** The stashed invitation once it has been read back, else null. */
165
+ invitation: OrganizationInvitationDetails | null;
166
+ status: InvitationPromptStatus;
167
+ /** Redeem it. Resolves true when the membership was written. */
168
+ accept: () => Promise<boolean>;
169
+ /** Forget it locally. Never rejects it server-side - that is a terminal state. */
170
+ dismiss: () => void;
171
+ };
172
+ /**
173
+ * The organization invitation this browser arrived carrying, if any.
174
+ *
175
+ * The emailed link lands on the operator's page with `?authowl_invitation=<id>`
176
+ * and the only route that can redeem it needs a session, which the invitee
177
+ * usually does not have yet. `AuthOwlProvider` captures the id into storage on
178
+ * mount so it survives the sign-up's own redirects; this hook reads it back once
179
+ * a session exists and drives the redemption.
180
+ *
181
+ * The details come from `getInvitation`, which is recipient-only - so the
182
+ * organization's name is available to the person invited and to nobody else,
183
+ * and no pre-authentication call can leak it.
184
+ */
185
+ declare function useOrganizationInvitation(): UseOrganizationInvitationResult;
152
186
  type UseSignInResult = {
153
187
  /** Email + password sign-in. */
154
188
  signIn: AuthOwlClient['signIn']['email'];
@@ -353,9 +387,11 @@ type PhoneOTPProps = {
353
387
  onSignedIn?: () => void;
354
388
  /** Optional navigation affordance when embedded in another sign-in surface. */
355
389
  onBack?: () => void;
390
+ /** Called when this phone belongs to an account that must use password + MFA. */
391
+ onMfaPasswordRequired?: () => void;
356
392
  };
357
393
  /** Egyptian phone sign-in with managed Turnstile, retry-safe send, and code verification. */
358
- declare function PhoneOTP({ redirectTo, onSignedIn, onBack }: PhoneOTPProps): React.JSX.Element;
394
+ declare function PhoneOTP({ redirectTo, onSignedIn, onBack, onMfaPasswordRequired, }: PhoneOTPProps): React.JSX.Element;
359
395
 
360
396
  type SignUpProps = {
361
397
  redirectTo?: string;
@@ -786,6 +822,25 @@ type OrganizationSwitcherProps = {
786
822
  };
787
823
  declare function OrganizationSwitcher({ showPersonalWorkspace, onOrganizationChange }?: OrganizationSwitcherProps): React.JSX.Element | null;
788
824
 
825
+ /**
826
+ * The one screen that turns an emailed organization invitation into a
827
+ * membership.
828
+ *
829
+ * It is CONFIRMED rather than automatic, and the reason is not taste: accepting
830
+ * can fail for reasons the user has to see and can act on - the organization is
831
+ * at its member cap, the role no longer fits the claim budget, the invitation
832
+ * expired, the session belongs to a different address. An automatic redeem has
833
+ * nowhere to render any of that, which would recreate the very defect this fixes
834
+ * (a flow that reports success and produces no membership) one layer up.
835
+ *
836
+ * `AuthOwlProvider` renders this, so an operator who mounts our components
837
+ * anywhere gets a working invitation flow without adding a route. Headless
838
+ * consumers pass `invitationPrompt={false}` and drive
839
+ * {@link useOrganizationInvitation} themselves - they never import our
840
+ * stylesheet, so the default modal would render unstyled for them.
841
+ */
842
+ declare function InvitationPrompt(): React.JSX.Element | null;
843
+
789
844
  type OrganizationListProps = {
790
845
  onOrganizationChange?: (organization: Organization | null) => void;
791
846
  };
@@ -845,4 +900,4 @@ type GoogleOneTapProps = {
845
900
  /** Invisible, server-configured Google One Tap conversion helper. */
846
901
  declare function GoogleOneTap({ disabled, nonce, autoSelect, cancelOnTapOutside, context, itpSupport, loginHint, hostedDomain, stateCookieDomain, scriptNonce, onSignedIn, onSkipped, onDismissed, onError, }: GoogleOneTapProps): null;
847
902
 
848
- export { type Appearance, AuthLoaded, type AuthLoadedProps, AuthLoading, type AuthLoadingProps, AuthOwlBadge, type AuthOwlBadgeProps, AuthOwlBranding, type AuthOwlBrandingProps, AuthOwlProvider, type AuthOwlProviderProps, type AutofillHost, BackupCodesManager, type BackupCodesManagerProps, Bidi, type ConfigState, ConsentDocLinks, type ConsentDocLinksProps, ConsentGate, type ConsentGateProps, CreateOrganization, type CreateOrganizationProps, DEFAULT_BRAND_COLOR, EmailOtpForm, type EmailOtpFormProps, ForgotPassword, type ForgotPasswordProps, GoogleOneTap, type GoogleOneTapDismissReason, type GoogleOneTapError, type GoogleOneTapErrorCode, type GoogleOneTapProps, type GoogleOneTapSkipReason, KNOWN_METHODS, type KnownMethod, MFAChallenge, type MFAChallengeProps, MFAEnrollment, type MFAEnrollmentProps, MFARequiredGate, type MFARequiredGateProps, MagicLinkForm, type MagicLinkFormProps, OrganizationList, type OrganizationListProps, OrganizationProfile, type OrganizationProfileProps, type OrganizationProfileSection, OrganizationSwitcher, type OrganizationSwitcherProps, PasskeyButton, type PasskeyButtonProps, PasskeyManager, type PasskeyManagerProps, PhoneOTP, type PhoneOTPProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, type SignInPlan, type SignInProps, SignOutButton, type SignOutButtonProps, SignUp, type SignUpProps, SignedIn, type SignedInProps, SignedOut, type SignedOutProps, SocialButtons, type SocialButtonsProps, Spinner, type UseAccountResult, type UseAuthResult, type UseConsentResult, type UseEmailVerificationResult, type UseMFAResult, type UseOrganizationResult, type UsePasskeysResult, type UsePasswordResetResult, type UsePublicConfigResult, type UseSignInResult, type UseSignOutResult, type UseSignUpResult, type UseUserResult, type UseWaitlistResult, UserButton, UserProfile, type UserProfileProps, type UserProfileSection, VerificationPending, type VerificationPendingProps, VerifyEmail, type VerifyEmailProps, Waitlist, type WaitlistProps, emailAutocomplete, resolveSignInMethods, useAccount, useAuth, useAuthClient, useAuthOwlContext, useConsent, useEmailVerification, useLocale, useMFA, useOrganization, usePasskeys, usePasswordReset, usePublicConfig, useSession, useSignIn, useSignOut, useSignUp, useUser, useWaitlist };
903
+ export { type Appearance, AuthLoaded, type AuthLoadedProps, AuthLoading, type AuthLoadingProps, AuthOwlBadge, type AuthOwlBadgeProps, AuthOwlBranding, type AuthOwlBrandingProps, AuthOwlProvider, type AuthOwlProviderProps, type AutofillHost, BackupCodesManager, type BackupCodesManagerProps, Bidi, type ConfigState, ConsentDocLinks, type ConsentDocLinksProps, ConsentGate, type ConsentGateProps, CreateOrganization, type CreateOrganizationProps, DEFAULT_BRAND_COLOR, EmailOtpForm, type EmailOtpFormProps, ForgotPassword, type ForgotPasswordProps, GoogleOneTap, type GoogleOneTapDismissReason, type GoogleOneTapError, type GoogleOneTapErrorCode, type GoogleOneTapProps, type GoogleOneTapSkipReason, InvitationPrompt, type InvitationPromptStatus, KNOWN_METHODS, type KnownMethod, MFAChallenge, type MFAChallengeProps, MFAEnrollment, type MFAEnrollmentProps, MFARequiredGate, type MFARequiredGateProps, MagicLinkForm, type MagicLinkFormProps, OrganizationList, type OrganizationListProps, OrganizationProfile, type OrganizationProfileProps, type OrganizationProfileSection, OrganizationSwitcher, type OrganizationSwitcherProps, PasskeyButton, type PasskeyButtonProps, PasskeyManager, type PasskeyManagerProps, PhoneOTP, type PhoneOTPProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, type SignInPlan, type SignInProps, SignOutButton, type SignOutButtonProps, SignUp, type SignUpProps, SignedIn, type SignedInProps, SignedOut, type SignedOutProps, SocialButtons, type SocialButtonsProps, Spinner, type UseAccountResult, type UseAuthResult, type UseConsentResult, type UseEmailVerificationResult, type UseMFAResult, type UseOrganizationInvitationResult, type UseOrganizationResult, type UsePasskeysResult, type UsePasswordResetResult, type UsePublicConfigResult, type UseSignInResult, type UseSignOutResult, type UseSignUpResult, type UseUserResult, type UseWaitlistResult, UserButton, UserProfile, type UserProfileProps, type UserProfileSection, VerificationPending, type VerificationPendingProps, VerifyEmail, type VerifyEmailProps, Waitlist, type WaitlistProps, emailAutocomplete, resolveSignInMethods, useAccount, useAuth, useAuthClient, useAuthOwlContext, useConsent, useEmailVerification, useLocale, useMFA, useOrganization, useOrganizationInvitation, usePasskeys, usePasswordReset, usePublicConfig, useSession, useSignIn, useSignOut, useSignUp, useUser, useWaitlist };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { AuthConfig, Locale, AuthOwlClient, PublicConfig, ConsentStatus, OrganizationDetails, OrganizationMembership, HasParams, AuthUser, AuthClientError, SessionState, Organization, AuthOwlErrorCode } from '@authowl/core';
2
+ import { AuthConfig, Locale, AuthOwlClient, PublicConfig, ConsentStatus, OrganizationInvitationDetails, OrganizationDetails, OrganizationMembership, HasParams, AuthUser, AuthClientError, SessionState, Organization, AuthOwlErrorCode } from '@authowl/core';
3
3
  export { AuthOwlError, AuthPasskey, ConsentStatus, HasParams, InvalidKeyError, Organization, OrganizationDetails, OrganizationInvitation, OrganizationMember, OrganizationMemberWithUser, OrganizationMembership, OrganizationRoleSummary, OrganizationTeam, OrganizationUserInvitation, PublicConfig, RateLimitedError, createMembershipHas, membershipHas, membershipHasPermission, membershipHasTeam } from '@authowl/core';
4
4
 
5
5
  type Appearance = {
@@ -26,9 +26,19 @@ type AuthOwlProviderProps = AuthConfig & {
26
26
  * project's default from public-config ('en' until the config loads).
27
27
  */
28
28
  locale?: Locale | 'auto';
29
+ /**
30
+ * Render the organization-invitation prompt when this browser arrives from an
31
+ * invitation link. Default true, because the link is otherwise inert: the
32
+ * emailed URL lands on the operator's own page and nothing else redeems it.
33
+ *
34
+ * Pass false for a headless app - it never imports our stylesheet, so the
35
+ * modal would render unstyled - and drive `useOrganizationInvitation()`
36
+ * instead.
37
+ */
38
+ invitationPrompt?: boolean;
29
39
  children: React.ReactNode;
30
40
  };
31
- declare function AuthOwlProvider({ publishableKey, apiUrl, fetch, appearance, locale: localeProp, children, }: AuthOwlProviderProps): React.JSX.Element;
41
+ declare function AuthOwlProvider({ publishableKey, apiUrl, fetch, appearance, locale: localeProp, invitationPrompt, children, }: AuthOwlProviderProps): React.JSX.Element;
32
42
  declare function useAuthOwlContext(): Ctx;
33
43
 
34
44
  /** The active component locale (resolved by <AuthOwlProvider>). */
@@ -149,6 +159,30 @@ type UseOrganizationResult = {
149
159
  * the active org when one is set. Advisory, like the rest of the client surface.
150
160
  */
151
161
  declare function useOrganization(): UseOrganizationResult;
162
+ type InvitationPromptStatus = 'idle' | 'loading' | 'ready' | 'joining' | 'wrong_account' | 'verify_email' | 'gone' | 'error';
163
+ type UseOrganizationInvitationResult = {
164
+ /** The stashed invitation once it has been read back, else null. */
165
+ invitation: OrganizationInvitationDetails | null;
166
+ status: InvitationPromptStatus;
167
+ /** Redeem it. Resolves true when the membership was written. */
168
+ accept: () => Promise<boolean>;
169
+ /** Forget it locally. Never rejects it server-side - that is a terminal state. */
170
+ dismiss: () => void;
171
+ };
172
+ /**
173
+ * The organization invitation this browser arrived carrying, if any.
174
+ *
175
+ * The emailed link lands on the operator's page with `?authowl_invitation=<id>`
176
+ * and the only route that can redeem it needs a session, which the invitee
177
+ * usually does not have yet. `AuthOwlProvider` captures the id into storage on
178
+ * mount so it survives the sign-up's own redirects; this hook reads it back once
179
+ * a session exists and drives the redemption.
180
+ *
181
+ * The details come from `getInvitation`, which is recipient-only - so the
182
+ * organization's name is available to the person invited and to nobody else,
183
+ * and no pre-authentication call can leak it.
184
+ */
185
+ declare function useOrganizationInvitation(): UseOrganizationInvitationResult;
152
186
  type UseSignInResult = {
153
187
  /** Email + password sign-in. */
154
188
  signIn: AuthOwlClient['signIn']['email'];
@@ -353,9 +387,11 @@ type PhoneOTPProps = {
353
387
  onSignedIn?: () => void;
354
388
  /** Optional navigation affordance when embedded in another sign-in surface. */
355
389
  onBack?: () => void;
390
+ /** Called when this phone belongs to an account that must use password + MFA. */
391
+ onMfaPasswordRequired?: () => void;
356
392
  };
357
393
  /** Egyptian phone sign-in with managed Turnstile, retry-safe send, and code verification. */
358
- declare function PhoneOTP({ redirectTo, onSignedIn, onBack }: PhoneOTPProps): React.JSX.Element;
394
+ declare function PhoneOTP({ redirectTo, onSignedIn, onBack, onMfaPasswordRequired, }: PhoneOTPProps): React.JSX.Element;
359
395
 
360
396
  type SignUpProps = {
361
397
  redirectTo?: string;
@@ -786,6 +822,25 @@ type OrganizationSwitcherProps = {
786
822
  };
787
823
  declare function OrganizationSwitcher({ showPersonalWorkspace, onOrganizationChange }?: OrganizationSwitcherProps): React.JSX.Element | null;
788
824
 
825
+ /**
826
+ * The one screen that turns an emailed organization invitation into a
827
+ * membership.
828
+ *
829
+ * It is CONFIRMED rather than automatic, and the reason is not taste: accepting
830
+ * can fail for reasons the user has to see and can act on - the organization is
831
+ * at its member cap, the role no longer fits the claim budget, the invitation
832
+ * expired, the session belongs to a different address. An automatic redeem has
833
+ * nowhere to render any of that, which would recreate the very defect this fixes
834
+ * (a flow that reports success and produces no membership) one layer up.
835
+ *
836
+ * `AuthOwlProvider` renders this, so an operator who mounts our components
837
+ * anywhere gets a working invitation flow without adding a route. Headless
838
+ * consumers pass `invitationPrompt={false}` and drive
839
+ * {@link useOrganizationInvitation} themselves - they never import our
840
+ * stylesheet, so the default modal would render unstyled for them.
841
+ */
842
+ declare function InvitationPrompt(): React.JSX.Element | null;
843
+
789
844
  type OrganizationListProps = {
790
845
  onOrganizationChange?: (organization: Organization | null) => void;
791
846
  };
@@ -845,4 +900,4 @@ type GoogleOneTapProps = {
845
900
  /** Invisible, server-configured Google One Tap conversion helper. */
846
901
  declare function GoogleOneTap({ disabled, nonce, autoSelect, cancelOnTapOutside, context, itpSupport, loginHint, hostedDomain, stateCookieDomain, scriptNonce, onSignedIn, onSkipped, onDismissed, onError, }: GoogleOneTapProps): null;
847
902
 
848
- export { type Appearance, AuthLoaded, type AuthLoadedProps, AuthLoading, type AuthLoadingProps, AuthOwlBadge, type AuthOwlBadgeProps, AuthOwlBranding, type AuthOwlBrandingProps, AuthOwlProvider, type AuthOwlProviderProps, type AutofillHost, BackupCodesManager, type BackupCodesManagerProps, Bidi, type ConfigState, ConsentDocLinks, type ConsentDocLinksProps, ConsentGate, type ConsentGateProps, CreateOrganization, type CreateOrganizationProps, DEFAULT_BRAND_COLOR, EmailOtpForm, type EmailOtpFormProps, ForgotPassword, type ForgotPasswordProps, GoogleOneTap, type GoogleOneTapDismissReason, type GoogleOneTapError, type GoogleOneTapErrorCode, type GoogleOneTapProps, type GoogleOneTapSkipReason, KNOWN_METHODS, type KnownMethod, MFAChallenge, type MFAChallengeProps, MFAEnrollment, type MFAEnrollmentProps, MFARequiredGate, type MFARequiredGateProps, MagicLinkForm, type MagicLinkFormProps, OrganizationList, type OrganizationListProps, OrganizationProfile, type OrganizationProfileProps, type OrganizationProfileSection, OrganizationSwitcher, type OrganizationSwitcherProps, PasskeyButton, type PasskeyButtonProps, PasskeyManager, type PasskeyManagerProps, PhoneOTP, type PhoneOTPProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, type SignInPlan, type SignInProps, SignOutButton, type SignOutButtonProps, SignUp, type SignUpProps, SignedIn, type SignedInProps, SignedOut, type SignedOutProps, SocialButtons, type SocialButtonsProps, Spinner, type UseAccountResult, type UseAuthResult, type UseConsentResult, type UseEmailVerificationResult, type UseMFAResult, type UseOrganizationResult, type UsePasskeysResult, type UsePasswordResetResult, type UsePublicConfigResult, type UseSignInResult, type UseSignOutResult, type UseSignUpResult, type UseUserResult, type UseWaitlistResult, UserButton, UserProfile, type UserProfileProps, type UserProfileSection, VerificationPending, type VerificationPendingProps, VerifyEmail, type VerifyEmailProps, Waitlist, type WaitlistProps, emailAutocomplete, resolveSignInMethods, useAccount, useAuth, useAuthClient, useAuthOwlContext, useConsent, useEmailVerification, useLocale, useMFA, useOrganization, usePasskeys, usePasswordReset, usePublicConfig, useSession, useSignIn, useSignOut, useSignUp, useUser, useWaitlist };
903
+ export { type Appearance, AuthLoaded, type AuthLoadedProps, AuthLoading, type AuthLoadingProps, AuthOwlBadge, type AuthOwlBadgeProps, AuthOwlBranding, type AuthOwlBrandingProps, AuthOwlProvider, type AuthOwlProviderProps, type AutofillHost, BackupCodesManager, type BackupCodesManagerProps, Bidi, type ConfigState, ConsentDocLinks, type ConsentDocLinksProps, ConsentGate, type ConsentGateProps, CreateOrganization, type CreateOrganizationProps, DEFAULT_BRAND_COLOR, EmailOtpForm, type EmailOtpFormProps, ForgotPassword, type ForgotPasswordProps, GoogleOneTap, type GoogleOneTapDismissReason, type GoogleOneTapError, type GoogleOneTapErrorCode, type GoogleOneTapProps, type GoogleOneTapSkipReason, InvitationPrompt, type InvitationPromptStatus, KNOWN_METHODS, type KnownMethod, MFAChallenge, type MFAChallengeProps, MFAEnrollment, type MFAEnrollmentProps, MFARequiredGate, type MFARequiredGateProps, MagicLinkForm, type MagicLinkFormProps, OrganizationList, type OrganizationListProps, OrganizationProfile, type OrganizationProfileProps, type OrganizationProfileSection, OrganizationSwitcher, type OrganizationSwitcherProps, PasskeyButton, type PasskeyButtonProps, PasskeyManager, type PasskeyManagerProps, PhoneOTP, type PhoneOTPProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, type SignInPlan, type SignInProps, SignOutButton, type SignOutButtonProps, SignUp, type SignUpProps, SignedIn, type SignedInProps, SignedOut, type SignedOutProps, SocialButtons, type SocialButtonsProps, Spinner, type UseAccountResult, type UseAuthResult, type UseConsentResult, type UseEmailVerificationResult, type UseMFAResult, type UseOrganizationInvitationResult, type UseOrganizationResult, type UsePasskeysResult, type UsePasswordResetResult, type UsePublicConfigResult, type UseSignInResult, type UseSignOutResult, type UseSignUpResult, type UseUserResult, type UseWaitlistResult, UserButton, UserProfile, type UserProfileProps, type UserProfileSection, VerificationPending, type VerificationPendingProps, VerifyEmail, type VerifyEmailProps, Waitlist, type WaitlistProps, emailAutocomplete, resolveSignInMethods, useAccount, useAuth, useAuthClient, useAuthOwlContext, useConsent, useEmailVerification, useLocale, useMFA, useOrganization, useOrganizationInvitation, usePasskeys, usePasswordReset, usePublicConfig, useSession, useSignIn, useSignOut, useSignUp, useUser, useWaitlist };