@easybits.cloud/mailmask 0.3.1 → 0.3.3

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
@@ -36,8 +36,20 @@ await mm.send.send(domainId, {
36
36
 
37
37
  // List aliases for a domain
38
38
  const aliases = await mm.aliases.list(domainId);
39
+
40
+ // Add a domain — returns the DNS records to configure (MX, TXT, DKIM, SPF)
41
+ const { domain, dnsRecords } = await mm.domains.create("yourdomain.com");
42
+
43
+ // An alias with an IMAP mailbox (activated domain): password is returned once
44
+ const inbox = await mm.aliases.create(domainId, { alias: "sales", mailbox: true });
45
+ console.log(inbox.buzon?.password, inbox.buzon?.imap);
39
46
  ```
40
47
 
48
+ ## MCP
49
+
50
+ The same actions are available to AI agents at `https://www.mailmask.studio/mcp`
51
+ (Streamable HTTP, `Authorization: Bearer mk_...`). See https://www.mailmask.studio/docs#mcp.
52
+
41
53
  ## More
42
54
 
43
55
  ```ts
@@ -53,7 +65,7 @@ await mm.send.send(domainId, {
53
65
  await mm.suppressions.list(domainId);
54
66
  await mm.suppressions.remove(domainId, "fixed@example.com");
55
67
 
56
- // Webhooks (Developer plan) — secret is shown once
68
+ // Webhooks (activated domain) — secret is shown once
57
69
  const wh = await mm.webhooks.create(domainId, { url: "https://app.example.com/hooks/mailmask", events: ["email.received", "email.delivered", "email.bounced"] });
58
70
 
59
71
  // On your server: verify the signature with the raw body
package/dist/index.cjs CHANGED
@@ -93,7 +93,15 @@ var AliasesResource = class {
93
93
  return this.req(`/api/domains/${domainId}/alias`);
94
94
  }
95
95
  create(domainId, input) {
96
- return this.req(`/api/domains/${domainId}/alias`, { method: "POST", body: JSON.stringify(input) });
96
+ return this.req(`/api/domains/${domainId}/alias`, { method: "POST", body: JSON.stringify({ ...input, destinations: input.destinations ?? [] }) });
97
+ }
98
+ /** Crea un buzón IMAP para una máscara existente. La contraseña sólo se devuelve aquí. */
99
+ createMailbox(domainId, alias) {
100
+ return this.req(`/api/domains/${domainId}/alias/${alias}/mailbox`, { method: "POST" });
101
+ }
102
+ /** Borra el buzón Y SU CORREO. La máscara debe conservar al menos un destino. */
103
+ deleteMailbox(domainId, alias) {
104
+ return this.req(`/api/domains/${domainId}/alias/${alias}/mailbox`, { method: "DELETE" });
97
105
  }
98
106
  update(domainId, alias, input) {
99
107
  return this.req(`/api/domains/${domainId}/alias/${alias}`, { method: "PUT", body: JSON.stringify(input) });
package/dist/index.d.cts CHANGED
@@ -20,6 +20,24 @@ interface Domain {
20
20
  /** Sólo en `domains.list`: tope de reenvíos por hora del plan. */
21
21
  forwardPerHour?: number;
22
22
  }
23
+ interface DnsRecord {
24
+ type: "MX" | "TXT" | "CNAME";
25
+ name: string;
26
+ value: string;
27
+ priority?: number;
28
+ }
29
+ /** Respuesta de `domains.create`: el dominio y los registros DNS que hay que poner. */
30
+ interface DomainCreated {
31
+ domain: Domain;
32
+ /** true si es el 2.º dominio sin activar: se guarda pero no reenvía hasta activarlo ($99/mes). */
33
+ requiereActivacion: boolean;
34
+ dnsRecords: {
35
+ mx: DnsRecord;
36
+ verification: DnsRecord;
37
+ dkim: DnsRecord[];
38
+ spf: DnsRecord;
39
+ };
40
+ }
23
41
  /** Respuesta de `domains.verify`. */
24
42
  interface DomainVerification {
25
43
  domain: string;
@@ -38,11 +56,37 @@ interface Alias {
38
56
  lastFrom?: string | null;
39
57
  lastAt?: string | null;
40
58
  createdAt: string;
59
+ /** true si la máscara guarda el correo en un buzón IMAP. */
60
+ mailboxEnabled?: boolean;
61
+ }
62
+ /** Credenciales de un buzón IMAP recién creado. La contraseña se muestra una sola vez. */
63
+ interface MailboxCreated {
64
+ email: string;
65
+ password: string;
66
+ quotaBytes: number;
67
+ imap: {
68
+ host: string;
69
+ port: number;
70
+ security: string;
71
+ };
72
+ smtp: {
73
+ host: string;
74
+ port: number;
75
+ security: string;
76
+ };
77
+ }
78
+ /** `aliases.create`: el alias, y si pediste buzón, sus credenciales o por qué no se creó. */
79
+ interface AliasCreated extends Alias {
80
+ buzon?: MailboxCreated | null;
81
+ errorBuzon?: string | null;
41
82
  }
42
83
  interface CreateAliasInput {
43
84
  /** Parte local, sin el dominio: "hola" para hola@tudominio.com. `*` para catch-all. */
44
85
  alias: string;
45
- destinations: string[];
86
+ /** Adónde reenviar. Puede ir vacío sólo si `mailbox` es true. */
87
+ destinations?: string[];
88
+ /** Crear también un buzón IMAP (requiere dominio activado). */
89
+ mailbox?: boolean;
46
90
  }
47
91
  interface UpdateAliasInput {
48
92
  enabled?: boolean;
@@ -91,10 +135,13 @@ interface EmailLog {
91
135
  from: string;
92
136
  to: string;
93
137
  subject: string;
94
- status: string;
138
+ /** Entrantes: forwarded, discarded, failed, rule_matched. Salientes: sent → delivered | bounced | complained. */
139
+ status: "forwarded" | "discarded" | "failed" | "rule_matched" | "sent" | "delivered" | "bounced" | "complained";
95
140
  forwardedTo: string;
96
141
  sizeBytes: number;
97
142
  error?: string;
143
+ /** Id interno de SES; cruza el log con los eventos de entrega. Sólo en salientes. */
144
+ sesMessageId?: string;
98
145
  }
99
146
  interface SendEmailInput {
100
147
  to: string;
@@ -278,9 +325,7 @@ declare class DomainsResource {
278
325
  constructor(req: Req);
279
326
  list(): Promise<Domain[]>;
280
327
  get(id: string): Promise<Domain>;
281
- create(domain: string): Promise<{
282
- domain: Domain;
283
- }>;
328
+ create(domain: string): Promise<DomainCreated>;
284
329
  delete(id: string): Promise<{
285
330
  ok: boolean;
286
331
  }>;
@@ -291,7 +336,13 @@ declare class AliasesResource {
291
336
  private req;
292
337
  constructor(req: Req);
293
338
  list(domainId: string): Promise<Alias[]>;
294
- create(domainId: string, input: CreateAliasInput): Promise<Alias>;
339
+ create(domainId: string, input: CreateAliasInput): Promise<AliasCreated>;
340
+ /** Crea un buzón IMAP para una máscara existente. La contraseña sólo se devuelve aquí. */
341
+ createMailbox(domainId: string, alias: string): Promise<MailboxCreated>;
342
+ /** Borra el buzón Y SU CORREO. La máscara debe conservar al menos un destino. */
343
+ deleteMailbox(domainId: string, alias: string): Promise<{
344
+ ok: boolean;
345
+ }>;
295
346
  update(domainId: string, alias: string, input: UpdateAliasInput): Promise<Alias>;
296
347
  delete(domainId: string, alias: string): Promise<{
297
348
  ok: boolean;
@@ -321,6 +372,7 @@ declare class SendResource {
321
372
  send(domainId: string, input: SendEmailInput, opts?: SendOptions): Promise<{
322
373
  ok: boolean;
323
374
  messageId: string;
375
+ sesMessageId: string;
324
376
  }>;
325
377
  bulkSend(domainId: string, input: BulkSendInput): Promise<BulkJobCreated>;
326
378
  bulkStatus(domainId: string, jobId: string): Promise<BulkJob>;
@@ -390,4 +442,4 @@ interface WebhookSignatureHeaders {
390
442
  */
391
443
  declare function verifyWebhookSignature(secret: string, headers: WebhookSignatureHeaders, rawBody: string, toleranceMs?: number): Promise<boolean>;
392
444
 
393
- export { type Alias, type ApiKey, type AttachmentRef, type BulkJob, type BulkJobCreated, type BulkSendInput, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type Domain, type DomainVerification, type EmailLog, MailMask, type MailMaskConfig, MailMaskError, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type UpdateAliasInput, type UpdateRuleInput, type UpdateWebhookInput, type UploadAttachmentInput, type UploadedAttachment, type Webhook, type WebhookCreated, type WebhookDelivery, type WebhookEvent, type WebhookPayload, type WebhookSignatureHeaders, verifyWebhookSignature };
445
+ export { type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BulkJob, type BulkJobCreated, type BulkSendInput, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type DnsRecord, type Domain, type DomainCreated, type DomainVerification, type EmailLog, MailMask, type MailMaskConfig, MailMaskError, type MailboxCreated, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type UpdateAliasInput, type UpdateRuleInput, type UpdateWebhookInput, type UploadAttachmentInput, type UploadedAttachment, type Webhook, type WebhookCreated, type WebhookDelivery, type WebhookEvent, type WebhookPayload, type WebhookSignatureHeaders, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -20,6 +20,24 @@ interface Domain {
20
20
  /** Sólo en `domains.list`: tope de reenvíos por hora del plan. */
21
21
  forwardPerHour?: number;
22
22
  }
23
+ interface DnsRecord {
24
+ type: "MX" | "TXT" | "CNAME";
25
+ name: string;
26
+ value: string;
27
+ priority?: number;
28
+ }
29
+ /** Respuesta de `domains.create`: el dominio y los registros DNS que hay que poner. */
30
+ interface DomainCreated {
31
+ domain: Domain;
32
+ /** true si es el 2.º dominio sin activar: se guarda pero no reenvía hasta activarlo ($99/mes). */
33
+ requiereActivacion: boolean;
34
+ dnsRecords: {
35
+ mx: DnsRecord;
36
+ verification: DnsRecord;
37
+ dkim: DnsRecord[];
38
+ spf: DnsRecord;
39
+ };
40
+ }
23
41
  /** Respuesta de `domains.verify`. */
24
42
  interface DomainVerification {
25
43
  domain: string;
@@ -38,11 +56,37 @@ interface Alias {
38
56
  lastFrom?: string | null;
39
57
  lastAt?: string | null;
40
58
  createdAt: string;
59
+ /** true si la máscara guarda el correo en un buzón IMAP. */
60
+ mailboxEnabled?: boolean;
61
+ }
62
+ /** Credenciales de un buzón IMAP recién creado. La contraseña se muestra una sola vez. */
63
+ interface MailboxCreated {
64
+ email: string;
65
+ password: string;
66
+ quotaBytes: number;
67
+ imap: {
68
+ host: string;
69
+ port: number;
70
+ security: string;
71
+ };
72
+ smtp: {
73
+ host: string;
74
+ port: number;
75
+ security: string;
76
+ };
77
+ }
78
+ /** `aliases.create`: el alias, y si pediste buzón, sus credenciales o por qué no se creó. */
79
+ interface AliasCreated extends Alias {
80
+ buzon?: MailboxCreated | null;
81
+ errorBuzon?: string | null;
41
82
  }
42
83
  interface CreateAliasInput {
43
84
  /** Parte local, sin el dominio: "hola" para hola@tudominio.com. `*` para catch-all. */
44
85
  alias: string;
45
- destinations: string[];
86
+ /** Adónde reenviar. Puede ir vacío sólo si `mailbox` es true. */
87
+ destinations?: string[];
88
+ /** Crear también un buzón IMAP (requiere dominio activado). */
89
+ mailbox?: boolean;
46
90
  }
47
91
  interface UpdateAliasInput {
48
92
  enabled?: boolean;
@@ -91,10 +135,13 @@ interface EmailLog {
91
135
  from: string;
92
136
  to: string;
93
137
  subject: string;
94
- status: string;
138
+ /** Entrantes: forwarded, discarded, failed, rule_matched. Salientes: sent → delivered | bounced | complained. */
139
+ status: "forwarded" | "discarded" | "failed" | "rule_matched" | "sent" | "delivered" | "bounced" | "complained";
95
140
  forwardedTo: string;
96
141
  sizeBytes: number;
97
142
  error?: string;
143
+ /** Id interno de SES; cruza el log con los eventos de entrega. Sólo en salientes. */
144
+ sesMessageId?: string;
98
145
  }
99
146
  interface SendEmailInput {
100
147
  to: string;
@@ -278,9 +325,7 @@ declare class DomainsResource {
278
325
  constructor(req: Req);
279
326
  list(): Promise<Domain[]>;
280
327
  get(id: string): Promise<Domain>;
281
- create(domain: string): Promise<{
282
- domain: Domain;
283
- }>;
328
+ create(domain: string): Promise<DomainCreated>;
284
329
  delete(id: string): Promise<{
285
330
  ok: boolean;
286
331
  }>;
@@ -291,7 +336,13 @@ declare class AliasesResource {
291
336
  private req;
292
337
  constructor(req: Req);
293
338
  list(domainId: string): Promise<Alias[]>;
294
- create(domainId: string, input: CreateAliasInput): Promise<Alias>;
339
+ create(domainId: string, input: CreateAliasInput): Promise<AliasCreated>;
340
+ /** Crea un buzón IMAP para una máscara existente. La contraseña sólo se devuelve aquí. */
341
+ createMailbox(domainId: string, alias: string): Promise<MailboxCreated>;
342
+ /** Borra el buzón Y SU CORREO. La máscara debe conservar al menos un destino. */
343
+ deleteMailbox(domainId: string, alias: string): Promise<{
344
+ ok: boolean;
345
+ }>;
295
346
  update(domainId: string, alias: string, input: UpdateAliasInput): Promise<Alias>;
296
347
  delete(domainId: string, alias: string): Promise<{
297
348
  ok: boolean;
@@ -321,6 +372,7 @@ declare class SendResource {
321
372
  send(domainId: string, input: SendEmailInput, opts?: SendOptions): Promise<{
322
373
  ok: boolean;
323
374
  messageId: string;
375
+ sesMessageId: string;
324
376
  }>;
325
377
  bulkSend(domainId: string, input: BulkSendInput): Promise<BulkJobCreated>;
326
378
  bulkStatus(domainId: string, jobId: string): Promise<BulkJob>;
@@ -390,4 +442,4 @@ interface WebhookSignatureHeaders {
390
442
  */
391
443
  declare function verifyWebhookSignature(secret: string, headers: WebhookSignatureHeaders, rawBody: string, toleranceMs?: number): Promise<boolean>;
392
444
 
393
- export { type Alias, type ApiKey, type AttachmentRef, type BulkJob, type BulkJobCreated, type BulkSendInput, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type Domain, type DomainVerification, type EmailLog, MailMask, type MailMaskConfig, MailMaskError, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type UpdateAliasInput, type UpdateRuleInput, type UpdateWebhookInput, type UploadAttachmentInput, type UploadedAttachment, type Webhook, type WebhookCreated, type WebhookDelivery, type WebhookEvent, type WebhookPayload, type WebhookSignatureHeaders, verifyWebhookSignature };
445
+ export { type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BulkJob, type BulkJobCreated, type BulkSendInput, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type DnsRecord, type Domain, type DomainCreated, type DomainVerification, type EmailLog, MailMask, type MailMaskConfig, MailMaskError, type MailboxCreated, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type UpdateAliasInput, type UpdateRuleInput, type UpdateWebhookInput, type UploadAttachmentInput, type UploadedAttachment, type Webhook, type WebhookCreated, type WebhookDelivery, type WebhookEvent, type WebhookPayload, type WebhookSignatureHeaders, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -65,7 +65,15 @@ var AliasesResource = class {
65
65
  return this.req(`/api/domains/${domainId}/alias`);
66
66
  }
67
67
  create(domainId, input) {
68
- return this.req(`/api/domains/${domainId}/alias`, { method: "POST", body: JSON.stringify(input) });
68
+ return this.req(`/api/domains/${domainId}/alias`, { method: "POST", body: JSON.stringify({ ...input, destinations: input.destinations ?? [] }) });
69
+ }
70
+ /** Crea un buzón IMAP para una máscara existente. La contraseña sólo se devuelve aquí. */
71
+ createMailbox(domainId, alias) {
72
+ return this.req(`/api/domains/${domainId}/alias/${alias}/mailbox`, { method: "POST" });
73
+ }
74
+ /** Borra el buzón Y SU CORREO. La máscara debe conservar al menos un destino. */
75
+ deleteMailbox(domainId, alias) {
76
+ return this.req(`/api/domains/${domainId}/alias/${alias}/mailbox`, { method: "DELETE" });
69
77
  }
70
78
  update(domainId, alias, input) {
71
79
  return this.req(`/api/domains/${domainId}/alias/${alias}`, { method: "PUT", body: JSON.stringify(input) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easybits.cloud/mailmask",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Official SDK for the MailMask email alias/forwarding API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",