@volr/react 0.1.105 → 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 +38 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.js +39 -56
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -767,10 +767,21 @@ interface UseMpcConnectionReturn {
|
|
|
767
767
|
*/
|
|
768
768
|
declare function useMpcConnection(): UseMpcConnectionReturn;
|
|
769
769
|
|
|
770
|
+
/**
|
|
771
|
+
* Blob helpers (headless)
|
|
772
|
+
* - Presign + direct PUT upload to S3
|
|
773
|
+
*/
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Upload blob via presigned URL
|
|
777
|
+
* Uses APIClient for authentication (recommended)
|
|
778
|
+
*/
|
|
770
779
|
declare function uploadBlobViaPresign(params: {
|
|
771
|
-
|
|
772
|
-
|
|
780
|
+
/** APIClient instance for authenticated requests */
|
|
781
|
+
client: APIClient;
|
|
782
|
+
/** Blob to upload */
|
|
773
783
|
blob: Blob;
|
|
784
|
+
/** Content type (default: application/octet-stream) */
|
|
774
785
|
contentType?: string;
|
|
775
786
|
}): Promise<{
|
|
776
787
|
s3Key: string;
|
|
@@ -1235,10 +1246,10 @@ interface MigrationRequestResult {
|
|
|
1235
1246
|
interface MigrationCompleteParams {
|
|
1236
1247
|
/** APIClient instance */
|
|
1237
1248
|
client: APIClient;
|
|
1238
|
-
/**
|
|
1239
|
-
baseUrl
|
|
1240
|
-
/**
|
|
1241
|
-
apiKey
|
|
1249
|
+
/** @deprecated No longer needed - client handles auth automatically */
|
|
1250
|
+
baseUrl?: string;
|
|
1251
|
+
/** @deprecated No longer needed - client handles auth automatically */
|
|
1252
|
+
apiKey?: string;
|
|
1242
1253
|
/** User ID */
|
|
1243
1254
|
userId: string;
|
|
1244
1255
|
/** Project ID */
|
package/dist/index.d.ts
CHANGED
|
@@ -767,10 +767,21 @@ interface UseMpcConnectionReturn {
|
|
|
767
767
|
*/
|
|
768
768
|
declare function useMpcConnection(): UseMpcConnectionReturn;
|
|
769
769
|
|
|
770
|
+
/**
|
|
771
|
+
* Blob helpers (headless)
|
|
772
|
+
* - Presign + direct PUT upload to S3
|
|
773
|
+
*/
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Upload blob via presigned URL
|
|
777
|
+
* Uses APIClient for authentication (recommended)
|
|
778
|
+
*/
|
|
770
779
|
declare function uploadBlobViaPresign(params: {
|
|
771
|
-
|
|
772
|
-
|
|
780
|
+
/** APIClient instance for authenticated requests */
|
|
781
|
+
client: APIClient;
|
|
782
|
+
/** Blob to upload */
|
|
773
783
|
blob: Blob;
|
|
784
|
+
/** Content type (default: application/octet-stream) */
|
|
774
785
|
contentType?: string;
|
|
775
786
|
}): Promise<{
|
|
776
787
|
s3Key: string;
|
|
@@ -1235,10 +1246,10 @@ interface MigrationRequestResult {
|
|
|
1235
1246
|
interface MigrationCompleteParams {
|
|
1236
1247
|
/** APIClient instance */
|
|
1237
1248
|
client: APIClient;
|
|
1238
|
-
/**
|
|
1239
|
-
baseUrl
|
|
1240
|
-
/**
|
|
1241
|
-
apiKey
|
|
1249
|
+
/** @deprecated No longer needed - client handles auth automatically */
|
|
1250
|
+
baseUrl?: string;
|
|
1251
|
+
/** @deprecated No longer needed - client handles auth automatically */
|
|
1252
|
+
apiKey?: string;
|
|
1242
1253
|
/** User ID */
|
|
1243
1254
|
userId: string;
|
|
1244
1255
|
/** Project ID */
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as nc from 'crypto';
|
|
2
2
|
import { createContext, useRef, useEffect, useMemo, useState, useCallback, useContext } from 'react';
|
|
3
|
-
import { createPasskeyProvider, createMpcProvider, deriveWrapKey, sealMasterSeed,
|
|
3
|
+
import { createPasskeyProvider, createMpcProvider, deriveWrapKey, sealMasterSeed, signSession, getAuthNonce, signAuthorization, createMasterKeyProvider, deriveEvmKey, ZERO_HASH, selectSigner, VolrError } from '@volr/sdk-core';
|
|
4
4
|
export { createMasterKeyProvider, createMpcProvider, createPasskeyProvider, deriveEvmKey, deriveWrapKey, sealMasterSeed, uploadBlob } from '@volr/sdk-core';
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -19175,6 +19175,18 @@ function useDepositListener(input) {
|
|
|
19175
19175
|
}, [getRpcUrl, input.chainId, input.address, JSON.stringify(input.asset)]);
|
|
19176
19176
|
return status;
|
|
19177
19177
|
}
|
|
19178
|
+
function blobToBase64(blob) {
|
|
19179
|
+
return new Promise((resolve, reject) => {
|
|
19180
|
+
const reader = new FileReader();
|
|
19181
|
+
reader.onloadend = () => {
|
|
19182
|
+
const result = reader.result;
|
|
19183
|
+
const base64 = result.includes(",") ? result.split(",")[1] : result;
|
|
19184
|
+
resolve(base64 || "");
|
|
19185
|
+
};
|
|
19186
|
+
reader.onerror = reject;
|
|
19187
|
+
reader.readAsDataURL(blob);
|
|
19188
|
+
});
|
|
19189
|
+
}
|
|
19178
19190
|
function detectPlatform() {
|
|
19179
19191
|
if (typeof navigator === "undefined") return "Unknown";
|
|
19180
19192
|
const ua = navigator.userAgent;
|
|
@@ -19312,16 +19324,11 @@ async function enrollPasskey(params) {
|
|
|
19312
19324
|
type: "application/octet-stream"
|
|
19313
19325
|
}
|
|
19314
19326
|
);
|
|
19315
|
-
const
|
|
19316
|
-
|
|
19317
|
-
|
|
19318
|
-
}
|
|
19319
|
-
const { key: blobUrl } = await uploadBlob({
|
|
19320
|
-
baseUrl,
|
|
19321
|
-
apiKey,
|
|
19322
|
-
accessToken,
|
|
19323
|
-
blob
|
|
19327
|
+
const blobB64 = await blobToBase64(blob);
|
|
19328
|
+
const uploadResponse = await client.post("/blob/upload", {
|
|
19329
|
+
blobB64
|
|
19324
19330
|
});
|
|
19331
|
+
const blobUrl = uploadResponse?.key;
|
|
19325
19332
|
if (!blobUrl) {
|
|
19326
19333
|
throw new Error("Failed to upload blob: missing key");
|
|
19327
19334
|
}
|
|
@@ -19594,48 +19601,19 @@ function useMpcConnection() {
|
|
|
19594
19601
|
error
|
|
19595
19602
|
};
|
|
19596
19603
|
}
|
|
19597
|
-
function createAxiosInstance(baseUrl, apiKey) {
|
|
19598
|
-
const instance = axios.create({
|
|
19599
|
-
baseURL: baseUrl.replace(/\/+$/, ""),
|
|
19600
|
-
// Remove trailing slashes
|
|
19601
|
-
withCredentials: true,
|
|
19602
|
-
// Include cookies
|
|
19603
|
-
headers: {
|
|
19604
|
-
"Content-Type": "application/json"
|
|
19605
|
-
}
|
|
19606
|
-
});
|
|
19607
|
-
instance.interceptors.request.use((config) => {
|
|
19608
|
-
if (apiKey) {
|
|
19609
|
-
config.headers["X-API-Key"] = apiKey;
|
|
19610
|
-
}
|
|
19611
|
-
return config;
|
|
19612
|
-
});
|
|
19613
|
-
instance.interceptors.response.use(
|
|
19614
|
-
(response) => response,
|
|
19615
|
-
(error) => {
|
|
19616
|
-
if (error.response?.data) {
|
|
19617
|
-
const errorData = error.response.data;
|
|
19618
|
-
if (errorData.error?.message) {
|
|
19619
|
-
error.message = errorData.error.message;
|
|
19620
|
-
}
|
|
19621
|
-
}
|
|
19622
|
-
return Promise.reject(error);
|
|
19623
|
-
}
|
|
19624
|
-
);
|
|
19625
|
-
return instance;
|
|
19626
|
-
}
|
|
19627
19604
|
|
|
19628
19605
|
// src/headless/blobs.ts
|
|
19629
19606
|
async function uploadBlobViaPresign(params) {
|
|
19630
|
-
const {
|
|
19631
|
-
const
|
|
19632
|
-
const presignResponse = await api.post("/blob/presign", {
|
|
19607
|
+
const { client, blob, contentType = "application/octet-stream" } = params;
|
|
19608
|
+
const presignData = await client.post("/blob/presign", {
|
|
19633
19609
|
op: "put",
|
|
19634
19610
|
contentType
|
|
19635
19611
|
});
|
|
19636
|
-
const presignData = presignResponse.data?.data || presignResponse.data;
|
|
19637
19612
|
const uploadUrl = presignData.url;
|
|
19638
|
-
const s3Key = presignData.s3Key;
|
|
19613
|
+
const s3Key = presignData.s3Key || presignData.proposedKey || "";
|
|
19614
|
+
if (!uploadUrl || !s3Key) {
|
|
19615
|
+
throw new Error("Invalid presign response: missing url or s3Key");
|
|
19616
|
+
}
|
|
19639
19617
|
const putRes = await fetch(uploadUrl, {
|
|
19640
19618
|
method: "PUT",
|
|
19641
19619
|
body: blob,
|
|
@@ -20105,6 +20083,18 @@ async function checkPrfExtensionAvailable() {
|
|
|
20105
20083
|
const { prfSupported } = checkPrfSupport();
|
|
20106
20084
|
return prfSupported;
|
|
20107
20085
|
}
|
|
20086
|
+
function blobToBase642(blob) {
|
|
20087
|
+
return new Promise((resolve, reject) => {
|
|
20088
|
+
const reader = new FileReader();
|
|
20089
|
+
reader.onloadend = () => {
|
|
20090
|
+
const result = reader.result;
|
|
20091
|
+
const base64 = result.includes(",") ? result.split(",")[1] : result;
|
|
20092
|
+
resolve(base64 || "");
|
|
20093
|
+
};
|
|
20094
|
+
reader.onerror = reject;
|
|
20095
|
+
reader.readAsDataURL(blob);
|
|
20096
|
+
});
|
|
20097
|
+
}
|
|
20108
20098
|
async function requestMigration(params) {
|
|
20109
20099
|
const { client, targetOrigin } = params;
|
|
20110
20100
|
const response = await client.post("/wallet/migration/request", { targetOrigin });
|
|
@@ -20223,8 +20213,6 @@ function detectPlatform3() {
|
|
|
20223
20213
|
async function completeMigration(params) {
|
|
20224
20214
|
const {
|
|
20225
20215
|
client,
|
|
20226
|
-
baseUrl,
|
|
20227
|
-
apiKey,
|
|
20228
20216
|
userId,
|
|
20229
20217
|
projectId,
|
|
20230
20218
|
migrationToken,
|
|
@@ -20296,16 +20284,11 @@ async function completeMigration(params) {
|
|
|
20296
20284
|
],
|
|
20297
20285
|
{ type: "application/octet-stream" }
|
|
20298
20286
|
);
|
|
20299
|
-
const
|
|
20300
|
-
|
|
20301
|
-
|
|
20302
|
-
}
|
|
20303
|
-
const { key: blobUrl } = await uploadBlob({
|
|
20304
|
-
baseUrl,
|
|
20305
|
-
apiKey,
|
|
20306
|
-
accessToken,
|
|
20307
|
-
blob
|
|
20287
|
+
const blobB64 = await blobToBase642(blob);
|
|
20288
|
+
const uploadResponse = await client.post("/blob/upload", {
|
|
20289
|
+
blobB64
|
|
20308
20290
|
});
|
|
20291
|
+
const blobUrl = uploadResponse?.key;
|
|
20309
20292
|
if (!blobUrl) {
|
|
20310
20293
|
throw new Error("Failed to upload blob");
|
|
20311
20294
|
}
|