@hogsend/db 0.19.0 → 0.20.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.
|
@@ -169,6 +169,13 @@
|
|
|
169
169
|
"when": 1781164526837,
|
|
170
170
|
"tag": "0023_semantic_tracked_links",
|
|
171
171
|
"breakpoints": true
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"idx": 24,
|
|
175
|
+
"version": "7",
|
|
176
|
+
"when": 1781282015159,
|
|
177
|
+
"tag": "0024_provider_credentials",
|
|
178
|
+
"breakpoints": true
|
|
172
179
|
}
|
|
173
180
|
]
|
|
174
181
|
}
|
package/package.json
CHANGED
package/src/schema/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./journey-configs.js";
|
|
|
17
17
|
export * from "./journey-logs.js";
|
|
18
18
|
export * from "./journey-states.js";
|
|
19
19
|
export * from "./link-clicks.js";
|
|
20
|
+
export * from "./provider-credentials.js";
|
|
20
21
|
export * from "./relations.js";
|
|
21
22
|
export * from "./tracked-links.js";
|
|
22
23
|
export * from "./user-events.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { pgTable, text, uniqueIndex, uuid } from "drizzle-orm/pg-core";
|
|
2
|
+
import { timestamps } from "./_shared.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Provider-neutral credential store (OAuth tokens today, API keys later).
|
|
6
|
+
* One row per (providerId, kind). `payload` is an AES-256-GCM blob
|
|
7
|
+
* (base64url, keyed off BETTER_AUTH_SECRET) produced by the engine's
|
|
8
|
+
* `lib/provider-credentials.ts` — NEVER plaintext JSON. It is `text`, not
|
|
9
|
+
* `jsonb`, precisely because the contents must not be queryable: tokens are
|
|
10
|
+
* opaque at the database layer by design.
|
|
11
|
+
*/
|
|
12
|
+
export const providerCredentials = pgTable(
|
|
13
|
+
"provider_credentials",
|
|
14
|
+
{
|
|
15
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
16
|
+
// e.g. "posthog" — matches an AnalyticsProvider meta.id by convention,
|
|
17
|
+
// but deliberately NOT foreign-keyed: providers are code-defined.
|
|
18
|
+
providerId: text("provider_id").notNull(),
|
|
19
|
+
// "oauth" today; "api_key" is the anticipated future kind.
|
|
20
|
+
kind: text("kind").notNull().default("oauth"),
|
|
21
|
+
// Encrypted JSON: base64url(iv || ciphertext || gcmTag).
|
|
22
|
+
payload: text("payload").notNull(),
|
|
23
|
+
...timestamps,
|
|
24
|
+
},
|
|
25
|
+
(table) => [
|
|
26
|
+
// unique-per-kind: one oauth credential per provider; a future api_key
|
|
27
|
+
// credential for the same provider coexists.
|
|
28
|
+
uniqueIndex("provider_credentials_provider_kind_idx").on(
|
|
29
|
+
table.providerId,
|
|
30
|
+
table.kind,
|
|
31
|
+
),
|
|
32
|
+
],
|
|
33
|
+
);
|