faire-auth 1.0.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 +661 -0
- package/README.md +34 -0
- package/dist/access-B5bBI4uT.mjs +39 -0
- package/dist/access-Crt-IJ2P.cjs +51 -0
- package/dist/adapter-factory-BXei1QRX.mjs +881 -0
- package/dist/adapter-factory-DT-_2aHJ.cjs +893 -0
- package/dist/adapters/drizzle-adapter/index.cjs +208 -0
- package/dist/adapters/drizzle-adapter/index.d.cts +48 -0
- package/dist/adapters/drizzle-adapter/index.d.mts +48 -0
- package/dist/adapters/drizzle-adapter/index.mjs +207 -0
- package/dist/adapters/index.cjs +23 -0
- package/dist/adapters/index.d.cts +157 -0
- package/dist/adapters/index.d.mts +157 -0
- package/dist/adapters/index.mjs +17 -0
- package/dist/adapters/kysely-adapter/index.cjs +11 -0
- package/dist/adapters/kysely-adapter/index.d.cts +52 -0
- package/dist/adapters/kysely-adapter/index.d.mts +52 -0
- package/dist/adapters/kysely-adapter/index.mjs +9 -0
- package/dist/adapters/memory-adapter/index.cjs +9 -0
- package/dist/adapters/memory-adapter/index.d.cts +15 -0
- package/dist/adapters/memory-adapter/index.d.mts +15 -0
- package/dist/adapters/memory-adapter/index.mjs +9 -0
- package/dist/adapters/mongodb-adapter/index.cjs +9 -0
- package/dist/adapters/mongodb-adapter/index.d.cts +4 -0
- package/dist/adapters/mongodb-adapter/index.d.mts +4 -0
- package/dist/adapters/mongodb-adapter/index.mjs +9 -0
- package/dist/adapters/prisma-adapter/index.cjs +156 -0
- package/dist/adapters/prisma-adapter/index.d.cts +35 -0
- package/dist/adapters/prisma-adapter/index.d.mts +35 -0
- package/dist/adapters/prisma-adapter/index.mjs +155 -0
- package/dist/adapters/test.cjs +797 -0
- package/dist/adapters/test.d.cts +82 -0
- package/dist/adapters/test.d.mts +82 -0
- package/dist/adapters/test.mjs +793 -0
- package/dist/api/index.cjs +20 -0
- package/dist/api/index.d.cts +3 -0
- package/dist/api/index.d.mts +3 -0
- package/dist/api/index.mjs +20 -0
- package/dist/api/middleware/index.cjs +16 -0
- package/dist/api/middleware/index.d.cts +16 -0
- package/dist/api/middleware/index.d.mts +16 -0
- package/dist/api/middleware/index.mjs +11 -0
- package/dist/api-Bm89BLgN.cjs +1899 -0
- package/dist/api-_B7qO28y.mjs +1892 -0
- package/dist/auth-Bo9PDt5j.cjs +739 -0
- package/dist/auth-Ds4AG4h4.mjs +709 -0
- package/dist/bearer-0SeEmaS4.mjs +54 -0
- package/dist/bearer-CHeREcGT.cjs +60 -0
- package/dist/bun-sqlite-dialect-CfkBo2v5.mjs +155 -0
- package/dist/bun-sqlite-dialect-wuaC2-gh.cjs +156 -0
- package/dist/chunk-Ceigfy4P.mjs +39 -0
- package/dist/chunk-oakRccI5.cjs +60 -0
- package/dist/client/index.cjs +22 -0
- package/dist/client/index.d.cts +8 -0
- package/dist/client/index.d.mts +8 -0
- package/dist/client/index.mjs +19 -0
- package/dist/client/lynx/index.cjs +79 -0
- package/dist/client/lynx/index.d.cts +156 -0
- package/dist/client/lynx/index.d.mts +156 -0
- package/dist/client/lynx/index.mjs +76 -0
- package/dist/client/plugins/index.cjs +11 -0
- package/dist/client/plugins/index.d.cts +17 -0
- package/dist/client/plugins/index.d.mts +17 -0
- package/dist/client/plugins/index.mjs +10 -0
- package/dist/client/react/index.cjs +79 -0
- package/dist/client/react/index.d.cts +156 -0
- package/dist/client/react/index.d.mts +156 -0
- package/dist/client/react/index.mjs +76 -0
- package/dist/client/solid/index.cjs +51 -0
- package/dist/client/solid/index.d.cts +90 -0
- package/dist/client/solid/index.d.mts +90 -0
- package/dist/client/solid/index.mjs +50 -0
- package/dist/client/svelte/index.cjs +28 -0
- package/dist/client/svelte/index.d.cts +110 -0
- package/dist/client/svelte/index.d.mts +110 -0
- package/dist/client/svelte/index.mjs +28 -0
- package/dist/client/vue/index.cjs +68 -0
- package/dist/client/vue/index.d.cts +123 -0
- package/dist/client/vue/index.d.mts +123 -0
- package/dist/client/vue/index.mjs +67 -0
- package/dist/cookies-B5xeA6i8.cjs +456 -0
- package/dist/cookies-Ch1JfQIz.mjs +367 -0
- package/dist/crypto/index.cjs +11 -0
- package/dist/crypto/index.d.cts +22 -0
- package/dist/crypto/index.d.mts +22 -0
- package/dist/crypto/index.mjs +5 -0
- package/dist/crypto-CcTxYH82.cjs +57 -0
- package/dist/crypto-CyQRFtkq.mjs +41 -0
- package/dist/db/index.cjs +40 -0
- package/dist/db/index.d.cts +4 -0
- package/dist/db/index.d.mts +4 -0
- package/dist/db/index.mjs +16 -0
- package/dist/db-BTKyYu-_.cjs +1180 -0
- package/dist/db-xiJtoDgz.mjs +1119 -0
- package/dist/defu-B0Svx_x4.cjs +34 -0
- package/dist/defu-SZkpHhbR.mjs +28 -0
- package/dist/email-verification-C-AsfJsb.cjs +247 -0
- package/dist/email-verification-CWhj2qfb.mjs +228 -0
- package/dist/hono-BEq1NYVX.cjs +526 -0
- package/dist/hono-Cdukwu5K.cjs +13 -0
- package/dist/hono-CoKYWnXA.mjs +7 -0
- package/dist/hono-Covz10jU.mjs +508 -0
- package/dist/hono-DOM31WQz.d.cts +18 -0
- package/dist/hono-DuE14mmj.d.mts +18 -0
- package/dist/index-B-WeOMzg.d.cts +13350 -0
- package/dist/index-B09P9p5_.d.cts +33 -0
- package/dist/index-B5_0QTLg.d.mts +3 -0
- package/dist/index-B7SKyR_a.d.cts +3 -0
- package/dist/index-BVHscLQl.d.cts +992 -0
- package/dist/index-C2-2QDyS.d.cts +35 -0
- package/dist/index-CTwrVluH.d.mts +41 -0
- package/dist/index-CWAqWfoZ.d.cts +27 -0
- package/dist/index-CYSShrFx.d.mts +27 -0
- package/dist/index-Qu-iJGNr.d.mts +992 -0
- package/dist/index-cs4Sh0En.d.cts +41 -0
- package/dist/index-jlessPI0.d.mts +13350 -0
- package/dist/index-ppgcFe12.d.mts +33 -0
- package/dist/index-to0RO38U.d.mts +35 -0
- package/dist/index.cjs +85 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +27 -0
- package/dist/integrations/next-js.cjs +50 -0
- package/dist/integrations/next-js.d.cts +23 -0
- package/dist/integrations/next-js.d.mts +23 -0
- package/dist/integrations/next-js.mjs +49 -0
- package/dist/integrations/node.cjs +139 -0
- package/dist/integrations/node.d.cts +22 -0
- package/dist/integrations/node.d.mts +22 -0
- package/dist/integrations/node.mjs +134 -0
- package/dist/integrations/react-start.cjs +37 -0
- package/dist/integrations/react-start.d.cts +17 -0
- package/dist/integrations/react-start.d.mts +17 -0
- package/dist/integrations/react-start.mjs +37 -0
- package/dist/integrations/solid-start.cjs +14 -0
- package/dist/integrations/solid-start.d.cts +13 -0
- package/dist/integrations/solid-start.d.mts +13 -0
- package/dist/integrations/solid-start.mjs +13 -0
- package/dist/integrations/svelte-kit.cjs +52 -0
- package/dist/integrations/svelte-kit.d.cts +42 -0
- package/dist/integrations/svelte-kit.d.mts +42 -0
- package/dist/integrations/svelte-kit.mjs +49 -0
- package/dist/ip-B5SwXaMB.cjs +54 -0
- package/dist/ip-BjNYspCH.mjs +36 -0
- package/dist/json-B1v2qRTQ.mjs +24 -0
- package/dist/json-CcJ2HjGo.cjs +30 -0
- package/dist/kysely-adapter-Bxi7sPdG.cjs +288 -0
- package/dist/kysely-adapter-DRuoT_X8.mjs +270 -0
- package/dist/logged-CyGfp8_H.mjs +187 -0
- package/dist/logged-DQK3C64b.cjs +193 -0
- package/dist/memory-adapter-BlnDIAAX.cjs +154 -0
- package/dist/memory-adapter-Db3tsJTn.mjs +148 -0
- package/dist/middleware-CE6OhDkq.mjs +29 -0
- package/dist/middleware-CWvRH4EW.cjs +47 -0
- package/dist/mongodb-adapter-C_qGQED5.mjs +291 -0
- package/dist/mongodb-adapter-C_qfK87x.cjs +297 -0
- package/dist/node-sqlite-dialect-BfBzyOAg.mjs +155 -0
- package/dist/node-sqlite-dialect-mJWC8LWQ.cjs +156 -0
- package/dist/oauth2/index.cjs +25 -0
- package/dist/oauth2/index.d.cts +42 -0
- package/dist/oauth2/index.d.mts +42 -0
- package/dist/oauth2/index.mjs +16 -0
- package/dist/oauth2-B8M0lW9l.mjs +159 -0
- package/dist/oauth2-BLeOEi7Y.cjs +177 -0
- package/dist/origin-check-8Gajklvh.mjs +228 -0
- package/dist/origin-check-id9lTnqZ.cjs +246 -0
- package/dist/parser-CdncAl9i.cjs +83 -0
- package/dist/parser-CeAer-RM.mjs +71 -0
- package/dist/passkey-B6N20LSS.cjs +512 -0
- package/dist/passkey-DJsR_GX3.mjs +505 -0
- package/dist/plugins/access/index.cjs +4 -0
- package/dist/plugins/access/index.d.cts +2 -0
- package/dist/plugins/access/index.d.mts +2 -0
- package/dist/plugins/access/index.mjs +3 -0
- package/dist/plugins/bearer/index.cjs +7 -0
- package/dist/plugins/bearer/index.d.cts +4 -0
- package/dist/plugins/bearer/index.d.mts +4 -0
- package/dist/plugins/bearer/index.mjs +7 -0
- package/dist/plugins/index.cjs +49 -0
- package/dist/plugins/index.d.cts +9326 -0
- package/dist/plugins/index.d.mts +9326 -0
- package/dist/plugins/index.mjs +26 -0
- package/dist/plugins/passkey/index.cjs +15 -0
- package/dist/plugins/passkey/index.d.cts +4 -0
- package/dist/plugins/passkey/index.d.mts +4 -0
- package/dist/plugins/passkey/index.mjs +15 -0
- package/dist/plugins-C1lm2Wj3.cjs +5254 -0
- package/dist/plugins-Dai1QkRU.mjs +5199 -0
- package/dist/request-1NL_1lyJ.mjs +58 -0
- package/dist/request-CPNlp-DK.cjs +100 -0
- package/dist/schema-D-qjygfE.cjs +179 -0
- package/dist/schema-DTIwLLmf.mjs +125 -0
- package/dist/session-De9POJTW.cjs +641 -0
- package/dist/session-rH8ougDl.mjs +538 -0
- package/dist/social-providers/index.cjs +10 -0
- package/dist/social-providers/index.d.cts +2 -0
- package/dist/social-providers/index.d.mts +2 -0
- package/dist/social-providers/index.mjs +5 -0
- package/dist/social-providers-DcFNUT0S.cjs +13 -0
- package/dist/social-providers-DoYJhBe3.mjs +9 -0
- package/dist/state--f7fwIGh.cjs +99 -0
- package/dist/state-CqJfCIl9.mjs +86 -0
- package/dist/test-utils/index.cjs +27492 -0
- package/dist/test-utils/index.d.cts +4584 -0
- package/dist/test-utils/index.d.mts +4584 -0
- package/dist/test-utils/index.mjs +27490 -0
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.mts +3 -0
- package/dist/types/index.mjs +1 -0
- package/dist/url-BoUuoIwZ.mjs +88 -0
- package/dist/url-D2yvKaM7.cjs +118 -0
- package/dist/utils/cookies.cjs +51 -0
- package/dist/utils/cookies.d.cts +179 -0
- package/dist/utils/cookies.d.mts +179 -0
- package/dist/utils/cookies.mjs +7 -0
- package/dist/utils-44aDDP8f.cjs +2 -0
- package/dist/utils-D4vZd1-9.mjs +4 -0
- package/dist/vanilla-Bu2PmFzE.cjs +30 -0
- package/dist/vanilla-TfHqeiC7.mjs +25 -0
- package/package.json +470 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { CompiledQuery, DEFAULT_MIGRATION_LOCK_TABLE, DEFAULT_MIGRATION_TABLE, DefaultQueryCompiler, Kysely, sql } from "kysely";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/kysely-adapter/node-sqlite-dialect.ts
|
|
4
|
+
var NodeSqliteAdapter = class {
|
|
5
|
+
get supportsCreateIfNotExists() {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
get supportsTransactionalDdl() {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
get supportsReturning() {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
async acquireMigrationLock() {}
|
|
15
|
+
async releaseMigrationLock() {}
|
|
16
|
+
get supportsOutput() {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var NodeSqliteDriver = class {
|
|
21
|
+
#config;
|
|
22
|
+
#connectionMutex = new ConnectionMutex();
|
|
23
|
+
#db;
|
|
24
|
+
#connection;
|
|
25
|
+
constructor(config) {
|
|
26
|
+
this.#config = { ...config };
|
|
27
|
+
}
|
|
28
|
+
async init() {
|
|
29
|
+
this.#db = this.#config.database;
|
|
30
|
+
this.#connection = new NodeSqliteConnection(this.#db);
|
|
31
|
+
if (this.#config.onCreateConnection) await this.#config.onCreateConnection(this.#connection);
|
|
32
|
+
}
|
|
33
|
+
async acquireConnection() {
|
|
34
|
+
await this.#connectionMutex.lock();
|
|
35
|
+
return this.#connection;
|
|
36
|
+
}
|
|
37
|
+
async beginTransaction(connection) {
|
|
38
|
+
await connection.executeQuery(CompiledQuery.raw("begin"));
|
|
39
|
+
}
|
|
40
|
+
async commitTransaction(connection) {
|
|
41
|
+
await connection.executeQuery(CompiledQuery.raw("commit"));
|
|
42
|
+
}
|
|
43
|
+
async rollbackTransaction(connection) {
|
|
44
|
+
await connection.executeQuery(CompiledQuery.raw("rollback"));
|
|
45
|
+
}
|
|
46
|
+
async releaseConnection() {
|
|
47
|
+
this.#connectionMutex.unlock();
|
|
48
|
+
}
|
|
49
|
+
async destroy() {
|
|
50
|
+
this.#db?.close();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var NodeSqliteConnection = class {
|
|
54
|
+
#db;
|
|
55
|
+
constructor(db) {
|
|
56
|
+
this.#db = db;
|
|
57
|
+
}
|
|
58
|
+
executeQuery(compiledQuery) {
|
|
59
|
+
const { sql: sql$1, parameters } = compiledQuery;
|
|
60
|
+
const rows = this.#db.prepare(sql$1).all(...parameters);
|
|
61
|
+
return Promise.resolve({ rows });
|
|
62
|
+
}
|
|
63
|
+
async *streamQuery() {
|
|
64
|
+
throw new Error("Streaming query is not supported by SQLite driver.");
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var ConnectionMutex = class {
|
|
68
|
+
#promise;
|
|
69
|
+
#resolve;
|
|
70
|
+
async lock() {
|
|
71
|
+
while (this.#promise) await this.#promise;
|
|
72
|
+
this.#promise = new Promise((resolve) => {
|
|
73
|
+
this.#resolve = resolve;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
unlock() {
|
|
77
|
+
const resolve = this.#resolve;
|
|
78
|
+
this.#promise = void 0;
|
|
79
|
+
this.#resolve = void 0;
|
|
80
|
+
resolve?.();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var NodeSqliteIntrospector = class {
|
|
84
|
+
#db;
|
|
85
|
+
constructor(db) {
|
|
86
|
+
this.#db = db;
|
|
87
|
+
}
|
|
88
|
+
async getSchemas() {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
async getTables(options = { withInternalKyselyTables: false }) {
|
|
92
|
+
let query = this.#db.selectFrom("sqlite_schema").where("type", "=", "table").where("name", "not like", "sqlite_%").select("name").$castTo();
|
|
93
|
+
if (!options.withInternalKyselyTables) query = query.where("name", "!=", DEFAULT_MIGRATION_TABLE).where("name", "!=", DEFAULT_MIGRATION_LOCK_TABLE);
|
|
94
|
+
const tables = await query.execute();
|
|
95
|
+
return Promise.all(tables.map(({ name }) => this.#getTableMetadata(name)));
|
|
96
|
+
}
|
|
97
|
+
async getMetadata(options) {
|
|
98
|
+
return { tables: await this.getTables(options) };
|
|
99
|
+
}
|
|
100
|
+
async #getTableMetadata(table) {
|
|
101
|
+
const db = this.#db;
|
|
102
|
+
const autoIncrementCol = (await db.selectFrom("sqlite_master").where("name", "=", table).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((it) => it.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g, "");
|
|
103
|
+
return {
|
|
104
|
+
name: table,
|
|
105
|
+
columns: (await db.selectFrom(sql`pragma_table_info(${table})`.as("table_info")).select([
|
|
106
|
+
"name",
|
|
107
|
+
"type",
|
|
108
|
+
"notnull",
|
|
109
|
+
"dflt_value"
|
|
110
|
+
]).execute()).map((col) => ({
|
|
111
|
+
name: col.name,
|
|
112
|
+
dataType: col.type,
|
|
113
|
+
isNullable: !col.notnull,
|
|
114
|
+
isAutoIncrementing: col.name === autoIncrementCol,
|
|
115
|
+
hasDefaultValue: col.dflt_value != null
|
|
116
|
+
})),
|
|
117
|
+
isView: true
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
var NodeSqliteQueryCompiler = class extends DefaultQueryCompiler {
|
|
122
|
+
getCurrentParameterPlaceholder() {
|
|
123
|
+
return "?";
|
|
124
|
+
}
|
|
125
|
+
getLeftIdentifierWrapper() {
|
|
126
|
+
return "\"";
|
|
127
|
+
}
|
|
128
|
+
getRightIdentifierWrapper() {
|
|
129
|
+
return "\"";
|
|
130
|
+
}
|
|
131
|
+
getAutoIncrement() {
|
|
132
|
+
return "autoincrement";
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
var NodeSqliteDialect = class {
|
|
136
|
+
#config;
|
|
137
|
+
constructor(config) {
|
|
138
|
+
this.#config = { ...config };
|
|
139
|
+
}
|
|
140
|
+
createDriver() {
|
|
141
|
+
return new NodeSqliteDriver(this.#config);
|
|
142
|
+
}
|
|
143
|
+
createQueryCompiler() {
|
|
144
|
+
return new NodeSqliteQueryCompiler();
|
|
145
|
+
}
|
|
146
|
+
createAdapter() {
|
|
147
|
+
return new NodeSqliteAdapter();
|
|
148
|
+
}
|
|
149
|
+
createIntrospector(db) {
|
|
150
|
+
return new NodeSqliteIntrospector(db);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
export { NodeSqliteAdapter, NodeSqliteDialect, NodeSqliteDriver, NodeSqliteIntrospector, NodeSqliteQueryCompiler };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-oakRccI5.cjs');
|
|
2
|
+
let kysely = require("kysely");
|
|
3
|
+
|
|
4
|
+
//#region src/adapters/kysely-adapter/node-sqlite-dialect.ts
|
|
5
|
+
var NodeSqliteAdapter = class {
|
|
6
|
+
get supportsCreateIfNotExists() {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
get supportsTransactionalDdl() {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
get supportsReturning() {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
async acquireMigrationLock() {}
|
|
16
|
+
async releaseMigrationLock() {}
|
|
17
|
+
get supportsOutput() {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var NodeSqliteDriver = class {
|
|
22
|
+
#config;
|
|
23
|
+
#connectionMutex = new ConnectionMutex();
|
|
24
|
+
#db;
|
|
25
|
+
#connection;
|
|
26
|
+
constructor(config) {
|
|
27
|
+
this.#config = { ...config };
|
|
28
|
+
}
|
|
29
|
+
async init() {
|
|
30
|
+
this.#db = this.#config.database;
|
|
31
|
+
this.#connection = new NodeSqliteConnection(this.#db);
|
|
32
|
+
if (this.#config.onCreateConnection) await this.#config.onCreateConnection(this.#connection);
|
|
33
|
+
}
|
|
34
|
+
async acquireConnection() {
|
|
35
|
+
await this.#connectionMutex.lock();
|
|
36
|
+
return this.#connection;
|
|
37
|
+
}
|
|
38
|
+
async beginTransaction(connection) {
|
|
39
|
+
await connection.executeQuery(kysely.CompiledQuery.raw("begin"));
|
|
40
|
+
}
|
|
41
|
+
async commitTransaction(connection) {
|
|
42
|
+
await connection.executeQuery(kysely.CompiledQuery.raw("commit"));
|
|
43
|
+
}
|
|
44
|
+
async rollbackTransaction(connection) {
|
|
45
|
+
await connection.executeQuery(kysely.CompiledQuery.raw("rollback"));
|
|
46
|
+
}
|
|
47
|
+
async releaseConnection() {
|
|
48
|
+
this.#connectionMutex.unlock();
|
|
49
|
+
}
|
|
50
|
+
async destroy() {
|
|
51
|
+
this.#db?.close();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var NodeSqliteConnection = class {
|
|
55
|
+
#db;
|
|
56
|
+
constructor(db) {
|
|
57
|
+
this.#db = db;
|
|
58
|
+
}
|
|
59
|
+
executeQuery(compiledQuery) {
|
|
60
|
+
const { sql: sql$1, parameters } = compiledQuery;
|
|
61
|
+
const rows = this.#db.prepare(sql$1).all(...parameters);
|
|
62
|
+
return Promise.resolve({ rows });
|
|
63
|
+
}
|
|
64
|
+
async *streamQuery() {
|
|
65
|
+
throw new Error("Streaming query is not supported by SQLite driver.");
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var ConnectionMutex = class {
|
|
69
|
+
#promise;
|
|
70
|
+
#resolve;
|
|
71
|
+
async lock() {
|
|
72
|
+
while (this.#promise) await this.#promise;
|
|
73
|
+
this.#promise = new Promise((resolve) => {
|
|
74
|
+
this.#resolve = resolve;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
unlock() {
|
|
78
|
+
const resolve = this.#resolve;
|
|
79
|
+
this.#promise = void 0;
|
|
80
|
+
this.#resolve = void 0;
|
|
81
|
+
resolve?.();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var NodeSqliteIntrospector = class {
|
|
85
|
+
#db;
|
|
86
|
+
constructor(db) {
|
|
87
|
+
this.#db = db;
|
|
88
|
+
}
|
|
89
|
+
async getSchemas() {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
async getTables(options = { withInternalKyselyTables: false }) {
|
|
93
|
+
let query = this.#db.selectFrom("sqlite_schema").where("type", "=", "table").where("name", "not like", "sqlite_%").select("name").$castTo();
|
|
94
|
+
if (!options.withInternalKyselyTables) query = query.where("name", "!=", kysely.DEFAULT_MIGRATION_TABLE).where("name", "!=", kysely.DEFAULT_MIGRATION_LOCK_TABLE);
|
|
95
|
+
const tables = await query.execute();
|
|
96
|
+
return Promise.all(tables.map(({ name }) => this.#getTableMetadata(name)));
|
|
97
|
+
}
|
|
98
|
+
async getMetadata(options) {
|
|
99
|
+
return { tables: await this.getTables(options) };
|
|
100
|
+
}
|
|
101
|
+
async #getTableMetadata(table) {
|
|
102
|
+
const db = this.#db;
|
|
103
|
+
const autoIncrementCol = (await db.selectFrom("sqlite_master").where("name", "=", table).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((it) => it.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g, "");
|
|
104
|
+
return {
|
|
105
|
+
name: table,
|
|
106
|
+
columns: (await db.selectFrom(kysely.sql`pragma_table_info(${table})`.as("table_info")).select([
|
|
107
|
+
"name",
|
|
108
|
+
"type",
|
|
109
|
+
"notnull",
|
|
110
|
+
"dflt_value"
|
|
111
|
+
]).execute()).map((col) => ({
|
|
112
|
+
name: col.name,
|
|
113
|
+
dataType: col.type,
|
|
114
|
+
isNullable: !col.notnull,
|
|
115
|
+
isAutoIncrementing: col.name === autoIncrementCol,
|
|
116
|
+
hasDefaultValue: col.dflt_value != null
|
|
117
|
+
})),
|
|
118
|
+
isView: true
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var NodeSqliteQueryCompiler = class extends kysely.DefaultQueryCompiler {
|
|
123
|
+
getCurrentParameterPlaceholder() {
|
|
124
|
+
return "?";
|
|
125
|
+
}
|
|
126
|
+
getLeftIdentifierWrapper() {
|
|
127
|
+
return "\"";
|
|
128
|
+
}
|
|
129
|
+
getRightIdentifierWrapper() {
|
|
130
|
+
return "\"";
|
|
131
|
+
}
|
|
132
|
+
getAutoIncrement() {
|
|
133
|
+
return "autoincrement";
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var NodeSqliteDialect = class {
|
|
137
|
+
#config;
|
|
138
|
+
constructor(config) {
|
|
139
|
+
this.#config = { ...config };
|
|
140
|
+
}
|
|
141
|
+
createDriver() {
|
|
142
|
+
return new NodeSqliteDriver(this.#config);
|
|
143
|
+
}
|
|
144
|
+
createQueryCompiler() {
|
|
145
|
+
return new NodeSqliteQueryCompiler();
|
|
146
|
+
}
|
|
147
|
+
createAdapter() {
|
|
148
|
+
return new NodeSqliteAdapter();
|
|
149
|
+
}
|
|
150
|
+
createIntrospector(db) {
|
|
151
|
+
return new NodeSqliteIntrospector(db);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
exports.NodeSqliteDialect = NodeSqliteDialect;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require('../hono-Cdukwu5K.cjs');
|
|
2
|
+
require('../crypto-CcTxYH82.cjs');
|
|
3
|
+
require('../json-CcJ2HjGo.cjs');
|
|
4
|
+
require('../cookies-B5xeA6i8.cjs');
|
|
5
|
+
require('../logged-DQK3C64b.cjs');
|
|
6
|
+
require('../url-D2yvKaM7.cjs');
|
|
7
|
+
require('../middleware-CWvRH4EW.cjs');
|
|
8
|
+
require('../session-De9POJTW.cjs');
|
|
9
|
+
require('../origin-check-id9lTnqZ.cjs');
|
|
10
|
+
require('../email-verification-C-AsfJsb.cjs');
|
|
11
|
+
const require_oauth2 = require('../oauth2-BLeOEi7Y.cjs');
|
|
12
|
+
const require_state = require('../state--f7fwIGh.cjs');
|
|
13
|
+
|
|
14
|
+
exports.decryptOAuthToken = require_oauth2.decryptOAuthToken;
|
|
15
|
+
exports.generateState = require_state.generateState;
|
|
16
|
+
exports.handleOAuthUserInfo = require_oauth2.handleOAuthUserInfo;
|
|
17
|
+
exports.parseState = require_state.parseState;
|
|
18
|
+
exports.setTokenUtil = require_oauth2.setTokenUtil;
|
|
19
|
+
var __faire_auth_core_oauth2 = require("@faire-auth/core/oauth2");
|
|
20
|
+
Object.keys(__faire_auth_core_oauth2).forEach(function (k) {
|
|
21
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return __faire_auth_core_oauth2[k]; }
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { I as FaireAuthOptions$1, M as generateState, N as parseState } from "../index-B-WeOMzg.cjs";
|
|
2
|
+
import { t as ContextVars } from "../hono-DOM31WQz.cjs";
|
|
3
|
+
import { ExK } from "@faire-auth/core/types";
|
|
4
|
+
import { Context, TypedResponse } from "hono";
|
|
5
|
+
import { Account, Session, User } from "@faire-auth/core/db";
|
|
6
|
+
export * from "@faire-auth/core/oauth2";
|
|
7
|
+
|
|
8
|
+
//#region src/oauth2/utils.d.ts
|
|
9
|
+
declare const decryptOAuthToken: <V extends object>(token: string, ctx: Context<ContextVars<V>>, options: Pick<FaireAuthOptions$1, "account">) => string | Promise<string>;
|
|
10
|
+
declare const setTokenUtil: <V extends object>(token: string | null | undefined, ctx: Context<ContextVars<V>>, options: Pick<FaireAuthOptions$1, "account">) => string | Promise<string> | null | undefined;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/oauth2/link-account.d.ts
|
|
13
|
+
type OAuthError = "account_not_linked" | "unable_to_link_account" | "unable_to_create_user" | "unable_to_create_session" | "internal_server_error" | "signup_disabled" | (string & {});
|
|
14
|
+
declare const handleOAuthUserInfo: (ctx: Context<ContextVars>, {
|
|
15
|
+
userInfo,
|
|
16
|
+
account,
|
|
17
|
+
callbackURL,
|
|
18
|
+
disableSignUp,
|
|
19
|
+
overrideUserInfo
|
|
20
|
+
}: {
|
|
21
|
+
userInfo: ExK<User, "createdAt" | "updatedAt">;
|
|
22
|
+
account: ExK<Account, "createdAt" | "id" | "updatedAt" | "userId">;
|
|
23
|
+
callbackURL?: string;
|
|
24
|
+
disableSignUp?: boolean;
|
|
25
|
+
overrideUserInfo?: boolean;
|
|
26
|
+
}, options: Pick<FaireAuthOptions$1, "account" | "emailVerification" | "onAPIError">) => Promise<{
|
|
27
|
+
type: "success";
|
|
28
|
+
data: {
|
|
29
|
+
session: Session;
|
|
30
|
+
user: User;
|
|
31
|
+
};
|
|
32
|
+
isRegister: boolean;
|
|
33
|
+
} | {
|
|
34
|
+
type: "redirect";
|
|
35
|
+
response: Response & TypedResponse<undefined, 302, "redirect">;
|
|
36
|
+
} | {
|
|
37
|
+
type: "error";
|
|
38
|
+
reason: OAuthError;
|
|
39
|
+
isRegister?: false;
|
|
40
|
+
}>;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { decryptOAuthToken, generateState, handleOAuthUserInfo, parseState, setTokenUtil };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { I as FaireAuthOptions$1, M as generateState, N as parseState } from "../index-jlessPI0.mjs";
|
|
2
|
+
import { t as ContextVars } from "../hono-DuE14mmj.mjs";
|
|
3
|
+
import { Context, TypedResponse } from "hono";
|
|
4
|
+
import { Account, Session, User } from "@faire-auth/core/db";
|
|
5
|
+
import { ExK } from "@faire-auth/core/types";
|
|
6
|
+
export * from "@faire-auth/core/oauth2";
|
|
7
|
+
|
|
8
|
+
//#region src/oauth2/utils.d.ts
|
|
9
|
+
declare const decryptOAuthToken: <V extends object>(token: string, ctx: Context<ContextVars<V>>, options: Pick<FaireAuthOptions$1, "account">) => string | Promise<string>;
|
|
10
|
+
declare const setTokenUtil: <V extends object>(token: string | null | undefined, ctx: Context<ContextVars<V>>, options: Pick<FaireAuthOptions$1, "account">) => string | Promise<string> | null | undefined;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/oauth2/link-account.d.ts
|
|
13
|
+
type OAuthError = "account_not_linked" | "unable_to_link_account" | "unable_to_create_user" | "unable_to_create_session" | "internal_server_error" | "signup_disabled" | (string & {});
|
|
14
|
+
declare const handleOAuthUserInfo: (ctx: Context<ContextVars>, {
|
|
15
|
+
userInfo,
|
|
16
|
+
account,
|
|
17
|
+
callbackURL,
|
|
18
|
+
disableSignUp,
|
|
19
|
+
overrideUserInfo
|
|
20
|
+
}: {
|
|
21
|
+
userInfo: ExK<User, "createdAt" | "updatedAt">;
|
|
22
|
+
account: ExK<Account, "createdAt" | "id" | "updatedAt" | "userId">;
|
|
23
|
+
callbackURL?: string;
|
|
24
|
+
disableSignUp?: boolean;
|
|
25
|
+
overrideUserInfo?: boolean;
|
|
26
|
+
}, options: Pick<FaireAuthOptions$1, "account" | "emailVerification" | "onAPIError">) => Promise<{
|
|
27
|
+
type: "success";
|
|
28
|
+
data: {
|
|
29
|
+
session: Session;
|
|
30
|
+
user: User;
|
|
31
|
+
};
|
|
32
|
+
isRegister: boolean;
|
|
33
|
+
} | {
|
|
34
|
+
type: "redirect";
|
|
35
|
+
response: Response & TypedResponse<undefined, 302, "redirect">;
|
|
36
|
+
} | {
|
|
37
|
+
type: "error";
|
|
38
|
+
reason: OAuthError;
|
|
39
|
+
isRegister?: false;
|
|
40
|
+
}>;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { decryptOAuthToken, generateState, handleOAuthUserInfo, parseState, setTokenUtil };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../hono-CoKYWnXA.mjs";
|
|
2
|
+
import "../crypto-CyQRFtkq.mjs";
|
|
3
|
+
import "../json-B1v2qRTQ.mjs";
|
|
4
|
+
import "../cookies-Ch1JfQIz.mjs";
|
|
5
|
+
import "../logged-CyGfp8_H.mjs";
|
|
6
|
+
import "../url-BoUuoIwZ.mjs";
|
|
7
|
+
import "../middleware-CE6OhDkq.mjs";
|
|
8
|
+
import "../session-rH8ougDl.mjs";
|
|
9
|
+
import "../origin-check-8Gajklvh.mjs";
|
|
10
|
+
import "../email-verification-CWhj2qfb.mjs";
|
|
11
|
+
import { n as decryptOAuthToken, r as setTokenUtil, t as handleOAuthUserInfo } from "../oauth2-B8M0lW9l.mjs";
|
|
12
|
+
import { n as parseState, t as generateState } from "../state-CqJfCIl9.mjs";
|
|
13
|
+
|
|
14
|
+
export * from "@faire-auth/core/oauth2"
|
|
15
|
+
|
|
16
|
+
export { decryptOAuthToken, generateState, handleOAuthUserInfo, parseState, setTokenUtil };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { n as crypto_exports } from "./crypto-CyQRFtkq.mjs";
|
|
2
|
+
import { t as createEmailVerificationToken } from "./email-verification-CWhj2qfb.mjs";
|
|
3
|
+
import { isDevelopment, logger } from "@faire-auth/core/env";
|
|
4
|
+
import { APIError } from "@faire-auth/core/error";
|
|
5
|
+
|
|
6
|
+
//#region src/oauth2/utils.ts
|
|
7
|
+
const decryptOAuthToken = (token, ctx, options) => {
|
|
8
|
+
if (!token) return token;
|
|
9
|
+
if (options.account?.encryptOAuthTokens) return (0, crypto_exports.symmetricDecrypt)({
|
|
10
|
+
key: ctx.get("context").secret,
|
|
11
|
+
data: token
|
|
12
|
+
});
|
|
13
|
+
return token;
|
|
14
|
+
};
|
|
15
|
+
const setTokenUtil = (token, ctx, options) => {
|
|
16
|
+
if (options.account?.encryptOAuthTokens && token) return (0, crypto_exports.symmetricEncrypt)({
|
|
17
|
+
key: ctx.get("context").secret,
|
|
18
|
+
data: token
|
|
19
|
+
});
|
|
20
|
+
return token;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/oauth2/link-account.ts
|
|
25
|
+
const handleOAuthUserInfo = async (ctx, { userInfo, account, callbackURL, disableSignUp, overrideUserInfo }, options) => {
|
|
26
|
+
const context = ctx.get("context");
|
|
27
|
+
const redirectOnError = (reason) => {
|
|
28
|
+
const errorURL = options.onAPIError?.errorURL ?? `${context.baseURL}/error`;
|
|
29
|
+
return {
|
|
30
|
+
type: "redirect",
|
|
31
|
+
response: ctx.redirect(`${errorURL}?error=${reason}`, 302)
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const dbUser = await context.internalAdapter.findOAuthUser(userInfo.email.toLowerCase(), account.accountId, account.providerId).catch((e) => {
|
|
35
|
+
logger.error("Better auth was unable to query your database.\nError: ", e);
|
|
36
|
+
return "error";
|
|
37
|
+
});
|
|
38
|
+
if (dbUser === "error") return redirectOnError("internal_server_error");
|
|
39
|
+
let user = dbUser?.user ?? null;
|
|
40
|
+
const isRegister = user == null;
|
|
41
|
+
if (dbUser) {
|
|
42
|
+
const hasBeenLinked = dbUser.accounts.find((a) => a.providerId === account.providerId && a.accountId === account.accountId);
|
|
43
|
+
if (!hasBeenLinked) {
|
|
44
|
+
if (!(options.account?.accountLinking?.trustedProviders)?.includes(account.providerId) && !userInfo.emailVerified || options.account?.accountLinking?.enabled === false) {
|
|
45
|
+
if (isDevelopment()) logger.warn(`User already exist but account isn't linked to ${account.providerId}. To read more about how account linking works in Faire Auth see https://www.faire-auth.com/docs/concepts/users-accounts#account-linking.`);
|
|
46
|
+
return {
|
|
47
|
+
type: "error",
|
|
48
|
+
reason: "account_not_linked"
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
await context.internalAdapter.linkAccount({
|
|
53
|
+
providerId: account.providerId,
|
|
54
|
+
accountId: userInfo.id.toString(),
|
|
55
|
+
userId: dbUser.user.id,
|
|
56
|
+
accessToken: await setTokenUtil(account.accessToken, ctx, options),
|
|
57
|
+
refreshToken: await setTokenUtil(account.refreshToken, ctx, options),
|
|
58
|
+
idToken: account.idToken,
|
|
59
|
+
accessTokenExpiresAt: account.accessTokenExpiresAt,
|
|
60
|
+
refreshTokenExpiresAt: account.refreshTokenExpiresAt,
|
|
61
|
+
scope: account.scope
|
|
62
|
+
});
|
|
63
|
+
} catch (e) {
|
|
64
|
+
logger.error("Unable to link account", e);
|
|
65
|
+
return {
|
|
66
|
+
type: "error",
|
|
67
|
+
reason: "unable_to_link_account"
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (userInfo.emailVerified && !dbUser.user.emailVerified && userInfo.email.toLowerCase() === dbUser.user.email) await context.internalAdapter.updateUser(dbUser.user.id, { emailVerified: true });
|
|
71
|
+
} else {
|
|
72
|
+
if (options.account?.updateAccountOnSignIn !== false) {
|
|
73
|
+
const updateData = Object.fromEntries(Object.entries({
|
|
74
|
+
idToken: account.idToken,
|
|
75
|
+
accessToken: await setTokenUtil(account.accessToken, ctx, options),
|
|
76
|
+
refreshToken: await setTokenUtil(account.refreshToken, ctx, options),
|
|
77
|
+
accessTokenExpiresAt: account.accessTokenExpiresAt,
|
|
78
|
+
refreshTokenExpiresAt: account.refreshTokenExpiresAt,
|
|
79
|
+
scope: account.scope
|
|
80
|
+
}).filter(([, value]) => value !== void 0 && value !== ""));
|
|
81
|
+
if (Object.keys(updateData).length > 0) await context.internalAdapter.updateAccount(hasBeenLinked.id, updateData);
|
|
82
|
+
}
|
|
83
|
+
if (userInfo.emailVerified && !dbUser.user.emailVerified && userInfo.email.toLowerCase() === dbUser.user.email) await context.internalAdapter.updateUser(dbUser.user.id, { emailVerified: true });
|
|
84
|
+
}
|
|
85
|
+
if (overrideUserInfo === true) {
|
|
86
|
+
const { id: _,...restUserInfo } = userInfo;
|
|
87
|
+
await context.internalAdapter.updateUser(dbUser.user.id, {
|
|
88
|
+
...restUserInfo,
|
|
89
|
+
email: userInfo.email.toLowerCase(),
|
|
90
|
+
emailVerified: userInfo.email.toLowerCase() === dbUser.user.email ? dbUser.user.emailVerified || userInfo.emailVerified : userInfo.emailVerified
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
if (disableSignUp === true) return {
|
|
95
|
+
type: "error",
|
|
96
|
+
reason: "signup_disabled",
|
|
97
|
+
isRegister: false
|
|
98
|
+
};
|
|
99
|
+
try {
|
|
100
|
+
const { id: _,...restUserInfo } = userInfo;
|
|
101
|
+
user = await context.internalAdapter.createOAuthUser({
|
|
102
|
+
...restUserInfo,
|
|
103
|
+
email: userInfo.email.toLowerCase()
|
|
104
|
+
}, {
|
|
105
|
+
accessToken: await setTokenUtil(account.accessToken, ctx, options),
|
|
106
|
+
refreshToken: await setTokenUtil(account.refreshToken, ctx, options),
|
|
107
|
+
idToken: account.idToken,
|
|
108
|
+
accessTokenExpiresAt: account.accessTokenExpiresAt,
|
|
109
|
+
refreshTokenExpiresAt: account.refreshTokenExpiresAt,
|
|
110
|
+
scope: account.scope,
|
|
111
|
+
providerId: account.providerId,
|
|
112
|
+
accountId: userInfo.id.toString()
|
|
113
|
+
}).then((res) => res.user);
|
|
114
|
+
if (!userInfo.emailVerified && user && options.emailVerification?.sendOnSignUp === true) {
|
|
115
|
+
const token = await createEmailVerificationToken(context.secret, user.email, void 0, options.emailVerification.expiresIn);
|
|
116
|
+
const url = `${context.baseURL}/verify-email?token=${token}${callbackURL ? `&callbackURL=${callbackURL}` : ""}`;
|
|
117
|
+
await options.emailVerification.sendVerificationEmail?.({
|
|
118
|
+
user,
|
|
119
|
+
url,
|
|
120
|
+
token
|
|
121
|
+
}, ctx);
|
|
122
|
+
}
|
|
123
|
+
} catch (e) {
|
|
124
|
+
logger.error(e instanceof Error ? e.message : String(e), e);
|
|
125
|
+
if (e instanceof APIError) return {
|
|
126
|
+
type: "error",
|
|
127
|
+
reason: e.message,
|
|
128
|
+
isRegister: false
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
type: "error",
|
|
132
|
+
reason: "unable_to_create_user",
|
|
133
|
+
isRegister: false
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (!user) return {
|
|
138
|
+
type: "error",
|
|
139
|
+
reason: "unable_to_create_user",
|
|
140
|
+
isRegister: false
|
|
141
|
+
};
|
|
142
|
+
const session = await context.internalAdapter.createSession(user.id);
|
|
143
|
+
if (!session) return {
|
|
144
|
+
type: "error",
|
|
145
|
+
reason: "unable_to_create_session",
|
|
146
|
+
isRegister: false
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
type: "success",
|
|
150
|
+
data: {
|
|
151
|
+
session,
|
|
152
|
+
user
|
|
153
|
+
},
|
|
154
|
+
isRegister
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
export { decryptOAuthToken as n, setTokenUtil as r, handleOAuthUserInfo as t };
|