File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ Function generate() : Text
4040 $algorithm := "HS"
4141 Else
4242 $algorithm := "RS"
43- End if
43+ End if
4444
4545 // Generate Verify Signature Hash based on Algorithm
4646 If ($algorithm= "HS")
@@ -203,10 +203,16 @@ Function _hashSign($inJWT : Object) : Text
203203Function decode ($inToken : Text) : Object
204204
205205 var $parts : Collection:= Split string ($inToken ; "." )
206- var $header ; $payload : Text
207-
208- BASE64 DECODE ($parts [0 ]; $header ; * )
209- BASE64 DECODE ($parts [1 ]; $payload ; * )
210206
211- // Note: If JSON parsing fails, Try(JSON Parse(...)) will return Null for header or payload.
212- return {header: Try (JSON Parse ($header )); payload: Try (JSON Parse ($payload ))}
207+ If ($parts .length > 2)
208+ var $header ; $payload ; $signature : Text
209+ BASE64 DECODE ($parts [0 ]; $header ; * )
210+ BASE64 DECODE ($parts [1 ]; $payload ; * )
211+ $signature := $parts [2 ]
212+
213+ // Note: If JSON parsing fails, Try(JSON Parse(...)) will return Null for header or payload.
214+ return {header: Try (JSON Parse ($header )); payload: Try (JSON Parse ($payload )); signature: $signature }
215+
216+ Else
217+ return {header: Null ; payload: Null }
218+ End if
You can’t perform that action at this time.
0 commit comments