native crypto setup
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
import {isWeb} from 'platform/detection'
|
||||
|
||||
export const OAUTH_CLIENT_ID = 'https://bsky.app'
|
||||
export const OAUTH_REDIRECT_URI = 'https://bsky.app/auth/callback'
|
||||
export const OAUTH_CLIENT_ID = 'http://localhost/'
|
||||
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',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react'
|
||||
import * as Browser from 'expo-web-browser'
|
||||
import {BrowserOAuthClientFactory} from '@atproto/oauth-client-react-native'
|
||||
|
||||
import {
|
||||
buildOAuthUrl,
|
||||
@@ -11,16 +12,11 @@ import {
|
||||
OAUTH_RESPONSE_TYPES,
|
||||
OAUTH_SCOPE,
|
||||
} from 'lib/oauth'
|
||||
import {CryptoImplementation} from '#/oauth-client-temp/client/crypto-implementation'
|
||||
import {OAuthClientFactory} from '#/oauth-client-temp/client/oauth-client-factory'
|
||||
|
||||
// TODO remove hack
|
||||
const serviceUrl = 'http://localhost'
|
||||
|
||||
// Service URL here is just a placeholder, this isn't how it will actually work
|
||||
export function useLogin(serviceUrl: string | undefined) {
|
||||
const openAuthSession = React.useCallback(async () => {
|
||||
const oauthFactory = new OAuthClientFactory({
|
||||
const oauthFactory = new BrowserOAuthClientFactory({
|
||||
clientMetadata: {
|
||||
client_id: OAUTH_CLIENT_ID,
|
||||
redirect_uris: [OAUTH_REDIRECT_URI],
|
||||
@@ -30,9 +26,12 @@ export function useLogin(serviceUrl: string | undefined) {
|
||||
dpop_bound_access_tokens: DPOP_BOUND_ACCESS_TOKENS,
|
||||
application_type: OAUTH_APPLICATION_TYPE,
|
||||
},
|
||||
cryptoImplementation: new CryptoImplementation(crypto),
|
||||
})
|
||||
|
||||
await oauthFactory.signIn('afepwasfojefpaowejfpwef')
|
||||
|
||||
return
|
||||
|
||||
if (!serviceUrl) return
|
||||
|
||||
const url = buildOAuthUrl(serviceUrl, '123') // TODO replace '123' with the appropriate state
|
||||
|
||||
Reference in New Issue
Block a user