few fixes
This commit is contained in:
@@ -19,11 +19,7 @@ export class ReactNativeKey extends Key {
|
||||
// Note: OauthClientReactNative.generatePrivateJwk should throw if it
|
||||
// doesn't support the algorithm.
|
||||
const res = await OauthClientReactNative.generateJwk(algo)
|
||||
const jwk = jwkValidator.parse({
|
||||
...res.privateKey,
|
||||
key_ops: ['sign', 'verify'],
|
||||
kid,
|
||||
})
|
||||
const jwk = res.privateKey
|
||||
const use = jwk.use || 'sig'
|
||||
return new ReactNativeKey(jwkValidator.parse({...jwk, use, kid}))
|
||||
} catch {
|
||||
@@ -44,12 +40,15 @@ export class ReactNativeKey extends Key {
|
||||
>(token: Jwt, options?: VerifyOptions<C>): Promise<VerifyResult<P, C>> {
|
||||
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)
|
||||
payloadParsed = Object.fromEntries(
|
||||
Object.entries(payloadParsed as object).filter(([_, v]) => v !== null),
|
||||
)
|
||||
|
||||
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
|
||||
|
||||
if (options?.audience != null) {
|
||||
|
||||
@@ -69,6 +69,8 @@ function HomeScreenReady({
|
||||
)
|
||||
|
||||
const verified = await key.verifyJwt(jwt)
|
||||
|
||||
console.log(verified)
|
||||
})()
|
||||
}, [])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user