README.mdView |
---|
3 | 3 … | Serve an npm registry server backed by SSB. |
4 | 4 … | |
5 | 5 … | ## Install |
6 | 6 … | |
7 | | -Requirement: scuttlebot running from the command line (`sbot server` / `ssb-server start`). |
| 7 … | +Requirement: ssb-server running from the command line (`sbot server` / `ssb-server start`). |
8 | 8 … | |
9 | 9 … | ``` |
10 | 10 … | BLOB_ID="$(sbot links2.read --query '[{"$filter":{"rel":["mentions",{"$prefix":"npm:ssb-npm-registry:"}]}}]'|grep -o '&.*sha256'|tail -n 1)" |
11 | 11 … | cd ~/.ssb && mkdir -p node_modules && cd node_modules |
20 | 20 … | ## Develop |
21 | 21 … | |
22 | 22 … | ### Install with git-ssb: |
23 | 23 … | |
24 | | -As a scuttlebot plugin: |
| 24 … | +As a ssb-server plugin: |
25 | 25 … | ``` |
26 | 26 … | git clone ssb://%pFqjcdVKHqsrtOjVEAVZeCF0iY4s+3Hr0vA3EFCq5UM=.sha256 ~/.ssb/node_modules/ssb-npm-registry |
27 | 27 … | cd ~/.ssb/node_modules/ssb-npm-registry |
28 | 28 … | ./enable.js |
29 | | -# restart sbot |
| 29 … | +# restart ssb-server |
30 | 30 … | ``` |
31 | 31 … | |
32 | 32 … | To set ssb-npm-registry as your default registry server: |
33 | 33 … | ``` |
59 | 59 … | - `config.npm.needShasum`: whether to fetch always calculate and send package shasums. Default is `false` but will always calculate the shasum in response to a request from `npm < v5` |
60 | 60 … | - `config.npm.baseUrl`: URL of this ssb-npm-registry instance, such as in case it is being served behind a proxy. Default is to try to detect it for each HTTP request from the Host header or local socket address. |
61 | 61 … | - `config.npm.defaultPkgs`: Array of names (or `name@version` strings) of |
62 | 62 … | ssb-npm packages for the bootstrap snippet to install globally with `npm`. |
63 | | - These are resolved to message ids when the snippet is served. Default: `["scuttlebot", "ssb-npm", "git-ssb"]` |
| 63 … | + These are resolved to message ids when the snippet is served. Default: `["ssb-server", "ssb-npm", "git-ssb"]` |
64 | 64 … | - `config.npm.postInstallCmd`: Command string for the bootstrap snippet to run |
65 | 65 … | after installing packages, if any. Default: `"sbot server"` |
66 | 66 … | |
67 | 67 … | ### Environmental variables |
105 | 105 … | `respond` method) serve the following additional routes: |
106 | 106 … | |
107 | 107 … | ### `/-/bootstrap` - Bootstrap shell snippet |
108 | 108 … | |
109 | | -Serves a shell script to for installing `ssb-npm-registry` and using it to install other `ssb-npm` packages by running in a bootstrap mode where it does not require running `scuttlebot`. |
| 109 … | +Serves a shell script to for installing `ssb-npm-registry` and using it to install other `ssb-npm` packages by running in a bootstrap mode where it does not require running `ssb-server`. |
110 | 110 … | |
111 | 111 … | ### `/-/blobs/get/:id` - Blobs |
112 | 112 … | |
113 | 113 … | Fetch a SSB blob by its id. |
136 | 136 … | ### Message scope |
137 | 137 … | |
138 | 138 … | Requests to the registry server can be scoped to one or more messages by prefixing the request pathname with a directory part with url-encoded message ids. You can make such requests by including that prefix in the registry URL. i.e. `npm --registry=http://localhost:8043/<MsgIdEnc>[,<MsgIdEnc>...]/ ...` |
139 | 139 … | |
140 | | -If a request is scoped to a message, the registry server will answer the request using information contained in that message or messages that it links to (recursively), instead of by using `sbot`'s ssb-links indexes. Fetching messages for a message-scoped request will be done using [`ssb-ooo`][] if that sbot plugin is available. |
| 140 … | +If a request is scoped to a message, the registry server will answer the request using information contained in that message or messages that it links to (recursively), instead of by using `ssb-server`'s ssb-links indexes. Fetching messages for a message-scoped request will be done using [`ssb-ooo`][] if that sbot plugin is available. |
141 | 141 … | |
142 | 142 … | A message-scoped request allows you to install a package without having to replicate the feeds of the authors of the package or its dependencies, since the information needed to install the package is referenced by message id. |
143 | 143 … | |
144 | | -If you prefix the message id with a caret (`^` or `%5E`), the results will include packages from both the message scope and sbot's ssb-links indexes. |
| 144 … | +If you prefix the message id with a caret (`^` or `%5E`), the results will include packages from both the message scope and ssb-server's ssb-links indexes. |
145 | 145 … | |
146 | | -If `sbot` does not have the `ssb-links` scuttlebot plugin, requests to the registry must use message scope and not the caret, since `ssb-links` is required otherwise. |
| 146 … | +If `ssb-server` does not have the `ssb-links` ssb-server plugin, requests to the registry must use message scope and not the caret, since `ssb-links` is required otherwise. |
147 | 147 … | |
148 | 148 … | When running the `ssb-npm` command or a ssb-npm bootstrap server |
149 | 149 … | (`ssb-npm-bootstrap` or `ssb-npm-registry/bootstrap/bin.js`), the `--branch` |
150 | 150 … | option is equivalent to adding a message id to the scope. |
154 | 154 … | ## Bootstrapping |
155 | 155 … | |
156 | 156 … | Since the ssb-npm and ssb-npm-registry packages are distributed on ssb-npm, |
157 | 157 … | there is a problem of how to get them securely if you do not already have |
158 | | -scuttlebot installed - especially if you also want to install scuttlebot via |
| 158 … | +ssb-server installed - especially if you also want to install ssb-server via |
159 | 159 … | ssb-npm. ssb-npm's bootstrap feature aims to solve this. ssb-npm-registry |
160 | 160 … | includes a route that serves a snippet of shell script code. Executing this |
161 | 161 … | bootstrap snippet fetches the ssb-npm-registry package identified by a blob id, |
162 | 162 … | uses that to run a bootstrap ssb-npm-registry server, and uses that to install |
163 | | -further packages from ssb-npm (e.g. the ssb-npm command, scuttlebot, git-ssb) |
| 163 … | +further packages from ssb-npm (e.g. the ssb-npm command, ssb-server, git-ssb) |
164 | 164 … | identified by message ids. The bootstrap snippet fetches from the network only |
165 | 165 … | hash-identified data (SSB blobs and messages), so the package contents cannot |
166 | 166 … | be modified by the server or in transit. By default, the snippet fetches |
167 | 167 … | content from the server that served the snippet, but it can be changed to fetch |