@metacall/protocol
Version:
Tool for deploying into MetaCall FaaS platform.
17 lines (16 loc) • 658 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.expiresIn = void 0;
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
const expiresIn = (token) => {
const decoded = jsonwebtoken_1.default.decode(token);
if (typeof decoded === 'string') {
return 0;
}
const now = Date.now() / 1000;
return new Date(((decoded === null || decoded === void 0 ? void 0 : decoded['exp']) || now) * 1000).getTime() - now * 1000;
};
exports.expiresIn = expiresIn;