@n8n/client-oauth2
Advanced tools
Comparing version 0.20.0 to 0.21.0
@@ -30,9 +30,9 @@ "use strict"; | ||
exports.ClientOAuth2 = void 0; | ||
const axios_1 = __importDefault(require("axios")); | ||
const https_1 = require("https"); | ||
const qs = __importStar(require("querystring")); | ||
const https_1 = require("https"); | ||
const axios_1 = __importDefault(require("axios")); | ||
const utils_1 = require("./utils"); | ||
const ClientOAuth2Token_1 = require("./ClientOAuth2Token"); | ||
const CodeFlow_1 = require("./CodeFlow"); | ||
const CredentialsFlow_1 = require("./CredentialsFlow"); | ||
const utils_1 = require("./utils"); | ||
class ResponseError extends Error { | ||
@@ -39,0 +39,0 @@ constructor(status, body, code = 'ESTATUS') { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ClientOAuth2Token = void 0; | ||
const constants_1 = require("./constants"); | ||
const utils_1 = require("./utils"); | ||
const constants_1 = require("./constants"); | ||
class ClientOAuth2Token { | ||
constructor(client, data) { | ||
var _a, _b; | ||
this.client = client; | ||
this.data = data; | ||
this.tokenType = (_b = (_a = data.token_type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : 'bearer'; | ||
this.tokenType = data.token_type?.toLowerCase() ?? 'bearer'; | ||
this.accessToken = data.access_token; | ||
@@ -18,7 +17,6 @@ this.refreshToken = data.refresh_token; | ||
sign(requestObject) { | ||
var _a; | ||
if (!this.accessToken) { | ||
throw new Error('Unable to sign without access token'); | ||
} | ||
requestObject.headers = (_a = requestObject.headers) !== null && _a !== void 0 ? _a : {}; | ||
requestObject.headers = requestObject.headers ?? {}; | ||
if (this.tokenType === 'bearer') { | ||
@@ -25,0 +23,0 @@ requestObject.headers.Authorization = 'Bearer ' + this.accessToken; |
@@ -35,3 +35,2 @@ "use strict"; | ||
getUri(opts) { | ||
var _a; | ||
const options = { ...this.client.options, ...opts }; | ||
@@ -46,3 +45,3 @@ (0, utils_1.expects)(options, 'clientId', 'authorizationUri'); | ||
state: options.state, | ||
...(options.scopes ? { scope: options.scopes.join((_a = options.scopesSeparator) !== null && _a !== void 0 ? _a : ' ') } : {}), | ||
...(options.scopes ? { scope: options.scopes.join(options.scopesSeparator ?? ' ') } : {}), | ||
}; | ||
@@ -57,3 +56,2 @@ for (const [key, value] of Object.entries(queryParams)) { | ||
async getToken(urlString, opts) { | ||
var _a; | ||
const options = { ...this.client.options, ...opts }; | ||
@@ -67,3 +65,3 @@ (0, utils_1.expects)(options, 'clientId', 'accessTokenUri'); | ||
} | ||
if (!((_a = url.search) === null || _a === void 0 ? void 0 : _a.substring(1))) { | ||
if (!url.search?.substring(1)) { | ||
throw new TypeError(`Unable to process uri: ${urlString}`); | ||
@@ -70,0 +68,0 @@ } |
@@ -11,3 +11,2 @@ "use strict"; | ||
async getToken() { | ||
var _a; | ||
const options = { ...this.client.options }; | ||
@@ -20,3 +19,3 @@ (0, utils_1.expects)(options, 'clientId', 'clientSecret', 'accessTokenUri'); | ||
if (options.scopes !== undefined) { | ||
body.scope = options.scopes.join((_a = options.scopesSeparator) !== null && _a !== void 0 ? _a : ' '); | ||
body.scope = options.scopes.join(options.scopesSeparator ?? ' '); | ||
} | ||
@@ -23,0 +22,0 @@ const clientId = options.clientId; |
@@ -25,4 +25,3 @@ "use strict"; | ||
function getAuthError(body) { | ||
var _a, _b; | ||
const message = (_b = (_a = constants_1.ERROR_RESPONSES[body.error]) !== null && _a !== void 0 ? _a : body.error_description) !== null && _b !== void 0 ? _b : body.error; | ||
const message = constants_1.ERROR_RESPONSES[body.error] ?? body.error_description ?? body.error; | ||
if (message) { | ||
@@ -45,3 +44,3 @@ return new AuthError(message, body); | ||
query: { ...query, ...options.query }, | ||
headers: headers !== null && headers !== void 0 ? headers : {}, | ||
headers: headers ?? {}, | ||
ignoreSSLIssues: options.ignoreSSLIssues, | ||
@@ -48,0 +47,0 @@ }; |
{ | ||
"name": "@n8n/client-oauth2", | ||
"version": "0.20.0", | ||
"version": "0.21.0", | ||
"main": "dist/index.js", | ||
@@ -13,3 +13,3 @@ "module": "src/index.ts", | ||
"dependencies": { | ||
"axios": "1.6.7" | ||
"axios": "1.7.4" | ||
}, | ||
@@ -31,3 +31,4 @@ "license": "SEE LICENSE IN LICENSE.md", | ||
"build": "tsc -p tsconfig.build.json", | ||
"format": "prettier --write . --ignore-path ../../../.prettierignore", | ||
"format": "biome format --write src test", | ||
"format:check": "biome ci src test", | ||
"lint": "eslint . --quiet", | ||
@@ -34,0 +35,0 @@ "lintfix": "eslint . --fix", |
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
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
66113
520
+ Addedaxios@1.7.4(transitive)
- Removedaxios@1.6.7(transitive)
Updatedaxios@1.7.4