importer-storage 1.0.11 → 1.0.13

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.
package/dist/index.cjs CHANGED
@@ -60,6 +60,7 @@ var import_fs = require("fs");
60
60
  var import_dotenv = require("dotenv");
61
61
  var import_axios = __toESM(require("axios"), 1);
62
62
  var import_jimp = require("jimp");
63
+ var import_https_proxy_agent = require("https-proxy-agent");
63
64
  (0, import_dotenv.config)();
64
65
  if (!process.env.AWS_ACCESS_KEY_ID) {
65
66
  throw new Error("'AWS_ACCESS_KEY_ID' not set");
@@ -93,6 +94,7 @@ var S3Storage = class {
93
94
  return __async(this, null, function* () {
94
95
  const result = [];
95
96
  const errored = [];
97
+ const proxyAgent = (options == null ? void 0 : options.proxyUrl) && new import_https_proxy_agent.HttpsProxyAgent(options == null ? void 0 : options.proxyUrl);
96
98
  for (const { key, filePath } of keys) {
97
99
  try {
98
100
  const s3Key = `${options.savePath}/${key}`;
@@ -105,7 +107,7 @@ var S3Storage = class {
105
107
  const axiosResponse = yield import_axios.default.get(filePath, {
106
108
  responseType: "arraybuffer",
107
109
  headers: options.headers,
108
- proxy: options.proxy
110
+ httpsAgent: proxyAgent
109
111
  });
110
112
  if (options.logging) {
111
113
  console.info(`[Success downloading] ${filePath}`);
package/dist/index.d.cts CHANGED
@@ -9,14 +9,7 @@ interface IStorage {
9
9
  savePath: string;
10
10
  headers?: Record<string, string>;
11
11
  logging?: boolean;
12
- proxy?: {
13
- host: string;
14
- port: number;
15
- auth: {
16
- username: string;
17
- password: string;
18
- };
19
- };
12
+ proxyUrl?: string;
20
13
  }): Promise<{
21
14
  errored: Array<{
22
15
  key: string;
@@ -41,14 +34,7 @@ declare class S3Storage implements IStorage {
41
34
  savePath: string;
42
35
  headers?: Record<string, string>;
43
36
  logging?: boolean;
44
- proxy: {
45
- host: string;
46
- port: number;
47
- auth: {
48
- username: string;
49
- password: string;
50
- };
51
- };
37
+ proxyUrl?: string;
52
38
  }): Promise<{
53
39
  result: {
54
40
  key: string;
package/dist/index.d.ts CHANGED
@@ -9,14 +9,7 @@ interface IStorage {
9
9
  savePath: string;
10
10
  headers?: Record<string, string>;
11
11
  logging?: boolean;
12
- proxy?: {
13
- host: string;
14
- port: number;
15
- auth: {
16
- username: string;
17
- password: string;
18
- };
19
- };
12
+ proxyUrl?: string;
20
13
  }): Promise<{
21
14
  errored: Array<{
22
15
  key: string;
@@ -41,14 +34,7 @@ declare class S3Storage implements IStorage {
41
34
  savePath: string;
42
35
  headers?: Record<string, string>;
43
36
  logging?: boolean;
44
- proxy: {
45
- host: string;
46
- port: number;
47
- auth: {
48
- username: string;
49
- password: string;
50
- };
51
- };
37
+ proxyUrl?: string;
52
38
  }): Promise<{
53
39
  result: {
54
40
  key: string;
@@ -9235,6 +9235,9 @@ ${toHex(hashedRequest)}`;
9235
9235
  "ap-east-1": {
9236
9236
  description: "Asia Pacific (Hong Kong)"
9237
9237
  },
9238
+ "ap-east-2": {
9239
+ description: "Asia Pacific (Taipei)"
9240
+ },
9238
9241
  "ap-northeast-1": {
9239
9242
  description: "Asia Pacific (Tokyo)"
9240
9243
  },
@@ -12507,7 +12510,7 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
12507
12510
  "node_modules/@aws-sdk/nested-clients/package.json"() {
12508
12511
  package_default2 = {
12509
12512
  name: "@aws-sdk/nested-clients",
12510
- version: "3.826.0",
12513
+ version: "3.828.0",
12511
12514
  description: "Nested clients for AWS SDK packages.",
12512
12515
  main: "./dist-cjs/index.js",
12513
12516
  module: "./dist-es/index.js",
@@ -12539,12 +12542,12 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
12539
12542
  "@aws-sdk/middleware-host-header": "3.821.0",
12540
12543
  "@aws-sdk/middleware-logger": "3.821.0",
12541
12544
  "@aws-sdk/middleware-recursion-detection": "3.821.0",
12542
- "@aws-sdk/middleware-user-agent": "3.826.0",
12545
+ "@aws-sdk/middleware-user-agent": "3.828.0",
12543
12546
  "@aws-sdk/region-config-resolver": "3.821.0",
12544
12547
  "@aws-sdk/types": "3.821.0",
12545
- "@aws-sdk/util-endpoints": "3.821.0",
12548
+ "@aws-sdk/util-endpoints": "3.828.0",
12546
12549
  "@aws-sdk/util-user-agent-browser": "3.821.0",
12547
- "@aws-sdk/util-user-agent-node": "3.826.0",
12550
+ "@aws-sdk/util-user-agent-node": "3.828.0",
12548
12551
  "@smithy/config-resolver": "^4.1.4",
12549
12552
  "@smithy/core": "^3.5.3",
12550
12553
  "@smithy/fetch-http-handler": "^5.0.4",
@@ -14068,7 +14071,7 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
14068
14071
  package_default3 = {
14069
14072
  name: "@aws-sdk/client-sso",
14070
14073
  description: "AWS SDK for JavaScript Sso Client for Node.js, Browser and React Native",
14071
- version: "3.826.0",
14074
+ version: "3.828.0",
14072
14075
  scripts: {
14073
14076
  build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
14074
14077
  "build:cjs": "node ../../scripts/compilation/inline client-sso",
@@ -14091,12 +14094,12 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
14091
14094
  "@aws-sdk/middleware-host-header": "3.821.0",
14092
14095
  "@aws-sdk/middleware-logger": "3.821.0",
14093
14096
  "@aws-sdk/middleware-recursion-detection": "3.821.0",
14094
- "@aws-sdk/middleware-user-agent": "3.826.0",
14097
+ "@aws-sdk/middleware-user-agent": "3.828.0",
14095
14098
  "@aws-sdk/region-config-resolver": "3.821.0",
14096
14099
  "@aws-sdk/types": "3.821.0",
14097
- "@aws-sdk/util-endpoints": "3.821.0",
14100
+ "@aws-sdk/util-endpoints": "3.828.0",
14098
14101
  "@aws-sdk/util-user-agent-browser": "3.821.0",
14099
- "@aws-sdk/util-user-agent-node": "3.826.0",
14102
+ "@aws-sdk/util-user-agent-node": "3.828.0",
14100
14103
  "@smithy/config-resolver": "^4.1.4",
14101
14104
  "@smithy/core": "^3.5.3",
14102
14105
  "@smithy/fetch-http-handler": "^5.0.4",
@@ -55741,6 +55744,496 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
55741
55744
  }
55742
55745
  });
55743
55746
 
55747
+ // node_modules/agent-base/dist/helpers.js
55748
+ var require_helpers = __commonJS({
55749
+ "node_modules/agent-base/dist/helpers.js"(exports2) {
55750
+ "use strict";
55751
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o5, m5, k5, k22) {
55752
+ if (k22 === void 0) k22 = k5;
55753
+ var desc = Object.getOwnPropertyDescriptor(m5, k5);
55754
+ if (!desc || ("get" in desc ? !m5.__esModule : desc.writable || desc.configurable)) {
55755
+ desc = { enumerable: true, get: function() {
55756
+ return m5[k5];
55757
+ } };
55758
+ }
55759
+ Object.defineProperty(o5, k22, desc);
55760
+ } : function(o5, m5, k5, k22) {
55761
+ if (k22 === void 0) k22 = k5;
55762
+ o5[k22] = m5[k5];
55763
+ });
55764
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o5, v6) {
55765
+ Object.defineProperty(o5, "default", { enumerable: true, value: v6 });
55766
+ } : function(o5, v6) {
55767
+ o5["default"] = v6;
55768
+ });
55769
+ var __importStar = exports2 && exports2.__importStar || function(mod) {
55770
+ if (mod && mod.__esModule) return mod;
55771
+ var result = {};
55772
+ if (mod != null) {
55773
+ for (var k5 in mod) if (k5 !== "default" && Object.prototype.hasOwnProperty.call(mod, k5)) __createBinding(result, mod, k5);
55774
+ }
55775
+ __setModuleDefault(result, mod);
55776
+ return result;
55777
+ };
55778
+ Object.defineProperty(exports2, "__esModule", { value: true });
55779
+ exports2.req = exports2.json = exports2.toBuffer = void 0;
55780
+ var http2 = __importStar(__require("http"));
55781
+ var https2 = __importStar(__require("https"));
55782
+ function toBuffer(stream5) {
55783
+ return __async(this, null, function* () {
55784
+ let length = 0;
55785
+ const chunks = [];
55786
+ try {
55787
+ for (var iter = __forAwait(stream5), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
55788
+ const chunk = temp.value;
55789
+ length += chunk.length;
55790
+ chunks.push(chunk);
55791
+ }
55792
+ } catch (temp) {
55793
+ error = [temp];
55794
+ } finally {
55795
+ try {
55796
+ more && (temp = iter.return) && (yield temp.call(iter));
55797
+ } finally {
55798
+ if (error)
55799
+ throw error[0];
55800
+ }
55801
+ }
55802
+ return Buffer.concat(chunks, length);
55803
+ });
55804
+ }
55805
+ exports2.toBuffer = toBuffer;
55806
+ function json(stream5) {
55807
+ return __async(this, null, function* () {
55808
+ const buf = yield toBuffer(stream5);
55809
+ const str = buf.toString("utf8");
55810
+ try {
55811
+ return JSON.parse(str);
55812
+ } catch (_err) {
55813
+ const err = _err;
55814
+ err.message += ` (input: ${str})`;
55815
+ throw err;
55816
+ }
55817
+ });
55818
+ }
55819
+ exports2.json = json;
55820
+ function req(url2, opts = {}) {
55821
+ const href = typeof url2 === "string" ? url2 : url2.href;
55822
+ const req2 = (href.startsWith("https:") ? https2 : http2).request(url2, opts);
55823
+ const promise = new Promise((resolve2, reject2) => {
55824
+ req2.once("response", resolve2).once("error", reject2).end();
55825
+ });
55826
+ req2.then = promise.then.bind(promise);
55827
+ return req2;
55828
+ }
55829
+ exports2.req = req;
55830
+ }
55831
+ });
55832
+
55833
+ // node_modules/agent-base/dist/index.js
55834
+ var require_dist = __commonJS({
55835
+ "node_modules/agent-base/dist/index.js"(exports2) {
55836
+ "use strict";
55837
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o5, m5, k5, k22) {
55838
+ if (k22 === void 0) k22 = k5;
55839
+ var desc = Object.getOwnPropertyDescriptor(m5, k5);
55840
+ if (!desc || ("get" in desc ? !m5.__esModule : desc.writable || desc.configurable)) {
55841
+ desc = { enumerable: true, get: function() {
55842
+ return m5[k5];
55843
+ } };
55844
+ }
55845
+ Object.defineProperty(o5, k22, desc);
55846
+ } : function(o5, m5, k5, k22) {
55847
+ if (k22 === void 0) k22 = k5;
55848
+ o5[k22] = m5[k5];
55849
+ });
55850
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o5, v6) {
55851
+ Object.defineProperty(o5, "default", { enumerable: true, value: v6 });
55852
+ } : function(o5, v6) {
55853
+ o5["default"] = v6;
55854
+ });
55855
+ var __importStar = exports2 && exports2.__importStar || function(mod) {
55856
+ if (mod && mod.__esModule) return mod;
55857
+ var result = {};
55858
+ if (mod != null) {
55859
+ for (var k5 in mod) if (k5 !== "default" && Object.prototype.hasOwnProperty.call(mod, k5)) __createBinding(result, mod, k5);
55860
+ }
55861
+ __setModuleDefault(result, mod);
55862
+ return result;
55863
+ };
55864
+ var __exportStar = exports2 && exports2.__exportStar || function(m5, exports3) {
55865
+ for (var p5 in m5) if (p5 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p5)) __createBinding(exports3, m5, p5);
55866
+ };
55867
+ Object.defineProperty(exports2, "__esModule", { value: true });
55868
+ exports2.Agent = void 0;
55869
+ var net = __importStar(__require("net"));
55870
+ var http2 = __importStar(__require("http"));
55871
+ var https_1 = __require("https");
55872
+ __exportStar(require_helpers(), exports2);
55873
+ var INTERNAL = Symbol("AgentBaseInternalState");
55874
+ var Agent = class extends http2.Agent {
55875
+ constructor(opts) {
55876
+ super(opts);
55877
+ this[INTERNAL] = {};
55878
+ }
55879
+ /**
55880
+ * Determine whether this is an `http` or `https` request.
55881
+ */
55882
+ isSecureEndpoint(options) {
55883
+ if (options) {
55884
+ if (typeof options.secureEndpoint === "boolean") {
55885
+ return options.secureEndpoint;
55886
+ }
55887
+ if (typeof options.protocol === "string") {
55888
+ return options.protocol === "https:";
55889
+ }
55890
+ }
55891
+ const { stack } = new Error();
55892
+ if (typeof stack !== "string")
55893
+ return false;
55894
+ return stack.split("\n").some((l5) => l5.indexOf("(https.js:") !== -1 || l5.indexOf("node:https:") !== -1);
55895
+ }
55896
+ // In order to support async signatures in `connect()` and Node's native
55897
+ // connection pooling in `http.Agent`, the array of sockets for each origin
55898
+ // has to be updated synchronously. This is so the length of the array is
55899
+ // accurate when `addRequest()` is next called. We achieve this by creating a
55900
+ // fake socket and adding it to `sockets[origin]` and incrementing
55901
+ // `totalSocketCount`.
55902
+ incrementSockets(name) {
55903
+ if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) {
55904
+ return null;
55905
+ }
55906
+ if (!this.sockets[name]) {
55907
+ this.sockets[name] = [];
55908
+ }
55909
+ const fakeSocket = new net.Socket({ writable: false });
55910
+ this.sockets[name].push(fakeSocket);
55911
+ this.totalSocketCount++;
55912
+ return fakeSocket;
55913
+ }
55914
+ decrementSockets(name, socket) {
55915
+ if (!this.sockets[name] || socket === null) {
55916
+ return;
55917
+ }
55918
+ const sockets = this.sockets[name];
55919
+ const index = sockets.indexOf(socket);
55920
+ if (index !== -1) {
55921
+ sockets.splice(index, 1);
55922
+ this.totalSocketCount--;
55923
+ if (sockets.length === 0) {
55924
+ delete this.sockets[name];
55925
+ }
55926
+ }
55927
+ }
55928
+ // In order to properly update the socket pool, we need to call `getName()` on
55929
+ // the core `https.Agent` if it is a secureEndpoint.
55930
+ getName(options) {
55931
+ const secureEndpoint = typeof options.secureEndpoint === "boolean" ? options.secureEndpoint : this.isSecureEndpoint(options);
55932
+ if (secureEndpoint) {
55933
+ return https_1.Agent.prototype.getName.call(this, options);
55934
+ }
55935
+ return super.getName(options);
55936
+ }
55937
+ createSocket(req, options, cb2) {
55938
+ const connectOpts = __spreadProps(__spreadValues({}, options), {
55939
+ secureEndpoint: this.isSecureEndpoint(options)
55940
+ });
55941
+ const name = this.getName(connectOpts);
55942
+ const fakeSocket = this.incrementSockets(name);
55943
+ Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => {
55944
+ this.decrementSockets(name, fakeSocket);
55945
+ if (socket instanceof http2.Agent) {
55946
+ try {
55947
+ return socket.addRequest(req, connectOpts);
55948
+ } catch (err) {
55949
+ return cb2(err);
55950
+ }
55951
+ }
55952
+ this[INTERNAL].currentSocket = socket;
55953
+ super.createSocket(req, options, cb2);
55954
+ }, (err) => {
55955
+ this.decrementSockets(name, fakeSocket);
55956
+ cb2(err);
55957
+ });
55958
+ }
55959
+ createConnection() {
55960
+ const socket = this[INTERNAL].currentSocket;
55961
+ this[INTERNAL].currentSocket = void 0;
55962
+ if (!socket) {
55963
+ throw new Error("No socket was returned in the `connect()` function");
55964
+ }
55965
+ return socket;
55966
+ }
55967
+ get defaultPort() {
55968
+ var _a2;
55969
+ return (_a2 = this[INTERNAL].defaultPort) != null ? _a2 : this.protocol === "https:" ? 443 : 80;
55970
+ }
55971
+ set defaultPort(v6) {
55972
+ if (this[INTERNAL]) {
55973
+ this[INTERNAL].defaultPort = v6;
55974
+ }
55975
+ }
55976
+ get protocol() {
55977
+ var _a2;
55978
+ return (_a2 = this[INTERNAL].protocol) != null ? _a2 : this.isSecureEndpoint() ? "https:" : "http:";
55979
+ }
55980
+ set protocol(v6) {
55981
+ if (this[INTERNAL]) {
55982
+ this[INTERNAL].protocol = v6;
55983
+ }
55984
+ }
55985
+ };
55986
+ exports2.Agent = Agent;
55987
+ }
55988
+ });
55989
+
55990
+ // node_modules/https-proxy-agent/dist/parse-proxy-response.js
55991
+ var require_parse_proxy_response = __commonJS({
55992
+ "node_modules/https-proxy-agent/dist/parse-proxy-response.js"(exports2) {
55993
+ "use strict";
55994
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
55995
+ return mod && mod.__esModule ? mod : { "default": mod };
55996
+ };
55997
+ Object.defineProperty(exports2, "__esModule", { value: true });
55998
+ exports2.parseProxyResponse = void 0;
55999
+ var debug_1 = __importDefault(require_src());
56000
+ var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
56001
+ function parseProxyResponse(socket) {
56002
+ return new Promise((resolve2, reject2) => {
56003
+ let buffersLength = 0;
56004
+ const buffers = [];
56005
+ function read() {
56006
+ const b5 = socket.read();
56007
+ if (b5)
56008
+ ondata(b5);
56009
+ else
56010
+ socket.once("readable", read);
56011
+ }
56012
+ function cleanup() {
56013
+ socket.removeListener("end", onend);
56014
+ socket.removeListener("error", onerror);
56015
+ socket.removeListener("readable", read);
56016
+ }
56017
+ function onend() {
56018
+ cleanup();
56019
+ debug("onend");
56020
+ reject2(new Error("Proxy connection ended before receiving CONNECT response"));
56021
+ }
56022
+ function onerror(err) {
56023
+ cleanup();
56024
+ debug("onerror %o", err);
56025
+ reject2(err);
56026
+ }
56027
+ function ondata(b5) {
56028
+ buffers.push(b5);
56029
+ buffersLength += b5.length;
56030
+ const buffered = Buffer.concat(buffers, buffersLength);
56031
+ const endOfHeaders = buffered.indexOf("\r\n\r\n");
56032
+ if (endOfHeaders === -1) {
56033
+ debug("have not received end of HTTP headers yet...");
56034
+ read();
56035
+ return;
56036
+ }
56037
+ const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split("\r\n");
56038
+ const firstLine = headerParts.shift();
56039
+ if (!firstLine) {
56040
+ socket.destroy();
56041
+ return reject2(new Error("No header received from proxy CONNECT response"));
56042
+ }
56043
+ const firstLineParts = firstLine.split(" ");
56044
+ const statusCode = +firstLineParts[1];
56045
+ const statusText = firstLineParts.slice(2).join(" ");
56046
+ const headers = {};
56047
+ for (const header of headerParts) {
56048
+ if (!header)
56049
+ continue;
56050
+ const firstColon = header.indexOf(":");
56051
+ if (firstColon === -1) {
56052
+ socket.destroy();
56053
+ return reject2(new Error(`Invalid header from proxy CONNECT response: "${header}"`));
56054
+ }
56055
+ const key = header.slice(0, firstColon).toLowerCase();
56056
+ const value = header.slice(firstColon + 1).trimStart();
56057
+ const current = headers[key];
56058
+ if (typeof current === "string") {
56059
+ headers[key] = [current, value];
56060
+ } else if (Array.isArray(current)) {
56061
+ current.push(value);
56062
+ } else {
56063
+ headers[key] = value;
56064
+ }
56065
+ }
56066
+ debug("got proxy server response: %o %o", firstLine, headers);
56067
+ cleanup();
56068
+ resolve2({
56069
+ connect: {
56070
+ statusCode,
56071
+ statusText,
56072
+ headers
56073
+ },
56074
+ buffered
56075
+ });
56076
+ }
56077
+ socket.on("error", onerror);
56078
+ socket.on("end", onend);
56079
+ read();
56080
+ });
56081
+ }
56082
+ exports2.parseProxyResponse = parseProxyResponse;
56083
+ }
56084
+ });
56085
+
56086
+ // node_modules/https-proxy-agent/dist/index.js
56087
+ var require_dist2 = __commonJS({
56088
+ "node_modules/https-proxy-agent/dist/index.js"(exports2) {
56089
+ "use strict";
56090
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o5, m5, k5, k22) {
56091
+ if (k22 === void 0) k22 = k5;
56092
+ var desc = Object.getOwnPropertyDescriptor(m5, k5);
56093
+ if (!desc || ("get" in desc ? !m5.__esModule : desc.writable || desc.configurable)) {
56094
+ desc = { enumerable: true, get: function() {
56095
+ return m5[k5];
56096
+ } };
56097
+ }
56098
+ Object.defineProperty(o5, k22, desc);
56099
+ } : function(o5, m5, k5, k22) {
56100
+ if (k22 === void 0) k22 = k5;
56101
+ o5[k22] = m5[k5];
56102
+ });
56103
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o5, v6) {
56104
+ Object.defineProperty(o5, "default", { enumerable: true, value: v6 });
56105
+ } : function(o5, v6) {
56106
+ o5["default"] = v6;
56107
+ });
56108
+ var __importStar = exports2 && exports2.__importStar || function(mod) {
56109
+ if (mod && mod.__esModule) return mod;
56110
+ var result = {};
56111
+ if (mod != null) {
56112
+ for (var k5 in mod) if (k5 !== "default" && Object.prototype.hasOwnProperty.call(mod, k5)) __createBinding(result, mod, k5);
56113
+ }
56114
+ __setModuleDefault(result, mod);
56115
+ return result;
56116
+ };
56117
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
56118
+ return mod && mod.__esModule ? mod : { "default": mod };
56119
+ };
56120
+ Object.defineProperty(exports2, "__esModule", { value: true });
56121
+ exports2.HttpsProxyAgent = void 0;
56122
+ var net = __importStar(__require("net"));
56123
+ var tls = __importStar(__require("tls"));
56124
+ var assert_1 = __importDefault(__require("assert"));
56125
+ var debug_1 = __importDefault(require_src());
56126
+ var agent_base_1 = require_dist();
56127
+ var url_1 = __require("url");
56128
+ var parse_proxy_response_1 = require_parse_proxy_response();
56129
+ var debug = (0, debug_1.default)("https-proxy-agent");
56130
+ var setServernameFromNonIpHost = (options) => {
56131
+ if (options.servername === void 0 && options.host && !net.isIP(options.host)) {
56132
+ return __spreadProps(__spreadValues({}, options), {
56133
+ servername: options.host
56134
+ });
56135
+ }
56136
+ return options;
56137
+ };
56138
+ var HttpsProxyAgent2 = class extends agent_base_1.Agent {
56139
+ constructor(proxy, opts) {
56140
+ var _a2;
56141
+ super(opts);
56142
+ this.options = { path: void 0 };
56143
+ this.proxy = typeof proxy === "string" ? new url_1.URL(proxy) : proxy;
56144
+ this.proxyHeaders = (_a2 = opts == null ? void 0 : opts.headers) != null ? _a2 : {};
56145
+ debug("Creating new HttpsProxyAgent instance: %o", this.proxy.href);
56146
+ const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, "");
56147
+ const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80;
56148
+ this.connectOpts = __spreadProps(__spreadValues({
56149
+ // Attempt to negotiate http/1.1 for proxy servers that support http/2
56150
+ ALPNProtocols: ["http/1.1"]
56151
+ }, opts ? omit(opts, "headers") : null), {
56152
+ host,
56153
+ port
56154
+ });
56155
+ }
56156
+ /**
56157
+ * Called when the node-core HTTP client library is creating a
56158
+ * new HTTP request.
56159
+ */
56160
+ connect(req, opts) {
56161
+ return __async(this, null, function* () {
56162
+ const { proxy } = this;
56163
+ if (!opts.host) {
56164
+ throw new TypeError('No "host" provided');
56165
+ }
56166
+ let socket;
56167
+ if (proxy.protocol === "https:") {
56168
+ debug("Creating `tls.Socket`: %o", this.connectOpts);
56169
+ socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
56170
+ } else {
56171
+ debug("Creating `net.Socket`: %o", this.connectOpts);
56172
+ socket = net.connect(this.connectOpts);
56173
+ }
56174
+ const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : __spreadValues({}, this.proxyHeaders);
56175
+ const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
56176
+ let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
56177
+ `;
56178
+ if (proxy.username || proxy.password) {
56179
+ const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
56180
+ headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`;
56181
+ }
56182
+ headers.Host = `${host}:${opts.port}`;
56183
+ if (!headers["Proxy-Connection"]) {
56184
+ headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close";
56185
+ }
56186
+ for (const name of Object.keys(headers)) {
56187
+ payload += `${name}: ${headers[name]}\r
56188
+ `;
56189
+ }
56190
+ const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket);
56191
+ socket.write(`${payload}\r
56192
+ `);
56193
+ const { connect, buffered } = yield proxyResponsePromise;
56194
+ req.emit("proxyConnect", connect);
56195
+ this.emit("proxyConnect", connect, req);
56196
+ if (connect.statusCode === 200) {
56197
+ req.once("socket", resume);
56198
+ if (opts.secureEndpoint) {
56199
+ debug("Upgrading socket connection to TLS");
56200
+ return tls.connect(__spreadProps(__spreadValues({}, omit(setServernameFromNonIpHost(opts), "host", "path", "port")), {
56201
+ socket
56202
+ }));
56203
+ }
56204
+ return socket;
56205
+ }
56206
+ socket.destroy();
56207
+ const fakeSocket = new net.Socket({ writable: false });
56208
+ fakeSocket.readable = true;
56209
+ req.once("socket", (s5) => {
56210
+ debug("Replaying proxy buffer for failed request");
56211
+ (0, assert_1.default)(s5.listenerCount("data") > 0);
56212
+ s5.push(buffered);
56213
+ s5.push(null);
56214
+ });
56215
+ return fakeSocket;
56216
+ });
56217
+ }
56218
+ };
56219
+ HttpsProxyAgent2.protocols = ["http", "https"];
56220
+ exports2.HttpsProxyAgent = HttpsProxyAgent2;
56221
+ function resume(socket) {
56222
+ socket.resume();
56223
+ }
56224
+ function omit(obj, ...keys) {
56225
+ const ret = {};
56226
+ let key;
56227
+ for (key in obj) {
56228
+ if (!keys.includes(key)) {
56229
+ ret[key] = obj[key];
56230
+ }
56231
+ }
56232
+ return ret;
56233
+ }
56234
+ }
56235
+ });
56236
+
55744
56237
  // src/index.ts
55745
56238
  var index_exports = {};
55746
56239
  __export(index_exports, {
@@ -58986,7 +59479,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
58986
59479
  var package_default = {
58987
59480
  name: "@aws-sdk/client-s3",
58988
59481
  description: "AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native",
58989
- version: "3.826.0",
59482
+ version: "3.828.0",
58990
59483
  scripts: {
58991
59484
  build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
58992
59485
  "build:cjs": "node ../../scripts/compilation/inline client-s3",
@@ -59015,7 +59508,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
59015
59508
  "@aws-crypto/sha256-browser": "5.2.0",
59016
59509
  "@aws-crypto/sha256-js": "5.2.0",
59017
59510
  "@aws-sdk/core": "3.826.0",
59018
- "@aws-sdk/credential-provider-node": "3.826.0",
59511
+ "@aws-sdk/credential-provider-node": "3.828.0",
59019
59512
  "@aws-sdk/middleware-bucket-endpoint": "3.821.0",
59020
59513
  "@aws-sdk/middleware-expect-continue": "3.821.0",
59021
59514
  "@aws-sdk/middleware-flexible-checksums": "3.826.0",
@@ -59025,13 +59518,13 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
59025
59518
  "@aws-sdk/middleware-recursion-detection": "3.821.0",
59026
59519
  "@aws-sdk/middleware-sdk-s3": "3.826.0",
59027
59520
  "@aws-sdk/middleware-ssec": "3.821.0",
59028
- "@aws-sdk/middleware-user-agent": "3.826.0",
59521
+ "@aws-sdk/middleware-user-agent": "3.828.0",
59029
59522
  "@aws-sdk/region-config-resolver": "3.821.0",
59030
59523
  "@aws-sdk/signature-v4-multi-region": "3.826.0",
59031
59524
  "@aws-sdk/types": "3.821.0",
59032
- "@aws-sdk/util-endpoints": "3.821.0",
59525
+ "@aws-sdk/util-endpoints": "3.828.0",
59033
59526
  "@aws-sdk/util-user-agent-browser": "3.821.0",
59034
- "@aws-sdk/util-user-agent-node": "3.826.0",
59527
+ "@aws-sdk/util-user-agent-node": "3.828.0",
59035
59528
  "@aws-sdk/xml-builder": "3.821.0",
59036
59529
  "@smithy/config-resolver": "^4.1.4",
59037
59530
  "@smithy/core": "^3.5.3",
@@ -59069,7 +59562,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
59069
59562
  tslib: "^2.6.2"
59070
59563
  },
59071
59564
  devDependencies: {
59072
- "@aws-sdk/signature-v4-crt": "3.826.0",
59565
+ "@aws-sdk/signature-v4-crt": "3.828.0",
59073
59566
  "@tsconfig/node18": "18.2.4",
59074
59567
  "@types/node": "^18.19.69",
59075
59568
  concurrently: "7.0.0",
@@ -60716,6 +61209,9 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
60716
61209
  if (utils_default.isDate(value)) {
60717
61210
  return value.toISOString();
60718
61211
  }
61212
+ if (utils_default.isBoolean(value)) {
61213
+ return value.toString();
61214
+ }
60719
61215
  if (!useBlob && utils_default.isBlob(value)) {
60720
61216
  throw new AxiosError_default("Blob is not supported. Use a Buffer instead.");
60721
61217
  }
@@ -61496,7 +61992,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
61496
61992
  var import_zlib = __toESM(__require("zlib"), 1);
61497
61993
 
61498
61994
  // node_modules/axios/lib/env/data.js
61499
- var VERSION = "1.9.0";
61995
+ var VERSION = "1.10.0";
61500
61996
 
61501
61997
  // node_modules/axios/lib/helpers/parseProtocol.js
61502
61998
  function parseProtocol(url2) {
@@ -62935,7 +63431,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
62935
63431
  duplex: "half",
62936
63432
  credentials: isCredentialsSupported ? withCredentials : void 0
62937
63433
  }));
62938
- let response = yield fetch(request2);
63434
+ let response = yield fetch(request2, fetchOptions);
62939
63435
  const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
62940
63436
  if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
62941
63437
  const options = {};
@@ -76213,6 +76709,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
76213
76709
  });
76214
76710
 
76215
76711
  // src/logic/storage.ts
76712
+ var import_https_proxy_agent = __toESM(require_dist2(), 1);
76216
76713
  (0, import_dotenv.config)();
76217
76714
  if (!process.env.AWS_ACCESS_KEY_ID) {
76218
76715
  throw new Error("'AWS_ACCESS_KEY_ID' not set");
@@ -76246,6 +76743,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
76246
76743
  return __async(this, null, function* () {
76247
76744
  const result = [];
76248
76745
  const errored = [];
76746
+ const proxyAgent = (options == null ? void 0 : options.proxyUrl) && new import_https_proxy_agent.HttpsProxyAgent(options == null ? void 0 : options.proxyUrl);
76249
76747
  for (const { key, filePath } of keys) {
76250
76748
  try {
76251
76749
  const s3Key = `${options.savePath}/${key}`;
@@ -76258,7 +76756,7 @@ For more information please go to https://github.com/aws/aws-sdk-js-v3#functiona
76258
76756
  const axiosResponse = yield axios_default.get(filePath, {
76259
76757
  responseType: "arraybuffer",
76260
76758
  headers: options.headers,
76261
- proxy: options.proxy
76759
+ httpsAgent: proxyAgent
76262
76760
  });
76263
76761
  if (options.logging) {
76264
76762
  console.info(`[Success downloading] ${filePath}`);
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ import { createReadStream } from "fs";
31
31
  import { config } from "dotenv";
32
32
  import axios from "axios";
33
33
  import { Jimp } from "jimp";
34
+ import { HttpsProxyAgent } from "https-proxy-agent";
34
35
  config();
35
36
  if (!process.env.AWS_ACCESS_KEY_ID) {
36
37
  throw new Error("'AWS_ACCESS_KEY_ID' not set");
@@ -64,6 +65,7 @@ var S3Storage = class {
64
65
  return __async(this, null, function* () {
65
66
  const result = [];
66
67
  const errored = [];
68
+ const proxyAgent = (options == null ? void 0 : options.proxyUrl) && new HttpsProxyAgent(options == null ? void 0 : options.proxyUrl);
67
69
  for (const { key, filePath } of keys) {
68
70
  try {
69
71
  const s3Key = `${options.savePath}/${key}`;
@@ -76,7 +78,7 @@ var S3Storage = class {
76
78
  const axiosResponse = yield axios.get(filePath, {
77
79
  responseType: "arraybuffer",
78
80
  headers: options.headers,
79
- proxy: options.proxy
81
+ httpsAgent: proxyAgent
80
82
  });
81
83
  if (options.logging) {
82
84
  console.info(`[Success downloading] ${filePath}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "importer-storage",
3
3
  "private": false,
4
- "version": "1.0.11",
4
+ "version": "1.0.13",
5
5
  "main": "dist/index.js",
6
6
  "files": [
7
7
  "dist",
@@ -22,6 +22,7 @@
22
22
  "axios": "^1.9.0",
23
23
  "dotenv": "^16.5.0",
24
24
  "globals": "^16.2.0",
25
+ "https-proxy-agent": "^7.0.6",
25
26
  "jimp": "^1.6.0"
26
27
  },
27
28
  "devDependencies": {