feat(release): prepare 1.1.0 candidate
This commit is contained in:
parent
5a34f66981
commit
5205dcdfa9
736 changed files with 115667 additions and 12203 deletions
41
apps/mobile-rn/src/lib/account-exit.ts
Normal file
41
apps/mobile-rn/src/lib/account-exit.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { unregisterCurrentDevice } from '../features/devices/device-service'
|
||||
import { detachPushRegistrationForLogout } from '../features/notifications/notification-service'
|
||||
import { getMobileRuntimeConfig } from './native-config'
|
||||
import { signOutWithLocalFallback, type LocalLogoutResult } from './logout'
|
||||
|
||||
export interface AccountLogoutInput {
|
||||
userId: string | null
|
||||
deviceId: string | null
|
||||
purgeLocalSession: () => Promise<void>
|
||||
}
|
||||
|
||||
export interface AccountLogoutOperations {
|
||||
detachPush: (userId: string, deviceId: string | null) => Promise<void>
|
||||
unregisterDevice: (userId: string, installationId: string) => Promise<unknown>
|
||||
installationId: () => string
|
||||
signOut: (purgeLocalSession: () => Promise<void>) => Promise<LocalLogoutResult>
|
||||
}
|
||||
|
||||
const accountLogoutOperations: AccountLogoutOperations = {
|
||||
detachPush: detachPushRegistrationForLogout,
|
||||
unregisterDevice: unregisterCurrentDevice,
|
||||
installationId: () => getMobileRuntimeConfig().installationId,
|
||||
signOut: signOutWithLocalFallback,
|
||||
}
|
||||
|
||||
/** Keeps authenticated server detach operations ahead of local session loss. */
|
||||
export async function performAccountLogout(
|
||||
input: AccountLogoutInput,
|
||||
operations: AccountLogoutOperations = accountLogoutOperations,
|
||||
): Promise<LocalLogoutResult> {
|
||||
if (input.userId !== null) {
|
||||
await operations.detachPush(input.userId, input.deviceId)
|
||||
try {
|
||||
await operations.unregisterDevice(input.userId, operations.installationId())
|
||||
} catch {
|
||||
// Device unregister is best effort after push detach; local privacy and
|
||||
// refresh-token deletion must still proceed while offline.
|
||||
}
|
||||
}
|
||||
return operations.signOut(input.purgeLocalSession)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue