@azure/container-registry 1.1.2-alpha.20260303.2 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/utils/base64.d.ts +1 -1
- package/dist/browser/utils/base64.d.ts.map +1 -0
- package/dist/browser/utils/base64.js +1 -1
- package/dist/browser/utils/base64.js.map +1 -0
- package/dist/commonjs/constants.js +27 -7
- package/dist/commonjs/constants.js.map +7 -1
- package/dist/commonjs/containerRegistryChallengeHandler.js +76 -80
- package/dist/commonjs/containerRegistryChallengeHandler.js.map +7 -1
- package/dist/commonjs/containerRegistryClient.js +188 -162
- package/dist/commonjs/containerRegistryClient.js.map +7 -1
- package/dist/commonjs/containerRegistryTokenCredential.js +91 -62
- package/dist/commonjs/containerRegistryTokenCredential.js.map +7 -1
- package/dist/commonjs/containerRepository.js +200 -162
- package/dist/commonjs/containerRepository.js.map +7 -1
- package/dist/commonjs/content/containerRegistryContentClient.js +342 -249
- package/dist/commonjs/content/containerRegistryContentClient.js.map +7 -1
- package/dist/commonjs/content/index.js +23 -8
- package/dist/commonjs/content/index.js.map +7 -1
- package/dist/commonjs/content/models.js +31 -20
- package/dist/commonjs/content/models.js.map +7 -1
- package/dist/commonjs/generated/generatedClient.js +102 -85
- package/dist/commonjs/generated/generatedClient.js.map +7 -1
- package/dist/commonjs/generated/generatedClientContext.js +71 -53
- package/dist/commonjs/generated/generatedClientContext.js.map +7 -1
- package/dist/commonjs/generated/index.js +32 -16
- package/dist/commonjs/generated/index.js.map +7 -1
- package/dist/commonjs/generated/models/index.js +75 -89
- package/dist/commonjs/generated/models/index.js.map +7 -1
- package/dist/commonjs/generated/models/mappers.js +1862 -1738
- package/dist/commonjs/generated/models/mappers.js.map +7 -1
- package/dist/commonjs/generated/models/parameters.js +464 -375
- package/dist/commonjs/generated/models/parameters.js.map +7 -1
- package/dist/commonjs/generated/operations/authentication.js +118 -87
- package/dist/commonjs/generated/operations/authentication.js.map +7 -1
- package/dist/commonjs/generated/operations/containerRegistry.js +515 -436
- package/dist/commonjs/generated/operations/containerRegistry.js.map +7 -1
- package/dist/commonjs/generated/operations/containerRegistryBlob.js +338 -280
- package/dist/commonjs/generated/operations/containerRegistryBlob.js.map +7 -1
- package/dist/commonjs/generated/operations/index.js +25 -14
- package/dist/commonjs/generated/operations/index.js.map +7 -1
- package/dist/commonjs/generated/operationsInterfaces/authentication.js +15 -10
- package/dist/commonjs/generated/operationsInterfaces/authentication.js.map +7 -1
- package/dist/commonjs/generated/operationsInterfaces/containerRegistry.js +15 -10
- package/dist/commonjs/generated/operationsInterfaces/containerRegistry.js.map +7 -1
- package/dist/commonjs/generated/operationsInterfaces/containerRegistryBlob.js +15 -10
- package/dist/commonjs/generated/operationsInterfaces/containerRegistryBlob.js.map +7 -1
- package/dist/commonjs/generated/operationsInterfaces/index.js +25 -14
- package/dist/commonjs/generated/operationsInterfaces/index.js.map +7 -1
- package/dist/commonjs/index.js +25 -9
- package/dist/commonjs/index.js.map +7 -1
- package/dist/commonjs/logger.js +28 -13
- package/dist/commonjs/logger.js.map +7 -1
- package/dist/commonjs/models.js +70 -89
- package/dist/commonjs/models.js.map +7 -1
- package/dist/commonjs/registryArtifact.js +331 -260
- package/dist/commonjs/registryArtifact.js.map +7 -1
- package/dist/commonjs/tracing.js +32 -13
- package/dist/commonjs/tracing.js.map +7 -1
- package/dist/commonjs/transformations.js +53 -41
- package/dist/commonjs/transformations.js.map +7 -1
- package/dist/commonjs/utils/base64.js +27 -14
- package/dist/commonjs/utils/base64.js.map +7 -1
- package/dist/commonjs/utils/digest.js +51 -23
- package/dist/commonjs/utils/digest.js.map +7 -1
- package/dist/commonjs/utils/helpers.js +64 -52
- package/dist/commonjs/utils/helpers.js.map +7 -1
- package/dist/commonjs/utils/retriableReadableStream.js +137 -122
- package/dist/commonjs/utils/retriableReadableStream.js.map +7 -1
- package/dist/commonjs/utils/tokenCycler.js +111 -141
- package/dist/commonjs/utils/tokenCycler.js.map +7 -1
- package/dist/commonjs/utils/wwwAuthenticateParser.js +33 -23
- package/dist/commonjs/utils/wwwAuthenticateParser.js.map +7 -1
- package/dist/esm/constants.js +4 -4
- package/dist/esm/constants.js.map +7 -1
- package/dist/esm/containerRegistryChallengeHandler.js +52 -75
- package/dist/esm/containerRegistryChallengeHandler.js.map +7 -1
- package/dist/esm/containerRegistryClient.js +157 -150
- package/dist/esm/containerRegistryClient.js.map +7 -1
- package/dist/esm/containerRegistryTokenCredential.js +68 -58
- package/dist/esm/containerRegistryTokenCredential.js.map +7 -1
- package/dist/esm/containerRepository.js +174 -155
- package/dist/esm/containerRepository.js.map +7 -1
- package/dist/esm/content/containerRegistryContentClient.js +298 -233
- package/dist/esm/content/containerRegistryContentClient.js.map +7 -1
- package/dist/esm/content/index.js +0 -3
- package/dist/esm/content/index.js.map +7 -1
- package/dist/esm/content/models.js +8 -17
- package/dist/esm/content/models.js.map +7 -1
- package/dist/esm/generated/generatedClient.js +73 -80
- package/dist/esm/generated/generatedClient.js.map +7 -1
- package/dist/esm/generated/generatedClientContext.js +38 -48
- package/dist/esm/generated/generatedClientContext.js.map +7 -1
- package/dist/esm/generated/index.js +4 -9
- package/dist/esm/generated/index.js.map +7 -1
- package/dist/esm/generated/models/index.js +49 -86
- package/dist/esm/generated/models/index.js.map +7 -1
- package/dist/esm/generated/models/mappers.js +1784 -1734
- package/dist/esm/generated/models/mappers.js.map +7 -1
- package/dist/esm/generated/models/parameters.js +408 -372
- package/dist/esm/generated/models/parameters.js.map +7 -1
- package/dist/esm/generated/operations/authentication.js +83 -80
- package/dist/esm/generated/operations/authentication.js.map +7 -1
- package/dist/esm/generated/operations/containerRegistry.js +480 -429
- package/dist/esm/generated/operations/containerRegistry.js.map +7 -1
- package/dist/esm/generated/operations/containerRegistryBlob.js +303 -273
- package/dist/esm/generated/operations/containerRegistryBlob.js.map +7 -1
- package/dist/esm/generated/operations/index.js +0 -8
- package/dist/esm/generated/operations/index.js.map +7 -1
- package/dist/esm/generated/operationsInterfaces/authentication.js +0 -9
- package/dist/esm/generated/operationsInterfaces/authentication.js.map +7 -1
- package/dist/esm/generated/operationsInterfaces/containerRegistry.js +0 -9
- package/dist/esm/generated/operationsInterfaces/containerRegistry.js.map +7 -1
- package/dist/esm/generated/operationsInterfaces/containerRegistryBlob.js +0 -9
- package/dist/esm/generated/operationsInterfaces/containerRegistryBlob.js.map +7 -1
- package/dist/esm/generated/operationsInterfaces/index.js +0 -8
- package/dist/esm/generated/operationsInterfaces/index.js.map +7 -1
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.map +7 -1
- package/dist/esm/logger.js +4 -9
- package/dist/esm/logger.js.map +7 -1
- package/dist/esm/models.js +45 -86
- package/dist/esm/models.js.map +7 -1
- package/dist/esm/registryArtifact.js +306 -254
- package/dist/esm/registryArtifact.js.map +7 -1
- package/dist/esm/tracing.js +7 -8
- package/dist/esm/tracing.js.map +7 -1
- package/dist/esm/transformations.js +31 -39
- package/dist/esm/transformations.js.map +7 -1
- package/dist/esm/utils/base64.js +5 -12
- package/dist/esm/utils/base64.js.map +7 -1
- package/dist/esm/utils/digest.js +17 -18
- package/dist/esm/utils/digest.js.map +7 -1
- package/dist/esm/utils/helpers.js +42 -50
- package/dist/esm/utils/helpers.js.map +7 -1
- package/dist/esm/utils/retriableReadableStream.js +112 -116
- package/dist/esm/utils/retriableReadableStream.js.map +7 -1
- package/dist/esm/utils/tokenCycler.js +88 -138
- package/dist/esm/utils/tokenCycler.js.map +7 -1
- package/dist/esm/utils/wwwAuthenticateParser.js +11 -21
- package/dist/esm/utils/wwwAuthenticateParser.js.map +7 -1
- package/package.json +11 -28
- package/dist/browser/utils/base64-browser.d.mts.map +0 -1
- package/dist/browser/utils/base64-browser.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../src/utils/base64.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,CAAC;IACb,SAAS,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACtC;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../../src/utils/base64.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,aAAqB;IAChD,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\ndeclare global {\n function atob(input: string): string;\n}\n\n/**\n * Base64 decode\n *\n * @internal\n * @param encodedString -\n * @returns\n\n */\nexport function base64decode(encodedString: string): string {\n return atob(encodedString);\n}\n"]}
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
|
+
SDK_VERSION: () => SDK_VERSION
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(constants_exports);
|
|
23
|
+
const SDK_VERSION = "1.1.2";
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
SDK_VERSION
|
|
27
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/containerregistry/container-registry/src/constants.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const SDK_VERSION = \"1.1.2\";\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,85 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*/
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var containerRegistryChallengeHandler_exports = {};
|
|
19
|
+
__export(containerRegistryChallengeHandler_exports, {
|
|
20
|
+
ChallengeHandler: () => ChallengeHandler
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(containerRegistryChallengeHandler_exports);
|
|
23
|
+
var import_wwwAuthenticateParser = require("./utils/wwwAuthenticateParser.js");
|
|
24
|
+
var import_tokenCycler = require("./utils/tokenCycler.js");
|
|
25
|
+
const fiveMinutesInMs = 5 * 60 * 1e3;
|
|
27
26
|
class ChallengeHandler {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
constructor(credential, options = {}) {
|
|
28
|
+
this.credential = credential;
|
|
29
|
+
this.options = options;
|
|
30
|
+
this.cycler = (0, import_tokenCycler.createTokenCycler)(credential, {
|
|
31
|
+
refreshWindowInMs: fiveMinutesInMs
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
cycler;
|
|
35
|
+
cachedAcrAccessToken;
|
|
36
|
+
authorizeRequest(options) {
|
|
37
|
+
if (this.cachedAcrAccessToken) {
|
|
38
|
+
options.request.headers.set("Authorization", `Bearer ${this.cachedAcrAccessToken}`);
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
return Promise.resolve();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Updates the authentication context based on the challenge.
|
|
44
|
+
*/
|
|
45
|
+
async authorizeRequestOnChallenge(options) {
|
|
46
|
+
const challenge = options.response?.headers.get("WWW-Authenticate");
|
|
47
|
+
if (!challenge) {
|
|
48
|
+
throw new Error("Failed to retrieve challenge from response headers");
|
|
45
49
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
async authorizeRequestOnChallenge(options) {
|
|
50
|
-
// Once we're here, we've completed Step 1.
|
|
51
|
-
const challenge = options.response?.headers.get("WWW-Authenticate");
|
|
52
|
-
if (!challenge) {
|
|
53
|
-
throw new Error("Failed to retrieve challenge from response headers");
|
|
54
|
-
}
|
|
55
|
-
// Step 2: Parse challenge string to retrieve serviceName and scope, where scope is the ACR Scope
|
|
56
|
-
const { service, scope } = (0, wwwAuthenticateParser_js_1.parseWWWAuthenticate)(challenge);
|
|
57
|
-
if (!service) {
|
|
58
|
-
throw new Error("Failed to retrieve 'service' from challenge");
|
|
59
|
-
}
|
|
60
|
-
if (!scope) {
|
|
61
|
-
throw new Error("Failed to retrieve 'scope' from challenge");
|
|
62
|
-
}
|
|
63
|
-
// Step 3: Exchange AAD Access Token for ACR Refresh Token
|
|
64
|
-
// For anonymous access, we send the request with grant_type=password and an empty ACR refresh token
|
|
65
|
-
// For non-anonymous access, we get an AAD token then exchange it for an ACR fresh token
|
|
66
|
-
let grantType;
|
|
67
|
-
let acrRefreshToken;
|
|
68
|
-
if (this.credential.isAnonymousAccess) {
|
|
69
|
-
grantType = "password";
|
|
70
|
-
acrRefreshToken = "";
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
grantType = "refresh_token";
|
|
74
|
-
acrRefreshToken = (await this.cycler.getToken(scope, { ...options, service })).token;
|
|
75
|
-
}
|
|
76
|
-
// Step 4: Send in acrRefreshToken and get back acrAccessToken
|
|
77
|
-
const acrAccessToken = await this.credential.tokenService.ExchangeAcrRefreshTokenForAcrAccessTokenAsync(acrRefreshToken, service, scope, grantType, this.options);
|
|
78
|
-
// Step 5 - Authorize Request. At this point we're done with AAD and using an ACR access token.
|
|
79
|
-
options.request.headers.set("Authorization", `Bearer ${acrAccessToken}`);
|
|
80
|
-
this.cachedAcrAccessToken = acrAccessToken;
|
|
81
|
-
return true;
|
|
50
|
+
const { service, scope } = (0, import_wwwAuthenticateParser.parseWWWAuthenticate)(challenge);
|
|
51
|
+
if (!service) {
|
|
52
|
+
throw new Error("Failed to retrieve 'service' from challenge");
|
|
82
53
|
}
|
|
54
|
+
if (!scope) {
|
|
55
|
+
throw new Error("Failed to retrieve 'scope' from challenge");
|
|
56
|
+
}
|
|
57
|
+
let grantType;
|
|
58
|
+
let acrRefreshToken;
|
|
59
|
+
if (this.credential.isAnonymousAccess) {
|
|
60
|
+
grantType = "password";
|
|
61
|
+
acrRefreshToken = "";
|
|
62
|
+
} else {
|
|
63
|
+
grantType = "refresh_token";
|
|
64
|
+
acrRefreshToken = (await this.cycler.getToken(scope, { ...options, service })).token;
|
|
65
|
+
}
|
|
66
|
+
const acrAccessToken = await this.credential.tokenService.ExchangeAcrRefreshTokenForAcrAccessTokenAsync(
|
|
67
|
+
acrRefreshToken,
|
|
68
|
+
service,
|
|
69
|
+
scope,
|
|
70
|
+
grantType,
|
|
71
|
+
this.options
|
|
72
|
+
);
|
|
73
|
+
options.request.headers.set("Authorization", `Bearer ${acrAccessToken}`);
|
|
74
|
+
this.cachedAcrAccessToken = acrAccessToken;
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
83
77
|
}
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
ChallengeHandler
|
|
81
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/containerregistry/container-registry/src/containerRegistryChallengeHandler.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { GetTokenOptions } from \"@azure/core-auth\";\nimport type {\n AuthorizeRequestOnChallengeOptions,\n ChallengeCallbacks,\n AuthorizeRequestOptions,\n} from \"@azure/core-rest-pipeline\";\nimport { parseWWWAuthenticate } from \"./utils/wwwAuthenticateParser.js\";\nimport type {\n ContainerRegistryGetTokenOptions,\n ContainerRegistryRefreshTokenCredential,\n} from \"./containerRegistryTokenCredential.js\";\nimport type { AccessTokenRefresher } from \"./utils/tokenCycler.js\";\nimport { createTokenCycler } from \"./utils/tokenCycler.js\";\n\nconst fiveMinutesInMs = 5 * 60 * 1000;\n\n/**\n * Handles challenge based authentication for Container Registry Service.\n *```\n * The challenge-based authorization flow for ACR is illustrated in the following steps.\n * For example, GET /api/v1/acr/repositories translates into the following calls.\n * Step 1: GET /api/v1/acr/repositories\n * Return Header: 401: www-authenticate header - Bearer realm=\"{url}\",service=\"{serviceName}\",scope=\"{scope}\",error=\"invalid_token\"\n * Step 2: Retrieve the serviceName, scope from the WWW-Authenticate header. (Parse the string.)\n * Step 3: POST /api/oauth2/exchange\n * Request Body : { service, scope, grant-type, aadToken with ARM scope }\n * Response Body: { acrRefreshToken }\n * Step 4: POST /api/oauth2/token\n * Request Body: { acrRefreshToken, scope, grant-type }\n * Response Body: { acrAccessToken }\n * Step 5: GET /api/v1/acr/repositories\n * Request Header: { Bearer acrTokenAccess }\n *```\n */\nexport class ChallengeHandler implements ChallengeCallbacks {\n private readonly cycler: AccessTokenRefresher<ContainerRegistryGetTokenOptions>;\n private cachedAcrAccessToken: string | undefined;\n\n constructor(\n private credential: ContainerRegistryRefreshTokenCredential,\n private options: GetTokenOptions = {},\n ) {\n this.cycler = createTokenCycler(credential, {\n refreshWindowInMs: fiveMinutesInMs,\n });\n }\n\n authorizeRequest(options: AuthorizeRequestOptions): Promise<void> {\n // Try using the existing token in case we don't need to refresh.\n if (this.cachedAcrAccessToken) {\n options.request.headers.set(\"Authorization\", `Bearer ${this.cachedAcrAccessToken}`);\n }\n\n return Promise.resolve();\n }\n\n /**\n * Updates the authentication context based on the challenge.\n */\n async authorizeRequestOnChallenge(options: AuthorizeRequestOnChallengeOptions): Promise<boolean> {\n // Once we're here, we've completed Step 1.\n const challenge = options.response?.headers.get(\"WWW-Authenticate\");\n if (!challenge) {\n throw new Error(\"Failed to retrieve challenge from response headers\");\n }\n // Step 2: Parse challenge string to retrieve serviceName and scope, where scope is the ACR Scope\n const { service, scope } = parseWWWAuthenticate(challenge);\n\n if (!service) {\n throw new Error(\"Failed to retrieve 'service' from challenge\");\n }\n\n if (!scope) {\n throw new Error(\"Failed to retrieve 'scope' from challenge\");\n }\n\n // Step 3: Exchange AAD Access Token for ACR Refresh Token\n // For anonymous access, we send the request with grant_type=password and an empty ACR refresh token\n // For non-anonymous access, we get an AAD token then exchange it for an ACR fresh token\n let grantType: \"password\" | \"refresh_token\";\n let acrRefreshToken: string;\n if (this.credential.isAnonymousAccess) {\n grantType = \"password\";\n acrRefreshToken = \"\";\n } else {\n grantType = \"refresh_token\";\n acrRefreshToken = (await this.cycler.getToken(scope, { ...options, service })).token;\n }\n\n // Step 4: Send in acrRefreshToken and get back acrAccessToken\n const acrAccessToken =\n await this.credential.tokenService.ExchangeAcrRefreshTokenForAcrAccessTokenAsync(\n acrRefreshToken,\n service,\n scope,\n grantType,\n this.options,\n );\n\n // Step 5 - Authorize Request. At this point we're done with AAD and using an ACR access token.\n options.request.headers.set(\"Authorization\", `Bearer ${acrAccessToken}`);\n\n this.cachedAcrAccessToken = acrAccessToken;\n\n return true;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mCAAqC;AAMrC,yBAAkC;AAElC,MAAM,kBAAkB,IAAI,KAAK;AAoB1B,MAAM,iBAA+C;AAAA,EAI1D,YACU,YACA,UAA2B,CAAC,GACpC;AAFQ;AACA;AAER,SAAK,aAAS,sCAAkB,YAAY;AAAA,MAC1C,mBAAmB;AAAA,IACrB,CAAC;AAAA,EACH;AAAA,EAViB;AAAA,EACT;AAAA,EAWR,iBAAiB,SAAiD;AAEhE,QAAI,KAAK,sBAAsB;AAC7B,cAAQ,QAAQ,QAAQ,IAAI,iBAAiB,UAAU,KAAK,oBAAoB,EAAE;AAAA,IACpF;AAEA,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,4BAA4B,SAA+D;AAE/F,UAAM,YAAY,QAAQ,UAAU,QAAQ,IAAI,kBAAkB;AAClE,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,oDAAoD;AAAA,IACtE;AAEA,UAAM,EAAE,SAAS,MAAM,QAAI,mDAAqB,SAAS;AAEzD,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,MAAM,6CAA6C;AAAA,IAC/D;AAEA,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,2CAA2C;AAAA,IAC7D;AAKA,QAAI;AACJ,QAAI;AACJ,QAAI,KAAK,WAAW,mBAAmB;AACrC,kBAAY;AACZ,wBAAkB;AAAA,IACpB,OAAO;AACL,kBAAY;AACZ,yBAAmB,MAAM,KAAK,OAAO,SAAS,OAAO,EAAE,GAAG,SAAS,QAAQ,CAAC,GAAG;AAAA,IACjF;AAGA,UAAM,iBACJ,MAAM,KAAK,WAAW,aAAa;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,KAAK;AAAA,IACP;AAGF,YAAQ,QAAQ,QAAQ,IAAI,iBAAiB,UAAU,cAAc,EAAE;AAEvE,SAAK,uBAAuB;AAE5B,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,172 +1,198 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var containerRegistryClient_exports = {};
|
|
19
|
+
__export(containerRegistryClient_exports, {
|
|
20
|
+
ContainerRegistryClient: () => ContainerRegistryClient
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(containerRegistryClient_exports);
|
|
23
|
+
var import_core_auth = require("@azure/core-auth");
|
|
24
|
+
var import_core_rest_pipeline = require("@azure/core-rest-pipeline");
|
|
25
|
+
var import_logger = require("./logger.js");
|
|
26
|
+
var import_generated = require("./generated/index.js");
|
|
27
|
+
var import_tracing = require("./tracing.js");
|
|
28
|
+
var import_helpers = require("./utils/helpers.js");
|
|
29
|
+
var import_containerRegistryChallengeHandler = require("./containerRegistryChallengeHandler.js");
|
|
30
|
+
var import_containerRepository = require("./containerRepository.js");
|
|
31
|
+
var import_containerRegistryTokenCredential = require("./containerRegistryTokenCredential.js");
|
|
15
32
|
const LATEST_API_VERSION = "2021-07-01";
|
|
16
|
-
/**
|
|
17
|
-
* The client class used to interact with the Container Registry service.
|
|
18
|
-
*/
|
|
19
33
|
class ContainerRegistryClient {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
this.endpoint = endpoint;
|
|
30
|
-
let credential;
|
|
31
|
-
let options;
|
|
32
|
-
if ((0, core_auth_1.isTokenCredential)(credentialOrOptions)) {
|
|
33
|
-
credential = credentialOrOptions;
|
|
34
|
-
options = clientOptions;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
options = credentialOrOptions ?? {};
|
|
38
|
-
}
|
|
39
|
-
const internalPipelineOptions = {
|
|
40
|
-
...options,
|
|
41
|
-
redirectOptions: {
|
|
42
|
-
allowCrossOriginRedirects: true,
|
|
43
|
-
...options?.redirectOptions,
|
|
44
|
-
},
|
|
45
|
-
loggingOptions: {
|
|
46
|
-
logger: logger_js_1.logger.info,
|
|
47
|
-
// This array contains header names we want to log that are not already
|
|
48
|
-
// included as safe. Unknown/unsafe headers are logged as "<REDACTED>".
|
|
49
|
-
additionalAllowedQueryParameters: ["last", "n", "orderby", "digest"],
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
const defaultScope = `${options.audience ?? "https://containerregistry.azure.net"}/.default`;
|
|
53
|
-
const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;
|
|
54
|
-
const authClient = new index_js_1.GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
|
|
55
|
-
this.client = new index_js_1.GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
|
|
56
|
-
this.client.pipeline.addPolicy((0, core_rest_pipeline_1.bearerTokenAuthenticationPolicy)({
|
|
57
|
-
credential,
|
|
58
|
-
scopes: [defaultScope],
|
|
59
|
-
challengeCallbacks: new containerRegistryChallengeHandler_js_1.ChallengeHandler(new containerRegistryTokenCredential_js_1.ContainerRegistryRefreshTokenCredential(authClient, defaultScope, credential)),
|
|
60
|
-
}));
|
|
34
|
+
/**
|
|
35
|
+
* The Azure Container Registry endpoint.
|
|
36
|
+
*/
|
|
37
|
+
endpoint;
|
|
38
|
+
client;
|
|
39
|
+
constructor(endpoint, credentialOrOptions, clientOptions = {}) {
|
|
40
|
+
if (!endpoint) {
|
|
41
|
+
throw new Error("invalid endpoint");
|
|
61
42
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
43
|
+
this.endpoint = endpoint;
|
|
44
|
+
let credential;
|
|
45
|
+
let options;
|
|
46
|
+
if ((0, import_core_auth.isTokenCredential)(credentialOrOptions)) {
|
|
47
|
+
credential = credentialOrOptions;
|
|
48
|
+
options = clientOptions;
|
|
49
|
+
} else {
|
|
50
|
+
options = credentialOrOptions ?? {};
|
|
51
|
+
}
|
|
52
|
+
const internalPipelineOptions = {
|
|
53
|
+
...options,
|
|
54
|
+
redirectOptions: {
|
|
55
|
+
allowCrossOriginRedirects: true,
|
|
56
|
+
...options?.redirectOptions
|
|
57
|
+
},
|
|
58
|
+
loggingOptions: {
|
|
59
|
+
logger: import_logger.logger.info,
|
|
60
|
+
// This array contains header names we want to log that are not already
|
|
61
|
+
// included as safe. Unknown/unsafe headers are logged as "<REDACTED>".
|
|
62
|
+
additionalAllowedQueryParameters: ["last", "n", "orderby", "digest"]
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const defaultScope = `${options.audience ?? "https://containerregistry.azure.net"}/.default`;
|
|
66
|
+
const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;
|
|
67
|
+
const authClient = new import_generated.GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
|
|
68
|
+
this.client = new import_generated.GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
|
|
69
|
+
this.client.pipeline.addPolicy(
|
|
70
|
+
(0, import_core_rest_pipeline.bearerTokenAuthenticationPolicy)({
|
|
71
|
+
credential,
|
|
72
|
+
scopes: [defaultScope],
|
|
73
|
+
challengeCallbacks: new import_containerRegistryChallengeHandler.ChallengeHandler(
|
|
74
|
+
new import_containerRegistryTokenCredential.ContainerRegistryRefreshTokenCredential(authClient, defaultScope, credential)
|
|
75
|
+
)
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Deletes the repository identified by the given name and all associated artifacts.
|
|
81
|
+
*
|
|
82
|
+
* @param repositoryName - the name of repository to delete
|
|
83
|
+
* @param options - optional configuration for the operation
|
|
84
|
+
*/
|
|
85
|
+
async deleteRepository(repositoryName, options = {}) {
|
|
86
|
+
if (!repositoryName) {
|
|
87
|
+
throw new Error("invalid repositoryName");
|
|
75
88
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
return import_tracing.tracingClient.withSpan(
|
|
90
|
+
"ContainerRegistryClient.deleteRepository",
|
|
91
|
+
options,
|
|
92
|
+
async (updatedOptions) => {
|
|
93
|
+
await this.client.containerRegistry.deleteRepository(repositoryName, updatedOptions);
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns an instance of {@link RegistryArtifact} for calling service methods related to the artifact specified by `repositoryName` and `tagOrDigest`.
|
|
99
|
+
*
|
|
100
|
+
* @param repositoryName - the name of repository
|
|
101
|
+
* @param tagOrDigest - tag or digest of the artifact to retrieve
|
|
102
|
+
*/
|
|
103
|
+
getArtifact(repositoryName, tagOrDigest) {
|
|
104
|
+
if (!repositoryName) {
|
|
105
|
+
throw new Error("invalid repositoryName");
|
|
90
106
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*
|
|
94
|
-
* @param repositoryName - the name of repository
|
|
95
|
-
*/
|
|
96
|
-
getRepository(repositoryName) {
|
|
97
|
-
if (!repositoryName) {
|
|
98
|
-
throw new Error("invalid repositoryName");
|
|
99
|
-
}
|
|
100
|
-
return new containerRepository_js_1.ContainerRepositoryImpl(this.endpoint, repositoryName, this.client);
|
|
107
|
+
if (!tagOrDigest) {
|
|
108
|
+
throw new Error("invalid tagOrDigest");
|
|
101
109
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
*
|
|
115
|
-
* const iterator = client.listRepositoryNames();
|
|
116
|
-
* for await (const repository of iterator) {
|
|
117
|
-
* console.log(` repository: ${repository}`);
|
|
118
|
-
* }
|
|
119
|
-
* ```
|
|
120
|
-
*
|
|
121
|
-
* @param options - The options for the request
|
|
122
|
-
*/
|
|
123
|
-
listRepositoryNames(
|
|
124
|
-
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
|
|
125
|
-
options = {}) {
|
|
126
|
-
const iter = this.listRepositoryItems(options);
|
|
127
|
-
return {
|
|
128
|
-
next() {
|
|
129
|
-
return iter.next();
|
|
130
|
-
},
|
|
131
|
-
[Symbol.asyncIterator]() {
|
|
132
|
-
return this;
|
|
133
|
-
},
|
|
134
|
-
byPage: (settings = {}) => this.listRepositoriesPage(settings, options),
|
|
135
|
-
};
|
|
110
|
+
return new import_containerRepository.ContainerRepositoryImpl(this.endpoint, repositoryName, this.client).getArtifact(
|
|
111
|
+
tagOrDigest
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Returns an instance of {@link ContainerRepository} for calling service methods related to the repository specified by `repositoryName`.
|
|
116
|
+
*
|
|
117
|
+
* @param repositoryName - the name of repository
|
|
118
|
+
*/
|
|
119
|
+
getRepository(repositoryName) {
|
|
120
|
+
if (!repositoryName) {
|
|
121
|
+
throw new Error("invalid repositoryName");
|
|
136
122
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
123
|
+
return new import_containerRepository.ContainerRepositoryImpl(this.endpoint, repositoryName, this.client);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Returns an async iterable iterator to list names of repositories in this registry.
|
|
127
|
+
*
|
|
128
|
+
* Example usage:
|
|
129
|
+
* ```ts snippet:SampleReadmeListRepositories
|
|
130
|
+
* import { ContainerRegistryClient, KnownContainerRegistryAudience } from "@azure/container-registry";
|
|
131
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
132
|
+
*
|
|
133
|
+
* const endpoint = "https://myregistryname.azurecr.io";
|
|
134
|
+
* const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {
|
|
135
|
+
* audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,
|
|
136
|
+
* });
|
|
137
|
+
*
|
|
138
|
+
* const iterator = client.listRepositoryNames();
|
|
139
|
+
* for await (const repository of iterator) {
|
|
140
|
+
* console.log(` repository: ${repository}`);
|
|
141
|
+
* }
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @param options - The options for the request
|
|
145
|
+
*/
|
|
146
|
+
listRepositoryNames(options = {}) {
|
|
147
|
+
const iter = this.listRepositoryItems(options);
|
|
148
|
+
return {
|
|
149
|
+
next() {
|
|
150
|
+
return iter.next();
|
|
151
|
+
},
|
|
152
|
+
[Symbol.asyncIterator]() {
|
|
153
|
+
return this;
|
|
154
|
+
},
|
|
155
|
+
byPage: (settings = {}) => this.listRepositoriesPage(settings, options)
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async *listRepositoryItems(options = {}) {
|
|
159
|
+
for await (const page of this.listRepositoriesPage({}, options)) {
|
|
160
|
+
yield* page;
|
|
141
161
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
162
|
+
}
|
|
163
|
+
async *listRepositoriesPage(continuationState, options = {}) {
|
|
164
|
+
if (!continuationState.continuationToken) {
|
|
165
|
+
const optionsComplete = {
|
|
166
|
+
...options,
|
|
167
|
+
n: continuationState.maxPageSize
|
|
168
|
+
};
|
|
169
|
+
const currentPage = await this.client.containerRegistry.getRepositories(optionsComplete);
|
|
170
|
+
continuationState.continuationToken = (0, import_helpers.extractNextLink)(currentPage.link);
|
|
171
|
+
if (currentPage.repositories) {
|
|
172
|
+
const array = currentPage.repositories;
|
|
173
|
+
yield Object.defineProperty(array, "continuationToken", {
|
|
174
|
+
value: continuationState.continuationToken,
|
|
175
|
+
enumerable: true
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
while (continuationState.continuationToken) {
|
|
180
|
+
const currentPage = await this.client.containerRegistry.getRepositoriesNext(
|
|
181
|
+
continuationState.continuationToken,
|
|
182
|
+
options
|
|
183
|
+
);
|
|
184
|
+
continuationState.continuationToken = (0, import_helpers.extractNextLink)(currentPage.link);
|
|
185
|
+
if (currentPage.repositories) {
|
|
186
|
+
const array = currentPage.repositories;
|
|
187
|
+
yield Object.defineProperty(array, "continuationToken", {
|
|
188
|
+
value: continuationState.continuationToken,
|
|
189
|
+
enumerable: true
|
|
190
|
+
});
|
|
191
|
+
}
|
|
169
192
|
}
|
|
193
|
+
}
|
|
170
194
|
}
|
|
171
|
-
|
|
172
|
-
|
|
195
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
196
|
+
0 && (module.exports = {
|
|
197
|
+
ContainerRegistryClient
|
|
198
|
+
});
|