azirid-react 0.10.0 → 0.10.2
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 +34 -3
- package/dist/index.cjs +13 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -235,6 +235,17 @@ interface AziridProviderProps {
|
|
|
235
235
|
onError?: (error: string) => void;
|
|
236
236
|
/** Callback when session expires and refresh fails */
|
|
237
237
|
onSessionExpired?: () => void;
|
|
238
|
+
/**
|
|
239
|
+
* Called after any auth state change (login, signup, logout, token refresh).
|
|
240
|
+
* Use this in Next.js to call `router.refresh()` so server actions see updated cookies.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```tsx
|
|
244
|
+
* const router = useRouter()
|
|
245
|
+
* <AziridProvider onAuthStateChange={() => router.refresh()} />
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
onAuthStateChange?: () => void;
|
|
238
249
|
/** Auto-bootstrap session on mount (default: true) */
|
|
239
250
|
autoBootstrap?: boolean;
|
|
240
251
|
/** Interval in ms for proactive token refresh (default: 50000 = 50 seconds). Set to 0 to disable. */
|
package/dist/index.d.ts
CHANGED
|
@@ -235,6 +235,17 @@ interface AziridProviderProps {
|
|
|
235
235
|
onError?: (error: string) => void;
|
|
236
236
|
/** Callback when session expires and refresh fails */
|
|
237
237
|
onSessionExpired?: () => void;
|
|
238
|
+
/**
|
|
239
|
+
* Called after any auth state change (login, signup, logout, token refresh).
|
|
240
|
+
* Use this in Next.js to call `router.refresh()` so server actions see updated cookies.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```tsx
|
|
244
|
+
* const router = useRouter()
|
|
245
|
+
* <AziridProvider onAuthStateChange={() => router.refresh()} />
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
onAuthStateChange?: () => void;
|
|
238
249
|
/** Auto-bootstrap session on mount (default: true) */
|
|
239
250
|
autoBootstrap?: boolean;
|
|
240
251
|
/** Interval in ms for proactive token refresh (default: 50000 = 50 seconds). Set to 0 to disable. */
|
package/dist/index.js
CHANGED
|
@@ -602,6 +602,7 @@ function useAuthMutations(deps) {
|
|
|
602
602
|
updateAccessToken(normalizeToken(data));
|
|
603
603
|
saveSessionTokens(data);
|
|
604
604
|
setError(null);
|
|
605
|
+
props.onAuthStateChange?.();
|
|
605
606
|
props.onLoginSuccess?.(data);
|
|
606
607
|
},
|
|
607
608
|
onError: (err) => {
|
|
@@ -619,6 +620,7 @@ function useAuthMutations(deps) {
|
|
|
619
620
|
updateAccessToken(normalizeToken(data));
|
|
620
621
|
saveSessionTokens(data);
|
|
621
622
|
setError(null);
|
|
623
|
+
props.onAuthStateChange?.();
|
|
622
624
|
props.onSignupSuccess?.(data);
|
|
623
625
|
},
|
|
624
626
|
onError: (err) => {
|
|
@@ -632,6 +634,7 @@ function useAuthMutations(deps) {
|
|
|
632
634
|
clearSession();
|
|
633
635
|
setError(null);
|
|
634
636
|
queryClient.clear();
|
|
637
|
+
props.onAuthStateChange?.();
|
|
635
638
|
props.onLogoutSuccess?.();
|
|
636
639
|
}
|
|
637
640
|
});
|
|
@@ -3006,6 +3009,7 @@ function usePayButton({
|
|
|
3006
3009
|
const [payphoneConfig, setPayphoneConfig] = useState(null);
|
|
3007
3010
|
const [currentError, setCurrentError] = useState(null);
|
|
3008
3011
|
const payphoneConfirmTriggered = useRef(false);
|
|
3012
|
+
const { isBootstrapping } = useAzirid();
|
|
3009
3013
|
const params = typeof window !== "undefined" ? new URLSearchParams(window.location.search) : new URLSearchParams();
|
|
3010
3014
|
const callbackId = params.get("id");
|
|
3011
3015
|
const callbackClientTxId = params.get("clientTransactionId");
|
|
@@ -3088,12 +3092,12 @@ function usePayButton({
|
|
|
3088
3092
|
}
|
|
3089
3093
|
});
|
|
3090
3094
|
useEffect(() => {
|
|
3091
|
-
if (!isPayphoneCallback || payphoneConfirmTriggered.current) return;
|
|
3095
|
+
if (!isPayphoneCallback || payphoneConfirmTriggered.current || isBootstrapping) return;
|
|
3092
3096
|
payphoneConfirmTriggered.current = true;
|
|
3093
3097
|
setSelectedProvider("PAYPHONE");
|
|
3094
3098
|
setStatus("processing");
|
|
3095
3099
|
confirmPayphone({ id: Number(callbackId), clientTransactionId: callbackClientTxId });
|
|
3096
|
-
}, [isPayphoneCallback, callbackId, callbackClientTxId, confirmPayphone]);
|
|
3100
|
+
}, [isPayphoneCallback, isBootstrapping, callbackId, callbackClientTxId, confirmPayphone]);
|
|
3097
3101
|
const handleSdkError = useCallback(
|
|
3098
3102
|
(err) => {
|
|
3099
3103
|
setCurrentError(err);
|
|
@@ -3527,16 +3531,17 @@ function PayphoneCallback({ onSuccess, onError, className, style }) {
|
|
|
3527
3531
|
onSuccess,
|
|
3528
3532
|
onError
|
|
3529
3533
|
});
|
|
3534
|
+
const { isBootstrapping } = useAzirid();
|
|
3530
3535
|
const called = useRef(false);
|
|
3531
3536
|
useEffect(() => {
|
|
3532
|
-
if (called.current) return;
|
|
3537
|
+
if (called.current || isBootstrapping) return;
|
|
3533
3538
|
called.current = true;
|
|
3534
3539
|
const params = new URLSearchParams(window.location.search);
|
|
3535
3540
|
const id = params.get("id");
|
|
3536
3541
|
const clientTransactionId = params.get("clientTransactionId");
|
|
3537
3542
|
if (!id || !clientTransactionId) return;
|
|
3538
3543
|
mutate({ id: Number(id), clientTransactionId });
|
|
3539
|
-
}, [mutate]);
|
|
3544
|
+
}, [mutate, isBootstrapping]);
|
|
3540
3545
|
return /* @__PURE__ */ jsxs("div", { className, style: { textAlign: "center", padding: "32px", ...style }, children: [
|
|
3541
3546
|
isPending && /* @__PURE__ */ jsxs("div", { children: [
|
|
3542
3547
|
/* @__PURE__ */ jsx("p", { style: textStyle, children: "Confirming your payment..." }),
|
|
@@ -4038,6 +4043,7 @@ function usePayphoneCheckout({
|
|
|
4038
4043
|
const [currentError, setCurrentError] = useState(null);
|
|
4039
4044
|
const checkoutTriggered = useRef(false);
|
|
4040
4045
|
const confirmTriggered = useRef(false);
|
|
4046
|
+
const { isBootstrapping } = useAzirid();
|
|
4041
4047
|
const params = typeof window !== "undefined" ? new URLSearchParams(window.location.search) : new URLSearchParams();
|
|
4042
4048
|
const callbackId = params.get("id");
|
|
4043
4049
|
const callbackClientTxId = params.get("clientTransactionId");
|
|
@@ -4079,11 +4085,11 @@ function usePayphoneCheckout({
|
|
|
4079
4085
|
}
|
|
4080
4086
|
});
|
|
4081
4087
|
useEffect(() => {
|
|
4082
|
-
if (!isCallback || confirmTriggered.current) return;
|
|
4088
|
+
if (!isCallback || confirmTriggered.current || isBootstrapping) return;
|
|
4083
4089
|
confirmTriggered.current = true;
|
|
4084
4090
|
setStatus("confirming");
|
|
4085
4091
|
confirm({ id: Number(callbackId), clientTransactionId: callbackClientTxId });
|
|
4086
|
-
}, [isCallback, callbackId, callbackClientTxId, confirm]);
|
|
4092
|
+
}, [isCallback, isBootstrapping, callbackId, callbackClientTxId, confirm]);
|
|
4087
4093
|
const handleSdkError = useCallback(
|
|
4088
4094
|
(err) => {
|
|
4089
4095
|
setCurrentError(err);
|
|
@@ -4341,7 +4347,7 @@ function usePasswordToggle() {
|
|
|
4341
4347
|
}
|
|
4342
4348
|
|
|
4343
4349
|
// src/index.ts
|
|
4344
|
-
var SDK_VERSION = "0.10.
|
|
4350
|
+
var SDK_VERSION = "0.10.2";
|
|
4345
4351
|
|
|
4346
4352
|
export { AuthForm, AziridProvider, BASE_PATHS, CheckoutButton, ForgotPasswordForm, 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, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePayButton, usePaymentProviders, usePayphoneCheckout, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferPayment, useTransferProofs };
|
|
4347
4353
|
//# sourceMappingURL=index.js.map
|