@@ -75,21 +75,21 @@ describe('JWT Auth', () => {
7575 defaultAudiences : [ 'other' ] ,
7676 maxAge : '6m'
7777 } )
78- ) . rejects . toThrow ( 'unexpected "aud" claim value' ) ;
78+ ) . rejects . toThrow ( '[PSYNC_S2105] Unexpected "aud" claim value: "tests" ' ) ;
7979
8080 await expect (
8181 store . verifyJwt ( signedJwt , {
8282 defaultAudiences : [ ] ,
8383 maxAge : '6m'
8484 } )
85- ) . rejects . toThrow ( 'unexpected "aud" claim value' ) ;
85+ ) . rejects . toThrow ( '[PSYNC_S2105] Unexpected "aud" claim value: "tests" ' ) ;
8686
8787 await expect (
8888 store . verifyJwt ( signedJwt , {
8989 defaultAudiences : [ 'tests' ] ,
9090 maxAge : '1m'
9191 } )
92- ) . rejects . toThrow ( 'Token must expire in a maximum of' ) ;
92+ ) . rejects . toThrow ( '[PSYNC_S2104] Token must expire in a maximum of 60 seconds, got 300s ' ) ;
9393
9494 const signedJwt2 = await new jose . SignJWT ( { } )
9595 . setProtectedHeader ( { alg : 'HS256' , kid : 'k1' } )
@@ -104,7 +104,7 @@ describe('JWT Auth', () => {
104104 defaultAudiences : [ 'tests' ] ,
105105 maxAge : '5m'
106106 } )
107- ) . rejects . toThrow ( 'missing required "sub" claim ' ) ;
107+ ) . rejects . toThrow ( '[PSYNC_S2101] JWT payload is missing a required claim "sub"' ) ;
108108 } ) ;
109109
110110 test ( 'Algorithm validation' , async ( ) => {
@@ -159,7 +159,7 @@ describe('JWT Auth', () => {
159159 maxAge : '6m'
160160 } )
161161 ) . rejects . toThrow (
162- 'Could not find an appropriate key in the keystore. The key is missing or no key matched the token KID'
162+ '[PSYNC_S2101] Could not find an appropriate key in the keystore. The key is missing or no key matched the token KID'
163163 ) ;
164164
165165 // Wrong kid
@@ -178,7 +178,7 @@ describe('JWT Auth', () => {
178178 maxAge : '6m'
179179 } )
180180 ) . rejects . toThrow (
181- 'Could not find an appropriate key in the keystore. The key is missing or no key matched the token KID'
181+ '[PSYNC_S2101] Could not find an appropriate key in the keystore. The key is missing or no key matched the token KID'
182182 ) ;
183183
184184 // No kid, matches sharedKey2
@@ -255,7 +255,7 @@ describe('JWT Auth', () => {
255255 defaultAudiences : [ 'tests' ] ,
256256 maxAge : '6m'
257257 } )
258- ) . rejects . toThrow ( 'unexpected "aud" claim value' ) ;
258+ ) . rejects . toThrow ( '[PSYNC_S2105] Unexpected "aud" claim value: "tests" ' ) ;
259259
260260 const signedJwt3 = await new jose . SignJWT ( { } )
261261 . setProtectedHeader ( { alg : 'HS256' , kid : 'k1' } )
@@ -345,7 +345,7 @@ describe('JWT Auth', () => {
345345 expect ( key . kid ) . toEqual ( publicKeyRSA . kid ! ) ;
346346
347347 cached . addTimeForTests ( 301_000 ) ;
348- currentResponse = Promise . reject ( 'refresh failed' ) ;
348+ currentResponse = Promise . reject ( new Error ( 'refresh failed' ) ) ;
349349
350350 // Uses the promise, refreshes in the background
351351 let response = await cached . getKeys ( ) ;
@@ -356,15 +356,16 @@ describe('JWT Auth', () => {
356356 await cached . addTimeForTests ( 0 ) ;
357357 response = await cached . getKeys ( ) ;
358358 // Still have the cached key, but also have the error
359+ console . log ( 'e' , response . errors [ 0 ] ) ;
359360 expect ( response . keys [ 0 ] . kid ) . toEqual ( publicKeyRSA . kid ! ) ;
360- expect ( response . errors [ 0 ] . message ) . toMatch ( 'Failed to fetch ' ) ;
361+ expect ( response . errors [ 0 ] . message ) . toMatch ( '[PSYNC_S2201] refresh failed ' ) ;
361362
362363 await cached . addTimeForTests ( 3601_000 ) ;
363364 response = await cached . getKeys ( ) ;
364365
365366 // Now the keys have expired, and the request still fails
366367 expect ( response . keys ) . toEqual ( [ ] ) ;
367- expect ( response . errors [ 0 ] . message ) . toMatch ( 'Failed to fetch ' ) ;
368+ expect ( response . errors [ 0 ] . message ) . toMatch ( '[PSYNC_S2201] refresh failed ' ) ;
368369
369370 currentResponse = Promise . resolve ( {
370371 errors : [ ] ,
0 commit comments