@nxgt/janus-drizzle 0.3.2 → 0.4.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/README.md +9 -1
- package/dist/index.js +378 -303
- package/dist/index.js.map +20 -6
- package/dist/relations/context.d.ts +9 -0
- package/dist/relations/context.d.ts.map +1 -0
- package/dist/{relations.d.ts → relations/index.d.ts} +3 -3
- package/dist/relations/index.d.ts.map +1 -0
- package/dist/relations/reads.d.ts +9 -0
- package/dist/relations/reads.d.ts.map +1 -0
- package/dist/relations/tuples.d.ts +12 -0
- package/dist/relations/tuples.d.ts.map +1 -0
- package/dist/relations/writes.d.ts +7 -0
- package/dist/relations/writes.d.ts.map +1 -0
- package/dist/stores/identity-tables.d.ts +5 -0
- package/dist/stores/identity-tables.d.ts.map +1 -0
- package/dist/{stores.d.ts → stores/index.d.ts} +4 -6
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/logins.d.ts +13 -0
- package/dist/stores/logins.d.ts.map +1 -0
- package/dist/stores/records.d.ts +23 -0
- package/dist/stores/records.d.ts.map +1 -0
- package/dist/stores/sessions.d.ts +5 -0
- package/dist/stores/sessions.d.ts.map +1 -0
- package/dist/stores/tokens.d.ts +5 -0
- package/dist/stores/tokens.d.ts.map +1 -0
- package/dist/stores/users.d.ts +5 -0
- package/dist/stores/users.d.ts.map +1 -0
- package/dist/tables/columns.d.ts +22 -0
- package/dist/tables/columns.d.ts.map +1 -0
- package/dist/{tables.d.ts → tables/index.d.ts} +16 -1
- package/dist/tables/index.d.ts.map +1 -0
- package/dist/tables/logins.d.ts +74 -0
- package/dist/tables/logins.d.ts.map +1 -0
- package/dist/tables/relations.d.ts +133 -0
- package/dist/tables/relations.d.ts.map +1 -0
- package/dist/tables/sessions.d.ts +131 -0
- package/dist/tables/sessions.d.ts.map +1 -0
- package/dist/tables/tokens.d.ts +153 -0
- package/dist/tables/tokens.d.ts.map +1 -0
- package/dist/tables/users.d.ts +276 -0
- package/dist/tables/users.d.ts.map +1 -0
- package/docs/guide/migrations.md +35 -4
- package/docs/roadmap.md +6 -0
- package/docs/troubleshooting.md +21 -0
- package/package.json +3 -3
- package/dist/relations.d.ts.map +0 -1
- package/dist/stores.d.ts.map +0 -1
- package/dist/tables.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ tables.
|
|
|
101
101
|
|
|
102
102
|
| Table | Keys and indexes |
|
|
103
103
|
| --- | --- |
|
|
104
|
-
| `users` | `id` · `(id, type)` unique, for the logins' foreign key · `(type, id)` for listing · a check that a password has both its hash and its date, or neither · a check that a second factor (`second_factor_method`, `_secret`, `_confirmed_at`, `_last_step`) has its method and its secret, or none of the
|
|
104
|
+
| `users` | `id` · `(id, type)` unique, for the logins' foreign key · `(type, id)` for listing · a check that a password has both its hash and its date, or neither · a check that a second factor (`second_factor_method`, `_secret`, `_confirmed_at`, `_last_step`, `_recovery_codes`) has its method and its secret, or none of the five · a check that the method is `totp` and the last step not negative |
|
|
105
105
|
| `logins` | primary key `(type, login)`: **a login is unique per user type** · `(user_id, type)` references the user, `on delete cascade` |
|
|
106
106
|
| `sessions` | `id` · `token_hash` unique · `user_id` · `expires_at`, for `collectExpired()` |
|
|
107
107
|
| `tokens` | `token_hash` · `user_id` · a check on `kind` · `code_hash`, and `attempts`, `not null default 0`, checked `>= 0` |
|
|
@@ -116,6 +116,8 @@ requires. No secret is stored: sessions and tokens hold `sha256` of the secret,
|
|
|
116
116
|
passwords a self-describing hash, and `second_factor_secret` a TOTP secret
|
|
117
117
|
`@nxgt/janus` has already sealed with your application's key —
|
|
118
118
|
`v1.<key id>.…` — which the store keeps byte for byte.
|
|
119
|
+
`second_factor_recovery_codes` holds keyed hashes of the recovery codes, never
|
|
120
|
+
a code, in the order written; no codes are `null`, read as `[]`.
|
|
119
121
|
|
|
120
122
|
## Traps
|
|
121
123
|
|
|
@@ -131,6 +133,12 @@ passwords a self-describing hash, and `second_factor_secret` a TOTP secret
|
|
|
131
133
|
Run `bunx drizzle-kit generate`, then `bunx drizzle-kit migrate`, before
|
|
132
134
|
deploying — with `--config` naming Janus's config if it has its own.
|
|
133
135
|
[Upgrading](docs/guide/migrations.md#upgrading) shows what it writes.
|
|
136
|
+
- **Upgrading to 0.4 needs a migration too.** `users` gained
|
|
137
|
+
`second_factor_recovery_codes`, and its whole-factor check now covers it.
|
|
138
|
+
Deployed without it, every query on `users` fails with `STORE_FAILED`,
|
|
139
|
+
caused by `column "second_factor_recovery_codes" does not exist`.
|
|
140
|
+
[To 0.4](docs/guide/migrations.md#to-04-recovery-codes) shows the two
|
|
141
|
+
statements drizzle-kit writes.
|
|
134
142
|
- **Your migrations create the tables, not this package.** The core never
|
|
135
143
|
manages a schema, and the stores create nothing per request. Without the
|
|
136
144
|
exports in your schema file, the first sign-up fails with `STORE_FAILED`,
|