Socket
Socket
Sign inDemoInstall

@ombori/grid-signals

Package Overview
Dependencies
Maintainers
18
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ombori/grid-signals - npm Package Compare versions

Comparing version 2.141.0 to 2.141.1

dist/utils/datetime.d.ts

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [2.141.1](https://github.com/ombori/gridapp/compare/v2.141.0...v2.141.1) (2021-12-20)
### Bug Fixes
* proper session lastactivity dif ([4799f14](https://github.com/ombori/gridapp/commit/4799f146d2869b4ddb2ef135795334239cf7d5fa))
# [2.141.0](https://github.com/ombori/gridapp/compare/v2.140.4...v2.141.0) (2021-12-20)

@@ -8,0 +19,0 @@

17

dist/grid-signals.js

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

const session_1 = require("./utils/session");
const datetime_1 = require("./utils/datetime");
let isOnline = false;

@@ -98,4 +99,4 @@ is_online_1.isOnlineSubscription().subscribe((nextOnline) => {

this.instance.sessionCreated = sessionCreated;
this.updateLastActivity();
this.startSessionTracker();
this.updateLastActivity();
return Promise.all([

@@ -137,2 +138,3 @@ ...(!!initParams.sendAppStartOnInit ? [this.sendAppStart()] : []),

this.instance.sessionCreated = sessionCreated;
this.updateLastActivity();
return this.sendOrCacheData(types_1.DataRequestTypeEnum.SESSION, instance_helper_1.getSessionFromInstance(this.instance));

@@ -181,11 +183,6 @@ });

setInterval(() => {
const sessionAndLastActivity = session_1.checkAndCreateSessionIfExpires({
maxSessionLastActivityMins: this.maxSessionLastActivityMins,
});
if (sessionAndLastActivity) {
this.instance.sessionId = sessionAndLastActivity.sessionId;
this.instance.sessionCreated = sessionAndLastActivity.sessionCreated;
if (sessionAndLastActivity.lastActivity) {
this.instance.sessionCreated = sessionAndLastActivity.lastActivity;
}
const isExpiredSession = datetime_1.getDifInMins(get_date_string_1.default(), this.instance.lastActivity) >=
this.maxSessionLastActivityMins;
if (isExpiredSession) {
this.createSession();
}

@@ -192,0 +189,0 @@ }, 60000);

@@ -10,14 +10,3 @@ export declare const supportsSessionStorage: () => boolean;

};
export declare const checkAndCreateSessionIfExpires: ({ maxSessionLastActivityMins, }: {
maxSessionLastActivityMins: number;
}) => {
sessionId: string;
sessionCreated: string;
lastActivity: string;
} | {
sessionId: string;
sessionCreated: string;
lastActivity?: undefined;
} | null;
export declare const getLastActivityCache: () => string | null;
export declare const setLastActivityCache: (dateString: string) => string | false;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.setLastActivityCache = exports.getLastActivityCache = exports.checkAndCreateSessionIfExpires = exports.generateSession = exports.cacheSession = exports.supportsSessionStorage = void 0;
exports.setLastActivityCache = exports.getLastActivityCache = exports.generateSession = exports.cacheSession = exports.supportsSessionStorage = void 0;
const uuid_1 = require("uuid");

@@ -12,6 +12,3 @@ const lodash_once_1 = __importDefault(require("lodash.once"));

const constants_1 = require("../constants");
const getDifInMins = (date, dateToCompare) => {
const dif = new Date(date).getTime() - new Date(dateToCompare).getTime();
return Math.round(dif / 60000);
};
const datetime_1 = require("./datetime");
exports.supportsSessionStorage = lodash_once_1.default(() => {

@@ -53,3 +50,3 @@ const value = '_OMBORI_GRID_SIGNALS_SESSION_STORAGE_TEST';

if (lastActivity) {
const isAfterMins = getDifInMins(get_date_string_1.default(), lastActivity) >= maxSessionLastActivityMins;
const isAfterMins = datetime_1.getDifInMins(get_date_string_1.default(), lastActivity) >= maxSessionLastActivityMins;
if (!isAfterMins) {

@@ -65,30 +62,2 @@ return { sessionId, sessionCreated };

};
exports.checkAndCreateSessionIfExpires = ({ maxSessionLastActivityMins, }) => {
if (!exports.supportsSessionStorage())
return null;
const cachedSession = getCachedSession();
const lastActivity = exports.getLastActivityCache();
if (!cachedSession) {
throw new Error('Cached session not found');
}
if (!lastActivity) {
throw new Error('Cached last activity not found');
}
const isAfterMins = getDifInMins(get_date_string_1.default(), lastActivity) >= maxSessionLastActivityMins;
if (isAfterMins) {
const newSession = exports.generateSession({
forceCreateNewSession: true,
maxSessionLastActivityMins,
});
return {
sessionId: newSession.sessionId,
sessionCreated: newSession.sessionCreated,
lastActivity: newSession.sessionCreated,
};
}
return {
sessionId: cachedSession.sessionId,
sessionCreated: cachedSession.sessionCreated,
};
};
exports.getLastActivityCache = () => {

@@ -95,0 +64,0 @@ try {

{
"name": "@ombori/grid-signals",
"version": "2.141.0",
"version": "2.141.1",
"main": "dist/index.js",

@@ -35,3 +35,3 @@ "scripts": {

},
"gitHead": "e66ff6825881950651614931c184cd2a89ffd3b7"
"gitHead": "abb6d50433f11e825a4c60da4298688e102227f3"
}

@@ -40,8 +40,4 @@ import { v4 as uuid } from 'uuid';

} from './api/api';
import {
generateSession,
cacheSession,
checkAndCreateSessionIfExpires,
setLastActivityCache,
} from './utils/session';
import { generateSession, cacheSession, setLastActivityCache } from './utils/session';
import { getDifInMins } from './utils/datetime';

@@ -141,5 +137,5 @@ let isOnline = false;

this.instance.sessionCreated = sessionCreated;
this.updateLastActivity();
this.startSessionTracker();
this.updateLastActivity();
return Promise.all([

@@ -187,2 +183,4 @@ ...(!!initParams.sendAppStartOnInit ? [this.sendAppStart()] : []),

this.updateLastActivity();
return this.sendOrCacheData(

@@ -256,11 +254,7 @@ DataRequestTypeEnum.SESSION,

setInterval(() => {
const sessionAndLastActivity = checkAndCreateSessionIfExpires({
maxSessionLastActivityMins: this.maxSessionLastActivityMins,
});
if (sessionAndLastActivity) {
this.instance.sessionId = sessionAndLastActivity.sessionId;
this.instance.sessionCreated = sessionAndLastActivity.sessionCreated;
if (sessionAndLastActivity.lastActivity) {
this.instance.sessionCreated = sessionAndLastActivity.lastActivity;
}
const isExpiredSession =
getDifInMins(getDateString(), this.instance.lastActivity) >=
this.maxSessionLastActivityMins;
if (isExpiredSession) {
this.createSession();
}

@@ -267,0 +261,0 @@ }, 60000);

@@ -5,2 +5,3 @@ import { v4 as uuid } from 'uuid';

import { SESSION_CACHE_KEY, LAST_ACTIVITY_CACHE_KEY } from '../constants';
import { getDifInMins } from './datetime';

@@ -12,7 +13,2 @@ type CachedSessionObj = {

const getDifInMins = (date: string, dateToCompare: string) => {
const dif = new Date(date).getTime() - new Date(dateToCompare).getTime();
return Math.round(dif / 60000);
};
export const supportsSessionStorage = once(() => {

@@ -83,41 +79,2 @@ const value = '_OMBORI_GRID_SIGNALS_SESSION_STORAGE_TEST';

export const checkAndCreateSessionIfExpires = ({
maxSessionLastActivityMins,
}: {
maxSessionLastActivityMins: number;
}) => {
if (!supportsSessionStorage()) return null;
const cachedSession = getCachedSession();
const lastActivity = getLastActivityCache();
if (!cachedSession) {
throw new Error('Cached session not found');
}
if (!lastActivity) {
throw new Error('Cached last activity not found');
}
const isAfterMins =
getDifInMins(getDateString(), lastActivity) >= maxSessionLastActivityMins;
if (isAfterMins) {
const newSession = generateSession({
forceCreateNewSession: true,
maxSessionLastActivityMins,
});
return {
sessionId: newSession.sessionId,
sessionCreated: newSession.sessionCreated,
lastActivity: newSession.sessionCreated,
};
}
return {
sessionId: cachedSession.sessionId,
sessionCreated: cachedSession.sessionCreated,
};
};
export const getLastActivityCache = () => {

@@ -124,0 +81,0 @@ try {

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