(error: unknown)
| 58 | }; |
| 59 | |
| 60 | const toPopupErrorMessage = (error: unknown): PopupErrorMessage => { |
| 61 | const completeError = decodeOAuthCompleteError(error); |
| 62 | if (Option.isSome(completeError)) |
| 63 | return { |
| 64 | short: "Could not complete authentication", |
| 65 | details: completeError.value.message, |
| 66 | }; |
| 67 | |
| 68 | const startError = decodeOAuthStartError(error); |
| 69 | if (Option.isSome(startError)) |
| 70 | return { |
| 71 | short: "Could not start authentication", |
| 72 | details: startError.value.message, |
| 73 | }; |
| 74 | |
| 75 | const probeError = decodeOAuthProbeError(error); |
| 76 | if (Option.isSome(probeError)) |
| 77 | return { |
| 78 | short: "Could not discover authentication endpoint", |
| 79 | details: probeError.value.message, |
| 80 | }; |
| 81 | |
| 82 | const sessionNotFound = decodeOAuthSessionNotFoundError(error); |
| 83 | if (Option.isSome(sessionNotFound)) |
| 84 | return { |
| 85 | short: "OAuth session expired or not found", |
| 86 | details: `State: ${sessionNotFound.value.state}`, |
| 87 | }; |
| 88 | |
| 89 | return { short: "Authentication failed" }; |
| 90 | }; |
| 91 | |
| 92 | export const OAuthHandlers = HttpApiBuilder.group(ExecutorApi, "oauth", (handlers) => |
| 93 | handlers |
nothing calls this directly
no outgoing calls
no test coverage detected