@easybits.cloud/mailmask 0.4.3 → 0.4.5
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 +10 -9
- package/dist/index.cjs +109 -2
- package/dist/index.d.cts +239 -1
- package/dist/index.d.ts +239 -1
- package/dist/index.js +109 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @easybits.cloud/mailmask
|
|
2
2
|
|
|
3
|
-
Official TypeScript/JavaScript SDK for the [MailMask](https://mailmask.studio) email
|
|
3
|
+
Official TypeScript/JavaScript SDK for the [MailMask](https://mailmask.studio) email address, mailbox and forwarding API.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -19,29 +19,30 @@ const mm = new MailMask({ apiKey: "mk_..." });
|
|
|
19
19
|
const domains = await mm.domains.list();
|
|
20
20
|
const domainId = domains[0].id;
|
|
21
21
|
|
|
22
|
-
// Create an
|
|
23
|
-
const
|
|
22
|
+
// Create an address — emails to hello@yourdomain.com forward to your inbox
|
|
23
|
+
const address = await mm.addresses.create(domainId, {
|
|
24
24
|
alias: "hello",
|
|
25
25
|
destinations: ["you@example.com"],
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
// Send an email (routed through MailMask for high deliverability)
|
|
29
29
|
await mm.send.send(domainId, {
|
|
30
|
-
from: "hello", // must be an active
|
|
30
|
+
from: "hello", // must be an active address; defaults to `noreply`
|
|
31
31
|
fromName: "Acme", // optional display name: Acme <hello@yourdomain.com>
|
|
32
32
|
to: "client@example.com",
|
|
33
33
|
subject: "Welcome!",
|
|
34
34
|
html: "<p>Thanks for signing up.</p>", // or `body` (plain text) / `markdown`
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
// List
|
|
38
|
-
const
|
|
37
|
+
// List addresses for a domain
|
|
38
|
+
const addresses = await mm.addresses.list(domainId);
|
|
39
39
|
|
|
40
40
|
// Add a domain — returns the DNS records to configure (MX, TXT, DKIM, SPF)
|
|
41
41
|
const { domain, dnsRecords } = await mm.domains.create("yourdomain.com");
|
|
42
42
|
|
|
43
|
-
// An
|
|
44
|
-
const inbox = await mm.
|
|
43
|
+
// An address with an IMAP mailbox (activated domain): password is returned once
|
|
44
|
+
const inbox = await mm.addresses.create(domainId, { alias: "sales", mailbox: true });
|
|
45
|
+
// `mm.aliases` still works: it is the same resource under its old name.
|
|
45
46
|
console.log(inbox.buzon?.password, inbox.buzon?.imap);
|
|
46
47
|
```
|
|
47
48
|
|
|
@@ -79,7 +80,7 @@ Full API reference and examples: https://mailmask.studio/docs
|
|
|
79
80
|
|
|
80
81
|
## Links
|
|
81
82
|
|
|
82
|
-
- [MailMask](https://mailmask.studio) — Email
|
|
83
|
+
- [MailMask](https://mailmask.studio) — Email addresses, mailboxes & forwarding on your domain
|
|
83
84
|
- [EasyBits](https://easybits.cloud) — Cloud platform
|
|
84
85
|
- [Fixter](https://fixter.org) — Development team
|
|
85
86
|
|
package/dist/index.cjs
CHANGED
|
@@ -59,7 +59,8 @@ var MailMask = class {
|
|
|
59
59
|
const doFetch = config.fetch ? config.fetch : fetch;
|
|
60
60
|
const req = (path, opts) => request(this.baseUrl, this.apiKey, path, opts, doFetch);
|
|
61
61
|
this.domains = new DomainsResource(req);
|
|
62
|
-
this.
|
|
62
|
+
this.addresses = new AliasesResource(req, (path) => requestRaw(this.baseUrl, this.apiKey, path, doFetch));
|
|
63
|
+
this.aliases = this.addresses;
|
|
63
64
|
this.rules = new RulesResource(req);
|
|
64
65
|
this.logs = new LogsResource(req);
|
|
65
66
|
this.send = new SendResource(req);
|
|
@@ -76,6 +77,8 @@ var MailMask = class {
|
|
|
76
77
|
this.signature = new SignatureResource(req);
|
|
77
78
|
this.canned = new CannedResource(req);
|
|
78
79
|
this.account = new AccountResource(req);
|
|
80
|
+
this.inbox = new InboxResource(req, (path) => requestRaw(this.baseUrl, this.apiKey, path, doFetch));
|
|
81
|
+
this.referrals = new ReferralsResource(req);
|
|
79
82
|
}
|
|
80
83
|
};
|
|
81
84
|
var DomainsResource = class {
|
|
@@ -104,6 +107,19 @@ var DomainsResource = class {
|
|
|
104
107
|
dnsSetup(id, opts) {
|
|
105
108
|
return this.req(`/api/domains/${id}/dns-setup${opts?.live ? "?live=1" : ""}`);
|
|
106
109
|
}
|
|
110
|
+
/** Logo de la firma (PNG, JPG o WebP; máx. 500 KB). Se ve en todo correo en markdown. */
|
|
111
|
+
setLogo(id, file, filename = "logo") {
|
|
112
|
+
const form = new FormData();
|
|
113
|
+
form.append("file", file, filename);
|
|
114
|
+
return this.req(`/api/domains/${id}/logo`, { method: "POST", body: form });
|
|
115
|
+
}
|
|
116
|
+
/** Logo desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
|
|
117
|
+
setLogoFromUrl(id, url) {
|
|
118
|
+
return this.req(`/api/domains/${id}/logo`, { method: "POST", body: JSON.stringify({ fromUrl: url }) });
|
|
119
|
+
}
|
|
120
|
+
removeLogo(id) {
|
|
121
|
+
return this.req(`/api/domains/${id}/logo`, { method: "DELETE" });
|
|
122
|
+
}
|
|
107
123
|
};
|
|
108
124
|
var DnsResource = class {
|
|
109
125
|
constructor(req) {
|
|
@@ -224,6 +240,10 @@ var AttachmentsResource = class {
|
|
|
224
240
|
form.append("file", blob, input.filename);
|
|
225
241
|
return this.req(`/api/domains/${domainId}/attachments`, { method: "POST", body: form });
|
|
226
242
|
}
|
|
243
|
+
/** Desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
|
|
244
|
+
uploadFromUrl(domainId, url, filename) {
|
|
245
|
+
return this.req(`/api/domains/${domainId}/attachments`, { method: "POST", body: JSON.stringify({ fromUrl: url, filename }) });
|
|
246
|
+
}
|
|
227
247
|
};
|
|
228
248
|
var SuppressionsResource = class {
|
|
229
249
|
constructor(req) {
|
|
@@ -306,7 +326,19 @@ var BillingResource = class {
|
|
|
306
326
|
* El usuario la abre y paga; hasta entonces no cambia nada.
|
|
307
327
|
*/
|
|
308
328
|
checkout(domainId, kind = "domain", opts) {
|
|
309
|
-
return this.req("/api/addons/checkout", { method: "POST", body: JSON.stringify({ kind, domainId, payerEmail: opts?.payerEmail }) });
|
|
329
|
+
return this.req("/api/addons/checkout", { method: "POST", body: JSON.stringify({ kind, domainId, payerEmail: opts?.payerEmail, period: opts?.period }) });
|
|
330
|
+
}
|
|
331
|
+
/** Cancela la suscripción de un add-on; el cupo sigue hasta el fin del periodo pagado. */
|
|
332
|
+
cancelAddon(addonId) {
|
|
333
|
+
return this.req(`/api/addons/${addonId}/cancel`, { method: "POST" });
|
|
334
|
+
}
|
|
335
|
+
/** Historial de cobros, cortesías y cancelaciones (más reciente primero). */
|
|
336
|
+
orders(opts) {
|
|
337
|
+
const qs = new URLSearchParams();
|
|
338
|
+
if (opts?.limit) qs.set("limit", String(opts.limit));
|
|
339
|
+
if (opts?.before) qs.set("before", opts.before);
|
|
340
|
+
const q = qs.toString();
|
|
341
|
+
return this.req(`/api/billing/orders${q ? `?${q}` : ""}`);
|
|
310
342
|
}
|
|
311
343
|
};
|
|
312
344
|
var RegistrationsResource = class {
|
|
@@ -334,6 +366,10 @@ var RegistrationsResource = class {
|
|
|
334
366
|
renewal(regId, opts) {
|
|
335
367
|
return this.req(`/api/domains/registrations/${regId}/renewal`, { method: "POST", body: JSON.stringify({ payerEmail: opts?.payerEmail }) });
|
|
336
368
|
}
|
|
369
|
+
/** Deja de cobrar la renovación anual. El dominio sigue vigente hasta su vencimiento. */
|
|
370
|
+
cancelRenewal(regId) {
|
|
371
|
+
return this.req(`/api/domains/registrations/${regId}/renewal/cancel`, { method: "POST" });
|
|
372
|
+
}
|
|
337
373
|
};
|
|
338
374
|
var TransfersResource = class {
|
|
339
375
|
constructor(req) {
|
|
@@ -426,6 +462,77 @@ var AccountResource = class {
|
|
|
426
462
|
return this.req("/api/profile/avatar", { method: "DELETE" });
|
|
427
463
|
}
|
|
428
464
|
};
|
|
465
|
+
var InboxResource = class {
|
|
466
|
+
constructor(req, raw) {
|
|
467
|
+
this.req = req;
|
|
468
|
+
this.raw = raw;
|
|
469
|
+
}
|
|
470
|
+
list(domainId, opts) {
|
|
471
|
+
const qs = new URLSearchParams({ domainId });
|
|
472
|
+
for (const [k, v] of Object.entries(opts ?? {})) if (v !== void 0 && v !== "") qs.set(k, String(v));
|
|
473
|
+
return this.req(`/api/bandeja/conversations?${qs}`);
|
|
474
|
+
}
|
|
475
|
+
/** Conversación con sus mensajes (los 30 más recientes, o anteriores a `before`). Abrirla la marca leída. */
|
|
476
|
+
get(domainId, conversationId, opts) {
|
|
477
|
+
const qs = new URLSearchParams({ domainId });
|
|
478
|
+
if (opts?.before) qs.set("before", opts.before);
|
|
479
|
+
return this.req(`/api/bandeja/conversations/${conversationId}?${qs}`);
|
|
480
|
+
}
|
|
481
|
+
/** Un correo nuevo desde una máscara: abre un hilo. Gasta cuota de envío (dominio activado). */
|
|
482
|
+
compose(domainId, input) {
|
|
483
|
+
return this.req("/api/bandeja/conversations", { method: "POST", body: JSON.stringify({ ...input, domainId }) });
|
|
484
|
+
}
|
|
485
|
+
/** Responde en el hilo desde la máscara del hilo. No gasta cuota de envío. */
|
|
486
|
+
reply(domainId, conversationId, input) {
|
|
487
|
+
return this.req(`/api/bandeja/conversations/${conversationId}/reply`, { method: "POST", body: JSON.stringify({ ...input, domainId }) });
|
|
488
|
+
}
|
|
489
|
+
update(domainId, conversationId, input) {
|
|
490
|
+
return this.req(`/api/bandeja/conversations/${conversationId}`, { method: "PATCH", body: JSON.stringify({ ...input, domainId }) });
|
|
491
|
+
}
|
|
492
|
+
markRead(domainId, conversationId) {
|
|
493
|
+
return this.req(`/api/bandeja/conversations/${conversationId}/read`, { method: "POST", body: JSON.stringify({ domainId }) });
|
|
494
|
+
}
|
|
495
|
+
/** Sin `assignedTo` la deja sin asignar. */
|
|
496
|
+
assign(domainId, conversationId, assignedTo) {
|
|
497
|
+
return this.req(`/api/bandeja/conversations/${conversationId}/assign`, { method: "POST", body: JSON.stringify({ domainId, assignedTo }) });
|
|
498
|
+
}
|
|
499
|
+
/** Nota interna: la ve el equipo, nunca el contacto. */
|
|
500
|
+
addNote(domainId, conversationId, body) {
|
|
501
|
+
return this.req(`/api/bandeja/conversations/${conversationId}/note`, { method: "POST", body: JSON.stringify({ domainId, body }) });
|
|
502
|
+
}
|
|
503
|
+
/** A la papelera (se puede restaurar). Máx. 200 por llamada. */
|
|
504
|
+
delete(domainId, conversationIds) {
|
|
505
|
+
return this.req("/api/bandeja/conversations/bulk-delete", { method: "POST", body: JSON.stringify({ domainId, ids: conversationIds }) });
|
|
506
|
+
}
|
|
507
|
+
restore(domainId, conversationId) {
|
|
508
|
+
return this.req(`/api/bandeja/conversations/${conversationId}/restore`, { method: "POST", body: JSON.stringify({ domainId }) });
|
|
509
|
+
}
|
|
510
|
+
metrics(domainId, opts) {
|
|
511
|
+
const qs = new URLSearchParams({ domainId });
|
|
512
|
+
if (opts?.days) qs.set("days", String(opts.days));
|
|
513
|
+
return this.req(`/api/bandeja/metrics?${qs}`);
|
|
514
|
+
}
|
|
515
|
+
/** Bytes de un adjunto de un mensaje (id del mensaje e índice de `attachments`). */
|
|
516
|
+
attachment(domainId, conversationId, messageId, index) {
|
|
517
|
+
return this.raw(`/api/bandeja/conversations/${conversationId}/attachments/${messageId}/${index}?domainId=${encodeURIComponent(domainId)}`);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
var ReferralsResource = class {
|
|
521
|
+
constructor(req) {
|
|
522
|
+
this.req = req;
|
|
523
|
+
}
|
|
524
|
+
get() {
|
|
525
|
+
return this.req("/api/referrals");
|
|
526
|
+
}
|
|
527
|
+
/** 3-30 caracteres: minúsculas, números y guiones. */
|
|
528
|
+
setSlug(slug) {
|
|
529
|
+
return this.req("/api/referrals/slug", { method: "PUT", body: JSON.stringify({ slug }) });
|
|
530
|
+
}
|
|
531
|
+
/** Nombre que ven los invitados (2-40 caracteres). */
|
|
532
|
+
setName(name) {
|
|
533
|
+
return this.req("/api/referrals/name", { method: "PUT", body: JSON.stringify({ name }) });
|
|
534
|
+
}
|
|
535
|
+
};
|
|
429
536
|
|
|
430
537
|
// src/verify.ts
|
|
431
538
|
function hex(buf) {
|
package/dist/index.d.cts
CHANGED
|
@@ -47,6 +47,14 @@ interface DomainVerification {
|
|
|
47
47
|
stale?: boolean;
|
|
48
48
|
error?: string;
|
|
49
49
|
}
|
|
50
|
+
/** Nombre público de `Alias` desde la 0.4.5. */
|
|
51
|
+
type Address = Alias;
|
|
52
|
+
/** Nombre público de `AliasCreated` desde la 0.4.5. */
|
|
53
|
+
type AddressCreated = AliasCreated;
|
|
54
|
+
/** Nombre público de `CreateAliasInput` desde la 0.4.5. */
|
|
55
|
+
type CreateAddressInput = CreateAliasInput;
|
|
56
|
+
/** Nombre público de `UpdateAliasInput` desde la 0.4.5. */
|
|
57
|
+
type UpdateAddressInput = UpdateAliasInput;
|
|
50
58
|
interface Alias {
|
|
51
59
|
alias: string;
|
|
52
60
|
domainId: string;
|
|
@@ -521,6 +529,139 @@ interface AccountProfile {
|
|
|
521
529
|
/** Ruta relativa al host de MailMask (`/api/avatar/...`), o null sin foto. */
|
|
522
530
|
avatarUrl: string | null;
|
|
523
531
|
}
|
|
532
|
+
type InboxStatus = "open" | "snoozed" | "closed";
|
|
533
|
+
interface InboxConversation {
|
|
534
|
+
id: string;
|
|
535
|
+
domainId: string;
|
|
536
|
+
/** El contacto externo (en un hilo que inició el dominio, el destinatario). */
|
|
537
|
+
from: string;
|
|
538
|
+
/** La máscara del dominio por la que va el hilo (`ventas@tudominio.com`). */
|
|
539
|
+
to: string;
|
|
540
|
+
subject: string;
|
|
541
|
+
status: InboxStatus;
|
|
542
|
+
assignedTo?: string;
|
|
543
|
+
priority: "normal" | "urgent";
|
|
544
|
+
lastMessageAt: string;
|
|
545
|
+
messageCount: number;
|
|
546
|
+
tags: string[];
|
|
547
|
+
deletedAt?: string;
|
|
548
|
+
snoozedUntil?: string;
|
|
549
|
+
/** Para quien pregunta: hay mensajes que no ha visto. */
|
|
550
|
+
unread?: boolean;
|
|
551
|
+
/** Sólo en búsqueda: fragmento con la coincidencia. */
|
|
552
|
+
snippet?: string;
|
|
553
|
+
[k: string]: unknown;
|
|
554
|
+
}
|
|
555
|
+
interface InboxListOptions {
|
|
556
|
+
/** `open`, `snoozed`, `closed`, `unread` (de quien pregunta) o `deleted` (papelera). */
|
|
557
|
+
status?: InboxStatus | "unread" | "deleted";
|
|
558
|
+
/** Dirección completa de la máscara (`ventas@tudominio.com`). */
|
|
559
|
+
to?: string;
|
|
560
|
+
assignedTo?: string;
|
|
561
|
+
/** Búsqueda en asunto, remitente y cuerpo. Con `q` no hay paginación (tope 50). */
|
|
562
|
+
q?: string;
|
|
563
|
+
/** Máx. 100. */
|
|
564
|
+
limit?: number;
|
|
565
|
+
cursor?: string;
|
|
566
|
+
}
|
|
567
|
+
interface InboxPage {
|
|
568
|
+
items: InboxConversation[];
|
|
569
|
+
nextCursor: string | null;
|
|
570
|
+
/** Máscaras con conversaciones (sólo en la primera página). */
|
|
571
|
+
aliases?: string[];
|
|
572
|
+
mode: "list" | "search" | "search-degraded";
|
|
573
|
+
unreadCount?: number;
|
|
574
|
+
[k: string]: unknown;
|
|
575
|
+
}
|
|
576
|
+
interface InboxAttachment {
|
|
577
|
+
index: number;
|
|
578
|
+
filename: string;
|
|
579
|
+
contentType: string;
|
|
580
|
+
size: number;
|
|
581
|
+
}
|
|
582
|
+
interface InboxMessage {
|
|
583
|
+
id: string;
|
|
584
|
+
conversationId: string;
|
|
585
|
+
from: string;
|
|
586
|
+
/** Texto plano. */
|
|
587
|
+
body?: string;
|
|
588
|
+
html?: string;
|
|
589
|
+
direction: "inbound" | "outbound";
|
|
590
|
+
createdAt: string;
|
|
591
|
+
messageId?: string;
|
|
592
|
+
deliveryStatus?: "sent" | "delivered" | "bounced" | "complained";
|
|
593
|
+
attachments?: InboxAttachment[];
|
|
594
|
+
/** El original ya no está (retención de 90 días o pérdida): `body` puede venir del índice. */
|
|
595
|
+
bodyDegraded?: string;
|
|
596
|
+
}
|
|
597
|
+
interface InboxNote {
|
|
598
|
+
id: string;
|
|
599
|
+
conversationId: string;
|
|
600
|
+
author: string;
|
|
601
|
+
body: string;
|
|
602
|
+
createdAt: string;
|
|
603
|
+
}
|
|
604
|
+
interface InboxConversationDetail extends InboxConversation {
|
|
605
|
+
messages: InboxMessage[];
|
|
606
|
+
notes: InboxNote[];
|
|
607
|
+
totalMessages: number;
|
|
608
|
+
hasMore: boolean;
|
|
609
|
+
}
|
|
610
|
+
interface InboxComposeInput {
|
|
611
|
+
/** Parte local (o dirección completa) de una máscara activa del dominio. */
|
|
612
|
+
fromAlias: string;
|
|
613
|
+
to: string;
|
|
614
|
+
subject: string;
|
|
615
|
+
markdown?: string;
|
|
616
|
+
html?: string;
|
|
617
|
+
body?: string;
|
|
618
|
+
cc?: string[];
|
|
619
|
+
bcc?: string[];
|
|
620
|
+
attachments?: AttachmentRef[];
|
|
621
|
+
}
|
|
622
|
+
interface InboxReplyInput {
|
|
623
|
+
markdown?: string;
|
|
624
|
+
html?: string;
|
|
625
|
+
body?: string;
|
|
626
|
+
cc?: string[];
|
|
627
|
+
bcc?: string[];
|
|
628
|
+
/** Cita el último mensaje recibido (por omisión true; sólo con markdown). */
|
|
629
|
+
quote?: boolean;
|
|
630
|
+
attachments?: AttachmentRef[];
|
|
631
|
+
}
|
|
632
|
+
interface InboxUpdateInput {
|
|
633
|
+
status?: InboxStatus;
|
|
634
|
+
/** ISO, futura y a menos de 90 días. Obligatoria con `status: "snoozed"`. */
|
|
635
|
+
snoozedUntil?: string;
|
|
636
|
+
tags?: string[];
|
|
637
|
+
priority?: "normal" | "urgent";
|
|
638
|
+
}
|
|
639
|
+
interface Order {
|
|
640
|
+
id: string;
|
|
641
|
+
number: string;
|
|
642
|
+
date: string;
|
|
643
|
+
kind: string;
|
|
644
|
+
concept: string;
|
|
645
|
+
subject: string | null;
|
|
646
|
+
amountCents: number;
|
|
647
|
+
listPriceCents: number | null;
|
|
648
|
+
currency: string;
|
|
649
|
+
periodStart: string | null;
|
|
650
|
+
periodEnd: string | null;
|
|
651
|
+
failureReason: string | null;
|
|
652
|
+
note: string | null;
|
|
653
|
+
reference: string | null;
|
|
654
|
+
}
|
|
655
|
+
interface OrdersPage {
|
|
656
|
+
orders: Order[];
|
|
657
|
+
nextCursor: string | null;
|
|
658
|
+
invoiceNote: string;
|
|
659
|
+
}
|
|
660
|
+
interface ReferralStats {
|
|
661
|
+
slug?: string | null;
|
|
662
|
+
referrals: unknown[];
|
|
663
|
+
[k: string]: unknown;
|
|
664
|
+
}
|
|
524
665
|
|
|
525
666
|
declare class MailMaskError extends Error {
|
|
526
667
|
status: number;
|
|
@@ -530,6 +671,9 @@ declare class MailMask {
|
|
|
530
671
|
private baseUrl;
|
|
531
672
|
private apiKey;
|
|
532
673
|
domains: DomainsResource;
|
|
674
|
+
/** Las direcciones del dominio (máscaras), con reenvío, buzón o ambos. */
|
|
675
|
+
addresses: AliasesResource;
|
|
676
|
+
/** @deprecated Usa `addresses`; es el mismo recurso y no se va a retirar. */
|
|
533
677
|
aliases: AliasesResource;
|
|
534
678
|
rules: RulesResource;
|
|
535
679
|
logs: LogsResource;
|
|
@@ -547,6 +691,8 @@ declare class MailMask {
|
|
|
547
691
|
signature: SignatureResource;
|
|
548
692
|
canned: CannedResource;
|
|
549
693
|
account: AccountResource;
|
|
694
|
+
inbox: InboxResource;
|
|
695
|
+
referrals: ReferralsResource;
|
|
550
696
|
constructor(config: MailMaskConfig);
|
|
551
697
|
}
|
|
552
698
|
type Req = <T>(path: string, opts?: RequestInit) => Promise<T>;
|
|
@@ -565,6 +711,19 @@ declare class DomainsResource {
|
|
|
565
711
|
dnsSetup(id: string, opts?: {
|
|
566
712
|
live?: boolean;
|
|
567
713
|
}): Promise<DnsSetup>;
|
|
714
|
+
/** Logo de la firma (PNG, JPG o WebP; máx. 500 KB). Se ve en todo correo en markdown. */
|
|
715
|
+
setLogo(id: string, file: Blob, filename?: string): Promise<{
|
|
716
|
+
ok: boolean;
|
|
717
|
+
logoUrl: string;
|
|
718
|
+
}>;
|
|
719
|
+
/** Logo desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
|
|
720
|
+
setLogoFromUrl(id: string, url: string): Promise<{
|
|
721
|
+
ok: boolean;
|
|
722
|
+
logoUrl: string;
|
|
723
|
+
}>;
|
|
724
|
+
removeLogo(id: string): Promise<{
|
|
725
|
+
ok: boolean;
|
|
726
|
+
}>;
|
|
568
727
|
}
|
|
569
728
|
declare class DnsResource {
|
|
570
729
|
private req;
|
|
@@ -645,6 +804,8 @@ declare class AttachmentsResource {
|
|
|
645
804
|
constructor(req: Req);
|
|
646
805
|
/** Máx. 5 MB. Ejecutables bloqueados (415). La llave vale hasta que se envía. */
|
|
647
806
|
upload(domainId: string, input: UploadAttachmentInput): Promise<UploadedAttachment>;
|
|
807
|
+
/** Desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
|
|
808
|
+
uploadFromUrl(domainId: string, url: string, filename?: string): Promise<UploadedAttachment>;
|
|
648
809
|
}
|
|
649
810
|
declare class SuppressionsResource {
|
|
650
811
|
private req;
|
|
@@ -702,7 +863,18 @@ declare class BillingResource {
|
|
|
702
863
|
*/
|
|
703
864
|
checkout(domainId: string, kind?: "domain" | "storage50" | "sends100", opts?: {
|
|
704
865
|
payerEmail?: string;
|
|
866
|
+
period?: "monthly" | "annual";
|
|
705
867
|
}): Promise<CheckoutLink>;
|
|
868
|
+
/** Cancela la suscripción de un add-on; el cupo sigue hasta el fin del periodo pagado. */
|
|
869
|
+
cancelAddon(addonId: string): Promise<{
|
|
870
|
+
ok: boolean;
|
|
871
|
+
activeUntil: string | null;
|
|
872
|
+
}>;
|
|
873
|
+
/** Historial de cobros, cortesías y cancelaciones (más reciente primero). */
|
|
874
|
+
orders(opts?: {
|
|
875
|
+
limit?: number;
|
|
876
|
+
before?: string;
|
|
877
|
+
}): Promise<OrdersPage>;
|
|
706
878
|
}
|
|
707
879
|
declare class RegistrationsResource {
|
|
708
880
|
private req;
|
|
@@ -721,6 +893,11 @@ declare class RegistrationsResource {
|
|
|
721
893
|
renewal(regId: string, opts?: {
|
|
722
894
|
payerEmail?: string;
|
|
723
895
|
}): Promise<RenewalLink>;
|
|
896
|
+
/** Deja de cobrar la renovación anual. El dominio sigue vigente hasta su vencimiento. */
|
|
897
|
+
cancelRenewal(regId: string): Promise<{
|
|
898
|
+
ok: boolean;
|
|
899
|
+
aviso: string;
|
|
900
|
+
}>;
|
|
724
901
|
}
|
|
725
902
|
declare class TransfersResource {
|
|
726
903
|
private req;
|
|
@@ -810,6 +987,67 @@ declare class AccountResource {
|
|
|
810
987
|
ok: boolean;
|
|
811
988
|
}>;
|
|
812
989
|
}
|
|
990
|
+
/**
|
|
991
|
+
* La Bandeja: conversaciones del dominio. Todo pasa por los mismos permisos que la app
|
|
992
|
+
* (dueño, admin o agente invitado) y los mismos topes de envío.
|
|
993
|
+
*/
|
|
994
|
+
declare class InboxResource {
|
|
995
|
+
private req;
|
|
996
|
+
private raw;
|
|
997
|
+
constructor(req: Req, raw: (path: string) => Promise<Response>);
|
|
998
|
+
list(domainId: string, opts?: InboxListOptions): Promise<InboxPage>;
|
|
999
|
+
/** Conversación con sus mensajes (los 30 más recientes, o anteriores a `before`). Abrirla la marca leída. */
|
|
1000
|
+
get(domainId: string, conversationId: string, opts?: {
|
|
1001
|
+
before?: string;
|
|
1002
|
+
}): Promise<InboxConversationDetail>;
|
|
1003
|
+
/** Un correo nuevo desde una máscara: abre un hilo. Gasta cuota de envío (dominio activado). */
|
|
1004
|
+
compose(domainId: string, input: InboxComposeInput): Promise<{
|
|
1005
|
+
ok: boolean;
|
|
1006
|
+
conversationId: string;
|
|
1007
|
+
messageId: string;
|
|
1008
|
+
}>;
|
|
1009
|
+
/** Responde en el hilo desde la máscara del hilo. No gasta cuota de envío. */
|
|
1010
|
+
reply(domainId: string, conversationId: string, input: InboxReplyInput): Promise<{
|
|
1011
|
+
ok: boolean;
|
|
1012
|
+
messageId: string;
|
|
1013
|
+
}>;
|
|
1014
|
+
update(domainId: string, conversationId: string, input: InboxUpdateInput): Promise<InboxConversation>;
|
|
1015
|
+
markRead(domainId: string, conversationId: string): Promise<{
|
|
1016
|
+
ok: boolean;
|
|
1017
|
+
unreadCount: number;
|
|
1018
|
+
}>;
|
|
1019
|
+
/** Sin `assignedTo` la deja sin asignar. */
|
|
1020
|
+
assign(domainId: string, conversationId: string, assignedTo?: string): Promise<InboxConversation>;
|
|
1021
|
+
/** Nota interna: la ve el equipo, nunca el contacto. */
|
|
1022
|
+
addNote(domainId: string, conversationId: string, body: string): Promise<InboxNote>;
|
|
1023
|
+
/** A la papelera (se puede restaurar). Máx. 200 por llamada. */
|
|
1024
|
+
delete(domainId: string, conversationIds: string[]): Promise<{
|
|
1025
|
+
ok: boolean;
|
|
1026
|
+
deleted: number;
|
|
1027
|
+
}>;
|
|
1028
|
+
restore(domainId: string, conversationId: string): Promise<{
|
|
1029
|
+
ok: boolean;
|
|
1030
|
+
}>;
|
|
1031
|
+
metrics(domainId: string, opts?: {
|
|
1032
|
+
days?: number;
|
|
1033
|
+
}): Promise<Record<string, unknown>>;
|
|
1034
|
+
/** Bytes de un adjunto de un mensaje (id del mensaje e índice de `attachments`). */
|
|
1035
|
+
attachment(domainId: string, conversationId: string, messageId: string, index: number): Promise<Response>;
|
|
1036
|
+
}
|
|
1037
|
+
declare class ReferralsResource {
|
|
1038
|
+
private req;
|
|
1039
|
+
constructor(req: Req);
|
|
1040
|
+
get(): Promise<ReferralStats>;
|
|
1041
|
+
/** 3-30 caracteres: minúsculas, números y guiones. */
|
|
1042
|
+
setSlug(slug: string): Promise<{
|
|
1043
|
+
ok: boolean;
|
|
1044
|
+
slug: string;
|
|
1045
|
+
}>;
|
|
1046
|
+
/** Nombre que ven los invitados (2-40 caracteres). */
|
|
1047
|
+
setName(name: string): Promise<{
|
|
1048
|
+
ok: boolean;
|
|
1049
|
+
}>;
|
|
1050
|
+
}
|
|
813
1051
|
|
|
814
1052
|
interface WebhookSignatureHeaders {
|
|
815
1053
|
/** Header `X-MailMask-Signature`, con forma `sha256=<hex>`. */
|
|
@@ -824,4 +1062,4 @@ interface WebhookSignatureHeaders {
|
|
|
824
1062
|
*/
|
|
825
1063
|
declare function verifyWebhookSignature(secret: string, headers: WebhookSignatureHeaders, rawBody: string, toleranceMs?: number): Promise<boolean>;
|
|
826
1064
|
|
|
827
|
-
export { type AccountProfile, type Addon, type AddonsResponse, type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BillingStatus, type BulkJob, type BulkJobCreated, type BulkSendInput, type CannedReply, type CheckoutLink, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type DnsChangeResult, type DnsDelegation, type DnsImportResult, type DnsListResponse, type DnsPreset, type DnsRRSet, type DnsRRSetAnotado, type DnsRecord, type DnsRecordType, type DnsSetup, type DnsSetupRecord, type DnsZoneCreated, type DnsZoneState, type Domain, type DomainCreated, type DomainInvite, type DomainMember, type DomainRegistration, type DomainRegistrationCreated, type DomainSearchResult, type DomainVerification, type EmailLog, MailMask, type MailMaskConfig, MailMaskError, type MailboxCreated, type RenewalLink, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type TldPrice, type TransferCheck, type TransferDnsInventory, type TransferRequirement, type UpdateAliasInput, type UpdateRuleInput, type UpdateWebhookInput, type UploadAttachmentInput, type UploadedAttachment, type Webhook, type WebhookCreated, type WebhookDelivery, type WebhookEvent, type WebhookPayload, type WebhookSignatureHeaders, verifyWebhookSignature };
|
|
1065
|
+
export { type AccountProfile, type Addon, type AddonsResponse, type Address, type AddressCreated, type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BillingStatus, type BulkJob, type BulkJobCreated, type BulkSendInput, type CannedReply, type CheckoutLink, type CreateAddressInput, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type DnsChangeResult, type DnsDelegation, type DnsImportResult, type DnsListResponse, type DnsPreset, type DnsRRSet, type DnsRRSetAnotado, type DnsRecord, type DnsRecordType, type DnsSetup, type DnsSetupRecord, type DnsZoneCreated, type DnsZoneState, type Domain, type DomainCreated, type DomainInvite, type DomainMember, type DomainRegistration, type DomainRegistrationCreated, type DomainSearchResult, type DomainVerification, type EmailLog, type InboxAttachment, type InboxComposeInput, type InboxConversation, type InboxConversationDetail, type InboxListOptions, type InboxMessage, type InboxNote, type InboxPage, type InboxReplyInput, type InboxStatus, type InboxUpdateInput, MailMask, type MailMaskConfig, MailMaskError, type MailboxCreated, type Order, type OrdersPage, type ReferralStats, type RenewalLink, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type TldPrice, type TransferCheck, type TransferDnsInventory, type TransferRequirement, type UpdateAddressInput, 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
|
@@ -47,6 +47,14 @@ interface DomainVerification {
|
|
|
47
47
|
stale?: boolean;
|
|
48
48
|
error?: string;
|
|
49
49
|
}
|
|
50
|
+
/** Nombre público de `Alias` desde la 0.4.5. */
|
|
51
|
+
type Address = Alias;
|
|
52
|
+
/** Nombre público de `AliasCreated` desde la 0.4.5. */
|
|
53
|
+
type AddressCreated = AliasCreated;
|
|
54
|
+
/** Nombre público de `CreateAliasInput` desde la 0.4.5. */
|
|
55
|
+
type CreateAddressInput = CreateAliasInput;
|
|
56
|
+
/** Nombre público de `UpdateAliasInput` desde la 0.4.5. */
|
|
57
|
+
type UpdateAddressInput = UpdateAliasInput;
|
|
50
58
|
interface Alias {
|
|
51
59
|
alias: string;
|
|
52
60
|
domainId: string;
|
|
@@ -521,6 +529,139 @@ interface AccountProfile {
|
|
|
521
529
|
/** Ruta relativa al host de MailMask (`/api/avatar/...`), o null sin foto. */
|
|
522
530
|
avatarUrl: string | null;
|
|
523
531
|
}
|
|
532
|
+
type InboxStatus = "open" | "snoozed" | "closed";
|
|
533
|
+
interface InboxConversation {
|
|
534
|
+
id: string;
|
|
535
|
+
domainId: string;
|
|
536
|
+
/** El contacto externo (en un hilo que inició el dominio, el destinatario). */
|
|
537
|
+
from: string;
|
|
538
|
+
/** La máscara del dominio por la que va el hilo (`ventas@tudominio.com`). */
|
|
539
|
+
to: string;
|
|
540
|
+
subject: string;
|
|
541
|
+
status: InboxStatus;
|
|
542
|
+
assignedTo?: string;
|
|
543
|
+
priority: "normal" | "urgent";
|
|
544
|
+
lastMessageAt: string;
|
|
545
|
+
messageCount: number;
|
|
546
|
+
tags: string[];
|
|
547
|
+
deletedAt?: string;
|
|
548
|
+
snoozedUntil?: string;
|
|
549
|
+
/** Para quien pregunta: hay mensajes que no ha visto. */
|
|
550
|
+
unread?: boolean;
|
|
551
|
+
/** Sólo en búsqueda: fragmento con la coincidencia. */
|
|
552
|
+
snippet?: string;
|
|
553
|
+
[k: string]: unknown;
|
|
554
|
+
}
|
|
555
|
+
interface InboxListOptions {
|
|
556
|
+
/** `open`, `snoozed`, `closed`, `unread` (de quien pregunta) o `deleted` (papelera). */
|
|
557
|
+
status?: InboxStatus | "unread" | "deleted";
|
|
558
|
+
/** Dirección completa de la máscara (`ventas@tudominio.com`). */
|
|
559
|
+
to?: string;
|
|
560
|
+
assignedTo?: string;
|
|
561
|
+
/** Búsqueda en asunto, remitente y cuerpo. Con `q` no hay paginación (tope 50). */
|
|
562
|
+
q?: string;
|
|
563
|
+
/** Máx. 100. */
|
|
564
|
+
limit?: number;
|
|
565
|
+
cursor?: string;
|
|
566
|
+
}
|
|
567
|
+
interface InboxPage {
|
|
568
|
+
items: InboxConversation[];
|
|
569
|
+
nextCursor: string | null;
|
|
570
|
+
/** Máscaras con conversaciones (sólo en la primera página). */
|
|
571
|
+
aliases?: string[];
|
|
572
|
+
mode: "list" | "search" | "search-degraded";
|
|
573
|
+
unreadCount?: number;
|
|
574
|
+
[k: string]: unknown;
|
|
575
|
+
}
|
|
576
|
+
interface InboxAttachment {
|
|
577
|
+
index: number;
|
|
578
|
+
filename: string;
|
|
579
|
+
contentType: string;
|
|
580
|
+
size: number;
|
|
581
|
+
}
|
|
582
|
+
interface InboxMessage {
|
|
583
|
+
id: string;
|
|
584
|
+
conversationId: string;
|
|
585
|
+
from: string;
|
|
586
|
+
/** Texto plano. */
|
|
587
|
+
body?: string;
|
|
588
|
+
html?: string;
|
|
589
|
+
direction: "inbound" | "outbound";
|
|
590
|
+
createdAt: string;
|
|
591
|
+
messageId?: string;
|
|
592
|
+
deliveryStatus?: "sent" | "delivered" | "bounced" | "complained";
|
|
593
|
+
attachments?: InboxAttachment[];
|
|
594
|
+
/** El original ya no está (retención de 90 días o pérdida): `body` puede venir del índice. */
|
|
595
|
+
bodyDegraded?: string;
|
|
596
|
+
}
|
|
597
|
+
interface InboxNote {
|
|
598
|
+
id: string;
|
|
599
|
+
conversationId: string;
|
|
600
|
+
author: string;
|
|
601
|
+
body: string;
|
|
602
|
+
createdAt: string;
|
|
603
|
+
}
|
|
604
|
+
interface InboxConversationDetail extends InboxConversation {
|
|
605
|
+
messages: InboxMessage[];
|
|
606
|
+
notes: InboxNote[];
|
|
607
|
+
totalMessages: number;
|
|
608
|
+
hasMore: boolean;
|
|
609
|
+
}
|
|
610
|
+
interface InboxComposeInput {
|
|
611
|
+
/** Parte local (o dirección completa) de una máscara activa del dominio. */
|
|
612
|
+
fromAlias: string;
|
|
613
|
+
to: string;
|
|
614
|
+
subject: string;
|
|
615
|
+
markdown?: string;
|
|
616
|
+
html?: string;
|
|
617
|
+
body?: string;
|
|
618
|
+
cc?: string[];
|
|
619
|
+
bcc?: string[];
|
|
620
|
+
attachments?: AttachmentRef[];
|
|
621
|
+
}
|
|
622
|
+
interface InboxReplyInput {
|
|
623
|
+
markdown?: string;
|
|
624
|
+
html?: string;
|
|
625
|
+
body?: string;
|
|
626
|
+
cc?: string[];
|
|
627
|
+
bcc?: string[];
|
|
628
|
+
/** Cita el último mensaje recibido (por omisión true; sólo con markdown). */
|
|
629
|
+
quote?: boolean;
|
|
630
|
+
attachments?: AttachmentRef[];
|
|
631
|
+
}
|
|
632
|
+
interface InboxUpdateInput {
|
|
633
|
+
status?: InboxStatus;
|
|
634
|
+
/** ISO, futura y a menos de 90 días. Obligatoria con `status: "snoozed"`. */
|
|
635
|
+
snoozedUntil?: string;
|
|
636
|
+
tags?: string[];
|
|
637
|
+
priority?: "normal" | "urgent";
|
|
638
|
+
}
|
|
639
|
+
interface Order {
|
|
640
|
+
id: string;
|
|
641
|
+
number: string;
|
|
642
|
+
date: string;
|
|
643
|
+
kind: string;
|
|
644
|
+
concept: string;
|
|
645
|
+
subject: string | null;
|
|
646
|
+
amountCents: number;
|
|
647
|
+
listPriceCents: number | null;
|
|
648
|
+
currency: string;
|
|
649
|
+
periodStart: string | null;
|
|
650
|
+
periodEnd: string | null;
|
|
651
|
+
failureReason: string | null;
|
|
652
|
+
note: string | null;
|
|
653
|
+
reference: string | null;
|
|
654
|
+
}
|
|
655
|
+
interface OrdersPage {
|
|
656
|
+
orders: Order[];
|
|
657
|
+
nextCursor: string | null;
|
|
658
|
+
invoiceNote: string;
|
|
659
|
+
}
|
|
660
|
+
interface ReferralStats {
|
|
661
|
+
slug?: string | null;
|
|
662
|
+
referrals: unknown[];
|
|
663
|
+
[k: string]: unknown;
|
|
664
|
+
}
|
|
524
665
|
|
|
525
666
|
declare class MailMaskError extends Error {
|
|
526
667
|
status: number;
|
|
@@ -530,6 +671,9 @@ declare class MailMask {
|
|
|
530
671
|
private baseUrl;
|
|
531
672
|
private apiKey;
|
|
532
673
|
domains: DomainsResource;
|
|
674
|
+
/** Las direcciones del dominio (máscaras), con reenvío, buzón o ambos. */
|
|
675
|
+
addresses: AliasesResource;
|
|
676
|
+
/** @deprecated Usa `addresses`; es el mismo recurso y no se va a retirar. */
|
|
533
677
|
aliases: AliasesResource;
|
|
534
678
|
rules: RulesResource;
|
|
535
679
|
logs: LogsResource;
|
|
@@ -547,6 +691,8 @@ declare class MailMask {
|
|
|
547
691
|
signature: SignatureResource;
|
|
548
692
|
canned: CannedResource;
|
|
549
693
|
account: AccountResource;
|
|
694
|
+
inbox: InboxResource;
|
|
695
|
+
referrals: ReferralsResource;
|
|
550
696
|
constructor(config: MailMaskConfig);
|
|
551
697
|
}
|
|
552
698
|
type Req = <T>(path: string, opts?: RequestInit) => Promise<T>;
|
|
@@ -565,6 +711,19 @@ declare class DomainsResource {
|
|
|
565
711
|
dnsSetup(id: string, opts?: {
|
|
566
712
|
live?: boolean;
|
|
567
713
|
}): Promise<DnsSetup>;
|
|
714
|
+
/** Logo de la firma (PNG, JPG o WebP; máx. 500 KB). Se ve en todo correo en markdown. */
|
|
715
|
+
setLogo(id: string, file: Blob, filename?: string): Promise<{
|
|
716
|
+
ok: boolean;
|
|
717
|
+
logoUrl: string;
|
|
718
|
+
}>;
|
|
719
|
+
/** Logo desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
|
|
720
|
+
setLogoFromUrl(id: string, url: string): Promise<{
|
|
721
|
+
ok: boolean;
|
|
722
|
+
logoUrl: string;
|
|
723
|
+
}>;
|
|
724
|
+
removeLogo(id: string): Promise<{
|
|
725
|
+
ok: boolean;
|
|
726
|
+
}>;
|
|
568
727
|
}
|
|
569
728
|
declare class DnsResource {
|
|
570
729
|
private req;
|
|
@@ -645,6 +804,8 @@ declare class AttachmentsResource {
|
|
|
645
804
|
constructor(req: Req);
|
|
646
805
|
/** Máx. 5 MB. Ejecutables bloqueados (415). La llave vale hasta que se envía. */
|
|
647
806
|
upload(domainId: string, input: UploadAttachmentInput): Promise<UploadedAttachment>;
|
|
807
|
+
/** Desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
|
|
808
|
+
uploadFromUrl(domainId: string, url: string, filename?: string): Promise<UploadedAttachment>;
|
|
648
809
|
}
|
|
649
810
|
declare class SuppressionsResource {
|
|
650
811
|
private req;
|
|
@@ -702,7 +863,18 @@ declare class BillingResource {
|
|
|
702
863
|
*/
|
|
703
864
|
checkout(domainId: string, kind?: "domain" | "storage50" | "sends100", opts?: {
|
|
704
865
|
payerEmail?: string;
|
|
866
|
+
period?: "monthly" | "annual";
|
|
705
867
|
}): Promise<CheckoutLink>;
|
|
868
|
+
/** Cancela la suscripción de un add-on; el cupo sigue hasta el fin del periodo pagado. */
|
|
869
|
+
cancelAddon(addonId: string): Promise<{
|
|
870
|
+
ok: boolean;
|
|
871
|
+
activeUntil: string | null;
|
|
872
|
+
}>;
|
|
873
|
+
/** Historial de cobros, cortesías y cancelaciones (más reciente primero). */
|
|
874
|
+
orders(opts?: {
|
|
875
|
+
limit?: number;
|
|
876
|
+
before?: string;
|
|
877
|
+
}): Promise<OrdersPage>;
|
|
706
878
|
}
|
|
707
879
|
declare class RegistrationsResource {
|
|
708
880
|
private req;
|
|
@@ -721,6 +893,11 @@ declare class RegistrationsResource {
|
|
|
721
893
|
renewal(regId: string, opts?: {
|
|
722
894
|
payerEmail?: string;
|
|
723
895
|
}): Promise<RenewalLink>;
|
|
896
|
+
/** Deja de cobrar la renovación anual. El dominio sigue vigente hasta su vencimiento. */
|
|
897
|
+
cancelRenewal(regId: string): Promise<{
|
|
898
|
+
ok: boolean;
|
|
899
|
+
aviso: string;
|
|
900
|
+
}>;
|
|
724
901
|
}
|
|
725
902
|
declare class TransfersResource {
|
|
726
903
|
private req;
|
|
@@ -810,6 +987,67 @@ declare class AccountResource {
|
|
|
810
987
|
ok: boolean;
|
|
811
988
|
}>;
|
|
812
989
|
}
|
|
990
|
+
/**
|
|
991
|
+
* La Bandeja: conversaciones del dominio. Todo pasa por los mismos permisos que la app
|
|
992
|
+
* (dueño, admin o agente invitado) y los mismos topes de envío.
|
|
993
|
+
*/
|
|
994
|
+
declare class InboxResource {
|
|
995
|
+
private req;
|
|
996
|
+
private raw;
|
|
997
|
+
constructor(req: Req, raw: (path: string) => Promise<Response>);
|
|
998
|
+
list(domainId: string, opts?: InboxListOptions): Promise<InboxPage>;
|
|
999
|
+
/** Conversación con sus mensajes (los 30 más recientes, o anteriores a `before`). Abrirla la marca leída. */
|
|
1000
|
+
get(domainId: string, conversationId: string, opts?: {
|
|
1001
|
+
before?: string;
|
|
1002
|
+
}): Promise<InboxConversationDetail>;
|
|
1003
|
+
/** Un correo nuevo desde una máscara: abre un hilo. Gasta cuota de envío (dominio activado). */
|
|
1004
|
+
compose(domainId: string, input: InboxComposeInput): Promise<{
|
|
1005
|
+
ok: boolean;
|
|
1006
|
+
conversationId: string;
|
|
1007
|
+
messageId: string;
|
|
1008
|
+
}>;
|
|
1009
|
+
/** Responde en el hilo desde la máscara del hilo. No gasta cuota de envío. */
|
|
1010
|
+
reply(domainId: string, conversationId: string, input: InboxReplyInput): Promise<{
|
|
1011
|
+
ok: boolean;
|
|
1012
|
+
messageId: string;
|
|
1013
|
+
}>;
|
|
1014
|
+
update(domainId: string, conversationId: string, input: InboxUpdateInput): Promise<InboxConversation>;
|
|
1015
|
+
markRead(domainId: string, conversationId: string): Promise<{
|
|
1016
|
+
ok: boolean;
|
|
1017
|
+
unreadCount: number;
|
|
1018
|
+
}>;
|
|
1019
|
+
/** Sin `assignedTo` la deja sin asignar. */
|
|
1020
|
+
assign(domainId: string, conversationId: string, assignedTo?: string): Promise<InboxConversation>;
|
|
1021
|
+
/** Nota interna: la ve el equipo, nunca el contacto. */
|
|
1022
|
+
addNote(domainId: string, conversationId: string, body: string): Promise<InboxNote>;
|
|
1023
|
+
/** A la papelera (se puede restaurar). Máx. 200 por llamada. */
|
|
1024
|
+
delete(domainId: string, conversationIds: string[]): Promise<{
|
|
1025
|
+
ok: boolean;
|
|
1026
|
+
deleted: number;
|
|
1027
|
+
}>;
|
|
1028
|
+
restore(domainId: string, conversationId: string): Promise<{
|
|
1029
|
+
ok: boolean;
|
|
1030
|
+
}>;
|
|
1031
|
+
metrics(domainId: string, opts?: {
|
|
1032
|
+
days?: number;
|
|
1033
|
+
}): Promise<Record<string, unknown>>;
|
|
1034
|
+
/** Bytes de un adjunto de un mensaje (id del mensaje e índice de `attachments`). */
|
|
1035
|
+
attachment(domainId: string, conversationId: string, messageId: string, index: number): Promise<Response>;
|
|
1036
|
+
}
|
|
1037
|
+
declare class ReferralsResource {
|
|
1038
|
+
private req;
|
|
1039
|
+
constructor(req: Req);
|
|
1040
|
+
get(): Promise<ReferralStats>;
|
|
1041
|
+
/** 3-30 caracteres: minúsculas, números y guiones. */
|
|
1042
|
+
setSlug(slug: string): Promise<{
|
|
1043
|
+
ok: boolean;
|
|
1044
|
+
slug: string;
|
|
1045
|
+
}>;
|
|
1046
|
+
/** Nombre que ven los invitados (2-40 caracteres). */
|
|
1047
|
+
setName(name: string): Promise<{
|
|
1048
|
+
ok: boolean;
|
|
1049
|
+
}>;
|
|
1050
|
+
}
|
|
813
1051
|
|
|
814
1052
|
interface WebhookSignatureHeaders {
|
|
815
1053
|
/** Header `X-MailMask-Signature`, con forma `sha256=<hex>`. */
|
|
@@ -824,4 +1062,4 @@ interface WebhookSignatureHeaders {
|
|
|
824
1062
|
*/
|
|
825
1063
|
declare function verifyWebhookSignature(secret: string, headers: WebhookSignatureHeaders, rawBody: string, toleranceMs?: number): Promise<boolean>;
|
|
826
1064
|
|
|
827
|
-
export { type AccountProfile, type Addon, type AddonsResponse, type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BillingStatus, type BulkJob, type BulkJobCreated, type BulkSendInput, type CannedReply, type CheckoutLink, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type DnsChangeResult, type DnsDelegation, type DnsImportResult, type DnsListResponse, type DnsPreset, type DnsRRSet, type DnsRRSetAnotado, type DnsRecord, type DnsRecordType, type DnsSetup, type DnsSetupRecord, type DnsZoneCreated, type DnsZoneState, type Domain, type DomainCreated, type DomainInvite, type DomainMember, type DomainRegistration, type DomainRegistrationCreated, type DomainSearchResult, type DomainVerification, type EmailLog, MailMask, type MailMaskConfig, MailMaskError, type MailboxCreated, type RenewalLink, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type TldPrice, type TransferCheck, type TransferDnsInventory, type TransferRequirement, type UpdateAliasInput, type UpdateRuleInput, type UpdateWebhookInput, type UploadAttachmentInput, type UploadedAttachment, type Webhook, type WebhookCreated, type WebhookDelivery, type WebhookEvent, type WebhookPayload, type WebhookSignatureHeaders, verifyWebhookSignature };
|
|
1065
|
+
export { type AccountProfile, type Addon, type AddonsResponse, type Address, type AddressCreated, type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BillingStatus, type BulkJob, type BulkJobCreated, type BulkSendInput, type CannedReply, type CheckoutLink, type CreateAddressInput, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type DnsChangeResult, type DnsDelegation, type DnsImportResult, type DnsListResponse, type DnsPreset, type DnsRRSet, type DnsRRSetAnotado, type DnsRecord, type DnsRecordType, type DnsSetup, type DnsSetupRecord, type DnsZoneCreated, type DnsZoneState, type Domain, type DomainCreated, type DomainInvite, type DomainMember, type DomainRegistration, type DomainRegistrationCreated, type DomainSearchResult, type DomainVerification, type EmailLog, type InboxAttachment, type InboxComposeInput, type InboxConversation, type InboxConversationDetail, type InboxListOptions, type InboxMessage, type InboxNote, type InboxPage, type InboxReplyInput, type InboxStatus, type InboxUpdateInput, MailMask, type MailMaskConfig, MailMaskError, type MailboxCreated, type Order, type OrdersPage, type ReferralStats, type RenewalLink, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type TldPrice, type TransferCheck, type TransferDnsInventory, type TransferRequirement, type UpdateAddressInput, 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
|
@@ -31,7 +31,8 @@ var MailMask = class {
|
|
|
31
31
|
const doFetch = config.fetch ? config.fetch : fetch;
|
|
32
32
|
const req = (path, opts) => request(this.baseUrl, this.apiKey, path, opts, doFetch);
|
|
33
33
|
this.domains = new DomainsResource(req);
|
|
34
|
-
this.
|
|
34
|
+
this.addresses = new AliasesResource(req, (path) => requestRaw(this.baseUrl, this.apiKey, path, doFetch));
|
|
35
|
+
this.aliases = this.addresses;
|
|
35
36
|
this.rules = new RulesResource(req);
|
|
36
37
|
this.logs = new LogsResource(req);
|
|
37
38
|
this.send = new SendResource(req);
|
|
@@ -48,6 +49,8 @@ var MailMask = class {
|
|
|
48
49
|
this.signature = new SignatureResource(req);
|
|
49
50
|
this.canned = new CannedResource(req);
|
|
50
51
|
this.account = new AccountResource(req);
|
|
52
|
+
this.inbox = new InboxResource(req, (path) => requestRaw(this.baseUrl, this.apiKey, path, doFetch));
|
|
53
|
+
this.referrals = new ReferralsResource(req);
|
|
51
54
|
}
|
|
52
55
|
};
|
|
53
56
|
var DomainsResource = class {
|
|
@@ -76,6 +79,19 @@ var DomainsResource = class {
|
|
|
76
79
|
dnsSetup(id, opts) {
|
|
77
80
|
return this.req(`/api/domains/${id}/dns-setup${opts?.live ? "?live=1" : ""}`);
|
|
78
81
|
}
|
|
82
|
+
/** Logo de la firma (PNG, JPG o WebP; máx. 500 KB). Se ve en todo correo en markdown. */
|
|
83
|
+
setLogo(id, file, filename = "logo") {
|
|
84
|
+
const form = new FormData();
|
|
85
|
+
form.append("file", file, filename);
|
|
86
|
+
return this.req(`/api/domains/${id}/logo`, { method: "POST", body: form });
|
|
87
|
+
}
|
|
88
|
+
/** Logo desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
|
|
89
|
+
setLogoFromUrl(id, url) {
|
|
90
|
+
return this.req(`/api/domains/${id}/logo`, { method: "POST", body: JSON.stringify({ fromUrl: url }) });
|
|
91
|
+
}
|
|
92
|
+
removeLogo(id) {
|
|
93
|
+
return this.req(`/api/domains/${id}/logo`, { method: "DELETE" });
|
|
94
|
+
}
|
|
79
95
|
};
|
|
80
96
|
var DnsResource = class {
|
|
81
97
|
constructor(req) {
|
|
@@ -196,6 +212,10 @@ var AttachmentsResource = class {
|
|
|
196
212
|
form.append("file", blob, input.filename);
|
|
197
213
|
return this.req(`/api/domains/${domainId}/attachments`, { method: "POST", body: form });
|
|
198
214
|
}
|
|
215
|
+
/** Desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
|
|
216
|
+
uploadFromUrl(domainId, url, filename) {
|
|
217
|
+
return this.req(`/api/domains/${domainId}/attachments`, { method: "POST", body: JSON.stringify({ fromUrl: url, filename }) });
|
|
218
|
+
}
|
|
199
219
|
};
|
|
200
220
|
var SuppressionsResource = class {
|
|
201
221
|
constructor(req) {
|
|
@@ -278,7 +298,19 @@ var BillingResource = class {
|
|
|
278
298
|
* El usuario la abre y paga; hasta entonces no cambia nada.
|
|
279
299
|
*/
|
|
280
300
|
checkout(domainId, kind = "domain", opts) {
|
|
281
|
-
return this.req("/api/addons/checkout", { method: "POST", body: JSON.stringify({ kind, domainId, payerEmail: opts?.payerEmail }) });
|
|
301
|
+
return this.req("/api/addons/checkout", { method: "POST", body: JSON.stringify({ kind, domainId, payerEmail: opts?.payerEmail, period: opts?.period }) });
|
|
302
|
+
}
|
|
303
|
+
/** Cancela la suscripción de un add-on; el cupo sigue hasta el fin del periodo pagado. */
|
|
304
|
+
cancelAddon(addonId) {
|
|
305
|
+
return this.req(`/api/addons/${addonId}/cancel`, { method: "POST" });
|
|
306
|
+
}
|
|
307
|
+
/** Historial de cobros, cortesías y cancelaciones (más reciente primero). */
|
|
308
|
+
orders(opts) {
|
|
309
|
+
const qs = new URLSearchParams();
|
|
310
|
+
if (opts?.limit) qs.set("limit", String(opts.limit));
|
|
311
|
+
if (opts?.before) qs.set("before", opts.before);
|
|
312
|
+
const q = qs.toString();
|
|
313
|
+
return this.req(`/api/billing/orders${q ? `?${q}` : ""}`);
|
|
282
314
|
}
|
|
283
315
|
};
|
|
284
316
|
var RegistrationsResource = class {
|
|
@@ -306,6 +338,10 @@ var RegistrationsResource = class {
|
|
|
306
338
|
renewal(regId, opts) {
|
|
307
339
|
return this.req(`/api/domains/registrations/${regId}/renewal`, { method: "POST", body: JSON.stringify({ payerEmail: opts?.payerEmail }) });
|
|
308
340
|
}
|
|
341
|
+
/** Deja de cobrar la renovación anual. El dominio sigue vigente hasta su vencimiento. */
|
|
342
|
+
cancelRenewal(regId) {
|
|
343
|
+
return this.req(`/api/domains/registrations/${regId}/renewal/cancel`, { method: "POST" });
|
|
344
|
+
}
|
|
309
345
|
};
|
|
310
346
|
var TransfersResource = class {
|
|
311
347
|
constructor(req) {
|
|
@@ -398,6 +434,77 @@ var AccountResource = class {
|
|
|
398
434
|
return this.req("/api/profile/avatar", { method: "DELETE" });
|
|
399
435
|
}
|
|
400
436
|
};
|
|
437
|
+
var InboxResource = class {
|
|
438
|
+
constructor(req, raw) {
|
|
439
|
+
this.req = req;
|
|
440
|
+
this.raw = raw;
|
|
441
|
+
}
|
|
442
|
+
list(domainId, opts) {
|
|
443
|
+
const qs = new URLSearchParams({ domainId });
|
|
444
|
+
for (const [k, v] of Object.entries(opts ?? {})) if (v !== void 0 && v !== "") qs.set(k, String(v));
|
|
445
|
+
return this.req(`/api/bandeja/conversations?${qs}`);
|
|
446
|
+
}
|
|
447
|
+
/** Conversación con sus mensajes (los 30 más recientes, o anteriores a `before`). Abrirla la marca leída. */
|
|
448
|
+
get(domainId, conversationId, opts) {
|
|
449
|
+
const qs = new URLSearchParams({ domainId });
|
|
450
|
+
if (opts?.before) qs.set("before", opts.before);
|
|
451
|
+
return this.req(`/api/bandeja/conversations/${conversationId}?${qs}`);
|
|
452
|
+
}
|
|
453
|
+
/** Un correo nuevo desde una máscara: abre un hilo. Gasta cuota de envío (dominio activado). */
|
|
454
|
+
compose(domainId, input) {
|
|
455
|
+
return this.req("/api/bandeja/conversations", { method: "POST", body: JSON.stringify({ ...input, domainId }) });
|
|
456
|
+
}
|
|
457
|
+
/** Responde en el hilo desde la máscara del hilo. No gasta cuota de envío. */
|
|
458
|
+
reply(domainId, conversationId, input) {
|
|
459
|
+
return this.req(`/api/bandeja/conversations/${conversationId}/reply`, { method: "POST", body: JSON.stringify({ ...input, domainId }) });
|
|
460
|
+
}
|
|
461
|
+
update(domainId, conversationId, input) {
|
|
462
|
+
return this.req(`/api/bandeja/conversations/${conversationId}`, { method: "PATCH", body: JSON.stringify({ ...input, domainId }) });
|
|
463
|
+
}
|
|
464
|
+
markRead(domainId, conversationId) {
|
|
465
|
+
return this.req(`/api/bandeja/conversations/${conversationId}/read`, { method: "POST", body: JSON.stringify({ domainId }) });
|
|
466
|
+
}
|
|
467
|
+
/** Sin `assignedTo` la deja sin asignar. */
|
|
468
|
+
assign(domainId, conversationId, assignedTo) {
|
|
469
|
+
return this.req(`/api/bandeja/conversations/${conversationId}/assign`, { method: "POST", body: JSON.stringify({ domainId, assignedTo }) });
|
|
470
|
+
}
|
|
471
|
+
/** Nota interna: la ve el equipo, nunca el contacto. */
|
|
472
|
+
addNote(domainId, conversationId, body) {
|
|
473
|
+
return this.req(`/api/bandeja/conversations/${conversationId}/note`, { method: "POST", body: JSON.stringify({ domainId, body }) });
|
|
474
|
+
}
|
|
475
|
+
/** A la papelera (se puede restaurar). Máx. 200 por llamada. */
|
|
476
|
+
delete(domainId, conversationIds) {
|
|
477
|
+
return this.req("/api/bandeja/conversations/bulk-delete", { method: "POST", body: JSON.stringify({ domainId, ids: conversationIds }) });
|
|
478
|
+
}
|
|
479
|
+
restore(domainId, conversationId) {
|
|
480
|
+
return this.req(`/api/bandeja/conversations/${conversationId}/restore`, { method: "POST", body: JSON.stringify({ domainId }) });
|
|
481
|
+
}
|
|
482
|
+
metrics(domainId, opts) {
|
|
483
|
+
const qs = new URLSearchParams({ domainId });
|
|
484
|
+
if (opts?.days) qs.set("days", String(opts.days));
|
|
485
|
+
return this.req(`/api/bandeja/metrics?${qs}`);
|
|
486
|
+
}
|
|
487
|
+
/** Bytes de un adjunto de un mensaje (id del mensaje e índice de `attachments`). */
|
|
488
|
+
attachment(domainId, conversationId, messageId, index) {
|
|
489
|
+
return this.raw(`/api/bandeja/conversations/${conversationId}/attachments/${messageId}/${index}?domainId=${encodeURIComponent(domainId)}`);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
var ReferralsResource = class {
|
|
493
|
+
constructor(req) {
|
|
494
|
+
this.req = req;
|
|
495
|
+
}
|
|
496
|
+
get() {
|
|
497
|
+
return this.req("/api/referrals");
|
|
498
|
+
}
|
|
499
|
+
/** 3-30 caracteres: minúsculas, números y guiones. */
|
|
500
|
+
setSlug(slug) {
|
|
501
|
+
return this.req("/api/referrals/slug", { method: "PUT", body: JSON.stringify({ slug }) });
|
|
502
|
+
}
|
|
503
|
+
/** Nombre que ven los invitados (2-40 caracteres). */
|
|
504
|
+
setName(name) {
|
|
505
|
+
return this.req("/api/referrals/name", { method: "PUT", body: JSON.stringify({ name }) });
|
|
506
|
+
}
|
|
507
|
+
};
|
|
401
508
|
|
|
402
509
|
// src/verify.ts
|
|
403
510
|
function hex(buf) {
|