Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@snyk/docker-registry-v2-client

Package Overview
Dependencies
Maintainers
1
Versions
56
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.4.1 to 2.5.0

3

dist/index.d.ts

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

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

@@ -20,4 +20,6 @@ Object.defineProperty(exports, "checkSupport", { enumerable: true, get: function () { return check_support_1.checkSupport; } });

Object.defineProperty(exports, "getTags", { enumerable: true, get: function () { return get_tags_1.getTags; } });
const registry_call_1 = require("./registry-call");
Object.defineProperty(exports, "registryCall", { enumerable: true, get: function () { return registry_call_1.registryCall; } });
const types = require("./types");
exports.types = types;
//# sourceMappingURL=index.js.map
import { NeedleResponse } from "needle";
export declare function registryV2Call(registryBase: string, endpoint: string, accept: string, username?: string, password?: string, reqOptions?: any): Promise<NeedleResponse>;
/**
* WARNING!!!
*
* This function was created for a very specific usecase (https://snyksec.atlassian.net/browse/MAGMA-1262)
* It uses the existing mechanism of obtaining a token for authenticating, but can be used to hit any API endpoint,
* and not necessarily a Docker V2 endpoint.
* This is clearly an abuse of a library that's named after the v2 API, and this function should be considered a tech debt.
* Once it's no longer necessary, it is advised that this function is removed.
*
*/
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 getToken(registryBase: string, authBase: string, service: string, scope: string, username: string, password: string, reqOptions?: any): Promise<string>;
export declare function parseChallengeHeaders(challangeHeaders: any): any[];
export declare function parseChallengeHeaders(challengeHeaders: any): string[];
export declare function buildUnauthenticatedV2RequestConfig(registryBase: string, endpoint: string, accept: string, reqOptions?: any): any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildUnauthenticatedV2RequestConfig = exports.parseChallengeHeaders = exports.getToken = exports.paginatedV2Call = exports.registryV2Call = void 0;
exports.buildUnauthenticatedV2RequestConfig = exports.parseChallengeHeaders = exports.getToken = exports.paginatedV2Call = exports.registryCall = exports.registryV2Call = void 0;
const parseLink = require("parse-link-header");

@@ -40,2 +40,43 @@ const url = require("url");

exports.registryV2Call = registryV2Call;
/**
* WARNING!!!
*
* This function was created for a very specific usecase (https://snyksec.atlassian.net/browse/MAGMA-1262)
* It uses the existing mechanism of obtaining a token for authenticating, but can be used to hit any API endpoint,
* and not necessarily a Docker V2 endpoint.
* This is clearly an abuse of a library that's named after the v2 API, and this function should be considered a tech debt.
* Once it's no longer necessary, it is advised that this function is removed.
*
*/
async function registryCall(uri, username, password, reqOptions = {}) {
const reqConfig = applyRequestOptions({ uri: `https://${uri}` }, reqOptions);
try {
return await needle_1.needleWrapper(reqConfig, MAX_RETRIES);
}
catch (err) {
if (err.statusCode === 401) {
if (!username || !password) {
// Supply and empty username and password if no credentials
// are provided. These might be added later by a broker client.
username = username ? username : "";
password = password ? password : "";
}
const authConfig = await setAuthConfig("", err, reqConfig, username, password, reqOptions);
try {
return await needle_1.needleWrapper(authConfig, MAX_RETRIES);
}
catch (err) {
if (err.statusCode === 307 || err.statusCode === 302) {
return await handleRedirect(err, reqConfig);
}
throw err;
}
}
if (err.statusCode === 307 || err.statusCode === 302) {
return await handleRedirect(err, reqConfig);
}
throw err;
}
}
exports.registryCall = registryCall;
async function paginatedV2Call(registryBase, accept, username, password, endpoint, key, pageSize = 1000, maxPages = Number.MAX_SAFE_INTEGER, reqOptions = {}) {

@@ -78,8 +119,18 @@ const result = [];

exports.getToken = getToken;
function parseChallengeHeaders(challangeHeaders) {
const headersMap = challangeHeaders.split(",").reduce((map, entry) => {
function parseChallengeHeaders(challengeHeaders) {
const headersMap = {};
const headerSplit = challengeHeaders.split(",");
for (let i = 0; i < headerSplit.length; i++) {
const entry = headerSplit[i];
if (!entry.includes("=") && i > 0) {
// we'll get here in case a value includes a comma. we want to concat what's after the comma to the previous value
headerSplit[i - 1] += `,${entry}`;
headerSplit.splice(i, 1);
i--;
}
}
headerSplit.forEach(entry => {
const [key, value] = entry.split("=");
map[key] = JSON.parse(value);
return map;
}, {});
headersMap[key] = JSON.parse(value);
});
return [headersMap[BEARER_REALM], headersMap.service, headersMap.scope];

@@ -86,0 +137,0 @@ }

@@ -45,3 +45,3 @@ {

},
"version": "2.4.1"
"version": "2.5.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