Skip to content

Commit

Permalink
Add additional function for key decoding without JSON #11
Browse files Browse the repository at this point in the history
Signed-off-by: Sarah Julia Kriesch <sarah.j.kriesch@fau.de>
  • Loading branch information
skriesch committed Jun 29, 2022
1 parent 05dc453 commit 5554a74
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/token/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class TokenService {

const header = this.decodeBase64EncodedString(tokenParts[0]);
const body = this.decodeBase64EncodedString(tokenParts[1]);
const signature = this.extractSignature(tokenParts[2]);
const signature = this.decodeBase64EncodedStringKey(tokenParts[2]).extractSignature();


return [header, body, signature];
Expand All @@ -162,12 +162,16 @@ export class TokenService {
return JSON.parse(new TextDecoder().decode(jose.base64url.decode(input)));
}

private async extractSignature(
private decodeBase64EncodedStringKey(input: string): string {
return parse(new TextDecoder().decode(jose.base64url.decode(input)));
}

private extractSignature(
algorithm: string,
filepath: string,
publicKey: jose.KeyLike,
privateKey: jose.KeyLike
): Promise<string, string, string> {
): [string, string, string] {
let message = '';
let isValid = true;
try {
Expand Down

0 comments on commit 5554a74

Please sign in to comment.