New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bity/oauth2-auth-code-pkce

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bity/oauth2-auth-code-pkce - npm Package Compare versions

Comparing version

to
2.8.0

27

index.js

@@ -337,3 +337,3 @@ "use strict";

}
if (!_this.state.isActive) {
if (!_this.state.isHTTPDecoratorActive) {
return fetch.apply(void 0, __spreadArrays([url, config], rest));

@@ -416,3 +416,3 @@ }

codeVerifier: codeVerifier,
stateQueryParam: stateQueryParam, isActive: true });
stateQueryParam: stateQueryParam, isHTTPDecoratorActive: true });
localStorage.setItem(exports.LOCALSTORAGE_STATE, JSON.stringify(this.state));

@@ -451,3 +451,3 @@ url = this.config.authorizationUrl

}
if (!accessToken || !hasAuthCodeBeenExchangedForAccessToken) {
if (!this.isAuthorized() || !hasAuthCodeBeenExchangedForAccessToken) {
this.authCodeForAccessTokenRequest = this.exchangeAuthCodeForAccessToken();

@@ -457,3 +457,3 @@ return this.authCodeForAccessTokenRequest;

// Depending on the server (and config), refreshToken may not be available.
if (refreshToken && (new Date()) >= (new Date(accessToken.expiry))) {
if (refreshToken && this.isAccessTokenExpired()) {
return onAccessTokenExpiry(function () { return _this.exchangeRefreshTokenForAccessToken(); });

@@ -530,7 +530,22 @@ }

*/
OAuth2AuthCodePKCE.prototype.isActive = function (isActive) {
this.state.isActive = isActive;
OAuth2AuthCodePKCE.prototype.isHTTPDecoratorActive = function (isActive) {
this.state.isHTTPDecoratorActive = isActive;
localStorage.setItem(exports.LOCALSTORAGE_STATE, JSON.stringify(this.state));
};
/**
* Tells if the client is authorized or not. This means the client has at
* least once successfully fetched an access token. The access token could be
* expired.
*/
OAuth2AuthCodePKCE.prototype.isAuthorized = function () {
return !!this.state.accessToken;
};
/**
* Checks to see if the access token has expired.
*/
OAuth2AuthCodePKCE.prototype.isAccessTokenExpired = function () {
var accessToken = this.state.accessToken;
return accessToken && (new Date()) >= (new Date(accessToken.expiry));
};
/**
* Resets the state of the client. Equivalent to "logging out" the user.

@@ -537,0 +552,0 @@ */

@@ -21,3 +21,3 @@ /**

export interface State {
isActive?: boolean;
isHTTPDecoratorActive?: boolean;
accessToken?: AccessToken;

@@ -198,3 +198,3 @@ authorizationCode?: string;

return (url: string, config: any, ...rest) => {
if (!this.state.isActive) {
if (!this.state.isHTTPDecoratorActive) {
return fetch(url, config, ...rest);

@@ -291,3 +291,3 @@ }

stateQueryParam,
isActive: true
isHTTPDecoratorActive: true
};

@@ -336,3 +336,3 @@

if (!accessToken || !hasAuthCodeBeenExchangedForAccessToken) {
if (!this.isAuthorized() || !hasAuthCodeBeenExchangedForAccessToken) {
this.authCodeForAccessTokenRequest = this.exchangeAuthCodeForAccessToken();

@@ -343,3 +343,3 @@ return this.authCodeForAccessTokenRequest;

// Depending on the server (and config), refreshToken may not be available.
if (refreshToken && (new Date()) >= (new Date(accessToken.expiry))) {
if (refreshToken && this.isAccessTokenExpired()) {
return onAccessTokenExpiry(() => this.exchangeRefreshTokenForAccessToken());

@@ -426,4 +426,4 @@ }

*/
public isActive(isActive: boolean) {
this.state.isActive = isActive;
public isHTTPDecoratorActive(isActive: boolean) {
this.state.isHTTPDecoratorActive = isActive;
localStorage.setItem(LOCALSTORAGE_STATE, JSON.stringify(this.state));

@@ -433,2 +433,19 @@ }

/**
* Tells if the client is authorized or not. This means the client has at
* least once successfully fetched an access token. The access token could be
* expired.
*/
public isAuthorized(): boolean {
return !!this.state.accessToken;
}
/**
* Checks to see if the access token has expired.
*/
public isAccessTokenExpired(): boolean {
const { accessToken } = this.state;
return accessToken && (new Date()) >= (new Date(accessToken.expiry));
}
/**
* Resets the state of the client. Equivalent to "logging out" the user.

@@ -435,0 +452,0 @@ */

@@ -438,3 +438,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

}
if (!_this.state.isActive) {
if (!_this.state.isHTTPDecoratorActive) {
return fetch.apply(void 0, __spreadArrays([url, config], rest));

@@ -517,3 +517,3 @@ }

codeVerifier: codeVerifier,
stateQueryParam: stateQueryParam, isActive: true });
stateQueryParam: stateQueryParam, isHTTPDecoratorActive: true });
localStorage.setItem(exports.LOCALSTORAGE_STATE, JSON.stringify(this.state));

@@ -552,3 +552,3 @@ url = this.config.authorizationUrl

}
if (!accessToken || !hasAuthCodeBeenExchangedForAccessToken) {
if (!this.isAuthorized() || !hasAuthCodeBeenExchangedForAccessToken) {
this.authCodeForAccessTokenRequest = this.exchangeAuthCodeForAccessToken();

@@ -558,3 +558,3 @@ return this.authCodeForAccessTokenRequest;

// Depending on the server (and config), refreshToken may not be available.
if (refreshToken && (new Date()) >= (new Date(accessToken.expiry))) {
if (refreshToken && this.isAccessTokenExpired()) {
return onAccessTokenExpiry(function () { return _this.exchangeRefreshTokenForAccessToken(); });

@@ -631,7 +631,22 @@ }

*/
OAuth2AuthCodePKCE.prototype.isActive = function (isActive) {
this.state.isActive = isActive;
OAuth2AuthCodePKCE.prototype.isHTTPDecoratorActive = function (isActive) {
this.state.isHTTPDecoratorActive = isActive;
localStorage.setItem(exports.LOCALSTORAGE_STATE, JSON.stringify(this.state));
};
/**
* Tells if the client is authorized or not. This means the client has at
* least once successfully fetched an access token. The access token could be
* expired.
*/
OAuth2AuthCodePKCE.prototype.isAuthorized = function () {
return !!this.state.accessToken;
};
/**
* Checks to see if the access token has expired.
*/
OAuth2AuthCodePKCE.prototype.isAccessTokenExpired = function () {
var accessToken = this.state.accessToken;
return accessToken && (new Date()) >= (new Date(accessToken.expiry));
};
/**
* Resets the state of the client. Equivalent to "logging out" the user.

@@ -638,0 +653,0 @@ */

{
"name": "@bity/oauth2-auth-code-pkce",
"version": "2.7.1",
"version": "2.8.0",
"description": "An OAuth 2.0 client that ONLY supports Authorization Code flow with PKCE support.",

@@ -5,0 +5,0 @@ "main": "index.js",