"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkCookieAndUniverseIdInternalAsync = void 0;
//C:\buildAgent\671a0da0ba061c98de801409dbc57d7e\Packages\NodeJS\RbxMessagingService\src\Helpers\Internal\checkCookieAndPlaceIdInternalAsync.ts
//C:\buildAgent\671a0da0ba061c98de801409dbc57d7e\Packages\NodeJS\RbxMessagingService\src\Helpers\InitAuthenticatedUser.ts
const constants_1 = require("../../util/constants");
const axios_1 = __importDefault(require("axios"));
const checkCookieAndUniverseIdInternalAsync = (cookie, universeId) => {
    return new Promise((resolve, reject) => {
        if (cookie.length === 0)
            return reject("Cookie name can't be empty");
        if (universeId < 1)
            return reject('The placeId is required to at least be >1');
        if (!cookie.match(constants_1.cookieWarningCapture))
            return reject("Cookie isn't valid, it requires the warning text to persistent");
        axios_1.default('https://users.roblox.com/v1/users/authenticated', {
            method: 'GET',
            headers: { Cookie: '.ROBLOSECURITY=' + cookie },
        })
            .catch((err) => {
            if (err.statusCode === 401)
                return reject("Cookie isn't valid, it threw a 401");
            else
                return reject(err.message);
        })
            .then(() => resolve());
    });
};
exports.checkCookieAndUniverseIdInternalAsync = checkCookieAndUniverseIdInternalAsync;
