@pathmx/auth 0.5.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/LICENSE.md ADDED
@@ -0,0 +1,172 @@
1
+ # PathMX Proprietary Beta License
2
+
3
+ Version 0.1 — July 21, 2026
4
+
5
+ Copyright © 2026 DUO Interactive, LLC.
6
+ All rights reserved.
7
+
8
+ This license governs the first-party PathMX software distributed in the npm
9
+ package `@pathmx/core`, including its command-line interface, bundled
10
+ library surfaces, runtime and Player components, and accompanying
11
+ documentation (the “Software”). DUO Interactive, LLC is the “Licensor.” This
12
+ license does not cover the private PathMX source-code repository or separately
13
+ identified third-party materials.
14
+
15
+ “Project” means Paths, Sources, responses, data, and other content authored or
16
+ processed with the Software.
17
+
18
+ “Application” means software or a service created by you in which the Software
19
+ supports product-specific functionality but is not itself offered as a
20
+ general-purpose PathMX product.
21
+
22
+ “Redistributable Components” means runtime, Player, or library portions of the
23
+ Software incorporated into a Project, Application, or generated output through
24
+ ordinary use of the Software or ordinary compilation and bundling tools.
25
+
26
+ “Authorized Users” means your employees and individual contractors who use the
27
+ Software on your behalf, and your hosting, continuous-integration, and other
28
+ service providers that possess or run necessary copies solely to provide
29
+ services to you.
30
+
31
+ ## 1. Agreement
32
+
33
+ By installing, accessing, or using the Software, you agree to this license. If
34
+ you use the Software on behalf of an organization, you represent that you have
35
+ authority to accept this license for that organization. If you do not agree,
36
+ do not install or use the Software.
37
+
38
+ ## 2. License grant
39
+
40
+ Subject to this license, the Licensor grants you a non-exclusive, worldwide,
41
+ royalty-free, non-transferable, and non-sublicensable license, perpetual for
42
+ the version of the Software to which it applies unless terminated under
43
+ Section 10, to:
44
+
45
+ - install, execute, and use the Software for personal, educational,
46
+ internal-business, or commercial purposes;
47
+ - use the Software to author, integrate, build, test, serve, play, host, and
48
+ operate Projects and Applications;
49
+ - import, compile, bundle, configure, and integrate the Software through its
50
+ documented library and command-line interfaces;
51
+ - create and distribute independent Projects, Applications, plugins, and
52
+ integrations that use those interfaces without modifying the Software
53
+ itself; and
54
+ - make copies reasonably necessary for local development, testing, continuous
55
+ integration, backup, and hosted production environments.
56
+
57
+ Your Authorized Users may exercise those rights solely on your behalf. You are
58
+ responsible for their compliance with this license.
59
+
60
+ You may reproduce and distribute Redistributable Components only as
61
+ incorporated into your Project, Application, or generated output, and only when
62
+ you preserve applicable license and proprietary notices. You may host and
63
+ commercially provide access to that Project, Application, or output. You may
64
+ not distribute Redistributable Components as a standalone package or as a
65
+ general-purpose substitute for the Software.
66
+
67
+ Each lawful recipient of a Redistributable Component may execute and use that
68
+ component, display its output, and make technically necessary transitory copies
69
+ solely as incorporated into the Project, Application, or output in which they
70
+ received it. This limited recipient permission does not include a right to
71
+ extract, modify, or redistribute the component separately.
72
+
73
+ ## 3. Restrictions
74
+
75
+ Except where applicable law does not allow the restriction, you may not:
76
+
77
+ - modify, adapt, translate, or create derivative works of the Software, except
78
+ for the compilation, bundling, configuration, and integration expressly
79
+ permitted in Section 2;
80
+ - redistribute, sublicense, sell, lease, or otherwise provide the Software to
81
+ another person as a standalone package, product, or service except to an
82
+ Authorized User or as a Redistributable Component under Section 2;
83
+ - resell, rebrand, or provide the Software as a hosted or managed service that
84
+ gives third parties general-purpose access to substantial PathMX authoring,
85
+ building, serving, Player-administration, or library functionality for their
86
+ own unrelated projects;
87
+ - reverse engineer, decompile, disassemble, or otherwise attempt to derive the
88
+ source code of the Software; or
89
+ - remove or alter copyright, license, trademark, or other proprietary notices.
90
+
91
+ For clarity, the managed-service restriction does not prohibit a hosted
92
+ Project or Application in which PathMX supports the licensee's own
93
+ product-specific experience and is not itself the general-purpose product
94
+ offered to customers.
95
+
96
+ ## 4. Your content
97
+
98
+ As between you and the Licensor, you retain ownership of the Paths, Sources,
99
+ responses, data, independent application code, and other content that you
100
+ author or provide while using the Software. You are responsible for that
101
+ content and for having the rights needed to use it.
102
+
103
+ Generated output may contain Redistributable Components or third-party
104
+ materials. Your ownership of your content does not change the ownership or
105
+ license terms of those components and materials.
106
+
107
+ ## 5. Ownership and trademarks
108
+
109
+ The Software is licensed, not sold. The Licensor and its suppliers retain all
110
+ rights in the Software not expressly granted by this license. This license
111
+ does not grant permission to use the PathMX name, logos, or other marks except
112
+ as reasonably necessary to identify the Software accurately.
113
+
114
+ ## 6. Beta status and changes
115
+
116
+ The Software is a proprietary beta release. Its APIs, behavior, file formats,
117
+ and features may change or be removed without notice. The Licensor has no
118
+ obligation to provide support, maintenance, updates, continued availability,
119
+ or backward compatibility. A later version may be offered under different
120
+ license terms, including an open-source license. Different terms for a later
121
+ version do not change the license previously granted for an earlier version.
122
+
123
+ ## 7. Third-party materials
124
+
125
+ The Software and Redistributable Components may include or depend on
126
+ third-party materials governed by their own license terms. Those terms control
127
+ for the applicable third-party materials. You must preserve third-party notices
128
+ when the applicable third-party terms require it.
129
+
130
+ ## 8. Disclaimer of warranties
131
+
132
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED “AS IS” AND
133
+ “AS AVAILABLE,” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS,
134
+ IMPLIED, OR STATUTORY, INCLUDING WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
135
+ PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR THAT THE SOFTWARE WILL BE
136
+ SECURE, ERROR-FREE, OR UNINTERRUPTED.
137
+
138
+ ## 9. Limitation of liability
139
+
140
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE LICENSOR AND ITS CONTRIBUTORS,
141
+ SUPPLIERS, AND AFFILIATES WILL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
142
+ SPECIAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES, OR FOR LOSS OF DATA,
143
+ PROFITS, REVENUE, GOODWILL, OR BUSINESS OPPORTUNITY, ARISING FROM OR RELATED TO
144
+ THE SOFTWARE OR THIS LICENSE, EVEN IF ADVISED OF THE POSSIBILITY OF THOSE
145
+ DAMAGES.
146
+
147
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, THEIR TOTAL LIABILITY FOR ALL CLAIMS
148
+ ARISING FROM OR RELATED TO THE SOFTWARE OR THIS LICENSE WILL NOT EXCEED THE
149
+ GREATER OF THE AMOUNT YOU PAID FOR THE SOFTWARE DURING THE TWELVE MONTHS BEFORE
150
+ THE EVENT GIVING RISE TO THE CLAIM OR US$100.
151
+
152
+ ## 10. Termination
153
+
154
+ This license terminates if you materially breach it and do not cure the breach
155
+ within thirty days after receiving written notice from the Licensor. On
156
+ termination, you and your Authorized Users must stop using and delete your
157
+ copies of the Software. Sections 4, 5, 8, 9, 10, and 11 survive termination.
158
+ Termination does not withdraw the limited permission already granted by
159
+ Section 2 to lawful recipients of Redistributable Components distributed
160
+ before termination.
161
+
162
+ ## 11. General
163
+
164
+ If a provision of this license is unenforceable, it will be modified only to
165
+ the minimum extent necessary to make it enforceable, and the remaining
166
+ provisions will continue in effect. Failure to enforce a provision is not a
167
+ waiver. You may not assign or transfer this license without the Licensor's
168
+ written consent. The Licensor may assign this license together with ownership
169
+ of the Software to a successor owner. This license binds and benefits the
170
+ permitted successors and assigns of you and the Licensor. This license is the
171
+ entire agreement concerning the Software unless you and the Licensor have
172
+ signed a separate agreement that expressly replaces it.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # `@pathmx/auth`
2
+
3
+ Optional PathMX authentication with development Actor switching,
4
+ production magic links, isolated SQLite state, React App View Components, and
5
+ plugin-contributed administrator commands.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ bun run pmx plugins add auth
11
+ ```
12
+
13
+ ```ts
14
+ // plugins/auth/index.plugin.ts
15
+ export { default } from "@pathmx/auth"
16
+ ```
17
+
18
+ Run `pmx auth setup`, copy `.env.example` to `.env`, and set:
19
+
20
+ - `PATHMX_AUTH_MODE=magic-link`
21
+ - `PATHMX_AUTH_ORIGIN` to the exact public origin
22
+ - `PATHMX_AUTH_SECRET` to at least 32 characters
23
+ - `PATHMX_AUTH_EMAIL_FROM` and `RESEND_API_KEY`
24
+
25
+ The setup command installs the exported `AuthSetupPattern`. Different existing
26
+ files are preserved, and the resulting Sources and configuration are ordinary
27
+ user-owned project files with no runtime Pattern dependency.
28
+
29
+ Only emails authored on User Sources may receive a link. GET requests to the
30
+ confirmation page are inert; the token stays in the URL fragment and the React
31
+ client submits it once by same-origin POST.
32
+
33
+ Additional providers implement `AuthProviderFactory` and are passed with
34
+ `AuthPlugin({ providers: [...] })`. Factories receive the isolated auth
35
+ database and structured auth logger; provider resolution and `/api/auth/*`
36
+ handling compose in declaration order.
37
+
38
+ `pmx dev` binds to `127.0.0.1` because its development Actor switcher is local
39
+ administrator tooling, not authentication for a shared server. Use a production
40
+ provider when exposing PathMX through a tunnel, proxy, container port, or LAN.
41
+
42
+ ## UI
43
+
44
+ - `<x-auth-sign-in />`
45
+ - `<x-auth-confirm />`
46
+ - `<x-auth-session />`
47
+
48
+ The components render useful HTML before JavaScript, inherit the PathMX theme,
49
+ and can be restyled with ordinary repository CSS. Override `--auth-accent`,
50
+ `--auth-border`, or `--auth-surface` on `.pmx-auth`; authored attributes such as
51
+ `email-label` and `submit-label` customize sign-in copy. Advanced provider UIs
52
+ can replace the component set through `AuthPlugin({ components })`.
53
+
54
+ ## Commands
55
+
56
+ - `pmx auth setup`
57
+ - `pmx auth doctor`
58
+ - `pmx auth users list`
59
+ - `pmx auth sessions revoke-all`
package/commands.ts ADDED
@@ -0,0 +1,61 @@
1
+ import type { Command } from "commander"
2
+ import type { PluginCommandContext } from "@pathmx/core"
3
+ import { AuthSetupPattern } from "./patterns/setup.ts"
4
+ import { providersFromEnv, type AuthEnvironment } from "./providers/env.ts"
5
+
6
+ async function setup(ctx: PluginCommandContext) {
7
+ const plan = await ctx.patterns.install(AuthSetupPattern, undefined, {
8
+ conflicts: "preserve",
9
+ })
10
+ const created = plan.files.filter((file) => file.status === "create")
11
+ for (const file of created) console.log(`created ${file.destination}`)
12
+ if (!created.length)
13
+ console.log("Authentication scaffold is already present.")
14
+ }
15
+
16
+ export function registerAuthCommands(
17
+ group: Command,
18
+ ctx: PluginCommandContext,
19
+ env?: AuthEnvironment,
20
+ ) {
21
+ group
22
+ .command("setup")
23
+ .description("Scaffold auth pages and environment configuration")
24
+ .action(() => setup(ctx))
25
+
26
+ group
27
+ .command("doctor")
28
+ .description("Validate auth configuration and database access")
29
+ .action(async () => {
30
+ if (!ctx.database) throw new Error("Auth database is unavailable.")
31
+ providersFromEnv({ database: ctx.database, log: ctx.log }, env)
32
+ await ctx.database.get("SELECT 1")
33
+ console.log("Authentication configuration is ready.")
34
+ })
35
+
36
+ const users = group
37
+ .command("users")
38
+ .description("Inspect authentication users")
39
+ users
40
+ .command("list")
41
+ .description("List provisioned authentication users")
42
+ .action(async () => {
43
+ if (!ctx.database) throw new Error("Auth database is unavailable.")
44
+ const rows = await ctx.database.all<{ name: string; email: string }>(
45
+ 'SELECT name, email FROM "user" ORDER BY email',
46
+ )
47
+ for (const user of rows) console.log(`${user.email}\t${user.name}`)
48
+ })
49
+
50
+ const sessions = group
51
+ .command("sessions")
52
+ .description("Administer authentication sessions")
53
+ sessions
54
+ .command("revoke-all")
55
+ .description("Revoke every active session")
56
+ .action(async () => {
57
+ if (!ctx.database) throw new Error("Auth database is unavailable.")
58
+ const result = await ctx.database.run('DELETE FROM "session"')
59
+ console.log(`Revoked ${result.changes} sessions.`)
60
+ })
61
+ }
@@ -0,0 +1,130 @@
1
+ import { useEffect, useState, type FormEvent } from "react"
2
+ import { mountPathMXApps } from "@pathmx/react"
3
+ import "./styles.css"
4
+
5
+ type Status = "idle" | "pending" | "success" | "error"
6
+
7
+ function SignIn(props: {
8
+ endpoint: string
9
+ emailLabel: string
10
+ submitLabel: string
11
+ }) {
12
+ const [status, setStatus] = useState<Status>("idle")
13
+ async function submit(event: FormEvent<HTMLFormElement>) {
14
+ event.preventDefault()
15
+ setStatus("pending")
16
+ try {
17
+ const data = new FormData(event.currentTarget)
18
+ const email = data.get("email")
19
+ const response = await fetch(props.endpoint, {
20
+ method: "POST",
21
+ credentials: "same-origin",
22
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
23
+ body: new URLSearchParams({
24
+ email: typeof email === "string" ? email : "",
25
+ }),
26
+ })
27
+ setStatus(response.ok ? "success" : "error")
28
+ } catch {
29
+ setStatus("error")
30
+ }
31
+ }
32
+ if (status === "success") {
33
+ return <p role="status">Check your email for a sign-in link.</p>
34
+ }
35
+ return (
36
+ <form onSubmit={submit}>
37
+ <label>
38
+ {props.emailLabel}
39
+ <input name="email" type="email" autoComplete="email" required />
40
+ </label>
41
+ <button type="submit" disabled={status === "pending"}>
42
+ {status === "pending" ? "Sending…" : props.submitLabel}
43
+ </button>
44
+ {status === "error" && (
45
+ <p className="pmx-auth__error" role="alert">
46
+ We couldn’t send the link. Please try again.
47
+ </p>
48
+ )}
49
+ </form>
50
+ )
51
+ }
52
+
53
+ function Confirm({ endpoint }: { endpoint: string }) {
54
+ const [status, setStatus] = useState<"pending" | "error">("pending")
55
+ useEffect(() => {
56
+ const token = new URLSearchParams(location.hash.slice(1)).get("token")
57
+ if (!token) {
58
+ setStatus("error")
59
+ return
60
+ }
61
+ history.replaceState(null, "", `${location.pathname}${location.search}`)
62
+ void fetch(endpoint, {
63
+ method: "POST",
64
+ credentials: "same-origin",
65
+ redirect: "manual",
66
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
67
+ body: new URLSearchParams({ token }),
68
+ }).then(
69
+ (response) => {
70
+ if (!response.ok && response.type !== "opaqueredirect") {
71
+ setStatus("error")
72
+ return
73
+ }
74
+ location.replace("/")
75
+ },
76
+ () => setStatus("error"),
77
+ )
78
+ }, [endpoint])
79
+ return (
80
+ <p role={status === "error" ? "alert" : "status"}>
81
+ {status === "error"
82
+ ? "This sign-in link is invalid or has expired."
83
+ : "Confirming your sign in…"}
84
+ </p>
85
+ )
86
+ }
87
+
88
+ function Session(props: {
89
+ authenticated: boolean
90
+ name?: string
91
+ home?: string
92
+ signIn?: string
93
+ signOut?: string
94
+ }) {
95
+ if (!props.authenticated) {
96
+ return <a href={props.signIn ?? "/sign-in"}>Sign in</a>
97
+ }
98
+ return (
99
+ <>
100
+ <a href={props.home ?? "/"}>{props.name}</a>
101
+ <form method="post" action={props.signOut ?? "/api/auth/sign-out"}>
102
+ <button type="submit">Sign out</button>
103
+ </form>
104
+ </>
105
+ )
106
+ }
107
+
108
+ mountPathMXApps('[data-component="auth:sign-in"]', (element) => (
109
+ <SignIn
110
+ endpoint={element.dataset.endpoint ?? "/api/auth/magic-link/request"}
111
+ emailLabel={element.dataset.emailLabel ?? "Email address"}
112
+ submitLabel={element.dataset.submitLabel ?? "Email me a sign-in link"}
113
+ />
114
+ ))
115
+
116
+ mountPathMXApps('[data-component="auth:confirm"]', (element) => (
117
+ <Confirm
118
+ endpoint={element.dataset.endpoint ?? "/api/auth/magic-link/confirm"}
119
+ />
120
+ ))
121
+
122
+ mountPathMXApps('[data-component="auth:session"]', (element) => (
123
+ <Session
124
+ authenticated={element.dataset.authenticated === "true"}
125
+ name={element.dataset.name}
126
+ home={element.dataset.home}
127
+ signIn={element.dataset.signIn}
128
+ signOut={element.dataset.signOut}
129
+ />
130
+ ))
@@ -0,0 +1,77 @@
1
+ import { defineAppComponent, html } from "@pathmx/core"
2
+ import { authRoutes } from "../providers/magic-link.ts"
3
+
4
+ const client = new URL("./client.tsx", import.meta.url)
5
+
6
+ export const SignIn = defineAppComponent({
7
+ tag: "auth:sign-in",
8
+ client,
9
+ render(use) {
10
+ return html`<div
11
+ class="pmx-auth"
12
+ data-component="auth:sign-in"
13
+ data-endpoint="${authRoutes.requestLink}"
14
+ data-email-label="${use.props["email-label"] ?? "Email address"}"
15
+ data-submit-label="${use.props["submit-label"] ?? "Email me a sign-in link"}"
16
+ >
17
+ <form method="post" action="${authRoutes.requestLink}">
18
+ <label>
19
+ ${use.props["email-label"] ?? "Email address"}
20
+ <input name="email" type="email" autocomplete="email" required />
21
+ </label>
22
+ <button type="submit">
23
+ ${use.props["submit-label"] ?? "Email me a sign-in link"}
24
+ </button>
25
+ </form>
26
+ </div>`
27
+ },
28
+ })
29
+
30
+ export const Confirm = defineAppComponent({
31
+ tag: "auth:confirm",
32
+ client,
33
+ render() {
34
+ return html`<div
35
+ class="pmx-auth"
36
+ data-component="auth:confirm"
37
+ data-endpoint="${authRoutes.confirm}"
38
+ >
39
+ <p role="status">Confirming your sign in…</p>
40
+ </div>`
41
+ },
42
+ })
43
+
44
+ export const Session = defineAppComponent({
45
+ tag: "auth:session",
46
+ client,
47
+ render(_use, _compiled, ctx) {
48
+ if (ctx.session.type === "anonymous") {
49
+ return html`<div
50
+ class="pmx-auth pmx-auth--session"
51
+ data-component="auth:session"
52
+ data-authenticated="false"
53
+ data-sign-in="${ctx.session.signIn?.href ?? "/sign-in"}"
54
+ >
55
+ <a href="${ctx.session.signIn?.href ?? "/sign-in"}">Sign in</a>
56
+ </div>`
57
+ }
58
+ return html`<div
59
+ class="pmx-auth pmx-auth--session"
60
+ data-component="auth:session"
61
+ data-authenticated="true"
62
+ data-name="${ctx.session.actor.profile.name}"
63
+ data-home="${ctx.session.actor.home}"
64
+ data-sign-out="${ctx.session.signOut?.href ?? authRoutes.signOut}"
65
+ >
66
+ <a href="${ctx.session.actor.home}">${ctx.session.actor.profile.name}</a>
67
+ <form
68
+ method="post"
69
+ action="${ctx.session.signOut?.href ?? authRoutes.signOut}"
70
+ >
71
+ <button type="submit">Sign out</button>
72
+ </form>
73
+ </div>`
74
+ },
75
+ })
76
+
77
+ export const authComponents = Object.freeze([SignIn, Confirm, Session])
@@ -0,0 +1,62 @@
1
+ :where(.pmx-auth) {
2
+ --auth-accent: var(--pmx-color-accent, #4f46e5);
3
+ --auth-border: var(--pmx-color-border, #d4d4d8);
4
+ --auth-surface: var(--pmx-color-surface, Canvas);
5
+ display: grid;
6
+ gap: 0.75rem;
7
+ max-width: 30rem;
8
+ padding: 1rem;
9
+ border: 1px solid var(--auth-border);
10
+ border-radius: var(--pmx-radius-xl, 0.75rem);
11
+ background: var(--auth-surface);
12
+ }
13
+
14
+ :where(.pmx-auth form, .pmx-auth label) {
15
+ display: grid;
16
+ gap: 0.5rem;
17
+ }
18
+
19
+ :where(.pmx-auth input, .pmx-auth button) {
20
+ box-sizing: border-box;
21
+ min-height: 2.75rem;
22
+ padding: 0.625rem 0.75rem;
23
+ border: 1px solid var(--auth-border);
24
+ border-radius: var(--pmx-radius-md, 0.35rem);
25
+ color: var(--pmx-color-fg, CanvasText);
26
+ font: inherit;
27
+ }
28
+
29
+ :where(.pmx-auth input) {
30
+ background: var(--pmx-color-bg, Canvas);
31
+ }
32
+
33
+ :where(.pmx-auth button) {
34
+ cursor: pointer;
35
+ border-color: var(--auth-accent);
36
+ background: var(--auth-accent);
37
+ color: var(--pmx-color-bg, Canvas);
38
+ }
39
+
40
+ :where(.pmx-auth button:disabled) {
41
+ cursor: wait;
42
+ opacity: 0.65;
43
+ }
44
+
45
+ :where(.pmx-auth :focus-visible) {
46
+ outline: 2px solid var(--pmx-color-focus, var(--auth-accent));
47
+ outline-offset: 2px;
48
+ }
49
+
50
+ :where(.pmx-auth--session) {
51
+ display: flex;
52
+ align-items: center;
53
+ justify-content: space-between;
54
+ max-width: none;
55
+ padding: 0;
56
+ border: 0;
57
+ background: transparent;
58
+ }
59
+
60
+ :where(.pmx-auth__error) {
61
+ color: var(--pmx-color-danger, #b91c1c);
62
+ }
package/database.ts ADDED
@@ -0,0 +1,56 @@
1
+ import type { PluginDatabase } from "@pathmx/core"
2
+
3
+ export const authDatabase: PluginDatabase = Object.freeze({
4
+ migrations: [
5
+ {
6
+ id: "001-better-auth",
7
+ sql: `
8
+ CREATE TABLE "user" (
9
+ "id" TEXT NOT NULL PRIMARY KEY,
10
+ "name" TEXT NOT NULL,
11
+ "email" TEXT NOT NULL UNIQUE,
12
+ "emailVerified" INTEGER NOT NULL,
13
+ "image" TEXT,
14
+ "createdAt" DATE NOT NULL,
15
+ "updatedAt" DATE NOT NULL
16
+ );
17
+ CREATE TABLE "session" (
18
+ "id" TEXT NOT NULL PRIMARY KEY,
19
+ "expiresAt" DATE NOT NULL,
20
+ "token" TEXT NOT NULL UNIQUE,
21
+ "createdAt" DATE NOT NULL,
22
+ "updatedAt" DATE NOT NULL,
23
+ "ipAddress" TEXT,
24
+ "userAgent" TEXT,
25
+ "userId" TEXT NOT NULL REFERENCES "user" ("id") ON DELETE CASCADE
26
+ );
27
+ CREATE TABLE "account" (
28
+ "id" TEXT NOT NULL PRIMARY KEY,
29
+ "accountId" TEXT NOT NULL,
30
+ "providerId" TEXT NOT NULL,
31
+ "userId" TEXT NOT NULL REFERENCES "user" ("id") ON DELETE CASCADE,
32
+ "accessToken" TEXT,
33
+ "refreshToken" TEXT,
34
+ "idToken" TEXT,
35
+ "accessTokenExpiresAt" DATE,
36
+ "refreshTokenExpiresAt" DATE,
37
+ "scope" TEXT,
38
+ "password" TEXT,
39
+ "createdAt" DATE NOT NULL,
40
+ "updatedAt" DATE NOT NULL
41
+ );
42
+ CREATE TABLE "verification" (
43
+ "id" TEXT NOT NULL PRIMARY KEY,
44
+ "identifier" TEXT NOT NULL,
45
+ "value" TEXT NOT NULL,
46
+ "expiresAt" DATE NOT NULL,
47
+ "createdAt" DATE NOT NULL,
48
+ "updatedAt" DATE NOT NULL
49
+ );
50
+ CREATE INDEX "session_userId_idx" ON "session" ("userId");
51
+ CREATE INDEX "account_userId_idx" ON "account" ("userId");
52
+ CREATE INDEX "verification_identifier_idx" ON "verification" ("identifier");
53
+ `,
54
+ },
55
+ ],
56
+ })