@starci/hfs 5.2.0 → 5.3.0
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 +34 -0
- package/README.md +1 -1
- package/cache/hfs-family.d.mts +2 -3
- package/cache/hfs-family.mjs +4 -9
- package/cache/secret-records.d.mts +7 -0
- package/cache/secret-records.mjs +12 -0
- package/cache/session.mjs +4 -2
- package/codemod/account-doors.d.mts +36 -0
- package/codemod/account-doors.mjs +128 -0
- package/codemod/main.mjs +31 -1
- package/codemod/module-definition.d.mts +52 -0
- package/codemod/module-definition.mjs +242 -0
- package/codemod/quality-binding.d.mts +33 -0
- package/codemod/quality-binding.mjs +38 -0
- package/codemod/secrets-cache.d.mts +35 -0
- package/codemod/secrets-cache.mjs +70 -0
- package/codemod/sops-rules.d.mts +34 -0
- package/codemod/sops-rules.mjs +69 -0
- package/codemod/theme-tokens.mjs +48 -2
- package/lint/run.d.mts +6 -0
- package/lint/run.mjs +63 -10
- package/package.json +1 -1
- package/runtime/knowledge/hfs/canon-pins.yaml +43 -10
- package/runtime/knowledge/hfs/fe-stack.yaml +3 -3
- package/runtime/knowledge/hfs/rules.yaml +13 -9
- package/runtime/knowledge/hfs/slots.yaml +105 -12
- package/runtime/modules/kernel/failure-codes.yaml +5 -4
- package/runtime/scripts/hfs/architecture/config.d.mts +4 -0
- package/runtime/scripts/hfs/architecture/config.mjs +25 -1
- package/runtime/scripts/hfs/architecture/module-per-transport.d.mts +1 -1
- package/runtime/scripts/hfs/architecture/module-per-transport.mjs +6 -1
- package/runtime/scripts/hfs/architecture/root-packages.d.mts +26 -0
- package/runtime/scripts/hfs/architecture/root-packages.mjs +78 -0
- package/runtime/scripts/hfs/architecture/type-context.d.mts +4 -1
- package/runtime/scripts/hfs/architecture/type-context.mjs +30 -0
- package/runtime/scripts/hfs/architecture/typescript.d.mts +7 -1
- package/runtime/scripts/hfs/architecture/typescript.mjs +21 -1
- package/runtime/scripts/hfs/explicit-surface-rule.mjs +1 -1
- package/runtime/scripts/hfs/rules/database-access.mjs +39 -1
- package/runtime/scripts/hfs/rules/monorepo.d.mts +4 -0
- package/runtime/scripts/hfs/rules/monorepo.mjs +10 -5
- package/runtime/scripts/hfs/rules/secrets.mjs +11 -0
- package/runtime/scripts/hfs/secret-errors.d.mts +3 -0
- package/runtime/scripts/hfs/secret-errors.mjs +8 -0
- package/runtime/scripts/hfs/secret-init.d.mts +6 -0
- package/runtime/scripts/hfs/secret-init.mjs +23 -0
- package/runtime/scripts/hfs/secret-sops.mjs +9 -1
- package/runtime/scripts/hfs/secret-standard.d.mts +20 -0
- package/runtime/scripts/hfs/secret-standard.mjs +106 -0
- package/runtime/scripts/hfs/secret.mjs +5 -1
- package/runtime/scripts/hfs/view.d.mts +23 -0
- package/runtime/scripts/hfs/view.mjs +68 -0
- package/runtime/scripts/lib/declaration-surface.d.mts +4 -0
- package/runtime/scripts/lib/declaration-surface.mjs +55 -1
- package/runtime/scripts/lib/secret-records.d.mts +13 -0
- package/runtime/scripts/lib/secret-records.mjs +83 -0
- package/scaffold/add-inbox-lite.mjs +2 -2
- package/scaffold/add-queue-lite.mjs +1 -3
- package/scaffold/app.d.mts +2 -2
- package/scaffold/app.mjs +10 -12
- package/scaffold/lite-exports.mjs +1 -15
- package/scripts/sync-bundles.d.mts +8 -0
- package/stack/images/openclaw-runtime/Dockerfile +18 -0
- package/stack/images/openclaw-runtime/entrypoint.sh +23 -0
- package/stack/images/openclaw-runtime/openclaw-init.mjs +101 -0
- package/stack/images/openclaw-runtime/openclaw-relay.mjs +25 -0
- package/stack/local-up.mjs +3 -0
- package/stack/runtime-layers.d.mts +21 -0
- package/stack/runtime-layers.mjs +67 -0
- package/sync/hygiene.mjs +3 -1
- package/sync/index.d.mts +2 -0
- package/sync/index.mjs +33 -2
- package/templates/app/auth-doors.sql.partial +115 -0
- package/templates/app/ci-workflows/github/workflows/ci.yml +1 -1
- package/templates/app/ci-workflows-lite/github/workflows/ci.yml +1 -1
- package/templates/app/package-scripts/core.json +1 -1
- package/templates/app/package-scripts/package.json +1 -1
- package/templates/app/package-scripts-lite/package.json +1 -1
- package/templates/app/skeleton-lite/.starcistacks/application-stacks.yaml +9 -0
- package/templates/app/skeleton-lite/.starcistacks/dev/README.md +3 -1
- package/templates/app/skeleton-lite/.starcistacks/dev/infra/compose/compose.yaml +19 -1
- package/templates/app/skeleton-lite/.starcistacks/dev/runtime/env/KEYS.md +3 -0
- package/templates/app/skeleton-lite/.starcistacks/production/infra/swarm/stack.yaml +5 -0
- package/templates/app/skeleton-lite/.starcistacks/production/runtime/env/KEYS.md +4 -0
- package/templates/app/skeleton-lite/db/migrations/__timestamp___baseline.sql +24 -4
- package/templates/be/auth-lite/src/features/api/auth/application/auth.contracts.ts +33 -0
- package/templates/be/auth-lite/src/features/api/auth/application/confirm.command.ts +11 -0
- package/templates/be/auth-lite/src/features/api/auth/application/confirm.handler.ts +22 -0
- package/templates/be/auth-lite/src/features/api/auth/application/forgot.command.ts +11 -0
- package/templates/be/auth-lite/src/features/api/auth/application/forgot.handler.ts +22 -0
- package/templates/be/auth-lite/src/features/api/auth/application/resend.command.ts +11 -0
- package/templates/be/auth-lite/src/features/api/auth/application/resend.handler.ts +22 -0
- package/templates/be/auth-lite/src/features/api/auth/application/reset.command.ts +11 -0
- package/templates/be/auth-lite/src/features/api/auth/application/reset.handler.ts +22 -0
- package/templates/be/auth-lite/src/features/api/auth/application/signup.command.ts +11 -0
- package/templates/be/auth-lite/src/features/api/auth/application/signup.handler.ts +22 -0
- package/templates/be/auth-lite/src/features/api/auth/auth.module-definition.ts +3 -10
- package/templates/be/auth-lite/src/features/api/auth/auth.module.ts +6 -1
- package/templates/be/auth-lite/src/features/api/auth/transport/http/auth-http.module-definition.ts +3 -10
- package/templates/be/auth-lite/src/features/api/auth/transport/http/auth.controller.ts +56 -1
- package/templates/be/auth-lite/src/features/api/auth/transport/http/dto/forgot.request.ts +16 -0
- package/templates/be/auth-lite/src/features/api/auth/transport/http/dto/resend.request.ts +16 -0
- package/templates/be/auth-lite/src/features/api/auth/transport/http/dto/reset.request.ts +18 -0
- package/templates/be/auth-lite/src/features/api/auth/transport/http/dto/signup.request.ts +22 -0
- package/templates/be/auth-lite/src/features/api/auth/transport/http/dto/token.request.ts +11 -0
- package/templates/be/auth-lite/src/modules/domain/identity/account-directory.service.spec.ts +30 -30
- package/templates/be/auth-lite/src/modules/domain/identity/account-directory.service.ts +7 -16
- package/templates/be/auth-lite/src/modules/domain/identity/authenticator.service.spec.ts +113 -49
- package/templates/be/auth-lite/src/modules/domain/identity/authenticator.service.ts +42 -53
- package/templates/be/auth-lite/src/modules/domain/identity/identity-email.log-events.ts +6 -0
- package/templates/be/auth-lite/src/modules/domain/identity/identity-email.service.spec.ts +233 -0
- package/templates/be/auth-lite/src/modules/domain/identity/identity-email.service.ts +176 -0
- package/templates/be/auth-lite/src/modules/domain/identity/identity-sign-in.log-events.ts +6 -0
- package/templates/be/auth-lite/src/modules/domain/identity/persistence/account-doors.port.ts +98 -0
- package/templates/be/auth-lite/src/modules/domain/identity/persistence/entities/identity-email-token.entity.ts +34 -0
- package/templates/be/auth-lite/src/modules/domain/identity/persistence/entities/index.ts +3 -10
- package/templates/be/auth-lite/src/modules/domain/identity/sign-in.service.spec.ts +17 -0
- package/templates/be/auth-lite/src/modules/domain/identity/sign-in.service.ts +6 -0
- package/templates/be/auth-lite/src/tests/fixtures/builders/identity.builder.ts +29 -33
- package/templates/be/inbox/module-definition.ts.tpl +2 -9
- package/templates/be/inbox/platform/event-bus/event-bus.module-definition.ts.tpl +2 -11
- package/templates/be/inbox/platform/inbox/inbox.module-definition.ts.tpl +2 -9
- package/templates/be/patterns/api/feature.module-definition.ts.tpl +3 -9
- package/templates/be/patterns/api/graphql.module-definition.ts.tpl +3 -9
- package/templates/be/patterns/cli/group.module-definition.ts.tpl +2 -9
- package/templates/be/patterns/event-bus/platform/event-bus.module-definition.ts.tpl +3 -10
- package/templates/be/patterns/idempotency/platform/inbox/inbox.module-definition.ts.tpl +2 -9
- package/templates/be/patterns/jobs/job.module-definition.ts.tpl +2 -9
- package/templates/be/patterns/jobs/job.queue.module-definition.ts.tpl +3 -9
- package/templates/be/patterns/jobs/platform/jobs.module-definition.ts.tpl +3 -10
- package/templates/be/patterns/projections/projection.module-definition.ts.tpl +2 -9
- package/templates/be/patterns/queues/platform/queue.module-definition.ts.tpl +3 -10
- package/templates/be/patterns/queues/queue.module-definition.ts.tpl +2 -9
- package/templates/be/patterns/reactors/message.module-definition.ts.tpl +3 -9
- package/templates/be/patterns/reactors/reactor.module-definition.ts.tpl +2 -9
- package/templates/be/patterns/realtime/channel.graphql.module-definition.ts.tpl +3 -9
- package/templates/be/patterns/realtime/channel.sse.module-definition.ts.tpl +3 -9
- package/templates/be/patterns/realtime/channel.websocket.module-definition.ts.tpl +3 -9
- package/templates/be/patterns/saga/saga.message.module-definition.ts.tpl +3 -9
- package/templates/be/patterns/saga/saga.module-definition.ts.tpl +2 -9
- package/templates/be/patterns/webhooks/webhook.http.module-definition.ts.tpl +3 -9
- package/templates/be/platform/graphql/graphql.module-definition.ts +2 -9
- package/templates/be/skeleton/src/features/api/system-health/system-health.module-definition.ts +3 -9
- package/templates/be/skeleton/src/features/api/system-health/transport/http/system-health-http.module-definition.ts +3 -9
- package/templates/be/skeleton/src/features/cli/cli.module-definition.ts +2 -9
- package/templates/be/skeleton/src/features/cli/migrate/migrate.module-definition.ts +3 -9
- package/templates/be/skeleton/src/features/cli/seed/seed.module-definition.ts +2 -9
- package/templates/be/skeleton/src/modules/domain/identity/identity.module-definition.ts +2 -9
- package/templates/be/skeleton/src/modules/domain/liveness/liveness.module-definition.ts +2 -9
- package/templates/be/skeleton/src/modules/domain/note/note.module-definition.ts +2 -9
- package/templates/be/skeleton/src/modules/platform/clock/clock.module-definition.ts +2 -9
- package/templates/be/skeleton/src/modules/platform/cqrs/cqrs.contracts.ts +2 -0
- package/templates/be/skeleton/src/modules/platform/cqrs/cqrs.module-definition.ts +2 -9
- package/templates/be/skeleton/src/modules/platform/database/database.module-definition.ts +3 -13
- package/templates/be/skeleton/src/modules/platform/errors/errors.module-definition.ts +4 -11
- package/templates/be/skeleton/src/modules/platform/http/http.module-definition.ts +4 -9
- package/templates/be/skeleton/src/modules/platform/http-security/http-security.module-definition.ts +5 -11
- package/templates/be/skeleton/src/modules/platform/i18n/i18n.module-definition.ts +4 -11
- package/templates/be/skeleton/src/modules/platform/ids/ids.module-definition.ts +2 -9
- package/templates/be/skeleton/src/modules/platform/logging/logging.module-definition.ts +2 -9
- package/templates/be/skeleton/src/modules/platform/retry/retry.module-definition.ts +2 -9
- package/templates/be/skeleton-lite/apps/api/src/api.env.ts +4 -0
- package/templates/be/skeleton-lite/apps/api/src/api.options.ts +3 -0
- package/templates/be/skeleton-lite/apps/api/src/compose/integrations.ts +3 -1
- package/templates/be/skeleton-lite/src/modules/domain/identity/errors/identity.error.ts +6 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/identity.module.ts +3 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/index.ts +1 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/messages/identity-mail.messages.ts +65 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/messages/identity.messages.ts +4 -0
- package/templates/be/skeleton-lite/src/modules/integrations/mail/index.ts +6 -0
- package/templates/be/skeleton-lite/src/modules/integrations/mail/mail.config.ts +33 -0
- package/templates/be/skeleton-lite/src/modules/integrations/mail/mail.decorators.ts +14 -0
- package/templates/be/skeleton-lite/src/modules/integrations/mail/mail.module-definition.ts +12 -0
- package/templates/be/skeleton-lite/src/modules/integrations/mail/mail.module.ts +27 -0
- package/templates/be/skeleton-lite/src/modules/integrations/mail/mail.options.ts +22 -0
- package/templates/be/skeleton-lite/src/modules/integrations/object-storage/object-storage.module-definition.ts +2 -9
- package/templates/be/skeleton-lite/src/modules/integrations/passport/index.ts +1 -1
- package/templates/be/skeleton-lite/src/modules/platform/database/index.ts +1 -0
- package/templates/be/skeleton-lite/src/modules/platform/http-security/rate-limit.guard.spec.ts +11 -0
- package/templates/be/skeleton-lite/src/tests/fixtures/builders/api.builder.ts +11 -0
- package/templates/be/table/api/feature.module-definition.ts.tpl +3 -9
- package/templates/be/table/api/graphql.module-definition.ts.tpl +3 -9
- package/templates/be/table/module-definition.ts.tpl +2 -9
- package/templates/fe/auth-lite/apps/web/src/modules/auth/email-doors.ts +16 -0
- package/templates/fe/auth-lite/apps/web/src/modules/auth/index.ts +5 -0
- package/templates/fe/skeleton/packages/__project__-i18n/src/index.ts +30 -67
- package/templates/fe/skeleton/packages/__project__-i18n/src/proxy.ts +6 -21
- package/templates/fe/skeleton/packages/__project__-i18n/src/routing.ts +10 -16
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/auth/confirm/page.tsx +9 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/auth/forgot/page.tsx +9 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/auth/resend/page.tsx +9 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/auth/reset/page.tsx +9 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/auth/signup/page.tsx +9 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/layout.tsx +5 -9
- package/templates/fe/skeleton-lite/apps/web/src/components/blocks/EmailDoorForm/component.tsx +51 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/blocks/EmailDoorForm/index.tsx +84 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppConfirmPage/index.tsx +25 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppForgotPage/index.tsx +21 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppHomePage/component.tsx +11 -3
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppHomePage/index.tsx +4 -1
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppResendPage/index.tsx +21 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppResetPage/index.tsx +25 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppSignupPage/index.tsx +21 -0
- package/templates/fe/skeleton-lite/apps/web/src/hooks/emailAuth/emailAuth.shared.ts +12 -0
- package/templates/fe/skeleton-lite/apps/web/src/hooks/emailAuth/index.ts +2 -0
- package/templates/fe/skeleton-lite/apps/web/src/hooks/emailAuth/useEmailDoor.ts +32 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/i18n/index.ts +2 -2
- package/templates/fe/skeleton-lite/apps/web/src/modules/i18n/messages/en.json +50 -1
- package/templates/fe/skeleton-lite/apps/web/src/modules/i18n/messages/vi.json +50 -1
- package/templates/fe/skeleton-lite/apps/web/src/modules/i18n/request.ts +7 -30
- package/templates/fe/skeleton-lite/apps/web/src/modules/i18n/routing.ts +13 -14
- package/templates/fe/skeleton-lite/apps/web/src/modules/routes/index.ts +5 -0
- package/templates/fe/skeleton-lite/apps/web/src/proxy.ts +4 -17
- package/templates/be/auth-lite/src/modules/domain/identity/persistence/entities/auth-identity.entity.ts +0 -38
- package/templates/be/auth-lite/src/modules/domain/identity/persistence/entities/auth-user.entity.ts +0 -54
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { MailSecurity } from "@starci/mail"
|
|
2
|
+
import type { EnvSource } from "@modules/platform/config"
|
|
3
|
+
import type { MailLanguage, MailOptions } from "./mail.options"
|
|
4
|
+
|
|
5
|
+
const DEFAULT_PORT = 587
|
|
6
|
+
const CONFIRM_TTL_SECONDS = 86_400
|
|
7
|
+
const RESET_TTL_SECONDS = 3_600
|
|
8
|
+
|
|
9
|
+
const readSecurity = (env: EnvSource): MailSecurity => {
|
|
10
|
+
const value = env.optional("MAIL_SECURITY") ?? "starttls"
|
|
11
|
+
if (value !== "tls" && value !== "starttls" && value !== "none") throw new Error("MAIL_SECURITY must be tls, starttls or none")
|
|
12
|
+
return value
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const readLanguage = (env: EnvSource): MailLanguage => {
|
|
16
|
+
const value = env.optional("MAIL_DEFAULT_LANGUAGE") ?? "en"
|
|
17
|
+
if (value !== "vi" && value !== "en") throw new Error("MAIL_DEFAULT_LANGUAGE must be vi or en")
|
|
18
|
+
return value
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Reads the mail configuration with no credential or server defaults; the login is optional and its password reads `<KEY>_FILE` first. */
|
|
22
|
+
export const parseMailConfig = (env: EnvSource): MailOptions => ({
|
|
23
|
+
host: env.string("MAIL_HOST"),
|
|
24
|
+
port: env.int("MAIL_PORT", DEFAULT_PORT),
|
|
25
|
+
security: readSecurity(env),
|
|
26
|
+
...(env.has("MAIL_USER") ? { auth: { user: env.string("MAIL_USER"), pass: env.secret("MAIL_PASSWORD") } } : {}),
|
|
27
|
+
from: { name: env.string("MAIL_FROM_NAME"), address: env.string("MAIL_FROM") },
|
|
28
|
+
webOrigin: new URL(env.url("AUTH_WEB_ORIGIN")).origin,
|
|
29
|
+
brandName: env.string("MAIL_FROM_NAME"),
|
|
30
|
+
defaultLanguage: readLanguage(env),
|
|
31
|
+
confirmTtlSeconds: env.int("MAIL_CONFIRM_TTL_SECONDS", CONFIRM_TTL_SECONDS),
|
|
32
|
+
resetTtlSeconds: env.int("MAIL_RESET_TTL_SECONDS", RESET_TTL_SECONDS),
|
|
33
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MAILER } from "@starci/mail"
|
|
2
|
+
import type { Mailer } from "@starci/mail"
|
|
3
|
+
import { injector } from "@modules/platform/composition"
|
|
4
|
+
import type { TypedParameterDecorator } from "@modules/platform/composition"
|
|
5
|
+
import type { MailOptions } from "./mail.options"
|
|
6
|
+
|
|
7
|
+
/** Token of the app's mail settings (the brand, the default language, the link lifetimes). */
|
|
8
|
+
export const MAIL_SETTINGS: unique symbol = Symbol("integrations.mail.settings")
|
|
9
|
+
|
|
10
|
+
/** Injects the mail port of `@starci/mail`. Parameter type: Mailer. */
|
|
11
|
+
export const InjectMailer = (): TypedParameterDecorator<Mailer> => injector<Mailer>(MAILER)
|
|
12
|
+
|
|
13
|
+
/** Injects the app's mail settings. Parameter type: MailOptions. */
|
|
14
|
+
export const InjectMailSettings = (): TypedParameterDecorator<MailOptions> => injector<MailOptions>(MAIL_SETTINGS)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConfigurableModuleBuilder, type ConfigurableModuleHost } from "@nestjs/common"
|
|
2
|
+
import type { MailOptions } from "./mail.options"
|
|
3
|
+
|
|
4
|
+
const built = new ConfigurableModuleBuilder<MailOptions>()
|
|
5
|
+
.setExtras({ isGlobal: false }, (definition, extras) => ({ ...definition, global: extras.isGlobal }))
|
|
6
|
+
.build()
|
|
7
|
+
type Host = ConfigurableModuleHost<MailOptions, "register", "create", { isGlobal: boolean }>
|
|
8
|
+
|
|
9
|
+
/** The configurable-module base of the mail glue; `isGlobal` is decided by the app root. */
|
|
10
|
+
export const ConfigurableModuleClass: Host["ConfigurableModuleClass"] = built.ConfigurableModuleClass
|
|
11
|
+
/** The options of a synchronous registration, for the register signature. */
|
|
12
|
+
export const OPTIONS_TYPE: Host["OPTIONS_TYPE"] = built.OPTIONS_TYPE
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MailModule as PackageMailModule } from "@starci/mail"
|
|
2
|
+
import type { MailOptions as PackageMailOptions } from "@starci/mail"
|
|
3
|
+
import { Module } from "@nestjs/common"
|
|
4
|
+
import type { DynamicModule } from "@nestjs/common"
|
|
5
|
+
import { MAIL_SETTINGS } from "./mail.decorators"
|
|
6
|
+
import { ConfigurableModuleClass, OPTIONS_TYPE } from "./mail.module-definition"
|
|
7
|
+
|
|
8
|
+
@Module({})
|
|
9
|
+
/** Composes `@starci/mail` with the app's typed settings and provides the settings of the app's own mail. */
|
|
10
|
+
export class MailModule extends ConfigurableModuleClass {
|
|
11
|
+
/** Registers the capability once per app. */
|
|
12
|
+
static register(options: typeof OPTIONS_TYPE): DynamicModule {
|
|
13
|
+
const { webOrigin, brandName, defaultLanguage, confirmTtlSeconds, resetTtlSeconds, isGlobal, ...transport } = options
|
|
14
|
+
const base = super.register(options)
|
|
15
|
+
const mail = PackageMailModule.register({ ...(transport satisfies PackageMailOptions), isGlobal: false })
|
|
16
|
+
return {
|
|
17
|
+
...base,
|
|
18
|
+
imports: [...(base.imports ?? []), mail],
|
|
19
|
+
providers: [
|
|
20
|
+
...(base.providers ?? []),
|
|
21
|
+
{ provide: MAIL_SETTINGS, useValue: { ...transport, webOrigin, brandName, defaultLanguage, confirmTtlSeconds, resetTtlSeconds } },
|
|
22
|
+
],
|
|
23
|
+
exports: [...(base.exports ?? []), mail, MAIL_SETTINGS],
|
|
24
|
+
global: isGlobal === true,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MailOptions as MailSettings } from "@starci/mail"
|
|
2
|
+
|
|
3
|
+
/** The languages the app writes its mail in. */
|
|
4
|
+
export type MailLanguage = "vi" | "en"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Outgoing mail parsed once at API boot: the settings of `@starci/mail` and what the app's own mail needs (the product name in
|
|
8
|
+
* the header, the language of a mail whose request names none, how long a confirmation or reset link lives). The words and
|
|
9
|
+
* layout of each mail belong to the domain that sends it.
|
|
10
|
+
*/
|
|
11
|
+
export interface MailOptions extends MailSettings {
|
|
12
|
+
/** The origin of the web app: the links of a confirmation or reset mail open its pages. */
|
|
13
|
+
readonly webOrigin: string
|
|
14
|
+
/** The product name in the header of every mail. */
|
|
15
|
+
readonly brandName: string
|
|
16
|
+
/** The language of a mail whose request names none. */
|
|
17
|
+
readonly defaultLanguage: MailLanguage
|
|
18
|
+
/** How long a confirmation link lives, in seconds. */
|
|
19
|
+
readonly confirmTtlSeconds: number
|
|
20
|
+
/** How long a password reset link lives, in seconds. */
|
|
21
|
+
readonly resetTtlSeconds: number
|
|
22
|
+
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineCapabilityModule } from "@starci/nest-kit"
|
|
2
2
|
import type { ObjectStorageOptions } from "./object-storage.options"
|
|
3
3
|
|
|
4
|
-
const built = new ConfigurableModuleBuilder<ObjectStorageOptions>()
|
|
5
|
-
.setExtras({ isGlobal: false }, (definition, extras) => ({ ...definition, global: extras.isGlobal }))
|
|
6
|
-
.build()
|
|
7
|
-
type Host = ConfigurableModuleHost<ObjectStorageOptions, "register", "create", { isGlobal: boolean }>
|
|
8
|
-
|
|
9
4
|
/** The configurable-module base of the object storage glue; `isGlobal` is decided by the app root. */
|
|
10
|
-
export const
|
|
11
|
-
/** The options of a synchronous registration, for the register signature. */
|
|
12
|
-
export const OPTIONS_TYPE: Host["OPTIONS_TYPE"] = built.OPTIONS_TYPE
|
|
5
|
+
export const { ConfigurableModuleClass, OPTIONS_TYPE } = defineCapabilityModule<ObjectStorageOptions>()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { DatabaseModule } from "./database.module"
|
|
2
|
+
export { callDbFunction } from "./database.client"
|
|
2
3
|
export { DATABASE_PROBE, InjectDatabaseProbe, InjectPrimaryEntityManager, PRIMARY_ENTITY_MANAGER } from "./primary.decorators"
|
|
3
4
|
export { DatabaseProbeService } from "./database-probe.service"
|
|
4
5
|
export type { DatabaseConnectionOptions } from "./database.options"
|
package/templates/be/skeleton-lite/src/modules/platform/http-security/rate-limit.guard.spec.ts
CHANGED
|
@@ -129,6 +129,17 @@ describe("RateLimitGuard", () => {
|
|
|
129
129
|
expect(entityManager.update).not.toHaveBeenCalled()
|
|
130
130
|
})
|
|
131
131
|
|
|
132
|
+
it("counts with an increment the database evaluates, so concurrent hits never overwrite each other", async () => {
|
|
133
|
+
const { entityManager, counting } = liveWindow(2)
|
|
134
|
+
const { guard } = await build(entityManager)
|
|
135
|
+
|
|
136
|
+
await guard.canActivate(contextOf("127.0.0.1"))
|
|
137
|
+
|
|
138
|
+
const assignment: unknown = counting?.callsOf("set")[0]?.[0]
|
|
139
|
+
const increment: unknown = typeof assignment === "object" && assignment !== null && "hits" in assignment && typeof assignment.hits === "function" ? Reflect.apply(assignment.hits, undefined, []) : undefined
|
|
140
|
+
expect(increment).toBe("hits + 1")
|
|
141
|
+
})
|
|
142
|
+
|
|
132
143
|
it("refuses a caller whose shared window is over the default limit", async () => {
|
|
133
144
|
const { guard } = await build(liveWindow(3).entityManager)
|
|
134
145
|
|
|
@@ -46,6 +46,17 @@ export const buildWiringProof = (): WiringProof => ({
|
|
|
46
46
|
secretAccessKey: new Secret("fixture-only"),
|
|
47
47
|
defaultExpiresIn: 300,
|
|
48
48
|
},
|
|
49
|
+
mail: {
|
|
50
|
+
host: "127.0.0.1",
|
|
51
|
+
port: 2525,
|
|
52
|
+
security: "none",
|
|
53
|
+
from: { name: "Fixture", address: "no-reply@fixture.example" },
|
|
54
|
+
webOrigin: "https://app.fixture.example",
|
|
55
|
+
brandName: "Fixture",
|
|
56
|
+
defaultLanguage: "en",
|
|
57
|
+
confirmTtlSeconds: 86400,
|
|
58
|
+
resetTtlSeconds: 3600,
|
|
59
|
+
},
|
|
49
60
|
},
|
|
50
61
|
overrides: [
|
|
51
62
|
{ token: PRIMARY_DATA_SOURCE, value: { manager: {} } },
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineConfigurableModule } from "@starci/nest-kit"
|
|
2
2
|
import type { {{Name}}ApiOptions } from "./{{name}}.options"
|
|
3
3
|
|
|
4
|
-
const built = new ConfigurableModuleBuilder<{{Name}}ApiOptions>().setClassMethodName("register").build()
|
|
5
|
-
type Host = ConfigurableModuleHost<{{Name}}ApiOptions, "register", "create", {}>
|
|
6
|
-
|
|
7
4
|
/** The configurable-module base of the {{name}} module. */
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
export const MODULE_OPTIONS_TOKEN: Host["MODULE_OPTIONS_TOKEN"] = built.MODULE_OPTIONS_TOKEN
|
|
11
|
-
/** The options of a synchronous registration, for the register signature. */
|
|
12
|
-
export const OPTIONS_TYPE: Host["OPTIONS_TYPE"] = built.OPTIONS_TYPE
|
|
5
|
+
export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE } =
|
|
6
|
+
defineConfigurableModule<{{Name}}ApiOptions>()
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineConfigurableModule } from "@starci/nest-kit"
|
|
2
2
|
import type { {{Name}}GraphqlOptions } from "./{{name}}-graphql.options"
|
|
3
3
|
|
|
4
|
-
const built = new ConfigurableModuleBuilder<{{Name}}GraphqlOptions>().setClassMethodName("register").build()
|
|
5
|
-
type Host = ConfigurableModuleHost<{{Name}}GraphqlOptions, "register", "create", {}>
|
|
6
|
-
|
|
7
4
|
/** The configurable-module base of the {{name}}-graphql module. */
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
export const MODULE_OPTIONS_TOKEN: Host["MODULE_OPTIONS_TOKEN"] = built.MODULE_OPTIONS_TOKEN
|
|
11
|
-
/** The options of a synchronous registration, for the register signature. */
|
|
12
|
-
export const OPTIONS_TYPE: Host["OPTIONS_TYPE"] = built.OPTIONS_TYPE
|
|
5
|
+
export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE } =
|
|
6
|
+
defineConfigurableModule<{{Name}}GraphqlOptions>()
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineCapabilityModule } from "@starci/nest-kit"
|
|
2
2
|
import type { {{Name}}Options } from "./{{name}}.options"
|
|
3
3
|
|
|
4
|
-
const built = new ConfigurableModuleBuilder<{{Name}}Options>()
|
|
5
|
-
.setExtras({ isGlobal: false }, (definition, extras) => ({ ...definition, global: extras.isGlobal }))
|
|
6
|
-
.build()
|
|
7
|
-
type Host = ConfigurableModuleHost<{{Name}}Options, "register", "create", { isGlobal: boolean }>
|
|
8
|
-
|
|
9
4
|
/** The configurable-module base of the {{name}} capability. */
|
|
10
|
-
export const
|
|
11
|
-
/** The options of a synchronous registration, for the register signature. */
|
|
12
|
-
export const OPTIONS_TYPE: Host["OPTIONS_TYPE"] = built.OPTIONS_TYPE
|
|
5
|
+
export const { ConfigurableModuleClass, OPTIONS_TYPE } = defineCapabilityModule<{{Name}}Options>()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Managed by starci app sync (slot fe.modules.auth.client); do not edit: run "npx starci app sync --execute".
|
|
2
|
+
import { createAuthClient } from "@starci/auth/client"
|
|
3
|
+
import { apiUrl } from "@/modules/config"
|
|
4
|
+
import type { AuthFailure } from "./contracts"
|
|
5
|
+
|
|
6
|
+
/** The email doors of the lite back end; the full edition's identity provider owns its own sign-up and recovery flows. */
|
|
7
|
+
export type EmailDoorName = "signup" | "resend" | "confirm" | "forgot" | "reset"
|
|
8
|
+
|
|
9
|
+
/** The anonymous doors need no session, so they use a client of their own over the same back-end origin. */
|
|
10
|
+
const doors = createAuthClient({ apiOrigin: () => apiUrl() })
|
|
11
|
+
|
|
12
|
+
/** Calls one email door with its posted fields; answers its failure (the wire code and its kind), or undefined when the back end accepted it. */
|
|
13
|
+
export const sendEmailDoor = async (door: EmailDoorName, body: Readonly<Record<string, string | undefined>>): Promise<AuthFailure | undefined> => {
|
|
14
|
+
const outcome = await doors.send(door, body)
|
|
15
|
+
return outcome.success ? undefined : { code: outcome.error, kind: outcome.message, message: "" }
|
|
16
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Managed by starci app sync (slot fe.modules.auth.client); do not edit: run "npx starci app sync --execute".
|
|
2
|
+
export { authClient } from "./client"
|
|
3
|
+
export { sendEmailDoor } from "./email-doors"
|
|
4
|
+
export type { EmailDoorName } from "./email-doors"
|
|
5
|
+
export type { AuthFailure, AuthSession } from "./contracts"
|
|
@@ -1,81 +1,44 @@
|
|
|
1
1
|
import "server-only"
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { createReadLocaleSegment } from "@starci/next-i18n/layout"
|
|
3
|
+
import type { ReadLocaleSegment } from "@starci/next-i18n/layout"
|
|
4
|
+
import { createI18nNavigation } from "@starci/next-i18n/navigation"
|
|
5
|
+
import type { I18nNavigation } from "@starci/next-i18n/navigation"
|
|
6
|
+
import { createRequestConfig } from "@starci/next-i18n/request"
|
|
7
|
+
import type { I18nRequestConfig } from "@starci/next-i18n/request"
|
|
8
|
+
import type { LoadCatalog } from "@starci/next-i18n"
|
|
7
9
|
import { locale as routeLocale } from "next/root-params"
|
|
8
|
-
import {
|
|
9
|
-
import type {
|
|
10
|
+
import { i18n } from "./routing"
|
|
11
|
+
import type { ProductI18n } from "./routing"
|
|
10
12
|
|
|
11
|
-
/**
|
|
12
|
-
type
|
|
13
|
+
/** The locales the product serves, as the catalog loader of an app receives them. */
|
|
14
|
+
type ProductLocale = ProductI18n["locales"][number]
|
|
13
15
|
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const messagesOf = (loaded: unknown): AbstractIntlMessages => {
|
|
21
|
-
const messages = typeof loaded === "object" && loaded !== null && "default" in loaded ? loaded.default : undefined
|
|
22
|
-
if (!isMessages(messages)) throw new TypeError("A message catalog module must export its messages as default")
|
|
23
|
-
return messages
|
|
16
|
+
/** What one app of the product reads of its next-intl stack. */
|
|
17
|
+
export interface AppI18n {
|
|
18
|
+
readonly navigation: I18nNavigation<ProductI18n["locales"], ProductI18n["localePrefix"]>
|
|
19
|
+
readonly requestConfig: I18nRequestConfig
|
|
20
|
+
readonly readLocaleSegment: ReadLocaleSegment<ProductLocale>
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
/** `next/root-params` is typed only after Next generates its types, so the reader is checked before it is called. */
|
|
27
24
|
const isLocaleReader = (value: unknown): value is () => Promise<unknown> => typeof value === "function"
|
|
28
25
|
|
|
26
|
+
/**
|
|
27
|
+
* The `[locale]` route param, read through `next/root-params` (`experimental.rootParams` in the app's next.config.ts), never the
|
|
28
|
+
* deprecated `requestLocale`. `next/root-params` is importable only where Next bundles it, which is why this workspace package, not
|
|
29
|
+
* `@starci/next-i18n`, reads it.
|
|
30
|
+
*/
|
|
29
31
|
const readRouteLocale = async (): Promise<unknown> => (isLocaleReader(routeLocale) ? routeLocale() : undefined)
|
|
30
32
|
|
|
31
|
-
/** The language the address states, its catalog and the product time zone. */
|
|
32
|
-
interface LocaleSegment {
|
|
33
|
-
readonly locale: string
|
|
34
|
-
readonly messages: AbstractIntlMessages
|
|
35
|
-
readonly timeZone: string
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** The navigation helpers of the product's routing (links, redirects, the locale-aware router). */
|
|
39
|
-
type ProductNavigation = ReturnType<typeof createNavigation<ProductRouting["locales"], "as-needed">>
|
|
40
|
-
|
|
41
|
-
/** What one app of the product reads of its next-intl stack. */
|
|
42
|
-
export interface AppI18n {
|
|
43
|
-
readonly navigation: ProductNavigation
|
|
44
|
-
readonly requestConfig: ReturnType<typeof getRequestConfig>
|
|
45
|
-
readonly readLocaleSegment: (params: Promise<{ readonly locale: string }>) => Promise<LocaleSegment>
|
|
46
|
-
}
|
|
47
|
-
|
|
48
33
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
34
|
+
* What one app of the product calls from its `modules/i18n` (R59): the locale-aware navigation, the request config next-intl's
|
|
35
|
+
* plugin loads (the app's `modules/i18n/request.ts` default-exports it) and what the app's `[locale]` layout resolves before it
|
|
36
|
+
* mounts the shell, all built by `@starci/next-i18n` over the product's one description of its languages. `app` names the app in the
|
|
37
|
+
* text of a message its catalog lacks (`<app>:<namespace>.<key>`); `loadMessages` loads its own catalogs. A server module: a client
|
|
38
|
+
* component reads the default locale from `./routing`.
|
|
54
39
|
*/
|
|
55
|
-
export const createAppI18n = (app: string, loadMessages:
|
|
56
|
-
navigation:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* FE-I18N-1), never the deprecated `requestLocale`. An unrecognised locale resolves to the default before the loader runs, so a
|
|
60
|
-
* missing catalog file is never imported.
|
|
61
|
-
*/
|
|
62
|
-
requestConfig: getRequestConfig(async () => {
|
|
63
|
-
const requested = await readRouteLocale()
|
|
64
|
-
const locale = hasLocale(routing.locales, requested) ? requested : routing.defaultLocale
|
|
65
|
-
return {
|
|
66
|
-
locale,
|
|
67
|
-
timeZone: PRODUCT_TIME_ZONE,
|
|
68
|
-
messages: messagesOf(await loadMessages(locale)),
|
|
69
|
-
getMessageFallback: ({ namespace, key }: MissingMessage) => `${app}:${namespace ?? ""}.${key}`,
|
|
70
|
-
}
|
|
71
|
-
}),
|
|
72
|
-
/**
|
|
73
|
-
* The language the address states, its catalog and the product time zone. An unknown segment is a route that does not exist,
|
|
74
|
-
* not a request to fall back silently.
|
|
75
|
-
*/
|
|
76
|
-
readLocaleSegment: async (params: Promise<{ readonly locale: string }>) => {
|
|
77
|
-
const { locale } = await params
|
|
78
|
-
if (!hasLocale(routing.locales, locale)) notFound()
|
|
79
|
-
return { locale, messages: await getMessages(), timeZone: PRODUCT_TIME_ZONE }
|
|
80
|
-
},
|
|
40
|
+
export const createAppI18n = (app: string, loadMessages: LoadCatalog<ProductLocale>): AppI18n => ({
|
|
41
|
+
navigation: createI18nNavigation(i18n),
|
|
42
|
+
requestConfig: createRequestConfig(i18n, { app, loadMessages, readRouteLocale }),
|
|
43
|
+
readLocaleSegment: createReadLocaleSegment(i18n),
|
|
81
44
|
})
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { routing } from "./routing"
|
|
5
|
-
|
|
6
|
-
/** The first path segments of the API, the health probe and the framework: never locale-negotiated. */
|
|
7
|
-
const UNNEGOTIATED_ROOTS: ReadonlySet<string> = new Set(["api", "health", "_next", "_vercel"])
|
|
8
|
-
|
|
9
|
-
/** Whether the path belongs to the API, the health probe, the framework or a file with an extension. */
|
|
10
|
-
const isUnnegotiated = (pathname: string): boolean => {
|
|
11
|
-
const segments = pathname.split("/")
|
|
12
|
-
const last = segments.at(-1) ?? ""
|
|
13
|
-
return UNNEGOTIATED_ROOTS.has(segments[1] ?? "") || (last.includes(".") && !last.endsWith("."))
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const negotiate = createMiddleware(routing)
|
|
1
|
+
import { createProxy } from "@starci/next-i18n/proxy"
|
|
2
|
+
import type { LocaleProxy } from "@starci/next-i18n/proxy"
|
|
3
|
+
import { i18n } from "./routing"
|
|
17
4
|
|
|
18
5
|
/**
|
|
19
|
-
* The one thing that runs before a route exists: which language it is in.
|
|
20
|
-
* the
|
|
21
|
-
* re-exports this.
|
|
6
|
+
* The one thing that runs before a route exists: which language it is in. The product's one description of its languages, read by
|
|
7
|
+
* the package's proxy; each app's `src/proxy.ts` re-exports this.
|
|
22
8
|
*/
|
|
23
|
-
export const proxy = (
|
|
24
|
-
isUnnegotiated(request.nextUrl.pathname) ? NextResponse.next() : negotiate(request)
|
|
9
|
+
export const proxy: LocaleProxy = createProxy(i18n)
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import { defineI18n } from "@starci/next-i18n"
|
|
2
|
+
import type { I18n } from "@starci/next-i18n"
|
|
3
3
|
|
|
4
4
|
/** The locales every app of the product serves; every catalog of an app has the same keys in each. */
|
|
5
5
|
const LOCALES = ["vi", "en"] as const
|
|
6
6
|
|
|
7
|
-
/** The
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
/** The product's time zone: fixed, not inferred, so the server and the hydrated client format the same instant the same way. */
|
|
11
|
-
export const PRODUCT_TIME_ZONE = "Asia/Ho_Chi_Minh"
|
|
7
|
+
/** The description of the product's languages: the locales and the `as-needed` prefix mode that `defineI18n` types. */
|
|
8
|
+
export type ProductI18n = I18n<typeof LOCALES, "as-needed">
|
|
12
9
|
|
|
13
|
-
/** The
|
|
14
|
-
export
|
|
10
|
+
/** The locale served at the unprefixed path, and the language of a document no locale reached (the global error boundary). */
|
|
11
|
+
export const DEFAULT_LOCALE: ProductI18n["defaultLocale"] = "vi"
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
|
-
* The one
|
|
18
|
-
* only when the locale is not the default, so
|
|
14
|
+
* The one description of the product's languages, for the proxy, the navigation and the request config of every app: vi default,
|
|
15
|
+
* a prefix only when the locale is not the default, and a fixed time zone so the server and the hydrated client format the same
|
|
16
|
+
* instant the same way. The stack that reads it is `@starci/next-i18n`'s; this package only states the languages (FE-I18N-1).
|
|
19
17
|
*/
|
|
20
|
-
export const
|
|
21
|
-
locales: LOCALES,
|
|
22
|
-
defaultLocale: DEFAULT_LOCALE,
|
|
23
|
-
localePrefix: "as-needed",
|
|
24
|
-
})
|
|
18
|
+
export const i18n: ProductI18n = defineI18n({ locales: LOCALES, defaultLocale: DEFAULT_LOCALE, timeZone: "Asia/Ho_Chi_Minh" })
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppConfirmPage } from "@/features/pages/AppConfirmPage"
|
|
2
|
+
|
|
3
|
+
/** The document title of this page. */
|
|
4
|
+
export { appConfirmMetadata as generateMetadata } from "@/features/pages/AppConfirmPage"
|
|
5
|
+
|
|
6
|
+
/** The confirm page slot: Next hands the query over as a promise, which the page reads for the token of the mail link. */
|
|
7
|
+
const Page = (props: Parameters<typeof AppConfirmPage>[0]) => <AppConfirmPage {...props} />
|
|
8
|
+
|
|
9
|
+
export default Page
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppForgotPage } from "@/features/pages/AppForgotPage"
|
|
2
|
+
|
|
3
|
+
/** The document title of this page. */
|
|
4
|
+
export { appForgotMetadata as generateMetadata } from "@/features/pages/AppForgotPage"
|
|
5
|
+
|
|
6
|
+
/** The forgot page slot. */
|
|
7
|
+
const Page = () => <AppForgotPage />
|
|
8
|
+
|
|
9
|
+
export default Page
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppResendPage } from "@/features/pages/AppResendPage"
|
|
2
|
+
|
|
3
|
+
/** The document title of this page. */
|
|
4
|
+
export { appResendMetadata as generateMetadata } from "@/features/pages/AppResendPage"
|
|
5
|
+
|
|
6
|
+
/** The resend page slot. */
|
|
7
|
+
const Page = () => <AppResendPage />
|
|
8
|
+
|
|
9
|
+
export default Page
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppResetPage } from "@/features/pages/AppResetPage"
|
|
2
|
+
|
|
3
|
+
/** The document title of this page. */
|
|
4
|
+
export { appResetMetadata as generateMetadata } from "@/features/pages/AppResetPage"
|
|
5
|
+
|
|
6
|
+
/** The reset page slot: Next hands the query over as a promise, which the page reads for the token of the mail link. */
|
|
7
|
+
const Page = (props: Parameters<typeof AppResetPage>[0]) => <AppResetPage {...props} />
|
|
8
|
+
|
|
9
|
+
export default Page
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppSignupPage } from "@/features/pages/AppSignupPage"
|
|
2
|
+
|
|
3
|
+
/** The document title of this page. */
|
|
4
|
+
export { appSignupMetadata as generateMetadata } from "@/features/pages/AppSignupPage"
|
|
5
|
+
|
|
6
|
+
/** The signup page slot. */
|
|
7
|
+
const Page = () => <AppSignupPage />
|
|
8
|
+
|
|
9
|
+
export default Page
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getMessages } from "next-intl/server"
|
|
3
|
-
import { notFound } from "next/navigation"
|
|
1
|
+
import { createReadLocaleSegment } from "@starci/next-i18n/layout"
|
|
4
2
|
import type { Metadata } from "next"
|
|
5
3
|
import type { ReactElement, ReactNode } from "react"
|
|
6
4
|
import { AppLayout, appLayoutMetadata } from "@/features/layouts/AppLayout"
|
|
7
|
-
import {
|
|
5
|
+
import { i18n } from "@/modules/i18n"
|
|
8
6
|
import { Providers } from "./providers"
|
|
9
7
|
import "../globals.css"
|
|
10
8
|
import "@/modules/brand"
|
|
@@ -17,16 +15,14 @@ type LayoutProps = {
|
|
|
17
15
|
/** The localized document title of this route segment. */
|
|
18
16
|
export const generateMetadata = async (props: LayoutProps): Promise<Metadata> => appLayoutMetadata((await props.params).locale)
|
|
19
17
|
|
|
20
|
-
/** The locale segment's document, providers and app chrome. */
|
|
18
|
+
/** The locale segment's document, providers and app chrome; an unknown locale is a 404. */
|
|
21
19
|
const Layout = async (props: LayoutProps): Promise<ReactElement> => {
|
|
22
|
-
const { locale } = await props.params
|
|
23
|
-
if (!hasLocale(routing.locales, locale)) notFound()
|
|
24
|
-
const messages = await getMessages()
|
|
20
|
+
const { locale, messages, timeZone } = await createReadLocaleSegment(i18n)(props.params)
|
|
25
21
|
return (
|
|
26
22
|
<AppLayout
|
|
27
23
|
locale={locale}
|
|
28
24
|
content={
|
|
29
|
-
<Providers locale={locale} messages={messages} timeZone={
|
|
25
|
+
<Providers locale={locale} messages={messages} timeZone={timeZone}>
|
|
30
26
|
{props.children}
|
|
31
27
|
</Providers>
|
|
32
28
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Button, Form, Input, Link, Text } from "@starci/grammar/common"
|
|
2
|
+
|
|
3
|
+
/** One destination under the form: a sibling door or the sign-in page. */
|
|
4
|
+
export interface EmailDoorLink {
|
|
5
|
+
readonly href: string
|
|
6
|
+
readonly label: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Copy, fields, state and action supplied by the connected email-door block. */
|
|
10
|
+
export interface EmailDoorFormBaseProps {
|
|
11
|
+
readonly props: {
|
|
12
|
+
readonly title: string
|
|
13
|
+
readonly description: string
|
|
14
|
+
/** The label of the email field, or undefined when the door takes none. */
|
|
15
|
+
readonly emailLabel: string | undefined
|
|
16
|
+
/** The label of the password field, or undefined when the door takes none. */
|
|
17
|
+
readonly passwordLabel: string | undefined
|
|
18
|
+
readonly submitLabel: string
|
|
19
|
+
readonly pending: boolean
|
|
20
|
+
/** The resolved message of the last refusal, or undefined. */
|
|
21
|
+
readonly errorMessage: string | undefined
|
|
22
|
+
/** The message shown once the back end accepted the request, or undefined while it has not. */
|
|
23
|
+
readonly doneMessage: string | undefined
|
|
24
|
+
readonly links: readonly EmailDoorLink[]
|
|
25
|
+
}
|
|
26
|
+
readonly on: { readonly submit: (input: FormData) => void }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Draws one email door (sign up, resend, forgot, reset) without reading navigation, copy or request state. */
|
|
30
|
+
export const EmailDoorFormBase = (props: EmailDoorFormBaseProps) => (
|
|
31
|
+
<>
|
|
32
|
+
{props.props.doneMessage === undefined ? (
|
|
33
|
+
<Form label={props.props.title} isPending={props.props.pending} onSubmit={props.on.submit}>
|
|
34
|
+
<Text>{props.props.description}</Text>
|
|
35
|
+
{props.props.emailLabel === undefined ? null : <Input id="email-door-email" name="email" label={props.props.emailLabel} kind="email" isRequired />}
|
|
36
|
+
{props.props.passwordLabel === undefined ? null : <Input id="email-door-password" name="password" label={props.props.passwordLabel} kind="password" isRequired />}
|
|
37
|
+
{props.props.errorMessage === undefined ? null : <Text live="assertive">{props.props.errorMessage}</Text>}
|
|
38
|
+
<Button type="submit" intent="commit" isPending={props.props.pending}>
|
|
39
|
+
{props.props.submitLabel}
|
|
40
|
+
</Button>
|
|
41
|
+
</Form>
|
|
42
|
+
) : (
|
|
43
|
+
<Text live="polite">{props.props.doneMessage}</Text>
|
|
44
|
+
)}
|
|
45
|
+
{props.props.links.map((link) => (
|
|
46
|
+
<Link key={link.href} href={link.href}>
|
|
47
|
+
{link.label}
|
|
48
|
+
</Link>
|
|
49
|
+
))}
|
|
50
|
+
</>
|
|
51
|
+
)
|