azirid-react 0.11.2 → 0.11.3

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.cjs CHANGED
@@ -4746,7 +4746,7 @@ function usePasswordToggle() {
4746
4746
  }
4747
4747
 
4748
4748
  // src/index.ts
4749
- var SDK_VERSION = "0.11.2";
4749
+ var SDK_VERSION = "0.11.3";
4750
4750
 
4751
4751
  exports.AuthForm = AuthForm;
4752
4752
  exports.AziridProvider = AziridProvider;
package/dist/index.js CHANGED
@@ -4744,7 +4744,7 @@ function usePasswordToggle() {
4744
4744
  }
4745
4745
 
4746
4746
  // src/index.ts
4747
- var SDK_VERSION = "0.11.2";
4747
+ var SDK_VERSION = "0.11.3";
4748
4748
 
4749
4749
  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
4750
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,121 @@
1
+ interface SessionSyncOptions {
2
+ /** Cookie name (default: "__session") */
3
+ cookieName?: string;
4
+ /** Set Secure flag on cookie (default: false) */
5
+ secure?: boolean;
6
+ /** Cookie max age in seconds (default: 3600 = 1h) */
7
+ maxAge?: number;
8
+ }
9
+ /**
10
+ * Create a route handler that syncs the access token to a local httpOnly cookie.
11
+ *
12
+ * Use this in a Next.js App Router route to bridge cross-origin sessions:
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // app/api/auth/session/route.ts
17
+ * import { createSessionSyncHandler } from "azirid-react/server";
18
+ * export const { POST, DELETE } = createSessionSyncHandler();
19
+ * ```
20
+ */
21
+ declare function createSessionSyncHandler(options?: SessionSyncOptions): {
22
+ POST(req: Request): Promise<Response>;
23
+ DELETE(): Promise<Response>;
24
+ };
25
+
26
+ /**
27
+ * Next.js route handlers for the Azirid auth proxy.
28
+ *
29
+ * This entry point uses **only standard Web APIs** (Request, Response, fetch)
30
+ * and has **zero dependency on `next/server`**. This makes it safe to use in
31
+ * Next.js standalone builds (`output: 'standalone'`) where external `next/server`
32
+ * imports may fail at runtime.
33
+ *
34
+ * @example Route handler (simplest — one line)
35
+ * ```ts
36
+ * // app/api/auth/[...path]/route.ts
37
+ * export { GET, POST, PUT, PATCH, DELETE } from "azirid-react/next/handlers";
38
+ * ```
39
+ *
40
+ * @example Route handler (custom API URL)
41
+ * ```ts
42
+ * // app/api/auth/[...path]/route.ts
43
+ * import { createAziridRouteHandlers } from "azirid-react/next/handlers";
44
+ * export const { GET, POST, PUT, PATCH, DELETE } = createAziridRouteHandlers({
45
+ * apiUrl: "https://my-custom-api.com",
46
+ * debug: true,
47
+ * });
48
+ * ```
49
+ *
50
+ * @packageDocumentation
51
+ */
52
+ type RouteHandler = (request: Request, context: {
53
+ params: Promise<{
54
+ path: string[];
55
+ }> | {
56
+ path: string[];
57
+ };
58
+ }) => Promise<Response>;
59
+ interface AziridRouteHandlerOptions {
60
+ /** Override the Azirid API URL (default: production API) */
61
+ apiUrl?: string;
62
+ /** Enable debug logging of proxy requests (default: false) */
63
+ debug?: boolean;
64
+ }
65
+ /**
66
+ * Create all route handlers for the Azirid auth proxy.
67
+ *
68
+ * Returns `{ GET, POST, PUT, PATCH, DELETE }` ready to be re-exported
69
+ * from your `app/api/auth/[...path]/route.ts`.
70
+ *
71
+ * @example Default (zero config)
72
+ * ```ts
73
+ * // app/api/auth/[...path]/route.ts
74
+ * import { createAziridRouteHandlers } from "azirid-react/next/handlers";
75
+ * export const { GET, POST, PUT, PATCH, DELETE } = createAziridRouteHandlers();
76
+ * ```
77
+ *
78
+ * @example Custom options
79
+ * ```ts
80
+ * // app/api/auth/[...path]/route.ts
81
+ * import { createAziridRouteHandlers } from "azirid-react/next/handlers";
82
+ * export const { GET, POST, PUT, PATCH, DELETE } = createAziridRouteHandlers({
83
+ * apiUrl: "https://my-custom-api.com",
84
+ * debug: true,
85
+ * });
86
+ * ```
87
+ */
88
+ declare function createAziridRouteHandlers(options?: AziridRouteHandlerOptions): {
89
+ GET: RouteHandler;
90
+ POST: RouteHandler;
91
+ PUT: RouteHandler;
92
+ PATCH: RouteHandler;
93
+ DELETE: RouteHandler;
94
+ };
95
+ declare const GET: RouteHandler;
96
+ declare const POST: RouteHandler;
97
+ declare const PUT: RouteHandler;
98
+ declare const PATCH: RouteHandler;
99
+ declare const DELETE: RouteHandler;
100
+ /**
101
+ * Create a single Next.js route handler function.
102
+ *
103
+ * Use this if you need a single handler reference (advanced use).
104
+ * For most cases, prefer `createAziridRouteHandlers()` or the pre-built exports.
105
+ *
106
+ * @deprecated Use `createAziridRouteHandlers()` instead.
107
+ */
108
+ declare function createAziridProxyHandler(apiUrl?: string): RouteHandler;
109
+ /**
110
+ * Wrap your Next.js config with Azirid settings.
111
+ *
112
+ * In Next.js 16+ with Turbopack, `transpilePackages` is no longer needed.
113
+ * This helper is kept for backward compatibility with Next.js 14/15.
114
+ *
115
+ * @param apiUrl - Override the Azirid API URL (default: production API)
116
+ */
117
+ declare function withAziridProxy(apiUrl?: string): (nextConfig?: Record<string, unknown>) => {
118
+ [x: string]: unknown;
119
+ };
120
+
121
+ export { type AziridRouteHandlerOptions, DELETE, GET, PATCH, POST, PUT, type SessionSyncOptions, createAziridProxyHandler, createAziridRouteHandlers, createSessionSyncHandler, withAziridProxy };
@@ -0,0 +1,121 @@
1
+ interface SessionSyncOptions {
2
+ /** Cookie name (default: "__session") */
3
+ cookieName?: string;
4
+ /** Set Secure flag on cookie (default: false) */
5
+ secure?: boolean;
6
+ /** Cookie max age in seconds (default: 3600 = 1h) */
7
+ maxAge?: number;
8
+ }
9
+ /**
10
+ * Create a route handler that syncs the access token to a local httpOnly cookie.
11
+ *
12
+ * Use this in a Next.js App Router route to bridge cross-origin sessions:
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // app/api/auth/session/route.ts
17
+ * import { createSessionSyncHandler } from "azirid-react/server";
18
+ * export const { POST, DELETE } = createSessionSyncHandler();
19
+ * ```
20
+ */
21
+ declare function createSessionSyncHandler(options?: SessionSyncOptions): {
22
+ POST(req: Request): Promise<Response>;
23
+ DELETE(): Promise<Response>;
24
+ };
25
+
26
+ /**
27
+ * Next.js route handlers for the Azirid auth proxy.
28
+ *
29
+ * This entry point uses **only standard Web APIs** (Request, Response, fetch)
30
+ * and has **zero dependency on `next/server`**. This makes it safe to use in
31
+ * Next.js standalone builds (`output: 'standalone'`) where external `next/server`
32
+ * imports may fail at runtime.
33
+ *
34
+ * @example Route handler (simplest — one line)
35
+ * ```ts
36
+ * // app/api/auth/[...path]/route.ts
37
+ * export { GET, POST, PUT, PATCH, DELETE } from "azirid-react/next/handlers";
38
+ * ```
39
+ *
40
+ * @example Route handler (custom API URL)
41
+ * ```ts
42
+ * // app/api/auth/[...path]/route.ts
43
+ * import { createAziridRouteHandlers } from "azirid-react/next/handlers";
44
+ * export const { GET, POST, PUT, PATCH, DELETE } = createAziridRouteHandlers({
45
+ * apiUrl: "https://my-custom-api.com",
46
+ * debug: true,
47
+ * });
48
+ * ```
49
+ *
50
+ * @packageDocumentation
51
+ */
52
+ type RouteHandler = (request: Request, context: {
53
+ params: Promise<{
54
+ path: string[];
55
+ }> | {
56
+ path: string[];
57
+ };
58
+ }) => Promise<Response>;
59
+ interface AziridRouteHandlerOptions {
60
+ /** Override the Azirid API URL (default: production API) */
61
+ apiUrl?: string;
62
+ /** Enable debug logging of proxy requests (default: false) */
63
+ debug?: boolean;
64
+ }
65
+ /**
66
+ * Create all route handlers for the Azirid auth proxy.
67
+ *
68
+ * Returns `{ GET, POST, PUT, PATCH, DELETE }` ready to be re-exported
69
+ * from your `app/api/auth/[...path]/route.ts`.
70
+ *
71
+ * @example Default (zero config)
72
+ * ```ts
73
+ * // app/api/auth/[...path]/route.ts
74
+ * import { createAziridRouteHandlers } from "azirid-react/next/handlers";
75
+ * export const { GET, POST, PUT, PATCH, DELETE } = createAziridRouteHandlers();
76
+ * ```
77
+ *
78
+ * @example Custom options
79
+ * ```ts
80
+ * // app/api/auth/[...path]/route.ts
81
+ * import { createAziridRouteHandlers } from "azirid-react/next/handlers";
82
+ * export const { GET, POST, PUT, PATCH, DELETE } = createAziridRouteHandlers({
83
+ * apiUrl: "https://my-custom-api.com",
84
+ * debug: true,
85
+ * });
86
+ * ```
87
+ */
88
+ declare function createAziridRouteHandlers(options?: AziridRouteHandlerOptions): {
89
+ GET: RouteHandler;
90
+ POST: RouteHandler;
91
+ PUT: RouteHandler;
92
+ PATCH: RouteHandler;
93
+ DELETE: RouteHandler;
94
+ };
95
+ declare const GET: RouteHandler;
96
+ declare const POST: RouteHandler;
97
+ declare const PUT: RouteHandler;
98
+ declare const PATCH: RouteHandler;
99
+ declare const DELETE: RouteHandler;
100
+ /**
101
+ * Create a single Next.js route handler function.
102
+ *
103
+ * Use this if you need a single handler reference (advanced use).
104
+ * For most cases, prefer `createAziridRouteHandlers()` or the pre-built exports.
105
+ *
106
+ * @deprecated Use `createAziridRouteHandlers()` instead.
107
+ */
108
+ declare function createAziridProxyHandler(apiUrl?: string): RouteHandler;
109
+ /**
110
+ * Wrap your Next.js config with Azirid settings.
111
+ *
112
+ * In Next.js 16+ with Turbopack, `transpilePackages` is no longer needed.
113
+ * This helper is kept for backward compatibility with Next.js 14/15.
114
+ *
115
+ * @param apiUrl - Override the Azirid API URL (default: production API)
116
+ */
117
+ declare function withAziridProxy(apiUrl?: string): (nextConfig?: Record<string, unknown>) => {
118
+ [x: string]: unknown;
119
+ };
120
+
121
+ export { type AziridRouteHandlerOptions, DELETE, GET, PATCH, POST, PUT, type SessionSyncOptions, createAziridProxyHandler, createAziridRouteHandlers, createSessionSyncHandler, withAziridProxy };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Server-side utilities for Next.js (App Router).
3
+ *
4
+ * Use this entry point in Server Components, Server Actions, and Route Handlers
5
+ * to read the authenticated user's session token from the httpOnly `__session` cookie.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // lib/access-server.ts
10
+ * import { cookies } from "next/headers";
11
+ * import { createServerAccess } from "azirid-react/server";
12
+ * export const { getSessionToken } = createServerAccess({ cookies });
13
+ * ```
14
+ *
15
+ * ```ts
16
+ * // app/actions/profile.ts
17
+ * "use server";
18
+ * import { getSessionToken } from "@/lib/access-server";
19
+ *
20
+ * export async function getProfile() {
21
+ * const token = await getSessionToken();
22
+ * if (!token) throw new Error("Not authenticated");
23
+ *
24
+ * const res = await fetch("https://api.myapp.com/v1/users/auth/me", {
25
+ * headers: { Authorization: `Bearer ${token}` },
26
+ * });
27
+ * return res.json();
28
+ * }
29
+ * ```
30
+ *
31
+ * @packageDocumentation
32
+ */
33
+ /** Minimal cookie store interface (subset of Next.js ReadonlyRequestCookies) */
34
+ interface CookieStore {
35
+ get(name: string): {
36
+ value: string;
37
+ } | undefined;
38
+ }
39
+ /** The `cookies` function from `next/headers` */
40
+ type CookiesFn = () => CookieStore | Promise<CookieStore>;
41
+ interface ServerAccessOptions {
42
+ /**
43
+ * The `cookies` function imported from `next/headers`.
44
+ * Required — pass it explicitly to avoid bundler issues with dynamic imports.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { cookies } from "next/headers";
49
+ * createServerAccess({ cookies });
50
+ * ```
51
+ */
52
+ cookies: CookiesFn;
53
+ /**
54
+ * Name of the httpOnly cookie that carries the access token.
55
+ * Must match the cookie set by the Azirid API.
56
+ * @default "__session"
57
+ */
58
+ cookieName?: string;
59
+ }
60
+ interface ServerAccess {
61
+ /**
62
+ * Read the raw JWT access token from the session cookie.
63
+ * Returns `null` when no cookie is present or when called
64
+ * outside a Next.js server context.
65
+ */
66
+ getSessionToken: () => Promise<string | null>;
67
+ /** Alias for {@link getSessionToken}. */
68
+ getAccessToken: () => Promise<string | null>;
69
+ }
70
+ /**
71
+ * Create server-side helpers bound to the session cookie.
72
+ *
73
+ * Call once at module scope, then use the returned functions
74
+ * in any Server Component, Server Action, or Route Handler.
75
+ */
76
+ declare function createServerAccess(options: ServerAccessOptions): ServerAccess;
77
+ interface SessionSyncOptions {
78
+ /** Cookie name (default: "__session") */
79
+ cookieName?: string;
80
+ /** Set Secure flag on cookie (default: false) */
81
+ secure?: boolean;
82
+ /** Cookie max age in seconds (default: 3600 = 1h) */
83
+ maxAge?: number;
84
+ }
85
+ /**
86
+ * Create a route handler that syncs the access token to a local httpOnly cookie.
87
+ *
88
+ * Use this in a Next.js App Router route to bridge cross-origin sessions:
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * // app/api/auth/session/route.ts
93
+ * import { createSessionSyncHandler } from "azirid-react/server";
94
+ * export const { POST, DELETE } = createSessionSyncHandler();
95
+ * ```
96
+ */
97
+ declare function createSessionSyncHandler(options?: SessionSyncOptions): {
98
+ POST(req: Request): Promise<Response>;
99
+ DELETE(): Promise<Response>;
100
+ };
101
+
102
+ export { type ServerAccess, type ServerAccessOptions, type SessionSyncOptions, createServerAccess, createSessionSyncHandler };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Server-side utilities for Next.js (App Router).
3
+ *
4
+ * Use this entry point in Server Components, Server Actions, and Route Handlers
5
+ * to read the authenticated user's session token from the httpOnly `__session` cookie.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // lib/access-server.ts
10
+ * import { cookies } from "next/headers";
11
+ * import { createServerAccess } from "azirid-react/server";
12
+ * export const { getSessionToken } = createServerAccess({ cookies });
13
+ * ```
14
+ *
15
+ * ```ts
16
+ * // app/actions/profile.ts
17
+ * "use server";
18
+ * import { getSessionToken } from "@/lib/access-server";
19
+ *
20
+ * export async function getProfile() {
21
+ * const token = await getSessionToken();
22
+ * if (!token) throw new Error("Not authenticated");
23
+ *
24
+ * const res = await fetch("https://api.myapp.com/v1/users/auth/me", {
25
+ * headers: { Authorization: `Bearer ${token}` },
26
+ * });
27
+ * return res.json();
28
+ * }
29
+ * ```
30
+ *
31
+ * @packageDocumentation
32
+ */
33
+ /** Minimal cookie store interface (subset of Next.js ReadonlyRequestCookies) */
34
+ interface CookieStore {
35
+ get(name: string): {
36
+ value: string;
37
+ } | undefined;
38
+ }
39
+ /** The `cookies` function from `next/headers` */
40
+ type CookiesFn = () => CookieStore | Promise<CookieStore>;
41
+ interface ServerAccessOptions {
42
+ /**
43
+ * The `cookies` function imported from `next/headers`.
44
+ * Required — pass it explicitly to avoid bundler issues with dynamic imports.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { cookies } from "next/headers";
49
+ * createServerAccess({ cookies });
50
+ * ```
51
+ */
52
+ cookies: CookiesFn;
53
+ /**
54
+ * Name of the httpOnly cookie that carries the access token.
55
+ * Must match the cookie set by the Azirid API.
56
+ * @default "__session"
57
+ */
58
+ cookieName?: string;
59
+ }
60
+ interface ServerAccess {
61
+ /**
62
+ * Read the raw JWT access token from the session cookie.
63
+ * Returns `null` when no cookie is present or when called
64
+ * outside a Next.js server context.
65
+ */
66
+ getSessionToken: () => Promise<string | null>;
67
+ /** Alias for {@link getSessionToken}. */
68
+ getAccessToken: () => Promise<string | null>;
69
+ }
70
+ /**
71
+ * Create server-side helpers bound to the session cookie.
72
+ *
73
+ * Call once at module scope, then use the returned functions
74
+ * in any Server Component, Server Action, or Route Handler.
75
+ */
76
+ declare function createServerAccess(options: ServerAccessOptions): ServerAccess;
77
+ interface SessionSyncOptions {
78
+ /** Cookie name (default: "__session") */
79
+ cookieName?: string;
80
+ /** Set Secure flag on cookie (default: false) */
81
+ secure?: boolean;
82
+ /** Cookie max age in seconds (default: 3600 = 1h) */
83
+ maxAge?: number;
84
+ }
85
+ /**
86
+ * Create a route handler that syncs the access token to a local httpOnly cookie.
87
+ *
88
+ * Use this in a Next.js App Router route to bridge cross-origin sessions:
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * // app/api/auth/session/route.ts
93
+ * import { createSessionSyncHandler } from "azirid-react/server";
94
+ * export const { POST, DELETE } = createSessionSyncHandler();
95
+ * ```
96
+ */
97
+ declare function createSessionSyncHandler(options?: SessionSyncOptions): {
98
+ POST(req: Request): Promise<Response>;
99
+ DELETE(): Promise<Response>;
100
+ };
101
+
102
+ export { type ServerAccess, type ServerAccessOptions, type SessionSyncOptions, createServerAccess, createSessionSyncHandler };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azirid-react",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "description": "Authentication components for React and Next.js — Login, Register, powered by TanStack Query and Zod.",
5
5
  "author": "Azirid",
6
6
  "license": "MIT",
@@ -36,6 +36,14 @@
36
36
  "main": "./dist/index.cjs",
37
37
  "module": "./dist/index.js",
38
38
  "types": "./dist/index.d.ts",
39
+ "typesVersions": {
40
+ "*": {
41
+ "next/handlers": ["./dist/next-handlers.d.ts"],
42
+ "next/proxy": ["./dist/next-proxy.d.ts"],
43
+ "next": ["./dist/next.d.ts"],
44
+ "server": ["./dist/server.d.ts"]
45
+ }
46
+ },
39
47
  "exports": {
40
48
  ".": {
41
49
  "import": {
@@ -94,7 +102,7 @@
94
102
  "README.md"
95
103
  ],
96
104
  "scripts": {
97
- "build": "node scripts/build-styles.mjs && tsup && cp src/styles/compiled.css dist/styles.css",
105
+ "build": "node scripts/build-styles.mjs && rm -rf dist && tsup && cp src/styles/compiled.css dist/styles.css",
98
106
  "dev": "tsup --watch",
99
107
  "lint": "tsc --noEmit",
100
108
  "clean": "rm -rf dist"