Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem after upgrade to latest version from 3.2.1 on verify method #299

Open
advapiIT opened this issue Jul 27, 2023 · 0 comments
Open

Comments

@advapiIT
Copy link

Hello,
I'm in the middle of an Angular update version from 9 to 16 and I'm getting this error when I updated crypto-js from 3.2.1 to 3.3.2

The original code was

  verifySignature(payload: string, signature: string, key: string): boolean {
    this.crypto.setPublicKey(key);
    const result = this.crypto.verify(payload, signature,CryptoJS.SHA256);

    return result;
  }

but It was giving this error

Error: src/app/shared/services/crypto.service.ts:47:59 - error TS2345: Argument of type 'HasherHelper' is not assignable to parameter of type '(str: string) => string'.
Type 'WordArray' is not assignable to type 'string'.

47 const result = this.crypto.verify(payload, signature, CryptoJS.SHA256);

Is this enough to replace the code with

  verifySignature(payload: string, signature: string, key: string): boolean {
    this.crypto.setPublicKey(key);
    const result = this.crypto.verify(payload, signature,(_)=> CryptoJS.SHA256.name);

    return result;
  }

or is there a correct and better way? At the moment I cannot create a unit test for this since the solution is not compiling

Any help appreciated,
Thanks

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

No branches or pull requests

1 participant