@volr/react 0.1.104 → 0.1.106

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 CHANGED
@@ -18288,7 +18288,7 @@ function defaultIdempotencyKey() {
18288
18288
  }
18289
18289
 
18290
18290
  // src/wallet/auth.ts
18291
- var GAS_CAP_BUFFER = 150000n;
18291
+ var GAS_CAP_BUFFER = 200000n;
18292
18292
  function computeTotalGasCap(calls) {
18293
18293
  return calls.reduce((sum, c) => sum + (c.gasLimit ?? 0n), 0n) + GAS_CAP_BUFFER;
18294
18294
  }
@@ -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 accessToken = client.getAccessToken();
19340
- if (!accessToken) {
19341
- throw new Error("Access token is required for blob upload");
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 { baseUrl, apiKey, blob, contentType = "application/octet-stream" } = params;
19655
- const api = createAxiosInstance(baseUrl, apiKey);
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,
@@ -20129,6 +20107,18 @@ async function checkPrfExtensionAvailable() {
20129
20107
  const { prfSupported } = checkPrfSupport();
20130
20108
  return prfSupported;
20131
20109
  }
20110
+ function blobToBase642(blob) {
20111
+ return new Promise((resolve, reject) => {
20112
+ const reader = new FileReader();
20113
+ reader.onloadend = () => {
20114
+ const result = reader.result;
20115
+ const base64 = result.includes(",") ? result.split(",")[1] : result;
20116
+ resolve(base64 || "");
20117
+ };
20118
+ reader.onerror = reject;
20119
+ reader.readAsDataURL(blob);
20120
+ });
20121
+ }
20132
20122
  async function requestMigration(params) {
20133
20123
  const { client, targetOrigin } = params;
20134
20124
  const response = await client.post("/wallet/migration/request", { targetOrigin });
@@ -20247,8 +20237,6 @@ function detectPlatform3() {
20247
20237
  async function completeMigration(params) {
20248
20238
  const {
20249
20239
  client,
20250
- baseUrl,
20251
- apiKey,
20252
20240
  userId,
20253
20241
  projectId,
20254
20242
  migrationToken,
@@ -20320,16 +20308,11 @@ async function completeMigration(params) {
20320
20308
  ],
20321
20309
  { type: "application/octet-stream" }
20322
20310
  );
20323
- const accessToken = client.getAccessToken();
20324
- if (!accessToken) {
20325
- throw new Error("Access token is required");
20326
- }
20327
- const { key: blobUrl } = await sdkCore.uploadBlob({
20328
- baseUrl,
20329
- apiKey,
20330
- accessToken,
20331
- blob
20311
+ const blobB64 = await blobToBase642(blob);
20312
+ const uploadResponse = await client.post("/blob/upload", {
20313
+ blobB64
20332
20314
  });
20315
+ const blobUrl = uploadResponse?.key;
20333
20316
  if (!blobUrl) {
20334
20317
  throw new Error("Failed to upload blob");
20335
20318
  }