hazo_auth 6.0.0 → 6.1.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.
Files changed (90) hide show
  1. package/README.md +70 -0
  2. package/SETUP_CHECKLIST.md +92 -0
  3. package/cli-src/cli/validate.ts +4 -0
  4. package/cli-src/lib/cookies_config.server.ts +1 -0
  5. package/cli-src/lib/login_config.server.ts +14 -0
  6. package/cli-src/lib/otp_config.server.ts +91 -0
  7. package/cli-src/lib/services/email_service.ts +3 -1
  8. package/cli-src/lib/services/email_template_manifest.ts +17 -0
  9. package/cli-src/lib/services/email_templates/otp_signin_code.html +13 -0
  10. package/cli-src/lib/services/email_templates/otp_signin_code.txt +5 -0
  11. package/cli-src/lib/services/index.ts +8 -2
  12. package/cli-src/lib/services/otp_service.ts +295 -0
  13. package/cli-src/lib/services/session_token_service.ts +4 -1
  14. package/config/hazo_auth_config.example.ini +38 -0
  15. package/dist/cli/validate.d.ts.map +1 -1
  16. package/dist/cli/validate.js +4 -0
  17. package/dist/client.d.ts +2 -0
  18. package/dist/client.d.ts.map +1 -1
  19. package/dist/client.js +1 -0
  20. package/dist/components/layouts/login/index.d.ts +7 -1
  21. package/dist/components/layouts/login/index.d.ts.map +1 -1
  22. package/dist/components/layouts/login/index.js +2 -2
  23. package/dist/components/layouts/otp/index.d.ts +10 -0
  24. package/dist/components/layouts/otp/index.d.ts.map +1 -0
  25. package/dist/components/layouts/otp/index.js +14 -0
  26. package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts.map +1 -1
  27. package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +8 -3
  28. package/dist/components/otp/OTPRequestForm.d.ts +11 -0
  29. package/dist/components/otp/OTPRequestForm.d.ts.map +1 -0
  30. package/dist/components/otp/OTPRequestForm.js +42 -0
  31. package/dist/components/otp/OTPVerifyForm.d.ts +16 -0
  32. package/dist/components/otp/OTPVerifyForm.d.ts.map +1 -0
  33. package/dist/components/otp/OTPVerifyForm.js +75 -0
  34. package/dist/components/otp/index.d.ts +5 -0
  35. package/dist/components/otp/index.d.ts.map +1 -0
  36. package/dist/components/otp/index.js +2 -0
  37. package/dist/components/ui/input-otp.d.ts +35 -0
  38. package/dist/components/ui/input-otp.d.ts.map +1 -0
  39. package/dist/components/ui/input-otp.js +44 -0
  40. package/dist/lib/cookies_config.server.d.ts +1 -0
  41. package/dist/lib/cookies_config.server.d.ts.map +1 -1
  42. package/dist/lib/cookies_config.server.js +1 -0
  43. package/dist/lib/login_config.server.d.ts +6 -0
  44. package/dist/lib/login_config.server.d.ts.map +1 -1
  45. package/dist/lib/login_config.server.js +7 -0
  46. package/dist/lib/otp_config.server.d.ts +49 -0
  47. package/dist/lib/otp_config.server.d.ts.map +1 -0
  48. package/dist/lib/otp_config.server.js +48 -0
  49. package/dist/lib/services/email_service.d.ts +1 -1
  50. package/dist/lib/services/email_service.d.ts.map +1 -1
  51. package/dist/lib/services/email_service.js +2 -0
  52. package/dist/lib/services/email_template_manifest.d.ts.map +1 -1
  53. package/dist/lib/services/email_template_manifest.js +17 -0
  54. package/dist/lib/services/email_templates/otp_signin_code.html +13 -0
  55. package/dist/lib/services/email_templates/otp_signin_code.txt +5 -0
  56. package/dist/lib/services/index.d.ts +2 -0
  57. package/dist/lib/services/index.d.ts.map +1 -1
  58. package/dist/lib/services/index.js +1 -0
  59. package/dist/lib/services/otp_service.d.ts +46 -0
  60. package/dist/lib/services/otp_service.d.ts.map +1 -0
  61. package/dist/lib/services/otp_service.js +238 -0
  62. package/dist/lib/services/session_token_service.d.ts +3 -1
  63. package/dist/lib/services/session_token_service.d.ts.map +1 -1
  64. package/dist/lib/services/session_token_service.js +4 -2
  65. package/dist/page_components/otp.d.ts +4 -0
  66. package/dist/page_components/otp.d.ts.map +1 -0
  67. package/dist/page_components/otp.js +5 -0
  68. package/dist/server/routes/index.d.ts +2 -0
  69. package/dist/server/routes/index.d.ts.map +1 -1
  70. package/dist/server/routes/index.js +3 -0
  71. package/dist/server/routes/me.d.ts.map +1 -1
  72. package/dist/server/routes/me.js +43 -1
  73. package/dist/server/routes/otp/request.d.ts +3 -0
  74. package/dist/server/routes/otp/request.d.ts.map +1 -0
  75. package/dist/server/routes/otp/request.js +33 -0
  76. package/dist/server/routes/otp/verify.d.ts +3 -0
  77. package/dist/server/routes/otp/verify.d.ts.map +1 -0
  78. package/dist/server/routes/otp/verify.js +58 -0
  79. package/dist/server-lib.d.ts +3 -0
  80. package/dist/server-lib.d.ts.map +1 -1
  81. package/dist/server-lib.js +2 -0
  82. package/dist/server_pages/login.d.ts.map +1 -1
  83. package/dist/server_pages/login.js +1 -1
  84. package/dist/server_pages/login_client_wrapper.d.ts +1 -1
  85. package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
  86. package/dist/server_pages/login_client_wrapper.js +2 -2
  87. package/dist/server_pages/otp.d.ts +42 -0
  88. package/dist/server_pages/otp.d.ts.map +1 -0
  89. package/dist/server_pages/otp.js +38 -0
  90. package/package.json +18 -1
@@ -0,0 +1,42 @@
1
+ import "server-only";
2
+ import * as React from "react";
3
+ export type OTPPageProps = {
4
+ /**
5
+ * searchParams from Next.js page props — supports both sync and async forms.
6
+ * Reads `redirect` param to set the post-sign-in redirect URL.
7
+ */
8
+ searchParams?: Promise<{
9
+ redirect?: string;
10
+ }> | {
11
+ redirect?: string;
12
+ };
13
+ /**
14
+ * Page heading passed through to OTPLayout.
15
+ * Defaults to "Sign in with email code".
16
+ */
17
+ title?: string;
18
+ };
19
+ /**
20
+ * Zero-config OTPPage server component
21
+ *
22
+ * Renders an email OTP sign-in flow: the user enters their email, receives a
23
+ * 6-digit code, and is redirected after successful verification.
24
+ *
25
+ * Usage in consuming apps:
26
+ * ```tsx
27
+ * // app/otp/page.tsx
28
+ * import { OTPPage } from "hazo_auth/pages/otp";
29
+ *
30
+ * export default function Page(props) {
31
+ * return <OTPPage {...props} />;
32
+ * }
33
+ * ```
34
+ *
35
+ * Pass `?redirect=/dashboard` in the URL to control the post-sign-in destination.
36
+ *
37
+ * @param props - Optional searchParams and title
38
+ * @returns Server-rendered OTP sign-in page
39
+ */
40
+ export default function OTPPage({ searchParams, title, }?: OTPPageProps): Promise<React.ReactElement>;
41
+ export { OTPPage };
42
+ //# sourceMappingURL=otp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otp.d.ts","sourceRoot":"","sources":["../../src/server_pages/otp.tsx"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAEtE;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAA8B,OAAO,CAAC,EACpC,YAAY,EACZ,KAAK,GACN,GAAE,YAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAYjD;AAGD,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // file_description: Zero-config OTPPage server component - drop in and use with no configuration required
3
+ // section: server-only-guard
4
+ import "server-only";
5
+ import { OTPLayout } from "../components/layouts/otp.js";
6
+ import { AuthPageShell } from "../components/layouts/shared/components/auth_page_shell.js";
7
+ // section: component
8
+ /**
9
+ * Zero-config OTPPage server component
10
+ *
11
+ * Renders an email OTP sign-in flow: the user enters their email, receives a
12
+ * 6-digit code, and is redirected after successful verification.
13
+ *
14
+ * Usage in consuming apps:
15
+ * ```tsx
16
+ * // app/otp/page.tsx
17
+ * import { OTPPage } from "hazo_auth/pages/otp";
18
+ *
19
+ * export default function Page(props) {
20
+ * return <OTPPage {...props} />;
21
+ * }
22
+ * ```
23
+ *
24
+ * Pass `?redirect=/dashboard` in the URL to control the post-sign-in destination.
25
+ *
26
+ * @param props - Optional searchParams and title
27
+ * @returns Server-rendered OTP sign-in page
28
+ */
29
+ export default async function OTPPage({ searchParams, title, } = {}) {
30
+ var _a;
31
+ const params = searchParams instanceof Promise
32
+ ? await searchParams
33
+ : (searchParams !== null && searchParams !== void 0 ? searchParams : {});
34
+ const redirect_url = (_a = params.redirect) !== null && _a !== void 0 ? _a : "/";
35
+ return (_jsx(AuthPageShell, { children: _jsx(OTPLayout, { redirect_url: redirect_url, title: title }) }));
36
+ }
37
+ // Named export for direct imports
38
+ export { OTPPage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_auth",
3
- "version": "6.0.0",
3
+ "version": "6.1.1",
4
4
  "description": "Zero-config authentication UI components for Next.js with RBAC, OAuth, scope-based multi-tenancy, and invitations",
5
5
  "keywords": [
6
6
  "authentication",
@@ -81,6 +81,10 @@
81
81
  "types": "./dist/components/layouts/create_firm/index.d.ts",
82
82
  "import": "./dist/components/layouts/create_firm/index.js"
83
83
  },
84
+ "./components/layouts/otp": {
85
+ "types": "./dist/components/layouts/otp/index.d.ts",
86
+ "import": "./dist/components/layouts/otp/index.js"
87
+ },
84
88
  "./components/layouts/shared": {
85
89
  "types": "./dist/components/layouts/shared/index.d.ts",
86
90
  "import": "./dist/components/layouts/shared/index.js"
@@ -113,6 +117,10 @@
113
117
  "types": "./dist/server_pages/login.d.ts",
114
118
  "import": "./dist/server_pages/login.js"
115
119
  },
120
+ "./pages/otp": {
121
+ "types": "./dist/server_pages/otp.d.ts",
122
+ "import": "./dist/server_pages/otp.js"
123
+ },
116
124
  "./pages/register": {
117
125
  "types": "./dist/server_pages/register.d.ts",
118
126
  "import": "./dist/server_pages/register.js"
@@ -141,6 +149,10 @@
141
149
  "types": "./dist/page_components/login.d.ts",
142
150
  "import": "./dist/page_components/login.js"
143
151
  },
152
+ "./page_components/otp": {
153
+ "types": "./dist/page_components/otp.d.ts",
154
+ "import": "./dist/page_components/otp.js"
155
+ },
144
156
  "./page_components/register": {
145
157
  "types": "./dist/page_components/register.d.ts",
146
158
  "import": "./dist/page_components/register.js"
@@ -254,6 +266,7 @@
254
266
  "hazo_logs": "^1.0.13",
255
267
  "hazo_notify": "^3.0.0",
256
268
  "hazo_ui": "^2.7.0",
269
+ "input-otp": "^1.4.0",
257
270
  "lucide-react": "^0.553.0",
258
271
  "next": ">=14.0.0",
259
272
  "next-auth": "^4.24.0",
@@ -278,6 +291,9 @@
278
291
  "hazo_ui": {
279
292
  "optional": true
280
293
  },
294
+ "input-otp": {
295
+ "optional": true
296
+ },
281
297
  "next-themes": {
282
298
  "optional": true
283
299
  },
@@ -380,6 +396,7 @@
380
396
  "hazo_ui": "^2.7.0",
381
397
  "jest": "^30.2.0",
382
398
  "jest-environment-jsdom": "^30.0.0",
399
+ "input-otp": "^1.4.0",
383
400
  "lucide-react": "^0.553.0",
384
401
  "next": "^16.0.7",
385
402
  "next-auth": "^4.24.13",