Files
YouTube.js/typings/lib/utils/Utils.d.ts
LuanRT 84d5edb6f0 refactor: rewrite OAuth and Requester (#90)
* chore: update type declarations

* dev: refactor oauth & requester

* chore: tidy things up

* chore: remove unneeded check
2022-07-04 16:34:02 -03:00

103 lines
2.8 KiB
TypeScript

export class InnertubeError extends Error {
constructor(message: any, info: any);
info: any;
date: Date;
version: any;
}
export class UnavailableContentError extends InnertubeError {
}
export class ParsingError extends InnertubeError {
}
export class DownloadError extends InnertubeError {
}
export class MissingParamError extends InnertubeError {
}
export class NoStreamingDataError extends InnertubeError {
}
export class OAuthError extends InnertubeError {
}
/**
* Utility to help access deep properties of an object.
*
* @param {object} obj - the object.
* @param {string} key - key of the property being accessed.
* @param {string} target - anything that might be inside of the property.
* @param {number} depth - maximum number of nested objects to flatten.
* @param {boolean} safe - if set to true arrays will be preserved.
* @returns {object|object[]}
*/
export function findNode(obj: object, key: string, target: string, depth: number, safe?: boolean): object | object[];
/**
* Creates a trap to intercept property access
* and add utilities to an object.
*
* @param {object} obj
* @returns {object}
*/
export function observe(obj: object): object;
/**
* Returns a random user agent.
*
* @param {string} type - mobile | desktop
* @returns {object}
*/
export function getRandomUserAgent(type: string): object;
/**
* Generates an authentication token from a cookies' sid.
*
* @param {string} sid - Sid extracted from cookies
* @returns {string}
*/
export function generateSidAuth(sid: string): string;
/**
* Generates a random string with the given length.
*
* @param {number} length
* @returns {string}
*/
export function generateRandomString(length: number): string;
/**
* Finds a string between two delimiters.
*
* @param {string} data - the data.
* @param {string} start_string - start string.
* @param {string} end_string - end string.
* @returns {string}
*/
export function getStringBetweenStrings(data: string, start_string: string, end_string: string): string;
/**
* Converts strings in camelCase to snake_case.
*
* @param {string} string The string in camelCase.
* @returns {string}
*/
export function camelToSnake(string: string): string;
/**
* Checks if a given client is valid.
*
* @param {string} client
* @returns {boolean}
*/
export function isValidClient(client: string): boolean;
/**
* Throws an error if given parameters are undefined.
*
* @param {object} params
* @returns {void}
*/
export function throwIfMissing(params: object): void;
/**
* Converts time (h:m:s) to seconds.
*
* @param {string} time
* @returns {number} seconds
*/
export function timeToSeconds(time: string): number;
/**
* Turns the ntoken transform data into a valid json array
*
* @param {string} data
* @returns {string}
*/
export function refineNTokenData(data: string): string;