From 9d681e26841609b1a41c382347f5ec5a0234be27 Mon Sep 17 00:00:00 2001 From: "Samuel EF. Tinnerholm" Date: Sun, 24 May 2026 20:24:22 +0300 Subject: [PATCH] fix: kalshi auth privateKey guard Fixes #217 --- core/src/exchanges/kalshi/auth.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/exchanges/kalshi/auth.ts b/core/src/exchanges/kalshi/auth.ts index ad51c9ca..3eed93b5 100644 --- a/core/src/exchanges/kalshi/auth.ts +++ b/core/src/exchanges/kalshi/auth.ts @@ -57,7 +57,10 @@ export class KalshiAuth { // Allow input of private key in both raw string or PEM format // If it's a raw key without headers, accessing it might be tricky with implicit types, // but standard PEM is best. We assume the user provides a valid PEM. - let privateKey = this.credentials.privateKey!; + if (!this.credentials.privateKey) { + throw new Error('[kalshi] privateKey is required for authenticated requests'); + } + let privateKey = this.credentials.privateKey; // Fix for common .env issue where newlines are escaped if (privateKey.includes('\\n')) {