From 6bc065307211296c188ae2958d764ec11f81f223 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sun, 28 Sep 2025 19:04:04 +0200 Subject: [PATCH] Update sealious to get the new i18n api --- package-lock.json | 44 +++---------------- package.json | 2 +- src/back/email-templates/password-reset.ts | 8 ++-- .../email-templates/registration-intent.ts | 8 ++-- src/back/policy-types/roles.ts | 8 ++-- 5 files changed, 19 insertions(+), 51 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0ec42a1..63fbc2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "nyc": "^17.1.0", "object-path": "^0.11.8", "qs": "^6.12.0", - "sealious": "^0.21.23", + "sealious": "^0.21.30", "slug": "^9.1.0", "stimulus": "^3.2.2", "tempstream": "^0.4.6", @@ -2969,15 +2969,6 @@ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" }, - "node_modules/boom": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-7.3.0.tgz", - "integrity": "sha512-Swpoyi2t5+GhOEGw8rEsKvTxFLIDiiKoUc2gsoV6Lyr43LHBIzch3k2MvYUs8RTROrIkVJ3Al0TkaOGjnb+B6A==", - "deprecated": "This module has moved and is now available at @hapi/boom. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.", - "dependencies": { - "hoek": "6.x.x" - } - }, "node_modules/brace-expansion": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", @@ -6852,12 +6843,6 @@ "node": "*" } }, - "node_modules/hoek": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz", - "integrity": "sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==", - "deprecated": "This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues." - }, "node_modules/hookable": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz", @@ -12031,9 +12016,9 @@ "peer": true }, "node_modules/sealious": { - "version": "0.21.23", - "resolved": "https://registry.npmjs.org/sealious/-/sealious-0.21.23.tgz", - "integrity": "sha512-Vl/Ms+L00ucjEl8/eE4+otLMrWaeVgspn1xCRT4SXh+dRz9DID84ydspqVpyyUf7hUiHuX8zlfdn1FwgCQ0lPQ==", + "version": "0.21.30", + "resolved": "https://registry.npmjs.org/sealious/-/sealious-0.21.30.tgz", + "integrity": "sha512-EWmqqFpDdgMvBmqAnaoX3FN2TmWdEgA1MgCUoQNB0iwUSl5m2Ghpd3W3eoM4H0Nr6bTr1ogJaOsAZJJFlIdc0Q==", "dependencies": { "@koa/router": "^12.0.1", "@sealcode/file-manager": "^1.0.1", @@ -12055,7 +12040,6 @@ "@types/object-hash": "^1.3.3", "@types/sanitize-html": "^2.11.0", "@types/uuid": "^8.3.0", - "boom": "^7.3.0", "chalk": "^4.1.0", "clone": "^1.0.2", "color": "latest", @@ -17220,14 +17204,6 @@ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" }, - "boom": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-7.3.0.tgz", - "integrity": "sha512-Swpoyi2t5+GhOEGw8rEsKvTxFLIDiiKoUc2gsoV6Lyr43LHBIzch3k2MvYUs8RTROrIkVJ3Al0TkaOGjnb+B6A==", - "requires": { - "hoek": "6.x.x" - } - }, "brace-expansion": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", @@ -20026,11 +20002,6 @@ "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==" }, - "hoek": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz", - "integrity": "sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==" - }, "hookable": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz", @@ -23910,9 +23881,9 @@ } }, "sealious": { - "version": "0.21.23", - "resolved": "https://registry.npmjs.org/sealious/-/sealious-0.21.23.tgz", - "integrity": "sha512-Vl/Ms+L00ucjEl8/eE4+otLMrWaeVgspn1xCRT4SXh+dRz9DID84ydspqVpyyUf7hUiHuX8zlfdn1FwgCQ0lPQ==", + "version": "0.21.30", + "resolved": "https://registry.npmjs.org/sealious/-/sealious-0.21.30.tgz", + "integrity": "sha512-EWmqqFpDdgMvBmqAnaoX3FN2TmWdEgA1MgCUoQNB0iwUSl5m2Ghpd3W3eoM4H0Nr6bTr1ogJaOsAZJJFlIdc0Q==", "requires": { "@koa/router": "^12.0.1", "@sealcode/file-manager": "^1.0.1", @@ -23934,7 +23905,6 @@ "@types/object-hash": "^1.3.3", "@types/sanitize-html": "^2.11.0", "@types/uuid": "^8.3.0", - "boom": "^7.3.0", "chalk": "^4.1.0", "clone": "^1.0.2", "color": "latest", diff --git a/package.json b/package.json index 782c86c..74679d2 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "nyc": "^17.1.0", "object-path": "^0.11.8", "qs": "^6.12.0", - "sealious": "^0.21.23", + "sealious": "^0.21.30", "slug": "^9.1.0", "stimulus": "^3.2.2", "tempstream": "^0.4.6", diff --git a/src/back/email-templates/password-reset.ts b/src/back/email-templates/password-reset.ts index d46fb55..a7b2db8 100644 --- a/src/back/email-templates/password-reset.ts +++ b/src/back/email-templates/password-reset.ts @@ -16,14 +16,14 @@ export default async function PasswordResetTemplate( const username = matching_users.items[0]?.get("username"); + const context = new app.Context(); return EmailTemplates.Simple(app, { - subject: app.i18n("password_reset_email_subject", [app.manifest.name]), + subject: context.i18n`[${app.manifest.name}] Password reset request`, to: `${String(username)}<${email_address}>`, - text: ` - ${app.i18n("password_reset_email_text", [app.manifest.name, username])}`, + text: `Hello, ${username}. Someone requested a password reset on your account on ${app.manifest.name}. If it was you, use the link below to change the password. Otherwise, ignore this message.`, buttons: [ { - text: app.i18n("password_reset_cta"), + text: context.i18n`Change password`, href: `${app.manifest.base_url}/confirm-password-reset?token=${token}&email=${email_address}`, }, ], diff --git a/src/back/email-templates/registration-intent.ts b/src/back/email-templates/registration-intent.ts index 8f9a42e..2adf9a1 100644 --- a/src/back/email-templates/registration-intent.ts +++ b/src/back/email-templates/registration-intent.ts @@ -5,14 +5,14 @@ export default async function RegistrationIntentTemplate( app: App, { email_address, token }: { email_address: string; token: string } ) { + const context = new app.Context(); return EmailTemplates.Simple(app, { - subject: app.i18n("registration_intent_email_subject", [app.manifest.name]), + subject: context.i18n`Finish creating your ${app.manifest.name} account`, to: email_address, - text: ` - ${app.i18n("registration_intent_email_text", [app.manifest.name])}`, + text: `To finish setting up your account, click the following link:`, buttons: [ { - text: app.i18n("registration_intent_cta"), + text: context.i18n`To finish setting up your account, click the following link:`, href: `${app.manifest.base_url}/account/confirm-registration-email?token=${token}&email=${email_address}`, }, ], diff --git a/src/back/policy-types/roles.ts b/src/back/policy-types/roles.ts index 1e9abe3..877b4d7 100644 --- a/src/back/policy-types/roles.ts +++ b/src/back/policy-types/roles.ts @@ -37,18 +37,16 @@ export class Roles extends Policy { async checkerFunction(context: Context) { if (context.user_id === null) { - return Policy.deny(context.app.i18n("policy_logged_in_deny")); + return Policy.deny(context.i18n`You are not logged in`); } const matching_roles_count = await this.countMatchingRoles(context); return matching_roles_count > 0 ? Policy.allow( - context.app.i18n("policy_roles_allow", [ - this.allowed_roles.join(", "), - ]) + context.i18n`You are assigned to one of these roles: ${this.allowed_roles.join(", ")}` ) : Policy.deny( - context.app.i18n("policy_roles_deny", [this.allowed_roles.join(", ")]) + context.i18n`You are not assigned to one of these roles: ${this.allowed_roles.join(", ")}` ); } }