@wtfalch/edge 0.11.0 → 0.13.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, SetPlatformWorkerSchedulesRequest, SetPlatformWorkerSchedulesResponse, SetPlatformWorkerSecretsRequest, SetPlatformWorkerSecretsResponse, 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, OneTimePinProviderView, 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
@@ -90,6 +90,18 @@ 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>;
102
+ /** The account's one-time-PIN identity provider, made when none exists.
103
+ * Safe to repeat. Its `id` goes in `allowedIdps` of `create`. */
104
+ oneTimePinProvider: () => Promise<OneTimePinProviderView>;
93
105
  /** Writes platform rows for the live apps named. Nothing is deleted or
94
106
  * recreated, and an app nobody names is left alone. */
95
107
  adopt: (input: AdoptAccessAppsRequest) => Promise<AdoptAccessAppsResponse>;
package/dist/client.js CHANGED
@@ -95,6 +95,18 @@ 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)}`),
107
+ /** The account's one-time-PIN identity provider, made when none exists.
108
+ * Safe to repeat. Its `id` goes in `allowedIdps` of `create`. */
109
+ oneTimePinProvider: () => call('GET', '/v1/platform/access/identity-providers/one-time-pin'),
98
110
  /** Writes platform rows for the live apps named. Nothing is deleted or
99
111
  * recreated, and an app nobody names is left alone. */
100
112
  adopt: (input) => call('POST', '/v1/platform/access/apps/adopt', input),
package/dist/types.d.ts CHANGED
@@ -314,6 +314,10 @@ export interface PlatformAccessAppView {
314
314
  /** The company the app serves; `'platform'` when none. `null` for an app with no row. */
315
315
  organisationId: string | null;
316
316
  state: 'pending' | 'active' | 'removing' | 'removed';
317
+ /** The identity providers the app accepts, as Cloudflare reports them. `[]` means Cloudflare lists none (it accepts any). */
318
+ allowedIdps: string[];
319
+ /** Whether a visitor goes straight to the one provider, as Cloudflare reports it. */
320
+ autoRedirectToIdentity: boolean;
317
321
  }
318
322
  export interface ListPlatformAccessAppsRequest {
319
323
  /** Only the app on exactly this domain. */
@@ -327,13 +331,15 @@ export interface ListPlatformAccessAppsResponse {
327
331
  /** Creates the app, or returns the one edge already made for that domain and name. */
328
332
  export interface CreatePlatformAccessAppRequest {
329
333
  name: string;
330
- /** A lower-case hostname, optionally with a leading `*.`. */
334
+ /** A lower-case hostname, optionally with a leading `*.`, optionally followed by a path (`/api/prices`; a segment may be `*`). */
331
335
  domain: string;
332
336
  /** Only `self_hosted` is supported (the default). */
333
337
  type?: 'self_hosted';
334
338
  /** Like `30m` or `24h`. */
335
339
  sessionDuration?: string;
336
340
  autoRedirectToIdentity?: boolean;
341
+ /** Identity provider ids (1 to 20) the app accepts and nothing else; for the one-time PIN alone, `[(await platform.access.oneTimePinProvider()).id]`. Omit to leave Cloudflare's default. */
342
+ allowedIdps?: string[];
337
343
  /** The company the app serves. Omit for an app that serves none. */
338
344
  organisationId?: string;
339
345
  }
@@ -376,6 +382,10 @@ export interface AccessProviderView {
376
382
  id: string;
377
383
  name: string;
378
384
  }
385
+ /** The account's one-time-PIN identity provider: its id is what `allowedIdps` takes. */
386
+ export interface OneTimePinProviderView {
387
+ id: string;
388
+ }
379
389
  /** 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
390
  export interface AccessReadinessResponse {
381
391
  ready: true;
@@ -443,6 +453,18 @@ export interface FindServiceTokenResponse {
443
453
  name: string;
444
454
  } | null;
445
455
  }
456
+ export interface CreatePlatformServiceTokenRequest {
457
+ name: string;
458
+ }
459
+ /** `clientId` and `clientSecret` are shown once, here. Edge keeps neither and cannot return them again. */
460
+ export interface CreatePlatformServiceTokenResponse {
461
+ token: {
462
+ id: string;
463
+ name: string;
464
+ };
465
+ clientId: string;
466
+ clientSecret: string;
467
+ }
446
468
  export interface AdoptAccessAppEntry {
447
469
  name: string;
448
470
  /** Narrows several apps of one name. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/edge",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Public client SDK and API types for the edge service.",