Embeddable widget: iframe integration and CDN storage.

Generates embed snippets (script and iframe variants) for embedding ticket booking on external websites. Includes host validation with wildcard domain support and Content-Security-Policy frame-ancestors headers.

Functions

f
appendIframeParam

Append iframe=true query param to a URL when in iframe mode

f
buildEmbedSnippets

Build embed snippets (script and iframe variants) for a ticket URL

f
buildFrameAncestors

Build a frame-ancestors CSP value from allowed embed hosts. Returns null if the list is empty (allow embedding from anywhere).

f
buildSubdomainRecordName

Build the full subdomain record name (user choice + suffix). e.g. "mylisting" + ".tickets" → "mylisting.tickets"

f
checkSubdomainAvailable

Check whether a bunny subdomain is available.

f
deleteAllImageStorageFiles

Delete all first-class image files.

f
deleteAllListingAttachmentFiles

Delete all attachment files for a list of listings

f
deleteFile

Delete a file, routing to local or Bunny based on config.

f
deleteImageStorageFiles

Delete the full-size image and thumbnail files for a first-class image.

f
deleteImageStorageFilesStrict

Delete an image's storage files, throwing if any file could not be removed (a file that is already gone counts as success, so retries are safe). Unlike deleteImageStorageFiles, this surfaces failures so the caller can keep the image's DB record for a later retry instead of orphaning the stored files under a deleted record.

f
deleteListingAttachmentFile

Delete the attachment file for a single listing

f
deployScriptCode

Upload and publish new script code to a Bunny edge script (defaults to this host's own script when scriptId is omitted).

f
detectIframeMode

Detect iframe mode from a request URL and store it for the current request

f
detectImageType

Detect the actual image type from magic bytes. Returns the MIME type if matched, null otherwise.

f
downloadImage

Download and decrypt a file. Returns the decrypted bytes, or null if the file does not exist.

f
downloadRaw

Download raw bytes from storage. Returns null if the file does not exist.

f
generateAttachmentFilename

Generate a random CDN filename preserving the original name for readability

f
generateWebpFilename

Generate a random .webp filename. Every uploaded image is transcoded to WebP, so stored image variants always carry the .webp extension.

f
getBasename

Extract the basename from a path (handles both forward and backslash separators)

f
getCdnHostname

Get CDN hostname (delegates to bunnyCdnApi for testability).

f
getIframeMode

Get the current request's iframe mode

f
getImageProxyUrl

Images are encrypted at rest, so browsers load them through this route.

f
getMimeTypeFromFilename

Get the MIME type for an image filename from its extension.

f
getStorageBackend

Returns which storage backend is active: "bunny", "local", or "none".

f
isStorageEnabled

Check if image storage is enabled (Bunny CDN or local filesystem).

f
listFiles

List files in storage matching a prefix (names only), sorted by name.

f
listFilesWithMeta

List files (with size metadata) matching a path prefix, sorted by name. The prefix may name a subfolder (see splitListingPrefix); returned names always include that folder so callers can download/delete them directly. For Bunny CDN the size comes from the Length field of the listing API.

f
parseBunnyError

Parse a Bunny API error response into a BunnyApiResult.

f
parseEmbedHosts

Parse a comma-separated list of hosts into trimmed, lowercased entries. Filters out empty strings from trailing commas etc.

f
registerBunnySubdomain

Register a bunny subdomain (DNS + CDN).

f
runWithIframeContext

Run a function within an iframe-mode scope (one container per request)

f
runWithStorageConfig

Run fn with an isolated storage configuration (test-only).

f
sanitizeBasename

Strip a path's basename down with each [pattern, replacement] rule in turn, falling back to "file" when nothing is left. Shared by every filename sanitiser — each supplies its own character rules.

f
setStorageConfigForTest

Test-only: set the suite-level storage config that describeWithEnv's storage option applies. A directly-exported named function (not an export {} list, which the test-hook scanner does not detect, nor a module-level alias) so it is visible to and registered in ALLOWED_TEST_HOOKS (test/lib/code-quality.test.ts), alongside runWithStorageConfig.

f
tryDeleteFile

Try to delete a file from storage, logging errors on failure

f
uploadAttachment

Upload an attachment to Bunny storage. Encrypts the file bytes before uploading. Uses the provided filename (caller generates via generateAttachmentFilename). Returns the filename on success.

f
uploadRaw

Upload raw bytes to storage, routing to local or Bunny based on config

f
validateAttachment

Validate an attachment file: check size only (any file type allowed).

f
validateCustomDomain

Validate a custom domain (delegates to bunnyCdnApi for testability).

f
validateEmbedHosts

Validate a comma-separated list of host patterns. Returns null if all valid, or the first error message.

f
validateHostPattern

Validate a single host pattern Returns null if valid, or an error message if invalid

f
validateImage

Validate an image file: check size, the declared MIME type, and the magic bytes. Both the declared type and the sniffed content must be an accepted upload format; a mismatch or an unsupported format (e.g. a GIF, or a file whose bytes don't match any decodable format) is rejected. On success, detectedType is the sniffed format the transcoder will decode.

Interfaces

I
EdgeScriptSecret

A secret as reported by the Bunny API (name + metadata only — never the value).

Type Aliases

T
AttachmentValidationError

Attachment validation error

T
AttachmentValidationResult

Attachment validation result

T
EmbedSnippets
No documentation available
T
ImageValidationError

Image validation error

T
ImageValidationResult

Image validation result

T
StorageFileMeta

A stored file with its name and size in bytes.

Variables

v
ATTACHMENT_ERROR_MESSAGES

User-facing messages for attachment validation errors

v
bunnyHostingProvider
No documentation available
v
DOMAIN_PATTERN

Matches a valid hostname like "example.com" or "sub.example.com"

v
IMAGE_ERROR_MESSAGES

User-facing messages for image validation errors

v
MAX_ATTACHMENT_SIZE

Maximum attachment file size in bytes (default: 25MB)

v
uploadImageTargets

Transcode an uploaded image to WebP and store one file per target.