From 989ff5b51977a79b9733be9f139a55e0a0c7aa1e Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Mon, 15 Jan 2024 12:19:23 +0100 Subject: [PATCH] add check for secured context before requesting store access #54 --- sysend.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sysend.js b/sysend.js index 0d70691..3b12b52 100644 --- a/sysend.js +++ b/sysend.js @@ -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) { @@ -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) {