@dopemarkets/agent-client 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/dist/client.d.ts +140 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +200 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/sign.d.ts +29 -0
- package/dist/sign.d.ts.map +1 -0
- package/dist/sign.js +112 -0
- package/dist/sign.js.map +1 -0
- package/dist/turnkey.d.ts +34 -0
- package/dist/turnkey.d.ts.map +1 -0
- package/dist/turnkey.js +56 -0
- package/dist/turnkey.js.map +1 -0
- package/dist/types.d.ts +225 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { AccountSummary, ActivateBuildResponse, ActivateSubmitResponse, ActivationTxResponse, AgentCredential, AgentKeySummary, ApiErrorCode, BalanceResponse, CandidatesResponse, LoginExchangeResponse, LoginInitInput, LoginInitResponse, MarketDetail, MarketSummary, QuoteResponse, StackDetail, StackSummary } from './types.js';
|
|
2
|
+
export interface DopeClientOptions {
|
|
3
|
+
/** Base URL of the DOPE backend, e.g. https://dope-backend-production.up.railway.app */
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
/** The Agent Key credential — used to sign every authenticated request. */
|
|
6
|
+
credential: AgentCredential;
|
|
7
|
+
/** Optional override for `fetch` (test injection). */
|
|
8
|
+
fetch?: typeof fetch;
|
|
9
|
+
/** Optional CLI version string for the X-DOPE-Client-Version header. */
|
|
10
|
+
clientVersion?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Error thrown by every client method on a non-2xx response. */
|
|
13
|
+
export declare class DopeAgentError extends Error {
|
|
14
|
+
/** Stable error code from the agent error taxonomy. */
|
|
15
|
+
code: ApiErrorCode;
|
|
16
|
+
/** HTTP status code. */
|
|
17
|
+
status: number;
|
|
18
|
+
/** The raw response body, parsed if JSON. */
|
|
19
|
+
body: unknown;
|
|
20
|
+
constructor(code: ApiErrorCode, status: number, body: unknown);
|
|
21
|
+
}
|
|
22
|
+
export interface ListStacksOptions {
|
|
23
|
+
status?: 'all' | 'active' | 'pending' | 'resolved' | 'failed';
|
|
24
|
+
limit?: number;
|
|
25
|
+
cursor?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SearchMarketsOptions {
|
|
28
|
+
q?: string;
|
|
29
|
+
category?: string;
|
|
30
|
+
min_liquidity?: number;
|
|
31
|
+
closes_before?: string;
|
|
32
|
+
closes_after?: string;
|
|
33
|
+
limit?: number;
|
|
34
|
+
cursor?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface QuoteInput {
|
|
37
|
+
legs: Array<{
|
|
38
|
+
market_id: string;
|
|
39
|
+
outcome: string;
|
|
40
|
+
}>;
|
|
41
|
+
premium_usdc: number | string;
|
|
42
|
+
}
|
|
43
|
+
export interface CandidatesInput {
|
|
44
|
+
target_multiplier_min: number;
|
|
45
|
+
target_multiplier_max: number;
|
|
46
|
+
max_premium_usdc: number | string;
|
|
47
|
+
categories?: string[];
|
|
48
|
+
leg_count_min?: number;
|
|
49
|
+
leg_count_max?: number;
|
|
50
|
+
closes_before?: string;
|
|
51
|
+
limit?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface ActivateInput {
|
|
54
|
+
quote_id: string;
|
|
55
|
+
idempotency_key: string;
|
|
56
|
+
}
|
|
57
|
+
export interface ActivateSubmitInput {
|
|
58
|
+
stack_id: string;
|
|
59
|
+
activation_id: string;
|
|
60
|
+
signed_tx_base64: string;
|
|
61
|
+
}
|
|
62
|
+
export declare class DopeClient {
|
|
63
|
+
private readonly baseUrl;
|
|
64
|
+
private readonly credential;
|
|
65
|
+
private readonly fetchImpl;
|
|
66
|
+
private readonly clientVersion;
|
|
67
|
+
constructor(options: DopeClientOptions);
|
|
68
|
+
getAccount(): Promise<AccountSummary>;
|
|
69
|
+
getBalance(): Promise<BalanceResponse>;
|
|
70
|
+
getAgentKeyStatus(): Promise<{
|
|
71
|
+
ok: true;
|
|
72
|
+
agent_key: AgentKeySummary;
|
|
73
|
+
}>;
|
|
74
|
+
searchMarkets(options?: SearchMarketsOptions): Promise<{
|
|
75
|
+
ok: true;
|
|
76
|
+
markets: MarketSummary[];
|
|
77
|
+
next_cursor: string | null;
|
|
78
|
+
}>;
|
|
79
|
+
getMarket(marketId: string): Promise<{
|
|
80
|
+
ok: true;
|
|
81
|
+
market: MarketDetail;
|
|
82
|
+
}>;
|
|
83
|
+
listStacks(options?: ListStacksOptions): Promise<{
|
|
84
|
+
ok: true;
|
|
85
|
+
stacks: StackSummary[];
|
|
86
|
+
next_cursor: string | null;
|
|
87
|
+
}>;
|
|
88
|
+
getStack(stackId: string): Promise<{
|
|
89
|
+
ok: true;
|
|
90
|
+
stack: StackDetail;
|
|
91
|
+
}>;
|
|
92
|
+
findCandidates(input: CandidatesInput): Promise<CandidatesResponse>;
|
|
93
|
+
quoteStack(input: QuoteInput): Promise<QuoteResponse>;
|
|
94
|
+
/** Build phase. Returns activation_id; long-poll getActivationTx() for the unsigned tx. */
|
|
95
|
+
activateStack(input: ActivateInput): Promise<ActivateBuildResponse>;
|
|
96
|
+
/** Long-poll. Returns 200 with unsigned_tx_base64 once ready; throws DopeAgentError on 408 (still building) so callers can retry. */
|
|
97
|
+
getActivationTx(activationId: string): Promise<ActivationTxResponse>;
|
|
98
|
+
/** Submit a Turnkey-signed activation tx. The CLI orchestrates the signing externally. */
|
|
99
|
+
submitActivation(input: ActivateSubmitInput): Promise<ActivateSubmitResponse>;
|
|
100
|
+
listAgentKeys(options?: {
|
|
101
|
+
status?: string;
|
|
102
|
+
limit?: number;
|
|
103
|
+
cursor?: string;
|
|
104
|
+
}): Promise<{
|
|
105
|
+
ok: true;
|
|
106
|
+
agent_keys: AgentKeySummary[];
|
|
107
|
+
next_cursor: string | null;
|
|
108
|
+
}>;
|
|
109
|
+
getAgentKey(agentKeyId: string): Promise<{
|
|
110
|
+
ok: true;
|
|
111
|
+
agent_key: AgentKeySummary;
|
|
112
|
+
}>;
|
|
113
|
+
revokeAgentKey(agentKeyId: string, reason?: string): Promise<{
|
|
114
|
+
ok: true;
|
|
115
|
+
agent_key_id: string;
|
|
116
|
+
}>;
|
|
117
|
+
private withQuery;
|
|
118
|
+
private request;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Login-flow client. These endpoints are NOT signed (the CLI has no
|
|
122
|
+
* credential yet) and don't need an AgentCredential.
|
|
123
|
+
*/
|
|
124
|
+
export declare class DopeLoginClient {
|
|
125
|
+
private readonly baseUrl;
|
|
126
|
+
private readonly fetchImpl;
|
|
127
|
+
constructor(options: {
|
|
128
|
+
baseUrl: string;
|
|
129
|
+
fetch?: typeof fetch;
|
|
130
|
+
});
|
|
131
|
+
init(input: LoginInitInput): Promise<LoginInitResponse>;
|
|
132
|
+
/**
|
|
133
|
+
* Poll for completion. Returns { ok: true } once the user has approved
|
|
134
|
+
* in the browser. While pending, throws DopeAgentError with
|
|
135
|
+
* code='AUTHORIZATION_PENDING' (HTTP 202); CLI should sleep and retry.
|
|
136
|
+
*/
|
|
137
|
+
exchange(deviceCode: string): Promise<LoginExchangeResponse>;
|
|
138
|
+
private unsignedRequest;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EAEb,aAAa,EACb,WAA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M,CAAA;KAAE,CAAC;IAUtG,OAAO,CAAC,SAAS;YAUH,OAAO;CAmCtB;AAED;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;gBAE7B,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;KAAE;IAKxD,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI7D;;;;OAIG;IACG,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;YAMpD,eAAe;CAmB9B"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The DOPE Agent Mode API client.
|
|
3
|
+
//
|
|
4
|
+
// One class with typed methods for every /agent/* endpoint. The client
|
|
5
|
+
// signs every request with the Agent Key's P-256 private key (caller
|
|
6
|
+
// supplies a `credential` at construction time) and returns parsed,
|
|
7
|
+
// typed responses.
|
|
8
|
+
//
|
|
9
|
+
// Errors from the server are surfaced as `DopeAgentError` with the stable
|
|
10
|
+
// `error_code` from the agent error taxonomy. The HTTP status is
|
|
11
|
+
// secondary — agents should react to the code.
|
|
12
|
+
//
|
|
13
|
+
// This client does NOT handle:
|
|
14
|
+
// - Local credential storage (OS keychain). That's the CLI's job; it
|
|
15
|
+
// loads the credential and passes it to `new DopeClient({ credential })`.
|
|
16
|
+
// - Turnkey-side transaction signing for /agent/stacks/activate/submit.
|
|
17
|
+
// See `turnkey.ts` for that helper; the CLI orchestrates the two.
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.DopeLoginClient = exports.DopeClient = exports.DopeAgentError = void 0;
|
|
20
|
+
const sign_js_1 = require("./sign.js");
|
|
21
|
+
/** Error thrown by every client method on a non-2xx response. */
|
|
22
|
+
class DopeAgentError extends Error {
|
|
23
|
+
/** Stable error code from the agent error taxonomy. */
|
|
24
|
+
code;
|
|
25
|
+
/** HTTP status code. */
|
|
26
|
+
status;
|
|
27
|
+
/** The raw response body, parsed if JSON. */
|
|
28
|
+
body;
|
|
29
|
+
constructor(code, status, body) {
|
|
30
|
+
super(`${code} (HTTP ${status})`);
|
|
31
|
+
this.name = 'DopeAgentError';
|
|
32
|
+
this.code = code;
|
|
33
|
+
this.status = status;
|
|
34
|
+
this.body = body;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.DopeAgentError = DopeAgentError;
|
|
38
|
+
class DopeClient {
|
|
39
|
+
baseUrl;
|
|
40
|
+
credential;
|
|
41
|
+
fetchImpl;
|
|
42
|
+
clientVersion;
|
|
43
|
+
constructor(options) {
|
|
44
|
+
this.baseUrl = options.baseUrl.replace(/\/$/, '');
|
|
45
|
+
this.credential = options.credential;
|
|
46
|
+
this.fetchImpl = options.fetch ?? globalThis.fetch;
|
|
47
|
+
this.clientVersion = options.clientVersion;
|
|
48
|
+
}
|
|
49
|
+
// ----- Account / balance / status --------------------------------------
|
|
50
|
+
async getAccount() {
|
|
51
|
+
return this.request('GET', '/agent/account');
|
|
52
|
+
}
|
|
53
|
+
async getBalance() {
|
|
54
|
+
return this.request('GET', '/agent/balance');
|
|
55
|
+
}
|
|
56
|
+
async getAgentKeyStatus() {
|
|
57
|
+
return this.request('GET', '/agent/agent-key-status');
|
|
58
|
+
}
|
|
59
|
+
// ----- Markets ----------------------------------------------------------
|
|
60
|
+
async searchMarkets(options = {}) {
|
|
61
|
+
return this.request('GET', this.withQuery('/agent/markets/search', options));
|
|
62
|
+
}
|
|
63
|
+
async getMarket(marketId) {
|
|
64
|
+
return this.request('GET', `/agent/markets/${encodeURIComponent(marketId)}`);
|
|
65
|
+
}
|
|
66
|
+
// ----- Stacks (read) ----------------------------------------------------
|
|
67
|
+
async listStacks(options = {}) {
|
|
68
|
+
return this.request('GET', this.withQuery('/agent/stacks', options));
|
|
69
|
+
}
|
|
70
|
+
async getStack(stackId) {
|
|
71
|
+
return this.request('GET', `/agent/stacks/${encodeURIComponent(stackId)}`);
|
|
72
|
+
}
|
|
73
|
+
// ----- Stacks (write) ---------------------------------------------------
|
|
74
|
+
async findCandidates(input) {
|
|
75
|
+
return this.request('POST', '/agent/stacks/candidates', input);
|
|
76
|
+
}
|
|
77
|
+
async quoteStack(input) {
|
|
78
|
+
return this.request('POST', '/agent/stacks/quote', input);
|
|
79
|
+
}
|
|
80
|
+
/** Build phase. Returns activation_id; long-poll getActivationTx() for the unsigned tx. */
|
|
81
|
+
async activateStack(input) {
|
|
82
|
+
return this.request('POST', '/agent/stacks/activate', input);
|
|
83
|
+
}
|
|
84
|
+
/** Long-poll. Returns 200 with unsigned_tx_base64 once ready; throws DopeAgentError on 408 (still building) so callers can retry. */
|
|
85
|
+
async getActivationTx(activationId) {
|
|
86
|
+
return this.request('GET', `/agent/stacks/activations/${encodeURIComponent(activationId)}/tx`);
|
|
87
|
+
}
|
|
88
|
+
/** Submit a Turnkey-signed activation tx. The CLI orchestrates the signing externally. */
|
|
89
|
+
async submitActivation(input) {
|
|
90
|
+
return this.request('POST', '/agent/stacks/activate/submit', input);
|
|
91
|
+
}
|
|
92
|
+
// ----- Agent Key management (mostly used by the consumer-app UI;
|
|
93
|
+
// the CLI's `dope agent-key list/revoke` is the same surface). -----
|
|
94
|
+
async listAgentKeys(options = {}) {
|
|
95
|
+
return this.request('GET', this.withQuery('/agent/agent-keys', options));
|
|
96
|
+
}
|
|
97
|
+
async getAgentKey(agentKeyId) {
|
|
98
|
+
return this.request('GET', `/agent/agent-keys/${encodeURIComponent(agentKeyId)}`);
|
|
99
|
+
}
|
|
100
|
+
async revokeAgentKey(agentKeyId, reason) {
|
|
101
|
+
return this.request('POST', `/agent/agent-keys/${encodeURIComponent(agentKeyId)}/revoke`, reason ? { reason } : {});
|
|
102
|
+
}
|
|
103
|
+
// ----- Internals --------------------------------------------------------
|
|
104
|
+
withQuery(path, params) {
|
|
105
|
+
const entries = Object.entries(params).filter(([, v]) => v !== undefined && v !== null && v !== '');
|
|
106
|
+
if (entries.length === 0)
|
|
107
|
+
return path;
|
|
108
|
+
const qs = new URLSearchParams();
|
|
109
|
+
for (const [k, v] of entries)
|
|
110
|
+
qs.set(k, String(v));
|
|
111
|
+
return `${path}?${qs.toString()}`;
|
|
112
|
+
}
|
|
113
|
+
async request(method, pathWithQuery, body) {
|
|
114
|
+
const bodyString = body === undefined ? '' : JSON.stringify(body);
|
|
115
|
+
const headers = signedHeadersToObject((0, sign_js_1.signRequest)({
|
|
116
|
+
agentKeyId: this.credential.agent_key_id,
|
|
117
|
+
privateKeyHex: this.credential.private_key_hex,
|
|
118
|
+
method,
|
|
119
|
+
pathWithQuery,
|
|
120
|
+
body: bodyString,
|
|
121
|
+
}));
|
|
122
|
+
if (body !== undefined)
|
|
123
|
+
headers['Content-Type'] = 'application/json';
|
|
124
|
+
if (this.clientVersion)
|
|
125
|
+
headers['X-DOPE-Client-Version'] = this.clientVersion;
|
|
126
|
+
const url = `${this.baseUrl}${pathWithQuery}`;
|
|
127
|
+
const response = await this.fetchImpl(url, {
|
|
128
|
+
method,
|
|
129
|
+
headers,
|
|
130
|
+
body: body === undefined ? undefined : bodyString,
|
|
131
|
+
});
|
|
132
|
+
let parsed;
|
|
133
|
+
try {
|
|
134
|
+
parsed = await response.json();
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
parsed = await response.text().catch(() => '');
|
|
138
|
+
}
|
|
139
|
+
if (!response.ok) {
|
|
140
|
+
const code = parsed?.error_code ?? 'SERVICE_UNAVAILABLE';
|
|
141
|
+
throw new DopeAgentError(code, response.status, parsed);
|
|
142
|
+
}
|
|
143
|
+
return parsed;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.DopeClient = DopeClient;
|
|
147
|
+
/**
|
|
148
|
+
* Login-flow client. These endpoints are NOT signed (the CLI has no
|
|
149
|
+
* credential yet) and don't need an AgentCredential.
|
|
150
|
+
*/
|
|
151
|
+
class DopeLoginClient {
|
|
152
|
+
baseUrl;
|
|
153
|
+
fetchImpl;
|
|
154
|
+
constructor(options) {
|
|
155
|
+
this.baseUrl = options.baseUrl.replace(/\/$/, '');
|
|
156
|
+
this.fetchImpl = options.fetch ?? globalThis.fetch;
|
|
157
|
+
}
|
|
158
|
+
async init(input) {
|
|
159
|
+
return this.unsignedRequest('POST', '/agent/login/init', input);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Poll for completion. Returns { ok: true } once the user has approved
|
|
163
|
+
* in the browser. While pending, throws DopeAgentError with
|
|
164
|
+
* code='AUTHORIZATION_PENDING' (HTTP 202); CLI should sleep and retry.
|
|
165
|
+
*/
|
|
166
|
+
async exchange(deviceCode) {
|
|
167
|
+
return this.unsignedRequest('POST', '/agent/login/exchange', {
|
|
168
|
+
device_code: deviceCode,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
async unsignedRequest(method, path, body) {
|
|
172
|
+
const response = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
173
|
+
method,
|
|
174
|
+
headers: { 'Content-Type': 'application/json' },
|
|
175
|
+
body: JSON.stringify(body),
|
|
176
|
+
});
|
|
177
|
+
let parsed;
|
|
178
|
+
try {
|
|
179
|
+
parsed = await response.json();
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
parsed = await response.text().catch(() => '');
|
|
183
|
+
}
|
|
184
|
+
if (!response.ok) {
|
|
185
|
+
const code = parsed?.error_code ?? 'SERVICE_UNAVAILABLE';
|
|
186
|
+
throw new DopeAgentError(code, response.status, parsed);
|
|
187
|
+
}
|
|
188
|
+
return parsed;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.DopeLoginClient = DopeLoginClient;
|
|
192
|
+
function signedHeadersToObject(h) {
|
|
193
|
+
return {
|
|
194
|
+
'X-Agent-Key-Id': h['X-Agent-Key-Id'],
|
|
195
|
+
'X-Agent-Key-Timestamp': h['X-Agent-Key-Timestamp'],
|
|
196
|
+
'X-Agent-Key-Nonce': h['X-Agent-Key-Nonce'],
|
|
197
|
+
'X-Agent-Key-Signature': h['X-Agent-Key-Signature'],
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC,EAAE;AACF,uEAAuE;AACvE,qEAAqE;AACrE,oEAAoE;AACpE,mBAAmB;AACnB,EAAE;AACF,0EAA0E;AAC1E,iEAAiE;AACjE,+CAA+C;AAC/C,EAAE;AACF,+BAA+B;AAC/B,uEAAuE;AACvE,8EAA8E;AAC9E,0EAA0E;AAC1E,sEAAsE;;;AAEtE,uCAA4D;AAiC5D,iEAAiE;AACjE,MAAa,cAAe,SAAQ,KAAK;IACvC,uDAAuD;IACvD,IAAI,CAAe;IACnB,wBAAwB;IACxB,MAAM,CAAS;IACf,6CAA6C;IAC7C,IAAI,CAAU;IACd,YAAY,IAAkB,EAAE,MAAc,EAAE,IAAa;QAC3D,KAAK,CAAC,GAAG,IAAI,UAAU,MAAM,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAdD,wCAcC;AA6CD,MAAa,UAAU;IACJ,OAAO,CAAS;IAChB,UAAU,CAAkB;IAC5B,SAAS,CAAe;IACxB,aAAa,CAAqB;IAEnD,YAAY,OAA0B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,UAA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from './client.js';
|
|
2
|
+
export type { DopeClientOptions, ListStacksOptions, SearchMarketsOptions, QuoteInput, CandidatesInput, ActivateInput, ActivateSubmitInput, } from './client.js';
|
|
3
|
+
export { signRequest, generateP256Keypair } from './sign.js';
|
|
4
|
+
export type { SignedHeaders, SignRequestArgs } from './sign.js';
|
|
5
|
+
export { signSolanaTransaction } from './turnkey.js';
|
|
6
|
+
export type { AgentTurnkeyCredential, SignSolanaTxArgs } from './turnkey.js';
|
|
7
|
+
export type { AccountSummary, ActivateBuildResponse, ActivateSubmitResponse, ActivationTxResponse, AgentCredential, AgentKeyStatus, AgentKeySummary, ApiErrorCode, BalanceResponse, BalanceUsdc, CandidatesResponse, LoginExchangeResponse, LoginInitInput, LoginInitResponse, MarketDetail, MarketSummary, Permission, QuoteResponse, StackDetail, StackStatus, StackSummary, } from './types.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1E,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,aAAa,EACb,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC7D,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE7E,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,eAAe,EACf,YAAY,EACZ,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,UAAU,EACV,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @dopemarkets/agent-client — public API.
|
|
3
|
+
//
|
|
4
|
+
// Most callers want `DopeClient` for everyday API calls and
|
|
5
|
+
// `DopeLoginClient` for the one-time `dope login` flow. The
|
|
6
|
+
// `signSolanaTransaction` helper lives in its own module because it
|
|
7
|
+
// pulls in the Turnkey browser SDK and not every caller needs it.
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.signSolanaTransaction = exports.generateP256Keypair = exports.signRequest = exports.DopeAgentError = exports.DopeLoginClient = exports.DopeClient = void 0;
|
|
10
|
+
var client_js_1 = require("./client.js");
|
|
11
|
+
Object.defineProperty(exports, "DopeClient", { enumerable: true, get: function () { return client_js_1.DopeClient; } });
|
|
12
|
+
Object.defineProperty(exports, "DopeLoginClient", { enumerable: true, get: function () { return client_js_1.DopeLoginClient; } });
|
|
13
|
+
Object.defineProperty(exports, "DopeAgentError", { enumerable: true, get: function () { return client_js_1.DopeAgentError; } });
|
|
14
|
+
var sign_js_1 = require("./sign.js");
|
|
15
|
+
Object.defineProperty(exports, "signRequest", { enumerable: true, get: function () { return sign_js_1.signRequest; } });
|
|
16
|
+
Object.defineProperty(exports, "generateP256Keypair", { enumerable: true, get: function () { return sign_js_1.generateP256Keypair; } });
|
|
17
|
+
var turnkey_js_1 = require("./turnkey.js");
|
|
18
|
+
Object.defineProperty(exports, "signSolanaTransaction", { enumerable: true, get: function () { return turnkey_js_1.signSolanaTransaction; } });
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,EAAE;AACF,4DAA4D;AAC5D,4DAA4D;AAC5D,oEAAoE;AACpE,kEAAkE;;;AAElE,yCAA0E;AAAjE,uGAAA,UAAU,OAAA;AAAE,4GAAA,eAAe,OAAA;AAAE,2GAAA,cAAc,OAAA;AAWpD,qCAA6D;AAApD,sGAAA,WAAW,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AAGzC,2CAAqD;AAA5C,mHAAA,qBAAqB,OAAA"}
|
package/dist/sign.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface SignedHeaders {
|
|
2
|
+
'X-Agent-Key-Id': string;
|
|
3
|
+
'X-Agent-Key-Timestamp': string;
|
|
4
|
+
'X-Agent-Key-Nonce': string;
|
|
5
|
+
'X-Agent-Key-Signature': string;
|
|
6
|
+
}
|
|
7
|
+
export interface SignRequestArgs {
|
|
8
|
+
agentKeyId: string;
|
|
9
|
+
privateKeyHex: string;
|
|
10
|
+
method: string;
|
|
11
|
+
/** Path INCLUDING query string. e.g. `/agent/stacks?status=active`. */
|
|
12
|
+
pathWithQuery: string;
|
|
13
|
+
/** Request body as a string. Empty string for GET. JSON.stringify your body before passing. */
|
|
14
|
+
body: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Sign one request. Returns the four headers to attach.
|
|
18
|
+
*/
|
|
19
|
+
export declare function signRequest(args: SignRequestArgs): SignedHeaders;
|
|
20
|
+
/**
|
|
21
|
+
* Generate a fresh P-256 keypair. Used during `dope login` to create the
|
|
22
|
+
* Agent Key's local credential before the browser ceremony installs the
|
|
23
|
+
* matching public key on the user's Turnkey sub-org.
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateP256Keypair(): {
|
|
26
|
+
publicKeyHex: string;
|
|
27
|
+
privateKeyHex: string;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=sign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../src/sign.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB,EAAE,MAAM,CAAC;IAChC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,+FAA+F;IAC/F,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,aAAa,CAyBhE;AA+BD;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAOrF"}
|
package/dist/sign.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// P-256 ECDSA signing for /agent/* requests.
|
|
3
|
+
//
|
|
4
|
+
// The canonical signed string is:
|
|
5
|
+
//
|
|
6
|
+
// <METHOD>\n<PATH+QUERY>\n<TIMESTAMP>\n<NONCE>\n<sha256(body)_hex>
|
|
7
|
+
//
|
|
8
|
+
// Signature is raw r||s (64 bytes), hex-encoded (128 chars). Server-side
|
|
9
|
+
// verification lives in dope-backend/src/shared/agent_key_auth.js — keep
|
|
10
|
+
// the canonical-string definition synchronized there.
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.signRequest = signRequest;
|
|
46
|
+
exports.generateP256Keypair = generateP256Keypair;
|
|
47
|
+
const crypto = __importStar(require("node:crypto"));
|
|
48
|
+
/**
|
|
49
|
+
* Sign one request. Returns the four headers to attach.
|
|
50
|
+
*/
|
|
51
|
+
function signRequest(args) {
|
|
52
|
+
const timestamp = new Date().toISOString();
|
|
53
|
+
const nonce = crypto.randomBytes(16).toString('hex');
|
|
54
|
+
const bodyHash = crypto.createHash('sha256').update(args.body).digest('hex');
|
|
55
|
+
const canonical = [
|
|
56
|
+
args.method.toUpperCase(),
|
|
57
|
+
args.pathWithQuery,
|
|
58
|
+
timestamp,
|
|
59
|
+
nonce,
|
|
60
|
+
bodyHash,
|
|
61
|
+
].join('\n');
|
|
62
|
+
const keyObject = privateKeyObjectFromRawHex(args.privateKeyHex);
|
|
63
|
+
const signature = crypto.sign('sha256', Buffer.from(canonical, 'utf8'), { key: keyObject, dsaEncoding: 'ieee-p1363' });
|
|
64
|
+
return {
|
|
65
|
+
'X-Agent-Key-Id': args.agentKeyId,
|
|
66
|
+
'X-Agent-Key-Timestamp': timestamp,
|
|
67
|
+
'X-Agent-Key-Nonce': nonce,
|
|
68
|
+
'X-Agent-Key-Signature': signature.toString('hex'),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Build a P-256 KeyObject from a raw 32-byte hex private scalar.
|
|
73
|
+
*
|
|
74
|
+
* The scalar alone isn't a valid key handle — Node wants a JWK or DER —
|
|
75
|
+
* so we reconstruct the public coords via ECDH and feed it through
|
|
76
|
+
* createPrivateKey({format:'jwk'}). The same convention the server uses
|
|
77
|
+
* to ingest the matching public key.
|
|
78
|
+
*/
|
|
79
|
+
function privateKeyObjectFromRawHex(privateKeyHex) {
|
|
80
|
+
if (privateKeyHex.length !== 64) {
|
|
81
|
+
throw new Error('private key must be 32 bytes (64 hex chars)');
|
|
82
|
+
}
|
|
83
|
+
const ecdh = crypto.createECDH('prime256v1');
|
|
84
|
+
ecdh.setPrivateKey(Buffer.from(privateKeyHex, 'hex'));
|
|
85
|
+
const publicKeyUncompressedHex = ecdh.getPublicKey('hex', 'uncompressed');
|
|
86
|
+
const xHex = publicKeyUncompressedHex.slice(2, 66);
|
|
87
|
+
const yHex = publicKeyUncompressedHex.slice(66);
|
|
88
|
+
return crypto.createPrivateKey({
|
|
89
|
+
key: {
|
|
90
|
+
kty: 'EC',
|
|
91
|
+
crv: 'P-256',
|
|
92
|
+
d: Buffer.from(privateKeyHex, 'hex').toString('base64url'),
|
|
93
|
+
x: Buffer.from(xHex, 'hex').toString('base64url'),
|
|
94
|
+
y: Buffer.from(yHex, 'hex').toString('base64url'),
|
|
95
|
+
},
|
|
96
|
+
format: 'jwk',
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Generate a fresh P-256 keypair. Used during `dope login` to create the
|
|
101
|
+
* Agent Key's local credential before the browser ceremony installs the
|
|
102
|
+
* matching public key on the user's Turnkey sub-org.
|
|
103
|
+
*/
|
|
104
|
+
function generateP256Keypair() {
|
|
105
|
+
const ecdh = crypto.createECDH('prime256v1');
|
|
106
|
+
ecdh.generateKeys();
|
|
107
|
+
return {
|
|
108
|
+
publicKeyHex: ecdh.getPublicKey('hex', 'compressed'),
|
|
109
|
+
privateKeyHex: ecdh.getPrivateKey('hex'),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=sign.js.map
|
package/dist/sign.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign.js","sourceRoot":"","sources":["../src/sign.ts"],"names":[],"mappings":";AAAA,6CAA6C;AAC7C,EAAE;AACF,kCAAkC;AAClC,EAAE;AACF,qEAAqE;AACrE,EAAE;AACF,yEAAyE;AACzE,yEAAyE;AACzE,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBtD,kCAyBC;AAoCD,kDAOC;AA1FD,oDAAsC;AAmBtC;;GAEG;AACH,SAAgB,WAAW,CAAC,IAAqB;IAC/C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7E,M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YACT,GAAG,EAAE,OAAO;YACZ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;YAC1D,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;YACjD,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;SAClD;QACD,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB;IACjC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC7C,IAAI,CAAC,YAAY,EAAE,CAAC;IACpB,OAAO;QACL,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC;QACpD,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;KACzC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential needed to sign a Solana transaction as the Agent Key's
|
|
3
|
+
* Turnkey authenticator. This is the Turnkey API key pair the CLI
|
|
4
|
+
* generated locally during `dope login` — distinct from the DOPE
|
|
5
|
+
* credential used to sign HTTP requests, though both happen to be
|
|
6
|
+
* P-256 keypairs.
|
|
7
|
+
*/
|
|
8
|
+
export interface AgentTurnkeyCredential {
|
|
9
|
+
/** The user's Turnkey sub-organization id. */
|
|
10
|
+
sub_org_id: string;
|
|
11
|
+
/** The user's primary Solana wallet address on Turnkey (what we sign with). */
|
|
12
|
+
wallet_address: string;
|
|
13
|
+
/** Turnkey API public key for the Agent Key authenticator. Compressed P-256 hex (66 chars). */
|
|
14
|
+
api_public_key_hex: string;
|
|
15
|
+
/** Turnkey API private key for the Agent Key authenticator. Raw P-256 scalar hex (64 chars). */
|
|
16
|
+
api_private_key_hex: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SignSolanaTxArgs {
|
|
19
|
+
credential: AgentTurnkeyCredential;
|
|
20
|
+
/** Unsigned Solana transaction (base64-encoded). */
|
|
21
|
+
unsignedTxBase64: string;
|
|
22
|
+
/** Override Turnkey API base URL (defaults to https://api.turnkey.com). */
|
|
23
|
+
apiBaseUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Sign an unsigned Solana transaction with the Agent Key's Turnkey
|
|
27
|
+
* authenticator. Returns the signed transaction as base64.
|
|
28
|
+
*
|
|
29
|
+
* Failures here typically come from Turnkey policy denials. The CLI
|
|
30
|
+
* should surface the error verbatim — the policy condition that
|
|
31
|
+
* matched the deny is the actionable signal.
|
|
32
|
+
*/
|
|
33
|
+
export declare function signSolanaTransaction(args: SignSolanaTxArgs): Promise<string>;
|
|
34
|
+
//# sourceMappingURL=turnkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turnkey.d.ts","sourceRoot":"","sources":["../src/turnkey.ts"],"names":[],"mappings":"AAyBA;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,cAAc,EAAE,MAAM,CAAC;IACvB,+FAA+F;IAC/F,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gGAAgG;IAChG,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,sBAAsB,CAAC;IACnC,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBnF"}
|
package/dist/turnkey.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Turnkey-side transaction signing for /agent/stacks/activate.
|
|
3
|
+
//
|
|
4
|
+
// Once the DOPE backend returns an unsigned Solana transaction (from
|
|
5
|
+
// `/agent/stacks/activations/:id/tx`), the CLI signs it with the Agent
|
|
6
|
+
// Key's installed Turnkey API-key authenticator. That authenticator was
|
|
7
|
+
// installed on the user's Turnkey sub-org during `dope login`; its
|
|
8
|
+
// private key lives in the OS keychain on the user's machine.
|
|
9
|
+
//
|
|
10
|
+
// This wrapper does ONE thing: produce a signed transaction (hex) given
|
|
11
|
+
// an unsigned transaction (base64 or hex) plus the Turnkey credential.
|
|
12
|
+
// Everything else — the `/activate` POST, the long-poll, the submit —
|
|
13
|
+
// is the responsibility of the DopeClient.
|
|
14
|
+
//
|
|
15
|
+
// The Turnkey policy template installed during `dope login` constrains
|
|
16
|
+
// what this signer can sign:
|
|
17
|
+
// - activity.type == 'ACTIVITY_TYPE_SIGN_TRANSACTION_V2'
|
|
18
|
+
// - wallet_account.address == <user's primary Solana address>
|
|
19
|
+
// - solana.tx.instructions.any(i, i.program_key == <DOPE_PROGRAM_ID>
|
|
20
|
+
// && i.parsed_instruction_data.instruction_name == 'execute_parlay')
|
|
21
|
+
// Plus a separate DENY for credential-management activities. Any
|
|
22
|
+
// unsigned tx that doesn't match this shape will be denied by Turnkey
|
|
23
|
+
// regardless of what the CLI tries to send.
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.signSolanaTransaction = signSolanaTransaction;
|
|
26
|
+
const sdk_server_1 = require("@turnkey/sdk-server");
|
|
27
|
+
const DEFAULT_TURNKEY_API_BASE = 'https://api.turnkey.com';
|
|
28
|
+
/**
|
|
29
|
+
* Sign an unsigned Solana transaction with the Agent Key's Turnkey
|
|
30
|
+
* authenticator. Returns the signed transaction as base64.
|
|
31
|
+
*
|
|
32
|
+
* Failures here typically come from Turnkey policy denials. The CLI
|
|
33
|
+
* should surface the error verbatim — the policy condition that
|
|
34
|
+
* matched the deny is the actionable signal.
|
|
35
|
+
*/
|
|
36
|
+
async function signSolanaTransaction(args) {
|
|
37
|
+
const turnkey = new sdk_server_1.Turnkey({
|
|
38
|
+
apiBaseUrl: args.apiBaseUrl ?? DEFAULT_TURNKEY_API_BASE,
|
|
39
|
+
defaultOrganizationId: args.credential.sub_org_id,
|
|
40
|
+
apiPublicKey: args.credential.api_public_key_hex,
|
|
41
|
+
apiPrivateKey: args.credential.api_private_key_hex,
|
|
42
|
+
});
|
|
43
|
+
const client = turnkey.apiClient();
|
|
44
|
+
const unsignedHex = Buffer.from(args.unsignedTxBase64, 'base64').toString('hex');
|
|
45
|
+
const result = await client.signTransaction({
|
|
46
|
+
organizationId: args.credential.sub_org_id,
|
|
47
|
+
signWith: args.credential.wallet_address,
|
|
48
|
+
type: 'TRANSACTION_TYPE_SOLANA',
|
|
49
|
+
unsignedTransaction: unsignedHex,
|
|
50
|
+
});
|
|
51
|
+
if (!result?.signedTransaction) {
|
|
52
|
+
throw new Error('Turnkey signTransaction returned no signedTransaction');
|
|
53
|
+
}
|
|
54
|
+
return Buffer.from(result.signedTransaction, 'hex').toString('base64');
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=turnkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turnkey.js","sourceRoot":"","sources":["../src/turnkey.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,wEAAwE;AACxE,mEAAmE;AACnE,8DAA8D;AAC9D,EAAE;AACF,wEAAwE;AACxE,uEAAuE;AACvE,sEAAsE;AACtE,2CAA2C;AAC3C,EAAE;AACF,uEAAuE;AACvE,6BAA6B;AAC7B,2DAA2D;AAC3D,gEAAgE;AAChE,uEAAuE;AACvE,0EAA0E;AAC1E,iEAAiE;AACjE,sEAAsE;AACtE,4CAA4C;;AAwC5C,sDAsBC;AA5DD,oDAA8C;AA4B9C,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAE3D;;;;;;;GAOG;AACI,KAAK,UAAU,qBAAqB,CAAC,IAAsB;IAChE,MAAM,OAAO,GAAG,IAAI,oBAAO,CAAC;QAC1B,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,wBAAwB;QACvD,qBAAqB,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU;QACjD,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,kBAAkB;QAChD,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB;KACnD,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEjF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC;QAC1C,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU;QAC1C,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc;QACxC,IAAI,EAAE,yBAAyB;QAC/B,mBAAmB,EAAE,WAAW;KACjC,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACzE,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
export type Permission = 'read:account' | 'read:markets' | 'read:stacks' | 'quote:stack' | 'activate:stack';
|
|
2
|
+
export type StackStatus = 'active' | 'pending' | 'resolved' | 'failed';
|
|
3
|
+
export type AgentKeyStatus = 'active' | 'expired' | 'revoked' | 'suspended';
|
|
4
|
+
/** Stable error codes returned by /agent/*. */
|
|
5
|
+
export type ApiErrorCode = 'AUTH_REQUIRED' | 'AGENT_KEY_INVALID' | 'AGENT_KEY_EXPIRED' | 'ACTIVATION_NOT_ALLOWED' | 'INVALID_REQUEST' | 'IDEMPOTENCY_REQUIRED' | 'LIMIT_EXCEEDED' | 'DAILY_LIMIT_EXCEEDED' | 'MAX_PREMIUM_EXCEEDED' | 'MAX_PAYOUT_EXCEEDED' | 'DAILY_QUOTE_QUOTA_EXCEEDED' | 'INSUFFICIENT_BALANCE' | 'MARKET_NOT_FOUND' | 'STACK_NOT_FOUND' | 'AGENT_KEY_NOT_FOUND' | 'ACCOUNT_NOT_FOUND' | 'STACK_UNAVAILABLE' | 'QUOTE_EXPIRED' | 'QUOTE_NOT_FOUND' | 'ACTIVATION_FAILED' | 'ACTIVATION_NOT_FOUND' | 'TRANSACTION_PENDING' | 'RATE_LIMITED' | 'SERVICE_UNAVAILABLE' | 'LOGIN_SESSION_INVALID' | 'LOGIN_SESSION_EXPIRED' | 'AUTHORIZATION_PENDING' | 'LOGIN_DENIED' | 'TOO_MANY_LEGS' | 'PERMISSION_DENIED' | string;
|
|
6
|
+
export interface AccountSummary {
|
|
7
|
+
ok: true;
|
|
8
|
+
account: {
|
|
9
|
+
wallet_pubkey: string;
|
|
10
|
+
created_at: string;
|
|
11
|
+
status: 'active';
|
|
12
|
+
};
|
|
13
|
+
agent_key: {
|
|
14
|
+
agent_key_id: string;
|
|
15
|
+
permissions: Permission[];
|
|
16
|
+
expires_at: string | null;
|
|
17
|
+
};
|
|
18
|
+
balance: BalanceUsdc;
|
|
19
|
+
stacks: {
|
|
20
|
+
active: number;
|
|
21
|
+
pending: number;
|
|
22
|
+
resolved: number;
|
|
23
|
+
failed: number;
|
|
24
|
+
total: number;
|
|
25
|
+
};
|
|
26
|
+
limits: {
|
|
27
|
+
max_premium_usdc: string | null;
|
|
28
|
+
max_daily_premium_usdc: string | null;
|
|
29
|
+
max_payout_per_stack_usdc: string | null;
|
|
30
|
+
daily_premium_remaining_usdc: string | null;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface BalanceUsdc {
|
|
34
|
+
available_usdc: string;
|
|
35
|
+
reserved_usdc: string;
|
|
36
|
+
committed_usdc: string;
|
|
37
|
+
total_usdc: string;
|
|
38
|
+
}
|
|
39
|
+
export interface BalanceResponse {
|
|
40
|
+
ok: true;
|
|
41
|
+
wallet_pubkey: string;
|
|
42
|
+
balance: BalanceUsdc;
|
|
43
|
+
}
|
|
44
|
+
export interface StackSummary {
|
|
45
|
+
stack_id: string;
|
|
46
|
+
title: string;
|
|
47
|
+
status: string;
|
|
48
|
+
leg_count: number;
|
|
49
|
+
premium_usdc: string | null;
|
|
50
|
+
max_payout_usdc: string | null;
|
|
51
|
+
multiplier: string | null;
|
|
52
|
+
outcome: string | null;
|
|
53
|
+
created_at: string;
|
|
54
|
+
activated_at: string | null;
|
|
55
|
+
resolved_at: string | null;
|
|
56
|
+
transaction_signature: string | null;
|
|
57
|
+
}
|
|
58
|
+
export interface StackDetail extends StackSummary {
|
|
59
|
+
legs: Array<{
|
|
60
|
+
leg_id: number;
|
|
61
|
+
market_id: string;
|
|
62
|
+
outcome: string;
|
|
63
|
+
title: string | null;
|
|
64
|
+
close_time: string | null;
|
|
65
|
+
status: string;
|
|
66
|
+
resolved: boolean;
|
|
67
|
+
resolution: string | null;
|
|
68
|
+
resolved_at: string | null;
|
|
69
|
+
}>;
|
|
70
|
+
transaction_signatures: {
|
|
71
|
+
activation: string | null;
|
|
72
|
+
settlement: string | null;
|
|
73
|
+
cash_out: string | null;
|
|
74
|
+
};
|
|
75
|
+
cash_out_amount_usdc: string | null;
|
|
76
|
+
settlement_reason: string | null;
|
|
77
|
+
early_settled: boolean;
|
|
78
|
+
pda: string | null;
|
|
79
|
+
}
|
|
80
|
+
export interface MarketSummary {
|
|
81
|
+
market_id: string;
|
|
82
|
+
venue: 'polymarket';
|
|
83
|
+
title: string;
|
|
84
|
+
description: string | null;
|
|
85
|
+
outcomes: string[];
|
|
86
|
+
price: string | null;
|
|
87
|
+
bid: string | null;
|
|
88
|
+
ask: string | null;
|
|
89
|
+
spread: string | null;
|
|
90
|
+
liquidity_usdc: string;
|
|
91
|
+
volume_usdc: string;
|
|
92
|
+
volume_24h_usdc: string;
|
|
93
|
+
close_time: string | null;
|
|
94
|
+
category: string | null;
|
|
95
|
+
eligible: boolean;
|
|
96
|
+
source_url: string | null;
|
|
97
|
+
}
|
|
98
|
+
export interface MarketDetail extends MarketSummary {
|
|
99
|
+
resolution_status: string;
|
|
100
|
+
resolution_outcome: string | null;
|
|
101
|
+
}
|
|
102
|
+
export interface QuoteResponse {
|
|
103
|
+
status: 'quoted';
|
|
104
|
+
quote_id: string;
|
|
105
|
+
premium_usdc: string;
|
|
106
|
+
max_payout_usdc: string;
|
|
107
|
+
multiplier: string;
|
|
108
|
+
expires_at: string;
|
|
109
|
+
legs: Array<{
|
|
110
|
+
market_id: string;
|
|
111
|
+
outcome: string;
|
|
112
|
+
}>;
|
|
113
|
+
activation_allowed_by_agent_key: boolean;
|
|
114
|
+
disclosure_text: string;
|
|
115
|
+
}
|
|
116
|
+
export interface CandidatesResponse {
|
|
117
|
+
ok: true;
|
|
118
|
+
candidates: Array<{
|
|
119
|
+
candidate_id: string;
|
|
120
|
+
title: string;
|
|
121
|
+
legs: Array<{
|
|
122
|
+
market_id: string;
|
|
123
|
+
outcome: string;
|
|
124
|
+
title: string;
|
|
125
|
+
}>;
|
|
126
|
+
indicative_multiplier: string;
|
|
127
|
+
indicative_premium_usdc: string;
|
|
128
|
+
indicative_max_payout_usdc: string;
|
|
129
|
+
quote_required: true;
|
|
130
|
+
blurb: string;
|
|
131
|
+
}>;
|
|
132
|
+
}
|
|
133
|
+
export interface ActivateBuildResponse {
|
|
134
|
+
ok: true;
|
|
135
|
+
status: 'pending_signature';
|
|
136
|
+
stack_id: string;
|
|
137
|
+
activation_id: string;
|
|
138
|
+
expires_at: string;
|
|
139
|
+
poll_interval_seconds: number;
|
|
140
|
+
cached?: boolean;
|
|
141
|
+
}
|
|
142
|
+
export interface ActivationTxResponse {
|
|
143
|
+
ok: true;
|
|
144
|
+
status: 'PENDING_SIGNATURE';
|
|
145
|
+
unsigned_tx_base64: string;
|
|
146
|
+
expires_at: string;
|
|
147
|
+
}
|
|
148
|
+
export interface ActivateSubmitResponse {
|
|
149
|
+
ok: true;
|
|
150
|
+
status: 'activated';
|
|
151
|
+
stack_id: string;
|
|
152
|
+
transaction_signature: string | null;
|
|
153
|
+
activated_at: string;
|
|
154
|
+
}
|
|
155
|
+
export interface AgentKeySummary {
|
|
156
|
+
agent_key_id: string;
|
|
157
|
+
name: string;
|
|
158
|
+
status: AgentKeyStatus;
|
|
159
|
+
permissions: Permission[];
|
|
160
|
+
public_key_fingerprint: string;
|
|
161
|
+
client_type: string;
|
|
162
|
+
limits: {
|
|
163
|
+
max_premium_usdc: string | null;
|
|
164
|
+
max_daily_premium_usdc: string | null;
|
|
165
|
+
max_payout_per_stack_usdc: string | null;
|
|
166
|
+
};
|
|
167
|
+
daily_usage: null | {
|
|
168
|
+
date: string;
|
|
169
|
+
premium_activated_usdc: string;
|
|
170
|
+
activation_count: number;
|
|
171
|
+
quote_count: number;
|
|
172
|
+
search_count: number;
|
|
173
|
+
failed_quote_count: number;
|
|
174
|
+
failed_activation_count: number;
|
|
175
|
+
};
|
|
176
|
+
created_at: string;
|
|
177
|
+
expires_at: string;
|
|
178
|
+
last_used_at: string | null;
|
|
179
|
+
revoked_at: string | null;
|
|
180
|
+
}
|
|
181
|
+
/** Login-flow types (used during `dope login` before Agent Key exists). */
|
|
182
|
+
export interface LoginInitInput {
|
|
183
|
+
name: string;
|
|
184
|
+
public_key_hex: string;
|
|
185
|
+
permissions: Permission[];
|
|
186
|
+
max_premium_usdc?: number;
|
|
187
|
+
max_daily_premium_usdc?: number;
|
|
188
|
+
max_payout_per_stack_usdc?: number;
|
|
189
|
+
expires_days: number;
|
|
190
|
+
client_type?: 'cli' | 'mcp' | 'unknown';
|
|
191
|
+
}
|
|
192
|
+
export interface LoginInitResponse {
|
|
193
|
+
ok: true;
|
|
194
|
+
device_code: string;
|
|
195
|
+
user_code: string;
|
|
196
|
+
verification_url: string;
|
|
197
|
+
expires_in_seconds: number;
|
|
198
|
+
poll_interval_seconds: number;
|
|
199
|
+
}
|
|
200
|
+
export interface LoginExchangeResponse {
|
|
201
|
+
ok: true;
|
|
202
|
+
status: 'authorized';
|
|
203
|
+
agent_key_id: string;
|
|
204
|
+
wallet_pubkey: string;
|
|
205
|
+
/**
|
|
206
|
+
* The user's Turnkey sub-organization id. Returned by the backend once
|
|
207
|
+
* the session is authorized so the CLI can persist it alongside the
|
|
208
|
+
* Agent Key credential and use it (with `wallet_pubkey` as the Solana
|
|
209
|
+
* wallet address) for `signSolanaTransaction` during stack activation.
|
|
210
|
+
*
|
|
211
|
+
* Theoretically nullable for non-passkey accounts, but in practice the
|
|
212
|
+
* agent-login approval path only succeeds for passkey sub-orgs.
|
|
213
|
+
*/
|
|
214
|
+
sub_org_id: string | null;
|
|
215
|
+
}
|
|
216
|
+
/** Credential the client signs requests with. Persisted by the CLI in the OS keychain. */
|
|
217
|
+
export interface AgentCredential {
|
|
218
|
+
agent_key_id: string;
|
|
219
|
+
wallet_pubkey: string;
|
|
220
|
+
/** P-256 compressed public key, hex. 66 chars. */
|
|
221
|
+
public_key_hex: string;
|
|
222
|
+
/** P-256 raw private scalar, hex. 64 chars. */
|
|
223
|
+
private_key_hex: string;
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,cAAc,GACd,aAAa,GACb,aAAa,GACb,gBAAgB,CAAC;AAErB,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,SAAS,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IAChC,EAAE,EAAE,IAAI,CAAC;IACT,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,EAAE,YAAY,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,0FAA0F;AAC1F,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,cAAc,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,eAAe,EAAE,MAAM,CAAC;CACzB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Response types for the DOPE Agent Mode HTTP API.
|
|
3
|
+
//
|
|
4
|
+
// These mirror the JSON shapes returned by /agent/* — sanitized, USDC
|
|
5
|
+
// strings, no internal pricing fields. See dope-backend's agent_*.js
|
|
6
|
+
// modules for the source of truth.
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,mCAAmC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dopemarkets/agent-client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Typed TypeScript client for the DOPE Agent Mode HTTP API. Handles request signing and Turnkey-side transaction signing.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -p tsconfig.json",
|
|
9
|
+
"clean": "rm -rf dist",
|
|
10
|
+
"smoke": "node --import tsx src/smoke.ts"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@turnkey/sdk-server": "^5.0.1"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^22.10.5",
|
|
17
|
+
"tsx": "^4.19.2",
|
|
18
|
+
"typescript": "^5.7.2"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=22.0.0"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
}
|
|
30
|
+
}
|