@irisend/sdk 0.1.0 → 0.2.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 CHANGED
@@ -75,6 +75,39 @@ await irisend.batch.send([...]);
75
75
  Batch items can't schedule or attach files (`scheduledAt` / `attachments`), matching
76
76
  `POST /emails/batch`.
77
77
 
78
+ ### React Email
79
+
80
+ Pass a React element as `react` instead of `html` — on `emails.send`, `emails.sendBatch`,
81
+ `broadcasts.create`, and `broadcasts.update`. It's rendered to HTML with
82
+ [`@react-email/render`](https://www.npmjs.com/package/@react-email/render) right before the
83
+ request is sent; `react` takes precedence over a caller-supplied `html` if both are given, and is
84
+ never sent on the wire itself:
85
+
86
+ ```tsx
87
+ import { Html, Text } from "@react-email/components";
88
+
89
+ await irisend.emails.send({
90
+ from: "Acme <onboarding@acme.com>",
91
+ to: "customer@example.com",
92
+ subject: "Welcome!",
93
+ react: (
94
+ <Html>
95
+ <Text>Thanks for signing up.</Text>
96
+ </Html>
97
+ ),
98
+ });
99
+ ```
100
+
101
+ `@react-email/render` (plus `react`/`react-dom`) is an **optional peer dependency** — install it
102
+ yourself if you use `react`:
103
+
104
+ ```sh
105
+ npm install @react-email/render react react-dom
106
+ ```
107
+
108
+ Calling `send`/`sendBatch`/`broadcasts.create`/`broadcasts.update` with `react` set but
109
+ `@react-email/render` not installed throws a clear error instead of sending a broken request.
110
+
78
111
  ### Emails
79
112
 
80
113
  ```ts
@@ -84,6 +117,25 @@ await irisend.emails.update(id, { scheduledAt: "2026-08-05T11:52:01.858Z" });
84
117
  await irisend.emails.cancel(id);
85
118
  ```
86
119
 
120
+ ### Receiving (inbound emails)
121
+
122
+ Enable receiving on a domain, then read what came in:
123
+
124
+ ```ts
125
+ await irisend.domains.update(domain.id, { capabilities: { receiving: "enabled" } });
126
+
127
+ const { data } = await irisend.emails.receiving.list({ limit: 20 });
128
+ const email = await irisend.emails.receiving.get(data.data[0].id); // html_format: "data_uri" | "cid"
129
+
130
+ await irisend.emails.receiving.attachments.list({ emailId: email.data.id });
131
+ await irisend.emails.receiving.attachments.get({ emailId: email.data.id, id: "att_123" });
132
+ ```
133
+
134
+ `emails.receiving.get`'s `raw.downloadUrl` and `attachments.list`/`attachments.get`'s
135
+ `downloadUrl` are signed, expiring URLs — fetch them directly, don't proxy through the API again.
136
+ Subscribe a webhook to `"email.received"` to get notified as inbound mail arrives instead of
137
+ polling `emails.receiving.list`.
138
+
87
139
  ### Domains
88
140
 
89
141
  ```ts
@@ -94,6 +146,10 @@ await irisend.domains.update(domain.id, { openTracking: true, clickTracking: tru
94
146
  await irisend.domains.verify(domain.id);
95
147
  await irisend.domains.remove(domain.id);
96
148
 
149
+ // Inbound receiving — off by default; the response's `capabilities.receiving` reflects it:
150
+ await irisend.domains.create({ name: "acme.com", capabilities: { receiving: "enabled" } });
151
+ await irisend.domains.update(domain.id, { capabilities: { receiving: "disabled" } });
152
+
97
153
  // Irisend-specific (no Resend equivalent):
98
154
  await irisend.domains.unpause(domain.id); // reputation circuit breaker override
99
155
  await irisend.domains.mintEmbedToken(domain.id); // token for @irisend/connect-react's widget
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import * as React from 'react';
2
+
1
3
  /**
2
4
  * Mirrors the `{ statusCode, name, message }` shape `@irisend/core`'s `ApiError.toJSON()` puts on
3
5
  * the wire. A real `Error` subclass (not a plain object) so callers who prefer `try`/`catch` over
@@ -47,7 +49,7 @@ interface MutationResponse {
47
49
 
48
50
  interface CreateApiKeyOptions {
49
51
  name: string;
50
- permission?: "full_access" | "sending_access";
52
+ permission?: "full_access" | "sending_access" | "contacts_access";
51
53
  domainId?: string;
52
54
  }
53
55
  interface CreateApiKeyResponse {
@@ -101,12 +103,229 @@ declare class AudiencesResource {
101
103
  }>>;
102
104
  }
103
105
 
106
+ type BroadcastStatus = "draft" | "scheduled" | "queued" | "sent" | "canceled";
107
+ /** Resend-compatible `GET /broadcasts/:id` shape. `audienceId`/`segmentId` are the same value —
108
+ * Resend renamed Audiences to Segments; both are kept since the response includes both. */
109
+ interface Broadcast {
110
+ object: "broadcast";
111
+ id: string;
112
+ name: string;
113
+ audienceId: string | null;
114
+ segmentId: string | null;
115
+ from: string;
116
+ subject: string;
117
+ replyTo: string[] | null;
118
+ previewText: string | null;
119
+ html: string | null;
120
+ text: string | null;
121
+ status: BroadcastStatus;
122
+ createdAt: string;
123
+ scheduledAt: string | null;
124
+ sentAt: string | null;
125
+ topicId: string | null;
126
+ }
127
+ /** `GET /broadcasts` item shape — a trimmed subset of `Broadcast`. */
128
+ interface BroadcastListItem {
129
+ id: string;
130
+ name: string;
131
+ audienceId: string | null;
132
+ segmentId: string | null;
133
+ status: BroadcastStatus;
134
+ createdAt: string;
135
+ scheduledAt: string | null;
136
+ sentAt: string | null;
137
+ }
138
+ interface CreateBroadcastOptions {
139
+ /** The segment (audience) to send to. Required unless `audienceId` is provided instead. */
140
+ segmentId?: string;
141
+ /** Legacy alias for `segmentId`. */
142
+ audienceId?: string;
143
+ from: string;
144
+ subject: string;
145
+ replyTo?: string | string[];
146
+ html?: string;
147
+ text?: string;
148
+ /** A React component to render as the `html` body. Takes precedence over `html` when both are
149
+ * given. Requires the optional peer dependency `@react-email/render` at call time. */
150
+ react?: React.ReactNode;
151
+ name?: string;
152
+ topicId?: string;
153
+ previewText?: string;
154
+ /** Send (or schedule, with `scheduledAt`) immediately after creation. Defaults to `false`. */
155
+ send?: boolean;
156
+ /** Requires `send: true`. ISO 8601, e.g. `2026-08-05T11:52:01.858Z`. */
157
+ scheduledAt?: string;
158
+ }
159
+ /** Every field optional — an omitted field keeps the broadcast's current value. Only allowed
160
+ * while the broadcast is `draft`. */
161
+ interface UpdateBroadcastOptions {
162
+ segmentId?: string;
163
+ audienceId?: string;
164
+ from?: string;
165
+ subject?: string;
166
+ replyTo?: string | string[];
167
+ html?: string;
168
+ text?: string;
169
+ /** A React component to render as the `html` body. Takes precedence over `html` when both are
170
+ * given. Requires the optional peer dependency `@react-email/render` at call time. */
171
+ react?: React.ReactNode;
172
+ name?: string;
173
+ topicId?: string;
174
+ previewText?: string;
175
+ }
176
+ interface SendBroadcastOptions {
177
+ /** ISO 8601, e.g. `2026-08-05T11:52:01.858Z`. Omit to send immediately. */
178
+ scheduledAt?: string;
179
+ }
180
+ /** `POST /broadcasts/:id/send` has no `object` field in its response, unlike every other
181
+ * broadcast mutation. */
182
+ interface SendBroadcastResponse {
183
+ id: string;
184
+ }
185
+ interface ListBroadcastsOptions {
186
+ limit?: number;
187
+ after?: string;
188
+ before?: string;
189
+ }
190
+ type BroadcastRecipientEventType = "sent" | "delivered" | "opened" | "clicked" | "bounced" | "complained" | "unsubscribed" | "suppressed";
191
+ type BounceType = "permanent" | "transient" | "undetermined";
192
+ interface ListBroadcastRecipientsOptions {
193
+ type: BroadcastRecipientEventType;
194
+ limit?: number;
195
+ after?: string;
196
+ before?: string;
197
+ email?: string;
198
+ /** Only valid with `type: "bounced"`. */
199
+ bounceType?: BounceType;
200
+ }
201
+ interface BroadcastRecipient {
202
+ /** Opaque cursor for this row; does not identify any entity. Use `contactId` for that. */
203
+ id: string;
204
+ contactId: string | null;
205
+ email: string;
206
+ /** Only present for `type: "opened"` / `type: "clicked"`. */
207
+ count?: number;
208
+ /** Only present for `type: "bounced"`. */
209
+ bounceType?: BounceType | null;
210
+ /** Only present for `type: "clicked"`. */
211
+ clickedLinks?: {
212
+ url: string;
213
+ clicks: number;
214
+ }[];
215
+ }
216
+ interface ListBroadcastClickedLinksOptions {
217
+ limit?: number;
218
+ after?: string;
219
+ before?: string;
220
+ }
221
+ interface BroadcastClickedLink {
222
+ id: string;
223
+ url: string;
224
+ clicks: number;
225
+ uniqueClicks: number;
226
+ }
227
+ declare class BroadcastsResource {
228
+ private readonly http;
229
+ constructor(http: HttpClient);
230
+ /** `POST /broadcasts` */
231
+ create(input: CreateBroadcastOptions): Promise<IrisendResponse<MutationResponse>>;
232
+ /** `GET /broadcasts` — cursor paginated. */
233
+ list(options?: ListBroadcastsOptions): Promise<IrisendResponse<ListResponse<BroadcastListItem>>>;
234
+ /** `GET /broadcasts/:id` */
235
+ get(id: string): Promise<IrisendResponse<Broadcast>>;
236
+ /** `PATCH /broadcasts/:id` — only while `draft`. */
237
+ update(id: string, input: UpdateBroadcastOptions): Promise<IrisendResponse<MutationResponse>>;
238
+ /** `DELETE /broadcasts/:id` — only while `draft` or `scheduled`. */
239
+ remove(id: string): Promise<IrisendResponse<MutationResponse & {
240
+ deleted: boolean;
241
+ }>>;
242
+ /** `POST /broadcasts/:id/send` — only while `draft`. You can send broadcasts created via the
243
+ * API only. */
244
+ send(id: string, input?: SendBroadcastOptions): Promise<IrisendResponse<SendBroadcastResponse>>;
245
+ /** `POST /broadcasts/:id/cancel` — only while `scheduled` or `queued`. */
246
+ cancel(id: string): Promise<IrisendResponse<MutationResponse>>;
247
+ /** `POST /broadcasts/:id/duplicate` — any broadcast can be duplicated, including sent ones. */
248
+ duplicate(id: string): Promise<IrisendResponse<MutationResponse>>;
249
+ /** `GET /broadcasts/:id/recipients` — cursor paginated. */
250
+ recipients(id: string, options: ListBroadcastRecipientsOptions): Promise<IrisendResponse<ListResponse<BroadcastRecipient>>>;
251
+ /** `GET /broadcasts/:id/clicked-links` — cursor paginated, ranked by total clicks descending. */
252
+ clickedLinks(id: string, options?: ListBroadcastClickedLinksOptions): Promise<IrisendResponse<ListResponse<BroadcastClickedLink>>>;
253
+ }
254
+
255
+ type ConsentBasis = "explicit_opt_in" | "soft_opt_in";
256
+ type ConsentStatus = "no_basis" | "explicit_opt_in" | "soft_opt_in" | "soft_opt_in_stale" | "withdrawn";
257
+ interface CreateConsentOptions {
258
+ email: string;
259
+ basis: ConsentBasis;
260
+ source: string;
261
+ /** The exact opt-in copy shown to the contact — required, this is the evidence the endpoint exists to capture. */
262
+ consentText: string;
263
+ /** ISO 8601, must not be in the future. @default now */
264
+ occurredAt?: string;
265
+ ipAddress?: string;
266
+ userAgent?: string;
267
+ metadata?: Record<string, unknown>;
268
+ }
269
+ interface CreateConsentResponse {
270
+ object: "consent";
271
+ id: string;
272
+ email: string;
273
+ status: ConsentStatus;
274
+ }
275
+ interface WithdrawConsentOptions {
276
+ source?: string;
277
+ }
278
+ interface WithdrawConsentResponse {
279
+ object: "consent";
280
+ email: string;
281
+ status: "withdrawn";
282
+ }
283
+ interface ConsentEvent {
284
+ object: "consent_event";
285
+ id: string;
286
+ action: "granted" | "withdrawn";
287
+ basis: ConsentBasis | null;
288
+ source: string;
289
+ consentText: string | null;
290
+ ipAddress: string | null;
291
+ userAgent: string | null;
292
+ metadata: Record<string, unknown>;
293
+ occurredAt: string;
294
+ recordedBy: string;
295
+ createdAt: string;
296
+ }
297
+ interface GetConsentResponse {
298
+ object: "consent";
299
+ email: string;
300
+ status: ConsentStatus;
301
+ /** Present only when `status` is `soft_opt_in`. */
302
+ validUntil?: string;
303
+ events: ConsentEvent[];
304
+ }
305
+ /** Telecommunicatiewet-style consent evidence register, keyed by email (not nested under an
306
+ * audience — one address's consent basis applies across every list it ends up on). */
307
+ declare class ConsentsResource {
308
+ private readonly http;
309
+ constructor(http: HttpClient);
310
+ /** `POST /consents` — records one consent grant with its evidence. */
311
+ create(input: CreateConsentOptions): Promise<IrisendResponse<CreateConsentResponse>>;
312
+ /** `POST /consents/:email/withdraw` */
313
+ withdraw(email: string, input?: WithdrawConsentOptions): Promise<IrisendResponse<WithdrawConsentResponse>>;
314
+ /** `GET /consents/:email` — 404s when no consent evidence has ever been recorded for the address. */
315
+ get(email: string): Promise<IrisendResponse<GetConsentResponse>>;
316
+ }
317
+
104
318
  interface CreateContactOptions {
105
319
  email: string;
106
320
  firstName?: string;
107
321
  lastName?: string;
108
322
  unsubscribed?: boolean;
109
323
  }
324
+ interface UpdateContactOptions {
325
+ firstName?: string | null;
326
+ lastName?: string | null;
327
+ unsubscribed?: boolean | null;
328
+ }
110
329
  interface CreateContactResponse {
111
330
  object: "contact";
112
331
  id: string;
@@ -126,6 +345,10 @@ declare class ContactsResource {
126
345
  constructor(http: HttpClient);
127
346
  /** `POST /audiences/:audienceId/contacts` — upserts by (audience, email). */
128
347
  create(audienceId: string, input: CreateContactOptions): Promise<IrisendResponse<CreateContactResponse>>;
348
+ /** `GET /audiences/:audienceId/contacts/:idOrEmail` */
349
+ get(audienceId: string, idOrEmail: string): Promise<IrisendResponse<Contact>>;
350
+ /** `PATCH /audiences/:audienceId/contacts/:idOrEmail` — an omitted field keeps its current value, matching the API's own contract. */
351
+ update(audienceId: string, idOrEmail: string, input: UpdateContactOptions): Promise<IrisendResponse<Contact>>;
129
352
  /** `GET /audiences/:audienceId/contacts` */
130
353
  list(audienceId: string): Promise<IrisendResponse<ListResponse<Contact>>>;
131
354
  /** `DELETE /audiences/:audienceId/contacts/:idOrEmail` */
@@ -160,11 +383,22 @@ interface Domain {
160
383
  reputationStatus: string;
161
384
  bimiLogoUrl: string | null;
162
385
  bimiVmcUrl: string | null;
386
+ capabilities: DomainCapabilities;
163
387
  }
164
388
  type DomainListItem = Omit<Domain, "records">;
389
+ /** Irisend domains always send, so `sending` is only ever `"enabled"` on the wire — `receiving`
390
+ * reflects whether the inbound MX record is published (`domains.receivingEnabled`). */
391
+ interface DomainCapabilities {
392
+ sending: "enabled";
393
+ receiving: "enabled" | "disabled";
394
+ }
165
395
  interface CreateDomainOptions {
166
396
  name: string;
167
397
  region?: DomainRegion;
398
+ /** Only `receiving` is settable on create — `sending` is always `"enabled"`. */
399
+ capabilities?: {
400
+ receiving?: "enabled" | "disabled";
401
+ };
168
402
  }
169
403
  interface UpdateDomainOptions {
170
404
  openTracking?: boolean;
@@ -172,6 +406,10 @@ interface UpdateDomainOptions {
172
406
  tls?: "opportunistic" | "enforced";
173
407
  bimiLogoUrl?: string | null;
174
408
  bimiVmcUrl?: string | null;
409
+ /** Only `receiving` is settable — toggles the inbound MX record and `receivingEnabled`. */
410
+ capabilities?: {
411
+ receiving?: "enabled" | "disabled";
412
+ };
175
413
  }
176
414
  interface ListDomainsOptions {
177
415
  limit?: number;
@@ -256,6 +494,98 @@ declare class DomainsResource {
256
494
  }): Promise<IrisendResponse<ListResponse<DmarcReport>>>;
257
495
  }
258
496
 
497
+ type InboundAuthResult = "pass" | "fail" | "gray" | "processing_failed" | "unknown";
498
+ interface InboundAuthentication {
499
+ spf: InboundAuthResult;
500
+ dkim: InboundAuthResult;
501
+ dmarc: InboundAuthResult;
502
+ }
503
+ interface ReceivedEmailAttachmentMeta {
504
+ id: string;
505
+ filename: string | null;
506
+ contentType: string;
507
+ contentDisposition: string | null;
508
+ contentId: string | null;
509
+ size: number;
510
+ }
511
+ interface ReceivedEmailListItem {
512
+ id: string;
513
+ to: string[];
514
+ from: string;
515
+ createdAt: string;
516
+ subject: string;
517
+ bcc: string[] | null;
518
+ cc: string[] | null;
519
+ replyTo: string[] | null;
520
+ messageId: string;
521
+ attachments: ReceivedEmailAttachmentMeta[];
522
+ }
523
+ type InboundHtmlFormat = "data_uri" | "cid";
524
+ interface ReceivedEmail extends ReceivedEmailListItem {
525
+ object: "email";
526
+ html: string | null;
527
+ /** Echoes the form actually served — may be `"cid"` even when `data_uri` was requested, for emails too large to inline. */
528
+ htmlFormat: InboundHtmlFormat;
529
+ text: string | null;
530
+ headers: Record<string, string> | null;
531
+ /** Recipient addresses taken from the `for` clause of the message's `Received` headers. */
532
+ receivedFor: string[];
533
+ /** `null` for emails received before this field was introduced. */
534
+ authentication: InboundAuthentication | null;
535
+ raw: {
536
+ downloadUrl: string;
537
+ expiresAt: string;
538
+ };
539
+ }
540
+ interface GetReceivedEmailOptions {
541
+ /** Controls how inline images are returned inside `html`; defaults to `"data_uri"`. */
542
+ htmlFormat?: InboundHtmlFormat;
543
+ }
544
+ interface ListReceivedEmailsOptions {
545
+ limit?: number;
546
+ after?: string;
547
+ before?: string;
548
+ }
549
+ interface ReceivedAttachment {
550
+ object: "attachment";
551
+ id: string;
552
+ filename: string | null;
553
+ size: number;
554
+ contentType: string;
555
+ contentDisposition: string | null;
556
+ contentId: string | null;
557
+ downloadUrl: string;
558
+ expiresAt: string;
559
+ }
560
+ type ReceivedAttachmentListItem = Omit<ReceivedAttachment, "object">;
561
+ interface ListReceivedAttachmentsOptions {
562
+ emailId: string;
563
+ limit?: number;
564
+ after?: string;
565
+ before?: string;
566
+ }
567
+ interface GetReceivedAttachmentOptions {
568
+ emailId: string;
569
+ id: string;
570
+ }
571
+ declare class ReceivingAttachmentsResource {
572
+ private readonly http;
573
+ constructor(http: HttpClient);
574
+ /** `GET /emails/receiving/:emailId/attachments` — cursor paginated. */
575
+ list(options: ListReceivedAttachmentsOptions): Promise<IrisendResponse<ListResponse<ReceivedAttachmentListItem>>>;
576
+ /** `GET /emails/receiving/:emailId/attachments/:id` */
577
+ get(options: GetReceivedAttachmentOptions): Promise<IrisendResponse<ReceivedAttachment>>;
578
+ }
579
+ declare class ReceivingResource {
580
+ private readonly http;
581
+ readonly attachments: ReceivingAttachmentsResource;
582
+ constructor(http: HttpClient);
583
+ /** `GET /emails/receiving` — cursor paginated; emails received by your team. */
584
+ list(options?: ListReceivedEmailsOptions): Promise<IrisendResponse<ListResponse<ReceivedEmailListItem>>>;
585
+ /** `GET /emails/receiving/:id` */
586
+ get(id: string, options?: GetReceivedEmailOptions): Promise<IrisendResponse<ReceivedEmail>>;
587
+ }
588
+
259
589
  interface Attachment {
260
590
  filename: string;
261
591
  /** base64-encoded content; provide exactly one of `content`/`path` */
@@ -277,6 +607,10 @@ interface CreateEmailOptions {
277
607
  replyTo?: string | string[];
278
608
  html?: string;
279
609
  text?: string;
610
+ /** A React component to render as the `html` body. Takes precedence over `html` when both are
611
+ * given, matching Resend's node SDK. Requires the optional peer dependency
612
+ * `@react-email/render` at call time (lazily imported — not needed unless you pass this). */
613
+ react?: React.ReactNode;
280
614
  /** opaque — never case-converted, since these are caller-chosen MIME header names */
281
615
  headers?: Record<string, string>;
282
616
  tags?: Tag[];
@@ -324,6 +658,7 @@ interface UpdateEmailOptions {
324
658
  }
325
659
  declare class EmailsResource {
326
660
  private readonly http;
661
+ readonly receiving: ReceivingResource;
327
662
  constructor(http: HttpClient);
328
663
  /** `POST /emails` */
329
664
  send(input: CreateEmailOptions, options?: Pick<ClientRequestOptions, "idempotencyKey">): Promise<IrisendResponse<CreateEmailResponse>>;
@@ -339,6 +674,94 @@ declare class EmailsResource {
339
674
  cancel(id: string): Promise<IrisendResponse<MutationResponse>>;
340
675
  }
341
676
 
677
+ /** `GET /logs` query parameters. `after`/`before` are mutually exclusive (Resend's pagination
678
+ * contract) — passing both is a 422 from the API, not validated client-side. */
679
+ interface ListLogsOptions {
680
+ limit?: number;
681
+ after?: string;
682
+ before?: string;
683
+ }
684
+ interface LogListItem {
685
+ id: string;
686
+ createdAt: string;
687
+ endpoint: string;
688
+ method: string;
689
+ responseStatus: number;
690
+ userAgent: string | null;
691
+ }
692
+ /** `GET /logs/:id` — adds the full request/response bodies. Shapes vary per logged endpoint, so
693
+ * both are `unknown`. Secrets (API key tokens, webhook signing secrets) are never present: the
694
+ * server redacts them before the row is ever written. */
695
+ interface Log extends LogListItem {
696
+ requestBody: unknown;
697
+ responseBody: unknown;
698
+ }
699
+ declare class LogsResource {
700
+ private readonly http;
701
+ constructor(http: HttpClient);
702
+ /** `GET /logs` — cursor paginated, newest first. */
703
+ list(options?: ListLogsOptions): Promise<IrisendResponse<ListResponse<LogListItem>>>;
704
+ /** `GET /logs/:id` */
705
+ get(id: string): Promise<IrisendResponse<Log>>;
706
+ }
707
+
708
+ /** Resend's `origin` enum has no `unsubscribe` value; Irisend surfaces a preference-center/
709
+ * one-click withdrawal as `manual` on the wire (see `packages/core/src/suppressions.ts`). */
710
+ type SuppressionOrigin = "bounce" | "complaint" | "manual";
711
+ interface AddSuppressionOptions {
712
+ email: string;
713
+ }
714
+ interface Suppression {
715
+ object: "suppression";
716
+ id: string;
717
+ email: string;
718
+ origin: SuppressionOrigin;
719
+ sourceId: string | null;
720
+ createdAt: string;
721
+ }
722
+ interface ListSuppressionsOptions {
723
+ limit?: number;
724
+ after?: string;
725
+ before?: string;
726
+ origin?: SuppressionOrigin;
727
+ }
728
+ interface BatchAddSuppressionsOptions {
729
+ emails: string[];
730
+ }
731
+ interface BatchRemoveSuppressionsOptions {
732
+ emails?: string[];
733
+ ids?: string[];
734
+ }
735
+ declare class SuppressionsBatchResource {
736
+ private readonly http;
737
+ constructor(http: HttpClient);
738
+ /** `POST /suppressions/batch/add` — up to 100 addresses at once. */
739
+ add(input: BatchAddSuppressionsOptions): Promise<IrisendResponse<{
740
+ data: MutationResponse[];
741
+ }>>;
742
+ /** `POST /suppressions/batch/remove` — provide exactly one of `emails`/`ids`, up to 100 entries. */
743
+ remove(input: BatchRemoveSuppressionsOptions): Promise<IrisendResponse<{
744
+ data: Array<MutationResponse & {
745
+ deleted: boolean;
746
+ }>;
747
+ }>>;
748
+ }
749
+ declare class SuppressionsResource {
750
+ private readonly http;
751
+ readonly batch: SuppressionsBatchResource;
752
+ constructor(http: HttpClient);
753
+ /** `POST /suppressions` */
754
+ add(input: AddSuppressionOptions): Promise<IrisendResponse<MutationResponse>>;
755
+ /** `GET /suppressions` */
756
+ list(options?: ListSuppressionsOptions): Promise<IrisendResponse<ListResponse<Suppression>>>;
757
+ /** `GET /suppressions/:suppression` — accepts either a suppression id or an email address. */
758
+ get(idOrEmail: string): Promise<IrisendResponse<Suppression>>;
759
+ /** `DELETE /suppressions/:suppression` — accepts either a suppression id or an email address. */
760
+ remove(idOrEmail: string): Promise<IrisendResponse<MutationResponse & {
761
+ deleted: boolean;
762
+ }>>;
763
+ }
764
+
342
765
  type TemplateVariableType = "string" | "number";
343
766
  interface TemplateVariable {
344
767
  key: string;
@@ -439,7 +862,7 @@ declare class TemplatesResource {
439
862
  rollback(id: string, versionId: string): Promise<IrisendResponse<MutationResponse>>;
440
863
  }
441
864
 
442
- type WebhookEventType = "email.sent" | "email.delivered" | "email.delivery_delayed" | "email.bounced" | "email.complained" | "email.opened" | "email.clicked" | "email.failed" | "email.scheduled" | "email.suppressed" | "email.canceled" | "domain.reputation.warning" | "domain.reputation.paused" | "account.created" | "account.suspended" | "account.resumed" | "domain.dmarc.unknown_source" | "domain.dmarc.ramp_ready";
865
+ type WebhookEventType = "email.sent" | "email.delivered" | "email.delivery_delayed" | "email.bounced" | "email.complained" | "email.opened" | "email.clicked" | "email.failed" | "email.scheduled" | "email.suppressed" | "email.canceled" | "email.received" | "domain.reputation.warning" | "domain.reputation.paused" | "domain.health.degraded" | "domain.health.critical" | "account.created" | "account.suspended" | "account.resumed" | "domain.dmarc.unknown_source" | "domain.dmarc.ramp_ready" | "contact.created" | "contact.updated" | "contact.deleted";
443
866
  interface CreateWebhookOptions {
444
867
  endpoint: string;
445
868
  events: WebhookEventType[];
@@ -472,6 +895,15 @@ declare class WebhooksResource {
472
895
  remove(id: string): Promise<IrisendResponse<MutationResponse & {
473
896
  deleted: boolean;
474
897
  }>>;
898
+ /**
899
+ * Verifies a Standard Webhooks-signed delivery to this plugin's receiver (byte-compatible with
900
+ * Svix — ports `packages/core/src/webhooks.ts`'s `verifyWebhook` so a consumer never needs
901
+ * `@irisend/core`, just this SDK, to validate an inbound webhook). Accepts either `webhook-*`
902
+ * or `svix-*` header names; pass a plain lower-cased header map (e.g.
903
+ * `Object.fromEntries(req.headers)`). `toleranceSec` bounds how stale `webhook-timestamp` may
904
+ * be (default 300s, matching Standard Webhooks' recommendation).
905
+ */
906
+ verify(secret: string, headers: Record<string, string | undefined>, body: string, toleranceSec?: number): boolean;
475
907
  }
476
908
 
477
909
  interface IrisendOptions {
@@ -485,7 +917,11 @@ declare class Irisend {
485
917
  readonly webhooks: WebhooksResource;
486
918
  readonly audiences: AudiencesResource;
487
919
  readonly contacts: ContactsResource;
920
+ readonly consents: ConsentsResource;
488
921
  readonly templates: TemplatesResource;
922
+ readonly logs: LogsResource;
923
+ readonly broadcasts: BroadcastsResource;
924
+ readonly suppressions: SuppressionsResource;
489
925
  /** Resend-style alias: `batch.send` is the same call as `emails.sendBatch`. */
490
926
  readonly batch: {
491
927
  send: EmailsResource["sendBatch"];
@@ -493,4 +929,4 @@ declare class Irisend {
493
929
  constructor(apiKey: string, options?: IrisendOptions);
494
930
  }
495
931
 
496
- export { type ApiKey, type Attachment, type Audience, type Contact, type CreateApiKeyOptions, type CreateApiKeyResponse, type CreateAudienceOptions, type CreateAudienceResponse, type CreateBatchEmailOptions, type CreateBatchEmailResponse, type CreateContactOptions, type CreateContactResponse, type CreateDomainOptions, type CreateEmailOptions, type CreateEmailResponse, type CreateTemplateOptions, type CreateWebhookOptions, type CreateWebhookResponse, type DmarcReport, type DmarcSource, type DmarcSummary, type Domain, type DomainListItem, type DomainRecord, type DomainRegion, type DuplicateTemplateOptions, type Email, type EmailListItem, type EmbedToken, Irisend, IrisendError, type IrisendOptions, type IrisendResponse, type ListDmarcSourcesOptions, type ListDomainsOptions, type ListEmailsOptions, type ListResponse, type ListTemplateVersionsOptions, type ListTemplatesOptions, type MutationResponse, type Tag, type Template, type TemplateVariable, type TemplateVariableType, type TemplateVersion, type UpdateDomainOptions, type UpdateEmailOptions, type UpdateTemplateOptions, type Webhook, type WebhookEventType };
932
+ export { type AddSuppressionOptions, type ApiKey, type Attachment, type Audience, type BatchAddSuppressionsOptions, type BatchRemoveSuppressionsOptions, type BounceType, type Broadcast, type BroadcastClickedLink, type BroadcastListItem, type BroadcastRecipient, type BroadcastRecipientEventType, type BroadcastStatus, type ConsentBasis, type ConsentEvent, type ConsentStatus, type Contact, type CreateApiKeyOptions, type CreateApiKeyResponse, type CreateAudienceOptions, type CreateAudienceResponse, type CreateBatchEmailOptions, type CreateBatchEmailResponse, type CreateBroadcastOptions, type CreateConsentOptions, type CreateConsentResponse, type CreateContactOptions, type CreateContactResponse, type CreateDomainOptions, type CreateEmailOptions, type CreateEmailResponse, type CreateTemplateOptions, type CreateWebhookOptions, type CreateWebhookResponse, type DmarcReport, type DmarcSource, type DmarcSummary, type Domain, type DomainCapabilities, type DomainListItem, type DomainRecord, type DomainRegion, type DuplicateTemplateOptions, type Email, type EmailListItem, type EmbedToken, type GetConsentResponse, type GetReceivedAttachmentOptions, type GetReceivedEmailOptions, type InboundAuthResult, type InboundAuthentication, type InboundHtmlFormat, Irisend, IrisendError, type IrisendOptions, type IrisendResponse, type ListBroadcastClickedLinksOptions, type ListBroadcastRecipientsOptions, type ListBroadcastsOptions, type ListDmarcSourcesOptions, type ListDomainsOptions, type ListEmailsOptions, type ListLogsOptions, type ListReceivedAttachmentsOptions, type ListReceivedEmailsOptions, type ListResponse, type ListSuppressionsOptions, type ListTemplateVersionsOptions, type ListTemplatesOptions, type Log, type LogListItem, type MutationResponse, type ReceivedAttachment, type ReceivedAttachmentListItem, type ReceivedEmail, type ReceivedEmailAttachmentMeta, type ReceivedEmailListItem, type SendBroadcastOptions, type SendBroadcastResponse, type Suppression, type SuppressionOrigin, type Tag, type Template, type TemplateVariable, type TemplateVariableType, type TemplateVersion, type UpdateBroadcastOptions, type UpdateContactOptions, type UpdateDomainOptions, type UpdateEmailOptions, type UpdateTemplateOptions, type Webhook, type WebhookEventType, type WithdrawConsentOptions, type WithdrawConsentResponse };
package/dist/index.js CHANGED
@@ -133,6 +133,213 @@ var AudiencesResource = class {
133
133
  }
134
134
  };
135
135
 
136
+ // src/react-render.ts
137
+ async function renderReactEmail(node) {
138
+ let render;
139
+ try {
140
+ ({ render } = await import("@react-email/render"));
141
+ } catch {
142
+ throw new Error(
143
+ "Sending a `react` email body requires the optional peer dependency `@react-email/render`. Install it with `npm install @react-email/render react react-dom`."
144
+ );
145
+ }
146
+ return render(node);
147
+ }
148
+
149
+ // src/resources/broadcasts.ts
150
+ function fromWireBroadcast(b) {
151
+ return {
152
+ object: "broadcast",
153
+ id: b.id,
154
+ name: b.name,
155
+ audienceId: b.audience_id,
156
+ segmentId: b.segment_id,
157
+ from: b.from,
158
+ subject: b.subject,
159
+ replyTo: b.reply_to,
160
+ previewText: b.preview_text,
161
+ html: b.html,
162
+ text: b.text,
163
+ status: b.status,
164
+ createdAt: b.created_at,
165
+ scheduledAt: b.scheduled_at,
166
+ sentAt: b.sent_at,
167
+ topicId: b.topic_id
168
+ };
169
+ }
170
+ function fromWireBroadcastListItem(b) {
171
+ return {
172
+ id: b.id,
173
+ name: b.name,
174
+ audienceId: b.audience_id,
175
+ segmentId: b.segment_id,
176
+ status: b.status,
177
+ createdAt: b.created_at,
178
+ scheduledAt: b.scheduled_at,
179
+ sentAt: b.sent_at
180
+ };
181
+ }
182
+ function fromWireRecipient(r) {
183
+ return {
184
+ id: r.id,
185
+ contactId: r.contact_id,
186
+ email: r.email,
187
+ ...r.count !== void 0 ? { count: r.count } : {},
188
+ ...r.bounce_type !== void 0 ? { bounceType: r.bounce_type } : {},
189
+ ...r.clicked_links !== void 0 ? { clickedLinks: r.clicked_links } : {}
190
+ };
191
+ }
192
+ function fromWireClickedLink(l) {
193
+ return { id: l.id, url: l.url, clicks: l.clicks, uniqueClicks: l.unique_clicks };
194
+ }
195
+ var BroadcastsResource = class {
196
+ constructor(http) {
197
+ this.http = http;
198
+ }
199
+ http;
200
+ /** `POST /broadcasts` */
201
+ async create(input) {
202
+ const html = input.react ? await renderReactEmail(input.react) : input.html;
203
+ return this.http.request("POST", "/broadcasts", {
204
+ body: {
205
+ segment_id: input.segmentId,
206
+ audience_id: input.audienceId,
207
+ from: input.from,
208
+ subject: input.subject,
209
+ reply_to: input.replyTo,
210
+ html,
211
+ text: input.text,
212
+ name: input.name,
213
+ topic_id: input.topicId,
214
+ preview_text: input.previewText,
215
+ send: input.send,
216
+ scheduled_at: input.scheduledAt
217
+ }
218
+ });
219
+ }
220
+ /** `GET /broadcasts` — cursor paginated. */
221
+ list(options) {
222
+ return mapResponse(
223
+ this.http.request("GET", "/broadcasts", {
224
+ query: { limit: options?.limit, after: options?.after, before: options?.before }
225
+ }),
226
+ (raw) => ({ object: "list", hasMore: raw.has_more, data: raw.data.map(fromWireBroadcastListItem) })
227
+ );
228
+ }
229
+ /** `GET /broadcasts/:id` */
230
+ get(id) {
231
+ return mapResponse(this.http.request("GET", `/broadcasts/${id}`), fromWireBroadcast);
232
+ }
233
+ /** `PATCH /broadcasts/:id` — only while `draft`. */
234
+ async update(id, input) {
235
+ const html = input.react ? await renderReactEmail(input.react) : input.html;
236
+ return this.http.request("PATCH", `/broadcasts/${id}`, {
237
+ body: {
238
+ segment_id: input.segmentId,
239
+ audience_id: input.audienceId,
240
+ from: input.from,
241
+ subject: input.subject,
242
+ reply_to: input.replyTo,
243
+ html,
244
+ text: input.text,
245
+ name: input.name,
246
+ topic_id: input.topicId,
247
+ preview_text: input.previewText
248
+ }
249
+ });
250
+ }
251
+ /** `DELETE /broadcasts/:id` — only while `draft` or `scheduled`. */
252
+ remove(id) {
253
+ return this.http.request("DELETE", `/broadcasts/${id}`);
254
+ }
255
+ /** `POST /broadcasts/:id/send` — only while `draft`. You can send broadcasts created via the
256
+ * API only. */
257
+ send(id, input = {}) {
258
+ return this.http.request("POST", `/broadcasts/${id}/send`, { body: { scheduled_at: input.scheduledAt } });
259
+ }
260
+ /** `POST /broadcasts/:id/cancel` — only while `scheduled` or `queued`. */
261
+ cancel(id) {
262
+ return this.http.request("POST", `/broadcasts/${id}/cancel`);
263
+ }
264
+ /** `POST /broadcasts/:id/duplicate` — any broadcast can be duplicated, including sent ones. */
265
+ duplicate(id) {
266
+ return this.http.request("POST", `/broadcasts/${id}/duplicate`);
267
+ }
268
+ /** `GET /broadcasts/:id/recipients` — cursor paginated. */
269
+ recipients(id, options) {
270
+ return mapResponse(
271
+ this.http.request("GET", `/broadcasts/${id}/recipients`, {
272
+ query: { type: options.type, limit: options.limit, after: options.after, before: options.before, email: options.email, bounce_type: options.bounceType }
273
+ }),
274
+ (raw) => ({ object: "list", hasMore: raw.has_more, data: raw.data.map(fromWireRecipient) })
275
+ );
276
+ }
277
+ /** `GET /broadcasts/:id/clicked-links` — cursor paginated, ranked by total clicks descending. */
278
+ clickedLinks(id, options = {}) {
279
+ return mapResponse(
280
+ this.http.request("GET", `/broadcasts/${id}/clicked-links`, {
281
+ query: { limit: options.limit, after: options.after, before: options.before }
282
+ }),
283
+ (raw) => ({ object: "list", hasMore: raw.has_more, data: raw.data.map(fromWireClickedLink) })
284
+ );
285
+ }
286
+ };
287
+
288
+ // src/resources/consents.ts
289
+ function fromWireConsentEvent(e) {
290
+ return {
291
+ object: "consent_event",
292
+ id: e.id,
293
+ action: e.action,
294
+ basis: e.basis,
295
+ source: e.source,
296
+ consentText: e.consent_text,
297
+ ipAddress: e.ip_address,
298
+ userAgent: e.user_agent,
299
+ metadata: e.metadata,
300
+ occurredAt: e.occurred_at,
301
+ recordedBy: e.recorded_by,
302
+ createdAt: e.created_at
303
+ };
304
+ }
305
+ var ConsentsResource = class {
306
+ constructor(http) {
307
+ this.http = http;
308
+ }
309
+ http;
310
+ /** `POST /consents` — records one consent grant with its evidence. */
311
+ create(input) {
312
+ return this.http.request("POST", "/consents", {
313
+ body: {
314
+ email: input.email,
315
+ basis: input.basis,
316
+ source: input.source,
317
+ consent_text: input.consentText,
318
+ occurred_at: input.occurredAt,
319
+ ip_address: input.ipAddress,
320
+ user_agent: input.userAgent,
321
+ metadata: input.metadata
322
+ }
323
+ });
324
+ }
325
+ /** `POST /consents/:email/withdraw` */
326
+ withdraw(email, input = {}) {
327
+ return this.http.request("POST", `/consents/${encodeURIComponent(email)}/withdraw`, {
328
+ body: { source: input.source }
329
+ });
330
+ }
331
+ /** `GET /consents/:email` — 404s when no consent evidence has ever been recorded for the address. */
332
+ get(email) {
333
+ return mapResponse(
334
+ this.http.request(
335
+ "GET",
336
+ `/consents/${encodeURIComponent(email)}`
337
+ ),
338
+ (raw) => ({ object: "consent", email: raw.email, status: raw.status, validUntil: raw.valid_until, events: raw.events.map(fromWireConsentEvent) })
339
+ );
340
+ }
341
+ };
342
+
136
343
  // src/resources/contacts.ts
137
344
  function fromWireContact(c) {
138
345
  return { object: "contact", id: c.id, email: c.email, firstName: c.first_name, lastName: c.last_name, unsubscribed: c.unsubscribed, createdAt: c.created_at };
@@ -148,6 +355,19 @@ var ContactsResource = class {
148
355
  body: { email: input.email, first_name: input.firstName, last_name: input.lastName, unsubscribed: input.unsubscribed }
149
356
  });
150
357
  }
358
+ /** `GET /audiences/:audienceId/contacts/:idOrEmail` */
359
+ get(audienceId, idOrEmail) {
360
+ return mapResponse(this.http.request("GET", `/audiences/${audienceId}/contacts/${encodeURIComponent(idOrEmail)}`), fromWireContact);
361
+ }
362
+ /** `PATCH /audiences/:audienceId/contacts/:idOrEmail` — an omitted field keeps its current value, matching the API's own contract. */
363
+ update(audienceId, idOrEmail, input) {
364
+ return mapResponse(
365
+ this.http.request("PATCH", `/audiences/${audienceId}/contacts/${encodeURIComponent(idOrEmail)}`, {
366
+ body: { first_name: input.firstName, last_name: input.lastName, unsubscribed: input.unsubscribed }
367
+ }),
368
+ fromWireContact
369
+ );
370
+ }
151
371
  /** `GET /audiences/:audienceId/contacts` */
152
372
  list(audienceId) {
153
373
  return mapResponse(
@@ -179,7 +399,8 @@ function fromWireDomain(d) {
179
399
  tls: d.tls,
180
400
  reputationStatus: d.reputation_status,
181
401
  bimiLogoUrl: d.bimi_logo_url,
182
- bimiVmcUrl: d.bimi_vmc_url
402
+ bimiVmcUrl: d.bimi_vmc_url,
403
+ capabilities: d.capabilities
183
404
  };
184
405
  }
185
406
  var DomainsResource = class {
@@ -189,7 +410,12 @@ var DomainsResource = class {
189
410
  http;
190
411
  /** `POST /domains` */
191
412
  create(input) {
192
- return mapResponse(this.http.request("POST", "/domains", { body: { name: input.name, region: input.region } }), fromWireDomain);
413
+ return mapResponse(
414
+ this.http.request("POST", "/domains", {
415
+ body: { name: input.name, region: input.region, capabilities: input.capabilities ? { receiving: input.capabilities.receiving } : void 0 }
416
+ }),
417
+ fromWireDomain
418
+ );
193
419
  }
194
420
  /** `GET /domains` — list items omit `records`. */
195
421
  list(options) {
@@ -212,7 +438,8 @@ var DomainsResource = class {
212
438
  click_tracking: input.clickTracking,
213
439
  tls: input.tls,
214
440
  bimi_logo_url: input.bimiLogoUrl,
215
- bimi_vmc_url: input.bimiVmcUrl
441
+ bimi_vmc_url: input.bimiVmcUrl,
442
+ capabilities: input.capabilities ? { receiving: input.capabilities.receiving } : void 0
216
443
  }
217
444
  });
218
445
  }
@@ -299,6 +526,106 @@ var DomainsResource = class {
299
526
  }
300
527
  };
301
528
 
529
+ // src/resources/receiving.ts
530
+ function fromWireAttachmentMeta(a) {
531
+ return { id: a.id, filename: a.filename, contentType: a.content_type, contentDisposition: a.content_disposition, contentId: a.content_id, size: a.size };
532
+ }
533
+ function fromWireReceivedEmailListItem(e) {
534
+ return {
535
+ id: e.id,
536
+ to: e.to,
537
+ from: e.from,
538
+ createdAt: e.created_at,
539
+ subject: e.subject,
540
+ bcc: e.bcc,
541
+ cc: e.cc,
542
+ replyTo: e.reply_to,
543
+ messageId: e.message_id,
544
+ attachments: e.attachments.map(fromWireAttachmentMeta)
545
+ };
546
+ }
547
+ function fromWireReceivedEmail(e) {
548
+ return {
549
+ ...fromWireReceivedEmailListItem(e),
550
+ object: "email",
551
+ html: e.html,
552
+ htmlFormat: e.html_format,
553
+ text: e.text,
554
+ headers: e.headers,
555
+ receivedFor: e.received_for,
556
+ authentication: e.authentication,
557
+ raw: { downloadUrl: e.raw.download_url, expiresAt: e.raw.expires_at }
558
+ };
559
+ }
560
+ function fromWireReceivedAttachment(a) {
561
+ return {
562
+ object: "attachment",
563
+ id: a.id,
564
+ filename: a.filename,
565
+ size: a.size,
566
+ contentType: a.content_type,
567
+ contentDisposition: a.content_disposition,
568
+ contentId: a.content_id,
569
+ downloadUrl: a.download_url,
570
+ expiresAt: a.expires_at
571
+ };
572
+ }
573
+ var ReceivingAttachmentsResource = class {
574
+ constructor(http) {
575
+ this.http = http;
576
+ }
577
+ http;
578
+ /** `GET /emails/receiving/:emailId/attachments` — cursor paginated. */
579
+ list(options) {
580
+ return mapResponse(
581
+ this.http.request(
582
+ "GET",
583
+ `/emails/receiving/${options.emailId}/attachments`,
584
+ { query: { limit: options.limit, after: options.after, before: options.before } }
585
+ ),
586
+ (raw) => ({
587
+ object: "list",
588
+ hasMore: raw.has_more,
589
+ data: raw.data.map((a) => {
590
+ const { object: _object, ...item } = fromWireReceivedAttachment({ ...a, object: "attachment" });
591
+ return item;
592
+ })
593
+ })
594
+ );
595
+ }
596
+ /** `GET /emails/receiving/:emailId/attachments/:id` */
597
+ get(options) {
598
+ return mapResponse(
599
+ this.http.request("GET", `/emails/receiving/${options.emailId}/attachments/${options.id}`),
600
+ fromWireReceivedAttachment
601
+ );
602
+ }
603
+ };
604
+ var ReceivingResource = class {
605
+ constructor(http) {
606
+ this.http = http;
607
+ this.attachments = new ReceivingAttachmentsResource(http);
608
+ }
609
+ http;
610
+ attachments;
611
+ /** `GET /emails/receiving` — cursor paginated; emails received by your team. */
612
+ list(options) {
613
+ return mapResponse(
614
+ this.http.request("GET", "/emails/receiving", {
615
+ query: { limit: options?.limit, after: options?.after, before: options?.before }
616
+ }),
617
+ (raw) => ({ object: "list", hasMore: raw.has_more, data: raw.data.map(fromWireReceivedEmailListItem) })
618
+ );
619
+ }
620
+ /** `GET /emails/receiving/:id` */
621
+ get(id, options) {
622
+ return mapResponse(
623
+ this.http.request("GET", `/emails/receiving/${id}`, { query: { html_format: options?.htmlFormat } }),
624
+ fromWireReceivedEmail
625
+ );
626
+ }
627
+ };
628
+
302
629
  // src/resources/emails.ts
303
630
  function toWireAttachment(a) {
304
631
  return { filename: a.filename, content: a.content, path: a.path, content_type: a.contentType, content_id: a.contentId };
@@ -343,15 +670,19 @@ function fromWireEmail(e) {
343
670
  var EmailsResource = class {
344
671
  constructor(http) {
345
672
  this.http = http;
673
+ this.receiving = new ReceivingResource(http);
346
674
  }
347
675
  http;
676
+ receiving;
348
677
  /** `POST /emails` */
349
- send(input, options) {
350
- return this.http.request("POST", "/emails", { body: toWireEmail(input), idempotencyKey: options?.idempotencyKey });
678
+ async send(input, options) {
679
+ const body = input.react ? { ...input, html: await renderReactEmail(input.react) } : input;
680
+ return this.http.request("POST", "/emails", { body: toWireEmail(body), idempotencyKey: options?.idempotencyKey });
351
681
  }
352
682
  /** `POST /emails/batch` — up to 100 emails, same order in the response. Also exposed as `batch.send` for drop-in Resend compatibility. */
353
- sendBatch(inputs, options) {
354
- return this.http.request("POST", "/emails/batch", { body: inputs.map(toWireEmail), idempotencyKey: options?.idempotencyKey });
683
+ async sendBatch(inputs, options) {
684
+ const bodies = await Promise.all(inputs.map(async (input) => input.react ? { ...input, html: await renderReactEmail(input.react) } : input));
685
+ return this.http.request("POST", "/emails/batch", { body: bodies.map(toWireEmail), idempotencyKey: options?.idempotencyKey });
355
686
  }
356
687
  /** `GET /emails/:id` */
357
688
  get(id) {
@@ -376,6 +707,83 @@ var EmailsResource = class {
376
707
  }
377
708
  };
378
709
 
710
+ // src/resources/logs.ts
711
+ function fromWireLogListItem(l) {
712
+ return { id: l.id, createdAt: l.created_at, endpoint: l.endpoint, method: l.method, responseStatus: l.response_status, userAgent: l.user_agent };
713
+ }
714
+ function fromWireLog(l) {
715
+ return { ...fromWireLogListItem(l), requestBody: l.request_body, responseBody: l.response_body };
716
+ }
717
+ var LogsResource = class {
718
+ constructor(http) {
719
+ this.http = http;
720
+ }
721
+ http;
722
+ /** `GET /logs` — cursor paginated, newest first. */
723
+ list(options) {
724
+ return mapResponse(
725
+ this.http.request("GET", "/logs", {
726
+ query: { limit: options?.limit, after: options?.after, before: options?.before }
727
+ }),
728
+ (raw) => ({ object: "list", hasMore: raw.has_more, data: raw.data.map(fromWireLogListItem) })
729
+ );
730
+ }
731
+ /** `GET /logs/:id` */
732
+ get(id) {
733
+ return mapResponse(this.http.request("GET", `/logs/${id}`), fromWireLog);
734
+ }
735
+ };
736
+
737
+ // src/resources/suppressions.ts
738
+ function fromWireSuppression(s) {
739
+ return { object: "suppression", id: s.id, email: s.email, origin: s.origin, sourceId: s.source_id, createdAt: s.created_at };
740
+ }
741
+ var SuppressionsBatchResource = class {
742
+ constructor(http) {
743
+ this.http = http;
744
+ }
745
+ http;
746
+ /** `POST /suppressions/batch/add` — up to 100 addresses at once. */
747
+ add(input) {
748
+ return this.http.request("POST", "/suppressions/batch/add", { body: { emails: input.emails } });
749
+ }
750
+ /** `POST /suppressions/batch/remove` — provide exactly one of `emails`/`ids`, up to 100 entries. */
751
+ remove(input) {
752
+ return this.http.request("POST", "/suppressions/batch/remove", {
753
+ body: { emails: input.emails, ids: input.ids }
754
+ });
755
+ }
756
+ };
757
+ var SuppressionsResource = class {
758
+ constructor(http) {
759
+ this.http = http;
760
+ this.batch = new SuppressionsBatchResource(http);
761
+ }
762
+ http;
763
+ batch;
764
+ /** `POST /suppressions` */
765
+ add(input) {
766
+ return this.http.request("POST", "/suppressions", { body: { email: input.email } });
767
+ }
768
+ /** `GET /suppressions` */
769
+ list(options) {
770
+ return mapResponse(
771
+ this.http.request("GET", "/suppressions", {
772
+ query: { limit: options?.limit, after: options?.after, before: options?.before, origin: options?.origin }
773
+ }),
774
+ (raw) => ({ object: "list", hasMore: raw.has_more, data: raw.data.map(fromWireSuppression) })
775
+ );
776
+ }
777
+ /** `GET /suppressions/:suppression` — accepts either a suppression id or an email address. */
778
+ get(idOrEmail) {
779
+ return mapResponse(this.http.request("GET", `/suppressions/${encodeURIComponent(idOrEmail)}`), fromWireSuppression);
780
+ }
781
+ /** `DELETE /suppressions/:suppression` — accepts either a suppression id or an email address. */
782
+ remove(idOrEmail) {
783
+ return this.http.request("DELETE", `/suppressions/${encodeURIComponent(idOrEmail)}`);
784
+ }
785
+ };
786
+
379
787
  // src/resources/templates.ts
380
788
  function toWireVariable(v) {
381
789
  return { key: v.key, type: v.type, fallback_value: v.fallbackValue };
@@ -500,6 +908,7 @@ var TemplatesResource = class {
500
908
  };
501
909
 
502
910
  // src/resources/webhooks.ts
911
+ import { createHmac, timingSafeEqual } from "crypto";
503
912
  function fromWireWebhook(w) {
504
913
  return { object: "webhook", id: w.id, endpoint: w.endpoint, events: w.events, status: w.status, createdAt: w.created_at, signingSecret: w.signing_secret };
505
914
  }
@@ -532,6 +941,27 @@ var WebhooksResource = class {
532
941
  remove(id) {
533
942
  return this.http.request("DELETE", `/webhooks/${id}`);
534
943
  }
944
+ /**
945
+ * Verifies a Standard Webhooks-signed delivery to this plugin's receiver (byte-compatible with
946
+ * Svix — ports `packages/core/src/webhooks.ts`'s `verifyWebhook` so a consumer never needs
947
+ * `@irisend/core`, just this SDK, to validate an inbound webhook). Accepts either `webhook-*`
948
+ * or `svix-*` header names; pass a plain lower-cased header map (e.g.
949
+ * `Object.fromEntries(req.headers)`). `toleranceSec` bounds how stale `webhook-timestamp` may
950
+ * be (default 300s, matching Standard Webhooks' recommendation).
951
+ */
952
+ verify(secret, headers, body, toleranceSec = 300) {
953
+ const id = headers["webhook-id"] ?? headers["svix-id"];
954
+ const ts = Number(headers["webhook-timestamp"] ?? headers["svix-timestamp"]);
955
+ const sigHeader = headers["webhook-signature"] ?? headers["svix-signature"];
956
+ if (!id || !ts || !sigHeader) return false;
957
+ if (Math.abs(Date.now() / 1e3 - ts) > toleranceSec) return false;
958
+ const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
959
+ const expected = Buffer.from(createHmac("sha256", key).update(`${id}.${ts}.${body}`).digest("base64"));
960
+ return sigHeader.split(" ").some((part) => {
961
+ const candidate = Buffer.from(part.replace(/^v1,/, ""));
962
+ return candidate.length === expected.length && timingSafeEqual(candidate, expected);
963
+ });
964
+ }
535
965
  };
536
966
 
537
967
  // src/irisend.ts
@@ -543,7 +973,11 @@ var Irisend = class {
543
973
  webhooks;
544
974
  audiences;
545
975
  contacts;
976
+ consents;
546
977
  templates;
978
+ logs;
979
+ broadcasts;
980
+ suppressions;
547
981
  /** Resend-style alias: `batch.send` is the same call as `emails.sendBatch`. */
548
982
  batch;
549
983
  constructor(apiKey, options = {}) {
@@ -555,7 +989,11 @@ var Irisend = class {
555
989
  this.webhooks = new WebhooksResource(http);
556
990
  this.audiences = new AudiencesResource(http);
557
991
  this.contacts = new ContactsResource(http);
992
+ this.consents = new ConsentsResource(http);
558
993
  this.templates = new TemplatesResource(http);
994
+ this.logs = new LogsResource(http);
995
+ this.broadcasts = new BroadcastsResource(http);
996
+ this.suppressions = new SuppressionsResource(http);
559
997
  this.batch = { send: this.emails.sendBatch.bind(this.emails) };
560
998
  }
561
999
  };
package/package.json CHANGED
@@ -1,7 +1,21 @@
1
1
  {
2
2
  "name": "@irisend/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Official Node.js SDK for the Irisend API (Resend-compatible).",
5
+ "keywords": [
6
+ "irisend",
7
+ "email",
8
+ "email-api",
9
+ "transactional-email",
10
+ "resend-alternative",
11
+ "sdk",
12
+ "ses"
13
+ ],
14
+ "homepage": "https://irisend.com/docs#sdk-node",
15
+ "bugs": {
16
+ "email": "legal@irisend.com"
17
+ },
18
+ "author": "Irisend <legal@irisend.com> (https://irisend.com)",
5
19
  "type": "module",
6
20
  "license": "MIT",
7
21
  "engines": {
@@ -20,11 +34,24 @@
20
34
  "dist",
21
35
  "README.md"
22
36
  ],
37
+ "peerDependencies": {
38
+ "@react-email/render": "^1.0.0 || ^2.0.0"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "@react-email/render": {
42
+ "optional": true
43
+ }
44
+ },
23
45
  "devDependencies": {
46
+ "@react-email/render": "^2.2.0",
24
47
  "@types/node": "^22.20.4",
48
+ "@types/react": "^19.3.0",
49
+ "react": "19.2.8",
50
+ "react-dom": "19.2.8",
25
51
  "tsup": "^8.5.1",
26
52
  "typescript": "^5.9.3",
27
- "vitest": "^5.0.2"
53
+ "vitest": "^5.0.2",
54
+ "@irisend/core": "0.0.0"
28
55
  },
29
56
  "scripts": {
30
57
  "build": "tsup",