node-red-contrib-tak-registration 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +35 -0
  3. package/node_modules/adm-zip/LICENSE +21 -0
  4. package/node_modules/adm-zip/README.md +65 -0
  5. package/node_modules/adm-zip/adm-zip.js +783 -0
  6. package/node_modules/adm-zip/headers/entryHeader.js +338 -0
  7. package/node_modules/adm-zip/headers/index.js +2 -0
  8. package/node_modules/adm-zip/headers/mainHeader.js +129 -0
  9. package/node_modules/adm-zip/methods/deflater.js +33 -0
  10. package/node_modules/adm-zip/methods/index.js +3 -0
  11. package/node_modules/adm-zip/methods/inflater.js +31 -0
  12. package/node_modules/adm-zip/methods/zipcrypto.js +170 -0
  13. package/node_modules/adm-zip/package.json +77 -0
  14. package/node_modules/adm-zip/util/constants.js +142 -0
  15. package/node_modules/adm-zip/util/errors.js +35 -0
  16. package/node_modules/adm-zip/util/fattr.js +79 -0
  17. package/node_modules/adm-zip/util/fileSystem.js +11 -0
  18. package/node_modules/adm-zip/util/index.js +4 -0
  19. package/node_modules/adm-zip/util/utils.js +246 -0
  20. package/node_modules/adm-zip/zipEntry.js +333 -0
  21. package/node_modules/adm-zip/zipFile.js +384 -0
  22. package/node_modules/asynckit/LICENSE +21 -0
  23. package/node_modules/asynckit/README.md +233 -0
  24. package/node_modules/asynckit/bench.js +76 -0
  25. package/node_modules/asynckit/index.js +6 -0
  26. package/node_modules/asynckit/lib/abort.js +29 -0
  27. package/node_modules/asynckit/lib/async.js +34 -0
  28. package/node_modules/asynckit/lib/defer.js +26 -0
  29. package/node_modules/asynckit/lib/iterate.js +75 -0
  30. package/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  31. package/node_modules/asynckit/lib/readable_parallel.js +25 -0
  32. package/node_modules/asynckit/lib/readable_serial.js +25 -0
  33. package/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  34. package/node_modules/asynckit/lib/state.js +37 -0
  35. package/node_modules/asynckit/lib/streamify.js +141 -0
  36. package/node_modules/asynckit/lib/terminator.js +29 -0
  37. package/node_modules/asynckit/package.json +91 -0
  38. package/node_modules/asynckit/parallel.js +43 -0
  39. package/node_modules/asynckit/serial.js +17 -0
  40. package/node_modules/asynckit/serialOrdered.js +75 -0
  41. package/node_modules/asynckit/stream.js +21 -0
  42. package/node_modules/axios/CHANGELOG.md +836 -0
  43. package/node_modules/axios/LICENSE +19 -0
  44. package/node_modules/axios/README.md +892 -0
  45. package/node_modules/axios/SECURITY.md +5 -0
  46. package/node_modules/axios/UPGRADE_GUIDE.md +162 -0
  47. package/node_modules/axios/dist/axios.js +2275 -0
  48. package/node_modules/axios/dist/axios.map +1 -0
  49. package/node_modules/axios/dist/axios.min.js +2 -0
  50. package/node_modules/axios/dist/axios.min.map +1 -0
  51. package/node_modules/axios/index.d.ts +206 -0
  52. package/node_modules/axios/index.js +1 -0
  53. package/node_modules/axios/lib/adapters/README.md +37 -0
  54. package/node_modules/axios/lib/adapters/http.js +363 -0
  55. package/node_modules/axios/lib/adapters/xhr.js +212 -0
  56. package/node_modules/axios/lib/axios.js +57 -0
  57. package/node_modules/axios/lib/cancel/Cancel.js +19 -0
  58. package/node_modules/axios/lib/cancel/CancelToken.js +119 -0
  59. package/node_modules/axios/lib/cancel/isCancel.js +5 -0
  60. package/node_modules/axios/lib/core/Axios.js +148 -0
  61. package/node_modules/axios/lib/core/InterceptorManager.js +54 -0
  62. package/node_modules/axios/lib/core/README.md +8 -0
  63. package/node_modules/axios/lib/core/buildFullPath.js +20 -0
  64. package/node_modules/axios/lib/core/createError.js +18 -0
  65. package/node_modules/axios/lib/core/dispatchRequest.js +87 -0
  66. package/node_modules/axios/lib/core/enhanceError.js +43 -0
  67. package/node_modules/axios/lib/core/mergeConfig.js +99 -0
  68. package/node_modules/axios/lib/core/settle.js +25 -0
  69. package/node_modules/axios/lib/core/transformData.js +22 -0
  70. package/node_modules/axios/lib/defaults.js +134 -0
  71. package/node_modules/axios/lib/env/README.md +3 -0
  72. package/node_modules/axios/lib/env/data.js +3 -0
  73. package/node_modules/axios/lib/helpers/README.md +7 -0
  74. package/node_modules/axios/lib/helpers/bind.js +11 -0
  75. package/node_modules/axios/lib/helpers/buildURL.js +70 -0
  76. package/node_modules/axios/lib/helpers/combineURLs.js +14 -0
  77. package/node_modules/axios/lib/helpers/cookies.js +53 -0
  78. package/node_modules/axios/lib/helpers/deprecatedMethod.js +24 -0
  79. package/node_modules/axios/lib/helpers/isAbsoluteURL.js +14 -0
  80. package/node_modules/axios/lib/helpers/isAxiosError.js +11 -0
  81. package/node_modules/axios/lib/helpers/isURLSameOrigin.js +68 -0
  82. package/node_modules/axios/lib/helpers/normalizeHeaderName.js +12 -0
  83. package/node_modules/axios/lib/helpers/parseHeaders.js +53 -0
  84. package/node_modules/axios/lib/helpers/spread.js +27 -0
  85. package/node_modules/axios/lib/helpers/validator.js +82 -0
  86. package/node_modules/axios/lib/utils.js +349 -0
  87. package/node_modules/axios/package.json +113 -0
  88. package/node_modules/axios/tsconfig.json +14 -0
  89. package/node_modules/axios/tslint.json +6 -0
  90. package/node_modules/combined-stream/License +19 -0
  91. package/node_modules/combined-stream/Readme.md +138 -0
  92. package/node_modules/combined-stream/lib/combined_stream.js +208 -0
  93. package/node_modules/combined-stream/package.json +57 -0
  94. package/node_modules/combined-stream/yarn.lock +17 -0
  95. package/node_modules/delayed-stream/.npmignore +1 -0
  96. package/node_modules/delayed-stream/License +19 -0
  97. package/node_modules/delayed-stream/Makefile +7 -0
  98. package/node_modules/delayed-stream/Readme.md +141 -0
  99. package/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  100. package/node_modules/delayed-stream/package.json +62 -0
  101. package/node_modules/follow-redirects/LICENSE +18 -0
  102. package/node_modules/follow-redirects/README.md +148 -0
  103. package/node_modules/follow-redirects/debug.js +15 -0
  104. package/node_modules/follow-redirects/http.js +1 -0
  105. package/node_modules/follow-redirects/https.js +1 -0
  106. package/node_modules/follow-redirects/index.js +569 -0
  107. package/node_modules/follow-redirects/package.json +95 -0
  108. package/node_modules/form-data/License +19 -0
  109. package/node_modules/form-data/README.md.bak +358 -0
  110. package/node_modules/form-data/Readme.md +358 -0
  111. package/node_modules/form-data/index.d.ts +62 -0
  112. package/node_modules/form-data/lib/browser.js +2 -0
  113. package/node_modules/form-data/lib/form_data.js +501 -0
  114. package/node_modules/form-data/lib/populate.js +10 -0
  115. package/node_modules/form-data/package.json +101 -0
  116. package/node_modules/mime-db/HISTORY.md +499 -0
  117. package/node_modules/mime-db/LICENSE +22 -0
  118. package/node_modules/mime-db/README.md +100 -0
  119. package/node_modules/mime-db/db.json +8471 -0
  120. package/node_modules/mime-db/index.js +11 -0
  121. package/node_modules/mime-db/package.json +102 -0
  122. package/node_modules/mime-types/HISTORY.md +388 -0
  123. package/node_modules/mime-types/LICENSE +23 -0
  124. package/node_modules/mime-types/README.md +113 -0
  125. package/node_modules/mime-types/index.js +188 -0
  126. package/node_modules/mime-types/package.json +87 -0
  127. package/node_modules/uuid/CHANGELOG.md +229 -0
  128. package/node_modules/uuid/CONTRIBUTING.md +18 -0
  129. package/node_modules/uuid/LICENSE.md +9 -0
  130. package/node_modules/uuid/README.md +505 -0
  131. package/node_modules/uuid/dist/bin/uuid +2 -0
  132. package/node_modules/uuid/dist/esm-browser/index.js +9 -0
  133. package/node_modules/uuid/dist/esm-browser/md5.js +215 -0
  134. package/node_modules/uuid/dist/esm-browser/nil.js +1 -0
  135. package/node_modules/uuid/dist/esm-browser/parse.js +35 -0
  136. package/node_modules/uuid/dist/esm-browser/regex.js +1 -0
  137. package/node_modules/uuid/dist/esm-browser/rng.js +19 -0
  138. package/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
  139. package/node_modules/uuid/dist/esm-browser/stringify.js +30 -0
  140. package/node_modules/uuid/dist/esm-browser/v1.js +95 -0
  141. package/node_modules/uuid/dist/esm-browser/v3.js +4 -0
  142. package/node_modules/uuid/dist/esm-browser/v35.js +64 -0
  143. package/node_modules/uuid/dist/esm-browser/v4.js +24 -0
  144. package/node_modules/uuid/dist/esm-browser/v5.js +4 -0
  145. package/node_modules/uuid/dist/esm-browser/validate.js +7 -0
  146. package/node_modules/uuid/dist/esm-browser/version.js +11 -0
  147. package/node_modules/uuid/dist/esm-node/index.js +9 -0
  148. package/node_modules/uuid/dist/esm-node/md5.js +13 -0
  149. package/node_modules/uuid/dist/esm-node/nil.js +1 -0
  150. package/node_modules/uuid/dist/esm-node/parse.js +35 -0
  151. package/node_modules/uuid/dist/esm-node/regex.js +1 -0
  152. package/node_modules/uuid/dist/esm-node/rng.js +12 -0
  153. package/node_modules/uuid/dist/esm-node/sha1.js +13 -0
  154. package/node_modules/uuid/dist/esm-node/stringify.js +29 -0
  155. package/node_modules/uuid/dist/esm-node/v1.js +95 -0
  156. package/node_modules/uuid/dist/esm-node/v3.js +4 -0
  157. package/node_modules/uuid/dist/esm-node/v35.js +64 -0
  158. package/node_modules/uuid/dist/esm-node/v4.js +24 -0
  159. package/node_modules/uuid/dist/esm-node/v5.js +4 -0
  160. package/node_modules/uuid/dist/esm-node/validate.js +7 -0
  161. package/node_modules/uuid/dist/esm-node/version.js +11 -0
  162. package/node_modules/uuid/dist/index.js +79 -0
  163. package/node_modules/uuid/dist/md5-browser.js +223 -0
  164. package/node_modules/uuid/dist/md5.js +23 -0
  165. package/node_modules/uuid/dist/nil.js +8 -0
  166. package/node_modules/uuid/dist/parse.js +45 -0
  167. package/node_modules/uuid/dist/regex.js +8 -0
  168. package/node_modules/uuid/dist/rng-browser.js +26 -0
  169. package/node_modules/uuid/dist/rng.js +24 -0
  170. package/node_modules/uuid/dist/sha1-browser.js +104 -0
  171. package/node_modules/uuid/dist/sha1.js +23 -0
  172. package/node_modules/uuid/dist/stringify.js +39 -0
  173. package/node_modules/uuid/dist/umd/uuid.min.js +1 -0
  174. package/node_modules/uuid/dist/umd/uuidNIL.min.js +1 -0
  175. package/node_modules/uuid/dist/umd/uuidParse.min.js +1 -0
  176. package/node_modules/uuid/dist/umd/uuidStringify.min.js +1 -0
  177. package/node_modules/uuid/dist/umd/uuidValidate.min.js +1 -0
  178. package/node_modules/uuid/dist/umd/uuidVersion.min.js +1 -0
  179. package/node_modules/uuid/dist/umd/uuidv1.min.js +1 -0
  180. package/node_modules/uuid/dist/umd/uuidv3.min.js +1 -0
  181. package/node_modules/uuid/dist/umd/uuidv4.min.js +1 -0
  182. package/node_modules/uuid/dist/umd/uuidv5.min.js +1 -0
  183. package/node_modules/uuid/dist/uuid-bin.js +85 -0
  184. package/node_modules/uuid/dist/v1.js +107 -0
  185. package/node_modules/uuid/dist/v3.js +16 -0
  186. package/node_modules/uuid/dist/v35.js +78 -0
  187. package/node_modules/uuid/dist/v4.js +37 -0
  188. package/node_modules/uuid/dist/v5.js +16 -0
  189. package/node_modules/uuid/dist/validate.js +17 -0
  190. package/node_modules/uuid/dist/version.js +21 -0
  191. package/node_modules/uuid/package.json +164 -0
  192. package/node_modules/uuid/wrapper.mjs +10 -0
  193. package/package.json +32 -0
  194. package/tak-registration.html +111 -0
  195. package/tak-registration.js +169 -0
@@ -0,0 +1,569 @@
1
+ var url = require("url");
2
+ var URL = url.URL;
3
+ var http = require("http");
4
+ var https = require("https");
5
+ var Writable = require("stream").Writable;
6
+ var assert = require("assert");
7
+ var debug = require("./debug");
8
+
9
+ // Create handlers that pass events from native requests
10
+ var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
11
+ var eventHandlers = Object.create(null);
12
+ events.forEach(function (event) {
13
+ eventHandlers[event] = function (arg1, arg2, arg3) {
14
+ this._redirectable.emit(event, arg1, arg2, arg3);
15
+ };
16
+ });
17
+
18
+ // Error types with codes
19
+ var RedirectionError = createErrorType(
20
+ "ERR_FR_REDIRECTION_FAILURE",
21
+ "Redirected request failed"
22
+ );
23
+ var TooManyRedirectsError = createErrorType(
24
+ "ERR_FR_TOO_MANY_REDIRECTS",
25
+ "Maximum number of redirects exceeded"
26
+ );
27
+ var MaxBodyLengthExceededError = createErrorType(
28
+ "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
29
+ "Request body larger than maxBodyLength limit"
30
+ );
31
+ var WriteAfterEndError = createErrorType(
32
+ "ERR_STREAM_WRITE_AFTER_END",
33
+ "write after end"
34
+ );
35
+
36
+ // An HTTP(S) request that can be redirected
37
+ function RedirectableRequest(options, responseCallback) {
38
+ // Initialize the request
39
+ Writable.call(this);
40
+ this._sanitizeOptions(options);
41
+ this._options = options;
42
+ this._ended = false;
43
+ this._ending = false;
44
+ this._redirectCount = 0;
45
+ this._redirects = [];
46
+ this._requestBodyLength = 0;
47
+ this._requestBodyBuffers = [];
48
+
49
+ // Attach a callback if passed
50
+ if (responseCallback) {
51
+ this.on("response", responseCallback);
52
+ }
53
+
54
+ // React to responses of native requests
55
+ var self = this;
56
+ this._onNativeResponse = function (response) {
57
+ self._processResponse(response);
58
+ };
59
+
60
+ // Perform the first request
61
+ this._performRequest();
62
+ }
63
+ RedirectableRequest.prototype = Object.create(Writable.prototype);
64
+
65
+ RedirectableRequest.prototype.abort = function () {
66
+ abortRequest(this._currentRequest);
67
+ this.emit("abort");
68
+ };
69
+
70
+ // Writes buffered data to the current native request
71
+ RedirectableRequest.prototype.write = function (data, encoding, callback) {
72
+ // Writing is not allowed if end has been called
73
+ if (this._ending) {
74
+ throw new WriteAfterEndError();
75
+ }
76
+
77
+ // Validate input and shift parameters if necessary
78
+ if (!(typeof data === "string" || typeof data === "object" && ("length" in data))) {
79
+ throw new TypeError("data should be a string, Buffer or Uint8Array");
80
+ }
81
+ if (typeof encoding === "function") {
82
+ callback = encoding;
83
+ encoding = null;
84
+ }
85
+
86
+ // Ignore empty buffers, since writing them doesn't invoke the callback
87
+ // https://github.com/nodejs/node/issues/22066
88
+ if (data.length === 0) {
89
+ if (callback) {
90
+ callback();
91
+ }
92
+ return;
93
+ }
94
+ // Only write when we don't exceed the maximum body length
95
+ if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
96
+ this._requestBodyLength += data.length;
97
+ this._requestBodyBuffers.push({ data: data, encoding: encoding });
98
+ this._currentRequest.write(data, encoding, callback);
99
+ }
100
+ // Error when we exceed the maximum body length
101
+ else {
102
+ this.emit("error", new MaxBodyLengthExceededError());
103
+ this.abort();
104
+ }
105
+ };
106
+
107
+ // Ends the current native request
108
+ RedirectableRequest.prototype.end = function (data, encoding, callback) {
109
+ // Shift parameters if necessary
110
+ if (typeof data === "function") {
111
+ callback = data;
112
+ data = encoding = null;
113
+ }
114
+ else if (typeof encoding === "function") {
115
+ callback = encoding;
116
+ encoding = null;
117
+ }
118
+
119
+ // Write data if needed and end
120
+ if (!data) {
121
+ this._ended = this._ending = true;
122
+ this._currentRequest.end(null, null, callback);
123
+ }
124
+ else {
125
+ var self = this;
126
+ var currentRequest = this._currentRequest;
127
+ this.write(data, encoding, function () {
128
+ self._ended = true;
129
+ currentRequest.end(null, null, callback);
130
+ });
131
+ this._ending = true;
132
+ }
133
+ };
134
+
135
+ // Sets a header value on the current native request
136
+ RedirectableRequest.prototype.setHeader = function (name, value) {
137
+ this._options.headers[name] = value;
138
+ this._currentRequest.setHeader(name, value);
139
+ };
140
+
141
+ // Clears a header value on the current native request
142
+ RedirectableRequest.prototype.removeHeader = function (name) {
143
+ delete this._options.headers[name];
144
+ this._currentRequest.removeHeader(name);
145
+ };
146
+
147
+ // Global timeout for all underlying requests
148
+ RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
149
+ var self = this;
150
+
151
+ // Destroys the socket on timeout
152
+ function destroyOnTimeout(socket) {
153
+ socket.setTimeout(msecs);
154
+ socket.removeListener("timeout", socket.destroy);
155
+ socket.addListener("timeout", socket.destroy);
156
+ }
157
+
158
+ // Sets up a timer to trigger a timeout event
159
+ function startTimer(socket) {
160
+ if (self._timeout) {
161
+ clearTimeout(self._timeout);
162
+ }
163
+ self._timeout = setTimeout(function () {
164
+ self.emit("timeout");
165
+ clearTimer();
166
+ }, msecs);
167
+ destroyOnTimeout(socket);
168
+ }
169
+
170
+ // Stops a timeout from triggering
171
+ function clearTimer() {
172
+ // Clear the timeout
173
+ if (self._timeout) {
174
+ clearTimeout(self._timeout);
175
+ self._timeout = null;
176
+ }
177
+
178
+ // Clean up all attached listeners
179
+ self.removeListener("abort", clearTimer);
180
+ self.removeListener("error", clearTimer);
181
+ self.removeListener("response", clearTimer);
182
+ if (callback) {
183
+ self.removeListener("timeout", callback);
184
+ }
185
+ if (!self.socket) {
186
+ self._currentRequest.removeListener("socket", startTimer);
187
+ }
188
+ }
189
+
190
+ // Attach callback if passed
191
+ if (callback) {
192
+ this.on("timeout", callback);
193
+ }
194
+
195
+ // Start the timer if or when the socket is opened
196
+ if (this.socket) {
197
+ startTimer(this.socket);
198
+ }
199
+ else {
200
+ this._currentRequest.once("socket", startTimer);
201
+ }
202
+
203
+ // Clean up on events
204
+ this.on("socket", destroyOnTimeout);
205
+ this.on("abort", clearTimer);
206
+ this.on("error", clearTimer);
207
+ this.on("response", clearTimer);
208
+
209
+ return this;
210
+ };
211
+
212
+ // Proxy all other public ClientRequest methods
213
+ [
214
+ "flushHeaders", "getHeader",
215
+ "setNoDelay", "setSocketKeepAlive",
216
+ ].forEach(function (method) {
217
+ RedirectableRequest.prototype[method] = function (a, b) {
218
+ return this._currentRequest[method](a, b);
219
+ };
220
+ });
221
+
222
+ // Proxy all public ClientRequest properties
223
+ ["aborted", "connection", "socket"].forEach(function (property) {
224
+ Object.defineProperty(RedirectableRequest.prototype, property, {
225
+ get: function () { return this._currentRequest[property]; },
226
+ });
227
+ });
228
+
229
+ RedirectableRequest.prototype._sanitizeOptions = function (options) {
230
+ // Ensure headers are always present
231
+ if (!options.headers) {
232
+ options.headers = {};
233
+ }
234
+
235
+ // Since http.request treats host as an alias of hostname,
236
+ // but the url module interprets host as hostname plus port,
237
+ // eliminate the host property to avoid confusion.
238
+ if (options.host) {
239
+ // Use hostname if set, because it has precedence
240
+ if (!options.hostname) {
241
+ options.hostname = options.host;
242
+ }
243
+ delete options.host;
244
+ }
245
+
246
+ // Complete the URL object when necessary
247
+ if (!options.pathname && options.path) {
248
+ var searchPos = options.path.indexOf("?");
249
+ if (searchPos < 0) {
250
+ options.pathname = options.path;
251
+ }
252
+ else {
253
+ options.pathname = options.path.substring(0, searchPos);
254
+ options.search = options.path.substring(searchPos);
255
+ }
256
+ }
257
+ };
258
+
259
+
260
+ // Executes the next native request (initial or redirect)
261
+ RedirectableRequest.prototype._performRequest = function () {
262
+ // Load the native protocol
263
+ var protocol = this._options.protocol;
264
+ var nativeProtocol = this._options.nativeProtocols[protocol];
265
+ if (!nativeProtocol) {
266
+ this.emit("error", new TypeError("Unsupported protocol " + protocol));
267
+ return;
268
+ }
269
+
270
+ // If specified, use the agent corresponding to the protocol
271
+ // (HTTP and HTTPS use different types of agents)
272
+ if (this._options.agents) {
273
+ var scheme = protocol.substr(0, protocol.length - 1);
274
+ this._options.agent = this._options.agents[scheme];
275
+ }
276
+
277
+ // Create the native request
278
+ var request = this._currentRequest =
279
+ nativeProtocol.request(this._options, this._onNativeResponse);
280
+ this._currentUrl = url.format(this._options);
281
+
282
+ // Set up event handlers
283
+ request._redirectable = this;
284
+ for (var e = 0; e < events.length; e++) {
285
+ request.on(events[e], eventHandlers[events[e]]);
286
+ }
287
+
288
+ // End a redirected request
289
+ // (The first request must be ended explicitly with RedirectableRequest#end)
290
+ if (this._isRedirect) {
291
+ // Write the request entity and end.
292
+ var i = 0;
293
+ var self = this;
294
+ var buffers = this._requestBodyBuffers;
295
+ (function writeNext(error) {
296
+ // Only write if this request has not been redirected yet
297
+ /* istanbul ignore else */
298
+ if (request === self._currentRequest) {
299
+ // Report any write errors
300
+ /* istanbul ignore if */
301
+ if (error) {
302
+ self.emit("error", error);
303
+ }
304
+ // Write the next buffer if there are still left
305
+ else if (i < buffers.length) {
306
+ var buffer = buffers[i++];
307
+ /* istanbul ignore else */
308
+ if (!request.finished) {
309
+ request.write(buffer.data, buffer.encoding, writeNext);
310
+ }
311
+ }
312
+ // End the request if `end` has been called on us
313
+ else if (self._ended) {
314
+ request.end();
315
+ }
316
+ }
317
+ }());
318
+ }
319
+ };
320
+
321
+ // Processes a response from the current native request
322
+ RedirectableRequest.prototype._processResponse = function (response) {
323
+ // Store the redirected response
324
+ var statusCode = response.statusCode;
325
+ if (this._options.trackRedirects) {
326
+ this._redirects.push({
327
+ url: this._currentUrl,
328
+ headers: response.headers,
329
+ statusCode: statusCode,
330
+ });
331
+ }
332
+
333
+ // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
334
+ // that further action needs to be taken by the user agent in order to
335
+ // fulfill the request. If a Location header field is provided,
336
+ // the user agent MAY automatically redirect its request to the URI
337
+ // referenced by the Location field value,
338
+ // even if the specific status code is not understood.
339
+ var location = response.headers.location;
340
+ if (location && this._options.followRedirects !== false &&
341
+ statusCode >= 300 && statusCode < 400) {
342
+ // Abort the current request
343
+ abortRequest(this._currentRequest);
344
+ // Discard the remainder of the response to avoid waiting for data
345
+ response.destroy();
346
+
347
+ // RFC7231§6.4: A client SHOULD detect and intervene
348
+ // in cyclical redirections (i.e., "infinite" redirection loops).
349
+ if (++this._redirectCount > this._options.maxRedirects) {
350
+ this.emit("error", new TooManyRedirectsError());
351
+ return;
352
+ }
353
+
354
+ // RFC7231§6.4: Automatic redirection needs to done with
355
+ // care for methods not known to be safe, […]
356
+ // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
357
+ // the request method from POST to GET for the subsequent request.
358
+ if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
359
+ // RFC7231§6.4.4: The 303 (See Other) status code indicates that
360
+ // the server is redirecting the user agent to a different resource […]
361
+ // A user agent can perform a retrieval request targeting that URI
362
+ // (a GET or HEAD request if using HTTP) […]
363
+ (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
364
+ this._options.method = "GET";
365
+ // Drop a possible entity and headers related to it
366
+ this._requestBodyBuffers = [];
367
+ removeMatchingHeaders(/^content-/i, this._options.headers);
368
+ }
369
+
370
+ // Drop the Host header, as the redirect might lead to a different host
371
+ var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
372
+
373
+ // If the redirect is relative, carry over the host of the last request
374
+ var currentUrlParts = url.parse(this._currentUrl);
375
+ var currentHost = currentHostHeader || currentUrlParts.host;
376
+ var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
377
+ url.format(Object.assign(currentUrlParts, { host: currentHost }));
378
+
379
+ // Determine the URL of the redirection
380
+ var redirectUrl;
381
+ try {
382
+ redirectUrl = url.resolve(currentUrl, location);
383
+ }
384
+ catch (cause) {
385
+ this.emit("error", new RedirectionError(cause));
386
+ return;
387
+ }
388
+
389
+ // Create the redirected request
390
+ debug("redirecting to", redirectUrl);
391
+ this._isRedirect = true;
392
+ var redirectUrlParts = url.parse(redirectUrl);
393
+ Object.assign(this._options, redirectUrlParts);
394
+
395
+ // Drop the confidential headers when redirecting to another domain
396
+ if (!(redirectUrlParts.host === currentHost || isSubdomainOf(redirectUrlParts.host, currentHost))) {
397
+ removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
398
+ }
399
+
400
+ // Evaluate the beforeRedirect callback
401
+ if (typeof this._options.beforeRedirect === "function") {
402
+ var responseDetails = { headers: response.headers };
403
+ try {
404
+ this._options.beforeRedirect.call(null, this._options, responseDetails);
405
+ }
406
+ catch (err) {
407
+ this.emit("error", err);
408
+ return;
409
+ }
410
+ this._sanitizeOptions(this._options);
411
+ }
412
+
413
+ // Perform the redirected request
414
+ try {
415
+ this._performRequest();
416
+ }
417
+ catch (cause) {
418
+ this.emit("error", new RedirectionError(cause));
419
+ }
420
+ }
421
+ else {
422
+ // The response is not a redirect; return it as-is
423
+ response.responseUrl = this._currentUrl;
424
+ response.redirects = this._redirects;
425
+ this.emit("response", response);
426
+
427
+ // Clean up
428
+ this._requestBodyBuffers = [];
429
+ }
430
+ };
431
+
432
+ // Wraps the key/value object of protocols with redirect functionality
433
+ function wrap(protocols) {
434
+ // Default settings
435
+ var exports = {
436
+ maxRedirects: 21,
437
+ maxBodyLength: 10 * 1024 * 1024,
438
+ };
439
+
440
+ // Wrap each protocol
441
+ var nativeProtocols = {};
442
+ Object.keys(protocols).forEach(function (scheme) {
443
+ var protocol = scheme + ":";
444
+ var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
445
+ var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
446
+
447
+ // Executes a request, following redirects
448
+ function request(input, options, callback) {
449
+ // Parse parameters
450
+ if (typeof input === "string") {
451
+ var urlStr = input;
452
+ try {
453
+ input = urlToOptions(new URL(urlStr));
454
+ }
455
+ catch (err) {
456
+ /* istanbul ignore next */
457
+ input = url.parse(urlStr);
458
+ }
459
+ }
460
+ else if (URL && (input instanceof URL)) {
461
+ input = urlToOptions(input);
462
+ }
463
+ else {
464
+ callback = options;
465
+ options = input;
466
+ input = { protocol: protocol };
467
+ }
468
+ if (typeof options === "function") {
469
+ callback = options;
470
+ options = null;
471
+ }
472
+
473
+ // Set defaults
474
+ options = Object.assign({
475
+ maxRedirects: exports.maxRedirects,
476
+ maxBodyLength: exports.maxBodyLength,
477
+ }, input, options);
478
+ options.nativeProtocols = nativeProtocols;
479
+
480
+ assert.equal(options.protocol, protocol, "protocol mismatch");
481
+ debug("options", options);
482
+ return new RedirectableRequest(options, callback);
483
+ }
484
+
485
+ // Executes a GET request, following redirects
486
+ function get(input, options, callback) {
487
+ var wrappedRequest = wrappedProtocol.request(input, options, callback);
488
+ wrappedRequest.end();
489
+ return wrappedRequest;
490
+ }
491
+
492
+ // Expose the properties on the wrapped protocol
493
+ Object.defineProperties(wrappedProtocol, {
494
+ request: { value: request, configurable: true, enumerable: true, writable: true },
495
+ get: { value: get, configurable: true, enumerable: true, writable: true },
496
+ });
497
+ });
498
+ return exports;
499
+ }
500
+
501
+ /* istanbul ignore next */
502
+ function noop() { /* empty */ }
503
+
504
+ // from https://github.com/nodejs/node/blob/master/lib/internal/url.js
505
+ function urlToOptions(urlObject) {
506
+ var options = {
507
+ protocol: urlObject.protocol,
508
+ hostname: urlObject.hostname.startsWith("[") ?
509
+ /* istanbul ignore next */
510
+ urlObject.hostname.slice(1, -1) :
511
+ urlObject.hostname,
512
+ hash: urlObject.hash,
513
+ search: urlObject.search,
514
+ pathname: urlObject.pathname,
515
+ path: urlObject.pathname + urlObject.search,
516
+ href: urlObject.href,
517
+ };
518
+ if (urlObject.port !== "") {
519
+ options.port = Number(urlObject.port);
520
+ }
521
+ return options;
522
+ }
523
+
524
+ function removeMatchingHeaders(regex, headers) {
525
+ var lastValue;
526
+ for (var header in headers) {
527
+ if (regex.test(header)) {
528
+ lastValue = headers[header];
529
+ delete headers[header];
530
+ }
531
+ }
532
+ return (lastValue === null || typeof lastValue === "undefined") ?
533
+ undefined : String(lastValue).trim();
534
+ }
535
+
536
+ function createErrorType(code, defaultMessage) {
537
+ function CustomError(cause) {
538
+ Error.captureStackTrace(this, this.constructor);
539
+ if (!cause) {
540
+ this.message = defaultMessage;
541
+ }
542
+ else {
543
+ this.message = defaultMessage + ": " + cause.message;
544
+ this.cause = cause;
545
+ }
546
+ }
547
+ CustomError.prototype = new Error();
548
+ CustomError.prototype.constructor = CustomError;
549
+ CustomError.prototype.name = "Error [" + code + "]";
550
+ CustomError.prototype.code = code;
551
+ return CustomError;
552
+ }
553
+
554
+ function abortRequest(request) {
555
+ for (var e = 0; e < events.length; e++) {
556
+ request.removeListener(events[e], eventHandlers[events[e]]);
557
+ }
558
+ request.on("error", noop);
559
+ request.abort();
560
+ }
561
+
562
+ function isSubdomainOf(subdomain, domain) {
563
+ const dot = subdomain.length - domain.length - 1;
564
+ return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
565
+ }
566
+
567
+ // Exports
568
+ module.exports = wrap({ http: http, https: https });
569
+ module.exports.wrap = wrap;
@@ -0,0 +1,95 @@
1
+ {
2
+ "_from": "follow-redirects@^1.14.4",
3
+ "_id": "follow-redirects@1.14.7",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==",
6
+ "_location": "/node-red-contrib-takfiles/follow-redirects",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "range",
10
+ "registry": true,
11
+ "raw": "follow-redirects@^1.14.4",
12
+ "name": "follow-redirects",
13
+ "escapedName": "follow-redirects",
14
+ "rawSpec": "^1.14.4",
15
+ "saveSpec": null,
16
+ "fetchSpec": "^1.14.4"
17
+ },
18
+ "_requiredBy": [
19
+ "/node-red-contrib-takfiles/axios"
20
+ ],
21
+ "_resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
22
+ "_shasum": "2004c02eb9436eee9a21446a6477debf17e81685",
23
+ "_spec": "follow-redirects@^1.14.4",
24
+ "_where": "/Users/conway/Projects/DCJNodes/takfile/node_modules/axios",
25
+ "author": {
26
+ "name": "Ruben Verborgh",
27
+ "email": "ruben@verborgh.org",
28
+ "url": "https://ruben.verborgh.org/"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/follow-redirects/follow-redirects/issues"
32
+ },
33
+ "bundleDependencies": false,
34
+ "contributors": [
35
+ {
36
+ "name": "Olivier Lalonde",
37
+ "email": "olalonde@gmail.com",
38
+ "url": "http://www.syskall.com"
39
+ },
40
+ {
41
+ "name": "James Talmage",
42
+ "email": "james@talmage.io"
43
+ }
44
+ ],
45
+ "deprecated": false,
46
+ "description": "HTTP and HTTPS modules that follow redirects.",
47
+ "devDependencies": {
48
+ "concat-stream": "^2.0.0",
49
+ "eslint": "^5.16.0",
50
+ "express": "^4.16.4",
51
+ "lolex": "^3.1.0",
52
+ "mocha": "^6.0.2",
53
+ "nyc": "^14.1.1"
54
+ },
55
+ "engines": {
56
+ "node": ">=4.0"
57
+ },
58
+ "files": [
59
+ "*.js"
60
+ ],
61
+ "funding": [
62
+ {
63
+ "type": "individual",
64
+ "url": "https://github.com/sponsors/RubenVerborgh"
65
+ }
66
+ ],
67
+ "homepage": "https://github.com/follow-redirects/follow-redirects",
68
+ "keywords": [
69
+ "http",
70
+ "https",
71
+ "url",
72
+ "redirect",
73
+ "client",
74
+ "location",
75
+ "utility"
76
+ ],
77
+ "license": "MIT",
78
+ "main": "index.js",
79
+ "name": "follow-redirects",
80
+ "peerDependenciesMeta": {
81
+ "debug": {
82
+ "optional": true
83
+ }
84
+ },
85
+ "repository": {
86
+ "type": "git",
87
+ "url": "git+ssh://git@github.com/follow-redirects/follow-redirects.git"
88
+ },
89
+ "scripts": {
90
+ "lint": "eslint *.js test",
91
+ "mocha": "nyc mocha",
92
+ "test": "npm run lint && npm run mocha"
93
+ },
94
+ "version": "1.14.7"
95
+ }
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.