diff --git a/packages/core/src/sessions/http/use-sessions.hook.ts b/packages/core/src/sessions/http/use-sessions.hook.ts index bff99c7fa0..dbc2060480 100644 --- a/packages/core/src/sessions/http/use-sessions.hook.ts +++ b/packages/core/src/sessions/http/use-sessions.hook.ts @@ -20,10 +20,7 @@ import { import { SESSION_DEFAULT_COOKIE_NAME } from './constants'; import { createSession, readSession, SessionStore } from '../core'; import { FetchUser } from './fetch-user.interface'; -import { removeSessionCookie } from './remove-session-cookie'; -import { setSessionCookie } from './set-session-cookie'; -import { getCsrfTokenFromRequest } from './get-csrf-token-from-request'; -import { shouldVerifyCsrfToken } from './utils'; +import { getCsrfTokenFromRequest, removeSessionCookie, setSessionCookie, shouldVerifyCsrfToken } from './utils'; export interface UseSessionOptions { user?: FetchUser; diff --git a/packages/core/src/sessions/http/get-csrf-token-from-request.spec.ts b/packages/core/src/sessions/http/utils/get-csrf-token-from-request.spec.ts similarity index 97% rename from packages/core/src/sessions/http/get-csrf-token-from-request.spec.ts rename to packages/core/src/sessions/http/utils/get-csrf-token-from-request.spec.ts index 5ef752847d..44f3d472b1 100644 --- a/packages/core/src/sessions/http/get-csrf-token-from-request.spec.ts +++ b/packages/core/src/sessions/http/utils/get-csrf-token-from-request.spec.ts @@ -2,7 +2,7 @@ import { strictEqual } from 'assert'; // FoalTS -import { Context } from '../../core'; +import { Context } from '../../../core'; import { getCsrfTokenFromRequest } from './get-csrf-token-from-request'; function createRequest(body: { [name: string]: any }, headers: { [name: string ]: string}): Context['request'] { diff --git a/packages/core/src/sessions/http/get-csrf-token-from-request.ts b/packages/core/src/sessions/http/utils/get-csrf-token-from-request.ts similarity index 81% rename from packages/core/src/sessions/http/get-csrf-token-from-request.ts rename to packages/core/src/sessions/http/utils/get-csrf-token-from-request.ts index 6d16ee6496..0441846fb1 100644 --- a/packages/core/src/sessions/http/get-csrf-token-from-request.ts +++ b/packages/core/src/sessions/http/utils/get-csrf-token-from-request.ts @@ -1,4 +1,4 @@ -import { Context } from '../../core'; +import { Context } from '../../../core'; export function getCsrfTokenFromRequest(request: Context['request']): string|undefined { return request.body._csrf || request.get('X-CSRF-Token') || request.get('X-XSRF-Token'); diff --git a/packages/core/src/sessions/http/utils/index.ts b/packages/core/src/sessions/http/utils/index.ts index 53bd41440a..5044c0f484 100644 --- a/packages/core/src/sessions/http/utils/index.ts +++ b/packages/core/src/sessions/http/utils/index.ts @@ -1 +1,4 @@ -export { shouldVerifyCsrfToken } from './should-verify-csrf-token'; \ No newline at end of file +export { getCsrfTokenFromRequest } from './get-csrf-token-from-request'; +export { shouldVerifyCsrfToken } from './should-verify-csrf-token'; +export { removeSessionCookie } from './remove-session-cookie'; +export { setSessionCookie } from './set-session-cookie'; \ No newline at end of file diff --git a/packages/core/src/sessions/http/remove-session-cookie.spec.ts b/packages/core/src/sessions/http/utils/remove-session-cookie.spec.ts similarity index 99% rename from packages/core/src/sessions/http/remove-session-cookie.spec.ts rename to packages/core/src/sessions/http/utils/remove-session-cookie.spec.ts index bb823f7852..4389f2e383 100644 --- a/packages/core/src/sessions/http/remove-session-cookie.spec.ts +++ b/packages/core/src/sessions/http/utils/remove-session-cookie.spec.ts @@ -2,7 +2,7 @@ import { strictEqual } from 'assert'; // FoalTS -import { Config, HttpResponse, HttpResponseOK } from '../../core'; +import { Config, HttpResponse, HttpResponseOK } from '../../../core'; import { SESSION_DEFAULT_COOKIE_HTTP_ONLY, SESSION_DEFAULT_COOKIE_NAME, @@ -10,7 +10,7 @@ import { SESSION_DEFAULT_CSRF_COOKIE_NAME, SESSION_DEFAULT_SAME_SITE_ON_CSRF_ENABLED, SESSION_USER_COOKIE_NAME, -} from './constants'; +} from '../constants'; import { removeSessionCookie } from './remove-session-cookie'; describe('removeSessionCookie', () => { diff --git a/packages/core/src/sessions/http/remove-session-cookie.ts b/packages/core/src/sessions/http/utils/remove-session-cookie.ts similarity index 95% rename from packages/core/src/sessions/http/remove-session-cookie.ts rename to packages/core/src/sessions/http/utils/remove-session-cookie.ts index b6f80b6ad9..1c2015619e 100644 --- a/packages/core/src/sessions/http/remove-session-cookie.ts +++ b/packages/core/src/sessions/http/utils/remove-session-cookie.ts @@ -1,5 +1,5 @@ // FoalTS -import { Config, CookieOptions, HttpResponse } from '../../core'; +import { Config, CookieOptions, HttpResponse } from '../../../core'; import { SESSION_DEFAULT_COOKIE_HTTP_ONLY, SESSION_DEFAULT_COOKIE_NAME, @@ -7,7 +7,7 @@ import { SESSION_DEFAULT_CSRF_COOKIE_NAME, SESSION_DEFAULT_SAME_SITE_ON_CSRF_ENABLED, SESSION_USER_COOKIE_NAME, -} from './constants'; +} from '../constants'; /** * Deletes the browser cookie containing the session token. diff --git a/packages/core/src/sessions/http/set-session-cookie.spec.ts b/packages/core/src/sessions/http/utils/set-session-cookie.spec.ts similarity index 99% rename from packages/core/src/sessions/http/set-session-cookie.spec.ts rename to packages/core/src/sessions/http/utils/set-session-cookie.spec.ts index 41d74af1e5..ab10fb16ac 100644 --- a/packages/core/src/sessions/http/set-session-cookie.spec.ts +++ b/packages/core/src/sessions/http/utils/set-session-cookie.spec.ts @@ -2,7 +2,7 @@ import { deepStrictEqual, strictEqual } from 'assert'; // FoalTS -import { Config, HttpResponse, HttpResponseOK } from '../../core'; +import { Config, HttpResponse, HttpResponseOK } from '../../../core'; import { SESSION_DEFAULT_COOKIE_HTTP_ONLY, SESSION_DEFAULT_COOKIE_NAME, @@ -10,8 +10,8 @@ import { SESSION_DEFAULT_CSRF_COOKIE_NAME, SESSION_DEFAULT_SAME_SITE_ON_CSRF_ENABLED, SESSION_USER_COOKIE_NAME, -} from './constants'; -import { Session } from '../core'; +} from '../constants'; +import { Session } from '../../core'; import { setSessionCookie } from './set-session-cookie'; describe('setSessionCookie', () => { diff --git a/packages/core/src/sessions/http/set-session-cookie.ts b/packages/core/src/sessions/http/utils/set-session-cookie.ts similarity index 94% rename from packages/core/src/sessions/http/set-session-cookie.ts rename to packages/core/src/sessions/http/utils/set-session-cookie.ts index e1fcad526e..cad5ebd8da 100644 --- a/packages/core/src/sessions/http/set-session-cookie.ts +++ b/packages/core/src/sessions/http/utils/set-session-cookie.ts @@ -1,5 +1,5 @@ // FoalTS -import { Config, CookieOptions, HttpResponse } from '../../core'; +import { Config, CookieOptions, HttpResponse } from '../../../core'; import { SESSION_DEFAULT_COOKIE_HTTP_ONLY, SESSION_DEFAULT_COOKIE_NAME, @@ -7,8 +7,8 @@ import { SESSION_DEFAULT_CSRF_COOKIE_NAME, SESSION_DEFAULT_SAME_SITE_ON_CSRF_ENABLED, SESSION_USER_COOKIE_NAME, -} from './constants'; -import { Session } from '../core'; +} from '../constants'; +import { Session } from '../../core'; /** * Sends the session token in a cookie. diff --git a/packages/jwt/src/http/jwt.hook.ts b/packages/jwt/src/http/jwt.hook.ts index b459c179f9..8528b221d6 100644 --- a/packages/jwt/src/http/jwt.hook.ts +++ b/packages/jwt/src/http/jwt.hook.ts @@ -20,9 +20,8 @@ import { decode, verify } from 'jsonwebtoken'; // FoalTS import { JWT_DEFAULT_COOKIE_NAME, JWT_DEFAULT_CSRF_COOKIE_NAME } from './constants'; import { getSecretOrPublicKey } from '../core'; -import { getCsrfTokenFromRequest } from './get-csrf-token-from-request'; import { isInvalidTokenError } from './invalid-token.error'; -import { getCsrfTokenFromCookie, shouldVerifyCsrfToken } from './utils'; +import { getCsrfTokenFromCookie, getCsrfTokenFromRequest, shouldVerifyCsrfToken } from './utils'; class InvalidTokenResponse extends HttpResponseUnauthorized { diff --git a/packages/jwt/src/http/get-csrf-token-from-request.spec.ts b/packages/jwt/src/http/utils/get-csrf-token-from-request.spec.ts similarity index 100% rename from packages/jwt/src/http/get-csrf-token-from-request.spec.ts rename to packages/jwt/src/http/utils/get-csrf-token-from-request.spec.ts diff --git a/packages/jwt/src/http/get-csrf-token-from-request.ts b/packages/jwt/src/http/utils/get-csrf-token-from-request.ts similarity index 100% rename from packages/jwt/src/http/get-csrf-token-from-request.ts rename to packages/jwt/src/http/utils/get-csrf-token-from-request.ts diff --git a/packages/jwt/src/http/utils/index.ts b/packages/jwt/src/http/utils/index.ts index b7cc4e0dc3..b157e132f6 100644 --- a/packages/jwt/src/http/utils/index.ts +++ b/packages/jwt/src/http/utils/index.ts @@ -1,2 +1,3 @@ export { getCsrfTokenFromCookie } from './get-csrf-token-from-cookie'; +export { getCsrfTokenFromRequest } from './get-csrf-token-from-request'; export { shouldVerifyCsrfToken } from './should-verify-csrf-token'; \ No newline at end of file