azirid-react 0.11.2 → 0.12.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.js CHANGED
@@ -147,6 +147,20 @@ function createAccessClient(config, appContext) {
147
147
  const paths = config.basePath ? buildPaths(config.basePath) : PATHS;
148
148
  const storageKeyRt = "__azrt";
149
149
  const storageKeyCsrf = "__azxc";
150
+ const storageKeyDeviceId = "__az_device_id";
151
+ function getOrCreateDeviceId() {
152
+ try {
153
+ if (typeof localStorage === "undefined") return null;
154
+ let id = localStorage.getItem(storageKeyDeviceId);
155
+ if (!id) {
156
+ id = crypto.randomUUID();
157
+ localStorage.setItem(storageKeyDeviceId, id);
158
+ }
159
+ return id;
160
+ } catch {
161
+ return null;
162
+ }
163
+ }
150
164
  function ssGet(key) {
151
165
  try {
152
166
  return typeof sessionStorage !== "undefined" ? sessionStorage.getItem(key) : null;
@@ -227,6 +241,8 @@ function createAccessClient(config, appContext) {
227
241
  }
228
242
  const csrf = getCsrfToken();
229
243
  if (csrf) reqHeaders["X-CSRF-Token"] = csrf;
244
+ const devId = getOrCreateDeviceId();
245
+ if (devId) reqHeaders["X-Device-Id"] = devId;
230
246
  const bodyPayload = {};
231
247
  if (refreshToken) {
232
248
  bodyPayload["rt"] = refreshToken;
@@ -289,6 +305,10 @@ function createAccessClient(config, appContext) {
289
305
  if (csrf) {
290
306
  headers["X-CSRF-Token"] = csrf;
291
307
  }
308
+ const devId = getOrCreateDeviceId();
309
+ if (devId) {
310
+ headers["X-Device-Id"] = devId;
311
+ }
292
312
  let requestBody = body;
293
313
  if (isSessionPath && refreshToken) {
294
314
  const existing = typeof body === "object" && body !== null ? body : {};
@@ -335,6 +355,10 @@ function createAccessClient(config, appContext) {
335
355
  if (retryCsrf) {
336
356
  retryHeaders["X-CSRF-Token"] = retryCsrf;
337
357
  }
358
+ const retryDevId = getOrCreateDeviceId();
359
+ if (retryDevId) {
360
+ retryHeaders["X-Device-Id"] = retryDevId;
361
+ }
338
362
  res = await fetch(`${baseUrl}${path}`, {
339
363
  method,
340
364
  headers: retryHeaders,
@@ -4744,7 +4768,7 @@ function usePasswordToggle() {
4744
4768
  }
4745
4769
 
4746
4770
  // src/index.ts
4747
- var SDK_VERSION = "0.11.2";
4771
+ var SDK_VERSION = "0.12.0";
4748
4772
 
4749
4773
  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, 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 };
4750
4774
  //# sourceMappingURL=index.js.map