File tree Expand file tree Collapse file tree 3 files changed +26
-5
lines changed
packages/jsonwebtoken/src Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,26 @@ impl From<Algorithm> for jsonwebtoken::Algorithm {
4848 }
4949}
5050
51+ impl From < jsonwebtoken:: Algorithm > for Algorithm {
52+ #[ inline]
53+ fn from ( value : jsonwebtoken:: Algorithm ) -> Self {
54+ match value {
55+ jsonwebtoken:: Algorithm :: ES256 => Algorithm :: ES256 ,
56+ jsonwebtoken:: Algorithm :: ES384 => Algorithm :: ES384 ,
57+ jsonwebtoken:: Algorithm :: EdDSA => Algorithm :: EdDSA ,
58+ jsonwebtoken:: Algorithm :: HS256 => Algorithm :: HS256 ,
59+ jsonwebtoken:: Algorithm :: HS384 => Algorithm :: HS384 ,
60+ jsonwebtoken:: Algorithm :: HS512 => Algorithm :: HS512 ,
61+ jsonwebtoken:: Algorithm :: PS256 => Algorithm :: PS256 ,
62+ jsonwebtoken:: Algorithm :: PS384 => Algorithm :: PS384 ,
63+ jsonwebtoken:: Algorithm :: PS512 => Algorithm :: PS512 ,
64+ jsonwebtoken:: Algorithm :: RS256 => Algorithm :: RS256 ,
65+ jsonwebtoken:: Algorithm :: RS384 => Algorithm :: RS384 ,
66+ jsonwebtoken:: Algorithm :: RS512 => Algorithm :: RS512 ,
67+ }
68+ }
69+ }
70+
5171impl Default for Algorithm {
5272 fn default ( ) -> Self {
5373 Self :: HS256
Original file line number Diff line number Diff line change @@ -3,8 +3,9 @@ use napi_derive::napi;
33use crate :: header:: Header ;
44
55#[ napi]
6- pub fn decode_header ( token : & str ) -> Header {
6+ pub fn decode_header ( token : String ) -> Header {
77 let result = jsonwebtoken:: decode_header ( & token) ;
88
9- let header = Header :: from ( result. unwrap ( ) ) ;
9+ let header = result. unwrap ( ) . into ( ) ;
10+ return header;
1011}
Original file line number Diff line number Diff line change @@ -73,11 +73,11 @@ impl From<&Header> for jsonwebtoken::Header {
7373 }
7474}
7575
76- impl From < & jsonwebtoken:: Header > for Header {
76+ impl From < jsonwebtoken:: Header > for Header {
7777 #[ inline]
78- fn from ( value : & jsonwebtoken:: Header ) -> Header {
78+ fn from ( value : jsonwebtoken:: Header ) -> Header {
7979 Header {
80- algorithm : value. alg . clone ( ) ,
80+ algorithm : Algorithm :: from ( value. alg . clone ( ) ) . into ( ) ,
8181 content_type : value. cty . clone ( ) ,
8282 json_key_url : value. jku . clone ( ) ,
8383 key_id : value. kid . clone ( ) ,
You can’t perform that action at this time.
0 commit comments