cloudstructs 0.4.20 → 0.4.23
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/.jsii +3 -3
- package/assets/email-receiver/s3.lambda/index.js +8 -13
- package/assets/email-receiver/whitelist.lambda/index.js +8 -13
- package/assets/slack-app/provider.lambda/index.js +203 -35
- package/assets/slack-events/events.lambda/index.js +9 -16
- package/assets/slack-textract/detect.lambda/index.js +323 -93
- package/assets/toolkit-cleaner/clean-images.lambda/index.js +8 -13
- package/assets/toolkit-cleaner/clean-objects.lambda/index.js +9 -16
- package/assets/toolkit-cleaner/extract-template-hashes.lambda/index.js +8 -13
- package/assets/toolkit-cleaner/get-stack-names.lambda/index.js +8 -13
- package/assets/url-shortener/shortener.lambda/index.js +8 -13
- package/changelog.md +1 -1
- package/lib/codecommit-mirror/index.js +2 -2
- package/lib/ecs-service-roller/index.js +2 -2
- package/lib/email-receiver/receiver.js +1 -1
- package/lib/saml-identity-provider/index.js +2 -2
- package/lib/slack-app/manifest.js +1 -1
- package/lib/slack-app/slack-app.js +2 -2
- package/lib/slack-events/index.js +1 -1
- package/lib/slack-textract/index.js +1 -1
- package/lib/state-machine-cr-provider/index.js +1 -1
- package/lib/static-website/index.js +14 -3
- package/lib/toolkit-cleaner/index.js +1 -1
- package/lib/url-shortener/index.js +1 -1
- package/node_modules/@sindresorhus/is/dist/index.d.ts +9 -4
- package/node_modules/@sindresorhus/is/dist/index.js +9 -3
- package/node_modules/@sindresorhus/is/package.json +1 -1
- package/node_modules/@sindresorhus/is/readme.md +24 -4
- package/node_modules/@slack/logger/node_modules/@types/node/README.md +2 -2
- package/node_modules/@slack/logger/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@slack/logger/node_modules/@types/node/buffer.d.ts +2 -2
- package/node_modules/@slack/logger/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@slack/logger/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@slack/logger/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@slack/logger/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@slack/logger/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@slack/logger/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@slack/logger/node_modules/@types/node/package.json +3 -3
- package/node_modules/@slack/logger/node_modules/@types/node/process.d.ts +1 -1
- package/node_modules/@slack/logger/node_modules/@types/node/stream/web.d.ts +2 -1
- package/node_modules/@slack/logger/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/README.md +2 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/buffer.d.ts +2 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@slack/web-api/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@slack/web-api/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/package.json +3 -3
- package/node_modules/@slack/web-api/node_modules/@types/node/process.d.ts +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/stream/web.d.ts +2 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/cacheable-request/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/buffer.d.ts +2 -2
- package/node_modules/@types/cacheable-request/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@types/cacheable-request/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@types/cacheable-request/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@types/cacheable-request/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/cacheable-request/node_modules/@types/node/process.d.ts +1 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/stream/web.d.ts +2 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/is-stream/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/buffer.d.ts +2 -2
- package/node_modules/@types/is-stream/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@types/is-stream/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@types/is-stream/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@types/is-stream/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@types/is-stream/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@types/is-stream/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/is-stream/node_modules/@types/node/process.d.ts +1 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/stream/web.d.ts +2 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/json-buffer/LICENSE +21 -0
- package/node_modules/@types/json-buffer/README.md +16 -0
- package/node_modules/@types/json-buffer/index.d.ts +19 -0
- package/node_modules/@types/json-buffer/package.json +24 -0
- package/node_modules/@types/keyv/README.md +1 -1
- package/node_modules/@types/keyv/index.d.ts +16 -3
- package/node_modules/@types/keyv/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/keyv/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@types/keyv/node_modules/@types/node/buffer.d.ts +2 -2
- package/node_modules/@types/keyv/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@types/keyv/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@types/keyv/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@types/keyv/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@types/keyv/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@types/keyv/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@types/keyv/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/keyv/node_modules/@types/node/process.d.ts +1 -1
- package/node_modules/@types/keyv/node_modules/@types/node/stream/web.d.ts +2 -1
- package/node_modules/@types/keyv/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/keyv/package.json +3 -3
- package/node_modules/@types/responselike/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/responselike/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@types/responselike/node_modules/@types/node/buffer.d.ts +2 -2
- package/node_modules/@types/responselike/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@types/responselike/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@types/responselike/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@types/responselike/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@types/responselike/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@types/responselike/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@types/responselike/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/responselike/node_modules/@types/node/process.d.ts +1 -1
- package/node_modules/@types/responselike/node_modules/@types/node/stream/web.d.ts +2 -1
- package/node_modules/@types/responselike/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/retry/LICENSE +21 -21
- package/node_modules/@types/retry/README.md +4 -4
- package/node_modules/@types/retry/index.d.ts +9 -9
- package/node_modules/@types/retry/package.json +5 -7
- package/node_modules/compress-brotli/LICENSE.md +21 -0
- package/node_modules/compress-brotli/README.md +125 -0
- package/node_modules/compress-brotli/package.json +97 -0
- package/node_modules/compress-brotli/src/index.d.ts +36 -0
- package/node_modules/compress-brotli/src/index.js +45 -0
- package/node_modules/compress-brotli/src/merge-options.js +18 -0
- package/node_modules/follow-redirects/README.md +8 -1
- package/node_modules/follow-redirects/index.js +102 -82
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/keyv/package.json +55 -46
- package/node_modules/keyv/src/index.d.ts +89 -0
- package/node_modules/keyv/src/index.js +177 -25
- package/node_modules/mime-db/HISTORY.md +8 -0
- package/node_modules/mime-db/LICENSE +19 -18
- package/node_modules/mime-db/README.md +1 -1
- package/node_modules/mime-db/db.json +54 -6
- package/node_modules/mime-db/index.js +1 -0
- package/node_modules/mime-db/package.json +5 -4
- package/node_modules/mime-types/HISTORY.md +9 -0
- package/node_modules/mime-types/README.md +1 -1
- package/node_modules/mime-types/package.json +5 -5
- package/node_modules/p-retry/package.json +2 -2
- package/package.json +10 -10
- package/releasetag.txt +1 -1
- package/version.txt +1 -1
- package/node_modules/keyv/.nyc_output/5d6b8dd1-67cf-42ee-8492-c8ae62ce826c.json +0 -1
- package/node_modules/keyv/.nyc_output/ce27532e-5888-46d4-ae10-5a71058d3f0c.json +0 -1
- package/node_modules/keyv/.nyc_output/processinfo/5d6b8dd1-67cf-42ee-8492-c8ae62ce826c.json +0 -1
- package/node_modules/keyv/.nyc_output/processinfo/ce27532e-5888-46d4-ae10-5a71058d3f0c.json +0 -1
- package/node_modules/keyv/.nyc_output/processinfo/index.json +0 -1
- package/node_modules/keyv/test/test.js +0 -130
- package/node_modules/keyv/test/testdb.sqlite +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { promisify } = require('util')
|
|
4
|
+
const JSONB = require('json-buffer')
|
|
5
|
+
const zlib = require('zlib')
|
|
6
|
+
|
|
7
|
+
const mergeOptions = require('./merge-options')
|
|
8
|
+
|
|
9
|
+
const compress = promisify(zlib.brotliCompress)
|
|
10
|
+
|
|
11
|
+
const decompress = promisify(zlib.brotliDecompress)
|
|
12
|
+
|
|
13
|
+
const identity = val => val
|
|
14
|
+
|
|
15
|
+
const createCompress = ({
|
|
16
|
+
enable = true,
|
|
17
|
+
serialize = JSONB.stringify,
|
|
18
|
+
deserialize = JSONB.parse,
|
|
19
|
+
compressOptions,
|
|
20
|
+
decompressOptions
|
|
21
|
+
} = {}) => {
|
|
22
|
+
if (!enable) {
|
|
23
|
+
return { serialize, deserialize, decompress: identity, compress: identity }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
serialize,
|
|
28
|
+
deserialize,
|
|
29
|
+
compress: async (data, options = {}) => {
|
|
30
|
+
if (data === undefined) return data
|
|
31
|
+
const serializedData = serialize(data)
|
|
32
|
+
return compress(serializedData, mergeOptions(compressOptions, options))
|
|
33
|
+
},
|
|
34
|
+
decompress: async (data, options = {}) => {
|
|
35
|
+
if (data === undefined) return data
|
|
36
|
+
return deserialize(
|
|
37
|
+
await decompress(data, mergeOptions(decompressOptions, options))
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = createCompress
|
|
44
|
+
module.exports.stringify = JSONB.stringify
|
|
45
|
+
module.exports.parse = JSONB.parse
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = (defaultOptions = {}, options = {}) => {
|
|
4
|
+
const params = {
|
|
5
|
+
...(defaultOptions.params || {}),
|
|
6
|
+
...(options.params || {})
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
...defaultOptions,
|
|
11
|
+
...options,
|
|
12
|
+
...(Object.keys(params).length
|
|
13
|
+
? {
|
|
14
|
+
params
|
|
15
|
+
}
|
|
16
|
+
: {})
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -63,10 +63,17 @@ const { http, https } = require('follow-redirects');
|
|
|
63
63
|
|
|
64
64
|
const options = url.parse('http://bit.ly/900913');
|
|
65
65
|
options.maxRedirects = 10;
|
|
66
|
-
options.beforeRedirect = (options,
|
|
66
|
+
options.beforeRedirect = (options, response, request) => {
|
|
67
67
|
// Use this to adjust the request options upon redirecting,
|
|
68
68
|
// to inspect the latest response headers,
|
|
69
69
|
// or to cancel the request by throwing an error
|
|
70
|
+
|
|
71
|
+
// response.headers = the redirect response headers
|
|
72
|
+
// response.statusCode = the redirect response code (eg. 301, 307, etc.)
|
|
73
|
+
|
|
74
|
+
// request.url = the requested URL that resulted in a redirect
|
|
75
|
+
// request.headers = the headers in the request that resulted in a redirect
|
|
76
|
+
// request.method = the method of the request that resulted in a redirect
|
|
70
77
|
if (options.hostname === "example.com") {
|
|
71
78
|
options.auth = "user:password";
|
|
72
79
|
}
|
|
@@ -270,7 +270,7 @@ RedirectableRequest.prototype._performRequest = function () {
|
|
|
270
270
|
// If specified, use the agent corresponding to the protocol
|
|
271
271
|
// (HTTP and HTTPS use different types of agents)
|
|
272
272
|
if (this._options.agents) {
|
|
273
|
-
var scheme = protocol.
|
|
273
|
+
var scheme = protocol.slice(0, -1);
|
|
274
274
|
this._options.agent = this._options.agents[scheme];
|
|
275
275
|
}
|
|
276
276
|
|
|
@@ -336,97 +336,120 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
|
336
336
|
// the user agent MAY automatically redirect its request to the URI
|
|
337
337
|
// referenced by the Location field value,
|
|
338
338
|
// even if the specific status code is not understood.
|
|
339
|
+
|
|
340
|
+
// If the response is not a redirect; return it as-is
|
|
339
341
|
var location = response.headers.location;
|
|
340
|
-
if (location
|
|
341
|
-
statusCode
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
-
}
|
|
342
|
+
if (!location || this._options.followRedirects === false ||
|
|
343
|
+
statusCode < 300 || statusCode >= 400) {
|
|
344
|
+
response.responseUrl = this._currentUrl;
|
|
345
|
+
response.redirects = this._redirects;
|
|
346
|
+
this.emit("response", response);
|
|
353
347
|
|
|
354
|
-
//
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
}
|
|
348
|
+
// Clean up
|
|
349
|
+
this._requestBodyBuffers = [];
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
369
352
|
|
|
370
|
-
|
|
371
|
-
|
|
353
|
+
// The response is a redirect, so abort the current request
|
|
354
|
+
abortRequest(this._currentRequest);
|
|
355
|
+
// Discard the remainder of the response to avoid waiting for data
|
|
356
|
+
response.destroy();
|
|
372
357
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
358
|
+
// RFC7231§6.4: A client SHOULD detect and intervene
|
|
359
|
+
// in cyclical redirections (i.e., "infinite" redirection loops).
|
|
360
|
+
if (++this._redirectCount > this._options.maxRedirects) {
|
|
361
|
+
this.emit("error", new TooManyRedirectsError());
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
378
364
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
365
|
+
// Store the request headers if applicable
|
|
366
|
+
var requestHeaders;
|
|
367
|
+
var beforeRedirect = this._options.beforeRedirect;
|
|
368
|
+
if (beforeRedirect) {
|
|
369
|
+
requestHeaders = Object.assign({
|
|
370
|
+
// The Host header was set by nativeProtocol.request
|
|
371
|
+
Host: response.req.getHeader("host"),
|
|
372
|
+
}, this._options.headers);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// RFC7231§6.4: Automatic redirection needs to done with
|
|
376
|
+
// care for methods not known to be safe, […]
|
|
377
|
+
// RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
|
|
378
|
+
// the request method from POST to GET for the subsequent request.
|
|
379
|
+
var method = this._options.method;
|
|
380
|
+
if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
|
|
381
|
+
// RFC7231§6.4.4: The 303 (See Other) status code indicates that
|
|
382
|
+
// the server is redirecting the user agent to a different resource […]
|
|
383
|
+
// A user agent can perform a retrieval request targeting that URI
|
|
384
|
+
// (a GET or HEAD request if using HTTP) […]
|
|
385
|
+
(statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
|
|
386
|
+
this._options.method = "GET";
|
|
387
|
+
// Drop a possible entity and headers related to it
|
|
388
|
+
this._requestBodyBuffers = [];
|
|
389
|
+
removeMatchingHeaders(/^content-/i, this._options.headers);
|
|
390
|
+
}
|
|
388
391
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
this._isRedirect = true;
|
|
392
|
-
var redirectUrlParts = url.parse(redirectUrl);
|
|
393
|
-
Object.assign(this._options, redirectUrlParts);
|
|
392
|
+
// Drop the Host header, as the redirect might lead to a different host
|
|
393
|
+
var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
|
|
394
394
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
395
|
+
// If the redirect is relative, carry over the host of the last request
|
|
396
|
+
var currentUrlParts = url.parse(this._currentUrl);
|
|
397
|
+
var currentHost = currentHostHeader || currentUrlParts.host;
|
|
398
|
+
var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
|
|
399
|
+
url.format(Object.assign(currentUrlParts, { host: currentHost }));
|
|
400
400
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
401
|
+
// Determine the URL of the redirection
|
|
402
|
+
var redirectUrl;
|
|
403
|
+
try {
|
|
404
|
+
redirectUrl = url.resolve(currentUrl, location);
|
|
405
|
+
}
|
|
406
|
+
catch (cause) {
|
|
407
|
+
this.emit("error", new RedirectionError(cause));
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// Create the redirected request
|
|
412
|
+
debug("redirecting to", redirectUrl);
|
|
413
|
+
this._isRedirect = true;
|
|
414
|
+
var redirectUrlParts = url.parse(redirectUrl);
|
|
415
|
+
Object.assign(this._options, redirectUrlParts);
|
|
413
416
|
|
|
414
|
-
|
|
417
|
+
// Drop confidential headers when redirecting to a less secure protocol
|
|
418
|
+
// or to a different domain that is not a superdomain
|
|
419
|
+
if (redirectUrlParts.protocol !== currentUrlParts.protocol &&
|
|
420
|
+
redirectUrlParts.protocol !== "https:" ||
|
|
421
|
+
redirectUrlParts.host !== currentHost &&
|
|
422
|
+
!isSubdomain(redirectUrlParts.host, currentHost)) {
|
|
423
|
+
removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Evaluate the beforeRedirect callback
|
|
427
|
+
if (typeof beforeRedirect === "function") {
|
|
428
|
+
var responseDetails = {
|
|
429
|
+
headers: response.headers,
|
|
430
|
+
statusCode: statusCode,
|
|
431
|
+
};
|
|
432
|
+
var requestDetails = {
|
|
433
|
+
url: currentUrl,
|
|
434
|
+
method: method,
|
|
435
|
+
headers: requestHeaders,
|
|
436
|
+
};
|
|
415
437
|
try {
|
|
416
|
-
this.
|
|
438
|
+
beforeRedirect(this._options, responseDetails, requestDetails);
|
|
417
439
|
}
|
|
418
|
-
catch (
|
|
419
|
-
this.emit("error",
|
|
440
|
+
catch (err) {
|
|
441
|
+
this.emit("error", err);
|
|
442
|
+
return;
|
|
420
443
|
}
|
|
444
|
+
this._sanitizeOptions(this._options);
|
|
421
445
|
}
|
|
422
|
-
else {
|
|
423
|
-
// The response is not a redirect; return it as-is
|
|
424
|
-
response.responseUrl = this._currentUrl;
|
|
425
|
-
response.redirects = this._redirects;
|
|
426
|
-
this.emit("response", response);
|
|
427
446
|
|
|
428
|
-
|
|
429
|
-
|
|
447
|
+
// Perform the redirected request
|
|
448
|
+
try {
|
|
449
|
+
this._performRequest();
|
|
450
|
+
}
|
|
451
|
+
catch (cause) {
|
|
452
|
+
this.emit("error", new RedirectionError(cause));
|
|
430
453
|
}
|
|
431
454
|
};
|
|
432
455
|
|
|
@@ -560,10 +583,7 @@ function abortRequest(request) {
|
|
|
560
583
|
request.abort();
|
|
561
584
|
}
|
|
562
585
|
|
|
563
|
-
function
|
|
564
|
-
if (subdomain === domain) {
|
|
565
|
-
return true;
|
|
566
|
-
}
|
|
586
|
+
function isSubdomain(subdomain, domain) {
|
|
567
587
|
const dot = subdomain.length - domain.length - 1;
|
|
568
588
|
return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
|
|
569
589
|
}
|
|
@@ -1,48 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
2
|
+
"name": "keyv",
|
|
3
|
+
"version": "4.2.6",
|
|
4
|
+
"description": "Simple key-value storage with support for multiple backends",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "xo && nyc ava --serial",
|
|
8
|
+
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
|
|
9
|
+
"clean": "rm -rf node_modules && rm -rf .nyc_output && rm -rf coverage.lcov && rm -rf ./test/testdb.sqlite"
|
|
10
|
+
},
|
|
11
|
+
"xo": {
|
|
12
|
+
"rules": {
|
|
13
|
+
"unicorn/prefer-module": 0,
|
|
14
|
+
"unicorn/prefer-node-protocol": 0
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/jaredwray/keyv.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"key",
|
|
23
|
+
"value",
|
|
24
|
+
"store",
|
|
25
|
+
"cache",
|
|
26
|
+
"ttl"
|
|
27
|
+
],
|
|
28
|
+
"author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/jaredwray/keyv/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/jaredwray/keyv",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"compress-brotli": "^1.3.8",
|
|
36
|
+
"json-buffer": "3.0.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@keyv/test-suite": "*",
|
|
40
|
+
"ava": "^4.2.0",
|
|
41
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
42
|
+
"nyc": "^15.1.0",
|
|
43
|
+
"pify": "5.0.0",
|
|
44
|
+
"this": "^1.1.0",
|
|
45
|
+
"timekeeper": "^2.2.0",
|
|
46
|
+
"tsd": "^0.20.0",
|
|
47
|
+
"typescript": "^4.6.4",
|
|
48
|
+
"xo": "^0.48.0"
|
|
49
|
+
},
|
|
50
|
+
"tsd": {
|
|
51
|
+
"directory": "test"
|
|
52
|
+
},
|
|
53
|
+
"types": "./src/index.d.ts",
|
|
54
|
+
"files": [
|
|
55
|
+
"src"
|
|
56
|
+
]
|
|
48
57
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {EventEmitter} from 'events';
|
|
2
|
+
|
|
3
|
+
type WithRequiredProperties<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
4
|
+
|
|
5
|
+
declare class Keyv<Value = any, Options extends Record<string, any> = Record<string, unknown>> extends EventEmitter {
|
|
6
|
+
/**
|
|
7
|
+
* `this.opts` is an object containing at least the properties listed
|
|
8
|
+
* below. However, `Keyv.Options` allows arbitrary properties as well.
|
|
9
|
+
* These properties can be specified as the second type parameter to `Keyv`.
|
|
10
|
+
*/
|
|
11
|
+
opts: WithRequiredProperties<
|
|
12
|
+
Keyv.Options<Value>,
|
|
13
|
+
'deserialize' | 'namespace' | 'serialize' | 'store' | 'uri'
|
|
14
|
+
> &
|
|
15
|
+
Options;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
|
|
19
|
+
*/
|
|
20
|
+
constructor(options?: Keyv.Options<Value> & Options);
|
|
21
|
+
/**
|
|
22
|
+
* @param uri The connection string URI.
|
|
23
|
+
*
|
|
24
|
+
* Merged into the options object as options.uri.
|
|
25
|
+
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
|
|
26
|
+
*/
|
|
27
|
+
constructor(uri?: string, options?: Keyv.Options<Value> & Options);
|
|
28
|
+
|
|
29
|
+
/** Returns the value. */
|
|
30
|
+
get<Raw extends boolean = false>(key: string | string[], options?: {raw?: Raw}):
|
|
31
|
+
Promise<(Raw extends false
|
|
32
|
+
? Value
|
|
33
|
+
: Keyv.DeserializedData<Value>) | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Set a value.
|
|
36
|
+
*
|
|
37
|
+
* By default keys are persistent. You can set an expiry TTL in milliseconds.
|
|
38
|
+
*/
|
|
39
|
+
set(key: string, value: Value, ttl?: number): Promise<true>;
|
|
40
|
+
/**
|
|
41
|
+
* Deletes an entry.
|
|
42
|
+
*
|
|
43
|
+
* Returns `true` if the key existed, `false` if not.
|
|
44
|
+
*/
|
|
45
|
+
delete(key: string | string[]): Promise<boolean>;
|
|
46
|
+
/** Delete all entries in the current namespace. */
|
|
47
|
+
clear(): Promise<void>;
|
|
48
|
+
/** Check if key exists in current namespace. */
|
|
49
|
+
has(key: string): Promise<boolean>;
|
|
50
|
+
/** Iterator */
|
|
51
|
+
iterator(namespace: string | undefined): AsyncGenerator<any, void, any>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare namespace Keyv {
|
|
55
|
+
interface Options<Value> {
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
|
|
58
|
+
/** Namespace for the current instance. */
|
|
59
|
+
namespace?: string | undefined;
|
|
60
|
+
/** A custom serialization function. */
|
|
61
|
+
serialize?: ((data: DeserializedData<Value>) => string) | undefined;
|
|
62
|
+
/** A custom deserialization function. */
|
|
63
|
+
deserialize?: ((data: string) => DeserializedData<Value> | undefined) | undefined;
|
|
64
|
+
/** The connection string URI. */
|
|
65
|
+
uri?: string | undefined;
|
|
66
|
+
/** The storage adapter instance to be used by Keyv. */
|
|
67
|
+
store?: Store<Value> | undefined;
|
|
68
|
+
/** Default TTL. Can be overridden by specififying a TTL on `.set()`. */
|
|
69
|
+
ttl?: number | undefined;
|
|
70
|
+
/** Specify an adapter to use. e.g `'redis'` or `'mongodb'`. */
|
|
71
|
+
adapter?: 'redis' | 'mongodb' | 'mongo' | 'sqlite' | 'postgresql' | 'postgres' | 'mysql' | undefined;
|
|
72
|
+
/** Enable compression option **/
|
|
73
|
+
compress?: Record<string, unknown> | undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface DeserializedData<Value> {
|
|
77
|
+
value: Value; expires: number | undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface Store<Value> {
|
|
81
|
+
get(key: string): Value | Promise<Value | undefined> | undefined;
|
|
82
|
+
set(key: string, value: Value, ttl?: number): any;
|
|
83
|
+
delete(key: string): boolean | Promise<boolean>;
|
|
84
|
+
clear(): void | Promise<void>;
|
|
85
|
+
has(key: string): boolean | Promise<boolean>;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export = Keyv;
|