@authhero/drizzle 0.42.0 → 0.43.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.
@@ -325,10 +325,32 @@ CREATE TABLE `clients` (
325
325
  `created_at` text(35) NOT NULL,
326
326
  `updated_at` text(35) NOT NULL,
327
327
  `connections` text DEFAULT '[]' NOT NULL,
328
+ `owner_user_id` text(255),
329
+ `registration_type` text(32),
330
+ `registration_metadata` text,
328
331
  PRIMARY KEY(`tenant_id`, `client_id`),
329
332
  FOREIGN KEY (`tenant_id`) REFERENCES `tenants`(`id`) ON UPDATE no action ON DELETE cascade
330
333
  );
331
334
  --> statement-breakpoint
335
+ CREATE INDEX `idx_clients_owner_user_id` ON `clients` (`tenant_id`,`owner_user_id`);--> statement-breakpoint
336
+ CREATE TABLE `client_registration_tokens` (
337
+ `id` text(255) PRIMARY KEY NOT NULL,
338
+ `tenant_id` text(191) NOT NULL,
339
+ `token_hash` text(64) NOT NULL,
340
+ `type` text(8) NOT NULL,
341
+ `client_id` text(191),
342
+ `sub` text(255),
343
+ `constraints` text,
344
+ `single_use` integer DEFAULT 0 NOT NULL,
345
+ `used_at_ts` integer,
346
+ `expires_at_ts` integer,
347
+ `created_at_ts` integer NOT NULL,
348
+ `revoked_at_ts` integer,
349
+ FOREIGN KEY (`tenant_id`) REFERENCES `tenants`(`id`) ON UPDATE no action ON DELETE cascade
350
+ );
351
+ --> statement-breakpoint
352
+ CREATE INDEX `idx_client_registration_tokens_hash` ON `client_registration_tokens` (`tenant_id`,`token_hash`);--> statement-breakpoint
353
+ CREATE INDEX `idx_client_registration_tokens_client` ON `client_registration_tokens` (`tenant_id`,`client_id`);--> statement-breakpoint
332
354
  CREATE TABLE `connections` (
333
355
  `id` text(255) NOT NULL,
334
356
  `tenant_id` text(191) NOT NULL,
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.42.0",
14
+ "version": "0.43.1",
15
15
  "files": [
16
16
  "dist",
17
17
  "src/schema",
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "drizzle-orm": "^0.44.2",
36
36
  "nanoid": "^5.0.8",
37
- "@authhero/adapter-interfaces": "1.7.0"
37
+ "@authhero/adapter-interfaces": "1.9.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@hono/zod-openapi": "^0.19.2",
@@ -4,6 +4,7 @@ import {
4
4
  integer,
5
5
  primaryKey,
6
6
  index,
7
+ uniqueIndex,
7
8
  } from "drizzle-orm/sqlite-core";
8
9
  import { tenants } from "./tenants";
9
10
 
@@ -79,12 +80,46 @@ export const clients = sqliteTable(
79
80
  created_at: text("created_at", { length: 35 }).notNull(),
80
81
  updated_at: text("updated_at", { length: 35 }).notNull(),
81
82
  connections: text("connections").notNull().default("[]"),
83
+ owner_user_id: text("owner_user_id", { length: 255 }),
84
+ registration_type: text("registration_type", { length: 32 }),
85
+ registration_metadata: text("registration_metadata"),
82
86
  },
83
87
  (table) => [
84
88
  primaryKey({
85
89
  columns: [table.tenant_id, table.client_id],
86
90
  name: "clients_tenant_id_client_id",
87
91
  }),
92
+ index("idx_clients_owner_user_id").on(table.tenant_id, table.owner_user_id),
93
+ ],
94
+ );
95
+
96
+ export const clientRegistrationTokens = sqliteTable(
97
+ "client_registration_tokens",
98
+ {
99
+ id: text("id", { length: 255 }).primaryKey(),
100
+ tenant_id: text("tenant_id", { length: 191 })
101
+ .notNull()
102
+ .references(() => tenants.id, { onDelete: "cascade" }),
103
+ token_hash: text("token_hash", { length: 64 }).notNull(),
104
+ type: text("type", { length: 8 }).notNull(),
105
+ client_id: text("client_id", { length: 191 }),
106
+ sub: text("sub", { length: 255 }),
107
+ constraints: text("constraints"),
108
+ single_use: integer("single_use").notNull().default(0),
109
+ used_at_ts: integer("used_at_ts"),
110
+ expires_at_ts: integer("expires_at_ts"),
111
+ created_at_ts: integer("created_at_ts").notNull(),
112
+ revoked_at_ts: integer("revoked_at_ts"),
113
+ },
114
+ (table) => [
115
+ uniqueIndex("idx_client_registration_tokens_hash").on(
116
+ table.tenant_id,
117
+ table.token_hash,
118
+ ),
119
+ index("idx_client_registration_tokens_client").on(
120
+ table.tenant_id,
121
+ table.client_id,
122
+ ),
88
123
  ],
89
124
  );
90
125