diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js --- a/lib/types/identity-service-types.js +++ b/lib/types/identity-service-types.js @@ -195,6 +195,9 @@ +linkFarcasterAccount: (farcasterID: string) => Promise; +unlinkFarcasterAccount: () => Promise; +findUserIdentities: (userIDs: $ReadOnlyArray) => Promise; + // We are introducing this on web temporarily to make sure the identity + // service is reachable in production + +ping?: () => Promise; } export type IdentityServiceAuthLayer = { diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -51,6 +51,7 @@ import { MemberListSidebarProvider } from './chat/member-list-sidebar/member-list-sidebar-provider.react.js'; import CommunitiesRefresher from './components/communities-refresher.react.js'; import { DBOpsHandler } from './components/db-ops-handler.react.js'; +import IdentityPing from './components/identity-ping.react.js'; import LogOutIfMissingCSATHandler from './components/log-out-if-missing-csat-handler.react.js'; import NavigationArrows from './components/navigation-arrows.react.js'; import MinVersionHandler from './components/version-handler.react.js'; @@ -238,6 +239,7 @@ + diff --git a/web/components/identity-ping.react.js b/web/components/identity-ping.react.js new file mode 100644 --- /dev/null +++ b/web/components/identity-ping.react.js @@ -0,0 +1,40 @@ +// @flow + +import * as React from 'react'; + +import { IdentityClientContext } from 'lib/shared/identity-client-context.js'; +import { useIsCurrentUserStaff } from 'lib/shared/staff-utils.js'; + +function IdentityPing(): React.Node { + const identityContext = React.useContext(IdentityClientContext); + const isCurrentUserStaff = useIsCurrentUserStaff(); + + const ping = React.useCallback(async () => { + try { + if (!identityContext) { + console.log('Identity context not available'); + return; + } + const identityClient = identityContext.identityClient; + const pingCall = identityClient.ping; + if (!pingCall) { + console.log('Ping method unimplemented'); + return; + } + await pingCall(); + if (isCurrentUserStaff) { + console.log('Identity ping successful'); + } + } catch (error) { + console.log('Error pinging identity service:', error); + } + }, [identityContext, isCurrentUserStaff]); + + React.useEffect(() => { + void ping(); + }, [ping]); + + return null; +} + +export default IdentityPing; diff --git a/web/grpc/identity-service-client-wrapper.js b/web/grpc/identity-service-client-wrapper.js --- a/web/grpc/identity-service-client-wrapper.js +++ b/web/grpc/identity-service-client-wrapper.js @@ -667,6 +667,11 @@ return assertWithValidator(identities, identitiesValidator); }; + + ping: () => Promise = async () => { + const client = this.unauthClient; + await client.ping(new Empty()); + }; } function authNewDeviceKeyUpload( diff --git a/web/grpc/identity-service-context-provider.react.js b/web/grpc/identity-service-context-provider.react.js --- a/web/grpc/identity-service-context-provider.react.js +++ b/web/grpc/identity-service-context-provider.react.js @@ -139,6 +139,7 @@ linkFarcasterAccount: proxyMethodToWorker('linkFarcasterAccount'), unlinkFarcasterAccount: proxyMethodToWorker('unlinkFarcasterAccount'), findUserIdentities: proxyMethodToWorker('findUserIdentities'), + ping: proxyMethodToWorker('ping'), }; }, [proxyMethodToWorker]);