'use strict'; const Axios = require('axios'); const Utils = require('./Utils'); const Constants = require('./Constants'); const EventEmitter = require('events'); const Uuid = require("uuid"); class OAuth extends EventEmitter { constructor(creds) { super(); // Default interval between requests when waiting for authorization. this.refresh_interval = 5; // OAuth URLs: this.oauth_code_url = `${Constants.URLS.YT_BASE_URL}/o/oauth2/device/code`; this.oauth_token_url = `${Constants.URLS.YT_BASE_URL}/o/oauth2/token`; // Used to check whether an access token is valid or not. this.guide_url = `${Constants.URLS.YT_BASE_URL}/youtubei/v1/guide`; // These are always the same, so we shouldn't have any problems for now. this.model_name = Constants.OAUTH.MODEL_NAME; this.grant_type = Constants.OAUTH.GRANT_TYPE; this.scope = Constants.OAUTH.SCOPE; // Script that contains important information such as client id and client secret. this.auth_script_regex = /