Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions tests/sessionTime.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,20 @@ variable.forEach(async (testVariable) => {


await test(`#Variable SessionTime test : ${JSON.stringify({ sessionTime: testVariable.sessionTime })} - disableSessionManager: ${disableSessionManager} client_id: ${web3AuthClientId}`, async (t) => {
const coreKitInstance = new Web3AuthMPCCoreKit({
web3AuthClientId,
web3AuthNetwork,
baseUrl: "http://localhost:3000",
uxMode,
tssLib,
storage: storageInstance,
manualSync,
sessionTime,
disableSessionManager,
});
let coreKitInstance: Web3AuthMPCCoreKit;

async function beforeTest() {
coreKitInstance= new Web3AuthMPCCoreKit({
web3AuthClientId,
web3AuthNetwork,
baseUrl: "http://localhost:3000",
uxMode,
tssLib,
storage: storageInstance,
manualSync,
sessionTime,
disableSessionManager,
});
if (coreKitInstance.status === COREKIT_STATUS.INITIALIZED) await criticalResetAccount(coreKitInstance);
}

Expand Down Expand Up @@ -110,7 +111,8 @@ variable.forEach(async (testVariable) => {
return;
}

coreKitInstance.signatures.forEach((sig) => {
const sigs = await coreKitInstance.getSessionSignatures();
sigs.forEach((sig) => {
const parsedSig = JSON.parse(sig);
const parsedSigData = JSON.parse(atob(parsedSig.data));

Expand Down
15 changes: 3 additions & 12 deletions tests/sfaImport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import test from "node:test";
import { tssLib as tssLibDKLS } from "@toruslabs/tss-dkls-lib";
import { tssLib as tssLibFROST } from "@toruslabs/tss-frost-lib";

import { AsyncStorage, MemoryStorage, TssLibType, TssShareType, WEB3AUTH_NETWORK } from "../src";
import { criticalResetAccount, generateRandomEmail, loginWithSFA, newCoreKitLogInInstance } from "./setup";
import { MemoryStorage, TssLibType, TssShareType, WEB3AUTH_NETWORK } from "../src";
import { generateRandomEmail, loginWithSFA, newCoreKitLogInInstance } from "./setup";

type ImportKeyTestVariable = {
manualSync?: boolean;
Expand All @@ -26,17 +26,9 @@ export const ImportSFATest = async (testVariable: ImportKeyTestVariable) => {
});
}

async function resetAccount(email: string) {
const kit = await newCoreKitInstance(email);
await criticalResetAccount(kit);
await kit.logout();
await new AsyncStorage(kit._storageKey, storageInstance).resetStore();
}

test(`import sfa key and recover tss key : ${testVariable.manualSync}`, async function (t) {
const afterTest = async () => {
await resetAccount(testVariable.email);
};

await t.test("#recover Tss key using 2 factors key, import tss key to new oauth login", async function () {
const sfaResult = await loginWithSFA({
network: WEB3AUTH_NETWORK.DEVNET,
Expand Down Expand Up @@ -85,7 +77,6 @@ export const ImportSFATest = async (testVariable: ImportKeyTestVariable) => {

});

await afterTest();
t.afterEach(function () {
return console.info("finished running recovery test");
});
Expand Down
Loading