@easybits.cloud/mailmask 0.4.1 → 0.4.2
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/dist/index.cjs +139 -2
- package/dist/index.d.cts +273 -2
- package/dist/index.d.ts +273 -2
- package/dist/index.js +139 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,14 @@ async function request(baseUrl, apiKey, path, opts, doFetch = fetch) {
|
|
|
44
44
|
}
|
|
45
45
|
return res.json();
|
|
46
46
|
}
|
|
47
|
+
async function requestRaw(baseUrl, apiKey, path, doFetch = fetch) {
|
|
48
|
+
const res = await doFetch(`${baseUrl}${path}`, { headers: { "Authorization": `Bearer ${apiKey}` } });
|
|
49
|
+
if (!res.ok) {
|
|
50
|
+
const body = await res.json().catch(() => ({ error: res.statusText }));
|
|
51
|
+
throw new MailMaskError(res.status, body.error || res.statusText);
|
|
52
|
+
}
|
|
53
|
+
return res;
|
|
54
|
+
}
|
|
47
55
|
var MailMask = class {
|
|
48
56
|
constructor(config) {
|
|
49
57
|
this.apiKey = config.apiKey;
|
|
@@ -51,7 +59,7 @@ var MailMask = class {
|
|
|
51
59
|
const doFetch = config.fetch ? config.fetch : fetch;
|
|
52
60
|
const req = (path, opts) => request(this.baseUrl, this.apiKey, path, opts, doFetch);
|
|
53
61
|
this.domains = new DomainsResource(req);
|
|
54
|
-
this.aliases = new AliasesResource(req);
|
|
62
|
+
this.aliases = new AliasesResource(req, (path) => requestRaw(this.baseUrl, this.apiKey, path, doFetch));
|
|
55
63
|
this.rules = new RulesResource(req);
|
|
56
64
|
this.logs = new LogsResource(req);
|
|
57
65
|
this.send = new SendResource(req);
|
|
@@ -61,6 +69,12 @@ var MailMask = class {
|
|
|
61
69
|
this.smtp = new SmtpResource(req);
|
|
62
70
|
this.apiKeys = new ApiKeysResource(req);
|
|
63
71
|
this.dns = new DnsResource(req);
|
|
72
|
+
this.billing = new BillingResource(req);
|
|
73
|
+
this.registrations = new RegistrationsResource(req);
|
|
74
|
+
this.transfers = new TransfersResource(req);
|
|
75
|
+
this.members = new MembersResource(req);
|
|
76
|
+
this.signature = new SignatureResource(req);
|
|
77
|
+
this.canned = new CannedResource(req);
|
|
64
78
|
}
|
|
65
79
|
};
|
|
66
80
|
var DomainsResource = class {
|
|
@@ -85,6 +99,10 @@ var DomainsResource = class {
|
|
|
85
99
|
verify(id) {
|
|
86
100
|
return this.req(`/api/domains/${id}/verify`, { method: "POST" });
|
|
87
101
|
}
|
|
102
|
+
/** Registros a pegar en el registrador. Con `live` los compara con el DNS público y deduce el panel. */
|
|
103
|
+
dnsSetup(id, opts) {
|
|
104
|
+
return this.req(`/api/domains/${id}/dns-setup${opts?.live ? "?live=1" : ""}`);
|
|
105
|
+
}
|
|
88
106
|
};
|
|
89
107
|
var DnsResource = class {
|
|
90
108
|
constructor(req) {
|
|
@@ -114,8 +132,17 @@ var DnsResource = class {
|
|
|
114
132
|
}
|
|
115
133
|
};
|
|
116
134
|
var AliasesResource = class {
|
|
117
|
-
constructor(req) {
|
|
135
|
+
constructor(req, raw) {
|
|
118
136
|
this.req = req;
|
|
137
|
+
this.raw = raw;
|
|
138
|
+
}
|
|
139
|
+
/** Perfil de configuración de Apple Mail (plist) para el buzón de una máscara. */
|
|
140
|
+
async appleProfile(domainId, alias) {
|
|
141
|
+
return (await this.raw(`/api/domains/${domainId}/apple-profile?alias=${encodeURIComponent(alias)}`)).text();
|
|
142
|
+
}
|
|
143
|
+
/** Exporta el buzón en formato mbox. Devuelve la respuesta en streaming: un buzón puede pesar GB. */
|
|
144
|
+
exportMbox(domainId, alias) {
|
|
145
|
+
return this.raw(`/api/domains/${domainId}/alias/${alias}/mailbox/export`);
|
|
119
146
|
}
|
|
120
147
|
list(domainId) {
|
|
121
148
|
return this.req(`/api/domains/${domainId}/alias`);
|
|
@@ -263,6 +290,116 @@ var ApiKeysResource = class {
|
|
|
263
290
|
return this.req(`/api/api-keys/${id}`, { method: "DELETE" });
|
|
264
291
|
}
|
|
265
292
|
};
|
|
293
|
+
var BillingResource = class {
|
|
294
|
+
constructor(req) {
|
|
295
|
+
this.req = req;
|
|
296
|
+
}
|
|
297
|
+
status() {
|
|
298
|
+
return this.req("/api/billing/status");
|
|
299
|
+
}
|
|
300
|
+
addons() {
|
|
301
|
+
return this.req("/api/addons");
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Liga de MercadoPago para un add-on de un dominio (`domain` = activarlo, $99/mes).
|
|
305
|
+
* El usuario la abre y paga; hasta entonces no cambia nada.
|
|
306
|
+
*/
|
|
307
|
+
checkout(domainId, kind = "domain", opts) {
|
|
308
|
+
return this.req("/api/addons/checkout", { method: "POST", body: JSON.stringify({ kind, domainId, payerEmail: opts?.payerEmail }) });
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
var RegistrationsResource = class {
|
|
312
|
+
constructor(req) {
|
|
313
|
+
this.req = req;
|
|
314
|
+
}
|
|
315
|
+
search(domain) {
|
|
316
|
+
return this.req(`/api/domains/search?q=${encodeURIComponent(domain)}`);
|
|
317
|
+
}
|
|
318
|
+
tlds() {
|
|
319
|
+
return this.req("/api/domains/tlds");
|
|
320
|
+
}
|
|
321
|
+
/** Crea el registro pendiente y devuelve la liga de pago; el dominio se registra al pagar. */
|
|
322
|
+
register(domain) {
|
|
323
|
+
return this.req("/api/domains/register", { method: "POST", body: JSON.stringify({ domain }) });
|
|
324
|
+
}
|
|
325
|
+
list() {
|
|
326
|
+
return this.req("/api/domains/registrations");
|
|
327
|
+
}
|
|
328
|
+
/** Pide el traslado a otro registrador. El código EPP llega por correo al dueño, nunca en la respuesta. */
|
|
329
|
+
transferOut(regId) {
|
|
330
|
+
return this.req(`/api/domains/registrations/${regId}/transfer-out`, { method: "POST" });
|
|
331
|
+
}
|
|
332
|
+
/** Liga de MercadoPago para la suscripción de renovación anual. */
|
|
333
|
+
renewal(regId, opts) {
|
|
334
|
+
return this.req(`/api/domains/registrations/${regId}/renewal`, { method: "POST", body: JSON.stringify({ payerEmail: opts?.payerEmail }) });
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
var TransfersResource = class {
|
|
338
|
+
constructor(req) {
|
|
339
|
+
this.req = req;
|
|
340
|
+
}
|
|
341
|
+
/** Requisitos, precio e inventario del DNS actual. No cobra ni crea nada. */
|
|
342
|
+
check(domain) {
|
|
343
|
+
return this.req("/api/domains/transfer/check", { method: "POST", body: JSON.stringify({ domain }) });
|
|
344
|
+
}
|
|
345
|
+
dns(regId) {
|
|
346
|
+
return this.req(`/api/domains/transfer/${regId}/dns`);
|
|
347
|
+
}
|
|
348
|
+
/** Reemplaza el inventario completo (RRSets). Vuelve a quedar pendiente de aprobar. */
|
|
349
|
+
setDns(regId, records) {
|
|
350
|
+
return this.req(`/api/domains/transfer/${regId}/dns`, { method: "PUT", body: JSON.stringify({ records }) });
|
|
351
|
+
}
|
|
352
|
+
approveDns(regId) {
|
|
353
|
+
return this.req(`/api/domains/transfer/${regId}/dns/approve`, { method: "POST" });
|
|
354
|
+
}
|
|
355
|
+
resendEmail(regId) {
|
|
356
|
+
return this.req(`/api/domains/transfer/${regId}/resend-email`, { method: "POST" });
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
var MembersResource = class {
|
|
360
|
+
constructor(req) {
|
|
361
|
+
this.req = req;
|
|
362
|
+
}
|
|
363
|
+
list(domainId) {
|
|
364
|
+
return this.req(`/api/domains/${domainId}/agents`);
|
|
365
|
+
}
|
|
366
|
+
invite(domainId, input) {
|
|
367
|
+
return this.req(`/api/domains/${domainId}/agents/invite`, { method: "POST", body: JSON.stringify(input) });
|
|
368
|
+
}
|
|
369
|
+
remove(domainId, memberId) {
|
|
370
|
+
return this.req(`/api/domains/${domainId}/agents/${memberId}`, { method: "DELETE" });
|
|
371
|
+
}
|
|
372
|
+
cancelInvite(domainId, token) {
|
|
373
|
+
return this.req(`/api/domains/${domainId}/agents/invites/${token}`, { method: "DELETE" });
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
var SignatureResource = class {
|
|
377
|
+
constructor(req) {
|
|
378
|
+
this.req = req;
|
|
379
|
+
}
|
|
380
|
+
async get(domainId) {
|
|
381
|
+
const d = await this.req(`/api/domains/${domainId}`);
|
|
382
|
+
return { signature: d.signature ?? null };
|
|
383
|
+
}
|
|
384
|
+
/** Markdown, máx. 2000 caracteres. Cadena vacía la borra. */
|
|
385
|
+
set(domainId, signature) {
|
|
386
|
+
return this.req(`/api/domains/${domainId}/signature`, { method: "PUT", body: JSON.stringify({ signature }) });
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
var CannedResource = class {
|
|
390
|
+
constructor(req) {
|
|
391
|
+
this.req = req;
|
|
392
|
+
}
|
|
393
|
+
list(domainId) {
|
|
394
|
+
return this.req(`/api/domains/${domainId}/canned`);
|
|
395
|
+
}
|
|
396
|
+
create(domainId, input) {
|
|
397
|
+
return this.req(`/api/domains/${domainId}/canned`, { method: "POST", body: JSON.stringify(input) });
|
|
398
|
+
}
|
|
399
|
+
delete(domainId, cannedId) {
|
|
400
|
+
return this.req(`/api/domains/${domainId}/canned/${cannedId}`, { method: "DELETE" });
|
|
401
|
+
}
|
|
402
|
+
};
|
|
266
403
|
|
|
267
404
|
// src/verify.ts
|
|
268
405
|
function hex(buf) {
|
package/dist/index.d.cts
CHANGED
|
@@ -354,6 +354,163 @@ interface DnsChangeResult {
|
|
|
354
354
|
propagacion: string;
|
|
355
355
|
}
|
|
356
356
|
type DnsPreset = "vercel" | "netlify" | "github-pages" | "cloudflare-pages" | "render" | "fly" | "redirect-a-www" | "dmarc";
|
|
357
|
+
interface DnsSetupRecord {
|
|
358
|
+
id: string;
|
|
359
|
+
type: "MX" | "TXT" | "CNAME";
|
|
360
|
+
/** Relativo al dominio, como lo piden casi todos los paneles ('@', '_amazonses'). */
|
|
361
|
+
name: string;
|
|
362
|
+
fqdn: string;
|
|
363
|
+
value: string;
|
|
364
|
+
/** Sólo MX, para paneles con campo de prioridad aparte (entonces el valor es `host`). */
|
|
365
|
+
priority?: number;
|
|
366
|
+
host?: string;
|
|
367
|
+
level: "requerido" | "recomendado" | "opcional";
|
|
368
|
+
purpose: string;
|
|
369
|
+
benefit?: string;
|
|
370
|
+
/** Ayuda en texto con **negritas** estilo markdown. */
|
|
371
|
+
hints: string[];
|
|
372
|
+
/** Sólo con `live`: si el DNS público ya lo tiene; null = no se pudo consultar. */
|
|
373
|
+
ok?: boolean | null;
|
|
374
|
+
observed?: string[];
|
|
375
|
+
/** SPF: valor fusionado cuando ya existe otro SPF (se edita ése, no se crea otro). */
|
|
376
|
+
suggestedValue?: string;
|
|
377
|
+
}
|
|
378
|
+
interface DnsSetup {
|
|
379
|
+
domain: string;
|
|
380
|
+
records: DnsSetupRecord[];
|
|
381
|
+
live: boolean;
|
|
382
|
+
nameservers?: string[];
|
|
383
|
+
/** Panel donde se pegan, deducido de los nameservers. */
|
|
384
|
+
registrarHint?: {
|
|
385
|
+
provider: string;
|
|
386
|
+
label: string;
|
|
387
|
+
note: string;
|
|
388
|
+
} | null;
|
|
389
|
+
summary?: string;
|
|
390
|
+
}
|
|
391
|
+
interface BillingStatus {
|
|
392
|
+
subscription: {
|
|
393
|
+
plan: string;
|
|
394
|
+
status: string;
|
|
395
|
+
currentPeriodEnd?: string;
|
|
396
|
+
[k: string]: unknown;
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
interface Addon {
|
|
400
|
+
id: string;
|
|
401
|
+
kind: string;
|
|
402
|
+
/** Dominio al que aplica; sin él es un add-on legado de toda la cuenta. */
|
|
403
|
+
domainId?: string;
|
|
404
|
+
status: "pending" | "active" | "cancelled" | "expired";
|
|
405
|
+
priceCents: number;
|
|
406
|
+
currentPeriodEnd?: string;
|
|
407
|
+
createdAt: string;
|
|
408
|
+
cancelledAt?: string;
|
|
409
|
+
source: "purchase" | "courtesy" | "migration";
|
|
410
|
+
}
|
|
411
|
+
interface AddonsResponse {
|
|
412
|
+
catalog: Record<string, {
|
|
413
|
+
price: number;
|
|
414
|
+
label: string;
|
|
415
|
+
}>;
|
|
416
|
+
forSale: string[];
|
|
417
|
+
mine: Addon[];
|
|
418
|
+
}
|
|
419
|
+
/** Liga de pago de MercadoPago. Nada cambia hasta que el usuario la abre y paga. */
|
|
420
|
+
interface CheckoutLink {
|
|
421
|
+
init_point: string;
|
|
422
|
+
addonId: string;
|
|
423
|
+
}
|
|
424
|
+
interface DomainSearchResult {
|
|
425
|
+
available: boolean;
|
|
426
|
+
domain: string;
|
|
427
|
+
tld: string;
|
|
428
|
+
/** Centavos MXN por año. */
|
|
429
|
+
price: number;
|
|
430
|
+
currency: "MXN";
|
|
431
|
+
}
|
|
432
|
+
interface TldPrice {
|
|
433
|
+
tld: string;
|
|
434
|
+
/** Centavos MXN. */
|
|
435
|
+
price: number;
|
|
436
|
+
renewPrice: number;
|
|
437
|
+
transferPrice: number;
|
|
438
|
+
popular: boolean;
|
|
439
|
+
}
|
|
440
|
+
interface DomainRegistrationCreated {
|
|
441
|
+
/** Liga de pago de MercadoPago; el registro arranca al pagar. */
|
|
442
|
+
initPoint: string;
|
|
443
|
+
registrationId: string;
|
|
444
|
+
}
|
|
445
|
+
interface DomainRegistration {
|
|
446
|
+
id: string;
|
|
447
|
+
domainId: string | null;
|
|
448
|
+
domainName: string;
|
|
449
|
+
kind: "register" | "transfer";
|
|
450
|
+
status: string;
|
|
451
|
+
expiresAt: string | null;
|
|
452
|
+
priceCents: number;
|
|
453
|
+
renewalStatus: string;
|
|
454
|
+
renewalPriceCents: number | null;
|
|
455
|
+
nextChargeAt: string | null;
|
|
456
|
+
dnsImportStatus: string;
|
|
457
|
+
transferAuthCodeHint: string | null;
|
|
458
|
+
lastError: string | null;
|
|
459
|
+
createdAt: string;
|
|
460
|
+
[k: string]: unknown;
|
|
461
|
+
}
|
|
462
|
+
interface TransferRequirement {
|
|
463
|
+
texto: string;
|
|
464
|
+
ok: boolean | null;
|
|
465
|
+
ayuda?: string;
|
|
466
|
+
}
|
|
467
|
+
interface TransferCheck {
|
|
468
|
+
domain: string;
|
|
469
|
+
/** Centavos MXN; incluye un año de renovación. */
|
|
470
|
+
price: number;
|
|
471
|
+
currency: "MXN";
|
|
472
|
+
requisitos: TransferRequirement[];
|
|
473
|
+
dns: {
|
|
474
|
+
found: unknown[];
|
|
475
|
+
nameservers?: string[];
|
|
476
|
+
warning?: string;
|
|
477
|
+
truncado?: boolean;
|
|
478
|
+
};
|
|
479
|
+
[k: string]: unknown;
|
|
480
|
+
}
|
|
481
|
+
interface TransferDnsInventory {
|
|
482
|
+
records: unknown[];
|
|
483
|
+
status: string;
|
|
484
|
+
takenAt: string | null;
|
|
485
|
+
}
|
|
486
|
+
interface RenewalLink {
|
|
487
|
+
init_point: string;
|
|
488
|
+
nextChargeAt: string;
|
|
489
|
+
}
|
|
490
|
+
interface DomainMember {
|
|
491
|
+
id: string;
|
|
492
|
+
domainId: string;
|
|
493
|
+
email: string;
|
|
494
|
+
name: string;
|
|
495
|
+
role: "admin" | "agent";
|
|
496
|
+
createdAt: string;
|
|
497
|
+
}
|
|
498
|
+
interface DomainInvite {
|
|
499
|
+
token: string;
|
|
500
|
+
email: string;
|
|
501
|
+
name: string;
|
|
502
|
+
role: "admin" | "agent";
|
|
503
|
+
expiresAt: string;
|
|
504
|
+
inviteUrl: string;
|
|
505
|
+
}
|
|
506
|
+
interface CannedReply {
|
|
507
|
+
id: string;
|
|
508
|
+
domainId: string;
|
|
509
|
+
title: string;
|
|
510
|
+
/** Markdown. */
|
|
511
|
+
body: string;
|
|
512
|
+
createdAt: string;
|
|
513
|
+
}
|
|
357
514
|
|
|
358
515
|
declare class MailMaskError extends Error {
|
|
359
516
|
status: number;
|
|
@@ -373,6 +530,12 @@ declare class MailMask {
|
|
|
373
530
|
smtp: SmtpResource;
|
|
374
531
|
apiKeys: ApiKeysResource;
|
|
375
532
|
dns: DnsResource;
|
|
533
|
+
billing: BillingResource;
|
|
534
|
+
registrations: RegistrationsResource;
|
|
535
|
+
transfers: TransfersResource;
|
|
536
|
+
members: MembersResource;
|
|
537
|
+
signature: SignatureResource;
|
|
538
|
+
canned: CannedResource;
|
|
376
539
|
constructor(config: MailMaskConfig);
|
|
377
540
|
}
|
|
378
541
|
type Req = <T>(path: string, opts?: RequestInit) => Promise<T>;
|
|
@@ -387,6 +550,10 @@ declare class DomainsResource {
|
|
|
387
550
|
}>;
|
|
388
551
|
health(id: string): Promise<Record<string, unknown>>;
|
|
389
552
|
verify(id: string): Promise<DomainVerification>;
|
|
553
|
+
/** Registros a pegar en el registrador. Con `live` los compara con el DNS público y deduce el panel. */
|
|
554
|
+
dnsSetup(id: string, opts?: {
|
|
555
|
+
live?: boolean;
|
|
556
|
+
}): Promise<DnsSetup>;
|
|
390
557
|
}
|
|
391
558
|
declare class DnsResource {
|
|
392
559
|
private req;
|
|
@@ -410,7 +577,12 @@ declare class DnsResource {
|
|
|
410
577
|
}
|
|
411
578
|
declare class AliasesResource {
|
|
412
579
|
private req;
|
|
413
|
-
|
|
580
|
+
private raw;
|
|
581
|
+
constructor(req: Req, raw: (path: string) => Promise<Response>);
|
|
582
|
+
/** Perfil de configuración de Apple Mail (plist) para el buzón de una máscara. */
|
|
583
|
+
appleProfile(domainId: string, alias: string): Promise<string>;
|
|
584
|
+
/** Exporta el buzón en formato mbox. Devuelve la respuesta en streaming: un buzón puede pesar GB. */
|
|
585
|
+
exportMbox(domainId: string, alias: string): Promise<Response>;
|
|
414
586
|
list(domainId: string): Promise<Alias[]>;
|
|
415
587
|
create(domainId: string, input: CreateAliasInput): Promise<AliasCreated>;
|
|
416
588
|
/** Crea un buzón IMAP para una máscara existente. La contraseña sólo se devuelve aquí. */
|
|
@@ -508,6 +680,105 @@ declare class ApiKeysResource {
|
|
|
508
680
|
ok: boolean;
|
|
509
681
|
}>;
|
|
510
682
|
}
|
|
683
|
+
declare class BillingResource {
|
|
684
|
+
private req;
|
|
685
|
+
constructor(req: Req);
|
|
686
|
+
status(): Promise<BillingStatus>;
|
|
687
|
+
addons(): Promise<AddonsResponse>;
|
|
688
|
+
/**
|
|
689
|
+
* Liga de MercadoPago para un add-on de un dominio (`domain` = activarlo, $99/mes).
|
|
690
|
+
* El usuario la abre y paga; hasta entonces no cambia nada.
|
|
691
|
+
*/
|
|
692
|
+
checkout(domainId: string, kind?: "domain" | "storage50" | "sends100", opts?: {
|
|
693
|
+
payerEmail?: string;
|
|
694
|
+
}): Promise<CheckoutLink>;
|
|
695
|
+
}
|
|
696
|
+
declare class RegistrationsResource {
|
|
697
|
+
private req;
|
|
698
|
+
constructor(req: Req);
|
|
699
|
+
search(domain: string): Promise<DomainSearchResult>;
|
|
700
|
+
tlds(): Promise<TldPrice[]>;
|
|
701
|
+
/** Crea el registro pendiente y devuelve la liga de pago; el dominio se registra al pagar. */
|
|
702
|
+
register(domain: string): Promise<DomainRegistrationCreated>;
|
|
703
|
+
list(): Promise<DomainRegistration[]>;
|
|
704
|
+
/** Pide el traslado a otro registrador. El código EPP llega por correo al dueño, nunca en la respuesta. */
|
|
705
|
+
transferOut(regId: string): Promise<{
|
|
706
|
+
ok: boolean;
|
|
707
|
+
aviso: string;
|
|
708
|
+
}>;
|
|
709
|
+
/** Liga de MercadoPago para la suscripción de renovación anual. */
|
|
710
|
+
renewal(regId: string, opts?: {
|
|
711
|
+
payerEmail?: string;
|
|
712
|
+
}): Promise<RenewalLink>;
|
|
713
|
+
}
|
|
714
|
+
declare class TransfersResource {
|
|
715
|
+
private req;
|
|
716
|
+
constructor(req: Req);
|
|
717
|
+
/** Requisitos, precio e inventario del DNS actual. No cobra ni crea nada. */
|
|
718
|
+
check(domain: string): Promise<TransferCheck>;
|
|
719
|
+
dns(regId: string): Promise<TransferDnsInventory>;
|
|
720
|
+
/** Reemplaza el inventario completo (RRSets). Vuelve a quedar pendiente de aprobar. */
|
|
721
|
+
setDns(regId: string, records: {
|
|
722
|
+
name: string;
|
|
723
|
+
type: string;
|
|
724
|
+
ttl?: number;
|
|
725
|
+
values: string[];
|
|
726
|
+
}[]): Promise<{
|
|
727
|
+
records: unknown[];
|
|
728
|
+
}>;
|
|
729
|
+
approveDns(regId: string): Promise<{
|
|
730
|
+
ok: boolean;
|
|
731
|
+
}>;
|
|
732
|
+
resendEmail(regId: string): Promise<{
|
|
733
|
+
ok: boolean;
|
|
734
|
+
}>;
|
|
735
|
+
}
|
|
736
|
+
declare class MembersResource {
|
|
737
|
+
private req;
|
|
738
|
+
constructor(req: Req);
|
|
739
|
+
list(domainId: string): Promise<{
|
|
740
|
+
members: DomainMember[];
|
|
741
|
+
invites: DomainInvite[];
|
|
742
|
+
}>;
|
|
743
|
+
invite(domainId: string, input: {
|
|
744
|
+
email: string;
|
|
745
|
+
name: string;
|
|
746
|
+
role?: "admin" | "agent";
|
|
747
|
+
}): Promise<{
|
|
748
|
+
ok: boolean;
|
|
749
|
+
inviteUrl: string;
|
|
750
|
+
}>;
|
|
751
|
+
remove(domainId: string, memberId: string): Promise<{
|
|
752
|
+
ok: boolean;
|
|
753
|
+
}>;
|
|
754
|
+
cancelInvite(domainId: string, token: string): Promise<{
|
|
755
|
+
ok: boolean;
|
|
756
|
+
}>;
|
|
757
|
+
}
|
|
758
|
+
declare class SignatureResource {
|
|
759
|
+
private req;
|
|
760
|
+
constructor(req: Req);
|
|
761
|
+
get(domainId: string): Promise<{
|
|
762
|
+
signature: string | null;
|
|
763
|
+
}>;
|
|
764
|
+
/** Markdown, máx. 2000 caracteres. Cadena vacía la borra. */
|
|
765
|
+
set(domainId: string, signature: string): Promise<{
|
|
766
|
+
ok: boolean;
|
|
767
|
+
signature: string | null;
|
|
768
|
+
}>;
|
|
769
|
+
}
|
|
770
|
+
declare class CannedResource {
|
|
771
|
+
private req;
|
|
772
|
+
constructor(req: Req);
|
|
773
|
+
list(domainId: string): Promise<CannedReply[]>;
|
|
774
|
+
create(domainId: string, input: {
|
|
775
|
+
title: string;
|
|
776
|
+
body: string;
|
|
777
|
+
}): Promise<CannedReply>;
|
|
778
|
+
delete(domainId: string, cannedId: string): Promise<{
|
|
779
|
+
ok: boolean;
|
|
780
|
+
}>;
|
|
781
|
+
}
|
|
511
782
|
|
|
512
783
|
interface WebhookSignatureHeaders {
|
|
513
784
|
/** Header `X-MailMask-Signature`, con forma `sha256=<hex>`. */
|
|
@@ -522,4 +793,4 @@ interface WebhookSignatureHeaders {
|
|
|
522
793
|
*/
|
|
523
794
|
declare function verifyWebhookSignature(secret: string, headers: WebhookSignatureHeaders, rawBody: string, toleranceMs?: number): Promise<boolean>;
|
|
524
795
|
|
|
525
|
-
export { type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BulkJob, type BulkJobCreated, type BulkSendInput, 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 DnsZoneCreated, type DnsZoneState, 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 };
|
|
796
|
+
export { 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -354,6 +354,163 @@ interface DnsChangeResult {
|
|
|
354
354
|
propagacion: string;
|
|
355
355
|
}
|
|
356
356
|
type DnsPreset = "vercel" | "netlify" | "github-pages" | "cloudflare-pages" | "render" | "fly" | "redirect-a-www" | "dmarc";
|
|
357
|
+
interface DnsSetupRecord {
|
|
358
|
+
id: string;
|
|
359
|
+
type: "MX" | "TXT" | "CNAME";
|
|
360
|
+
/** Relativo al dominio, como lo piden casi todos los paneles ('@', '_amazonses'). */
|
|
361
|
+
name: string;
|
|
362
|
+
fqdn: string;
|
|
363
|
+
value: string;
|
|
364
|
+
/** Sólo MX, para paneles con campo de prioridad aparte (entonces el valor es `host`). */
|
|
365
|
+
priority?: number;
|
|
366
|
+
host?: string;
|
|
367
|
+
level: "requerido" | "recomendado" | "opcional";
|
|
368
|
+
purpose: string;
|
|
369
|
+
benefit?: string;
|
|
370
|
+
/** Ayuda en texto con **negritas** estilo markdown. */
|
|
371
|
+
hints: string[];
|
|
372
|
+
/** Sólo con `live`: si el DNS público ya lo tiene; null = no se pudo consultar. */
|
|
373
|
+
ok?: boolean | null;
|
|
374
|
+
observed?: string[];
|
|
375
|
+
/** SPF: valor fusionado cuando ya existe otro SPF (se edita ése, no se crea otro). */
|
|
376
|
+
suggestedValue?: string;
|
|
377
|
+
}
|
|
378
|
+
interface DnsSetup {
|
|
379
|
+
domain: string;
|
|
380
|
+
records: DnsSetupRecord[];
|
|
381
|
+
live: boolean;
|
|
382
|
+
nameservers?: string[];
|
|
383
|
+
/** Panel donde se pegan, deducido de los nameservers. */
|
|
384
|
+
registrarHint?: {
|
|
385
|
+
provider: string;
|
|
386
|
+
label: string;
|
|
387
|
+
note: string;
|
|
388
|
+
} | null;
|
|
389
|
+
summary?: string;
|
|
390
|
+
}
|
|
391
|
+
interface BillingStatus {
|
|
392
|
+
subscription: {
|
|
393
|
+
plan: string;
|
|
394
|
+
status: string;
|
|
395
|
+
currentPeriodEnd?: string;
|
|
396
|
+
[k: string]: unknown;
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
interface Addon {
|
|
400
|
+
id: string;
|
|
401
|
+
kind: string;
|
|
402
|
+
/** Dominio al que aplica; sin él es un add-on legado de toda la cuenta. */
|
|
403
|
+
domainId?: string;
|
|
404
|
+
status: "pending" | "active" | "cancelled" | "expired";
|
|
405
|
+
priceCents: number;
|
|
406
|
+
currentPeriodEnd?: string;
|
|
407
|
+
createdAt: string;
|
|
408
|
+
cancelledAt?: string;
|
|
409
|
+
source: "purchase" | "courtesy" | "migration";
|
|
410
|
+
}
|
|
411
|
+
interface AddonsResponse {
|
|
412
|
+
catalog: Record<string, {
|
|
413
|
+
price: number;
|
|
414
|
+
label: string;
|
|
415
|
+
}>;
|
|
416
|
+
forSale: string[];
|
|
417
|
+
mine: Addon[];
|
|
418
|
+
}
|
|
419
|
+
/** Liga de pago de MercadoPago. Nada cambia hasta que el usuario la abre y paga. */
|
|
420
|
+
interface CheckoutLink {
|
|
421
|
+
init_point: string;
|
|
422
|
+
addonId: string;
|
|
423
|
+
}
|
|
424
|
+
interface DomainSearchResult {
|
|
425
|
+
available: boolean;
|
|
426
|
+
domain: string;
|
|
427
|
+
tld: string;
|
|
428
|
+
/** Centavos MXN por año. */
|
|
429
|
+
price: number;
|
|
430
|
+
currency: "MXN";
|
|
431
|
+
}
|
|
432
|
+
interface TldPrice {
|
|
433
|
+
tld: string;
|
|
434
|
+
/** Centavos MXN. */
|
|
435
|
+
price: number;
|
|
436
|
+
renewPrice: number;
|
|
437
|
+
transferPrice: number;
|
|
438
|
+
popular: boolean;
|
|
439
|
+
}
|
|
440
|
+
interface DomainRegistrationCreated {
|
|
441
|
+
/** Liga de pago de MercadoPago; el registro arranca al pagar. */
|
|
442
|
+
initPoint: string;
|
|
443
|
+
registrationId: string;
|
|
444
|
+
}
|
|
445
|
+
interface DomainRegistration {
|
|
446
|
+
id: string;
|
|
447
|
+
domainId: string | null;
|
|
448
|
+
domainName: string;
|
|
449
|
+
kind: "register" | "transfer";
|
|
450
|
+
status: string;
|
|
451
|
+
expiresAt: string | null;
|
|
452
|
+
priceCents: number;
|
|
453
|
+
renewalStatus: string;
|
|
454
|
+
renewalPriceCents: number | null;
|
|
455
|
+
nextChargeAt: string | null;
|
|
456
|
+
dnsImportStatus: string;
|
|
457
|
+
transferAuthCodeHint: string | null;
|
|
458
|
+
lastError: string | null;
|
|
459
|
+
createdAt: string;
|
|
460
|
+
[k: string]: unknown;
|
|
461
|
+
}
|
|
462
|
+
interface TransferRequirement {
|
|
463
|
+
texto: string;
|
|
464
|
+
ok: boolean | null;
|
|
465
|
+
ayuda?: string;
|
|
466
|
+
}
|
|
467
|
+
interface TransferCheck {
|
|
468
|
+
domain: string;
|
|
469
|
+
/** Centavos MXN; incluye un año de renovación. */
|
|
470
|
+
price: number;
|
|
471
|
+
currency: "MXN";
|
|
472
|
+
requisitos: TransferRequirement[];
|
|
473
|
+
dns: {
|
|
474
|
+
found: unknown[];
|
|
475
|
+
nameservers?: string[];
|
|
476
|
+
warning?: string;
|
|
477
|
+
truncado?: boolean;
|
|
478
|
+
};
|
|
479
|
+
[k: string]: unknown;
|
|
480
|
+
}
|
|
481
|
+
interface TransferDnsInventory {
|
|
482
|
+
records: unknown[];
|
|
483
|
+
status: string;
|
|
484
|
+
takenAt: string | null;
|
|
485
|
+
}
|
|
486
|
+
interface RenewalLink {
|
|
487
|
+
init_point: string;
|
|
488
|
+
nextChargeAt: string;
|
|
489
|
+
}
|
|
490
|
+
interface DomainMember {
|
|
491
|
+
id: string;
|
|
492
|
+
domainId: string;
|
|
493
|
+
email: string;
|
|
494
|
+
name: string;
|
|
495
|
+
role: "admin" | "agent";
|
|
496
|
+
createdAt: string;
|
|
497
|
+
}
|
|
498
|
+
interface DomainInvite {
|
|
499
|
+
token: string;
|
|
500
|
+
email: string;
|
|
501
|
+
name: string;
|
|
502
|
+
role: "admin" | "agent";
|
|
503
|
+
expiresAt: string;
|
|
504
|
+
inviteUrl: string;
|
|
505
|
+
}
|
|
506
|
+
interface CannedReply {
|
|
507
|
+
id: string;
|
|
508
|
+
domainId: string;
|
|
509
|
+
title: string;
|
|
510
|
+
/** Markdown. */
|
|
511
|
+
body: string;
|
|
512
|
+
createdAt: string;
|
|
513
|
+
}
|
|
357
514
|
|
|
358
515
|
declare class MailMaskError extends Error {
|
|
359
516
|
status: number;
|
|
@@ -373,6 +530,12 @@ declare class MailMask {
|
|
|
373
530
|
smtp: SmtpResource;
|
|
374
531
|
apiKeys: ApiKeysResource;
|
|
375
532
|
dns: DnsResource;
|
|
533
|
+
billing: BillingResource;
|
|
534
|
+
registrations: RegistrationsResource;
|
|
535
|
+
transfers: TransfersResource;
|
|
536
|
+
members: MembersResource;
|
|
537
|
+
signature: SignatureResource;
|
|
538
|
+
canned: CannedResource;
|
|
376
539
|
constructor(config: MailMaskConfig);
|
|
377
540
|
}
|
|
378
541
|
type Req = <T>(path: string, opts?: RequestInit) => Promise<T>;
|
|
@@ -387,6 +550,10 @@ declare class DomainsResource {
|
|
|
387
550
|
}>;
|
|
388
551
|
health(id: string): Promise<Record<string, unknown>>;
|
|
389
552
|
verify(id: string): Promise<DomainVerification>;
|
|
553
|
+
/** Registros a pegar en el registrador. Con `live` los compara con el DNS público y deduce el panel. */
|
|
554
|
+
dnsSetup(id: string, opts?: {
|
|
555
|
+
live?: boolean;
|
|
556
|
+
}): Promise<DnsSetup>;
|
|
390
557
|
}
|
|
391
558
|
declare class DnsResource {
|
|
392
559
|
private req;
|
|
@@ -410,7 +577,12 @@ declare class DnsResource {
|
|
|
410
577
|
}
|
|
411
578
|
declare class AliasesResource {
|
|
412
579
|
private req;
|
|
413
|
-
|
|
580
|
+
private raw;
|
|
581
|
+
constructor(req: Req, raw: (path: string) => Promise<Response>);
|
|
582
|
+
/** Perfil de configuración de Apple Mail (plist) para el buzón de una máscara. */
|
|
583
|
+
appleProfile(domainId: string, alias: string): Promise<string>;
|
|
584
|
+
/** Exporta el buzón en formato mbox. Devuelve la respuesta en streaming: un buzón puede pesar GB. */
|
|
585
|
+
exportMbox(domainId: string, alias: string): Promise<Response>;
|
|
414
586
|
list(domainId: string): Promise<Alias[]>;
|
|
415
587
|
create(domainId: string, input: CreateAliasInput): Promise<AliasCreated>;
|
|
416
588
|
/** Crea un buzón IMAP para una máscara existente. La contraseña sólo se devuelve aquí. */
|
|
@@ -508,6 +680,105 @@ declare class ApiKeysResource {
|
|
|
508
680
|
ok: boolean;
|
|
509
681
|
}>;
|
|
510
682
|
}
|
|
683
|
+
declare class BillingResource {
|
|
684
|
+
private req;
|
|
685
|
+
constructor(req: Req);
|
|
686
|
+
status(): Promise<BillingStatus>;
|
|
687
|
+
addons(): Promise<AddonsResponse>;
|
|
688
|
+
/**
|
|
689
|
+
* Liga de MercadoPago para un add-on de un dominio (`domain` = activarlo, $99/mes).
|
|
690
|
+
* El usuario la abre y paga; hasta entonces no cambia nada.
|
|
691
|
+
*/
|
|
692
|
+
checkout(domainId: string, kind?: "domain" | "storage50" | "sends100", opts?: {
|
|
693
|
+
payerEmail?: string;
|
|
694
|
+
}): Promise<CheckoutLink>;
|
|
695
|
+
}
|
|
696
|
+
declare class RegistrationsResource {
|
|
697
|
+
private req;
|
|
698
|
+
constructor(req: Req);
|
|
699
|
+
search(domain: string): Promise<DomainSearchResult>;
|
|
700
|
+
tlds(): Promise<TldPrice[]>;
|
|
701
|
+
/** Crea el registro pendiente y devuelve la liga de pago; el dominio se registra al pagar. */
|
|
702
|
+
register(domain: string): Promise<DomainRegistrationCreated>;
|
|
703
|
+
list(): Promise<DomainRegistration[]>;
|
|
704
|
+
/** Pide el traslado a otro registrador. El código EPP llega por correo al dueño, nunca en la respuesta. */
|
|
705
|
+
transferOut(regId: string): Promise<{
|
|
706
|
+
ok: boolean;
|
|
707
|
+
aviso: string;
|
|
708
|
+
}>;
|
|
709
|
+
/** Liga de MercadoPago para la suscripción de renovación anual. */
|
|
710
|
+
renewal(regId: string, opts?: {
|
|
711
|
+
payerEmail?: string;
|
|
712
|
+
}): Promise<RenewalLink>;
|
|
713
|
+
}
|
|
714
|
+
declare class TransfersResource {
|
|
715
|
+
private req;
|
|
716
|
+
constructor(req: Req);
|
|
717
|
+
/** Requisitos, precio e inventario del DNS actual. No cobra ni crea nada. */
|
|
718
|
+
check(domain: string): Promise<TransferCheck>;
|
|
719
|
+
dns(regId: string): Promise<TransferDnsInventory>;
|
|
720
|
+
/** Reemplaza el inventario completo (RRSets). Vuelve a quedar pendiente de aprobar. */
|
|
721
|
+
setDns(regId: string, records: {
|
|
722
|
+
name: string;
|
|
723
|
+
type: string;
|
|
724
|
+
ttl?: number;
|
|
725
|
+
values: string[];
|
|
726
|
+
}[]): Promise<{
|
|
727
|
+
records: unknown[];
|
|
728
|
+
}>;
|
|
729
|
+
approveDns(regId: string): Promise<{
|
|
730
|
+
ok: boolean;
|
|
731
|
+
}>;
|
|
732
|
+
resendEmail(regId: string): Promise<{
|
|
733
|
+
ok: boolean;
|
|
734
|
+
}>;
|
|
735
|
+
}
|
|
736
|
+
declare class MembersResource {
|
|
737
|
+
private req;
|
|
738
|
+
constructor(req: Req);
|
|
739
|
+
list(domainId: string): Promise<{
|
|
740
|
+
members: DomainMember[];
|
|
741
|
+
invites: DomainInvite[];
|
|
742
|
+
}>;
|
|
743
|
+
invite(domainId: string, input: {
|
|
744
|
+
email: string;
|
|
745
|
+
name: string;
|
|
746
|
+
role?: "admin" | "agent";
|
|
747
|
+
}): Promise<{
|
|
748
|
+
ok: boolean;
|
|
749
|
+
inviteUrl: string;
|
|
750
|
+
}>;
|
|
751
|
+
remove(domainId: string, memberId: string): Promise<{
|
|
752
|
+
ok: boolean;
|
|
753
|
+
}>;
|
|
754
|
+
cancelInvite(domainId: string, token: string): Promise<{
|
|
755
|
+
ok: boolean;
|
|
756
|
+
}>;
|
|
757
|
+
}
|
|
758
|
+
declare class SignatureResource {
|
|
759
|
+
private req;
|
|
760
|
+
constructor(req: Req);
|
|
761
|
+
get(domainId: string): Promise<{
|
|
762
|
+
signature: string | null;
|
|
763
|
+
}>;
|
|
764
|
+
/** Markdown, máx. 2000 caracteres. Cadena vacía la borra. */
|
|
765
|
+
set(domainId: string, signature: string): Promise<{
|
|
766
|
+
ok: boolean;
|
|
767
|
+
signature: string | null;
|
|
768
|
+
}>;
|
|
769
|
+
}
|
|
770
|
+
declare class CannedResource {
|
|
771
|
+
private req;
|
|
772
|
+
constructor(req: Req);
|
|
773
|
+
list(domainId: string): Promise<CannedReply[]>;
|
|
774
|
+
create(domainId: string, input: {
|
|
775
|
+
title: string;
|
|
776
|
+
body: string;
|
|
777
|
+
}): Promise<CannedReply>;
|
|
778
|
+
delete(domainId: string, cannedId: string): Promise<{
|
|
779
|
+
ok: boolean;
|
|
780
|
+
}>;
|
|
781
|
+
}
|
|
511
782
|
|
|
512
783
|
interface WebhookSignatureHeaders {
|
|
513
784
|
/** Header `X-MailMask-Signature`, con forma `sha256=<hex>`. */
|
|
@@ -522,4 +793,4 @@ interface WebhookSignatureHeaders {
|
|
|
522
793
|
*/
|
|
523
794
|
declare function verifyWebhookSignature(secret: string, headers: WebhookSignatureHeaders, rawBody: string, toleranceMs?: number): Promise<boolean>;
|
|
524
795
|
|
|
525
|
-
export { type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BulkJob, type BulkJobCreated, type BulkSendInput, 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 DnsZoneCreated, type DnsZoneState, 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 };
|
|
796
|
+
export { 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 };
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,14 @@ async function request(baseUrl, apiKey, path, opts, doFetch = fetch) {
|
|
|
16
16
|
}
|
|
17
17
|
return res.json();
|
|
18
18
|
}
|
|
19
|
+
async function requestRaw(baseUrl, apiKey, path, doFetch = fetch) {
|
|
20
|
+
const res = await doFetch(`${baseUrl}${path}`, { headers: { "Authorization": `Bearer ${apiKey}` } });
|
|
21
|
+
if (!res.ok) {
|
|
22
|
+
const body = await res.json().catch(() => ({ error: res.statusText }));
|
|
23
|
+
throw new MailMaskError(res.status, body.error || res.statusText);
|
|
24
|
+
}
|
|
25
|
+
return res;
|
|
26
|
+
}
|
|
19
27
|
var MailMask = class {
|
|
20
28
|
constructor(config) {
|
|
21
29
|
this.apiKey = config.apiKey;
|
|
@@ -23,7 +31,7 @@ var MailMask = class {
|
|
|
23
31
|
const doFetch = config.fetch ? config.fetch : fetch;
|
|
24
32
|
const req = (path, opts) => request(this.baseUrl, this.apiKey, path, opts, doFetch);
|
|
25
33
|
this.domains = new DomainsResource(req);
|
|
26
|
-
this.aliases = new AliasesResource(req);
|
|
34
|
+
this.aliases = new AliasesResource(req, (path) => requestRaw(this.baseUrl, this.apiKey, path, doFetch));
|
|
27
35
|
this.rules = new RulesResource(req);
|
|
28
36
|
this.logs = new LogsResource(req);
|
|
29
37
|
this.send = new SendResource(req);
|
|
@@ -33,6 +41,12 @@ var MailMask = class {
|
|
|
33
41
|
this.smtp = new SmtpResource(req);
|
|
34
42
|
this.apiKeys = new ApiKeysResource(req);
|
|
35
43
|
this.dns = new DnsResource(req);
|
|
44
|
+
this.billing = new BillingResource(req);
|
|
45
|
+
this.registrations = new RegistrationsResource(req);
|
|
46
|
+
this.transfers = new TransfersResource(req);
|
|
47
|
+
this.members = new MembersResource(req);
|
|
48
|
+
this.signature = new SignatureResource(req);
|
|
49
|
+
this.canned = new CannedResource(req);
|
|
36
50
|
}
|
|
37
51
|
};
|
|
38
52
|
var DomainsResource = class {
|
|
@@ -57,6 +71,10 @@ var DomainsResource = class {
|
|
|
57
71
|
verify(id) {
|
|
58
72
|
return this.req(`/api/domains/${id}/verify`, { method: "POST" });
|
|
59
73
|
}
|
|
74
|
+
/** Registros a pegar en el registrador. Con `live` los compara con el DNS público y deduce el panel. */
|
|
75
|
+
dnsSetup(id, opts) {
|
|
76
|
+
return this.req(`/api/domains/${id}/dns-setup${opts?.live ? "?live=1" : ""}`);
|
|
77
|
+
}
|
|
60
78
|
};
|
|
61
79
|
var DnsResource = class {
|
|
62
80
|
constructor(req) {
|
|
@@ -86,8 +104,17 @@ var DnsResource = class {
|
|
|
86
104
|
}
|
|
87
105
|
};
|
|
88
106
|
var AliasesResource = class {
|
|
89
|
-
constructor(req) {
|
|
107
|
+
constructor(req, raw) {
|
|
90
108
|
this.req = req;
|
|
109
|
+
this.raw = raw;
|
|
110
|
+
}
|
|
111
|
+
/** Perfil de configuración de Apple Mail (plist) para el buzón de una máscara. */
|
|
112
|
+
async appleProfile(domainId, alias) {
|
|
113
|
+
return (await this.raw(`/api/domains/${domainId}/apple-profile?alias=${encodeURIComponent(alias)}`)).text();
|
|
114
|
+
}
|
|
115
|
+
/** Exporta el buzón en formato mbox. Devuelve la respuesta en streaming: un buzón puede pesar GB. */
|
|
116
|
+
exportMbox(domainId, alias) {
|
|
117
|
+
return this.raw(`/api/domains/${domainId}/alias/${alias}/mailbox/export`);
|
|
91
118
|
}
|
|
92
119
|
list(domainId) {
|
|
93
120
|
return this.req(`/api/domains/${domainId}/alias`);
|
|
@@ -235,6 +262,116 @@ var ApiKeysResource = class {
|
|
|
235
262
|
return this.req(`/api/api-keys/${id}`, { method: "DELETE" });
|
|
236
263
|
}
|
|
237
264
|
};
|
|
265
|
+
var BillingResource = class {
|
|
266
|
+
constructor(req) {
|
|
267
|
+
this.req = req;
|
|
268
|
+
}
|
|
269
|
+
status() {
|
|
270
|
+
return this.req("/api/billing/status");
|
|
271
|
+
}
|
|
272
|
+
addons() {
|
|
273
|
+
return this.req("/api/addons");
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Liga de MercadoPago para un add-on de un dominio (`domain` = activarlo, $99/mes).
|
|
277
|
+
* El usuario la abre y paga; hasta entonces no cambia nada.
|
|
278
|
+
*/
|
|
279
|
+
checkout(domainId, kind = "domain", opts) {
|
|
280
|
+
return this.req("/api/addons/checkout", { method: "POST", body: JSON.stringify({ kind, domainId, payerEmail: opts?.payerEmail }) });
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
var RegistrationsResource = class {
|
|
284
|
+
constructor(req) {
|
|
285
|
+
this.req = req;
|
|
286
|
+
}
|
|
287
|
+
search(domain) {
|
|
288
|
+
return this.req(`/api/domains/search?q=${encodeURIComponent(domain)}`);
|
|
289
|
+
}
|
|
290
|
+
tlds() {
|
|
291
|
+
return this.req("/api/domains/tlds");
|
|
292
|
+
}
|
|
293
|
+
/** Crea el registro pendiente y devuelve la liga de pago; el dominio se registra al pagar. */
|
|
294
|
+
register(domain) {
|
|
295
|
+
return this.req("/api/domains/register", { method: "POST", body: JSON.stringify({ domain }) });
|
|
296
|
+
}
|
|
297
|
+
list() {
|
|
298
|
+
return this.req("/api/domains/registrations");
|
|
299
|
+
}
|
|
300
|
+
/** Pide el traslado a otro registrador. El código EPP llega por correo al dueño, nunca en la respuesta. */
|
|
301
|
+
transferOut(regId) {
|
|
302
|
+
return this.req(`/api/domains/registrations/${regId}/transfer-out`, { method: "POST" });
|
|
303
|
+
}
|
|
304
|
+
/** Liga de MercadoPago para la suscripción de renovación anual. */
|
|
305
|
+
renewal(regId, opts) {
|
|
306
|
+
return this.req(`/api/domains/registrations/${regId}/renewal`, { method: "POST", body: JSON.stringify({ payerEmail: opts?.payerEmail }) });
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
var TransfersResource = class {
|
|
310
|
+
constructor(req) {
|
|
311
|
+
this.req = req;
|
|
312
|
+
}
|
|
313
|
+
/** Requisitos, precio e inventario del DNS actual. No cobra ni crea nada. */
|
|
314
|
+
check(domain) {
|
|
315
|
+
return this.req("/api/domains/transfer/check", { method: "POST", body: JSON.stringify({ domain }) });
|
|
316
|
+
}
|
|
317
|
+
dns(regId) {
|
|
318
|
+
return this.req(`/api/domains/transfer/${regId}/dns`);
|
|
319
|
+
}
|
|
320
|
+
/** Reemplaza el inventario completo (RRSets). Vuelve a quedar pendiente de aprobar. */
|
|
321
|
+
setDns(regId, records) {
|
|
322
|
+
return this.req(`/api/domains/transfer/${regId}/dns`, { method: "PUT", body: JSON.stringify({ records }) });
|
|
323
|
+
}
|
|
324
|
+
approveDns(regId) {
|
|
325
|
+
return this.req(`/api/domains/transfer/${regId}/dns/approve`, { method: "POST" });
|
|
326
|
+
}
|
|
327
|
+
resendEmail(regId) {
|
|
328
|
+
return this.req(`/api/domains/transfer/${regId}/resend-email`, { method: "POST" });
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
var MembersResource = class {
|
|
332
|
+
constructor(req) {
|
|
333
|
+
this.req = req;
|
|
334
|
+
}
|
|
335
|
+
list(domainId) {
|
|
336
|
+
return this.req(`/api/domains/${domainId}/agents`);
|
|
337
|
+
}
|
|
338
|
+
invite(domainId, input) {
|
|
339
|
+
return this.req(`/api/domains/${domainId}/agents/invite`, { method: "POST", body: JSON.stringify(input) });
|
|
340
|
+
}
|
|
341
|
+
remove(domainId, memberId) {
|
|
342
|
+
return this.req(`/api/domains/${domainId}/agents/${memberId}`, { method: "DELETE" });
|
|
343
|
+
}
|
|
344
|
+
cancelInvite(domainId, token) {
|
|
345
|
+
return this.req(`/api/domains/${domainId}/agents/invites/${token}`, { method: "DELETE" });
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
var SignatureResource = class {
|
|
349
|
+
constructor(req) {
|
|
350
|
+
this.req = req;
|
|
351
|
+
}
|
|
352
|
+
async get(domainId) {
|
|
353
|
+
const d = await this.req(`/api/domains/${domainId}`);
|
|
354
|
+
return { signature: d.signature ?? null };
|
|
355
|
+
}
|
|
356
|
+
/** Markdown, máx. 2000 caracteres. Cadena vacía la borra. */
|
|
357
|
+
set(domainId, signature) {
|
|
358
|
+
return this.req(`/api/domains/${domainId}/signature`, { method: "PUT", body: JSON.stringify({ signature }) });
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
var CannedResource = class {
|
|
362
|
+
constructor(req) {
|
|
363
|
+
this.req = req;
|
|
364
|
+
}
|
|
365
|
+
list(domainId) {
|
|
366
|
+
return this.req(`/api/domains/${domainId}/canned`);
|
|
367
|
+
}
|
|
368
|
+
create(domainId, input) {
|
|
369
|
+
return this.req(`/api/domains/${domainId}/canned`, { method: "POST", body: JSON.stringify(input) });
|
|
370
|
+
}
|
|
371
|
+
delete(domainId, cannedId) {
|
|
372
|
+
return this.req(`/api/domains/${domainId}/canned/${cannedId}`, { method: "DELETE" });
|
|
373
|
+
}
|
|
374
|
+
};
|
|
238
375
|
|
|
239
376
|
// src/verify.ts
|
|
240
377
|
function hex(buf) {
|