@arch-cadre/auth 0.0.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 (64) hide show
  1. package/dist/actions/basic.cjs +46 -0
  2. package/dist/actions/basic.d.ts +14 -0
  3. package/dist/actions/basic.mjs +32 -0
  4. package/dist/actions/email.cjs +209 -0
  5. package/dist/actions/email.d.ts +7 -0
  6. package/dist/actions/email.mjs +186 -0
  7. package/dist/actions/index.cjs +27 -0
  8. package/dist/actions/index.d.ts +2 -0
  9. package/dist/actions/index.mjs +2 -0
  10. package/dist/index.cjs +16 -0
  11. package/dist/index.d.ts +3 -0
  12. package/dist/index.mjs +9 -0
  13. package/dist/intl.d.ts +13 -0
  14. package/dist/routes.cjs +46 -0
  15. package/dist/routes.d.ts +2 -0
  16. package/dist/routes.mjs +48 -0
  17. package/dist/types.cjs +1 -0
  18. package/dist/types.d.ts +12 -0
  19. package/dist/types.mjs +0 -0
  20. package/dist/ui/forgot-password/components.cjs +91 -0
  21. package/dist/ui/forgot-password/components.d.ts +2 -0
  22. package/dist/ui/forgot-password/components.mjs +63 -0
  23. package/dist/ui/forgot-password/page.cjs +13 -0
  24. package/dist/ui/forgot-password/page.d.ts +2 -0
  25. package/dist/ui/forgot-password/page.mjs +5 -0
  26. package/dist/ui/layout.cjs +39 -0
  27. package/dist/ui/layout.d.ts +4 -0
  28. package/dist/ui/layout.mjs +18 -0
  29. package/dist/ui/reset-password/components.cjs +109 -0
  30. package/dist/ui/reset-password/components.d.ts +2 -0
  31. package/dist/ui/reset-password/components.mjs +84 -0
  32. package/dist/ui/reset-password/page.cjs +29 -0
  33. package/dist/ui/reset-password/page.d.ts +2 -0
  34. package/dist/ui/reset-password/page.mjs +21 -0
  35. package/dist/ui/reset-password/verify-email/components.cjs +106 -0
  36. package/dist/ui/reset-password/verify-email/components.d.ts +4 -0
  37. package/dist/ui/reset-password/verify-email/components.mjs +62 -0
  38. package/dist/ui/reset-password/verify-email/page.cjs +31 -0
  39. package/dist/ui/reset-password/verify-email/page.d.ts +2 -0
  40. package/dist/ui/reset-password/verify-email/page.mjs +21 -0
  41. package/dist/ui/signin/components.cjs +172 -0
  42. package/dist/ui/signin/components.d.ts +11 -0
  43. package/dist/ui/signin/components.mjs +134 -0
  44. package/dist/ui/signin/page.cjs +41 -0
  45. package/dist/ui/signin/page.d.ts +2 -0
  46. package/dist/ui/signin/page.mjs +39 -0
  47. package/dist/ui/signup/components.cjs +193 -0
  48. package/dist/ui/signup/components.d.ts +11 -0
  49. package/dist/ui/signup/components.mjs +150 -0
  50. package/dist/ui/signup/page.cjs +36 -0
  51. package/dist/ui/signup/page.d.ts +2 -0
  52. package/dist/ui/signup/page.mjs +34 -0
  53. package/dist/ui/verify-email/components.cjs +129 -0
  54. package/dist/ui/verify-email/components.d.ts +4 -0
  55. package/dist/ui/verify-email/components.mjs +76 -0
  56. package/dist/ui/verify-email/page.cjs +29 -0
  57. package/dist/ui/verify-email/page.d.ts +2 -0
  58. package/dist/ui/verify-email/page.mjs +21 -0
  59. package/dist/validation.cjs +43 -0
  60. package/dist/validation.d.ts +97 -0
  61. package/dist/validation.mjs +37 -0
  62. package/locales/en/global.json +35 -0
  63. package/manifest.json +11 -0
  64. package/package.json +57 -0
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = Page;
7
+ var _server = require("@arch-cadre/core/server");
8
+ var _navigation = require("next/navigation");
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _components = require("./components.cjs");
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ async function Page() {
14
+ const {
15
+ user
16
+ } = await (0, _server.getCurrentSession)();
17
+ if (user === null) {
18
+ return (0, _navigation.redirect)("/signin");
19
+ }
20
+ const verificationRequest = await (0, _server.getUserEmailVerificationRequestFromRequest)();
21
+ if (verificationRequest === null && user.emailVerifiedAt) {
22
+ return (0, _navigation.redirect)("/?verified");
23
+ }
24
+ return /* @__PURE__ */React.createElement("div", {
25
+ className: "space-y-3"
26
+ }, /* @__PURE__ */React.createElement(_components.EmailVerificationForm, {
27
+ email: verificationRequest?.email ?? user.email
28
+ }), /* @__PURE__ */React.createElement(_components.ResendEmailVerificationCodeForm, null));
29
+ }
@@ -0,0 +1,2 @@
1
+ import * as React from "react";
2
+ export default function Page(): Promise<React.JSX.Element>;
@@ -0,0 +1,21 @@
1
+ import {
2
+ getCurrentSession,
3
+ getUserEmailVerificationRequestFromRequest
4
+ } from "@arch-cadre/core/server";
5
+ import { redirect } from "next/navigation";
6
+ import * as React from "react";
7
+ import {
8
+ EmailVerificationForm,
9
+ ResendEmailVerificationCodeForm
10
+ } from "./components.mjs";
11
+ export default async function Page() {
12
+ const { user } = await getCurrentSession();
13
+ if (user === null) {
14
+ return redirect("/signin");
15
+ }
16
+ const verificationRequest = await getUserEmailVerificationRequestFromRequest();
17
+ if (verificationRequest === null && user.emailVerifiedAt) {
18
+ return redirect("/?verified");
19
+ }
20
+ return /* @__PURE__ */ React.createElement("div", { className: "space-y-3" }, /* @__PURE__ */ React.createElement(EmailVerificationForm, { email: verificationRequest?.email ?? user.email }), /* @__PURE__ */ React.createElement(ResendEmailVerificationCodeForm, null));
21
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.verifyEmailSchema = exports.totpVerifySchema = exports.totpSetupSchema = exports.resetPasswordSchema = exports.registerSchema = exports.recoveryCodeVerifySchema = exports.passkeysSetupSchema = exports.loginSchema = exports.forgotPasswordSchema = void 0;
7
+ var _zod = require("zod");
8
+ const loginSchema = exports.loginSchema = _zod.z.object({
9
+ email: _zod.z.string().email("Invalid email address"),
10
+ password: _zod.z.string().min(8),
11
+ remember: _zod.z.boolean().optional()
12
+ });
13
+ const registerSchema = exports.registerSchema = _zod.z.object({
14
+ username: _zod.z.string().min(2, "Name must be at least 2 characters"),
15
+ email: _zod.z.string().email("Invalid email address"),
16
+ password: _zod.z.string().min(8, "Password must be at least 8 characters"),
17
+ terms: _zod.z.boolean().refine(val => val === true, "You must accept the terms")
18
+ });
19
+ const forgotPasswordSchema = exports.forgotPasswordSchema = _zod.z.object({
20
+ email: _zod.z.string().email("Invalid email address")
21
+ });
22
+ const resetPasswordSchema = exports.resetPasswordSchema = _zod.z.object({
23
+ password: _zod.z.string().min(8, "Password must be at least 8 characters"),
24
+ confirm: _zod.z.string()
25
+ }).refine(data => data.password === data.confirm, {
26
+ message: "Passwords do not match",
27
+ path: ["confirm"]
28
+ });
29
+ const verifyEmailSchema = exports.verifyEmailSchema = _zod.z.object({
30
+ code: _zod.z.string().min(6).max(6)
31
+ });
32
+ const totpSetupSchema = exports.totpSetupSchema = _zod.z.object({
33
+ code: _zod.z.string().regex(/^\d{6}$/, "Code must be 6 digits")
34
+ });
35
+ const totpVerifySchema = exports.totpVerifySchema = _zod.z.object({
36
+ code: _zod.z.string().regex(/^\d{6}$/, "Code must be 6 digits")
37
+ });
38
+ const passkeysSetupSchema = exports.passkeysSetupSchema = _zod.z.object({
39
+ name: _zod.z.string().min(1, "Passkey name is required")
40
+ });
41
+ const recoveryCodeVerifySchema = exports.recoveryCodeVerifySchema = _zod.z.object({
42
+ code: _zod.z.string().min(16, "Recovery code is required").max(16)
43
+ });
@@ -0,0 +1,97 @@
1
+ import { z } from "zod";
2
+ export declare const loginSchema: z.ZodObject<{
3
+ email: z.ZodString;
4
+ password: z.ZodString;
5
+ remember: z.ZodOptional<z.ZodBoolean>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ email: string;
8
+ password: string;
9
+ remember?: boolean | undefined;
10
+ }, {
11
+ email: string;
12
+ password: string;
13
+ remember?: boolean | undefined;
14
+ }>;
15
+ export declare const registerSchema: z.ZodObject<{
16
+ username: z.ZodString;
17
+ email: z.ZodString;
18
+ password: z.ZodString;
19
+ terms: z.ZodEffects<z.ZodBoolean, boolean, boolean>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ email: string;
22
+ password: string;
23
+ username: string;
24
+ terms: boolean;
25
+ }, {
26
+ email: string;
27
+ password: string;
28
+ username: string;
29
+ terms: boolean;
30
+ }>;
31
+ export declare const forgotPasswordSchema: z.ZodObject<{
32
+ email: z.ZodString;
33
+ }, "strip", z.ZodTypeAny, {
34
+ email: string;
35
+ }, {
36
+ email: string;
37
+ }>;
38
+ export declare const resetPasswordSchema: z.ZodEffects<z.ZodObject<{
39
+ password: z.ZodString;
40
+ confirm: z.ZodString;
41
+ }, "strip", z.ZodTypeAny, {
42
+ password: string;
43
+ confirm: string;
44
+ }, {
45
+ password: string;
46
+ confirm: string;
47
+ }>, {
48
+ password: string;
49
+ confirm: string;
50
+ }, {
51
+ password: string;
52
+ confirm: string;
53
+ }>;
54
+ export declare const verifyEmailSchema: z.ZodObject<{
55
+ code: z.ZodString;
56
+ }, "strip", z.ZodTypeAny, {
57
+ code: string;
58
+ }, {
59
+ code: string;
60
+ }>;
61
+ export declare const totpSetupSchema: z.ZodObject<{
62
+ code: z.ZodString;
63
+ }, "strip", z.ZodTypeAny, {
64
+ code: string;
65
+ }, {
66
+ code: string;
67
+ }>;
68
+ export declare const totpVerifySchema: z.ZodObject<{
69
+ code: z.ZodString;
70
+ }, "strip", z.ZodTypeAny, {
71
+ code: string;
72
+ }, {
73
+ code: string;
74
+ }>;
75
+ export declare const passkeysSetupSchema: z.ZodObject<{
76
+ name: z.ZodString;
77
+ }, "strip", z.ZodTypeAny, {
78
+ name: string;
79
+ }, {
80
+ name: string;
81
+ }>;
82
+ export declare const recoveryCodeVerifySchema: z.ZodObject<{
83
+ code: z.ZodString;
84
+ }, "strip", z.ZodTypeAny, {
85
+ code: string;
86
+ }, {
87
+ code: string;
88
+ }>;
89
+ export type LoginInput = z.infer<typeof loginSchema>;
90
+ export type RegisterInput = z.infer<typeof registerSchema>;
91
+ export type ForgotPasswordInput = z.infer<typeof forgotPasswordSchema>;
92
+ export type ResetPasswordInput = z.infer<typeof resetPasswordSchema>;
93
+ export type TOTPSetupInput = z.infer<typeof totpSetupSchema>;
94
+ export type TOTPVerifyInput = z.infer<typeof totpVerifySchema>;
95
+ export type PasskeysSetupInput = z.infer<typeof passkeysSetupSchema>;
96
+ export type VerifyEmailInput = z.infer<typeof verifyEmailSchema>;
97
+ export type RecoveryVerifyInput = z.infer<typeof recoveryCodeVerifySchema>;
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+ export const loginSchema = z.object({
3
+ email: z.string().email("Invalid email address"),
4
+ password: z.string().min(8),
5
+ remember: z.boolean().optional()
6
+ });
7
+ export const registerSchema = z.object({
8
+ username: z.string().min(2, "Name must be at least 2 characters"),
9
+ email: z.string().email("Invalid email address"),
10
+ password: z.string().min(8, "Password must be at least 8 characters"),
11
+ terms: z.boolean().refine((val) => val === true, "You must accept the terms")
12
+ });
13
+ export const forgotPasswordSchema = z.object({
14
+ email: z.string().email("Invalid email address")
15
+ });
16
+ export const resetPasswordSchema = z.object({
17
+ password: z.string().min(8, "Password must be at least 8 characters"),
18
+ confirm: z.string()
19
+ }).refine((data) => data.password === data.confirm, {
20
+ message: "Passwords do not match",
21
+ path: ["confirm"]
22
+ });
23
+ export const verifyEmailSchema = z.object({
24
+ code: z.string().min(6).max(6)
25
+ });
26
+ export const totpSetupSchema = z.object({
27
+ code: z.string().regex(/^\d{6}$/, "Code must be 6 digits")
28
+ });
29
+ export const totpVerifySchema = z.object({
30
+ code: z.string().regex(/^\d{6}$/, "Code must be 6 digits")
31
+ });
32
+ export const passkeysSetupSchema = z.object({
33
+ name: z.string().min(1, "Passkey name is required")
34
+ });
35
+ export const recoveryCodeVerifySchema = z.object({
36
+ code: z.string().min(16, "Recovery code is required").max(16)
37
+ });
@@ -0,0 +1,35 @@
1
+ {
2
+ "error_occurred": "error_occurred",
3
+ "Verify email": "Verify email",
4
+ "We've sent a verification code to your email address: {email}": "We've sent a verification code to your email address: {email}",
5
+ "Verify Email": "Verify Email",
6
+ "Resend verification email": "Resend verification email",
7
+ "Sign Up": "Sign Up",
8
+ "Sign up to access your dashboard, settings and projects.": "Sign up to access your dashboard, settings and projects.",
9
+ "or sign up with email": "or sign up with email",
10
+ "Email address": "Email address",
11
+ "Username": "Username",
12
+ "Password": "Password",
13
+ "I agree to the": "I agree to the",
14
+ "Terms": "Terms",
15
+ "and": "and",
16
+ "Privacy Policy": "Privacy Policy",
17
+ "Already have an account?": "Already have an account?",
18
+ "Sign In": "Sign In",
19
+ "Sign in to access your dashboard, settings and projects.": "Sign in to access your dashboard, settings and projects.",
20
+ "or sign in with email": "or sign in with email",
21
+ "Forgot your password?": "Forgot your password?",
22
+ "Remember me": "Remember me",
23
+ "No account?": "No account?",
24
+ "Reset password": "Reset password",
25
+ "Enter your new password below.": "Enter your new password below.",
26
+ "New Password": "New Password",
27
+ "Confirm Password": "Confirm Password",
28
+ "Forgot Password": "Forgot Password",
29
+ "Enter your email address and we'll send you a link to reset your password.": "Enter your email address and we'll send you a link to reset your password.",
30
+ "Send reset link": "Send reset link",
31
+ "Verification failed. Please try again.": "Verification failed. Please try again.",
32
+ "Verify your email address": "Verify your email address",
33
+ "We sent an 6-digit code to {email}.": "We sent an 6-digit code to {email}.",
34
+ "Verify": "Verify"
35
+ }
package/manifest.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "id": "auth-module",
3
+ "name": "Kryo Auth",
4
+ "version": "0.0.1",
5
+ "description": "Basic authentication module",
6
+ "enabled": true,
7
+ "system": true,
8
+ "dependencies": [],
9
+ "extends": [],
10
+ "isNpm": true
11
+ }
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@arch-cadre/auth",
3
+ "version": "0.0.1",
4
+ "description": "Auth module for Kryo framework",
5
+ "type": "module",
6
+ "exports": {
7
+ "./package.json": "./package.json",
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.cjs"
12
+ },
13
+ "./actions": {
14
+ "types": "./dist/actions/index.d.ts",
15
+ "import": "./dist/actions/index.mjs",
16
+ "require": "./dist/actions/index.cjs"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "locales",
22
+ "manifest.json"
23
+ ],
24
+ "scripts": {
25
+ "release": "npm publish --access public --no-git-checks",
26
+ "clean": "rm -rf ./dist",
27
+ "switch:dev": "node scripts/switchToSrc.js",
28
+ "switch:prod": "node scripts/switchToDist.js",
29
+ "dev": "unbuild --stub",
30
+ "build": "unbuild"
31
+ },
32
+ "dependencies": {
33
+ "@arch-cadre/modules": "^0.0.15",
34
+ "@arch-cadre/ui": "^0.0.15",
35
+ "@hookform/resolvers": "^3.10.0",
36
+ "lucide-react": "^0.475.0",
37
+ "react-hook-form": "^7.54.2",
38
+ "sonner": "^2.0.7",
39
+ "zod": "^3.24.1"
40
+ },
41
+ "devDependencies": {
42
+ "@arch-cadre/core": "^0.0.15",
43
+ "@types/react": "^19",
44
+ "next": "16.1.1",
45
+ "react": "^19.0.0",
46
+ "typescript": "^5.3.3",
47
+ "unbuild": "^3.6.1"
48
+ },
49
+ "peerDependencies": {
50
+ "@arch-cadre/core": "^0.0.15",
51
+ "@arch-cadre/intl": "^0.0.15",
52
+ "@arch-cadre/ui": "^0.0.15",
53
+ "next": ">=13.0.0",
54
+ "react": "^19.0.0"
55
+ },
56
+ "main": "./dist/index.mjs"
57
+ }