tiny-essentials
Version:
Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.
25 lines • 1.23 kB
text/typescript
/**
* Refreshes the Discord token using the provided refresh token.
*
* @async
* @function refreshToken
* @param {Record<string, any>} req - The request object containing query parameters and csrfToken.
* @param {Record<string, any>} cfg - The configuration object containing auth and state configurations.
* @param {boolean} existSession - A flag indicating if the user session exists.
*
* @returns {Promise<Record<string, any>>} Resolves to an object containing the status of the refresh and the new token data, or rejects with an error object.
*
* @throws {Record<string, any>} Rejects with an error object containing the following properties:
* - `code` {number} The error code (e.g., 401 for invalid CSRF token, 500 for server errors).
* - `message` {string} The error message describing the issue.
*
* @example
* const result = await refreshToken(req, cfg, existSession);
* if (result.refreshed) {
* console.log('Token refreshed:', result.tokenRequest);
* } else {
* console.log('Token refresh failed');
* }
*/
export default function refreshToken(req: Record<string, any>, cfg: Record<string, any>, existSession: boolean): Promise<Record<string, any>>;
//# sourceMappingURL=refreshToken.d.mts.map