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

Adds hostname auth capability to Frame #868

Merged
merged 1 commit into from
Jan 26, 2024
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
4 changes: 4 additions & 0 deletions lib/recurly/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export class Frame extends Emitter {
payload.event = name;
payload.key = recurly.config.publicKey;

if (recurly.config.hostname) {
payload.credentialCheckoutHostname = recurly.config.hostname;
}

const ev = res => {
this.removeRelay();
if (res.error) {
Expand Down
14 changes: 14 additions & 0 deletions test/unit/frame.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@ describe('Recurly.Frame', function () {
assert(~src.indexOf(`version=${recurly.version}`));
assert(~src.indexOf('event=recurly-frame-'));
assert(~src.indexOf('key=test'));
assert(!~src.indexOf('credentialCheckoutHostname'));
});

describe('when configured to use hostname auth', function () {
beforeEach(function (done) {
this.recurly.configure({ hostname: 'test-hostname.recurly.com' });
this.frame = this.recurly.Frame({ path, payload, type: Frame.TYPES.IFRAME, container: testBed() });
this.frame.on('done', () => done());
});

it('assigns the value in the URL', function () {
const { src } = this.frame.iframe;
assert(~src.indexOf('credentialCheckoutHostname=test-hostname.recurly.com'));
});
});

describe('Frame.destroy', function () {
Expand Down
Loading