File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ const headers = {
1010const base64Url = ( value ) => Buffer . from ( value ) . toString ( 'base64url' ) ;
1111const REMOTE_SCOPE = 'notifycomp.remote' ;
1212const PUSH_SCOPE = 'assignment_notifications' ;
13+ const REMOTE_TOKEN_TTL_SECONDS = 12 * 60 * 60 ;
14+ const PUSH_TOKEN_TTL_SECONDS = 10 * 60 ;
1315
1416const signJwt = ( claims , secret ) => {
1517 const encodedHeader = base64Url ( JSON . stringify ( { alg : 'HS256' , typ : 'JWT' } ) ) ;
@@ -89,6 +91,8 @@ exports.handler = async (event) => {
8991 }
9092
9193 const tokenScope = scope === REMOTE_SCOPE ? REMOTE_SCOPE : PUSH_SCOPE ;
94+ const tokenTtlSeconds =
95+ tokenScope === REMOTE_SCOPE ? REMOTE_TOKEN_TTL_SECONDS : PUSH_TOKEN_TTL_SECONDS ;
9296 if ( tokenScope === REMOTE_SCOPE && ! competitionId ) {
9397 return {
9498 statusCode : 400 ,
@@ -102,7 +106,7 @@ exports.handler = async (event) => {
102106 {
103107 aud : process . env . COMPETITION_GROUPS_JWT_AUDIENCE || 'notifycomp' ,
104108 competitionIds : tokenScope === REMOTE_SCOPE ? [ competitionId ] : undefined ,
105- exp : now + 10 * 60 ,
109+ exp : now + tokenTtlSeconds ,
106110 iat : now ,
107111 iss : process . env . COMPETITION_GROUPS_JWT_ISSUER || 'competitiongroups.com' ,
108112 name : me . name ,
You can’t perform that action at this time.
0 commit comments