Use your own signature mechanism

In a previous chapter, we used the signature providers @requestnetwork/web3-signature and @requestnetwork/epk-signature (this one is made for test purpose). But, if you are not using web3, you need to inject your own signature mechanism to the request client. This is fairly simple, you need to implement a class following this interface: (see on github)

export interface ISignatureProvider {
  supportedMethods: Signature.METHOD[];
  supportedIdentityTypes: Identity.TYPE[];

  sign: (data: any, signer: Identity.IIdentity) => Promise<Signature.ISignedData>;
}

Example 1

For example, your own package to sign needs an ethereum address and return the signature as a hexadecimal string:

class mySignaturePackage {
  /**
   * Sign data
   *
   * @param data the data to sign
   * @param address the address to sign with
   * @returns a promise resolving the signature
   */
  public async sign(data: any, address: string): Promise<string>;
}

Your signature provider would look like:

Now you can inject it into the request client:

## Example 2

For example, your own package to sign needs an internal identifier and return the signature as a Buffer:

Your signature provider would look like:

Now you can inject it into the request client:

Last updated

Was this helpful?