Skip to content

Commit

Permalink
BA-fix: remove getExpoConstant from preAuthenticateJWT
Browse files Browse the repository at this point in the history
  • Loading branch information
anicioalexandre committed Jan 9, 2025
1 parent 4ff7fac commit 367c12e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
6 changes: 6 additions & 0 deletions packages/authentication/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 11 additions & 12 deletions packages/authentication/modules/access/preAuthenticateJWT/index.ts
Original file line number Diff line number Diff line change
@@ -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.')
Expand Down
2 changes: 1 addition & 1 deletion packages/authentication/package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
7 changes: 7 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 367c12e

Please sign in to comment.