Page MenuHomePhabricator

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

Authored by atul on Dec 31 2022, 3:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Sep 18, 9:30 PM
Unknown Object (File)
Wed, Sep 18, 9:30 PM
Unknown Object (File)
Wed, Sep 18, 9:30 PM
Unknown Object (File)
Wed, Sep 18, 9:30 PM
Unknown Object (File)
Wed, Sep 18, 9:29 PM
Unknown Object (File)
Wed, Sep 18, 9:19 PM
Unknown Object (File)
Sat, Sep 14, 4:21 PM
Unknown Object (File)
Tue, Sep 10, 9:08 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
Branch
arcpatch-D6131 (branched from master)
Lint
No Lint Coverage
Unit
No Test Coverage

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.