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

BREAKING - Auth Unification

Open Ansonhkg opened this issue 10 months ago • 1 comments

Description

This PR introduces Tinny, an improved mini e2e testing framework that allows us to write tests in TypeScript. It leverages esbuild for rapid test compilation and execution. Tinny includes typed test helper functions to generate new identities within tests, and provides APIs to modify the development environment.

See docs: https://github.com/LIT-Protocol/js-sdk/tree/feature/lit-2958-auth-unification-ts-tests/local-tests

Note

We are not merging this PR to master until all related PRs are merged to this branch.

  • https://github.com/LIT-Protocol/js-sdk/pull/438
  • https://github.com/LIT-Protocol/js-sdk/pull/440
  • https://github.com/LIT-Protocol/js-sdk/pull/439
  • https://github.com/LIT-Protocol/js-sdk/pull/436

We should also raise a PR to remove all existing V0 features when we are ready to deploy. They are now being tracked here

Changes

  • [x] Local Network Context: Fixed issues to ensure local network settings are accurately recognized during test runs.
  • [x] Helper Functions: Introduced new helper functions for siweMessage creation and authSig crafting, addressing circular dependencies in the auth-helpers package.
  • [x] Fetch Polyfill: Implemented a temporary fix to ensure the fetch API is polyfilled correctly when bundling the tests.
  • [x] Interface Updates: Restored the litNodeClient to the ILitNodeClient interface to ensure type consistency.
  • [x] Auth unification params: Expanded authNeededCallbacks to support additional parameters and introduced a - higher-level function, getPkpSessionSigs, to streamline PKP sessionSigs creation process.
  • [x] Type Migration: Migrated type definitions to the types package to enhance modularity and maintenance.

Type of change

  • [x] 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?

https://github.com/LIT-Protocol/js-sdk/assets/4049673/9216c2ce-9774-45b4-92ed-3f666c00470f

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
  • [x] 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 17:04 Ansonhkg

This PR atm. as stated in the description is solely for the new testing environment, which is a prerequisite for other PRs to test their features against on, and will be merged on here once they are reviewed, and will be tested again. Perhaps I'll change the title so that's not as confusing.

Ansonhkg avatar Apr 24 '24 23:04 Ansonhkg

@Ansonhkg would we be able to update the e2e nodejs tests? when i go to use the 1-sig lit action test the following errror is returned

[Lit-JS-SDK v5.0.0] [2024-05-01T21:14:02.577Z] [ERROR] [core] [id: 0258afdf7707b] most common error: {"message":"You must pass in sessionSigs","errorCode":"InvalidArgumentException","errorKind":"Validation"}
[Lit-JS-SDK v5.0.0] [2024-05-01T21:14:02.577Z] [ERROR] [core] an error occured, attempting to retry operation
[Lit-JS-SDK v5.0.0] [2024-05-01T21:14:02.677Z] [ERROR] [core] [id: 9debb3e11d47] most common error: {"message":"You must pass in sessionSigs","errorCode":"InvalidArgumentException","errorKind":"Validation"}
[Lit-JS-SDK v5.0.0] [2024-05-01T21:14:02.778Z] [ERROR] [core] [id: 7997b5cc49cc1] most common error: {"message":"You must pass in sessionSigs","errorCode":"InvalidArgumentException","errorKind":"Validation"}
errConstructorFunc {
  message: 'You must pass in sessionSigs',
  errorCode: 'InvalidArgumentException',
  errorKind: 'Validation',
  status: undefined,
  details: undefined,
  requestId: '7997b5cc49cc1'
}

If we are going to keep them i think we must update them to now use sessions over auth signatures

joshLong145 avatar May 01 '24 21:05 joshLong145

@Ansonhkg would we be able to update the e2e nodejs tests? when i go to use the 1-sig lit action test the following errror is returned

[Lit-JS-SDK v5.0.0] [2024-05-01T21:14:02.577Z] [ERROR] [core] [id: 0258afdf7707b] most common error: {"message":"You must pass in sessionSigs","errorCode":"InvalidArgumentException","errorKind":"Validation"}
[Lit-JS-SDK v5.0.0] [2024-05-01T21:14:02.577Z] [ERROR] [core] an error occured, attempting to retry operation
[Lit-JS-SDK v5.0.0] [2024-05-01T21:14:02.677Z] [ERROR] [core] [id: 9debb3e11d47] most common error: {"message":"You must pass in sessionSigs","errorCode":"InvalidArgumentException","errorKind":"Validation"}
[Lit-JS-SDK v5.0.0] [2024-05-01T21:14:02.778Z] [ERROR] [core] [id: 7997b5cc49cc1] most common error: {"message":"You must pass in sessionSigs","errorCode":"InvalidArgumentException","errorKind":"Validation"}
errConstructorFunc {
  message: 'You must pass in sessionSigs',
  errorCode: 'InvalidArgumentException',
  errorKind: 'Validation',
  status: undefined,
  details: undefined,
  requestId: '7997b5cc49cc1'
}

If we are going to keep them i think we must update them to now use sessions over auth signatures

After playing with the new localtesting additions i think they are able to support networks which are not localchain if this is the case can we migrate from e2e-nodejs to using the new testing tools? This would mean switching ci to run these as well.

joshLong145 avatar May 02 '24 13:05 joshLong145