Use nswag generator

This commit is contained in:
2024-10-02 21:03:18 -03:00
parent 332c0b2fa6
commit b5d1e086f3
25 changed files with 3063 additions and 1456 deletions

1
.prettierignore Normal file
View File

@ -0,0 +1 @@
src/api.generated.ts

View File

@ -1,15 +1,14 @@
// Copyright (c) Tribufu. All Rights Reserved. // Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT AND Apache-2.0
import dotenv from 'dotenv'; import dotenv from "dotenv";
import { TribufuApi } from '../build/index.mjs'; import { TribufuApi } from "../build/index.mjs";
dotenv.config(); dotenv.config();
async function main() { async function main() {
const api = TribufuApi.fromEnv("TRIBUFU"); const api = TribufuApi.fromEnv("TRIBUFU");
const games = await api.getGames(); console.log(await api.authGetUserInfo());
console.log(games[0]);
} }
main(); main();

View File

@ -1,10 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import dotenv from 'dotenv';
import { TribufuBot } from '../build/index.mjs';
dotenv.config();
const bot = TribufuBot.fromEnv("TRIBUFU");
const botId = bot.getBotId();

View File

@ -1,15 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import dotenv from 'dotenv';
import { TribufuClient } from '../build/index.mjs';
dotenv.config();
async function main() {
const client = TribufuClient.fromEnv("TRIBUFU");
const games = await client.getServers();
console.log(games);
}
main();

View File

@ -1,11 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import dotenv from 'dotenv';
import { TribufuServer } from '../build/index.mjs';
dotenv.config();
const server = TribufuServer.fromEnv("TRIBUFU");
const serverId = server.getServerId();
const clientId = server.getClientId();

View File

@ -1,6 +1,6 @@
{ {
"name": "tribufu", "name": "tribufu",
"version": "0.1.19", "version": "0.1.20",
"description": "Tribufu JS SDK", "description": "Tribufu JS SDK",
"repository": "https://github.com/Tribufu/TribufuJs", "repository": "https://github.com/Tribufu/TribufuJs",
"author": "Tribufu <contact@Tribufu.com>", "author": "Tribufu <contact@Tribufu.com>",
@ -15,15 +15,14 @@
"clean": "rimraf build", "clean": "rimraf build",
"build": "npm run clean && tsc && node scripts/esbuild.js" "build": "npm run clean && tsc && node scripts/esbuild.js"
}, },
"dependencies": { "dependencies": {},
"@tribufu/mintaka": "0.1.8"
},
"devDependencies": { "devDependencies": {
"@types/node": "^20.10.6", "@types/node": "^20.10.6",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"esbuild": "^0.19.10",
"esbuild-node-externals": "^1.12.0", "esbuild-node-externals": "^1.12.0",
"esbuild": "^0.19.10",
"eslint": "9.11.1",
"prettier": "3.3.3",
"rimraf": "^5.0.5", "rimraf": "^5.0.5",
"typescript": "^5.3.3" "typescript": "^5.3.3"
} }

748
pnpm-lock.yaml generated
View File

@ -5,14 +5,23 @@ settings:
excludeLinksFromLockfile: false excludeLinksFromLockfile: false
dependencies: dependencies:
'@tribufu/mintaka': json-bigint:
specifier: 0.1.8 specifier: ^1.0.0
version: 0.1.8 version: 1.0.0
devDependencies: devDependencies:
'@types/json-bigint':
specifier: ^1.0.4
version: 1.0.4
'@types/jsonwebtoken':
specifier: ^9.0.5
version: 9.0.7
'@types/node': '@types/node':
specifier: ^20.10.6 specifier: ^20.10.6
version: 20.10.6 version: 20.10.6
'@types/uuid':
specifier: ^9.0.7
version: 9.0.8
cross-env: cross-env:
specifier: ^7.0.3 specifier: ^7.0.3
version: 7.0.3 version: 7.0.3
@ -25,6 +34,12 @@ devDependencies:
esbuild-node-externals: esbuild-node-externals:
specifier: ^1.12.0 specifier: ^1.12.0
version: 1.12.0(esbuild@0.19.11) version: 1.12.0(esbuild@0.19.11)
eslint:
specifier: 9.11.1
version: 9.11.1
prettier:
specifier: 3.3.3
version: 3.3.3
rimraf: rimraf:
specifier: ^5.0.5 specifier: ^5.0.5
version: 5.0.5 version: 5.0.5
@ -241,6 +256,81 @@ packages:
dev: true dev: true
optional: true optional: true
/@eslint-community/eslint-utils@4.4.0(eslint@9.11.1):
resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || >=8.0.0
dependencies:
eslint: 9.11.1
eslint-visitor-keys: 3.4.3
dev: true
/@eslint-community/regexpp@4.11.1:
resolution: {integrity: sha512-m4DVN9ZqskZoLU5GlWZadwDnYo3vAEydiUayB9widCl9ffWx2IvPnp6n3on5rJmziJSw9Bv+Z3ChDVdMwXCY8Q==}
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
dev: true
/@eslint/config-array@0.18.0:
resolution: {integrity: sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
dependencies:
'@eslint/object-schema': 2.1.4
debug: 4.3.7
minimatch: 3.1.2
transitivePeerDependencies:
- supports-color
dev: true
/@eslint/core@0.6.0:
resolution: {integrity: sha512-8I2Q8ykA4J0x0o7cg67FPVnehcqWTBehu/lmY+bolPFHGjh49YzGBMXTvpqVgEbBdvNCSxj6iFgiIyHzf03lzg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
dev: true
/@eslint/eslintrc@3.1.0:
resolution: {integrity: sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
dependencies:
ajv: 6.12.6
debug: 4.3.7
espree: 10.2.0
globals: 14.0.0
ignore: 5.3.2
import-fresh: 3.3.0
js-yaml: 4.1.0
minimatch: 3.1.2
strip-json-comments: 3.1.1
transitivePeerDependencies:
- supports-color
dev: true
/@eslint/js@9.11.1:
resolution: {integrity: sha512-/qu+TWz8WwPWc7/HcIJKi+c+MOm46GdVaSlTTQcaqaL53+GsoA6MxWp5PtTx48qbSP7ylM1Kn7nhvkugfJvRSA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
dev: true
/@eslint/object-schema@2.1.4:
resolution: {integrity: sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
dev: true
/@eslint/plugin-kit@0.2.0:
resolution: {integrity: sha512-vH9PiIMMwvhCx31Af3HiGzsVNULDbyVkHXwlemn/B0TFj/00ho3y55efXrUZTfQipxoHC5u4xq6zblww1zm1Ig==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
dependencies:
levn: 0.4.1
dev: true
/@humanwhocodes/module-importer@1.0.1:
resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==}
engines: {node: '>=12.22'}
dev: true
/@humanwhocodes/retry@0.3.0:
resolution: {integrity: sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==}
engines: {node: '>=18.18'}
dev: true
/@isaacs/cliui@8.0.2: /@isaacs/cliui@8.0.2:
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
engines: {node: '>=12'} engines: {node: '>=12'}
@ -253,6 +343,27 @@ packages:
wrap-ansi-cjs: /wrap-ansi@7.0.0 wrap-ansi-cjs: /wrap-ansi@7.0.0
dev: true dev: true
/@nodelib/fs.scandir@2.1.5:
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
dependencies:
'@nodelib/fs.stat': 2.0.5
run-parallel: 1.2.0
dev: true
/@nodelib/fs.stat@2.0.5:
resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==}
engines: {node: '>= 8'}
dev: true
/@nodelib/fs.walk@1.2.8:
resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}
engines: {node: '>= 8'}
dependencies:
'@nodelib/fs.scandir': 2.1.5
fastq: 1.17.1
dev: true
/@pkgjs/parseargs@0.11.0: /@pkgjs/parseargs@0.11.0:
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
engines: {node: '>=14'} engines: {node: '>=14'}
@ -260,21 +371,23 @@ packages:
dev: true dev: true
optional: true optional: true
/@tribufu/mintaka@0.1.8: /@types/estree@1.0.6:
resolution: {integrity: sha512-qUvReWlz8irSIbKCTfjFnUnUq7MIgLjnTBPeWv2ayyiwGkf8L3q7qi1Zxuqt3OduOugSOtxYQwXOaClldIMUTQ==} resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==}
dev: true
/@types/json-bigint@1.0.4:
resolution: {integrity: sha512-ydHooXLbOmxBbubnA7Eh+RpBzuaIiQjh8WGJYQB50JFGFrdxW7JzVlyEV7fAXw0T2sqJ1ysTneJbiyNLqZRAag==}
dev: true
/@types/json-schema@7.0.15:
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
dev: true
/@types/jsonwebtoken@9.0.7:
resolution: {integrity: sha512-ugo316mmTYBl2g81zDFnZ7cfxlut3o+/EQdaP7J8QN2kY6lJ22hmQYCK5EHcJHbrW+dkCGSCPgbG8JtYj6qSrg==}
dependencies: dependencies:
axios: 1.6.4 '@types/node': 20.10.6
camelcase-keys: 9.1.2 dev: true
fp-ts: 2.16.2
json-bigint: 1.0.0
jsonwebtoken: 9.0.2
snakecase-keys: 5.5.0
toml: 3.0.0
uuid: 9.0.1
uuidv7: 0.6.3
transitivePeerDependencies:
- debug
dev: false
/@types/node@20.10.6: /@types/node@20.10.6:
resolution: {integrity: sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==} resolution: {integrity: sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==}
@ -282,6 +395,33 @@ packages:
undici-types: 5.26.5 undici-types: 5.26.5
dev: true dev: true
/@types/uuid@9.0.8:
resolution: {integrity: sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==}
dev: true
/acorn-jsx@5.3.2(acorn@8.12.1):
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
peerDependencies:
acorn: ^6.0.0 || ^7.0.0 || ^8.0.0
dependencies:
acorn: 8.12.1
dev: true
/acorn@8.12.1:
resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==}
engines: {node: '>=0.4.0'}
hasBin: true
dev: true
/ajv@6.12.6:
resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==}
dependencies:
fast-deep-equal: 3.1.3
fast-json-stable-stringify: 2.1.0
json-schema-traverse: 0.4.1
uri-js: 4.4.1
dev: true
/ansi-regex@5.0.1: /ansi-regex@5.0.1:
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -304,19 +444,9 @@ packages:
engines: {node: '>=12'} engines: {node: '>=12'}
dev: true dev: true
/asynckit@0.4.0: /argparse@2.0.1:
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
dev: false dev: true
/axios@1.6.4:
resolution: {integrity: sha512-heJnIs6N4aa1eSthhN9M5ioILu8Wi8vmQW9iHQ9NUvfkJb0lEEDUiIdQNAuBtfUt3FxReaKdpQA5DbmMOqzF/A==}
dependencies:
follow-redirects: 1.15.4
form-data: 4.0.0
proxy-from-env: 1.1.0
transitivePeerDependencies:
- debug
dev: false
/balanced-match@1.0.2: /balanced-match@1.0.2:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
@ -326,30 +456,31 @@ packages:
resolution: {integrity: sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==} resolution: {integrity: sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==}
dev: false dev: false
/brace-expansion@1.1.11:
resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==}
dependencies:
balanced-match: 1.0.2
concat-map: 0.0.1
dev: true
/brace-expansion@2.0.1: /brace-expansion@2.0.1:
resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==}
dependencies: dependencies:
balanced-match: 1.0.2 balanced-match: 1.0.2
dev: true dev: true
/buffer-equal-constant-time@1.0.1: /callsites@3.1.0:
resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==} resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
dev: false engines: {node: '>=6'}
dev: true
/camelcase-keys@9.1.2: /chalk@4.1.2:
resolution: {integrity: sha512-nFhquwz7p3nWSHeVYoIkefNPdR2Rt4EuKs9/gaqx3DhJL6HkNHIEcsH+D6N4NvW/MHxc4TT+rp0rc4K7E7x9hw==} resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
engines: {node: '>=16'} engines: {node: '>=10'}
dependencies: dependencies:
camelcase: 8.0.0 ansi-styles: 4.3.0
map-obj: 5.0.0 supports-color: 7.2.0
quick-lru: 6.1.2 dev: true
type-fest: 4.9.0
dev: false
/camelcase@8.0.0:
resolution: {integrity: sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==}
engines: {node: '>=16'}
dev: false
/color-convert@2.0.1: /color-convert@2.0.1:
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
@ -362,12 +493,9 @@ packages:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
dev: true dev: true
/combined-stream@1.0.8: /concat-map@0.0.1:
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
engines: {node: '>= 0.8'} dev: true
dependencies:
delayed-stream: 1.0.0
dev: false
/cross-env@7.0.3: /cross-env@7.0.3:
resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==}
@ -386,17 +514,21 @@ packages:
which: 2.0.2 which: 2.0.2
dev: true dev: true
/delayed-stream@1.0.0: /debug@4.3.7:
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} resolution: {integrity: sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==}
engines: {node: '>=0.4.0'} engines: {node: '>=6.0'}
dev: false peerDependencies:
supports-color: '*'
/dot-case@3.0.4: peerDependenciesMeta:
resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==} supports-color:
optional: true
dependencies: dependencies:
no-case: 3.0.4 ms: 2.1.3
tslib: 2.6.2 dev: true
dev: false
/deep-is@0.1.4:
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
dev: true
/dotenv@16.3.1: /dotenv@16.3.1:
resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==} resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==}
@ -407,12 +539,6 @@ packages:
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
dev: true dev: true
/ecdsa-sig-formatter@1.0.11:
resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==}
dependencies:
safe-buffer: 5.2.1
dev: false
/emoji-regex@8.0.0: /emoji-regex@8.0.0:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
dev: true dev: true
@ -463,6 +589,138 @@ packages:
'@esbuild/win32-x64': 0.19.11 '@esbuild/win32-x64': 0.19.11
dev: true dev: true
/escape-string-regexp@4.0.0:
resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
engines: {node: '>=10'}
dev: true
/eslint-scope@8.1.0:
resolution: {integrity: sha512-14dSvlhaVhKKsa9Fx1l8A17s7ah7Ef7wCakJ10LYk6+GYmP9yDti2oq2SEwcyndt6knfcZyhyxwY3i9yL78EQw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
dependencies:
esrecurse: 4.3.0
estraverse: 5.3.0
dev: true
/eslint-visitor-keys@3.4.3:
resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
/eslint-visitor-keys@4.1.0:
resolution: {integrity: sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
dev: true
/eslint@9.11.1:
resolution: {integrity: sha512-MobhYKIoAO1s1e4VUrgx1l1Sk2JBR/Gqjjgw8+mfgoLE2xwsHur4gdfTxyTgShrhvdVFTaJSgMiQBl1jv/AWxg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
hasBin: true
peerDependencies:
jiti: '*'
peerDependenciesMeta:
jiti:
optional: true
dependencies:
'@eslint-community/eslint-utils': 4.4.0(eslint@9.11.1)
'@eslint-community/regexpp': 4.11.1
'@eslint/config-array': 0.18.0
'@eslint/core': 0.6.0
'@eslint/eslintrc': 3.1.0
'@eslint/js': 9.11.1
'@eslint/plugin-kit': 0.2.0
'@humanwhocodes/module-importer': 1.0.1
'@humanwhocodes/retry': 0.3.0
'@nodelib/fs.walk': 1.2.8
'@types/estree': 1.0.6
'@types/json-schema': 7.0.15
ajv: 6.12.6
chalk: 4.1.2
cross-spawn: 7.0.3
debug: 4.3.7
escape-string-regexp: 4.0.0
eslint-scope: 8.1.0
eslint-visitor-keys: 4.1.0
espree: 10.2.0
esquery: 1.6.0
esutils: 2.0.3
fast-deep-equal: 3.1.3
file-entry-cache: 8.0.0
find-up: 5.0.0
glob-parent: 6.0.2
ignore: 5.3.2
imurmurhash: 0.1.4
is-glob: 4.0.3
is-path-inside: 3.0.3
json-stable-stringify-without-jsonify: 1.0.1
lodash.merge: 4.6.2
minimatch: 3.1.2
natural-compare: 1.4.0
optionator: 0.9.4
strip-ansi: 6.0.1
text-table: 0.2.0
transitivePeerDependencies:
- supports-color
dev: true
/espree@10.2.0:
resolution: {integrity: sha512-upbkBJbckcCNBDBDXEbuhjbP68n+scUd3k/U2EkyM9nw+I/jPiL4cLF/Al06CF96wRltFda16sxDFrxsI1v0/g==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
dependencies:
acorn: 8.12.1
acorn-jsx: 5.3.2(acorn@8.12.1)
eslint-visitor-keys: 4.1.0
dev: true
/esquery@1.6.0:
resolution: {integrity: sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==}
engines: {node: '>=0.10'}
dependencies:
estraverse: 5.3.0
dev: true
/esrecurse@4.3.0:
resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==}
engines: {node: '>=4.0'}
dependencies:
estraverse: 5.3.0
dev: true
/estraverse@5.3.0:
resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==}
engines: {node: '>=4.0'}
dev: true
/esutils@2.0.3:
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
engines: {node: '>=0.10.0'}
dev: true
/fast-deep-equal@3.1.3:
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
dev: true
/fast-json-stable-stringify@2.1.0:
resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==}
dev: true
/fast-levenshtein@2.0.6:
resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==}
dev: true
/fastq@1.17.1:
resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==}
dependencies:
reusify: 1.0.4
dev: true
/file-entry-cache@8.0.0:
resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==}
engines: {node: '>=16.0.0'}
dependencies:
flat-cache: 4.0.1
dev: true
/find-up@5.0.0: /find-up@5.0.0:
resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -471,15 +729,17 @@ packages:
path-exists: 4.0.0 path-exists: 4.0.0
dev: true dev: true
/follow-redirects@1.15.4: /flat-cache@4.0.1:
resolution: {integrity: sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==} resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==}
engines: {node: '>=4.0'} engines: {node: '>=16'}
peerDependencies: dependencies:
debug: '*' flatted: 3.3.1
peerDependenciesMeta: keyv: 4.5.4
debug: dev: true
optional: true
dev: false /flatted@3.3.1:
resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==}
dev: true
/foreground-child@3.1.1: /foreground-child@3.1.1:
resolution: {integrity: sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==} resolution: {integrity: sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==}
@ -489,18 +749,12 @@ packages:
signal-exit: 4.1.0 signal-exit: 4.1.0
dev: true dev: true
/form-data@4.0.0: /glob-parent@6.0.2:
resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==}
engines: {node: '>= 6'} engines: {node: '>=10.13.0'}
dependencies: dependencies:
asynckit: 0.4.0 is-glob: 4.0.3
combined-stream: 1.0.8 dev: true
mime-types: 2.1.35
dev: false
/fp-ts@2.16.2:
resolution: {integrity: sha512-CkqAjnIKFqvo3sCyoBTqgJvF+bHrSik584S9nhTjtBESLx26cbtVMR/T9a6ApChOcSDAaM3JydDmWDUn4EEXng==}
dev: false
/glob@10.3.10: /glob@10.3.10:
resolution: {integrity: sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==} resolution: {integrity: sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==}
@ -514,11 +768,56 @@ packages:
path-scurry: 1.10.1 path-scurry: 1.10.1
dev: true dev: true
/globals@14.0.0:
resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==}
engines: {node: '>=18'}
dev: true
/has-flag@4.0.0:
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
engines: {node: '>=8'}
dev: true
/ignore@5.3.2:
resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==}
engines: {node: '>= 4'}
dev: true
/import-fresh@3.3.0:
resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==}
engines: {node: '>=6'}
dependencies:
parent-module: 1.0.1
resolve-from: 4.0.0
dev: true
/imurmurhash@0.1.4:
resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==}
engines: {node: '>=0.8.19'}
dev: true
/is-extglob@2.1.1:
resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==}
engines: {node: '>=0.10.0'}
dev: true
/is-fullwidth-code-point@3.0.0: /is-fullwidth-code-point@3.0.0:
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
engines: {node: '>=8'} engines: {node: '>=8'}
dev: true dev: true
/is-glob@4.0.3:
resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==}
engines: {node: '>=0.10.0'}
dependencies:
is-extglob: 2.1.1
dev: true
/is-path-inside@3.0.3:
resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==}
engines: {node: '>=8'}
dev: true
/isexe@2.0.0: /isexe@2.0.0:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
dev: true dev: true
@ -532,42 +831,44 @@ packages:
'@pkgjs/parseargs': 0.11.0 '@pkgjs/parseargs': 0.11.0
dev: true dev: true
/js-yaml@4.1.0:
resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==}
hasBin: true
dependencies:
argparse: 2.0.1
dev: true
/json-bigint@1.0.0: /json-bigint@1.0.0:
resolution: {integrity: sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==} resolution: {integrity: sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==}
dependencies: dependencies:
bignumber.js: 9.1.2 bignumber.js: 9.1.2
dev: false dev: false
/jsonwebtoken@9.0.2: /json-buffer@3.0.1:
resolution: {integrity: sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==} resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==}
engines: {node: '>=12', npm: '>=6'} dev: true
dependencies:
jws: 3.2.2
lodash.includes: 4.3.0
lodash.isboolean: 3.0.3
lodash.isinteger: 4.0.4
lodash.isnumber: 3.0.3
lodash.isplainobject: 4.0.6
lodash.isstring: 4.0.1
lodash.once: 4.1.1
ms: 2.1.3
semver: 7.5.4
dev: false
/jwa@1.4.1: /json-schema-traverse@0.4.1:
resolution: {integrity: sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==} resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==}
dependencies: dev: true
buffer-equal-constant-time: 1.0.1
ecdsa-sig-formatter: 1.0.11
safe-buffer: 5.2.1
dev: false
/jws@3.2.2: /json-stable-stringify-without-jsonify@1.0.1:
resolution: {integrity: sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==} resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==}
dev: true
/keyv@4.5.4:
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
dependencies: dependencies:
jwa: 1.4.1 json-buffer: 3.0.1
safe-buffer: 5.2.1 dev: true
dev: false
/levn@0.4.1:
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
engines: {node: '>= 0.8.0'}
dependencies:
prelude-ls: 1.2.1
type-check: 0.4.0
dev: true
/locate-path@6.0.0: /locate-path@6.0.0:
resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}
@ -576,73 +877,20 @@ packages:
p-locate: 5.0.0 p-locate: 5.0.0
dev: true dev: true
/lodash.includes@4.3.0: /lodash.merge@4.6.2:
resolution: {integrity: sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==} resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==}
dev: false dev: true
/lodash.isboolean@3.0.3:
resolution: {integrity: sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==}
dev: false
/lodash.isinteger@4.0.4:
resolution: {integrity: sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==}
dev: false
/lodash.isnumber@3.0.3:
resolution: {integrity: sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==}
dev: false
/lodash.isplainobject@4.0.6:
resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==}
dev: false
/lodash.isstring@4.0.1:
resolution: {integrity: sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==}
dev: false
/lodash.once@4.1.1:
resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==}
dev: false
/lower-case@2.0.2:
resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==}
dependencies:
tslib: 2.6.2
dev: false
/lru-cache@10.1.0: /lru-cache@10.1.0:
resolution: {integrity: sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==} resolution: {integrity: sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==}
engines: {node: 14 || >=16.14} engines: {node: 14 || >=16.14}
dev: true dev: true
/lru-cache@6.0.0: /minimatch@3.1.2:
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
engines: {node: '>=10'}
dependencies: dependencies:
yallist: 4.0.0 brace-expansion: 1.1.11
dev: false dev: true
/map-obj@4.3.0:
resolution: {integrity: sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==}
engines: {node: '>=8'}
dev: false
/map-obj@5.0.0:
resolution: {integrity: sha512-2L3MIgJynYrZ3TYMriLDLWocz15okFakV6J12HXvMXDHui2x/zgChzg1u9mFFGbbGWE+GsLpQByt4POb9Or+uA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dev: false
/mime-db@1.52.0:
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
engines: {node: '>= 0.6'}
dev: false
/mime-types@2.1.35:
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
engines: {node: '>= 0.6'}
dependencies:
mime-db: 1.52.0
dev: false
/minimatch@9.0.3: /minimatch@9.0.3:
resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==}
@ -658,14 +906,23 @@ packages:
/ms@2.1.3: /ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
dev: false dev: true
/no-case@3.0.4: /natural-compare@1.4.0:
resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==} resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
dev: true
/optionator@0.9.4:
resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==}
engines: {node: '>= 0.8.0'}
dependencies: dependencies:
lower-case: 2.0.2 deep-is: 0.1.4
tslib: 2.6.2 fast-levenshtein: 2.0.6
dev: false levn: 0.4.1
prelude-ls: 1.2.1
type-check: 0.4.0
word-wrap: 1.2.5
dev: true
/p-limit@3.1.0: /p-limit@3.1.0:
resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==}
@ -681,6 +938,13 @@ packages:
p-limit: 3.1.0 p-limit: 3.1.0
dev: true dev: true
/parent-module@1.0.1:
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
engines: {node: '>=6'}
dependencies:
callsites: 3.1.0
dev: true
/path-exists@4.0.0: /path-exists@4.0.0:
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -699,14 +963,35 @@ packages:
minipass: 7.0.4 minipass: 7.0.4
dev: true dev: true
/proxy-from-env@1.1.0: /prelude-ls@1.2.1:
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
dev: false engines: {node: '>= 0.8.0'}
dev: true
/quick-lru@6.1.2: /prettier@3.3.3:
resolution: {integrity: sha512-AAFUA5O1d83pIHEhJwWCq/RQcRukCkn/NSm2QsTEMle5f2hP0ChI2+3Xb051PZCkLryI/Ir1MVKviT2FIloaTQ==} resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==}
engines: {node: '>=12'} engines: {node: '>=14'}
dev: false hasBin: true
dev: true
/punycode@2.3.1:
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
engines: {node: '>=6'}
dev: true
/queue-microtask@1.2.3:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
dev: true
/resolve-from@4.0.0:
resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==}
engines: {node: '>=4'}
dev: true
/reusify@1.0.4:
resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==}
engines: {iojs: '>=1.0.0', node: '>=0.10.0'}
dev: true
/rimraf@5.0.5: /rimraf@5.0.5:
resolution: {integrity: sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==} resolution: {integrity: sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==}
@ -716,17 +1001,11 @@ packages:
glob: 10.3.10 glob: 10.3.10
dev: true dev: true
/safe-buffer@5.2.1: /run-parallel@1.2.0:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
dev: false
/semver@7.5.4:
resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==}
engines: {node: '>=10'}
hasBin: true
dependencies: dependencies:
lru-cache: 6.0.0 queue-microtask: 1.2.3
dev: false dev: true
/shebang-command@2.0.0: /shebang-command@2.0.0:
resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
@ -745,22 +1024,6 @@ packages:
engines: {node: '>=14'} engines: {node: '>=14'}
dev: true dev: true
/snake-case@3.0.4:
resolution: {integrity: sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==}
dependencies:
dot-case: 3.0.4
tslib: 2.6.2
dev: false
/snakecase-keys@5.5.0:
resolution: {integrity: sha512-r3kRtnoPu3FxGJ3fny6PKNnU3pteb29o6qAa0ugzhSseKNWRkw1dw8nIjXMyyKaU9vQxxVIE62Mb3bKbdrgpiw==}
engines: {node: '>=12'}
dependencies:
map-obj: 4.3.0
snake-case: 3.0.4
type-fest: 3.13.1
dev: false
/string-width@4.2.3: /string-width@4.2.3:
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
engines: {node: '>=8'} engines: {node: '>=8'}
@ -793,22 +1056,32 @@ packages:
ansi-regex: 6.0.1 ansi-regex: 6.0.1
dev: true dev: true
/toml@3.0.0: /strip-json-comments@3.1.1:
resolution: {integrity: sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==} resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==}
dev: false engines: {node: '>=8'}
dev: true
/supports-color@7.2.0:
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
engines: {node: '>=8'}
dependencies:
has-flag: 4.0.0
dev: true
/text-table@0.2.0:
resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==}
dev: true
/tslib@2.6.2: /tslib@2.6.2:
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
dev: true
/type-fest@3.13.1: /type-check@0.4.0:
resolution: {integrity: sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==} resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
engines: {node: '>=14.16'} engines: {node: '>= 0.8.0'}
dev: false dependencies:
prelude-ls: 1.2.1
/type-fest@4.9.0: dev: true
resolution: {integrity: sha512-KS/6lh/ynPGiHD/LnAobrEFq3Ad4pBzOlJ1wAnJx9N4EYoqFhMfLIBjUT2UEx4wg5ZE+cC1ob6DCSpppVo+rtg==}
engines: {node: '>=16'}
dev: false
/typescript@5.3.3: /typescript@5.3.3:
resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==}
@ -820,15 +1093,11 @@ packages:
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
dev: true dev: true
/uuid@9.0.1: /uri-js@4.4.1:
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
hasBin: true dependencies:
dev: false punycode: 2.3.1
dev: true
/uuidv7@0.6.3:
resolution: {integrity: sha512-zV3eW2NlXTsun/aJ7AixxZjH/byQcH/r3J99MI0dDEkU2cJIBJxhEWUHDTpOaLPRNhebPZoeHuykYREkI9HafA==}
hasBin: true
dev: false
/which@2.0.2: /which@2.0.2:
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
@ -838,6 +1107,11 @@ packages:
isexe: 2.0.0 isexe: 2.0.0
dev: true dev: true
/word-wrap@1.2.5:
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
engines: {node: '>=0.10.0'}
dev: true
/wrap-ansi@7.0.0: /wrap-ansi@7.0.0:
resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==}
engines: {node: '>=10'} engines: {node: '>=10'}
@ -856,10 +1130,6 @@ packages:
strip-ansi: 7.1.0 strip-ansi: 7.1.0
dev: true dev: true
/yallist@4.0.0:
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
dev: false
/yocto-queue@0.1.0: /yocto-queue@0.1.0:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'} engines: {node: '>=10'}

3
scripts/nswag.ps1 Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
nswag run ./src/api/api.nswag

View File

@ -1,544 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import { HttpHeaders, HttpClient } from "@tribufu/mintaka";
import { JavaScriptRuntime } from "./node";
import { JsonCasing, JwtDecoder } from "@tribufu/mintaka";
import { TokenPayload } from "./token";
import { TRIBUFU_API_URL, TRIBUFU_VERSION } from ".";
import { TribufuApiOptions } from "./options";
/**
* **Tribufu API**
*
* Use this class to interact with the Tribufu API.
*
* *There are three ways to use the Tribufu API:*
* - A api key give you public read only access to the Tribufu API.
* - A bot give you read and write access to the Tribufu API as a bot account.
* - A client give you read and write access to the Tribufu API as a client application.
*/
export class TribufuApi {
protected readonly http: HttpClient;
protected readonly options: TribufuApiOptions;
constructor(options?: TribufuApiOptions | null) {
this.options = options || {};
this.http = new HttpClient({
baseUrl: TribufuApi.getBaseUrl(),
headers: TribufuApi.defaultHeaders(),
logEnabled: TribufuApi.debugEnabled(),
jsonRequestCasing: JsonCasing.SnakeCase,
jsonResponseCasing: JsonCasing.CamelCase,
});
}
/**
* Create a TribufuApi with the default options.
* @returns
*/
public static default(): TribufuApi {
return new TribufuApi();
}
/**
* Create a TribufuApi with the given api key.
*
* - A api key give you public read only access to the Tribufu API.
*
* @param apiKey
* @returns TribufuApi
*/
public static withApiKey(apiKey: string): TribufuApi {
return new TribufuApi({ apiKey });
}
/**
* Try to create a TribufuApi from environment variables.
*
* - This will only work if the environment variables are set.
*
* @param prefix A prefix for the environment variables.
* @returns TribufuApi | null
* @example
* ```ts
* // process.env.TRIBUFU_API_KEY
* const api = TribufuApi.fromEnv("TRIBUFU");
* ```
*/
public static fromEnv(prefix?: string | null): TribufuApi | null {
const envPrefix = prefix ? `${prefix}_` : "";
const apiKey = process.env[`${envPrefix}API_KEY`];
if (apiKey) {
return TribufuApi.withApiKey(apiKey);
}
return null;
}
/**
* Create a TribufuApi from environment variables or the default api.
*
* - This will fallback to the default api if the environment variables are not set.
*
* @param prefix A prefix for the environment variables.
* @returns TribufuApi | null
* @example
* ```ts
* // process.env.TRIBUFU_API_KEY = null
* const api = TribufuApi.fromEnvOrDefault("TRIBUFU_");
* ```
*/
public static fromEnvOrDefault(prefix: string = ""): TribufuApi {
return TribufuApi.fromEnv(prefix) || TribufuApi.default();
}
/**
* Set the tokens.
* @param accessToken
* @param refreshToken
* @param expiresIn
*/
protected setApiKey(apiKey: string | null): void {
this.options.apiKey = apiKey;
}
/**
* Check if debug mode is enabled.
*
* - Debug mode is enabled if the environment variable `NODE_ENV` is set to `development`.
* - Debug mode is disabled by default.
* - Debug mode is disabled in the browser.
*
* @returns boolean
*/
private static debugEnabled(): boolean {
return process.env.NODE_ENV ? process.env.NODE_ENV === "development" : false;
}
/**
* Get the base url for the Tribufu API.
*
* - The base url can be set using the environment variable `TRIBUFU_API_URL`.
* - The custom base url is only used if debug mode is enabled.
* - The default base url is `https://api.tribufu.com`.
*
* @returns string
*/
private static getBaseUrl(): string {
const baseUrl = process.env[`TRIBUFU_API_URL`] || null;
return TribufuApi.debugEnabled() && baseUrl ? baseUrl : TRIBUFU_API_URL;
}
/**
* Get the default headers for the Tribufu API.
* @returns HeaderMap
*/
protected static defaultHeaders(): HttpHeaders {
const headers = new HttpHeaders();
headers.set("X-Tribufu-Language", "javascript");
headers.set("X-Tribufu-Version", TRIBUFU_VERSION);
return headers;
}
/**
* Detect the current JavaScript runtime.
*
* - This is used to determine if the code is running in a browser or in Node.js.
*
* @returns JavaScriptRuntime
*/
private static detectRuntime(): JavaScriptRuntime {
if (typeof window !== "undefined") {
return JavaScriptRuntime.Browser;
}
if (typeof process !== "undefined" && process?.versions?.node) {
return JavaScriptRuntime.Node;
}
return JavaScriptRuntime.Other;
}
/**
* Check if the current JavaScript runtime is a browser.
* @returns boolean
*/
public static isBrowser(): boolean {
return TribufuApi.detectRuntime() === JavaScriptRuntime.Browser;
}
/**
* Check if the current JavaScript runtime is Node.js.
* @returns boolean
*/
public static isNode(): boolean {
return TribufuApi.detectRuntime() === JavaScriptRuntime.Node;
}
/**
* Extract the payload from a Tribufu token.
* @param token
* @returns TokenPayload | null
*/
protected static parseToken(token: string): TokenPayload | null {
try {
const payload = JwtDecoder.decode(token);
if (!payload) {
return null;
}
return payload as TokenPayload;
}
catch (error) {
return null;
}
}
/**
* Get current headers with the api key or access token.
* @returns HeaderMap
*/
protected getHeaders(): HttpHeaders {
let headers = TribufuApi.defaultHeaders();
if (this.options.apiKey) {
headers.set("Authorization", `ApiKey ${this.options.apiKey}`);
return headers;
}
if (this.options.accessToken) {
headers.set("Authorization", `Bearer ${this.options.accessToken}`);
return headers;
}
return headers;
}
/**
* Get games from the Tribufu API.
* @param page
* @returns Game[]
*/
public async getGames(page: number = 1): Promise<any[]> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any[]>(`/v1/games?page=${page}`, headers);
if (!responseBody) {
return [];
}
return responseBody;
}
/**
* Get a game from the Tribufu API.
* @param id
* @returns Game | null
*/
public async getGameById(id: string): Promise<any | null> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any>(`/v1/games/${id}`, headers);
if (!responseBody) {
return null;
}
return responseBody;
}
/**
* Get servers from the Tribufu API.
* @param page
* @returns Server[]
*/
public async getServers(page: number = 1): Promise<any[]> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any[]>(`/v1/servers?page=${page}`, headers);
if (!responseBody) {
return [];
}
return responseBody;
}
/**
* Get a server by id or address from the Tribufu API.
* @param idOrAddress
* @returns Server | null
*/
public async getServer(idOrAddress: string): Promise<any> {
if (/[.:]/.test(idOrAddress)) {
return await this.getServerByAddress(idOrAddress);
}
return await this.getServerById(idOrAddress);
}
/**
* Get a server by id from the Tribufu API.
* @param id
* @returns Server | null
*/
public async getServerById(id: string): Promise<any> {
const headers = this.getHeaders()
const responseBody = await this.http.get<any>(`/v1/servers/${id}`, headers);
if (!responseBody) {
return null;
}
return responseBody;
}
/**
* Get a server by address from the Tribufu API.
* @param address
* @returns Server | null
*/
public async getServerByAddress(address: string): Promise<any> {
const parts = address.split(":");
const hostOrAddress = parts[0];
const queryPort = parts[1];
const headers = this.getHeaders();
const responseBody = await this.http.get(`/v1/servers?address=${hostOrAddress}&query_port=${queryPort}`, headers);
if (!responseBody) {
return null;
}
return responseBody[0];
}
/**
* Get a user by id from the Tribufu API.
* @param id
* @returns User | null
*/
public async getUserById(id: string): Promise<any> {
const headers = this.getHeaders();
const responseBody = await this.http.get(`/v1/users/${id}`, headers);
if (!responseBody) {
return null;
}
return responseBody;
}
/**
* Get a user by uuid from the Tribufu API.
* @param uuid
* @returns User[]
*/
public async getUserByUuid(uuid: string): Promise<any[]> {
return await this.getUserByKey("uuid", uuid);
}
/**
* Get a user by name from the Tribufu API.
* @param uuid
* @returns User[]
*/
public async getUserByName(name: string): Promise<any[]> {
return await this.getUserByKey("name", name);
}
/**
* Get a user by custom key from the Tribufu API.
* @param key
* @param value
* @returns User[]
*/
private async getUserByKey(key: string, value: string): Promise<any[]> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any[]>(`/v1/users?${key}=${value}`, headers);
if (!responseBody) {
return [];
}
return responseBody;
}
/**
* Get all groups for a user from the Tribufu API.
* @param userId
* @returns Group[]
*/
public async getUserGroups(userId: string): Promise<any[]> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any[]>(`/v1/users/${userId}/groups`, headers);
if (!responseBody) {
return [];
}
return responseBody;
}
/**
* Get all games for a user from the Tribufu API.
* @param userId
* @returns Game[]
*/
public async getUserGames(userId: string): Promise<any[]> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any[]>(`/v1/users/${userId}/games`, headers);
if (!responseBody) {
return [];
}
return responseBody;
}
/**
* Get all punishments for a user from the Tribufu API.
* @param userId
* @returns Punishment[]
*/
public async getUserPunishments(userId: string): Promise<any[]> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any[]>(`/v1/users/${userId}/punishments`, headers);
if (!responseBody) {
return [];
}
return responseBody;
}
/**
* Get all servers for a user from the Tribufu API.
* @param userId
* @returns Server[]
*/
public async getUserServers(userId: string): Promise<any[]> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any[]>(`/v1/users/${userId}/servers`, headers);
if (!responseBody) {
return [];
}
return responseBody;
}
/**
* Get a oauth2 client by id from the Tribufu API.
* @param id
* @returns Client | null
*/
protected async getClientById(id: string): Promise<any> {
const headers = this.getHeaders();
const responseBody = await this.http.get(`/v1/oauth2/clients/${id}`, headers);
if (!responseBody) {
return null;
}
return responseBody;
}
/**
* Get files from the Tribufu API.
* @param page
* @returns File[]
*/
public async getFiles(page: number = 1): Promise<any[]> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any[]>(`/v1/files?page=${page}`, headers);
if (!responseBody) {
return [];
}
return responseBody;
}
/**
* Get a file by id from the Tribufu API.
* @param id
* @returns File | null
*/
public async getFileById(id: string): Promise<any> {
const headers = this.getHeaders()
const responseBody = await this.http.get<any>(`/v1/files/${id}`, headers);
if (!responseBody) {
return null;
}
return responseBody;
}
/**
* Get clusters from the Tribufu API.
* @param page
* @returns Cluster[]
*/
public async getClusters(page: number = 1): Promise<any[]> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any[]>(`/v1/clusters?page=${page}`, headers);
if (!responseBody) {
return [];
}
return responseBody;
}
/**
* Get a cluster by id from the Tribufu API.
* @param id
* @returns Cluster | null
*/
public async getClusterById(id: string): Promise<any> {
const headers = this.getHeaders()
const responseBody = await this.http.get<any>(`/v1/clusters/${id}`, headers);
if (!responseBody) {
return null;
}
return responseBody;
}
/**
* Get subscriptions from the Tribufu API.
* @param page
* @returns Subscription[]
*/
public async getSubscriptions(page: number = 1): Promise<any[]> {
const headers = this.getHeaders();
const responseBody = await this.http.get<any[]>(`/v1/subscriptions?page=${page}`, headers);
if (!responseBody) {
return [];
}
return responseBody;
}
/**
* Get a subscription by id from the Tribufu API.
* @param id
* @returns Subscription | null
*/
public async getSubscriptionById(id: string): Promise<any> {
const headers = this.getHeaders()
const responseBody = await this.http.get<any>(`/v1/subscriptions/${id}`, headers);
if (!responseBody) {
return null;
}
return responseBody;
}
}

104
src/api/api.base.ts Normal file
View File

@ -0,0 +1,104 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: UNLICENSED
import { HttpHeaders } from "../http/headers";
import { JavaScriptRuntime } from "../node";
import { TRIBUFU_VERSION } from "..";
export abstract class TribufuApiBase {
protected apiKey: string | null = null;
/**
* Check if debug mode is enabled.
*
* - Debug mode is enabled if the environment variable `NODE_ENV` is set to `development`.
* - Debug mode is disabled by default.
* - Debug mode is disabled in the browser.
*
* @returns boolean
*/
public static debugEnabled(): boolean {
if (!process) {
return false;
}
return process.env.NODE_ENV === "development";
}
/**
* Detect the current JavaScript runtime.
*
* - This is used to determine if the code is running in a browser or in Node.js.
*
* @returns JavaScriptRuntime
*/
public static detectRuntime(): JavaScriptRuntime {
if (typeof window !== "undefined") {
return JavaScriptRuntime.Browser;
}
if (typeof process !== "undefined" && process?.versions?.node) {
return JavaScriptRuntime.Node;
}
return JavaScriptRuntime.Other;
}
/**
* Check if the current JavaScript runtime is a browser.
* @returns boolean
*/
public static isBrowser(): boolean {
return TribufuApiBase.detectRuntime() === JavaScriptRuntime.Browser;
}
/**
* Check if the current JavaScript runtime is Node.js.
* @returns boolean
*/
public static isNode(): boolean {
return TribufuApiBase.detectRuntime() === JavaScriptRuntime.Node;
}
/**
* Get the default headers for the Tribufu API.
* @returns HeaderMap
*/
protected static defaultHeaders(): HttpHeaders {
const headers = {};
headers["X-Tribufu-Language"] = "javascript";
headers["X-Tribufu-Version"] = TRIBUFU_VERSION;
return headers;
}
/**
* Get current headers with the api key or access token.
* @returns HeaderMap
*/
protected getHeaders(): HttpHeaders {
let headers = TribufuApiBase.defaultHeaders();
if (this.apiKey) {
headers["Authorization"] = `ApiKey ${this.apiKey}`;
return headers;
}
return headers;
}
/**
* Transform the options before sending the request.
* @param options
* @returns
*/
protected transformOptions(options: RequestInit) {
if (this.apiKey) {
options.headers = {
...options.headers,
...this.getHeaders(),
};
}
return Promise.resolve(options);
}
}

2233
src/api/api.generated.ts Normal file

File diff suppressed because it is too large Load Diff

1
src/api/api.include.ts Normal file
View File

@ -0,0 +1 @@
import { TribufuApiBase } from "./api.base";

74
src/api/api.nswag Normal file
View File

@ -0,0 +1,74 @@
{
"runtime": "Default",
"defaultVariables": null,
"documentGenerator": {
"fromDocument": {
"json": "",
"url": "http://localhost:5000/v1/openapi.json",
"output": null,
"newLineBehavior": "Auto"
}
},
"codeGenerators": {
"openApiToTypeScriptClient": {
"className": "TribufuApiGenerated",
"moduleName": "",
"namespace": "",
"typeScriptVersion": 4.3,
"template": "Fetch",
"promiseType": "Promise",
"httpClass": "HttpClient",
"withCredentials": false,
"useSingletonProvider": false,
"injectionTokenType": "OpaqueToken",
"rxJsVersion": 6,
"dateTimeType": "String",
"nullValue": "Null",
"generateClientClasses": true,
"generateClientInterfaces": false,
"generateOptionalParameters": false,
"exportTypes": true,
"wrapDtoExceptions": false,
"exceptionClass": "TribufuApiError",
"clientBaseClass": "TribufuApiBase",
"wrapResponses": false,
"wrapResponseMethods": [],
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"protectedMethods": [],
"configurationClass": null,
"useTransformOptionsMethod": true,
"useTransformResultMethod": false,
"generateDtoTypes": true,
"operationGenerationMode": "SingleClientFromOperationId",
"markOptionalProperties": true,
"generateCloneMethod": false,
"typeStyle": "Interface",
"enumStyle": "Enum",
"useLeafType": false,
"classTypes": [],
"extendedClasses": [],
"extensionCode": "api.include.ts",
"generateDefaultValues": true,
"excludedTypeNames": [],
"excludedParameterNames": [],
"handleReferences": false,
"generateTypeCheckFunctions": false,
"generateConstructorInterface": true,
"convertConstructorInterfaceData": false,
"importRequiredTypes": true,
"useGetBaseUrlMethod": false,
"baseUrlTokenName": "API_BASE_URL",
"queryNullValue": "",
"useAbortSignal": false,
"inlineNamedDictionaries": false,
"inlineNamedAny": false,
"includeHttpContext": false,
"templateDirectory": null,
"serviceHost": null,
"serviceSchemes": null,
"output": "api.generated.ts",
"newLineBehavior": "LF"
}
}
}

107
src/api/index.ts Normal file
View File

@ -0,0 +1,107 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import { TRIBUFU_API_URL } from "..";
import { TribufuApiBase } from "./api.base";
import { TribufuApiGenerated } from "./api.generated";
import { TribufuApiOptions } from "../options";
/**
* **Tribufu API**
*
* Use this class to interact with the Tribufu API.
*/
export class TribufuApi extends TribufuApiGenerated {
constructor(options?: TribufuApiOptions | null) {
const baseUrl = options?.baseUrl || TribufuApi.getBaseUrl();
const http = options?.fetch ? { fetch: options.fetch } : { fetch };
super(baseUrl, http);
this.apiKey = options?.apiKey || null;
}
/**
* Create a TribufuApi with the default options.
* @returns
*/
public static default(): TribufuApi {
return new TribufuApi();
}
/**
* Create a TribufuApi with the given api key.
*
* - A api key give you public read only access to the Tribufu API.
*
* @param apiKey
* @returns TribufuApi
*/
public static withApiKey(apiKey: string): TribufuApi {
return new TribufuApi({ apiKey });
}
/**
* Try to create a TribufuApi from environment variables.
*
* - This will only work if the environment variables are set.
*
* @param prefix A prefix for the environment variables.
* @returns TribufuApi | null
* @example
* ```ts
* // process.env.TRIBUFU_API_KEY
* const api = TribufuApi.fromEnv("TRIBUFU");
* ```
*/
public static fromEnv(prefix?: string | null): TribufuApi | null {
const envPrefix = prefix ? `${prefix}_` : "";
if (!process) {
return null;
}
const apiKey = process.env[`${envPrefix}API_KEY`];
if (apiKey) {
return TribufuApi.withApiKey(apiKey);
}
return null;
}
/**
* Create a TribufuApi from environment variables or the default api.
*
* - This will fallback to the default api if the environment variables are not set.
*
* @param prefix A prefix for the environment variables.
* @returns TribufuApi | null
* @example
* ```ts
* // process.env.TRIBUFU_API_KEY = null
* const api = TribufuApi.fromEnvOrDefault("TRIBUFU_");
* ```
*/
public static fromEnvOrDefault(prefix: string = ""): TribufuApi {
return TribufuApi.fromEnv(prefix) || TribufuApi.default();
}
/**
* Get the base url for the Tribufu API.
*
* - The base url can be set using the environment variable `TRIBUFU_API_URL`.
* - The custom base url is only used if debug mode is enabled.
* - The default base url is `https://api.tribufu.com`.
*
* @returns string
*/
private static getBaseUrl(): string {
if (!process) {
return TRIBUFU_API_URL;
}
const baseUrl = process.env[`TRIBUFU_API_URL`] || null;
return TribufuApiBase.debugEnabled() && baseUrl
? baseUrl
: TRIBUFU_API_URL;
}
}

View File

@ -1,68 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import { TribufuApi } from "./api";
/**
* **Tribufu Bot**
*
* To authenticate a bot you need to use the bot token obtained from the Tribufu Developer Portal.
*
* - A bot is a special type of user account.
* - A bot give you read and write access to the Tribufu API.
*/
export class TribufuBot extends TribufuApi {
private readonly botId: string;
constructor(token: string) {
const payload = TribufuApi.parseToken(token);
if (!payload) {
throw new Error("Invalid token");
}
if (payload.type !== "bot") {
throw new Error("Invalid token type");
}
if (!payload.bot_id) {
throw new Error("Invalid token payload");
}
super({ accessToken: token });
this.botId = payload.bot_id;
}
/**
* Try to create a TribufuBot from environment variables.
*
* - This will only work if the environment variables are set.
*
* @param prefix A prefix for the environment variables.
* @returns TribufuBot | null
* @example
* ```ts
* // process.env.TRIBUFU_BOT_TOKEN
* const bot = TribufuBot.fromEnv("TRIBUFU");
* ```
*/
public static override fromEnv(prefix?: string | null): TribufuBot | null {
const envPrefix = prefix ? `${prefix}_` : "";
const token = process.env[`${envPrefix}BOT_TOKEN`];
if (token) {
return new TribufuBot(token);
}
return null;
}
/**
* Get the bot id.
* @returns string
*/
public getBotId(): string {
return this.botId;
}
}

View File

@ -1,386 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import { HttpCookieMap, HttpHeaders } from "@tribufu/mintaka";
import { OAuth2GrantType, OAuth2IntrospectionRequest, OAuth2IntrospectionResponse, OAuth2TokenRequest, OAuth2TokenResponse } from "@tribufu/mintaka";
import { TribufuApi } from "./api";
/**
* **Tribufu Client**
*
* To authenticate a client you need to use the client id and client secret obtained from the Tribufu Developer Portal
*
* - A client is how external applications interact with the Tribufu API.
* - A client give you read and write access to the Tribufu API.
* - A client can be used to login users.
*/
export class TribufuClient extends TribufuApi {
private readonly clientId: string;
private readonly clientSecret: string;
constructor(clientId: string, clientSecret: string) {
super();
this.clientId = clientId;
this.clientSecret = clientSecret;
}
/**
* Try to create a TribufuClient from environment variables.
*
* - This will only work if the environment variables are set.
*
* @param prefix A prefix for the environment variables.
* @returns TribufuClient | null
* @example
* ```ts
* // process.env.TRIBUFU_CLIENT_ID
* // process.env.TRIBUFU_CLIENT_SECRET
* const client = TribufuClient.fromEnv("TRIBUFU");
* ```
*/
public static override fromEnv(prefix?: string | null): TribufuClient | null {
const envPrefix = prefix ? `${prefix}_` : "";
//const apiKey = process.env[`${envPrefix}API_KEY`];
const clientId = process.env[`${envPrefix}CLIENT_ID`];
const clientSecret = process.env[`${envPrefix}CLIENT_SECRET`];
if (!clientId || !clientSecret) {
return null;
}
const client = new TribufuClient(clientId, clientSecret);
/*
if (apiKey) {
client.setApiKey(apiKey);
}
*/
return client;
}
/**
* Try to create a TribufuClient from environment variables and cookies.
*
* - This will only work if the environment variables are set.
* - The cookies are used to get the access token and refresh token.
*
* @param cookies Cookies from the request.
* @param prefix A prefix for the environment variables.
* @returns TribufuClient | null
* @example
* ```ts
* // process.env.TRIBUFU_CLIENT_ID
* // process.env.TRIBUFU_CLIENT_SECRET
* const cookies = { "access_token": "...", "refresh_token": "..." };
* const client = TribufuClient.fromCookies(cookies, "TRIBUFU_");
* ```
*/
public static fromCookies(cookies: HttpCookieMap, prefix: string = ""): TribufuClient | null {
const client = TribufuClient.fromEnv(prefix);
const accessToken = cookies["access_token"] || null;
const refreshToken = cookies["refresh_token"] || null;
if (client && accessToken && refreshToken) {
client.setTokens(accessToken, refreshToken);
}
return client;
}
/**
* Set the tokens.
* @param accessToken
* @param refreshToken
* @param expiresIn
*/
protected setTokens(accessToken: string | null, refreshToken?: string | null, expiresIn?: number | null): void {
this.options.accessToken = accessToken;
this.options.refreshToken = refreshToken || null;
this.options.expiresIn = expiresIn || null;
}
/**
* Clear the tokens.
*/
protected clearTokens(): void {
this.setTokens(null, null, null);
}
/**
* Set the tokens from a oauth2 response.
* @param tokens
*/
private setTokensFromResponse(tokens: OAuth2TokenResponse): void {
this.setTokens(tokens.access_token, tokens.refresh_token || null, tokens.expires_in || null);
}
/**
* Get the headers for a oauth2 request.
* @returns HttpHeaders
*/
private getOAuthHeaders(): HttpHeaders {
let headers = this.getHeaders();
headers["Authorization"] = `Basic ${Buffer.from(`${this.clientId}:${this.clientSecret}`, "binary").toString("base64")}`;
headers["Content-Type"] = "application/x-www-form-urlencoded";
return headers;
}
/**
* Get current headers with the api key or access token.
* @returns HeaderMap
*/
protected override getHeaders(): HttpHeaders {
let headers = TribufuClient.defaultHeaders();
headers.set("Authorization", `Basic ${Buffer.from(`${this.clientId}:${this.clientSecret}`, "binary").toString("base64")}`);
if (this.options.accessToken) {
headers.set("Authorization", `Bearer ${this.options.accessToken}`);
return headers;
}
return headers;
}
/**
* Get the client id.
* @returns string
*/
public getClientId(): string {
return this.clientId;
}
/**
* Login using an authorization code.
* @param authorizationCode
* @returns boolean
*/
public async authorizationLogin(authorizationCode: string): Promise<boolean> {
const response = await this.getToken("authorization_code", authorizationCode, null, null);
if (!response) {
return false;
}
this.setTokensFromResponse(response);
return true;
}
/**
* Login using a device code.
* @param deviceCode
* @returns boolean
*/
public async deviceLogin(deviceCode: string): Promise<boolean> {
const response = await this.getToken("device_code", deviceCode, null, null);
if (!response) {
return false;
}
this.setTokensFromResponse(response);
return true;
}
/**
* Login using a username and password.
* @param username
* @param password
* @returns boolean
*/
public async passwordLogin(username: string, password: string): Promise<boolean> {
const response = await this.getToken("password", password, null, username);
if (!response) {
return false;
}
this.setTokensFromResponse(response);
return true;
}
/**
* Login using a passkey.
* @param username
* @param passkey
* @returns boolean
*/
public async passkeyLogin(username: string, passkey: string): Promise<boolean> {
const response = await this.getToken("passkey", passkey, null, username);
if (!response) {
return false;
}
this.setTokensFromResponse(response);
return true;
}
/**
* Get a token for a client application.
* @param subjectKey
* @param subjectValue
* @returns boolean
*/
public async clientLogin(subjectKey: string | null, subjectValue: string | null): Promise<boolean> {
const response = await this.getToken("client_credentials", null, subjectKey, subjectValue);
if (!response) {
return false;
}
this.setTokensFromResponse(response);
return true;
}
/**
* Get a new access token using a refresh token.
* @param refreshToken
* @returns boolean
*/
public async refreshToken(): Promise<boolean> {
if (!this.options.refreshToken) {
return false;
}
const response = await this.getToken("refresh_token", this.options.refreshToken, null, null);
if (!response) {
return false;
}
this.setTokensFromResponse(response);
return true;
}
/**
* Get information about a access token.
* @returns boolean
*/
public async instrospectToken(): Promise<OAuth2IntrospectionResponse | null> {
if (!this.options.accessToken) {
return null;
}
const requestBody: OAuth2IntrospectionRequest = {
token: this.options.accessToken,
token_type_hint: "access_token",
}
const url = `/v1/oauth2/introspect`;
const headers = this.getOAuthHeaders();
const responseBody = await this.http.post<OAuth2IntrospectionRequest, OAuth2IntrospectionResponse>(url, requestBody, headers);
if (!responseBody) {
return null;
}
return responseBody;
}
/**
* Revoke a refresh token.
* @returns boolean
*/
public async revokeToken(): Promise<boolean> {
if (!this.options.refreshToken) {
return false;
}
const requestBody: OAuth2IntrospectionRequest = {
token: this.options.refreshToken,
token_type_hint: "refresh_token",
}
const url = `/v1/oauth2/revoke`;
const headers = this.getOAuthHeaders();
const responseBody = await this.http.post<OAuth2IntrospectionRequest, OAuth2IntrospectionResponse>(url, requestBody, headers);
if (!responseBody) {
return false;
}
this.clearTokens();
return true;
}
/**
* Check if the current access token is valid.
* @returns boolean
*/
public async isTokenValid(): Promise<boolean> {
const response = await this.instrospectToken();
if (!response) {
return false;
}
return response.active;
}
/**
* Get a oauth2 token with the given grant type.
* @param grantType
* @param grantValue
* @param subjectKey
* @param subjectValue
* @returns OAuth2TokenResponse | null
*/
protected async getToken(grantType: OAuth2GrantType, grantValue: string | null, subjectKey: string | null, subjectValue: string | null): Promise<OAuth2TokenResponse | null> {
const requestBody: OAuth2TokenRequest = {
grant_type: grantType,
code: grantType === "authorization_code" ? grantValue : null,
refresh_token: grantType === "refresh_token" ? grantValue : null,
username: grantType === "password" || grantType === "passkey" ? subjectValue : null,
password: grantType === "password" ? grantValue : null,
passkey: grantType === "passkey" ? grantValue : null,
client_id: this.clientId,
client_secret: this.clientSecret,
}
const params = subjectKey && subjectValue ? `?${subjectKey}=${subjectValue}` : "";
const url = `/v1/oauth2/token${params}`;
const headers = this.getOAuthHeaders();
const responseBody = await this.http.post<OAuth2TokenRequest, OAuth2TokenResponse>(url, requestBody, headers);
if (!responseBody) {
return null;
}
return responseBody;
}
/**
* Get information about the current client.
* @returns Client | null
*/
public async getClientInfo(): Promise<any | null> {
return this.getClientById(this.clientId);
}
/**
* Get information about the current user.
* @returns User | null
*/
public async getUserInfo(): Promise<any | null> {
if (!this.options.accessToken) {
return null;
}
const headers = this.getHeaders();
const responseBody = await this.http.get<any>(`/v1/oauth2/userinfo`, headers);
if (!responseBody) {
return null;
}
return responseBody;
}
}

View File

@ -1,26 +1,24 @@
// Copyright (c) Tribufu. All Rights Reserved. // Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import packageJson from "../package.json";
/** /**
* The version of the Tribufu SDK. * The version of the Tribufu SDK.
* @type {string}
*/ */
export const TRIBUFU_VERSION = "0.1.13"; export const TRIBUFU_VERSION: string = packageJson.version;
/** /**
* The default Tribufu API URL. * The default Tribufu API URL.
* @type {string}
*/ */
export const TRIBUFU_API_URL = "https://api.tribufu.com"; export const TRIBUFU_API_URL: string = "https://api.tribufu.com";
/** /**
* The default Tribufu WEB URL. * The default Tribufu WEB URL.
* @type {string}
*/ */
export const TRIBUFU_WEB_URL = "https://www.tribufu.com"; export const TRIBUFU_WEB_URL: string = "https://www.tribufu.com";
/** /**
* The default Tribufu CDN URL. * The default Tribufu CDN URL.
* @type {string}
*/ */
export const TRIBUFU_CDN_URL = "https://cdn.tribufu.com"; export const TRIBUFU_CDN_URL: string = "https://cdn.tribufu.com";

11
src/http/headers.ts Normal file
View File

@ -0,0 +1,11 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
/**
* Http Headers
*
* Helper type to represent HTTP headers.
*/
export type HttpHeaders = {
[key: string]: string;
};

View File

@ -8,23 +8,9 @@ import {
TRIBUFU_WEB_URL, TRIBUFU_WEB_URL,
} from "./constants"; } from "./constants";
export { export { TRIBUFU_API_URL, TRIBUFU_CDN_URL, TRIBUFU_VERSION, TRIBUFU_WEB_URL };
TRIBUFU_API_URL,
TRIBUFU_CDN_URL,
TRIBUFU_VERSION,
TRIBUFU_WEB_URL,
};
import { TribufuApi } from "./api"; import { TribufuApi } from "./api";
import { TribufuApiOptions } from "./options"; import { TribufuApiOptions } from "./options";
import { TribufuBot } from "./bot";
import { TribufuClient } from "./client";
import { TribufuServer } from "./server";
export { export { TribufuApi, TribufuApiOptions };
TribufuApi,
TribufuApiOptions,
TribufuBot,
TribufuClient,
TribufuServer,
};

View File

@ -1,22 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import { MiniProfile } from "./profile";
export interface Cluster {
id: string,
name: string,
description: string | null,
packageId: string,
websiteUrl: string | null,
bannerUrl: string | null,
ownerId: string | null,
owner: MiniProfile | null,
discordServerId: string | null,
youtubeVideoUrl: string | null,
tags: string | null,
commentCount: number,
serverCount: number,
created: string,
updated: string | null
}

View File

@ -1,16 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
export type ProfileType = "user" | "bot" | "org";
export type Profile = any;
export interface MiniProfile {
id: string,
uuid: string,
name: string,
displayName: string,
type: ProfileType,
verified: boolean,
photoUrl: string | null
}

View File

@ -2,8 +2,7 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
export interface TribufuApiOptions { export interface TribufuApiOptions {
apiKey?: string | null; baseUrl?: string;
accessToken?: string | null; apiKey?: string;
refreshToken?: string | null; fetch?: (url: RequestInfo, init?: RequestInit) => Promise<Response>;
expiresIn?: number | null;
} }

View File

@ -1,74 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import { TribufuClient } from "./client";
/**
* **Tribufu Server**
*
* To authenticate a server you need to use the server id, client id and client secret obtained from your server subscription.
*
* - A server is a special type of client application.
* - A server is how game servers interact with the Tribufu API.
* - A server give you read and write access to the Tribufu API.
*/
export class TribufuServer extends TribufuClient {
private readonly serverId: string;
constructor(serverId: string, clientId: string, clientSecret: string) {
super(clientId, clientSecret);
this.serverId = serverId;
}
/**
* Try to create a TribufuServer from environment variables.
*
* - This will only work if the environment variables are set.
*
* @param prefix A prefix for the environment variables.
* @returns TribufuServer | null
* @example
* ```ts
* // process.env.TRIBUFU_SERVER_ID
* // process.env.TRIBUFU_CLIENT_ID
* // process.env.TRIBUFU_CLIENT_SECRET
* const server = TribufuServer.fromEnv("TRIBUFU");
* ```
*/
public static override fromEnv(prefix?: string | null): TribufuServer | null {
const envPrefix = prefix ? `${prefix}_` : "";
const serverId = process.env[`${envPrefix}SERVER_ID`];
const clientId = process.env[`${envPrefix}CLIENT_ID`];
const clientSecret = process.env[`${envPrefix}CLIENT_SECRET`];
if (serverId && clientId && clientSecret) {
return new TribufuServer(serverId, clientId, clientSecret);
}
return null;
}
/**
* Get the server id.
* @returns string
*/
public getServerId(): string {
return this.serverId;
}
/**
* Get information about the current server.
* @returns Server | null
*/
public async getServerInfo(): Promise<any | null> {
return this.getServerById(this.serverId);
}
/**
* Get a list of connected users.
* @returns
*/
public async getConnectedUsers(): Promise<any[]> {
return [];
}
}

View File

@ -1,12 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
/**
* Tribufu Socket
*
* Helper class to connect to the Tribufu Socket API.
*/
export class TribufuSocket {
constructor() {
}
}

View File

@ -1,20 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
export type TokenType = "user" | "bot" | "client" | "server";
export interface TokenPayload {
jti: string;
type: TokenType;
iss: string;
aud: string;
client_id: string;
scope: string;
user_id?: string;
bot_id?: string;
private_flags?: string;
public_flags?: string;
server_id?: string;
iat: number;
exp: number;
}