@blindmarket/sdk 0.1.5 → 0.1.6
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/index.d.ts +1 -11
- package/dist/index.js +1 -28
- package/package.json +1 -1
- package/src/index.ts +8 -30
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
2
|
export interface BlindMarketConfig {
|
|
3
3
|
apiBase?: string;
|
|
4
4
|
apiKey: string;
|
|
@@ -79,15 +79,5 @@ export declare class BlindMarket {
|
|
|
79
79
|
* List open tasks.
|
|
80
80
|
*/
|
|
81
81
|
listTasks(limit?: number): Promise<object[]>;
|
|
82
|
-
/**
|
|
83
|
-
* Authenticate with a wallet and return a JWT.
|
|
84
|
-
* Use this to get the apiKey for the constructor.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* const wallet = new ethers.Wallet(privateKey);
|
|
88
|
-
* const apiKey = await BlindMarket.authenticate(wallet, 'http://localhost:3001');
|
|
89
|
-
* const bb = new BlindMarket({ apiKey });
|
|
90
|
-
*/
|
|
91
|
-
static authenticate(wallet: Wallet, apiBase?: string): Promise<string>;
|
|
92
82
|
}
|
|
93
83
|
export { ethers };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export class BlindMarket {
|
|
|
3
3
|
apiBase;
|
|
4
4
|
apiKey;
|
|
5
5
|
constructor(config) {
|
|
6
|
-
this.apiBase = config.apiBase ?? '
|
|
6
|
+
this.apiBase = config.apiBase ?? 'https://api.blindmarket.xyz';
|
|
7
7
|
this.apiKey = config.apiKey;
|
|
8
8
|
}
|
|
9
9
|
async req(method, path, body) {
|
|
@@ -72,32 +72,5 @@ export class BlindMarket {
|
|
|
72
72
|
const { tasks } = await this.req('GET', `/api/v1/tasks?limit=${limit}`);
|
|
73
73
|
return tasks;
|
|
74
74
|
}
|
|
75
|
-
// ── Auth helper ───────────────────────────────────────────────────────────
|
|
76
|
-
/**
|
|
77
|
-
* Authenticate with a wallet and return a JWT.
|
|
78
|
-
* Use this to get the apiKey for the constructor.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* const wallet = new ethers.Wallet(privateKey);
|
|
82
|
-
* const apiKey = await BlindMarket.authenticate(wallet, 'http://localhost:3001');
|
|
83
|
-
* const bb = new BlindMarket({ apiKey });
|
|
84
|
-
*/
|
|
85
|
-
static async authenticate(wallet, apiBase = 'http://localhost:3001') {
|
|
86
|
-
const nonceRes = await fetch(`${apiBase}/api/v1/auth/nonce`, {
|
|
87
|
-
method: 'POST',
|
|
88
|
-
headers: { 'Content-Type': 'application/json' },
|
|
89
|
-
body: JSON.stringify({ address: wallet.address }),
|
|
90
|
-
});
|
|
91
|
-
const { data: { nonce } } = await nonceRes.json();
|
|
92
|
-
const message = `Sign this message to authenticate with BlindMarket.\n\nNonce: ${nonce}`;
|
|
93
|
-
const signature = await wallet.signMessage(message);
|
|
94
|
-
const verifyRes = await fetch(`${apiBase}/api/v1/auth/verify`, {
|
|
95
|
-
method: 'POST',
|
|
96
|
-
headers: { 'Content-Type': 'application/json' },
|
|
97
|
-
body: JSON.stringify({ address: wallet.address, signature }),
|
|
98
|
-
});
|
|
99
|
-
const { data: { token } } = await verifyRes.json();
|
|
100
|
-
return token;
|
|
101
|
-
}
|
|
102
75
|
}
|
|
103
76
|
export { ethers };
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
2
|
|
|
3
3
|
export interface BlindMarketConfig {
|
|
4
4
|
apiBase?: string;
|
|
@@ -32,7 +32,7 @@ export class BlindMarket {
|
|
|
32
32
|
private apiKey: string;
|
|
33
33
|
|
|
34
34
|
constructor(config: BlindMarketConfig) {
|
|
35
|
-
this.apiBase = config.apiBase ?? '
|
|
35
|
+
this.apiBase = config.apiBase ?? 'https://api.blindmarket.xyz';
|
|
36
36
|
this.apiKey = config.apiKey;
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -115,34 +115,12 @@ export class BlindMarket {
|
|
|
115
115
|
return tasks;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
* @example
|
|
125
|
-
* const wallet = new ethers.Wallet(privateKey);
|
|
126
|
-
* const apiKey = await BlindMarket.authenticate(wallet, 'http://localhost:3001');
|
|
127
|
-
* const bb = new BlindMarket({ apiKey });
|
|
128
|
-
*/
|
|
129
|
-
static async authenticate(wallet: Wallet, apiBase = 'http://localhost:3001'): Promise<string> {
|
|
130
|
-
const nonceRes = await fetch(`${apiBase}/api/v1/auth/nonce`, {
|
|
131
|
-
method: 'POST',
|
|
132
|
-
headers: { 'Content-Type': 'application/json' },
|
|
133
|
-
body: JSON.stringify({ address: wallet.address }),
|
|
134
|
-
});
|
|
135
|
-
const { data: { nonce } } = await nonceRes.json() as { data: { nonce: string } };
|
|
136
|
-
const message = `Sign this message to authenticate with BlindMarket.\n\nNonce: ${nonce}`;
|
|
137
|
-
const signature = await wallet.signMessage(message);
|
|
138
|
-
const verifyRes = await fetch(`${apiBase}/api/v1/auth/verify`, {
|
|
139
|
-
method: 'POST',
|
|
140
|
-
headers: { 'Content-Type': 'application/json' },
|
|
141
|
-
body: JSON.stringify({ address: wallet.address, signature }),
|
|
142
|
-
});
|
|
143
|
-
const { data: { token } } = await verifyRes.json() as { data: { token: string } };
|
|
144
|
-
return token;
|
|
145
|
-
}
|
|
118
|
+
// Auth: there's no SDK-side authenticate() anymore. Browser users
|
|
119
|
+
// sign in via Privy; agents obtain an API key one of two ways:
|
|
120
|
+
// 1. Ask the operator for the shared AGENT_API_KEY (set on the backend)
|
|
121
|
+
// 2. Run `blind register --name <agent>` from @blindmarket/cli to mint
|
|
122
|
+
// a per-agent token via the device-flow registration endpoint
|
|
123
|
+
// Pass the resulting key to `new BlindMarket({ apiKey })`.
|
|
146
124
|
}
|
|
147
125
|
|
|
148
126
|
export { ethers };
|