@wtfalch/edge 0.9.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 +23 -1
- package/dist/client.js +24 -0
- package/dist/types.d.ts +69 -0
- 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, 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
|
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
|
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: {
|