@azure/container-registry 1.1.1-alpha.20250618.1 → 1.1.1-alpha.20250722.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/containerRegistryChallengeHandler.js +6 -3
- package/dist/browser/containerRegistryChallengeHandler.js.map +1 -1
- package/dist/browser/containerRegistryClient.js +42 -50
- package/dist/browser/containerRegistryClient.js.map +1 -1
- package/dist/browser/containerRegistryTokenCredential.js +9 -1
- package/dist/browser/containerRegistryTokenCredential.js.map +1 -1
- package/dist/browser/containerRepository.js +41 -46
- package/dist/browser/containerRepository.js.map +1 -1
- package/dist/browser/content/containerRegistryContentClient.js +34 -32
- package/dist/browser/content/containerRegistryContentClient.js.map +1 -1
- package/dist/browser/generated/generatedClient.js +12 -3
- package/dist/browser/generated/generatedClient.js.map +1 -1
- package/dist/browser/generated/generatedClientContext.js +9 -2
- package/dist/browser/generated/generatedClientContext.js.map +1 -1
- package/dist/browser/generated/models/mappers.js +63 -29
- package/dist/browser/generated/models/mappers.js.map +1 -1
- package/dist/browser/generated/operations/authentication.js +1 -0
- package/dist/browser/generated/operations/authentication.js.map +1 -1
- package/dist/browser/generated/operations/containerRegistry.js +1 -0
- package/dist/browser/generated/operations/containerRegistry.js.map +1 -1
- package/dist/browser/generated/operations/containerRegistryBlob.js +1 -0
- package/dist/browser/generated/operations/containerRegistryBlob.js.map +1 -1
- package/dist/browser/registryArtifact.js +69 -53
- package/dist/browser/registryArtifact.js.map +1 -1
- package/dist/browser/transformations.js +13 -3
- package/dist/browser/transformations.js.map +1 -1
- package/dist/browser/utils/helpers.js +19 -35
- package/dist/browser/utils/helpers.js.map +1 -1
- package/dist/browser/utils/retriableReadableStream.js +64 -56
- package/dist/browser/utils/retriableReadableStream.js.map +1 -1
- package/dist/browser/utils/tokenCycler.js +7 -6
- package/dist/browser/utils/tokenCycler.js.map +1 -1
- package/dist/commonjs/containerRegistryChallengeHandler.js +6 -3
- package/dist/commonjs/containerRegistryChallengeHandler.js.map +1 -1
- package/dist/commonjs/containerRegistryClient.js +42 -50
- package/dist/commonjs/containerRegistryClient.js.map +1 -1
- package/dist/commonjs/containerRegistryTokenCredential.js +9 -1
- package/dist/commonjs/containerRegistryTokenCredential.js.map +1 -1
- package/dist/commonjs/containerRepository.js +41 -46
- package/dist/commonjs/containerRepository.js.map +1 -1
- package/dist/commonjs/content/containerRegistryContentClient.js +34 -31
- package/dist/commonjs/content/containerRegistryContentClient.js.map +1 -1
- package/dist/commonjs/generated/generatedClient.js +12 -3
- package/dist/commonjs/generated/generatedClient.js.map +1 -1
- package/dist/commonjs/generated/generatedClientContext.js +9 -2
- package/dist/commonjs/generated/generatedClientContext.js.map +1 -1
- package/dist/commonjs/generated/models/mappers.js +63 -29
- package/dist/commonjs/generated/models/mappers.js.map +1 -1
- package/dist/commonjs/generated/operations/authentication.js +1 -0
- package/dist/commonjs/generated/operations/authentication.js.map +1 -1
- package/dist/commonjs/generated/operations/containerRegistry.js +1 -0
- package/dist/commonjs/generated/operations/containerRegistry.js.map +1 -1
- package/dist/commonjs/generated/operations/containerRegistryBlob.js +1 -0
- package/dist/commonjs/generated/operations/containerRegistryBlob.js.map +1 -1
- package/dist/commonjs/registryArtifact.js +69 -53
- package/dist/commonjs/registryArtifact.js.map +1 -1
- package/dist/commonjs/transformations.js +13 -3
- package/dist/commonjs/transformations.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/commonjs/utils/helpers.js +19 -35
- package/dist/commonjs/utils/helpers.js.map +1 -1
- package/dist/commonjs/utils/retriableReadableStream.js +64 -56
- package/dist/commonjs/utils/retriableReadableStream.js.map +1 -1
- package/dist/commonjs/utils/tokenCycler.js +7 -6
- package/dist/commonjs/utils/tokenCycler.js.map +1 -1
- package/dist/esm/containerRegistryChallengeHandler.js +6 -3
- package/dist/esm/containerRegistryChallengeHandler.js.map +1 -1
- package/dist/esm/containerRegistryClient.js +42 -50
- package/dist/esm/containerRegistryClient.js.map +1 -1
- package/dist/esm/containerRegistryTokenCredential.js +9 -1
- package/dist/esm/containerRegistryTokenCredential.js.map +1 -1
- package/dist/esm/containerRepository.js +41 -46
- package/dist/esm/containerRepository.js.map +1 -1
- package/dist/esm/content/containerRegistryContentClient.js +34 -32
- package/dist/esm/content/containerRegistryContentClient.js.map +1 -1
- package/dist/esm/generated/generatedClient.js +12 -3
- package/dist/esm/generated/generatedClient.js.map +1 -1
- package/dist/esm/generated/generatedClientContext.js +9 -2
- package/dist/esm/generated/generatedClientContext.js.map +1 -1
- package/dist/esm/generated/models/mappers.js +63 -29
- package/dist/esm/generated/models/mappers.js.map +1 -1
- package/dist/esm/generated/operations/authentication.js +1 -0
- package/dist/esm/generated/operations/authentication.js.map +1 -1
- package/dist/esm/generated/operations/containerRegistry.js +1 -0
- package/dist/esm/generated/operations/containerRegistry.js.map +1 -1
- package/dist/esm/generated/operations/containerRegistryBlob.js +1 -0
- package/dist/esm/generated/operations/containerRegistryBlob.js.map +1 -1
- package/dist/esm/registryArtifact.js +69 -53
- package/dist/esm/registryArtifact.js.map +1 -1
- package/dist/esm/transformations.js +13 -3
- package/dist/esm/transformations.js.map +1 -1
- package/dist/esm/utils/helpers.js +19 -35
- package/dist/esm/utils/helpers.js.map +1 -1
- package/dist/esm/utils/retriableReadableStream.js +64 -56
- package/dist/esm/utils/retriableReadableStream.js.map +1 -1
- package/dist/esm/utils/tokenCycler.js +7 -6
- package/dist/esm/utils/tokenCycler.js.map +1 -1
- package/dist/react-native/containerRegistryChallengeHandler.js +6 -3
- package/dist/react-native/containerRegistryChallengeHandler.js.map +1 -1
- package/dist/react-native/containerRegistryClient.js +42 -50
- package/dist/react-native/containerRegistryClient.js.map +1 -1
- package/dist/react-native/containerRegistryTokenCredential.js +9 -1
- package/dist/react-native/containerRegistryTokenCredential.js.map +1 -1
- package/dist/react-native/containerRepository.js +41 -46
- package/dist/react-native/containerRepository.js.map +1 -1
- package/dist/react-native/content/containerRegistryContentClient.js +34 -32
- package/dist/react-native/content/containerRegistryContentClient.js.map +1 -1
- package/dist/react-native/generated/generatedClient.js +12 -3
- package/dist/react-native/generated/generatedClient.js.map +1 -1
- package/dist/react-native/generated/generatedClientContext.js +9 -2
- package/dist/react-native/generated/generatedClientContext.js.map +1 -1
- package/dist/react-native/generated/models/mappers.js +63 -29
- package/dist/react-native/generated/models/mappers.js.map +1 -1
- package/dist/react-native/generated/operations/authentication.js +1 -0
- package/dist/react-native/generated/operations/authentication.js.map +1 -1
- package/dist/react-native/generated/operations/containerRegistry.js +1 -0
- package/dist/react-native/generated/operations/containerRegistry.js.map +1 -1
- package/dist/react-native/generated/operations/containerRegistryBlob.js +1 -0
- package/dist/react-native/generated/operations/containerRegistryBlob.js.map +1 -1
- package/dist/react-native/registryArtifact.js +69 -53
- package/dist/react-native/registryArtifact.js.map +1 -1
- package/dist/react-native/transformations.js +13 -3
- package/dist/react-native/transformations.js.map +1 -1
- package/dist/react-native/utils/helpers.js +19 -35
- package/dist/react-native/utils/helpers.js.map +1 -1
- package/dist/react-native/utils/retriableReadableStream.js +64 -56
- package/dist/react-native/utils/retriableReadableStream.js.map +1 -1
- package/dist/react-native/utils/tokenCycler.js +7 -6
- package/dist/react-native/utils/tokenCycler.js.map +1 -1
- package/package.json +2 -2
|
@@ -22,6 +22,10 @@ const fiveMinutesInMs = 5 * 60 * 1000;
|
|
|
22
22
|
*```
|
|
23
23
|
*/
|
|
24
24
|
export class ChallengeHandler {
|
|
25
|
+
credential;
|
|
26
|
+
options;
|
|
27
|
+
cycler;
|
|
28
|
+
cachedAcrAccessToken;
|
|
25
29
|
constructor(credential, options = {}) {
|
|
26
30
|
this.credential = credential;
|
|
27
31
|
this.options = options;
|
|
@@ -40,9 +44,8 @@ export class ChallengeHandler {
|
|
|
40
44
|
* Updates the authentication context based on the challenge.
|
|
41
45
|
*/
|
|
42
46
|
async authorizeRequestOnChallenge(options) {
|
|
43
|
-
var _a;
|
|
44
47
|
// Once we're here, we've completed Step 1.
|
|
45
|
-
const challenge =
|
|
48
|
+
const challenge = options.response?.headers.get("WWW-Authenticate");
|
|
46
49
|
if (!challenge) {
|
|
47
50
|
throw new Error("Failed to retrieve challenge from response headers");
|
|
48
51
|
}
|
|
@@ -65,7 +68,7 @@ export class ChallengeHandler {
|
|
|
65
68
|
}
|
|
66
69
|
else {
|
|
67
70
|
grantType = "refresh_token";
|
|
68
|
-
acrRefreshToken = (await this.cycler.getToken(scope,
|
|
71
|
+
acrRefreshToken = (await this.cycler.getToken(scope, { ...options, service })).token;
|
|
69
72
|
}
|
|
70
73
|
// Step 4: Send in acrRefreshToken and get back acrAccessToken
|
|
71
74
|
const acrAccessToken = await this.credential.tokenService.ExchangeAcrRefreshTokenForAcrAccessTokenAsync(acrRefreshToken, service, scope, grantType, this.options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerRegistryChallengeHandler.js","sourceRoot":"","sources":["../../src/containerRegistryChallengeHandler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAMxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,gBAAgB;
|
|
1
|
+
{"version":3,"file":"containerRegistryChallengeHandler.js","sourceRoot":"","sources":["../../src/containerRegistryChallengeHandler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAMxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,gBAAgB;IAKjB;IACA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AS,GAAG,UAAU,CAAC;YACvB,eAAe,GAAG,EAAE,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,SAAS,GAAG,eAAe,CAAC;YAC5B,eAAe,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACvF,CAAC;QAED,8DAA8D;QAC9D,MAAM,cAAc,GAClB,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,6CAA6C,CAC9E,eAAe,EACf,OAAO,EACP,KAAK,EACL,SAAS,EACT,IAAI,CAAC,OAAO,CACb,CAAC;QAEJ,gGAAgG;QAChG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,cAAc,EAAE,CAAC,CAAC;QAEzE,IAAI,CAAC,oBAAoB,GAAG,cAAc,CAAC;QAE3C,OAAO,IAAI,CAAC;IACd,CAAC;CACF","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"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
|
|
4
3
|
import { isTokenCredential } from "@azure/core-auth";
|
|
5
4
|
import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
|
|
6
5
|
import { logger } from "./logger.js";
|
|
@@ -15,8 +14,12 @@ const LATEST_API_VERSION = "2021-07-01";
|
|
|
15
14
|
* The client class used to interact with the Container Registry service.
|
|
16
15
|
*/
|
|
17
16
|
export class ContainerRegistryClient {
|
|
17
|
+
/**
|
|
18
|
+
* The Azure Container Registry endpoint.
|
|
19
|
+
*/
|
|
20
|
+
endpoint;
|
|
21
|
+
client;
|
|
18
22
|
constructor(endpoint, credentialOrOptions, clientOptions = {}) {
|
|
19
|
-
var _a, _b;
|
|
20
23
|
if (!endpoint) {
|
|
21
24
|
throw new Error("invalid endpoint");
|
|
22
25
|
}
|
|
@@ -28,16 +31,19 @@ export class ContainerRegistryClient {
|
|
|
28
31
|
options = clientOptions;
|
|
29
32
|
}
|
|
30
33
|
else {
|
|
31
|
-
options = credentialOrOptions
|
|
34
|
+
options = credentialOrOptions ?? {};
|
|
32
35
|
}
|
|
33
|
-
const internalPipelineOptions =
|
|
36
|
+
const internalPipelineOptions = {
|
|
37
|
+
...options,
|
|
38
|
+
loggingOptions: {
|
|
34
39
|
logger: logger.info,
|
|
35
40
|
// This array contains header names we want to log that are not already
|
|
36
41
|
// included as safe. Unknown/unsafe headers are logged as "<REDACTED>".
|
|
37
42
|
additionalAllowedQueryParameters: ["last", "n", "orderby", "digest"],
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const defaultScope = `${options.audience ?? "https://containerregistry.azure.net"}/.default`;
|
|
46
|
+
const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;
|
|
41
47
|
const authClient = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
|
|
42
48
|
this.client = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
|
|
43
49
|
this.client.pipeline.addPolicy(bearerTokenAuthenticationPolicy({
|
|
@@ -121,52 +127,38 @@ export class ContainerRegistryClient {
|
|
|
121
127
|
byPage: (settings = {}) => this.listRepositoriesPage(settings, options),
|
|
122
128
|
};
|
|
123
129
|
}
|
|
124
|
-
listRepositoryItems() {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
for (var _d = true, _e = __asyncValues(this.listRepositoriesPage({}, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
129
|
-
_c = _f.value;
|
|
130
|
-
_d = false;
|
|
131
|
-
const page = _c;
|
|
132
|
-
yield __await(yield* __asyncDelegator(__asyncValues(page)));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
136
|
-
finally {
|
|
137
|
-
try {
|
|
138
|
-
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
|
|
139
|
-
}
|
|
140
|
-
finally { if (e_1) throw e_1.error; }
|
|
141
|
-
}
|
|
142
|
-
});
|
|
130
|
+
async *listRepositoryItems(options = {}) {
|
|
131
|
+
for await (const page of this.listRepositoriesPage({}, options)) {
|
|
132
|
+
yield* page;
|
|
133
|
+
}
|
|
143
134
|
}
|
|
144
|
-
listRepositoriesPage(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
135
|
+
async *listRepositoriesPage(continuationState, options = {}) {
|
|
136
|
+
if (!continuationState.continuationToken) {
|
|
137
|
+
const optionsComplete = {
|
|
138
|
+
...options,
|
|
139
|
+
n: continuationState.maxPageSize,
|
|
140
|
+
};
|
|
141
|
+
const currentPage = await this.client.containerRegistry.getRepositories(optionsComplete);
|
|
142
|
+
continuationState.continuationToken = extractNextLink(currentPage.link);
|
|
143
|
+
if (currentPage.repositories) {
|
|
144
|
+
const array = currentPage.repositories;
|
|
145
|
+
yield Object.defineProperty(array, "continuationToken", {
|
|
146
|
+
value: continuationState.continuationToken,
|
|
147
|
+
enumerable: true,
|
|
148
|
+
});
|
|
157
149
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
150
|
+
}
|
|
151
|
+
while (continuationState.continuationToken) {
|
|
152
|
+
const currentPage = await this.client.containerRegistry.getRepositoriesNext(continuationState.continuationToken, options);
|
|
153
|
+
continuationState.continuationToken = extractNextLink(currentPage.link);
|
|
154
|
+
if (currentPage.repositories) {
|
|
155
|
+
const array = currentPage.repositories;
|
|
156
|
+
yield Object.defineProperty(array, "continuationToken", {
|
|
157
|
+
value: continuationState.continuationToken,
|
|
158
|
+
enumerable: true,
|
|
159
|
+
});
|
|
168
160
|
}
|
|
169
|
-
}
|
|
161
|
+
}
|
|
170
162
|
}
|
|
171
163
|
}
|
|
172
164
|
//# sourceMappingURL=containerRegistryClient.js.map
|
|
@@ -1 +1 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H,CAAC;KAAA;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\n\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nimport { logger } from \"./logger.js\";\nimport { GeneratedClient } from \"./generated/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport type { RepositoryPageResponse } from \"./models.js\";\nimport { extractNextLink } from \"./utils/helpers.js\";\nimport { ChallengeHandler } from \"./containerRegistryChallengeHandler.js\";\nimport type { ContainerRepository, DeleteRepositoryOptions } from \"./containerRepository.js\";\nimport { ContainerRepositoryImpl } from \"./containerRepository.js\";\nimport type { RegistryArtifact } from \"./registryArtifact.js\";\nimport { ContainerRegistryRefreshTokenCredential } from \"./containerRegistryTokenCredential.js\";\n\nconst LATEST_API_VERSION = \"2021-07-01\";\n\n/**\n * Client options used to configure Container Registry Repository API requests.\n */\nexport interface ContainerRegistryClientOptions extends CommonClientOptions {\n /**\n * Gets or sets the audience to use for authentication with Azure Active Directory.\n * The authentication scope will be set from this audience.\n * See {@link KnownContainerRegistryAudience} for known audience values.\n */\n audience?: string;\n /**\n * The version of service API to make calls against.\n */\n serviceVersion?: \"2021-07-01\";\n}\n\n/**\n * Options for the `listRepositories` method of `ContainerRegistryClient`.\n */\nexport interface ListRepositoriesOptions extends OperationOptions {}\n\n/**\n * The client class used to interact with the Container Registry service.\n */\nexport class ContainerRegistryClient {\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly endpoint: string;\n\n private client: GeneratedClient;\n\n /**\n * Creates an instance of a ContainerRegistryClient.\n *\n * Example usage:\n * ```ts snippet:ReadmeSampleCreateClient_Node\n * import { ContainerRegistryClient, KnownContainerRegistryAudience } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * // Create a ContainerRegistryClient that will authenticate through Active Directory\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {\n * audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,\n * });\n * ```\n * @param endpoint - the URL endpoint of the container registry\n * @param credential - used to authenticate requests to the service\n * @param options - optional configuration used to send requests to the service\n */\n constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: ContainerRegistryClientOptions,\n );\n\n /**\n * Creates an instance of a ContainerRegistryClient to interact with\n * an Azure Container Registry that has anonymous pull access enabled.\n * Only operations that support anonymous access are enabled. Other service\n * methods will throw errors.\n *\n * Example usage:\n * ```ts snippet:ReadmeSampleCreateClient_Anonymous\n * import { ContainerRegistryClient, KnownContainerRegistryAudience } from \"@azure/container-registry\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * // Create a new ContainerRegistryClient for anonymous access\n * const client = new ContainerRegistryClient(endpoint, {\n * audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,\n * });\n * ```\n * @param endpoint - the URL endpoint of the container registry\n * @param options - optional configuration used to send requests to the service\n */\n constructor(endpoint: string, options?: ContainerRegistryClientOptions);\n\n constructor(\n endpoint: string,\n credentialOrOptions?: TokenCredential | ContainerRegistryClientOptions,\n clientOptions: ContainerRegistryClientOptions = {},\n ) {\n if (!endpoint) {\n throw new Error(\"invalid endpoint\");\n }\n\n this.endpoint = endpoint;\n\n let credential: TokenCredential | undefined;\n let options: ContainerRegistryClientOptions | undefined;\n if (isTokenCredential(credentialOrOptions)) {\n credential = credentialOrOptions;\n options = clientOptions;\n } else {\n options = credentialOrOptions ?? {};\n }\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n // This array contains header names we want to log that are not already\n // included as safe. Unknown/unsafe headers are logged as \"<REDACTED>\".\n additionalAllowedQueryParameters: [\"last\", \"n\", \"orderby\", \"digest\"],\n },\n };\n\n const defaultScope = `${options.audience ?? \"https://containerregistry.azure.net\"}/.default`;\n const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;\n const authClient = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: [defaultScope],\n challengeCallbacks: new ChallengeHandler(\n new ContainerRegistryRefreshTokenCredential(authClient, defaultScope, credential),\n ),\n }),\n );\n }\n\n /**\n * Deletes the repository identified by the given name and all associated artifacts.\n *\n * @param repositoryName - the name of repository to delete\n * @param options - optional configuration for the operation\n */\n public async deleteRepository(\n repositoryName: string,\n options: DeleteRepositoryOptions = {},\n ): Promise<void> {\n if (!repositoryName) {\n throw new Error(\"invalid repositoryName\");\n }\n\n return tracingClient.withSpan(\n \"ContainerRegistryClient.deleteRepository\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteRepository(repositoryName, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an instance of {@link RegistryArtifact} for calling service methods related to the artifact specified by `repositoryName` and `tagOrDigest`.\n *\n * @param repositoryName - the name of repository\n * @param tagOrDigest - tag or digest of the artifact to retrieve\n */\n public getArtifact(repositoryName: string, tagOrDigest: string): RegistryArtifact {\n if (!repositoryName) {\n throw new Error(\"invalid repositoryName\");\n }\n if (!tagOrDigest) {\n throw new Error(\"invalid tagOrDigest\");\n }\n\n return new ContainerRepositoryImpl(this.endpoint, repositoryName, this.client).getArtifact(\n tagOrDigest,\n );\n }\n\n /**\n * Returns an instance of {@link ContainerRepository} for calling service methods related to the repository specified by `repositoryName`.\n *\n * @param repositoryName - the name of repository\n */\n public getRepository(repositoryName: string): ContainerRepository {\n if (!repositoryName) {\n throw new Error(\"invalid repositoryName\");\n }\n\n return new ContainerRepositoryImpl(this.endpoint, repositoryName, this.client);\n }\n\n /**\n * Returns an async iterable iterator to list names of repositories in this registry.\n *\n * Example usage:\n * ```ts snippet:SampleReadmeListRepositories\n * import { ContainerRegistryClient, KnownContainerRegistryAudience } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {\n * audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,\n * });\n *\n * const iterator = client.listRepositoryNames();\n * for await (const repository of iterator) {\n * console.log(` repository: ${repository}`);\n * }\n * ```\n *\n * @param options - The options for the request\n */\n public listRepositoryNames(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: ListRepositoriesOptions = {},\n ): PagedAsyncIterableIterator<string, RepositoryPageResponse> {\n const iter = this.listRepositoryItems(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.listRepositoriesPage(settings, options),\n };\n }\n\n private async *listRepositoryItems(\n options: ListRepositoriesOptions = {},\n ): AsyncIterableIterator<string> {\n for await (const page of this.listRepositoriesPage({}, options)) {\n yield* page;\n }\n }\n\n private async *listRepositoriesPage(\n continuationState: PageSettings,\n options: ListRepositoriesOptions = {},\n ): AsyncIterableIterator<RepositoryPageResponse> {\n if (!continuationState.continuationToken) {\n const optionsComplete = {\n ...options,\n n: continuationState.maxPageSize,\n };\n const currentPage = await this.client.containerRegistry.getRepositories(optionsComplete);\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.repositories) {\n const array = currentPage.repositories;\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n while (continuationState.continuationToken) {\n const currentPage = await this.client.containerRegistry.getRepositoriesNext(\n continuationState.continuationToken,\n options,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.repositories) {\n const array = currentPage.repositories;\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"containerRegistryClient.js","sourceRoot":"","sources":["../../src/containerRegistryClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAK5E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,uCAAuC,EAAE,MAAM,uCAAuC,CAAC;AAEhG,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAuBxC;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAClC;;OAEG;IACa,QAAQ,CAAS;IAEzB,MAAM,CAAkB;IA+ChC,YACE,QAAgB,EAChB,mBAAsE,EACtE,gBAAgD,EAAE;QAElD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,UAAuC,CAAC;QAC5C,IAAI,OAAmD,CAAC;QACxD,IAAI,iBAAiB,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC3C,UAAU,GAAG,mBAAmB,CAAC;YACjC,OAAO,GAAG,aAAa,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,mBAAmB,IAAI,EAAE,CAAC;QACtC,CAA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microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport type { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\n\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nimport { logger } from \"./logger.js\";\nimport { GeneratedClient } from \"./generated/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport type { RepositoryPageResponse } from \"./models.js\";\nimport { extractNextLink } from \"./utils/helpers.js\";\nimport { ChallengeHandler } from \"./containerRegistryChallengeHandler.js\";\nimport type { ContainerRepository, DeleteRepositoryOptions } from \"./containerRepository.js\";\nimport { ContainerRepositoryImpl } from \"./containerRepository.js\";\nimport type { RegistryArtifact } from \"./registryArtifact.js\";\nimport { ContainerRegistryRefreshTokenCredential } from \"./containerRegistryTokenCredential.js\";\n\nconst LATEST_API_VERSION = \"2021-07-01\";\n\n/**\n * Client options used to configure Container Registry Repository API requests.\n */\nexport interface ContainerRegistryClientOptions extends CommonClientOptions {\n /**\n * Gets or sets the audience to use for authentication with Azure Active Directory.\n * The authentication scope will be set from this audience.\n * See {@link KnownContainerRegistryAudience} for known audience values.\n */\n audience?: string;\n /**\n * The version of service API to make calls against.\n */\n serviceVersion?: \"2021-07-01\";\n}\n\n/**\n * Options for the `listRepositories` method of `ContainerRegistryClient`.\n */\nexport interface ListRepositoriesOptions extends OperationOptions {}\n\n/**\n * The client class used to interact with the Container Registry service.\n */\nexport class ContainerRegistryClient {\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly endpoint: string;\n\n private client: GeneratedClient;\n\n /**\n * Creates an instance of a ContainerRegistryClient.\n *\n * Example usage:\n * ```ts snippet:ReadmeSampleCreateClient_Node\n * import { ContainerRegistryClient, KnownContainerRegistryAudience } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * // Create a ContainerRegistryClient that will authenticate through Active Directory\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {\n * audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,\n * });\n * ```\n * @param endpoint - the URL endpoint of the container registry\n * @param credential - used to authenticate requests to the service\n * @param options - optional configuration used to send requests to the service\n */\n constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: ContainerRegistryClientOptions,\n );\n\n /**\n * Creates an instance of a ContainerRegistryClient to interact with\n * an Azure Container Registry that has anonymous pull access enabled.\n * Only operations that support anonymous access are enabled. Other service\n * methods will throw errors.\n *\n * Example usage:\n * ```ts snippet:ReadmeSampleCreateClient_Anonymous\n * import { ContainerRegistryClient, KnownContainerRegistryAudience } from \"@azure/container-registry\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * // Create a new ContainerRegistryClient for anonymous access\n * const client = new ContainerRegistryClient(endpoint, {\n * audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,\n * });\n * ```\n * @param endpoint - the URL endpoint of the container registry\n * @param options - optional configuration used to send requests to the service\n */\n constructor(endpoint: string, options?: ContainerRegistryClientOptions);\n\n constructor(\n endpoint: string,\n credentialOrOptions?: TokenCredential | ContainerRegistryClientOptions,\n clientOptions: ContainerRegistryClientOptions = {},\n ) {\n if (!endpoint) {\n throw new Error(\"invalid endpoint\");\n }\n\n this.endpoint = endpoint;\n\n let credential: TokenCredential | undefined;\n let options: ContainerRegistryClientOptions | undefined;\n if (isTokenCredential(credentialOrOptions)) {\n credential = credentialOrOptions;\n options = clientOptions;\n } else {\n options = credentialOrOptions ?? {};\n }\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n // This array contains header names we want to log that are not already\n // included as safe. Unknown/unsafe headers are logged as \"<REDACTED>\".\n additionalAllowedQueryParameters: [\"last\", \"n\", \"orderby\", \"digest\"],\n },\n };\n\n const defaultScope = `${options.audience ?? \"https://containerregistry.azure.net\"}/.default`;\n const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;\n const authClient = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: [defaultScope],\n challengeCallbacks: new ChallengeHandler(\n new ContainerRegistryRefreshTokenCredential(authClient, defaultScope, credential),\n ),\n }),\n );\n }\n\n /**\n * Deletes the repository identified by the given name and all associated artifacts.\n *\n * @param repositoryName - the name of repository to delete\n * @param options - optional configuration for the operation\n */\n public async deleteRepository(\n repositoryName: string,\n options: DeleteRepositoryOptions = {},\n ): Promise<void> {\n if (!repositoryName) {\n throw new Error(\"invalid repositoryName\");\n }\n\n return tracingClient.withSpan(\n \"ContainerRegistryClient.deleteRepository\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteRepository(repositoryName, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an instance of {@link RegistryArtifact} for calling service methods related to the artifact specified by `repositoryName` and `tagOrDigest`.\n *\n * @param repositoryName - the name of repository\n * @param tagOrDigest - tag or digest of the artifact to retrieve\n */\n public getArtifact(repositoryName: string, tagOrDigest: string): RegistryArtifact {\n if (!repositoryName) {\n throw new Error(\"invalid repositoryName\");\n }\n if (!tagOrDigest) {\n throw new Error(\"invalid tagOrDigest\");\n }\n\n return new ContainerRepositoryImpl(this.endpoint, repositoryName, this.client).getArtifact(\n tagOrDigest,\n );\n }\n\n /**\n * Returns an instance of {@link ContainerRepository} for calling service methods related to the repository specified by `repositoryName`.\n *\n * @param repositoryName - the name of repository\n */\n public getRepository(repositoryName: string): ContainerRepository {\n if (!repositoryName) {\n throw new Error(\"invalid repositoryName\");\n }\n\n return new ContainerRepositoryImpl(this.endpoint, repositoryName, this.client);\n }\n\n /**\n * Returns an async iterable iterator to list names of repositories in this registry.\n *\n * Example usage:\n * ```ts snippet:SampleReadmeListRepositories\n * import { ContainerRegistryClient, KnownContainerRegistryAudience } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {\n * audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,\n * });\n *\n * const iterator = client.listRepositoryNames();\n * for await (const repository of iterator) {\n * console.log(` repository: ${repository}`);\n * }\n * ```\n *\n * @param options - The options for the request\n */\n public listRepositoryNames(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: ListRepositoriesOptions = {},\n ): PagedAsyncIterableIterator<string, RepositoryPageResponse> {\n const iter = this.listRepositoryItems(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.listRepositoriesPage(settings, options),\n };\n }\n\n private async *listRepositoryItems(\n options: ListRepositoriesOptions = {},\n ): AsyncIterableIterator<string> {\n for await (const page of this.listRepositoriesPage({}, options)) {\n yield* page;\n }\n }\n\n private async *listRepositoriesPage(\n continuationState: PageSettings,\n options: ListRepositoriesOptions = {},\n ): AsyncIterableIterator<RepositoryPageResponse> {\n if (!continuationState.continuationToken) {\n const optionsComplete = {\n ...options,\n n: continuationState.maxPageSize,\n };\n const currentPage = await this.client.containerRegistry.getRepositories(optionsComplete);\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.repositories) {\n const array = currentPage.repositories;\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n while (continuationState.continuationToken) {\n const currentPage = await this.client.containerRegistry.getRepositoriesNext(\n continuationState.continuationToken,\n options,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.repositories) {\n const array = currentPage.repositories;\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n }\n}\n"]}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { base64decode } from "./utils/base64.js";
|
|
4
4
|
export class ContainerRegistryRefreshTokenCredential {
|
|
5
|
+
authenticationScope;
|
|
6
|
+
credential;
|
|
7
|
+
tokenService;
|
|
8
|
+
isAnonymousAccess;
|
|
5
9
|
constructor(authClient, authenticationScope, credential) {
|
|
6
10
|
this.authenticationScope = authenticationScope;
|
|
7
11
|
this.credential = credential;
|
|
@@ -20,11 +24,15 @@ export class ContainerRegistryRefreshTokenCredential {
|
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
export class ContainerRegistryTokenService {
|
|
27
|
+
authClient;
|
|
23
28
|
constructor(authClient) {
|
|
24
29
|
this.authClient = authClient;
|
|
25
30
|
}
|
|
26
31
|
async ExchangeAadAccessTokenForAcrRefreshTokenAsync(aadAccessToken, service, options) {
|
|
27
|
-
const acrRefreshToken = await this.authClient.authentication.exchangeAadAccessTokenForAcrRefreshToken("access_token", service,
|
|
32
|
+
const acrRefreshToken = await this.authClient.authentication.exchangeAadAccessTokenForAcrRefreshToken("access_token", service, {
|
|
33
|
+
...options,
|
|
34
|
+
accessToken: aadAccessToken,
|
|
35
|
+
});
|
|
28
36
|
if (!acrRefreshToken.refreshToken) {
|
|
29
37
|
throw new Error("Failed to exchange AAD access token for an ACR refresh token.");
|
|
30
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerRegistryTokenCredential.js","sourceRoot":"","sources":["../../src/containerRegistryTokenCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMjD,MAAM,OAAO,uCAAuC;
|
|
1
|
+
{"version":3,"file":"containerRegistryTokenCredential.js","sourceRoot":"","sources":["../../src/containerRegistryTokenCredential.ts"],"names":[],"mappings":"AAAA,uCA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ourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport type { GeneratedClient } from \"./generated/index.js\";\nimport { base64decode } from \"./utils/base64.js\";\n\nexport interface ContainerRegistryGetTokenOptions extends GetTokenOptions {\n service: string;\n}\n\nexport class ContainerRegistryRefreshTokenCredential implements TokenCredential {\n readonly tokenService: ContainerRegistryTokenService;\n readonly isAnonymousAccess: boolean;\n constructor(\n authClient: GeneratedClient,\n private authenticationScope: string,\n private credential?: TokenCredential,\n ) {\n this.tokenService = new ContainerRegistryTokenService(authClient);\n this.isAnonymousAccess = !this.credential;\n }\n\n async getToken(\n _scopes: string | string[],\n options: ContainerRegistryGetTokenOptions,\n ): Promise<AccessToken | null> {\n if (!this.credential) {\n return null;\n }\n\n const aadToken = await this.credential.getToken(this.authenticationScope, options);\n if (!aadToken) {\n throw new Error(\"Failed to retrieve AAD token.\");\n }\n\n return this.tokenService.ExchangeAadAccessTokenForAcrRefreshTokenAsync(\n aadToken.token,\n options.service,\n options,\n );\n }\n}\n\nexport class ContainerRegistryTokenService {\n constructor(private authClient: GeneratedClient) {}\n\n async ExchangeAadAccessTokenForAcrRefreshTokenAsync(\n aadAccessToken: string,\n service: string,\n options: GetTokenOptions,\n ): Promise<AccessToken> {\n const acrRefreshToken =\n await this.authClient.authentication.exchangeAadAccessTokenForAcrRefreshToken(\n \"access_token\",\n service,\n {\n ...options,\n accessToken: aadAccessToken,\n },\n );\n if (!acrRefreshToken.refreshToken) {\n throw new Error(\"Failed to exchange AAD access token for an ACR refresh token.\");\n }\n\n // ACR refresh token expires after three hours\n const jwtParts = acrRefreshToken.refreshToken.split(\".\");\n if (jwtParts.length < 3) {\n throw new Error(\"Invalid JWT structure from ACR refresh token.\");\n }\n if (!jwtParts[1]) {\n throw new Error(\"Invalid JWT payload.\");\n }\n\n const jwtPayload = JSON.parse(base64decode(jwtParts[1]));\n if (!jwtPayload.exp) {\n throw new Error(\"Invalid JWT payload structure. No expiration.\");\n }\n\n // JWT expiry is in seconds\n const expiry = Number.parseInt(jwtPayload.exp) * 1000;\n return {\n token: acrRefreshToken.refreshToken,\n expiresOnTimestamp: expiry,\n };\n }\n\n async ExchangeAcrRefreshTokenForAcrAccessTokenAsync(\n acrRefreshToken: string,\n service: string,\n scope: string,\n grantType: \"refresh_token\" | \"password\",\n options: GetTokenOptions,\n ): Promise<string> {\n const acrAccessToken =\n await this.authClient.authentication.exchangeAcrRefreshTokenForAcrAccessToken(\n service,\n scope,\n acrRefreshToken,\n grantType,\n options,\n );\n\n if (!acrAccessToken.accessToken) {\n throw new Error(\"Failed to exchange ACR refresh token for an ACR access token\");\n }\n return acrAccessToken.accessToken;\n }\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
|
|
4
3
|
import { tracingClient } from "./tracing.js";
|
|
5
4
|
import { RegistryArtifactImpl } from "./registryArtifact.js";
|
|
6
5
|
import { toArtifactManifestProperties, toServiceManifestOrderBy } from "./transformations.js";
|
|
@@ -10,6 +9,15 @@ import { extractNextLink } from "./utils/helpers.js";
|
|
|
10
9
|
* @internal
|
|
11
10
|
*/
|
|
12
11
|
export class ContainerRepositoryImpl {
|
|
12
|
+
client;
|
|
13
|
+
/**
|
|
14
|
+
* The Azure Container Registry endpoint.
|
|
15
|
+
*/
|
|
16
|
+
registryEndpoint;
|
|
17
|
+
/**
|
|
18
|
+
* Repository name.
|
|
19
|
+
*/
|
|
20
|
+
name;
|
|
13
21
|
/**
|
|
14
22
|
* Creates an instance of a ContainerRepository.
|
|
15
23
|
* @param registryEndpoint - the URL to the Container Registry endpoint
|
|
@@ -80,7 +88,7 @@ export class ContainerRepositoryImpl {
|
|
|
80
88
|
canList: options.canList,
|
|
81
89
|
canRead: options.canRead,
|
|
82
90
|
};
|
|
83
|
-
return tracingClient.withSpan("ContainerRepositoryImpl.updateProperties",
|
|
91
|
+
return tracingClient.withSpan("ContainerRepositoryImpl.updateProperties", { ...options, value }, (updatedOptions) => {
|
|
84
92
|
return this.client.containerRegistry.updateProperties(this.name, updatedOptions);
|
|
85
93
|
});
|
|
86
94
|
}
|
|
@@ -119,53 +127,40 @@ export class ContainerRepositoryImpl {
|
|
|
119
127
|
byPage: (settings = {}) => this.listManifestsPage(settings, options),
|
|
120
128
|
};
|
|
121
129
|
}
|
|
122
|
-
listManifestsItems() {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
for (var _d = true, _e = __asyncValues(this.listManifestsPage({}, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
127
|
-
_c = _f.value;
|
|
128
|
-
_d = false;
|
|
129
|
-
const page = _c;
|
|
130
|
-
yield __await(yield* __asyncDelegator(__asyncValues(page)));
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
134
|
-
finally {
|
|
135
|
-
try {
|
|
136
|
-
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
|
|
137
|
-
}
|
|
138
|
-
finally { if (e_1) throw e_1.error; }
|
|
139
|
-
}
|
|
140
|
-
});
|
|
130
|
+
async *listManifestsItems(options = {}) {
|
|
131
|
+
for await (const page of this.listManifestsPage({}, options)) {
|
|
132
|
+
yield* page;
|
|
133
|
+
}
|
|
141
134
|
}
|
|
142
|
-
listManifestsPage(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
135
|
+
async *listManifestsPage(continuationState, options = {}) {
|
|
136
|
+
const orderby = toServiceManifestOrderBy(options.order);
|
|
137
|
+
if (!continuationState.continuationToken) {
|
|
138
|
+
const optionsComplete = {
|
|
139
|
+
...options,
|
|
140
|
+
n: continuationState.maxPageSize,
|
|
141
|
+
orderby,
|
|
142
|
+
};
|
|
143
|
+
const currentPage = await this.client.containerRegistry.getManifests(this.name, optionsComplete);
|
|
144
|
+
continuationState.continuationToken = extractNextLink(currentPage.link);
|
|
145
|
+
if (currentPage.manifests) {
|
|
146
|
+
const array = currentPage.manifests.map((t) => toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer));
|
|
147
|
+
yield Object.defineProperty(array, "continuationToken", {
|
|
148
|
+
value: continuationState.continuationToken,
|
|
149
|
+
enumerable: true,
|
|
150
|
+
});
|
|
156
151
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
152
|
+
}
|
|
153
|
+
while (continuationState.continuationToken) {
|
|
154
|
+
const currentPage = await this.client.containerRegistry.getManifestsNext(this.name, continuationState.continuationToken, options);
|
|
155
|
+
continuationState.continuationToken = extractNextLink(currentPage.link);
|
|
156
|
+
if (currentPage.manifests) {
|
|
157
|
+
const array = currentPage.manifests.map((t) => toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer));
|
|
158
|
+
yield Object.defineProperty(array, "continuationToken", {
|
|
159
|
+
value: continuationState.continuationToken,
|
|
160
|
+
enumerable: true,
|
|
161
|
+
});
|
|
167
162
|
}
|
|
168
|
-
}
|
|
163
|
+
}
|
|
169
164
|
}
|
|
170
165
|
}
|
|
171
166
|
//# sourceMappingURL=containerRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerRepository.js","sourceRoot":"","sources":["../../src/containerRepository.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAQlC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQ7C,OAAO,EAAE,oBAAoB,EAAE,MAA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oBAC1B,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5C,4BAA4B,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,mBAAoB,CAAC,CAC7E,CAAC;oBACF,oBAAM,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE;wBACtD,KAAK,EAAE,iBAAiB,CAAC,iBAAiB;wBAC1C,UAAU,EAAE,IAAI;qBACjB,CAAC,CAAA,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;KAAA;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport type { OperationOptions } from \"@azure/core-client\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nimport type { GeneratedClient, RepositoryWriteableProperties } from \"./generated/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport type {\n ArtifactManifestOrder,\n ContainerRepositoryProperties,\n ArtifactManifestProperties,\n ManifestPageResponse,\n} from \"./models.js\";\nimport type { RegistryArtifact } from \"./registryArtifact.js\";\nimport { RegistryArtifactImpl } from \"./registryArtifact.js\";\nimport { toArtifactManifestProperties, toServiceManifestOrderBy } from \"./transformations.js\";\nimport { extractNextLink } from \"./utils/helpers.js\";\n\n/**\n * Options for delete repository operation.\n */\nexport interface DeleteRepositoryOptions extends OperationOptions {}\n/**\n * Options for the `listRegistryArtifacts` method of `ContainerRepository`.\n */\nexport interface ListManifestPropertiesOptions extends OperationOptions {\n /** order in which the manifest properties are returned */\n order?: ArtifactManifestOrder;\n}\n/**\n * Options for the `getProperties` method of `ContainerRepository`.\n */\nexport interface GetRepositoryPropertiesOptions extends OperationOptions {}\n/**\n * Options for the `setProperties` method of `ContainerRepository`.\n */\nexport interface UpdateRepositoryPropertiesOptions extends OperationOptions {\n /** Whether or not this repository can be deleted */\n canDelete?: boolean;\n /** Whether or not this repository can be written to */\n canWrite?: boolean;\n /** Whether or not include this repository when listing repositories */\n canList?: boolean;\n /** Whether or not this repository can be read */\n canRead?: boolean;\n}\n\n/**\n * A `repository` in a container registry is a logical grouping of images or artifacts that share the same name. For example,\n * different versions of a `hello-world` application could have tags `v1` and `v2`, and be grouped by the repository `hello-world`.\n *\n * The {@link ContainerRepository} interface is a helper that groups information and operations about a repository in this\n * container registry.\n */\nexport interface ContainerRepository {\n /**\n * The Azure Container Registry endpoint.\n */\n readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n readonly name: string;\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n delete(options?: DeleteRepositoryOptions): Promise<void>;\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n getArtifact(tagOrDigest: string): RegistryArtifact;\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n getProperties(options?: GetRepositoryPropertiesOptions): Promise<ContainerRepositoryProperties>;\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties>;\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n listManifestProperties(\n options?: ListManifestPropertiesOptions,\n ): PagedAsyncIterableIterator<ArtifactManifestProperties>;\n}\n\n/**\n * The client class used to interact with the Container Registry service.\n * @internal\n */\nexport class ContainerRepositoryImpl {\n private readonly client: GeneratedClient;\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n public readonly name: string;\n\n /**\n * Creates an instance of a ContainerRepository.\n * @param registryEndpoint - the URL to the Container Registry endpoint\n * @param name - the name of the repository\n * @param client - the generated client that interacts with service\n */\n constructor(registryEndpoint: string, name: string, client: GeneratedClient) {\n this.registryEndpoint = registryEndpoint;\n this.name = name;\n\n this.client = client;\n }\n\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n public async delete(options: DeleteRepositoryOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.delete\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteRepository(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n public getArtifact(tagOrDigest: string): RegistryArtifact {\n if (!tagOrDigest) {\n throw new Error(\"invalid tagOrDigest\");\n }\n return new RegistryArtifactImpl(this.registryEndpoint, this.name, tagOrDigest, this.client);\n }\n\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n public async getProperties(\n options: GetRepositoryPropertiesOptions = {},\n ): Promise<ContainerRepositoryProperties> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.getProperties\",\n options,\n (updatedOptions) => {\n return this.client.containerRegistry.getProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n public async updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties> {\n const value: RepositoryWriteableProperties = {\n canDelete: options.canDelete,\n canWrite: options.canWrite,\n canList: options.canList,\n canRead: options.canRead,\n };\n\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.updateProperties\",\n { ...options, value },\n (updatedOptions) => {\n return this.client.containerRegistry.updateProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n public listManifestProperties(\n options: ListManifestPropertiesOptions = {},\n ): PagedAsyncIterableIterator<ArtifactManifestProperties, ManifestPageResponse> {\n const iter = this.listManifestsItems(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.listManifestsPage(settings, options),\n };\n }\n\n private async *listManifestsItems(\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ArtifactManifestProperties> {\n for await (const page of this.listManifestsPage({}, options)) {\n yield* page;\n }\n }\n\n private async *listManifestsPage(\n continuationState: PageSettings,\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ManifestPageResponse> {\n const orderby = toServiceManifestOrderBy(options.order);\n if (!continuationState.continuationToken) {\n const optionsComplete = {\n ...options,\n n: continuationState.maxPageSize,\n orderby,\n };\n const currentPage = await this.client.containerRegistry.getManifests(\n this.name,\n optionsComplete,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n while (continuationState.continuationToken) {\n const currentPage = await this.client.containerRegistry.getManifestsNext(\n this.name,\n continuationState.continuationToken,\n options,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"containerRepository.js","sourceRoot":"","sources":["../../src/containerRepository.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQ7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,C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AK,GAAG,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5C,4BAA4B,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,mBAAoB,CAAC,CAC7E,CAAC;gBACF,MAAM,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE;oBACtD,KAAK,EAAE,iBAAiB,CAAC,iBAAiB;oBAC1C,UAAU,EAAE,IAAI;iBACjB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport type { OperationOptions } from \"@azure/core-client\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nimport type { GeneratedClient, RepositoryWriteableProperties } from \"./generated/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport type {\n ArtifactManifestOrder,\n ContainerRepositoryProperties,\n ArtifactManifestProperties,\n ManifestPageResponse,\n} from \"./models.js\";\nimport type { RegistryArtifact } from \"./registryArtifact.js\";\nimport { RegistryArtifactImpl } from \"./registryArtifact.js\";\nimport { toArtifactManifestProperties, toServiceManifestOrderBy } from \"./transformations.js\";\nimport { extractNextLink } from \"./utils/helpers.js\";\n\n/**\n * Options for delete repository operation.\n */\nexport interface DeleteRepositoryOptions extends OperationOptions {}\n/**\n * Options for the `listRegistryArtifacts` method of `ContainerRepository`.\n */\nexport interface ListManifestPropertiesOptions extends OperationOptions {\n /** order in which the manifest properties are returned */\n order?: ArtifactManifestOrder;\n}\n/**\n * Options for the `getProperties` method of `ContainerRepository`.\n */\nexport interface GetRepositoryPropertiesOptions extends OperationOptions {}\n/**\n * Options for the `setProperties` method of `ContainerRepository`.\n */\nexport interface UpdateRepositoryPropertiesOptions extends OperationOptions {\n /** Whether or not this repository can be deleted */\n canDelete?: boolean;\n /** Whether or not this repository can be written to */\n canWrite?: boolean;\n /** Whether or not include this repository when listing repositories */\n canList?: boolean;\n /** Whether or not this repository can be read */\n canRead?: boolean;\n}\n\n/**\n * A `repository` in a container registry is a logical grouping of images or artifacts that share the same name. For example,\n * different versions of a `hello-world` application could have tags `v1` and `v2`, and be grouped by the repository `hello-world`.\n *\n * The {@link ContainerRepository} interface is a helper that groups information and operations about a repository in this\n * container registry.\n */\nexport interface ContainerRepository {\n /**\n * The Azure Container Registry endpoint.\n */\n readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n readonly name: string;\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n delete(options?: DeleteRepositoryOptions): Promise<void>;\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n getArtifact(tagOrDigest: string): RegistryArtifact;\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n getProperties(options?: GetRepositoryPropertiesOptions): Promise<ContainerRepositoryProperties>;\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties>;\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n listManifestProperties(\n options?: ListManifestPropertiesOptions,\n ): PagedAsyncIterableIterator<ArtifactManifestProperties>;\n}\n\n/**\n * The client class used to interact with the Container Registry service.\n * @internal\n */\nexport class ContainerRepositoryImpl {\n private readonly client: GeneratedClient;\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n public readonly name: string;\n\n /**\n * Creates an instance of a ContainerRepository.\n * @param registryEndpoint - the URL to the Container Registry endpoint\n * @param name - the name of the repository\n * @param client - the generated client that interacts with service\n */\n constructor(registryEndpoint: string, name: string, client: GeneratedClient) {\n this.registryEndpoint = registryEndpoint;\n this.name = name;\n\n this.client = client;\n }\n\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n public async delete(options: DeleteRepositoryOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.delete\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteRepository(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n public getArtifact(tagOrDigest: string): RegistryArtifact {\n if (!tagOrDigest) {\n throw new Error(\"invalid tagOrDigest\");\n }\n return new RegistryArtifactImpl(this.registryEndpoint, this.name, tagOrDigest, this.client);\n }\n\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n public async getProperties(\n options: GetRepositoryPropertiesOptions = {},\n ): Promise<ContainerRepositoryProperties> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.getProperties\",\n options,\n (updatedOptions) => {\n return this.client.containerRegistry.getProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n public async updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties> {\n const value: RepositoryWriteableProperties = {\n canDelete: options.canDelete,\n canWrite: options.canWrite,\n canList: options.canList,\n canRead: options.canRead,\n };\n\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.updateProperties\",\n { ...options, value },\n (updatedOptions) => {\n return this.client.containerRegistry.updateProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n public listManifestProperties(\n options: ListManifestPropertiesOptions = {},\n ): PagedAsyncIterableIterator<ArtifactManifestProperties, ManifestPageResponse> {\n const iter = this.listManifestsItems(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.listManifestsPage(settings, options),\n };\n }\n\n private async *listManifestsItems(\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ArtifactManifestProperties> {\n for await (const page of this.listManifestsPage({}, options)) {\n yield* page;\n }\n }\n\n private async *listManifestsPage(\n continuationState: PageSettings,\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ManifestPageResponse> {\n const orderby = toServiceManifestOrderBy(options.order);\n if (!continuationState.continuationToken) {\n const optionsComplete = {\n ...options,\n n: continuationState.maxPageSize,\n orderby,\n };\n const currentPage = await this.client.containerRegistry.getManifests(\n this.name,\n optionsComplete,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n while (continuationState.continuationToken) {\n const currentPage = await this.client.containerRegistry.getManifestsNext(\n this.name,\n continuationState.continuationToken,\n options,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n }\n}\n"]}
|