({
apiBaseUrl,
fetch,
}: ApiClientOptions)
| 140 | }; |
| 141 | |
| 142 | export const createDeviceAuthRequest = async ({ |
| 143 | apiBaseUrl, |
| 144 | fetch, |
| 145 | }: ApiClientOptions): Promise<DeviceAuthRequest> => { |
| 146 | const response = await fetch(`${trimTrailingSlash(apiBaseUrl)}/api/device-auth/codes?app=1`, { |
| 147 | headers: { 'Content-Type': 'application/json' }, |
| 148 | method: 'POST', |
| 149 | }); |
| 150 | |
| 151 | if (!response.ok) { |
| 152 | throw new Error('Failed to start sign in.'); |
| 153 | } |
| 154 | |
| 155 | const data: unknown = await response.json(); |
| 156 | return parseDeviceAuthRequest(data); |
| 157 | }; |
| 158 | |
| 159 | export const pollDeviceAuthCode = async ({ |
| 160 | apiBaseUrl, |
no test coverage detected