@cloudflare/workers-types 5.20261119.1 → 5.20261121.1

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.
@@ -252,7 +252,6 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
252
252
  ): number;
253
253
  clearInterval(timeoutId: number | null): void;
254
254
  queueMicrotask(task: Function): void;
255
- structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
256
255
  reportError(error: any): void;
257
256
  fetch(
258
257
  input: RequestInfo | URL,
@@ -284,14 +283,11 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
284
283
  ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
285
284
  CountQueuingStrategy: typeof CountQueuingStrategy;
286
285
  ErrorEvent: typeof ErrorEvent;
287
- MessageChannel: typeof MessageChannel;
288
- MessagePort: typeof MessagePort;
289
286
  FileSystemHandle: typeof FileSystemHandle;
290
287
  FileSystemFileHandle: typeof FileSystemFileHandle;
291
288
  FileSystemDirectoryHandle: typeof FileSystemDirectoryHandle;
292
289
  FileSystemWritableFileStream: typeof FileSystemWritableFileStream;
293
290
  StorageManager: typeof StorageManager;
294
- EventSource: typeof EventSource;
295
291
  ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
296
292
  ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
297
293
  ReadableByteStreamController: typeof ReadableByteStreamController;
@@ -336,6 +332,9 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
336
332
  PerformanceResourceTiming: typeof PerformanceResourceTiming;
337
333
  PerformanceObserver: typeof PerformanceObserver;
338
334
  PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
335
+ MessageChannel: typeof MessageChannel;
336
+ MessagePort: typeof MessagePort;
337
+ EventSource: typeof EventSource;
339
338
  }
340
339
  export declare function addEventListener<
341
340
  Type extends keyof WorkerGlobalScopeEventMap,
@@ -391,11 +390,6 @@ export declare function setInterval<Args extends any[]>(
391
390
  export declare function clearInterval(timeoutId: number | null): void;
392
391
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
393
392
  export declare function queueMicrotask(task: Function): void;
394
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
395
- export declare function structuredClone<T>(
396
- value: T,
397
- options?: StructuredSerializeOptions,
398
- ): T;
399
393
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
400
394
  export declare function reportError(error: any): void;
401
395
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
@@ -519,9 +513,6 @@ export interface ExportedHandler<
519
513
  email?: EmailExportedHandler<Env, Props>;
520
514
  queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
521
515
  }
522
- export interface StructuredSerializeOptions {
523
- transfer?: any[];
524
- }
525
516
  export declare abstract class Navigator {
526
517
  sendBeacon(url: string, body?: BodyInit): boolean;
527
518
  readonly userAgent: string;
@@ -3669,6 +3660,7 @@ export interface Socket {
3669
3660
  close(): Promise<void>;
3670
3661
  startTls(options?: TlsOptions): Socket;
3671
3662
  proxyTo(sock: Socket, options?: StreamPipeOptions): Promise<void>;
3663
+ accept(): void;
3672
3664
  }
3673
3665
  export interface SocketOptions {
3674
3666
  secureTransport?: string;
@@ -3690,58 +3682,6 @@ export declare class Datagram {
3690
3682
  constructor(data: Uint8Array);
3691
3683
  get data(): Uint8Array;
3692
3684
  }
3693
- /**
3694
- * The **`EventSource`** interface is web content's interface to server-sent events.
3695
- *
3696
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3697
- */
3698
- export declare class EventSource extends EventTarget {
3699
- constructor(url: string, init?: EventSourceEventSourceInit);
3700
- /**
3701
- * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
3702
- *
3703
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3704
- */
3705
- close(): void;
3706
- /**
3707
- * The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
3708
- *
3709
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3710
- */
3711
- get url(): string;
3712
- /**
3713
- * The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
3714
- *
3715
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3716
- */
3717
- get withCredentials(): boolean;
3718
- /**
3719
- * The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
3720
- *
3721
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3722
- */
3723
- get readyState(): number;
3724
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3725
- get onopen(): any | null;
3726
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3727
- set onopen(value: any | null);
3728
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3729
- get onmessage(): any | null;
3730
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3731
- set onmessage(value: any | null);
3732
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3733
- get onerror(): any | null;
3734
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3735
- set onerror(value: any | null);
3736
- static readonly CONNECTING: number;
3737
- static readonly OPEN: number;
3738
- static readonly CLOSED: number;
3739
- static from(stream: ReadableStream): EventSource;
3740
- }
3741
- export interface EventSourceEventSourceInit {
3742
- withCredentials?: boolean;
3743
- fetcher?: Fetcher;
3744
- }
3745
3685
  export interface ExecOutput {
3746
3686
  readonly stdout: ArrayBuffer;
3747
3687
  readonly stderr: ArrayBuffer;
@@ -4029,59 +3969,6 @@ export interface FileSystemFileWriteParams {
4029
3969
  export interface FileSystemHandleRemoveOptions {
4030
3970
  recursive?: boolean;
4031
3971
  }
4032
- /**
4033
- * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
4034
- *
4035
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
4036
- */
4037
- export declare abstract class MessagePort extends EventTarget {
4038
- /**
4039
- * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
4040
- *
4041
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
4042
- */
4043
- postMessage(
4044
- data?: any,
4045
- options?: any[] | MessagePortPostMessageOptions,
4046
- ): void;
4047
- /**
4048
- * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
4049
- *
4050
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
4051
- */
4052
- close(): void;
4053
- /**
4054
- * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.
4055
- *
4056
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
4057
- */
4058
- start(): void;
4059
- get onmessage(): any | null;
4060
- set onmessage(value: any | null);
4061
- }
4062
- /**
4063
- * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
4064
- *
4065
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
4066
- */
4067
- export declare class MessageChannel {
4068
- constructor();
4069
- /**
4070
- * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.
4071
- *
4072
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
4073
- */
4074
- readonly port1: MessagePort;
4075
- /**
4076
- * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.
4077
- *
4078
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
4079
- */
4080
- readonly port2: MessagePort;
4081
- }
4082
- export interface MessagePortPostMessageOptions {
4083
- transfer?: any[];
4084
- }
4085
3972
  export type LoopbackForExport<
4086
3973
  T extends
4087
3974
  | (new (...args: any[]) => Rpc.EntrypointBranded)
@@ -13569,21 +13456,31 @@ export type BrowserRunScriptOptions = {
13569
13456
  lab?: boolean;
13570
13457
  /** Record the browser session. @default false */
13571
13458
  recording?: boolean;
13459
+ /** Run the script on an alternate browser backend. Only the raw CDP client is
13460
+ * supported, and no session is kept open afterwards. Setting `library`,
13461
+ * `keepAlive`, `lab` or `recording` with it returns an HTTP 400 error
13462
+ * response.
13463
+ */
13464
+ browser?: "kitesurf";
13572
13465
  };
13573
- /** Options for `scriptInSession()`. */
13466
+ /** Options for `script()` in an existing browser session. */
13574
13467
  export type BrowserRunScriptSessionOptions = {
13468
+ /** Session to run in, such as the `cf-browser-session-id` header returned by
13469
+ * `script()`. The session keeps the launch options it was acquired with.
13470
+ */
13471
+ sessionId: string;
13472
+ /** Page target the script attaches to, such as the `cf-browser-target-id`
13473
+ * header returned by `script()`. Defaults to the session's first page.
13474
+ */
13475
+ targetId?: string;
13575
13476
  /** Library whose objects are passed to the script. Omit it for raw CDP. */
13576
13477
  library?: BrowserRunScriptLibrary;
13577
13478
  /** Maximum run time of the script in milliseconds. Between 1 and 120000.
13578
13479
  * @default 60000
13579
13480
  */
13580
13481
  timeout?: number;
13581
- /** Page target the script attaches to, such as the `cf-browser-target-id`
13582
- * header returned by `script()`. Defaults to the session's first page.
13583
- */
13584
- targetId?: string;
13585
13482
  };
13586
- /** JSON success body of `script()` and `scriptInSession()`. */
13483
+ /** JSON success body of `script()`. */
13587
13484
  export type BrowserRunScriptSuccessResponse = {
13588
13485
  success: true;
13589
13486
  /** The script's return value, or `null` when it returned nothing. */
@@ -13808,7 +13705,7 @@ export declare abstract class BrowserRun {
13808
13705
  * @param code - Source of an async function. It receives the selected
13809
13706
  * library's objects (Playwright `{ page, context, browser }`, Puppeteer
13810
13707
  * `{ page, browser }`) or, without `library`, a CDP client.
13811
- * @param options - Library, timeout and session launch options.
13708
+ * @param options - Library, timeout, session launch and backend options.
13812
13709
  * @returns A `Response` containing one of:
13813
13710
  *
13814
13711
  * **Success (HTTP 200):**
@@ -13818,26 +13715,28 @@ export declare abstract class BrowserRun {
13818
13715
  * non-JSON output
13819
13716
  *
13820
13717
  * **Error:**
13821
- * - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 503)
13718
+ * - JSON error body with an HTTP status code (400, 404, 408, 422, 429, 500, 502, 503)
13822
13719
  * - HTTP 408 when the script exceeds `timeout`
13823
13720
  * - HTTP 422 when the script fails to compile or throws
13721
+ * - HTTP 502 when the script fails on the `browser: 'kitesurf'` backend
13824
13722
  * - HTTP errors are returned as a `Response`, not thrown. Invalid `options`
13825
13723
  * throw before any request is made.
13826
13724
  *
13827
- * **Headers:**
13828
- * - `cf-browser-session-id`: Session kept open for `scriptInSession()`
13725
+ * **Headers** (not returned with `browser: 'kitesurf'`):
13726
+ * - `cf-browser-session-id`: Session kept open for a later `script()` call
13727
+ * with `sessionId`
13829
13728
  * - `cf-browser-target-id`: Page target the script ran on
13830
13729
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13831
13730
  */
13832
13731
  script(code: string, options?: BrowserRunScriptOptions): Promise<Response>;
13833
13732
  /**
13834
13733
  * Run a script against an existing browser session, such as one kept open by
13835
- * `script()`.
13836
- * @param sessionId - Session to run in, such as the `cf-browser-session-id`
13837
- * header returned by `script()`.
13838
- * @param code - Source of an async function, as for `script()`.
13839
- * @param options - Library, timeout and page target options.
13840
- * @returns A `Response` with the same success bodies as `script()`.
13734
+ * an earlier `script()` call.
13735
+ * @param code - Source of an async function, as for a new session.
13736
+ * @param options - The session to run in, plus page target, library and
13737
+ * timeout options. Launch options such as `keepAlive` cannot be set, because
13738
+ * the session keeps the ones it was acquired with.
13739
+ * @returns A `Response` with the same success bodies as a new-session run.
13841
13740
  *
13842
13741
  * **Error:**
13843
13742
  * - JSON error body with an HTTP status code (400, 401, 404, 408, 410, 422, 500)
@@ -13849,10 +13748,9 @@ export declare abstract class BrowserRun {
13849
13748
  * **Headers:**
13850
13749
  * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds
13851
13750
  */
13852
- scriptInSession(
13853
- sessionId: string,
13751
+ script(
13854
13752
  code: string,
13855
- options?: BrowserRunScriptSessionOptions,
13753
+ options: BrowserRunScriptSessionOptions,
13856
13754
  ): Promise<Response>;
13857
13755
  /** DevTools JSON methods exposed through one nested binding target. */
13858
13756
  get devtools(): BrowserRunDevtools;
@@ -15374,6 +15272,59 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
15374
15272
  env: Env,
15375
15273
  ctx: ExecutionContext<Props>,
15376
15274
  ) => void | Promise<void>;
15275
+ // EventSource, a global at every compatibility date.
15276
+ /**
15277
+ * The **`EventSource`** interface is web content's interface to server-sent events.
15278
+ *
15279
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
15280
+ */
15281
+ export declare class EventSource extends EventTarget {
15282
+ constructor(url: string, init?: EventSourceEventSourceInit);
15283
+ /**
15284
+ * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
15285
+ *
15286
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
15287
+ */
15288
+ close(): void;
15289
+ /**
15290
+ * The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
15291
+ *
15292
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
15293
+ */
15294
+ get url(): string;
15295
+ /**
15296
+ * The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
15297
+ *
15298
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
15299
+ */
15300
+ get withCredentials(): boolean;
15301
+ /**
15302
+ * The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
15303
+ *
15304
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
15305
+ */
15306
+ get readyState(): number;
15307
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
15308
+ get onopen(): any | null;
15309
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
15310
+ set onopen(value: any | null);
15311
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
15312
+ get onmessage(): any | null;
15313
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
15314
+ set onmessage(value: any | null);
15315
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
15316
+ get onerror(): any | null;
15317
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
15318
+ set onerror(value: any | null);
15319
+ static readonly CONNECTING: number;
15320
+ static readonly OPEN: number;
15321
+ static readonly CLOSED: number;
15322
+ static from(stream: ReadableStream): EventSource;
15323
+ }
15324
+ export interface EventSourceEventSourceInit {
15325
+ withCredentials?: boolean;
15326
+ fetcher?: Fetcher;
15327
+ }
15377
15328
  /**
15378
15329
  * Evaluation context for targeting rules.
15379
15330
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
@@ -16156,6 +16107,62 @@ export interface MediaError extends Error {
16156
16107
  readonly message: string;
16157
16108
  readonly stack?: string;
16158
16109
  }
16110
+ // MessageChannel and MessagePort, declared at every compatibility date. They
16111
+ // are globals under the expose_global_message_channel compatibility flag (the
16112
+ // default from 2025-08-15); node:worker_threads exports them at any date.
16113
+ /**
16114
+ * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
16115
+ *
16116
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
16117
+ */
16118
+ export declare abstract class MessagePort extends EventTarget {
16119
+ /**
16120
+ * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
16121
+ *
16122
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
16123
+ */
16124
+ postMessage(
16125
+ data?: any,
16126
+ options?: any[] | MessagePortPostMessageOptions,
16127
+ ): void;
16128
+ /**
16129
+ * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.
16130
+ *
16131
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
16132
+ */
16133
+ close(): void;
16134
+ /**
16135
+ * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.
16136
+ *
16137
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
16138
+ */
16139
+ start(): void;
16140
+ get onmessage(): any | null;
16141
+ set onmessage(value: any | null);
16142
+ }
16143
+ /**
16144
+ * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
16145
+ *
16146
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
16147
+ */
16148
+ export declare class MessageChannel {
16149
+ constructor();
16150
+ /**
16151
+ * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.
16152
+ *
16153
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
16154
+ */
16155
+ readonly port1: MessagePort;
16156
+ /**
16157
+ * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.
16158
+ *
16159
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
16160
+ */
16161
+ readonly port2: MessagePort;
16162
+ }
16163
+ export interface MessagePortPostMessageOptions {
16164
+ transfer?: any[];
16165
+ }
16159
16166
  export type Params<P extends string = any> = Record<P, string | string[]>;
16160
16167
  export type EventContext<Env, P extends string, Data> = {
16161
16168
  request: Request<unknown, IncomingRequestCfProperties<unknown>>;
@@ -16751,6 +16758,7 @@ export interface SecretsStoreSecret {
16751
16758
  * - Binding-level operations:
16752
16759
  * `await env.STREAM.videos.upload`
16753
16760
  * `await env.STREAM.videos.createDirectUpload`
16761
+ * `await env.STREAM.clip`
16754
16762
  * `await env.STREAM.videos.*`
16755
16763
  * `await env.STREAM.watermarks.*`
16756
16764
  * - Per-video operations:
@@ -16797,6 +16805,19 @@ export interface StreamBinding {
16797
16805
  createDirectUpload(
16798
16806
  params: StreamDirectUploadCreateParams,
16799
16807
  ): Promise<StreamDirectUpload>;
16808
+ /**
16809
+ * Creates a new video by clipping a time range from an existing video.
16810
+ * @param videoId The unique identifier of the source video to clip from.
16811
+ * @param params The time range to clip from the source video.
16812
+ * @returns The details of the newly created clip.
16813
+ * @throws {NotFoundError} if the source video is not found
16814
+ * @throws {BadRequestError} if the time range is invalid or extends past the end of the source video
16815
+ * @throws {BadRequestError} if the source video is a live stream recording
16816
+ * @throws {QuotaReachedError} if the account storage capacity is exceeded
16817
+ * @throws {RateLimitedError} if the account has too many videos processing at once
16818
+ * @throws {InternalError} if an unexpected error occurs
16819
+ */
16820
+ clip(videoId: string, params: StreamClipParams): Promise<StreamVideo>;
16800
16821
  videos: StreamVideos;
16801
16822
  watermarks: StreamWatermarks;
16802
16823
  }
@@ -16833,10 +16854,13 @@ export interface StreamVideoHandle {
16833
16854
  delete(): Promise<void>;
16834
16855
  /**
16835
16856
  * Creates a signed URL token for a video.
16857
+ * @param options Optional settings for the token.
16836
16858
  * @returns The signed token that was created.
16859
+ * @throws {NotFoundError} if the video is not found
16860
+ * @throws {BadRequestError} if the options are invalid, e.g. `expiresAt` is in the past or more than 24 hours away, `notBefore` is not before `expiresAt`, or the signing key is not found or does not belong to the account
16837
16861
  * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
16838
16862
  */
16839
- generateToken(): Promise<string>;
16863
+ generateToken(options?: StreamSignedTokenOptions): Promise<string>;
16840
16864
  downloads: StreamScopedDownloads;
16841
16865
  captions: StreamScopedCaptions;
16842
16866
  }
@@ -16946,6 +16970,13 @@ export interface StreamVideo {
16946
16970
  * Public details associated with the video.
16947
16971
  */
16948
16972
  publicDetails: StreamPublicDetails | null;
16973
+ /**
16974
+ * The unique customer code associated with the video.
16975
+ *
16976
+ * Use this to construct URLs that require a customer code, such as player URLs using signed tokens.
16977
+ * `https://customer-{customerCode}.cloudflarestream.com/{token}/iframe`
16978
+ */
16979
+ customerCode: string;
16949
16980
  }
16950
16981
  export type StreamVideoStatus = {
16951
16982
  /**
@@ -17104,6 +17135,98 @@ export type StreamUrlUploadParams = {
17104
17135
  */
17105
17136
  watermarkId?: string;
17106
17137
  };
17138
+ export type StreamClipParams = {
17139
+ /**
17140
+ * The point in the source video, in whole seconds, where the clip starts.
17141
+ */
17142
+ startTimeSeconds: number;
17143
+ /**
17144
+ * The point in the source video, in whole seconds, where the clip ends.
17145
+ * Must be greater than `startTimeSeconds` and no later than the end of the
17146
+ * source video.
17147
+ */
17148
+ endTimeSeconds: number;
17149
+ };
17150
+ export type StreamSignedTokenOptions = {
17151
+ /**
17152
+ * The signing key to sign the token with. When omitted, the token is signed
17153
+ * with a key Stream manages for the account.
17154
+ */
17155
+ signingKey?: StreamSigningKey;
17156
+ /**
17157
+ * When the token stops being accepted, as a `Date` or a Unix timestamp in
17158
+ * seconds. Must be in the future and no more than 24 hours from now.
17159
+ * Defaults to one hour from now.
17160
+ */
17161
+ expiresAt?: Date | number;
17162
+ /**
17163
+ * When the token starts being accepted, as a `Date` or a Unix timestamp in
17164
+ * seconds. Must be earlier than `expiresAt`. Defaults to one hour ago.
17165
+ */
17166
+ notBefore?: Date | number;
17167
+ /**
17168
+ * Whether the token can also be used to access the video's MP4 downloads.
17169
+ * @default false
17170
+ */
17171
+ downloadable?: boolean;
17172
+ /**
17173
+ * Rules that allow or block viewers by IP address or country. Rules are
17174
+ * evaluated in order, and the first rule that matches is applied.
17175
+ */
17176
+ accessRules?: StreamAccessRule[];
17177
+ /**
17178
+ * Additional flags for the token.
17179
+ */
17180
+ flags?: StreamSignedTokenFlags;
17181
+ };
17182
+ export type StreamSigningKey = {
17183
+ /**
17184
+ * The ID of a Stream signing key.
17185
+ */
17186
+ id: string;
17187
+ /**
17188
+ * The base64-encoded private key, in PEM format, for the signing key.
17189
+ */
17190
+ pem: string;
17191
+ };
17192
+ export type StreamSignedTokenFlags = {
17193
+ /**
17194
+ * Whether the token serves the original video without transformations.
17195
+ * @default false
17196
+ */
17197
+ original?: boolean;
17198
+ };
17199
+ export type StreamAccessRuleAction = "allow" | "block";
17200
+ export type StreamAccessRule =
17201
+ | {
17202
+ /**
17203
+ * Matches every request. Use as the last rule to set a default action.
17204
+ */
17205
+ type: "any";
17206
+ action: StreamAccessRuleAction;
17207
+ }
17208
+ | {
17209
+ /**
17210
+ * Matches requests from the listed IP addresses or CIDR ranges.
17211
+ */
17212
+ type: "ip.src";
17213
+ action: StreamAccessRuleAction;
17214
+ /**
17215
+ * IPv4 or IPv6 addresses or CIDR ranges.
17216
+ */
17217
+ ip: string[];
17218
+ }
17219
+ | {
17220
+ /**
17221
+ * Matches requests from the listed countries.
17222
+ */
17223
+ type: "ip.geoip.country";
17224
+ action: StreamAccessRuleAction;
17225
+ /**
17226
+ * Two-letter ISO 3166-1 alpha-2 country codes.
17227
+ */
17228
+ country: string[];
17229
+ };
17107
17230
  export interface StreamScopedCaptions {
17108
17231
  /**
17109
17232
  * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
@@ -17138,6 +17261,15 @@ export interface StreamScopedCaptions {
17138
17261
  * @throws {InternalError} if an unexpected error occurs
17139
17262
  */
17140
17263
  list(language?: string): Promise<StreamCaption[]>;
17264
+ /**
17265
+ * Gets the WebVTT file for a caption or subtitle track.
17266
+ * @param language The BCP 47 language tag of the track.
17267
+ * @returns The track's WebVTT file as a stream.
17268
+ * @throws {NotFoundError} if the video is not found, it has no caption for this language, or a generated caption has not finished
17269
+ * @throws {BadRequestError} if the language is not a valid BCP 47 tag
17270
+ * @throws {InternalError} if an unexpected error occurs
17271
+ */
17272
+ get(language: string): Promise<ReadableStream>;
17141
17273
  /**
17142
17274
  * Removes the captions or subtitles from a video.
17143
17275
  * @param language The BCP 47 language tag to remove.
@@ -17487,6 +17619,17 @@ export interface AlreadyUploadedError extends StreamError {
17487
17619
  export interface TooManyWatermarksError extends StreamError {
17488
17620
  name: "TooManyWatermarksError";
17489
17621
  }
17622
+ export interface StructuredSerializeOptions {
17623
+ transfer?: any[];
17624
+ }
17625
+ export interface ServiceWorkerGlobalScope {
17626
+ structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
17627
+ }
17628
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
17629
+ export declare function structuredClone<T>(
17630
+ value: T,
17631
+ options?: StructuredSerializeOptions,
17632
+ ): T;
17490
17633
  export type MarkdownDocument = {
17491
17634
  name: string;
17492
17635
  blob: Blob;