fix(oci): Preserve raw manifest bytes for digest calculation and handle string/JSON manifest bodies in OCI registry
This commit is contained in:
@@ -379,7 +379,18 @@ export class OciRegistry extends BaseRegistry {
|
||||
};
|
||||
}
|
||||
|
||||
const manifestData = Buffer.isBuffer(body) ? body : Buffer.from(JSON.stringify(body));
|
||||
// Preserve raw bytes for accurate digest calculation
|
||||
// Per OCI spec, digest must match the exact bytes sent by client
|
||||
let manifestData: Buffer;
|
||||
if (Buffer.isBuffer(body)) {
|
||||
manifestData = body;
|
||||
} else if (typeof body === 'string') {
|
||||
// String body - convert directly without JSON transformation
|
||||
manifestData = Buffer.from(body, 'utf-8');
|
||||
} else {
|
||||
// Body was already parsed as JSON object - re-serialize as fallback
|
||||
manifestData = Buffer.from(JSON.stringify(body));
|
||||
}
|
||||
const contentType = headers?.['content-type'] || headers?.['Content-Type'] || 'application/vnd.oci.image.manifest.v1+json';
|
||||
|
||||
// Calculate manifest digest
|
||||
|
||||
Reference in New Issue
Block a user