Page MenuHomePhabricator

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

Authored by atul on Dec 31 2022, 2:54 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:29 PM
Unknown Object (File)
Wed, Sep 18, 9:19 PM
Unknown Object (File)
Tue, Sep 10, 9:08 PM
Unknown Object (File)
Sun, Sep 8, 9:33 PM
Unknown Object (File)
Sun, Sep 8, 9:33 PM
Subscribers
None

Details

Summary

Introduce isValidSIWEStatementWithPublicKey(...) to check if SIWE statement is valid statement that includes the Device IdPubKey as described in the whitepaper: https://blob.sh/a3d138.png


Depends on D6129

Test Plan

included a unit test (will include more later)

Diff Detail

Repository
rCOMM Comm
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul published this revision for review.Dec 31 2022, 2:57 AM
atul added inline comments.
lib/utils/siwe-utils.js
53

Yes, this is a long line that exceeds the 80 character width limit.

Saw that there are ways to split a regex across multiple lines on StackOverflow (https://stackoverflow.com/questions/12317049/how-to-split-a-long-regular-expression-into-multiple-lines-in-javascript), but the solutions didn't seem as clean and there were some "gotchas."

Open to any suggestions.

ashoat added inline comments.
lib/utils/siwe-utils.js
53

Eh whatever. We do this in other places with JS RegExp literals in the codebase, like lib/shared/markdown.js

Can you update this to have a newline?

This revision is now accepted and ready to land.Jan 1 2023, 7:22 PM
lib/utils/siwe-utils.js
53

SIWE spec prohibits newlines in statement field

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