@onekeyfe/cross-inpage-provider-core
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -7,6 +7,4 @@ "use strict"; | ||
const JsBridgeBase_1 = require("./JsBridgeBase"); | ||
const index_1 = require("./index"); | ||
let postMessageListenerAdded = false; | ||
function setupPostMessageListener(options = {}) { | ||
const debugLogger = options.debugLogger || index_1.fakeDebugLogger; | ||
if (postMessageListenerAdded) { | ||
@@ -20,4 +18,4 @@ return; | ||
// TODO source whitelist | ||
if (event.source !== window) { | ||
// return; | ||
if (event.origin !== options.origin) { | ||
return; | ||
} | ||
@@ -39,2 +37,3 @@ const eventData = event.data; | ||
constructor(config) { | ||
var _a; | ||
super(config); | ||
@@ -44,2 +43,3 @@ this.sendAsString = false; | ||
this.bridgeConfig = config; | ||
this.targetOrigin = (_a = config.targetOrigin) !== null && _a !== void 0 ? _a : window.location.origin; | ||
// receive message | ||
@@ -49,2 +49,3 @@ setupPostMessageListener({ | ||
bridge: this, | ||
origin: this.targetOrigin, | ||
}); | ||
@@ -60,5 +61,5 @@ } | ||
}; | ||
this.bridgeConfig.remoteFrame.postMessage(eventData); | ||
this.bridgeConfig.remoteFrame.postMessage(eventData, this.targetOrigin); | ||
} | ||
} | ||
exports.JsBridgeIframe = JsBridgeIframe; |
@@ -66,3 +66,3 @@ "use strict"; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument | ||
return (_b = (_a = this._externalLogger) === null || _a === void 0 ? void 0 : _a.log) === null || _b === void 0 ? void 0 : _b.call(_a, name + ' >>> ', ...args); | ||
return (_b = (_a = this._externalLogger) === null || _a === void 0 ? void 0 : _a.log) === null || _b === void 0 ? void 0 : _b.call(_a, `${name} >>> `, ...args); | ||
}; | ||
@@ -69,0 +69,0 @@ this.initExternalLogInstances(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const version = '0.0.12'; | ||
const version = '0.0.13'; | ||
const versionBuild = '2020-0101-1'; | ||
@@ -5,0 +5,0 @@ exports.default = { |
@@ -5,2 +5,3 @@ import { IJsBridgeConfig, IJsBridgeMessagePayload, IPostMessageEventData, IOptionsWithDebugLogger } from '@onekeyfe/cross-inpage-provider-types'; | ||
bridge?: JsBridgeIframe; | ||
origin?: string; | ||
}; | ||
@@ -15,4 +16,6 @@ export declare type IPostMessageEventDataIframe = IPostMessageEventData & { | ||
channel: string; | ||
targetOrigin?: string; | ||
}; | ||
declare class JsBridgeIframe extends JsBridgeBase { | ||
targetOrigin: string; | ||
constructor(config: IJsBridgeIframeConfig); | ||
@@ -19,0 +22,0 @@ bridgeConfig: IJsBridgeIframeConfig; |
/* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
import { JsBridgeBase } from './JsBridgeBase'; | ||
import { fakeDebugLogger } from './index'; | ||
let postMessageListenerAdded = false; | ||
function setupPostMessageListener(options = {}) { | ||
const debugLogger = options.debugLogger || fakeDebugLogger; | ||
if (postMessageListenerAdded) { | ||
@@ -16,4 +14,4 @@ return; | ||
// TODO source whitelist | ||
if (event.source !== window) { | ||
// return; | ||
if (event.origin !== options.origin) { | ||
return; | ||
} | ||
@@ -35,2 +33,3 @@ const eventData = event.data; | ||
constructor(config) { | ||
var _a; | ||
super(config); | ||
@@ -40,2 +39,3 @@ this.sendAsString = false; | ||
this.bridgeConfig = config; | ||
this.targetOrigin = (_a = config.targetOrigin) !== null && _a !== void 0 ? _a : window.location.origin; | ||
// receive message | ||
@@ -45,2 +45,3 @@ setupPostMessageListener({ | ||
bridge: this, | ||
origin: this.targetOrigin, | ||
}); | ||
@@ -56,5 +57,5 @@ } | ||
}; | ||
this.bridgeConfig.remoteFrame.postMessage(eventData); | ||
this.bridgeConfig.remoteFrame.postMessage(eventData, this.targetOrigin); | ||
} | ||
} | ||
export { JsBridgeIframe }; |
@@ -58,3 +58,3 @@ // @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument | ||
return (_b = (_a = this._externalLogger) === null || _a === void 0 ? void 0 : _a.log) === null || _b === void 0 ? void 0 : _b.call(_a, name + ' >>> ', ...args); | ||
return (_b = (_a = this._externalLogger) === null || _a === void 0 ? void 0 : _a.log) === null || _b === void 0 ? void 0 : _b.call(_a, `${name} >>> `, ...args); | ||
}; | ||
@@ -61,0 +61,0 @@ this.initExternalLogInstances(); |
@@ -1,2 +0,2 @@ | ||
const version = '0.0.12'; | ||
const version = '0.0.13'; | ||
const versionBuild = '2020-0101-1'; | ||
@@ -3,0 +3,0 @@ export default { |
{ | ||
"name": "@onekeyfe/cross-inpage-provider-core", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"keywords": [ | ||
@@ -32,5 +32,5 @@ "cross-inpage-provider" | ||
"dependencies": { | ||
"@onekeyfe/cross-inpage-provider-errors": "^0.0.12", | ||
"@onekeyfe/cross-inpage-provider-events": "^0.0.12", | ||
"@onekeyfe/cross-inpage-provider-types": "^0.0.12", | ||
"@onekeyfe/cross-inpage-provider-errors": "^0.0.13", | ||
"@onekeyfe/cross-inpage-provider-events": "^0.0.13", | ||
"@onekeyfe/cross-inpage-provider-types": "^0.0.13", | ||
"events": "^3.3.0", | ||
@@ -40,3 +40,3 @@ "lodash": "^4.17.21", | ||
}, | ||
"gitHead": "8d2544a62c77934ce19b19439476bf35d88bd5b8" | ||
"gitHead": "2dfe2910cf3a333649382f1124c44f7c53c90ecd" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
151609
3716
+ Added@onekeyfe/cross-inpage-provider-errors@0.0.13(transitive)
+ Added@onekeyfe/cross-inpage-provider-events@0.0.13(transitive)
+ Added@onekeyfe/cross-inpage-provider-types@0.0.13(transitive)
- Removed@onekeyfe/cross-inpage-provider-errors@0.0.12(transitive)
- Removed@onekeyfe/cross-inpage-provider-events@0.0.12(transitive)
- Removed@onekeyfe/cross-inpage-provider-types@0.0.12(transitive)