kannon.js 0.1.3 → 0.2.0-beta1
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/lib/kannon.d.ts +12 -5
- package/lib/kannon.js +6 -12
- package/package.json +1 -1
package/lib/kannon.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import * as proto from './proto/kannon/mailer/apiv1/mailerapiv1';
|
|
2
2
|
import { Recipient } from './proto/kannon/mailer/types/send';
|
|
3
3
|
export declare class KannonCli {
|
|
4
|
-
private readonly
|
|
5
|
-
private readonly senderAlias;
|
|
6
|
-
private readonly token;
|
|
4
|
+
private readonly sender;
|
|
7
5
|
private readonly client;
|
|
8
|
-
|
|
6
|
+
private readonly token;
|
|
7
|
+
constructor(domain: string, apiKey: string, sender: KannonSender, { host, skipTLS }: KannonConfig);
|
|
9
8
|
sendMail(recipients: Recipient[], subject: string, html: string, scheduledTime?: Date): Promise<proto.SendRes>;
|
|
10
9
|
sendMailTemplate(recipients: Recipient[], subject: string, templateId: string, scheduledTime?: Date): Promise<proto.SendRes>;
|
|
11
10
|
private meta;
|
|
12
|
-
private sender;
|
|
13
11
|
}
|
|
12
|
+
export interface KannonConfig {
|
|
13
|
+
host: string;
|
|
14
|
+
skipTLS?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface KannonSender {
|
|
17
|
+
email: string;
|
|
18
|
+
alias: string;
|
|
19
|
+
}
|
|
20
|
+
export type { Recipient };
|
package/lib/kannon.js
CHANGED
|
@@ -64,10 +64,10 @@ var proto = __importStar(require("./proto/kannon/mailer/apiv1/mailerapiv1"));
|
|
|
64
64
|
var grpc = __importStar(require("@grpc/grpc-js"));
|
|
65
65
|
var grpc_promisify_1 = require("./utils/grpc-promisify");
|
|
66
66
|
var KannonCli = /** @class */ (function () {
|
|
67
|
-
function KannonCli(
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
this.token =
|
|
67
|
+
function KannonCli(domain, apiKey, sender, _a) {
|
|
68
|
+
var host = _a.host, _b = _a.skipTLS, skipTLS = _b === void 0 ? false : _b;
|
|
69
|
+
this.sender = sender;
|
|
70
|
+
this.token = Buffer.from("".concat(domain, ":").concat(apiKey)).toString('base64');
|
|
71
71
|
var credentials = skipTLS ? grpc.credentials.createInsecure() : grpc.credentials.createSsl();
|
|
72
72
|
this.client = (0, grpc_promisify_1.promisifyAll)(new proto.MailerClient(host, credentials));
|
|
73
73
|
}
|
|
@@ -77,7 +77,7 @@ var KannonCli = /** @class */ (function () {
|
|
|
77
77
|
return __generator(this, function (_a) {
|
|
78
78
|
return [2 /*return*/, this.client.sendHtml({
|
|
79
79
|
html: html,
|
|
80
|
-
sender: this.sender
|
|
80
|
+
sender: this.sender,
|
|
81
81
|
subject: subject,
|
|
82
82
|
scheduledTime: scheduledTime,
|
|
83
83
|
recipients: recipients,
|
|
@@ -91,7 +91,7 @@ var KannonCli = /** @class */ (function () {
|
|
|
91
91
|
return __generator(this, function (_a) {
|
|
92
92
|
return [2 /*return*/, this.client.sendTemplate({
|
|
93
93
|
templateId: templateId,
|
|
94
|
-
sender: this.sender
|
|
94
|
+
sender: this.sender,
|
|
95
95
|
subject: subject,
|
|
96
96
|
scheduledTime: scheduledTime,
|
|
97
97
|
recipients: recipients,
|
|
@@ -104,12 +104,6 @@ var KannonCli = /** @class */ (function () {
|
|
|
104
104
|
meta.add('authorization', 'Basic ' + this.token);
|
|
105
105
|
return meta;
|
|
106
106
|
};
|
|
107
|
-
KannonCli.prototype.sender = function () {
|
|
108
|
-
return {
|
|
109
|
-
alias: this.senderAlias,
|
|
110
|
-
email: this.senderEmail,
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
107
|
return KannonCli;
|
|
114
108
|
}());
|
|
115
109
|
exports.KannonCli = KannonCli;
|