@spfunctions/cli 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/kalshi.js +8 -8
  2. package/package.json +1 -1
package/dist/kalshi.js CHANGED
@@ -20,7 +20,7 @@ exports.getMarketPrice = getMarketPrice;
20
20
  const fs_1 = __importDefault(require("fs"));
21
21
  const path_1 = __importDefault(require("path"));
22
22
  const crypto_1 = __importDefault(require("crypto"));
23
- const KALSHI_API_BASE = 'https://trading-api.kalshi.co/trade-api/v2';
23
+ const KALSHI_API_BASE = 'https://api.elections.kalshi.com/trade-api/v2';
24
24
  // ============================================================================
25
25
  // AUTH
26
26
  // ============================================================================
@@ -53,15 +53,15 @@ function loadPrivateKey() {
53
53
  * Sign a request using RSA-PSS (Kalshi's auth scheme).
54
54
  *
55
55
  * Kalshi expects:
56
- * Header: KALSHI-ACCESS-KEY = key ID
57
- * Header: KALSHI-ACCESS-SIGNATURE = base64(RSA-PSS-sign(timestamp + method + path))
58
- * Header: KALSHI-ACCESS-TIMESTAMP = ISO 8601 timestamp
56
+ * Header: KALSHI-ACCESS-KEY = API key ID
57
+ * Header: KALSHI-ACCESS-SIGNATURE = base64(RSA-PSS-sign(timestamp_ms + method + path))
58
+ * Header: KALSHI-ACCESS-TIMESTAMP = milliseconds since epoch (string)
59
59
  */
60
60
  function signRequest(method, urlPath, privateKey) {
61
61
  const keyId = process.env.KALSHI_API_KEY_ID;
62
- const timestamp = new Date().toISOString();
63
- // Kalshi signing payload: timestamp + method + path (no body)
64
- const payload = timestamp + method.toUpperCase() + urlPath;
62
+ const timestampMs = Date.now().toString();
63
+ // Kalshi signing payload: timestamp_ms + method + path (no body)
64
+ const payload = timestampMs + method.toUpperCase() + urlPath;
65
65
  const signature = crypto_1.default.sign('sha256', Buffer.from(payload), {
66
66
  key: privateKey,
67
67
  padding: crypto_1.default.constants.RSA_PKCS1_PSS_PADDING,
@@ -71,7 +71,7 @@ function signRequest(method, urlPath, privateKey) {
71
71
  headers: {
72
72
  'KALSHI-ACCESS-KEY': keyId,
73
73
  'KALSHI-ACCESS-SIGNATURE': signature.toString('base64'),
74
- 'KALSHI-ACCESS-TIMESTAMP': timestamp,
74
+ 'KALSHI-ACCESS-TIMESTAMP': timestampMs,
75
75
  'Content-Type': 'application/json',
76
76
  'Accept': 'application/json',
77
77
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spfunctions/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "CLI for SimpleFunctions prediction market thesis agent",
5
5
  "bin": {
6
6
  "sf": "./dist/index.js"