feat(embed): Wrapped all localStorage access with try/catch statements

This commit is contained in:
Alan Rynne
2021-08-26 16:27:53 +02:00
parent b12a97b0e7
commit 18eea01c29
3 changed files with 45 additions and 29 deletions
@@ -10,7 +10,12 @@ export default class ViewerObjectLoader {
constructor( parent, objectUrl, authToken ) {
this.viewer = parent
this.token = authToken || localStorage.getItem( 'AuthToken' )
this.token = null
try {
this.token = authToken || localStorage.getItem( 'AuthToken' )
} catch ( error ) {
// Accessing localStorage may throw when executing on sandboxed document, ignore.
}
if ( !this.token ) {
console.warn( 'Viewer: no auth token present. Requests to non-public stream objects will fail.' )
@@ -32,7 +37,7 @@ export default class ViewerObjectLoader {
serverUrl: this.serverUrl,
token: this.token,
streamId: this.streamId,
objectId: this.objectId,
objectId: this.objectId
} )
this.converter = new Converter( this.loader )