diff --git a/apps/android/src/services/login/types.ts b/apps/android/src/services/login/types.ts new file mode 100644 index 0000000..856dc84 --- /dev/null +++ b/apps/android/src/services/login/types.ts @@ -0,0 +1,37 @@ +import type { RemoteServerApi } from '../api' +import type { DeviceIdentity, LoginMethod } from '../../types' + +/** Shared inputs for every login channel invocation. */ +export interface LoginChannelContext { + baseUrl: string + identity: DeviceIdentity + publicApi: RemoteServerApi +} + +/** Result of a completed login; device credentials are persisted separately. */ +export interface LoginOutcome { + account: string + loginMethod: LoginMethod +} + +/** + * Single-step login: the channel obtains an account token and registers the + * device before returning. + */ +export interface ImmediateLoginChannel { + readonly method: LoginMethod + readonly busyAction: string + signIn(context: LoginChannelContext, input: TInput): Promise +} + +/** + * Two-step login: the UI opens an external redirect, then resumes with the + * delivered account token. + */ +export interface RedirectLoginChannel { + readonly method: LoginMethod + readonly prepareBusyAction: string + readonly completeBusyAction: string + prepareRedirect(context: LoginChannelContext): Promise + completeSignIn(context: LoginChannelContext, accountToken: string): Promise +}