defender-base-client
Advanced tools
Comparing version 1.37.0 to 1.38.0-rc.1
@@ -0,6 +1,8 @@ | ||
/// <reference types="node" /> | ||
import { AxiosError, AxiosInstance } from 'axios'; | ||
import https from 'https'; | ||
import { PoolData, UserPass } from './auth'; | ||
export declare function rejectWithDefenderApiError(axiosError: AxiosError): Promise<never>; | ||
export declare function createApi(key: string, token: string, apiUrl: string): AxiosInstance; | ||
export declare function createAuthenticatedApi(userPass: UserPass, poolData: PoolData, apiUrl: string): Promise<AxiosInstance>; | ||
export declare function createApi(key: string, token: string, apiUrl: string, httpsAgent?: https.Agent): AxiosInstance; | ||
export declare function createAuthenticatedApi(userPass: UserPass, poolData: PoolData, apiUrl: string, httpsAgent?: https.Agent): Promise<AxiosInstance>; | ||
//# sourceMappingURL=api.d.ts.map |
@@ -14,3 +14,3 @@ "use strict"; | ||
exports.rejectWithDefenderApiError = rejectWithDefenderApiError; | ||
function createApi(key, token, apiUrl) { | ||
function createApi(key, token, apiUrl, httpsAgent) { | ||
const instance = axios_1.default.create({ | ||
@@ -23,2 +23,3 @@ baseURL: apiUrl, | ||
}, | ||
httpsAgent, | ||
}); | ||
@@ -29,7 +30,7 @@ instance.interceptors.response.use(({ data }) => data, rejectWithDefenderApiError); | ||
exports.createApi = createApi; | ||
async function createAuthenticatedApi(userPass, poolData, apiUrl) { | ||
async function createAuthenticatedApi(userPass, poolData, apiUrl, httpsAgent) { | ||
const token = await auth_1.authenticate(userPass, poolData); | ||
const api = createApi(userPass.Username, token, apiUrl); | ||
const api = createApi(userPass.Username, token, apiUrl, httpsAgent); | ||
return api; | ||
} | ||
exports.createAuthenticatedApi = createAuthenticatedApi; |
@@ -0,2 +1,4 @@ | ||
/// <reference types="node" /> | ||
import { AxiosInstance } from 'axios'; | ||
import https from 'https'; | ||
export declare abstract class BaseApiClient { | ||
@@ -6,2 +8,3 @@ private api; | ||
private apiSecret; | ||
private httpsAgent?; | ||
protected abstract getPoolId(): string; | ||
@@ -13,2 +16,3 @@ protected abstract getPoolClientId(): string; | ||
apiSecret: string; | ||
httpsAgent?: https.Agent; | ||
}); | ||
@@ -15,0 +19,0 @@ protected init(): Promise<AxiosInstance>; |
@@ -13,2 +13,3 @@ "use strict"; | ||
this.apiSecret = params.apiSecret; | ||
this.httpsAgent = params.httpsAgent; | ||
} | ||
@@ -19,3 +20,3 @@ async init() { | ||
const poolData = { UserPoolId: this.getPoolId(), ClientId: this.getPoolClientId() }; | ||
this.api = api_1.createAuthenticatedApi(userPass, poolData, this.getApiUrl()); | ||
this.api = api_1.createAuthenticatedApi(userPass, poolData, this.getApiUrl(), this.httpsAgent); | ||
} | ||
@@ -22,0 +23,0 @@ return this.api; |
{ | ||
"name": "defender-base-client", | ||
"version": "1.37.0", | ||
"version": "1.38.0-rc.1", | ||
"description": "", | ||
@@ -34,3 +34,3 @@ "main": "./lib/index.js", | ||
}, | ||
"gitHead": "4b153fb8b16facd6713921faa4499af0b55c9e6e" | ||
"gitHead": "6c2082ed372e93ccad04347786cf233d3186c8d8" | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
120714
421
2