corpushub-design-system 0.0.13 → 0.0.15

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.
@@ -1,5 +1,6 @@
1
1
  import { isTransientAuthRefreshError, markApiErrorHandled, } from './apiHandledError';
2
2
  import { clearSession } from '../auth/session';
3
+ import { isPublicAuthRequest } from '../auth/isPublicAuthRequest';
3
4
  import CookieStorage from '../CookieStorage';
4
5
  import { dispatchAccessDeniedError } from './dispatchApiError';
5
6
  import { logged } from '../store/actions';
@@ -58,6 +59,10 @@ export function applyAuthErrorHandling(api, options) {
58
59
  if (status === 401 && isTransientAuthRefreshError(error)) {
59
60
  return Promise.reject(error);
60
61
  }
62
+ // Bad password / missing refresh cookie — let the page show the error.
63
+ if (isPublicAuthRequest(error.config)) {
64
+ return Promise.reject(error);
65
+ }
61
66
  if (authErrorHandling === 'toast') {
62
67
  handleToastAuthError(status, clearSessionOn401);
63
68
  }
@@ -1,5 +1,6 @@
1
1
  import { getAccessToken, refreshAccessTokenOutcome, } from './session';
2
2
  import { markTransientAuthRefresh } from '../api/apiHandledError';
3
+ import { isPublicAuthRequest } from './isPublicAuthRequest';
3
4
  export function installAuthRefreshInterceptor(api) {
4
5
  api.interceptors.response.use((response) => response, async (error) => {
5
6
  const status = error.response?.status;
@@ -7,6 +8,10 @@ export function installAuthRefreshInterceptor(api) {
7
8
  if (status !== 401 || !config || config._retried) {
8
9
  return Promise.reject(error);
9
10
  }
11
+ // Login/refresh/logout 401s are credential failures — do not retry via /refresh.
12
+ if (isPublicAuthRequest(config)) {
13
+ return Promise.reject(error);
14
+ }
10
15
  config._retried = true;
11
16
  const outcome = await refreshAccessTokenOutcome();
12
17
  if (outcome.kind !== 'success') {
@@ -0,0 +1,6 @@
1
+ import type { InternalAxiosRequestConfig } from 'axios';
2
+ /**
3
+ * True when the failed request was itself a public auth call.
4
+ * Used to avoid refresh-retry and session-redirect on login failures.
5
+ */
6
+ export declare function isPublicAuthRequest(config?: InternalAxiosRequestConfig | null): boolean;
@@ -0,0 +1,28 @@
1
+ /** Cookie/password auth endpoints — 401 means bad credentials, not expired access. */
2
+ const PUBLIC_AUTH_PATHS = [
3
+ '/login',
4
+ '/login/google',
5
+ '/refresh',
6
+ '/logout',
7
+ ];
8
+ /**
9
+ * True when the failed request was itself a public auth call.
10
+ * Used to avoid refresh-retry and session-redirect on login failures.
11
+ */
12
+ export function isPublicAuthRequest(config) {
13
+ if (!config) {
14
+ return false;
15
+ }
16
+ const raw = config.url ?? '';
17
+ let path;
18
+ try {
19
+ path = raw.includes('://')
20
+ ? new URL(raw).pathname
21
+ : raw.split('?')[0] ?? '';
22
+ }
23
+ catch {
24
+ path = raw.split('?')[0] ?? '';
25
+ }
26
+ const normalized = path.replace(/\/+$/, '') || '/';
27
+ return PUBLIC_AUTH_PATHS.some((suffix) => normalized === suffix || normalized.endsWith(suffix));
28
+ }
@@ -81,6 +81,14 @@ export async function bootstrapAuthSession() {
81
81
  setAccessToken(fromHash);
82
82
  return fromHash;
83
83
  }
84
+ // Localhost: restore the handoff JWT before calling remote /refresh.
85
+ // Credentialed cross-origin refresh often fails CORS while the access
86
+ // token handoff cookie is still valid across Vite ports.
87
+ const fromCookie = consumeLegacyJwtCookie();
88
+ if (fromCookie) {
89
+ setAccessToken(fromCookie);
90
+ return fromCookie;
91
+ }
84
92
  // Prefer refresh (rotates httpOnly cookie) when a prior session exists.
85
93
  if (mayHaveRefreshSession()) {
86
94
  const refreshed = await refreshAccessToken();
@@ -88,11 +96,5 @@ export async function bootstrapAuthSession() {
88
96
  return refreshed;
89
97
  }
90
98
  }
91
- // Localhost fallback: cross-port handoff cookie (e.g. auth:4000 → app:3000).
92
- const fromCookie = consumeLegacyJwtCookie();
93
- if (fromCookie) {
94
- setAccessToken(fromCookie);
95
- return fromCookie;
96
- }
97
99
  return null;
98
100
  }
@@ -47,6 +47,8 @@ export declare const HistoryTexts: {
47
47
  'document.metadata.save': string;
48
48
  'editor.apply.all': string;
49
49
  'editor.block.add': string;
50
+ 'editor.block.update': string;
51
+ 'editor.block.merge': string;
50
52
  'editor.block.delete': string;
51
53
  'editor.box.create': string;
52
54
  'editor.box.delete': string;
@@ -189,6 +191,8 @@ export declare const HistoryTexts: {
189
191
  'document.metadata.save': string;
190
192
  'editor.apply.all': string;
191
193
  'editor.block.add': string;
194
+ 'editor.block.update': string;
195
+ 'editor.block.merge': string;
192
196
  'editor.block.delete': string;
193
197
  'editor.box.create': string;
194
198
  'editor.box.delete': string;
@@ -331,6 +335,8 @@ export declare const HistoryTexts: {
331
335
  'document.metadata.save': string;
332
336
  'editor.apply.all': string;
333
337
  'editor.block.add': string;
338
+ 'editor.block.update': string;
339
+ 'editor.block.merge': string;
334
340
  'editor.block.delete': string;
335
341
  'editor.box.create': string;
336
342
  'editor.box.delete': string;
@@ -47,6 +47,8 @@ export const HistoryTexts = {
47
47
  'document.metadata.save': 'Document metadata saved',
48
48
  'editor.apply.all': 'All changes applied',
49
49
  'editor.block.add': 'Block added',
50
+ 'editor.block.update': 'Block updated',
51
+ 'editor.block.merge': 'Block merged',
50
52
  'editor.block.delete': 'Block deleted',
51
53
  'editor.box.create': 'Box created',
52
54
  'editor.box.delete': 'Box deleted',
@@ -189,6 +191,8 @@ export const HistoryTexts = {
189
191
  'document.metadata.save': 'Metadado do documento salvo',
190
192
  'editor.apply.all': 'Todas as alterações aplicadas',
191
193
  'editor.block.add': 'Bloco adicionado',
194
+ 'editor.block.update': 'Bloco atualizado',
195
+ 'editor.block.merge': 'Bloco mesclado',
192
196
  'editor.block.delete': 'Bloco excluído',
193
197
  'editor.box.create': 'Caixa criada',
194
198
  'editor.box.delete': 'Caixa excluída',
@@ -331,6 +335,8 @@ export const HistoryTexts = {
331
335
  'document.metadata.save': 'Metadato del documento salvato',
332
336
  'editor.apply.all': 'Tutte le modifiche applicate',
333
337
  'editor.block.add': 'Blocco aggiunto',
338
+ 'editor.block.update': 'Blocco aggiornato',
339
+ 'editor.block.merge': 'Blocco unito',
334
340
  'editor.block.delete': 'Blocco eliminato',
335
341
  'editor.box.create': 'Riquadro creato',
336
342
  'editor.box.delete': 'Riquadro eliminato',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corpushub-design-system",
3
3
  "private": false,
4
- "version": "0.0.13",
4
+ "version": "0.0.15",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {