resend 0.15.3 → 0.15.4
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/build/package.json +1 -1
- package/build/src/domains/domains.d.ts +2 -1
- package/build/src/domains/domains.js +6 -0
- package/build/src/domains/domains.spec.js +96 -0
- package/build/src/domains/interfaces/domain.d.ts +23 -0
- package/build/src/domains/interfaces/get-domain.interface.d.ts +10 -0
- package/build/src/domains/interfaces/get-domain.interface.js +2 -0
- package/build/src/domains/interfaces/index.d.ts +1 -0
- package/build/src/domains/interfaces/index.js +1 -0
- package/build/src/resend.js +4 -1
- package/package.json +1 -1
package/build/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Resend } from '../resend';
|
|
2
|
-
import { CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, ListDomainsResponse } from './interfaces';
|
|
2
|
+
import { CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, GetDomainResponse, ListDomainsResponse } from './interfaces';
|
|
3
3
|
export declare class Domains {
|
|
4
4
|
private readonly resend;
|
|
5
5
|
constructor(resend: Resend);
|
|
6
6
|
create(payload: CreateDomainOptions, options?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
|
|
7
7
|
list(): Promise<ListDomainsResponse>;
|
|
8
|
+
get(id: string): Promise<GetDomainResponse>;
|
|
8
9
|
remove(id: string): Promise<void>;
|
|
9
10
|
verify(id: string): Promise<void>;
|
|
10
11
|
}
|
|
@@ -26,6 +26,12 @@ class Domains {
|
|
|
26
26
|
return data;
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
+
get(id) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const data = yield this.resend.get(`/domains/${id}`);
|
|
32
|
+
return data;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
29
35
|
remove(id) {
|
|
30
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
37
|
yield this.resend.delete(`/domains/${id}`);
|
|
@@ -317,6 +317,102 @@ describe('Domains', () => {
|
|
|
317
317
|
expect(mock.history.get.length).toBe(1);
|
|
318
318
|
}));
|
|
319
319
|
});
|
|
320
|
+
describe('get', () => {
|
|
321
|
+
describe('when domain not found', () => {
|
|
322
|
+
it('returns error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
323
|
+
mock.onGet('/domains/1234').replyOnce(200, {
|
|
324
|
+
name: 'not_found',
|
|
325
|
+
message: 'Domain not found',
|
|
326
|
+
statusCode: 404,
|
|
327
|
+
});
|
|
328
|
+
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
329
|
+
yield expect(resend.domains.get('1234')).resolves
|
|
330
|
+
.toMatchInlineSnapshot(`
|
|
331
|
+
{
|
|
332
|
+
"message": "Domain not found",
|
|
333
|
+
"name": "not_found",
|
|
334
|
+
"statusCode": 404,
|
|
335
|
+
}
|
|
336
|
+
`);
|
|
337
|
+
}));
|
|
338
|
+
});
|
|
339
|
+
it('get domain', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
340
|
+
const domain = {
|
|
341
|
+
object: 'domain',
|
|
342
|
+
id: 'fd61172c-cafc-40f5-b049-b45947779a29',
|
|
343
|
+
name: 'resend.com',
|
|
344
|
+
status: 'not_started',
|
|
345
|
+
created_at: '2023-06-21T06:10:36.144Z',
|
|
346
|
+
region: 'us-east-1',
|
|
347
|
+
records: [
|
|
348
|
+
{
|
|
349
|
+
record: 'SPF',
|
|
350
|
+
name: 'bounces.resend.com',
|
|
351
|
+
type: 'MX',
|
|
352
|
+
ttl: 'Auto',
|
|
353
|
+
status: 'not_started',
|
|
354
|
+
value: 'feedback-smtp.us-east-1.amazonses.com',
|
|
355
|
+
priority: 10,
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
record: 'SPF',
|
|
359
|
+
name: 'bounces.resend.com',
|
|
360
|
+
value: '"v=spf1 include:amazonses.com ~all"',
|
|
361
|
+
type: 'TXT',
|
|
362
|
+
ttl: 'Auto',
|
|
363
|
+
status: 'not_started',
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
record: 'DKIM',
|
|
367
|
+
name: 'resend._domainkey',
|
|
368
|
+
value: 'p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDZDhdsAKs5xdSj7h3v22wjx3WMWWADCHwxfef8U03JUbVM/sNSVuY5mbrdJKUoG6QBdfxsOGzhINmQnT89idjp5GdAUhx/KNpt8hcLXMID4nB0Gbcafn03/z5zEPxPfzVJqQd/UqOtZQcfxN9OrIhLiBsYTbcTBB7EvjCb3wEaBwIDAQAB',
|
|
369
|
+
type: 'TXT',
|
|
370
|
+
status: 'verified',
|
|
371
|
+
ttl: 'Auto',
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
};
|
|
375
|
+
mock.onGet('/domains/1234').replyOnce(200, domain);
|
|
376
|
+
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
377
|
+
yield expect(resend.domains.get('1234')).resolves.toMatchInlineSnapshot(`
|
|
378
|
+
{
|
|
379
|
+
"created_at": "2023-06-21T06:10:36.144Z",
|
|
380
|
+
"id": "fd61172c-cafc-40f5-b049-b45947779a29",
|
|
381
|
+
"name": "resend.com",
|
|
382
|
+
"object": "domain",
|
|
383
|
+
"records": [
|
|
384
|
+
{
|
|
385
|
+
"name": "bounces.resend.com",
|
|
386
|
+
"priority": 10,
|
|
387
|
+
"record": "SPF",
|
|
388
|
+
"status": "not_started",
|
|
389
|
+
"ttl": "Auto",
|
|
390
|
+
"type": "MX",
|
|
391
|
+
"value": "feedback-smtp.us-east-1.amazonses.com",
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"name": "bounces.resend.com",
|
|
395
|
+
"record": "SPF",
|
|
396
|
+
"status": "not_started",
|
|
397
|
+
"ttl": "Auto",
|
|
398
|
+
"type": "TXT",
|
|
399
|
+
"value": ""v=spf1 include:amazonses.com ~all"",
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"name": "resend._domainkey",
|
|
403
|
+
"record": "DKIM",
|
|
404
|
+
"status": "verified",
|
|
405
|
+
"ttl": "Auto",
|
|
406
|
+
"type": "TXT",
|
|
407
|
+
"value": "p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDZDhdsAKs5xdSj7h3v22wjx3WMWWADCHwxfef8U03JUbVM/sNSVuY5mbrdJKUoG6QBdfxsOGzhINmQnT89idjp5GdAUhx/KNpt8hcLXMID4nB0Gbcafn03/z5zEPxPfzVJqQd/UqOtZQcfxN9OrIhLiBsYTbcTBB7EvjCb3wEaBwIDAQAB",
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
"region": "us-east-1",
|
|
411
|
+
"status": "not_started",
|
|
412
|
+
}
|
|
413
|
+
`);
|
|
414
|
+
}));
|
|
415
|
+
});
|
|
320
416
|
describe('verify', () => {
|
|
321
417
|
it('verifies a domain', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
322
418
|
mock
|
|
@@ -1,3 +1,26 @@
|
|
|
1
1
|
export type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1';
|
|
2
2
|
export type DomainNameservers = 'Amazon Route 53' | 'Cloudflare' | 'Digital Ocean' | 'GoDaddy' | 'Google Domains' | 'Namecheap' | 'Unidentified' | 'Vercel';
|
|
3
3
|
export type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
|
|
4
|
+
export type DomainRecords = DomainSpfRecord | DomainDkimRecord;
|
|
5
|
+
export interface DomainSpfRecord {
|
|
6
|
+
record: 'SPF';
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
type: 'MX' | 'TXT';
|
|
10
|
+
ttl: string;
|
|
11
|
+
status: DomainStatus;
|
|
12
|
+
routing_policy?: string;
|
|
13
|
+
priority?: number;
|
|
14
|
+
proxy_status?: 'enable' | 'disable';
|
|
15
|
+
}
|
|
16
|
+
export interface DomainDkimRecord {
|
|
17
|
+
record: 'DKIM';
|
|
18
|
+
name: string;
|
|
19
|
+
value: string;
|
|
20
|
+
type: 'CNAME' | 'TXT';
|
|
21
|
+
ttl: string;
|
|
22
|
+
status: DomainStatus;
|
|
23
|
+
routing_policy?: string;
|
|
24
|
+
priority?: number;
|
|
25
|
+
proxy_status?: 'enable' | 'disable';
|
|
26
|
+
}
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./create-domain-options.interface"), exports);
|
|
18
18
|
__exportStar(require("./list-domains.interface"), exports);
|
|
19
|
+
__exportStar(require("./get-domain.interface"), exports);
|
package/build/src/resend.js
CHANGED
|
@@ -31,7 +31,10 @@ class Resend {
|
|
|
31
31
|
throw new Error('Missing API key. Pass it to the constructor `new Resend("re_123")`');
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
this.baseUrl =
|
|
34
|
+
this.baseUrl =
|
|
35
|
+
'http://localhost:3001' ||
|
|
36
|
+
process.env.RESEND_BASE_URL ||
|
|
37
|
+
'https://api.resend.com';
|
|
35
38
|
this.headers = {
|
|
36
39
|
Authorization: `Bearer ${this.key}`,
|
|
37
40
|
'User-Agent': `node:${package_json_1.version}`,
|