11import { KeyType , Point as TkeyPoint , ShareDescriptionMap } from "@tkey/common-types" ;
2- import { TKeyTSS } from "@tkey/tss" ;
2+ import { TKeyTSS , TSSTorusServiceProvider } from "@tkey/tss" ;
33import { WEB3AUTH_SIG_TYPE } from "@toruslabs/constants" ;
44import type {
55 AGGREGATE_VERIFIER_TYPE ,
66 ExtraParams ,
77 LoginWindowResponse ,
88 PasskeyExtraParams ,
99 SubVerifierDetails ,
10+ TorusAggregateLoginResponse ,
11+ TorusLoginResponse ,
1012 TorusVerifierResponse ,
1113 UX_MODE_TYPE ,
1214} from "@toruslabs/customauth" ;
15+ import { TorusKey } from "@toruslabs/torus.js" ;
1316import { Client } from "@toruslabs/tss-client" ;
1417// TODO: move the types to a base class for both dkls and frost in future
1518import type { tssLib as TssDklsLib } from "@toruslabs/tss-dkls-lib" ;
@@ -18,6 +21,7 @@ import type { tssLib as TssFrostLibBip340 } from "@toruslabs/tss-frost-lib-bip34
1821import BN from "bn.js" ;
1922
2023import { FactorKeyTypeShareDescription , TssShareType , USER_PATH , WEB3AUTH_NETWORK } from "./constants" ;
24+ import { ISessionSigGenerator } from "./plugins/ISessionSigGenerator" ;
2125
2226export type CoreKitMode = UX_MODE_TYPE | "nodejs" | "react-native" ;
2327
@@ -86,7 +90,18 @@ export type MPCKeyDetails = {
8690 tssPubKey ?: TkeyPoint ;
8791} ;
8892
89- export type OAuthLoginParams = ( SubVerifierDetailsParams | AggregateVerifierLoginParams ) & { importTssKey ?: string } ;
93+ export type OAuthLoginParams = ( SubVerifierDetailsParams | AggregateVerifierLoginParams ) & {
94+ /**
95+ * Key to import key into Tss during first time login.
96+ */
97+ importTssKey ?: string ;
98+
99+ /**
100+ * For new users, use SFA key if user was registered with SFA before.
101+ * Useful when you created the user with SFA before and now want to convert it to TSS.
102+ */
103+ registerExistingSFAKey ?: boolean ;
104+ } ;
90105export type UserInfo = TorusVerifierResponse & LoginWindowResponse ;
91106
92107export interface EnableMFAParams {
@@ -147,6 +162,12 @@ export interface JWTLoginParams {
147162 */
148163 importTssKey ?: string ;
149164
165+ /**
166+ * For new users, use SFA key if user was registered with SFA before.
167+ * Useful when you created the user with SFA before and now want to convert it to TSS.
168+ */
169+ registerExistingSFAKey ?: boolean ;
170+
150171 /**
151172 * Number of TSS public keys to prefetch. For the best performance, set it to
152173 * the number of factors you want to create. Set it to 0 for an existing user.
@@ -166,18 +187,31 @@ export interface Web3AuthState {
166187 factorKey ?: BN ;
167188}
168189
190+ export interface IContext {
191+ status : COREKIT_STATUS ;
192+ state : Web3AuthState ;
193+ sessionId : string ;
194+ serviceProvider : TSSTorusServiceProvider | null ;
195+ updateState : ( newState : Partial < Web3AuthState > ) => void ;
196+ getUserInfo : ( ) => UserInfo ;
197+ logout : ( ) => Promise < void > ;
198+ setupTkey : ( params ?: {
199+ providedImportKey ?: string ;
200+ sfaLoginResponse ?: TorusKey | TorusLoginResponse | TorusAggregateLoginResponse ;
201+ userInfo ?: UserInfo ;
202+ importingSFAKey ?: boolean ;
203+ persistSessionSigs ?: boolean ;
204+ } ) => Promise < void > ;
205+ setCustomSessionSigGenerator : ( sessionSigGenerator : ISessionSigGenerator ) => void ;
206+ }
207+
169208export interface ICoreKit {
170209 /**
171210 * The tKey instance, if initialized.
172211 * TKey is the core module on which this wrapper SDK sits for easy integration.
173212 **/
174213 tKey : TKeyTSS | null ;
175214
176- /**
177- * Signatures generated from the OAuth Login.
178- **/
179- signatures : string [ ] | null ;
180-
181215 /**
182216 * Status of the current MPC Core Kit Instance
183217 **/
@@ -193,6 +227,7 @@ export interface ICoreKit {
193227 */
194228 sessionId : string ;
195229
230+ getContext ( ) : IContext ;
196231 /**
197232 * The function used to initailise the state of MPCCoreKit
198233 * Also is useful to resume an existing session.
@@ -268,6 +303,10 @@ export interface ICoreKit {
268303 */
269304 getKeyDetails ( ) : MPCKeyDetails ;
270305
306+ getSessionSignatures ( ) : Promise < string [ ] > ;
307+
308+ setCustomSessionSigGenerator ( sessionSigGenerator : ISessionSigGenerator ) : void ;
309+
271310 /**
272311 * Commit the changes made to the user's account when in manual sync mode.
273312 */
0 commit comments