Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic options object to App init #46

Merged
merged 4 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Next Release
-------------
1.9.0
------
* Add generic options object to App init. #46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be a 1.9 feature release. Also, we need README documentation on how to use this new feaature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will update it.


1.8.1
------
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ XFC.Provider.init({
})
```

If the app wants to transmit details to frame after authorization, it may pass in an options object.

```js
XFC.Provider.init({
acls: ['*'],
options: { moreDetail: 'detail' }
})
```

### Launching Fullscreen
An application may request to launch a pagelet fullscreen within the consumer application.

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xfc",
"version": "1.8.1",
"version": "1.9.0",
"description": "A Cross Frame Container that handles securely embedding web content into a 3rd party domain",
"author": "Cerner Corporation",
"license": "Apache-2.0",
Expand Down
7 changes: 5 additions & 2 deletions src/provider/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ class Application extends EventEmitter {
* @param options.targetSelectors A DOMString containing one or more selectors to match against.
* This string must be a valid CSS selector string; if it's not,
* a SyntaxError exception is thrown.
* @param options.options An optional object used for App to transmit details to frame
* after App is authorized.
*/
init({ acls = [], secret = null, onReady = null, targetSelectors = '' }) {
init({ acls = [], secret = null, onReady = null, targetSelectors = '', options = {} }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add documentation for this new parameter.

this.acls = [].concat(acls);
this.secret = secret;
this.options = options;
this.onReady = onReady;
this.targetSelectors = targetSelectors;
this.resizeConfig = null;
Expand Down Expand Up @@ -251,7 +254,7 @@ class Application extends EventEmitter {

// Emit a ready event
this.emit('xfc.ready');
this.JSONRPC.notification('authorized', [{ url: window.location.href }]);
this.JSONRPC.notification('authorized', [{ url: window.location.href, options: this.options }]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we always send options or should we only send if it has something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it non-passive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is just extra info object always present/received, it could be read or ignored.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no problem with always sending it then

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is any work required to make this available on the Consumer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need any changes on Consumer as we are merging in the new options object with url into one detail object. https://github.com/cerner/xfc/blob/master/src/consumer/frame.js#L51


// If there is an onReady callback, execute it
if (typeof this.onReady === 'function') {
Expand Down
12 changes: 11 additions & 1 deletion test/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,17 @@ describe('Application', () => {
const notification = this.stub(application.JSONRPC, 'notification');
application.authorizeConsumer();

sinon.assert.calledWith(notification, 'authorized', [{ url: window.location.href }]);
sinon.assert.calledWith(notification, 'authorized', [{ url: window.location.href, options: {} }]);
}));

it("calls this.JSONRPC.notification of 'authorized' with current url and generic options object", sinon.test(function() {
const options = { moreDetail: 'detail' }
const application = new Application();
application.init({options});
const notification = this.stub(application.JSONRPC, 'notification');
application.authorizeConsumer();

sinon.assert.calledWith(notification, 'authorized', [{ url: window.location.href, options: { moreDetail: 'detail'} }]);
}));

it("calls this.onReady if onReady is a function", () => {
Expand Down