From 1c74b381429ebfb8a7d1625d9e4294d527c2a430 Mon Sep 17 00:00:00 2001 From: Samuel Tinnerholm Date: Mon, 29 Jun 2026 06:35:32 +0000 Subject: [PATCH] fix(ts-sdk): forward apiSecret credentials --- sdks/typescript/pmxt/client.ts | 8 +++++- .../tests/exchange-credentials.test.ts | 26 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 sdks/typescript/tests/exchange-credentials.test.ts diff --git a/sdks/typescript/pmxt/client.ts b/sdks/typescript/pmxt/client.ts index 5049f617..6e3664d8 100644 --- a/sdks/typescript/pmxt/client.ts +++ b/sdks/typescript/pmxt/client.ts @@ -232,6 +232,9 @@ export interface ExchangeOptions { /** Venue-specific API key (e.g. Polymarket CLOB key). Optional. */ apiKey?: string; + /** Venue-specific API secret for HMAC/CLOB-authenticated exchanges. Optional. */ + apiSecret?: string; + /** Venue-specific private key. Optional. */ privateKey?: string; @@ -320,6 +323,7 @@ export abstract class Exchange { public exchangeName: string; public pmxtApiKey?: string; protected apiKey?: string; + protected apiSecret?: string; protected privateKey?: string; protected proxyAddress?: string; protected signatureType?: number; @@ -357,6 +361,7 @@ export abstract class Exchange { constructor(exchangeName: string, options: ExchangeOptions = {}) { this.exchangeName = exchangeName.toLowerCase(); this.apiKey = options.apiKey; + this.apiSecret = options.apiSecret; this.privateKey = options.privateKey; this.proxyAddress = options.proxyAddress; this.signatureType = options.signatureType; @@ -462,11 +467,12 @@ export abstract class Exchange { } protected getCredentials(): ExchangeCredentials | undefined { - if (!this.apiKey && !this.privateKey) { + if (!this.apiKey && !this.apiSecret && !this.privateKey) { return undefined; } return { apiKey: this.apiKey, + apiSecret: this.apiSecret, privateKey: this.privateKey, funderAddress: this.proxyAddress, signatureType: this.signatureType, diff --git a/sdks/typescript/tests/exchange-credentials.test.ts b/sdks/typescript/tests/exchange-credentials.test.ts new file mode 100644 index 00000000..ce8f9899 --- /dev/null +++ b/sdks/typescript/tests/exchange-credentials.test.ts @@ -0,0 +1,26 @@ +import { Exchange, ExchangeOptions } from "../pmxt/client"; + +class TestExchange extends Exchange { + public exposedCredentials() { + return this.getCredentials(); + } +} + +describe("exchange credentials", () => { + it("accepts and forwards apiSecret with sidecar credentials", () => { + const options = { + apiKey: "api-key", + apiSecret: "api-secret", + privateKey: "private-key", + autoStartServer: false, + } satisfies ExchangeOptions; + + const exchange = new TestExchange("polymarket", options); + + expect(exchange.exposedCredentials()).toMatchObject({ + apiKey: "api-key", + apiSecret: "api-secret", + privateKey: "private-key", + }); + }); +});