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

@propelauth/javascript

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@propelauth/javascript - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

15

dist/cjs/index.js

@@ -122,4 +122,7 @@ 'use strict';

function hasLocalStorage() {
return typeof localStorage !== 'undefined';
return typeof localStorage !== "undefined";
}
function hasWindow() {
return typeof window !== "undefined";
}
function getLocalStorageNumber(key) {

@@ -357,7 +360,9 @@ if (!hasLocalStorage()) {

window.addEventListener("storage", onStorageChange);
if (hasWindow()) {
window.addEventListener("storage", onStorageChange);
if (authOptions.enableBackgroundTokenRefresh) {
client.getAuthenticationInfoOrNull();
clientState.refreshInterval = window.setInterval(client.getAuthenticationInfoOrNull, 60000);
if (authOptions.enableBackgroundTokenRefresh) {
client.getAuthenticationInfoOrNull();
clientState.refreshInterval = window.setInterval(client.getAuthenticationInfoOrNull, 60000);
}
}

@@ -364,0 +369,0 @@

@@ -118,4 +118,7 @@ let UserRole;

function hasLocalStorage() {
return typeof localStorage !== 'undefined';
return typeof localStorage !== "undefined";
}
function hasWindow() {
return typeof window !== "undefined";
}
function getLocalStorageNumber(key) {

@@ -353,7 +356,9 @@ if (!hasLocalStorage()) {

window.addEventListener("storage", onStorageChange);
if (hasWindow()) {
window.addEventListener("storage", onStorageChange);
if (authOptions.enableBackgroundTokenRefresh) {
client.getAuthenticationInfoOrNull();
clientState.refreshInterval = window.setInterval(client.getAuthenticationInfoOrNull, 60000);
if (authOptions.enableBackgroundTokenRefresh) {
client.getAuthenticationInfoOrNull();
clientState.refreshInterval = window.setInterval(client.getAuthenticationInfoOrNull, 60000);
}
}

@@ -360,0 +365,0 @@

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).PropelAuth={})}(this,(function(e){"use strict";var t;function n(t){return new Promise(((n,o)=>{const r=new XMLHttpRequest;r.onreadystatechange=function(){if(r.readyState===XMLHttpRequest.DONE){const s=r.status;if(s>=200&&s<300)try{const o=(t=r.responseText,JSON.parse(t,(function(t,n){if("org_id"===t)this.orgId=n;else if("org_name"===t)this.orgName=n;else if("user_role"===t)this.userRole=(o=n,e.UserRole[o]);else if("access_token"===t)this.accessToken=n;else if("expires_at_seconds"===t)this.expiresAtSeconds=n;else if("org_id_to_org_member_info"===t)this.orgIdToOrgMemberInfo=n;else{if("user_id"!==t)return n;this.userId=n}var o})));n(o)}catch(e){console.error("Unable to process authentication response",e),o({status:500,message:"Unable to process authentication response"})}else 401===s?n(null):o({status:s,message:r.responseText})}var t},r.open("get",`${t}/api/v1/refresh_token`),r.withCredentials=!0,r.ontimeout=function(){o({status:408,message:"Request timed out"})},r.send(null)}))}function o(){return Date.now()/1e3}function r(){return"undefined"!=typeof localStorage}function s(e){if(!r())return null;const t=localStorage.getItem(e);if(!t)return null;const n=parseInt(t,10);return Number.isNaN(n)?null:n}e.UserRole=void 0,(t=e.UserRole||(e.UserRole={}))[t.Member=0]="Member",t[t.Admin=1]="Admin",t[t.Owner=2]="Owner";const a="__PROPEL_AUTH_LOGGED_IN_AT",i="__PROPEL_AUTH_LOGGED_OUT_AT";e.createClient=function(e){!function(e){try{const t=new URL(e.authUrl);e.authUrl=t.origin}catch(e){throw console.error("Invalid authUrl",e),new Error("Unable to initialize auth client")}void 0===e.enableBackgroundTokenRefresh&&(e.enableBackgroundTokenRefresh=!0)}(e);const t={initialLoadFinished:!1,authenticationInfo:null,observers:[],lastLoggedInAtMessage:s(a),lastLoggedOutAtMessage:s(i),authUrl:e.authUrl,refreshInterval:null};function u(e){for(let n=0;n<t.observers.length;n++){const o=t.observers[n];o&&o(e)}}function l(e){var n;const r=null===(n=t.authenticationInfo)||void 0===n?void 0:n.accessToken;t.authenticationInfo=e;const s=null==e?void 0:e.accessToken;!function(e,n){return!e&&(n||!t.initialLoadFinished)}(s,r)?function(e,t){return!t&&e}(s,r)&&(u(!0),function(){const e=o();t.lastLoggedInAtMessage=e,localStorage.setItem(a,String(e))}()):(u(!1),function(){const e=o();t.lastLoggedOutAtMessage=e,localStorage.setItem(i,String(e))}()),t.initialLoadFinished=!0}async function c(e){try{const e=await n(t.authUrl);return l(e),e}catch(n){if(e)return t.authenticationInfo;throw l(null),n}}const d={addLoggedInChangeObserver(e){t.observers.includes(e)?console.error("Observer has been attached already."):e?t.observers.push(e):console.error("Cannot add a null observer")},removeLoggedInChangeObserver(e){const n=t.observers.indexOf(e);-1===n?console.error("Cannot find observer to remove"):t.observers.splice(n,1)},async getAuthenticationInfoOrNull(e){const n=o();if(e)return await c(!1);if(t.authenticationInfo){if(n+240>t.authenticationInfo.expiresAtSeconds){const e=n<t.authenticationInfo.expiresAtSeconds;return await c(e)}return t.authenticationInfo}return await c(!1)},redirectToSignupPage(){window.location.href=`${t.authUrl}/signup`},redirectToLoginPage(){window.location.href=`${t.authUrl}/login`},redirectToAccountPage(){window.location.href=`${t.authUrl}/account`},redirectToOrgPage(e){window.location.href=e?`${t.authUrl}/org?id=${e}`:`${t.authUrl}/org`},redirectToCreateOrgPage(){window.location.href=`${t.authUrl}/create_org`},async logout(e){const n=await(o=t.authUrl,new Promise(((e,t)=>{const n=new XMLHttpRequest;n.onreadystatechange=function(){if(n.readyState===XMLHttpRequest.DONE){const o=n.status;if(o>=200&&o<300){const t=JSON.parse(n.responseText);e(t)}else console.error("Logout error",n.status,n.responseText),t({status:o,message:n.responseText})}},n.open("post",`${o}/api/v1/logout`),n.withCredentials=!0,n.ontimeout=function(){t({status:408,message:"Request timed out"})},n.send(null)})));var o;l(null),e&&(window.location.href=n.redirect_to)},destroy(){t.observers=[],window.removeEventListener("storage",g),t.refreshInterval&&clearInterval(t.refreshInterval)}},g=async function(){if(!r())return;const e=s(i),n=s(a);e&&(!t.lastLoggedOutAtMessage||e>t.lastLoggedOutAtMessage)&&(t.lastLoggedOutAtMessage=e,t.authenticationInfo&&await c(!0)),n&&(!t.lastLoggedInAtMessage||n>t.lastLoggedInAtMessage)&&(t.lastLoggedInAtMessage=n,t.authenticationInfo||await c(!0))};return window.addEventListener("storage",g),e.enableBackgroundTokenRefresh&&(d.getAuthenticationInfoOrNull(),t.refreshInterval=window.setInterval(d.getAuthenticationInfoOrNull,6e4)),d}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).PropelAuth={})}(this,(function(e){"use strict";var t;function n(t){return new Promise(((n,o)=>{const r=new XMLHttpRequest;r.onreadystatechange=function(){if(r.readyState===XMLHttpRequest.DONE){const s=r.status;if(s>=200&&s<300)try{const o=(t=r.responseText,JSON.parse(t,(function(t,n){if("org_id"===t)this.orgId=n;else if("org_name"===t)this.orgName=n;else if("user_role"===t)this.userRole=(o=n,e.UserRole[o]);else if("access_token"===t)this.accessToken=n;else if("expires_at_seconds"===t)this.expiresAtSeconds=n;else if("org_id_to_org_member_info"===t)this.orgIdToOrgMemberInfo=n;else{if("user_id"!==t)return n;this.userId=n}var o})));n(o)}catch(e){console.error("Unable to process authentication response",e),o({status:500,message:"Unable to process authentication response"})}else 401===s?n(null):o({status:s,message:r.responseText})}var t},r.open("get",`${t}/api/v1/refresh_token`),r.withCredentials=!0,r.ontimeout=function(){o({status:408,message:"Request timed out"})},r.send(null)}))}function o(){return Date.now()/1e3}function r(){return"undefined"!=typeof localStorage}function s(e){if(!r())return null;const t=localStorage.getItem(e);if(!t)return null;const n=parseInt(t,10);return Number.isNaN(n)?null:n}e.UserRole=void 0,(t=e.UserRole||(e.UserRole={}))[t.Member=0]="Member",t[t.Admin=1]="Admin",t[t.Owner=2]="Owner";const a="__PROPEL_AUTH_LOGGED_IN_AT",i="__PROPEL_AUTH_LOGGED_OUT_AT";e.createClient=function(e){!function(e){try{const t=new URL(e.authUrl);e.authUrl=t.origin}catch(e){throw console.error("Invalid authUrl",e),new Error("Unable to initialize auth client")}void 0===e.enableBackgroundTokenRefresh&&(e.enableBackgroundTokenRefresh=!0)}(e);const t={initialLoadFinished:!1,authenticationInfo:null,observers:[],lastLoggedInAtMessage:s(a),lastLoggedOutAtMessage:s(i),authUrl:e.authUrl,refreshInterval:null};function u(e){for(let n=0;n<t.observers.length;n++){const o=t.observers[n];o&&o(e)}}function l(e){var n;const r=null===(n=t.authenticationInfo)||void 0===n?void 0:n.accessToken;t.authenticationInfo=e;const s=null==e?void 0:e.accessToken;!function(e,n){return!e&&(n||!t.initialLoadFinished)}(s,r)?function(e,t){return!t&&e}(s,r)&&(u(!0),function(){const e=o();t.lastLoggedInAtMessage=e,localStorage.setItem(a,String(e))}()):(u(!1),function(){const e=o();t.lastLoggedOutAtMessage=e,localStorage.setItem(i,String(e))}()),t.initialLoadFinished=!0}async function c(e){try{const e=await n(t.authUrl);return l(e),e}catch(n){if(e)return t.authenticationInfo;throw l(null),n}}const d={addLoggedInChangeObserver(e){t.observers.includes(e)?console.error("Observer has been attached already."):e?t.observers.push(e):console.error("Cannot add a null observer")},removeLoggedInChangeObserver(e){const n=t.observers.indexOf(e);-1===n?console.error("Cannot find observer to remove"):t.observers.splice(n,1)},async getAuthenticationInfoOrNull(e){const n=o();if(e)return await c(!1);if(t.authenticationInfo){if(n+240>t.authenticationInfo.expiresAtSeconds){const e=n<t.authenticationInfo.expiresAtSeconds;return await c(e)}return t.authenticationInfo}return await c(!1)},redirectToSignupPage(){window.location.href=`${t.authUrl}/signup`},redirectToLoginPage(){window.location.href=`${t.authUrl}/login`},redirectToAccountPage(){window.location.href=`${t.authUrl}/account`},redirectToOrgPage(e){window.location.href=e?`${t.authUrl}/org?id=${e}`:`${t.authUrl}/org`},redirectToCreateOrgPage(){window.location.href=`${t.authUrl}/create_org`},async logout(e){const n=await(o=t.authUrl,new Promise(((e,t)=>{const n=new XMLHttpRequest;n.onreadystatechange=function(){if(n.readyState===XMLHttpRequest.DONE){const o=n.status;if(o>=200&&o<300){const t=JSON.parse(n.responseText);e(t)}else console.error("Logout error",n.status,n.responseText),t({status:o,message:n.responseText})}},n.open("post",`${o}/api/v1/logout`),n.withCredentials=!0,n.ontimeout=function(){t({status:408,message:"Request timed out"})},n.send(null)})));var o;l(null),e&&(window.location.href=n.redirect_to)},destroy(){t.observers=[],window.removeEventListener("storage",g),t.refreshInterval&&clearInterval(t.refreshInterval)}},g=async function(){if(!r())return;const e=s(i),n=s(a);e&&(!t.lastLoggedOutAtMessage||e>t.lastLoggedOutAtMessage)&&(t.lastLoggedOutAtMessage=e,t.authenticationInfo&&await c(!0)),n&&(!t.lastLoggedInAtMessage||n>t.lastLoggedInAtMessage)&&(t.lastLoggedInAtMessage=n,t.authenticationInfo||await c(!0))};return"undefined"!=typeof window&&(window.addEventListener("storage",g),e.enableBackgroundTokenRefresh&&(d.getAuthenticationInfoOrNull(),t.refreshInterval=window.setInterval(d.getAuthenticationInfoOrNull,6e4))),d}}));
//# sourceMappingURL=javascript.min.js.map
export declare function currentTimeSeconds(): number;
export declare function hasLocalStorage(): boolean;
export declare function hasWindow(): boolean;
export declare function getLocalStorageNumber(key: string): number | null;
{
"name": "@propelauth/javascript",
"description": "A library for managing authentication in the browser, backed by PropelAuth",
"repository": {

@@ -7,3 +8,3 @@ "type": "git",

},
"version": "1.1.1",
"version": "1.1.2",
"keywords": [

@@ -10,0 +11,0 @@ "auth",

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