@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.
@@ -1,4 +1,5 @@
1
1
  import { validateOperationSection } from "@jskit-ai/http-runtime/shared/validators/operationValidation";
2
+ import { useJskitText } from "../../i18n.js";
2
3
 
3
4
  function validateCommandSection(commandResource, section, payload) {
4
5
  if (!commandResource || !commandResource.operation) {
@@ -16,31 +17,27 @@ function validateCommandSection(commandResource, section, payload) {
16
17
  });
17
18
  }
18
19
 
19
- function resolveValidationMessage(validationResult, fallbackMessage = "Validation failed.") {
20
+ // Field messages in the user's language when the validator sent their codes.
21
+ function validationFieldMessages(validationResult) {
22
+ return validationResult && !validationResult.ok ? useJskitText().fieldErrorMessages(validationResult) : {};
23
+ }
24
+
25
+ function resolveValidationMessage(validationResult, fallbackMessage = "") {
20
26
  if (!validationResult || validationResult.ok) {
21
27
  return "";
22
28
  }
23
29
 
24
- const fieldErrors = validationResult.fieldErrors && typeof validationResult.fieldErrors === "object"
25
- ? validationResult.fieldErrors
26
- : {};
27
- const firstFieldError = Object.values(fieldErrors).find((entry) => String(entry || "").trim().length > 0);
30
+ const firstFieldError = Object.values(validationFieldMessages(validationResult))
31
+ .find((entry) => String(entry || "").trim().length > 0);
28
32
  if (firstFieldError) {
29
33
  return String(firstFieldError);
30
34
  }
31
35
 
32
- return String(fallbackMessage || "Validation failed.");
36
+ return String(fallbackMessage || useJskitText().t("jskit.errors.validation_failed"));
33
37
  }
34
38
 
35
39
  function resolveFieldValidationMessage(validationResult, fieldName = "") {
36
- if (!validationResult || validationResult.ok) {
37
- return "";
38
- }
39
-
40
- const fieldErrors = validationResult.fieldErrors && typeof validationResult.fieldErrors === "object"
41
- ? validationResult.fieldErrors
42
- : {};
43
- return String(fieldErrors[fieldName] || "").trim();
40
+ return String(validationFieldMessages(validationResult)[fieldName] || "").trim();
44
41
  }
45
42
 
46
43
  function ensureCommandSectionValid(commandResource, section, payload, fallbackMessage) {
@@ -8,6 +8,7 @@ import {
8
8
  import { performSignOutRequest } from "../runtime/useSignOut.js";
9
9
  import { useAuthGuardRuntime } from "../runtime/inject.js";
10
10
  import { normalizeAuthReturnToPath } from "../lib/returnToPath.js";
11
+ import { useJskitText } from "../i18n.js";
11
12
 
12
13
  function readReturnToPathFromLocation({ allowedOrigins = [] } = {}) {
13
14
  if (typeof window !== "object" || !window.location) {
@@ -31,6 +32,7 @@ function navigateToPath(path, { replace = true } = {}) {
31
32
  }
32
33
 
33
34
  export function useDefaultSignOutView() {
35
+ const { serverMessage, t } = useJskitText();
34
36
  const authGuardRuntime = useAuthGuardRuntime({
35
37
  required: true
36
38
  });
@@ -87,7 +89,7 @@ export function useDefaultSignOutView() {
87
89
  navigateToPath(loginRoute.value, { replace: true });
88
90
  } catch (error) {
89
91
  status.value = "error";
90
- setErrorMessage(String(error?.message || "Sign out failed."));
92
+ setErrorMessage(serverMessage(error, t("jskit.auth.signOut.failed")));
91
93
  }
92
94
  }
93
95
 
@@ -0,0 +1,6 @@
1
+ import { registerJskitMessages, useJskitText } from "@jskit-ai/kernel/client";
2
+ import en from "../../locales/en.json" with { type: "json" };
3
+
4
+ registerJskitMessages(en);
5
+
6
+ export { useJskitText };
@@ -0,0 +1,12 @@
1
+ import { resolveAuthDeniedLoginText } from "@jskit-ai/auth-core/shared/authDenied";
2
+ import { useJskitText } from "../i18n.js";
3
+
4
+ // Why a sign-in that succeeded left no active session: the account's denial,
5
+ // or a hint to retry.
6
+ function inactiveSessionMessage(session) {
7
+ const { serverMessage, t } = useJskitText();
8
+ const denied = resolveAuthDeniedLoginText(session?.authDenied);
9
+ return denied ? serverMessage(denied) : t("jskit.auth.login.error.sessionNotActive");
10
+ }
11
+
12
+ export { inactiveSessionMessage };
@@ -1,5 +1,4 @@
1
1
  import { authLoginOAuthCompleteCommand } from "@jskit-ai/auth-core/shared/commands/authLoginOAuthCompleteCommand";
2
- import { resolveAuthDeniedLoginMessage } from "@jskit-ai/auth-core/shared/authDenied";
3
2
  import {
4
3
  OAUTH_QUERY_PARAM_PROVIDER,
5
4
  OAUTH_QUERY_PARAM_RETURN_TO
@@ -12,6 +11,18 @@ import {
12
11
  readAuthCallbackUrlParams
13
12
  } from "./authCallbackUrlParams.js";
14
13
  import { ensureCommandSectionValid } from "../composables/loginView/validationHelpers.js";
14
+ import { inactiveSessionMessage } from "./inactiveSessionMessage.js";
15
+ import { useJskitText } from "../i18n.js";
16
+
17
+ // The params of a sign-in error the server explained by redirect (error_params).
18
+ function readErrorParams(value = "") {
19
+ try {
20
+ const params = JSON.parse(value || "{}");
21
+ return params && typeof params === "object" && !Array.isArray(params) ? params : {};
22
+ } catch {
23
+ return {};
24
+ }
25
+ }
15
26
 
16
27
  function readOAuthCallbackParamsFromUrl(url = "") {
17
28
  const callbackUrlParams = readAuthCallbackUrlParams(url);
@@ -33,6 +44,10 @@ function readOAuthCallbackParamsFromUrl(url = "") {
33
44
  readAuthCallbackParam(callbackUrlParams, "error_description") ||
34
45
  readAuthCallbackParam(callbackUrlParams, "errorDescription")
35
46
  ).trim();
47
+ // The description's code and params, sent when the app's server explained the
48
+ // error. A provider's own error_code is translated only if its English matches.
49
+ const errorDescriptionCode = String(readAuthCallbackParam(callbackUrlParams, "error_code")).trim();
50
+ const errorDescriptionParams = readErrorParams(readAuthCallbackParam(callbackUrlParams, "error_params"));
36
51
  const hasSessionPair = Boolean(accessToken && refreshToken);
37
52
 
38
53
  if (!code && !hasSessionPair && !errorCode) {
@@ -48,6 +63,8 @@ function readOAuthCallbackParamsFromUrl(url = "") {
48
63
  hasSessionPair,
49
64
  errorCode,
50
65
  errorDescription,
66
+ errorDescriptionCode,
67
+ errorDescriptionParams,
51
68
  provider: String(searchParams.get(OAUTH_QUERY_PARAM_PROVIDER) || "").trim().toLowerCase(),
52
69
  returnTo: String(searchParams.get(OAUTH_QUERY_PARAM_RETURN_TO) || "").trim()
53
70
  });
@@ -100,15 +117,19 @@ async function completeOAuthCallbackFromUrl({
100
117
  .trim()
101
118
  .toLowerCase();
102
119
  const oauthError = callbackParams.errorCode;
103
- const oauthErrorDescription = callbackParams.errorDescription;
104
120
  const hasSessionPair = callbackParams.hasSessionPair === true;
121
+ const { serverMessage, t } = useJskitText();
105
122
 
106
123
  if (oauthError) {
107
124
  return Object.freeze({
108
125
  handled: true,
109
126
  completed: false,
110
127
  returnTo,
111
- errorMessage: oauthErrorDescription || oauthError,
128
+ errorMessage: serverMessage({
129
+ code: callbackParams.errorDescriptionCode,
130
+ params: callbackParams.errorDescriptionParams,
131
+ message: callbackParams.errorDescription
132
+ }, oauthError),
112
133
  callbackParams
113
134
  });
114
135
  }
@@ -118,7 +139,7 @@ async function completeOAuthCallbackFromUrl({
118
139
  handled: true,
119
140
  completed: false,
120
141
  returnTo,
121
- errorMessage: "OAuth provider is missing from callback.",
142
+ errorMessage: t("jskit.auth.oauth.providerMissing"),
122
143
  callbackParams
123
144
  });
124
145
  }
@@ -133,7 +154,7 @@ async function completeOAuthCallbackFromUrl({
133
154
  authLoginOAuthCompleteCommand,
134
155
  "body",
135
156
  payload,
136
- "Invalid OAuth callback payload."
157
+ t("jskit.auth.oauth.invalidCallback")
137
158
  );
138
159
 
139
160
  const oauthResult = await request(AUTH_PATHS.OAUTH_COMPLETE, {
@@ -142,11 +163,7 @@ async function completeOAuthCallbackFromUrl({
142
163
  });
143
164
  const session = await refreshSession();
144
165
  if (!session?.authenticated) {
145
- const authDeniedMessage = resolveAuthDeniedLoginMessage(session?.authDenied);
146
- if (authDeniedMessage) {
147
- throw new Error(authDeniedMessage);
148
- }
149
- throw new Error("Login succeeded but the session is not active yet. Please retry.");
166
+ throw new Error(inactiveSessionMessage(session));
150
167
  }
151
168
 
152
169
  return Object.freeze({
@@ -166,7 +183,7 @@ async function completeOAuthCallbackFromUrl({
166
183
  completed: false,
167
184
  returnTo,
168
185
  callbackParams,
169
- errorMessage: String(error?.message || "Unable to complete OAuth sign-in.")
186
+ errorMessage: serverMessage(error, t("jskit.auth.login.error.oauthCompleteFailed"))
170
187
  });
171
188
  }
172
189
  }
@@ -1,4 +1,5 @@
1
1
  import { createBrowserOAuthLaunchClient } from "./oauthLaunchClient.js";
2
+ import { useJskitText } from "../i18n.js";
2
3
 
3
4
  // A sign-in page refuses to be framed, so a framed app (an editor Preview, an
4
5
  // embedded dashboard) signs in through a window of its own. The window
@@ -7,6 +8,7 @@ const OAUTH_POPUP_WINDOW_NAME = "jskit-oauth-sign-in";
7
8
  const OAUTH_POPUP_MESSAGE_TYPE = "jskit.auth-web.oauth-popup.complete";
8
9
  const OAUTH_POPUP_MARKER_KEY = "jskit.auth-web.oauth-popup.started-at";
9
10
  const OAUTH_POPUP_LIFETIME_MS = 10 * 60 * 1000;
11
+ // The English of jskit.auth.oauth.popupBlocked; the error itself is in the user's language.
10
12
  const OAUTH_POPUP_BLOCKED_MESSAGE =
11
13
  "Your browser blocked the sign-in window. Allow pop-ups for this page, then try again.";
12
14
 
@@ -57,7 +59,7 @@ function createPopupOAuthLaunchClient({
57
59
  }
58
60
  const popup = win.open(normalizedUrl, OAUTH_POPUP_WINDOW_NAME, popupFeatures(win));
59
61
  if (!popup) {
60
- throw new Error(OAUTH_POPUP_BLOCKED_MESSAGE);
62
+ throw new Error(useJskitText().t("jskit.auth.oauth.popupBlocked"));
61
63
  }
62
64
  storageOf(win)?.setItem(OAUTH_POPUP_MARKER_KEY, String(Date.now()));
63
65
  popup.focus?.();
@@ -4,6 +4,7 @@ import { isAuthGuardRuntime } from "./authGuardRuntime.js";
4
4
  import { authHttpRequest, clearAuthCsrfTokenCache } from "./authHttpClient.js";
5
5
  import { useAuthGuardRuntime } from "./inject.js";
6
6
  import { normalizeAuthReturnToPath } from "../lib/returnToPath.js";
7
+ import { useJskitText } from "../i18n.js";
7
8
 
8
9
  const SIGN_OUT_ENDPOINT = AUTH_PATHS.LOGOUT;
9
10
  const SESSION_ENDPOINT = AUTH_PATHS.SESSION;
@@ -48,7 +49,7 @@ function createHttpLogoutApi() {
48
49
  return;
49
50
  }
50
51
 
51
- throw new Error("Logout did not terminate the server session.");
52
+ throw new Error(useJskitText().t("jskit.auth.signOut.serverSessionActive"));
52
53
  }
53
54
  };
54
55
  }
@@ -65,7 +66,7 @@ async function performSignOutRequest({ authGuardRuntime } = {}) {
65
66
 
66
67
  const guardState = await authGuardRuntime.refresh();
67
68
  if (guardState?.authenticated) {
68
- throw new Error("Sign out did not complete because the session is still authenticated.");
69
+ throw new Error(useJskitText().t("jskit.auth.signOut.sessionStillActive"));
69
70
  }
70
71
 
71
72
  return guardState;
@@ -4,10 +4,12 @@ import { useRoute } from "vue-router";
4
4
  import { useWebPlacementContext } from "@jskit-ai/shell-web/client/placement";
5
5
  import ShellMenuLinkItem from "@jskit-ai/shell-web/client/components/ShellMenuLinkItem";
6
6
  import { appendAccountReturnToIfNeeded } from "../lib/profileMenuLinkTarget.js";
7
+ import { useJskitText } from "../i18n.js";
7
8
 
8
9
  const props = defineProps({
10
+ // Plain text, a message key or { key, fallback, params }.
9
11
  label: {
10
- type: String,
12
+ type: [String, Object],
11
13
  default: ""
12
14
  },
13
15
  to: {
@@ -24,6 +26,7 @@ const props = defineProps({
24
26
  }
25
27
  });
26
28
  const route = useRoute();
29
+ const { text } = useJskitText();
27
30
  const { context: placementContext } = useWebPlacementContext();
28
31
 
29
32
  function resolveWindowHref() {
@@ -45,7 +48,7 @@ const resolvedTo = computed(() =>
45
48
 
46
49
  <template>
47
50
  <ShellMenuLinkItem
48
- :label="props.label"
51
+ :label="text(props.label)"
49
52
  :to="resolvedTo"
50
53
  :icon="props.icon"
51
54
  :disabled="props.disabled"
@@ -3,8 +3,10 @@ import { computed } from "vue";
3
3
  import ShellOutlet from "@jskit-ai/shell-web/client/components/ShellOutlet";
4
4
  import { useWebPlacementContext } from "@jskit-ai/shell-web/client/placement";
5
5
  import { useAuthStore } from "../stores/useAuthStore.js";
6
+ import { useJskitText } from "../i18n.js";
6
7
 
7
8
  const auth = useAuthStore();
9
+ const { t } = useJskitText();
8
10
  const { context: shellPlacementContext } = useWebPlacementContext();
9
11
 
10
12
  const shellUser = computed(() => {
@@ -26,7 +28,7 @@ const displayName = computed(() => {
26
28
  return username;
27
29
  }
28
30
 
29
- return "Guest";
31
+ return t("jskit.auth.profile.guest");
30
32
  });
31
33
 
32
34
  const avatarUrl = computed(() => {
@@ -32,7 +32,7 @@
32
32
  :color="isLogin ? 'primary' : undefined"
33
33
  @click="switchMode('login')"
34
34
  >
35
- Sign in
35
+ {{ t("jskit.auth.login.mode.signIn") }}
36
36
  </v-btn>
37
37
  <v-btn
38
38
  v-if="!showRememberedAccount && canRegister"
@@ -42,7 +42,7 @@
42
42
  :color="isRegister ? 'primary' : undefined"
43
43
  @click="switchMode('register')"
44
44
  >
45
- Register
45
+ {{ t("jskit.auth.login.mode.register") }}
46
46
  </v-btn>
47
47
  </div>
48
48
 
@@ -56,7 +56,7 @@
56
56
 
57
57
  <div class="switch-row d-flex align-center justify-space-between ga-3">
58
58
  <v-btn class="text-none" variant="tonal" color="primary" @click="goToMainScreen">
59
- Go to main screen
59
+ {{ t("jskit.auth.login.confirmEmail.goToMainScreen") }}
60
60
  </v-btn>
61
61
  <v-btn
62
62
  v-if="canResendEmailConfirmation"
@@ -66,9 +66,11 @@
66
66
  :loading="registerConfirmationResendPending"
67
67
  @click="resendRegisterConfirmationEmail"
68
68
  >
69
- Resend confirmation email
69
+ {{ t("jskit.auth.login.confirmEmail.resend") }}
70
+ </v-btn>
71
+ <v-btn variant="text" color="secondary" @click="switchMode('login')">
72
+ {{ t("jskit.auth.login.backToSignIn") }}
70
73
  </v-btn>
71
- <v-btn variant="text" color="secondary" @click="switchMode('login')">Back to sign in</v-btn>
72
74
  </div>
73
75
  </template>
74
76
 
@@ -78,7 +80,9 @@
78
80
  class="remembered-account d-flex align-center justify-space-between ga-3 mb-4"
79
81
  >
80
82
  <div class="remembered-copy flex-grow-1">
81
- <p class="remembered-title">Welcome back, {{ rememberedAccountDisplayName }}</p>
83
+ <p class="remembered-title">
84
+ {{ t("jskit.auth.login.rememberedAccount.welcomeBack", { name: rememberedAccountDisplayName }) }}
85
+ </p>
82
86
  <p class="remembered-email">{{ rememberedAccountMaskedEmail }}</p>
83
87
  </div>
84
88
  <v-btn variant="text" color="secondary" class="text-none" @click="switchAccount">
@@ -89,7 +93,7 @@
89
93
  <v-text-field
90
94
  v-if="!isLogin || canUsePasswordLogin"
91
95
  v-model="email"
92
- label="Email"
96
+ :label="t('jskit.auth.login.field.email')"
93
97
  variant="outlined"
94
98
  density="comfortable"
95
99
  type="email"
@@ -102,7 +106,7 @@
102
106
  <v-text-field
103
107
  v-if="(isLogin && canUsePasswordLogin) || isRegister"
104
108
  v-model="password"
105
- label="Password"
109
+ :label="t('jskit.auth.login.field.password')"
106
110
  :type="showPassword ? 'text' : 'password'"
107
111
  variant="outlined"
108
112
  density="comfortable"
@@ -117,7 +121,7 @@
117
121
  <v-text-field
118
122
  v-if="isRegister"
119
123
  v-model="confirmPassword"
120
- label="Confirm password"
124
+ :label="t('jskit.auth.login.field.confirmPassword')"
121
125
  :type="showConfirmPassword ? 'text' : 'password'"
122
126
  variant="outlined"
123
127
  density="comfortable"
@@ -132,7 +136,7 @@
132
136
  <v-text-field
133
137
  v-if="isOtp"
134
138
  v-model="otpCode"
135
- label="One-time code"
139
+ :label="t('jskit.auth.login.field.otpCode')"
136
140
  variant="outlined"
137
141
  density="comfortable"
138
142
  autocomplete="one-time-code"
@@ -148,17 +152,17 @@
148
152
  color="secondary"
149
153
  @click="switchMode('forgot')"
150
154
  >
151
- Forgot password?
155
+ {{ t("jskit.auth.login.forgotPassword") }}
152
156
  </v-btn>
153
157
  <v-btn v-if="canUseOtp" variant="text" color="secondary" @click="switchMode('otp')">
154
- Use one-time code
158
+ {{ t("jskit.auth.login.useOtp") }}
155
159
  </v-btn>
156
160
  </div>
157
161
 
158
162
  <v-checkbox
159
163
  v-if="(isLogin && canUsePasswordLogin) || isOtp"
160
164
  v-model="rememberAccountOnDevice"
161
- label="Remember this account on this device"
165
+ :label="t('jskit.auth.login.rememberedAccount.rememberDevice')"
162
166
  density="compact"
163
167
  hide-details
164
168
  class="mb-4"
@@ -172,7 +176,7 @@
172
176
  :loading="otpRequestPending"
173
177
  @click="requestOtpCode"
174
178
  >
175
- Send one-time code
179
+ {{ t("jskit.auth.login.sendOtp") }}
176
180
  </v-btn>
177
181
  </div>
178
182
 
@@ -205,18 +209,24 @@
205
209
  </v-btn>
206
210
 
207
211
  <div v-if="isRegister" class="switch-row mt-4 d-flex align-center justify-space-between ga-3">
208
- <span class="text-medium-emphasis">Already have an account?</span>
209
- <v-btn variant="text" color="secondary" @click="switchMode('login')">Back to sign in</v-btn>
212
+ <span class="text-medium-emphasis">{{ t("jskit.auth.login.hasAccount") }}</span>
213
+ <v-btn variant="text" color="secondary" @click="switchMode('login')">
214
+ {{ t("jskit.auth.login.backToSignIn") }}
215
+ </v-btn>
210
216
  </div>
211
217
 
212
218
  <div v-else-if="isForgot" class="switch-row mt-4 d-flex align-center justify-space-between ga-3">
213
- <span class="text-medium-emphasis">Remembered your password?</span>
214
- <v-btn variant="text" color="secondary" @click="switchMode('login')">Back to sign in</v-btn>
219
+ <span class="text-medium-emphasis">{{ t("jskit.auth.login.rememberedPassword") }}</span>
220
+ <v-btn variant="text" color="secondary" @click="switchMode('login')">
221
+ {{ t("jskit.auth.login.backToSignIn") }}
222
+ </v-btn>
215
223
  </div>
216
224
 
217
225
  <div v-else-if="isOtp" class="switch-row mt-4 d-flex align-center justify-space-between ga-3">
218
- <span class="text-medium-emphasis">Want to use another method?</span>
219
- <v-btn variant="text" color="secondary" @click="switchMode('login')">Back to sign in</v-btn>
226
+ <span class="text-medium-emphasis">{{ t("jskit.auth.login.otherMethod") }}</span>
227
+ <v-btn variant="text" color="secondary" @click="switchMode('login')">
228
+ {{ t("jskit.auth.login.backToSignIn") }}
229
+ </v-btn>
220
230
  </div>
221
231
  </template>
222
232
  </v-form>
@@ -237,6 +247,7 @@ import { useAuthOAuthLaunchClient } from "../runtime/inject.js";
237
247
  import { useLoginViewState } from "../composables/loginView/useLoginViewState.js";
238
248
  import { useLoginViewValidation } from "../composables/loginView/useLoginViewValidation.js";
239
249
  import { useLoginViewActions } from "../composables/loginView/useLoginViewActions.js";
250
+ import { useJskitText } from "../i18n.js";
240
251
 
241
252
  const {
242
253
  context: placementContext
@@ -244,6 +255,7 @@ const {
244
255
  const queryClient = useQueryClient();
245
256
  const errorRuntime = useShellWebErrorRuntime();
246
257
  const { mobile: isMobileViewport } = useDisplay({ mobileBreakpoint: 960 });
258
+ const { t } = useJskitText();
247
259
 
248
260
  const state = useLoginViewState({ placementContext });
249
261
  const validation = useLoginViewValidation({ state });
@@ -18,7 +18,7 @@
18
18
  >
19
19
  <v-card-text class="reset-content" :class="{ 'reset-content--mobile': isMobileViewport }">
20
20
  <div class="reset-header mb-5">
21
- <h1 class="reset-title">Reset password</h1>
21
+ <h1 class="reset-title">{{ t("jskit.auth.resetPassword.title") }}</h1>
22
22
  </div>
23
23
 
24
24
  <v-alert v-if="errorMessage" type="error" variant="tonal" class="mb-4">
@@ -26,7 +26,7 @@
26
26
  </v-alert>
27
27
 
28
28
  <v-alert v-if="status === 'done'" type="success" variant="tonal" class="mb-4">
29
- Password updated. Sign in with your new password.
29
+ {{ t("jskit.auth.resetPassword.done") }}
30
30
  </v-alert>
31
31
 
32
32
  <v-progress-linear v-if="status === 'checking'" indeterminate color="primary" class="mb-4" />
@@ -34,7 +34,7 @@
34
34
  <v-form v-if="status === 'ready'" @submit.prevent="submitReset" novalidate>
35
35
  <v-text-field
36
36
  v-model="password"
37
- label="New password"
37
+ :label="t('jskit.auth.resetPassword.newPassword')"
38
38
  :type="showPassword ? 'text' : 'password'"
39
39
  variant="outlined"
40
40
  density="comfortable"
@@ -46,7 +46,7 @@
46
46
  />
47
47
  <v-text-field
48
48
  v-model="confirmPassword"
49
- label="Confirm password"
49
+ :label="t('jskit.auth.resetPassword.confirmPassword')"
50
50
  :type="showConfirmPassword ? 'text' : 'password'"
51
51
  variant="outlined"
52
52
  density="comfortable"
@@ -57,12 +57,14 @@
57
57
  @click:append-inner="showConfirmPassword = !showConfirmPassword"
58
58
  />
59
59
  <v-btn block color="primary" size="large" type="submit" :loading="loading" :disabled="!canSubmit">
60
- Update password
60
+ {{ t("jskit.auth.resetPassword.submit") }}
61
61
  </v-btn>
62
62
  </v-form>
63
63
 
64
64
  <div v-if="status === 'done' || status === 'error'" class="mt-4 d-flex justify-end">
65
- <v-btn variant="text" color="secondary" href="/auth/login">Back to sign in</v-btn>
65
+ <v-btn variant="text" color="secondary" href="/auth/login">
66
+ {{ t("jskit.auth.resetPassword.backToSignIn") }}
67
+ </v-btn>
66
68
  </div>
67
69
  </v-card-text>
68
70
  </v-card>
@@ -85,8 +87,10 @@ import {
85
87
  validateCommandSection,
86
88
  resolveFieldValidationMessage
87
89
  } from "../composables/loginView/validationHelpers.js";
90
+ import { useJskitText } from "../i18n.js";
88
91
 
89
92
  const { mobile: isMobileViewport } = useDisplay({ mobileBreakpoint: 960 });
93
+ const { serverMessage, t } = useJskitText();
90
94
  const status = ref("checking");
91
95
  const loading = ref(false);
92
96
  const errorMessage = ref("");
@@ -112,7 +116,7 @@ const confirmPasswordError = computed(() => {
112
116
  if (!confirmPassword.value) {
113
117
  return [];
114
118
  }
115
- return password.value === confirmPassword.value ? [] : ["Passwords must match."];
119
+ return password.value === confirmPassword.value ? [] : [t("jskit.auth.resetPassword.passwordsMustMatch")];
116
120
  });
117
121
  const canSubmit = computed(() =>
118
122
  Boolean(password.value) &&
@@ -143,7 +147,7 @@ async function exchangeRecoveryToken() {
143
147
  status.value = "ready";
144
148
  } catch (error) {
145
149
  status.value = "error";
146
- errorMessage.value = String(error?.message || "Recovery link is invalid or expired.");
150
+ errorMessage.value = serverMessage(error, t("jskit.auth.resetPassword.recoveryInvalid"));
147
151
  }
148
152
  }
149
153
 
@@ -164,7 +168,7 @@ async function submitReset() {
164
168
  password.value = "";
165
169
  confirmPassword.value = "";
166
170
  } catch (error) {
167
- errorMessage.value = String(error?.message || "Unable to update password.");
171
+ errorMessage.value = serverMessage(error, t("jskit.auth.resetPassword.updateFailed"));
168
172
  } finally {
169
173
  loading.value = false;
170
174
  }
@@ -3,14 +3,14 @@
3
3
  <v-container class="fill-height d-flex align-center justify-center py-8">
4
4
  <v-card class="signout-card" rounded="lg" elevation="1" border>
5
5
  <v-card-text class="pa-7">
6
- <h1 class="text-h5 mb-3">Signing you out</h1>
6
+ <h1 class="text-h5 mb-3">{{ t("jskit.auth.signOut.title") }}</h1>
7
7
 
8
8
  <p v-if="status === 'pending'" class="text-medium-emphasis mb-4">
9
- Please wait while we end your session.
9
+ {{ t("jskit.auth.signOut.pending") }}
10
10
  </p>
11
11
 
12
12
  <p v-if="status === 'error'" class="text-body-1 text-medium-emphasis mb-4">
13
- {{ errorMessage || "Sign out failed. Please try again." }}
13
+ {{ errorMessage || t("jskit.auth.signOut.failedTryAgain") }}
14
14
  </p>
15
15
 
16
16
  <div class="d-flex ga-3">
@@ -21,7 +21,7 @@
21
21
  class="text-none"
22
22
  @click="retrySignOut"
23
23
  >
24
- Retry sign out
24
+ {{ t("jskit.auth.signOut.retry") }}
25
25
  </v-btn>
26
26
  <v-btn
27
27
  v-if="status === 'error'"
@@ -30,7 +30,7 @@
30
30
  class="text-none"
31
31
  @click="goToLogin"
32
32
  >
33
- Go to login
33
+ {{ t("jskit.auth.signOut.goToLogin") }}
34
34
  </v-btn>
35
35
  <v-progress-circular v-if="status === 'pending'" indeterminate color="primary" size="22" />
36
36
  </div>
@@ -42,7 +42,9 @@
42
42
 
43
43
  <script setup>
44
44
  import { useDefaultSignOutView } from "../composables/useDefaultSignOutView.js";
45
+ import { useJskitText } from "../i18n.js";
45
46
 
47
+ const { t } = useJskitText();
46
48
  const { status, errorMessage, retrySignOut, goToLogin } = useDefaultSignOutView();
47
49
  </script>
48
50
 
@@ -1,5 +1,6 @@
1
1
  import { AppError } from "@jskit-ai/kernel/server/runtime/errors";
2
2
  import { normalizeAuthDenied } from "@jskit-ai/auth-core/shared/authDenied";
3
+ import { AUTH_TEXTS, authMessageFields, authText } from "@jskit-ai/auth-core/server/authTexts";
3
4
  import { AUTH_ACTION_IDS } from "../constants/authActionIds.js";
4
5
  import { AuthWebService } from "../services/AuthWebService.js";
5
6
 
@@ -25,7 +26,9 @@ class AuthController {
25
26
  reply.code(201).send({
26
27
  ok: true,
27
28
  requiresEmailConfirmation: true,
28
- message: "Check your email to confirm the account before logging in."
29
+ message: "Check your email to confirm the account before logging in.",
30
+ messageCode: "auth.register.confirmEmail",
31
+ messageParams: {}
29
32
  });
30
33
  return;
31
34
  }
@@ -83,8 +86,15 @@ class AuthController {
83
86
  if (!(error instanceof AppError) || error.statusCode === 500) {
84
87
  throw error;
85
88
  }
86
- // The browser navigated here, so the login page explains instead of a JSON body.
89
+ // The browser navigated here, so the login page explains instead of a JSON body,
90
+ // with the error's code and params so it can show the explanation translated.
87
91
  const explained = new URLSearchParams({ error: "sign_in_unavailable", error_description: error.message });
92
+ if (error.code) {
93
+ explained.set("error_code", String(error.code));
94
+ }
95
+ if (error.params && Object.keys(error.params).length > 0) {
96
+ explained.set("error_params", JSON.stringify(error.params));
97
+ }
88
98
  reply.redirect(`/auth/login?${explained}`);
89
99
  return;
90
100
  }
@@ -154,7 +164,9 @@ class AuthController {
154
164
 
155
165
  if (authResult.transientFailure) {
156
166
  reply.code(503).send({
157
- error: "Authentication service temporarily unavailable. Please retry.",
167
+ error: authText(AUTH_TEXTS.sessionUnavailable),
168
+ code: AUTH_TEXTS.sessionUnavailable.code,
169
+ params: {},
158
170
  csrfToken,
159
171
  ...oauthCatalogPayload
160
172
  });
@@ -203,7 +215,7 @@ class AuthController {
203
215
  this.service.clearSessionCookies(reply);
204
216
  reply.code(200).send({
205
217
  ok: true,
206
- message: "Password updated. Sign in with your new password."
218
+ ...authMessageFields(AUTH_TEXTS.passwordUpdatedSignIn)
207
219
  });
208
220
  }
209
221
  }