@bluvo/sdk-ts
Version:
Bluvo SDK for TypeScript
1,654 lines (1,642 loc) • 181 kB
JavaScript
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __await = function(promise, isYieldStar) {
this[0] = promise;
this[1] = isYieldStar;
};
var __asyncGenerator = (__this, __arguments, generator) => {
var resume = (k, v, yes, no) => {
try {
var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
} catch (e) {
no(e);
}
}, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
};
// generated/types.gen.ts
var SchemaEnum = {
COINBASE: "coinbase",
KRAKEN: "kraken",
BINANCE: "binance",
LOCAL_CEX: "local-cex",
BINANCE_WEB: "binance-web",
BYBIT_WEB: "bybit-web"
};
var StatusEnum = {
LIVE: "live",
OFFLINE: "offline",
MAINTENANCE: "maintenance",
COMING_SOON: "coming_soon"
};
var ExchangeEnum = {
ACE: "ace",
ASCENDEX: "ascendex",
BEQUANT: "bequant",
BIGONE: "bigone",
BINANCE: "binance",
BINANCE_WEB: "binance-web",
COINBASE: "coinbase",
BINANCEUS: "binanceus",
BINGX: "bingx",
BIT2C: "bit2c",
BITBANK: "bitbank",
BITBNS: "bitbns",
BITCOINCOM: "bitcoincom",
BITFINEX: "bitfinex",
BITFLYER: "bitflyer",
BITGET: "bitget",
BITHUMB: "bithumb",
BITMART: "bitmart",
BITMEX: "bitmex",
BITOPRO: "bitopro",
BITPANDA: "bitpanda",
BITRUE: "bitrue",
BITSO: "bitso",
BITSTAMP: "bitstamp",
BITTEAM: "bitteam",
BITVAVO: "bitvavo",
BYBIT: "bybit",
BYBIT_WEB: "bybit-web",
BL3P: "bl3p",
BLOCKCHAINCOM: "blockchaincom",
BLOFIN: "blofin",
BTCALPHA: "btcalpha",
BTCBOX: "btcbox",
BTCMARKETS: "btcmarkets",
BTCTURK: "btcturk",
CEX: "cex",
COINCHECK: "coincheck",
COINEX: "coinex",
COINLIST: "coinlist",
COINMATE: "coinmate",
COINMETRO: "coinmetro",
COINONE: "coinone",
COINSPH: "coinsph",
COINSPOT: "coinspot",
CRYPTOCOM: "cryptocom",
DELTA: "delta",
DERIBIT: "deribit",
DIGIFINEX: "digifinex",
EXMO: "exmo",
FMFWIO: "fmfwio",
GATE: "gate",
GATEIO: "gateio",
GEMINI: "gemini",
HASHKEY: "hashkey",
HITBTC: "hitbtc",
HOLLAEX: "hollaex",
HTX: "htx",
HUOBI: "huobi",
HUOBIJP: "huobijp",
HYPERLIQUID: "hyperliquid",
INDEPENDENTRESERVE: "independentreserve",
INDODAX: "indodax",
KRAKEN: "kraken",
KRAKENFUTURES: "krakenfutures",
KUCOIN: "kucoin",
KUCOINFUTURES: "kucoinfutures",
LATOKEN: "latoken",
LBANK: "lbank",
LUNO: "luno",
MERCADO: "mercado",
MEXC: "mexc",
NDAX: "ndax",
NOVADAX: "novadax",
OCEANEX: "oceanex",
OKCOIN: "okcoin",
OKX: "okx",
ONETRADING: "onetrading",
OXFUN: "oxfun",
P2B: "p2b",
PARADEX: "paradex",
PAYMIUM: "paymium",
PHEMEX: "phemex",
POLONIEX: "poloniex",
POLONIEXFUTURES: "poloniexfutures",
PROBIT: "probit",
TIMEX: "timex",
TRADEOGRE: "tradeogre",
UPBIT: "upbit",
VERTEX: "vertex",
WAVESEXCHANGE: "wavesexchange",
WHITEBIT: "whitebit",
WOO: "woo",
WOOFIPRO: "woofipro",
XT: "xt",
YOBIT: "yobit",
ZAIF: "zaif",
ZONDA: "zonda",
LOCAL_CEX: "local-cex"
};
var StatusEnum2 = {
SUCCESS: "SUCCESS",
INVALID_API_CREDENTIALS: "INVALID_API_CREDENTIALS"
};
var TypeEnum = {
WALLET_NOT_FOUND: "WALLET_NOT_FOUND",
WALLET_IDENTITY_NOT_FOUND: "WALLET_IDENTITY_NOT_FOUND"
};
var SchemaEnum2 = {
ACE: "ace",
ASCENDEX: "ascendex",
BEQUANT: "bequant",
BIGONE: "bigone",
BINANCE: "binance",
BINANCE_WEB: "binance-web",
COINBASE: "coinbase",
BINANCEUS: "binanceus",
BINGX: "bingx",
BIT2C: "bit2c",
BITBANK: "bitbank",
BITBNS: "bitbns",
BITCOINCOM: "bitcoincom",
BITFINEX: "bitfinex",
BITFLYER: "bitflyer",
BITGET: "bitget",
BITHUMB: "bithumb",
BITMART: "bitmart",
BITMEX: "bitmex",
BITOPRO: "bitopro",
BITPANDA: "bitpanda",
BITRUE: "bitrue",
BITSO: "bitso",
BITSTAMP: "bitstamp",
BITTEAM: "bitteam",
BITVAVO: "bitvavo",
BYBIT: "bybit",
BYBIT_WEB: "bybit-web",
BL3P: "bl3p",
BLOCKCHAINCOM: "blockchaincom",
BLOFIN: "blofin",
BTCALPHA: "btcalpha",
BTCBOX: "btcbox",
BTCMARKETS: "btcmarkets",
BTCTURK: "btcturk",
CEX: "cex",
COINCHECK: "coincheck",
COINEX: "coinex",
COINLIST: "coinlist",
COINMATE: "coinmate",
COINMETRO: "coinmetro",
COINONE: "coinone",
COINSPH: "coinsph",
COINSPOT: "coinspot",
CRYPTOCOM: "cryptocom",
DELTA: "delta",
DERIBIT: "deribit",
DIGIFINEX: "digifinex",
EXMO: "exmo",
FMFWIO: "fmfwio",
GATE: "gate",
GATEIO: "gateio",
GEMINI: "gemini",
HASHKEY: "hashkey",
HITBTC: "hitbtc",
HOLLAEX: "hollaex",
HTX: "htx",
HUOBI: "huobi",
HUOBIJP: "huobijp",
HYPERLIQUID: "hyperliquid",
INDEPENDENTRESERVE: "independentreserve",
INDODAX: "indodax",
KRAKEN: "kraken",
KRAKENFUTURES: "krakenfutures",
KUCOIN: "kucoin",
KUCOINFUTURES: "kucoinfutures",
LATOKEN: "latoken",
LBANK: "lbank",
LUNO: "luno",
MERCADO: "mercado",
MEXC: "mexc",
NDAX: "ndax",
NOVADAX: "novadax",
OCEANEX: "oceanex",
OKCOIN: "okcoin",
OKX: "okx",
ONETRADING: "onetrading",
OXFUN: "oxfun",
P2B: "p2b",
PARADEX: "paradex",
PAYMIUM: "paymium",
PHEMEX: "phemex",
POLONIEX: "poloniex",
POLONIEXFUTURES: "poloniexfutures",
PROBIT: "probit",
TIMEX: "timex",
TRADEOGRE: "tradeogre",
UPBIT: "upbit",
VERTEX: "vertex",
WAVESEXCHANGE: "wavesexchange",
WHITEBIT: "whitebit",
WOO: "woo",
WOOFIPRO: "woofipro",
XT: "xt",
YOBIT: "yobit",
ZAIF: "zaif",
ZONDA: "zonda",
LOCAL_CEX: "local-cex",
NULL: null
};
var SchemaEnum3 = {
TRUE: "true",
FALSE: "false",
NULL: null
};
var TypeEnum2 = {
DEPOSIT: "deposit",
WITHDRAWAL: "withdrawal",
TRANSACTION: "transaction"
};
var DirectionEnum = {
IN: "in",
OUT: "out",
NULL: null
};
var FiatCurrencyEnum = {
USD: "USD",
EUR: "EUR",
NULL: null
};
var StatusEnum3 = {
PENDING: "pending",
OK: "ok",
FAILED: "failed",
CANCELED: "canceled"
};
var CategoryEnum = {
EXCHANGE_WITHDRAWAL_FEE: "exchange_withdrawal_fee",
NETWORK_FEE: "network_fee",
PROVIDER_FEE: "provider_fee",
OTHER: "other"
};
var TypeEnum3 = {
GENERIC_NOT_FOUND: "GENERIC_NOT_FOUND",
GENERIC_UNAUTHORIZED: "GENERIC_UNAUTHORIZED",
GENERIC_INTERNAL_SERVER_ERROR: "GENERIC_INTERNAL_SERVER_ERROR",
GENERIC_VALIDATION_ERROR: "GENERIC_VALIDATION_ERROR",
GENERIC_INVALID_REQUEST: "GENERIC_INVALID_REQUEST",
GENERIC_RATE_LIMIT_EXCEEDED: "GENERIC_RATE_LIMIT_EXCEEDED",
APIKEY_INSUFFICIENT_PERMISSIONS: "APIKEY_INSUFFICIENT_PERMISSIONS",
WALLET_NOT_FOUND: "WALLET_NOT_FOUND",
WALLET_INVALID_CREDENTIALS: "WALLET_INVALID_CREDENTIALS",
WALLET_IDENTITY_NOT_FOUND: "WALLET_IDENTITY_NOT_FOUND",
QUOTE_NOT_FOUND: "QUOTE_NOT_FOUND",
QUOTE_EXPIRED: "QUOTE_EXPIRED",
WITHDRAWAL_INSUFFICIENT_BALANCE: "WITHDRAWAL_INSUFFICIENT_BALANCE",
WITHDRAWAL_INSUFFICIENT_BALANCE_FOR_FEE: "WITHDRAWAL_INSUFFICIENT_BALANCE_FOR_FEE",
WITHDRAWAL_INVALID_ADDRESS: "WITHDRAWAL_INVALID_ADDRESS",
WITHDRAWAL_NETWORK_NOT_SUPPORTED: "WITHDRAWAL_NETWORK_NOT_SUPPORTED",
WITHDRAWAL_TOO_MANY_ADDRESSES: "WITHDRAWAL_TOO_MANY_ADDRESSES",
WITHDRAWAL_AMOUNT_BELOW_MINIMUM: "WITHDRAWAL_AMOUNT_BELOW_MINIMUM",
WITHDRAWAL_AMOUNT_ABOVE_MAXIMUM: "WITHDRAWAL_AMOUNT_ABOVE_MAXIMUM",
WITHDRAWAL_ASSET_NOT_SUPPORTED: "WITHDRAWAL_ASSET_NOT_SUPPORTED",
WITHDRAWAL_PROVIDER_ERROR: "WITHDRAWAL_PROVIDER_ERROR",
WITHDRAWAL_2FA_REQUIRED_TOTP: "WITHDRAWAL_2FA_REQUIRED_TOTP",
WITHDRAWAL_2FA_REQUIRED_SMS: "WITHDRAWAL_2FA_REQUIRED_SMS",
WITHDRAWAL_2FA_REQUIRED_FACE_RECOGNITION: "WITHDRAWAL_2FA_REQUIRED_FACE_RECOGNITION",
WITHDRAWAL_2FA_REQUIRED_EMAIL: "WITHDRAWAL_2FA_REQUIRED_EMAIL",
WITHDRAWAL_2FA_REQUIRED_YUBIKEY: "WITHDRAWAL_2FA_REQUIRED_YUBIKEY",
WITHDRAWAL_2FA_REQUIRED_PASSPHRASE: "WITHDRAWAL_2FA_REQUIRED_PASSPHRASE",
WITHDRAWAL_2FA_REQUIRED_MULTI_STEPS: "WITHDRAWAL_2FA_REQUIRED_MULTI_STEPS",
WITHDRAWAL_2FA_INCOMPLETE: "WITHDRAWAL_2FA_INCOMPLETE",
WITHDRAWAL_2FA_INVALID: "WITHDRAWAL_2FA_INVALID",
WITHDRAWAL_2FA_METHOD_NOT_SUPPORTED: "WITHDRAWAL_2FA_METHOD_NOT_SUPPORTED",
WITHDRAWAL_KYC_REQUIRED: "WITHDRAWAL_KYC_REQUIRED",
WITHDRAWAL_EMAIL_UNVERIFIED: "WITHDRAWAL_EMAIL_UNVERIFIED",
WITHDRAWAL_RATE_LIMIT_EXCEEDED: "WITHDRAWAL_RATE_LIMIT_EXCEEDED",
OAUTH_AUTHORIZATION_FAILED: "OAUTH_AUTHORIZATION_FAILED",
OAUTH_TOKEN_EXCHANGE_FAILED: "OAUTH_TOKEN_EXCHANGE_FAILED",
OAUTH_INVALID_STATE: "OAUTH_INVALID_STATE",
OAUTH_INSUFFICIENT_SCOPE: "OAUTH_INSUFFICIENT_SCOPE",
OAUTH_QR_CODE_UNAVAILABLE: "OAUTH_QR_CODE_UNAVAILABLE",
OAUTH_COUNTRY_NOT_DETECTED: "OAUTH_COUNTRY_NOT_DETECTED",
OAUTH_COUNTRY_NOT_SUPPORTED: "OAUTH_COUNTRY_NOT_SUPPORTED",
OAUTH_COUNTRY_CODE_INVALID: "OAUTH_COUNTRY_CODE_INVALID",
WEBHOOK_SIGNATURE_INVALID: "WEBHOOK_SIGNATURE_INVALID",
WEBHOOK_MISSING_HEADERS: "WEBHOOK_MISSING_HEADERS",
WEBHOOK_INVALID_TIMESTAMP: "WEBHOOK_INVALID_TIMESTAMP",
CACHE_MISS: "CACHE_MISS",
CACHE_EXPIRED: "CACHE_EXPIRED",
CACHE_INVALID_PATH: "CACHE_INVALID_PATH",
WITHDRAWAL_DRY_RUN_COMPLETE: "WITHDRAWAL_DRY_RUN_COMPLETE",
ENRICHMENT_NETWORK_NOT_SUPPORTED: "ENRICHMENT_NETWORK_NOT_SUPPORTED",
ENRICHMENT_TIMEOUT: "ENRICHMENT_TIMEOUT",
ENRICHMENT_API_ERROR: "ENRICHMENT_API_ERROR"
};
var TypeEnum4 = {
GOOGLE: "GOOGLE",
EMAIL: "EMAIL",
FACE: "FACE",
SMS: "SMS",
ROAMING_FIDO: "ROAMING_FIDO"
};
var StatusEnum4 = {
PENDING: "pending",
SUCCESS: "success",
FAILED: "failed"
};
var RelationEnum = {
AND: "AND",
OR: "OR"
};
// generated/core/bodySerializer.gen.ts
var jsonBodySerializer = {
bodySerializer: (body) => JSON.stringify(
body,
(_key, value) => typeof value === "bigint" ? value.toString() : value
)
};
// generated/core/serverSentEvents.gen.ts
var createSseClient = (_a) => {
var _b = _a, {
onRequest,
onSseError,
onSseEvent,
responseTransformer,
responseValidator,
sseDefaultRetryDelay,
sseMaxRetryAttempts,
sseMaxRetryDelay,
sseSleepFn,
url
} = _b, options = __objRest(_b, [
"onRequest",
"onSseError",
"onSseEvent",
"responseTransformer",
"responseValidator",
"sseDefaultRetryDelay",
"sseMaxRetryAttempts",
"sseMaxRetryDelay",
"sseSleepFn",
"url"
]);
let lastEventId;
const sleep = sseSleepFn != null ? sseSleepFn : ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
const createStream = function() {
return __asyncGenerator(this, null, function* () {
var _a2, _b2, _c;
let retryDelay = sseDefaultRetryDelay != null ? sseDefaultRetryDelay : 3e3;
let attempt = 0;
const signal = (_a2 = options.signal) != null ? _a2 : new AbortController().signal;
while (true) {
if (signal.aborted) break;
attempt++;
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
if (lastEventId !== void 0) {
headers.set("Last-Event-ID", lastEventId);
}
try {
const requestInit = __spreadProps(__spreadValues({
redirect: "follow"
}, options), {
body: options.serializedBody,
headers,
signal
});
let request = new Request(url, requestInit);
if (onRequest) {
request = yield new __await(onRequest(url, requestInit));
}
const _fetch = (_b2 = options.fetch) != null ? _b2 : globalThis.fetch;
const response = yield new __await(_fetch(request));
if (!response.ok)
throw new Error(
`SSE failed: ${response.status} ${response.statusText}`
);
if (!response.body) throw new Error("No body in SSE response");
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
let buffer = "";
const abortHandler = () => {
try {
reader.cancel();
} catch (e) {
}
};
signal.addEventListener("abort", abortHandler);
try {
while (true) {
const { done, value } = yield new __await(reader.read());
if (done) break;
buffer += value;
const chunks = buffer.split("\n\n");
buffer = (_c = chunks.pop()) != null ? _c : "";
for (const chunk of chunks) {
const lines = chunk.split("\n");
const dataLines = [];
let eventName;
for (const line of lines) {
if (line.startsWith("data:")) {
dataLines.push(line.replace(/^data:\s*/, ""));
} else if (line.startsWith("event:")) {
eventName = line.replace(/^event:\s*/, "");
} else if (line.startsWith("id:")) {
lastEventId = line.replace(/^id:\s*/, "");
} else if (line.startsWith("retry:")) {
const parsed = Number.parseInt(
line.replace(/^retry:\s*/, ""),
10
);
if (!Number.isNaN(parsed)) {
retryDelay = parsed;
}
}
}
let data;
let parsedJson = false;
if (dataLines.length) {
const rawData = dataLines.join("\n");
try {
data = JSON.parse(rawData);
parsedJson = true;
} catch (e) {
data = rawData;
}
}
if (parsedJson) {
if (responseValidator) {
yield new __await(responseValidator(data));
}
if (responseTransformer) {
data = yield new __await(responseTransformer(data));
}
}
onSseEvent == null ? void 0 : onSseEvent({
data,
event: eventName,
id: lastEventId,
retry: retryDelay
});
if (dataLines.length) {
yield data;
}
}
}
} finally {
signal.removeEventListener("abort", abortHandler);
reader.releaseLock();
}
break;
} catch (error) {
onSseError == null ? void 0 : onSseError(error);
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
break;
}
const backoff = Math.min(
retryDelay * 2 ** (attempt - 1),
sseMaxRetryDelay != null ? sseMaxRetryDelay : 3e4
);
yield new __await(sleep(backoff));
}
}
});
};
const stream = createStream();
return { stream };
};
// generated/core/pathSerializer.gen.ts
var separatorArrayExplode = (style) => {
switch (style) {
case "label":
return ".";
case "matrix":
return ";";
case "simple":
return ",";
default:
return "&";
}
};
var separatorArrayNoExplode = (style) => {
switch (style) {
case "form":
return ",";
case "pipeDelimited":
return "|";
case "spaceDelimited":
return "%20";
default:
return ",";
}
};
var separatorObjectExplode = (style) => {
switch (style) {
case "label":
return ".";
case "matrix":
return ";";
case "simple":
return ",";
default:
return "&";
}
};
var serializeArrayParam = ({
allowReserved,
explode,
name,
style,
value
}) => {
if (!explode) {
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
switch (style) {
case "label":
return `.${joinedValues2}`;
case "matrix":
return `;${name}=${joinedValues2}`;
case "simple":
return joinedValues2;
default:
return `${name}=${joinedValues2}`;
}
}
const separator = separatorArrayExplode(style);
const joinedValues = value.map((v) => {
if (style === "label" || style === "simple") {
return allowReserved ? v : encodeURIComponent(v);
}
return serializePrimitiveParam({
allowReserved,
name,
value: v
});
}).join(separator);
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
};
var serializePrimitiveParam = ({
allowReserved,
name,
value
}) => {
if (value === void 0 || value === null) {
return "";
}
if (typeof value === "object") {
throw new Error(
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
);
}
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
};
var serializeObjectParam = ({
allowReserved,
explode,
name,
style,
value,
valueOnly
}) => {
if (value instanceof Date) {
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
}
if (style !== "deepObject" && !explode) {
let values = [];
Object.entries(value).forEach(([key, v]) => {
values = [
...values,
key,
allowReserved ? v : encodeURIComponent(v)
];
});
const joinedValues2 = values.join(",");
switch (style) {
case "form":
return `${name}=${joinedValues2}`;
case "label":
return `.${joinedValues2}`;
case "matrix":
return `;${name}=${joinedValues2}`;
default:
return joinedValues2;
}
}
const separator = separatorObjectExplode(style);
const joinedValues = Object.entries(value).map(
([key, v]) => serializePrimitiveParam({
allowReserved,
name: style === "deepObject" ? `${name}[${key}]` : key,
value: v
})
).join(separator);
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
};
// generated/core/utils.gen.ts
var PATH_PARAM_RE = /\{[^{}]+\}/g;
var defaultPathSerializer = ({ path, url: _url }) => {
let url = _url;
const matches = _url.match(PATH_PARAM_RE);
if (matches) {
for (const match of matches) {
let explode = false;
let name = match.substring(1, match.length - 1);
let style = "simple";
if (name.endsWith("*")) {
explode = true;
name = name.substring(0, name.length - 1);
}
if (name.startsWith(".")) {
name = name.substring(1);
style = "label";
} else if (name.startsWith(";")) {
name = name.substring(1);
style = "matrix";
}
const value = path[name];
if (value === void 0 || value === null) {
continue;
}
if (Array.isArray(value)) {
url = url.replace(
match,
serializeArrayParam({ explode, name, style, value })
);
continue;
}
if (typeof value === "object") {
url = url.replace(
match,
serializeObjectParam({
explode,
name,
style,
value,
valueOnly: true
})
);
continue;
}
if (style === "matrix") {
url = url.replace(
match,
`;${serializePrimitiveParam({
name,
value
})}`
);
continue;
}
const replaceValue = encodeURIComponent(
style === "label" ? `.${value}` : value
);
url = url.replace(match, replaceValue);
}
}
return url;
};
var getUrl = ({
baseUrl,
path,
query,
querySerializer,
url: _url
}) => {
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
let url = (baseUrl != null ? baseUrl : "") + pathUrl;
if (path) {
url = defaultPathSerializer({ path, url });
}
let search = query ? querySerializer(query) : "";
if (search.startsWith("?")) {
search = search.substring(1);
}
if (search) {
url += `?${search}`;
}
return url;
};
function getValidRequestBody(options) {
const hasBody = options.body !== void 0;
const isSerializedBody = hasBody && options.bodySerializer;
if (isSerializedBody) {
if ("serializedBody" in options) {
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
return hasSerializedBody ? options.serializedBody : null;
}
return options.body !== "" ? options.body : null;
}
if (hasBody) {
return options.body;
}
return void 0;
}
// generated/core/auth.gen.ts
var getAuthToken = async (auth, callback) => {
const token = typeof callback === "function" ? await callback(auth) : callback;
if (!token) {
return;
}
if (auth.scheme === "bearer") {
return `Bearer ${token}`;
}
if (auth.scheme === "basic") {
return `Basic ${btoa(token)}`;
}
return token;
};
// generated/client/utils.gen.ts
var createQuerySerializer = (_a = {}) => {
var _b = _a, {
parameters = {}
} = _b, args = __objRest(_b, [
"parameters"
]);
const querySerializer = (queryParams) => {
const search = [];
if (queryParams && typeof queryParams === "object") {
for (const name in queryParams) {
const value = queryParams[name];
if (value === void 0 || value === null) {
continue;
}
const options = parameters[name] || args;
if (Array.isArray(value)) {
const serializedArray = serializeArrayParam(__spreadValues({
allowReserved: options.allowReserved,
explode: true,
name,
style: "form",
value
}, options.array));
if (serializedArray) search.push(serializedArray);
} else if (typeof value === "object") {
const serializedObject = serializeObjectParam(__spreadValues({
allowReserved: options.allowReserved,
explode: true,
name,
style: "deepObject",
value
}, options.object));
if (serializedObject) search.push(serializedObject);
} else {
const serializedPrimitive = serializePrimitiveParam({
allowReserved: options.allowReserved,
name,
value
});
if (serializedPrimitive) search.push(serializedPrimitive);
}
}
}
return search.join("&");
};
return querySerializer;
};
var getParseAs = (contentType) => {
var _a;
if (!contentType) {
return "stream";
}
const cleanContent = (_a = contentType.split(";")[0]) == null ? void 0 : _a.trim();
if (!cleanContent) {
return;
}
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
return "json";
}
if (cleanContent === "multipart/form-data") {
return "formData";
}
if (["application/", "audio/", "image/", "video/"].some(
(type) => cleanContent.startsWith(type)
)) {
return "blob";
}
if (cleanContent.startsWith("text/")) {
return "text";
}
return;
};
var checkForExistence = (options, name) => {
var _a, _b;
if (!name) {
return false;
}
if (options.headers.has(name) || ((_a = options.query) == null ? void 0 : _a[name]) || ((_b = options.headers.get("Cookie")) == null ? void 0 : _b.includes(`${name}=`))) {
return true;
}
return false;
};
var setAuthParams = async (_a) => {
var _b = _a, {
security
} = _b, options = __objRest(_b, [
"security"
]);
var _a2;
for (const auth of security) {
if (checkForExistence(options, auth.name)) {
continue;
}
const token = await getAuthToken(auth, options.auth);
if (!token) {
continue;
}
const name = (_a2 = auth.name) != null ? _a2 : "Authorization";
switch (auth.in) {
case "query":
if (!options.query) {
options.query = {};
}
options.query[name] = token;
break;
case "cookie":
options.headers.append("Cookie", `${name}=${token}`);
break;
case "header":
default:
options.headers.set(name, token);
break;
}
}
};
var buildUrl = (options) => getUrl({
baseUrl: options.baseUrl,
path: options.path,
query: options.query,
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
url: options.url
});
var mergeConfigs = (a, b) => {
var _a;
const config = __spreadValues(__spreadValues({}, a), b);
if ((_a = config.baseUrl) == null ? void 0 : _a.endsWith("/")) {
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
}
config.headers = mergeHeaders(a.headers, b.headers);
return config;
};
var headersEntries = (headers) => {
const entries = [];
headers.forEach((value, key) => {
entries.push([key, value]);
});
return entries;
};
var mergeHeaders = (...headers) => {
const mergedHeaders = new Headers();
for (const header of headers) {
if (!header) {
continue;
}
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
for (const [key, value] of iterator) {
if (value === null) {
mergedHeaders.delete(key);
} else if (Array.isArray(value)) {
for (const v of value) {
mergedHeaders.append(key, v);
}
} else if (value !== void 0) {
mergedHeaders.set(
key,
typeof value === "object" ? JSON.stringify(value) : value
);
}
}
}
return mergedHeaders;
};
var Interceptors = class {
constructor() {
this.fns = [];
}
clear() {
this.fns = [];
}
eject(id) {
const index = this.getInterceptorIndex(id);
if (this.fns[index]) {
this.fns[index] = null;
}
}
exists(id) {
const index = this.getInterceptorIndex(id);
return Boolean(this.fns[index]);
}
getInterceptorIndex(id) {
if (typeof id === "number") {
return this.fns[id] ? id : -1;
}
return this.fns.indexOf(id);
}
update(id, fn) {
const index = this.getInterceptorIndex(id);
if (this.fns[index]) {
this.fns[index] = fn;
return id;
}
return false;
}
use(fn) {
this.fns.push(fn);
return this.fns.length - 1;
}
};
var createInterceptors = () => ({
error: new Interceptors(),
request: new Interceptors(),
response: new Interceptors()
});
var defaultQuerySerializer = createQuerySerializer({
allowReserved: false,
array: {
explode: true,
style: "form"
},
object: {
explode: true,
style: "deepObject"
}
});
var defaultHeaders = {
"Content-Type": "application/json"
};
var createConfig = (override = {}) => __spreadValues(__spreadProps(__spreadValues({}, jsonBodySerializer), {
headers: defaultHeaders,
parseAs: "auto",
querySerializer: defaultQuerySerializer
}), override);
// generated/client/client.gen.ts
var createClient = (config = {}) => {
let _config = mergeConfigs(createConfig(), config);
const getConfig = () => __spreadValues({}, _config);
const setConfig = (config2) => {
_config = mergeConfigs(_config, config2);
return getConfig();
};
const interceptors = createInterceptors();
const beforeRequest = async (options) => {
var _a, _b;
const opts = __spreadProps(__spreadValues(__spreadValues({}, _config), options), {
fetch: (_b = (_a = options.fetch) != null ? _a : _config.fetch) != null ? _b : globalThis.fetch,
headers: mergeHeaders(_config.headers, options.headers),
serializedBody: void 0
});
if (opts.security) {
await setAuthParams(__spreadProps(__spreadValues({}, opts), {
security: opts.security
}));
}
if (opts.requestValidator) {
await opts.requestValidator(opts);
}
if (opts.body !== void 0 && opts.bodySerializer) {
opts.serializedBody = opts.bodySerializer(opts.body);
}
if (opts.body === void 0 || opts.serializedBody === "") {
opts.headers.delete("Content-Type");
}
const url = buildUrl(opts);
return { opts, url };
};
const request = async (options) => {
var _a;
const { opts, url } = await beforeRequest(options);
const requestInit = __spreadProps(__spreadValues({
redirect: "follow"
}, opts), {
body: getValidRequestBody(opts)
});
let request2 = new Request(url, requestInit);
for (const fn of interceptors.request.fns) {
if (fn) {
request2 = await fn(request2, opts);
}
}
const _fetch = opts.fetch;
let response = await _fetch(request2);
for (const fn of interceptors.response.fns) {
if (fn) {
response = await fn(response, request2, opts);
}
}
const result = {
request: request2,
response
};
if (response.ok) {
const parseAs = (_a = opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) != null ? _a : "json";
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
let emptyData;
switch (parseAs) {
case "arrayBuffer":
case "blob":
case "text":
emptyData = await response[parseAs]();
break;
case "formData":
emptyData = new FormData();
break;
case "stream":
emptyData = response.body;
break;
case "json":
default:
emptyData = {};
break;
}
return opts.responseStyle === "data" ? emptyData : __spreadValues({
data: emptyData
}, result);
}
let data;
switch (parseAs) {
case "arrayBuffer":
case "blob":
case "formData":
case "json":
case "text":
data = await response[parseAs]();
break;
case "stream":
return opts.responseStyle === "data" ? response.body : __spreadValues({
data: response.body
}, result);
}
if (parseAs === "json") {
if (opts.responseValidator) {
await opts.responseValidator(data);
}
if (opts.responseTransformer) {
data = await opts.responseTransformer(data);
}
}
return opts.responseStyle === "data" ? data : __spreadValues({
data
}, result);
}
const textError = await response.text();
let jsonError;
try {
jsonError = JSON.parse(textError);
} catch (e) {
}
const error = jsonError != null ? jsonError : textError;
let finalError = error;
for (const fn of interceptors.error.fns) {
if (fn) {
finalError = await fn(error, response, request2, opts);
}
}
finalError = finalError || {};
if (opts.throwOnError) {
throw finalError;
}
return opts.responseStyle === "data" ? void 0 : __spreadValues({
error: finalError
}, result);
};
const makeMethodFn = (method) => (options) => request(__spreadProps(__spreadValues({}, options), { method }));
const makeSseFn = (method) => async (options) => {
const { opts, url } = await beforeRequest(options);
return createSseClient(__spreadProps(__spreadValues({}, opts), {
body: opts.body,
headers: opts.headers,
method,
onRequest: async (url2, init) => {
let request2 = new Request(url2, init);
for (const fn of interceptors.request.fns) {
if (fn) {
request2 = await fn(request2, opts);
}
}
return request2;
},
url
}));
};
return {
buildUrl,
connect: makeMethodFn("CONNECT"),
delete: makeMethodFn("DELETE"),
get: makeMethodFn("GET"),
getConfig,
head: makeMethodFn("HEAD"),
interceptors,
options: makeMethodFn("OPTIONS"),
patch: makeMethodFn("PATCH"),
post: makeMethodFn("POST"),
put: makeMethodFn("PUT"),
request,
setConfig,
sse: {
connect: makeSseFn("CONNECT"),
delete: makeSseFn("DELETE"),
get: makeSseFn("GET"),
head: makeSseFn("HEAD"),
options: makeSseFn("OPTIONS"),
patch: makeSseFn("PATCH"),
post: makeSseFn("POST"),
put: makeSseFn("PUT"),
trace: makeSseFn("TRACE")
},
trace: makeMethodFn("TRACE")
};
};
// generated/client.gen.ts
var client = createClient(
createConfig({
baseUrl: "https://api-bluvo.com"
})
);
// generated/sdk.gen.ts
var oauth2Exchangeurlgeturl = (options) => {
var _a;
return ((_a = options.client) != null ? _a : client).get(__spreadValues({
security: [
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
},
{
name: "x-bluvo-wallet-id",
type: "apiKey"
}
],
url: "/v0/oauth2/{exchange}/url"
}, options));
};
var oauth2Exchangeslistexchanges = (options) => {
var _a;
return ((_a = options == null ? void 0 : options.client) != null ? _a : client).get(__spreadValues({
url: "/v0/oauth2/exchanges"
}, options));
};
var walletdelete = (options) => {
var _a;
return ((_a = options == null ? void 0 : options.client) != null ? _a : client).delete(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
},
{
name: "x-bluvo-wallet-id",
type: "apiKey"
}
],
url: "/v0/wallet"
}, options));
};
var walletget = (options) => {
var _a;
return ((_a = options == null ? void 0 : options.client) != null ? _a : client).get(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
},
{
name: "x-bluvo-wallet-id",
type: "apiKey"
}
],
url: "/v0/wallet"
}, options));
};
var walletpingping = (options) => {
var _a;
return ((_a = options == null ? void 0 : options.client) != null ? _a : client).get(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
},
{
name: "x-bluvo-wallet-id",
type: "apiKey"
}
],
url: "/v0/wallet/ping"
}, options));
};
var walletkycgetkycidentity = (options) => {
var _a;
return ((_a = options == null ? void 0 : options.client) != null ? _a : client).get(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
},
{
name: "x-bluvo-wallet-id",
type: "apiKey"
}
],
url: "/v0/wallet/kyc"
}, options));
};
var walletlistlistwallets = (options) => {
var _a;
return ((_a = options == null ? void 0 : options.client) != null ? _a : client).get(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
}
],
url: "/v0/wallet/list"
}, options));
};
var wallettransactionslisttransactions = (options) => {
var _a;
return ((_a = options == null ? void 0 : options.client) != null ? _a : client).get(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
}
],
url: "/v0/wallet/transactions"
}, options));
};
var wallettransactiontransactionidgettransaction = (options) => {
var _a;
return ((_a = options.client) != null ? _a : client).get(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
}
],
url: "/v0/wallet/transaction/{transactionId}"
}, options));
};
var walletwithdrawbalancebalance = (options) => {
var _a;
return ((_a = options == null ? void 0 : options.client) != null ? _a : client).get(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
},
{
name: "x-bluvo-wallet-id",
type: "apiKey"
}
],
url: "/v0/wallet/withdraw/balance"
}, options));
};
var walletwithdrawquotequotation = (options) => {
var _a;
return ((_a = options.client) != null ? _a : client).post(__spreadProps(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
},
{
name: "x-bluvo-wallet-id",
type: "apiKey"
}
],
url: "/v0/wallet/withdraw/quote"
}, options), {
headers: __spreadValues({
"Content-Type": "application/json"
}, options.headers)
}));
};
var walletwithdrawquoteidexecutewithdraw = (options) => {
var _a;
return ((_a = options.client) != null ? _a : client).put(__spreadProps(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
},
{
name: "x-bluvo-wallet-id",
type: "apiKey"
}
],
url: "/v0/wallet/withdraw/{quoteId}/execute"
}, options), {
headers: __spreadValues({
"Content-Type": "application/json"
}, options.headers)
}));
};
var organizationapikeyapikeyinfo = (options) => {
var _a;
return ((_a = options == null ? void 0 : options.client) != null ? _a : client).get(__spreadValues({
security: [
{
name: "x-bluvo-api-key",
type: "apiKey"
},
{
name: "x-bluvo-org-id",
type: "apiKey"
},
{
name: "x-bluvo-project-id",
type: "apiKey"
}
],
url: "/v0/organization/api-key"
}, options));
};
// src/helpers.ts
var transformResponse = (response) => {
return {
data: response.data,
error: response.error,
success: !response.error
};
};
// src/BluvoClient.ts
var BluvoClient = class _BluvoClient {
/**
* Creates a new BluvoClient instance with the specified credentials.
*
* @param orgId Your Bluvo organization identifier.
* @param projectId Your Bluvo project identifier.
* @param apiKey Your Bluvo API access key.
* @param sandbox
* @param dev
* @param customDomain Custom domain configuration to override default api-bluvo.com
* @private Use the static `createClient` method or the global `createClient` function instead.
*/
constructor(orgId, projectId, apiKey, sandbox = false, dev = false, customDomain) {
this.orgId = orgId;
this.projectId = projectId;
this.apiKey = apiKey;
this.sandbox = sandbox;
this.dev = dev;
this.customDomain = customDomain;
this.wallet = {
/**
* Retrieve comprehensive details about a connected exchange wallet, including balances, permissions, and connection status.
*
* This method provides a complete snapshot of your connected exchange wallet, giving you real-time visibility into
* available funds, account permissions, and the health of the API connection. The data returned is fetched directly
* from the exchange API at the time of the request, ensuring you always have the most up-to-date information.
*
* Use this method to verify connections, check available balances across different assets, or determine
* the permission scope of your connected API keys before executing transactions.
*
* @param walletId The unique identifier of the connected wallet to query. This ID was specified during the initial
* wallet connection and uniquely identifies this particular exchange integration within your project.
*
* @returns A promise resolving to a detailed wallet information object containing:
* - Connection status and health
* - Exchange identifier and account details
* - Available balances for all assets
* - API key permissions and restrictions
* - Last synchronization timestamp
*
* @example
* // Get details about a connected Binance wallet
* const walletDetails = await client.wallet.get('primary-trading-account');
* console.log(`Connection status: ${walletDetails.status}`);
* console.log(`BTC Balance: ${walletDetails.balances.BTC?.available || 0}`);
*/
get: async (walletId) => {
const response = await walletget({
client: this.client,
headers: {
"x-bluvo-wallet-id": walletId
}
});
return transformResponse(response);
},
/**
* Ping
*/
ping: async (walletId) => {
const response = await walletpingping({
client: this.client,
headers: {
"x-bluvo-wallet-id": walletId
}
});
return transformResponse(response);
},
/**
* Securely disconnect and remove a previously connected exchange wallet from your Bluvo project.
*
* This method completely removes the stored API credentials and terminates the connection between your Bluvo
* project and the exchange account. This is useful when you need to rotate API keys, remove unused connections,
* or comply with user requests to delete their account information.
*
* The deletion is immediate and permanent. After deletion, any operations that were using this wallet connection
* will fail until a new connection is established with the `connect` method.
*
* @param walletId The unique identifier of the connected wallet to permanently delete from your project.
* This is the same ID that was used when initially connecting the wallet.
*
* @returns A promise resolving to a confirmation object indicating successful deletion with a timestamp.
* All API keys and secrets associated with this connection are immediately and permanently deleted
* from Bluvo's secure storage.
*
* @example
* // Remove a wallet connection that's no longer needed
* await client.wallet.delete('old-trading-account');
*
* // You can also handle the confirmation response if needed
* const result = await client.wallet.delete('temporary-connection');
* console.log(`Wallet deleted at: ${new Date(result.timestamp).toLocaleString()}`);
*/
delete: async (walletId) => {
const response = await walletdelete({
client: this.client,
headers: {
"x-bluvo-wallet-id": walletId
}
});
return transformResponse(response);
},
/**
* Retrieve a comprehensive, paginated list of all exchange wallets connected to your Bluvo project with powerful filtering options.
*
* This method provides a complete overview of all your integrated exchange accounts, making it easy to manage multiple
* connections across different exchanges or for different purposes. Results are paginated to handle large numbers of
* connections efficiently, with flexible page size configuration.
*
* Each wallet entry includes essential information like connection status, exchange type, and last activity timestamp,
* giving you a quick overview without needing to query each wallet individually. For detailed information about a specific
* wallet, use the `get` method with the wallet's ID.
*
* @param page Optional pagination control parameter (0-indexed). Defaults to 0 (first page).
* Use this parameter in combination with the `limit` parameter to navigate through large result sets.
* For example, page=1 with limit=50 will return wallets 51-100.
*
* @param limit Optional maximum number of wallet records to return per page. Defaults to 10.
* Can be increased up to 1000 for retrieving larger batches in a single request.
* Larger values reduce the number of API calls needed but increase response size.
*
* @param exchange Optional filter to retrieve wallets from a specific exchange only.
* Supports major exchanges including 'binance', 'coinbase', 'kraken', 'kucoin', and 'okx'.
* When omitted, wallets from all exchanges are returned.
*
* @returns A promise resolving to a paginated list response containing:
* - Array of wallet objects with their connection details
* - Pagination metadata (total count, current page, total pages)
* - Navigation links for next/previous pages when applicable
*
* @example
* // List all connected wallets with default pagination (10 per page)
* const allWallets = await client.wallet.list();
*
* // Get the second page of results with 20 wallets per page
* const page2 = await client.wallet.list(1, 20);
*
* // Get only Binance wallets
* const binanceWallets = await client.wallet.list(0, 50, 'binance');
* console.log(`Found ${binanceWallets.pagination.total} Binance connections`);
*/
list: async (page, limit, exchange) => {
const response = await walletlistlistwallets({
client: this.client,
query: {
page,
limit,
exchange
}
});
return transformResponse(response);
},
transaction: {
/**
* Retrieve a comprehensive, paginated list of all transactions for a specific wallet with powerful filtering capabilities.
*
* This method provides detailed visibility into the complete transaction history of a connected exchange wallet,
* including deposits, withdrawals, trades, and internal transfers. The flexible filtering system allows you to precisely
* target specific transaction types, assets, date ranges, or statuses to streamline your analysis and reporting.
*
* Transaction data is normalized across different exchanges into a consistent format, making it easy to work with
* multiple exchange integrations using the same code. Each transaction includes timestamps, amounts, fees, status
* information, and exchange-specific details when available.
*
* @param walletId The unique identifier of the connected wallet whose transactions you want to retrieve.
* This must be a valid wallet ID that was previously connected via the `connect` method.
*
* @param page Optional pagination control parameter (0-indexed). Defaults to 0 (first page).
* Use this parameter with the `limit` parameter to navigate through large transaction histories.
*
* @param limit Optional maximum number of transaction records to return per page. Defaults to a platform-specific value.
* Increasing this value reduces the number of API calls needed for large datasets but increases response size.
*
* @param asset Optional filter to retrieve transactions for a specific cryptocurrency only (e.g., 'BTC', 'ETH').
* When omitted, transactions for all assets are returned.
*
* @param type Opti