@pantechdynamic/sdk 0.3.0 → 0.5.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/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", "secret_access_key"];
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(strings, ...ids) {
273
- let out = strings[0] ?? "";
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) + (strings[i + 1] ?? "");
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,12 +739,416 @@ 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: the registrant has
905
+ * accepted the Domain Registration Agreement
906
+ * (https://pantechdynamics.com/legal/domain-registration). Follow the order with
907
+ * `orders.wait(result)`.
908
+ */
909
+ register(body, options) {
910
+ return this._post("/domains", body, options);
911
+ }
912
+ /**
913
+ * Moves a domain to Pantech with its auth code, adding `years` to its term.
914
+ * `accept_terms` must be true, as for `register`. Follow it with `orders.wait`.
915
+ */
916
+ transfer(body, options) {
917
+ return this._post("/domains/transfers", body, options);
918
+ }
919
+ get(domainId, options) {
920
+ return this._get(path`/domains/${domainId}`, void 0, options);
921
+ }
922
+ /** Turns auto-renew, the transfer lock or privacy on or off. */
923
+ update(domainId, body, options) {
924
+ return this._patch(path`/domains/${domainId}`, body, options);
925
+ }
926
+ /** Points the domain at its Pantech DNS zone, or at up to 6 custom name servers. */
927
+ setNameServers(domainId, body, options) {
928
+ return this._put(path`/domains/${domainId}/name-servers`, body, options);
929
+ }
930
+ /** The registrant contact. Owners and admins only. */
931
+ getContact(domainId, options) {
932
+ return this._get(path`/domains/${domainId}/contact`, void 0, options);
933
+ }
934
+ /** Replaces the registrant contact; applied at the registry in the background. */
935
+ updateContact(domainId, body, options) {
936
+ return this._put(path`/domains/${domainId}/contact`, body, options);
937
+ }
938
+ /** Adds `years` (default 1) to the domain's term, paid from your credit first. */
939
+ renew(domainId, body = {}, options) {
940
+ return this._post(path`/domains/${domainId}/renew`, body, options);
941
+ }
942
+ /**
943
+ * Asks for the code that moves the domain to another registrar. Needs the
944
+ * `delete` scope, and the transfer lock off. Read it with `getAuthCode`.
945
+ */
946
+ requestAuthCode(domainId, options) {
947
+ return this._post(path`/domains/${domainId}/auth-code`, void 0, options);
948
+ }
949
+ /** The auth code once it has arrived, or `{ status: "pending" }` while it is on its way. */
950
+ getAuthCode(domainId, options) {
951
+ return this._get(path`/domains/${domainId}/auth-code`, void 0, options);
952
+ }
953
+ };
954
+ var DomainOrders = class extends APIResource {
955
+ /** A domain's registrations, renewals and transfers, newest first. */
956
+ list(domainId, options) {
957
+ return this._get(path`/domains/${domainId}/orders`, void 0, options);
958
+ }
959
+ get(orderId2, options) {
960
+ return this._get(path`/domain-orders/${orderId2}`, void 0, options);
961
+ }
962
+ /**
963
+ * Makes an order waiting in `awaiting_payment` try its payment again now,
964
+ * and wait another hour: in US dollars the saved card is charged the
965
+ * difference once more (after a decline, or once a new card is saved); in
966
+ * naira the credit just added is taken. The call charges nothing itself
967
+ * and an order is never charged twice, so repeating it is safe. Resolves
968
+ * with the order (`202`); follow it with `wait(order, { waitForPayment: true })`.
969
+ * Rejects with ConflictError `DOMAIN_ORDER_NOT_AWAITING_PAYMENT` when the
970
+ * order is not waiting for a payment or its window has ended.
971
+ */
972
+ retryPayment(orderId2, options) {
973
+ return this._post(path`/domain-orders/${orderId2}/retry-payment`, void 0, options);
974
+ }
975
+ /**
976
+ * Polls the order until it `succeeded` (resolves with it) or `failed`
977
+ * (rejects with OrderFailedError; any amount taken is returned to your
978
+ * credit). An order your credit does not cover waits in `awaiting_payment`
979
+ * for an hour (in US dollars the saved card is charged the difference; in
980
+ * naira the user adds credit): it rejects with PaymentRequiredError carrying
981
+ * `paymentExpiresAt`, and `paymentUrl` only when the bank asks the user to
982
+ * confirm the payment; wait again with `{ waitForPayment: true }`, or call
983
+ * `retryPayment` to try again at once. An order not paid in time fails
984
+ * `insufficient_credit` and nothing is charged. Default timeout 15 minutes,
985
+ * polling every 5 seconds. A transfer can take days: pass a longer
986
+ * `timeoutMs`, or check the order later.
987
+ */
988
+ wait(ref, options = {}) {
989
+ const id = domainOrderId(ref);
990
+ const { waitForPayment, ...waitOptions } = options;
991
+ return poll(
992
+ () => this.get(id, { signal: options.signal }),
993
+ (o) => {
994
+ if (o.status === "awaiting_payment" && !waitForPayment) {
995
+ throw new PaymentRequiredError(
996
+ `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.`,
997
+ {
998
+ status: 402,
999
+ code: "AWAITING_PAYMENT",
1000
+ paymentUrl: o.payment_url ?? void 0,
1001
+ paymentExpiresAt: o.payment_expires_at ?? void 0,
1002
+ order: o
1003
+ }
1004
+ );
1005
+ }
1006
+ if (o.status === "failed") {
1007
+ const code = o.failure_code ?? "failed";
1008
+ throw new OrderFailedError(
1009
+ `Domain order ${o.id} failed (${code}).${o.refunded ? " The amount was returned to your credit." : ""}`,
1010
+ o,
1011
+ { code }
1012
+ );
1013
+ }
1014
+ return o.status === "succeeded";
1015
+ },
1016
+ `Domain order ${id}`,
1017
+ { timeoutMs: ORDER_WAIT_MS, pollIntervalMs: 5e3, ...waitOptions }
1018
+ );
1019
+ }
1020
+ };
1021
+
1022
+ // src/resources/iam.ts
1023
+ var IAM = class extends APIResource {
1024
+ /** The actions a policy statement can name. */
1025
+ actions = new IAMActions(this._client);
1026
+ /** Whether members may read everything, or only what their policies allow. */
1027
+ settings = new IAMSettings(this._client);
1028
+ /** The organization's members, with their teams and how many policies apply to each. */
1029
+ members = new IAMMembers(this._client);
1030
+ /** Teams of members that policies are attached to. */
1031
+ teams = new IAMTeams(this._client);
1032
+ /** Statements that allow or deny actions, attached to members or teams. */
1033
+ policies = new IAMPolicies(this._client);
1034
+ /** A member's role, teams and every policy that applies to them, with the team that brought it. */
1035
+ effectiveAccess(userId, options) {
1036
+ return this._get(path`/iam/members/${userId}/effective-access`, void 0, options);
1037
+ }
1038
+ /** Whether a member may do an action (on a resource, from an address, with MFA), and which policy decided. */
1039
+ simulate(body, options) {
1040
+ return this._post("/iam/simulate", body, options);
1041
+ }
1042
+ };
1043
+ var IAMActions = class extends APIResource {
1044
+ /** Every action, e.g. `instances:Stop`, with its description and whether it is a read. */
1045
+ list(options) {
1046
+ return this._get("/iam/actions", void 0, options);
1047
+ }
1048
+ };
1049
+ var IAMMembers = class extends APIResource {
1050
+ /** One page of members, by when they joined. Filter with `q` (email or name). */
1051
+ list(params = {}, options) {
1052
+ return this._get("/iam/members", params, options);
1053
+ }
1054
+ listAll(params = {}, options) {
1055
+ return this._listAll("/iam/members", params, options);
1056
+ }
1057
+ };
1058
+ var IAMSettings = class extends APIResource {
1059
+ get(options) {
1060
+ return this._get("/iam/settings", void 0, options);
1061
+ }
1062
+ /** Changes `member_baseline` (`read` or `none`). Owners only. Pass `{ ifMatch: settings.version }` to refuse a lost update. */
1063
+ update(body, options) {
1064
+ return this._put("/iam/settings", body, withIfMatch(options));
1065
+ }
1066
+ };
1067
+ var IAMTeams = class extends APIResource {
1068
+ /** Members of a team. */
1069
+ members = new IAMTeamMembers(this._client);
1070
+ list(params = {}, options) {
1071
+ return this._get("/iam/teams", params, options);
1072
+ }
1073
+ listAll(params = {}, options) {
1074
+ return this._listAll("/iam/teams", params, options);
1075
+ }
1076
+ create(body, options) {
1077
+ return this._post("/iam/teams", body, options);
1078
+ }
1079
+ get(teamId, options) {
1080
+ return this._get(path`/iam/teams/${teamId}`, void 0, options);
1081
+ }
1082
+ update(teamId, body, options) {
1083
+ return this._patch(path`/iam/teams/${teamId}`, body, options);
1084
+ }
1085
+ /** Deletes the team; its members lose what its policies gave them. */
1086
+ delete(teamId, options) {
1087
+ return this._delete(path`/iam/teams/${teamId}`, options);
1088
+ }
1089
+ };
1090
+ var IAMTeamMembers = class extends APIResource {
1091
+ list(teamId, params = {}, options) {
1092
+ return this._get(path`/iam/teams/${teamId}/members`, params, options);
1093
+ }
1094
+ listAll(teamId, params = {}, options) {
1095
+ return this._listAll(path`/iam/teams/${teamId}/members`, params, options);
1096
+ }
1097
+ /** Adds an organization member to the team. Only owners may add an admin. */
1098
+ add(teamId, userId, options) {
1099
+ return this._request("PUT", path`/iam/teams/${teamId}/members/${userId}`, {}, options);
1100
+ }
1101
+ remove(teamId, userId, options) {
1102
+ return this._delete(path`/iam/teams/${teamId}/members/${userId}`, options);
1103
+ }
1104
+ };
1105
+ var IAMPolicies = class extends APIResource {
1106
+ /** The members and teams a policy is attached to. */
1107
+ attachments = new IAMPolicyAttachments(this._client);
1108
+ /** Your policies and Pantech's managed ones; `{ managed: false }` for yours only. */
1109
+ list(params = {}, options) {
1110
+ return this._get("/iam/policies", params, options);
1111
+ }
1112
+ listAll(params = {}, options) {
1113
+ return this._listAll("/iam/policies", params, options);
1114
+ }
1115
+ /** Creates a policy of 1 to 20 statements. It does nothing until it is attached. */
1116
+ create(body, options) {
1117
+ return this._post("/iam/policies", body, options);
1118
+ }
1119
+ get(policyId, options) {
1120
+ return this._get(path`/iam/policies/${policyId}`, void 0, options);
1121
+ }
1122
+ /** Replaces the name, description and statements. Pass `{ ifMatch: policy.version }` to refuse a lost update. */
1123
+ update(policyId, body, options) {
1124
+ return this._put(path`/iam/policies/${policyId}`, body, withIfMatch(options));
1125
+ }
1126
+ /** Deletes the policy and detaches it everywhere. Pantech's managed policies cannot be deleted. */
1127
+ delete(policyId, options) {
1128
+ return this._delete(path`/iam/policies/${policyId}`, options);
1129
+ }
1130
+ };
1131
+ var IAMPolicyAttachments = class extends APIResource {
1132
+ list(policyId, options) {
1133
+ return this._get(path`/iam/policies/${policyId}/attachments`, void 0, options);
1134
+ }
1135
+ /** Attaches the policy to a member (`usr_…`) or a team (`team_…`). */
1136
+ attach(policyId, body, options) {
1137
+ return this._post(path`/iam/policies/${policyId}/attachments`, body, options);
1138
+ }
1139
+ detach(policyId, principalType, principalId, options) {
1140
+ return this._delete(path`/iam/policies/${policyId}/attachments/${principalType}/${principalId}`, options);
1141
+ }
1142
+ };
1143
+
515
1144
  // src/resources/instances.ts
516
1145
  var Instances = class extends APIResource {
517
1146
  /** Snapshots of an instance's root disk. */
518
1147
  snapshots = new InstanceSnapshots(this._client);
519
1148
  /** Short-lived SSH access grants through the browser terminal relay. */
520
1149
  sshAccess = new InstanceSshAccess(this._client);
1150
+ /** Dynamic IP: a public outbound address that rotates on a schedule or on demand. */
1151
+ dynamicIp = new InstanceDynamicIp(this._client);
521
1152
  /** One page of your instances. */
522
1153
  list(params = {}, options) {
523
1154
  return this._get("/instances", params, options);
@@ -625,6 +1256,24 @@ var InstanceSshAccess = class extends APIResource {
625
1256
  return this._delete(path`/instances/${instanceId}/ssh-access/${grantId}`, options);
626
1257
  }
627
1258
  };
1259
+ var InstanceDynamicIp = class extends APIResource {
1260
+ /** Whether the instance has a dynamic IP, its schedule, current address and recent changes. */
1261
+ get(instanceId, options) {
1262
+ return this._get(path`/instances/${instanceId}/address-rotation`, void 0, options);
1263
+ }
1264
+ /** Turns on or changes dynamic IP settings for the instance. */
1265
+ set(instanceId, body, options) {
1266
+ return this._put(path`/instances/${instanceId}/address-rotation`, body, options);
1267
+ }
1268
+ /** Turns off dynamic IP for the instance and stops its surcharge. */
1269
+ disable(instanceId, options) {
1270
+ return this._delete(path`/instances/${instanceId}/address-rotation`, options);
1271
+ }
1272
+ /** Gives the instance a new dynamic IP now, outside its schedule. Sent once: the API does not replay it. */
1273
+ rotate(instanceId, options) {
1274
+ return this._post(path`/instances/${instanceId}/address-rotation/rotate`, void 0, options, { noRetry: true });
1275
+ }
1276
+ };
628
1277
  var InstanceOrders = class extends APIResource {
629
1278
  list(params = {}, options) {
630
1279
  return this._get("/instance-orders", params, options);
@@ -978,6 +1627,192 @@ var FirewallRules = class extends APIResource {
978
1627
  }
979
1628
  };
980
1629
 
1630
+ // src/resources/object-storage.ts
1631
+ var ObjectStorage = class extends APIResource {
1632
+ /** S3 access keys for your organization. */
1633
+ keys = new ObjectStorageKeys(this._client);
1634
+ /** Whether object storage is available, with endpoints and regional pricing. */
1635
+ getStatus(options) {
1636
+ return this._get("/object-storage", void 0, options);
1637
+ }
1638
+ /** Hourly object storage traffic and operations for your organization. */
1639
+ getUsage(params = {}, options) {
1640
+ return this._get("/object-storage/usage", params, options);
1641
+ }
1642
+ };
1643
+ var ObjectStorageKeys = class extends APIResource {
1644
+ /** Lists your S3 access keys without their secrets. */
1645
+ list(params = {}, options) {
1646
+ return this._get("/object-storage/keys", params, options);
1647
+ }
1648
+ /**
1649
+ * Creates an S3 access key. Its `secret_access_key` is returned once and
1650
+ * never replayed; it is non-enumerable so `console.log` and `JSON.stringify`
1651
+ * leave it out while `key.secret_access_key` reads it.
1652
+ */
1653
+ async create(body, options) {
1654
+ return hideSecrets(
1655
+ await this._post("/object-storage/keys", body, options, { noRetry: true })
1656
+ );
1657
+ }
1658
+ /** Revokes an S3 access key at once. */
1659
+ revoke(storageKeyId, options) {
1660
+ return this._delete(path`/object-storage/keys/${storageKeyId}`, options);
1661
+ }
1662
+ };
1663
+ var Buckets = class extends APIResource {
1664
+ /** Objects and folders inside a bucket. */
1665
+ objects = new BucketObjects(this._client);
1666
+ /** Multipart uploads for large objects. */
1667
+ multipart = new BucketMultipart(this._client);
1668
+ /** Lists every bucket in your organization. */
1669
+ list(options) {
1670
+ return this._get("/buckets", void 0, options);
1671
+ }
1672
+ /** Creates a new bucket. */
1673
+ create(body, options) {
1674
+ return this._post("/buckets", body, options);
1675
+ }
1676
+ /** Gets one bucket's settings and endpoints. */
1677
+ get(bucketId, options) {
1678
+ return this._get(path`/buckets/${bucketId}`, void 0, options);
1679
+ }
1680
+ /** Updates a bucket's versioning, access policy, or public prefixes. */
1681
+ update(bucketId, body, options) {
1682
+ return this._patch(path`/buckets/${bucketId}`, body, options);
1683
+ }
1684
+ /** Deletes a bucket. Pass `{ force: true }` to empty it before removal. */
1685
+ delete(bucketId, params = {}, options) {
1686
+ return this._request("DELETE", path`/buckets/${bucketId}`, { query: params }, options);
1687
+ }
1688
+ /** Live total size and object count of a bucket. */
1689
+ stats(bucketId, options) {
1690
+ return this._get(path`/buckets/${bucketId}/stats`, void 0, options);
1691
+ }
1692
+ /** Deletes all objects, versions, and active multipart uploads in a bucket. Sent once: not retried on error. */
1693
+ empty(bucketId, options) {
1694
+ return this._post(path`/buckets/${bucketId}/empty`, void 0, options, { noRetry: true });
1695
+ }
1696
+ /** Reads the bucket's CORS rules. */
1697
+ getCors(bucketId, options) {
1698
+ return this._get(path`/buckets/${bucketId}/cors`, void 0, options);
1699
+ }
1700
+ /** Replaces the bucket's CORS rules (an empty list clears them). */
1701
+ setCors(bucketId, body, options) {
1702
+ return this._put(path`/buckets/${bucketId}/cors`, body, options);
1703
+ }
1704
+ /** Reads the bucket's lifecycle rules. */
1705
+ getLifecycle(bucketId, options) {
1706
+ return this._get(path`/buckets/${bucketId}/lifecycle`, void 0, options);
1707
+ }
1708
+ /** Replaces the bucket's lifecycle rules (an empty list clears them). */
1709
+ setLifecycle(bucketId, body, options) {
1710
+ return this._put(path`/buckets/${bucketId}/lifecycle`, body, options);
1711
+ }
1712
+ /** Reads the bucket's tags. */
1713
+ getTags(bucketId, options) {
1714
+ return this._get(path`/buckets/${bucketId}/tags`, void 0, options);
1715
+ }
1716
+ /** Replaces the bucket's tags (an empty list clears them). */
1717
+ setTags(bucketId, body, options) {
1718
+ return this._put(path`/buckets/${bucketId}/tags`, body, options);
1719
+ }
1720
+ /** Reads the bucket's default object lock configuration. */
1721
+ getObjectLock(bucketId, options) {
1722
+ return this._get(path`/buckets/${bucketId}/object-lock`, void 0, options);
1723
+ }
1724
+ /** Updates the bucket's default object lock configuration. */
1725
+ setObjectLock(bucketId, body, options) {
1726
+ return this._put(path`/buckets/${bucketId}/object-lock`, body, options);
1727
+ }
1728
+ };
1729
+ var BucketObjects = class extends APIResource {
1730
+ /** Lists folders and objects under a prefix, searches across the bucket, or lists object versions. */
1731
+ list(bucketId, params = {}, options) {
1732
+ return this._get(path`/buckets/${bucketId}/objects`, params, options);
1733
+ }
1734
+ /** Reads metadata, headers, tags, lock status, and public visibility of one object. */
1735
+ getMeta(bucketId, params, options) {
1736
+ return this._get(path`/buckets/${bucketId}/objects/meta`, params, options);
1737
+ }
1738
+ /** Downloads an object's raw bytes as an `ArrayBuffer`. */
1739
+ download(bucketId, params, options) {
1740
+ return this._request(
1741
+ "GET",
1742
+ path`/buckets/${bucketId}/objects/download`,
1743
+ { query: params, responseType: "arrayBuffer" },
1744
+ options
1745
+ );
1746
+ }
1747
+ /** Mints a short-lived signed download URL when direct transfers are enabled. */
1748
+ presignDownload(bucketId, body, options) {
1749
+ return this._post(path`/buckets/${bucketId}/objects/download-url`, body, options);
1750
+ }
1751
+ /**
1752
+ * Streams an object upload into the bucket as raw bytes. Sets
1753
+ * `Content-Type: application/octet-stream` unless `options.headers` sets a
1754
+ * custom `Content-Type`.
1755
+ */
1756
+ upload(bucketId, params, body, options) {
1757
+ return this._request("PUT", path`/buckets/${bucketId}/objects/upload`, { query: params, rawBody: body }, options);
1758
+ }
1759
+ /** Mints a short-lived signed upload URL when direct transfers are enabled. */
1760
+ presignUpload(bucketId, body, options) {
1761
+ return this._post(path`/buckets/${bucketId}/objects/upload-url`, body, options);
1762
+ }
1763
+ /** Creates a folder marker object ending with `/`. */
1764
+ createFolder(bucketId, body, options) {
1765
+ return this._post(path`/buckets/${bucketId}/objects/folder`, body, options);
1766
+ }
1767
+ /** Copies, renames, or updates metadata of an object inside the bucket. */
1768
+ copy(bucketId, body, options) {
1769
+ return this._post(path`/buckets/${bucketId}/objects/copy`, body, options);
1770
+ }
1771
+ /** Deletes one or more objects or versions, or deletes a folder prefix recursively. */
1772
+ delete(bucketId, body, options) {
1773
+ return this._post(path`/buckets/${bucketId}/objects/delete`, body, options);
1774
+ }
1775
+ /** Replaces tags on an object or object version. */
1776
+ setTags(bucketId, body, options) {
1777
+ return this._put(path`/buckets/${bucketId}/objects/tags`, body, options);
1778
+ }
1779
+ /** Sets retention or legal hold on an object or object version. */
1780
+ setLock(bucketId, body, options) {
1781
+ return this._put(path`/buckets/${bucketId}/objects/lock`, body, options);
1782
+ }
1783
+ /** Sets whether a specific object is publicly readable and returns its `public_url`. */
1784
+ setVisibility(bucketId, body, options) {
1785
+ return this._put(path`/buckets/${bucketId}/objects/visibility`, body, options);
1786
+ }
1787
+ };
1788
+ var BucketMultipart = class extends APIResource {
1789
+ /** Starts a multipart upload session for a large object. Sent once: not retried on error. */
1790
+ start(bucketId, body, options) {
1791
+ return this._post(path`/buckets/${bucketId}/objects/multipart/start`, body, options, { noRetry: true });
1792
+ }
1793
+ /** Mints a short-lived signed upload URL for one part of an active multipart upload. */
1794
+ signPart(bucketId, body, options) {
1795
+ return this._post(path`/buckets/${bucketId}/objects/multipart/sign-part`, body, options);
1796
+ }
1797
+ /** Uploads one part of an active multipart upload as raw bytes. */
1798
+ uploadPart(bucketId, params, body, options) {
1799
+ return this._request(
1800
+ "PUT",
1801
+ path`/buckets/${bucketId}/objects/multipart/part`,
1802
+ { query: params, rawBody: body },
1803
+ options
1804
+ );
1805
+ }
1806
+ /** Completes a multipart upload from its uploaded part ETags. Sent once: not retried on error. */
1807
+ complete(bucketId, body, options) {
1808
+ return this._post(path`/buckets/${bucketId}/objects/multipart/complete`, body, options, { noRetry: true });
1809
+ }
1810
+ /** Aborts an active multipart upload and discards uploaded parts. */
1811
+ abort(bucketId, body, options) {
1812
+ return this._post(path`/buckets/${bucketId}/objects/multipart/abort`, body, options);
1813
+ }
1814
+ };
1815
+
981
1816
  // src/resources/operations.ts
982
1817
  function operationId(ref) {
983
1818
  const id = typeof ref === "string" ? ref : ref.operation_id;
@@ -1131,6 +1966,89 @@ var PortForwardingRules = class extends APIResource {
1131
1966
  }
1132
1967
  };
1133
1968
 
1969
+ // src/resources/registry.ts
1970
+ var Registry = class extends APIResource {
1971
+ /** Your organization's namespace, which every image name starts with. */
1972
+ namespace = new RegistryNamespaces(this._client);
1973
+ /** Repositories in your namespace. */
1974
+ repositories = new RegistryRepositories(this._client);
1975
+ /** Tags of a repository, and the images they point at. */
1976
+ tags = new RegistryTags(this._client);
1977
+ /** Registry-only credentials for CI and clusters. */
1978
+ tokens = new RegistryTokens(this._client);
1979
+ };
1980
+ var RegistryNamespaces = class extends APIResource {
1981
+ /** The namespace with its usage and limits. Rejects with `404 REGISTRY_NAMESPACE_NOT_SET` until one is claimed. */
1982
+ get(options) {
1983
+ return this._get("/registry", void 0, options);
1984
+ }
1985
+ /** Claims the namespace, or changes it or `create_on_push`. The name is fixed once a repository exists. */
1986
+ set(body, options) {
1987
+ return this._put("/registry", body, options);
1988
+ }
1989
+ };
1990
+ var RegistryRepositories = class extends APIResource {
1991
+ list(params = {}, options) {
1992
+ return this._get("/registry/repositories", params, options);
1993
+ }
1994
+ listAll(params = {}, options) {
1995
+ return this._listAll("/registry/repositories", params, options);
1996
+ }
1997
+ /** Creates a repository, private unless `visibility` is `public`. */
1998
+ create(body, options) {
1999
+ return this._post("/registry/repositories", body, options);
2000
+ }
2001
+ get(repositoryId, options) {
2002
+ return this._get(path`/registry/repositories/${repositoryId}`, void 0, options);
2003
+ }
2004
+ /** Changes the description, visibility, tag immutability or retention policy. */
2005
+ update(repositoryId, body, options) {
2006
+ return this._patch(path`/registry/repositories/${repositoryId}`, body, options);
2007
+ }
2008
+ /** Deletes the repository and every image in it. */
2009
+ delete(repositoryId, options) {
2010
+ return this._delete(path`/registry/repositories/${repositoryId}`, options);
2011
+ }
2012
+ };
2013
+ var RegistryTags = class extends APIResource {
2014
+ /** A repository's tags, newest push first. */
2015
+ list(repositoryId, params = {}, options) {
2016
+ return this._get(path`/registry/repositories/${repositoryId}/tags`, params, options);
2017
+ }
2018
+ listAll(repositoryId, params = {}, options) {
2019
+ return this._listAll(path`/registry/repositories/${repositoryId}/tags`, params, options);
2020
+ }
2021
+ get(repositoryId, tag, options) {
2022
+ return this._get(path`/registry/repositories/${repositoryId}/tags/${tag}`, void 0, options);
2023
+ }
2024
+ /** Removes the tag. Rejected with `409 TAG_IMMUTABLE` in a repository with immutable tags. */
2025
+ delete(repositoryId, tag, options) {
2026
+ return this._delete(path`/registry/repositories/${repositoryId}/tags/${tag}`, options);
2027
+ }
2028
+ };
2029
+ var RegistryTokens = class extends APIResource {
2030
+ /** Your registry tokens, without their secrets. */
2031
+ list(params = {}, options) {
2032
+ return this._get("/registry/tokens", params, options);
2033
+ }
2034
+ listAll(params = {}, options) {
2035
+ return this._listAll("/registry/tokens", params, options);
2036
+ }
2037
+ /**
2038
+ * Creates a token for `docker login`: `pull`, or `push` (which includes
2039
+ * pull), for every repository or only `repositories`. Its `secret` is in
2040
+ * this response alone. It is non-enumerable: `token.secret` reads it, but
2041
+ * console.log and JSON.stringify leave it out.
2042
+ */
2043
+ async create(body, options) {
2044
+ return hideSecrets(await this._post("/registry/tokens", body, options));
2045
+ }
2046
+ /** Revokes the token: logins stop at once, and access already granted ends within 5 minutes. */
2047
+ delete(tokenId, options) {
2048
+ return this._delete(path`/registry/tokens/${tokenId}`, options);
2049
+ }
2050
+ };
2051
+
1134
2052
  // src/resources/security-groups.ts
1135
2053
  var SecurityGroups = class extends APIResource {
1136
2054
  list(params = {}, options) {
@@ -1325,7 +2243,7 @@ var WebhookDeliveries = class extends APIResource {
1325
2243
  };
1326
2244
 
1327
2245
  // src/version.ts
1328
- var VERSION = "0.3.0";
2246
+ var VERSION = "0.5.0";
1329
2247
 
1330
2248
  // src/client.ts
1331
2249
  var DEFAULT_BASE_URL = "https://api.pantechdynamics.com/public/v1";
@@ -1333,6 +2251,12 @@ var DEFAULT_TIMEOUT_MS = 6e4;
1333
2251
  var DEFAULT_MAX_RETRIES = 3;
1334
2252
  var MAX_RETRY_AFTER_MS = 6e4;
1335
2253
  var RETRY_STATUSES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
2254
+ var ACCEPT = {
2255
+ json: "application/json",
2256
+ arrayBuffer: "application/octet-stream",
2257
+ text: "text/dns, text/plain;q=0.9",
2258
+ response: "application/json"
2259
+ };
1336
2260
  var Pantech = class {
1337
2261
  baseURL;
1338
2262
  maxRetries;
@@ -1372,6 +2296,20 @@ var Pantech = class {
1372
2296
  webhooks;
1373
2297
  /** Move from another cloud: connections, scans and migration plans. */
1374
2298
  migrate;
2299
+ /** Pantech DNS: hosted zones and their records, on Pantech's own name servers. */
2300
+ dns;
2301
+ /** Domains: search, register, transfer in, renew and configure. */
2302
+ domains;
2303
+ /** The private container registry: namespace, repositories, tags and registry tokens. */
2304
+ registry;
2305
+ /** Teams and access policies: who may do what, on which resources. */
2306
+ iam;
2307
+ /** TLS certificates Pantech issues and renews, or ones you import. */
2308
+ certificates;
2309
+ /** S3-compatible object storage: status, usage and access keys. */
2310
+ objectStorage;
2311
+ /** Object storage buckets, objects, multipart uploads and bucket rules. */
2312
+ buckets;
1375
2313
  operations;
1376
2314
  constructor(options = {}) {
1377
2315
  const apiKey = options.apiKey ?? readEnv("PANTECH_API_KEY");
@@ -1414,6 +2352,13 @@ var Pantech = class {
1414
2352
  this.sshKeys = new SshKeys(this);
1415
2353
  this.webhooks = new Webhooks(this);
1416
2354
  this.migrate = new Migrate(this);
2355
+ this.dns = new DNS(this);
2356
+ this.domains = new Domains(this);
2357
+ this.registry = new Registry(this);
2358
+ this.iam = new IAM(this);
2359
+ this.certificates = new Certificates(this);
2360
+ this.objectStorage = new ObjectStorage(this);
2361
+ this.buckets = new Buckets(this);
1417
2362
  }
1418
2363
  /**
1419
2364
  * Sends one request and returns its decoded body (undefined for an empty
@@ -1425,12 +2370,17 @@ var Pantech = class {
1425
2370
  const isWrite = req.method !== "GET";
1426
2371
  const headers = {
1427
2372
  ...this.#headers,
1428
- Accept: req.responseType === "arrayBuffer" ? "*/*" : "application/json",
2373
+ Accept: ACCEPT[req.responseType ?? "json"],
1429
2374
  ...options.headers,
1430
2375
  Authorization: `Bearer ${this.#apiKey}`
1431
2376
  };
1432
2377
  let payload;
1433
- if (req.body !== void 0) {
2378
+ if (req.rawBody !== void 0) {
2379
+ payload = req.rawBody;
2380
+ if (!hasHeader(headers, "content-type")) {
2381
+ headers["Content-Type"] = "application/octet-stream";
2382
+ }
2383
+ } else if (req.body !== void 0) {
1434
2384
  payload = JSON.stringify(req.body);
1435
2385
  headers["Content-Type"] = "application/json";
1436
2386
  }
@@ -1488,6 +2438,9 @@ var Pantech = class {
1488
2438
  }
1489
2439
  }
1490
2440
  };
2441
+ function hasHeader(headers, name) {
2442
+ return Object.keys(headers).some((key) => key.toLowerCase() === name);
2443
+ }
1491
2444
  function queryString(query) {
1492
2445
  if (!query) return "";
1493
2446
  const params = new URLSearchParams();
@@ -1501,6 +2454,7 @@ function queryString(query) {
1501
2454
  async function readBody(res, type) {
1502
2455
  if (type === "response") return res;
1503
2456
  if (type === "arrayBuffer") return res.arrayBuffer();
2457
+ if (type === "text") return res.text();
1504
2458
  const text = await res.text();
1505
2459
  if (res.status === 204 || text === "") return void 0;
1506
2460
  try {
@@ -1556,6 +2510,59 @@ function linkSignal(parent, timeout) {
1556
2510
  };
1557
2511
  }
1558
2512
 
2513
+ // src/iam.ts
2514
+ var SID = /^[A-Za-z0-9_-]{1,64}$/;
2515
+ var MAX_ITEMS = 50;
2516
+ var MAX_SOURCE_IPS = 20;
2517
+ var MANAGED_POLICY_IDS = [
2518
+ "pol_pantech_read_only",
2519
+ "pol_pantech_developer",
2520
+ "pol_pantech_network_admin",
2521
+ "pol_pantech_database_admin",
2522
+ "pol_pantech_dns_manager",
2523
+ "pol_pantech_domain_manager",
2524
+ "pol_pantech_registry_push",
2525
+ "pol_pantech_registry_pull",
2526
+ "pol_pantech_billing_manager",
2527
+ "pol_pantech_support",
2528
+ "pol_pantech_deny_delete",
2529
+ "pol_pantech_require_mfa_for_writes"
2530
+ ];
2531
+ function strings(name, values, limit) {
2532
+ if (!Array.isArray(values)) throw new TypeError(`${name} must be an array of strings.`);
2533
+ if (values.length === 0) throw new RangeError(`${name} needs at least one entry.`);
2534
+ if (values.length > limit) throw new RangeError(`${name} takes at most ${limit} entries, got ${values.length}.`);
2535
+ for (const v of values) {
2536
+ if (typeof v !== "string" || v === "") throw new TypeError(`${name} entries must be non-empty strings.`);
2537
+ }
2538
+ return [...values];
2539
+ }
2540
+ function statement(effect, actions, resources = ["*"], options = {}) {
2541
+ if (effect !== "allow" && effect !== "deny") throw new TypeError(`effect must be "allow" or "deny".`);
2542
+ const out = {
2543
+ effect,
2544
+ actions: strings("actions", actions, MAX_ITEMS),
2545
+ resources: strings("resources", resources, MAX_ITEMS)
2546
+ };
2547
+ if (options.sid !== void 0) {
2548
+ if (!SID.test(options.sid)) throw new RangeError("sid must be 1 to 64 letters, digits, '_' or '-'.");
2549
+ out.sid = options.sid;
2550
+ }
2551
+ const conditions = {};
2552
+ if (options.sourceIp !== void 0) conditions.source_ip = strings("sourceIp", options.sourceIp, MAX_SOURCE_IPS);
2553
+ if (options.mfa !== void 0) conditions.mfa = options.mfa;
2554
+ if (Object.keys(conditions).length > 0) out.conditions = conditions;
2555
+ return out;
2556
+ }
2557
+ var iam = {
2558
+ /** An `allow` statement: `iam.allow(["instances:Start"], ["name:staging-*"])`. */
2559
+ allow: (actions, resources, options) => statement("allow", actions, resources, options),
2560
+ /** A `deny` statement, which wins over every allow: `iam.deny(["*:Delete"])`. */
2561
+ deny: (actions, resources, options) => statement("deny", actions, resources, options),
2562
+ statement,
2563
+ MANAGED_POLICY_IDS
2564
+ };
2565
+
1559
2566
  // src/webhooks.ts
1560
2567
  var WEBHOOK_SIGNATURE_HEADER = "Pantech-Signature";
1561
2568
  var DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
@@ -1629,6 +2636,6 @@ async function signWebhook(options) {
1629
2636
  return `t=${t},v1=${await hmacHex(options.secret, t, bytes(options.body))}`;
1630
2637
  }
1631
2638
 
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 };
2639
+ 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
2640
  //# sourceMappingURL=index.js.map
1634
2641
  //# sourceMappingURL=index.js.map