Skip to content

Commit 140c1bf

Browse files
committed
feat: removing dependnecies
Signed-off-by: Pawel Psztyc <jarrodek@gmail.com>
1 parent dc7f7e8 commit 140c1bf

14 files changed

+12556
-1971
lines changed

package-lock.json

Lines changed: 12160 additions & 1921 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@advanced-rest-client/oauth",
33
"description": "The OAuth library for the Advanced REST Client",
4-
"version": "0.1.0",
4+
"version": "0.2.0",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",
@@ -20,18 +20,13 @@
2020
"url": "https://github.com/advanced-rest-client/oauth/issues",
2121
"email": "arc@mulesoft.com"
2222
},
23-
"dependencies": {
24-
"@advanced-rest-client/events": "^0.2.28"
25-
},
2623
"peerDependencies": {
2724
"jsrsasign": "^10.4.0"
2825
},
2926
"devDependencies": {
30-
"lit-element": "^2.5.1",
31-
"lit-html": "^1.4.1",
32-
"@advanced-rest-client/arc-mock": "^5.0.0",
33-
"@commitlint/cli": "^13.2.1",
34-
"@commitlint/config-conventional": "^13.2.0",
27+
"lit": "^2.2.6",
28+
"@commitlint/cli": "^17.0.2",
29+
"@commitlint/config-conventional": "^17.0.2",
3530
"@open-wc/eslint-config": "^7.0.0",
3631
"@open-wc/testing": "^3.0.2",
3732
"@web/dev-server": "^0.1.25",
@@ -40,12 +35,12 @@
4035
"eslint": "^8.0.1",
4136
"eslint-config-prettier": "^8.3.0",
4237
"get-port": "^6.0.0",
43-
"husky": "^7.0.2",
38+
"husky": "^8.0.1",
4439
"jsrsasign": "^10.4.1",
4540
"koa-proxies": "^0.12.1",
46-
"lint-staged": "^11.2.6",
47-
"oauth2-mock-server": "^3.2.0",
48-
"sinon": "^11.1.2",
41+
"lint-staged": "^13.0.2",
42+
"oauth2-mock-server": "^4.3.1",
43+
"sinon": "^14.0.0",
4944
"typescript": "^4.4.4",
5045
"typescript-lit-html-plugin": "^0.9.0"
5146
},

src/CustomParameters.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2AuthorizationRequestCustomData} OAuth2AuthorizationRequestCustomData */
2-
/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2CustomData} OAuth2CustomData */
1+
/** @typedef {import('./types').OAuth2AuthorizationRequestCustomData} OAuth2AuthorizationRequestCustomData */
2+
/** @typedef {import('./types').OAuth2CustomData} OAuth2CustomData */
33

44
/**
55
* Applies custom properties defined in the OAuth settings object to the URL.

src/OAuth2Authorization.d.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Authorization } from '@advanced-rest-client/events';
2-
import { ProcessingOptions } from './types';
1+
import { ProcessingOptions, OAuth2Authorization as OAuth2Config, TokenInfo } from './types';
32

43
export declare const resolveFunction: unique symbol;
54
export declare const rejectFunction: unique symbol;
@@ -38,16 +37,13 @@ export declare const grantResponseMapping: Record<string, string>;
3837

3938
/**
4039
* A library that performs OAuth 2 authorization.
41-
*
42-
* It is build for API components ecosystem and the configuration is defined in `@advanced-rest-client/events`
43-
* so all components use the same configuration.
4440
*/
4541
export class OAuth2Authorization {
4642
/**
4743
* The authorization settings used to initialize this class.
4844
*/
49-
get settings(): Authorization.OAuth2Authorization;
50-
[settingsValue]: Authorization.OAuth2Authorization;
45+
get settings(): OAuth2Config;
46+
[settingsValue]: OAuth2Config;
5147

5248
/**
5349
* The processing options used to initialize this object.
@@ -70,12 +66,12 @@ export class OAuth2Authorization {
7066
* @param settings The authorization configuration.
7167
* @param options Additional processing options to configure the behavior of this library.
7268
*/
73-
constructor(settings: Authorization.OAuth2Authorization, options?: ProcessingOptions);
69+
constructor(settings: OAuth2Config, options?: ProcessingOptions);
7470

7571
/**
7672
* @returns Processed settings
7773
*/
78-
[prepareSettings](settings: Authorization.OAuth2Authorization): Authorization.OAuth2Authorization;
74+
[prepareSettings](settings: OAuth2Config): OAuth2Config;
7975

8076
/**
8177
* @returns Processed options
@@ -93,7 +89,7 @@ export class OAuth2Authorization {
9389
* Performs the authorization.
9490
* @returns Promise resolved to the token info.
9591
*/
96-
authorize(): Promise<Authorization.TokenInfo|any>;
92+
authorize(): Promise<TokenInfo|any>;
9793

9894
/**
9995
* Reports authorization error back to the application.
@@ -204,14 +200,14 @@ export class OAuth2Authorization {
204200
/**
205201
* Creates a token info object from query parameters
206202
*/
207-
[tokenInfoFromParams](oauthParams: URLSearchParams): Authorization.TokenInfo;
203+
[tokenInfoFromParams](oauthParams: URLSearchParams): TokenInfo;
208204

209205
/**
210206
* Processes token info object when it's ready.
211207
*
212208
* @param info Token info returned from the server.
213209
*/
214-
[handleTokenInfo](info: Authorization.TokenInfo): void;
210+
[handleTokenInfo](info: TokenInfo): void;
215211

216212
/**
217213
* Computes token expiration time.
@@ -221,7 +217,7 @@ export class OAuth2Authorization {
221217
* @param tokenInfo Token info object
222218
* @returns A copy with updated properties.
223219
*/
224-
[computeExpires](tokenInfo: Authorization.TokenInfo): Authorization.TokenInfo;
220+
[computeExpires](tokenInfo: TokenInfo): TokenInfo;
225221

226222
/**
227223
* Computes the final list of granted scopes.
@@ -260,15 +256,15 @@ export class OAuth2Authorization {
260256
* @param info
261257
* @returns The token info when the request was a success.
262258
*/
263-
mapCodeResponse(info: Record<string, any>): Authorization.TokenInfo;
259+
mapCodeResponse(info: Record<string, any>): TokenInfo;
264260

265261
/**
266262
* Exchanges the authorization code for authorization token.
267263
*
268264
* @param code Returned code from the authorization endpoint.
269265
* @returns The token info when the request was a success.
270266
*/
271-
exchangeCode(code: string): Promise<Authorization.TokenInfo>;
267+
exchangeCode(code: string): Promise<TokenInfo>;
272268

273269
/**
274270
* Returns a body value for the code exchange request.
@@ -305,7 +301,7 @@ export class OAuth2Authorization {
305301
*
306302
* @param settings The OAuth 2 settings to use
307303
*/
308-
getClientCredentialsHeader(settings: Authorization.OAuth2Authorization): string;
304+
getClientCredentialsHeader(settings: OAuth2Config): string;
309305

310306
/**
311307
* Requests a token for `client_credentials` request type.

src/OAuth2Authorization.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { IframeAuthorization } from './lib/IframeAuthorization.js';
88
import { PopupAuthorization } from './lib/PopupAuthorization.js';
99
import * as KnownGrants from './lib/KnownGrants.js';
1010

11-
/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2Authorization} OAuth2Settings */
12-
/** @typedef {import('@advanced-rest-client/events').Authorization.TokenInfo} TokenInfo */
13-
/** @typedef {import('@advanced-rest-client/events').Authorization.OidcTokenInfo} OidcTokenInfo */
11+
/** @typedef {import('./types').OAuth2Authorization} OAuth2Settings */
12+
/** @typedef {import('./types').TokenInfo} TokenInfo */
13+
/** @typedef {import('./types').OidcTokenInfo} OidcTokenInfo */
1414
/** @typedef {import('./types').ProcessingOptions} ProcessingOptions */
1515

1616
export const resolveFunction = Symbol('resolveFunction');
@@ -53,9 +53,6 @@ export const grantResponseMapping = {
5353

5454
/**
5555
* A library that performs OAuth 2 authorization.
56-
*
57-
* It is build for API components ecosystem and the configuration is defined in `@advanced-rest-client/events`
58-
* so all components use the same configuration.
5956
*/
6057
export class OAuth2Authorization {
6158
/**

src/OidcAuthorization.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { OidcTokenError, OidcTokenInfo } from '@advanced-rest-client/events/src/authorization/Authorization';
21
import { OAuth2Authorization } from './OAuth2Authorization.js';
2+
import { OidcTokenError, OidcTokenInfo } from './types.js';
33

44
export declare class OidcAuthorization extends OAuth2Authorization {
55
/**

src/OidcAuthorization.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { Tokens } from './lib/Tokens.js';
22
import { OAuth2Authorization, grantResponseMapping, reportOAuthError, resolveFunction, rejectFunction, handleTokenInfo } from './OAuth2Authorization.js';
33
import { nonceGenerator } from './Utils.js';
44

5-
/** @typedef {import('@advanced-rest-client/events').Authorization.OidcTokenInfo} OidcTokenInfo */
6-
/** @typedef {import('@advanced-rest-client/events').Authorization.OidcTokenError} OidcTokenError */
7-
/** @typedef {import('@advanced-rest-client/events').Authorization.TokenInfo} TokenInfo */
5+
/** @typedef {import('./types').OidcTokenInfo} OidcTokenInfo */
6+
/** @typedef {import('./types').OidcTokenError} OidcTokenError */
7+
/** @typedef {import('./types').TokenInfo} TokenInfo */
88

99
export class OidcAuthorization extends OAuth2Authorization {
1010
/**

src/Utils.d.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { OAuth2Authorization } from "./types";
2+
3+
/**
4+
* Checks if the URL has valid scheme for OAuth flow.
5+
*
6+
* Do not use this to validate redirect URIs as they can use any protocol.
7+
*
8+
* @param url The url value to test
9+
* @throws {TypeError} When passed value is not set, empty, or not a string
10+
* @throws {Error} When passed value is not a valid URL for OAuth 2 flow
11+
*/
12+
export function checkUrl(url: string): void;
13+
14+
/**
15+
* Checks if basic configuration of the OAuth 2 request is valid an can proceed
16+
* with authentication.
17+
* @param settings authorization settings
18+
* @throws {Error} When settings are not valid
19+
*/
20+
export function sanityCheck(settings: OAuth2Authorization): void;
21+
22+
/**
23+
* Generates a random string of characters.
24+
*
25+
* @returns A random string.
26+
*/
27+
export function randomString(): string;
28+
29+
/**
30+
* Replaces `-` or `_` with camel case.
31+
* @param name The string to process
32+
* @return Camel cased string or `undefined` if not transformed.
33+
*/
34+
export function camel(name: string): string | undefined;
35+
36+
/**
37+
* Computes the SHA256 hash ogf the given input.
38+
* @param value The value to encode.
39+
*/
40+
export function sha256(value: string): Promise<ArrayBuffer>;
41+
42+
/**
43+
* Encoded the array buffer to a base64 string value.
44+
*/
45+
export function base64Buffer(buffer: ArrayBuffer): string;
46+
47+
/**
48+
* Generates code challenge for the PKCE extension to the OAuth2 specification.
49+
* @param verifier The generated code verifier.
50+
* @returns The code challenge string
51+
*/
52+
export function generateCodeChallenge(verifier: string): Promise<string>;
53+
54+
/**
55+
* Generates cryptographically significant random string.
56+
* @param size The size of the generated nonce. Default to 20.
57+
* @returns A nonce (number used once).
58+
*/
59+
export function nonceGenerator(size?: number): string;

src/Utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2Authorization} OAuth2Settings */
1+
/** @typedef {import('./types').Authorization.OAuth2Authorization} OAuth2Settings */
22

33
/**
44
* Checks if the URL has valid scheme for OAuth flow.

src/lib/Tokens.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/** @typedef {import('@advanced-rest-client/events').Authorization.OidcTokenInfo} OidcTokenInfo */
2-
/** @typedef {import('@advanced-rest-client/events').Authorization.OidcTokenError} OidcTokenError */
3-
/** @typedef {import('@advanced-rest-client/events').Authorization.TokenInfo} TokenInfo */
1+
/** @typedef {import('../types').OidcTokenInfo} OidcTokenInfo */
2+
/** @typedef {import('../types').OidcTokenError} OidcTokenError */
3+
/** @typedef {import('../types').TokenInfo} TokenInfo */
44

55
export class Tokens {
66
/**

0 commit comments

Comments
 (0)