feat: Update smartregistry integration to support Uint8Array for body handling

This commit is contained in:
2025-11-25 22:25:41 +00:00
parent 5cf9c72dd4
commit 9d58971983
2 changed files with 5 additions and 7 deletions

View File

@@ -20,7 +20,7 @@
"@apiclient.xyz/docker": "npm:@apiclient.xyz/docker@^5.1.0", "@apiclient.xyz/docker": "npm:@apiclient.xyz/docker@^5.1.0",
"@apiclient.xyz/cloudflare": "npm:@apiclient.xyz/cloudflare@6.4.3", "@apiclient.xyz/cloudflare": "npm:@apiclient.xyz/cloudflare@6.4.3",
"@push.rocks/smartacme": "npm:@push.rocks/smartacme@^8.0.0", "@push.rocks/smartacme": "npm:@push.rocks/smartacme@^8.0.0",
"@push.rocks/smartregistry": "npm:@push.rocks/smartregistry@^2.1.2", "@push.rocks/smartregistry": "npm:@push.rocks/smartregistry@^2.2.0",
"@push.rocks/smarts3": "npm:@push.rocks/smarts3@^5.1.0" "@push.rocks/smarts3": "npm:@push.rocks/smarts3@^5.1.0"
}, },
"compilerOptions": { "compilerOptions": {

View File

@@ -118,18 +118,16 @@ export class RegistryManager {
}); });
// Read body for non-GET requests // Read body for non-GET requests
// IMPORTANT: smartregistry expects Buffer (not Uint8Array) for proper digest calculation // smartregistry v2.2.0 handles Uint8Array natively for proper digest calculation
// Buffer.isBuffer(Uint8Array) returns false, causing JSON.stringify which corrupts the data let body: Uint8Array | undefined;
let body: Buffer | undefined;
if (req.method !== 'GET' && req.method !== 'HEAD') { if (req.method !== 'GET' && req.method !== 'HEAD') {
const bodyData = await req.arrayBuffer(); const bodyData = await req.arrayBuffer();
if (bodyData.byteLength > 0) { if (bodyData.byteLength > 0) {
body = Buffer.from(bodyData); body = new Uint8Array(bodyData);
} }
} }
// smartregistry v2.0.0 handles JWT tokens natively - no decoding needed // smartregistry v2.2.0 handles JWT tokens natively and supports Uint8Array body
// Pass rawBody for content-addressable operations (manifest push needs exact bytes for digest)
const context = { const context = {
method: req.method, method: req.method,
path: url.pathname, path: url.pathname,