129 lines
3.9 KiB
JavaScript
129 lines
3.9 KiB
JavaScript
// Module ID: 6334
|
|
// Function ID: 56959
|
|
// Name: updateSession
|
|
// Dependencies: [6310, 6311, 6335, 6325, 6322, 6317]
|
|
// Exports: closeSession, makeSession
|
|
|
|
// Module 6334 (updateSession)
|
|
import module_6310 from "module_6310";
|
|
import consoleSandbox from "consoleSandbox";
|
|
import "SyncPromise";
|
|
|
|
function updateSession(ipAddress) {
|
|
if (arguments.length > 1) {
|
|
if (undefined !== arguments[1]) {
|
|
let obj = arguments[1];
|
|
}
|
|
if (obj.user) {
|
|
if (tmp) {
|
|
ipAddress.ipAddress = obj.user.ip_address;
|
|
}
|
|
if (!tmp2) {
|
|
ipAddress.did = obj.user.id || obj.user.email || obj.user.username;
|
|
}
|
|
tmp = !ipAddress.ipAddress && obj.user.ip_address;
|
|
tmp2 = ipAddress.did || obj.did;
|
|
}
|
|
let timestamp = obj.timestamp;
|
|
if (!timestamp) {
|
|
timestamp = require(6325) /* dateTimestampInSeconds */.timestampInSeconds();
|
|
const obj2 = require(6325) /* dateTimestampInSeconds */;
|
|
}
|
|
ipAddress.timestamp = timestamp;
|
|
if (obj.abnormal_mechanism) {
|
|
ipAddress.abnormal_mechanism = obj.abnormal_mechanism;
|
|
}
|
|
if (obj.ignoreDuration) {
|
|
ipAddress.ignoreDuration = obj.ignoreDuration;
|
|
}
|
|
if (!obj.sid) {
|
|
if (undefined !== obj.init) {
|
|
ipAddress.init = obj.init;
|
|
}
|
|
if (tmp7) {
|
|
const _HermesInternal = HermesInternal;
|
|
ipAddress.did = "" + obj.did;
|
|
}
|
|
if ("number" === typeof obj.started) {
|
|
ipAddress.started = obj.started;
|
|
}
|
|
if (ipAddress.ignoreDuration) {
|
|
ipAddress.duration = undefined;
|
|
} else if ("number" === typeof obj.duration) {
|
|
ipAddress.duration = obj.duration;
|
|
} else {
|
|
const diff = ipAddress.timestamp - ipAddress.started;
|
|
let num4 = 0;
|
|
if (diff >= 0) {
|
|
num4 = diff;
|
|
}
|
|
ipAddress.duration = num4;
|
|
}
|
|
if (obj.release) {
|
|
ipAddress.release = obj.release;
|
|
}
|
|
if (obj.environment) {
|
|
ipAddress.environment = obj.environment;
|
|
}
|
|
if (tmp10) {
|
|
ipAddress.ipAddress = obj.ipAddress;
|
|
}
|
|
if (tmp11) {
|
|
ipAddress.userAgent = obj.userAgent;
|
|
}
|
|
if ("number" === typeof obj.errors) {
|
|
ipAddress.errors = obj.errors;
|
|
}
|
|
if (obj.status) {
|
|
ipAddress.status = obj.status;
|
|
}
|
|
} else {
|
|
if (32 === obj.sid.length) {
|
|
let sid = obj.sid;
|
|
} else {
|
|
sid = require(6322) /* getFirstException */.uuid4();
|
|
const obj3 = require(6322) /* getFirstException */;
|
|
}
|
|
ipAddress.sid = sid;
|
|
}
|
|
}
|
|
obj = {};
|
|
}
|
|
|
|
export const closeSession = function closeSession(status, status2) {
|
|
if (status2) {
|
|
let obj = { status: status2 };
|
|
} else if ("ok" === status.status) {
|
|
obj = { status: "exited" };
|
|
}
|
|
updateSession(status, {});
|
|
};
|
|
export const makeSession = function makeSession(arg0) {
|
|
obj = obj(6325);
|
|
const timestampInSecondsResult = obj.timestampInSeconds();
|
|
obj = { sid: null, init: true, timestamp: null, started: null, duration: 0, status: "ok", errors: 0, ignoreDuration: false };
|
|
obj.sid = obj(6322).uuid4();
|
|
obj.timestamp = timestampInSecondsResult;
|
|
obj.started = timestampInSecondsResult;
|
|
obj.toJSON = function toJSON() {
|
|
obj = obj(outer1_1[5]);
|
|
obj = { sid: "" + obj.sid, init: obj.init };
|
|
obj.started = new Date(1000 * obj.started).toISOString();
|
|
const date = new Date(1000 * obj.started);
|
|
obj.timestamp = new Date(1000 * obj.timestamp).toISOString();
|
|
({ status: obj2.status, errors: obj2.errors } = obj);
|
|
if ("number" === typeof obj.did) {
|
|
const _HermesInternal = HermesInternal;
|
|
const combined = "" + tmp.did;
|
|
}
|
|
obj.did = combined;
|
|
({ duration: obj2.duration, abnormal_mechanism: obj2.abnormal_mechanism } = obj);
|
|
obj.attrs = { release: obj.release, environment: obj.environment, ip_address: obj.ipAddress, user_agent: obj.userAgent };
|
|
return obj.dropUndefinedKeys(obj);
|
|
};
|
|
if (arg0) {
|
|
updateSession(obj, arg0);
|
|
}
|
|
return obj;
|
|
};
|
|
export { updateSession };
|