Page MenuHomePhabricator

[lib] Introduce `getPublicKeyFromSIWEStatement(...)`
ClosedPublic

Authored by atul on Dec 31 2022, 3:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 21, 9:59 PM
Unknown Object (File)
Fri, Jun 21, 3:52 AM
Unknown Object (File)
Fri, Jun 21, 3:52 AM
Unknown Object (File)
Fri, Jun 21, 3:52 AM
Unknown Object (File)
Fri, Jun 21, 1:31 AM
Unknown Object (File)
Fri, Jun 21, 1:31 AM
Unknown Object (File)
Thu, Jun 13, 2:04 AM
Unknown Object (File)
Tue, Jun 11, 7:01 PM
Subscribers
None

Details

Summary

Introduce getPublicKeyFromSIWEStatement(...) to pull public key out of SIWE statement which includes a public key. Will be used on the keyserver to retrieve the public key from the signed SIWE message.


Depends on D6130

Test Plan

included a unit test (will include more later)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

add isValidSIWEStatementWithPublicKey(...) precondition

atul published this revision for review.Dec 31 2022, 3:17 AM

Accepting to unblock, but in a less urgent context I would request changes. If you prefer, feel free to create (and link) a follow-up task to address before landing, but I feel strongly that we should just have one RegEx literal with a capture group instead of two separate RegEx literals

lib/utils/siwe-utils.js
64 ↗(On Diff #20481)
  1. Not sure why we're doing this twice. Can't we put a capture group in siweStatementWithPublicKeyRegex?
  2. Doesn't this allow the statement to have other parts match IdPubKey? I know right now there's no other part of the text that can match, but hypothetically that could change in the future. I think it'd better to use a capture group so that we know we're capturing the right part of the statement
This revision is now accepted and ready to land.Jan 1 2023, 8:02 PM

Accepting to unblock, but in a less urgent context I would request changes. If you prefer, feel free to create (and link) a follow-up task to address before landing, but I feel strongly that we should just have one RegEx literal with a capture group instead of two separate RegEx literals

Created a follow-up task: https://linear.app/comm/issue/ENG-2624/create-one-siwestatement-regex-literal-w-capture-group-instead-of-two since I'm confident this works for now. I'll read up on capture groups, I haven't used them before.

lib/utils/siwe-utils.js
64 ↗(On Diff #20481)

rebase after resolving merge conflicts

This revision was landed with ongoing or failed builds.Jan 3 2023, 2:21 PM
This revision was automatically updated to reflect the committed changes.