Skip to content

Commit

Permalink
Merge branch 'supabase:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
bombillazo committed Apr 30, 2024
2 parents 6f2b4d6 + 927ae7a commit 1d5dace
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## [2.64.1](https://github.com/supabase/auth-js/compare/v2.64.0...v2.64.1) (2024-04-25)


### Bug Fixes

* return error if missing session or missing custom auth header ([#891](https://github.com/supabase/auth-js/issues/891)) ([8d16578](https://github.com/supabase/auth-js/commit/8d165787ec46929cba68d18c35161463240f61e3))

## [2.64.0](https://github.com/supabase/auth-js/compare/v2.63.2...v2.64.0) (2024-04-25)


### Features

* remove `cache: no-store` as it breaks cloudflare ([#886](https://github.com/supabase/auth-js/issues/886)) ([10e9d38](https://github.com/supabase/auth-js/commit/10e9d3871c5a9ce50d15c35c7fd7045cad504670))


### Bug Fixes

* Revert "fix: `getUser` returns null if there is no session ([#876](https://github.com/supabase/auth-js/issues/876))" ([#889](https://github.com/supabase/auth-js/issues/889)) ([6755fef](https://github.com/supabase/auth-js/commit/6755fef2aefd1bc84a26182f848c0912492cb106))
* revert check for access token in header ([#885](https://github.com/supabase/auth-js/issues/885)) ([03d8ba7](https://github.com/supabase/auth-js/commit/03d8ba7ca5c485979788d6f121199e4370622491))

## [2.63.2](https://github.com/supabase/auth-js/compare/v2.63.1...v2.63.2) (2024-04-20)


### Bug Fixes

* check for access token in header ([#882](https://github.com/supabase/auth-js/issues/882)) ([ae4a53d](https://github.com/supabase/auth-js/commit/ae4a53de7eb41ebde3b4e1abe823e2ffcb53a71d))

## [2.63.1](https://github.com/supabase/auth-js/compare/v2.63.0...v2.63.1) (2024-04-18)


Expand Down
7 changes: 5 additions & 2 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const DEFAULT_OPTIONS: Omit<Required<GoTrueClientOptions>, 'fetch' | 'storage' |
headers: DEFAULT_HEADERS,
flowType: 'implicit',
debug: false,
hasCustomAuthorizationHeader: false,
}

/** Current session will be checked for refresh at this interval. */
Expand Down Expand Up @@ -154,6 +155,7 @@ export default class GoTrueClient {
protected headers: {
[key: string]: string
}
protected hasCustomAuthorizationHeader = false
protected fetch: Fetch
protected lock: LockFunc
protected lockAcquired = false
Expand Down Expand Up @@ -202,6 +204,7 @@ export default class GoTrueClient {
this.lock = settings.lock || lockNoOp
this.detectSessionInUrl = settings.detectSessionInUrl
this.flowType = settings.flowType
this.hasCustomAuthorizationHeader = settings.hasCustomAuthorizationHeader

if (settings.lock) {
this.lock = settings.lock
Expand Down Expand Up @@ -1240,8 +1243,8 @@ export default class GoTrueClient {
throw error
}

if (!data.session?.access_token) {
// if there's no access token, the user can't be fetched
// returns an error if there is no access_token or custom authorization header
if (!data.session?.access_token && !this.hasCustomAuthorizationHeader) {
return { data: { user: null }, error: new AuthSessionMissingError() }
}

Expand Down
3 changes: 0 additions & 3 deletions src/lib/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ async function _handleRequest(
try {
result = await fetcher(url, {
...requestParams,
// UNDER NO CIRCUMSTANCE SHOULD THIS OPTION BE REMOVED, YOU MAY BE OPENING UP A SECURITY HOLE IN NEXT.JS APPS
// https://nextjs.org/docs/app/building-your-application/caching#opting-out-1
cache: 'no-store',
})
} catch (e) {
console.error(e)
Expand Down
5 changes: 5 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export type GoTrueClientOptions = {
* @experimental
*/
lock?: LockFunc
/**
* Set to "true" if there is a custom authorization header set globally.
* @experimental
*/
hasCustomAuthorizationHeader?: boolean
}

export type WeakPasswordReasons = 'length' | 'characters' | 'pwned' | string
Expand Down

0 comments on commit 1d5dace

Please sign in to comment.