You can do Allowed Origins Only on videos, so if you were to embed the vidoe generated by a live inp
You can do Allowed Origins Only on videos, so if you were to embed the vidoe generated by a live input once it goes live, you would be protected
stream.connected webhook (or whatever its called) and make the necessary changes, and then embed it where necessary. That will depend on your specific needs/requirements
/token endpoint provided by Stream, to be able to only render the stream if your UI provides the correct credentialsrequiredSignedURLs to true, but those calls can be easily done from curl or anything not necessarily a worker
fetch() handler of a Worker script/captions endpoint on the video, without the language tag, is there any listed caption file attached to the video?
fetch()export default {
async fetch(request, env) {
// Global variables
const jwkKey = "{PRIVATE-KEY-IN-JWK-FORMAT}";
const keyID = "<KEY_ID>";
const videoUID = "<VIDEO_UID>";
// expiresTimeInS is the expired time in second of the video
const expiresTimeInS = 3600;
const encoder = new TextEncoder();
const expiresIn = Math.floor(Date.now() / 1000) + expiresTimeInS;
const headers = {
alg: "RS256",
kid: keyID,
};
const data = {
sub: videoUID,
kid: keyID,
exp: expiresIn,
accessRules: [
{
type: "ip.geoip.country",
action: "allow",
country: ["GB"],
},
{
type: "any",
action: "block",
},
],
};
const token = `${objectToBase64url(headers)}.${objectToBase64url(data)}`;
const jwk = JSON.parse(atob(jwkKey));
const key = await crypto.subtle.importKey(
"jwk",
jwk,
{
name: "RSASSA-PKCS1-v1_5",
hash: "SHA-256",
},
false,
["sign"],
);
const signature = await crypto.subtle.sign(
{ name: "RSASSA-PKCS1-v1_5" },
key,
encoder.encode(token),
);
const signedToken = `${token}.${arrayBufferToBase64Url(signature)}`;
return signedToken;
// Utilities functions
function arrayBufferToBase64Url(buffer) {
return btoa(String.fromCharCode(...new Uint8Array(buffer)))
.replace(/=/g, "")
.replace(/\+/g, "-")
.replace(/\//g, "_");
}
function objectToBase64url(payload) {
return arrayBufferToBase64Url(
new TextEncoder().encode(JSON.stringify(payload)),
);
}
},
};/captions[
{
"result": [
{
"language": "en",
"label": "English",
"generated": false,
"status": "ready"
}
],
"success": true,
"errors": [],
"messages": []
}
]