summary refs log tree commit diff
diff options
context:
space:
mode:
authorCyber <cyber.hf18@gmail.com>2025-10-20 21:02:22 +0200
committerGitHub <noreply@github.com>2025-10-20 21:02:22 +0200
commita9302ca7964c2f0704704c2b1cd4fa960c28e7bc (patch)
treeb16fb9e1d4a041cf720e6a408fb01ad5ada8e07e
parentMerge pull request #1354 from CyberL1/fix/bulk-command-registration (diff)
parentadd fingerprint endpoint (diff)
downloadserver-ts-a9302ca7964c2f0704704c2b1cd4fa960c28e7bc.tar.xz
Merge pull request #1355 from anotherdoesnm/master
add fingerprint endpoint
-rw-r--r--assets/openapi.json50
-rw-r--r--assets/schemas.json81
-rw-r--r--src/api/middlewares/Authentication.ts1
-rw-r--r--src/api/routes/auth/fingerprint.ts29
-rw-r--r--src/schemas/CreateFingerprintResponse.ts3
5 files changed, 120 insertions, 44 deletions
diff --git a/assets/openapi.json b/assets/openapi.json

index 8917d9e6..bb8268f5 100644 --- a/assets/openapi.json +++ b/assets/openapi.json
@@ -30,6 +30,17 @@ } }, "schemas": { + "CreateFingerprintResponse": { + "type": "object", + "properties": { + "fingerprint": { + "type": "string" + } + }, + "required": [ + "fingerprint" + ] + }, "ApplicationCommandOption": { "type": "object", "properties": { @@ -4470,7 +4481,7 @@ "sending_dns_records": { "type": "array", "items": { - "$ref": "#/components/schemas/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord" + "$ref": "#/components/schemas/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord" } } }, @@ -7993,7 +8004,7 @@ "type": "string" }, "template": { - "$ref": "#/components/schemas/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/components/schemas/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -8020,7 +8031,7 @@ "items": { "type": "array", "items": { - "$ref": "#/components/schemas/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/components/schemas/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "paging": { @@ -8070,7 +8081,7 @@ "type": "object", "properties": { "template": { - "$ref": "#/components/schemas/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/components/schemas/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -8158,7 +8169,7 @@ "type": "string" }, "template": { - "$ref": "#/components/schemas/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/components/schemas/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -9212,7 +9223,7 @@ "type": "object", "properties": { "body": { - "$ref": "#/components/schemas/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType" + "$ref": "#/components/schemas/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType" }, "status": { "type": "integer" @@ -17813,7 +17824,7 @@ "length": { "type": "integer" }, - "__@unscopables@689": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -17972,17 +17983,17 @@ "except": { "type": "boolean" }, - "__@iterator@687": { + "__@iterator@689": { "type": "boolean" }, - "__@unscopables@689": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@689", + "__@unscopables@691", "length" ] }, @@ -33565,6 +33576,25 @@ ] } }, + "/auth/fingerprint/": { + "post": { + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateFingerprintResponse" + } + } + } + } + }, + "tags": [ + "auth" + ] + } + }, "/attachments/refresh-urls/": { "post": { "security": [ diff --git a/assets/schemas.json b/assets/schemas.json
index c8afe2c7..3a275201 100644 --- a/assets/schemas.json +++ b/assets/schemas.json
@@ -1,4 +1,17 @@ { + "CreateFingerprintResponse": { + "type": "object", + "properties": { + "fingerprint": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "fingerprint" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, "ApplicationCommandSchema": { "type": "object", "properties": { @@ -10699,7 +10712,7 @@ "sending_dns_records": { "type": "array", "items": { - "$ref": "#/definitions/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord" + "$ref": "#/definitions/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord" } } }, @@ -10720,7 +10733,7 @@ "status" ], "definitions": { - "import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord": { + "import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/Domains\",{with:{\"resolution-mode\":\"import\"}}).DNSRecord": { "type": "object", "properties": { "cached": { @@ -14322,7 +14335,7 @@ "type": "string" }, "template": { - "$ref": "#/definitions/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/definitions/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -14338,7 +14351,7 @@ "status" ], "definitions": { - "import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { + "import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { "type": "object", "properties": { "name": { @@ -14365,7 +14378,7 @@ "type": "string" }, "version": { - "$ref": "#/definitions/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" + "$ref": "#/definitions/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" }, "versions": { "type": "array", @@ -14424,7 +14437,7 @@ "name" ] }, - "import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { + "import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { "additionalProperties": false, "type": "object", "properties": { @@ -14502,7 +14515,7 @@ "items": { "type": "array", "items": { - "$ref": "#/definitions/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/definitions/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "paging": { @@ -14543,7 +14556,7 @@ "status" ], "definitions": { - "import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { + "import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { "type": "object", "properties": { "name": { @@ -14570,7 +14583,7 @@ "type": "string" }, "version": { - "$ref": "#/definitions/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" + "$ref": "#/definitions/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" }, "versions": { "type": "array", @@ -14629,7 +14642,7 @@ "name" ] }, - "import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { + "import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { "additionalProperties": false, "type": "object", "properties": { @@ -14705,7 +14718,7 @@ "type": "object", "properties": { "template": { - "$ref": "#/definitions/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/definitions/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -14720,7 +14733,7 @@ "status" ], "definitions": { - "import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { + "import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { "type": "object", "properties": { "name": { @@ -14747,7 +14760,7 @@ "type": "string" }, "version": { - "$ref": "#/definitions/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" + "$ref": "#/definitions/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" }, "versions": { "type": "array", @@ -14806,7 +14819,7 @@ "name" ] }, - "import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { + "import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { "additionalProperties": false, "type": "object", "properties": { @@ -14950,7 +14963,7 @@ "type": "string" }, "template": { - "$ref": "#/definitions/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" + "$ref": "#/definitions/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate" } }, "additionalProperties": false, @@ -14966,7 +14979,7 @@ "status" ], "definitions": { - "import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { + "import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Interfaces/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).IDomainTemplate": { "type": "object", "properties": { "name": { @@ -14993,7 +15006,7 @@ "type": "string" }, "version": { - "$ref": "#/definitions/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" + "$ref": "#/definitions/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion" }, "versions": { "type": "array", @@ -15052,7 +15065,7 @@ "name" ] }, - "import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { + "import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Domains/DomainTemplates\",{with:{\"resolution-mode\":\"import\"}}).TemplateVersion": { "additionalProperties": false, "type": "object", "properties": { @@ -16185,7 +16198,7 @@ "type": "object", "properties": { "body": { - "$ref": "#/definitions/import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType" + "$ref": "#/definitions/import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType" }, "status": { "type": "integer" @@ -16197,7 +16210,7 @@ "status" ], "definitions": { - "import(\"/home/cyber/Dokumenty/git-projects/private/spacebar-test-station/server/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType": { + "import(\"/data/data/com.termux/files/home/server/node_modules/mailgun.js/Types/Types/Suppressions/Suppressions\",{with:{\"resolution-mode\":\"import\"}}).SuppressionDataType": { "anyOf": [ { "type": "object", @@ -17090,13 +17103,13 @@ "Promise<Cancel>": { "type": "object", "properties": { - "__@toStringTag@1292": { + "__@toStringTag@1294": { "type": "string" } }, "additionalProperties": false, "required": [ - "__@toStringTag@1292" + "__@toStringTag@1294" ] }, "Cancel": { @@ -58228,7 +58241,7 @@ "length": { "type": "integer" }, - "__@unscopables@689": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -58387,17 +58400,17 @@ "except": { "type": "boolean" }, - "__@iterator@687": { + "__@iterator@689": { "type": "boolean" }, - "__@unscopables@689": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@689", + "__@unscopables@691", "length" ] }, @@ -58451,7 +58464,7 @@ "length": { "type": "integer" }, - "__@unscopables@689": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -58610,17 +58623,17 @@ "except": { "type": "boolean" }, - "__@iterator@687": { + "__@iterator@689": { "type": "boolean" }, - "__@unscopables@689": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@689", + "__@unscopables@691", "length" ] }, @@ -117751,7 +117764,7 @@ "length": { "type": "integer" }, - "__@unscopables@689": { + "__@unscopables@691": { "type": "object", "additionalProperties": false, "patternProperties": { @@ -117910,17 +117923,17 @@ "except": { "type": "boolean" }, - "__@iterator@687": { + "__@iterator@689": { "type": "boolean" }, - "__@unscopables@689": { + "__@unscopables@691": { "type": "boolean" } } } }, "required": [ - "__@unscopables@689", + "__@unscopables@691", "length" ] }, diff --git a/src/api/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts
index 0821f811..4bb809a6 100644 --- a/src/api/middlewares/Authentication.ts +++ b/src/api/middlewares/Authentication.ts
@@ -29,6 +29,7 @@ export const NO_AUTHORIZATION_ROUTES = [ "POST /auth/verify", "POST /auth/forgot", "POST /auth/reset", + "POST /auth/fingerprint", "GET /invites/", // Routes with a seperate auth system /^(POST|HEAD|GET|PATCH|DELETE) \/webhooks\/\d+\/\w+\/?/, // no token requires auth diff --git a/src/api/routes/auth/fingerprint.ts b/src/api/routes/auth/fingerprint.ts new file mode 100644
index 00000000..d7ef34b4 --- /dev/null +++ b/src/api/routes/auth/fingerprint.ts
@@ -0,0 +1,29 @@ +/* + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ +import { route } from "@spacebar/api"; +import { createHash } from "node:crypto"; +import { Snowflake } from "@spacebar/util"; +import { Request, Response, Router } from "express"; +const router = Router({ mergeParams: true }); +router.post("/", route({ responses: { 200: { body: "CreateFingerprintResponse" } } }), (req: Request, res: Response) => { + const snowflake = Snowflake.generate(); + return res.json({ + fingerprint: `${snowflake}.${createHash("sha512").update(snowflake).digest("base64")}`, + }); +}); +export default router; diff --git a/src/schemas/CreateFingerprintResponse.ts b/src/schemas/CreateFingerprintResponse.ts new file mode 100644
index 00000000..3182ad9e --- /dev/null +++ b/src/schemas/CreateFingerprintResponse.ts
@@ -0,0 +1,3 @@ +export interface CreateFingerprintResponse { + fingerprint: string; +}