@rebasepro/server-core 0.5.0 → 0.6.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 (279) hide show
  1. package/dist/{server-core/src/api → api}/errors.d.ts +5 -2
  2. package/dist/{server-core/src/api → api}/rest/api-generator.d.ts +8 -2
  3. package/dist/{server-core/src/api → api}/types.d.ts +2 -0
  4. package/dist/auth/admin-user-ops.d.ts +79 -0
  5. package/dist/{server-core/src/auth → auth}/api-keys/index.d.ts +2 -2
  6. package/dist/{server-core/src/auth → auth}/auth-hooks.d.ts +37 -9
  7. package/dist/{server-core/src/auth → auth}/builtin-auth-adapter.d.ts +4 -4
  8. package/dist/{server-core/src/auth → auth}/index.d.ts +5 -2
  9. package/dist/auth/mfa-routes.d.ts +6 -0
  10. package/dist/auth/reset-password-admin.d.ts +29 -0
  11. package/dist/auth/session-routes.d.ts +25 -0
  12. package/dist/backend-CIxN4FVm.js +15 -0
  13. package/dist/backend-CIxN4FVm.js.map +1 -0
  14. package/dist/chunk-Dze3rakg.js +42 -0
  15. package/dist/{server-core/src/cron → cron}/cron-scheduler.d.ts +1 -1
  16. package/dist/dist-CZKP-Xz4.js +832 -0
  17. package/dist/dist-CZKP-Xz4.js.map +1 -0
  18. package/dist/env.d.ts +102 -0
  19. package/dist/from-VbwD7xRf.js +3849 -0
  20. package/dist/from-VbwD7xRf.js.map +1 -0
  21. package/dist/{server-core/src/index.d.ts → index.d.ts} +1 -0
  22. package/dist/index.es.js +60867 -50462
  23. package/dist/index.es.js.map +1 -1
  24. package/dist/index.umd.js +73151 -51298
  25. package/dist/index.umd.js.map +1 -1
  26. package/dist/init/docs.d.ts +4 -0
  27. package/dist/init/health.d.ts +2 -0
  28. package/dist/init/middlewares.d.ts +10 -0
  29. package/dist/init/shutdown.d.ts +11 -0
  30. package/dist/init/storage.d.ts +5 -0
  31. package/dist/{server-core/src/init.d.ts → init.d.ts} +4 -4
  32. package/dist/jwt-DHcQRGC3.js +4168 -0
  33. package/dist/jwt-DHcQRGC3.js.map +1 -0
  34. package/dist/logger-BYU66ENZ.js +94 -0
  35. package/dist/logger-BYU66ENZ.js.map +1 -0
  36. package/dist/ms-BeBSuOXN.js +125 -0
  37. package/dist/ms-BeBSuOXN.js.map +1 -0
  38. package/dist/multipart-parser-CedBDOeC.js +299 -0
  39. package/dist/multipart-parser-CedBDOeC.js.map +1 -0
  40. package/dist/src-COaj0G3P.js +1182 -0
  41. package/dist/src-COaj0G3P.js.map +1 -0
  42. package/dist/{server-core/src/storage → storage}/image-transform.d.ts +3 -1
  43. package/dist/utils/request-id.d.ts +4 -0
  44. package/package.json +29 -29
  45. package/src/api/collections_for_test/callbacks_test_collection.ts +7 -6
  46. package/src/api/errors.ts +75 -19
  47. package/src/api/graphql/graphql-schema-generator.ts +15 -10
  48. package/src/api/logs-routes.ts +5 -2
  49. package/src/api/rest/api-generator-count.test.ts +21 -10
  50. package/src/api/rest/api-generator.ts +83 -24
  51. package/src/api/rest/query-parser.ts +18 -12
  52. package/src/api/server.ts +12 -1
  53. package/src/api/types.ts +2 -0
  54. package/src/auth/adapter-middleware.ts +17 -10
  55. package/src/auth/admin-user-ops.ts +236 -0
  56. package/src/auth/api-keys/api-key-middleware.ts +15 -9
  57. package/src/auth/api-keys/api-key-permission-guard.ts +1 -1
  58. package/src/auth/api-keys/api-key-routes.ts +3 -3
  59. package/src/auth/api-keys/api-key-store.ts +14 -8
  60. package/src/auth/api-keys/index.ts +2 -2
  61. package/src/auth/apple-oauth.ts +4 -3
  62. package/src/auth/auth-hooks.ts +50 -10
  63. package/src/auth/bitbucket-oauth.ts +5 -4
  64. package/src/auth/builtin-auth-adapter.ts +60 -39
  65. package/src/auth/custom-auth-adapter.ts +4 -5
  66. package/src/auth/discord-oauth.ts +5 -4
  67. package/src/auth/facebook-oauth.ts +5 -4
  68. package/src/auth/github-oauth.ts +6 -5
  69. package/src/auth/gitlab-oauth.ts +5 -4
  70. package/src/auth/google-oauth.ts +2 -1
  71. package/src/auth/index.ts +6 -2
  72. package/src/auth/jwt.ts +5 -4
  73. package/src/auth/linkedin-oauth.ts +4 -3
  74. package/src/auth/mfa-routes.ts +299 -0
  75. package/src/auth/mfa.ts +2 -1
  76. package/src/auth/microsoft-oauth.ts +5 -4
  77. package/src/auth/middleware.ts +5 -4
  78. package/src/auth/rate-limiter.ts +1 -1
  79. package/src/auth/reset-password-admin.ts +144 -0
  80. package/src/auth/rls-scope.ts +1 -1
  81. package/src/auth/routes.ts +52 -596
  82. package/src/auth/session-routes.ts +341 -0
  83. package/src/auth/slack-oauth.ts +6 -5
  84. package/src/auth/spotify-oauth.ts +5 -4
  85. package/src/auth/twitter-oauth.ts +4 -3
  86. package/src/collections/loader.ts +5 -4
  87. package/src/cron/cron-scheduler.test.ts +23 -11
  88. package/src/cron/cron-scheduler.ts +14 -8
  89. package/src/cron/cron-store.ts +1 -1
  90. package/src/email/smtp-email-service.ts +3 -2
  91. package/src/env.ts +11 -10
  92. package/src/index.ts +1 -0
  93. package/src/init/docs.ts +47 -0
  94. package/src/init/health.ts +37 -0
  95. package/src/init/middlewares.ts +61 -0
  96. package/src/init/shutdown.ts +56 -0
  97. package/src/init/storage.ts +57 -0
  98. package/src/init.ts +85 -279
  99. package/src/serve-spa.ts +12 -5
  100. package/src/services/driver-registry.ts +4 -3
  101. package/src/storage/S3StorageController.ts +1 -2
  102. package/src/storage/image-transform.ts +25 -10
  103. package/src/storage/routes.ts +30 -11
  104. package/src/storage/storage-registry.ts +4 -3
  105. package/src/storage/tus-handler.ts +12 -12
  106. package/src/utils/request-id.ts +40 -0
  107. package/src/utils/request-logger.ts +6 -0
  108. package/test/api-generator.test.ts +90 -2
  109. package/test/api-key-permission-guard.test.ts +24 -12
  110. package/test/auth-routes.test.ts +5 -3
  111. package/test/backend-hooks-data.test.ts +99 -30
  112. package/test/custom-auth-adapter.test.ts +16 -15
  113. package/test/email-templates.test.ts +10 -5
  114. package/test/env.test.ts +10 -10
  115. package/test/function-loader.test.ts +7 -4
  116. package/test/graphql-schema-generator.test.ts +554 -0
  117. package/test/jwt-security.test.ts +1 -1
  118. package/test/query-parser.test.ts +0 -1
  119. package/test/reset-password-admin.test.ts +113 -0
  120. package/test/singleton.test.ts +5 -5
  121. package/test/smtp-email-service.test.ts +21 -21
  122. package/test/webhook-service.test.ts +22 -11
  123. package/tsconfig.json +2 -0
  124. package/tsconfig.prod.json +3 -0
  125. package/vite.config.ts +5 -5
  126. package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
  127. package/dist/common/src/collections/default-collections.d.ts +0 -9
  128. package/dist/common/src/collections/index.d.ts +0 -2
  129. package/dist/common/src/data/buildRebaseData.d.ts +0 -14
  130. package/dist/common/src/data/query_builder.d.ts +0 -55
  131. package/dist/common/src/index.d.ts +0 -4
  132. package/dist/common/src/util/builders.d.ts +0 -57
  133. package/dist/common/src/util/callbacks.d.ts +0 -6
  134. package/dist/common/src/util/collections.d.ts +0 -11
  135. package/dist/common/src/util/common.d.ts +0 -2
  136. package/dist/common/src/util/conditions.d.ts +0 -26
  137. package/dist/common/src/util/entities.d.ts +0 -58
  138. package/dist/common/src/util/enums.d.ts +0 -3
  139. package/dist/common/src/util/index.d.ts +0 -16
  140. package/dist/common/src/util/navigation_from_path.d.ts +0 -34
  141. package/dist/common/src/util/navigation_utils.d.ts +0 -20
  142. package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
  143. package/dist/common/src/util/paths.d.ts +0 -14
  144. package/dist/common/src/util/permissions.d.ts +0 -14
  145. package/dist/common/src/util/references.d.ts +0 -2
  146. package/dist/common/src/util/relations.d.ts +0 -22
  147. package/dist/common/src/util/resolutions.d.ts +0 -72
  148. package/dist/common/src/util/storage.d.ts +0 -24
  149. package/dist/index-Cr1D21av.js +0 -49
  150. package/dist/index-Cr1D21av.js.map +0 -1
  151. package/dist/server-core/src/auth/admin-routes.d.ts +0 -27
  152. package/dist/server-core/src/env.d.ts +0 -137
  153. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  154. package/dist/types/src/controllers/auth.d.ts +0 -104
  155. package/dist/types/src/controllers/client.d.ts +0 -168
  156. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  157. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  158. package/dist/types/src/controllers/data.d.ts +0 -207
  159. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  160. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  161. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  162. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  163. package/dist/types/src/controllers/email.d.ts +0 -36
  164. package/dist/types/src/controllers/index.d.ts +0 -18
  165. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  166. package/dist/types/src/controllers/navigation.d.ts +0 -225
  167. package/dist/types/src/controllers/registry.d.ts +0 -63
  168. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  169. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  170. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  171. package/dist/types/src/controllers/storage.d.ts +0 -171
  172. package/dist/types/src/index.d.ts +0 -4
  173. package/dist/types/src/rebase_context.d.ts +0 -122
  174. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  175. package/dist/types/src/types/backend.d.ts +0 -571
  176. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  177. package/dist/types/src/types/builders.d.ts +0 -15
  178. package/dist/types/src/types/chips.d.ts +0 -5
  179. package/dist/types/src/types/collections.d.ts +0 -961
  180. package/dist/types/src/types/component_ref.d.ts +0 -47
  181. package/dist/types/src/types/cron.d.ts +0 -102
  182. package/dist/types/src/types/data_source.d.ts +0 -64
  183. package/dist/types/src/types/database_adapter.d.ts +0 -94
  184. package/dist/types/src/types/entities.d.ts +0 -145
  185. package/dist/types/src/types/entity_actions.d.ts +0 -104
  186. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  187. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  188. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  189. package/dist/types/src/types/entity_views.d.ts +0 -87
  190. package/dist/types/src/types/export_import.d.ts +0 -21
  191. package/dist/types/src/types/formex.d.ts +0 -40
  192. package/dist/types/src/types/index.d.ts +0 -28
  193. package/dist/types/src/types/locales.d.ts +0 -4
  194. package/dist/types/src/types/modify_collections.d.ts +0 -5
  195. package/dist/types/src/types/plugins.d.ts +0 -282
  196. package/dist/types/src/types/properties.d.ts +0 -1173
  197. package/dist/types/src/types/property_config.d.ts +0 -74
  198. package/dist/types/src/types/relations.d.ts +0 -336
  199. package/dist/types/src/types/slots.d.ts +0 -262
  200. package/dist/types/src/types/translations.d.ts +0 -900
  201. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  202. package/dist/types/src/types/websockets.d.ts +0 -78
  203. package/dist/types/src/users/index.d.ts +0 -1
  204. package/dist/types/src/users/user.d.ts +0 -50
  205. package/src/auth/admin-routes.ts +0 -534
  206. package/test/admin-routes.test.ts +0 -544
  207. package/test/backend-hooks-admin.test.ts +0 -388
  208. /package/dist/{server-core/src/api → api}/ast-schema-editor.d.ts +0 -0
  209. /package/dist/{server-core/src/api → api}/collections_for_test/callbacks_test_collection.d.ts +0 -0
  210. /package/dist/{server-core/src/api → api}/graphql/graphql-schema-generator.d.ts +0 -0
  211. /package/dist/{server-core/src/api → api}/graphql/index.d.ts +0 -0
  212. /package/dist/{server-core/src/api → api}/index.d.ts +0 -0
  213. /package/dist/{server-core/src/api → api}/logs-routes.d.ts +0 -0
  214. /package/dist/{server-core/src/api → api}/openapi-generator.d.ts +0 -0
  215. /package/dist/{server-core/src/api → api}/rest/index.d.ts +0 -0
  216. /package/dist/{server-core/src/api → api}/rest/query-parser.d.ts +0 -0
  217. /package/dist/{server-core/src/api → api}/schema-editor-routes.d.ts +0 -0
  218. /package/dist/{server-core/src/api → api}/server.d.ts +0 -0
  219. /package/dist/{server-core/src/auth → auth}/adapter-middleware.d.ts +0 -0
  220. /package/dist/{server-core/src/auth → auth}/api-keys/api-key-middleware.d.ts +0 -0
  221. /package/dist/{server-core/src/auth → auth}/api-keys/api-key-permission-guard.d.ts +0 -0
  222. /package/dist/{server-core/src/auth → auth}/api-keys/api-key-routes.d.ts +0 -0
  223. /package/dist/{server-core/src/auth → auth}/api-keys/api-key-store.d.ts +0 -0
  224. /package/dist/{server-core/src/auth → auth}/api-keys/api-key-types.d.ts +0 -0
  225. /package/dist/{server-core/src/auth → auth}/apple-oauth.d.ts +0 -0
  226. /package/dist/{server-core/src/auth → auth}/bitbucket-oauth.d.ts +0 -0
  227. /package/dist/{server-core/src/auth → auth}/crypto-utils.d.ts +0 -0
  228. /package/dist/{server-core/src/auth → auth}/custom-auth-adapter.d.ts +0 -0
  229. /package/dist/{server-core/src/auth → auth}/discord-oauth.d.ts +0 -0
  230. /package/dist/{server-core/src/auth → auth}/facebook-oauth.d.ts +0 -0
  231. /package/dist/{server-core/src/auth → auth}/github-oauth.d.ts +0 -0
  232. /package/dist/{server-core/src/auth → auth}/gitlab-oauth.d.ts +0 -0
  233. /package/dist/{server-core/src/auth → auth}/google-oauth.d.ts +0 -0
  234. /package/dist/{server-core/src/auth → auth}/interfaces.d.ts +0 -0
  235. /package/dist/{server-core/src/auth → auth}/jwt.d.ts +0 -0
  236. /package/dist/{server-core/src/auth → auth}/linkedin-oauth.d.ts +0 -0
  237. /package/dist/{server-core/src/auth → auth}/mfa.d.ts +0 -0
  238. /package/dist/{server-core/src/auth → auth}/microsoft-oauth.d.ts +0 -0
  239. /package/dist/{server-core/src/auth → auth}/middleware.d.ts +0 -0
  240. /package/dist/{server-core/src/auth → auth}/password.d.ts +0 -0
  241. /package/dist/{server-core/src/auth → auth}/rate-limiter.d.ts +0 -0
  242. /package/dist/{server-core/src/auth → auth}/rls-scope.d.ts +0 -0
  243. /package/dist/{server-core/src/auth → auth}/routes.d.ts +0 -0
  244. /package/dist/{server-core/src/auth → auth}/slack-oauth.d.ts +0 -0
  245. /package/dist/{server-core/src/auth → auth}/spotify-oauth.d.ts +0 -0
  246. /package/dist/{server-core/src/auth → auth}/twitter-oauth.d.ts +0 -0
  247. /package/dist/{server-core/src/collections → collections}/BackendCollectionRegistry.d.ts +0 -0
  248. /package/dist/{server-core/src/collections → collections}/loader.d.ts +0 -0
  249. /package/dist/{server-core/src/cron → cron}/cron-loader.d.ts +0 -0
  250. /package/dist/{server-core/src/cron → cron}/cron-routes.d.ts +0 -0
  251. /package/dist/{server-core/src/cron → cron}/cron-store.d.ts +0 -0
  252. /package/dist/{server-core/src/cron → cron}/index.d.ts +0 -0
  253. /package/dist/{server-core/src/db → db}/interfaces.d.ts +0 -0
  254. /package/dist/{server-core/src/email → email}/index.d.ts +0 -0
  255. /package/dist/{server-core/src/email → email}/smtp-email-service.d.ts +0 -0
  256. /package/dist/{server-core/src/email → email}/templates.d.ts +0 -0
  257. /package/dist/{server-core/src/email → email}/types.d.ts +0 -0
  258. /package/dist/{server-core/src/functions → functions}/function-loader.d.ts +0 -0
  259. /package/dist/{server-core/src/functions → functions}/function-routes.d.ts +0 -0
  260. /package/dist/{server-core/src/functions → functions}/index.d.ts +0 -0
  261. /package/dist/{server-core/src/history → history}/history-routes.d.ts +0 -0
  262. /package/dist/{server-core/src/history → history}/index.d.ts +0 -0
  263. /package/dist/{server-core/src/serve-spa.d.ts → serve-spa.d.ts} +0 -0
  264. /package/dist/{server-core/src/services → services}/driver-registry.d.ts +0 -0
  265. /package/dist/{server-core/src/services → services}/webhook-service.d.ts +0 -0
  266. /package/dist/{server-core/src/singleton.d.ts → singleton.d.ts} +0 -0
  267. /package/dist/{server-core/src/storage → storage}/LocalStorageController.d.ts +0 -0
  268. /package/dist/{server-core/src/storage → storage}/S3StorageController.d.ts +0 -0
  269. /package/dist/{server-core/src/storage → storage}/index.d.ts +0 -0
  270. /package/dist/{server-core/src/storage → storage}/routes.d.ts +0 -0
  271. /package/dist/{server-core/src/storage → storage}/storage-registry.d.ts +0 -0
  272. /package/dist/{server-core/src/storage → storage}/tus-handler.d.ts +0 -0
  273. /package/dist/{server-core/src/storage → storage}/types.d.ts +0 -0
  274. /package/dist/{server-core/src/types → types}/index.d.ts +0 -0
  275. /package/dist/{server-core/src/utils → utils}/dev-port.d.ts +0 -0
  276. /package/dist/{server-core/src/utils → utils}/logger.d.ts +0 -0
  277. /package/dist/{server-core/src/utils → utils}/logging.d.ts +0 -0
  278. /package/dist/{server-core/src/utils → utils}/request-logger.d.ts +0 -0
  279. /package/dist/{server-core/src/utils → utils}/sql.d.ts +0 -0
@@ -0,0 +1,1182 @@
1
+ import { createRequire as __createRequire } from "module";
2
+ import process from "process";
3
+ __createRequire(import.meta.url);
4
+ import { n as __esmMin } from "./chunk-Dze3rakg.js";
5
+ import { c as init_fetch_blob, i as init_esm_min, n as FormData, r as formDataToBlob, s as Blob, t as init_from } from "./from-VbwD7xRf.js";
6
+ import http from "node:http";
7
+ import https from "node:https";
8
+ import zlib from "node:zlib";
9
+ import Stream, { PassThrough, pipeline } from "node:stream";
10
+ import { Buffer as Buffer$1 } from "node:buffer";
11
+ import { deprecate, promisify, types } from "node:util";
12
+ import { format } from "node:url";
13
+ import { isIP } from "node:net";
14
+ //#region ../../node_modules/.pnpm/data-uri-to-buffer@4.0.1/node_modules/data-uri-to-buffer/dist/index.js
15
+ /**
16
+ * Returns a `Buffer` instance from the given data URI `uri`.
17
+ *
18
+ * @param {String} uri Data URI to turn into a Buffer instance
19
+ * @returns {Buffer} Buffer instance from Data URI
20
+ * @api public
21
+ */
22
+ function dataUriToBuffer(uri) {
23
+ if (!/^data:/i.test(uri)) throw new TypeError("`uri` does not appear to be a Data URI (must begin with \"data:\")");
24
+ uri = uri.replace(/\r?\n/g, "");
25
+ const firstComma = uri.indexOf(",");
26
+ if (firstComma === -1 || firstComma <= 4) throw new TypeError("malformed data: URI");
27
+ const meta = uri.substring(5, firstComma).split(";");
28
+ let charset = "";
29
+ let base64 = false;
30
+ const type = meta[0] || "text/plain";
31
+ let typeFull = type;
32
+ for (let i = 1; i < meta.length; i++) if (meta[i] === "base64") base64 = true;
33
+ else if (meta[i]) {
34
+ typeFull += `;${meta[i]}`;
35
+ if (meta[i].indexOf("charset=") === 0) charset = meta[i].substring(8);
36
+ }
37
+ if (!meta[0] && !charset.length) {
38
+ typeFull += ";charset=US-ASCII";
39
+ charset = "US-ASCII";
40
+ }
41
+ const encoding = base64 ? "base64" : "ascii";
42
+ const data = unescape(uri.substring(firstComma + 1));
43
+ const buffer = Buffer.from(data, encoding);
44
+ buffer.type = type;
45
+ buffer.typeFull = typeFull;
46
+ buffer.charset = charset;
47
+ return buffer;
48
+ }
49
+ var init_dist = __esmMin((() => {}));
50
+ //#endregion
51
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/base.js
52
+ var FetchBaseError;
53
+ var init_base = __esmMin((() => {
54
+ FetchBaseError = class extends Error {
55
+ constructor(message, type) {
56
+ super(message);
57
+ Error.captureStackTrace(this, this.constructor);
58
+ this.type = type;
59
+ }
60
+ get name() {
61
+ return this.constructor.name;
62
+ }
63
+ get [Symbol.toStringTag]() {
64
+ return this.constructor.name;
65
+ }
66
+ };
67
+ }));
68
+ //#endregion
69
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/fetch-error.js
70
+ var FetchError;
71
+ var init_fetch_error = __esmMin((() => {
72
+ init_base();
73
+ FetchError = class extends FetchBaseError {
74
+ /**
75
+ * @param {string} message - Error message for human
76
+ * @param {string} [type] - Error type for machine
77
+ * @param {SystemError} [systemError] - For Node.js system error
78
+ */
79
+ constructor(message, type, systemError) {
80
+ super(message, type);
81
+ if (systemError) {
82
+ this.code = this.errno = systemError.code;
83
+ this.erroredSysCall = systemError.syscall;
84
+ }
85
+ }
86
+ };
87
+ }));
88
+ //#endregion
89
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/is.js
90
+ var NAME, isURLSearchParameters, isBlob, isAbortSignal, isDomainOrSubdomain, isSameProtocol;
91
+ var init_is = __esmMin((() => {
92
+ NAME = Symbol.toStringTag;
93
+ isURLSearchParameters = (object) => {
94
+ return typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && typeof object.sort === "function" && object[NAME] === "URLSearchParams";
95
+ };
96
+ isBlob = (object) => {
97
+ return object && typeof object === "object" && typeof object.arrayBuffer === "function" && typeof object.type === "string" && typeof object.stream === "function" && typeof object.constructor === "function" && /^(Blob|File)$/.test(object[NAME]);
98
+ };
99
+ isAbortSignal = (object) => {
100
+ return typeof object === "object" && (object[NAME] === "AbortSignal" || object[NAME] === "EventTarget");
101
+ };
102
+ isDomainOrSubdomain = (destination, original) => {
103
+ const orig = new URL(original).hostname;
104
+ const dest = new URL(destination).hostname;
105
+ return orig === dest || orig.endsWith(`.${dest}`);
106
+ };
107
+ isSameProtocol = (destination, original) => {
108
+ return new URL(original).protocol === new URL(destination).protocol;
109
+ };
110
+ }));
111
+ //#endregion
112
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/body.js
113
+ /**
114
+ * Body.js
115
+ *
116
+ * Body interface provides common methods for Request and Response
117
+ */
118
+ /**
119
+ * Consume and convert an entire Body to a Buffer.
120
+ *
121
+ * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body
122
+ *
123
+ * @return Promise
124
+ */
125
+ async function consumeBody(data) {
126
+ if (data[INTERNALS$2].disturbed) throw new TypeError(`body used already for: ${data.url}`);
127
+ data[INTERNALS$2].disturbed = true;
128
+ if (data[INTERNALS$2].error) throw data[INTERNALS$2].error;
129
+ const { body } = data;
130
+ if (body === null) return Buffer$1.alloc(0);
131
+ /* c8 ignore next 3 */
132
+ if (!(body instanceof Stream)) return Buffer$1.alloc(0);
133
+ const accum = [];
134
+ let accumBytes = 0;
135
+ try {
136
+ for await (const chunk of body) {
137
+ if (data.size > 0 && accumBytes + chunk.length > data.size) {
138
+ const error = new FetchError(`content size at ${data.url} over limit: ${data.size}`, "max-size");
139
+ body.destroy(error);
140
+ throw error;
141
+ }
142
+ accumBytes += chunk.length;
143
+ accum.push(chunk);
144
+ }
145
+ } catch (error) {
146
+ throw error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data.url}: ${error.message}`, "system", error);
147
+ }
148
+ if (body.readableEnded === true || body._readableState.ended === true) try {
149
+ if (accum.every((c) => typeof c === "string")) return Buffer$1.from(accum.join(""));
150
+ return Buffer$1.concat(accum, accumBytes);
151
+ } catch (error) {
152
+ throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, "system", error);
153
+ }
154
+ else throw new FetchError(`Premature close of server response while trying to fetch ${data.url}`);
155
+ }
156
+ var pipeline$1, INTERNALS$2, Body, clone, getNonSpecFormDataBoundary, extractContentType, getTotalBytes, writeToStream;
157
+ var init_body = __esmMin((() => {
158
+ init_fetch_blob();
159
+ init_esm_min();
160
+ init_fetch_error();
161
+ init_base();
162
+ init_is();
163
+ pipeline$1 = promisify(Stream.pipeline);
164
+ INTERNALS$2 = Symbol("Body internals");
165
+ Body = class {
166
+ constructor(body, { size = 0 } = {}) {
167
+ let boundary = null;
168
+ if (body === null) body = null;
169
+ else if (isURLSearchParameters(body)) body = Buffer$1.from(body.toString());
170
+ else if (isBlob(body)) {} else if (Buffer$1.isBuffer(body)) {} else if (types.isAnyArrayBuffer(body)) body = Buffer$1.from(body);
171
+ else if (ArrayBuffer.isView(body)) body = Buffer$1.from(body.buffer, body.byteOffset, body.byteLength);
172
+ else if (body instanceof Stream) {} else if (body instanceof FormData) {
173
+ body = formDataToBlob(body);
174
+ boundary = body.type.split("=")[1];
175
+ } else body = Buffer$1.from(String(body));
176
+ let stream = body;
177
+ if (Buffer$1.isBuffer(body)) stream = Stream.Readable.from(body);
178
+ else if (isBlob(body)) stream = Stream.Readable.from(body.stream());
179
+ this[INTERNALS$2] = {
180
+ body,
181
+ stream,
182
+ boundary,
183
+ disturbed: false,
184
+ error: null
185
+ };
186
+ this.size = size;
187
+ if (body instanceof Stream) body.on("error", (error_) => {
188
+ const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
189
+ this[INTERNALS$2].error = error;
190
+ });
191
+ }
192
+ get body() {
193
+ return this[INTERNALS$2].stream;
194
+ }
195
+ get bodyUsed() {
196
+ return this[INTERNALS$2].disturbed;
197
+ }
198
+ /**
199
+ * Decode response as ArrayBuffer
200
+ *
201
+ * @return Promise
202
+ */
203
+ async arrayBuffer() {
204
+ const { buffer, byteOffset, byteLength } = await consumeBody(this);
205
+ return buffer.slice(byteOffset, byteOffset + byteLength);
206
+ }
207
+ async formData() {
208
+ const ct = this.headers.get("content-type");
209
+ if (ct.startsWith("application/x-www-form-urlencoded")) {
210
+ const formData = new FormData();
211
+ const parameters = new URLSearchParams(await this.text());
212
+ for (const [name, value] of parameters) formData.append(name, value);
213
+ return formData;
214
+ }
215
+ const { toFormData } = await import("./multipart-parser-CedBDOeC.js");
216
+ return toFormData(this.body, ct);
217
+ }
218
+ /**
219
+ * Return raw response as Blob
220
+ *
221
+ * @return Promise
222
+ */
223
+ async blob() {
224
+ const ct = this.headers && this.headers.get("content-type") || this[INTERNALS$2].body && this[INTERNALS$2].body.type || "";
225
+ return new Blob([await this.arrayBuffer()], { type: ct });
226
+ }
227
+ /**
228
+ * Decode response as json
229
+ *
230
+ * @return Promise
231
+ */
232
+ async json() {
233
+ const text = await this.text();
234
+ return JSON.parse(text);
235
+ }
236
+ /**
237
+ * Decode response as text
238
+ *
239
+ * @return Promise
240
+ */
241
+ async text() {
242
+ const buffer = await consumeBody(this);
243
+ return new TextDecoder().decode(buffer);
244
+ }
245
+ /**
246
+ * Decode response as buffer (non-spec api)
247
+ *
248
+ * @return Promise
249
+ */
250
+ buffer() {
251
+ return consumeBody(this);
252
+ }
253
+ };
254
+ Body.prototype.buffer = deprecate(Body.prototype.buffer, "Please use 'response.arrayBuffer()' instead of 'response.buffer()'", "node-fetch#buffer");
255
+ Object.defineProperties(Body.prototype, {
256
+ body: { enumerable: true },
257
+ bodyUsed: { enumerable: true },
258
+ arrayBuffer: { enumerable: true },
259
+ blob: { enumerable: true },
260
+ json: { enumerable: true },
261
+ text: { enumerable: true },
262
+ data: { get: deprecate(() => {}, "data doesn't exist, use json(), text(), arrayBuffer(), or body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (response)") }
263
+ });
264
+ clone = (instance, highWaterMark) => {
265
+ let p1;
266
+ let p2;
267
+ let { body } = instance[INTERNALS$2];
268
+ if (instance.bodyUsed) throw new Error("cannot clone body after it is used");
269
+ if (body instanceof Stream && typeof body.getBoundary !== "function") {
270
+ p1 = new PassThrough({ highWaterMark });
271
+ p2 = new PassThrough({ highWaterMark });
272
+ body.pipe(p1);
273
+ body.pipe(p2);
274
+ instance[INTERNALS$2].stream = p1;
275
+ body = p2;
276
+ }
277
+ return body;
278
+ };
279
+ getNonSpecFormDataBoundary = deprecate((body) => body.getBoundary(), "form-data doesn't follow the spec and requires special treatment. Use alternative package", "https://github.com/node-fetch/node-fetch/issues/1167");
280
+ extractContentType = (body, request) => {
281
+ if (body === null) return null;
282
+ if (typeof body === "string") return "text/plain;charset=UTF-8";
283
+ if (isURLSearchParameters(body)) return "application/x-www-form-urlencoded;charset=UTF-8";
284
+ if (isBlob(body)) return body.type || null;
285
+ if (Buffer$1.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) return null;
286
+ if (body instanceof FormData) return `multipart/form-data; boundary=${request[INTERNALS$2].boundary}`;
287
+ if (body && typeof body.getBoundary === "function") return `multipart/form-data;boundary=${getNonSpecFormDataBoundary(body)}`;
288
+ if (body instanceof Stream) return null;
289
+ return "text/plain;charset=UTF-8";
290
+ };
291
+ getTotalBytes = (request) => {
292
+ const { body } = request[INTERNALS$2];
293
+ if (body === null) return 0;
294
+ if (isBlob(body)) return body.size;
295
+ if (Buffer$1.isBuffer(body)) return body.length;
296
+ if (body && typeof body.getLengthSync === "function") return body.hasKnownLength && body.hasKnownLength() ? body.getLengthSync() : null;
297
+ return null;
298
+ };
299
+ writeToStream = async (dest, { body }) => {
300
+ if (body === null) dest.end();
301
+ else await pipeline$1(body, dest);
302
+ };
303
+ }));
304
+ //#endregion
305
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/headers.js
306
+ /**
307
+ * Headers.js
308
+ *
309
+ * Headers class offers convenient helpers
310
+ */
311
+ /**
312
+ * Create a Headers object from an http.IncomingMessage.rawHeaders, ignoring those that do
313
+ * not conform to HTTP grammar productions.
314
+ * @param {import('http').IncomingMessage['rawHeaders']} headers
315
+ */
316
+ function fromRawHeaders(headers = []) {
317
+ return new Headers(headers.reduce((result, value, index, array) => {
318
+ if (index % 2 === 0) result.push(array.slice(index, index + 2));
319
+ return result;
320
+ }, []).filter(([name, value]) => {
321
+ try {
322
+ validateHeaderName(name);
323
+ validateHeaderValue(name, String(value));
324
+ return true;
325
+ } catch {
326
+ return false;
327
+ }
328
+ }));
329
+ }
330
+ var validateHeaderName, validateHeaderValue, Headers;
331
+ var init_headers = __esmMin((() => {
332
+ validateHeaderName = typeof http.validateHeaderName === "function" ? http.validateHeaderName : (name) => {
333
+ if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
334
+ const error = /* @__PURE__ */ new TypeError(`Header name must be a valid HTTP token [${name}]`);
335
+ Object.defineProperty(error, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
336
+ throw error;
337
+ }
338
+ };
339
+ validateHeaderValue = typeof http.validateHeaderValue === "function" ? http.validateHeaderValue : (name, value) => {
340
+ if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
341
+ const error = /* @__PURE__ */ new TypeError(`Invalid character in header content ["${name}"]`);
342
+ Object.defineProperty(error, "code", { value: "ERR_INVALID_CHAR" });
343
+ throw error;
344
+ }
345
+ };
346
+ Headers = class Headers extends URLSearchParams {
347
+ /**
348
+ * Headers class
349
+ *
350
+ * @constructor
351
+ * @param {HeadersInit} [init] - Response headers
352
+ */
353
+ constructor(init) {
354
+ /** @type {string[][]} */
355
+ let result = [];
356
+ if (init instanceof Headers) {
357
+ const raw = init.raw();
358
+ for (const [name, values] of Object.entries(raw)) result.push(...values.map((value) => [name, value]));
359
+ } else if (init == null) {} else if (typeof init === "object" && !types.isBoxedPrimitive(init)) {
360
+ const method = init[Symbol.iterator];
361
+ if (method == null) result.push(...Object.entries(init));
362
+ else {
363
+ if (typeof method !== "function") throw new TypeError("Header pairs must be iterable");
364
+ result = [...init].map((pair) => {
365
+ if (typeof pair !== "object" || types.isBoxedPrimitive(pair)) throw new TypeError("Each header pair must be an iterable object");
366
+ return [...pair];
367
+ }).map((pair) => {
368
+ if (pair.length !== 2) throw new TypeError("Each header pair must be a name/value tuple");
369
+ return [...pair];
370
+ });
371
+ }
372
+ } else throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");
373
+ result = result.length > 0 ? result.map(([name, value]) => {
374
+ validateHeaderName(name);
375
+ validateHeaderValue(name, String(value));
376
+ return [String(name).toLowerCase(), String(value)];
377
+ }) : void 0;
378
+ super(result);
379
+ return new Proxy(this, { get(target, p, receiver) {
380
+ switch (p) {
381
+ case "append":
382
+ case "set": return (name, value) => {
383
+ validateHeaderName(name);
384
+ validateHeaderValue(name, String(value));
385
+ return URLSearchParams.prototype[p].call(target, String(name).toLowerCase(), String(value));
386
+ };
387
+ case "delete":
388
+ case "has":
389
+ case "getAll": return (name) => {
390
+ validateHeaderName(name);
391
+ return URLSearchParams.prototype[p].call(target, String(name).toLowerCase());
392
+ };
393
+ case "keys": return () => {
394
+ target.sort();
395
+ return new Set(URLSearchParams.prototype.keys.call(target)).keys();
396
+ };
397
+ default: return Reflect.get(target, p, receiver);
398
+ }
399
+ } });
400
+ /* c8 ignore next */
401
+ }
402
+ get [Symbol.toStringTag]() {
403
+ return this.constructor.name;
404
+ }
405
+ toString() {
406
+ return Object.prototype.toString.call(this);
407
+ }
408
+ get(name) {
409
+ const values = this.getAll(name);
410
+ if (values.length === 0) return null;
411
+ let value = values.join(", ");
412
+ if (/^content-encoding$/i.test(name)) value = value.toLowerCase();
413
+ return value;
414
+ }
415
+ forEach(callback, thisArg = void 0) {
416
+ for (const name of this.keys()) Reflect.apply(callback, thisArg, [
417
+ this.get(name),
418
+ name,
419
+ this
420
+ ]);
421
+ }
422
+ *values() {
423
+ for (const name of this.keys()) yield this.get(name);
424
+ }
425
+ /**
426
+ * @type {() => IterableIterator<[string, string]>}
427
+ */
428
+ *entries() {
429
+ for (const name of this.keys()) yield [name, this.get(name)];
430
+ }
431
+ [Symbol.iterator]() {
432
+ return this.entries();
433
+ }
434
+ /**
435
+ * Node-fetch non-spec method
436
+ * returning all headers and their values as array
437
+ * @returns {Record<string, string[]>}
438
+ */
439
+ raw() {
440
+ return [...this.keys()].reduce((result, key) => {
441
+ result[key] = this.getAll(key);
442
+ return result;
443
+ }, {});
444
+ }
445
+ /**
446
+ * For better console.log(headers) and also to convert Headers into Node.js Request compatible format
447
+ */
448
+ [Symbol.for("nodejs.util.inspect.custom")]() {
449
+ return [...this.keys()].reduce((result, key) => {
450
+ const values = this.getAll(key);
451
+ if (key === "host") result[key] = values[0];
452
+ else result[key] = values.length > 1 ? values : values[0];
453
+ return result;
454
+ }, {});
455
+ }
456
+ };
457
+ /**
458
+ * Re-shaping object for Web IDL tests
459
+ * Only need to do it for overridden methods
460
+ */
461
+ Object.defineProperties(Headers.prototype, [
462
+ "get",
463
+ "entries",
464
+ "forEach",
465
+ "values"
466
+ ].reduce((result, property) => {
467
+ result[property] = { enumerable: true };
468
+ return result;
469
+ }, {}));
470
+ }));
471
+ //#endregion
472
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/is-redirect.js
473
+ var redirectStatus, isRedirect;
474
+ var init_is_redirect = __esmMin((() => {
475
+ redirectStatus = new Set([
476
+ 301,
477
+ 302,
478
+ 303,
479
+ 307,
480
+ 308
481
+ ]);
482
+ isRedirect = (code) => {
483
+ return redirectStatus.has(code);
484
+ };
485
+ }));
486
+ //#endregion
487
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/response.js
488
+ var INTERNALS$1, Response;
489
+ var init_response = __esmMin((() => {
490
+ init_headers();
491
+ init_body();
492
+ init_is_redirect();
493
+ INTERNALS$1 = Symbol("Response internals");
494
+ Response = class Response extends Body {
495
+ constructor(body = null, options = {}) {
496
+ super(body, options);
497
+ const status = options.status != null ? options.status : 200;
498
+ const headers = new Headers(options.headers);
499
+ if (body !== null && !headers.has("Content-Type")) {
500
+ const contentType = extractContentType(body, this);
501
+ if (contentType) headers.append("Content-Type", contentType);
502
+ }
503
+ this[INTERNALS$1] = {
504
+ type: "default",
505
+ url: options.url,
506
+ status,
507
+ statusText: options.statusText || "",
508
+ headers,
509
+ counter: options.counter,
510
+ highWaterMark: options.highWaterMark
511
+ };
512
+ }
513
+ get type() {
514
+ return this[INTERNALS$1].type;
515
+ }
516
+ get url() {
517
+ return this[INTERNALS$1].url || "";
518
+ }
519
+ get status() {
520
+ return this[INTERNALS$1].status;
521
+ }
522
+ /**
523
+ * Convenience property representing if the request ended normally
524
+ */
525
+ get ok() {
526
+ return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;
527
+ }
528
+ get redirected() {
529
+ return this[INTERNALS$1].counter > 0;
530
+ }
531
+ get statusText() {
532
+ return this[INTERNALS$1].statusText;
533
+ }
534
+ get headers() {
535
+ return this[INTERNALS$1].headers;
536
+ }
537
+ get highWaterMark() {
538
+ return this[INTERNALS$1].highWaterMark;
539
+ }
540
+ /**
541
+ * Clone this response
542
+ *
543
+ * @return Response
544
+ */
545
+ clone() {
546
+ return new Response(clone(this, this.highWaterMark), {
547
+ type: this.type,
548
+ url: this.url,
549
+ status: this.status,
550
+ statusText: this.statusText,
551
+ headers: this.headers,
552
+ ok: this.ok,
553
+ redirected: this.redirected,
554
+ size: this.size,
555
+ highWaterMark: this.highWaterMark
556
+ });
557
+ }
558
+ /**
559
+ * @param {string} url The URL that the new response is to originate from.
560
+ * @param {number} status An optional status code for the response (e.g., 302.)
561
+ * @returns {Response} A Response object.
562
+ */
563
+ static redirect(url, status = 302) {
564
+ if (!isRedirect(status)) throw new RangeError("Failed to execute \"redirect\" on \"response\": Invalid status code");
565
+ return new Response(null, {
566
+ headers: { location: new URL(url).toString() },
567
+ status
568
+ });
569
+ }
570
+ static error() {
571
+ const response = new Response(null, {
572
+ status: 0,
573
+ statusText: ""
574
+ });
575
+ response[INTERNALS$1].type = "error";
576
+ return response;
577
+ }
578
+ static json(data = void 0, init = {}) {
579
+ const body = JSON.stringify(data);
580
+ if (body === void 0) throw new TypeError("data is not JSON serializable");
581
+ const headers = new Headers(init && init.headers);
582
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
583
+ return new Response(body, {
584
+ ...init,
585
+ headers
586
+ });
587
+ }
588
+ get [Symbol.toStringTag]() {
589
+ return "Response";
590
+ }
591
+ };
592
+ Object.defineProperties(Response.prototype, {
593
+ type: { enumerable: true },
594
+ url: { enumerable: true },
595
+ status: { enumerable: true },
596
+ ok: { enumerable: true },
597
+ redirected: { enumerable: true },
598
+ statusText: { enumerable: true },
599
+ headers: { enumerable: true },
600
+ clone: { enumerable: true }
601
+ });
602
+ }));
603
+ //#endregion
604
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/get-search.js
605
+ var getSearch;
606
+ var init_get_search = __esmMin((() => {
607
+ getSearch = (parsedURL) => {
608
+ if (parsedURL.search) return parsedURL.search;
609
+ const lastOffset = parsedURL.href.length - 1;
610
+ const hash = parsedURL.hash || (parsedURL.href[lastOffset] === "#" ? "#" : "");
611
+ return parsedURL.href[lastOffset - hash.length] === "?" ? "?" : "";
612
+ };
613
+ }));
614
+ //#endregion
615
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/referrer.js
616
+ /**
617
+ * @external URL
618
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/URL|URL}
619
+ */
620
+ /**
621
+ * @module utils/referrer
622
+ * @private
623
+ */
624
+ /**
625
+ * @see {@link https://w3c.github.io/webappsec-referrer-policy/#strip-url|Referrer Policy §8.4. Strip url for use as a referrer}
626
+ * @param {string} URL
627
+ * @param {boolean} [originOnly=false]
628
+ */
629
+ function stripURLForUseAsAReferrer(url, originOnly = false) {
630
+ if (url == null) return "no-referrer";
631
+ url = new URL(url);
632
+ if (/^(about|blob|data):$/.test(url.protocol)) return "no-referrer";
633
+ url.username = "";
634
+ url.password = "";
635
+ url.hash = "";
636
+ if (originOnly) {
637
+ url.pathname = "";
638
+ url.search = "";
639
+ }
640
+ return url;
641
+ }
642
+ /**
643
+ * @see {@link https://w3c.github.io/webappsec-referrer-policy/#referrer-policies|Referrer Policy §3. Referrer Policies}
644
+ * @param {string} referrerPolicy
645
+ * @returns {string} referrerPolicy
646
+ */
647
+ function validateReferrerPolicy(referrerPolicy) {
648
+ if (!ReferrerPolicy.has(referrerPolicy)) throw new TypeError(`Invalid referrerPolicy: ${referrerPolicy}`);
649
+ return referrerPolicy;
650
+ }
651
+ /**
652
+ * @see {@link https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy|Referrer Policy §3.2. Is origin potentially trustworthy?}
653
+ * @param {external:URL} url
654
+ * @returns `true`: "Potentially Trustworthy", `false`: "Not Trustworthy"
655
+ */
656
+ function isOriginPotentiallyTrustworthy(url) {
657
+ if (/^(http|ws)s:$/.test(url.protocol)) return true;
658
+ const hostIp = url.host.replace(/(^\[)|(]$)/g, "");
659
+ const hostIPVersion = isIP(hostIp);
660
+ if (hostIPVersion === 4 && /^127\./.test(hostIp)) return true;
661
+ if (hostIPVersion === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(hostIp)) return true;
662
+ if (url.host === "localhost" || url.host.endsWith(".localhost")) return false;
663
+ if (url.protocol === "file:") return true;
664
+ return false;
665
+ }
666
+ /**
667
+ * @see {@link https://w3c.github.io/webappsec-secure-contexts/#is-url-trustworthy|Referrer Policy §3.3. Is url potentially trustworthy?}
668
+ * @param {external:URL} url
669
+ * @returns `true`: "Potentially Trustworthy", `false`: "Not Trustworthy"
670
+ */
671
+ function isUrlPotentiallyTrustworthy(url) {
672
+ if (/^about:(blank|srcdoc)$/.test(url)) return true;
673
+ if (url.protocol === "data:") return true;
674
+ if (/^(blob|filesystem):$/.test(url.protocol)) return true;
675
+ return isOriginPotentiallyTrustworthy(url);
676
+ }
677
+ /**
678
+ * Modifies the referrerURL to enforce any extra security policy considerations.
679
+ * @see {@link https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer|Referrer Policy §8.3. Determine request's Referrer}, step 7
680
+ * @callback module:utils/referrer~referrerURLCallback
681
+ * @param {external:URL} referrerURL
682
+ * @returns {external:URL} modified referrerURL
683
+ */
684
+ /**
685
+ * Modifies the referrerOrigin to enforce any extra security policy considerations.
686
+ * @see {@link https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer|Referrer Policy §8.3. Determine request's Referrer}, step 7
687
+ * @callback module:utils/referrer~referrerOriginCallback
688
+ * @param {external:URL} referrerOrigin
689
+ * @returns {external:URL} modified referrerOrigin
690
+ */
691
+ /**
692
+ * @see {@link https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer|Referrer Policy §8.3. Determine request's Referrer}
693
+ * @param {Request} request
694
+ * @param {object} o
695
+ * @param {module:utils/referrer~referrerURLCallback} o.referrerURLCallback
696
+ * @param {module:utils/referrer~referrerOriginCallback} o.referrerOriginCallback
697
+ * @returns {external:URL} Request's referrer
698
+ */
699
+ function determineRequestsReferrer(request, { referrerURLCallback, referrerOriginCallback } = {}) {
700
+ if (request.referrer === "no-referrer" || request.referrerPolicy === "") return null;
701
+ const policy = request.referrerPolicy;
702
+ if (request.referrer === "about:client") return "no-referrer";
703
+ const referrerSource = request.referrer;
704
+ let referrerURL = stripURLForUseAsAReferrer(referrerSource);
705
+ let referrerOrigin = stripURLForUseAsAReferrer(referrerSource, true);
706
+ if (referrerURL.toString().length > 4096) referrerURL = referrerOrigin;
707
+ if (referrerURLCallback) referrerURL = referrerURLCallback(referrerURL);
708
+ if (referrerOriginCallback) referrerOrigin = referrerOriginCallback(referrerOrigin);
709
+ const currentURL = new URL(request.url);
710
+ switch (policy) {
711
+ case "no-referrer": return "no-referrer";
712
+ case "origin": return referrerOrigin;
713
+ case "unsafe-url": return referrerURL;
714
+ case "strict-origin":
715
+ if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) return "no-referrer";
716
+ return referrerOrigin.toString();
717
+ case "strict-origin-when-cross-origin":
718
+ if (referrerURL.origin === currentURL.origin) return referrerURL;
719
+ if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) return "no-referrer";
720
+ return referrerOrigin;
721
+ case "same-origin":
722
+ if (referrerURL.origin === currentURL.origin) return referrerURL;
723
+ return "no-referrer";
724
+ case "origin-when-cross-origin":
725
+ if (referrerURL.origin === currentURL.origin) return referrerURL;
726
+ return referrerOrigin;
727
+ case "no-referrer-when-downgrade":
728
+ if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) return "no-referrer";
729
+ return referrerURL;
730
+ default: throw new TypeError(`Invalid referrerPolicy: ${policy}`);
731
+ }
732
+ }
733
+ /**
734
+ * @see {@link https://w3c.github.io/webappsec-referrer-policy/#parse-referrer-policy-from-header|Referrer Policy §8.1. Parse a referrer policy from a Referrer-Policy header}
735
+ * @param {Headers} headers Response headers
736
+ * @returns {string} policy
737
+ */
738
+ function parseReferrerPolicyFromHeader(headers) {
739
+ const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
740
+ let policy = "";
741
+ for (const token of policyTokens) if (token && ReferrerPolicy.has(token)) policy = token;
742
+ return policy;
743
+ }
744
+ var ReferrerPolicy, DEFAULT_REFERRER_POLICY;
745
+ var init_referrer = __esmMin((() => {
746
+ ReferrerPolicy = new Set([
747
+ "",
748
+ "no-referrer",
749
+ "no-referrer-when-downgrade",
750
+ "same-origin",
751
+ "origin",
752
+ "strict-origin",
753
+ "origin-when-cross-origin",
754
+ "strict-origin-when-cross-origin",
755
+ "unsafe-url"
756
+ ]);
757
+ DEFAULT_REFERRER_POLICY = "strict-origin-when-cross-origin";
758
+ }));
759
+ //#endregion
760
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/request.js
761
+ /**
762
+ * Request.js
763
+ *
764
+ * Request class contains server only options
765
+ *
766
+ * All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
767
+ */
768
+ var INTERNALS, isRequest, doBadDataWarn, Request, getNodeRequestOptions;
769
+ var init_request = __esmMin((() => {
770
+ init_headers();
771
+ init_body();
772
+ init_is();
773
+ init_get_search();
774
+ init_referrer();
775
+ INTERNALS = Symbol("Request internals");
776
+ isRequest = (object) => {
777
+ return typeof object === "object" && typeof object[INTERNALS] === "object";
778
+ };
779
+ doBadDataWarn = deprecate(() => {}, ".data is not a valid RequestInit property, use .body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (request)");
780
+ Request = class Request extends Body {
781
+ constructor(input, init = {}) {
782
+ let parsedURL;
783
+ if (isRequest(input)) parsedURL = new URL(input.url);
784
+ else {
785
+ parsedURL = new URL(input);
786
+ input = {};
787
+ }
788
+ if (parsedURL.username !== "" || parsedURL.password !== "") throw new TypeError(`${parsedURL} is an url with embedded credentials.`);
789
+ let method = init.method || input.method || "GET";
790
+ if (/^(delete|get|head|options|post|put)$/i.test(method)) method = method.toUpperCase();
791
+ if (!isRequest(init) && "data" in init) doBadDataWarn();
792
+ if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) throw new TypeError("Request with GET/HEAD method cannot have body");
793
+ const inputBody = init.body ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
794
+ super(inputBody, { size: init.size || input.size || 0 });
795
+ const headers = new Headers(init.headers || input.headers || {});
796
+ if (inputBody !== null && !headers.has("Content-Type")) {
797
+ const contentType = extractContentType(inputBody, this);
798
+ if (contentType) headers.set("Content-Type", contentType);
799
+ }
800
+ let signal = isRequest(input) ? input.signal : null;
801
+ if ("signal" in init) signal = init.signal;
802
+ if (signal != null && !isAbortSignal(signal)) throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");
803
+ let referrer = init.referrer == null ? input.referrer : init.referrer;
804
+ if (referrer === "") referrer = "no-referrer";
805
+ else if (referrer) {
806
+ const parsedReferrer = new URL(referrer);
807
+ referrer = /^about:(\/\/)?client$/.test(parsedReferrer) ? "client" : parsedReferrer;
808
+ } else referrer = void 0;
809
+ this[INTERNALS] = {
810
+ method,
811
+ redirect: init.redirect || input.redirect || "follow",
812
+ headers,
813
+ parsedURL,
814
+ signal,
815
+ referrer
816
+ };
817
+ this.follow = init.follow === void 0 ? input.follow === void 0 ? 20 : input.follow : init.follow;
818
+ this.compress = init.compress === void 0 ? input.compress === void 0 ? true : input.compress : init.compress;
819
+ this.counter = init.counter || input.counter || 0;
820
+ this.agent = init.agent || input.agent;
821
+ this.highWaterMark = init.highWaterMark || input.highWaterMark || 16384;
822
+ this.insecureHTTPParser = init.insecureHTTPParser || input.insecureHTTPParser || false;
823
+ this.referrerPolicy = init.referrerPolicy || input.referrerPolicy || "";
824
+ }
825
+ /** @returns {string} */
826
+ get method() {
827
+ return this[INTERNALS].method;
828
+ }
829
+ /** @returns {string} */
830
+ get url() {
831
+ return format(this[INTERNALS].parsedURL);
832
+ }
833
+ /** @returns {Headers} */
834
+ get headers() {
835
+ return this[INTERNALS].headers;
836
+ }
837
+ get redirect() {
838
+ return this[INTERNALS].redirect;
839
+ }
840
+ /** @returns {AbortSignal} */
841
+ get signal() {
842
+ return this[INTERNALS].signal;
843
+ }
844
+ get referrer() {
845
+ if (this[INTERNALS].referrer === "no-referrer") return "";
846
+ if (this[INTERNALS].referrer === "client") return "about:client";
847
+ if (this[INTERNALS].referrer) return this[INTERNALS].referrer.toString();
848
+ }
849
+ get referrerPolicy() {
850
+ return this[INTERNALS].referrerPolicy;
851
+ }
852
+ set referrerPolicy(referrerPolicy) {
853
+ this[INTERNALS].referrerPolicy = validateReferrerPolicy(referrerPolicy);
854
+ }
855
+ /**
856
+ * Clone this request
857
+ *
858
+ * @return Request
859
+ */
860
+ clone() {
861
+ return new Request(this);
862
+ }
863
+ get [Symbol.toStringTag]() {
864
+ return "Request";
865
+ }
866
+ };
867
+ Object.defineProperties(Request.prototype, {
868
+ method: { enumerable: true },
869
+ url: { enumerable: true },
870
+ headers: { enumerable: true },
871
+ redirect: { enumerable: true },
872
+ clone: { enumerable: true },
873
+ signal: { enumerable: true },
874
+ referrer: { enumerable: true },
875
+ referrerPolicy: { enumerable: true }
876
+ });
877
+ getNodeRequestOptions = (request) => {
878
+ const { parsedURL } = request[INTERNALS];
879
+ const headers = new Headers(request[INTERNALS].headers);
880
+ if (!headers.has("Accept")) headers.set("Accept", "*/*");
881
+ let contentLengthValue = null;
882
+ if (request.body === null && /^(post|put)$/i.test(request.method)) contentLengthValue = "0";
883
+ if (request.body !== null) {
884
+ const totalBytes = getTotalBytes(request);
885
+ if (typeof totalBytes === "number" && !Number.isNaN(totalBytes)) contentLengthValue = String(totalBytes);
886
+ }
887
+ if (contentLengthValue) headers.set("Content-Length", contentLengthValue);
888
+ if (request.referrerPolicy === "") request.referrerPolicy = DEFAULT_REFERRER_POLICY;
889
+ if (request.referrer && request.referrer !== "no-referrer") request[INTERNALS].referrer = determineRequestsReferrer(request);
890
+ else request[INTERNALS].referrer = "no-referrer";
891
+ if (request[INTERNALS].referrer instanceof URL) headers.set("Referer", request.referrer);
892
+ if (!headers.has("User-Agent")) headers.set("User-Agent", "node-fetch");
893
+ if (request.compress && !headers.has("Accept-Encoding")) headers.set("Accept-Encoding", "gzip, deflate, br");
894
+ let { agent } = request;
895
+ if (typeof agent === "function") agent = agent(parsedURL);
896
+ const search = getSearch(parsedURL);
897
+ return {
898
+ /** @type {URL} */
899
+ parsedURL,
900
+ options: {
901
+ path: parsedURL.pathname + search,
902
+ method: request.method,
903
+ headers: headers[Symbol.for("nodejs.util.inspect.custom")](),
904
+ insecureHTTPParser: request.insecureHTTPParser,
905
+ agent
906
+ }
907
+ };
908
+ };
909
+ }));
910
+ //#endregion
911
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/abort-error.js
912
+ var AbortError;
913
+ var init_abort_error = __esmMin((() => {
914
+ init_base();
915
+ AbortError = class extends FetchBaseError {
916
+ constructor(message, type = "aborted") {
917
+ super(message, type);
918
+ }
919
+ };
920
+ }));
921
+ //#endregion
922
+ //#region ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
923
+ /**
924
+ * Index.js
925
+ *
926
+ * a request API compatible with window.fetch
927
+ *
928
+ * All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
929
+ */
930
+ /**
931
+ * Fetch function
932
+ *
933
+ * @param {string | URL | import('./request').default} url - Absolute url or Request instance
934
+ * @param {*} [options_] - Fetch options
935
+ * @return {Promise<import('./response').default>}
936
+ */
937
+ async function fetch(url, options_) {
938
+ return new Promise((resolve, reject) => {
939
+ const request = new Request(url, options_);
940
+ const { parsedURL, options } = getNodeRequestOptions(request);
941
+ if (!supportedSchemas.has(parsedURL.protocol)) throw new TypeError(`node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`);
942
+ if (parsedURL.protocol === "data:") {
943
+ const data = dataUriToBuffer(request.url);
944
+ resolve(new Response(data, { headers: { "Content-Type": data.typeFull } }));
945
+ return;
946
+ }
947
+ const send = (parsedURL.protocol === "https:" ? https : http).request;
948
+ const { signal } = request;
949
+ let response = null;
950
+ const abort = () => {
951
+ const error = new AbortError("The operation was aborted.");
952
+ reject(error);
953
+ if (request.body && request.body instanceof Stream.Readable) request.body.destroy(error);
954
+ if (!response || !response.body) return;
955
+ response.body.emit("error", error);
956
+ };
957
+ if (signal && signal.aborted) {
958
+ abort();
959
+ return;
960
+ }
961
+ const abortAndFinalize = () => {
962
+ abort();
963
+ finalize();
964
+ };
965
+ const request_ = send(parsedURL.toString(), options);
966
+ if (signal) signal.addEventListener("abort", abortAndFinalize);
967
+ const finalize = () => {
968
+ request_.abort();
969
+ if (signal) signal.removeEventListener("abort", abortAndFinalize);
970
+ };
971
+ request_.on("error", (error) => {
972
+ reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, "system", error));
973
+ finalize();
974
+ });
975
+ fixResponseChunkedTransferBadEnding(request_, (error) => {
976
+ if (response && response.body) response.body.destroy(error);
977
+ });
978
+ /* c8 ignore next 18 */
979
+ if (process.version < "v14") request_.on("socket", (s) => {
980
+ let endedWithEventsCount;
981
+ s.prependListener("end", () => {
982
+ endedWithEventsCount = s._eventsCount;
983
+ });
984
+ s.prependListener("close", (hadError) => {
985
+ if (response && endedWithEventsCount < s._eventsCount && !hadError) {
986
+ const error = /* @__PURE__ */ new Error("Premature close");
987
+ error.code = "ERR_STREAM_PREMATURE_CLOSE";
988
+ response.body.emit("error", error);
989
+ }
990
+ });
991
+ });
992
+ request_.on("response", (response_) => {
993
+ request_.setTimeout(0);
994
+ const headers = fromRawHeaders(response_.rawHeaders);
995
+ if (isRedirect(response_.statusCode)) {
996
+ const location = headers.get("Location");
997
+ let locationURL = null;
998
+ try {
999
+ locationURL = location === null ? null : new URL(location, request.url);
1000
+ } catch {
1001
+ if (request.redirect !== "manual") {
1002
+ reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, "invalid-redirect"));
1003
+ finalize();
1004
+ return;
1005
+ }
1006
+ }
1007
+ switch (request.redirect) {
1008
+ case "error":
1009
+ reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, "no-redirect"));
1010
+ finalize();
1011
+ return;
1012
+ case "manual": break;
1013
+ case "follow": {
1014
+ if (locationURL === null) break;
1015
+ if (request.counter >= request.follow) {
1016
+ reject(new FetchError(`maximum redirect reached at: ${request.url}`, "max-redirect"));
1017
+ finalize();
1018
+ return;
1019
+ }
1020
+ const requestOptions = {
1021
+ headers: new Headers(request.headers),
1022
+ follow: request.follow,
1023
+ counter: request.counter + 1,
1024
+ agent: request.agent,
1025
+ compress: request.compress,
1026
+ method: request.method,
1027
+ body: clone(request),
1028
+ signal: request.signal,
1029
+ size: request.size,
1030
+ referrer: request.referrer,
1031
+ referrerPolicy: request.referrerPolicy
1032
+ };
1033
+ if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) for (const name of [
1034
+ "authorization",
1035
+ "www-authenticate",
1036
+ "cookie",
1037
+ "cookie2"
1038
+ ]) requestOptions.headers.delete(name);
1039
+ if (response_.statusCode !== 303 && request.body && options_.body instanceof Stream.Readable) {
1040
+ reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect"));
1041
+ finalize();
1042
+ return;
1043
+ }
1044
+ if (response_.statusCode === 303 || (response_.statusCode === 301 || response_.statusCode === 302) && request.method === "POST") {
1045
+ requestOptions.method = "GET";
1046
+ requestOptions.body = void 0;
1047
+ requestOptions.headers.delete("content-length");
1048
+ }
1049
+ const responseReferrerPolicy = parseReferrerPolicyFromHeader(headers);
1050
+ if (responseReferrerPolicy) requestOptions.referrerPolicy = responseReferrerPolicy;
1051
+ resolve(fetch(new Request(locationURL, requestOptions)));
1052
+ finalize();
1053
+ return;
1054
+ }
1055
+ default: return reject(/* @__PURE__ */ new TypeError(`Redirect option '${request.redirect}' is not a valid value of RequestRedirect`));
1056
+ }
1057
+ }
1058
+ if (signal) response_.once("end", () => {
1059
+ signal.removeEventListener("abort", abortAndFinalize);
1060
+ });
1061
+ let body = pipeline(response_, new PassThrough(), (error) => {
1062
+ if (error) reject(error);
1063
+ });
1064
+ /* c8 ignore next 3 */
1065
+ if (process.version < "v12.10") response_.on("aborted", abortAndFinalize);
1066
+ const responseOptions = {
1067
+ url: request.url,
1068
+ status: response_.statusCode,
1069
+ statusText: response_.statusMessage,
1070
+ headers,
1071
+ size: request.size,
1072
+ counter: request.counter,
1073
+ highWaterMark: request.highWaterMark
1074
+ };
1075
+ const codings = headers.get("Content-Encoding");
1076
+ if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
1077
+ response = new Response(body, responseOptions);
1078
+ resolve(response);
1079
+ return;
1080
+ }
1081
+ const zlibOptions = {
1082
+ flush: zlib.Z_SYNC_FLUSH,
1083
+ finishFlush: zlib.Z_SYNC_FLUSH
1084
+ };
1085
+ if (codings === "gzip" || codings === "x-gzip") {
1086
+ body = pipeline(body, zlib.createGunzip(zlibOptions), (error) => {
1087
+ if (error) reject(error);
1088
+ });
1089
+ response = new Response(body, responseOptions);
1090
+ resolve(response);
1091
+ return;
1092
+ }
1093
+ if (codings === "deflate" || codings === "x-deflate") {
1094
+ const raw = pipeline(response_, new PassThrough(), (error) => {
1095
+ if (error) reject(error);
1096
+ });
1097
+ raw.once("data", (chunk) => {
1098
+ if ((chunk[0] & 15) === 8) body = pipeline(body, zlib.createInflate(), (error) => {
1099
+ if (error) reject(error);
1100
+ });
1101
+ else body = pipeline(body, zlib.createInflateRaw(), (error) => {
1102
+ if (error) reject(error);
1103
+ });
1104
+ response = new Response(body, responseOptions);
1105
+ resolve(response);
1106
+ });
1107
+ raw.once("end", () => {
1108
+ if (!response) {
1109
+ response = new Response(body, responseOptions);
1110
+ resolve(response);
1111
+ }
1112
+ });
1113
+ return;
1114
+ }
1115
+ if (codings === "br") {
1116
+ body = pipeline(body, zlib.createBrotliDecompress(), (error) => {
1117
+ if (error) reject(error);
1118
+ });
1119
+ response = new Response(body, responseOptions);
1120
+ resolve(response);
1121
+ return;
1122
+ }
1123
+ response = new Response(body, responseOptions);
1124
+ resolve(response);
1125
+ });
1126
+ writeToStream(request_, request).catch(reject);
1127
+ });
1128
+ }
1129
+ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
1130
+ const LAST_CHUNK = Buffer$1.from("0\r\n\r\n");
1131
+ let isChunkedTransfer = false;
1132
+ let properLastChunkReceived = false;
1133
+ let previousChunk;
1134
+ request.on("response", (response) => {
1135
+ const { headers } = response;
1136
+ isChunkedTransfer = headers["transfer-encoding"] === "chunked" && !headers["content-length"];
1137
+ });
1138
+ request.on("socket", (socket) => {
1139
+ const onSocketClose = () => {
1140
+ if (isChunkedTransfer && !properLastChunkReceived) {
1141
+ const error = /* @__PURE__ */ new Error("Premature close");
1142
+ error.code = "ERR_STREAM_PREMATURE_CLOSE";
1143
+ errorCallback(error);
1144
+ }
1145
+ };
1146
+ const onData = (buf) => {
1147
+ properLastChunkReceived = Buffer$1.compare(buf.slice(-5), LAST_CHUNK) === 0;
1148
+ if (!properLastChunkReceived && previousChunk) properLastChunkReceived = Buffer$1.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && Buffer$1.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0;
1149
+ previousChunk = buf;
1150
+ };
1151
+ socket.prependListener("close", onSocketClose);
1152
+ socket.on("data", onData);
1153
+ request.on("close", () => {
1154
+ socket.removeListener("close", onSocketClose);
1155
+ socket.removeListener("data", onData);
1156
+ });
1157
+ });
1158
+ }
1159
+ var supportedSchemas;
1160
+ //#endregion
1161
+ __esmMin((() => {
1162
+ init_dist();
1163
+ init_body();
1164
+ init_response();
1165
+ init_headers();
1166
+ init_request();
1167
+ init_fetch_error();
1168
+ init_abort_error();
1169
+ init_is_redirect();
1170
+ init_esm_min();
1171
+ init_is();
1172
+ init_referrer();
1173
+ init_from();
1174
+ supportedSchemas = new Set([
1175
+ "data:",
1176
+ "http:",
1177
+ "https:"
1178
+ ]);
1179
+ }))();
1180
+ export { fetch as default };
1181
+
1182
+ //# sourceMappingURL=src-COaj0G3P.js.map