Comparing version 6.0.9 to 6.1.0
@@ -17,2 +17,3 @@ import { Claims } from './Claims'; | ||
identityProviders: IdentityProvider[]; | ||
private readonly logger; | ||
constructor({ identityProviders }: { | ||
@@ -19,0 +20,0 @@ identityProviders: IdentityProvider[]; |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.IdentityProvider = exports.Limes = void 0; | ||
const flaschenpost_1 = require("flaschenpost"); | ||
const IdentityProvider_1 = require("./IdentityProvider"); | ||
@@ -13,2 +14,3 @@ Object.defineProperty(exports, "IdentityProvider", { enumerable: true, get: function () { return IdentityProvider_1.IdentityProvider; } }); | ||
constructor({ identityProviders }) { | ||
this.logger = flaschenpost_1.flaschenpost.getLogger(); | ||
this.identityProviders = identityProviders; | ||
@@ -83,12 +85,13 @@ } | ||
if (err) { | ||
this.logger.error(err.message); | ||
return reject(new Error('Failed to verify token.')); | ||
} | ||
if (typeof verifiedToken === 'string') { | ||
throw new Error('Token payload malformed.'); | ||
return reject(new Error('Token payload malformed.')); | ||
} | ||
if (!verifiedToken) { | ||
throw new Error('Token could not be decoded.'); | ||
return reject(new Error('Token could not be decoded.')); | ||
} | ||
if (!verifiedToken.sub) { | ||
throw new Error('Token payload does not contain sub.'); | ||
return reject(new Error('Token payload does not contain sub.')); | ||
} | ||
@@ -128,3 +131,6 @@ resolve({ | ||
} | ||
catch { | ||
catch (ex) { | ||
if (ex instanceof Error) { | ||
this.logger.error(ex.message); | ||
} | ||
return res.status(401).end(); | ||
@@ -155,2 +161,3 @@ } | ||
if (!decodedToken) { | ||
this.logger.error('Failed to verify token.'); | ||
return res.status(400).end(); | ||
@@ -157,0 +164,0 @@ } |
@@ -0,1 +1,8 @@ | ||
# [6.1.0](https://github.com/thenativeweb/limes/compare/6.0.9...6.1.0) (2021-02-10) | ||
### Features | ||
* Add logger ([#277](https://github.com/thenativeweb/limes/issues/277)) ([f684300](https://github.com/thenativeweb/limes/commit/f684300b9c2a4a55f9b2ee3f59e1f2e302c46816)) | ||
## [6.0.9](https://github.com/thenativeweb/limes/compare/6.0.8...6.0.9) (2021-01-13) | ||
@@ -2,0 +9,0 @@ |
import { Claims } from './Claims'; | ||
import { flaschenpost } from 'flaschenpost'; | ||
import { IdentityProvider } from './IdentityProvider'; | ||
@@ -22,2 +23,4 @@ import { RequestHandler } from 'express'; | ||
private readonly logger = flaschenpost.getLogger(); | ||
public constructor ({ identityProviders }: { | ||
@@ -134,2 +137,4 @@ identityProviders: IdentityProvider[]; | ||
if (err) { | ||
this.logger.error(err.message); | ||
return reject(new Error('Failed to verify token.')); | ||
@@ -139,9 +144,11 @@ } | ||
if (typeof verifiedToken === 'string') { | ||
throw new Error('Token payload malformed.'); | ||
return reject(new Error('Token payload malformed.')); | ||
} | ||
if (!verifiedToken) { | ||
throw new Error('Token could not be decoded.'); | ||
return reject(new Error('Token could not be decoded.')); | ||
} | ||
if (!verifiedToken.sub) { | ||
throw new Error('Token payload does not contain sub.'); | ||
return reject(new Error('Token payload does not contain sub.')); | ||
} | ||
@@ -191,3 +198,7 @@ | ||
decodedToken = await this.verifyToken({ token }); | ||
} catch { | ||
} catch (ex: unknown) { | ||
if (ex instanceof Error) { | ||
this.logger.error(ex.message); | ||
} | ||
return res.status(401).end(); | ||
@@ -222,2 +233,4 @@ } | ||
if (!decodedToken) { | ||
this.logger.error('Failed to verify token.'); | ||
return res.status(400).end(); | ||
@@ -224,0 +237,0 @@ } |
{ | ||
"name": "limes", | ||
"version": "6.0.9", | ||
"version": "6.1.0", | ||
"description": "limes authenticates users.", | ||
@@ -17,2 +17,6 @@ "contributors": [ | ||
"email": "hannes.leutloff@thenativeweb.io" | ||
}, | ||
{ | ||
"name": "Markus Fürer", | ||
"email": "m.fuerer@vtxmail.ch" | ||
} | ||
@@ -32,5 +36,6 @@ ], | ||
"express": "4.17.1", | ||
"roboter": "11.6.3", | ||
"semantic-release-configuration": "1.0.29", | ||
"supertest": "6.0.1", | ||
"flaschenpost": "4.3.32", | ||
"roboter": "11.6.13", | ||
"semantic-release-configuration": "1.0.33", | ||
"supertest": "6.1.3", | ||
"uuid": "8.3.2" | ||
@@ -37,0 +42,0 @@ }, |
28283
511
9