openid-client
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -8,2 +8,3 @@ # openid-client CHANGELOG | ||
<!-- TOC START min:2 max:2 link:true update:true --> | ||
- [Version 1.4.0](#version-140) | ||
- [Version 1.3.0](#version-130) | ||
@@ -18,2 +19,7 @@ - [Version 1.2.0](#version-120) | ||
## Version 1.4.0 | ||
- [DIFF](https://github.com/panva/node-openid-client/compare/v1.3.1...v1.4.0) | ||
- deprecated passing keystore directly to Client#register, pass an object with keystore property instead | ||
- added the option to provide InitialAccessToken value to Client#register | ||
## Version 1.3.0 | ||
@@ -20,0 +26,0 @@ ### Version 1.3.1 |
@@ -133,2 +133,5 @@ 'use strict'; | ||
const deprecatedKeystore = util.deprecate(keystore => keystore, | ||
'passing keystore directly is deprecated, pass an object with keystore property instead'); | ||
class Client { | ||
@@ -673,6 +676,15 @@ constructor(metadata, keystore) { | ||
static register(body, keystore) { | ||
static register(properties, opts) { | ||
const options = (() => { | ||
if (!opts) return {}; | ||
if (_.isPlainObject(opts)) return opts; | ||
return { keystore: deprecatedKeystore(opts) }; | ||
})(); | ||
const keystore = options.keystore; | ||
const initialAccessToken = options.initialAccessToken; | ||
assert(this.issuer.registration_endpoint, 'issuer does not support dynamic registration'); | ||
if (keystore !== undefined && !(body.jwks || body.jwks_uri)) { | ||
if (keystore !== undefined && !(properties.jwks || properties.jwks_uri)) { | ||
assert(jose.JWK.isKeyStore(keystore), 'keystore must be an instance of jose.JWK.KeyStore'); | ||
@@ -686,8 +698,12 @@ assert(keystore.all().every((key) => { | ||
}), 'keystore must only contain private EC or RSA keys'); | ||
body.jwks = keystore.toJSON(); | ||
properties.jwks = keystore.toJSON(); | ||
} | ||
const headers = { 'Content-Type': 'application/json' }; | ||
if (initialAccessToken) headers.Authorization = `Bearer ${initialAccessToken}`; | ||
return got.post(this.issuer.registration_endpoint, this.issuer.httpOptions({ | ||
body: JSON.stringify(body), | ||
headers: { 'Content-Type': 'application/json' }, | ||
headers, | ||
body: JSON.stringify(properties), | ||
})) | ||
@@ -694,0 +710,0 @@ .then(expectResponse(201)) |
{ | ||
"name": "openid-client", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "OpenID Connect Relying Party (RP, Client) implementation for Node.js", | ||
@@ -29,2 +29,7 @@ "main": "lib/index.js", | ||
"certified", | ||
"dynamic", | ||
"config", | ||
"basic", | ||
"hybrid", | ||
"implicit", | ||
"oauth2" | ||
@@ -31,0 +36,0 @@ ], |
@@ -300,3 +300,4 @@ # openid-client | ||
```js | ||
issuer.Client.register(metadata, [keystore]) // => Promise | ||
const opts = { keystore, initialAccessToken }; // both optional | ||
issuer.Client.register(metadata, [opts]) // => opts optional, Promise | ||
.then(function (client) { | ||
@@ -303,0 +304,0 @@ console.log('Registered client %s, %j', client, client.metadata); |
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
59105
1077
394