hylekit 1.0.3 → 1.0.4
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/README.md +126 -59
- package/dist/bff/index.cjs +5 -139
- package/dist/bff/index.cjs.map +1 -1
- package/dist/bff/index.d.cts +2 -1
- package/dist/bff/index.d.ts +2 -1
- package/dist/bff/index.js +5 -145
- package/dist/bff/index.js.map +1 -1
- package/dist/client/index.cjs +58 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +1530 -0
- package/dist/client/index.d.ts +1530 -0
- package/dist/client/index.js +31 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/nextjs.cjs +3 -214
- package/dist/client/nextjs.cjs.map +1 -1
- package/dist/client/nextjs.d.cts +4 -97
- package/dist/client/nextjs.d.ts +4 -97
- package/dist/client/nextjs.js +2 -218
- package/dist/client/nextjs.js.map +1 -1
- package/dist/client/sveltekit.cjs +3 -201
- package/dist/client/sveltekit.cjs.map +1 -1
- package/dist/client/sveltekit.d.cts +3 -72
- package/dist/client/sveltekit.d.ts +3 -72
- package/dist/client/sveltekit.js +2 -205
- package/dist/client/sveltekit.js.map +1 -1
- package/dist/{index-DYW73KK3.d.cts → index-B-5TEr94.d.cts} +28 -2
- package/dist/{index-DYW73KK3.d.ts → index-B-5TEr94.d.ts} +28 -2
- package/dist/index.cjs +276 -262
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -3272
- package/dist/index.d.ts +110 -3272
- package/dist/index.js +270 -258
- package/dist/index.js.map +1 -1
- package/dist/server/express.cjs +71 -80
- package/dist/server/express.cjs.map +1 -1
- package/dist/server/express.d.cts +18 -6
- package/dist/server/express.d.ts +18 -6
- package/dist/server/express.js +70 -86
- package/dist/server/express.js.map +1 -1
- package/dist/server/nextjs.cjs +107 -0
- package/dist/server/nextjs.cjs.map +1 -0
- package/dist/server/nextjs.d.cts +90 -0
- package/dist/server/nextjs.d.ts +90 -0
- package/dist/server/nextjs.js +82 -0
- package/dist/server/nextjs.js.map +1 -0
- package/dist/server/sveltekit.cjs +94 -0
- package/dist/server/sveltekit.cjs.map +1 -0
- package/dist/server/sveltekit.d.cts +68 -0
- package/dist/server/sveltekit.d.ts +68 -0
- package/dist/server/sveltekit.js +69 -0
- package/dist/server/sveltekit.js.map +1 -0
- package/dist/{types-GOn9sn7-.d.ts → types-Wucl0qmN.d.cts} +1 -8
- package/dist/{types-BHiK1JUX.d.cts → types-Wucl0qmN.d.ts} +1 -8
- package/package.json +22 -6
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/client/sveltekit.ts
|
|
2
|
+
import { createAuthClient } from "better-auth/svelte";
|
|
3
|
+
var authClient = createAuthClient();
|
|
4
|
+
var client = {
|
|
5
|
+
...authClient,
|
|
6
|
+
/**
|
|
7
|
+
* Alias for signIn.
|
|
8
|
+
*/
|
|
9
|
+
login: authClient.signIn
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/client/nextjs.ts
|
|
13
|
+
import { createAuthClient as createAuthClient2 } from "better-auth/react";
|
|
14
|
+
var authClient2 = createAuthClient2();
|
|
15
|
+
var client2 = {
|
|
16
|
+
...authClient2,
|
|
17
|
+
/**
|
|
18
|
+
* Alias for signIn.
|
|
19
|
+
*/
|
|
20
|
+
login: authClient2.signIn
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/client/index.ts
|
|
24
|
+
var client3 = {
|
|
25
|
+
sveltekit: client,
|
|
26
|
+
nextjs: client2
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
client3 as client
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/sveltekit.ts","../../src/client/nextjs.ts","../../src/client/index.ts"],"sourcesContent":["import { createAuthClient } from \"better-auth/svelte\";\nexport type { SessionResult, UserInfo, SessionData } from \"./types\";\n\n// Initialize the Better Auth Client (for browser/client-side use)\nconst authClient = createAuthClient();\n\n/**\n * Client-side Auth instance.\n * Use this in your Svelte components and client-side logic.\n * This is safe to use on the client as it doesn't contain secrets.\n */\nexport const client = {\n ...authClient,\n /**\n * Alias for signIn.\n */\n login: authClient.signIn\n};\n","import { createAuthClient } from \"better-auth/react\";\nexport type { SessionResult, UserInfo, SessionData } from \"./types\";\n\n// Initialize the Better Auth Client (for browser/client-side use)\nconst authClient = createAuthClient();\n\n/**\n * Client-side Auth instance.\n * Use this in your Next.js client components.\n * This is safe to use on the client as it doesn't contain secrets.\n */\nexport const client = {\n ...authClient,\n /**\n * Alias for signIn.\n */\n login: authClient.signIn\n};\n","import { client as svelteKitClient } from \"./sveltekit\";\nimport { client as nextJsClient } from \"./nextjs\";\n\n// Client-side adapters (safe to use on client)\nexport const client = {\n sveltekit: svelteKitClient,\n nextjs: nextJsClient\n};\n\n// Shared types\nexport type {\n SessionResult,\n SessionData,\n UserInfo,\n Session,\n User,\n} from \"./types\";\n"],"mappings":";AAAA,SAAS,wBAAwB;AAIjC,IAAM,aAAa,iBAAiB;AAO7B,IAAM,SAAS;AAAA,EAClB,GAAG;AAAA;AAAA;AAAA;AAAA,EAIH,OAAO,WAAW;AACtB;;;ACjBA,SAAS,oBAAAA,yBAAwB;AAIjC,IAAMC,cAAaD,kBAAiB;AAO7B,IAAME,UAAS;AAAA,EAClB,GAAGD;AAAA;AAAA;AAAA;AAAA,EAIH,OAAOA,YAAW;AACtB;;;ACbO,IAAME,UAAS;AAAA,EAClB,WAAW;AAAA,EACX,QAAQA;AACZ;","names":["createAuthClient","authClient","client","client"]}
|
package/dist/client/nextjs.cjs
CHANGED
|
@@ -20,231 +20,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/client/nextjs.ts
|
|
21
21
|
var nextjs_exports = {};
|
|
22
22
|
__export(nextjs_exports, {
|
|
23
|
-
client: () =>
|
|
24
|
-
server: () => server
|
|
23
|
+
client: () => client
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(nextjs_exports);
|
|
27
|
-
var import_next_js = require("better-auth/next-js");
|
|
28
26
|
var import_react = require("better-auth/react");
|
|
29
|
-
var import_headers = require("next/headers");
|
|
30
|
-
|
|
31
|
-
// src/lib/auth.ts
|
|
32
|
-
var import_better_auth = require("better-auth");
|
|
33
|
-
var import_drizzle = require("better-auth/adapters/drizzle");
|
|
34
|
-
|
|
35
|
-
// src/lib/db.ts
|
|
36
|
-
var import_libsql = require("drizzle-orm/libsql");
|
|
37
|
-
var import_client = require("@libsql/client");
|
|
38
|
-
|
|
39
|
-
// src/lib/schema.ts
|
|
40
|
-
var schema_exports = {};
|
|
41
|
-
__export(schema_exports, {
|
|
42
|
-
account: () => account,
|
|
43
|
-
accountRelations: () => accountRelations,
|
|
44
|
-
session: () => session,
|
|
45
|
-
sessionRelations: () => sessionRelations,
|
|
46
|
-
user: () => user,
|
|
47
|
-
userRelations: () => userRelations,
|
|
48
|
-
verification: () => verification
|
|
49
|
-
});
|
|
50
|
-
var import_drizzle_orm = require("drizzle-orm");
|
|
51
|
-
var import_sqlite_core = require("drizzle-orm/sqlite-core");
|
|
52
|
-
var user = (0, import_sqlite_core.sqliteTable)("user", {
|
|
53
|
-
id: (0, import_sqlite_core.text)("id").primaryKey(),
|
|
54
|
-
name: (0, import_sqlite_core.text)("name").notNull(),
|
|
55
|
-
email: (0, import_sqlite_core.text)("email").notNull().unique(),
|
|
56
|
-
emailVerified: (0, import_sqlite_core.integer)("email_verified", { mode: "boolean" }).default(false).notNull(),
|
|
57
|
-
image: (0, import_sqlite_core.text)("image"),
|
|
58
|
-
createdAt: (0, import_sqlite_core.integer)("created_at", { mode: "timestamp_ms" }).default(import_drizzle_orm.sql`(cast(unixepoch('subsecond') * 1000 as integer))`).notNull(),
|
|
59
|
-
updatedAt: (0, import_sqlite_core.integer)("updated_at", { mode: "timestamp_ms" }).default(import_drizzle_orm.sql`(cast(unixepoch('subsecond') * 1000 as integer))`).$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
60
|
-
});
|
|
61
|
-
var session = (0, import_sqlite_core.sqliteTable)(
|
|
62
|
-
"session",
|
|
63
|
-
{
|
|
64
|
-
id: (0, import_sqlite_core.text)("id").primaryKey(),
|
|
65
|
-
expiresAt: (0, import_sqlite_core.integer)("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
66
|
-
token: (0, import_sqlite_core.text)("token").notNull().unique(),
|
|
67
|
-
createdAt: (0, import_sqlite_core.integer)("created_at", { mode: "timestamp_ms" }).default(import_drizzle_orm.sql`(cast(unixepoch('subsecond') * 1000 as integer))`).notNull(),
|
|
68
|
-
updatedAt: (0, import_sqlite_core.integer)("updated_at", { mode: "timestamp_ms" }).$onUpdate(() => /* @__PURE__ */ new Date()).notNull(),
|
|
69
|
-
ipAddress: (0, import_sqlite_core.text)("ip_address"),
|
|
70
|
-
userAgent: (0, import_sqlite_core.text)("user_agent"),
|
|
71
|
-
userId: (0, import_sqlite_core.text)("user_id").notNull().references(() => user.id, { onDelete: "cascade" })
|
|
72
|
-
},
|
|
73
|
-
(table) => [(0, import_sqlite_core.index)("session_userId_idx").on(table.userId)]
|
|
74
|
-
);
|
|
75
|
-
var account = (0, import_sqlite_core.sqliteTable)(
|
|
76
|
-
"account",
|
|
77
|
-
{
|
|
78
|
-
id: (0, import_sqlite_core.text)("id").primaryKey(),
|
|
79
|
-
accountId: (0, import_sqlite_core.text)("account_id").notNull(),
|
|
80
|
-
providerId: (0, import_sqlite_core.text)("provider_id").notNull(),
|
|
81
|
-
userId: (0, import_sqlite_core.text)("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
82
|
-
accessToken: (0, import_sqlite_core.text)("access_token"),
|
|
83
|
-
refreshToken: (0, import_sqlite_core.text)("refresh_token"),
|
|
84
|
-
idToken: (0, import_sqlite_core.text)("id_token"),
|
|
85
|
-
accessTokenExpiresAt: (0, import_sqlite_core.integer)("access_token_expires_at", {
|
|
86
|
-
mode: "timestamp_ms"
|
|
87
|
-
}),
|
|
88
|
-
refreshTokenExpiresAt: (0, import_sqlite_core.integer)("refresh_token_expires_at", {
|
|
89
|
-
mode: "timestamp_ms"
|
|
90
|
-
}),
|
|
91
|
-
scope: (0, import_sqlite_core.text)("scope"),
|
|
92
|
-
password: (0, import_sqlite_core.text)("password"),
|
|
93
|
-
createdAt: (0, import_sqlite_core.integer)("created_at", { mode: "timestamp_ms" }).default(import_drizzle_orm.sql`(cast(unixepoch('subsecond') * 1000 as integer))`).notNull(),
|
|
94
|
-
updatedAt: (0, import_sqlite_core.integer)("updated_at", { mode: "timestamp_ms" }).$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
95
|
-
},
|
|
96
|
-
(table) => [(0, import_sqlite_core.index)("account_userId_idx").on(table.userId)]
|
|
97
|
-
);
|
|
98
|
-
var verification = (0, import_sqlite_core.sqliteTable)(
|
|
99
|
-
"verification",
|
|
100
|
-
{
|
|
101
|
-
id: (0, import_sqlite_core.text)("id").primaryKey(),
|
|
102
|
-
identifier: (0, import_sqlite_core.text)("identifier").notNull(),
|
|
103
|
-
value: (0, import_sqlite_core.text)("value").notNull(),
|
|
104
|
-
expiresAt: (0, import_sqlite_core.integer)("expires_at", { mode: "timestamp_ms" }).notNull(),
|
|
105
|
-
createdAt: (0, import_sqlite_core.integer)("created_at", { mode: "timestamp_ms" }).default(import_drizzle_orm.sql`(cast(unixepoch('subsecond') * 1000 as integer))`).notNull(),
|
|
106
|
-
updatedAt: (0, import_sqlite_core.integer)("updated_at", { mode: "timestamp_ms" }).default(import_drizzle_orm.sql`(cast(unixepoch('subsecond') * 1000 as integer))`).$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
107
|
-
},
|
|
108
|
-
(table) => [(0, import_sqlite_core.index)("verification_identifier_idx").on(table.identifier)]
|
|
109
|
-
);
|
|
110
|
-
var userRelations = (0, import_drizzle_orm.relations)(user, ({ many }) => ({
|
|
111
|
-
sessions: many(session),
|
|
112
|
-
accounts: many(account)
|
|
113
|
-
}));
|
|
114
|
-
var sessionRelations = (0, import_drizzle_orm.relations)(session, ({ one }) => ({
|
|
115
|
-
user: one(user, {
|
|
116
|
-
fields: [session.userId],
|
|
117
|
-
references: [user.id]
|
|
118
|
-
})
|
|
119
|
-
}));
|
|
120
|
-
var accountRelations = (0, import_drizzle_orm.relations)(account, ({ one }) => ({
|
|
121
|
-
user: one(user, {
|
|
122
|
-
fields: [account.userId],
|
|
123
|
-
references: [user.id]
|
|
124
|
-
})
|
|
125
|
-
}));
|
|
126
|
-
|
|
127
|
-
// src/lib/db.ts
|
|
128
|
-
var client = (0, import_client.createClient)({
|
|
129
|
-
url: process.env.HYLE_DATABASE_URL,
|
|
130
|
-
authToken: process.env.HYLE_DATABASE_AUTH_TOKEN
|
|
131
|
-
});
|
|
132
|
-
var db = (0, import_libsql.drizzle)(client, { schema: schema_exports });
|
|
133
|
-
|
|
134
|
-
// src/lib/auth.ts
|
|
135
|
-
var auth = (0, import_better_auth.betterAuth)({
|
|
136
|
-
database: (0, import_drizzle.drizzleAdapter)(db, {
|
|
137
|
-
provider: "sqlite",
|
|
138
|
-
schema: {
|
|
139
|
-
...schema_exports
|
|
140
|
-
}
|
|
141
|
-
}),
|
|
142
|
-
baseURL: process.env.BETTER_AUTH_URL || process.env.PUBLIC_APP_URL || process.env.NEXT_PUBLIC_APP_URL,
|
|
143
|
-
secret: process.env.BETTER_AUTH_SECRET,
|
|
144
|
-
trustedOrigins: process.env.TRUSTED_ORIGINS ? process.env.TRUSTED_ORIGINS.split(",") : void 0,
|
|
145
|
-
socialProviders: {
|
|
146
|
-
google: {
|
|
147
|
-
clientId: process.env.GOOGLE_CLIENT_ID || "",
|
|
148
|
-
clientSecret: process.env.GOOGLE_CLIENT_SECRET || ""
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
session: {
|
|
152
|
-
expiresIn: 60 * 60 * 24 * 7,
|
|
153
|
-
// 7 days
|
|
154
|
-
updateAge: 60 * 60 * 24,
|
|
155
|
-
// Update session every 24 hours
|
|
156
|
-
cookieCache: {
|
|
157
|
-
enabled: true,
|
|
158
|
-
maxAge: 60 * 5
|
|
159
|
-
// 5 minutes
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// src/client/nextjs.ts
|
|
165
|
-
var handler = (0, import_next_js.toNextJsHandler)(auth);
|
|
166
27
|
var authClient = (0, import_react.createAuthClient)();
|
|
167
|
-
var
|
|
28
|
+
var client = {
|
|
168
29
|
...authClient,
|
|
169
30
|
/**
|
|
170
31
|
* Alias for signIn.
|
|
171
32
|
*/
|
|
172
33
|
login: authClient.signIn
|
|
173
34
|
};
|
|
174
|
-
var server = {
|
|
175
|
-
/**
|
|
176
|
-
* The underlying BetterAuth instance.
|
|
177
|
-
*/
|
|
178
|
-
auth,
|
|
179
|
-
/**
|
|
180
|
-
* Next.js route handler for auth routes.
|
|
181
|
-
* Place this in `app/api/auth/[...auth]/route.ts`
|
|
182
|
-
*/
|
|
183
|
-
handler: {
|
|
184
|
-
GET: handler,
|
|
185
|
-
POST: handler
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* Get session from current request headers.
|
|
189
|
-
* Use in Server Components or Route Handlers.
|
|
190
|
-
*/
|
|
191
|
-
getSession: async () => {
|
|
192
|
-
const requestHeaders = await (0, import_headers.headers)();
|
|
193
|
-
return auth.api.getSession({
|
|
194
|
-
headers: requestHeaders
|
|
195
|
-
});
|
|
196
|
-
},
|
|
197
|
-
/**
|
|
198
|
-
* Get session from specific headers.
|
|
199
|
-
* Use when you have direct access to headers.
|
|
200
|
-
*/
|
|
201
|
-
getSessionFromHeaders: async (requestHeaders) => {
|
|
202
|
-
return auth.api.getSession({
|
|
203
|
-
headers: requestHeaders
|
|
204
|
-
});
|
|
205
|
-
},
|
|
206
|
-
/**
|
|
207
|
-
* Check if user is authenticated.
|
|
208
|
-
* Use in Server Components.
|
|
209
|
-
*/
|
|
210
|
-
isAuthenticated: async () => {
|
|
211
|
-
const requestHeaders = await (0, import_headers.headers)();
|
|
212
|
-
const session2 = await auth.api.getSession({
|
|
213
|
-
headers: requestHeaders
|
|
214
|
-
});
|
|
215
|
-
return session2 !== null;
|
|
216
|
-
},
|
|
217
|
-
/**
|
|
218
|
-
* Get the current user or null.
|
|
219
|
-
* Convenience method for Server Components.
|
|
220
|
-
*/
|
|
221
|
-
getUser: async () => {
|
|
222
|
-
const requestHeaders = await (0, import_headers.headers)();
|
|
223
|
-
const session2 = await auth.api.getSession({
|
|
224
|
-
headers: requestHeaders
|
|
225
|
-
});
|
|
226
|
-
return session2?.user ?? null;
|
|
227
|
-
},
|
|
228
|
-
/**
|
|
229
|
-
* Wraps a function to ensure the user is authenticated before execution.
|
|
230
|
-
* Injects the user, session, and db into the first argument.
|
|
231
|
-
*/
|
|
232
|
-
makeAuthenticatedCall: (fn) => {
|
|
233
|
-
return async (...args) => {
|
|
234
|
-
const requestHeaders = await (0, import_headers.headers)();
|
|
235
|
-
const session2 = await auth.api.getSession({
|
|
236
|
-
headers: requestHeaders
|
|
237
|
-
});
|
|
238
|
-
if (!session2) {
|
|
239
|
-
throw new Error("Unauthorized");
|
|
240
|
-
}
|
|
241
|
-
return fn({ user: session2.user, session: session2.session, db }, ...args);
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
246
36
|
0 && (module.exports = {
|
|
247
|
-
client
|
|
248
|
-
server
|
|
37
|
+
client
|
|
249
38
|
});
|
|
250
39
|
//# sourceMappingURL=nextjs.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/nextjs.ts","../../src/lib/auth.ts","../../src/lib/db.ts","../../src/lib/schema.ts"],"sourcesContent":["import { toNextJsHandler } from \"better-auth/next-js\";\nimport { createAuthClient } from \"better-auth/react\";\nimport { headers } from \"next/headers\";\nimport { auth as betterAuthInstance } from \"../lib/auth\";\nimport { db } from \"../lib/db\";\nimport type { SessionResult, UserInfo, SessionData } from \"./types\";\n\nexport type { SessionResult, UserInfo, SessionData } from \"./types\";\n\nconst handler = toNextJsHandler(betterAuthInstance);\n\n// Initialize the Better Auth Client\nconst authClient = createAuthClient();\n\n/**\n * Client-side Auth instance.\n * @remarks\n * This export might not be usable in Next.js Client Components directly if this file\n * also imports server-only modules (like next/headers). \n * Consider creating a separate client-only file if separation is needed.\n */\nexport const client = {\n ...authClient,\n /**\n * Alias for signIn.\n */\n login: authClient.signIn\n};\n\n/**\n * Next.js Server Auth instance (App Router).\n */\nexport const server = {\n /**\n * The underlying BetterAuth instance.\n */\n auth: betterAuthInstance,\n\n /**\n * Next.js route handler for auth routes.\n * Place this in `app/api/auth/[...auth]/route.ts`\n */\n handler: {\n GET: handler,\n POST: handler,\n },\n\n /**\n * Get session from current request headers.\n * Use in Server Components or Route Handlers.\n */\n getSession: async (): Promise<SessionResult> => {\n const requestHeaders = await headers();\n return betterAuthInstance.api.getSession({\n headers: requestHeaders,\n });\n },\n\n /**\n * Get session from specific headers.\n * Use when you have direct access to headers.\n */\n getSessionFromHeaders: async (requestHeaders: Headers): Promise<SessionResult> => {\n return betterAuthInstance.api.getSession({\n headers: requestHeaders,\n });\n },\n\n /**\n * Check if user is authenticated.\n * Use in Server Components.\n */\n isAuthenticated: async (): Promise<boolean> => {\n const requestHeaders = await headers();\n const session = await betterAuthInstance.api.getSession({\n headers: requestHeaders,\n });\n return session !== null;\n },\n\n /**\n * Get the current user or null.\n * Convenience method for Server Components.\n */\n getUser: async () => {\n const requestHeaders = await headers();\n const session = await betterAuthInstance.api.getSession({\n headers: requestHeaders,\n });\n return session?.user ?? null;\n },\n\n /**\n * Wraps a function to ensure the user is authenticated before execution.\n * Injects the user, session, and db into the first argument.\n */\n makeAuthenticatedCall: <TArgs extends any[], TReturn>(\n fn: (ctx: { user: SessionData['user']; session: SessionData['session']; db: typeof db }, ...args: TArgs) => Promise<TReturn>\n ) => {\n return async (...args: TArgs): Promise<TReturn> => {\n const requestHeaders = await headers();\n const session = await betterAuthInstance.api.getSession({\n headers: requestHeaders,\n });\n if (!session) {\n throw new Error(\"Unauthorized\");\n }\n return fn({ user: session.user, session: session.session, db }, ...args);\n }\n }\n};\n","import { betterAuth } from \"better-auth\";\nimport { drizzleAdapter } from \"better-auth/adapters/drizzle\";\nimport { db } from \"./db\";\nimport * as schema from \"./schema\";\n\nexport const auth = betterAuth({\n database: drizzleAdapter(db, {\n provider: \"sqlite\",\n schema: {\n ...schema\n }\n }),\n baseURL: process.env.BETTER_AUTH_URL || process.env.PUBLIC_APP_URL || process.env.NEXT_PUBLIC_APP_URL,\n secret: process.env.BETTER_AUTH_SECRET,\n trustedOrigins: process.env.TRUSTED_ORIGINS ? process.env.TRUSTED_ORIGINS.split(\",\") : undefined,\n socialProviders: {\n google: {\n clientId: process.env.GOOGLE_CLIENT_ID || \"\",\n clientSecret: process.env.GOOGLE_CLIENT_SECRET || \"\",\n },\n },\n session: {\n expiresIn: 60 * 60 * 24 * 7, // 7 days\n updateAge: 60 * 60 * 24, // Update session every 24 hours\n cookieCache: {\n enabled: true,\n maxAge: 60 * 5, // 5 minutes\n },\n },\n});\n","import { drizzle } from \"drizzle-orm/libsql\";\nimport { createClient } from \"@libsql/client\";\nimport * as schema from \"./schema\";\n\nconst client = createClient({\n url: process.env.HYLE_DATABASE_URL!,\n authToken: process.env.HYLE_DATABASE_AUTH_TOKEN!,\n});\n\nexport const db = drizzle(client, { schema });\n","import { relations, sql } from \"drizzle-orm\";\nimport { sqliteTable, text, integer, index } from \"drizzle-orm/sqlite-core\";\n\nexport const user = sqliteTable(\"user\", {\n id: text(\"id\").primaryKey(),\n name: text(\"name\").notNull(),\n email: text(\"email\").notNull().unique(),\n emailVerified: integer(\"email_verified\", { mode: \"boolean\" })\n .default(false)\n .notNull(),\n image: text(\"image\"),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .$onUpdate(() => /* @__PURE__ */ new Date())\n .notNull(),\n});\n\nexport const session = sqliteTable(\n \"session\",\n {\n id: text(\"id\").primaryKey(),\n expiresAt: integer(\"expires_at\", { mode: \"timestamp_ms\" }).notNull(),\n token: text(\"token\").notNull().unique(),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" })\n .$onUpdate(() => /* @__PURE__ */ new Date())\n .notNull(),\n ipAddress: text(\"ip_address\"),\n userAgent: text(\"user_agent\"),\n userId: text(\"user_id\")\n .notNull()\n .references(() => user.id, { onDelete: \"cascade\" }),\n },\n (table) => [index(\"session_userId_idx\").on(table.userId)],\n);\n\nexport const account = sqliteTable(\n \"account\",\n {\n id: text(\"id\").primaryKey(),\n accountId: text(\"account_id\").notNull(),\n providerId: text(\"provider_id\").notNull(),\n userId: text(\"user_id\")\n .notNull()\n .references(() => user.id, { onDelete: \"cascade\" }),\n accessToken: text(\"access_token\"),\n refreshToken: text(\"refresh_token\"),\n idToken: text(\"id_token\"),\n accessTokenExpiresAt: integer(\"access_token_expires_at\", {\n mode: \"timestamp_ms\",\n }),\n refreshTokenExpiresAt: integer(\"refresh_token_expires_at\", {\n mode: \"timestamp_ms\",\n }),\n scope: text(\"scope\"),\n password: text(\"password\"),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" })\n .$onUpdate(() => /* @__PURE__ */ new Date())\n .notNull(),\n },\n (table) => [index(\"account_userId_idx\").on(table.userId)],\n);\n\nexport const verification = sqliteTable(\n \"verification\",\n {\n id: text(\"id\").primaryKey(),\n identifier: text(\"identifier\").notNull(),\n value: text(\"value\").notNull(),\n expiresAt: integer(\"expires_at\", { mode: \"timestamp_ms\" }).notNull(),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" })\n .default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)\n .$onUpdate(() => /* @__PURE__ */ new Date())\n .notNull(),\n },\n (table) => [index(\"verification_identifier_idx\").on(table.identifier)],\n);\n\nexport const userRelations = relations(user, ({ many }) => ({\n sessions: many(session),\n accounts: many(account),\n}));\n\nexport const sessionRelations = relations(session, ({ one }) => ({\n user: one(user, {\n fields: [session.userId],\n references: [user.id],\n }),\n}));\n\nexport const accountRelations = relations(account, ({ one }) => ({\n user: one(user, {\n fields: [account.userId],\n references: [user.id],\n }),\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA,qBAAgC;AAChC,mBAAiC;AACjC,qBAAwB;;;ACFxB,yBAA2B;AAC3B,qBAA+B;;;ACD/B,oBAAwB;AACxB,oBAA6B;;;ACD7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA+B;AAC/B,yBAAkD;AAE3C,IAAM,WAAO,gCAAY,QAAQ;AAAA,EACtC,QAAI,yBAAK,IAAI,EAAE,WAAW;AAAA,EAC1B,UAAM,yBAAK,MAAM,EAAE,QAAQ;AAAA,EAC3B,WAAO,yBAAK,OAAO,EAAE,QAAQ,EAAE,OAAO;AAAA,EACtC,mBAAe,4BAAQ,kBAAkB,EAAE,MAAM,UAAU,CAAC,EACzD,QAAQ,KAAK,EACb,QAAQ;AAAA,EACX,WAAO,yBAAK,OAAO;AAAA,EACnB,eAAW,4BAAQ,cAAc,EAAE,MAAM,eAAe,CAAC,EACtD,QAAQ,wE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,IAAI;AAAA,IAC3E;AAAA,EACJ;AACJ;","names":["client","client","session"]}
|
|
1
|
+
{"version":3,"sources":["../../src/client/nextjs.ts"],"sourcesContent":["import { createAuthClient } from \"better-auth/react\";\nexport type { SessionResult, UserInfo, SessionData } from \"./types\";\n\n// Initialize the Better Auth Client (for browser/client-side use)\nconst authClient = createAuthClient();\n\n/**\n * Client-side Auth instance.\n * Use this in your Next.js client components.\n * This is safe to use on the client as it doesn't contain secrets.\n */\nexport const client = {\n ...authClient,\n /**\n * Alias for signIn.\n */\n login: authClient.signIn\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AAIjC,IAAM,iBAAa,+BAAiB;AAO7B,IAAM,SAAS;AAAA,EAClB,GAAG;AAAA;AAAA;AAAA;AAAA,EAIH,OAAO,WAAW;AACtB;","names":[]}
|
package/dist/client/nextjs.d.cts
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import * as nanostores from 'nanostores';
|
|
2
2
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
3
3
|
import * as better_auth from 'better-auth';
|
|
4
|
-
|
|
5
|
-
export { U as UserInfo } from '../types-BHiK1JUX.cjs';
|
|
6
|
-
import '@libsql/client';
|
|
7
|
-
import 'drizzle-orm/libsql';
|
|
8
|
-
import '../schema-ph9L8QMm.cjs';
|
|
9
|
-
import 'drizzle-orm';
|
|
10
|
-
import 'drizzle-orm/sqlite-core';
|
|
4
|
+
export { a as SessionData, S as SessionResult, U as UserInfo } from '../types-Wucl0qmN.cjs';
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
* Client-side Auth instance.
|
|
14
|
-
*
|
|
15
|
-
* This
|
|
16
|
-
* also imports server-only modules (like next/headers).
|
|
17
|
-
* Consider creating a separate client-only file if separation is needed.
|
|
8
|
+
* Use this in your Next.js client components.
|
|
9
|
+
* This is safe to use on the client as it doesn't contain secrets.
|
|
18
10
|
*/
|
|
19
11
|
declare const client: {
|
|
20
12
|
/**
|
|
@@ -779,90 +771,5 @@ declare const client: {
|
|
|
779
771
|
readonly MISSING_FIELD: "Field is required";
|
|
780
772
|
};
|
|
781
773
|
};
|
|
782
|
-
/**
|
|
783
|
-
* Next.js Server Auth instance (App Router).
|
|
784
|
-
*/
|
|
785
|
-
declare const server: {
|
|
786
|
-
/**
|
|
787
|
-
* The underlying BetterAuth instance.
|
|
788
|
-
*/
|
|
789
|
-
auth: better_auth.Auth<{
|
|
790
|
-
database: (options: better_auth.BetterAuthOptions) => better_auth.DBAdapter<better_auth.BetterAuthOptions>;
|
|
791
|
-
baseURL: string | undefined;
|
|
792
|
-
secret: string | undefined;
|
|
793
|
-
trustedOrigins: string[] | undefined;
|
|
794
|
-
socialProviders: {
|
|
795
|
-
google: {
|
|
796
|
-
clientId: string;
|
|
797
|
-
clientSecret: string;
|
|
798
|
-
};
|
|
799
|
-
};
|
|
800
|
-
session: {
|
|
801
|
-
expiresIn: number;
|
|
802
|
-
updateAge: number;
|
|
803
|
-
cookieCache: {
|
|
804
|
-
enabled: true;
|
|
805
|
-
maxAge: number;
|
|
806
|
-
};
|
|
807
|
-
};
|
|
808
|
-
}>;
|
|
809
|
-
/**
|
|
810
|
-
* Next.js route handler for auth routes.
|
|
811
|
-
* Place this in `app/api/auth/[...auth]/route.ts`
|
|
812
|
-
*/
|
|
813
|
-
handler: {
|
|
814
|
-
GET: {
|
|
815
|
-
GET: (request: Request) => Promise<Response>;
|
|
816
|
-
POST: (request: Request) => Promise<Response>;
|
|
817
|
-
PATCH: (request: Request) => Promise<Response>;
|
|
818
|
-
PUT: (request: Request) => Promise<Response>;
|
|
819
|
-
DELETE: (request: Request) => Promise<Response>;
|
|
820
|
-
};
|
|
821
|
-
POST: {
|
|
822
|
-
GET: (request: Request) => Promise<Response>;
|
|
823
|
-
POST: (request: Request) => Promise<Response>;
|
|
824
|
-
PATCH: (request: Request) => Promise<Response>;
|
|
825
|
-
PUT: (request: Request) => Promise<Response>;
|
|
826
|
-
DELETE: (request: Request) => Promise<Response>;
|
|
827
|
-
};
|
|
828
|
-
};
|
|
829
|
-
/**
|
|
830
|
-
* Get session from current request headers.
|
|
831
|
-
* Use in Server Components or Route Handlers.
|
|
832
|
-
*/
|
|
833
|
-
getSession: () => Promise<SessionResult>;
|
|
834
|
-
/**
|
|
835
|
-
* Get session from specific headers.
|
|
836
|
-
* Use when you have direct access to headers.
|
|
837
|
-
*/
|
|
838
|
-
getSessionFromHeaders: (requestHeaders: Headers) => Promise<SessionResult>;
|
|
839
|
-
/**
|
|
840
|
-
* Check if user is authenticated.
|
|
841
|
-
* Use in Server Components.
|
|
842
|
-
*/
|
|
843
|
-
isAuthenticated: () => Promise<boolean>;
|
|
844
|
-
/**
|
|
845
|
-
* Get the current user or null.
|
|
846
|
-
* Convenience method for Server Components.
|
|
847
|
-
*/
|
|
848
|
-
getUser: () => Promise<{
|
|
849
|
-
id: string;
|
|
850
|
-
createdAt: Date;
|
|
851
|
-
updatedAt: Date;
|
|
852
|
-
email: string;
|
|
853
|
-
emailVerified: boolean;
|
|
854
|
-
name: string;
|
|
855
|
-
image?: string | null | undefined | undefined;
|
|
856
|
-
} | null>;
|
|
857
|
-
/**
|
|
858
|
-
* Wraps a function to ensure the user is authenticated before execution.
|
|
859
|
-
* Injects the user, session, and db into the first argument.
|
|
860
|
-
*/
|
|
861
|
-
makeAuthenticatedCall: <TArgs extends any[], TReturn>(fn: (ctx: {
|
|
862
|
-
user: SessionData["user"];
|
|
863
|
-
session: SessionData["session"];
|
|
864
|
-
db: typeof db;
|
|
865
|
-
}, ...args: TArgs) => Promise<TReturn>) => (...args: TArgs) => Promise<TReturn>;
|
|
866
|
-
};
|
|
867
774
|
|
|
868
|
-
export {
|
|
775
|
+
export { client };
|
package/dist/client/nextjs.d.ts
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import * as nanostores from 'nanostores';
|
|
2
2
|
import * as _better_fetch_fetch from '@better-fetch/fetch';
|
|
3
3
|
import * as better_auth from 'better-auth';
|
|
4
|
-
|
|
5
|
-
export { U as UserInfo } from '../types-GOn9sn7-.js';
|
|
6
|
-
import '@libsql/client';
|
|
7
|
-
import 'drizzle-orm/libsql';
|
|
8
|
-
import '../schema-ph9L8QMm.js';
|
|
9
|
-
import 'drizzle-orm';
|
|
10
|
-
import 'drizzle-orm/sqlite-core';
|
|
4
|
+
export { a as SessionData, S as SessionResult, U as UserInfo } from '../types-Wucl0qmN.js';
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
* Client-side Auth instance.
|
|
14
|
-
*
|
|
15
|
-
* This
|
|
16
|
-
* also imports server-only modules (like next/headers).
|
|
17
|
-
* Consider creating a separate client-only file if separation is needed.
|
|
8
|
+
* Use this in your Next.js client components.
|
|
9
|
+
* This is safe to use on the client as it doesn't contain secrets.
|
|
18
10
|
*/
|
|
19
11
|
declare const client: {
|
|
20
12
|
/**
|
|
@@ -779,90 +771,5 @@ declare const client: {
|
|
|
779
771
|
readonly MISSING_FIELD: "Field is required";
|
|
780
772
|
};
|
|
781
773
|
};
|
|
782
|
-
/**
|
|
783
|
-
* Next.js Server Auth instance (App Router).
|
|
784
|
-
*/
|
|
785
|
-
declare const server: {
|
|
786
|
-
/**
|
|
787
|
-
* The underlying BetterAuth instance.
|
|
788
|
-
*/
|
|
789
|
-
auth: better_auth.Auth<{
|
|
790
|
-
database: (options: better_auth.BetterAuthOptions) => better_auth.DBAdapter<better_auth.BetterAuthOptions>;
|
|
791
|
-
baseURL: string | undefined;
|
|
792
|
-
secret: string | undefined;
|
|
793
|
-
trustedOrigins: string[] | undefined;
|
|
794
|
-
socialProviders: {
|
|
795
|
-
google: {
|
|
796
|
-
clientId: string;
|
|
797
|
-
clientSecret: string;
|
|
798
|
-
};
|
|
799
|
-
};
|
|
800
|
-
session: {
|
|
801
|
-
expiresIn: number;
|
|
802
|
-
updateAge: number;
|
|
803
|
-
cookieCache: {
|
|
804
|
-
enabled: true;
|
|
805
|
-
maxAge: number;
|
|
806
|
-
};
|
|
807
|
-
};
|
|
808
|
-
}>;
|
|
809
|
-
/**
|
|
810
|
-
* Next.js route handler for auth routes.
|
|
811
|
-
* Place this in `app/api/auth/[...auth]/route.ts`
|
|
812
|
-
*/
|
|
813
|
-
handler: {
|
|
814
|
-
GET: {
|
|
815
|
-
GET: (request: Request) => Promise<Response>;
|
|
816
|
-
POST: (request: Request) => Promise<Response>;
|
|
817
|
-
PATCH: (request: Request) => Promise<Response>;
|
|
818
|
-
PUT: (request: Request) => Promise<Response>;
|
|
819
|
-
DELETE: (request: Request) => Promise<Response>;
|
|
820
|
-
};
|
|
821
|
-
POST: {
|
|
822
|
-
GET: (request: Request) => Promise<Response>;
|
|
823
|
-
POST: (request: Request) => Promise<Response>;
|
|
824
|
-
PATCH: (request: Request) => Promise<Response>;
|
|
825
|
-
PUT: (request: Request) => Promise<Response>;
|
|
826
|
-
DELETE: (request: Request) => Promise<Response>;
|
|
827
|
-
};
|
|
828
|
-
};
|
|
829
|
-
/**
|
|
830
|
-
* Get session from current request headers.
|
|
831
|
-
* Use in Server Components or Route Handlers.
|
|
832
|
-
*/
|
|
833
|
-
getSession: () => Promise<SessionResult>;
|
|
834
|
-
/**
|
|
835
|
-
* Get session from specific headers.
|
|
836
|
-
* Use when you have direct access to headers.
|
|
837
|
-
*/
|
|
838
|
-
getSessionFromHeaders: (requestHeaders: Headers) => Promise<SessionResult>;
|
|
839
|
-
/**
|
|
840
|
-
* Check if user is authenticated.
|
|
841
|
-
* Use in Server Components.
|
|
842
|
-
*/
|
|
843
|
-
isAuthenticated: () => Promise<boolean>;
|
|
844
|
-
/**
|
|
845
|
-
* Get the current user or null.
|
|
846
|
-
* Convenience method for Server Components.
|
|
847
|
-
*/
|
|
848
|
-
getUser: () => Promise<{
|
|
849
|
-
id: string;
|
|
850
|
-
createdAt: Date;
|
|
851
|
-
updatedAt: Date;
|
|
852
|
-
email: string;
|
|
853
|
-
emailVerified: boolean;
|
|
854
|
-
name: string;
|
|
855
|
-
image?: string | null | undefined | undefined;
|
|
856
|
-
} | null>;
|
|
857
|
-
/**
|
|
858
|
-
* Wraps a function to ensure the user is authenticated before execution.
|
|
859
|
-
* Injects the user, session, and db into the first argument.
|
|
860
|
-
*/
|
|
861
|
-
makeAuthenticatedCall: <TArgs extends any[], TReturn>(fn: (ctx: {
|
|
862
|
-
user: SessionData["user"];
|
|
863
|
-
session: SessionData["session"];
|
|
864
|
-
db: typeof db;
|
|
865
|
-
}, ...args: TArgs) => Promise<TReturn>) => (...args: TArgs) => Promise<TReturn>;
|
|
866
|
-
};
|
|
867
774
|
|
|
868
|
-
export {
|
|
775
|
+
export { client };
|