Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/lit 4086 hide sessionsigs #752

Closed
wants to merge 10 commits into from

Conversation

FedericoAmura
Copy link
Contributor

@FedericoAmura FedericoAmura commented Dec 30, 2024

Description

This PR brings the authContext property in PKP*Wallet instances down to LitNodeClient to allow for automatic management of sessionSigs inside its methods

The authContext can be configured/updated when creating the LitNodeClient instance or afterwards. Having it, it is not needed to pass sessionSigs and the instance will use that to create them if needed. When a sessionSigs instance is passed, that will take precedence
There is also an option to override specific properties of the configured authContext when sessionSigs are needed.

With this PR, when using the authContext, litNodeClient.pkpSign and litNodeClient.executeJs can be executed without receiving sessionSigs

  const litNodeClient = new LitNodeClient({
    litNetwork: LIT_NETWORK,
    authContext: {
      getSessionSigsProps: {
        resourceAbilityRequests: ...,
        expiration: ...,
        authNeededCallback: ...
      },
    },
  });

  const signature = await litNodeClient.pkpSign({
    // sessionSigs, // <----- NO sessionSigs needed. Internally will call litNodeClient.getSessionSigs(authContext.getSessionSigsProps)
    // Properties to create `sessionSigs` can be overrided
    // getSessionSigsPropsOverride: {
    //   expiration: new Date(Date.now() - 1000 * 60 * 60 * 24).toISOString(), // (Will fail as `expiration` is in the past)
    // },
    pubKey: pkp.publicKey,
    toSign: MESSAGE_TO_SIGN,
  });
  console.log(`signature: ${JSON.stringify(signature)}`);

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added integration tests
  • Locally with a script signing a message using PKPEthersWallet, LitNodeClient with sessionSigs and LitNodeClient with authContext

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • 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

@FedericoAmura FedericoAmura marked this pull request as ready for review December 30, 2024 20:04
@Ansonhkg Ansonhkg mentioned this pull request Dec 31, 2024
@Ansonhkg
Copy link
Collaborator

Ansonhkg commented Jan 2, 2025

Closing this as per internal discussion

@Ansonhkg Ansonhkg closed this Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants