Skip to content

Commit

Permalink
add check for secured context before requesting store access #54
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jan 15, 2024
1 parent e0daf4d commit 989ff5b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sysend.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,11 @@
// :: valid sysend message
// -------------------------------------------------------------------------
function is_sysend_post_message(e) {
return typeof e.data === 'string' && is_internal(e.data);
return is_string(e.data) && is_internal(e.data);
}
// -------------------------------------------------------------------------
function is_secured_iframe() {
return is_proxy_iframe() && window.isSecureContext;
}
// -------------------------------------------------------------------------
function is_valid_origin(origin) {
Expand Down Expand Up @@ -851,8 +855,8 @@
}
// -------------------------------------------------------------------------
function init() {
if (typeof window.BroadcastChannel === 'function') {
if (is_proxy_iframe() && document.requestStorageAccess) {
if (is_function(window.BroadcastChannel)) {
if (is_secured_iframe() && document.requestStorageAccess) {
document.requestStorageAccess({
all: true
}).then(function(handle) {
Expand Down

0 comments on commit 989ff5b

Please sign in to comment.