@wtfalch/edge 0.10.0 → 0.12.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/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type ClientOptions } from './transport.js';
2
- import type { AccessProviderView, AccessReadinessResponse, AdoptAccessAppsRequest, AdoptAccessAppsResponse, AdoptRateLimitRulesRequest, AdoptRateLimitRulesResponse, AdoptRecordsRequest, AdoptRecordsResponse, AdoptTunnelsRequest, AdoptTunnelsResponse, AdoptWorkersRequest, AdoptWorkersResponse, AdoptZonesRequest, AdoptZonesResponse, AvailableResponse, ClaimNameRequest, CreatePlatformAccessAppRequest, CreatePlatformAccessPolicyRequest, CreatePlatformGateRequest, CreatePlatformRateLimitRuleRequest, CreatePlatformRecordRequest, CreatePlatformTunnelRequest, CreatePlatformWorkerRouteRequest, CreatePlatformZoneRequest, EnsureAccessProviderRequest, FindServiceTokenResponse, ListClaimsResponse, ListGatesResponse, ListPlatformAccessAppsRequest, ListPlatformAccessAppsResponse, ListPlatformAccessPoliciesResponse, ListPlatformRateLimitRulesRequest, ListPlatformRateLimitRulesResponse, ListPlatformRecordsRequest, ListPlatformRecordsResponse, ListPlatformTunnelsResponse, ListPlatformWorkerRoutesRequest, ListPlatformWorkerRoutesResponse, ListPlatformWorkerScriptsResponse, ListPlatformZonesRequest, ListPlatformZonesResponse, ListRecordsResponse, MintKeyRequest, MintKeyResponse, NameClaim, OrgSettingsRequest, PlatformAccessAppView, PlatformAccessPolicyView, PlatformGateView, PlatformRateLimitRuleView, PlatformRecordView, PlatformTunnelView, PlatformWorkerRouteView, PlatformWorkerScriptView, PlatformZoneView, PutPlatformTunnelConfigRequest, RecordInput, RecordPatch, RecordView, ReplacePlatformGateHostnamesRequest, SetGatePeopleResponse, TokenResponse, UpdatePlatformRecordRequest, UploadPlatformWorkerScriptRequest } from './types.js';
2
+ import type { AccessProviderView, AccessReadinessResponse, AdoptAccessAppsRequest, AdoptAccessAppsResponse, AdoptRateLimitRulesRequest, AdoptRateLimitRulesResponse, AdoptRecordsRequest, AdoptRecordsResponse, AdoptTunnelsRequest, AdoptTunnelsResponse, AdoptWorkersRequest, AdoptWorkersResponse, AdoptZonesRequest, AdoptZonesResponse, AvailableResponse, ClaimNameRequest, CreatePlatformAccessAppRequest, CreatePlatformAccessPolicyRequest, CreatePlatformGateRequest, CreatePlatformRateLimitRuleRequest, CreatePlatformRecordRequest, CreatePlatformServiceTokenRequest, CreatePlatformServiceTokenResponse, CreatePlatformTunnelRequest, CreatePlatformWorkerRouteRequest, CreatePlatformZoneRequest, EnsureAccessProviderRequest, FindServiceTokenResponse, ListClaimsResponse, ListGatesResponse, ListPlatformAccessAppsRequest, ListPlatformAccessAppsResponse, ListPlatformAccessPoliciesResponse, ListPlatformRateLimitRulesRequest, ListPlatformRateLimitRulesResponse, ListPlatformRecordsRequest, ListPlatformRecordsResponse, ListPlatformTunnelsResponse, ListPlatformWorkerRoutesRequest, ListPlatformWorkerRoutesResponse, ListPlatformWorkerScriptsResponse, ListPlatformZonesRequest, ListPlatformZonesResponse, ListRecordsResponse, MintKeyRequest, MintKeyResponse, NameClaim, OrgSettingsRequest, PlatformAccessAppView, PlatformAccessPolicyView, PlatformGateView, PlatformRateLimitRuleView, PlatformRecordView, PlatformTunnelView, PlatformWorkerRouteView, PlatformWorkerScriptView, PlatformZoneView, PutPlatformTunnelConfigRequest, RecordInput, RecordPatch, RecordView, ReplacePlatformGateHostnamesRequest, SetGatePeopleResponse, SetPlatformWorkerSchedulesRequest, SetPlatformWorkerSchedulesResponse, SetPlatformWorkerSecretsRequest, SetPlatformWorkerSecretsResponse, TokenResponse, UpdatePlatformRecordRequest, UploadPlatformWorkerScriptRequest } from './types.js';
3
3
  export { EdgeApiError, type ClientOptions } from './transport.js';
4
4
  /** Called with an entry's key: the key carries its organisation and domain, so
5
5
  * no call names either. `setReservedLabels`, `mintKey` and `revokeKey` are
@@ -9,9 +9,9 @@ export declare function createEdgeClient(options: ClientOptions): {
9
9
  gates: {
10
10
  /** The org's gates, each with the people who pass it now. */
11
11
  list: () => Promise<ListGatesResponse>;
12
- /** Replaces the people who pass a gate with `emails` (1 to 1000), then ends
13
- * the sessions of each person dropped. `notRevoked` names any whose session
14
- * could not be ended; the list is replaced regardless. */
12
+ /** Replaces the people who pass a gate with `emails` (1 to 1000), then when
13
+ * the list drops anyone, ends every session on the gate. `revoked` is false
14
+ * when that did not happen; the list is replaced regardless. */
15
15
  setPeople: (id: string, emails: string[]) => Promise<SetGatePeopleResponse>;
16
16
  };
17
17
  /** The org's DNS records. Needs `records:read` (`records:edit` for changes). */
@@ -90,6 +90,15 @@ export declare function createEdgeClient(options: ClientOptions): {
90
90
  /** A service token's id by exact name; `token` is `null` when none has
91
91
  * it. Read-only: the secret is never returned. */
92
92
  findServiceToken: (name: string) => Promise<FindServiceTokenResponse>;
93
+ /** Makes a service token that never expires and returns its client id
94
+ * and secret, once; edge keeps neither. Rejects with `conflict` when a token of that name
95
+ * exists at Cloudflare. After a lost reply the token exists but the
96
+ * secret is gone: `findServiceToken(name)`, `removeServiceToken(id)`,
97
+ * then create again. */
98
+ createServiceToken: (input: CreatePlatformServiceTokenRequest) => Promise<CreatePlatformServiceTokenResponse>;
99
+ /** Deletes a service token edge made; any other rejects with `not_found`.
100
+ * One already gone at Cloudflare counts as deleted. */
101
+ removeServiceToken: (id: string) => Promise<void>;
93
102
  /** Writes platform rows for the live apps named. Nothing is deleted or
94
103
  * recreated, and an app nobody names is left alone. */
95
104
  adopt: (input: AdoptAccessAppsRequest) => Promise<AdoptAccessAppsResponse>;
@@ -156,7 +165,16 @@ export declare function createEdgeClient(options: ClientOptions): {
156
165
  * with `invalid_request` when the script is not base64 or its sha256
157
166
  * differs from `artifactSha256`. */
158
167
  uploadScript: (name: string, input: UploadPlatformWorkerScriptRequest) => Promise<PlatformWorkerScriptView>;
159
- /** Deletes the script; returns the tombstone. Repeating it rejects with `not_found`. */
168
+ /** Sets the script's cron triggers to exactly `crons` (an empty list
169
+ * clears them). Safe to repeat. Rejects with `not_found` when edge does
170
+ * not own an active script of that name, and `invalid_request` for a bad expression. */
171
+ setSchedules: (name: string, input: SetPlatformWorkerSchedulesRequest) => Promise<SetPlatformWorkerSchedulesResponse>;
172
+ /** Sets secret_text bindings on the script. Write-only: no response, audit
173
+ * row or error carries a value. A secret whose `version` equals the stored
174
+ * one is skipped (`changed: false`); a new version sets the value again.
175
+ * Survives `uploadScript` redeploys. Deleting the script removes them. */
176
+ setSecrets: (name: string, input: SetPlatformWorkerSecretsRequest) => Promise<SetPlatformWorkerSecretsResponse>;
177
+ /** Deletes the script, its cron triggers and the KV namespaces edge created for it; returns the tombstone. Repeating it rejects with `not_found`. */
160
178
  removeScript: (name: string) => Promise<PlatformWorkerScriptView>;
161
179
  /** Every live route in the zone with its owner (`null`: no row), optionally only one pattern. */
162
180
  listRoutes: (filter: ListPlatformWorkerRoutesRequest) => Promise<ListPlatformWorkerRoutesResponse>;
package/dist/client.js CHANGED
@@ -14,9 +14,9 @@ export function createEdgeClient(options) {
14
14
  gates: {
15
15
  /** The org's gates, each with the people who pass it now. */
16
16
  list: () => call('GET', '/v1/gates'),
17
- /** Replaces the people who pass a gate with `emails` (1 to 1000), then ends
18
- * the sessions of each person dropped. `notRevoked` names any whose session
19
- * could not be ended; the list is replaced regardless. */
17
+ /** Replaces the people who pass a gate with `emails` (1 to 1000), then when
18
+ * the list drops anyone, ends every session on the gate. `revoked` is false
19
+ * when that did not happen; the list is replaced regardless. */
20
20
  setPeople: (id, emails) => call('PUT', `/v1/gates/${encodeURIComponent(id)}/people`, {
21
21
  emails,
22
22
  }),
@@ -95,6 +95,15 @@ export function createEdgeClient(options) {
95
95
  /** A service token's id by exact name; `token` is `null` when none has
96
96
  * it. Read-only: the secret is never returned. */
97
97
  findServiceToken: (name) => call('GET', `/v1/platform/access/service-tokens?${new URLSearchParams({ name })}`),
98
+ /** Makes a service token that never expires and returns its client id
99
+ * and secret, once; edge keeps neither. Rejects with `conflict` when a token of that name
100
+ * exists at Cloudflare. After a lost reply the token exists but the
101
+ * secret is gone: `findServiceToken(name)`, `removeServiceToken(id)`,
102
+ * then create again. */
103
+ createServiceToken: (input) => call('POST', '/v1/platform/access/service-tokens', input),
104
+ /** Deletes a service token edge made; any other rejects with `not_found`.
105
+ * One already gone at Cloudflare counts as deleted. */
106
+ removeServiceToken: (id) => call('DELETE', `/v1/platform/access/service-tokens/${encodeURIComponent(id)}`),
98
107
  /** Writes platform rows for the live apps named. Nothing is deleted or
99
108
  * recreated, and an app nobody names is left alone. */
100
109
  adopt: (input) => call('POST', '/v1/platform/access/apps/adopt', input),
@@ -159,7 +168,16 @@ export function createEdgeClient(options) {
159
168
  * with `invalid_request` when the script is not base64 or its sha256
160
169
  * differs from `artifactSha256`. */
161
170
  uploadScript: (name, input) => call('PUT', `/v1/platform/workers/scripts/${encodeURIComponent(name)}`, input),
162
- /** Deletes the script; returns the tombstone. Repeating it rejects with `not_found`. */
171
+ /** Sets the script's cron triggers to exactly `crons` (an empty list
172
+ * clears them). Safe to repeat. Rejects with `not_found` when edge does
173
+ * not own an active script of that name, and `invalid_request` for a bad expression. */
174
+ setSchedules: (name, input) => call('PUT', `/v1/platform/workers/scripts/${encodeURIComponent(name)}/schedules`, input),
175
+ /** Sets secret_text bindings on the script. Write-only: no response, audit
176
+ * row or error carries a value. A secret whose `version` equals the stored
177
+ * one is skipped (`changed: false`); a new version sets the value again.
178
+ * Survives `uploadScript` redeploys. Deleting the script removes them. */
179
+ setSecrets: (name, input) => call('PUT', `/v1/platform/workers/scripts/${encodeURIComponent(name)}/secrets`, input),
180
+ /** Deletes the script, its cron triggers and the KV namespaces edge created for it; returns the tombstone. Repeating it rejects with `not_found`. */
163
181
  removeScript: (name) => call('DELETE', `/v1/platform/workers/scripts/${encodeURIComponent(name)}`),
164
182
  /** Every live route in the zone with its owner (`null`: no row), optionally only one pattern. */
165
183
  listRoutes: (filter) => call('GET', `/v1/platform/workers/routes?${new URLSearchParams(Object.entries(filter).filter((entry) => entry[1] !== undefined))}`),
package/dist/types.d.ts CHANGED
@@ -376,15 +376,19 @@ export interface AccessProviderView {
376
376
  id: string;
377
377
  name: string;
378
378
  }
379
- /** Whether the Cloudflare token holds every Access right gates need. A token that lacks one rejects with `not_configured`, naming each missing right. */
379
+ /** Whether the Cloudflare token holds every Access right gates need. A token that lacks one, or an organisation with no team address, rejects with `not_configured`, naming each missing right. */
380
380
  export interface AccessReadinessResponse {
381
381
  ready: true;
382
+ /** The Access organisation's team address, for example `team.cloudflareaccess.com`. */
383
+ authDomain: string;
382
384
  }
383
385
  /** Makes a company's gate: an application over `hostnames`, a group of `emails`, and a policy that requires the provider and one OIDC claim. */
384
386
  export interface CreatePlatformGateRequest {
385
387
  organisationId: string;
386
388
  /** A lower-case DNS label, unique in the company. */
387
389
  key: string;
390
+ /** The key of the app entry that declared the gate: a lower-case DNS label. */
391
+ entry: string;
388
392
  /** The hostnames the gate covers, a leading `*.` allowed. */
389
393
  hostnames: string[];
390
394
  /** The provider's id from `ensureProvider`. */
@@ -402,6 +406,8 @@ export interface PlatformGateView {
402
406
  id: string;
403
407
  organisationId: string;
404
408
  key: string;
409
+ /** The key of the app entry that declared the gate. */
410
+ entry: string;
405
411
  hostnames: string[];
406
412
  providerId: string;
407
413
  applicationId: string;
@@ -412,6 +418,8 @@ export interface GateView {
412
418
  /** Edge's gate id: what `setPeople` takes. */
413
419
  id: string;
414
420
  key: string;
421
+ /** The key of the app entry that declared the gate. */
422
+ entry: string;
415
423
  hostnames: string[];
416
424
  /** The addresses that pass the gate, lower-case. */
417
425
  people: string[];
@@ -425,8 +433,8 @@ export interface SetGatePeopleRequest {
425
433
  }
426
434
  /** The gate with its new people. The list is replaced even when a revoke fails. */
427
435
  export interface SetGatePeopleResponse extends GateView {
428
- /** Addresses the new list dropped whose sessions could not be ended. Empty when all were. */
429
- notRevoked: string[];
436
+ /** Whether this call ended every session on the gate. False when nobody was dropped, or when Cloudflare refused: the next update tries again. */
437
+ revoked: boolean;
430
438
  }
431
439
  /** A service token's id and name. Its secret is never returned. */
432
440
  export interface FindServiceTokenResponse {
@@ -435,6 +443,18 @@ export interface FindServiceTokenResponse {
435
443
  name: string;
436
444
  } | null;
437
445
  }
446
+ export interface CreatePlatformServiceTokenRequest {
447
+ name: string;
448
+ }
449
+ /** `clientId` and `clientSecret` are shown once, here. Edge keeps neither and cannot return them again. */
450
+ export interface CreatePlatformServiceTokenResponse {
451
+ token: {
452
+ id: string;
453
+ name: string;
454
+ };
455
+ clientId: string;
456
+ clientSecret: string;
457
+ }
438
458
  export interface AdoptAccessAppEntry {
439
459
  name: string;
440
460
  /** Narrows several apps of one name. */
@@ -486,6 +506,23 @@ export interface WorkerRateLimitBinding {
486
506
  period: number;
487
507
  };
488
508
  }
509
+ /** A KV namespace bound to the script as `name`. Edge finds the namespace by
510
+ * `title`, reuses it when it exists and creates it when it does not. A
511
+ * namespace edge created is deleted with the script; one it only reused is kept. */
512
+ export interface WorkerKvBinding {
513
+ type: 'kv_namespace';
514
+ name: string;
515
+ /** 1 to 100 letters, digits, `.`, `_` or `-`. Unique in the account; one script holds it. */
516
+ title: string;
517
+ }
518
+ /** An environment binding whose value is not secret (at most 5120 characters). */
519
+ export interface WorkerPlainTextBinding {
520
+ type: 'plain_text';
521
+ name: string;
522
+ text: string;
523
+ }
524
+ /** Everything `uploadScript` accepts in `bindings`. Secrets are not here: see `setSecrets`. */
525
+ export type WorkerBinding = WorkerRateLimitBinding | WorkerKvBinding | WorkerPlainTextBinding;
489
526
  /** Uploads (or redeploys) a script. Edge fetches nothing: the caller sends the
490
527
  * script, edge checks its size and sha256, and sends it to Cloudflare. The body
491
528
  * is never stored or returned. */
@@ -496,10 +533,48 @@ export interface UploadPlatformWorkerScriptRequest {
496
533
  artifactSha256: string;
497
534
  /** Like `2026-10-01`. */
498
535
  compatibilityDate: string;
499
- bindings?: WorkerRateLimitBinding[];
536
+ /** The script's bindings, all of them: a redeploy replaces the list. Secrets set by `setSecrets` survive a redeploy. */
537
+ bindings?: WorkerBinding[];
500
538
  /** The company the script serves. Omit for a script that serves none. */
501
539
  organisationId?: string;
502
540
  }
541
+ /** Replaces the script's cron triggers with exactly `crons`. An empty list clears them. */
542
+ export interface SetPlatformWorkerSchedulesRequest {
543
+ /** Up to 50 expressions of five fields, like `* * * * *`. Duplicates collapse. */
544
+ crons: string[];
545
+ }
546
+ export interface SetPlatformWorkerSchedulesResponse {
547
+ name: string;
548
+ /** The list now set, de-duplicated and sorted. */
549
+ crons: string[];
550
+ }
551
+ /** One secret_text binding. `value` goes to Cloudflare and is never stored,
552
+ * returned, audited or logged. `version` is a label you choose and keep, such
553
+ * as a rotation counter or a fingerprint of a high-entropy secret. Edge stores
554
+ * it beside the name: the same version is skipped, a new one sets `value` again.
555
+ * Do not use an unsalted hash of a guessable value. */
556
+ export interface PlatformWorkerSecretInput {
557
+ /** The binding name, like `UPTIME_TOKEN`. */
558
+ name: string;
559
+ /** 1 to 5120 bytes. */
560
+ value: string;
561
+ /** 1 to 128 printable characters. */
562
+ version: string;
563
+ }
564
+ export interface SetPlatformWorkerSecretsRequest {
565
+ /** 1 to 50 secrets, names unique. */
566
+ secrets: PlatformWorkerSecretInput[];
567
+ }
568
+ export interface PlatformWorkerSecretView {
569
+ name: string;
570
+ version: string;
571
+ /** False when the stored version equalled the one sent, so nothing was sent to Cloudflare. */
572
+ changed: boolean;
573
+ }
574
+ export interface SetPlatformWorkerSecretsResponse {
575
+ name: string;
576
+ secrets: PlatformWorkerSecretView[];
577
+ }
503
578
  /** A Workers route seen with the platform credential. `id` is Cloudflare's
504
579
  * route id, which every platform route call takes. */
505
580
  export interface PlatformWorkerRouteView {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/edge",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Public client SDK and API types for the edge service.",