Hello, i’m trying to implement the single factor auth using custom jwt but some wierd error happens. When i use the node-sdk
with same code but the import from node-sdk
seems to be working.
- SDK Version:
"@web3auth/single-factor-auth": "^5.1.0"
-
Platform:
React with Vite and TS. -
Browser Console Screenshots:
JWKS endpoint is https://a11b-2a02-2f0d-602-fa00-54be-f85b-380b-e0f2.ngrok.io/.well-known/jwks.json but it works only when my laptop is online so here are the contents:
{
"keys": [
{
"kty": "RSA",
"e": "AQAB",
"n": "vcx_9vckbEsZaAgWEjj1MRmx2y3hwgqxkVGRk4r2Ar7pRfPAqPaDt2TDZugWWlxkImNBobNsG5dY1hiWeQaNzwtxy3lAuUHQhRNjAN3KUWb-PhW53RRtpQ8ZJ2nFvaR3ZRjb8Kb1veEQcLoUDJcoe7LsODh-P_5EfMhjlnPEd5QCLcPO7AUVdT5Ft6iB_EHOzjdgjtLnPoc5IMSpPIGukIctIZXVgQmM1xzoXW6N1lTRoh3Nj2YJQp8fEmUq6KvbLQyLpUkRON2CJt-Muygr5RbFi_qkafRsLZRhffy-mzD4YBRWTklsLVhC32inxTMwxgzYHlJW0UTrPSRUpXI6SQ==",
"use": "sig",
"kid": "0904f1a8-ae89-4f0f-9277-1dab58287593",
"alg": "RS256"
}
]
}
-
Verifier Name: wam-test-2
-
JWKS Endpoint: https://a11b-2a02-2f0d-602-fa00-54be-f85b-380b-e0f2.ngrok.io/.well-known/jwks.json
-
Sample idToken(JWT)
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjA5MDRmMWE4LWFlODktNGYwZi05Mjc3LTFkYWI1ODI4NzU5MyJ9.eyJzdWIiOiI2ZTE4NWE4Ni00ZTUyLTQzMWYtYjk2OC0xZmExODM2ODc4MGQiLCJuYW1lIjoiVFlrb21UdENYTyIsImF1ZCI6InVybjphMTFiLTJhMDItMmYwZC02MDItZmEwMC01NGJlLWY4NWItMzgwYi1lMGYyLm5ncm9rLmlvIiwiaXNzIjoiaHR0cHM6Ly9hMTFiLTJhMDItMmYwZC02MDItZmEwMC01NGJlLWY4NWItMzgwYi1lMGYyLm5ncm9rLmlvIiwiaWF0IjoxNjc5ODQ4NTgxLCJleHAiOjE2ODAyNTE1NTF9.DoPmgVnYC7uLBbwWLkigcrIZ12OGbhsntmy2FFcYRgiszBp9msODMTuBakASzwGNIik32emWPf-HToIRBpCRcHvDDXlD04cPObxEPncmCXzuWJFqBqB73KUwfD6lva2gT0j7dxpFFxQgt01-bgUFoOByELCSXKCg3DStg5I3WleutQtIhPaxcjBobiK6lpOUHDUNhWMta88PCf_nY6fkrqcnDNXFoT4EZF4F4DaluY1Nw7gKAB-elu_qqhqFMn_5onVCIfjiu845sJFowqpgBk5HliBvzyg0Vinnj95uSemAfbe8R-QYfU2DlBnmGi6nboO_HN-c6bQERKeSRkEl7g
-
Code:
import { Web3Auth } from "@web3auth/single-factor-auth";
const connect = async () => {
const web3auth = new Web3Auth({
clientId: 'MY_CLIENT_ID',
chainConfig: {
chainNamespace: "eip155",
chainId: "0x1",
rpcTarget: "https://rpc.ankr.com/eth",
},
web3AuthNetwork: "testnet",
});
web3auth.init();
const provider = await web3auth.connect({
verifier: "wam-test-2",
verifierId: "6e185a86-4e52-431f-b968-1fa18368780d",
idToken: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjA5MDRmMWE4LWFlODktNGYwZi05Mjc3LTFkYWI1ODI4NzU5MyJ9.eyJzdWIiOiI2ZTE4NWE4Ni00ZTUyLTQzMWYtYjk2OC0xZmExODM2ODc4MGQiLCJuYW1lIjoiVFlrb21UdENYTyIsImF1ZCI6InVybjphMTFiLTJhMDItMmYwZC02MDItZmEwMC01NGJlLWY4NWItMzgwYi1lMGYyLm5ncm9rLmlvIiwiaXNzIjoiaHR0cHM6Ly9hMTFiLTJhMDItMmYwZC02MDItZmEwMC01NGJlLWY4NWItMzgwYi1lMGYyLm5ncm9rLmlvIiwiaWF0IjoxNjc5NjY5Mzc2LCJleHAiOjE2ODAyNTE1NTF9.N3_gUmeUmFr3Wj5Byk6LRh1e0MT4h26xA0rNemtgm9RM1dW7iQUF7JddhewRUoGdedVPKl8GCa4vJaL4Hcv35REN1JBI8hotyBnVi-V-Ky9XOLJpk1mC2_I3rrUfF6HHmnVhJxF4ZAOoMoAkhPMI364f8vxVAMxp-XGlKWrrgi87QGcmpI9FQWPClp1cuWPMaZSIbHZ1wAY6-DtAV_DGEfN9P88Avic3FnNDqJHhXMWBjwOV-sqBLfOdK5tGRO7ESOp_2Ee6GyYm4Wbs_1U7H6CAycFBP5vVhAfJBVQAkXUZlpJ-gNEq2Qnflsqh43fL66kLfUVsZIGdVc0tNqx_Ew",
});
if(!provider) {
console.log('============= INVALID PROVIDER ============');
return;
}
const privateKey = await provider.request({ method: "eth_private_key" });
// The private key returned here is the CoreKitKey
console.log("ETH Private Key", privateKey);
};
});