|
@@ -17,6 +17,11 @@
|
|
|
window.parent.postMessage(message, '*')
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @type {string} - The main frame origin.
|
|
|
+ */
|
|
|
+ const origin = __TEMPLATE_origin__
|
|
|
+
|
|
|
/**
|
|
|
* @type {Uint8Array} - Injected by Tauri during runtime
|
|
|
*/
|
|
@@ -42,14 +47,14 @@
|
|
|
algorithm.name = 'AES-GCM'
|
|
|
algorithm.iv = window.crypto.getRandomValues(new Uint8Array(12))
|
|
|
|
|
|
- const { contentType, data } = __RAW_process_ipc_message_fn__(payload)
|
|
|
+ const {contentType, data} = __RAW_process_ipc_message_fn__(payload)
|
|
|
|
|
|
const message =
|
|
|
typeof data === 'string'
|
|
|
? new TextEncoder().encode(data)
|
|
|
: ArrayBuffer.isView(data) || data instanceof ArrayBuffer
|
|
|
- ? data
|
|
|
- : new Uint8Array(data)
|
|
|
+ ? data
|
|
|
+ : new Uint8Array(data)
|
|
|
|
|
|
return window.crypto.subtle
|
|
|
.encrypt(algorithm, aesGcmKey, message)
|
|
@@ -101,7 +106,7 @@
|
|
|
* @param {MessageEvent<any>} event
|
|
|
*/
|
|
|
async function payloadHandler(event) {
|
|
|
- if (!isIsolationPayload(event.data)) {
|
|
|
+ if (event.origin !== origin || !isIsolationPayload(event.data)) {
|
|
|
return
|
|
|
}
|
|
|
|