| export interface AccountAuthHandoffEffects { |
| destroyEntitlementSubscription: () => void; |
| resetEntitlementState: () => void; |
| destroySubscriptionWatch: () => void; |
| rebindConvexAuthForWatchHandoff: ( |
| isCurrent: () => boolean, |
| attachWatches: () => void, |
| ) => Promise<boolean>; |
| initEntitlementSubscription: ( |
| userId: string, |
| isCurrent: () => boolean, |
| ) => void | Promise<void>; |
| initSubscriptionWatch: ( |
| userId: string, |
| isCurrent: () => boolean, |
| ) => void | Promise<void>; |
| cloudPrefsSignIn: (userId: string) => void | Promise<void>; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export function startAccountAuthHandoff(input: { |
| userId: string; |
| isCurrent: () => boolean; |
| effects: AccountAuthHandoffEffects; |
| }): Promise<boolean> { |
| const { userId, isCurrent, effects } = input; |
|
|
| effects.destroyEntitlementSubscription(); |
| effects.resetEntitlementState(); |
| effects.destroySubscriptionWatch(); |
|
|
| const handoff = effects.rebindConvexAuthForWatchHandoff( |
| isCurrent, |
| () => { |
| void effects.initEntitlementSubscription(userId, isCurrent); |
| void effects.initSubscriptionWatch(userId, isCurrent); |
| }, |
| ); |
| void effects.cloudPrefsSignIn(userId); |
| return handoff; |
| } |
|
|