mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 09:23:07 +02:00
* 🚨 **[WIP]** fix: fastify dependencies
* update & fix http stuff
This commit is contained in:
parent
3e7127a3d9
commit
5f77b28012
@ -49,9 +49,9 @@
|
|||||||
"@eartharoid/dbf": "^0.4.2",
|
"@eartharoid/dbf": "^0.4.2",
|
||||||
"@eartharoid/dtf": "^2.0.1",
|
"@eartharoid/dtf": "^2.0.1",
|
||||||
"@eartharoid/i18n": "^1.2.1",
|
"@eartharoid/i18n": "^1.2.1",
|
||||||
"@fastify/cookie": "^6.0.0",
|
"@fastify/cookie": "^9.3.1",
|
||||||
"@fastify/jwt": "^5.0.1",
|
"@fastify/jwt": "^8.0.0",
|
||||||
"@fastify/oauth2": "^5.1.0",
|
"@fastify/oauth2": "^7.8.0",
|
||||||
"@prisma/client": "^4.16.2",
|
"@prisma/client": "^4.16.2",
|
||||||
"boxen": "^7.1.1",
|
"boxen": "^7.1.1",
|
||||||
"cryptr": "^6.3.0",
|
"cryptr": "^6.3.0",
|
||||||
|
164
pnpm-lock.yaml
164
pnpm-lock.yaml
@ -18,14 +18,14 @@ dependencies:
|
|||||||
specifier: ^1.2.1
|
specifier: ^1.2.1
|
||||||
version: 1.2.1
|
version: 1.2.1
|
||||||
'@fastify/cookie':
|
'@fastify/cookie':
|
||||||
specifier: ^6.0.0
|
specifier: ^9.3.1
|
||||||
version: 6.0.0
|
version: 9.3.1
|
||||||
'@fastify/jwt':
|
'@fastify/jwt':
|
||||||
specifier: ^5.0.1
|
specifier: ^8.0.0
|
||||||
version: 5.0.1
|
version: 8.0.0
|
||||||
'@fastify/oauth2':
|
'@fastify/oauth2':
|
||||||
specifier: ^5.1.0
|
specifier: ^7.8.0
|
||||||
version: 5.1.0
|
version: 7.8.0
|
||||||
'@prisma/client':
|
'@prisma/client':
|
||||||
specifier: ^4.16.2
|
specifier: ^4.16.2
|
||||||
version: 4.16.2(prisma@4.16.2)
|
version: 4.16.2(prisma@4.16.2)
|
||||||
@ -181,6 +181,7 @@ packages:
|
|||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
dependencies:
|
dependencies:
|
||||||
regenerator-runtime: 0.14.1
|
regenerator-runtime: 0.14.1
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@commitlint/cli@17.8.1:
|
/@commitlint/cli@17.8.1:
|
||||||
resolution: {integrity: sha512-ay+WbzQesE0Rv4EQKfNbSMiJJ12KdKTDzIt0tcK4k11FdsWmtwP0Kp1NWMOUswfIWo6Eb7p7Ln721Nx9FLNBjg==}
|
resolution: {integrity: sha512-ay+WbzQesE0Rv4EQKfNbSMiJJ12KdKTDzIt0tcK4k11FdsWmtwP0Kp1NWMOUswfIWo6Eb7p7Ln721Nx9FLNBjg==}
|
||||||
@ -515,11 +516,11 @@ packages:
|
|||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@fastify/cookie@6.0.0:
|
/@fastify/cookie@9.3.1:
|
||||||
resolution: {integrity: sha512-Luy3Po3dOJmqAuPCiPcWsX0tV5+C3AOnULSdlsGjNGOvyE7jqzysp8kT9ICfsUvove+TeUMgTWl1y9XS3ZPPMg==}
|
resolution: {integrity: sha512-h1NAEhB266+ZbZ0e9qUE6NnNR07i7DnNXWG9VbbZ8uC6O/hxHpl+Zoe5sw1yfdZ2U6XhToUGDnzQtWJdCaPwfg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
cookie-signature: 1.2.1
|
cookie-signature: 1.2.1
|
||||||
fastify-plugin: 3.0.1
|
fastify-plugin: 4.5.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@fastify/deepmerge@1.3.0:
|
/@fastify/deepmerge@1.3.0:
|
||||||
@ -536,22 +537,22 @@ packages:
|
|||||||
fast-json-stringify: 5.10.0
|
fast-json-stringify: 5.10.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@fastify/jwt@5.0.1:
|
/@fastify/jwt@8.0.0:
|
||||||
resolution: {integrity: sha512-BF2JrhSRcMRwHim2pbFEgWLJE8DdRh0NaGeAgU+ZFICj2AHxGvrHSOaYRaXNUQixgmGjVaTrbRFl3bSBc6Pj+g==}
|
resolution: {integrity: sha512-pJHjmZaokteZFMbsVVt7pbyJpbDogTnpl/aD7eR3vLOPgfktp4k4gUM6cd7RtjL/Ol1qDwL5mup+vdNlZI3K0Q==}
|
||||||
engines: {node: '>=10'}
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@fastify/error': 3.4.0
|
||||||
'@lukeed/ms': 2.0.2
|
'@lukeed/ms': 2.0.2
|
||||||
fast-jwt: 1.7.2
|
fast-jwt: 3.3.2
|
||||||
fastify-plugin: 3.0.1
|
fastify-plugin: 4.5.1
|
||||||
http-errors: 2.0.0
|
|
||||||
steed: 1.1.3
|
steed: 1.1.3
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@fastify/oauth2@5.1.0:
|
/@fastify/oauth2@7.8.0:
|
||||||
resolution: {integrity: sha512-Z/2ZR8v2BB+vwFm1t0DnavxAKymCGvJiGD/lTtNV/dTPHTHRQ1X68hFs/Nl2Rd0Gv9AlSlrpYsX9hfoNjTSiYQ==}
|
resolution: {integrity: sha512-piQldGFUfAH0+SXM7Cw6hlanFmYnTWYtDC3EcbxNiQedAbr9SbGNxJynTHsvyKzRO7dupdxIdWA81k1egxKftQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@fastify/cookie': 9.3.1
|
||||||
fastify-plugin: 4.5.1
|
fastify-plugin: 4.5.1
|
||||||
simple-oauth2: 3.4.0
|
simple-oauth2: 5.0.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: false
|
dev: false
|
||||||
@ -562,63 +563,40 @@ packages:
|
|||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@hapi/address@2.1.4:
|
/@hapi/boom@10.0.1:
|
||||||
resolution: {integrity: sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ==}
|
resolution: {integrity: sha512-ERcCZaEjdH3OgSJlyjVk8pHIFeus91CjKP3v+MpgBNp5IvGzP2l/bRiD78nqYcKPaZdbKkK5vDBVPd2ohHBlsA==}
|
||||||
deprecated: Moved to 'npm install @sideway/address'
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@hapi/boom@7.4.11:
|
|
||||||
resolution: {integrity: sha512-VSU/Cnj1DXouukYxxkes4nNJonCnlogHvIff1v1RVoN4xzkKhMXX+GRmb3NyH1iar10I9WFPDv2JPwfH3GaV0A==}
|
|
||||||
deprecated: This version has been deprecated and is no longer supported or maintained
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@hapi/hoek': 8.5.1
|
'@hapi/hoek': 11.0.2
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@hapi/bourne@1.3.2:
|
/@hapi/bourne@3.0.0:
|
||||||
resolution: {integrity: sha512-1dVNHT76Uu5N3eJNTYcvxee+jzX4Z9lfciqRRHCU27ihbUcYi+iSc2iml5Ke1LXe1SyJCLA0+14Jh4tXJgOppA==}
|
resolution: {integrity: sha512-Waj1cwPXJDucOib4a3bAISsKJVb15MKi9IvmTI/7ssVEm6sywXGjVJDhl6/umt1pK1ZS7PacXU3A1PmFKHEZ2w==}
|
||||||
deprecated: This version has been deprecated and is no longer supported or maintained
|
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@hapi/formula@1.2.0:
|
/@hapi/hoek@10.0.1:
|
||||||
resolution: {integrity: sha512-UFbtbGPjstz0eWHb+ga/GM3Z9EzqKXFWIbSOFURU0A/Gku0Bky4bCk9/h//K2Xr3IrCfjFNhMm4jyZ5dbCewGA==}
|
resolution: {integrity: sha512-CvlW7jmOhWzuqOqiJQ3rQVLMcREh0eel4IBnxDx2FAcK8g7qoJRQK4L1CPBASoCY6y8e6zuCy3f2g+HWdkzcMw==}
|
||||||
deprecated: Moved to 'npm install @sideway/formula'
|
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@hapi/hoek@8.5.1:
|
/@hapi/hoek@11.0.2:
|
||||||
resolution: {integrity: sha512-yN7kbciD87WzLGc5539Tn0sApjyiGHAJgKvG9W8C7O+6c7qmoQMfVs0W4bX17eqz6C78QJqqFrtgdK5EWf6Qow==}
|
resolution: {integrity: sha512-aKmlCO57XFZ26wso4rJsW4oTUnrgTFw2jh3io7CAtO9w4UltBNwRXvXIVzzyfkaaLRo3nluP/19msA8vDUUuKw==}
|
||||||
deprecated: This version has been deprecated and is no longer supported or maintained
|
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@hapi/joi@16.1.8:
|
/@hapi/hoek@9.3.0:
|
||||||
resolution: {integrity: sha512-wAsVvTPe+FwSrsAurNt5vkg3zo+TblvC5Bb1zMVK6SJzZqw9UrJnexxR+76cpePmtUZKHAPxcQ2Bf7oVHyahhg==}
|
resolution: {integrity: sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==}
|
||||||
deprecated: Switch to 'npm install joi'
|
dev: false
|
||||||
|
|
||||||
|
/@hapi/topo@5.1.0:
|
||||||
|
resolution: {integrity: sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@hapi/address': 2.1.4
|
'@hapi/hoek': 9.3.0
|
||||||
'@hapi/formula': 1.2.0
|
|
||||||
'@hapi/hoek': 8.5.1
|
|
||||||
'@hapi/pinpoint': 1.0.2
|
|
||||||
'@hapi/topo': 3.1.6
|
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@hapi/pinpoint@1.0.2:
|
/@hapi/wreck@18.0.1:
|
||||||
resolution: {integrity: sha512-dtXC/WkZBfC5vxscazuiJ6iq4j9oNx1SHknmIr8hofarpKUZKmlUVYVIhNVzIEgK5Wrc4GMHL5lZtt1uS2flmQ==}
|
resolution: {integrity: sha512-OLHER70+rZxvDl75xq3xXOfd3e8XIvz8fWY0dqg92UvhZ29zo24vQgfqgHSYhB5ZiuFpSLeriOisAlxAo/1jWg==}
|
||||||
deprecated: Moved to 'npm install @sideway/pinpoint'
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@hapi/topo@3.1.6:
|
|
||||||
resolution: {integrity: sha512-tAag0jEcjwH+P2quUfipd7liWCNX2F8NvYjQp2wtInsZxnMlypdw0FtAOLxtvvkO+GSRRbmNi8m/5y42PQJYCQ==}
|
|
||||||
deprecated: This version has been deprecated and is no longer supported or maintained
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@hapi/hoek': 8.5.1
|
'@hapi/boom': 10.0.1
|
||||||
dev: false
|
'@hapi/bourne': 3.0.0
|
||||||
|
'@hapi/hoek': 11.0.2
|
||||||
/@hapi/wreck@15.1.0:
|
|
||||||
resolution: {integrity: sha512-tQczYRTTeYBmvhsek/D49En/5khcShaBEmzrAaDjMrFXKJRuF8xA8+tlq1ETLBFwGd6Do6g2OC74rt11kzawzg==}
|
|
||||||
deprecated: This version has been deprecated and is no longer supported or maintained
|
|
||||||
dependencies:
|
|
||||||
'@hapi/boom': 7.4.11
|
|
||||||
'@hapi/bourne': 1.3.2
|
|
||||||
'@hapi/hoek': 8.5.1
|
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@humanwhocodes/config-array@0.11.14:
|
/@humanwhocodes/config-array@0.11.14:
|
||||||
@ -1575,11 +1553,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
|
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/depd@2.0.0:
|
|
||||||
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
|
|
||||||
engines: {node: '>= 0.8'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/dequal@2.0.3:
|
/dequal@2.0.3:
|
||||||
resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}
|
resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
@ -1886,10 +1859,11 @@ packages:
|
|||||||
rfdc: 1.3.0
|
rfdc: 1.3.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/fast-jwt@1.7.2:
|
/fast-jwt@3.3.2:
|
||||||
resolution: {integrity: sha512-OEInypGXJhtURzq9GbFM5KaALUu9+4IV3kJEbWPuqOBN5JBe7A51Tx0CaQYHGC9GNfZnr5npA0lCIMaWiZmz/A==}
|
resolution: {integrity: sha512-H+JYxaFy2LepiC1AQWM/2hzKlQOWaWUkEnu/yebhYu4+ameb3qG77WiRZ1Ct6YBk6d/ESsNguBfTT5+q0XMtKg==}
|
||||||
engines: {node: '>=14 <20'}
|
engines: {node: '>=16 <22'}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@lukeed/ms': 2.0.1
|
||||||
asn1.js: 5.4.1
|
asn1.js: 5.4.1
|
||||||
ecdsa-sig-formatter: 1.0.11
|
ecdsa-sig-formatter: 1.0.11
|
||||||
mnemonist: 0.39.7
|
mnemonist: 0.39.7
|
||||||
@ -1921,10 +1895,6 @@ packages:
|
|||||||
reusify: 1.0.4
|
reusify: 1.0.4
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/fastify-plugin@3.0.1:
|
|
||||||
resolution: {integrity: sha512-qKcDXmuZadJqdTm6vlCqioEbyewF60b/0LOFCcYN1B6BIZGlYJumWWOYs70SFYLDAH4YqdE1cxH/RKMG7rFxgA==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/fastify-plugin@4.5.1:
|
/fastify-plugin@4.5.1:
|
||||||
resolution: {integrity: sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ==}
|
resolution: {integrity: sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ==}
|
||||||
dev: false
|
dev: false
|
||||||
@ -2239,17 +2209,6 @@ packages:
|
|||||||
lru-cache: 6.0.0
|
lru-cache: 6.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/http-errors@2.0.0:
|
|
||||||
resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==}
|
|
||||||
engines: {node: '>= 0.8'}
|
|
||||||
dependencies:
|
|
||||||
depd: 2.0.0
|
|
||||||
inherits: 2.0.4
|
|
||||||
setprototypeof: 1.2.0
|
|
||||||
statuses: 2.0.1
|
|
||||||
toidentifier: 1.0.1
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/human-signals@2.1.0:
|
/human-signals@2.1.0:
|
||||||
resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==}
|
resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==}
|
||||||
engines: {node: '>=10.17.0'}
|
engines: {node: '>=10.17.0'}
|
||||||
@ -2435,6 +2394,16 @@ packages:
|
|||||||
resolution: {integrity: sha512-4dG1D1x/7g8PwHS9aK6QV5V94+ZvyP4+d19qDv43EzImmrndysIl4prmJ1hWWIGCqrZHyaHBm6BSEWHOLnpoNw==}
|
resolution: {integrity: sha512-4dG1D1x/7g8PwHS9aK6QV5V94+ZvyP4+d19qDv43EzImmrndysIl4prmJ1hWWIGCqrZHyaHBm6BSEWHOLnpoNw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/joi@17.11.0:
|
||||||
|
resolution: {integrity: sha512-NgB+lZLNoqISVy1rZocE9PZI36bL/77ie924Ri43yEvi9GUUMPeyVIr8KdFTMUlby1p0PBYMk9spIxEUQYqrJQ==}
|
||||||
|
dependencies:
|
||||||
|
'@hapi/hoek': 9.3.0
|
||||||
|
'@hapi/topo': 5.1.0
|
||||||
|
'@sideway/address': 4.1.4
|
||||||
|
'@sideway/formula': 3.0.1
|
||||||
|
'@sideway/pinpoint': 2.0.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
/js-tokens@4.0.0:
|
/js-tokens@4.0.0:
|
||||||
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
||||||
dev: true
|
dev: true
|
||||||
@ -3216,6 +3185,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==}
|
resolution: {integrity: sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/process-warning@3.0.0:
|
||||||
|
resolution: {integrity: sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/process@0.11.10:
|
/process@0.11.10:
|
||||||
resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==}
|
resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==}
|
||||||
engines: {node: '>= 0.6.0'}
|
engines: {node: '>= 0.6.0'}
|
||||||
@ -3493,10 +3466,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==}
|
resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/setprototypeof@1.2.0:
|
|
||||||
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/shebang-command@2.0.0:
|
/shebang-command@2.0.0:
|
||||||
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
|
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
@ -3518,15 +3487,13 @@ packages:
|
|||||||
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
|
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/simple-oauth2@3.4.0:
|
/simple-oauth2@5.0.0:
|
||||||
resolution: {integrity: sha512-gDPCC/xjq82FJnzF7+XGUUMWWfHeibuGsp3OYOV7yHwIibxHkq4+WSxywY63/3BF9j8SfIDygGqBrPLynx/iuQ==}
|
resolution: {integrity: sha512-8291lo/z5ZdpmiOFzOs1kF3cxn22bMj5FFH+DNUppLJrpoIlM1QnFiE7KpshHu3J3i21TVcx4yW+gXYjdCKDLQ==}
|
||||||
deprecated: simple-oauth2 v3 is no longer supported. Use simple-oauth2 v4 or higher for continued support
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@hapi/hoek': 8.5.1
|
'@hapi/hoek': 10.0.1
|
||||||
'@hapi/joi': 16.1.8
|
'@hapi/wreck': 18.0.1
|
||||||
'@hapi/wreck': 15.1.0
|
|
||||||
date-fns: 2.30.0
|
|
||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
|
joi: 17.11.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: false
|
dev: false
|
||||||
@ -3609,11 +3576,6 @@ packages:
|
|||||||
through: 2.3.8
|
through: 2.3.8
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/statuses@2.0.1:
|
|
||||||
resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==}
|
|
||||||
engines: {node: '>= 0.8'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/steed@1.1.3:
|
/steed@1.1.3:
|
||||||
resolution: {integrity: sha512-EUkci0FAUiE4IvGTSKcDJIQ/eRUP2JJb56+fvZ4sdnguLTqIdKjSxUe138poW8mkvKWXW2sFPrgTsxqoISnmoA==}
|
resolution: {integrity: sha512-EUkci0FAUiE4IvGTSKcDJIQ/eRUP2JJb56+fvZ4sdnguLTqIdKjSxUe138poW8mkvKWXW2sFPrgTsxqoISnmoA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
47
src/http.js
47
src/http.js
@ -9,16 +9,34 @@ const { PermissionsBitField } = require('discord.js');
|
|||||||
process.env.ORIGIN = process.env.HTTP_INTERNAL || process.env.HTTP_EXTERNAL;
|
process.env.ORIGIN = process.env.HTTP_INTERNAL || process.env.HTTP_EXTERNAL;
|
||||||
|
|
||||||
module.exports = async client => {
|
module.exports = async client => {
|
||||||
|
// cookies plugin, must be registered before oauth2 since oauth2@7.2.0
|
||||||
|
fastify.register(require('@fastify/cookie'));
|
||||||
|
|
||||||
|
// jwt plugin
|
||||||
|
fastify.register(require('@fastify/jwt'), {
|
||||||
|
cookie: {
|
||||||
|
cookieName: 'token',
|
||||||
|
signed: false,
|
||||||
|
},
|
||||||
|
secret: process.env.ENCRYPTION_KEY,
|
||||||
|
});
|
||||||
|
|
||||||
// oauth2 plugin
|
// oauth2 plugin
|
||||||
fastify.states = new Map();
|
fastify.states = new Map();
|
||||||
fastify.register(oauth, {
|
fastify.register(oauth, {
|
||||||
callbackUri: `${process.env.HTTP_EXTERNAL}/auth/callback`,
|
callbackUri: `${process.env.HTTP_EXTERNAL}/auth/callback`,
|
||||||
checkStateFunction: (state, callback) => {
|
// checkStateFunction: (req, callback) => {
|
||||||
if (fastify.states.has(state)) {
|
// if (req.query.state === req.cookies['oauth2-redirect-state']) {
|
||||||
callback();
|
// callback();
|
||||||
return;
|
// return;
|
||||||
|
// }
|
||||||
|
// callback(new Error('Invalid state'));
|
||||||
|
// },
|
||||||
|
checkStateFunction: async req => {
|
||||||
|
if (req.query.state !== req.cookies['oauth2-redirect-state']) {
|
||||||
|
throw new Error('Invalid state');
|
||||||
}
|
}
|
||||||
callback(new Error('Invalid state'));
|
return true;
|
||||||
},
|
},
|
||||||
credentials: {
|
credentials: {
|
||||||
auth: oauth.DISCORD_CONFIGURATION,
|
auth: oauth.DISCORD_CONFIGURATION,
|
||||||
@ -37,17 +55,6 @@ module.exports = async client => {
|
|||||||
startRedirectPath: '/auth/login',
|
startRedirectPath: '/auth/login',
|
||||||
});
|
});
|
||||||
|
|
||||||
// cookies plugin
|
|
||||||
fastify.register(require('@fastify/cookie'));
|
|
||||||
|
|
||||||
// jwt plugin
|
|
||||||
fastify.register(require('@fastify/jwt'), {
|
|
||||||
cookie: {
|
|
||||||
cookieName: 'token',
|
|
||||||
signed: false,
|
|
||||||
},
|
|
||||||
secret: process.env.ENCRYPTION_KEY,
|
|
||||||
});
|
|
||||||
|
|
||||||
// auth
|
// auth
|
||||||
fastify.decorate('authenticate', async (req, res) => {
|
fastify.decorate('authenticate', async (req, res) => {
|
||||||
@ -122,13 +129,13 @@ module.exports = async client => {
|
|||||||
: responseTime >= 10
|
: responseTime >= 10
|
||||||
? '&e'
|
? '&e'
|
||||||
: '&a') + responseTime + 'ms';
|
: '&a') + responseTime + 'ms';
|
||||||
const level = req.routerPath === '/status'
|
const level = req.routeOptions.url === '/status'
|
||||||
? 'debug'
|
? 'debug'
|
||||||
: req.routerPath === '/*'
|
: req.routeOptions.url === '/*'
|
||||||
? 'verbose'
|
? 'verbose'
|
||||||
: 'info';
|
: 'info';
|
||||||
client.log[level].http(short(`${req.id} ${req.ip} ${req.method} ${req.routerPath ?? '*'} &m-+>&r ${status}&b in ${responseTime}`));
|
client.log[level].http(short(`${req.id} ${req.ip} ${req.method} ${req.routeOptions.url ?? '*'} &m-+>&r ${status}&b in ${responseTime}`));
|
||||||
if (!req.routerPath) client.log.verbose.http(`${req.id} ${req.method} ${req.url}`);
|
if (!req.routeOptions.url) client.log.verbose.http(`${req.id} ${req.method} ${req.url}`);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ const { ApplicationCommandPermissionType } = require('discord.js');
|
|||||||
module.exports.delete = fastify => ({
|
module.exports.delete = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async (req, res) => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const guild = client.guilds.cache.get(req.params.guild);
|
const guild = client.guilds.cache.get(req.params.guild);
|
||||||
const categoryId = Number(req.params.category);
|
const categoryId = Number(req.params.category);
|
||||||
const original = categoryId && await client.prisma.category.findUnique({ where: { id: categoryId } });
|
const original = categoryId && await client.prisma.category.findUnique({ where: { id: categoryId } });
|
||||||
@ -33,7 +33,7 @@ module.exports.delete = fastify => ({
|
|||||||
module.exports.get = fastify => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async (req, res) => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const guildId = req.params.guild;
|
const guildId = req.params.guild;
|
||||||
const categoryId = Number(req.params.category);
|
const categoryId = Number(req.params.category);
|
||||||
const category = await client.prisma.category.findUnique({
|
const category = await client.prisma.category.findUnique({
|
||||||
@ -68,7 +68,7 @@ module.exports.get = fastify => ({
|
|||||||
module.exports.patch = fastify => ({
|
module.exports.patch = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async (req, res) => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const guildId = req.params.guild;
|
const guildId = req.params.guild;
|
||||||
const categoryId = Number(req.params.category);
|
const categoryId = Number(req.params.category);
|
||||||
/** @type {import('discord.js').Guild} */
|
/** @type {import('discord.js').Guild} */
|
||||||
|
@ -3,7 +3,7 @@ const { logAdminEvent } = require('../../../../../../../../lib/logging');
|
|||||||
module.exports.delete = fastify => ({
|
module.exports.delete = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async (req, res) => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const guildId = req.params.guild;
|
const guildId = req.params.guild;
|
||||||
const categoryId = Number(req.params.category);
|
const categoryId = Number(req.params.category);
|
||||||
const questionId = req.params.question;
|
const questionId = req.params.question;
|
||||||
|
@ -12,9 +12,9 @@ const {
|
|||||||
} = require('../../../../../../lib/stats');
|
} = require('../../../../../../lib/stats');
|
||||||
|
|
||||||
module.exports.get = fastify => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
|
|
||||||
let { categories } = await client.prisma.guild.findUnique({
|
let { categories } = await client.prisma.guild.findUnique({
|
||||||
select: {
|
select: {
|
||||||
@ -54,9 +54,9 @@ module.exports.get = fastify => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
module.exports.post = fastify => ({
|
module.exports.post = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
|
|
||||||
const user = await client.users.fetch(req.user.id);
|
const user = await client.users.fetch(req.user.id);
|
||||||
const guild = client.guilds.cache.get(req.params.guild);
|
const guild = client.guilds.cache.get(req.params.guild);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module.exports.get = fastify => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const id = req.params.guild;
|
const id = req.params.guild;
|
||||||
const guild = client.guilds.cache.get(id) ?? {};
|
const guild = client.guilds.cache.get(id) ?? {};
|
||||||
const { query } = req.query;
|
const { query } = req.query;
|
||||||
|
@ -6,9 +6,9 @@ const {
|
|||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
|
|
||||||
module.exports.get = fastify => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import("client")} */
|
/** @type {import("client")} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const id = req.params.guild;
|
const id = req.params.guild;
|
||||||
const cacheKey = `cache/stats/guild:${id}`;
|
const cacheKey = `cache/stats/guild:${id}`;
|
||||||
let cached = await client.keyv.get(cacheKey);
|
let cached = await client.keyv.get(cacheKey);
|
||||||
|
@ -14,9 +14,9 @@ const emoji = require('node-emoji');
|
|||||||
const { logAdminEvent } = require('../../../../../lib/logging');
|
const { logAdminEvent } = require('../../../../../lib/logging');
|
||||||
|
|
||||||
module.exports.post = fastify => ({
|
module.exports.post = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const guild = client.guilds.cache.get(req.params.guild);
|
const guild = client.guilds.cache.get(req.params.guild);
|
||||||
const data = req.body;
|
const data = req.body;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
const { PermissionsBitField } = require('discord.js');
|
const { PermissionsBitField } = require('discord.js');
|
||||||
|
|
||||||
module.exports.get = fastify => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const id = req.params.guild;
|
const id = req.params.guild;
|
||||||
const guild = client.guilds.cache.get(id);
|
const guild = client.guilds.cache.get(id);
|
||||||
const settings = await client.prisma.guild.findUnique({ where: { id } }) ??
|
const settings = await client.prisma.guild.findUnique({ where: { id } }) ??
|
||||||
|
@ -2,9 +2,9 @@ const { logAdminEvent } = require('../../../../../lib/logging.js');
|
|||||||
const { Colors } = require('discord.js');
|
const { Colors } = require('discord.js');
|
||||||
|
|
||||||
module.exports.delete = fastify => ({
|
module.exports.delete = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const id = req.params.guild;
|
const id = req.params.guild;
|
||||||
await client.prisma.guild.delete({ where: { id } });
|
await client.prisma.guild.delete({ where: { id } });
|
||||||
const settings = await client.prisma.guild.create({ data: { id } });
|
const settings = await client.prisma.guild.create({ data: { id } });
|
||||||
@ -24,9 +24,9 @@ module.exports.delete = fastify => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
module.exports.get = fastify => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const id = req.params.guild;
|
const id = req.params.guild;
|
||||||
const settings = await client.prisma.guild.findUnique({ where: { id } }) ??
|
const settings = await client.prisma.guild.findUnique({ where: { id } }) ??
|
||||||
await client.prisma.guild.create({ data: { id } });
|
await client.prisma.guild.create({ data: { id } });
|
||||||
@ -37,7 +37,7 @@ module.exports.get = fastify => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
module.exports.patch = fastify => ({
|
module.exports.patch = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
const data = req.body;
|
const data = req.body;
|
||||||
if (data.hasOwnProperty('id')) delete data.id;
|
if (data.hasOwnProperty('id')) delete data.id;
|
||||||
if (data.hasOwnProperty('createdAt')) delete data.createdAt;
|
if (data.hasOwnProperty('createdAt')) delete data.createdAt;
|
||||||
@ -49,7 +49,7 @@ module.exports.patch = fastify => ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const id = req.params.guild;
|
const id = req.params.guild;
|
||||||
const original = await client.prisma.guild.findUnique({ where: { id } });
|
const original = await client.prisma.guild.findUnique({ where: { id } });
|
||||||
const settings = await client.prisma.guild.update({
|
const settings = await client.prisma.guild.update({
|
||||||
|
@ -4,7 +4,7 @@ const { logAdminEvent } = require('../../../../../../lib/logging');
|
|||||||
module.exports.delete = fastify => ({
|
module.exports.delete = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async (req, res) => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const guildId = req.params.guild;
|
const guildId = req.params.guild;
|
||||||
const tagId = Number(req.params.tag);
|
const tagId = Number(req.params.tag);
|
||||||
const original = tagId && await client.prisma.tag.findUnique({ where: { id: tagId } });
|
const original = tagId && await client.prisma.tag.findUnique({ where: { id: tagId } });
|
||||||
@ -41,7 +41,7 @@ module.exports.delete = fastify => ({
|
|||||||
module.exports.get = fastify => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async (req, res) => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const guildId = req.params.guild;
|
const guildId = req.params.guild;
|
||||||
const tagId = Number(req.params.tag);
|
const tagId = Number(req.params.tag);
|
||||||
const tag = await client.prisma.tag.findUnique({ where: { id: tagId } });
|
const tag = await client.prisma.tag.findUnique({ where: { id: tagId } });
|
||||||
@ -56,7 +56,7 @@ module.exports.get = fastify => ({
|
|||||||
module.exports.patch = fastify => ({
|
module.exports.patch = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async (req, res) => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const guildId = req.params.guild;
|
const guildId = req.params.guild;
|
||||||
const tagId = Number(req.params.tag);
|
const tagId = Number(req.params.tag);
|
||||||
const guild = client.guilds.cache.get(req.params.guild);
|
const guild = client.guilds.cache.get(req.params.guild);
|
||||||
|
@ -2,9 +2,9 @@ const ms = require('ms');
|
|||||||
const { logAdminEvent } = require('../../../../../../lib/logging');
|
const { logAdminEvent } = require('../../../../../../lib/logging');
|
||||||
|
|
||||||
module.exports.get = fastify => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
|
|
||||||
const { tags } = await client.prisma.guild.findUnique({
|
const { tags } = await client.prisma.guild.findUnique({
|
||||||
select: { tags: true },
|
select: { tags: true },
|
||||||
@ -18,9 +18,9 @@ module.exports.get = fastify => ({
|
|||||||
|
|
||||||
|
|
||||||
module.exports.post = fastify => ({
|
module.exports.post = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const guild = client.guilds.cache.get(req.params.guild);
|
const guild = client.guilds.cache.get(req.params.guild);
|
||||||
const data = req.body;
|
const data = req.body;
|
||||||
const tag = await client.prisma.tag.create({
|
const tag = await client.prisma.tag.create({
|
||||||
|
@ -2,7 +2,7 @@ const { PermissionsBitField } = require('discord.js');
|
|||||||
|
|
||||||
module.exports.get = fastify => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async (req, res) => {
|
handler: async (req, res) => {
|
||||||
const { client } = res.context.config;
|
const { client } = req.routeOptions.config;
|
||||||
const guilds = await (await fetch('https://discordapp.com/api/users/@me/guilds', { headers: { 'Authorization': `Bearer ${req.user.accessToken}` } })).json();
|
const guilds = await (await fetch('https://discordapp.com/api/users/@me/guilds', { headers: { 'Authorization': `Bearer ${req.user.accessToken}` } })).json();
|
||||||
res.send(
|
res.send(
|
||||||
guilds
|
guilds
|
||||||
|
@ -4,9 +4,9 @@ const {
|
|||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
|
|
||||||
module.exports.get = () => ({
|
module.exports.get = () => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import("client")} */
|
/** @type {import("client")} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
const cacheKey = 'cache/stats/client';
|
const cacheKey = 'cache/stats/client';
|
||||||
let cached = await client.keyv.get(cacheKey);
|
let cached = await client.keyv.get(cacheKey);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module.exports.get = () => ({
|
module.exports.get = () => ({
|
||||||
handler: async (req, res) => {
|
handler: async req => {
|
||||||
/** @type {import("client")} */
|
/** @type {import("client")} */
|
||||||
const client = res.context.config.client;
|
const client = req.routeOptions.config.client;
|
||||||
return client.i18n.locales;
|
return client.i18n.locales;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -2,18 +2,25 @@ const { domain } = require('../../lib/http');
|
|||||||
|
|
||||||
module.exports.get = () => ({
|
module.exports.get = () => ({
|
||||||
handler: async function (req, res) { // MUST NOT use arrow function syntax
|
handler: async function (req, res) { // MUST NOT use arrow function syntax
|
||||||
const {
|
const data = await (await fetch('https://discord.com/api/oauth2/token', {
|
||||||
access_token: accessToken,
|
body: new URLSearchParams({
|
||||||
expires_in: expiresIn,
|
client_id: req.routeOptions.config.client.user.id,
|
||||||
} = await this.discord.getAccessTokenFromAuthorizationCodeFlow(req);
|
client_secret: process.env.DISCORD_SECRET,
|
||||||
|
code: req.query.code,
|
||||||
|
grant_type: 'authorization_code',
|
||||||
|
redirect_uri: `${process.env.HTTP_EXTERNAL}/auth/callback`,
|
||||||
|
}).toString(),
|
||||||
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
|
method: 'POST',
|
||||||
|
})).json();
|
||||||
const redirect = this.states.get(req.query.state) || '/';
|
const redirect = this.states.get(req.query.state) || '/';
|
||||||
this.states.delete(req.query.state);
|
this.states.delete(req.query.state);
|
||||||
const user = await (await fetch('https://discordapp.com/api/users/@me', { headers: { 'Authorization': `Bearer ${accessToken}` } })).json();
|
const user = await (await fetch('https://discordapp.com/api/users/@me', { headers: { 'Authorization': `Bearer ${data.access_token}` } })).json();
|
||||||
const token = this.jwt.sign({
|
const token = this.jwt.sign({
|
||||||
accessToken,
|
accessToken: data.access_token,
|
||||||
avatar: user.avatar,
|
avatar: user.avatar,
|
||||||
discriminator: user.discriminator,
|
discriminator: user.discriminator,
|
||||||
expiresAt: Date.now() + (expiresIn * 1000),
|
expiresAt: Date.now() + (data.expires_in * 1000),
|
||||||
id: user.id,
|
id: user.id,
|
||||||
locale: user.locale,
|
locale: user.locale,
|
||||||
username: user.username,
|
username: user.username,
|
||||||
@ -21,7 +28,7 @@ module.exports.get = () => ({
|
|||||||
res.setCookie('token', token, {
|
res.setCookie('token', token, {
|
||||||
domain,
|
domain,
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
maxAge: expiresIn,
|
maxAge: data.expires_in,
|
||||||
path: '/',
|
path: '/',
|
||||||
sameSite: 'Lax',
|
sameSite: 'Lax',
|
||||||
secure: false,
|
secure: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user