@authhero/drizzle 0.64.0 → 0.65.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.
@@ -158,7 +158,6 @@ CREATE TABLE `users` (
158
158
  );
159
159
  --> statement-breakpoint
160
160
  CREATE UNIQUE INDEX `unique_email_provider` ON `users` (`email`,`provider`,`tenant_id`);--> statement-breakpoint
161
- CREATE UNIQUE INDEX `unique_phone_provider` ON `users` (`phone_number`,`provider`,`tenant_id`);--> statement-breakpoint
162
161
  CREATE UNIQUE INDEX `unique_username_provider` ON `users` (`username`,`provider`,`tenant_id`);--> statement-breakpoint
163
162
  CREATE INDEX `users_email_index` ON `users` (`email`);--> statement-breakpoint
164
163
  CREATE INDEX `users_linked_to_index` ON `users` (`linked_to`);--> statement-breakpoint
@@ -433,6 +432,21 @@ CREATE TABLE `clients` (
433
432
  );
434
433
  --> statement-breakpoint
435
434
  CREATE INDEX `idx_clients_owner_user_id` ON `clients` (`tenant_id`,`owner_user_id`);--> statement-breakpoint
435
+ CREATE TABLE `grants` (
436
+ `id` text(21) PRIMARY KEY NOT NULL,
437
+ `tenant_id` text(255) NOT NULL,
438
+ `user_id` text(255) NOT NULL,
439
+ `client_id` text(100) NOT NULL,
440
+ `audience` text(100) DEFAULT '' NOT NULL,
441
+ `scope` text DEFAULT '[]' NOT NULL,
442
+ `created_at` text(35) NOT NULL,
443
+ `updated_at` text(35) NOT NULL,
444
+ FOREIGN KEY (`tenant_id`) REFERENCES `tenants`(`id`) ON UPDATE no action ON DELETE cascade,
445
+ FOREIGN KEY (`user_id`,`tenant_id`) REFERENCES `users`(`user_id`,`tenant_id`) ON UPDATE no action ON DELETE cascade
446
+ );
447
+ --> statement-breakpoint
448
+ CREATE UNIQUE INDEX `grants_natural_key_idx` ON `grants` (`tenant_id`,`user_id`,`client_id`,`audience`);--> statement-breakpoint
449
+ CREATE INDEX `grants_tenant_user_idx` ON `grants` (`tenant_id`,`user_id`);--> statement-breakpoint
436
450
  CREATE TABLE `connections` (
437
451
  `id` text(255) NOT NULL,
438
452
  `tenant_id` text(191) NOT NULL,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "6",
3
3
  "dialect": "sqlite",
4
- "id": "f5a5b35e-cf8e-4fe4-afe9-ec2d33b03c33",
4
+ "id": "f612da20-cbcd-43bf-819f-2d1d5a3beb5e",
5
5
  "prevId": "00000000-0000-0000-0000-000000000000",
6
6
  "tables": {
7
7
  "tenants": {
@@ -1084,15 +1084,6 @@
1084
1084
  ],
1085
1085
  "isUnique": true
1086
1086
  },
1087
- "unique_phone_provider": {
1088
- "name": "unique_phone_provider",
1089
- "columns": [
1090
- "phone_number",
1091
- "provider",
1092
- "tenant_id"
1093
- ],
1094
- "isUnique": true
1095
- },
1096
1087
  "unique_username_provider": {
1097
1088
  "name": "unique_username_provider",
1098
1089
  "columns": [
@@ -3048,6 +3039,122 @@
3048
3039
  "uniqueConstraints": {},
3049
3040
  "checkConstraints": {}
3050
3041
  },
3042
+ "grants": {
3043
+ "name": "grants",
3044
+ "columns": {
3045
+ "id": {
3046
+ "name": "id",
3047
+ "type": "text(21)",
3048
+ "primaryKey": true,
3049
+ "notNull": true,
3050
+ "autoincrement": false
3051
+ },
3052
+ "tenant_id": {
3053
+ "name": "tenant_id",
3054
+ "type": "text(255)",
3055
+ "primaryKey": false,
3056
+ "notNull": true,
3057
+ "autoincrement": false
3058
+ },
3059
+ "user_id": {
3060
+ "name": "user_id",
3061
+ "type": "text(255)",
3062
+ "primaryKey": false,
3063
+ "notNull": true,
3064
+ "autoincrement": false
3065
+ },
3066
+ "client_id": {
3067
+ "name": "client_id",
3068
+ "type": "text(100)",
3069
+ "primaryKey": false,
3070
+ "notNull": true,
3071
+ "autoincrement": false
3072
+ },
3073
+ "audience": {
3074
+ "name": "audience",
3075
+ "type": "text(100)",
3076
+ "primaryKey": false,
3077
+ "notNull": true,
3078
+ "autoincrement": false,
3079
+ "default": "''"
3080
+ },
3081
+ "scope": {
3082
+ "name": "scope",
3083
+ "type": "text",
3084
+ "primaryKey": false,
3085
+ "notNull": true,
3086
+ "autoincrement": false,
3087
+ "default": "'[]'"
3088
+ },
3089
+ "created_at": {
3090
+ "name": "created_at",
3091
+ "type": "text(35)",
3092
+ "primaryKey": false,
3093
+ "notNull": true,
3094
+ "autoincrement": false
3095
+ },
3096
+ "updated_at": {
3097
+ "name": "updated_at",
3098
+ "type": "text(35)",
3099
+ "primaryKey": false,
3100
+ "notNull": true,
3101
+ "autoincrement": false
3102
+ }
3103
+ },
3104
+ "indexes": {
3105
+ "grants_natural_key_idx": {
3106
+ "name": "grants_natural_key_idx",
3107
+ "columns": [
3108
+ "tenant_id",
3109
+ "user_id",
3110
+ "client_id",
3111
+ "audience"
3112
+ ],
3113
+ "isUnique": true
3114
+ },
3115
+ "grants_tenant_user_idx": {
3116
+ "name": "grants_tenant_user_idx",
3117
+ "columns": [
3118
+ "tenant_id",
3119
+ "user_id"
3120
+ ],
3121
+ "isUnique": false
3122
+ }
3123
+ },
3124
+ "foreignKeys": {
3125
+ "grants_tenant_id_tenants_id_fk": {
3126
+ "name": "grants_tenant_id_tenants_id_fk",
3127
+ "tableFrom": "grants",
3128
+ "tableTo": "tenants",
3129
+ "columnsFrom": [
3130
+ "tenant_id"
3131
+ ],
3132
+ "columnsTo": [
3133
+ "id"
3134
+ ],
3135
+ "onDelete": "cascade",
3136
+ "onUpdate": "no action"
3137
+ },
3138
+ "grants_user_id_constraint": {
3139
+ "name": "grants_user_id_constraint",
3140
+ "tableFrom": "grants",
3141
+ "tableTo": "users",
3142
+ "columnsFrom": [
3143
+ "user_id",
3144
+ "tenant_id"
3145
+ ],
3146
+ "columnsTo": [
3147
+ "user_id",
3148
+ "tenant_id"
3149
+ ],
3150
+ "onDelete": "cascade",
3151
+ "onUpdate": "no action"
3152
+ }
3153
+ },
3154
+ "compositePrimaryKeys": {},
3155
+ "uniqueConstraints": {},
3156
+ "checkConstraints": {}
3157
+ },
3051
3158
  "connections": {
3052
3159
  "name": "connections",
3053
3160
  "columns": {
@@ -5,16 +5,9 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "6",
8
- "when": 1783004771436,
8
+ "when": 1784301636273,
9
9
  "tag": "0000_init",
10
10
  "breakpoints": true
11
- },
12
- {
13
- "idx": 1,
14
- "version": "6",
15
- "when": 1783242650985,
16
- "tag": "0001_next_young_avengers",
17
- "breakpoints": true
18
11
  }
19
12
  ]
20
13
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "0.64.0",
14
+ "version": "0.65.1",
15
15
  "files": [
16
16
  "dist",
17
17
  "src/schema",
@@ -35,8 +35,8 @@
35
35
  "dependencies": {
36
36
  "drizzle-orm": "^0.45.2",
37
37
  "nanoid": "^5.1.11",
38
- "@authhero/adapter-interfaces": "4.1.0",
39
- "@authhero/proxy": "0.9.4"
38
+ "@authhero/adapter-interfaces": "4.2.1",
39
+ "@authhero/proxy": "0.9.6"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@hono/zod-openapi": "^1.4.0",
@@ -69,10 +69,7 @@ export const actionVersions = sqliteTable(
69
69
  table.action_id,
70
70
  table.number,
71
71
  ),
72
- index("idx_action_versions_action_id").on(
73
- table.tenant_id,
74
- table.action_id,
75
- ),
72
+ index("idx_action_versions_action_id").on(table.tenant_id, table.action_id),
76
73
  ],
77
74
  );
78
75
 
@@ -64,11 +64,13 @@ export const users = sqliteTable(
64
64
  table.provider,
65
65
  table.tenant_id,
66
66
  ),
67
- uniqueIndex("unique_phone_provider").on(
68
- table.phone_number,
69
- table.provider,
70
- table.tenant_id,
71
- ),
67
+ // No unique index on phone_number: a phone only *identifies* a user on the
68
+ // passwordless `sms` connection; for every other provider it is ordinary
69
+ // profile data that people legitimately share (placeholder / switchboard /
70
+ // family numbers). sms-phone uniqueness is enforced at the application
71
+ // layer (Auth0-style, at lookup), not by a database constraint. This
72
+ // mirrors the kysely baseline, which carries no phone unique index either.
73
+ // See #1162. The non-unique lookup index below remains.
72
74
  uniqueIndex("unique_username_provider").on(
73
75
  table.username,
74
76
  table.provider,
@@ -1,15 +0,0 @@
1
- CREATE TABLE `grants` (
2
- `id` text(21) PRIMARY KEY NOT NULL,
3
- `tenant_id` text(255) NOT NULL,
4
- `user_id` text(255) NOT NULL,
5
- `client_id` text(100) NOT NULL,
6
- `audience` text(100) DEFAULT '' NOT NULL,
7
- `scope` text DEFAULT '[]' NOT NULL,
8
- `created_at` text(35) NOT NULL,
9
- `updated_at` text(35) NOT NULL,
10
- FOREIGN KEY (`tenant_id`) REFERENCES `tenants`(`id`) ON UPDATE no action ON DELETE cascade,
11
- FOREIGN KEY (`user_id`,`tenant_id`) REFERENCES `users`(`user_id`,`tenant_id`) ON UPDATE no action ON DELETE cascade
12
- );
13
- --> statement-breakpoint
14
- CREATE UNIQUE INDEX `grants_natural_key_idx` ON `grants` (`tenant_id`,`user_id`,`client_id`,`audience`);--> statement-breakpoint
15
- CREATE INDEX `grants_tenant_user_idx` ON `grants` (`tenant_id`,`user_id`);