faire-auth 1.0.3 → 1.1.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.
Files changed (228) hide show
  1. package/dist/{adapter-factory-lKIOf2OR.mjs → adapter-factory-qPVW8x9-.mjs} +34 -36
  2. package/dist/{adapter-factory-D1I7joki.cjs → adapter-factory-u8r3oTez.cjs} +66 -68
  3. package/dist/adapters/drizzle-adapter/index.cjs +34 -40
  4. package/dist/adapters/drizzle-adapter/index.d.cts +4 -9
  5. package/dist/adapters/drizzle-adapter/index.d.mts +4 -9
  6. package/dist/adapters/drizzle-adapter/index.mjs +20 -26
  7. package/dist/adapters/index.cjs +11 -16
  8. package/dist/adapters/index.d.cts +11 -37
  9. package/dist/adapters/index.d.mts +11 -37
  10. package/dist/adapters/index.mjs +4 -13
  11. package/dist/adapters/kysely-adapter/index.cjs +270 -11
  12. package/dist/adapters/kysely-adapter/index.d.cts +9 -19
  13. package/dist/adapters/kysely-adapter/index.d.mts +9 -19
  14. package/dist/adapters/kysely-adapter/index.mjs +267 -9
  15. package/dist/adapters/memory-adapter/index.cjs +146 -9
  16. package/dist/adapters/memory-adapter/index.d.cts +4 -10
  17. package/dist/adapters/memory-adapter/index.d.mts +4 -10
  18. package/dist/adapters/memory-adapter/index.mjs +145 -9
  19. package/dist/adapters/mongodb-adapter/index.cjs +13 -21
  20. package/dist/adapters/mongodb-adapter/index.d.cts +3 -8
  21. package/dist/adapters/mongodb-adapter/index.d.mts +4 -9
  22. package/dist/adapters/mongodb-adapter/index.mjs +12 -20
  23. package/dist/adapters/prisma-adapter/index.cjs +12 -20
  24. package/dist/adapters/prisma-adapter/index.d.cts +4 -8
  25. package/dist/adapters/prisma-adapter/index.d.mts +4 -8
  26. package/dist/adapters/prisma-adapter/index.mjs +5 -13
  27. package/dist/adapters/test.cjs +86 -69
  28. package/dist/adapters/test.d.cts +7 -11
  29. package/dist/adapters/test.d.mts +7 -11
  30. package/dist/adapters/test.mjs +83 -66
  31. package/dist/api/index.cjs +3 -20
  32. package/dist/api/index.d.cts +2 -3
  33. package/dist/api/index.d.mts +2 -3
  34. package/dist/api/index.mjs +1 -20
  35. package/dist/api/middleware/index.cjs +4 -11
  36. package/dist/api/middleware/index.d.cts +3 -9
  37. package/dist/api/middleware/index.d.mts +3 -9
  38. package/dist/api/middleware/index.mjs +3 -11
  39. package/dist/{api-B4RDwBty.mjs → api-0f-F-Fi2.mjs} +292 -189
  40. package/dist/{api-CaRC1Gio.cjs → api-LjfH6hQi.cjs} +557 -452
  41. package/dist/{test-utils/bun-sqlite-dialect-BZBvHchL.cjs → bun-sqlite-dialect-BHkarnxN.cjs} +5 -9
  42. package/dist/{test-utils/bun-sqlite-dialect-BSWhhKNs.mjs → bun-sqlite-dialect-BiZBuEF6.mjs} +6 -9
  43. package/dist/client/index.cjs +8 -15
  44. package/dist/client/index.d.cts +9 -14
  45. package/dist/client/index.d.mts +9 -14
  46. package/dist/client/index.mjs +7 -15
  47. package/dist/client/lynx/index.cjs +10 -18
  48. package/dist/client/lynx/index.d.cts +402 -71
  49. package/dist/client/lynx/index.d.mts +402 -71
  50. package/dist/client/lynx/index.mjs +5 -13
  51. package/dist/client/plugins/index.cjs +3 -5
  52. package/dist/client/plugins/index.d.cts +5 -10
  53. package/dist/client/plugins/index.d.mts +5 -10
  54. package/dist/client/plugins/index.mjs +2 -4
  55. package/dist/client/react/index.cjs +6 -14
  56. package/dist/client/react/index.d.cts +402 -71
  57. package/dist/client/react/index.d.mts +402 -71
  58. package/dist/client/react/index.mjs +5 -13
  59. package/dist/client/solid/index.cjs +6 -14
  60. package/dist/client/solid/index.d.cts +393 -57
  61. package/dist/client/solid/index.d.mts +393 -57
  62. package/dist/client/solid/index.mjs +5 -13
  63. package/dist/client/svelte/index.cjs +5 -10
  64. package/dist/client/svelte/index.d.cts +400 -67
  65. package/dist/client/svelte/index.d.mts +400 -67
  66. package/dist/client/svelte/index.mjs +4 -10
  67. package/dist/client/vue/index.cjs +6 -14
  68. package/dist/client/vue/index.d.cts +401 -68
  69. package/dist/client/vue/index.d.mts +401 -68
  70. package/dist/client/vue/index.mjs +5 -13
  71. package/dist/{cookies-BTs1o992.mjs → cookies-D9aY_gJh.mjs} +25 -21
  72. package/dist/{cookies-BTl72THv.cjs → cookies-DQ52rcOy.cjs} +119 -115
  73. package/dist/crypto/index.cjs +10 -8
  74. package/dist/crypto/index.d.cts +5 -13
  75. package/dist/crypto/index.d.mts +5 -13
  76. package/dist/crypto/index.mjs +2 -5
  77. package/dist/{crypto-DH2Aa7jN.mjs → crypto-BH-hD0lJ.mjs} +7 -10
  78. package/dist/{crypto-DpSCnrTp.cjs → crypto-BITfWVwD.cjs} +24 -27
  79. package/dist/db/index.cjs +1135 -29
  80. package/dist/db/index.d.cts +1 -2
  81. package/dist/db/index.d.mts +1 -2
  82. package/dist/db/index.mjs +1115 -16
  83. package/dist/defu-D2h4S3X-.mjs +87 -0
  84. package/dist/defu-DWS5RPWt.cjs +134 -0
  85. package/dist/{email-verification-DI_0H4JC.cjs → email-verification-DOPnSgbI.cjs} +65 -71
  86. package/dist/{email-verification-C_lBu_JY.mjs → email-verification-YSR5n5lb.mjs} +23 -29
  87. package/dist/{hono-CO-zsqI-.mjs → hono-BAV2wQkK.mjs} +16 -33
  88. package/dist/hono-SVQuc5Ru.mjs +4 -0
  89. package/dist/hono-pgK4H_U1.cjs +9 -0
  90. package/dist/{hono-DnW5crl1.cjs → hono-tyFFJFdS.cjs} +42 -60
  91. package/dist/index-B86Cy0dE.d.cts +2 -0
  92. package/dist/index-B86Cy0dE.d.mts +2 -0
  93. package/dist/index.cjs +115 -150
  94. package/dist/index.d.cts +4 -5
  95. package/dist/index.d.mts +4 -5
  96. package/dist/index.mjs +46 -81
  97. package/dist/integrations/next-js.cjs +5 -9
  98. package/dist/integrations/next-js.d.cts +6 -14
  99. package/dist/integrations/next-js.d.mts +6 -14
  100. package/dist/integrations/next-js.mjs +4 -9
  101. package/dist/integrations/node.cjs +16 -14
  102. package/dist/integrations/node.d.cts +6 -14
  103. package/dist/integrations/node.d.mts +6 -14
  104. package/dist/integrations/node.mjs +15 -13
  105. package/dist/integrations/react-start.cjs +7 -11
  106. package/dist/integrations/react-start.d.cts +5 -13
  107. package/dist/integrations/react-start.d.mts +5 -13
  108. package/dist/integrations/react-start.mjs +6 -11
  109. package/dist/integrations/solid-start.cjs +3 -5
  110. package/dist/integrations/solid-start.d.cts +2 -5
  111. package/dist/integrations/solid-start.d.mts +2 -5
  112. package/dist/integrations/solid-start.mjs +2 -4
  113. package/dist/integrations/svelte-kit.cjs +6 -10
  114. package/dist/integrations/svelte-kit.d.cts +11 -23
  115. package/dist/integrations/svelte-kit.d.mts +11 -23
  116. package/dist/integrations/svelte-kit.mjs +5 -10
  117. package/dist/{ip-BjNYspCH.mjs → ip-6Lv2o42m.mjs} +4 -9
  118. package/dist/{ip-C17Qdq-G.cjs → ip-DPydExzV.cjs} +21 -27
  119. package/dist/{json--tl7Grvs.cjs → json-D3aq-nH2.cjs} +9 -13
  120. package/dist/{json-B1v2qRTQ.mjs → json-DooGMtnJ.mjs} +2 -5
  121. package/dist/{logged-CyGfp8_H.mjs → logged-B83SzMnJ.mjs} +6 -10
  122. package/dist/{logged-Dv3st5qc.cjs → logged-BIpCpnVY.cjs} +13 -18
  123. package/dist/{middleware-CE6OhDkq.mjs → middleware-Cakg4e1D.mjs} +2 -4
  124. package/dist/{middleware-CWvRH4EW.cjs → middleware-Cd-VkNxB.cjs} +17 -20
  125. package/dist/{node-sqlite-dialect-w4DAg0PH.mjs → node-sqlite-dialect-BMVOjEMh.mjs} +6 -9
  126. package/dist/{test-utils/node-sqlite-dialect-BgJqjBOu.cjs → node-sqlite-dialect-D3QPFROH.cjs} +5 -9
  127. package/dist/oauth2/index.cjs +166 -22
  128. package/dist/oauth2/index.d.cts +5 -17
  129. package/dist/oauth2/index.d.mts +5 -17
  130. package/dist/oauth2/index.mjs +156 -16
  131. package/dist/{origin-check-DjLTuZQ8.cjs → origin-check-BflGhEEN.cjs} +34 -38
  132. package/dist/{origin-check-8Gajklvh.mjs → origin-check-CRgs1M7k.mjs} +13 -16
  133. package/dist/{parser-B25ylT5u.mjs → parser-CqwvpF6l.cjs} +12 -10
  134. package/dist/{parser-B_wxvaAr.cjs → parser-DcKDjjHO.mjs} +7 -22
  135. package/dist/plugins/access/index.cjs +38 -4
  136. package/dist/plugins/access/index.d.cts +36 -2
  137. package/dist/plugins/access/index.d.mts +36 -2
  138. package/dist/plugins/access/index.mjs +36 -3
  139. package/dist/plugins/bearer/index.cjs +52 -7
  140. package/dist/plugins/bearer/index.d.cts +27 -4
  141. package/dist/plugins/bearer/index.d.mts +27 -4
  142. package/dist/plugins/bearer/index.mjs +51 -7
  143. package/dist/plugins/index.cjs +1385 -842
  144. package/dist/plugins/index.d.cts +489 -7566
  145. package/dist/plugins/index.d.mts +489 -7566
  146. package/dist/plugins/index.mjs +1118 -576
  147. package/dist/plugins/passkey/index.cjs +551 -15
  148. package/dist/plugins/passkey/index.d.cts +123 -4
  149. package/dist/plugins/passkey/index.d.mts +123 -4
  150. package/dist/plugins/passkey/index.mjs +547 -15
  151. package/dist/{chunk-BFnQceUY.mjs → rolldown-runtime-BKpuH2hG.mjs} +6 -7
  152. package/dist/{chunk-fPmz2rbM.cjs → rolldown-runtime-C_Pgydhf.cjs} +22 -24
  153. package/dist/{schema-DTIwLLmf.mjs → schema-CFCpv0tK.mjs} +3 -6
  154. package/dist/{schema-CirKflVs.cjs → schema-b-lKhMkG.cjs} +51 -55
  155. package/dist/{session-CM3rmOYF.mjs → session-BGjJgihS.mjs} +51 -74
  156. package/dist/{session-Cwrj4GfV.cjs → session-CzZSMmQC.cjs} +197 -219
  157. package/dist/shared.d.cts +1581 -0
  158. package/dist/shared.d.mts +1581 -0
  159. package/dist/social-providers/index.cjs +9 -9
  160. package/dist/social-providers/index.d.cts +1 -1
  161. package/dist/social-providers/index.d.mts +1 -1
  162. package/dist/social-providers/index.mjs +3 -5
  163. package/dist/social-providers-CjPww-qf.mjs +6 -0
  164. package/dist/social-providers-D7w_7Ym8.cjs +10 -0
  165. package/dist/{state-CvSihlVT.cjs → state-2OrNjOO-.cjs} +24 -24
  166. package/dist/{state-CQghgH9I.mjs → state-Dooeisfq.mjs} +17 -17
  167. package/dist/{bun-sqlite-dialect-DPgTzc0w.cjs → test-utils/bun-sqlite-dialect-BHkarnxN.cjs} +5 -9
  168. package/dist/{bun-sqlite-dialect-6NqeV3px.mjs → test-utils/bun-sqlite-dialect-BiZBuEF6.mjs} +6 -9
  169. package/dist/test-utils/index.cjs +8831 -7941
  170. package/dist/test-utils/index.d.cts +310 -12440
  171. package/dist/test-utils/index.d.mts +313 -12440
  172. package/dist/test-utils/index.mjs +8591 -7701
  173. package/dist/test-utils/{node-sqlite-dialect-DAQXiobH.mjs → node-sqlite-dialect-BMVOjEMh.mjs} +6 -9
  174. package/dist/{node-sqlite-dialect-DP11CB0y.cjs → test-utils/node-sqlite-dialect-D3QPFROH.cjs} +5 -9
  175. package/dist/types/index.d.cts +2 -3
  176. package/dist/types/index.d.mts +2 -3
  177. package/dist/types/index.mjs +1 -1
  178. package/dist/{url-BoUuoIwZ.mjs → url-CJtdrrUu.mjs} +12 -13
  179. package/dist/{url-Ce7CVaQD.cjs → url-DjCmCUHS.cjs} +42 -44
  180. package/dist/utils/cookies.cjs +29 -30
  181. package/dist/utils/cookies.d.cts +21 -25
  182. package/dist/utils/cookies.d.mts +20 -24
  183. package/dist/utils/cookies.mjs +2 -7
  184. package/dist/utils-C7OHyfHa.mjs +4 -0
  185. package/dist/utils-iX0Vy_UL.cjs +3 -0
  186. package/package.json +40 -30
  187. package/dist/access-BZ7-AbTM.cjs +0 -51
  188. package/dist/access-D0DRqUKC.mjs +0 -39
  189. package/dist/bearer-DDzrp5M7.cjs +0 -60
  190. package/dist/bearer-WZcs7gxL.mjs +0 -54
  191. package/dist/db-4tUsQJXd.mjs +0 -1119
  192. package/dist/db-ChMbb_U-.cjs +0 -1180
  193. package/dist/defu-BmOYq4PU.cjs +0 -34
  194. package/dist/defu-D9ZTXqlo.mjs +0 -28
  195. package/dist/hono-C14rpOEa.cjs +0 -13
  196. package/dist/hono-CoKYWnXA.mjs +0 -7
  197. package/dist/hono-D0VqxVy1.d.mts +0 -18
  198. package/dist/hono-DOM31WQz.d.cts +0 -18
  199. package/dist/index-BCTFWP_o.d.mts +0 -992
  200. package/dist/index-BDhhaE6Y.d.cts +0 -3
  201. package/dist/index-BVRfQy6L.d.mts +0 -992
  202. package/dist/index-Baarsq5J.d.mts +0 -33
  203. package/dist/index-By364WbF.d.cts +0 -992
  204. package/dist/index-BzWwMgxr.d.cts +0 -992
  205. package/dist/index-CF9iq55a.d.mts +0 -3
  206. package/dist/index-CJD2yB-W.d.cts +0 -33
  207. package/dist/index-CRt_fppq.d.mts +0 -41
  208. package/dist/index-CdLyn7qP.d.cts +0 -41
  209. package/dist/index-CsWF3f7U.d.cts +0 -13350
  210. package/dist/index-CzidsAyA.d.mts +0 -13350
  211. package/dist/index-DvW-GCcI.d.cts +0 -33
  212. package/dist/index-f-5OJ9yV.d.cts +0 -13350
  213. package/dist/index-rFv8Hxld.d.mts +0 -13350
  214. package/dist/index-ztVZPQdV.d.mts +0 -33
  215. package/dist/kysely-adapter-CtIdoHa8.mjs +0 -270
  216. package/dist/kysely-adapter-QZTx077T.cjs +0 -288
  217. package/dist/memory-adapter-17RZd5df.cjs +0 -154
  218. package/dist/memory-adapter-Dp4XdCZK.mjs +0 -148
  219. package/dist/oauth2-5RL4cVNS.cjs +0 -177
  220. package/dist/oauth2-C56wz-n9.mjs +0 -159
  221. package/dist/passkey-BTT-v5c-.cjs +0 -512
  222. package/dist/passkey-CzY_W2us.mjs +0 -505
  223. package/dist/request-1NL_1lyJ.mjs +0 -58
  224. package/dist/request-CPNlp-DK.cjs +0 -100
  225. package/dist/social-providers-B8RK5yqI.mjs +0 -9
  226. package/dist/social-providers-BmFOIIPk.cjs +0 -13
  227. package/dist/utils-44aDDP8f.cjs +0 -2
  228. package/dist/utils-D4vZd1-9.mjs +0 -4
@@ -1,9 +1,145 @@
1
- import "../../crypto-DH2Aa7jN.mjs";
2
- import "../../json-B1v2qRTQ.mjs";
3
- import "../../state-CQghgH9I.mjs";
4
- import "../../request-1NL_1lyJ.mjs";
5
- import "../../utils-D4vZd1-9.mjs";
6
- import "../../adapter-factory-lKIOf2OR.mjs";
7
- import { t as memoryAdapter } from "../../memory-adapter-Dp4XdCZK.mjs";
8
-
9
- export { memoryAdapter };
1
+ import { t as createAdapterFactory } from "../../adapter-factory-qPVW8x9-.mjs";
2
+ import { logger } from "@faire-auth/core/env";
3
+ // src/adapters/memory-adapter/memory-adapter.ts
4
+ const memoryAdapter = (db, config) => {
5
+ let lazyOptions = null;
6
+ let adapterCreator = createAdapterFactory({
7
+ config: {
8
+ adapterId: "memory",
9
+ adapterName: "Memory Adapter",
10
+ usePlural: false,
11
+ debugLogs: config?.debugLogs || false,
12
+ customTransformInput(props) {
13
+ if (props.options.advanced?.database?.useNumberId && props.field === "id" && props.action === "create") return db[props.model].length + 1;
14
+ return props.data;
15
+ },
16
+ transaction: async (cb) => {
17
+ let clone = structuredClone(db);
18
+ try {
19
+ return await cb(adapterCreator(lazyOptions));
20
+ } catch (error) {
21
+ Object.keys(db).forEach((key) => {
22
+ db[key] = clone[key];
23
+ });
24
+ throw error;
25
+ }
26
+ }
27
+ },
28
+ adapter: ({ getFieldName, options, debugLog }) => {
29
+ function convertWhereClause(where, model) {
30
+ const table = db[model];
31
+ if (!table) {
32
+ logger.error(`[MemoryAdapter] Model ${model} not found in the DB`, Object.keys(db));
33
+ throw new Error(`Model ${model} not found`);
34
+ }
35
+ const evalClause = (record, clause) => {
36
+ const { field, value, operator } = clause;
37
+ switch (operator) {
38
+ case "in":
39
+ if (!Array.isArray(value)) throw new Error("Value must be an array");
40
+ return value.includes(record[field]);
41
+ case "not_in":
42
+ if (!Array.isArray(value)) throw new Error("Value must be an array");
43
+ return !value.includes(record[field]);
44
+ case "contains": return record[field].includes(value);
45
+ case "starts_with": return record[field].startsWith(value);
46
+ case "ends_with": return record[field].endsWith(value);
47
+ case "ne": return record[field] !== value;
48
+ case "gt": return value != null && Boolean(record[field] > value);
49
+ case "gte": return value != null && Boolean(record[field] >= value);
50
+ case "lt": return value != null && Boolean(record[field] < value);
51
+ case "lte": return value != null && Boolean(record[field] <= value);
52
+ default: return record[field] === value;
53
+ }
54
+ };
55
+ return table.filter((record) => {
56
+ if (!where.length || where.length === 0) return true;
57
+ let result = evalClause(record, where[0]);
58
+ for (const clause of where) {
59
+ const clauseResult = evalClause(record, clause);
60
+ if (clause.connector === "OR") result = result || clauseResult;
61
+ else result = result && clauseResult;
62
+ }
63
+ return result;
64
+ });
65
+ }
66
+ return {
67
+ create: async ({ model, data }) => {
68
+ if (options.advanced?.database?.useNumberId) data.id = db[model].length + 1;
69
+ if (!db[model]) db[model] = [];
70
+ db[model].push(data);
71
+ return data;
72
+ },
73
+ findOne: async ({ model, where }) => {
74
+ return convertWhereClause(where, model)[0] || null;
75
+ },
76
+ findMany: async ({ model, where, sortBy, limit, offset }) => {
77
+ let table = db[model];
78
+ if (where) table = convertWhereClause(where, model);
79
+ if (sortBy) table = table.sort((a, b) => {
80
+ const field = getFieldName({
81
+ model,
82
+ field: sortBy.field
83
+ });
84
+ const aValue = a[field];
85
+ const bValue = b[field];
86
+ let comparison = 0;
87
+ if (aValue == null && bValue == null) comparison = 0;
88
+ else if (aValue == null) comparison = -1;
89
+ else if (bValue == null) comparison = 1;
90
+ else if (typeof aValue === "string" && typeof bValue === "string") comparison = aValue.localeCompare(bValue);
91
+ else if (aValue instanceof Date && bValue instanceof Date) comparison = aValue.getTime() - bValue.getTime();
92
+ else if (typeof aValue === "number" && typeof bValue === "number") comparison = aValue - bValue;
93
+ else if (typeof aValue === "boolean" && typeof bValue === "boolean") comparison = aValue === bValue ? 0 : aValue ? 1 : -1;
94
+ else comparison = String(aValue).localeCompare(String(bValue));
95
+ return sortBy.direction === "asc" ? comparison : -comparison;
96
+ });
97
+ if (offset !== void 0) table = table.slice(offset);
98
+ if (limit !== void 0) table = table.slice(0, limit);
99
+ return table || [];
100
+ },
101
+ count: async ({ model, where }) => {
102
+ if (where) return convertWhereClause(where, model).length;
103
+ return db[model].length;
104
+ },
105
+ update: async ({ model, where, update }) => {
106
+ const res = convertWhereClause(where, model);
107
+ res.forEach((record) => {
108
+ Object.assign(record, update);
109
+ });
110
+ return res[0] || null;
111
+ },
112
+ delete: async ({ model, where }) => {
113
+ const table = db[model];
114
+ const res = convertWhereClause(where, model);
115
+ db[model] = table.filter((record) => !res.includes(record));
116
+ },
117
+ deleteMany: async ({ model, where }) => {
118
+ const table = db[model];
119
+ const res = convertWhereClause(where, model);
120
+ let count = 0;
121
+ db[model] = table.filter((record) => {
122
+ if (res.includes(record)) {
123
+ count++;
124
+ return false;
125
+ }
126
+ return !res.includes(record);
127
+ });
128
+ return count;
129
+ },
130
+ updateMany({ model, where, update }) {
131
+ const res = convertWhereClause(where, model);
132
+ res.forEach((record) => {
133
+ Object.assign(record, update);
134
+ });
135
+ return res[0] || null;
136
+ }
137
+ };
138
+ }
139
+ });
140
+ return (options) => {
141
+ lazyOptions = options;
142
+ return adapterCreator(options);
143
+ };
144
+ };
145
+ export { memoryAdapter };
@@ -1,16 +1,10 @@
1
- const require_chunk = require('../../chunk-fPmz2rbM.cjs');
2
- require('../../crypto-DpSCnrTp.cjs');
3
- require('../../json--tl7Grvs.cjs');
4
- require('../../state-CvSihlVT.cjs');
5
- require('../../request-CPNlp-DK.cjs');
6
- require('../../utils-44aDDP8f.cjs');
7
- const require_adapter_factory = require('../../adapter-factory-D1I7joki.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_adapter_factory = require("../../adapter-factory-u8r3oTez.cjs");
8
3
  let mongodb = require("mongodb");
9
-
10
- //#region src/adapters/mongodb-adapter/mongodb-adapter.ts
4
+ // src/adapters/mongodb-adapter/mongodb-adapter.ts
11
5
  const mongodbAdapter = (db, config) => {
12
6
  let lazyOptions;
13
- const createCustomAdapter = (db$1, session) => ({ options, getFieldName, schema, getDefaultModelName }) => {
7
+ const createCustomAdapter = (db, session) => ({ options, getFieldName, schema, getDefaultModelName }) => {
14
8
  function serializeID({ field, value, model }) {
15
9
  model = getDefaultModelName(model);
16
10
  if (field === "id" || field === "_id" || schema[model].fields[field]?.references?.field === "id") {
@@ -123,7 +117,7 @@ const mongodbAdapter = (db, config) => {
123
117
  return {
124
118
  async create({ model, data: values }) {
125
119
  return {
126
- _id: (await db$1.collection(model).insertOne(values, { ...session && { session } })).insertedId.toString(),
120
+ _id: (await db.collection(model).insertOne(values, { ...session && { session } })).insertedId.toString(),
127
121
  ...values
128
122
  };
129
123
  },
@@ -136,7 +130,7 @@ const mongodbAdapter = (db, config) => {
136
130
  field,
137
131
  model
138
132
  }), 1])) : void 0;
139
- const res = await db$1.collection(model).findOne(clause, {
133
+ const res = await db.collection(model).findOne(clause, {
140
134
  ...session && { session },
141
135
  ...projection && { projection }
142
136
  });
@@ -148,7 +142,7 @@ const mongodbAdapter = (db, config) => {
148
142
  where,
149
143
  model
150
144
  }) : {};
151
- const cursor = db$1.collection(model).find(clause, { ...session && { session } });
145
+ const cursor = db.collection(model).find(clause, { ...session && { session } });
152
146
  if (limit) cursor.limit(limit);
153
147
  if (offset) cursor.skip(offset);
154
148
  if (sortBy) cursor.sort(getFieldName({
@@ -162,14 +156,14 @@ const mongodbAdapter = (db, config) => {
162
156
  where,
163
157
  model
164
158
  }) : {};
165
- return await db$1.collection(model).countDocuments(clause, { ...session && { session } });
159
+ return await db.collection(model).countDocuments(clause, { ...session && { session } });
166
160
  },
167
161
  async update({ model, where, update: values }) {
168
162
  const clause = convertWhereClause({
169
163
  where,
170
164
  model
171
165
  });
172
- const res = await db$1.collection(model).findOneAndUpdate(clause, { $set: values }, {
166
+ const res = await db.collection(model).findOneAndUpdate(clause, { $set: values }, {
173
167
  ...session && { session },
174
168
  returnDocument: "after"
175
169
  });
@@ -181,21 +175,21 @@ const mongodbAdapter = (db, config) => {
181
175
  where,
182
176
  model
183
177
  });
184
- return (await db$1.collection(model).updateMany(clause, { $set: values }, { ...session && { session } })).modifiedCount;
178
+ return (await db.collection(model).updateMany(clause, { $set: values }, { ...session && { session } })).modifiedCount;
185
179
  },
186
180
  async delete({ model, where }) {
187
181
  const clause = convertWhereClause({
188
182
  where,
189
183
  model
190
184
  });
191
- await db$1.collection(model).deleteOne(clause, { ...session && { session } });
185
+ await db.collection(model).deleteOne(clause, { ...session && { session } });
192
186
  },
193
187
  async deleteMany({ model, where }) {
194
188
  const clause = convertWhereClause({
195
189
  where,
196
190
  model
197
191
  });
198
- return (await db$1.collection(model).deleteMany(clause, { ...session && { session } })).deletedCount;
192
+ return (await db.collection(model).deleteMany(clause, { ...session && { session } })).deletedCount;
199
193
  }
200
194
  };
201
195
  };
@@ -292,6 +286,4 @@ function escapeForMongoRegex(input, maxLength = 256) {
292
286
  if (typeof input !== "string") return "";
293
287
  return input.slice(0, maxLength).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
294
288
  }
295
-
296
- //#endregion
297
- exports.mongodbAdapter = mongodbAdapter;
289
+ exports.mongodbAdapter = mongodbAdapter;
@@ -1,10 +1,7 @@
1
- import { I as FaireAuthOptions } from "../../index-CsWF3f7U.cjs";
2
- import "../../hono-DOM31WQz.cjs";
1
+ import { ht as FaireAuthOptions } from "../../shared.cjs";
3
2
  import { DBAdapter, DBAdapterDebugLogOption } from "@faire-auth/core/db/adapter";
4
3
  import { Db, MongoClient } from "mongodb";
5
-
6
- //#region src/adapters/mongodb-adapter/mongodb-adapter.d.ts
7
- interface MongoDBAdapterConfig {
4
+ export interface MongoDBAdapterConfig {
8
5
  /**
9
6
  * MongoDB client instance
10
7
  * If not provided, Database transactions won't be enabled.
@@ -31,6 +28,4 @@ interface MongoDBAdapterConfig {
31
28
  */
32
29
  transaction?: boolean;
33
30
  }
34
- declare const mongodbAdapter: (db: Db, config?: MongoDBAdapterConfig) => (options: FaireAuthOptions) => DBAdapter<FaireAuthOptions>;
35
- //#endregion
36
- export { MongoDBAdapterConfig, mongodbAdapter };
31
+ export declare const mongodbAdapter: (db: Db, config?: MongoDBAdapterConfig) => (options: FaireAuthOptions) => DBAdapter<FaireAuthOptions>;
@@ -1,10 +1,7 @@
1
- import { I as FaireAuthOptions } from "../../index-rFv8Hxld.mjs";
2
- import "../../hono-D0VqxVy1.mjs";
3
- import { DBAdapter, DBAdapterDebugLogOption } from "@faire-auth/core/db/adapter";
1
+ import { gt as FaireAuthOptions } from "../../shared.mjs";
4
2
  import { Db, MongoClient } from "mongodb";
5
-
6
- //#region src/adapters/mongodb-adapter/mongodb-adapter.d.ts
7
- interface MongoDBAdapterConfig {
3
+ import { DBAdapter, DBAdapterDebugLogOption } from "@faire-auth/core/db/adapter";
4
+ export interface MongoDBAdapterConfig {
8
5
  /**
9
6
  * MongoDB client instance
10
7
  * If not provided, Database transactions won't be enabled.
@@ -31,6 +28,4 @@ interface MongoDBAdapterConfig {
31
28
  */
32
29
  transaction?: boolean;
33
30
  }
34
- declare const mongodbAdapter: (db: Db, config?: MongoDBAdapterConfig) => (options: FaireAuthOptions) => DBAdapter<FaireAuthOptions>;
35
- //#endregion
36
- export { MongoDBAdapterConfig, mongodbAdapter };
31
+ export declare const mongodbAdapter: (db: Db, config?: MongoDBAdapterConfig) => (options: FaireAuthOptions) => DBAdapter<FaireAuthOptions>;
@@ -1,15 +1,9 @@
1
- import "../../crypto-DH2Aa7jN.mjs";
2
- import "../../json-B1v2qRTQ.mjs";
3
- import "../../state-CQghgH9I.mjs";
4
- import "../../request-1NL_1lyJ.mjs";
5
- import "../../utils-D4vZd1-9.mjs";
6
- import { t as createAdapterFactory } from "../../adapter-factory-lKIOf2OR.mjs";
1
+ import { t as createAdapterFactory } from "../../adapter-factory-qPVW8x9-.mjs";
7
2
  import { ObjectId } from "mongodb";
8
-
9
- //#region src/adapters/mongodb-adapter/mongodb-adapter.ts
3
+ // src/adapters/mongodb-adapter/mongodb-adapter.ts
10
4
  const mongodbAdapter = (db, config) => {
11
5
  let lazyOptions;
12
- const createCustomAdapter = (db$1, session) => ({ options, getFieldName, schema, getDefaultModelName }) => {
6
+ const createCustomAdapter = (db, session) => ({ options, getFieldName, schema, getDefaultModelName }) => {
13
7
  function serializeID({ field, value, model }) {
14
8
  model = getDefaultModelName(model);
15
9
  if (field === "id" || field === "_id" || schema[model].fields[field]?.references?.field === "id") {
@@ -122,7 +116,7 @@ const mongodbAdapter = (db, config) => {
122
116
  return {
123
117
  async create({ model, data: values }) {
124
118
  return {
125
- _id: (await db$1.collection(model).insertOne(values, { ...session && { session } })).insertedId.toString(),
119
+ _id: (await db.collection(model).insertOne(values, { ...session && { session } })).insertedId.toString(),
126
120
  ...values
127
121
  };
128
122
  },
@@ -135,7 +129,7 @@ const mongodbAdapter = (db, config) => {
135
129
  field,
136
130
  model
137
131
  }), 1])) : void 0;
138
- const res = await db$1.collection(model).findOne(clause, {
132
+ const res = await db.collection(model).findOne(clause, {
139
133
  ...session && { session },
140
134
  ...projection && { projection }
141
135
  });
@@ -147,7 +141,7 @@ const mongodbAdapter = (db, config) => {
147
141
  where,
148
142
  model
149
143
  }) : {};
150
- const cursor = db$1.collection(model).find(clause, { ...session && { session } });
144
+ const cursor = db.collection(model).find(clause, { ...session && { session } });
151
145
  if (limit) cursor.limit(limit);
152
146
  if (offset) cursor.skip(offset);
153
147
  if (sortBy) cursor.sort(getFieldName({
@@ -161,14 +155,14 @@ const mongodbAdapter = (db, config) => {
161
155
  where,
162
156
  model
163
157
  }) : {};
164
- return await db$1.collection(model).countDocuments(clause, { ...session && { session } });
158
+ return await db.collection(model).countDocuments(clause, { ...session && { session } });
165
159
  },
166
160
  async update({ model, where, update: values }) {
167
161
  const clause = convertWhereClause({
168
162
  where,
169
163
  model
170
164
  });
171
- const res = await db$1.collection(model).findOneAndUpdate(clause, { $set: values }, {
165
+ const res = await db.collection(model).findOneAndUpdate(clause, { $set: values }, {
172
166
  ...session && { session },
173
167
  returnDocument: "after"
174
168
  });
@@ -180,21 +174,21 @@ const mongodbAdapter = (db, config) => {
180
174
  where,
181
175
  model
182
176
  });
183
- return (await db$1.collection(model).updateMany(clause, { $set: values }, { ...session && { session } })).modifiedCount;
177
+ return (await db.collection(model).updateMany(clause, { $set: values }, { ...session && { session } })).modifiedCount;
184
178
  },
185
179
  async delete({ model, where }) {
186
180
  const clause = convertWhereClause({
187
181
  where,
188
182
  model
189
183
  });
190
- await db$1.collection(model).deleteOne(clause, { ...session && { session } });
184
+ await db.collection(model).deleteOne(clause, { ...session && { session } });
191
185
  },
192
186
  async deleteMany({ model, where }) {
193
187
  const clause = convertWhereClause({
194
188
  where,
195
189
  model
196
190
  });
197
- return (await db$1.collection(model).deleteMany(clause, { ...session && { session } })).deletedCount;
191
+ return (await db.collection(model).deleteMany(clause, { ...session && { session } })).deletedCount;
198
192
  }
199
193
  };
200
194
  };
@@ -291,6 +285,4 @@ function escapeForMongoRegex(input, maxLength = 256) {
291
285
  if (typeof input !== "string") return "";
292
286
  return input.slice(0, maxLength).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
293
287
  }
294
-
295
- //#endregion
296
- export { mongodbAdapter };
288
+ export { mongodbAdapter };
@@ -1,17 +1,11 @@
1
- const require_chunk = require('../../chunk-fPmz2rbM.cjs');
2
- require('../../crypto-DpSCnrTp.cjs');
3
- require('../../json--tl7Grvs.cjs');
4
- require('../../state-CvSihlVT.cjs');
5
- require('../../request-CPNlp-DK.cjs');
6
- require('../../utils-44aDDP8f.cjs');
7
- const require_adapter_factory = require('../../adapter-factory-D1I7joki.cjs');
8
- let __faire_auth_core_error = require("@faire-auth/core/error");
9
-
10
- //#region src/adapters/prisma-adapter/prisma-adapter.ts
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_adapter_factory = require("../../adapter-factory-u8r3oTez.cjs");
3
+ let _faire_auth_core_error = require("@faire-auth/core/error");
4
+ // src/adapters/prisma-adapter/prisma-adapter.ts
11
5
  const prismaAdapter = (prisma, config) => {
12
6
  let lazyOptions = null;
13
- const createCustomAdapter = (prisma$1) => ({ getFieldName }) => {
14
- const db = prisma$1;
7
+ const createCustomAdapter = (prisma) => ({ getFieldName }) => {
8
+ const db = prisma;
15
9
  const convertSelect = (select, model) => {
16
10
  if (!select || !model) return void 0;
17
11
  return select.reduce((prev, cur) => {
@@ -64,7 +58,7 @@ const prismaAdapter = (prisma, config) => {
64
58
  };
65
59
  return {
66
60
  async create({ model, data: values, select }) {
67
- if (!db[model]) throw new __faire_auth_core_error.FaireAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
61
+ if (!db[model]) throw new _faire_auth_core_error.FaireAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
68
62
  return await db[model].create({
69
63
  data: values,
70
64
  select: convertSelect(select, model)
@@ -72,7 +66,7 @@ const prismaAdapter = (prisma, config) => {
72
66
  },
73
67
  async findOne({ model, where, select }) {
74
68
  const whereClause = convertWhereClause(model, where);
75
- if (!db[model]) throw new __faire_auth_core_error.FaireAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
69
+ if (!db[model]) throw new _faire_auth_core_error.FaireAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
76
70
  return await db[model].findFirst({
77
71
  where: whereClause,
78
72
  select: convertSelect(select, model)
@@ -80,7 +74,7 @@ const prismaAdapter = (prisma, config) => {
80
74
  },
81
75
  async findMany({ model, where, limit, offset, sortBy }) {
82
76
  const whereClause = convertWhereClause(model, where);
83
- if (!db[model]) throw new __faire_auth_core_error.FaireAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
77
+ if (!db[model]) throw new _faire_auth_core_error.FaireAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
84
78
  return await db[model].findMany({
85
79
  where: whereClause,
86
80
  take: limit || 100,
@@ -93,11 +87,11 @@ const prismaAdapter = (prisma, config) => {
93
87
  },
94
88
  async count({ model, where }) {
95
89
  const whereClause = convertWhereClause(model, where);
96
- if (!db[model]) throw new __faire_auth_core_error.FaireAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
90
+ if (!db[model]) throw new _faire_auth_core_error.FaireAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
97
91
  return await db[model].count({ where: whereClause });
98
92
  },
99
93
  async update({ model, where, update }) {
100
- if (!db[model]) throw new __faire_auth_core_error.FaireAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
94
+ if (!db[model]) throw new _faire_auth_core_error.FaireAuthError(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
101
95
  const whereClause = convertWhereClause(model, where);
102
96
  return await db[model].update({
103
97
  where: whereClause,
@@ -151,6 +145,4 @@ const prismaAdapter = (prisma, config) => {
151
145
  return adapter(options);
152
146
  };
153
147
  };
154
-
155
- //#endregion
156
- exports.prismaAdapter = prismaAdapter;
148
+ exports.prismaAdapter = prismaAdapter;
@@ -1,9 +1,6 @@
1
- import { I as FaireAuthOptions } from "../../index-CsWF3f7U.cjs";
2
- import "../../hono-DOM31WQz.cjs";
1
+ import { ht as FaireAuthOptions } from "../../shared.cjs";
3
2
  import { DBAdapter, DBAdapterDebugLogOption } from "@faire-auth/core/db/adapter";
4
-
5
- //#region src/adapters/prisma-adapter/prisma-adapter.d.ts
6
- interface PrismaConfig {
3
+ export interface PrismaConfig {
7
4
  /**
8
5
  * Database provider.
9
6
  */
@@ -30,6 +27,5 @@ interface PrismaConfig {
30
27
  transaction?: boolean;
31
28
  }
32
29
  interface PrismaClient {}
33
- declare const prismaAdapter: (prisma: PrismaClient, config: PrismaConfig) => (options: FaireAuthOptions) => DBAdapter<FaireAuthOptions>;
34
- //#endregion
35
- export { PrismaConfig, prismaAdapter };
30
+ export declare const prismaAdapter: (prisma: PrismaClient, config: PrismaConfig) => (options: FaireAuthOptions) => DBAdapter<FaireAuthOptions>;
31
+ export {};
@@ -1,9 +1,6 @@
1
- import { I as FaireAuthOptions } from "../../index-rFv8Hxld.mjs";
2
- import "../../hono-D0VqxVy1.mjs";
1
+ import { gt as FaireAuthOptions } from "../../shared.mjs";
3
2
  import { DBAdapter, DBAdapterDebugLogOption } from "@faire-auth/core/db/adapter";
4
-
5
- //#region src/adapters/prisma-adapter/prisma-adapter.d.ts
6
- interface PrismaConfig {
3
+ export interface PrismaConfig {
7
4
  /**
8
5
  * Database provider.
9
6
  */
@@ -30,6 +27,5 @@ interface PrismaConfig {
30
27
  transaction?: boolean;
31
28
  }
32
29
  interface PrismaClient {}
33
- declare const prismaAdapter: (prisma: PrismaClient, config: PrismaConfig) => (options: FaireAuthOptions) => DBAdapter<FaireAuthOptions>;
34
- //#endregion
35
- export { PrismaConfig, prismaAdapter };
30
+ export declare const prismaAdapter: (prisma: PrismaClient, config: PrismaConfig) => (options: FaireAuthOptions) => DBAdapter<FaireAuthOptions>;
31
+ export {};
@@ -1,16 +1,10 @@
1
- import "../../crypto-DH2Aa7jN.mjs";
2
- import "../../json-B1v2qRTQ.mjs";
3
- import "../../state-CQghgH9I.mjs";
4
- import "../../request-1NL_1lyJ.mjs";
5
- import "../../utils-D4vZd1-9.mjs";
6
- import { t as createAdapterFactory } from "../../adapter-factory-lKIOf2OR.mjs";
1
+ import { t as createAdapterFactory } from "../../adapter-factory-qPVW8x9-.mjs";
7
2
  import { FaireAuthError } from "@faire-auth/core/error";
8
-
9
- //#region src/adapters/prisma-adapter/prisma-adapter.ts
3
+ // src/adapters/prisma-adapter/prisma-adapter.ts
10
4
  const prismaAdapter = (prisma, config) => {
11
5
  let lazyOptions = null;
12
- const createCustomAdapter = (prisma$1) => ({ getFieldName }) => {
13
- const db = prisma$1;
6
+ const createCustomAdapter = (prisma) => ({ getFieldName }) => {
7
+ const db = prisma;
14
8
  const convertSelect = (select, model) => {
15
9
  if (!select || !model) return void 0;
16
10
  return select.reduce((prev, cur) => {
@@ -150,6 +144,4 @@ const prismaAdapter = (prisma, config) => {
150
144
  return adapter(options);
151
145
  };
152
146
  };
153
-
154
- //#endregion
155
- export { prismaAdapter };
147
+ export { prismaAdapter };