@vltpkg/vsr 0.2.0
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/.editorconfig +13 -0
- package/.prettierrc +7 -0
- package/CONTRIBUTING.md +228 -0
- package/LICENSE.md +110 -0
- package/README.md +373 -0
- package/bin/vsr.ts +29 -0
- package/config.ts +124 -0
- package/debug-npm.js +19 -0
- package/drizzle.config.js +33 -0
- package/package.json +80 -0
- package/pnpm-workspace.yaml +5 -0
- package/src/api.ts +2246 -0
- package/src/assets/public/images/bg.png +0 -0
- package/src/assets/public/images/clients/logo-bun.png +0 -0
- package/src/assets/public/images/clients/logo-deno.png +0 -0
- package/src/assets/public/images/clients/logo-npm.png +0 -0
- package/src/assets/public/images/clients/logo-pnpm.png +0 -0
- package/src/assets/public/images/clients/logo-vlt.png +0 -0
- package/src/assets/public/images/clients/logo-yarn.png +0 -0
- package/src/assets/public/images/favicon/apple-touch-icon.png +0 -0
- package/src/assets/public/images/favicon/favicon-96x96.png +0 -0
- package/src/assets/public/images/favicon/favicon.ico +0 -0
- package/src/assets/public/images/favicon/favicon.svg +3 -0
- package/src/assets/public/images/favicon/site.webmanifest +21 -0
- package/src/assets/public/images/favicon/web-app-manifest-192x192.png +0 -0
- package/src/assets/public/images/favicon/web-app-manifest-512x512.png +0 -0
- package/src/assets/public/styles/styles.css +219 -0
- package/src/db/client.ts +544 -0
- package/src/db/migrations/0000_faulty_ricochet.sql +14 -0
- package/src/db/migrations/0000_initial.sql +29 -0
- package/src/db/migrations/0001_uuid_validation.sql +35 -0
- package/src/db/migrations/0001_wealthy_magdalene.sql +7 -0
- package/src/db/migrations/drop.sql +3 -0
- package/src/db/migrations/meta/0000_snapshot.json +104 -0
- package/src/db/migrations/meta/0001_snapshot.json +155 -0
- package/src/db/migrations/meta/_journal.json +20 -0
- package/src/db/schema.ts +41 -0
- package/src/index.ts +709 -0
- package/src/routes/access.ts +263 -0
- package/src/routes/auth.ts +93 -0
- package/src/routes/index.ts +135 -0
- package/src/routes/packages.ts +924 -0
- package/src/routes/search.ts +50 -0
- package/src/routes/static.ts +53 -0
- package/src/routes/tokens.ts +102 -0
- package/src/routes/users.ts +14 -0
- package/src/utils/auth.ts +145 -0
- package/src/utils/cache.ts +466 -0
- package/src/utils/database.ts +44 -0
- package/src/utils/packages.ts +337 -0
- package/src/utils/response.ts +100 -0
- package/src/utils/routes.ts +47 -0
- package/src/utils/spa.ts +14 -0
- package/src/utils/tracing.ts +63 -0
- package/src/utils/upstream.ts +131 -0
- package/test/README.md +91 -0
- package/test/access.test.js +760 -0
- package/test/cloudflare-waituntil.test.js +141 -0
- package/test/db.test.js +447 -0
- package/test/dist-tag.test.js +415 -0
- package/test/e2e.test.js +904 -0
- package/test/hono-context.test.js +250 -0
- package/test/integrity-validation.test.js +183 -0
- package/test/json-response.test.js +76 -0
- package/test/manifest-slimming.test.js +449 -0
- package/test/packument-consistency.test.js +351 -0
- package/test/packument-version-range.test.js +144 -0
- package/test/performance.test.js +162 -0
- package/test/route-with-waituntil.test.js +298 -0
- package/test/run-tests.js +151 -0
- package/test/setup-cache-tests.js +190 -0
- package/test/setup.js +64 -0
- package/test/stale-while-revalidate.test.js +273 -0
- package/test/static-assets.test.js +85 -0
- package/test/upstream-routing.test.js +86 -0
- package/test/utils/test-helpers.js +84 -0
- package/test/waituntil-correct.test.js +208 -0
- package/test/waituntil-demo.test.js +138 -0
- package/test/waituntil-readme.md +113 -0
- package/tsconfig.json +37 -0
- package/types.ts +446 -0
- package/vitest.config.js +95 -0
- package/wrangler.json +58 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "6",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"id": "d78cc389-7e78-46bc-969b-7a2828cc2e07",
|
|
5
|
+
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
6
|
+
"tables": {
|
|
7
|
+
"packages": {
|
|
8
|
+
"name": "packages",
|
|
9
|
+
"columns": {
|
|
10
|
+
"name": {
|
|
11
|
+
"name": "name",
|
|
12
|
+
"type": "text",
|
|
13
|
+
"primaryKey": true,
|
|
14
|
+
"notNull": true,
|
|
15
|
+
"autoincrement": false
|
|
16
|
+
},
|
|
17
|
+
"tags": {
|
|
18
|
+
"name": "tags",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": false,
|
|
22
|
+
"autoincrement": false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"indexes": {},
|
|
26
|
+
"foreignKeys": {},
|
|
27
|
+
"compositePrimaryKeys": {},
|
|
28
|
+
"uniqueConstraints": {},
|
|
29
|
+
"checkConstraints": {}
|
|
30
|
+
},
|
|
31
|
+
"tokens": {
|
|
32
|
+
"name": "tokens",
|
|
33
|
+
"columns": {
|
|
34
|
+
"token": {
|
|
35
|
+
"name": "token",
|
|
36
|
+
"type": "text",
|
|
37
|
+
"primaryKey": true,
|
|
38
|
+
"notNull": true,
|
|
39
|
+
"autoincrement": false
|
|
40
|
+
},
|
|
41
|
+
"uuid": {
|
|
42
|
+
"name": "uuid",
|
|
43
|
+
"type": "text",
|
|
44
|
+
"primaryKey": false,
|
|
45
|
+
"notNull": true,
|
|
46
|
+
"autoincrement": false
|
|
47
|
+
},
|
|
48
|
+
"scope": {
|
|
49
|
+
"name": "scope",
|
|
50
|
+
"type": "text",
|
|
51
|
+
"primaryKey": false,
|
|
52
|
+
"notNull": false,
|
|
53
|
+
"autoincrement": false
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"indexes": {},
|
|
57
|
+
"foreignKeys": {},
|
|
58
|
+
"compositePrimaryKeys": {},
|
|
59
|
+
"uniqueConstraints": {},
|
|
60
|
+
"checkConstraints": {}
|
|
61
|
+
},
|
|
62
|
+
"versions": {
|
|
63
|
+
"name": "versions",
|
|
64
|
+
"columns": {
|
|
65
|
+
"spec": {
|
|
66
|
+
"name": "spec",
|
|
67
|
+
"type": "text",
|
|
68
|
+
"primaryKey": true,
|
|
69
|
+
"notNull": true,
|
|
70
|
+
"autoincrement": false
|
|
71
|
+
},
|
|
72
|
+
"manifest": {
|
|
73
|
+
"name": "manifest",
|
|
74
|
+
"type": "text",
|
|
75
|
+
"primaryKey": false,
|
|
76
|
+
"notNull": false,
|
|
77
|
+
"autoincrement": false
|
|
78
|
+
},
|
|
79
|
+
"published_at": {
|
|
80
|
+
"name": "published_at",
|
|
81
|
+
"type": "text",
|
|
82
|
+
"primaryKey": false,
|
|
83
|
+
"notNull": false,
|
|
84
|
+
"autoincrement": false
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"indexes": {},
|
|
88
|
+
"foreignKeys": {},
|
|
89
|
+
"compositePrimaryKeys": {},
|
|
90
|
+
"uniqueConstraints": {},
|
|
91
|
+
"checkConstraints": {}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"views": {},
|
|
95
|
+
"enums": {},
|
|
96
|
+
"_meta": {
|
|
97
|
+
"schemas": {},
|
|
98
|
+
"tables": {},
|
|
99
|
+
"columns": {}
|
|
100
|
+
},
|
|
101
|
+
"internal": {
|
|
102
|
+
"indexes": {}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "6",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"id": "a961f197-33f4-4c03-901c-0aa1c1f835b6",
|
|
5
|
+
"prevId": "d78cc389-7e78-46bc-969b-7a2828cc2e07",
|
|
6
|
+
"tables": {
|
|
7
|
+
"packages": {
|
|
8
|
+
"name": "packages",
|
|
9
|
+
"columns": {
|
|
10
|
+
"name": {
|
|
11
|
+
"name": "name",
|
|
12
|
+
"type": "text",
|
|
13
|
+
"primaryKey": true,
|
|
14
|
+
"notNull": true,
|
|
15
|
+
"autoincrement": false
|
|
16
|
+
},
|
|
17
|
+
"tags": {
|
|
18
|
+
"name": "tags",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": false,
|
|
22
|
+
"autoincrement": false
|
|
23
|
+
},
|
|
24
|
+
"last_updated": {
|
|
25
|
+
"name": "last_updated",
|
|
26
|
+
"type": "text",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": false,
|
|
29
|
+
"autoincrement": false
|
|
30
|
+
},
|
|
31
|
+
"origin": {
|
|
32
|
+
"name": "origin",
|
|
33
|
+
"type": "text",
|
|
34
|
+
"primaryKey": false,
|
|
35
|
+
"notNull": true,
|
|
36
|
+
"autoincrement": false,
|
|
37
|
+
"default": "'local'"
|
|
38
|
+
},
|
|
39
|
+
"upstream": {
|
|
40
|
+
"name": "upstream",
|
|
41
|
+
"type": "text",
|
|
42
|
+
"primaryKey": false,
|
|
43
|
+
"notNull": false,
|
|
44
|
+
"autoincrement": false
|
|
45
|
+
},
|
|
46
|
+
"cached_at": {
|
|
47
|
+
"name": "cached_at",
|
|
48
|
+
"type": "text",
|
|
49
|
+
"primaryKey": false,
|
|
50
|
+
"notNull": false,
|
|
51
|
+
"autoincrement": false
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"indexes": {},
|
|
55
|
+
"foreignKeys": {},
|
|
56
|
+
"compositePrimaryKeys": {},
|
|
57
|
+
"uniqueConstraints": {},
|
|
58
|
+
"checkConstraints": {}
|
|
59
|
+
},
|
|
60
|
+
"tokens": {
|
|
61
|
+
"name": "tokens",
|
|
62
|
+
"columns": {
|
|
63
|
+
"token": {
|
|
64
|
+
"name": "token",
|
|
65
|
+
"type": "text",
|
|
66
|
+
"primaryKey": true,
|
|
67
|
+
"notNull": true,
|
|
68
|
+
"autoincrement": false
|
|
69
|
+
},
|
|
70
|
+
"uuid": {
|
|
71
|
+
"name": "uuid",
|
|
72
|
+
"type": "text",
|
|
73
|
+
"primaryKey": false,
|
|
74
|
+
"notNull": true,
|
|
75
|
+
"autoincrement": false
|
|
76
|
+
},
|
|
77
|
+
"scope": {
|
|
78
|
+
"name": "scope",
|
|
79
|
+
"type": "text",
|
|
80
|
+
"primaryKey": false,
|
|
81
|
+
"notNull": false,
|
|
82
|
+
"autoincrement": false
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"indexes": {},
|
|
86
|
+
"foreignKeys": {},
|
|
87
|
+
"compositePrimaryKeys": {},
|
|
88
|
+
"uniqueConstraints": {},
|
|
89
|
+
"checkConstraints": {}
|
|
90
|
+
},
|
|
91
|
+
"versions": {
|
|
92
|
+
"name": "versions",
|
|
93
|
+
"columns": {
|
|
94
|
+
"spec": {
|
|
95
|
+
"name": "spec",
|
|
96
|
+
"type": "text",
|
|
97
|
+
"primaryKey": true,
|
|
98
|
+
"notNull": true,
|
|
99
|
+
"autoincrement": false
|
|
100
|
+
},
|
|
101
|
+
"manifest": {
|
|
102
|
+
"name": "manifest",
|
|
103
|
+
"type": "text",
|
|
104
|
+
"primaryKey": false,
|
|
105
|
+
"notNull": false,
|
|
106
|
+
"autoincrement": false
|
|
107
|
+
},
|
|
108
|
+
"published_at": {
|
|
109
|
+
"name": "published_at",
|
|
110
|
+
"type": "text",
|
|
111
|
+
"primaryKey": false,
|
|
112
|
+
"notNull": false,
|
|
113
|
+
"autoincrement": false
|
|
114
|
+
},
|
|
115
|
+
"origin": {
|
|
116
|
+
"name": "origin",
|
|
117
|
+
"type": "text",
|
|
118
|
+
"primaryKey": false,
|
|
119
|
+
"notNull": true,
|
|
120
|
+
"autoincrement": false,
|
|
121
|
+
"default": "'local'"
|
|
122
|
+
},
|
|
123
|
+
"upstream": {
|
|
124
|
+
"name": "upstream",
|
|
125
|
+
"type": "text",
|
|
126
|
+
"primaryKey": false,
|
|
127
|
+
"notNull": false,
|
|
128
|
+
"autoincrement": false
|
|
129
|
+
},
|
|
130
|
+
"cached_at": {
|
|
131
|
+
"name": "cached_at",
|
|
132
|
+
"type": "text",
|
|
133
|
+
"primaryKey": false,
|
|
134
|
+
"notNull": false,
|
|
135
|
+
"autoincrement": false
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"indexes": {},
|
|
139
|
+
"foreignKeys": {},
|
|
140
|
+
"compositePrimaryKeys": {},
|
|
141
|
+
"uniqueConstraints": {},
|
|
142
|
+
"checkConstraints": {}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"views": {},
|
|
146
|
+
"enums": {},
|
|
147
|
+
"_meta": {
|
|
148
|
+
"schemas": {},
|
|
149
|
+
"tables": {},
|
|
150
|
+
"columns": {}
|
|
151
|
+
},
|
|
152
|
+
"internal": {
|
|
153
|
+
"indexes": {}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "7",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"entries": [
|
|
5
|
+
{
|
|
6
|
+
"idx": 0,
|
|
7
|
+
"version": "6",
|
|
8
|
+
"when": 1742933058715,
|
|
9
|
+
"tag": "0000_faulty_ricochet",
|
|
10
|
+
"breakpoints": true
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"idx": 1,
|
|
14
|
+
"version": "6",
|
|
15
|
+
"when": 1750313789237,
|
|
16
|
+
"tag": "0001_wealthy_magdalene",
|
|
17
|
+
"breakpoints": true
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
package/src/db/schema.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { sqliteTable, text, integer, primaryKey } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
|
|
3
|
+
// Define the packages table
|
|
4
|
+
export const packages = sqliteTable('packages', {
|
|
5
|
+
name: text('name').primaryKey(),
|
|
6
|
+
tags: text('tags').$type<string>(), // JSON stored as string
|
|
7
|
+
lastUpdated: text('last_updated'), // Timestamp for when this package was last updated
|
|
8
|
+
origin: text('origin').notNull().default('local'), // 'local' or 'upstream'
|
|
9
|
+
upstream: text('upstream'), // Name of upstream registry (null for local packages)
|
|
10
|
+
cachedAt: text('cached_at'), // When this package was cached from upstream
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// Define the tokens table
|
|
14
|
+
export const tokens = sqliteTable('tokens', {
|
|
15
|
+
token: text('token').primaryKey(),
|
|
16
|
+
uuid: text('uuid').notNull(),
|
|
17
|
+
scope: text('scope').$type<string>(), // JSON stored as string
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Define the versions table
|
|
21
|
+
export const versions = sqliteTable('versions', {
|
|
22
|
+
spec: text('spec').primaryKey(),
|
|
23
|
+
manifest: text('manifest').$type<string>(), // JSON stored as string
|
|
24
|
+
publishedAt: text('published_at'),
|
|
25
|
+
origin: text('origin').notNull().default('local'), // 'local' or 'upstream'
|
|
26
|
+
upstream: text('upstream'), // Name of upstream registry (null for local packages)
|
|
27
|
+
cachedAt: text('cached_at'), // When this version was cached from upstream
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Default admin token
|
|
31
|
+
export const defaultAdminToken = {
|
|
32
|
+
token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
33
|
+
uuid: 'admin',
|
|
34
|
+
scope: JSON.stringify([{
|
|
35
|
+
values: ['*'],
|
|
36
|
+
types: {
|
|
37
|
+
pkg: { read: true, write: true },
|
|
38
|
+
user: { read: true, write: true },
|
|
39
|
+
},
|
|
40
|
+
}]),
|
|
41
|
+
} as const;
|