@jskit-ai/auth-web 0.1.4
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/package.descriptor.mjs +290 -0
- package/package.json +29 -0
- package/src/client/composables/useDefaultLoginView.js +935 -0
- package/src/client/composables/useDefaultSignOutView.js +113 -0
- package/src/client/index.js +19 -0
- package/src/client/lib/returnToPath.js +20 -0
- package/src/client/lib/surfaceLinkTarget.js +19 -0
- package/src/client/providers/AuthWebClientProvider.js +72 -0
- package/src/client/runtime/authGuardRuntime.js +499 -0
- package/src/client/runtime/authHttpClient.js +19 -0
- package/src/client/runtime/inject.js +43 -0
- package/src/client/runtime/tokens.js +7 -0
- package/src/client/runtime/useLoginView.js +7 -0
- package/src/client/runtime/useSignOut.js +121 -0
- package/src/client/views/AuthProfileMenuLinkItem.vue +83 -0
- package/src/client/views/AuthProfileWidget.vue +100 -0
- package/src/client/views/DefaultLoginView.vue +291 -0
- package/src/client/views/DefaultSignOutView.vue +58 -0
- package/src/server/constants/authActionIds.js +15 -0
- package/src/server/controllers/AuthController.js +183 -0
- package/src/server/providers/AuthRouteServiceProvider.js +31 -0
- package/src/server/providers/AuthWebServiceProvider.js +23 -0
- package/src/server/routes/authRoutes.js +244 -0
- package/src/server/services/AuthWebService.js +126 -0
- package/templates/src/pages/auth/login.vue +17 -0
- package/templates/src/pages/auth/signout.vue +17 -0
- package/templates/src/runtime/authGuardRuntime.js +7 -0
- package/templates/src/runtime/authHttpClient.js +1 -0
- package/templates/src/runtime/useSignOut.js +1 -0
- package/templates/src/views/auth/LoginView.vue +7 -0
- package/templates/src/views/auth/SignOutView.vue +7 -0
- package/test/authGuardRuntime.test.js +361 -0
- package/test/clientBoot.test.js +16 -0
- package/test/clientSurface.test.js +89 -0
- package/test/index.test.js +21 -0
- package/test/logoutFallback.test.js +50 -0
- package/test/providerRuntime.test.js +100 -0
- package/test/returnToPath.test.js +72 -0
- package/test/surfaceLinkTarget.test.js +80 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
export default Object.freeze({
|
|
2
|
+
"packageVersion": 1,
|
|
3
|
+
"packageId": "@jskit-ai/auth-web",
|
|
4
|
+
"version": "0.1.4",
|
|
5
|
+
"description": "Auth web module: Fastify auth routes plus web login/sign-out scaffolds.",
|
|
6
|
+
"dependsOn": [
|
|
7
|
+
"@jskit-ai/auth-core",
|
|
8
|
+
"@jskit-ai/http-runtime",
|
|
9
|
+
"@jskit-ai/shell-web",
|
|
10
|
+
"@jskit-ai/value-app-config-shared"
|
|
11
|
+
],
|
|
12
|
+
"capabilities": {
|
|
13
|
+
"provides": [
|
|
14
|
+
"auth.server-routes",
|
|
15
|
+
"auth.web-login"
|
|
16
|
+
],
|
|
17
|
+
"requires": [
|
|
18
|
+
"auth.access",
|
|
19
|
+
"auth.provider",
|
|
20
|
+
"validators.http",
|
|
21
|
+
"auth.policy",
|
|
22
|
+
"runtime.web-placement"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"runtime": {
|
|
26
|
+
"server": {
|
|
27
|
+
"providerEntrypoint": "src/server/providers/AuthWebServiceProvider.js",
|
|
28
|
+
"providers": [
|
|
29
|
+
{
|
|
30
|
+
"entrypoint": "src/server/providers/AuthWebServiceProvider.js",
|
|
31
|
+
"export": "AuthWebServiceProvider"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"entrypoint": "src/server/providers/AuthRouteServiceProvider.js",
|
|
35
|
+
"export": "AuthRouteServiceProvider"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"client": {
|
|
40
|
+
"providers": [
|
|
41
|
+
{
|
|
42
|
+
"entrypoint": "src/client/providers/AuthWebClientProvider.js",
|
|
43
|
+
"export": "AuthWebClientProvider"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"metadata": {
|
|
49
|
+
"apiSummary": {
|
|
50
|
+
"surfaces": [
|
|
51
|
+
{
|
|
52
|
+
"subpath": "./client",
|
|
53
|
+
"summary": "Exports auth web client provider, default auth views, and route/provider registration surface."
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"subpath": "./server",
|
|
57
|
+
"summary": "Exports auth web server providers, controller/service classes, route builders, and HTTP schema modules."
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"containerTokens": {
|
|
61
|
+
"server": [
|
|
62
|
+
"auth.web.service"
|
|
63
|
+
],
|
|
64
|
+
"client": [
|
|
65
|
+
"runtime.auth-guard.client",
|
|
66
|
+
"auth.login.component",
|
|
67
|
+
"auth.login.useLoginView",
|
|
68
|
+
"auth.web.profile.widget",
|
|
69
|
+
"auth.web.profile.menu.link-item"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"server": {
|
|
74
|
+
"routes": [
|
|
75
|
+
{
|
|
76
|
+
"method": "POST",
|
|
77
|
+
"path": "/api/login",
|
|
78
|
+
"summary": "Log in with configured credentials"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"method": "POST",
|
|
82
|
+
"path": "/api/login/otp/request",
|
|
83
|
+
"summary": "Request one-time email login code"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"method": "POST",
|
|
87
|
+
"path": "/api/login/otp/verify",
|
|
88
|
+
"summary": "Verify one-time email login code and create session"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"method": "POST",
|
|
92
|
+
"path": "/api/logout",
|
|
93
|
+
"summary": "Log out and clear session cookies"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"method": "GET",
|
|
97
|
+
"path": "/api/oauth/:provider/start",
|
|
98
|
+
"summary": "Start OAuth login with configured provider"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"method": "POST",
|
|
102
|
+
"path": "/api/oauth/complete",
|
|
103
|
+
"summary": "Complete OAuth code exchange and set session cookies"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"method": "POST",
|
|
107
|
+
"path": "/api/password/forgot",
|
|
108
|
+
"summary": "Request a password reset email"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"method": "POST",
|
|
112
|
+
"path": "/api/password/recovery",
|
|
113
|
+
"summary": "Complete password recovery link exchange"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"method": "POST",
|
|
117
|
+
"path": "/api/password/reset",
|
|
118
|
+
"summary": "Set a new password for authenticated recovery session"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"method": "POST",
|
|
122
|
+
"path": "/api/register",
|
|
123
|
+
"summary": "Register a new user"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"method": "GET",
|
|
127
|
+
"path": "/api/session",
|
|
128
|
+
"summary": "Get current session status and CSRF token"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
"ui": {
|
|
133
|
+
"routes": [
|
|
134
|
+
{
|
|
135
|
+
"id": "auth.login",
|
|
136
|
+
"path": "/auth/login",
|
|
137
|
+
"scope": "surface",
|
|
138
|
+
"surface": "auth",
|
|
139
|
+
"name": "auth-login",
|
|
140
|
+
"componentKey": "auth-login",
|
|
141
|
+
"autoRegister": false,
|
|
142
|
+
"guard": {
|
|
143
|
+
"policy": "public"
|
|
144
|
+
},
|
|
145
|
+
"purpose": "Public login route for authentication flows."
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"id": "auth.signout",
|
|
149
|
+
"path": "/auth/signout",
|
|
150
|
+
"scope": "surface",
|
|
151
|
+
"surface": "auth",
|
|
152
|
+
"name": "auth-signout",
|
|
153
|
+
"componentKey": "auth-signout",
|
|
154
|
+
"autoRegister": false,
|
|
155
|
+
"guard": {
|
|
156
|
+
"policy": "public"
|
|
157
|
+
},
|
|
158
|
+
"purpose": "Public sign-out route that clears session then returns to login."
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"id": "auth.default-login",
|
|
162
|
+
"path": "/auth/default-login",
|
|
163
|
+
"scope": "surface",
|
|
164
|
+
"surface": "auth",
|
|
165
|
+
"name": "auth-default-login",
|
|
166
|
+
"componentKey": "auth-default-login",
|
|
167
|
+
"autoRegister": true,
|
|
168
|
+
"guard": {
|
|
169
|
+
"policy": "public"
|
|
170
|
+
},
|
|
171
|
+
"purpose": "Default module-supplied login screen."
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"elements": [],
|
|
175
|
+
"overrides": [],
|
|
176
|
+
"placements": {
|
|
177
|
+
"outlets": [
|
|
178
|
+
{
|
|
179
|
+
"host": "auth-profile-menu",
|
|
180
|
+
"position": "primary-menu",
|
|
181
|
+
"surfaces": ["*"],
|
|
182
|
+
"source": "src/client/views/AuthProfileWidget.vue"
|
|
183
|
+
}
|
|
184
|
+
],
|
|
185
|
+
"contributions": [
|
|
186
|
+
{
|
|
187
|
+
"id": "auth.profile.widget",
|
|
188
|
+
"host": "shell-layout",
|
|
189
|
+
"position": "top-right",
|
|
190
|
+
"surfaces": ["*"],
|
|
191
|
+
"order": 1000,
|
|
192
|
+
"componentToken": "auth.web.profile.widget",
|
|
193
|
+
"source": "mutations.text#auth-web-placement-block"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"id": "auth.profile.menu.sign-in",
|
|
197
|
+
"host": "auth-profile-menu",
|
|
198
|
+
"position": "primary-menu",
|
|
199
|
+
"surfaces": ["*"],
|
|
200
|
+
"order": 200,
|
|
201
|
+
"componentToken": "auth.web.profile.menu.link-item",
|
|
202
|
+
"when": "auth.authenticated !== true",
|
|
203
|
+
"source": "mutations.text#auth-web-placement-block"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"id": "auth.profile.menu.sign-out",
|
|
207
|
+
"host": "auth-profile-menu",
|
|
208
|
+
"position": "primary-menu",
|
|
209
|
+
"surfaces": ["*"],
|
|
210
|
+
"order": 1000,
|
|
211
|
+
"componentToken": "auth.web.profile.menu.link-item",
|
|
212
|
+
"when": "auth.authenticated === true",
|
|
213
|
+
"source": "mutations.text#auth-web-placement-block"
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"mutations": {
|
|
220
|
+
"dependencies": {
|
|
221
|
+
"runtime": {
|
|
222
|
+
"@tanstack/vue-query": "^5.90.5",
|
|
223
|
+
"@mdi/js": "^7.4.47",
|
|
224
|
+
"@fastify/type-provider-typebox": "^6.1.0",
|
|
225
|
+
"@jskit-ai/auth-core": "0.1.4",
|
|
226
|
+
"@jskit-ai/http-runtime": "0.1.4",
|
|
227
|
+
"@jskit-ai/kernel": "0.1.4",
|
|
228
|
+
"@jskit-ai/shell-web": "0.1.4",
|
|
229
|
+
"vuetify": "^4.0.0"
|
|
230
|
+
},
|
|
231
|
+
"dev": {}
|
|
232
|
+
},
|
|
233
|
+
"packageJson": {
|
|
234
|
+
"scripts": {}
|
|
235
|
+
},
|
|
236
|
+
"procfile": {},
|
|
237
|
+
"files": [
|
|
238
|
+
{
|
|
239
|
+
"from": "templates/src/views/auth/LoginView.vue",
|
|
240
|
+
"to": "src/views/auth/LoginView.vue",
|
|
241
|
+
"reason": "Install minimal login container that renders the module-provided DefaultLoginView by default.",
|
|
242
|
+
"category": "auth-web",
|
|
243
|
+
"id": "auth-view-login"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"from": "templates/src/views/auth/SignOutView.vue",
|
|
247
|
+
"to": "src/views/auth/SignOutView.vue",
|
|
248
|
+
"reason": "Install minimal sign-out container that renders the module-provided SignOutView by default (edit the scaffolded file to customize).",
|
|
249
|
+
"category": "auth-web",
|
|
250
|
+
"id": "auth-view-signout"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"from": "templates/src/pages/auth/login.vue",
|
|
254
|
+
"to": "src/pages/auth/login.vue",
|
|
255
|
+
"reason": "Provide an auth-surface /auth/login wrapper that renders the package login view.",
|
|
256
|
+
"category": "auth-web",
|
|
257
|
+
"id": "auth-page-login"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"from": "templates/src/pages/auth/signout.vue",
|
|
261
|
+
"to": "src/pages/auth/signout.vue",
|
|
262
|
+
"reason": "Provide an auth-surface /auth/signout wrapper that renders the package sign-out view.",
|
|
263
|
+
"category": "auth-web",
|
|
264
|
+
"id": "auth-page-signout"
|
|
265
|
+
}
|
|
266
|
+
],
|
|
267
|
+
"text": [
|
|
268
|
+
{
|
|
269
|
+
"op": "append-text",
|
|
270
|
+
"file": "config/public.js",
|
|
271
|
+
"position": "bottom",
|
|
272
|
+
"skipIfContains": "config.surfaceDefinitions.auth = {",
|
|
273
|
+
"value": "\nconfig.surfaceDefinitions.auth = {\n id: \"auth\",\n label: \"Auth\",\n pagesRoot: \"auth\",\n enabled: true,\n requiresAuth: false,\n requiresWorkspace: false,\n origin: \"\"\n};\n",
|
|
274
|
+
"reason": "Register auth surface definition in public surface config.",
|
|
275
|
+
"category": "auth-web",
|
|
276
|
+
"id": "auth-web-surface-config-auth"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"op": "append-text",
|
|
280
|
+
"file": "src/placement.js",
|
|
281
|
+
"position": "bottom",
|
|
282
|
+
"skipIfContains": "id: \"auth.profile.widget\"",
|
|
283
|
+
"value": "\naddPlacement({\n id: \"auth.profile.widget\",\n host: \"shell-layout\",\n position: \"top-right\",\n surfaces: [\"*\"],\n order: 1000,\n componentToken: \"auth.web.profile.widget\"\n});\n\naddPlacement({\n id: \"auth.profile.menu.sign-in\",\n host: \"auth-profile-menu\",\n position: \"primary-menu\",\n surfaces: [\"*\"],\n order: 200,\n componentToken: \"auth.web.profile.menu.link-item\",\n props: {\n label: \"Sign in\",\n to: \"/auth/login\"\n },\n when: ({ auth }) => !Boolean(auth?.authenticated)\n});\n\naddPlacement({\n id: \"auth.profile.menu.sign-out\",\n host: \"auth-profile-menu\",\n position: \"primary-menu\",\n surfaces: [\"*\"],\n order: 1000,\n componentToken: \"auth.web.profile.menu.link-item\",\n props: {\n label: \"Sign out\",\n to: \"/auth/signout\"\n },\n when: ({ auth }) => Boolean(auth?.authenticated)\n});\n",
|
|
284
|
+
"reason": "Append auth profile placement entries into app-owned placement registry.",
|
|
285
|
+
"category": "auth-web",
|
|
286
|
+
"id": "auth-web-placement-block"
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jskit-ai/auth-web",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "node --test"
|
|
7
|
+
},
|
|
8
|
+
"exports": {
|
|
9
|
+
"./server/controllers/AuthController": "./src/server/controllers/AuthController.js",
|
|
10
|
+
"./server/services/AuthWebService": "./src/server/services/AuthWebService.js",
|
|
11
|
+
"./server/routes/authRoutes": "./src/server/routes/authRoutes.js",
|
|
12
|
+
"./client": "./src/client/index.js",
|
|
13
|
+
"./client/views/DefaultLoginView": "./src/client/views/DefaultLoginView.vue",
|
|
14
|
+
"./client/views/DefaultSignOutView": "./src/client/views/DefaultSignOutView.vue",
|
|
15
|
+
"./client/runtime/authGuardRuntime": "./src/client/runtime/authGuardRuntime.js",
|
|
16
|
+
"./client/runtime/authHttpClient": "./src/client/runtime/authHttpClient.js",
|
|
17
|
+
"./client/runtime/useSignOut": "./src/client/runtime/useSignOut.js"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@tanstack/vue-query": "^5.90.5",
|
|
21
|
+
"@jskit-ai/auth-core": "0.1.4",
|
|
22
|
+
"@mdi/js": "^7.4.47",
|
|
23
|
+
"@fastify/type-provider-typebox": "^6.1.0",
|
|
24
|
+
"@jskit-ai/kernel": "0.1.4",
|
|
25
|
+
"@jskit-ai/shell-web": "0.1.4",
|
|
26
|
+
"vuetify": "^4.0.0",
|
|
27
|
+
"@jskit-ai/http-runtime": "0.1.4"
|
|
28
|
+
}
|
|
29
|
+
}
|