fix(oci): Preserve raw manifest bytes for digest calculation and handle string/JSON manifest bodies in OCI registry
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-11-25 - 2.1.1 - fix(oci)
|
||||||
|
Preserve raw manifest bytes for digest calculation and handle string/JSON manifest bodies in OCI registry
|
||||||
|
|
||||||
|
- Preserve the exact bytes of the manifest payload when computing the sha256 digest to comply with the OCI spec and avoid mismatches caused by re-serialization.
|
||||||
|
- Accept string request bodies (converted using UTF-8) and treat already-parsed JSON objects by re-serializing as a fallback.
|
||||||
|
- Keep existing content-type fallback logic while ensuring accurate digest calculation prior to storing manifests.
|
||||||
|
|
||||||
## 2025-11-25 - 2.1.0 - feat(oci)
|
## 2025-11-25 - 2.1.0 - feat(oci)
|
||||||
Support configurable OCI token realm/service and centralize unauthorized responses
|
Support configurable OCI token realm/service and centralize unauthorized responses
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartregistry',
|
name: '@push.rocks/smartregistry',
|
||||||
version: '2.1.0',
|
version: '2.1.1',
|
||||||
description: 'A composable TypeScript library implementing OCI, NPM, Maven, Cargo, Composer, PyPI, and RubyGems registries for building unified container and package registries'
|
description: 'A composable TypeScript library implementing OCI, NPM, Maven, Cargo, Composer, PyPI, and RubyGems registries for building unified container and package registries'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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';
|
const contentType = headers?.['content-type'] || headers?.['Content-Type'] || 'application/vnd.oci.image.manifest.v1+json';
|
||||||
|
|
||||||
// Calculate manifest digest
|
// Calculate manifest digest
|
||||||
|
|||||||
Reference in New Issue
Block a user