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 {
48
48
}
49
49
}
50
50
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
+
51
71
impl Default for Algorithm {
52
72
fn default ( ) -> Self {
53
73
Self :: HS256
Original file line number Diff line number Diff line change @@ -3,8 +3,9 @@ use napi_derive::napi;
3
3
use crate :: header:: Header ;
4
4
5
5
#[ napi]
6
- pub fn decode_header ( token : & str ) -> Header {
6
+ pub fn decode_header ( token : String ) -> Header {
7
7
let result = jsonwebtoken:: decode_header ( & token) ;
8
8
9
- let header = Header :: from ( result. unwrap ( ) ) ;
9
+ let header = result. unwrap ( ) . into ( ) ;
10
+ return header;
10
11
}
Original file line number Diff line number Diff line change @@ -73,11 +73,11 @@ impl From<&Header> for jsonwebtoken::Header {
73
73
}
74
74
}
75
75
76
- impl From < & jsonwebtoken:: Header > for Header {
76
+ impl From < jsonwebtoken:: Header > for Header {
77
77
#[ inline]
78
- fn from ( value : & jsonwebtoken:: Header ) -> Header {
78
+ fn from ( value : jsonwebtoken:: Header ) -> Header {
79
79
Header {
80
- algorithm : value. alg . clone ( ) ,
80
+ algorithm : Algorithm :: from ( value. alg . clone ( ) ) . into ( ) ,
81
81
content_type : value. cty . clone ( ) ,
82
82
json_key_url : value. jku . clone ( ) ,
83
83
key_id : value. kid . clone ( ) ,
You can’t perform that action at this time.
0 commit comments