@equinor/fusion-framework-module-http 6.2.1 → 6.2.2
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/CHANGELOG.md +336 -310
- package/dist/esm/configurator.js.map +1 -1
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/lib/client/client-msal.js.map +1 -1
- package/dist/esm/lib/client/client.js.map +1 -1
- package/dist/esm/lib/operators/capitalize-request-method.operator.js +3 -1
- package/dist/esm/lib/operators/capitalize-request-method.operator.js.map +1 -1
- package/dist/esm/lib/operators/fetch-request.schema.js.map +1 -1
- package/dist/esm/lib/operators/http-request-handler.js.map +1 -1
- package/dist/esm/lib/operators/process-operators.js.map +1 -1
- package/dist/esm/lib/operators/request-operator-header.js.map +1 -1
- package/dist/esm/lib/operators/request-validation.operator.js.map +1 -1
- package/dist/esm/lib/selectors/blob-selector.js.map +1 -1
- package/dist/esm/lib/selectors/json-selector.js.map +1 -1
- package/dist/esm/module.js +1 -1
- package/dist/esm/module.js.map +1 -1
- package/dist/esm/provider.js +8 -3
- package/dist/esm/provider.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/lib/operators/process-operators.d.ts +1 -1
- package/dist/types/module.d.ts +3 -3
- package/dist/types/provider.d.ts +10 -3
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/configurator.ts +115 -116
- package/src/errors.ts +24 -24
- package/src/lib/client/client-msal.ts +34 -34
- package/src/lib/client/client.ts +298 -298
- package/src/lib/client/types.ts +147 -145
- package/src/lib/operators/capitalize-request-method.operator.ts +11 -9
- package/src/lib/operators/fetch-request.schema.ts +70 -73
- package/src/lib/operators/http-request-handler.ts +11 -11
- package/src/lib/operators/process-operators.ts +88 -88
- package/src/lib/operators/request-operator-header.ts +6 -6
- package/src/lib/operators/request-validation.operator.ts +32 -32
- package/src/lib/operators/types.ts +44 -44
- package/src/lib/selectors/blob-selector.ts +24 -24
- package/src/lib/selectors/json-selector.ts +25 -25
- package/src/module.ts +73 -69
- package/src/provider.ts +141 -139
- package/src/version.ts +1 -1
- package/tests/HttpClient.test.ts +37 -37
- package/tests/operators.test.ts +67 -67
- package/vitest.config.ts +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
|
-
import { IProcessOperators, ProcessOperator } from './types';
|
|
2
|
+
import type { IProcessOperators, ProcessOperator } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* ProcessOperators class manages a collection of process operators
|
|
5
5
|
* and provides methods to add, set, get, and process these operators.
|
package/dist/types/module.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HttpClientMsal } from './lib/client';
|
|
2
|
-
import { IHttpClientConfigurator, HttpClientOptions } from './configurator';
|
|
3
|
-
import { IHttpClientProvider } from './provider';
|
|
2
|
+
import { type IHttpClientConfigurator, type HttpClientOptions } from './configurator';
|
|
3
|
+
import { type IHttpClientProvider } from './provider';
|
|
4
4
|
import type { Module, ModuleConfigType, IModuleConfigurator } from '@equinor/fusion-framework-module';
|
|
5
|
-
import { MsalModule } from '@equinor/fusion-framework-module-msal';
|
|
5
|
+
import type { MsalModule } from '@equinor/fusion-framework-module-msal';
|
|
6
6
|
/**
|
|
7
7
|
* Defines the type for the HTTP module, which includes:
|
|
8
8
|
* - The module name: 'http'
|
package/dist/types/provider.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { HttpClient } from './lib/client';
|
|
2
|
-
import { HttpClientOptions, HttpClientRequestInitType, IHttpClientConfigurator } from './configurator';
|
|
1
|
+
import type { HttpClient } from './lib/client';
|
|
2
|
+
import type { HttpClientOptions, HttpClientRequestInitType, IHttpClientConfigurator } from './configurator';
|
|
3
3
|
import type { IHttpRequestHandler } from './lib/operators';
|
|
4
4
|
import type { IHttpClient } from './lib/client';
|
|
5
|
+
/**
|
|
6
|
+
* Exception thrown when a client cannot be found.
|
|
7
|
+
*
|
|
8
|
+
* This error is typically used to indicate that a requested client instance
|
|
9
|
+
* does not exist or cannot be located within the current context.
|
|
10
|
+
*
|
|
11
|
+
* @extends {Error}
|
|
12
|
+
*/
|
|
5
13
|
export declare class ClientNotFoundException extends Error {
|
|
6
|
-
constructor(message: string);
|
|
7
14
|
}
|
|
8
15
|
export interface IHttpClientProvider<TClient extends IHttpClient = IHttpClient> {
|
|
9
16
|
/**
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.2.
|
|
1
|
+
export declare const version = "6.2.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-module-http",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"rxjs": "^7.8.1",
|
|
58
58
|
"zod": "^3.23.8",
|
|
59
|
-
"@equinor/fusion-framework-module": "^4.3.
|
|
60
|
-
"@equinor/fusion-framework-module-msal": "^4.0.
|
|
59
|
+
"@equinor/fusion-framework-module": "^4.3.6",
|
|
60
|
+
"@equinor/fusion-framework-module-msal": "^4.0.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"typescript": "^5.5.4",
|
package/src/configurator.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
capitalizeRequestMethodOperator,
|
|
3
|
+
requestValidationOperator,
|
|
4
|
+
HttpRequestHandler,
|
|
5
5
|
} from './lib/operators';
|
|
6
6
|
|
|
7
7
|
import type { FetchRequest, IHttpClient } from './lib/client';
|
|
@@ -14,7 +14,7 @@ import type { IHttpRequestHandler, IHttpResponseHandler } from './lib/operators'
|
|
|
14
14
|
* @property {IHttpRequestHandler<TInit>} requestHandler - The request handler to be used by the `IHttpClient` instance.
|
|
15
15
|
*/
|
|
16
16
|
interface HttpClientConstructorOptions<TInit extends FetchRequest> {
|
|
17
|
-
|
|
17
|
+
requestHandler: IHttpRequestHandler<TInit>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -26,10 +26,10 @@ interface HttpClientConstructorOptions<TInit extends FetchRequest> {
|
|
|
26
26
|
* @returns A new instance of the `TClient` type.
|
|
27
27
|
*/
|
|
28
28
|
interface HttpClientConstructor<TClient extends IHttpClient> {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
new (
|
|
30
|
+
uri: string,
|
|
31
|
+
options: HttpClientConstructorOptions<HttpClientRequestInitType<TClient>>,
|
|
32
|
+
): TClient;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -38,23 +38,23 @@ interface HttpClientConstructor<TClient extends IHttpClient> {
|
|
|
38
38
|
* @template TClient - The type of the `IHttpClient` instance to be configured.
|
|
39
39
|
*/
|
|
40
40
|
export interface HttpClientOptions<TClient extends IHttpClient = IHttpClient> {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
/** The base URI for the `IHttpClient` instance. */
|
|
42
|
+
baseUri?: string;
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
/** The default scopes to be used by the `IHttpClient` instance. */
|
|
45
|
+
defaultScopes?: string[];
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
/** The constructor for the `TClient` type. */
|
|
48
|
+
ctor?: HttpClientConstructor<TClient>;
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
/** A callback function that is called when a new `TClient` instance is created. */
|
|
51
|
+
onCreate?: (client: TClient) => void;
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
/** The request handler to be used by the `IHttpClient` instance. */
|
|
54
|
+
requestHandler?: IHttpRequestHandler<HttpClientRequestInitType<TClient>>;
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
/** The response handler to be used by the `IHttpClient` instance. */
|
|
57
|
+
responseHandler?: IHttpResponseHandler<HttpClientRequestInitType<TClient>>;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -64,113 +64,112 @@ export interface HttpClientOptions<TClient extends IHttpClient = IHttpClient> {
|
|
|
64
64
|
* @template T - The type of the `IHttpClient` implementation.
|
|
65
65
|
* @returns The request init type for the `IHttpClient` implementation.
|
|
66
66
|
*/
|
|
67
|
-
export type HttpClientRequestInitType<T extends IHttpClient> =
|
|
68
|
-
|
|
67
|
+
export type HttpClientRequestInitType<T extends IHttpClient> = T extends IHttpClient<infer U>
|
|
68
|
+
? U
|
|
69
|
+
: never;
|
|
69
70
|
|
|
70
71
|
/**
|
|
71
72
|
* Instance for configuring http client
|
|
72
73
|
* @template TClient base type of client that the provider will create
|
|
73
74
|
*/
|
|
74
75
|
export interface IHttpClientConfigurator<TClient extends IHttpClient = IHttpClient> {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
76
|
+
readonly clients: Record<string, HttpClientOptions<TClient>>;
|
|
77
|
+
readonly defaultHttpClientCtor: HttpClientConstructor<TClient>;
|
|
78
|
+
readonly defaultHttpRequestHandler: IHttpRequestHandler<HttpClientRequestInitType<TClient>>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Configure a client with arguments
|
|
82
|
+
* @param name name of the client
|
|
83
|
+
* @param args option that are used cor creating a client
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* configurator.http.configureClient('foo',{
|
|
87
|
+
* baseUri: 'https://foo.bar',
|
|
88
|
+
* defaultScopes: ['foobar/.default']
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
configureClient<T extends TClient>(
|
|
93
|
+
name: string,
|
|
94
|
+
args: HttpClientOptions<T>,
|
|
95
|
+
): IHttpClientConfigurator<TClient>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Configure a simple client by name to an endpoint
|
|
99
|
+
* @param name name of the client
|
|
100
|
+
* @param uri base endpoint for the client
|
|
101
|
+
*/
|
|
102
|
+
configureClient(name: string, uri: string): IHttpClientConfigurator<TClient>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Creates a client with callback configuration
|
|
106
|
+
* @param name name of the client
|
|
107
|
+
* @param onCreate callback when a client is created
|
|
108
|
+
* ```ts
|
|
109
|
+
* configurator.http.configureClient('foo',(client) => {
|
|
110
|
+
* client.requestHandler.add('logger', (request) => console.log(request));
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
configureClient<T extends TClient>(
|
|
115
|
+
name: string,
|
|
116
|
+
onCreate: (client: T) => void,
|
|
117
|
+
): HttpClientConfigurator<TClient>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Check if there is a configuration for provided name
|
|
121
|
+
*/
|
|
122
|
+
hasClient(name: string): boolean;
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
/** @inheritdoc */
|
|
125
126
|
export class HttpClientConfigurator<TClient extends IHttpClient>
|
|
126
|
-
|
|
127
|
+
implements IHttpClientConfigurator<TClient>
|
|
127
128
|
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return this;
|
|
173
|
-
}
|
|
129
|
+
protected _clients: Record<string, HttpClientOptions<TClient>> = {};
|
|
130
|
+
|
|
131
|
+
/** Get a clone of all configured clients */
|
|
132
|
+
public get clients(): Record<string, HttpClientOptions<TClient>> {
|
|
133
|
+
return { ...this._clients };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** default class for creation of http clients */
|
|
137
|
+
readonly defaultHttpClientCtor: HttpClientConstructor<TClient>;
|
|
138
|
+
|
|
139
|
+
/** default request handler for http clients, applied on creation */
|
|
140
|
+
readonly defaultHttpRequestHandler = new HttpRequestHandler<HttpClientRequestInitType<TClient>>({
|
|
141
|
+
// convert all request methods to uppercase
|
|
142
|
+
['capitalize-method']: capitalizeRequestMethodOperator(),
|
|
143
|
+
// validate the request object
|
|
144
|
+
['request-validation']: requestValidationOperator(),
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Create a instance of http configuration
|
|
149
|
+
* @param client defaultHttpRequestHandler
|
|
150
|
+
*/
|
|
151
|
+
constructor(client: HttpClientConstructor<TClient>) {
|
|
152
|
+
this.defaultHttpClientCtor = client;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** @inheritdoc */
|
|
156
|
+
hasClient(name: string): boolean {
|
|
157
|
+
return Object.keys(this._clients).includes(name);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** @inheritdoc */
|
|
161
|
+
configureClient<T extends TClient>(
|
|
162
|
+
name: string,
|
|
163
|
+
args: string | HttpClientOptions<T> | HttpClientOptions<T>['onCreate'],
|
|
164
|
+
): HttpClientConfigurator<TClient> {
|
|
165
|
+
const argFn = typeof args === 'string' ? ({ baseUri: args } as HttpClientOptions<T>) : args;
|
|
166
|
+
const options = typeof argFn === 'function' ? { onCreate: argFn } : argFn;
|
|
167
|
+
this._clients[name] = {
|
|
168
|
+
...this._clients[name],
|
|
169
|
+
...(options as unknown as HttpClientOptions<TClient>),
|
|
170
|
+
};
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
174
173
|
}
|
|
175
174
|
|
|
176
175
|
export default HttpClientConfigurator;
|
package/src/errors.ts
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* @template TResponse The type of the HTTP response.
|
|
4
4
|
*/
|
|
5
5
|
export class HttpResponseError<TResponse = Response> extends Error {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
static Name = 'HttpResponseError';
|
|
7
|
+
constructor(
|
|
8
|
+
message: string,
|
|
9
|
+
public readonly response: TResponse,
|
|
10
|
+
options?: ErrorOptions,
|
|
11
|
+
) {
|
|
12
|
+
super(message, options);
|
|
13
|
+
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -21,22 +21,22 @@ export class HttpResponseError<TResponse = Response> extends Error {
|
|
|
21
21
|
* @template TResponse - The type of the HTTP response.
|
|
22
22
|
*/
|
|
23
23
|
export class HttpJsonResponseError<
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
TType = unknown,
|
|
25
|
+
TResponse = Response,
|
|
26
26
|
> extends HttpResponseError<TResponse> {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
static Name = 'HttpJsonResponseError';
|
|
28
|
+
public readonly data?: TType;
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new instance of `HttpJsonResponseError`.
|
|
32
|
+
*
|
|
33
|
+
* @param message - The error message.
|
|
34
|
+
* @param response - The HTTP response associated with the error.
|
|
35
|
+
* @param options - Additional options for the error, including the associated data.
|
|
36
|
+
*/
|
|
37
|
+
constructor(message: string, response: TResponse, options?: ErrorOptions & { data?: TType }) {
|
|
38
|
+
super(message, response, options);
|
|
39
|
+
this.name = HttpJsonResponseError.Name;
|
|
40
|
+
this.data = options?.data;
|
|
41
|
+
}
|
|
42
42
|
}
|
|
@@ -17,9 +17,9 @@ type MsalFetchRequest = FetchRequest & { scopes?: string[] };
|
|
|
17
17
|
* @template TResponse - The type of the response object. Defaults to `Response`.
|
|
18
18
|
*/
|
|
19
19
|
type MsalFetchRequestInit<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
TReturn = unknown,
|
|
21
|
+
TRequest = FetchRequest,
|
|
22
|
+
TResponse = FetchResponse,
|
|
23
23
|
> = FetchRequestInit<TReturn, TRequest, TResponse> & Pick<MsalFetchRequest, 'scopes'>;
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -37,42 +37,42 @@ type MsalFetchRequestInit<
|
|
|
37
37
|
* @template TResponse - The type of the response object. Defaults to `FetchResponse`.
|
|
38
38
|
*/
|
|
39
39
|
export class HttpClientMsal<
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
TRequest extends MsalFetchRequest = MsalFetchRequest,
|
|
41
|
+
TResponse extends FetchResponse = FetchResponse,
|
|
42
42
|
> extends HttpClient<TRequest, TResponse> {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
/**
|
|
44
|
+
* An array of default scopes to be used for all requests, unless overridden in the request object.
|
|
45
|
+
* This property is used by the `HttpClientMsal` class to add MSAL authentication support to requests.
|
|
46
|
+
*/
|
|
47
|
+
public defaultScopes: string[] = [];
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Fetches a resource from the specified path, with optional MSAL authentication scopes.
|
|
51
|
+
*
|
|
52
|
+
* This method extends the `HttpClient.fetch$` method to add support for MSAL authentication.
|
|
53
|
+
* If `init.scopes` is provided, it will be used in addition to the `defaultScopes` defined in the `HttpClientMsal` class.
|
|
54
|
+
* If `init.scopes` is not provided, only the `defaultScopes` will be used for the request.
|
|
55
|
+
*
|
|
56
|
+
* @overrides HttpClient.fetch$
|
|
57
|
+
*
|
|
58
|
+
* @param path - The path to the resource to fetch.
|
|
59
|
+
* @param init - An optional `MsalFetchRequestInit` object that can include the `scopes` property.
|
|
60
|
+
* @returns An `Observable` that emits the fetched resource.
|
|
61
|
+
*/
|
|
62
|
+
public fetch$<T = TResponse>(
|
|
63
|
+
path: string,
|
|
64
|
+
init?: MsalFetchRequestInit<T, TRequest, TResponse>,
|
|
65
|
+
): Observable<T> {
|
|
49
66
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* This method extends the `HttpClient.fetch$` method to add support for MSAL authentication.
|
|
53
|
-
* If `init.scopes` is provided, it will be used in addition to the `defaultScopes` defined in the `HttpClientMsal` class.
|
|
54
|
-
* If `init.scopes` is not provided, only the `defaultScopes` will be used for the request.
|
|
55
|
-
*
|
|
56
|
-
* @overrides HttpClient.fetch$
|
|
57
|
-
*
|
|
58
|
-
* @param path - The path to the resource to fetch.
|
|
59
|
-
* @param init - An optional `MsalFetchRequestInit` object that can include the `scopes` property.
|
|
60
|
-
* @returns An `Observable` that emits the fetched resource.
|
|
67
|
+
* Merges the default scopes defined in the `HttpClientMsal` class with the scopes provided in the `init` parameter, if any.
|
|
68
|
+
* This ensures that the request includes the necessary scopes for MSAL authentication.
|
|
61
69
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
): Observable<T> {
|
|
66
|
-
/**
|
|
67
|
-
* Merges the default scopes defined in the `HttpClientMsal` class with the scopes provided in the `init` parameter, if any.
|
|
68
|
-
* This ensures that the request includes the necessary scopes for MSAL authentication.
|
|
69
|
-
*/
|
|
70
|
-
const args = Object.assign(init || {}, {
|
|
71
|
-
scopes: this.defaultScopes.concat(init?.scopes || []),
|
|
72
|
-
}) as FetchRequestInit<T, TRequest, TResponse>;
|
|
70
|
+
const args = Object.assign(init || {}, {
|
|
71
|
+
scopes: this.defaultScopes.concat(init?.scopes || []),
|
|
72
|
+
}) as FetchRequestInit<T, TRequest, TResponse>;
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
return super._fetch$(path, args);
|
|
75
|
+
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
export default HttpClientMsal;
|