@insforge/react 0.4.6 → 0.4.8
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/atoms.cjs +79 -62
- package/dist/atoms.cjs.map +1 -1
- package/dist/atoms.d.cts +1 -2
- package/dist/atoms.d.ts +1 -2
- package/dist/atoms.js +80 -63
- package/dist/atoms.js.map +1 -1
- package/dist/components.cjs +96 -98
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +97 -99
- package/dist/components.js.map +1 -1
- package/dist/forms.cjs +86 -86
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.js +87 -87
- package/dist/forms.js.map +1 -1
- package/dist/index.cjs +110 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +110 -122
- package/dist/index.js.map +1 -1
- package/dist/lib.cjs +24 -0
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.d.cts +36 -1
- package/dist/lib.d.ts +36 -1
- package/dist/lib.js +23 -1
- package/dist/lib.js.map +1 -1
- package/dist/router.cjs +11 -21
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts +5 -4
- package/dist/router.d.ts +5 -4
- package/dist/router.js +11 -21
- package/dist/router.js.map +1 -1
- package/dist/styles.css +43 -63
- package/package.json +1 -1
package/dist/lib.cjs
CHANGED
|
@@ -74,10 +74,34 @@ function checkPasswordStrength(password) {
|
|
|
74
74
|
return { score, feedback };
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
// src/lib/path-utils.ts
|
|
78
|
+
function resolveAuthPath(targetPath) {
|
|
79
|
+
if (typeof window === "undefined") {
|
|
80
|
+
return targetPath;
|
|
81
|
+
}
|
|
82
|
+
const currentPath = window.location.pathname;
|
|
83
|
+
if (currentPath.startsWith("/auth/")) {
|
|
84
|
+
if (targetPath.startsWith("/auth/")) {
|
|
85
|
+
return targetPath;
|
|
86
|
+
}
|
|
87
|
+
return `/auth${targetPath}`;
|
|
88
|
+
}
|
|
89
|
+
return targetPath;
|
|
90
|
+
}
|
|
91
|
+
function resolveAuthUrl(targetPath, searchParams) {
|
|
92
|
+
const resolvedPath = resolveAuthPath(targetPath);
|
|
93
|
+
if (!searchParams || searchParams.toString() === "") {
|
|
94
|
+
return resolvedPath;
|
|
95
|
+
}
|
|
96
|
+
return `${resolvedPath}?${searchParams.toString()}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
77
99
|
exports.checkPasswordStrength = checkPasswordStrength;
|
|
78
100
|
exports.createPasswordSchema = createPasswordSchema;
|
|
79
101
|
exports.emailSchema = emailSchema;
|
|
80
102
|
exports.passwordSchema = passwordSchema;
|
|
103
|
+
exports.resolveAuthPath = resolveAuthPath;
|
|
104
|
+
exports.resolveAuthUrl = resolveAuthUrl;
|
|
81
105
|
exports.validateEmail = validateEmail;
|
|
82
106
|
exports.validatePassword = validatePassword;
|
|
83
107
|
//# sourceMappingURL=lib.cjs.map
|
package/dist/lib.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/validation.ts"],"names":["z"],"mappings":";;;;AAKO,IAAM,WAAA,GAAcA,MAAE,MAAA,EAAO,CAAE,IAAI,CAAA,EAAG,mBAAmB,CAAA,CAAE,KAAA,CAAM,uBAAuB;AAKxF,SAAS,qBAAqB,OAAA,EAMlC;AACD,EAAA,MAAM;AAAA,IACJ,SAAA,GAAY,CAAA;AAAA,IACZ,gBAAA,GAAmB,KAAA;AAAA,IACnB,gBAAA,GAAmB,KAAA;AAAA,IACnB,aAAA,GAAgB,KAAA;AAAA,IAChB,kBAAA,GAAqB;AAAA,GACvB,GAAI,WAAW,EAAC;AAEhB,EAAA,IAAI,MAAA,GAASA,MAAE,MAAA,EAAO,CAAE,IAAI,SAAA,EAAW,CAAA,0BAAA,EAA6B,SAAS,CAAA,WAAA,CAAa,CAAA;AAE1F,EAAA,IAAI,gBAAA,EAAkB;AACpB,IAAA,MAAA,GAAS,MAA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QAAA,CAAS,UAAU,CAAA,EAAG;AACxB,IAAA,KAAA,IAAS,CAAA;AAAA,EACX,CAAA,MAAO;AACL,IAAA,QAAA,CAAS,KAAK,2BAA2B,CAAA;AAAA,EAC3C;AAEA,EAAA,IAAI,QAAA,CAAS,UAAU,EAAA,EAAI;AACzB,IAAA,KAAA,IAAS,CAAA;AAAA,EACX;AAEA,EAAA,IAAI,QAAQ,IAAA,CAAK,QAAQ,KAAK,OAAA,CAAQ,IAAA,CAAK,QAAQ,CAAA,EAAG;AACpD,IAAA,KAAA,IAAS,CAAA;AAAA,EACX,CAAA,MAAO;AACL,IAAA,QAAA,CAAS,KAAK,0CAA0C,CAAA;AAAA,EAC1D;AAEA,EAAA,IAAI,IAAA,CAAK,IAAA,CAAK,QAAQ,CAAA,EAAG;AACvB,IAAA,KAAA,IAAS,CAAA;AAAA,EACX,CAAA,MAAO;AACL,IAAA,QAAA,CAAS,KAAK,6BAA6B,CAAA;AAAA,EAC7C;AAEA,EAAA,IAAI,qCAAA,CAAsC,IAAA,CAAK,QAAQ,CAAA,EAAG;AACxD,IAAA,KAAA,IAAS,CAAA;AAAA,EACX,CAAA,MAAO;AACL,IAAA,QAAA,CAAS,KAAK,wCAAwC,CAAA;AAAA,EACxD;AAEA,EAAA,OAAO,EAAE,OAAO,QAAA,EAAS;AAC3B","file":"lib.cjs","sourcesContent":["import { z } from 'zod';\n\n/**\n * Email validation schema\n */\nexport const emailSchema = z.string().min(1, 'Email is required').email('Invalid email address');\n\n/**\n * Password validation schema with configurable requirements\n */\nexport function createPasswordSchema(options?: {\n minLength?: number;\n requireUppercase?: boolean;\n requireLowercase?: boolean;\n requireNumber?: boolean;\n requireSpecialChar?: boolean;\n}) {\n const {\n minLength = 6,\n requireUppercase = false,\n requireLowercase = false,\n requireNumber = false,\n requireSpecialChar = false,\n } = options || {};\n\n let schema = z.string().min(minLength, `Password must be at least ${minLength} characters`);\n\n if (requireUppercase) {\n schema = schema.regex(/[A-Z]/, 'Password must contain at least one uppercase letter');\n }\n\n if (requireLowercase) {\n schema = schema.regex(/[a-z]/, 'Password must contain at least one lowercase letter');\n }\n\n if (requireNumber) {\n schema = schema.regex(/\\d/, 'Password must contain at least one number');\n }\n\n if (requireSpecialChar) {\n schema = schema.regex(\n /[!@#$%^&*()_+\\-=[\\]{};':\"\\\\|,.<>/?]/,\n 'Password must contain at least one special character'\n );\n }\n\n return schema;\n}\n\n/**\n * Default password schema (minimum 6 characters)\n */\nexport const passwordSchema = createPasswordSchema();\n\n/**\n * Validate email format\n */\nexport function validateEmail(email: string): { valid: boolean; error?: string } {\n const result = emailSchema.safeParse(email);\n if (result.success) {\n return { valid: true };\n }\n return { valid: false, error: result.error.message };\n}\n\n/**\n * Validate password format\n */\nexport function validatePassword(\n password: string,\n options?: Parameters<typeof createPasswordSchema>[0]\n): { valid: boolean; error?: string } {\n const schema = createPasswordSchema(options);\n const result = schema.safeParse(password);\n if (result.success) {\n return { valid: true };\n }\n return { valid: false, error: result.error.message };\n}\n\n/**\n * Validate password strength based on multiple criteria\n */\nexport function checkPasswordStrength(password: string): {\n score: number;\n feedback: string[];\n} {\n const feedback: string[] = [];\n let score = 0;\n\n if (password.length >= 8) {\n score += 1;\n } else {\n feedback.push('Use at least 8 characters');\n }\n\n if (password.length >= 12) {\n score += 1;\n }\n\n if (/[a-z]/.test(password) && /[A-Z]/.test(password)) {\n score += 1;\n } else {\n feedback.push('Use both uppercase and lowercase letters');\n }\n\n if (/\\d/.test(password)) {\n score += 1;\n } else {\n feedback.push('Include at least one number');\n }\n\n if (/[!@#$%^&*()_+\\-=[\\]{};':\"\\\\|,.<>/?]/.test(password)) {\n score += 1;\n } else {\n feedback.push('Include at least one special character');\n }\n\n return { score, feedback };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/validation.ts","../src/lib/path-utils.ts"],"names":["z"],"mappings":";;;;AAKO,IAAM,WAAA,GAAcA,MAAE,MAAA,EAAO,CAAE,IAAI,CAAA,EAAG,mBAAmB,C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,EAAA,OAAO,EAAE,OAAO,QAAA,EAAS;AAC3B;;;AClGO,SAAS,gBAAgB,UAAA,EAA4B;AAC1D,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA,OAAO,UAAA;AAAA,EACT;AAEA,EAAA,MAAM,WAAA,GAAc,OAAO,QAAA,CAAS,QAAA;AAGpC,EAAA,IAAI,WAAA,CAAY,UAAA,CAAW,QAAQ,CAAA,EAAG;AAEpC,IAAA,IAAI,UAAA,CAAW,UAAA,CAAW,QAAQ,CAAA,EAAG;AACnC,MAAA,OAAO,UAAA;AAAA,IACT;AAEA,IAAA,OAAO,QAAQ,UAAU,CAAA,CAAA;AAAA,EAC3B;AAGA,EAAA,OAAO,UAAA;AACT;AAcO,SAAS,cAAA,CAAe,YAAoB,YAAA,EAAwC;AACzF,EAAA,MAAM,YAAA,GAAe,gBAAgB,UAAU,CAAA;AAE/C,EAAA,IAAI,CAAC,YAAA,IAAgB,YAAA,CAAa,QAAA,OAAe,EAAA,EAAI;AACnD,IAAA,OAAO,YAAA;AAAA,EACT;AAEA,EAAA,OAAO,CAAA,EAAG,YAAY,CAAA,CAAA,EAAI,YAAA,CAAa,UAAU,CAAA,CAAA;AACnD","file":"lib.cjs","sourcesContent":["import { z } from 'zod';\n\n/**\n * Email validation schema\n */\nexport const emailSchema = z.string().min(1, 'Email is required').email('Invalid email address');\n\n/**\n * Password validation schema with configurable requirements\n */\nexport function createPasswordSchema(options?: {\n minLength?: number;\n requireUppercase?: boolean;\n requireLowercase?: boolean;\n requireNumber?: boolean;\n requireSpecialChar?: boolean;\n}) {\n const {\n minLength = 6,\n requireUppercase = false,\n requireLowercase = false,\n requireNumber = false,\n requireSpecialChar = false,\n } = options || {};\n\n let schema = z.string().min(minLength, `Password must be at least ${minLength} characters`);\n\n if (requireUppercase) {\n schema = schema.regex(/[A-Z]/, 'Password must contain at least one uppercase letter');\n }\n\n if (requireLowercase) {\n schema = schema.regex(/[a-z]/, 'Password must contain at least one lowercase letter');\n }\n\n if (requireNumber) {\n schema = schema.regex(/\\d/, 'Password must contain at least one number');\n }\n\n if (requireSpecialChar) {\n schema = schema.regex(\n /[!@#$%^&*()_+\\-=[\\]{};':\"\\\\|,.<>/?]/,\n 'Password must contain at least one special character'\n );\n }\n\n return schema;\n}\n\n/**\n * Default password schema (minimum 6 characters)\n */\nexport const passwordSchema = createPasswordSchema();\n\n/**\n * Validate email format\n */\nexport function validateEmail(email: string): { valid: boolean; error?: string } {\n const result = emailSchema.safeParse(email);\n if (result.success) {\n return { valid: true };\n }\n return { valid: false, error: result.error.message };\n}\n\n/**\n * Validate password format\n */\nexport function validatePassword(\n password: string,\n options?: Parameters<typeof createPasswordSchema>[0]\n): { valid: boolean; error?: string } {\n const schema = createPasswordSchema(options);\n const result = schema.safeParse(password);\n if (result.success) {\n return { valid: true };\n }\n return { valid: false, error: result.error.message };\n}\n\n/**\n * Validate password strength based on multiple criteria\n */\nexport function checkPasswordStrength(password: string): {\n score: number;\n feedback: string[];\n} {\n const feedback: string[] = [];\n let score = 0;\n\n if (password.length >= 8) {\n score += 1;\n } else {\n feedback.push('Use at least 8 characters');\n }\n\n if (password.length >= 12) {\n score += 1;\n }\n\n if (/[a-z]/.test(password) && /[A-Z]/.test(password)) {\n score += 1;\n } else {\n feedback.push('Use both uppercase and lowercase letters');\n }\n\n if (/\\d/.test(password)) {\n score += 1;\n } else {\n feedback.push('Include at least one number');\n }\n\n if (/[!@#$%^&*()_+\\-=[\\]{};':\"\\\\|,.<>/?]/.test(password)) {\n score += 1;\n } else {\n feedback.push('Include at least one special character');\n }\n\n return { score, feedback };\n}\n","/**\n * Path utilities for handling navigation in auth flows.\n * Ensures proper path resolution when auth pages are served under a base path (e.g., /auth/)\n */\n\n/**\n * Resolves an auth route path relative to the current location.\n * If the current path is under /auth/, it will preserve that prefix.\n * Otherwise, it returns the path as-is.\n *\n * @param targetPath - The target auth path (e.g., '/sign-in', '/sign-up')\n * @returns The resolved path with proper base path handling\n *\n * @example\n * // Current URL: http://localhost:5174/auth/sign-in\n * resolveAuthPath('/sign-up') // Returns '/auth/sign-up'\n *\n * @example\n * // Current URL: http://localhost:5174/sign-in\n * resolveAuthPath('/sign-up') // Returns '/sign-up'\n */\nexport function resolveAuthPath(targetPath: string): string {\n if (typeof window === 'undefined') {\n return targetPath;\n }\n\n const currentPath = window.location.pathname;\n\n // Check if we're currently under /auth/ base path\n if (currentPath.startsWith('/auth/')) {\n // If target already has /auth/ prefix, return as-is\n if (targetPath.startsWith('/auth/')) {\n return targetPath;\n }\n // Add /auth/ prefix to the target path\n return `/auth${targetPath}`;\n }\n\n // Not under /auth/, return target path as-is\n return targetPath;\n}\n\n/**\n * Resolves an auth route URL with search params preserved.\n * Similar to resolveAuthPath but returns a full URL string with query parameters.\n *\n * @param targetPath - The target auth path (e.g., '/sign-in', '/sign-up')\n * @param searchParams - Optional URLSearchParams to append\n * @returns The resolved URL as a string\n *\n * @example\n * // Current URL: http://localhost:5174/auth/sign-in?redirect=...\n * resolveAuthUrl('/sign-up', searchParams) // Returns '/auth/sign-up?redirect=...'\n */\nexport function resolveAuthUrl(targetPath: string, searchParams?: URLSearchParams): string {\n const resolvedPath = resolveAuthPath(targetPath);\n\n if (!searchParams || searchParams.toString() === '') {\n return resolvedPath;\n }\n\n return `${resolvedPath}?${searchParams.toString()}`;\n}\n"]}
|
package/dist/lib.d.cts
CHANGED
|
@@ -40,4 +40,39 @@ declare function checkPasswordStrength(password: string): {
|
|
|
40
40
|
feedback: string[];
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Path utilities for handling navigation in auth flows.
|
|
45
|
+
* Ensures proper path resolution when auth pages are served under a base path (e.g., /auth/)
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Resolves an auth route path relative to the current location.
|
|
49
|
+
* If the current path is under /auth/, it will preserve that prefix.
|
|
50
|
+
* Otherwise, it returns the path as-is.
|
|
51
|
+
*
|
|
52
|
+
* @param targetPath - The target auth path (e.g., '/sign-in', '/sign-up')
|
|
53
|
+
* @returns The resolved path with proper base path handling
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Current URL: http://localhost:5174/auth/sign-in
|
|
57
|
+
* resolveAuthPath('/sign-up') // Returns '/auth/sign-up'
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Current URL: http://localhost:5174/sign-in
|
|
61
|
+
* resolveAuthPath('/sign-up') // Returns '/sign-up'
|
|
62
|
+
*/
|
|
63
|
+
declare function resolveAuthPath(targetPath: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Resolves an auth route URL with search params preserved.
|
|
66
|
+
* Similar to resolveAuthPath but returns a full URL string with query parameters.
|
|
67
|
+
*
|
|
68
|
+
* @param targetPath - The target auth path (e.g., '/sign-in', '/sign-up')
|
|
69
|
+
* @param searchParams - Optional URLSearchParams to append
|
|
70
|
+
* @returns The resolved URL as a string
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Current URL: http://localhost:5174/auth/sign-in?redirect=...
|
|
74
|
+
* resolveAuthUrl('/sign-up', searchParams) // Returns '/auth/sign-up?redirect=...'
|
|
75
|
+
*/
|
|
76
|
+
declare function resolveAuthUrl(targetPath: string, searchParams?: URLSearchParams): string;
|
|
77
|
+
|
|
78
|
+
export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, resolveAuthPath, resolveAuthUrl, validateEmail, validatePassword };
|
package/dist/lib.d.ts
CHANGED
|
@@ -40,4 +40,39 @@ declare function checkPasswordStrength(password: string): {
|
|
|
40
40
|
feedback: string[];
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Path utilities for handling navigation in auth flows.
|
|
45
|
+
* Ensures proper path resolution when auth pages are served under a base path (e.g., /auth/)
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Resolves an auth route path relative to the current location.
|
|
49
|
+
* If the current path is under /auth/, it will preserve that prefix.
|
|
50
|
+
* Otherwise, it returns the path as-is.
|
|
51
|
+
*
|
|
52
|
+
* @param targetPath - The target auth path (e.g., '/sign-in', '/sign-up')
|
|
53
|
+
* @returns The resolved path with proper base path handling
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Current URL: http://localhost:5174/auth/sign-in
|
|
57
|
+
* resolveAuthPath('/sign-up') // Returns '/auth/sign-up'
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Current URL: http://localhost:5174/sign-in
|
|
61
|
+
* resolveAuthPath('/sign-up') // Returns '/sign-up'
|
|
62
|
+
*/
|
|
63
|
+
declare function resolveAuthPath(targetPath: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Resolves an auth route URL with search params preserved.
|
|
66
|
+
* Similar to resolveAuthPath but returns a full URL string with query parameters.
|
|
67
|
+
*
|
|
68
|
+
* @param targetPath - The target auth path (e.g., '/sign-in', '/sign-up')
|
|
69
|
+
* @param searchParams - Optional URLSearchParams to append
|
|
70
|
+
* @returns The resolved URL as a string
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Current URL: http://localhost:5174/auth/sign-in?redirect=...
|
|
74
|
+
* resolveAuthUrl('/sign-up', searchParams) // Returns '/auth/sign-up?redirect=...'
|
|
75
|
+
*/
|
|
76
|
+
declare function resolveAuthUrl(targetPath: string, searchParams?: URLSearchParams): string;
|
|
77
|
+
|
|
78
|
+
export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, resolveAuthPath, resolveAuthUrl, validateEmail, validatePassword };
|
package/dist/lib.js
CHANGED
|
@@ -72,6 +72,28 @@ function checkPasswordStrength(password) {
|
|
|
72
72
|
return { score, feedback };
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
// src/lib/path-utils.ts
|
|
76
|
+
function resolveAuthPath(targetPath) {
|
|
77
|
+
if (typeof window === "undefined") {
|
|
78
|
+
return targetPath;
|
|
79
|
+
}
|
|
80
|
+
const currentPath = window.location.pathname;
|
|
81
|
+
if (currentPath.startsWith("/auth/")) {
|
|
82
|
+
if (targetPath.startsWith("/auth/")) {
|
|
83
|
+
return targetPath;
|
|
84
|
+
}
|
|
85
|
+
return `/auth${targetPath}`;
|
|
86
|
+
}
|
|
87
|
+
return targetPath;
|
|
88
|
+
}
|
|
89
|
+
function resolveAuthUrl(targetPath, searchParams) {
|
|
90
|
+
const resolvedPath = resolveAuthPath(targetPath);
|
|
91
|
+
if (!searchParams || searchParams.toString() === "") {
|
|
92
|
+
return resolvedPath;
|
|
93
|
+
}
|
|
94
|
+
return `${resolvedPath}?${searchParams.toString()}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { checkPasswordStrength, createPasswordSchema, emailSchema, passwordSchema, resolveAuthPath, resolveAuthUrl, validateEmail, validatePassword };
|
|
76
98
|
//# sourceMappingURL=lib.js.map
|
|
77
99
|
//# sourceMappingURL=lib.js.map
|
package/dist/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/validation.ts"],"names":[],"mappings":";;AAKO,IAAM,WAAA,GAAc,EAAE,MAAA,EAAO,CAAE,IAAI,CAAA,EAAG,mBAAmB,CAAA,CAAE,KAAA,CAAM,uBAAuB;AAKxF,SAAS,qBAAqB,OAAA,EAMlC;AACD,EAAA,MAAM;AAAA,IACJ,SAAA,GAAY,CAAA;AAAA,IACZ,gBAAA,GAAmB,KAAA;AAAA,IACnB,gBAAA,GAAmB,KAAA;AAAA,IACnB,aAAA,GAAgB,KAAA;AAAA,IAChB,kBAAA,GAAqB;AAAA,GACvB,GAAI,WAAW,EAAC;AAEhB,EAAA,IAAI,MAAA,GAAS,EAAE,MAAA,EAAO,CAAE,IAAI,SAAA,EAAW,CAAA,0BAAA,EAA6B,SAAS,CAAA,WAAA,CAAa,CAAA;AAE1F,EAAA,IAAI,gBAAA,EAAkB;AACpB,IAAA,MAAA,GAAS,MAAA,CAAO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AAS,UAAU,CAAA,EAAG;AACxB,IAAA,KAAA,IAAS,CAAA;AAAA,EACX,CAAA,MAAO;AACL,IAAA,QAAA,CAAS,KAAK,2BAA2B,CAAA;AAAA,EAC3C;AAEA,EAAA,IAAI,QAAA,CAAS,UAAU,EAAA,EAAI;AACzB,IAAA,KAAA,IAAS,CAAA;AAAA,EACX;AAEA,EAAA,IAAI,QAAQ,IAAA,CAAK,QAAQ,KAAK,OAAA,CAAQ,IAAA,CAAK,QAAQ,CAAA,EAAG;AACpD,IAAA,KAAA,IAAS,CAAA;AAAA,EACX,CAAA,MAAO;AACL,IAAA,QAAA,CAAS,KAAK,0CAA0C,CAAA;AAAA,EAC1D;AAEA,EAAA,IAAI,IAAA,CAAK,IAAA,CAAK,QAAQ,CAAA,EAAG;AACvB,IAAA,KAAA,IAAS,CAAA;AAAA,EACX,CAAA,MAAO;AACL,IAAA,QAAA,CAAS,KAAK,6BAA6B,CAAA;AAAA,EAC7C;AAEA,EAAA,IAAI,qCAAA,CAAsC,IAAA,CAAK,QAAQ,CAAA,EAAG;AACxD,IAAA,KAAA,IAAS,CAAA;AAAA,EACX,CAAA,MAAO;AACL,IAAA,QAAA,CAAS,KAAK,wCAAwC,CAAA;AAAA,EACxD;AAEA,EAAA,OAAO,EAAE,OAAO,QAAA,EAAS;AAC3B","file":"lib.js","sourcesContent":["import { z } from 'zod';\n\n/**\n * Email validation schema\n */\nexport const emailSchema = z.string().min(1, 'Email is required').email('Invalid email address');\n\n/**\n * Password validation schema with configurable requirements\n */\nexport function createPasswordSchema(options?: {\n minLength?: number;\n requireUppercase?: boolean;\n requireLowercase?: boolean;\n requireNumber?: boolean;\n requireSpecialChar?: boolean;\n}) {\n const {\n minLength = 6,\n requireUppercase = false,\n requireLowercase = false,\n requireNumber = false,\n requireSpecialChar = false,\n } = options || {};\n\n let schema = z.string().min(minLength, `Password must be at least ${minLength} characters`);\n\n if (requireUppercase) {\n schema = schema.regex(/[A-Z]/, 'Password must contain at least one uppercase letter');\n }\n\n if (requireLowercase) {\n schema = schema.regex(/[a-z]/, 'Password must contain at least one lowercase letter');\n }\n\n if (requireNumber) {\n schema = schema.regex(/\\d/, 'Password must contain at least one number');\n }\n\n if (requireSpecialChar) {\n schema = schema.regex(\n /[!@#$%^&*()_+\\-=[\\]{};':\"\\\\|,.<>/?]/,\n 'Password must contain at least one special character'\n );\n }\n\n return schema;\n}\n\n/**\n * Default password schema (minimum 6 characters)\n */\nexport const passwordSchema = createPasswordSchema();\n\n/**\n * Validate email format\n */\nexport function validateEmail(email: string): { valid: boolean; error?: string } {\n const result = emailSchema.safeParse(email);\n if (result.success) {\n return { valid: true };\n }\n return { valid: false, error: result.error.message };\n}\n\n/**\n * Validate password format\n */\nexport function validatePassword(\n password: string,\n options?: Parameters<typeof createPasswordSchema>[0]\n): { valid: boolean; error?: string } {\n const schema = createPasswordSchema(options);\n const result = schema.safeParse(password);\n if (result.success) {\n return { valid: true };\n }\n return { valid: false, error: result.error.message };\n}\n\n/**\n * Validate password strength based on multiple criteria\n */\nexport function checkPasswordStrength(password: string): {\n score: number;\n feedback: string[];\n} {\n const feedback: string[] = [];\n let score = 0;\n\n if (password.length >= 8) {\n score += 1;\n } else {\n feedback.push('Use at least 8 characters');\n }\n\n if (password.length >= 12) {\n score += 1;\n }\n\n if (/[a-z]/.test(password) && /[A-Z]/.test(password)) {\n score += 1;\n } else {\n feedback.push('Use both uppercase and lowercase letters');\n }\n\n if (/\\d/.test(password)) {\n score += 1;\n } else {\n feedback.push('Include at least one number');\n }\n\n if (/[!@#$%^&*()_+\\-=[\\]{};':\"\\\\|,.<>/?]/.test(password)) {\n score += 1;\n } else {\n feedback.push('Include at least one special character');\n }\n\n return { score, feedback };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/validation.ts","../src/lib/path-utils.ts"],"names":[],"mappings":";;AAKO,IAAM,WAAA,GAAc,EAAE,MAAA,EAAO,CAAE,IAAI,CAAA,EAAG,mBAAmB,CAAA,CAAE,KAAA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AE,OAAO,QAAA,EAAS;AAC3B;;;AClGO,SAAS,gBAAgB,UAAA,EAA4B;AAC1D,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA,OAAO,UAAA;AAAA,EACT;AAEA,EAAA,MAAM,WAAA,GAAc,OAAO,QAAA,CAAS,QAAA;AAGpC,EAAA,IAAI,WAAA,CAAY,UAAA,CAAW,QAAQ,CAAA,EAAG;AAEpC,IAAA,IAAI,UAAA,CAAW,UAAA,CAAW,QAAQ,CAAA,EAAG;AACnC,MAAA,OAAO,UAAA;AAAA,IACT;AAEA,IAAA,OAAO,QAAQ,UAAU,CAAA,CAAA;AAAA,EAC3B;AAGA,EAAA,OAAO,UAAA;AACT;AAcO,SAAS,cAAA,CAAe,YAAoB,YAAA,EAAwC;AACzF,EAAA,MAAM,YAAA,GAAe,gBAAgB,UAAU,CAAA;AAE/C,EAAA,IAAI,CAAC,YAAA,IAAgB,YAAA,CAAa,QAAA,OAAe,EAAA,EAAI;AACnD,IAAA,OAAO,YAAA;AAAA,EACT;AAEA,EAAA,OAAO,CAAA,EAAG,YAAY,CAAA,CAAA,EAAI,YAAA,CAAa,UAAU,CAAA,CAAA;AACnD","file":"lib.js","sourcesContent":["import { z } from 'zod';\n\n/**\n * Email validation schema\n */\nexport const emailSchema = z.string().min(1, 'Email is required').email('Invalid email address');\n\n/**\n * Password validation schema with configurable requirements\n */\nexport function createPasswordSchema(options?: {\n minLength?: number;\n requireUppercase?: boolean;\n requireLowercase?: boolean;\n requireNumber?: boolean;\n requireSpecialChar?: boolean;\n}) {\n const {\n minLength = 6,\n requireUppercase = false,\n requireLowercase = false,\n requireNumber = false,\n requireSpecialChar = false,\n } = options || {};\n\n let schema = z.string().min(minLength, `Password must be at least ${minLength} characters`);\n\n if (requireUppercase) {\n schema = schema.regex(/[A-Z]/, 'Password must contain at least one uppercase letter');\n }\n\n if (requireLowercase) {\n schema = schema.regex(/[a-z]/, 'Password must contain at least one lowercase letter');\n }\n\n if (requireNumber) {\n schema = schema.regex(/\\d/, 'Password must contain at least one number');\n }\n\n if (requireSpecialChar) {\n schema = schema.regex(\n /[!@#$%^&*()_+\\-=[\\]{};':\"\\\\|,.<>/?]/,\n 'Password must contain at least one special character'\n );\n }\n\n return schema;\n}\n\n/**\n * Default password schema (minimum 6 characters)\n */\nexport const passwordSchema = createPasswordSchema();\n\n/**\n * Validate email format\n */\nexport function validateEmail(email: string): { valid: boolean; error?: string } {\n const result = emailSchema.safeParse(email);\n if (result.success) {\n return { valid: true };\n }\n return { valid: false, error: result.error.message };\n}\n\n/**\n * Validate password format\n */\nexport function validatePassword(\n password: string,\n options?: Parameters<typeof createPasswordSchema>[0]\n): { valid: boolean; error?: string } {\n const schema = createPasswordSchema(options);\n const result = schema.safeParse(password);\n if (result.success) {\n return { valid: true };\n }\n return { valid: false, error: result.error.message };\n}\n\n/**\n * Validate password strength based on multiple criteria\n */\nexport function checkPasswordStrength(password: string): {\n score: number;\n feedback: string[];\n} {\n const feedback: string[] = [];\n let score = 0;\n\n if (password.length >= 8) {\n score += 1;\n } else {\n feedback.push('Use at least 8 characters');\n }\n\n if (password.length >= 12) {\n score += 1;\n }\n\n if (/[a-z]/.test(password) && /[A-Z]/.test(password)) {\n score += 1;\n } else {\n feedback.push('Use both uppercase and lowercase letters');\n }\n\n if (/\\d/.test(password)) {\n score += 1;\n } else {\n feedback.push('Include at least one number');\n }\n\n if (/[!@#$%^&*()_+\\-=[\\]{};':\"\\\\|,.<>/?]/.test(password)) {\n score += 1;\n } else {\n feedback.push('Include at least one special character');\n }\n\n return { score, feedback };\n}\n","/**\n * Path utilities for handling navigation in auth flows.\n * Ensures proper path resolution when auth pages are served under a base path (e.g., /auth/)\n */\n\n/**\n * Resolves an auth route path relative to the current location.\n * If the current path is under /auth/, it will preserve that prefix.\n * Otherwise, it returns the path as-is.\n *\n * @param targetPath - The target auth path (e.g., '/sign-in', '/sign-up')\n * @returns The resolved path with proper base path handling\n *\n * @example\n * // Current URL: http://localhost:5174/auth/sign-in\n * resolveAuthPath('/sign-up') // Returns '/auth/sign-up'\n *\n * @example\n * // Current URL: http://localhost:5174/sign-in\n * resolveAuthPath('/sign-up') // Returns '/sign-up'\n */\nexport function resolveAuthPath(targetPath: string): string {\n if (typeof window === 'undefined') {\n return targetPath;\n }\n\n const currentPath = window.location.pathname;\n\n // Check if we're currently under /auth/ base path\n if (currentPath.startsWith('/auth/')) {\n // If target already has /auth/ prefix, return as-is\n if (targetPath.startsWith('/auth/')) {\n return targetPath;\n }\n // Add /auth/ prefix to the target path\n return `/auth${targetPath}`;\n }\n\n // Not under /auth/, return target path as-is\n return targetPath;\n}\n\n/**\n * Resolves an auth route URL with search params preserved.\n * Similar to resolveAuthPath but returns a full URL string with query parameters.\n *\n * @param targetPath - The target auth path (e.g., '/sign-in', '/sign-up')\n * @param searchParams - Optional URLSearchParams to append\n * @returns The resolved URL as a string\n *\n * @example\n * // Current URL: http://localhost:5174/auth/sign-in?redirect=...\n * resolveAuthUrl('/sign-up', searchParams) // Returns '/auth/sign-up?redirect=...'\n */\nexport function resolveAuthUrl(targetPath: string, searchParams?: URLSearchParams): string {\n const resolvedPath = resolveAuthPath(targetPath);\n\n if (!searchParams || searchParams.toString() === '') {\n return resolvedPath;\n }\n\n return `${resolvedPath}?${searchParams.toString()}`;\n}\n"]}
|
package/dist/router.cjs
CHANGED
|
@@ -3,46 +3,36 @@
|
|
|
3
3
|
var react = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
|
|
6
|
-
function RedirectToAuth({
|
|
6
|
+
function RedirectToAuth({
|
|
7
|
+
baseUrl,
|
|
8
|
+
path,
|
|
9
|
+
afterSignInUrl
|
|
10
|
+
}) {
|
|
7
11
|
react.useEffect(() => {
|
|
8
|
-
const currentUrl = window.location.
|
|
12
|
+
const currentUrl = window.location.origin + afterSignInUrl;
|
|
9
13
|
const authUrl = new URL(path, baseUrl);
|
|
10
14
|
authUrl.searchParams.set("redirect", currentUrl);
|
|
11
15
|
window.location.replace(authUrl.toString());
|
|
12
|
-
}, [baseUrl, path]);
|
|
16
|
+
}, [baseUrl, path, afterSignInUrl]);
|
|
13
17
|
return null;
|
|
14
18
|
}
|
|
15
19
|
function getInsforgeRoutes(config) {
|
|
16
|
-
const { baseUrl, builtInAuth = true, paths = {} } = config;
|
|
17
|
-
const {
|
|
18
|
-
signIn = "/sign-in",
|
|
19
|
-
signUp = "/sign-up",
|
|
20
|
-
verifyEmail = "/verify-email",
|
|
21
|
-
forgotPassword = "/forgot-password",
|
|
22
|
-
resetPassword = "/reset-password"
|
|
23
|
-
} = paths;
|
|
20
|
+
const { baseUrl, builtInAuth = true, paths = {}, afterSignInUrl = "/" } = config;
|
|
21
|
+
const { signIn = "/sign-in", signUp = "/sign-up", forgotPassword = "/forgot-password" } = paths;
|
|
24
22
|
const routes = [];
|
|
25
23
|
if (builtInAuth) {
|
|
26
24
|
routes.push(
|
|
27
25
|
{
|
|
28
26
|
path: signIn,
|
|
29
|
-
element: /* @__PURE__ */ jsxRuntime.jsx(RedirectToAuth, { baseUrl, path: "/auth/sign-in" })
|
|
27
|
+
element: /* @__PURE__ */ jsxRuntime.jsx(RedirectToAuth, { baseUrl, path: "/auth/sign-in", afterSignInUrl })
|
|
30
28
|
},
|
|
31
29
|
{
|
|
32
30
|
path: signUp,
|
|
33
|
-
element: /* @__PURE__ */ jsxRuntime.jsx(RedirectToAuth, { baseUrl, path: "/auth/sign-up" })
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
path: verifyEmail,
|
|
37
|
-
element: /* @__PURE__ */ jsxRuntime.jsx(RedirectToAuth, { baseUrl, path: "/auth/verify-email" })
|
|
31
|
+
element: /* @__PURE__ */ jsxRuntime.jsx(RedirectToAuth, { baseUrl, path: "/auth/sign-up", afterSignInUrl })
|
|
38
32
|
},
|
|
39
33
|
{
|
|
40
34
|
path: forgotPassword,
|
|
41
35
|
element: /* @__PURE__ */ jsxRuntime.jsx(RedirectToAuth, { baseUrl, path: "/auth/forgot-password" })
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
path: resetPassword,
|
|
45
|
-
element: /* @__PURE__ */ jsxRuntime.jsx(RedirectToAuth, { baseUrl, path: "/auth/reset-password" })
|
|
46
36
|
}
|
|
47
37
|
);
|
|
48
38
|
}
|
package/dist/router.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/router/getInsforgeRoutes.tsx"],"names":["useEffect","jsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["../src/router/getInsforgeRoutes.tsx"],"names":["useEffect","jsx"],"mappings":";;;;;AA2CA,SAAS,cAAA,CAAe;AAAA,EACtB,OAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAA,EAIG;AACD,EAAAA,eAAA,CAAU,MAAM;AAEd,IAAA,MAAM,UAAA,GAAa,MAAA,CAAO,QAAA,CAAS,MAAA,GAAS,cAAA;AAC5C,IAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAI,IAAA,EAAM,OAAO,CAAA;AACrC,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,UAAA,EAAY,UAAU,CAAA;AAC/C,IAAA,MAAA,CAAO,QAAA,CAAS,OAAA,CAAQ,OAAA,CAAQ,QAAA,EAAU,CAAA;AAAA,EAC5C,CAAA,EAAG,CAAC,OAAA,EAAS,IAAA,EAAM,cAAc,CAAC,CAAA;AAElC,EAAA,OAAO,IAAA;AACT;AA6CO,SAAS,kBAAkB,MAAA,EAAgD;AAChF,EAAA,MAAM,EAAE,SAAS,WAAA,GAAc,IAAA,EAAM,QAAQ,EAAC,EAAG,cAAA,GAAiB,GAAA,EAAI,GAAI,MAAA;AAE1E,EAAA,MAAM,EAAE,MAAA,GAAS,UAAA,EAAY,SAAS,UAAA,EAAY,cAAA,GAAiB,oBAAmB,GAAI,KAAA;AAE1F,EAAA,MAAM,SAAwB,EAAC;AAG/B,EAAA,IAAI,WAAA,EAAa;AACf,IAAA,MAAA,CAAO,IAAA;AAAA,MACL;AAAA,QACE,IAAA,EAAM,MAAA;AAAA,QACN,yBACEC,cAAA,CAAC,cAAA,EAAA,EAAe,OAAA,EAAkB,IAAA,EAAK,iBAAgB,cAAA,EAAgC;AAAA,OAE3F;AAAA,MACA;AAAA,QACE,IAAA,EAAM,MAAA;AAAA,QACN,yBACEA,cAAA,CAAC,cAAA,EAAA,EAAe,OAAA,EAAkB,IAAA,EAAK,iBAAgB,cAAA,EAAgC;AAAA,OAE3F;AAAA,MACA;AAAA,QACE,IAAA,EAAM,cAAA;AAAA,QACN,OAAA,kBAASA,cAAA,CAAC,cAAA,EAAA,EAAe,OAAA,EAAkB,MAAK,uBAAA,EAAwB;AAAA;AAC1E,KACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"router.cjs","sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport type { RouteObject } from 'react-router-dom';\n\ninterface GetInsforgeRoutesConfig {\n /**\n * Base URL of your Insforge backend\n */\n baseUrl: string;\n\n /**\n * URL to redirect to after successful sign in (when token is detected in URL)\n * @default '/'\n */\n afterSignInUrl?: string;\n\n /**\n * Whether to use built-in auth (deployed Insforge Auth)\n * When true: redirects to baseUrl/auth/* pages\n * When false: no redirect routes are added (use your own components)\n * @default true\n */\n builtInAuth?: boolean;\n\n /**\n * Custom paths for auth redirect routes\n * @default {\n * signIn: '/sign-in',\n * signUp: '/sign-up',\n * forgotPassword: '/forgot-password',\n * }\n */\n paths?: {\n signIn?: string;\n signUp?: string;\n forgotPassword?: string;\n };\n}\n\n/**\n * Helper component for redirecting to external auth\n */\nfunction RedirectToAuth({\n baseUrl,\n path,\n afterSignInUrl,\n}: {\n baseUrl: string;\n path: string;\n afterSignInUrl?: string;\n}) {\n useEffect(() => {\n // Redirect back to current URL - middleware/SDK will handle token from URL\n const currentUrl = window.location.origin + afterSignInUrl;\n const authUrl = new URL(path, baseUrl);\n authUrl.searchParams.set('redirect', currentUrl);\n window.location.replace(authUrl.toString());\n }, [baseUrl, path, afterSignInUrl]);\n\n return null;\n}\n\n/**\n * Generates Insforge authentication redirect routes for React Router.\n *\n * Returns redirect routes for sign-in, sign-up, etc. that redirect to your deployed Insforge auth pages.\n *\n * @param config - Configuration for Insforge routes\n * @returns Array of RouteObject for React Router (redirect routes only)\n *\n * @example\n * ```tsx\n * import { createBrowserRouter } from 'react-router-dom';\n * import { getInsforgeRoutes } from '@insforge/react/router';\n *\n * const router = createBrowserRouter([\n * {\n * path: '/',\n * element: <Layout />,\n * children: [\n * { index: true, element: <Home /> },\n * { path: 'dashboard', element: <Dashboard /> }\n * ]\n * },\n * // Add redirect routes (sign-in, sign-up, etc.)\n * ...getInsforgeRoutes({\n * baseUrl: 'https://your-backend.com',\n * builtInAuth: true\n * })\n * ]);\n * ```\n *\n * @example\n * ```tsx\n * // Custom paths for redirect routes\n * ...getInsforgeRoutes({\n * baseUrl: 'https://your-backend.com',\n * builtInAuth: true,\n * paths: {\n * signIn: '/login',\n * signUp: '/register'\n * }\n * })\n * ```\n */\nexport function getInsforgeRoutes(config: GetInsforgeRoutesConfig): RouteObject[] {\n const { baseUrl, builtInAuth = true, paths = {}, afterSignInUrl = '/' } = config;\n\n const { signIn = '/sign-in', signUp = '/sign-up', forgotPassword = '/forgot-password' } = paths;\n\n const routes: RouteObject[] = [];\n\n // Only add redirect routes if using built-in auth\n if (builtInAuth) {\n routes.push(\n {\n path: signIn,\n element: (\n <RedirectToAuth baseUrl={baseUrl} path=\"/auth/sign-in\" afterSignInUrl={afterSignInUrl} />\n ),\n },\n {\n path: signUp,\n element: (\n <RedirectToAuth baseUrl={baseUrl} path=\"/auth/sign-up\" afterSignInUrl={afterSignInUrl} />\n ),\n },\n {\n path: forgotPassword,\n element: <RedirectToAuth baseUrl={baseUrl} path=\"/auth/forgot-password\" />,\n }\n );\n }\n\n return routes;\n}\n"]}
|
package/dist/router.d.cts
CHANGED
|
@@ -5,6 +5,11 @@ interface GetInsforgeRoutesConfig {
|
|
|
5
5
|
* Base URL of your Insforge backend
|
|
6
6
|
*/
|
|
7
7
|
baseUrl: string;
|
|
8
|
+
/**
|
|
9
|
+
* URL to redirect to after successful sign in (when token is detected in URL)
|
|
10
|
+
* @default '/'
|
|
11
|
+
*/
|
|
12
|
+
afterSignInUrl?: string;
|
|
8
13
|
/**
|
|
9
14
|
* Whether to use built-in auth (deployed Insforge Auth)
|
|
10
15
|
* When true: redirects to baseUrl/auth/* pages
|
|
@@ -17,17 +22,13 @@ interface GetInsforgeRoutesConfig {
|
|
|
17
22
|
* @default {
|
|
18
23
|
* signIn: '/sign-in',
|
|
19
24
|
* signUp: '/sign-up',
|
|
20
|
-
* verifyEmail: '/verify-email',
|
|
21
25
|
* forgotPassword: '/forgot-password',
|
|
22
|
-
* resetPassword: '/reset-password'
|
|
23
26
|
* }
|
|
24
27
|
*/
|
|
25
28
|
paths?: {
|
|
26
29
|
signIn?: string;
|
|
27
30
|
signUp?: string;
|
|
28
|
-
verifyEmail?: string;
|
|
29
31
|
forgotPassword?: string;
|
|
30
|
-
resetPassword?: string;
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
/**
|
package/dist/router.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ interface GetInsforgeRoutesConfig {
|
|
|
5
5
|
* Base URL of your Insforge backend
|
|
6
6
|
*/
|
|
7
7
|
baseUrl: string;
|
|
8
|
+
/**
|
|
9
|
+
* URL to redirect to after successful sign in (when token is detected in URL)
|
|
10
|
+
* @default '/'
|
|
11
|
+
*/
|
|
12
|
+
afterSignInUrl?: string;
|
|
8
13
|
/**
|
|
9
14
|
* Whether to use built-in auth (deployed Insforge Auth)
|
|
10
15
|
* When true: redirects to baseUrl/auth/* pages
|
|
@@ -17,17 +22,13 @@ interface GetInsforgeRoutesConfig {
|
|
|
17
22
|
* @default {
|
|
18
23
|
* signIn: '/sign-in',
|
|
19
24
|
* signUp: '/sign-up',
|
|
20
|
-
* verifyEmail: '/verify-email',
|
|
21
25
|
* forgotPassword: '/forgot-password',
|
|
22
|
-
* resetPassword: '/reset-password'
|
|
23
26
|
* }
|
|
24
27
|
*/
|
|
25
28
|
paths?: {
|
|
26
29
|
signIn?: string;
|
|
27
30
|
signUp?: string;
|
|
28
|
-
verifyEmail?: string;
|
|
29
31
|
forgotPassword?: string;
|
|
30
|
-
resetPassword?: string;
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
/**
|
package/dist/router.js
CHANGED
|
@@ -1,46 +1,36 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
|
-
function RedirectToAuth({
|
|
4
|
+
function RedirectToAuth({
|
|
5
|
+
baseUrl,
|
|
6
|
+
path,
|
|
7
|
+
afterSignInUrl
|
|
8
|
+
}) {
|
|
5
9
|
useEffect(() => {
|
|
6
|
-
const currentUrl = window.location.
|
|
10
|
+
const currentUrl = window.location.origin + afterSignInUrl;
|
|
7
11
|
const authUrl = new URL(path, baseUrl);
|
|
8
12
|
authUrl.searchParams.set("redirect", currentUrl);
|
|
9
13
|
window.location.replace(authUrl.toString());
|
|
10
|
-
}, [baseUrl, path]);
|
|
14
|
+
}, [baseUrl, path, afterSignInUrl]);
|
|
11
15
|
return null;
|
|
12
16
|
}
|
|
13
17
|
function getInsforgeRoutes(config) {
|
|
14
|
-
const { baseUrl, builtInAuth = true, paths = {} } = config;
|
|
15
|
-
const {
|
|
16
|
-
signIn = "/sign-in",
|
|
17
|
-
signUp = "/sign-up",
|
|
18
|
-
verifyEmail = "/verify-email",
|
|
19
|
-
forgotPassword = "/forgot-password",
|
|
20
|
-
resetPassword = "/reset-password"
|
|
21
|
-
} = paths;
|
|
18
|
+
const { baseUrl, builtInAuth = true, paths = {}, afterSignInUrl = "/" } = config;
|
|
19
|
+
const { signIn = "/sign-in", signUp = "/sign-up", forgotPassword = "/forgot-password" } = paths;
|
|
22
20
|
const routes = [];
|
|
23
21
|
if (builtInAuth) {
|
|
24
22
|
routes.push(
|
|
25
23
|
{
|
|
26
24
|
path: signIn,
|
|
27
|
-
element: /* @__PURE__ */ jsx(RedirectToAuth, { baseUrl, path: "/auth/sign-in" })
|
|
25
|
+
element: /* @__PURE__ */ jsx(RedirectToAuth, { baseUrl, path: "/auth/sign-in", afterSignInUrl })
|
|
28
26
|
},
|
|
29
27
|
{
|
|
30
28
|
path: signUp,
|
|
31
|
-
element: /* @__PURE__ */ jsx(RedirectToAuth, { baseUrl, path: "/auth/sign-up" })
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
path: verifyEmail,
|
|
35
|
-
element: /* @__PURE__ */ jsx(RedirectToAuth, { baseUrl, path: "/auth/verify-email" })
|
|
29
|
+
element: /* @__PURE__ */ jsx(RedirectToAuth, { baseUrl, path: "/auth/sign-up", afterSignInUrl })
|
|
36
30
|
},
|
|
37
31
|
{
|
|
38
32
|
path: forgotPassword,
|
|
39
33
|
element: /* @__PURE__ */ jsx(RedirectToAuth, { baseUrl, path: "/auth/forgot-password" })
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
path: resetPassword,
|
|
43
|
-
element: /* @__PURE__ */ jsx(RedirectToAuth, { baseUrl, path: "/auth/reset-password" })
|
|
44
34
|
}
|
|
45
35
|
);
|
|
46
36
|
}
|
package/dist/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/router/getInsforgeRoutes.tsx"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/router/getInsforgeRoutes.tsx"],"names":[],"mappings":";;;AA2CA,SAAS,cAAA,CAAe;AAAA,EACtB,OAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAA,EAIG;AACD,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,MAAM,UAAA,GAAa,MAAA,CAAO,QAAA,CAAS,MAAA,GAAS,cAAA;AAC5C,IAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAI,IAAA,EAAM,OAAO,CAAA;AACrC,IAAA,OAAA,CAAQ,YAAA,CAAa,GAAA,CAAI,UAAA,EAAY,UAAU,CAAA;AAC/C,IAAA,MAAA,CAAO,QAAA,CAAS,OAAA,CAAQ,OAAA,CAAQ,QAAA,EAAU,CAAA;AAAA,EAC5C,CAAA,EAAG,CAAC,OAAA,EAAS,IAAA,EAAM,cAAc,CAAC,CAAA;AAElC,EAAA,OAAO,IAAA;AACT;AA6CO,SAAS,kBAAkB,MAAA,EAAgD;AAChF,EAAA,MAAM,EAAE,SAAS,WAAA,GAAc,IAAA,EAAM,QAAQ,EAAC,EAAG,cAAA,GAAiB,GAAA,EAAI,GAAI,MAAA;AAE1E,EAAA,MAAM,EAAE,MAAA,GAAS,UAAA,EAAY,SAAS,UAAA,EAAY,cAAA,GAAiB,oBAAmB,GAAI,KAAA;AAE1F,EAAA,MAAM,SAAwB,EAAC;AAG/B,EAAA,IAAI,WAAA,EAAa;AACf,IAAA,MAAA,CAAO,IAAA;AAAA,MACL;AAAA,QACE,IAAA,EAAM,MAAA;AAAA,QACN,yBACE,GAAA,CAAC,cAAA,EAAA,EAAe,OAAA,EAAkB,IAAA,EAAK,iBAAgB,cAAA,EAAgC;AAAA,OAE3F;AAAA,MACA;AAAA,QACE,IAAA,EAAM,MAAA;AAAA,QACN,yBACE,GAAA,CAAC,cAAA,EAAA,EAAe,OAAA,EAAkB,IAAA,EAAK,iBAAgB,cAAA,EAAgC;AAAA,OAE3F;AAAA,MACA;AAAA,QACE,IAAA,EAAM,cAAA;AAAA,QACN,OAAA,kBAAS,GAAA,CAAC,cAAA,EAAA,EAAe,OAAA,EAAkB,MAAK,uBAAA,EAAwB;AAAA;AAC1E,KACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"router.js","sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport type { RouteObject } from 'react-router-dom';\n\ninterface GetInsforgeRoutesConfig {\n /**\n * Base URL of your Insforge backend\n */\n baseUrl: string;\n\n /**\n * URL to redirect to after successful sign in (when token is detected in URL)\n * @default '/'\n */\n afterSignInUrl?: string;\n\n /**\n * Whether to use built-in auth (deployed Insforge Auth)\n * When true: redirects to baseUrl/auth/* pages\n * When false: no redirect routes are added (use your own components)\n * @default true\n */\n builtInAuth?: boolean;\n\n /**\n * Custom paths for auth redirect routes\n * @default {\n * signIn: '/sign-in',\n * signUp: '/sign-up',\n * forgotPassword: '/forgot-password',\n * }\n */\n paths?: {\n signIn?: string;\n signUp?: string;\n forgotPassword?: string;\n };\n}\n\n/**\n * Helper component for redirecting to external auth\n */\nfunction RedirectToAuth({\n baseUrl,\n path,\n afterSignInUrl,\n}: {\n baseUrl: string;\n path: string;\n afterSignInUrl?: string;\n}) {\n useEffect(() => {\n // Redirect back to current URL - middleware/SDK will handle token from URL\n const currentUrl = window.location.origin + afterSignInUrl;\n const authUrl = new URL(path, baseUrl);\n authUrl.searchParams.set('redirect', currentUrl);\n window.location.replace(authUrl.toString());\n }, [baseUrl, path, afterSignInUrl]);\n\n return null;\n}\n\n/**\n * Generates Insforge authentication redirect routes for React Router.\n *\n * Returns redirect routes for sign-in, sign-up, etc. that redirect to your deployed Insforge auth pages.\n *\n * @param config - Configuration for Insforge routes\n * @returns Array of RouteObject for React Router (redirect routes only)\n *\n * @example\n * ```tsx\n * import { createBrowserRouter } from 'react-router-dom';\n * import { getInsforgeRoutes } from '@insforge/react/router';\n *\n * const router = createBrowserRouter([\n * {\n * path: '/',\n * element: <Layout />,\n * children: [\n * { index: true, element: <Home /> },\n * { path: 'dashboard', element: <Dashboard /> }\n * ]\n * },\n * // Add redirect routes (sign-in, sign-up, etc.)\n * ...getInsforgeRoutes({\n * baseUrl: 'https://your-backend.com',\n * builtInAuth: true\n * })\n * ]);\n * ```\n *\n * @example\n * ```tsx\n * // Custom paths for redirect routes\n * ...getInsforgeRoutes({\n * baseUrl: 'https://your-backend.com',\n * builtInAuth: true,\n * paths: {\n * signIn: '/login',\n * signUp: '/register'\n * }\n * })\n * ```\n */\nexport function getInsforgeRoutes(config: GetInsforgeRoutesConfig): RouteObject[] {\n const { baseUrl, builtInAuth = true, paths = {}, afterSignInUrl = '/' } = config;\n\n const { signIn = '/sign-in', signUp = '/sign-up', forgotPassword = '/forgot-password' } = paths;\n\n const routes: RouteObject[] = [];\n\n // Only add redirect routes if using built-in auth\n if (builtInAuth) {\n routes.push(\n {\n path: signIn,\n element: (\n <RedirectToAuth baseUrl={baseUrl} path=\"/auth/sign-in\" afterSignInUrl={afterSignInUrl} />\n ),\n },\n {\n path: signUp,\n element: (\n <RedirectToAuth baseUrl={baseUrl} path=\"/auth/sign-up\" afterSignInUrl={afterSignInUrl} />\n ),\n },\n {\n path: forgotPassword,\n element: <RedirectToAuth baseUrl={baseUrl} path=\"/auth/forgot-password\" />,\n }\n );\n }\n\n return routes;\n}\n"]}
|
package/dist/styles.css
CHANGED
|
@@ -469,27 +469,9 @@
|
|
|
469
469
|
/* ============================================
|
|
470
470
|
VERIFICATION CODE INPUT
|
|
471
471
|
============================================ */
|
|
472
|
-
.if-verificationCode {
|
|
473
|
-
display: flex;
|
|
474
|
-
flex-direction: column;
|
|
475
|
-
gap: var(--if-space-4);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
.if-verificationCode-description {
|
|
479
|
-
font-size: var(--if-font-size-sm);
|
|
480
|
-
color: var(--if-color-text-secondary);
|
|
481
|
-
text-align: center;
|
|
482
|
-
font-family: var(--if-font-family);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
.if-verificationCode-email {
|
|
486
|
-
font-weight: 600;
|
|
487
|
-
color: var(--if-color-text);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
472
|
.if-verificationCode-inputContainer {
|
|
491
473
|
display: flex;
|
|
492
|
-
gap: var(--if-space-
|
|
474
|
+
gap: var(--if-space-3);
|
|
493
475
|
justify-content: center;
|
|
494
476
|
}
|
|
495
477
|
|
|
@@ -497,12 +479,12 @@
|
|
|
497
479
|
width: 3rem;
|
|
498
480
|
height: 3rem;
|
|
499
481
|
text-align: center;
|
|
500
|
-
font-size: var(--if-font-size-
|
|
482
|
+
font-size: var(--if-font-size-base);
|
|
501
483
|
font-weight: 600;
|
|
502
|
-
border:
|
|
503
|
-
border-radius: var(--if-radius-
|
|
484
|
+
border: 1px solid var(--if-color-border);
|
|
485
|
+
border-radius: var(--if-radius-sm);
|
|
504
486
|
transition: border-color var(--if-transition-base);
|
|
505
|
-
font-family: var(--if-font-family);
|
|
487
|
+
font-family: var(--if-font-family-manrope);
|
|
506
488
|
}
|
|
507
489
|
|
|
508
490
|
.if-verificationCode-input:focus {
|
|
@@ -520,29 +502,51 @@
|
|
|
520
502
|
align-items: stretch;
|
|
521
503
|
}
|
|
522
504
|
|
|
523
|
-
.if-verificationStep-
|
|
505
|
+
.if-verificationStep-descriptionContainer {
|
|
506
|
+
width: 100%;
|
|
507
|
+
background-color: #f5f5f5;
|
|
508
|
+
border-radius: var(--if-radius-lg);
|
|
509
|
+
padding: var(--if-space-3) var(--if-space-3) var(--if-space-6) var(--if-space-3);
|
|
510
|
+
display: flex;
|
|
511
|
+
flex-direction: column;
|
|
512
|
+
gap: var(--if-space-3);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.if-verificationStep-descriptionTitle {
|
|
516
|
+
color: var(--black, #000);
|
|
517
|
+
font-family: var(--if-font-family);
|
|
518
|
+
font-size: var(--if-font-size-base);
|
|
519
|
+
font-style: normal;
|
|
520
|
+
font-weight: 600;
|
|
521
|
+
line-height: 24px;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.if-verificationStep-description,
|
|
525
|
+
.if-verificationStep-codeDescription {
|
|
524
526
|
font-size: var(--if-font-size-sm);
|
|
525
|
-
color:
|
|
526
|
-
text-align:
|
|
527
|
-
margin: 0;
|
|
527
|
+
color: #525252;
|
|
528
|
+
text-align: left;
|
|
528
529
|
font-family: var(--if-font-family);
|
|
530
|
+
margin: 0;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
.if-verificationLink-email,
|
|
534
|
+
.if-verificationCode-email {
|
|
535
|
+
font-weight: 500;
|
|
536
|
+
color: var(--if-color-text);
|
|
529
537
|
}
|
|
530
538
|
|
|
531
539
|
.if-verificationStep-codeContainer {
|
|
532
540
|
width: 100%;
|
|
533
|
-
background-color: #f5f5f5;
|
|
534
|
-
border-radius: var(--if-radius-lg);
|
|
535
|
-
padding: var(--if-space-4) var(--if-space-4) var(--if-space-6);
|
|
536
541
|
display: flex;
|
|
537
542
|
flex-direction: column;
|
|
538
|
-
gap:
|
|
543
|
+
gap: 40px;
|
|
539
544
|
}
|
|
540
545
|
|
|
541
546
|
.if-verificationStep-codeInputWrapper {
|
|
542
547
|
display: flex;
|
|
543
548
|
flex-direction: column;
|
|
544
|
-
gap: var(--if-space-
|
|
545
|
-
margin-top: var(--if-space-2);
|
|
549
|
+
gap: var(--if-space-6);
|
|
546
550
|
}
|
|
547
551
|
|
|
548
552
|
.if-verificationStep-verifyingText {
|
|
@@ -573,12 +577,10 @@
|
|
|
573
577
|
|
|
574
578
|
.if-verificationStep-resendButton:not(:disabled) {
|
|
575
579
|
cursor: pointer;
|
|
576
|
-
text-decoration: underline;
|
|
577
580
|
}
|
|
578
581
|
|
|
579
582
|
.if-verificationStep-resendButton:disabled {
|
|
580
583
|
cursor: not-allowed;
|
|
581
|
-
text-decoration: none;
|
|
582
584
|
opacity: 0.5;
|
|
583
585
|
}
|
|
584
586
|
|
|
@@ -589,14 +591,6 @@
|
|
|
589
591
|
margin-top: var(--if-space-2);
|
|
590
592
|
}
|
|
591
593
|
|
|
592
|
-
.if-passwordStrength-bar {
|
|
593
|
-
height: 4px;
|
|
594
|
-
background-color: #e5e7eb;
|
|
595
|
-
border-radius: 2px;
|
|
596
|
-
overflow: hidden;
|
|
597
|
-
margin-bottom: var(--if-space-2);
|
|
598
|
-
}
|
|
599
|
-
|
|
600
594
|
.if-passwordStrength-fill {
|
|
601
595
|
height: 100%;
|
|
602
596
|
transition:
|
|
@@ -604,21 +598,6 @@
|
|
|
604
598
|
background-color var(--if-transition-base);
|
|
605
599
|
}
|
|
606
600
|
|
|
607
|
-
.if-passwordStrength-fill.weak {
|
|
608
|
-
background-color: #ef4444;
|
|
609
|
-
width: 33%;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
.if-passwordStrength-fill.medium {
|
|
613
|
-
background-color: #f59e0b;
|
|
614
|
-
width: 66%;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
.if-passwordStrength-fill.strong {
|
|
618
|
-
background-color: var(--if-color-success);
|
|
619
|
-
width: 100%;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
601
|
.if-passwordStrength-text {
|
|
623
602
|
font-size: var(--if-font-size-xs);
|
|
624
603
|
color: var(--if-color-text-secondary);
|
|
@@ -626,17 +605,18 @@
|
|
|
626
605
|
}
|
|
627
606
|
|
|
628
607
|
.if-passwordStrength-requirements {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
608
|
+
display: flex;
|
|
609
|
+
flex-direction: column;
|
|
610
|
+
gap: var(--if-space-2);
|
|
611
|
+
font-size: var(--if-font-size-sm);
|
|
612
|
+
color: #525252;
|
|
632
613
|
font-family: var(--if-font-family);
|
|
633
614
|
}
|
|
634
615
|
|
|
635
616
|
.if-passwordStrength-requirement {
|
|
636
617
|
display: flex;
|
|
637
618
|
align-items: center;
|
|
638
|
-
gap: var(--if-space-
|
|
639
|
-
margin-bottom: var(--if-space-1);
|
|
619
|
+
gap: var(--if-space-2);
|
|
640
620
|
}
|
|
641
621
|
|
|
642
622
|
.if-passwordStrength-requirement.met {
|
package/package.json
CHANGED