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 @@ -51,17 +51,23 @@ Function generate($inParams : Object; $inPrivateKey : Text) : Text
5151 This ._throwError (9 ; {which: "\" $inPrivateKey\" " ; function: "JWT.generate" })
5252
5353 Else
54- var $alg : Text:= (Value type ($inParams .header .alg )= Is text) ? $inParams .header .alg : "RS256"
55- var $typ : Text:= (Value type ($inParams .header .typ )= Is text) ? $inParams .header .typ : "JWT"
54+ var $alg : Text:= (( Value type ($inParams .header .alg )= Is text) && ( Length ( $inParams . header . alg ) > 0) ) ? $inParams .header .alg : "RS256"
55+ var $typ : Text:= (( Value type ($inParams .header .typ )= Is text) && ( Length ( $inParams . header . typ ) > 0) ) ? $inParams .header .typ : "JWT"
5656 var $x5t : Text:= (Value type ($inParams .header .x5t )= Is text) ? $inParams .header .x5t : ""
5757
58- This ._header := {alg: $alg ; typ: $typ }
59- If (Length ($x5t )> 0)
58+ This ._header := ((Value type ($inParams .header )= Is object) && Not (OB Is empty ($inParams .header ))) ? $inParams .header : {}
59+ This ._payload := ((Value type ($inParams .payload )= Is object) && Not (OB Is empty ($inParams .payload ))) ? $inParams .payload : {}
60+
61+ If (Value type (This ._header .alg )= Is undefined)
62+ This ._header .alg := $alg
63+ End if
64+ If (Value type (This ._header .typ )= Is undefined)
65+ This ._header .typ := $typ
66+ End if
67+ If ((Value type (This ._header .x5t )= Is undefined) && (Length ($x5t )> 0))
6068 This ._header .x5t := $x5t
6169 End if
6270
63- This ._payload := (Value type ($inParams .payload )= Is object) ? $inParams .payload : {}
64-
6571 var $header ; $payload ; $signature : Text
6672
6773 // Encode the Header and Payload
@@ -132,7 +138,7 @@ Function validate($inJWT : Text; $inKey : Text) : Boolean
132138 return Bool ($result .success )
133139 End if
134140 End if
135-
141+
136142 End if
137143 End case
138144
You can’t perform that action at this time.
0 commit comments