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/cloudflare": "npm:@apiclient.xyz/cloudflare@6.4.3",
"@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"
},
"compilerOptions": {

View File

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