@ingestkorea/client-sens 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +98 -63
- package/dist-cjs/SensClient.js +57 -28
- package/dist-cjs/commands/GetAlimtalkResultCommand.js +5 -32
- package/dist-cjs/commands/GetAlimtalkStatusCommand.js +7 -35
- package/dist-cjs/commands/GetAlimtalkTemplateCommand.js +5 -32
- package/dist-cjs/commands/GetSMSResultCommand.js +8 -33
- package/dist-cjs/commands/GetSMSStatusCommand.js +7 -33
- package/dist-cjs/commands/ListAlimtalkChannelsCommand.js +6 -33
- package/dist-cjs/commands/ListAlimtalkStatusCommand.js +29 -35
- package/dist-cjs/commands/ListAlimtalkTemplatesCommand.js +5 -32
- package/dist-cjs/commands/ListSMSStatusCommand.js +37 -0
- package/dist-cjs/commands/SendAlimtalkCommand.js +36 -44
- package/dist-cjs/commands/SendMMSCommand.js +67 -103
- package/dist-cjs/commands/SendSMSCommand.js +38 -71
- package/dist-cjs/commands/constants.js +57 -14
- package/dist-cjs/commands/index.js +12 -11
- package/dist-cjs/index.js +2 -2
- package/dist-cjs/middleware/constants.js +10 -0
- package/dist-cjs/middleware/index.js +3 -4
- package/dist-cjs/middleware/middleware-metadata.js +4 -5
- package/dist-cjs/middleware/middleware-retry.js +32 -27
- package/dist-cjs/middleware/middleware-sign.js +10 -9
- package/dist-cjs/models/SendAlimtalk.js +3 -0
- package/dist-cjs/models/SendMMS.js +3 -0
- package/dist-cjs/models/SensClient.js +2 -0
- package/dist-cjs/models/SensErrorInfo.js +13 -0
- package/dist-cjs/models/SensMiddleware.js +2 -0
- package/dist-cjs/models/index.js +17 -14
- package/dist-cjs/protocols/GetAlimtalkResult.js +19 -22
- package/dist-cjs/protocols/GetAlimtalkStatus.js +39 -40
- package/dist-cjs/protocols/GetAlimtalkTemplate.js +56 -90
- package/dist-cjs/protocols/GetSMSResult.js +31 -48
- package/dist-cjs/protocols/GetSMSStatus.js +51 -37
- package/dist-cjs/protocols/ListAlimtalkChannels.js +27 -31
- package/dist-cjs/protocols/ListAlimtalkStatus.js +22 -19
- package/dist-cjs/protocols/ListAlimtalkTemplates.js +33 -25
- package/dist-cjs/protocols/ListSMSStatus.js +48 -0
- package/dist-cjs/protocols/SendAlimtalk.js +23 -27
- package/dist-cjs/protocols/SendMMS.js +8 -38
- package/dist-cjs/protocols/SendSMS.js +20 -22
- package/dist-cjs/protocols/constants.js +103 -34
- package/dist-es/SensClient.js +63 -30
- package/dist-es/commands/GetAlimtalkResultCommand.js +9 -19
- package/dist-es/commands/GetAlimtalkStatusCommand.js +12 -19
- package/dist-es/commands/GetAlimtalkTemplateCommand.js +9 -19
- package/dist-es/commands/GetSMSResultCommand.js +10 -20
- package/dist-es/commands/GetSMSStatusCommand.js +13 -20
- package/dist-es/commands/ListAlimtalkChannelsCommand.js +10 -22
- package/dist-es/commands/ListAlimtalkStatusCommand.js +39 -28
- package/dist-es/commands/ListAlimtalkTemplatesCommand.js +9 -19
- package/dist-es/commands/ListSMSStatusCommand.js +48 -0
- package/dist-es/commands/SendAlimtalkCommand.js +35 -30
- package/dist-es/commands/SendMMSCommand.js +70 -100
- package/dist-es/commands/SendSMSCommand.js +51 -66
- package/dist-es/commands/constants.js +65 -15
- package/dist-es/commands/index.js +28 -11
- package/dist-es/index.js +18 -2
- package/dist-es/middleware/constants.js +10 -0
- package/dist-es/middleware/index.js +19 -4
- package/dist-es/middleware/middleware-metadata.js +11 -5
- package/dist-es/middleware/middleware-retry.js +39 -30
- package/dist-es/middleware/middleware-sign.js +19 -14
- package/dist-es/models/GetAlimtalkResult.js +2 -1
- package/dist-es/models/GetAlimtalkStatus.js +2 -1
- package/dist-es/models/GetAlimtalkTemplate.js +2 -1
- package/dist-es/models/GetSMSResult.js +2 -1
- package/dist-es/models/GetSMSStatus.js +2 -1
- package/dist-es/models/ListAlimtalkChannels.js +2 -1
- package/dist-es/models/ListAlimtalkStatus.js +2 -1
- package/dist-es/models/ListAlimtalkTemplates.js +2 -1
- package/dist-es/models/ListSMSStatus.js +2 -0
- package/dist-es/models/MetadataBearer.js +2 -1
- package/dist-es/models/SendAlimtalk.js +5 -1
- package/dist-es/models/SendMMS.js +5 -1
- package/dist-es/models/SendSMS.js +2 -1
- package/dist-es/models/SensClient.js +2 -0
- package/dist-es/models/SensCommand.js +5 -1
- package/dist-es/models/SensErrorInfo.js +13 -0
- package/dist-es/models/SensMiddleware.js +2 -0
- package/dist-es/models/index.js +33 -14
- package/dist-es/protocols/GetAlimtalkResult.js +24 -23
- package/dist-es/protocols/GetAlimtalkStatus.js +51 -47
- package/dist-es/protocols/GetAlimtalkTemplate.js +78 -87
- package/dist-es/protocols/GetSMSResult.js +40 -47
- package/dist-es/protocols/GetSMSStatus.js +55 -37
- package/dist-es/protocols/ListAlimtalkChannels.js +31 -31
- package/dist-es/protocols/ListAlimtalkStatus.js +26 -32
- package/dist-es/protocols/ListAlimtalkTemplates.js +37 -24
- package/dist-es/protocols/ListSMSStatus.js +42 -0
- package/dist-es/protocols/SendAlimtalk.js +27 -26
- package/dist-es/protocols/SendMMS.js +10 -49
- package/dist-es/protocols/SendSMS.js +24 -31
- package/dist-es/protocols/constants.js +119 -39
- package/dist-types/SensClient.d.ts +3 -20
- package/dist-types/commands/GetAlimtalkResultCommand.d.ts +5 -10
- package/dist-types/commands/GetAlimtalkStatusCommand.d.ts +5 -10
- package/dist-types/commands/GetAlimtalkTemplateCommand.d.ts +5 -10
- package/dist-types/commands/GetSMSResultCommand.d.ts +5 -10
- package/dist-types/commands/GetSMSStatusCommand.d.ts +5 -10
- package/dist-types/commands/ListAlimtalkChannelsCommand.d.ts +5 -10
- package/dist-types/commands/ListAlimtalkStatusCommand.d.ts +5 -10
- package/dist-types/commands/ListAlimtalkTemplatesCommand.d.ts +5 -10
- package/dist-types/commands/ListSMSStatusCommand.d.ts +11 -0
- package/dist-types/commands/SendAlimtalkCommand.d.ts +5 -10
- package/dist-types/commands/SendMMSCommand.d.ts +5 -10
- package/dist-types/commands/SendSMSCommand.d.ts +9 -10
- package/dist-types/commands/constants.d.ts +14 -4
- package/dist-types/commands/index.d.ts +12 -11
- package/dist-types/index.d.ts +2 -2
- package/dist-types/middleware/constants.d.ts +7 -0
- package/dist-types/middleware/index.d.ts +3 -4
- package/dist-types/middleware/middleware-metadata.d.ts +2 -2
- package/dist-types/middleware/middleware-retry.d.ts +2 -2
- package/dist-types/middleware/middleware-sign.d.ts +2 -2
- package/dist-types/models/GetAlimtalkResult.d.ts +3 -3
- package/dist-types/models/GetAlimtalkStatus.d.ts +8 -5
- package/dist-types/models/GetAlimtalkTemplate.d.ts +5 -5
- package/dist-types/models/GetSMSResult.d.ts +7 -15
- package/dist-types/models/GetSMSStatus.d.ts +19 -4
- package/dist-types/models/ListAlimtalkChannels.d.ts +4 -4
- package/dist-types/models/ListAlimtalkStatus.d.ts +8 -8
- package/dist-types/models/ListAlimtalkTemplates.d.ts +2 -2
- package/dist-types/models/ListSMSStatus.d.ts +15 -0
- package/dist-types/models/MetadataBearer.d.ts +3 -3
- package/dist-types/models/SendAlimtalk.d.ts +7 -4
- package/dist-types/models/SendMMS.d.ts +5 -3
- package/dist-types/models/SendSMS.d.ts +2 -2
- package/dist-types/models/SensClient.d.ts +17 -0
- package/dist-types/models/SensCommand.d.ts +4 -6
- package/dist-types/models/SensErrorInfo.d.ts +21 -0
- package/dist-types/models/SensMiddleware.d.ts +8 -0
- package/dist-types/models/index.d.ts +17 -14
- package/dist-types/protocols/GetAlimtalkResult.d.ts +4 -11
- package/dist-types/protocols/GetAlimtalkStatus.d.ts +6 -12
- package/dist-types/protocols/GetAlimtalkTemplate.d.ts +4 -14
- package/dist-types/protocols/GetSMSResult.d.ts +4 -12
- package/dist-types/protocols/GetSMSStatus.d.ts +6 -11
- package/dist-types/protocols/ListAlimtalkChannels.d.ts +4 -11
- package/dist-types/protocols/ListAlimtalkStatus.d.ts +4 -10
- package/dist-types/protocols/ListAlimtalkTemplates.d.ts +5 -12
- package/dist-types/protocols/ListSMSStatus.d.ts +4 -0
- package/dist-types/protocols/SendAlimtalk.d.ts +5 -12
- package/dist-types/protocols/SendMMS.d.ts +4 -10
- package/dist-types/protocols/SendSMS.d.ts +5 -10
- package/dist-types/protocols/constants.d.ts +4 -2
- package/package.json +20 -4
- package/.github/pull_request_template.md +0 -19
- package/dist-cjs/middleware/middleware-sort-headers.js +0 -25
- package/dist-cjs/protocols/index.js +0 -28
- package/dist-es/middleware/middleware-sort-headers.js +0 -12
- package/dist-es/models/Middleware.js +0 -1
- package/dist-es/protocols/index.js +0 -12
- package/dist-types/middleware/middleware-sort-headers.d.ts +0 -2
- package/dist-types/models/Middleware.d.ts +0 -12
- package/dist-types/protocols/index.d.ts +0 -12
- /package/dist-cjs/models/{Middleware.js → ListSMSStatus.js} +0 -0
|
@@ -1,80 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveInputMessages = exports.SendSMSCommand = void 0;
|
|
4
|
+
const index_js_1 = require("../models/index.js");
|
|
5
|
+
const SendSMS_js_1 = require("../protocols/SendSMS.js");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
class SendSMSCommand extends index_js_1.SensCommand {
|
|
6
8
|
constructor(input) {
|
|
7
9
|
super(input);
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
+
const content = input.content ? (0, constants_1.trimText)(input.content) : "내용없음";
|
|
11
|
+
const subject = input.subject ? (0, constants_1.trimText)(input.subject) : "제목없음";
|
|
12
|
+
const messages = (0, exports.resolveInputMessages)(input.messages, { defaultContent: content, defaultSubject: subject });
|
|
13
|
+
const isLMS = !!messages.filter((msg) => !!msg.subject).length;
|
|
10
14
|
this.input = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type:
|
|
15
|
-
|
|
15
|
+
from: (0, constants_1.prettyPhoneNum)(input.from),
|
|
16
|
+
content,
|
|
17
|
+
messages,
|
|
18
|
+
type: isLMS ? "LMS" : "SMS",
|
|
19
|
+
contentType: input.contentType ? input.contentType : "COMM",
|
|
20
|
+
countryCode: input.countryCode ? input.countryCode : "82",
|
|
21
|
+
...(isLMS && { subject }),
|
|
16
22
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (!config.serviceId.sms)
|
|
20
|
-
throw new IngestkoreaError({
|
|
21
|
-
code: 400,
|
|
22
|
-
type: "Bad Request",
|
|
23
|
-
message: "Invalid Params",
|
|
24
|
-
description: "Please Check SMS ServiceId",
|
|
25
|
-
});
|
|
26
|
-
let request = await serializeIngestkorea_restJson_SendSMSCommand(input, config);
|
|
27
|
-
return request;
|
|
28
|
-
}
|
|
29
|
-
async deserialize(response) {
|
|
30
|
-
let output = await deserializeIngestkorea_restJson_SendSMSCommand(response);
|
|
31
|
-
return output;
|
|
23
|
+
this.serializer = SendSMS_js_1.se_SendSMSCommand;
|
|
24
|
+
this.deserializer = SendSMS_js_1.de_SendSMSCommand;
|
|
32
25
|
}
|
|
33
26
|
}
|
|
27
|
+
exports.SendSMSCommand = SendSMSCommand;
|
|
28
|
+
const resolveInputMessages = (messages, config) => {
|
|
29
|
+
const output = messages
|
|
30
|
+
.filter((d) => !!d)
|
|
31
|
+
.map((message) => {
|
|
32
|
+
const content = message.content ? (0, constants_1.trimText)(message.content) : config.defaultContent;
|
|
33
|
+
const subject = message.subject ? (0, constants_1.trimText)(message.subject) : config.defaultSubject;
|
|
34
|
+
const msgType = getMessageType({ content });
|
|
35
|
+
return {
|
|
36
|
+
to: (0, constants_1.prettyPhoneNum)(message.to),
|
|
37
|
+
content,
|
|
38
|
+
...(msgType === "LMS" && { subject }),
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
return output;
|
|
42
|
+
};
|
|
43
|
+
exports.resolveInputMessages = resolveInputMessages;
|
|
34
44
|
const getMessageType = (input) => {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
const SMS_MAX_CONTENT_LENGTH = 90;
|
|
46
|
+
const LMS_MAX_CONTENT_LENGTH = 2000;
|
|
47
|
+
const contentLength = (0, constants_1.getContentLength)(input.content);
|
|
48
|
+
if (!contentLength) {
|
|
49
|
+
throw new index_js_1.SensError({
|
|
38
50
|
code: 400,
|
|
39
51
|
type: "Bad Request",
|
|
40
|
-
message: "
|
|
41
|
-
|
|
52
|
+
message: "메세지 내용이 없습니다.",
|
|
53
|
+
invalidInputs: [{ type: "not-valid.args", message: "메세지 내용을 확인해주세요." }],
|
|
42
54
|
});
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
}
|
|
56
|
+
if (contentLength > LMS_MAX_CONTENT_LENGTH) {
|
|
57
|
+
throw new index_js_1.SensError({
|
|
45
58
|
code: 400,
|
|
46
59
|
type: "Bad Request",
|
|
47
|
-
message: "
|
|
48
|
-
|
|
60
|
+
message: "메세지 최대 크기 초과",
|
|
61
|
+
invalidInputs: [{ type: "not-valid.args", message: `메세지 최대 길이는 ${LMS_MAX_CONTENT_LENGTH}글자입니다` }],
|
|
49
62
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const resolveInputContent = (content) => {
|
|
53
|
-
const resolvedContent = trimText(content);
|
|
54
|
-
const messageType = getMessageType(resolvedContent);
|
|
55
|
-
return {
|
|
56
|
-
content: resolvedContent,
|
|
57
|
-
messageType: messageType,
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
const resolveInputMessages = (messages) => {
|
|
61
|
-
let init = {
|
|
62
|
-
messages: [],
|
|
63
|
-
messageType: "SMS",
|
|
64
|
-
};
|
|
65
|
-
const output = messages.reduce((acc, message) => {
|
|
66
|
-
const to = prettyPhoneNum(message.to);
|
|
67
|
-
const content = message.content != undefined ? trimText(message.content) : undefined;
|
|
68
|
-
const subject = message.subject != undefined ? trimText(message.subject) : undefined;
|
|
69
|
-
const messageType = content != undefined ? getMessageType(content) : "SMS";
|
|
70
|
-
if (messageType == "LMS")
|
|
71
|
-
acc.messageType = messageType;
|
|
72
|
-
acc.messages.push({
|
|
73
|
-
to: to,
|
|
74
|
-
...(content != undefined && { content: content }),
|
|
75
|
-
...(subject != undefined && acc.messageType === "LMS" && { subject: subject }),
|
|
76
|
-
});
|
|
77
|
-
return acc;
|
|
78
|
-
}, init);
|
|
79
|
-
return output;
|
|
63
|
+
}
|
|
64
|
+
return contentLength > SMS_MAX_CONTENT_LENGTH ? "LMS" : "SMS";
|
|
80
65
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveRequestDuration = exports.getDefaultRequestDuration = exports.convertToKst = exports.convertToUtc = exports.getContentLength = exports.prettyPhoneNum = exports.trimText = void 0;
|
|
4
|
+
const index_js_1 = require("../models/index.js");
|
|
5
|
+
const trimText = (input) => input.trim();
|
|
6
|
+
exports.trimText = trimText;
|
|
7
|
+
const prettyPhoneNum = (input) => input.replace(/\-/gi, "");
|
|
8
|
+
exports.prettyPhoneNum = prettyPhoneNum;
|
|
6
9
|
/** @returns content-length(euc-kr) */
|
|
7
|
-
|
|
10
|
+
const getContentLength = (input) => {
|
|
8
11
|
return input.split("").reduce((acc, text) => {
|
|
9
12
|
let byte = Buffer.from(text).length;
|
|
10
13
|
let modulo = byte % 3;
|
|
@@ -12,13 +15,60 @@ export const getContentLength = (input) => {
|
|
|
12
15
|
return acc;
|
|
13
16
|
}, 0);
|
|
14
17
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const current_ms = new Date().getTime() + OFFSET;
|
|
20
|
-
const startTime_ms = current_ms - hours_ms;
|
|
21
|
-
let current_kst = new Date(current_ms).toISOString().replace(/\.\d{3}Z$/, "");
|
|
22
|
-
let startTime_kst = new Date(startTime_ms).toISOString().replace(/\.\d{3}Z$/, "");
|
|
23
|
-
return { startTime: startTime_kst, endTime: current_kst };
|
|
18
|
+
exports.getContentLength = getContentLength;
|
|
19
|
+
const convertToUtc = (input) => {
|
|
20
|
+
const utcRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
|
|
21
|
+
return utcRegex.test(input) ? input : new Date(input.replace(" ", "T") + "+09:00").toISOString();
|
|
24
22
|
};
|
|
23
|
+
exports.convertToUtc = convertToUtc;
|
|
24
|
+
const convertToKst = (input) => {
|
|
25
|
+
const KST_OFFSET = 9 * 3600000;
|
|
26
|
+
return new Date(input + KST_OFFSET).toISOString().replace(/\.\d{3}Z$/, "");
|
|
27
|
+
};
|
|
28
|
+
exports.convertToKst = convertToKst;
|
|
29
|
+
// UTC
|
|
30
|
+
const getDefaultRequestDuration = (config) => {
|
|
31
|
+
const now = Date.now();
|
|
32
|
+
return {
|
|
33
|
+
startTime: new Date(now - config.durationLimitMs).toISOString(),
|
|
34
|
+
endTime: new Date(now).toISOString(),
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.getDefaultRequestDuration = getDefaultRequestDuration;
|
|
38
|
+
// UTC
|
|
39
|
+
const resolveRequestDuration = (input, config) => {
|
|
40
|
+
const start = new Date(input.startTime).getTime();
|
|
41
|
+
const end = new Date(input.endTime).getTime();
|
|
42
|
+
const diff = end - start;
|
|
43
|
+
if (diff < 0) {
|
|
44
|
+
throw new index_js_1.SensError({
|
|
45
|
+
code: 400,
|
|
46
|
+
type: "Bad Request",
|
|
47
|
+
message: `조회 가능 날짜 오류`,
|
|
48
|
+
invalidInputs: [
|
|
49
|
+
{
|
|
50
|
+
type: "not-valid.args",
|
|
51
|
+
message: "종료일이 시작일보다 빠를 수 없습니다.",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (diff > config.durationLimitMs) {
|
|
57
|
+
throw new index_js_1.SensError({
|
|
58
|
+
code: 400,
|
|
59
|
+
type: "Bad Request",
|
|
60
|
+
message: `조회 가능 날짜 범위 오류`,
|
|
61
|
+
invalidInputs: [
|
|
62
|
+
{
|
|
63
|
+
type: "not-valid.args",
|
|
64
|
+
message: `조회 가능한 날짜 범위는 최대 ${config.durationLimitMs / (24 * 3600000)}일 이내여야 합니다.`,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
startTimeMs: start,
|
|
71
|
+
endTimeMs: end,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
exports.resolveRequestDuration = resolveRequestDuration;
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./GetAlimtalkResultCommand.js"), exports);
|
|
18
|
+
__exportStar(require("./GetAlimtalkStatusCommand.js"), exports);
|
|
19
|
+
__exportStar(require("./GetAlimtalkTemplateCommand.js"), exports);
|
|
20
|
+
__exportStar(require("./GetSMSResultCommand.js"), exports);
|
|
21
|
+
__exportStar(require("./GetSMSStatusCommand.js"), exports);
|
|
22
|
+
__exportStar(require("./ListAlimtalkChannelsCommand.js"), exports);
|
|
23
|
+
__exportStar(require("./ListAlimtalkStatusCommand.js"), exports);
|
|
24
|
+
__exportStar(require("./ListAlimtalkTemplatesCommand.js"), exports);
|
|
25
|
+
__exportStar(require("./ListSMSStatusCommand.js"), exports);
|
|
26
|
+
__exportStar(require("./SendAlimtalkCommand.js"), exports);
|
|
27
|
+
__exportStar(require("./SendMMSCommand.js"), exports);
|
|
28
|
+
__exportStar(require("./SendSMSCommand.js"), exports);
|
package/dist-es/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./commands/index.js"), exports);
|
|
18
|
+
__exportStar(require("./SensClient.js"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NCP_SIGNATURE = exports.NCP_TIMESTAMP = exports.NCP_ACCESS_KEY = exports.INGESTKOREA_RETRY_DELAY = exports.INGESTKOREA_RETRY = exports.INGESTKOREA_REQUEST_LOG = exports.INGESTKOREA_USER_AGENT = void 0;
|
|
4
|
+
exports.INGESTKOREA_USER_AGENT = "x-ingestkorea-user-agent";
|
|
5
|
+
exports.INGESTKOREA_REQUEST_LOG = "x-ingestkorea-request";
|
|
6
|
+
exports.INGESTKOREA_RETRY = "x-ingestkorea-attempts";
|
|
7
|
+
exports.INGESTKOREA_RETRY_DELAY = "x-ingestkorea-total-retry-delay";
|
|
8
|
+
exports.NCP_ACCESS_KEY = "x-ncp-iam-access-key";
|
|
9
|
+
exports.NCP_TIMESTAMP = "x-ncp-apigw-timestamp";
|
|
10
|
+
exports.NCP_SIGNATURE = "x-ncp-apigw-signature-v2";
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./middleware-metadata.js"), exports);
|
|
18
|
+
__exportStar(require("./middleware-retry.js"), exports);
|
|
19
|
+
__exportStar(require("./middleware-sign.js"), exports);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.middlewareIngestkoreaMetadata = void 0;
|
|
4
|
+
const constants_js_1 = require("./constants.js");
|
|
5
|
+
const middlewareIngestkoreaMetadata = (next) => async (input, context) => {
|
|
6
|
+
input.request.headers = {
|
|
7
|
+
...input.request.headers,
|
|
8
|
+
[constants_js_1.INGESTKOREA_USER_AGENT]: "@ingestkorea/client-sens/1.8.x",
|
|
9
|
+
};
|
|
10
|
+
return next(input, context);
|
|
6
11
|
};
|
|
12
|
+
exports.middlewareIngestkoreaMetadata = middlewareIngestkoreaMetadata;
|
|
@@ -1,51 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.middlewareRetry = void 0;
|
|
4
|
+
const util_error_handler_1 = require("@ingestkorea/util-error-handler");
|
|
5
|
+
const constants_js_1 = require("./constants.js");
|
|
6
|
+
const middlewareRetry = (next) => async (input, context) => {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
var _c;
|
|
9
|
+
const MAX_RETRIES = 3;
|
|
10
|
+
const BASE_DELAY_MS = 500;
|
|
11
|
+
const MAX_DELAY_MS = 5000;
|
|
5
12
|
let attempts = 0;
|
|
6
13
|
let totalRetryDelay = 0;
|
|
7
|
-
|
|
14
|
+
(_a = (_c = input.request).headers) !== null && _a !== void 0 ? _a : (_c.headers = {});
|
|
15
|
+
let lastError = new util_error_handler_1.IngestkoreaError({
|
|
8
16
|
code: 400,
|
|
9
17
|
type: "Bad Request",
|
|
10
18
|
message: "Invalid Request",
|
|
11
|
-
description: { attempts,
|
|
19
|
+
description: { attempts, maxRetries: MAX_RETRIES, totalRetryDelay },
|
|
12
20
|
});
|
|
13
|
-
while (
|
|
21
|
+
while (attempts < MAX_RETRIES) {
|
|
22
|
+
const attemptNo = attempts + 1;
|
|
23
|
+
const requestLog = `attempt=${attemptNo}; max=${MAX_RETRIES}; totalRetryDelay=${totalRetryDelay}`;
|
|
24
|
+
input.request.headers[constants_js_1.INGESTKOREA_REQUEST_LOG] = requestLog;
|
|
14
25
|
try {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
$metadata: {
|
|
20
|
-
attempts: attempts + 1,
|
|
21
|
-
totalRetryDelay: totalRetryDelay,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
response,
|
|
25
|
-
};
|
|
26
|
+
const { response } = await next(input, context);
|
|
27
|
+
response.headers[constants_js_1.INGESTKOREA_RETRY] = attemptNo.toString();
|
|
28
|
+
response.headers[constants_js_1.INGESTKOREA_RETRY_DELAY] = totalRetryDelay.toString();
|
|
29
|
+
return { response };
|
|
26
30
|
}
|
|
27
|
-
catch (
|
|
31
|
+
catch (error) {
|
|
28
32
|
attempts++;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
throw lastError;
|
|
32
|
-
}
|
|
33
|
-
const delay = attempts * 1000;
|
|
34
|
-
totalRetryDelay += delay;
|
|
35
|
-
lastError.error.description = { attempts, maxAttempts, totalRetryDelay };
|
|
36
|
-
if (err instanceof IngestkoreaError) {
|
|
33
|
+
lastError.error.description = { attempts, maxRetries: MAX_RETRIES, totalRetryDelay };
|
|
34
|
+
if (error instanceof util_error_handler_1.IngestkoreaError) {
|
|
37
35
|
lastError.error.description = {
|
|
38
36
|
...lastError.error.description,
|
|
39
|
-
detail:
|
|
37
|
+
detail: error.error.description,
|
|
40
38
|
};
|
|
41
39
|
}
|
|
42
|
-
|
|
40
|
+
else {
|
|
43
41
|
lastError.error.description = {
|
|
44
42
|
...lastError.error.description,
|
|
45
|
-
detail:
|
|
43
|
+
detail: String((_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error),
|
|
46
44
|
};
|
|
47
45
|
}
|
|
46
|
+
if (attempts >= MAX_RETRIES) {
|
|
47
|
+
lastError.error.description = { attempts, maxRetries: MAX_RETRIES, totalRetryDelay };
|
|
48
|
+
throw lastError;
|
|
49
|
+
}
|
|
50
|
+
const exp = BASE_DELAY_MS * 2 ** (attempts - 1);
|
|
51
|
+
const capped = Math.min(MAX_DELAY_MS, exp);
|
|
52
|
+
const delay = Math.floor(Math.random() * capped);
|
|
53
|
+
totalRetryDelay += delay;
|
|
54
|
+
lastError.error.description = { attempts, maxRetries: MAX_RETRIES, totalRetryDelay };
|
|
48
55
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
49
56
|
}
|
|
50
57
|
}
|
|
58
|
+
throw lastError;
|
|
51
59
|
};
|
|
60
|
+
exports.middlewareRetry = middlewareRetry;
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.middlewareNcpSign = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const util_http_handler_1 = require("@ingestkorea/util-http-handler");
|
|
6
|
+
const constants_js_1 = require("./constants.js");
|
|
7
|
+
const middlewareNcpSign = (next) => async (input, context) => {
|
|
8
|
+
const { accessKey, secretKey } = context.credentials;
|
|
9
|
+
const method = input.request.method;
|
|
10
|
+
const queryString = (0, util_http_handler_1.buildQueryString)(input.request.query);
|
|
11
|
+
const path = queryString ? `${input.request.path}?${queryString}` : input.request.path;
|
|
8
12
|
const space = " ";
|
|
9
13
|
const newLine = "\n";
|
|
10
14
|
const timestamp = new Date().getTime().toString();
|
|
11
15
|
const stringToSign = [method + space + path, timestamp, accessKey].join(newLine);
|
|
12
|
-
const signature = createHmac("sha256", secretKey).update(stringToSign).digest("base64");
|
|
13
|
-
request.headers = {
|
|
14
|
-
...request.headers,
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
16
|
+
const signature = (0, crypto_1.createHmac)("sha256", secretKey).update(stringToSign).digest("base64");
|
|
17
|
+
input.request.headers = {
|
|
18
|
+
...input.request.headers,
|
|
19
|
+
[constants_js_1.NCP_ACCESS_KEY]: accessKey,
|
|
20
|
+
[constants_js_1.NCP_TIMESTAMP]: timestamp,
|
|
21
|
+
[constants_js_1.NCP_SIGNATURE]: signature,
|
|
18
22
|
};
|
|
19
|
-
return
|
|
23
|
+
return next(input, context);
|
|
20
24
|
};
|
|
25
|
+
exports.middlewareNcpSign = middlewareNcpSign;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALIMTALK_MAX_CONTENT_LENGTH = exports.ALIMTALK_MAX_RECIPIENTS = void 0;
|
|
4
|
+
exports.ALIMTALK_MAX_RECIPIENTS = 100;
|
|
5
|
+
exports.ALIMTALK_MAX_CONTENT_LENGTH = 1000;
|
|
1
6
|
const ALIMTALK_BUTTON_TYPES = ["DS", "WL", "AL", "BK", "MD", "AC"];
|
|
2
7
|
const ALIMTALK_BUTTON_NAMES = ["배송 조회", "웹 링크", "앱 링크", "봇 키워드", "메시지 전달", "채널 추가"];
|
|
3
|
-
export {};
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MMS_SUPPORT_FILE_EXTENSION = exports.MMS_MAX_SUPPORT_FILE_SIZE = void 0;
|
|
4
|
+
exports.MMS_MAX_SUPPORT_FILE_SIZE = 300; // KiByte
|
|
5
|
+
exports.MMS_SUPPORT_FILE_EXTENSION = [".jpg", ".jpeg"];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SensError = void 0;
|
|
4
|
+
class SensError extends Error {
|
|
5
|
+
constructor(info) {
|
|
6
|
+
super(info.message);
|
|
7
|
+
this.name = "SensError";
|
|
8
|
+
this.code = info.code;
|
|
9
|
+
this.type = info.type;
|
|
10
|
+
this.invalidInputs = info.invalidInputs || [];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.SensError = SensError;
|
package/dist-es/models/index.js
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./GetAlimtalkResult.js"), exports);
|
|
18
|
+
__exportStar(require("./GetAlimtalkStatus.js"), exports);
|
|
19
|
+
__exportStar(require("./GetAlimtalkTemplate.js"), exports);
|
|
20
|
+
__exportStar(require("./GetSMSResult.js"), exports);
|
|
21
|
+
__exportStar(require("./GetSMSStatus.js"), exports);
|
|
22
|
+
__exportStar(require("./ListAlimtalkChannels.js"), exports);
|
|
23
|
+
__exportStar(require("./ListAlimtalkStatus.js"), exports);
|
|
24
|
+
__exportStar(require("./ListAlimtalkTemplates.js"), exports);
|
|
25
|
+
__exportStar(require("./ListSMSStatus.js"), exports);
|
|
26
|
+
__exportStar(require("./MetadataBearer.js"), exports);
|
|
27
|
+
__exportStar(require("./SendAlimtalk.js"), exports);
|
|
28
|
+
__exportStar(require("./SendMMS.js"), exports);
|
|
29
|
+
__exportStar(require("./SendSMS.js"), exports);
|
|
30
|
+
__exportStar(require("./SensClient.js"), exports);
|
|
31
|
+
__exportStar(require("./SensCommand.js"), exports);
|
|
32
|
+
__exportStar(require("./SensErrorInfo.js"), exports);
|
|
33
|
+
__exportStar(require("./SensMiddleware.js"), exports);
|