@wtfalch/edge 0.12.0 → 0.14.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, 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, 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, EnsureRequestHeaderStripResponse, 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, RequestHeaderStripRule, 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
@@ -99,6 +99,9 @@ export declare function createEdgeClient(options: ClientOptions): {
99
99
  /** Deletes a service token edge made; any other rejects with `not_found`.
100
100
  * One already gone at Cloudflare counts as deleted. */
101
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>;
102
105
  /** Writes platform rows for the live apps named. Nothing is deleted or
103
106
  * recreated, and an app nobody names is left alone. */
104
107
  adopt: (input: AdoptAccessAppsRequest) => Promise<AdoptAccessAppsResponse>;
@@ -135,6 +138,16 @@ export declare function createEdgeClient(options: ClientOptions): {
135
138
  * Cloudflare, and anything nobody names is left alone. */
136
139
  adopt: (input: AdoptRateLimitRulesRequest) => Promise<AdoptRateLimitRulesResponse>;
137
140
  };
141
+ /** Request-header Transform Rules in a zone. */
142
+ requestHeaders: {
143
+ /** Keeps one rule, named by `rule.description`, that removes `rule.headers`
144
+ * from requests matching `rule.expression` (the zone's
145
+ * `http_request_late_transform` phase). Creates the rule, or rewrites it
146
+ * when it exists; no other rule in the zone changes. Safe to repeat. Needs
147
+ * the platform credential. Rejects with `conflict` (reason
148
+ * `upstream_rejected`) when Cloudflare refuses the rule for good. */
149
+ ensureRequestHeaderStrip: (zoneId: string, rule: RequestHeaderStripRule) => Promise<EnsureRequestHeaderStripResponse>;
150
+ };
138
151
  /** Cloudflare zones the platform made or adopted. A zone is the root of a
139
152
  * company's domain, so there is no delete. A zone's `id` is Cloudflare's zone id. */
140
153
  zones: {
package/dist/client.js CHANGED
@@ -104,6 +104,9 @@ export function createEdgeClient(options) {
104
104
  /** Deletes a service token edge made; any other rejects with `not_found`.
105
105
  * One already gone at Cloudflare counts as deleted. */
106
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'),
107
110
  /** Writes platform rows for the live apps named. Nothing is deleted or
108
111
  * recreated, and an app nobody names is left alone. */
109
112
  adopt: (input) => call('POST', '/v1/platform/access/apps/adopt', input),
@@ -140,6 +143,21 @@ export function createEdgeClient(options) {
140
143
  * Cloudflare, and anything nobody names is left alone. */
141
144
  adopt: (input) => call('POST', '/v1/platform/ratelimits/adopt', input),
142
145
  },
146
+ /** Request-header Transform Rules in a zone. */
147
+ requestHeaders: {
148
+ /** Keeps one rule, named by `rule.description`, that removes `rule.headers`
149
+ * from requests matching `rule.expression` (the zone's
150
+ * `http_request_late_transform` phase). Creates the rule, or rewrites it
151
+ * when it exists; no other rule in the zone changes. Safe to repeat. Needs
152
+ * the platform credential. Rejects with `conflict` (reason
153
+ * `upstream_rejected`) when Cloudflare refuses the rule for good. */
154
+ ensureRequestHeaderStrip: (zoneId, rule) => call('PUT', '/v1/platform/transforms/request-headers', {
155
+ zoneId,
156
+ description: rule.description,
157
+ expression: rule.expression,
158
+ headers: rule.headers,
159
+ }),
160
+ },
143
161
  /** Cloudflare zones the platform made or adopted. A zone is the root of a
144
162
  * company's domain, so there is no delete. A zone's `id` is Cloudflare's zone id. */
145
163
  zones: {
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;
@@ -688,6 +698,19 @@ export interface CreatePlatformRateLimitRuleRequest {
688
698
  /** The company the rule serves. Omit for a rule that serves none. */
689
699
  organisationId?: string;
690
700
  }
701
+ /** A rule that removes request headers from every request its expression matches. */
702
+ export interface RequestHeaderStripRule {
703
+ /** Names the rule in the zone: the key that makes a repeat safe. 1 to 500 printable characters. */
704
+ description: string;
705
+ /** Cloudflare's rule expression, 1 to 4096 printable characters. */
706
+ expression: string;
707
+ /** 1 to 20 header names of letters, digits and hyphens. */
708
+ headers: readonly string[];
709
+ }
710
+ export interface EnsureRequestHeaderStripResponse {
711
+ /** Cloudflare's rule id. */
712
+ id: string;
713
+ }
691
714
  export interface AdoptRateLimitRuleEntry {
692
715
  zoneId: string;
693
716
  /** Match the live rule by description, by id, or both. At least one is needed. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/edge",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Public client SDK and API types for the edge service.",