Responding To Sign Message Requests
Responding to a sign message request
Once our provider object has been initialized, we can simply listen to events and respond:
- Javascript
- TypeScript
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
// initialized provider
provider.onSignMessage(({ params }) => {
// ... using the `params.message` and the `params.signer` parameters, the provider signs the message with the private key of the signer and, with the signature, encodes as a base64 string
return {
providerId,
signature: 'gqNzaWfEQ...', // base64 encoded signature
signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
};
});
import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
// initialized provider
provider.onSignMessage(({ params }: IAVMWebProviderCallbackOptions) => {
// ... using the `params.message` and the `params.signer` parameters, the provider signs the message with the private key of the signer and, with the signature, encodes as a base64 string
return {
providerId,
signature: 'gqNzaWfEQ...', // base64 encoded signature
signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
};
});
caution
If this method is not supported, then a MethodNotSupportedError
should be thrown.
caution
If the signer, supplied in the params
, is not known, or not authorized, a UnauthorizedSignerError
should be thrown.