@jskit-ai/auth-web 0.1.251 → 0.2.1
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/CHANGELOG.md +103 -0
- package/locales/en.json +116 -0
- package/package.json +7 -6
- package/src/client/composables/loginView/constants.js +14 -16
- package/src/client/composables/loginView/oauthCallbackUrl.js +2 -0
- package/src/client/composables/loginView/registerCompletion.js +3 -2
- package/src/client/composables/loginView/rememberedAccountStorage.js +3 -1
- package/src/client/composables/loginView/useLoginViewActions.js +38 -33
- package/src/client/composables/loginView/useLoginViewState.js +17 -8
- package/src/client/composables/loginView/useLoginViewValidation.js +4 -1
- package/src/client/composables/loginView/validationHelpers.js +11 -14
- package/src/client/composables/useDefaultSignOutView.js +3 -1
- package/src/client/i18n.js +6 -0
- package/src/client/runtime/inactiveSessionMessage.js +12 -0
- package/src/client/runtime/oauthCallbackRuntime.js +28 -11
- package/src/client/runtime/popupOAuthLaunchClient.js +3 -1
- package/src/client/runtime/useSignOut.js +3 -2
- package/src/client/views/AuthProfileMenuLinkItem.vue +5 -2
- package/src/client/views/AuthProfileWidget.vue +3 -1
- package/src/client/views/DefaultLoginView.vue +32 -20
- package/src/client/views/DefaultResetPasswordView.vue +13 -9
- package/src/client/views/DefaultSignOutView.vue +7 -5
- package/src/server/controllers/AuthController.js +16 -4
- package/test/i18nCatalog.test.js +16 -0
- package/test/loginViewActions.test.js +14 -0
- package/test/oauthCallbackRuntime.test.js +30 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 - 2026-10-29
|
|
4
|
+
|
|
5
|
+
- Translation ready: every user-visible text is a message key with its English in `locales/en.json`, so an app translates it by supplying translation files only. With no translations, texts and behaviour are unchanged. See the guide "Translating a JSKIT app".
|
|
6
|
+
- Sign-in, registration, password reset, sign-out, OAuth and the profile menu are translated.
|
|
7
|
+
|
|
8
|
+
### New message keys (80)
|
|
9
|
+
|
|
10
|
+
All keys in `locales/en.json` (exported as `./locales/en.json`) are new in this version.
|
|
11
|
+
|
|
12
|
+
<details><summary>Key list</summary>
|
|
13
|
+
|
|
14
|
+
- `jskit.auth.register.confirmEmail`
|
|
15
|
+
- `jskit.auth.login.title.register`
|
|
16
|
+
- `jskit.auth.login.title.forgot`
|
|
17
|
+
- `jskit.auth.login.title.otp`
|
|
18
|
+
- `jskit.auth.login.title.confirmEmail`
|
|
19
|
+
- `jskit.auth.login.subtitle.register`
|
|
20
|
+
- `jskit.auth.login.subtitle.forgot`
|
|
21
|
+
- `jskit.auth.login.subtitle.otp`
|
|
22
|
+
- `jskit.auth.login.subtitle.confirmEmailSentTo`
|
|
23
|
+
- `jskit.auth.login.subtitle.confirmEmailInbox`
|
|
24
|
+
- `jskit.auth.login.submit.login`
|
|
25
|
+
- `jskit.auth.login.submit.register`
|
|
26
|
+
- `jskit.auth.login.submit.forgot`
|
|
27
|
+
- `jskit.auth.login.submit.otp`
|
|
28
|
+
- `jskit.auth.login.submit.confirmEmail`
|
|
29
|
+
- `jskit.auth.login.mode.signIn`
|
|
30
|
+
- `jskit.auth.login.mode.register`
|
|
31
|
+
- `jskit.auth.login.field.email`
|
|
32
|
+
- `jskit.auth.login.field.password`
|
|
33
|
+
- `jskit.auth.login.field.confirmPassword`
|
|
34
|
+
- `jskit.auth.login.field.otpCode`
|
|
35
|
+
- `jskit.auth.login.confirmEmail.message`
|
|
36
|
+
- `jskit.auth.login.confirmEmail.goToMainScreen`
|
|
37
|
+
- `jskit.auth.login.confirmEmail.resend`
|
|
38
|
+
- `jskit.auth.login.confirmEmail.resent`
|
|
39
|
+
- `jskit.auth.login.rememberedAccount.welcomeBack`
|
|
40
|
+
- `jskit.auth.login.rememberedAccount.fallbackName`
|
|
41
|
+
- `jskit.auth.login.rememberedAccount.defaultName`
|
|
42
|
+
- `jskit.auth.login.rememberedAccount.switch`
|
|
43
|
+
- `jskit.auth.login.rememberedAccount.rememberDevice`
|
|
44
|
+
- `jskit.auth.login.oauth.register`
|
|
45
|
+
- `jskit.auth.login.oauth.continue`
|
|
46
|
+
- `jskit.auth.login.oauth.continueAs`
|
|
47
|
+
- `jskit.auth.login.oauth.providerFallback`
|
|
48
|
+
- `jskit.auth.login.forgotPassword`
|
|
49
|
+
- `jskit.auth.login.useOtp`
|
|
50
|
+
- `jskit.auth.login.sendOtp`
|
|
51
|
+
- `jskit.auth.login.backToSignIn`
|
|
52
|
+
- `jskit.auth.login.hasAccount`
|
|
53
|
+
- `jskit.auth.login.rememberedPassword`
|
|
54
|
+
- `jskit.auth.login.otherMethod`
|
|
55
|
+
- `jskit.auth.login.passwordsMismatch`
|
|
56
|
+
- `jskit.auth.login.resetSent`
|
|
57
|
+
- `jskit.auth.login.otpSent`
|
|
58
|
+
- `jskit.auth.login.error.sessionNotActive`
|
|
59
|
+
- `jskit.auth.login.error.authFailed`
|
|
60
|
+
- `jskit.auth.login.error.registerFailed`
|
|
61
|
+
- `jskit.auth.login.error.resetRequestFailed`
|
|
62
|
+
- `jskit.auth.login.error.otpVerifyFailed`
|
|
63
|
+
- `jskit.auth.login.error.signInFailed`
|
|
64
|
+
- `jskit.auth.login.error.otpRequestFailed`
|
|
65
|
+
- `jskit.auth.login.error.emailRequiredForConfirmation`
|
|
66
|
+
- `jskit.auth.login.error.resendConfirmationFailed`
|
|
67
|
+
- `jskit.auth.login.error.oauthCompleteFailed`
|
|
68
|
+
- `jskit.auth.login.error.oauthProviderInvalid`
|
|
69
|
+
- `jskit.auth.login.error.oauthReturnToInvalid`
|
|
70
|
+
- `jskit.auth.login.error.oauthStartFailed`
|
|
71
|
+
- `jskit.auth.login.error.oauthLaunchUnavailable`
|
|
72
|
+
- `jskit.auth.login.error.initializeFailed`
|
|
73
|
+
- `jskit.auth.oauth.providerMissing`
|
|
74
|
+
- `jskit.auth.oauth.invalidCallback`
|
|
75
|
+
- `jskit.auth.oauth.popupBlocked`
|
|
76
|
+
- `jskit.auth.resetPassword.title`
|
|
77
|
+
- `jskit.auth.resetPassword.done`
|
|
78
|
+
- `jskit.auth.resetPassword.newPassword`
|
|
79
|
+
- `jskit.auth.resetPassword.confirmPassword`
|
|
80
|
+
- `jskit.auth.resetPassword.submit`
|
|
81
|
+
- `jskit.auth.resetPassword.backToSignIn`
|
|
82
|
+
- `jskit.auth.resetPassword.passwordsMustMatch`
|
|
83
|
+
- `jskit.auth.resetPassword.recoveryInvalid`
|
|
84
|
+
- `jskit.auth.resetPassword.updateFailed`
|
|
85
|
+
- `jskit.auth.signOut.title`
|
|
86
|
+
- `jskit.auth.signOut.pending`
|
|
87
|
+
- `jskit.auth.signOut.failedTryAgain`
|
|
88
|
+
- `jskit.auth.signOut.failed`
|
|
89
|
+
- `jskit.auth.signOut.retry`
|
|
90
|
+
- `jskit.auth.signOut.goToLogin`
|
|
91
|
+
- `jskit.auth.signOut.sessionStillActive`
|
|
92
|
+
- `jskit.auth.signOut.serverSessionActive`
|
|
93
|
+
- `jskit.auth.profile.guest`
|
|
94
|
+
|
|
95
|
+
</details>
|
|
96
|
+
|
|
97
|
+
### Codes (1)
|
|
98
|
+
|
|
99
|
+
Error, field-error and message codes this package sends, with their English. Undotted codes kept their existing values and render from `jskit.errors.<code>`.
|
|
100
|
+
|
|
101
|
+
| Code | English |
|
|
102
|
+
| --- | --- |
|
|
103
|
+
| `auth.register.confirmEmail` | Check your email to confirm the account before logging in. |
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jskit": {
|
|
3
|
+
"auth": {
|
|
4
|
+
"register": {
|
|
5
|
+
"confirmEmail": "Check your email to confirm the account before logging in."
|
|
6
|
+
},
|
|
7
|
+
"login": {
|
|
8
|
+
"title": {
|
|
9
|
+
"register": "Create your account",
|
|
10
|
+
"forgot": "Reset your password",
|
|
11
|
+
"otp": "Use one-time code",
|
|
12
|
+
"confirmEmail": "Confirm your email"
|
|
13
|
+
},
|
|
14
|
+
"subtitle": {
|
|
15
|
+
"register": "Register to access your workspace.",
|
|
16
|
+
"forgot": "We will send password reset instructions to your email.",
|
|
17
|
+
"otp": "Request a one-time login code and verify it below.",
|
|
18
|
+
"confirmEmailSentTo": "Open the confirmation link sent to {email} to finish signing in.",
|
|
19
|
+
"confirmEmailInbox": "Open the confirmation link from your inbox to finish signing in."
|
|
20
|
+
},
|
|
21
|
+
"submit": {
|
|
22
|
+
"login": "Sign in",
|
|
23
|
+
"register": "Register",
|
|
24
|
+
"forgot": "Send reset instructions",
|
|
25
|
+
"otp": "Verify code",
|
|
26
|
+
"confirmEmail": "Continue"
|
|
27
|
+
},
|
|
28
|
+
"mode": {
|
|
29
|
+
"signIn": "Sign in",
|
|
30
|
+
"register": "Register"
|
|
31
|
+
},
|
|
32
|
+
"field": {
|
|
33
|
+
"email": "Email",
|
|
34
|
+
"password": "Password",
|
|
35
|
+
"confirmPassword": "Confirm password",
|
|
36
|
+
"otpCode": "One-time code"
|
|
37
|
+
},
|
|
38
|
+
"confirmEmail": {
|
|
39
|
+
"message": "Please confirm your email address. After confirmation, you can sign in.",
|
|
40
|
+
"goToMainScreen": "Go to main screen",
|
|
41
|
+
"resend": "Resend confirmation email",
|
|
42
|
+
"resent": "If an account exists for that email, a confirmation email has been sent."
|
|
43
|
+
},
|
|
44
|
+
"rememberedAccount": {
|
|
45
|
+
"welcomeBack": "Welcome back, {name}",
|
|
46
|
+
"fallbackName": "your account",
|
|
47
|
+
"defaultName": "User",
|
|
48
|
+
"switch": "Use another account",
|
|
49
|
+
"rememberDevice": "Remember this account on this device"
|
|
50
|
+
},
|
|
51
|
+
"oauth": {
|
|
52
|
+
"register": "Register with {provider}",
|
|
53
|
+
"continue": "Continue with {provider}",
|
|
54
|
+
"continueAs": "Continue with {provider} as {name}",
|
|
55
|
+
"providerFallback": "OAuth provider"
|
|
56
|
+
},
|
|
57
|
+
"forgotPassword": "Forgot password?",
|
|
58
|
+
"useOtp": "Use one-time code",
|
|
59
|
+
"sendOtp": "Send one-time code",
|
|
60
|
+
"backToSignIn": "Back to sign in",
|
|
61
|
+
"hasAccount": "Already have an account?",
|
|
62
|
+
"rememberedPassword": "Remembered your password?",
|
|
63
|
+
"otherMethod": "Want to use another method?",
|
|
64
|
+
"passwordsMismatch": "Passwords do not match.",
|
|
65
|
+
"resetSent": "Password reset instructions sent.",
|
|
66
|
+
"otpSent": "One-time code sent. Check your inbox.",
|
|
67
|
+
"error": {
|
|
68
|
+
"sessionNotActive": "Login succeeded but the session is not active yet. Please retry.",
|
|
69
|
+
"authFailed": "Authentication failed.",
|
|
70
|
+
"registerFailed": "Unable to register.",
|
|
71
|
+
"resetRequestFailed": "Unable to request password reset.",
|
|
72
|
+
"otpVerifyFailed": "Unable to verify one-time code.",
|
|
73
|
+
"signInFailed": "Unable to sign in.",
|
|
74
|
+
"otpRequestFailed": "Unable to request one-time code.",
|
|
75
|
+
"emailRequiredForConfirmation": "Enter an email address before requesting confirmation.",
|
|
76
|
+
"resendConfirmationFailed": "Unable to resend confirmation email.",
|
|
77
|
+
"oauthCompleteFailed": "Unable to complete OAuth sign-in.",
|
|
78
|
+
"oauthProviderInvalid": "OAuth provider id is invalid.",
|
|
79
|
+
"oauthReturnToInvalid": "OAuth return path is invalid.",
|
|
80
|
+
"oauthStartFailed": "Unable to start OAuth sign-in.",
|
|
81
|
+
"oauthLaunchUnavailable": "OAuth launch client is unavailable.",
|
|
82
|
+
"initializeFailed": "Unable to initialize sign in."
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"oauth": {
|
|
86
|
+
"providerMissing": "OAuth provider is missing from callback.",
|
|
87
|
+
"invalidCallback": "Invalid OAuth callback payload.",
|
|
88
|
+
"popupBlocked": "Your browser blocked the sign-in window. Allow pop-ups for this page, then try again."
|
|
89
|
+
},
|
|
90
|
+
"resetPassword": {
|
|
91
|
+
"title": "Reset password",
|
|
92
|
+
"done": "Password updated. Sign in with your new password.",
|
|
93
|
+
"newPassword": "New password",
|
|
94
|
+
"confirmPassword": "Confirm password",
|
|
95
|
+
"submit": "Update password",
|
|
96
|
+
"backToSignIn": "Back to sign in",
|
|
97
|
+
"passwordsMustMatch": "Passwords must match.",
|
|
98
|
+
"recoveryInvalid": "Recovery link is invalid or expired.",
|
|
99
|
+
"updateFailed": "Unable to update password."
|
|
100
|
+
},
|
|
101
|
+
"signOut": {
|
|
102
|
+
"title": "Signing you out",
|
|
103
|
+
"pending": "Please wait while we end your session.",
|
|
104
|
+
"failedTryAgain": "Sign out failed. Please try again.",
|
|
105
|
+
"failed": "Sign out failed.",
|
|
106
|
+
"retry": "Retry sign out",
|
|
107
|
+
"goToLogin": "Go to login",
|
|
108
|
+
"sessionStillActive": "Sign out did not complete because the session is still authenticated.",
|
|
109
|
+
"serverSessionActive": "Logout did not terminate the server session."
|
|
110
|
+
},
|
|
111
|
+
"profile": {
|
|
112
|
+
"guest": "Guest"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/auth-web",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test --test-concurrency=1"
|
|
@@ -19,16 +19,17 @@
|
|
|
19
19
|
"./client/runtime/authHttpClient": "./src/client/runtime/authHttpClient.js",
|
|
20
20
|
"./client/runtime/oauthCallbackRuntime": "./src/client/runtime/oauthCallbackRuntime.js",
|
|
21
21
|
"./client/runtime/useSignOut": "./src/client/runtime/useSignOut.js",
|
|
22
|
-
"./test/playwright": "./src/test/playwright.js"
|
|
22
|
+
"./test/playwright": "./src/test/playwright.js",
|
|
23
|
+
"./locales/en.json": "./locales/en.json"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@mdi/js": "^7.4.47"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
|
-
"@jskit-ai/auth-core": "0.1
|
|
29
|
-
"@jskit-ai/http-runtime": "0.1
|
|
30
|
-
"@jskit-ai/kernel": "0.1
|
|
31
|
-
"@jskit-ai/shell-web": "0.1
|
|
29
|
+
"@jskit-ai/auth-core": "0.2.1",
|
|
30
|
+
"@jskit-ai/http-runtime": "0.2.1",
|
|
31
|
+
"@jskit-ai/kernel": "0.2.1",
|
|
32
|
+
"@jskit-ai/shell-web": "0.2.1",
|
|
32
33
|
"@tanstack/vue-query": "^5.90.5",
|
|
33
34
|
"pinia": "^4.0.3",
|
|
34
35
|
"vue": "^3.5.44",
|
|
@@ -4,31 +4,30 @@ const FORGOT_MODE = "forgot";
|
|
|
4
4
|
const OTP_MODE = "otp";
|
|
5
5
|
const EMAIL_CONFIRMATION_MODE = "confirm-email";
|
|
6
6
|
|
|
7
|
+
// Message keys per mode; an empty entry shows nothing.
|
|
7
8
|
const AUTH_TITLE_BY_MODE = Object.freeze({
|
|
8
9
|
[LOGIN_MODE]: "",
|
|
9
|
-
[REGISTER_MODE]: "
|
|
10
|
-
[FORGOT_MODE]: "
|
|
11
|
-
[OTP_MODE]: "
|
|
12
|
-
[EMAIL_CONFIRMATION_MODE]: "
|
|
10
|
+
[REGISTER_MODE]: "jskit.auth.login.title.register",
|
|
11
|
+
[FORGOT_MODE]: "jskit.auth.login.title.forgot",
|
|
12
|
+
[OTP_MODE]: "jskit.auth.login.title.otp",
|
|
13
|
+
[EMAIL_CONFIRMATION_MODE]: "jskit.auth.login.title.confirmEmail"
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
const AUTH_SUBTITLE_BY_MODE = Object.freeze({
|
|
16
17
|
[LOGIN_MODE]: "",
|
|
17
|
-
[REGISTER_MODE]: "
|
|
18
|
-
[FORGOT_MODE]: "
|
|
19
|
-
[OTP_MODE]: "
|
|
18
|
+
[REGISTER_MODE]: "jskit.auth.login.subtitle.register",
|
|
19
|
+
[FORGOT_MODE]: "jskit.auth.login.subtitle.forgot",
|
|
20
|
+
[OTP_MODE]: "jskit.auth.login.subtitle.otp"
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
const SUBMIT_LABEL_BY_MODE = Object.freeze({
|
|
23
|
-
[LOGIN_MODE]: "
|
|
24
|
-
[REGISTER_MODE]: "
|
|
25
|
-
[FORGOT_MODE]: "
|
|
26
|
-
[OTP_MODE]: "
|
|
27
|
-
[EMAIL_CONFIRMATION_MODE]: "
|
|
24
|
+
[LOGIN_MODE]: "jskit.auth.login.submit.login",
|
|
25
|
+
[REGISTER_MODE]: "jskit.auth.login.submit.register",
|
|
26
|
+
[FORGOT_MODE]: "jskit.auth.login.submit.forgot",
|
|
27
|
+
[OTP_MODE]: "jskit.auth.login.submit.otp",
|
|
28
|
+
[EMAIL_CONFIRMATION_MODE]: "jskit.auth.login.submit.confirmEmail"
|
|
28
29
|
});
|
|
29
30
|
|
|
30
|
-
const DEFAULT_REGISTER_CONFIRMATION_MESSAGE = "Check your email to confirm the account before logging in.";
|
|
31
|
-
|
|
32
31
|
export {
|
|
33
32
|
LOGIN_MODE,
|
|
34
33
|
REGISTER_MODE,
|
|
@@ -37,6 +36,5 @@ export {
|
|
|
37
36
|
EMAIL_CONFIRMATION_MODE,
|
|
38
37
|
AUTH_TITLE_BY_MODE,
|
|
39
38
|
AUTH_SUBTITLE_BY_MODE,
|
|
40
|
-
SUBMIT_LABEL_BY_MODE
|
|
41
|
-
DEFAULT_REGISTER_CONFIRMATION_MESSAGE
|
|
39
|
+
SUBMIT_LABEL_BY_MODE
|
|
42
40
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useJskitText } from "../../i18n.js";
|
|
2
2
|
|
|
3
3
|
function resolveRegisterCompletionState(registerResult) {
|
|
4
4
|
if (registerResult?.requiresEmailConfirmation === true) {
|
|
5
|
-
const
|
|
5
|
+
const { serverMessage, t } = useJskitText();
|
|
6
|
+
const message = serverMessage(registerResult).trim() || t("jskit.auth.register.confirmEmail");
|
|
6
7
|
return {
|
|
7
8
|
shouldCompleteLogin: false,
|
|
8
9
|
message
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeEmailAddress, maskEmail } from "./identityHelpers.js";
|
|
2
|
+
import { useJskitText } from "../../i18n.js";
|
|
2
3
|
|
|
3
4
|
function resolveLocalStorage() {
|
|
4
5
|
if (typeof window === "undefined" || !window.localStorage) {
|
|
@@ -21,7 +22,8 @@ function createRememberedAccountHint({ email: accountEmail, displayName, maskedE
|
|
|
21
22
|
return null;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
const normalizedDisplayName = String(displayName || "").trim() || normalizedEmail.split("@")[0] ||
|
|
25
|
+
const normalizedDisplayName = String(displayName || "").trim() || normalizedEmail.split("@")[0] ||
|
|
26
|
+
useJskitText().t("jskit.auth.login.rememberedAccount.defaultName");
|
|
25
27
|
const normalizedMaskedEmail =
|
|
26
28
|
normalizedEmail.includes("@") && !maskedEmail ? maskEmail(normalizedEmail) : String(maskedEmail || "").trim();
|
|
27
29
|
|
|
@@ -7,7 +7,6 @@ import { authLoginOtpVerifyCommand } from "@jskit-ai/auth-core/shared/commands/a
|
|
|
7
7
|
import { authLoginOAuthStartCommand } from "@jskit-ai/auth-core/shared/commands/authLoginOAuthStartCommand";
|
|
8
8
|
import { authPasswordResetRequestCommand } from "@jskit-ai/auth-core/shared/commands/authPasswordResetRequestCommand";
|
|
9
9
|
import { AUTH_PATHS, buildAuthOauthStartPath } from "@jskit-ai/auth-core/shared/authPaths";
|
|
10
|
-
import { resolveAuthDeniedLoginMessage } from "@jskit-ai/auth-core/shared/authDenied";
|
|
11
10
|
import { authHttpRequest } from "../../runtime/authHttpClient.js";
|
|
12
11
|
import { completeOAuthCallbackFromCurrentLocation } from "../../runtime/oauthCallbackRuntime.js";
|
|
13
12
|
import { normalizeAuthReturnToPath } from "../../lib/returnToPath.js";
|
|
@@ -17,6 +16,8 @@ import { stripOAuthParamsFromLocation } from "./oauthCallbackUrl.js";
|
|
|
17
16
|
import { completeOAuthPopupSignIn } from "../../runtime/popupOAuthLaunchClient.js";
|
|
18
17
|
import { ensureCommandSectionValid } from "./validationHelpers.js";
|
|
19
18
|
import { resolveRegisterCompletionState } from "./registerCompletion.js";
|
|
19
|
+
import { inactiveSessionMessage } from "../../runtime/inactiveSessionMessage.js";
|
|
20
|
+
import { useJskitText } from "../../i18n.js";
|
|
20
21
|
|
|
21
22
|
const SESSION_QUERY_KEY = Object.freeze(["auth-web", "session"]);
|
|
22
23
|
|
|
@@ -27,6 +28,8 @@ export function useLoginViewActions({
|
|
|
27
28
|
errorRuntime,
|
|
28
29
|
oauthLaunchClient = null
|
|
29
30
|
} = {}) {
|
|
31
|
+
const { serverMessage, t } = useJskitText();
|
|
32
|
+
|
|
30
33
|
function reportAuthFeedback({
|
|
31
34
|
message,
|
|
32
35
|
severity = "error",
|
|
@@ -145,11 +148,7 @@ export function useLoginViewActions({
|
|
|
145
148
|
async function completeLogin() {
|
|
146
149
|
const session = await refreshSession();
|
|
147
150
|
if (!session?.authenticated) {
|
|
148
|
-
|
|
149
|
-
if (authDeniedMessage) {
|
|
150
|
-
throw new Error(authDeniedMessage);
|
|
151
|
-
}
|
|
152
|
-
throw new Error("Login succeeded but the session is not active yet. Please retry.");
|
|
151
|
+
throw new Error(inactiveSessionMessage(session));
|
|
153
152
|
}
|
|
154
153
|
if (typeof window === "object" && window.location) {
|
|
155
154
|
window.location.replace(state.requestedReturnTo.value);
|
|
@@ -168,7 +167,7 @@ export function useLoginViewActions({
|
|
|
168
167
|
source: "workspace-invite"
|
|
169
168
|
};
|
|
170
169
|
}
|
|
171
|
-
ensureCommandSectionValid(authRegisterCommand, "body", registerPayload, "
|
|
170
|
+
ensureCommandSectionValid(authRegisterCommand, "body", registerPayload, t("jskit.auth.login.error.registerFailed"));
|
|
172
171
|
|
|
173
172
|
const registerResult = await request(AUTH_PATHS.REGISTER, {
|
|
174
173
|
method: "POST",
|
|
@@ -198,14 +197,14 @@ export function useLoginViewActions({
|
|
|
198
197
|
authPasswordResetRequestCommand,
|
|
199
198
|
"body",
|
|
200
199
|
forgotPayload,
|
|
201
|
-
"
|
|
200
|
+
t("jskit.auth.login.error.resetRequestFailed")
|
|
202
201
|
);
|
|
203
202
|
|
|
204
203
|
await request(AUTH_PATHS.PASSWORD_FORGOT, {
|
|
205
204
|
method: "POST",
|
|
206
205
|
body: forgotPayload
|
|
207
206
|
});
|
|
208
|
-
setInfoMessage("
|
|
207
|
+
setInfoMessage(t("jskit.auth.login.resetSent"), "auth-web.default-login-view:password-reset-sent");
|
|
209
208
|
}
|
|
210
209
|
|
|
211
210
|
async function submitOtp({ normalizedEmail, shouldRememberAccount }) {
|
|
@@ -214,7 +213,12 @@ export function useLoginViewActions({
|
|
|
214
213
|
token: String(state.otpCode.value || "").trim(),
|
|
215
214
|
type: "email"
|
|
216
215
|
};
|
|
217
|
-
ensureCommandSectionValid(
|
|
216
|
+
ensureCommandSectionValid(
|
|
217
|
+
authLoginOtpVerifyCommand,
|
|
218
|
+
"body",
|
|
219
|
+
otpPayload,
|
|
220
|
+
t("jskit.auth.login.error.otpVerifyFailed")
|
|
221
|
+
);
|
|
218
222
|
|
|
219
223
|
const otpResult = await request(AUTH_PATHS.LOGIN_OTP_VERIFY, {
|
|
220
224
|
method: "POST",
|
|
@@ -233,7 +237,7 @@ export function useLoginViewActions({
|
|
|
233
237
|
email: normalizedEmail,
|
|
234
238
|
password: String(state.password.value || "")
|
|
235
239
|
};
|
|
236
|
-
ensureCommandSectionValid(authLoginPasswordCommand, "body", loginPayload, "
|
|
240
|
+
ensureCommandSectionValid(authLoginPasswordCommand, "body", loginPayload, t("jskit.auth.login.error.signInFailed"));
|
|
237
241
|
|
|
238
242
|
const loginResult = await request(AUTH_PATHS.LOGIN, {
|
|
239
243
|
method: "POST",
|
|
@@ -273,7 +277,7 @@ export function useLoginViewActions({
|
|
|
273
277
|
|
|
274
278
|
try {
|
|
275
279
|
if (callbackResult.completed !== true) {
|
|
276
|
-
throw new Error(callbackResult.errorMessage || "
|
|
280
|
+
throw new Error(callbackResult.errorMessage || t("jskit.auth.login.error.oauthCompleteFailed"));
|
|
277
281
|
}
|
|
278
282
|
|
|
279
283
|
state.applyRememberedAccountPreference({
|
|
@@ -291,7 +295,7 @@ export function useLoginViewActions({
|
|
|
291
295
|
window.location.replace(state.requestedReturnTo.value);
|
|
292
296
|
}
|
|
293
297
|
} catch (error) {
|
|
294
|
-
setErrorMessage(
|
|
298
|
+
setErrorMessage(serverMessage(error, t("jskit.auth.login.error.oauthCompleteFailed")));
|
|
295
299
|
stripOAuthParamsFromLocation();
|
|
296
300
|
} finally {
|
|
297
301
|
state.loading.value = false;
|
|
@@ -330,7 +334,7 @@ export function useLoginViewActions({
|
|
|
330
334
|
|
|
331
335
|
await submitLogin({ normalizedEmail, shouldRememberAccount });
|
|
332
336
|
} catch (error) {
|
|
333
|
-
setErrorMessage(
|
|
337
|
+
setErrorMessage(serverMessage(error, t("jskit.auth.login.error.authFailed")));
|
|
334
338
|
} finally {
|
|
335
339
|
state.loading.value = false;
|
|
336
340
|
}
|
|
@@ -349,15 +353,15 @@ export function useLoginViewActions({
|
|
|
349
353
|
authLoginOtpRequestCommand,
|
|
350
354
|
"body",
|
|
351
355
|
otpRequestPayload,
|
|
352
|
-
"
|
|
356
|
+
t("jskit.auth.login.error.otpRequestFailed")
|
|
353
357
|
);
|
|
354
358
|
await request(AUTH_PATHS.LOGIN_OTP_REQUEST, {
|
|
355
359
|
method: "POST",
|
|
356
360
|
body: otpRequestPayload
|
|
357
361
|
});
|
|
358
|
-
setInfoMessage("
|
|
362
|
+
setInfoMessage(t("jskit.auth.login.otpSent"), "auth-web.default-login-view:otp-code-sent");
|
|
359
363
|
} catch (error) {
|
|
360
|
-
setErrorMessage(
|
|
364
|
+
setErrorMessage(serverMessage(error, t("jskit.auth.login.error.otpRequestFailed")));
|
|
361
365
|
} finally {
|
|
362
366
|
state.otpRequestPending.value = false;
|
|
363
367
|
}
|
|
@@ -366,7 +370,7 @@ export function useLoginViewActions({
|
|
|
366
370
|
async function resendRegisterConfirmationEmail() {
|
|
367
371
|
const normalizedEmail = normalizeEmailAddress(state.pendingEmailConfirmationAddress.value || state.email.value);
|
|
368
372
|
if (!normalizedEmail) {
|
|
369
|
-
setErrorMessage("
|
|
373
|
+
setErrorMessage(t("jskit.auth.login.error.emailRequiredForConfirmation"));
|
|
370
374
|
return;
|
|
371
375
|
}
|
|
372
376
|
|
|
@@ -380,32 +384,33 @@ export function useLoginViewActions({
|
|
|
380
384
|
authRegisterConfirmationResendCommand,
|
|
381
385
|
"body",
|
|
382
386
|
resendPayload,
|
|
383
|
-
"
|
|
387
|
+
t("jskit.auth.login.error.resendConfirmationFailed")
|
|
384
388
|
);
|
|
385
389
|
const resendResult = await request(AUTH_PATHS.REGISTER_CONFIRMATION_RESEND, {
|
|
386
390
|
method: "POST",
|
|
387
391
|
body: resendPayload
|
|
388
392
|
});
|
|
389
|
-
const info =
|
|
390
|
-
String(resendResult?.message || "").trim() ||
|
|
391
|
-
"If an account exists for that email, a confirmation email has been sent.";
|
|
393
|
+
const info = serverMessage(resendResult).trim() || t("jskit.auth.login.confirmEmail.resent");
|
|
392
394
|
setInfoMessage(info, "auth-web.default-login-view:register-confirmation-resend");
|
|
393
395
|
} catch (error) {
|
|
394
|
-
setErrorMessage(
|
|
396
|
+
setErrorMessage(serverMessage(error, t("jskit.auth.login.error.resendConfirmationFailed")));
|
|
395
397
|
} finally {
|
|
396
398
|
state.registerConfirmationResendPending.value = false;
|
|
397
399
|
}
|
|
398
400
|
}
|
|
399
401
|
|
|
400
402
|
function oauthProviderButtonLabel(provider) {
|
|
401
|
-
const providerLabel = String(provider?.label || provider?.id || "
|
|
403
|
+
const providerLabel = String(provider?.label || provider?.id || t("jskit.auth.login.oauth.providerFallback"));
|
|
402
404
|
if (state.isRegister.value) {
|
|
403
|
-
return
|
|
405
|
+
return t("jskit.auth.login.oauth.register", { provider: providerLabel });
|
|
404
406
|
}
|
|
405
407
|
if (state.showRememberedAccount.value) {
|
|
406
|
-
return
|
|
408
|
+
return t("jskit.auth.login.oauth.continueAs", {
|
|
409
|
+
provider: providerLabel,
|
|
410
|
+
name: state.rememberedAccountDisplayName.value
|
|
411
|
+
});
|
|
407
412
|
}
|
|
408
|
-
return
|
|
413
|
+
return t("jskit.auth.login.oauth.continue", { provider: providerLabel });
|
|
409
414
|
}
|
|
410
415
|
|
|
411
416
|
function oauthProviderIcon(provider) {
|
|
@@ -432,16 +437,16 @@ export function useLoginViewActions({
|
|
|
432
437
|
authLoginOAuthStartCommand,
|
|
433
438
|
"params",
|
|
434
439
|
paramsPayload,
|
|
435
|
-
"
|
|
440
|
+
t("jskit.auth.login.error.oauthProviderInvalid")
|
|
436
441
|
);
|
|
437
442
|
ensureCommandSectionValid(
|
|
438
443
|
authLoginOAuthStartCommand,
|
|
439
444
|
"query",
|
|
440
445
|
queryPayload,
|
|
441
|
-
"
|
|
446
|
+
t("jskit.auth.login.error.oauthReturnToInvalid")
|
|
442
447
|
);
|
|
443
448
|
} catch (error) {
|
|
444
|
-
setErrorMessage(
|
|
449
|
+
setErrorMessage(serverMessage(error, t("jskit.auth.login.error.oauthStartFailed")));
|
|
445
450
|
return;
|
|
446
451
|
}
|
|
447
452
|
|
|
@@ -449,13 +454,13 @@ export function useLoginViewActions({
|
|
|
449
454
|
const oauthStartPath = buildAuthOauthStartPath(provider);
|
|
450
455
|
try {
|
|
451
456
|
if (!oauthLaunchClient || typeof oauthLaunchClient.open !== "function") {
|
|
452
|
-
throw new Error("
|
|
457
|
+
throw new Error(t("jskit.auth.login.error.oauthLaunchUnavailable"));
|
|
453
458
|
}
|
|
454
459
|
await oauthLaunchClient.open({
|
|
455
460
|
url: `${oauthStartPath}?${params.toString()}`
|
|
456
461
|
});
|
|
457
462
|
} catch (error) {
|
|
458
|
-
setErrorMessage(
|
|
463
|
+
setErrorMessage(serverMessage(error, t("jskit.auth.login.error.oauthStartFailed")));
|
|
459
464
|
}
|
|
460
465
|
}
|
|
461
466
|
|
|
@@ -469,7 +474,7 @@ export function useLoginViewActions({
|
|
|
469
474
|
window.location.replace(state.requestedReturnTo.value);
|
|
470
475
|
}
|
|
471
476
|
} catch (error) {
|
|
472
|
-
setErrorMessage(
|
|
477
|
+
setErrorMessage(serverMessage(error, t("jskit.auth.login.error.initializeFailed")));
|
|
473
478
|
} finally {
|
|
474
479
|
state.loading.value = false;
|
|
475
480
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
SUBMIT_LABEL_BY_MODE
|
|
18
18
|
} from "./constants.js";
|
|
19
19
|
import { normalizeEmailAddress, maskEmail } from "./identityHelpers.js";
|
|
20
|
+
import { useJskitText } from "../../i18n.js";
|
|
20
21
|
import {
|
|
21
22
|
createRememberedAccountHint,
|
|
22
23
|
writeRememberedAccountHint,
|
|
@@ -39,6 +40,7 @@ function resolveInitialMode() {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
export function useLoginViewState({ placementContext } = {}) {
|
|
43
|
+
const { t } = useJskitText();
|
|
42
44
|
const mode = ref(resolveInitialMode());
|
|
43
45
|
const email = ref(normalizeEmailAddress(readWindowSearchParam("email")));
|
|
44
46
|
const password = ref("");
|
|
@@ -82,21 +84,28 @@ export function useLoginViewState({ placementContext } = {}) {
|
|
|
82
84
|
const showRememberedAccount = computed(
|
|
83
85
|
() => (isLogin.value || isOtp.value) && useRememberedAccount.value && Boolean(rememberedAccount.value)
|
|
84
86
|
);
|
|
85
|
-
const rememberedAccountDisplayName = computed(
|
|
87
|
+
const rememberedAccountDisplayName = computed(
|
|
88
|
+
() => String(rememberedAccount.value?.displayName || t("jskit.auth.login.rememberedAccount.fallbackName"))
|
|
89
|
+
);
|
|
86
90
|
const rememberedAccountMaskedEmail = computed(() => String(rememberedAccount.value?.maskedEmail || ""));
|
|
87
|
-
const rememberedAccountSwitchLabel =
|
|
88
|
-
|
|
91
|
+
const rememberedAccountSwitchLabel = computed(() => t("jskit.auth.login.rememberedAccount.switch"));
|
|
92
|
+
// An empty key (the plain login mode) shows nothing.
|
|
93
|
+
function modeText(keysByMode) {
|
|
94
|
+
const key = keysByMode[mode.value] || keysByMode[LOGIN_MODE];
|
|
95
|
+
return key ? t(key) : "";
|
|
96
|
+
}
|
|
97
|
+
const authTitle = computed(() => modeText(AUTH_TITLE_BY_MODE));
|
|
89
98
|
const authSubtitle = computed(() => {
|
|
90
99
|
if (isEmailConfirmationPending.value) {
|
|
91
100
|
const maskedEmail = maskEmail(pendingEmailConfirmationAddress.value);
|
|
92
101
|
if (maskedEmail) {
|
|
93
|
-
return
|
|
102
|
+
return t("jskit.auth.login.subtitle.confirmEmailSentTo", { email: maskedEmail });
|
|
94
103
|
}
|
|
95
|
-
return "
|
|
104
|
+
return t("jskit.auth.login.subtitle.confirmEmailInbox");
|
|
96
105
|
}
|
|
97
|
-
return AUTH_SUBTITLE_BY_MODE
|
|
106
|
+
return modeText(AUTH_SUBTITLE_BY_MODE);
|
|
98
107
|
});
|
|
99
|
-
const submitLabel = computed(() => SUBMIT_LABEL_BY_MODE
|
|
108
|
+
const submitLabel = computed(() => modeText(SUBMIT_LABEL_BY_MODE));
|
|
100
109
|
const allowedReturnToOrigins = computed(() =>
|
|
101
110
|
resolveAllowedOriginsFromPlacementContext(placementContext?.value)
|
|
102
111
|
);
|
|
@@ -122,7 +131,7 @@ export function useLoginViewState({ placementContext } = {}) {
|
|
|
122
131
|
const emailConfirmationMessage = computed(
|
|
123
132
|
() =>
|
|
124
133
|
String(pendingEmailConfirmationMessage.value || "").trim() ||
|
|
125
|
-
"
|
|
134
|
+
t("jskit.auth.login.confirmEmail.message")
|
|
126
135
|
);
|
|
127
136
|
|
|
128
137
|
function clearTransientMessages() {
|
|
@@ -8,8 +8,11 @@ import {
|
|
|
8
8
|
validateCommandSection,
|
|
9
9
|
resolveFieldValidationMessage
|
|
10
10
|
} from "./validationHelpers.js";
|
|
11
|
+
import { useJskitText } from "../../i18n.js";
|
|
11
12
|
|
|
12
13
|
export function useLoginViewValidation({ state } = {}) {
|
|
14
|
+
const { t } = useJskitText();
|
|
15
|
+
|
|
13
16
|
function resolveFieldErrorMessages({
|
|
14
17
|
shouldValidate,
|
|
15
18
|
commandResource,
|
|
@@ -78,7 +81,7 @@ export function useLoginViewValidation({ state } = {}) {
|
|
|
78
81
|
return [];
|
|
79
82
|
}
|
|
80
83
|
if (String(state.confirmPassword.value || "").trim() !== String(state.password.value || "").trim()) {
|
|
81
|
-
return ["
|
|
84
|
+
return [t("jskit.auth.login.passwordsMismatch")];
|
|
82
85
|
}
|
|
83
86
|
return [];
|
|
84
87
|
});
|