UNPKG

1.12 kBPlain TextView Raw
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License. See License.txt in the project root for license information.
3
4import { AgentSettings } from "../serviceClient";
5import {
6 BaseRequestPolicy,
7 RequestPolicy,
8 RequestPolicyFactory,
9 RequestPolicyOptionsLike,
10} from "./requestPolicy";
11import { HttpOperationResponse } from "../httpOperationResponse";
12import { WebResourceLike } from "../webResource";
13
14const agentNotSupportedInBrowser = new Error("AgentPolicy is not supported in browser environment");
15
16export function agentPolicy(_agentSettings?: AgentSettings): RequestPolicyFactory {
17 return {
18 create: (_nextPolicy: RequestPolicy, _options: RequestPolicyOptionsLike) => {
19 throw agentNotSupportedInBrowser;
20 },
21 };
22}
23
24export class AgentPolicy extends BaseRequestPolicy {
25 constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptionsLike) {
26 super(nextPolicy, options);
27 throw agentNotSupportedInBrowser;
28 }
29
30 public sendRequest(_request: WebResourceLike): Promise<HttpOperationResponse> {
31 throw agentNotSupportedInBrowser;
32 }
33}