@stamn/sdk 0.1.0-alpha.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/README.md +42 -0
- package/dist/index.d.ts +210 -0
- package/dist/index.js +303 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @stamn/sdk
|
|
2
|
+
|
|
3
|
+
Stamn TypeScript SDK.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @stamn/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { StamnClient } from "@stamn/sdk";
|
|
15
|
+
|
|
16
|
+
const client = new StamnClient({ serverUrl: "https://api.stamn.com" });
|
|
17
|
+
|
|
18
|
+
const flow = await client.auth.initiateDeviceFlow();
|
|
19
|
+
console.log(`Open ${flow.verificationUri} and enter code: ${flow.userCode}`);
|
|
20
|
+
|
|
21
|
+
const apiKey = await client.auth.pollForApproval(flow.deviceCode);
|
|
22
|
+
client.setApiKey(apiKey);
|
|
23
|
+
|
|
24
|
+
const agent = await client.agents.create({ name: "my-agent" });
|
|
25
|
+
|
|
26
|
+
const health = await client.health.check();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Retry
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
const client = new StamnClient({
|
|
33
|
+
serverUrl: "https://api.stamn.com",
|
|
34
|
+
retry: { maxRetries: 3, initialDelayMs: 500 },
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Retries on 5xx, 429, and network errors with exponential backoff.
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
interface Requestable {
|
|
2
|
+
request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
3
|
+
}
|
|
4
|
+
interface RetryOptions {
|
|
5
|
+
maxRetries?: number;
|
|
6
|
+
initialDelayMs?: number;
|
|
7
|
+
backoffMultiplier?: number;
|
|
8
|
+
maxDelayMs?: number;
|
|
9
|
+
}
|
|
10
|
+
interface StamnClientOptions {
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
retry?: RetryOptions;
|
|
13
|
+
}
|
|
14
|
+
interface DeviceFlowData {
|
|
15
|
+
deviceCode: string;
|
|
16
|
+
userCode: string;
|
|
17
|
+
verificationUri: string;
|
|
18
|
+
expiresIn: number;
|
|
19
|
+
}
|
|
20
|
+
interface DeviceFlowStatus {
|
|
21
|
+
status: string;
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
}
|
|
24
|
+
interface ParticipantSettings {
|
|
25
|
+
requireApprovalAbove: number;
|
|
26
|
+
allowedVendors: string[];
|
|
27
|
+
dailySpendLimit?: number;
|
|
28
|
+
autoPauseTriggers: {
|
|
29
|
+
balanceBelow: number;
|
|
30
|
+
dailySpendExceeded: boolean;
|
|
31
|
+
anomalyDetected: boolean;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
interface Participant {
|
|
35
|
+
id: string;
|
|
36
|
+
type: 'agent' | 'human';
|
|
37
|
+
name: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
walletAddress: string;
|
|
41
|
+
chainId: number;
|
|
42
|
+
walletType: string;
|
|
43
|
+
settings: ParticipantSettings;
|
|
44
|
+
status: 'active' | 'paused' | 'frozen';
|
|
45
|
+
pluginVersion?: string;
|
|
46
|
+
lastX?: number;
|
|
47
|
+
lastY?: number;
|
|
48
|
+
lastSeenAt?: string;
|
|
49
|
+
createdAt: string;
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
}
|
|
52
|
+
interface BalanceResponse {
|
|
53
|
+
agentId: string;
|
|
54
|
+
balanceCents: string;
|
|
55
|
+
currency: string;
|
|
56
|
+
}
|
|
57
|
+
interface OnchainBalanceResponse {
|
|
58
|
+
agentId: string;
|
|
59
|
+
walletAddress: string;
|
|
60
|
+
onchainBalance: string;
|
|
61
|
+
token: string;
|
|
62
|
+
}
|
|
63
|
+
interface LedgerEntry {
|
|
64
|
+
id: string;
|
|
65
|
+
participantId: string;
|
|
66
|
+
type: string;
|
|
67
|
+
amountCents: number;
|
|
68
|
+
currency: string;
|
|
69
|
+
decimals: number;
|
|
70
|
+
direction: 'credit' | 'debit';
|
|
71
|
+
rail: string;
|
|
72
|
+
transactionHash?: string;
|
|
73
|
+
blockNumber?: number;
|
|
74
|
+
confirmations?: number;
|
|
75
|
+
counterpartyAddress?: string;
|
|
76
|
+
counterpartyVendor?: string;
|
|
77
|
+
description: string;
|
|
78
|
+
category: string;
|
|
79
|
+
status: string;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
confirmedAt?: string;
|
|
82
|
+
}
|
|
83
|
+
interface ApiKeyCreateResponse {
|
|
84
|
+
id: string;
|
|
85
|
+
key: string;
|
|
86
|
+
prefix: string;
|
|
87
|
+
label?: string;
|
|
88
|
+
createdAt: string;
|
|
89
|
+
}
|
|
90
|
+
interface ApiKeySummary {
|
|
91
|
+
id: string;
|
|
92
|
+
prefix: string;
|
|
93
|
+
label?: string;
|
|
94
|
+
lastUsedAt?: string;
|
|
95
|
+
expiresAt?: string;
|
|
96
|
+
createdAt: string;
|
|
97
|
+
}
|
|
98
|
+
interface DirectoryServiceEntry {
|
|
99
|
+
serviceTag: string;
|
|
100
|
+
description: string;
|
|
101
|
+
priceCents: number;
|
|
102
|
+
}
|
|
103
|
+
interface DirectoryEntry {
|
|
104
|
+
participantId: string;
|
|
105
|
+
name: string;
|
|
106
|
+
walletAddress: string;
|
|
107
|
+
services: DirectoryServiceEntry[];
|
|
108
|
+
}
|
|
109
|
+
interface DirectoryResponse {
|
|
110
|
+
participants: DirectoryEntry[];
|
|
111
|
+
total: number;
|
|
112
|
+
}
|
|
113
|
+
interface LeaderboardEntry {
|
|
114
|
+
rank: number;
|
|
115
|
+
displayId: string;
|
|
116
|
+
totalAgents: number;
|
|
117
|
+
totalTransactions: number;
|
|
118
|
+
totalVolumeCents: string;
|
|
119
|
+
}
|
|
120
|
+
interface HealthCheckResult {
|
|
121
|
+
ok: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare abstract class Resource {
|
|
125
|
+
protected readonly client: Requestable;
|
|
126
|
+
constructor(client: Requestable);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare class AuthResource extends Resource {
|
|
130
|
+
initiateDeviceFlow(): Promise<DeviceFlowData>;
|
|
131
|
+
getDeviceFlowStatus(deviceCode: string): Promise<DeviceFlowStatus>;
|
|
132
|
+
pollForApproval(deviceCode: string, options?: {
|
|
133
|
+
pollIntervalMs?: number;
|
|
134
|
+
timeoutMs?: number;
|
|
135
|
+
}): Promise<string>;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
declare class AgentsResource extends Resource {
|
|
139
|
+
create(options?: {
|
|
140
|
+
name?: string;
|
|
141
|
+
description?: string;
|
|
142
|
+
}): Promise<Participant>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
declare class ParticipantsResource extends Resource {
|
|
146
|
+
create(options?: {
|
|
147
|
+
name?: string;
|
|
148
|
+
description?: string;
|
|
149
|
+
}): Promise<Participant>;
|
|
150
|
+
list(): Promise<Participant[]>;
|
|
151
|
+
get(participantId: string): Promise<Participant>;
|
|
152
|
+
update(participantId: string, data: {
|
|
153
|
+
settings?: Partial<ParticipantSettings>;
|
|
154
|
+
status?: 'active' | 'paused' | 'frozen';
|
|
155
|
+
}): Promise<Participant>;
|
|
156
|
+
getBalance(participantId: string): Promise<BalanceResponse>;
|
|
157
|
+
getOnchainBalance(participantId: string): Promise<OnchainBalanceResponse>;
|
|
158
|
+
getLedgerEntries(participantId: string): Promise<LedgerEntry[]>;
|
|
159
|
+
deposit(participantId: string, data: {
|
|
160
|
+
amountCents: number;
|
|
161
|
+
}): Promise<LedgerEntry>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
declare class ApiKeysResource extends Resource {
|
|
165
|
+
create(): Promise<ApiKeyCreateResponse>;
|
|
166
|
+
list(): Promise<ApiKeySummary[]>;
|
|
167
|
+
revoke(id: string): Promise<void>;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare class DirectoryResource extends Resource {
|
|
171
|
+
list(options?: {
|
|
172
|
+
serviceTag?: string;
|
|
173
|
+
name?: string;
|
|
174
|
+
}): Promise<DirectoryResponse>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
declare class LeaderboardResource extends Resource {
|
|
178
|
+
get(): Promise<LeaderboardEntry[]>;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
declare class HealthResource extends Resource {
|
|
182
|
+
check(): Promise<HealthCheckResult>;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
declare class StamnApiError extends Error {
|
|
186
|
+
readonly status: number;
|
|
187
|
+
constructor(message: string, status: number);
|
|
188
|
+
}
|
|
189
|
+
declare class StamnClient implements Requestable {
|
|
190
|
+
private readonly serverUrl;
|
|
191
|
+
private apiKey?;
|
|
192
|
+
private retryOptions;
|
|
193
|
+
readonly auth: AuthResource;
|
|
194
|
+
readonly agents: AgentsResource;
|
|
195
|
+
readonly participants: ParticipantsResource;
|
|
196
|
+
readonly apiKeys: ApiKeysResource;
|
|
197
|
+
readonly directory: DirectoryResource;
|
|
198
|
+
readonly leaderboard: LeaderboardResource;
|
|
199
|
+
readonly health: HealthResource;
|
|
200
|
+
constructor(options?: StamnClientOptions);
|
|
201
|
+
setApiKey(apiKey: string): void;
|
|
202
|
+
request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
203
|
+
private executeRequest;
|
|
204
|
+
private isRetryable;
|
|
205
|
+
private calculateDelay;
|
|
206
|
+
private sleep;
|
|
207
|
+
private parseErrorResponse;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { type ApiKeyCreateResponse, type ApiKeySummary, ApiKeysResource, AuthResource, type BalanceResponse, type DeviceFlowData, type DeviceFlowStatus, type DirectoryEntry, DirectoryResource, type DirectoryResponse, type DirectoryServiceEntry, type HealthCheckResult, HealthResource, type LeaderboardEntry, LeaderboardResource, type LedgerEntry, type OnchainBalanceResponse, type Participant, type ParticipantSettings, ParticipantsResource, type Requestable, Resource, type RetryOptions, StamnApiError, StamnClient, type StamnClientOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
// src/resources/base.ts
|
|
2
|
+
var Resource = class {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// src/resources/auth.ts
|
|
9
|
+
var DEFAULT_POLL_INTERVAL_MS = 5e3;
|
|
10
|
+
var DEFAULT_TIMEOUT_MS = 3e5;
|
|
11
|
+
var AuthResource = class extends Resource {
|
|
12
|
+
async initiateDeviceFlow() {
|
|
13
|
+
const res = await this.client.request(
|
|
14
|
+
"POST",
|
|
15
|
+
"/v1/auth/device-codes"
|
|
16
|
+
);
|
|
17
|
+
return res.data;
|
|
18
|
+
}
|
|
19
|
+
async getDeviceFlowStatus(deviceCode) {
|
|
20
|
+
const res = await this.client.request(
|
|
21
|
+
"GET",
|
|
22
|
+
`/v1/auth/device-codes/${deviceCode}`
|
|
23
|
+
);
|
|
24
|
+
return res.data;
|
|
25
|
+
}
|
|
26
|
+
async pollForApproval(deviceCode, options) {
|
|
27
|
+
const pollInterval = options?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
28
|
+
const timeout = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
29
|
+
const deadline = Date.now() + timeout;
|
|
30
|
+
while (Date.now() < deadline) {
|
|
31
|
+
await new Promise((r) => setTimeout(r, pollInterval));
|
|
32
|
+
try {
|
|
33
|
+
const status = await this.getDeviceFlowStatus(deviceCode);
|
|
34
|
+
if (status.status === "approved" && status.apiKey) {
|
|
35
|
+
return status.apiKey;
|
|
36
|
+
}
|
|
37
|
+
if (status.status === "expired") {
|
|
38
|
+
throw new Error("Login code expired. Try again.");
|
|
39
|
+
}
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (err.message.includes("expired")) throw err;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
throw new Error("Login timed out. Try again.");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/resources/agents.ts
|
|
49
|
+
var AgentsResource = class extends Resource {
|
|
50
|
+
async create(options) {
|
|
51
|
+
const res = await this.client.request(
|
|
52
|
+
"POST",
|
|
53
|
+
"/v1/participants",
|
|
54
|
+
{
|
|
55
|
+
name: options?.name,
|
|
56
|
+
description: options?.description
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
return res.data;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/resources/participants.ts
|
|
64
|
+
var ParticipantsResource = class extends Resource {
|
|
65
|
+
async create(options) {
|
|
66
|
+
const res = await this.client.request(
|
|
67
|
+
"POST",
|
|
68
|
+
"/v1/participants",
|
|
69
|
+
{
|
|
70
|
+
name: options?.name || void 0,
|
|
71
|
+
description: options?.description || void 0
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
return res.data;
|
|
75
|
+
}
|
|
76
|
+
async list() {
|
|
77
|
+
const res = await this.client.request(
|
|
78
|
+
"GET",
|
|
79
|
+
"/v1/participants"
|
|
80
|
+
);
|
|
81
|
+
return res.data;
|
|
82
|
+
}
|
|
83
|
+
async get(participantId) {
|
|
84
|
+
const res = await this.client.request(
|
|
85
|
+
"GET",
|
|
86
|
+
`/v1/participants/${participantId}`
|
|
87
|
+
);
|
|
88
|
+
return res.data;
|
|
89
|
+
}
|
|
90
|
+
async update(participantId, data) {
|
|
91
|
+
const res = await this.client.request(
|
|
92
|
+
"PATCH",
|
|
93
|
+
`/v1/participants/${participantId}`,
|
|
94
|
+
data
|
|
95
|
+
);
|
|
96
|
+
return res.data;
|
|
97
|
+
}
|
|
98
|
+
async getBalance(participantId) {
|
|
99
|
+
const res = await this.client.request(
|
|
100
|
+
"GET",
|
|
101
|
+
`/v1/participants/${participantId}/balance`
|
|
102
|
+
);
|
|
103
|
+
return res.data;
|
|
104
|
+
}
|
|
105
|
+
async getOnchainBalance(participantId) {
|
|
106
|
+
const res = await this.client.request(
|
|
107
|
+
"GET",
|
|
108
|
+
`/v1/participants/${participantId}/onchain-balance`
|
|
109
|
+
);
|
|
110
|
+
return res.data;
|
|
111
|
+
}
|
|
112
|
+
async getLedgerEntries(participantId) {
|
|
113
|
+
const res = await this.client.request(
|
|
114
|
+
"GET",
|
|
115
|
+
`/v1/participants/${participantId}/ledger-entries`
|
|
116
|
+
);
|
|
117
|
+
return res.data;
|
|
118
|
+
}
|
|
119
|
+
async deposit(participantId, data) {
|
|
120
|
+
const res = await this.client.request(
|
|
121
|
+
"POST",
|
|
122
|
+
`/v1/participants/${participantId}/deposits`,
|
|
123
|
+
data
|
|
124
|
+
);
|
|
125
|
+
return res.data;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// src/resources/api-keys.ts
|
|
130
|
+
var ApiKeysResource = class extends Resource {
|
|
131
|
+
async create() {
|
|
132
|
+
const res = await this.client.request(
|
|
133
|
+
"POST",
|
|
134
|
+
"/v1/api-keys"
|
|
135
|
+
);
|
|
136
|
+
return res.data;
|
|
137
|
+
}
|
|
138
|
+
async list() {
|
|
139
|
+
const res = await this.client.request(
|
|
140
|
+
"GET",
|
|
141
|
+
"/v1/api-keys"
|
|
142
|
+
);
|
|
143
|
+
return res.data;
|
|
144
|
+
}
|
|
145
|
+
async revoke(id) {
|
|
146
|
+
await this.client.request("DELETE", `/v1/api-keys/${id}`);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// src/resources/directory.ts
|
|
151
|
+
var DirectoryResource = class extends Resource {
|
|
152
|
+
async list(options) {
|
|
153
|
+
const params = new URLSearchParams();
|
|
154
|
+
if (options?.serviceTag) params.set("serviceTag", options.serviceTag);
|
|
155
|
+
if (options?.name) params.set("name", options.name);
|
|
156
|
+
const query = params.toString();
|
|
157
|
+
const path = query ? `/v1/directory?${query}` : "/v1/directory";
|
|
158
|
+
const res = await this.client.request(
|
|
159
|
+
"GET",
|
|
160
|
+
path
|
|
161
|
+
);
|
|
162
|
+
return res.data;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/resources/leaderboard.ts
|
|
167
|
+
var LeaderboardResource = class extends Resource {
|
|
168
|
+
async get() {
|
|
169
|
+
const res = await this.client.request(
|
|
170
|
+
"GET",
|
|
171
|
+
"/v1/leaderboard"
|
|
172
|
+
);
|
|
173
|
+
return res.data;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// src/resources/health.ts
|
|
178
|
+
var HealthResource = class extends Resource {
|
|
179
|
+
async check() {
|
|
180
|
+
try {
|
|
181
|
+
await this.client.request("GET", "/v1/health");
|
|
182
|
+
return { ok: true };
|
|
183
|
+
} catch {
|
|
184
|
+
return { ok: false };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// src/client.ts
|
|
190
|
+
var StamnApiError = class extends Error {
|
|
191
|
+
constructor(message, status) {
|
|
192
|
+
super(message);
|
|
193
|
+
this.status = status;
|
|
194
|
+
this.name = "StamnApiError";
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var DEFAULT_RETRY = {
|
|
198
|
+
maxRetries: 0,
|
|
199
|
+
initialDelayMs: 500,
|
|
200
|
+
backoffMultiplier: 2,
|
|
201
|
+
maxDelayMs: 1e4
|
|
202
|
+
};
|
|
203
|
+
var SERVER_URL = "https://api.stamn.com";
|
|
204
|
+
var StamnClient = class {
|
|
205
|
+
serverUrl = SERVER_URL;
|
|
206
|
+
apiKey;
|
|
207
|
+
retryOptions;
|
|
208
|
+
auth;
|
|
209
|
+
agents;
|
|
210
|
+
participants;
|
|
211
|
+
apiKeys;
|
|
212
|
+
directory;
|
|
213
|
+
leaderboard;
|
|
214
|
+
health;
|
|
215
|
+
constructor(options = {}) {
|
|
216
|
+
this.apiKey = options.apiKey;
|
|
217
|
+
this.retryOptions = { ...DEFAULT_RETRY, ...options.retry };
|
|
218
|
+
this.auth = new AuthResource(this);
|
|
219
|
+
this.agents = new AgentsResource(this);
|
|
220
|
+
this.participants = new ParticipantsResource(this);
|
|
221
|
+
this.apiKeys = new ApiKeysResource(this);
|
|
222
|
+
this.directory = new DirectoryResource(this);
|
|
223
|
+
this.leaderboard = new LeaderboardResource(this);
|
|
224
|
+
this.health = new HealthResource(this);
|
|
225
|
+
}
|
|
226
|
+
setApiKey(apiKey) {
|
|
227
|
+
this.apiKey = apiKey;
|
|
228
|
+
}
|
|
229
|
+
async request(method, path, body) {
|
|
230
|
+
let lastError;
|
|
231
|
+
for (let attempt = 0; attempt <= this.retryOptions.maxRetries; attempt++) {
|
|
232
|
+
if (attempt > 0) {
|
|
233
|
+
await this.sleep(this.calculateDelay(attempt - 1));
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
return await this.executeRequest(method, path, body);
|
|
237
|
+
} catch (error) {
|
|
238
|
+
lastError = error;
|
|
239
|
+
if (!this.isRetryable(error) || attempt === this.retryOptions.maxRetries) {
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
throw lastError;
|
|
245
|
+
}
|
|
246
|
+
async executeRequest(method, path, body) {
|
|
247
|
+
const headers = {};
|
|
248
|
+
if (body !== void 0) {
|
|
249
|
+
headers["Content-Type"] = "application/json";
|
|
250
|
+
}
|
|
251
|
+
if (this.apiKey) {
|
|
252
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
253
|
+
}
|
|
254
|
+
const res = await fetch(`${this.serverUrl}${path}`, {
|
|
255
|
+
method,
|
|
256
|
+
headers,
|
|
257
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
258
|
+
});
|
|
259
|
+
if (!res.ok) {
|
|
260
|
+
const message = await this.parseErrorResponse(res);
|
|
261
|
+
throw new StamnApiError(message, res.status);
|
|
262
|
+
}
|
|
263
|
+
const text = await res.text();
|
|
264
|
+
if (!text) return void 0;
|
|
265
|
+
return JSON.parse(text);
|
|
266
|
+
}
|
|
267
|
+
isRetryable(error) {
|
|
268
|
+
if (error instanceof TypeError) return true;
|
|
269
|
+
if (error instanceof StamnApiError && error.status >= 500) return true;
|
|
270
|
+
if (error instanceof StamnApiError && error.status === 429) return true;
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
calculateDelay(attempt) {
|
|
274
|
+
const baseDelay = this.retryOptions.initialDelayMs * Math.pow(this.retryOptions.backoffMultiplier, attempt);
|
|
275
|
+
const capped = Math.min(baseDelay, this.retryOptions.maxDelayMs);
|
|
276
|
+
return Math.random() * capped;
|
|
277
|
+
}
|
|
278
|
+
sleep(ms) {
|
|
279
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
280
|
+
}
|
|
281
|
+
async parseErrorResponse(res) {
|
|
282
|
+
const body = await res.text();
|
|
283
|
+
try {
|
|
284
|
+
const parsed = JSON.parse(body);
|
|
285
|
+
const msg = parsed.error?.message ?? (Array.isArray(parsed.message) ? parsed.message.join(". ") : parsed.message);
|
|
286
|
+
if (msg) return msg;
|
|
287
|
+
} catch {
|
|
288
|
+
}
|
|
289
|
+
return body || `HTTP ${res.status}`;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
export {
|
|
293
|
+
ApiKeysResource,
|
|
294
|
+
AuthResource,
|
|
295
|
+
DirectoryResource,
|
|
296
|
+
HealthResource,
|
|
297
|
+
LeaderboardResource,
|
|
298
|
+
ParticipantsResource,
|
|
299
|
+
Resource,
|
|
300
|
+
StamnApiError,
|
|
301
|
+
StamnClient
|
|
302
|
+
};
|
|
303
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resources/base.ts","../src/resources/auth.ts","../src/resources/agents.ts","../src/resources/participants.ts","../src/resources/api-keys.ts","../src/resources/directory.ts","../src/resources/leaderboard.ts","../src/resources/health.ts","../src/client.ts"],"sourcesContent":["import type { Requestable } from '@/types';\n\nexport abstract class Resource {\n constructor(protected readonly client: Requestable) {}\n}\n","import { Resource } from '@/resources/base';\nimport type { DeviceFlowData, DeviceFlowStatus } from '@/types';\n\nconst DEFAULT_POLL_INTERVAL_MS = 5_000;\nconst DEFAULT_TIMEOUT_MS = 300_000; // 5 minutes\n\nexport class AuthResource extends Resource {\n\n async initiateDeviceFlow(): Promise<DeviceFlowData> {\n const res = await this.client.request<{ data: DeviceFlowData }>(\n 'POST',\n '/v1/auth/device-codes',\n );\n return res.data;\n }\n\n async getDeviceFlowStatus(deviceCode: string): Promise<DeviceFlowStatus> {\n const res = await this.client.request<{ data: DeviceFlowStatus }>(\n 'GET',\n `/v1/auth/device-codes/${deviceCode}`,\n );\n return res.data;\n }\n\n async pollForApproval(\n deviceCode: string,\n options?: { pollIntervalMs?: number; timeoutMs?: number },\n ): Promise<string> {\n const pollInterval = options?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const timeout = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const deadline = Date.now() + timeout;\n\n while (Date.now() < deadline) {\n await new Promise((r) => setTimeout(r, pollInterval));\n\n try {\n const status = await this.getDeviceFlowStatus(deviceCode);\n\n if (status.status === 'approved' && status.apiKey) {\n return status.apiKey;\n }\n\n if (status.status === 'expired') {\n throw new Error('Login code expired. Try again.');\n }\n } catch (err) {\n if ((err as Error).message.includes('expired')) throw err;\n }\n }\n\n throw new Error('Login timed out. Try again.');\n }\n}\n","import { Resource } from '@/resources/base';\nimport type { Participant } from '@/types';\n\nexport class AgentsResource extends Resource {\n\n async create(options?: { name?: string; description?: string }): Promise<Participant> {\n const res = await this.client.request<{ data: Participant }>(\n 'POST',\n '/v1/participants',\n {\n name: options?.name,\n description: options?.description,\n },\n );\n return res.data;\n }\n}\n","import { Resource } from '@/resources/base';\nimport type {\n Participant,\n ParticipantSettings,\n BalanceResponse,\n OnchainBalanceResponse,\n LedgerEntry,\n} from '@/types';\n\nexport class ParticipantsResource extends Resource {\n\n async create(options?: { name?: string; description?: string }): Promise<Participant> {\n const res = await this.client.request<{ data: Participant }>(\n 'POST',\n '/v1/participants',\n {\n name: options?.name || undefined,\n description: options?.description || undefined,\n },\n );\n return res.data;\n }\n\n async list(): Promise<Participant[]> {\n const res = await this.client.request<{ data: Participant[] }>(\n 'GET',\n '/v1/participants',\n );\n return res.data;\n }\n\n async get(participantId: string): Promise<Participant> {\n const res = await this.client.request<{ data: Participant }>(\n 'GET',\n `/v1/participants/${participantId}`,\n );\n return res.data;\n }\n\n async update(\n participantId: string,\n data: {\n settings?: Partial<ParticipantSettings>;\n status?: 'active' | 'paused' | 'frozen';\n },\n ): Promise<Participant> {\n const res = await this.client.request<{ data: Participant }>(\n 'PATCH',\n `/v1/participants/${participantId}`,\n data,\n );\n return res.data;\n }\n\n async getBalance(participantId: string): Promise<BalanceResponse> {\n const res = await this.client.request<{ data: BalanceResponse }>(\n 'GET',\n `/v1/participants/${participantId}/balance`,\n );\n return res.data;\n }\n\n async getOnchainBalance(participantId: string): Promise<OnchainBalanceResponse> {\n const res = await this.client.request<{ data: OnchainBalanceResponse }>(\n 'GET',\n `/v1/participants/${participantId}/onchain-balance`,\n );\n return res.data;\n }\n\n async getLedgerEntries(participantId: string): Promise<LedgerEntry[]> {\n const res = await this.client.request<{ data: LedgerEntry[] }>(\n 'GET',\n `/v1/participants/${participantId}/ledger-entries`,\n );\n return res.data;\n }\n\n async deposit(\n participantId: string,\n data: { amountCents: number },\n ): Promise<LedgerEntry> {\n const res = await this.client.request<{ data: LedgerEntry }>(\n 'POST',\n `/v1/participants/${participantId}/deposits`,\n data,\n );\n return res.data;\n }\n}\n","import { Resource } from '@/resources/base';\nimport type { ApiKeyCreateResponse, ApiKeySummary } from '@/types';\n\nexport class ApiKeysResource extends Resource {\n\n async create(): Promise<ApiKeyCreateResponse> {\n const res = await this.client.request<{ data: ApiKeyCreateResponse }>(\n 'POST',\n '/v1/api-keys',\n );\n return res.data;\n }\n\n async list(): Promise<ApiKeySummary[]> {\n const res = await this.client.request<{ data: ApiKeySummary[] }>(\n 'GET',\n '/v1/api-keys',\n );\n return res.data;\n }\n\n async revoke(id: string): Promise<void> {\n await this.client.request('DELETE', `/v1/api-keys/${id}`);\n }\n}\n","import { Resource } from '@/resources/base';\nimport type { DirectoryResponse } from '@/types';\n\nexport class DirectoryResource extends Resource {\n\n async list(options?: { serviceTag?: string; name?: string }): Promise<DirectoryResponse> {\n const params = new URLSearchParams();\n if (options?.serviceTag) params.set('serviceTag', options.serviceTag);\n if (options?.name) params.set('name', options.name);\n const query = params.toString();\n const path = query ? `/v1/directory?${query}` : '/v1/directory';\n\n const res = await this.client.request<{ data: DirectoryResponse }>(\n 'GET',\n path,\n );\n return res.data;\n }\n}\n","import { Resource } from '@/resources/base';\nimport type { LeaderboardEntry } from '@/types';\n\nexport class LeaderboardResource extends Resource {\n\n async get(): Promise<LeaderboardEntry[]> {\n const res = await this.client.request<{ data: LeaderboardEntry[] }>(\n 'GET',\n '/v1/leaderboard',\n );\n return res.data;\n }\n}\n","import { Resource } from '@/resources/base';\nimport type { HealthCheckResult } from '@/types';\n\nexport class HealthResource extends Resource {\n\n async check(): Promise<HealthCheckResult> {\n try {\n await this.client.request('GET', '/v1/health');\n return { ok: true };\n } catch {\n return { ok: false };\n }\n }\n}\n","import type { StamnClientOptions, Requestable } from '@/types';\nimport { AuthResource } from '@/resources/auth';\nimport { AgentsResource } from '@/resources/agents';\nimport { ParticipantsResource } from '@/resources/participants';\nimport { ApiKeysResource } from '@/resources/api-keys';\nimport { DirectoryResource } from '@/resources/directory';\nimport { LeaderboardResource } from '@/resources/leaderboard';\nimport { HealthResource } from '@/resources/health';\n\nexport class StamnApiError extends Error {\n constructor(\n message: string,\n public readonly status: number,\n ) {\n super(message);\n this.name = \"StamnApiError\";\n }\n}\n\ninterface ResolvedRetryOptions {\n maxRetries: number;\n initialDelayMs: number;\n backoffMultiplier: number;\n maxDelayMs: number;\n}\n\nconst DEFAULT_RETRY: ResolvedRetryOptions = {\n maxRetries: 0,\n initialDelayMs: 500,\n backoffMultiplier: 2,\n maxDelayMs: 10_000,\n};\n\nconst SERVER_URL = \"https://api.stamn.com\";\n\nexport class StamnClient implements Requestable {\n private readonly serverUrl = SERVER_URL;\n private apiKey?: string;\n private retryOptions: ResolvedRetryOptions;\n\n public readonly auth: AuthResource;\n public readonly agents: AgentsResource;\n public readonly participants: ParticipantsResource;\n public readonly apiKeys: ApiKeysResource;\n public readonly directory: DirectoryResource;\n public readonly leaderboard: LeaderboardResource;\n public readonly health: HealthResource;\n\n constructor(options: StamnClientOptions = {}) {\n this.apiKey = options.apiKey;\n this.retryOptions = { ...DEFAULT_RETRY, ...options.retry };\n\n this.auth = new AuthResource(this);\n this.agents = new AgentsResource(this);\n this.participants = new ParticipantsResource(this);\n this.apiKeys = new ApiKeysResource(this);\n this.directory = new DirectoryResource(this);\n this.leaderboard = new LeaderboardResource(this);\n this.health = new HealthResource(this);\n }\n\n setApiKey(apiKey: string): void {\n this.apiKey = apiKey;\n }\n\n async request<T>(method: string, path: string, body?: unknown): Promise<T> {\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= this.retryOptions.maxRetries; attempt++) {\n if (attempt > 0) {\n await this.sleep(this.calculateDelay(attempt - 1));\n }\n\n try {\n return await this.executeRequest<T>(method, path, body);\n } catch (error) {\n lastError = error;\n if (\n !this.isRetryable(error) ||\n attempt === this.retryOptions.maxRetries\n ) {\n throw error;\n }\n }\n }\n\n throw lastError;\n }\n\n private async executeRequest<T>(\n method: string,\n path: string,\n body?: unknown,\n ): Promise<T> {\n const headers: Record<string, string> = {};\n\n if (body !== undefined) {\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n if (this.apiKey) {\n headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n }\n\n const res = await fetch(`${this.serverUrl}${path}`, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n\n if (!res.ok) {\n const message = await this.parseErrorResponse(res);\n throw new StamnApiError(message, res.status);\n }\n\n const text = await res.text();\n if (!text) return undefined as T;\n\n return JSON.parse(text) as T;\n }\n\n private isRetryable(error: unknown): boolean {\n if (error instanceof TypeError) return true;\n if (error instanceof StamnApiError && error.status >= 500) return true;\n if (error instanceof StamnApiError && error.status === 429) return true;\n return false;\n }\n\n private calculateDelay(attempt: number): number {\n const baseDelay =\n this.retryOptions.initialDelayMs *\n Math.pow(this.retryOptions.backoffMultiplier, attempt);\n const capped = Math.min(baseDelay, this.retryOptions.maxDelayMs);\n return Math.random() * capped;\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n private async parseErrorResponse(res: Response): Promise<string> {\n const body = await res.text();\n try {\n const parsed = JSON.parse(body);\n const msg =\n parsed.error?.message ??\n (Array.isArray(parsed.message)\n ? parsed.message.join(\". \")\n : parsed.message);\n if (msg) return msg;\n } catch {}\n return body || `HTTP ${res.status}`;\n }\n}\n"],"mappings":";AAEO,IAAe,WAAf,MAAwB;AAAA,EAC7B,YAA+B,QAAqB;AAArB;AAAA,EAAsB;AACvD;;;ACDA,IAAM,2BAA2B;AACjC,IAAM,qBAAqB;AAEpB,IAAM,eAAN,cAA2B,SAAS;AAAA,EAEzC,MAAM,qBAA8C;AAClD,UAAM,MAAM,MAAM,KAAK,OAAO;AAAA,MAC5B;AAAA,MACA;AAAA,IACF;AACA,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAM,oBAAoB,YAA+C;AACvE,UAAM,MAAM,MAAM,KAAK,OAAO;AAAA,MAC5B;AAAA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": "0.1.0-alpha.0",
|
|
4
|
+
"description": "Stamn SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsup",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:watch": "vitest",
|
|
21
|
+
"prepare": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"tsup": {
|
|
24
|
+
"entry": [
|
|
25
|
+
"src/index.ts"
|
|
26
|
+
],
|
|
27
|
+
"format": [
|
|
28
|
+
"esm"
|
|
29
|
+
],
|
|
30
|
+
"dts": true,
|
|
31
|
+
"clean": true,
|
|
32
|
+
"sourcemap": true
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"stamn",
|
|
36
|
+
"sdk"
|
|
37
|
+
],
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^22.0.0",
|
|
41
|
+
"tsup": "^8.5.1",
|
|
42
|
+
"typescript": "^5.9.0",
|
|
43
|
+
"vitest": "^4.0.18"
|
|
44
|
+
}
|
|
45
|
+
}
|