Socket
Socket
Sign inDemoInstall

@screencloud/auth-sdk

Package Overview
Dependencies
Maintainers
6
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@screencloud/auth-sdk - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

build/lib/UnixDate.d.ts

3

build/Auth.js

@@ -71,2 +71,3 @@ "use strict";

var event_emitter_1 = require("@screencloud/event-emitter");
var UnixDate_1 = require("./lib/UnixDate");
function isNonEmptyString(str) {

@@ -323,3 +324,3 @@ return typeof str === 'string' && !!str.trim();

// cached payload expires soon
else if (this.cache.session && this.cache.session.claims.exp - (new Date().getTime()) < 1000 * 60 * 2) {
else if (this.cache.session && (this.cache.session.claims.exp - UnixDate_1.UnixDate.now()) < 60 * 2) {
this.log('shouldRefresh()', 'cached payload expires soon');

@@ -326,0 +327,0 @@ return true;

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

email: 'bob@example.com',
exp: Date.now() + (1000 * 60 * 60),
exp: Math.floor(Date.now() / 1000) + (60 * 60),
},

@@ -238,15 +238,15 @@ token: 'eyFooFoo',

var auth = new Auth_1.Auth(defaultConfig);
// false by default
// true by default
expect(auth.shouldRefresh()).toBeTruthy();
// true if valid
// false if valid
auth.setCache(defaultSession);
expect(auth.shouldRefresh()).toBeFalsy();
});
it('returns true if exp is near is outdated', function () {
it('returns true if exp is near or outdated', function () {
var auth = new Auth_1.Auth(defaultConfig);
// fresh session with long living date
auth.setCache(defaultSession);
// fresh session with 2+ minutes lifetime remaining
auth.setCache(__assign(__assign({}, defaultSession), { claims: __assign(__assign({}, defaultSession.claims), { exp: Math.floor(Date.now() / 1000) + (60 * 2) + 2 }) }));
expect(auth.shouldRefresh()).toBeFalsy();
// same session with changed exp-claim
auth.setCache(__assign(__assign({}, defaultSession), { claims: __assign(__assign({}, defaultSession.claims), { exp: Date.now() + (1000 * 60 * 2) - 1 }) }));
// same session with 2- minutes lifetime remaining
auth.setCache(__assign(__assign({}, defaultSession), { claims: __assign(__assign({}, defaultSession.claims), { exp: Math.floor(Date.now() / 1000) + (60 * 2) - 2 }) }));
expect(auth.shouldRefresh()).toBeTruthy();

@@ -263,2 +263,11 @@ });

});
it('returns false if session is cached and valid for another 2+ minutes', function () {
var auth = new Auth_1.Auth(defaultConfig);
// fresh session with long living date
auth.setCache(defaultSession);
expect(auth.shouldRefresh()).toBeFalsy();
// same session with changed exp-claim
auth.setCache(__assign(__assign({}, defaultSession), { claims: __assign(__assign({}, defaultSession.claims), { exp: Date.now() + (1000 * 60 * 2) + 5 }) }));
expect(auth.shouldRefresh()).toBeFalsy();
});
});

@@ -265,0 +274,0 @@ describe('refresh()', function () {

@@ -67,3 +67,3 @@ {

},
"version": "2.0.0"
"version": "2.0.1"
}
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