[Archive] Register whitelist url using web3auth sdk

:classical_building: 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?

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);“>
// 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();

스크린샷 2022-09-06 오후 4 07 27



Originally posted by: Fullstack-sh

Check the discussion at: https://github.com/orgs/Web3Auth/discussions/555

Hey @Fullstack-sh

Thanks for your question. I'm not sure what you're trying to do here. You have to manually enter the whitelist URL in the web3auth dashboard. This particular option originData doesn't exist on the Openlogin Adapter. You can check out the SDK reference for Openlogin adapter here: https://web3auth.io/docs/sdk/web/openlogin#openloginoptions



Originally posted by: yashovardhan

Creating and whitelisting clientId/secret programmatically won't show your clients in the developer dashboard, as SDK doesn't have any connection with your dashboard account. You will have to maintain those clients and secrets yourself on your backend if you are generating it programmatically.



Originally posted by: himanshuchawla009