| 142 | } |
| 143 | |
| 144 | async status() { |
| 145 | const api = await fetch(GITHUB_STATUS_ENDPOINT) |
| 146 | .then(res => res.json()) |
| 147 | .then(res => { |
| 148 | return res['components'] |
| 149 | .filter((statusComponent: GitHubStatusComponent) => |
| 150 | GITHUB_OPERATIONAL_UNITS.includes(statusComponent.name), |
| 151 | ) |
| 152 | .every( |
| 153 | (statusComponent: GitHubStatusComponent) => statusComponent.status === 'operational', |
| 154 | ); |
| 155 | }) |
| 156 | .catch(e => { |
| 157 | console.warn('Failed getting GitHub status', e); |
| 158 | return true; |
| 159 | }); |
| 160 | |
| 161 | let auth = false; |
| 162 | // no need to check auth if api is down |
| 163 | if (api) { |
| 164 | auth = |
| 165 | (await this.api |
| 166 | ?.getUser({ token: this.token ?? '' }) |
| 167 | .then(user => !!user) |
| 168 | .catch(e => { |
| 169 | console.warn('Failed getting GitHub user', e); |
| 170 | return false; |
| 171 | })) || false; |
| 172 | } |
| 173 | |
| 174 | return { auth: { status: auth }, api: { status: api, statusPage: STATUS_PAGE } }; |
| 175 | } |
| 176 | |
| 177 | authComponent() { |
| 178 | const wrappedAuthenticationPage = (props: Record<string, unknown>) => ( |