@azure/keyvault-admin 4.2.1-alpha.20220330.1 → 4.2.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 (31) hide show
  1. package/dist/index.js +54 -93
  2. package/dist/index.js.map +1 -1
  3. package/dist-esm/keyvault-admin/src/accessControlClient.js +16 -15
  4. package/dist-esm/keyvault-admin/src/accessControlClient.js.map +1 -1
  5. package/dist-esm/keyvault-admin/src/backupClient.js +5 -3
  6. package/dist-esm/keyvault-admin/src/backupClient.js.map +1 -1
  7. package/dist-esm/keyvault-admin/src/constants.js +0 -4
  8. package/dist-esm/keyvault-admin/src/constants.js.map +1 -1
  9. package/dist-esm/keyvault-admin/src/generated/keyVaultClientContext.js +1 -2
  10. package/dist-esm/keyvault-admin/src/generated/keyVaultClientContext.js.map +1 -1
  11. package/dist-esm/keyvault-admin/src/lro/backup/operation.js +3 -7
  12. package/dist-esm/keyvault-admin/src/lro/backup/operation.js.map +1 -1
  13. package/dist-esm/keyvault-admin/src/lro/restore/operation.js +3 -7
  14. package/dist-esm/keyvault-admin/src/lro/restore/operation.js.map +1 -1
  15. package/dist-esm/keyvault-admin/src/lro/selectiveKeyRestore/operation.js +3 -7
  16. package/dist-esm/keyvault-admin/src/lro/selectiveKeyRestore/operation.js.map +1 -1
  17. package/dist-esm/keyvault-admin/src/tracing.js +10 -0
  18. package/dist-esm/keyvault-admin/src/tracing.js.map +1 -0
  19. package/dist-esm/keyvault-common/src/challengeBasedAuthenticationPolicy.js +70 -151
  20. package/dist-esm/keyvault-common/src/challengeBasedAuthenticationPolicy.js.map +1 -1
  21. package/dist-esm/keyvault-common/src/index.js +0 -1
  22. package/dist-esm/keyvault-common/src/index.js.map +1 -1
  23. package/dist-esm/keyvault-common/src/parseKeyvaultIdentifier.js.map +1 -1
  24. package/package.json +10 -10
  25. package/CHANGELOG.md +0 -116
  26. package/dist-esm/keyvault-admin/src/challengeAuthenticationCallbacks.js +0 -81
  27. package/dist-esm/keyvault-admin/src/challengeAuthenticationCallbacks.js.map +0 -1
  28. package/dist-esm/keyvault-admin/src/tracingHelpers.js +0 -42
  29. package/dist-esm/keyvault-admin/src/tracingHelpers.js.map +0 -1
  30. package/dist-esm/keyvault-common/src/tracingHelpers.js +0 -42
  31. package/dist-esm/keyvault-common/src/tracingHelpers.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC/C,SAAS,EAAE,oBAAoB;IAC/B,WAAW,EAAE,uBAAuB;IACpC,cAAc,EAAE,WAAW;CAC5B,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SDK_VERSION } from \"./constants\";\nimport { createTracingClient } from \"@azure/core-tracing\";\n\nexport const tracingClient = createTracingClient({\n namespace: \"Microsoft.KeyVault\",\n packageName: \"@azure/keyvault-admin\",\n packageVersion: SDK_VERSION,\n});\n"]}
@@ -1,169 +1,88 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- /* eslint-disable @azure/azure-sdk/ts-use-interface-parameters */
4
- import { ExpiringAccessTokenCache } from "@azure/core-http";
5
- import { BaseRequestPolicy, } from "@azure/core-http";
6
3
  import { parseWWWAuthenticate } from "./parseWWWAuthenticate";
7
- import { Constants } from "@azure/core-http";
8
4
  /**
9
- * Representation of the Authentication Challenge
10
- */
11
- export class AuthenticationChallenge {
12
- constructor(authorization, scope, tenantId) {
13
- this.authorization = authorization;
14
- this.scope = scope;
15
- this.tenantId = tenantId;
16
- }
17
- /**
18
- * Checks that this AuthenticationChallenge is equal to another one given.
19
- * Only compares the scope.
20
- * This is exactly what C# is doing, as we can see here:
21
- * https://github.com/Azure/azure-sdk-for-net/blob/70e54b878ff1d01a45266fb3674a396b4ab9c1d2/sdk/keyvault/Azure.Security.KeyVault.Shared/src/ChallengeBasedAuthenticationPolicy.cs#L143-L147
22
- * @param other - The other AuthenticationChallenge
23
- */
24
- equalTo(other) {
25
- var _a, _b;
26
- return other
27
- ? this.scope.toLowerCase() === other.scope.toLowerCase() &&
28
- this.authorization.toLowerCase() === other.authorization.toLowerCase() &&
29
- ((_a = this.tenantId) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_b = other.tenantId) === null || _b === void 0 ? void 0 : _b.toLowerCase())
30
- : false;
31
- }
32
- }
33
- /**
34
- * Helps keep a copy of any previous authentication challenges,
35
- * so that we can compare on any further request.
36
- */
37
- export class AuthenticationChallengeCache {
38
- setCachedChallenge(challenge) {
39
- this.challenge = challenge;
40
- }
41
- }
42
- /**
43
- * Creates a new ChallengeBasedAuthenticationPolicy factory.
5
+ * @internal
44
6
  *
45
- * @param credential - The TokenCredential implementation that can supply the challenge token.
46
- */
47
- export function challengeBasedAuthenticationPolicy(credential) {
48
- const tokenCache = new ExpiringAccessTokenCache();
49
- const challengeCache = new AuthenticationChallengeCache();
50
- return {
51
- create: (nextPolicy, options) => {
52
- return new ChallengeBasedAuthenticationPolicy(nextPolicy, options, credential, tokenCache, challengeCache);
53
- },
54
- };
55
- }
56
- /**
7
+ * Creates challenge callback handlers to manage CAE lifecycle in Azure Key Vault.
8
+ *
9
+ * Key Vault supports other authentication schemes, but we ensure challenge authentication
10
+ * is used by first sending a copy of the request, without authorization or content.
57
11
  *
58
- * Provides a RequestPolicy that can request a token from a TokenCredential
59
- * implementation and then apply it to the Authorization header of a request
60
- * as a Bearer token.
12
+ * when the challenge is received, it will be authenticated and used to send the original
13
+ * request with authorization.
61
14
  *
15
+ * Following the first request of a client, follow-up requests will get the cached token
16
+ * if possible.
62
17
  */
63
- export class ChallengeBasedAuthenticationPolicy extends BaseRequestPolicy {
64
- /**
65
- * Creates a new ChallengeBasedAuthenticationPolicy object.
66
- *
67
- * @param nextPolicy - The next RequestPolicy in the request pipeline.
68
- * @param options - Options for this RequestPolicy.
69
- * @param credential - The TokenCredential implementation that can supply the bearer token.
70
- * @param tokenCache - The cache for the most recent AccessToken returned by the TokenCredential.
71
- */
72
- constructor(nextPolicy, options, credential, tokenCache, challengeCache) {
73
- super(nextPolicy, options);
74
- this.credential = credential;
75
- this.tokenCache = tokenCache;
76
- this.challengeCache = challengeCache;
77
- this.parseWWWAuthenticate = parseWWWAuthenticate;
78
- }
79
- /**
80
- * Gets or updates the token from the token cache into the headers of the received web resource.
81
- */
82
- async loadToken(webResource) {
83
- let accessToken = this.tokenCache.getCachedToken();
84
- // If there's no cached token in the cache, we try to get a new one.
85
- if (accessToken === undefined) {
86
- const receivedToken = await this.credential.getToken(this.challengeCache.challenge.scope, {
87
- tenantId: this.challengeCache.challenge.tenantId,
88
- });
89
- accessToken = receivedToken || undefined;
90
- this.tokenCache.setCachedToken(accessToken);
91
- }
92
- if (accessToken) {
93
- webResource.headers.set(Constants.HeaderConstants.AUTHORIZATION, `Bearer ${accessToken.token}`);
94
- }
18
+ export function createChallengeCallbacks() {
19
+ let challengeState = { status: "none" };
20
+ function requestToOptions(request) {
21
+ return {
22
+ abortSignal: request.abortSignal,
23
+ requestOptions: {
24
+ timeout: request.timeout,
25
+ },
26
+ tracingOptions: request.tracingOptions,
27
+ };
95
28
  }
96
- /**
97
- * Parses the given WWW-Authenticate header, generates a new AuthenticationChallenge,
98
- * then if the challenge is different from the one cached, resets the token and forces
99
- * a re-authentication, otherwise continues with the existing challenge and token.
100
- * @param wwwAuthenticate - Value of the incoming WWW-Authenticate header.
101
- * @param webResource - Ongoing HTTP request.
102
- */
103
- async regenerateChallenge(wwwAuthenticate, webResource) {
104
- var _a;
105
- // The challenge based authentication will contain both:
106
- // - An authorization URI with a token,
107
- // - The resource to which that token is valid against (also called the scope).
108
- const parsedWWWAuth = this.parseWWWAuthenticate(wwwAuthenticate);
109
- const authorization = parsedWWWAuth.authorization;
110
- const resource = parsedWWWAuth.resource || parsedWWWAuth.scope;
111
- const tenantId = parsedWWWAuth.tenantId;
112
- if (!(authorization && resource)) {
113
- return this._nextPolicy.sendRequest(webResource);
114
- }
115
- const challenge = new AuthenticationChallenge(authorization, resource + "/.default", tenantId);
116
- // Either if there's no cached challenge at this point (could have happen in parallel),
117
- // or if the cached challenge has a different scope,
118
- // we store the just received challenge and reset the cached token, to force a re-authentication.
119
- if (!((_a = this.challengeCache.challenge) === null || _a === void 0 ? void 0 : _a.equalTo(challenge))) {
120
- this.challengeCache.setCachedChallenge(challenge);
121
- this.tokenCache.setCachedToken(undefined);
29
+ async function authorizeRequest(options) {
30
+ const { request } = options;
31
+ const requestOptions = requestToOptions(request);
32
+ switch (challengeState.status) {
33
+ case "none":
34
+ challengeState = {
35
+ status: "started",
36
+ originalBody: request.body,
37
+ };
38
+ request.body = null;
39
+ break;
40
+ case "started":
41
+ break; // Retry, we should not overwrite the original body
42
+ case "complete": {
43
+ const token = await options.getAccessToken(challengeState.scopes, requestOptions);
44
+ if (token) {
45
+ request.headers.set("authorization", `Bearer ${token.token}`);
46
+ }
47
+ break;
48
+ }
122
49
  }
123
- await this.loadToken(webResource);
124
- return this._nextPolicy.sendRequest(webResource);
50
+ return Promise.resolve();
125
51
  }
126
- /**
127
- * Applies the Bearer token to the request through the Authorization header.
128
- * @param webResource - Ongoing HTTP request.
129
- */
130
- async sendRequest(webResource) {
131
- // Ensure that we're about to use a secure connection.
132
- if (!webResource.url.startsWith("https:")) {
133
- throw new Error("The resource address for authorization must use the 'https' protocol.");
134
- }
135
- // The next request will happen differently whether we have a challenge or not.
136
- let response;
137
- if (this.challengeCache.challenge === undefined ||
138
- this.challengeCache.challenge === undefined) {
139
- // If there's no challenge in cache, a blank body will start the challenge.
140
- const originalBody = webResource.body;
141
- webResource.body = "";
142
- try {
143
- response = await this._nextPolicy.sendRequest(webResource);
144
- }
145
- finally {
146
- webResource.body = originalBody;
147
- }
52
+ async function authorizeRequestOnChallenge(options) {
53
+ const { request, response } = options;
54
+ if (request.body === null && challengeState.status === "started") {
55
+ // Reset the original body before doing anything else.
56
+ // Note: If successful status will be "complete", otherwise "none" will
57
+ // restart the process.
58
+ request.body = challengeState.originalBody;
148
59
  }
149
- else {
150
- // If we did have a challenge in memory,
151
- // we attempt to load the token from the cache into the request before we try to send the request.
152
- await this.loadToken(webResource);
153
- response = await this._nextPolicy.sendRequest(webResource);
60
+ const getTokenOptions = requestToOptions(request);
61
+ const challenge = response.headers.get("WWW-Authenticate");
62
+ if (!challenge) {
63
+ throw new Error("Missing challenge.");
154
64
  }
155
- // If we don't receive a response with a 401 status code,
156
- // then we can assume this response has nothing to do with the challenge authentication process.
157
- if (response.status !== 401) {
158
- return response;
65
+ const parsedChallenge = parseWWWAuthenticate(challenge) || {};
66
+ const scope = parsedChallenge.resource
67
+ ? parsedChallenge.resource + "/.default"
68
+ : parsedChallenge.scope;
69
+ if (!scope) {
70
+ throw new Error("Missing scope.");
159
71
  }
160
- // If the response status is 401, we only re-authenticate if the WWW-Authenticate header is present.
161
- const wwwAuthenticate = response.headers.get("WWW-Authenticate");
162
- if (!wwwAuthenticate) {
163
- return response;
72
+ const accessToken = await options.getAccessToken([scope], Object.assign(Object.assign({}, getTokenOptions), { tenantId: parsedChallenge.tenantId }));
73
+ if (!accessToken) {
74
+ return false;
164
75
  }
165
- // We re-generate the challenge and see if we have to re-authenticate.
166
- return this.regenerateChallenge(wwwAuthenticate, webResource);
76
+ options.request.headers.set("Authorization", `Bearer ${accessToken.token}`);
77
+ challengeState = {
78
+ status: "complete",
79
+ scopes: [scope],
80
+ };
81
+ return true;
167
82
  }
83
+ return {
84
+ authorizeRequest,
85
+ authorizeRequestOnChallenge,
86
+ };
168
87
  }
169
88
  //# sourceMappingURL=challengeBasedAuthenticationPolicy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"challengeBas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3C,IAAI,CAAC,cAAc,CAAC,SAAS,KAAK,SAAS,EAC3C;YACA,2EAA2E;YAC3E,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC;YACtC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;YACtB,IAAI;gBACF,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;aAC5D;oBAAS;gBACR,WAAW,CAAC,IAAI,GAAG,YAAY,CAAC;aACjC;SACF;aAAM;YACL,wCAAwC;YACxC,kGAAkG;YAClG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAClC,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;SAC5D;QAED,yDAAyD;QACzD,gGAAgG;QAChG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;YAC3B,OAAO,QAAQ,CAAC;SACjB;QAED,oGAAoG;QACpG,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACjE,IAAI,CAAC,eAAe,EAAE;YACpB,OAAO,QAAQ,CAAC;SACjB;QAED,sEAAsE;QACtE,OAAO,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable @azure/azure-sdk/ts-use-interface-parameters */\n\nimport { AccessTokenCache, ExpiringAccessTokenCache } from \"@azure/core-http\";\nimport {\n BaseRequestPolicy,\n RequestPolicy,\n RequestPolicyFactory,\n RequestPolicyOptions,\n} from \"@azure/core-http\";\nimport { ParsedWWWAuthenticate, parseWWWAuthenticate } from \"./parseWWWAuthenticate\";\nimport { Constants } from \"@azure/core-http\";\nimport { HttpOperationResponse } from \"@azure/core-http\";\nimport { TokenCredential } from \"@azure/core-http\";\nimport { WebResource } from \"@azure/core-http\";\n\n/**\n * Representation of the Authentication Challenge\n */\nexport class AuthenticationChallenge {\n constructor(public authorization: string, public scope: string, public tenantId?: string) {}\n\n /**\n * Checks that this AuthenticationChallenge is equal to another one given.\n * Only compares the scope.\n * This is exactly what C# is doing, as we can see here:\n * https://github.com/Azure/azure-sdk-for-net/blob/70e54b878ff1d01a45266fb3674a396b4ab9c1d2/sdk/keyvault/Azure.Security.KeyVault.Shared/src/ChallengeBasedAuthenticationPolicy.cs#L143-L147\n * @param other - The other AuthenticationChallenge\n */\n public equalTo(other: AuthenticationChallenge | undefined): boolean {\n return other\n ? this.scope.toLowerCase() === other.scope.toLowerCase() &&\n this.authorization.toLowerCase() === other.authorization.toLowerCase() &&\n this.tenantId?.toLowerCase() === other.tenantId?.toLowerCase()\n : false;\n }\n}\n\n/**\n * Helps keep a copy of any previous authentication challenges,\n * so that we can compare on any further request.\n */\nexport class AuthenticationChallengeCache {\n public challenge?: AuthenticationChallenge;\n\n public setCachedChallenge(challenge: AuthenticationChallenge): void {\n this.challenge = challenge;\n }\n}\n\n/**\n * Creates a new ChallengeBasedAuthenticationPolicy factory.\n *\n * @param credential - The TokenCredential implementation that can supply the challenge token.\n */\nexport function challengeBasedAuthenticationPolicy(\n credential: TokenCredential\n): RequestPolicyFactory {\n const tokenCache: AccessTokenCache = new ExpiringAccessTokenCache();\n const challengeCache = new AuthenticationChallengeCache();\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => {\n return new ChallengeBasedAuthenticationPolicy(\n nextPolicy,\n options,\n credential,\n tokenCache,\n challengeCache\n );\n },\n };\n}\n\n/**\n *\n * Provides a RequestPolicy that can request a token from a TokenCredential\n * implementation and then apply it to the Authorization header of a request\n * as a Bearer token.\n *\n */\nexport class ChallengeBasedAuthenticationPolicy extends BaseRequestPolicy {\n private parseWWWAuthenticate: (wwwAuthenticate: string) => ParsedWWWAuthenticate =\n parseWWWAuthenticate;\n\n /**\n * Creates a new ChallengeBasedAuthenticationPolicy object.\n *\n * @param nextPolicy - The next RequestPolicy in the request pipeline.\n * @param options - Options for this RequestPolicy.\n * @param credential - The TokenCredential implementation that can supply the bearer token.\n * @param tokenCache - The cache for the most recent AccessToken returned by the TokenCredential.\n */\n constructor(\n nextPolicy: RequestPolicy,\n options: RequestPolicyOptions,\n private credential: TokenCredential,\n private tokenCache: AccessTokenCache,\n private challengeCache: AuthenticationChallengeCache\n ) {\n super(nextPolicy, options);\n }\n\n /**\n * Gets or updates the token from the token cache into the headers of the received web resource.\n */\n private async loadToken(webResource: WebResource): Promise<void> {\n let accessToken = this.tokenCache.getCachedToken();\n\n // If there's no cached token in the cache, we try to get a new one.\n if (accessToken === undefined) {\n const receivedToken = await this.credential.getToken(this.challengeCache.challenge!.scope, {\n tenantId: this.challengeCache.challenge!.tenantId,\n });\n accessToken = receivedToken || undefined;\n this.tokenCache.setCachedToken(accessToken);\n }\n\n if (accessToken) {\n webResource.headers.set(\n Constants.HeaderConstants.AUTHORIZATION,\n `Bearer ${accessToken.token}`\n );\n }\n }\n\n /**\n * Parses the given WWW-Authenticate header, generates a new AuthenticationChallenge,\n * then if the challenge is different from the one cached, resets the token and forces\n * a re-authentication, otherwise continues with the existing challenge and token.\n * @param wwwAuthenticate - Value of the incoming WWW-Authenticate header.\n * @param webResource - Ongoing HTTP request.\n */\n private async regenerateChallenge(\n wwwAuthenticate: string,\n webResource: WebResource\n ): Promise<HttpOperationResponse> {\n // The challenge based authentication will contain both:\n // - An authorization URI with a token,\n // - The resource to which that token is valid against (also called the scope).\n const parsedWWWAuth = this.parseWWWAuthenticate(wwwAuthenticate);\n const authorization = parsedWWWAuth.authorization!;\n const resource = parsedWWWAuth.resource! || parsedWWWAuth.scope!;\n const tenantId = parsedWWWAuth.tenantId;\n\n if (!(authorization && resource)) {\n return this._nextPolicy.sendRequest(webResource);\n }\n\n const challenge = new AuthenticationChallenge(authorization, resource + \"/.default\", tenantId);\n\n // Either if there's no cached challenge at this point (could have happen in parallel),\n // or if the cached challenge has a different scope,\n // we store the just received challenge and reset the cached token, to force a re-authentication.\n if (!this.challengeCache.challenge?.equalTo(challenge)) {\n this.challengeCache.setCachedChallenge(challenge);\n this.tokenCache.setCachedToken(undefined);\n }\n\n await this.loadToken(webResource);\n return this._nextPolicy.sendRequest(webResource);\n }\n\n /**\n * Applies the Bearer token to the request through the Authorization header.\n * @param webResource - Ongoing HTTP request.\n */\n public async sendRequest(webResource: WebResource): Promise<HttpOperationResponse> {\n // Ensure that we're about to use a secure connection.\n if (!webResource.url.startsWith(\"https:\")) {\n throw new Error(\"The resource address for authorization must use the 'https' protocol.\");\n }\n\n // The next request will happen differently whether we have a challenge or not.\n let response: HttpOperationResponse;\n\n if (\n this.challengeCache.challenge === undefined ||\n this.challengeCache.challenge === undefined\n ) {\n // If there's no challenge in cache, a blank body will start the challenge.\n const originalBody = webResource.body;\n webResource.body = \"\";\n try {\n response = await this._nextPolicy.sendRequest(webResource);\n } finally {\n webResource.body = originalBody;\n }\n } else {\n // If we did have a challenge in memory,\n // we attempt to load the token from the cache into the request before we try to send the request.\n await this.loadToken(webResource);\n response = await this._nextPolicy.sendRequest(webResource);\n }\n\n // If we don't receive a response with a 401 status code,\n // then we can assume this response has nothing to do with the challenge authentication process.\n if (response.status !== 401) {\n return response;\n }\n\n // If the response status is 401, we only re-authenticate if the WWW-Authenticate header is present.\n const wwwAuthenticate = response.headers.get(\"WWW-Authenticate\");\n if (!wwwAuthenticate) {\n return response;\n }\n\n // We re-generate the challenge and see if we have to re-authenticate.\n return this.regenerateChallenge(wwwAuthenticate, webResource);\n }\n}\n"]}
1
+ {"version":3,"file":"challengeBasedAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../keyvault-common/src/challengeBasedAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EAAyB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AA6BrF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,wBAAw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AO,CAAC,IAAI,GAAG,cAAc,CAAC,YAAY,CAAC;SAC5C;QAED,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAElD,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAC3D,IAAI,CAAC,SAAS,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACvC;QACD,MAAM,eAAe,GAA0B,oBAAoB,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAErF,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ;YACpC,CAAC,CAAC,eAAe,CAAC,QAAQ,GAAG,WAAW;YACxC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC;QAE1B,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;SACnC;QAED,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,kCACnD,eAAe,KAClB,QAAQ,EAAE,eAAe,CAAC,QAAQ,IAClC,CAAC;QAEH,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;QAE5E,cAAc,GAAG;YACf,MAAM,EAAE,UAAU;YAClB,MAAM,EAAE,CAAC,KAAK,CAAC;SAChB,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,gBAAgB;QAChB,2BAA2B;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AuthorizeRequestOnChallengeOptions,\n AuthorizeRequestOptions,\n ChallengeCallbacks,\n PipelineRequest,\n RequestBodyType,\n} from \"@azure/core-rest-pipeline\";\nimport { ParsedWWWAuthenticate, parseWWWAuthenticate } from \"./parseWWWAuthenticate\";\n\nimport { GetTokenOptions } from \"@azure/core-auth\";\n\n/**\n * @internal\n * Holds the state of Challenge Auth.\n * When making the first request we force Key Vault to begin a challenge\n * by clearing out the request body and storing it locally.\n *\n * Later on, the authorizeRequestOnChallenge callback will process the\n * challenge and, if ready to resend the original request, reset the body\n * so that it may be sent again.\n *\n * Once a client has succeeded once, we can start skipping CAE.\n */\ntype ChallengeState =\n | {\n status: \"none\";\n }\n | {\n status: \"started\";\n originalBody?: RequestBodyType;\n }\n | {\n status: \"complete\";\n scopes: string[];\n };\n\n/**\n * @internal\n *\n * Creates challenge callback handlers to manage CAE lifecycle in Azure Key Vault.\n *\n * Key Vault supports other authentication schemes, but we ensure challenge authentication\n * is used by first sending a copy of the request, without authorization or content.\n *\n * when the challenge is received, it will be authenticated and used to send the original\n * request with authorization.\n *\n * Following the first request of a client, follow-up requests will get the cached token\n * if possible.\n */\nexport function createChallengeCallbacks(): ChallengeCallbacks {\n let challengeState: ChallengeState = { status: \"none\" };\n\n function requestToOptions(request: PipelineRequest): GetTokenOptions {\n return {\n abortSignal: request.abortSignal,\n requestOptions: {\n timeout: request.timeout,\n },\n tracingOptions: request.tracingOptions,\n };\n }\n\n async function authorizeRequest(options: AuthorizeRequestOptions) {\n const { request } = options;\n const requestOptions: GetTokenOptions = requestToOptions(request);\n\n switch (challengeState.status) {\n case \"none\":\n challengeState = {\n status: \"started\",\n originalBody: request.body,\n };\n request.body = null;\n break;\n case \"started\":\n break; // Retry, we should not overwrite the original body\n case \"complete\": {\n const token = await options.getAccessToken(challengeState.scopes, requestOptions);\n if (token) {\n request.headers.set(\"authorization\", `Bearer ${token.token}`);\n }\n break;\n }\n }\n return Promise.resolve();\n }\n\n async function authorizeRequestOnChallenge(\n options: AuthorizeRequestOnChallengeOptions\n ): Promise<boolean> {\n const { request, response } = options;\n\n if (request.body === null && challengeState.status === \"started\") {\n // Reset the original body before doing anything else.\n // Note: If successful status will be \"complete\", otherwise \"none\" will\n // restart the process.\n request.body = challengeState.originalBody;\n }\n\n const getTokenOptions = requestToOptions(request);\n\n const challenge = response.headers.get(\"WWW-Authenticate\");\n if (!challenge) {\n throw new Error(\"Missing challenge.\");\n }\n const parsedChallenge: ParsedWWWAuthenticate = parseWWWAuthenticate(challenge) || {};\n\n const scope = parsedChallenge.resource\n ? parsedChallenge.resource + \"/.default\"\n : parsedChallenge.scope;\n\n if (!scope) {\n throw new Error(\"Missing scope.\");\n }\n\n const accessToken = await options.getAccessToken([scope], {\n ...getTokenOptions,\n tenantId: parsedChallenge.tenantId,\n });\n\n if (!accessToken) {\n return false;\n }\n\n options.request.headers.set(\"Authorization\", `Bearer ${accessToken.token}`);\n\n challengeState = {\n status: \"complete\",\n scopes: [scope],\n };\n\n return true;\n }\n\n return {\n authorizeRequest,\n authorizeRequestOnChallenge,\n };\n}\n"]}
@@ -2,6 +2,5 @@
2
2
  // Licensed under the MIT license.
3
3
  export * from "./challengeBasedAuthenticationPolicy";
4
4
  export * from "./parseKeyvaultIdentifier";
5
- export * from "./tracingHelpers";
6
5
  export * from "./parseWWWAuthenticate";
7
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../keyvault-common/src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./challengeBasedAuthenticationPolicy\";\nexport * from \"./parseKeyvaultIdentifier\";\nexport * from \"./tracingHelpers\";\nexport * from \"./parseWWWAuthenticate\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../keyvault-common/src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./challengeBasedAuthenticationPolicy\";\nexport * from \"./parseKeyvaultIdentifier\";\nexport * from \"./parseWWWAuthenticate\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"parseKeyvaultIdentifier.js","sourceRoot":"","sources":["../../../../keyvault-common/src/parseKeyvaultIdentifier.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAgB3B,MAAM,UAAU,uBAAuB,CACrC,UAAkB,EAClB,UAA8B;IAE9B,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE;QACvE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE;QACvE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,IAAI,OAAO,CAAC;IACZ,IAAI;QACF,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;KAC7C;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,WAAW,UAAU,gBAAgB,UAAU,mBAAmB,CAAC,CAAC;KACrF;IAED,mDAAmD;IACnD,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAClD,MAAM,IAAI,KAAK,CACb,WAAW,UAAU,gBAAgB,UAAU,6BAA6B,QAAQ,CAAC,MAAM,EAAE,CAC9F,CAAC;KACH;IAED,IAAI,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE;QAC9B,MAAM,IAAI,KAAK,CACb,WAAW,UAAU,gBAAgB,UAAU,4BAA4B,UAAU,aAAa,QAAQ,CAAC,CAAC,CAAC,GAAG,CACjH,CAAC;KACH;IAED,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC;IACxD,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,OAAO;QACL,QAAQ;QACR,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as url from \"url\";\n\nexport interface ParsedKeyVaultEntityIdentifier {\n /**\n * The vault URI.\n */\n vaultUrl: string;\n /**\n * The version of key/secret/certificate. May be undefined.\n */\n version?: string;\n /**\n * The name of key/secret/certificate.\n */\n name: string;\n}\nexport function parseKeyvaultIdentifier(\n collection: string,\n identifier: string | undefined\n): ParsedKeyVaultEntityIdentifier {\n if (typeof collection !== \"string\" || !(collection = collection.trim())) {\n throw new Error(\"Invalid collection argument\");\n }\n\n if (typeof identifier !== \"string\" || !(identifier = identifier.trim())) {\n throw new Error(\"Invalid identifier argument\");\n }\n\n let baseUri;\n try {\n baseUri = url.parse(identifier, true, true);\n } catch (e) {\n throw new Error(`Invalid ${collection} identifier: ${identifier}. Not a valid URI`);\n }\n\n // Path is of the form '/collection/name[/version]'\n const segments = (baseUri.pathname || \"\").split(\"/\");\n if (segments.length !== 3 && segments.length !== 4) {\n throw new Error(\n `Invalid ${collection} identifier: ${identifier}. Bad number of segments: ${segments.length}`\n );\n }\n\n if (collection !== segments[1]) {\n throw new Error(\n `Invalid ${collection} identifier: ${identifier}. segment [1] should be \"${collection}\", found \"${segments[1]}\"`\n );\n }\n\n const vaultUrl = `${baseUri.protocol}//${baseUri.host}`;\n const name = segments[2];\n const version = segments.length === 4 ? segments[3] : undefined;\n return {\n vaultUrl,\n name,\n version,\n };\n}\n"]}
1
+ {"version":3,"file":"parseKeyvaultIdentifier.js","sourceRoot":"","sources":["../../../../keyvault-common/src/parseKeyvaultIdentifier.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAgB3B,MAAM,UAAU,uBAAuB,CACrC,UAAkB,EAClB,UAA8B;IAE9B,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE;QACvE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE;QACvE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,IAAI,OAAO,CAAC;IACZ,IAAI;QACF,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;KAC7C;IAAC,OAAO,CAAM,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,WAAW,UAAU,gBAAgB,UAAU,mBAAmB,CAAC,CAAC;KACrF;IAED,mDAAmD;IACnD,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAClD,MAAM,IAAI,KAAK,CACb,WAAW,UAAU,gBAAgB,UAAU,6BAA6B,QAAQ,CAAC,MAAM,EAAE,CAC9F,CAAC;KACH;IAED,IAAI,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE;QAC9B,MAAM,IAAI,KAAK,CACb,WAAW,UAAU,gBAAgB,UAAU,4BAA4B,UAAU,aAAa,QAAQ,CAAC,CAAC,CAAC,GAAG,CACjH,CAAC;KACH;IAED,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC;IACxD,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,OAAO;QACL,QAAQ;QACR,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as url from \"url\";\n\nexport interface ParsedKeyVaultEntityIdentifier {\n /**\n * The vault URI.\n */\n vaultUrl: string;\n /**\n * The version of key/secret/certificate. May be undefined.\n */\n version?: string;\n /**\n * The name of key/secret/certificate.\n */\n name: string;\n}\nexport function parseKeyvaultIdentifier(\n collection: string,\n identifier: string | undefined\n): ParsedKeyVaultEntityIdentifier {\n if (typeof collection !== \"string\" || !(collection = collection.trim())) {\n throw new Error(\"Invalid collection argument\");\n }\n\n if (typeof identifier !== \"string\" || !(identifier = identifier.trim())) {\n throw new Error(\"Invalid identifier argument\");\n }\n\n let baseUri;\n try {\n baseUri = url.parse(identifier, true, true);\n } catch (e: any) {\n throw new Error(`Invalid ${collection} identifier: ${identifier}. Not a valid URI`);\n }\n\n // Path is of the form '/collection/name[/version]'\n const segments = (baseUri.pathname || \"\").split(\"/\");\n if (segments.length !== 3 && segments.length !== 4) {\n throw new Error(\n `Invalid ${collection} identifier: ${identifier}. Bad number of segments: ${segments.length}`\n );\n }\n\n if (collection !== segments[1]) {\n throw new Error(\n `Invalid ${collection} identifier: ${identifier}. segment [1] should be \"${collection}\", found \"${segments[1]}\"`\n );\n }\n\n const vaultUrl = `${baseUri.protocol}//${baseUri.host}`;\n const name = segments[2];\n const version = segments.length === 4 ? segments[3] : undefined;\n return {\n vaultUrl,\n name,\n version,\n };\n}\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@azure/keyvault-admin",
3
3
  "sdk-type": "client",
4
4
  "author": "Microsoft Corporation",
5
- "version": "4.2.1-alpha.20220330.1",
5
+ "version": "4.2.1",
6
6
  "license": "MIT",
7
7
  "description": "Isomorphic client library for Azure KeyVault's administrative functions.",
8
8
  "homepage": "https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/keyvault-admin/README.md",
@@ -74,7 +74,7 @@
74
74
  "constantPaths": [
75
75
  {
76
76
  "path": "src/generated/keyVaultClientContext.ts",
77
- "prefix": "packageVersion"
77
+ "prefix": "packageDetails"
78
78
  },
79
79
  {
80
80
  "path": "src/constants.ts",
@@ -109,7 +109,7 @@
109
109
  "@azure/core-lro": "^2.2.0",
110
110
  "@azure/core-paging": "^1.1.1",
111
111
  "@azure/core-rest-pipeline": "^1.1.0",
112
- "@azure/core-tracing": "1.0.0-preview.13",
112
+ "@azure/core-tracing": "^1.0.0",
113
113
  "@azure/logger": "^1.0.0",
114
114
  "@types/uuid": "^8.0.0",
115
115
  "tslib": "^2.2.0",
@@ -117,20 +117,20 @@
117
117
  },
118
118
  "devDependencies": {
119
119
  "@azure/abort-controller": "^1.0.0",
120
- "@azure/core-util": "^1.0.0-beta.1",
121
- "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
122
- "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
120
+ "@azure/core-util": "^1.0.0",
121
+ "@azure/dev-tool": "^1.0.0",
122
+ "@azure/eslint-plugin-azure-sdk": "^3.0.0",
123
123
  "@azure/identity": "^2.0.1",
124
124
  "@azure/keyvault-keys": "^4.2.1",
125
- "@azure/test-utils": ">=1.0.0-alpha <1.0.0-alphb",
125
+ "@azure/test-utils": "^1.0.0",
126
126
  "@azure-tools/test-recorder": "^1.0.0",
127
- "@microsoft/api-extractor": "^7.18.11",
127
+ "@microsoft/api-extractor": "7.18.11",
128
128
  "@types/mocha": "^7.0.2",
129
129
  "@types/node": "^12.0.0",
130
130
  "@types/sinon": "^9.0.4",
131
131
  "cross-env": "^7.0.2",
132
132
  "dotenv": "^8.2.0",
133
- "eslint": "^7.15.0",
133
+ "eslint": "^8.0.0",
134
134
  "esm": "^3.2.18",
135
135
  "mocha": "^7.1.1",
136
136
  "mocha-junit-reporter": "^2.0.0",
@@ -139,6 +139,6 @@
139
139
  "rimraf": "^3.0.0",
140
140
  "sinon": "^9.0.2",
141
141
  "source-map-support": "^0.5.9",
142
- "typescript": "~4.2.0"
142
+ "typescript": "~4.6.0"
143
143
  }
144
144
  }
package/CHANGELOG.md DELETED
@@ -1,116 +0,0 @@
1
- # Release History
2
-
3
- ## 4.2.1 (Unreleased)
4
-
5
- ### Features Added
6
-
7
- ### Breaking Changes
8
-
9
- ### Bugs Fixed
10
-
11
- ### Other Changes
12
-
13
- ## 4.2.0 (2022-03-24)
14
-
15
- ### Other Changes
16
-
17
- - This release updates `BackupClient` and `AccessControlClient` to support service version 7.3 by default.
18
-
19
- ## 4.2.0-beta.2 (2021-11-09)
20
-
21
- ### Features Added
22
-
23
- - Support multi-tenant authentication against Key Vault and Managed HSM when using @azure/identity 2.0.0 or newer.
24
-
25
- ### Other Changes
26
-
27
- - Updated the latest service version to 7.3.
28
-
29
- ## 4.2.0-beta.1 (2021-08-10)
30
-
31
- - Move generated client to use @azure/core-rest-pipeline. For more information about Core V2, please refer to [the documentation](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core#core-v1-and-core-v2).
32
-
33
- - With this change, the response types no longer contain the raw response `_response`. To access the raw response, an `onResponse` callback has to be passed in the request options bag.
34
-
35
- ```typescript
36
- let rawResponse: FullOperationResponse | undefined;
37
- await client.getRoleDefinition(globalScope, "roleDefinitionName", {
38
- onResponse: (response) => (rawResponse = response),
39
- });
40
- ```
41
-
42
- ## 4.1.0 (2021-07-29)
43
-
44
- ### New Features
45
-
46
- - Support for Node.js 8 and IE 11 has been dropped. Please see our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
47
- - Changed TS compilation target to ES2017 to produce smaller bundles and use more native platform features.
48
- - Updated our internal core package dependencies to their latest versions to add support for Opentelemetry 1.0.0, which is compatible with the latest versions of our other client libraries.
49
-
50
- ## 4.1.0-beta.1 (2021-07-07)
51
-
52
- ### Features Added
53
-
54
- - With the dropping of support for Node.js versions that are no longer in LTS, the dependency on `@types/node` has been updated to version 12. Read our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
55
-
56
- ## 4.0.1 (2021-06-15)
57
-
58
- ### Bug Fixes
59
-
60
- - Fixed an issue where bundling could fail when importing this library due to an incorrectly set import.
61
-
62
- ## 4.0.0 (2021-06-15)
63
-
64
- This release marks the general availability of the `@azure/keyvault-admin` package.
65
-
66
- ### New Features
67
-
68
- - The `KeyVaultAccessControlClient` provides support for managing role-based access control (RBAC) operations.
69
- - Both role assignments and custom role definitions are supported with the ability to create, read, update, and delete custom role definitions and assignments.
70
- - The `KeyVaultBackupClient` provides support for back up and restore operations for the entire Key Vault Managed HSM instance.
71
- - Full Managed HSM backup and restore operations are supported.
72
- - Selective Key Restore from a previous backup is also supported.
73
-
74
- ### Changes since 4.0.0-beta.3:
75
-
76
- - Added the "KeyVault" prefix to all of the Key Vault Admin client operations.
77
- - Made the AesGcmDecryptParameters authenticationTag required.
78
- - Collapsed `KeyVaultRoleAssignmentPropertiesWithScope` to `KeyVaultRoleAssignmentProperties`.
79
- - Renamed `KeyVaultKeyId` to `KeyVaultKeyIdentifier`.
80
- - Renamed `beginRestore`'s `blobStorageUri` to `folderUri`.
81
- - Removed `folderName` from `beginRestore`. Now the folder name will be inferred from the `folderUri`.
82
- - Renamed `beginSelectiveRestore`'s `blobStorageUri` to `folderUri`.
83
- - Removed `folderName` from `beginSelectiveRestore`. Now the folder name will be inferred from the `folderUri`.
84
- - Reordered the parameters of `beginSelectiveRestore` to `keyName`, `folderUrl`, `sasToken`, `[options]`.
85
- - Renamed `KeyVaultBackupResult`'s `backupFolderUri` to `folderUri`.
86
- - Renamed `beginSelectiveRestore` to `beginSelectiveKeyRestore`.
87
- - Renamed `KeyVaultBeginSelectiveRestoreOptions` to `KeyVaultBeginSelectiveKeyRestoreOptions`.
88
- - Renamed `KeyVaultSelectiveRestoreOperationState` to `KeyVaultSelectiveKeyRestoreOperationState`.
89
- - Renamed `KeyVaultSelectiveRestoreResult` to `KeyVaultSelectiveKeyRestoreResult`.
90
- - `deleteRoleAssignment` and `deleteRoleDefinition` will no longer throw an exception when the resource no longer exist and return no result.
91
-
92
- ## 4.0.0-beta.3 (2021-04-06)
93
-
94
- - Updated the Latest service version to 7.2.
95
- - Long Running Operations will now use the `status` field to determine whether the operation failed.
96
- - Improved tracing across the various KeyVault libraries. By switching to a consistent naming convention, ensuring spans are always closed appropriately, and setting the correct status when an operation errors developers can expect an improved experience when enabling distributed tracing.
97
- - We now ensure tracing spans are properly closed with an appropriate status when an operation throws an exception.
98
- - If a traced operation throws an exception we will now properly record the exception message in the tracing span.
99
- - Finally, naming conventions have been standardized across the KeyVault libraries taking the format of `Azure.KeyVault.<PACKAGE NAME>.<CLIENT NAME>`.
100
- - Fixed an issue where retrying a failed initial Key Vault request may result in an empty body.
101
-
102
- ## 4.0.0-beta.2 (2021-02-09)
103
-
104
- - [Breaking] Removed `dist-browser` from the published package. To bundle the Azure SDK libraries for the browsers, please read our bundling guide: [link](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/Bundling.md).
105
- - Updated the Key Vault Admin Long Running Operation Pollers to follow a more compact and meaningful approach moving forward.
106
- - Bug fix: The logging of HTTP requests wasn't properly working - now it has been fixed and tests have been written that verify the fix.
107
- - [Breaking] Return `BackupResult` and `RestoreResult` from backup/restore long running operations which will contain additional information about the operation as well any relevant data.
108
- - Backup / Restore polling will now correctly propagate any errors to the awaited call.
109
- - Add support for custom role definitions - creating, updating, and deleting role definitions are now supported.
110
-
111
- ## 4.0.0-beta.1 (2020-09-11)
112
-
113
- The @azure/keyvault-admin package provides two clients, `KeyVaultAccessControlClient` and `KeyVaultBackupClient`.
114
-
115
- - The `KeyVaultAccessControlClient` allows working with role-based access control (RBAC) operations, meaning assigning, deleting and retrieving role assignments, and retrieving role definitions.
116
- - The `KeyVaultBackupClient` allows generating full backups and restores of Key Vault instances, and selective restores of keys.
@@ -1,81 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { parseWWWAuthenticate } from "../../keyvault-common/src";
4
- /**
5
- * @internal
6
- *
7
- * Creates challenge callback handlers to manage CAE lifecycle in Azure Key Vault.
8
- *
9
- * Key Vault supports other authentication schemes, but we ensure challenge authentication
10
- * is used by first sending a copy of the request, without authorization or content.
11
- *
12
- * when the challenge is received, it will be authenticated and used to send the original
13
- * request with authorization.
14
- *
15
- * Following the first request of a client, follow-up requests will get the cached token
16
- * if possible.
17
- */
18
- export function createChallengeCallbacks() {
19
- let challengeState = { status: "none" };
20
- function requestToOptions(request) {
21
- return {
22
- abortSignal: request.abortSignal,
23
- requestOptions: {
24
- timeout: request.timeout,
25
- },
26
- tracingOptions: request.tracingOptions,
27
- };
28
- }
29
- async function authorizeRequest(options) {
30
- const { scopes, request } = options;
31
- const requestOptions = requestToOptions(request);
32
- switch (challengeState.status) {
33
- case "none":
34
- challengeState = {
35
- status: "started",
36
- originalBody: request.body,
37
- };
38
- request.body = null;
39
- break;
40
- case "started":
41
- break; // Retry, we should not overwrite the original body
42
- case "complete": {
43
- const token = await options.getAccessToken(scopes, requestOptions);
44
- if (token) {
45
- request.headers.set("authorization", `Bearer ${token.token}`);
46
- }
47
- break;
48
- }
49
- }
50
- return Promise.resolve();
51
- }
52
- async function authorizeRequestOnChallenge(options) {
53
- const { scopes, request, response } = options;
54
- if (request.body === null && challengeState.status === "started") {
55
- // Reset the original body before doing anything else.
56
- // Note: If successful status will be "complete", otherwise "none" will
57
- // restart the process.
58
- request.body = challengeState.originalBody;
59
- }
60
- const getTokenOptions = requestToOptions(request);
61
- const challenge = response.headers.get("WWW-Authenticate");
62
- if (!challenge) {
63
- throw new Error("Missing challenge.");
64
- }
65
- const parsedChallenge = parseWWWAuthenticate(challenge) || [];
66
- const accessToken = await options.getAccessToken(parsedChallenge.scope ? [parsedChallenge.scope] : scopes, Object.assign(Object.assign({}, getTokenOptions), { tenantId: parsedChallenge.tenantId }));
67
- if (!accessToken) {
68
- return false;
69
- }
70
- options.request.headers.set("Authorization", `Bearer ${accessToken.token}`);
71
- challengeState = {
72
- status: "complete",
73
- };
74
- return true;
75
- }
76
- return {
77
- authorizeRequest,
78
- authorizeRequestOnChallenge,
79
- };
80
- }
81
- //# sourceMappingURL=challengeAuthenticationCallbacks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"challengeAuthenticationCallbacks.js","sourceRoot":"","sources":["../../../src/challengeAuthenticationCallbacks.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EAAyB,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AA4BxF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,wBAAwB;IACtC,IAAI,cAAc,GAAmB,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAExD,SAAS,gBAAgB,CAAC,OAAwB;QAChD,OAAO;YACL,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,cAAc,EAAE;gBACd,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB;YACD,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,C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I,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACvC;QACD,MAAM,eAAe,GAA0B,oBAAoB,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAErF,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,CAC9C,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,kCACnD,eAAe,KAAE,QAAQ,EAAE,eAAe,CAAC,QAAQ,IACzD,CAAC;QAEF,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;QAE5E,cAAc,GAAG;YACf,MAAM,EAAE,UAAU;SACnB,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,gBAAgB;QAChB,2BAA2B;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AuthorizeRequestOnChallengeOptions,\n AuthorizeRequestOptions,\n ChallengeCallbacks,\n PipelineRequest,\n RequestBodyType,\n} from \"@azure/core-rest-pipeline\";\nimport { ParsedWWWAuthenticate, parseWWWAuthenticate } from \"../../keyvault-common/src\";\n\nimport { GetTokenOptions } from \"@azure/core-auth\";\n\n/**\n * @internal\n * Holds the state of Challenge Auth.\n * When making the first request we force Key Vault to begin a challenge\n * by clearing out the request body and storing it locally.\n *\n * Later on, the authorizeRequestOnChallenge callback will process the\n * challenge and, if ready to resend the original request, reset the body\n * so that it may be sent again.\n *\n * Once a client has succeeded once, we can start skipping CAE.\n */\ntype ChallengeState =\n | {\n status: \"none\";\n }\n | {\n status: \"started\";\n originalBody?: RequestBodyType;\n }\n | {\n status: \"complete\";\n };\n\n/**\n * @internal\n *\n * Creates challenge callback handlers to manage CAE lifecycle in Azure Key Vault.\n *\n * Key Vault supports other authentication schemes, but we ensure challenge authentication\n * is used by first sending a copy of the request, without authorization or content.\n *\n * when the challenge is received, it will be authenticated and used to send the original\n * request with authorization.\n *\n * Following the first request of a client, follow-up requests will get the cached token\n * if possible.\n */\nexport function createChallengeCallbacks(): ChallengeCallbacks {\n let challengeState: ChallengeState = { status: \"none\" };\n\n function requestToOptions(request: PipelineRequest): GetTokenOptions {\n return {\n abortSignal: request.abortSignal,\n requestOptions: {\n timeout: request.timeout,\n },\n tracingOptions: request.tracingOptions,\n };\n }\n\n async function authorizeRequest(options: AuthorizeRequestOptions) {\n const { scopes, request } = options;\n const requestOptions: GetTokenOptions = requestToOptions(request);\n\n switch (challengeState.status) {\n case \"none\":\n challengeState = {\n status: \"started\",\n originalBody: request.body,\n };\n request.body = null;\n break;\n case \"started\":\n break; // Retry, we should not overwrite the original body\n case \"complete\": {\n const token = await options.getAccessToken(scopes, requestOptions);\n if (token) {\n request.headers.set(\"authorization\", `Bearer ${token.token}`);\n }\n break;\n }\n }\n return Promise.resolve();\n }\n\n async function authorizeRequestOnChallenge(\n options: AuthorizeRequestOnChallengeOptions\n ): Promise<boolean> {\n const { scopes, request, response } = options;\n\n if (request.body === null && challengeState.status === \"started\") {\n // Reset the original body before doing anything else.\n // Note: If successful status will be \"complete\", otherwise \"none\" will\n // restart the process.\n request.body = challengeState.originalBody;\n }\n\n const getTokenOptions = requestToOptions(request);\n\n const challenge = response.headers.get(\"WWW-Authenticate\");\n if (!challenge) {\n throw new Error(\"Missing challenge.\");\n }\n const parsedChallenge: ParsedWWWAuthenticate = parseWWWAuthenticate(challenge) || [];\n\n const accessToken = await options.getAccessToken(\n parsedChallenge.scope ? [parsedChallenge.scope] : scopes,\n { ...getTokenOptions, tenantId: parsedChallenge.tenantId }\n );\n\n if (!accessToken) {\n return false;\n }\n\n options.request.headers.set(\"Authorization\", `Bearer ${accessToken.token}`);\n\n challengeState = {\n status: \"complete\",\n };\n\n return true;\n }\n\n return {\n authorizeRequest,\n authorizeRequestOnChallenge,\n };\n}\n"]}