Data ethAddress does not match response address

The torus service provider has recently started throwing this data ethAddress does not match response address error and it is blocking some of our users from authenticating with TKey. We’re not providing any sort of address during authentication, so I have no idea how we can fix this issue from our end. Please assist

export async function initializeServiceProviderShare(
  jwt: string
): Promise<TKeyServiceProviderLoginDetails | undefined> {
  try {
    // @ts-expect-error Tkey types lacks the 'serviceProvider' property
    await tKey.serviceProvider.init({ skipSw: true, skipPrefetch: true });
    // @ts-expect-error Tkey types lacks the 'serviceProvider' property
    const loginDetails = await tKey.serviceProvider.triggerLogin({
      typeOfLogin: LOGIN_PROVIDER.JWT,
      verifier: env.web3AuthVerifier,
      clientId: env.web3AuthClientId,
      jwtParams: {
        id_token: jwt,
        verifierIdField: "email",
      },
    });

    const pbKey = new BN(loginDetails.privateKey, "hex");
    // The postboxKey is used by the storage layer to fetch the metadata associated with the service provider share
    // Tech doc: https://hackmd.io/Tej2tf83SZOxZmz70ObEpg
    tKey.serviceProvider.postboxKey = pbKey;
    return loginDetails;
  } catch (error: any) {
    if (
      error.message?.includes(
        "Error occurred while verifying paramstimesigned is more than 1m0s ago"
      )
    ) {
      throw new ExpiredTokenError();
    }
    if (error.message === "Duplicate token found") {
      throw new DuplicateTokenError();
    }
    console.error("[initializeServiceProviderShare]", error);
    throw error;
  }
}

Please provide the following details too when asking for help in this category:

  • SDK Version:
    @tkey/common-types”: “7.2.0”,
    @tkey/default”: “7.2.0”,
    @tkey/service-provider-torus”: “^7.3.0”,
    @tkey/share-serialization”: “^7.3.0”,
    @tkey/storage-layer-torus”: “^7.3.0”,

  • Verifier Details:

@noelc Thanks for your recent communication.

Your issue has been forwarded to our team and we will get back with further updates once more information becomes available.

@vjgee
Please help us as soon as possible, as we have many users facing this issue, they cannot do anything with their balance and they started to blame and report us.

Can you update to the latest version of the SDK and check once?

Upgrading to the latest SDK requires a complete overhaul of how we’re initializing TKey. I’m afraid doing so would also put our users further at risk of losing their private key because the latest SDK requires reconfiguring how we retrieve the user’s private key (we’d have to replace TorusServiceProvider with SfaServiceProvider, which requires a chainConfig. Our current implementation does not require a chainConfig and it was working just fine until recently).

Is there any less riskier solution? Preferably using the same SDK version we’re currently using?

I get Unable to resolve enough promises if I were to continue using TorusServiceProvider.

@yashovardhan @vjgee We are currently facing a critical issue affecting every user with TKey. A sudden, unannounced change on your end has resulted in severe consequences, blocking our users from accessing their funds because TKey is now unable to authorize their social share.

It does not require you to replace the service provider, the TorusServiceProvider will work as usual. There has been no change in the way our tKey SDK works. SFA Service Provider is a new option, but not a necessary upgradation.

Please share your code snippets after upgrading to the latest version of tKey. Also share your console log for error details.

I’ll start by sharing the code snippets and log details after the upgrade. Then after, I’ll share the code snippets and log details before the upgrade, the code that was working just fine the past few months.

Code snippets after upgrading:

function createTKey() {
  const directParams = {
    baseUrl: "http://localhost:3000",
    enableLogging: true,
    network: isTestnet ? OPENLOGIN_NETWORK.TESTNET : OPENLOGIN_NETWORK.MAINNET,
    web3AuthClientId: env.web3AuthClientId,
  };

  const serviceProvider = new ServiceProviderTorus({
    customAuthArgs: directParams,
  });
  const storageLayer = new TorusStorageLayer({
    hostUrl: "https://metadata.tor.us",
    serverTimeOffset: 3600000,
  });

  return new ThresholdKey({
    serviceProvider,
    storageLayer,
    modules: {
      [MOBILE_DEVICE_SHARE_MODULE]: new MobileDeviceShareModule(),
    },
    manualSync: false,
  });
}

const tKey = createTKey();

export async function initializeServiceProviderShare(
  jwt: string
): Promise<TKeyServiceProviderLoginDetails | undefined> {
  try {
    await tKey.serviceProvider.init({ skipSw: true, skipPrefetch: true });
    const loginDetails = await tKey.serviceProvider.triggerLogin({
      typeOfLogin: LOGIN_PROVIDER.JWT,
      verifier: env.web3AuthVerifier,
      clientId: env.web3AuthClientId,
      jwtParams: {
        id_token: jwt,
        verifierIdField: "email",
      },
    });

    const pbKey = new BN(loginDetails.privateKey, "hex");
    // The postboxKey is used by the storage layer to fetch the metadata associated with the service provider share
    // Tech doc: https://hackmd.io/Tej2tf83SZOxZmz70ObEpg
    tKey.serviceProvider.postboxKey = pbKey;
    return loginDetails;
  } catch (error: any) {
    if (
      error.message?.includes(
        "Error occurred while verifying paramstimesigned is more than 1m0s ago"
      )
    ) {
      throw new ExpiredTokenError();
    }
    if (error.message === "Duplicate token found") {
      throw new DuplicateTokenError();
    }
    console.error("[initializeServiceProviderShare]", error.stack);
    throw error;
  }
}

Console log with error details:

 INFO  {"browser":{"name":"","version":""},"os":{},"platform":{},"engine":{}} current browser info
 INFO  Verifier:  nft5-verifier-testnet
 LOG  torus-direct/getTorusKey {"torusNodeEndpoints": ["https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc"]}
 ERROR  [initializeServiceProviderShare] Unable to resolve enough promises.
    at construct (native)
    at apply (native)
    at _construct (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:3261:28)
    at Wrapper (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:3223:25)
    at construct (native)
    at _createSuperInternal (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:429741:294)
    at call (native)
    at SomeError (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:430411:29)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:430479:39)
    at anonymous (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:418:28)
    at tryCallOne (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16)
    at anonymous (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/2q6r403w/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27)
    at apply (native)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29567:26)
    at _callTimer (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29486:17)
    at _callReactNativeMicrotasksPass (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29516:17)
    at callReactNativeMicrotasks (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29679:44)
    at __callReactNativeMicrotasks (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2688:46)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2500:45)
    at __guard (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2672:15)
    at flushedQueue (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2499:21)
    at invokeCallbackAndReturnFlushedQueue (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2493:33)

Patch file we have to change due to the ‘document’ error on mobile for customauth:

// patches/@toruslabs+customauth+16.0.0.patch
diff --git a/node_modules/@toruslabs/customauth/dist/customauth.cjs.js b/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
index 2da94ca..09161cf 100644
--- a/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
+++ b/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
@@ -260,18 +260,19 @@ function storageAvailable(type) {
 }
 function getPopupFeatures() {
   // Fixes dual-screen position                             Most browsers      Firefox
-  const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
-  const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
-  const w = 1200;
-  const h = 700;
-  const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width;
-  const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height;
-  const systemZoom = 1; // No reliable estimate
-
-  const left = Math.abs((width - w) / 2 / systemZoom + dualScreenLeft);
-  const top = Math.abs((height - h) / 2 / systemZoom + dualScreenTop);
-  const features = `titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${h / systemZoom},width=${w / systemZoom},top=${top},left=${left}`;
-  return features;
+  // const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
+  // const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
+  // const w = 1200;
+  // const h = 700;
+  // const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width;
+  // const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height;
+  // const systemZoom = 1; // No reliable estimate
+
+  // const left = Math.abs((width - w) / 2 / systemZoom + dualScreenLeft);
+  // const top = Math.abs((height - h) / 2 / systemZoom + dualScreenTop);
+  // const features = `titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${h / systemZoom},width=${w / systemZoom},top=${top},left=${left}`;
+  // return features;
+  return "";
 }
 const isFirefox = () => {
   var _window;

Code snippets before upgrading:

function createTKey() {
  const directParams = {
    baseUrl: "http://localhost:3000",
    enableLogging: true,
    network: isTestnet ? OPENLOGIN_NETWORK.TESTNET : OPENLOGIN_NETWORK.MAINNET,
  };

  const serviceProvider = new ServiceProviderTorus({
    customAuthArgs: directParams,
  });
  const storageLayer = new TorusStorageLayer({
    hostUrl: "https://metadata.tor.us",
    serverTimeOffset: 3600000,
  });

  return new ThresholdKey({
    serviceProvider,
    storageLayer,
    modules: {
      [MOBILE_DEVICE_SHARE_MODULE]: new MobileDeviceShareModule(),
    },
    manualSync: false,
  });
}

const tKey = createTKey();


export async function initializeServiceProviderShare(
  jwt: string
): Promise<TKeyServiceProviderLoginDetails | undefined> {
  try {
    await tKey.serviceProvider.init({ skipSw: true, skipPrefetch: true });
    const loginDetails = await tKey.serviceProvider.triggerLogin({
      typeOfLogin: LOGIN_PROVIDER.JWT,
      verifier: env.web3AuthVerifier,
      clientId: env.web3AuthClientId,
      jwtParams: {
        id_token: jwt,
        verifierIdField: "email",
      },
    });

    const pbKey = new BN(loginDetails.privateKey, "hex");
    // The postboxKey is used by the storage layer to fetch the metadata associated with the service provider share
    // Tech doc: https://hackmd.io/Tej2tf83SZOxZmz70ObEpg
    tKey.serviceProvider.postboxKey = pbKey;
    return loginDetails;
  } catch (error: any) {
    if (
      error.message?.includes(
        "Error occurred while verifying paramstimesigned is more than 1m0s ago"
      )
    ) {
      throw new ExpiredTokenError();
    }
    if (error.message === "Duplicate token found") {
      throw new DuplicateTokenError();
    }
    console.error("[initializeServiceProviderShare]", error.stack);
    throw error;
  }
}

Console log with error details (this is what I’m currently getting with 1 account)

 INFO  {"browser":{"name":"","version":""},"os":{},"platform":{},"engine":{}} current browser info
 INFO  Verifier:  nft5-verifier-testnet
 LOG  torus-direct/getTorusKey {"torusIndexes": [1, 2, 3, 4, 5], "torusNodeEndpoints": ["https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc"], "torusNodePub": [{"X": "f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", "Y": "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7"}, {"X": "bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", "Y": "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a"}, {"X": "b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", "Y": "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c"}, {"X": "7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", "Y": "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b"}, {"X": "bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", "Y": "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4"}]}
 LOG  torus-direct/getTorusKey {"getPublicAddress": {"X": "93d4ff5b8d1096bd3f03ec576ed67b92195266cde9a7fef01b1ce99328ba2a70", "Y": "2b1ca1e48e53d7ca95424bb01ab873be8980fbf24210cd554acb519cddcecb3a", "address": "0xBcEac6E8eEb53D8348aBdE56678Fc44f186D1A97", "metadataNonce": "00", "pubNonce": undefined, "typeOfUser": "v1", "upgraded": undefined}}
 LOG  torus-direct/getTorusKey {"retrieveShares": {"ethAddress": "0xBcEac6E8eEb53D8348aBdE56678Fc44f186D1A97", "metadataNonce": "00", "privKey": "a6b86d25dea539f8daa7fdcb9ff1bd3f532d5b158f8ac787b4f71fdc68f36ee6"}}
 ERROR  [setupDeviceShare] {"errorMessage": "setMetadata errored Assertion failed", "errorStack": "{\"name\":\"CoreError\",\"code\":1103,\"message\":\"setMetadata errored Assertion failed\"}
    at fromCode (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:425657:31)
    at metadataPostFailed (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:425687:36)
    at ?anon_0_ (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:426866:46)
    at throw (native)
    at asyncGeneratorStep (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:4556:26)
    at _throw (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:4578:29)
    at invokeCallback (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446832:27)
    at publish (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446818:25)
    at publishRejection (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446774:14)
    at flush (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446631:17)
    at apply (native)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29547:26)
    at _callTimer (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29486:17)
    at callTimers (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29642:19)
    at apply (native)
    at __callFunction (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2721:36)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2482:31)
    at __guard (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2672:15)
    at callFunctionReturnFlushedQueue (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2481:21)"}
 LOG  8:04:51 PM | [useTKeyInitializationFlow] | ERROR : [setupDeviceShare] An occurred with TKey storage layer

The code for setupDeviceShare is:

export async function setupDeviceShare() {
  try {
    const keyDetails = await tKey.initialize(); // 2/3 flow - NOTE: This will create the device share if it does not exist
    const { requiredShares } = keyDetails;
    Logger.debug("[setupDeviceShare]", { requiredShares });
    if (requiredShares > 0) {
      // This means the user setup 2FA from Web3Auth flow and we need to recover it.
      throw new InsufficientSharesError(`Required shares: ${requiredShares}`);
    }
  } catch (error: any) {
    console.error("[setupDeviceShare]", {
      errorMessage: error.message,
      errorStack: error.stack,
    });
    if (
      METADATA_RELATED_ERROR_MESSAGES.some((message) =>
        error.message.includes(message)
      )
    ) {
      throw new MetadataError(error.message);
    }
  }
}

This is the console log with error details using a different account:

 INFO  {"browser":{"name":"","version":""},"os":{},"platform":{},"engine":{}} current browser info
 INFO  Verifier:  nft5-verifier-testnet
 LOG  torus-direct/getTorusKey {"torusIndexes": [1, 2, 3, 4, 5], "torusNodeEndpoints": ["https://sapphire-dev-2-1.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-2.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-3.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-4.authnetwork.dev/sss/teal/jrpc", "https://sapphire-dev-2-5.authnetwork.dev/sss/teal/jrpc"], "torusNodePub": [{"X": "f74389b0a4c8d10d2a687ae575f69b20f412d41ab7f1fe6b358aa14871327247", "Y": "54e3a73098ed9bced3ef8821736e9794f9264a1420c0c7ad15d2fa617ba35ef7"}, {"X": "bc38813a6873e526087918507c78fc3a61624670ee851ecfb4f3bef55d027b5a", "Y": "ac4b21229f662a0aefdfdac21cf17c3261a392c74a8790db218b34e3e4c1d56a"}, {"X": "b56541684ea5fa40c8337b7688d502f0e9e092098962ad344c34e94f06d293fb", "Y": "759a998cef79d389082f9a75061a29190eec0cac99b8c25ddcf6b58569dad55c"}, {"X": "7bcb058d4c6ffc6ba4bfdfd93d141af35a66338a62c7c27cdad2ae3f8289b767", "Y": "336ab1935e41ed4719e162587f0ab55518db4207a1eb36cc72303f1b86689d2b"}, {"X": "bf12a136ef94399ea098f926f04e26a4ec4ac70f69cce274e8893704c4951773", "Y": "bdd44828020f52ce510e026338216ada184a6867eb4e19fb4c2d495d4a7e15e4"}]}
 LOG  torus-direct/getTorusKey {"getPublicAddress": {"X": "1843e2f416d6370096c7950fa99c0c7bcf80dba8117720365bf14711386bb4db", "Y": "8a8085da380db3d2e627d2b9284a6c24a3acc2bc067dff90120b75113971949d", "address": "0x82973543270490057653D32a602FaDA93E4EdC23", "metadataNonce": "00", "pubNonce": undefined, "typeOfUser": "v1", "upgraded": undefined}}
 LOG  torus-direct/getTorusKey {"retrieveShares": {"ethAddress": "0x82973543270490057653D32a602FaDA93E4EdC23", "metadataNonce": "00", "privKey": "8b2badbe99445c8e51232fc0301faabf52315604b038c52191666e4e0960cece"}}
 ERROR  [setupDeviceShare] {"errorMessage": "setMetadata errored Assertion failed", "errorStack": "{\"name\":\"CoreError\",\"code\":1103,\"message\":\"setMetadata errored Assertion failed\"}
    at fromCode (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:425657:31)
    at metadataPostFailed (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:425687:36)
    at ?anon_0_ (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:426866:46)
    at throw (native)
    at asyncGeneratorStep (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:4556:26)
    at _throw (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:4578:29)
    at invokeCallback (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446832:27)
    at publish (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446818:25)
    at publishRejection (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446774:14)
    at flush (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:446631:17)
    at apply (native)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29547:26)
    at _callTimer (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29486:17)
    at callTimers (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:29642:19)
    at apply (native)
    at __callFunction (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2721:36)
    at anonymous (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2482:31)
    at __guard (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2672:15)
    at callFunctionReturnFlushedQueue (http://192.168.1.5:8081/index.bundle?platform=android&dev=true&minify=false&app=com.nft5.imota.dev&modulesOnly=false&runModule=true:2481:21)"}
 LOG  8:08:33 PM | [useTKeyInitializationFlow] | ERROR : [setupDeviceShare] An occurred with TKey storage layer

Patch file we have to change due to the ‘document’ error on mobile for customauth (and has been working for several months):

// patches/@toruslabs+customauth+11.5.0.patch

diff --git a/node_modules/@toruslabs/customauth/dist/customauth-bundled.cjs.js b/node_modules/@toruslabs/customauth/dist/customauth-bundled.cjs.js
index 6caceb7..d5ba346 100644
--- a/node_modules/@toruslabs/customauth/dist/customauth-bundled.cjs.js
+++ b/node_modules/@toruslabs/customauth/dist/customauth-bundled.cjs.js
@@ -44277,19 +44277,7 @@ function storageAvailable(type) {
   }
 }
 function getPopupFeatures() {
-  // Fixes dual-screen position                             Most browsers      Firefox
-  const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
-  const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
-  const w = 1200;
-  const h = 700;
-  const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width;
-  const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height;
-  const systemZoom = 1; // No reliable estimate
-
-  const left = Math.abs((width - w) / 2 / systemZoom + dualScreenLeft);
-  const top = Math.abs((height - h) / 2 / systemZoom + dualScreenTop);
-  const features = `titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${h / systemZoom},width=${w / systemZoom},top=${top},left=${left}`;
-  return features;
+    return "";
 }
 const isFirefox = () => {
   var _window, _window$navigator;
diff --git a/node_modules/@toruslabs/customauth/dist/customauth.cjs.js b/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
index 6fec82a..1fa7e57 100644
--- a/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
+++ b/node_modules/@toruslabs/customauth/dist/customauth.cjs.js
@@ -273,19 +273,7 @@ function storageAvailable(type) {
   }
 }
 function getPopupFeatures() {
-  // Fixes dual-screen position                             Most browsers      Firefox
-  const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
-  const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
-  const w = 1200;
-  const h = 700;
-  const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width;
-  const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height;
-  const systemZoom = 1; // No reliable estimate
-
-  const left = Math.abs((width - w) / 2 / systemZoom + dualScreenLeft);
-  const top = Math.abs((height - h) / 2 / systemZoom + dualScreenTop);
-  const features = `titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${h / systemZoom},width=${w / systemZoom},top=${top},left=${left}`;
-  return features;
+  return "";
 }
 const isFirefox = () => {
   var _window, _window$navigator;
diff --git a/node_modules/@toruslabs/customauth/src/utils/helpers.ts b/node_modules/@toruslabs/customauth/src/utils/helpers.ts
index fd76e86..b8bf338 100644
--- a/node_modules/@toruslabs/customauth/src/utils/helpers.ts
+++ b/node_modules/@toruslabs/customauth/src/utils/helpers.ts
@@ -129,31 +129,7 @@ export function storageAvailable(type: REDIRECT_PARAMS_STORAGE_METHOD_TYPE): boo
 }
 
 export function getPopupFeatures(): string {
-  // Fixes dual-screen position                             Most browsers      Firefox
-  const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
-  const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
-
-  const w = 1200;
-  const h = 700;
-
-  const width = window.innerWidth
-    ? window.innerWidth
-    : document.documentElement.clientWidth
-    ? document.documentElement.clientWidth
-    : window.screen.width;
-
-  const height = window.innerHeight
-    ? window.innerHeight
-    : document.documentElement.clientHeight
-    ? document.documentElement.clientHeight
-    : window.screen.height;
-
-  const systemZoom = 1; // No reliable estimate
-
-  const left = Math.abs((width - w) / 2 / systemZoom + dualScreenLeft);
-  const top = Math.abs((height - h) / 2 / systemZoom + dualScreenTop);
-  const features = `titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${h / systemZoom},width=${w / systemZoom},top=${top},left=${left}`;
-  return features;
+  return "";
 }
 
 export const isFirefox = (): boolean => window?.navigator?.userAgent.toLowerCase().indexOf("firefox") > -1 || false;

@noelc can you additionally upgrade @toruslabs/customauth package to v16? Please delete your package.lock and then try so that all the web3auth packages are updated. @tkey packages are good to go on v11.

Let me know if that solves the issue.

I already tried using @toruslabs/customauth v16 and it doesn’t help. You can also see the associated patch file in the code snippet I provided above for the post-upgrade.

After consulting with the Web3Auth team, we discovered that the root cause of the issue was linked to this problem. We had been using it as an alternative for bn.js, which led to BN formatting problems that subsequently affected TKey. We would like to extend our gratitude to cherngwoei@tor.us for helping us identify this problem.

Additionally, I recommend the TKey team to enhance their error response and handling within the TKey SDK. This is crucial, as several network-related errors make debugging challenging.

Since implementing the fix, we’ve observed no further instances of the data ethAddress does not match response address errors in our production environment. Consequently, this issue can now be marked as resolved.