js-sdk icon indicating copy to clipboard operation
js-sdk copied to clipboard

Feature/lit 2962 auth unification better siwe authsig creation

Open Ansonhkg opened this issue 10 months ago • 2 comments

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.

  1. createSiweMessage - A general function that allows users to create any type of SIWE message, ideal for advanced users.
  2. createSiweMessageWithRecaps - Using createSiweMessage under the hood, but adding recap resources to the SIWE message.
  3. createSiweMessageWithCapacityDelegation - Using createSiweMessage under the hood, but setting the uri as lit: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 to LIT_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

Ansonhkg avatar Apr 23 '24 21:04 Ansonhkg

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

DashKash54 avatar Apr 24 '24 23:04 DashKash54

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

DashKash54 avatar Apr 29 '24 20:04 DashKash54