@sanity/client
Version:
Client for retrieving, creating and patching data from Sanity.io
42 lines (41 loc) • 1.22 kB
JavaScript
/**
* Check if a playback info item (stream/thumbnail/etc) has a signed token
* @internal
*/
function isSignedPlayback(item) {
return "token" in item;
}
/**
* Check if the entire playback info response requires signed URLs
* @public
*/
function isSignedPlaybackInfo(playbackInfo) {
return isSignedPlayback(playbackInfo.stream);
}
/**
* Extract playback tokens from signed video playback info
* @param playbackInfo - The video playback info
* @returns The playback tokens or undefined if the response is not signed
* @public
* @example
* const tokens = getPlaybackTokens(playbackInfo)
* console.log(tokens)
* ```json
* {
* stream: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
* thumbnail: "eyJ0a2VuIjoiVGh1bWJuYWlsVG9rZW4tMTIz...",
* animated: "eyJ0a2VuIjoiQW5pbWF0ZWRUb2tlbi1kZWY...",
* storyboard: "eyJ0a2VuIjoiU3Rvcnlib2FyZFRva2VuLTc4..."
* }
* ```
*/
function getPlaybackTokens(playbackInfo) {
if (isSignedPlaybackInfo(playbackInfo)) return {
stream: playbackInfo.stream.token,
thumbnail: playbackInfo.thumbnail.token,
storyboard: playbackInfo.storyboard.token,
animated: playbackInfo.animated.token
};
}
export { getPlaybackTokens, isSignedPlaybackInfo };
//# sourceMappingURL=media-library.js.map