@@ -115,7 +115,15 @@ export type HypergraphAppCtx = {
115115 connectUrl : string ;
116116 redirectFn : ( url : URL ) => void ;
117117 } ) : void ;
118- processConnectAuthSuccess ( params : { storage : Identity . Storage ; ciphertext : string ; nonce : string } ) : void ;
118+ processConnectAuthSuccess ( params : { storage : Identity . Storage ; ciphertext : string ; nonce : string } ) :
119+ | {
120+ success : true ;
121+ identity : Connect . PrivateAppIdentity ;
122+ }
123+ | {
124+ success : false ;
125+ error : string ;
126+ } ;
119127 syncServerUri : string ;
120128} ;
121129
@@ -250,9 +258,6 @@ export function HypergraphAppProvider({
250258 const identity = useSelectorStore ( store , ( state ) => state . context . identity ) ;
251259 const privyIdentity = useSelectorStore ( store , ( state ) => state . context . privyIdentity ) ;
252260
253- console . log ( 'identity' , identity ) ;
254- console . log ( 'privyIdentity' , privyIdentity ) ;
255-
256261 const logout = useCallback ( ( ) => {
257262 websocketConnection ?. close ( ) ;
258263 setWebsocketConnection ( undefined ) ;
@@ -1464,15 +1469,26 @@ export function HypergraphAppProvider({
14641469 ) ;
14651470
14661471 const processConnectAuthSuccessForContext = useCallback (
1467- ( params : { storage : Identity . Storage ; ciphertext : string ; nonce : string } ) => {
1472+ ( params : {
1473+ storage : Identity . Storage ;
1474+ ciphertext : string ;
1475+ nonce : string ;
1476+ } ) :
1477+ | {
1478+ success : true ;
1479+ identity : Connect . PrivateAppIdentity ;
1480+ }
1481+ | {
1482+ success : false ;
1483+ error : string ;
1484+ } => {
14681485 const { storage, ciphertext, nonce } = params ;
14691486 const storedNonce = storage . getItem ( 'geo-connect-auth-nonce' ) ;
14701487 const storedExpiry = Number . parseInt ( storage . getItem ( 'geo-connect-auth-expiry' ) ?? '0' , 10 ) ;
14711488 const storedSecretKey = storage . getItem ( 'geo-connect-auth-secret-key' ) ;
14721489 const storedPublicKey = storage . getItem ( 'geo-connect-auth-public-key' ) ;
14731490 if ( ! storedNonce || ! storedExpiry || ! storedSecretKey || ! storedPublicKey ) {
1474- alert ( 'Failed to authenticate due missing data in the local storage' ) ;
1475- return ;
1491+ return { success : false , error : 'Failed to authenticate due missing data in the local storage' } ;
14761492 }
14771493
14781494 try {
@@ -1487,7 +1503,7 @@ export function HypergraphAppProvider({
14871503 } ) ,
14881504 ) ;
14891505
1490- setIdentity ( {
1506+ const identity : Connect . PrivateAppIdentity = {
14911507 address : parsedAuthParams . appIdentityAddress ,
14921508 addressPrivateKey : parsedAuthParams . appIdentityAddressPrivateKey ,
14931509 accountAddress : parsedAuthParams . accountAddress ,
@@ -1498,14 +1514,17 @@ export function HypergraphAppProvider({
14981514 encryptionPrivateKey : parsedAuthParams . encryptionPrivateKey ,
14991515 sessionToken : parsedAuthParams . sessionToken ,
15001516 sessionTokenExpires : parsedAuthParams . sessionTokenExpires ,
1501- } ) ;
1517+ } ;
1518+
1519+ setIdentity ( identity ) ;
15021520 storage . removeItem ( 'geo-connect-auth-nonce' ) ;
15031521 storage . removeItem ( 'geo-connect-auth-expiry' ) ;
15041522 storage . removeItem ( 'geo-connect-auth-secret-key' ) ;
15051523 storage . removeItem ( 'geo-connect-auth-public-key' ) ;
1524+ return { success : true , identity } ;
15061525 } catch ( error ) {
15071526 console . error ( error ) ;
1508- alert ( 'Failed to authenticate due to invalid callback' ) ;
1527+ return { success : false , error : 'Failed to authenticate due to invalid callback' } ;
15091528 }
15101529 } ,
15111530 [ setIdentity ] ,
0 commit comments