(state: string)
| 22 | } |
| 23 | |
| 24 | function decodeState(state: string) { |
| 25 | const [encoded] = state.split("."); |
| 26 | if (!encoded) { |
| 27 | throw new Error("Invalid state"); |
| 28 | } |
| 29 | |
| 30 | return JSON.parse(Buffer.from(encoded, "base64url").toString()) as OAuthState; |
| 31 | } |
| 32 | |
| 33 | function getErrorMessage(error: unknown) { |
| 34 | return error instanceof Error ? error.message : String(error); |