azirid-react 0.13.2 → 0.14.1
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/README.md +54 -196
- package/dist/index.cjs +43 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -67
- package/dist/index.d.ts +12 -67
- package/dist/index.js +43 -65
- package/dist/index.js.map +1 -1
- package/dist/next-proxy.cjs +19 -3
- package/dist/next-proxy.cjs.map +1 -1
- package/dist/next-proxy.d.cts +19 -14
- package/dist/next-proxy.d.ts +19 -14
- package/dist/next-proxy.js +19 -3
- package/dist/next-proxy.js.map +1 -1
- package/dist/server.cjs +0 -35
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -25
- package/dist/server.d.ts +1 -25
- package/dist/server.js +1 -35
- package/dist/server.js.map +1 -1
- package/package.json +8 -25
- package/dist/next-handlers.cjs +0 -148
- package/dist/next-handlers.cjs.map +0 -1
- package/dist/next-handlers.d.cts +0 -121
- package/dist/next-handlers.d.ts +0 -121
- package/dist/next-handlers.js +0 -138
- package/dist/next-handlers.js.map +0 -1
- package/dist/next.cjs +0 -182
- package/dist/next.cjs.map +0 -1
- package/dist/next.d.cts +0 -182
- package/dist/next.d.ts +0 -182
- package/dist/next.js +0 -170
- package/dist/next.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -202,26 +202,7 @@ interface RegisterPasskeyData {
|
|
|
202
202
|
}
|
|
203
203
|
interface AziridProviderProps {
|
|
204
204
|
children: ReactNode;
|
|
205
|
-
/**
|
|
206
|
-
* Azirid API URL for **direct mode** (requests go straight to the API).
|
|
207
|
-
*
|
|
208
|
-
* - **Omitted** → proxy mode (recommended for Next.js). Requests go to
|
|
209
|
-
* your app's `/api/auth/*` route handler which proxies them securely.
|
|
210
|
-
* Cookies are first-party. No CORS needed.
|
|
211
|
-
*
|
|
212
|
-
* - **Set** → direct mode. Requests go directly to this URL.
|
|
213
|
-
* Requires CORS configured on the API.
|
|
214
|
-
*
|
|
215
|
-
* @example Direct mode (React SPA / Vite)
|
|
216
|
-
* ```tsx
|
|
217
|
-
* <AziridProvider apiUrl="https://api.azirid.com" publishableKey="pk_live_...">
|
|
218
|
-
* ```
|
|
219
|
-
*
|
|
220
|
-
* @example Proxy mode (Next.js — recommended)
|
|
221
|
-
* ```tsx
|
|
222
|
-
* <AziridProvider publishableKey="pk_live_...">
|
|
223
|
-
* ```
|
|
224
|
-
*/
|
|
205
|
+
/** @internal Override API URL. Only for Azirid monorepo development. */
|
|
225
206
|
apiUrl?: string;
|
|
226
207
|
/** Extra headers to send with every request */
|
|
227
208
|
fetchOptions?: Record<string, string>;
|
|
@@ -250,13 +231,6 @@ interface AziridProviderProps {
|
|
|
250
231
|
autoBootstrap?: boolean;
|
|
251
232
|
/** Interval in ms for proactive token refresh (default: 50000 = 50 seconds). Set to 0 to disable. */
|
|
252
233
|
refreshInterval?: number;
|
|
253
|
-
/**
|
|
254
|
-
* URL of a local API route to sync the session cookie (for server actions).
|
|
255
|
-
* - In dev mode (pk_dev_*): auto-activates with "/api/auth/session"
|
|
256
|
-
* - In prod mode (pk_live_*): disabled by default
|
|
257
|
-
* - Pass a string to force a custom URL, or false to force disable
|
|
258
|
-
*/
|
|
259
|
-
sessionSyncUrl?: string | false;
|
|
260
234
|
/** Publishable key for the app (e.g. pk_development_a1b2c3...) */
|
|
261
235
|
publishableKey?: string;
|
|
262
236
|
/** Tenant ID for multi-tenant apps */
|
|
@@ -777,25 +751,12 @@ interface HandoffCallbackProps {
|
|
|
777
751
|
/**
|
|
778
752
|
* Standalone component for handling impersonation handoff redirects.
|
|
779
753
|
*
|
|
780
|
-
* Does NOT
|
|
781
|
-
* API URL from the `&api=` query parameter
|
|
782
|
-
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
* ```tsx
|
|
787
|
-
* // app/auth/handoff/page.tsx
|
|
788
|
-
* import { HandoffCallback } from 'azirid-react'
|
|
789
|
-
*
|
|
790
|
-
* export default function HandoffPage() {
|
|
791
|
-
* return (
|
|
792
|
-
* <HandoffCallback
|
|
793
|
-
* onSuccess={() => window.location.href = '/'}
|
|
794
|
-
* onError={() => window.location.href = '/login'}
|
|
795
|
-
* />
|
|
796
|
-
* )
|
|
797
|
-
* }
|
|
798
|
-
* ```
|
|
754
|
+
* Does NOT depend on AziridProvider. Works independently by:
|
|
755
|
+
* 1. Reading the API URL from the `&api=` query parameter
|
|
756
|
+
* 2. Exchanging the handoff code for tokens directly with the API
|
|
757
|
+
* 3. Storing tokens in sessionStorage
|
|
758
|
+
* 4. Setting the __session cookie for SSR access
|
|
759
|
+
* 5. Redirecting to the app
|
|
799
760
|
*/
|
|
800
761
|
declare function HandoffCallback({ onSuccess, onError, loadingText, errorText, }: HandoffCallbackProps): react_jsx_runtime.JSX.Element;
|
|
801
762
|
|
|
@@ -876,27 +837,20 @@ declare const SUFFIXES: {
|
|
|
876
837
|
readonly branches: "branches";
|
|
877
838
|
readonly paymentMethods: "payment-methods";
|
|
878
839
|
};
|
|
879
|
-
/** Base
|
|
880
|
-
declare const
|
|
881
|
-
/** Proxy mode (Next.js): requests go to the same origin via route handler */
|
|
882
|
-
readonly proxy: "/api/auth";
|
|
883
|
-
/** Direct mode: requests go straight to the Azirid API */
|
|
884
|
-
readonly direct: "/v1/users/auth";
|
|
885
|
-
};
|
|
840
|
+
/** Base path for auth endpoints */
|
|
841
|
+
declare const AUTH_BASE_PATH: "/v1/users/auth";
|
|
886
842
|
/** Build full path map from a basePath */
|
|
887
843
|
declare function buildPaths(basePath: string): AuthPaths;
|
|
888
|
-
/** Default paths
|
|
844
|
+
/** Default paths */
|
|
889
845
|
declare const PATHS: AuthPaths;
|
|
890
846
|
type AuthPaths = {
|
|
891
847
|
[K in keyof typeof SUFFIXES]: string;
|
|
892
848
|
};
|
|
893
849
|
interface AccessClientConfig {
|
|
894
|
-
/** Base URL of the Azirid API
|
|
850
|
+
/** Base URL of the Azirid API */
|
|
895
851
|
baseUrl: string;
|
|
896
852
|
/**
|
|
897
853
|
* Base path for auth endpoints.
|
|
898
|
-
* - Proxy mode: '/api/auth' (matches Next.js route handler)
|
|
899
|
-
* - Direct mode: '/v1/users/auth' (matches API routes)
|
|
900
854
|
* @default '/v1/users/auth'
|
|
901
855
|
*/
|
|
902
856
|
basePath?: string;
|
|
@@ -2061,15 +2015,6 @@ interface PayphoneModalProps {
|
|
|
2061
2015
|
onClose: () => void;
|
|
2062
2016
|
}
|
|
2063
2017
|
|
|
2064
|
-
interface SessionSyncOptions {
|
|
2065
|
-
/** Cookie name (default: "__session") */
|
|
2066
|
-
cookieName?: string;
|
|
2067
|
-
/** Set Secure flag on cookie (default: false) */
|
|
2068
|
-
secure?: boolean;
|
|
2069
|
-
/** Cookie max age in seconds (default: 3600 = 1h) */
|
|
2070
|
-
maxAge?: number;
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
2018
|
declare const SDK_VERSION: string;
|
|
2074
2019
|
|
|
2075
|
-
export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, AuthForm, type AuthFormProps, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AuthView, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps,
|
|
2020
|
+
export { AUTH_BASE_PATH, type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, AuthForm, type AuthFormProps, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AuthView, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, type BillingInvoice, type BillingPlan, type BootstrapResponse, type Branch, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type CreateTenantData, type FieldError, ForgotPasswordForm, type ForgotPasswordFormProps, type ForgotPasswordInput, HandoffCallback, type HandoffCallbackProps, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, type MutationHookConfig, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, type PasswordResetConfirmData, type PasswordResetRequestData, PayButton, type PayButtonProps, type PayButtonStatus, type PaymentIntent, type PaymentMethod, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneCheckoutStatus, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, PayphoneWidgetRenderer, type PricingCardProps, type PricingFeatureListProps, PricingTable, type PricingTableProps, type ProviderModalProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, type ResetPasswordConfirmInput, ResetPasswordForm, type ResetPasswordFormProps, SDK_VERSION, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SimpleMutationOptions, type SocialLoginData, type SocialLoginInput, type SubmitProofData, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TenantMemberInfo, type TenantWithRole, type TransferModalProps, type TransferPaymentStatus, type TransferProof, type UploadTransferProofRequest, type UploadTransferProofResponse, type UseBootstrapOptions, type UseBootstrapReturn, type UseChangePasswordOptions, type UseChangePasswordReturn, type UseCheckoutOptions, type UseFormReturn, type UseLoginOptions, type UseLoginReturn, type UseLogoutOptions, type UseLogoutReturn, type UseMagicLinkOptions, type UseMagicLinkReturn, type UsePasskeysOptions, type UsePasskeysReturn, type UsePasswordResetOptions, type UsePasswordResetReturn, type UsePayButtonOptions, type UsePayButtonReturn, type UsePayphoneCheckoutOptions, type UsePayphoneCheckoutReturn, type UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UseTransferPaymentOptions, type UseTransferPaymentReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createForgotPasswordSchema, createLoginSchema, createMutationHook, createResetPasswordConfirmSchema, createSignupSchema, en, es, forgotPasswordSchema, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resetPasswordConfirmSchema, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranches, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePayButton, usePaymentMethods, usePaymentProviders, usePayphoneCheckout, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferPayment, useTransferProofs, useUploadTransferProof };
|
package/dist/index.d.ts
CHANGED
|
@@ -202,26 +202,7 @@ interface RegisterPasskeyData {
|
|
|
202
202
|
}
|
|
203
203
|
interface AziridProviderProps {
|
|
204
204
|
children: ReactNode;
|
|
205
|
-
/**
|
|
206
|
-
* Azirid API URL for **direct mode** (requests go straight to the API).
|
|
207
|
-
*
|
|
208
|
-
* - **Omitted** → proxy mode (recommended for Next.js). Requests go to
|
|
209
|
-
* your app's `/api/auth/*` route handler which proxies them securely.
|
|
210
|
-
* Cookies are first-party. No CORS needed.
|
|
211
|
-
*
|
|
212
|
-
* - **Set** → direct mode. Requests go directly to this URL.
|
|
213
|
-
* Requires CORS configured on the API.
|
|
214
|
-
*
|
|
215
|
-
* @example Direct mode (React SPA / Vite)
|
|
216
|
-
* ```tsx
|
|
217
|
-
* <AziridProvider apiUrl="https://api.azirid.com" publishableKey="pk_live_...">
|
|
218
|
-
* ```
|
|
219
|
-
*
|
|
220
|
-
* @example Proxy mode (Next.js — recommended)
|
|
221
|
-
* ```tsx
|
|
222
|
-
* <AziridProvider publishableKey="pk_live_...">
|
|
223
|
-
* ```
|
|
224
|
-
*/
|
|
205
|
+
/** @internal Override API URL. Only for Azirid monorepo development. */
|
|
225
206
|
apiUrl?: string;
|
|
226
207
|
/** Extra headers to send with every request */
|
|
227
208
|
fetchOptions?: Record<string, string>;
|
|
@@ -250,13 +231,6 @@ interface AziridProviderProps {
|
|
|
250
231
|
autoBootstrap?: boolean;
|
|
251
232
|
/** Interval in ms for proactive token refresh (default: 50000 = 50 seconds). Set to 0 to disable. */
|
|
252
233
|
refreshInterval?: number;
|
|
253
|
-
/**
|
|
254
|
-
* URL of a local API route to sync the session cookie (for server actions).
|
|
255
|
-
* - In dev mode (pk_dev_*): auto-activates with "/api/auth/session"
|
|
256
|
-
* - In prod mode (pk_live_*): disabled by default
|
|
257
|
-
* - Pass a string to force a custom URL, or false to force disable
|
|
258
|
-
*/
|
|
259
|
-
sessionSyncUrl?: string | false;
|
|
260
234
|
/** Publishable key for the app (e.g. pk_development_a1b2c3...) */
|
|
261
235
|
publishableKey?: string;
|
|
262
236
|
/** Tenant ID for multi-tenant apps */
|
|
@@ -777,25 +751,12 @@ interface HandoffCallbackProps {
|
|
|
777
751
|
/**
|
|
778
752
|
* Standalone component for handling impersonation handoff redirects.
|
|
779
753
|
*
|
|
780
|
-
* Does NOT
|
|
781
|
-
* API URL from the `&api=` query parameter
|
|
782
|
-
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
* ```tsx
|
|
787
|
-
* // app/auth/handoff/page.tsx
|
|
788
|
-
* import { HandoffCallback } from 'azirid-react'
|
|
789
|
-
*
|
|
790
|
-
* export default function HandoffPage() {
|
|
791
|
-
* return (
|
|
792
|
-
* <HandoffCallback
|
|
793
|
-
* onSuccess={() => window.location.href = '/'}
|
|
794
|
-
* onError={() => window.location.href = '/login'}
|
|
795
|
-
* />
|
|
796
|
-
* )
|
|
797
|
-
* }
|
|
798
|
-
* ```
|
|
754
|
+
* Does NOT depend on AziridProvider. Works independently by:
|
|
755
|
+
* 1. Reading the API URL from the `&api=` query parameter
|
|
756
|
+
* 2. Exchanging the handoff code for tokens directly with the API
|
|
757
|
+
* 3. Storing tokens in sessionStorage
|
|
758
|
+
* 4. Setting the __session cookie for SSR access
|
|
759
|
+
* 5. Redirecting to the app
|
|
799
760
|
*/
|
|
800
761
|
declare function HandoffCallback({ onSuccess, onError, loadingText, errorText, }: HandoffCallbackProps): react_jsx_runtime.JSX.Element;
|
|
801
762
|
|
|
@@ -876,27 +837,20 @@ declare const SUFFIXES: {
|
|
|
876
837
|
readonly branches: "branches";
|
|
877
838
|
readonly paymentMethods: "payment-methods";
|
|
878
839
|
};
|
|
879
|
-
/** Base
|
|
880
|
-
declare const
|
|
881
|
-
/** Proxy mode (Next.js): requests go to the same origin via route handler */
|
|
882
|
-
readonly proxy: "/api/auth";
|
|
883
|
-
/** Direct mode: requests go straight to the Azirid API */
|
|
884
|
-
readonly direct: "/v1/users/auth";
|
|
885
|
-
};
|
|
840
|
+
/** Base path for auth endpoints */
|
|
841
|
+
declare const AUTH_BASE_PATH: "/v1/users/auth";
|
|
886
842
|
/** Build full path map from a basePath */
|
|
887
843
|
declare function buildPaths(basePath: string): AuthPaths;
|
|
888
|
-
/** Default paths
|
|
844
|
+
/** Default paths */
|
|
889
845
|
declare const PATHS: AuthPaths;
|
|
890
846
|
type AuthPaths = {
|
|
891
847
|
[K in keyof typeof SUFFIXES]: string;
|
|
892
848
|
};
|
|
893
849
|
interface AccessClientConfig {
|
|
894
|
-
/** Base URL of the Azirid API
|
|
850
|
+
/** Base URL of the Azirid API */
|
|
895
851
|
baseUrl: string;
|
|
896
852
|
/**
|
|
897
853
|
* Base path for auth endpoints.
|
|
898
|
-
* - Proxy mode: '/api/auth' (matches Next.js route handler)
|
|
899
|
-
* - Direct mode: '/v1/users/auth' (matches API routes)
|
|
900
854
|
* @default '/v1/users/auth'
|
|
901
855
|
*/
|
|
902
856
|
basePath?: string;
|
|
@@ -2061,15 +2015,6 @@ interface PayphoneModalProps {
|
|
|
2061
2015
|
onClose: () => void;
|
|
2062
2016
|
}
|
|
2063
2017
|
|
|
2064
|
-
interface SessionSyncOptions {
|
|
2065
|
-
/** Cookie name (default: "__session") */
|
|
2066
|
-
cookieName?: string;
|
|
2067
|
-
/** Set Secure flag on cookie (default: false) */
|
|
2068
|
-
secure?: boolean;
|
|
2069
|
-
/** Cookie max age in seconds (default: 3600 = 1h) */
|
|
2070
|
-
maxAge?: number;
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
2018
|
declare const SDK_VERSION: string;
|
|
2074
2019
|
|
|
2075
|
-
export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, AuthForm, type AuthFormProps, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AuthView, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps,
|
|
2020
|
+
export { AUTH_BASE_PATH, type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, AuthForm, type AuthFormProps, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AuthView, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, type BillingInvoice, type BillingPlan, type BootstrapResponse, type Branch, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type CreateTenantData, type FieldError, ForgotPasswordForm, type ForgotPasswordFormProps, type ForgotPasswordInput, HandoffCallback, type HandoffCallbackProps, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, type MutationHookConfig, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, type PasswordResetConfirmData, type PasswordResetRequestData, PayButton, type PayButtonProps, type PayButtonStatus, type PaymentIntent, type PaymentMethod, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneCheckoutStatus, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, PayphoneWidgetRenderer, type PricingCardProps, type PricingFeatureListProps, PricingTable, type PricingTableProps, type ProviderModalProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, type ResetPasswordConfirmInput, ResetPasswordForm, type ResetPasswordFormProps, SDK_VERSION, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SimpleMutationOptions, type SocialLoginData, type SocialLoginInput, type SubmitProofData, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TenantMemberInfo, type TenantWithRole, type TransferModalProps, type TransferPaymentStatus, type TransferProof, type UploadTransferProofRequest, type UploadTransferProofResponse, type UseBootstrapOptions, type UseBootstrapReturn, type UseChangePasswordOptions, type UseChangePasswordReturn, type UseCheckoutOptions, type UseFormReturn, type UseLoginOptions, type UseLoginReturn, type UseLogoutOptions, type UseLogoutReturn, type UseMagicLinkOptions, type UseMagicLinkReturn, type UsePasskeysOptions, type UsePasskeysReturn, type UsePasswordResetOptions, type UsePasswordResetReturn, type UsePayButtonOptions, type UsePayButtonReturn, type UsePayphoneCheckoutOptions, type UsePayphoneCheckoutReturn, type UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UseTransferPaymentOptions, type UseTransferPaymentReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createForgotPasswordSchema, createLoginSchema, createMutationHook, createResetPasswordConfirmSchema, createSignupSchema, en, es, forgotPasswordSchema, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resetPasswordConfirmSchema, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranches, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePayButton, usePaymentMethods, usePaymentProviders, usePayphoneCheckout, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferPayment, useTransferProofs, useUploadTransferProof };
|
package/dist/index.js
CHANGED
|
@@ -129,19 +129,14 @@ var SUFFIXES = {
|
|
|
129
129
|
branches: "branches",
|
|
130
130
|
paymentMethods: "payment-methods"
|
|
131
131
|
};
|
|
132
|
-
var
|
|
133
|
-
/** Proxy mode (Next.js): requests go to the same origin via route handler */
|
|
134
|
-
proxy: "/api/auth",
|
|
135
|
-
/** Direct mode: requests go straight to the Azirid API */
|
|
136
|
-
direct: "/v1/users/auth"
|
|
137
|
-
};
|
|
132
|
+
var AUTH_BASE_PATH = "/v1/users/auth";
|
|
138
133
|
function buildPaths(basePath) {
|
|
139
134
|
const bp = basePath.replace(/\/$/, "");
|
|
140
135
|
return Object.fromEntries(
|
|
141
136
|
Object.entries(SUFFIXES).map(([key, suffix]) => [key, `${bp}/${suffix}`])
|
|
142
137
|
);
|
|
143
138
|
}
|
|
144
|
-
var PATHS = buildPaths(
|
|
139
|
+
var PATHS = buildPaths(AUTH_BASE_PATH);
|
|
145
140
|
function createAccessClient(config, appContext) {
|
|
146
141
|
const baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
147
142
|
const paths = config.basePath ? buildPaths(config.basePath) : PATHS;
|
|
@@ -208,6 +203,13 @@ function createAccessClient(config, appContext) {
|
|
|
208
203
|
}
|
|
209
204
|
function setAccessToken(token) {
|
|
210
205
|
accessToken = token;
|
|
206
|
+
if (typeof document !== "undefined") {
|
|
207
|
+
if (token) {
|
|
208
|
+
document.cookie = `__session=${token}; Path=/; SameSite=Lax; Max-Age=900`;
|
|
209
|
+
} else {
|
|
210
|
+
document.cookie = "__session=; Path=/; SameSite=Lax; Max-Age=0";
|
|
211
|
+
}
|
|
212
|
+
}
|
|
211
213
|
}
|
|
212
214
|
function getAccessToken() {
|
|
213
215
|
return accessToken;
|
|
@@ -774,40 +776,12 @@ function AziridProviderInner({
|
|
|
774
776
|
[props.locale, props.messages]
|
|
775
777
|
);
|
|
776
778
|
const brandingValue = useMemo(() => ({ branding, messages }), [branding, messages]);
|
|
777
|
-
const isProxyMode = !props.apiUrl;
|
|
778
|
-
const syncUrl = useMemo(() => {
|
|
779
|
-
if (props.sessionSyncUrl === false) return null;
|
|
780
|
-
if (props.sessionSyncUrl) return props.sessionSyncUrl;
|
|
781
|
-
if (isProxyMode) return null;
|
|
782
|
-
if (client.appContext?.publishableKey?.startsWith("pk_dev")) {
|
|
783
|
-
return "/api/auth/session";
|
|
784
|
-
}
|
|
785
|
-
return null;
|
|
786
|
-
}, [props.sessionSyncUrl, client.appContext?.publishableKey, isProxyMode]);
|
|
787
|
-
const syncSession = useCallback(
|
|
788
|
-
(token) => {
|
|
789
|
-
if (!syncUrl) return;
|
|
790
|
-
if (token) {
|
|
791
|
-
fetch(syncUrl, {
|
|
792
|
-
method: "POST",
|
|
793
|
-
headers: { "Content-Type": "application/json" },
|
|
794
|
-
body: JSON.stringify({ token })
|
|
795
|
-
}).catch(() => {
|
|
796
|
-
});
|
|
797
|
-
} else {
|
|
798
|
-
fetch(syncUrl, { method: "DELETE" }).catch(() => {
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
|
-
},
|
|
802
|
-
[syncUrl]
|
|
803
|
-
);
|
|
804
779
|
const updateAccessToken = useCallback(
|
|
805
780
|
(token) => {
|
|
806
781
|
setAccessToken(token);
|
|
807
782
|
client.setAccessToken(token);
|
|
808
|
-
syncSession(token);
|
|
809
783
|
},
|
|
810
|
-
[client
|
|
784
|
+
[client]
|
|
811
785
|
);
|
|
812
786
|
const saveSessionTokens = useCallback(
|
|
813
787
|
(data) => {
|
|
@@ -1011,11 +985,9 @@ function AziridProvider(props) {
|
|
|
1011
985
|
publishableKey: props.publishableKey,
|
|
1012
986
|
tenantId: props.tenantId
|
|
1013
987
|
} : void 0;
|
|
1014
|
-
const
|
|
1015
|
-
const baseUrl = isProxy ? "" : props.apiUrl.replace(/\/$/, "");
|
|
1016
|
-
const basePath = isProxy ? BASE_PATHS.proxy : BASE_PATHS.direct;
|
|
988
|
+
const baseUrl = (props.apiUrl ?? "https://api.azirid.com").replace(/\/$/, "");
|
|
1017
989
|
return createAccessClient(
|
|
1018
|
-
{ baseUrl, basePath, headers: props.fetchOptions },
|
|
990
|
+
{ baseUrl, basePath: AUTH_BASE_PATH, headers: props.fetchOptions },
|
|
1019
991
|
appContext
|
|
1020
992
|
);
|
|
1021
993
|
}, [props.publishableKey, props.tenantId, props.fetchOptions, props.apiUrl]);
|
|
@@ -4027,29 +3999,8 @@ function HandoffCallback({
|
|
|
4027
3999
|
onError?.(new Error("No API URL in handoff link"));
|
|
4028
4000
|
return;
|
|
4029
4001
|
}
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
method: "POST",
|
|
4033
|
-
headers: { "Content-Type": "application/json" },
|
|
4034
|
-
credentials: "include",
|
|
4035
|
-
body: JSON.stringify({ code })
|
|
4036
|
-
}).then(async (res) => {
|
|
4037
|
-
if (!res.ok) {
|
|
4038
|
-
const body = await res.json().catch(() => null);
|
|
4039
|
-
throw new Error(body?.error?.message ?? body?.message ?? "Handoff exchange failed");
|
|
4040
|
-
}
|
|
4041
|
-
return res.json();
|
|
4042
|
-
}).then((raw) => {
|
|
4043
|
-
const json = raw && typeof raw === "object" && "data" in raw && "meta" in raw ? raw.data : raw;
|
|
4044
|
-
json.at ?? json.accessToken;
|
|
4045
|
-
const refreshToken = json.rt ?? json.refreshToken;
|
|
4046
|
-
const csrfToken = json.xc ?? json.csrfToken;
|
|
4047
|
-
try {
|
|
4048
|
-
if (refreshToken) sessionStorage.setItem("__azrt", refreshToken);
|
|
4049
|
-
if (csrfToken) sessionStorage.setItem("__azxc", csrfToken);
|
|
4050
|
-
} catch {
|
|
4051
|
-
}
|
|
4052
|
-
onSuccess?.(json.user);
|
|
4002
|
+
performHandoff(apiUrl, code).then((user) => {
|
|
4003
|
+
onSuccess?.(user);
|
|
4053
4004
|
}).catch((err) => {
|
|
4054
4005
|
setStatus("error");
|
|
4055
4006
|
const error = err instanceof Error ? err : new Error("Handoff exchange failed");
|
|
@@ -4062,6 +4013,33 @@ function HandoffCallback({
|
|
|
4062
4013
|
}
|
|
4063
4014
|
return /* @__PURE__ */ jsx("div", { style: wrapperStyle, children: /* @__PURE__ */ jsx("p", { style: messageStyle2, children: loadingText }) });
|
|
4064
4015
|
}
|
|
4016
|
+
async function performHandoff(apiUrl, code) {
|
|
4017
|
+
const exchangeUrl = `${apiUrl.replace(/\/+$/, "")}/users/auth/handoff/exchange`;
|
|
4018
|
+
const res = await fetch(exchangeUrl, {
|
|
4019
|
+
method: "POST",
|
|
4020
|
+
headers: { "Content-Type": "application/json" },
|
|
4021
|
+
credentials: "include",
|
|
4022
|
+
body: JSON.stringify({ code })
|
|
4023
|
+
});
|
|
4024
|
+
if (!res.ok) {
|
|
4025
|
+
const body = await res.json().catch(() => null);
|
|
4026
|
+
throw new Error(body?.error?.message ?? body?.message ?? "Handoff exchange failed");
|
|
4027
|
+
}
|
|
4028
|
+
const raw = await res.json();
|
|
4029
|
+
const json = raw && typeof raw === "object" && "data" in raw && "meta" in raw ? raw.data : raw;
|
|
4030
|
+
const refreshToken = json.rt ?? json.refreshToken;
|
|
4031
|
+
const csrfToken = json.xc ?? json.csrfToken;
|
|
4032
|
+
try {
|
|
4033
|
+
if (refreshToken) sessionStorage.setItem("__azrt", refreshToken);
|
|
4034
|
+
if (csrfToken) sessionStorage.setItem("__azxc", csrfToken);
|
|
4035
|
+
} catch {
|
|
4036
|
+
}
|
|
4037
|
+
const at = json.at ?? json.accessToken;
|
|
4038
|
+
if (at) {
|
|
4039
|
+
document.cookie = `__session=${at}; Path=/; SameSite=Lax; Max-Age=900`;
|
|
4040
|
+
}
|
|
4041
|
+
return json.user;
|
|
4042
|
+
}
|
|
4065
4043
|
var wrapperStyle = {
|
|
4066
4044
|
display: "flex",
|
|
4067
4045
|
flexDirection: "column",
|
|
@@ -4873,8 +4851,8 @@ function usePasswordToggle() {
|
|
|
4873
4851
|
}
|
|
4874
4852
|
|
|
4875
4853
|
// src/index.ts
|
|
4876
|
-
var SDK_VERSION = "0.
|
|
4854
|
+
var SDK_VERSION = "0.14.1";
|
|
4877
4855
|
|
|
4878
|
-
export { AuthForm, AziridProvider,
|
|
4856
|
+
export { AUTH_BASE_PATH, AuthForm, AziridProvider, CheckoutButton, ForgotPasswordForm, HandoffCallback, InvoiceList, LoginForm, PATHS, PayButton, PayphoneCallback, PayphoneWidgetRenderer, PricingTable, ReferralCard, ReferralStats, ResetPasswordForm, SDK_VERSION, SignupForm, SubscriptionBadge, buildPaths, changePasswordSchema, cn, createAccessClient, createForgotPasswordSchema, createLoginSchema, createMutationHook, createResetPasswordConfirmSchema, createSignupSchema, en, es, forgotPasswordSchema, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resetPasswordConfirmSchema, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranches, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePayButton, usePaymentMethods, usePaymentProviders, usePayphoneCheckout, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferPayment, useTransferProofs, useUploadTransferProof };
|
|
4879
4857
|
//# sourceMappingURL=index.js.map
|
|
4880
4858
|
//# sourceMappingURL=index.js.map
|