@n8n/client-oauth2
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -14,2 +14,3 @@ /// <reference types="node" /> | ||
headers?: Headers; | ||
ignoreSSLIssues?: boolean; | ||
} | ||
@@ -28,2 +29,3 @@ export interface ClientOAuth2Options { | ||
query?: qs.ParsedUrlQuery; | ||
ignoreSSLIssues?: boolean; | ||
} | ||
@@ -30,0 +32,0 @@ export declare class ClientOAuth2 { |
@@ -31,2 +31,3 @@ "use strict"; | ||
const qs = __importStar(require("querystring")); | ||
const https_1 = require("https"); | ||
const axios_1 = __importDefault(require("axios")); | ||
@@ -45,2 +46,3 @@ const utils_1 = require("./utils"); | ||
} | ||
const sslIgnoringAgent = new https_1.Agent({ rejectUnauthorized: false }); | ||
class ClientOAuth2 { | ||
@@ -72,3 +74,3 @@ constructor(options) { | ||
} | ||
const response = await axios_1.default.request({ | ||
const requestConfig = { | ||
url, | ||
@@ -80,3 +82,7 @@ method: options.method, | ||
validateStatus: (status) => status < 500, | ||
}); | ||
}; | ||
if (options.ignoreSSLIssues) { | ||
requestConfig.httpsAgent = sslIgnoringAgent; | ||
} | ||
const response = await axios_1.default.request(requestConfig); | ||
const body = this.parseResponseBody(response.data); | ||
@@ -83,0 +89,0 @@ const authErr = (0, utils_1.getAuthError)(body); |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import type { ClientOAuth2, ClientOAuth2Options } from './ClientOAuth2'; | ||
@@ -8,3 +7,3 @@ import type { ClientOAuth2Token } from './ClientOAuth2Token'; | ||
getUri(opts?: Partial<ClientOAuth2Options>): string; | ||
getToken(uri: string | URL, opts?: Partial<ClientOAuth2Options>): Promise<ClientOAuth2Token>; | ||
getToken(urlString: string, opts?: Partial<ClientOAuth2Options>): Promise<ClientOAuth2Token>; | ||
} |
@@ -54,7 +54,7 @@ "use strict"; | ||
} | ||
async getToken(uri, opts) { | ||
async getToken(urlString, opts) { | ||
var _a; | ||
const options = { ...this.client.options, ...opts }; | ||
(0, utils_1.expects)(options, 'clientId', 'accessTokenUri'); | ||
const url = uri instanceof URL ? uri : new URL(uri, constants_1.DEFAULT_URL_BASE); | ||
const url = new URL(urlString, constants_1.DEFAULT_URL_BASE); | ||
if (typeof options.redirectUri === 'string' && | ||
@@ -66,3 +66,3 @@ typeof url.pathname === 'string' && | ||
if (!((_a = url.search) === null || _a === void 0 ? void 0 : _a.substring(1))) { | ||
throw new TypeError(`Unable to process uri: ${uri.toString()}`); | ||
throw new TypeError(`Unable to process uri: ${urlString}`); | ||
} | ||
@@ -69,0 +69,0 @@ const data = typeof url.search === 'string' ? qs.parse(url.search.substring(1)) : url.search || {}; |
@@ -15,2 +15,2 @@ import type { ClientOAuth2Options, ClientOAuth2RequestObject } from './ClientOAuth2'; | ||
export declare function auth(username: string, password: string): string; | ||
export declare function getRequestOptions({ url, method, body, query, headers }: ClientOAuth2RequestObject, options: any): ClientOAuth2RequestObject; | ||
export declare function getRequestOptions({ url, method, body, query, headers }: ClientOAuth2RequestObject, options: ClientOAuth2Options): ClientOAuth2RequestObject; |
@@ -43,3 +43,4 @@ "use strict"; | ||
query: { ...query, ...options.query }, | ||
headers: { ...headers, ...options.headers }, | ||
headers: headers !== null && headers !== void 0 ? headers : {}, | ||
ignoreSSLIssues: options.ignoreSSLIssues, | ||
}; | ||
@@ -46,0 +47,0 @@ if (rOptions.headers.Authorization === '') { |
{ | ||
"name": "@n8n/client-oauth2", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "src/index.ts", |
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
Network access
Supply chain riskThis module accesses the network.
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
59678
494
1