feat: hotspot PIX MikroTik + backend Docker + CI Gitea Actions
build-image / build-push (push) Failing after 4m36s
build-image / build-push (push) Failing after 4m36s
This commit is contained in:
commit
de9bd4ae0b
15 files changed
+1720
No files matched your search
@@ -0,0 +1,37 @@
|
||||
name: build-image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["v*"]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
build-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login no Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.jf.eng.br
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Build e push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: backend
|
||||
push: true
|
||||
tags: |
|
||||
git.jf.eng.br/jfeng/hotspot:latest
|
||||
git.jf.eng.br/jfeng/hotspot:${{ github.sha }}
|
||||
@@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
data/
|
||||
.env
|
||||
*.log
|
||||
@@ -0,0 +1,116 @@
|
||||
# pix-hotspot — WiFi Convidados com PIX (MikroTik + Mercado Pago)
|
||||
|
||||
Hotspot de convidados para MikroTik (hAP lite) com **cobrança via PIX** e **liberação automática** de acesso.
|
||||
|
||||
## Arquitetura
|
||||
|
||||
```
|
||||
Conecta no WiFi "Convidados-Pix"
|
||||
│
|
||||
▼
|
||||
Hotspot MikroTik (captive portal)
|
||||
│ escolhe plano
|
||||
▼
|
||||
Backend (ZimaOS / Docker) ◄──── API Mercado Pago (PIX)
|
||||
│ pagamento aprovado
|
||||
▼
|
||||
Cria voucher no MikroTik (API local - nunca exposta)
|
||||
│
|
||||
▼
|
||||
Convidado usa o WiFi com limite de velocidade e validade
|
||||
```
|
||||
|
||||
## Instalação em 1 clique (ZimaOS)
|
||||
|
||||
A imagem é **gerada automaticamente pelo Gitea Actions** e publicada no
|
||||
Gitea Container Registry (`git.jf.eng.br/jfeng/hotspot`).
|
||||
|
||||
1. Abra a pasta do projeto no ZimaOS (CasaOS → Importar / Docker Compose)
|
||||
2. Edite **`docker-compose.yml`** — todas as variáveis estão ali dentro:
|
||||
- `MP_ACCESS_TOKEN` — token do Mercado Pago
|
||||
- `MIKROTIK_HOST` / `MIKROTIK_PASSWORD` — seus dados do hAP lite
|
||||
- `BASE_URL` — IP do ZimaOS: `http://<ip-do-zimaos>:3000`
|
||||
3. Rode:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Pronto: backend no ar em `http://<ip-do-zimaos>:3000`.
|
||||
|
||||
> Se o repositório/pkg for privado, faça login uma vez no host:
|
||||
> `docker login git.jf.eng.br`
|
||||
|
||||
## CI/CD (Gitea Actions)
|
||||
|
||||
Workflow: `.gitea/workflows/docker.yml`
|
||||
|
||||
- A cada **push na branch `main`** (ou tag `v*`), o Gitea **compila a imagem**
|
||||
(`backend/Dockerfile`) e publica como:
|
||||
- `git.jf.eng.br/jfeng/hotspot:latest`
|
||||
- `git.jf.eng.br/jfeng/hotspot:<sha>`
|
||||
- Usa o token automático `secrets.GITEA_TOKEN` — **nenhum token manual é
|
||||
necessário** no repositório (permissão `packages: write` via `permissions:`).
|
||||
|
||||
Requisitos no Gitea:
|
||||
- [ ] **Actions habilitado** no repositório (Settings → Actions → General)
|
||||
- [ ] Um **runner** registrado na instância (senão o workflow fica "aguardando")
|
||||
|
||||
## MikroTik
|
||||
|
||||
1. Edite no `mikrotik/setup-hotspot.rsc`: `backendIP` (IP do ZimaOS)
|
||||
2. Winbox → **New Terminal** → `/import file-name=setup-hotspot.rsc`
|
||||
3. (Opcional) página do hotspot com botão PIX — `mikrotik/README-hotspot-pages.txt`
|
||||
|
||||
Rede de convidados **isolada** (`10.10.10.0/24`): não acessa seus PCs nem o
|
||||
MikroTik; só alcança `backend:3000` (pagamento) e internet.
|
||||
|
||||
## Planos padrão
|
||||
|
||||
| Plano | Preço | Velocidade | Perfil MikroTik |
|
||||
|-------|-------|------------|-----------------|
|
||||
| 1 Hora | R$ 3,00 | 5M/1M | `pix-1h` |
|
||||
| 24 Horas | R$ 5,00 | 8M/2M | `pix-24h` |
|
||||
| 7 Dias | R$ 15,00 | 10M/3M | `pix-7d` |
|
||||
|
||||
Para alterar: `POST /api/admin/plans` (header `x-admin-token`) ou edite
|
||||
`backend/src/db.js` antes do primeiro run.
|
||||
|
||||
## API (resumo)
|
||||
|
||||
| Rota | Descrição |
|
||||
|------|-----------|
|
||||
| `GET /api/plans` | Lista planos ativos |
|
||||
| `POST /api/checkout` | Cria pagamento PIX `{planId, mac?}` |
|
||||
| `GET /api/status/:id` | Status + voucher após pagar |
|
||||
| `GET /api/admin/payments` | Últimos pagamentos (token) |
|
||||
| `POST /api/admin/plans` | Atualiza planos (token) |
|
||||
| `GET /api/health` | Saúde do serviço |
|
||||
|
||||
## Segurança em produção
|
||||
|
||||
- [ ] Troque `ADMIN_TOKEN` no compose por valor longo aleatório
|
||||
- [ ] MikroTik: usuário API dedicado (não use `admin`) com permissão mínima
|
||||
- [ ] Mercado Pago: saia do `sandbox` quando testar tudo
|
||||
- [ ] ZimaOS: porta 3000 só na rede local (não exponha na internet)
|
||||
|
||||
## Estrutura
|
||||
|
||||
```
|
||||
pix-hotspot/
|
||||
├── docker-compose.yml # TUDO configurável aqui (1 clique)
|
||||
├── .gitea/workflows/ # CI: build + push da imagem no Gitea
|
||||
├── backend/
|
||||
│ ├── Dockerfile
|
||||
│ ├── package.json
|
||||
│ ├── src/
|
||||
│ │ ├── index.js # Express + rotas + polling MP
|
||||
│ │ ├── config.js # lê env
|
||||
│ │ ├── db.js # JSON store (planos/pagamentos)
|
||||
│ │ ├── mp.js # Mercado Pago PIX
|
||||
│ │ └── ros.js # API client RouterOS (sem dependências)
|
||||
│ └── public/
|
||||
│ └── index.html # Portal de pagamento
|
||||
└── mikrotik/
|
||||
└── setup-hotspot.rsc # Rede guest isolada + hotspot + perfis
|
||||
```
|
||||
@@ -0,0 +1,9 @@
|
||||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm install --omit=dev
|
||||
COPY src ./src
|
||||
COPY public ./public
|
||||
ENV NODE_ENV=production
|
||||
EXPOSE 3000
|
||||
CMD ["node", "src/index.js"]
|
||||
Generated
+898
@@ -0,0 +1,898 @@
|
||||
{
|
||||
"name": "pix-hotspot-backend",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "pix-hotspot-backend",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"express": "^4.19.2",
|
||||
"mercadopago": "^2.0.15"
|
||||
}
|
||||
},
|
||||
"node_modules/accepts": {
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
||||
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-types": "~2.1.34",
|
||||
"negotiator": "0.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/array-flatten": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/body-parser": {
|
||||
"version": "1.20.8",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.8.tgz",
|
||||
"integrity": "sha512-JNcyFQ64OiijEkPzUBTCe+hyPXUD/3LEldGQ6iF5LR1w00mx9o7xtDWHXBY2iItjdCFGoilOLNQbH943ut7pHA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "~3.1.2",
|
||||
"content-type": "~1.0.5",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "~1.2.0",
|
||||
"http-errors": "~2.0.1",
|
||||
"iconv-lite": "~0.4.24",
|
||||
"on-finished": "~2.4.1",
|
||||
"qs": "~6.16.0",
|
||||
"raw-body": "~2.5.3",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/bytes": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
|
||||
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bound": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
|
||||
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"get-intrinsic": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/content-disposition": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
||||
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "5.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/content-type": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
|
||||
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/cookie": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
|
||||
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/cookie-signature": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
|
||||
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/depd": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/destroy": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
|
||||
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"gopd": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/encodeurl": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
|
||||
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
|
||||
"integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/etag": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
||||
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "4.22.3",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.22.3.tgz",
|
||||
"integrity": "sha512-Bdcs4+3qlpVlx2NRn6fgX2Ue2/gGRaPeawebgclM0ERSCqDpA+owF1fdPwjJUTAJWMTuAaxjDf+hzb0/4eKvvw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "~1.20.5",
|
||||
"content-disposition": "~0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "~0.7.1",
|
||||
"cookie-signature": "~1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "~1.3.1",
|
||||
"fresh": "~0.5.2",
|
||||
"http-errors": "~2.0.0",
|
||||
"merge-descriptors": "1.0.3",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "~2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "~0.1.13",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"qs": "~6.16.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"safe-buffer": "5.2.1",
|
||||
"send": "~0.19.0",
|
||||
"serve-static": "~1.16.2",
|
||||
"setprototypeof": "1.2.0",
|
||||
"statuses": "~2.0.1",
|
||||
"type-is": "~1.6.18",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/finalhandler": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
|
||||
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"on-finished": "~2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"statuses": "~2.0.2",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/forwarded": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
||||
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/fresh": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"es-define-property": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.1.1",
|
||||
"function-bind": "^1.1.2",
|
||||
"get-proto": "^1.0.1",
|
||||
"gopd": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"math-intrinsics": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
"es-object-atoms": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
|
||||
"integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/http-errors": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
|
||||
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"depd": "~2.0.0",
|
||||
"inherits": "~2.0.4",
|
||||
"setprototypeof": "~1.2.0",
|
||||
"statuses": "~2.0.2",
|
||||
"toidentifier": "~1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ipaddr.js": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
||||
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mercadopago": {
|
||||
"version": "2.13.0",
|
||||
"resolved": "https://registry.npmjs.org/mercadopago/-/mercadopago-2.13.0.tgz",
|
||||
"integrity": "sha512-dm096v3Mu2VcW6j3/YJIiIAuGzzUwtGGnNga+SmfK55lpY28r1m7Zi3JyRVxSWtrwYWHT0rKs6ni05gc2kUmDw==",
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.7.0",
|
||||
"uuid": "^9.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/merge-descriptors": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
|
||||
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/methods": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
||||
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"mime": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/negotiator": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
||||
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.13.4",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
|
||||
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/on-finished": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
|
||||
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ee-first": "1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/parseurl": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/path-to-regexp": {
|
||||
"version": "0.1.13",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
|
||||
"integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
|
||||
"integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"forwarded": "0.2.0",
|
||||
"ipaddr.js": "1.9.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.16.1",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.1.tgz",
|
||||
"integrity": "sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"es-define-property": "^1.0.1",
|
||||
"side-channel": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/range-parser": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
|
||||
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/raw-body": {
|
||||
"version": "2.5.3",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
|
||||
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "~3.1.2",
|
||||
"http-errors": "~2.0.1",
|
||||
"iconv-lite": "~0.4.24",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/send": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
|
||||
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"fresh": "~0.5.2",
|
||||
"http-errors": "~2.0.1",
|
||||
"mime": "1.6.0",
|
||||
"ms": "2.1.3",
|
||||
"on-finished": "~2.4.1",
|
||||
"range-parser": "~1.2.1",
|
||||
"statuses": "~2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/send/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/serve-static": {
|
||||
"version": "1.16.3",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
|
||||
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"parseurl": "~1.3.3",
|
||||
"send": "~0.19.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/setprototypeof": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
||||
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/side-channel": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
|
||||
"integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.4",
|
||||
"side-channel-list": "^1.0.1",
|
||||
"side-channel-map": "^1.0.1",
|
||||
"side-channel-weakmap": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-list": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
|
||||
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-map": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
|
||||
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-weakmap": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
|
||||
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3",
|
||||
"side-channel-map": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/statuses": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
|
||||
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/toidentifier": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
||||
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/type-is": {
|
||||
"version": "1.6.18",
|
||||
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
|
||||
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"media-typer": "0.3.0",
|
||||
"mime-types": "~2.1.24"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",
|
||||
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
|
||||
"deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/broofa",
|
||||
"https://github.com/sponsors/ctavan"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/vary": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "pix-hotspot-backend",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"start": "node src/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.19.2",
|
||||
"mercadopago": "^2.0.15"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pt-BR">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>WiFi Convidados - Pagar com PIX</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; font-family: system-ui, sans-serif; }
|
||||
body { background: linear-gradient(135deg, #0f172a, #1e3a5f); min-height: 100vh; color: #e2e8f0; padding: 20px; }
|
||||
.container { max-width: 480px; margin: 0 auto; }
|
||||
h1 { text-align: center; font-size: 1.5rem; margin-bottom: 6px; }
|
||||
.sub { text-align: center; color: #94a3b8; margin-bottom: 24px; font-size: .9rem; }
|
||||
.plan { background: #1e293b; border: 1px solid #334155; border-radius: 14px; padding: 18px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: .15s; }
|
||||
.plan:hover { border: 1px solid #38bdf8; transform: translateY(-2px); }
|
||||
.plan h3 { font-size: 1.05rem; }
|
||||
.plan .speed { color: #94a3b8; font-size: .8rem; margin-top: 3px; }
|
||||
.price { background: #059669; color: #fff; font-weight: 700; padding: 8px 14px; border-radius: 10px; font-size: 1rem; white-space: nowrap; }
|
||||
#pay, #voucher { display: none; background: #1e293b; border: 1px solid #334155; border-radius: 14px; padding: 24px; text-align: center; }
|
||||
#pay img, #voucher img { width: 220px; height: 220px; background: #fff; border-radius: 10px; padding: 8px; margin: 16px 0; }
|
||||
.colacode { background: #0f172a; border: 1px dashed #475569; border-radius: 10px; padding: 12px; font-size: .75rem; word-break: break-all; color: #7dd3fc; margin-bottom: 14px; }
|
||||
button { background: #0ea5e9; color: #fff; border: 0; border-radius: 10px; padding: 14px 22px; font-size: 1rem; font-weight: 600; cursor: pointer; width: 100%; margin-top: 8px; }
|
||||
button.secondary { background: #334155; }
|
||||
button:disabled { opacity: .5; cursor: wait; }
|
||||
.voucher-box { background: #0f172a; border: 2px solid #10b981; border-radius: 12px; padding: 18px; margin: 16px 0; }
|
||||
.voucher-box .code { font-size: 1.6rem; font-weight: 800; color: #34d399; letter-spacing: 2px; }
|
||||
.voucher-box .lbl { color: #94a3b8; font-size: .8rem; margin-top: 10px; }
|
||||
.error { color: #f87171; margin-top: 12px; font-size: .9rem; }
|
||||
.back { text-align: center; margin-top: 16px; }
|
||||
.back a { color: #7dd3fc; font-size: .9rem; }
|
||||
.hidden { display: none !important; }
|
||||
#copied { color: #34d399; font-size: .85rem; margin-top: 6px; display: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>📶 WiFi Convidados</h1>
|
||||
<p class="sub">Escolha seu plano e pague com PIX — liberação automática</p>
|
||||
|
||||
<div id="plans"></div>
|
||||
|
||||
<div id="pay">
|
||||
<h2 id="payTitle"></h2>
|
||||
<p style="color:#94a3b8;margin-top:6px">Escaneie o QR Code no app do seu banco</p>
|
||||
<img id="qrImg" alt="QR Code PIX">
|
||||
<div class="colacode" id="copiaCola"></div>
|
||||
<button class="secondary" id="copyBtn">Copiar código PIX</button>
|
||||
<div id="copied">Copiado!</div>
|
||||
<button id="checkBtn">Já paguei — verificar</button>
|
||||
<div class="error" id="payError"></div>
|
||||
<div class="back"><a href="#" id="backBtn">← Voltar aos planos</a></div>
|
||||
</div>
|
||||
|
||||
<div id="voucher">
|
||||
<h2 style="color:#34d399">✅ Pagamento confirmado!</h2>
|
||||
<div class="voucher-box">
|
||||
<div class="lbl">Usuário</div>
|
||||
<div class="code" id="vUser"></div>
|
||||
<div class="lbl">Senha</div>
|
||||
<div class="code" id="vPass"></div>
|
||||
</div>
|
||||
<p style="color:#94a3b8;font-size:.9rem">Use esses dados na tela de login do WiFi.<br>Válido conforme o plano escolhido.</p>
|
||||
<button class="secondary" id="copyVoucher">Copiar usuário e senha</button>
|
||||
<div class="back"><a href="#" id="backBtn2">← Voltar aos planos</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const params = new URLSearchParams(location.search);
|
||||
const mac = params.get('mac') || '';
|
||||
let currentPaymentId = null;
|
||||
let pollTimer = null;
|
||||
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
async function loadPlans() {
|
||||
const res = await fetch('/api/plans');
|
||||
const plans = await res.json();
|
||||
$('plans').innerHTML = plans.map(p => `
|
||||
<div class="plan" data-id="${p.id}">
|
||||
<div>
|
||||
<h3>${p.name}</h3>
|
||||
<div class="speed">${p.speed} · validade ${p.uptime}</div>
|
||||
</div>
|
||||
<div class="price">R$ ${p.price.toFixed(2).replace('.', ',')}</div>
|
||||
</div>`).join('');
|
||||
document.querySelectorAll('.plan').forEach(el => {
|
||||
el.onclick = () => checkout(el.dataset.id);
|
||||
});
|
||||
}
|
||||
|
||||
function show(which) {
|
||||
$('plans').style.display = which === 'plans' ? '' : 'none';
|
||||
$('pay').style.display = which === 'pay' ? 'block' : 'none';
|
||||
$('voucher').style.display = which === 'voucher' ? 'block' : 'none';
|
||||
if (which === 'plans' && pollTimer) { clearInterval(pollTimer); pollTimer = null; }
|
||||
}
|
||||
|
||||
async function checkout(planId) {
|
||||
try {
|
||||
const res = await fetch('/api/checkout', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ planId, mac }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.error) throw new Error(data.error);
|
||||
currentPaymentId = data.paymentId;
|
||||
$('payTitle').textContent = `${data.planName} — R$ ${data.price.toFixed(2).replace('.', ',')}`;
|
||||
$('qrImg').src = data.qrCodeBase64 ? 'data:image/png;base64,' + data.qrCodeBase64 : '';
|
||||
$('copiaCola').textContent = data.copiaCola;
|
||||
$('payError').textContent = '';
|
||||
show('pay');
|
||||
} catch (e) {
|
||||
alert('Erro: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
$('copyBtn').onclick = async () => {
|
||||
await navigator.clipboard.writeText($('copiaCola').textContent);
|
||||
$('copied').style.display = 'block';
|
||||
setTimeout(() => $('copied').style.display = 'none', 2000);
|
||||
};
|
||||
|
||||
async function verify() {
|
||||
const btn = $('checkBtn');
|
||||
btn.disabled = true; btn.textContent = 'Verificando...';
|
||||
try {
|
||||
const res = await fetch('/api/status/' + currentPaymentId);
|
||||
const data = await res.json();
|
||||
if (data.status === 'paid' && data.voucher) {
|
||||
$('vUser').textContent = data.voucher.user;
|
||||
$('vPass').textContent = data.voucher.pass;
|
||||
show('voucher');
|
||||
return true;
|
||||
}
|
||||
if (['rejected', 'cancelled', 'expired'].includes(data.status)) {
|
||||
$('payError').textContent = 'Pagamento não aprovado. Tente novamente.';
|
||||
} else {
|
||||
$('payError').textContent = 'Ainda aguardando pagamento...';
|
||||
}
|
||||
} catch (e) {
|
||||
$('payError').textContent = 'Erro ao verificar.';
|
||||
}
|
||||
btn.disabled = false; btn.textContent = 'Já paguei — verificar';
|
||||
return false;
|
||||
}
|
||||
|
||||
$('checkBtn').onclick = verify;
|
||||
$('backBtn').onclick = (e) => { e.preventDefault(); show('plans'); };
|
||||
$('backBtn2').onclick = (e) => { e.preventDefault(); show('plans'); };
|
||||
$('copyVoucher').onclick = async () => {
|
||||
await navigator.clipboard.writeText(`User: ${$('vUser').textContent}\nPass: ${$('vPass').textContent}`);
|
||||
alert('Copiado!');
|
||||
};
|
||||
|
||||
loadPlans();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const config = {
|
||||
mpAccessToken: process.env.MP_ACCESS_TOKEN || '',
|
||||
mpEnvironment: process.env.MP_ENVIRONMENT || 'sandbox',
|
||||
mikrotik: {
|
||||
host: process.env.MIKROTIK_HOST || '192.168.3.81',
|
||||
port: parseInt(process.env.MIKROTIK_PORT || '8728', 10),
|
||||
user: process.env.MIKROTIK_USER || 'admin',
|
||||
password: process.env.MIKROTIK_PASSWORD || '',
|
||||
server: process.env.MIKROTIK_SERVER || 'guest-hotspot',
|
||||
},
|
||||
port: parseInt(process.env.PORT || '3000', 10),
|
||||
baseUrl: process.env.BASE_URL || 'http://192.168.3.100:3000',
|
||||
adminToken: process.env.ADMIN_TOKEN || 'dev-token',
|
||||
dataDir: process.env.DATA_DIR || path.join(__dirname, '..', 'data'),
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -0,0 +1,44 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import crypto from 'node:crypto';
|
||||
import config from './config.js';
|
||||
|
||||
const DB_PATH = path.join(config.dataDir, 'db.json');
|
||||
|
||||
const DEFAULT_PLANS = [
|
||||
{ id: 'plano-1h', name: '1 Hora', price: 3.00, profile: 'pix-1h', uptime: '1h', speed: '5M/1M', active: true },
|
||||
{ id: 'plano-24h', name: '24 Horas', price: 5.00, profile: 'pix-24h', uptime: '1d', speed: '8M/2M', active: true },
|
||||
{ id: 'plano-7d', name: '7 Dias', price: 15.00, profile: 'pix-7d', uptime: '1w', speed: '10M/3M', active: true },
|
||||
];
|
||||
|
||||
let db = { plans: [], payments: [] };
|
||||
|
||||
export function initDb() {
|
||||
fs.mkdirSync(config.dataDir, { recursive: true });
|
||||
if (fs.existsSync(DB_PATH)) {
|
||||
db = JSON.parse(fs.readFileSync(DB_PATH, 'utf8'));
|
||||
if (!db.plans?.length) db.plans = structuredClone(DEFAULT_PLANS);
|
||||
if (!db.payments) db.payments = [];
|
||||
} else {
|
||||
db = { plans: structuredClone(DEFAULT_PLANS), payments: [] };
|
||||
saveDb();
|
||||
}
|
||||
}
|
||||
|
||||
export function saveDb() {
|
||||
const tmp = DB_PATH + '.tmp';
|
||||
fs.writeFileSync(tmp, JSON.stringify(db, null, 2));
|
||||
fs.renameSync(tmp, DB_PATH);
|
||||
}
|
||||
|
||||
export function getDb() {
|
||||
return db;
|
||||
}
|
||||
|
||||
export function genCode(len = 8) {
|
||||
const chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
|
||||
const bytes = crypto.randomBytes(len);
|
||||
let out = '';
|
||||
for (let i = 0; i < len; i++) out += chars[bytes[i] % chars.length];
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
import express from 'express';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import config from './config.js';
|
||||
import { initDb, getDb, saveDb, genCode } from './db.js';
|
||||
import { initMp, createPixPayment, getPaymentStatus } from './mp.js';
|
||||
import { createHotspotUser } from './ros.js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.use(express.static(path.join(__dirname, '../public')));
|
||||
|
||||
initDb();
|
||||
initMp();
|
||||
|
||||
async function fulfill(payment) {
|
||||
if (payment.voucher) return payment;
|
||||
const user = 'G' + genCode(6);
|
||||
const pass = genCode(8);
|
||||
const plan = getDb().plans.find((p) => p.id === payment.planId);
|
||||
await createHotspotUser(user, pass, plan?.profile || payment.profile, plan?.uptime);
|
||||
payment.voucher = { user, pass };
|
||||
payment.status = 'paid';
|
||||
payment.paidAt = new Date().toISOString();
|
||||
saveDb();
|
||||
console.log(`[PAGA] ${payment.planId} -> voucher ${user}`);
|
||||
return payment;
|
||||
}
|
||||
|
||||
async function checkPayment(payment) {
|
||||
if (!payment.mpId || payment.status !== 'pending') return payment;
|
||||
try {
|
||||
const st = await getPaymentStatus(payment.mpId);
|
||||
if (st === 'approved') return await fulfill(payment);
|
||||
if (st === 'rejected' || st === 'cancelled' || st === 'expired') {
|
||||
payment.status = st;
|
||||
saveDb();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[MP] erro ao consultar:', e.message);
|
||||
}
|
||||
return payment;
|
||||
}
|
||||
|
||||
// ===== Rotas =====
|
||||
|
||||
app.get('/api/plans', (req, res) => {
|
||||
res.json(getDb().plans.filter((p) => p.active));
|
||||
});
|
||||
|
||||
app.post('/api/checkout', async (req, res) => {
|
||||
try {
|
||||
const { planId, mac } = req.body || {};
|
||||
const plan = getDb().plans.find((p) => p.id === planId && p.active);
|
||||
if (!plan) return res.status(400).json({ error: 'plano invalido' });
|
||||
|
||||
const payment = {
|
||||
id: 'P' + Date.now() + genCode(4),
|
||||
planId: plan.id,
|
||||
profile: plan.profile,
|
||||
mac: mac || null,
|
||||
price: plan.price,
|
||||
status: 'pending',
|
||||
mpId: null,
|
||||
voucher: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
const pix = await createPixPayment(plan.price, payment.id, `WiFi ${plan.name}`);
|
||||
payment.mpId = pix.mpId;
|
||||
payment.qrCodeBase64 = pix.qrCodeBase64;
|
||||
payment.copiaCola = pix.copiaCola;
|
||||
getDb().payments.push(payment);
|
||||
saveDb();
|
||||
|
||||
res.json({
|
||||
paymentId: payment.id,
|
||||
qrCodeBase64: pix.qrCodeBase64,
|
||||
copiaCola: pix.copiaCola,
|
||||
price: plan.price,
|
||||
planName: plan.name,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('[CHECKOUT]', e.message);
|
||||
res.status(500).json({ error: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/status/:id', async (req, res) => {
|
||||
const payment = getDb().payments.find((p) => p.id === req.params.id);
|
||||
if (!payment) return res.status(404).json({ error: 'nao encontrado' });
|
||||
await checkPayment(payment);
|
||||
res.json({
|
||||
status: payment.status,
|
||||
voucher: payment.voucher,
|
||||
planName: getDb().plans.find((p) => p.id === payment.planId)?.name,
|
||||
});
|
||||
});
|
||||
|
||||
function adminAuth(req, res, next) {
|
||||
const token = req.headers['x-admin-token'] || req.query.token;
|
||||
if (token !== config.adminToken) return res.status(401).json({ error: 'token invalido' });
|
||||
next();
|
||||
}
|
||||
|
||||
app.get('/api/admin/payments', adminAuth, (req, res) => {
|
||||
res.json(getDb().payments.slice(-100).reverse());
|
||||
});
|
||||
|
||||
app.post('/api/admin/plans', adminAuth, (req, res) => {
|
||||
const { plans } = req.body || {};
|
||||
if (!Array.isArray(plans)) return res.status(400).json({ error: 'plans[] obrigatorio' });
|
||||
getDb().plans = plans;
|
||||
saveDb();
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
app.get('/api/health', async (req, res) => {
|
||||
res.json({ ok: true, mp: !!config.mpAccessToken && !config.mpAccessToken.includes('COLE_SEU'), time: new Date().toISOString() });
|
||||
});
|
||||
|
||||
// ===== Polling: confirma pagamentos pendentes sozinho =====
|
||||
setInterval(async () => {
|
||||
const pendings = getDb().payments.filter((p) => p.status === 'pending' && p.mpId);
|
||||
for (const p of pendings) await checkPayment(p);
|
||||
}, 15000);
|
||||
|
||||
app.listen(config.port, '0.0.0.0', () => {
|
||||
console.log(`pix-hotspot rodando em ${config.baseUrl} (porta ${config.port})`);
|
||||
console.log(`MikroTik: ${config.mikrotik.host}:${config.mikrotik.port}`);
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import { MercadoPagoConfig, Payment } from 'mercadopago';
|
||||
import config from './config.js';
|
||||
|
||||
let paymentApi = null;
|
||||
|
||||
export function initMp() {
|
||||
if (!config.mpAccessToken || config.mpAccessToken.includes('COLE_SEU')) {
|
||||
console.warn('[MP] MP_ACCESS_TOKEN nao configurado - pagamentos nao funcionarao');
|
||||
return;
|
||||
}
|
||||
const client = new MercadoPagoConfig({ accessToken: config.mpAccessToken });
|
||||
paymentApi = new Payment(client);
|
||||
}
|
||||
|
||||
export async function createPixPayment(amount, reference, description) {
|
||||
if (!paymentApi) throw new Error('Mercado Pago nao configurado');
|
||||
const result = await paymentApi.create({
|
||||
body: {
|
||||
transaction_amount: amount,
|
||||
payment_method_id: 'pix',
|
||||
external_reference: reference,
|
||||
description,
|
||||
payer: { email: '[email protected]' },
|
||||
},
|
||||
});
|
||||
const tx = result.point_of_interaction?.transaction_data;
|
||||
if (!tx) throw new Error('Resposta do MP sem dados PIX');
|
||||
return {
|
||||
mpId: result.id,
|
||||
qrCodeBase64: tx.qr_code_base64 || null,
|
||||
copiaCola: tx.qr_code || tx.ticket_url || '',
|
||||
status: result.status,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getPaymentStatus(mpId) {
|
||||
if (!paymentApi) throw new Error('Mercado Pago nao configurado');
|
||||
const result = await paymentApi.get({ id: mpId });
|
||||
return result.status; // pending | approved | rejected | cancelled | ...
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
import net from 'node:net';
|
||||
import config from './config.js';
|
||||
|
||||
function packLen(n) {
|
||||
if (n < 0x80) return Buffer.from([n]);
|
||||
if (n < 0x4000) return Buffer.from([0x80 | (n >> 8), n & 0xff]);
|
||||
if (n < 0x200000) return Buffer.from([0xc0 | (n >> 16), (n >> 8) & 0xff, n & 0xff]);
|
||||
if (n < 0x10000000) return Buffer.from([0xe0 | (n >> 24), (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]);
|
||||
return Buffer.from([0xf0, (n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]);
|
||||
}
|
||||
|
||||
function encodeSentence(words) {
|
||||
const parts = [];
|
||||
for (const w of words) {
|
||||
const buf = Buffer.from(String(w), 'utf8');
|
||||
parts.push(packLen(buf.length), buf, Buffer.from([0]));
|
||||
}
|
||||
parts.push(Buffer.from([0]));
|
||||
return Buffer.concat(parts);
|
||||
}
|
||||
|
||||
class Parser {
|
||||
constructor() {
|
||||
this.buf = Buffer.alloc(0);
|
||||
this.words = [];
|
||||
this.sentence = [];
|
||||
this.done = false;
|
||||
this.error = null;
|
||||
this.replies = [];
|
||||
}
|
||||
push(chunk) {
|
||||
this.buf = Buffer.concat([this.buf, chunk]);
|
||||
while (true) {
|
||||
if (this.buf.length === 0) return;
|
||||
const first = this.buf[0];
|
||||
let len, offset;
|
||||
if ((first & 0x80) === 0) { len = first; offset = 1; }
|
||||
else if ((first & 0xc0) === 0x80) {
|
||||
if (this.buf.length < 2) return;
|
||||
len = ((first & 0x3f) << 8) | this.buf[1]; offset = 2;
|
||||
} else if ((first & 0xe0) === 0xc0) {
|
||||
if (this.buf.length < 3) return;
|
||||
len = ((first & 0x1f) << 16) | (this.buf[1] << 8) | this.buf[2]; offset = 3;
|
||||
} else if ((first & 0xf0) === 0xe0) {
|
||||
if (this.buf.length < 4) return;
|
||||
len = ((first & 0x0f) << 24) | (this.buf[1] << 16) | (this.buf[2] << 8) | this.buf[3]; offset = 4;
|
||||
} else {
|
||||
if (this.buf.length < 5) return;
|
||||
len = (this.buf[1] << 24) | (this.buf[2] << 16) | (this.buf[3] << 8) | this.buf[4]; offset = 5;
|
||||
}
|
||||
if (this.buf.length < offset + len) return;
|
||||
const data = this.buf.subarray(offset, offset + len);
|
||||
this.buf = this.buf.subarray(offset + len);
|
||||
if (len === 0) {
|
||||
if (this.sentence.length > 0) {
|
||||
this.handleSentence(this.sentence);
|
||||
this.sentence = [];
|
||||
} else if (this.words.length > 0) {
|
||||
this.handleSentence(this.words);
|
||||
this.words = [];
|
||||
}
|
||||
if (this.done || this.error) return;
|
||||
} else {
|
||||
this.words.push(data.toString('utf8'));
|
||||
}
|
||||
}
|
||||
}
|
||||
handleSentence(words) {
|
||||
const attr = words[0];
|
||||
if (attr === '!re') this.replies.push(words.slice(1));
|
||||
else if (attr === '!done') this.done = true;
|
||||
else if (attr === '!trap') this.error = words.slice(1).join(' ') || 'trap';
|
||||
else this.replies.push(words);
|
||||
}
|
||||
}
|
||||
|
||||
async function rosCommand(words, timeoutMs = 8000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const socket = new net.Socket();
|
||||
const parser = new Parser();
|
||||
let settled = false;
|
||||
const finish = (err, val) => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
clearTimeout(timer);
|
||||
socket.destroy();
|
||||
err ? reject(err) : resolve(val);
|
||||
};
|
||||
const timer = setTimeout(() => finish(new Error('timeout MikroTik API')), timeoutMs);
|
||||
socket.on('data', (chunk) => {
|
||||
parser.push(chunk);
|
||||
if (parser.error) finish(new Error(parser.error));
|
||||
else if (parser.done) finish(null, parser.replies);
|
||||
});
|
||||
socket.on('error', (e) => finish(e));
|
||||
socket.on('close', () => {
|
||||
if (!settled) finish(new Error('conexao MikroTik fechada'));
|
||||
});
|
||||
socket.connect(config.mikrotik.port, config.mikrotik.host, () => {
|
||||
socket.write(encodeSentence(['/login', `=name=${config.mikrotik.user}`, `=password=${config.mikrotik.password}`]));
|
||||
const onLogin = (chunk) => {
|
||||
parser.push(chunk);
|
||||
if (parser.error) { socket.off('data', onLogin); return finish(new Error(parser.error)); }
|
||||
if (parser.done) {
|
||||
socket.off('data', onLogin);
|
||||
// login ok - recria parser e envia comando
|
||||
const p2 = new Parser();
|
||||
const onData2 = (c2) => {
|
||||
p2.push(c2);
|
||||
if (p2.error) finish(new Error(p2.error));
|
||||
else if (p2.done) finish(null, p2.replies);
|
||||
};
|
||||
socket.on('data', onData2);
|
||||
socket.write(encodeSentence(words));
|
||||
} else if (parser.replies.length && parser.replies.some(r => r.some(w => w.startsWith('=ret=')))) {
|
||||
finish(new Error('RouterOS antigo (<6.43): use login simples - atualize o RouterOS'));
|
||||
}
|
||||
};
|
||||
socket.on('data', onLogin);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function createHotspotUser(name, password, profile, uptime) {
|
||||
const words = [
|
||||
'/ip/hotspot/user/add',
|
||||
`=server=${config.mikrotik.server}`,
|
||||
`=name=${name}`,
|
||||
`=password=${password}`,
|
||||
`=profile=${profile}`,
|
||||
];
|
||||
if (uptime) words.push(`=limit-uptime=${uptime}`);
|
||||
await rosCommand(words);
|
||||
}
|
||||
|
||||
export async function mikrotikPing() {
|
||||
const replies = await rosCommand(['/system/identity/print']);
|
||||
return replies?.[0]?.find((w) => w.startsWith('=name='))?.slice(6) || 'ok';
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
# ============================================================
|
||||
# pix-hotspot — instalação em 1 clique
|
||||
# docker compose up -d
|
||||
# Tudo configurável fica AQUI (nenhum .env necessário).
|
||||
# ============================================================
|
||||
name: pix-hotspot
|
||||
|
||||
services:
|
||||
pix-hotspot:
|
||||
image: git.jf.eng.br/jfeng/hotspot:latest
|
||||
container_name: pix-hotspot
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
restart: unless-stopped
|
||||
|
||||
environment:
|
||||
# ===== Mercado Pago (PIX) =====
|
||||
MP_ACCESS_TOKEN: "COLE_SEU_TOKEN_AQUI" # APP_USR-... (producao) ou TEST-... (sandbox)
|
||||
MP_ENVIRONMENT: "sandbox" # sandbox | production
|
||||
|
||||
# ===== MikroTik =====
|
||||
MIKROTIK_HOST: "192.168.3.81" # IP do hAP lite na sua rede
|
||||
MIKROTIK_PORT: "8728"
|
||||
MIKROTIK_USER: "admin"
|
||||
MIKROTIK_PASSWORD: ""
|
||||
MIKROTIK_SERVER: "guest-hotspot" # nome do servidor hotspot
|
||||
|
||||
# ===== Backend =====
|
||||
PORT: "3000"
|
||||
BASE_URL: "http://192.168.3.100:3000" # IP do ZimaOS (portal de pagamento)
|
||||
ADMIN_TOKEN: "troque-este-token-aleatorio-grande"
|
||||
@@ -0,0 +1,11 @@
|
||||
# ============================================================
|
||||
# Página do Hotspot com botão "Pagar com PIX"
|
||||
# Envie para o MikroTik: Winbox -> Files -> pasta hotspot/
|
||||
# edite o IP abaixo antes de enviar
|
||||
# ============================================================
|
||||
# Alternativa: use a pagina padrao do hotspot e adicione o link:
|
||||
# http://SEU_IP_ZIMASOS:3000/?mac=$(mac)
|
||||
#
|
||||
# No Winbox: IP -> Hotspot -> Server -> aba HTTP ->
|
||||
# ou edite hotspot/login.html direto no Files
|
||||
# ============================================================
|
||||
@@ -0,0 +1,62 @@
|
||||
# ============================================================
|
||||
# pix-hotspot - Setup MikroTik hAP lite
|
||||
# WiFi de convidados isolado + Hotspot + perfis PIX
|
||||
# Importe via: /import file-name=setup-hotspot.rsc
|
||||
# (ou cole linha a linha no Terminal do Winbox)
|
||||
# ============================================================
|
||||
|
||||
# ===== EDITAR ABAIXO =====
|
||||
:local guestSubnet "10.10.10.0/24"
|
||||
:local guestIP "10.10.10.1"
|
||||
:local backendIP "192.168.3.100"
|
||||
:local wanInterface "ether1"
|
||||
:local guestInterface "ether4"
|
||||
|
||||
# ===== 1. REDE DOS CONVIDADOS (isolada) =====
|
||||
/interface bridge add name=bridge-guest comment="REDE CONVIDADOS"
|
||||
/ip address add address=($guestIP . "/24") interface=bridge-guest
|
||||
|
||||
# ether4 = porta fisica dos convidados (opcional - cabo para switch guest)
|
||||
/interface bridge port add bridge=bridge-guest interface=$guestInterface comment="porta convidados"
|
||||
|
||||
# WiFi virtual para convidados (SSID separado)
|
||||
/interface wireless add master-interface=wlan1 name=wlan-guest ssid="Convidados-Pix" mode=ap disabled=no comment="WiFi convidados"
|
||||
/interface bridge port add bridge=bridge-guest interface=wlan-guest comment="wifi convidados"
|
||||
|
||||
# ===== 2. POOL + HOTSPOT =====
|
||||
/ip pool add name=guest-pool ranges=($guestIP . "10-")($guestIP . "50")
|
||||
/ip pool set [find name=guest-pool] ranges=("10.10.10.10-10.10.10.50")
|
||||
|
||||
/ip hotspot profile add name=hs-guest hotspot-interface=bridge-guest html-directory=hotspot login-by=http-chap dns-name="" comment="perfil hotspot convidados"
|
||||
/ip hotspot add name=guest-hotspot interface=bridge-guest address-pool=guest-pool profile=hs-guest lease-time=1h disabled=no
|
||||
|
||||
# ===== 3. PERFIS DE PLANO (nomes devem bater com o backend) =====
|
||||
/ip hotspot user profile remove [find name~"pix-"]
|
||||
/ip hotspot user profile add name=pix-1h rate-limit=5M/1M shared-users=1 comment="plano 1h"
|
||||
/ip hotspot user profile add name=pix-24h rate-limit=8M/2M shared-users=1 comment="plano 24h"
|
||||
/ip hotspot user profile add name=pix-7d rate-limit=10M/3M shared-users=1 comment="plano 7d"
|
||||
|
||||
# ===== 4. DNS/Internet dos convidados =====
|
||||
/ip firewall nat add chain=srcnat out-interface=$wanInterface src-address=$guestSubnet action=masquerade comment="NAT convidados"
|
||||
|
||||
# ===== 5. FIREWALL - ISOLAMENTO =====
|
||||
# Convidado pode ir: internet + backend (portal de pagamento) + DNS do hotspot
|
||||
# Convidado NAO pode: rede interna192.168.3.0/24 (seus PCs, MikroTik, etc)
|
||||
|
||||
/ip firewall filter
|
||||
# permite convidado -> backend:3000 (pagamento PIX)
|
||||
add chain=forward src-address=$guestSubnet dst-address=$backendIP protocol=tcp dst-port=3000 action=accept place-before=0 comment="guest->backend PIX"
|
||||
# permite respostas estabelecidas
|
||||
add chain=forward connection-state=established,related action=accept place-before=0 comment="estabelecidos"
|
||||
# BLOQUEIA convidado -> qualquer rede interna (exceto o backend ja aceito acima)
|
||||
add chain=forward src-address=$guestSubnet dst-address=192.168.0.0/16 action=drop comment="guest nao acessa rede interna"
|
||||
add chain=forward src-address=$guestSubnet dst-address=10.0.0.0/8 action=drop comment="guest nao acessa10.x"
|
||||
add chain=forward src-address=$guestSubnet dst-address=172.16.0.0/12 action=drop comment="guest nao acessa172.x"
|
||||
# gerenciao MikroTik pelo lado guest = bloqueado
|
||||
add chain=input src-address=$guestSubnet dst-address=$guestIP action=drop comment="guest nao gerencia o MikroTik"
|
||||
add chain=input src-address=$guestSubnet action=drop comment="guest so usa hotspot"
|
||||
|
||||
# ===== 6. LIMPA HOTSPOT ANTIGO (se houver) =====
|
||||
/ip hotspot user remove [find where comment~"pix"]
|
||||
|
||||
:log info "pix-hotspot: setup de rede convidados concluido"
|
||||
Reference in new issue
Block a user