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(url: string): string

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

f
buildEmbedSnippets(url: string): EmbedSnippets

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

f
buildFrameAncestors(hosts: string[]): string | null

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

f
buildSubdomainRecordName(subdomain: string): string

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

f
checkSubdomainAvailable(subdomain: string)

Check whether a bunny subdomain is available.

f
deleteAllEventStorageFiles(events: ReadonlyArray<EventWithStorage>): Promise<void>

Delete all storage files (images and attachments) for a list of events

f
deleteEventStorageFiles(
event: EventWithStorage,
reason: string
): Promise<void>

Delete the image and attachment files for a single event

f
deleteFile(filename: string): Promise<void>

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

f
deployScriptCode(code: string): Promise<BunnyApiResult>

Upload and publish new script code to Bunny CDN.

f
detectIframeMode(url: string): void

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

f
detectImageType(data: Uint8Array): string | null

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

f
downloadImage(filename: string): Promise<Uint8Array | null>

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

f
downloadRaw(filename: string): Promise<Uint8Array | null>

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

f
generateAttachmentFilename(originalName: string): string

Generate a random CDN filename preserving the original name for readability

f
generateImageFilename(detectedType: string): string

Generate a random filename with the correct extension

f
getCdnHostname(): Promise<CdnHostnameResult>

Get CDN hostname (delegates to bunnyCdnApi for testability).

f
getIframeMode(): boolean

Get the current request's iframe mode

f
getImageProxyUrl(filename: string): string

Get the proxy URL path for serving a decrypted image. Images are encrypted on CDN, so they must be served through the proxy.

f
getMimeTypeFromFilename(filename: string): string | null

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

f
getStorageBackend(): "bunny" | "local" | "none"

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

f
isStorageEnabled(): boolean

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

f
listFiles(prefix: string): Promise<string[]>

List files in storage matching a prefix

f
parseEmbedHosts(input: string): string[]

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

f
registerBunnySubdomain(subdomain: string)

Register a bunny subdomain (DNS + CDN).

f
runWithStorageConfig<T>(
config: StorageConfig,
fn: () => T
): T

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

f
tryDeleteFile(
filename: string,
eventId: number | undefined,
detail: string
): Promise<void>

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

f
uploadAttachment(
data: Uint8Array,
filename: string
): Promise<string>

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
uploadImage(
data: Uint8Array,
detectedType: string
): Promise<string>

Upload an image to Bunny storage. Encrypts the image bytes before uploading. Returns the filename (without path) on success.

f
uploadRaw(
data: Uint8Array,
filename: string
): Promise<string>

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

f
validateAttachment(data: Uint8Array): AttachmentValidationResult

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

f
validateCustomDomain(hostname: string): Promise<BunnyApiResult>

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

f
validateEmbedHosts(input: string): string | null

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

f
validateHostPattern(host: string): string | null

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

f
validateImage(
data: Uint8Array,
contentType: string
): ImageValidationResult

Validate an image file: check MIME type, size, and magic bytes.

Type Aliases

Variables