From 0fa6ec5bf5f17a13fc485fffc1c89f7c5dfdb795 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Tue, 2 Feb 2021 17:06:08 +0100 Subject: [PATCH] fix(browser): use auth mode in query string in browser --- packages/algoliasearch/src/builds/browser.ts | 3 ++- packages/client-common/src/types/AuthModeType.ts | 8 +++++--- packages/transporter/src/types/CallType.ts | 8 +++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/algoliasearch/src/builds/browser.ts b/packages/algoliasearch/src/builds/browser.ts index f8976e59d..2d0186b86 100644 --- a/packages/algoliasearch/src/builds/browser.ts +++ b/packages/algoliasearch/src/builds/browser.ts @@ -17,7 +17,7 @@ import { stopABTest, StopABTestResponse, } from '@algolia/client-analytics'; -import { version, WaitablePromise } from '@algolia/client-common'; +import { AuthMode, version, WaitablePromise } from '@algolia/client-common'; import { createRecommendationClient, getPersonalizationStrategy, @@ -201,6 +201,7 @@ export default function algoliasearch( ], }), userAgent: createUserAgent(version).add({ segment: 'Browser' }), + authMode: AuthMode.WithinQueryParameters, }; return createSearchClient({ diff --git a/packages/client-common/src/types/AuthModeType.ts b/packages/client-common/src/types/AuthModeType.ts index eb3ab43b9..4a8bd05ad 100644 --- a/packages/client-common/src/types/AuthModeType.ts +++ b/packages/client-common/src/types/AuthModeType.ts @@ -1,4 +1,6 @@ -export const AuthMode: Readonly> = { +// @MAJOR: export this as individual constants, so it can be minified + +export const AuthMode = { /** * If auth credentials should be in query parameters. */ @@ -8,6 +10,6 @@ export const AuthMode: Readonly> = { * If auth credentials should be in headers. */ WithinHeaders: 1, -}; +} as const; -export type AuthModeType = 0 | 1; +export type AuthModeType = typeof AuthMode[keyof typeof AuthMode]; diff --git a/packages/transporter/src/types/CallType.ts b/packages/transporter/src/types/CallType.ts index 5d9ebaa64..c9a67411f 100644 --- a/packages/transporter/src/types/CallType.ts +++ b/packages/transporter/src/types/CallType.ts @@ -1,4 +1,6 @@ -export const CallEnum: Readonly> = { +// @MAJOR: export this as individual constants, so it can be minified + +export const CallEnum = { /** * If the host is read only. */ @@ -13,6 +15,6 @@ export const CallEnum: Readonly> = { * If the host is both read and write. */ Any: 3, -}; +} as const; -export type CallType = 1 | 2 | 3; +export type CallType = typeof CallEnum[keyof typeof CallEnum];