diff --git a/modules/expo-bluesky-oauth-client/src/rn-oauth-client-factory.native.ts b/modules/expo-bluesky-oauth-client/src/rn-oauth-client-factory.native.ts index 81713e140c..08efd3ca8f 100644 --- a/modules/expo-bluesky-oauth-client/src/rn-oauth-client-factory.native.ts +++ b/modules/expo-bluesky-oauth-client/src/rn-oauth-client-factory.native.ts @@ -8,7 +8,7 @@ import { Session, } from '@atproto/oauth-client' import {OAuthClientMetadata} from '@atproto/oauth-client-metadata' -import IsomorphicOAuthServerMetadataResolver from '@atproto/oauth-server-metadata-resolver' +import {IsomorphicOAuthServerMetadataResolver} from '@atproto/oauth-server-metadata-resolver' import {CryptoSubtle} from './crypto-subtle' import {DatabaseStore, RNOAuthDatabase} from './rn-oauth-database' @@ -31,7 +31,7 @@ export class RNOAuthClientFactory extends OAuthClientFactory { // "fragment" is safer as it is not sent to the server responseMode = 'fragment', responseType, - crypto = {subtle: CryptoSubtle}, + crypto, fetch = globalThis.fetch, }: RNOAuthClientOptions) { const database = new RNOAuthDatabase() @@ -41,7 +41,7 @@ export class RNOAuthClientFactory extends OAuthClientFactory { responseMode, responseType, fetch, - cryptoImplementation: new CryptoSubtle(crypto), + cryptoImplementation: new CryptoSubtle(), sessionStore: database.getSessionStore(), stateStore: database.getStateStore(), metadataResolver: new IsomorphicOAuthServerMetadataResolver({ @@ -52,6 +52,8 @@ export class RNOAuthClientFactory extends OAuthClientFactory { fetch, didCache: database.getDidCache(), handleCache: database.getHandleCache(), + plcDirectoryUrl: 'http://localhost:2582', // dev-env + atprotoLexiconUrl: 'http://localhost:2584', // dev-env (bsky appview) }), dpopNonceCache: database.getDpopNonceCache(), }) diff --git a/modules/expo-bluesky-oauth-client/src/rn-oauth-database.native.ts b/modules/expo-bluesky-oauth-client/src/rn-oauth-database.native.ts index 96a7ae74d7..0ed6e41d03 100644 --- a/modules/expo-bluesky-oauth-client/src/rn-oauth-database.native.ts +++ b/modules/expo-bluesky-oauth-client/src/rn-oauth-database.native.ts @@ -7,7 +7,7 @@ import {InternalStateData, Session, TokenSet} from '@atproto/oauth-client' import {OAuthServerMetadata} from '@atproto/oauth-server-metadata' import Storage from '@react-native-async-storage/async-storage' -type Item = { +type Item = { value: string expiresAt: null | Date } @@ -18,7 +18,7 @@ type EncodedKey = { } function encodeKey(key: Key): EncodedKey { - if (!(key instanceof WebcryptoKey) || !key.kid) { + if (!key.kid) { throw new Error('Invalid key object') } return { diff --git a/src/lib/oauth.ts b/src/lib/oauth.ts index f917d12a25..d1152a6e6f 100644 --- a/src/lib/oauth.ts +++ b/src/lib/oauth.ts @@ -1,7 +1,7 @@ import {isWeb} from 'platform/detection' export const OAUTH_CLIENT_ID = 'http://localhost/' -export const OAUTH_REDIRECT_URI = 'http://localhost:5173/' +export const OAUTH_REDIRECT_URI = 'http://127.0.0.1:5173/' export const OAUTH_SCOPE = 'openid profile email phone offline_access' export const OAUTH_GRANT_TYPES = [ 'authorization_code', diff --git a/src/screens/Login/hooks/useLogin.ts b/src/screens/Login/hooks/useLogin.ts index 5de8483be0..c596d994f8 100644 --- a/src/screens/Login/hooks/useLogin.ts +++ b/src/screens/Login/hooks/useLogin.ts @@ -26,9 +26,11 @@ export function useLogin(serviceUrl: string | undefined) { dpop_bound_access_tokens: DPOP_BOUND_ACCESS_TOKENS, application_type: OAUTH_APPLICATION_TYPE, }, + fetch: global.fetch, }) - await oauthFactory.signIn('alice.test') + const res = await oauthFactory.signIn('http://localhost:2583/') + console.log(res) return