Archived Content from Web3Auth Community
This topic was originally posted by githubdiscussions on 9/6/2022.
This content has been migrated from our previous community forum to preserve valuable discussions.
I am now trying to add a URL whitelist using web3auth sdk. As a result of executing the code below, nothing is registered in the whitelist.
Could you please let me know if there is anything that needs to be fixed?
const appKeyBuf = Buffer.from(clientSecret.padStart(64, "0"), "hex");
if (base64url.encode(getPublic(appKeyBuf)) !== clientId) throw new Error("appKey mismatch");
const sig = await sign(appKeyBuf, Buffer.from(keccak("keccak256").update(origin).digest("hex"), "hex"));
const finalSig = base64url.encode(sig);
console.log("final sig", finalSig);“>
// sample
const base64url = require(“base64url”);
const keccak = require(“keccak”);
const {getPublic, sign} = require(”@toruslabs/eccrypto");
const {OpenloginAdapter} = require(‘@web3auth/openlogin-adapter’);
const {Web3AuthCore} = require(“@web3auth/core”);
const {CHAIN_NAMESPACES} = require(“@web3auth/base”);
const origin = “https://example.com”;
const appKeyBuf = Buffer.from(clientSecret.padStart(64, “0”), “hex”);
if (base64url.encode(getPublic(appKeyBuf)) !== clientId) throw new Error(“appKey mismatch”);
const sig = await sign(appKeyBuf, Buffer.from(keccak(“keccak256”).update(origin).digest(“hex”), “hex”));
const finalSig = base64url.encode(sig);
console.log(“final sig”, finalSig);
let adapterSettings = {
clientId: clientId,
network: “testnet”,
originData: {
“https://example.com”: finalSig
}
};
const adapter = new OpenloginAdapter({
adapterSettings: adapterSettings
});
console.log(“adapter”, adapter);
const web3auth = new Web3AuthCore({
clientId: clientId,
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: “0x1”,
rpcTarget: “RPC_TARGET”,
},
});
web3auth.configureAdapter(adapter);
await web3auth.init();
Originally posted by: Fullstack-sh
Check the discussion at: https://github.com/orgs/Web3Auth/discussions/555
