File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ class NeetoJWT {
5252 const payload = {
5353 email : this . email ,
5454 workspace : this . workspace ,
55+ scope : this . scope ,
5556 iat,
5657 exp,
5758 } ;
Original file line number Diff line number Diff line change @@ -42,10 +42,23 @@ describe("NeetoJWT", () => {
4242 const decoded = jwt . verify ( token , publicKey , { algorithms : [ "ES256" ] } ) ;
4343 expect ( decoded . email ) . toBe ( email ) ;
4444 expect ( decoded . workspace ) . toBe ( workspace ) ;
45+ expect ( decoded . scope ) . toBe ( "user" ) ;
4546 expect ( decoded . iat ) . toBeDefined ( ) ;
4647 expect ( decoded . exp ) . toBeDefined ( ) ;
4748 } ) ;
4849
50+ it ( "should embed scope in the JWT payload for consumer scope" , ( ) => {
51+ const neetoJWT = new NeetoJWT ( {
52+ email,
53+ privateKey,
54+ scope : "consumer" ,
55+ } ) ;
56+ const token = neetoJWT . generateJWT ( ) ;
57+ const decoded = jwt . verify ( token , publicKey , { algorithms : [ "ES256" ] } ) ;
58+ expect ( decoded . scope ) . toBe ( "consumer" ) ;
59+ expect ( decoded . workspace ) . toBe ( "app" ) ;
60+ } ) ;
61+
4962 it ( "should generate a login URL" , ( ) => {
5063 const neetoJWT = new NeetoJWT ( { email, workspace, privateKey } ) ;
5164 const loginUrl = neetoJWT . generateLoginUrl ( redirectUri ) ;
You can’t perform that action at this time.
0 commit comments