-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 18dbc80
Showing
39 changed files
with
1,550 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
tsconfigRootDir: __dirname, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint/eslint-plugin'], | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended', | ||
], | ||
root: true, | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
ignorePatterns: ['.eslintrc.js'], | ||
rules: { | ||
'@typescript-eslint/interface-name-prefix': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Regular lint, build and deploy to private registry (if commit message contains ~deploy~) | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies and lint, then build | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
- run: npm i -f | ||
- run: npm lint | ||
- run: npm run build | ||
docker: | ||
name: Create docker image and push to private registry | ||
runs-on: ubuntu-latest | ||
if: "contains(github.event.head_commit.message, '~deploy~')" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to registry | ||
uses: docker/login-action@v2 | ||
with: | ||
context: . | ||
registry: ${{ secrets.REGISTRY_URL }} | ||
username: ${{ secrets.REGISTRY_LOGIN }} | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: ${{ secrets.REGISTRY_URL }}/${{ github.event.repository.name }}:latest | ||
env: | ||
DOCKER_BUILDKIT: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# compiled output | ||
/dist | ||
/node_modules | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
pnpm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.env | ||
browser-cache | ||
# OS | ||
yarn.lock | ||
params.txt | ||
.DS_Store | ||
|
||
# Tests | ||
/coverage | ||
/.nyc_output | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM node:18 | ||
|
||
# Setup workdir and copy package.json | ||
WORKDIR /usr/src/app | ||
COPY package*.json ./ | ||
|
||
# Install dependencies with ignore flag | ||
RUN npm i --force | ||
|
||
COPY . . | ||
|
||
# Build the app | ||
RUN npm run build | ||
|
||
# Expose port 3000 | ||
EXPOSE 3000 | ||
|
||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) [year] [fullname] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
# 🥝 QIWI Reverse API | ||
|
||
## Что это и зачем? | ||
|
||
С [недавних пор](https://developer.qiwi.com/ru/qiwi-wallet-personal/#auth_param) QIWI закрыли возможность получения OAuth-токенов: | ||
|
||
> **Мы остановили выпуск OAuth-токенов. Приносим извинения за доставленные неудобства.** | ||
> | ||
> _Источник: [developer.qiwi.com/ru/qiwi-wallet-personal](https://developer.qiwi.com/ru/qiwi-wallet-personal/#auth_param)_ | ||
Благодаря этому API, осуществляющему получение **куки** и **access_token** из вашего QIWI-кошелька через аутентификацию с помощью телефона и пароля, а также обновляющему их каждые два часа, продолжение использования API становится возможным, хотя и менее удобным. | ||
|
||
## Как происходит получение токена? | ||
|
||
Под капотом [puppeteer](https://github.com/puppeteer/puppeteer), [puppeteer-extra-plugin-stealth](https://www.npmjs.com/package/puppeteer-extra-plugin-stealth) и [puppeteer-extra](https://www.npmjs.com/package/puppeteer-extra). | ||
|
||
Запускаем браузер, входим, достаем параметр из _куки_, а тажке токен из _localstorage_. | ||
|
||
## Начало работы | ||
|
||
Склонируйте репозиторий в нужную вам директорию: | ||
|
||
```bash | ||
git clone https://github.com/LukasAndreano/qiwi-reverse-api.git <name> | ||
``` | ||
|
||
Установите зависимости: | ||
|
||
```bash | ||
cd <name> | ||
yarn | ||
``` | ||
|
||
Пропишите правильные доступы к БД, создав файл **.env** (он не идет в GIT, игнорируется), используя **env.example**. После чего запустите сервинг: | ||
|
||
```bash | ||
yarn dev | ||
``` | ||
|
||
## Todo | ||
|
||
- [ ] Авто-деплой на локальный Docker Registry | ||
- [ ] Написать автотесты | ||
|
||
## Методы API | ||
|
||
Все методы для работы описаны в документации, расположенной по адресу: | ||
|
||
> [http://localhost:3000/docs](http://localhost:3000/docs) | ||
> | ||
> Логин и пароль для входа в Swagger: **devs** (если не указан иной) | ||
Однако, дополнительно дублирую: | ||
|
||
### /auth POST | ||
|
||
```json | ||
{ | ||
"phone": "79999999999", | ||
"password": "YourPassword" | ||
} | ||
``` | ||
|
||
Вернет: | ||
|
||
```json | ||
{ | ||
"status": true, | ||
"statusCode": 200, | ||
"data": { | ||
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywidHlwZSI6ImFjY2Vzc190b2tlbiIsImlhdCI6MTY5OTg4Mjg5OSwiZXhwIjoxNjk5OTY5Mjk5fQ.R0njmshiqkzZWQNObJtRw6RzCfC7DHNsoJiOnoZVHM0", | ||
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE3NTA5YjMxLWVjMDAtNDlhZi1hZDhmLWExMTExNmE2NGE0MCIsInVzZXJfaWQiOjMsInR5cGUiOiJyZWZyZXNoX3Rva2VuIiwiaWF0IjoxNjk5ODgyODk5LCJleHAiOjE3MDI0NzQ4OTl9.rkWCHDWlR-m_-Pqh4F0Grw3HNpTlazTBVimu-sKwdpY" | ||
} | ||
} | ||
``` | ||
|
||
> Время жизни **access_token** - 1 день, **refresh_token** - 30 дней. | ||
### /auth/refresh POST | ||
|
||
body: | ||
|
||
```json | ||
{ | ||
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE3NTA5YjMxLWVjMDAtNDlhZi1hZDhmLWExMTExNmE2NGE0MCIsInVzZXJfaWQiOjMsInR5cGUiOiJyZWZyZXNoX3Rva2VuIiwiaWF0IjoxNjk5ODgyODk5LCJleHAiOjE3MDI0NzQ4OTl9.rkWCHDWlR-m_-Pqh4F0Grw3HNpTlazTBVimu-sKwdpY" | ||
} | ||
``` | ||
|
||
Вернет: | ||
|
||
```json | ||
{ | ||
"status": true, | ||
"statusCode": 200, | ||
"data": { | ||
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywidHlwZSI6ImFjY2Vzc190b2tlbiIsImlhdCI6MTY5OTg4Mjg5OSwiZXhwIjoxNjk5OTY5Mjk5fQ.R0njmshiqkzZWQNObJtRw6RzCfC7DHNsoJiOnoZVHM0", | ||
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImE3NTA5YjMxLWVjMDAtNDlhZi1hZDhmLWExMTExNmE2NGE0MCIsInVzZXJfaWQiOjMsInR5cGUiOiJyZWZyZXNoX3Rva2VuIiwiaWF0IjoxNjk5ODgyODk5LCJleHAiOjE3MDI0NzQ4OTl9.rkWCHDWlR-m_-Pqh4F0Grw3HNpTlazTBVimu-sKwdpY" | ||
} | ||
} | ||
``` | ||
|
||
### /request POST | ||
|
||
body: | ||
|
||
```json | ||
{ | ||
"method": "GET", | ||
"endpoint": "/payment-history/v2/persons/79999999999/payments", | ||
"params": { | ||
"rows": 10, | ||
"operation": "IN" | ||
} | ||
} | ||
``` | ||
|
||
Ответ (изменен в целях безопасности): | ||
|
||
```json | ||
{ | ||
"status": true, | ||
"statusCode": 201, | ||
"data": { | ||
"data": [ | ||
{ | ||
"txnId": 0, | ||
"personId": 0, | ||
"date": "2022-10-13T14:45:27+03:00", | ||
"errorCode": 0, | ||
"error": null, | ||
"status": "SUCCESS", | ||
"type": "IN", | ||
"statusText": "Success", | ||
"trmTxnId": "0", | ||
"account": "0", | ||
"sum": { | ||
"amount": 1000, | ||
"currency": 398 | ||
}, | ||
"commission": { | ||
"amount": 0, | ||
"currency": 398 | ||
}, | ||
"total": { | ||
"amount": 190000, | ||
"currency": 398 | ||
}, | ||
"provider": { | ||
"id": 4, | ||
"shortName": "Платеж с терминала", | ||
"longName": "Платеж с терминала", | ||
"logoUrl": null, | ||
"description": null, | ||
"keys": null, | ||
"siteUrl": null, | ||
"extras": [] | ||
}, | ||
"source": { | ||
"id": 99, | ||
"shortName": "Перевод на QIWI Кошелек", | ||
"longName": null, | ||
"logoUrl": "https://static.qiwi.com/img/providers/logoBig/99_l.png", | ||
"description": null, | ||
"keys": "пополнить, перевести, qiwi, кошелек, оплатить, онлайн, оплата, счет, способ, услуга, перевод", | ||
"siteUrl": "https://www.qiwi.com", | ||
"extras": [ | ||
{ | ||
"key": "seo_description", | ||
"value": "Пополнение QIWI Кошелька банковской картой без комиссии от 2000 руб., со счета мобильного телефона или наличными через QIWI Терминалы. Оплачивать услуги стало проще." | ||
}, | ||
{ | ||
"key": "seo_title", | ||
"value": "Пополнить QIWI Кошелек: с банковской карты, с баланса телефона, через QIWI Кошелек" | ||
} | ||
] | ||
}, | ||
"comment": null, | ||
"currencyRate": 1, | ||
"paymentExtras": [], | ||
"features": { | ||
"chequeReady": false, | ||
"bankDocumentReady": false, | ||
"regularPaymentEnabled": false, | ||
"bankDocumentAvailable": false, | ||
"repeatPaymentEnabled": false, | ||
"favoritePaymentEnabled": false, | ||
"chatAvailable": false, | ||
"greetingCardAttached": false | ||
}, | ||
"serviceExtras": {}, | ||
"view": { | ||
"title": "Платеж с терминала", | ||
"account": "0" | ||
} | ||
} | ||
], | ||
"nextTxnId": 0, | ||
"nextTxnDate": "2022-10-13T14:45:27+03:00" | ||
} | ||
} | ||
``` | ||
|
||
> Если метод **GET** и имеет **query** параметры, то необходимо их передавать в **params**, как и в случае с **body** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
PORT=3000 | ||
|
||
DB_HOST=localhost | ||
DB_PORT=8889 | ||
DB_USER=qiwi | ||
DB_NAME=qiwi | ||
DB_PASSWORD=qiwi | ||
|
||
DOCS_PASSWORD=devs | ||
JWT_SECRET=supersecretjwtkey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/nest-cli", | ||
"collection": "@nestjs/schematics", | ||
"sourceRoot": "src", | ||
"compilerOptions": { | ||
"deleteOutDir": true | ||
} | ||
} |
Oops, something went wrong.