Skip to content

Commit

Permalink
feat: removing dependnecies
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Psztyc <[email protected]>
  • Loading branch information
jarrodek committed Jun 23, 2022
1 parent dc7f7e8 commit 140c1bf
Show file tree
Hide file tree
Showing 14 changed files with 12,556 additions and 1,971 deletions.
14,081 changes: 12,160 additions & 1,921 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 8 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@advanced-rest-client/oauth",
"description": "The OAuth library for the Advanced REST Client",
"version": "0.1.0",
"version": "0.2.0",
"license": "Apache-2.0",
"main": "index.js",
"module": "index.js",
Expand All @@ -20,18 +20,13 @@
"url": "https://github.com/advanced-rest-client/oauth/issues",
"email": "[email protected]"
},
"dependencies": {
"@advanced-rest-client/events": "^0.2.28"
},
"peerDependencies": {
"jsrsasign": "^10.4.0"
},
"devDependencies": {
"lit-element": "^2.5.1",
"lit-html": "^1.4.1",
"@advanced-rest-client/arc-mock": "^5.0.0",
"@commitlint/cli": "^13.2.1",
"@commitlint/config-conventional": "^13.2.0",
"lit": "^2.2.6",
"@commitlint/cli": "^17.0.2",
"@commitlint/config-conventional": "^17.0.2",
"@open-wc/eslint-config": "^7.0.0",
"@open-wc/testing": "^3.0.2",
"@web/dev-server": "^0.1.25",
Expand All @@ -40,12 +35,12 @@
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"get-port": "^6.0.0",
"husky": "^7.0.2",
"husky": "^8.0.1",
"jsrsasign": "^10.4.1",
"koa-proxies": "^0.12.1",
"lint-staged": "^11.2.6",
"oauth2-mock-server": "^3.2.0",
"sinon": "^11.1.2",
"lint-staged": "^13.0.2",
"oauth2-mock-server": "^4.3.1",
"sinon": "^14.0.0",
"typescript": "^4.4.4",
"typescript-lit-html-plugin": "^0.9.0"
},
Expand Down
4 changes: 2 additions & 2 deletions src/CustomParameters.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2AuthorizationRequestCustomData} OAuth2AuthorizationRequestCustomData */
/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2CustomData} OAuth2CustomData */
/** @typedef {import('./types').OAuth2AuthorizationRequestCustomData} OAuth2AuthorizationRequestCustomData */
/** @typedef {import('./types').OAuth2CustomData} OAuth2CustomData */

/**
* Applies custom properties defined in the OAuth settings object to the URL.
Expand Down
28 changes: 12 additions & 16 deletions src/OAuth2Authorization.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Authorization } from '@advanced-rest-client/events';
import { ProcessingOptions } from './types';
import { ProcessingOptions, OAuth2Authorization as OAuth2Config, TokenInfo } from './types';

export declare const resolveFunction: unique symbol;
export declare const rejectFunction: unique symbol;
Expand Down Expand Up @@ -38,16 +37,13 @@ export declare const grantResponseMapping: Record<string, string>;

/**
* A library that performs OAuth 2 authorization.
*
* It is build for API components ecosystem and the configuration is defined in `@advanced-rest-client/events`
* so all components use the same configuration.
*/
export class OAuth2Authorization {
/**
* The authorization settings used to initialize this class.
*/
get settings(): Authorization.OAuth2Authorization;
[settingsValue]: Authorization.OAuth2Authorization;
get settings(): OAuth2Config;
[settingsValue]: OAuth2Config;

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

/**
* @returns Processed settings
*/
[prepareSettings](settings: Authorization.OAuth2Authorization): Authorization.OAuth2Authorization;
[prepareSettings](settings: OAuth2Config): OAuth2Config;

/**
* @returns Processed options
Expand All @@ -93,7 +89,7 @@ export class OAuth2Authorization {
* Performs the authorization.
* @returns Promise resolved to the token info.
*/
authorize(): Promise<Authorization.TokenInfo|any>;
authorize(): Promise<TokenInfo|any>;

/**
* Reports authorization error back to the application.
Expand Down Expand Up @@ -204,14 +200,14 @@ export class OAuth2Authorization {
/**
* Creates a token info object from query parameters
*/
[tokenInfoFromParams](oauthParams: URLSearchParams): Authorization.TokenInfo;
[tokenInfoFromParams](oauthParams: URLSearchParams): TokenInfo;

/**
* Processes token info object when it's ready.
*
* @param info Token info returned from the server.
*/
[handleTokenInfo](info: Authorization.TokenInfo): void;
[handleTokenInfo](info: TokenInfo): void;

/**
* Computes token expiration time.
Expand All @@ -221,7 +217,7 @@ export class OAuth2Authorization {
* @param tokenInfo Token info object
* @returns A copy with updated properties.
*/
[computeExpires](tokenInfo: Authorization.TokenInfo): Authorization.TokenInfo;
[computeExpires](tokenInfo: TokenInfo): TokenInfo;

/**
* Computes the final list of granted scopes.
Expand Down Expand Up @@ -260,15 +256,15 @@ export class OAuth2Authorization {
* @param info
* @returns The token info when the request was a success.
*/
mapCodeResponse(info: Record<string, any>): Authorization.TokenInfo;
mapCodeResponse(info: Record<string, any>): TokenInfo;

/**
* Exchanges the authorization code for authorization token.
*
* @param code Returned code from the authorization endpoint.
* @returns The token info when the request was a success.
*/
exchangeCode(code: string): Promise<Authorization.TokenInfo>;
exchangeCode(code: string): Promise<TokenInfo>;

/**
* Returns a body value for the code exchange request.
Expand Down Expand Up @@ -305,7 +301,7 @@ export class OAuth2Authorization {
*
* @param settings The OAuth 2 settings to use
*/
getClientCredentialsHeader(settings: Authorization.OAuth2Authorization): string;
getClientCredentialsHeader(settings: OAuth2Config): string;

/**
* Requests a token for `client_credentials` request type.
Expand Down
9 changes: 3 additions & 6 deletions src/OAuth2Authorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { IframeAuthorization } from './lib/IframeAuthorization.js';
import { PopupAuthorization } from './lib/PopupAuthorization.js';
import * as KnownGrants from './lib/KnownGrants.js';

/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2Authorization} OAuth2Settings */
/** @typedef {import('@advanced-rest-client/events').Authorization.TokenInfo} TokenInfo */
/** @typedef {import('@advanced-rest-client/events').Authorization.OidcTokenInfo} OidcTokenInfo */
/** @typedef {import('./types').OAuth2Authorization} OAuth2Settings */
/** @typedef {import('./types').TokenInfo} TokenInfo */
/** @typedef {import('./types').OidcTokenInfo} OidcTokenInfo */
/** @typedef {import('./types').ProcessingOptions} ProcessingOptions */

export const resolveFunction = Symbol('resolveFunction');
Expand Down Expand Up @@ -53,9 +53,6 @@ export const grantResponseMapping = {

/**
* A library that performs OAuth 2 authorization.
*
* It is build for API components ecosystem and the configuration is defined in `@advanced-rest-client/events`
* so all components use the same configuration.
*/
export class OAuth2Authorization {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/OidcAuthorization.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OidcTokenError, OidcTokenInfo } from '@advanced-rest-client/events/src/authorization/Authorization';
import { OAuth2Authorization } from './OAuth2Authorization.js';
import { OidcTokenError, OidcTokenInfo } from './types.js';

export declare class OidcAuthorization extends OAuth2Authorization {
/**
Expand Down
6 changes: 3 additions & 3 deletions src/OidcAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Tokens } from './lib/Tokens.js';
import { OAuth2Authorization, grantResponseMapping, reportOAuthError, resolveFunction, rejectFunction, handleTokenInfo } from './OAuth2Authorization.js';
import { nonceGenerator } from './Utils.js';

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

export class OidcAuthorization extends OAuth2Authorization {
/**
Expand Down
59 changes: 59 additions & 0 deletions src/Utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { OAuth2Authorization } from "./types";

/**
* Checks if the URL has valid scheme for OAuth flow.
*
* Do not use this to validate redirect URIs as they can use any protocol.
*
* @param url The url value to test
* @throws {TypeError} When passed value is not set, empty, or not a string
* @throws {Error} When passed value is not a valid URL for OAuth 2 flow
*/
export function checkUrl(url: string): void;

/**
* Checks if basic configuration of the OAuth 2 request is valid an can proceed
* with authentication.
* @param settings authorization settings
* @throws {Error} When settings are not valid
*/
export function sanityCheck(settings: OAuth2Authorization): void;

/**
* Generates a random string of characters.
*
* @returns A random string.
*/
export function randomString(): string;

/**
* Replaces `-` or `_` with camel case.
* @param name The string to process
* @return Camel cased string or `undefined` if not transformed.
*/
export function camel(name: string): string | undefined;

/**
* Computes the SHA256 hash ogf the given input.
* @param value The value to encode.
*/
export function sha256(value: string): Promise<ArrayBuffer>;

/**
* Encoded the array buffer to a base64 string value.
*/
export function base64Buffer(buffer: ArrayBuffer): string;

/**
* Generates code challenge for the PKCE extension to the OAuth2 specification.
* @param verifier The generated code verifier.
* @returns The code challenge string
*/
export function generateCodeChallenge(verifier: string): Promise<string>;

/**
* Generates cryptographically significant random string.
* @param size The size of the generated nonce. Default to 20.
* @returns A nonce (number used once).
*/
export function nonceGenerator(size?: number): string;
2 changes: 1 addition & 1 deletion src/Utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @typedef {import('@advanced-rest-client/events').Authorization.OAuth2Authorization} OAuth2Settings */
/** @typedef {import('./types').Authorization.OAuth2Authorization} OAuth2Settings */

/**
* Checks if the URL has valid scheme for OAuth flow.
Expand Down
6 changes: 3 additions & 3 deletions src/lib/Tokens.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @typedef {import('@advanced-rest-client/events').Authorization.OidcTokenInfo} OidcTokenInfo */
/** @typedef {import('@advanced-rest-client/events').Authorization.OidcTokenError} OidcTokenError */
/** @typedef {import('@advanced-rest-client/events').Authorization.TokenInfo} TokenInfo */
/** @typedef {import('../types').OidcTokenInfo} OidcTokenInfo */
/** @typedef {import('../types').OidcTokenError} OidcTokenError */
/** @typedef {import('../types').TokenInfo} TokenInfo */

export class Tokens {
/**
Expand Down
Loading

0 comments on commit 140c1bf

Please sign in to comment.