File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed
packages/jsonwebtoken/src Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ pub struct Header {
57
57
impl From < & Header > for jsonwebtoken:: Header {
58
58
#[ inline]
59
59
fn from ( value : & Header ) -> Self {
60
- let header = jsonwebtoken:: Header {
60
+ jsonwebtoken:: Header {
61
61
typ : Some ( String :: from ( "JWT" ) ) ,
62
62
alg : value. algorithm . unwrap_or ( Algorithm :: ES256 ) . into ( ) ,
63
63
cty : value. content_type . clone ( ) ,
@@ -69,9 +69,7 @@ impl From<&Header> for jsonwebtoken::Header {
69
69
x5t_s256 : value. x5t_s256_cert_thumbprint . clone ( ) ,
70
70
// TODO: support jwk
71
71
jwk : None ,
72
- } ;
73
-
74
- header
72
+ }
75
73
}
76
74
}
77
75
Original file line number Diff line number Diff line change 1
- use jsonwebtoken;
2
1
use napi:: { bindgen_prelude:: * , JsBuffer , JsBufferValue , Ref } ;
3
2
use napi_derive:: napi;
4
3
use std:: borrow:: Borrow ;
@@ -66,12 +65,12 @@ pub struct VerifyTask {
66
65
}
67
66
68
67
impl VerifyTask {
69
- pub fn verify ( token : & String , key : & [ u8 ] , validation : & Validation ) -> Result < Claims > {
68
+ pub fn verify ( token : & str , key : & [ u8 ] , validation : & Validation ) -> Result < Claims > {
70
69
let validation: & jsonwebtoken:: Validation = & validation. borrow ( ) . into ( ) ;
71
70
72
71
let first_alg = validation. algorithms . first ( ) . ok_or ( Error :: new (
73
72
Status :: InvalidArg ,
74
- format ! ( "Validation `algorithms` should contain at least one valid algorithm" ) ,
73
+ "Validation `algorithms` should contain at least one valid algorithm" . to_string ( ) ,
75
74
) ) ?;
76
75
let verify_key = & into_decoding_key ( key, first_alg) ?;
77
76
@@ -87,7 +86,7 @@ impl Task for VerifyTask {
87
86
type JsValue = Claims ;
88
87
89
88
fn compute ( & mut self ) -> Result < Self :: Output > {
90
- VerifyTask :: verify ( & self . token , & self . key . as_ref ( ) , & self . validation )
89
+ VerifyTask :: verify ( & self . token , self . key . as_ref ( ) , & self . validation )
91
90
}
92
91
93
92
fn resolve ( & mut self , _env : Env , output : Self :: Output ) -> Result < Self :: JsValue > {
You can’t perform that action at this time.
0 commit comments