@azure/container-registry 1.1.1-alpha.20250619.1 → 1.1.1-alpha.20250730.1

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.
Files changed (130) hide show
  1. package/dist/browser/containerRegistryChallengeHandler.js +6 -3
  2. package/dist/browser/containerRegistryChallengeHandler.js.map +1 -1
  3. package/dist/browser/containerRegistryClient.js +42 -50
  4. package/dist/browser/containerRegistryClient.js.map +1 -1
  5. package/dist/browser/containerRegistryTokenCredential.js +9 -1
  6. package/dist/browser/containerRegistryTokenCredential.js.map +1 -1
  7. package/dist/browser/containerRepository.js +41 -46
  8. package/dist/browser/containerRepository.js.map +1 -1
  9. package/dist/browser/content/containerRegistryContentClient.js +34 -32
  10. package/dist/browser/content/containerRegistryContentClient.js.map +1 -1
  11. package/dist/browser/generated/generatedClient.js +12 -3
  12. package/dist/browser/generated/generatedClient.js.map +1 -1
  13. package/dist/browser/generated/generatedClientContext.js +9 -2
  14. package/dist/browser/generated/generatedClientContext.js.map +1 -1
  15. package/dist/browser/generated/models/mappers.js +63 -29
  16. package/dist/browser/generated/models/mappers.js.map +1 -1
  17. package/dist/browser/generated/operations/authentication.js +1 -0
  18. package/dist/browser/generated/operations/authentication.js.map +1 -1
  19. package/dist/browser/generated/operations/containerRegistry.js +1 -0
  20. package/dist/browser/generated/operations/containerRegistry.js.map +1 -1
  21. package/dist/browser/generated/operations/containerRegistryBlob.js +1 -0
  22. package/dist/browser/generated/operations/containerRegistryBlob.js.map +1 -1
  23. package/dist/browser/registryArtifact.js +69 -53
  24. package/dist/browser/registryArtifact.js.map +1 -1
  25. package/dist/browser/transformations.js +13 -3
  26. package/dist/browser/transformations.js.map +1 -1
  27. package/dist/browser/utils/helpers.js +19 -35
  28. package/dist/browser/utils/helpers.js.map +1 -1
  29. package/dist/browser/utils/retriableReadableStream.js +64 -56
  30. package/dist/browser/utils/retriableReadableStream.js.map +1 -1
  31. package/dist/browser/utils/tokenCycler.js +7 -6
  32. package/dist/browser/utils/tokenCycler.js.map +1 -1
  33. package/dist/commonjs/containerRegistryChallengeHandler.js +6 -3
  34. package/dist/commonjs/containerRegistryChallengeHandler.js.map +1 -1
  35. package/dist/commonjs/containerRegistryClient.js +42 -50
  36. package/dist/commonjs/containerRegistryClient.js.map +1 -1
  37. package/dist/commonjs/containerRegistryTokenCredential.js +9 -1
  38. package/dist/commonjs/containerRegistryTokenCredential.js.map +1 -1
  39. package/dist/commonjs/containerRepository.js +41 -46
  40. package/dist/commonjs/containerRepository.js.map +1 -1
  41. package/dist/commonjs/content/containerRegistryContentClient.js +34 -31
  42. package/dist/commonjs/content/containerRegistryContentClient.js.map +1 -1
  43. package/dist/commonjs/generated/generatedClient.js +12 -3
  44. package/dist/commonjs/generated/generatedClient.js.map +1 -1
  45. package/dist/commonjs/generated/generatedClientContext.js +9 -2
  46. package/dist/commonjs/generated/generatedClientContext.js.map +1 -1
  47. package/dist/commonjs/generated/models/mappers.js +63 -29
  48. package/dist/commonjs/generated/models/mappers.js.map +1 -1
  49. package/dist/commonjs/generated/operations/authentication.js +1 -0
  50. package/dist/commonjs/generated/operations/authentication.js.map +1 -1
  51. package/dist/commonjs/generated/operations/containerRegistry.js +1 -0
  52. package/dist/commonjs/generated/operations/containerRegistry.js.map +1 -1
  53. package/dist/commonjs/generated/operations/containerRegistryBlob.js +1 -0
  54. package/dist/commonjs/generated/operations/containerRegistryBlob.js.map +1 -1
  55. package/dist/commonjs/registryArtifact.js +69 -53
  56. package/dist/commonjs/registryArtifact.js.map +1 -1
  57. package/dist/commonjs/transformations.js +13 -3
  58. package/dist/commonjs/transformations.js.map +1 -1
  59. package/dist/commonjs/tsdoc-metadata.json +11 -11
  60. package/dist/commonjs/utils/helpers.js +19 -35
  61. package/dist/commonjs/utils/helpers.js.map +1 -1
  62. package/dist/commonjs/utils/retriableReadableStream.js +64 -56
  63. package/dist/commonjs/utils/retriableReadableStream.js.map +1 -1
  64. package/dist/commonjs/utils/tokenCycler.js +7 -6
  65. package/dist/commonjs/utils/tokenCycler.js.map +1 -1
  66. package/dist/esm/containerRegistryChallengeHandler.js +6 -3
  67. package/dist/esm/containerRegistryChallengeHandler.js.map +1 -1
  68. package/dist/esm/containerRegistryClient.js +42 -50
  69. package/dist/esm/containerRegistryClient.js.map +1 -1
  70. package/dist/esm/containerRegistryTokenCredential.js +9 -1
  71. package/dist/esm/containerRegistryTokenCredential.js.map +1 -1
  72. package/dist/esm/containerRepository.js +41 -46
  73. package/dist/esm/containerRepository.js.map +1 -1
  74. package/dist/esm/content/containerRegistryContentClient.js +34 -32
  75. package/dist/esm/content/containerRegistryContentClient.js.map +1 -1
  76. package/dist/esm/generated/generatedClient.js +12 -3
  77. package/dist/esm/generated/generatedClient.js.map +1 -1
  78. package/dist/esm/generated/generatedClientContext.js +9 -2
  79. package/dist/esm/generated/generatedClientContext.js.map +1 -1
  80. package/dist/esm/generated/models/mappers.js +63 -29
  81. package/dist/esm/generated/models/mappers.js.map +1 -1
  82. package/dist/esm/generated/operations/authentication.js +1 -0
  83. package/dist/esm/generated/operations/authentication.js.map +1 -1
  84. package/dist/esm/generated/operations/containerRegistry.js +1 -0
  85. package/dist/esm/generated/operations/containerRegistry.js.map +1 -1
  86. package/dist/esm/generated/operations/containerRegistryBlob.js +1 -0
  87. package/dist/esm/generated/operations/containerRegistryBlob.js.map +1 -1
  88. package/dist/esm/registryArtifact.js +69 -53
  89. package/dist/esm/registryArtifact.js.map +1 -1
  90. package/dist/esm/transformations.js +13 -3
  91. package/dist/esm/transformations.js.map +1 -1
  92. package/dist/esm/utils/helpers.js +19 -35
  93. package/dist/esm/utils/helpers.js.map +1 -1
  94. package/dist/esm/utils/retriableReadableStream.js +64 -56
  95. package/dist/esm/utils/retriableReadableStream.js.map +1 -1
  96. package/dist/esm/utils/tokenCycler.js +7 -6
  97. package/dist/esm/utils/tokenCycler.js.map +1 -1
  98. package/dist/react-native/containerRegistryChallengeHandler.js +6 -3
  99. package/dist/react-native/containerRegistryChallengeHandler.js.map +1 -1
  100. package/dist/react-native/containerRegistryClient.js +42 -50
  101. package/dist/react-native/containerRegistryClient.js.map +1 -1
  102. package/dist/react-native/containerRegistryTokenCredential.js +9 -1
  103. package/dist/react-native/containerRegistryTokenCredential.js.map +1 -1
  104. package/dist/react-native/containerRepository.js +41 -46
  105. package/dist/react-native/containerRepository.js.map +1 -1
  106. package/dist/react-native/content/containerRegistryContentClient.js +34 -32
  107. package/dist/react-native/content/containerRegistryContentClient.js.map +1 -1
  108. package/dist/react-native/generated/generatedClient.js +12 -3
  109. package/dist/react-native/generated/generatedClient.js.map +1 -1
  110. package/dist/react-native/generated/generatedClientContext.js +9 -2
  111. package/dist/react-native/generated/generatedClientContext.js.map +1 -1
  112. package/dist/react-native/generated/models/mappers.js +63 -29
  113. package/dist/react-native/generated/models/mappers.js.map +1 -1
  114. package/dist/react-native/generated/operations/authentication.js +1 -0
  115. package/dist/react-native/generated/operations/authentication.js.map +1 -1
  116. package/dist/react-native/generated/operations/containerRegistry.js +1 -0
  117. package/dist/react-native/generated/operations/containerRegistry.js.map +1 -1
  118. package/dist/react-native/generated/operations/containerRegistryBlob.js +1 -0
  119. package/dist/react-native/generated/operations/containerRegistryBlob.js.map +1 -1
  120. package/dist/react-native/registryArtifact.js +69 -53
  121. package/dist/react-native/registryArtifact.js.map +1 -1
  122. package/dist/react-native/transformations.js +13 -3
  123. package/dist/react-native/transformations.js.map +1 -1
  124. package/dist/react-native/utils/helpers.js +19 -35
  125. package/dist/react-native/utils/helpers.js.map +1 -1
  126. package/dist/react-native/utils/retriableReadableStream.js +64 -56
  127. package/dist/react-native/utils/retriableReadableStream.js.map +1 -1
  128. package/dist/react-native/utils/tokenCycler.js +7 -6
  129. package/dist/react-native/utils/tokenCycler.js.map +1 -1
  130. package/package.json +2 -2
@@ -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 !== null && credentialOrOptions !== void 0 ? credentialOrOptions : {};
34
+ options = credentialOrOptions ?? {};
32
35
  }
33
- const internalPipelineOptions = Object.assign(Object.assign({}, options), { loggingOptions: {
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
- const defaultScope = `${(_a = options.audience) !== null && _a !== void 0 ? _a : "https://containerregistry.azure.net"}/.default`;
40
- const serviceVersion = (_b = options.serviceVersion) !== null && _b !== void 0 ? _b : LATEST_API_VERSION;
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
- return __asyncGenerator(this, arguments, function* listRepositoryItems_1(options = {}) {
126
- var _a, e_1, _b, _c;
127
- try {
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(continuationState_1) {
145
- return __asyncGenerator(this, arguments, function* listRepositoriesPage_1(continuationState, options = {}) {
146
- if (!continuationState.continuationToken) {
147
- const optionsComplete = Object.assign(Object.assign({}, options), { n: continuationState.maxPageSize });
148
- const currentPage = yield __await(this.client.containerRegistry.getRepositories(optionsComplete));
149
- continuationState.continuationToken = extractNextLink(currentPage.link);
150
- if (currentPage.repositories) {
151
- const array = currentPage.repositories;
152
- yield yield __await(Object.defineProperty(array, "continuationToken", {
153
- value: continuationState.continuationToken,
154
- enumerable: true,
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
- while (continuationState.continuationToken) {
159
- const currentPage = yield __await(this.client.containerRegistry.getRepositoriesNext(continuationState.continuationToken, options));
160
- continuationState.continuationToken = extractNextLink(currentPage.link);
161
- if (currentPage.repositories) {
162
- const array = currentPage.repositories;
163
- yield yield __await(Object.defineProperty(array, "continuationToken", {
164
- value: continuationState.continuationToken,
165
- enumerable: true,
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 @@
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;IAqDlC,YACE,QAAgB,EAChB,mBAAsE,EACtE,gBAAgD,EA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AiB,EAAE,CAAC;gBAC3C,MAAM,WAAW,GAAG,cAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,mBAAmB,CACzE,iBAAiB,CAAC,iBAAiB,EACnC,OAAO,CACR,CAAA,CAAC;gBACF,iBAAiB,CAAC,iBAAiB,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxE,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;oBAC7B,MAAM,KAAK,GAAG,WAAW,CAAC,YAAY,CAAC;oBACvC,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\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,uBA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,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,mBAAmB,CACzE,iBAAiB,CAAC,iBAAiB,EACnC,OAAO,CACR,CAAC;YACF,iBAAiB,CAAC,iBAAiB,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACxE,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;gBAC7B,MAAM,KAAK,GAAG,WAAW,CAAC,YAAY,CAAC;gBACvC,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\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, Object.assign(Object.assign({}, options), { accessToken: aadAccessToken }));
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;IAGlD,YACE,UAA2B,EACnB,mBAA2B,EAC3B,UAA4B;QAD5B,wBAAmB,GAAnB,mBAAmB,CAAQ;QAC3B,eAAU,GAAV,UAAU,CAAkB;QAEpC,IAAI,CAAC,YAAY,GAAG,IAAI,6BAA6B,CAAC,UAAU,CAAC,CAAC;QAClE,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,OAA0B,EAC1B,OAAyC;QAEzC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QACnF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,6CAA6C,CACpE,QAAQ,CAAC,KAAK,EACd,OAAO,CAAC,OAAO,EACf,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,6BAA6B;IACxC,YAAoB,UAA2B;QAA3B,eAAU,GAAV,UAAU,CAAiB;IAAG,CAAC;IAEnD,KAAK,CAAC,6CAA6C,CACjD,cAAsB,EACtB,OAAe,EACf,OAAwB;QAExB,MAAM,eAAe,GACnB,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,wCAAwC,CAC3E,cAAc,EACd,OAAO,kCA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QAClF,CAAC;QACD,OAAO,cAAc,CAAC,WAAW,CAAC;IACpC,CAAC;CACF","sourcesContent":["// 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
+ {"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;IAKxC;IACA;IALD,YAAY,CAAgC;IAC5C,iBAAiB,CAAU;IACpC,YACE,UAA2B,EACnB,mBAA2B,EAC3B,UAA4B;QAD5B,wBAAmB,GAAnB,mBAAmB,CAAQ;QAC3B,eAAU,GAAV,UAAU,CAAkB;QAEpC,IAAI,CAAC,YAAY,GAAG,IAAI,6BAA6B,CAAC,UAAU,CAAC,CAAC;QAClE,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,OAA0B,EAC1B,OAAyC;QAEzC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UA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,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;QAED,2BAA2B;QAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QACtD,OAAO;YACL,KAAK,EAAE,eAAe,CAAC,YAAY;YACnC,kBAAkB,EAAE,MAAM;SAC3B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,6CAA6C,CACjD,eAAuB,EACvB,OAAe,EACf,KAAa,EACb,SAAuC,EACvC,OAAwB;QAExB,MAAM,cAAc,GAClB,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,wCAAwC,CAC3E,OAAO,EACP,KAAK,EACL,eAAe,EACf,SAAS,EACT,OAAO,CACR,CAAC;QAEJ,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,cAAc,CAAC,WAAW,CAAC;IACpC,CAAC;CACF","sourcesContent":["// 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", Object.assign(Object.assign({}, options), { value }), (updatedOptions) => {
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
- return __asyncGenerator(this, arguments, function* listManifestsItems_1(options = {}) {
124
- var _a, e_1, _b, _c;
125
- try {
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(continuationState_1) {
143
- return __asyncGenerator(this, arguments, function* listManifestsPage_1(continuationState, options = {}) {
144
- const orderby = toServiceManifestOrderBy(options.order);
145
- if (!continuationState.continuationToken) {
146
- const optionsComplete = Object.assign(Object.assign({}, options), { n: continuationState.maxPageSize, orderby });
147
- const currentPage = yield __await(this.client.containerRegistry.getManifests(this.name, optionsComplete));
148
- continuationState.continuationToken = extractNextLink(currentPage.link);
149
- if (currentPage.manifests) {
150
- const array = currentPage.manifests.map((t) => toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer));
151
- yield yield __await(Object.defineProperty(array, "continuationToken", {
152
- value: continuationState.continuationToken,
153
- enumerable: true,
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
- while (continuationState.continuationToken) {
158
- const currentPage = yield __await(this.client.containerRegistry.getManifestsNext(this.name, continuationState.continuationToken, options));
159
- continuationState.continuationToken = extractNextLink(currentPage.link);
160
- if (currentPage.manifests) {
161
- const array = currentPage.manifests.map((t) => toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer));
162
- yield yield __await(Object.defineProperty(array, "continuationToken", {
163
- value: continuationState.continuationToken,
164
- enumerable: true,
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,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAqHrD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAWlC;;;;;OAKG;IACH,YAAY,gBAAwB,EAAE,IAAY,EAAE,MAAuB;QACzE,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM,CAAC,UAAmC,EAAE;QACvD,OAAO,aAAa,CAAC,QAAQ,CAC3B,gCAAgC,EAChC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAClF,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,WAAmB;QACpC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAA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,KAAK,EAAE,mBAAmB,EAAE;wBACtD,KAAK,EAAE,iBAAiB,CAAC,iBAAiB;wBAC1C,UAAU,EAAE,IAAI;qBACjB,CAAC,CAAA,CAAC;gBACL,CAAC;YACH,CAAC;YACD,OAAO,iBAAiB,CAAC,iBAAiB,EAAE,CAAC;gBAC3C,MAAM,WAAW,GAAG,cAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CACtE,IAAI,CAAC,IAAI,EACT,iBAAiB,CAAC,iBAAiB,EACnC,OAAO,CACR,CAAA,CAAC;gBACF,iBAAiB,CAAC,iBAAiB,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxE,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;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,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAqHrD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IACjB,MAAM,CAAkB;IACzC;;OAEG;IACa,gBAAgB,CAAS;IACzC;;OAEG;IACa,IAAI,CAAS;IAE7B;;;;;OAKG;IACH,YAAY,gBAAwB,EAAE,IAAY,EAAE,MAAuB;QACzE,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM,CAAC,UAAmC,EAAE;QACvD,OAAO,aAAa,CAAC,QAAQ,CAC3B,gCAAgC,EAChC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAClF,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,WA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EAAE,mBAAmB,EAAE;oBACtD,KAAK,EAAE,iBAAiB,CAAC,iBAAiB;oBAC1C,UAAU,EAAE,IAAI;iBACjB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO,iBAAiB,CAAC,iBAAiB,EAAE,CAAC;YAC3C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CACtE,IAAI,CAAC,IAAI,EACT,iBAAiB,CAAC,iBAAiB,EACnC,OAAO,CACR,CAAC;YACF,iBAAiB,CAAC,iBAAiB,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACxE,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;gBAC1B,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;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"]}
@@ -1,6 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { __asyncValues } from "tslib";
4
3
  import { bearerTokenAuthenticationPolicy, RestError } from "@azure/core-rest-pipeline";
5
4
  import { GeneratedClient } from "../generated/index.js";
6
5
  import { ChallengeHandler } from "../containerRegistryChallengeHandler.js";
@@ -45,6 +44,15 @@ export class DigestMismatchError extends Error {
45
44
  * The Azure Container Registry blob client, responsible for uploading and downloading blobs and manifests, the building blocks of artifacts.
46
45
  */
47
46
  export class ContainerRegistryContentClient {
47
+ /**
48
+ * The Azure Container Registry endpoint.
49
+ */
50
+ endpoint;
51
+ /**
52
+ * The name of the repository that logically groups the artifact parts.
53
+ */
54
+ repositoryName;
55
+ client;
48
56
  /**
49
57
  * Creates an instance of a ContainerRegistryContentClient for managing container images and artifacts.
50
58
  *
@@ -67,13 +75,14 @@ export class ContainerRegistryContentClient {
67
75
  * @param options - optional configuration used to send requests to the service
68
76
  */
69
77
  constructor(endpoint, repositoryName, credential, options = {}) {
70
- var _a, _b;
71
78
  if (!endpoint) {
72
79
  throw new Error("invalid endpoint");
73
80
  }
74
81
  this.endpoint = endpoint;
75
82
  this.repositoryName = repositoryName;
76
- const internalPipelineOptions = Object.assign(Object.assign({}, options), { loggingOptions: {
83
+ const internalPipelineOptions = {
84
+ ...options,
85
+ loggingOptions: {
77
86
  logger: logger.info,
78
87
  // This array contains header names we want to log that are not already
79
88
  // included as safe. Unknown/unsafe headers are logged as "<REDACTED>".
@@ -85,9 +94,10 @@ export class ContainerRegistryContentClient {
85
94
  "_nouploadcache",
86
95
  "_state",
87
96
  ],
88
- } });
89
- const defaultScope = `${(_a = options.audience) !== null && _a !== void 0 ? _a : "https://containerregistry.azure.net"}/.default`;
90
- const serviceVersion = (_b = options.serviceVersion) !== null && _b !== void 0 ? _b : LATEST_API_VERSION;
97
+ },
98
+ };
99
+ const defaultScope = `${options.audience ?? "https://containerregistry.azure.net"}/.default`;
100
+ const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;
91
101
  const authClient = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
92
102
  this.client = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
93
103
  this.client.pipeline.addPolicy(bearerTokenAuthenticationPolicy({
@@ -113,22 +123,24 @@ export class ContainerRegistryContentClient {
113
123
  */
114
124
  async setManifest(manifest, options = {}) {
115
125
  return tracingClient.withSpan("ContainerRegistryContentClient.uploadManifest", options, async (updatedOptions) => {
116
- var _a;
117
126
  let manifestBody;
118
- let tagOrDigest = options === null || options === void 0 ? void 0 : options.tag;
127
+ let tagOrDigest = options?.tag;
119
128
  if (Buffer.isBuffer(manifest)) {
120
129
  manifestBody = manifest;
121
- tagOrDigest !== null && tagOrDigest !== void 0 ? tagOrDigest : (tagOrDigest = await calculateDigest(manifest));
130
+ tagOrDigest ??= await calculateDigest(manifest);
122
131
  }
123
132
  else if (isReadableStream(manifest)) {
124
133
  manifestBody = await readStreamToEnd(manifest);
125
- tagOrDigest !== null && tagOrDigest !== void 0 ? tagOrDigest : (tagOrDigest = await calculateDigest(manifestBody));
134
+ tagOrDigest ??= await calculateDigest(manifestBody);
126
135
  }
127
136
  else {
128
137
  manifestBody = Buffer.from(JSON.stringify(manifest));
129
- tagOrDigest !== null && tagOrDigest !== void 0 ? tagOrDigest : (tagOrDigest = await calculateDigest(manifestBody));
138
+ tagOrDigest ??= await calculateDigest(manifestBody);
130
139
  }
131
- const createManifestResult = await this.client.containerRegistry.createManifest(this.repositoryName, tagOrDigest, manifestBody, Object.assign({ contentType: (_a = options === null || options === void 0 ? void 0 : options.mediaType) !== null && _a !== void 0 ? _a : KnownManifestMediaType.OciImageManifest }, updatedOptions));
140
+ const createManifestResult = await this.client.containerRegistry.createManifest(this.repositoryName, tagOrDigest, manifestBody, {
141
+ contentType: options?.mediaType ?? KnownManifestMediaType.OciImageManifest,
142
+ ...updatedOptions,
143
+ });
132
144
  assertHasProperty(createManifestResult, "dockerContentDigest");
133
145
  return { digest: createManifestResult.dockerContentDigest };
134
146
  });
@@ -141,7 +153,10 @@ export class ContainerRegistryContentClient {
141
153
  */
142
154
  async getManifest(tagOrDigest, options = {}) {
143
155
  return tracingClient.withSpan("ContainerRegistryContentClient.downloadManifest", options, async (updatedOptions) => {
144
- const response = await this.client.containerRegistry.getManifest(this.repositoryName, tagOrDigest, Object.assign({ accept: ACCEPTED_MANIFEST_MEDIA_TYPES.join(", ") }, updatedOptions));
156
+ const response = await this.client.containerRegistry.getManifest(this.repositoryName, tagOrDigest, {
157
+ accept: ACCEPTED_MANIFEST_MEDIA_TYPES.join(", "),
158
+ ...updatedOptions,
159
+ });
145
160
  assertHasProperty(response, "mediaType");
146
161
  const content = response.readableStreamBody
147
162
  ? await readStreamToEnd(response.readableStreamBody, MAX_MANIFEST_SIZE_BYTES)
@@ -179,7 +194,6 @@ export class ContainerRegistryContentClient {
179
194
  */
180
195
  async uploadBlob(blob, options = {}) {
181
196
  return tracingClient.withSpan("ContainerRegistryContentClient.uploadBlob", options, async (updatedOptions) => {
182
- var _a, e_1, _b, _c;
183
197
  const blobStream = Buffer.isBuffer(blob) ? Readable.from(blob) : blob;
184
198
  const startUploadResult = await this.client.containerRegistryBlob.startUpload(this.repositoryName, updatedOptions);
185
199
  assertHasProperty(startUploadResult, "location");
@@ -187,24 +201,12 @@ export class ContainerRegistryContentClient {
187
201
  const chunks = readChunksFromStream(blobStream, CHUNK_SIZE);
188
202
  const hash = crypto.createHash("sha256");
189
203
  let bytesUploaded = 0;
190
- try {
191
- for (var _d = true, chunks_1 = __asyncValues(chunks), chunks_1_1; chunks_1_1 = await chunks_1.next(), _a = chunks_1_1.done, !_a; _d = true) {
192
- _c = chunks_1_1.value;
193
- _d = false;
194
- const chunk = _c;
195
- hash.write(chunk);
196
- const result = await this.client.containerRegistryBlob.uploadChunk(location, chunk, updatedOptions);
197
- bytesUploaded += chunk.byteLength;
198
- assertHasProperty(result, "location");
199
- location = result.location.substring(1);
200
- }
201
- }
202
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
203
- finally {
204
- try {
205
- if (!_d && !_a && (_b = chunks_1.return)) await _b.call(chunks_1);
206
- }
207
- finally { if (e_1) throw e_1.error; }
204
+ for await (const chunk of chunks) {
205
+ hash.write(chunk);
206
+ const result = await this.client.containerRegistryBlob.uploadChunk(location, chunk, updatedOptions);
207
+ bytesUploaded += chunk.byteLength;
208
+ assertHasProperty(result, "location");
209
+ location = result.location.substring(1);
208
210
  }
209
211
  hash.end();
210
212
  const digest = `sha256:${hash.digest("hex")}`;