(location: string)
| 30 | * @returns Parsed callback parameters with success/error information |
| 31 | */ |
| 32 | export const parseOAuthCallbackParams = (location: string): CallbackParams => { |
| 33 | const params = new URLSearchParams(location); |
| 34 | |
| 35 | const code = params.get("code"); |
| 36 | if (code) { |
| 37 | return { successful: true, code }; |
| 38 | } |
| 39 | |
| 40 | const error = params.get("error"); |
| 41 | const error_description = params.get("error_description"); |
| 42 | const error_uri = params.get("error_uri"); |
| 43 | |
| 44 | if (error) { |
| 45 | return { successful: false, error, error_description, error_uri }; |
| 46 | } |
| 47 | |
| 48 | return { |
| 49 | successful: false, |
| 50 | error: "invalid_request", |
| 51 | error_description: "Missing code or error in response", |
| 52 | error_uri: null, |
| 53 | }; |
| 54 | }; |
| 55 | |
| 56 | /** |
| 57 | * Generate a random state for the OAuth 2.0 flow. |
no outgoing calls
no test coverage detected