it works!
This commit is contained in:
@@ -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(),
|
||||
})
|
||||
|
||||
@@ -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<T> = {
|
||||
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 {
|
||||
|
||||
+1
-1
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user