@logtura/cloudflare-shared
v0.2.11
Published
Shared Cloudflare API-token plumbing used by the cloudflare-* logtura drivers.
Downloads
1,830
Readme
@logtura/cloudflare-shared
Shared helpers for Cloudflare-* logtura provider drivers. Handles the bits that are the same regardless of which Cloudflare surface (Workers tail, AI Gateway, and future drivers) you are consuming: API-token verification, freshness check, the Bearer ... fetch helper, and the runtime env-var spec the forwarder needs.
Not useful on its own. Depend on it from a @logtura/driver-cloudflare-* package. If you are writing a third Cloudflare driver, this is what you import.
npm install @logtura/cloudflare-shared @logtura/coreWhat's exported
cfFetch(path, token, init?). JSON-aware fetch againstapi.cloudflare.com/client/v4. ThrowsProviderErrorwith the API's own error message on non-2xx.verifyCfCredentials(creds)returningProviderAccount[]. Verifies the token and lists accessible accounts. Drivers wire this asProviderDriver.verifyCredentials.checkCfCredentialFreshness(creds)returning{ fresh, reason?, expiresAt? }. Checks token status and expiry. Drivers wire this asProviderDriver.checkCredentialFreshness.cfRuntimeSpec({ helpUrl, extraDockerInstall? })returning{ envVars, dockerfileDeps }. DeclaresCLOUDFLARE_API_TOKEN(credential) andCLOUDFLARE_ACCOUNT_ID(external_account_id). Drivers call this fromruntimeSpec.safeKey(s)andshellQuoteCfWorkerName(s). Small string helpers for naming Vector components and shell-quoting worker names in exec commands.
