@@ -182,9 +182,16 @@ export class Web3Auth extends SafeEventEmitter<Web3AuthSfaEvents> implements IWe
182182
183183 const { chainNamespace, chainId } = this . coreOptions . chainConfig || { } ;
184184 if ( ! this . authInstance || ! this . privKeyProvider ) throw WalletInitializationError . notReady ( ) ;
185- const accounts = await this . privKeyProvider . provider . request < unknown , string [ ] > ( {
186- method : chainNamespace === CHAIN_NAMESPACES . EIP155 ? "eth_accounts" : "getAccounts" ,
187- } ) ;
185+ const [ accounts , publicKey ] = await Promise . all ( [
186+ this . privKeyProvider . provider . request < unknown , string [ ] > ( {
187+ method : chainNamespace === CHAIN_NAMESPACES . EIP155 ? "eth_accounts" : "getAccounts" ,
188+ } ) ,
189+ this . privKeyProvider . provider . request < unknown , string [ ] > ( {
190+ method : "public_key" ,
191+ } ) ,
192+ ] ) ;
193+ // const thresholdPrivKey = this._getBasePrivKey();
194+
188195 if ( accounts && accounts . length > 0 ) {
189196 const existingToken = getSavedToken ( accounts [ 0 ] as string , "SFA" ) ;
190197 if ( existingToken ) {
@@ -202,8 +209,33 @@ export class Web3Auth extends SafeEventEmitter<Web3AuthSfaEvents> implements IWe
202209 version : "1" ,
203210 nonce : Math . random ( ) . toString ( 36 ) . slice ( 2 ) ,
204211 issuedAt : new Date ( ) . toISOString ( ) ,
212+ email : userInfo . email ,
213+ name : userInfo . name ,
214+ profileImage : userInfo . profileImage ,
215+ aggregateVerifier : userInfo . aggregateVerifier ,
216+ verifier : userInfo . verifier ,
217+ verifierId : userInfo . verifierId ,
218+ typeOfLogin : userInfo . typeOfLogin || "jwt" ,
219+ oAuthIdToken : userInfo . oAuthIdToken ,
220+ oAuthAccessToken : userInfo . oAuthAccessToken ,
221+ wallets : [ ] as unknown [ ] ,
222+ signatures : [ ] as unknown [ ] ,
205223 } ;
206224
225+ if ( this . coreOptions . usePnPKey ) {
226+ payload . wallets . push ( {
227+ public_key : publicKey ,
228+ type : "web3auth_app_key" ,
229+ curve : chainNamespace === CHAIN_NAMESPACES . EIP155 ? KEY_TYPE . SECP256K1 : KEY_TYPE . ED25519 ,
230+ } ) ;
231+ } else {
232+ payload . wallets . push ( {
233+ public_key : publicKey ,
234+ type : "web3auth_threshold_key" ,
235+ curve : chainNamespace === CHAIN_NAMESPACES . EIP155 ? KEY_TYPE . SECP256K1 : KEY_TYPE . ED25519 ,
236+ } ) ;
237+ }
238+
207239 const challenge = await signChallenge ( payload , chainNamespace ) ;
208240 const signedMessage = await this . _getSignedMessage ( challenge , accounts , chainNamespace ) ;
209241 const idToken = await verifySignedChallenge (
@@ -415,18 +447,26 @@ export class Web3Auth extends SafeEventEmitter<Web3AuthSfaEvents> implements IWe
415447 let finalPrivKey = privKey . padStart ( 64 , "0" ) ;
416448 // get app scoped keys.
417449 if ( this . coreOptions . usePnPKey ) {
418- const pnpPrivKey = subkey ( finalPrivKey , Buffer . from ( this . coreOptions . clientId , "base64" ) ) ;
419- finalPrivKey = pnpPrivKey . padStart ( 64 , "0" ) ;
450+ finalPrivKey = this . getSubKey ( finalPrivKey ) ;
420451 }
421452 if ( this . coreOptions . chainConfig . chainNamespace === CHAIN_NAMESPACES . SOLANA ) {
422- if ( ! this . privKeyProvider . getEd25519Key ) {
423- throw WalletLoginError . fromCode ( 5000 , "Private key provider is not valid, Missing getEd25519Key function" ) ;
424- }
425- finalPrivKey = this . privKeyProvider . getEd25519Key ( finalPrivKey ) ;
453+ finalPrivKey = this . getEd25519Key ( finalPrivKey ) ;
426454 }
427455 return finalPrivKey ;
428456 }
429457
458+ private getSubKey ( privKey : string ) {
459+ const pnpPrivKey = subkey ( privKey , Buffer . from ( this . coreOptions . clientId , "base64" ) ) ;
460+ return pnpPrivKey . padStart ( 64 , "0" ) ;
461+ }
462+
463+ private getEd25519Key ( privKey : string ) {
464+ if ( ! this . privKeyProvider . getEd25519Key ) {
465+ throw WalletLoginError . fromCode ( 5000 , "Private key provider is not valid, Missing getEd25519Key function" ) ;
466+ }
467+ return this . privKeyProvider . getEd25519Key ( privKey ) ;
468+ }
469+
430470 private async getTorusKey ( loginParams : LoginParams ) : Promise < string > {
431471 const { verifier, verifierId, idToken, subVerifierInfoArray } = loginParams ;
432472
0 commit comments