@functionalcms/svelte-components 5.2.1 → 5.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ import { paraglideHandler } from "./handlers/paraglideHandler";
4
4
  import sessionHandler from "./handlers/sessionHandler";
5
5
  import authorizationHandle from "./auth/authorizationHandle";
6
6
  import { userHandler } from "./handlers/userHandler";
7
+ import { accessTokenHandler } from "./handlers/accessTokenHandler";
7
8
  export const hookSequence = (secret, paraglideMiddleware, getTextDirection, customHooks) => {
8
- return sequence(sessionHandler(secret), userHandler(secret), errorHandler, paraglideHandler(paraglideMiddleware, getTextDirection), authorizationHandle(), ...customHooks);
9
+ return sequence(sessionHandler(secret), userHandler(secret), accessTokenHandler(secret), errorHandler, paraglideHandler(paraglideMiddleware, getTextDirection), authorizationHandle(), ...customHooks);
9
10
  };
@@ -1,7 +1,5 @@
1
1
  import { CommunicationService, DataService, TemplateService, WebsitesService, AuthService, FilesService, } from "@functionalcms/services";
2
- const getAccessToken = (locals) => {
3
- return locals.token.access_token;
4
- };
2
+ const getAccessToken = (locals) => locals.token;
5
3
  export const getDataService = (locals, endpoint) => {
6
4
  const accessToken = getAccessToken(locals);
7
5
  const service = new DataService(accessToken, endpoint);
@@ -0,0 +1,2 @@
1
+ import { type Handle } from '@sveltejs/kit';
2
+ export declare const accessTokenHandler: (secret: string) => Handle;
@@ -0,0 +1,12 @@
1
+ import {} from '@sveltejs/kit';
2
+ import { loadCookie } from '../cookies';
3
+ const accessTokenCookie = "functionalcms_access_token";
4
+ export const accessTokenHandler = (secret) => {
5
+ return async ({ event, resolve }) => {
6
+ let token = await loadCookie(event.cookies, secret, accessTokenCookie);
7
+ if (token) {
8
+ event.locals.token = token;
9
+ }
10
+ return resolve(event);
11
+ };
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "5.2.1",
3
+ "version": "5.2.2",
4
4
  "license": "MIT",
5
5
  "watch": {
6
6
  "build": {