@vibe-lark/larkpal 0.1.86 → 0.1.87

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 (208) hide show
  1. package/dist/account-id-BM1T6029-BzQ_cMoi.mjs +1 -0
  2. package/dist/activation-context--5yu1dPF-XV0Y0pTy.mjs +1 -0
  3. package/dist/anthropic-CFZUCb1w.mjs +39 -0
  4. package/dist/assistant-visible-text-DuFWokAt-BOJV_zwc.mjs +9 -0
  5. package/dist/azure-openai-responses-BEuiMaF-.mjs +1 -0
  6. package/dist/boundary-file-read-BSd9MXPy-gnNVhPKT.mjs +1 -0
  7. package/dist/browser-lifecycle-cleanup-BdNsMhMD-BM97qA_M.mjs +1 -0
  8. package/dist/build-Bkj0hOS2.mjs +3 -0
  9. package/dist/bundled-compat-BpaDaAAu-DJtrIX6i.mjs +27 -0
  10. package/dist/bundled-dir-U738ay4K-BxbzrJOo.mjs +1 -0
  11. package/dist/call-DimWbpgJ-B4pv55RH.mjs +20 -0
  12. package/dist/channel-bootstrap.runtime-BVclcGv1-CEZ0-JP9.mjs +1 -0
  13. package/dist/channel-bootstrap.runtime-Cwcr38m2-Dt6QlQkX.mjs +1 -0
  14. package/dist/chunk-DHbaKqs-.mjs +1 -0
  15. package/dist/cli.mjs +7 -92
  16. package/dist/command-format-LSnUCVVF-Dn4h9IOh.mjs +16 -0
  17. package/dist/config-Bim2pi8a-03N-28sw.mjs +1 -0
  18. package/dist/delivery-context.shared-j5hC5qb1-BSLQG47q.mjs +1 -0
  19. package/dist/diagnostic-ClMwNnUA-BMKvPQJT.mjs +1 -0
  20. package/dist/dist-J5UB83Ws.mjs +601 -0
  21. package/dist/dist-coestTs9.mjs +5 -0
  22. package/dist/env-api-keys-Cuz5irWW.mjs +1 -0
  23. package/dist/event-stream-B7Ei41Bu.mjs +1 -0
  24. package/dist/facade-loader-DFzIYYt_-4bzFvy-b.mjs +1 -0
  25. package/dist/from-Ba69_5cR.mjs +14 -0
  26. package/dist/gateway-method-policy-C7rf0SeV-CTJcMQCE.mjs +1 -0
  27. package/dist/github-copilot-headers-BfhryVuU.mjs +1 -0
  28. package/dist/google-ABo-1guT.mjs +1 -0
  29. package/dist/google-gemini-cli-CGlN1zUA.mjs +2 -0
  30. package/dist/google-shared-C60sNhwd.mjs +301 -0
  31. package/dist/google-vertex-De0nAItu.mjs +1 -0
  32. package/dist/hash-Dw-N8Y9l.mjs +1 -0
  33. package/dist/headers-Bpsp70B9.mjs +1 -0
  34. package/dist/home-dir-C44RaPME-B5iLWwCq.mjs +1 -0
  35. package/dist/ids-BPsM98Uu-CJBJAeVC.mjs +1 -0
  36. package/dist/image-2w3cApg7-CrpUMCvm.mjs +3 -0
  37. package/dist/interactive-init-C5MFL5MW.mjs +8 -0
  38. package/dist/io-CH2g3vsv-JJtUIa_U.mjs +10 -0
  39. package/dist/jiti-loader-cache-Bat69wam-DNIteTtO.mjs +9 -0
  40. package/dist/json-file-BQRNuxmK-hRjIgOXI.mjs +1 -0
  41. package/dist/json-parse-BESd8UAM.mjs +3 -0
  42. package/dist/jws-YaZ38F_i.mjs +12 -0
  43. package/dist/lark-cli-provider-BLMxH6CN.mjs +4 -0
  44. package/dist/lark-logger-xpMKNNtY.mjs +1 -0
  45. package/dist/live-smoke-DpURW676.mjs +33 -0
  46. package/dist/load-context-mb7uvLSn-3xYwSnOZ.mjs +1 -0
  47. package/dist/loader-708jrx4Y-BbJRXNlQ.mjs +4 -0
  48. package/dist/main.mjs +153 -74571
  49. package/dist/manifest-registry-_hxKCS2K-OL8KK_o4.mjs +15 -0
  50. package/dist/mcp-server.mjs +4 -527
  51. package/dist/message-channel-Bk_YHfQg-n2Hw2Y0L.mjs +1 -0
  52. package/dist/message-channel-core-DTA--Gjh-CIh10vfo.mjs +1 -0
  53. package/dist/message.config.runtime-K-k4XOyq-F_h0Cgkl.mjs +1 -0
  54. package/dist/message.gateway.runtime-DqHOHRTQ-ge4c5p4s.mjs +1 -0
  55. package/dist/mistral-DyL3Zo1b.mjs +7 -0
  56. package/dist/model-auth-env-oyg2Hexc-DJbt9J3o.mjs +1 -0
  57. package/dist/models-config-BmpSQJQF-BL6S5qAo.mjs +1 -0
  58. package/dist/models-config.runtime-SOhLEw-f.mjs +1 -0
  59. package/dist/multipart-parser-B9dwXBqu.mjs +2 -0
  60. package/dist/oauth-25y2wc7K.mjs +75 -0
  61. package/dist/openai-C-rgGb7X.mjs +16 -0
  62. package/dist/openai-codex-responses-BbyAPsP1.mjs +7 -0
  63. package/dist/openai-completions-Bu5qvQzb.mjs +5 -0
  64. package/dist/openai-responses-pIdwQBc4.mjs +1 -0
  65. package/dist/openai-responses-shared-DqW1JSux.mjs +10 -0
  66. package/dist/paths-D6msg0S1-BO4XgM1u.mjs +1 -0
  67. package/dist/paths-D92DjaZ--DdtJ-zYp.mjs +1 -0
  68. package/dist/pi-model-discovery-Bd0TWzo8-DvSM0eWu.mjs +1 -0
  69. package/dist/pi-model-discovery-runtime-PrjWOmsV.mjs +1 -0
  70. package/dist/pi-tools.before-tool-call.runtime-Bn7uqKie-WPxU5oNX.mjs +2 -0
  71. package/dist/plugin-auto-enable-DdH3n9V8-Dr_bUXkG.mjs +1 -0
  72. package/dist/process-scoped-map-B2cWkYET-Co-i-MXA.mjs +1 -0
  73. package/dist/provider-discovery.runtime-DY0VWQ81.mjs +1 -0
  74. package/dist/provider-model-compat-CFqcq0it-BUwZENrz.mjs +1 -0
  75. package/dist/provider-runtime-C8rljsNs-BDvu6FW3.mjs +1 -0
  76. package/dist/provider-runtime-CT50mNIX-DImw7ZZu.mjs +79 -0
  77. package/dist/provider-stream-COLujAAo-Dpq1DSIk.mjs +248 -0
  78. package/dist/providers.runtime-Ba7tOlq7-B4t6ywCr.mjs +1 -0
  79. package/dist/public-surface-loader-BVl0NQAE-TfJ3izj1.mjs +1 -0
  80. package/dist/resolve-C33B7eeu-DZM_z6Wr.mjs +1 -0
  81. package/dist/runtime-Cym-fqI8-1GOIuRRQ.mjs +1 -0
  82. package/dist/runtime-channel-state-CohMybAh-BBzhl07Q.mjs +1 -0
  83. package/dist/runtime-snapshot-C54O1-gI-DxusscPf.mjs +1 -0
  84. package/dist/runtime-state-IBOIXKOx-Cw1GA1td.mjs +1 -0
  85. package/dist/runtime-web-tools-fallback.runtime-Ca-qn1mj-BsYE2gOd.mjs +1 -0
  86. package/dist/runtime-web-tools-manifest.runtime-BgxQTjmq-P6MKP9gQ.mjs +1 -0
  87. package/dist/runtime-web-tools-public-artifacts.runtime-D9qcoWIX-5VoyjouO.mjs +1 -0
  88. package/dist/session-archive.runtime-B52_5vs4-cU2tYbBz.mjs +1 -0
  89. package/dist/session-key-Cn2QoOyX-QZeYmbxd.mjs +1 -0
  90. package/dist/session-transcript-files.fs-DEeFXruQ-CXIAFSsr.mjs +1 -0
  91. package/dist/src-CCDx_C-U.mjs +3 -0
  92. package/dist/src-DACmA9V6.mjs +5 -0
  93. package/dist/subagent-announce-L5WsQatW--rMn240x.mjs +2 -0
  94. package/dist/subagent-announce.registry.runtime-DiqZyeTs-DNfNHsls.mjs +1 -0
  95. package/dist/subagent-registry-steer-runtime-DFgZFC0j-XYS1_qwl.mjs +1 -0
  96. package/dist/subagent-system-prompt-C1qnN--K-CsU4f97T.mjs +23 -0
  97. package/dist/target-parsing-loaded-DKkb6jJY-B830OA1a.mjs +12 -0
  98. package/dist/task-registry-delivery-runtime-Dd1CUkZF-B2Hj2k8C.mjs +16 -0
  99. package/dist/task-registry-delivery-runtime-ragbeVx5-Bdvo2Q5u.mjs +1 -0
  100. package/dist/thinking-Bh-7MqXz-uApNUe6g.mjs +1 -0
  101. package/dist/transcript-E_-ISOkD-VTwb782D.mjs +5 -0
  102. package/dist/transcript.runtime-BqhvZZdl-B4E0TiX5.mjs +1 -0
  103. package/dist/transform-messages-BTA3xbAI.mjs +1 -0
  104. package/dist/web-provider-public-artifacts-BlpRwIUS-DbVhDOrY.mjs +1 -0
  105. package/dist/web-search-providers.runtime--0aUtC3b-Bjh4Bmrz.mjs +1 -0
  106. package/package.json +2 -3
  107. package/dist/account-id-BM1T6029-DYjVxojW.mjs +0 -46
  108. package/dist/activation-context--5yu1dPF-Bwsn3moT.mjs +0 -172
  109. package/dist/anthropic-TH8ERTXK.mjs +0 -5962
  110. package/dist/assistant-visible-text-DuFWokAt-CsbII5KS.mjs +0 -596
  111. package/dist/azure-openai-responses-Bt_Ag9Er.mjs +0 -166
  112. package/dist/boundary-file-read-BSd9MXPy--KThL5e6.mjs +0 -594
  113. package/dist/browser-lifecycle-cleanup-BdNsMhMD-O3tnAM4i.mjs +0 -60
  114. package/dist/build-DgTrEpge.mjs +0 -3333
  115. package/dist/bundled-compat-BpaDaAAu-D7oazKjD.mjs +0 -5216
  116. package/dist/bundled-dir-U738ay4K-DXK0q_TV.mjs +0 -258
  117. package/dist/call-DimWbpgJ-ColD4W-y.mjs +0 -9993
  118. package/dist/channel-bootstrap.runtime-BVclcGv1-DJv_Z-Kr.mjs +0 -2
  119. package/dist/channel-bootstrap.runtime-Cwcr38m2-VRfVCR-i.mjs +0 -33
  120. package/dist/chunk-D6SyT4dJ.mjs +0 -36
  121. package/dist/command-format-LSnUCVVF-BQ2SMKka.mjs +0 -685
  122. package/dist/config-Bim2pi8a-BQUdfiEi.mjs +0 -9
  123. package/dist/delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs +0 -72
  124. package/dist/diagnostic-ClMwNnUA-D6nUtLnb.mjs +0 -140
  125. package/dist/dist-CEGw8-2W.mjs +0 -429
  126. package/dist/dist-DD2aJ2UL.mjs +0 -125135
  127. package/dist/env-api-keys-BVvSg7T2.mjs +0 -68
  128. package/dist/event-stream-xaQWmyas.mjs +0 -15226
  129. package/dist/facade-loader-DFzIYYt_-CIr4HKtE.mjs +0 -194
  130. package/dist/from-DF7cl2wz.mjs +0 -3842
  131. package/dist/gateway-method-policy-C7rf0SeV-CJQMEYIE.mjs +0 -28
  132. package/dist/github-copilot-headers-DjqWtUoP.mjs +0 -22
  133. package/dist/google-C2pVrgBZ.mjs +0 -336
  134. package/dist/google-gemini-cli-BBxgS5Ho.mjs +0 -623
  135. package/dist/google-shared-BsWgwEk1.mjs +0 -22791
  136. package/dist/google-vertex-BsVLJrrC.mjs +0 -358
  137. package/dist/hash-DAFtW_W7.mjs +0 -16
  138. package/dist/headers-R3HdCbAE.mjs +0 -8
  139. package/dist/home-dir-C44RaPME-CBRS4HLP.mjs +0 -93
  140. package/dist/ids-BPsM98Uu-CwuxvUai.mjs +0 -77
  141. package/dist/image-2w3cApg7-CxpHvoB5.mjs +0 -207
  142. package/dist/interactive-init-BXQBalNr.mjs +0 -450
  143. package/dist/io-CH2g3vsv-BOGlLlB8.mjs +0 -26218
  144. package/dist/jiti-loader-cache-Bat69wam-D6hCxboy.mjs +0 -5049
  145. package/dist/json-file-BQRNuxmK-DhJM5NsG.mjs +0 -108
  146. package/dist/json-parse-v_HIJjjI.mjs +0 -381
  147. package/dist/jws-GFcTvvVT.mjs +0 -2291
  148. package/dist/lark-cli-provider-BARgbbmo.mjs +0 -554
  149. package/dist/lark-logger-D7_pEVQc.mjs +0 -143
  150. package/dist/live-smoke-BhkBOcH9.mjs +0 -7135
  151. package/dist/load-context-mb7uvLSn-B10MAi3I.mjs +0 -29
  152. package/dist/loader-708jrx4Y-BOswuvpe.mjs +0 -5053
  153. package/dist/manifest-registry-_hxKCS2K-CZdeyN0f.mjs +0 -3512
  154. package/dist/message-channel-Bk_YHfQg-AeNrPPpp.mjs +0 -50
  155. package/dist/message-channel-core-DTA--Gjh-CY4Tkb7N.mjs +0 -29
  156. package/dist/message.config.runtime-K-k4XOyq-DZTmXomP.mjs +0 -2
  157. package/dist/message.gateway.runtime-DqHOHRTQ-DH4ml0YF.mjs +0 -2
  158. package/dist/mistral-CaR4DiLu.mjs +0 -28657
  159. package/dist/model-auth-env-oyg2Hexc-DU_rOUU5.mjs +0 -1306
  160. package/dist/models-config-BmpSQJQF-Gfvh1n3A.mjs +0 -1282
  161. package/dist/models-config.runtime-BsU_22xk.mjs +0 -2
  162. package/dist/multipart-parser-DedmaB5g.mjs +0 -294
  163. package/dist/oauth-DOJeGfcE.mjs +0 -6392
  164. package/dist/openai-BDtIh3Ja.mjs +0 -6693
  165. package/dist/openai-codex-responses-C5EORu31.mjs +0 -664
  166. package/dist/openai-completions-CR_cS6gX.mjs +0 -669
  167. package/dist/openai-responses-oGxwZyuC.mjs +0 -184
  168. package/dist/openai-responses-shared-BixMSDZE.mjs +0 -398
  169. package/dist/paths-D6msg0S1-C2lYuisN.mjs +0 -189
  170. package/dist/paths-D92DjaZ--CTOESW2b.mjs +0 -192
  171. package/dist/pi-model-discovery-Bd0TWzo8-BFsJmeMb.mjs +0 -227
  172. package/dist/pi-model-discovery-runtime-CCCZxkd8.mjs +0 -2
  173. package/dist/pi-tools.before-tool-call.runtime-Bn7uqKie-C5ewk8kK.mjs +0 -399
  174. package/dist/plugin-auto-enable-DdH3n9V8-DsA1isaF.mjs +0 -1456
  175. package/dist/process-scoped-map-B2cWkYET-CXwUZ8CZ.mjs +0 -61
  176. package/dist/provider-discovery.runtime-BPzz1PFj.mjs +0 -58
  177. package/dist/provider-model-compat-CFqcq0it-BDDuBI3A.mjs +0 -118
  178. package/dist/provider-runtime-C8rljsNs-CIT93zoy.mjs +0 -2
  179. package/dist/provider-runtime-CT50mNIX-BwEV6GyO.mjs +0 -573
  180. package/dist/provider-stream-COLujAAo-CbJPDngm.mjs +0 -35449
  181. package/dist/providers.runtime-Ba7tOlq7-CXkhkzU9.mjs +0 -219
  182. package/dist/public-surface-loader-BVl0NQAE-C0piXtsT.mjs +0 -117
  183. package/dist/resolve-C33B7eeu-BNvYTl6k.mjs +0 -1041
  184. package/dist/runtime-Cym-fqI8-DaSDMH-a.mjs +0 -120
  185. package/dist/runtime-channel-state-CohMybAh-hXR6y5Gx.mjs +0 -19
  186. package/dist/runtime-snapshot-C54O1-gI-40cbyi7P.mjs +0 -677
  187. package/dist/runtime-state-IBOIXKOx-Bf9tcLvc.mjs +0 -10
  188. package/dist/runtime-web-tools-fallback.runtime-Ca-qn1mj-BCVImm7a.mjs +0 -39
  189. package/dist/runtime-web-tools-manifest.runtime-BgxQTjmq-Cb4nJkRT.mjs +0 -2
  190. package/dist/runtime-web-tools-public-artifacts.runtime-D9qcoWIX-BrQdXzOQ.mjs +0 -2
  191. package/dist/session-archive.runtime-B52_5vs4-BG-_IwNJ.mjs +0 -2
  192. package/dist/session-key-Cn2QoOyX-CuHbJMgR.mjs +0 -82
  193. package/dist/session-transcript-files.fs-DEeFXruQ-B1PF6nLy.mjs +0 -147
  194. package/dist/src-BgCX0MLG.mjs +0 -813
  195. package/dist/src-DYbqlAqf.mjs +0 -1177
  196. package/dist/subagent-announce-L5WsQatW-CQWI9GMd.mjs +0 -344
  197. package/dist/subagent-announce.registry.runtime-DiqZyeTs-BKuniyi3.mjs +0 -28
  198. package/dist/subagent-registry-steer-runtime-DFgZFC0j-BhBz0roy.mjs +0 -211
  199. package/dist/subagent-system-prompt-C1qnN--K-DpnTFP47.mjs +0 -3061
  200. package/dist/target-parsing-loaded-DKkb6jJY-BMD4CkpS.mjs +0 -1002
  201. package/dist/task-registry-delivery-runtime-Dd1CUkZF-C8U40a3O.mjs +0 -2950
  202. package/dist/task-registry-delivery-runtime-ragbeVx5-CNbFAkjD.mjs +0 -2
  203. package/dist/thinking-Bh-7MqXz-D3woGbO7.mjs +0 -2
  204. package/dist/transcript-E_-ISOkD-DWCfZP2p.mjs +0 -2019
  205. package/dist/transcript.runtime-BqhvZZdl-BPy42vBP.mjs +0 -2
  206. package/dist/transform-messages-DbhIzTxq.mjs +0 -207
  207. package/dist/web-provider-public-artifacts-BlpRwIUS-CGPSV4W2.mjs +0 -295
  208. package/dist/web-search-providers.runtime--0aUtC3b-DyuhC95V.mjs +0 -200
@@ -1,1177 +0,0 @@
1
- import { n as __esmMin } from "./chunk-D6SyT4dJ.mjs";
2
- import { i as init_esm_min, n as FormData, o as Blob, r as formDataToBlob, s as init_fetch_blob, t as init_from } from "./from-DF7cl2wz.mjs";
3
- import { format } from "node:url";
4
- import Pe, { PassThrough, pipeline } from "node:stream";
5
- import { deprecate, promisify, types } from "node:util";
6
- import { isIP } from "node:net";
7
- import { Buffer as Buffer$1 } from "node:buffer";
8
- import zlib from "node:zlib";
9
- import http from "node:http";
10
- import https from "node:https";
11
- //#region node_modules/.pnpm/data-uri-to-buffer@4.0.1/node_modules/data-uri-to-buffer/dist/index.js
12
- /**
13
- * Returns a `Buffer` instance from the given data URI `uri`.
14
- *
15
- * @param {String} uri Data URI to turn into a Buffer instance
16
- * @returns {Buffer} Buffer instance from Data URI
17
- * @api public
18
- */
19
- function dataUriToBuffer(uri) {
20
- if (!/^data:/i.test(uri)) throw new TypeError("`uri` does not appear to be a Data URI (must begin with \"data:\")");
21
- uri = uri.replace(/\r?\n/g, "");
22
- const firstComma = uri.indexOf(",");
23
- if (firstComma === -1 || firstComma <= 4) throw new TypeError("malformed data: URI");
24
- const meta = uri.substring(5, firstComma).split(";");
25
- let charset = "";
26
- let base64 = false;
27
- const type = meta[0] || "text/plain";
28
- let typeFull = type;
29
- for (let i = 1; i < meta.length; i++) if (meta[i] === "base64") base64 = true;
30
- else if (meta[i]) {
31
- typeFull += `;${meta[i]}`;
32
- if (meta[i].indexOf("charset=") === 0) charset = meta[i].substring(8);
33
- }
34
- if (!meta[0] && !charset.length) {
35
- typeFull += ";charset=US-ASCII";
36
- charset = "US-ASCII";
37
- }
38
- const encoding = base64 ? "base64" : "ascii";
39
- const data = unescape(uri.substring(firstComma + 1));
40
- const buffer = Buffer.from(data, encoding);
41
- buffer.type = type;
42
- buffer.typeFull = typeFull;
43
- buffer.charset = charset;
44
- return buffer;
45
- }
46
- var init_dist = __esmMin((() => {}));
47
- //#endregion
48
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/base.js
49
- var FetchBaseError;
50
- var init_base = __esmMin((() => {
51
- FetchBaseError = class extends Error {
52
- constructor(message, type) {
53
- super(message);
54
- Error.captureStackTrace(this, this.constructor);
55
- this.type = type;
56
- }
57
- get name() {
58
- return this.constructor.name;
59
- }
60
- get [Symbol.toStringTag]() {
61
- return this.constructor.name;
62
- }
63
- };
64
- }));
65
- //#endregion
66
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/fetch-error.js
67
- var FetchError;
68
- var init_fetch_error = __esmMin((() => {
69
- init_base();
70
- FetchError = class extends FetchBaseError {
71
- /**
72
- * @param {string} message - Error message for human
73
- * @param {string} [type] - Error type for machine
74
- * @param {SystemError} [systemError] - For Node.js system error
75
- */
76
- constructor(message, type, systemError) {
77
- super(message, type);
78
- if (systemError) {
79
- this.code = this.errno = systemError.code;
80
- this.erroredSysCall = systemError.syscall;
81
- }
82
- }
83
- };
84
- }));
85
- //#endregion
86
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/is.js
87
- var NAME, isURLSearchParameters, isBlob, isAbortSignal, isDomainOrSubdomain, isSameProtocol;
88
- var init_is = __esmMin((() => {
89
- NAME = Symbol.toStringTag;
90
- isURLSearchParameters = (object) => {
91
- 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";
92
- };
93
- isBlob = (object) => {
94
- 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]);
95
- };
96
- isAbortSignal = (object) => {
97
- return typeof object === "object" && (object[NAME] === "AbortSignal" || object[NAME] === "EventTarget");
98
- };
99
- isDomainOrSubdomain = (destination, original) => {
100
- const orig = new URL(original).hostname;
101
- const dest = new URL(destination).hostname;
102
- return orig === dest || orig.endsWith(`.${dest}`);
103
- };
104
- isSameProtocol = (destination, original) => {
105
- return new URL(original).protocol === new URL(destination).protocol;
106
- };
107
- }));
108
- //#endregion
109
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/body.js
110
- /**
111
- * Body.js
112
- *
113
- * Body interface provides common methods for Request and Response
114
- */
115
- /**
116
- * Consume and convert an entire Body to a Buffer.
117
- *
118
- * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body
119
- *
120
- * @return Promise
121
- */
122
- async function consumeBody(data) {
123
- if (data[INTERNALS$2].disturbed) throw new TypeError(`body used already for: ${data.url}`);
124
- data[INTERNALS$2].disturbed = true;
125
- if (data[INTERNALS$2].error) throw data[INTERNALS$2].error;
126
- const { body } = data;
127
- if (body === null) return Buffer$1.alloc(0);
128
- /* c8 ignore next 3 */
129
- if (!(body instanceof Pe)) return Buffer$1.alloc(0);
130
- const accum = [];
131
- let accumBytes = 0;
132
- try {
133
- for await (const chunk of body) {
134
- if (data.size > 0 && accumBytes + chunk.length > data.size) {
135
- const error = new FetchError(`content size at ${data.url} over limit: ${data.size}`, "max-size");
136
- body.destroy(error);
137
- throw error;
138
- }
139
- accumBytes += chunk.length;
140
- accum.push(chunk);
141
- }
142
- } catch (error) {
143
- throw error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data.url}: ${error.message}`, "system", error);
144
- }
145
- if (body.readableEnded === true || body._readableState.ended === true) try {
146
- if (accum.every((c) => typeof c === "string")) return Buffer$1.from(accum.join(""));
147
- return Buffer$1.concat(accum, accumBytes);
148
- } catch (error) {
149
- throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, "system", error);
150
- }
151
- else throw new FetchError(`Premature close of server response while trying to fetch ${data.url}`);
152
- }
153
- var pipeline$1, INTERNALS$2, Body, clone, getNonSpecFormDataBoundary, extractContentType, getTotalBytes, writeToStream;
154
- var init_body = __esmMin((() => {
155
- init_fetch_blob();
156
- init_esm_min();
157
- init_fetch_error();
158
- init_base();
159
- init_is();
160
- pipeline$1 = promisify(Pe.pipeline);
161
- INTERNALS$2 = Symbol("Body internals");
162
- Body = class {
163
- constructor(body, { size = 0 } = {}) {
164
- let boundary = null;
165
- if (body === null) body = null;
166
- else if (isURLSearchParameters(body)) body = Buffer$1.from(body.toString());
167
- else if (isBlob(body)) {} else if (Buffer$1.isBuffer(body)) {} else if (types.isAnyArrayBuffer(body)) body = Buffer$1.from(body);
168
- else if (ArrayBuffer.isView(body)) body = Buffer$1.from(body.buffer, body.byteOffset, body.byteLength);
169
- else if (body instanceof Pe) {} else if (body instanceof FormData) {
170
- body = formDataToBlob(body);
171
- boundary = body.type.split("=")[1];
172
- } else body = Buffer$1.from(String(body));
173
- let stream = body;
174
- if (Buffer$1.isBuffer(body)) stream = Pe.Readable.from(body);
175
- else if (isBlob(body)) stream = Pe.Readable.from(body.stream());
176
- this[INTERNALS$2] = {
177
- body,
178
- stream,
179
- boundary,
180
- disturbed: false,
181
- error: null
182
- };
183
- this.size = size;
184
- if (body instanceof Pe) body.on("error", (error_) => {
185
- const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
186
- this[INTERNALS$2].error = error;
187
- });
188
- }
189
- get body() {
190
- return this[INTERNALS$2].stream;
191
- }
192
- get bodyUsed() {
193
- return this[INTERNALS$2].disturbed;
194
- }
195
- /**
196
- * Decode response as ArrayBuffer
197
- *
198
- * @return Promise
199
- */
200
- async arrayBuffer() {
201
- const { buffer, byteOffset, byteLength } = await consumeBody(this);
202
- return buffer.slice(byteOffset, byteOffset + byteLength);
203
- }
204
- async formData() {
205
- const ct = this.headers.get("content-type");
206
- if (ct.startsWith("application/x-www-form-urlencoded")) {
207
- const formData = new FormData();
208
- const parameters = new URLSearchParams(await this.text());
209
- for (const [name, value] of parameters) formData.append(name, value);
210
- return formData;
211
- }
212
- const { toFormData } = await import("./multipart-parser-DedmaB5g.mjs");
213
- return toFormData(this.body, ct);
214
- }
215
- /**
216
- * Return raw response as Blob
217
- *
218
- * @return Promise
219
- */
220
- async blob() {
221
- const ct = this.headers && this.headers.get("content-type") || this[INTERNALS$2].body && this[INTERNALS$2].body.type || "";
222
- return new Blob([await this.arrayBuffer()], { type: ct });
223
- }
224
- /**
225
- * Decode response as json
226
- *
227
- * @return Promise
228
- */
229
- async json() {
230
- const text = await this.text();
231
- return JSON.parse(text);
232
- }
233
- /**
234
- * Decode response as text
235
- *
236
- * @return Promise
237
- */
238
- async text() {
239
- const buffer = await consumeBody(this);
240
- return new TextDecoder().decode(buffer);
241
- }
242
- /**
243
- * Decode response as buffer (non-spec api)
244
- *
245
- * @return Promise
246
- */
247
- buffer() {
248
- return consumeBody(this);
249
- }
250
- };
251
- Body.prototype.buffer = deprecate(Body.prototype.buffer, "Please use 'response.arrayBuffer()' instead of 'response.buffer()'", "node-fetch#buffer");
252
- Object.defineProperties(Body.prototype, {
253
- body: { enumerable: true },
254
- bodyUsed: { enumerable: true },
255
- arrayBuffer: { enumerable: true },
256
- blob: { enumerable: true },
257
- json: { enumerable: true },
258
- text: { enumerable: true },
259
- data: { get: deprecate(() => {}, "data doesn't exist, use json(), text(), arrayBuffer(), or body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (response)") }
260
- });
261
- clone = (instance, highWaterMark) => {
262
- let p1;
263
- let p2;
264
- let { body } = instance[INTERNALS$2];
265
- if (instance.bodyUsed) throw new Error("cannot clone body after it is used");
266
- if (body instanceof Pe && typeof body.getBoundary !== "function") {
267
- p1 = new PassThrough({ highWaterMark });
268
- p2 = new PassThrough({ highWaterMark });
269
- body.pipe(p1);
270
- body.pipe(p2);
271
- instance[INTERNALS$2].stream = p1;
272
- body = p2;
273
- }
274
- return body;
275
- };
276
- 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");
277
- extractContentType = (body, request) => {
278
- if (body === null) return null;
279
- if (typeof body === "string") return "text/plain;charset=UTF-8";
280
- if (isURLSearchParameters(body)) return "application/x-www-form-urlencoded;charset=UTF-8";
281
- if (isBlob(body)) return body.type || null;
282
- if (Buffer$1.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) return null;
283
- if (body instanceof FormData) return `multipart/form-data; boundary=${request[INTERNALS$2].boundary}`;
284
- if (body && typeof body.getBoundary === "function") return `multipart/form-data;boundary=${getNonSpecFormDataBoundary(body)}`;
285
- if (body instanceof Pe) return null;
286
- return "text/plain;charset=UTF-8";
287
- };
288
- getTotalBytes = (request) => {
289
- const { body } = request[INTERNALS$2];
290
- if (body === null) return 0;
291
- if (isBlob(body)) return body.size;
292
- if (Buffer$1.isBuffer(body)) return body.length;
293
- if (body && typeof body.getLengthSync === "function") return body.hasKnownLength && body.hasKnownLength() ? body.getLengthSync() : null;
294
- return null;
295
- };
296
- writeToStream = async (dest, { body }) => {
297
- if (body === null) dest.end();
298
- else await pipeline$1(body, dest);
299
- };
300
- }));
301
- //#endregion
302
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/headers.js
303
- /**
304
- * Headers.js
305
- *
306
- * Headers class offers convenient helpers
307
- */
308
- /**
309
- * Create a Headers object from an http.IncomingMessage.rawHeaders, ignoring those that do
310
- * not conform to HTTP grammar productions.
311
- * @param {import('http').IncomingMessage['rawHeaders']} headers
312
- */
313
- function fromRawHeaders(headers = []) {
314
- return new Headers(headers.reduce((result, value, index, array) => {
315
- if (index % 2 === 0) result.push(array.slice(index, index + 2));
316
- return result;
317
- }, []).filter(([name, value]) => {
318
- try {
319
- validateHeaderName(name);
320
- validateHeaderValue(name, String(value));
321
- return true;
322
- } catch {
323
- return false;
324
- }
325
- }));
326
- }
327
- var validateHeaderName, validateHeaderValue, Headers;
328
- var init_headers = __esmMin((() => {
329
- validateHeaderName = typeof http.validateHeaderName === "function" ? http.validateHeaderName : (name) => {
330
- if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
331
- const error = /* @__PURE__ */ new TypeError(`Header name must be a valid HTTP token [${name}]`);
332
- Object.defineProperty(error, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
333
- throw error;
334
- }
335
- };
336
- validateHeaderValue = typeof http.validateHeaderValue === "function" ? http.validateHeaderValue : (name, value) => {
337
- if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
338
- const error = /* @__PURE__ */ new TypeError(`Invalid character in header content ["${name}"]`);
339
- Object.defineProperty(error, "code", { value: "ERR_INVALID_CHAR" });
340
- throw error;
341
- }
342
- };
343
- Headers = class Headers extends URLSearchParams {
344
- /**
345
- * Headers class
346
- *
347
- * @constructor
348
- * @param {HeadersInit} [init] - Response headers
349
- */
350
- constructor(init) {
351
- /** @type {string[][]} */
352
- let result = [];
353
- if (init instanceof Headers) {
354
- const raw = init.raw();
355
- for (const [name, values] of Object.entries(raw)) result.push(...values.map((value) => [name, value]));
356
- } else if (init == null) {} else if (typeof init === "object" && !types.isBoxedPrimitive(init)) {
357
- const method = init[Symbol.iterator];
358
- if (method == null) result.push(...Object.entries(init));
359
- else {
360
- if (typeof method !== "function") throw new TypeError("Header pairs must be iterable");
361
- result = [...init].map((pair) => {
362
- if (typeof pair !== "object" || types.isBoxedPrimitive(pair)) throw new TypeError("Each header pair must be an iterable object");
363
- return [...pair];
364
- }).map((pair) => {
365
- if (pair.length !== 2) throw new TypeError("Each header pair must be a name/value tuple");
366
- return [...pair];
367
- });
368
- }
369
- } else throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");
370
- result = result.length > 0 ? result.map(([name, value]) => {
371
- validateHeaderName(name);
372
- validateHeaderValue(name, String(value));
373
- return [String(name).toLowerCase(), String(value)];
374
- }) : void 0;
375
- super(result);
376
- return new Proxy(this, { get(target, p, receiver) {
377
- switch (p) {
378
- case "append":
379
- case "set": return (name, value) => {
380
- validateHeaderName(name);
381
- validateHeaderValue(name, String(value));
382
- return URLSearchParams.prototype[p].call(target, String(name).toLowerCase(), String(value));
383
- };
384
- case "delete":
385
- case "has":
386
- case "getAll": return (name) => {
387
- validateHeaderName(name);
388
- return URLSearchParams.prototype[p].call(target, String(name).toLowerCase());
389
- };
390
- case "keys": return () => {
391
- target.sort();
392
- return new Set(URLSearchParams.prototype.keys.call(target)).keys();
393
- };
394
- default: return Reflect.get(target, p, receiver);
395
- }
396
- } });
397
- /* c8 ignore next */
398
- }
399
- get [Symbol.toStringTag]() {
400
- return this.constructor.name;
401
- }
402
- toString() {
403
- return Object.prototype.toString.call(this);
404
- }
405
- get(name) {
406
- const values = this.getAll(name);
407
- if (values.length === 0) return null;
408
- let value = values.join(", ");
409
- if (/^content-encoding$/i.test(name)) value = value.toLowerCase();
410
- return value;
411
- }
412
- forEach(callback, thisArg = void 0) {
413
- for (const name of this.keys()) Reflect.apply(callback, thisArg, [
414
- this.get(name),
415
- name,
416
- this
417
- ]);
418
- }
419
- *values() {
420
- for (const name of this.keys()) yield this.get(name);
421
- }
422
- /**
423
- * @type {() => IterableIterator<[string, string]>}
424
- */
425
- *entries() {
426
- for (const name of this.keys()) yield [name, this.get(name)];
427
- }
428
- [Symbol.iterator]() {
429
- return this.entries();
430
- }
431
- /**
432
- * Node-fetch non-spec method
433
- * returning all headers and their values as array
434
- * @returns {Record<string, string[]>}
435
- */
436
- raw() {
437
- return [...this.keys()].reduce((result, key) => {
438
- result[key] = this.getAll(key);
439
- return result;
440
- }, {});
441
- }
442
- /**
443
- * For better console.log(headers) and also to convert Headers into Node.js Request compatible format
444
- */
445
- [Symbol.for("nodejs.util.inspect.custom")]() {
446
- return [...this.keys()].reduce((result, key) => {
447
- const values = this.getAll(key);
448
- if (key === "host") result[key] = values[0];
449
- else result[key] = values.length > 1 ? values : values[0];
450
- return result;
451
- }, {});
452
- }
453
- };
454
- /**
455
- * Re-shaping object for Web IDL tests
456
- * Only need to do it for overridden methods
457
- */
458
- Object.defineProperties(Headers.prototype, [
459
- "get",
460
- "entries",
461
- "forEach",
462
- "values"
463
- ].reduce((result, property) => {
464
- result[property] = { enumerable: true };
465
- return result;
466
- }, {}));
467
- }));
468
- //#endregion
469
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/is-redirect.js
470
- var redirectStatus, isRedirect;
471
- var init_is_redirect = __esmMin((() => {
472
- redirectStatus = new Set([
473
- 301,
474
- 302,
475
- 303,
476
- 307,
477
- 308
478
- ]);
479
- isRedirect = (code) => {
480
- return redirectStatus.has(code);
481
- };
482
- }));
483
- //#endregion
484
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/response.js
485
- var INTERNALS$1, Response;
486
- var init_response = __esmMin((() => {
487
- init_headers();
488
- init_body();
489
- init_is_redirect();
490
- INTERNALS$1 = Symbol("Response internals");
491
- Response = class Response extends Body {
492
- constructor(body = null, options = {}) {
493
- super(body, options);
494
- const status = options.status != null ? options.status : 200;
495
- const headers = new Headers(options.headers);
496
- if (body !== null && !headers.has("Content-Type")) {
497
- const contentType = extractContentType(body, this);
498
- if (contentType) headers.append("Content-Type", contentType);
499
- }
500
- this[INTERNALS$1] = {
501
- type: "default",
502
- url: options.url,
503
- status,
504
- statusText: options.statusText || "",
505
- headers,
506
- counter: options.counter,
507
- highWaterMark: options.highWaterMark
508
- };
509
- }
510
- get type() {
511
- return this[INTERNALS$1].type;
512
- }
513
- get url() {
514
- return this[INTERNALS$1].url || "";
515
- }
516
- get status() {
517
- return this[INTERNALS$1].status;
518
- }
519
- /**
520
- * Convenience property representing if the request ended normally
521
- */
522
- get ok() {
523
- return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;
524
- }
525
- get redirected() {
526
- return this[INTERNALS$1].counter > 0;
527
- }
528
- get statusText() {
529
- return this[INTERNALS$1].statusText;
530
- }
531
- get headers() {
532
- return this[INTERNALS$1].headers;
533
- }
534
- get highWaterMark() {
535
- return this[INTERNALS$1].highWaterMark;
536
- }
537
- /**
538
- * Clone this response
539
- *
540
- * @return Response
541
- */
542
- clone() {
543
- return new Response(clone(this, this.highWaterMark), {
544
- type: this.type,
545
- url: this.url,
546
- status: this.status,
547
- statusText: this.statusText,
548
- headers: this.headers,
549
- ok: this.ok,
550
- redirected: this.redirected,
551
- size: this.size,
552
- highWaterMark: this.highWaterMark
553
- });
554
- }
555
- /**
556
- * @param {string} url The URL that the new response is to originate from.
557
- * @param {number} status An optional status code for the response (e.g., 302.)
558
- * @returns {Response} A Response object.
559
- */
560
- static redirect(url, status = 302) {
561
- if (!isRedirect(status)) throw new RangeError("Failed to execute \"redirect\" on \"response\": Invalid status code");
562
- return new Response(null, {
563
- headers: { location: new URL(url).toString() },
564
- status
565
- });
566
- }
567
- static error() {
568
- const response = new Response(null, {
569
- status: 0,
570
- statusText: ""
571
- });
572
- response[INTERNALS$1].type = "error";
573
- return response;
574
- }
575
- static json(data = void 0, init = {}) {
576
- const body = JSON.stringify(data);
577
- if (body === void 0) throw new TypeError("data is not JSON serializable");
578
- const headers = new Headers(init && init.headers);
579
- if (!headers.has("content-type")) headers.set("content-type", "application/json");
580
- return new Response(body, {
581
- ...init,
582
- headers
583
- });
584
- }
585
- get [Symbol.toStringTag]() {
586
- return "Response";
587
- }
588
- };
589
- Object.defineProperties(Response.prototype, {
590
- type: { enumerable: true },
591
- url: { enumerable: true },
592
- status: { enumerable: true },
593
- ok: { enumerable: true },
594
- redirected: { enumerable: true },
595
- statusText: { enumerable: true },
596
- headers: { enumerable: true },
597
- clone: { enumerable: true }
598
- });
599
- }));
600
- //#endregion
601
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/get-search.js
602
- var getSearch;
603
- var init_get_search = __esmMin((() => {
604
- getSearch = (parsedURL) => {
605
- if (parsedURL.search) return parsedURL.search;
606
- const lastOffset = parsedURL.href.length - 1;
607
- const hash = parsedURL.hash || (parsedURL.href[lastOffset] === "#" ? "#" : "");
608
- return parsedURL.href[lastOffset - hash.length] === "?" ? "?" : "";
609
- };
610
- }));
611
- //#endregion
612
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/referrer.js
613
- /**
614
- * @external URL
615
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/URL|URL}
616
- */
617
- /**
618
- * @module utils/referrer
619
- * @private
620
- */
621
- /**
622
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#strip-url|Referrer Policy §8.4. Strip url for use as a referrer}
623
- * @param {string} URL
624
- * @param {boolean} [originOnly=false]
625
- */
626
- function stripURLForUseAsAReferrer(url, originOnly = false) {
627
- if (url == null) return "no-referrer";
628
- url = new URL(url);
629
- if (/^(about|blob|data):$/.test(url.protocol)) return "no-referrer";
630
- url.username = "";
631
- url.password = "";
632
- url.hash = "";
633
- if (originOnly) {
634
- url.pathname = "";
635
- url.search = "";
636
- }
637
- return url;
638
- }
639
- /**
640
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#referrer-policies|Referrer Policy §3. Referrer Policies}
641
- * @param {string} referrerPolicy
642
- * @returns {string} referrerPolicy
643
- */
644
- function validateReferrerPolicy(referrerPolicy) {
645
- if (!ReferrerPolicy.has(referrerPolicy)) throw new TypeError(`Invalid referrerPolicy: ${referrerPolicy}`);
646
- return referrerPolicy;
647
- }
648
- /**
649
- * @see {@link https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy|Referrer Policy §3.2. Is origin potentially trustworthy?}
650
- * @param {external:URL} url
651
- * @returns `true`: "Potentially Trustworthy", `false`: "Not Trustworthy"
652
- */
653
- function isOriginPotentiallyTrustworthy(url) {
654
- if (/^(http|ws)s:$/.test(url.protocol)) return true;
655
- const hostIp = url.host.replace(/(^\[)|(]$)/g, "");
656
- const hostIPVersion = isIP(hostIp);
657
- if (hostIPVersion === 4 && /^127\./.test(hostIp)) return true;
658
- if (hostIPVersion === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(hostIp)) return true;
659
- if (url.host === "localhost" || url.host.endsWith(".localhost")) return false;
660
- if (url.protocol === "file:") return true;
661
- return false;
662
- }
663
- /**
664
- * @see {@link https://w3c.github.io/webappsec-secure-contexts/#is-url-trustworthy|Referrer Policy §3.3. Is url potentially trustworthy?}
665
- * @param {external:URL} url
666
- * @returns `true`: "Potentially Trustworthy", `false`: "Not Trustworthy"
667
- */
668
- function isUrlPotentiallyTrustworthy(url) {
669
- if (/^about:(blank|srcdoc)$/.test(url)) return true;
670
- if (url.protocol === "data:") return true;
671
- if (/^(blob|filesystem):$/.test(url.protocol)) return true;
672
- return isOriginPotentiallyTrustworthy(url);
673
- }
674
- /**
675
- * Modifies the referrerURL to enforce any extra security policy considerations.
676
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer|Referrer Policy §8.3. Determine request's Referrer}, step 7
677
- * @callback module:utils/referrer~referrerURLCallback
678
- * @param {external:URL} referrerURL
679
- * @returns {external:URL} modified referrerURL
680
- */
681
- /**
682
- * Modifies the referrerOrigin to enforce any extra security policy considerations.
683
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer|Referrer Policy §8.3. Determine request's Referrer}, step 7
684
- * @callback module:utils/referrer~referrerOriginCallback
685
- * @param {external:URL} referrerOrigin
686
- * @returns {external:URL} modified referrerOrigin
687
- */
688
- /**
689
- * @see {@link https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer|Referrer Policy §8.3. Determine request's Referrer}
690
- * @param {Request} request
691
- * @param {object} o
692
- * @param {module:utils/referrer~referrerURLCallback} o.referrerURLCallback
693
- * @param {module:utils/referrer~referrerOriginCallback} o.referrerOriginCallback
694
- * @returns {external:URL} Request's referrer
695
- */
696
- function determineRequestsReferrer(request, { referrerURLCallback, referrerOriginCallback } = {}) {
697
- if (request.referrer === "no-referrer" || request.referrerPolicy === "") return null;
698
- const policy = request.referrerPolicy;
699
- if (request.referrer === "about:client") return "no-referrer";
700
- const referrerSource = request.referrer;
701
- let referrerURL = stripURLForUseAsAReferrer(referrerSource);
702
- let referrerOrigin = stripURLForUseAsAReferrer(referrerSource, true);
703
- if (referrerURL.toString().length > 4096) referrerURL = referrerOrigin;
704
- if (referrerURLCallback) referrerURL = referrerURLCallback(referrerURL);
705
- if (referrerOriginCallback) referrerOrigin = referrerOriginCallback(referrerOrigin);
706
- const currentURL = new URL(request.url);
707
- switch (policy) {
708
- case "no-referrer": return "no-referrer";
709
- case "origin": return referrerOrigin;
710
- case "unsafe-url": return referrerURL;
711
- case "strict-origin":
712
- if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) return "no-referrer";
713
- return referrerOrigin.toString();
714
- case "strict-origin-when-cross-origin":
715
- if (referrerURL.origin === currentURL.origin) return referrerURL;
716
- if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) return "no-referrer";
717
- return referrerOrigin;
718
- case "same-origin":
719
- if (referrerURL.origin === currentURL.origin) return referrerURL;
720
- return "no-referrer";
721
- case "origin-when-cross-origin":
722
- if (referrerURL.origin === currentURL.origin) return referrerURL;
723
- return referrerOrigin;
724
- case "no-referrer-when-downgrade":
725
- if (isUrlPotentiallyTrustworthy(referrerURL) && !isUrlPotentiallyTrustworthy(currentURL)) return "no-referrer";
726
- return referrerURL;
727
- default: throw new TypeError(`Invalid referrerPolicy: ${policy}`);
728
- }
729
- }
730
- /**
731
- * @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}
732
- * @param {Headers} headers Response headers
733
- * @returns {string} policy
734
- */
735
- function parseReferrerPolicyFromHeader(headers) {
736
- const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
737
- let policy = "";
738
- for (const token of policyTokens) if (token && ReferrerPolicy.has(token)) policy = token;
739
- return policy;
740
- }
741
- var ReferrerPolicy, DEFAULT_REFERRER_POLICY;
742
- var init_referrer = __esmMin((() => {
743
- ReferrerPolicy = new Set([
744
- "",
745
- "no-referrer",
746
- "no-referrer-when-downgrade",
747
- "same-origin",
748
- "origin",
749
- "strict-origin",
750
- "origin-when-cross-origin",
751
- "strict-origin-when-cross-origin",
752
- "unsafe-url"
753
- ]);
754
- DEFAULT_REFERRER_POLICY = "strict-origin-when-cross-origin";
755
- }));
756
- //#endregion
757
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/request.js
758
- /**
759
- * Request.js
760
- *
761
- * Request class contains server only options
762
- *
763
- * All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
764
- */
765
- var INTERNALS, isRequest, doBadDataWarn, Request, getNodeRequestOptions;
766
- var init_request = __esmMin((() => {
767
- init_headers();
768
- init_body();
769
- init_is();
770
- init_get_search();
771
- init_referrer();
772
- INTERNALS = Symbol("Request internals");
773
- isRequest = (object) => {
774
- return typeof object === "object" && typeof object[INTERNALS] === "object";
775
- };
776
- doBadDataWarn = deprecate(() => {}, ".data is not a valid RequestInit property, use .body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (request)");
777
- Request = class Request extends Body {
778
- constructor(input, init = {}) {
779
- let parsedURL;
780
- if (isRequest(input)) parsedURL = new URL(input.url);
781
- else {
782
- parsedURL = new URL(input);
783
- input = {};
784
- }
785
- if (parsedURL.username !== "" || parsedURL.password !== "") throw new TypeError(`${parsedURL} is an url with embedded credentials.`);
786
- let method = init.method || input.method || "GET";
787
- if (/^(delete|get|head|options|post|put)$/i.test(method)) method = method.toUpperCase();
788
- if (!isRequest(init) && "data" in init) doBadDataWarn();
789
- if ((init.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) throw new TypeError("Request with GET/HEAD method cannot have body");
790
- const inputBody = init.body ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
791
- super(inputBody, { size: init.size || input.size || 0 });
792
- const headers = new Headers(init.headers || input.headers || {});
793
- if (inputBody !== null && !headers.has("Content-Type")) {
794
- const contentType = extractContentType(inputBody, this);
795
- if (contentType) headers.set("Content-Type", contentType);
796
- }
797
- let signal = isRequest(input) ? input.signal : null;
798
- if ("signal" in init) signal = init.signal;
799
- if (signal != null && !isAbortSignal(signal)) throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");
800
- let referrer = init.referrer == null ? input.referrer : init.referrer;
801
- if (referrer === "") referrer = "no-referrer";
802
- else if (referrer) {
803
- const parsedReferrer = new URL(referrer);
804
- referrer = /^about:(\/\/)?client$/.test(parsedReferrer) ? "client" : parsedReferrer;
805
- } else referrer = void 0;
806
- this[INTERNALS] = {
807
- method,
808
- redirect: init.redirect || input.redirect || "follow",
809
- headers,
810
- parsedURL,
811
- signal,
812
- referrer
813
- };
814
- this.follow = init.follow === void 0 ? input.follow === void 0 ? 20 : input.follow : init.follow;
815
- this.compress = init.compress === void 0 ? input.compress === void 0 ? true : input.compress : init.compress;
816
- this.counter = init.counter || input.counter || 0;
817
- this.agent = init.agent || input.agent;
818
- this.highWaterMark = init.highWaterMark || input.highWaterMark || 16384;
819
- this.insecureHTTPParser = init.insecureHTTPParser || input.insecureHTTPParser || false;
820
- this.referrerPolicy = init.referrerPolicy || input.referrerPolicy || "";
821
- }
822
- /** @returns {string} */
823
- get method() {
824
- return this[INTERNALS].method;
825
- }
826
- /** @returns {string} */
827
- get url() {
828
- return format(this[INTERNALS].parsedURL);
829
- }
830
- /** @returns {Headers} */
831
- get headers() {
832
- return this[INTERNALS].headers;
833
- }
834
- get redirect() {
835
- return this[INTERNALS].redirect;
836
- }
837
- /** @returns {AbortSignal} */
838
- get signal() {
839
- return this[INTERNALS].signal;
840
- }
841
- get referrer() {
842
- if (this[INTERNALS].referrer === "no-referrer") return "";
843
- if (this[INTERNALS].referrer === "client") return "about:client";
844
- if (this[INTERNALS].referrer) return this[INTERNALS].referrer.toString();
845
- }
846
- get referrerPolicy() {
847
- return this[INTERNALS].referrerPolicy;
848
- }
849
- set referrerPolicy(referrerPolicy) {
850
- this[INTERNALS].referrerPolicy = validateReferrerPolicy(referrerPolicy);
851
- }
852
- /**
853
- * Clone this request
854
- *
855
- * @return Request
856
- */
857
- clone() {
858
- return new Request(this);
859
- }
860
- get [Symbol.toStringTag]() {
861
- return "Request";
862
- }
863
- };
864
- Object.defineProperties(Request.prototype, {
865
- method: { enumerable: true },
866
- url: { enumerable: true },
867
- headers: { enumerable: true },
868
- redirect: { enumerable: true },
869
- clone: { enumerable: true },
870
- signal: { enumerable: true },
871
- referrer: { enumerable: true },
872
- referrerPolicy: { enumerable: true }
873
- });
874
- getNodeRequestOptions = (request) => {
875
- const { parsedURL } = request[INTERNALS];
876
- const headers = new Headers(request[INTERNALS].headers);
877
- if (!headers.has("Accept")) headers.set("Accept", "*/*");
878
- let contentLengthValue = null;
879
- if (request.body === null && /^(post|put)$/i.test(request.method)) contentLengthValue = "0";
880
- if (request.body !== null) {
881
- const totalBytes = getTotalBytes(request);
882
- if (typeof totalBytes === "number" && !Number.isNaN(totalBytes)) contentLengthValue = String(totalBytes);
883
- }
884
- if (contentLengthValue) headers.set("Content-Length", contentLengthValue);
885
- if (request.referrerPolicy === "") request.referrerPolicy = DEFAULT_REFERRER_POLICY;
886
- if (request.referrer && request.referrer !== "no-referrer") request[INTERNALS].referrer = determineRequestsReferrer(request);
887
- else request[INTERNALS].referrer = "no-referrer";
888
- if (request[INTERNALS].referrer instanceof URL) headers.set("Referer", request.referrer);
889
- if (!headers.has("User-Agent")) headers.set("User-Agent", "node-fetch");
890
- if (request.compress && !headers.has("Accept-Encoding")) headers.set("Accept-Encoding", "gzip, deflate, br");
891
- let { agent } = request;
892
- if (typeof agent === "function") agent = agent(parsedURL);
893
- const search = getSearch(parsedURL);
894
- return {
895
- /** @type {URL} */
896
- parsedURL,
897
- options: {
898
- path: parsedURL.pathname + search,
899
- method: request.method,
900
- headers: headers[Symbol.for("nodejs.util.inspect.custom")](),
901
- insecureHTTPParser: request.insecureHTTPParser,
902
- agent
903
- }
904
- };
905
- };
906
- }));
907
- //#endregion
908
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/errors/abort-error.js
909
- var AbortError;
910
- var init_abort_error = __esmMin((() => {
911
- init_base();
912
- AbortError = class extends FetchBaseError {
913
- constructor(message, type = "aborted") {
914
- super(message, type);
915
- }
916
- };
917
- }));
918
- //#endregion
919
- //#region node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
920
- /**
921
- * Index.js
922
- *
923
- * a request API compatible with window.fetch
924
- *
925
- * All spec algorithm step numbers are based on https://fetch.spec.whatwg.org/commit-snapshots/ae716822cb3a61843226cd090eefc6589446c1d2/.
926
- */
927
- /**
928
- * Fetch function
929
- *
930
- * @param {string | URL | import('./request').default} url - Absolute url or Request instance
931
- * @param {*} [options_] - Fetch options
932
- * @return {Promise<import('./response').default>}
933
- */
934
- async function fetch(url, options_) {
935
- return new Promise((resolve, reject) => {
936
- const request = new Request(url, options_);
937
- const { parsedURL, options } = getNodeRequestOptions(request);
938
- if (!supportedSchemas.has(parsedURL.protocol)) throw new TypeError(`node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`);
939
- if (parsedURL.protocol === "data:") {
940
- const data = dataUriToBuffer(request.url);
941
- resolve(new Response(data, { headers: { "Content-Type": data.typeFull } }));
942
- return;
943
- }
944
- const send = (parsedURL.protocol === "https:" ? https : http).request;
945
- const { signal } = request;
946
- let response = null;
947
- const abort = () => {
948
- const error = new AbortError("The operation was aborted.");
949
- reject(error);
950
- if (request.body && request.body instanceof Pe.Readable) request.body.destroy(error);
951
- if (!response || !response.body) return;
952
- response.body.emit("error", error);
953
- };
954
- if (signal && signal.aborted) {
955
- abort();
956
- return;
957
- }
958
- const abortAndFinalize = () => {
959
- abort();
960
- finalize();
961
- };
962
- const request_ = send(parsedURL.toString(), options);
963
- if (signal) signal.addEventListener("abort", abortAndFinalize);
964
- const finalize = () => {
965
- request_.abort();
966
- if (signal) signal.removeEventListener("abort", abortAndFinalize);
967
- };
968
- request_.on("error", (error) => {
969
- reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, "system", error));
970
- finalize();
971
- });
972
- fixResponseChunkedTransferBadEnding(request_, (error) => {
973
- if (response && response.body) response.body.destroy(error);
974
- });
975
- /* c8 ignore next 18 */
976
- if (process.version < "v14") request_.on("socket", (s) => {
977
- let endedWithEventsCount;
978
- s.prependListener("end", () => {
979
- endedWithEventsCount = s._eventsCount;
980
- });
981
- s.prependListener("close", (hadError) => {
982
- if (response && endedWithEventsCount < s._eventsCount && !hadError) {
983
- const error = /* @__PURE__ */ new Error("Premature close");
984
- error.code = "ERR_STREAM_PREMATURE_CLOSE";
985
- response.body.emit("error", error);
986
- }
987
- });
988
- });
989
- request_.on("response", (response_) => {
990
- request_.setTimeout(0);
991
- const headers = fromRawHeaders(response_.rawHeaders);
992
- if (isRedirect(response_.statusCode)) {
993
- const location = headers.get("Location");
994
- let locationURL = null;
995
- try {
996
- locationURL = location === null ? null : new URL(location, request.url);
997
- } catch {
998
- if (request.redirect !== "manual") {
999
- reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, "invalid-redirect"));
1000
- finalize();
1001
- return;
1002
- }
1003
- }
1004
- switch (request.redirect) {
1005
- case "error":
1006
- reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, "no-redirect"));
1007
- finalize();
1008
- return;
1009
- case "manual": break;
1010
- case "follow": {
1011
- if (locationURL === null) break;
1012
- if (request.counter >= request.follow) {
1013
- reject(new FetchError(`maximum redirect reached at: ${request.url}`, "max-redirect"));
1014
- finalize();
1015
- return;
1016
- }
1017
- const requestOptions = {
1018
- headers: new Headers(request.headers),
1019
- follow: request.follow,
1020
- counter: request.counter + 1,
1021
- agent: request.agent,
1022
- compress: request.compress,
1023
- method: request.method,
1024
- body: clone(request),
1025
- signal: request.signal,
1026
- size: request.size,
1027
- referrer: request.referrer,
1028
- referrerPolicy: request.referrerPolicy
1029
- };
1030
- if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) for (const name of [
1031
- "authorization",
1032
- "www-authenticate",
1033
- "cookie",
1034
- "cookie2"
1035
- ]) requestOptions.headers.delete(name);
1036
- if (response_.statusCode !== 303 && request.body && options_.body instanceof Pe.Readable) {
1037
- reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect"));
1038
- finalize();
1039
- return;
1040
- }
1041
- if (response_.statusCode === 303 || (response_.statusCode === 301 || response_.statusCode === 302) && request.method === "POST") {
1042
- requestOptions.method = "GET";
1043
- requestOptions.body = void 0;
1044
- requestOptions.headers.delete("content-length");
1045
- }
1046
- const responseReferrerPolicy = parseReferrerPolicyFromHeader(headers);
1047
- if (responseReferrerPolicy) requestOptions.referrerPolicy = responseReferrerPolicy;
1048
- resolve(fetch(new Request(locationURL, requestOptions)));
1049
- finalize();
1050
- return;
1051
- }
1052
- default: return reject(/* @__PURE__ */ new TypeError(`Redirect option '${request.redirect}' is not a valid value of RequestRedirect`));
1053
- }
1054
- }
1055
- if (signal) response_.once("end", () => {
1056
- signal.removeEventListener("abort", abortAndFinalize);
1057
- });
1058
- let body = pipeline(response_, new PassThrough(), (error) => {
1059
- if (error) reject(error);
1060
- });
1061
- /* c8 ignore next 3 */
1062
- if (process.version < "v12.10") response_.on("aborted", abortAndFinalize);
1063
- const responseOptions = {
1064
- url: request.url,
1065
- status: response_.statusCode,
1066
- statusText: response_.statusMessage,
1067
- headers,
1068
- size: request.size,
1069
- counter: request.counter,
1070
- highWaterMark: request.highWaterMark
1071
- };
1072
- const codings = headers.get("Content-Encoding");
1073
- if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
1074
- response = new Response(body, responseOptions);
1075
- resolve(response);
1076
- return;
1077
- }
1078
- const zlibOptions = {
1079
- flush: zlib.Z_SYNC_FLUSH,
1080
- finishFlush: zlib.Z_SYNC_FLUSH
1081
- };
1082
- if (codings === "gzip" || codings === "x-gzip") {
1083
- body = pipeline(body, zlib.createGunzip(zlibOptions), (error) => {
1084
- if (error) reject(error);
1085
- });
1086
- response = new Response(body, responseOptions);
1087
- resolve(response);
1088
- return;
1089
- }
1090
- if (codings === "deflate" || codings === "x-deflate") {
1091
- const raw = pipeline(response_, new PassThrough(), (error) => {
1092
- if (error) reject(error);
1093
- });
1094
- raw.once("data", (chunk) => {
1095
- if ((chunk[0] & 15) === 8) body = pipeline(body, zlib.createInflate(), (error) => {
1096
- if (error) reject(error);
1097
- });
1098
- else body = pipeline(body, zlib.createInflateRaw(), (error) => {
1099
- if (error) reject(error);
1100
- });
1101
- response = new Response(body, responseOptions);
1102
- resolve(response);
1103
- });
1104
- raw.once("end", () => {
1105
- if (!response) {
1106
- response = new Response(body, responseOptions);
1107
- resolve(response);
1108
- }
1109
- });
1110
- return;
1111
- }
1112
- if (codings === "br") {
1113
- body = pipeline(body, zlib.createBrotliDecompress(), (error) => {
1114
- if (error) reject(error);
1115
- });
1116
- response = new Response(body, responseOptions);
1117
- resolve(response);
1118
- return;
1119
- }
1120
- response = new Response(body, responseOptions);
1121
- resolve(response);
1122
- });
1123
- writeToStream(request_, request).catch(reject);
1124
- });
1125
- }
1126
- function fixResponseChunkedTransferBadEnding(request, errorCallback) {
1127
- const LAST_CHUNK = Buffer$1.from("0\r\n\r\n");
1128
- let isChunkedTransfer = false;
1129
- let properLastChunkReceived = false;
1130
- let previousChunk;
1131
- request.on("response", (response) => {
1132
- const { headers } = response;
1133
- isChunkedTransfer = headers["transfer-encoding"] === "chunked" && !headers["content-length"];
1134
- });
1135
- request.on("socket", (socket) => {
1136
- const onSocketClose = () => {
1137
- if (isChunkedTransfer && !properLastChunkReceived) {
1138
- const error = /* @__PURE__ */ new Error("Premature close");
1139
- error.code = "ERR_STREAM_PREMATURE_CLOSE";
1140
- errorCallback(error);
1141
- }
1142
- };
1143
- const onData = (buf) => {
1144
- properLastChunkReceived = Buffer$1.compare(buf.slice(-5), LAST_CHUNK) === 0;
1145
- 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;
1146
- previousChunk = buf;
1147
- };
1148
- socket.prependListener("close", onSocketClose);
1149
- socket.on("data", onData);
1150
- request.on("close", () => {
1151
- socket.removeListener("close", onSocketClose);
1152
- socket.removeListener("data", onData);
1153
- });
1154
- });
1155
- }
1156
- var supportedSchemas;
1157
- //#endregion
1158
- __esmMin((() => {
1159
- init_dist();
1160
- init_body();
1161
- init_response();
1162
- init_headers();
1163
- init_request();
1164
- init_fetch_error();
1165
- init_abort_error();
1166
- init_is_redirect();
1167
- init_esm_min();
1168
- init_is();
1169
- init_referrer();
1170
- init_from();
1171
- supportedSchemas = new Set([
1172
- "data:",
1173
- "http:",
1174
- "https:"
1175
- ]);
1176
- }))();
1177
- export { fetch as default };