Rocket.Chat.Apps-engine icon indicating copy to clipboard operation
Rocket.Chat.Apps-engine copied to clipboard

added support for built-in node modules

Open murtaza98 opened this issue 5 years ago • 4 comments

What? :boat:

@lolimay following the conversation from here (#204 #249)

The following is the list of secure built-in modules

  • assert,
  • async_hooks, // The async_hooks module exposes functions to track asynchronous resources.
  • buffer,
  • crypto,
  • dns, // dns resolver
  • timers,
  • util,
  • stream, // for working with streaming data in Node.js
  • readline, // reading data from file
  • querystring,
  • string_decoder,
  • url,

The following is a list of un-secure built-in modules which I haven't added support of

  • child_process,
  • cluster // Cluster is an extensible multi-core server manager
  • console // replacement for console
  • constants // deprecated
  • fs, // file system
  • os,
  • process,
  • worker_threads,
  • v8,
  • vm,
  • inspector,
  • module,
  • perf_hooks,
  • punycode, // deprecated
  • repl,
  • trace_events,
  • tty,
  • http,
  • http,
  • https,
  • path,
  • net,
  • zlib, // compress/extract from buffer

For the below 4 modules I'm not sure whether to include them or not. Currently, I've not included them

  • domain,
  • events,
  • globals,
  • tls, // its secure but this requires openssl installed

Why? :thinking:

Links :earth_americas:

PS :eyes:

murtaza98 avatar Apr 03 '20 07:04 murtaza98

Codecov Report

Merging #256 (4f58884) into master (e9ca98a) will increase coverage by 0.16%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #256      +/-   ##
==========================================
+ Coverage   53.81%   53.97%   +0.16%     
==========================================
  Files          70       70              
  Lines        2568     2577       +9     
  Branches      380      380              
==========================================
+ Hits         1382     1391       +9     
  Misses       1186     1186              
Impacted Files Coverage Δ
src/server/misc/Utilities.ts 57.69% <100.00%> (+8.85%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e9ca98a...4f58884. Read the comment docs.

codecov[bot] avatar Apr 03 '20 07:04 codecov[bot]

Not sure we should provide modules such as net, http, https etc. Since we actually don't want use other ways to access network excect existing APIs provided.

shiqimei avatar Apr 03 '20 10:04 shiqimei

As for zlib, since we don't provide filesystem r/w access, it not a good idea introduce it into the project.

shiqimei avatar Apr 03 '20 10:04 shiqimei

@lolimay thanks for the suggestion, removed support for those libraries

murtaza98 avatar Apr 04 '20 14:04 murtaza98

Is there a chance, that this will be merged?

jschirrmacher avatar Jan 11 '23 15:01 jschirrmacher

@jschirrmacher I don't think its required now since node-modules are already supported with rocket.chat apps. More info here -> https://developer.rocket.chat/apps-engine/adding-features/npm-package-support-experimental

murtaza98 avatar Jan 12 '23 06:01 murtaza98

Note about using node modules in your app and publishing them to our marketplace: you must contact us ahead of time so we can enable it on your publisher. As it is still experimental, we are gatekeeping just to ensure everything works right. Once we are out of the experimental phase then we will enable it for all publishers.

graywolf336 avatar Jan 12 '23 15:01 graywolf336

How about using the builtin console package of node.js?

As of a current (1.36.0) api version of rc-apps, I get this messages:

packaging your app... !
[info] using TypeScript v4.9.4
2023-01-11 15:51:27.606 WARN  App has external module(s) as dependency
2023-01-11 15:51:27.745 WARN  App has native module(s) as dependency
 ›   Error: Failed to resolve module: console

jschirrmacher avatar Feb 21 '23 12:02 jschirrmacher

Can you show me an example of this module being used? Also do share the package.json, tslint and tsconfig file

Is it something like the native console logs that we have in node like console.log('Some text')? I hope its not like this because I've been using this a ton of time

murtaza98 avatar Feb 22 '23 04:02 murtaza98

The funny thing is, there is no actual usage in my repository. An npm ls console doesn't show anything, and even a full text search only reveals @jest/console in package-lock.json.

jschirrmacher avatar Feb 22 '23 09:02 jschirrmacher