js-sdk
js-sdk copied to clipboard
Feature/lit 2962 auth unification better siwe authsig creation
Description
Previously, we had many conditional/optional parameters when creating a SIWE message, which led to confusion about its inputs and outputs. This PR introduces helper functions tailored to users' intentions.
-
createSiweMessage
- A general function that allows users to create any type of SIWE message, ideal for advanced users. -
createSiweMessageWithRecaps
- UsingcreateSiweMessage
under the hood, but adding recap resources to the SIWE message. -
createSiweMessageWithCapacityDelegation
- UsingcreateSiweMessage
under the hood, but setting the uri aslit:capability:delegation
and different optional parameters
These helper functions can be found here and here
Note that the actual changes are in feature/lit-2958-auth-unification-ts-tests cus they are needed for the tests to work. However, in this PR, we are actually using them in the core component.
- [x] (Breaking) Renaming
SIG_TYPE
toLIT_CURVE
- [x] Added types to facilitate new shape of JSON requests to node
- [x] Replace operations to use the following helpers:
import {
craftAuthSig,
createSiweMessageWithCapacityDelegation,
createSiweMessageWithRecaps,
createSiweMessage
} from '@lit-protocol/auth-helpers';
Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] This change requires a documentation update
How Has This Been Tested?
All tests will be provided in a separated PR
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
createSiweMessageWithRecaps - Using createSiweMessage under the hood, but adding recap resources to the SIWE message.
Doesn't all the Siwe messages require resource to be allowed from the user? @Ansonhkg
I'm approving this PR, although there are still comments unresolved. Might be worth responding & resolving it. For certain comments we may also defer addressing them later but we should track them in Linear @Ansonhkg