Replies: 1 comment 2 replies
-
|
The standard way is to put them in the package tarball. Most native builds with external downloads can actually just do this (see https://github.com/prebuild/prebuildify). As with many problems in the npm ecosystem, people opt-in to many of the complexities and problems they encounter. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
NPM needs to solve issue with external assets being downloaded with a package
Problem
There are packages which requires big files (binaries, data files, LLM models, etc) being downloaded with the package itself and there is no standard solution to download these files with NPM. Such packages use install-scripts to do so. But developers disables install-scripts, because of security concerns. The problem is that it's hard (and sometimes impossible) to audit what has been downloaded and there could be malicious packages which doesn't download malicious payloads every time to hide their presence in repository. It make the whole process of installation unreliable and the infrastructure vulnerable
So developers should just trust to the package owners to be honest and careful to store only required files without bloating free space
Electron's RFC
For example Electron requires 200+ Mb to be with their package. They have pretty sophisticated installation system and release scheme. In a few words: they have different binaries and drivers for many platforms and bunch of temporal builds which they don't want to upload to NPM Registry. Now as most of developers disables installation scripts they want to change their installation to make things work for them without ruining DX for Electron users. It highlights the problem with the current NPM installation architecture
More here: electron/rfcs#22
Requirements
The solution should be:
There should be some deterministic way to specify and select URLs to download and then to verify them and to verify the final outcome of the installation
Solution
To solve this
package.jsonshould include "assets" directive for external downloadable resources. Assets directive allows to:The asset directive is an object or array of objects. If the asset is an object it contains list of files to be downloaded. If it's an array it contains installation variants. Each installation variant has conditions, like os, architecture and a runtime. This conditions are used by package manager to select suitable installation variant. After selecting suitable installation variant it would select the assets from provided list of files.
NPM and other package managers should download and check these files against checksums out of the box without the need to run installation scripts
Example of a regular assets files list:
{ "assets": { "bin/app": { "urls": ["https://cdn.developer.example/v1/bin/app"], "checksum": "sha-512:09af..." }, "models/llm-1": { "urls": ["https://cdn.models.example/llms/releases/llm-1/llm.tar.gz"], "archive": "tar-gz", "checksum": "sha-512:09af..." } } }Example of assets field with installation variants:
{ "assets": [ { "os": "darwin", "arch": "arm64", "osVersion": "", "files": { ".": { "urls": ["https://github.com/electron/electron/releases/download/v39.2.4/electron-v39.2.4-darwin-arm64.zip"], "archive": "zip", "checksum": "sha-512:09af..." } } }, { "os": "linux", "arch": "i686", "files": { ".": { "urls": ["https://github.com/electron/electron/releases/download/v39.2.4/electron-v39.2.4-linux-x64.zip"], "checksum": "sha-512:09af..." } } }, ] }Benefits of such solution
Beta Was this translation helpful? Give feedback.
All reactions