|
|
@ -1,8 +1,9 @@
|
|
|
|
// This file provides the API for the channel for talking to and from the sandbox iframe.
|
|
|
|
// This file provides the API for the channel for talking to and from the sandbox iframe.
|
|
|
|
define([
|
|
|
|
define([
|
|
|
|
//'/common/sframe-protocol.js',
|
|
|
|
//'/common/sframe-protocol.js',
|
|
|
|
'/common/common-util.js'
|
|
|
|
'/common/common-util.js',
|
|
|
|
], function (/*SFrameProtocol,*/ Util) {
|
|
|
|
'/api/config',
|
|
|
|
|
|
|
|
], function (/*SFrameProtocol,*/ Util, ApiConfig) {
|
|
|
|
|
|
|
|
|
|
|
|
var mkTxid = function () {
|
|
|
|
var mkTxid = function () {
|
|
|
|
return Math.random().toString(16).replace('0.', '') + Math.random().toString(16).replace('0.', '');
|
|
|
|
return Math.random().toString(16).replace('0.', '') + Math.random().toString(16).replace('0.', '');
|
|
|
@ -156,9 +157,17 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var trusted = [
|
|
|
|
|
|
|
|
ApiConfig.httpUnsafeOrigin,
|
|
|
|
|
|
|
|
ApiConfig.httpSafeOrigin,
|
|
|
|
|
|
|
|
'', // sharedworkers
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
onMsg.reg(function (msg) {
|
|
|
|
onMsg.reg(function (msg) {
|
|
|
|
if (!chanLoaded) { return; }
|
|
|
|
if (!chanLoaded) { return; }
|
|
|
|
if (!msg.data || msg.data === '_READY') { return; }
|
|
|
|
if (!msg.data || msg.data === '_READY') { return; }
|
|
|
|
|
|
|
|
if (!trusted.includes(msg.origin)) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
var data = typeof(msg.data) === "object" ? msg.data : JSON.parse(msg.data);
|
|
|
|
var data = typeof(msg.data) === "object" ? msg.data : JSON.parse(msg.data);
|
|
|
|
if (typeof(data.ack) !== "undefined") {
|
|
|
|
if (typeof(data.ack) !== "undefined") {
|
|
|
|
if (acks[data.txid]) { acks[data.txid](!data.ack); }
|
|
|
|
if (acks[data.txid]) { acks[data.txid](!data.ack); }
|
|
|
|