Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(node/crypto): Assign publicKey and privateKey with let instead of const #24943

Conversation

birkskyum
Copy link
Contributor

@birkskyum birkskyum commented Aug 8, 2024

Because public/private key are reassigned, they should be let instead of const.

  const privateKey = new PrivateKeyObject(privateKeyHandle);  // <- Const here
  const publicKey = new PublicKeyObject(publicKeyHandle); // <- Const here

  if (typeof options === "object" && options !== null) {
    const { publicKeyEncoding, privateKeyEncoding } = options as any;


    if (publicKeyEncoding) {
      publicKey = publicKey.export(publicKeyEncoding); // <- Reassigned here
    }

    if (privateKeyEncoding) {
      privateKey = privateKey.export(privateKeyEncoding);  // <- Reassigned here
    }
  }

This gives an error:

ERROR Assignment to constant variable.

Related to

@birkskyum birkskyum changed the title Assign publicKey and privateKey with let instead of const fix(crypto): Assign publicKey and privateKey with let instead of const Aug 8, 2024
@birkskyum birkskyum changed the title fix(crypto): Assign publicKey and privateKey with let instead of const fix(node:crypto): Assign publicKey and privateKey with let instead of const Aug 8, 2024
@birkskyum
Copy link
Contributor Author

birkskyum commented Aug 8, 2024

CI failed because I gave wrong PR title initially. I expect it to pass if rerun.

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@littledivy littledivy changed the title fix(node:crypto): Assign publicKey and privateKey with let instead of const fix(node/crypto): Assign publicKey and privateKey with let instead of const Aug 8, 2024
@littledivy littledivy merged commit 733162a into denoland:main Aug 8, 2024
17 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants