@wtfalch/edge 0.15.1 → 0.17.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, EnsurePlatformWorkerContainerRequest, 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, PlatformWorkerContainerView, PlatformWorkerRouteView, PlatformWorkerScriptView, PlatformZoneView, PutPlatformTunnelConfigRequest, RecordInput, RecordPatch, RecordView, RemovePlatformWorkerContainerResponse, RemovePlatformWorkerSecretResponse, ReplacePlatformGateHostnamesRequest, RequestHeaderStripRule, 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, EnsureCaCertificateRequest, EnsureCaCertificateResponse, EnsurePlatformWorkerContainerRequest, 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, PlatformWorkerContainerView, PlatformWorkerRouteView, PlatformWorkerScriptView, PlatformZoneView, PutPlatformTunnelConfigRequest, RecordInput, RecordPatch, RecordView, RemovePlatformWorkerContainerResponse, RemovePlatformWorkerSecretResponse, ReplacePlatformGateHostnamesRequest, RequestHeaderStripRule, SetGatePeopleResponse, SetPlatformWorkerSchedulesRequest, SetPlatformWorkerSchedulesResponse, SetPlatformWorkerSecretsRequest, SetPlatformWorkerSecretsResponse, TokenResponse, UpdatePlatformRecordRequest, UploadPlatformWorkerScriptRequest, UpsertHyperdriveRequest, UpsertHyperdriveResponse } 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
@@ -138,6 +138,26 @@ export declare function createEdgeClient(options: ClientOptions): {
138
138
  * Cloudflare, and anything nobody names is left alone. */
139
139
  adopt: (input: AdoptRateLimitRulesRequest) => Promise<AdoptRateLimitRulesResponse>;
140
140
  };
141
+ /** Hyperdrive configs whose origin is a private database behind a Cloudflare Tunnel and an Access service token. */
142
+ hyperdrive: {
143
+ /** Creates the config, or rewrites the one of that name, so the same call
144
+ * twice leaves one config and the same id. Needs the platform credential.
145
+ * The password and Access secret go to Cloudflare and are not stored,
146
+ * returned or audited. A failure halfway (the config written, the audit
147
+ * not) throws with the config live; repeat the call. Rejects with
148
+ * `conflict` (reason `upstream_rejected`) when Cloudflare refuses it for good. */
149
+ upsert: (input: UpsertHyperdriveRequest) => Promise<UpsertHyperdriveResponse>;
150
+ /** Deletes the config of that name. One already gone counts as deleted. */
151
+ delete: (name: string) => Promise<void>;
152
+ };
153
+ /** Private CA certificates that a Hyperdrive origin's TLS certificate is checked against. */
154
+ caCertificates: {
155
+ /** Uploads the CA under that name, or returns the id of the one already
156
+ * uploaded under it (its PEM is not compared or replaced). Needs the
157
+ * platform credential. Rejects with `conflict` (reason `upstream_rejected`)
158
+ * when Cloudflare refuses it for good. */
159
+ ensure: (input: EnsureCaCertificateRequest) => Promise<EnsureCaCertificateResponse>;
160
+ };
141
161
  /** Request-header Transform Rules in a zone. */
142
162
  requestHeaders: {
143
163
  /** Keeps one rule, named by `rule.description`, that removes `rule.headers`
package/dist/client.js CHANGED
@@ -143,6 +143,26 @@ export function createEdgeClient(options) {
143
143
  * Cloudflare, and anything nobody names is left alone. */
144
144
  adopt: (input) => call('POST', '/v1/platform/ratelimits/adopt', input),
145
145
  },
146
+ /** Hyperdrive configs whose origin is a private database behind a Cloudflare Tunnel and an Access service token. */
147
+ hyperdrive: {
148
+ /** Creates the config, or rewrites the one of that name, so the same call
149
+ * twice leaves one config and the same id. Needs the platform credential.
150
+ * The password and Access secret go to Cloudflare and are not stored,
151
+ * returned or audited. A failure halfway (the config written, the audit
152
+ * not) throws with the config live; repeat the call. Rejects with
153
+ * `conflict` (reason `upstream_rejected`) when Cloudflare refuses it for good. */
154
+ upsert: (input) => call('PUT', '/v1/platform/hyperdrive/configs', input),
155
+ /** Deletes the config of that name. One already gone counts as deleted. */
156
+ delete: (name) => call('DELETE', `/v1/platform/hyperdrive/configs/${encodeURIComponent(name)}`),
157
+ },
158
+ /** Private CA certificates that a Hyperdrive origin's TLS certificate is checked against. */
159
+ caCertificates: {
160
+ /** Uploads the CA under that name, or returns the id of the one already
161
+ * uploaded under it (its PEM is not compared or replaced). Needs the
162
+ * platform credential. Rejects with `conflict` (reason `upstream_rejected`)
163
+ * when Cloudflare refuses it for good. */
164
+ ensure: (input) => call('PUT', '/v1/platform/ca-certificates', input),
165
+ },
146
166
  /** Request-header Transform Rules in a zone. */
147
167
  requestHeaders: {
148
168
  /** Keeps one rule, named by `rule.description`, that removes `rule.headers`
package/dist/types.d.ts CHANGED
@@ -540,8 +540,14 @@ export interface WorkerDurableObjectBinding {
540
540
  /** The exported class name. */
541
541
  class_name: string;
542
542
  }
543
+ /** A Hyperdrive config bound to the script as `name`; `id` is the id `platform.hyperdrive.upsert` returned (32 hex digits). It lives only as long as an upload lists it: send it on every deploy. */
544
+ export interface WorkerHyperdriveBinding {
545
+ type: 'hyperdrive';
546
+ name: string;
547
+ id: string;
548
+ }
543
549
  /** Everything `uploadScript` accepts in `bindings`. Secrets are not here: see `setSecrets`. */
544
- export type WorkerBinding = WorkerRateLimitBinding | WorkerKvBinding | WorkerPlainTextBinding | WorkerDurableObjectBinding;
550
+ export type WorkerBinding = WorkerRateLimitBinding | WorkerKvBinding | WorkerPlainTextBinding | WorkerDurableObjectBinding | WorkerHyperdriveBinding;
545
551
  /** A Durable Object migration applied with the upload. `oldTag` is the tag the
546
552
  * live script holds now (omit for a script with none): Cloudflare refuses the
547
553
  * upload when it is not. Send only the steps not yet applied. */
@@ -776,6 +782,34 @@ export interface EnsureRequestHeaderStripResponse {
776
782
  /** Cloudflare's rule id. */
777
783
  id: string;
778
784
  }
785
+ /** A Hyperdrive config's origin: a private database reached over a Cloudflare Tunnel hostname with an Access service token. */
786
+ export interface HyperdriveOrigin {
787
+ /** The tunnel's public hostname, lower case, with no scheme, port or path. */
788
+ host: string;
789
+ /** 1 to 63 printable characters. */
790
+ database: string;
791
+ /** 1 to 63 printable characters. */
792
+ user: string;
793
+ /** Goes to Cloudflare and is never stored, returned, audited or logged. */
794
+ password: string;
795
+ /** The Access service token's client id. */
796
+ accessClientId: string;
797
+ /** The Access service token's secret. Goes to Cloudflare and is never stored, returned, audited or logged. */
798
+ accessClientSecret: string;
799
+ /** How Hyperdrive checks the database's TLS certificate. Leave out for no check. */
800
+ sslmode?: 'verify-ca' | 'verify-full';
801
+ /** The id `platform.caCertificates.ensure` returned: the private CA that signed the database's certificate. A lower-case UUID. Needs `sslmode`. */
802
+ caCertificateId?: string;
803
+ }
804
+ export interface UpsertHyperdriveRequest {
805
+ /** Names the config: the key that makes a repeat safe. 1 to 63 letters, digits, dashes or underscores, starting with a letter or digit. */
806
+ name: string;
807
+ origin: HyperdriveOrigin;
808
+ }
809
+ export interface UpsertHyperdriveResponse {
810
+ /** Cloudflare's config id: what a `hyperdrive` Worker binding takes. */
811
+ id: string;
812
+ }
779
813
  export interface AdoptRateLimitRuleEntry {
780
814
  zoneId: string;
781
815
  /** Match the live rule by description, by id, or both. At least one is needed. */
@@ -848,3 +882,13 @@ export interface AdoptZonesResponse {
848
882
  }>;
849
883
  notFound: AdoptZoneEntry[];
850
884
  }
885
+ export interface EnsureCaCertificateRequest {
886
+ /** Names the certificate: the key that makes a repeat safe. 1 to 63 letters, digits, dashes or underscores, starting with a letter or digit. */
887
+ name: string;
888
+ /** Exactly one PEM `CERTIFICATE` block, at most 8192 characters. */
889
+ pem: string;
890
+ }
891
+ export interface EnsureCaCertificateResponse {
892
+ /** Cloudflare's certificate id: what `HyperdriveOrigin.caCertificateId` takes. */
893
+ id: string;
894
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/edge",
3
- "version": "0.15.1",
3
+ "version": "0.17.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Public client SDK and API types for the edge service.",