openid-client
Advanced tools
Comparing version 1.6.4 to 1.7.1
@@ -8,2 +8,3 @@ # openid-client CHANGELOG | ||
<!-- TOC START min:2 max:2 link:true update:true --> | ||
- [Version 1.7.0](#version-170) | ||
- [Version 1.6.0](#version-160) | ||
@@ -21,2 +22,7 @@ - [Version 1.5.0](#version-150) | ||
## Version 1.7.0 | ||
- [DIFF](https://github.com/panva/node-openid-client/compare/v1.6.4...v1.7.0) | ||
- added authorizationCallback support for submitting code_verifier | ||
- example now includes session management OP and RP frames | ||
## Version 1.6.0 | ||
@@ -23,0 +29,0 @@ ### Version 1.6.4 |
@@ -16,3 +16,3 @@ 'use strict'; | ||
const gotErrorHandler = require('./got_error_handler'); | ||
const errorHandler = require('./error_handler'); | ||
const expectResponse = require('./expect_response'); | ||
@@ -275,2 +275,3 @@ const TokenSet = require('./token_set'); | ||
redirect_uri: redirectUri, | ||
code_verifier: toCheck.code_verifier, | ||
}) | ||
@@ -294,2 +295,6 @@ .then(tokenset => this.decryptIdToken(tokenset, 'id_token')) | ||
/** | ||
* @name decryptIdToken | ||
* @api private | ||
*/ | ||
decryptIdToken(token, use) { | ||
@@ -531,3 +536,3 @@ if ( | ||
return JSON.parse(response.body); | ||
}, gotErrorHandler) | ||
}) | ||
.then((parsed) => { | ||
@@ -539,5 +544,10 @@ if (accessToken.id_token) { | ||
return parsed; | ||
}); | ||
}) | ||
.catch(errorHandler); | ||
} | ||
/** | ||
* @name derivedKey | ||
* @api private | ||
*/ | ||
derivedKey(len) { | ||
@@ -560,2 +570,6 @@ const cacheKey = `${len}_key`; | ||
/** | ||
* @name joseSecret | ||
* @api private | ||
*/ | ||
joseSecret(alg) { | ||
@@ -582,4 +596,4 @@ if (String(alg).match(/^A(128|192|256)(GCM)?KW$/)) { | ||
assert(this.issuer.token_endpoint, 'issuer must be configured with token endpoint'); | ||
return this.authenticatedPost('token', { body }, | ||
response => new TokenSet(JSON.parse(response.body))); | ||
return this.authenticatedPost('token', { body: _.omitBy(body, _.isUndefined) }) | ||
.then(response => new TokenSet(JSON.parse(response.body))); | ||
} | ||
@@ -597,8 +611,9 @@ | ||
if (hint) body.token_type_hint = hint; | ||
return this.authenticatedPost('revocation', { body }, (response) => { | ||
if (response.body) { | ||
return JSON.parse(response.body); | ||
} | ||
return {}; | ||
}); | ||
return this.authenticatedPost('revocation', { body }) | ||
.then((response) => { | ||
if (response.body) { | ||
return JSON.parse(response.body); | ||
} | ||
return {}; | ||
}); | ||
} | ||
@@ -616,3 +631,5 @@ | ||
if (hint) body.token_type_hint = hint; | ||
return this.authenticatedPost('introspection', { body }, response => JSON.parse(response.body)); | ||
return this.authenticatedPost('introspection', { body }) | ||
.then(expectResponse(200)) | ||
.then(response => JSON.parse(response.body)); | ||
} | ||
@@ -635,3 +652,3 @@ | ||
return got(def.endpoint, this.issuer.httpOptions(opts)) | ||
.then(response => claimJWT.call(this, response.body), gotErrorHandler) | ||
.then(response => claimJWT.call(this, response.body), errorHandler) | ||
.then((data) => { | ||
@@ -662,8 +679,16 @@ delete claims._claim_sources[sourceName]; | ||
authenticatedPost(endpoint, httpOptions, success) { | ||
/** | ||
* @name authenticatedPost | ||
* @api private | ||
*/ | ||
authenticatedPost(endpoint, httpOptions) { | ||
return Promise.resolve(this.authFor(endpoint)) | ||
.then(auth => got.post(this.issuer[`${endpoint}_endpoint`], this.issuer.httpOptions(_.merge(httpOptions, auth))) | ||
.then(success, gotErrorHandler)); | ||
.catch(errorHandler)); | ||
} | ||
/** | ||
* @name createSign | ||
* @api private | ||
*/ | ||
createSign() { | ||
@@ -710,2 +735,6 @@ let alg = this.token_endpoint_auth_signing_alg; | ||
/** | ||
* @name authFor | ||
* @api private | ||
*/ | ||
authFor(endpoint) { | ||
@@ -746,2 +775,7 @@ switch (this.token_endpoint_auth_method) { | ||
/** | ||
* @name inspect | ||
* @api public | ||
*/ | ||
inspect() { | ||
@@ -788,3 +822,4 @@ return util.format('Client <%s>', this.client_id); | ||
.then(expectResponse(201)) | ||
.then(response => new this(JSON.parse(response.body), keystore), gotErrorHandler); | ||
.then(response => new this(JSON.parse(response.body), keystore)) | ||
.catch(errorHandler); | ||
} | ||
@@ -805,3 +840,3 @@ | ||
.then(expectResponse(200)) | ||
.then(response => new this(JSON.parse(response.body)), gotErrorHandler); | ||
.then(response => new this(JSON.parse(response.body)), errorHandler); | ||
} | ||
@@ -808,0 +843,0 @@ |
@@ -6,2 +6,3 @@ 'use strict'; | ||
const Strategy = require('./passport_strategy'); | ||
const TokenSet = require('./token_set'); | ||
@@ -12,2 +13,3 @@ module.exports = { | ||
Strategy, | ||
TokenSet, | ||
}; |
@@ -18,3 +18,3 @@ 'use strict'; | ||
const gotErrorHandler = require('./got_error_handler'); | ||
const errorHandler = require('./error_handler'); | ||
const BaseClient = require('./client'); | ||
@@ -81,2 +81,6 @@ const registry = require('./issuer_registry'); | ||
/** | ||
* @name inspect | ||
* @api public | ||
*/ | ||
inspect() { | ||
@@ -86,2 +90,6 @@ return util.format('Issuer <%s>', this.issuer); | ||
/** | ||
* @name keystore | ||
* @api private | ||
*/ | ||
keystore(reload) { | ||
@@ -97,3 +105,3 @@ if (!this.jwks_uri) return Promise.reject(new Error('jwks_uri must be configured')); | ||
.then(expectResponse(200)) | ||
.then(response => JSON.parse(response.body), gotErrorHandler) | ||
.then(response => JSON.parse(response.body)) | ||
.then(jwks => jose.JWK.asKeyStore(jwks)) | ||
@@ -104,3 +112,4 @@ .then((joseKeyStore) => { | ||
return joseKeyStore; | ||
}); | ||
}) | ||
.catch(errorHandler); | ||
} | ||
@@ -111,2 +120,6 @@ | ||
/** | ||
* @name key | ||
* @api private | ||
*/ | ||
key(def, allowMulti) { | ||
@@ -130,2 +143,6 @@ const lookupCache = instance(this).cache; | ||
/** | ||
* @name metadata | ||
* @api public | ||
*/ | ||
get metadata() { | ||
@@ -178,5 +195,10 @@ return _.omitBy(_.pick(this, ISSUER_METADATA), _.isUndefined); | ||
.then(expectResponse(200)) | ||
.then(response => new this(JSON.parse(response.body)), gotErrorHandler); | ||
.then(response => new this(JSON.parse(response.body))) | ||
.catch(errorHandler); | ||
} | ||
/** | ||
* @name httpOptions | ||
* @api public | ||
*/ | ||
httpOptions() { | ||
@@ -186,2 +208,6 @@ return this.constructor.httpOptions.apply(this.constructor, arguments); // eslint-disable-line prefer-rest-params, max-len | ||
/** | ||
* @name httpOptions | ||
* @api public | ||
*/ | ||
static httpOptions(values) { | ||
@@ -188,0 +214,0 @@ return _.merge({}, this.defaultHttpOptions, values); |
@@ -9,2 +9,6 @@ 'use strict'; | ||
class TokenSet { | ||
/** | ||
* @name constructor | ||
* @api public | ||
*/ | ||
constructor(values) { | ||
@@ -14,2 +18,6 @@ Object.assign(this, values); | ||
/** | ||
* @name expires_in= | ||
* @api public | ||
*/ | ||
set expires_in(value) { // eslint-disable-line camelcase | ||
@@ -19,2 +27,6 @@ this.expires_at = now() + Number(value); | ||
/** | ||
* @name expires_in | ||
* @api public | ||
*/ | ||
get expires_in() { // eslint-disable-line camelcase | ||
@@ -24,2 +36,6 @@ return Math.max.apply(null, [this.expires_at - now(), 0]); | ||
/** | ||
* @name expired | ||
* @api public | ||
*/ | ||
expired() { | ||
@@ -29,2 +45,6 @@ return this.expires_in === 0; | ||
/** | ||
* @name claims | ||
* @api public | ||
*/ | ||
get claims() { | ||
@@ -31,0 +51,0 @@ if (decodedClaims.has(this)) return decodedClaims.get(this); |
{ | ||
"name": "openid-client", | ||
"version": "1.6.4", | ||
"version": "1.7.1", | ||
"description": "OpenID Connect Relying Party (RP, Client) implementation for Node.js servers, supports passportjs", | ||
@@ -58,3 +58,3 @@ "main": "lib/index.js", | ||
"readable-mock-req": "^0.2.2", | ||
"sinon": "^1.17.4", | ||
"sinon": "^2.1.0", | ||
"timekeeper": "^1.0.0" | ||
@@ -61,0 +61,0 @@ }, |
71499
1377