From 0ac2a1d250fdf34ad76686d37eb1e671126e0798 Mon Sep 17 00:00:00 2001 From: carlos-poly Date: Wed, 4 Mar 2026 12:30:58 -0500 Subject: [PATCH] Switch to esm --- package.json | 14 ++++++++++---- pnpm-lock.yaml | 8 -------- src/config.ts | 6 +++--- src/index.ts | 8 ++++---- src/signer.ts | 4 ++-- src/signing/hmac.ts | 4 ++-- src/signing/index.ts | 2 +- tests/config.test.ts | 4 ++-- tests/hmac.test.ts | 2 +- tests/signer.test.ts | 2 +- tsconfig.json | 10 +++------- 11 files changed, 29 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index 5da9293..c26fa74 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,20 @@ { "name": "@polymarket/builder-signing-sdk", "description": "Polymarket SDK for creating builder headers", - "version": "0.0.9", + "version": "1.0.0", "contributors": [ { "name": "Jonathan Amenechi", "url": "https://github.com/JonathanAmenechi" } ], + "type": "module", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } + }, "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ @@ -16,13 +23,12 @@ "license": "MIT", "packageManager": "pnpm@10.30.3", "scripts": { - "build": "rm -rf dist && tsc --module commonjs", + "build": "rm -rf dist && tsc", "deploy": "npm run build && npm publish", "test": "vitest run --coverage" }, "dependencies": { - "axios": "^1.12.2", - "tslib": "^2.8.1" + "axios": "^1.12.2" }, "devDependencies": { "@types/node": "^22.19.11", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a4db557..bad8e6c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,6 @@ importers: axios: specifier: ^1.12.2 version: 1.12.2 - tslib: - specifier: ^2.8.1 - version: 2.8.1 devDependencies: '@types/node': specifier: ^22.19.11 @@ -644,9 +641,6 @@ packages: resolution: {integrity: sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==} engines: {node: '>=14.0.0'} - tslib@2.8.1: - resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} - typescript@5.9.3: resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} engines: {node: '>=14.17'} @@ -1236,8 +1230,6 @@ snapshots: tinyrainbow@3.0.3: {} - tslib@2.8.1: {} - typescript@5.9.3: {} undici-types@6.21.0: {} diff --git a/src/config.ts b/src/config.ts index e1cc773..0b3cebf 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,12 +1,12 @@ -import { BuilderSigner } from "./signer"; -import { post } from "./http-helpers"; +import { BuilderSigner } from "./signer.js"; +import { post } from "./http-helpers/index.js"; import { BuilderApiKeyCreds, BuilderHeaderPayload, BuilderType, RemoteBuilderConfig, RemoteSignerPayload -} from "./types"; +} from "./types.js"; import { AxiosRequestHeaders } from 'axios'; export class BuilderConfig { diff --git a/src/index.ts b/src/index.ts index 4a2e826..da69341 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export * from "./config"; -export * from "./signing"; -export * from "./signer"; -export * from "./types"; +export * from "./config.js"; +export * from "./signing/index.js"; +export * from "./signer.js"; +export * from "./types.js"; diff --git a/src/signer.ts b/src/signer.ts index 54628cd..537693d 100644 --- a/src/signer.ts +++ b/src/signer.ts @@ -1,5 +1,5 @@ -import { buildHmacSignature } from "./signing"; -import { BuilderApiKeyCreds, BuilderHeaderPayload } from "./types"; +import { buildHmacSignature } from "./signing/index.js"; +import { BuilderApiKeyCreds, BuilderHeaderPayload } from "./types.js"; export class BuilderSigner { diff --git a/src/signing/hmac.ts b/src/signing/hmac.ts index 58bf9d9..83d769a 100644 --- a/src/signing/hmac.ts +++ b/src/signing/hmac.ts @@ -1,4 +1,4 @@ -import crypto from "crypto"; +import { createHmac } from "node:crypto"; function replaceAll(s: string, search: string, replace: string) { return s.split(search).join(replace); @@ -25,7 +25,7 @@ export const buildHmacSignature = ( } const base64Secret = Buffer.from(secret, "base64"); - const hmac = crypto.createHmac("sha256", base64Secret); + const hmac = createHmac("sha256", base64Secret); const sig = hmac.update(message).digest("base64"); // NOTE: Must be url safe base64 encoding, but keep base64 "=" suffix diff --git a/src/signing/index.ts b/src/signing/index.ts index 0188ebc..422ace4 100644 --- a/src/signing/index.ts +++ b/src/signing/index.ts @@ -1 +1 @@ -export * from "./hmac"; +export * from "./hmac.js"; diff --git a/tests/config.test.ts b/tests/config.test.ts index bf6e7b2..c0102a2 100644 --- a/tests/config.test.ts +++ b/tests/config.test.ts @@ -1,6 +1,6 @@ -import * as httpHelpers from '../src/http-helpers'; +import * as httpHelpers from '../src/http-helpers/index.js'; import { describe, it, expect, vi, afterEach } from "vitest"; -import { BuilderApiKeyCreds, BuilderConfig, BuilderHeaderPayload, BuilderType } from "../src"; +import { BuilderApiKeyCreds, BuilderConfig, BuilderHeaderPayload, BuilderType } from "../src/index.js"; describe("builder config", () => { afterEach(() => { diff --git a/tests/hmac.test.ts b/tests/hmac.test.ts index c272562..cea6e15 100644 --- a/tests/hmac.test.ts +++ b/tests/hmac.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from "vitest"; -import { buildHmacSignature } from "../src/signing"; +import { buildHmacSignature } from "../src/signing/index.js"; describe("hmac", () => { it("buildHmacSignature", () => { diff --git a/tests/signer.test.ts b/tests/signer.test.ts index 1a6bddb..737fd9f 100644 --- a/tests/signer.test.ts +++ b/tests/signer.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from "vitest"; -import { BuilderSigner, BuilderApiKeyCreds } from "../src"; +import { BuilderSigner, BuilderApiKeyCreds } from "../src/index.js"; describe("builderHeaderPayload", () => { it("createBuilderHeaderPayload", () => { diff --git a/tsconfig.json b/tsconfig.json index f10847f..02fd4f6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,16 +11,12 @@ ], "compilerOptions": { "baseUrl": "./", - "module": "commonjs", + "module": "nodenext", "target": "esnext", "outDir": "./dist", "sourceMap": true, "declaration": true, - "moduleResolution": "node", - "esModuleInterop": true, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "importHelpers": true, + "moduleResolution": "nodenext", "strict": true, "noFallthroughCasesInSwitch": true, "noUnusedLocals": true, @@ -29,7 +25,7 @@ "resolveJsonModule": true, "strictNullChecks": true, "typeRoots": ["node_modules/@types"], - "lib": ["es2018", "dom"], + "lib": ["es2022"], "skipLibCheck": true } } \ No newline at end of file