@inodra/sui 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 +202 -0
- package/README.md +237 -0
- package/bin/inodra-sui.mjs +2 -0
- package/dist/chunk-3CBLVI6J.js +426 -0
- package/dist/chunk-3CBLVI6J.js.map +1 -0
- package/dist/chunk-4HKKW5QN.js +80 -0
- package/dist/chunk-4HKKW5QN.js.map +1 -0
- package/dist/chunk-74XGJJJI.js +33 -0
- package/dist/chunk-74XGJJJI.js.map +1 -0
- package/dist/chunk-D6FZYWG7.js +99 -0
- package/dist/chunk-D6FZYWG7.js.map +1 -0
- package/dist/chunk-LZZMTSLH.js +31 -0
- package/dist/chunk-LZZMTSLH.js.map +1 -0
- package/dist/chunk-M3M2L6BW.js +29 -0
- package/dist/chunk-M3M2L6BW.js.map +1 -0
- package/dist/chunk-NSXRC5XW.js +298 -0
- package/dist/chunk-NSXRC5XW.js.map +1 -0
- package/dist/chunk-OGMBYWTG.js +537 -0
- package/dist/chunk-OGMBYWTG.js.map +1 -0
- package/dist/chunk-U6D5LGNF.js +111 -0
- package/dist/chunk-U6D5LGNF.js.map +1 -0
- package/dist/chunk-ZSW3EWGF.js +539 -0
- package/dist/chunk-ZSW3EWGF.js.map +1 -0
- package/dist/cli.js +665 -0
- package/dist/cli.js.map +1 -0
- package/dist/events.cjs +3273 -0
- package/dist/events.cjs.map +1 -0
- package/dist/events.d.cts +47 -0
- package/dist/events.d.ts +47 -0
- package/dist/events.js +2578 -0
- package/dist/events.js.map +1 -0
- package/dist/graphql.cjs +129 -0
- package/dist/graphql.cjs.map +1 -0
- package/dist/graphql.d.cts +36 -0
- package/dist/graphql.d.ts +36 -0
- package/dist/graphql.js +10 -0
- package/dist/graphql.js.map +1 -0
- package/dist/grpc-web.cjs +129 -0
- package/dist/grpc-web.cjs.map +1 -0
- package/dist/grpc-web.d.cts +31 -0
- package/dist/grpc-web.d.ts +31 -0
- package/dist/grpc-web.js +10 -0
- package/dist/grpc-web.js.map +1 -0
- package/dist/grpc.cjs +131 -0
- package/dist/grpc.cjs.map +1 -0
- package/dist/grpc.d.cts +34 -0
- package/dist/grpc.d.ts +34 -0
- package/dist/grpc.js +10 -0
- package/dist/grpc.js.map +1 -0
- package/dist/index-CGBN_EI5.d.ts +4800 -0
- package/dist/index-CVO2Kj8a.d.cts +4800 -0
- package/dist/index.cjs +4723 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +504 -0
- package/dist/index.d.ts +504 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/manage.cjs +376 -0
- package/dist/manage.cjs.map +1 -0
- package/dist/manage.d.cts +2 -0
- package/dist/manage.d.ts +2 -0
- package/dist/manage.js +8 -0
- package/dist/manage.js.map +1 -0
- package/dist/network-CEg2MJY3.d.cts +60 -0
- package/dist/network-CEg2MJY3.d.ts +60 -0
- package/dist/node.cjs +4759 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +28 -0
- package/dist/node.d.ts +28 -0
- package/dist/node.js +73 -0
- package/dist/node.js.map +1 -0
- package/dist/reflection-Bx44-Fs1.d.ts +4639 -0
- package/dist/reflection-Cf7WFH6H.d.cts +4639 -0
- package/dist/reflection-FEGYA7DU.js +9 -0
- package/dist/reflection-FEGYA7DU.js.map +1 -0
- package/dist/runtime-OWKF3LZ7.js +37 -0
- package/dist/runtime-OWKF3LZ7.js.map +1 -0
- package/dist/warp.cjs +633 -0
- package/dist/warp.cjs.map +1 -0
- package/dist/warp.d.cts +195 -0
- package/dist/warp.d.ts +195 -0
- package/dist/warp.js +12 -0
- package/dist/warp.js.map +1 -0
- package/dist/webhooks.cjs +104 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +35 -0
- package/dist/webhooks.d.ts +35 -0
- package/dist/webhooks.js +7 -0
- package/dist/webhooks.js.map +1 -0
- package/llms.txt +189 -0
- package/package.json +119 -0
package/dist/manage.cjs
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/manage/index.ts
|
|
21
|
+
var manage_exports = {};
|
|
22
|
+
__export(manage_exports, {
|
|
23
|
+
InodraManagementClient: () => InodraManagementClient
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(manage_exports);
|
|
26
|
+
|
|
27
|
+
// src/core/auth.ts
|
|
28
|
+
function resolveAuth(auth) {
|
|
29
|
+
if (typeof auth === "string") {
|
|
30
|
+
return staticAuth(apiKeyCredentials(auth));
|
|
31
|
+
}
|
|
32
|
+
if ("apiKey" in auth) {
|
|
33
|
+
return staticAuth(apiKeyCredentials(auth.apiKey));
|
|
34
|
+
}
|
|
35
|
+
if ("sessionToken" in auth) {
|
|
36
|
+
return staticAuth({
|
|
37
|
+
headers: { authorization: `Bearer ${auth.sessionToken}` }
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
credentials: async () => auth.getCredentials(),
|
|
42
|
+
staticCredentials: () => void 0
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function authFromOptions(options, context) {
|
|
46
|
+
if (options.auth !== void 0) {
|
|
47
|
+
return resolveAuth(options.auth);
|
|
48
|
+
}
|
|
49
|
+
if (options.apiKey) {
|
|
50
|
+
return resolveAuth(options.apiKey);
|
|
51
|
+
}
|
|
52
|
+
throw new Error(`${context} requires auth (or the apiKey shorthand)`);
|
|
53
|
+
}
|
|
54
|
+
function apiKeyCredentials(apiKey) {
|
|
55
|
+
if (!apiKey) {
|
|
56
|
+
throw new Error("Inodra auth: apiKey must be a non-empty string");
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
headers: { "x-api-key": apiKey },
|
|
60
|
+
queryParams: { api_key: apiKey }
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function staticAuth(credentials) {
|
|
64
|
+
return {
|
|
65
|
+
credentials: async () => credentials,
|
|
66
|
+
staticCredentials: () => credentials
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/core/errors.ts
|
|
71
|
+
var InodraError = class extends Error {
|
|
72
|
+
status;
|
|
73
|
+
requestId;
|
|
74
|
+
body;
|
|
75
|
+
/** Stable machine-readable error code from the API (e.g. "QUOTA_EXCEEDED"). */
|
|
76
|
+
code;
|
|
77
|
+
constructor(message, options) {
|
|
78
|
+
super(message);
|
|
79
|
+
this.name = "InodraError";
|
|
80
|
+
this.status = options.status;
|
|
81
|
+
this.requestId = options.requestId;
|
|
82
|
+
this.body = options.body;
|
|
83
|
+
this.code = options.code;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var InodraAuthenticationError = class extends InodraError {
|
|
87
|
+
constructor(options) {
|
|
88
|
+
super(
|
|
89
|
+
options.message ?? (options.status === 403 ? "Forbidden \u2014 the API key is valid but not allowed to do this" : "Invalid or missing API key"),
|
|
90
|
+
options
|
|
91
|
+
);
|
|
92
|
+
this.name = "InodraAuthenticationError";
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var InodraRateLimitError = class extends InodraError {
|
|
96
|
+
retryAfterSeconds;
|
|
97
|
+
constructor(options) {
|
|
98
|
+
super(options.message ?? "Rate limit exceeded", options);
|
|
99
|
+
this.name = "InodraRateLimitError";
|
|
100
|
+
this.retryAfterSeconds = options.retryAfterSeconds;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var InodraTimeoutError = class extends Error {
|
|
104
|
+
constructor(timeoutMs) {
|
|
105
|
+
super(`Request timed out after ${timeoutMs}ms`);
|
|
106
|
+
this.name = "InodraTimeoutError";
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// src/core/network.ts
|
|
111
|
+
var INODRA_ENDPOINTS = {
|
|
112
|
+
mainnet: {
|
|
113
|
+
rest: "https://mainnet-api.inodra.com/v1",
|
|
114
|
+
graphql: "https://mainnet-api.inodra.com/v1/graphql",
|
|
115
|
+
/** host:port for native gRPC transports */
|
|
116
|
+
grpc: "mainnet-grpc.inodra.com:443",
|
|
117
|
+
/** base URL for gRPC-Web transports */
|
|
118
|
+
grpcWeb: "https://mainnet-grpc.inodra.com",
|
|
119
|
+
warpWs: "wss://mainnet-api.inodra.com/v1"
|
|
120
|
+
},
|
|
121
|
+
testnet: {
|
|
122
|
+
rest: "https://testnet-api.inodra.com/v1",
|
|
123
|
+
graphql: "https://testnet-api.inodra.com/v1/graphql",
|
|
124
|
+
grpc: "testnet-grpc.inodra.com:443",
|
|
125
|
+
grpcWeb: "https://testnet-grpc.inodra.com",
|
|
126
|
+
warpWs: "wss://testnet-api.inodra.com/v1"
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
function restBaseUrl(network) {
|
|
130
|
+
return INODRA_ENDPOINTS[network].rest;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/core/version.ts
|
|
134
|
+
var SDK_VERSION = "0.1.0";
|
|
135
|
+
var SDK_HEADER_NAME = "x-inodra-sdk";
|
|
136
|
+
var SDK_HEADER_VALUE = `inodra-sdk-ts/${SDK_VERSION}`;
|
|
137
|
+
|
|
138
|
+
// src/core/http.ts
|
|
139
|
+
var InodraHttpClient = class {
|
|
140
|
+
baseUrl;
|
|
141
|
+
/** Rate-limit/credit info from the most recent response, if any. */
|
|
142
|
+
lastResponseMeta;
|
|
143
|
+
auth;
|
|
144
|
+
maxRetries;
|
|
145
|
+
timeoutMs;
|
|
146
|
+
fetchImpl;
|
|
147
|
+
onResponseMeta;
|
|
148
|
+
constructor(options) {
|
|
149
|
+
this.auth = authFromOptions(options, "InodraHttpClient");
|
|
150
|
+
this.baseUrl = (options.baseUrl ?? restBaseUrl(options.network ?? "mainnet")).replace(/\/$/, "");
|
|
151
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
152
|
+
this.timeoutMs = options.timeoutMs ?? 3e4;
|
|
153
|
+
this.fetchImpl = options.fetch ?? globalThis.fetch;
|
|
154
|
+
this.onResponseMeta = options.onResponseMeta;
|
|
155
|
+
}
|
|
156
|
+
async request(method, path, options = {}) {
|
|
157
|
+
const url = new URL(this.baseUrl + path);
|
|
158
|
+
for (const [key, value] of Object.entries(options.query ?? {})) {
|
|
159
|
+
if (value !== void 0) {
|
|
160
|
+
url.searchParams.set(key, String(value));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const retryOn5xx = options.idempotent ?? !(method === "POST" || method === "PATCH");
|
|
164
|
+
let attempt = 0;
|
|
165
|
+
for (; ; ) {
|
|
166
|
+
const response = await this.send(url, method, options);
|
|
167
|
+
this.captureMeta(response);
|
|
168
|
+
if (response.ok) {
|
|
169
|
+
if (response.status === 204) {
|
|
170
|
+
return void 0;
|
|
171
|
+
}
|
|
172
|
+
return await response.json();
|
|
173
|
+
}
|
|
174
|
+
const retryable = response.status === 429 || retryOn5xx && response.status >= 500;
|
|
175
|
+
if (retryable && attempt < this.maxRetries) {
|
|
176
|
+
attempt += 1;
|
|
177
|
+
await sleep(retryDelayMs(response, attempt));
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
throw await toError(response);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async send(url, method, options) {
|
|
184
|
+
const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
|
185
|
+
const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
|
|
186
|
+
const { headers: authHeaders } = await this.auth.credentials();
|
|
187
|
+
try {
|
|
188
|
+
return await this.fetchImpl(url, {
|
|
189
|
+
method,
|
|
190
|
+
headers: {
|
|
191
|
+
...authHeaders,
|
|
192
|
+
[SDK_HEADER_NAME]: SDK_HEADER_VALUE,
|
|
193
|
+
"content-type": "application/json",
|
|
194
|
+
accept: "application/json"
|
|
195
|
+
},
|
|
196
|
+
body: options.body === void 0 ? void 0 : JSON.stringify(options.body),
|
|
197
|
+
signal
|
|
198
|
+
});
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (timeoutSignal.aborted && !options.signal?.aborted) {
|
|
201
|
+
throw new InodraTimeoutError(this.timeoutMs);
|
|
202
|
+
}
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
captureMeta(response) {
|
|
207
|
+
const meta = parseResponseMeta(response);
|
|
208
|
+
if (meta) {
|
|
209
|
+
this.lastResponseMeta = meta;
|
|
210
|
+
this.onResponseMeta?.(meta);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
function parseResponseMeta(response) {
|
|
215
|
+
const meta = {};
|
|
216
|
+
const limit = header(response, "x-ratelimit-limit");
|
|
217
|
+
const remaining = header(response, "x-ratelimit-remaining");
|
|
218
|
+
const reset = header(response, "x-ratelimit-reset");
|
|
219
|
+
if (limit !== void 0 && remaining !== void 0) {
|
|
220
|
+
meta.rateLimit = {
|
|
221
|
+
limit,
|
|
222
|
+
remaining,
|
|
223
|
+
reset: reset ?? 0,
|
|
224
|
+
throttled: response.headers.get("x-ratelimit-throttle") !== null
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
const creditRemaining = header(response, "x-inodra-credit-remaining");
|
|
228
|
+
const creditLimit = header(response, "x-inodra-credit-limit");
|
|
229
|
+
if (creditRemaining !== void 0 && creditLimit !== void 0) {
|
|
230
|
+
meta.credits = {
|
|
231
|
+
remaining: creditRemaining,
|
|
232
|
+
limit: creditLimit,
|
|
233
|
+
replenishDate: response.headers.get("x-inodra-credit-replenish-date") ?? void 0,
|
|
234
|
+
degraded: response.headers.get("x-inodra-credit-degraded") === "true"
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const requestId = response.headers.get("x-request-id");
|
|
238
|
+
if (requestId) {
|
|
239
|
+
meta.requestId = requestId;
|
|
240
|
+
}
|
|
241
|
+
if (!meta.rateLimit && !meta.credits && !meta.requestId) {
|
|
242
|
+
return void 0;
|
|
243
|
+
}
|
|
244
|
+
return meta;
|
|
245
|
+
}
|
|
246
|
+
function header(response, name) {
|
|
247
|
+
const raw = response.headers.get(name);
|
|
248
|
+
if (raw === null) {
|
|
249
|
+
return void 0;
|
|
250
|
+
}
|
|
251
|
+
const value = Number(raw);
|
|
252
|
+
return Number.isFinite(value) ? value : void 0;
|
|
253
|
+
}
|
|
254
|
+
async function toError(response) {
|
|
255
|
+
const requestId = response.headers.get("x-request-id") ?? void 0;
|
|
256
|
+
let body;
|
|
257
|
+
try {
|
|
258
|
+
body = await response.json();
|
|
259
|
+
} catch {
|
|
260
|
+
body = void 0;
|
|
261
|
+
}
|
|
262
|
+
const serverMessage = extractField(body, ["message", "error"]);
|
|
263
|
+
const code = extractField(body, ["code"]);
|
|
264
|
+
if (response.status === 401 || response.status === 403) {
|
|
265
|
+
return new InodraAuthenticationError({
|
|
266
|
+
status: response.status,
|
|
267
|
+
requestId,
|
|
268
|
+
body,
|
|
269
|
+
code,
|
|
270
|
+
message: serverMessage
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (response.status === 429) {
|
|
274
|
+
const retryAfter = response.headers.get("retry-after");
|
|
275
|
+
return new InodraRateLimitError({
|
|
276
|
+
status: response.status,
|
|
277
|
+
requestId,
|
|
278
|
+
body,
|
|
279
|
+
code,
|
|
280
|
+
retryAfterSeconds: retryAfter ? Number(retryAfter) : void 0,
|
|
281
|
+
message: serverMessage
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
return new InodraError(
|
|
285
|
+
serverMessage ?? `Request failed with status ${response.status}`,
|
|
286
|
+
{ status: response.status, requestId, body, code }
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
function extractField(body, keys) {
|
|
290
|
+
if (typeof body !== "object" || body === null) {
|
|
291
|
+
return void 0;
|
|
292
|
+
}
|
|
293
|
+
for (const key of keys) {
|
|
294
|
+
const value = body[key];
|
|
295
|
+
if (typeof value === "string" && value.length > 0) {
|
|
296
|
+
return value;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return void 0;
|
|
300
|
+
}
|
|
301
|
+
function retryDelayMs(response, attempt) {
|
|
302
|
+
const retryAfter = response.headers.get("retry-after");
|
|
303
|
+
if (retryAfter) {
|
|
304
|
+
const seconds = Number(retryAfter);
|
|
305
|
+
if (Number.isFinite(seconds)) {
|
|
306
|
+
return seconds * 1e3;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return 250 * 2 ** (attempt - 1) + Math.random() * 100;
|
|
310
|
+
}
|
|
311
|
+
function sleep(ms) {
|
|
312
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// src/manage/index.ts
|
|
316
|
+
var InodraManagementClient = class {
|
|
317
|
+
http;
|
|
318
|
+
constructor(options) {
|
|
319
|
+
this.http = new InodraHttpClient(options);
|
|
320
|
+
}
|
|
321
|
+
webhooks = {
|
|
322
|
+
createEvent: (input) => this.http.request("POST", "/webhooks/events", {
|
|
323
|
+
body: input
|
|
324
|
+
}),
|
|
325
|
+
createAddress: (input) => this.http.request("POST", "/webhooks/addresses", {
|
|
326
|
+
body: input
|
|
327
|
+
}),
|
|
328
|
+
createCoin: (input) => this.http.request("POST", "/webhooks/coins", {
|
|
329
|
+
body: input
|
|
330
|
+
}),
|
|
331
|
+
createObject: (input) => this.http.request("POST", "/webhooks/objects", {
|
|
332
|
+
body: input
|
|
333
|
+
}),
|
|
334
|
+
list: () => this.http.request("GET", "/webhooks"),
|
|
335
|
+
get: (id) => this.http.request("GET", `/webhooks/${encodeURIComponent(id)}`),
|
|
336
|
+
update: (id, input) => this.http.request(
|
|
337
|
+
"PUT",
|
|
338
|
+
`/webhooks/${encodeURIComponent(id)}`,
|
|
339
|
+
{ body: input }
|
|
340
|
+
),
|
|
341
|
+
delete: (id) => this.http.request(
|
|
342
|
+
"DELETE",
|
|
343
|
+
`/webhooks/${encodeURIComponent(id)}`
|
|
344
|
+
)
|
|
345
|
+
};
|
|
346
|
+
warp = {
|
|
347
|
+
createEventStream: (input) => this.http.request("POST", "/warp/events", {
|
|
348
|
+
body: input
|
|
349
|
+
}),
|
|
350
|
+
createAddressStream: (input) => this.http.request("POST", "/warp/addresses", {
|
|
351
|
+
body: input
|
|
352
|
+
}),
|
|
353
|
+
createCoinStream: (input) => this.http.request("POST", "/warp/coins", {
|
|
354
|
+
body: input
|
|
355
|
+
}),
|
|
356
|
+
createObjectStream: (input) => this.http.request("POST", "/warp/objects", {
|
|
357
|
+
body: input
|
|
358
|
+
}),
|
|
359
|
+
list: () => this.http.request("GET", "/warp"),
|
|
360
|
+
get: (id) => this.http.request("GET", `/warp/${encodeURIComponent(id)}`),
|
|
361
|
+
update: (id, input) => this.http.request(
|
|
362
|
+
"PUT",
|
|
363
|
+
`/warp/${encodeURIComponent(id)}`,
|
|
364
|
+
{ body: input }
|
|
365
|
+
),
|
|
366
|
+
delete: (id) => this.http.request(
|
|
367
|
+
"DELETE",
|
|
368
|
+
`/warp/${encodeURIComponent(id)}`
|
|
369
|
+
)
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
373
|
+
0 && (module.exports = {
|
|
374
|
+
InodraManagementClient
|
|
375
|
+
});
|
|
376
|
+
//# sourceMappingURL=manage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/manage/index.ts","../src/core/auth.ts","../src/core/errors.ts","../src/core/network.ts","../src/core/version.ts","../src/core/http.ts"],"sourcesContent":["import {\n\tInodraHttpClient,\n\ttype InodraHttpClientOptions,\n} from \"../core/http.js\";\nimport type { Body, Operation, Success } from \"../core/openapi.js\";\n\n// Webhooks\nexport type CreateEventWebhookInput = Body<Operation<\"/webhooks/events\", \"post\">>;\nexport type CreateAddressWebhookInput = Body<\n\tOperation<\"/webhooks/addresses\", \"post\">\n>;\nexport type CreateCoinWebhookInput = Body<Operation<\"/webhooks/coins\", \"post\">>;\nexport type CreateObjectWebhookInput = Body<\n\tOperation<\"/webhooks/objects\", \"post\">\n>;\nexport type CreateWebhookResponse = Success<Operation<\"/webhooks/events\", \"post\">>;\nexport type ListWebhooksResponse = Success<Operation<\"/webhooks\", \"get\">>;\nexport type Webhook = Success<Operation<\"/webhooks/{id}\", \"get\">>;\nexport type UpdateWebhookInput = Body<Operation<\"/webhooks/{id}\", \"put\">>;\nexport type UpdateWebhookResponse = Success<Operation<\"/webhooks/{id}\", \"put\">>;\nexport type DeleteWebhookResponse = Success<Operation<\"/webhooks/{id}\", \"delete\">>;\n\n// Warp streams\nexport type CreateEventStreamInput = Body<Operation<\"/warp/events\", \"post\">>;\nexport type CreateAddressStreamInput = Body<Operation<\"/warp/addresses\", \"post\">>;\nexport type CreateCoinStreamInput = Body<Operation<\"/warp/coins\", \"post\">>;\nexport type CreateObjectStreamInput = Body<Operation<\"/warp/objects\", \"post\">>;\nexport type CreateStreamResponse = Success<Operation<\"/warp/events\", \"post\">>;\nexport type ListStreamsResponse = Success<Operation<\"/warp\", \"get\">>;\nexport type WarpStream = Success<Operation<\"/warp/{id}\", \"get\">>;\nexport type UpdateStreamInput = Body<Operation<\"/warp/{id}\", \"put\">>;\nexport type UpdateStreamResponse = Success<Operation<\"/warp/{id}\", \"put\">>;\nexport type DeleteStreamResponse = Success<Operation<\"/warp/{id}\", \"delete\">>;\n\nexport type InodraManagementClientOptions = InodraHttpClientOptions;\n\n/**\n * CRUD client for Inodra webhooks and Warp stream subscriptions.\n *\n * ```ts\n * const inodra = new InodraManagementClient({ apiKey });\n * const stream = await inodra.warp.createEventStream({\n * eventType: \"0xpkg::module::Event\",\n * });\n * ```\n */\nexport class InodraManagementClient {\n\treadonly http: InodraHttpClient;\n\n\tconstructor(options: InodraManagementClientOptions) {\n\t\tthis.http = new InodraHttpClient(options);\n\t}\n\n\treadonly webhooks = {\n\t\tcreateEvent: (input: CreateEventWebhookInput) =>\n\t\t\tthis.http.request<CreateWebhookResponse>(\"POST\", \"/webhooks/events\", {\n\t\t\t\tbody: input,\n\t\t\t}),\n\t\tcreateAddress: (input: CreateAddressWebhookInput) =>\n\t\t\tthis.http.request<CreateWebhookResponse>(\"POST\", \"/webhooks/addresses\", {\n\t\t\t\tbody: input,\n\t\t\t}),\n\t\tcreateCoin: (input: CreateCoinWebhookInput) =>\n\t\t\tthis.http.request<CreateWebhookResponse>(\"POST\", \"/webhooks/coins\", {\n\t\t\t\tbody: input,\n\t\t\t}),\n\t\tcreateObject: (input: CreateObjectWebhookInput) =>\n\t\t\tthis.http.request<CreateWebhookResponse>(\"POST\", \"/webhooks/objects\", {\n\t\t\t\tbody: input,\n\t\t\t}),\n\t\tlist: () => this.http.request<ListWebhooksResponse>(\"GET\", \"/webhooks\"),\n\t\tget: (id: string) =>\n\t\t\tthis.http.request<Webhook>(\"GET\", `/webhooks/${encodeURIComponent(id)}`),\n\t\tupdate: (id: string, input: UpdateWebhookInput) =>\n\t\t\tthis.http.request<UpdateWebhookResponse>(\n\t\t\t\t\"PUT\",\n\t\t\t\t`/webhooks/${encodeURIComponent(id)}`,\n\t\t\t\t{ body: input },\n\t\t\t),\n\t\tdelete: (id: string) =>\n\t\t\tthis.http.request<DeleteWebhookResponse>(\n\t\t\t\t\"DELETE\",\n\t\t\t\t`/webhooks/${encodeURIComponent(id)}`,\n\t\t\t),\n\t};\n\n\treadonly warp = {\n\t\tcreateEventStream: (input: CreateEventStreamInput) =>\n\t\t\tthis.http.request<CreateStreamResponse>(\"POST\", \"/warp/events\", {\n\t\t\t\tbody: input,\n\t\t\t}),\n\t\tcreateAddressStream: (input: CreateAddressStreamInput) =>\n\t\t\tthis.http.request<CreateStreamResponse>(\"POST\", \"/warp/addresses\", {\n\t\t\t\tbody: input,\n\t\t\t}),\n\t\tcreateCoinStream: (input: CreateCoinStreamInput) =>\n\t\t\tthis.http.request<CreateStreamResponse>(\"POST\", \"/warp/coins\", {\n\t\t\t\tbody: input,\n\t\t\t}),\n\t\tcreateObjectStream: (input: CreateObjectStreamInput) =>\n\t\t\tthis.http.request<CreateStreamResponse>(\"POST\", \"/warp/objects\", {\n\t\t\t\tbody: input,\n\t\t\t}),\n\t\tlist: () => this.http.request<ListStreamsResponse>(\"GET\", \"/warp\"),\n\t\tget: (id: string) =>\n\t\t\tthis.http.request<WarpStream>(\"GET\", `/warp/${encodeURIComponent(id)}`),\n\t\tupdate: (id: string, input: UpdateStreamInput) =>\n\t\t\tthis.http.request<UpdateStreamResponse>(\n\t\t\t\t\"PUT\",\n\t\t\t\t`/warp/${encodeURIComponent(id)}`,\n\t\t\t\t{ body: input },\n\t\t\t),\n\t\tdelete: (id: string) =>\n\t\t\tthis.http.request<DeleteStreamResponse>(\n\t\t\t\t\"DELETE\",\n\t\t\t\t`/warp/${encodeURIComponent(id)}`,\n\t\t\t),\n\t};\n}\n","/**\n * Pluggable authentication for every Inodra transport.\n *\n * Most users pass an API key. The provider shape exists so future credential\n * types (x402 wallet session tokens, refreshing vault-issued keys) slot in\n * without changing any client constructor.\n */\n\nexport interface AuthCredentials {\n\t/** Sent as HTTP headers (REST, SSE, GraphQL) and gRPC metadata. */\n\theaders: Record<string, string>;\n\t/**\n\t * Sent as URL query parameters on transports that cannot carry headers\n\t * (WebSocket upgrades in browsers). Omit to disallow such transports.\n\t */\n\tqueryParams?: Record<string, string>;\n}\n\nexport type InodraAuth =\n\t| string\n\t| { apiKey: string }\n\t| { sessionToken: string }\n\t| {\n\t\t\tgetCredentials: () => AuthCredentials | Promise<AuthCredentials>;\n\t };\n\n/** Normalized auth handle used internally by every transport. */\nexport interface ResolvedAuth {\n\t/** Resolve credentials. Called per request on REST/SSE, per connect on WS. */\n\tcredentials(): Promise<AuthCredentials>;\n\t/**\n\t * Resolve credentials synchronously, or undefined for dynamic providers.\n\t * Used by clients whose underlying transport takes static headers\n\t * (gRPC, GraphQL).\n\t */\n\tstaticCredentials(): AuthCredentials | undefined;\n}\n\nexport function resolveAuth(auth: InodraAuth): ResolvedAuth {\n\tif (typeof auth === \"string\") {\n\t\treturn staticAuth(apiKeyCredentials(auth));\n\t}\n\tif (\"apiKey\" in auth) {\n\t\treturn staticAuth(apiKeyCredentials(auth.apiKey));\n\t}\n\tif (\"sessionToken\" in auth) {\n\t\treturn staticAuth({\n\t\t\theaders: { authorization: `Bearer ${auth.sessionToken}` },\n\t\t});\n\t}\n\treturn {\n\t\tcredentials: async () => auth.getCredentials(),\n\t\tstaticCredentials: () => undefined,\n\t};\n}\n\n/**\n * Resolve auth from an options bag that accepts both the modern `auth` field\n * and the original `apiKey` shorthand.\n */\nexport function authFromOptions(\n\toptions: { auth?: InodraAuth; apiKey?: string },\n\tcontext: string,\n): ResolvedAuth {\n\tif (options.auth !== undefined) {\n\t\treturn resolveAuth(options.auth);\n\t}\n\tif (options.apiKey) {\n\t\treturn resolveAuth(options.apiKey);\n\t}\n\tthrow new Error(`${context} requires auth (or the apiKey shorthand)`);\n}\n\n/**\n * Headers for clients whose transports take static headers (gRPC, GraphQL).\n * Dynamic providers are rejected: the underlying Mysten clients cannot\n * re-resolve credentials per call, so a snapshot would silently go stale.\n */\nexport function staticAuthHeaders(\n\toptions: { auth?: InodraAuth; apiKey?: string },\n\tcontext: string,\n): Record<string, string> {\n\tconst credentials = authFromOptions(options, context).staticCredentials();\n\tif (!credentials) {\n\t\tthrow new Error(\n\t\t\t`${context} does not support dynamic credential providers — pass an apiKey or sessionToken`,\n\t\t);\n\t}\n\treturn credentials.headers;\n}\n\nfunction apiKeyCredentials(apiKey: string): AuthCredentials {\n\tif (!apiKey) {\n\t\tthrow new Error(\"Inodra auth: apiKey must be a non-empty string\");\n\t}\n\treturn {\n\t\theaders: { \"x-api-key\": apiKey },\n\t\tqueryParams: { api_key: apiKey },\n\t};\n}\n\nfunction staticAuth(credentials: AuthCredentials): ResolvedAuth {\n\treturn {\n\t\tcredentials: async () => credentials,\n\t\tstaticCredentials: () => credentials,\n\t};\n}\n","export class InodraError extends Error {\n\treadonly status: number;\n\treadonly requestId?: string;\n\treadonly body?: unknown;\n\t/** Stable machine-readable error code from the API (e.g. \"QUOTA_EXCEEDED\"). */\n\treadonly code?: string;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tstatus: number;\n\t\t\trequestId?: string;\n\t\t\tbody?: unknown;\n\t\t\tcode?: string;\n\t\t},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"InodraError\";\n\t\tthis.status = options.status;\n\t\tthis.requestId = options.requestId;\n\t\tthis.body = options.body;\n\t\tthis.code = options.code;\n\t}\n}\n\nexport class InodraAuthenticationError extends InodraError {\n\tconstructor(options: {\n\t\tstatus: number;\n\t\trequestId?: string;\n\t\tbody?: unknown;\n\t\tcode?: string;\n\t\tmessage?: string;\n\t}) {\n\t\tsuper(\n\t\t\toptions.message ??\n\t\t\t\t(options.status === 403\n\t\t\t\t\t? \"Forbidden — the API key is valid but not allowed to do this\"\n\t\t\t\t\t: \"Invalid or missing API key\"),\n\t\t\toptions,\n\t\t);\n\t\tthis.name = \"InodraAuthenticationError\";\n\t}\n}\n\nexport class InodraRateLimitError extends InodraError {\n\treadonly retryAfterSeconds?: number;\n\n\tconstructor(options: {\n\t\tstatus: number;\n\t\trequestId?: string;\n\t\tbody?: unknown;\n\t\tcode?: string;\n\t\tretryAfterSeconds?: number;\n\t\tmessage?: string;\n\t}) {\n\t\tsuper(options.message ?? \"Rate limit exceeded\", options);\n\t\tthis.name = \"InodraRateLimitError\";\n\t\tthis.retryAfterSeconds = options.retryAfterSeconds;\n\t}\n}\n\nexport class InodraTimeoutError extends Error {\n\tconstructor(timeoutMs: number) {\n\t\tsuper(`Request timed out after ${timeoutMs}ms`);\n\t\tthis.name = \"InodraTimeoutError\";\n\t}\n}\n\nexport class InodraWebhookSignatureError extends Error {\n\tconstructor() {\n\t\tsuper(\"Webhook signature verification failed (bad, missing, or expired)\");\n\t\tthis.name = \"InodraWebhookSignatureError\";\n\t}\n}\n","export type InodraNetwork = \"mainnet\" | \"testnet\";\n\n/**\n * Canonical Inodra endpoints per network and protocol.\n */\nexport const INODRA_ENDPOINTS = {\n\tmainnet: {\n\t\trest: \"https://mainnet-api.inodra.com/v1\",\n\t\tgraphql: \"https://mainnet-api.inodra.com/v1/graphql\",\n\t\t/** host:port for native gRPC transports */\n\t\tgrpc: \"mainnet-grpc.inodra.com:443\",\n\t\t/** base URL for gRPC-Web transports */\n\t\tgrpcWeb: \"https://mainnet-grpc.inodra.com\",\n\t\twarpWs: \"wss://mainnet-api.inodra.com/v1\",\n\t},\n\ttestnet: {\n\t\trest: \"https://testnet-api.inodra.com/v1\",\n\t\tgraphql: \"https://testnet-api.inodra.com/v1/graphql\",\n\t\tgrpc: \"testnet-grpc.inodra.com:443\",\n\t\tgrpcWeb: \"https://testnet-grpc.inodra.com\",\n\t\twarpWs: \"wss://testnet-api.inodra.com/v1\",\n\t},\n} as const satisfies Record<\n\tInodraNetwork,\n\t{ rest: string; graphql: string; grpc: string; grpcWeb: string; warpWs: string }\n>;\n\nexport function restBaseUrl(network: InodraNetwork): string {\n\treturn INODRA_ENDPOINTS[network].rest;\n}\n\nexport function graphqlUrl(network: InodraNetwork): string {\n\treturn INODRA_ENDPOINTS[network].graphql;\n}\n\n/** Base URL for gRPC-Web / Connect transports. */\nexport function grpcBaseUrl(network: InodraNetwork): string {\n\treturn INODRA_ENDPOINTS[network].grpcWeb;\n}\n\n/** host:port for native gRPC transports. */\nexport function grpcHost(network: InodraNetwork): string {\n\treturn INODRA_ENDPOINTS[network].grpc;\n}\n\nexport function warpStreamUrl(\n\tnetwork: InodraNetwork,\n\tsubscriptionId: string,\n): string {\n\treturn `${INODRA_ENDPOINTS[network].rest}/warp/${subscriptionId}/stream`;\n}\n\nexport function warpWebSocketUrl(\n\tnetwork: InodraNetwork,\n\tsubscriptionId: string,\n): string {\n\treturn `${INODRA_ENDPOINTS[network].warpWs}/warp/${subscriptionId}/ws`;\n}\n","export const SDK_VERSION = \"0.1.0\";\n\n/**\n * Identifies the SDK to Inodra on every request, alongside the API key.\n * Sent on REST, GraphQL, SSE (headers) and gRPC (metadata). Browsers cannot\n * attach headers to WebSocket upgrades, so the Warp WS client omits it.\n */\nexport const SDK_HEADER_NAME = \"x-inodra-sdk\";\nexport const SDK_HEADER_VALUE = `inodra-sdk-ts/${SDK_VERSION}`;\n","import {\n\tauthFromOptions,\n\ttype InodraAuth,\n\ttype ResolvedAuth,\n} from \"./auth.js\";\nimport {\n\tInodraAuthenticationError,\n\tInodraError,\n\tInodraRateLimitError,\n\tInodraTimeoutError,\n} from \"./errors.js\";\nimport { type InodraNetwork, restBaseUrl } from \"./network.js\";\nimport { SDK_HEADER_NAME, SDK_HEADER_VALUE } from \"./version.js\";\n\nexport interface InodraHttpClientOptions {\n\t/** Credentials: an API key string, {apiKey}, {sessionToken}, or a provider. */\n\tauth?: InodraAuth;\n\t/** Shorthand for `auth: { apiKey }`. */\n\tapiKey?: string;\n\t/** Defaults to \"mainnet\". Ignored when baseUrl is set. */\n\tnetwork?: InodraNetwork;\n\t/** Overrides the network-derived base URL (e.g. http://localhost:3000/v1). */\n\tbaseUrl?: string;\n\t/** Retries on 429 and 5xx responses. Defaults to 2. */\n\tmaxRetries?: number;\n\t/** Per-request timeout in milliseconds. Defaults to 30000. */\n\ttimeoutMs?: number;\n\t/** Custom fetch implementation (e.g. for testing or proxying). */\n\tfetch?: typeof globalThis.fetch;\n\t/** Called with rate-limit/credit info after every response that carries it. */\n\tonResponseMeta?: (meta: InodraResponseMeta) => void;\n}\n\nexport interface RequestOptions {\n\tquery?: Record<string, string | number | boolean | undefined>;\n\tbody?: unknown;\n\tsignal?: AbortSignal;\n\t/**\n\t * Marks a POST/PATCH as safe to retry on 5xx. Reads (GET) and idempotent\n\t * writes (PUT/DELETE) retry on 429 and 5xx by default; non-idempotent\n\t * writes retry only on 429 (the request was never processed) unless this\n\t * is set — a 5xx may have been applied server-side.\n\t */\n\tidempotent?: boolean;\n}\n\n/** Rate-limit and credit state reported by the API on each response. */\nexport interface InodraResponseMeta {\n\trateLimit?: {\n\t\tlimit: number;\n\t\tremaining: number;\n\t\t/** Unix epoch (ms) when the window resets. */\n\t\treset: number;\n\t\t/** True when CU quota is exceeded and limits are soft-dropped. */\n\t\tthrottled: boolean;\n\t};\n\tcredits?: {\n\t\tremaining: number;\n\t\tlimit: number;\n\t\t/** ISO date when credits replenish. */\n\t\treplenishDate?: string;\n\t\t/** True when credit accounting is degraded (fail-open). */\n\t\tdegraded: boolean;\n\t};\n\trequestId?: string;\n}\n\nexport class InodraHttpClient {\n\treadonly baseUrl: string;\n\t/** Rate-limit/credit info from the most recent response, if any. */\n\tlastResponseMeta: InodraResponseMeta | undefined;\n\n\tprivate readonly auth: ResolvedAuth;\n\tprivate readonly maxRetries: number;\n\tprivate readonly timeoutMs: number;\n\tprivate readonly fetchImpl: typeof globalThis.fetch;\n\tprivate readonly onResponseMeta?: (meta: InodraResponseMeta) => void;\n\n\tconstructor(options: InodraHttpClientOptions) {\n\t\tthis.auth = authFromOptions(options, \"InodraHttpClient\");\n\t\tthis.baseUrl = (\n\t\t\toptions.baseUrl ?? restBaseUrl(options.network ?? \"mainnet\")\n\t\t).replace(/\\/$/, \"\");\n\t\tthis.maxRetries = options.maxRetries ?? 2;\n\t\tthis.timeoutMs = options.timeoutMs ?? 30_000;\n\t\tthis.fetchImpl = options.fetch ?? globalThis.fetch;\n\t\tthis.onResponseMeta = options.onResponseMeta;\n\t}\n\n\tasync request<T>(\n\t\tmethod: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\",\n\t\tpath: string,\n\t\toptions: RequestOptions = {},\n\t): Promise<T> {\n\t\tconst url = new URL(this.baseUrl + path);\n\t\tfor (const [key, value] of Object.entries(options.query ?? {})) {\n\t\t\tif (value !== undefined) {\n\t\t\t\turl.searchParams.set(key, String(value));\n\t\t\t}\n\t\t}\n\n\t\tconst retryOn5xx =\n\t\t\toptions.idempotent ?? !(method === \"POST\" || method === \"PATCH\");\n\n\t\tlet attempt = 0;\n\t\tfor (;;) {\n\t\t\tconst response = await this.send(url, method, options);\n\t\t\tthis.captureMeta(response);\n\n\t\t\tif (response.ok) {\n\t\t\t\tif (response.status === 204) {\n\t\t\t\t\treturn undefined as T;\n\t\t\t\t}\n\t\t\t\treturn (await response.json()) as T;\n\t\t\t}\n\n\t\t\tconst retryable =\n\t\t\t\tresponse.status === 429 || (retryOn5xx && response.status >= 500);\n\t\t\tif (retryable && attempt < this.maxRetries) {\n\t\t\t\tattempt += 1;\n\t\t\t\tawait sleep(retryDelayMs(response, attempt));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthrow await toError(response);\n\t\t}\n\t}\n\n\tprivate async send(\n\t\turl: URL,\n\t\tmethod: string,\n\t\toptions: RequestOptions,\n\t): Promise<Response> {\n\t\tconst timeoutSignal = AbortSignal.timeout(this.timeoutMs);\n\t\tconst signal = options.signal\n\t\t\t? AbortSignal.any([options.signal, timeoutSignal])\n\t\t\t: timeoutSignal;\n\n\t\tconst { headers: authHeaders } = await this.auth.credentials();\n\n\t\ttry {\n\t\t\treturn await this.fetchImpl(url, {\n\t\t\t\tmethod,\n\t\t\t\theaders: {\n\t\t\t\t\t...authHeaders,\n\t\t\t\t\t[SDK_HEADER_NAME]: SDK_HEADER_VALUE,\n\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\taccept: \"application/json\",\n\t\t\t\t},\n\t\t\t\tbody: options.body === undefined ? undefined : JSON.stringify(options.body),\n\t\t\t\tsignal,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (timeoutSignal.aborted && !options.signal?.aborted) {\n\t\t\t\tthrow new InodraTimeoutError(this.timeoutMs);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate captureMeta(response: Response): void {\n\t\tconst meta = parseResponseMeta(response);\n\t\tif (meta) {\n\t\t\tthis.lastResponseMeta = meta;\n\t\t\tthis.onResponseMeta?.(meta);\n\t\t}\n\t}\n}\n\nexport function parseResponseMeta(\n\tresponse: Response,\n): InodraResponseMeta | undefined {\n\tconst meta: InodraResponseMeta = {};\n\n\tconst limit = header(response, \"x-ratelimit-limit\");\n\tconst remaining = header(response, \"x-ratelimit-remaining\");\n\tconst reset = header(response, \"x-ratelimit-reset\");\n\tif (limit !== undefined && remaining !== undefined) {\n\t\tmeta.rateLimit = {\n\t\t\tlimit,\n\t\t\tremaining,\n\t\t\treset: reset ?? 0,\n\t\t\tthrottled: response.headers.get(\"x-ratelimit-throttle\") !== null,\n\t\t};\n\t}\n\n\tconst creditRemaining = header(response, \"x-inodra-credit-remaining\");\n\tconst creditLimit = header(response, \"x-inodra-credit-limit\");\n\tif (creditRemaining !== undefined && creditLimit !== undefined) {\n\t\tmeta.credits = {\n\t\t\tremaining: creditRemaining,\n\t\t\tlimit: creditLimit,\n\t\t\treplenishDate:\n\t\t\t\tresponse.headers.get(\"x-inodra-credit-replenish-date\") ?? undefined,\n\t\t\tdegraded: response.headers.get(\"x-inodra-credit-degraded\") === \"true\",\n\t\t};\n\t}\n\n\tconst requestId = response.headers.get(\"x-request-id\");\n\tif (requestId) {\n\t\tmeta.requestId = requestId;\n\t}\n\n\tif (!meta.rateLimit && !meta.credits && !meta.requestId) {\n\t\treturn undefined;\n\t}\n\treturn meta;\n}\n\nfunction header(response: Response, name: string): number | undefined {\n\tconst raw = response.headers.get(name);\n\tif (raw === null) {\n\t\treturn undefined;\n\t}\n\tconst value = Number(raw);\n\treturn Number.isFinite(value) ? value : undefined;\n}\n\nasync function toError(response: Response): Promise<InodraError> {\n\tconst requestId = response.headers.get(\"x-request-id\") ?? undefined;\n\tlet body: unknown;\n\ttry {\n\t\tbody = await response.json();\n\t} catch {\n\t\tbody = undefined;\n\t}\n\n\tconst serverMessage = extractField(body, [\"message\", \"error\"]);\n\tconst code = extractField(body, [\"code\"]);\n\n\tif (response.status === 401 || response.status === 403) {\n\t\treturn new InodraAuthenticationError({\n\t\t\tstatus: response.status,\n\t\t\trequestId,\n\t\t\tbody,\n\t\t\tcode,\n\t\t\tmessage: serverMessage,\n\t\t});\n\t}\n\tif (response.status === 429) {\n\t\tconst retryAfter = response.headers.get(\"retry-after\");\n\t\treturn new InodraRateLimitError({\n\t\t\tstatus: response.status,\n\t\t\trequestId,\n\t\t\tbody,\n\t\t\tcode,\n\t\t\tretryAfterSeconds: retryAfter ? Number(retryAfter) : undefined,\n\t\t\tmessage: serverMessage,\n\t\t});\n\t}\n\n\treturn new InodraError(\n\t\tserverMessage ?? `Request failed with status ${response.status}`,\n\t\t{ status: response.status, requestId, body, code },\n\t);\n}\n\nfunction extractField(body: unknown, keys: string[]): string | undefined {\n\tif (typeof body !== \"object\" || body === null) {\n\t\treturn undefined;\n\t}\n\tfor (const key of keys) {\n\t\tconst value = (body as Record<string, unknown>)[key];\n\t\tif (typeof value === \"string\" && value.length > 0) {\n\t\t\treturn value;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction retryDelayMs(response: Response, attempt: number): number {\n\tconst retryAfter = response.headers.get(\"retry-after\");\n\tif (retryAfter) {\n\t\tconst seconds = Number(retryAfter);\n\t\tif (Number.isFinite(seconds)) {\n\t\t\treturn seconds * 1000;\n\t\t}\n\t}\n\treturn 250 * 2 ** (attempt - 1) + Math.random() * 100;\n}\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsCO,SAAS,YAAY,MAAgC;AAC3D,MAAI,OAAO,SAAS,UAAU;AAC7B,WAAO,WAAW,kBAAkB,IAAI,CAAC;AAAA,EAC1C;AACA,MAAI,YAAY,MAAM;AACrB,WAAO,WAAW,kBAAkB,KAAK,MAAM,CAAC;AAAA,EACjD;AACA,MAAI,kBAAkB,MAAM;AAC3B,WAAO,WAAW;AAAA,MACjB,SAAS,EAAE,eAAe,UAAU,KAAK,YAAY,GAAG;AAAA,IACzD,CAAC;AAAA,EACF;AACA,SAAO;AAAA,IACN,aAAa,YAAY,KAAK,eAAe;AAAA,IAC7C,mBAAmB,MAAM;AAAA,EAC1B;AACD;AAMO,SAAS,gBACf,SACA,SACe;AACf,MAAI,QAAQ,SAAS,QAAW;AAC/B,WAAO,YAAY,QAAQ,IAAI;AAAA,EAChC;AACA,MAAI,QAAQ,QAAQ;AACnB,WAAO,YAAY,QAAQ,MAAM;AAAA,EAClC;AACA,QAAM,IAAI,MAAM,GAAG,OAAO,0CAA0C;AACrE;AAoBA,SAAS,kBAAkB,QAAiC;AAC3D,MAAI,CAAC,QAAQ;AACZ,UAAM,IAAI,MAAM,gDAAgD;AAAA,EACjE;AACA,SAAO;AAAA,IACN,SAAS,EAAE,aAAa,OAAO;AAAA,IAC/B,aAAa,EAAE,SAAS,OAAO;AAAA,EAChC;AACD;AAEA,SAAS,WAAW,aAA4C;AAC/D,SAAO;AAAA,IACN,aAAa,YAAY;AAAA,IACzB,mBAAmB,MAAM;AAAA,EAC1B;AACD;;;AC1GO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EAET,YACC,SACA,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BAAmB,EAAE,CAAC,EAAE;AAAA,IACxE,QAAQ,CAAC,IAAY,UACpB,KAAK,KAAK;AAAA,MACT;AAAA,MACA,aAAa,mBAAmB,EAAE,CAAC;AAAA,MACnC,EAAE,MAAM,MAAM;AAAA,IACf;AAAA,IACD,QAAQ,CAAC,OACR,KAAK,KAAK;AAAA,MACT;AAAA,MACA,aAAa,mBAAmB,EAAE,CAAC;AAAA,IACpC;AAAA,EACF;AAAA,EAES,OAAO;AAAA,IACf,mBAAmB,CAAC,UACnB,KAAK,KAAK,QAA8B,QAAQ,gBAAgB;AAAA,MAC/D,MAAM;AAAA,IACP,CAAC;AAAA,IACF,qBAAqB,CAAC,UACrB,KAAK,KAAK,QAA8B,QAAQ,mBAAmB;AAAA,MAClE,MAAM;AAAA,IACP,CAAC;AAAA,IACF,kBAAkB,CAAC,UAClB,KAAK,KAAK,QAA8B,QAAQ,eAAe;AAAA,MAC9D,MAAM;AAAA,IACP,CAAC;AAAA,IACF,oBAAoB,CAAC,UACpB,KAAK,KAAK,QAA8B,QAAQ,iBAAiB;AAAA,MAChE,MAAM;AAAA,IACP,CAAC;AAAA,IACF,MAAM,MAAM,KAAK,KAAK,QAA6B,OAAO,OAAO;AAAA,IACjE,KAAK,CAAC,OACL,KAAK,KAAK,QAAoB,OAAO,SAAS,mBAAmB,EAAE,CAAC,EAAE;AAAA,IACvE,QAAQ,CAAC,IAAY,UACpB,KAAK,KAAK;AAAA,MACT;AAAA,MACA,SAAS,mBAAmB,EAAE,CAAC;AAAA,MAC/B,EAAE,MAAM,MAAM;AAAA,IACf;AAAA,IACD,QAAQ,CAAC,OACR,KAAK,KAAK;AAAA,MACT;AAAA,MACA,SAAS,mBAAmB,EAAE,CAAC;AAAA,IAChC;AAAA,EACF;AACD;","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { C as CreateAddressStreamInput, a as CreateAddressWebhookInput, b as CreateCoinStreamInput, c as CreateCoinWebhookInput, d as CreateEventStreamInput, e as CreateEventWebhookInput, f as CreateObjectStreamInput, g as CreateObjectWebhookInput, h as CreateStreamResponse, i as CreateWebhookResponse, D as DeleteStreamResponse, j as DeleteWebhookResponse, l as InodraManagementClient, m as InodraManagementClientOptions, L as ListStreamsResponse, o as ListWebhooksResponse, U as UpdateStreamInput, p as UpdateStreamResponse, q as UpdateWebhookInput, r as UpdateWebhookResponse, W as WarpStream, s as Webhook } from './index-CVO2Kj8a.cjs';
|
|
2
|
+
import './network-CEg2MJY3.cjs';
|
package/dist/manage.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { C as CreateAddressStreamInput, a as CreateAddressWebhookInput, b as CreateCoinStreamInput, c as CreateCoinWebhookInput, d as CreateEventStreamInput, e as CreateEventWebhookInput, f as CreateObjectStreamInput, g as CreateObjectWebhookInput, h as CreateStreamResponse, i as CreateWebhookResponse, D as DeleteStreamResponse, j as DeleteWebhookResponse, l as InodraManagementClient, m as InodraManagementClientOptions, L as ListStreamsResponse, o as ListWebhooksResponse, U as UpdateStreamInput, p as UpdateStreamResponse, q as UpdateWebhookInput, r as UpdateWebhookResponse, W as WarpStream, s as Webhook } from './index-CGBN_EI5.js';
|
|
2
|
+
import './network-CEg2MJY3.js';
|
package/dist/manage.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable authentication for every Inodra transport.
|
|
3
|
+
*
|
|
4
|
+
* Most users pass an API key. The provider shape exists so future credential
|
|
5
|
+
* types (x402 wallet session tokens, refreshing vault-issued keys) slot in
|
|
6
|
+
* without changing any client constructor.
|
|
7
|
+
*/
|
|
8
|
+
interface AuthCredentials {
|
|
9
|
+
/** Sent as HTTP headers (REST, SSE, GraphQL) and gRPC metadata. */
|
|
10
|
+
headers: Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Sent as URL query parameters on transports that cannot carry headers
|
|
13
|
+
* (WebSocket upgrades in browsers). Omit to disallow such transports.
|
|
14
|
+
*/
|
|
15
|
+
queryParams?: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
type InodraAuth = string | {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
} | {
|
|
20
|
+
sessionToken: string;
|
|
21
|
+
} | {
|
|
22
|
+
getCredentials: () => AuthCredentials | Promise<AuthCredentials>;
|
|
23
|
+
};
|
|
24
|
+
/** Normalized auth handle used internally by every transport. */
|
|
25
|
+
interface ResolvedAuth {
|
|
26
|
+
/** Resolve credentials. Called per request on REST/SSE, per connect on WS. */
|
|
27
|
+
credentials(): Promise<AuthCredentials>;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve credentials synchronously, or undefined for dynamic providers.
|
|
30
|
+
* Used by clients whose underlying transport takes static headers
|
|
31
|
+
* (gRPC, GraphQL).
|
|
32
|
+
*/
|
|
33
|
+
staticCredentials(): AuthCredentials | undefined;
|
|
34
|
+
}
|
|
35
|
+
declare function resolveAuth(auth: InodraAuth): ResolvedAuth;
|
|
36
|
+
|
|
37
|
+
type InodraNetwork = "mainnet" | "testnet";
|
|
38
|
+
/**
|
|
39
|
+
* Canonical Inodra endpoints per network and protocol.
|
|
40
|
+
*/
|
|
41
|
+
declare const INODRA_ENDPOINTS: {
|
|
42
|
+
readonly mainnet: {
|
|
43
|
+
readonly rest: "https://mainnet-api.inodra.com/v1";
|
|
44
|
+
readonly graphql: "https://mainnet-api.inodra.com/v1/graphql";
|
|
45
|
+
/** host:port for native gRPC transports */
|
|
46
|
+
readonly grpc: "mainnet-grpc.inodra.com:443";
|
|
47
|
+
/** base URL for gRPC-Web transports */
|
|
48
|
+
readonly grpcWeb: "https://mainnet-grpc.inodra.com";
|
|
49
|
+
readonly warpWs: "wss://mainnet-api.inodra.com/v1";
|
|
50
|
+
};
|
|
51
|
+
readonly testnet: {
|
|
52
|
+
readonly rest: "https://testnet-api.inodra.com/v1";
|
|
53
|
+
readonly graphql: "https://testnet-api.inodra.com/v1/graphql";
|
|
54
|
+
readonly grpc: "testnet-grpc.inodra.com:443";
|
|
55
|
+
readonly grpcWeb: "https://testnet-grpc.inodra.com";
|
|
56
|
+
readonly warpWs: "wss://testnet-api.inodra.com/v1";
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { type AuthCredentials as A, type InodraAuth as I, type InodraNetwork as a, INODRA_ENDPOINTS as b, resolveAuth as r };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable authentication for every Inodra transport.
|
|
3
|
+
*
|
|
4
|
+
* Most users pass an API key. The provider shape exists so future credential
|
|
5
|
+
* types (x402 wallet session tokens, refreshing vault-issued keys) slot in
|
|
6
|
+
* without changing any client constructor.
|
|
7
|
+
*/
|
|
8
|
+
interface AuthCredentials {
|
|
9
|
+
/** Sent as HTTP headers (REST, SSE, GraphQL) and gRPC metadata. */
|
|
10
|
+
headers: Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Sent as URL query parameters on transports that cannot carry headers
|
|
13
|
+
* (WebSocket upgrades in browsers). Omit to disallow such transports.
|
|
14
|
+
*/
|
|
15
|
+
queryParams?: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
type InodraAuth = string | {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
} | {
|
|
20
|
+
sessionToken: string;
|
|
21
|
+
} | {
|
|
22
|
+
getCredentials: () => AuthCredentials | Promise<AuthCredentials>;
|
|
23
|
+
};
|
|
24
|
+
/** Normalized auth handle used internally by every transport. */
|
|
25
|
+
interface ResolvedAuth {
|
|
26
|
+
/** Resolve credentials. Called per request on REST/SSE, per connect on WS. */
|
|
27
|
+
credentials(): Promise<AuthCredentials>;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve credentials synchronously, or undefined for dynamic providers.
|
|
30
|
+
* Used by clients whose underlying transport takes static headers
|
|
31
|
+
* (gRPC, GraphQL).
|
|
32
|
+
*/
|
|
33
|
+
staticCredentials(): AuthCredentials | undefined;
|
|
34
|
+
}
|
|
35
|
+
declare function resolveAuth(auth: InodraAuth): ResolvedAuth;
|
|
36
|
+
|
|
37
|
+
type InodraNetwork = "mainnet" | "testnet";
|
|
38
|
+
/**
|
|
39
|
+
* Canonical Inodra endpoints per network and protocol.
|
|
40
|
+
*/
|
|
41
|
+
declare const INODRA_ENDPOINTS: {
|
|
42
|
+
readonly mainnet: {
|
|
43
|
+
readonly rest: "https://mainnet-api.inodra.com/v1";
|
|
44
|
+
readonly graphql: "https://mainnet-api.inodra.com/v1/graphql";
|
|
45
|
+
/** host:port for native gRPC transports */
|
|
46
|
+
readonly grpc: "mainnet-grpc.inodra.com:443";
|
|
47
|
+
/** base URL for gRPC-Web transports */
|
|
48
|
+
readonly grpcWeb: "https://mainnet-grpc.inodra.com";
|
|
49
|
+
readonly warpWs: "wss://mainnet-api.inodra.com/v1";
|
|
50
|
+
};
|
|
51
|
+
readonly testnet: {
|
|
52
|
+
readonly rest: "https://testnet-api.inodra.com/v1";
|
|
53
|
+
readonly graphql: "https://testnet-api.inodra.com/v1/graphql";
|
|
54
|
+
readonly grpc: "testnet-grpc.inodra.com:443";
|
|
55
|
+
readonly grpcWeb: "https://testnet-grpc.inodra.com";
|
|
56
|
+
readonly warpWs: "wss://testnet-api.inodra.com/v1";
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { type AuthCredentials as A, type InodraAuth as I, type InodraNetwork as a, INODRA_ENDPOINTS as b, resolveAuth as r };
|