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

Add optional peer dependencies to new shared components modules? #1317

Closed
TimoGlastra opened this issue Feb 17, 2023 · 4 comments · Fixed by #1349
Closed

Add optional peer dependencies to new shared components modules? #1317

TimoGlastra opened this issue Feb 17, 2023 · 4 comments · Fixed by #1349
Assignees
Milestone

Comments

@TimoGlastra
Copy link
Contributor

TimoGlastra commented Feb 17, 2023

  • indy-sdk or indy-sdk-react-native
  • @hyperledger/indy-vdr-nodejs or @hyperledger/indy-vdr-react-native
  • @hyperledger/anoncreds-nodejs or @hyperledger/anoncreds-react-native
  • @hyperledger/aries-askar-nodejs or @hyperledger/aries-askar-react-native

Either add them as optional peer deps to the package.json or add documentation on that you need to install them

@Vickysomtee
Copy link
Contributor

Working on this!

@TimoGlastra
Copy link
Contributor Author

TimoGlastra commented Feb 23, 2023

  1. Don't add as peer dependency and write documentation that the user needs to install this package for their specific platform.
  • e.g. if using indy-vdr, it would mean you either have to install @hyperledger/indy-vdr-nodejs or @hyperledger/indy-vdr-react-native
  1. Add both the react native and nodejs packages to the package.json of the respective package, and then based on the platfrom you're currently in import either the nodejs, or the react native.
  • e.g. if using @aries-framework/indy-vdr, the package.json will contain depenecy on @hyperledger/indy-vdr-nodejs and @hyperledger/indy-vdr-react-native
    if (isNodeJs()) {
      // eslint-disable-next-line import/no-extraneous-dependencies
      require('@hyperledger/indy-vdr-nodejs')
   } else if (isReactNative()) {
      require('@hyperledger/indy-vdr-react-native')
   } else {
      // throw error unsupported platform
   }
  1. Require them to pass the native implementation explicitly to the module (and they will have to install the package themselves for the specific platform)
import { indyVdr } from '@hyperledger/indy-vdr-nodejs' 

const agent = new Agent({
  config: {},
  dependencies: agentDependencies,
  modules: {
    indyVdr: new IndyVdrModule({
      indyVdr,
   })
  }
})

@TimoGlastra
Copy link
Contributor Author

TimoGlastra commented Feb 23, 2023

For approach 3.:

Example with indy-sdk:

For e.g. indy-vdr you can use the IndyVdr type from the @hyperledger/indy-vdr-shared package as the type in the IndyVdrModuleConfig class (see indy-sdk example above)

@Vickysomtee
Copy link
Contributor

@TimoGlastra can you share more context on why a new Agent is created for approach 3?

@TimoGlastra TimoGlastra moved this from Todo to In Progress in Ledger Agnostic AnonCreds Mar 6, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Ledger Agnostic AnonCreds Mar 19, 2023
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 a pull request may close this issue.

2 participants