@stacksjs/registry 0.10.35 → 0.10.40
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/README.md +5 -1
- package/dist/index.js +13 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Pantry package registry backend. A simple, fast package registry that works with the Pantry CLI.
|
|
4
4
|
|
|
5
|
+
The authoritative route, authentication, integrity, storage, failure, operations,
|
|
6
|
+
and test contract is [docs/registry.md](../../docs/registry.md). CI verifies its
|
|
7
|
+
critical claims directly against the route handlers.
|
|
8
|
+
|
|
5
9
|
## Features
|
|
6
10
|
|
|
7
11
|
- **npm-compatible API** - Works with the Pantry CLI out of the box
|
|
@@ -9,7 +13,7 @@ Pantry package registry backend. A simple, fast package registry that works with
|
|
|
9
13
|
- **Zig package support** - Host Zig packages with content-addressed hashing
|
|
10
14
|
- **S3 storage** - Tarball storage via S3 (or local filesystem for development)
|
|
11
15
|
- **Analytics** - Track download counts and package statistics
|
|
12
|
-
- **
|
|
16
|
+
- **Portable metadata** - Local/in-memory stores for development and an object-storage snapshot for production
|
|
13
17
|
- **Zero config** - Works out of the box for local development
|
|
14
18
|
|
|
15
19
|
## Quick Start
|
package/dist/index.js
CHANGED
|
@@ -41014,22 +41014,25 @@ async function handleZigRoutes(path, req, url, storage, baseUrl, corsHeaders, an
|
|
|
41014
41014
|
}
|
|
41015
41015
|
return null;
|
|
41016
41016
|
}
|
|
41017
|
-
|
|
41017
|
+
function getRegistryToken() {
|
|
41018
|
+
return process.env.PANTRY_REGISTRY_TOKEN || process.env.PANTRY_TOKEN;
|
|
41019
|
+
}
|
|
41018
41020
|
function validateToken(authHeader) {
|
|
41019
|
-
|
|
41021
|
+
const registryToken = getRegistryToken();
|
|
41022
|
+
if (!registryToken) {
|
|
41020
41023
|
return { valid: false, error: "Server misconfigured \u2014 no registry token set" };
|
|
41021
41024
|
}
|
|
41022
41025
|
if (!authHeader) {
|
|
41023
41026
|
return { valid: false, error: "Authorization required" };
|
|
41024
41027
|
}
|
|
41025
41028
|
const token = authHeader.startsWith("Bearer ") ? authHeader.slice(7) : authHeader;
|
|
41026
|
-
const maxLen = Math.max(token.length,
|
|
41029
|
+
const maxLen = Math.max(token.length, registryToken.length);
|
|
41027
41030
|
const tokenBuf = Buffer.alloc(maxLen);
|
|
41028
41031
|
const legacyBuf = Buffer.alloc(maxLen);
|
|
41029
41032
|
Buffer.from(token).copy(tokenBuf);
|
|
41030
|
-
Buffer.from(
|
|
41033
|
+
Buffer.from(registryToken).copy(legacyBuf);
|
|
41031
41034
|
const crypto5 = __require("crypto");
|
|
41032
|
-
if (!crypto5.timingSafeEqual(tokenBuf, legacyBuf) || token.length !==
|
|
41035
|
+
if (!crypto5.timingSafeEqual(tokenBuf, legacyBuf) || token.length !== registryToken.length) {
|
|
41033
41036
|
return { valid: false, error: "Invalid token" };
|
|
41034
41037
|
}
|
|
41035
41038
|
return { valid: true };
|
|
@@ -41627,11 +41630,11 @@ async function handlePhpRoutes(path, req, url, storage, baseUrl, corsHeaders, an
|
|
|
41627
41630
|
}
|
|
41628
41631
|
return null;
|
|
41629
41632
|
}
|
|
41630
|
-
function
|
|
41633
|
+
function getRegistryToken2() {
|
|
41631
41634
|
return process.env.PANTRY_REGISTRY_TOKEN || process.env.PANTRY_TOKEN;
|
|
41632
41635
|
}
|
|
41633
41636
|
function validateToken2(authHeader) {
|
|
41634
|
-
const registryToken =
|
|
41637
|
+
const registryToken = getRegistryToken2();
|
|
41635
41638
|
if (!registryToken) {
|
|
41636
41639
|
return { valid: false, error: "Server misconfigured \u2014 no registry token set" };
|
|
41637
41640
|
}
|
|
@@ -101896,10 +101899,10 @@ async function handleAnalyticsEvent(req, analytics, corsHeaders) {
|
|
|
101896
101899
|
return Response.json({ error: "Invalid JSON body" }, { status: 400, headers: corsHeaders });
|
|
101897
101900
|
}
|
|
101898
101901
|
}
|
|
101899
|
-
function
|
|
101902
|
+
function getRegistryToken3() {
|
|
101900
101903
|
return process.env.PANTRY_REGISTRY_TOKEN || process.env.PANTRY_TOKEN;
|
|
101901
101904
|
}
|
|
101902
|
-
if (!
|
|
101905
|
+
if (!getRegistryToken3()) {
|
|
101903
101906
|
console.warn("WARNING: PANTRY_REGISTRY_TOKEN or PANTRY_TOKEN must be set \u2014 publish/admin endpoints will reject all requests");
|
|
101904
101907
|
}
|
|
101905
101908
|
var _authService;
|
|
@@ -101913,7 +101916,7 @@ async function validateToken3(authHeader) {
|
|
|
101913
101916
|
return { valid: false, error: "Authorization required" };
|
|
101914
101917
|
}
|
|
101915
101918
|
const token = authHeader.startsWith("Bearer ") ? authHeader.slice(7) : authHeader;
|
|
101916
|
-
const registryToken =
|
|
101919
|
+
const registryToken = getRegistryToken3();
|
|
101917
101920
|
if (_authService && isUserApiToken(token)) {
|
|
101918
101921
|
const result = await _authService.validatePublishToken(token, registryToken ?? "");
|
|
101919
101922
|
return result;
|