@volr/react 0.1.130 → 0.1.131

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
@@ -9750,10 +9750,41 @@ function useSessionSync({
9750
9750
  }
9751
9751
 
9752
9752
  // src/config/webauthn.ts
9753
+ function isWindows() {
9754
+ if (typeof navigator === "undefined") return false;
9755
+ const platform = navigator.platform || "";
9756
+ return /Win/.test(platform);
9757
+ }
9758
+ function isLinux() {
9759
+ if (typeof navigator === "undefined") return false;
9760
+ const platform = navigator.platform || "";
9761
+ const ua = navigator.userAgent;
9762
+ return /Linux/.test(platform) && !/CrOS/.test(ua) && !/Android/.test(ua);
9763
+ }
9764
+ function shouldForceCrossDevice() {
9765
+ return isWindows() || isLinux();
9766
+ }
9753
9767
  var AUTHENTICATOR_SELECTION = {
9754
9768
  userVerification: "required",
9755
9769
  residentKey: "required"
9756
9770
  };
9771
+ var AUTHENTICATOR_SELECTION_CROSS_DEVICE = {
9772
+ userVerification: "required",
9773
+ residentKey: "required",
9774
+ authenticatorAttachment: "cross-platform"
9775
+ };
9776
+ function getAuthenticatorSelection() {
9777
+ if (shouldForceCrossDevice()) {
9778
+ return AUTHENTICATOR_SELECTION_CROSS_DEVICE;
9779
+ }
9780
+ return AUTHENTICATOR_SELECTION;
9781
+ }
9782
+ function getWebAuthnHints() {
9783
+ if (shouldForceCrossDevice()) {
9784
+ return ["hybrid"];
9785
+ }
9786
+ return void 0;
9787
+ }
9757
9788
  var CREDENTIAL_MEDIATION = "required";
9758
9789
  var USER_VERIFICATION = "required";
9759
9790
  var WEBAUTHN_TIMEOUT = 6e4;
@@ -9958,10 +9989,11 @@ function createPasskeyAdapter(options = {}) {
9958
9989
  type: "public-key"
9959
9990
  }
9960
9991
  ];
9992
+ const hints = getWebAuthnHints();
9961
9993
  return withWebAuthnLock(async () => {
9962
9994
  let credential = null;
9963
9995
  try {
9964
- credential = await navigator.credentials.get({
9996
+ const requestOptions = {
9965
9997
  publicKey: {
9966
9998
  challenge: crypto.getRandomValues(new Uint8Array(32)),
9967
9999
  rpId,
@@ -9974,11 +10006,15 @@ function createPasskeyAdapter(options = {}) {
9974
10006
  first: prfInput.salt.buffer
9975
10007
  }
9976
10008
  }
9977
- }
10009
+ },
10010
+ // Chrome 128+ supports hints to prioritize certain authenticator types
10011
+ // On Windows/Linux, this prioritizes QR code over USB security key prompt
10012
+ ...hints && { hints }
9978
10013
  },
9979
10014
  mediation: CREDENTIAL_MEDIATION
9980
10015
  // Use shared constant
9981
- });
10016
+ };
10017
+ credential = await navigator.credentials.get(requestOptions);
9982
10018
  } catch (error) {
9983
10019
  console.error("[PasskeyAdapter] WebAuthn get() failed:", error);
9984
10020
  console.error("[PasskeyAdapter] Error name:", error?.name);
@@ -19652,6 +19688,8 @@ async function enrollPasskey(params) {
19652
19688
  };
19653
19689
  const prfSalt = deriveWrapKey(tempPrfInput);
19654
19690
  const displayName = buildDisplayName(userEmail, userEvmAddress, userId);
19691
+ const authenticatorSelection = getAuthenticatorSelection();
19692
+ const hints = getWebAuthnHints();
19655
19693
  const publicKeyCredentialCreationOptions = {
19656
19694
  challenge: challenge2,
19657
19695
  rp: {
@@ -19664,7 +19702,7 @@ async function enrollPasskey(params) {
19664
19702
  displayName
19665
19703
  },
19666
19704
  pubKeyCredParams: PUBKEY_CRED_PARAMS,
19667
- authenticatorSelection: AUTHENTICATOR_SELECTION,
19705
+ authenticatorSelection,
19668
19706
  timeout: WEBAUTHN_TIMEOUT,
19669
19707
  attestation: ATTESTATION,
19670
19708
  extensions: {
@@ -19673,7 +19711,10 @@ async function enrollPasskey(params) {
19673
19711
  first: prfSalt.buffer
19674
19712
  }
19675
19713
  }
19676
- }
19714
+ },
19715
+ // Chrome 128+ supports hints to prioritize certain authenticator types
19716
+ // On Windows/Linux, this prioritizes QR code over USB security key prompt
19717
+ ...hints && { hints }
19677
19718
  };
19678
19719
  const credential = await navigator.credentials.create({
19679
19720
  publicKey: publicKeyCredentialCreationOptions
@@ -20867,7 +20908,12 @@ function getPlatformHint(platform) {
20867
20908
  case "Windows":
20868
20909
  return {
20869
20910
  hintKey: "passkey.hint.windows",
20870
- noteKey: "passkey.hint.note"
20911
+ noteKey: "passkey.hint.windowsNote"
20912
+ };
20913
+ case "Linux":
20914
+ return {
20915
+ hintKey: "passkey.hint.linux",
20916
+ noteKey: "passkey.hint.windowsNote"
20871
20917
  };
20872
20918
  default:
20873
20919
  return {
@@ -21061,6 +21107,8 @@ async function completeMigration(params) {
21061
21107
  credentialId: tempCredentialId
21062
21108
  };
21063
21109
  const prfSalt = deriveWrapKey(tempPrfInput);
21110
+ const authenticatorSelection = getAuthenticatorSelection();
21111
+ const hints = getWebAuthnHints();
21064
21112
  const publicKeyCredentialCreationOptions = {
21065
21113
  challenge: challenge2,
21066
21114
  rp: {
@@ -21073,7 +21121,7 @@ async function completeMigration(params) {
21073
21121
  displayName
21074
21122
  },
21075
21123
  pubKeyCredParams: PUBKEY_CRED_PARAMS,
21076
- authenticatorSelection: AUTHENTICATOR_SELECTION,
21124
+ authenticatorSelection,
21077
21125
  timeout: WEBAUTHN_TIMEOUT,
21078
21126
  attestation: ATTESTATION,
21079
21127
  extensions: {
@@ -21082,7 +21130,10 @@ async function completeMigration(params) {
21082
21130
  first: prfSalt.buffer
21083
21131
  }
21084
21132
  }
21085
- }
21133
+ },
21134
+ // Chrome 128+ supports hints to prioritize certain authenticator types
21135
+ // On Windows/Linux, this prioritizes QR code over USB security key prompt
21136
+ ...hints && { hints }
21086
21137
  };
21087
21138
  const credential = await navigator.credentials.create({
21088
21139
  publicKey: publicKeyCredentialCreationOptions