From 10564bf0d92938bd49e613182f3cfca8e71e654e Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Sun, 17 Nov 2024 12:33:20 +0100 Subject: [PATCH] fix: encode query params for react native compat Signed-off-by: Timo Glastra --- packages/oauth2/src/Oauth2Client.ts | 2 +- packages/oauth2/src/access-token/introspect-token.ts | 2 +- packages/oauth2/src/access-token/retrieve-access-token.ts | 2 +- .../authorization-challenge/send-authorization-challenge.ts | 2 +- .../src/authorization-request/create-authorization-request.ts | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/oauth2/src/Oauth2Client.ts b/packages/oauth2/src/Oauth2Client.ts index dd48fc6..9752900 100644 --- a/packages/oauth2/src/Oauth2Client.ts +++ b/packages/oauth2/src/Oauth2Client.ts @@ -98,7 +98,7 @@ export class Oauth2Client { request_uri: error.errorResponse.request_uri, client_id: options.clientId, } - )}` + ).toString()}` return { authorizationRequestUrl, diff --git a/packages/oauth2/src/access-token/introspect-token.ts b/packages/oauth2/src/access-token/introspect-token.ts index 5fe5267..1bef9c7 100644 --- a/packages/oauth2/src/access-token/introspect-token.ts +++ b/packages/oauth2/src/access-token/introspect-token.ts @@ -70,7 +70,7 @@ export async function introspectToken(options: IntrospectTokenOptions) { ContentType.Json, introspectionEndpoint, { - body: objectToQueryParams(introspectionRequest), + body: objectToQueryParams(introspectionRequest).toString(), method: 'POST', headers, } diff --git a/packages/oauth2/src/access-token/retrieve-access-token.ts b/packages/oauth2/src/access-token/retrieve-access-token.ts index de27b4a..1f0ac49 100644 --- a/packages/oauth2/src/access-token/retrieve-access-token.ts +++ b/packages/oauth2/src/access-token/retrieve-access-token.ts @@ -168,7 +168,7 @@ async function retrieveAccessToken(options: RetrieveAccessTokenOptions): Promise ContentType.Json, options.authorizationServerMetadata.token_endpoint, { - body: requestQueryParams, + body: requestQueryParams.toString(), method: 'POST', headers: { 'Content-Type': ContentType.XWwwFormUrlencoded, diff --git a/packages/oauth2/src/authorization-challenge/send-authorization-challenge.ts b/packages/oauth2/src/authorization-challenge/send-authorization-challenge.ts index e3218a1..162b61f 100644 --- a/packages/oauth2/src/authorization-challenge/send-authorization-challenge.ts +++ b/packages/oauth2/src/authorization-challenge/send-authorization-challenge.ts @@ -114,7 +114,7 @@ export async function sendAuthorizationChallengeRequest(options: SendAuthorizati authorizationServerMetadata.authorization_challenge_endpoint, { method: 'POST', - body: objectToQueryParams(authorizationChallengeRequest), + body: objectToQueryParams(authorizationChallengeRequest).toString(), headers: { 'Content-Type': ContentType.XWwwFormUrlencoded, }, diff --git a/packages/oauth2/src/authorization-request/create-authorization-request.ts b/packages/oauth2/src/authorization-request/create-authorization-request.ts index 85dfdb7..b8d7e05 100644 --- a/packages/oauth2/src/authorization-request/create-authorization-request.ts +++ b/packages/oauth2/src/authorization-request/create-authorization-request.ts @@ -118,7 +118,7 @@ export async function createAuthorizationRequestUrl(options: CreateAuthorization } } - const authorizationRequestUrl = `${authorizationServerMetadata.authorization_endpoint}?${objectToQueryParams(pushedAuthorizationRequest ?? authorizationRequest)}` + const authorizationRequestUrl = `${authorizationServerMetadata.authorization_endpoint}?${objectToQueryParams(pushedAuthorizationRequest ?? authorizationRequest).toString()}` return { authorizationRequestUrl, pkce, @@ -150,7 +150,7 @@ async function pushAuthorizationRequest(options: PushAuthorizationRequestOptions options.pushedAuthorizationRequestEndpoint, { method: 'POST', - body: objectToQueryParams(options.authorizationRequest), + body: objectToQueryParams(options.authorizationRequest).toString(), headers: { 'Content-Type': ContentType.XWwwFormUrlencoded, },