@azure/keyvault-admin 4.2.0-beta.1 → 4.2.1-alpha.20220325.3

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 (54) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/README.md +3 -0
  3. package/dist/index.js +311 -237
  4. package/dist/index.js.map +1 -1
  5. package/dist-esm/keyvault-admin/src/accessControlClient.js +14 -21
  6. package/dist-esm/keyvault-admin/src/accessControlClient.js.map +1 -1
  7. package/dist-esm/keyvault-admin/src/accessControlModels.js +2 -70
  8. package/dist-esm/keyvault-admin/src/accessControlModels.js.map +1 -1
  9. package/dist-esm/keyvault-admin/src/backupClient.js +7 -7
  10. package/dist-esm/keyvault-admin/src/backupClient.js.map +1 -1
  11. package/dist-esm/keyvault-admin/src/challengeAuthenticationCallbacks.js +7 -29
  12. package/dist-esm/keyvault-admin/src/challengeAuthenticationCallbacks.js.map +1 -1
  13. package/dist-esm/keyvault-admin/src/constants.js +2 -2
  14. package/dist-esm/keyvault-admin/src/constants.js.map +1 -1
  15. package/dist-esm/keyvault-admin/src/generated/keyVaultClient.js +2 -1
  16. package/dist-esm/keyvault-admin/src/generated/keyVaultClient.js.map +1 -1
  17. package/dist-esm/keyvault-admin/src/generated/keyVaultClientContext.js +2 -2
  18. package/dist-esm/keyvault-admin/src/generated/keyVaultClientContext.js.map +1 -1
  19. package/dist-esm/keyvault-admin/src/generated/models/index.js +99 -1
  20. package/dist-esm/keyvault-admin/src/generated/models/index.js.map +1 -1
  21. package/dist-esm/keyvault-admin/src/generated/operations/roleAssignments.js +1 -1
  22. package/dist-esm/keyvault-admin/src/generated/operations/roleAssignments.js.map +1 -1
  23. package/dist-esm/keyvault-admin/src/generated/operations/roleDefinitions.js +1 -1
  24. package/dist-esm/keyvault-admin/src/generated/operations/roleDefinitions.js.map +1 -1
  25. package/dist-esm/keyvault-admin/src/lro/backup/operation.js +4 -4
  26. package/dist-esm/keyvault-admin/src/lro/backup/operation.js.map +1 -1
  27. package/dist-esm/keyvault-admin/src/lro/backup/poller.js +2 -2
  28. package/dist-esm/keyvault-admin/src/lro/backup/poller.js.map +1 -1
  29. package/dist-esm/keyvault-admin/src/lro/keyVaultAdminPoller.js +2 -2
  30. package/dist-esm/keyvault-admin/src/lro/keyVaultAdminPoller.js.map +1 -1
  31. package/dist-esm/keyvault-admin/src/lro/restore/operation.js +5 -5
  32. package/dist-esm/keyvault-admin/src/lro/restore/operation.js.map +1 -1
  33. package/dist-esm/keyvault-admin/src/lro/restore/poller.js +2 -2
  34. package/dist-esm/keyvault-admin/src/lro/restore/poller.js.map +1 -1
  35. package/dist-esm/keyvault-admin/src/lro/selectiveKeyRestore/operation.js +4 -4
  36. package/dist-esm/keyvault-admin/src/lro/selectiveKeyRestore/operation.js.map +1 -1
  37. package/dist-esm/keyvault-admin/src/lro/selectiveKeyRestore/poller.js +2 -2
  38. package/dist-esm/keyvault-admin/src/lro/selectiveKeyRestore/poller.js.map +1 -1
  39. package/dist-esm/keyvault-admin/src/mappings.js +7 -7
  40. package/dist-esm/keyvault-admin/src/mappings.js.map +1 -1
  41. package/dist-esm/keyvault-admin/src/tracingHelpers.js +4 -4
  42. package/dist-esm/keyvault-admin/src/tracingHelpers.js.map +1 -1
  43. package/dist-esm/keyvault-common/src/challengeBasedAuthenticationPolicy.js +14 -25
  44. package/dist-esm/keyvault-common/src/challengeBasedAuthenticationPolicy.js.map +1 -1
  45. package/dist-esm/keyvault-common/src/index.js +1 -0
  46. package/dist-esm/keyvault-common/src/index.js.map +1 -1
  47. package/dist-esm/keyvault-common/src/parseKeyvaultIdentifier.js +1 -1
  48. package/dist-esm/keyvault-common/src/parseKeyvaultIdentifier.js.map +1 -1
  49. package/dist-esm/keyvault-common/src/parseWWWAuthenticate.js +52 -0
  50. package/dist-esm/keyvault-common/src/parseWWWAuthenticate.js.map +1 -0
  51. package/dist-esm/keyvault-common/src/tracingHelpers.js +4 -4
  52. package/dist-esm/keyvault-common/src/tracingHelpers.js.map +1 -1
  53. package/package.json +20 -37
  54. package/types/keyvault-admin.d.ts +54 -13
package/dist/index.js CHANGED
@@ -1,61 +1,49 @@
1
- /*!
2
- * Copyright (c) Microsoft and contributors. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for
4
- * license information.
5
- *
6
- * Azure KeyVault Admin SDK for JavaScript - 4.2.0-beta.1
7
- */
8
1
  'use strict';
9
2
 
10
3
  Object.defineProperty(exports, '__esModule', { value: true });
11
4
 
12
5
  var tslib = require('tslib');
13
- var coreTracing = require('@azure/core-tracing');
14
6
  var coreClient = require('@azure/core-client');
7
+ var coreRestPipeline = require('@azure/core-rest-pipeline');
8
+ var coreTracing = require('@azure/core-tracing');
15
9
  var logger$1 = require('@azure/logger');
16
10
  var uuid = require('uuid');
17
- var coreRestPipeline = require('@azure/core-rest-pipeline');
18
11
  var coreLro = require('@azure/core-lro');
19
12
 
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n["default"] = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var coreClient__namespace = /*#__PURE__*/_interopNamespace(coreClient);
32
+
20
33
  // Copyright (c) Microsoft Corporation.
34
+ // Licensed under the MIT license.
21
35
  /**
22
- * Returns a function that can be used for tracing options.
23
- *
24
- * @param prefix - The prefix to use, likely the name of the class / client.
25
- *
26
- * @example const withTrace = createTraceFunction("Azure.KeyVault.Certificates.CertificateClient")
27
- *
28
- * @internal
36
+ * Current version of the Key Vault Admin SDK.
29
37
  */
30
- function createTraceFunction(prefix) {
31
- const createSpan = coreTracing.createSpanFunction({
32
- namespace: "Microsoft.KeyVault",
33
- packagePrefix: prefix
34
- });
35
- return async function (operationName, options, cb) {
36
- const { updatedOptions, span } = createSpan(operationName, options);
37
- try {
38
- // NOTE: we really do need to await on this function here so we can handle any exceptions thrown and properly
39
- // close the span.
40
- const result = await cb(updatedOptions, span);
41
- // otel 0.16+ needs this or else the code ends up being set as UNSET
42
- span.setStatus({
43
- code: coreTracing.SpanStatusCode.OK
44
- });
45
- return result;
46
- }
47
- catch (err) {
48
- span.setStatus({
49
- code: coreTracing.SpanStatusCode.ERROR,
50
- message: err.message
51
- });
52
- throw err;
53
- }
54
- finally {
55
- span.end();
56
- }
57
- };
58
- }
38
+ const SDK_VERSION = "4.2.1";
39
+ /**
40
+ * The latest supported Key Vault service API version.
41
+ */
42
+ const LATEST_API_VERSION = "7.3";
43
+ /**
44
+ * Authentication scopes
45
+ */
46
+ const authenticationScopes = ["https://managedhsm.azure.net/.default"];
59
47
 
60
48
  /*
61
49
  * Copyright (c) Microsoft Corporation.
@@ -920,7 +908,7 @@ const keyName = {
920
908
  * Code generated by Microsoft (R) AutoRest Code Generator.
921
909
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
922
910
  */
923
- /** Class representing a RoleDefinitions. */
911
+ /** Class containing RoleDefinitions operations. */
924
912
  class RoleDefinitionsImpl {
925
913
  /**
926
914
  * Initialize a new instance of the class RoleDefinitions class.
@@ -937,7 +925,7 @@ class RoleDefinitionsImpl {
937
925
  * @param options The options parameters.
938
926
  */
939
927
  delete(vaultBaseUrl, scope, roleDefinitionName, options) {
940
- return this.client.sendOperationRequest({ vaultBaseUrl, scope, roleDefinitionName, options }, deleteOperationSpec);
928
+ return this.client.sendOperationRequest({ vaultBaseUrl, scope, roleDefinitionName, options }, deleteOperationSpec$1);
941
929
  }
942
930
  /**
943
931
  * Creates or updates a custom role definition.
@@ -959,7 +947,7 @@ class RoleDefinitionsImpl {
959
947
  * @param options The options parameters.
960
948
  */
961
949
  get(vaultBaseUrl, scope, roleDefinitionName, options) {
962
- return this.client.sendOperationRequest({ vaultBaseUrl, scope, roleDefinitionName, options }, getOperationSpec);
950
+ return this.client.sendOperationRequest({ vaultBaseUrl, scope, roleDefinitionName, options }, getOperationSpec$1);
963
951
  }
964
952
  /**
965
953
  * Get all role definitions that are applicable at scope and above.
@@ -982,8 +970,8 @@ class RoleDefinitionsImpl {
982
970
  }
983
971
  }
984
972
  // Operation Specifications
985
- const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
986
- const deleteOperationSpec = {
973
+ const serializer$2 = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
974
+ const deleteOperationSpec$1 = {
987
975
  path: "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionName}",
988
976
  httpMethod: "DELETE",
989
977
  responses: {
@@ -1000,7 +988,7 @@ const deleteOperationSpec = {
1000
988
  roleDefinitionName
1001
989
  ],
1002
990
  headerParameters: [accept],
1003
- serializer
991
+ serializer: serializer$2
1004
992
  };
1005
993
  const createOrUpdateOperationSpec = {
1006
994
  path: "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionName}",
@@ -1022,9 +1010,9 @@ const createOrUpdateOperationSpec = {
1022
1010
  ],
1023
1011
  headerParameters: [accept, contentType],
1024
1012
  mediaType: "json",
1025
- serializer
1013
+ serializer: serializer$2
1026
1014
  };
1027
- const getOperationSpec = {
1015
+ const getOperationSpec$1 = {
1028
1016
  path: "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionName}",
1029
1017
  httpMethod: "GET",
1030
1018
  responses: {
@@ -1042,7 +1030,7 @@ const getOperationSpec = {
1042
1030
  roleDefinitionName
1043
1031
  ],
1044
1032
  headerParameters: [accept],
1045
- serializer
1033
+ serializer: serializer$2
1046
1034
  };
1047
1035
  const listOperationSpec = {
1048
1036
  path: "/{scope}/providers/Microsoft.Authorization/roleDefinitions",
@@ -1058,7 +1046,7 @@ const listOperationSpec = {
1058
1046
  queryParameters: [apiVersion, filter],
1059
1047
  urlParameters: [vaultBaseUrl, scope],
1060
1048
  headerParameters: [accept],
1061
- serializer
1049
+ serializer: serializer$2
1062
1050
  };
1063
1051
  const listNextOperationSpec = {
1064
1052
  path: "{nextLink}",
@@ -1078,7 +1066,7 @@ const listNextOperationSpec = {
1078
1066
  nextLink
1079
1067
  ],
1080
1068
  headerParameters: [accept],
1081
- serializer
1069
+ serializer: serializer$2
1082
1070
  };
1083
1071
 
1084
1072
  /*
@@ -1088,7 +1076,7 @@ const listNextOperationSpec = {
1088
1076
  * Code generated by Microsoft (R) AutoRest Code Generator.
1089
1077
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
1090
1078
  */
1091
- /** Class representing a RoleAssignments. */
1079
+ /** Class containing RoleAssignments operations. */
1092
1080
  class RoleAssignmentsImpl {
1093
1081
  /**
1094
1082
  * Initialize a new instance of the class RoleAssignments class.
@@ -1105,7 +1093,7 @@ class RoleAssignmentsImpl {
1105
1093
  * @param options The options parameters.
1106
1094
  */
1107
1095
  delete(vaultBaseUrl, scope, roleAssignmentName, options) {
1108
- return this.client.sendOperationRequest({ vaultBaseUrl, scope, roleAssignmentName, options }, deleteOperationSpec$1);
1096
+ return this.client.sendOperationRequest({ vaultBaseUrl, scope, roleAssignmentName, options }, deleteOperationSpec);
1109
1097
  }
1110
1098
  /**
1111
1099
  * Creates a role assignment.
@@ -1126,7 +1114,7 @@ class RoleAssignmentsImpl {
1126
1114
  * @param options The options parameters.
1127
1115
  */
1128
1116
  get(vaultBaseUrl, scope, roleAssignmentName, options) {
1129
- return this.client.sendOperationRequest({ vaultBaseUrl, scope, roleAssignmentName, options }, getOperationSpec$1);
1117
+ return this.client.sendOperationRequest({ vaultBaseUrl, scope, roleAssignmentName, options }, getOperationSpec);
1130
1118
  }
1131
1119
  /**
1132
1120
  * Gets role assignments for a scope.
@@ -1149,8 +1137,8 @@ class RoleAssignmentsImpl {
1149
1137
  }
1150
1138
  }
1151
1139
  // Operation Specifications
1152
- const serializer$1 = coreClient.createSerializer(Mappers, /* isXml */ false);
1153
- const deleteOperationSpec$1 = {
1140
+ const serializer$1 = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
1141
+ const deleteOperationSpec = {
1154
1142
  path: "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}",
1155
1143
  httpMethod: "DELETE",
1156
1144
  responses: {
@@ -1191,7 +1179,7 @@ const createOperationSpec = {
1191
1179
  mediaType: "json",
1192
1180
  serializer: serializer$1
1193
1181
  };
1194
- const getOperationSpec$1 = {
1182
+ const getOperationSpec = {
1195
1183
  path: "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}",
1196
1184
  httpMethod: "GET",
1197
1185
  responses: {
@@ -1255,7 +1243,7 @@ const listForScopeNextOperationSpec = {
1255
1243
  * Code generated by Microsoft (R) AutoRest Code Generator.
1256
1244
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
1257
1245
  */
1258
- class KeyVaultClientContext extends coreClient.ServiceClient {
1246
+ class KeyVaultClientContext extends coreClient__namespace.ServiceClient {
1259
1247
  /**
1260
1248
  * Initializes a new instance of the KeyVaultClientContext class.
1261
1249
  * @param apiVersion Api Version
@@ -1272,7 +1260,7 @@ class KeyVaultClientContext extends coreClient.ServiceClient {
1272
1260
  const defaults = {
1273
1261
  requestContentType: "application/json; charset=utf-8"
1274
1262
  };
1275
- const packageDetails = `azsdk-js-keyvault-admin/4.2.0-beta.1`;
1263
+ const packageDetails = `azsdk-js-keyvault-admin/4.2.0`;
1276
1264
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1277
1265
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1278
1266
  : `${packageDetails}`;
@@ -1304,7 +1292,8 @@ class KeyVaultClient extends KeyVaultClientContext {
1304
1292
  this.roleAssignments = new RoleAssignmentsImpl(this);
1305
1293
  }
1306
1294
  /**
1307
- * Creates a full backup using a user-provided SAS token to an Azure blob storage container.
1295
+ * Creates a full backup using a user-provided SAS token to an Azure blob storage container. This
1296
+ * operation is supported only by the Managed HSM service.
1308
1297
  * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
1309
1298
  * @param options The options parameters.
1310
1299
  */
@@ -1350,7 +1339,7 @@ class KeyVaultClient extends KeyVaultClientContext {
1350
1339
  }
1351
1340
  }
1352
1341
  // Operation Specifications
1353
- const serializer$2 = coreClient.createSerializer(Mappers, /* isXml */ false);
1342
+ const serializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
1354
1343
  const fullBackupOperationSpec = {
1355
1344
  path: "/backup",
1356
1345
  httpMethod: "POST",
@@ -1368,7 +1357,7 @@ const fullBackupOperationSpec = {
1368
1357
  urlParameters: [vaultBaseUrl],
1369
1358
  headerParameters: [accept, contentType],
1370
1359
  mediaType: "json",
1371
- serializer: serializer$2
1360
+ serializer
1372
1361
  };
1373
1362
  const fullBackupStatusOperationSpec = {
1374
1363
  path: "/backup/{jobId}/pending",
@@ -1384,7 +1373,7 @@ const fullBackupStatusOperationSpec = {
1384
1373
  queryParameters: [apiVersion],
1385
1374
  urlParameters: [vaultBaseUrl, jobId],
1386
1375
  headerParameters: [accept],
1387
- serializer: serializer$2
1376
+ serializer
1388
1377
  };
1389
1378
  const fullRestoreOperationOperationSpec = {
1390
1379
  path: "/restore",
@@ -1403,7 +1392,7 @@ const fullRestoreOperationOperationSpec = {
1403
1392
  urlParameters: [vaultBaseUrl],
1404
1393
  headerParameters: [accept, contentType],
1405
1394
  mediaType: "json",
1406
- serializer: serializer$2
1395
+ serializer
1407
1396
  };
1408
1397
  const restoreStatusOperationSpec = {
1409
1398
  path: "/restore/{jobId}/pending",
@@ -1419,7 +1408,7 @@ const restoreStatusOperationSpec = {
1419
1408
  queryParameters: [apiVersion],
1420
1409
  urlParameters: [vaultBaseUrl, jobId],
1421
1410
  headerParameters: [accept],
1422
- serializer: serializer$2
1411
+ serializer
1423
1412
  };
1424
1413
  const selectiveKeyRestoreOperationOperationSpec = {
1425
1414
  path: "/keys/{keyName}/restore",
@@ -1438,92 +1427,36 @@ const selectiveKeyRestoreOperationOperationSpec = {
1438
1427
  urlParameters: [vaultBaseUrl, keyName],
1439
1428
  headerParameters: [accept, contentType],
1440
1429
  mediaType: "json",
1441
- serializer: serializer$2
1430
+ serializer
1442
1431
  };
1443
1432
 
1444
1433
  // Copyright (c) Microsoft Corporation.
1445
1434
  // Licensed under the MIT license.
1446
1435
  /**
1447
- * Current version of the Key Vault Admin SDK.
1448
- */
1449
- const SDK_VERSION = "4.2.0-beta.1";
1450
- /**
1451
- * The latest supported Key Vault service API version.
1452
- */
1453
- const LATEST_API_VERSION = "7.2";
1454
- /**
1455
- * Authentication scopes
1456
- */
1457
- const authenticationScopes = ["https://managedhsm.azure.net/.default"];
1458
-
1459
- // Copyright (c) Microsoft Corporation.
1460
- // Licensed under the MIT license.
1461
- const mappings = {
1462
- roleAssignment: {
1463
- generatedToPublic(roleAssignment) {
1464
- const { id, name, type, properties } = roleAssignment;
1465
- const { scope, roleDefinitionId, principalId } = properties || {};
1466
- return {
1467
- id: id,
1468
- name: name,
1469
- kind: type,
1470
- properties: {
1471
- scope: scope,
1472
- roleDefinitionId: roleDefinitionId,
1473
- principalId: principalId
1474
- }
1475
- };
1476
- }
1477
- },
1478
- roleDefinition: {
1479
- generatedToPublic(roleDefinition) {
1480
- const { id, name, type, roleName, description, roleType, permissions, assignableScopes } = roleDefinition;
1481
- return {
1482
- id: id,
1483
- name: name,
1484
- kind: type,
1485
- roleName: roleName,
1486
- description: description,
1487
- roleType: roleType,
1488
- permissions: permissions,
1489
- assignableScopes: assignableScopes
1490
- };
1491
- }
1492
- },
1493
- folderUriParts(folderUri) {
1494
- const uriParts = folderUri.split("/");
1495
- const folderName = uriParts.pop();
1496
- const storageUri = uriParts.join("/");
1497
- if (!folderName) {
1498
- throw new Error("The provided folder URI is missing the folder name.");
1499
- }
1500
- return {
1501
- folderName,
1502
- folderUri: storageUri
1503
- };
1504
- }
1505
- };
1506
-
1507
- // Copyright (c) Microsoft Corporation.
1508
- /**
1509
- * The \@azure/logger configuration for this package.
1436
+ * @internal
1437
+ *
1438
+ * Valid key names in WWW-Authenticate header.
1510
1439
  */
1511
- const logger = logger$1.createClientLogger("keyvault-admin");
1512
-
1513
- // Copyright (c) Microsoft Corporation.
1514
- // Licensed under the MIT license.
1515
- const validParsedWWWAuthenticateProperties = ["authorization", "resource", "scope"];
1440
+ const validParsedWWWAuthenticateProperties = [
1441
+ "authorization",
1442
+ "authorization_url",
1443
+ "resource",
1444
+ "scope",
1445
+ "tenantId",
1446
+ ];
1516
1447
  /**
1517
1448
  * Parses an WWW-Authenticate response.
1518
1449
  * This transforms a string value like:
1519
- * `Bearer authorization="some_authorization", resource="https://some.url"`
1450
+ * `Bearer authorization="https://some.url/tenantId", resource="https://some.url"`
1520
1451
  * into an object like:
1521
- * `{ authorization: "some_authorization", resource: "https://some.url" }`
1452
+ * `{ authorization: "https://some.url/tenantId", resource: "https://some.url" }`
1522
1453
  * @param wwwAuthenticate - String value in the WWW-Authenticate header
1523
1454
  */
1524
1455
  function parseWWWAuthenticate(wwwAuthenticate) {
1525
1456
  const pairDelimiter = /,? +/;
1526
- return wwwAuthenticate.split(pairDelimiter).reduce((kvPairs, p) => {
1457
+ const parsed = wwwAuthenticate
1458
+ .split(pairDelimiter)
1459
+ .reduce((kvPairs, p) => {
1527
1460
  if (p.match(/\w="/)) {
1528
1461
  // 'sampleKey="sample_value"' -> [sampleKey, "sample_value"] -> { sampleKey: sample_value }
1529
1462
  const [key, value] = p.split("=");
@@ -1534,7 +1467,22 @@ function parseWWWAuthenticate(wwwAuthenticate) {
1534
1467
  }
1535
1468
  return kvPairs;
1536
1469
  }, {});
1470
+ // Finally, we pull the tenantId from the authorization header to support multi-tenant authentication.
1471
+ if (parsed.authorization) {
1472
+ try {
1473
+ const tenantId = new URL(parsed.authorization).pathname.substring(1);
1474
+ if (tenantId) {
1475
+ parsed.tenantId = tenantId;
1476
+ }
1477
+ }
1478
+ catch (_) {
1479
+ throw new Error(`The challenge authorization URI '${parsed.authorization}' is invalid.`);
1480
+ }
1481
+ }
1482
+ return parsed;
1537
1483
  }
1484
+
1485
+ // Copyright (c) Microsoft Corporation.
1538
1486
  /**
1539
1487
  * @internal
1540
1488
  *
@@ -1555,9 +1503,9 @@ function createChallengeCallbacks() {
1555
1503
  return {
1556
1504
  abortSignal: request.abortSignal,
1557
1505
  requestOptions: {
1558
- timeout: request.timeout
1506
+ timeout: request.timeout,
1559
1507
  },
1560
- tracingOptions: request.tracingOptions
1508
+ tracingOptions: request.tracingOptions,
1561
1509
  };
1562
1510
  }
1563
1511
  async function authorizeRequest(options) {
@@ -1567,7 +1515,7 @@ function createChallengeCallbacks() {
1567
1515
  case "none":
1568
1516
  challengeState = {
1569
1517
  status: "started",
1570
- originalBody: request.body
1518
+ originalBody: request.body,
1571
1519
  };
1572
1520
  request.body = null;
1573
1521
  break;
@@ -1597,24 +1545,118 @@ function createChallengeCallbacks() {
1597
1545
  throw new Error("Missing challenge.");
1598
1546
  }
1599
1547
  const parsedChallenge = parseWWWAuthenticate(challenge) || [];
1600
- const accessToken = await options.getAccessToken(parsedChallenge.scope ? [parsedChallenge.scope] : scopes, getTokenOptions);
1548
+ const accessToken = await options.getAccessToken(parsedChallenge.scope ? [parsedChallenge.scope] : scopes, Object.assign(Object.assign({}, getTokenOptions), { tenantId: parsedChallenge.tenantId }));
1601
1549
  if (!accessToken) {
1602
1550
  return false;
1603
1551
  }
1604
1552
  options.request.headers.set("Authorization", `Bearer ${accessToken.token}`);
1605
1553
  challengeState = {
1606
- status: "complete"
1554
+ status: "complete",
1607
1555
  };
1608
1556
  return true;
1609
1557
  }
1610
1558
  return {
1611
1559
  authorizeRequest,
1612
- authorizeRequestOnChallenge
1560
+ authorizeRequestOnChallenge,
1561
+ };
1562
+ }
1563
+
1564
+ // Copyright (c) Microsoft Corporation.
1565
+ /**
1566
+ * Returns a function that can be used for tracing options.
1567
+ *
1568
+ * @param prefix - The prefix to use, likely the name of the class / client.
1569
+ *
1570
+ * @example const withTrace = createTraceFunction("Azure.KeyVault.Certificates.CertificateClient")
1571
+ *
1572
+ * @internal
1573
+ */
1574
+ function createTraceFunction(prefix) {
1575
+ const createSpan = coreTracing.createSpanFunction({
1576
+ namespace: "Microsoft.KeyVault",
1577
+ packagePrefix: prefix,
1578
+ });
1579
+ return async function (operationName, options, cb) {
1580
+ const { updatedOptions, span } = createSpan(operationName, options);
1581
+ try {
1582
+ // NOTE: we really do need to await on this function here so we can handle any exceptions thrown and properly
1583
+ // close the span.
1584
+ const result = await cb(updatedOptions, span);
1585
+ // otel 0.16+ needs this or else the code ends up being set as UNSET
1586
+ span.setStatus({
1587
+ code: coreTracing.SpanStatusCode.OK,
1588
+ });
1589
+ return result;
1590
+ }
1591
+ catch (err) {
1592
+ span.setStatus({
1593
+ code: coreTracing.SpanStatusCode.ERROR,
1594
+ message: err.message,
1595
+ });
1596
+ throw err;
1597
+ }
1598
+ finally {
1599
+ span.end();
1600
+ }
1613
1601
  };
1614
1602
  }
1615
1603
 
1616
1604
  // Copyright (c) Microsoft Corporation.
1617
- const withTrace = createTraceFunction("Azure.KeyVault.Admin.KeyVaultAccessControlClient");
1605
+ /**
1606
+ * The \@azure/logger configuration for this package.
1607
+ */
1608
+ const logger = logger$1.createClientLogger("keyvault-admin");
1609
+
1610
+ // Copyright (c) Microsoft Corporation.
1611
+ // Licensed under the MIT license.
1612
+ const mappings = {
1613
+ roleAssignment: {
1614
+ generatedToPublic(roleAssignment) {
1615
+ const { id, name, type, properties } = roleAssignment;
1616
+ const { scope, roleDefinitionId, principalId } = properties || {};
1617
+ return {
1618
+ id: id,
1619
+ name: name,
1620
+ kind: type,
1621
+ properties: {
1622
+ scope: scope,
1623
+ roleDefinitionId: roleDefinitionId,
1624
+ principalId: principalId,
1625
+ },
1626
+ };
1627
+ },
1628
+ },
1629
+ roleDefinition: {
1630
+ generatedToPublic(roleDefinition) {
1631
+ const { id, name, type, roleName, description, roleType, permissions, assignableScopes } = roleDefinition;
1632
+ return {
1633
+ id: id,
1634
+ name: name,
1635
+ kind: type,
1636
+ roleName: roleName,
1637
+ description: description,
1638
+ roleType: roleType,
1639
+ permissions: permissions,
1640
+ assignableScopes: assignableScopes,
1641
+ };
1642
+ },
1643
+ },
1644
+ folderUriParts(folderUri) {
1645
+ const uriParts = folderUri.split("/");
1646
+ const folderName = uriParts.pop();
1647
+ const storageUri = uriParts.join("/");
1648
+ if (!folderName) {
1649
+ throw new Error("The provided folder URI is missing the folder name.");
1650
+ }
1651
+ return {
1652
+ folderName,
1653
+ folderUri: storageUri,
1654
+ };
1655
+ },
1656
+ };
1657
+
1658
+ // Copyright (c) Microsoft Corporation.
1659
+ const withTrace$3 = createTraceFunction("Azure.KeyVault.Admin.KeyVaultAccessControlClient");
1618
1660
  /**
1619
1661
  * The KeyVaultAccessControlClient provides methods to manage
1620
1662
  * access control and role assignments in any given Azure Key Vault instance.
@@ -1646,14 +1688,14 @@ class KeyVaultAccessControlClient {
1646
1688
  additionalAllowedHeaderNames: [
1647
1689
  "x-ms-keyvault-region",
1648
1690
  "x-ms-keyvault-network-info",
1649
- "x-ms-keyvault-service-version"
1650
- ]
1691
+ "x-ms-keyvault-service-version",
1692
+ ],
1651
1693
  } });
1652
1694
  this.client = new KeyVaultClient(serviceVersion, clientOptions);
1653
1695
  this.client.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
1654
1696
  credential,
1655
1697
  scopes: authenticationScopes,
1656
- challengeCallbacks: createChallengeCallbacks()
1698
+ challengeCallbacks: createChallengeCallbacks(),
1657
1699
  }));
1658
1700
  }
1659
1701
  /**
@@ -1674,12 +1716,12 @@ class KeyVaultAccessControlClient {
1674
1716
  * @param options - The optional parameters.
1675
1717
  */
1676
1718
  createRoleAssignment(roleScope, name, roleDefinitionId, principalId, options = {}) {
1677
- return withTrace("createRoleAssignment", options, async (updatedOptions) => {
1719
+ return withTrace$3("createRoleAssignment", options, async (updatedOptions) => {
1678
1720
  const response = await this.client.roleAssignments.create(this.vaultUrl, roleScope, name, {
1679
1721
  properties: {
1680
1722
  roleDefinitionId,
1681
- principalId
1682
- }
1723
+ principalId,
1724
+ },
1683
1725
  }, updatedOptions);
1684
1726
  return mappings.roleAssignment.generatedToPublic(response);
1685
1727
  });
@@ -1699,7 +1741,7 @@ class KeyVaultAccessControlClient {
1699
1741
  * @param options - The optional parameters.
1700
1742
  */
1701
1743
  deleteRoleAssignment(roleScope, name, options = {}) {
1702
- return withTrace("deleteRoleAssignment", options, async (updatedOptions) => {
1744
+ return withTrace$3("deleteRoleAssignment", options, async (updatedOptions) => {
1703
1745
  await this.client.roleAssignments.delete(this.vaultUrl, roleScope, name, updatedOptions);
1704
1746
  });
1705
1747
  }
@@ -1719,13 +1761,12 @@ class KeyVaultAccessControlClient {
1719
1761
  * @param options - The optional parameters.
1720
1762
  */
1721
1763
  getRoleAssignment(roleScope, name, options = {}) {
1722
- return withTrace("getRoleAssignment", options, async (updatedOptions) => {
1764
+ return withTrace$3("getRoleAssignment", options, async (updatedOptions) => {
1723
1765
  const response = await this.client.roleAssignments.get(this.vaultUrl, roleScope, name, updatedOptions);
1724
1766
  return mappings.roleAssignment.generatedToPublic(response);
1725
1767
  });
1726
1768
  }
1727
1769
  /**
1728
- * @internal
1729
1770
  * Deals with the pagination of {@link listRoleAssignments}.
1730
1771
  * @param roleScope - The scope of the role assignments.
1731
1772
  * @param continuationState - An object that indicates the position of the paginated request.
@@ -1735,7 +1776,7 @@ class KeyVaultAccessControlClient {
1735
1776
  return tslib.__asyncGenerator(this, arguments, function* listRoleAssignmentsPage_1() {
1736
1777
  if (!continuationState.continuationToken) {
1737
1778
  const optionsComplete = options || {};
1738
- const currentSetResponse = yield tslib.__await(withTrace("listRoleAssignments", optionsComplete, async (updatedOptions) => {
1779
+ const currentSetResponse = yield tslib.__await(withTrace$3("listRoleAssignments", optionsComplete, async (updatedOptions) => {
1739
1780
  return this.client.roleAssignments.listForScope(this.vaultUrl, roleScope, updatedOptions);
1740
1781
  }));
1741
1782
  continuationState.continuationToken = currentSetResponse.nextLink;
@@ -1744,7 +1785,7 @@ class KeyVaultAccessControlClient {
1744
1785
  }
1745
1786
  }
1746
1787
  while (continuationState.continuationToken) {
1747
- const currentSetResponse = yield tslib.__await(withTrace("listRoleAssignments", options || {}, async (updatedOptions) => {
1788
+ const currentSetResponse = yield tslib.__await(withTrace$3("listRoleAssignments", options || {}, async (updatedOptions) => {
1748
1789
  return this.client.roleAssignments.listForScopeNext(this.vaultUrl, roleScope, continuationState.continuationToken, updatedOptions);
1749
1790
  }));
1750
1791
  continuationState.continuationToken = currentSetResponse.nextLink;
@@ -1758,7 +1799,6 @@ class KeyVaultAccessControlClient {
1758
1799
  });
1759
1800
  }
1760
1801
  /**
1761
- * @internal
1762
1802
  * Deals with the iteration of all the available results of {@link listRoleAssignments}.
1763
1803
  * @param roleScope - The scope of the role assignments.
1764
1804
  * @param options - Common options for the iterative endpoints.
@@ -1804,11 +1844,10 @@ class KeyVaultAccessControlClient {
1804
1844
  [Symbol.asyncIterator]() {
1805
1845
  return this;
1806
1846
  },
1807
- byPage: (settings = {}) => this.listRoleAssignmentsPage(roleScope, settings, options)
1847
+ byPage: (settings = {}) => this.listRoleAssignmentsPage(roleScope, settings, options),
1808
1848
  };
1809
1849
  }
1810
1850
  /**
1811
- * @internal
1812
1851
  * Deals with the pagination of {@link listRoleDefinitions}.
1813
1852
  * @param roleScope - The scope of the role definition.
1814
1853
  * @param continuationState - An object that indicates the position of the paginated request.
@@ -1818,14 +1857,14 @@ class KeyVaultAccessControlClient {
1818
1857
  return tslib.__asyncGenerator(this, arguments, function* listRoleDefinitionsPage_1() {
1819
1858
  if (!continuationState.continuationToken) {
1820
1859
  const optionsComplete = options || {};
1821
- const currentSetResponse = yield tslib.__await(withTrace("listRoleDefinitions", optionsComplete, (updatedOptions) => this.client.roleDefinitions.list(this.vaultUrl, roleScope, updatedOptions)));
1860
+ const currentSetResponse = yield tslib.__await(withTrace$3("listRoleDefinitions", optionsComplete, (updatedOptions) => this.client.roleDefinitions.list(this.vaultUrl, roleScope, updatedOptions)));
1822
1861
  continuationState.continuationToken = currentSetResponse.nextLink;
1823
1862
  if (currentSetResponse.value) {
1824
1863
  yield yield tslib.__await(currentSetResponse.value.map(mappings.roleDefinition.generatedToPublic, this));
1825
1864
  }
1826
1865
  }
1827
1866
  while (continuationState.continuationToken) {
1828
- const currentSetResponse = yield tslib.__await(withTrace("listRoleDefinitions", options, (updatedOptions) => this.client.roleDefinitions.listNext(this.vaultUrl, roleScope, continuationState.continuationToken, updatedOptions)));
1867
+ const currentSetResponse = yield tslib.__await(withTrace$3("listRoleDefinitions", options, (updatedOptions) => this.client.roleDefinitions.listNext(this.vaultUrl, roleScope, continuationState.continuationToken, updatedOptions)));
1829
1868
  continuationState.continuationToken = currentSetResponse.nextLink;
1830
1869
  if (currentSetResponse.value) {
1831
1870
  yield yield tslib.__await(currentSetResponse.value.map(mappings.roleDefinition.generatedToPublic, this));
@@ -1837,7 +1876,6 @@ class KeyVaultAccessControlClient {
1837
1876
  });
1838
1877
  }
1839
1878
  /**
1840
- * @internal
1841
1879
  * Deals with the iteration of all the available results of {@link listRoleDefinitions}.
1842
1880
  * @param roleScope - The scope of the role definition.
1843
1881
  * @param options - Common options for the iterative endpoints.
@@ -1883,7 +1921,7 @@ class KeyVaultAccessControlClient {
1883
1921
  [Symbol.asyncIterator]() {
1884
1922
  return this;
1885
1923
  },
1886
- byPage: (settings = {}) => this.listRoleDefinitionsPage(roleScope, settings, options)
1924
+ byPage: (settings = {}) => this.listRoleDefinitionsPage(roleScope, settings, options),
1887
1925
  };
1888
1926
  }
1889
1927
  /**
@@ -1900,7 +1938,7 @@ class KeyVaultAccessControlClient {
1900
1938
  * @param options - The optional parameters.
1901
1939
  */
1902
1940
  getRoleDefinition(roleScope, name, options = {}) {
1903
- return withTrace("getRoleDefinition", options, async (updatedOptions) => {
1941
+ return withTrace$3("getRoleDefinition", options, async (updatedOptions) => {
1904
1942
  const response = await this.client.roleDefinitions.get(this.vaultUrl, roleScope, name, updatedOptions);
1905
1943
  return mappings.roleDefinition.generatedToPublic(response);
1906
1944
  });
@@ -1917,21 +1955,18 @@ class KeyVaultAccessControlClient {
1917
1955
  * console.log(roleDefinition);
1918
1956
  * ```
1919
1957
  * @param roleScope - The scope of the role definition.
1920
- * @param name - The name of the role definition. Must be a UUID.
1921
- * @param permissions - The set of {@link KeyVaultPermission} for this role definition.
1922
- * @param description - The role definition description.
1923
1958
  * @param options - The optional parameters.
1924
1959
  */
1925
1960
  setRoleDefinition(roleScope, options = {}) {
1926
- return withTrace("setRoleDefinition", options, async (updatedOptions) => {
1961
+ return withTrace$3("setRoleDefinition", options, async (updatedOptions) => {
1927
1962
  const response = await this.client.roleDefinitions.createOrUpdate(this.vaultUrl, roleScope, options.roleDefinitionName || uuid.v4(), {
1928
1963
  properties: {
1929
1964
  description: options.description,
1930
1965
  permissions: options.permissions,
1931
1966
  assignableScopes: [roleScope],
1932
1967
  roleName: options.roleName,
1933
- roleType: "CustomRole"
1934
- }
1968
+ roleType: "CustomRole",
1969
+ },
1935
1970
  }, updatedOptions);
1936
1971
  return mappings.roleDefinition.generatedToPublic(response);
1937
1972
  });
@@ -1950,79 +1985,118 @@ class KeyVaultAccessControlClient {
1950
1985
  * @param options - The optional parameters.
1951
1986
  */
1952
1987
  deleteRoleDefinition(roleScope, name, options = {}) {
1953
- return withTrace("deleteRoleDefinition", options, async (updatedOptions) => {
1988
+ return withTrace$3("deleteRoleDefinition", options, async (updatedOptions) => {
1954
1989
  await this.client.roleDefinitions.delete(this.vaultUrl, roleScope, name, updatedOptions);
1955
1990
  });
1956
1991
  }
1957
1992
  }
1958
1993
 
1959
- // Copyright (c) Microsoft Corporation.
1960
- (function (KnownKeyVaultDataAction) {
1994
+ /*
1995
+ * Copyright (c) Microsoft Corporation.
1996
+ * Licensed under the MIT License.
1997
+ *
1998
+ * Code generated by Microsoft (R) AutoRest Code Generator.
1999
+ * Changes may cause incorrect behavior and will be lost if the code is regenerated.
2000
+ */
2001
+ /** Known values of {@link ApiVersion73} that the service accepts. */
2002
+ var KnownApiVersion73;
2003
+ (function (KnownApiVersion73) {
2004
+ /** Api Version '7.3' */
2005
+ KnownApiVersion73["Seven3"] = "7.3";
2006
+ })(KnownApiVersion73 || (KnownApiVersion73 = {}));
2007
+ /** Known values of {@link RoleType} that the service accepts. */
2008
+ var KnownRoleType;
2009
+ (function (KnownRoleType) {
2010
+ /** Built in role. */
2011
+ KnownRoleType["BuiltInRole"] = "AKVBuiltInRole";
2012
+ /** Custom role. */
2013
+ KnownRoleType["CustomRole"] = "CustomRole";
2014
+ })(KnownRoleType || (KnownRoleType = {}));
2015
+ /** Known values of {@link DataAction} that the service accepts. */
2016
+ exports.KnownKeyVaultDataAction = void 0;
2017
+ (function (KnownDataAction) {
1961
2018
  /** Read HSM key metadata. */
1962
- KnownKeyVaultDataAction["ReadHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/read/action";
2019
+ KnownDataAction["ReadHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/read/action";
1963
2020
  /** Update an HSM key. */
1964
- KnownKeyVaultDataAction["WriteHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/write/action";
2021
+ KnownDataAction["WriteHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/write/action";
1965
2022
  /** Read deleted HSM key. */
1966
- KnownKeyVaultDataAction["ReadDeletedHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/deletedKeys/read/action";
2023
+ KnownDataAction["ReadDeletedHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/deletedKeys/read/action";
1967
2024
  /** Recover deleted HSM key. */
1968
- KnownKeyVaultDataAction["RecoverDeletedHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/deletedKeys/recover/action";
2025
+ KnownDataAction["RecoverDeletedHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/deletedKeys/recover/action";
1969
2026
  /** Backup HSM keys. */
1970
- KnownKeyVaultDataAction["BackupHsmKeys"] = "Microsoft.KeyVault/managedHsm/keys/backup/action";
2027
+ KnownDataAction["BackupHsmKeys"] = "Microsoft.KeyVault/managedHsm/keys/backup/action";
1971
2028
  /** Restore HSM keys. */
1972
- KnownKeyVaultDataAction["RestoreHsmKeys"] = "Microsoft.KeyVault/managedHsm/keys/restore/action";
2029
+ KnownDataAction["RestoreHsmKeys"] = "Microsoft.KeyVault/managedHsm/keys/restore/action";
1973
2030
  /** Delete role assignment. */
1974
- KnownKeyVaultDataAction["DeleteRoleAssignment"] = "Microsoft.KeyVault/managedHsm/roleAssignments/delete/action";
2031
+ KnownDataAction["DeleteRoleAssignment"] = "Microsoft.KeyVault/managedHsm/roleAssignments/delete/action";
1975
2032
  /** Get role assignment. */
1976
- KnownKeyVaultDataAction["GetRoleAssignment"] = "Microsoft.KeyVault/managedHsm/roleAssignments/read/action";
2033
+ KnownDataAction["GetRoleAssignment"] = "Microsoft.KeyVault/managedHsm/roleAssignments/read/action";
1977
2034
  /** Create or update role assignment. */
1978
- KnownKeyVaultDataAction["WriteRoleAssignment"] = "Microsoft.KeyVault/managedHsm/roleAssignments/write/action";
2035
+ KnownDataAction["WriteRoleAssignment"] = "Microsoft.KeyVault/managedHsm/roleAssignments/write/action";
1979
2036
  /** Get role definition. */
1980
- KnownKeyVaultDataAction["ReadRoleDefinition"] = "Microsoft.KeyVault/managedHsm/roleDefinitions/read/action";
2037
+ KnownDataAction["ReadRoleDefinition"] = "Microsoft.KeyVault/managedHsm/roleDefinitions/read/action";
2038
+ /** Create or update role definition. */
2039
+ KnownDataAction["WriteRoleDefinition"] = "Microsoft.KeyVault/managedHsm/roleDefinitions/write/action";
2040
+ /** Delete role definition. */
2041
+ KnownDataAction["DeleteRoleDefinition"] = "Microsoft.KeyVault/managedHsm/roleDefinitions/delete/action";
1981
2042
  /** Encrypt using an HSM key. */
1982
- KnownKeyVaultDataAction["EncryptHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/encrypt/action";
2043
+ KnownDataAction["EncryptHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/encrypt/action";
1983
2044
  /** Decrypt using an HSM key. */
1984
- KnownKeyVaultDataAction["DecryptHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/decrypt/action";
2045
+ KnownDataAction["DecryptHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/decrypt/action";
1985
2046
  /** Wrap using an HSM key. */
1986
- KnownKeyVaultDataAction["WrapHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/wrap/action";
2047
+ KnownDataAction["WrapHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/wrap/action";
1987
2048
  /** Unwrap using an HSM key. */
1988
- KnownKeyVaultDataAction["UnwrapHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/unwrap/action";
2049
+ KnownDataAction["UnwrapHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/unwrap/action";
1989
2050
  /** Sign using an HSM key. */
1990
- KnownKeyVaultDataAction["SignHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/sign/action";
2051
+ KnownDataAction["SignHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/sign/action";
1991
2052
  /** Verify using an HSM key. */
1992
- KnownKeyVaultDataAction["VerifyHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/verify/action";
2053
+ KnownDataAction["VerifyHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/verify/action";
1993
2054
  /** Create an HSM key. */
1994
- KnownKeyVaultDataAction["CreateHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/create";
2055
+ KnownDataAction["CreateHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/create";
1995
2056
  /** Delete an HSM key. */
1996
- KnownKeyVaultDataAction["DeleteHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/delete";
2057
+ KnownDataAction["DeleteHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/delete";
1997
2058
  /** Export an HSM key. */
1998
- KnownKeyVaultDataAction["ExportHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/export/action";
2059
+ KnownDataAction["ExportHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/export/action";
2060
+ /** Release an HSM key using Secure Key Release. */
2061
+ KnownDataAction["ReleaseKey"] = "Microsoft.KeyVault/managedHsm/keys/release/action";
1999
2062
  /** Import an HSM key. */
2000
- KnownKeyVaultDataAction["ImportHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/import/action";
2063
+ KnownDataAction["ImportHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/import/action";
2001
2064
  /** Purge a deleted HSM key. */
2002
- KnownKeyVaultDataAction["PurgeDeletedHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/deletedKeys/delete";
2065
+ KnownDataAction["PurgeDeletedHsmKey"] = "Microsoft.KeyVault/managedHsm/keys/deletedKeys/delete";
2003
2066
  /** Download an HSM security domain. */
2004
- KnownKeyVaultDataAction["DownloadHsmSecurityDomain"] = "Microsoft.KeyVault/managedHsm/securitydomain/download/action";
2067
+ KnownDataAction["DownloadHsmSecurityDomain"] = "Microsoft.KeyVault/managedHsm/securitydomain/download/action";
2068
+ /** Check status of HSM security domain download. */
2069
+ KnownDataAction["DownloadHsmSecurityDomainStatus"] = "Microsoft.KeyVault/managedHsm/securitydomain/download/read";
2005
2070
  /** Upload an HSM security domain. */
2006
- KnownKeyVaultDataAction["UploadHsmSecurityDomain"] = "Microsoft.KeyVault/managedHsm/securitydomain/upload/action";
2071
+ KnownDataAction["UploadHsmSecurityDomain"] = "Microsoft.KeyVault/managedHsm/securitydomain/upload/action";
2007
2072
  /** Check the status of the HSM security domain exchange file. */
2008
- KnownKeyVaultDataAction["ReadHsmSecurityDomainStatus"] = "Microsoft.KeyVault/managedHsm/securitydomain/upload/read";
2073
+ KnownDataAction["ReadHsmSecurityDomainStatus"] = "Microsoft.KeyVault/managedHsm/securitydomain/upload/read";
2009
2074
  /** Download an HSM security domain transfer key. */
2010
- KnownKeyVaultDataAction["ReadHsmSecurityDomainTransferKey"] = "Microsoft.KeyVault/managedHsm/securitydomain/transferkey/read";
2075
+ KnownDataAction["ReadHsmSecurityDomainTransferKey"] = "Microsoft.KeyVault/managedHsm/securitydomain/transferkey/read";
2011
2076
  /** Start an HSM backup. */
2012
- KnownKeyVaultDataAction["StartHsmBackup"] = "Microsoft.KeyVault/managedHsm/backup/start/action";
2077
+ KnownDataAction["StartHsmBackup"] = "Microsoft.KeyVault/managedHsm/backup/start/action";
2013
2078
  /** Start an HSM restore. */
2014
- KnownKeyVaultDataAction["StartHsmRestore"] = "Microsoft.KeyVault/managedHsm/restore/start/action";
2079
+ KnownDataAction["StartHsmRestore"] = "Microsoft.KeyVault/managedHsm/restore/start/action";
2015
2080
  /** Read an HSM backup status. */
2016
- KnownKeyVaultDataAction["ReadHsmBackupStatus"] = "Microsoft.KeyVault/managedHsm/backup/status/action";
2081
+ KnownDataAction["ReadHsmBackupStatus"] = "Microsoft.KeyVault/managedHsm/backup/status/action";
2017
2082
  /** Read an HSM restore status. */
2018
- KnownKeyVaultDataAction["ReadHsmRestoreStatus"] = "Microsoft.KeyVault/managedHsm/restore/status/action";
2083
+ KnownDataAction["ReadHsmRestoreStatus"] = "Microsoft.KeyVault/managedHsm/restore/status/action";
2084
+ /** Generate random numbers. */
2085
+ KnownDataAction["RandomNumbersGenerate"] = "Microsoft.KeyVault/managedHsm/rng/action";
2019
2086
  })(exports.KnownKeyVaultDataAction || (exports.KnownKeyVaultDataAction = {}));
2020
- (function (KnownKeyVaultRoleScope) {
2087
+ /** Known values of {@link RoleScope} that the service accepts. */
2088
+ exports.KnownKeyVaultRoleScope = void 0;
2089
+ (function (KnownRoleScope) {
2021
2090
  /** Global scope */
2022
- KnownKeyVaultRoleScope["Global"] = "/";
2091
+ KnownRoleScope["Global"] = "/";
2023
2092
  /** Keys scope */
2024
- KnownKeyVaultRoleScope["Keys"] = "/keys";
2093
+ KnownRoleScope["Keys"] = "/keys";
2025
2094
  })(exports.KnownKeyVaultRoleScope || (exports.KnownKeyVaultRoleScope = {}));
2095
+ /** Known values of {@link RoleDefinitionType} that the service accepts. */
2096
+ var KnownRoleDefinitionType;
2097
+ (function (KnownRoleDefinitionType) {
2098
+ KnownRoleDefinitionType["MicrosoftAuthorizationRoleDefinitions"] = "Microsoft.Authorization/roleDefinitions";
2099
+ })(KnownRoleDefinitionType || (KnownRoleDefinitionType = {}));
2026
2100
 
2027
2101
  // Copyright (c) Microsoft Corporation.
2028
2102
  /**
@@ -2039,7 +2113,7 @@ function cleanState(state) {
2039
2113
  isCancelled: state.isCancelled,
2040
2114
  isCompleted: state.isCompleted,
2041
2115
  error: state.error,
2042
- result: state.result
2116
+ result: state.result,
2043
2117
  };
2044
2118
  }
2045
2119
  /**
@@ -2091,7 +2165,7 @@ class KeyVaultAdminPollOperation {
2091
2165
  */
2092
2166
  toString() {
2093
2167
  return JSON.stringify({
2094
- state: cleanState(this.state)
2168
+ state: cleanState(this.state),
2095
2169
  });
2096
2170
  }
2097
2171
  }
@@ -2100,7 +2174,7 @@ class KeyVaultAdminPollOperation {
2100
2174
  /**
2101
2175
  * @internal
2102
2176
  */
2103
- const withTrace$1 = createTraceFunction("Azure.KeyVault.Admin.KeyVaultBackupPoller");
2177
+ const withTrace$2 = createTraceFunction("Azure.KeyVault.Admin.KeyVaultBackupPoller");
2104
2178
  /**
2105
2179
  * The backup Key Vault's poll operation.
2106
2180
  */
@@ -2116,13 +2190,13 @@ class KeyVaultBackupPollOperation extends KeyVaultAdminPollOperation {
2116
2190
  * Tracing the fullBackup operation
2117
2191
  */
2118
2192
  fullBackup(options) {
2119
- return withTrace$1("fullBackup", options, (updatedOptions) => this.client.fullBackup(this.vaultUrl, updatedOptions));
2193
+ return withTrace$2("fullBackup", options, (updatedOptions) => this.client.fullBackup(this.vaultUrl, updatedOptions));
2120
2194
  }
2121
2195
  /**
2122
2196
  * Tracing the fullBackupStatus operation
2123
2197
  */
2124
2198
  fullBackupStatus(jobId, options) {
2125
- return withTrace$1("fullBackupStatus", options, (updatedOptions) => this.client.fullBackupStatus(this.vaultUrl, jobId, updatedOptions));
2199
+ return withTrace$2("fullBackupStatus", options, (updatedOptions) => this.client.fullBackupStatus(this.vaultUrl, jobId, updatedOptions));
2126
2200
  }
2127
2201
  /**
2128
2202
  * Reaches to the service and updates the backup's poll operation.
@@ -2136,7 +2210,7 @@ class KeyVaultBackupPollOperation extends KeyVaultAdminPollOperation {
2136
2210
  if (!state.isStarted) {
2137
2211
  const serviceOperation = await this.fullBackup(Object.assign(Object.assign({}, this.requestOptions), { azureStorageBlobContainerUri: {
2138
2212
  storageResourceUri: blobStorageUri,
2139
- token: sasToken
2213
+ token: sasToken,
2140
2214
  } }));
2141
2215
  this.mapState(serviceOperation);
2142
2216
  }
@@ -2151,7 +2225,7 @@ class KeyVaultBackupPollOperation extends KeyVaultAdminPollOperation {
2151
2225
  }
2152
2226
  mapState(serviceOperation) {
2153
2227
  const state = this.state;
2154
- const { startTime, jobId, azureStorageBlobContainerUri, endTime, error, status, statusDetails } = serviceOperation;
2228
+ const { startTime, jobId, azureStorageBlobContainerUri, endTime, error, status, statusDetails, } = serviceOperation;
2155
2229
  if (!startTime) {
2156
2230
  throw new Error(`Missing "startTime" from the full backup operation. Full backup did not start successfully.`);
2157
2231
  }
@@ -2169,7 +2243,7 @@ class KeyVaultBackupPollOperation extends KeyVaultAdminPollOperation {
2169
2243
  state.result = {
2170
2244
  folderUri: azureStorageBlobContainerUri,
2171
2245
  startTime,
2172
- endTime
2246
+ endTime,
2173
2247
  };
2174
2248
  }
2175
2249
  }
@@ -2181,7 +2255,7 @@ class KeyVaultBackupPollOperation extends KeyVaultAdminPollOperation {
2181
2255
  */
2182
2256
  class KeyVaultBackupPoller extends KeyVaultAdminPoller {
2183
2257
  constructor(options) {
2184
- const { client, vaultUrl, blobStorageUri, sasToken, requestOptions, intervalInMs = 2000, resumeFrom } = options;
2258
+ const { client, vaultUrl, blobStorageUri, sasToken, requestOptions, intervalInMs = 2000, resumeFrom, } = options;
2185
2259
  let state;
2186
2260
  if (resumeFrom) {
2187
2261
  state = JSON.parse(resumeFrom).state;
@@ -2197,14 +2271,14 @@ class KeyVaultBackupPoller extends KeyVaultAdminPoller {
2197
2271
  /**
2198
2272
  * @internal
2199
2273
  */
2200
- const withTrace$2 = createTraceFunction("Azure.KeyVault.Admin.KeyVaultRestorePoller");
2274
+ const withTrace$1 = createTraceFunction("Azure.KeyVault.Admin.KeyVaultRestorePoller");
2201
2275
  /**
2202
2276
  * An interface representing a restore Key Vault's poll operation.
2203
2277
  */
2204
2278
  class KeyVaultRestorePollOperation extends KeyVaultAdminPollOperation {
2205
2279
  constructor(state, vaultUrl, client, requestOptions = {}) {
2206
2280
  super(state, {
2207
- cancelMessage: "Cancelling the restoration full Key Vault backup is not supported."
2281
+ cancelMessage: "Cancelling the restoration full Key Vault backup is not supported.",
2208
2282
  });
2209
2283
  this.state = state;
2210
2284
  this.vaultUrl = vaultUrl;
@@ -2215,13 +2289,13 @@ class KeyVaultRestorePollOperation extends KeyVaultAdminPollOperation {
2215
2289
  * Tracing the fullRestore operation
2216
2290
  */
2217
2291
  fullRestore(options) {
2218
- return withTrace$2("fullRestore", options, (updatedOptions) => this.client.fullRestoreOperation(this.vaultUrl, updatedOptions));
2292
+ return withTrace$1("fullRestore", options, (updatedOptions) => this.client.fullRestoreOperation(this.vaultUrl, updatedOptions));
2219
2293
  }
2220
2294
  /**
2221
2295
  * Tracing the restoreStatus operation.
2222
2296
  */
2223
2297
  async restoreStatus(jobId, options) {
2224
- return withTrace$2("restoreStatus", options, (updatedOptions) => this.client.restoreStatus(this.vaultUrl, jobId, updatedOptions));
2298
+ return withTrace$1("restoreStatus", options, (updatedOptions) => this.client.restoreStatus(this.vaultUrl, jobId, updatedOptions));
2225
2299
  }
2226
2300
  /**
2227
2301
  * Reaches to the service and updates the restore poll operation.
@@ -2237,8 +2311,8 @@ class KeyVaultRestorePollOperation extends KeyVaultAdminPollOperation {
2237
2311
  folderToRestore: folderName,
2238
2312
  sasTokenParameters: {
2239
2313
  storageResourceUri: folderUri,
2240
- token: sasToken
2241
- }
2314
+ token: sasToken,
2315
+ },
2242
2316
  } }));
2243
2317
  this.mapState(serviceOperation);
2244
2318
  }
@@ -2270,7 +2344,7 @@ class KeyVaultRestorePollOperation extends KeyVaultAdminPollOperation {
2270
2344
  if (state.isCompleted) {
2271
2345
  state.result = {
2272
2346
  startTime,
2273
- endTime
2347
+ endTime,
2274
2348
  };
2275
2349
  }
2276
2350
  }
@@ -2282,7 +2356,7 @@ class KeyVaultRestorePollOperation extends KeyVaultAdminPollOperation {
2282
2356
  */
2283
2357
  class KeyVaultRestorePoller extends KeyVaultAdminPoller {
2284
2358
  constructor(options) {
2285
- const { client, vaultUrl, folderUri, sasToken, folderName, requestOptions, intervalInMs = 2000, resumeFrom } = options;
2359
+ const { client, vaultUrl, folderUri, sasToken, folderName, requestOptions, intervalInMs = 2000, resumeFrom, } = options;
2286
2360
  let state;
2287
2361
  if (resumeFrom) {
2288
2362
  state = JSON.parse(resumeFrom).state;
@@ -2299,7 +2373,7 @@ class KeyVaultRestorePoller extends KeyVaultAdminPoller {
2299
2373
  /**
2300
2374
  * @internal
2301
2375
  */
2302
- const withTrace$3 = createTraceFunction("Azure.KeyVault.Admin.KeyVaultSelectiveKeyRestorePoller");
2376
+ const withTrace = createTraceFunction("Azure.KeyVault.Admin.KeyVaultSelectiveKeyRestorePoller");
2303
2377
  /**
2304
2378
  * The selective restore Key Vault's poll operation.
2305
2379
  */
@@ -2315,13 +2389,13 @@ class KeyVaultSelectiveKeyRestorePollOperation extends KeyVaultAdminPollOperatio
2315
2389
  * Tracing the selectiveRestore operation
2316
2390
  */
2317
2391
  selectiveRestore(keyName, options) {
2318
- return withTrace$3("selectiveRestore", options, (updatedOptions) => this.client.selectiveKeyRestoreOperation(this.vaultUrl, keyName, updatedOptions));
2392
+ return withTrace("selectiveRestore", options, (updatedOptions) => this.client.selectiveKeyRestoreOperation(this.vaultUrl, keyName, updatedOptions));
2319
2393
  }
2320
2394
  /**
2321
2395
  * Tracing the restoreStatus operation.
2322
2396
  */
2323
2397
  restoreStatus(jobId, options) {
2324
- return withTrace$3("restoreStatus", options, (updatedOptions) => this.client.restoreStatus(this.vaultUrl, jobId, updatedOptions));
2398
+ return withTrace("restoreStatus", options, (updatedOptions) => this.client.restoreStatus(this.vaultUrl, jobId, updatedOptions));
2325
2399
  }
2326
2400
  /**
2327
2401
  * Reaches to the service and updates the selective restore poll operation.
@@ -2337,8 +2411,8 @@ class KeyVaultSelectiveKeyRestorePollOperation extends KeyVaultAdminPollOperatio
2337
2411
  folder: folderName,
2338
2412
  sasTokenParameters: {
2339
2413
  storageResourceUri: folderUri,
2340
- token: sasToken
2341
- }
2414
+ token: sasToken,
2415
+ },
2342
2416
  } }));
2343
2417
  this.mapState(selectiveRestoreOperation);
2344
2418
  }
@@ -2370,7 +2444,7 @@ class KeyVaultSelectiveKeyRestorePollOperation extends KeyVaultAdminPollOperatio
2370
2444
  if (state.isCompleted) {
2371
2445
  state.result = {
2372
2446
  startTime,
2373
- endTime
2447
+ endTime,
2374
2448
  };
2375
2449
  }
2376
2450
  }
@@ -2382,7 +2456,7 @@ class KeyVaultSelectiveKeyRestorePollOperation extends KeyVaultAdminPollOperatio
2382
2456
  */
2383
2457
  class KeyVaultSelectiveKeyRestorePoller extends KeyVaultAdminPoller {
2384
2458
  constructor(options) {
2385
- const { client, vaultUrl, keyName, folderUri, sasToken, folderName, requestOptions, intervalInMs = 2000, resumeFrom } = options;
2459
+ const { client, vaultUrl, keyName, folderUri, sasToken, folderName, requestOptions, intervalInMs = 2000, resumeFrom, } = options;
2386
2460
  let state;
2387
2461
  if (resumeFrom) {
2388
2462
  state = JSON.parse(resumeFrom).state;
@@ -2427,14 +2501,14 @@ class KeyVaultBackupClient {
2427
2501
  additionalAllowedHeaderNames: [
2428
2502
  "x-ms-keyvault-region",
2429
2503
  "x-ms-keyvault-network-info",
2430
- "x-ms-keyvault-service-version"
2431
- ]
2504
+ "x-ms-keyvault-service-version",
2505
+ ],
2432
2506
  } });
2433
2507
  this.client = new KeyVaultClient(apiVersion, clientOptions);
2434
2508
  this.client.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
2435
2509
  credential,
2436
2510
  scopes: authenticationScopes,
2437
- challengeCallbacks: createChallengeCallbacks()
2511
+ challengeCallbacks: createChallengeCallbacks(),
2438
2512
  }));
2439
2513
  }
2440
2514
  /**
@@ -2476,7 +2550,7 @@ class KeyVaultBackupClient {
2476
2550
  vaultUrl: this.vaultUrl,
2477
2551
  intervalInMs: options.intervalInMs,
2478
2552
  resumeFrom: options.resumeFrom,
2479
- requestOptions: options
2553
+ requestOptions: options,
2480
2554
  });
2481
2555
  // This will initialize the poller's operation (the generation of the backup).
2482
2556
  await poller.poll();