@n8n/client-oauth2 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,85 @@
1
+ # License
2
+
3
+ Portions of this software are licensed as follows:
4
+
5
+ - Content of branches other than the main branch (i.e. "master") are not licensed.
6
+ - All source code files that contain ".ee." in their filename are licensed under the
7
+ "n8n Enterprise License" defined in "LICENSE_EE.md".
8
+ - All third party components incorporated into the n8n Software are licensed under the original license
9
+ provided by the owner of the applicable component.
10
+ - Content outside of the above mentioned files or restrictions is available under the "Sustainable Use
11
+ License" as defined below.
12
+
13
+ ## Sustainable Use License
14
+
15
+ Version 1.0
16
+
17
+ ### Acceptance
18
+
19
+ By using the software, you agree to all of the terms and conditions below.
20
+
21
+ ### Copyright License
22
+
23
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
24
+ to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
25
+ to the limitations below.
26
+
27
+ ### Limitations
28
+
29
+ You may use or modify the software only for your own internal business purposes or for non-commercial or
30
+ personal use. You may distribute the software or provide it to others only if you do so free of charge for
31
+ non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
32
+ the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
33
+
34
+ ### Patents
35
+
36
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
37
+ license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
38
+ subject to the limitations and conditions in this license. This license does not cover any patent claims that
39
+ you cause to be infringed by modifications or additions to the software. If you or your company make any
40
+ written claim that the software infringes or contributes to infringement of any patent, your patent license
41
+ for the software granted under these terms ends immediately. If your company makes such a claim, your patent
42
+ license ends immediately for work on behalf of your company.
43
+
44
+ ### Notices
45
+
46
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
47
+ terms. If you modify the software, you must include in any modified copies of the software a prominent notice
48
+ stating that you have modified the software.
49
+
50
+ ### No Other Rights
51
+
52
+ These terms do not imply any licenses other than those expressly granted in these terms.
53
+
54
+ ### Termination
55
+
56
+ If you use the software in violation of these terms, such use is not licensed, and your license will
57
+ automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
58
+ violation of this license no later than 30 days after you receive that notice, your license will be reinstated
59
+ retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
60
+ terms will cause your license to terminate automatically and permanently.
61
+
62
+ ### No Liability
63
+
64
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
65
+ not be liable to you for any damages arising out of these terms or the use or nature of the software, under
66
+ any kind of legal claim.
67
+
68
+ ### Definitions
69
+
70
+ The “licensor” is the entity offering these terms.
71
+
72
+ The “software” is the software the licensor makes available under these terms, including any portion of it.
73
+
74
+ “You” refers to the individual or entity agreeing to these terms.
75
+
76
+ “Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
77
+ all organizations that have control over, are under the control of, or are under common control with that
78
+ organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
79
+ management and policies by vote, contract, or otherwise. Control can be direct or indirect.
80
+
81
+ “Your license” is the license granted to you for the software under these terms.
82
+
83
+ “Use” means anything you do with the software requiring your license.
84
+
85
+ “Trademark” means trademarks, service marks, and similar rights.
@@ -0,0 +1,34 @@
1
+ import type { ClientOAuth2TokenData } from './ClientOAuth2Token';
2
+ import { ClientOAuth2Token } from './ClientOAuth2Token';
3
+ import { CodeFlow } from './CodeFlow';
4
+ import { CredentialsFlow } from './CredentialsFlow';
5
+ import type { Headers, Query } from './types';
6
+ export interface ClientOAuth2RequestObject {
7
+ url: string;
8
+ method: 'DELETE' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT';
9
+ body?: Record<string, any>;
10
+ query?: Query;
11
+ headers?: Headers;
12
+ }
13
+ export interface ClientOAuth2Options {
14
+ clientId: string;
15
+ clientSecret: string;
16
+ accessTokenUri: string;
17
+ authorizationUri?: string;
18
+ redirectUri?: string;
19
+ scopes?: string[];
20
+ authorizationGrants?: string[];
21
+ state?: string;
22
+ body?: Record<string, any>;
23
+ query?: Query;
24
+ headers?: Headers;
25
+ }
26
+ export declare class ClientOAuth2 {
27
+ readonly options: ClientOAuth2Options;
28
+ code: CodeFlow;
29
+ credentials: CredentialsFlow;
30
+ constructor(options: ClientOAuth2Options);
31
+ createToken(data: ClientOAuth2TokenData, type?: string): ClientOAuth2Token;
32
+ private parseResponseBody;
33
+ request<T extends object>(options: ClientOAuth2RequestObject): Promise<T>;
34
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ClientOAuth2 = void 0;
30
+ const qs = __importStar(require("querystring"));
31
+ const axios_1 = __importDefault(require("axios"));
32
+ const utils_1 = require("./utils");
33
+ const ClientOAuth2Token_1 = require("./ClientOAuth2Token");
34
+ const CodeFlow_1 = require("./CodeFlow");
35
+ const CredentialsFlow_1 = require("./CredentialsFlow");
36
+ class ResponseError extends Error {
37
+ constructor(status, body, code = 'ESTATUS') {
38
+ super(`HTTP status ${status}`);
39
+ this.status = status;
40
+ this.body = body;
41
+ this.code = code;
42
+ }
43
+ }
44
+ class ClientOAuth2 {
45
+ constructor(options) {
46
+ this.options = options;
47
+ this.code = new CodeFlow_1.CodeFlow(this);
48
+ this.credentials = new CredentialsFlow_1.CredentialsFlow(this);
49
+ }
50
+ createToken(data, type) {
51
+ return new ClientOAuth2Token_1.ClientOAuth2Token(this, {
52
+ ...data,
53
+ ...(typeof type === 'string' ? { token_type: type } : type),
54
+ });
55
+ }
56
+ parseResponseBody(body) {
57
+ try {
58
+ return JSON.parse(body);
59
+ }
60
+ catch (e) {
61
+ return qs.parse(body);
62
+ }
63
+ }
64
+ async request(options) {
65
+ let url = options.url;
66
+ const query = qs.stringify(options.query);
67
+ if (query) {
68
+ url += (url.indexOf('?') === -1 ? '?' : '&') + query;
69
+ }
70
+ const response = await axios_1.default.request({
71
+ url,
72
+ method: options.method,
73
+ data: qs.stringify(options.body),
74
+ headers: options.headers,
75
+ transformResponse: (res) => res,
76
+ });
77
+ const body = this.parseResponseBody(response.data);
78
+ const authErr = (0, utils_1.getAuthError)(body);
79
+ if (authErr)
80
+ throw authErr;
81
+ if (response.status < 200 || response.status >= 399)
82
+ throw new ResponseError(response.status, response.data);
83
+ return body;
84
+ }
85
+ }
86
+ exports.ClientOAuth2 = ClientOAuth2;
87
+ //# sourceMappingURL=ClientOAuth2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClientOAuth2.js","sourceRoot":"","sources":["../src/ClientOAuth2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,gDAAkC;AAClC,kDAA0B;AAC1B,mCAAuC;AAEvC,2DAAwD;AACxD,yCAAsC;AACtC,uDAAoD;AAyBpD,MAAM,aAA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ACrD;QAED,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,OAAO,CAAC;YACpC,GAAG;YACH,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;YAChC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;SAC/B,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;QAItD,MAAM,OAAO,GAAG,IAAA,oBAAY,EAAC,IAAI,CAAC,CAAC;QACnC,IAAI,OAAO;YAAE,MAAM,OAAO,CAAC;QAE3B,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG;YAClD,MAAM,IAAI,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AA/DD,oCA+DC"}
@@ -0,0 +1,20 @@
1
+ import type { ClientOAuth2, ClientOAuth2Options, ClientOAuth2RequestObject } from './ClientOAuth2';
2
+ export interface ClientOAuth2TokenData extends Record<string, string | undefined> {
3
+ token_type?: string | undefined;
4
+ access_token: string;
5
+ refresh_token: string;
6
+ expires_in?: string;
7
+ scope?: string | undefined;
8
+ }
9
+ export declare class ClientOAuth2Token {
10
+ readonly client: ClientOAuth2;
11
+ readonly data: ClientOAuth2TokenData;
12
+ readonly tokenType?: string;
13
+ readonly accessToken: string;
14
+ readonly refreshToken: string;
15
+ private expires;
16
+ constructor(client: ClientOAuth2, data: ClientOAuth2TokenData);
17
+ sign(requestObject: ClientOAuth2RequestObject): ClientOAuth2RequestObject;
18
+ refresh(opts?: ClientOAuth2Options): Promise<ClientOAuth2Token>;
19
+ expired(): boolean;
20
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientOAuth2Token = void 0;
4
+ const utils_1 = require("./utils");
5
+ const constants_1 = require("./constants");
6
+ class ClientOAuth2Token {
7
+ constructor(client, data) {
8
+ var _a, _b;
9
+ this.client = client;
10
+ this.data = data;
11
+ this.tokenType = (_b = (_a = data.token_type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : 'bearer';
12
+ this.accessToken = data.access_token;
13
+ this.refreshToken = data.refresh_token;
14
+ this.expires = new Date();
15
+ this.expires.setSeconds(this.expires.getSeconds() + Number(data.expires_in));
16
+ }
17
+ sign(requestObject) {
18
+ var _a;
19
+ if (!this.accessToken) {
20
+ throw new Error('Unable to sign without access token');
21
+ }
22
+ requestObject.headers = (_a = requestObject.headers) !== null && _a !== void 0 ? _a : {};
23
+ if (this.tokenType === 'bearer') {
24
+ requestObject.headers.Authorization = 'Bearer ' + this.accessToken;
25
+ }
26
+ else {
27
+ const parts = requestObject.url.split('#');
28
+ const token = 'access_token=' + this.accessToken;
29
+ const url = parts[0].replace(/[?&]access_token=[^&#]/, '');
30
+ const fragment = parts[1] ? '#' + parts[1] : '';
31
+ requestObject.url = url + (url.indexOf('?') > -1 ? '&' : '?') + token + fragment;
32
+ requestObject.headers.Pragma = 'no-store';
33
+ requestObject.headers['Cache-Control'] = 'no-store';
34
+ }
35
+ return requestObject;
36
+ }
37
+ async refresh(opts) {
38
+ const options = { ...this.client.options, ...opts };
39
+ if (!this.refreshToken)
40
+ throw new Error('No refresh token');
41
+ const requestOptions = (0, utils_1.getRequestOptions)({
42
+ url: options.accessTokenUri,
43
+ method: 'POST',
44
+ headers: {
45
+ ...constants_1.DEFAULT_HEADERS,
46
+ Authorization: (0, utils_1.auth)(options.clientId, options.clientSecret),
47
+ },
48
+ body: {
49
+ refresh_token: this.refreshToken,
50
+ grant_type: 'refresh_token',
51
+ },
52
+ }, options);
53
+ const responseData = await this.client.request(requestOptions);
54
+ return this.client.createToken({ ...this.data, ...responseData });
55
+ }
56
+ expired() {
57
+ return Date.now() > this.expires.getTime();
58
+ }
59
+ }
60
+ exports.ClientOAuth2Token = ClientOAuth2Token;
61
+ //# sourceMappingURL=ClientOAuth2Token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClientOAuth2Token.js","sourceRoot":"","sources":["../src/ClientOAuth2Token.ts"],"names":[],"mappings":";;;AAIA,mCAAkD;AAClD,2CAA8C;AAY9C,MAAa,iBAAiB;IAS7B,YAAqB,MAAoB,EAAW,IAA2B;;QAA1D,WAAM,GAAN,MAAM,CAAc;QAAW,SAAI,GAAJ,IAAI,CAAuB;QAC9E,IAAI,CAAC,SAAS,GAAG,MAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,WAAW,EAAE,mCAAI,QAAQ,CAAC;QAC5D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC;QAEvC,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9E,CAAC;IAKD,IAAI,CAAC,aAAwC;;QAC5C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;SACvD;QAED,aAAa,CAAC,OAAO,GAAG,MAAA,aAAa,CAAC,OAAO,mCAAI,EAAE,CAAC;QAEpD,IAAI,IAAI,CAAC,SAAS,KAAK,QAAQ,EAAE;YAChC,aAAa,CAAC,OAAO,CAAC,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC;SACnE;aAAM;YACN,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,GAA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AAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAwB,cAAc,CAAC,CAAC;QACtF,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;IACnE,CAAC;IAKD,OAAO;QACN,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5C,CAAC;CACD;AAlFD,8CAkFC"}
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ import type { ClientOAuth2, ClientOAuth2Options } from './ClientOAuth2';
3
+ import type { ClientOAuth2Token } from './ClientOAuth2Token';
4
+ export declare class CodeFlow {
5
+ private client;
6
+ constructor(client: ClientOAuth2);
7
+ getUri(opts?: ClientOAuth2Options): string;
8
+ getToken(uri: string | URL, opts?: Partial<ClientOAuth2Options>): Promise<ClientOAuth2Token>;
9
+ }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.CodeFlow = void 0;
27
+ const qs = __importStar(require("querystring"));
28
+ const constants_1 = require("./constants");
29
+ const utils_1 = require("./utils");
30
+ class CodeFlow {
31
+ constructor(client) {
32
+ this.client = client;
33
+ }
34
+ getUri(opts) {
35
+ const options = { ...this.client.options, ...opts };
36
+ (0, utils_1.expects)(options, 'clientId', 'authorizationUri');
37
+ const query = {
38
+ client_id: options.clientId,
39
+ redirect_uri: options.redirectUri,
40
+ response_type: 'code',
41
+ state: options.state,
42
+ };
43
+ if (options.scopes !== undefined) {
44
+ query.scope = (0, utils_1.sanitizeScope)(options.scopes);
45
+ }
46
+ if (options.authorizationUri) {
47
+ const sep = options.authorizationUri.includes('?') ? '&' : '?';
48
+ return options.authorizationUri + sep + qs.stringify({ ...query, ...options.query });
49
+ }
50
+ throw new TypeError('Missing authorization uri, unable to get redirect uri');
51
+ }
52
+ async getToken(uri, opts) {
53
+ var _a;
54
+ const options = { ...this.client.options, ...opts };
55
+ (0, utils_1.expects)(options, 'clientId', 'accessTokenUri');
56
+ const url = uri instanceof URL ? uri : new URL(uri, constants_1.DEFAULT_URL_BASE);
57
+ if (typeof options.redirectUri === 'string' &&
58
+ typeof url.pathname === 'string' &&
59
+ url.pathname !== new URL(options.redirectUri, constants_1.DEFAULT_URL_BASE).pathname) {
60
+ throw new TypeError('Redirected path should match configured path, but got: ' + url.pathname);
61
+ }
62
+ if (!((_a = url.search) === null || _a === void 0 ? void 0 : _a.substring(1))) {
63
+ throw new TypeError(`Unable to process uri: ${uri.toString()}`);
64
+ }
65
+ const data = typeof url.search === 'string' ? qs.parse(url.search.substring(1)) : url.search || {};
66
+ const error = (0, utils_1.getAuthError)(data);
67
+ if (error)
68
+ throw error;
69
+ if (options.state && data.state !== options.state) {
70
+ throw new TypeError(`Invalid state: ${data.state}`);
71
+ }
72
+ if (!data.code) {
73
+ throw new TypeError('Missing code, unable to request token');
74
+ }
75
+ const headers = { ...constants_1.DEFAULT_HEADERS };
76
+ const body = {
77
+ code: data.code,
78
+ grant_type: 'authorization_code',
79
+ redirect_uri: options.redirectUri,
80
+ };
81
+ if (options.clientSecret) {
82
+ headers.Authorization = (0, utils_1.auth)(options.clientId, options.clientSecret);
83
+ }
84
+ else {
85
+ body.client_id = options.clientId;
86
+ }
87
+ const requestOptions = (0, utils_1.getRequestOptions)({
88
+ url: options.accessTokenUri,
89
+ method: 'POST',
90
+ headers,
91
+ body,
92
+ }, options);
93
+ const responseData = await this.client.request(requestOptions);
94
+ return this.client.createToken(responseData);
95
+ }
96
+ }
97
+ exports.CodeFlow = CodeFlow;
98
+ //# sourceMappingURL=CodeFlow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeFlow.js","sourceRoot":"","sources":["../src/CodeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAGlC,2CAAgE;AAChE,mCAAwF;AAcxF,MAAa,QAAQ;IACpB,YAAoB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAK5C,MAAM,CAAC,IAA0B;QAChC,MAAM,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;QAGpD,IAAA,eAAO,EAAC,OAAO,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAC;QAEjD,MAAM,KAAK,GAAuC;YACjD,SAAS,EAAE,OAAO,CAAC,QAAQ;YAC3B,YAAY,EAAE,OAAO,CAAC,WAAW;YACjC,aAAa,EAAE,MAAM;YACrB,KAAK,EAAE,OAAO,CAAC,KAAK;SACpB,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;YACjC,KAAK,CAAC,KAAK,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC5C;QAED,IAAI,OAA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;IAC9C,CAAC;CACD;AAtGD,4BAsGC"}
@@ -0,0 +1,7 @@
1
+ import type { ClientOAuth2, ClientOAuth2Options } from './ClientOAuth2';
2
+ import type { ClientOAuth2Token } from './ClientOAuth2Token';
3
+ export declare class CredentialsFlow {
4
+ private client;
5
+ constructor(client: ClientOAuth2);
6
+ getToken(opts?: Partial<ClientOAuth2Options>): Promise<ClientOAuth2Token>;
7
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CredentialsFlow = void 0;
4
+ const constants_1 = require("./constants");
5
+ const utils_1 = require("./utils");
6
+ class CredentialsFlow {
7
+ constructor(client) {
8
+ this.client = client;
9
+ }
10
+ async getToken(opts) {
11
+ const options = { ...this.client.options, ...opts };
12
+ (0, utils_1.expects)(options, 'clientId', 'clientSecret', 'accessTokenUri');
13
+ const body = {
14
+ grant_type: 'client_credentials',
15
+ };
16
+ if (options.scopes !== undefined) {
17
+ body.scope = (0, utils_1.sanitizeScope)(options.scopes);
18
+ }
19
+ const requestOptions = (0, utils_1.getRequestOptions)({
20
+ url: options.accessTokenUri,
21
+ method: 'POST',
22
+ headers: {
23
+ ...constants_1.DEFAULT_HEADERS,
24
+ Authorization: (0, utils_1.auth)(options.clientId, options.clientSecret),
25
+ },
26
+ body,
27
+ }, options);
28
+ const responseData = await this.client.request(requestOptions);
29
+ return this.client.createToken(responseData);
30
+ }
31
+ }
32
+ exports.CredentialsFlow = CredentialsFlow;
33
+ //# sourceMappingURL=CredentialsFlow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CredentialsFlow.js","sourceRoot":"","sources":["../src/CredentialsFlow.ts"],"names":[],"mappings":";;;AAEA,2CAA8C;AAC9C,mCAA0E;AAY1E,MAAa,eAAe;IAC3B,YAAoB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAK5C,KAAK,CAAC,QAAQ,CAAC,IAAmC;QACjD,MAAM,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;QAEpD,IAAA,eAAO,EAAC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;QAE/D,MAAM,IAAI,GAAwB;YACjC,UAAU,EAAE,oBAAoB;SAChC,CAAC;QAEF,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;YACjC,IAAI,CAAC,KAAK,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAC3C;QAED,MAAM,cAAc,GAAG,IAAA,yBAAiB,EACvC;YACC,GAAG,EAAE,OAAO,CAAC,cAAc;YAC3B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACR,GAAG,2BAAe;gBAElB,aAAa,EAAE,IAAA,YAAI,EAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC;aAC3D;YACD,IAAI;SACJ,EACD,OAAO,CACP,CAAC;QAEF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAwB,cAAc,CAAC,CAAC;QACtF,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;CACD;AApCD,0CAoCC"}
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../../node_modules/.pnpm/typescript@5.0.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../node_modules/jest-expect-message/types/index.d.ts","../../../../node_modules/.pnpm/axios@0.21.4_debug@4.3.2/node_modules/axios/index.d.ts","../src/types.ts","../src/constants.ts","../src/utils.ts","../src/ClientOAuth2Token.ts","../src/CodeFlow.ts","../src/CredentialsFlow.ts","../src/ClientOAuth2.ts","../src/index.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/assert.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/globals.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/buffer.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/child_process.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/cluster.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/console.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/constants.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/crypto.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/dgram.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/diagnostics_channel.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/dns.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/domain.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/events.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/fs.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/http.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/http2.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/https.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/inspector.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/module.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/net.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/os.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/path.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/process.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/punycode.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/querystring.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/readline.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/repl.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/stream.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/stream/consumers.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/stream/web.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/test.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/timers.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/tls.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/trace_events.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/tty.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/url.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/util.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/v8.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/vm.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/wasi.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/zlib.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/globals.global.d.ts","../../../../node_modules/.pnpm/@types+node@16.18.12/node_modules/@types/node/index.d.ts"],"fileInfos":[{"version":"6a6b471e7e43e15ef6f8fe617a22ce4ecb0e34efa6c3dfcfe7cebd392bcca9d2","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4",{"version":"f296963760430fb65b4e5d91f0ed770a91c6e77455bacf8fa23a1501654ede0e","affectsGlobalScope":true},{"version":"5114a95689b63f96b957e00216bc04baf9e1a1782aa4d8ee7e5e9acbf768e301","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"b7e9f95a7387e3f66be0ed6db43600c49cec33a3900437ce2fd350d9b7cb16f2","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"f5c92f2c27b06c1a41b88f6db8299205aee52c2a2943f7ed29bd585977f254e8","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"406a5a771d97867cba07e7fbd3cd1fb2dd1004558b973733205737e9dd7ed929","affectsGlobalScope":true},"3154a026075044aa102298fe9e6a7a14aaa26a06270680c7478a1765af8ffb09","1034da96b9276076c90a90b74b980817d84fce3bcbd7061d94503df5c6b99def",{"version":"a3756929e84c4919c8cad96d784d6b331674a6c17856a9880fd619d35471349e","signature":"242433744c6e75d737eb8d39f719a6aa802067b73c448485c7a0207ca6e24303"},{"version":"0fdd3f130f21c8849afc7d3c5203295424daf33fd490c12e6494c886e175f06f","signature":"909b8da26dd0a387ce1c7dd5efaa40fdabc81566b9c1f9eec33bd6cc8d90d0c2"},{"version":"6f8384c7345fd094e6cabca4a1543d308ca481e8818c6cf43b7f5544ed67e87e","signature":"7b9a2d82b6bb17e537b6cca0ce7fad731f26f0c24e3a812b90f4f79f5ff372d4"},{"version":"b99c60f8e524707e0c73fb825f70f8750da7940d9160a37725350bce3064e0b8","signature":"1629da4a295d13ca0425cd508a28e313e4637b4ce07558d1459cee1c3ebd643e"},{"version":"f37d50ce774ea66b116ff9164fbbb242c4a40d533fa1188b6dd5628806547c89","signature":"55fa835520013137749f3cf1cbafc538cec75e146acbcc96c9c8e933aad11a36"},{"version":"67d3a0ced08a45dba3cd6321d2cf2e0bb4bb32c64c17539606ff63c1ddf1dd7a","signature":"a060a37a30b860ee90de348ec147648b1253f9f5687c8974d036a6dec515ddb7"},"d75f9dd24e94cd75e68f1ea39adbf393c81e84a212f3238ef373804ad164b8bd","4911d4c3a7f7c11bad0e2cec329a19a385d10ea83b0b69c76e032359e388f624","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"4f6463a60e5754bbc4a864b2aaf8fecb7706b96a21b88f27b534589b801978b6","affectsGlobalScope":true},"56d13f223ab40f71840795f5bef2552a397a70666ee60878222407f3893fb8d0",{"version":"4ffef5c4698e94e49dcf150e3270bad2b24a2aeab48b24acbe7c1366edff377d","affectsGlobalScope":true},"2534e46a52653b55dfb5a41ce427ec430c4afbaaf3bfcb1ae09b185c5d6bf169","afc6e96061af46bcff47246158caee7e056f5288783f2d83d6858cd25be1c565",{"version":"34f5bcac12b36d70304b73de5f5aab3bb91bd9919f984be80579ebcad03a624e","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","3f2478baf49cf27aa1335ba5299e2394131284e9d50a3845e3f95e52664ff518","f50c975ab7b50e25a69e3d8a3773894125b44e9698924105f23b812bf7488baf","8bd106053ee0345dde7f626ed1f6100a89fb85f13ea65352627cf78c5f30c553","76650408392bf49a8fbf3e2b6b302712a92d76af77b06e2da1cc8077359c4409","0af3121e68297b2247dd331c0d24dba599e50736a7517a5622d5591aae4a3122","06ccebc2c2db57d6bdbca63b71c4ae5e6ddc42d972fd8f122d4c1a28aa111b25",{"version":"81e8508d1e82278f5d3fee936f267e00c308af36219bfcee2631f9513c9c4017","affectsGlobalScope":true},"413a4be7f94f631235bbc83dad36c4d15e5a2ff02bca1efdbd03636d6454631b","20c468256fd68d3ef1fa53526e76d51d6aa91711e84d72c0343589b99238287e","4198acced75d48a039c078734c4efca7788ff8c78609c270a2b63ec20e3e1676","8d4c16a26d59e3ce49741a7d4a6e8206b884e226cf308667c7778a0b2c0fee7f","288dd0c774a5c6e3964084c7a2bc8cc6b746d70f44a9892d028d04f915cf7ebc","d61c7c41eb1960b1285e242fd102c162b65c0522985b839fadda59874308a170",{"version":"e630e5528e899219ae319e83bef54bf3bcb91b01d76861ecf881e8e614b167f0","affectsGlobalScope":true},"1805e0e4d1ed00f6361db25dff6887c7fa9b5b39f32599a34e8551da7daaa9c2","abc1c425b2ad6720433f40f1877abfa4223f0f3dd486c9c28c492179ca183cb6","fb0989383c6109f20281b3d31265293daefdd76d0d30551782c1654e93704f48","a4210a84a82b3e7a8cec5b2f3616e46d523f4f10cc1576d8f2fb89d0987b341e",{"version":"8207e7e6db9aa5fc7e61c8f17ba74cf9c115d26f51f91ee93f790815a7ea9dfb","affectsGlobalScope":true},"9f1069b9e2c051737b1f9b4f1baf50e4a63385a6a89c32235549ae87fc3d5492","22d48bfb37261136423ac687f1fa7bd4dda3083f767416d409a8260cf92bc8fc","29c2706fa0cc49a2bd90c83234da33d08bb9554ecec675e91c1f85087f5a5324","0acbf26bf958f9e80c1ffa587b74749d2697b75b484062d36e103c137c562bc3","95518ff86843e226b62a800f679f6968ad8dac8ccbe30fbfe63de3afb13761a2","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","698ab660b477b9c2cd5ccbd99e7e7df8b4a6134c1f5711fa615ed7aab51cb7f7","33eee034727baf564056b4ea719075c23d3b4767d0b5f9c6933b81f3d77774d2","c33a6ea7147af60d8e98f1ac127047f4b0d4e2ce28b8f08ff3de07ca7cc00637","a4471d2bdba495b2a6a30b8765d5e0282fa7009d88345a9528f73c37869d3b93",{"version":"aee7013623e7632fba449d4df1da92925b27d9b816cb05546044dbfe54c88ef4","affectsGlobalScope":true},"e10177274a35a9d07c825615340b2fcde2f610f53f3fb40269fd196b4288dda6","c9d70d3d7191a66a81cb554557f8ed1cf736ea8397c44a864fe52689de18865a","998a3de5237518c0b3ac00a11b3b4417affb008aa20aedee52f3fdae3cb86151","ad41008ffe077206e1811fc873f4d9005b5fd7f6ab52bb6118fef600815a5cb4",{"version":"1aad825534c73852a1f3275e527d729a2c0640f539198fdfdfeb83b839851910","affectsGlobalScope":true},"badae0df9a8016ac36994b0a0e7b82ba6aaa3528e175a8c3cb161e4683eec03e","c3db860bcaaaeb3bbc23f353bbda1f8ab82756c8d5e973bebb3953cb09ea68f2","235a53595bd20b0b0eeb1a29cb2887c67c48375e92f03749b2488fbd46d0b1a0","bc09393cd4cd13f69cf1366d4236fbae5359bb550f0de4e15767e9a91d63dfb1","9c266243b01545e11d2733a55ad02b4c00ecdbda99c561cd1674f96e89cdc958","c71155c05fc76ff948a4759abc1cb9feec036509f500174bc18dad4c7827a60c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"88003d9ab15507806f41b120be6d407c1afe566c2f6689ebe3a034dd5ec0c8dc"],"root":[45,[47,54]],"options":{"composite":true,"declaration":true,"esModuleInterop":true,"module":1,"noImplicitAny":true,"noImplicitReturns":true,"noUnusedLocals":true,"outDir":"./","preserveConstEnums":true,"removeComments":true,"rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"strictNullChecks":true,"target":6,"tsBuildInfoFile":"./build.tsbuildinfo","useUnknownInCatchVariables":true},"fileIdsList":[[55,99],[58,99],[59,64,90,99],[60,70,71,78,87,98,99],[60,61,70,78,99],[62,99],[63,64,71,79,99],[64,87,95,99],[65,67,70,78,99],[66,99],[67,68,99],[69,70,99],[70,99],[70,71,72,87,98,99],[70,71,72,87,99],[99],[73,78,87,98,99],[70,71,73,74,78,87,95,98,99],[73,75,87,95,98,99],[55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105],[70,76,99],[77,98,99],[67,70,78,87,99],[79,99],[80,99],[58,81,99],[82,97,99,103],[83,99],[84,99],[70,85,99],[85,86,99,101],[59,70,87,88,89,99],[59,87,89,99],[87,88,99],[90,99],[91,99],[70,93,94,99],[93,94,99],[64,78,95,99],[96,99],[78,97,99],[59,73,84,98,99],[64,99],[87,99,100],[99,101],[99,102],[59,64,70,72,81,87,98,99,101,103],[87,99,104],[46,47,49,50,51,52,84,99],[48,49,53,99],[48,49,50,53,84,99],[48,49,50,53,99],[47,99],[50,53,99],[48,53,99],[47,50,51,52],[53],[50,53],[47]],"referencedMap":[[55,1],[56,1],[58,2],[59,3],[60,4],[61,5],[62,6],[63,7],[64,8],[65,9],[66,10],[67,11],[68,11],[69,12],[70,13],[71,14],[72,15],[57,16],[105,16],[73,17],[74,18],[75,19],[106,20],[76,21],[77,22],[78,23],[79,24],[80,25],[81,26],[82,27],[83,28],[84,29],[85,30],[86,31],[87,32],[89,33],[88,34],[90,35],[91,36],[92,16],[93,37],[94,38],[95,39],[96,40],[97,41],[98,42],[99,43],[100,44],[101,45],[102,46],[103,47],[104,48],[46,16],[43,16],[44,16],[9,16],[8,16],[2,16],[10,16],[11,16],[12,16],[13,16],[14,16],[15,16],[16,16],[17,16],[3,16],[4,16],[21,16],[18,16],[19,16],[20,16],[22,16],[23,16],[24,16],[5,16],[25,16],[26,16],[27,16],[28,16],[6,16],[32,16],[29,16],[30,16],[31,16],[33,16],[7,16],[34,16],[39,16],[40,16],[35,16],[36,16],[37,16],[38,16],[41,16],[1,16],[42,16],[45,16],[53,49],[50,50],[51,51],[52,52],[48,53],[54,54],[47,16],[49,55]],"exportedModulesMap":[[55,1],[56,1],[58,2],[59,3],[60,4],[61,5],[62,6],[63,7],[64,8],[65,9],[66,10],[67,11],[68,11],[69,12],[70,13],[71,14],[72,15],[57,16],[105,16],[73,17],[74,18],[75,19],[106,20],[76,21],[77,22],[78,23],[79,24],[80,25],[81,26],[82,27],[83,28],[84,29],[85,30],[86,31],[87,32],[89,33],[88,34],[90,35],[91,36],[92,16],[93,37],[94,38],[95,39],[96,40],[97,41],[98,42],[99,43],[100,44],[101,45],[102,46],[103,47],[104,48],[46,16],[43,16],[44,16],[9,16],[8,16],[2,16],[10,16],[11,16],[12,16],[13,16],[14,16],[15,16],[16,16],[17,16],[3,16],[4,16],[21,16],[18,16],[19,16],[20,16],[22,16],[23,16],[24,16],[5,16],[25,16],[26,16],[27,16],[28,16],[6,16],[32,16],[29,16],[30,16],[31,16],[33,16],[7,16],[34,16],[39,16],[40,16],[35,16],[36,16],[37,16],[38,16],[41,16],[1,16],[42,16],[45,16],[53,56],[50,57],[51,58],[52,58],[48,59],[54,54],[47,16],[49,57]],"semanticDiagnosticsPerFile":[55,56,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,57,105,73,74,75,106,76,77,78,79,80,81,82,83,84,85,86,87,89,88,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,46,43,44,9,8,2,10,11,12,13,14,15,16,17,3,4,21,18,19,20,22,23,24,5,25,26,27,28,6,32,29,30,31,33,7,34,39,40,35,36,37,38,41,1,42,45,53,50,51,52,48,54,47,49],"latestChangedDtsFile":"./index.d.ts"},"version":"5.0.3"}
@@ -0,0 +1,4 @@
1
+ import type { Headers } from './types';
2
+ export declare const DEFAULT_URL_BASE = "https://example.org/";
3
+ export declare const DEFAULT_HEADERS: Headers;
4
+ export declare const ERROR_RESPONSES: Record<string, string>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERROR_RESPONSES = exports.DEFAULT_HEADERS = exports.DEFAULT_URL_BASE = void 0;
4
+ exports.DEFAULT_URL_BASE = 'https://example.org/';
5
+ exports.DEFAULT_HEADERS = {
6
+ Accept: 'application/json, application/x-www-form-urlencoded',
7
+ 'Content-Type': 'application/x-www-form-urlencoded',
8
+ };
9
+ exports.ERROR_RESPONSES = {
10
+ invalid_request: [
11
+ 'The request is missing a required parameter, includes an',
12
+ 'invalid parameter value, includes a parameter more than',
13
+ 'once, or is otherwise malformed.',
14
+ ].join(' '),
15
+ invalid_client: [
16
+ 'Client authentication failed (e.g., unknown client, no',
17
+ 'client authentication included, or unsupported',
18
+ 'authentication method).',
19
+ ].join(' '),
20
+ invalid_grant: [
21
+ 'The provided authorization grant (e.g., authorization',
22
+ 'code, resource owner credentials) or refresh token is',
23
+ 'invalid, expired, revoked, does not match the redirection',
24
+ 'URI used in the authorization request, or was issued to',
25
+ 'another client.',
26
+ ].join(' '),
27
+ unauthorized_client: [
28
+ 'The client is not authorized to request an authorization',
29
+ 'code using this method.',
30
+ ].join(' '),
31
+ unsupported_grant_type: [
32
+ 'The authorization grant type is not supported by the',
33
+ 'authorization server.',
34
+ ].join(' '),
35
+ access_denied: ['The resource owner or authorization server denied the request.'].join(' '),
36
+ unsupported_response_type: [
37
+ 'The authorization server does not support obtaining',
38
+ 'an authorization code using this method.',
39
+ ].join(' '),
40
+ invalid_scope: ['The requested scope is invalid, unknown, or malformed.'].join(' '),
41
+ server_error: [
42
+ 'The authorization server encountered an unexpected',
43
+ 'condition that prevented it from fulfilling the request.',
44
+ '(This error code is needed because a 500 Internal Server',
45
+ 'Error HTTP status code cannot be returned to the client',
46
+ 'via an HTTP redirect.)',
47
+ ].join(' '),
48
+ temporarily_unavailable: [
49
+ 'The authorization server is currently unable to handle',
50
+ 'the request due to a temporary overloading or maintenance',
51
+ 'of the server.',
52
+ ].join(' '),
53
+ };
54
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAGa,QAAA,gBAAgB,GAAG,sBAAsB,CAAC;AAK1C,QAAA,eAAe,GAAY;IACvC,MAAM,EAAE,qDAAqD;IAC7D,cAAc,EAAE,mCAAmC;CACnD,CAAC;AAOW,QAAA,eAAe,GAA2B;IACtD,eAAe,EAAE;QAChB,0DAA0D;QAC1D,yDAAyD;QACzD,kCAAkC;KAClC,CAAC,IAAI,CAAC,GAAG,CAAC;IACX,cAAc,EAAE;QACf,wDAAwD;QACxD,gDAAgD;QAChD,yBAAyB;KACzB,CAAC,IAAI,CAAC,GAAG,CAAC;IACX,aAAa,EAAE;QACd,uDAAuD;QACvD,uDAAuD;QACvD,2DAA2D;QAC3D,yDAAyD;QACzD,iBAAiB;KACjB,CAAC,IAAI,CAAC,GAAG,CAAC;IACX,mBAAmB,EAAE;QACpB,0DAA0D;QAC1D,yBAAyB;KACzB,CAAC,IAAI,CAAC,GAAG,CAAC;IACX,sBAAsB,EAAE;QACvB,sDAAsD;QACtD,uBAAuB;KACvB,CAAC,IAAI,CAAC,GAAG,CAAC;IACX,aAAa,EAAE,CAAC,gEAAgE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IAC3F,yBAAyB,EAAE;QAC1B,qDAAqD;QACrD,0CAA0C;KAC1C,CAAC,IAAI,CAAC,GAAG,CAAC;IACX,aAAa,EAAE,CAAC,wDAAwD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IACnF,YAAY,EAAE;QACb,oDAAoD;QACpD,0DAA0D;QAC1D,0DAA0D;QAC1D,yDAAyD;QACzD,wBAAwB;KACxB,CAAC,IAAI,CAAC,GAAG,CAAC;IACX,uBAAuB,EAAE;QACxB,wDAAwD;QACxD,2DAA2D;QAC3D,gBAAgB;KAChB,CAAC,IAAI,CAAC,GAAG,CAAC;CACX,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { ClientOAuth2, ClientOAuth2Options, ClientOAuth2RequestObject } from './ClientOAuth2';
2
+ export { ClientOAuth2Token, ClientOAuth2TokenData } from './ClientOAuth2Token';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientOAuth2Token = exports.ClientOAuth2 = void 0;
4
+ var ClientOAuth2_1 = require("./ClientOAuth2");
5
+ Object.defineProperty(exports, "ClientOAuth2", { enumerable: true, get: function () { return ClientOAuth2_1.ClientOAuth2; } });
6
+ var ClientOAuth2Token_1 = require("./ClientOAuth2Token");
7
+ Object.defineProperty(exports, "ClientOAuth2Token", { enumerable: true, get: function () { return ClientOAuth2Token_1.ClientOAuth2Token; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8F;AAArF,4GAAA,YAAY,OAAA;AACrB,yDAA+E;AAAtE,sHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,2 @@
1
+ export type Headers = Record<string, string | string[]>;
2
+ export type Query = Record<string, string | string[]>;
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { ClientOAuth2RequestObject } from './ClientOAuth2';
2
+ export declare function expects(obj: any, ...args: any[]): void;
3
+ export declare class AuthError extends Error {
4
+ readonly body: any;
5
+ readonly code: string;
6
+ constructor(message: string, body: any, code?: string);
7
+ }
8
+ export declare function getAuthError(body: {
9
+ error: string;
10
+ error_description?: string;
11
+ }): Error | undefined;
12
+ export declare function sanitizeScope(scopes: string[] | string): string;
13
+ export declare function auth(username: string, password: string): string;
14
+ export declare function getRequestOptions({ url, method, body, query, headers }: ClientOAuth2RequestObject, options: any): ClientOAuth2RequestObject;
package/dist/utils.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRequestOptions = exports.auth = exports.sanitizeScope = exports.getAuthError = exports.AuthError = exports.expects = void 0;
4
+ const constants_1 = require("./constants");
5
+ function expects(obj, ...args) {
6
+ for (let i = 1; i < args.length; i++) {
7
+ const prop = args[i];
8
+ if (obj[prop] === null) {
9
+ throw new TypeError('Expected "' + prop + '" to exist');
10
+ }
11
+ }
12
+ }
13
+ exports.expects = expects;
14
+ class AuthError extends Error {
15
+ constructor(message, body, code = 'EAUTH') {
16
+ super(message);
17
+ this.body = body;
18
+ this.code = code;
19
+ }
20
+ }
21
+ exports.AuthError = AuthError;
22
+ function getAuthError(body) {
23
+ var _a, _b;
24
+ 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;
25
+ if (message) {
26
+ return new AuthError(message, body);
27
+ }
28
+ return undefined;
29
+ }
30
+ exports.getAuthError = getAuthError;
31
+ function toString(str) {
32
+ return str === null ? '' : String(str);
33
+ }
34
+ function sanitizeScope(scopes) {
35
+ return Array.isArray(scopes) ? scopes.join(' ') : toString(scopes);
36
+ }
37
+ exports.sanitizeScope = sanitizeScope;
38
+ function auth(username, password) {
39
+ return 'Basic ' + Buffer.from(toString(username) + ':' + toString(password)).toString('base64');
40
+ }
41
+ exports.auth = auth;
42
+ function getRequestOptions({ url, method, body, query, headers }, options) {
43
+ const rOptions = {
44
+ url,
45
+ method,
46
+ body: { ...body, ...options.body },
47
+ query: { ...query, ...options.query },
48
+ headers: { ...headers, ...options.headers },
49
+ };
50
+ if (rOptions.headers.Authorization === '') {
51
+ delete rOptions.headers.Authorization;
52
+ }
53
+ return rOptions;
54
+ }
55
+ exports.getRequestOptions = getRequestOptions;
56
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAKA,2CAA8C;AAK9C,SAAgB,OAAO,CAAC,GAAQ,EAAE,GAAG,IAAW;IAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YACvB,MAAM,IAAI,SAAS,CAAC,YAAY,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC;SACxD;KACD;AACF,CAAC;AAPD,0BAOC;AAED,MAAa,SAAU,SAAQ,KAAK;IACnC,YAAY,OAAe,EAAW,IAAS,EAAW,OAAO,OAAO;QACvE,KAAK,CAAC,OAAO,CAAC,CAAC;QADsB,SAAI,GAAJ,IAAI,CAAK;QAAW,SAAI,GAAJ,IAAI,CAAU;IAExE,CAAC;CACD;AAJD,8BAIC;AAKD,SAAgB,YAAY,CAAC,IAG5B;;IACA,MAAM,OAAO,GACZ,MAAA,MAAA,2BAAe,CAAC,IAAI,CAAC,KAAK,CAAC,mCAAI,IAAI,CAAC,iBAAiB,mCAAI,IAAI,CAAC,KAAK,CAAC;IAErE,IAAI,OAAO,EAAE;QACZ,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;KACpC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC;AAZD,oCAYC;AAKD,SAAS,QAAQ,CAAC,GAA8B;IAC/C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6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*"
9
+ ],
10
+ "dependencies": {
11
+ "axios": "^0.21.1"
12
+ },
13
+ "scripts": {
14
+ "clean": "rimraf dist .turbo",
15
+ "dev": "pnpm watch",
16
+ "typecheck": "tsc",
17
+ "build": "tsc -p tsconfig.build.json",
18
+ "format": "prettier --write . --ignore-path ../../../.prettierignore",
19
+ "lint": "eslint --quiet .",
20
+ "lintfix": "eslint . --fix",
21
+ "watch": "tsc -p tsconfig.build.json --watch",
22
+ "test": "jest",
23
+ "test:dev": "jest --watch"
24
+ }
25
+ }