Archived Content from Web3Auth Community
This topic was originally posted by m.bilinski on 2/26/2025.
This content has been migrated from our previous community forum to preserve valuable discussions.
Hello dear web3auth team,
I’m trying to to achieve to implement the share module into your MPC SDK, but am failing and wanted to reach out to you.
So I want to send the request, approve the request and create a new factor and the device, so it’s the user stays logged in.
I’m not sure If I even need WebStorage for this to work, but this current state of the code. It’s placed in the mpcCoreKit.ts file.
I’m called enableMFA on Device A, and Device B calls requestShare() on COREKIT_STATUS.REQUIRED_SHARE. Device A than approves the share, but device B fails in reconstruction and “registering” Device B.
Do you have any suggestions in how to incoperate those function correctly into your MPC Core Kit? I really would love to have the benefits of you MPC Core Package.
Thank you in advance!!
async requestShare(): Promise<void> { try { const result = await ( this.tKey.modules.shareTransfer as ShareTransferModule ).requestNewShare( navigator.userAgent, this.tKey.getCurrentShareIndexes() ); console.log("Share request result:", result); } catch (err) { log.error(err); } }async approveShareRequest(): Promise<void> {
console.log(“Approving All Share Requests”);
try {
const result = await (
this.tKey.modules.shareTransfer as ShareTransferModule
).getShareTransferStore();const pubkeys = Object.keys(result); await ( this.tKey.modules.shareTransfer as ShareTransferModule ).approveRequest(pubkeys[0]); await this.commitChanges(); console.log("Finished approving all share transfer requests"); } catch (err) { console.error("Failed to process share transfer store:", err); }}
async reconstructKey(): Promise<void> {
try {
console.log(“Starting key reconstruction process…”);const result = await ( this.tkey!.modules.shareTransfer as ShareTransferModule ).getShareTransferStore(); console.log("Share transfer store retrieved:", result); const pubKeys = Object.keys(result); console.log("Extracted public keys:", pubKeys); await ( this.tkey!.modules.shareTransfer as ShareTransferModule ).startRequestStatusCheck(pubKeys[0], true); await this.tKey.reconstructKey(); const generateShareResult = await this.tKey.generateNewShare(); const share = this.tKey.outputShareStore( generateShareResult.newShareIndex ); await (this.tKey.modules.webStorage as WebStorageModule).storeDeviceShare( share ); await ( this.tKey.modules.webStorage as WebStorageModule ).inputShareFromWebStorage(); await this.commitChanges(); } catch (err) { console.error("Failed to reconstruct key:", err); }
}