Skip to content

Conversation

@MichaelAJay
Copy link
Contributor

No description provided.

* Override signTx to require vault access
*/
public async signTx(params: any): Promise<any> {
return this.withVaultAccess(params.passphrase, super.signTx.bind(this), params);
Copy link
Contributor

@leolambo leolambo Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is interesting withVaultAccess unlocks using the passphrase. but the passphrase still needs to be sent via params?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Updated.

}

private getPublicKey(): string {
return this.publicKey.export({ type: 'spki', format: 'pem' }).toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this.publicKey null check

if (!walletEntry) {
throw new Error(`Wallet not found: ${name}`);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider privateKey null check

    if (!this.privateKey) {
      throw new Error('Private key not available - secure process not initialized or already cleaned up');
    }

});

await this.sendMessage<void>('initialize', {});
const publicKeyPem = await this.sendMessage<string>('getPublicKey', {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider validating retrieved key

if (!publicKeyPem || typeof publicKeyPem !== 'string' || publicKeyPem.trim().length === 0) {
    throw new Error('Invalid public key received from secure process');
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. typeof publicKeyPem !== 'string' || !publicKey.trim().length is functionally similar - any other falsy value (including undefined) than "" wouldn't make it past the type check, and the trim().length takes care of "".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants