From 367c12eb04e890640b85345444bd93ef2926ea13 Mon Sep 17 00:00:00 2001 From: Alexandre Anicio Date: Thu, 9 Jan 2025 17:50:00 -0300 Subject: [PATCH] BA-fix: remove `getExpoConstant` from `preAuthenticateJWT` --- packages/authentication/CHANGELOG.md | 6 +++++ .../access/preAuthenticateJWT/index.ts | 23 +++++++++---------- packages/authentication/package.json | 2 +- packages/components/CHANGELOG.md | 7 ++++++ packages/components/package.json | 2 +- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/authentication/CHANGELOG.md b/packages/authentication/CHANGELOG.md index e543cb9d..bb3e8bb9 100644 --- a/packages/authentication/CHANGELOG.md +++ b/packages/authentication/CHANGELOG.md @@ -1,5 +1,11 @@ # @baseapp-frontend/authentication +## 4.1.1 + +### Patch Changes + +- Remove `getExpoConstant` from `preAuthenticateJWT` since it is being used on the web app middleware. + ## 4.1.0 ### Minor Changes diff --git a/packages/authentication/modules/access/preAuthenticateJWT/index.ts b/packages/authentication/modules/access/preAuthenticateJWT/index.ts index 9771479b..61f9ddc9 100644 --- a/packages/authentication/modules/access/preAuthenticateJWT/index.ts +++ b/packages/authentication/modules/access/preAuthenticateJWT/index.ts @@ -1,24 +1,23 @@ -import { getExpoConstant } from '@baseapp-frontend/utils' import type { JWTResponse } from '@baseapp-frontend/utils/types/jwt' +/** + * This function is intended for web usage only + * because it relies on `NEXT_PUBLIC_API_BASE_URL`. + */ const preAuthenticateJWT = async (token?: string) => { try { if (!token) { throw new Error('No token provided.') } - const EXPO_PUBLIC_API_BASE_URL = getExpoConstant('EXPO_PUBLIC_API_BASE_URL') - const response = await fetch( - `${process.env.NEXT_PUBLIC_API_BASE_URL ?? EXPO_PUBLIC_API_BASE_URL}/auth/pre-auth/jwt`, - { - method: 'POST', - body: JSON.stringify({ token }), - cache: 'no-store', - headers: { - 'Content-Type': 'application/json', - }, + const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/auth/pre-auth/jwt`, { + method: 'POST', + body: JSON.stringify({ token }), + cache: 'no-store', + headers: { + 'Content-Type': 'application/json', }, - ) + }) if (response instanceof Response && !response.ok) { throw new Error('Failed to pre-authenticate.') diff --git a/packages/authentication/package.json b/packages/authentication/package.json index 96a75d3c..ef8cbc1e 100644 --- a/packages/authentication/package.json +++ b/packages/authentication/package.json @@ -1,7 +1,7 @@ { "name": "@baseapp-frontend/authentication", "description": "Authentication modules.", - "version": "4.1.0", + "version": "4.1.1", "main": "./index.ts", "types": "dist/index.d.ts", "sideEffects": false, diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 3d519b64..dc2c23fc 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -1,5 +1,12 @@ # @baseapp-frontend/components +## 0.0.45 + +### Patch Changes + +- Updated dependencies + - @baseapp-frontend/authentication@4.1.1 + ## 0.0.44 ### Patch Changes diff --git a/packages/components/package.json b/packages/components/package.json index 46f47b26..ad21fc38 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,7 +1,7 @@ { "name": "@baseapp-frontend/components", "description": "BaseApp components modules such as comments, notifications, messages, and more.", - "version": "0.0.44", + "version": "0.0.45", "main": "./index.ts", "types": "dist/index.d.ts", "sideEffects": false,