equito 0.0.0-stage → 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Equito
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,85 @@
1
- # Temporary Holding Version
1
+ # equito
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Stock token data on Robinhood Chain in one small client: every token, live prices, the DEX premium over the real
4
+ stock, Uniswap v3 pool depth, candles, wallet portfolios, corporate actions, SEC research, Pons launches, webhook
5
+ alerts, real Uniswap quotes and unsigned trades. No dependencies. Node 18+, browsers, Deno, Bun, Workers.
6
+
7
+ ```bash
8
+ npm install equito
9
+ ```
10
+
11
+ ```ts
12
+ import { Equito } from "equito";
13
+
14
+ const eq = new Equito();
15
+
16
+ const nvda = await eq.stats("NVDA");
17
+ // { tokenPrice: 145.44, dexPrice: 145.45, premiumPct: 0.005, liquidityUsd: 2168488, pools: [...] }
18
+
19
+ const quote = await eq.quote({ symbol: "NVDA", side: "buy", amount: "100" });
20
+ // spend 100 USDG: amountOut, effective price, priceImpactPct, vsTokenPricePct
21
+
22
+ const trade = await eq.buildTrade({ symbol: "NVDA", side: "buy", amount: "100", recipient: "0xYourWallet" });
23
+ // trade.transactions: unsigned approve + swap. Sign and send them yourself, in order.
24
+ ```
25
+
26
+ ## Methods
27
+
28
+ | Method | What it returns |
29
+ |---|---|
30
+ | `assets()`, `asset(symbol)` | Every stock token: contract, multiplier, status |
31
+ | `price(symbol)` | Robinhood's token bid/ask and the real stock's quote |
32
+ | `stats(symbol)` | Live DEX price vs Robinhood's price (premium), pools, supply, market cap |
33
+ | `stats({ sort })` | Every token from the last collector run |
34
+ | `history(symbol, { interval, days })` | 1h / 4h / 1d candles |
35
+ | `quote({ symbol, side, amount })` | A real Uniswap v3 quote on the best pool |
36
+ | `buildTrade({ symbol, side, amount, recipient, slippageBps })` | Unsigned approve + deadline-bound swap (2 calls) |
37
+ | `portfolio(address)` | Every stock token a wallet holds, valued live |
38
+ | `corporateActions(symbol?)` | Dividends and splits |
39
+ | `research(symbol)` | SEC EDGAR: revenue, income, EPS, filings |
40
+ | `markets({ hours, limit })` | New Pons launches, with reused-ticker counts |
41
+ | `createAlert(...)`, `alert(id)`, `deleteAlert(id)` | 7-day webhook alerts |
42
+ | `pricing()` | Price, free calls, payment terms |
43
+
44
+ Errors are `EquitoError` with the API's `status` and `code`. `eq.last.freeCallsLeft` tells how many free calls are
45
+ left today.
46
+
47
+ ## Paying
48
+
49
+ 50 calls a day per IP are free. After that each call costs $0.02 in USDG on Robinhood Chain over x402 ($0.04 for
50
+ `buildTrade`). Hand the client a `pay` function and it signs and retries once for you:
51
+
52
+ ```ts
53
+ const eq = new Equito({
54
+ pay: async (requirements) => {
55
+ // Sign an x402 v2 "exact" payment for `requirements` with your own wallet
56
+ // (any x402 client library does this) and return the base64 PAYMENT-SIGNATURE payload.
57
+ return signWithMyWallet(requirements);
58
+ },
59
+ });
60
+ ```
61
+
62
+ Without `pay`, a paid call throws `EquitoError` with `status: 402` and the terms in `paymentRequired`.
63
+ Equito never sees, holds or asks for your keys.
64
+
65
+ ## Alerts
66
+
67
+ ```ts
68
+ const { alert, webhookSecret } = await eq.createAlert({
69
+ symbol: "NVDA", metric: "premium_pct", op: "above", value: 1, webhookUrl: "https://example.com/hooks/equito",
70
+ });
71
+ ```
72
+
73
+ Each webhook carries `equito-signature: t=<unix>,v1=<hex>`. Check it with the raw body:
74
+
75
+ ```ts
76
+ import { verifyWebhook } from "equito";
77
+ const ok = await verifyWebhook(rawBody, request.headers.get("equito-signature")!, webhookSecret);
78
+ ```
79
+
80
+ ## Links
81
+
82
+ Docs: https://equito.pages.dev/docs · API: https://equito.pages.dev · MCP: https://equito.pages.dev/mcp ·
83
+ OpenAPI: https://equito.pages.dev/openapi.json · llms.txt: https://equito.pages.dev/llms.txt
84
+
85
+ Data, not investment advice.
@@ -0,0 +1,315 @@
1
+ export declare const DEFAULT_BASE_URL = "https://equito.pages.dev";
2
+ export type PaymentRequirements = {
3
+ scheme: "exact";
4
+ network: string;
5
+ amount: string;
6
+ asset: string;
7
+ payTo: string;
8
+ maxTimeoutSeconds: number;
9
+ extra: {
10
+ name: string;
11
+ version: string;
12
+ };
13
+ };
14
+ export type PaymentRequired = {
15
+ x402Version: number;
16
+ error?: string;
17
+ resource?: unknown;
18
+ accepts: PaymentRequirements[];
19
+ };
20
+ export type EquitoOptions = {
21
+ baseUrl?: string;
22
+ /** Signs the x402 payment for `requirements` with your wallet and returns the base64 PAYMENT-SIGNATURE payload. */
23
+ pay?: (requirements: PaymentRequirements, paymentRequired: PaymentRequired) => Promise<string>;
24
+ /** Your address, for the holder price once $EQUITO is live. Payments must then come from this address. */
25
+ holder?: string;
26
+ fetch?: typeof fetch;
27
+ headers?: Record<string, string>;
28
+ };
29
+ export declare class EquitoError extends Error {
30
+ status: number;
31
+ code: string;
32
+ /** Present on a 402 that was not paid (no `pay` given, or the payment was refused). */
33
+ paymentRequired?: PaymentRequired;
34
+ constructor(status: number, code: string, message: string, paymentRequired?: PaymentRequired);
35
+ }
36
+ export type CallInfo = {
37
+ /** Free calls left today for this IP (null once you are paying). */
38
+ freeCallsLeft: number | null;
39
+ /** base64 PAYMENT-RESPONSE (transaction, payer) when this call was paid. */
40
+ paymentResponse: string | null;
41
+ };
42
+ export type Asset = {
43
+ symbol: string;
44
+ name: string;
45
+ address: string | null;
46
+ chainId: number;
47
+ multiplier: number;
48
+ pendingMultiplier: number | null;
49
+ pendingMultiplierAt: string | null;
50
+ status: string | null;
51
+ tradingCapabilities: unknown;
52
+ };
53
+ export type Price = {
54
+ symbol: string;
55
+ name: string;
56
+ address: string | null;
57
+ multiplier: number;
58
+ tokenPrice: number;
59
+ token: {
60
+ bid: number;
61
+ ask: number;
62
+ };
63
+ stock: {
64
+ bid: number;
65
+ ask: number;
66
+ mid: number;
67
+ dailyHigh: number | null;
68
+ dailyLow: number | null;
69
+ dailyVolume: number | null;
70
+ };
71
+ mintBurnUsdVolume: number | null;
72
+ isTradingHalt: boolean;
73
+ generatedAt: string | null;
74
+ };
75
+ export type Pool = {
76
+ address: string;
77
+ fee: number;
78
+ feePct: number;
79
+ dexPrice: number | null;
80
+ tokenBalance: number;
81
+ usdgBalance: number;
82
+ liquidityUsd: number | null;
83
+ activeLiquidity: string;
84
+ };
85
+ export type Stats = {
86
+ symbol: string;
87
+ name: string | null;
88
+ address: string | null;
89
+ supply: number | null;
90
+ marketCapUsd?: number | null;
91
+ tokenPrice: number | null;
92
+ dexPrice: number | null;
93
+ premiumPct: number | null;
94
+ liquidityUsd: number | null;
95
+ pools?: Pool[];
96
+ live?: boolean;
97
+ updatedAt?: string;
98
+ };
99
+ export type StatsList = {
100
+ count: number;
101
+ updatedAt: string | null;
102
+ tokens: Stats[];
103
+ };
104
+ export type Candle = {
105
+ t: string;
106
+ open: number;
107
+ high: number;
108
+ low: number;
109
+ close: number;
110
+ dexClose: number | null;
111
+ liquidityUsd: number | null;
112
+ points: number;
113
+ };
114
+ export type History = {
115
+ symbol: string;
116
+ interval: string;
117
+ days: number;
118
+ count: number;
119
+ candles: Candle[];
120
+ };
121
+ export type Quote = {
122
+ symbol: string;
123
+ side: "buy" | "sell";
124
+ amountIn: string;
125
+ amountOut: string;
126
+ tokenIn: string;
127
+ tokenOut: string;
128
+ price: number;
129
+ pool: string;
130
+ feePct: number;
131
+ priceImpactPct: number | null;
132
+ vsTokenPricePct: number | null;
133
+ tokenPrice: number | null;
134
+ };
135
+ export type UnsignedTx = {
136
+ to: string;
137
+ data: string;
138
+ value: "0";
139
+ description: string;
140
+ };
141
+ export type TradeBuild = {
142
+ quote: Quote;
143
+ recipient: string;
144
+ slippageBps: number;
145
+ amountOutMinimum: string;
146
+ deadline: number;
147
+ chainId: number;
148
+ transactions: UnsignedTx[];
149
+ };
150
+ export type Holding = {
151
+ symbol: string;
152
+ name: string;
153
+ address: string;
154
+ balance: number;
155
+ price: number | null;
156
+ valueUsd: number | null;
157
+ };
158
+ export type Portfolio = {
159
+ address: string;
160
+ holdings: Holding[];
161
+ usdg: number;
162
+ totalUsd: number;
163
+ tokensChecked: number;
164
+ };
165
+ export type CorporateAction = {
166
+ id: string | null;
167
+ symbol: string;
168
+ type: string | null;
169
+ status: string | null;
170
+ processDate: string | null;
171
+ address: string | null;
172
+ details: unknown;
173
+ };
174
+ export type Figure = {
175
+ value: number;
176
+ periodEnd: string;
177
+ form: string | null;
178
+ fiscalYear: number | null;
179
+ } | null;
180
+ export type Figures = Record<"revenue" | "netIncome" | "epsDiluted" | "totalAssets" | "totalLiabilities" | "cash" | "operatingCashFlow", Figure>;
181
+ export type Research = {
182
+ symbol: string;
183
+ cik: string;
184
+ name: string;
185
+ industry: string | null;
186
+ exchanges: string[];
187
+ fiscalYearEnd: string | null;
188
+ sharesOutstanding: {
189
+ value: number;
190
+ asOf: string;
191
+ } | null;
192
+ annual: Figures;
193
+ quarter: Figures;
194
+ filings: {
195
+ form: string;
196
+ filed: string | null;
197
+ reportDate: string | null;
198
+ description: string | null;
199
+ url: string | null;
200
+ }[];
201
+ };
202
+ export type Launch = {
203
+ token: string;
204
+ symbol: string | null;
205
+ name: string | null;
206
+ pool: string;
207
+ creator: string;
208
+ createdAt: string;
209
+ block: number;
210
+ sameTickerInWindow: number | null;
211
+ creatorLaunchesInWindow: number;
212
+ };
213
+ export type Markets = {
214
+ hours: number;
215
+ total: number;
216
+ updatedAt: string | null;
217
+ launches: Launch[];
218
+ };
219
+ export type AlertMetric = "token_price" | "dex_price" | "premium_pct" | "liquidity_usd";
220
+ export type Alert = {
221
+ id: string;
222
+ symbol: string;
223
+ metric: AlertMetric;
224
+ op: "above" | "below";
225
+ value: number;
226
+ webhookHost: string;
227
+ createdAt: string;
228
+ expiresAt: string;
229
+ met: boolean | null;
230
+ lastValue: number | null;
231
+ lastChecked: string | null;
232
+ fired: number;
233
+ lastFired: string | null;
234
+ lastStatus: number | null;
235
+ };
236
+ export type Pricing = {
237
+ freeCallsPerDay: number;
238
+ priceUsd: number;
239
+ tradeBuildPriceUsd: number;
240
+ amount: string;
241
+ asset: string;
242
+ network: string;
243
+ payTo: string | null;
244
+ facilitator: string;
245
+ holder: {
246
+ token: string;
247
+ minBalance: string;
248
+ discountPct: number;
249
+ header: string;
250
+ } | null;
251
+ };
252
+ export declare class Equito {
253
+ readonly baseUrl: string;
254
+ /** Free calls left and the payment receipt of the most recent call. */
255
+ last: CallInfo;
256
+ private opts;
257
+ private f;
258
+ constructor(opts?: EquitoOptions);
259
+ private request;
260
+ private sym;
261
+ /** Every stock token on Robinhood Chain. */
262
+ assets(): Promise<Asset[]>;
263
+ asset(symbol: string): Promise<Asset>;
264
+ /** Robinhood's token bid/ask and the real stock's quote. */
265
+ price(symbol: string): Promise<Price>;
266
+ /** One token live (DEX price, premium, pools), or every token from the last collector run when no symbol is given. */
267
+ stats(symbol: string): Promise<Stats>;
268
+ stats(opts?: {
269
+ sort?: "liquidity" | "premium" | "symbol";
270
+ }): Promise<StatsList>;
271
+ history(symbol: string, opts?: {
272
+ interval?: "1h" | "4h" | "1d";
273
+ days?: number;
274
+ }): Promise<History>;
275
+ /** A real Uniswap v3 quote. amount: USDG to spend (buy) or tokens to sell (sell). */
276
+ quote(o: {
277
+ symbol: string;
278
+ side: "buy" | "sell";
279
+ amount: string | number;
280
+ }): Promise<Quote>;
281
+ /** Unsigned approve + swap to send from your own wallet. Costs 2 calls. */
282
+ buildTrade(o: {
283
+ symbol: string;
284
+ side: "buy" | "sell";
285
+ amount: string | number;
286
+ recipient: string;
287
+ slippageBps?: number;
288
+ }): Promise<TradeBuild>;
289
+ portfolio(address: string): Promise<Portfolio>;
290
+ corporateActions(symbol?: string): Promise<CorporateAction[]>;
291
+ research(symbol: string, opts?: {
292
+ filings?: number;
293
+ }): Promise<Research>;
294
+ /** Newest Pons launches, each with how many launches in the window reuse its ticker. */
295
+ markets(opts?: {
296
+ hours?: number;
297
+ limit?: number;
298
+ }): Promise<Markets>;
299
+ /** A 7-day webhook alert. Keep the returned id and webhookSecret: they are shown only once. */
300
+ createAlert(o: {
301
+ symbol: string;
302
+ metric: AlertMetric;
303
+ op: "above" | "below";
304
+ value: number;
305
+ webhookUrl: string;
306
+ }): Promise<{
307
+ alert: Alert;
308
+ webhookSecret: string;
309
+ }>;
310
+ alert(id: string): Promise<Alert>;
311
+ deleteAlert(id: string): Promise<void>;
312
+ pricing(): Promise<Pricing>;
313
+ }
314
+ /** Checks an alert webhook: header equito-signature "t=<unix>,v1=<hex>" over "<t>.<raw body>" with your webhookSecret. */
315
+ export declare function verifyWebhook(rawBody: string, signatureHeader: string, secret: string, maxAgeSeconds?: number, nowMs?: number): Promise<boolean>;
package/dist/index.js ADDED
@@ -0,0 +1,167 @@
1
+ // Equito SDK: one small class over the Equito API (https://equito.pages.dev). No dependencies, works in Node 18+,
2
+ // browsers, Deno, Bun and Workers.
3
+ //
4
+ // import { Equito } from "equito";
5
+ // const eq = new Equito();
6
+ // const nvda = await eq.stats("NVDA"); // DEX price vs Robinhood's price, pools, supply
7
+ // const q = await eq.quote({ symbol: "NVDA", side: "buy", amount: "100" });
8
+ //
9
+ // 50 calls a day per IP are free. After that a call answers 402 (x402 v2, USDG on Robinhood Chain). Pass `pay` and
10
+ // the SDK signs and retries once for you: `pay` gets the payment terms and returns the base64 PAYMENT-SIGNATURE,
11
+ // signed by your own wallet (any x402 client library can build it). Equito never sees or holds your keys.
12
+ // Same value as API_URL in api/src/hosts.ts (a test keeps them equal). The published package cannot import it, so the
13
+ // address is written here too; on domain day change both and publish a new version.
14
+ export const DEFAULT_BASE_URL = "https://equito.pages.dev";
15
+ export class EquitoError extends Error {
16
+ status;
17
+ code;
18
+ /** Present on a 402 that was not paid (no `pay` given, or the payment was refused). */
19
+ paymentRequired;
20
+ constructor(status, code, message, paymentRequired) {
21
+ super(message);
22
+ this.name = "EquitoError";
23
+ this.status = status;
24
+ this.code = code;
25
+ this.paymentRequired = paymentRequired;
26
+ }
27
+ }
28
+ const SYMBOL = /^[A-Za-z][A-Za-z0-9.\-]{0,11}$/;
29
+ const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
30
+ function fromBase64Json(text) {
31
+ try {
32
+ const bin = atob(text.trim());
33
+ return JSON.parse(new TextDecoder().decode(Uint8Array.from(bin, (c) => c.charCodeAt(0))));
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ }
39
+ export class Equito {
40
+ baseUrl;
41
+ /** Free calls left and the payment receipt of the most recent call. */
42
+ last = { freeCallsLeft: null, paymentResponse: null };
43
+ opts;
44
+ f;
45
+ constructor(opts = {}) {
46
+ this.opts = opts;
47
+ this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
48
+ this.f = opts.fetch ?? ((input, init) => fetch(input, init));
49
+ if (opts.holder !== undefined && !ADDRESS.test(opts.holder))
50
+ throw new TypeError("holder must be an address: 0x + 40 hex");
51
+ }
52
+ async request(method, path, body) {
53
+ const headers = { accept: "application/json", ...this.opts.headers };
54
+ if (this.opts.holder)
55
+ headers["x-holder"] = this.opts.holder;
56
+ if (body !== undefined)
57
+ headers["content-type"] = "application/json";
58
+ const send = (extra = {}) => this.f(this.baseUrl + path, { method, headers: { ...headers, ...extra }, body: body === undefined ? undefined : JSON.stringify(body) });
59
+ let res = await send();
60
+ if (res.status === 402) {
61
+ const terms = ((await res.clone().json().catch(() => undefined)) ?? fromBase64Json(res.headers.get("payment-required") ?? ""));
62
+ const req = terms?.accepts?.[0];
63
+ if (!this.opts.pay || !req)
64
+ throw new EquitoError(402, "payment_required", terms?.error ?? "Payment required.", terms);
65
+ res = await send({ "payment-signature": await this.opts.pay(req, terms) });
66
+ }
67
+ const left = res.headers.get("x-free-calls-left");
68
+ this.last = { freeCallsLeft: left === null ? null : Number(left), paymentResponse: res.headers.get("payment-response") };
69
+ const data = (await res.json().catch(() => undefined));
70
+ if (!res.ok) {
71
+ const e = data?.error;
72
+ if (res.status === 402)
73
+ throw new EquitoError(402, "payment_refused", typeof data?.error === "string" ? data.error : "The payment was not accepted.", data);
74
+ throw new EquitoError(res.status, typeof e?.code === "string" ? e.code : `http_${res.status}`, typeof e?.message === "string" ? e.message : `Equito answered ${res.status}.`);
75
+ }
76
+ return data;
77
+ }
78
+ sym(symbol) {
79
+ if (!SYMBOL.test(symbol))
80
+ throw new TypeError(`Not a ticker: ${symbol}`);
81
+ return encodeURIComponent(symbol.toUpperCase());
82
+ }
83
+ /** Every stock token on Robinhood Chain. */
84
+ async assets() {
85
+ return (await this.request("GET", "/v1/assets")).assets;
86
+ }
87
+ asset(symbol) {
88
+ return this.request("GET", `/v1/assets/${this.sym(symbol)}`);
89
+ }
90
+ /** Robinhood's token bid/ask and the real stock's quote. */
91
+ price(symbol) {
92
+ return this.request("GET", `/v1/prices/${this.sym(symbol)}`);
93
+ }
94
+ stats(arg) {
95
+ if (typeof arg === "string")
96
+ return this.request("GET", `/v1/stats/${this.sym(arg)}`);
97
+ return this.request("GET", `/v1/stats${arg?.sort ? `?sort=${arg.sort}` : ""}`);
98
+ }
99
+ history(symbol, opts = {}) {
100
+ const q = new URLSearchParams();
101
+ if (opts.interval)
102
+ q.set("interval", opts.interval);
103
+ if (opts.days !== undefined)
104
+ q.set("days", String(opts.days));
105
+ return this.request("GET", `/v1/history/${this.sym(symbol)}${[...q].length ? "?" + q : ""}`);
106
+ }
107
+ /** A real Uniswap v3 quote. amount: USDG to spend (buy) or tokens to sell (sell). */
108
+ quote(o) {
109
+ const q = new URLSearchParams({ symbol: o.symbol.toUpperCase(), side: o.side, amount: String(o.amount) });
110
+ return this.request("GET", `/v1/quote?${q}`);
111
+ }
112
+ /** Unsigned approve + swap to send from your own wallet. Costs 2 calls. */
113
+ buildTrade(o) {
114
+ if (!ADDRESS.test(o.recipient))
115
+ throw new TypeError("recipient must be an address: 0x + 40 hex");
116
+ return this.request("POST", "/v1/trade/build", { ...o, symbol: o.symbol.toUpperCase(), amount: String(o.amount) });
117
+ }
118
+ portfolio(address) {
119
+ if (!ADDRESS.test(address))
120
+ throw new TypeError("address must be 0x + 40 hex");
121
+ return this.request("GET", `/v1/portfolio/${address}`);
122
+ }
123
+ async corporateActions(symbol) {
124
+ return (await this.request("GET", `/v1/corporate-actions${symbol ? `?symbol=${this.sym(symbol)}` : ""}`)).actions;
125
+ }
126
+ research(symbol, opts = {}) {
127
+ return this.request("GET", `/v1/research/${this.sym(symbol)}${opts.filings ? `?filings=${opts.filings}` : ""}`);
128
+ }
129
+ /** Newest Pons launches, each with how many launches in the window reuse its ticker. */
130
+ markets(opts = {}) {
131
+ const q = new URLSearchParams();
132
+ if (opts.hours !== undefined)
133
+ q.set("hours", String(opts.hours));
134
+ if (opts.limit !== undefined)
135
+ q.set("limit", String(opts.limit));
136
+ return this.request("GET", `/v1/markets${[...q].length ? "?" + q : ""}`);
137
+ }
138
+ /** A 7-day webhook alert. Keep the returned id and webhookSecret: they are shown only once. */
139
+ createAlert(o) {
140
+ return this.request("POST", "/v1/alerts", { ...o, symbol: o.symbol.toUpperCase() });
141
+ }
142
+ async alert(id) {
143
+ return (await this.request("GET", `/v1/alerts/${encodeURIComponent(id)}`)).alert;
144
+ }
145
+ async deleteAlert(id) {
146
+ await this.request("DELETE", `/v1/alerts/${encodeURIComponent(id)}`);
147
+ }
148
+ pricing() {
149
+ return this.request("GET", "/v1/pricing");
150
+ }
151
+ }
152
+ /** Checks an alert webhook: header equito-signature "t=<unix>,v1=<hex>" over "<t>.<raw body>" with your webhookSecret. */
153
+ export async function verifyWebhook(rawBody, signatureHeader, secret, maxAgeSeconds = 300, nowMs = Date.now()) {
154
+ const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(signatureHeader.trim());
155
+ if (!m)
156
+ return false;
157
+ const t = Number(m[1]);
158
+ if (Math.abs(nowMs / 1000 - t) > maxAgeSeconds)
159
+ return false;
160
+ const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
161
+ const mac = new Uint8Array(await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(`${t}.${rawBody}`)));
162
+ const hex = [...mac].map((b) => b.toString(16).padStart(2, "0")).join("");
163
+ let diff = 0;
164
+ for (let i = 0; i < 64; i++)
165
+ diff |= hex.charCodeAt(i) ^ m[2].charCodeAt(i);
166
+ return diff === 0;
167
+ }
package/package.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "equito",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Stock token data on Robinhood Chain: prices, DEX premium, pools, candles, portfolios, SEC research, Uniswap quotes and unsigned trades. Pays per call over x402 when you hand it a signer.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
10
+ "files": ["dist", "README.md", "LICENSE"],
11
+ "sideEffects": false,
12
+ "engines": { "node": ">=18" },
13
+ "keywords": ["robinhood-chain", "tokenized-stocks", "stock-tokens", "x402", "uniswap", "ai-agents", "api"],
14
+ "repository": { "type": "git", "url": "git+https://github.com/equito-dev/equito-app.git", "directory": "sdk" },
15
+ "homepage": "https://equito.pages.dev/docs/sdk",
16
+ "scripts": {
17
+ "build": "tsc -p tsconfig.build.json",
18
+ "prepublishOnly": "npm run build && npm test",
19
+ "test": "node --test test/*.test.ts",
20
+ "typecheck": "tsc -p tsconfig.json"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^24.19.2",
24
+ "typescript": "~7.0.2"
25
+ }
26
+ }