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.
Files changed (221) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +34 -0
  3. package/dist/access-B5bBI4uT.mjs +39 -0
  4. package/dist/access-Crt-IJ2P.cjs +51 -0
  5. package/dist/adapter-factory-BXei1QRX.mjs +881 -0
  6. package/dist/adapter-factory-DT-_2aHJ.cjs +893 -0
  7. package/dist/adapters/drizzle-adapter/index.cjs +208 -0
  8. package/dist/adapters/drizzle-adapter/index.d.cts +48 -0
  9. package/dist/adapters/drizzle-adapter/index.d.mts +48 -0
  10. package/dist/adapters/drizzle-adapter/index.mjs +207 -0
  11. package/dist/adapters/index.cjs +23 -0
  12. package/dist/adapters/index.d.cts +157 -0
  13. package/dist/adapters/index.d.mts +157 -0
  14. package/dist/adapters/index.mjs +17 -0
  15. package/dist/adapters/kysely-adapter/index.cjs +11 -0
  16. package/dist/adapters/kysely-adapter/index.d.cts +52 -0
  17. package/dist/adapters/kysely-adapter/index.d.mts +52 -0
  18. package/dist/adapters/kysely-adapter/index.mjs +9 -0
  19. package/dist/adapters/memory-adapter/index.cjs +9 -0
  20. package/dist/adapters/memory-adapter/index.d.cts +15 -0
  21. package/dist/adapters/memory-adapter/index.d.mts +15 -0
  22. package/dist/adapters/memory-adapter/index.mjs +9 -0
  23. package/dist/adapters/mongodb-adapter/index.cjs +9 -0
  24. package/dist/adapters/mongodb-adapter/index.d.cts +4 -0
  25. package/dist/adapters/mongodb-adapter/index.d.mts +4 -0
  26. package/dist/adapters/mongodb-adapter/index.mjs +9 -0
  27. package/dist/adapters/prisma-adapter/index.cjs +156 -0
  28. package/dist/adapters/prisma-adapter/index.d.cts +35 -0
  29. package/dist/adapters/prisma-adapter/index.d.mts +35 -0
  30. package/dist/adapters/prisma-adapter/index.mjs +155 -0
  31. package/dist/adapters/test.cjs +797 -0
  32. package/dist/adapters/test.d.cts +82 -0
  33. package/dist/adapters/test.d.mts +82 -0
  34. package/dist/adapters/test.mjs +793 -0
  35. package/dist/api/index.cjs +20 -0
  36. package/dist/api/index.d.cts +3 -0
  37. package/dist/api/index.d.mts +3 -0
  38. package/dist/api/index.mjs +20 -0
  39. package/dist/api/middleware/index.cjs +16 -0
  40. package/dist/api/middleware/index.d.cts +16 -0
  41. package/dist/api/middleware/index.d.mts +16 -0
  42. package/dist/api/middleware/index.mjs +11 -0
  43. package/dist/api-Bm89BLgN.cjs +1899 -0
  44. package/dist/api-_B7qO28y.mjs +1892 -0
  45. package/dist/auth-Bo9PDt5j.cjs +739 -0
  46. package/dist/auth-Ds4AG4h4.mjs +709 -0
  47. package/dist/bearer-0SeEmaS4.mjs +54 -0
  48. package/dist/bearer-CHeREcGT.cjs +60 -0
  49. package/dist/bun-sqlite-dialect-CfkBo2v5.mjs +155 -0
  50. package/dist/bun-sqlite-dialect-wuaC2-gh.cjs +156 -0
  51. package/dist/chunk-Ceigfy4P.mjs +39 -0
  52. package/dist/chunk-oakRccI5.cjs +60 -0
  53. package/dist/client/index.cjs +22 -0
  54. package/dist/client/index.d.cts +8 -0
  55. package/dist/client/index.d.mts +8 -0
  56. package/dist/client/index.mjs +19 -0
  57. package/dist/client/lynx/index.cjs +79 -0
  58. package/dist/client/lynx/index.d.cts +156 -0
  59. package/dist/client/lynx/index.d.mts +156 -0
  60. package/dist/client/lynx/index.mjs +76 -0
  61. package/dist/client/plugins/index.cjs +11 -0
  62. package/dist/client/plugins/index.d.cts +17 -0
  63. package/dist/client/plugins/index.d.mts +17 -0
  64. package/dist/client/plugins/index.mjs +10 -0
  65. package/dist/client/react/index.cjs +79 -0
  66. package/dist/client/react/index.d.cts +156 -0
  67. package/dist/client/react/index.d.mts +156 -0
  68. package/dist/client/react/index.mjs +76 -0
  69. package/dist/client/solid/index.cjs +51 -0
  70. package/dist/client/solid/index.d.cts +90 -0
  71. package/dist/client/solid/index.d.mts +90 -0
  72. package/dist/client/solid/index.mjs +50 -0
  73. package/dist/client/svelte/index.cjs +28 -0
  74. package/dist/client/svelte/index.d.cts +110 -0
  75. package/dist/client/svelte/index.d.mts +110 -0
  76. package/dist/client/svelte/index.mjs +28 -0
  77. package/dist/client/vue/index.cjs +68 -0
  78. package/dist/client/vue/index.d.cts +123 -0
  79. package/dist/client/vue/index.d.mts +123 -0
  80. package/dist/client/vue/index.mjs +67 -0
  81. package/dist/cookies-B5xeA6i8.cjs +456 -0
  82. package/dist/cookies-Ch1JfQIz.mjs +367 -0
  83. package/dist/crypto/index.cjs +11 -0
  84. package/dist/crypto/index.d.cts +22 -0
  85. package/dist/crypto/index.d.mts +22 -0
  86. package/dist/crypto/index.mjs +5 -0
  87. package/dist/crypto-CcTxYH82.cjs +57 -0
  88. package/dist/crypto-CyQRFtkq.mjs +41 -0
  89. package/dist/db/index.cjs +40 -0
  90. package/dist/db/index.d.cts +4 -0
  91. package/dist/db/index.d.mts +4 -0
  92. package/dist/db/index.mjs +16 -0
  93. package/dist/db-BTKyYu-_.cjs +1180 -0
  94. package/dist/db-xiJtoDgz.mjs +1119 -0
  95. package/dist/defu-B0Svx_x4.cjs +34 -0
  96. package/dist/defu-SZkpHhbR.mjs +28 -0
  97. package/dist/email-verification-C-AsfJsb.cjs +247 -0
  98. package/dist/email-verification-CWhj2qfb.mjs +228 -0
  99. package/dist/hono-BEq1NYVX.cjs +526 -0
  100. package/dist/hono-Cdukwu5K.cjs +13 -0
  101. package/dist/hono-CoKYWnXA.mjs +7 -0
  102. package/dist/hono-Covz10jU.mjs +508 -0
  103. package/dist/hono-DOM31WQz.d.cts +18 -0
  104. package/dist/hono-DuE14mmj.d.mts +18 -0
  105. package/dist/index-B-WeOMzg.d.cts +13350 -0
  106. package/dist/index-B09P9p5_.d.cts +33 -0
  107. package/dist/index-B5_0QTLg.d.mts +3 -0
  108. package/dist/index-B7SKyR_a.d.cts +3 -0
  109. package/dist/index-BVHscLQl.d.cts +992 -0
  110. package/dist/index-C2-2QDyS.d.cts +35 -0
  111. package/dist/index-CTwrVluH.d.mts +41 -0
  112. package/dist/index-CWAqWfoZ.d.cts +27 -0
  113. package/dist/index-CYSShrFx.d.mts +27 -0
  114. package/dist/index-Qu-iJGNr.d.mts +992 -0
  115. package/dist/index-cs4Sh0En.d.cts +41 -0
  116. package/dist/index-jlessPI0.d.mts +13350 -0
  117. package/dist/index-ppgcFe12.d.mts +33 -0
  118. package/dist/index-to0RO38U.d.mts +35 -0
  119. package/dist/index.cjs +85 -0
  120. package/dist/index.d.cts +5 -0
  121. package/dist/index.d.mts +5 -0
  122. package/dist/index.mjs +27 -0
  123. package/dist/integrations/next-js.cjs +50 -0
  124. package/dist/integrations/next-js.d.cts +23 -0
  125. package/dist/integrations/next-js.d.mts +23 -0
  126. package/dist/integrations/next-js.mjs +49 -0
  127. package/dist/integrations/node.cjs +139 -0
  128. package/dist/integrations/node.d.cts +22 -0
  129. package/dist/integrations/node.d.mts +22 -0
  130. package/dist/integrations/node.mjs +134 -0
  131. package/dist/integrations/react-start.cjs +37 -0
  132. package/dist/integrations/react-start.d.cts +17 -0
  133. package/dist/integrations/react-start.d.mts +17 -0
  134. package/dist/integrations/react-start.mjs +37 -0
  135. package/dist/integrations/solid-start.cjs +14 -0
  136. package/dist/integrations/solid-start.d.cts +13 -0
  137. package/dist/integrations/solid-start.d.mts +13 -0
  138. package/dist/integrations/solid-start.mjs +13 -0
  139. package/dist/integrations/svelte-kit.cjs +52 -0
  140. package/dist/integrations/svelte-kit.d.cts +42 -0
  141. package/dist/integrations/svelte-kit.d.mts +42 -0
  142. package/dist/integrations/svelte-kit.mjs +49 -0
  143. package/dist/ip-B5SwXaMB.cjs +54 -0
  144. package/dist/ip-BjNYspCH.mjs +36 -0
  145. package/dist/json-B1v2qRTQ.mjs +24 -0
  146. package/dist/json-CcJ2HjGo.cjs +30 -0
  147. package/dist/kysely-adapter-Bxi7sPdG.cjs +288 -0
  148. package/dist/kysely-adapter-DRuoT_X8.mjs +270 -0
  149. package/dist/logged-CyGfp8_H.mjs +187 -0
  150. package/dist/logged-DQK3C64b.cjs +193 -0
  151. package/dist/memory-adapter-BlnDIAAX.cjs +154 -0
  152. package/dist/memory-adapter-Db3tsJTn.mjs +148 -0
  153. package/dist/middleware-CE6OhDkq.mjs +29 -0
  154. package/dist/middleware-CWvRH4EW.cjs +47 -0
  155. package/dist/mongodb-adapter-C_qGQED5.mjs +291 -0
  156. package/dist/mongodb-adapter-C_qfK87x.cjs +297 -0
  157. package/dist/node-sqlite-dialect-BfBzyOAg.mjs +155 -0
  158. package/dist/node-sqlite-dialect-mJWC8LWQ.cjs +156 -0
  159. package/dist/oauth2/index.cjs +25 -0
  160. package/dist/oauth2/index.d.cts +42 -0
  161. package/dist/oauth2/index.d.mts +42 -0
  162. package/dist/oauth2/index.mjs +16 -0
  163. package/dist/oauth2-B8M0lW9l.mjs +159 -0
  164. package/dist/oauth2-BLeOEi7Y.cjs +177 -0
  165. package/dist/origin-check-8Gajklvh.mjs +228 -0
  166. package/dist/origin-check-id9lTnqZ.cjs +246 -0
  167. package/dist/parser-CdncAl9i.cjs +83 -0
  168. package/dist/parser-CeAer-RM.mjs +71 -0
  169. package/dist/passkey-B6N20LSS.cjs +512 -0
  170. package/dist/passkey-DJsR_GX3.mjs +505 -0
  171. package/dist/plugins/access/index.cjs +4 -0
  172. package/dist/plugins/access/index.d.cts +2 -0
  173. package/dist/plugins/access/index.d.mts +2 -0
  174. package/dist/plugins/access/index.mjs +3 -0
  175. package/dist/plugins/bearer/index.cjs +7 -0
  176. package/dist/plugins/bearer/index.d.cts +4 -0
  177. package/dist/plugins/bearer/index.d.mts +4 -0
  178. package/dist/plugins/bearer/index.mjs +7 -0
  179. package/dist/plugins/index.cjs +49 -0
  180. package/dist/plugins/index.d.cts +9326 -0
  181. package/dist/plugins/index.d.mts +9326 -0
  182. package/dist/plugins/index.mjs +26 -0
  183. package/dist/plugins/passkey/index.cjs +15 -0
  184. package/dist/plugins/passkey/index.d.cts +4 -0
  185. package/dist/plugins/passkey/index.d.mts +4 -0
  186. package/dist/plugins/passkey/index.mjs +15 -0
  187. package/dist/plugins-C1lm2Wj3.cjs +5254 -0
  188. package/dist/plugins-Dai1QkRU.mjs +5199 -0
  189. package/dist/request-1NL_1lyJ.mjs +58 -0
  190. package/dist/request-CPNlp-DK.cjs +100 -0
  191. package/dist/schema-D-qjygfE.cjs +179 -0
  192. package/dist/schema-DTIwLLmf.mjs +125 -0
  193. package/dist/session-De9POJTW.cjs +641 -0
  194. package/dist/session-rH8ougDl.mjs +538 -0
  195. package/dist/social-providers/index.cjs +10 -0
  196. package/dist/social-providers/index.d.cts +2 -0
  197. package/dist/social-providers/index.d.mts +2 -0
  198. package/dist/social-providers/index.mjs +5 -0
  199. package/dist/social-providers-DcFNUT0S.cjs +13 -0
  200. package/dist/social-providers-DoYJhBe3.mjs +9 -0
  201. package/dist/state--f7fwIGh.cjs +99 -0
  202. package/dist/state-CqJfCIl9.mjs +86 -0
  203. package/dist/test-utils/index.cjs +27492 -0
  204. package/dist/test-utils/index.d.cts +4584 -0
  205. package/dist/test-utils/index.d.mts +4584 -0
  206. package/dist/test-utils/index.mjs +27490 -0
  207. package/dist/types/index.cjs +0 -0
  208. package/dist/types/index.d.cts +3 -0
  209. package/dist/types/index.d.mts +3 -0
  210. package/dist/types/index.mjs +1 -0
  211. package/dist/url-BoUuoIwZ.mjs +88 -0
  212. package/dist/url-D2yvKaM7.cjs +118 -0
  213. package/dist/utils/cookies.cjs +51 -0
  214. package/dist/utils/cookies.d.cts +179 -0
  215. package/dist/utils/cookies.d.mts +179 -0
  216. package/dist/utils/cookies.mjs +7 -0
  217. package/dist/utils-44aDDP8f.cjs +2 -0
  218. package/dist/utils-D4vZd1-9.mjs +4 -0
  219. package/dist/vanilla-Bu2PmFzE.cjs +30 -0
  220. package/dist/vanilla-TfHqeiC7.mjs +25 -0
  221. package/package.json +470 -0
@@ -0,0 +1,187 @@
1
+ import { isCI, isTest } from "@faire-auth/core/env";
2
+
3
+ //#region src/utils/logged.ts
4
+ let _nodeInspect;
5
+ const inspect = (object) => {
6
+ if (!_nodeInspect) return String(object);
7
+ return _nodeInspect(object, { colors: true });
8
+ };
9
+ if (typeof globalThis.process !== "undefined") import("node:util").then((m) => {
10
+ _nodeInspect = m.inspect;
11
+ }).catch(() => {});
12
+ const MAX_SIZE = 100;
13
+ var LogQueue = class {
14
+ queue = [];
15
+ maxSize;
16
+ constructor(maxSize = MAX_SIZE) {
17
+ this.maxSize = maxSize;
18
+ }
19
+ push(log) {
20
+ this.queue.push(log);
21
+ if (this.queue.length > this.maxSize) this.queue.shift();
22
+ }
23
+ read() {
24
+ return this.queue.shift();
25
+ }
26
+ readN(n) {
27
+ return this.queue.splice(0, n);
28
+ }
29
+ readAll() {
30
+ return this.queue.splice(0);
31
+ }
32
+ peek() {
33
+ return this.queue[0];
34
+ }
35
+ peekN(n) {
36
+ return this.queue.slice(0, n);
37
+ }
38
+ peekAll() {
39
+ return [...this.queue];
40
+ }
41
+ size() {
42
+ return this.queue.length;
43
+ }
44
+ clear() {
45
+ this.queue.length = 0;
46
+ }
47
+ setMaxSize(size) {
48
+ this.maxSize = size;
49
+ if (this.queue.length > size) this.queue.splice(0, this.queue.length - size);
50
+ }
51
+ [Symbol.iterator]() {
52
+ return { next: () => {
53
+ const log = this.queue.shift();
54
+ if (log === void 0) return {
55
+ done: true,
56
+ value: void 0
57
+ };
58
+ return {
59
+ done: false,
60
+ value: log
61
+ };
62
+ } };
63
+ }
64
+ async *watch() {
65
+ while (true) {
66
+ const log = this.queue.shift();
67
+ if (log) yield log;
68
+ else await new Promise((resolve) => setTimeout(resolve, 10));
69
+ }
70
+ }
71
+ };
72
+ const logQueue = new LogQueue();
73
+ const LoggerAPI = {
74
+ wrap(target, prefix = "", strategy = "queue") {
75
+ return logged(target, prefix, strategy);
76
+ },
77
+ clear() {
78
+ logQueue.clear();
79
+ },
80
+ get size() {
81
+ return logQueue.size();
82
+ },
83
+ set size(newSize) {
84
+ logQueue.setMaxSize(newSize);
85
+ },
86
+ read: {
87
+ next(n) {
88
+ if (n == null) return logQueue.read();
89
+ return logQueue.readN(n);
90
+ },
91
+ all() {
92
+ return logQueue.readAll();
93
+ }
94
+ },
95
+ peek: {
96
+ next(n) {
97
+ if (n == null) return logQueue.peek();
98
+ return logQueue.peekN(n);
99
+ },
100
+ all() {
101
+ return logQueue.peekAll();
102
+ }
103
+ },
104
+ [Symbol.iterator]() {
105
+ return logQueue[Symbol.iterator]();
106
+ },
107
+ watch() {
108
+ return logQueue.watch();
109
+ }
110
+ };
111
+ function printLogs(logs = LoggerAPI.read.all()) {
112
+ if (logs.length === 0) return;
113
+ logs.forEach((log, i) => {
114
+ console.log(`${log.duration.toFixed(2)}ms \x1b[35m\x1b[1m${log.method}\x1b[0m(${log.input.join(", ")}): ${log.error ? inspect(log.error) : log.output}`);
115
+ });
116
+ }
117
+ function wrapFunction(fn, method, strategy) {
118
+ const queue = strategy === "immediate" ? new LogQueue() : logQueue;
119
+ const onComplete = () => {
120
+ if (strategy === "immediate") printLogs(queue.readAll());
121
+ };
122
+ return new Proxy(fn, { apply(target, thisArg, args) {
123
+ const input = args.map((a) => inspect(a));
124
+ const timestamp = /* @__PURE__ */ new Date();
125
+ const startTime = performance.now();
126
+ try {
127
+ const result = target.apply(thisArg, args);
128
+ if (result instanceof Promise) return result.then((resolvedValue) => {
129
+ const duration$1 = performance.now() - startTime;
130
+ queue.push({
131
+ method,
132
+ input,
133
+ output: inspect(resolvedValue),
134
+ timestamp,
135
+ duration: duration$1
136
+ });
137
+ return resolvedValue;
138
+ }, (error) => {
139
+ const duration$1 = performance.now() - startTime;
140
+ queue.push({
141
+ method,
142
+ input,
143
+ output: "None",
144
+ timestamp,
145
+ duration: duration$1,
146
+ error
147
+ });
148
+ throw error;
149
+ }).finally(onComplete);
150
+ const duration = performance.now() - startTime;
151
+ queue.push({
152
+ method,
153
+ input,
154
+ output: inspect(result),
155
+ timestamp,
156
+ duration
157
+ });
158
+ return result;
159
+ } catch (error) {
160
+ const duration = performance.now() - startTime;
161
+ queue.push({
162
+ method,
163
+ input,
164
+ output: "None",
165
+ timestamp,
166
+ duration,
167
+ error
168
+ });
169
+ throw error;
170
+ } finally {
171
+ onComplete();
172
+ }
173
+ } });
174
+ }
175
+ function logged(target, name, strategy = "queue") {
176
+ if (!isTest() || isCI()) return target;
177
+ if (typeof target === "function") return wrapFunction(target, name || target.name || "anonymous", strategy);
178
+ return new Proxy(target, { get(obj, prop) {
179
+ const value = obj[prop];
180
+ if (typeof value !== "function") return value;
181
+ return wrapFunction(value, name ? `${name}.${String(prop)}` : String(prop), strategy);
182
+ } });
183
+ }
184
+ var logged_default = LoggerAPI;
185
+
186
+ //#endregion
187
+ export { logged_default as t };
@@ -0,0 +1,193 @@
1
+ const require_chunk = require('./chunk-oakRccI5.cjs');
2
+ let __faire_auth_core_env = require("@faire-auth/core/env");
3
+
4
+ //#region src/utils/logged.ts
5
+ let _nodeInspect;
6
+ const inspect = (object) => {
7
+ if (!_nodeInspect) return String(object);
8
+ return _nodeInspect(object, { colors: true });
9
+ };
10
+ if (typeof globalThis.process !== "undefined") import("node:util").then((m) => {
11
+ _nodeInspect = m.inspect;
12
+ }).catch(() => {});
13
+ const MAX_SIZE = 100;
14
+ var LogQueue = class {
15
+ queue = [];
16
+ maxSize;
17
+ constructor(maxSize = MAX_SIZE) {
18
+ this.maxSize = maxSize;
19
+ }
20
+ push(log) {
21
+ this.queue.push(log);
22
+ if (this.queue.length > this.maxSize) this.queue.shift();
23
+ }
24
+ read() {
25
+ return this.queue.shift();
26
+ }
27
+ readN(n) {
28
+ return this.queue.splice(0, n);
29
+ }
30
+ readAll() {
31
+ return this.queue.splice(0);
32
+ }
33
+ peek() {
34
+ return this.queue[0];
35
+ }
36
+ peekN(n) {
37
+ return this.queue.slice(0, n);
38
+ }
39
+ peekAll() {
40
+ return [...this.queue];
41
+ }
42
+ size() {
43
+ return this.queue.length;
44
+ }
45
+ clear() {
46
+ this.queue.length = 0;
47
+ }
48
+ setMaxSize(size) {
49
+ this.maxSize = size;
50
+ if (this.queue.length > size) this.queue.splice(0, this.queue.length - size);
51
+ }
52
+ [Symbol.iterator]() {
53
+ return { next: () => {
54
+ const log = this.queue.shift();
55
+ if (log === void 0) return {
56
+ done: true,
57
+ value: void 0
58
+ };
59
+ return {
60
+ done: false,
61
+ value: log
62
+ };
63
+ } };
64
+ }
65
+ async *watch() {
66
+ while (true) {
67
+ const log = this.queue.shift();
68
+ if (log) yield log;
69
+ else await new Promise((resolve) => setTimeout(resolve, 10));
70
+ }
71
+ }
72
+ };
73
+ const logQueue = new LogQueue();
74
+ const LoggerAPI = {
75
+ wrap(target, prefix = "", strategy = "queue") {
76
+ return logged(target, prefix, strategy);
77
+ },
78
+ clear() {
79
+ logQueue.clear();
80
+ },
81
+ get size() {
82
+ return logQueue.size();
83
+ },
84
+ set size(newSize) {
85
+ logQueue.setMaxSize(newSize);
86
+ },
87
+ read: {
88
+ next(n) {
89
+ if (n == null) return logQueue.read();
90
+ return logQueue.readN(n);
91
+ },
92
+ all() {
93
+ return logQueue.readAll();
94
+ }
95
+ },
96
+ peek: {
97
+ next(n) {
98
+ if (n == null) return logQueue.peek();
99
+ return logQueue.peekN(n);
100
+ },
101
+ all() {
102
+ return logQueue.peekAll();
103
+ }
104
+ },
105
+ [Symbol.iterator]() {
106
+ return logQueue[Symbol.iterator]();
107
+ },
108
+ watch() {
109
+ return logQueue.watch();
110
+ }
111
+ };
112
+ function printLogs(logs = LoggerAPI.read.all()) {
113
+ if (logs.length === 0) return;
114
+ logs.forEach((log, i) => {
115
+ console.log(`${log.duration.toFixed(2)}ms \x1b[35m\x1b[1m${log.method}\x1b[0m(${log.input.join(", ")}): ${log.error ? inspect(log.error) : log.output}`);
116
+ });
117
+ }
118
+ function wrapFunction(fn, method, strategy) {
119
+ const queue = strategy === "immediate" ? new LogQueue() : logQueue;
120
+ const onComplete = () => {
121
+ if (strategy === "immediate") printLogs(queue.readAll());
122
+ };
123
+ return new Proxy(fn, { apply(target, thisArg, args) {
124
+ const input = args.map((a) => inspect(a));
125
+ const timestamp = /* @__PURE__ */ new Date();
126
+ const startTime = performance.now();
127
+ try {
128
+ const result = target.apply(thisArg, args);
129
+ if (result instanceof Promise) return result.then((resolvedValue) => {
130
+ const duration$1 = performance.now() - startTime;
131
+ queue.push({
132
+ method,
133
+ input,
134
+ output: inspect(resolvedValue),
135
+ timestamp,
136
+ duration: duration$1
137
+ });
138
+ return resolvedValue;
139
+ }, (error) => {
140
+ const duration$1 = performance.now() - startTime;
141
+ queue.push({
142
+ method,
143
+ input,
144
+ output: "None",
145
+ timestamp,
146
+ duration: duration$1,
147
+ error
148
+ });
149
+ throw error;
150
+ }).finally(onComplete);
151
+ const duration = performance.now() - startTime;
152
+ queue.push({
153
+ method,
154
+ input,
155
+ output: inspect(result),
156
+ timestamp,
157
+ duration
158
+ });
159
+ return result;
160
+ } catch (error) {
161
+ const duration = performance.now() - startTime;
162
+ queue.push({
163
+ method,
164
+ input,
165
+ output: "None",
166
+ timestamp,
167
+ duration,
168
+ error
169
+ });
170
+ throw error;
171
+ } finally {
172
+ onComplete();
173
+ }
174
+ } });
175
+ }
176
+ function logged(target, name, strategy = "queue") {
177
+ if (!(0, __faire_auth_core_env.isTest)() || (0, __faire_auth_core_env.isCI)()) return target;
178
+ if (typeof target === "function") return wrapFunction(target, name || target.name || "anonymous", strategy);
179
+ return new Proxy(target, { get(obj, prop) {
180
+ const value = obj[prop];
181
+ if (typeof value !== "function") return value;
182
+ return wrapFunction(value, name ? `${name}.${String(prop)}` : String(prop), strategy);
183
+ } });
184
+ }
185
+ var logged_default = LoggerAPI;
186
+
187
+ //#endregion
188
+ Object.defineProperty(exports, 'logged_default', {
189
+ enumerable: true,
190
+ get: function () {
191
+ return logged_default;
192
+ }
193
+ });
@@ -0,0 +1,154 @@
1
+ const require_chunk = require('./chunk-oakRccI5.cjs');
2
+ const require_adapter_factory = require('./adapter-factory-DT-_2aHJ.cjs');
3
+ let __faire_auth_core_env = require("@faire-auth/core/env");
4
+
5
+ //#region src/adapters/memory-adapter/memory-adapter.ts
6
+ const memoryAdapter = (db, config) => {
7
+ let lazyOptions = null;
8
+ let adapterCreator = require_adapter_factory.createAdapterFactory({
9
+ config: {
10
+ adapterId: "memory",
11
+ adapterName: "Memory Adapter",
12
+ usePlural: false,
13
+ debugLogs: config?.debugLogs || false,
14
+ customTransformInput(props) {
15
+ if (props.options.advanced?.database?.useNumberId && props.field === "id" && props.action === "create") return db[props.model].length + 1;
16
+ return props.data;
17
+ },
18
+ transaction: async (cb) => {
19
+ let clone = structuredClone(db);
20
+ try {
21
+ return await cb(adapterCreator(lazyOptions));
22
+ } catch (error) {
23
+ Object.keys(db).forEach((key) => {
24
+ db[key] = clone[key];
25
+ });
26
+ throw error;
27
+ }
28
+ }
29
+ },
30
+ adapter: ({ getFieldName, options, debugLog }) => {
31
+ function convertWhereClause(where, model) {
32
+ const table = db[model];
33
+ if (!table) {
34
+ __faire_auth_core_env.logger.error(`[MemoryAdapter] Model ${model} not found in the DB`, Object.keys(db));
35
+ throw new Error(`Model ${model} not found`);
36
+ }
37
+ const evalClause = (record, clause) => {
38
+ const { field, value, operator } = clause;
39
+ switch (operator) {
40
+ case "in":
41
+ if (!Array.isArray(value)) throw new Error("Value must be an array");
42
+ return value.includes(record[field]);
43
+ case "not_in":
44
+ if (!Array.isArray(value)) throw new Error("Value must be an array");
45
+ return !value.includes(record[field]);
46
+ case "contains": return record[field].includes(value);
47
+ case "starts_with": return record[field].startsWith(value);
48
+ case "ends_with": return record[field].endsWith(value);
49
+ case "ne": return record[field] !== value;
50
+ case "gt": return value != null && Boolean(record[field] > value);
51
+ case "gte": return value != null && Boolean(record[field] >= value);
52
+ case "lt": return value != null && Boolean(record[field] < value);
53
+ case "lte": return value != null && Boolean(record[field] <= value);
54
+ default: return record[field] === value;
55
+ }
56
+ };
57
+ return table.filter((record) => {
58
+ if (!where.length || where.length === 0) return true;
59
+ let result = evalClause(record, where[0]);
60
+ for (const clause of where) {
61
+ const clauseResult = evalClause(record, clause);
62
+ if (clause.connector === "OR") result = result || clauseResult;
63
+ else result = result && clauseResult;
64
+ }
65
+ return result;
66
+ });
67
+ }
68
+ return {
69
+ create: async ({ model, data }) => {
70
+ if (options.advanced?.database?.useNumberId) data.id = db[model].length + 1;
71
+ if (!db[model]) db[model] = [];
72
+ db[model].push(data);
73
+ return data;
74
+ },
75
+ findOne: async ({ model, where }) => {
76
+ return convertWhereClause(where, model)[0] || null;
77
+ },
78
+ findMany: async ({ model, where, sortBy, limit, offset }) => {
79
+ let table = db[model];
80
+ if (where) table = convertWhereClause(where, model);
81
+ if (sortBy) table = table.sort((a, b) => {
82
+ const field = getFieldName({
83
+ model,
84
+ field: sortBy.field
85
+ });
86
+ const aValue = a[field];
87
+ const bValue = b[field];
88
+ let comparison = 0;
89
+ if (aValue == null && bValue == null) comparison = 0;
90
+ else if (aValue == null) comparison = -1;
91
+ else if (bValue == null) comparison = 1;
92
+ else if (typeof aValue === "string" && typeof bValue === "string") comparison = aValue.localeCompare(bValue);
93
+ else if (aValue instanceof Date && bValue instanceof Date) comparison = aValue.getTime() - bValue.getTime();
94
+ else if (typeof aValue === "number" && typeof bValue === "number") comparison = aValue - bValue;
95
+ else if (typeof aValue === "boolean" && typeof bValue === "boolean") comparison = aValue === bValue ? 0 : aValue ? 1 : -1;
96
+ else comparison = String(aValue).localeCompare(String(bValue));
97
+ return sortBy.direction === "asc" ? comparison : -comparison;
98
+ });
99
+ if (offset !== void 0) table = table.slice(offset);
100
+ if (limit !== void 0) table = table.slice(0, limit);
101
+ return table || [];
102
+ },
103
+ count: async ({ model, where }) => {
104
+ if (where) return convertWhereClause(where, model).length;
105
+ return db[model].length;
106
+ },
107
+ update: async ({ model, where, update }) => {
108
+ const res = convertWhereClause(where, model);
109
+ res.forEach((record) => {
110
+ Object.assign(record, update);
111
+ });
112
+ return res[0] || null;
113
+ },
114
+ delete: async ({ model, where }) => {
115
+ const table = db[model];
116
+ const res = convertWhereClause(where, model);
117
+ db[model] = table.filter((record) => !res.includes(record));
118
+ },
119
+ deleteMany: async ({ model, where }) => {
120
+ const table = db[model];
121
+ const res = convertWhereClause(where, model);
122
+ let count = 0;
123
+ db[model] = table.filter((record) => {
124
+ if (res.includes(record)) {
125
+ count++;
126
+ return false;
127
+ }
128
+ return !res.includes(record);
129
+ });
130
+ return count;
131
+ },
132
+ updateMany({ model, where, update }) {
133
+ const res = convertWhereClause(where, model);
134
+ res.forEach((record) => {
135
+ Object.assign(record, update);
136
+ });
137
+ return res[0] || null;
138
+ }
139
+ };
140
+ }
141
+ });
142
+ return (options) => {
143
+ lazyOptions = options;
144
+ return adapterCreator(options);
145
+ };
146
+ };
147
+
148
+ //#endregion
149
+ Object.defineProperty(exports, 'memoryAdapter', {
150
+ enumerable: true,
151
+ get: function () {
152
+ return memoryAdapter;
153
+ }
154
+ });
@@ -0,0 +1,148 @@
1
+ import { t as createAdapterFactory } from "./adapter-factory-BXei1QRX.mjs";
2
+ import { logger } from "@faire-auth/core/env";
3
+
4
+ //#region src/adapters/memory-adapter/memory-adapter.ts
5
+ const memoryAdapter = (db, config) => {
6
+ let lazyOptions = null;
7
+ let adapterCreator = createAdapterFactory({
8
+ config: {
9
+ adapterId: "memory",
10
+ adapterName: "Memory Adapter",
11
+ usePlural: false,
12
+ debugLogs: config?.debugLogs || false,
13
+ customTransformInput(props) {
14
+ if (props.options.advanced?.database?.useNumberId && props.field === "id" && props.action === "create") return db[props.model].length + 1;
15
+ return props.data;
16
+ },
17
+ transaction: async (cb) => {
18
+ let clone = structuredClone(db);
19
+ try {
20
+ return await cb(adapterCreator(lazyOptions));
21
+ } catch (error) {
22
+ Object.keys(db).forEach((key) => {
23
+ db[key] = clone[key];
24
+ });
25
+ throw error;
26
+ }
27
+ }
28
+ },
29
+ adapter: ({ getFieldName, options, debugLog }) => {
30
+ function convertWhereClause(where, model) {
31
+ const table = db[model];
32
+ if (!table) {
33
+ logger.error(`[MemoryAdapter] Model ${model} not found in the DB`, Object.keys(db));
34
+ throw new Error(`Model ${model} not found`);
35
+ }
36
+ const evalClause = (record, clause) => {
37
+ const { field, value, operator } = clause;
38
+ switch (operator) {
39
+ case "in":
40
+ if (!Array.isArray(value)) throw new Error("Value must be an array");
41
+ return value.includes(record[field]);
42
+ case "not_in":
43
+ if (!Array.isArray(value)) throw new Error("Value must be an array");
44
+ return !value.includes(record[field]);
45
+ case "contains": return record[field].includes(value);
46
+ case "starts_with": return record[field].startsWith(value);
47
+ case "ends_with": return record[field].endsWith(value);
48
+ case "ne": return record[field] !== value;
49
+ case "gt": return value != null && Boolean(record[field] > value);
50
+ case "gte": return value != null && Boolean(record[field] >= value);
51
+ case "lt": return value != null && Boolean(record[field] < value);
52
+ case "lte": return value != null && Boolean(record[field] <= value);
53
+ default: return record[field] === value;
54
+ }
55
+ };
56
+ return table.filter((record) => {
57
+ if (!where.length || where.length === 0) return true;
58
+ let result = evalClause(record, where[0]);
59
+ for (const clause of where) {
60
+ const clauseResult = evalClause(record, clause);
61
+ if (clause.connector === "OR") result = result || clauseResult;
62
+ else result = result && clauseResult;
63
+ }
64
+ return result;
65
+ });
66
+ }
67
+ return {
68
+ create: async ({ model, data }) => {
69
+ if (options.advanced?.database?.useNumberId) data.id = db[model].length + 1;
70
+ if (!db[model]) db[model] = [];
71
+ db[model].push(data);
72
+ return data;
73
+ },
74
+ findOne: async ({ model, where }) => {
75
+ return convertWhereClause(where, model)[0] || null;
76
+ },
77
+ findMany: async ({ model, where, sortBy, limit, offset }) => {
78
+ let table = db[model];
79
+ if (where) table = convertWhereClause(where, model);
80
+ if (sortBy) table = table.sort((a, b) => {
81
+ const field = getFieldName({
82
+ model,
83
+ field: sortBy.field
84
+ });
85
+ const aValue = a[field];
86
+ const bValue = b[field];
87
+ let comparison = 0;
88
+ if (aValue == null && bValue == null) comparison = 0;
89
+ else if (aValue == null) comparison = -1;
90
+ else if (bValue == null) comparison = 1;
91
+ else if (typeof aValue === "string" && typeof bValue === "string") comparison = aValue.localeCompare(bValue);
92
+ else if (aValue instanceof Date && bValue instanceof Date) comparison = aValue.getTime() - bValue.getTime();
93
+ else if (typeof aValue === "number" && typeof bValue === "number") comparison = aValue - bValue;
94
+ else if (typeof aValue === "boolean" && typeof bValue === "boolean") comparison = aValue === bValue ? 0 : aValue ? 1 : -1;
95
+ else comparison = String(aValue).localeCompare(String(bValue));
96
+ return sortBy.direction === "asc" ? comparison : -comparison;
97
+ });
98
+ if (offset !== void 0) table = table.slice(offset);
99
+ if (limit !== void 0) table = table.slice(0, limit);
100
+ return table || [];
101
+ },
102
+ count: async ({ model, where }) => {
103
+ if (where) return convertWhereClause(where, model).length;
104
+ return db[model].length;
105
+ },
106
+ update: async ({ model, where, update }) => {
107
+ const res = convertWhereClause(where, model);
108
+ res.forEach((record) => {
109
+ Object.assign(record, update);
110
+ });
111
+ return res[0] || null;
112
+ },
113
+ delete: async ({ model, where }) => {
114
+ const table = db[model];
115
+ const res = convertWhereClause(where, model);
116
+ db[model] = table.filter((record) => !res.includes(record));
117
+ },
118
+ deleteMany: async ({ model, where }) => {
119
+ const table = db[model];
120
+ const res = convertWhereClause(where, model);
121
+ let count = 0;
122
+ db[model] = table.filter((record) => {
123
+ if (res.includes(record)) {
124
+ count++;
125
+ return false;
126
+ }
127
+ return !res.includes(record);
128
+ });
129
+ return count;
130
+ },
131
+ updateMany({ model, where, update }) {
132
+ const res = convertWhereClause(where, model);
133
+ res.forEach((record) => {
134
+ Object.assign(record, update);
135
+ });
136
+ return res[0] || null;
137
+ }
138
+ };
139
+ }
140
+ });
141
+ return (options) => {
142
+ lazyOptions = options;
143
+ return adapterCreator(options);
144
+ };
145
+ };
146
+
147
+ //#endregion
148
+ export { memoryAdapter as t };
@@ -0,0 +1,29 @@
1
+ //#region src/api/factory/middleware.ts
2
+ /**
3
+ * Creates a hook handler.
4
+ * @template E - The environment type.
5
+ * @template P - The path type.
6
+ * @template I - The input type.
7
+ * @param handler - The hook handler function.
8
+ * @returns The hook handler.
9
+ */
10
+ const createHook = () => (handler) => handler;
11
+ /**
12
+ * Creates a middleware handler.
13
+ * @template E - The environment type.
14
+ * @template P - The path type.
15
+ * @template I - The input type.
16
+ * @param handler - The middleware handler function.
17
+ * @returns The middleware handler.
18
+ */
19
+ const createMiddleware = () => (handler) => handler;
20
+ /**
21
+ * Creates an error handler.
22
+ * @template E - The environment type.
23
+ * @param handler - The error handler function.
24
+ * @returns The error handler.
25
+ */
26
+ const createErrorHandler = () => (handler) => handler;
27
+
28
+ //#endregion
29
+ export { createHook as n, createMiddleware as r, createErrorHandler as t };