Skip to content

Commit

Permalink
Add decode function to JWT class
Browse files Browse the repository at this point in the history
  • Loading branch information
yannicktrinh committed Mar 14, 2024
1 parent d37e856 commit 3237388
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Project/Sources/Classes/_JWT.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,17 @@ Function _hashSign($inJWT : Object)->$hash : Text
// Sign Message with CryptoKey to generate hashed verify signature
$hash:=$cryptoKey.sign(String($encodedHead+"."+$encodedPayload); {hash: $hashAlgorithm; pss: Bool($inJWT.header.alg="PS@"); encoding: "Base64URL"})
End if


// ----------------------------------------------------


function decode($inToken : Text) : Object

var $parts : Collection:=Split string($inToken; ".")
var $header; $payload : Text

BASE64 DECODE($parts[0]; $header; *)
BASE64 DECODE($parts[1]; $payload; *)

return {header: Try(JSON Parse($header)); payload: Try(JSON Parse($payload))}

0 comments on commit 3237388

Please sign in to comment.