@jskit-ai/auth-core 0.1.54 → 0.1.56
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 -3
- package/src/server/authPolicyContextResolverRegistry.js +5 -0
- package/src/server/providers/FastifyAuthPolicyServiceProvider.js +11 -27
- package/src/shared/commands/authCommandValidators.js +231 -191
- package/src/shared/commands/authDevLoginAsCommand.js +19 -19
- package/src/shared/commands/authLoginOAuthCompleteCommand.js +26 -31
- package/src/shared/commands/authLoginOAuthStartCommand.js +29 -34
- package/src/shared/commands/authLoginOtpRequestCommand.js +18 -23
- package/src/shared/commands/authLoginOtpVerifyCommand.js +29 -22
- package/src/shared/commands/authLoginPasswordCommand.js +18 -23
- package/src/shared/commands/authLogoutCommand.js +8 -7
- package/src/shared/commands/authPasswordRecoveryCompleteCommand.js +33 -23
- package/src/shared/commands/authPasswordResetCommand.js +16 -21
- package/src/shared/commands/authPasswordResetRequestCommand.js +16 -21
- package/src/shared/commands/authRegisterCommand.js +18 -23
- package/src/shared/commands/authRegisterConfirmationResendCommand.js +15 -20
- package/src/shared/commands/authSessionReadCommand.js +11 -10
- package/test/authPolicyContextResolverRegistry.test.js +39 -1
- package/test/commandValidators.test.js +68 -2
- package/test/providerRuntime.test.js +20 -8
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createSchema } from "json-rest-schema";
|
|
2
|
+
import { deepFreeze } from "@jskit-ai/kernel/shared/support/deepFreeze";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
authAccessTokenFieldDefinition,
|
|
5
|
+
authRecoveryTokenFieldDefinition,
|
|
6
|
+
authRefreshTokenFieldDefinition,
|
|
7
7
|
createCommandMessages,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
oauthCompleteOutputValidator,
|
|
9
|
+
oauthProviderFieldDefinition
|
|
10
10
|
} from "./authCommandValidators.js";
|
|
11
11
|
|
|
12
12
|
const AUTH_LOGIN_OAUTH_COMPLETE_MESSAGES = createCommandMessages({
|
|
@@ -27,41 +27,36 @@ const AUTH_LOGIN_OAUTH_COMPLETE_MESSAGES = createCommandMessages({
|
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
const authLoginOAuthCompleteBodyValidator =
|
|
31
|
-
schema:
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
additionalProperties: false
|
|
44
|
-
}
|
|
45
|
-
),
|
|
46
|
-
normalize: normalizeObjectInput,
|
|
30
|
+
const authLoginOAuthCompleteBodyValidator = deepFreeze({
|
|
31
|
+
schema: createSchema({
|
|
32
|
+
provider: { ...oauthProviderFieldDefinition, required: false },
|
|
33
|
+
code: { ...authRecoveryTokenFieldDefinition, required: false },
|
|
34
|
+
accessToken: { ...authAccessTokenFieldDefinition, required: false },
|
|
35
|
+
refreshToken: { ...authRefreshTokenFieldDefinition, required: false },
|
|
36
|
+
error: { type: "string", required: false, minLength: 1, maxLength: 128 },
|
|
37
|
+
errorDescription: { type: "string", required: false, minLength: 1, maxLength: 1024 },
|
|
38
|
+
error_code: { type: "string", required: false, minLength: 1, maxLength: 128 },
|
|
39
|
+
error_description: { type: "string", required: false, minLength: 1, maxLength: 1024 }
|
|
40
|
+
}),
|
|
41
|
+
mode: "patch",
|
|
47
42
|
messages: AUTH_LOGIN_OAUTH_COMPLETE_MESSAGES
|
|
48
43
|
});
|
|
49
44
|
|
|
50
|
-
const authLoginOAuthCompleteCommand =
|
|
45
|
+
const authLoginOAuthCompleteCommand = deepFreeze({
|
|
51
46
|
command: "auth.login.oauth.complete",
|
|
52
|
-
operation:
|
|
47
|
+
operation: {
|
|
53
48
|
method: "POST",
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
body: authLoginOAuthCompleteBodyValidator,
|
|
50
|
+
response: oauthCompleteOutputValidator,
|
|
56
51
|
messages: AUTH_LOGIN_OAUTH_COMPLETE_MESSAGES,
|
|
57
52
|
idempotent: false,
|
|
58
|
-
invalidates:
|
|
59
|
-
}
|
|
53
|
+
invalidates: ["auth.session.read"]
|
|
54
|
+
}
|
|
60
55
|
});
|
|
61
56
|
|
|
62
57
|
export {
|
|
63
58
|
authLoginOAuthCompleteBodyValidator,
|
|
64
|
-
|
|
59
|
+
oauthCompleteOutputValidator,
|
|
65
60
|
AUTH_LOGIN_OAUTH_COMPLETE_MESSAGES,
|
|
66
61
|
authLoginOAuthCompleteCommand
|
|
67
62
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createSchema } from "json-rest-schema";
|
|
2
|
+
import { deepFreeze } from "@jskit-ai/kernel/shared/support/deepFreeze";
|
|
3
3
|
import {
|
|
4
4
|
createCommandMessages,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
oauthProviderFieldDefinition,
|
|
6
|
+
oauthReturnToFieldDefinition
|
|
7
7
|
} from "./authCommandValidators.js";
|
|
8
8
|
|
|
9
9
|
const AUTH_LOGIN_OAUTH_START_MESSAGES = createCommandMessages({
|
|
@@ -20,53 +20,48 @@ const AUTH_LOGIN_OAUTH_START_MESSAGES = createCommandMessages({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const authLoginOAuthStartParamsValidator =
|
|
24
|
-
schema:
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
additionalProperties: false
|
|
30
|
-
}
|
|
31
|
-
),
|
|
32
|
-
normalize: normalizeObjectInput,
|
|
23
|
+
const authLoginOAuthStartParamsValidator = deepFreeze({
|
|
24
|
+
schema: createSchema({
|
|
25
|
+
provider: { ...oauthProviderFieldDefinition, required: true }
|
|
26
|
+
}),
|
|
27
|
+
mode: "patch",
|
|
33
28
|
messages: AUTH_LOGIN_OAUTH_START_MESSAGES
|
|
34
29
|
});
|
|
35
30
|
|
|
36
|
-
const authLoginOAuthStartQueryValidator =
|
|
37
|
-
schema:
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
additionalProperties: false
|
|
43
|
-
}
|
|
44
|
-
),
|
|
45
|
-
normalize: normalizeObjectInput,
|
|
31
|
+
const authLoginOAuthStartQueryValidator = deepFreeze({
|
|
32
|
+
schema: createSchema({
|
|
33
|
+
returnTo: { ...oauthReturnToFieldDefinition, required: false }
|
|
34
|
+
}),
|
|
35
|
+
mode: "patch",
|
|
46
36
|
messages: AUTH_LOGIN_OAUTH_START_MESSAGES
|
|
47
37
|
});
|
|
48
38
|
|
|
49
|
-
const
|
|
50
|
-
schema:
|
|
39
|
+
const authLoginOAuthStartOutputValidator = deepFreeze({
|
|
40
|
+
schema: createSchema({
|
|
41
|
+
provider: { ...oauthProviderFieldDefinition, required: true },
|
|
42
|
+
returnTo: { ...oauthReturnToFieldDefinition, required: true },
|
|
43
|
+
url: { type: "string", required: true, minLength: 1, maxLength: 4096 }
|
|
44
|
+
}),
|
|
45
|
+
mode: "replace"
|
|
51
46
|
});
|
|
52
47
|
|
|
53
|
-
const authLoginOAuthStartCommand =
|
|
48
|
+
const authLoginOAuthStartCommand = deepFreeze({
|
|
54
49
|
command: "auth.login.oauth.start",
|
|
55
|
-
operation:
|
|
50
|
+
operation: {
|
|
56
51
|
method: "GET",
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
params: authLoginOAuthStartParamsValidator,
|
|
53
|
+
query: authLoginOAuthStartQueryValidator,
|
|
54
|
+
response: authLoginOAuthStartOutputValidator,
|
|
60
55
|
messages: AUTH_LOGIN_OAUTH_START_MESSAGES,
|
|
61
56
|
idempotent: true,
|
|
62
|
-
invalidates:
|
|
63
|
-
}
|
|
57
|
+
invalidates: []
|
|
58
|
+
}
|
|
64
59
|
});
|
|
65
60
|
|
|
66
61
|
export {
|
|
67
62
|
authLoginOAuthStartParamsValidator,
|
|
68
63
|
authLoginOAuthStartQueryValidator,
|
|
69
|
-
|
|
64
|
+
authLoginOAuthStartOutputValidator,
|
|
70
65
|
AUTH_LOGIN_OAUTH_START_MESSAGES,
|
|
71
66
|
authLoginOAuthStartCommand
|
|
72
67
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createSchema } from "json-rest-schema";
|
|
2
|
+
import { deepFreeze } from "@jskit-ai/kernel/shared/support/deepFreeze";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
authEmailFieldDefinition,
|
|
5
5
|
createCommandMessages,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
oauthReturnToFieldDefinition,
|
|
7
|
+
okMessageOutputValidator
|
|
8
8
|
} from "./authCommandValidators.js";
|
|
9
9
|
|
|
10
10
|
const AUTH_LOGIN_OTP_REQUEST_MESSAGES = createCommandMessages({
|
|
@@ -22,35 +22,30 @@ const AUTH_LOGIN_OTP_REQUEST_MESSAGES = createCommandMessages({
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
const authLoginOtpRequestBodyValidator =
|
|
26
|
-
schema:
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
additionalProperties: false
|
|
33
|
-
}
|
|
34
|
-
),
|
|
35
|
-
normalize: normalizeObjectInput,
|
|
25
|
+
const authLoginOtpRequestBodyValidator = deepFreeze({
|
|
26
|
+
schema: createSchema({
|
|
27
|
+
email: { ...authEmailFieldDefinition, required: true },
|
|
28
|
+
returnTo: { ...oauthReturnToFieldDefinition, required: false }
|
|
29
|
+
}),
|
|
30
|
+
mode: "create",
|
|
36
31
|
messages: AUTH_LOGIN_OTP_REQUEST_MESSAGES
|
|
37
32
|
});
|
|
38
33
|
|
|
39
|
-
const authLoginOtpRequestCommand =
|
|
34
|
+
const authLoginOtpRequestCommand = deepFreeze({
|
|
40
35
|
command: "auth.login.otp.request",
|
|
41
|
-
operation:
|
|
36
|
+
operation: {
|
|
42
37
|
method: "POST",
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
body: authLoginOtpRequestBodyValidator,
|
|
39
|
+
response: okMessageOutputValidator,
|
|
45
40
|
messages: AUTH_LOGIN_OTP_REQUEST_MESSAGES,
|
|
46
41
|
idempotent: false,
|
|
47
|
-
invalidates:
|
|
48
|
-
}
|
|
42
|
+
invalidates: []
|
|
43
|
+
}
|
|
49
44
|
});
|
|
50
45
|
|
|
51
46
|
export {
|
|
52
47
|
authLoginOtpRequestBodyValidator,
|
|
53
|
-
|
|
48
|
+
okMessageOutputValidator,
|
|
54
49
|
AUTH_LOGIN_OTP_REQUEST_MESSAGES,
|
|
55
50
|
authLoginOtpRequestCommand
|
|
56
51
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createSchema } from "json-rest-schema";
|
|
2
|
+
import { deepFreeze } from "@jskit-ai/kernel/shared/support/deepFreeze";
|
|
3
3
|
import {
|
|
4
4
|
authEmailValidator,
|
|
5
5
|
authRecoveryTokenValidator,
|
|
6
6
|
createCommandMessages,
|
|
7
|
-
|
|
7
|
+
otpVerifyOutputValidator
|
|
8
8
|
} from "./authCommandValidators.js";
|
|
9
9
|
|
|
10
10
|
const AUTH_LOGIN_OTP_VERIFY_MESSAGES = createCommandMessages({
|
|
@@ -27,38 +27,45 @@ const AUTH_LOGIN_OTP_VERIFY_MESSAGES = createCommandMessages({
|
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
const authLoginOtpVerifyBodyValidator =
|
|
31
|
-
schema:
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const authLoginOtpVerifyBodyValidator = deepFreeze({
|
|
31
|
+
schema: createSchema({
|
|
32
|
+
email: {
|
|
33
|
+
...authEmailValidator,
|
|
34
|
+
required: false
|
|
35
|
+
},
|
|
36
|
+
token: {
|
|
37
|
+
...authRecoveryTokenValidator,
|
|
38
|
+
required: false
|
|
37
39
|
},
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
tokenHash: {
|
|
41
|
+
...authRecoveryTokenValidator,
|
|
42
|
+
required: false
|
|
43
|
+
},
|
|
44
|
+
type: {
|
|
45
|
+
type: "string",
|
|
46
|
+
required: false,
|
|
47
|
+
enum: ["email"]
|
|
41
48
|
}
|
|
42
|
-
),
|
|
43
|
-
|
|
49
|
+
}),
|
|
50
|
+
mode: "patch",
|
|
44
51
|
messages: AUTH_LOGIN_OTP_VERIFY_MESSAGES
|
|
45
52
|
});
|
|
46
53
|
|
|
47
|
-
const authLoginOtpVerifyCommand =
|
|
54
|
+
const authLoginOtpVerifyCommand = deepFreeze({
|
|
48
55
|
command: "auth.login.otp.verify",
|
|
49
|
-
operation:
|
|
56
|
+
operation: {
|
|
50
57
|
method: "POST",
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
body: authLoginOtpVerifyBodyValidator,
|
|
59
|
+
response: otpVerifyOutputValidator,
|
|
53
60
|
messages: AUTH_LOGIN_OTP_VERIFY_MESSAGES,
|
|
54
61
|
idempotent: false,
|
|
55
|
-
invalidates:
|
|
56
|
-
}
|
|
62
|
+
invalidates: ["auth.session.read"]
|
|
63
|
+
}
|
|
57
64
|
});
|
|
58
65
|
|
|
59
66
|
export {
|
|
60
67
|
authLoginOtpVerifyBodyValidator,
|
|
61
|
-
|
|
68
|
+
otpVerifyOutputValidator,
|
|
62
69
|
AUTH_LOGIN_OTP_VERIFY_MESSAGES,
|
|
63
70
|
authLoginOtpVerifyCommand
|
|
64
71
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createSchema } from "json-rest-schema";
|
|
2
|
+
import { deepFreeze } from "@jskit-ai/kernel/shared/support/deepFreeze";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
authEmailFieldDefinition,
|
|
5
|
+
authLoginPasswordFieldDefinition,
|
|
6
6
|
createCommandMessages,
|
|
7
|
-
|
|
7
|
+
loginOutputValidator
|
|
8
8
|
} from "./authCommandValidators.js";
|
|
9
9
|
|
|
10
10
|
const AUTH_LOGIN_PASSWORD_MESSAGES = createCommandMessages({
|
|
@@ -23,35 +23,30 @@ const AUTH_LOGIN_PASSWORD_MESSAGES = createCommandMessages({
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
const authLoginPasswordBodyValidator =
|
|
27
|
-
schema:
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
additionalProperties: false
|
|
34
|
-
}
|
|
35
|
-
),
|
|
36
|
-
normalize: normalizeObjectInput,
|
|
26
|
+
const authLoginPasswordBodyValidator = deepFreeze({
|
|
27
|
+
schema: createSchema({
|
|
28
|
+
email: { ...authEmailFieldDefinition, required: true },
|
|
29
|
+
password: { ...authLoginPasswordFieldDefinition, required: true }
|
|
30
|
+
}),
|
|
31
|
+
mode: "create",
|
|
37
32
|
messages: AUTH_LOGIN_PASSWORD_MESSAGES
|
|
38
33
|
});
|
|
39
34
|
|
|
40
|
-
const authLoginPasswordCommand =
|
|
35
|
+
const authLoginPasswordCommand = deepFreeze({
|
|
41
36
|
command: "auth.login.password",
|
|
42
|
-
operation:
|
|
37
|
+
operation: {
|
|
43
38
|
method: "POST",
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
body: authLoginPasswordBodyValidator,
|
|
40
|
+
response: loginOutputValidator,
|
|
46
41
|
messages: AUTH_LOGIN_PASSWORD_MESSAGES,
|
|
47
42
|
idempotent: false,
|
|
48
|
-
invalidates:
|
|
49
|
-
}
|
|
43
|
+
invalidates: ["auth.session.read"]
|
|
44
|
+
}
|
|
50
45
|
});
|
|
51
46
|
|
|
52
47
|
export {
|
|
53
48
|
authLoginPasswordBodyValidator,
|
|
54
|
-
|
|
49
|
+
loginOutputValidator,
|
|
55
50
|
AUTH_LOGIN_PASSWORD_MESSAGES,
|
|
56
51
|
authLoginPasswordCommand
|
|
57
52
|
};
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCommandMessages,
|
|
3
|
-
|
|
3
|
+
logoutOutputValidator
|
|
4
4
|
} from "./authCommandValidators.js";
|
|
5
|
+
import { deepFreeze } from "@jskit-ai/kernel/shared/support/deepFreeze";
|
|
5
6
|
|
|
6
7
|
const AUTH_LOGOUT_MESSAGES = createCommandMessages();
|
|
7
8
|
|
|
8
|
-
const authLogoutCommand =
|
|
9
|
+
const authLogoutCommand = deepFreeze({
|
|
9
10
|
command: "auth.logout",
|
|
10
|
-
operation:
|
|
11
|
+
operation: {
|
|
11
12
|
method: "POST",
|
|
12
|
-
|
|
13
|
+
response: logoutOutputValidator,
|
|
13
14
|
messages: AUTH_LOGOUT_MESSAGES,
|
|
14
15
|
idempotent: false,
|
|
15
|
-
invalidates:
|
|
16
|
-
}
|
|
16
|
+
invalidates: ["auth.session.read"]
|
|
17
|
+
}
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
+
logoutOutputValidator,
|
|
21
22
|
AUTH_LOGOUT_MESSAGES,
|
|
22
23
|
authLogoutCommand
|
|
23
24
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createSchema } from "json-rest-schema";
|
|
2
|
+
import { deepFreeze } from "@jskit-ai/kernel/shared/support/deepFreeze";
|
|
3
3
|
import {
|
|
4
4
|
authAccessTokenValidator,
|
|
5
5
|
authRecoveryTokenValidator,
|
|
6
6
|
authRefreshTokenValidator,
|
|
7
7
|
createCommandMessages,
|
|
8
|
-
|
|
8
|
+
okOutputValidator
|
|
9
9
|
} from "./authCommandValidators.js";
|
|
10
10
|
|
|
11
11
|
const AUTH_PASSWORD_RECOVERY_COMPLETE_MESSAGES = createCommandMessages({
|
|
@@ -29,39 +29,49 @@ const AUTH_PASSWORD_RECOVERY_COMPLETE_MESSAGES = createCommandMessages({
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
const authPasswordRecoveryCompleteBodyValidator =
|
|
33
|
-
schema:
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
const authPasswordRecoveryCompleteBodyValidator = deepFreeze({
|
|
33
|
+
schema: createSchema({
|
|
34
|
+
code: {
|
|
35
|
+
...authRecoveryTokenValidator,
|
|
36
|
+
required: false
|
|
37
|
+
},
|
|
38
|
+
tokenHash: {
|
|
39
|
+
...authRecoveryTokenValidator,
|
|
40
|
+
required: false
|
|
41
|
+
},
|
|
42
|
+
accessToken: {
|
|
43
|
+
...authAccessTokenValidator,
|
|
44
|
+
required: false
|
|
40
45
|
},
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
refreshToken: {
|
|
47
|
+
...authRefreshTokenValidator,
|
|
48
|
+
required: false
|
|
49
|
+
},
|
|
50
|
+
type: {
|
|
51
|
+
type: "string",
|
|
52
|
+
required: false,
|
|
53
|
+
enum: ["recovery"]
|
|
44
54
|
}
|
|
45
|
-
),
|
|
46
|
-
|
|
55
|
+
}),
|
|
56
|
+
mode: "patch",
|
|
47
57
|
messages: AUTH_PASSWORD_RECOVERY_COMPLETE_MESSAGES
|
|
48
58
|
});
|
|
49
59
|
|
|
50
|
-
const authPasswordRecoveryCompleteCommand =
|
|
60
|
+
const authPasswordRecoveryCompleteCommand = deepFreeze({
|
|
51
61
|
command: "auth.password.recovery.complete",
|
|
52
|
-
operation:
|
|
62
|
+
operation: {
|
|
53
63
|
method: "POST",
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
body: authPasswordRecoveryCompleteBodyValidator,
|
|
65
|
+
response: okOutputValidator,
|
|
56
66
|
messages: AUTH_PASSWORD_RECOVERY_COMPLETE_MESSAGES,
|
|
57
67
|
idempotent: false,
|
|
58
|
-
invalidates:
|
|
59
|
-
}
|
|
68
|
+
invalidates: ["auth.session.read"]
|
|
69
|
+
}
|
|
60
70
|
});
|
|
61
71
|
|
|
62
72
|
export {
|
|
63
73
|
authPasswordRecoveryCompleteBodyValidator,
|
|
64
|
-
|
|
74
|
+
okOutputValidator,
|
|
65
75
|
AUTH_PASSWORD_RECOVERY_COMPLETE_MESSAGES,
|
|
66
76
|
authPasswordRecoveryCompleteCommand
|
|
67
77
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createSchema } from "json-rest-schema";
|
|
2
|
+
import { deepFreeze } from "@jskit-ai/kernel/shared/support/deepFreeze";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
authPasswordFieldDefinition,
|
|
5
5
|
createCommandMessages,
|
|
6
|
-
|
|
6
|
+
okMessageOutputValidator
|
|
7
7
|
} from "./authCommandValidators.js";
|
|
8
8
|
|
|
9
9
|
const AUTH_PASSWORD_RESET_MESSAGES = createCommandMessages({
|
|
@@ -16,34 +16,29 @@ const AUTH_PASSWORD_RESET_MESSAGES = createCommandMessages({
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
const authPasswordResetBodyValidator =
|
|
20
|
-
schema:
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
additionalProperties: false
|
|
26
|
-
}
|
|
27
|
-
),
|
|
28
|
-
normalize: normalizeObjectInput,
|
|
19
|
+
const authPasswordResetBodyValidator = deepFreeze({
|
|
20
|
+
schema: createSchema({
|
|
21
|
+
password: { ...authPasswordFieldDefinition, required: true }
|
|
22
|
+
}),
|
|
23
|
+
mode: "create",
|
|
29
24
|
messages: AUTH_PASSWORD_RESET_MESSAGES
|
|
30
25
|
});
|
|
31
26
|
|
|
32
|
-
const authPasswordResetCommand =
|
|
27
|
+
const authPasswordResetCommand = deepFreeze({
|
|
33
28
|
command: "auth.password.reset",
|
|
34
|
-
operation:
|
|
29
|
+
operation: {
|
|
35
30
|
method: "POST",
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
body: authPasswordResetBodyValidator,
|
|
32
|
+
response: okMessageOutputValidator,
|
|
38
33
|
messages: AUTH_PASSWORD_RESET_MESSAGES,
|
|
39
34
|
idempotent: false,
|
|
40
|
-
invalidates:
|
|
41
|
-
}
|
|
35
|
+
invalidates: ["auth.session.read"]
|
|
36
|
+
}
|
|
42
37
|
});
|
|
43
38
|
|
|
44
39
|
export {
|
|
45
40
|
authPasswordResetBodyValidator,
|
|
46
|
-
|
|
41
|
+
okMessageOutputValidator,
|
|
47
42
|
AUTH_PASSWORD_RESET_MESSAGES,
|
|
48
43
|
authPasswordResetCommand
|
|
49
44
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createSchema } from "json-rest-schema";
|
|
2
|
+
import { deepFreeze } from "@jskit-ai/kernel/shared/support/deepFreeze";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
authEmailFieldDefinition,
|
|
5
5
|
createCommandMessages,
|
|
6
|
-
|
|
6
|
+
okMessageOutputValidator
|
|
7
7
|
} from "./authCommandValidators.js";
|
|
8
8
|
|
|
9
9
|
const AUTH_PASSWORD_RESET_REQUEST_MESSAGES = createCommandMessages({
|
|
@@ -17,34 +17,29 @@ const AUTH_PASSWORD_RESET_REQUEST_MESSAGES = createCommandMessages({
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
const authPasswordResetRequestBodyValidator =
|
|
21
|
-
schema:
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
additionalProperties: false
|
|
27
|
-
}
|
|
28
|
-
),
|
|
29
|
-
normalize: normalizeObjectInput,
|
|
20
|
+
const authPasswordResetRequestBodyValidator = deepFreeze({
|
|
21
|
+
schema: createSchema({
|
|
22
|
+
email: { ...authEmailFieldDefinition, required: true }
|
|
23
|
+
}),
|
|
24
|
+
mode: "create",
|
|
30
25
|
messages: AUTH_PASSWORD_RESET_REQUEST_MESSAGES
|
|
31
26
|
});
|
|
32
27
|
|
|
33
|
-
const authPasswordResetRequestCommand =
|
|
28
|
+
const authPasswordResetRequestCommand = deepFreeze({
|
|
34
29
|
command: "auth.password.reset.request",
|
|
35
|
-
operation:
|
|
30
|
+
operation: {
|
|
36
31
|
method: "POST",
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
body: authPasswordResetRequestBodyValidator,
|
|
33
|
+
response: okMessageOutputValidator,
|
|
39
34
|
messages: AUTH_PASSWORD_RESET_REQUEST_MESSAGES,
|
|
40
35
|
idempotent: false,
|
|
41
|
-
invalidates:
|
|
42
|
-
}
|
|
36
|
+
invalidates: []
|
|
37
|
+
}
|
|
43
38
|
});
|
|
44
39
|
|
|
45
40
|
export {
|
|
46
41
|
authPasswordResetRequestBodyValidator,
|
|
47
|
-
|
|
42
|
+
okMessageOutputValidator,
|
|
48
43
|
AUTH_PASSWORD_RESET_REQUEST_MESSAGES,
|
|
49
44
|
authPasswordResetRequestCommand
|
|
50
45
|
};
|