@mux/blurhash
Advanced tools
Comparing version 0.1.1 to 0.1.2-canary.0-04f2548
@@ -43,4 +43,10 @@ import sharp from 'sharp'; | ||
const muxBlurHash = async (playbackId, options = {}) => { | ||
if (typeof playbackId !== 'string') { | ||
throw new TypeError(`[@mux/blurhash] playbackId error. Expected a string, got ${typeof playbackId}`); | ||
} | ||
let url = `https://image.mux.com/${playbackId}/thumbnail.png`; | ||
if (typeof options.time !== 'undefined' || typeof options.thumbnailToken !== 'undefined') { | ||
if (typeof options.time !== 'undefined' && typeof options.thumbnailToken !== 'undefined') { | ||
console.warn('[@mux/blurhash] When thumbnailToken is set, time will have no effect. Encode time in your token. See https://docs.mux.com/guides/video/secure-video-playback for more information.'); | ||
} | ||
url += '?'; | ||
@@ -56,3 +62,8 @@ if (typeof options.time !== 'undefined') { | ||
if (response.status === 403) { | ||
throw new Error(`[@mux/blurhash] Error fetching thumbnail. 403: Forbidden. This Playback ID may require a thumbnail token. See https://docs.mux.com/guides/video/secure-video-playback for more information.`); | ||
if (typeof options.thumbnailToken !== 'undefined') { | ||
throw new Error(`[@mux/blurhash] Error fetching thumbnail. 403: Forbidden. The thumbnailToken option may be invalid. See https://docs.mux.com/guides/video/secure-video-playback for more information.`); | ||
} | ||
else { | ||
throw new Error(`[@mux/blurhash] Error fetching thumbnail. 403: Forbidden. This Playback ID may require a thumbnail token. See https://docs.mux.com/guides/video/secure-video-playback for more information.`); | ||
} | ||
} | ||
@@ -59,0 +70,0 @@ else if (response.status >= 400) { |
{ | ||
"name": "@mux/blurhash", | ||
"version": "0.1.1", | ||
"version": "0.1.2-canary.0-04f2548", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -58,5 +58,15 @@ import sharp from 'sharp'; | ||
const muxBlurHash = async (playbackId: string, options: MuxBlurHashOptions = {}) => { | ||
if (typeof playbackId !== 'string') { | ||
throw new TypeError( | ||
`[@mux/blurhash] playbackId error. Expected a string, got ${typeof playbackId}` | ||
); | ||
} | ||
let url = `https://image.mux.com/${playbackId}/thumbnail.png`; | ||
if (typeof options.time !== 'undefined' || typeof options.thumbnailToken !== 'undefined') { | ||
if (typeof options.time !== 'undefined' && typeof options.thumbnailToken !== 'undefined') { | ||
console.warn( | ||
'[@mux/blurhash] When thumbnailToken is set, time will have no effect. Encode time in your token. See https://docs.mux.com/guides/video/secure-video-playback for more information.' | ||
); | ||
} | ||
url += '?'; | ||
@@ -74,5 +84,11 @@ if (typeof options.time !== 'undefined') { | ||
if (response.status === 403) { | ||
throw new Error( | ||
`[@mux/blurhash] Error fetching thumbnail. 403: Forbidden. This Playback ID may require a thumbnail token. See https://docs.mux.com/guides/video/secure-video-playback for more information.` | ||
); | ||
if (typeof options.thumbnailToken !== 'undefined') { | ||
throw new Error( | ||
`[@mux/blurhash] Error fetching thumbnail. 403: Forbidden. The thumbnailToken option may be invalid. See https://docs.mux.com/guides/video/secure-video-playback for more information.` | ||
); | ||
} else { | ||
throw new Error( | ||
`[@mux/blurhash] Error fetching thumbnail. 403: Forbidden. This Playback ID may require a thumbnail token. See https://docs.mux.com/guides/video/secure-video-playback for more information.` | ||
); | ||
} | ||
} else if (response.status >= 400) { | ||
@@ -79,0 +95,0 @@ throw new Error( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
222076
390
40