UNPKG

eightsleep

Version:
31 lines 1.08 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const baseerr_1 = __importDefault(require("baseerr")); class InvalidSessionError extends baseerr_1.default { } function validateSession(session) { if (typeof session != 'object') { throw new InvalidSessionError('invalid session', { session }); } let { expirationDate, userId, token } = session; expirationDate = new Date(expirationDate); if (isNaN(expirationDate.valueOf())) { throw new InvalidSessionError('invalid expirationDate', { session }); } if (typeof userId != 'string') { throw new InvalidSessionError('invalid userId', { session }); } if (typeof token != 'string') { throw new InvalidSessionError('invalid token', { session }); } return { expirationDate, userId, token, }; } exports.default = validateSession; //# sourceMappingURL=validateSession.js.map