UNPKG

@duosecurity/duo_universal

Version:
18 lines (17 loc) 723 B
"use strict"; // SPDX-FileCopyrightText: 2021 Lukas Hroch // SPDX-FileCopyrightText: 2022 Cisco Systems, Inc. and/or its affiliates // // SPDX-License-Identifier: MIT Object.defineProperty(exports, "__esModule", { value: true }); exports.getTimeInSeconds = exports.generateRandomString = void 0; const crypto_1 = require("crypto"); function bytesToBase64url(s) { return s.toString('base64url'); } const generateRandomString = (length) => { return bytesToBase64url((0, crypto_1.randomBytes)(length)).substring(0, length); }; exports.generateRandomString = generateRandomString; const getTimeInSeconds = (date = new Date(Date.now())) => Math.round(date.getTime() / 1000); exports.getTimeInSeconds = getTimeInSeconds;