mattrglobal / bbs-signatures

An implementation of BBS+ signatures for node and browser environments
Apache License 2.0
108 stars 30 forks source link

Add react-native-bbs-signatures as optional peer dependency #139

Open TimoGlastra opened 2 years ago

TimoGlastra commented 2 years ago

We've been working on a react native wrapper around the FFI interface that matches the interface of this library. We use it to expose the same functionlity in react native and leverage the jsonld-signatures-bbs library.

https://github.com/animo/react-native-bbs-signatures

Currently, however, we need to add overrides for all dependencies of @mattrglobal/bbs-signatures and map it to @animo-id/react-native-bbs-signatures. If we were to make @animo-id/react-native-bbs-signatures an optional peer dependency of this library and import it conditionally like is already done with node vs wasm, we wouldn't need any overrides anymore.

The package won't be installed by default and the user is still responsible for adding the dependency. It just adds support for the import in this library, meaning all packages that depend on this package (e.g. the bls12381-key-pair package) would automatically import the correct version.

We would still need to add the dependency to a react native project because autolinking only supports top-level packages declared in package.json, but it would make the setup easier.

Currently we have to add the following mapping to the package.json (depending whether you're using yarn/npm)

yarn

+   "resolutions": {
+     "@mattrglobal/bbs-signatures": "@animo-id/react-native-bbs-signatures@0.1.0",
+   }

npm

+   "overrides": {
+     "@mattrglobal/bbs-signatures": "@animo-id/react-native-bbs-signatures@0.1.0",
+   }

The resolution field says that any instance of @mattrglobal/bbs-signatures in any child dependency must be swapped with @animo-id/react-native-bbs-signatures.