Skip to content

Commit

Permalink
chore: add signature check when relaying a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
antomor committed Aug 29, 2024
1 parent b33c07e commit d4b9737
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/RelayServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export class RelayServer extends EventEmitter {

async validateInput(envelopingRequest: HttpEnvelopingRequest): Promise<void> {
const {
metadata: { relayHubAddress: relayHubAddressFromRequest },
metadata: { relayHubAddress: relayHubAddressFromRequest, signature },
relayRequest,
} = envelopingRequest;

Expand Down Expand Up @@ -299,6 +299,13 @@ export class RelayServer extends EventEmitter {
relayRequest.request.validUntilTime,
requestMinValidSeconds
);

// TODO: one of the 2 checks may be unnecessary
if (signature === SERVER_SIGNATURE_REQUIRED || [undefined, ''].includes(signature)) {
throw new Error(
'Unacceptable signature: it must be required and provided by the client'
);
}
}

validateVerifier(envelopingRequest: HttpEnvelopingRequest): void {
Expand Down

0 comments on commit d4b9737

Please sign in to comment.