From dfdd8cb3271717fc901b53c05053b1a079dda022 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sat, 24 Aug 2019 13:22:31 +0200 Subject: [PATCH] feat: allow multiple resource parameters in authorization requests --- lib/client.js | 2 ++ test/client/client_instance.test.js | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/client.js b/lib/client.js index 48c5a3da..94e1879b 100644 --- a/lib/client.js +++ b/lib/client.js @@ -115,6 +115,8 @@ function authorizationParams(params) { delete authParams[key]; } else if (key === 'claims' && typeof value === 'object') { authParams[key] = JSON.stringify(value); + } else if (key === 'resource' && Array.isArray(value)) { + authParams[key] = value; } else if (typeof value !== 'string') { authParams[key] = String(value); } diff --git a/test/client/client_instance.test.js b/test/client/client_instance.test.js index 64a48d00..44b94d65 100644 --- a/test/client/client_instance.test.js +++ b/test/client/client_instance.test.js @@ -132,6 +132,14 @@ describe('Client', () => { }); }); + it('allows resource to passed as an array', function () { + expect(url.parse(this.client.authorizationUrl({ + resource: ['urn:example:com', 'urn:example-2:com'], + }), true).query).to.deep.contain({ + resource: ['urn:example:com', 'urn:example-2:com'], + }); + }); + it('auto-stringifies claims parameter', function () { expect(url.parse(this.client.authorizationUrl({ claims: { id_token: { email: null } },