azirid-react 0.6.0 → 0.7.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/README.md +92 -1
- package/dist/index.cjs +52 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +50 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -14,7 +14,8 @@ interface AuthUser {
|
|
|
14
14
|
emailVerified: boolean;
|
|
15
15
|
mfaEnabled?: boolean;
|
|
16
16
|
appId?: string;
|
|
17
|
-
tenantId
|
|
17
|
+
tenantId: string;
|
|
18
|
+
tenantRole: string;
|
|
18
19
|
workspaceId?: string;
|
|
19
20
|
environment?: 'development' | 'production';
|
|
20
21
|
mustChangePassword?: boolean;
|
|
@@ -258,6 +259,8 @@ interface AziridContextValue extends AuthState {
|
|
|
258
259
|
clearError: () => void;
|
|
259
260
|
/** Refresh the access token manually */
|
|
260
261
|
refresh: () => Promise<void>;
|
|
262
|
+
/** Switch the active tenant (re-issues tokens via refresh endpoint) */
|
|
263
|
+
switchTenant: (tenantId: string) => Promise<void>;
|
|
261
264
|
/** Update local user state after profile changes */
|
|
262
265
|
setUser: (user: AuthUser | null) => void;
|
|
263
266
|
/** TanStack mutation states */
|
|
@@ -501,6 +504,31 @@ interface TransferProof {
|
|
|
501
504
|
notes?: string;
|
|
502
505
|
createdAt: string;
|
|
503
506
|
}
|
|
507
|
+
interface TenantWithRole {
|
|
508
|
+
tenantId: string;
|
|
509
|
+
name: string;
|
|
510
|
+
slug: string;
|
|
511
|
+
description?: string | null;
|
|
512
|
+
enabled: boolean;
|
|
513
|
+
role: 'OWNER' | 'MEMBER';
|
|
514
|
+
joinedAt: string;
|
|
515
|
+
}
|
|
516
|
+
interface TenantMemberInfo {
|
|
517
|
+
id: string;
|
|
518
|
+
role: 'OWNER' | 'MEMBER';
|
|
519
|
+
joinedAt: string;
|
|
520
|
+
user: {
|
|
521
|
+
id: string;
|
|
522
|
+
email: string;
|
|
523
|
+
firstName?: string | null;
|
|
524
|
+
lastName?: string | null;
|
|
525
|
+
emailVerified: boolean;
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
interface CreateTenantData {
|
|
529
|
+
name: string;
|
|
530
|
+
description?: string;
|
|
531
|
+
}
|
|
504
532
|
|
|
505
533
|
declare const LoginForm: react.ForwardRefExoticComponent<LoginFormProps & react.RefAttributes<HTMLFormElement>>;
|
|
506
534
|
|
|
@@ -630,6 +658,7 @@ declare const SUFFIXES: {
|
|
|
630
658
|
readonly payphoneConfirm: "billing/payphone/confirm";
|
|
631
659
|
readonly referralMe: "referrals/me";
|
|
632
660
|
readonly referralStats: "referrals/stats";
|
|
661
|
+
readonly userTenants: "tenants";
|
|
633
662
|
};
|
|
634
663
|
/** Base paths for each mode */
|
|
635
664
|
declare const BASE_PATHS: {
|
|
@@ -686,7 +715,9 @@ interface AccessClient {
|
|
|
686
715
|
/** Get the current CSRF token (from memory or cookie) */
|
|
687
716
|
getCsrfToken: () => string | null;
|
|
688
717
|
/** Deduplicated refresh — safe to call from multiple places concurrently */
|
|
689
|
-
refreshSession: (
|
|
718
|
+
refreshSession: (opts?: {
|
|
719
|
+
tenantId?: string;
|
|
720
|
+
}) => Promise<void>;
|
|
690
721
|
}
|
|
691
722
|
declare function createAccessClient(config: AccessClientConfig, appContext?: AccessClient['appContext']): AccessClient;
|
|
692
723
|
|
|
@@ -1405,6 +1436,12 @@ interface UsePayphoneConfirmOptions {
|
|
|
1405
1436
|
}
|
|
1406
1437
|
declare function usePayphoneConfirm(options?: UsePayphoneConfirmOptions): _tanstack_react_query.UseMutationResult<PayphoneConfirmResult, Error, PayphoneConfirmParams, unknown>;
|
|
1407
1438
|
|
|
1439
|
+
declare function useTenants(): _tanstack_react_query.UseQueryResult<TenantWithRole[], Error>;
|
|
1440
|
+
declare function useTenantMembers(tenantId: string): _tanstack_react_query.UseQueryResult<TenantMemberInfo[], Error>;
|
|
1441
|
+
declare function useSwitchTenant(): {
|
|
1442
|
+
switchTenant: (tenantId: string) => Promise<void>;
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1408
1445
|
declare function useFormState<T extends Record<string, unknown>>(initialValues: T, schema: z.ZodType<unknown, z.ZodTypeDef, unknown>, onSubmit: (values: T) => void | Promise<void>): UseFormReturn<T>;
|
|
1409
1446
|
|
|
1410
1447
|
declare function usePasswordToggle(): {
|
|
@@ -1567,4 +1604,4 @@ interface SessionSyncOptions {
|
|
|
1567
1604
|
|
|
1568
1605
|
declare const SDK_VERSION: string;
|
|
1569
1606
|
|
|
1570
|
-
export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, BASE_PATHS, type BillingInvoice, type BillingPlan, type BootstrapResponse, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type FieldError, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, PayButton, type PayButtonProps, type PaymentIntent, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, PricingTable, type PricingTableProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, SDK_VERSION, type SessionSyncOptions, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SocialLoginData, type SocialLoginInput, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TransferProof, 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 UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createLoginSchema, createSignupSchema, en, es, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useTransferProofs };
|
|
1607
|
+
export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, BASE_PATHS, type BillingInvoice, type BillingPlan, type BootstrapResponse, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type CreateTenantData, type FieldError, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, PayButton, type PayButtonProps, type PaymentIntent, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, PricingTable, type PricingTableProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, SDK_VERSION, type SessionSyncOptions, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SocialLoginData, type SocialLoginInput, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TenantMemberInfo, type TenantWithRole, type TransferProof, 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 UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createLoginSchema, createSignupSchema, en, es, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferProofs };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ interface AuthUser {
|
|
|
14
14
|
emailVerified: boolean;
|
|
15
15
|
mfaEnabled?: boolean;
|
|
16
16
|
appId?: string;
|
|
17
|
-
tenantId
|
|
17
|
+
tenantId: string;
|
|
18
|
+
tenantRole: string;
|
|
18
19
|
workspaceId?: string;
|
|
19
20
|
environment?: 'development' | 'production';
|
|
20
21
|
mustChangePassword?: boolean;
|
|
@@ -258,6 +259,8 @@ interface AziridContextValue extends AuthState {
|
|
|
258
259
|
clearError: () => void;
|
|
259
260
|
/** Refresh the access token manually */
|
|
260
261
|
refresh: () => Promise<void>;
|
|
262
|
+
/** Switch the active tenant (re-issues tokens via refresh endpoint) */
|
|
263
|
+
switchTenant: (tenantId: string) => Promise<void>;
|
|
261
264
|
/** Update local user state after profile changes */
|
|
262
265
|
setUser: (user: AuthUser | null) => void;
|
|
263
266
|
/** TanStack mutation states */
|
|
@@ -501,6 +504,31 @@ interface TransferProof {
|
|
|
501
504
|
notes?: string;
|
|
502
505
|
createdAt: string;
|
|
503
506
|
}
|
|
507
|
+
interface TenantWithRole {
|
|
508
|
+
tenantId: string;
|
|
509
|
+
name: string;
|
|
510
|
+
slug: string;
|
|
511
|
+
description?: string | null;
|
|
512
|
+
enabled: boolean;
|
|
513
|
+
role: 'OWNER' | 'MEMBER';
|
|
514
|
+
joinedAt: string;
|
|
515
|
+
}
|
|
516
|
+
interface TenantMemberInfo {
|
|
517
|
+
id: string;
|
|
518
|
+
role: 'OWNER' | 'MEMBER';
|
|
519
|
+
joinedAt: string;
|
|
520
|
+
user: {
|
|
521
|
+
id: string;
|
|
522
|
+
email: string;
|
|
523
|
+
firstName?: string | null;
|
|
524
|
+
lastName?: string | null;
|
|
525
|
+
emailVerified: boolean;
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
interface CreateTenantData {
|
|
529
|
+
name: string;
|
|
530
|
+
description?: string;
|
|
531
|
+
}
|
|
504
532
|
|
|
505
533
|
declare const LoginForm: react.ForwardRefExoticComponent<LoginFormProps & react.RefAttributes<HTMLFormElement>>;
|
|
506
534
|
|
|
@@ -630,6 +658,7 @@ declare const SUFFIXES: {
|
|
|
630
658
|
readonly payphoneConfirm: "billing/payphone/confirm";
|
|
631
659
|
readonly referralMe: "referrals/me";
|
|
632
660
|
readonly referralStats: "referrals/stats";
|
|
661
|
+
readonly userTenants: "tenants";
|
|
633
662
|
};
|
|
634
663
|
/** Base paths for each mode */
|
|
635
664
|
declare const BASE_PATHS: {
|
|
@@ -686,7 +715,9 @@ interface AccessClient {
|
|
|
686
715
|
/** Get the current CSRF token (from memory or cookie) */
|
|
687
716
|
getCsrfToken: () => string | null;
|
|
688
717
|
/** Deduplicated refresh — safe to call from multiple places concurrently */
|
|
689
|
-
refreshSession: (
|
|
718
|
+
refreshSession: (opts?: {
|
|
719
|
+
tenantId?: string;
|
|
720
|
+
}) => Promise<void>;
|
|
690
721
|
}
|
|
691
722
|
declare function createAccessClient(config: AccessClientConfig, appContext?: AccessClient['appContext']): AccessClient;
|
|
692
723
|
|
|
@@ -1405,6 +1436,12 @@ interface UsePayphoneConfirmOptions {
|
|
|
1405
1436
|
}
|
|
1406
1437
|
declare function usePayphoneConfirm(options?: UsePayphoneConfirmOptions): _tanstack_react_query.UseMutationResult<PayphoneConfirmResult, Error, PayphoneConfirmParams, unknown>;
|
|
1407
1438
|
|
|
1439
|
+
declare function useTenants(): _tanstack_react_query.UseQueryResult<TenantWithRole[], Error>;
|
|
1440
|
+
declare function useTenantMembers(tenantId: string): _tanstack_react_query.UseQueryResult<TenantMemberInfo[], Error>;
|
|
1441
|
+
declare function useSwitchTenant(): {
|
|
1442
|
+
switchTenant: (tenantId: string) => Promise<void>;
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1408
1445
|
declare function useFormState<T extends Record<string, unknown>>(initialValues: T, schema: z.ZodType<unknown, z.ZodTypeDef, unknown>, onSubmit: (values: T) => void | Promise<void>): UseFormReturn<T>;
|
|
1409
1446
|
|
|
1410
1447
|
declare function usePasswordToggle(): {
|
|
@@ -1567,4 +1604,4 @@ interface SessionSyncOptions {
|
|
|
1567
1604
|
|
|
1568
1605
|
declare const SDK_VERSION: string;
|
|
1569
1606
|
|
|
1570
|
-
export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, BASE_PATHS, type BillingInvoice, type BillingPlan, type BootstrapResponse, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type FieldError, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, PayButton, type PayButtonProps, type PaymentIntent, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, PricingTable, type PricingTableProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, SDK_VERSION, type SessionSyncOptions, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SocialLoginData, type SocialLoginInput, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TransferProof, 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 UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createLoginSchema, createSignupSchema, en, es, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useTransferProofs };
|
|
1607
|
+
export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, BASE_PATHS, type BillingInvoice, type BillingPlan, type BootstrapResponse, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type CreateTenantData, type FieldError, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, PayButton, type PayButtonProps, type PaymentIntent, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, PricingTable, type PricingTableProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, SDK_VERSION, type SessionSyncOptions, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SocialLoginData, type SocialLoginInput, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TenantMemberInfo, type TenantWithRole, type TransferProof, 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 UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createLoginSchema, createSignupSchema, en, es, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferProofs };
|
package/dist/index.js
CHANGED
|
@@ -95,7 +95,8 @@ var SUFFIXES = {
|
|
|
95
95
|
transferProofs: "billing/transfer-proofs",
|
|
96
96
|
payphoneConfirm: "billing/payphone/confirm",
|
|
97
97
|
referralMe: "referrals/me",
|
|
98
|
-
referralStats: "referrals/stats"
|
|
98
|
+
referralStats: "referrals/stats",
|
|
99
|
+
userTenants: "tenants"
|
|
99
100
|
};
|
|
100
101
|
var BASE_PATHS = {
|
|
101
102
|
/** Proxy mode (Next.js): requests go to the same origin via route handler */
|
|
@@ -159,7 +160,7 @@ function createAccessClient(config, appContext) {
|
|
|
159
160
|
return match ? decodeURIComponent(match[1]) : null;
|
|
160
161
|
}
|
|
161
162
|
const sessionPaths = [paths.refresh, paths.bootstrap, paths.logout];
|
|
162
|
-
async function refreshTokensInternal() {
|
|
163
|
+
async function refreshTokensInternal(opts) {
|
|
163
164
|
const reqHeaders = {
|
|
164
165
|
"Content-Type": "application/json",
|
|
165
166
|
...config.headers
|
|
@@ -173,6 +174,9 @@ function createAccessClient(config, appContext) {
|
|
|
173
174
|
if (refreshToken) {
|
|
174
175
|
bodyPayload["rt"] = refreshToken;
|
|
175
176
|
}
|
|
177
|
+
if (opts?.tenantId) {
|
|
178
|
+
bodyPayload["tenantId"] = opts.tenantId;
|
|
179
|
+
}
|
|
176
180
|
const res = await fetch(`${baseUrl}${paths.refresh}`, {
|
|
177
181
|
method: "POST",
|
|
178
182
|
headers: reqHeaders,
|
|
@@ -193,7 +197,11 @@ function createAccessClient(config, appContext) {
|
|
|
193
197
|
if (rt) setRefreshToken(rt);
|
|
194
198
|
if (xc) setCsrfToken(xc);
|
|
195
199
|
}
|
|
196
|
-
function refreshTokens() {
|
|
200
|
+
function refreshTokens(opts) {
|
|
201
|
+
if (opts?.tenantId) {
|
|
202
|
+
return refreshTokensInternal(opts).finally(() => {
|
|
203
|
+
});
|
|
204
|
+
}
|
|
197
205
|
if (refreshPromise) return refreshPromise;
|
|
198
206
|
refreshPromise = refreshTokensInternal().finally(() => {
|
|
199
207
|
refreshPromise = null;
|
|
@@ -301,7 +309,7 @@ function createAccessClient(config, appContext) {
|
|
|
301
309
|
getRefreshToken,
|
|
302
310
|
setCsrfToken,
|
|
303
311
|
getCsrfToken,
|
|
304
|
-
refreshSession: refreshTokens
|
|
312
|
+
refreshSession: (opts) => refreshTokens(opts)
|
|
305
313
|
};
|
|
306
314
|
}
|
|
307
315
|
|
|
@@ -724,6 +732,14 @@ function AziridProviderInner({
|
|
|
724
732
|
throw err;
|
|
725
733
|
}
|
|
726
734
|
}, [client, queryClient, props, updateAccessToken, clearSession]);
|
|
735
|
+
const switchTenantFn = useCallback(
|
|
736
|
+
async (tenantId) => {
|
|
737
|
+
await client.refreshSession({ tenantId });
|
|
738
|
+
updateAccessToken(client.getAccessToken());
|
|
739
|
+
await queryClient.invalidateQueries({ queryKey: ["azirid-access"] });
|
|
740
|
+
},
|
|
741
|
+
[client, queryClient, updateAccessToken]
|
|
742
|
+
);
|
|
727
743
|
const login = useCallback(
|
|
728
744
|
(data) => loginMutation.mutate(data),
|
|
729
745
|
[loginMutation]
|
|
@@ -746,6 +762,7 @@ function AziridProviderInner({
|
|
|
746
762
|
logout,
|
|
747
763
|
clearError,
|
|
748
764
|
refresh: refreshFn,
|
|
765
|
+
switchTenant: switchTenantFn,
|
|
749
766
|
setUser: setUserFn,
|
|
750
767
|
isLoginPending: loginMutation.isPending,
|
|
751
768
|
isSignupPending: signupMutation.isPending,
|
|
@@ -763,6 +780,7 @@ function AziridProviderInner({
|
|
|
763
780
|
logout,
|
|
764
781
|
clearError,
|
|
765
782
|
refreshFn,
|
|
783
|
+
switchTenantFn,
|
|
766
784
|
setUserFn,
|
|
767
785
|
loginMutation,
|
|
768
786
|
signupMutation,
|
|
@@ -2546,7 +2564,7 @@ function TransferModal2({
|
|
|
2546
2564
|
const bankDetails = data.bankDetails;
|
|
2547
2565
|
const plan = data.plan;
|
|
2548
2566
|
const intent = data.intent;
|
|
2549
|
-
const displayAmount = plan ? formatAmount2(plan.amount, plan.currency) : intent ? formatAmount2(intent.amount
|
|
2567
|
+
const displayAmount = plan ? formatAmount2(plan.amount, plan.currency) : intent ? formatAmount2(intent.amount, intent.currency) : "";
|
|
2550
2568
|
return /* @__PURE__ */ jsx("div", { style: modalStyles.overlay, onClick: onClose, children: /* @__PURE__ */ jsxs("div", { style: modalStyles.card, onClick: (e) => e.stopPropagation(), children: [
|
|
2551
2569
|
/* @__PURE__ */ jsx("h2", { style: modalStyles.title, children: labels?.bankTransfer ?? "Bank Transfer" }),
|
|
2552
2570
|
displayAmount && /* @__PURE__ */ jsxs(
|
|
@@ -3212,6 +3230,31 @@ function useTransferProofs() {
|
|
|
3212
3230
|
queryFn: () => client.get(client.paths.transferProofs)
|
|
3213
3231
|
});
|
|
3214
3232
|
}
|
|
3233
|
+
function useTenants() {
|
|
3234
|
+
const client = useAccessClient();
|
|
3235
|
+
return useQuery({
|
|
3236
|
+
queryKey: ["azirid-access", "tenants"],
|
|
3237
|
+
queryFn: () => client.get(client.paths.userTenants),
|
|
3238
|
+
enabled: !!client.getAccessToken()
|
|
3239
|
+
});
|
|
3240
|
+
}
|
|
3241
|
+
function useTenantMembers(tenantId) {
|
|
3242
|
+
const client = useAccessClient();
|
|
3243
|
+
return useQuery({
|
|
3244
|
+
queryKey: ["azirid-access", "tenants", tenantId, "members"],
|
|
3245
|
+
queryFn: () => client.get(`${client.paths.userTenants}/${tenantId}/members`),
|
|
3246
|
+
enabled: !!client.getAccessToken() && !!tenantId
|
|
3247
|
+
});
|
|
3248
|
+
}
|
|
3249
|
+
function useSwitchTenant() {
|
|
3250
|
+
const client = useAccessClient();
|
|
3251
|
+
const queryClient = useQueryClient();
|
|
3252
|
+
const switchTenant = async (tenantId) => {
|
|
3253
|
+
await client.refreshSession({ tenantId });
|
|
3254
|
+
await queryClient.invalidateQueries({ queryKey: ["azirid-access"] });
|
|
3255
|
+
};
|
|
3256
|
+
return { switchTenant };
|
|
3257
|
+
}
|
|
3215
3258
|
function zodToFieldErrors(zodError) {
|
|
3216
3259
|
return zodError.issues.map((issue) => ({
|
|
3217
3260
|
field: issue.path.join("."),
|
|
@@ -3268,8 +3311,8 @@ function usePasswordToggle() {
|
|
|
3268
3311
|
}
|
|
3269
3312
|
|
|
3270
3313
|
// src/index.ts
|
|
3271
|
-
var SDK_VERSION = "0.
|
|
3314
|
+
var SDK_VERSION = "0.7.0";
|
|
3272
3315
|
|
|
3273
|
-
export { AziridProvider, BASE_PATHS, CheckoutButton, InvoiceList, LoginForm, PATHS, PayButton, PayphoneCallback, PricingTable, ReferralCard, ReferralStats, SDK_VERSION, SignupForm, SubscriptionBadge, buildPaths, changePasswordSchema, cn, createAccessClient, createLoginSchema, createSignupSchema, en, es, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useTransferProofs };
|
|
3316
|
+
export { AziridProvider, BASE_PATHS, CheckoutButton, InvoiceList, LoginForm, PATHS, PayButton, PayphoneCallback, PricingTable, ReferralCard, ReferralStats, SDK_VERSION, SignupForm, SubscriptionBadge, buildPaths, changePasswordSchema, cn, createAccessClient, createLoginSchema, createSignupSchema, en, es, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferProofs };
|
|
3274
3317
|
//# sourceMappingURL=index.js.map
|
|
3275
3318
|
//# sourceMappingURL=index.js.map
|