@vltpkg/vsr 0.0.0-26 → 0.0.0-28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/README.md +1 -0
- package/dist/assets/public/favicon.ico +0 -0
- package/dist/assets/public/fonts/courier-bold-italic.ttf +0 -0
- package/dist/assets/public/fonts/courier-bold.ttf +0 -0
- package/dist/assets/public/fonts/courier-italic.ttf +0 -0
- package/dist/assets/public/fonts/courier-regular.ttf +0 -0
- package/dist/assets/public/fonts/geist-mono.ttf +0 -0
- package/dist/assets/public/fonts/inter.ttf +0 -0
- package/dist/assets/public/images/bg.png +0 -0
- package/dist/assets/public/images/clients/logo-bun.png +0 -0
- package/dist/assets/public/images/clients/logo-deno.png +0 -0
- package/dist/assets/public/images/clients/logo-npm.png +0 -0
- package/dist/assets/public/images/clients/logo-pnpm.png +0 -0
- package/dist/assets/public/images/clients/logo-vlt.png +0 -0
- package/dist/assets/public/images/clients/logo-yarn.png +0 -0
- package/dist/assets/public/images/favicon/apple-touch-icon.png +0 -0
- package/dist/assets/public/images/favicon/favicon-96x96.png +0 -0
- package/dist/assets/public/images/favicon/favicon.ico +0 -0
- package/dist/assets/public/images/favicon/favicon.svg +3 -0
- package/dist/assets/public/images/favicon/site.webmanifest +21 -0
- package/dist/assets/public/images/favicon/web-app-manifest-192x192.png +0 -0
- package/dist/assets/public/images/favicon/web-app-manifest-512x512.png +0 -0
- package/dist/assets/public/index.html +70 -0
- package/dist/assets/public/index.js +1300 -0
- package/dist/assets/public/index.js.map +7 -0
- package/dist/assets/public/main.css +1 -0
- package/dist/assets/public/styles/styles.css +231 -0
- package/dist/bin/demo/package.json +6 -0
- package/dist/bin/demo/vlt.json +1 -0
- package/dist/bin/vsr.js +773 -0
- package/dist/index.js +28280 -0
- package/dist/index.js.map +8 -0
- package/package.json +6 -6
- package/scripts/build-bin.js +1 -0
- package/src/bin/vsr.ts +15 -3
- package/scripts/prepack.js +0 -27
- package/test/access.test.ts +0 -705
- package/test/audit.test.ts +0 -828
- package/test/dashboard.test.ts +0 -693
- package/test/dist-tags.test.ts +0 -678
- package/test/manifest.test.ts +0 -436
- package/test/packument.test.ts +0 -530
- package/test/ping.test.ts +0 -41
- package/test/search.test.ts +0 -472
- package/test/setup.ts +0 -130
- package/test/static.test.ts +0 -646
- package/test/tokens.test.ts +0 -389
- package/test/utils/auth.test.ts +0 -214
- package/test/utils/packages.test.ts +0 -235
- package/test/utils/response.test.ts +0 -184
- package/test/whoami.test.ts +0 -119
package/dist/bin/vsr.js
ADDED
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
#!/usr/bin/env NODE_OPTIONS=--no-warnings node
|
|
2
|
+
|
|
3
|
+
// src/bin/vsr.ts
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { PathScurry } from "path-scurry";
|
|
8
|
+
import { PackageJson } from "@vltpkg/package-json";
|
|
9
|
+
import { PackageInfoClient } from "@vltpkg/package-info";
|
|
10
|
+
import { createServer } from "@vltpkg/server";
|
|
11
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
12
|
+
|
|
13
|
+
// wrangler.json
|
|
14
|
+
var wrangler_default = {
|
|
15
|
+
name: "vsr",
|
|
16
|
+
main: "src/index.ts",
|
|
17
|
+
compatibility_date: "2024-09-23",
|
|
18
|
+
d1_databases: [
|
|
19
|
+
{
|
|
20
|
+
binding: "DB",
|
|
21
|
+
database_name: "vsr-local-database",
|
|
22
|
+
database_id: "74ce30e6-35cf-42b2-880e-be628f1e8bbb",
|
|
23
|
+
migrations_dir: "src/db/migrations"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
version_metadata: {
|
|
27
|
+
binding: "CF_VERSION_METADATA"
|
|
28
|
+
},
|
|
29
|
+
compatibility_flags: ["nodejs_compat"],
|
|
30
|
+
workers_dev: true,
|
|
31
|
+
r2_buckets: [
|
|
32
|
+
{
|
|
33
|
+
binding: "BUCKET",
|
|
34
|
+
bucket_name: "vsr-local-bucket"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
observability: {
|
|
38
|
+
logs: {
|
|
39
|
+
enabled: true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
queues: {
|
|
43
|
+
producers: [
|
|
44
|
+
{
|
|
45
|
+
queue: "cache-refresh-queue",
|
|
46
|
+
binding: "CACHE_REFRESH_QUEUE"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
consumers: [
|
|
50
|
+
{
|
|
51
|
+
queue: "cache-refresh-queue",
|
|
52
|
+
max_batch_size: 10,
|
|
53
|
+
max_batch_timeout: 5,
|
|
54
|
+
max_retries: 3
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
assets: {
|
|
59
|
+
directory: "./dist/assets/",
|
|
60
|
+
binding: "ASSETS"
|
|
61
|
+
},
|
|
62
|
+
dev: {
|
|
63
|
+
local_protocol: "http",
|
|
64
|
+
port: 1337
|
|
65
|
+
},
|
|
66
|
+
placement: {
|
|
67
|
+
mode: "smart"
|
|
68
|
+
},
|
|
69
|
+
vars: {
|
|
70
|
+
DAEMON_ENABLED: false,
|
|
71
|
+
TELEMETRY_ENABLED: true,
|
|
72
|
+
API_DOCS_ENABLED: true,
|
|
73
|
+
DEBUG_ENABLED: true,
|
|
74
|
+
SENTRY: {
|
|
75
|
+
dsn: "https://909b085eb764c00250ad312660c2fdf1@o4506397716054016.ingest.us.sentry.io/4509492612300800"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// package.json
|
|
81
|
+
var package_default = {
|
|
82
|
+
name: "@vltpkg/vsr",
|
|
83
|
+
version: "0.0.0-28",
|
|
84
|
+
repository: {
|
|
85
|
+
type: "git",
|
|
86
|
+
url: "git+https://github.com/vltpkg/vltpkg.git",
|
|
87
|
+
directory: "src/registry"
|
|
88
|
+
},
|
|
89
|
+
author: "vlt technology inc. <support@vlt.sh> (http://vlt.sh)",
|
|
90
|
+
bin: "./dist/bin/vsr.js",
|
|
91
|
+
dependencies: {
|
|
92
|
+
"@hono/sentry": "^1.2.2",
|
|
93
|
+
"@hono/zod-openapi": "^0.19.10",
|
|
94
|
+
"@libsql/client": "^0.15.14",
|
|
95
|
+
"@scalar/hono-api-reference": "^0.9.16",
|
|
96
|
+
"@vltpkg/package-info": "workspace:*",
|
|
97
|
+
"@vltpkg/package-json": "workspace:*",
|
|
98
|
+
"@vltpkg/server": "workspace:*",
|
|
99
|
+
"@vltpkg/vlt-json": "workspace:*",
|
|
100
|
+
"drizzle-orm": "^0.44.5",
|
|
101
|
+
hono: "^4.9.5",
|
|
102
|
+
minargs: "^2.1.0",
|
|
103
|
+
"path-scurry": "catalog:",
|
|
104
|
+
semver: "catalog:",
|
|
105
|
+
"validate-npm-package-name": "6.0.2",
|
|
106
|
+
wrangler: "^4.33.1",
|
|
107
|
+
zod: "^3.25.76"
|
|
108
|
+
},
|
|
109
|
+
devDependencies: {
|
|
110
|
+
"@cloudflare/vitest-pool-workers": "^0.8.68",
|
|
111
|
+
"@cloudflare/workers-types": "^4.20250829.0",
|
|
112
|
+
"@types/node": "catalog:",
|
|
113
|
+
"@types/validate-npm-package-name": "^4.0.2",
|
|
114
|
+
"@vltpkg/gui": "workspace:*",
|
|
115
|
+
"chokidar-cli": "^3.0.0",
|
|
116
|
+
"drizzle-kit": "^0.31.4",
|
|
117
|
+
esbuild: "^0.25.9",
|
|
118
|
+
eslint: "catalog:",
|
|
119
|
+
typedoc: "catalog:",
|
|
120
|
+
typescript: "catalog:",
|
|
121
|
+
"typescript-eslint": "catalog:",
|
|
122
|
+
vitest: "^3.2.4"
|
|
123
|
+
},
|
|
124
|
+
license: "FSL-1.1-MIT",
|
|
125
|
+
engines: {
|
|
126
|
+
node: ">=22"
|
|
127
|
+
},
|
|
128
|
+
scripts: {
|
|
129
|
+
build: "pnpm build:dist && pnpm build:assets && pnpm build:worker && pnpm build:bin",
|
|
130
|
+
"build:assets": "node scripts/build-assets.js",
|
|
131
|
+
"build:bin": "node scripts/build-bin.js",
|
|
132
|
+
"build:dist": `node -e "const fs=require('fs'); fs.rmSync('./dist', {recursive: true, force: true}); fs.mkdirSync('./dist/assets/public', {recursive: true});"`,
|
|
133
|
+
"build:worker": "npx wrangler deploy --dry-run --outdir dist",
|
|
134
|
+
"db:drop": `npx wrangler d1 execute vsr-local-database --file=src/db/migrations/drop.sql --local --persist-to=local-store --no-remote && node -e "const fs=require('fs'); fs.rmSync('local-store',{recursive:true,force:true}); fs.rmSync('.wrangler',{recursive:true,force:true});"`,
|
|
135
|
+
"db:generate": "drizzle-kit generate",
|
|
136
|
+
"db:migrate": "drizzle-kit migrate",
|
|
137
|
+
"db:push": "drizzle-kit push",
|
|
138
|
+
"db:setup": "npx wrangler d1 execute vsr-local-database --file=src/db/migrations/0000_initial.sql --local --persist-to=local-store --no-remote && npx wrangler d1 execute vsr-local-database --file=src/db/migrations/0001_wealthy_magdalene.sql --local --persist-to=local-store --no-remote",
|
|
139
|
+
"db:studio": "drizzle-kit studio --port 4985",
|
|
140
|
+
deploy: "pnpm build && npx wrangler deploy",
|
|
141
|
+
format: "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
142
|
+
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
143
|
+
lint: "eslint . --fix",
|
|
144
|
+
"lint:check": "eslint .",
|
|
145
|
+
prepack: "pnpm build",
|
|
146
|
+
"serve:build": "pnpm --silent build && node ./dist/bin/vsr.js --debug --daemon=false",
|
|
147
|
+
"serve:build:daemon": "pnpm --silent build && node ./dist/bin/vsr.js --debug --daemon=true",
|
|
148
|
+
"serve:death": `echo "Killing wrangler dev processes..." && (pkill -f 'wrangler.*dev' || true) && sleep 1 && (pids=$(lsof -ti :1337 2>/dev/null; lsof -ti :3000 2>/dev/null) && [ -n "$pids" ] && echo "Force killing remaining processes: $pids" && kill -9 $pids || echo "No remaining processes found") && echo "Done."`,
|
|
149
|
+
"serve:watch": "chokidar './src/**/*' -c 'pnpm serve:death && pnpm serve:build'",
|
|
150
|
+
snap: "vitest --no-watch -u",
|
|
151
|
+
pretest: "pnpm build",
|
|
152
|
+
test: "vitest --no-watch",
|
|
153
|
+
posttest: "tsc --noEmit",
|
|
154
|
+
typecheck: "tsc --noEmit",
|
|
155
|
+
"typecheck:worker": "tsc -p tsconfig.worker.json --noEmit"
|
|
156
|
+
},
|
|
157
|
+
type: "module"
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// src/utils/docs.ts
|
|
161
|
+
var apiBody = ({ YEAR: YEAR2 }) => {
|
|
162
|
+
return `The **vlt serverless registry** is the modern JavaScript package registry.
|
|
163
|
+
|
|
164
|
+
### Compatible Clients
|
|
165
|
+
|
|
166
|
+
<table>
|
|
167
|
+
<tbody>
|
|
168
|
+
<tr>
|
|
169
|
+
<td><a href="https://vlt.sh" alt="vlt"><strong><code>vlt</code></strong></a></td>
|
|
170
|
+
<td><a href="https://npmjs.com/package/npm" alt="npm"><strong><code>npm</code></strong></a></td>
|
|
171
|
+
<td><a href="https://yarnpkg.com/" alt="yarn"><strong><code>yarn</code></strong></a></td>
|
|
172
|
+
<td><a href="https://pnpm.io/" alt="pnpm"><strong><code>pnpm</code></strong></a></td>
|
|
173
|
+
<td><a href="https://deno.com/" alt="deno"><strong><code>deno</code></strong></a></td>
|
|
174
|
+
<td><a href="https://bun.sh/" alt="bun"><strong><code>bun</code></strong></a></td>
|
|
175
|
+
</tr>
|
|
176
|
+
</tbody>
|
|
177
|
+
</table>
|
|
178
|
+
|
|
179
|
+
### Resources
|
|
180
|
+
|
|
181
|
+
<ul alt="resources">
|
|
182
|
+
<li><a href="https://vlt.sh">https://<strong>vlt.sh</strong></a></li>
|
|
183
|
+
<li><a href="https://github.com/vltpkg/vsr">https://github.com/<strong>vltpkg/vsr</strong></a></li>
|
|
184
|
+
<li><a href="https://discord.gg/vltpkg">https://discord.gg/<strong>vltpkg</strong></a></li>
|
|
185
|
+
<li><a href="https://x.com/vltpkg">https://x.com/<strong>vltpkg</strong></a></li>
|
|
186
|
+
</ul>
|
|
187
|
+
|
|
188
|
+
##### Trademark Disclaimer
|
|
189
|
+
|
|
190
|
+
<p alt="trademark-disclaimer">All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.</p>
|
|
191
|
+
|
|
192
|
+
### License
|
|
193
|
+
|
|
194
|
+
<details alt="license">
|
|
195
|
+
<summary><strong>Functional Source License</strong>, Version 1.1, MIT Future License</summary>
|
|
196
|
+
<h1>Functional Source License,<br />Version 1.1,<br />MIT Future License</h1>
|
|
197
|
+
<h2>Abbreviation</h2>
|
|
198
|
+
|
|
199
|
+
FSL-1.1-MIT
|
|
200
|
+
|
|
201
|
+
<h2>Notice</h2>
|
|
202
|
+
|
|
203
|
+
Copyright ${YEAR2} vlt technology inc.
|
|
204
|
+
|
|
205
|
+
<h2>Terms and Conditions</h2>
|
|
206
|
+
|
|
207
|
+
<h3>Licensor ("We")</h3>
|
|
208
|
+
|
|
209
|
+
The party offering the Software under these Terms and Conditions.
|
|
210
|
+
|
|
211
|
+
<h3>The Software</h3>
|
|
212
|
+
|
|
213
|
+
The "Software" is each version of the software that we make available under
|
|
214
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
215
|
+
Conditions with the Software.
|
|
216
|
+
|
|
217
|
+
<h3>License Grant</h3>
|
|
218
|
+
|
|
219
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
220
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
221
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
222
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
223
|
+
|
|
224
|
+
<h3>Permitted Purpose</h3>
|
|
225
|
+
|
|
226
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
227
|
+
means making the Software available to others in a commercial product or
|
|
228
|
+
service that:
|
|
229
|
+
|
|
230
|
+
1. substitutes for the Software;
|
|
231
|
+
|
|
232
|
+
2. substitutes for any other product or service we offer using the Software
|
|
233
|
+
that exists as of the date we make the Software available; or
|
|
234
|
+
|
|
235
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
236
|
+
|
|
237
|
+
Permitted Purposes specifically include using the Software:
|
|
238
|
+
|
|
239
|
+
1. for your internal use and access;
|
|
240
|
+
|
|
241
|
+
2. for non-commercial education;
|
|
242
|
+
|
|
243
|
+
3. for non-commercial research; and
|
|
244
|
+
|
|
245
|
+
4. in connection with professional services that you provide to a licensee
|
|
246
|
+
using the Software in accordance with these Terms and Conditions.
|
|
247
|
+
|
|
248
|
+
<h3>Patents</h3>
|
|
249
|
+
|
|
250
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
251
|
+
patents, the license grant above includes a license under our patents. If you
|
|
252
|
+
make a claim against any party that the Software infringes or contributes to
|
|
253
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
254
|
+
immediately.
|
|
255
|
+
|
|
256
|
+
<h3>Redistribution</h3>
|
|
257
|
+
|
|
258
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
259
|
+
the Software.
|
|
260
|
+
|
|
261
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
262
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
263
|
+
remove any copyright notices provided in or with the Software.
|
|
264
|
+
|
|
265
|
+
<h3>Disclaimer</h3>
|
|
266
|
+
|
|
267
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
268
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
269
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
270
|
+
|
|
271
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
272
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
273
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
274
|
+
|
|
275
|
+
<h3>Trademarks</h3>
|
|
276
|
+
|
|
277
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
278
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
279
|
+
trademarks, trade names, service marks or product names.
|
|
280
|
+
|
|
281
|
+
<h2>Grant of Future License</h2>
|
|
282
|
+
|
|
283
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
284
|
+
the MIT license that is effective on the second anniversary of the date we make
|
|
285
|
+
the Software available. On or after that date, you may use the Software under
|
|
286
|
+
the MIT license, in which case the following will apply:
|
|
287
|
+
|
|
288
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
289
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
290
|
+
the Software without restriction, including without limitation the rights to
|
|
291
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
292
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
293
|
+
so, subject to the following conditions:
|
|
294
|
+
|
|
295
|
+
The above copyright notice and this permission notice shall be included in all
|
|
296
|
+
copies or substantial portions of the Software.
|
|
297
|
+
|
|
298
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
299
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
300
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
301
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
302
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
303
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
304
|
+
SOFTWARE.
|
|
305
|
+
</dialog>`;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// config.ts
|
|
309
|
+
var YEAR = (/* @__PURE__ */ new Date()).getFullYear();
|
|
310
|
+
var WRANGLER_CONFIG = wrangler_default.dev;
|
|
311
|
+
var PORT = WRANGLER_CONFIG.port || 1337;
|
|
312
|
+
var DAEMON_PORT = 3e3;
|
|
313
|
+
var DAEMON_URL = `http://localhost:${DAEMON_PORT}`;
|
|
314
|
+
var VERSION = package_default.version;
|
|
315
|
+
var URL = `http://localhost:${PORT}`;
|
|
316
|
+
var REDIRECT_URI = `${URL}/-/auth/callback`;
|
|
317
|
+
var ORIGIN_CONFIG = {
|
|
318
|
+
default: "local",
|
|
319
|
+
upstreams: {
|
|
320
|
+
local: {
|
|
321
|
+
type: "local",
|
|
322
|
+
url: URL,
|
|
323
|
+
allowPublish: true
|
|
324
|
+
},
|
|
325
|
+
npm: {
|
|
326
|
+
type: "npm",
|
|
327
|
+
url: "https://registry.npmjs.org"
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
var PROXY = Object.keys(ORIGIN_CONFIG.upstreams).length > 1;
|
|
332
|
+
var PROXY_URL = ORIGIN_CONFIG.upstreams[ORIGIN_CONFIG.default]?.url;
|
|
333
|
+
var REQUEST_TIMEOUT = 60 * 1e3;
|
|
334
|
+
var OPEN_API_CONFIG = {
|
|
335
|
+
openapi: "3.1.0",
|
|
336
|
+
info: {
|
|
337
|
+
title: "vlt serverless registry",
|
|
338
|
+
version: VERSION,
|
|
339
|
+
description: "The vlt serverless registry API"
|
|
340
|
+
},
|
|
341
|
+
tags: [
|
|
342
|
+
{
|
|
343
|
+
name: "Health Check",
|
|
344
|
+
description: "Registry health and status endpoints"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: "Authentication",
|
|
348
|
+
description: "User authentication and token management"
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
name: "Packages",
|
|
352
|
+
description: "Package publishing, downloading, and management"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "Dist-Tags",
|
|
356
|
+
description: "Package version tagging and lifecycle management"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "Access Control",
|
|
360
|
+
description: "Package access permissions and collaborator management"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: "Search",
|
|
364
|
+
description: "Package discovery and search functionality"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "Security",
|
|
368
|
+
description: "Security auditing and vulnerability scanning"
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
name: "Dashboard",
|
|
372
|
+
description: "Registry dashboard and administration"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: "Static Assets",
|
|
376
|
+
description: "Static file serving and web assets"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: "NPM Compatibility",
|
|
380
|
+
description: "Legacy npm client compatibility redirects"
|
|
381
|
+
}
|
|
382
|
+
]
|
|
383
|
+
};
|
|
384
|
+
var SCALAR_API_CONFIG = {
|
|
385
|
+
metaData: {
|
|
386
|
+
title: "vlt serverless registry"
|
|
387
|
+
},
|
|
388
|
+
hideModels: false,
|
|
389
|
+
hideDownloadButton: false,
|
|
390
|
+
darkMode: false,
|
|
391
|
+
favicon: "/public/images/favicon/favicon.svg",
|
|
392
|
+
defaultHttpClient: {
|
|
393
|
+
targetKey: "curl",
|
|
394
|
+
clientKey: "fetch"
|
|
395
|
+
},
|
|
396
|
+
authentication: {
|
|
397
|
+
http: {
|
|
398
|
+
bearer: {
|
|
399
|
+
token: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
400
|
+
},
|
|
401
|
+
basic: {
|
|
402
|
+
username: "user",
|
|
403
|
+
password: "pass"
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
hiddenClients: {
|
|
408
|
+
python: true,
|
|
409
|
+
c: true,
|
|
410
|
+
go: true,
|
|
411
|
+
java: true,
|
|
412
|
+
ruby: true,
|
|
413
|
+
shell: ["httpie", "wget", "fetch"],
|
|
414
|
+
clojure: true,
|
|
415
|
+
csharp: true,
|
|
416
|
+
kotlin: true,
|
|
417
|
+
objc: true,
|
|
418
|
+
swift: true,
|
|
419
|
+
r: true,
|
|
420
|
+
powershell: false,
|
|
421
|
+
ocaml: true,
|
|
422
|
+
curl: false,
|
|
423
|
+
http: true,
|
|
424
|
+
php: true,
|
|
425
|
+
node: ["request", "unirest"],
|
|
426
|
+
javascript: ["xhr", "jquery"]
|
|
427
|
+
},
|
|
428
|
+
spec: {
|
|
429
|
+
content: {
|
|
430
|
+
openapi: OPEN_API_CONFIG.openapi,
|
|
431
|
+
servers: [
|
|
432
|
+
{
|
|
433
|
+
url: URL,
|
|
434
|
+
description: "localhost"
|
|
435
|
+
}
|
|
436
|
+
],
|
|
437
|
+
info: {
|
|
438
|
+
title: "vlt serverless registry",
|
|
439
|
+
version: VERSION,
|
|
440
|
+
license: {
|
|
441
|
+
identifier: "FSL-1.1-MIT",
|
|
442
|
+
name: "Functional Source License, Version 1.1, MIT Future License",
|
|
443
|
+
url: "https://fsl.software/FSL-1.1-MIT.template.md"
|
|
444
|
+
},
|
|
445
|
+
description: apiBody({ YEAR })
|
|
446
|
+
},
|
|
447
|
+
// Include tag ordering and descriptions
|
|
448
|
+
tags: OPEN_API_CONFIG.tags
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
customCss: `@import '${URL}/public/styles/styles.css';`
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
// src/bin/vsr.ts
|
|
455
|
+
import { minArgs } from "minargs";
|
|
456
|
+
import { load } from "@vltpkg/vlt-json";
|
|
457
|
+
import { createRequire } from "node:module";
|
|
458
|
+
var usage = `USAGE:
|
|
459
|
+
|
|
460
|
+
$ vsr [<command>] [<options>]
|
|
461
|
+
|
|
462
|
+
COMMANDS:
|
|
463
|
+
|
|
464
|
+
dev Start development server (default)
|
|
465
|
+
deploy Deploy to Cloudflare Workers
|
|
466
|
+
|
|
467
|
+
OPTIONS: DESCRIPTION:
|
|
468
|
+
|
|
469
|
+
--daemon=<boolean> Run filesystem daemon (default: true)
|
|
470
|
+
--telemetry=<boolean> Run with telemetry reporting (default: true)
|
|
471
|
+
-p, --port=<number> Run on a specific port (default: ${DAEMON_PORT})
|
|
472
|
+
-c, --config=<path> Load configuration from vlt.json file
|
|
473
|
+
-d, --debug Run in debug mode
|
|
474
|
+
-h, --help Print usage information
|
|
475
|
+
|
|
476
|
+
DEPLOY OPTIONS:
|
|
477
|
+
|
|
478
|
+
--env=<string> Environment to deploy to (dev, staging, prod)
|
|
479
|
+
--db-name=<string> Override D1 database name
|
|
480
|
+
--bucket-name=<string> Override R2 bucket name
|
|
481
|
+
--queue-name=<string> Override queue name
|
|
482
|
+
--dry-run Show what would be deployed without deploying
|
|
483
|
+
|
|
484
|
+
EXAMPLES:
|
|
485
|
+
|
|
486
|
+
$ vsr # Run dev server with all defaults
|
|
487
|
+
$ vsr dev --port=3000 --debug # Custom port with debug
|
|
488
|
+
$ vsr deploy # Deploy to default environment
|
|
489
|
+
$ vsr deploy --env=prod # Deploy to production
|
|
490
|
+
$ vsr deploy --dry-run # Preview deployment
|
|
491
|
+
$ vsr --config=/path/to/vlt.json # Use specific config file
|
|
492
|
+
`;
|
|
493
|
+
var defaults = {
|
|
494
|
+
daemon: true,
|
|
495
|
+
telemetry: true,
|
|
496
|
+
debug: false,
|
|
497
|
+
help: false,
|
|
498
|
+
port: WRANGLER_CONFIG.port,
|
|
499
|
+
config: void 0,
|
|
500
|
+
env: void 0,
|
|
501
|
+
"db-name": void 0,
|
|
502
|
+
"bucket-name": void 0,
|
|
503
|
+
"queue-name": void 0,
|
|
504
|
+
"dry-run": false
|
|
505
|
+
};
|
|
506
|
+
var opts = {
|
|
507
|
+
alias: {
|
|
508
|
+
p: "port",
|
|
509
|
+
c: "config",
|
|
510
|
+
d: "debug",
|
|
511
|
+
h: "help"
|
|
512
|
+
},
|
|
513
|
+
boolean: ["debug", "help", "daemon", "telemetry", "dry-run"],
|
|
514
|
+
string: [
|
|
515
|
+
"port",
|
|
516
|
+
"config",
|
|
517
|
+
"env",
|
|
518
|
+
"db-name",
|
|
519
|
+
"bucket-name",
|
|
520
|
+
"queue-name"
|
|
521
|
+
],
|
|
522
|
+
default: defaults,
|
|
523
|
+
positionalValues: true
|
|
524
|
+
// Allow space-separated values like -p 3000
|
|
525
|
+
};
|
|
526
|
+
var { args, positionals } = minArgs(opts);
|
|
527
|
+
var command = positionals[0] || "dev";
|
|
528
|
+
function getBooleanValue(arg, defaultValue) {
|
|
529
|
+
if (!arg || arg.length === 0) return defaultValue;
|
|
530
|
+
const value = arg[0];
|
|
531
|
+
if (value === "" || value === void 0) return true;
|
|
532
|
+
return value !== "false" && value !== "0";
|
|
533
|
+
}
|
|
534
|
+
function getStringValue(arg, defaultValue) {
|
|
535
|
+
if (!arg || arg.length === 0) return defaultValue;
|
|
536
|
+
return arg[0] || defaultValue;
|
|
537
|
+
}
|
|
538
|
+
function getNumberValue(arg, defaultValue) {
|
|
539
|
+
if (!arg || arg.length === 0) return defaultValue;
|
|
540
|
+
const value = arg[0];
|
|
541
|
+
return Number(value) || defaultValue;
|
|
542
|
+
}
|
|
543
|
+
function loadVltConfig(configPath2) {
|
|
544
|
+
try {
|
|
545
|
+
const isVsrConfig = (x, _file) => {
|
|
546
|
+
if (x === null || typeof x !== "object") {
|
|
547
|
+
throw new Error("Config must be an object");
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
let configData;
|
|
551
|
+
if (configPath2) {
|
|
552
|
+
if (!existsSync(configPath2)) {
|
|
553
|
+
console.warn(`Config file not found: ${configPath2}`);
|
|
554
|
+
return {};
|
|
555
|
+
}
|
|
556
|
+
const configContent = readFileSync(configPath2, "utf8");
|
|
557
|
+
try {
|
|
558
|
+
configData = JSON.parse(configContent);
|
|
559
|
+
} catch (_err) {
|
|
560
|
+
console.warn(`Failed to parse config file ${configPath2}`);
|
|
561
|
+
return {};
|
|
562
|
+
}
|
|
563
|
+
} else {
|
|
564
|
+
try {
|
|
565
|
+
configData = load("config", isVsrConfig);
|
|
566
|
+
} catch (_err) {
|
|
567
|
+
configData = void 0;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return configData ?? {};
|
|
571
|
+
} catch (_err) {
|
|
572
|
+
return {};
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
var configPath = getStringValue(args.config);
|
|
576
|
+
var vltConfig = loadVltConfig(configPath);
|
|
577
|
+
var registryConfig = vltConfig.registry ?? {};
|
|
578
|
+
var PORT2 = getNumberValue(
|
|
579
|
+
args.port,
|
|
580
|
+
registryConfig.port ?? vltConfig.port ?? defaults.port
|
|
581
|
+
);
|
|
582
|
+
var TELEMETRY = getBooleanValue(
|
|
583
|
+
args.telemetry,
|
|
584
|
+
registryConfig.telemetry ?? vltConfig.telemetry ?? defaults.telemetry
|
|
585
|
+
);
|
|
586
|
+
var DAEMON = getBooleanValue(
|
|
587
|
+
args.daemon,
|
|
588
|
+
registryConfig.daemon ?? vltConfig.daemon ?? defaults.daemon
|
|
589
|
+
);
|
|
590
|
+
var DEBUG = getBooleanValue(
|
|
591
|
+
args.debug,
|
|
592
|
+
registryConfig.debug ?? vltConfig.debug ?? defaults.debug
|
|
593
|
+
);
|
|
594
|
+
var ENV = getStringValue(args.env, "dev");
|
|
595
|
+
var DRY_RUN = getBooleanValue(
|
|
596
|
+
args["dry-run"],
|
|
597
|
+
defaults["dry-run"] ?? false
|
|
598
|
+
);
|
|
599
|
+
var DB_NAME_OVERRIDE = getStringValue(args["db-name"]);
|
|
600
|
+
var BUCKET_NAME_OVERRIDE = getStringValue(args["bucket-name"]);
|
|
601
|
+
var QUEUE_NAME_OVERRIDE = getStringValue(args["queue-name"]);
|
|
602
|
+
function printUsage() {
|
|
603
|
+
console.log(usage);
|
|
604
|
+
}
|
|
605
|
+
async function deployToCloudflare() {
|
|
606
|
+
const deployConfig = registryConfig.deploy;
|
|
607
|
+
const envConfig = deployConfig?.environments?.[ENV ?? "dev"] ?? {};
|
|
608
|
+
const databaseName = DB_NAME_OVERRIDE ?? envConfig.databaseName ?? "vsr-database";
|
|
609
|
+
const bucketName = BUCKET_NAME_OVERRIDE ?? envConfig.bucketName ?? "vsr-bucket";
|
|
610
|
+
const queueName = QUEUE_NAME_OVERRIDE ?? envConfig.queueName ?? "cache-refresh-queue";
|
|
611
|
+
const sentryConfig = envConfig.sentry ?? deployConfig?.sentry ?? {};
|
|
612
|
+
const sentryDsn = sentryConfig.dsn ?? "https://909b085eb764c00250ad312660c2fdf1@o4506397716054016.ingest.us.sentry.io/4509492612300800";
|
|
613
|
+
const sentryEnv = sentryConfig.environment ?? ENV;
|
|
614
|
+
const wranglerArgs = [
|
|
615
|
+
"deploy",
|
|
616
|
+
indexPath,
|
|
617
|
+
"--config",
|
|
618
|
+
wranglerConfigPath,
|
|
619
|
+
"--name",
|
|
620
|
+
`vsr-${ENV}`,
|
|
621
|
+
"--compatibility-date",
|
|
622
|
+
"2024-09-23",
|
|
623
|
+
"--var",
|
|
624
|
+
`SENTRY_DSN:${sentryDsn}`,
|
|
625
|
+
"--var",
|
|
626
|
+
`SENTRY_ENVIRONMENT:${sentryEnv}`,
|
|
627
|
+
"--var",
|
|
628
|
+
`ARG_DEBUG:${DEBUG}`,
|
|
629
|
+
"--var",
|
|
630
|
+
`ARG_TELEMETRY:${TELEMETRY}`,
|
|
631
|
+
"--var",
|
|
632
|
+
`ARG_DAEMON:${DAEMON}`
|
|
633
|
+
];
|
|
634
|
+
wranglerArgs.push("--d1", `DB=${databaseName}`);
|
|
635
|
+
wranglerArgs.push("--r2", `BUCKET=${bucketName}`);
|
|
636
|
+
wranglerArgs.push(
|
|
637
|
+
"--queue-producer",
|
|
638
|
+
`CACHE_REFRESH_QUEUE=${queueName}`
|
|
639
|
+
);
|
|
640
|
+
wranglerArgs.push("--queue-consumer", queueName);
|
|
641
|
+
if (envConfig.vars) {
|
|
642
|
+
for (const [key, value] of Object.entries(envConfig.vars)) {
|
|
643
|
+
wranglerArgs.push("--var", `${key}:${value}`);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
if (DRY_RUN) {
|
|
647
|
+
wranglerArgs.push("--dry-run");
|
|
648
|
+
console.log(
|
|
649
|
+
"\u{1F50D} Dry run - would execute:",
|
|
650
|
+
wranglerBin,
|
|
651
|
+
wranglerArgs.join(" ")
|
|
652
|
+
);
|
|
653
|
+
console.log("\n\u{1F4CB} Deployment configuration:");
|
|
654
|
+
console.log(` Environment: ${ENV}`);
|
|
655
|
+
console.log(` Database: ${databaseName}`);
|
|
656
|
+
console.log(` Bucket: ${bucketName}`);
|
|
657
|
+
console.log(` Queue: ${queueName}`);
|
|
658
|
+
console.log(` Sentry DSN: ${sentryDsn}`);
|
|
659
|
+
console.log(` Sentry Environment: ${sentryEnv}`);
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
console.log(`\u{1F680} Deploying VSR to ${ENV} environment...`);
|
|
663
|
+
return new Promise((resolve, reject) => {
|
|
664
|
+
const deployProcess = spawn(wranglerBin, wranglerArgs, {
|
|
665
|
+
cwd: registryRoot,
|
|
666
|
+
stdio: "inherit"
|
|
667
|
+
});
|
|
668
|
+
deployProcess.on("close", (code) => {
|
|
669
|
+
if (code === 0) {
|
|
670
|
+
console.log(`\u2705 Successfully deployed VSR to ${ENV}`);
|
|
671
|
+
resolve();
|
|
672
|
+
} else {
|
|
673
|
+
reject(new Error(`Deployment failed with exit code ${code}`));
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
deployProcess.on("error", (error) => {
|
|
677
|
+
reject(
|
|
678
|
+
new Error(`Failed to start deployment: ${error.message}`)
|
|
679
|
+
);
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
if (args.help) {
|
|
684
|
+
printUsage();
|
|
685
|
+
process.exit(0);
|
|
686
|
+
}
|
|
687
|
+
if (!["dev", "deploy"].includes(command)) {
|
|
688
|
+
console.error(`\u274C Unknown command: ${command}`);
|
|
689
|
+
printUsage();
|
|
690
|
+
process.exit(1);
|
|
691
|
+
}
|
|
692
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
693
|
+
var __dirname = path.dirname(__filename);
|
|
694
|
+
var demo = path.resolve(__dirname, "./demo");
|
|
695
|
+
var require2 = createRequire(import.meta.url);
|
|
696
|
+
var registryRoot = path.resolve(__dirname, "../../");
|
|
697
|
+
var indexPath = path.resolve(registryRoot, "dist/index.js");
|
|
698
|
+
var wranglerConfigPath = path.resolve(registryRoot, "wrangler.json");
|
|
699
|
+
var wranglerPkgPath = require2.resolve("wrangler/package.json");
|
|
700
|
+
var wranglerRelBinPath = JSON.parse(readFileSync(wranglerPkgPath, "utf8")).bin.wrangler;
|
|
701
|
+
var wranglerBinPath = require2.resolve(
|
|
702
|
+
path.join("wrangler", wranglerRelBinPath)
|
|
703
|
+
);
|
|
704
|
+
var wranglerBin = existsSync(wranglerBinPath) ? wranglerBinPath : "wrangler";
|
|
705
|
+
var serverOptions = {
|
|
706
|
+
scurry: new PathScurry(demo),
|
|
707
|
+
projectRoot: demo,
|
|
708
|
+
packageJson: new PackageJson(),
|
|
709
|
+
catalog: {},
|
|
710
|
+
catalogs: {},
|
|
711
|
+
registry: "https://registry.npmjs.org/",
|
|
712
|
+
registries: {},
|
|
713
|
+
"scope-registries": {},
|
|
714
|
+
"git-hosts": {},
|
|
715
|
+
"git-host-archives": {}
|
|
716
|
+
};
|
|
717
|
+
void (async () => {
|
|
718
|
+
try {
|
|
719
|
+
if (command === "deploy") {
|
|
720
|
+
await deployToCloudflare();
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
if (DAEMON) {
|
|
724
|
+
const originalArgv = process.argv.slice();
|
|
725
|
+
process.argv = [process.argv[0], process.argv[1]];
|
|
726
|
+
try {
|
|
727
|
+
const server = createServer({
|
|
728
|
+
...serverOptions,
|
|
729
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
730
|
+
packageInfo: new PackageInfoClient()
|
|
731
|
+
});
|
|
732
|
+
await server.start({
|
|
733
|
+
port: DAEMON_PORT
|
|
734
|
+
});
|
|
735
|
+
console.log(`Daemon: ${DAEMON_URL}`);
|
|
736
|
+
} finally {
|
|
737
|
+
process.argv = originalArgv;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
console.log(`VSR: ${URL}`);
|
|
741
|
+
const { stdout, stderr } = spawn(
|
|
742
|
+
wranglerBin,
|
|
743
|
+
[
|
|
744
|
+
"dev",
|
|
745
|
+
indexPath,
|
|
746
|
+
"--config",
|
|
747
|
+
wranglerConfigPath,
|
|
748
|
+
"--local",
|
|
749
|
+
"--persist-to=local-store",
|
|
750
|
+
"--no-remote",
|
|
751
|
+
`--port=${PORT2}`,
|
|
752
|
+
`--var=ARG_DEBUG:${DEBUG}`,
|
|
753
|
+
`--var=ARG_TELEMETRY:${TELEMETRY}`,
|
|
754
|
+
`--var=ARG_DAEMON:${DAEMON}`
|
|
755
|
+
],
|
|
756
|
+
{
|
|
757
|
+
cwd: registryRoot
|
|
758
|
+
// Set working directory to registry root
|
|
759
|
+
}
|
|
760
|
+
);
|
|
761
|
+
if (DEBUG) {
|
|
762
|
+
stdout.on("data", (data) => {
|
|
763
|
+
console.log(data.toString());
|
|
764
|
+
});
|
|
765
|
+
stderr.on("data", (data) => {
|
|
766
|
+
console.error(data.toString());
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
} catch (error) {
|
|
770
|
+
console.error("Failed to start:", error);
|
|
771
|
+
process.exit(1);
|
|
772
|
+
}
|
|
773
|
+
})();
|