@redmix/api 9.0.0-canary.581 → 9.0.0-canary.582
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/auth/index.js +10 -49
- package/dist/auth/parseJWT.js +3 -26
- package/dist/auth/verifiers/base64Sha1Verifier.js +18 -37
- package/dist/auth/verifiers/base64Sha256Verifier.js +18 -37
- package/dist/auth/verifiers/common.js +19 -58
- package/dist/auth/verifiers/index.js +8 -33
- package/dist/auth/verifiers/jwtVerifier.js +17 -47
- package/dist/auth/verifiers/secretKeyVerifier.js +7 -26
- package/dist/auth/verifiers/sha1Verifier.js +18 -37
- package/dist/auth/verifiers/sha256Verifier.js +18 -37
- package/dist/auth/verifiers/skipVerifier.js +4 -23
- package/dist/auth/verifiers/timestampSchemeVerifier.js +18 -33
- package/dist/cache/clients/BaseClient.js +4 -23
- package/dist/cache/clients/InMemoryClient.js +6 -35
- package/dist/cache/clients/MemcachedClient.js +6 -35
- package/dist/cache/clients/RedisClient.js +6 -35
- package/dist/cache/errors.js +3 -26
- package/dist/cache/index.js +14 -52
- package/dist/cjs/auth/index.d.ts +51 -0
- package/dist/cjs/auth/index.d.ts.map +1 -0
- package/dist/cjs/auth/index.js +129 -0
- package/dist/cjs/auth/parseJWT.d.ts +6 -0
- package/dist/cjs/auth/parseJWT.d.ts.map +1 -0
- package/dist/cjs/auth/parseJWT.js +57 -0
- package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts +19 -0
- package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/base64Sha1Verifier.js +77 -0
- package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts +19 -0
- package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/base64Sha256Verifier.js +77 -0
- package/dist/cjs/auth/verifiers/common.d.ts +104 -0
- package/dist/cjs/auth/verifiers/common.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/common.js +99 -0
- package/dist/cjs/auth/verifiers/index.d.ts +8 -0
- package/dist/cjs/auth/verifiers/index.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/index.js +38 -0
- package/dist/cjs/auth/verifiers/jwtVerifier.d.ts +26 -0
- package/dist/cjs/auth/verifiers/jwtVerifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/jwtVerifier.js +86 -0
- package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts +14 -0
- package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/secretKeyVerifier.js +40 -0
- package/dist/cjs/auth/verifiers/sha1Verifier.d.ts +25 -0
- package/dist/cjs/auth/verifiers/sha1Verifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/sha1Verifier.js +85 -0
- package/dist/cjs/auth/verifiers/sha256Verifier.d.ts +25 -0
- package/dist/cjs/auth/verifiers/sha256Verifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/sha256Verifier.js +85 -0
- package/dist/cjs/auth/verifiers/skipVerifier.d.ts +13 -0
- package/dist/cjs/auth/verifiers/skipVerifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/skipVerifier.js +37 -0
- package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts +16 -0
- package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts.map +1 -0
- package/dist/cjs/auth/verifiers/timestampSchemeVerifier.js +81 -0
- package/dist/cjs/bins/redwood.d.ts +9 -0
- package/dist/cjs/bins/redwood.d.ts.map +1 -0
- package/dist/cjs/bins/rwfw.d.ts +3 -0
- package/dist/cjs/bins/rwfw.d.ts.map +1 -0
- package/dist/cjs/bins/tsc.d.ts +3 -0
- package/dist/cjs/bins/tsc.d.ts.map +1 -0
- package/dist/{bins → cjs/bins}/tsc.js +2 -2
- package/dist/cjs/cache/clients/BaseClient.d.ts +11 -0
- package/dist/cjs/cache/clients/BaseClient.d.ts.map +1 -0
- package/dist/cjs/cache/clients/BaseClient.js +27 -0
- package/dist/cjs/cache/clients/InMemoryClient.d.ts +31 -0
- package/dist/cjs/cache/clients/InMemoryClient.d.ts.map +1 -0
- package/dist/cjs/cache/clients/InMemoryClient.js +100 -0
- package/dist/cjs/cache/clients/MemcachedClient.d.ts +16 -0
- package/dist/cjs/cache/clients/MemcachedClient.d.ts.map +1 -0
- package/dist/cjs/cache/clients/MemcachedClient.js +75 -0
- package/dist/cjs/cache/clients/RedisClient.d.ts +20 -0
- package/dist/cjs/cache/clients/RedisClient.d.ts.map +1 -0
- package/dist/cjs/cache/clients/RedisClient.js +79 -0
- package/dist/cjs/cache/errors.d.ts +4 -0
- package/dist/cjs/cache/errors.d.ts.map +1 -0
- package/dist/cjs/cache/errors.js +33 -0
- package/dist/cjs/cache/index.d.ts +35 -0
- package/dist/cjs/cache/index.d.ts.map +1 -0
- package/dist/cjs/cache/index.js +171 -0
- package/dist/cjs/cors.d.ts +16 -0
- package/dist/cjs/cors.d.ts.map +1 -0
- package/dist/cjs/cors.js +93 -0
- package/dist/cjs/errors.d.ts +5 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +38 -0
- package/dist/cjs/event.d.ts +3 -0
- package/dist/cjs/event.d.ts.map +1 -0
- package/dist/cjs/event.js +34 -0
- package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts +4 -0
- package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts.map +1 -0
- package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.js +72 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/logger/index.d.ts +179 -0
- package/dist/cjs/logger/index.d.ts.map +1 -0
- package/dist/cjs/logger/index.js +195 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/transforms.d.ts +35 -0
- package/dist/cjs/transforms.d.ts.map +1 -0
- package/dist/cjs/transforms.js +98 -0
- package/dist/cjs/types.d.ts +25 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/validations/errors.d.ts +101 -0
- package/dist/cjs/validations/errors.d.ts.map +1 -0
- package/dist/cjs/validations/errors.js +298 -0
- package/dist/cjs/validations/validations.d.ts +222 -0
- package/dist/cjs/validations/validations.d.ts.map +1 -0
- package/dist/cjs/validations/validations.js +351 -0
- package/dist/cjs/webhooks/index.d.ts +76 -0
- package/dist/cjs/webhooks/index.d.ts.map +1 -0
- package/dist/cjs/webhooks/index.js +107 -0
- package/dist/cors.js +7 -30
- package/dist/errors.js +3 -26
- package/dist/event.js +5 -28
- package/dist/functions/fixtures/apiGatewayProxyEvent.fixture.js +4 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -46
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +6 -48
- package/dist/package.json +1 -0
- package/dist/transforms.js +6 -33
- package/dist/types.js +1 -16
- package/dist/validations/errors.js +8 -66
- package/dist/validations/validations.js +8 -44
- package/dist/webhooks/index.js +25 -46
- package/package.json +53 -18
- /package/dist/{bins → cjs/bins}/redwood.js +0 -0
- /package/dist/{bins → cjs/bins}/rwfw.js +0 -0
@@ -1,29 +1,10 @@
|
|
1
|
-
"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
var sha1Verifier_exports = {};
|
20
|
-
__export(sha1Verifier_exports, {
|
21
|
-
default: () => sha1Verifier_default,
|
22
|
-
verifySignature: () => verifySignature
|
23
|
-
});
|
24
|
-
module.exports = __toCommonJS(sha1Verifier_exports);
|
25
|
-
var import_crypto = require("crypto");
|
26
|
-
var import_common = require("./common.js");
|
1
|
+
import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
|
2
|
+
import { createHmac, timingSafeEqual } from "crypto";
|
3
|
+
import {
|
4
|
+
WebhookVerificationError,
|
5
|
+
VERIFICATION_ERROR_MESSAGE,
|
6
|
+
DEFAULT_WEBHOOK_SECRET
|
7
|
+
} from "./common.js";
|
27
8
|
function toNormalizedJsonString(payload) {
|
28
9
|
return JSON.stringify(payload).replace(/[^\\]\\u[\da-f]{4}/g, (s) => {
|
29
10
|
return s.substr(0, 3) + s.substr(3).toUpperCase();
|
@@ -31,10 +12,10 @@ function toNormalizedJsonString(payload) {
|
|
31
12
|
}
|
32
13
|
const createSignature = ({
|
33
14
|
payload,
|
34
|
-
secret =
|
15
|
+
secret = DEFAULT_WEBHOOK_SECRET
|
35
16
|
}) => {
|
36
17
|
const algorithm = "sha1";
|
37
|
-
const hmac =
|
18
|
+
const hmac = createHmac(algorithm, secret);
|
38
19
|
payload = typeof payload === "string" ? payload : toNormalizedJsonString(payload);
|
39
20
|
const digest = Buffer.from(
|
40
21
|
algorithm + "=" + hmac.update(payload).digest("hex"),
|
@@ -44,26 +25,26 @@ const createSignature = ({
|
|
44
25
|
};
|
45
26
|
const verifySignature = ({
|
46
27
|
payload,
|
47
|
-
secret =
|
28
|
+
secret = DEFAULT_WEBHOOK_SECRET,
|
48
29
|
signature
|
49
30
|
}) => {
|
50
31
|
try {
|
51
32
|
const algorithm = signature.split("=")[0];
|
52
33
|
const webhookSignature = Buffer.from(signature || "", "utf8");
|
53
|
-
const hmac =
|
34
|
+
const hmac = createHmac(algorithm, secret);
|
54
35
|
payload = typeof payload === "string" ? payload : toNormalizedJsonString(payload);
|
55
36
|
const digest = Buffer.from(
|
56
37
|
algorithm + "=" + hmac.update(payload).digest("hex"),
|
57
38
|
"utf8"
|
58
39
|
);
|
59
|
-
const verified = webhookSignature.length === digest.length &&
|
40
|
+
const verified = webhookSignature.length === digest.length && timingSafeEqual(digest, webhookSignature);
|
60
41
|
if (verified) {
|
61
42
|
return verified;
|
62
43
|
}
|
63
|
-
throw new
|
44
|
+
throw new WebhookVerificationError();
|
64
45
|
} catch (error) {
|
65
|
-
throw new
|
66
|
-
`${
|
46
|
+
throw new WebhookVerificationError(
|
47
|
+
`${VERIFICATION_ERROR_MESSAGE}: ${error.message}`
|
67
48
|
);
|
68
49
|
}
|
69
50
|
};
|
@@ -79,7 +60,7 @@ const sha1Verifier = (_options) => {
|
|
79
60
|
};
|
80
61
|
};
|
81
62
|
var sha1Verifier_default = sha1Verifier;
|
82
|
-
|
83
|
-
|
63
|
+
export {
|
64
|
+
sha1Verifier_default as default,
|
84
65
|
verifySignature
|
85
|
-
}
|
66
|
+
};
|
@@ -1,29 +1,10 @@
|
|
1
|
-
"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
var sha256Verifier_exports = {};
|
20
|
-
__export(sha256Verifier_exports, {
|
21
|
-
default: () => sha256Verifier_default,
|
22
|
-
verifySignature: () => verifySignature
|
23
|
-
});
|
24
|
-
module.exports = __toCommonJS(sha256Verifier_exports);
|
25
|
-
var import_crypto = require("crypto");
|
26
|
-
var import_common = require("./common.js");
|
1
|
+
import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
|
2
|
+
import { createHmac, timingSafeEqual } from "crypto";
|
3
|
+
import {
|
4
|
+
WebhookVerificationError,
|
5
|
+
VERIFICATION_ERROR_MESSAGE,
|
6
|
+
DEFAULT_WEBHOOK_SECRET
|
7
|
+
} from "./common.js";
|
27
8
|
function toNormalizedJsonString(payload) {
|
28
9
|
return JSON.stringify(payload).replace(/[^\\]\\u[\da-f]{4}/g, (s) => {
|
29
10
|
return s.substr(0, 3) + s.substr(3).toUpperCase();
|
@@ -31,10 +12,10 @@ function toNormalizedJsonString(payload) {
|
|
31
12
|
}
|
32
13
|
const createSignature = ({
|
33
14
|
payload,
|
34
|
-
secret =
|
15
|
+
secret = DEFAULT_WEBHOOK_SECRET
|
35
16
|
}) => {
|
36
17
|
const algorithm = "sha256";
|
37
|
-
const hmac =
|
18
|
+
const hmac = createHmac(algorithm, secret);
|
38
19
|
payload = typeof payload === "string" ? payload : toNormalizedJsonString(payload);
|
39
20
|
const digest = Buffer.from(
|
40
21
|
algorithm + "=" + hmac.update(payload).digest("hex"),
|
@@ -44,26 +25,26 @@ const createSignature = ({
|
|
44
25
|
};
|
45
26
|
const verifySignature = ({
|
46
27
|
payload,
|
47
|
-
secret =
|
28
|
+
secret = DEFAULT_WEBHOOK_SECRET,
|
48
29
|
signature
|
49
30
|
}) => {
|
50
31
|
try {
|
51
32
|
const algorithm = signature.split("=")[0];
|
52
33
|
const webhookSignature = Buffer.from(signature || "", "utf8");
|
53
|
-
const hmac =
|
34
|
+
const hmac = createHmac(algorithm, secret);
|
54
35
|
payload = typeof payload === "string" ? payload : toNormalizedJsonString(payload);
|
55
36
|
const digest = Buffer.from(
|
56
37
|
algorithm + "=" + hmac.update(payload).digest("hex"),
|
57
38
|
"utf8"
|
58
39
|
);
|
59
|
-
const verified = webhookSignature.length === digest.length &&
|
40
|
+
const verified = webhookSignature.length === digest.length && timingSafeEqual(digest, webhookSignature);
|
60
41
|
if (verified) {
|
61
42
|
return verified;
|
62
43
|
}
|
63
|
-
throw new
|
44
|
+
throw new WebhookVerificationError();
|
64
45
|
} catch (error) {
|
65
|
-
throw new
|
66
|
-
`${
|
46
|
+
throw new WebhookVerificationError(
|
47
|
+
`${VERIFICATION_ERROR_MESSAGE}: ${error.message}`
|
67
48
|
);
|
68
49
|
}
|
69
50
|
};
|
@@ -79,7 +60,7 @@ const sha256Verifier = (_options) => {
|
|
79
60
|
};
|
80
61
|
};
|
81
62
|
var sha256Verifier_default = sha256Verifier;
|
82
|
-
|
83
|
-
|
63
|
+
export {
|
64
|
+
sha256Verifier_default as default,
|
84
65
|
verifySignature
|
85
|
-
}
|
66
|
+
};
|
@@ -1,26 +1,4 @@
|
|
1
|
-
"
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
var skipVerifier_exports = {};
|
20
|
-
__export(skipVerifier_exports, {
|
21
|
-
default: () => skipVerifier_default
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(skipVerifier_exports);
|
1
|
+
import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
|
24
2
|
const skipVerifier = (_options) => {
|
25
3
|
return {
|
26
4
|
sign: () => {
|
@@ -35,3 +13,6 @@ const skipVerifier = (_options) => {
|
|
35
13
|
};
|
36
14
|
};
|
37
15
|
var skipVerifier_default = skipVerifier;
|
16
|
+
export {
|
17
|
+
skipVerifier_default as default
|
18
|
+
};
|
@@ -1,37 +1,19 @@
|
|
1
|
-
"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
var timestampSchemeVerifier_exports = {};
|
20
|
-
__export(timestampSchemeVerifier_exports, {
|
21
|
-
default: () => timestampSchemeVerifier_default
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(timestampSchemeVerifier_exports);
|
24
|
-
var import_crypto = require("crypto");
|
25
|
-
var import_common = require("./common.js");
|
1
|
+
import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
|
2
|
+
import { createHmac } from "crypto";
|
3
|
+
import {
|
4
|
+
WebhookVerificationError,
|
5
|
+
DEFAULT_WEBHOOK_SECRET,
|
6
|
+
DEFAULT_TOLERANCE
|
7
|
+
} from "./common.js";
|
26
8
|
const getHmac = ({ secret }) => {
|
27
9
|
if (typeof secret === "undefined" || secret === "") {
|
28
|
-
throw new
|
10
|
+
throw new WebhookVerificationError();
|
29
11
|
}
|
30
|
-
return
|
12
|
+
return createHmac("sha256", secret);
|
31
13
|
};
|
32
14
|
const createSignature = ({
|
33
15
|
payload,
|
34
|
-
secret =
|
16
|
+
secret = DEFAULT_WEBHOOK_SECRET,
|
35
17
|
timestamp = Date.now()
|
36
18
|
}) => {
|
37
19
|
const hmac = getHmac({ secret });
|
@@ -40,28 +22,28 @@ const createSignature = ({
|
|
40
22
|
};
|
41
23
|
const verifySignature = ({
|
42
24
|
payload,
|
43
|
-
secret =
|
25
|
+
secret = DEFAULT_WEBHOOK_SECRET,
|
44
26
|
signature,
|
45
27
|
options
|
46
28
|
}) => {
|
47
29
|
const match = /t=(\d+),v1=([\da-f]+)/.exec(signature);
|
48
30
|
if (!match) {
|
49
|
-
throw new
|
31
|
+
throw new WebhookVerificationError();
|
50
32
|
}
|
51
33
|
const signedStamp = Number(match[1]);
|
52
34
|
const signedPayload = match[2];
|
53
35
|
const timestamp = options?.currentTimestampOverride ?? Date.now();
|
54
|
-
const tolerance = options?.tolerance ??
|
36
|
+
const tolerance = options?.tolerance ?? DEFAULT_TOLERANCE;
|
55
37
|
const difference = Math.abs(timestamp - signedStamp);
|
56
38
|
if (difference > tolerance) {
|
57
|
-
throw new
|
39
|
+
throw new WebhookVerificationError();
|
58
40
|
}
|
59
41
|
const hmac = getHmac({ secret });
|
60
42
|
hmac.update(signedStamp + "." + payload);
|
61
43
|
if (hmac.digest("hex") === signedPayload) {
|
62
44
|
return true;
|
63
45
|
}
|
64
|
-
throw new
|
46
|
+
throw new WebhookVerificationError();
|
65
47
|
};
|
66
48
|
const timestampSchemeVerifier = (options) => {
|
67
49
|
return {
|
@@ -79,3 +61,6 @@ const timestampSchemeVerifier = (options) => {
|
|
79
61
|
};
|
80
62
|
};
|
81
63
|
var timestampSchemeVerifier_default = timestampSchemeVerifier;
|
64
|
+
export {
|
65
|
+
timestampSchemeVerifier_default as default
|
66
|
+
};
|
@@ -1,27 +1,8 @@
|
|
1
|
-
"
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
var BaseClient_exports = {};
|
20
|
-
__export(BaseClient_exports, {
|
21
|
-
default: () => BaseClient
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(BaseClient_exports);
|
1
|
+
import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
|
24
2
|
class BaseClient {
|
25
3
|
constructor() {
|
26
4
|
}
|
27
5
|
}
|
6
|
+
export {
|
7
|
+
BaseClient as default
|
8
|
+
};
|
@@ -1,38 +1,6 @@
|
|
1
|
-
"
|
2
|
-
|
3
|
-
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var InMemoryClient_exports = {};
|
30
|
-
__export(InMemoryClient_exports, {
|
31
|
-
default: () => InMemoryClient
|
32
|
-
});
|
33
|
-
module.exports = __toCommonJS(InMemoryClient_exports);
|
34
|
-
var import_BaseClient = __toESM(require("./BaseClient.js"));
|
35
|
-
class InMemoryClient extends import_BaseClient.default {
|
1
|
+
import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
|
2
|
+
import BaseClient from "./BaseClient.js";
|
3
|
+
class InMemoryClient extends BaseClient {
|
36
4
|
storage;
|
37
5
|
// initialize with pre-cached data if needed
|
38
6
|
constructor(data = {}) {
|
@@ -98,3 +66,6 @@ class InMemoryClient extends import_BaseClient.default {
|
|
98
66
|
return !!this.cacheKeyForValue(value);
|
99
67
|
}
|
100
68
|
}
|
69
|
+
export {
|
70
|
+
InMemoryClient as default
|
71
|
+
};
|
@@ -1,38 +1,6 @@
|
|
1
|
-
"
|
2
|
-
|
3
|
-
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var MemcachedClient_exports = {};
|
30
|
-
__export(MemcachedClient_exports, {
|
31
|
-
default: () => MemcachedClient
|
32
|
-
});
|
33
|
-
module.exports = __toCommonJS(MemcachedClient_exports);
|
34
|
-
var import_BaseClient = __toESM(require("./BaseClient.js"));
|
35
|
-
class MemcachedClient extends import_BaseClient.default {
|
1
|
+
import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
|
2
|
+
import BaseClient from "./BaseClient.js";
|
3
|
+
class MemcachedClient extends BaseClient {
|
36
4
|
client;
|
37
5
|
servers;
|
38
6
|
options;
|
@@ -73,3 +41,6 @@ class MemcachedClient extends import_BaseClient.default {
|
|
73
41
|
return this.client?.delete(key);
|
74
42
|
}
|
75
43
|
}
|
44
|
+
export {
|
45
|
+
MemcachedClient as default
|
46
|
+
};
|
@@ -1,38 +1,6 @@
|
|
1
|
-
"
|
2
|
-
|
3
|
-
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var RedisClient_exports = {};
|
30
|
-
__export(RedisClient_exports, {
|
31
|
-
default: () => RedisClient
|
32
|
-
});
|
33
|
-
module.exports = __toCommonJS(RedisClient_exports);
|
34
|
-
var import_BaseClient = __toESM(require("./BaseClient.js"));
|
35
|
-
class RedisClient extends import_BaseClient.default {
|
1
|
+
import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
|
2
|
+
import BaseClient from "./BaseClient.js";
|
3
|
+
class RedisClient extends BaseClient {
|
36
4
|
client;
|
37
5
|
logger;
|
38
6
|
redisOptions;
|
@@ -77,3 +45,6 @@ class RedisClient extends import_BaseClient.default {
|
|
77
45
|
return !!await this.client?.del([key]);
|
78
46
|
}
|
79
47
|
}
|
48
|
+
export {
|
49
|
+
RedisClient as default
|
50
|
+
};
|
package/dist/cache/errors.js
CHANGED
@@ -1,33 +1,10 @@
|
|
1
|
-
"
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
var errors_exports = {};
|
20
|
-
__export(errors_exports, {
|
21
|
-
CacheTimeoutError: () => CacheTimeoutError
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(errors_exports);
|
1
|
+
import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
|
24
2
|
class CacheTimeoutError extends Error {
|
25
3
|
constructor() {
|
26
4
|
super("Timed out waiting for response from the cache server");
|
27
5
|
this.name = "CacheTimeoutError";
|
28
6
|
}
|
29
7
|
}
|
30
|
-
|
31
|
-
0 && (module.exports = {
|
8
|
+
export {
|
32
9
|
CacheTimeoutError
|
33
|
-
}
|
10
|
+
};
|
package/dist/cache/index.js
CHANGED
@@ -1,45 +1,8 @@
|
|
1
|
-
"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var cache_exports = {};
|
30
|
-
__export(cache_exports, {
|
31
|
-
InMemoryClient: () => import_InMemoryClient.default,
|
32
|
-
MemcachedClient: () => import_MemcachedClient.default,
|
33
|
-
RedisClient: () => import_RedisClient.default,
|
34
|
-
cacheKeySeparator: () => cacheKeySeparator,
|
35
|
-
createCache: () => createCache,
|
36
|
-
formatCacheKey: () => formatCacheKey
|
37
|
-
});
|
38
|
-
module.exports = __toCommonJS(cache_exports);
|
39
|
-
var import_errors = require("./errors.js");
|
40
|
-
var import_MemcachedClient = __toESM(require("./clients/MemcachedClient.js"));
|
41
|
-
var import_RedisClient = __toESM(require("./clients/RedisClient.js"));
|
42
|
-
var import_InMemoryClient = __toESM(require("./clients/InMemoryClient.js"));
|
1
|
+
import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
|
2
|
+
import { CacheTimeoutError } from "./errors.js";
|
3
|
+
import { default as default2 } from "./clients/MemcachedClient.js";
|
4
|
+
import { default as default3 } from "./clients/RedisClient.js";
|
5
|
+
import { default as default4 } from "./clients/InMemoryClient.js";
|
43
6
|
const DEFAULT_LATEST_FIELDS = { id: "id", updatedAt: "updatedAt" };
|
44
7
|
const wait = (ms) => {
|
45
8
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
@@ -72,7 +35,7 @@ const createCache = (cacheClient, options) => {
|
|
72
35
|
const result = await Promise.race([
|
73
36
|
client.get(cacheKey),
|
74
37
|
wait(timeout).then(() => {
|
75
|
-
throw new
|
38
|
+
throw new CacheTimeoutError();
|
76
39
|
})
|
77
40
|
]);
|
78
41
|
if (result) {
|
@@ -81,7 +44,7 @@ const createCache = (cacheClient, options) => {
|
|
81
44
|
}
|
82
45
|
} catch (e) {
|
83
46
|
logger?.error(`[Cache] Error GET '${cacheKey}': ${e.message}`);
|
84
|
-
if (e instanceof
|
47
|
+
if (e instanceof CacheTimeoutError && client.disconnect) {
|
85
48
|
logger?.error(`[Cache] Disconnecting current instance...`);
|
86
49
|
await client.disconnect();
|
87
50
|
}
|
@@ -93,7 +56,7 @@ const createCache = (cacheClient, options) => {
|
|
93
56
|
await Promise.race([
|
94
57
|
client.set(cacheKey, data, options2 || {}),
|
95
58
|
wait(timeout).then(() => {
|
96
|
-
throw new
|
59
|
+
throw new CacheTimeoutError();
|
97
60
|
})
|
98
61
|
]);
|
99
62
|
logger?.debug(
|
@@ -143,7 +106,7 @@ const createCache = (cacheClient, options) => {
|
|
143
106
|
await Promise.race([
|
144
107
|
result = client.del(cacheKey),
|
145
108
|
wait(timeout).then(() => {
|
146
|
-
throw new
|
109
|
+
throw new CacheTimeoutError();
|
147
110
|
})
|
148
111
|
]);
|
149
112
|
logger?.debug(`[Cache] DEL '${cacheKey}'`);
|
@@ -160,12 +123,11 @@ const createCache = (cacheClient, options) => {
|
|
160
123
|
deleteCacheKey
|
161
124
|
};
|
162
125
|
};
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
RedisClient,
|
126
|
+
export {
|
127
|
+
default4 as InMemoryClient,
|
128
|
+
default2 as MemcachedClient,
|
129
|
+
default3 as RedisClient,
|
168
130
|
cacheKeySeparator,
|
169
131
|
createCache,
|
170
132
|
formatCacheKey
|
171
|
-
}
|
133
|
+
};
|