|
1 | 1 | import { configureOAuth, createAuthorizationUrl, finalizeAuthorization, getSession, OAuthUserAgent, resolveFromIdentity } from '@atcute/oauth-browser-client';
|
2 | 2 | import type { FetchHandlerObject } from '@atcute/client';
|
3 | 3 | import type { At } from '@atcute/client/lexicons';
|
4 |
| -import { useEventListener } from '@vueuse/core'; |
5 | 4 |
|
6 | 5 | configureOAuth({
|
7 | 6 | metadata: {
|
@@ -29,20 +28,12 @@ export class AtpOauthClient {
|
29 | 28 | // recommended to wait for the browser to persist local storage before proceeding
|
30 | 29 | await new Promise(resolve => setTimeout(resolve, 200));
|
31 | 30 |
|
32 |
| - const hashPromise = Promise.race([ |
33 |
| - new Promise(resolve => useEventListener(window, 'message', event => { |
34 |
| - const hash = event.data as string; |
35 |
| - resolve(hash); |
36 |
| - })), |
37 |
| - new Promise(resolve => setTimeout(resolve, 180000)) // 3 minutes |
38 |
| - ]); |
39 |
| - |
40 | 31 | // redirect the user to sign in and authorize the app
|
41 |
| - window.open(authUrl, '_blank'); |
| 32 | + window.open(authUrl, '_blank', 'noopener,noreferrer'); |
42 | 33 |
|
43 | 34 | // TODO setup a redirect instead
|
44 |
| - const hash = (await hashPromise) as string | undefined; |
45 |
| - if (!hash) throw new Error('Authentication timed out'); |
| 35 | + const hash = prompt('Input the code that was displayed on the page'); |
| 36 | + if (!hash) throw new Error('User cancelled authentication'); |
46 | 37 |
|
47 | 38 | // `createAuthorizationUrl` asks for the server to redirect here with the
|
48 | 39 | // parameters assigned in the hash, not the search string.
|
|
0 commit comments