ag-common 0.0.894 → 0.0.896
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/LICENSE.md +2 -3
- package/README.md +2 -2
- package/dist/api/helpers/acm.d.ts +1 -1
- package/dist/api/helpers/acm.js +3 -3
- package/dist/api/helpers/api.d.ts +2 -2
- package/dist/api/helpers/api.js +26 -22
- package/dist/api/helpers/apigw.js +4 -4
- package/dist/api/helpers/aws.js +2 -2
- package/dist/api/helpers/cosmos/delete.d.ts +1 -1
- package/dist/api/helpers/cosmos/delete.js +15 -16
- package/dist/api/helpers/cosmos/get.d.ts +3 -3
- package/dist/api/helpers/cosmos/get.js +26 -32
- package/dist/api/helpers/cosmos/index.d.ts +3 -3
- package/dist/api/helpers/cosmos/index.js +1 -1
- package/dist/api/helpers/cosmos/utils.d.ts +1 -1
- package/dist/api/helpers/cosmos/utils.js +3 -7
- package/dist/api/helpers/cosmos/write.d.ts +1 -1
- package/dist/api/helpers/cosmos/write.js +11 -12
- package/dist/api/helpers/dynamo/delete.d.ts +1 -1
- package/dist/api/helpers/dynamo/delete.js +3 -3
- package/dist/api/helpers/dynamo/get.d.ts +2 -2
- package/dist/api/helpers/dynamo/get.js +20 -14
- package/dist/api/helpers/dynamo/index.d.ts +10 -38
- package/dist/api/helpers/dynamo/index.js +4 -4
- package/dist/api/helpers/dynamo/set.d.ts +1 -1
- package/dist/api/helpers/dynamo/set.js +10 -10
- package/dist/api/helpers/dynamo/types.d.ts +3 -3
- package/dist/api/helpers/dynamo/types.js +1 -1
- package/dist/api/helpers/enforceDynamoProvisionCap.d.ts +13 -1
- package/dist/api/helpers/enforceDynamoProvisionCap.js +3 -4
- package/dist/api/helpers/google/apikey.js +1 -1
- package/dist/api/helpers/google/gemini.d.ts +1 -1
- package/dist/api/helpers/google/gemini.js +43 -45
- package/dist/api/helpers/google/index.d.ts +2 -2
- package/dist/api/helpers/index.d.ts +17 -17
- package/dist/api/helpers/retryOnError.js +6 -11
- package/dist/api/helpers/s3.d.ts +9 -9
- package/dist/api/helpers/s3.js +19 -16
- package/dist/api/helpers/ses.d.ts +1 -1
- package/dist/api/helpers/ses.js +9 -9
- package/dist/api/helpers/sqs.d.ts +1 -1
- package/dist/api/helpers/sqs.js +1 -1
- package/dist/api/helpers/ssm.d.ts +1 -1
- package/dist/api/helpers/ssm.js +2 -2
- package/dist/api/helpers/ssmInfra/apigw.d.ts +6 -6
- package/dist/api/helpers/ssmInfra/apigw.js +6 -10
- package/dist/api/helpers/ssmInfra/dynamo.d.ts +2 -2
- package/dist/api/helpers/ssmInfra/dynamo.js +1 -1
- package/dist/api/helpers/ssmInfra/index.d.ts +4 -4
- package/dist/api/helpers/ssmInfra/s3.d.ts +3 -3
- package/dist/api/helpers/ssmInfra/s3.js +1 -1
- package/dist/api/helpers/ssmInfra/sqs.d.ts +3 -3
- package/dist/api/helpers/ssmInfra/sqs.js +1 -1
- package/dist/api/helpers/sts.d.ts +1 -1
- package/dist/api/helpers/sts.js +4 -4
- package/dist/api/helpers/validations.d.ts +2 -2
- package/dist/api/helpers/validations.js +14 -14
- package/dist/api/helpers/zod.d.ts +1 -1
- package/dist/api/helpers/zod.js +21 -27
- package/dist/api/index.d.ts +2 -2
- package/dist/api/types/aws.d.ts +0 -56
- package/dist/api/types/aws.js +0 -1
- package/dist/api/types/index.d.ts +1 -1
- package/dist/common/helpers/array.js +9 -10
- package/dist/common/helpers/async.js +2 -2
- package/dist/common/helpers/binary.d.ts +1 -1
- package/dist/common/helpers/binary.js +1 -1
- package/dist/common/helpers/csv.d.ts +4 -2
- package/dist/common/helpers/csv.js +8 -12
- package/dist/common/helpers/date.d.ts +2 -4
- package/dist/common/helpers/date.js +2 -2
- package/dist/common/helpers/email.js +2 -2
- package/dist/common/helpers/fetch.js +8 -8
- package/dist/common/helpers/generator.js +2 -2
- package/dist/common/helpers/groupBy.js +0 -2
- package/dist/common/helpers/hashCode.js +2 -6
- package/dist/common/helpers/headers.d.ts +20 -20
- package/dist/common/helpers/headers.js +38 -38
- package/dist/common/helpers/i18n.d.ts +2 -2
- package/dist/common/helpers/i18n.js +5 -6
- package/dist/common/helpers/index.d.ts +25 -25
- package/dist/common/helpers/log.d.ts +1 -1
- package/dist/common/helpers/log.js +30 -30
- package/dist/common/helpers/math.d.ts +2 -2
- package/dist/common/helpers/math.js +6 -6
- package/dist/common/helpers/memo.d.ts +1 -1
- package/dist/common/helpers/memo.js +1 -3
- package/dist/common/helpers/node-cache.d.ts +2 -2
- package/dist/common/helpers/node-cache.js +0 -1
- package/dist/common/helpers/object.d.ts +1 -1
- package/dist/common/helpers/object.js +16 -27
- package/dist/common/helpers/secondsInNearest.js +5 -5
- package/dist/common/helpers/stream.js +4 -6
- package/dist/common/helpers/string/base64.js +2 -2
- package/dist/common/helpers/string/chunk.js +1 -1
- package/dist/common/helpers/string/contains.js +1 -3
- package/dist/common/helpers/string/getExtendedStringSegment.js +1 -1
- package/dist/common/helpers/string/index.d.ts +11 -11
- package/dist/common/helpers/string/json.js +1 -1
- package/dist/common/helpers/string/redact.js +38 -39
- package/dist/common/helpers/string/trim.js +4 -4
- package/dist/common/helpers/string/truncate.js +1 -1
- package/dist/common/helpers/string/url.js +7 -8
- package/dist/common/helpers/withRetry.js +7 -7
- package/dist/common/helpers/xml.d.ts +7 -3
- package/dist/common/helpers/xml.js +33 -36
- package/dist/common/index.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/node/helpers/fetch.js +1 -2
- package/dist/node/helpers/fs.js +2 -2
- package/dist/node/helpers/index.d.ts +2 -2
- package/dist/node/index.d.ts +1 -1
- package/dist/ui/components/DarkMode/Base.d.ts +4 -4
- package/dist/ui/components/DarkMode/Base.js +26 -31
- package/dist/ui/components/DarkMode/index.d.ts +2 -2
- package/dist/ui/components/DarkMode/types.d.ts +5 -5
- package/dist/ui/components/HeadersRaw/index.d.ts +2 -2
- package/dist/ui/components/HeadersRaw/index.js +5 -5
- package/dist/ui/components/Markdown/index.d.ts +1 -1
- package/dist/ui/components/Markdown/index.js +10 -10
- package/dist/ui/components/index.d.ts +4 -4
- package/dist/ui/components/shadcn/accordion.d.ts +4 -4
- package/dist/ui/components/shadcn/accordion.js +6 -6
- package/dist/ui/components/shadcn/alert.d.ts +2 -2
- package/dist/ui/components/shadcn/alert.js +6 -6
- package/dist/ui/components/shadcn/avatar.d.ts +2 -2
- package/dist/ui/components/shadcn/avatar.js +4 -4
- package/dist/ui/components/shadcn/button.d.ts +4 -4
- package/dist/ui/components/shadcn/button.js +14 -14
- package/dist/ui/components/shadcn/card.d.ts +2 -2
- package/dist/ui/components/shadcn/card.js +6 -6
- package/dist/ui/components/shadcn/checkbox.d.ts +2 -2
- package/dist/ui/components/shadcn/checkbox.js +3 -3
- package/dist/ui/components/shadcn/dialog.d.ts +10 -10
- package/dist/ui/components/shadcn/dialog.js +9 -11
- package/dist/ui/components/shadcn/divider.d.ts +1 -1
- package/dist/ui/components/shadcn/divider.js +1 -1
- package/dist/ui/components/shadcn/dropdown-list.d.ts +1 -1
- package/dist/ui/components/shadcn/dropdown-list.js +5 -5
- package/dist/ui/components/shadcn/dropdown-menu.d.ts +6 -6
- package/dist/ui/components/shadcn/dropdown-menu.js +11 -11
- package/dist/ui/components/shadcn/index.d.ts +21 -21
- package/dist/ui/components/shadcn/input-selector.d.ts +1 -1
- package/dist/ui/components/shadcn/input-selector.js +10 -12
- package/dist/ui/components/shadcn/input.d.ts +1 -1
- package/dist/ui/components/shadcn/input.js +1 -1
- package/dist/ui/components/shadcn/label.d.ts +3 -3
- package/dist/ui/components/shadcn/label.js +2 -2
- package/dist/ui/components/shadcn/popover.d.ts +2 -2
- package/dist/ui/components/shadcn/popover.js +3 -3
- package/dist/ui/components/shadcn/radio-group.d.ts +2 -2
- package/dist/ui/components/shadcn/radio-group.js +2 -2
- package/dist/ui/components/shadcn/scroll-area.d.ts +2 -2
- package/dist/ui/components/shadcn/scroll-area.js +3 -5
- package/dist/ui/components/shadcn/select.d.ts +2 -2
- package/dist/ui/components/shadcn/select.js +12 -12
- package/dist/ui/components/shadcn/sheet.d.ts +12 -12
- package/dist/ui/components/shadcn/sheet.js +15 -15
- package/dist/ui/components/shadcn/switch.d.ts +2 -2
- package/dist/ui/components/shadcn/switch.js +3 -3
- package/dist/ui/components/shadcn/textarea.d.ts +1 -1
- package/dist/ui/components/shadcn/textarea.js +1 -1
- package/dist/ui/components/shadcn/toast.d.ts +2 -2
- package/dist/ui/components/shadcn/toast.js +25 -25
- package/dist/ui/helpers/cognito.d.ts +1 -1
- package/dist/ui/helpers/cookie/const.js +1 -1
- package/dist/ui/helpers/cookie/get.js +3 -4
- package/dist/ui/helpers/cookie/index.d.ts +5 -5
- package/dist/ui/helpers/cookie/raw.d.ts +1 -1
- package/dist/ui/helpers/cookie/raw.js +8 -9
- package/dist/ui/helpers/cookie/use.d.ts +1 -1
- package/dist/ui/helpers/cookie/use.js +4 -4
- package/dist/ui/helpers/date.js +8 -8
- package/dist/ui/helpers/debounce.js +1 -1
- package/dist/ui/helpers/dom.d.ts +1 -1
- package/dist/ui/helpers/dom.js +4 -14
- package/dist/ui/helpers/index.d.ts +26 -26
- package/dist/ui/helpers/jwt.d.ts +3 -3
- package/dist/ui/helpers/openDialog.d.ts +2 -2
- package/dist/ui/helpers/openDialog.js +8 -8
- package/dist/ui/helpers/plural.js +1 -1
- package/dist/ui/helpers/routes.d.ts +2 -2
- package/dist/ui/helpers/routes.js +14 -15
- package/dist/ui/helpers/serviceWorker.js +1 -1
- package/dist/ui/helpers/useContextMenu.d.ts +1 -1
- package/dist/ui/helpers/useContextMenu.js +9 -10
- package/dist/ui/helpers/useElementAttribute.js +3 -5
- package/dist/ui/helpers/useGranularHook.d.ts +1 -1
- package/dist/ui/helpers/useGranularHook.js +2 -3
- package/dist/ui/helpers/useInterval.d.ts +2 -2
- package/dist/ui/helpers/useInterval.js +2 -2
- package/dist/ui/helpers/useIsInViewport.d.ts +1 -1
- package/dist/ui/helpers/useIsInViewport.js +0 -1
- package/dist/ui/helpers/useLocalStorage.js +6 -6
- package/dist/ui/helpers/useLockBodyScroll.js +2 -2
- package/dist/ui/helpers/useOnClickOutside.d.ts +1 -1
- package/dist/ui/helpers/useOnClickOutside.js +3 -6
- package/dist/ui/helpers/useOnScroll.d.ts +1 -1
- package/dist/ui/helpers/useOnScroll.js +3 -4
- package/dist/ui/helpers/useOverloadPageSearch.js +8 -10
- package/dist/ui/helpers/useQueryString.js +7 -7
- package/dist/ui/helpers/useResize.js +5 -6
- package/dist/ui/helpers/useTimeout.js +1 -1
- package/dist/ui/helpers/useTooltip.d.ts +2 -2
- package/dist/ui/helpers/useTooltip.js +5 -7
- package/dist/ui/helpers/utils.d.ts +2 -2
- package/dist/ui/icons/Checkmark.d.ts +2 -2
- package/dist/ui/icons/Checkmark.js +1 -1
- package/dist/ui/icons/ChevronRight.d.ts +1 -1
- package/dist/ui/icons/Circle.d.ts +2 -2
- package/dist/ui/icons/Circle.js +1 -1
- package/dist/ui/icons/CircleDot.d.ts +2 -2
- package/dist/ui/icons/Cog.d.ts +2 -2
- package/dist/ui/icons/Computer.d.ts +2 -2
- package/dist/ui/icons/Door.d.ts +1 -1
- package/dist/ui/icons/Hamburger.d.ts +1 -1
- package/dist/ui/icons/HorizontalDots.d.ts +1 -1
- package/dist/ui/icons/House.d.ts +2 -2
- package/dist/ui/icons/Magnify.d.ts +2 -2
- package/dist/ui/icons/Magnify.js +1 -1
- package/dist/ui/icons/Moon.d.ts +2 -2
- package/dist/ui/icons/Pencil.d.ts +1 -1
- package/dist/ui/icons/Save.d.ts +1 -1
- package/dist/ui/icons/Sun.d.ts +1 -1
- package/dist/ui/icons/Sun.js +1 -1
- package/dist/ui/icons/Undo.d.ts +1 -1
- package/dist/ui/icons/UserOutline.d.ts +1 -1
- package/dist/ui/icons/Warning.d.ts +2 -2
- package/dist/ui/icons/Warning.js +1 -1
- package/dist/ui/icons/index.d.ts +32 -74
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/styles/colours.js +29 -29
- package/dist/ui/styles/common.d.ts +1 -1
- package/dist/ui/styles/common.js +10 -10
- package/dist/ui/styles/index.d.ts +3 -3
- package/package.json +65 -75
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
1
|
+
export * from "./acm";
|
|
2
|
+
export * from "./api";
|
|
3
|
+
export * from "./apigw";
|
|
4
|
+
export * from "./aws";
|
|
5
|
+
export * from "./cosmos";
|
|
6
|
+
export * from "./dynamo";
|
|
7
|
+
export * from "./enforceDynamoProvisionCap";
|
|
8
|
+
export * from "./google";
|
|
9
|
+
export * from "./retryOnError";
|
|
10
|
+
export * from "./s3";
|
|
11
|
+
export * from "./ses";
|
|
12
|
+
export * from "./sqs";
|
|
13
|
+
export * from "./ssm";
|
|
14
|
+
export * from "./ssmInfra";
|
|
15
|
+
export * from "./sts";
|
|
16
|
+
export * from "./validations";
|
|
17
|
+
export * from "./zod";
|
|
@@ -3,19 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.sleep = exports.isRetryableApiError = exports.isOverloadedApiKeyError = exports.retryableErrorMessages = exports.overloadedMessages = void 0;
|
|
4
4
|
exports.retryOnError = retryOnError;
|
|
5
5
|
const log_1 = require("../../common/helpers/log");
|
|
6
|
-
exports.overloadedMessages = [
|
|
7
|
-
'429',
|
|
8
|
-
'current usage',
|
|
9
|
-
'current quota',
|
|
10
|
-
'overloaded',
|
|
11
|
-
];
|
|
6
|
+
exports.overloadedMessages = ["429", "current usage", "current quota", "overloaded"];
|
|
12
7
|
exports.retryableErrorMessages = [
|
|
13
8
|
...exports.overloadedMessages,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
"500",
|
|
10
|
+
"503",
|
|
11
|
+
"safety",
|
|
12
|
+
"invalid_type",
|
|
13
|
+
"expected",
|
|
19
14
|
];
|
|
20
15
|
const errorContainsAnyMessage = (error, messages) => {
|
|
21
16
|
const message = error.message.toLowerCase();
|
package/dist/api/helpers/s3.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
4
|
-
export type StorageProvider =
|
|
1
|
+
import type { Buffer } from "buffer";
|
|
2
|
+
import type { GetObjectCommandOutput } from "@aws-sdk/client-s3";
|
|
3
|
+
import { S3Client } from "@aws-sdk/client-s3";
|
|
4
|
+
export type StorageProvider = "s3" | "r2";
|
|
5
5
|
export type StorageConfig = {
|
|
6
|
-
provider:
|
|
6
|
+
provider: "s3";
|
|
7
7
|
region?: string;
|
|
8
8
|
endpoint?: string;
|
|
9
9
|
accountId?: string;
|
|
10
10
|
accessKeyId?: string;
|
|
11
11
|
secretAccessKey?: string;
|
|
12
12
|
} | {
|
|
13
|
-
provider:
|
|
13
|
+
provider: "r2";
|
|
14
14
|
accountId: string;
|
|
15
15
|
accessKeyId?: string;
|
|
16
16
|
secretAccessKey?: string;
|
|
@@ -32,18 +32,18 @@ export declare const getS3Object: ({ fileurl: { Bucket, Key }, }: {
|
|
|
32
32
|
export interface IS3Object {
|
|
33
33
|
bucket: string;
|
|
34
34
|
key: string;
|
|
35
|
-
content:
|
|
35
|
+
content: NonNullable<GetObjectCommandOutput["Body"]>;
|
|
36
36
|
}
|
|
37
37
|
/** function generator to get s3 files */
|
|
38
|
-
export declare function getS3Objects({ bucket, keys
|
|
38
|
+
export declare function getS3Objects({ bucket, keys }: {
|
|
39
39
|
bucket: string;
|
|
40
40
|
keys: string[];
|
|
41
41
|
}): AsyncGenerator<{
|
|
42
42
|
error: string;
|
|
43
43
|
data?: undefined;
|
|
44
44
|
} | {
|
|
45
|
-
data: IS3Object;
|
|
46
45
|
error?: undefined;
|
|
46
|
+
data: IS3Object;
|
|
47
47
|
}, void, unknown>;
|
|
48
48
|
export declare const putS3Object: ({ Body, Bucket, Key, ContentType, CacheControl, }: {
|
|
49
49
|
ContentType?: string;
|
package/dist/api/helpers/s3.js
CHANGED
|
@@ -14,7 +14,7 @@ const object_1 = require("../../common/helpers/object");
|
|
|
14
14
|
// Cache for memoization
|
|
15
15
|
const clientCache = new Map();
|
|
16
16
|
const getCacheKey = (config) => {
|
|
17
|
-
if (config.provider ===
|
|
17
|
+
if (config.provider === "r2") {
|
|
18
18
|
return JSON.stringify({
|
|
19
19
|
provider: config.provider,
|
|
20
20
|
accountId: config.accountId,
|
|
@@ -34,10 +34,10 @@ const createStorageClient = (config) => {
|
|
|
34
34
|
return cachedClient;
|
|
35
35
|
}
|
|
36
36
|
let client;
|
|
37
|
-
if (config.provider ===
|
|
37
|
+
if (config.provider === "r2") {
|
|
38
38
|
const accountId = config.accountId || process.env.CLOUDFLARE_ACCOUNT_ID;
|
|
39
39
|
if (!accountId) {
|
|
40
|
-
throw new Error(
|
|
40
|
+
throw new Error("Account ID is required for R2. Set CLOUDFLARE_ACCOUNT_ID env var or provide accountId in config");
|
|
41
41
|
}
|
|
42
42
|
client = new client_s3_1.S3Client({
|
|
43
43
|
endpoint: `https://${accountId}.r2.cloudflarestorage.com`,
|
|
@@ -50,7 +50,7 @@ const createStorageClient = (config) => {
|
|
|
50
50
|
},
|
|
51
51
|
}
|
|
52
52
|
: {}),
|
|
53
|
-
region: config.region ??
|
|
53
|
+
region: config.region ?? "auto",
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
@@ -68,14 +68,14 @@ const setS3 = (config) => {
|
|
|
68
68
|
};
|
|
69
69
|
exports.setS3 = setS3;
|
|
70
70
|
(0, exports.setS3)({
|
|
71
|
-
provider:
|
|
72
|
-
region:
|
|
71
|
+
provider: "s3",
|
|
72
|
+
region: "ap-southeast-2",
|
|
73
73
|
});
|
|
74
74
|
const getS3Object = async ({ fileurl: { Bucket, Key }, }) => {
|
|
75
75
|
try {
|
|
76
76
|
const r = await s3.send(new client_s3_1.GetObjectCommand({ Bucket, Key }));
|
|
77
77
|
if (!r.Body) {
|
|
78
|
-
throw new Error(
|
|
78
|
+
throw new Error("no body returned");
|
|
79
79
|
}
|
|
80
80
|
const data = {
|
|
81
81
|
bucket: Bucket,
|
|
@@ -90,7 +90,7 @@ const getS3Object = async ({ fileurl: { Bucket, Key }, }) => {
|
|
|
90
90
|
};
|
|
91
91
|
exports.getS3Object = getS3Object;
|
|
92
92
|
/** function generator to get s3 files */
|
|
93
|
-
async function* getS3Objects({ bucket, keys
|
|
93
|
+
async function* getS3Objects({ bucket, keys }) {
|
|
94
94
|
let toProcess = keys.map((Key) => ({
|
|
95
95
|
Bucket: bucket,
|
|
96
96
|
Key,
|
|
@@ -99,8 +99,9 @@ async function* getS3Objects({ bucket, keys, }) {
|
|
|
99
99
|
const { part, rest } = (0, array_1.take)(toProcess, 1);
|
|
100
100
|
toProcess = rest;
|
|
101
101
|
const fileurl = part[0];
|
|
102
|
+
// oxlint-disable-next-line no-await-in-loop -- generator results must preserve input order
|
|
102
103
|
const g = await (0, exports.getS3Object)({ fileurl });
|
|
103
|
-
if (
|
|
104
|
+
if ("error" in g) {
|
|
104
105
|
yield { error: g.error };
|
|
105
106
|
}
|
|
106
107
|
else {
|
|
@@ -108,7 +109,7 @@ async function* getS3Objects({ bucket, keys, }) {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
|
-
const putS3Object = async ({ Body, Bucket, Key, ContentType, CacheControl =
|
|
112
|
+
const putS3Object = async ({ Body, Bucket, Key, ContentType, CacheControl = "public, max-age=300", }) => {
|
|
112
113
|
try {
|
|
113
114
|
const r = await s3.send(new client_s3_1.PutObjectCommand({ Body, Bucket, Key, ContentType, CacheControl }));
|
|
114
115
|
const code = r.$metadata.httpStatusCode;
|
|
@@ -141,12 +142,13 @@ const deleteFiles = async ({ Bucket, Keys, }) => {
|
|
|
141
142
|
while (toDelete.length > 0) {
|
|
142
143
|
const { part, rest } = (0, array_1.take)(toDelete, 900);
|
|
143
144
|
toDelete = rest;
|
|
145
|
+
// oxlint-disable-next-line no-await-in-loop -- deletion batches are intentionally bounded
|
|
144
146
|
const res = await s3.send(new client_s3_1.DeleteObjectsCommand({
|
|
145
147
|
Bucket,
|
|
146
148
|
Delete: { Objects: part },
|
|
147
149
|
}));
|
|
148
150
|
if (!res.Deleted?.length) {
|
|
149
|
-
throw new Error(
|
|
151
|
+
throw new Error("no deleted files");
|
|
150
152
|
}
|
|
151
153
|
deleted += res.Deleted.length;
|
|
152
154
|
(0, log_1.debug)(`deleted ${deleted} files`);
|
|
@@ -163,7 +165,7 @@ const copyFile = async ({ Bucket, fromKey, toKey, deleteSource = false, }) => {
|
|
|
163
165
|
(0, log_1.debug)(`copying s3 file from ${Bucket}- ${fromKey} to ${toKey}`);
|
|
164
166
|
await s3.send(new client_s3_1.CopyObjectCommand({
|
|
165
167
|
//incl bucket
|
|
166
|
-
CopySource: Bucket +
|
|
168
|
+
CopySource: Bucket + "/" + fromKey,
|
|
167
169
|
//dest
|
|
168
170
|
Bucket,
|
|
169
171
|
Key: toKey,
|
|
@@ -186,6 +188,7 @@ async function listFiles(bucketName, opt) {
|
|
|
186
188
|
const ret = [];
|
|
187
189
|
let response;
|
|
188
190
|
do {
|
|
191
|
+
// oxlint-disable-next-line no-await-in-loop -- pagination depends on the prior continuation token
|
|
189
192
|
response = await s3.send(new client_s3_1.ListObjectsV2Command({
|
|
190
193
|
Bucket: bucketName,
|
|
191
194
|
ContinuationToken: response?.NextContinuationToken,
|
|
@@ -198,7 +201,7 @@ async function listFiles(bucketName, opt) {
|
|
|
198
201
|
return { data: (0, array_1.distinct)(ret.filter((r) => r)) };
|
|
199
202
|
}
|
|
200
203
|
catch (err) {
|
|
201
|
-
(0, log_1.error)(
|
|
204
|
+
(0, log_1.error)("Error", err);
|
|
202
205
|
return { error: err.toString() };
|
|
203
206
|
}
|
|
204
207
|
}
|
|
@@ -222,8 +225,8 @@ async function getPresignedPostURL({ bucket, key, maxMb = 5, }) {
|
|
|
222
225
|
Key: key,
|
|
223
226
|
Expires: 600,
|
|
224
227
|
Conditions: [
|
|
225
|
-
[
|
|
226
|
-
[
|
|
228
|
+
["content-length-range", 0, maxMb * 1049000], // content length restrictions: 0-5MB
|
|
229
|
+
["starts-with", "$Content-Type", "image/"],
|
|
227
230
|
],
|
|
228
231
|
});
|
|
229
232
|
const fields = (0, object_1.copy)(ps.fields);
|
|
@@ -253,7 +256,7 @@ async function getPresignedPutUrl({ bucket, key, contentType, contentLength, exp
|
|
|
253
256
|
expiresIn,
|
|
254
257
|
// Sign the Content-Length header so it's enforced
|
|
255
258
|
...(contentLength !== undefined && {
|
|
256
|
-
signableHeaders: new Set([
|
|
259
|
+
signableHeaders: new Set(["content-length"]),
|
|
257
260
|
}),
|
|
258
261
|
});
|
|
259
262
|
return { data: url };
|
package/dist/api/helpers/ses.js
CHANGED
|
@@ -9,16 +9,16 @@ const setSes = (region) => {
|
|
|
9
9
|
return raw;
|
|
10
10
|
};
|
|
11
11
|
exports.setSes = setSes;
|
|
12
|
-
exports.ses = (0, exports.setSes)(
|
|
12
|
+
exports.ses = (0, exports.setSes)("ap-southeast-2");
|
|
13
13
|
const sendEmail = async ({ to, message, subject, sourceArn, from, }) => {
|
|
14
14
|
try {
|
|
15
|
-
const sourceArnRegion = sourceArn.match(
|
|
15
|
+
const sourceArnRegion = sourceArn.match(":ses:(.*?):")?.[1];
|
|
16
16
|
if (sourceArn !== exports.ses.config.region && sourceArnRegion) {
|
|
17
|
-
(0, log_1.warn)(
|
|
17
|
+
(0, log_1.warn)("ses arn not equal to config region changing to:" + sourceArnRegion);
|
|
18
18
|
(0, exports.setSes)(sourceArnRegion);
|
|
19
19
|
}
|
|
20
|
-
const ishtml = message.startsWith(
|
|
21
|
-
(0, log_1.warn)(
|
|
20
|
+
const ishtml = message.startsWith("<!DOCTYPE HTML") || message.startsWith("<html");
|
|
21
|
+
(0, log_1.warn)("sending email. html=" + ishtml);
|
|
22
22
|
await exports.ses.send(new client_ses_1.SendEmailCommand({
|
|
23
23
|
Destination: {
|
|
24
24
|
CcAddresses: [],
|
|
@@ -29,18 +29,18 @@ const sendEmail = async ({ to, message, subject, sourceArn, from, }) => {
|
|
|
29
29
|
...(ishtml && {
|
|
30
30
|
Html: {
|
|
31
31
|
Data: message,
|
|
32
|
-
Charset:
|
|
32
|
+
Charset: "UTF-8",
|
|
33
33
|
},
|
|
34
34
|
}),
|
|
35
35
|
...(!ishtml && {
|
|
36
36
|
Text: {
|
|
37
37
|
Data: message,
|
|
38
|
-
Charset:
|
|
38
|
+
Charset: "UTF-8",
|
|
39
39
|
},
|
|
40
40
|
}),
|
|
41
41
|
},
|
|
42
42
|
Subject: {
|
|
43
|
-
Charset:
|
|
43
|
+
Charset: "UTF-8",
|
|
44
44
|
Data: subject,
|
|
45
45
|
},
|
|
46
46
|
},
|
|
@@ -51,7 +51,7 @@ const sendEmail = async ({ to, message, subject, sourceArn, from, }) => {
|
|
|
51
51
|
return {};
|
|
52
52
|
}
|
|
53
53
|
catch (e) {
|
|
54
|
-
(0, log_1.warn)(
|
|
54
|
+
(0, log_1.warn)("ses send error:" + JSON.stringify(e));
|
|
55
55
|
return { error: e.toString() };
|
|
56
56
|
}
|
|
57
57
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SQSClient } from
|
|
1
|
+
import { SQSClient } from "@aws-sdk/client-sqs";
|
|
2
2
|
export declare const setSqs: (region: string) => SQSClient;
|
|
3
3
|
export declare const sqs: SQSClient;
|
|
4
4
|
export declare const sendMessages: <T>(items: T[], queueUrl: string) => Promise<{
|
package/dist/api/helpers/sqs.js
CHANGED
|
@@ -8,7 +8,7 @@ const setSqs = (region) => {
|
|
|
8
8
|
return raw;
|
|
9
9
|
};
|
|
10
10
|
exports.setSqs = setSqs;
|
|
11
|
-
exports.sqs = (0, exports.setSqs)(
|
|
11
|
+
exports.sqs = (0, exports.setSqs)("ap-southeast-2");
|
|
12
12
|
const sendMessages = async (items, queueUrl) => {
|
|
13
13
|
const p = await exports.sqs.send(new client_sqs_1.SendMessageBatchCommand({
|
|
14
14
|
QueueUrl: queueUrl,
|
package/dist/api/helpers/ssm.js
CHANGED
|
@@ -10,7 +10,7 @@ const base64_1 = require("../../common/helpers/string/base64");
|
|
|
10
10
|
const saveToSsm = ({ stack, path, value, }) => {
|
|
11
11
|
const name = (0, base64_1.toBase64)(path);
|
|
12
12
|
new aws_cdk_lib_1.aws_ssm.StringParameter(stack, name, {
|
|
13
|
-
allowedPattern:
|
|
13
|
+
allowedPattern: ".*",
|
|
14
14
|
description: `${name} (cdk)`,
|
|
15
15
|
parameterName: path,
|
|
16
16
|
stringValue: value,
|
|
@@ -25,5 +25,5 @@ exports.loadSsmString = loadSsmString;
|
|
|
25
25
|
const loadSsmStringSynth = ({ stack, path, }) => aws_cdk_lib_1.aws_ssm.StringParameter.valueFromLookup(stack, path);
|
|
26
26
|
exports.loadSsmStringSynth = loadSsmStringSynth;
|
|
27
27
|
/** load a csv from ssm */
|
|
28
|
-
const loadSsmStringList = ({ stack, path, }) => aws_cdk_lib_1.Fn.split(
|
|
28
|
+
const loadSsmStringList = ({ stack, path, }) => aws_cdk_lib_1.Fn.split(",", (0, exports.loadSsmString)({ stack, path }));
|
|
29
29
|
exports.loadSsmStringList = loadSsmStringList;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Stack } from
|
|
2
|
-
import { aws_iam as iam } from
|
|
3
|
-
import type { IWebSocketApi, WebSocketStage } from
|
|
4
|
-
import { WebSocketApi } from
|
|
5
|
-
import type { IUser } from
|
|
6
|
-
export declare const generateApigwRef: ({ stack, baseKey
|
|
1
|
+
import type { Stack } from "aws-cdk-lib";
|
|
2
|
+
import { aws_iam as iam } from "aws-cdk-lib";
|
|
3
|
+
import type { IWebSocketApi, WebSocketStage } from "aws-cdk-lib/aws-apigatewayv2";
|
|
4
|
+
import { WebSocketApi } from "aws-cdk-lib/aws-apigatewayv2";
|
|
5
|
+
import type { IUser } from "aws-cdk-lib/aws-iam";
|
|
6
|
+
export declare const generateApigwRef: ({ stack, baseKey }: {
|
|
7
7
|
stack: Stack;
|
|
8
8
|
baseKey: string;
|
|
9
9
|
}) => {
|
|
@@ -6,7 +6,7 @@ exports.grantWebSocketManageConnectionsToRole = grantWebSocketManageConnectionsT
|
|
|
6
6
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
7
7
|
const aws_apigatewayv2_1 = require("aws-cdk-lib/aws-apigatewayv2");
|
|
8
8
|
const ssm_1 = require("../ssm");
|
|
9
|
-
const generateApigwRef = ({ stack, baseKey
|
|
9
|
+
const generateApigwRef = ({ stack, baseKey }) => {
|
|
10
10
|
const webSocketId = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/id` });
|
|
11
11
|
const apiEndpoint = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/endpoint` });
|
|
12
12
|
const stageName = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/stage` });
|
|
@@ -25,22 +25,18 @@ const generateApigwSSMParams = ({ stack, api, baseKey, stage, }) => {
|
|
|
25
25
|
exports.generateApigwSSMParams = generateApigwSSMParams;
|
|
26
26
|
function grantWebSocketManageConnectionsToUser(stack, apiGw, stage, user) {
|
|
27
27
|
const statement = new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
28
|
-
actions: [
|
|
29
|
-
resources: [
|
|
30
|
-
`arn:aws:execute-api:${stack.region}:${stack.account}:${apiGw.apiId}/${stage}/*`,
|
|
31
|
-
],
|
|
28
|
+
actions: ["execute-api:ManageConnections"],
|
|
29
|
+
resources: [`arn:aws:execute-api:${stack.region}:${stack.account}:${apiGw.apiId}/${stage}/*`],
|
|
32
30
|
});
|
|
33
|
-
const policy = new aws_cdk_lib_1.aws_iam.ManagedPolicy(stack,
|
|
31
|
+
const policy = new aws_cdk_lib_1.aws_iam.ManagedPolicy(stack, "WebSocketConnectionPolicy", {
|
|
34
32
|
statements: [statement],
|
|
35
33
|
});
|
|
36
34
|
user.addManagedPolicy(policy);
|
|
37
35
|
}
|
|
38
36
|
function grantWebSocketManageConnectionsToRole(stack, apiGw, stage, ref) {
|
|
39
37
|
const statement = new aws_cdk_lib_1.aws_iam.PolicyStatement({
|
|
40
|
-
actions: [
|
|
41
|
-
resources: [
|
|
42
|
-
`arn:aws:execute-api:${stack.region}:${stack.account}:${apiGw.apiId}/${stage}/*`,
|
|
43
|
-
],
|
|
38
|
+
actions: ["execute-api:ManageConnections"],
|
|
39
|
+
resources: [`arn:aws:execute-api:${stack.region}:${stack.account}:${apiGw.apiId}/${stage}/*`],
|
|
44
40
|
});
|
|
45
41
|
ref.addToRolePolicy(statement);
|
|
46
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Stack } from
|
|
2
|
-
import { aws_dynamodb as dynamodb } from
|
|
1
|
+
import type { Stack } from "aws-cdk-lib";
|
|
2
|
+
import { aws_dynamodb as dynamodb } from "aws-cdk-lib";
|
|
3
3
|
export declare const generateTableRef: ({ stack, baseKey, hasStream, hasGSI, }: {
|
|
4
4
|
hasStream: boolean;
|
|
5
5
|
hasGSI: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./apigw";
|
|
2
|
+
export * from "./dynamo";
|
|
3
|
+
export * from "./s3";
|
|
4
|
+
export * from "./sqs";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Stack } from
|
|
2
|
-
import { aws_s3 as s3 } from
|
|
1
|
+
import type { Stack } from "aws-cdk-lib";
|
|
2
|
+
import { aws_s3 as s3 } from "aws-cdk-lib";
|
|
3
3
|
export declare const generateS3SSMParams: ({ stack, bucket, baseKey, }: {
|
|
4
4
|
stack: Stack;
|
|
5
5
|
bucket: s3.IBucket;
|
|
6
6
|
baseKey: string;
|
|
7
7
|
}) => void;
|
|
8
|
-
export declare const generateBucketRef: ({ stack, baseKey
|
|
8
|
+
export declare const generateBucketRef: ({ stack, baseKey }: {
|
|
9
9
|
stack: Stack;
|
|
10
10
|
baseKey: string;
|
|
11
11
|
}) => s3.IBucket;
|
|
@@ -8,7 +8,7 @@ const generateS3SSMParams = ({ stack, bucket, baseKey, }) => {
|
|
|
8
8
|
(0, ssm_1.saveToSsm)({ stack, path: `${baseKey}/name`, value: bucket.bucketName });
|
|
9
9
|
};
|
|
10
10
|
exports.generateS3SSMParams = generateS3SSMParams;
|
|
11
|
-
const generateBucketRef = ({ stack, baseKey
|
|
11
|
+
const generateBucketRef = ({ stack, baseKey }) => {
|
|
12
12
|
const bucketName = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/name` });
|
|
13
13
|
return aws_cdk_lib_1.aws_s3.Bucket.fromBucketAttributes(stack, baseKey, {
|
|
14
14
|
bucketArn: (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/arn` }),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Stack } from
|
|
2
|
-
import { aws_sqs as sqs } from
|
|
1
|
+
import type { Stack } from "aws-cdk-lib";
|
|
2
|
+
import { aws_sqs as sqs } from "aws-cdk-lib";
|
|
3
3
|
export declare const generateSqsSSMParams: ({ stack, queue, baseKey, }: {
|
|
4
4
|
stack: Stack;
|
|
5
5
|
queue: sqs.IQueue;
|
|
6
6
|
baseKey: string;
|
|
7
7
|
}) => void;
|
|
8
|
-
export declare const generateQueueRef: ({ stack, baseKey
|
|
8
|
+
export declare const generateQueueRef: ({ stack, baseKey }: {
|
|
9
9
|
stack: Stack;
|
|
10
10
|
baseKey: string;
|
|
11
11
|
}) => sqs.IQueue;
|
|
@@ -9,7 +9,7 @@ const generateSqsSSMParams = ({ stack, queue, baseKey, }) => {
|
|
|
9
9
|
(0, ssm_1.saveToSsm)({ stack, path: `${baseKey}/url`, value: queue.queueUrl });
|
|
10
10
|
};
|
|
11
11
|
exports.generateSqsSSMParams = generateSqsSSMParams;
|
|
12
|
-
const generateQueueRef = ({ stack, baseKey
|
|
12
|
+
const generateQueueRef = ({ stack, baseKey }) => {
|
|
13
13
|
const queueArn = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/arn` });
|
|
14
14
|
return aws_cdk_lib_1.aws_sqs.Queue.fromQueueAttributes(stack, baseKey, {
|
|
15
15
|
queueArn,
|
package/dist/api/helpers/sts.js
CHANGED
|
@@ -9,7 +9,7 @@ const setSts = (region) => {
|
|
|
9
9
|
return raw;
|
|
10
10
|
};
|
|
11
11
|
exports.setSts = setSts;
|
|
12
|
-
exports.sts = (0, exports.setSts)(
|
|
12
|
+
exports.sts = (0, exports.setSts)("ap-southeast-2");
|
|
13
13
|
/**
|
|
14
14
|
* assume sts role
|
|
15
15
|
* @returns {string} assumed accountId
|
|
@@ -19,16 +19,16 @@ async function assumeRole({ assumeRoleArn, region, }) {
|
|
|
19
19
|
(0, log_1.info)(`assuming:${assumeRoleArn} in region:${region}`);
|
|
20
20
|
const data = await exports.sts.send(new client_sts_1.AssumeRoleCommand({
|
|
21
21
|
RoleArn: assumeRoleArn,
|
|
22
|
-
RoleSessionName:
|
|
22
|
+
RoleSessionName: "stssession",
|
|
23
23
|
}));
|
|
24
24
|
if (!data.Credentials) {
|
|
25
|
-
return { error:
|
|
25
|
+
return { error: "aws assume role error" };
|
|
26
26
|
}
|
|
27
27
|
if (!data.Credentials.AccessKeyId ||
|
|
28
28
|
!data.Credentials.SecretAccessKey ||
|
|
29
29
|
!data.Credentials.SessionToken ||
|
|
30
30
|
!data.Credentials.Expiration) {
|
|
31
|
-
return { error:
|
|
31
|
+
return { error: "missing cred values error" };
|
|
32
32
|
}
|
|
33
33
|
return {
|
|
34
34
|
data: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { User } from
|
|
2
|
-
import type { APIGatewayProxyResult } from
|
|
1
|
+
import type { User } from "../../ui/helpers/jwt";
|
|
2
|
+
import type { APIGatewayProxyResult } from "../types";
|
|
3
3
|
export interface IGetAndValidateToken {
|
|
4
4
|
/**
|
|
5
5
|
* default ap-southeast-2
|
|
@@ -41,7 +41,7 @@ const jwtVerify = async ({ token, jwksUri, issuer, }) => {
|
|
|
41
41
|
});
|
|
42
42
|
}, {
|
|
43
43
|
issuer,
|
|
44
|
-
algorithms: [
|
|
44
|
+
algorithms: ["RS256"],
|
|
45
45
|
}, (errorV, decoded) => {
|
|
46
46
|
if (errorV) {
|
|
47
47
|
reject(errorV);
|
|
@@ -52,21 +52,21 @@ const jwtVerify = async ({ token, jwksUri, issuer, }) => {
|
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
54
|
/** extracts user details from oauth token */
|
|
55
|
-
const getAndValidateToken = async ({ tokenRaw, jwksRegion =
|
|
55
|
+
const getAndValidateToken = async ({ tokenRaw, jwksRegion = "ap-southeast-2", COGNITO_USER_POOL_ID, }) => {
|
|
56
56
|
const jwksUri = `https://cognito-idp.${jwksRegion}.amazonaws.com/${COGNITO_USER_POOL_ID}/.well-known/jwks.json`;
|
|
57
57
|
const issuer = `https://cognito-idp.${jwksRegion}.amazonaws.com/${COGNITO_USER_POOL_ID}`;
|
|
58
|
-
let token =
|
|
58
|
+
let token = "";
|
|
59
59
|
try {
|
|
60
60
|
if (!tokenRaw) {
|
|
61
|
-
const m =
|
|
61
|
+
const m = "auth error: no auth headers";
|
|
62
62
|
(0, log_1.error)(m);
|
|
63
63
|
return {
|
|
64
64
|
error: (0, api_1.returnCode)(403, m),
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
token = tokenRaw.substring(tokenRaw.indexOf(
|
|
67
|
+
token = tokenRaw.substring(tokenRaw.indexOf(" ") + 1);
|
|
68
68
|
if (!token) {
|
|
69
|
-
const m =
|
|
69
|
+
const m = "auth error: no token";
|
|
70
70
|
(0, log_1.error)(m);
|
|
71
71
|
return {
|
|
72
72
|
error: (0, api_1.returnCode)(403, m),
|
|
@@ -78,7 +78,7 @@ const getAndValidateToken = async ({ tokenRaw, jwksRegion = 'ap-southeast-2', CO
|
|
|
78
78
|
const decoded = (0, jsonwebtoken_1.decode)(token);
|
|
79
79
|
(0, log_1.debug)(`decoded=${JSON.stringify(decoded, null, 2)}`);
|
|
80
80
|
if (!decoded.email) {
|
|
81
|
-
const m =
|
|
81
|
+
const m = "auth error, no email";
|
|
82
82
|
(0, log_1.error)(m);
|
|
83
83
|
return {
|
|
84
84
|
error: (0, api_1.returnCode)(403, m),
|
|
@@ -86,21 +86,21 @@ const getAndValidateToken = async ({ tokenRaw, jwksRegion = 'ap-southeast-2', CO
|
|
|
86
86
|
}
|
|
87
87
|
subject = decoded.sub;
|
|
88
88
|
if (!subject) {
|
|
89
|
-
const mess =
|
|
89
|
+
const mess = "user should have responded with subject (sub) field";
|
|
90
90
|
(0, log_1.error)(mess);
|
|
91
91
|
throw new Error(mess);
|
|
92
92
|
}
|
|
93
93
|
let { picture } = decoded;
|
|
94
|
-
if (decoded.identities[0]?.providerName ===
|
|
94
|
+
if (decoded.identities[0]?.providerName === "Facebook") {
|
|
95
95
|
picture = JSON.parse(decoded.picture).data.url;
|
|
96
96
|
}
|
|
97
97
|
const userId = decoded.email.toLowerCase();
|
|
98
98
|
const userProfile = {
|
|
99
|
-
isAdmin: [
|
|
99
|
+
isAdmin: ["andreigec@hotmail.com", "andreigec@gmail.com"].includes(userId),
|
|
100
100
|
idJwt: decoded,
|
|
101
101
|
userId,
|
|
102
|
-
nickname: decoded.nickname || decoded[
|
|
103
|
-
fullname: decoded.name || decoded[
|
|
102
|
+
nickname: decoded.nickname || decoded["cognito:username"],
|
|
103
|
+
fullname: decoded.name || decoded["cognito:username"],
|
|
104
104
|
picture,
|
|
105
105
|
updatedAt: parseInt(`${decoded.auth_time}000`, 10),
|
|
106
106
|
};
|
|
@@ -109,14 +109,14 @@ const getAndValidateToken = async ({ tokenRaw, jwksRegion = 'ap-southeast-2', CO
|
|
|
109
109
|
catch (e) {
|
|
110
110
|
const ex = e;
|
|
111
111
|
// expiry is too common to log
|
|
112
|
-
if (ex.toString().indexOf(
|
|
112
|
+
if (ex.toString().indexOf("jwt expired") !== -1) {
|
|
113
113
|
(0, log_1.info)(`jwt fail:${e}`);
|
|
114
114
|
}
|
|
115
115
|
throw e;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
catch (e) {
|
|
119
|
-
const m =
|
|
119
|
+
const m = "auth error:" + JSON.stringify(e, null, 2);
|
|
120
120
|
(0, log_1.error)(m);
|
|
121
121
|
return {
|
|
122
122
|
error: (0, api_1.returnCode)(403, m),
|