@rebasepro/server-core 0.7.0 → 0.8.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 (155) hide show
  1. package/build-errors.txt +52 -0
  2. package/dist/api/ast-schema-editor.d.ts +21 -0
  3. package/dist/api/collections_for_test/callbacks_test_collection.d.ts +2 -0
  4. package/dist/api/errors.d.ts +53 -0
  5. package/dist/api/graphql/graphql-schema-generator.d.ts +44 -0
  6. package/dist/api/graphql/index.d.ts +1 -0
  7. package/dist/api/index.d.ts +9 -0
  8. package/dist/api/logs-routes.d.ts +37 -0
  9. package/dist/api/openapi-generator.d.ts +16 -0
  10. package/dist/api/rest/api-generator.d.ts +76 -0
  11. package/dist/api/rest/index.d.ts +1 -0
  12. package/dist/api/rest/query-parser.d.ts +8 -0
  13. package/dist/api/schema-editor-routes.d.ts +3 -0
  14. package/dist/api/server.d.ts +40 -0
  15. package/dist/api/types.d.ts +104 -0
  16. package/dist/auth/adapter-middleware.d.ts +43 -0
  17. package/dist/auth/admin-roles-route.d.ts +18 -0
  18. package/dist/auth/admin-user-ops.d.ts +79 -0
  19. package/dist/auth/admin-users-route.d.ts +28 -0
  20. package/dist/auth/api-keys/api-key-middleware.d.ts +39 -0
  21. package/dist/auth/api-keys/api-key-permission-guard.d.ts +32 -0
  22. package/dist/auth/api-keys/api-key-routes.d.ts +20 -0
  23. package/dist/auth/api-keys/api-key-store.d.ts +35 -0
  24. package/dist/auth/api-keys/api-key-types.d.ts +96 -0
  25. package/dist/auth/api-keys/index.d.ts +17 -0
  26. package/dist/auth/apple-oauth.d.ts +30 -0
  27. package/dist/auth/auth-hooks.d.ts +242 -0
  28. package/dist/auth/bitbucket-oauth.d.ts +11 -0
  29. package/dist/auth/builtin-auth-adapter.d.ts +51 -0
  30. package/dist/auth/crypto-utils.d.ts +16 -0
  31. package/dist/auth/custom-auth-adapter.d.ts +39 -0
  32. package/dist/auth/discord-oauth.d.ts +14 -0
  33. package/dist/auth/facebook-oauth.d.ts +14 -0
  34. package/dist/auth/github-oauth.d.ts +15 -0
  35. package/dist/auth/gitlab-oauth.d.ts +13 -0
  36. package/dist/auth/google-oauth.d.ts +47 -0
  37. package/dist/auth/index.d.ts +37 -0
  38. package/dist/auth/interfaces.d.ts +431 -0
  39. package/dist/auth/jwt.d.ts +55 -0
  40. package/dist/auth/linkedin-oauth.d.ts +18 -0
  41. package/dist/auth/magic-link-routes.d.ts +30 -0
  42. package/dist/auth/mfa-crypto.d.ts +23 -0
  43. package/dist/auth/mfa-routes.d.ts +7 -0
  44. package/dist/auth/mfa.d.ts +49 -0
  45. package/dist/auth/microsoft-oauth.d.ts +16 -0
  46. package/dist/auth/middleware.d.ts +113 -0
  47. package/dist/auth/password.d.ts +22 -0
  48. package/dist/auth/rate-limiter.d.ts +50 -0
  49. package/dist/auth/reset-password-admin.d.ts +29 -0
  50. package/dist/auth/rls-scope.d.ts +31 -0
  51. package/dist/auth/routes.d.ts +35 -0
  52. package/dist/auth/session-routes.d.ts +27 -0
  53. package/dist/auth/slack-oauth.d.ts +12 -0
  54. package/dist/auth/spotify-oauth.d.ts +12 -0
  55. package/dist/auth/twitter-oauth.d.ts +18 -0
  56. package/dist/backend-CIxN4FVm.js +15 -0
  57. package/dist/backend-CIxN4FVm.js.map +1 -0
  58. package/dist/base64-js-C_frYBkI.js +1687 -0
  59. package/dist/base64-js-C_frYBkI.js.map +1 -0
  60. package/dist/chunk-Dze3rakg.js +42 -0
  61. package/dist/collections/BackendCollectionRegistry.d.ts +13 -0
  62. package/dist/collections/loader.d.ts +5 -0
  63. package/dist/cron/cron-loader.d.ts +17 -0
  64. package/dist/cron/cron-routes.d.ts +14 -0
  65. package/dist/cron/cron-scheduler.d.ts +106 -0
  66. package/dist/cron/cron-store.d.ts +32 -0
  67. package/dist/cron/index.d.ts +6 -0
  68. package/dist/db/interfaces.d.ts +18 -0
  69. package/dist/dist-DMO-zF6D.js +832 -0
  70. package/dist/dist-DMO-zF6D.js.map +1 -0
  71. package/dist/email/index.d.ts +6 -0
  72. package/dist/email/smtp-email-service.d.ts +25 -0
  73. package/dist/email/templates.d.ts +50 -0
  74. package/dist/email/types.d.ts +126 -0
  75. package/dist/env.d.ts +102 -0
  76. package/dist/from-VbwD7xRf.js +3849 -0
  77. package/dist/from-VbwD7xRf.js.map +1 -0
  78. package/dist/functions/define-function.d.ts +50 -0
  79. package/dist/functions/function-loader.d.ts +17 -0
  80. package/dist/functions/function-routes.d.ts +10 -0
  81. package/dist/functions/index.d.ts +5 -0
  82. package/dist/history/history-routes.d.ts +23 -0
  83. package/dist/history/index.d.ts +1 -0
  84. package/dist/index.d.ts +31 -0
  85. package/dist/index.es.js +61322 -0
  86. package/dist/index.es.js.map +1 -0
  87. package/dist/index.umd.js +103633 -0
  88. package/dist/index.umd.js.map +1 -0
  89. package/dist/init/docs.d.ts +4 -0
  90. package/dist/init/health.d.ts +2 -0
  91. package/dist/init/middlewares.d.ts +10 -0
  92. package/dist/init/shutdown.d.ts +11 -0
  93. package/dist/init/storage.d.ts +5 -0
  94. package/dist/init.d.ts +314 -0
  95. package/dist/jws-BqRRaK11.js +616 -0
  96. package/dist/jws-BqRRaK11.js.map +1 -0
  97. package/dist/jwt-BETC8a1J.js +3560 -0
  98. package/dist/jwt-BETC8a1J.js.map +1 -0
  99. package/dist/logger-BYU66ENZ.js +94 -0
  100. package/dist/logger-BYU66ENZ.js.map +1 -0
  101. package/dist/ms-BeBSuOXN.js +125 -0
  102. package/dist/ms-BeBSuOXN.js.map +1 -0
  103. package/dist/multipart-parser-CedBDOeC.js +299 -0
  104. package/dist/multipart-parser-CedBDOeC.js.map +1 -0
  105. package/dist/serve-spa.d.ts +30 -0
  106. package/dist/services/driver-registry.d.ts +78 -0
  107. package/dist/services/routed-realtime-service.d.ts +43 -0
  108. package/dist/services/webhook-service.d.ts +29 -0
  109. package/dist/singleton.d.ts +35 -0
  110. package/dist/src-CB2PIpBe.js +1182 -0
  111. package/dist/src-CB2PIpBe.js.map +1 -0
  112. package/dist/src-DjzOT1kG.js +29746 -0
  113. package/dist/src-DjzOT1kG.js.map +1 -0
  114. package/dist/storage/GCSStorageController.d.ts +43 -0
  115. package/dist/storage/LocalStorageController.d.ts +46 -0
  116. package/dist/storage/S3StorageController.d.ts +36 -0
  117. package/dist/storage/image-transform.d.ts +50 -0
  118. package/dist/storage/index.d.ts +31 -0
  119. package/dist/storage/routes.d.ts +70 -0
  120. package/dist/storage/storage-registry.d.ts +78 -0
  121. package/dist/storage/tus-handler.d.ts +53 -0
  122. package/dist/storage/types.d.ts +128 -0
  123. package/dist/types/index.d.ts +11 -0
  124. package/dist/utils/dev-port.d.ts +37 -0
  125. package/dist/utils/logger.d.ts +31 -0
  126. package/dist/utils/logging.d.ts +9 -0
  127. package/dist/utils/request-id.d.ts +4 -0
  128. package/dist/utils/request-logger.d.ts +19 -0
  129. package/dist/utils/sql.d.ts +27 -0
  130. package/package.json +22 -14
  131. package/src/api/graphql/graphql-schema-generator.ts +5 -5
  132. package/src/api/openapi-generator.ts +2 -2
  133. package/src/api/rest/api-generator.ts +44 -123
  134. package/src/api/rest/query-parser.ts +6 -23
  135. package/src/api/types.ts +2 -2
  136. package/src/auth/auth-hooks.ts +1 -1
  137. package/src/auth/builtin-auth-adapter.ts +1 -2
  138. package/src/auth/interfaces.ts +11 -2
  139. package/src/auth/middleware.ts +4 -4
  140. package/src/auth/routes.ts +1 -2
  141. package/src/functions/define-function.ts +59 -0
  142. package/src/functions/function-loader.ts +16 -0
  143. package/src/functions/index.ts +2 -0
  144. package/src/index.ts +70 -37
  145. package/src/init.ts +78 -21
  146. package/src/storage/GCSStorageController.ts +334 -0
  147. package/src/storage/index.ts +9 -3
  148. package/src/storage/routes.ts +191 -23
  149. package/src/storage/tus-handler.ts +16 -4
  150. package/src/storage/types.ts +25 -3
  151. package/test/api-generator.test.ts +1 -1
  152. package/test/auth-config-types.test.ts +40 -0
  153. package/test/define-function.test.ts +45 -0
  154. package/test/storage-routes.test.ts +160 -0
  155. package/test/backend-hooks-data.test.ts +0 -477
@@ -0,0 +1,832 @@
1
+ import { createRequire as __createRequire } from "module";
2
+ import process from "process";
3
+ __createRequire(import.meta.url);
4
+ import { i as __require, t as __commonJSMin } from "./chunk-Dze3rakg.js";
5
+ import { t as require_ms } from "./ms-BeBSuOXN.js";
6
+ //#region ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
7
+ var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8
+ /**
9
+ * This is the common logic for both the Node.js and web browser
10
+ * implementations of `debug()`.
11
+ */
12
+ function setup(env) {
13
+ createDebug.debug = createDebug;
14
+ createDebug.default = createDebug;
15
+ createDebug.coerce = coerce;
16
+ createDebug.disable = disable;
17
+ createDebug.enable = enable;
18
+ createDebug.enabled = enabled;
19
+ createDebug.humanize = require_ms();
20
+ createDebug.destroy = destroy;
21
+ Object.keys(env).forEach((key) => {
22
+ createDebug[key] = env[key];
23
+ });
24
+ /**
25
+ * The currently active debug mode names, and names to skip.
26
+ */
27
+ createDebug.names = [];
28
+ createDebug.skips = [];
29
+ /**
30
+ * Map of special "%n" handling functions, for the debug "format" argument.
31
+ *
32
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
33
+ */
34
+ createDebug.formatters = {};
35
+ /**
36
+ * Selects a color for a debug namespace
37
+ * @param {String} namespace The namespace string for the debug instance to be colored
38
+ * @return {Number|String} An ANSI color code for the given namespace
39
+ * @api private
40
+ */
41
+ function selectColor(namespace) {
42
+ let hash = 0;
43
+ for (let i = 0; i < namespace.length; i++) {
44
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
45
+ hash |= 0;
46
+ }
47
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
48
+ }
49
+ createDebug.selectColor = selectColor;
50
+ /**
51
+ * Create a debugger with the given `namespace`.
52
+ *
53
+ * @param {String} namespace
54
+ * @return {Function}
55
+ * @api public
56
+ */
57
+ function createDebug(namespace) {
58
+ let prevTime;
59
+ let enableOverride = null;
60
+ let namespacesCache;
61
+ let enabledCache;
62
+ function debug(...args) {
63
+ if (!debug.enabled) return;
64
+ const self = debug;
65
+ const curr = Number(/* @__PURE__ */ new Date());
66
+ self.diff = curr - (prevTime || curr);
67
+ self.prev = prevTime;
68
+ self.curr = curr;
69
+ prevTime = curr;
70
+ args[0] = createDebug.coerce(args[0]);
71
+ if (typeof args[0] !== "string") args.unshift("%O");
72
+ let index = 0;
73
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
74
+ if (match === "%%") return "%";
75
+ index++;
76
+ const formatter = createDebug.formatters[format];
77
+ if (typeof formatter === "function") {
78
+ const val = args[index];
79
+ match = formatter.call(self, val);
80
+ args.splice(index, 1);
81
+ index--;
82
+ }
83
+ return match;
84
+ });
85
+ createDebug.formatArgs.call(self, args);
86
+ (self.log || createDebug.log).apply(self, args);
87
+ }
88
+ debug.namespace = namespace;
89
+ debug.useColors = createDebug.useColors();
90
+ debug.color = createDebug.selectColor(namespace);
91
+ debug.extend = extend;
92
+ debug.destroy = createDebug.destroy;
93
+ Object.defineProperty(debug, "enabled", {
94
+ enumerable: true,
95
+ configurable: false,
96
+ get: () => {
97
+ if (enableOverride !== null) return enableOverride;
98
+ if (namespacesCache !== createDebug.namespaces) {
99
+ namespacesCache = createDebug.namespaces;
100
+ enabledCache = createDebug.enabled(namespace);
101
+ }
102
+ return enabledCache;
103
+ },
104
+ set: (v) => {
105
+ enableOverride = v;
106
+ }
107
+ });
108
+ if (typeof createDebug.init === "function") createDebug.init(debug);
109
+ return debug;
110
+ }
111
+ function extend(namespace, delimiter) {
112
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
113
+ newDebug.log = this.log;
114
+ return newDebug;
115
+ }
116
+ /**
117
+ * Enables a debug mode by namespaces. This can include modes
118
+ * separated by a colon and wildcards.
119
+ *
120
+ * @param {String} namespaces
121
+ * @api public
122
+ */
123
+ function enable(namespaces) {
124
+ createDebug.save(namespaces);
125
+ createDebug.namespaces = namespaces;
126
+ createDebug.names = [];
127
+ createDebug.skips = [];
128
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
129
+ for (const ns of split) if (ns[0] === "-") createDebug.skips.push(ns.slice(1));
130
+ else createDebug.names.push(ns);
131
+ }
132
+ /**
133
+ * Checks if the given string matches a namespace template, honoring
134
+ * asterisks as wildcards.
135
+ *
136
+ * @param {String} search
137
+ * @param {String} template
138
+ * @return {Boolean}
139
+ */
140
+ function matchesTemplate(search, template) {
141
+ let searchIndex = 0;
142
+ let templateIndex = 0;
143
+ let starIndex = -1;
144
+ let matchIndex = 0;
145
+ while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") {
146
+ starIndex = templateIndex;
147
+ matchIndex = searchIndex;
148
+ templateIndex++;
149
+ } else {
150
+ searchIndex++;
151
+ templateIndex++;
152
+ }
153
+ else if (starIndex !== -1) {
154
+ templateIndex = starIndex + 1;
155
+ matchIndex++;
156
+ searchIndex = matchIndex;
157
+ } else return false;
158
+ while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++;
159
+ return templateIndex === template.length;
160
+ }
161
+ /**
162
+ * Disable debug output.
163
+ *
164
+ * @return {String} namespaces
165
+ * @api public
166
+ */
167
+ function disable() {
168
+ const namespaces = [...createDebug.names, ...createDebug.skips.map((namespace) => "-" + namespace)].join(",");
169
+ createDebug.enable("");
170
+ return namespaces;
171
+ }
172
+ /**
173
+ * Returns true if the given mode name is enabled, false otherwise.
174
+ *
175
+ * @param {String} name
176
+ * @return {Boolean}
177
+ * @api public
178
+ */
179
+ function enabled(name) {
180
+ for (const skip of createDebug.skips) if (matchesTemplate(name, skip)) return false;
181
+ for (const ns of createDebug.names) if (matchesTemplate(name, ns)) return true;
182
+ return false;
183
+ }
184
+ /**
185
+ * Coerce `val`.
186
+ *
187
+ * @param {Mixed} val
188
+ * @return {Mixed}
189
+ * @api private
190
+ */
191
+ function coerce(val) {
192
+ if (val instanceof Error) return val.stack || val.message;
193
+ return val;
194
+ }
195
+ /**
196
+ * XXX DO NOT USE. This is a temporary stub function.
197
+ * XXX It WILL be removed in the next major release.
198
+ */
199
+ function destroy() {
200
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
201
+ }
202
+ createDebug.enable(createDebug.load());
203
+ return createDebug;
204
+ }
205
+ module.exports = setup;
206
+ }));
207
+ //#endregion
208
+ //#region ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
209
+ var require_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
210
+ /**
211
+ * This is the web browser implementation of `debug()`.
212
+ */
213
+ exports.formatArgs = formatArgs;
214
+ exports.save = save;
215
+ exports.load = load;
216
+ exports.useColors = useColors;
217
+ exports.storage = localstorage();
218
+ exports.destroy = (() => {
219
+ let warned = false;
220
+ return () => {
221
+ if (!warned) {
222
+ warned = true;
223
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
224
+ }
225
+ };
226
+ })();
227
+ /**
228
+ * Colors.
229
+ */
230
+ exports.colors = [
231
+ "#0000CC",
232
+ "#0000FF",
233
+ "#0033CC",
234
+ "#0033FF",
235
+ "#0066CC",
236
+ "#0066FF",
237
+ "#0099CC",
238
+ "#0099FF",
239
+ "#00CC00",
240
+ "#00CC33",
241
+ "#00CC66",
242
+ "#00CC99",
243
+ "#00CCCC",
244
+ "#00CCFF",
245
+ "#3300CC",
246
+ "#3300FF",
247
+ "#3333CC",
248
+ "#3333FF",
249
+ "#3366CC",
250
+ "#3366FF",
251
+ "#3399CC",
252
+ "#3399FF",
253
+ "#33CC00",
254
+ "#33CC33",
255
+ "#33CC66",
256
+ "#33CC99",
257
+ "#33CCCC",
258
+ "#33CCFF",
259
+ "#6600CC",
260
+ "#6600FF",
261
+ "#6633CC",
262
+ "#6633FF",
263
+ "#66CC00",
264
+ "#66CC33",
265
+ "#9900CC",
266
+ "#9900FF",
267
+ "#9933CC",
268
+ "#9933FF",
269
+ "#99CC00",
270
+ "#99CC33",
271
+ "#CC0000",
272
+ "#CC0033",
273
+ "#CC0066",
274
+ "#CC0099",
275
+ "#CC00CC",
276
+ "#CC00FF",
277
+ "#CC3300",
278
+ "#CC3333",
279
+ "#CC3366",
280
+ "#CC3399",
281
+ "#CC33CC",
282
+ "#CC33FF",
283
+ "#CC6600",
284
+ "#CC6633",
285
+ "#CC9900",
286
+ "#CC9933",
287
+ "#CCCC00",
288
+ "#CCCC33",
289
+ "#FF0000",
290
+ "#FF0033",
291
+ "#FF0066",
292
+ "#FF0099",
293
+ "#FF00CC",
294
+ "#FF00FF",
295
+ "#FF3300",
296
+ "#FF3333",
297
+ "#FF3366",
298
+ "#FF3399",
299
+ "#FF33CC",
300
+ "#FF33FF",
301
+ "#FF6600",
302
+ "#FF6633",
303
+ "#FF9900",
304
+ "#FF9933",
305
+ "#FFCC00",
306
+ "#FFCC33"
307
+ ];
308
+ /**
309
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
310
+ * and the Firebug extension (any Firefox version) are known
311
+ * to support "%c" CSS customizations.
312
+ *
313
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
314
+ */
315
+ function useColors() {
316
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return true;
317
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return false;
318
+ let m;
319
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
320
+ }
321
+ /**
322
+ * Colorize log arguments if enabled.
323
+ *
324
+ * @api public
325
+ */
326
+ function formatArgs(args) {
327
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
328
+ if (!this.useColors) return;
329
+ const c = "color: " + this.color;
330
+ args.splice(1, 0, c, "color: inherit");
331
+ let index = 0;
332
+ let lastC = 0;
333
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
334
+ if (match === "%%") return;
335
+ index++;
336
+ if (match === "%c") lastC = index;
337
+ });
338
+ args.splice(lastC, 0, c);
339
+ }
340
+ /**
341
+ * Invokes `console.debug()` when available.
342
+ * No-op when `console.debug` is not a "function".
343
+ * If `console.debug` is not available, falls back
344
+ * to `console.log`.
345
+ *
346
+ * @api public
347
+ */
348
+ exports.log = console.debug || console.log || (() => {});
349
+ /**
350
+ * Save `namespaces`.
351
+ *
352
+ * @param {String} namespaces
353
+ * @api private
354
+ */
355
+ function save(namespaces) {
356
+ try {
357
+ if (namespaces) exports.storage.setItem("debug", namespaces);
358
+ else exports.storage.removeItem("debug");
359
+ } catch (error) {}
360
+ }
361
+ /**
362
+ * Load `namespaces`.
363
+ *
364
+ * @return {String} returns the previously persisted debug modes
365
+ * @api private
366
+ */
367
+ function load() {
368
+ let r;
369
+ try {
370
+ r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
371
+ } catch (error) {}
372
+ if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
373
+ return r;
374
+ }
375
+ /**
376
+ * Localstorage attempts to return the localstorage.
377
+ *
378
+ * This is necessary because safari throws
379
+ * when a user disables cookies/localstorage
380
+ * and you attempt to access it.
381
+ *
382
+ * @return {LocalStorage}
383
+ * @api private
384
+ */
385
+ function localstorage() {
386
+ try {
387
+ return localStorage;
388
+ } catch (error) {}
389
+ }
390
+ module.exports = require_common()(exports);
391
+ var { formatters } = module.exports;
392
+ /**
393
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
394
+ */
395
+ formatters.j = function(v) {
396
+ try {
397
+ return JSON.stringify(v);
398
+ } catch (error) {
399
+ return "[UnexpectedJSONParseError]: " + error.message;
400
+ }
401
+ };
402
+ }));
403
+ //#endregion
404
+ //#region ../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js
405
+ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
406
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
407
+ if (k2 === void 0) k2 = k;
408
+ var desc = Object.getOwnPropertyDescriptor(m, k);
409
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
410
+ enumerable: true,
411
+ get: function() {
412
+ return m[k];
413
+ }
414
+ };
415
+ Object.defineProperty(o, k2, desc);
416
+ }) : (function(o, m, k, k2) {
417
+ if (k2 === void 0) k2 = k;
418
+ o[k2] = m[k];
419
+ }));
420
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
421
+ Object.defineProperty(o, "default", {
422
+ enumerable: true,
423
+ value: v
424
+ });
425
+ }) : function(o, v) {
426
+ o["default"] = v;
427
+ });
428
+ var __importStar = exports && exports.__importStar || function(mod) {
429
+ if (mod && mod.__esModule) return mod;
430
+ var result = {};
431
+ if (mod != null) {
432
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
433
+ }
434
+ __setModuleDefault(result, mod);
435
+ return result;
436
+ };
437
+ Object.defineProperty(exports, "__esModule", { value: true });
438
+ exports.req = exports.json = exports.toBuffer = void 0;
439
+ var http$1 = __importStar(__require("http"));
440
+ var https = __importStar(__require("https"));
441
+ async function toBuffer(stream) {
442
+ let length = 0;
443
+ const chunks = [];
444
+ for await (const chunk of stream) {
445
+ length += chunk.length;
446
+ chunks.push(chunk);
447
+ }
448
+ return Buffer.concat(chunks, length);
449
+ }
450
+ exports.toBuffer = toBuffer;
451
+ async function json(stream) {
452
+ const str = (await toBuffer(stream)).toString("utf8");
453
+ try {
454
+ return JSON.parse(str);
455
+ } catch (_err) {
456
+ const err = _err;
457
+ err.message += ` (input: ${str})`;
458
+ throw err;
459
+ }
460
+ }
461
+ exports.json = json;
462
+ function req(url, opts = {}) {
463
+ const req = ((typeof url === "string" ? url : url.href).startsWith("https:") ? https : http$1).request(url, opts);
464
+ const promise = new Promise((resolve, reject) => {
465
+ req.once("response", resolve).once("error", reject).end();
466
+ });
467
+ req.then = promise.then.bind(promise);
468
+ return req;
469
+ }
470
+ exports.req = req;
471
+ }));
472
+ //#endregion
473
+ //#region ../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/index.js
474
+ var require_dist$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
475
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
476
+ if (k2 === void 0) k2 = k;
477
+ var desc = Object.getOwnPropertyDescriptor(m, k);
478
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
479
+ enumerable: true,
480
+ get: function() {
481
+ return m[k];
482
+ }
483
+ };
484
+ Object.defineProperty(o, k2, desc);
485
+ }) : (function(o, m, k, k2) {
486
+ if (k2 === void 0) k2 = k;
487
+ o[k2] = m[k];
488
+ }));
489
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
490
+ Object.defineProperty(o, "default", {
491
+ enumerable: true,
492
+ value: v
493
+ });
494
+ }) : function(o, v) {
495
+ o["default"] = v;
496
+ });
497
+ var __importStar = exports && exports.__importStar || function(mod) {
498
+ if (mod && mod.__esModule) return mod;
499
+ var result = {};
500
+ if (mod != null) {
501
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
502
+ }
503
+ __setModuleDefault(result, mod);
504
+ return result;
505
+ };
506
+ var __exportStar = exports && exports.__exportStar || function(m, exports$1) {
507
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
508
+ };
509
+ Object.defineProperty(exports, "__esModule", { value: true });
510
+ exports.Agent = void 0;
511
+ var net$1 = __importStar(__require("net"));
512
+ var http = __importStar(__require("http"));
513
+ var https_1 = __require("https");
514
+ __exportStar(require_helpers(), exports);
515
+ var INTERNAL = Symbol("AgentBaseInternalState");
516
+ var Agent = class extends http.Agent {
517
+ constructor(opts) {
518
+ super(opts);
519
+ this[INTERNAL] = {};
520
+ }
521
+ /**
522
+ * Determine whether this is an `http` or `https` request.
523
+ */
524
+ isSecureEndpoint(options) {
525
+ if (options) {
526
+ if (typeof options.secureEndpoint === "boolean") return options.secureEndpoint;
527
+ if (typeof options.protocol === "string") return options.protocol === "https:";
528
+ }
529
+ const { stack } = /* @__PURE__ */ new Error();
530
+ if (typeof stack !== "string") return false;
531
+ return stack.split("\n").some((l) => l.indexOf("(https.js:") !== -1 || l.indexOf("node:https:") !== -1);
532
+ }
533
+ incrementSockets(name) {
534
+ if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) return null;
535
+ if (!this.sockets[name]) this.sockets[name] = [];
536
+ const fakeSocket = new net$1.Socket({ writable: false });
537
+ this.sockets[name].push(fakeSocket);
538
+ this.totalSocketCount++;
539
+ return fakeSocket;
540
+ }
541
+ decrementSockets(name, socket) {
542
+ if (!this.sockets[name] || socket === null) return;
543
+ const sockets = this.sockets[name];
544
+ const index = sockets.indexOf(socket);
545
+ if (index !== -1) {
546
+ sockets.splice(index, 1);
547
+ this.totalSocketCount--;
548
+ if (sockets.length === 0) delete this.sockets[name];
549
+ }
550
+ }
551
+ getName(options) {
552
+ if (this.isSecureEndpoint(options)) return https_1.Agent.prototype.getName.call(this, options);
553
+ return super.getName(options);
554
+ }
555
+ createSocket(req, options, cb) {
556
+ const connectOpts = {
557
+ ...options,
558
+ secureEndpoint: this.isSecureEndpoint(options)
559
+ };
560
+ const name = this.getName(connectOpts);
561
+ const fakeSocket = this.incrementSockets(name);
562
+ Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => {
563
+ this.decrementSockets(name, fakeSocket);
564
+ if (socket instanceof http.Agent) try {
565
+ return socket.addRequest(req, connectOpts);
566
+ } catch (err) {
567
+ return cb(err);
568
+ }
569
+ this[INTERNAL].currentSocket = socket;
570
+ super.createSocket(req, options, cb);
571
+ }, (err) => {
572
+ this.decrementSockets(name, fakeSocket);
573
+ cb(err);
574
+ });
575
+ }
576
+ createConnection() {
577
+ const socket = this[INTERNAL].currentSocket;
578
+ this[INTERNAL].currentSocket = void 0;
579
+ if (!socket) throw new Error("No socket was returned in the `connect()` function");
580
+ return socket;
581
+ }
582
+ get defaultPort() {
583
+ return this[INTERNAL].defaultPort ?? (this.protocol === "https:" ? 443 : 80);
584
+ }
585
+ set defaultPort(v) {
586
+ if (this[INTERNAL]) this[INTERNAL].defaultPort = v;
587
+ }
588
+ get protocol() {
589
+ return this[INTERNAL].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:");
590
+ }
591
+ set protocol(v) {
592
+ if (this[INTERNAL]) this[INTERNAL].protocol = v;
593
+ }
594
+ };
595
+ exports.Agent = Agent;
596
+ }));
597
+ //#endregion
598
+ //#region ../../node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/parse-proxy-response.js
599
+ var require_parse_proxy_response = /* @__PURE__ */ __commonJSMin(((exports) => {
600
+ var __importDefault = exports && exports.__importDefault || function(mod) {
601
+ return mod && mod.__esModule ? mod : { "default": mod };
602
+ };
603
+ Object.defineProperty(exports, "__esModule", { value: true });
604
+ exports.parseProxyResponse = void 0;
605
+ var debug = (0, __importDefault(require_browser()).default)("https-proxy-agent:parse-proxy-response");
606
+ function parseProxyResponse(socket) {
607
+ return new Promise((resolve, reject) => {
608
+ let buffersLength = 0;
609
+ const buffers = [];
610
+ function read() {
611
+ const b = socket.read();
612
+ if (b) ondata(b);
613
+ else socket.once("readable", read);
614
+ }
615
+ function cleanup() {
616
+ socket.removeListener("end", onend);
617
+ socket.removeListener("error", onerror);
618
+ socket.removeListener("readable", read);
619
+ }
620
+ function onend() {
621
+ cleanup();
622
+ debug("onend");
623
+ reject(/* @__PURE__ */ new Error("Proxy connection ended before receiving CONNECT response"));
624
+ }
625
+ function onerror(err) {
626
+ cleanup();
627
+ debug("onerror %o", err);
628
+ reject(err);
629
+ }
630
+ function ondata(b) {
631
+ buffers.push(b);
632
+ buffersLength += b.length;
633
+ const buffered = Buffer.concat(buffers, buffersLength);
634
+ const endOfHeaders = buffered.indexOf("\r\n\r\n");
635
+ if (endOfHeaders === -1) {
636
+ debug("have not received end of HTTP headers yet...");
637
+ read();
638
+ return;
639
+ }
640
+ const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split("\r\n");
641
+ const firstLine = headerParts.shift();
642
+ if (!firstLine) {
643
+ socket.destroy();
644
+ return reject(/* @__PURE__ */ new Error("No header received from proxy CONNECT response"));
645
+ }
646
+ const firstLineParts = firstLine.split(" ");
647
+ const statusCode = +firstLineParts[1];
648
+ const statusText = firstLineParts.slice(2).join(" ");
649
+ const headers = {};
650
+ for (const header of headerParts) {
651
+ if (!header) continue;
652
+ const firstColon = header.indexOf(":");
653
+ if (firstColon === -1) {
654
+ socket.destroy();
655
+ return reject(/* @__PURE__ */ new Error(`Invalid header from proxy CONNECT response: "${header}"`));
656
+ }
657
+ const key = header.slice(0, firstColon).toLowerCase();
658
+ const value = header.slice(firstColon + 1).trimStart();
659
+ const current = headers[key];
660
+ if (typeof current === "string") headers[key] = [current, value];
661
+ else if (Array.isArray(current)) current.push(value);
662
+ else headers[key] = value;
663
+ }
664
+ debug("got proxy server response: %o %o", firstLine, headers);
665
+ cleanup();
666
+ resolve({
667
+ connect: {
668
+ statusCode,
669
+ statusText,
670
+ headers
671
+ },
672
+ buffered
673
+ });
674
+ }
675
+ socket.on("error", onerror);
676
+ socket.on("end", onend);
677
+ read();
678
+ });
679
+ }
680
+ exports.parseProxyResponse = parseProxyResponse;
681
+ }));
682
+ //#endregion
683
+ //#region ../../node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js
684
+ var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
685
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
686
+ if (k2 === void 0) k2 = k;
687
+ var desc = Object.getOwnPropertyDescriptor(m, k);
688
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
689
+ enumerable: true,
690
+ get: function() {
691
+ return m[k];
692
+ }
693
+ };
694
+ Object.defineProperty(o, k2, desc);
695
+ }) : (function(o, m, k, k2) {
696
+ if (k2 === void 0) k2 = k;
697
+ o[k2] = m[k];
698
+ }));
699
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
700
+ Object.defineProperty(o, "default", {
701
+ enumerable: true,
702
+ value: v
703
+ });
704
+ }) : function(o, v) {
705
+ o["default"] = v;
706
+ });
707
+ var __importStar = exports && exports.__importStar || function(mod) {
708
+ if (mod && mod.__esModule) return mod;
709
+ var result = {};
710
+ if (mod != null) {
711
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
712
+ }
713
+ __setModuleDefault(result, mod);
714
+ return result;
715
+ };
716
+ var __importDefault = exports && exports.__importDefault || function(mod) {
717
+ return mod && mod.__esModule ? mod : { "default": mod };
718
+ };
719
+ Object.defineProperty(exports, "__esModule", { value: true });
720
+ exports.HttpsProxyAgent = void 0;
721
+ var net = __importStar(__require("net"));
722
+ var tls = __importStar(__require("tls"));
723
+ var assert_1 = __importDefault(__require("assert"));
724
+ var debug_1 = __importDefault(require_browser());
725
+ var agent_base_1 = require_dist$1();
726
+ var url_1 = __require("url");
727
+ var parse_proxy_response_1 = require_parse_proxy_response();
728
+ var debug = (0, debug_1.default)("https-proxy-agent");
729
+ var setServernameFromNonIpHost = (options) => {
730
+ if (options.servername === void 0 && options.host && !net.isIP(options.host)) return {
731
+ ...options,
732
+ servername: options.host
733
+ };
734
+ return options;
735
+ };
736
+ /**
737
+ * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
738
+ * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
739
+ *
740
+ * Outgoing HTTP requests are first tunneled through the proxy server using the
741
+ * `CONNECT` HTTP request method to establish a connection to the proxy server,
742
+ * and then the proxy server connects to the destination target and issues the
743
+ * HTTP request from the proxy server.
744
+ *
745
+ * `https:` requests have their socket connection upgraded to TLS once
746
+ * the connection to the proxy server has been established.
747
+ */
748
+ var HttpsProxyAgent = class extends agent_base_1.Agent {
749
+ constructor(proxy, opts) {
750
+ super(opts);
751
+ this.options = { path: void 0 };
752
+ this.proxy = typeof proxy === "string" ? new url_1.URL(proxy) : proxy;
753
+ this.proxyHeaders = opts?.headers ?? {};
754
+ debug("Creating new HttpsProxyAgent instance: %o", this.proxy.href);
755
+ const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, "");
756
+ const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80;
757
+ this.connectOpts = {
758
+ ALPNProtocols: ["http/1.1"],
759
+ ...opts ? omit(opts, "headers") : null,
760
+ host,
761
+ port
762
+ };
763
+ }
764
+ /**
765
+ * Called when the node-core HTTP client library is creating a
766
+ * new HTTP request.
767
+ */
768
+ async connect(req, opts) {
769
+ const { proxy } = this;
770
+ if (!opts.host) throw new TypeError("No \"host\" provided");
771
+ let socket;
772
+ if (proxy.protocol === "https:") {
773
+ debug("Creating `tls.Socket`: %o", this.connectOpts);
774
+ socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
775
+ } else {
776
+ debug("Creating `net.Socket`: %o", this.connectOpts);
777
+ socket = net.connect(this.connectOpts);
778
+ }
779
+ const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
780
+ const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
781
+ let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
782
+ if (proxy.username || proxy.password) {
783
+ const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
784
+ headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`;
785
+ }
786
+ headers.Host = `${host}:${opts.port}`;
787
+ if (!headers["Proxy-Connection"]) headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close";
788
+ for (const name of Object.keys(headers)) payload += `${name}: ${headers[name]}\r\n`;
789
+ const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket);
790
+ socket.write(`${payload}\r\n`);
791
+ const { connect, buffered } = await proxyResponsePromise;
792
+ req.emit("proxyConnect", connect);
793
+ this.emit("proxyConnect", connect, req);
794
+ if (connect.statusCode === 200) {
795
+ req.once("socket", resume);
796
+ if (opts.secureEndpoint) {
797
+ debug("Upgrading socket connection to TLS");
798
+ return tls.connect({
799
+ ...omit(setServernameFromNonIpHost(opts), "host", "path", "port"),
800
+ socket
801
+ });
802
+ }
803
+ return socket;
804
+ }
805
+ socket.destroy();
806
+ const fakeSocket = new net.Socket({ writable: false });
807
+ fakeSocket.readable = true;
808
+ req.once("socket", (s) => {
809
+ debug("Replaying proxy buffer for failed request");
810
+ (0, assert_1.default)(s.listenerCount("data") > 0);
811
+ s.push(buffered);
812
+ s.push(null);
813
+ });
814
+ return fakeSocket;
815
+ }
816
+ };
817
+ HttpsProxyAgent.protocols = ["http", "https"];
818
+ exports.HttpsProxyAgent = HttpsProxyAgent;
819
+ function resume(socket) {
820
+ socket.resume();
821
+ }
822
+ function omit(obj, ...keys) {
823
+ const ret = {};
824
+ let key;
825
+ for (key in obj) if (!keys.includes(key)) ret[key] = obj[key];
826
+ return ret;
827
+ }
828
+ }));
829
+ //#endregion
830
+ export { require_browser as n, require_dist as t };
831
+
832
+ //# sourceMappingURL=dist-DMO-zF6D.js.map