@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 CHANGED
@@ -4,6 +4,65 @@ A new version heading here (`## X.Y.Z (YYYY-MM-DD)`) pushed to main is
4
4
  tagged `vX.Y.Z` and published to npm. Add changes under `## Unreleased`
5
5
  until then.
6
6
 
7
+ ## 0.4.0 (2026-11-10)
8
+
9
+ - `client.dns`, Pantech DNS on Pantech's own name servers (two per zone): `dns.zones` (`list`, `listAll`,
10
+ `create`, `get`, `update`, `delete`, `verify`, `exportZoneFile` returning the BIND zone file as
11
+ a string, `importZoneFile`) and `dns.records` (`list`, `listAll`, `create`, `get`, `update` and
12
+ `delete` with `{ ifMatch: version }`, `batch` for up to 1000 changes at once).
13
+ - `client.domains`: `listTlds`, `search`, `checkTransfer`, `list`, `listAll`, `get`, `register`,
14
+ `transfer`, `update` (auto-renew, transfer lock, privacy), `setNameServers`, `getContact`,
15
+ `updateContact`, `renew`, `requestAuthCode`, `getAuthCode`, and `domains.orders` (`list`, `get`).
16
+ - `dns.zones.wait()` (until the zone has its name servers) and `dns.records.wait()` (until the
17
+ record set answers), which reject with the new `DNSFailedError`, and `domains.orders.wait()`,
18
+ which rejects with `OrderFailedError` carrying the order's `failure_code`.
19
+ - `PreconditionFailedError` for `412` (`VERSION_CONFLICT`); `DNSErrorCode`, `DomainErrorCode`,
20
+ `DNS_ERROR_CODES` and `DOMAIN_ERROR_CODES` for every DNS and domain problem code.
21
+ - `examples/dns-and-domains.ts`.
22
+ - `client.registry`, the private container registry: `registry.namespace` (`get`, `set`),
23
+ `registry.repositories` (`list`, `listAll`, `create`, `get`, `update` for visibility, tag
24
+ immutability and retention, `delete`), `registry.tags` (`list`, `listAll`, `get`, `delete`) and
25
+ `registry.tokens` (`list`, `listAll`, `create`, `delete`). A new token's `secret` is
26
+ non-enumerable, so `console.log` and `JSON.stringify` leave it out; read `token.secret`.
27
+ - `RegistryErrorCode` and `REGISTRY_ERROR_CODES` for every registry problem code.
28
+ - `examples/container-registry.ts`.
29
+ - `client.iam`, teams and access policies: `iam.actions.list`, `iam.settings` (`get`, `update`),
30
+ `iam.teams` (`list`, `listAll`, `create`, `get`, `update`, `delete`) with `iam.teams.members`
31
+ (`list`, `listAll`, `add`, `remove`), `iam.policies` (`list`, `listAll`, `create`, `get`,
32
+ `update` with `{ ifMatch }`, `delete`) with `iam.policies.attachments` (`list`, `attach`,
33
+ `detach`), `iam.effectiveAccess(userId)` and `iam.simulate(...)`.
34
+ - The `iam` helper: `iam.allow(...)`, `iam.deny(...)` and `iam.statement(...)` build typed policy
35
+ statements and check the API's limits first; `iam.MANAGED_POLICY_IDS` lists Pantech's policies.
36
+ - `IamErrorCode` and `IAM_ERROR_CODES` for every access policy problem code; `IfMatchOptions` for
37
+ any change conditional on a version (`RecordWriteOptions` is now an alias of it).
38
+ - `examples/access-policies.ts`.
39
+ - `iam.members.list` / `listAll`: the organization's members with their teams and policy counts;
40
+ `iam.settings.update` takes `{ ifMatch }`.
41
+ - `client.certificates`, Certificate Manager: `list`, `listAll`, `request`, `import`, `get`,
42
+ `update`, `verify`, `reimport`, `export`, `revoke`, `delete`, and `wait(id)` until it is issued,
43
+ which rejects with the new `CertificateFailedError`. An exported `private_key_pem` is
44
+ non-enumerable, like a new registry token's `secret`.
45
+ - `CertificateErrorCode` and `CERTIFICATE_ERROR_CODES` for every certificate problem code.
46
+ - `examples/certificates.ts`.
47
+ - `dns.zones.quote()`: the free zone allowance and the monthly price of each further zone.
48
+ - `domains.orders.wait()` rejects with `PaymentRequiredError` (code `AWAITING_PAYMENT`, with
49
+ `paymentUrl`, `paymentExpiresAt` and `order`) when an order is `awaiting_payment` because your
50
+ credit does not cover it, instead of waiting silently; `{ waitForPayment: true }` keeps waiting
51
+ while the user pays. Domain orders carry `payment_url` and `payment_expires_at`; TLD offers and
52
+ search results carry `privacy_always_on`.
53
+ - `domains.orders.retryPayment(orderId)` (`POST /domain-orders/{order_id}/retry-payment`): an
54
+ order waiting in `awaiting_payment` tries its payment again at once and waits another hour; it
55
+ never charges twice. A `409` `DOMAIN_ORDER_NOT_AWAITING_PAYMENT` (in `DOMAIN_ERROR_CODES`) when
56
+ the order is not waiting for a payment. `payment_url` is now set only when the bank asks the
57
+ customer to confirm a saved-card payment in US dollars, so `PaymentRequiredError.paymentUrl`
58
+ can be undefined.
59
+ - HTTPS load balancers: `loadBalancers.create` and `update` take `protocol: "https"`,
60
+ `certificate_id`, `tls_policy` and `redirect_http`, and a load balancer reports
61
+ `certificate_fingerprint_sha256`.
62
+ - The vendored spec is the current public API, with DNS, domains, the container registry, IAM,
63
+ certificates and HTTPS load balancers, so `spec/pending/` is empty again. `npm run generate` and
64
+ the coverage test accept a missing `spec/pending/`.
65
+
7
66
  ## 0.3.0 (2026-11-06)
8
67
 
9
68
  - `KubernetesFixedNodeSize` and `fixed_node_sizes` on the Kubernetes versions list: the zones
package/README.md CHANGED
@@ -76,6 +76,11 @@ Every method takes per-call options last: `{ signal, timeout, maxRetries, idempo
76
76
  | SSH keys, webhooks | `sshKeys.*`, `webhooks.*`, `webhooks.deliveries.*` |
77
77
  | Billing and usage | `billing.credit.get()`, `billing.credit.purchases.create(...)`, `billing.receipts.getPdf(id)`, `usage.get()` |
78
78
  | Move from another cloud | `migrate.connections.*`, `migrate.scans.*`, `migrate.migrations.*` |
79
+ | DNS | `dns.zones.*` (`exportZoneFile`, `importZoneFile`, `verify`, `wait`), `dns.records.*` (`batch`, `wait`) |
80
+ | Certificates | `certificates.request/import/get/list/update/verify/reimport/export/revoke/delete`, `certificates.wait(id)` |
81
+ | Teams and access policies | `iam.members.list()`, `iam.actions.list()`, `iam.settings.*`, `iam.teams.*`, `iam.teams.members.*`, `iam.policies.*`, `iam.policies.attachments.*`, `iam.effectiveAccess(userId)`, `iam.simulate({...})` |
82
+ | Container registry | `registry.namespace.get/set`, `registry.repositories.*`, `registry.tags.*`, `registry.tokens.*` |
83
+ | Domains | `domains.search({ query })`, `domains.register({...})`, `domains.transfer({...})`, `domains.renew(id)`, `domains.orders.wait(result)` |
79
84
  | Operations | `operations.get(id)`, `operations.wait(id)`, `operations.stream(id)` |
80
85
 
81
86
  Every operation in the public spec has a method, except agent sessions, which answer only AI apps
@@ -104,7 +109,8 @@ for await (const o of client.operations.stream("op_…")) console.log(o.status);
104
109
 
105
110
  A failed operation rejects with `OperationFailedError` (`code`, `detail` from its `failure`), a
106
111
  failed or unpaid order with `OrderFailedError`, a failed cloud connection or scan with
107
- `CloudFailedError`, and a wait that runs out with `WaitTimeoutError`.
112
+ `CloudFailedError`, a failed DNS zone or record change with `DNSFailedError`, a certificate that
113
+ cannot be issued with `CertificateFailedError`, and a wait that runs out with `WaitTimeoutError`.
108
114
 
109
115
  ## Move from another cloud
110
116
 
@@ -127,6 +133,139 @@ const { files } = await client.migrate.migrations.exportTerraform(plan.id); // m
127
133
  `migrate.migrations.updateItem(id, { key, excluded: true })` leaves an item out, or changes its
128
134
  plan, size, address range or role, before you export. See `examples/migrate-from-aws.ts`.
129
135
 
136
+ ## Certificates
137
+
138
+ `client.certificates` issues TLS certificates through a publicly trusted CA and renews them by
139
+ itself, or holds certificates you import, for Pantech load balancers and your own servers.
140
+
141
+ ```ts
142
+ let cert = await client.certificates.request({ names: ["example.com", "*.example.com"], exportable: true });
143
+ for (const v of cert.validations) {
144
+ // Names outside your Pantech DNS zones: add this CNAME once.
145
+ if (v.method === "cname") console.log(v.cname_name, "CNAME", v.cname_target);
146
+ }
147
+ cert = await client.certificates.wait(cert.id); // CertificateFailedError if it cannot be issued
148
+
149
+ const exported = await client.certificates.export(cert.id); // needs the delete scope; owners are emailed
150
+ await writeKeyFile(exported.private_key_pem); // non-enumerable: console.log and JSON.stringify leave it out
151
+ ```
152
+
153
+ `certificates.import({ certificate_pem, private_key_pem })` imports one, `reimport` replaces it
154
+ before it expires, `verify` re-checks CNAMEs now, and `revoke` and `delete` retire it. The SDK never
155
+ logs request or response bodies, so an imported key is not logged either. See
156
+ `examples/certificates.ts`.
157
+
158
+ An appliance load balancer can end TLS with one: `client.loadBalancers.create({ …, protocol:
159
+ "https", certificate_id: cert.id, tls_policy: "modern", redirect_http: true })`; renewals reach it
160
+ by themselves. VPC native load balancers pass TLS through as `tcp`, and a certificate in use cannot
161
+ be revoked or deleted (`CERTIFICATE_IN_USE`).
162
+
163
+ ## Teams and access policies
164
+
165
+ `client.iam` controls who in your organization may do what. Policies are statements that allow or
166
+ deny actions (`instances:Stop`, `dns:*`, `*:Read`) on resources (`*`, an id, or `name:staging-*`),
167
+ optionally only from some addresses or with MFA; attach them to members or teams. The `iam` helper
168
+ builds statements and checks the API's limits before the call.
169
+
170
+ ```ts
171
+ import { iam } from "@pantechdynamic/sdk";
172
+
173
+ const team = await client.iam.teams.create({ name: "Platform" });
174
+ const policy = await client.iam.policies.create({
175
+ name: "staging-operators",
176
+ statements: [
177
+ iam.allow(["instances:Read", "instances:Start", "instances:Stop"], ["name:staging-*"], { sourceIp: ["102.89.0.0/16"] }),
178
+ iam.deny(["*:Delete"]),
179
+ ],
180
+ });
181
+ await client.iam.policies.attachments.attach(policy.id, { principal_type: "team", principal_id: team.id });
182
+ await client.iam.teams.members.add(team.id, "usr_…");
183
+
184
+ const sim = await client.iam.simulate({ user_id: "usr_…", action: "instances:Delete", resource: "vm_…" });
185
+ console.log(sim.allowed, sim.decision); // false "explicit_deny"
186
+ ```
187
+
188
+ `iam.policies.update(id, body, { ifMatch: policy.version })` refuses a lost update.
189
+ `iam.actions.list()` is the action catalogue, `iam.effectiveAccess(userId)` what applies to a
190
+ member, `iam.settings` the organization's `member_baseline`, and `iam.MANAGED_POLICY_IDS`
191
+ Pantech's ready-made policies. See `examples/access-policies.ts`.
192
+
193
+ ## Container registry
194
+
195
+ `client.registry` manages your private registry at `registry.pantechdynamics.com`: one namespace per
196
+ organization, repositories (private by default), their tags, and registry-only tokens for CI and
197
+ clusters. Push and pull with `docker`, logged in with an API key or a registry token.
198
+
199
+ ```ts
200
+ await client.registry.namespace.set({ name: "acme" }); // once; images are registry.pantechdynamics.com/acme/…
201
+ const repo = await client.registry.repositories.create({
202
+ name: "api/server",
203
+ immutable_tags: true,
204
+ retention: { keep_last: 50, keep_pattern: "v*" },
205
+ });
206
+ for await (const tag of client.registry.tags.listAll(repo.id)) console.log(tag.name, tag.digest);
207
+
208
+ const token = await client.registry.tokens.create({ name: "github-actions", permission: "push", repositories: ["api/server"] });
209
+ await saveToCiSecrets(token.secret); // shown only now (null on a replayed create)
210
+ ```
211
+
212
+ The token's `secret` is non-enumerable: `token.secret` reads it, but `console.log(token)` and
213
+ `JSON.stringify(token)` leave it out. `docker login registry.pantechdynamics.com -u pantech -p
214
+ <secret>` then works for that repository; `registry.tokens.delete(id)` revokes it. See
215
+ `examples/container-registry.ts`.
216
+
217
+ ## DNS and domains
218
+
219
+ `client.dns` hosts zones on Pantech DNS, Pantech's own name servers; `client.domains` buys,
220
+ transfers in and renews domains, paid from your credit. Each zone gets its own two name servers to
221
+ set at your registrar. Changes go live in the background: a record set is `pending` until it
222
+ answers, usually within a minute, and records added before the zone is `active` (delegated) stay
223
+ `pending` until it is. The first 5 zones are free; `client.dns.zones.quote()` gives the price of the
224
+ rest in your currency.
225
+
226
+ ```ts
227
+ let zone = await client.dns.zones.create({ name: "example.com" });
228
+ zone = await client.dns.zones.wait(zone.id); // until it has its name servers
229
+ console.log(zone.name_servers); // set these at your registrar
230
+
231
+ const rec = await client.dns.records.create(zone.id, { name: "www", type: "A", values: ["203.0.113.10"] });
232
+ await client.dns.records.wait(zone.id, rec.id); // DNSFailedError if the change fails
233
+
234
+ // Change it only if nobody else did since you read it (412 PreconditionFailedError otherwise).
235
+ await client.dns.records.update(zone.id, rec.id, { values: ["203.0.113.11"] }, { ifMatch: rec.version });
236
+
237
+ await client.dns.records.batch(zone.id, {
238
+ changes: [
239
+ { action: "create", record: { name: "@", type: "MX", values: ["10 mail.example.com"] } },
240
+ { action: "delete", record_id: "dnsr_…" },
241
+ ],
242
+ });
243
+ const zoneFile = await client.dns.zones.exportZoneFile(zone.id); // BIND zone file, as a string
244
+
245
+ const { data } = await client.domains.search({ query: "example" });
246
+ const result = await client.domains.register({ name: "example.com", contact, accept_terms: true });
247
+ try {
248
+ await client.domains.orders.wait(result); // OrderFailedError (amount refunded) if it fails
249
+ } catch (err) {
250
+ if (!(err instanceof PaymentRequiredError)) throw err;
251
+ // Your credit does not cover it: the order waits for a payment until err.paymentExpiresAt.
252
+ // In US dollars your saved card is charged the difference; in naira, add credit.
253
+ if (err.paymentUrl) sendUserTo(err.paymentUrl); // only when the bank asks to confirm the payment
254
+ await client.domains.orders.wait(result, { waitForPayment: true });
255
+ // Or, after saving a new card or adding credit: await client.domains.orders.retryPayment(result.order.id);
256
+ }
257
+ ```
258
+
259
+ Prices are before VAT. A TLD whose offer has `privacy_always_on: true` (the `.ng` family) has
260
+ privacy protection that cannot be turned off: asking for `privacy: false` is a `422` naming field
261
+ `privacy` with code `PRIVACY_ALWAYS_ON`. `.ng` contacts need `state` and `postal_code`, and
262
+ `name.ng` registrants must be people (`type: "person"`).
263
+
264
+ `domains` also has `listTlds`, `checkTransfer`, `update` (auto-renew, transfer lock, privacy),
265
+ `setNameServers`, `getContact`/`updateContact`, `requestAuthCode`/`getAuthCode`,
266
+ `orders.list(domainId)`, `orders.get(orderId)` and `orders.retryPayment(orderId)`. The registrant
267
+ contact is personal data: the SDK never logs requests or responses. See `examples/dns-and-domains.ts`.
268
+
130
269
  ## Errors
131
270
 
132
271
  Every error is a `PantechError` carrying `status`, `code`, `title`, `detail`, `requestId` and
@@ -145,9 +284,16 @@ try {
145
284
  ```
146
285
 
147
286
  Subclasses: `BadRequestError` (400), `AuthenticationError` (401), `PaymentRequiredError` (402),
148
- `PermissionDeniedError` (403), `NotFoundError` (404), `ConflictError` (409), `ValidationError`
149
- (422), `RateLimitError` (429), `InternalServerError` (5xx), `APIConnectionError` and
150
- `APITimeoutError` (no answer).
287
+ `PermissionDeniedError` (403), `NotFoundError` (404), `ConflictError` (409),
288
+ `PreconditionFailedError` (412), `ValidationError` (422), `RateLimitError` (429),
289
+ `InternalServerError` (5xx), `APIConnectionError` and `APITimeoutError` (no answer).
290
+
291
+ DNS and domain codes are typed: `DNSErrorCode` and `DomainErrorCode` are unions of every code those
292
+ endpoints answer with (`DNS_RECORD_EXISTS`, `VERSION_CONFLICT`, `DOMAIN_NOT_AVAILABLE`…), listed at
293
+ runtime in `DNS_ERROR_CODES` and `DOMAIN_ERROR_CODES` (and `RegistryErrorCode`,
294
+ `REGISTRY_ERROR_CODES` for the container registry, `IamErrorCode`, `IAM_ERROR_CODES` for access
295
+ policies, `CertificateErrorCode`, `CERTIFICATE_ERROR_CODES` for certificates), and `isPantechError(err, code)` completes
296
+ them.
151
297
 
152
298
  ## Retries and idempotency
153
299
 
@@ -180,7 +326,8 @@ the timestamp is too old. On Node.js 18, start node with `--experimental-global-
180
326
 
181
327
  ## Examples
182
328
 
183
- `examples/` has `create-instance.ts`, `list.ts`, `webhook-receiver.ts` and `migrate-from-aws.ts`. With Node.js 23.6+:
329
+ `examples/` has `create-instance.ts`, `list.ts`, `webhook-receiver.ts`, `migrate-from-aws.ts`,
330
+ `dns-and-domains.ts`, `container-registry.ts`, `access-policies.ts` and `certificates.ts`. With Node.js 23.6+:
184
331
  `npm run build && PANTECH_API_KEY=PAN_… node examples/list.ts`.
185
332
 
186
333
  ## Development