Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@n8n/client-oauth2

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@n8n/client-oauth2 - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

12

dist/ClientOAuth2.d.ts

@@ -0,1 +1,3 @@

/// <reference types="node" />
import * as qs from 'querystring';
import type { ClientOAuth2TokenData } from './ClientOAuth2Token';

@@ -5,3 +7,3 @@ import { ClientOAuth2Token } from './ClientOAuth2Token';

import { CredentialsFlow } from './CredentialsFlow';
import type { Headers, Query } from './types';
import type { Headers } from './types';
export interface ClientOAuth2RequestObject {

@@ -11,3 +13,3 @@ url: string;

body?: Record<string, any>;
query?: Query;
query?: qs.ParsedUrlQuery;
headers?: Headers;

@@ -17,3 +19,3 @@ }

clientId: string;
clientSecret: string;
clientSecret?: string;
accessTokenUri: string;

@@ -23,7 +25,7 @@ authorizationUri?: string;

scopes?: string[];
scopesSeparator?: ',' | ' ';
authorizationGrants?: string[];
state?: string;
body?: Record<string, any>;
query?: Query;
headers?: Headers;
query?: qs.ParsedUrlQuery;
}

@@ -30,0 +32,0 @@ export declare class ClientOAuth2 {

@@ -39,2 +39,3 @@ "use strict";

const options = { ...this.client.options, ...opts };
(0, utils_1.expects)(options, 'clientSecret');
if (!this.refreshToken)

@@ -41,0 +42,0 @@ throw new Error('No refresh token');

@@ -7,4 +7,4 @@ /// <reference types="node" />

constructor(client: ClientOAuth2);
getUri(opts?: ClientOAuth2Options): string;
getUri(opts?: Partial<ClientOAuth2Options>): string;
getToken(uri: string | URL, opts?: Partial<ClientOAuth2Options>): Promise<ClientOAuth2Token>;
}

@@ -35,5 +35,8 @@ "use strict";

getUri(opts) {
var _a;
const options = { ...this.client.options, ...opts };
(0, utils_1.expects)(options, 'clientId', 'authorizationUri');
const query = {
const url = new URL(options.authorizationUri);
const queryParams = {
...options.query,
client_id: options.clientId,

@@ -43,11 +46,10 @@ redirect_uri: options.redirectUri,

state: options.state,
...(options.scopes ? { scope: options.scopes.join((_a = options.scopesSeparator) !== null && _a !== void 0 ? _a : ' ') } : {}),
};
if (options.scopes !== undefined) {
query.scope = (0, utils_1.sanitizeScope)(options.scopes);
for (const [key, value] of Object.entries(queryParams)) {
if (value !== null && value !== undefined) {
url.searchParams.append(key, value);
}
}
if (options.authorizationUri) {
const sep = options.authorizationUri.includes('?') ? '&' : '?';
return options.authorizationUri + sep + qs.stringify({ ...query, ...options.query });
}
throw new TypeError('Missing authorization uri, unable to get redirect uri');
return url.toString();
}

@@ -54,0 +56,0 @@ async getToken(uri, opts) {

@@ -11,2 +11,3 @@ "use strict";

async getToken(opts) {
var _a;
const options = { ...this.client.options, ...opts };

@@ -18,3 +19,3 @@ (0, utils_1.expects)(options, 'clientId', 'clientSecret', 'accessTokenUri');

if (options.scopes !== undefined) {
body.scope = (0, utils_1.sanitizeScope)(options.scopes);
body.scope = options.scopes.join((_a = options.scopesSeparator) !== null && _a !== void 0 ? _a : ' ');
}

@@ -21,0 +22,0 @@ const requestOptions = (0, utils_1.getRequestOptions)({

export type Headers = Record<string, string | string[]>;
export type Query = Record<string, string | string[]>;

@@ -1,3 +0,5 @@

import type { ClientOAuth2RequestObject } from './ClientOAuth2';
export declare function expects(obj: any, ...args: any[]): void;
import type { ClientOAuth2Options, ClientOAuth2RequestObject } from './ClientOAuth2';
export declare function expects<Keys extends keyof ClientOAuth2Options>(obj: ClientOAuth2Options, ...keys: Keys[]): asserts obj is ClientOAuth2Options & {
[K in Keys]: NonNullable<ClientOAuth2Options[K]>;
};
export declare class AuthError extends Error {

@@ -12,4 +14,3 @@ readonly body: any;

}): Error | undefined;
export declare function sanitizeScope(scopes: string[] | string): string;
export declare function auth(username: string, password: string): string;
export declare function getRequestOptions({ url, method, body, query, headers }: ClientOAuth2RequestObject, options: any): ClientOAuth2RequestObject;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRequestOptions = exports.auth = exports.sanitizeScope = exports.getAuthError = exports.AuthError = exports.expects = void 0;
exports.getRequestOptions = exports.auth = exports.getAuthError = exports.AuthError = exports.expects = void 0;
const constants_1 = require("./constants");
function expects(obj, ...args) {
for (let i = 1; i < args.length; i++) {
const prop = args[i];
if (obj[prop] === null) {
throw new TypeError('Expected "' + prop + '" to exist');
function expects(obj, ...keys) {
for (const key of keys) {
if (obj[key] === null || obj[key] === undefined) {
throw new TypeError('Expected "' + key + '" to exist');
}

@@ -34,6 +33,2 @@ }

}
function sanitizeScope(scopes) {
return Array.isArray(scopes) ? scopes.join(' ') : toString(scopes);
}
exports.sanitizeScope = sanitizeScope;
function auth(username, password) {

@@ -40,0 +35,0 @@ return 'Basic ' + Buffer.from(toString(username) + ':' + toString(password)).toString('base64');

{
"name": "@n8n/client-oauth2",
"version": "0.2.0",
"version": "0.3.0",
"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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc