@bagelink/auth 1.6.53 → 1.6.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -219
- package/dist/Callback-BHqVaZZm.cjs +4 -0
- package/dist/Callback-C-XghN_z.js +4 -0
- package/dist/ForgotPasswordPage-BV9tyhHl.cjs +4 -0
- package/dist/ForgotPasswordPage-DvttMGb0.js +4 -0
- package/dist/LoginPage-hv1wc54S.cjs +4 -0
- package/dist/LoginPage-klj1NV4J.js +4 -0
- package/dist/ResetPasswordPage-COPrJmW8.cjs +4 -0
- package/dist/ResetPasswordPage-nvQ4uupb.js +4 -0
- package/dist/SignupPage-m36w9PLJ.cjs +4 -0
- package/dist/SignupPage-oUFYApYW.js +4 -0
- package/dist/api.d.ts +115 -0
- package/dist/components/auth/ForgotPasswordForm.vue.d.ts +23 -0
- package/dist/components/auth/LoginForm.vue.d.ts +58 -0
- package/dist/components/auth/ResetPasswordForm.vue.d.ts +28 -0
- package/dist/components/auth/SignupForm.vue.d.ts +34 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/constants.d.ts +34 -0
- package/dist/index.cjs +1227 -30
- package/dist/index.d.ts +16 -631
- package/dist/index.mjs +1242 -24
- package/dist/pages/Callback.vue.d.ts +2 -0
- package/dist/pages/ForgotPasswordPage.vue.d.ts +13 -0
- package/dist/pages/LoginPage.vue.d.ts +38 -0
- package/dist/pages/ResetPasswordPage.vue.d.ts +13 -0
- package/dist/pages/SignupPage.vue.d.ts +16 -0
- package/dist/routes.d.ts +49 -0
- package/dist/sso.d.ts +145 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types.d.ts +254 -0
- package/dist/useAuth.d.ts +112 -0
- package/dist/utils.d.ts +11 -0
- package/package.json +11 -13
- package/src/components/auth/ForgotPasswordForm.vue +97 -0
- package/src/components/auth/LoginForm.vue +257 -0
- package/src/components/auth/ResetPasswordForm.vue +146 -0
- package/src/components/auth/SignupForm.vue +224 -0
- package/src/components/index.ts +5 -0
- package/src/constants.ts +10 -0
- package/src/index.ts +26 -1
- package/src/pages/Callback.vue +183 -0
- package/src/pages/ForgotPasswordPage.vue +42 -0
- package/src/pages/LoginPage.vue +68 -0
- package/src/pages/ResetPasswordPage.vue +47 -0
- package/src/pages/SignupPage.vue +46 -0
- package/src/routes.ts +122 -0
- package/src/types/index.ts +45 -0
- package/dist/index.d.cts +0 -631
- package/dist/index.d.mts +0 -631
package/src/routes.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { RouteRecordRaw } from 'vue-router'
|
|
2
|
+
|
|
3
|
+
export interface AuthRouteConfig {
|
|
4
|
+
/** Base path for auth routes. Defaults to '/' */
|
|
5
|
+
basePath?: string
|
|
6
|
+
/** Route names prefix. Defaults to '' */
|
|
7
|
+
namePrefix?: string
|
|
8
|
+
/** Custom route names */
|
|
9
|
+
routeNames?: {
|
|
10
|
+
login?: string
|
|
11
|
+
signup?: string
|
|
12
|
+
forgotPassword?: string
|
|
13
|
+
resetPassword?: string
|
|
14
|
+
callback?: string
|
|
15
|
+
}
|
|
16
|
+
/** Redirect path after successful auth. Defaults to '/' */
|
|
17
|
+
redirectTo?: string
|
|
18
|
+
/** Custom layout wrapper component */
|
|
19
|
+
layout?: any
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates auth routes for Vue Router
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { createAuthRoutes } from '@bagelink/auth'
|
|
28
|
+
*
|
|
29
|
+
* const routes = [
|
|
30
|
+
* ...createAuthRoutes({
|
|
31
|
+
* basePath: '/auth',
|
|
32
|
+
* redirectTo: '/dashboard'
|
|
33
|
+
* }),
|
|
34
|
+
* // ... other routes
|
|
35
|
+
* ]
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function createAuthRoutes(config: AuthRouteConfig = {}): RouteRecordRaw[] {
|
|
39
|
+
const {
|
|
40
|
+
basePath = '',
|
|
41
|
+
namePrefix = '',
|
|
42
|
+
routeNames = {},
|
|
43
|
+
layout
|
|
44
|
+
} = config
|
|
45
|
+
|
|
46
|
+
const createRouteName = (name: string) => namePrefix ? `${namePrefix}${name}` : name
|
|
47
|
+
|
|
48
|
+
// Lazy load components
|
|
49
|
+
const routes: RouteRecordRaw[] = [
|
|
50
|
+
{
|
|
51
|
+
path: `${basePath}/login`,
|
|
52
|
+
name: routeNames.login || createRouteName('Login'),
|
|
53
|
+
component: () => import('./pages/LoginPage.vue'),
|
|
54
|
+
meta: { requiresAuth: false }
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
path: `${basePath}/signup`,
|
|
58
|
+
name: routeNames.signup || createRouteName('Signup'),
|
|
59
|
+
component: () => import('./pages/SignupPage.vue'),
|
|
60
|
+
meta: { requiresAuth: false }
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
path: `${basePath}/forgot-password`,
|
|
64
|
+
name: routeNames.forgotPassword || createRouteName('ForgotPassword'),
|
|
65
|
+
component: () => import('./pages/ForgotPasswordPage.vue'),
|
|
66
|
+
meta: { requiresAuth: false }
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
path: `${basePath}/reset-password`,
|
|
70
|
+
name: routeNames.resetPassword || createRouteName('ResetPassword'),
|
|
71
|
+
component: () => import('./pages/ResetPasswordPage.vue'),
|
|
72
|
+
meta: { requiresAuth: false }
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
path: `${basePath}/callback`,
|
|
76
|
+
name: routeNames.callback || createRouteName('AuthCallback'),
|
|
77
|
+
component: () => import('./pages/Callback.vue'),
|
|
78
|
+
meta: { requiresAuth: false }
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
// Wrap in layout if provided
|
|
83
|
+
if (layout) {
|
|
84
|
+
return [{
|
|
85
|
+
path: basePath,
|
|
86
|
+
component: layout,
|
|
87
|
+
children: routes.map(route => ({
|
|
88
|
+
...route,
|
|
89
|
+
path: route.path.replace(basePath, '')
|
|
90
|
+
}))
|
|
91
|
+
}]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return routes
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Creates a navigation guard to redirect authenticated users away from auth pages
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* import { createAuthGuard } from '@bagelink/auth'
|
|
103
|
+
*
|
|
104
|
+
* router.beforeEach(createAuthGuard({ redirectTo: '/dashboard' }))
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export function createAuthGuard(config: { redirectTo?: string } = {}) {
|
|
108
|
+
const { redirectTo = '/' } = config
|
|
109
|
+
|
|
110
|
+
return async (to: any, _from: any, next: any) => {
|
|
111
|
+
// Import dynamically to avoid circular dependencies
|
|
112
|
+
const { useAuth } = await import('./useAuth')
|
|
113
|
+
const { user } = useAuth()
|
|
114
|
+
|
|
115
|
+
// If route doesn't require auth and user is authenticated, redirect
|
|
116
|
+
if (to.meta.requiresAuth === false && user.value) {
|
|
117
|
+
next(redirectTo)
|
|
118
|
+
} else {
|
|
119
|
+
next()
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Auth form text customization types
|
|
2
|
+
export interface ForgotPasswordTexts {
|
|
3
|
+
title?: string
|
|
4
|
+
emailLabel?: string
|
|
5
|
+
submitButton?: string
|
|
6
|
+
backToLogin?: string
|
|
7
|
+
emailSentTitle?: string
|
|
8
|
+
emailSentMessage?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface LoginTexts {
|
|
12
|
+
title?: string
|
|
13
|
+
emailLabel?: string
|
|
14
|
+
passwordLabel?: string
|
|
15
|
+
forgotPassword?: string
|
|
16
|
+
submitButton?: string
|
|
17
|
+
noAccount?: string
|
|
18
|
+
signupLink?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ResetPasswordTexts {
|
|
22
|
+
title?: string
|
|
23
|
+
newPasswordLabel?: string
|
|
24
|
+
confirmPasswordLabel?: string
|
|
25
|
+
submitButton?: string
|
|
26
|
+
passwordStrength?: {
|
|
27
|
+
weak?: string
|
|
28
|
+
medium?: string
|
|
29
|
+
strong?: string
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface SignupTexts {
|
|
34
|
+
title?: string
|
|
35
|
+
emailLabel?: string
|
|
36
|
+
passwordLabel?: string
|
|
37
|
+
submitButton?: string
|
|
38
|
+
haveAccount?: string
|
|
39
|
+
loginLink?: string
|
|
40
|
+
passwordStrength?: {
|
|
41
|
+
weak?: string
|
|
42
|
+
medium?: string
|
|
43
|
+
strong?: string
|
|
44
|
+
}
|
|
45
|
+
}
|