@typespec/ts-http-runtime 0.1.0-alpha.20250325.2 → 0.2.0-alpha.20250326.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.
- package/dist/browser/auth/credentials.d.ts +77 -0
- package/dist/browser/auth/credentials.js +27 -0
- package/dist/browser/auth/credentials.js.map +1 -0
- package/dist/browser/auth/oauth2Flows.d.ts +57 -0
- package/dist/browser/{abort-controller/AbortSignalLike.js → auth/oauth2Flows.js} +1 -1
- package/dist/browser/auth/oauth2Flows.js.map +1 -0
- package/dist/browser/auth/schemes.d.ts +53 -0
- package/dist/{esm/abort-controller/AbortSignalLike.js → browser/auth/schemes.js} +1 -1
- package/dist/browser/auth/schemes.js.map +1 -0
- package/dist/browser/client/clientHelpers.d.ts +1 -20
- package/dist/browser/client/clientHelpers.js +21 -30
- package/dist/browser/client/clientHelpers.js.map +1 -1
- package/dist/browser/client/common.d.ts +13 -15
- package/dist/browser/client/common.js.map +1 -1
- package/dist/browser/client/getClient.d.ts +1 -9
- package/dist/browser/client/getClient.js +8 -16
- package/dist/browser/client/getClient.js.map +1 -1
- package/dist/browser/constants.js +1 -1
- package/dist/browser/constants.js.map +1 -1
- package/dist/browser/index.d.ts +3 -3
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/interfaces.d.ts +10 -2
- package/dist/browser/interfaces.js.map +1 -1
- package/dist/browser/pipelineRequest.d.ts +1 -2
- package/dist/browser/pipelineRequest.js.map +1 -1
- package/dist/browser/policies/auth/apiKeyAuthenticationPolicy.d.ts +30 -0
- package/dist/browser/policies/auth/apiKeyAuthenticationPolicy.js +31 -0
- package/dist/browser/policies/auth/apiKeyAuthenticationPolicy.js.map +1 -0
- package/dist/browser/policies/auth/basicAuthenticationPolicy.d.ts +30 -0
- package/dist/browser/policies/auth/basicAuthenticationPolicy.js +31 -0
- package/dist/browser/policies/auth/basicAuthenticationPolicy.js.map +1 -0
- package/dist/browser/policies/auth/bearerAuthenticationPolicy.d.ts +30 -0
- package/dist/browser/policies/auth/bearerAuthenticationPolicy.js +31 -0
- package/dist/browser/policies/auth/bearerAuthenticationPolicy.js.map +1 -0
- package/dist/browser/policies/auth/checkInsecureConnection.d.ts +9 -0
- package/dist/browser/policies/auth/checkInsecureConnection.js +50 -0
- package/dist/browser/policies/auth/checkInsecureConnection.js.map +1 -0
- package/dist/browser/policies/auth/oauth2AuthenticationPolicy.d.ts +31 -0
- package/dist/browser/policies/auth/oauth2AuthenticationPolicy.js +31 -0
- package/dist/browser/policies/auth/oauth2AuthenticationPolicy.js.map +1 -0
- package/dist/browser/util/aborterUtils.d.ts +3 -4
- package/dist/browser/util/aborterUtils.js.map +1 -1
- package/dist/browser/util/helpers.d.ts +1 -2
- package/dist/browser/util/helpers.js.map +1 -1
- package/dist/commonjs/auth/credentials.d.ts +77 -0
- package/dist/commonjs/auth/credentials.js +33 -0
- package/dist/commonjs/auth/credentials.js.map +1 -0
- package/dist/commonjs/auth/oauth2Flows.d.ts +57 -0
- package/dist/commonjs/{abort-controller/AbortSignalLike.js → auth/oauth2Flows.js} +1 -1
- package/dist/commonjs/auth/oauth2Flows.js.map +1 -0
- package/dist/commonjs/auth/schemes.d.ts +53 -0
- package/dist/commonjs/auth/schemes.js +5 -0
- package/dist/commonjs/auth/schemes.js.map +1 -0
- package/dist/commonjs/client/clientHelpers.d.ts +1 -20
- package/dist/commonjs/client/clientHelpers.js +21 -31
- package/dist/commonjs/client/clientHelpers.js.map +1 -1
- package/dist/commonjs/client/common.d.ts +13 -15
- package/dist/commonjs/client/common.js.map +1 -1
- package/dist/commonjs/client/getClient.d.ts +1 -9
- package/dist/commonjs/client/getClient.js +8 -16
- package/dist/commonjs/client/getClient.js.map +1 -1
- package/dist/commonjs/constants.js +1 -1
- package/dist/commonjs/constants.js.map +1 -1
- package/dist/commonjs/index.d.ts +3 -3
- package/dist/commonjs/index.js +4 -5
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/interfaces.d.ts +10 -2
- package/dist/commonjs/interfaces.js.map +1 -1
- package/dist/commonjs/pipelineRequest.d.ts +1 -2
- package/dist/commonjs/pipelineRequest.js.map +1 -1
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.d.ts +30 -0
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js +35 -0
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js.map +1 -0
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.d.ts +30 -0
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js +35 -0
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js.map +1 -0
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.d.ts +30 -0
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js +35 -0
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js.map +1 -0
- package/dist/commonjs/policies/auth/checkInsecureConnection.d.ts +9 -0
- package/dist/commonjs/policies/auth/checkInsecureConnection.js +53 -0
- package/dist/commonjs/policies/auth/checkInsecureConnection.js.map +1 -0
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.d.ts +31 -0
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js +35 -0
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js.map +1 -0
- package/dist/commonjs/util/aborterUtils.d.ts +3 -4
- package/dist/commonjs/util/aborterUtils.js.map +1 -1
- package/dist/commonjs/util/helpers.d.ts +1 -2
- package/dist/commonjs/util/helpers.js.map +1 -1
- package/dist/esm/auth/credentials.d.ts +77 -0
- package/dist/esm/auth/credentials.js +27 -0
- package/dist/esm/auth/credentials.js.map +1 -0
- package/dist/esm/auth/oauth2Flows.d.ts +57 -0
- package/dist/{react-native/abort-controller/AbortSignalLike.js → esm/auth/oauth2Flows.js} +1 -1
- package/dist/esm/auth/oauth2Flows.js.map +1 -0
- package/dist/esm/auth/schemes.d.ts +53 -0
- package/dist/esm/auth/schemes.js +4 -0
- package/dist/esm/auth/schemes.js.map +1 -0
- package/dist/esm/client/clientHelpers.d.ts +1 -20
- package/dist/esm/client/clientHelpers.js +21 -30
- package/dist/esm/client/clientHelpers.js.map +1 -1
- package/dist/esm/client/common.d.ts +13 -15
- package/dist/esm/client/common.js.map +1 -1
- package/dist/esm/client/getClient.d.ts +1 -9
- package/dist/esm/client/getClient.js +8 -16
- package/dist/esm/client/getClient.js.map +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces.d.ts +10 -2
- package/dist/esm/interfaces.js.map +1 -1
- package/dist/esm/pipelineRequest.d.ts +1 -2
- package/dist/esm/pipelineRequest.js.map +1 -1
- package/dist/esm/policies/auth/apiKeyAuthenticationPolicy.d.ts +30 -0
- package/dist/esm/policies/auth/apiKeyAuthenticationPolicy.js +31 -0
- package/dist/esm/policies/auth/apiKeyAuthenticationPolicy.js.map +1 -0
- package/dist/esm/policies/auth/basicAuthenticationPolicy.d.ts +30 -0
- package/dist/esm/policies/auth/basicAuthenticationPolicy.js +31 -0
- package/dist/esm/policies/auth/basicAuthenticationPolicy.js.map +1 -0
- package/dist/esm/policies/auth/bearerAuthenticationPolicy.d.ts +30 -0
- package/dist/esm/policies/auth/bearerAuthenticationPolicy.js +31 -0
- package/dist/esm/policies/auth/bearerAuthenticationPolicy.js.map +1 -0
- package/dist/esm/policies/auth/checkInsecureConnection.d.ts +9 -0
- package/dist/esm/policies/auth/checkInsecureConnection.js +50 -0
- package/dist/esm/policies/auth/checkInsecureConnection.js.map +1 -0
- package/dist/esm/policies/auth/oauth2AuthenticationPolicy.d.ts +31 -0
- package/dist/esm/policies/auth/oauth2AuthenticationPolicy.js +31 -0
- package/dist/esm/policies/auth/oauth2AuthenticationPolicy.js.map +1 -0
- package/dist/esm/util/aborterUtils.d.ts +3 -4
- package/dist/esm/util/aborterUtils.js.map +1 -1
- package/dist/esm/util/helpers.d.ts +1 -2
- package/dist/esm/util/helpers.js.map +1 -1
- package/dist/react-native/auth/credentials.d.ts +77 -0
- package/dist/react-native/auth/credentials.js +27 -0
- package/dist/react-native/auth/credentials.js.map +1 -0
- package/dist/react-native/auth/oauth2Flows.d.ts +57 -0
- package/dist/react-native/auth/oauth2Flows.js +4 -0
- package/dist/react-native/auth/oauth2Flows.js.map +1 -0
- package/dist/react-native/auth/schemes.d.ts +53 -0
- package/dist/react-native/auth/schemes.js +4 -0
- package/dist/react-native/auth/schemes.js.map +1 -0
- package/dist/react-native/client/clientHelpers.d.ts +1 -20
- package/dist/react-native/client/clientHelpers.js +21 -30
- package/dist/react-native/client/clientHelpers.js.map +1 -1
- package/dist/react-native/client/common.d.ts +13 -15
- package/dist/react-native/client/common.js.map +1 -1
- package/dist/react-native/client/getClient.d.ts +1 -9
- package/dist/react-native/client/getClient.js +8 -16
- package/dist/react-native/client/getClient.js.map +1 -1
- package/dist/react-native/constants.js +1 -1
- package/dist/react-native/constants.js.map +1 -1
- package/dist/react-native/index.d.ts +3 -3
- package/dist/react-native/index.js +2 -2
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/interfaces.d.ts +10 -2
- package/dist/react-native/interfaces.js.map +1 -1
- package/dist/react-native/pipelineRequest.d.ts +1 -2
- package/dist/react-native/pipelineRequest.js.map +1 -1
- package/dist/react-native/policies/auth/apiKeyAuthenticationPolicy.d.ts +30 -0
- package/dist/react-native/policies/auth/apiKeyAuthenticationPolicy.js +31 -0
- package/dist/react-native/policies/auth/apiKeyAuthenticationPolicy.js.map +1 -0
- package/dist/react-native/policies/auth/basicAuthenticationPolicy.d.ts +30 -0
- package/dist/react-native/policies/auth/basicAuthenticationPolicy.js +31 -0
- package/dist/react-native/policies/auth/basicAuthenticationPolicy.js.map +1 -0
- package/dist/react-native/policies/auth/bearerAuthenticationPolicy.d.ts +30 -0
- package/dist/react-native/policies/auth/bearerAuthenticationPolicy.js +31 -0
- package/dist/react-native/policies/auth/bearerAuthenticationPolicy.js.map +1 -0
- package/dist/react-native/policies/auth/checkInsecureConnection.d.ts +9 -0
- package/dist/react-native/policies/auth/checkInsecureConnection.js +50 -0
- package/dist/react-native/policies/auth/checkInsecureConnection.js.map +1 -0
- package/dist/react-native/policies/auth/oauth2AuthenticationPolicy.d.ts +31 -0
- package/dist/react-native/policies/auth/oauth2AuthenticationPolicy.js +31 -0
- package/dist/react-native/policies/auth/oauth2AuthenticationPolicy.js.map +1 -0
- package/dist/react-native/util/aborterUtils.d.ts +3 -4
- package/dist/react-native/util/aborterUtils.js.map +1 -1
- package/dist/react-native/util/helpers.d.ts +1 -2
- package/dist/react-native/util/helpers.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser/abort-controller/AbortSignalLike.d.ts +0 -19
- package/dist/browser/abort-controller/AbortSignalLike.js.map +0 -1
- package/dist/browser/accessTokenCache.d.ts +0 -40
- package/dist/browser/accessTokenCache.js +0 -32
- package/dist/browser/accessTokenCache.js.map +0 -1
- package/dist/browser/auth/keyCredential.d.ts +0 -16
- package/dist/browser/auth/keyCredential.js +0 -12
- package/dist/browser/auth/keyCredential.js.map +0 -1
- package/dist/browser/auth/tokenCredential.d.ts +0 -71
- package/dist/browser/auth/tokenCredential.js +0 -19
- package/dist/browser/auth/tokenCredential.js.map +0 -1
- package/dist/browser/client/keyCredentialAuthenticationPolicy.d.ts +0 -8
- package/dist/browser/client/keyCredentialAuthenticationPolicy.js +0 -16
- package/dist/browser/client/keyCredentialAuthenticationPolicy.js.map +0 -1
- package/dist/browser/policies/bearerTokenAuthenticationPolicy.d.ts +0 -99
- package/dist/browser/policies/bearerTokenAuthenticationPolicy.js +0 -107
- package/dist/browser/policies/bearerTokenAuthenticationPolicy.js.map +0 -1
- package/dist/browser/util/tokenCycler.d.ts +0 -45
- package/dist/browser/util/tokenCycler.js +0 -162
- package/dist/browser/util/tokenCycler.js.map +0 -1
- package/dist/commonjs/abort-controller/AbortSignalLike.d.ts +0 -19
- package/dist/commonjs/abort-controller/AbortSignalLike.js.map +0 -1
- package/dist/commonjs/accessTokenCache.d.ts +0 -40
- package/dist/commonjs/accessTokenCache.js +0 -36
- package/dist/commonjs/accessTokenCache.js.map +0 -1
- package/dist/commonjs/auth/keyCredential.d.ts +0 -16
- package/dist/commonjs/auth/keyCredential.js +0 -15
- package/dist/commonjs/auth/keyCredential.js.map +0 -1
- package/dist/commonjs/auth/tokenCredential.d.ts +0 -71
- package/dist/commonjs/auth/tokenCredential.js +0 -22
- package/dist/commonjs/auth/tokenCredential.js.map +0 -1
- package/dist/commonjs/client/keyCredentialAuthenticationPolicy.d.ts +0 -8
- package/dist/commonjs/client/keyCredentialAuthenticationPolicy.js +0 -20
- package/dist/commonjs/client/keyCredentialAuthenticationPolicy.js.map +0 -1
- package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.d.ts +0 -99
- package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js +0 -111
- package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js.map +0 -1
- package/dist/commonjs/util/tokenCycler.d.ts +0 -45
- package/dist/commonjs/util/tokenCycler.js +0 -166
- package/dist/commonjs/util/tokenCycler.js.map +0 -1
- package/dist/esm/abort-controller/AbortSignalLike.d.ts +0 -19
- package/dist/esm/abort-controller/AbortSignalLike.js.map +0 -1
- package/dist/esm/accessTokenCache.d.ts +0 -40
- package/dist/esm/accessTokenCache.js +0 -32
- package/dist/esm/accessTokenCache.js.map +0 -1
- package/dist/esm/auth/keyCredential.d.ts +0 -16
- package/dist/esm/auth/keyCredential.js +0 -12
- package/dist/esm/auth/keyCredential.js.map +0 -1
- package/dist/esm/auth/tokenCredential.d.ts +0 -71
- package/dist/esm/auth/tokenCredential.js +0 -19
- package/dist/esm/auth/tokenCredential.js.map +0 -1
- package/dist/esm/client/keyCredentialAuthenticationPolicy.d.ts +0 -8
- package/dist/esm/client/keyCredentialAuthenticationPolicy.js +0 -16
- package/dist/esm/client/keyCredentialAuthenticationPolicy.js.map +0 -1
- package/dist/esm/policies/bearerTokenAuthenticationPolicy.d.ts +0 -99
- package/dist/esm/policies/bearerTokenAuthenticationPolicy.js +0 -107
- package/dist/esm/policies/bearerTokenAuthenticationPolicy.js.map +0 -1
- package/dist/esm/util/tokenCycler.d.ts +0 -45
- package/dist/esm/util/tokenCycler.js +0 -162
- package/dist/esm/util/tokenCycler.js.map +0 -1
- package/dist/react-native/abort-controller/AbortSignalLike.d.ts +0 -19
- package/dist/react-native/abort-controller/AbortSignalLike.js.map +0 -1
- package/dist/react-native/accessTokenCache.d.ts +0 -40
- package/dist/react-native/accessTokenCache.js +0 -32
- package/dist/react-native/accessTokenCache.js.map +0 -1
- package/dist/react-native/auth/keyCredential.d.ts +0 -16
- package/dist/react-native/auth/keyCredential.js +0 -12
- package/dist/react-native/auth/keyCredential.js.map +0 -1
- package/dist/react-native/auth/tokenCredential.d.ts +0 -71
- package/dist/react-native/auth/tokenCredential.js +0 -19
- package/dist/react-native/auth/tokenCredential.js.map +0 -1
- package/dist/react-native/client/keyCredentialAuthenticationPolicy.d.ts +0 -8
- package/dist/react-native/client/keyCredentialAuthenticationPolicy.js +0 -16
- package/dist/react-native/client/keyCredentialAuthenticationPolicy.js.map +0 -1
- package/dist/react-native/policies/bearerTokenAuthenticationPolicy.d.ts +0 -99
- package/dist/react-native/policies/bearerTokenAuthenticationPolicy.js +0 -107
- package/dist/react-native/policies/bearerTokenAuthenticationPolicy.js.map +0 -1
- package/dist/react-native/util/tokenCycler.d.ts +0 -45
- package/dist/react-native/util/tokenCycler.js +0 -162
- package/dist/react-native/util/tokenCycler.js.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { OAuth2Flow } from "../../auth/oauth2Flows.js";
|
|
2
|
+
import type { OAuth2TokenCredential } from "../../auth/credentials.js";
|
|
3
|
+
import type { AuthScheme } from "../../auth/schemes.js";
|
|
4
|
+
import type { PipelinePolicy } from "../../pipeline.js";
|
|
5
|
+
/**
|
|
6
|
+
* Name of the OAuth2 Authentication Policy
|
|
7
|
+
*/
|
|
8
|
+
export declare const oauth2AuthenticationPolicyName = "oauth2AuthenticationPolicy";
|
|
9
|
+
/**
|
|
10
|
+
* Options for configuring the OAuth2 authentication policy
|
|
11
|
+
*/
|
|
12
|
+
export interface OAuth2AuthenticationPolicyOptions<TFlows extends OAuth2Flow> {
|
|
13
|
+
/**
|
|
14
|
+
* The OAuth2TokenCredential implementation that can supply the bearer token.
|
|
15
|
+
*/
|
|
16
|
+
credential: OAuth2TokenCredential<TFlows>;
|
|
17
|
+
/**
|
|
18
|
+
* Optional authentication schemes to use. If not provided, schemes from the request will be used.
|
|
19
|
+
*/
|
|
20
|
+
authSchemes?: AuthScheme[];
|
|
21
|
+
/**
|
|
22
|
+
* Allows for connecting to HTTP endpoints instead of enforcing HTTPS.
|
|
23
|
+
* CAUTION: Never use this option in production.
|
|
24
|
+
*/
|
|
25
|
+
allowInsecureConnection?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets a pipeline policy that adds authorization header from OAuth2 schemes
|
|
29
|
+
*/
|
|
30
|
+
export declare function oauth2AuthenticationPolicy<TFlows extends OAuth2Flow>(options: OAuth2AuthenticationPolicyOptions<TFlows>): PipelinePolicy;
|
|
31
|
+
//# sourceMappingURL=oauth2AuthenticationPolicy.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.oauth2AuthenticationPolicyName = void 0;
|
|
6
|
+
exports.oauth2AuthenticationPolicy = oauth2AuthenticationPolicy;
|
|
7
|
+
const checkInsecureConnection_js_1 = require("./checkInsecureConnection.js");
|
|
8
|
+
/**
|
|
9
|
+
* Name of the OAuth2 Authentication Policy
|
|
10
|
+
*/
|
|
11
|
+
exports.oauth2AuthenticationPolicyName = "oauth2AuthenticationPolicy";
|
|
12
|
+
/**
|
|
13
|
+
* Gets a pipeline policy that adds authorization header from OAuth2 schemes
|
|
14
|
+
*/
|
|
15
|
+
function oauth2AuthenticationPolicy(options) {
|
|
16
|
+
return {
|
|
17
|
+
name: exports.oauth2AuthenticationPolicyName,
|
|
18
|
+
async sendRequest(request, next) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
// Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs
|
|
21
|
+
(0, checkInsecureConnection_js_1.ensureSecureConnection)(request, options);
|
|
22
|
+
const scheme = (_b = ((_a = request.authSchemes) !== null && _a !== void 0 ? _a : options.authSchemes)) === null || _b === void 0 ? void 0 : _b.find((x) => x.kind === "oauth2");
|
|
23
|
+
// Skip adding authentication header if no OAuth2 authentication scheme is found
|
|
24
|
+
if (!scheme) {
|
|
25
|
+
return next(request);
|
|
26
|
+
}
|
|
27
|
+
const token = await options.credential.getOAuth2Token(scheme.flows, {
|
|
28
|
+
abortSignal: request.abortSignal,
|
|
29
|
+
});
|
|
30
|
+
request.headers.set("Authorization", `Bearer ${token}`);
|
|
31
|
+
return next(request);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=oauth2AuthenticationPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth2AuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/oauth2AuthenticationPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAoClC,gEAsBC;AAnDD,6EAAsE;AAEtE;;GAEG;AACU,QAAA,8BAA8B,GAAG,4BAA4B,CAAC;AAqB3E;;GAEG;AACH,SAAgB,0BAA0B,CACxC,OAAkD;IAElD,OAAO;QACL,IAAI,EAAE,sCAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;;YAC3D,0FAA0F;YAC1F,IAAA,mDAAsB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEzC,MAAM,MAAM,GAAG,MAAA,CAAC,MAAA,OAAO,CAAC,WAAW,mCAAI,OAAO,CAAC,WAAW,CAAC,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;YAE9F,gFAAgF;YAChF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,KAAiB,EAAE;gBAC9E,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;YACxD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OAuth2Flow } from \"../../auth/oauth2Flows.js\";\nimport type { OAuth2TokenCredential } from \"../../auth/credentials.js\";\nimport type { AuthScheme } from \"../../auth/schemes.js\";\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../../interfaces.js\";\nimport type { PipelinePolicy } from \"../../pipeline.js\";\nimport { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the OAuth2 Authentication Policy\n */\nexport const oauth2AuthenticationPolicyName = \"oauth2AuthenticationPolicy\";\n\n/**\n * Options for configuring the OAuth2 authentication policy\n */\nexport interface OAuth2AuthenticationPolicyOptions<TFlows extends OAuth2Flow> {\n /**\n * The OAuth2TokenCredential implementation that can supply the bearer token.\n */\n credential: OAuth2TokenCredential<TFlows>;\n /**\n * Optional authentication schemes to use. If not provided, schemes from the request will be used.\n */\n authSchemes?: AuthScheme[];\n /**\n * Allows for connecting to HTTP endpoints instead of enforcing HTTPS.\n * CAUTION: Never use this option in production.\n */\n allowInsecureConnection?: boolean;\n}\n\n/**\n * Gets a pipeline policy that adds authorization header from OAuth2 schemes\n */\nexport function oauth2AuthenticationPolicy<TFlows extends OAuth2Flow>(\n options: OAuth2AuthenticationPolicyOptions<TFlows>,\n): PipelinePolicy {\n return {\n name: oauth2AuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs\n ensureSecureConnection(request, options);\n\n const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === \"oauth2\");\n\n // Skip adding authentication header if no OAuth2 authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n const token = await options.credential.getOAuth2Token(scheme.flows as TFlows[], {\n abortSignal: request.abortSignal,\n });\n request.headers.set(\"Authorization\", `Bearer ${token}`);\n return next(request);\n },\n };\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AbortSignalLike } from "../abort-controller/AbortSignalLike.js";
|
|
2
1
|
/**
|
|
3
2
|
* Options related to abort controller.
|
|
4
3
|
*/
|
|
@@ -6,7 +5,7 @@ export interface AbortOptions {
|
|
|
6
5
|
/**
|
|
7
6
|
* The abortSignal associated with containing operation.
|
|
8
7
|
*/
|
|
9
|
-
abortSignal?:
|
|
8
|
+
abortSignal?: AbortSignal;
|
|
10
9
|
/**
|
|
11
10
|
* The abort error message associated with containing operation.
|
|
12
11
|
*/
|
|
@@ -16,12 +15,12 @@ export interface AbortOptions {
|
|
|
16
15
|
* Represents a function that returns a promise that can be aborted.
|
|
17
16
|
*/
|
|
18
17
|
export type AbortablePromiseBuilder<T> = (abortOptions: {
|
|
19
|
-
abortSignal?:
|
|
18
|
+
abortSignal?: AbortSignal;
|
|
20
19
|
}) => Promise<T>;
|
|
21
20
|
/**
|
|
22
21
|
* promise.race() wrapper that aborts rest of promises as soon as the first promise settles.
|
|
23
22
|
*/
|
|
24
23
|
export declare function cancelablePromiseRace<T extends unknown[]>(abortablePromiseBuilders: AbortablePromiseBuilder<T[number]>[], options?: {
|
|
25
|
-
abortSignal?:
|
|
24
|
+
abortSignal?: AbortSignal;
|
|
26
25
|
}): Promise<T[number]>;
|
|
27
26
|
//# sourceMappingURL=aborterUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aborterUtils.js","sourceRoot":"","sources":["../../../src/util/aborterUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;
|
|
1
|
+
{"version":3,"file":"aborterUtils.js","sourceRoot":"","sources":["../../../src/util/aborterUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AA0BlC,sDAiBC;AApBD;;GAEG;AACI,KAAK,UAAU,qBAAqB,CACzC,wBAA8D,EAC9D,OAAuC;;IAEvC,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;IACtC,SAAS,YAAY;QACnB,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IACD,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,0CAAE,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9D,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CACvB,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CACxE,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,0CAAE,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnE,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Options related to abort controller.\n */\nexport interface AbortOptions {\n /**\n * The abortSignal associated with containing operation.\n */\n abortSignal?: AbortSignal;\n /**\n * The abort error message associated with containing operation.\n */\n abortErrorMsg?: string;\n}\n\n/**\n * Represents a function that returns a promise that can be aborted.\n */\nexport type AbortablePromiseBuilder<T> = (abortOptions: {\n abortSignal?: AbortSignal;\n}) => Promise<T>;\n\n/**\n * promise.race() wrapper that aborts rest of promises as soon as the first promise settles.\n */\nexport async function cancelablePromiseRace<T extends unknown[]>(\n abortablePromiseBuilders: AbortablePromiseBuilder<T[number]>[],\n options?: { abortSignal?: AbortSignal },\n): Promise<T[number]> {\n const aborter = new AbortController();\n function abortHandler(): void {\n aborter.abort();\n }\n options?.abortSignal?.addEventListener(\"abort\", abortHandler);\n try {\n return await Promise.race(\n abortablePromiseBuilders.map((p) => p({ abortSignal: aborter.signal })),\n );\n } finally {\n aborter.abort();\n options?.abortSignal?.removeEventListener(\"abort\", abortHandler);\n }\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AbortSignalLike } from "../abort-controller/AbortSignalLike.js";
|
|
2
1
|
import type { PipelineResponse } from "../interfaces.js";
|
|
3
2
|
/**
|
|
4
3
|
* A wrapper for setTimeout that resolves a promise after delayInMs milliseconds.
|
|
@@ -10,7 +9,7 @@ import type { PipelineResponse } from "../interfaces.js";
|
|
|
10
9
|
* @returns Resolved promise
|
|
11
10
|
*/
|
|
12
11
|
export declare function delay<T>(delayInMs: number, value?: T, options?: {
|
|
13
|
-
abortSignal?:
|
|
12
|
+
abortSignal?: AbortSignal;
|
|
14
13
|
abortErrorMsg?: string;
|
|
15
14
|
}): Promise<T | void>;
|
|
16
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/util/helpers.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/util/helpers.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAgBlC,sBA6CC;AAMD,4DASC;AA1ED,qEAA+D;AAG/D,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAE1D;;;;;;;;GAQG;AACH,SAAgB,KAAK,CACnB,SAAiB,EACjB,KAAS,EACT,OAGC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,KAAK,GAA8C,SAAS,CAAC;QACjE,IAAI,SAAS,GAA6B,SAAS,CAAC;QAEpD,MAAM,aAAa,GAAG,GAAS,EAAE;YAC/B,OAAO,MAAM,CACX,IAAI,0BAAU,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,EAAC,CAAC,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAC,CAAC,CAAC,oBAAoB,CAAC,CACvF,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,eAAe,GAAG,GAAS,EAAE;YACjC,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,KAAI,SAAS,EAAE,CAAC;gBACtC,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC,CAAC;QAEF,SAAS,GAAG,GAAS,EAAE;YACrB,IAAI,KAAK,EAAE,CAAC;gBACV,YAAY,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;YACD,eAAe,EAAE,CAAC;YAClB,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC,CAAC;QAEF,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,KAAI,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACxD,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC;QAED,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,eAAe,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAE,CAAC;YACzB,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CACtC,QAA0B,EAC1B,UAAkB;IAElB,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;QAAE,OAAO;IACrC,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError } from \"../abort-controller/AbortError.js\";\nimport type { PipelineResponse } from \"../interfaces.js\";\n\nconst StandardAbortMessage = \"The operation was aborted.\";\n\n/**\n * A wrapper for setTimeout that resolves a promise after delayInMs milliseconds.\n * @param delayInMs - The number of milliseconds to be delayed.\n * @param value - The value to be resolved with after a timeout of t milliseconds.\n * @param options - The options for delay - currently abort options\n * - abortSignal - The abortSignal associated with containing operation.\n * - abortErrorMsg - The abort error message associated with containing operation.\n * @returns Resolved promise\n */\nexport function delay<T>(\n delayInMs: number,\n value?: T,\n options?: {\n abortSignal?: AbortSignal;\n abortErrorMsg?: string;\n },\n): Promise<T | void> {\n return new Promise((resolve, reject) => {\n let timer: ReturnType<typeof setTimeout> | undefined = undefined;\n let onAborted: (() => void) | undefined = undefined;\n\n const rejectOnAbort = (): void => {\n return reject(\n new AbortError(options?.abortErrorMsg ? options?.abortErrorMsg : StandardAbortMessage),\n );\n };\n\n const removeListeners = (): void => {\n if (options?.abortSignal && onAborted) {\n options.abortSignal.removeEventListener(\"abort\", onAborted);\n }\n };\n\n onAborted = (): void => {\n if (timer) {\n clearTimeout(timer);\n }\n removeListeners();\n return rejectOnAbort();\n };\n\n if (options?.abortSignal && options.abortSignal.aborted) {\n return rejectOnAbort();\n }\n\n timer = setTimeout(() => {\n removeListeners();\n resolve(value);\n }, delayInMs);\n\n if (options?.abortSignal) {\n options.abortSignal.addEventListener(\"abort\", onAborted);\n }\n });\n}\n\n/**\n * @internal\n * @returns the parsed value or undefined if the parsed value is invalid.\n */\nexport function parseHeaderValueAsNumber(\n response: PipelineResponse,\n headerName: string,\n): number | undefined {\n const value = response.headers.get(headerName);\n if (!value) return;\n const valueAsNum = Number(value);\n if (Number.isNaN(valueAsNum)) return;\n return valueAsNum;\n}\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { OAuth2Flow } from "./oauth2Flows.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options used when creating and sending get OAuth 2 requests for this operation.
|
|
4
|
+
*/
|
|
5
|
+
export interface GetOAuth2TokenOptions {
|
|
6
|
+
/** Abort signal for the request */
|
|
7
|
+
abortSignal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Options used when creating and sending get bearer token requests for this operation.
|
|
11
|
+
*/
|
|
12
|
+
export interface GetBearerTokenOptions {
|
|
13
|
+
/** Abort signal for the request */
|
|
14
|
+
abortSignal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Credential for OAuth2 authentication flows.
|
|
18
|
+
*/
|
|
19
|
+
export interface OAuth2TokenCredential<TFlows extends OAuth2Flow> {
|
|
20
|
+
/**
|
|
21
|
+
* Gets an OAuth2 token for the specified flows.
|
|
22
|
+
* @param flows - The OAuth2 flows to use.
|
|
23
|
+
* @param options - Options for the request.
|
|
24
|
+
* @returns - a valid access token which was obtained through one of the flows specified in `flows`.
|
|
25
|
+
*/
|
|
26
|
+
getOAuth2Token(flows: TFlows[], options?: GetOAuth2TokenOptions): Promise<string>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Credential for Bearer token authentication.
|
|
30
|
+
*/
|
|
31
|
+
export interface BearerTokenCredential {
|
|
32
|
+
/**
|
|
33
|
+
* Gets a Bearer token for the specified flows.
|
|
34
|
+
* @param options - Options for the request.
|
|
35
|
+
* @returns - a valid access token.
|
|
36
|
+
*/
|
|
37
|
+
getBearerToken(options?: GetBearerTokenOptions): Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Credential for HTTP Basic authentication.
|
|
41
|
+
* Provides username and password for basic authentication headers.
|
|
42
|
+
*/
|
|
43
|
+
export interface BasicCredential {
|
|
44
|
+
/** The username for basic authentication. */
|
|
45
|
+
username: string;
|
|
46
|
+
/** The password for basic authentication. */
|
|
47
|
+
password: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Credential for API Key authentication.
|
|
51
|
+
* Provides an API key that will be used in the request headers.
|
|
52
|
+
*/
|
|
53
|
+
export interface ApiKeyCredential {
|
|
54
|
+
/** The API key for authentication. */
|
|
55
|
+
key: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Union type of all supported authentication credentials.
|
|
59
|
+
*/
|
|
60
|
+
export type ClientCredential = OAuth2TokenCredential<OAuth2Flow> | BearerTokenCredential | BasicCredential | ApiKeyCredential;
|
|
61
|
+
/**
|
|
62
|
+
* Type guard to check if a credential is an OAuth2 token credential.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isOAuth2TokenCredential(credential: ClientCredential): credential is OAuth2TokenCredential<OAuth2Flow>;
|
|
65
|
+
/**
|
|
66
|
+
* Type guard to check if a credential is a Bearer token credential.
|
|
67
|
+
*/
|
|
68
|
+
export declare function isBearerTokenCredential(credential: ClientCredential): credential is BearerTokenCredential;
|
|
69
|
+
/**
|
|
70
|
+
* Type guard to check if a credential is a Basic auth credential.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isBasicCredential(credential: ClientCredential): credential is BasicCredential;
|
|
73
|
+
/**
|
|
74
|
+
* Type guard to check if a credential is an API key credential.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isApiKeyCredential(credential: ClientCredential): credential is ApiKeyCredential;
|
|
77
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
/**
|
|
4
|
+
* Type guard to check if a credential is an OAuth2 token credential.
|
|
5
|
+
*/
|
|
6
|
+
export function isOAuth2TokenCredential(credential) {
|
|
7
|
+
return "getOAuth2Token" in credential;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Type guard to check if a credential is a Bearer token credential.
|
|
11
|
+
*/
|
|
12
|
+
export function isBearerTokenCredential(credential) {
|
|
13
|
+
return "getBearerToken" in credential;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if a credential is a Basic auth credential.
|
|
17
|
+
*/
|
|
18
|
+
export function isBasicCredential(credential) {
|
|
19
|
+
return "username" in credential && "password" in credential;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Type guard to check if a credential is an API key credential.
|
|
23
|
+
*/
|
|
24
|
+
export function isApiKeyCredential(credential) {
|
|
25
|
+
return "key" in credential;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../src/auth/credentials.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA0ElC;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,UAA4B;IAE5B,OAAO,gBAAgB,IAAI,UAAU,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,UAA4B;IAE5B,OAAO,gBAAgB,IAAI,UAAU,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAA4B;IAC5D,OAAO,UAAU,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAA4B;IAC7D,OAAO,KAAK,IAAI,UAAU,CAAC;AAC7B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OAuth2Flow } from \"./oauth2Flows.js\";\n\n/**\n * Options used when creating and sending get OAuth 2 requests for this operation.\n */\nexport interface GetOAuth2TokenOptions {\n /** Abort signal for the request */\n abortSignal?: AbortSignal;\n}\n\n/**\n * Options used when creating and sending get bearer token requests for this operation.\n */\nexport interface GetBearerTokenOptions {\n /** Abort signal for the request */\n abortSignal?: AbortSignal;\n}\n\n/**\n * Credential for OAuth2 authentication flows.\n */\nexport interface OAuth2TokenCredential<TFlows extends OAuth2Flow> {\n /**\n * Gets an OAuth2 token for the specified flows.\n * @param flows - The OAuth2 flows to use.\n * @param options - Options for the request.\n * @returns - a valid access token which was obtained through one of the flows specified in `flows`.\n */\n getOAuth2Token(flows: TFlows[], options?: GetOAuth2TokenOptions): Promise<string>;\n}\n\n/**\n * Credential for Bearer token authentication.\n */\nexport interface BearerTokenCredential {\n /**\n * Gets a Bearer token for the specified flows.\n * @param options - Options for the request.\n * @returns - a valid access token.\n */\n getBearerToken(options?: GetBearerTokenOptions): Promise<string>;\n}\n\n/**\n * Credential for HTTP Basic authentication.\n * Provides username and password for basic authentication headers.\n */\nexport interface BasicCredential {\n /** The username for basic authentication. */\n username: string;\n /** The password for basic authentication. */\n password: string;\n}\n\n/**\n * Credential for API Key authentication.\n * Provides an API key that will be used in the request headers.\n */\nexport interface ApiKeyCredential {\n /** The API key for authentication. */\n key: string;\n}\n\n/**\n * Union type of all supported authentication credentials.\n */\nexport type ClientCredential =\n | OAuth2TokenCredential<OAuth2Flow>\n | BearerTokenCredential\n | BasicCredential\n | ApiKeyCredential;\n\n/**\n * Type guard to check if a credential is an OAuth2 token credential.\n */\nexport function isOAuth2TokenCredential(\n credential: ClientCredential,\n): credential is OAuth2TokenCredential<OAuth2Flow> {\n return \"getOAuth2Token\" in credential;\n}\n\n/**\n * Type guard to check if a credential is a Bearer token credential.\n */\nexport function isBearerTokenCredential(\n credential: ClientCredential,\n): credential is BearerTokenCredential {\n return \"getBearerToken\" in credential;\n}\n\n/**\n * Type guard to check if a credential is a Basic auth credential.\n */\nexport function isBasicCredential(credential: ClientCredential): credential is BasicCredential {\n return \"username\" in credential && \"password\" in credential;\n}\n\n/**\n * Type guard to check if a credential is an API key credential.\n */\nexport function isApiKeyCredential(credential: ClientCredential): credential is ApiKeyCredential {\n return \"key\" in credential;\n}\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents OAuth2 Authorization Code flow configuration.
|
|
3
|
+
*/
|
|
4
|
+
export interface AuthorizationCodeFlow {
|
|
5
|
+
/** Type of OAuth2 flow */
|
|
6
|
+
kind: "authorizationCode";
|
|
7
|
+
/** Authorization endpoint */
|
|
8
|
+
authorizationUrl: string;
|
|
9
|
+
/** Token endpoint */
|
|
10
|
+
tokenUrl: string;
|
|
11
|
+
/** Refresh token endpoint */
|
|
12
|
+
refreshUrl?: string;
|
|
13
|
+
/** OAuth2 scopes */
|
|
14
|
+
scopes?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Represents OAuth2 Client Credentials flow configuration.
|
|
18
|
+
*/
|
|
19
|
+
export interface ClientCredentialsFlow {
|
|
20
|
+
/** Type of OAuth2 flow */
|
|
21
|
+
kind: "clientCredentials";
|
|
22
|
+
/** Token endpoint */
|
|
23
|
+
tokenUrl: string;
|
|
24
|
+
/** Refresh token endpoints */
|
|
25
|
+
refreshUrl?: string[];
|
|
26
|
+
/** OAuth2 scopes */
|
|
27
|
+
scopes?: string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents OAuth2 Implicit flow configuration.
|
|
31
|
+
*/
|
|
32
|
+
export interface ImplicitFlow {
|
|
33
|
+
/** Type of OAuth2 flow */
|
|
34
|
+
kind: "implicit";
|
|
35
|
+
/** Authorization endpoint */
|
|
36
|
+
authorizationUrl: string;
|
|
37
|
+
/** Refresh token endpoint */
|
|
38
|
+
refreshUrl?: string;
|
|
39
|
+
/** OAuth2 scopes */
|
|
40
|
+
scopes?: string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Represents OAuth2 Password flow configuration.
|
|
44
|
+
*/
|
|
45
|
+
export interface PasswordFlow {
|
|
46
|
+
/** Type of OAuth2 flow */
|
|
47
|
+
kind: "password";
|
|
48
|
+
/** Token endpoint */
|
|
49
|
+
tokenUrl: string;
|
|
50
|
+
/** Refresh token endpoint */
|
|
51
|
+
refreshUrl?: string;
|
|
52
|
+
/** OAuth2 scopes */
|
|
53
|
+
scopes?: string[];
|
|
54
|
+
}
|
|
55
|
+
/** Union type of all supported OAuth2 flows */
|
|
56
|
+
export type OAuth2Flow = AuthorizationCodeFlow | ClientCredentialsFlow | ImplicitFlow | PasswordFlow;
|
|
57
|
+
//# sourceMappingURL=oauth2Flows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth2Flows.js","sourceRoot":"","sources":["../../../src/auth/oauth2Flows.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Represents OAuth2 Authorization Code flow configuration.\n */\nexport interface AuthorizationCodeFlow {\n /** Type of OAuth2 flow */\n kind: \"authorizationCode\";\n /** Authorization endpoint */\n authorizationUrl: string;\n /** Token endpoint */\n tokenUrl: string;\n /** Refresh token endpoint */\n refreshUrl?: string;\n /** OAuth2 scopes */\n scopes?: string[];\n}\n\n/**\n * Represents OAuth2 Client Credentials flow configuration.\n */\nexport interface ClientCredentialsFlow {\n /** Type of OAuth2 flow */\n kind: \"clientCredentials\";\n /** Token endpoint */\n tokenUrl: string;\n /** Refresh token endpoints */\n refreshUrl?: string[];\n /** OAuth2 scopes */\n scopes?: string[];\n}\n\n/**\n * Represents OAuth2 Implicit flow configuration.\n */\nexport interface ImplicitFlow {\n /** Type of OAuth2 flow */\n kind: \"implicit\";\n /** Authorization endpoint */\n authorizationUrl: string;\n /** Refresh token endpoint */\n refreshUrl?: string;\n /** OAuth2 scopes */\n scopes?: string[];\n}\n\n/**\n * Represents OAuth2 Password flow configuration.\n */\nexport interface PasswordFlow {\n /** Type of OAuth2 flow */\n kind: \"password\";\n /** Token endpoint */\n tokenUrl: string;\n /** Refresh token endpoint */\n refreshUrl?: string;\n /** OAuth2 scopes */\n scopes?: string[];\n}\n\n/** Union type of all supported OAuth2 flows */\nexport type OAuth2Flow =\n | AuthorizationCodeFlow\n | ClientCredentialsFlow\n | ImplicitFlow\n | PasswordFlow;\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { OAuth2Flow } from "./oauth2Flows.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents HTTP Basic authentication scheme.
|
|
4
|
+
* Basic authentication scheme requires a username and password to be provided with each request.
|
|
5
|
+
* The credentials are encoded using Base64 and included in the Authorization header.
|
|
6
|
+
*/
|
|
7
|
+
export interface BasicAuthScheme {
|
|
8
|
+
/** Type of auth scheme */
|
|
9
|
+
kind: "http";
|
|
10
|
+
/** Basic authentication scheme */
|
|
11
|
+
scheme: "basic";
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Represents HTTP Bearer authentication scheme.
|
|
15
|
+
* Bearer authentication scheme requires a bearer token to be provided with each request.
|
|
16
|
+
* The token is included in the Authorization header with the "Bearer" prefix.
|
|
17
|
+
*/
|
|
18
|
+
export interface BearerAuthScheme {
|
|
19
|
+
/** Type of auth scheme */
|
|
20
|
+
kind: "http";
|
|
21
|
+
/** Bearer authentication scheme */
|
|
22
|
+
scheme: "bearer";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Represents an endpoint or operation that requires no authentication.
|
|
26
|
+
*/
|
|
27
|
+
export interface NoAuthAuthScheme {
|
|
28
|
+
/** Type of auth scheme */
|
|
29
|
+
kind: "noAuth";
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Represents API Key authentication scheme.
|
|
33
|
+
* API Key authentication requires a key to be provided with each request.
|
|
34
|
+
* The key can be provided in different locations: query parameter, header, or cookie.
|
|
35
|
+
*/
|
|
36
|
+
export interface ApiKeyAuthScheme {
|
|
37
|
+
/** Type of auth scheme */
|
|
38
|
+
kind: "apiKey";
|
|
39
|
+
/** Location of the API key */
|
|
40
|
+
apiKeyLocation: "query" | "header" | "cookie";
|
|
41
|
+
/** Name of the API key parameter */
|
|
42
|
+
name: string;
|
|
43
|
+
}
|
|
44
|
+
/** Represents OAuth2 authentication scheme with specified flows */
|
|
45
|
+
export interface OAuth2AuthScheme<TFlows extends OAuth2Flow[]> {
|
|
46
|
+
/** Type of auth scheme */
|
|
47
|
+
kind: "oauth2";
|
|
48
|
+
/** Supported OAuth2 flows */
|
|
49
|
+
flows: TFlows;
|
|
50
|
+
}
|
|
51
|
+
/** Union type of all supported authentication schemes */
|
|
52
|
+
export type AuthScheme = BasicAuthScheme | BearerAuthScheme | NoAuthAuthScheme | ApiKeyAuthScheme | OAuth2AuthScheme<OAuth2Flow[]>;
|
|
53
|
+
//# sourceMappingURL=schemes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemes.js","sourceRoot":"","sources":["../../../src/auth/schemes.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OAuth2Flow } from \"./oauth2Flows.js\";\n\n/**\n * Represents HTTP Basic authentication scheme.\n * Basic authentication scheme requires a username and password to be provided with each request.\n * The credentials are encoded using Base64 and included in the Authorization header.\n */\nexport interface BasicAuthScheme {\n /** Type of auth scheme */\n kind: \"http\";\n /** Basic authentication scheme */\n scheme: \"basic\";\n}\n\n/**\n * Represents HTTP Bearer authentication scheme.\n * Bearer authentication scheme requires a bearer token to be provided with each request.\n * The token is included in the Authorization header with the \"Bearer\" prefix.\n */\nexport interface BearerAuthScheme {\n /** Type of auth scheme */\n kind: \"http\";\n /** Bearer authentication scheme */\n scheme: \"bearer\";\n}\n\n/**\n * Represents an endpoint or operation that requires no authentication.\n */\nexport interface NoAuthAuthScheme {\n /** Type of auth scheme */\n kind: \"noAuth\";\n}\n\n/**\n * Represents API Key authentication scheme.\n * API Key authentication requires a key to be provided with each request.\n * The key can be provided in different locations: query parameter, header, or cookie.\n */\nexport interface ApiKeyAuthScheme {\n /** Type of auth scheme */\n kind: \"apiKey\";\n /** Location of the API key */\n apiKeyLocation: \"query\" | \"header\" | \"cookie\";\n /** Name of the API key parameter */\n name: string;\n}\n\n/** Represents OAuth2 authentication scheme with specified flows */\nexport interface OAuth2AuthScheme<TFlows extends OAuth2Flow[]> {\n /** Type of auth scheme */\n kind: \"oauth2\";\n /** Supported OAuth2 flows */\n flows: TFlows;\n}\n\n/** Union type of all supported authentication schemes */\nexport type AuthScheme =\n | BasicAuthScheme\n | BearerAuthScheme\n | NoAuthAuthScheme\n | ApiKeyAuthScheme\n | OAuth2AuthScheme<OAuth2Flow[]>;\n"]}
|
|
@@ -1,28 +1,9 @@
|
|
|
1
1
|
import type { HttpClient } from "../interfaces.js";
|
|
2
2
|
import type { Pipeline } from "../pipeline.js";
|
|
3
|
-
import type { TokenCredential } from "../auth/tokenCredential.js";
|
|
4
|
-
import type { KeyCredential } from "../auth/keyCredential.js";
|
|
5
3
|
import type { ClientOptions } from "./common.js";
|
|
6
|
-
/**
|
|
7
|
-
* Optional parameters for adding a credential policy to the pipeline.
|
|
8
|
-
*/
|
|
9
|
-
export interface AddCredentialPipelinePolicyOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Options related to the client.
|
|
12
|
-
*/
|
|
13
|
-
clientOptions?: ClientOptions;
|
|
14
|
-
/**
|
|
15
|
-
* The credential to use.
|
|
16
|
-
*/
|
|
17
|
-
credential?: TokenCredential | KeyCredential;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
|
|
21
|
-
*/
|
|
22
|
-
export declare function addCredentialPipelinePolicy(pipeline: Pipeline, endpoint: string, options?: AddCredentialPipelinePolicyOptions): void;
|
|
23
4
|
/**
|
|
24
5
|
* Creates a default rest pipeline to re-use accross Rest Level Clients
|
|
25
6
|
*/
|
|
26
|
-
export declare function createDefaultPipeline(
|
|
7
|
+
export declare function createDefaultPipeline(options?: ClientOptions): Pipeline;
|
|
27
8
|
export declare function getCachedDefaultHttpsClient(): HttpClient;
|
|
28
9
|
//# sourceMappingURL=clientHelpers.d.ts.map
|
|
@@ -1,44 +1,35 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { bearerTokenAuthenticationPolicy } from "../policies/bearerTokenAuthenticationPolicy.js";
|
|
4
3
|
import { createDefaultHttpClient } from "../defaultHttpClient.js";
|
|
5
4
|
import { createPipelineFromOptions } from "../createPipelineFromOptions.js";
|
|
6
|
-
import { isTokenCredential } from "../auth/tokenCredential.js";
|
|
7
|
-
import { isKeyCredential } from "../auth/keyCredential.js";
|
|
8
5
|
import { apiVersionPolicy } from "./apiVersionPolicy.js";
|
|
9
|
-
import {
|
|
6
|
+
import { isApiKeyCredential, isBasicCredential, isBearerTokenCredential, isOAuth2TokenCredential, } from "../auth/credentials.js";
|
|
7
|
+
import { apiKeyAuthenticationPolicy } from "../policies/auth/apiKeyAuthenticationPolicy.js";
|
|
8
|
+
import { basicAuthenticationPolicy } from "../policies/auth/basicAuthenticationPolicy.js";
|
|
9
|
+
import { bearerAuthenticationPolicy } from "../policies/auth/bearerAuthenticationPolicy.js";
|
|
10
|
+
import { oauth2AuthenticationPolicy } from "../policies/auth/oauth2AuthenticationPolicy.js";
|
|
10
11
|
let cachedHttpClient;
|
|
11
|
-
/**
|
|
12
|
-
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
|
|
13
|
-
*/
|
|
14
|
-
export function addCredentialPipelinePolicy(pipeline, endpoint, options = {}) {
|
|
15
|
-
var _a, _b, _c, _d;
|
|
16
|
-
const { credential, clientOptions } = options;
|
|
17
|
-
if (!credential) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (isTokenCredential(credential)) {
|
|
21
|
-
const tokenPolicy = bearerTokenAuthenticationPolicy({
|
|
22
|
-
credential,
|
|
23
|
-
scopes: (_b = (_a = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.credentials) === null || _a === void 0 ? void 0 : _a.scopes) !== null && _b !== void 0 ? _b : `${endpoint}/.default`,
|
|
24
|
-
});
|
|
25
|
-
pipeline.addPolicy(tokenPolicy);
|
|
26
|
-
}
|
|
27
|
-
else if (isKeyCredential(credential)) {
|
|
28
|
-
if (!((_c = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.credentials) === null || _c === void 0 ? void 0 : _c.apiKeyHeaderName)) {
|
|
29
|
-
throw new Error(`Missing API Key Header Name`);
|
|
30
|
-
}
|
|
31
|
-
const keyPolicy = keyCredentialAuthenticationPolicy(credential, (_d = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.credentials) === null || _d === void 0 ? void 0 : _d.apiKeyHeaderName);
|
|
32
|
-
pipeline.addPolicy(keyPolicy);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
12
|
/**
|
|
36
13
|
* Creates a default rest pipeline to re-use accross Rest Level Clients
|
|
37
14
|
*/
|
|
38
|
-
export function createDefaultPipeline(
|
|
15
|
+
export function createDefaultPipeline(options = {}) {
|
|
39
16
|
const pipeline = createPipelineFromOptions(options);
|
|
40
17
|
pipeline.addPolicy(apiVersionPolicy(options));
|
|
41
|
-
|
|
18
|
+
const { credential, authSchemes } = options;
|
|
19
|
+
if (credential) {
|
|
20
|
+
if (isApiKeyCredential(credential)) {
|
|
21
|
+
pipeline.addPolicy(apiKeyAuthenticationPolicy({ authSchemes, credential }));
|
|
22
|
+
}
|
|
23
|
+
else if (isBasicCredential(credential)) {
|
|
24
|
+
pipeline.addPolicy(basicAuthenticationPolicy({ authSchemes, credential }));
|
|
25
|
+
}
|
|
26
|
+
else if (isBearerTokenCredential(credential)) {
|
|
27
|
+
pipeline.addPolicy(bearerAuthenticationPolicy({ authSchemes, credential }));
|
|
28
|
+
}
|
|
29
|
+
else if (isOAuth2TokenCredential(credential)) {
|
|
30
|
+
pipeline.addPolicy(oauth2AuthenticationPolicy({ authSchemes, credential }));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
42
33
|
return pipeline;
|
|
43
34
|
}
|
|
44
35
|
export function getCachedDefaultHttpsClient() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../../src/client/clientHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE
|
|
1
|
+
{"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../../src/client/clientHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAE5F,IAAI,gBAAwC,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAyB,EAAE;IAC/D,MAAM,QAAQ,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAEpD,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE9C,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAC5C,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;YACnC,QAAQ,CAAC,SAAS,CAAC,0BAA0B,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QAC9E,CAAC;aAAM,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;YACzC,QAAQ,CAAC,SAAS,CAAC,yBAAyB,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QAC7E,CAAC;aAAM,IAAI,uBAAuB,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/C,QAAQ,CAAC,SAAS,CAAC,0BAA0B,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QAC9E,CAAC;aAAM,IAAI,uBAAuB,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/C,QAAQ,CAAC,SAAS,CAAC,0BAA0B,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,uBAAuB,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient } from \"../interfaces.js\";\nimport type { Pipeline } from \"../pipeline.js\";\nimport { createDefaultHttpClient } from \"../defaultHttpClient.js\";\nimport { createPipelineFromOptions } from \"../createPipelineFromOptions.js\";\nimport type { ClientOptions } from \"./common.js\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy.js\";\nimport {\n isApiKeyCredential,\n isBasicCredential,\n isBearerTokenCredential,\n isOAuth2TokenCredential,\n} from \"../auth/credentials.js\";\nimport { apiKeyAuthenticationPolicy } from \"../policies/auth/apiKeyAuthenticationPolicy.js\";\nimport { basicAuthenticationPolicy } from \"../policies/auth/basicAuthenticationPolicy.js\";\nimport { bearerAuthenticationPolicy } from \"../policies/auth/bearerAuthenticationPolicy.js\";\nimport { oauth2AuthenticationPolicy } from \"../policies/auth/oauth2AuthenticationPolicy.js\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(options: ClientOptions = {}): Pipeline {\n const pipeline = createPipelineFromOptions(options);\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n const { credential, authSchemes } = options;\n if (credential) {\n if (isApiKeyCredential(credential)) {\n pipeline.addPolicy(apiKeyAuthenticationPolicy({ authSchemes, credential }));\n } else if (isBasicCredential(credential)) {\n pipeline.addPolicy(basicAuthenticationPolicy({ authSchemes, credential }));\n } else if (isBearerTokenCredential(credential)) {\n pipeline.addPolicy(bearerAuthenticationPolicy({ authSchemes, credential }));\n } else if (isOAuth2TokenCredential(credential)) {\n pipeline.addPolicy(oauth2AuthenticationPolicy({ authSchemes, credential }));\n }\n }\n\n return pipeline;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { HttpClient, PipelineRequest, PipelineResponse, RawHttpHeaders, RequestBodyType, TransferProgressEvent, RawHttpHeadersInput } from "../interfaces.js";
|
|
2
2
|
import type { Pipeline, PipelinePolicy } from "../pipeline.js";
|
|
3
|
-
import type { AbortSignalLike } from "../abort-controller/AbortSignalLike.js";
|
|
4
3
|
import type { PipelineOptions } from "../createPipelineFromOptions.js";
|
|
5
4
|
import type { LogPolicyOptions } from "../policies/logPolicy.js";
|
|
5
|
+
import type { AuthScheme } from "../auth/schemes.js";
|
|
6
|
+
import type { ClientCredential } from "../auth/credentials.js";
|
|
6
7
|
/**
|
|
7
8
|
* Shape of the default request parameters, this may be overridden by the specific
|
|
8
9
|
* request types to provide strong types
|
|
@@ -54,7 +55,7 @@ export type RequestParameters = {
|
|
|
54
55
|
/**
|
|
55
56
|
* The signal which can be used to abort requests.
|
|
56
57
|
*/
|
|
57
|
-
abortSignal?:
|
|
58
|
+
abortSignal?: AbortSignal;
|
|
58
59
|
/**
|
|
59
60
|
* A function to be called each time a response is received from the server
|
|
60
61
|
* while performing the requested operation.
|
|
@@ -93,7 +94,7 @@ export interface OperationOptions {
|
|
|
93
94
|
/**
|
|
94
95
|
* The signal which can be used to abort requests.
|
|
95
96
|
*/
|
|
96
|
-
abortSignal?:
|
|
97
|
+
abortSignal?: AbortSignal;
|
|
97
98
|
/**
|
|
98
99
|
* Options used when creating and sending HTTP requests for this operation.
|
|
99
100
|
*/
|
|
@@ -262,18 +263,15 @@ export interface AdditionalPolicyConfig {
|
|
|
262
263
|
*/
|
|
263
264
|
export type ClientOptions = PipelineOptions & {
|
|
264
265
|
/**
|
|
265
|
-
*
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
*/
|
|
275
|
-
apiKeyHeaderName?: string;
|
|
276
|
-
};
|
|
266
|
+
* List of authentication schemes supported by the client.
|
|
267
|
+
* These schemes define how the client can authenticate requests.
|
|
268
|
+
*/
|
|
269
|
+
authSchemes?: AuthScheme[];
|
|
270
|
+
/**
|
|
271
|
+
* The credential used to authenticate requests.
|
|
272
|
+
* Must be compatible with one of the specified authentication schemes.
|
|
273
|
+
*/
|
|
274
|
+
credential?: ClientCredential;
|
|
277
275
|
/**
|
|
278
276
|
* Endpoint for the client
|
|
279
277
|
*/
|