@cloudflare/workers-types 5.20261120.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.
@@ -288,7 +288,6 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
288
288
  FileSystemDirectoryHandle: typeof FileSystemDirectoryHandle;
289
289
  FileSystemWritableFileStream: typeof FileSystemWritableFileStream;
290
290
  StorageManager: typeof StorageManager;
291
- EventSource: typeof EventSource;
292
291
  ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
293
292
  ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
294
293
  ReadableByteStreamController: typeof ReadableByteStreamController;
@@ -335,6 +334,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
335
334
  PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
336
335
  MessageChannel: typeof MessageChannel;
337
336
  MessagePort: typeof MessagePort;
337
+ EventSource: typeof EventSource;
338
338
  }
339
339
  declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
340
340
  type: Type,
@@ -3676,58 +3676,6 @@ declare class Datagram {
3676
3676
  constructor(data: Uint8Array);
3677
3677
  get data(): Uint8Array;
3678
3678
  }
3679
- /**
3680
- * The **`EventSource`** interface is web content's interface to server-sent events.
3681
- *
3682
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3683
- */
3684
- declare class EventSource extends EventTarget {
3685
- constructor(url: string, init?: EventSourceEventSourceInit);
3686
- /**
3687
- * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
3688
- *
3689
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3690
- */
3691
- close(): void;
3692
- /**
3693
- * The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
3694
- *
3695
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3696
- */
3697
- get url(): string;
3698
- /**
3699
- * The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
3700
- *
3701
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3702
- */
3703
- get withCredentials(): boolean;
3704
- /**
3705
- * The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
3706
- *
3707
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3708
- */
3709
- get readyState(): number;
3710
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3711
- get onopen(): any | null;
3712
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3713
- set onopen(value: any | null);
3714
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3715
- get onmessage(): any | null;
3716
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3717
- set onmessage(value: any | null);
3718
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3719
- get onerror(): any | null;
3720
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3721
- set onerror(value: any | null);
3722
- static readonly CONNECTING: number;
3723
- static readonly OPEN: number;
3724
- static readonly CLOSED: number;
3725
- static from(stream: ReadableStream): EventSource;
3726
- }
3727
- interface EventSourceEventSourceInit {
3728
- withCredentials?: boolean;
3729
- fetcher?: Fetcher;
3730
- }
3731
3679
  interface ExecOutput {
3732
3680
  readonly stdout: ArrayBuffer;
3733
3681
  readonly stderr: ArrayBuffer;
@@ -15338,6 +15286,59 @@ declare module "cloudflare:email" {
15338
15286
  };
15339
15287
  export { _EmailMessage as EmailMessage };
15340
15288
  }
15289
+ // EventSource, a global at every compatibility date.
15290
+ /**
15291
+ * The **`EventSource`** interface is web content's interface to server-sent events.
15292
+ *
15293
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
15294
+ */
15295
+ declare class EventSource extends EventTarget {
15296
+ constructor(url: string, init?: EventSourceEventSourceInit);
15297
+ /**
15298
+ * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
15299
+ *
15300
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
15301
+ */
15302
+ close(): void;
15303
+ /**
15304
+ * The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
15305
+ *
15306
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
15307
+ */
15308
+ get url(): string;
15309
+ /**
15310
+ * The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
15311
+ *
15312
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
15313
+ */
15314
+ get withCredentials(): boolean;
15315
+ /**
15316
+ * The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
15317
+ *
15318
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
15319
+ */
15320
+ get readyState(): number;
15321
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
15322
+ get onopen(): any | null;
15323
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
15324
+ set onopen(value: any | null);
15325
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
15326
+ get onmessage(): any | null;
15327
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
15328
+ set onmessage(value: any | null);
15329
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
15330
+ get onerror(): any | null;
15331
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
15332
+ set onerror(value: any | null);
15333
+ static readonly CONNECTING: number;
15334
+ static readonly OPEN: number;
15335
+ static readonly CLOSED: number;
15336
+ static from(stream: ReadableStream): EventSource;
15337
+ }
15338
+ interface EventSourceEventSourceInit {
15339
+ withCredentials?: boolean;
15340
+ fetcher?: Fetcher;
15341
+ }
15341
15342
  /**
15342
15343
  * Evaluation context for targeting rules.
15343
15344
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
@@ -16857,6 +16858,7 @@ declare module "cloudflare:sockets" {
16857
16858
  * - Binding-level operations:
16858
16859
  * `await env.STREAM.videos.upload`
16859
16860
  * `await env.STREAM.videos.createDirectUpload`
16861
+ * `await env.STREAM.clip`
16860
16862
  * `await env.STREAM.videos.*`
16861
16863
  * `await env.STREAM.watermarks.*`
16862
16864
  * - Per-video operations:
@@ -16903,6 +16905,19 @@ interface StreamBinding {
16903
16905
  createDirectUpload(
16904
16906
  params: StreamDirectUploadCreateParams,
16905
16907
  ): Promise<StreamDirectUpload>;
16908
+ /**
16909
+ * Creates a new video by clipping a time range from an existing video.
16910
+ * @param videoId The unique identifier of the source video to clip from.
16911
+ * @param params The time range to clip from the source video.
16912
+ * @returns The details of the newly created clip.
16913
+ * @throws {NotFoundError} if the source video is not found
16914
+ * @throws {BadRequestError} if the time range is invalid or extends past the end of the source video
16915
+ * @throws {BadRequestError} if the source video is a live stream recording
16916
+ * @throws {QuotaReachedError} if the account storage capacity is exceeded
16917
+ * @throws {RateLimitedError} if the account has too many videos processing at once
16918
+ * @throws {InternalError} if an unexpected error occurs
16919
+ */
16920
+ clip(videoId: string, params: StreamClipParams): Promise<StreamVideo>;
16906
16921
  videos: StreamVideos;
16907
16922
  watermarks: StreamWatermarks;
16908
16923
  }
@@ -16939,10 +16954,13 @@ interface StreamVideoHandle {
16939
16954
  delete(): Promise<void>;
16940
16955
  /**
16941
16956
  * Creates a signed URL token for a video.
16957
+ * @param options Optional settings for the token.
16942
16958
  * @returns The signed token that was created.
16959
+ * @throws {NotFoundError} if the video is not found
16960
+ * @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
16943
16961
  * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
16944
16962
  */
16945
- generateToken(): Promise<string>;
16963
+ generateToken(options?: StreamSignedTokenOptions): Promise<string>;
16946
16964
  downloads: StreamScopedDownloads;
16947
16965
  captions: StreamScopedCaptions;
16948
16966
  }
@@ -17052,6 +17070,13 @@ interface StreamVideo {
17052
17070
  * Public details associated with the video.
17053
17071
  */
17054
17072
  publicDetails: StreamPublicDetails | null;
17073
+ /**
17074
+ * The unique customer code associated with the video.
17075
+ *
17076
+ * Use this to construct URLs that require a customer code, such as player URLs using signed tokens.
17077
+ * `https://customer-{customerCode}.cloudflarestream.com/{token}/iframe`
17078
+ */
17079
+ customerCode: string;
17055
17080
  }
17056
17081
  type StreamVideoStatus = {
17057
17082
  /**
@@ -17210,6 +17235,98 @@ type StreamUrlUploadParams = {
17210
17235
  */
17211
17236
  watermarkId?: string;
17212
17237
  };
17238
+ type StreamClipParams = {
17239
+ /**
17240
+ * The point in the source video, in whole seconds, where the clip starts.
17241
+ */
17242
+ startTimeSeconds: number;
17243
+ /**
17244
+ * The point in the source video, in whole seconds, where the clip ends.
17245
+ * Must be greater than `startTimeSeconds` and no later than the end of the
17246
+ * source video.
17247
+ */
17248
+ endTimeSeconds: number;
17249
+ };
17250
+ type StreamSignedTokenOptions = {
17251
+ /**
17252
+ * The signing key to sign the token with. When omitted, the token is signed
17253
+ * with a key Stream manages for the account.
17254
+ */
17255
+ signingKey?: StreamSigningKey;
17256
+ /**
17257
+ * When the token stops being accepted, as a `Date` or a Unix timestamp in
17258
+ * seconds. Must be in the future and no more than 24 hours from now.
17259
+ * Defaults to one hour from now.
17260
+ */
17261
+ expiresAt?: Date | number;
17262
+ /**
17263
+ * When the token starts being accepted, as a `Date` or a Unix timestamp in
17264
+ * seconds. Must be earlier than `expiresAt`. Defaults to one hour ago.
17265
+ */
17266
+ notBefore?: Date | number;
17267
+ /**
17268
+ * Whether the token can also be used to access the video's MP4 downloads.
17269
+ * @default false
17270
+ */
17271
+ downloadable?: boolean;
17272
+ /**
17273
+ * Rules that allow or block viewers by IP address or country. Rules are
17274
+ * evaluated in order, and the first rule that matches is applied.
17275
+ */
17276
+ accessRules?: StreamAccessRule[];
17277
+ /**
17278
+ * Additional flags for the token.
17279
+ */
17280
+ flags?: StreamSignedTokenFlags;
17281
+ };
17282
+ type StreamSigningKey = {
17283
+ /**
17284
+ * The ID of a Stream signing key.
17285
+ */
17286
+ id: string;
17287
+ /**
17288
+ * The base64-encoded private key, in PEM format, for the signing key.
17289
+ */
17290
+ pem: string;
17291
+ };
17292
+ type StreamSignedTokenFlags = {
17293
+ /**
17294
+ * Whether the token serves the original video without transformations.
17295
+ * @default false
17296
+ */
17297
+ original?: boolean;
17298
+ };
17299
+ type StreamAccessRuleAction = "allow" | "block";
17300
+ type StreamAccessRule =
17301
+ | {
17302
+ /**
17303
+ * Matches every request. Use as the last rule to set a default action.
17304
+ */
17305
+ type: "any";
17306
+ action: StreamAccessRuleAction;
17307
+ }
17308
+ | {
17309
+ /**
17310
+ * Matches requests from the listed IP addresses or CIDR ranges.
17311
+ */
17312
+ type: "ip.src";
17313
+ action: StreamAccessRuleAction;
17314
+ /**
17315
+ * IPv4 or IPv6 addresses or CIDR ranges.
17316
+ */
17317
+ ip: string[];
17318
+ }
17319
+ | {
17320
+ /**
17321
+ * Matches requests from the listed countries.
17322
+ */
17323
+ type: "ip.geoip.country";
17324
+ action: StreamAccessRuleAction;
17325
+ /**
17326
+ * Two-letter ISO 3166-1 alpha-2 country codes.
17327
+ */
17328
+ country: string[];
17329
+ };
17213
17330
  interface StreamScopedCaptions {
17214
17331
  /**
17215
17332
  * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
@@ -17244,6 +17361,15 @@ interface StreamScopedCaptions {
17244
17361
  * @throws {InternalError} if an unexpected error occurs
17245
17362
  */
17246
17363
  list(language?: string): Promise<StreamCaption[]>;
17364
+ /**
17365
+ * Gets the WebVTT file for a caption or subtitle track.
17366
+ * @param language The BCP 47 language tag of the track.
17367
+ * @returns The track's WebVTT file as a stream.
17368
+ * @throws {NotFoundError} if the video is not found, it has no caption for this language, or a generated caption has not finished
17369
+ * @throws {BadRequestError} if the language is not a valid BCP 47 tag
17370
+ * @throws {InternalError} if an unexpected error occurs
17371
+ */
17372
+ get(language: string): Promise<ReadableStream>;
17247
17373
  /**
17248
17374
  * Removes the captions or subtitles from a video.
17249
17375
  * @param language The BCP 47 language tag to remove.
@@ -288,7 +288,6 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
288
288
  FileSystemDirectoryHandle: typeof FileSystemDirectoryHandle;
289
289
  FileSystemWritableFileStream: typeof FileSystemWritableFileStream;
290
290
  StorageManager: typeof StorageManager;
291
- EventSource: typeof EventSource;
292
291
  ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
293
292
  ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
294
293
  ReadableByteStreamController: typeof ReadableByteStreamController;
@@ -335,6 +334,7 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
335
334
  PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
336
335
  MessageChannel: typeof MessageChannel;
337
336
  MessagePort: typeof MessagePort;
337
+ EventSource: typeof EventSource;
338
338
  }
339
339
  export declare function addEventListener<
340
340
  Type extends keyof WorkerGlobalScopeEventMap,
@@ -3682,58 +3682,6 @@ export declare class Datagram {
3682
3682
  constructor(data: Uint8Array);
3683
3683
  get data(): Uint8Array;
3684
3684
  }
3685
- /**
3686
- * The **`EventSource`** interface is web content's interface to server-sent events.
3687
- *
3688
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3689
- */
3690
- export declare class EventSource extends EventTarget {
3691
- constructor(url: string, init?: EventSourceEventSourceInit);
3692
- /**
3693
- * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
3694
- *
3695
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3696
- */
3697
- close(): void;
3698
- /**
3699
- * The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
3700
- *
3701
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3702
- */
3703
- get url(): string;
3704
- /**
3705
- * The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
3706
- *
3707
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3708
- */
3709
- get withCredentials(): boolean;
3710
- /**
3711
- * The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
3712
- *
3713
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3714
- */
3715
- get readyState(): number;
3716
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3717
- get onopen(): any | null;
3718
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3719
- set onopen(value: any | null);
3720
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3721
- get onmessage(): any | null;
3722
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3723
- set onmessage(value: any | null);
3724
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3725
- get onerror(): any | null;
3726
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3727
- set onerror(value: any | null);
3728
- static readonly CONNECTING: number;
3729
- static readonly OPEN: number;
3730
- static readonly CLOSED: number;
3731
- static from(stream: ReadableStream): EventSource;
3732
- }
3733
- export interface EventSourceEventSourceInit {
3734
- withCredentials?: boolean;
3735
- fetcher?: Fetcher;
3736
- }
3737
3685
  export interface ExecOutput {
3738
3686
  readonly stdout: ArrayBuffer;
3739
3687
  readonly stderr: ArrayBuffer;
@@ -15324,6 +15272,59 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
15324
15272
  env: Env,
15325
15273
  ctx: ExecutionContext<Props>,
15326
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
+ }
15327
15328
  /**
15328
15329
  * Evaluation context for targeting rules.
15329
15330
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
@@ -16757,6 +16758,7 @@ export interface SecretsStoreSecret {
16757
16758
  * - Binding-level operations:
16758
16759
  * `await env.STREAM.videos.upload`
16759
16760
  * `await env.STREAM.videos.createDirectUpload`
16761
+ * `await env.STREAM.clip`
16760
16762
  * `await env.STREAM.videos.*`
16761
16763
  * `await env.STREAM.watermarks.*`
16762
16764
  * - Per-video operations:
@@ -16803,6 +16805,19 @@ export interface StreamBinding {
16803
16805
  createDirectUpload(
16804
16806
  params: StreamDirectUploadCreateParams,
16805
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>;
16806
16821
  videos: StreamVideos;
16807
16822
  watermarks: StreamWatermarks;
16808
16823
  }
@@ -16839,10 +16854,13 @@ export interface StreamVideoHandle {
16839
16854
  delete(): Promise<void>;
16840
16855
  /**
16841
16856
  * Creates a signed URL token for a video.
16857
+ * @param options Optional settings for the token.
16842
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
16843
16861
  * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
16844
16862
  */
16845
- generateToken(): Promise<string>;
16863
+ generateToken(options?: StreamSignedTokenOptions): Promise<string>;
16846
16864
  downloads: StreamScopedDownloads;
16847
16865
  captions: StreamScopedCaptions;
16848
16866
  }
@@ -16952,6 +16970,13 @@ export interface StreamVideo {
16952
16970
  * Public details associated with the video.
16953
16971
  */
16954
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;
16955
16980
  }
16956
16981
  export type StreamVideoStatus = {
16957
16982
  /**
@@ -17110,6 +17135,98 @@ export type StreamUrlUploadParams = {
17110
17135
  */
17111
17136
  watermarkId?: string;
17112
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
+ };
17113
17230
  export interface StreamScopedCaptions {
17114
17231
  /**
17115
17232
  * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
@@ -17144,6 +17261,15 @@ export interface StreamScopedCaptions {
17144
17261
  * @throws {InternalError} if an unexpected error occurs
17145
17262
  */
17146
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>;
17147
17273
  /**
17148
17274
  * Removes the captions or subtitles from a video.
17149
17275
  * @param language The BCP 47 language tag to remove.
package/index.d.ts CHANGED
@@ -282,7 +282,6 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
282
282
  ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
283
283
  CountQueuingStrategy: typeof CountQueuingStrategy;
284
284
  ErrorEvent: typeof ErrorEvent;
285
- EventSource: typeof EventSource;
286
285
  ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
287
286
  ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
288
287
  ReadableByteStreamController: typeof ReadableByteStreamController;
@@ -336,6 +335,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
336
335
  PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
337
336
  MessageChannel: typeof MessageChannel;
338
337
  MessagePort: typeof MessagePort;
338
+ EventSource: typeof EventSource;
339
339
  }
340
340
  declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
341
341
  type: Type,
@@ -3498,58 +3498,6 @@ interface SocketInfo {
3498
3498
  remoteAddress?: string;
3499
3499
  localAddress?: string;
3500
3500
  }
3501
- /**
3502
- * The **`EventSource`** interface is web content's interface to server-sent events.
3503
- *
3504
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3505
- */
3506
- declare class EventSource extends EventTarget {
3507
- constructor(url: string, init?: EventSourceEventSourceInit);
3508
- /**
3509
- * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
3510
- *
3511
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3512
- */
3513
- close(): void;
3514
- /**
3515
- * The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
3516
- *
3517
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3518
- */
3519
- get url(): string;
3520
- /**
3521
- * The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
3522
- *
3523
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3524
- */
3525
- get withCredentials(): boolean;
3526
- /**
3527
- * The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
3528
- *
3529
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3530
- */
3531
- get readyState(): number;
3532
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3533
- get onopen(): any | null;
3534
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3535
- set onopen(value: any | null);
3536
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3537
- get onmessage(): any | null;
3538
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3539
- set onmessage(value: any | null);
3540
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3541
- get onerror(): any | null;
3542
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3543
- set onerror(value: any | null);
3544
- static readonly CONNECTING: number;
3545
- static readonly OPEN: number;
3546
- static readonly CLOSED: number;
3547
- static from(stream: ReadableStream): EventSource;
3548
- }
3549
- interface EventSourceEventSourceInit {
3550
- withCredentials?: boolean;
3551
- fetcher?: Fetcher;
3552
- }
3553
3501
  interface ExecOutput {
3554
3502
  readonly stdout: ArrayBuffer;
3555
3503
  readonly stderr: ArrayBuffer;
@@ -14970,6 +14918,59 @@ declare module "cloudflare:email" {
14970
14918
  };
14971
14919
  export { _EmailMessage as EmailMessage };
14972
14920
  }
14921
+ // EventSource, a global at every compatibility date.
14922
+ /**
14923
+ * The **`EventSource`** interface is web content's interface to server-sent events.
14924
+ *
14925
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
14926
+ */
14927
+ declare class EventSource extends EventTarget {
14928
+ constructor(url: string, init?: EventSourceEventSourceInit);
14929
+ /**
14930
+ * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
14931
+ *
14932
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
14933
+ */
14934
+ close(): void;
14935
+ /**
14936
+ * The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
14937
+ *
14938
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
14939
+ */
14940
+ get url(): string;
14941
+ /**
14942
+ * The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
14943
+ *
14944
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
14945
+ */
14946
+ get withCredentials(): boolean;
14947
+ /**
14948
+ * The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
14949
+ *
14950
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
14951
+ */
14952
+ get readyState(): number;
14953
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
14954
+ get onopen(): any | null;
14955
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
14956
+ set onopen(value: any | null);
14957
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
14958
+ get onmessage(): any | null;
14959
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
14960
+ set onmessage(value: any | null);
14961
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
14962
+ get onerror(): any | null;
14963
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
14964
+ set onerror(value: any | null);
14965
+ static readonly CONNECTING: number;
14966
+ static readonly OPEN: number;
14967
+ static readonly CLOSED: number;
14968
+ static from(stream: ReadableStream): EventSource;
14969
+ }
14970
+ interface EventSourceEventSourceInit {
14971
+ withCredentials?: boolean;
14972
+ fetcher?: Fetcher;
14973
+ }
14973
14974
  /**
14974
14975
  * Evaluation context for targeting rules.
14975
14976
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
@@ -16489,6 +16490,7 @@ declare module "cloudflare:sockets" {
16489
16490
  * - Binding-level operations:
16490
16491
  * `await env.STREAM.videos.upload`
16491
16492
  * `await env.STREAM.videos.createDirectUpload`
16493
+ * `await env.STREAM.clip`
16492
16494
  * `await env.STREAM.videos.*`
16493
16495
  * `await env.STREAM.watermarks.*`
16494
16496
  * - Per-video operations:
@@ -16535,6 +16537,19 @@ interface StreamBinding {
16535
16537
  createDirectUpload(
16536
16538
  params: StreamDirectUploadCreateParams,
16537
16539
  ): Promise<StreamDirectUpload>;
16540
+ /**
16541
+ * Creates a new video by clipping a time range from an existing video.
16542
+ * @param videoId The unique identifier of the source video to clip from.
16543
+ * @param params The time range to clip from the source video.
16544
+ * @returns The details of the newly created clip.
16545
+ * @throws {NotFoundError} if the source video is not found
16546
+ * @throws {BadRequestError} if the time range is invalid or extends past the end of the source video
16547
+ * @throws {BadRequestError} if the source video is a live stream recording
16548
+ * @throws {QuotaReachedError} if the account storage capacity is exceeded
16549
+ * @throws {RateLimitedError} if the account has too many videos processing at once
16550
+ * @throws {InternalError} if an unexpected error occurs
16551
+ */
16552
+ clip(videoId: string, params: StreamClipParams): Promise<StreamVideo>;
16538
16553
  videos: StreamVideos;
16539
16554
  watermarks: StreamWatermarks;
16540
16555
  }
@@ -16571,10 +16586,13 @@ interface StreamVideoHandle {
16571
16586
  delete(): Promise<void>;
16572
16587
  /**
16573
16588
  * Creates a signed URL token for a video.
16589
+ * @param options Optional settings for the token.
16574
16590
  * @returns The signed token that was created.
16591
+ * @throws {NotFoundError} if the video is not found
16592
+ * @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
16575
16593
  * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
16576
16594
  */
16577
- generateToken(): Promise<string>;
16595
+ generateToken(options?: StreamSignedTokenOptions): Promise<string>;
16578
16596
  downloads: StreamScopedDownloads;
16579
16597
  captions: StreamScopedCaptions;
16580
16598
  }
@@ -16684,6 +16702,13 @@ interface StreamVideo {
16684
16702
  * Public details associated with the video.
16685
16703
  */
16686
16704
  publicDetails: StreamPublicDetails | null;
16705
+ /**
16706
+ * The unique customer code associated with the video.
16707
+ *
16708
+ * Use this to construct URLs that require a customer code, such as player URLs using signed tokens.
16709
+ * `https://customer-{customerCode}.cloudflarestream.com/{token}/iframe`
16710
+ */
16711
+ customerCode: string;
16687
16712
  }
16688
16713
  type StreamVideoStatus = {
16689
16714
  /**
@@ -16842,6 +16867,98 @@ type StreamUrlUploadParams = {
16842
16867
  */
16843
16868
  watermarkId?: string;
16844
16869
  };
16870
+ type StreamClipParams = {
16871
+ /**
16872
+ * The point in the source video, in whole seconds, where the clip starts.
16873
+ */
16874
+ startTimeSeconds: number;
16875
+ /**
16876
+ * The point in the source video, in whole seconds, where the clip ends.
16877
+ * Must be greater than `startTimeSeconds` and no later than the end of the
16878
+ * source video.
16879
+ */
16880
+ endTimeSeconds: number;
16881
+ };
16882
+ type StreamSignedTokenOptions = {
16883
+ /**
16884
+ * The signing key to sign the token with. When omitted, the token is signed
16885
+ * with a key Stream manages for the account.
16886
+ */
16887
+ signingKey?: StreamSigningKey;
16888
+ /**
16889
+ * When the token stops being accepted, as a `Date` or a Unix timestamp in
16890
+ * seconds. Must be in the future and no more than 24 hours from now.
16891
+ * Defaults to one hour from now.
16892
+ */
16893
+ expiresAt?: Date | number;
16894
+ /**
16895
+ * When the token starts being accepted, as a `Date` or a Unix timestamp in
16896
+ * seconds. Must be earlier than `expiresAt`. Defaults to one hour ago.
16897
+ */
16898
+ notBefore?: Date | number;
16899
+ /**
16900
+ * Whether the token can also be used to access the video's MP4 downloads.
16901
+ * @default false
16902
+ */
16903
+ downloadable?: boolean;
16904
+ /**
16905
+ * Rules that allow or block viewers by IP address or country. Rules are
16906
+ * evaluated in order, and the first rule that matches is applied.
16907
+ */
16908
+ accessRules?: StreamAccessRule[];
16909
+ /**
16910
+ * Additional flags for the token.
16911
+ */
16912
+ flags?: StreamSignedTokenFlags;
16913
+ };
16914
+ type StreamSigningKey = {
16915
+ /**
16916
+ * The ID of a Stream signing key.
16917
+ */
16918
+ id: string;
16919
+ /**
16920
+ * The base64-encoded private key, in PEM format, for the signing key.
16921
+ */
16922
+ pem: string;
16923
+ };
16924
+ type StreamSignedTokenFlags = {
16925
+ /**
16926
+ * Whether the token serves the original video without transformations.
16927
+ * @default false
16928
+ */
16929
+ original?: boolean;
16930
+ };
16931
+ type StreamAccessRuleAction = "allow" | "block";
16932
+ type StreamAccessRule =
16933
+ | {
16934
+ /**
16935
+ * Matches every request. Use as the last rule to set a default action.
16936
+ */
16937
+ type: "any";
16938
+ action: StreamAccessRuleAction;
16939
+ }
16940
+ | {
16941
+ /**
16942
+ * Matches requests from the listed IP addresses or CIDR ranges.
16943
+ */
16944
+ type: "ip.src";
16945
+ action: StreamAccessRuleAction;
16946
+ /**
16947
+ * IPv4 or IPv6 addresses or CIDR ranges.
16948
+ */
16949
+ ip: string[];
16950
+ }
16951
+ | {
16952
+ /**
16953
+ * Matches requests from the listed countries.
16954
+ */
16955
+ type: "ip.geoip.country";
16956
+ action: StreamAccessRuleAction;
16957
+ /**
16958
+ * Two-letter ISO 3166-1 alpha-2 country codes.
16959
+ */
16960
+ country: string[];
16961
+ };
16845
16962
  interface StreamScopedCaptions {
16846
16963
  /**
16847
16964
  * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
@@ -16876,6 +16993,15 @@ interface StreamScopedCaptions {
16876
16993
  * @throws {InternalError} if an unexpected error occurs
16877
16994
  */
16878
16995
  list(language?: string): Promise<StreamCaption[]>;
16996
+ /**
16997
+ * Gets the WebVTT file for a caption or subtitle track.
16998
+ * @param language The BCP 47 language tag of the track.
16999
+ * @returns The track's WebVTT file as a stream.
17000
+ * @throws {NotFoundError} if the video is not found, it has no caption for this language, or a generated caption has not finished
17001
+ * @throws {BadRequestError} if the language is not a valid BCP 47 tag
17002
+ * @throws {InternalError} if an unexpected error occurs
17003
+ */
17004
+ get(language: string): Promise<ReadableStream>;
16879
17005
  /**
16880
17006
  * Removes the captions or subtitles from a video.
16881
17007
  * @param language The BCP 47 language tag to remove.
package/index.ts CHANGED
@@ -282,7 +282,6 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
282
282
  ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
283
283
  CountQueuingStrategy: typeof CountQueuingStrategy;
284
284
  ErrorEvent: typeof ErrorEvent;
285
- EventSource: typeof EventSource;
286
285
  ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
287
286
  ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
288
287
  ReadableByteStreamController: typeof ReadableByteStreamController;
@@ -336,6 +335,7 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
336
335
  PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
337
336
  MessageChannel: typeof MessageChannel;
338
337
  MessagePort: typeof MessagePort;
338
+ EventSource: typeof EventSource;
339
339
  }
340
340
  export declare function addEventListener<
341
341
  Type extends keyof WorkerGlobalScopeEventMap,
@@ -3507,58 +3507,6 @@ export interface SocketInfo {
3507
3507
  remoteAddress?: string;
3508
3508
  localAddress?: string;
3509
3509
  }
3510
- /**
3511
- * The **`EventSource`** interface is web content's interface to server-sent events.
3512
- *
3513
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3514
- */
3515
- export declare class EventSource extends EventTarget {
3516
- constructor(url: string, init?: EventSourceEventSourceInit);
3517
- /**
3518
- * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
3519
- *
3520
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3521
- */
3522
- close(): void;
3523
- /**
3524
- * The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
3525
- *
3526
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3527
- */
3528
- get url(): string;
3529
- /**
3530
- * The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
3531
- *
3532
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3533
- */
3534
- get withCredentials(): boolean;
3535
- /**
3536
- * The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
3537
- *
3538
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3539
- */
3540
- get readyState(): number;
3541
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3542
- get onopen(): any | null;
3543
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3544
- set onopen(value: any | null);
3545
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3546
- get onmessage(): any | null;
3547
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3548
- set onmessage(value: any | null);
3549
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3550
- get onerror(): any | null;
3551
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3552
- set onerror(value: any | null);
3553
- static readonly CONNECTING: number;
3554
- static readonly OPEN: number;
3555
- static readonly CLOSED: number;
3556
- static from(stream: ReadableStream): EventSource;
3557
- }
3558
- export interface EventSourceEventSourceInit {
3559
- withCredentials?: boolean;
3560
- fetcher?: Fetcher;
3561
- }
3562
3510
  export interface ExecOutput {
3563
3511
  readonly stdout: ArrayBuffer;
3564
3512
  readonly stderr: ArrayBuffer;
@@ -14959,6 +14907,59 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
14959
14907
  env: Env,
14960
14908
  ctx: ExecutionContext<Props>,
14961
14909
  ) => void | Promise<void>;
14910
+ // EventSource, a global at every compatibility date.
14911
+ /**
14912
+ * The **`EventSource`** interface is web content's interface to server-sent events.
14913
+ *
14914
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
14915
+ */
14916
+ export declare class EventSource extends EventTarget {
14917
+ constructor(url: string, init?: EventSourceEventSourceInit);
14918
+ /**
14919
+ * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).
14920
+ *
14921
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
14922
+ */
14923
+ close(): void;
14924
+ /**
14925
+ * The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.
14926
+ *
14927
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
14928
+ */
14929
+ get url(): string;
14930
+ /**
14931
+ * The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.
14932
+ *
14933
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
14934
+ */
14935
+ get withCredentials(): boolean;
14936
+ /**
14937
+ * The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.
14938
+ *
14939
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
14940
+ */
14941
+ get readyState(): number;
14942
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
14943
+ get onopen(): any | null;
14944
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
14945
+ set onopen(value: any | null);
14946
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
14947
+ get onmessage(): any | null;
14948
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
14949
+ set onmessage(value: any | null);
14950
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
14951
+ get onerror(): any | null;
14952
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
14953
+ set onerror(value: any | null);
14954
+ static readonly CONNECTING: number;
14955
+ static readonly OPEN: number;
14956
+ static readonly CLOSED: number;
14957
+ static from(stream: ReadableStream): EventSource;
14958
+ }
14959
+ export interface EventSourceEventSourceInit {
14960
+ withCredentials?: boolean;
14961
+ fetcher?: Fetcher;
14962
+ }
14962
14963
  /**
14963
14964
  * Evaluation context for targeting rules.
14964
14965
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
@@ -16392,6 +16393,7 @@ export interface SecretsStoreSecret {
16392
16393
  * - Binding-level operations:
16393
16394
  * `await env.STREAM.videos.upload`
16394
16395
  * `await env.STREAM.videos.createDirectUpload`
16396
+ * `await env.STREAM.clip`
16395
16397
  * `await env.STREAM.videos.*`
16396
16398
  * `await env.STREAM.watermarks.*`
16397
16399
  * - Per-video operations:
@@ -16438,6 +16440,19 @@ export interface StreamBinding {
16438
16440
  createDirectUpload(
16439
16441
  params: StreamDirectUploadCreateParams,
16440
16442
  ): Promise<StreamDirectUpload>;
16443
+ /**
16444
+ * Creates a new video by clipping a time range from an existing video.
16445
+ * @param videoId The unique identifier of the source video to clip from.
16446
+ * @param params The time range to clip from the source video.
16447
+ * @returns The details of the newly created clip.
16448
+ * @throws {NotFoundError} if the source video is not found
16449
+ * @throws {BadRequestError} if the time range is invalid or extends past the end of the source video
16450
+ * @throws {BadRequestError} if the source video is a live stream recording
16451
+ * @throws {QuotaReachedError} if the account storage capacity is exceeded
16452
+ * @throws {RateLimitedError} if the account has too many videos processing at once
16453
+ * @throws {InternalError} if an unexpected error occurs
16454
+ */
16455
+ clip(videoId: string, params: StreamClipParams): Promise<StreamVideo>;
16441
16456
  videos: StreamVideos;
16442
16457
  watermarks: StreamWatermarks;
16443
16458
  }
@@ -16474,10 +16489,13 @@ export interface StreamVideoHandle {
16474
16489
  delete(): Promise<void>;
16475
16490
  /**
16476
16491
  * Creates a signed URL token for a video.
16492
+ * @param options Optional settings for the token.
16477
16493
  * @returns The signed token that was created.
16494
+ * @throws {NotFoundError} if the video is not found
16495
+ * @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
16478
16496
  * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
16479
16497
  */
16480
- generateToken(): Promise<string>;
16498
+ generateToken(options?: StreamSignedTokenOptions): Promise<string>;
16481
16499
  downloads: StreamScopedDownloads;
16482
16500
  captions: StreamScopedCaptions;
16483
16501
  }
@@ -16587,6 +16605,13 @@ export interface StreamVideo {
16587
16605
  * Public details associated with the video.
16588
16606
  */
16589
16607
  publicDetails: StreamPublicDetails | null;
16608
+ /**
16609
+ * The unique customer code associated with the video.
16610
+ *
16611
+ * Use this to construct URLs that require a customer code, such as player URLs using signed tokens.
16612
+ * `https://customer-{customerCode}.cloudflarestream.com/{token}/iframe`
16613
+ */
16614
+ customerCode: string;
16590
16615
  }
16591
16616
  export type StreamVideoStatus = {
16592
16617
  /**
@@ -16745,6 +16770,98 @@ export type StreamUrlUploadParams = {
16745
16770
  */
16746
16771
  watermarkId?: string;
16747
16772
  };
16773
+ export type StreamClipParams = {
16774
+ /**
16775
+ * The point in the source video, in whole seconds, where the clip starts.
16776
+ */
16777
+ startTimeSeconds: number;
16778
+ /**
16779
+ * The point in the source video, in whole seconds, where the clip ends.
16780
+ * Must be greater than `startTimeSeconds` and no later than the end of the
16781
+ * source video.
16782
+ */
16783
+ endTimeSeconds: number;
16784
+ };
16785
+ export type StreamSignedTokenOptions = {
16786
+ /**
16787
+ * The signing key to sign the token with. When omitted, the token is signed
16788
+ * with a key Stream manages for the account.
16789
+ */
16790
+ signingKey?: StreamSigningKey;
16791
+ /**
16792
+ * When the token stops being accepted, as a `Date` or a Unix timestamp in
16793
+ * seconds. Must be in the future and no more than 24 hours from now.
16794
+ * Defaults to one hour from now.
16795
+ */
16796
+ expiresAt?: Date | number;
16797
+ /**
16798
+ * When the token starts being accepted, as a `Date` or a Unix timestamp in
16799
+ * seconds. Must be earlier than `expiresAt`. Defaults to one hour ago.
16800
+ */
16801
+ notBefore?: Date | number;
16802
+ /**
16803
+ * Whether the token can also be used to access the video's MP4 downloads.
16804
+ * @default false
16805
+ */
16806
+ downloadable?: boolean;
16807
+ /**
16808
+ * Rules that allow or block viewers by IP address or country. Rules are
16809
+ * evaluated in order, and the first rule that matches is applied.
16810
+ */
16811
+ accessRules?: StreamAccessRule[];
16812
+ /**
16813
+ * Additional flags for the token.
16814
+ */
16815
+ flags?: StreamSignedTokenFlags;
16816
+ };
16817
+ export type StreamSigningKey = {
16818
+ /**
16819
+ * The ID of a Stream signing key.
16820
+ */
16821
+ id: string;
16822
+ /**
16823
+ * The base64-encoded private key, in PEM format, for the signing key.
16824
+ */
16825
+ pem: string;
16826
+ };
16827
+ export type StreamSignedTokenFlags = {
16828
+ /**
16829
+ * Whether the token serves the original video without transformations.
16830
+ * @default false
16831
+ */
16832
+ original?: boolean;
16833
+ };
16834
+ export type StreamAccessRuleAction = "allow" | "block";
16835
+ export type StreamAccessRule =
16836
+ | {
16837
+ /**
16838
+ * Matches every request. Use as the last rule to set a default action.
16839
+ */
16840
+ type: "any";
16841
+ action: StreamAccessRuleAction;
16842
+ }
16843
+ | {
16844
+ /**
16845
+ * Matches requests from the listed IP addresses or CIDR ranges.
16846
+ */
16847
+ type: "ip.src";
16848
+ action: StreamAccessRuleAction;
16849
+ /**
16850
+ * IPv4 or IPv6 addresses or CIDR ranges.
16851
+ */
16852
+ ip: string[];
16853
+ }
16854
+ | {
16855
+ /**
16856
+ * Matches requests from the listed countries.
16857
+ */
16858
+ type: "ip.geoip.country";
16859
+ action: StreamAccessRuleAction;
16860
+ /**
16861
+ * Two-letter ISO 3166-1 alpha-2 country codes.
16862
+ */
16863
+ country: string[];
16864
+ };
16748
16865
  export interface StreamScopedCaptions {
16749
16866
  /**
16750
16867
  * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
@@ -16779,6 +16896,15 @@ export interface StreamScopedCaptions {
16779
16896
  * @throws {InternalError} if an unexpected error occurs
16780
16897
  */
16781
16898
  list(language?: string): Promise<StreamCaption[]>;
16899
+ /**
16900
+ * Gets the WebVTT file for a caption or subtitle track.
16901
+ * @param language The BCP 47 language tag of the track.
16902
+ * @returns The track's WebVTT file as a stream.
16903
+ * @throws {NotFoundError} if the video is not found, it has no caption for this language, or a generated caption has not finished
16904
+ * @throws {BadRequestError} if the language is not a valid BCP 47 tag
16905
+ * @throws {InternalError} if an unexpected error occurs
16906
+ */
16907
+ get(language: string): Promise<ReadableStream>;
16782
16908
  /**
16783
16909
  * Removes the captions or subtitles from a video.
16784
16910
  * @param language The BCP 47 language tag to remove.
package/package.json CHANGED
@@ -7,5 +7,5 @@
7
7
  },
8
8
  "author": "Cloudflare Workers DevProd Team <workers-devprod@cloudflare.com> (https://workers.cloudflare.com)",
9
9
  "license": "MIT OR Apache-2.0",
10
- "version": "5.20261120.1"
10
+ "version": "5.20261121.1"
11
11
  }