@softure-ai/auth 0.2.20 → 0.2.22
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 +16 -0
- package/README.md +4 -2
- package/dist/index.js +2 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +2 -1
- package/dist/schema.js.map +1 -1
- package/migrations/0008_index_invitations_foreign_keys.sql +6 -0
- package/module.json +2 -2
- package/package.json +2 -2
- package/src/index.ts +2 -2
- package/src/schema.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ Newest first. Each version lists what changed for an app that uses `@softure-ai/
|
|
|
4
4
|
production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
|
|
5
5
|
"Definition of done"). Versions before the first one below are described in their GitHub Releases (`auth@x.y.z`).
|
|
6
6
|
|
|
7
|
+
## 0.2.22
|
|
8
|
+
|
|
9
|
+
- Works with `@softure-ai/mailing` `^0.3.0` (issue #1418), the release that keys a recipient with
|
|
10
|
+
`SOFTURE_EMAIL_KEY_SECRET`: the peer range and the manifest's `dependsOn` move from mailing `^0.2` to `^0.3.0`.
|
|
11
|
+
- Migrate: when the app lists mailing, upgrade it to `^0.3.0` and set `SOFTURE_EMAIL_KEY_SECRET` (see mailing's
|
|
12
|
+
CHANGELOG). An app without mailing changes nothing.
|
|
13
|
+
|
|
14
|
+
## 0.2.21
|
|
15
|
+
|
|
16
|
+
- **The foreign keys of `auth.invitations` are indexed** (issue #1420): migration `0008` adds
|
|
17
|
+
`invitations_invited_by_idx` and `invitations_accepted_user_id_idx`, so deleting an account no longer scans
|
|
18
|
+
`auth.invitations` to set `invited_by` and `accepted_user_id` to null. Every foreign key of the auth tables now has
|
|
19
|
+
an index that starts with its column (a test guards it), so an app's "every foreign key is indexed" schema check
|
|
20
|
+
passes again.
|
|
21
|
+
- Migrate: run `softure migrate` (migration `0008` only adds the two indexes; nothing else changes).
|
|
22
|
+
|
|
7
23
|
## 0.2.20
|
|
8
24
|
|
|
9
25
|
- **Invitations by email** (issue #1406): with `auth({ invitations: { send } })` an admin invites an address with roles
|
package/README.md
CHANGED
|
@@ -773,8 +773,10 @@ module itself.
|
|
|
773
773
|
`softure migrate` applies `migrations/0001_create_users_and_sessions.sql`,
|
|
774
774
|
`0002_create_user_roles.sql`, `0003_create_password_resets.sql` and
|
|
775
775
|
`0004_index_users_created_at.sql` (an index on `users.created_at` for billing's reminder mail),
|
|
776
|
-
`0005_create_identities_and_oidc_states.sql`, `0006_add_users_display_name.sql
|
|
777
|
-
after security's.
|
|
776
|
+
`0005_create_identities_and_oidc_states.sql`, `0006_add_users_display_name.sql`, `0007_create_invitations.sql` and
|
|
777
|
+
`0008_index_invitations_foreign_keys.sql` (an index on each foreign key of `auth.invitations`) after security's. Every
|
|
778
|
+
foreign key of the auth tables has an index that starts with its column (tested), so deleting an account scans no
|
|
779
|
+
table.
|
|
778
780
|
|
|
779
781
|
- `auth.users(id uuid, email, password_hash, created_at, password_changed_at, display_name)`: the email is stored
|
|
780
782
|
trimmed and lowercased (`CHECK`), unique; the hash must be a `scrypt$…` string; `display_name` is null or the
|
package/dist/index.js
CHANGED
|
@@ -42,9 +42,9 @@ export const AUTH_RATE_LIMIT_BUCKETS = {
|
|
|
42
42
|
export const auth = defineModule({
|
|
43
43
|
manifest: {
|
|
44
44
|
id: MODULE_ID,
|
|
45
|
-
version: "0.2.
|
|
45
|
+
version: "0.2.22",
|
|
46
46
|
runtimes: ["node", "workers"],
|
|
47
|
-
dependsOn: { security: "^0.2.0", mailing: "^0.
|
|
47
|
+
dependsOn: { security: "^0.2.0", mailing: "^0.3.0?", ops: "^0.2.0?", jobs: "^0.1.1?" },
|
|
48
48
|
dbSchema: "auth",
|
|
49
49
|
tables: ["users", "sessions", "user_roles", "password_resets", "identities", "oidc_states", "invitations"],
|
|
50
50
|
env: [
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,UAAU,gDAAmB,CAAC;AAE3C,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOhB,CAAC;AAEH,gFAAgF;AAChF,eAAO,MAAM,iBAAiB;IAAK,EAAE;;;;;;;;;;;;;;;;;IAAY,KAAK;;;;;;;;;;;;;;;;;IAAe,SAAS;;;;;;;;;;;;;;;;;IAAmB,WAAW;;;;;;;;;;;;;;;;;CAAqB,CAAC;AAElI,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOnB,CAAC;AAEH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUrB,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOzB,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAatB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQrB,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWtB,CAAC"}
|
package/dist/schema.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Drizzle view of the module's tables (migrations/0001_create_users_and_sessions.sql,
|
|
2
2
|
// 0002_create_user_roles.sql, 0003_create_password_resets.sql, the users.created_at index of
|
|
3
3
|
// 0004_index_users_created_at.sql, 0005_create_identities_and_oidc_states.sql and
|
|
4
|
-
// 0006_add_users_display_name.sql
|
|
4
|
+
// 0006_add_users_display_name.sql, 0007_create_invitations.sql and the invitations foreign key indexes of
|
|
5
|
+
// 0008_index_invitations_foreign_keys.sql). The migrations are the source of truth; this file only types
|
|
5
6
|
// the queries. App tables may reference `users.id`.
|
|
6
7
|
import { pgSchema, primaryKey, text, timestamp, unique, uuid } from "drizzle-orm/pg-core";
|
|
7
8
|
export const authSchema = pgSchema("auth");
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,6FAA6F;AAC7F,kFAAkF;AAClF,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,6FAA6F;AAC7F,kFAAkF;AAClF,0GAA0G;AAC1G,yGAAyG;AACzG,oDAAoD;AACpD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE1F,MAAM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AAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- The foreign keys of auth.invitations get an index each: deleting an account sets invited_by and
|
|
2
|
+
-- accepted_user_id to null, and without an index Postgres scans the table for every deleted account.
|
|
3
|
+
-- Rollback: DROP INDEX auth.invitations_invited_by_idx, auth.invitations_accepted_user_id_idx; then
|
|
4
|
+
-- DELETE FROM softure.migrations WHERE module = 'auth' AND version = 8;
|
|
5
|
+
CREATE INDEX invitations_invited_by_idx ON invitations (invited_by);
|
|
6
|
+
CREATE INDEX invitations_accepted_user_id_idx ON invitations (accepted_user_id);
|
package/module.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.22",
|
|
4
4
|
"runtimes": ["node", "workers"],
|
|
5
|
-
"dependsOn": { "security": "^0.2.0", "mailing": "^0.
|
|
5
|
+
"dependsOn": { "security": "^0.2.0", "mailing": "^0.3.0?", "ops": "^0.2.0?", "jobs": "^0.1.1?" },
|
|
6
6
|
"dbSchema": "auth",
|
|
7
7
|
"tables": ["users", "sessions", "user_roles", "password_resets", "identities", "oidc_states", "invitations"],
|
|
8
8
|
"env": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.22",
|
|
4
4
|
"description": "SOFTURE AI auth module: users, scrypt passwords, database sessions, register with consent, login, logout, password change, roles, a proxy route guard, pages and forms for Next.js, and a password reset sender over @softure-ai/mailing, sent in the request or by a background job through @softure-ai/jobs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@softure-ai/jobs": "^0.1.1",
|
|
87
|
-
"@softure-ai/mailing": "^0.
|
|
87
|
+
"@softure-ai/mailing": "^0.3.0",
|
|
88
88
|
"@softure-ai/ops": "^0.2.0",
|
|
89
89
|
"@softure-ai/ui": "^0.3.0",
|
|
90
90
|
"drizzle-orm": "^0.45.2",
|
package/src/index.ts
CHANGED
|
@@ -48,9 +48,9 @@ export const AUTH_RATE_LIMIT_BUCKETS = {
|
|
|
48
48
|
export const auth = defineModule({
|
|
49
49
|
manifest: {
|
|
50
50
|
id: MODULE_ID,
|
|
51
|
-
version: "0.2.
|
|
51
|
+
version: "0.2.22",
|
|
52
52
|
runtimes: ["node", "workers"],
|
|
53
|
-
dependsOn: { security: "^0.2.0", mailing: "^0.
|
|
53
|
+
dependsOn: { security: "^0.2.0", mailing: "^0.3.0?", ops: "^0.2.0?", jobs: "^0.1.1?" },
|
|
54
54
|
dbSchema: "auth",
|
|
55
55
|
tables: ["users", "sessions", "user_roles", "password_resets", "identities", "oidc_states", "invitations"],
|
|
56
56
|
env: [
|
package/src/schema.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Drizzle view of the module's tables (migrations/0001_create_users_and_sessions.sql,
|
|
2
2
|
// 0002_create_user_roles.sql, 0003_create_password_resets.sql, the users.created_at index of
|
|
3
3
|
// 0004_index_users_created_at.sql, 0005_create_identities_and_oidc_states.sql and
|
|
4
|
-
// 0006_add_users_display_name.sql
|
|
4
|
+
// 0006_add_users_display_name.sql, 0007_create_invitations.sql and the invitations foreign key indexes of
|
|
5
|
+
// 0008_index_invitations_foreign_keys.sql). The migrations are the source of truth; this file only types
|
|
5
6
|
// the queries. App tables may reference `users.id`.
|
|
6
7
|
import { pgSchema, primaryKey, text, timestamp, unique, uuid } from "drizzle-orm/pg-core";
|
|
7
8
|
|