yoomoney-sdk
Advanced tools
Comparing version 1.0.5 to 1.1.0
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import type * as t from "./api.types"; | ||
@@ -22,10 +23,11 @@ import { QueryStringifiable } from "./fetch"; | ||
export declare class API { | ||
readonly token: string; | ||
readonly endpoint: string; | ||
token: string; | ||
endpoint: string; | ||
agent?: import("http").Agent | ((parsedUrl: import("url").URL) => import("http").Agent) | undefined; | ||
/** | ||
* | ||
* @param {string} token Токен авторизации пользователя | ||
* @param {string} endpoint | ||
* @param {string} endpoint По умолчанию `https://yoomoney.ru/api` | ||
*/ | ||
constructor(token: string, endpoint?: string); | ||
constructor(token: string, endpoint?: string, agent?: import("http").Agent | ((parsedUrl: import("url").URL) => import("http").Agent) | undefined); | ||
/** | ||
@@ -32,0 +34,0 @@ * Позволяет совершить вызов произвольного метода API |
@@ -29,7 +29,8 @@ "use strict"; | ||
* @param {string} token Токен авторизации пользователя | ||
* @param {string} endpoint | ||
* @param {string} endpoint По умолчанию `https://yoomoney.ru/api` | ||
*/ | ||
constructor(token, endpoint = "https://yoomoney.ru/api") { | ||
constructor(token, endpoint = "https://yoomoney.ru/api", agent) { | ||
this.token = token; | ||
this.endpoint = endpoint; | ||
this.agent = agent; | ||
} | ||
@@ -48,3 +49,3 @@ /** | ||
Authorization: `Bearer ${this.token}` | ||
}); | ||
}, this.agent); | ||
const data = await response.json(); | ||
@@ -51,0 +52,0 @@ if (data.error) |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
declare type AuthScope = "account-info" | "operation-history" | "operation-details" | "incoming-transfers" | "payment" | "payment-shop" | "payment-p2p" | "money-source"; | ||
@@ -19,6 +20,7 @@ /** | ||
export declare class Auth { | ||
readonly clientId: string; | ||
readonly redirectUrl: string; | ||
readonly clientSecret?: string | undefined; | ||
readonly endpoint: string; | ||
clientId: string; | ||
redirectUrl: string; | ||
clientSecret?: string | undefined; | ||
endpoint: string; | ||
agent?: import("http").Agent | ((parsedUrl: import("url").URL) => import("http").Agent) | undefined; | ||
/** | ||
@@ -29,5 +31,5 @@ * | ||
* @param {string=} clientSecret Секретное Слово | ||
* @param {string=} endpoint | ||
* @param {string=} endpoint По умолчанию `https://yoomoney.ru/oauth` | ||
*/ | ||
constructor(clientId: string, redirectUrl: string, clientSecret?: string | undefined, endpoint?: string); | ||
constructor(clientId: string, redirectUrl: string, clientSecret?: string | undefined, endpoint?: string, agent?: import("http").Agent | ((parsedUrl: import("url").URL) => import("http").Agent) | undefined); | ||
/** | ||
@@ -34,0 +36,0 @@ * Генерирует html-форму перенаправления пользователя на авторизацию |
@@ -31,5 +31,5 @@ "use strict"; | ||
* @param {string=} clientSecret Секретное Слово | ||
* @param {string=} endpoint | ||
* @param {string=} endpoint По умолчанию `https://yoomoney.ru/oauth` | ||
*/ | ||
constructor(clientId, redirectUrl, clientSecret, endpoint = "https://yoomoney.ru/oauth") { | ||
constructor(clientId, redirectUrl, clientSecret, endpoint = "https://yoomoney.ru/oauth", agent) { | ||
this.clientId = clientId; | ||
@@ -39,2 +39,3 @@ this.redirectUrl = redirectUrl; | ||
this.endpoint = endpoint; | ||
this.agent = agent; | ||
} | ||
@@ -71,3 +72,3 @@ /** | ||
client_secret: this.clientSecret | ||
}); | ||
}, {}, this.agent); | ||
const json = await response.json(); | ||
@@ -74,0 +75,0 @@ if (json.error) |
@@ -1,3 +0,4 @@ | ||
import { Response } from "node-fetch"; | ||
import { RequestInit, Response } from "node-fetch"; | ||
export declare type QueryStringifiable = Record<string, string | number | boolean | ReadonlyArray<string> | ReadonlyArray<number> | ReadonlyArray<boolean> | null | undefined>; | ||
export declare type Agent = RequestInit["agent"]; | ||
/** | ||
@@ -8,4 +9,6 @@ * | ||
* @param {Record<string, string>=} headers Заголовки запроса | ||
* @param {*} agent Агент запроса | ||
* | ||
* @return {Promise<Response>} Ответ | ||
*/ | ||
export declare function fetch(url: string, parameters: QueryStringifiable, headers?: Record<string, string>): Promise<Response>; | ||
export declare function fetch(url: string, parameters: QueryStringifiable, headers?: Record<string, string>, agent?: Agent): Promise<Response>; |
@@ -14,8 +14,11 @@ "use strict"; | ||
* @param {Record<string, string>=} headers Заголовки запроса | ||
* @param {*} agent Агент запроса | ||
* | ||
* @return {Promise<Response>} Ответ | ||
*/ | ||
async function fetch(url, parameters, headers = {}) { | ||
async function fetch(url, parameters, headers = {}, agent) { | ||
return await node_fetch_1.default(url, { | ||
method: "POST", | ||
body: querystring_1.stringify(parameters), | ||
agent, | ||
headers: { | ||
@@ -22,0 +25,0 @@ ...headers, |
{ | ||
"name": "yoomoney-sdk", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "YooMoney typed SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102236
1413