@equinor/fusion-framework-module-http
Advanced tools
Comparing version 0.1.0-beta.12 to 0.1.0-beta.14
import { HttpClient } from './client'; | ||
export class HttpClientMsal extends HttpClient { | ||
defaultScope = []; | ||
defaultScopes = []; | ||
fetch(init) { | ||
init = typeof init === 'string' ? { path: init } : init; | ||
Object.assign(init, { scopes: this.defaultScope.concat(init.scopes || []) }); | ||
Object.assign(init, { scopes: this.defaultScopes.concat(init.scopes || []) }); | ||
return super.fetch(init); | ||
@@ -8,0 +8,0 @@ } |
@@ -31,5 +31,6 @@ export class ClientNotFoundException extends Error { | ||
} | ||
const { baseUri, onCreate, ctor = this.config.defaultHttpClientCtor, requestHandler = this.config.defaultHttpRequestHandler, } = config; | ||
const { baseUri, defaultScopes = [], onCreate, ctor = this.config.defaultHttpClientCtor, requestHandler = this.config.defaultHttpRequestHandler, } = config; | ||
const options = { requestHandler }; | ||
const instance = new ctor(baseUri || '', options); | ||
Object.assign(instance, { defaultScopes }); | ||
onCreate && onCreate(instance); | ||
@@ -36,0 +37,0 @@ return instance; |
@@ -6,5 +6,5 @@ import { HttpClient, HttpRequestInit } from './client'; | ||
export declare class HttpClientMsal extends HttpClient<RequestInitMsal> { | ||
defaultScope: string[]; | ||
defaultScopes: string[]; | ||
fetch(init: Omit<RequestInitMsal, 'uri'> | string): ReturnType<HttpClient['fetch']>; | ||
} | ||
export default HttpClientMsal; |
@@ -10,2 +10,3 @@ import { HttpRequestHandler, HttpRequestInit, IHttpClient } from './client'; | ||
baseUri?: string; | ||
defaultScopes?: string[]; | ||
ctor?: HttpClientConstructor<TClient>; | ||
@@ -12,0 +13,0 @@ onCreate?: (client: TClient) => void; |
{ | ||
"name": "@equinor/fusion-framework-module-http", | ||
"version": "0.1.0-beta.12", | ||
"version": "0.1.0-beta.14", | ||
"description": "", | ||
@@ -24,3 +24,3 @@ "main": "./dist/esm/index.js", | ||
"dependencies": { | ||
"@equinor/fusion-framework-module": "^0.1.0-beta.12" | ||
"@equinor/fusion-framework-module": "^0.1.0-beta.14" | ||
}, | ||
@@ -35,3 +35,3 @@ "types": "index.d.ts", | ||
}, | ||
"gitHead": "1edabdde39b4815a9d56bf85748781986485d4fa" | ||
"gitHead": "be4491d21f95b885efb42970ea51a305207ac493" | ||
} |
@@ -9,3 +9,3 @@ import { HttpClient, HttpRequestInit } from './client'; | ||
/** Scope that will be applied to all request if no scope is provided in request object */ | ||
public defaultScope: string[] = []; | ||
public defaultScopes: string[] = []; | ||
@@ -15,3 +15,3 @@ /** @inheritdoc */ | ||
init = typeof init === 'string' ? { path: init } : init; | ||
Object.assign(init, { scopes: this.defaultScope.concat(init.scopes || []) }); | ||
Object.assign(init, { scopes: this.defaultScopes.concat(init.scopes || []) }); | ||
return super.fetch(init); | ||
@@ -18,0 +18,0 @@ } |
@@ -16,2 +16,3 @@ import { HttpRequestHandler, HttpRequestInit, IHttpClient } from './client'; | ||
baseUri?: string; | ||
defaultScopes?: string[]; | ||
ctor?: HttpClientConstructor<TClient>; | ||
@@ -18,0 +19,0 @@ onCreate?: (client: TClient) => void; |
@@ -58,2 +58,3 @@ import { HttpClient } from './client'; | ||
baseUri, | ||
defaultScopes = [], | ||
onCreate, | ||
@@ -65,2 +66,3 @@ ctor = this.config.defaultHttpClientCtor, | ||
const instance = new ctor(baseUri || '', options) as TClient; | ||
Object.assign(instance, { defaultScopes }); | ||
onCreate && onCreate(instance as TClient); | ||
@@ -67,0 +69,0 @@ return instance as TClient; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95597
714