| 1 | import { DesktopHostedAuthState } from "@t3tools/contracts"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Schema from "effect/Schema"; |
| 4 | import * as DesktopHostedAuth from "../../app/DesktopHostedAuth.ts"; |
| 5 | import * as IpcChannels from "../channels.ts"; |
| 6 | import * as DesktopIpc from "../DesktopIpc.ts"; |
| 7 | |
| 8 | export const beginHostedAuth = DesktopIpc.makeIpcMethod({ |
| 9 | channel: IpcChannels.BEGIN_HOSTED_AUTH_CHANNEL, |
| 10 | payload: Schema.String, |
| 11 | result: Schema.Void, |
| 12 | handler: Effect.fn("desktop.ipc.hostedAuth.begin")(function* (server) { |
| 13 | return yield* (yield* DesktopHostedAuth.DesktopHostedAuth).begin(server); |
| 14 | }), |
| 15 | }); |
| 16 | export const getHostedAuthState = DesktopIpc.makeIpcMethod({ |
| 17 | channel: IpcChannels.GET_HOSTED_AUTH_STATE_CHANNEL, |
| 18 | payload: Schema.Void, |
| 19 | result: DesktopHostedAuthState, |
| 20 | handler: Effect.fn("desktop.ipc.hostedAuth.state")(function* () { |
| 21 | return yield* (yield* DesktopHostedAuth.DesktopHostedAuth).state; |
| 22 | }), |
| 23 | }); |
| 24 | export const getHostedAccessToken = DesktopIpc.makeIpcMethod({ |
| 25 | channel: IpcChannels.GET_HOSTED_ACCESS_TOKEN_CHANNEL, |
| 26 | payload: Schema.String, |
| 27 | result: Schema.String, |
| 28 | handler: Effect.fn("desktop.ipc.hostedAuth.accessToken")(function* (server) { |
| 29 | return yield* (yield* DesktopHostedAuth.DesktopHostedAuth).accessToken(server); |
| 30 | }), |
| 31 | }); |
| 32 | export const disconnectHostedAuth = DesktopIpc.makeIpcMethod({ |
| 33 | channel: IpcChannels.DISCONNECT_HOSTED_AUTH_CHANNEL, |
| 34 | payload: Schema.Void, |
| 35 | result: Schema.Void, |
| 36 | handler: Effect.fn("desktop.ipc.hostedAuth.disconnect")(function* () { |
| 37 | return yield* (yield* DesktopHostedAuth.DesktopHostedAuth).disconnect; |
| 38 | }), |
| 39 | }); |
| 40 | |
| 41 | export const cancelHostedAuth = DesktopIpc.makeIpcMethod({ |
| 42 | channel: IpcChannels.CANCEL_HOSTED_AUTH_CHANNEL, |
| 43 | payload: Schema.Void, |
| 44 | result: Schema.Void, |
| 45 | handler: Effect.fn("desktop.ipc.hostedAuth.cancel")(function* () { |
| 46 | return yield* (yield* DesktopHostedAuth.DesktopHostedAuth).cancel; |
| 47 | }), |
| 48 | }); |