Skip to content

Commit 10190ba

Browse files
authored
fix: avoid to post message to origin * (#300)
1 parent 95ca484 commit 10190ba

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ <h2>Two ways to integrate this widget to your web application</h2>
6060
</p>
6161
<div class="collapse" id="config-params">
6262
<div class="card card-body">
63-
<p>Create a browser based app in <a href="https://developer.ringcentral.com/" target="_blank">RingCentral Developer Platform<a> to get appKey, appSecret and appServer.</p>
63+
<p>Create a browser based app in <a href="https://developer.ringcentral.com/" target="_blank" rel="noopener noreferrer">RingCentral Developer Platform<a> to get appKey, appSecret and appServer.</p>
6464
<form>
6565
<div class="form-group row">
6666
<label for="appKey" class="col-sm-2 col-form-label">appKey</label>

src/lib/Adapter/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import classnames from 'classnames';
22
import AdapterCore from 'ringcentral-widgets/lib/AdapterCore';
3+
import url from 'url';
34

45
import parseUri from '../parseUri';
56
import messageTypes from './messageTypes';
@@ -292,6 +293,8 @@ class Adapter extends AdapterCore {
292293

293294
_setAppUrl(appUrl) {
294295
this._appUrl = appUrl;
296+
const { protocol, host } = url.parse(appUrl, false);
297+
this._appOrigin = `${protocol}//${host}`;
295298
if (appUrl) {
296299
this.contentFrameEl.src = appUrl;
297300
this.contentFrameEl.id = `${this._prefix}-adapter-frame`;
@@ -304,7 +307,7 @@ class Adapter extends AdapterCore {
304307

305308
_postMessage(data) {
306309
if (this._contentFrameEl.contentWindow) {
307-
this._contentFrameEl.contentWindow.postMessage(data, '*');
310+
this._contentFrameEl.contentWindow.postMessage(data, this._appOrigin);
308311
}
309312
}
310313

0 commit comments

Comments
 (0)