@wtfalch/edge 0.10.0 → 0.11.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, 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). */
@@ -156,7 +156,16 @@ export declare function createEdgeClient(options: ClientOptions): {
156
156
  * with `invalid_request` when the script is not base64 or its sha256
157
157
  * differs from `artifactSha256`. */
158
158
  uploadScript: (name: string, input: UploadPlatformWorkerScriptRequest) => Promise<PlatformWorkerScriptView>;
159
- /** Deletes the script; returns the tombstone. Repeating it rejects with `not_found`. */
159
+ /** Sets the script's cron triggers to exactly `crons` (an empty list
160
+ * clears them). Safe to repeat. Rejects with `not_found` when edge does
161
+ * not own an active script of that name, and `invalid_request` for a bad expression. */
162
+ setSchedules: (name: string, input: SetPlatformWorkerSchedulesRequest) => Promise<SetPlatformWorkerSchedulesResponse>;
163
+ /** Sets secret_text bindings on the script. Write-only: no response, audit
164
+ * row or error carries a value. A secret whose `version` equals the stored
165
+ * one is skipped (`changed: false`); a new version sets the value again.
166
+ * Survives `uploadScript` redeploys. Deleting the script removes them. */
167
+ setSecrets: (name: string, input: SetPlatformWorkerSecretsRequest) => Promise<SetPlatformWorkerSecretsResponse>;
168
+ /** Deletes the script, its cron triggers and the KV namespaces edge created for it; returns the tombstone. Repeating it rejects with `not_found`. */
160
169
  removeScript: (name: string) => Promise<PlatformWorkerScriptView>;
161
170
  /** Every live route in the zone with its owner (`null`: no row), optionally only one pattern. */
162
171
  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
  }),
@@ -159,7 +159,16 @@ export function createEdgeClient(options) {
159
159
  * with `invalid_request` when the script is not base64 or its sha256
160
160
  * differs from `artifactSha256`. */
161
161
  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`. */
162
+ /** Sets the script's cron triggers to exactly `crons` (an empty list
163
+ * clears them). Safe to repeat. Rejects with `not_found` when edge does
164
+ * not own an active script of that name, and `invalid_request` for a bad expression. */
165
+ setSchedules: (name, input) => call('PUT', `/v1/platform/workers/scripts/${encodeURIComponent(name)}/schedules`, input),
166
+ /** Sets secret_text bindings on the script. Write-only: no response, audit
167
+ * row or error carries a value. A secret whose `version` equals the stored
168
+ * one is skipped (`changed: false`); a new version sets the value again.
169
+ * Survives `uploadScript` redeploys. Deleting the script removes them. */
170
+ setSecrets: (name, input) => call('PUT', `/v1/platform/workers/scripts/${encodeURIComponent(name)}/secrets`, input),
171
+ /** Deletes the script, its cron triggers and the KV namespaces edge created for it; returns the tombstone. Repeating it rejects with `not_found`. */
163
172
  removeScript: (name) => call('DELETE', `/v1/platform/workers/scripts/${encodeURIComponent(name)}`),
164
173
  /** Every live route in the zone with its owner (`null`: no row), optionally only one pattern. */
165
174
  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 {
@@ -486,6 +494,23 @@ export interface WorkerRateLimitBinding {
486
494
  period: number;
487
495
  };
488
496
  }
497
+ /** A KV namespace bound to the script as `name`. Edge finds the namespace by
498
+ * `title`, reuses it when it exists and creates it when it does not. A
499
+ * namespace edge created is deleted with the script; one it only reused is kept. */
500
+ export interface WorkerKvBinding {
501
+ type: 'kv_namespace';
502
+ name: string;
503
+ /** 1 to 100 letters, digits, `.`, `_` or `-`. Unique in the account; one script holds it. */
504
+ title: string;
505
+ }
506
+ /** An environment binding whose value is not secret (at most 5120 characters). */
507
+ export interface WorkerPlainTextBinding {
508
+ type: 'plain_text';
509
+ name: string;
510
+ text: string;
511
+ }
512
+ /** Everything `uploadScript` accepts in `bindings`. Secrets are not here: see `setSecrets`. */
513
+ export type WorkerBinding = WorkerRateLimitBinding | WorkerKvBinding | WorkerPlainTextBinding;
489
514
  /** Uploads (or redeploys) a script. Edge fetches nothing: the caller sends the
490
515
  * script, edge checks its size and sha256, and sends it to Cloudflare. The body
491
516
  * is never stored or returned. */
@@ -496,10 +521,48 @@ export interface UploadPlatformWorkerScriptRequest {
496
521
  artifactSha256: string;
497
522
  /** Like `2026-10-01`. */
498
523
  compatibilityDate: string;
499
- bindings?: WorkerRateLimitBinding[];
524
+ /** The script's bindings, all of them: a redeploy replaces the list. Secrets set by `setSecrets` survive a redeploy. */
525
+ bindings?: WorkerBinding[];
500
526
  /** The company the script serves. Omit for a script that serves none. */
501
527
  organisationId?: string;
502
528
  }
529
+ /** Replaces the script's cron triggers with exactly `crons`. An empty list clears them. */
530
+ export interface SetPlatformWorkerSchedulesRequest {
531
+ /** Up to 50 expressions of five fields, like `* * * * *`. Duplicates collapse. */
532
+ crons: string[];
533
+ }
534
+ export interface SetPlatformWorkerSchedulesResponse {
535
+ name: string;
536
+ /** The list now set, de-duplicated and sorted. */
537
+ crons: string[];
538
+ }
539
+ /** One secret_text binding. `value` goes to Cloudflare and is never stored,
540
+ * returned, audited or logged. `version` is a label you choose and keep, such
541
+ * as a rotation counter or a fingerprint of a high-entropy secret. Edge stores
542
+ * it beside the name: the same version is skipped, a new one sets `value` again.
543
+ * Do not use an unsalted hash of a guessable value. */
544
+ export interface PlatformWorkerSecretInput {
545
+ /** The binding name, like `UPTIME_TOKEN`. */
546
+ name: string;
547
+ /** 1 to 5120 bytes. */
548
+ value: string;
549
+ /** 1 to 128 printable characters. */
550
+ version: string;
551
+ }
552
+ export interface SetPlatformWorkerSecretsRequest {
553
+ /** 1 to 50 secrets, names unique. */
554
+ secrets: PlatformWorkerSecretInput[];
555
+ }
556
+ export interface PlatformWorkerSecretView {
557
+ name: string;
558
+ version: string;
559
+ /** False when the stored version equalled the one sent, so nothing was sent to Cloudflare. */
560
+ changed: boolean;
561
+ }
562
+ export interface SetPlatformWorkerSecretsResponse {
563
+ name: string;
564
+ secrets: PlatformWorkerSecretView[];
565
+ }
503
566
  /** A Workers route seen with the platform credential. `id` is Cloudflare's
504
567
  * route id, which every platform route call takes. */
505
568
  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.11.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Public client SDK and API types for the edge service.",