net3000.cloudflare
1.1.0
dotnet add package net3000.cloudflare --version 1.1.0
NuGet\Install-Package net3000.cloudflare -Version 1.1.0
<PackageReference Include="net3000.cloudflare" Version="1.1.0" />
<PackageVersion Include="net3000.cloudflare" Version="1.1.0" />
<PackageReference Include="net3000.cloudflare" />
paket add net3000.cloudflare --version 1.1.0
#r "nuget: net3000.cloudflare, 1.1.0"
#:package net3000.cloudflare@1.1.0
#addin nuget:?package=net3000.cloudflare&version=1.1.0
#tool nuget:?package=net3000.cloudflare&version=1.1.0
Net3000.Cloudflare
net3000.cloudflare 1.1.0 targets .NET 10. It provides zone listing, zone HTTP
analytics and private Cloudflare Stream hosting. It does not implement DNS record
management, firewall rules, TLS configuration or cache purging.
Existing zone and analytics service
Net3000.Cloudflare.Services is unchanged. Set ApiToken (or pass the optional
method argument) and call GetCloudflareZonesAsync() or
GetCloudflareStatsAsync(zoneId, from, to). These methods return nullable results;
the token needs the corresponding zone read/analytics permissions.
Stream service
Net3000.Cloudflare.Stream.CloudflareStreamService is a separate, database-free
class. Supply its credential properties from environment configuration. The
optional constructor logger uses ILogger<CloudflareStreamService>. The default
HTTP client is shared, uses the Net3000.ca Platform user agent and does not follow
redirects. Authorization is set on each request, never on shared default headers.
An optional injected HttpClient and TimeProvider support offline tests; the
caller owns an injected client's lifetime.
The hosts register a scoped factory that reads these configuration keys (both
hosts already load variables with the NET3000_ prefix):
| Configuration key | Service property | Environment variable |
|---|---|---|
| Cloudflare:AccountId | AccountId | NET3000_Cloudflare__AccountId |
| Cloudflare:StreamApiToken | ApiToken | NET3000_Cloudflare__StreamApiToken |
| Cloudflare:StreamCustomerSubdomain | CustomerSubdomain | NET3000_Cloudflare__StreamCustomerSubdomain |
| Cloudflare:StreamSigningKeyId | SigningKeyId | NET3000_Cloudflare__StreamSigningKeyId |
| Cloudflare:StreamSigningKeyPem | SigningKeyPem | NET3000_Cloudflare__StreamSigningKeyPem |
| Cloudflare:StreamWebhookSecret | WebhookSecret | NET3000_Cloudflare__StreamWebhookSecret |
| Cloudflare:StreamEnvironment | StreamEnvironment | NET3000_Cloudflare__StreamEnvironment |
CustomerSubdomain is the hostname label customer-<code>, without a scheme or
.cloudflarestream.com. SigningKeyPem accepts Cloudflare's base64-encoded PEM or
raw PEM. StreamEnvironment must be explicitly live or staging; there is no
production fallback. Keep credentials in host environment variables, never in
appsettings*.json, source control, response logs or browser code.
Construction performs no network request, key import or configuration validation
that could prevent host startup. IsConfigured checks all feature configuration;
IsApiConfigured and IsPlaybackConfigured describe the individual capabilities.
Missing credentials cause operations to return stream-not-configured (503).
Invalid signing material is reported only when signing is requested. URL builders
throw if the customer subdomain is missing or invalid; check configuration first.
Operations and response contract
Async operations and CreatePlaybackToken return the house apiResponse<T>.
Check success before using data. Invalid input returns 400; HTTP failures retain
the upstream status; malformed/failed success envelopes and transport failures
return 502. Error messages do not echo Cloudflare response bodies. Caller-requested
cancellation propagates. Every async method accepts a cancellation token.
| Method | Behavior |
|---|---|
| CreateTusUploadAsync(length, name, maxDurationSeconds, creator) | Creates a resumable direct upload ticket; reads Location and stream-media-id headers |
| GetVideoAsync(uid) | Retrieves state, fractional duration, creator and metadata |
| ListVideosAsync(creator, before, limit) | Returns one page, up to 1000 videos; before is an exclusive RFC3339 creation-time cursor |
| UpdateVideoAsync(uid, update) | Updates creator/metadata and always sends requireSignedURLs=true |
| DeleteVideoAsync(uid) | Deletes a video; accepts a successful envelope or HTTP 204 |
| GetStorageUsageAsync(creator) | Returns stored minutes, capacity and video count, optionally filtered by creator |
| CreateSigningKeyAsync() | Creates an account signing key; returns secret base64 PEM/JWK |
| SetWebhookAsync(notificationUrl) | Sets the single account-wide subscription; returns the webhook secret |
| CreatePlaybackToken(uid, ttl) | Locally signs RS256; no per-view Cloudflare request |
| BuildIframeUrl(token), BuildThumbnailUrl(token) | Builds URLs on the configured customer hostname |
| VerifyWebhookSignature(header, rawBody, secret, tolerance) | Authenticates raw body bytes with HMAC-SHA256 and constant-time comparison |
Signing-key creation and webhook setup are operator setup operations. This change only supplies their code; it does not provision credentials, change a Cloudflare account or deploy a webhook endpoint.
Private direct uploads
The backend sends POST /accounts/{AccountId}/stream?direct_user=true with
Tus-Resumable: 1.0.0, Upload-Length, Upload-Creator and UTF-8/base64 tus
metadata. Metadata includes name, the presence flag requiresignedurls,
maxDurationSeconds (1–36000) and env. Arbitrary tus metadata becomes video
meta, so env is available to later webhook/delete guards. The documented
maxDurationSeconds spelling replaces the plan KTD4's maxdurationseconds, with
user approval. No allowed-origin restriction is sent.
The caller supplies an opaque creator such as staging-acct-123, after resolving
the tenant server-side and checking permission and storage caps. File bytes go
directly from the browser to the returned ticket URL with a tus client. Never send
the API token or signing key to that browser.
Playback and webhook security
Playback JWTs have RS256 and kid in the header; sub (video UID), kid, numeric
exp, nbf (60 seconds before signing) and downloadable=false in the payload.
TTL defaults to four hours and must be between one second and 24 hours.
Callers enforce entitlement before signing and avoid caching tokens past expiry.
Webhook verification takes unaltered body bytes, not reserialized JSON. It
parses time and sig1, rejects malformed/duplicate fields, checks a default
five-minute tolerance in both directions, computes HMAC-SHA256 over
{time}.{rawBody} and compares decoded hex signatures in constant time. Verify
before deserializing StreamWebhookPayload.
The wrapper does not perform tenant or database checks. Callers must verify video
ownership and compare meta.env with the running StreamEnvironment before
deleting or applying webhook updates. Staging must never delete live-tagged videos.
Dependencies and local verification
The library references commonModels (not commonCore), JWT 8.17.0 and logging
abstractions 10.0.0. No CM, SC or database dependency is introduced.
dotnet test Services/Cloudflare.Tests
dotnet build -c Release Services/Cloudflare/Cloudflare.csproj
dotnet build "Web Applications/api/api.csproj"
dotnet build "Web Applications/net3000.core/net3000.core.csproj"
The tests use stub HTTP handlers, generated disposable RSA keys and canned JSON;
they make no network calls. A Release build emits
nupkgs/net3000.cloudflare.1.1.0.nupkg through GeneratePackageOnBuild.
Contract references: direct creator uploads, tus metadata, signed playback, webhooks, storage usage.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- net3000.common.models (>= 1.0.19)
- System.IdentityModel.Tokens.Jwt (>= 8.17.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on net3000.cloudflare:
| Package | Downloads |
|---|---|
|
net3000.servicecoordinator
Service coordination library for Net3000 solutions. Provides API connection management and service orchestration capabilities. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Add reusable Stream operations, resumable upload tickets, local RS256 playback tokens and webhook verification.