Skip to content

Commit d9355ae

Browse files
committed
Fix bug in JWT parser
1 parent 0e652f7 commit d9355ae

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strontium",
3-
"version": "2.4.0",
3+
"version": "2.4.1",
44
"description": "Strontium is a TypeScript toolkit for High Performance API servers built for Production not Projects.",
55
"main": "lib/src/index.js",
66
"types": "lib/src/index.d.ts",

src/cryptography/drivers/node/AsymmetricJWTSigner.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { JWTSigner } from "../../abstract/JWTSigner"
33

44
// Types are dodgy on this library
55
// @ts-ignore
6-
import { decode, encode } from "base64url"
6+
import { decode, encode, fromBase64 } from "base64url"
77

88
export class AsymmetricJWTSigner extends JWTSigner {
99
constructor(
@@ -30,9 +30,7 @@ export class AsymmetricJWTSigner extends JWTSigner {
3030
new Buffer(`${encodedHeader}.${encodedClaim}`)
3131
)
3232

33-
return `${encodedHeader}.${encodedClaim}.${signature.toString(
34-
"base64"
35-
)}`
33+
return `${encodedHeader}.${encodedClaim}.${fromBase64(signature.toString("base64"))}`
3634
}
3735

3836
public async verify(token: string): Promise<unknown> {
@@ -56,7 +54,7 @@ export class AsymmetricJWTSigner extends JWTSigner {
5654

5755
let claimBody = claimComponents[1]
5856

59-
let decodedSignature = new Buffer(claimComponents[2], "base64")
57+
let decodedSignature = new Buffer(decode(claimComponents[2]))
6058

6159
// Delegate validation of the signature to the signer
6260
await this.signer.verify(

0 commit comments

Comments
 (0)