@pantechdynamic/sdk 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +152 -5
- package/dist/index.cjs +796 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17976 -7911
- package/dist/index.d.ts +17976 -7911
- package/dist/index.js +788 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37,6 +37,23 @@ var AuthenticationError = class extends PantechError {
|
|
|
37
37
|
};
|
|
38
38
|
var PaymentRequiredError = class extends PantechError {
|
|
39
39
|
name = "PaymentRequiredError";
|
|
40
|
+
/**
|
|
41
|
+
* For a domain order waiting in `awaiting_payment`: the page where the bank
|
|
42
|
+
* asks the user to confirm the saved-card payment (US dollars only), when it
|
|
43
|
+
* does. Undefined when no confirmation is needed, for a naira order waiting
|
|
44
|
+
* for credit, and for a `402` answer.
|
|
45
|
+
*/
|
|
46
|
+
paymentUrl;
|
|
47
|
+
/** When an unpaid order fails `insufficient_credit` (nothing is charged). */
|
|
48
|
+
paymentExpiresAt;
|
|
49
|
+
/** The order waiting for payment, as the API returned it. */
|
|
50
|
+
order;
|
|
51
|
+
constructor(message, init = {}) {
|
|
52
|
+
super(message, init);
|
|
53
|
+
this.paymentUrl = init.paymentUrl;
|
|
54
|
+
this.paymentExpiresAt = init.paymentExpiresAt;
|
|
55
|
+
this.order = init.order;
|
|
56
|
+
}
|
|
40
57
|
};
|
|
41
58
|
var PermissionDeniedError = class extends PantechError {
|
|
42
59
|
name = "PermissionDeniedError";
|
|
@@ -47,6 +64,9 @@ var NotFoundError = class extends PantechError {
|
|
|
47
64
|
var ConflictError = class extends PantechError {
|
|
48
65
|
name = "ConflictError";
|
|
49
66
|
};
|
|
67
|
+
var PreconditionFailedError = class extends PantechError {
|
|
68
|
+
name = "PreconditionFailedError";
|
|
69
|
+
};
|
|
50
70
|
var ValidationError = class extends PantechError {
|
|
51
71
|
name = "ValidationError";
|
|
52
72
|
};
|
|
@@ -98,12 +118,115 @@ var CloudFailedError = class extends PantechError {
|
|
|
98
118
|
this.resource = resource;
|
|
99
119
|
}
|
|
100
120
|
};
|
|
121
|
+
var DNSFailedError = class extends PantechError {
|
|
122
|
+
name = "DNSFailedError";
|
|
123
|
+
/** `zone` or `record`. */
|
|
124
|
+
kind;
|
|
125
|
+
/** The zone or record set, as the API returned it. */
|
|
126
|
+
resource;
|
|
127
|
+
constructor(message, kind, resource, init = {}) {
|
|
128
|
+
super(message, init);
|
|
129
|
+
this.kind = kind;
|
|
130
|
+
this.resource = resource;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var CertificateFailedError = class extends PantechError {
|
|
134
|
+
name = "CertificateFailedError";
|
|
135
|
+
/** The certificate, as the API returned it. */
|
|
136
|
+
certificate;
|
|
137
|
+
constructor(message, certificate, init = {}) {
|
|
138
|
+
super(message, init);
|
|
139
|
+
this.certificate = certificate;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
101
142
|
var WaitTimeoutError = class extends PantechError {
|
|
102
143
|
name = "WaitTimeoutError";
|
|
103
144
|
};
|
|
104
145
|
var WebhookVerificationError = class extends PantechError {
|
|
105
146
|
name = "WebhookVerificationError";
|
|
106
147
|
};
|
|
148
|
+
var DNS_ERROR_CODES = [
|
|
149
|
+
"DNS_UNAVAILABLE",
|
|
150
|
+
"DNS_ZONE_NOT_FOUND",
|
|
151
|
+
"DNS_RECORD_NOT_FOUND",
|
|
152
|
+
"DNS_ZONE_LIMIT_REACHED",
|
|
153
|
+
"DNS_ZONE_CREATE_LIMIT_REACHED",
|
|
154
|
+
"DNS_RECORD_LIMIT_REACHED",
|
|
155
|
+
"DNS_ZONE_NAME_TAKEN",
|
|
156
|
+
"DNS_ZONE_ACTIVE_ELSEWHERE",
|
|
157
|
+
"DNS_RECORD_EXISTS",
|
|
158
|
+
"DNS_CNAME_CONFLICT",
|
|
159
|
+
"DNS_RECORD_READ_ONLY",
|
|
160
|
+
"DNS_ZONE_SUSPENDED",
|
|
161
|
+
"DNS_ZONE_NOT_WRITABLE",
|
|
162
|
+
"DNS_ZONE_IN_USE_BY_DOMAIN",
|
|
163
|
+
"VERSION_CONFLICT",
|
|
164
|
+
"TOO_MANY_CHANGES",
|
|
165
|
+
"INVALID_ZONE_FILE"
|
|
166
|
+
];
|
|
167
|
+
var DOMAIN_ERROR_CODES = [
|
|
168
|
+
"DOMAINS_UNAVAILABLE",
|
|
169
|
+
"DOMAIN_NOT_FOUND",
|
|
170
|
+
"DOMAIN_ORDER_NOT_FOUND",
|
|
171
|
+
"DOMAIN_LOOKUP_UNAVAILABLE",
|
|
172
|
+
"TLD_NOT_SOLD",
|
|
173
|
+
"DOMAIN_NOT_AVAILABLE",
|
|
174
|
+
"DOMAIN_NOT_TRANSFERABLE",
|
|
175
|
+
"DOMAIN_ALREADY_HELD",
|
|
176
|
+
"DOMAIN_ORDER_IN_FLIGHT",
|
|
177
|
+
"DOMAIN_ORDER_NOT_AWAITING_PAYMENT",
|
|
178
|
+
"DOMAIN_ORDER_LIMIT_REACHED",
|
|
179
|
+
"DOMAIN_NOT_CONFIGURABLE",
|
|
180
|
+
"DOMAIN_LOCKED",
|
|
181
|
+
"DOMAIN_ZONE_MISMATCH"
|
|
182
|
+
];
|
|
183
|
+
var REGISTRY_ERROR_CODES = [
|
|
184
|
+
"REGISTRY_UNAVAILABLE",
|
|
185
|
+
"REGISTRY_NAMESPACE_NOT_SET",
|
|
186
|
+
"REGISTRY_NAMESPACE_TAKEN",
|
|
187
|
+
"REGISTRY_NAMESPACE_LOCKED",
|
|
188
|
+
"INVALID_REGISTRY_NAMESPACE",
|
|
189
|
+
"INVALID_REPOSITORY_NAME",
|
|
190
|
+
"REPOSITORY_NOT_FOUND",
|
|
191
|
+
"TAG_NOT_FOUND",
|
|
192
|
+
"REGISTRY_TOKEN_NOT_FOUND",
|
|
193
|
+
"REPOSITORY_EXISTS",
|
|
194
|
+
"REPOSITORY_LIMIT_REACHED",
|
|
195
|
+
"REGISTRY_STORAGE_LIMIT_REACHED",
|
|
196
|
+
"REGISTRY_TOKEN_LIMIT_REACHED",
|
|
197
|
+
"TAG_IMMUTABLE",
|
|
198
|
+
"REPOSITORY_SUSPENDED"
|
|
199
|
+
];
|
|
200
|
+
var IAM_ERROR_CODES = [
|
|
201
|
+
"ACCESS_DENIED",
|
|
202
|
+
"IAM_TEAM_NOT_FOUND",
|
|
203
|
+
"IAM_POLICY_NOT_FOUND",
|
|
204
|
+
"IAM_ATTACHMENT_NOT_FOUND",
|
|
205
|
+
"IAM_TEAM_NAME_TAKEN",
|
|
206
|
+
"IAM_POLICY_NAME_TAKEN",
|
|
207
|
+
"IAM_TEAM_LIMIT_REACHED",
|
|
208
|
+
"IAM_POLICY_LIMIT_REACHED",
|
|
209
|
+
"IAM_ATTACHMENT_LIMIT_REACHED",
|
|
210
|
+
"IAM_MANAGED_POLICY",
|
|
211
|
+
"IAM_ADMIN_TARGET",
|
|
212
|
+
"INVALID_POLICY",
|
|
213
|
+
"VERSION_CONFLICT"
|
|
214
|
+
];
|
|
215
|
+
var CERTIFICATE_ERROR_CODES = [
|
|
216
|
+
"CERTIFICATES_UNAVAILABLE",
|
|
217
|
+
"CERTIFICATE_NOT_FOUND",
|
|
218
|
+
"CERTIFICATE_LIMIT_REACHED",
|
|
219
|
+
"CERTIFICATE_REQUEST_LIMIT_REACHED",
|
|
220
|
+
"CERTIFICATE_RATE_LIMITED",
|
|
221
|
+
"CERTIFICATE_IN_USE",
|
|
222
|
+
"CERTIFICATE_NOT_EXPORTABLE",
|
|
223
|
+
"CERTIFICATE_NOT_ISSUED",
|
|
224
|
+
"CERTIFICATE_NOT_REVOCABLE",
|
|
225
|
+
"CERTIFICATE_NOT_IMPORTED",
|
|
226
|
+
"CERTIFICATE_NOT_PENDING",
|
|
227
|
+
"CERTIFICATE_NAMES_MISMATCH",
|
|
228
|
+
"CONFLICT"
|
|
229
|
+
];
|
|
107
230
|
function isPantechError(err, code) {
|
|
108
231
|
return err instanceof PantechError && (code === void 0 || err.code === code);
|
|
109
232
|
}
|
|
@@ -115,6 +238,7 @@ var STATUS_TEXT = {
|
|
|
115
238
|
404: "Not found",
|
|
116
239
|
405: "Method not allowed",
|
|
117
240
|
409: "Conflict",
|
|
241
|
+
412: "Precondition failed",
|
|
118
242
|
413: "Request too large",
|
|
119
243
|
415: "Unsupported media type",
|
|
120
244
|
422: "Validation failed",
|
|
@@ -173,6 +297,8 @@ function errorFromResponse(status, headers, bodyText, retryAfterSeconds) {
|
|
|
173
297
|
return new NotFoundError(message, init);
|
|
174
298
|
case status === 409:
|
|
175
299
|
return new ConflictError(message, init);
|
|
300
|
+
case status === 412:
|
|
301
|
+
return new PreconditionFailedError(message, init);
|
|
176
302
|
case status === 422:
|
|
177
303
|
return new ValidationError(message, init);
|
|
178
304
|
case status === 429:
|
|
@@ -199,6 +325,26 @@ async function* paginate(fetchPage, startCursor) {
|
|
|
199
325
|
}
|
|
200
326
|
|
|
201
327
|
// src/resource.ts
|
|
328
|
+
var SECRET_FIELDS = ["secret", "private_key_pem"];
|
|
329
|
+
function hideSecrets(value) {
|
|
330
|
+
if (value && typeof value === "object") {
|
|
331
|
+
for (const field of SECRET_FIELDS) {
|
|
332
|
+
if (Object.hasOwn(value, field)) {
|
|
333
|
+
const secret = value[field];
|
|
334
|
+
Object.defineProperty(value, field, { value: secret, enumerable: false, writable: false, configurable: true });
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return value;
|
|
339
|
+
}
|
|
340
|
+
function withIfMatch(options) {
|
|
341
|
+
if (options?.ifMatch === void 0) return options;
|
|
342
|
+
const { ifMatch, ...rest } = options;
|
|
343
|
+
if (!Number.isInteger(ifMatch) || ifMatch < 0) {
|
|
344
|
+
throw new TypeError("ifMatch must be the version you read: a whole number, 0 or more.");
|
|
345
|
+
}
|
|
346
|
+
return { ...rest, headers: { ...rest.headers, "If-Match": String(ifMatch) } };
|
|
347
|
+
}
|
|
202
348
|
var APIResource = class {
|
|
203
349
|
_client;
|
|
204
350
|
constructor(client) {
|
|
@@ -269,13 +415,13 @@ function sleep(ms, signal) {
|
|
|
269
415
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
270
416
|
});
|
|
271
417
|
}
|
|
272
|
-
function path(
|
|
273
|
-
let out =
|
|
418
|
+
function path(strings2, ...ids) {
|
|
419
|
+
let out = strings2[0] ?? "";
|
|
274
420
|
ids.forEach((id, i) => {
|
|
275
421
|
if (typeof id !== "string" || id === "") {
|
|
276
422
|
throw new PantechError("A resource id is required, and it must be a non-empty string.");
|
|
277
423
|
}
|
|
278
|
-
out += encodeURIComponent(id) + (
|
|
424
|
+
out += encodeURIComponent(id) + (strings2[i + 1] ?? "");
|
|
279
425
|
});
|
|
280
426
|
return out;
|
|
281
427
|
}
|
|
@@ -395,6 +541,87 @@ async function poll(read, done, what, options = {}) {
|
|
|
395
541
|
}
|
|
396
542
|
}
|
|
397
543
|
|
|
544
|
+
// src/resources/certificates.ts
|
|
545
|
+
var ISSUE_WAIT_MS = 10 * 6e4;
|
|
546
|
+
var READY = /* @__PURE__ */ new Set(["issued", "renewing"]);
|
|
547
|
+
var FINISHED = /* @__PURE__ */ new Set(["failed", "revoked", "expired"]);
|
|
548
|
+
var Certificates = class extends APIResource {
|
|
549
|
+
/** One page of your certificates, newest first. Filter with `q` (any name), `status` or `kind`. */
|
|
550
|
+
list(params = {}, options) {
|
|
551
|
+
return this._get("/certificates", params, options);
|
|
552
|
+
}
|
|
553
|
+
listAll(params = {}, options) {
|
|
554
|
+
return this._listAll("/certificates", params, options);
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Requests a certificate for 1 to 100 names. Names in your Pantech DNS
|
|
558
|
+
* zones are validated for you; for the others add each `validations[]`
|
|
559
|
+
* CNAME once. Follow it with `wait`.
|
|
560
|
+
*/
|
|
561
|
+
request(body, options) {
|
|
562
|
+
return this._post("/certificates", body, options);
|
|
563
|
+
}
|
|
564
|
+
/** Imports a certificate and its private key. An expired or mismatched one is refused. */
|
|
565
|
+
import(body, options) {
|
|
566
|
+
return this._post("/certificates/import", body, options);
|
|
567
|
+
}
|
|
568
|
+
get(certificateId, options) {
|
|
569
|
+
return this._get(path`/certificates/${certificateId}`, void 0, options);
|
|
570
|
+
}
|
|
571
|
+
update(certificateId, body, options) {
|
|
572
|
+
return this._patch(path`/certificates/${certificateId}`, body, options);
|
|
573
|
+
}
|
|
574
|
+
/** Checks the CNAMEs of a certificate waiting for validation within seconds. */
|
|
575
|
+
verify(certificateId, options) {
|
|
576
|
+
return this._post(path`/certificates/${certificateId}/verify`, void 0, options);
|
|
577
|
+
}
|
|
578
|
+
/** Replaces an imported certificate with a new one for the same names. */
|
|
579
|
+
reimport(certificateId, body, options) {
|
|
580
|
+
return this._post(path`/certificates/${certificateId}/reimport`, body, options);
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* The certificate, its chain and its private key, for a certificate created
|
|
584
|
+
* with `exportable: true`. Needs the `delete` scope; every owner and admin is
|
|
585
|
+
* emailed. `private_key_pem` is non-enumerable: read it explicitly.
|
|
586
|
+
*/
|
|
587
|
+
async export(certificateId, options) {
|
|
588
|
+
return hideSecrets(
|
|
589
|
+
await this._post(path`/certificates/${certificateId}/export`, void 0, options)
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
/** Asks the CA to revoke it (`reason`: `unspecified` or `key_compromise`). Refused while it is in use. */
|
|
593
|
+
revoke(certificateId, body = {}, options) {
|
|
594
|
+
return this._post(path`/certificates/${certificateId}/revoke`, body, options);
|
|
595
|
+
}
|
|
596
|
+
/** Deletes it. Refused while a Pantech service uses it. */
|
|
597
|
+
delete(certificateId, options) {
|
|
598
|
+
return this._delete(path`/certificates/${certificateId}`, options);
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Polls the certificate until it is `issued` (resolves with it) or it
|
|
602
|
+
* `failed`, was revoked or expired (rejects with CertificateFailedError).
|
|
603
|
+
* Default timeout 10 minutes, polling every 5 seconds; a name validated by
|
|
604
|
+
* CNAME waits until you add it, up to 72 hours, so pass a longer `timeoutMs`.
|
|
605
|
+
*/
|
|
606
|
+
wait(certificateId, options = {}) {
|
|
607
|
+
return poll(
|
|
608
|
+
() => this.get(certificateId, { signal: options.signal }),
|
|
609
|
+
(c) => {
|
|
610
|
+
if (FINISHED.has(c.status)) {
|
|
611
|
+
const code = c.failure_code ?? c.status;
|
|
612
|
+
const detail = code === c.status ? "" : ` (${code})`;
|
|
613
|
+
throw new CertificateFailedError(`Certificate ${c.id} (${c.names[0] ?? ""}) is ${c.status}${detail}.`, c, {
|
|
614
|
+
code
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
return READY.has(c.status);
|
|
618
|
+
},
|
|
619
|
+
`Certificate ${certificateId}`,
|
|
620
|
+
{ timeoutMs: ISSUE_WAIT_MS, pollIntervalMs: 5e3, ...options }
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
|
|
398
625
|
// src/orders.ts
|
|
399
626
|
var orderId = (ref) => typeof ref === "string" ? ref : ref.order_id;
|
|
400
627
|
async function waitForOrder(client, read, what, options = {}) {
|
|
@@ -512,6 +739,403 @@ var DatabaseOrders = class extends APIResource {
|
|
|
512
739
|
}
|
|
513
740
|
};
|
|
514
741
|
|
|
742
|
+
// src/resources/dns.ts
|
|
743
|
+
var RECORD_WAIT_MS = 5 * 6e4;
|
|
744
|
+
var ZONE_WAIT_MS = 5 * 6e4;
|
|
745
|
+
var DNS = class extends APIResource {
|
|
746
|
+
/** Hosted zones, with the name servers to delegate your domain to. */
|
|
747
|
+
zones = new DNSZones(this._client);
|
|
748
|
+
/** Record sets of a zone: one name and type each, with a TTL and values. */
|
|
749
|
+
records = new DNSRecords(this._client);
|
|
750
|
+
};
|
|
751
|
+
var DNSZones = class extends APIResource {
|
|
752
|
+
/** One page of your zones, newest first. Filter with `q` (name contains) or `status`. */
|
|
753
|
+
list(params = {}, options) {
|
|
754
|
+
return this._get("/dns/zones", params, options);
|
|
755
|
+
}
|
|
756
|
+
listAll(params = {}, options) {
|
|
757
|
+
return this._listAll("/dns/zones", params, options);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Hosts a zone. It is `pending`, then `awaiting_delegation` with its own
|
|
761
|
+
* two `name_servers` to set at your registrar, then `active` once the
|
|
762
|
+
* registry delegates to exactly those. Undelegated for 14 days, it is
|
|
763
|
+
* removed. The first 5 zones are free: see `quote`.
|
|
764
|
+
*/
|
|
765
|
+
create(body, options) {
|
|
766
|
+
return this._post("/dns/zones", body, options);
|
|
767
|
+
}
|
|
768
|
+
/** The free zone allowance, and the monthly price of each further zone in your currency (before VAT). */
|
|
769
|
+
quote(options) {
|
|
770
|
+
return this._get("/dns/zones/quote", void 0, options);
|
|
771
|
+
}
|
|
772
|
+
get(zoneId, options) {
|
|
773
|
+
return this._get(path`/dns/zones/${zoneId}`, void 0, options);
|
|
774
|
+
}
|
|
775
|
+
/** Changes the zone's description. */
|
|
776
|
+
update(zoneId, body, options) {
|
|
777
|
+
return this._patch(path`/dns/zones/${zoneId}`, body, options);
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Stops answering for the zone at once and removes its records. Refused
|
|
781
|
+
* with `DNS_ZONE_IN_USE_BY_DOMAIN` while a Pantech domain delegates to it.
|
|
782
|
+
*/
|
|
783
|
+
delete(zoneId, options) {
|
|
784
|
+
return this._delete(path`/dns/zones/${zoneId}`, options);
|
|
785
|
+
}
|
|
786
|
+
/** Checks the zone's delegation within seconds instead of at the next scheduled check. */
|
|
787
|
+
verify(zoneId, options) {
|
|
788
|
+
return this._post(path`/dns/zones/${zoneId}/verify`, void 0, options);
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Polls a new zone until it has its name servers: `awaiting_delegation`
|
|
792
|
+
* (set them at your registrar) or `active`. Rejects with DNSFailedError if
|
|
793
|
+
* it fails or is being deleted. Default timeout 5 minutes, polling every 3
|
|
794
|
+
* seconds. It does not wait for delegation, which is up to your registrar.
|
|
795
|
+
*/
|
|
796
|
+
wait(zoneId, options = {}) {
|
|
797
|
+
return poll(
|
|
798
|
+
() => this.get(zoneId, { signal: options.signal }),
|
|
799
|
+
(z) => {
|
|
800
|
+
if (z.status === "failed" || z.status === "deleting" || z.status === "deleted") {
|
|
801
|
+
const code = z.failure_code ?? z.status;
|
|
802
|
+
throw new DNSFailedError(`DNS zone ${z.id} (${z.name}) is ${z.status} (${code}).`, "zone", z, { code });
|
|
803
|
+
}
|
|
804
|
+
return z.status === "awaiting_delegation" || z.status === "active";
|
|
805
|
+
},
|
|
806
|
+
`DNS zone ${zoneId}`,
|
|
807
|
+
{ timeoutMs: ZONE_WAIT_MS, pollIntervalMs: 3e3, ...options }
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
/** The zone's record sets as a BIND zone file. */
|
|
811
|
+
exportZoneFile(zoneId, options) {
|
|
812
|
+
return this._request("GET", path`/dns/zones/${zoneId}/export`, { responseType: "text" }, options);
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Creates and updates record sets from a BIND zone file (at most 1000
|
|
816
|
+
* changes). With `replace: true`, record sets the file lacks are deleted too.
|
|
817
|
+
*/
|
|
818
|
+
importZoneFile(zoneId, body, options) {
|
|
819
|
+
return this._post(path`/dns/zones/${zoneId}/import`, body, options);
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
var DNSRecords = class extends APIResource {
|
|
823
|
+
/** One page of a zone's record sets, by name then type. Filter with `name`, `q` or `type`. */
|
|
824
|
+
list(zoneId, params = {}, options) {
|
|
825
|
+
return this._get(path`/dns/zones/${zoneId}/records`, params, options);
|
|
826
|
+
}
|
|
827
|
+
listAll(zoneId, params = {}, options) {
|
|
828
|
+
return this._listAll(path`/dns/zones/${zoneId}/records`, params, options);
|
|
829
|
+
}
|
|
830
|
+
/** Adds a record set, `pending` until it answers. Follow it with `wait`. */
|
|
831
|
+
create(zoneId, body, options) {
|
|
832
|
+
return this._post(path`/dns/zones/${zoneId}/records`, body, options);
|
|
833
|
+
}
|
|
834
|
+
get(zoneId, recordId, options) {
|
|
835
|
+
return this._get(path`/dns/zones/${zoneId}/records/${recordId}`, void 0, options);
|
|
836
|
+
}
|
|
837
|
+
/** Changes the TTL, values or comment. Pass `{ ifMatch: record.version }` to refuse a lost update. */
|
|
838
|
+
update(zoneId, recordId, body, options) {
|
|
839
|
+
return this._patch(path`/dns/zones/${zoneId}/records/${recordId}`, body, withIfMatch(options));
|
|
840
|
+
}
|
|
841
|
+
/** Removes the record set. Pass `{ ifMatch: record.version }` to refuse it if the record changed. */
|
|
842
|
+
delete(zoneId, recordId, options) {
|
|
843
|
+
return this._delete(path`/dns/zones/${zoneId}/records/${recordId}`, withIfMatch(options));
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Up to 1000 creates, updates and deletes, all or nothing. A change's
|
|
847
|
+
* `version` refuses it with `412 VERSION_CONFLICT` if the record moved on.
|
|
848
|
+
*/
|
|
849
|
+
batch(zoneId, body, options) {
|
|
850
|
+
return this._post(path`/dns/zones/${zoneId}/records/batch`, body, options);
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Polls the record set until it is `active` (resolves with it) or its
|
|
854
|
+
* change failed (rejects with DNSFailedError). Default timeout 5
|
|
855
|
+
* minutes, polling every 3 seconds.
|
|
856
|
+
*/
|
|
857
|
+
wait(zoneId, recordId, options = {}) {
|
|
858
|
+
return poll(
|
|
859
|
+
() => this.get(zoneId, recordId, { signal: options.signal }),
|
|
860
|
+
(r) => {
|
|
861
|
+
if (r.status === "failed") {
|
|
862
|
+
const code = r.failure_code ?? void 0;
|
|
863
|
+
throw new DNSFailedError(
|
|
864
|
+
`DNS record ${r.id} (${r.fqdn} ${r.type}) failed${code ? ` (${code})` : ""}. The previous values still answer.`,
|
|
865
|
+
"record",
|
|
866
|
+
r,
|
|
867
|
+
{ code }
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
return r.status === "active";
|
|
871
|
+
},
|
|
872
|
+
`DNS record ${recordId}`,
|
|
873
|
+
{ timeoutMs: RECORD_WAIT_MS, pollIntervalMs: 3e3, ...options }
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
// src/resources/domains.ts
|
|
879
|
+
var ORDER_WAIT_MS = 15 * 6e4;
|
|
880
|
+
var domainOrderId = (ref) => typeof ref === "string" ? ref : ref.order.id;
|
|
881
|
+
var Domains = class extends APIResource {
|
|
882
|
+
/** Registrations, renewals and transfers. */
|
|
883
|
+
orders = new DomainOrders(this._client);
|
|
884
|
+
/** Every TLD for sale to your organization, priced per year in minor units of its currency. */
|
|
885
|
+
listTlds(options) {
|
|
886
|
+
return this._get("/domains/tlds", void 0, options);
|
|
887
|
+
}
|
|
888
|
+
/** Checks a name across the TLDs for sale, plus suggestions, each with its price. */
|
|
889
|
+
search(params, options) {
|
|
890
|
+
return this._get("/domains/search", params, options);
|
|
891
|
+
}
|
|
892
|
+
/** Whether the registry lets the domain move to Pantech now, and what it costs. */
|
|
893
|
+
checkTransfer(params, options) {
|
|
894
|
+
return this._get("/domains/transfer-check", params, options);
|
|
895
|
+
}
|
|
896
|
+
list(params = {}, options) {
|
|
897
|
+
return this._get("/domains", params, options);
|
|
898
|
+
}
|
|
899
|
+
listAll(params = {}, options) {
|
|
900
|
+
return this._listAll("/domains", params, options);
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Buys the domain for `years` (1 to 10), paid from your credit first; a
|
|
904
|
+
* failed order is refunded. `accept_terms` must be true. Follow the order
|
|
905
|
+
* with `orders.wait(result)`.
|
|
906
|
+
*/
|
|
907
|
+
register(body, options) {
|
|
908
|
+
return this._post("/domains", body, options);
|
|
909
|
+
}
|
|
910
|
+
/** Moves a domain to Pantech with its auth code, adding `years` to its term. Follow it with `orders.wait`. */
|
|
911
|
+
transfer(body, options) {
|
|
912
|
+
return this._post("/domains/transfers", body, options);
|
|
913
|
+
}
|
|
914
|
+
get(domainId, options) {
|
|
915
|
+
return this._get(path`/domains/${domainId}`, void 0, options);
|
|
916
|
+
}
|
|
917
|
+
/** Turns auto-renew, the transfer lock or privacy on or off. */
|
|
918
|
+
update(domainId, body, options) {
|
|
919
|
+
return this._patch(path`/domains/${domainId}`, body, options);
|
|
920
|
+
}
|
|
921
|
+
/** Points the domain at its Pantech DNS zone, or at up to 6 custom name servers. */
|
|
922
|
+
setNameServers(domainId, body, options) {
|
|
923
|
+
return this._put(path`/domains/${domainId}/name-servers`, body, options);
|
|
924
|
+
}
|
|
925
|
+
/** The registrant contact. Owners and admins only. */
|
|
926
|
+
getContact(domainId, options) {
|
|
927
|
+
return this._get(path`/domains/${domainId}/contact`, void 0, options);
|
|
928
|
+
}
|
|
929
|
+
/** Replaces the registrant contact; applied at the registry in the background. */
|
|
930
|
+
updateContact(domainId, body, options) {
|
|
931
|
+
return this._put(path`/domains/${domainId}/contact`, body, options);
|
|
932
|
+
}
|
|
933
|
+
/** Adds `years` (default 1) to the domain's term, paid from your credit first. */
|
|
934
|
+
renew(domainId, body = {}, options) {
|
|
935
|
+
return this._post(path`/domains/${domainId}/renew`, body, options);
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Asks for the code that moves the domain to another registrar. Needs the
|
|
939
|
+
* `delete` scope, and the transfer lock off. Read it with `getAuthCode`.
|
|
940
|
+
*/
|
|
941
|
+
requestAuthCode(domainId, options) {
|
|
942
|
+
return this._post(path`/domains/${domainId}/auth-code`, void 0, options);
|
|
943
|
+
}
|
|
944
|
+
/** The auth code once it has arrived, or `{ status: "pending" }` while it is on its way. */
|
|
945
|
+
getAuthCode(domainId, options) {
|
|
946
|
+
return this._get(path`/domains/${domainId}/auth-code`, void 0, options);
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
var DomainOrders = class extends APIResource {
|
|
950
|
+
/** A domain's registrations, renewals and transfers, newest first. */
|
|
951
|
+
list(domainId, options) {
|
|
952
|
+
return this._get(path`/domains/${domainId}/orders`, void 0, options);
|
|
953
|
+
}
|
|
954
|
+
get(orderId2, options) {
|
|
955
|
+
return this._get(path`/domain-orders/${orderId2}`, void 0, options);
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Makes an order waiting in `awaiting_payment` try its payment again now,
|
|
959
|
+
* and wait another hour: in US dollars the saved card is charged the
|
|
960
|
+
* difference once more (after a decline, or once a new card is saved); in
|
|
961
|
+
* naira the credit just added is taken. The call charges nothing itself
|
|
962
|
+
* and an order is never charged twice, so repeating it is safe. Resolves
|
|
963
|
+
* with the order (`202`); follow it with `wait(order, { waitForPayment: true })`.
|
|
964
|
+
* Rejects with ConflictError `DOMAIN_ORDER_NOT_AWAITING_PAYMENT` when the
|
|
965
|
+
* order is not waiting for a payment or its window has ended.
|
|
966
|
+
*/
|
|
967
|
+
retryPayment(orderId2, options) {
|
|
968
|
+
return this._post(path`/domain-orders/${orderId2}/retry-payment`, void 0, options);
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Polls the order until it `succeeded` (resolves with it) or `failed`
|
|
972
|
+
* (rejects with OrderFailedError; any amount taken is returned to your
|
|
973
|
+
* credit). An order your credit does not cover waits in `awaiting_payment`
|
|
974
|
+
* for an hour (in US dollars the saved card is charged the difference; in
|
|
975
|
+
* naira the user adds credit): it rejects with PaymentRequiredError carrying
|
|
976
|
+
* `paymentExpiresAt`, and `paymentUrl` only when the bank asks the user to
|
|
977
|
+
* confirm the payment; wait again with `{ waitForPayment: true }`, or call
|
|
978
|
+
* `retryPayment` to try again at once. An order not paid in time fails
|
|
979
|
+
* `insufficient_credit` and nothing is charged. Default timeout 15 minutes,
|
|
980
|
+
* polling every 5 seconds. A transfer can take days: pass a longer
|
|
981
|
+
* `timeoutMs`, or check the order later.
|
|
982
|
+
*/
|
|
983
|
+
wait(ref, options = {}) {
|
|
984
|
+
const id = domainOrderId(ref);
|
|
985
|
+
const { waitForPayment, ...waitOptions } = options;
|
|
986
|
+
return poll(
|
|
987
|
+
() => this.get(id, { signal: options.signal }),
|
|
988
|
+
(o) => {
|
|
989
|
+
if (o.status === "awaiting_payment" && !waitForPayment) {
|
|
990
|
+
throw new PaymentRequiredError(
|
|
991
|
+
`Domain order ${o.id} is waiting for a payment: your credit does not cover it.${o.payment_url ? " The bank asks the user to confirm the card payment at paymentUrl." : ""} It must be paid${o.payment_expires_at ? ` before ${o.payment_expires_at}` : " within the hour"}; the order goes on by itself once it is, and retryPayment tries again at once.`,
|
|
992
|
+
{
|
|
993
|
+
status: 402,
|
|
994
|
+
code: "AWAITING_PAYMENT",
|
|
995
|
+
paymentUrl: o.payment_url ?? void 0,
|
|
996
|
+
paymentExpiresAt: o.payment_expires_at ?? void 0,
|
|
997
|
+
order: o
|
|
998
|
+
}
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
if (o.status === "failed") {
|
|
1002
|
+
const code = o.failure_code ?? "failed";
|
|
1003
|
+
throw new OrderFailedError(
|
|
1004
|
+
`Domain order ${o.id} failed (${code}).${o.refunded ? " The amount was returned to your credit." : ""}`,
|
|
1005
|
+
o,
|
|
1006
|
+
{ code }
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
1009
|
+
return o.status === "succeeded";
|
|
1010
|
+
},
|
|
1011
|
+
`Domain order ${id}`,
|
|
1012
|
+
{ timeoutMs: ORDER_WAIT_MS, pollIntervalMs: 5e3, ...waitOptions }
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
// src/resources/iam.ts
|
|
1018
|
+
var IAM = class extends APIResource {
|
|
1019
|
+
/** The actions a policy statement can name. */
|
|
1020
|
+
actions = new IAMActions(this._client);
|
|
1021
|
+
/** Whether members may read everything, or only what their policies allow. */
|
|
1022
|
+
settings = new IAMSettings(this._client);
|
|
1023
|
+
/** The organization's members, with their teams and how many policies apply to each. */
|
|
1024
|
+
members = new IAMMembers(this._client);
|
|
1025
|
+
/** Teams of members that policies are attached to. */
|
|
1026
|
+
teams = new IAMTeams(this._client);
|
|
1027
|
+
/** Statements that allow or deny actions, attached to members or teams. */
|
|
1028
|
+
policies = new IAMPolicies(this._client);
|
|
1029
|
+
/** A member's role, teams and every policy that applies to them, with the team that brought it. */
|
|
1030
|
+
effectiveAccess(userId, options) {
|
|
1031
|
+
return this._get(path`/iam/members/${userId}/effective-access`, void 0, options);
|
|
1032
|
+
}
|
|
1033
|
+
/** Whether a member may do an action (on a resource, from an address, with MFA), and which policy decided. */
|
|
1034
|
+
simulate(body, options) {
|
|
1035
|
+
return this._post("/iam/simulate", body, options);
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
var IAMActions = class extends APIResource {
|
|
1039
|
+
/** Every action, e.g. `instances:Stop`, with its description and whether it is a read. */
|
|
1040
|
+
list(options) {
|
|
1041
|
+
return this._get("/iam/actions", void 0, options);
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
var IAMMembers = class extends APIResource {
|
|
1045
|
+
/** One page of members, by when they joined. Filter with `q` (email or name). */
|
|
1046
|
+
list(params = {}, options) {
|
|
1047
|
+
return this._get("/iam/members", params, options);
|
|
1048
|
+
}
|
|
1049
|
+
listAll(params = {}, options) {
|
|
1050
|
+
return this._listAll("/iam/members", params, options);
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
var IAMSettings = class extends APIResource {
|
|
1054
|
+
get(options) {
|
|
1055
|
+
return this._get("/iam/settings", void 0, options);
|
|
1056
|
+
}
|
|
1057
|
+
/** Changes `member_baseline` (`read` or `none`). Owners only. Pass `{ ifMatch: settings.version }` to refuse a lost update. */
|
|
1058
|
+
update(body, options) {
|
|
1059
|
+
return this._put("/iam/settings", body, withIfMatch(options));
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
var IAMTeams = class extends APIResource {
|
|
1063
|
+
/** Members of a team. */
|
|
1064
|
+
members = new IAMTeamMembers(this._client);
|
|
1065
|
+
list(params = {}, options) {
|
|
1066
|
+
return this._get("/iam/teams", params, options);
|
|
1067
|
+
}
|
|
1068
|
+
listAll(params = {}, options) {
|
|
1069
|
+
return this._listAll("/iam/teams", params, options);
|
|
1070
|
+
}
|
|
1071
|
+
create(body, options) {
|
|
1072
|
+
return this._post("/iam/teams", body, options);
|
|
1073
|
+
}
|
|
1074
|
+
get(teamId, options) {
|
|
1075
|
+
return this._get(path`/iam/teams/${teamId}`, void 0, options);
|
|
1076
|
+
}
|
|
1077
|
+
update(teamId, body, options) {
|
|
1078
|
+
return this._patch(path`/iam/teams/${teamId}`, body, options);
|
|
1079
|
+
}
|
|
1080
|
+
/** Deletes the team; its members lose what its policies gave them. */
|
|
1081
|
+
delete(teamId, options) {
|
|
1082
|
+
return this._delete(path`/iam/teams/${teamId}`, options);
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
var IAMTeamMembers = class extends APIResource {
|
|
1086
|
+
list(teamId, params = {}, options) {
|
|
1087
|
+
return this._get(path`/iam/teams/${teamId}/members`, params, options);
|
|
1088
|
+
}
|
|
1089
|
+
listAll(teamId, params = {}, options) {
|
|
1090
|
+
return this._listAll(path`/iam/teams/${teamId}/members`, params, options);
|
|
1091
|
+
}
|
|
1092
|
+
/** Adds an organization member to the team. Only owners may add an admin. */
|
|
1093
|
+
add(teamId, userId, options) {
|
|
1094
|
+
return this._request("PUT", path`/iam/teams/${teamId}/members/${userId}`, {}, options);
|
|
1095
|
+
}
|
|
1096
|
+
remove(teamId, userId, options) {
|
|
1097
|
+
return this._delete(path`/iam/teams/${teamId}/members/${userId}`, options);
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
var IAMPolicies = class extends APIResource {
|
|
1101
|
+
/** The members and teams a policy is attached to. */
|
|
1102
|
+
attachments = new IAMPolicyAttachments(this._client);
|
|
1103
|
+
/** Your policies and Pantech's managed ones; `{ managed: false }` for yours only. */
|
|
1104
|
+
list(params = {}, options) {
|
|
1105
|
+
return this._get("/iam/policies", params, options);
|
|
1106
|
+
}
|
|
1107
|
+
listAll(params = {}, options) {
|
|
1108
|
+
return this._listAll("/iam/policies", params, options);
|
|
1109
|
+
}
|
|
1110
|
+
/** Creates a policy of 1 to 20 statements. It does nothing until it is attached. */
|
|
1111
|
+
create(body, options) {
|
|
1112
|
+
return this._post("/iam/policies", body, options);
|
|
1113
|
+
}
|
|
1114
|
+
get(policyId, options) {
|
|
1115
|
+
return this._get(path`/iam/policies/${policyId}`, void 0, options);
|
|
1116
|
+
}
|
|
1117
|
+
/** Replaces the name, description and statements. Pass `{ ifMatch: policy.version }` to refuse a lost update. */
|
|
1118
|
+
update(policyId, body, options) {
|
|
1119
|
+
return this._put(path`/iam/policies/${policyId}`, body, withIfMatch(options));
|
|
1120
|
+
}
|
|
1121
|
+
/** Deletes the policy and detaches it everywhere. Pantech's managed policies cannot be deleted. */
|
|
1122
|
+
delete(policyId, options) {
|
|
1123
|
+
return this._delete(path`/iam/policies/${policyId}`, options);
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
var IAMPolicyAttachments = class extends APIResource {
|
|
1127
|
+
list(policyId, options) {
|
|
1128
|
+
return this._get(path`/iam/policies/${policyId}/attachments`, void 0, options);
|
|
1129
|
+
}
|
|
1130
|
+
/** Attaches the policy to a member (`usr_…`) or a team (`team_…`). */
|
|
1131
|
+
attach(policyId, body, options) {
|
|
1132
|
+
return this._post(path`/iam/policies/${policyId}/attachments`, body, options);
|
|
1133
|
+
}
|
|
1134
|
+
detach(policyId, principalType, principalId, options) {
|
|
1135
|
+
return this._delete(path`/iam/policies/${policyId}/attachments/${principalType}/${principalId}`, options);
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
|
|
515
1139
|
// src/resources/instances.ts
|
|
516
1140
|
var Instances = class extends APIResource {
|
|
517
1141
|
/** Snapshots of an instance's root disk. */
|
|
@@ -1131,6 +1755,89 @@ var PortForwardingRules = class extends APIResource {
|
|
|
1131
1755
|
}
|
|
1132
1756
|
};
|
|
1133
1757
|
|
|
1758
|
+
// src/resources/registry.ts
|
|
1759
|
+
var Registry = class extends APIResource {
|
|
1760
|
+
/** Your organization's namespace, which every image name starts with. */
|
|
1761
|
+
namespace = new RegistryNamespaces(this._client);
|
|
1762
|
+
/** Repositories in your namespace. */
|
|
1763
|
+
repositories = new RegistryRepositories(this._client);
|
|
1764
|
+
/** Tags of a repository, and the images they point at. */
|
|
1765
|
+
tags = new RegistryTags(this._client);
|
|
1766
|
+
/** Registry-only credentials for CI and clusters. */
|
|
1767
|
+
tokens = new RegistryTokens(this._client);
|
|
1768
|
+
};
|
|
1769
|
+
var RegistryNamespaces = class extends APIResource {
|
|
1770
|
+
/** The namespace with its usage and limits. Rejects with `404 REGISTRY_NAMESPACE_NOT_SET` until one is claimed. */
|
|
1771
|
+
get(options) {
|
|
1772
|
+
return this._get("/registry", void 0, options);
|
|
1773
|
+
}
|
|
1774
|
+
/** Claims the namespace, or changes it or `create_on_push`. The name is fixed once a repository exists. */
|
|
1775
|
+
set(body, options) {
|
|
1776
|
+
return this._put("/registry", body, options);
|
|
1777
|
+
}
|
|
1778
|
+
};
|
|
1779
|
+
var RegistryRepositories = class extends APIResource {
|
|
1780
|
+
list(params = {}, options) {
|
|
1781
|
+
return this._get("/registry/repositories", params, options);
|
|
1782
|
+
}
|
|
1783
|
+
listAll(params = {}, options) {
|
|
1784
|
+
return this._listAll("/registry/repositories", params, options);
|
|
1785
|
+
}
|
|
1786
|
+
/** Creates a repository, private unless `visibility` is `public`. */
|
|
1787
|
+
create(body, options) {
|
|
1788
|
+
return this._post("/registry/repositories", body, options);
|
|
1789
|
+
}
|
|
1790
|
+
get(repositoryId, options) {
|
|
1791
|
+
return this._get(path`/registry/repositories/${repositoryId}`, void 0, options);
|
|
1792
|
+
}
|
|
1793
|
+
/** Changes the description, visibility, tag immutability or retention policy. */
|
|
1794
|
+
update(repositoryId, body, options) {
|
|
1795
|
+
return this._patch(path`/registry/repositories/${repositoryId}`, body, options);
|
|
1796
|
+
}
|
|
1797
|
+
/** Deletes the repository and every image in it. */
|
|
1798
|
+
delete(repositoryId, options) {
|
|
1799
|
+
return this._delete(path`/registry/repositories/${repositoryId}`, options);
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
var RegistryTags = class extends APIResource {
|
|
1803
|
+
/** A repository's tags, newest push first. */
|
|
1804
|
+
list(repositoryId, params = {}, options) {
|
|
1805
|
+
return this._get(path`/registry/repositories/${repositoryId}/tags`, params, options);
|
|
1806
|
+
}
|
|
1807
|
+
listAll(repositoryId, params = {}, options) {
|
|
1808
|
+
return this._listAll(path`/registry/repositories/${repositoryId}/tags`, params, options);
|
|
1809
|
+
}
|
|
1810
|
+
get(repositoryId, tag, options) {
|
|
1811
|
+
return this._get(path`/registry/repositories/${repositoryId}/tags/${tag}`, void 0, options);
|
|
1812
|
+
}
|
|
1813
|
+
/** Removes the tag. Rejected with `409 TAG_IMMUTABLE` in a repository with immutable tags. */
|
|
1814
|
+
delete(repositoryId, tag, options) {
|
|
1815
|
+
return this._delete(path`/registry/repositories/${repositoryId}/tags/${tag}`, options);
|
|
1816
|
+
}
|
|
1817
|
+
};
|
|
1818
|
+
var RegistryTokens = class extends APIResource {
|
|
1819
|
+
/** Your registry tokens, without their secrets. */
|
|
1820
|
+
list(params = {}, options) {
|
|
1821
|
+
return this._get("/registry/tokens", params, options);
|
|
1822
|
+
}
|
|
1823
|
+
listAll(params = {}, options) {
|
|
1824
|
+
return this._listAll("/registry/tokens", params, options);
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Creates a token for `docker login`: `pull`, or `push` (which includes
|
|
1828
|
+
* pull), for every repository or only `repositories`. Its `secret` is in
|
|
1829
|
+
* this response alone. It is non-enumerable: `token.secret` reads it, but
|
|
1830
|
+
* console.log and JSON.stringify leave it out.
|
|
1831
|
+
*/
|
|
1832
|
+
async create(body, options) {
|
|
1833
|
+
return hideSecrets(await this._post("/registry/tokens", body, options));
|
|
1834
|
+
}
|
|
1835
|
+
/** Revokes the token: logins stop at once, and access already granted ends within 5 minutes. */
|
|
1836
|
+
delete(tokenId, options) {
|
|
1837
|
+
return this._delete(path`/registry/tokens/${tokenId}`, options);
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1134
1841
|
// src/resources/security-groups.ts
|
|
1135
1842
|
var SecurityGroups = class extends APIResource {
|
|
1136
1843
|
list(params = {}, options) {
|
|
@@ -1325,7 +2032,7 @@ var WebhookDeliveries = class extends APIResource {
|
|
|
1325
2032
|
};
|
|
1326
2033
|
|
|
1327
2034
|
// src/version.ts
|
|
1328
|
-
var VERSION = "0.
|
|
2035
|
+
var VERSION = "0.4.0";
|
|
1329
2036
|
|
|
1330
2037
|
// src/client.ts
|
|
1331
2038
|
var DEFAULT_BASE_URL = "https://api.pantechdynamics.com/public/v1";
|
|
@@ -1333,6 +2040,12 @@ var DEFAULT_TIMEOUT_MS = 6e4;
|
|
|
1333
2040
|
var DEFAULT_MAX_RETRIES = 3;
|
|
1334
2041
|
var MAX_RETRY_AFTER_MS = 6e4;
|
|
1335
2042
|
var RETRY_STATUSES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
|
|
2043
|
+
var ACCEPT = {
|
|
2044
|
+
json: "application/json",
|
|
2045
|
+
arrayBuffer: "*/*",
|
|
2046
|
+
text: "text/dns, text/plain;q=0.9",
|
|
2047
|
+
response: "application/json"
|
|
2048
|
+
};
|
|
1336
2049
|
var Pantech = class {
|
|
1337
2050
|
baseURL;
|
|
1338
2051
|
maxRetries;
|
|
@@ -1372,6 +2085,16 @@ var Pantech = class {
|
|
|
1372
2085
|
webhooks;
|
|
1373
2086
|
/** Move from another cloud: connections, scans and migration plans. */
|
|
1374
2087
|
migrate;
|
|
2088
|
+
/** Pantech DNS: hosted zones and their records, on Pantech's own name servers. */
|
|
2089
|
+
dns;
|
|
2090
|
+
/** Domains: search, register, transfer in, renew and configure. */
|
|
2091
|
+
domains;
|
|
2092
|
+
/** The private container registry: namespace, repositories, tags and registry tokens. */
|
|
2093
|
+
registry;
|
|
2094
|
+
/** Teams and access policies: who may do what, on which resources. */
|
|
2095
|
+
iam;
|
|
2096
|
+
/** TLS certificates Pantech issues and renews, or ones you import. */
|
|
2097
|
+
certificates;
|
|
1375
2098
|
operations;
|
|
1376
2099
|
constructor(options = {}) {
|
|
1377
2100
|
const apiKey = options.apiKey ?? readEnv("PANTECH_API_KEY");
|
|
@@ -1414,6 +2137,11 @@ var Pantech = class {
|
|
|
1414
2137
|
this.sshKeys = new SshKeys(this);
|
|
1415
2138
|
this.webhooks = new Webhooks(this);
|
|
1416
2139
|
this.migrate = new Migrate(this);
|
|
2140
|
+
this.dns = new DNS(this);
|
|
2141
|
+
this.domains = new Domains(this);
|
|
2142
|
+
this.registry = new Registry(this);
|
|
2143
|
+
this.iam = new IAM(this);
|
|
2144
|
+
this.certificates = new Certificates(this);
|
|
1417
2145
|
}
|
|
1418
2146
|
/**
|
|
1419
2147
|
* Sends one request and returns its decoded body (undefined for an empty
|
|
@@ -1425,7 +2153,7 @@ var Pantech = class {
|
|
|
1425
2153
|
const isWrite = req.method !== "GET";
|
|
1426
2154
|
const headers = {
|
|
1427
2155
|
...this.#headers,
|
|
1428
|
-
Accept: req.responseType
|
|
2156
|
+
Accept: ACCEPT[req.responseType ?? "json"],
|
|
1429
2157
|
...options.headers,
|
|
1430
2158
|
Authorization: `Bearer ${this.#apiKey}`
|
|
1431
2159
|
};
|
|
@@ -1501,6 +2229,7 @@ function queryString(query) {
|
|
|
1501
2229
|
async function readBody(res, type) {
|
|
1502
2230
|
if (type === "response") return res;
|
|
1503
2231
|
if (type === "arrayBuffer") return res.arrayBuffer();
|
|
2232
|
+
if (type === "text") return res.text();
|
|
1504
2233
|
const text = await res.text();
|
|
1505
2234
|
if (res.status === 204 || text === "") return void 0;
|
|
1506
2235
|
try {
|
|
@@ -1556,6 +2285,59 @@ function linkSignal(parent, timeout) {
|
|
|
1556
2285
|
};
|
|
1557
2286
|
}
|
|
1558
2287
|
|
|
2288
|
+
// src/iam.ts
|
|
2289
|
+
var SID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
2290
|
+
var MAX_ITEMS = 50;
|
|
2291
|
+
var MAX_SOURCE_IPS = 20;
|
|
2292
|
+
var MANAGED_POLICY_IDS = [
|
|
2293
|
+
"pol_pantech_read_only",
|
|
2294
|
+
"pol_pantech_developer",
|
|
2295
|
+
"pol_pantech_network_admin",
|
|
2296
|
+
"pol_pantech_database_admin",
|
|
2297
|
+
"pol_pantech_dns_manager",
|
|
2298
|
+
"pol_pantech_domain_manager",
|
|
2299
|
+
"pol_pantech_registry_push",
|
|
2300
|
+
"pol_pantech_registry_pull",
|
|
2301
|
+
"pol_pantech_billing_manager",
|
|
2302
|
+
"pol_pantech_support",
|
|
2303
|
+
"pol_pantech_deny_delete",
|
|
2304
|
+
"pol_pantech_require_mfa_for_writes"
|
|
2305
|
+
];
|
|
2306
|
+
function strings(name, values, limit) {
|
|
2307
|
+
if (!Array.isArray(values)) throw new TypeError(`${name} must be an array of strings.`);
|
|
2308
|
+
if (values.length === 0) throw new RangeError(`${name} needs at least one entry.`);
|
|
2309
|
+
if (values.length > limit) throw new RangeError(`${name} takes at most ${limit} entries, got ${values.length}.`);
|
|
2310
|
+
for (const v of values) {
|
|
2311
|
+
if (typeof v !== "string" || v === "") throw new TypeError(`${name} entries must be non-empty strings.`);
|
|
2312
|
+
}
|
|
2313
|
+
return [...values];
|
|
2314
|
+
}
|
|
2315
|
+
function statement(effect, actions, resources = ["*"], options = {}) {
|
|
2316
|
+
if (effect !== "allow" && effect !== "deny") throw new TypeError(`effect must be "allow" or "deny".`);
|
|
2317
|
+
const out = {
|
|
2318
|
+
effect,
|
|
2319
|
+
actions: strings("actions", actions, MAX_ITEMS),
|
|
2320
|
+
resources: strings("resources", resources, MAX_ITEMS)
|
|
2321
|
+
};
|
|
2322
|
+
if (options.sid !== void 0) {
|
|
2323
|
+
if (!SID.test(options.sid)) throw new RangeError("sid must be 1 to 64 letters, digits, '_' or '-'.");
|
|
2324
|
+
out.sid = options.sid;
|
|
2325
|
+
}
|
|
2326
|
+
const conditions = {};
|
|
2327
|
+
if (options.sourceIp !== void 0) conditions.source_ip = strings("sourceIp", options.sourceIp, MAX_SOURCE_IPS);
|
|
2328
|
+
if (options.mfa !== void 0) conditions.mfa = options.mfa;
|
|
2329
|
+
if (Object.keys(conditions).length > 0) out.conditions = conditions;
|
|
2330
|
+
return out;
|
|
2331
|
+
}
|
|
2332
|
+
var iam = {
|
|
2333
|
+
/** An `allow` statement: `iam.allow(["instances:Start"], ["name:staging-*"])`. */
|
|
2334
|
+
allow: (actions, resources, options) => statement("allow", actions, resources, options),
|
|
2335
|
+
/** A `deny` statement, which wins over every allow: `iam.deny(["*:Delete"])`. */
|
|
2336
|
+
deny: (actions, resources, options) => statement("deny", actions, resources, options),
|
|
2337
|
+
statement,
|
|
2338
|
+
MANAGED_POLICY_IDS
|
|
2339
|
+
};
|
|
2340
|
+
|
|
1559
2341
|
// src/webhooks.ts
|
|
1560
2342
|
var WEBHOOK_SIGNATURE_HEADER = "Pantech-Signature";
|
|
1561
2343
|
var DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
@@ -1629,6 +2411,6 @@ async function signWebhook(options) {
|
|
|
1629
2411
|
return `t=${t},v1=${await hmacHex(options.secret, t, bytes(options.body))}`;
|
|
1630
2412
|
}
|
|
1631
2413
|
|
|
1632
|
-
export { APIConnectionError, APITimeoutError, AuthenticationError, BadRequestError, CloudFailedError, ConflictError, DEFAULT_BASE_URL, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, InternalServerError, NotFoundError, OperationFailedError, OrderFailedError, Pantech, PantechError, PaymentRequiredError, PermissionDeniedError, RateLimitError, VERSION, ValidationError, WEBHOOK_SIGNATURE_HEADER, WaitTimeoutError, WebhookVerificationError, isPantechError, paginate, signWebhook, verifyWebhook };
|
|
2414
|
+
export { APIConnectionError, APITimeoutError, AuthenticationError, BadRequestError, CERTIFICATE_ERROR_CODES, CertificateFailedError, CloudFailedError, ConflictError, DEFAULT_BASE_URL, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DNSFailedError, DNS_ERROR_CODES, DOMAIN_ERROR_CODES, IAM_ERROR_CODES, InternalServerError, NotFoundError, OperationFailedError, OrderFailedError, Pantech, PantechError, PaymentRequiredError, PermissionDeniedError, PreconditionFailedError, REGISTRY_ERROR_CODES, RateLimitError, VERSION, ValidationError, WEBHOOK_SIGNATURE_HEADER, WaitTimeoutError, WebhookVerificationError, iam, isPantechError, paginate, signWebhook, verifyWebhook };
|
|
1633
2415
|
//# sourceMappingURL=index.js.map
|
|
1634
2416
|
//# sourceMappingURL=index.js.map
|