-
Notifications
You must be signed in to change notification settings - Fork 92
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
Enable TypeScript/JavaScript implementation to be used in a browser #609
Comments
I created a prototype implementation by:
The restructuring of the code seems to be successful but the bundling process highlighted that
|
My current thinking is that refactoring the current Node implementation so that it (or parts of it) can be run in a browser environment is impractical. It probably makes sense to make use of the WebCrypto (SubtleCrypto) API, and the Since the primary use case is to modify the off-line signing flow by both generating and signing request messages at the client to avoid the need for the server to generate messages and return them to the client for signing, a more practical approach might be to lift and refactor a subset of the existing code out into a separate browser package. This would include capability to:
An optional addition would be to directly build similar, cut-down variants of the block event request objects: FilteredBlockEventsRequest, BlockEventsRequest and BlockAndPrivateDataEventsRequest. The fabric-protos package also has a dependency on @grpc/grpc-js since it includes gRPC service stubs. As described in previous comments, @grpc/grpc-js has dependencies on many standard Node packages. It might be necessary to build and package within this browser package a subset of the fabric-protos, including only the ones needed to build the objects described above, and excluding gRPC services. Since the browser environment would only interact with the Fabric Gateway client API indirectly by passing serialised protocol buffer messages, this should not present a compatibility problem, since wire-level interoperability of serialized protocol buffer messages is robust. |
Hi! Do you have a status update on this issue? I see your PR has been in draft since April, and I'd love for this feature to be merged |
My progress on this stalled, partly due to time commitments and largely due to my lack of experience in developing, packaging and testing bundles for the browser. The people who were interested in this capability also went quiet. With nobody actively looking to make use of it, development took a back seat to other things. If you (or anyone else) can provide some guidance (or help) on some of the areas I am lacking experience, I would really like to get this done. I have rebased my working branch on the latest main branch content, and you can find it here. The actual implementation is pretty well complete. If you want to pull down that branch and build the Web bundle with You can generate API documentation with |
Sounds good! I've dabbled in module development, and I'd be happy to take a look and help out where I can. I'll try pulling your changes and testing them out. In the meantime, could you let me know what areas specifically I can offer help? Thanks for supporting this issue, I really appreciate it! |
The main thing is whether the code (currently output to
The unit test coverage is pretty comprehensive so it should work OK. I would feel more comfortable with some scenario tests that drive a transaction end-to-end into a running Fabric, which I have not yet done. If I can get good answers to the questions above, implement any changes necessary based on that, and the code works with some hands-on testing, perhaps it could be released sooner and I can work on scenario testing later. |
Ok great, so at first glance here's what I would propose:
|
As a front-end developer
I want to use the client API directly from the browser
So that a back-end Node.js server is not required as an intermediary
The key issues are the use of Node packages in the implementation, and some exposure of Node packages in the public API. This includes:
The core of the implementation either is or can be implemented without using any Node-specific packages. A workable approach seems to be to split this core capability out into a separate package, which can be depended on by the fabric-gateway package. The fabric-gateway package will then only contain Node-specific additions, such as the default signer, hash and checkpointer implementations. @noble/hashes should provide secure random and hash implementations required by the core package (for transactioncontext.ts) without any dependency on Node.js.
The alternatives available with the existing implementation are:
The text was updated successfully, but these errors were encountered: