Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qiwi-sdk

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qiwi-sdk - npm Package Compare versions

Comparing version 3.6.7 to 3.6.8

coverage/lcov-report/apis/api.ts.html

9

dist/cjs/apis/shared/http.js

@@ -123,8 +123,5 @@ "use strict";

statusCode: axiosResponse.status,
body:
axiosResponse.data !== undefined
? ((_a = request.parseResponse) !== null && _a !== void 0 ? _a : _)(
axiosResponse.data
)
: undefined,
body: ((_a = request.parseResponse) !== null && _a !== void 0 ? _a : _)(
axiosResponse.data
),
request

@@ -131,0 +128,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const USER_AGENT = "qiwi-sdk/3.6.7 (+https://npmjs.com/package/qiwi-sdk)";
const USER_AGENT = "qiwi-sdk/3.6.8 (+https://npmjs.com/package/qiwi-sdk)";
exports.USER_AGENT = USER_AGENT;

@@ -42,3 +42,2 @@ QIWI SDK / [Modules](modules.md)

- **Lot of [examples](#examples)**.
- [**`Express`** integration](#express-integration)
3. **Reliable.** The library is written in **TypeScript** and covered by tests.

@@ -55,2 +54,3 @@ 4. [**Secure.**](./SECURITY.md) The library has only 3 dependencies and is constantly scanned by Code QL and [Snyk](https://snyk.io/advisor/npm-package/qiwi-sdk) for vulnerabilities.

- "Qiwi Master" Card API.
- [`Express` integration](#express-integration) out of the box

@@ -57,0 +57,0 @@ Language: [Русский](./README.ru.md) | **English**

@@ -26,15 +26,9 @@ # QIWI SDK

1. **Полная.** Покрывает следующие API:
- API Кошелька - [Wallet Personal](https://developer.qiwi.com/ru/qiwi-wallet-personal/);
- P2P Счетов - [P2P Payments](https://developer.qiwi.com/ru/p2p-payments/).
2. **Простая.** Все методы названы как в документации QIWI и собраны в подклассы. Ко всем методам есть комментарии JSDoc.
- **Много [примеров](#примеры)**.
- [Интеграция с **`Express`**](#интеграция-с-express)
3. **Надёжная.** Библиотека написана на **TypeScript** и покрыта тестами.
4. [**Безопасная.**](./SECURITY.md) У библиотеки всего 3 зависимости, и она постоянно сканируется Code QL и [Snyk](https://snyk.io/advisor/npm-package/qiwi-sdk) на наличие уязвимостей.
5. **Совместимая.** Код с версии `1.1.0` (18 янв. 2020) будет работать на версии `3.1.0` (26 апр. 2022) с незначительными изменениями. Так-же `qiwi-sdk` предоставляет классы совместимости для упрощения миграции с похожих библиотек.
- [Миграция с версии 1 на 2](./docs/migrations/from-1-to-2);

@@ -44,8 +38,7 @@ - [Миграция с версии 2 на 3](./docs/migrations/from-2-to-3.md);

- [Миграция с `@qiwi/bill-payments-node-js-sdk`](./docs/migrations/from-bill-payments-sdk.md).
6. **Мощная.** Поддерживается работа с [**прокси**](./examples/7-proxy.js), и даже редко используемые API:
- Персональные WebHook'и;
- Блокировка метода оплаты P2P;
- API работы с картами Qiwi Master.
- [Интеграция с **`Express`**](#интеграция-с-express) из коробки

@@ -52,0 +45,0 @@ Язык: **Русский** | [English](./README.md)

{
"name": "qiwi-sdk",
"version": "3.6.7",
"version": "3.6.8",
"description": "⭐ Typed QIWI Wallet SDK. Supported API's: Personal & P2P Bill Payments",

@@ -5,0 +5,0 @@ "keywords": [

@@ -40,3 +40,2 @@ # QIWI SDK

- **Lot of [examples](#examples)**.
- [**`Express`** integration](#express-integration)
3. **Reliable.** The library is written in **TypeScript** and covered by tests.

@@ -53,2 +52,3 @@ 4. [**Secure.**](./SECURITY.md) The library has only 3 dependencies and is constantly scanned by Code QL and [Snyk](https://snyk.io/advisor/npm-package/qiwi-sdk) for vulnerabilities.

- "Qiwi Master" Card API.
- [`Express` integration](#express-integration) out of the box

@@ -55,0 +55,0 @@ Language: [Русский](./README.ru.md) | **English**

@@ -26,15 +26,9 @@ # QIWI SDK

1. **Полная.** Покрывает следующие API:
- API Кошелька - [Wallet Personal](https://developer.qiwi.com/ru/qiwi-wallet-personal/);
- P2P Счетов - [P2P Payments](https://developer.qiwi.com/ru/p2p-payments/).
2. **Простая.** Все методы названы как в документации QIWI и собраны в подклассы. Ко всем методам есть комментарии JSDoc.
- **Много [примеров](#примеры)**.
- [Интеграция с **`Express`**](#интеграция-с-express)
3. **Надёжная.** Библиотека написана на **TypeScript** и покрыта тестами.
4. [**Безопасная.**](./SECURITY.md) У библиотеки всего 3 зависимости, и она постоянно сканируется Code QL и [Snyk](https://snyk.io/advisor/npm-package/qiwi-sdk) на наличие уязвимостей.
5. **Совместимая.** Код с версии `1.1.0` (18 янв. 2020) будет работать на версии `3.1.0` (26 апр. 2022) с незначительными изменениями. Так-же `qiwi-sdk` предоставляет классы совместимости для упрощения миграции с похожих библиотек.
- [Миграция с версии 1 на 2](./docs/migrations/from-1-to-2);

@@ -44,8 +38,7 @@ - [Миграция с версии 2 на 3](./docs/migrations/from-2-to-3.md);

- [Миграция с `@qiwi/bill-payments-node-js-sdk`](./docs/migrations/from-bill-payments-sdk.md).
6. **Мощная.** Поддерживается работа с [**прокси**](./examples/7-proxy.js), и даже редко используемые API:
- Персональные WebHook'и;
- Блокировка метода оплаты P2P;
- API работы с картами Qiwi Master.
- [Интеграция с **`Express`**](#интеграция-с-express) из коробки

@@ -52,0 +45,0 @@ Язык: **Русский** | [English](./README.md)

@@ -7,2 +7,7 @@ import { Recipients, DetectorCompat, DetectorError, Detector } from "../apis";

test("Instantiation", () => {
expect(new Detector()).toBeInstanceOf(Detector);
expect(new Detector({})).toBeInstanceOf(Detector);
});
test("Phone", async () => {

@@ -9,0 +14,0 @@ // Префикс 7920 принадлежит Мегафону

@@ -36,2 +36,4 @@ import axios from "axios";

expect(P2p.create("")).toBeInstanceOf(P2p);
expect(new P2p()).toBeInstanceOf(P2p);
expect(new P2p({})).toBeInstanceOf(P2p);
});

@@ -79,7 +81,23 @@

expect(qiwi.checkNotificationSignature(hash, response)).toBe(true);
expect(
P2P.patchPayUrl(response.payUrl, { paySource: P2P.PaySource.QIWI })
).toContain("paySource=qw");
const url = P2P.patchPayUrl(response.payUrl, {
paySource: P2P.PaySource.QIWI,
successUrl: "https://example.com"
});
expect(url).toContain("paySource=qw");
expect(url).toContain("successUrl");
expect(url).toContain("example.com");
});
test("[v3] Can create bill", async () => {
const response = await qiwi.createBill(
{
amount
},
billId
);
expect(new Date(response.expirationDateTime)).toBeInstanceOf(Date);
});
test("Can get bill status", async () => {

@@ -86,0 +104,0 @@ const response = await qiwi.billStatus(billId);

@@ -9,2 +9,3 @@ /* eslint-disable unicorn/consistent-function-scoping */

Currency,
DetectorError,
formatOffsetDate,

@@ -39,2 +40,4 @@ PaymentHistorySource,

expect(Wallet.create("")).toBeInstanceOf(Wallet);
expect(new Wallet()).toBeInstanceOf(Wallet);
expect(new Wallet({})).toBeInstanceOf(Wallet);
});

@@ -44,7 +47,12 @@

const wallet = await Wallet.createAndFetchWalletId(
process.env.QIWI_TOKEN as string
);
expect(wallet.options.walletId).toBe(process.env.QIWI_WALLET as string);
});
test("[v3] Wallet id can be fetched (w/ setupHttp)", async () => {
const wallet = await Wallet.createAndFetchWalletId(
process.env.QIWI_TOKEN as string,
{
setupHttp(options) {
return options;
}
setupHttp: (http) => http
}

@@ -121,4 +129,34 @@ );

account: SAMPLE_PHONE,
amount: 1e6 // 1 лям
});
}));
test("[v3] Can't send 1 million rubles to unknown wallet", () =>
expectToThrow(WalletApiShortError, async () => {
const commission = await qiwi.getCommission(
Recipients.QIWI,
SAMPLE_PHONE,
100
);
expect(typeof commission).toBe("number");
await qiwi.payments.pay({
account: SAMPLE_PHONE,
amount: 1e6 // 1 лям
});
}));
test("[v3] Can't send 1 million rubles to unknown wallet (w/ comment)", () =>
expectToThrow(WalletApiShortError, async () => {
const commission = await qiwi.getCommission(
Recipients.QIWI,
SAMPLE_PHONE,
100
);
expect(typeof commission).toBe("number");
await qiwi.payments.pay({
account: SAMPLE_PHONE,
amount: 1e6, // 1 лям
comment: "Test npmjs.com/package/qiwi-sdk#pay2"
comment: "Test"
});

@@ -134,3 +172,2 @@ }));

accountCurrency: Currency.KZT,
comment: "Test npmjs.com/package/qiwi-sdk#payments.quickPay",
commissionPayer: CommissionPayer.RECEIVER,

@@ -142,2 +179,14 @@ provider: "card"

test("Cant send 1m rub to unknown provider", async () => {
await expectToThrow(DetectorError, async () => {
await qiwi.payments.quickPay({
account: SAMPLE_CARD,
amount: 1e6,
accountCurrency: Currency.KZT,
commissionPayer: CommissionPayer.RECEIVER,
provider: "unknown" as any
});
});
});
test("Cant send 1m rub to unknown phone", async () => {

@@ -163,2 +212,11 @@ await expectToThrow(WalletApiShortError, async () => {

test("Cant send 1m rub to unknown wallet", async () => {
await expectToThrow(WalletApiShortError, async () => {
await qiwi.payments.quickPay({
account: SAMPLE_PHONE,
amount: 1e6
});
});
});
test("Cant send 1m rub to unknown yoomoney", async () => {

@@ -292,3 +350,5 @@ await expectToThrow(WalletApiShortError, async () => {

test("[v3] Can get agent and options", () => {
qiwi.agent = undefined;
expect(qiwi).toHaveProperty("agent");
expect(qiwi.options).toMatchObject({

@@ -295,0 +355,0 @@ token: process.env.QIWI_TOKEN as string,

@@ -0,1 +1,3 @@

import { createHmac, randomBytes } from "crypto";
import { compareHmac, parseQuerystring } from "../apis";
import { promise, resolveHeaderValue } from "../apis/p2p/p2p.middleware";

@@ -54,2 +56,23 @@ import { getOwnProperty, getOwnPropertyDeep } from "../apis/shared/get";

});
test("parseQuerystring", () => {
expect(parseQuerystring("a[0]=1")).toEqual({ a: [1] });
});
test("Compare HMAC", () => {
const algorithm = "sha512";
const data = randomBytes(16);
const key = randomBytes(8);
const digest = createHmac(algorithm, key).update(data).digest();
const result = compareHmac({
algorithm,
key,
data,
digest
});
expect(result).toBeTruthy();
});
});

@@ -33,3 +33,2 @@ import type { SimpleJsonHttp } from "./shared";

set agent(agent: any) {
/* istanbul ignore next */
this.options.http.client.options.agent = agent;

@@ -36,0 +35,0 @@ }

@@ -21,4 +21,2 @@ import type { AnyResponse } from "../shared";

protected _extractProvider(response: AnyResponse): number {
// Legacy проверка ответа
/* istanbul ignore next */
if (response.code.value !== "0") throw new DetectorError(response.message);

@@ -25,0 +23,0 @@

@@ -95,5 +95,3 @@ import type { RequestHandler } from "express";

constructor({
/* istanbul ignore next */
publicKey = "",
/* istanbul ignore next */
secretKey = "",

@@ -100,0 +98,0 @@ http = P2p.httpClientFactory(secretKey)

@@ -14,3 +14,3 @@ import { createHmac, timingSafeEqual } from "crypto";

if (typeof data === "string") return Buffer.from(data, "hex");
/* istanbul ignore next */
return data;

@@ -17,0 +17,0 @@ }

@@ -66,3 +66,2 @@ import axios, { AxiosResponse, Method } from "axios";

function _<T>(argument: T): T {
/* istanbul ignore next */
return argument;

@@ -104,3 +103,2 @@ }

const okStatusCodes = new Set(
/* istanbul ignore next */
request.okStatusCodes ? collect(request.okStatusCodes) : []

@@ -110,3 +108,2 @@ );

const validateStatus = (status: number) =>
/* istanbul ignore next */
okStatusCodes.size === 0 ? true : okStatusCodes.has(status);

@@ -125,3 +122,2 @@

responseType: "arraybuffer",
/* istanbul ignore next */
data: request.body

@@ -140,3 +136,3 @@ ? (request.stringifyBody ?? _)(request.body)

// Тесты не покрывают кривые использования API
// Выбрасывается если есть ошибки сети
/* istanbul ignore next */

@@ -172,6 +168,3 @@ throw error;

statusCode: axiosResponse.status,
body:
axiosResponse.data !== undefined
? (request.parseResponse ?? _)(axiosResponse.data)
: undefined,
body: (request.parseResponse ?? _)(axiosResponse.data),
request

@@ -249,4 +242,2 @@ };

async patch<T>(url: string, body?: any): Promise<T> {
// Метод PATCH не используется в тестах
/* istanbul ignore next */
return await this.simpleRequest("PATCH", url, body);

@@ -265,4 +256,2 @@ }

async delete<T>(url: string, body?: any): Promise<T> {
// Метод DELETE не используется в тестах
/* istanbul ignore next */
return await this.simpleRequest("DELETE", url, body);

@@ -269,0 +258,0 @@ }

@@ -10,5 +10,2 @@ import { parse, stringify } from "query-string";

export function parseQuerystring(querystring: string): AnyResponse {
// Парсинг строки не используется в тестах
// Пакет `query-string` уже протестирован
/* istanbul ignore next */
return parse(querystring, {

@@ -15,0 +12,0 @@ arrayFormat: "index",

@@ -175,3 +175,2 @@ import { Detector, DetectorError } from "../detector";

provider = Recipients.QIWI,
/* istanbul ignore next */
comment = "",

@@ -244,3 +243,2 @@ currency = Currency.RUB,

/* istanbul ignore next */
throw new DetectorError("Unable to detect provider");

@@ -247,0 +245,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc