few fixes
This commit is contained in:
@@ -19,11 +19,7 @@ export class ReactNativeKey extends Key {
|
|||||||
// Note: OauthClientReactNative.generatePrivateJwk should throw if it
|
// Note: OauthClientReactNative.generatePrivateJwk should throw if it
|
||||||
// doesn't support the algorithm.
|
// doesn't support the algorithm.
|
||||||
const res = await OauthClientReactNative.generateJwk(algo)
|
const res = await OauthClientReactNative.generateJwk(algo)
|
||||||
const jwk = jwkValidator.parse({
|
const jwk = res.privateKey
|
||||||
...res.privateKey,
|
|
||||||
key_ops: ['sign', 'verify'],
|
|
||||||
kid,
|
|
||||||
})
|
|
||||||
const use = jwk.use || 'sig'
|
const use = jwk.use || 'sig'
|
||||||
return new ReactNativeKey(jwkValidator.parse({...jwk, use, kid}))
|
return new ReactNativeKey(jwkValidator.parse({...jwk, use, kid}))
|
||||||
} catch {
|
} catch {
|
||||||
@@ -44,12 +40,15 @@ export class ReactNativeKey extends Key {
|
|||||||
>(token: Jwt, options?: VerifyOptions<C>): Promise<VerifyResult<P, C>> {
|
>(token: Jwt, options?: VerifyOptions<C>): Promise<VerifyResult<P, C>> {
|
||||||
const result = await OauthClientReactNative.verifyJwt(token, this.jwk)
|
const result = await OauthClientReactNative.verifyJwt(token, this.jwk)
|
||||||
|
|
||||||
|
// TODO see if we can make these `undefined` or maybe update zod to allow `nullable()`
|
||||||
let payloadParsed = JSON.parse(result.payload)
|
let payloadParsed = JSON.parse(result.payload)
|
||||||
payloadParsed = Object.fromEntries(
|
payloadParsed = Object.fromEntries(
|
||||||
Object.entries(payloadParsed as object).filter(([_, v]) => v !== null),
|
Object.entries(payloadParsed as object).filter(([_, v]) => v !== null),
|
||||||
)
|
)
|
||||||
|
|
||||||
const payload = jwtPayloadSchema.parse(payloadParsed)
|
const payload = jwtPayloadSchema.parse(payloadParsed)
|
||||||
|
|
||||||
|
// We don't need to validate this, because the native types ensure it is correct. But this is a TODO
|
||||||
|
// for the same reason above
|
||||||
const protectedHeader = result.protectedHeader
|
const protectedHeader = result.protectedHeader
|
||||||
|
|
||||||
if (options?.audience != null) {
|
if (options?.audience != null) {
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ function HomeScreenReady({
|
|||||||
)
|
)
|
||||||
|
|
||||||
const verified = await key.verifyJwt(jwt)
|
const verified = await key.verifyJwt(jwt)
|
||||||
|
|
||||||
|
console.log(verified)
|
||||||
})()
|
})()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user