@solobrand/auth 0.0.0-stage → 0.1.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/README.md +169 -2
- package/dist/accounts/email.d.ts +4 -0
- package/dist/accounts/email.d.ts.map +1 -0
- package/dist/accounts/email.js +9 -0
- package/dist/accounts/email.js.map +1 -0
- package/dist/accounts/index.d.ts +10 -0
- package/dist/accounts/index.d.ts.map +1 -0
- package/dist/accounts/index.js +10 -0
- package/dist/accounts/index.js.map +1 -0
- package/dist/accounts/mail.d.ts +16 -0
- package/dist/accounts/mail.d.ts.map +1 -0
- package/dist/accounts/mail.js +23 -0
- package/dist/accounts/mail.js.map +1 -0
- package/dist/accounts/mailers.d.ts +17 -0
- package/dist/accounts/mailers.d.ts.map +1 -0
- package/dist/accounts/mailers.js +33 -0
- package/dist/accounts/mailers.js.map +1 -0
- package/dist/accounts/messages.d.ts +94 -0
- package/dist/accounts/messages.d.ts.map +1 -0
- package/dist/accounts/messages.js +93 -0
- package/dist/accounts/messages.js.map +1 -0
- package/dist/accounts/migrations.d.ts +22 -0
- package/dist/accounts/migrations.d.ts.map +1 -0
- package/dist/accounts/migrations.js +95 -0
- package/dist/accounts/migrations.js.map +1 -0
- package/dist/accounts/policy.d.ts +12 -0
- package/dist/accounts/policy.d.ts.map +1 -0
- package/dist/accounts/policy.js +16 -0
- package/dist/accounts/policy.js.map +1 -0
- package/dist/accounts/service.d.ts +160 -0
- package/dist/accounts/service.d.ts.map +1 -0
- package/dist/accounts/service.js +471 -0
- package/dist/accounts/service.js.map +1 -0
- package/dist/contracts.d.ts +166 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +2 -0
- package/dist/contracts.js.map +1 -0
- package/dist/credential.d.ts +26 -0
- package/dist/credential.d.ts.map +1 -0
- package/dist/credential.js +11 -0
- package/dist/credential.js.map +1 -0
- package/dist/crypto/index.d.ts +24 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/index.js +71 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/gate/gate.d.ts +67 -0
- package/dist/gate/gate.d.ts.map +1 -0
- package/dist/gate/gate.js +170 -0
- package/dist/gate/gate.js.map +1 -0
- package/dist/gate/index.d.ts +4 -0
- package/dist/gate/index.d.ts.map +1 -0
- package/dist/gate/index.js +4 -0
- package/dist/gate/index.js.map +1 -0
- package/dist/gate/middleware.d.ts +25 -0
- package/dist/gate/middleware.d.ts.map +1 -0
- package/dist/gate/middleware.js +50 -0
- package/dist/gate/middleware.js.map +1 -0
- package/dist/gate/owner.d.ts +18 -0
- package/dist/gate/owner.d.ts.map +1 -0
- package/dist/gate/owner.js +27 -0
- package/dist/gate/owner.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/passwords/common.d.ts +4 -0
- package/dist/passwords/common.d.ts.map +1 -0
- package/dist/passwords/common.js +63 -0
- package/dist/passwords/common.js.map +1 -0
- package/dist/passwords/index.d.ts +65 -0
- package/dist/passwords/index.d.ts.map +1 -0
- package/dist/passwords/index.js +105 -0
- package/dist/passwords/index.js.map +1 -0
- package/dist/provider/config.d.ts +14 -0
- package/dist/provider/config.d.ts.map +1 -0
- package/dist/provider/config.js +112 -0
- package/dist/provider/config.js.map +1 -0
- package/dist/provider/index.d.ts +58 -0
- package/dist/provider/index.d.ts.map +1 -0
- package/dist/provider/index.js +135 -0
- package/dist/provider/index.js.map +1 -0
- package/dist/provider/middleware.d.ts +44 -0
- package/dist/provider/middleware.d.ts.map +1 -0
- package/dist/provider/middleware.js +154 -0
- package/dist/provider/middleware.js.map +1 -0
- package/dist/provider/migrations.d.ts +4 -0
- package/dist/provider/migrations.d.ts.map +1 -0
- package/dist/provider/migrations.js +14 -0
- package/dist/provider/migrations.js.map +1 -0
- package/dist/provider/requests.d.ts +96 -0
- package/dist/provider/requests.d.ts.map +1 -0
- package/dist/provider/requests.js +309 -0
- package/dist/provider/requests.js.map +1 -0
- package/dist/provider/routes.d.ts +11 -0
- package/dist/provider/routes.d.ts.map +1 -0
- package/dist/provider/routes.js +36 -0
- package/dist/provider/routes.js.map +1 -0
- package/dist/provider/tokens.d.ts +10 -0
- package/dist/provider/tokens.d.ts.map +1 -0
- package/dist/provider/tokens.js +17 -0
- package/dist/provider/tokens.js.map +1 -0
- package/dist/prune.d.ts +33 -0
- package/dist/prune.d.ts.map +1 -0
- package/dist/prune.js +25 -0
- package/dist/prune.js.map +1 -0
- package/dist/sessions/cookie.d.ts +17 -0
- package/dist/sessions/cookie.d.ts.map +1 -0
- package/dist/sessions/cookie.js +41 -0
- package/dist/sessions/cookie.js.map +1 -0
- package/dist/sessions/guard.d.ts +21 -0
- package/dist/sessions/guard.d.ts.map +1 -0
- package/dist/sessions/guard.js +25 -0
- package/dist/sessions/guard.js.map +1 -0
- package/dist/sessions/index.d.ts +7 -0
- package/dist/sessions/index.d.ts.map +1 -0
- package/dist/sessions/index.js +5 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/sessions/manager.d.ts +100 -0
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/sessions/manager.js +251 -0
- package/dist/sessions/manager.js.map +1 -0
- package/dist/sessions/migration.d.ts +7 -0
- package/dist/sessions/migration.d.ts.map +1 -0
- package/dist/sessions/migration.js +24 -0
- package/dist/sessions/migration.js.map +1 -0
- package/dist/throttle/index.d.ts +40 -0
- package/dist/throttle/index.d.ts.map +1 -0
- package/dist/throttle/index.js +64 -0
- package/dist/throttle/index.js.map +1 -0
- package/dist/tokens/format.d.ts +17 -0
- package/dist/tokens/format.d.ts.map +1 -0
- package/dist/tokens/format.js +36 -0
- package/dist/tokens/format.js.map +1 -0
- package/dist/tokens/guard.d.ts +25 -0
- package/dist/tokens/guard.d.ts.map +1 -0
- package/dist/tokens/guard.js +87 -0
- package/dist/tokens/guard.js.map +1 -0
- package/dist/tokens/index.d.ts +9 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +9 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/messages.d.ts +25 -0
- package/dist/tokens/messages.d.ts.map +1 -0
- package/dist/tokens/messages.js +24 -0
- package/dist/tokens/messages.js.map +1 -0
- package/dist/tokens/middleware.d.ts +15 -0
- package/dist/tokens/middleware.d.ts.map +1 -0
- package/dist/tokens/middleware.js +35 -0
- package/dist/tokens/middleware.js.map +1 -0
- package/dist/tokens/migration.d.ts +8 -0
- package/dist/tokens/migration.d.ts.map +1 -0
- package/dist/tokens/migration.js +25 -0
- package/dist/tokens/migration.js.map +1 -0
- package/dist/tokens/shared.d.ts +45 -0
- package/dist/tokens/shared.d.ts.map +1 -0
- package/dist/tokens/shared.js +41 -0
- package/dist/tokens/shared.js.map +1 -0
- package/dist/tokens/token-manager.d.ts +32 -0
- package/dist/tokens/token-manager.d.ts.map +1 -0
- package/dist/tokens/token-manager.js +95 -0
- package/dist/tokens/token-manager.js.map +1 -0
- package/package.json +37 -4
package/README.md
CHANGED
|
@@ -1,3 +1,170 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @solobrand/auth
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Cookie sessions, scoped API tokens, registration, verification, recovery, gates and policies.
|
|
4
|
+
|
|
5
|
+
Part of the [SoloBrand framework](../../README.md). Public API: `src/contracts.ts` (frozen, see CONTRIBUTING.md).
|
|
6
|
+
|
|
7
|
+
## Usage (the app's Worker)
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createApplication } from '@solobrand/core';
|
|
11
|
+
import { createKernel } from '@solobrand/http';
|
|
12
|
+
import { authProvider, authMigrations } from '@solobrand/auth';
|
|
13
|
+
|
|
14
|
+
const app = createApplication({ env, providers: [dbProvider, authProvider({ tokens: { scopes: ['posts:read'] } })] }); // appUrl ← env.APP_URL
|
|
15
|
+
export default createKernel({ app, routes: (r) => { /* app routes… */ }, global: ['secure-headers', 'cors'] });
|
|
16
|
+
// migrations: [...authMigrations, ...appMigrations]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The provider contributes to the http `KernelRegistry`: the `/auth` routes, the middleware `auth`,
|
|
20
|
+
`verified`, `guest`, `auth.cookies`, `auth.csrf`, the factories `auth:<session|token>` and
|
|
21
|
+
`scope:<name>` (any name), and the globals `auth.cookies` → `auth.csrf` (after the app's own; list
|
|
22
|
+
them in `global` to place them yourself). Mount `/auth` elsewhere with `authRoutes(r, { prefix })`
|
|
23
|
+
(the provider then skips its mount). Opt out with `authProvider(config, { kernel: false })` and wire
|
|
24
|
+
`authRoutes` + `authMiddlewareTable(config)` by hand. `authMiddlewareMap` is deprecated and returns
|
|
25
|
+
`{}`, so old `{ ...authMiddlewareMap(config) }` spreads keep working.
|
|
26
|
+
|
|
27
|
+
Routes (all FormRequests, named `auth.*`): `POST /auth/register · login · logout · logout-all ·
|
|
28
|
+
forgot-password · reset-password · password · email/verify · email/resend`, `GET /auth/me · csrf`,
|
|
29
|
+
`GET|POST /auth/tokens`, `DELETE /auth/tokens/:id`. Middleware names: `auth`, `auth:session`,
|
|
30
|
+
`auth:token`, `verified`, `guest`, `scope:<s>`, `auth.cookies`, `auth.csrf`.
|
|
31
|
+
|
|
32
|
+
## API tokens and the gate (AUD-28)
|
|
33
|
+
|
|
34
|
+
A session carries every scope and the gate decides by the policy alone, as always. **An API
|
|
35
|
+
token is denied by the gate unless the ability declares a scope the token holds** (`createGate({
|
|
36
|
+
scopes })` / `requireScope`), **or the token holds `*`**, **or the policy check itself looks at
|
|
37
|
+
the token's scopes** (`(u) => hasScope(u, 'posts:write')`, what generated policies do). An
|
|
38
|
+
ability that declares nothing — `ownerPolicy`, `define('profile.edit', () => true)` — is
|
|
39
|
+
session-only; a `before` hook cannot admit a token there (it can still deny). `logout-all`,
|
|
40
|
+
`logout`, `password` and the token routes are session-only too: a leaked token can neither sign
|
|
41
|
+
its owner out everywhere nor mint more tokens.
|
|
42
|
+
|
|
43
|
+
## Credential version, prune, limits
|
|
44
|
+
|
|
45
|
+
- **`users.auth_version`** (migration `2026_11_28_000003_…`, after `sessions`) goes up in the
|
|
46
|
+
same batch as every new password hash. A session stores the version its login VERIFIED and is
|
|
47
|
+
refused (and deleted) when it is not the account's current one, so a login that checked the old
|
|
48
|
+
password and lands after a reset or a change gets nothing usable; the known-device row is bound
|
|
49
|
+
to the verified hash, and a re-hash or a password change only writes over the credential it
|
|
50
|
+
checked (AUD-23).
|
|
51
|
+
- **`pruneAuth(app)`** deletes idle / expired / stale-version sessions, ended `auth_attempts`
|
|
52
|
+
windows and used or expired links. The template's Worker calls it from `scheduled` (daily cron in
|
|
53
|
+
`wrangler.jsonc`) (AUD-29).
|
|
54
|
+
- **Per-source limits** (AUD-24): register, forgot-password, reset-password and the verification
|
|
55
|
+
resend count one request per IP (/64) before any hashing or mailing; 429 past
|
|
56
|
+
`throttle.maxAttempts × 4` per window. Every mail throttle counts first (AUD-25).
|
|
57
|
+
|
|
58
|
+
## Status — API tokens sub-front
|
|
59
|
+
|
|
60
|
+
Details and the full rule list: [`src/tokens/README.md`](src/tokens/README.md).
|
|
61
|
+
|
|
62
|
+
**Implemented**
|
|
63
|
+
- `api_tokens` migration (`0001_01_01_000003_…`, after `users`); `DbTokenManager` (`issue` / `revoke` /
|
|
64
|
+
`revokeAll` / `list`), `TokenGuard`, `tokenAuthMiddleware` (`auth:token`), `scopeMiddleware`
|
|
65
|
+
(`scope:<name>`), `principalHasScope`, es/en `tokenMessages`.
|
|
66
|
+
- Tokens `sb_<id>_<secret>` (32 random bytes) shown once, only SHA-256(secret) stored; lookup by id then
|
|
67
|
+
`timingSafeEqual` against the stored or a dummy hash; `Authorization: Bearer` only (query string and
|
|
68
|
+
cookies ignored); scopes declared in config (undeclared refuses `issue`, `*` only if declared) and
|
|
69
|
+
re-filtered against the config on every request; revocation and expiry immediate (unreadable expiry
|
|
70
|
+
fails closed); deleted user refused; `last_used_at` at most once per minute (conditional UPDATE).
|
|
71
|
+
|
|
72
|
+
**Tested** (tokens 56, real SQLite via `node:sqlite` behind `Database`): guessed id + wrong secret,
|
|
73
|
+
secret moved to another id, stolen hash, revoked, expired at the instant, deleted user (with and without
|
|
74
|
+
the FK cascade), scope escalation (tampered column, narrowed config, missing scope → 403), timing (same
|
|
75
|
+
crypto work on every failure path), `?token=` / cookie ignored, once-per-minute touch. Security review
|
|
76
|
+
@ `150c5a1`: no finding (security/FINDINGS.md, "Reviewed, no finding").
|
|
77
|
+
|
|
78
|
+
- `actingAs()` hook: the token guard reads http's `readTestPrincipal` first (only a `via: 'token'`
|
|
79
|
+
principal, scopes cut to the declared ones) and falls through to the bearer check on null; it never
|
|
80
|
+
authenticates without `SOLOBRAND_TESTING=1` and the matching key (tested). `readTestPrincipal: false`
|
|
81
|
+
turns it off.
|
|
82
|
+
|
|
83
|
+
**Left**
|
|
84
|
+
- Pruning old revoked/expired `api_tokens` rows: `pruneAuth` leaves them (the list shows them).
|
|
85
|
+
|
|
86
|
+
## Status — accounts + provider sub-front
|
|
87
|
+
|
|
88
|
+
**Implemented**
|
|
89
|
+
- `DatabaseAccountService` (`AccountService` over the `Database` contract, parameterized SQL):
|
|
90
|
+
register (e-mail trimmed+lowercased, unique; policy = the hasher's `checkPassword` + "not your
|
|
91
|
+
e-mail"), `attempt` (three counters — e-mail+IP, IP, account — counted atomically BEFORE the password
|
|
92
|
+
is verified, so concurrent guesses cannot slip past the lockout (SEC-006); the IP and account budgets
|
|
93
|
+
are 10× `maxAttempts`, IPv6 is bucketed by /64, a success gives the shared IP budget back and a reset
|
|
94
|
+
lifts the account lockout (SEC-007); a known device (`__Host-sb_device`, set after
|
|
95
|
+
each login, only a digest stored, bound to the password hash) skips the account counter with its own
|
|
96
|
+
budget, so a targeted lockout does not lock out the owner's browser (SEC-011); a dummy hash is verified for unknown e-mails; re-hash on
|
|
97
|
+
`needsRehash`); device trust is resolved FIRST, so a known device spends only its own budget and
|
|
98
|
+
nobody on the owner's NAT can lock it out (AUD-26),
|
|
99
|
+
verification and reset links (32 random bytes, only SHA-256 stored, single use by an atomic
|
|
100
|
+
`used_at` compare-and-set, expiring, a new link spends the older ones), `resetPassword` (one D1
|
|
101
|
+
batch: new hash + every reset link spent + every session deleted + every API token revoked),
|
|
102
|
+
`changePassword` (current password, throttled, closes sessions, revokes API tokens — AUD-27 —,
|
|
103
|
+
spends reset links), events
|
|
104
|
+
`auth.registered|login|failed|lockout|verified|password_reset|password_changed` (ids only).
|
|
105
|
+
- `Throttle` over `auth_attempts` (atomic upsert; keys are SHA-256, no e-mail/IP stored).
|
|
106
|
+
- Mails through the `Mailer` port, es/en (`messages/*.json`, mirrored in `accounts/messages.ts`):
|
|
107
|
+
verify, reset, "account already exists" (sent to the owner instead of a register error), "password
|
|
108
|
+
changed". `memoryMailer()` for tests/dev; an unconfigured default that logs no recipient or body.
|
|
109
|
+
- Migrations `users`, `email_verifications`, `password_resets`, `auth_attempts`; `authMigrations`
|
|
110
|
+
lists all six auth tables in order.
|
|
111
|
+
- `authProvider(config)` / `createAuthProvider(config, parts)`: config validated at boot (defaults ←
|
|
112
|
+
app config `auth` ← argument, section-partial, https `appUrl` except localhost); binds every
|
|
113
|
+
`authTokens` entry (the gate: one deny-by-default `createGate()` per app, policy errors logged with
|
|
114
|
+
ids only), the session/token guards (`authGuards`) and
|
|
115
|
+
`authMiddlewareToken`; es/en messages of every auth piece.
|
|
116
|
+
- Middleware: a request with `Authorization: Bearer` is judged by the token ONLY (http's `csrf`
|
|
117
|
+
exempts bearer requests, so a cookie riding along never counts); `auth:session` refuses bearer
|
|
118
|
+
requests; `auth.csrf` requires the session's token only when the session is valid; `auth.cookies`
|
|
119
|
+
is idempotent.
|
|
120
|
+
- No enumeration over HTTP: register and forgot-password answer the same status and bytes;
|
|
121
|
+
register, forgot-password and resend mail in `waitUntil` (timing says nothing), and register does
|
|
122
|
+
the same database work before answering in both branches; login answers the same body for
|
|
123
|
+
unknown e-mail and wrong password, does one hash verification and the same statements either way
|
|
124
|
+
(the device lookup always runs, AUD-30).
|
|
125
|
+
|
|
126
|
+
**Tested** (accounts 54 + provider 41, real SQLite via `node:sqlite` behind `Database`, the real
|
|
127
|
+
core Application, http Kernel and db Migrator): enumeration (status, body bytes, hash-work count,
|
|
128
|
+
PBKDF2 work counted with a `deriveBits` spy — not milliseconds, deferred mail), brute force (lockout, decay, other IP unaffected, IP spray cap, concurrent
|
|
129
|
+
guesses, account cap across /64s, NAT budget, 429 + Retry-After), the gate through `can()`, reset token reuse, concurrent reuse, reset link after password change, older
|
|
130
|
+
link after newer used, reset revokes sessions + API tokens, another user's verification link (not
|
|
131
|
+
spent, not burned), bearer + cookie on CSRF-exempt requests, token cannot mint tokens, another user's
|
|
132
|
+
token id → 404, CSRF 419 without token or with foreign Origin, config refusals, es/en sync, KernelRegistry wiring (registry only, old hand wiring
|
|
133
|
+
without duplicates, custom prefix, `kernel: false`, unknown `auth:<guard>` fails the build). Mutation
|
|
134
|
+
check: removing the bearer rule or the verification-owner rule turns those tests red.
|
|
135
|
+
|
|
136
|
+
**Left**
|
|
137
|
+
- **F5 (template/golden), whose owner is active:** `templates/app/app/kernel.ts` can drop the
|
|
138
|
+
`authRoutes(...)` call, the `...authMiddlewareMap(auth)` spread and `auth.cookies`/`auth.csrf` from
|
|
139
|
+
`global` (keep them there only to fix their order). Nothing breaks if it waits: both are now no-ops.
|
|
140
|
+
- `actingAs()` hook: wired — the guards get `readTestPrincipal` only under `testHookAllowed(env)`
|
|
141
|
+
(SEC-013, provider part); `auth.csrf` asks for the token only for a real cookie session, never for a
|
|
142
|
+
hook principal. SEC-013 is Fixed (http's `testKeyAcceptable` + this provider gate).
|
|
143
|
+
- SEC-011: the owner on a NEW device during an attack is still capped (no mailed one-time login link
|
|
144
|
+
yet); a password reset lifts it.
|
|
145
|
+
- With `verification.required` off, a caller who just registered can learn whether the address
|
|
146
|
+
pre-existed by trying to log in with their password (inherent to open registration).
|
|
147
|
+
|
|
148
|
+
TERMINADO 2026-11-28
|
|
149
|
+
|
|
150
|
+
## Status — crypto + passwords + sessions sub-front
|
|
151
|
+
|
|
152
|
+
Details in `src/sessions/README.md`.
|
|
153
|
+
|
|
154
|
+
**Implemented**: `crypto/` (randomToken ≥ 32 B base64url, sha256Hex, timingSafeEqual);
|
|
155
|
+
`Pbkdf2PasswordHasher` (`pbkdf2_sha256$it$salt$hash`, needsRehash, boot-time refusal above the
|
|
156
|
+
Workers cap of 100 000, `fakeVerify`), `checkPassword` (length, common passwords, es/en keys);
|
|
157
|
+
`DatabaseSessionManager` (`__Host-sb_session`, only SHA-256 stored, idle + absolute expiry,
|
|
158
|
+
rotation on login, `last_seen_at` ≤ once a minute, logout / logoutEverywhere / pruneExpired, CSRF
|
|
159
|
+
bound to the session; `token(ctx)` is http's `CsrfTokenSource`; the token is delivered in the
|
|
160
|
+
`X-CSRF-Token` header of the login response), `SessionGuard` (reads the `actingAs()` hook first
|
|
161
|
+
when given one), `createSessionsTable`.
|
|
162
|
+
|
|
163
|
+
**Tested**: 56 tests — fixation, stolen cookie after logout, idle/absolute expiry, tampered and
|
|
164
|
+
tossed cookies, CSRF across sessions / tampered / rotated, timing-safe compare reads every byte,
|
|
165
|
+
OpenSSL PBKDF2 vector, planted high-iteration hash, test hook off outside `SOLOBRAND_TESTING=1`.
|
|
166
|
+
|
|
167
|
+
**Left**: nothing. The provider wired the test hook into `SessionGuard` and `auth.cookies` uses
|
|
168
|
+
`clearPendingSessionCookies` (ebdf1a4). No open finding in `security/FINDINGS.md` is ours.
|
|
169
|
+
|
|
170
|
+
TERMINADO 2026-11-28
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/accounts/email.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAID,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE9C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** E-mail is the account key: trimmed and lowercased everywhere, once. */
|
|
2
|
+
export function normalizeEmail(email) {
|
|
3
|
+
return email.trim().toLowerCase();
|
|
4
|
+
}
|
|
5
|
+
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
6
|
+
export function isEmail(email) {
|
|
7
|
+
return email.length <= 255 && EMAIL.test(email);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../src/accounts/email.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,KAAK,GAAG,4BAA4B,CAAC;AAE3C,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Accounts sub-front (F3): registration, login, verification, recovery. */
|
|
2
|
+
export { DatabaseAccountService, accountEvents, toUser, ipBucket, limitAccountFlow, DEVICE_TTL_DAYS, FLOW_BUDGET_FACTOR, type AccountFlow, type AccountServiceDeps, } from './service.js';
|
|
3
|
+
export { Throttle, type ThrottleOptions } from '../throttle/index.js';
|
|
4
|
+
export { passwordProblems, type PasswordProblemDetail } from './policy.js';
|
|
5
|
+
export { normalizeEmail, isEmail } from './email.js';
|
|
6
|
+
export { renderAccountMail, type AccountMail, type AccountMailKind } from './mail.js';
|
|
7
|
+
export { accountMessages, type AccountMessageKey } from './messages.js';
|
|
8
|
+
export { accountMigrations, createUsersTable, createEmailVerificationsTable, createPasswordResetsTable, createAuthAttemptsTable, addAuthVersionColumns, } from './migrations.js';
|
|
9
|
+
export { memoryMailer, unconfiguredMailer, type MemoryMailer, type SentMail } from './mailers.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/accounts/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Accounts sub-front (F3): registration, login, verification, recovery. */
|
|
2
|
+
export { DatabaseAccountService, accountEvents, toUser, ipBucket, limitAccountFlow, DEVICE_TTL_DAYS, FLOW_BUDGET_FACTOR, } from './service.js';
|
|
3
|
+
export { Throttle } from '../throttle/index.js';
|
|
4
|
+
export { passwordProblems } from './policy.js';
|
|
5
|
+
export { normalizeEmail, isEmail } from './email.js';
|
|
6
|
+
export { renderAccountMail } from './mail.js';
|
|
7
|
+
export { accountMessages } from './messages.js';
|
|
8
|
+
export { accountMigrations, createUsersTable, createEmailVerificationsTable, createPasswordResetsTable, createAuthAttemptsTable, addAuthVersionColumns, } from './migrations.js';
|
|
9
|
+
export { memoryMailer, unconfiguredMailer } from './mailers.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/accounts/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GAGnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAwB,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAA8B,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAA0C,MAAM,WAAW,CAAC;AACtF,OAAO,EAAE,eAAe,EAA0B,MAAM,eAAe,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAoC,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Translator } from '@solobrand/core';
|
|
2
|
+
export type AccountMailKind = 'verify' | 'reset' | 'exists' | 'changed';
|
|
3
|
+
export interface AccountMail {
|
|
4
|
+
readonly subject: string;
|
|
5
|
+
readonly text: string;
|
|
6
|
+
readonly html: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Renders an account mail in the translator's locale. Every sentence is a
|
|
10
|
+
* key in `messages/{es,en}.json`; the only free value is the link, escaped.
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderAccountMail(t: Translator, kind: AccountMailKind, params: {
|
|
13
|
+
readonly url: string;
|
|
14
|
+
readonly minutes?: number;
|
|
15
|
+
}): AccountMail;
|
|
16
|
+
//# sourceMappingURL=mail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../src/accounts/mail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAKD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,CAAC,EAAE,UAAU,EACb,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1D,WAAW,CAgBb"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const escapeHtml = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
2
|
+
/**
|
|
3
|
+
* Renders an account mail in the translator's locale. Every sentence is a
|
|
4
|
+
* key in `messages/{es,en}.json`; the only free value is the link, escaped.
|
|
5
|
+
*/
|
|
6
|
+
export function renderAccountMail(t, kind, params) {
|
|
7
|
+
const subject = t.t(`auth.mail.${kind}.subject`);
|
|
8
|
+
const lines = [t.t('auth.mail.greeting'), t.t(`auth.mail.${kind}.intro`)];
|
|
9
|
+
const after = [];
|
|
10
|
+
if (params.minutes !== undefined)
|
|
11
|
+
after.push(t.t('auth.mail.expires', { minutes: params.minutes }));
|
|
12
|
+
if (kind === 'verify' || kind === 'reset')
|
|
13
|
+
after.push(t.t('auth.mail.ignore'));
|
|
14
|
+
const text = [...lines, '', params.url, '', ...after].join('\n').trimEnd() + '\n';
|
|
15
|
+
const url = escapeHtml(params.url);
|
|
16
|
+
const html = `<!doctype html><html lang="${escapeHtml(t.locale)}"><body>` +
|
|
17
|
+
lines.map((l) => `<p>${escapeHtml(l)}</p>`).join('') +
|
|
18
|
+
`<p><a href="${url}">${url}</a></p>` +
|
|
19
|
+
after.map((l) => `<p>${escapeHtml(l)}</p>`).join('') +
|
|
20
|
+
`</body></html>`;
|
|
21
|
+
return { subject, text, html };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=mail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail.js","sourceRoot":"","sources":["../../src/accounts/mail.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,GAAG,CAAC,CAAS,EAAU,EAAE,CACvC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAEtH;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,CAAa,EACb,IAAqB,EACrB,MAA2D;IAE3D,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,UAAU,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,QAAQ,CAAC,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACpG,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAE/E,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAClF,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,IAAI,GACR,8BAA8B,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU;QAC5D,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,eAAe,GAAG,KAAK,GAAG,UAAU;QACpC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,gBAAgB,CAAC;IACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Logger } from '@solobrand/core';
|
|
2
|
+
import type { Mailer } from '../contracts.js';
|
|
3
|
+
export type SentMail = Parameters<Mailer['send']>[0];
|
|
4
|
+
/** Keeps every message in memory: for tests and local development. */
|
|
5
|
+
export interface MemoryMailer extends Mailer {
|
|
6
|
+
readonly sent: SentMail[];
|
|
7
|
+
/** The last message sent to `to`, if any. */
|
|
8
|
+
last(to?: string): SentMail | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function memoryMailer(): MemoryMailer;
|
|
11
|
+
/**
|
|
12
|
+
* The default when nothing else bound `authTokens.mailer`: refuses to send and
|
|
13
|
+
* warns once per kind of call. It logs no recipient and no body (a body holds a
|
|
14
|
+
* live link). @solobrand/platform binds the real mailer.
|
|
15
|
+
*/
|
|
16
|
+
export declare function unconfiguredMailer(logger?: Logger): Mailer;
|
|
17
|
+
//# sourceMappingURL=mailers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailers.d.ts","sourceRoot":"","sources":["../../src/accounts/mailers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,MAAM,EAAe,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAErD,sEAAsE;AACtE,MAAM,WAAW,YAAa,SAAQ,MAAM;IAC1C,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC1B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;CACzC;AAED,wBAAgB,YAAY,IAAI,YAAY,CAgB3C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAO1D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ok } from '@solobrand/core';
|
|
2
|
+
export function memoryMailer() {
|
|
3
|
+
const sent = [];
|
|
4
|
+
return {
|
|
5
|
+
sent,
|
|
6
|
+
async send(message) {
|
|
7
|
+
sent.push(message);
|
|
8
|
+
return ok(undefined);
|
|
9
|
+
},
|
|
10
|
+
last(to) {
|
|
11
|
+
for (let i = sent.length - 1; i >= 0; i--) {
|
|
12
|
+
const m = sent[i];
|
|
13
|
+
if (m && (to === undefined || m.to === to))
|
|
14
|
+
return m;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The default when nothing else bound `authTokens.mailer`: refuses to send and
|
|
22
|
+
* warns once per kind of call. It logs no recipient and no body (a body holds a
|
|
23
|
+
* live link). @solobrand/platform binds the real mailer.
|
|
24
|
+
*/
|
|
25
|
+
export function unconfiguredMailer(logger) {
|
|
26
|
+
return {
|
|
27
|
+
async send() {
|
|
28
|
+
logger?.warn('auth.mailer_not_configured');
|
|
29
|
+
return { ok: false, error: { code: 'unavailable', status: 503, messageKey: 'auth.mailer_not_configured' } };
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=mailers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailers.js","sourceRoot":"","sources":["../../src/accounts/mailers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA4B,MAAM,iBAAiB,CAAC;AAY/D,MAAM,UAAU,YAAY;IAC1B,MAAM,IAAI,GAAe,EAAE,CAAC;IAC5B,OAAO;QACL,IAAI;QACJ,KAAK,CAAC,IAAI,CAAC,OAAO;YAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACnB,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,EAAE;YACL,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;oBAAE,OAAO,CAAC,CAAC;YACvD,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAe;IAChD,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,EAAE,IAAI,CAAC,4BAA4B,CAAC,CAAC;YAC3C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,4BAA4B,EAAE,EAAE,CAAC;QAC9G,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The account translations (es, en). Source of truth: `packages/auth/messages/*.json`;
|
|
3
|
+
* this module mirrors them for the runtime and a test keeps both in sync.
|
|
4
|
+
*/
|
|
5
|
+
export declare const accountMessages: {
|
|
6
|
+
readonly es: {
|
|
7
|
+
readonly "auth.failed": "Estas credenciales no coinciden con nuestros registros.";
|
|
8
|
+
readonly "auth.throttled": "Demasiados intentos. Vuelve a intentarlo en {seconds} segundos.";
|
|
9
|
+
readonly "auth.unauthenticated": "Necesitas iniciar sesión.";
|
|
10
|
+
readonly "auth.forbidden": "No tienes permiso para hacer esto.";
|
|
11
|
+
readonly "auth.guest_only": "Ya iniciaste sesión.";
|
|
12
|
+
readonly "auth.registration_closed": "El registro de cuentas nuevas está cerrado.";
|
|
13
|
+
readonly "auth.email_not_verified": "Primero verifica tu correo electrónico.";
|
|
14
|
+
readonly "auth.token_invalid": "Este enlace no es válido o ya caducó.";
|
|
15
|
+
readonly "auth.email_invalid": "Escribe un correo electrónico válido.";
|
|
16
|
+
readonly "auth.email_taken": "Este correo electrónico ya está registrado.";
|
|
17
|
+
readonly "auth.user_not_found": "No se encontró la cuenta.";
|
|
18
|
+
readonly "auth.password.required": "Escribe una contraseña.";
|
|
19
|
+
readonly "auth.password.same_as_email": "La contraseña no puede ser tu correo electrónico.";
|
|
20
|
+
readonly "auth.password.current_invalid": "La contraseña actual no es correcta.";
|
|
21
|
+
readonly "auth.register.check_email": "¡Gracias! Revisa tu correo para continuar.";
|
|
22
|
+
readonly "auth.login.ok": "Sesión iniciada.";
|
|
23
|
+
readonly "auth.logout.ok": "Sesión cerrada.";
|
|
24
|
+
readonly "auth.logout_all.ok": "Sesión cerrada en todos lados.";
|
|
25
|
+
readonly "auth.forgot.sent": "Si existe una cuenta con ese correo, te enviamos un enlace para restablecer la contraseña.";
|
|
26
|
+
readonly "auth.reset.ok": "Tu contraseña se restableció. Inicia sesión con la nueva.";
|
|
27
|
+
readonly "auth.password.changed": "Tu contraseña se cambió.";
|
|
28
|
+
readonly "auth.verify.ok": "Tu correo electrónico está verificado.";
|
|
29
|
+
readonly "auth.verify.sent": "Si tu correo aún necesita verificarse, te enviamos un enlace nuevo.";
|
|
30
|
+
readonly "auth.tokens.created": "Copia el token ahora: no se volverá a mostrar.";
|
|
31
|
+
readonly "auth.tokens.revoked": "El token se revocó.";
|
|
32
|
+
readonly "auth.tokens.not_found": "No se encontró el token.";
|
|
33
|
+
readonly "auth.mail.greeting": "Hola:";
|
|
34
|
+
readonly "auth.mail.ignore": "Si no lo pediste, puedes ignorar este mensaje.";
|
|
35
|
+
readonly "auth.mail.expires": "El enlace caduca en {minutes} minutos.";
|
|
36
|
+
readonly "auth.mail.verify.subject": "Verifica tu correo electrónico";
|
|
37
|
+
readonly "auth.mail.verify.intro": "Confirma que este correo es tuyo abriendo este enlace:";
|
|
38
|
+
readonly "auth.mail.reset.subject": "Restablece tu contraseña";
|
|
39
|
+
readonly "auth.mail.reset.intro": "Alguien pidió restablecer la contraseña de tu cuenta. Para elegir una nueva, abre este enlace:";
|
|
40
|
+
readonly "auth.mail.exists.subject": "Tu cuenta ya existe";
|
|
41
|
+
readonly "auth.mail.exists.intro": "Alguien intentó crear una cuenta con este correo, pero ya tienes una. Si fuiste tú, inicia sesión o restablece tu contraseña:";
|
|
42
|
+
readonly "auth.mail.changed.subject": "Tu contraseña se cambió";
|
|
43
|
+
readonly "auth.mail.changed.intro": "La contraseña de tu cuenta se acaba de cambiar y se cerraron todas las sesiones. Si no fuiste tú, restablécela ahora:";
|
|
44
|
+
readonly "auth.mailer_not_configured": "No hay un servicio de correo configurado.";
|
|
45
|
+
readonly "auth.config_invalid": "La configuración de auth no es válida en {path}.";
|
|
46
|
+
readonly "auth.custom_sessions_need_guard": "Un SessionManager propio necesita también su propia pieza sessionGuard.";
|
|
47
|
+
readonly "auth.deferred_failed": "Falló una tarea de cuenta en segundo plano.";
|
|
48
|
+
};
|
|
49
|
+
readonly en: {
|
|
50
|
+
readonly "auth.failed": "These credentials do not match our records.";
|
|
51
|
+
readonly "auth.throttled": "Too many attempts. Try again in {seconds} seconds.";
|
|
52
|
+
readonly "auth.unauthenticated": "You need to sign in.";
|
|
53
|
+
readonly "auth.forbidden": "You are not allowed to do this.";
|
|
54
|
+
readonly "auth.guest_only": "You are already signed in.";
|
|
55
|
+
readonly "auth.registration_closed": "Sign-up for new accounts is closed.";
|
|
56
|
+
readonly "auth.email_not_verified": "Verify your e-mail address first.";
|
|
57
|
+
readonly "auth.token_invalid": "This link is invalid or has expired.";
|
|
58
|
+
readonly "auth.email_invalid": "Enter a valid e-mail address.";
|
|
59
|
+
readonly "auth.email_taken": "This e-mail address is already registered.";
|
|
60
|
+
readonly "auth.user_not_found": "The account was not found.";
|
|
61
|
+
readonly "auth.password.required": "Enter a password.";
|
|
62
|
+
readonly "auth.password.same_as_email": "The password must not be your e-mail address.";
|
|
63
|
+
readonly "auth.password.current_invalid": "The current password is not correct.";
|
|
64
|
+
readonly "auth.register.check_email": "Thanks! Check your e-mail to continue.";
|
|
65
|
+
readonly "auth.login.ok": "Signed in.";
|
|
66
|
+
readonly "auth.logout.ok": "Signed out.";
|
|
67
|
+
readonly "auth.logout_all.ok": "Signed out everywhere.";
|
|
68
|
+
readonly "auth.forgot.sent": "If an account exists for that address, we sent a link to reset the password.";
|
|
69
|
+
readonly "auth.reset.ok": "Your password was reset. Sign in with the new one.";
|
|
70
|
+
readonly "auth.password.changed": "Your password was changed.";
|
|
71
|
+
readonly "auth.verify.ok": "Your e-mail address is verified.";
|
|
72
|
+
readonly "auth.verify.sent": "If your address still needs verifying, we sent a new link.";
|
|
73
|
+
readonly "auth.tokens.created": "Copy the token now: it will not be shown again.";
|
|
74
|
+
readonly "auth.tokens.revoked": "The token was revoked.";
|
|
75
|
+
readonly "auth.tokens.not_found": "The token was not found.";
|
|
76
|
+
readonly "auth.mail.greeting": "Hello,";
|
|
77
|
+
readonly "auth.mail.ignore": "If you did not ask for this, you can ignore this message.";
|
|
78
|
+
readonly "auth.mail.expires": "The link expires in {minutes} minutes.";
|
|
79
|
+
readonly "auth.mail.verify.subject": "Verify your e-mail address";
|
|
80
|
+
readonly "auth.mail.verify.intro": "Confirm that this address is yours by opening this link:";
|
|
81
|
+
readonly "auth.mail.reset.subject": "Reset your password";
|
|
82
|
+
readonly "auth.mail.reset.intro": "Someone asked to reset the password of your account. To choose a new one, open this link:";
|
|
83
|
+
readonly "auth.mail.exists.subject": "Your account already exists";
|
|
84
|
+
readonly "auth.mail.exists.intro": "Someone tried to create an account with this address, but you already have one. If it was you, sign in or reset your password:";
|
|
85
|
+
readonly "auth.mail.changed.subject": "Your password was changed";
|
|
86
|
+
readonly "auth.mail.changed.intro": "The password of your account was just changed and every session was closed. If it was not you, reset it now:";
|
|
87
|
+
readonly "auth.mailer_not_configured": "No mailer is configured.";
|
|
88
|
+
readonly "auth.config_invalid": "The auth configuration is invalid at {path}.";
|
|
89
|
+
readonly "auth.custom_sessions_need_guard": "A custom SessionManager needs its own sessionGuard part.";
|
|
90
|
+
readonly "auth.deferred_failed": "A background account task failed.";
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export type AccountMessageKey = keyof (typeof accountMessages)['en'];
|
|
94
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/accounts/messages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuF8C,CAAC;AAE3E,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The account translations (es, en). Source of truth: `packages/auth/messages/*.json`;
|
|
3
|
+
* this module mirrors them for the runtime and a test keeps both in sync.
|
|
4
|
+
*/
|
|
5
|
+
export const accountMessages = {
|
|
6
|
+
es: {
|
|
7
|
+
"auth.failed": "Estas credenciales no coinciden con nuestros registros.",
|
|
8
|
+
"auth.throttled": "Demasiados intentos. Vuelve a intentarlo en {seconds} segundos.",
|
|
9
|
+
"auth.unauthenticated": "Necesitas iniciar sesión.",
|
|
10
|
+
"auth.forbidden": "No tienes permiso para hacer esto.",
|
|
11
|
+
"auth.guest_only": "Ya iniciaste sesión.",
|
|
12
|
+
"auth.registration_closed": "El registro de cuentas nuevas está cerrado.",
|
|
13
|
+
"auth.email_not_verified": "Primero verifica tu correo electrónico.",
|
|
14
|
+
"auth.token_invalid": "Este enlace no es válido o ya caducó.",
|
|
15
|
+
"auth.email_invalid": "Escribe un correo electrónico válido.",
|
|
16
|
+
"auth.email_taken": "Este correo electrónico ya está registrado.",
|
|
17
|
+
"auth.user_not_found": "No se encontró la cuenta.",
|
|
18
|
+
"auth.password.required": "Escribe una contraseña.",
|
|
19
|
+
"auth.password.same_as_email": "La contraseña no puede ser tu correo electrónico.",
|
|
20
|
+
"auth.password.current_invalid": "La contraseña actual no es correcta.",
|
|
21
|
+
"auth.register.check_email": "¡Gracias! Revisa tu correo para continuar.",
|
|
22
|
+
"auth.login.ok": "Sesión iniciada.",
|
|
23
|
+
"auth.logout.ok": "Sesión cerrada.",
|
|
24
|
+
"auth.logout_all.ok": "Sesión cerrada en todos lados.",
|
|
25
|
+
"auth.forgot.sent": "Si existe una cuenta con ese correo, te enviamos un enlace para restablecer la contraseña.",
|
|
26
|
+
"auth.reset.ok": "Tu contraseña se restableció. Inicia sesión con la nueva.",
|
|
27
|
+
"auth.password.changed": "Tu contraseña se cambió.",
|
|
28
|
+
"auth.verify.ok": "Tu correo electrónico está verificado.",
|
|
29
|
+
"auth.verify.sent": "Si tu correo aún necesita verificarse, te enviamos un enlace nuevo.",
|
|
30
|
+
"auth.tokens.created": "Copia el token ahora: no se volverá a mostrar.",
|
|
31
|
+
"auth.tokens.revoked": "El token se revocó.",
|
|
32
|
+
"auth.tokens.not_found": "No se encontró el token.",
|
|
33
|
+
"auth.mail.greeting": "Hola:",
|
|
34
|
+
"auth.mail.ignore": "Si no lo pediste, puedes ignorar este mensaje.",
|
|
35
|
+
"auth.mail.expires": "El enlace caduca en {minutes} minutos.",
|
|
36
|
+
"auth.mail.verify.subject": "Verifica tu correo electrónico",
|
|
37
|
+
"auth.mail.verify.intro": "Confirma que este correo es tuyo abriendo este enlace:",
|
|
38
|
+
"auth.mail.reset.subject": "Restablece tu contraseña",
|
|
39
|
+
"auth.mail.reset.intro": "Alguien pidió restablecer la contraseña de tu cuenta. Para elegir una nueva, abre este enlace:",
|
|
40
|
+
"auth.mail.exists.subject": "Tu cuenta ya existe",
|
|
41
|
+
"auth.mail.exists.intro": "Alguien intentó crear una cuenta con este correo, pero ya tienes una. Si fuiste tú, inicia sesión o restablece tu contraseña:",
|
|
42
|
+
"auth.mail.changed.subject": "Tu contraseña se cambió",
|
|
43
|
+
"auth.mail.changed.intro": "La contraseña de tu cuenta se acaba de cambiar y se cerraron todas las sesiones. Si no fuiste tú, restablécela ahora:",
|
|
44
|
+
"auth.mailer_not_configured": "No hay un servicio de correo configurado.",
|
|
45
|
+
"auth.config_invalid": "La configuración de auth no es válida en {path}.",
|
|
46
|
+
"auth.custom_sessions_need_guard": "Un SessionManager propio necesita también su propia pieza sessionGuard.",
|
|
47
|
+
"auth.deferred_failed": "Falló una tarea de cuenta en segundo plano.",
|
|
48
|
+
},
|
|
49
|
+
en: {
|
|
50
|
+
"auth.failed": "These credentials do not match our records.",
|
|
51
|
+
"auth.throttled": "Too many attempts. Try again in {seconds} seconds.",
|
|
52
|
+
"auth.unauthenticated": "You need to sign in.",
|
|
53
|
+
"auth.forbidden": "You are not allowed to do this.",
|
|
54
|
+
"auth.guest_only": "You are already signed in.",
|
|
55
|
+
"auth.registration_closed": "Sign-up for new accounts is closed.",
|
|
56
|
+
"auth.email_not_verified": "Verify your e-mail address first.",
|
|
57
|
+
"auth.token_invalid": "This link is invalid or has expired.",
|
|
58
|
+
"auth.email_invalid": "Enter a valid e-mail address.",
|
|
59
|
+
"auth.email_taken": "This e-mail address is already registered.",
|
|
60
|
+
"auth.user_not_found": "The account was not found.",
|
|
61
|
+
"auth.password.required": "Enter a password.",
|
|
62
|
+
"auth.password.same_as_email": "The password must not be your e-mail address.",
|
|
63
|
+
"auth.password.current_invalid": "The current password is not correct.",
|
|
64
|
+
"auth.register.check_email": "Thanks! Check your e-mail to continue.",
|
|
65
|
+
"auth.login.ok": "Signed in.",
|
|
66
|
+
"auth.logout.ok": "Signed out.",
|
|
67
|
+
"auth.logout_all.ok": "Signed out everywhere.",
|
|
68
|
+
"auth.forgot.sent": "If an account exists for that address, we sent a link to reset the password.",
|
|
69
|
+
"auth.reset.ok": "Your password was reset. Sign in with the new one.",
|
|
70
|
+
"auth.password.changed": "Your password was changed.",
|
|
71
|
+
"auth.verify.ok": "Your e-mail address is verified.",
|
|
72
|
+
"auth.verify.sent": "If your address still needs verifying, we sent a new link.",
|
|
73
|
+
"auth.tokens.created": "Copy the token now: it will not be shown again.",
|
|
74
|
+
"auth.tokens.revoked": "The token was revoked.",
|
|
75
|
+
"auth.tokens.not_found": "The token was not found.",
|
|
76
|
+
"auth.mail.greeting": "Hello,",
|
|
77
|
+
"auth.mail.ignore": "If you did not ask for this, you can ignore this message.",
|
|
78
|
+
"auth.mail.expires": "The link expires in {minutes} minutes.",
|
|
79
|
+
"auth.mail.verify.subject": "Verify your e-mail address",
|
|
80
|
+
"auth.mail.verify.intro": "Confirm that this address is yours by opening this link:",
|
|
81
|
+
"auth.mail.reset.subject": "Reset your password",
|
|
82
|
+
"auth.mail.reset.intro": "Someone asked to reset the password of your account. To choose a new one, open this link:",
|
|
83
|
+
"auth.mail.exists.subject": "Your account already exists",
|
|
84
|
+
"auth.mail.exists.intro": "Someone tried to create an account with this address, but you already have one. If it was you, sign in or reset your password:",
|
|
85
|
+
"auth.mail.changed.subject": "Your password was changed",
|
|
86
|
+
"auth.mail.changed.intro": "The password of your account was just changed and every session was closed. If it was not you, reset it now:",
|
|
87
|
+
"auth.mailer_not_configured": "No mailer is configured.",
|
|
88
|
+
"auth.config_invalid": "The auth configuration is invalid at {path}.",
|
|
89
|
+
"auth.custom_sessions_need_guard": "A custom SessionManager needs its own sessionGuard part.",
|
|
90
|
+
"auth.deferred_failed": "A background account task failed.",
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/accounts/messages.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Migration } from '@solobrand/db';
|
|
2
|
+
/**
|
|
3
|
+
* The account tables. `users` runs first (every other auth table references it);
|
|
4
|
+
* the sessions and api_tokens sub-fronts own theirs, and `authMigrations`
|
|
5
|
+
* (provider) lists them all in order.
|
|
6
|
+
*/
|
|
7
|
+
export declare const createUsersTable: Migration;
|
|
8
|
+
/** Verification links: only the SHA-256 of the token is stored; single use via used_at. */
|
|
9
|
+
export declare const createEmailVerificationsTable: Migration;
|
|
10
|
+
/** Reset links: same shape as verifications. */
|
|
11
|
+
export declare const createPasswordResetsTable: Migration;
|
|
12
|
+
/** Throttle windows. `key` is a SHA-256 digest: no e-mail or IP is stored. */
|
|
13
|
+
export declare const createAuthAttemptsTable: Migration;
|
|
14
|
+
export declare const accountMigrations: readonly Migration[];
|
|
15
|
+
/**
|
|
16
|
+
* AUD-23: the credential version. `users.auth_version` goes up with every new
|
|
17
|
+
* password (same batch as the hash); a session carries the version its login
|
|
18
|
+
* verified and dies when they differ. A NEW migration, after `sessions`:
|
|
19
|
+
* applied ones are never edited.
|
|
20
|
+
*/
|
|
21
|
+
export declare const addAuthVersionColumns: Migration;
|
|
22
|
+
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/accounts/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAe9B,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,6BAA6B,EAAE,SAc3C,CAAC;AAEF,gDAAgD;AAChD,eAAO,MAAM,yBAAyB,EAAE,SAcvC,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,EAAE,SAYrC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,SAAS,SAAS,EAKjD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAcnC,CAAC"}
|