UNPKG

yoomoney-sdk

Version:

⭐ Typed YooMoney Wallet SDK for NodeJS. Supported API's: Auth, Wallet & Notifications

62 lines (61 loc) 2.59 kB
import { Agent } from './fetch'; export type AuthScope = "account-info" | "operation-history" | "operation-details" | "incoming-transfers" | "payment" | "payment-shop" | "payment-p2p" | "money-source" | (string & {}); export declare const AuthScope: Record<string, AuthScope>; /** * Ошибка в процессе авторизации * @class YMAuthError */ export declare class YMAuthError extends Error { code: string; /** * * @param {string} code Код ошибки */ constructor(code: string); } /** * Реализует всё необходимое для [авторизации через YooMoney](https://yoomoney.ru/docs/wallet/using-api/authorization/basics) * * @see {@link https://yoomoney.ru/docs/wallet/using-api/authorization/basics|Описание протокола} * @class Auth */ export declare class Auth { clientId: string; redirectUrl: string; clientSecret?: string | undefined; endpoint: string; agent?: Agent | undefined; /** * Creates an instance of Auth. * @param {string} clientId ID приложения * @param {string} redirectUrl URL-перенаправления * @param {string=} [clientSecret] Секретное Слово * @param {string} [endpoint="https://yoomoney.ru/oauth"] По умолчанию `https://yoomoney.ru/oauth` * @param {Agent=} [agent] HTTP Agent для использования с Proxy */ constructor(clientId: string, redirectUrl: string, clientSecret?: string | undefined, endpoint?: string, agent?: Agent | undefined); /** * Генерирует html-форму перенаправления пользователя на авторизацию * * @param {AuthScope[]} scope * @param {string=} instanceName * @return {string} */ getAuthForm(scope: AuthScope[], instanceName?: string): string; /** * Генерирует URL для перенаправления пользователя на авторизацию * * @param {AuthScope[]} scope * @param {string=} instanceName * @return {string} */ getAuthUrl(scope: AuthScope[], instanceName?: string): string; /** * Обменивает временный токен на постоянный токен авторизации * * @throws {YMAuthError} * @param {string} code Временный токен (authorization code) * @return {Promise<string>} Токен авторизации */ exchangeCode2Token(code: string): Promise<string>; }