@wtfalch/edge 0.9.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 +33 -2
- package/dist/client.js +34 -1
- package/dist/types.d.ts +133 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { type ClientOptions } from './transport.js';
|
|
2
|
-
import type { AdoptAccessAppsRequest, AdoptAccessAppsResponse, AdoptRateLimitRulesRequest, AdoptRateLimitRulesResponse, AdoptRecordsRequest, AdoptRecordsResponse, AdoptTunnelsRequest, AdoptTunnelsResponse, AdoptWorkersRequest, AdoptWorkersResponse, AdoptZonesRequest, AdoptZonesResponse, AvailableResponse, ClaimNameRequest, CreatePlatformAccessAppRequest, CreatePlatformAccessPolicyRequest, CreatePlatformRateLimitRuleRequest, CreatePlatformRecordRequest, CreatePlatformTunnelRequest, CreatePlatformWorkerRouteRequest, CreatePlatformZoneRequest, FindServiceTokenResponse, ListClaimsResponse, ListPlatformAccessAppsRequest, ListPlatformAccessAppsResponse, ListPlatformAccessPoliciesResponse, ListPlatformRateLimitRulesRequest, ListPlatformRateLimitRulesResponse, ListPlatformRecordsRequest, ListPlatformRecordsResponse, ListPlatformTunnelsResponse, ListPlatformWorkerRoutesRequest, ListPlatformWorkerRoutesResponse, ListPlatformWorkerScriptsResponse, ListPlatformZonesRequest, ListPlatformZonesResponse, ListRecordsResponse, MintKeyRequest, MintKeyResponse, NameClaim, OrgSettingsRequest, PlatformAccessAppView, PlatformAccessPolicyView, PlatformRateLimitRuleView, PlatformRecordView, PlatformTunnelView, PlatformWorkerRouteView, PlatformWorkerScriptView, PlatformZoneView, PutPlatformTunnelConfigRequest, RecordInput, RecordPatch, RecordView, 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
|
|
6
6
|
* refused by the service for any credential but the platform's own. */
|
|
7
7
|
export declare function createEdgeClient(options: ClientOptions): {
|
|
8
|
+
/** The org's gates. Needs `gates:read` (`gates:edit` for `setPeople`). */
|
|
9
|
+
gates: {
|
|
10
|
+
/** The org's gates, each with the people who pass it now. */
|
|
11
|
+
list: () => Promise<ListGatesResponse>;
|
|
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
|
+
setPeople: (id: string, emails: string[]) => Promise<SetGatePeopleResponse>;
|
|
16
|
+
};
|
|
8
17
|
/** The org's DNS records. Needs `records:read` (`records:edit` for changes). */
|
|
9
18
|
records: {
|
|
10
19
|
/** The org's own records, then every other live record in the zone as a
|
|
@@ -84,6 +93,19 @@ export declare function createEdgeClient(options: ClientOptions): {
|
|
|
84
93
|
/** Writes platform rows for the live apps named. Nothing is deleted or
|
|
85
94
|
* recreated, and an app nobody names is left alone. */
|
|
86
95
|
adopt: (input: AdoptAccessAppsRequest) => Promise<AdoptAccessAppsResponse>;
|
|
96
|
+
/** Resolves when the Cloudflare token holds every Access right gates
|
|
97
|
+
* need. Rejects with `not_configured`, naming each right it lacks. */
|
|
98
|
+
readiness: () => Promise<AccessReadinessResponse>;
|
|
99
|
+
/** Creates the OIDC provider, or updates the one of that name; returns
|
|
100
|
+
* its id. The client secret is never returned. */
|
|
101
|
+
ensureProvider: (input: EnsureAccessProviderRequest) => Promise<AccessProviderView>;
|
|
102
|
+
/** Makes a company's gate. Rejects with `conflict` when the company
|
|
103
|
+
* already has a gate of that key. */
|
|
104
|
+
createGate: (input: CreatePlatformGateRequest) => Promise<PlatformGateView>;
|
|
105
|
+
/** Replaces the hostnames a gate covers. */
|
|
106
|
+
replaceGateHostnames: (id: string, input: ReplacePlatformGateHostnamesRequest) => Promise<PlatformGateView>;
|
|
107
|
+
/** Deletes a gate with its application, policy and group. */
|
|
108
|
+
deleteGate: (id: string) => Promise<PlatformGateView>;
|
|
87
109
|
};
|
|
88
110
|
/** Cloudflare rate limiting rules the platform owns. A zone's rules share
|
|
89
111
|
* one ruleset, so each rule is owned on its own; a rule's `id` is
|
|
@@ -134,7 +156,16 @@ export declare function createEdgeClient(options: ClientOptions): {
|
|
|
134
156
|
* with `invalid_request` when the script is not base64 or its sha256
|
|
135
157
|
* differs from `artifactSha256`. */
|
|
136
158
|
uploadScript: (name: string, input: UploadPlatformWorkerScriptRequest) => Promise<PlatformWorkerScriptView>;
|
|
137
|
-
/**
|
|
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`. */
|
|
138
169
|
removeScript: (name: string) => Promise<PlatformWorkerScriptView>;
|
|
139
170
|
/** Every live route in the zone with its owner (`null`: no row), optionally only one pattern. */
|
|
140
171
|
listRoutes: (filter: ListPlatformWorkerRoutesRequest) => Promise<ListPlatformWorkerRoutesResponse>;
|
package/dist/client.js
CHANGED
|
@@ -10,6 +10,17 @@ function query(values) {
|
|
|
10
10
|
export function createEdgeClient(options) {
|
|
11
11
|
const call = createTransport(options);
|
|
12
12
|
return {
|
|
13
|
+
/** The org's gates. Needs `gates:read` (`gates:edit` for `setPeople`). */
|
|
14
|
+
gates: {
|
|
15
|
+
/** The org's gates, each with the people who pass it now. */
|
|
16
|
+
list: () => call('GET', '/v1/gates'),
|
|
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
|
+
setPeople: (id, emails) => call('PUT', `/v1/gates/${encodeURIComponent(id)}/people`, {
|
|
21
|
+
emails,
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
13
24
|
/** The org's DNS records. Needs `records:read` (`records:edit` for changes). */
|
|
14
25
|
records: {
|
|
15
26
|
/** The org's own records, then every other live record in the zone as a
|
|
@@ -87,6 +98,19 @@ export function createEdgeClient(options) {
|
|
|
87
98
|
/** Writes platform rows for the live apps named. Nothing is deleted or
|
|
88
99
|
* recreated, and an app nobody names is left alone. */
|
|
89
100
|
adopt: (input) => call('POST', '/v1/platform/access/apps/adopt', input),
|
|
101
|
+
/** Resolves when the Cloudflare token holds every Access right gates
|
|
102
|
+
* need. Rejects with `not_configured`, naming each right it lacks. */
|
|
103
|
+
readiness: () => call('GET', '/v1/platform/access/readiness'),
|
|
104
|
+
/** Creates the OIDC provider, or updates the one of that name; returns
|
|
105
|
+
* its id. The client secret is never returned. */
|
|
106
|
+
ensureProvider: (input) => call('PUT', '/v1/platform/access/identity-providers', input),
|
|
107
|
+
/** Makes a company's gate. Rejects with `conflict` when the company
|
|
108
|
+
* already has a gate of that key. */
|
|
109
|
+
createGate: (input) => call('POST', '/v1/platform/access/gates', input),
|
|
110
|
+
/** Replaces the hostnames a gate covers. */
|
|
111
|
+
replaceGateHostnames: (id, input) => call('PUT', `/v1/platform/access/gates/${encodeURIComponent(id)}/hostnames`, input),
|
|
112
|
+
/** Deletes a gate with its application, policy and group. */
|
|
113
|
+
deleteGate: (id) => call('DELETE', `/v1/platform/access/gates/${encodeURIComponent(id)}`),
|
|
90
114
|
},
|
|
91
115
|
/** Cloudflare rate limiting rules the platform owns. A zone's rules share
|
|
92
116
|
* one ruleset, so each rule is owned on its own; a rule's `id` is
|
|
@@ -135,7 +159,16 @@ export function createEdgeClient(options) {
|
|
|
135
159
|
* with `invalid_request` when the script is not base64 or its sha256
|
|
136
160
|
* differs from `artifactSha256`. */
|
|
137
161
|
uploadScript: (name, input) => call('PUT', `/v1/platform/workers/scripts/${encodeURIComponent(name)}`, input),
|
|
138
|
-
/**
|
|
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`. */
|
|
139
172
|
removeScript: (name) => call('DELETE', `/v1/platform/workers/scripts/${encodeURIComponent(name)}`),
|
|
140
173
|
/** Every live route in the zone with its owner (`null`: no row), optionally only one pattern. */
|
|
141
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
|
@@ -359,6 +359,83 @@ export interface CreatePlatformAccessPolicyRequest {
|
|
|
359
359
|
exclude?: AccessRule[];
|
|
360
360
|
require?: AccessRule[];
|
|
361
361
|
}
|
|
362
|
+
/** The sign-in provider every gate requires: a generic OIDC provider, found by `name`. */
|
|
363
|
+
export interface EnsureAccessProviderRequest {
|
|
364
|
+
name: string;
|
|
365
|
+
clientId: string;
|
|
366
|
+
/** Sent to Cloudflare and never returned. */
|
|
367
|
+
clientSecret: string;
|
|
368
|
+
authUrl: string;
|
|
369
|
+
tokenUrl: string;
|
|
370
|
+
certsUrl: string;
|
|
371
|
+
scopes: string[];
|
|
372
|
+
claims: string[];
|
|
373
|
+
}
|
|
374
|
+
export interface AccessProviderView {
|
|
375
|
+
/** Cloudflare's id for the provider: what a gate takes as `providerId`. */
|
|
376
|
+
id: string;
|
|
377
|
+
name: string;
|
|
378
|
+
}
|
|
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
|
+
export interface AccessReadinessResponse {
|
|
381
|
+
ready: true;
|
|
382
|
+
/** The Access organisation's team address, for example `team.cloudflareaccess.com`. */
|
|
383
|
+
authDomain: string;
|
|
384
|
+
}
|
|
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. */
|
|
386
|
+
export interface CreatePlatformGateRequest {
|
|
387
|
+
organisationId: string;
|
|
388
|
+
/** A lower-case DNS label, unique in the company. */
|
|
389
|
+
key: string;
|
|
390
|
+
/** The key of the app entry that declared the gate: a lower-case DNS label. */
|
|
391
|
+
entry: string;
|
|
392
|
+
/** The hostnames the gate covers, a leading `*.` allowed. */
|
|
393
|
+
hostnames: string[];
|
|
394
|
+
/** The provider's id from `ensureProvider`. */
|
|
395
|
+
providerId: string;
|
|
396
|
+
claimName: string;
|
|
397
|
+
claimValue: string;
|
|
398
|
+
/** The first list of people: 1 to 1000 addresses. */
|
|
399
|
+
emails: string[];
|
|
400
|
+
}
|
|
401
|
+
export interface ReplacePlatformGateHostnamesRequest {
|
|
402
|
+
hostnames: string[];
|
|
403
|
+
}
|
|
404
|
+
/** A company's gate. `id` is edge's gate id, which the change and delete calls take. */
|
|
405
|
+
export interface PlatformGateView {
|
|
406
|
+
id: string;
|
|
407
|
+
organisationId: string;
|
|
408
|
+
key: string;
|
|
409
|
+
/** The key of the app entry that declared the gate. */
|
|
410
|
+
entry: string;
|
|
411
|
+
hostnames: string[];
|
|
412
|
+
providerId: string;
|
|
413
|
+
applicationId: string;
|
|
414
|
+
groupId: string;
|
|
415
|
+
}
|
|
416
|
+
/** A gate as its company sees it. */
|
|
417
|
+
export interface GateView {
|
|
418
|
+
/** Edge's gate id: what `setPeople` takes. */
|
|
419
|
+
id: string;
|
|
420
|
+
key: string;
|
|
421
|
+
/** The key of the app entry that declared the gate. */
|
|
422
|
+
entry: string;
|
|
423
|
+
hostnames: string[];
|
|
424
|
+
/** The addresses that pass the gate, lower-case. */
|
|
425
|
+
people: string[];
|
|
426
|
+
}
|
|
427
|
+
export interface ListGatesResponse {
|
|
428
|
+
gates: GateView[];
|
|
429
|
+
}
|
|
430
|
+
/** The whole list of people for a gate: 1 to 1000 addresses. Duplicates collapse and case is ignored. */
|
|
431
|
+
export interface SetGatePeopleRequest {
|
|
432
|
+
emails: string[];
|
|
433
|
+
}
|
|
434
|
+
/** The gate with its new people. The list is replaced even when a revoke fails. */
|
|
435
|
+
export interface SetGatePeopleResponse extends GateView {
|
|
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;
|
|
438
|
+
}
|
|
362
439
|
/** A service token's id and name. Its secret is never returned. */
|
|
363
440
|
export interface FindServiceTokenResponse {
|
|
364
441
|
token: {
|
|
@@ -417,6 +494,23 @@ export interface WorkerRateLimitBinding {
|
|
|
417
494
|
period: number;
|
|
418
495
|
};
|
|
419
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;
|
|
420
514
|
/** Uploads (or redeploys) a script. Edge fetches nothing: the caller sends the
|
|
421
515
|
* script, edge checks its size and sha256, and sends it to Cloudflare. The body
|
|
422
516
|
* is never stored or returned. */
|
|
@@ -427,10 +521,48 @@ export interface UploadPlatformWorkerScriptRequest {
|
|
|
427
521
|
artifactSha256: string;
|
|
428
522
|
/** Like `2026-10-01`. */
|
|
429
523
|
compatibilityDate: string;
|
|
430
|
-
bindings
|
|
524
|
+
/** The script's bindings, all of them: a redeploy replaces the list. Secrets set by `setSecrets` survive a redeploy. */
|
|
525
|
+
bindings?: WorkerBinding[];
|
|
431
526
|
/** The company the script serves. Omit for a script that serves none. */
|
|
432
527
|
organisationId?: string;
|
|
433
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
|
+
}
|
|
434
566
|
/** A Workers route seen with the platform credential. `id` is Cloudflare's
|
|
435
567
|
* route id, which every platform route call takes. */
|
|
436
568
|
export interface PlatformWorkerRouteView {
|