When asking for help in this category, please make sure to provide the following details:
-
SDK Version: @web3auth/single-factor-auth": “^9.5.0”,
-
Platform: React native - expo
-
Browser Console Screenshots:
-
If the issue is related to Custom Authentication, please include the following information (optional):
- Verifier Name: kalki-firebase-test (firebase)
- JWKS Endpoint:
- Sample idToken (JWT):
Also, kindly provide the Web3Auth initialization and login code snippet below. This will help us better understand your issue and provide you with the necessary assistance.
const clientId = process.env.EXPO_PUBLIC_WEB3AUTH_CLIENT_ID;
const verifier = process.env.EXPO_PUBLIC_FIREBASE_VERIFIER_IDENTIFIER;
console.log(‘Web3Auth Configuration:’, {
clientId,
verifier,
network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
chainConfig: POLYGON_AMOY_CHAIN_CONFIG
});
// Initialize private key provider
const privateKeyProvider = new EthereumPrivateKeyProvider({
config: {chainConfig: POLYGON_AMOY_CHAIN_CONFIG},
});
// Initialize Web3Auth instance
const web3auth = new Web3Auth({
clientId,
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
privateKeyProvider,
storage: SecureStore,
mode: SDK_MODE.REACT_NATIVE,
});
console.log(‘web3auth:’, web3auth);
interface Web3AuthContextType {
web3AuthLoading: boolean;
web3AuthInitializationError: any;
provider: IProvider | null;
web3authLoggedIn: boolean;
initialized: boolean;
updateWeb3AuthProviderAfterLogin: (loginResult: any) => Promise<string | null>;
}
const Web3AuthContext = createContext<Web3AuthContextType | null>(null);
export const Web3AuthProvider: FC<{ children: React.ReactNode }> = ({ children }) => {
const [web3AuthLoading, setWeb3AuthLoading] = useState(true);
const [web3AuthInitializationError, setWeb3AuthInitializationError] = useState(null);
const [provider, setProvider] = useState<IProvider | null>(null);
const [web3authLoggedIn, setWeb3authLoggedIn] = useState(false);
const [initialized, setInitialized] = useState(false);
useEffect(() => {
let mounted = true;
const init = async () => {
if (!mounted) return;
try {
console.log('Initializing Web3Auth...');
await web3auth.init();
console.log('Web3Auth initialized successfully');
setWeb3AuthLoading(false);
setInitialized(true);
console.log('Web3Auth provider:', web3auth.provider);
if (web3auth.provider) {
setProvider(web3auth.provider);
console.log('Web3Auth provider:', web3auth.provider);
}
if(web3auth.connected){
setWeb3authLoggedIn(true);
}
} catch (error) {
console.error('Error initializing Web3Auth:', error);
if (mounted) {
setWeb3AuthInitializationError(error);
}
} finally {
if (mounted) {
setWeb3AuthLoading(false);
}
}
};
init();
return () => {
mounted = false;
};
}, []);
const updateWeb3AuthProviderAfterLogin = async (loginResult: any) => {
try {
if (!web3auth) {
console.error(‘Web3Auth instance is not available’);
return “Web3Auth instance is not available”;
}
if (!loginResult) {
console.error('Login result is null or undefined');
return "Invalid login result";
}
console.log('Getting ID token...');
const idToken = await loginResult.getIdToken(true);
if (!idToken) {
console.error('Failed to get ID token');
return "Failed to get ID token";
}
console.log('Decoding token...');
const parsedToken = decodeToken(idToken);
console.log('Payload:', parsedToken);
const sub = parsedToken.payload.sub;
if (!sub) {
console.error('Invalid token payload: missing sub');
return "Invalid token payload";
}
console.log('sub:', sub);
console.log('Connecting to Web3Auth with:', {
verifier,
verifierId: sub,
hasIdToken: !!idToken,
clientId,
network: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET
});
try {
const web3authProvider = await web3auth.connect({
verifier,
verifierId: sub,
idToken,
});
if (web3authProvider) {
console.log('Successfully connected to Web3Auth');
setProvider(web3authProvider);
setWeb3authLoggedIn(true);
console.log('web3authProvider:', web3authProvider);
const ethProvider = new ethers.BrowserProvider(web3authProvider);
const signer = await ethProvider.getSigner();
const address = await signer.getAddress();
console.log('address:', address);
} else {
console.error('Web3Auth provider is null after connect');
return "web3auth provider not updated";
}
} catch (connectError) {
console.error('Error during Web3Auth connect:', connectError);
if (connectError instanceof Error) {
return `Error during Web3Auth connect: ${connectError.message}`;
}
return "Error during Web3Auth connect";
}
} catch (error) {
console.error('Error updating Web3Auth provider:', error);
if (error instanceof Error) {
return `Error updating Web3Auth provider: ${error.message}`;
}
return "Error updating Web3Auth provider";
}
};
const value: Web3AuthContextType = {
web3AuthLoading,
web3AuthInitializationError,
provider,
web3authLoggedIn,
initialized,
updateWeb3AuthProviderAfterLogin,
};
return React.createElement(Web3AuthContext.Provider, { value }, children);
};
Error Message:
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) WARN Failed to decrypt padded share cipher [TypeError: Cannot read property ‘digest’ of undefined]
(NOBRIDGE) ERROR Error during Web3Auth connect: [Error: Unable to resolve enough promises.
errors: , , , , ,
predicate error: Insufficient number of signatures from nodes, required: 3, found: 0,
Please help to resolve this issue