more progress working through this
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ class ExpoBlueskyOAuthClientModule : Module() {
|
|||||||
return@AsyncFunction JWTUtil().createJwt(header, payload, jwk)
|
return@AsyncFunction JWTUtil().createJwt(header, payload, jwk)
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncFunction("verifyJwt") { token: String, jwk: JWK ->
|
AsyncFunction("verifyJwt") { token: String, jwk: String ->
|
||||||
return@AsyncFunction JWTUtil().verifyJwt(token, jwk)
|
return@AsyncFunction JWTUtil().verifyJwt(token, jwk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ export type RNOAuthClientOptions = {
|
|||||||
clientMetadata: OAuthClientMetadata
|
clientMetadata: OAuthClientMetadata
|
||||||
fetch?: Fetch
|
fetch?: Fetch
|
||||||
crypto?: any
|
crypto?: any
|
||||||
|
plcDirectoryUrl?: string
|
||||||
|
atprotoLexiconUrl?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RNOAuthClientFactory extends OAuthClientFactory {
|
export class RNOAuthClientFactory extends OAuthClientFactory {
|
||||||
@@ -30,6 +32,8 @@ 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',
|
||||||
fetch = globalThis.fetch,
|
fetch = globalThis.fetch,
|
||||||
|
plcDirectoryUrl,
|
||||||
|
atprotoLexiconUrl,
|
||||||
}: RNOAuthClientOptions) {
|
}: RNOAuthClientOptions) {
|
||||||
const database = new RNOAuthDatabase()
|
const database = new RNOAuthDatabase()
|
||||||
|
|
||||||
@@ -46,6 +50,8 @@ export class RNOAuthClientFactory extends OAuthClientFactory {
|
|||||||
}),
|
}),
|
||||||
identityResolver: UniversalIdentityResolver.from({
|
identityResolver: UniversalIdentityResolver.from({
|
||||||
fetch,
|
fetch,
|
||||||
|
plcDirectoryUrl,
|
||||||
|
atprotoLexiconUrl,
|
||||||
didCache: database.getDidCache(),
|
didCache: database.getDidCache(),
|
||||||
handleCache: database.getHandleCache(),
|
handleCache: database.getHandleCache(),
|
||||||
}),
|
}),
|
||||||
@@ -80,26 +86,26 @@ export class RNOAuthClientFactory extends OAuthClientFactory {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
async signIn(input: string, options?: OAuthAuthorizeOptions) {
|
async signIn(input: string, options?: OAuthAuthorizeOptions) {
|
||||||
|
console.log(options)
|
||||||
return await this.authorize(input, options)
|
return await this.authorize(input, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// async signInCallback() {
|
async signInCallback(callback: string) {
|
||||||
// const redirectUri = new URL(this.clientMetadata.redirect_uris[0])
|
// const redirectUri = new URL(this.clientMetadata.redirect_uris[0])
|
||||||
// if (location.pathname !== redirectUri.pathname) return null
|
// if (location.pathname !== redirectUri.pathname) return null
|
||||||
//
|
//
|
||||||
// const params =
|
const params = new URL(callback).searchParams
|
||||||
// this.responseMode === 'query'
|
// Only if the query string contains oauth callback params
|
||||||
// ? new URLSearchParams(location.search)
|
if (
|
||||||
// : new URLSearchParams(location.hash.slice(1))
|
!params.has('iss') ||
|
||||||
//
|
!params.has('state') ||
|
||||||
// // Only if the query string contains oauth callback params
|
!(params.has('code') || params.has('error'))
|
||||||
// if (
|
) {
|
||||||
// !params.has('iss') ||
|
console.log('no')
|
||||||
// !params.has('state') ||
|
return null
|
||||||
// !(params.has('code') || params.has('error'))
|
} else {
|
||||||
// ) {
|
console.log('has!')
|
||||||
// return null
|
}
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// // Replace the current history entry without the query string (this will
|
// // Replace the current history entry without the query string (this will
|
||||||
// // prevent this 'if' branch to run again if the user refreshes the page)
|
// // prevent this 'if' branch to run again if the user refreshes the page)
|
||||||
@@ -139,5 +145,5 @@ export class RNOAuthClientFactory extends OAuthClientFactory {
|
|||||||
//
|
//
|
||||||
// throw err
|
// throw err
|
||||||
// })
|
// })
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user