diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js --- a/keyserver/src/responders/user-responders.js +++ b/keyserver/src/responders/user-responders.js @@ -302,10 +302,10 @@ watchedIDs: t.list(t.String), }); -async function siweAuthResponder(viewer: Viewer, input: any): Promise { +async function siweAuthResponder(viewer: Viewer, input: any): Promise { await validateInput(viewer, siweAuthRequestInputValidator, input); - return 'UNIMPLEMENTED'; + return false; } const updatePasswordRequestInputValidator = tShape({ diff --git a/lib/actions/siwe-actions.js b/lib/actions/siwe-actions.js --- a/lib/actions/siwe-actions.js +++ b/lib/actions/siwe-actions.js @@ -1,6 +1,9 @@ // @flow +import threadWatcher from '../shared/thread-watcher.js'; +import type { SIWEAuthServerCall } from '../types/siwe-types.js'; import type { CallServerEndpoint } from '../utils/call-server-endpoint'; +import { getConfig } from '../utils/config.js'; const getSIWENonceActionTypes = Object.freeze({ started: 'GET_SIWE_NONCE_STARTED', @@ -19,10 +22,22 @@ success: 'SIWE_AUTH_SUCCESS', failed: 'SIWE_AUTH_FAILED', }); +const siweAuthCallServerEndpointOptions = { timeout: 60000 }; const siweAuth = ( callServerEndpoint: CallServerEndpoint, -): (() => Promise) => async () => { - const response = await callServerEndpoint('siwe_auth'); +): (( + siweAuthPayload: SIWEAuthServerCall, +) => Promise) => async siweAuthPayload => { + const watchedIDs = threadWatcher.getWatchedIDs(); + const response = await callServerEndpoint( + 'siwe_auth', + { + ...siweAuthPayload, + watchedIDs, + platformDetails: getConfig().platformDetails, + }, + siweAuthCallServerEndpointOptions, + ); return response; }; diff --git a/lib/types/siwe-types.js b/lib/types/siwe-types.js --- a/lib/types/siwe-types.js +++ b/lib/types/siwe-types.js @@ -1,5 +1,6 @@ // @flow +import type { LogInExtraInfo } from './account-types.js'; import { type DeviceTokenUpdateRequest, type PlatformDetails, @@ -19,6 +20,12 @@ +watchedIDs: $ReadOnlyArray, }; +export type SIWEAuthServerCall = { + +message: string, + +signature: string, + ...LogInExtraInfo, +}; + // This is a message that the rendered webpage (landing/siwe.react.js) uses to // communicate back to the React Native WebView that is rendering it // (native/account/siwe-panel.react.js)