Remote Signer
When the sdk is run in SingleUser mode, a user can be passed in instead of a suri. In this setup, signing will happen remotely on the caller's side using the sign() method defined in the remoteSignerOptions object. This is especially useful when building Dapps that require the user to sign actions on the Dapp or validate themselves without exposing their Suri.
In multiUserMode, the same remote signer option can be used but without having to specify the "address" in the remoteSignerOptions
Example
const { AvnApi, SetupMode, SigningMode } = require("avn-api");
const AVN_GATEWAY_URL = "https://gateway.testnet.aventus.network/";
async function signData(encodedDataToSign, signerAccount) {
// Example:
// Make an http call to a KMS to sign encodedData using signerAccount
// and return the signature
}
// This can be the address or public key.
const signerAccount = "5Gc8Po...baUBde";
const remoteSignerOptions = {
sign: (data) => signData(data, signerAccount),
address: signerAccount,
};
const singleUserOptions = {
signer: remoteSignerOptions,
setupMode: SetupMode.SingleUser,
signingMode: SigningMode.SuriBased,
};
const avnSdk = new AvnApi(AVN_GATEWAY_URL, singleUserOptions);
await avnSdk.init();