@volr/react 0.1.64 → 0.1.66

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.js CHANGED
@@ -9463,7 +9463,6 @@ function useSessionSync({
9463
9463
 
9464
9464
  // src/config/webauthn.ts
9465
9465
  var AUTHENTICATOR_SELECTION = {
9466
- authenticatorAttachment: "platform",
9467
9466
  userVerification: "required",
9468
9467
  residentKey: "required"
9469
9468
  };
@@ -18870,6 +18869,30 @@ function useDepositListener(input) {
18870
18869
  }, [getRpcUrl, input.chainId, input.address, JSON.stringify(input.asset)]);
18871
18870
  return status;
18872
18871
  }
18872
+ function detectPlatform() {
18873
+ if (typeof navigator === "undefined") return "Unknown";
18874
+ const ua = navigator.userAgent;
18875
+ const platform = navigator.platform || "";
18876
+ if (/iPhone|iPad|iPod/.test(ua) || platform === "MacIntel" && navigator.maxTouchPoints > 1) {
18877
+ return "iOS";
18878
+ }
18879
+ if (/Android/.test(ua)) {
18880
+ return "Android";
18881
+ }
18882
+ if (/Mac/.test(platform)) {
18883
+ return "macOS";
18884
+ }
18885
+ if (/Win/.test(platform)) {
18886
+ return "Windows";
18887
+ }
18888
+ if (/CrOS/.test(ua)) {
18889
+ return "ChromeOS";
18890
+ }
18891
+ if (/Linux/.test(platform)) {
18892
+ return "Linux";
18893
+ }
18894
+ return "Unknown";
18895
+ }
18873
18896
  async function enrollPasskey(params) {
18874
18897
  const {
18875
18898
  client,
@@ -18877,6 +18900,7 @@ async function enrollPasskey(params) {
18877
18900
  apiKey,
18878
18901
  userId,
18879
18902
  userEmail,
18903
+ userEvmAddress,
18880
18904
  projectId,
18881
18905
  rpId = typeof window !== "undefined" ? window.location.hostname : "localhost",
18882
18906
  rpName = "Volr"
@@ -18884,9 +18908,6 @@ async function enrollPasskey(params) {
18884
18908
  if (!userId) {
18885
18909
  throw new Error("userId is required");
18886
18910
  }
18887
- if (!userEmail) {
18888
- throw new Error("userEmail is required");
18889
- }
18890
18911
  if (!projectId) {
18891
18912
  throw new Error("projectId is required");
18892
18913
  }
@@ -18910,6 +18931,7 @@ async function enrollPasskey(params) {
18910
18931
  credentialId: tempCredentialId
18911
18932
  };
18912
18933
  const prfSalt = deriveWrapKey(tempPrfInput);
18934
+ const displayName = userEmail || userEvmAddress || userId;
18913
18935
  const publicKeyCredentialCreationOptions = {
18914
18936
  challenge: challenge2,
18915
18937
  rp: {
@@ -18918,8 +18940,8 @@ async function enrollPasskey(params) {
18918
18940
  },
18919
18941
  user: {
18920
18942
  id: userHandle,
18921
- name: userEmail,
18922
- displayName: userEmail
18943
+ name: displayName,
18944
+ displayName
18923
18945
  },
18924
18946
  pubKeyCredParams: PUBKEY_CRED_PARAMS,
18925
18947
  authenticatorSelection: AUTHENTICATOR_SELECTION,
@@ -18990,6 +19012,7 @@ async function enrollPasskey(params) {
18990
19012
  }
18991
19013
  const keypair = deriveEvmKey({ masterSeed: masterSeedHandle.bytes });
18992
19014
  const address = keypair.address;
19015
+ const platform = detectPlatform();
18993
19016
  const registerResponse = await client.post("/wallet/provider/register", {
18994
19017
  keyStorageType: "passkey",
18995
19018
  credentialId,
@@ -18999,7 +19022,9 @@ async function enrollPasskey(params) {
18999
19022
  projectId,
19000
19023
  credentialId
19001
19024
  },
19002
- address
19025
+ address,
19026
+ platform
19027
+ // For UX hints when authenticating on different devices
19003
19028
  });
19004
19029
  return {
19005
19030
  credentialId,
@@ -19035,9 +19060,6 @@ function usePasskeyEnrollment() {
19035
19060
  if (!user?.id) {
19036
19061
  throw new Error("User ID is required for passkey enrollment");
19037
19062
  }
19038
- if (!user?.email) {
19039
- throw new Error("User email is required for passkey enrollment");
19040
- }
19041
19063
  const accessToken = client.getAccessToken();
19042
19064
  if (!accessToken) {
19043
19065
  throw new Error(
@@ -19051,7 +19073,8 @@ function usePasskeyEnrollment() {
19051
19073
  baseUrl: apiBaseUrl,
19052
19074
  apiKey: config.projectApiKey,
19053
19075
  userId: user.id,
19054
- userEmail: user.email,
19076
+ userEmail: user.email ?? null,
19077
+ userEvmAddress: user.evmAddress ?? null,
19055
19078
  projectId
19056
19079
  });
19057
19080
  setStep("registering");