How to use the @colony/purser-core/helpers.messageVerificationObjectValidator function in @colony/purser-core

To help you get started, we’ve selected a few @colony/purser-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JoinColony / purser / modules / node_modules / @colony / purser-metamask / staticMethods.js View on Github external
export const verifyMessage = async ({
  currentAddress,
  ...messageVerificationObject
}: Object = {}) => {
  /*
   * Validate the current address
   */
  addressValidator(currentAddress);
  /*
   * Validate the rest of the pros using the core helper
   */
  const { message, signature } = messageVerificationObjectValidator(
    messageVerificationObject,
  );
  /*
   * We must check for the Metamask injected in-page proxy every time we
   * try to access it. This is because something can change it from the time
   * of last detection until now.
   */
  return methodCaller(
    /*
     * @TODO Move into own (non-anonymous) method
     * This way we could better test it
     */
    () =>
      new Promise((resolve, reject) => {
        /*
         * Verify the message
github JoinColony / purser / modules / node_modules / @colony / purser-ledger / staticMethods.js View on Github external
export const verifyMessage = async ({
  publicKey,
  ...signatureMessage
}: Object): Promise => {
  /*
   * Validate the public key locally
   */
  hexSequenceValidator(publicKey);
  /*
   * Validate the rest of the pros using the core helper
   */
  const { message, signature } = messageVerificationObjectValidator(
    signatureMessage,
  );
  return verifyMessageSignature({
    /*
     * Ensure the public key has the hex `0x` prefix
     */
    publicKey: hexSequenceNormalizer(publicKey),
    message,
    /*
     * Ensure the signature has the hex `0x` prefix
     */
    signature: hexSequenceNormalizer(signature),
  });
};
github JoinColony / purser / modules / node_modules / @colony / purser-trezor / staticMethods.js View on Github external
export const verifyMessage = async ({
  address,
  ...signatureMessage
}: Object = {}): Promise => {
  /*
   * Validate the address locally
   */
  addressValidator(address);
  /*
   * Validate the rest of the pros using the core helper
   */
  const { message, signature } = messageVerificationObjectValidator(
    signatureMessage,
  );
  warning(messages.messageSignatureOnlyTrezor);
  try {
    const { success: isMessageValid } = await payloadListener({
      payload: Object.assign({}, PAYLOAD_VERIFYMSG, {
        /*
         * Trezor service requires the prefix from the address to be stripped
         */
        address: addressNormalizer(address, false),
        message,
        /*
         * Trezor service requires the prefix from the signature to be stripped
         */
        signature: hexSequenceNormalizer(signature, false),
      }),
github JoinColony / purser / modules / node_modules / @colony / purser-software / staticMethods.js View on Github external
export const verifyMessage = async ({
  address,
  ...signatureMessage
}: Object = {}): Promise => {
  /*
   * Validate the address locally
   */
  addressValidator(address);
  /*
   * Validate the rest of the pros using the core helper
   */
  const { message, signature } = messageVerificationObjectValidator(
    signatureMessage,
  );
  try {
    const recoveredAddress: string = verifyEthersMessage(
      message,
      signature,
    );
    /*
     * Validate the recovered address
     */
    addressValidator(recoveredAddress);
    return address === recoveredAddress;
  } catch (caughtError) {
    throw new Error(
      `${messages.cannotVerifySignature} ${objectToErrorString(
        signatureMessage,