Skip to content

Commit 9edd53d

Browse files
committed
feat: add generateEmbedToken method for iframe token generation
1 parent 0dd0369 commit 9edd53d

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,28 @@ export class BunnyCdnStream {
758758
};
759759
}
760760

761+
/**
762+
* Generate an embed token for an iframe
763+
*
764+
* @param videoId
765+
* @param tokenSecurityKey
766+
* @param expirationTime
767+
* @returns A sha256 hash string
768+
*/
769+
public async generateEmbedToken(
770+
videoId: string,
771+
tokenSecurityKey: string,
772+
expirationTime: number,
773+
) {
774+
return createHash("sha256")
775+
.update(
776+
tokenSecurityKey.toString() +
777+
videoId.toString() +
778+
expirationTime.toString(),
779+
)
780+
.digest("hex");
781+
}
782+
761783
private generateTUSHash(videoId: string, expirationTime: number) {
762784
// sha256(library_id + api_key + expiration_time + video_id)
763785
return createHash("sha256")

0 commit comments

Comments
 (0)