swift impl
This commit is contained in:
@@ -40,7 +40,7 @@ export const OauthClientReactNative = (NativeModule as null) || {
|
||||
_token: Jwt,
|
||||
_jwk: Jwk,
|
||||
): Promise<{
|
||||
payload: Record<string, unknown>
|
||||
payload: string // this is a JSON response to make Swift a bit easier to work with
|
||||
protectedHeader: Record<string, unknown>
|
||||
}> {
|
||||
throw new Error(LINKING_ERROR)
|
||||
|
||||
@@ -2,7 +2,6 @@ import {
|
||||
jwkValidator,
|
||||
Jwt,
|
||||
JwtHeader,
|
||||
jwtHeaderSchema,
|
||||
JwtPayload,
|
||||
jwtPayloadSchema,
|
||||
Key,
|
||||
@@ -45,8 +44,13 @@ export class ReactNativeKey extends Key {
|
||||
>(token: Jwt, options?: VerifyOptions<C>): Promise<VerifyResult<P, C>> {
|
||||
const result = await OauthClientReactNative.verifyJwt(token, this.jwk)
|
||||
|
||||
const payload = jwtPayloadSchema.parse(result.payload)
|
||||
const protectedHeader = jwtHeaderSchema.parse(result.protectedHeader)
|
||||
let payloadParsed = JSON.parse(result.payload)
|
||||
payloadParsed = Object.fromEntries(
|
||||
Object.entries(payloadParsed as object).filter(([_, v]) => v !== null),
|
||||
)
|
||||
|
||||
const payload = jwtPayloadSchema.parse(payloadParsed)
|
||||
const protectedHeader = result.protectedHeader
|
||||
|
||||
if (options?.audience != null) {
|
||||
const audience = Array.isArray(options.audience)
|
||||
@@ -85,6 +89,8 @@ export class ReactNativeKey extends Key {
|
||||
}
|
||||
}
|
||||
|
||||
console.log(payload)
|
||||
|
||||
if (payload.iat == null) {
|
||||
throw new Error('Missing issued at')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user