mailisk 2.2.4 → 2.3.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/README.md +97 -0
- package/dist/index.d.mts +536 -0
- package/dist/index.d.ts +199 -1
- package/dist/index.js +219 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +212 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/mailisk.interfaces.ts +109 -0
- package/src/mailisk.ts +144 -2
- package/tests/mocks/axios-mocks.ts +31 -0
- package/tests/unit/mailisk.test.ts +153 -0
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ Mailisk is an end-to-end email and SMS testing platform. It allows you to receiv
|
|
|
5
5
|
- Get a unique subdomain and unlimited email addresses for free.
|
|
6
6
|
- Easily automate E2E password reset and account verification by catching emails.
|
|
7
7
|
- Receive SMS messages and automate SMS tests.
|
|
8
|
+
- Generate TOTP authenticator codes and manage saved TOTP devices.
|
|
8
9
|
- Virtual SMTP and SMS support to test without 3rd party clients.
|
|
9
10
|
|
|
10
11
|
## Get started
|
|
@@ -214,3 +215,99 @@ await mailisk.sendVirtualSms({
|
|
|
214
215
|
body: "Test message",
|
|
215
216
|
});
|
|
216
217
|
```
|
|
218
|
+
|
|
219
|
+
## Client functions (TOTP)
|
|
220
|
+
|
|
221
|
+
TOTP methods call the Mailisk API to generate codes and manage saved authenticator devices. The client does not generate TOTP codes locally.
|
|
222
|
+
|
|
223
|
+
These endpoints require an organisation API key, prefixed with `sk_org_`.
|
|
224
|
+
|
|
225
|
+
### `listTotpDevices(params?)`
|
|
226
|
+
|
|
227
|
+
List active saved TOTP devices.
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
const devices = await mailisk.listTotpDevices({
|
|
231
|
+
limit: 20,
|
|
232
|
+
offset: 0,
|
|
233
|
+
issuer: "GitHub",
|
|
234
|
+
username: "qa@example.com",
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### `createTotpDevice(params)`
|
|
239
|
+
|
|
240
|
+
Create a saved TOTP device from a Base32 shared secret using default settings: 6 digits, 30 second period, and SHA1.
|
|
241
|
+
|
|
242
|
+
```js
|
|
243
|
+
const device = await mailisk.createTotpDevice({
|
|
244
|
+
name: "GitHub staging",
|
|
245
|
+
sharedSecret: "JBSWY3DPEHPK3PXP",
|
|
246
|
+
expiresAt: "2026-06-01T12:00:00.000Z",
|
|
247
|
+
});
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### `createCustomTotpDevice(params)`
|
|
251
|
+
|
|
252
|
+
Create a saved TOTP device with custom settings.
|
|
253
|
+
|
|
254
|
+
```js
|
|
255
|
+
const device = await mailisk.createCustomTotpDevice({
|
|
256
|
+
name: "GitHub staging",
|
|
257
|
+
secret: "JBSWY3DPEHPK3PXP",
|
|
258
|
+
username: "qa@example.com",
|
|
259
|
+
issuer: "GitHub",
|
|
260
|
+
digits: 6,
|
|
261
|
+
period: 30,
|
|
262
|
+
algorithm: "SHA1",
|
|
263
|
+
});
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### `createTotpDeviceFromBase32SecretKey(params)`
|
|
267
|
+
|
|
268
|
+
Create a saved TOTP device from a Base32 secret key.
|
|
269
|
+
|
|
270
|
+
```js
|
|
271
|
+
const device = await mailisk.createTotpDeviceFromBase32SecretKey({
|
|
272
|
+
base32SecretKey: "JBSWY3DPEHPK3PXP",
|
|
273
|
+
username: "qa@example.com",
|
|
274
|
+
issuer: "GitHub",
|
|
275
|
+
});
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### `createTotpDeviceFromOtpAuthUrl(params)`
|
|
279
|
+
|
|
280
|
+
Create a saved TOTP device from an `otpauth://totp/...` URL.
|
|
281
|
+
|
|
282
|
+
```js
|
|
283
|
+
const device = await mailisk.createTotpDeviceFromOtpAuthUrl({
|
|
284
|
+
otpAuthUrl: "otpauth://totp/GitHub:qa@example.com?secret=JBSWY3DPEHPK3PXP&issuer=GitHub",
|
|
285
|
+
});
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### `getTotpOtpBySharedSecret(sharedSecret)`
|
|
289
|
+
|
|
290
|
+
Generate a TOTP code from a shared secret without saving a device.
|
|
291
|
+
|
|
292
|
+
```js
|
|
293
|
+
const otp = await mailisk.getTotpOtpBySharedSecret("JBSWY3DPEHPK3PXP");
|
|
294
|
+
|
|
295
|
+
console.log(otp.code);
|
|
296
|
+
console.log(otp.expires);
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### `getTotpOtpByDeviceId(deviceId)`
|
|
300
|
+
|
|
301
|
+
Generate a TOTP code for a saved device.
|
|
302
|
+
|
|
303
|
+
```js
|
|
304
|
+
const otp = await mailisk.getTotpOtpByDeviceId(device.id);
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### `deleteTotpDevice(deviceId)`
|
|
308
|
+
|
|
309
|
+
Delete a saved TOTP device.
|
|
310
|
+
|
|
311
|
+
```js
|
|
312
|
+
await mailisk.deleteTotpDevice(device.id);
|
|
313
|
+
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
import { AxiosBasicCredentials, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { Attachment } from 'nodemailer/lib/mailer';
|
|
3
|
+
|
|
4
|
+
interface EmailAddress {
|
|
5
|
+
/** Email address */
|
|
6
|
+
address: string;
|
|
7
|
+
/** Display name, if one is specified */
|
|
8
|
+
name?: string;
|
|
9
|
+
}
|
|
10
|
+
interface EmailAttachment {
|
|
11
|
+
/** Unique identifier for the attachment */
|
|
12
|
+
id: string;
|
|
13
|
+
/** Filename of the attachment */
|
|
14
|
+
filename: string;
|
|
15
|
+
/** Content type of the attachment */
|
|
16
|
+
content_type: string;
|
|
17
|
+
/** Size in bytes of the attachment */
|
|
18
|
+
size: number;
|
|
19
|
+
}
|
|
20
|
+
interface Email {
|
|
21
|
+
/** Namespace scoped ID */
|
|
22
|
+
id: string;
|
|
23
|
+
/** Sender of email */
|
|
24
|
+
from: EmailAddress;
|
|
25
|
+
/** Recepients of email */
|
|
26
|
+
to: EmailAddress[];
|
|
27
|
+
/** Carbon-copied recipients for email message */
|
|
28
|
+
cc?: EmailAddress[];
|
|
29
|
+
/** Blind carbon-copied recipients for email message */
|
|
30
|
+
bcc?: EmailAddress[];
|
|
31
|
+
/** Subject of email */
|
|
32
|
+
subject?: string;
|
|
33
|
+
/** Email content that was sent in HTML format */
|
|
34
|
+
html?: string;
|
|
35
|
+
/** Email content that was sent in plain text format */
|
|
36
|
+
text?: string;
|
|
37
|
+
/** The datetime that this email was received */
|
|
38
|
+
received_date: Date;
|
|
39
|
+
/** The unix timestamp (s) that this email was received */
|
|
40
|
+
received_timestamp: number;
|
|
41
|
+
/** The unix timestamp (s) when this email will be deleted */
|
|
42
|
+
expires_timestamp: number;
|
|
43
|
+
/** The spam score as reported by SpamAssassin */
|
|
44
|
+
spam_score?: number;
|
|
45
|
+
/** The headers of the email */
|
|
46
|
+
headers?: Record<string, string>;
|
|
47
|
+
/** The attachments of the email */
|
|
48
|
+
attachments?: EmailAttachment[];
|
|
49
|
+
}
|
|
50
|
+
interface SmsMessage {
|
|
51
|
+
/** Unique identifier for the message */
|
|
52
|
+
id: string;
|
|
53
|
+
/** Unique identifier for the SMS phone number */
|
|
54
|
+
sms_phone_number_id: string;
|
|
55
|
+
/** Body of the message */
|
|
56
|
+
body: string;
|
|
57
|
+
/** From number of the message */
|
|
58
|
+
from_number: string;
|
|
59
|
+
/** To number of the message */
|
|
60
|
+
to_number: string;
|
|
61
|
+
/** Provider message ID */
|
|
62
|
+
provider_message_id?: string;
|
|
63
|
+
/** Date and time the message was created */
|
|
64
|
+
created_at: string;
|
|
65
|
+
/** Direction of the message */
|
|
66
|
+
direction: "inbound" | "outbound";
|
|
67
|
+
}
|
|
68
|
+
interface SmsNumber {
|
|
69
|
+
/** Unique identifier for the SMS number */
|
|
70
|
+
id: string;
|
|
71
|
+
/** Unique identifier for the organisation */
|
|
72
|
+
organisation_id: string;
|
|
73
|
+
/** Status of the SMS number */
|
|
74
|
+
status: "requested" | "active" | "disabled";
|
|
75
|
+
/** Country of the SMS number */
|
|
76
|
+
country: string;
|
|
77
|
+
/** SMS Phone number */
|
|
78
|
+
phone_number?: string;
|
|
79
|
+
/** Date and time the SMS number was created */
|
|
80
|
+
created_at: string;
|
|
81
|
+
/** Date and time the SMS number was updated */
|
|
82
|
+
updated_at: string;
|
|
83
|
+
}
|
|
84
|
+
interface SearchInboxParams {
|
|
85
|
+
/**
|
|
86
|
+
* The maximum number of emails that can be returned in this request, used alongside `offset` for pagination.
|
|
87
|
+
*/
|
|
88
|
+
limit?: number;
|
|
89
|
+
/**
|
|
90
|
+
* The number of emails to skip/ignore, used alongside `limit` for pagination.
|
|
91
|
+
*/
|
|
92
|
+
offset?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Filter emails by starting unix timestamp in seconds.
|
|
95
|
+
*/
|
|
96
|
+
from_timestamp?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Filter emails by ending unix timestamp in seconds.
|
|
99
|
+
*/
|
|
100
|
+
to_timestamp?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Filter emails by 'to' address. Address must start with this.
|
|
103
|
+
*
|
|
104
|
+
* 'foo' would return for 'foobar@namespace.mailisk.net' but not 'barfoo@namespace.mailisk.net'
|
|
105
|
+
*/
|
|
106
|
+
to_addr_prefix?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Filter emails by 'from' address. Address must include this.
|
|
109
|
+
*
|
|
110
|
+
* '@foo' would return for 'a@foo.com', 'b@foo.net'
|
|
111
|
+
*/
|
|
112
|
+
from_addr_includes?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Filter emails by subject. This is case insensitive. Subject must include this.
|
|
115
|
+
*
|
|
116
|
+
* 'password' would return for 'Password reset', 'Reset password notification' but not 'Reset'
|
|
117
|
+
*/
|
|
118
|
+
subject_includes?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Will keep the request going till at least one email would be returned.
|
|
121
|
+
*
|
|
122
|
+
* Default is `true`
|
|
123
|
+
*/
|
|
124
|
+
wait?: boolean;
|
|
125
|
+
}
|
|
126
|
+
interface SearchInboxResponse {
|
|
127
|
+
/**
|
|
128
|
+
* Total number of emails matching query.
|
|
129
|
+
*/
|
|
130
|
+
total_count: number;
|
|
131
|
+
/**
|
|
132
|
+
* Parameters that were used for the query
|
|
133
|
+
*/
|
|
134
|
+
options: SearchInboxParams;
|
|
135
|
+
/**
|
|
136
|
+
* Emails
|
|
137
|
+
*/
|
|
138
|
+
data: Email[];
|
|
139
|
+
}
|
|
140
|
+
interface SmtpSettings {
|
|
141
|
+
data: {
|
|
142
|
+
host: string;
|
|
143
|
+
port: number;
|
|
144
|
+
username: string;
|
|
145
|
+
password: string;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
interface GetAttachmentResponse {
|
|
149
|
+
data: {
|
|
150
|
+
id: string;
|
|
151
|
+
filename: string;
|
|
152
|
+
content_type: string;
|
|
153
|
+
size: number;
|
|
154
|
+
expires_at: string | null;
|
|
155
|
+
download_url: string;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
interface ListNamespacesResponse {
|
|
159
|
+
total_count: number;
|
|
160
|
+
data: {
|
|
161
|
+
id: string;
|
|
162
|
+
namespace: string;
|
|
163
|
+
}[];
|
|
164
|
+
}
|
|
165
|
+
interface SendVirtualEmailParams {
|
|
166
|
+
/** Sender of email */
|
|
167
|
+
from: string;
|
|
168
|
+
/**
|
|
169
|
+
* Recepients of email
|
|
170
|
+
*
|
|
171
|
+
* Must match namespace. E.g. if using namespace 'mynamespace' `to` must be 'something@mynamespace.mailisk.net'.
|
|
172
|
+
*/
|
|
173
|
+
to: string;
|
|
174
|
+
/** The subject of the e-mail */
|
|
175
|
+
subject: string;
|
|
176
|
+
/** The plaintext version of the message */
|
|
177
|
+
text?: string | undefined;
|
|
178
|
+
/** The HTML version of the message */
|
|
179
|
+
html?: string | undefined;
|
|
180
|
+
/** Custom headers for the email */
|
|
181
|
+
headers?: Record<string, string>;
|
|
182
|
+
/** Attachments to the email */
|
|
183
|
+
attachments?: Attachment[];
|
|
184
|
+
}
|
|
185
|
+
interface SearchSmsMessagesParams {
|
|
186
|
+
/**
|
|
187
|
+
* The maximum number of SMS messages returned (1-100), used alongside `offset` for pagination.
|
|
188
|
+
*/
|
|
189
|
+
limit?: number;
|
|
190
|
+
/**
|
|
191
|
+
* The number of SMS messages to skip/ignore, used alongside `limit` for pagination.
|
|
192
|
+
*/
|
|
193
|
+
offset?: number;
|
|
194
|
+
/**
|
|
195
|
+
* Filter messages by body contents (case insensitive).
|
|
196
|
+
*/
|
|
197
|
+
body?: string;
|
|
198
|
+
/**
|
|
199
|
+
* Filter messages by sender phone number prefix.
|
|
200
|
+
*/
|
|
201
|
+
from_number?: string;
|
|
202
|
+
/**
|
|
203
|
+
* Filter messages created on or after this date.
|
|
204
|
+
* Provide an ISO 8601 timestamp string.
|
|
205
|
+
*/
|
|
206
|
+
from_date?: string;
|
|
207
|
+
/**
|
|
208
|
+
* Filter messages created on or before this date.
|
|
209
|
+
* Provide an ISO 8601 timestamp string.
|
|
210
|
+
*/
|
|
211
|
+
to_date?: string;
|
|
212
|
+
/**
|
|
213
|
+
* When true, keep the request open until at least one SMS is returned.
|
|
214
|
+
*/
|
|
215
|
+
wait?: boolean;
|
|
216
|
+
}
|
|
217
|
+
interface SearchSmsMessagesResponse {
|
|
218
|
+
total_count: number;
|
|
219
|
+
options: SearchSmsMessagesParams;
|
|
220
|
+
data: SmsMessage[];
|
|
221
|
+
}
|
|
222
|
+
interface ListSmsNumbersResponse {
|
|
223
|
+
total_count: number;
|
|
224
|
+
data: SmsNumber[];
|
|
225
|
+
}
|
|
226
|
+
interface SendVirtualSmsParams {
|
|
227
|
+
/** The phone number to send the SMS from */
|
|
228
|
+
from_number: string;
|
|
229
|
+
/** The phone number to send the SMS to */
|
|
230
|
+
to_number: string;
|
|
231
|
+
/** The body of the SMS message */
|
|
232
|
+
body: string;
|
|
233
|
+
}
|
|
234
|
+
type TotpAlgorithm = "SHA1" | "SHA256" | "SHA512";
|
|
235
|
+
type KnownTotpDeviceSource = "shared_secret" | "custom" | "base32_secret_key" | "otpauth_url";
|
|
236
|
+
type TotpDeviceSource = KnownTotpDeviceSource | (string & {});
|
|
237
|
+
interface TotpDevice {
|
|
238
|
+
id: string;
|
|
239
|
+
organisation_id: string;
|
|
240
|
+
name: string;
|
|
241
|
+
username?: string | null;
|
|
242
|
+
issuer?: string | null;
|
|
243
|
+
digits: number;
|
|
244
|
+
period: number;
|
|
245
|
+
algorithm: TotpAlgorithm;
|
|
246
|
+
source: TotpDeviceSource;
|
|
247
|
+
expiresAt?: string | null;
|
|
248
|
+
created_at: string;
|
|
249
|
+
updated_at: string;
|
|
250
|
+
}
|
|
251
|
+
interface ListTotpDevicesParams {
|
|
252
|
+
/** The maximum number of saved TOTP devices returned (1-100), used alongside `offset` for pagination. */
|
|
253
|
+
limit?: number;
|
|
254
|
+
/** The number of saved TOTP devices to skip/ignore, used alongside `limit` for pagination. Must be >= 0. */
|
|
255
|
+
offset?: number;
|
|
256
|
+
/** Case-insensitive partial username match. Trimmed before sending. */
|
|
257
|
+
username?: string;
|
|
258
|
+
/** Case-insensitive partial issuer match. Trimmed before sending. */
|
|
259
|
+
issuer?: string;
|
|
260
|
+
}
|
|
261
|
+
interface ListTotpDevicesResponse {
|
|
262
|
+
total_count: number;
|
|
263
|
+
options: ListTotpDevicesParams;
|
|
264
|
+
items: TotpDevice[];
|
|
265
|
+
}
|
|
266
|
+
interface CreateTotpDeviceParams {
|
|
267
|
+
/** Base32 shared secret. Uses default TOTP settings. */
|
|
268
|
+
sharedSecret: string;
|
|
269
|
+
/** Optional saved-device display name. Max 120 characters. */
|
|
270
|
+
name?: string;
|
|
271
|
+
/** Future ISO timestamp after which the saved device expires. */
|
|
272
|
+
expiresAt?: string;
|
|
273
|
+
}
|
|
274
|
+
interface CreateCustomTotpDeviceParams {
|
|
275
|
+
/** Base32 shared secret. */
|
|
276
|
+
secret: string;
|
|
277
|
+
/** Optional saved-device display name. Max 120 characters. */
|
|
278
|
+
name?: string;
|
|
279
|
+
/** Account label. Max 240 characters. */
|
|
280
|
+
username?: string;
|
|
281
|
+
/** Issuer/app label. Max 240 characters. */
|
|
282
|
+
issuer?: string;
|
|
283
|
+
/** Number of OTP digits. */
|
|
284
|
+
digits?: 6 | 8;
|
|
285
|
+
/** OTP period in seconds. Must be an integer from 10 to 300. */
|
|
286
|
+
period?: number;
|
|
287
|
+
/** Hashing algorithm. */
|
|
288
|
+
algorithm?: TotpAlgorithm;
|
|
289
|
+
/** Future ISO timestamp after which the saved device expires. */
|
|
290
|
+
expiresAt?: string;
|
|
291
|
+
}
|
|
292
|
+
interface CreateBase32SecretKeyTotpDeviceParams {
|
|
293
|
+
/** Base32 shared secret key. */
|
|
294
|
+
base32SecretKey: string;
|
|
295
|
+
/** Optional saved-device display name. Max 120 characters. */
|
|
296
|
+
name?: string;
|
|
297
|
+
/** Account label. Max 240 characters. */
|
|
298
|
+
username?: string;
|
|
299
|
+
/** Issuer/app label. Max 240 characters. */
|
|
300
|
+
issuer?: string;
|
|
301
|
+
/** Number of OTP digits. */
|
|
302
|
+
digits?: 6 | 8;
|
|
303
|
+
/** OTP period in seconds. Must be an integer from 10 to 300. */
|
|
304
|
+
period?: number;
|
|
305
|
+
/** Hashing algorithm. */
|
|
306
|
+
algorithm?: TotpAlgorithm;
|
|
307
|
+
/** Future ISO timestamp after which the saved device expires. */
|
|
308
|
+
expiresAt?: string;
|
|
309
|
+
}
|
|
310
|
+
interface CreateOtpAuthUrlTotpDeviceParams {
|
|
311
|
+
/** otpauth://totp URL with a secret query parameter. */
|
|
312
|
+
otpAuthUrl: string;
|
|
313
|
+
/** Optional saved-device display name. Max 120 characters. */
|
|
314
|
+
name?: string;
|
|
315
|
+
/** Account label, used when missing from the URL label. Max 240 characters. */
|
|
316
|
+
username?: string;
|
|
317
|
+
/** Issuer/app label, used when missing from the URL. Max 240 characters. */
|
|
318
|
+
issuer?: string;
|
|
319
|
+
/** Number of OTP digits, used when missing from the URL. */
|
|
320
|
+
digits?: 6 | 8;
|
|
321
|
+
/** OTP period in seconds, used when missing from the URL. Must be an integer from 10 to 300. */
|
|
322
|
+
period?: number;
|
|
323
|
+
/** Hashing algorithm, used when missing from the URL. */
|
|
324
|
+
algorithm?: TotpAlgorithm;
|
|
325
|
+
/** Future ISO timestamp after which the saved device expires. */
|
|
326
|
+
expiresAt?: string;
|
|
327
|
+
}
|
|
328
|
+
interface TotpOtpResponse {
|
|
329
|
+
code: string;
|
|
330
|
+
expires: string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
declare class MailiskClient {
|
|
334
|
+
constructor({ apiKey, baseUrl, auth }: {
|
|
335
|
+
apiKey: string;
|
|
336
|
+
baseUrl?: string;
|
|
337
|
+
auth?: AxiosBasicCredentials;
|
|
338
|
+
});
|
|
339
|
+
private readonly axiosInstance;
|
|
340
|
+
/**
|
|
341
|
+
* Search SMS messages sent to a phone number.
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* Search for SMS messages sent to a phone number
|
|
345
|
+
* ```typescript
|
|
346
|
+
* const { data: smsMessages } = await client.searchSmsMessages("1234567890");
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
searchSmsMessages(phoneNumber: string, params?: SearchSmsMessagesParams, config?: AxiosRequestConfig): Promise<SearchSmsMessagesResponse>;
|
|
350
|
+
/**
|
|
351
|
+
* List all SMS phone numbers associated with the current account.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* List all SMS phone numbers
|
|
355
|
+
* ```typescript
|
|
356
|
+
* const { data: smsNumbers } = await client.listSmsNumbers();
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
listSmsNumbers(): Promise<ListSmsNumbersResponse>;
|
|
360
|
+
sendVirtualSms(params: SendVirtualSmsParams): Promise<void>;
|
|
361
|
+
/**
|
|
362
|
+
* List saved TOTP devices.
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* List saved TOTP devices for an issuer and username
|
|
366
|
+
* ```typescript
|
|
367
|
+
* const { items: devices } = await client.listTotpDevices({
|
|
368
|
+
* issuer: "GitHub",
|
|
369
|
+
* username: "qa@example.com",
|
|
370
|
+
* });
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
listTotpDevices(params?: ListTotpDevicesParams): Promise<ListTotpDevicesResponse>;
|
|
374
|
+
/**
|
|
375
|
+
* Create a saved TOTP device from a Base32 shared secret using default TOTP settings.
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* Create a saved TOTP device from a shared secret
|
|
379
|
+
* ```typescript
|
|
380
|
+
* const device = await client.createTotpDevice({
|
|
381
|
+
* name: "GitHub staging",
|
|
382
|
+
* sharedSecret: "JBSWY3DPEHPK3PXP",
|
|
383
|
+
* });
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
386
|
+
createTotpDevice(params: CreateTotpDeviceParams): Promise<TotpDevice>;
|
|
387
|
+
/**
|
|
388
|
+
* Create a saved TOTP device with custom settings.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* Create a saved TOTP device with custom settings
|
|
392
|
+
* ```typescript
|
|
393
|
+
* const device = await client.createCustomTotpDevice({
|
|
394
|
+
* name: "GitHub staging",
|
|
395
|
+
* secret: "JBSWY3DPEHPK3PXP",
|
|
396
|
+
* username: "qa@example.com",
|
|
397
|
+
* issuer: "GitHub",
|
|
398
|
+
* digits: 6,
|
|
399
|
+
* period: 30,
|
|
400
|
+
* algorithm: "SHA1",
|
|
401
|
+
* });
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
createCustomTotpDevice(params: CreateCustomTotpDeviceParams): Promise<TotpDevice>;
|
|
405
|
+
/**
|
|
406
|
+
* Create a saved TOTP device from a Base32 secret key.
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* Create a saved TOTP device from a Base32 secret key
|
|
410
|
+
* ```typescript
|
|
411
|
+
* const device = await client.createTotpDeviceFromBase32SecretKey({
|
|
412
|
+
* base32SecretKey: "JBSWY3DPEHPK3PXP",
|
|
413
|
+
* username: "qa@example.com",
|
|
414
|
+
* issuer: "GitHub",
|
|
415
|
+
* });
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
createTotpDeviceFromBase32SecretKey(params: CreateBase32SecretKeyTotpDeviceParams): Promise<TotpDevice>;
|
|
419
|
+
/**
|
|
420
|
+
* Create a saved TOTP device from an otpauth://totp URL.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* Create a saved TOTP device from an otpauth URL
|
|
424
|
+
* ```typescript
|
|
425
|
+
* const device = await client.createTotpDeviceFromOtpAuthUrl({
|
|
426
|
+
* otpAuthUrl: "otpauth://totp/GitHub:qa@example.com?secret=JBSWY3DPEHPK3PXP&issuer=GitHub",
|
|
427
|
+
* });
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
createTotpDeviceFromOtpAuthUrl(params: CreateOtpAuthUrlTotpDeviceParams): Promise<TotpDevice>;
|
|
431
|
+
/**
|
|
432
|
+
* Generate a TOTP code from a shared secret without saving a device.
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* Generate a TOTP code from a shared secret
|
|
436
|
+
* ```typescript
|
|
437
|
+
* const { code } = await client.getTotpOtpBySharedSecret("JBSWY3DPEHPK3PXP");
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
getTotpOtpBySharedSecret(sharedSecret: string): Promise<TotpOtpResponse>;
|
|
441
|
+
/**
|
|
442
|
+
* Generate a TOTP code for a saved device.
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* Generate a TOTP code for a saved device
|
|
446
|
+
* ```typescript
|
|
447
|
+
* const { code } = await client.getTotpOtpByDeviceId(device.id);
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
getTotpOtpByDeviceId(deviceId: string): Promise<TotpOtpResponse>;
|
|
451
|
+
/**
|
|
452
|
+
* Delete a saved TOTP device.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* Delete a saved TOTP device
|
|
456
|
+
* ```typescript
|
|
457
|
+
* await client.deleteTotpDevice(device.id);
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
deleteTotpDevice(deviceId: string): Promise<void>;
|
|
461
|
+
/**
|
|
462
|
+
* List all namespaces that belong to the current account (API key).
|
|
463
|
+
*/
|
|
464
|
+
listNamespaces(): Promise<ListNamespacesResponse>;
|
|
465
|
+
/**
|
|
466
|
+
* Send an email using the Virtual SMTP.
|
|
467
|
+
*
|
|
468
|
+
* These emails can only be sent to valid Mailisk namespaces, i.e. emails that end in @mynamespace.mailisk.net
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* For example, sending a test email:
|
|
472
|
+
* ```typescript
|
|
473
|
+
* client.sendVirtualEmail(namespace, {
|
|
474
|
+
* from: "test@example.com",
|
|
475
|
+
* to: `john@${namespace}.mailisk.net`,
|
|
476
|
+
* subject: "This is a test",
|
|
477
|
+
* text: "Testing",
|
|
478
|
+
* });
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
sendVirtualEmail(namespace: string, params: SendVirtualEmailParams): Promise<void>;
|
|
482
|
+
/**
|
|
483
|
+
* Search inbox of a namespace.
|
|
484
|
+
*
|
|
485
|
+
* By default, this calls the api using the `wait` flag. This means the call won't timeout until at least one email is received or 5 minutes pass.
|
|
486
|
+
* It also uses a default `from_timestamp` of **current timestamp - 15 minutes**. This means that older emails will be ignored.
|
|
487
|
+
*
|
|
488
|
+
* Both of these settings can be overriden by passing them in the `params` object.
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* Get the latest emails
|
|
492
|
+
* ```typescript
|
|
493
|
+
* const { data: emails } = await client.searchInbox(namespace);
|
|
494
|
+
* ```
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* Get the latest emails for a specific email address
|
|
498
|
+
* ```typescript
|
|
499
|
+
* const { data: emails } = await client.searchInbox(namespace, {
|
|
500
|
+
* to_addr_prefix: 'john@mynamespace.mailisk.net'
|
|
501
|
+
* });
|
|
502
|
+
* ```
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* Get the last 20 emails in the namespace
|
|
506
|
+
* ```typescript
|
|
507
|
+
* const { data: emails } = await mailisk.searchInbox(namespace, {
|
|
508
|
+
* wait: false,
|
|
509
|
+
* from_timestamp: 0,
|
|
510
|
+
* limit: 20
|
|
511
|
+
* });
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
searchInbox(namespace: string, params?: SearchInboxParams, config?: AxiosRequestConfig): Promise<SearchInboxResponse>;
|
|
515
|
+
/**
|
|
516
|
+
* Get the SMTP settings for a namespace.
|
|
517
|
+
*/
|
|
518
|
+
getSmtpSettings(namespace: string): Promise<SmtpSettings>;
|
|
519
|
+
getAttachment(attachmentId: string): Promise<GetAttachmentResponse>;
|
|
520
|
+
/**
|
|
521
|
+
* Download an attachment from an attachment ID.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* Download an attachment from an email
|
|
525
|
+
* ```typescript
|
|
526
|
+
* const attachment = email.attachments[0];
|
|
527
|
+
* const attachmentBuffer = await client.downloadAttachment(attachment.id);
|
|
528
|
+
*
|
|
529
|
+
* // save to file
|
|
530
|
+
* fs.writeFileSync(attachment.filename, attachmentBuffer);
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
533
|
+
downloadAttachment(attachmentId: string): Promise<Buffer>;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export { type CreateBase32SecretKeyTotpDeviceParams, type CreateCustomTotpDeviceParams, type CreateOtpAuthUrlTotpDeviceParams, type CreateTotpDeviceParams, type Email, type EmailAddress, type EmailAttachment, type GetAttachmentResponse, type KnownTotpDeviceSource, type ListNamespacesResponse, type ListSmsNumbersResponse, type ListTotpDevicesParams, type ListTotpDevicesResponse, MailiskClient, type SearchInboxParams, type SearchInboxResponse, type SearchSmsMessagesParams, type SearchSmsMessagesResponse, type SendVirtualEmailParams, type SendVirtualSmsParams, type SmsMessage, type SmsNumber, type SmtpSettings, type TotpAlgorithm, type TotpDevice, type TotpDeviceSource, type TotpOtpResponse };
|