@wtfalch/edge 0.8.0 → 0.10.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,10 +1,19 @@
1
1
  import { type ClientOptions } from './transport.js';
2
- import type { AdoptAccessAppsRequest, AdoptAccessAppsResponse, AdoptRateLimitRulesRequest, AdoptRateLimitRulesResponse, AdoptRecordsRequest, AdoptRecordsResponse, AdoptTunnelsRequest, AdoptTunnelsResponse, AdoptWorkersRequest, AdoptWorkersResponse, AvailableResponse, ClaimNameRequest, CreatePlatformAccessAppRequest, CreatePlatformAccessPolicyRequest, CreatePlatformRateLimitRuleRequest, CreatePlatformRecordRequest, CreatePlatformTunnelRequest, CreatePlatformWorkerRouteRequest, FindServiceTokenResponse, ListClaimsResponse, ListPlatformAccessAppsRequest, ListPlatformAccessAppsResponse, ListPlatformAccessPoliciesResponse, ListPlatformRateLimitRulesRequest, ListPlatformRateLimitRulesResponse, ListPlatformRecordsRequest, ListPlatformRecordsResponse, ListPlatformTunnelsResponse, ListPlatformWorkerRoutesRequest, ListPlatformWorkerRoutesResponse, ListPlatformWorkerScriptsResponse, ListRecordsResponse, MintKeyRequest, MintKeyResponse, NameClaim, OrgSettingsRequest, PlatformAccessAppView, PlatformAccessPolicyView, PlatformRateLimitRuleView, PlatformRecordView, PlatformTunnelView, PlatformWorkerRouteView, PlatformWorkerScriptView, 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, 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 ends
13
+ * the sessions of each person dropped. `notRevoked` names any whose session
14
+ * could not be ended; 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
@@ -104,6 +126,22 @@ export declare function createEdgeClient(options: ClientOptions): {
104
126
  * Cloudflare, and anything nobody names is left alone. */
105
127
  adopt: (input: AdoptRateLimitRulesRequest) => Promise<AdoptRateLimitRulesResponse>;
106
128
  };
129
+ /** Cloudflare zones the platform made or adopted. A zone is the root of a
130
+ * company's domain, so there is no delete. A zone's `id` is Cloudflare's zone id. */
131
+ zones: {
132
+ /** The live zone with exactly this name (none: an empty list), with its owner (`null`: no row). */
133
+ list: (filter: ListPlatformZonesRequest) => Promise<ListPlatformZonesResponse>;
134
+ /** Creates the zone, or returns the one edge already made for that name
135
+ * (201 when new, 200 after); `nameServers` are what the registrar must
136
+ * delegate to. Rejects with `conflict` when a zone of that name already
137
+ * exists at Cloudflare that nobody adopted (adopt it instead, reason
138
+ * `exists`) or another create of it is in progress (reason `busy`), and
139
+ * with `conflict` (reason `upstream_rejected`) when Cloudflare refuses
140
+ * the zone for good. */
141
+ create: (input: CreatePlatformZoneRequest) => Promise<PlatformZoneView>;
142
+ /** Writes platform rows for the zones named. Nothing is changed at Cloudflare. */
143
+ adopt: (input: AdoptZonesRequest) => Promise<AdoptZonesResponse>;
144
+ };
107
145
  /** Cloudflare Workers scripts and routes the platform owns. A script's
108
146
  * `id` is its name; a route's `id` is Cloudflare's route id. */
109
147
  workers: {
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 ends
18
+ * the sessions of each person dropped. `notRevoked` names any whose session
19
+ * could not be ended; 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
@@ -107,6 +131,22 @@ export function createEdgeClient(options) {
107
131
  * Cloudflare, and anything nobody names is left alone. */
108
132
  adopt: (input) => call('POST', '/v1/platform/ratelimits/adopt', input),
109
133
  },
134
+ /** Cloudflare zones the platform made or adopted. A zone is the root of a
135
+ * company's domain, so there is no delete. A zone's `id` is Cloudflare's zone id. */
136
+ zones: {
137
+ /** The live zone with exactly this name (none: an empty list), with its owner (`null`: no row). */
138
+ list: (filter) => call('GET', `/v1/platform/zones?${new URLSearchParams({ name: filter.name })}`),
139
+ /** Creates the zone, or returns the one edge already made for that name
140
+ * (201 when new, 200 after); `nameServers` are what the registrar must
141
+ * delegate to. Rejects with `conflict` when a zone of that name already
142
+ * exists at Cloudflare that nobody adopted (adopt it instead, reason
143
+ * `exists`) or another create of it is in progress (reason `busy`), and
144
+ * with `conflict` (reason `upstream_rejected`) when Cloudflare refuses
145
+ * the zone for good. */
146
+ create: (input) => call('POST', '/v1/platform/zones', input),
147
+ /** Writes platform rows for the zones named. Nothing is changed at Cloudflare. */
148
+ adopt: (input) => call('POST', '/v1/platform/zones/adopt', input),
149
+ },
110
150
  /** Cloudflare Workers scripts and routes the platform owns. A script's
111
151
  * `id` is its name; a route's `id` is Cloudflare's route id. */
112
152
  workers: {
package/dist/types.d.ts CHANGED
@@ -359,6 +359,75 @@ 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 rejects with `not_configured`, naming each missing right. */
380
+ export interface AccessReadinessResponse {
381
+ ready: true;
382
+ }
383
+ /** 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
+ export interface CreatePlatformGateRequest {
385
+ organisationId: string;
386
+ /** A lower-case DNS label, unique in the company. */
387
+ key: string;
388
+ /** The hostnames the gate covers, a leading `*.` allowed. */
389
+ hostnames: string[];
390
+ /** The provider's id from `ensureProvider`. */
391
+ providerId: string;
392
+ claimName: string;
393
+ claimValue: string;
394
+ /** The first list of people: 1 to 1000 addresses. */
395
+ emails: string[];
396
+ }
397
+ export interface ReplacePlatformGateHostnamesRequest {
398
+ hostnames: string[];
399
+ }
400
+ /** A company's gate. `id` is edge's gate id, which the change and delete calls take. */
401
+ export interface PlatformGateView {
402
+ id: string;
403
+ organisationId: string;
404
+ key: string;
405
+ hostnames: string[];
406
+ providerId: string;
407
+ applicationId: string;
408
+ groupId: string;
409
+ }
410
+ /** A gate as its company sees it. */
411
+ export interface GateView {
412
+ /** Edge's gate id: what `setPeople` takes. */
413
+ id: string;
414
+ key: string;
415
+ hostnames: string[];
416
+ /** The addresses that pass the gate, lower-case. */
417
+ people: string[];
418
+ }
419
+ export interface ListGatesResponse {
420
+ gates: GateView[];
421
+ }
422
+ /** The whole list of people for a gate: 1 to 1000 addresses. Duplicates collapse and case is ignored. */
423
+ export interface SetGatePeopleRequest {
424
+ emails: string[];
425
+ }
426
+ /** The gate with its new people. The list is replaced even when a revoke fails. */
427
+ export interface SetGatePeopleResponse extends GateView {
428
+ /** Addresses the new list dropped whose sessions could not be ended. Empty when all were. */
429
+ notRevoked: string[];
430
+ }
362
431
  /** A service token's id and name. Its secret is never returned. */
363
432
  export interface FindServiceTokenResponse {
364
433
  token: {
@@ -567,3 +636,52 @@ export interface AdoptRateLimitRulesResponse {
567
636
  /** Live rules in the named zones that no entry named. Reported, never touched. */
568
637
  unclaimed: PlatformRateLimitRuleView[];
569
638
  }
639
+ /** A Cloudflare zone seen with the platform credential. A zone is the root of a
640
+ * company's domain, so edge only looks it up, creates it and adopts it: there is no delete. */
641
+ export interface PlatformZoneView {
642
+ /** Cloudflare's zone id. */
643
+ id: string;
644
+ name: string;
645
+ /** Cloudflare's zone status, such as `pending` until the registrar delegates. */
646
+ status: string;
647
+ /** What the domain's registrar must delegate to. */
648
+ nameServers: string[];
649
+ /** Who owns it: the platform, or `null` when no row exists (a live zone
650
+ * nobody adopted: reported, never touched). */
651
+ owner: 'platform' | null;
652
+ /** The company the zone serves; `'platform'` when none. `null` for a zone with no row. */
653
+ organisationId: string | null;
654
+ state: 'pending' | 'active' | 'removed' | null;
655
+ }
656
+ export interface ListPlatformZonesRequest {
657
+ /** The zone's exact name, such as `example.com`. */
658
+ name: string;
659
+ }
660
+ /** Empty when no zone has that name. */
661
+ export interface ListPlatformZonesResponse {
662
+ zones: PlatformZoneView[];
663
+ }
664
+ export interface CreatePlatformZoneRequest {
665
+ /** The domain's apex, such as `example.com`. Lower-cased. */
666
+ name: string;
667
+ /** The company the zone serves. Omit for a zone that serves none. */
668
+ organisationId?: string;
669
+ }
670
+ export interface AdoptZoneEntry {
671
+ name: string;
672
+ }
673
+ export interface AdoptZonesRequest {
674
+ zones: AdoptZoneEntry[];
675
+ /** The company the adopted zones serve. Omit for none. */
676
+ organisationId?: string;
677
+ }
678
+ export interface AdoptZonesResponse {
679
+ adopted: PlatformZoneView[];
680
+ alreadyAdopted: PlatformZoneView[];
681
+ /** `taken`: a row for that name holds a different zone. */
682
+ skipped: Array<{
683
+ zone: PlatformZoneView;
684
+ reason: 'taken';
685
+ }>;
686
+ notFound: AdoptZoneEntry[];
687
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/edge",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Public client SDK and API types for the edge service.",