hyperledger-cacti / cacti

Hyperledger Cacti is a new approach to the blockchain interoperability problem
https://wiki.hyperledger.org/display/cactus
Apache License 2.0
341 stars 283 forks source link

docs(examples): add Deno-ified API server demonstration #127

Open petermetz opened 4 years ago

petermetz commented 4 years ago

Update 2023-08-20

Deno added direct support for npm packages in the meantime which makes this exponentially simpler to implement. Right now if I import the ApiServer in a deno code file, it crashes with error: Uncaught TypeError: Unsupported named curve which I'm assuming is because the jose version we use is not yet Deno compatible (which is a blocker).

To put that above theory to the test, first we need to publish the latest code on npm, therefore this => Depends on https://github.com/hyperledger/cacti/issues/2573


Is your feature request related to a problem? Please describe. More like an enhancement/feature. Eventually we should support running on Deno which looks like it has certain security focused features for those who appreciate these kind of things. https://github.com/denoland/deno

Would be great if we could run on NodeJS and Deno as well.

Describe the solution you'd like Just make the code compatible with Deno, mostly it should just run valid Typescript out of the box but there could be issues with file system access and other permission/security related things that Deno lock down by default.

Describe alternatives you've considered Nothing else is out there that I'm aware of.

Additional context Clive on Rocket Chat also mentioned Deno and I agree 100% that it's a project that is up and coming and could even replace NodeJS as the de-facto runtime for server side Javascript/Typescript.

cliveb commented 4 years ago

Deno 1.0 is slated for May 13. https://blog.logrocket.com/deno-1-0-what-you-need-to-know/

I'm contributing to plugin based federated wiki by Ward Cunningham. The project has used node for about 10 years. Wiki learned security and other issues with node and plugins. The wiki dev team has been tracking Deno http://clive.tries.fed.wiki/view/welcome-visitors/view/deno-is-node-corrected.

Here are the plugins in node https://github.com/fedwiki Here is an experimental for in deno https://github.com/joshuabenuck/seran-wiki

cliveb commented 4 years ago

deno v1.0.0 released! https://deno.land/v1 "The CLI is the thing that is version 1.0 today."

github-actions[bot] commented 1 year ago

This PR/issue depends on:

petermetz commented 1 month ago

One step closer to making this happen.

deno cache --allow-scripts=npm:secp256k1 npm:protobufjs ./examples/cacti-example-deno-1/
peter@zend:~/a/cacti-upstream$ curl -fsSL https://deno.land/install.sh | sh
######################################################################## 100.0%
Archive:  /home/peter/.deno/bin/deno.zip
  inflating: /home/peter/.deno/bin/deno  
Deno was installed successfully to /home/peter/.deno/bin/deno
Manually add the directory to your $HOME/.bashrc (or similar)
  export DENO_INSTALL="/home/peter/.deno"
  export PATH="$DENO_INSTALL/bin:$PATH"
Run '/home/peter/.deno/bin/deno --help' to get started

Stuck? Join our Discord https://discord.gg/deno
peter@zend:~/a/cacti-upstream$ code /home/peter/.bashrc 
peter@zend:~/a/cacti-upstream$ 
peter@zend:~/a/cacti-upstream$ 
peter@zend:~/a/cacti-upstream$ 
peter@zend:~/a/cacti-upstream$ 
peter@zend:~/a/cacti-upstream$ source ~/.bashrc 
peter@zend:~/a/cacti-upstream$ deno examples/cacti-example-deno-1/main.ts 
Warning lmify@0.3.0 is deprecated: Please use https://github.com/unjs/nypm instead
warning: Packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed.
    This may cause the packages to not work correctly. To run them, use the `--allow-scripts` flag with `deno cache`
    (e.g. `deno cache --allow-scripts=pkg1,pkg2 <entrypoint>`):
      npm:secp256k1@4.0.3, npm:protobufjs@7.4.0
✅ Granted env access to "GRACEFUL_FS_PLATFORM".
✅ Granted read access to <CWD>.
✅ Granted env access to "TEST_GRACEFUL_FS_GLOBAL_PATCH".
✅ Granted env access to "OSTYPE".
✅ Granted env access to "FORCE_COLOR".
✅ Granted env access to "TERM".
✅ Granted env access to "CI".
✅ Granted env access to "TEAMCITY_VERSION".
✅ Granted env access to "COLORTERM".
✅ Granted env access.
✅ Granted sys access to "hostname".
✅ Granted read access to "/home/peter/a/node_modules".
✅ Granted read access to "/home/peter/node_modules".
✅ Granted read access to "/home/node_modules".
✅ Granted read access to "/node_modules".
✅ Granted read access to "/etc/alpine-release".
✅ Granted ffi access to "/home/peter/a/cacti-upstream/node_modules/.deno/secp256k1@4.0.3/node_modules/secp256k1/prebuilds/linux-x64/node.napi.glibc.node".
[2024-09-12T01:32:49.973Z] DEBUG (cacti-example-deno-1): ENV: [Object: null prototype] {
 }
[2024-09-12T01:32:49.975Z] DEBUG (cacti-example-deno-1): ARGS: []
[2024-09-12T01:32:49.975Z] DEBUG (cacti-example-deno-1): ConfigService instantiated OK
error: Uncaught (in promise) TypeError: unsupported named curve: secp256k1