@volr/react 0.1.105 → 0.1.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +39 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -8
- package/dist/index.d.ts +26 -8
- package/dist/index.js +40 -56
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -19199,6 +19199,18 @@ function useDepositListener(input) {
|
|
|
19199
19199
|
}, [getRpcUrl, input.chainId, input.address, JSON.stringify(input.asset)]);
|
|
19200
19200
|
return status;
|
|
19201
19201
|
}
|
|
19202
|
+
function blobToBase64(blob) {
|
|
19203
|
+
return new Promise((resolve, reject) => {
|
|
19204
|
+
const reader = new FileReader();
|
|
19205
|
+
reader.onloadend = () => {
|
|
19206
|
+
const result = reader.result;
|
|
19207
|
+
const base64 = result.includes(",") ? result.split(",")[1] : result;
|
|
19208
|
+
resolve(base64 || "");
|
|
19209
|
+
};
|
|
19210
|
+
reader.onerror = reject;
|
|
19211
|
+
reader.readAsDataURL(blob);
|
|
19212
|
+
});
|
|
19213
|
+
}
|
|
19202
19214
|
function detectPlatform() {
|
|
19203
19215
|
if (typeof navigator === "undefined") return "Unknown";
|
|
19204
19216
|
const ua = navigator.userAgent;
|
|
@@ -19336,16 +19348,11 @@ async function enrollPasskey(params) {
|
|
|
19336
19348
|
type: "application/octet-stream"
|
|
19337
19349
|
}
|
|
19338
19350
|
);
|
|
19339
|
-
const
|
|
19340
|
-
|
|
19341
|
-
|
|
19342
|
-
}
|
|
19343
|
-
const { key: blobUrl } = await sdkCore.uploadBlob({
|
|
19344
|
-
baseUrl,
|
|
19345
|
-
apiKey,
|
|
19346
|
-
accessToken,
|
|
19347
|
-
blob
|
|
19351
|
+
const blobB64 = await blobToBase64(blob);
|
|
19352
|
+
const uploadResponse = await client.post("/blob/upload", {
|
|
19353
|
+
blobB64
|
|
19348
19354
|
});
|
|
19355
|
+
const blobUrl = uploadResponse?.key;
|
|
19349
19356
|
if (!blobUrl) {
|
|
19350
19357
|
throw new Error("Failed to upload blob: missing key");
|
|
19351
19358
|
}
|
|
@@ -19618,48 +19625,19 @@ function useMpcConnection() {
|
|
|
19618
19625
|
error
|
|
19619
19626
|
};
|
|
19620
19627
|
}
|
|
19621
|
-
function createAxiosInstance(baseUrl, apiKey) {
|
|
19622
|
-
const instance = axios__default.default.create({
|
|
19623
|
-
baseURL: baseUrl.replace(/\/+$/, ""),
|
|
19624
|
-
// Remove trailing slashes
|
|
19625
|
-
withCredentials: true,
|
|
19626
|
-
// Include cookies
|
|
19627
|
-
headers: {
|
|
19628
|
-
"Content-Type": "application/json"
|
|
19629
|
-
}
|
|
19630
|
-
});
|
|
19631
|
-
instance.interceptors.request.use((config) => {
|
|
19632
|
-
if (apiKey) {
|
|
19633
|
-
config.headers["X-API-Key"] = apiKey;
|
|
19634
|
-
}
|
|
19635
|
-
return config;
|
|
19636
|
-
});
|
|
19637
|
-
instance.interceptors.response.use(
|
|
19638
|
-
(response) => response,
|
|
19639
|
-
(error) => {
|
|
19640
|
-
if (error.response?.data) {
|
|
19641
|
-
const errorData = error.response.data;
|
|
19642
|
-
if (errorData.error?.message) {
|
|
19643
|
-
error.message = errorData.error.message;
|
|
19644
|
-
}
|
|
19645
|
-
}
|
|
19646
|
-
return Promise.reject(error);
|
|
19647
|
-
}
|
|
19648
|
-
);
|
|
19649
|
-
return instance;
|
|
19650
|
-
}
|
|
19651
19628
|
|
|
19652
19629
|
// src/headless/blobs.ts
|
|
19653
19630
|
async function uploadBlobViaPresign(params) {
|
|
19654
|
-
const {
|
|
19655
|
-
const
|
|
19656
|
-
const presignResponse = await api.post("/blob/presign", {
|
|
19631
|
+
const { client, blob, contentType = "application/octet-stream" } = params;
|
|
19632
|
+
const presignData = await client.post("/blob/presign", {
|
|
19657
19633
|
op: "put",
|
|
19658
19634
|
contentType
|
|
19659
19635
|
});
|
|
19660
|
-
const presignData = presignResponse.data?.data || presignResponse.data;
|
|
19661
19636
|
const uploadUrl = presignData.url;
|
|
19662
|
-
const s3Key = presignData.s3Key;
|
|
19637
|
+
const s3Key = presignData.s3Key || presignData.proposedKey || "";
|
|
19638
|
+
if (!uploadUrl || !s3Key) {
|
|
19639
|
+
throw new Error("Invalid presign response: missing url or s3Key");
|
|
19640
|
+
}
|
|
19663
19641
|
const putRes = await fetch(uploadUrl, {
|
|
19664
19642
|
method: "PUT",
|
|
19665
19643
|
body: blob,
|
|
@@ -19685,6 +19663,7 @@ function useVolrPaymentApi() {
|
|
|
19685
19663
|
setIsLoading(true);
|
|
19686
19664
|
try {
|
|
19687
19665
|
const response = await client.post("/payments", {
|
|
19666
|
+
tokenId: options.tokenId,
|
|
19688
19667
|
amount: options.amount,
|
|
19689
19668
|
item: options.item,
|
|
19690
19669
|
referenceId: options.referenceId,
|
|
@@ -20129,6 +20108,18 @@ async function checkPrfExtensionAvailable() {
|
|
|
20129
20108
|
const { prfSupported } = checkPrfSupport();
|
|
20130
20109
|
return prfSupported;
|
|
20131
20110
|
}
|
|
20111
|
+
function blobToBase642(blob) {
|
|
20112
|
+
return new Promise((resolve, reject) => {
|
|
20113
|
+
const reader = new FileReader();
|
|
20114
|
+
reader.onloadend = () => {
|
|
20115
|
+
const result = reader.result;
|
|
20116
|
+
const base64 = result.includes(",") ? result.split(",")[1] : result;
|
|
20117
|
+
resolve(base64 || "");
|
|
20118
|
+
};
|
|
20119
|
+
reader.onerror = reject;
|
|
20120
|
+
reader.readAsDataURL(blob);
|
|
20121
|
+
});
|
|
20122
|
+
}
|
|
20132
20123
|
async function requestMigration(params) {
|
|
20133
20124
|
const { client, targetOrigin } = params;
|
|
20134
20125
|
const response = await client.post("/wallet/migration/request", { targetOrigin });
|
|
@@ -20247,8 +20238,6 @@ function detectPlatform3() {
|
|
|
20247
20238
|
async function completeMigration(params) {
|
|
20248
20239
|
const {
|
|
20249
20240
|
client,
|
|
20250
|
-
baseUrl,
|
|
20251
|
-
apiKey,
|
|
20252
20241
|
userId,
|
|
20253
20242
|
projectId,
|
|
20254
20243
|
migrationToken,
|
|
@@ -20320,16 +20309,11 @@ async function completeMigration(params) {
|
|
|
20320
20309
|
],
|
|
20321
20310
|
{ type: "application/octet-stream" }
|
|
20322
20311
|
);
|
|
20323
|
-
const
|
|
20324
|
-
|
|
20325
|
-
|
|
20326
|
-
}
|
|
20327
|
-
const { key: blobUrl } = await sdkCore.uploadBlob({
|
|
20328
|
-
baseUrl,
|
|
20329
|
-
apiKey,
|
|
20330
|
-
accessToken,
|
|
20331
|
-
blob
|
|
20312
|
+
const blobB64 = await blobToBase642(blob);
|
|
20313
|
+
const uploadResponse = await client.post("/blob/upload", {
|
|
20314
|
+
blobB64
|
|
20332
20315
|
});
|
|
20316
|
+
const blobUrl = uploadResponse?.key;
|
|
20333
20317
|
if (!blobUrl) {
|
|
20334
20318
|
throw new Error("Failed to upload blob");
|
|
20335
20319
|
}
|