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.12.0 to 2.13.0

3

dist/check-support.d.ts

@@ -0,4 +1,5 @@

import { CallChainObserver } from "./types";
/**
* Root V2 endpoint, useful to check V2 support and validating credentials.
*/
export declare function checkSupport(registryBase: string, username?: string, password?: string, options?: any): Promise<any>;
export declare function checkSupport(registryBase: string, username?: string, password?: string, options?: any, callChainObserver?: CallChainObserver): Promise<any>;

@@ -9,5 +9,5 @@ "use strict";

*/
async function checkSupport(registryBase, username, password, options = {}) {
async function checkSupport(registryBase, username, password, options = {}, callChainObserver = { visitedUrls: [] }) {
const result = await (0, registry_call_1.registryV2Call)(registryBase, "/", // full url path should be "/v2/" as per spec
contentTypes.JSON, username, password, options);
contentTypes.JSON, callChainObserver, username, password, options);
// always return thruthy object, even for ECR

@@ -14,0 +14,0 @@ return result || {};

import { NeedleResponse } from "needle";
export declare function downloadLayer(output: string, registryBase: string, repo: string, digest: string, username?: string, password?: string, options?: any): Promise<NeedleResponse>;
import { CallChainObserver } from "./types";
export declare function downloadLayer(output: string, registryBase: string, repo: string, digest: string, username?: string, password?: string, options?: any, callChainObserver?: CallChainObserver): Promise<NeedleResponse>;

@@ -6,3 +6,3 @@ "use strict";

const contentTypes = require("./content-types");
async function downloadLayer(output, registryBase, repo, digest, username, password, options = {}) {
async function downloadLayer(output, registryBase, repo, digest, username, password, options = {}, callChainObserver = { visitedUrls: [] }) {
var _a;

@@ -12,3 +12,3 @@ const accept = `${(_a = options.acceptLayer) !== null && _a !== void 0 ? _a : contentTypes.LAYER}`;

options = Object.assign({ json: false, encoding: null, snykInternalOutputStream: output }, options);
const layerResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, accept, username, password, options);
const layerResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, accept, callChainObserver, username, password, options);
return layerResponse;

@@ -15,0 +15,0 @@ }

@@ -1,1 +0,2 @@

export declare function getImageConfig(registryBase: string, repo: string, digest: string, username?: string, password?: string, options?: any): Promise<any>;
import { CallChainObserver } from "./types";
export declare function getImageConfig(registryBase: string, repo: string, digest: string, username?: string, password?: string, options?: any, callChainObserver?: CallChainObserver): Promise<any>;

@@ -7,5 +7,5 @@ "use strict";

const needle_1 = require("./needle");
async function getImageConfig(registryBase, repo, digest, username, password, options = {}) {
async function getImageConfig(registryBase, repo, digest, username, password, options = {}, callChainObserver = { visitedUrls: [] }) {
const endpoint = `/${repo}/blobs/${digest}`;
const configResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, contentTypes.IMAGE_CONFIG, username, password, options);
const configResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, contentTypes.IMAGE_CONFIG, callChainObserver, username, password, options);
return (0, needle_1.parseResponseBody)(configResponse);

@@ -12,0 +12,0 @@ }

/// <reference types="node" />
import { CallChainObserver } from "./types";
/** @deprecated use downloadLayer instead. */
export declare function getLayer(registryBase: string, repo: string, digest: string, username?: string, password?: string, options?: any): Promise<Buffer>;
export declare function getLayer(registryBase: string, repo: string, digest: string, username?: string, password?: string, options?: any, callChainObserver?: CallChainObserver): Promise<Buffer>;

@@ -7,3 +7,3 @@ "use strict";

/** @deprecated use downloadLayer instead. */
async function getLayer(registryBase, repo, digest, username, password, options = {}) {
async function getLayer(registryBase, repo, digest, username, password, options = {}, callChainObserver = { visitedUrls: [] }) {
var _a;

@@ -13,3 +13,3 @@ const accept = `${(_a = options.acceptLayer) !== null && _a !== void 0 ? _a : contentTypes.LAYER}`;

options = Object.assign({ json: false, encoding: null }, options);
const layerResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, accept, username, password, options);
const layerResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, accept, callChainObserver, username, password, options);
// When the content type is wrongly set to text instead of binary, response body is returned as string instead of a buffer

@@ -16,0 +16,0 @@ // This forces a buffer response.

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

*/
export declare function getManifest(registryBase: string, repo: string, imageReference: string, username?: string, password?: string, options?: any, platform?: types.Platform): Promise<types.ImageManifest>;
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;

@@ -22,3 +22,3 @@ "use strict";

*/
async function getManifest(registryBase, repo, imageReference, username, password, options = {}, platform) {
async function getManifest(registryBase, repo, imageReference, username, password, options = {}, platform, callChainObserver = { visitedUrls: [] }) {
var _a;

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

}
let manifestResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, accept, username, password, options);
let manifestResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, accept, callChainObserver, username, password, options);
const contentType = manifestResponse.headers["content-type"];

@@ -45,3 +45,3 @@ let indexDigest;

const endpoint = `/${repo}/manifests/${manifestDigest}`;
manifestResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, accept, username, password, options);
manifestResponse = await (0, registry_call_1.registryV2Call)(registryBase, endpoint, accept, callChainObserver !== null && callChainObserver !== void 0 ? callChainObserver : { visitedUrls: [] }, username, password, options);
}

@@ -48,0 +48,0 @@ const dockerContentDigest = manifestResponse.headers["Docker-Content-Digest"];

@@ -1,1 +0,2 @@

export declare function getRepos(registryBase: string, username?: string, password?: string, pageSize?: number, maxPages?: number, options?: any): Promise<string[]>;
import { CallChainObserver } from "./types";
export declare function getRepos(registryBase: string, username?: string, password?: string, pageSize?: number, maxPages?: number, options?: any, callChainObserver?: CallChainObserver): Promise<string[]>;

@@ -6,7 +6,8 @@ "use strict";

const registry_call_1 = require("./registry-call");
async function getRepos(registryBase, username, password, pageSize = 100, maxPages = Number.MAX_SAFE_INTEGER, options = {}) {
async function getRepos(registryBase, username, password, pageSize = 100, maxPages = Number.MAX_SAFE_INTEGER, options = {}, callChainObserver = { visitedUrls: [] }) {
const endpoint = "/_catalog";
return await (0, registry_call_1.paginatedV2Call)(registryBase, contentTypes.JSON, username, password, endpoint, "repositories", pageSize, maxPages, options);
const result = await (0, registry_call_1.paginatedV2Call)(registryBase, contentTypes.JSON, username, password, endpoint, "repositories", pageSize, maxPages, options, callChainObserver);
return result;
}
exports.getRepos = getRepos;
//# sourceMappingURL=get-repos.js.map

@@ -1,1 +0,2 @@

export declare function getTags(registryBase: string, repo: string, username?: string, password?: string, pageSize?: number, maxPages?: number, options?: any): Promise<string[]>;
import { CallChainObserver } from "./types";
export declare function getTags(registryBase: string, repo: string, username?: string, password?: string, pageSize?: number, maxPages?: number, options?: any, callChainObserver?: CallChainObserver): Promise<string[]>;

@@ -6,7 +6,7 @@ "use strict";

const contentTypes = require("./content-types");
async function getTags(registryBase, repo, username, password, pageSize = 1000, maxPages = Number.MAX_SAFE_INTEGER, options = {}) {
async function getTags(registryBase, repo, username, password, pageSize = 1000, maxPages = Number.MAX_SAFE_INTEGER, options = {}, callChainObserver = { visitedUrls: [] }) {
const endpoint = `/${repo}/tags/list`;
return await (0, registry_call_1.paginatedV2Call)(registryBase, contentTypes.JSON, username, password, endpoint, "tags", pageSize, maxPages, options);
return await (0, registry_call_1.paginatedV2Call)(registryBase, contentTypes.JSON, username, password, endpoint, "tags", pageSize, maxPages, options, callChainObserver);
}
exports.getTags = getTags;
//# sourceMappingURL=get-tags.js.map
import { NeedleOptions, NeedleResponse } from "needle";
import { CallChainObserver } from "./types";
type Headers = NeedleOptions["headers"];

@@ -20,3 +21,3 @@ interface RequestOptions extends NeedleOptions {

*/
export declare function needleWrapper(options: RequestOptions, maxRetries?: number): Promise<NeedleResponse>;
export declare function needleWrapper(options: RequestOptions, maxRetries?: number, callChainObserver?: CallChainObserver): Promise<NeedleResponse>;
export declare function parseResponseBody(response: NeedleResponse): any;

@@ -23,0 +24,0 @@ export declare class NeedleWrapperException extends Error {

@@ -24,3 +24,3 @@ "use strict";

*/
async function needleWrapper(options, maxRetries) {
async function needleWrapper(options, maxRetries, callChainObserver = { visitedUrls: [] }) {
var _a, _b;

@@ -39,2 +39,3 @@ let uri = options.uri;

}
callChainObserver.visitedUrls.push(uri);
let response;

@@ -41,0 +42,0 @@ let lastError;

import { NeedleResponse } from "needle";
export declare function registryV2Call(registryBase: string, endpoint: string, accept: string, username?: string, password?: string, reqOptions?: any): Promise<NeedleResponse>;
import { CallChainObserver } from "./types";
export declare function registryV2Call(registryBase: string, endpoint: string, accept: string, callChainObserver: CallChainObserver, username?: string, password?: string, reqOptions?: any): Promise<NeedleResponse>;
/**

@@ -13,6 +14,6 @@ * WARNING!!!

*/
export declare function registryCall(uri: string, username?: string, password?: string, reqOptions?: any): Promise<NeedleResponse>;
export declare function paginatedV2Call(registryBase: string, accept: string, username: string, password: string, endpoint: string, key: string, pageSize?: number, maxPages?: number, reqOptions?: any): Promise<string[]>;
export declare function registryCall(uri: string, username?: string, password?: string, reqOptions?: any, callChainObserver?: CallChainObserver): Promise<NeedleResponse>;
export declare function paginatedV2Call(registryBase: string, accept: string, username: string, password: string, endpoint: string, key: string, pageSize?: number, maxPages?: number, reqOptions?: any, callChainObserver?: CallChainObserver): Promise<string[]>;
export declare function getToken(registryBase: string, authBase: string, service: string, scope: string, username: string, password: string, reqOptions?: any): Promise<string>;
export declare function parseChallengeHeaders(challengeHeaders: any): string[];
export declare function buildUnauthenticatedV2RequestConfig(registryBase: string, endpoint: string, accept: string, reqOptions?: any): any;

@@ -10,6 +10,7 @@ "use strict";

const MAX_REDIRECTS = 5;
async function registryV2Call(registryBase, endpoint, accept, username, password, reqOptions = {}) {
async function registryV2Call(registryBase, endpoint, accept, callChainObserver, username, password, reqOptions = {}) {
const reqConfig = buildUnauthenticatedV2RequestConfig(registryBase, endpoint, accept, reqOptions);
try {
return await (0, needle_1.needleWrapper)(reqConfig, MAX_RETRIES);
callChainObserver.visitedUrls.push();
return await (0, needle_1.needleWrapper)(reqConfig, MAX_RETRIES, callChainObserver);
}

@@ -26,7 +27,7 @@ catch (err) {

try {
return await (0, needle_1.needleWrapper)(authConfig, MAX_RETRIES);
return await (0, needle_1.needleWrapper)(authConfig, MAX_RETRIES, callChainObserver);
}
catch (err) {
if (isRedirectStatus(err.statusCode)) {
return await handleRedirect(err, reqConfig);
return await handleRedirect(err, reqConfig, callChainObserver);
}

@@ -37,3 +38,3 @@ throw err;

if (isRedirectStatus(err.statusCode)) {
return await handleRedirect(err, reqConfig);
return await handleRedirect(err, reqConfig, callChainObserver);
}

@@ -54,6 +55,6 @@ throw err;

*/
async function registryCall(uri, username, password, reqOptions = {}) {
async function registryCall(uri, username, password, reqOptions = {}, callChainObserver = { visitedUrls: [] }) {
const reqConfig = applyRequestOptions({ uri: `https://${uri}` }, reqOptions);
try {
return await (0, needle_1.needleWrapper)(reqConfig, MAX_RETRIES);
return await (0, needle_1.needleWrapper)(reqConfig, MAX_RETRIES, callChainObserver);
}

@@ -70,7 +71,7 @@ catch (err) {

try {
return await (0, needle_1.needleWrapper)(authConfig, MAX_RETRIES);
return await (0, needle_1.needleWrapper)(authConfig, MAX_RETRIES, callChainObserver);
}
catch (err) {
if (isRedirectStatus(err.statusCode)) {
return await handleRedirect(err, reqConfig);
return await handleRedirect(err, reqConfig, callChainObserver);
}

@@ -81,3 +82,3 @@ throw err;

if (isRedirectStatus(err.statusCode)) {
return await handleRedirect(err, reqConfig);
return await handleRedirect(err, reqConfig, callChainObserver);
}

@@ -88,3 +89,3 @@ throw err;

exports.registryCall = registryCall;
async function paginatedV2Call(registryBase, accept, username, password, endpoint, key, pageSize = 1000, maxPages = Number.MAX_SAFE_INTEGER, reqOptions = {}) {
async function paginatedV2Call(registryBase, accept, username, password, endpoint, key, pageSize = 1000, maxPages = Number.MAX_SAFE_INTEGER, reqOptions = {}, callChainObserver = { visitedUrls: [] }) {
const result = [];

@@ -94,3 +95,3 @@ let pageEndpoint = `${endpoint}?n=${pageSize}`;

while (pageCount < maxPages) {
const response = await registryV2Call(registryBase, pageEndpoint, accept, username, password, reqOptions);
const response = await registryV2Call(registryBase, pageEndpoint, accept, callChainObserver, username, password, reqOptions);
const body = (0, needle_1.parseResponseBody)(response);

@@ -178,6 +179,6 @@ if (body && body[key]) {

// Handle redirect while following up to MAX_REDIRECTS
async function handleRedirect(err, config) {
return handleRedirectRec(err, config, MAX_REDIRECTS);
async function handleRedirect(err, config, callChainObserver) {
return handleRedirectRec(err, config, MAX_REDIRECTS, callChainObserver);
}
async function handleRedirectRec(err, config, maxRedirects = 0) {
async function handleRedirectRec(err, config, maxRedirects = 0, callChainObserver) {
if (maxRedirects === 0) {

@@ -202,7 +203,7 @@ throw err;

try {
return await (0, needle_1.needleWrapper)(config, MAX_RETRIES);
return await (0, needle_1.needleWrapper)(config, MAX_RETRIES, callChainObserver);
}
catch (err) {
if (isRedirectStatus(err.statusCode)) {
return await handleRedirectRec(err, config, maxRedirects - 1);
return await handleRedirectRec(err, config, maxRedirects - 1, callChainObserver);
}

@@ -209,0 +210,0 @@ throw err;

@@ -44,1 +44,4 @@ export interface LayerConfig {

}
export type CallChainObserver = {
visitedUrls: string[];
};

@@ -50,3 +50,3 @@ {

},
"version": "2.12.0"
"version": "2.13.0"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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