@creator.co/wapi 1.3.15 → 1.3.17
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creator.co/wapi",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
"author": "",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@aws-sdk/client-kms": "^3.
|
|
20
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
21
|
-
"@aws-sdk/client-ses": "^3.
|
|
22
|
-
"@aws-sdk/client-sns": "^3.
|
|
23
|
-
"@aws-sdk/client-ssm": "^3.
|
|
24
|
-
"@aws-sdk/credential-provider-node": "^3.
|
|
19
|
+
"@aws-sdk/client-kms": "^3.509.0",
|
|
20
|
+
"@aws-sdk/client-secrets-manager": "^3.509.0",
|
|
21
|
+
"@aws-sdk/client-ses": "^3.509.0",
|
|
22
|
+
"@aws-sdk/client-sns": "^3.509.0",
|
|
23
|
+
"@aws-sdk/client-ssm": "^3.509.0",
|
|
24
|
+
"@aws-sdk/credential-provider-node": "^3.509.0",
|
|
25
25
|
"@types/email-templates": "^10.0.1",
|
|
26
26
|
"@types/nodemailer": "^6.4.10",
|
|
27
27
|
"@types/object-hash": "^3.0.4",
|
|
28
28
|
"abind": "^1.0.5",
|
|
29
29
|
"cors": "^2.8.5",
|
|
30
30
|
"cuid": "^3.0.0",
|
|
31
|
-
"dotenv": "^16.
|
|
31
|
+
"dotenv": "^16.4.1",
|
|
32
32
|
"email-templates": "^11.1.1",
|
|
33
33
|
"express": "^4.18.2",
|
|
34
34
|
"json-stringify-safe": "^5.0.1",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@jest/globals": "^29.7.0",
|
|
49
|
-
"@types/aws-lambda": "^8.10.
|
|
49
|
+
"@types/aws-lambda": "^8.10.133",
|
|
50
50
|
"@types/chai": "^4.3.9",
|
|
51
51
|
"@types/cors": "^2.8.15",
|
|
52
52
|
"@types/express": "^4.17.19",
|
|
53
|
-
"@types/jest": "^29.5.
|
|
53
|
+
"@types/jest": "^29.5.12",
|
|
54
54
|
"@types/jsonwebtoken": "^9.0.3",
|
|
55
|
-
"@types/node": "^20.
|
|
55
|
+
"@types/node": "^20.11.16",
|
|
56
56
|
"@types/path-to-regexp": "^1.7.0",
|
|
57
|
-
"@types/pg": "^8.
|
|
57
|
+
"@types/pg": "^8.11.0",
|
|
58
58
|
"@types/supertest": "^2.0.15",
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
60
|
-
"@typescript-eslint/parser": "^6.
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
60
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
61
61
|
"aws-lambda": "^1.0.7",
|
|
62
62
|
"aws-sdk-client-mock": "^3.0.0",
|
|
63
63
|
"chai": "^4.3.10",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"eslint-plugin-prettier": "^5.0.0",
|
|
68
68
|
"jest": "^29.7.0",
|
|
69
69
|
"jest-junit": "^16.0.0",
|
|
70
|
-
"prettier": "^3.
|
|
70
|
+
"prettier": "^3.2.5",
|
|
71
71
|
"supertest": "^6.3.3",
|
|
72
72
|
"ts-jest": "^29.1.1",
|
|
73
73
|
"ts-node": "^10.9.1",
|
|
@@ -31,6 +31,13 @@ export default class Publisher {
|
|
|
31
31
|
* @returns {Promise<PublishCommandOutput>} - A promise that resolves to the response from the publish command.
|
|
32
32
|
*/
|
|
33
33
|
publishOnTopic(messageObject: any, topic: string, additionalProps?: object): Promise<PublishCommandOutput | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Publishes a message on a specified topic.
|
|
36
|
+
* @param {string} message - The SMS message to publish.
|
|
37
|
+
* @param {string} phone - The phone number to publish the message to.
|
|
38
|
+
* @returns {Promise<PublishCommandOutput>} - A promise that resolves to the response from the publish command.
|
|
39
|
+
*/
|
|
40
|
+
publishSMS(message: string, phone: string): Promise<PublishCommandOutput | undefined>;
|
|
34
41
|
/**
|
|
35
42
|
* Establishes a connection to the SNS client if it does not already exist or if the region has changed.
|
|
36
43
|
* @returns None
|
|
@@ -96,7 +96,7 @@ var Publisher = /** @class */ (function () {
|
|
|
96
96
|
_a.trys.push([1, 3, , 4]);
|
|
97
97
|
this.connect();
|
|
98
98
|
params = __assign({ Message: JSON.stringify(messageObject), TopicArn: topic }, (additionalProps ? additionalProps : {}));
|
|
99
|
-
return [4 /*yield*/,
|
|
99
|
+
return [4 /*yield*/, PUBLISHER_CONN.send(new client_sns_1.PublishCommand(params))];
|
|
100
100
|
case 2:
|
|
101
101
|
resp = _a.sent();
|
|
102
102
|
return [3 /*break*/, 4];
|
|
@@ -111,6 +111,42 @@ var Publisher = /** @class */ (function () {
|
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* Publishes a message on a specified topic.
|
|
116
|
+
* @param {string} message - The SMS message to publish.
|
|
117
|
+
* @param {string} phone - The phone number to publish the message to.
|
|
118
|
+
* @returns {Promise<PublishCommandOutput>} - A promise that resolves to the response from the publish command.
|
|
119
|
+
*/
|
|
120
|
+
Publisher.prototype.publishSMS = function (message, phone) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var resp, params, e_2;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
resp = undefined;
|
|
127
|
+
_a.label = 1;
|
|
128
|
+
case 1:
|
|
129
|
+
_a.trys.push([1, 3, , 4]);
|
|
130
|
+
this.connect();
|
|
131
|
+
params = {
|
|
132
|
+
Message: message,
|
|
133
|
+
PhoneNumber: phone,
|
|
134
|
+
};
|
|
135
|
+
return [4 /*yield*/, PUBLISHER_CONN.send(new client_sns_1.PublishCommand(params))];
|
|
136
|
+
case 2:
|
|
137
|
+
resp = _a.sent();
|
|
138
|
+
return [3 /*break*/, 4];
|
|
139
|
+
case 3:
|
|
140
|
+
e_2 = _a.sent();
|
|
141
|
+
console.error("Error while publishing SMS ".concat(message, " with error: ").concat(e_2));
|
|
142
|
+
return [3 /*break*/, 4];
|
|
143
|
+
case 4:
|
|
144
|
+
console.debug('Publisher resp', resp);
|
|
145
|
+
return [2 /*return*/, resp];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
};
|
|
114
150
|
/**
|
|
115
151
|
* Establishes a connection to the SNS client if it does not already exist or if the region has changed.
|
|
116
152
|
* @returns None
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Publisher.js","sourceRoot":"","sources":["../../../src/Publisher/Publisher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAK4B;AAC5B,2BAA4B;AAC5B,iBAAiB;AACjB;;;GAGG;AACH,kCAAkC;AAClC,IAAI,cAAc,GAAqB,IAAI,CAAA;AAC3C;;;GAGG;AACH,kCAAkC;AAClC,IAAI,mBAAmB,GAAkB,IAAI,CAAA;AAW7C;;GAEG;AACH;IAQE;;;;OAIG;IACH,mBAAY,MAAwB;QAClC,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;YAC3B,iDAAiD;QACnD,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACG,kCAAc,GAApB,UACE,aAAkB,EAClB,KAAa,EACb,eAAwB;;;;;;wBAEpB,IAAI,GAAqC,SAAS,CAAA;;;;wBAEpD,IAAI,CAA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"",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
"author": "",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@aws-sdk/client-kms": "^3.
|
|
20
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
21
|
-
"@aws-sdk/client-ses": "^3.
|
|
22
|
-
"@aws-sdk/client-sns": "^3.
|
|
23
|
-
"@aws-sdk/client-ssm": "^3.
|
|
24
|
-
"@aws-sdk/credential-provider-node": "^3.
|
|
19
|
+
"@aws-sdk/client-kms": "^3.509.0",
|
|
20
|
+
"@aws-sdk/client-secrets-manager": "^3.509.0",
|
|
21
|
+
"@aws-sdk/client-ses": "^3.509.0",
|
|
22
|
+
"@aws-sdk/client-sns": "^3.509.0",
|
|
23
|
+
"@aws-sdk/client-ssm": "^3.509.0",
|
|
24
|
+
"@aws-sdk/credential-provider-node": "^3.509.0",
|
|
25
25
|
"@types/email-templates": "^10.0.1",
|
|
26
26
|
"@types/nodemailer": "^6.4.10",
|
|
27
27
|
"@types/object-hash": "^3.0.4",
|
|
28
28
|
"abind": "^1.0.5",
|
|
29
29
|
"cors": "^2.8.5",
|
|
30
30
|
"cuid": "^3.0.0",
|
|
31
|
-
"dotenv": "^16.
|
|
31
|
+
"dotenv": "^16.4.1",
|
|
32
32
|
"email-templates": "^11.1.1",
|
|
33
33
|
"express": "^4.18.2",
|
|
34
34
|
"json-stringify-safe": "^5.0.1",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@jest/globals": "^29.7.0",
|
|
49
|
-
"@types/aws-lambda": "^8.10.
|
|
49
|
+
"@types/aws-lambda": "^8.10.133",
|
|
50
50
|
"@types/chai": "^4.3.9",
|
|
51
51
|
"@types/cors": "^2.8.15",
|
|
52
52
|
"@types/express": "^4.17.19",
|
|
53
|
-
"@types/jest": "^29.5.
|
|
53
|
+
"@types/jest": "^29.5.12",
|
|
54
54
|
"@types/jsonwebtoken": "^9.0.3",
|
|
55
|
-
"@types/node": "^20.
|
|
55
|
+
"@types/node": "^20.11.16",
|
|
56
56
|
"@types/path-to-regexp": "^1.7.0",
|
|
57
|
-
"@types/pg": "^8.
|
|
57
|
+
"@types/pg": "^8.11.0",
|
|
58
58
|
"@types/supertest": "^2.0.15",
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
60
|
-
"@typescript-eslint/parser": "^6.
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
60
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
61
61
|
"aws-lambda": "^1.0.7",
|
|
62
62
|
"aws-sdk-client-mock": "^3.0.0",
|
|
63
63
|
"chai": "^4.3.10",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"eslint-plugin-prettier": "^5.0.0",
|
|
68
68
|
"jest": "^29.7.0",
|
|
69
69
|
"jest-junit": "^16.0.0",
|
|
70
|
-
"prettier": "^3.
|
|
70
|
+
"prettier": "^3.2.5",
|
|
71
71
|
"supertest": "^6.3.3",
|
|
72
72
|
"ts-jest": "^29.1.1",
|
|
73
73
|
"ts-node": "^10.9.1",
|
|
@@ -72,7 +72,7 @@ export default class Publisher {
|
|
|
72
72
|
TopicArn: topic,
|
|
73
73
|
...(additionalProps ? additionalProps : {}),
|
|
74
74
|
}
|
|
75
|
-
resp = await PUBLISHER_CONN
|
|
75
|
+
resp = await PUBLISHER_CONN!.send(new PublishCommand(params))
|
|
76
76
|
} catch (e) {
|
|
77
77
|
console.error(`Error while publishing into topic ${topic} with error: ${e}`)
|
|
78
78
|
}
|
|
@@ -80,6 +80,29 @@ export default class Publisher {
|
|
|
80
80
|
return resp
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Publishes a message on a specified topic.
|
|
85
|
+
* @param {string} message - The SMS message to publish.
|
|
86
|
+
* @param {string} phone - The phone number to publish the message to.
|
|
87
|
+
* @returns {Promise<PublishCommandOutput>} - A promise that resolves to the response from the publish command.
|
|
88
|
+
*/
|
|
89
|
+
async publishSMS(message: string, phone: string): Promise<PublishCommandOutput | undefined> {
|
|
90
|
+
let resp: undefined | PublishCommandOutput = undefined
|
|
91
|
+
try {
|
|
92
|
+
this.connect()
|
|
93
|
+
//Send to SNS
|
|
94
|
+
const params: PublishCommandInput = {
|
|
95
|
+
Message: message,
|
|
96
|
+
PhoneNumber: phone,
|
|
97
|
+
}
|
|
98
|
+
resp = await PUBLISHER_CONN!.send(new PublishCommand(params))
|
|
99
|
+
} catch (e) {
|
|
100
|
+
console.error(`Error while publishing SMS ${message} with error: ${e}`)
|
|
101
|
+
}
|
|
102
|
+
console.debug('Publisher resp', resp)
|
|
103
|
+
return resp
|
|
104
|
+
}
|
|
105
|
+
|
|
83
106
|
/**
|
|
84
107
|
* Establishes a connection to the SNS client if it does not already exist or if the region has changed.
|
|
85
108
|
* @returns None
|
|
@@ -6,7 +6,7 @@ import Publisher from '../../src/Publisher/Publisher'
|
|
|
6
6
|
|
|
7
7
|
const SNSMock = mockClient(SNSClient)
|
|
8
8
|
|
|
9
|
-
describe('
|
|
9
|
+
describe('SNS Pub-Sub', () => {
|
|
10
10
|
// reset mock
|
|
11
11
|
beforeEach(() => {
|
|
12
12
|
SNSMock.reset()
|
|
@@ -57,4 +57,38 @@ describe('Encryption', () => {
|
|
|
57
57
|
})
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
+
describe('SNS SMS', () => {
|
|
61
|
+
// reset mock
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
SNSMock.reset()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const provider = new Publisher({
|
|
67
|
+
region: 'ca-central-1',
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
test('Publishes with success', async () => {
|
|
71
|
+
const msg = 'hello world'
|
|
72
|
+
const phoneNumber = '+16042001234'
|
|
73
|
+
const messageId = 'id-123'
|
|
74
|
+
SNSMock.on(PublishCommand, {
|
|
75
|
+
Message: msg,
|
|
76
|
+
PhoneNumber: phoneNumber,
|
|
77
|
+
}).resolves({
|
|
78
|
+
MessageId: messageId,
|
|
79
|
+
})
|
|
80
|
+
const res = await provider.publishSMS(msg, phoneNumber)
|
|
81
|
+
expect(res).is.not.null
|
|
82
|
+
expect(res?.MessageId).to.be.equals(messageId)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('Publish failure', async () => {
|
|
86
|
+
const msg = 'hello world'
|
|
87
|
+
const phoneNumber = '+16042001234'
|
|
88
|
+
SNSMock.on(PublishCommand).rejects(new Error('failed!'))
|
|
89
|
+
const res = await provider.publishSMS(msg, phoneNumber)
|
|
90
|
+
expect(res).is.undefined
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
60
94
|
export {}
|