diff --git a/packages/npm/@amazeelabs/decap-cms-backend-token-auth/package.json b/packages/npm/@amazeelabs/decap-cms-backend-token-auth/package.json index eb8058637..866a984e7 100644 --- a/packages/npm/@amazeelabs/decap-cms-backend-token-auth/package.json +++ b/packages/npm/@amazeelabs/decap-cms-backend-token-auth/package.json @@ -46,9 +46,11 @@ "devDependencies": { "@amazeelabs/eslint-config": "1.4.43", "@octokit/types": "13.5.0", + "@types/js-cookie": "3.0.6", "@types/node": "18.19.33", "@types/react": "18.3.1", "@types/semaphore": "1.1.4", + "js-cookie": "3.0.5", "typescript": "5.4.5", "vitest": "1.6.0" }, diff --git a/packages/npm/@amazeelabs/decap-cms-backend-token-auth/src/backend.ts b/packages/npm/@amazeelabs/decap-cms-backend-token-auth/src/backend.ts index 6a467ea0a..228dea6a7 100644 --- a/packages/npm/@amazeelabs/decap-cms-backend-token-auth/src/backend.ts +++ b/packages/npm/@amazeelabs/decap-cms-backend-token-auth/src/backend.ts @@ -1,6 +1,7 @@ import { TokenAuthClient } from '@amazeelabs/token-auth-middleware'; import { GitHubBackend } from 'decap-cms-backend-github'; import { Implementation } from 'decap-cms-lib-util'; +import Cookies from 'js-cookie'; import { AuthComponent } from './ui.js'; @@ -55,7 +56,7 @@ export class TokenAuthBackend implements Implementation { // Authenticate against the delegate backend. await this.delegate.authenticate(status); // Let frontend know that user is logged in. - sessionStorage.setItem('decap-cms-logged-in', '1'); + Cookies.set('decap-cms-logged-in', '1'); // Return status information. return { ...status, @@ -81,7 +82,7 @@ export class TokenAuthBackend implements Implementation { async logout() { await this.client.logout(); await this.delegate.logout(); - sessionStorage.removeItem('decap-cms-logged-in'); + Cookies.remove('decap-cms-logged-in'); } /** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 83c94e748..18f2392df 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -755,6 +755,9 @@ importers: '@octokit/types': specifier: 13.5.0 version: 13.5.0 + '@types/js-cookie': + specifier: 3.0.6 + version: 3.0.6 '@types/node': specifier: 18.19.33 version: 18.19.33 @@ -764,6 +767,9 @@ importers: '@types/semaphore': specifier: 1.1.4 version: 1.1.4 + js-cookie: + specifier: 3.0.5 + version: 3.0.5 typescript: specifier: 5.4.5 version: 5.4.5 @@ -12077,6 +12083,10 @@ packages: pretty-format: 29.7.0 dev: true + /@types/js-cookie@3.0.6: + resolution: {integrity: sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==} + dev: true + /@types/js-yaml@4.0.9: resolution: {integrity: sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==} dev: true @@ -26814,6 +26824,11 @@ packages: resolution: {integrity: sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==} dev: false + /js-cookie@3.0.5: + resolution: {integrity: sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==} + engines: {node: '>=14'} + dev: true + /js-sha256@0.9.0: resolution: {integrity: sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==} dev: false