Socket
Socket
Sign inDemoInstall

@snyk/docker-registry-v2-client

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@snyk/docker-registry-v2-client - npm Package Compare versions

Comparing version 2.15.0 to 2.16.0

15

dist/get-manifest.d.ts

@@ -6,3 +6,3 @@ import * as types from "./types";

* @param repo the requested image repository.
* @param tag the manifest tag or digest value
* @param imageReference the manifest tag or digest value
* @param username optional, username to be used for basic auth.

@@ -15,3 +15,16 @@ * @param password optional, password to be used for basic auth.

*/
export declare function getAttestationManifest(registryBase: string, repo: string, imageReference: string, username?: string, password?: string, options?: any, platform?: types.Platform, callChainObserver?: types.CallChainObserver): Promise<types.ImageManifest>;
/**
* A request to get image manifest by tag or digest
* @param registryBase the hostname (and optionally base path) from which to get the manifest.
* @param repo the requested image repository.
* @param imageReference the manifest tag or digest value
* @param username optional, username to be used for basic auth.
* @param password optional, password to be used for basic auth.
* @param options optional, request options.
* @param platform optional, the manifest platform (os and architecture), applicable only for multi-architecture manifests.
* Defaults to linux/amd64. In case the requested manifest platform is not found an error is thrown.
* @returns
*/
export declare function getManifest(registryBase: string, repo: string, imageReference: string, username?: string, password?: string, options?: any, platform?: types.Platform, callChainObserver?: types.CallChainObserver): Promise<types.ImageManifest>;
export declare function computeDigest(body: any): string | undefined;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.computeDigest = exports.getManifest = void 0;
exports.computeDigest = exports.getManifest = exports.getAttestationManifest = void 0;
const registry_call_1 = require("./registry-call");

@@ -10,2 +10,4 @@ const contentTypes = require("./content-types");

const digestRegex = /^sha256:[a-f0-9]{64}$/i;
const referenceType = "vnd.docker.reference.type";
const attestationManifestType = "attestation-manifest";
/**

@@ -15,3 +17,3 @@ * A request to get image manifest by tag or digest

* @param repo the requested image repository.
* @param tag the manifest tag or digest value
* @param imageReference the manifest tag or digest value
* @param username optional, username to be used for basic auth.

@@ -24,3 +26,23 @@ * @param password optional, password to be used for basic auth.

*/
async function getAttestationManifest(registryBase, repo, imageReference, username, password, options = {}, platform, callChainObserver = { visitedUrls: [] }) {
return getManifestHelper(registryBase, repo, imageReference, findAttestationManifest, [contentTypes.MANIFEST_LIST_V2, contentTypes.OCI_INDEX_V1], username, password, Object.assign(Object.assign({}, options), { acceptManifest: `${contentTypes.MANIFEST_V2}, ${contentTypes.MANIFEST_LIST_V2}, ${contentTypes.OCI_MANIFEST_V1}` }), platform, callChainObserver);
}
exports.getAttestationManifest = getAttestationManifest;
/**
* A request to get image manifest by tag or digest
* @param registryBase the hostname (and optionally base path) from which to get the manifest.
* @param repo the requested image repository.
* @param imageReference the manifest tag or digest value
* @param username optional, username to be used for basic auth.
* @param password optional, password to be used for basic auth.
* @param options optional, request options.
* @param platform optional, the manifest platform (os and architecture), applicable only for multi-architecture manifests.
* Defaults to linux/amd64. In case the requested manifest platform is not found an error is thrown.
* @returns
*/
async function getManifest(registryBase, repo, imageReference, username, password, options = {}, platform, callChainObserver = { visitedUrls: [] }) {
return getManifestHelper(registryBase, repo, imageReference, getManifestDigestByPlatform, undefined, username, password, options, platform, callChainObserver);
}
exports.getManifest = getManifest;
async function getManifestHelper(registryBase, repo, imageReference, manifestDigestExtractor, expectedContentTypes, username, password, options = {}, platform, callChainObserver = { visitedUrls: [] }) {
var _a;

@@ -38,2 +60,6 @@ const accept = (_a = options.acceptManifest) !== null && _a !== void 0 ? _a : `${contentTypes.MANIFEST_V2}, ${contentTypes.MANIFEST_LIST_V2}`;

const contentType = manifestResponse.headers["content-type"];
if ((expectedContentTypes === null || expectedContentTypes === void 0 ? void 0 : expectedContentTypes.length) &&
!expectedContentTypes.includes(contentType)) {
return null;
}
let indexDigest;

@@ -44,3 +70,3 @@ let manifestDigest;

indexDigest = computeDigest(manifestResponse.body);
manifestDigest = getManifestDigestByPlatform(manifestResponse, platform);
manifestDigest = manifestDigestExtractor(manifestResponse, platform);
// need to call again with actual manifest (and not a list of manifest-lists)

@@ -50,2 +76,5 @@ const endpoint = `/${repo}/manifests/${manifestDigest}`;

}
return processResponse(manifestResponse, imageReference, manifestDigest, indexDigest);
}
function processResponse(manifestResponse, imageReference, manifestDigest, indexDigest) {
const dockerContentDigest = manifestResponse.headers["Docker-Content-Digest"];

@@ -68,3 +97,2 @@ switch (true) {

}
exports.getManifest = getManifest;
function isManifestDigest(imageReference) {

@@ -87,2 +115,10 @@ return digestRegex.test(imageReference);

exports.computeDigest = computeDigest;
function findAttestationManifest(manifestResponse) {
const manifestList = (0, needle_1.parseResponseBody)(manifestResponse);
const attestationManifest = manifestList.manifests.find(manifest => { var _a; return ((_a = manifest.annotations) === null || _a === void 0 ? void 0 : _a[referenceType]) == attestationManifestType; });
if (attestationManifest) {
return attestationManifest.digest;
}
throw new Error("could not find attestation manifest");
}
function getManifestDigestByPlatform(manifestResponse, platform) {

@@ -89,0 +125,0 @@ const defaultPlatform = {

4

dist/index.d.ts

@@ -7,3 +7,3 @@ import { checkSupport } from "./check-support";

import { getLayer } from "./get-layer";
import { getManifest } from "./get-manifest";
import { getManifest, getAttestationManifest } from "./get-manifest";
import { getRepos } from "./get-repos";

@@ -15,2 +15,2 @@ import { getTags } from "./get-tags";

import * as contentTypes from "./content-types";
export { checkSupport, downloadLayer, getAuthTokenForEndpoint, getImageConfig, getImageSize, getLayer, getManifest, getRepos, getTags, registryCall, validation, types, contentTypes, };
export { checkSupport, downloadLayer, getAuthTokenForEndpoint, getImageConfig, getImageSize, getLayer, getManifest, getAttestationManifest, getRepos, getTags, registryCall, validation, types, contentTypes, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.contentTypes = exports.types = exports.validation = exports.registryCall = exports.getTags = exports.getRepos = exports.getManifest = exports.getLayer = exports.getImageSize = exports.getImageConfig = exports.getAuthTokenForEndpoint = exports.downloadLayer = exports.checkSupport = void 0;
exports.contentTypes = exports.types = exports.validation = exports.registryCall = exports.getTags = exports.getRepos = exports.getAttestationManifest = exports.getManifest = exports.getLayer = exports.getImageSize = exports.getImageConfig = exports.getAuthTokenForEndpoint = exports.downloadLayer = exports.checkSupport = void 0;
const check_support_1 = require("./check-support");

@@ -18,2 +18,3 @@ Object.defineProperty(exports, "checkSupport", { enumerable: true, get: function () { return check_support_1.checkSupport; } });

Object.defineProperty(exports, "getManifest", { enumerable: true, get: function () { return get_manifest_1.getManifest; } });
Object.defineProperty(exports, "getAttestationManifest", { enumerable: true, get: function () { return get_manifest_1.getAttestationManifest; } });
const get_repos_1 = require("./get-repos");

@@ -20,0 +21,0 @@ Object.defineProperty(exports, "getRepos", { enumerable: true, get: function () { return get_repos_1.getRepos; } });

@@ -11,2 +11,3 @@ export interface LayerConfig {

platform?: Platform;
annotations?: Record<string, string>;
}

@@ -13,0 +14,0 @@ export interface Platform {

@@ -51,3 +51,3 @@ {

},
"version": "2.15.0"
"version": "2.16.0"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc