@flink-app/sms-plugin 0.3.12 → 0.4.1
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/package.json +3 -3
- package/dist/flowmailerClient.d.ts +0 -17
- package/dist/flowmailerClient.js +0 -166
- package/dist/schemas/email.d.ts +0 -90
- package/dist/schemas/email.js +0 -2
- package/dist/schemas/emailFlowmailer.d.ts +0 -24
- package/dist/schemas/emailFlowmailer.js +0 -2
- package/dist/schemas/emailSendgrid.d.ts +0 -40
- package/dist/schemas/emailSendgrid.js +0 -2
- package/dist/schemas/sendgridClientOptions.d.ts +0 -6
- package/dist/schemas/sendgridClientOptions.js +0 -2
- package/dist/schemas/smtpClientOptions.d.ts +0 -9
- package/dist/schemas/smtpClientOptions.js +0 -2
- package/dist/sendgridClient.d.ts +0 -14
- package/dist/sendgridClient.js +0 -68
- package/dist/smtpClient.d.ts +0 -17
- package/dist/smtpClient.js +0 -70
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flink-app/sms-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Flink plugin that makes it possible to send sms",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\"",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"axios": "^0.27.2"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@flink-app/flink": "^0.
|
|
20
|
+
"@flink-app/flink": "^0.4.1",
|
|
21
21
|
"@types/node": "^15.6.2",
|
|
22
22
|
"ts-node": "^9.1.1",
|
|
23
23
|
"typescript": "^4.2.4"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "70eb91072256cd5e0c4e3c5fb013d99f0a2a82e1"
|
|
26
26
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { emailFlowmailer as email } from "./schemas/emailFlowmailer";
|
|
2
|
-
import { client } from "./schemas/client";
|
|
3
|
-
export interface flowmailerClientOptions {
|
|
4
|
-
client_id: string;
|
|
5
|
-
client_secrect: string;
|
|
6
|
-
account_id: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class flowMailerClient implements client {
|
|
9
|
-
accessToken: string;
|
|
10
|
-
client_id: string;
|
|
11
|
-
client_secrect: string;
|
|
12
|
-
account_id: string;
|
|
13
|
-
constructor(options: flowmailerClientOptions);
|
|
14
|
-
getToken(): Promise<void>;
|
|
15
|
-
sendEmail(email: email, to: string): Promise<boolean>;
|
|
16
|
-
send(email: email): Promise<boolean>;
|
|
17
|
-
}
|
package/dist/flowmailerClient.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.flowMailerClient = void 0;
|
|
43
|
-
var axios_1 = __importDefault(require("axios"));
|
|
44
|
-
var querystring_1 = __importDefault(require("querystring"));
|
|
45
|
-
var flowMailerClient = /** @class */ (function () {
|
|
46
|
-
function flowMailerClient(options) {
|
|
47
|
-
this.accessToken = "";
|
|
48
|
-
this.client_id = options.client_id;
|
|
49
|
-
this.client_secrect = options.client_secrect;
|
|
50
|
-
this.account_id = options.account_id;
|
|
51
|
-
}
|
|
52
|
-
flowMailerClient.prototype.getToken = function () {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var resp, ex_1;
|
|
55
|
-
return __generator(this, function (_a) {
|
|
56
|
-
switch (_a.label) {
|
|
57
|
-
case 0:
|
|
58
|
-
_a.trys.push([0, 2, , 3]);
|
|
59
|
-
return [4 /*yield*/, axios_1.default.post("https://login.flowmailer.net/oauth/token", querystring_1.default.stringify({
|
|
60
|
-
client_id: this.client_id,
|
|
61
|
-
client_secret: this.client_secrect,
|
|
62
|
-
grant_type: "client_credentials",
|
|
63
|
-
scope: "api",
|
|
64
|
-
}), {
|
|
65
|
-
headers: {
|
|
66
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
67
|
-
},
|
|
68
|
-
})];
|
|
69
|
-
case 1:
|
|
70
|
-
resp = _a.sent();
|
|
71
|
-
if (resp.status == 200) {
|
|
72
|
-
this.accessToken = resp.data.access_token;
|
|
73
|
-
}
|
|
74
|
-
return [3 /*break*/, 3];
|
|
75
|
-
case 2:
|
|
76
|
-
ex_1 = _a.sent();
|
|
77
|
-
return [3 /*break*/, 3];
|
|
78
|
-
case 3: return [2 /*return*/];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
flowMailerClient.prototype.sendEmail = function (email, to) {
|
|
84
|
-
var _a, _b, _c;
|
|
85
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
var data, resp, ex_2;
|
|
87
|
-
return __generator(this, function (_d) {
|
|
88
|
-
switch (_d.label) {
|
|
89
|
-
case 0:
|
|
90
|
-
data = {
|
|
91
|
-
messageType: "EMAIL",
|
|
92
|
-
senderAddress: email.from,
|
|
93
|
-
recipientAddress: to,
|
|
94
|
-
subject: email.subject,
|
|
95
|
-
text: email.text,
|
|
96
|
-
html: email.html,
|
|
97
|
-
};
|
|
98
|
-
_d.label = 1;
|
|
99
|
-
case 1:
|
|
100
|
-
_d.trys.push([1, 3, , 4]);
|
|
101
|
-
return [4 /*yield*/, axios_1.default.post("https://api.flowmailer.net/" + this.account_id + "/messages/submit", data, {
|
|
102
|
-
headers: {
|
|
103
|
-
Accept: "application/vnd.flowmailer.v1.12+json",
|
|
104
|
-
"Content-Type": "application/vnd.flowmailer.v1.12+json;charset=UTF-8",
|
|
105
|
-
Authorization: "Bearer " + this.accessToken,
|
|
106
|
-
},
|
|
107
|
-
})];
|
|
108
|
-
case 2:
|
|
109
|
-
resp = _d.sent();
|
|
110
|
-
if (resp.status == 201)
|
|
111
|
-
return [2 /*return*/, true];
|
|
112
|
-
return [3 /*break*/, 4];
|
|
113
|
-
case 3:
|
|
114
|
-
ex_2 = _d.sent();
|
|
115
|
-
if (((_c = (_b = (_a = ex_2) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) != "invalid_token") {
|
|
116
|
-
}
|
|
117
|
-
return [3 /*break*/, 4];
|
|
118
|
-
case 4: return [2 /*return*/, false];
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
flowMailerClient.prototype.send = function (email) {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
-
var failure, _a, _b, _i, i, success;
|
|
126
|
-
return __generator(this, function (_c) {
|
|
127
|
-
switch (_c.label) {
|
|
128
|
-
case 0:
|
|
129
|
-
failure = false;
|
|
130
|
-
_a = [];
|
|
131
|
-
for (_b in email.to)
|
|
132
|
-
_a.push(_b);
|
|
133
|
-
_i = 0;
|
|
134
|
-
_c.label = 1;
|
|
135
|
-
case 1:
|
|
136
|
-
if (!(_i < _a.length)) return [3 /*break*/, 8];
|
|
137
|
-
i = _a[_i];
|
|
138
|
-
if (!this.client_secrect) {
|
|
139
|
-
this.getToken();
|
|
140
|
-
}
|
|
141
|
-
return [4 /*yield*/, this.sendEmail(email, email.to[i])];
|
|
142
|
-
case 2:
|
|
143
|
-
success = _c.sent();
|
|
144
|
-
if (!!success) return [3 /*break*/, 4];
|
|
145
|
-
return [4 /*yield*/, this.getToken()];
|
|
146
|
-
case 3:
|
|
147
|
-
_c.sent();
|
|
148
|
-
return [3 /*break*/, 5];
|
|
149
|
-
case 4: return [3 /*break*/, 7];
|
|
150
|
-
case 5: return [4 /*yield*/, this.sendEmail(email, email.to[i])];
|
|
151
|
-
case 6:
|
|
152
|
-
success = _c.sent();
|
|
153
|
-
if (!success)
|
|
154
|
-
failure = true;
|
|
155
|
-
_c.label = 7;
|
|
156
|
-
case 7:
|
|
157
|
-
_i++;
|
|
158
|
-
return [3 /*break*/, 1];
|
|
159
|
-
case 8: return [2 /*return*/, !failure];
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
|
-
return flowMailerClient;
|
|
165
|
-
}());
|
|
166
|
-
exports.flowMailerClient = flowMailerClient;
|
package/dist/schemas/email.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Readable } from "stream";
|
|
3
|
-
import { Url } from "url";
|
|
4
|
-
export declare type email = {
|
|
5
|
-
/**
|
|
6
|
-
* From address used to send the email
|
|
7
|
-
*/
|
|
8
|
-
from: string;
|
|
9
|
-
/**
|
|
10
|
-
* Email addresses to send to
|
|
11
|
-
*/
|
|
12
|
-
to: string[];
|
|
13
|
-
/**
|
|
14
|
-
* Reply email
|
|
15
|
-
*/
|
|
16
|
-
replyTo?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Email addresses to add as BCC
|
|
19
|
-
*/
|
|
20
|
-
bcc?: string[];
|
|
21
|
-
/**
|
|
22
|
-
* Subject of email
|
|
23
|
-
*/
|
|
24
|
-
subject: string;
|
|
25
|
-
/**
|
|
26
|
-
* attached file object
|
|
27
|
-
*/
|
|
28
|
-
attachments?: Attachment[];
|
|
29
|
-
} & ({
|
|
30
|
-
text: string;
|
|
31
|
-
} | {
|
|
32
|
-
html: string;
|
|
33
|
-
});
|
|
34
|
-
interface Attachment {
|
|
35
|
-
/**
|
|
36
|
-
* String, Buffer or a Stream contents for the attachment
|
|
37
|
-
*/
|
|
38
|
-
content?: string | Buffer | Readable;
|
|
39
|
-
/**
|
|
40
|
-
* filename to be reported as the name of the attached file. Use of unicode is allowed
|
|
41
|
-
*/
|
|
42
|
-
filename?: string | false;
|
|
43
|
-
/**
|
|
44
|
-
* path to the file if you want to stream the file instead of including it (better for larger attachments)
|
|
45
|
-
*/
|
|
46
|
-
path?: string | Url;
|
|
47
|
-
/**
|
|
48
|
-
* an URL to the file (data uris are allowed as well)
|
|
49
|
-
*/
|
|
50
|
-
href?: string;
|
|
51
|
-
/**
|
|
52
|
-
* optional HTTP headers to pass on with the href request, eg. {authorization: "bearer ..."}
|
|
53
|
-
*/
|
|
54
|
-
httpHeaders?: string;
|
|
55
|
-
/**
|
|
56
|
-
* optional content type for the attachment, if not set will be derived from the filename property
|
|
57
|
-
*/
|
|
58
|
-
contentType?: string;
|
|
59
|
-
/**
|
|
60
|
-
* optional content disposition type for the attachment, defaults to ‘attachment’
|
|
61
|
-
*/
|
|
62
|
-
contentDisposition?: 'attachment' | 'inline';
|
|
63
|
-
/**
|
|
64
|
-
* optional content id for using inline images in HTML message source
|
|
65
|
-
*/
|
|
66
|
-
cid?: string;
|
|
67
|
-
/**
|
|
68
|
-
* If set and content is string, then encodes the content to a Buffer using the specified encoding. Example values: ‘base64’, ‘hex’, ‘binary’ etc.
|
|
69
|
-
* Useful if you want to use binary attachments in a JSON formatted email object
|
|
70
|
-
*/
|
|
71
|
-
encoding?: string;
|
|
72
|
-
/**
|
|
73
|
-
* custom headers for the attachment node. Same usage as with message headers
|
|
74
|
-
*/
|
|
75
|
-
headers?: {
|
|
76
|
-
[key: string]: string | string[] | {
|
|
77
|
-
prepared: boolean;
|
|
78
|
-
value: string;
|
|
79
|
-
};
|
|
80
|
-
} | Array<{
|
|
81
|
-
key: string;
|
|
82
|
-
value: string;
|
|
83
|
-
}>;
|
|
84
|
-
/**
|
|
85
|
-
* is an optional special value that overrides entire contents of current mime node including mime headers.
|
|
86
|
-
* Useful if you want to prepare node contents yourself
|
|
87
|
-
*/
|
|
88
|
-
raw?: string | Buffer;
|
|
89
|
-
}
|
|
90
|
-
export {};
|
package/dist/schemas/email.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare type emailFlowmailer = {
|
|
2
|
-
/**
|
|
3
|
-
* From address used to send the email
|
|
4
|
-
*/
|
|
5
|
-
from: string;
|
|
6
|
-
/**
|
|
7
|
-
* Email addresses to send to
|
|
8
|
-
*/
|
|
9
|
-
to: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Reply email
|
|
12
|
-
*/
|
|
13
|
-
replyTo?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Email addresses to add as BCC
|
|
16
|
-
*/
|
|
17
|
-
bcc?: string[];
|
|
18
|
-
/**
|
|
19
|
-
* Subject of email
|
|
20
|
-
*/
|
|
21
|
-
subject: string;
|
|
22
|
-
text?: string;
|
|
23
|
-
html?: string;
|
|
24
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export declare type emailSendgrid = {
|
|
2
|
-
/**
|
|
3
|
-
* From address used to send the email
|
|
4
|
-
*/
|
|
5
|
-
from: string;
|
|
6
|
-
/**
|
|
7
|
-
* Email addresses to send to
|
|
8
|
-
*/
|
|
9
|
-
to: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Reply email
|
|
12
|
-
*/
|
|
13
|
-
replyTo?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Email addresses to add as BCC
|
|
16
|
-
*/
|
|
17
|
-
bcc?: string[];
|
|
18
|
-
/**
|
|
19
|
-
* Subject of email
|
|
20
|
-
*/
|
|
21
|
-
subject: string;
|
|
22
|
-
/**
|
|
23
|
-
* attached file object
|
|
24
|
-
*/
|
|
25
|
-
attachments?: Attachment[];
|
|
26
|
-
} & ({
|
|
27
|
-
text: string;
|
|
28
|
-
} | {
|
|
29
|
-
html: string;
|
|
30
|
-
});
|
|
31
|
-
interface Attachment {
|
|
32
|
-
/**
|
|
33
|
-
* base64 encoded string
|
|
34
|
-
*/
|
|
35
|
-
content: string;
|
|
36
|
-
filename: string;
|
|
37
|
-
type?: string;
|
|
38
|
-
disposition?: string;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
package/dist/sendgridClient.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { MailService } from "@sendgrid/mail";
|
|
2
|
-
import { emailSendgrid as email } from "./schemas/emailSendgrid";
|
|
3
|
-
import { client } from "./schemas/client";
|
|
4
|
-
export interface sendgridClientOptions {
|
|
5
|
-
/**
|
|
6
|
-
* API-key to use when sending email
|
|
7
|
-
*/
|
|
8
|
-
apiKey: string;
|
|
9
|
-
}
|
|
10
|
-
export declare class sendgridClient implements client {
|
|
11
|
-
sendgrid: MailService;
|
|
12
|
-
constructor(options: sendgridClientOptions);
|
|
13
|
-
send(email: email): Promise<boolean>;
|
|
14
|
-
}
|
package/dist/sendgridClient.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.sendgridClient = void 0;
|
|
40
|
-
var mail_1 = require("@sendgrid/mail");
|
|
41
|
-
var sendgridClient = /** @class */ (function () {
|
|
42
|
-
function sendgridClient(options) {
|
|
43
|
-
this.sendgrid = new mail_1.MailService();
|
|
44
|
-
this.sendgrid.setApiKey(options.apiKey);
|
|
45
|
-
}
|
|
46
|
-
sendgridClient.prototype.send = function (email) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
var ex_1;
|
|
49
|
-
return __generator(this, function (_a) {
|
|
50
|
-
switch (_a.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
_a.trys.push([0, 2, , 3]);
|
|
53
|
-
return [4 /*yield*/, this.sendgrid.send(email)];
|
|
54
|
-
case 1:
|
|
55
|
-
_a.sent();
|
|
56
|
-
return [3 /*break*/, 3];
|
|
57
|
-
case 2:
|
|
58
|
-
ex_1 = _a.sent();
|
|
59
|
-
console.log(JSON.stringify(ex_1));
|
|
60
|
-
return [2 /*return*/, false];
|
|
61
|
-
case 3: return [2 /*return*/, true];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
return sendgridClient;
|
|
67
|
-
}());
|
|
68
|
-
exports.sendgridClient = sendgridClient;
|
package/dist/smtpClient.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import nodemailer from "nodemailer";
|
|
2
|
-
import { email } from "./schemas/email";
|
|
3
|
-
import { client } from "./schemas/client";
|
|
4
|
-
export interface smtpClientOptions {
|
|
5
|
-
host: string;
|
|
6
|
-
port: number;
|
|
7
|
-
secure: boolean;
|
|
8
|
-
auth?: {
|
|
9
|
-
user: string;
|
|
10
|
-
pass: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export declare class smtpClient implements client {
|
|
14
|
-
transporter: nodemailer.Transporter;
|
|
15
|
-
constructor(options: smtpClientOptions);
|
|
16
|
-
send(email: email): Promise<boolean>;
|
|
17
|
-
}
|
package/dist/smtpClient.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.smtpClient = void 0;
|
|
43
|
-
var nodemailer_1 = __importDefault(require("nodemailer"));
|
|
44
|
-
var smtpClient = /** @class */ (function () {
|
|
45
|
-
function smtpClient(options) {
|
|
46
|
-
this.transporter = nodemailer_1.default.createTransport(options);
|
|
47
|
-
}
|
|
48
|
-
smtpClient.prototype.send = function (email) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
-
var ex_1;
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
_a.trys.push([0, 2, , 3]);
|
|
55
|
-
return [4 /*yield*/, this.transporter.sendMail(email)];
|
|
56
|
-
case 1:
|
|
57
|
-
_a.sent();
|
|
58
|
-
return [3 /*break*/, 3];
|
|
59
|
-
case 2:
|
|
60
|
-
ex_1 = _a.sent();
|
|
61
|
-
console.log(JSON.stringify(ex_1));
|
|
62
|
-
return [2 /*return*/, false];
|
|
63
|
-
case 3: return [2 /*return*/, true];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
return smtpClient;
|
|
69
|
-
}());
|
|
70
|
-
exports.smtpClient = smtpClient;
|