@volr/react 0.1.83 → 0.1.85

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
@@ -541,6 +541,21 @@ interface AuthResult {
541
541
  /** Access token for API authentication. Always present after successful login. */
542
542
  accessToken: string;
543
543
  }
544
+ /** SIWE session for mobile wallet signing */
545
+ interface SiweSession {
546
+ id: string;
547
+ expiresAt: number;
548
+ }
549
+ /** SIWE session status response */
550
+ interface SiweSessionStatus {
551
+ status: 'pending' | 'completed' | 'expired';
552
+ tokens?: {
553
+ accessToken: string;
554
+ refreshToken: string;
555
+ };
556
+ user?: UserDto;
557
+ isNewUser?: boolean;
558
+ }
544
559
  interface UseVolrLoginReturn {
545
560
  requestEmailCode: (email: string) => Promise<void>;
546
561
  verifyEmailCode: (email: string, code: string) => Promise<AuthResult>;
@@ -550,7 +565,18 @@ interface UseVolrLoginReturn {
550
565
  walletConnector?: string;
551
566
  chainId?: number;
552
567
  }) => Promise<AuthResult>;
568
+ /**
569
+ * Complete SIWE flow: connect wallet → request nonce → sign message → verify
570
+ * Use this for desktop wallet signing
571
+ */
572
+ signWithWallet: (walletAddress: string) => Promise<AuthResult>;
553
573
  handlePasskeyComplete: () => Promise<void>;
574
+ /** Create a SIWE session for mobile wallet signing */
575
+ createSiweSession: () => Promise<SiweSession>;
576
+ /** Check SIWE session status (for polling) */
577
+ checkSiweSession: (sessionId: string) => Promise<SiweSessionStatus>;
578
+ /** Get the sign.volr.io URL for a session */
579
+ getSiweSignUrl: (sessionId: string) => string;
554
580
  }
555
581
  /**
556
582
  * useVolrLogin hook
@@ -973,4 +999,4 @@ declare function getPasskeyAuthGuidance(passkeyPlatform?: string | null): string
973
999
  */
974
1000
  declare function checkPrfExtensionAvailable(): Promise<boolean>;
975
1001
 
976
- export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmClient, type KeyStorageType, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignerType, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getWalletState, isEIP7702Delegated, isUserCancelledError, normalizeHex, normalizeHexArray, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin };
1002
+ export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmClient, type KeyStorageType, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getWalletState, isEIP7702Delegated, isUserCancelledError, normalizeHex, normalizeHexArray, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin };
package/dist/index.d.ts CHANGED
@@ -541,6 +541,21 @@ interface AuthResult {
541
541
  /** Access token for API authentication. Always present after successful login. */
542
542
  accessToken: string;
543
543
  }
544
+ /** SIWE session for mobile wallet signing */
545
+ interface SiweSession {
546
+ id: string;
547
+ expiresAt: number;
548
+ }
549
+ /** SIWE session status response */
550
+ interface SiweSessionStatus {
551
+ status: 'pending' | 'completed' | 'expired';
552
+ tokens?: {
553
+ accessToken: string;
554
+ refreshToken: string;
555
+ };
556
+ user?: UserDto;
557
+ isNewUser?: boolean;
558
+ }
544
559
  interface UseVolrLoginReturn {
545
560
  requestEmailCode: (email: string) => Promise<void>;
546
561
  verifyEmailCode: (email: string, code: string) => Promise<AuthResult>;
@@ -550,7 +565,18 @@ interface UseVolrLoginReturn {
550
565
  walletConnector?: string;
551
566
  chainId?: number;
552
567
  }) => Promise<AuthResult>;
568
+ /**
569
+ * Complete SIWE flow: connect wallet → request nonce → sign message → verify
570
+ * Use this for desktop wallet signing
571
+ */
572
+ signWithWallet: (walletAddress: string) => Promise<AuthResult>;
553
573
  handlePasskeyComplete: () => Promise<void>;
574
+ /** Create a SIWE session for mobile wallet signing */
575
+ createSiweSession: () => Promise<SiweSession>;
576
+ /** Check SIWE session status (for polling) */
577
+ checkSiweSession: (sessionId: string) => Promise<SiweSessionStatus>;
578
+ /** Get the sign.volr.io URL for a session */
579
+ getSiweSignUrl: (sessionId: string) => string;
554
580
  }
555
581
  /**
556
582
  * useVolrLogin hook
@@ -973,4 +999,4 @@ declare function getPasskeyAuthGuidance(passkeyPlatform?: string | null): string
973
999
  */
974
1000
  declare function checkPrfExtensionAvailable(): Promise<boolean>;
975
1001
 
976
- export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmClient, type KeyStorageType, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignerType, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getWalletState, isEIP7702Delegated, isUserCancelledError, normalizeHex, normalizeHexArray, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin };
1002
+ export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmClient, type KeyStorageType, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getWalletState, isEIP7702Delegated, isUserCancelledError, normalizeHex, normalizeHexArray, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin };
package/dist/index.js CHANGED
@@ -1699,6 +1699,16 @@ function byteSwap32(arr) {
1699
1699
  }
1700
1700
  return arr;
1701
1701
  }
1702
+ function bytesToHex2(bytes) {
1703
+ abytes(bytes);
1704
+ if (hasHexBuiltin)
1705
+ return bytes.toHex();
1706
+ let hex = "";
1707
+ for (let i = 0; i < bytes.length; i++) {
1708
+ hex += hexes2[bytes[i]];
1709
+ }
1710
+ return hex;
1711
+ }
1702
1712
  function utf8ToBytes(str) {
1703
1713
  if (typeof str !== "string")
1704
1714
  throw new Error("string expected");
@@ -1742,12 +1752,17 @@ function randomBytes(bytesLength = 32) {
1742
1752
  }
1743
1753
  throw new Error("crypto.getRandomValues must be defined");
1744
1754
  }
1745
- var isLE, swap32IfBE, Hash;
1755
+ var isLE, swap32IfBE, hasHexBuiltin, hexes2, Hash;
1746
1756
  var init_utils2 = __esm({
1747
1757
  "../node_modules/@noble/hashes/esm/utils.js"() {
1748
1758
  init_cryptoNode();
1749
1759
  isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
1750
1760
  swap32IfBE = isLE ? (u) => u : byteSwap32;
1761
+ hasHexBuiltin = /* @__PURE__ */ (() => (
1762
+ // @ts-ignore
1763
+ typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
1764
+ ))();
1765
+ hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
1751
1766
  Hash = class {
1752
1767
  };
1753
1768
  }
@@ -4577,13 +4592,13 @@ function hexToNumber2(hex) {
4577
4592
  throw new Error("hex string expected, got " + typeof hex);
4578
4593
  return hex === "" ? _0n2 : BigInt("0x" + hex);
4579
4594
  }
4580
- function bytesToHex2(bytes) {
4595
+ function bytesToHex3(bytes) {
4581
4596
  abytes2(bytes);
4582
- if (hasHexBuiltin)
4597
+ if (hasHexBuiltin2)
4583
4598
  return bytes.toHex();
4584
4599
  let hex = "";
4585
4600
  for (let i = 0; i < bytes.length; i++) {
4586
- hex += hexes2[bytes[i]];
4601
+ hex += hexes3[bytes[i]];
4587
4602
  }
4588
4603
  return hex;
4589
4604
  }
@@ -4599,7 +4614,7 @@ function asciiToBase16(ch) {
4599
4614
  function hexToBytes2(hex) {
4600
4615
  if (typeof hex !== "string")
4601
4616
  throw new Error("hex string expected, got " + typeof hex);
4602
- if (hasHexBuiltin)
4617
+ if (hasHexBuiltin2)
4603
4618
  return Uint8Array.fromHex(hex);
4604
4619
  const hl = hex.length;
4605
4620
  const al = hl / 2;
@@ -4618,11 +4633,11 @@ function hexToBytes2(hex) {
4618
4633
  return array;
4619
4634
  }
4620
4635
  function bytesToNumberBE(bytes) {
4621
- return hexToNumber2(bytesToHex2(bytes));
4636
+ return hexToNumber2(bytesToHex3(bytes));
4622
4637
  }
4623
4638
  function bytesToNumberLE(bytes) {
4624
4639
  abytes2(bytes);
4625
- return hexToNumber2(bytesToHex2(Uint8Array.from(bytes).reverse()));
4640
+ return hexToNumber2(bytesToHex3(Uint8Array.from(bytes).reverse()));
4626
4641
  }
4627
4642
  function numberToBytesBE(n, len) {
4628
4643
  return hexToBytes2(n.toString(16).padStart(len * 2, "0"));
@@ -4758,14 +4773,14 @@ function memoized(fn) {
4758
4773
  return computed;
4759
4774
  };
4760
4775
  }
4761
- var _0n2, _1n2, hasHexBuiltin, hexes2, asciis, isPosBig, bitMask, u8n, u8fr, validatorFns;
4776
+ var _0n2, _1n2, hasHexBuiltin2, hexes3, asciis, isPosBig, bitMask, u8n, u8fr, validatorFns;
4762
4777
  var init_utils4 = __esm({
4763
4778
  "../node_modules/@noble/curves/esm/abstract/utils.js"() {
4764
4779
  _0n2 = /* @__PURE__ */ BigInt(0);
4765
4780
  _1n2 = /* @__PURE__ */ BigInt(1);
4766
- hasHexBuiltin = // @ts-ignore
4781
+ hasHexBuiltin2 = // @ts-ignore
4767
4782
  typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
4768
- hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
4783
+ hexes3 = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
4769
4784
  asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
4770
4785
  isPosBig = (n) => typeof n === "bigint" && _0n2 <= n;
4771
4786
  bitMask = (n) => (_1n2 << BigInt(n)) - _1n2;
@@ -5339,7 +5354,7 @@ function validatePointOpts(curve) {
5339
5354
  return Object.freeze({ ...opts });
5340
5355
  }
5341
5356
  function numToSizedHex(num2, size5) {
5342
- return bytesToHex2(numberToBytesBE(num2, size5));
5357
+ return bytesToHex3(numberToBytesBE(num2, size5));
5343
5358
  }
5344
5359
  function weierstrassPoints(opts) {
5345
5360
  const CURVE = validatePointOpts(opts);
@@ -5379,7 +5394,7 @@ function weierstrassPoints(opts) {
5379
5394
  const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N } = CURVE;
5380
5395
  if (lengths && typeof key !== "bigint") {
5381
5396
  if (isBytes2(key))
5382
- key = bytesToHex2(key);
5397
+ key = bytesToHex3(key);
5383
5398
  if (typeof key !== "string" || !lengths.includes(key.length))
5384
5399
  throw new Error("invalid private key");
5385
5400
  key = key.padStart(nByteLength * 2, "0");
@@ -5729,7 +5744,7 @@ function weierstrassPoints(opts) {
5729
5744
  }
5730
5745
  toHex(isCompressed = true) {
5731
5746
  abool("isCompressed", isCompressed);
5732
- return bytesToHex2(this.toRawBytes(isCompressed));
5747
+ return bytesToHex3(this.toRawBytes(isCompressed));
5733
5748
  }
5734
5749
  }
5735
5750
  Point2.BASE = new Point2(CURVE.Gx, CURVE.Gy, Fp.ONE);
@@ -7644,7 +7659,7 @@ function fromBoolean(value, options = {}) {
7644
7659
  function fromBytes(value, options = {}) {
7645
7660
  let string = "";
7646
7661
  for (let i = 0; i < value.length; i++)
7647
- string += hexes3[value[i]];
7662
+ string += hexes4[value[i]];
7648
7663
  const hex = `0x${string}`;
7649
7664
  if (typeof options.size === "number") {
7650
7665
  assertSize3(hex, options.size);
@@ -7733,14 +7748,14 @@ function validate2(value, options = {}) {
7733
7748
  return false;
7734
7749
  }
7735
7750
  }
7736
- var encoder4, hexes3, IntegerOutOfRangeError2, InvalidHexTypeError, InvalidHexValueError, SizeOverflowError3, SliceOffsetOutOfBoundsError3, SizeExceedsPaddingSizeError3;
7751
+ var encoder4, hexes4, IntegerOutOfRangeError2, InvalidHexTypeError, InvalidHexValueError, SizeOverflowError3, SliceOffsetOutOfBoundsError3, SizeExceedsPaddingSizeError3;
7737
7752
  var init_Hex = __esm({
7738
7753
  "../node_modules/ox/_esm/core/Hex.js"() {
7739
7754
  init_Errors();
7740
7755
  init_hex();
7741
7756
  init_Json();
7742
7757
  encoder4 = /* @__PURE__ */ new TextEncoder();
7743
- hexes3 = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
7758
+ hexes4 = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
7744
7759
  IntegerOutOfRangeError2 = class extends BaseError3 {
7745
7760
  constructor({ max, min, signed, size: size5, value }) {
7746
7761
  super(`Number \`${value}\` is not in safe${size5 ? ` ${size5 * 8}-bit` : ""}${signed ? " signed" : " unsigned"} integer range ${max ? `(\`${min}\` to \`${max}\`)` : `(above \`${min}\`)`}`);
@@ -8945,6 +8960,10 @@ var init_call = __esm({
8945
8960
  });
8946
8961
  var VolrContext = createContext(null);
8947
8962
  var InternalAuthContext = createContext(null);
8963
+ var ERROR_CODES = {
8964
+ AUTH_PROJECT_NOT_FOUND: "AUTH_PROJECT_NOT_FOUND",
8965
+ AUTH_PROJECT_REQUIRED: "AUTH_PROJECT_REQUIRED",
8966
+ ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED"};
8948
8967
  function mapBackendError(error) {
8949
8968
  return new VolrError(error.code, error.message);
8950
8969
  }
@@ -9021,6 +9040,32 @@ var STORAGE_CHANNELS = {
9021
9040
  };
9022
9041
 
9023
9042
  // src/headless/client.ts
9043
+ var CONFIG_ERROR_CODES = [
9044
+ ERROR_CODES.AUTH_PROJECT_NOT_FOUND,
9045
+ ERROR_CODES.AUTH_PROJECT_REQUIRED,
9046
+ ERROR_CODES.ORIGIN_NOT_ALLOWED
9047
+ ];
9048
+ function logConfigurationError(errorCode, errorMessage) {
9049
+ const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
9050
+ const errorMessages = {
9051
+ [ERROR_CODES.AUTH_PROJECT_NOT_FOUND]: `[Volr SDK] \u274C Invalid projectApiKey: Project not found.
9052
+ Please verify your VolrProvider config.projectApiKey is correct.
9053
+ You can find your API key in the Volr Dashboard > Project Settings.`,
9054
+ [ERROR_CODES.AUTH_PROJECT_REQUIRED]: `[Volr SDK] \u274C Missing projectApiKey.
9055
+ Please provide projectApiKey in your VolrProvider config.
9056
+ Example: <VolrProvider config={{ projectApiKey: 'your-api-key', ... }}>`,
9057
+ [ERROR_CODES.ORIGIN_NOT_ALLOWED]: `[Volr SDK] \u274C Origin not allowed for this project.
9058
+ The current origin is not in your project's allowed origins list.
9059
+ Add this origin in Volr Dashboard > Project Settings > Security.`
9060
+ };
9061
+ const devMessage = errorMessages[errorCode] || `[Volr SDK] \u274C Configuration error: ${errorCode}
9062
+ ${errorMessage}`;
9063
+ if (isDevelopment) {
9064
+ console.error(devMessage);
9065
+ } else {
9066
+ console.error(`[Volr SDK] Configuration error: ${errorCode}. Check console in development mode for details.`);
9067
+ }
9068
+ }
9024
9069
  var APIClient = class {
9025
9070
  constructor(config) {
9026
9071
  this.refreshPromise = null;
@@ -9067,6 +9112,14 @@ var APIClient = class {
9067
9112
  async (error) => {
9068
9113
  const originalRequest = error.config;
9069
9114
  const requestUrl = originalRequest?.url || "";
9115
+ const responseData = error.response?.data;
9116
+ if (responseData && !responseData.ok && responseData.error) {
9117
+ const errorCode = responseData.error.code;
9118
+ const errorMessage = responseData.error.message;
9119
+ if (CONFIG_ERROR_CODES.includes(errorCode)) {
9120
+ logConfigurationError(errorCode, errorMessage);
9121
+ }
9122
+ }
9070
9123
  const publicAuthEndpoints = [
9071
9124
  "/auth/refresh",
9072
9125
  "/auth/siwe/nonce",
@@ -18590,6 +18643,34 @@ function useVolr() {
18590
18643
  error
18591
18644
  };
18592
18645
  }
18646
+ init_sha3();
18647
+ init_utils2();
18648
+ function toChecksumAddress(address) {
18649
+ const addr = address.toLowerCase().replace("0x", "");
18650
+ const hash3 = bytesToHex2(keccak_256(new TextEncoder().encode(addr)));
18651
+ let checksummed = "0x";
18652
+ for (let i = 0; i < addr.length; i++) {
18653
+ if (parseInt(hash3[i], 16) >= 8) {
18654
+ checksummed += addr[i].toUpperCase();
18655
+ } else {
18656
+ checksummed += addr[i];
18657
+ }
18658
+ }
18659
+ return checksummed;
18660
+ }
18661
+ function detectWalletConnector() {
18662
+ if (typeof window === "undefined" || !window.ethereum) {
18663
+ return void 0;
18664
+ }
18665
+ const provider = window.ethereum;
18666
+ if (provider.info?.rdns) return provider.info.rdns;
18667
+ if (provider.isMetaMask) return "io.metamask";
18668
+ if (provider.isCoinbaseWallet) return "com.coinbase.wallet";
18669
+ if (provider.isRabby) return "io.rabby";
18670
+ if (provider.isZerion) return "io.zerion";
18671
+ if (provider.isBraveWallet) return "com.brave.wallet";
18672
+ return "unknown";
18673
+ }
18593
18674
  function useVolrLogin() {
18594
18675
  const { config, setUser } = useVolrContext();
18595
18676
  const { setAccessToken, setRefreshToken, client } = useInternalAuth();
@@ -18719,15 +18800,84 @@ function useVolrLogin() {
18719
18800
  },
18720
18801
  [client, setAccessToken, setRefreshToken, setUser, toVolrUser]
18721
18802
  );
18803
+ const signWithWallet = useCallback(
18804
+ async (walletAddress) => {
18805
+ if (typeof window === "undefined" || !window.ethereum) {
18806
+ throw new Error("No Ethereum wallet found. Please install MetaMask or another wallet.");
18807
+ }
18808
+ const ethereum = window.ethereum;
18809
+ const chainIdHex = await ethereum.request({ method: "eth_chainId" });
18810
+ const chainId = parseInt(chainIdHex, 16);
18811
+ const nonce = await requestSiweNonce();
18812
+ const domain = window.location.host;
18813
+ const origin = window.location.origin;
18814
+ const statement = "Sign in with Ethereum to continue";
18815
+ const issuedAt = (/* @__PURE__ */ new Date()).toISOString();
18816
+ const checksumAddress2 = toChecksumAddress(walletAddress);
18817
+ const message = `${domain} wants you to sign in with your Ethereum account:
18818
+ ${checksumAddress2}
18819
+
18820
+ ${statement}
18821
+
18822
+ URI: ${origin}
18823
+ Version: 1
18824
+ Chain ID: ${chainId}
18825
+ Nonce: ${nonce}
18826
+ Issued At: ${issuedAt}`;
18827
+ const signature = await ethereum.request({
18828
+ method: "personal_sign",
18829
+ params: [message, walletAddress]
18830
+ });
18831
+ const walletConnector = detectWalletConnector();
18832
+ return verifySiweSignature(message, signature, { walletConnector, chainId });
18833
+ },
18834
+ [requestSiweNonce, verifySiweSignature]
18835
+ );
18722
18836
  const handlePasskeyComplete = useCallback(async () => {
18723
18837
  }, []);
18838
+ const createSiweSession = useCallback(async () => {
18839
+ const response = await client.post("/auth/siwe/session", {});
18840
+ return response;
18841
+ }, [client]);
18842
+ const checkSiweSession = useCallback(
18843
+ async (sessionId) => {
18844
+ const response = await client.get(`/auth/siwe/session/${sessionId}`);
18845
+ if (response.status === "completed" && response.tokens && response.user) {
18846
+ setAccessToken(response.tokens.accessToken);
18847
+ setRefreshToken(response.tokens.refreshToken);
18848
+ setUser(toVolrUser(response.user));
18849
+ }
18850
+ return response;
18851
+ },
18852
+ [client, setAccessToken, setRefreshToken, setUser, toVolrUser]
18853
+ );
18854
+ const getSiweSignUrl = useCallback(
18855
+ (sessionId) => {
18856
+ const accentColor = config.accentColor || "#303030";
18857
+ const params = new URLSearchParams({
18858
+ session: sessionId,
18859
+ accentColor
18860
+ });
18861
+ if (apiBaseUrl.includes("dev-api") || apiBaseUrl.includes("localhost")) {
18862
+ params.set("env", "dev");
18863
+ }
18864
+ const lang = typeof navigator !== "undefined" ? navigator.language?.startsWith("ko") ? "ko" : "en" : "en";
18865
+ params.set("lang", lang);
18866
+ return `https://sign.volr.io?${params.toString()}`;
18867
+ },
18868
+ [apiBaseUrl, config]
18869
+ );
18724
18870
  return {
18725
18871
  requestEmailCode,
18726
18872
  verifyEmailCode,
18727
18873
  handleSocialLogin,
18728
18874
  requestSiweNonce,
18729
18875
  verifySiweSignature,
18730
- handlePasskeyComplete
18876
+ signWithWallet,
18877
+ handlePasskeyComplete,
18878
+ createSiweSession,
18879
+ checkSiweSession,
18880
+ getSiweSignUrl
18731
18881
  };
18732
18882
  }
18733
18883
  function useVolrAuthCallback(options = {}) {