@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.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
- baseUrl: string;
772
- apiKey: string;
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;
@@ -798,8 +809,10 @@ interface PaymentItem {
798
809
  image?: string;
799
810
  }
800
811
  interface PayOptions {
801
- /** Amount in token units (before decimals applied) */
812
+ /** Amount in token units (before decimals applied) - same amount applies to all tokens */
802
813
  amount: number;
814
+ /** Token ID to use for payment (if not provided, user selects in modal) */
815
+ tokenId?: string;
803
816
  /** Item information to display in payment modal */
804
817
  item?: PaymentItem;
805
818
  /** Client-side order/reference ID */
@@ -835,6 +848,8 @@ interface PaymentToken {
835
848
  symbol: string;
836
849
  chainId: number;
837
850
  decimals: number;
851
+ address: string;
852
+ iconUrl?: string | null;
838
853
  }
839
854
  interface PaymentResult {
840
855
  id: string;
@@ -905,8 +920,11 @@ interface PaymentContext {
905
920
  interface UseVolrPaymentApiReturn {
906
921
  /**
907
922
  * Create a payment via API
923
+ * @param options Payment options including required tokenId
908
924
  */
909
- createPayment: (options: PayOptions) => Promise<PaymentResult>;
925
+ createPayment: (options: PayOptions & {
926
+ tokenId: string;
927
+ }) => Promise<PaymentResult>;
910
928
  /**
911
929
  * Check payment status by ID
912
930
  */
@@ -1235,10 +1253,10 @@ interface MigrationRequestResult {
1235
1253
  interface MigrationCompleteParams {
1236
1254
  /** APIClient instance */
1237
1255
  client: APIClient;
1238
- /** Base URL for API calls */
1239
- baseUrl: string;
1240
- /** Project API key */
1241
- apiKey: string;
1256
+ /** @deprecated No longer needed - client handles auth automatically */
1257
+ baseUrl?: string;
1258
+ /** @deprecated No longer needed - client handles auth automatically */
1259
+ apiKey?: string;
1242
1260
  /** User ID */
1243
1261
  userId: string;
1244
1262
  /** 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
- baseUrl: string;
772
- apiKey: string;
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;
@@ -798,8 +809,10 @@ interface PaymentItem {
798
809
  image?: string;
799
810
  }
800
811
  interface PayOptions {
801
- /** Amount in token units (before decimals applied) */
812
+ /** Amount in token units (before decimals applied) - same amount applies to all tokens */
802
813
  amount: number;
814
+ /** Token ID to use for payment (if not provided, user selects in modal) */
815
+ tokenId?: string;
803
816
  /** Item information to display in payment modal */
804
817
  item?: PaymentItem;
805
818
  /** Client-side order/reference ID */
@@ -835,6 +848,8 @@ interface PaymentToken {
835
848
  symbol: string;
836
849
  chainId: number;
837
850
  decimals: number;
851
+ address: string;
852
+ iconUrl?: string | null;
838
853
  }
839
854
  interface PaymentResult {
840
855
  id: string;
@@ -905,8 +920,11 @@ interface PaymentContext {
905
920
  interface UseVolrPaymentApiReturn {
906
921
  /**
907
922
  * Create a payment via API
923
+ * @param options Payment options including required tokenId
908
924
  */
909
- createPayment: (options: PayOptions) => Promise<PaymentResult>;
925
+ createPayment: (options: PayOptions & {
926
+ tokenId: string;
927
+ }) => Promise<PaymentResult>;
910
928
  /**
911
929
  * Check payment status by ID
912
930
  */
@@ -1235,10 +1253,10 @@ interface MigrationRequestResult {
1235
1253
  interface MigrationCompleteParams {
1236
1254
  /** APIClient instance */
1237
1255
  client: APIClient;
1238
- /** Base URL for API calls */
1239
- baseUrl: string;
1240
- /** Project API key */
1241
- apiKey: string;
1256
+ /** @deprecated No longer needed - client handles auth automatically */
1257
+ baseUrl?: string;
1258
+ /** @deprecated No longer needed - client handles auth automatically */
1259
+ apiKey?: string;
1242
1260
  /** User ID */
1243
1261
  userId: string;
1244
1262
  /** 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, uploadBlob, signSession, getAuthNonce, signAuthorization, createMasterKeyProvider, deriveEvmKey, ZERO_HASH, selectSigner, VolrError } from '@volr/sdk-core';
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 accessToken = client.getAccessToken();
19316
- if (!accessToken) {
19317
- throw new Error("Access token is required for blob upload");
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 { baseUrl, apiKey, blob, contentType = "application/octet-stream" } = params;
19631
- const api = createAxiosInstance(baseUrl, apiKey);
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,
@@ -19661,6 +19639,7 @@ function useVolrPaymentApi() {
19661
19639
  setIsLoading(true);
19662
19640
  try {
19663
19641
  const response = await client.post("/payments", {
19642
+ tokenId: options.tokenId,
19664
19643
  amount: options.amount,
19665
19644
  item: options.item,
19666
19645
  referenceId: options.referenceId,
@@ -20105,6 +20084,18 @@ async function checkPrfExtensionAvailable() {
20105
20084
  const { prfSupported } = checkPrfSupport();
20106
20085
  return prfSupported;
20107
20086
  }
20087
+ function blobToBase642(blob) {
20088
+ return new Promise((resolve, reject) => {
20089
+ const reader = new FileReader();
20090
+ reader.onloadend = () => {
20091
+ const result = reader.result;
20092
+ const base64 = result.includes(",") ? result.split(",")[1] : result;
20093
+ resolve(base64 || "");
20094
+ };
20095
+ reader.onerror = reject;
20096
+ reader.readAsDataURL(blob);
20097
+ });
20098
+ }
20108
20099
  async function requestMigration(params) {
20109
20100
  const { client, targetOrigin } = params;
20110
20101
  const response = await client.post("/wallet/migration/request", { targetOrigin });
@@ -20223,8 +20214,6 @@ function detectPlatform3() {
20223
20214
  async function completeMigration(params) {
20224
20215
  const {
20225
20216
  client,
20226
- baseUrl,
20227
- apiKey,
20228
20217
  userId,
20229
20218
  projectId,
20230
20219
  migrationToken,
@@ -20296,16 +20285,11 @@ async function completeMigration(params) {
20296
20285
  ],
20297
20286
  { type: "application/octet-stream" }
20298
20287
  );
20299
- const accessToken = client.getAccessToken();
20300
- if (!accessToken) {
20301
- throw new Error("Access token is required");
20302
- }
20303
- const { key: blobUrl } = await uploadBlob({
20304
- baseUrl,
20305
- apiKey,
20306
- accessToken,
20307
- blob
20288
+ const blobB64 = await blobToBase642(blob);
20289
+ const uploadResponse = await client.post("/blob/upload", {
20290
+ blobB64
20308
20291
  });
20292
+ const blobUrl = uploadResponse?.key;
20309
20293
  if (!blobUrl) {
20310
20294
  throw new Error("Failed to upload blob");
20311
20295
  }