@jskit-ai/auth-core 0.1.45 → 0.1.47
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 +2 -2
- package/package.json +3 -2
- package/src/shared/authApi.js +3 -0
- package/src/shared/authPaths.js +1 -0
- package/src/shared/commands/authCommandValidators.js +15 -0
- package/src/shared/commands/authDevLoginAsCommand.js +57 -0
- package/src/shared/commands/index.js +1 -0
package/package.descriptor.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default Object.freeze({
|
|
2
2
|
"packageVersion": 1,
|
|
3
3
|
"packageId": "@jskit-ai/auth-core",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.47",
|
|
5
5
|
"kind": "runtime",
|
|
6
6
|
"dependsOn": [
|
|
7
7
|
"@jskit-ai/value-app-config-shared"
|
|
@@ -69,7 +69,7 @@ export default Object.freeze({
|
|
|
69
69
|
"mutations": {
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"runtime": {
|
|
72
|
-
"@jskit-ai/kernel": "0.1.
|
|
72
|
+
"@jskit-ai/kernel": "0.1.48",
|
|
73
73
|
"@fastify/cookie": "^11.0.2",
|
|
74
74
|
"@fastify/csrf-protection": "^7.1.0",
|
|
75
75
|
"@fastify/rate-limit": "^10.3.0"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/auth-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"./shared/commands/authLoginOtpVerifyCommand": "./src/shared/commands/authLoginOtpVerifyCommand.js",
|
|
37
37
|
"./shared/commands/authLoginOAuthStartCommand": "./src/shared/commands/authLoginOAuthStartCommand.js",
|
|
38
38
|
"./shared/commands/authLoginOAuthCompleteCommand": "./src/shared/commands/authLoginOAuthCompleteCommand.js",
|
|
39
|
+
"./shared/commands/authDevLoginAsCommand": "./src/shared/commands/authDevLoginAsCommand.js",
|
|
39
40
|
"./shared/commands/authPasswordResetRequestCommand": "./src/shared/commands/authPasswordResetRequestCommand.js",
|
|
40
41
|
"./shared/commands/authPasswordRecoveryCompleteCommand": "./src/shared/commands/authPasswordRecoveryCompleteCommand.js",
|
|
41
42
|
"./shared/commands/authPasswordResetCommand": "./src/shared/commands/authPasswordResetCommand.js",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"./shared/commands/authSessionReadCommand": "./src/shared/commands/authSessionReadCommand.js"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@jskit-ai/kernel": "0.1.
|
|
47
|
+
"@jskit-ai/kernel": "0.1.48",
|
|
47
48
|
"@fastify/cookie": "^11.0.2",
|
|
48
49
|
"@fastify/csrf-protection": "^7.1.0",
|
|
49
50
|
"@fastify/rate-limit": "^10.3.0",
|
package/src/shared/authApi.js
CHANGED
|
@@ -35,6 +35,9 @@ function createApi({ request }) {
|
|
|
35
35
|
oauthComplete(payload) {
|
|
36
36
|
return request(AUTH_PATHS.OAUTH_COMPLETE, { method: "POST", body: payload });
|
|
37
37
|
},
|
|
38
|
+
devLoginAs(payload) {
|
|
39
|
+
return request(AUTH_PATHS.DEV_LOGIN_AS, { method: "POST", body: payload });
|
|
40
|
+
},
|
|
38
41
|
requestPasswordReset(payload) {
|
|
39
42
|
return request(AUTH_PATHS.PASSWORD_FORGOT, { method: "POST", body: payload });
|
|
40
43
|
},
|
package/src/shared/authPaths.js
CHANGED
|
@@ -9,6 +9,7 @@ const AUTH_PATHS = Object.freeze({
|
|
|
9
9
|
PASSWORD_FORGOT: "/api/password/forgot",
|
|
10
10
|
PASSWORD_RECOVERY: "/api/password/recovery",
|
|
11
11
|
PASSWORD_RESET: "/api/password/reset",
|
|
12
|
+
DEV_LOGIN_AS: "/api/dev-auth/login-as",
|
|
12
13
|
LOGOUT: "/api/logout",
|
|
13
14
|
SESSION: "/api/session"
|
|
14
15
|
});
|
|
@@ -162,6 +162,20 @@ const oauthCompleteResponseValidator = Object.freeze({
|
|
|
162
162
|
)
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
+
const devLoginAsResponseValidator = Object.freeze({
|
|
166
|
+
schema: Type.Object(
|
|
167
|
+
{
|
|
168
|
+
ok: Type.Boolean(),
|
|
169
|
+
userId: Type.String({ minLength: 1 }),
|
|
170
|
+
username: Type.String({ minLength: 1, maxLength: 120 }),
|
|
171
|
+
email: authEmailValidator.schema
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
additionalProperties: false
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
});
|
|
178
|
+
|
|
165
179
|
const logoutResponseValidator = Object.freeze({
|
|
166
180
|
schema: Type.Object(
|
|
167
181
|
{
|
|
@@ -247,6 +261,7 @@ export {
|
|
|
247
261
|
loginResponseValidator,
|
|
248
262
|
otpVerifyResponseValidator,
|
|
249
263
|
oauthCompleteResponseValidator,
|
|
264
|
+
devLoginAsResponseValidator,
|
|
250
265
|
logoutResponseValidator,
|
|
251
266
|
oauthProviderCatalogEntryValidator,
|
|
252
267
|
sessionResponseValidator,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { recordIdInputSchema } from "@jskit-ai/kernel/shared/validators";
|
|
3
|
+
import { normalizeObjectInput } from "../inputNormalization.js";
|
|
4
|
+
import {
|
|
5
|
+
authEmailValidator,
|
|
6
|
+
createCommandMessages,
|
|
7
|
+
devLoginAsResponseValidator
|
|
8
|
+
} from "./authCommandValidators.js";
|
|
9
|
+
|
|
10
|
+
const AUTH_DEV_LOGIN_AS_MESSAGES = createCommandMessages({
|
|
11
|
+
fields: {
|
|
12
|
+
userId: {
|
|
13
|
+
pattern: "Provide a valid user id.",
|
|
14
|
+
default: "Provide a valid user id."
|
|
15
|
+
},
|
|
16
|
+
email: {
|
|
17
|
+
pattern: "Enter a valid email address.",
|
|
18
|
+
default: "Enter a valid email address."
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
defaultMessage: "Provide a valid user id or email."
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const authDevLoginAsBodyValidator = Object.freeze({
|
|
25
|
+
schema: Type.Object(
|
|
26
|
+
{
|
|
27
|
+
userId: Type.Optional(recordIdInputSchema),
|
|
28
|
+
email: Type.Optional(authEmailValidator.schema)
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
additionalProperties: false,
|
|
32
|
+
anyOf: [{ required: ["userId"] }, { required: ["email"] }]
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
normalize: normalizeObjectInput,
|
|
36
|
+
messages: {
|
|
37
|
+
...AUTH_DEV_LOGIN_AS_MESSAGES,
|
|
38
|
+
keywords: {
|
|
39
|
+
...AUTH_DEV_LOGIN_AS_MESSAGES.keywords,
|
|
40
|
+
anyOf: "Provide a user id or email."
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const authDevLoginAsCommand = Object.freeze({
|
|
46
|
+
command: "auth.dev.loginAs",
|
|
47
|
+
operation: Object.freeze({
|
|
48
|
+
method: "POST",
|
|
49
|
+
bodyValidator: authDevLoginAsBodyValidator,
|
|
50
|
+
responseValidator: devLoginAsResponseValidator,
|
|
51
|
+
messages: AUTH_DEV_LOGIN_AS_MESSAGES,
|
|
52
|
+
idempotent: false,
|
|
53
|
+
invalidates: Object.freeze(["auth.session.read"])
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export { AUTH_DEV_LOGIN_AS_MESSAGES, authDevLoginAsBodyValidator, authDevLoginAsCommand };
|
|
@@ -5,6 +5,7 @@ export { authLoginOtpRequestCommand } from "./authLoginOtpRequestCommand.js";
|
|
|
5
5
|
export { authLoginOtpVerifyCommand } from "./authLoginOtpVerifyCommand.js";
|
|
6
6
|
export { authLoginOAuthStartCommand } from "./authLoginOAuthStartCommand.js";
|
|
7
7
|
export { authLoginOAuthCompleteCommand } from "./authLoginOAuthCompleteCommand.js";
|
|
8
|
+
export { authDevLoginAsCommand } from "./authDevLoginAsCommand.js";
|
|
8
9
|
export { authPasswordResetRequestCommand } from "./authPasswordResetRequestCommand.js";
|
|
9
10
|
export { authPasswordRecoveryCompleteCommand } from "./authPasswordRecoveryCompleteCommand.js";
|
|
10
11
|
export { authPasswordResetCommand } from "./authPasswordResetCommand.js";
|