From 43eb1384fdf2ce2b1d28da1a4a926e3f96d67880 Mon Sep 17 00:00:00 2001 From: izzy Date: Fri, 4 Apr 2025 15:40:15 +0100 Subject: [PATCH] fix: authentication headers being shadowed by init data --- package.json | 6 +++--- pnpm-lock.yaml | 8 ++++---- src/index.ts | 22 +++++++++------------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 0497ed5..514ba6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "revolt-api", - "version": "0.8.4", + "version": "0.8.4-rc.5", "description": "Revolt API Library", "type": "module", "module": "lib/index.js", @@ -14,7 +14,7 @@ "prepublish": "in-publish && pnpm build || echo Skipping build." }, "devDependencies": { - "@insertish/oapi": "0.2.1", + "@insertish/oapi": "0.2.2", "in-publish": "^2.0.1", "openapi-typescript": "^5.4.2", "typescript": "^5.8.2" @@ -27,4 +27,4 @@ "README.md" ], "packageManager": "pnpm@8.13.1+sha512.758bebc6989cb6462c5138129840193b10c258ddcdb0ab43ee0ef9dd87784bc218d6e41cb5beeac362b8ce33f1f8b08025b599933c0bce82050a9a36b8474d43" -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5f9bd56..a16f7de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: devDependencies: '@insertish/oapi': - specifier: 0.2.1 - version: 0.2.1 + specifier: 0.2.2 + version: 0.2.2 in-publish: specifier: ^2.0.1 version: 2.0.1 @@ -25,8 +25,8 @@ packages: engines: {node: '>=14'} dev: true - /@insertish/oapi@0.2.1: - resolution: {integrity: sha512-Y60oVDHvXv9CHVZNhx0YdlErPpUohOLjc3UvrTZkV4lwE+qdw/bJDuebunwAOBS3cAersG7ZAu3LCLROuqctkA==} + /@insertish/oapi@0.2.2: + resolution: {integrity: sha512-rUWiu01PfXXJ9bgfbBa93uOtNi0WYPqfLWJcWTsbke4HrALX2ZvVHjMCMSGblvoQpnDeNTUZgW09wPgaMPa+JA==} hasBin: true dependencies: typescript: 4.9.5 diff --git a/src/index.ts b/src/index.ts index a3f5335..0d482a2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -106,34 +106,28 @@ export class API { /** * Generate authentication options. */ - get auth(): RequestOptions { + get auth(): Record { if (this.authentication.rauth) { if (typeof this.authentication.rauth === "string") { return { - headers: { - "X-Session-Token": this.authentication.rauth, - }, + "X-Session-Token": this.authentication.rauth, }; } } else if (this.authentication.revolt) { switch (typeof this.authentication.revolt) { case "string": { return { - headers: { - "X-Bot-Token": this.authentication.revolt, - }, + "X-Bot-Token": this.authentication.revolt, }; } case "object": { return { - headers: { - "X-Session-Token": this.authentication.revolt.token, - }, + "X-Session-Token": this.authentication.revolt.token, }; } } } else if (this.authentication.headers) { - return { headers: this.authentication.headers }; + return this.authentication.headers; } return {}; @@ -145,8 +139,10 @@ export class API { get config(): RequestOptions { return { baseURL: this.baseURL, - ...this.auth, - headers: this.headers, + headers: { + ...this.auth, + ...this.headers, + }, }; }