File tree Expand file tree Collapse file tree 5 files changed +16
-5
lines changed
Expand file tree Collapse file tree 5 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 11import type { HandlerTypes } from '@matrixai/rpc' ;
2- import type AuthSignToken from '../handlers/AgentLockAll .js' ;
2+ import type AuthSignToken from '../handlers/AuthSignToken .js' ;
33import { UnaryCaller } from '@matrixai/rpc' ;
44
55type CallerTypes = HandlerTypes < AuthSignToken > ;
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ class ErrorClientVerificationFailed<T> extends ErrorClientService<T> {
5353class ErrorAuthentication < T > extends ErrorPolykey < T > { }
5454
5555class ErrorAuthenticationInvalidToken < T > extends ErrorAuthentication < T > {
56- static description = 'Incoming token does not match its signature ' ;
56+ static description = 'Token is invalid ' ;
5757 exitCode = sysexits . PROTOCOL ;
5858}
5959
Original file line number Diff line number Diff line change @@ -28,11 +28,19 @@ class AuthSignToken extends UnaryHandler<
2828 // Get and verify incoming node
2929 const inputToken = { payload : input . payload , signatures : input . signatures } ;
3030 const incomingToken = Token . fromEncoded < IdentityRequestData > ( inputToken ) ;
31+ if ( ! ( 'publicKey' in incomingToken . payload ) ) {
32+ throw new clientErrors . ErrorAuthenticationInvalidToken (
33+ 'Input token does not contain public key' ,
34+ ) ;
35+ }
3136 const incomingPublicKey = Buffer . from (
3237 incomingToken . payload . publicKey ,
38+ 'base64url' ,
3339 ) as PublicKey ;
3440 if ( ! incomingToken . verifyWithPublicKey ( incomingPublicKey ) ) {
35- throw new clientErrors . ErrorAuthenticationInvalidToken ( ) ;
41+ throw new clientErrors . ErrorAuthenticationInvalidToken (
42+ 'Incoming token does not match its signature' ,
43+ ) ;
3644 }
3745
3846 // Create the outgoing token with the incoming token integrated into the
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ type TokenMessage = {
111111// Return URL must be present on the token, otherwise token contents is decided
112112// by the client.
113113type IdentityRequestData = TokenPayload & {
114- returnUrl : string ;
114+ returnURL : string ;
115115 publicKey : string ;
116116} ;
117117
Original file line number Diff line number Diff line change @@ -477,7 +477,10 @@ function fromError(error: any) {
477477 // serialising only the error type, message and its stack.
478478 const wrappedError = new errors . ErrorPolykeyUnexpected (
479479 `Unexpected error occurred: ${ error . name } ` ,
480- { cause : error } ,
480+ {
481+ cause : error ,
482+ data : { message : 'message' in error ? error . message : undefined } ,
483+ } ,
481484 ) ;
482485 return wrappedError . toJSON ( ) ;
483486 }
You can’t perform that action at this time.
0 commit comments