it works!
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
|||||||
Session,
|
Session,
|
||||||
} from '@atproto/oauth-client'
|
} from '@atproto/oauth-client'
|
||||||
import {OAuthClientMetadata} from '@atproto/oauth-client-metadata'
|
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 {CryptoSubtle} from './crypto-subtle'
|
||||||
import {DatabaseStore, RNOAuthDatabase} from './rn-oauth-database'
|
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
|
// "fragment" is safer as it is not sent to the server
|
||||||
responseMode = 'fragment',
|
responseMode = 'fragment',
|
||||||
responseType,
|
responseType,
|
||||||
crypto = {subtle: CryptoSubtle},
|
crypto,
|
||||||
fetch = globalThis.fetch,
|
fetch = globalThis.fetch,
|
||||||
}: RNOAuthClientOptions) {
|
}: RNOAuthClientOptions) {
|
||||||
const database = new RNOAuthDatabase()
|
const database = new RNOAuthDatabase()
|
||||||
@@ -41,7 +41,7 @@ export class RNOAuthClientFactory extends OAuthClientFactory {
|
|||||||
responseMode,
|
responseMode,
|
||||||
responseType,
|
responseType,
|
||||||
fetch,
|
fetch,
|
||||||
cryptoImplementation: new CryptoSubtle(crypto),
|
cryptoImplementation: new CryptoSubtle(),
|
||||||
sessionStore: database.getSessionStore(),
|
sessionStore: database.getSessionStore(),
|
||||||
stateStore: database.getStateStore(),
|
stateStore: database.getStateStore(),
|
||||||
metadataResolver: new IsomorphicOAuthServerMetadataResolver({
|
metadataResolver: new IsomorphicOAuthServerMetadataResolver({
|
||||||
@@ -52,6 +52,8 @@ export class RNOAuthClientFactory extends OAuthClientFactory {
|
|||||||
fetch,
|
fetch,
|
||||||
didCache: database.getDidCache(),
|
didCache: database.getDidCache(),
|
||||||
handleCache: database.getHandleCache(),
|
handleCache: database.getHandleCache(),
|
||||||
|
plcDirectoryUrl: 'http://localhost:2582', // dev-env
|
||||||
|
atprotoLexiconUrl: 'http://localhost:2584', // dev-env (bsky appview)
|
||||||
}),
|
}),
|
||||||
dpopNonceCache: database.getDpopNonceCache(),
|
dpopNonceCache: database.getDpopNonceCache(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {InternalStateData, Session, TokenSet} from '@atproto/oauth-client'
|
|||||||
import {OAuthServerMetadata} from '@atproto/oauth-server-metadata'
|
import {OAuthServerMetadata} from '@atproto/oauth-server-metadata'
|
||||||
import Storage from '@react-native-async-storage/async-storage'
|
import Storage from '@react-native-async-storage/async-storage'
|
||||||
|
|
||||||
type Item = {
|
type Item<T> = {
|
||||||
value: string
|
value: string
|
||||||
expiresAt: null | Date
|
expiresAt: null | Date
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ type EncodedKey = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function encodeKey(key: Key): EncodedKey {
|
function encodeKey(key: Key): EncodedKey {
|
||||||
if (!(key instanceof WebcryptoKey) || !key.kid) {
|
if (!key.kid) {
|
||||||
throw new Error('Invalid key object')
|
throw new Error('Invalid key object')
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import {isWeb} from 'platform/detection'
|
import {isWeb} from 'platform/detection'
|
||||||
|
|
||||||
export const OAUTH_CLIENT_ID = 'http://localhost/'
|
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_SCOPE = 'openid profile email phone offline_access'
|
||||||
export const OAUTH_GRANT_TYPES = [
|
export const OAUTH_GRANT_TYPES = [
|
||||||
'authorization_code',
|
'authorization_code',
|
||||||
|
|||||||
@@ -26,9 +26,11 @@ export function useLogin(serviceUrl: string | undefined) {
|
|||||||
dpop_bound_access_tokens: DPOP_BOUND_ACCESS_TOKENS,
|
dpop_bound_access_tokens: DPOP_BOUND_ACCESS_TOKENS,
|
||||||
application_type: OAUTH_APPLICATION_TYPE,
|
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
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user