1- import  {  logger ,  errors ,  AuthorizationError2 ,  ErrorCode  }  from  '@powersync/lib-services-framework' ; 
1+ import  {  logger ,  errors ,  AuthorizationError ,  ErrorCode  }  from  '@powersync/lib-services-framework' ; 
22import  *  as  jose  from  'jose' ; 
33import  secs  from  '../util/secs.js' ; 
44import  {  JwtPayload  }  from  './JwtPayload.js' ; 
@@ -69,7 +69,7 @@ export class KeyStore<Collector extends KeyCollector = KeyCollector> {
6969        return  audiences . includes ( a ) ; 
7070      } ) 
7171    )  { 
72-       throw  new  AuthorizationError2 ( 
72+       throw  new  AuthorizationError ( 
7373        ErrorCode . PSYNC_S2105 , 
7474        `Unexpected "aud" claim value: ${ JSON . stringify ( tokenPayload . aud ) }  , 
7575        {  sensitiveDetails : `Current configuration allows these audience values: ${ JSON . stringify ( audiences ) }   } 
@@ -82,15 +82,15 @@ export class KeyStore<Collector extends KeyCollector = KeyCollector> {
8282    // is too far into the future. 
8383    const  maxAge  =  keyOptions . maxLifetimeSeconds  ??  secs ( options . maxAge ) ; 
8484    if  ( tokenDuration  >  maxAge )  { 
85-       throw  new  AuthorizationError2 ( 
85+       throw  new  AuthorizationError ( 
8686        ErrorCode . PSYNC_S2104 , 
8787        `Token must expire in a maximum of ${ maxAge } ${ tokenDuration }  
8888      ) ; 
8989    } 
9090
9191    const  parameters  =  tokenPayload . parameters ; 
9292    if  ( parameters  !=  null  &&  ( Array . isArray ( parameters )  ||  typeof  parameters  !=  'object' ) )  { 
93-       throw  new  AuthorizationError2 ( ErrorCode . PSYNC_S2101 ,  `Payload parameters must be an object` ) ; 
93+       throw  new  AuthorizationError ( ErrorCode . PSYNC_S2101 ,  `Payload parameters must be an object` ) ; 
9494    } 
9595
9696    return  tokenPayload  as  JwtPayload ; 
@@ -119,7 +119,7 @@ export class KeyStore<Collector extends KeyCollector = KeyCollector> {
119119      for  ( let  key  of  keys )  { 
120120        if  ( key . kid  ==  kid )  { 
121121          if  ( ! key . matchesAlgorithm ( header . alg ) )  { 
122-             throw  new  AuthorizationError2 ( ErrorCode . PSYNC_S2101 ,  `Unexpected token algorithm ${ header . alg }  ,  { 
122+             throw  new  AuthorizationError ( ErrorCode . PSYNC_S2101 ,  `Unexpected token algorithm ${ header . alg }  ,  { 
123123              sensitiveDetails : `Key kid: ${ key . source . kid } ${ key . source . alg } ${ key . source . kty }  
124124            } ) ; 
125125          } 
@@ -154,7 +154,7 @@ export class KeyStore<Collector extends KeyCollector = KeyCollector> {
154154        logger . error ( `Failed to refresh keys` ,  e ) ; 
155155      } ) ; 
156156
157-       throw  new  AuthorizationError2 ( 
157+       throw  new  AuthorizationError ( 
158158        ErrorCode . PSYNC_S2101 , 
159159        'Could not find an appropriate key in the keystore. The key is missing or no key matched the token KID' , 
160160        { 
0 commit comments