@shellui/core 0.3.0-beta.0 → 0.3.0-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shellui/core",
3
- "version": "0.3.0-beta.0",
3
+ "version": "0.3.0-beta.2",
4
4
  "description": "ShellUI Core - Core React application runtime",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -62,7 +62,7 @@
62
62
  "workbox-routing": "^7.4.0",
63
63
  "workbox-strategies": "^7.4.0",
64
64
  "workbox-window": "^7.4.0",
65
- "@shellui/sdk": "0.3.0-beta.0"
65
+ "@shellui/sdk": "0.3.0-beta.2"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "react": "^18.0.0 || ^19.0.0",
@@ -4,7 +4,6 @@
4
4
  */
5
5
 
6
6
  const DEVICE_ID_STORAGE_KEY = 'shellui_auth_client_device_id';
7
- const COMPANY_ID_STORAGE_KEY = 'shellui_auth_company_id';
8
7
 
9
8
  const IANA_TZ_RE = /^[A-Za-z0-9_+/\-]{1,64}$/;
10
9
 
@@ -65,25 +64,9 @@ export function getShellUILoginDeviceId(): string {
65
64
 
66
65
  /**
67
66
  * Preferred company id for tenant-scoped auth calls.
68
- * Uses localStorage value first; if missing, persists and returns the configured fallback.
67
+ * Uses the configured value from shellui auth config (no persistence; config changes apply immediately).
69
68
  */
70
69
  export function getShellUILoginCompanyId(fallbackCompanyId?: string | number): string {
71
70
  const fallback = `${fallbackCompanyId ?? ''}`.trim();
72
- const validFallback = fallback && /^\d+$/.test(fallback) ? fallback : '';
73
- if (typeof window === 'undefined') {
74
- return validFallback;
75
- }
76
- try {
77
- const stored = localStorage.getItem(COMPANY_ID_STORAGE_KEY)?.trim() ?? '';
78
- if (stored && /^\d+$/.test(stored)) {
79
- return stored;
80
- }
81
- if (validFallback) {
82
- localStorage.setItem(COMPANY_ID_STORAGE_KEY, validFallback);
83
- return validFallback;
84
- }
85
- } catch {
86
- return validFallback;
87
- }
88
- return '';
71
+ return fallback && /^\d+$/.test(fallback) ? fallback : '';
89
72
  }
@@ -140,4 +140,28 @@ describe('buildSettingsForPropagation', () => {
140
140
  });
141
141
  expect(unsafeResult.accessToken).toBeNull();
142
142
  });
143
+
144
+ it('injects authBackendBaseUrl when backend type is shellui', () => {
145
+ const config = {
146
+ backend: {
147
+ type: 'shellui' as const,
148
+ url: 'https://id.example.com/',
149
+ },
150
+ } as ShellUIConfig;
151
+
152
+ const result = buildSettingsForPropagation(baseSettings, config, 'en');
153
+ expect(result.authBackendBaseUrl).toBe('https://id.example.com');
154
+ });
155
+
156
+ it('sets authBackendBaseUrl to null when backend is not shellui', () => {
157
+ const config = {
158
+ backend: {
159
+ type: 'supabase' as const,
160
+ url: 'https://xyz.supabase.co',
161
+ },
162
+ } as ShellUIConfig;
163
+
164
+ const result = buildSettingsForPropagation(baseSettings, config, 'en');
165
+ expect(result.authBackendBaseUrl).toBeNull();
166
+ });
143
167
  });
@@ -46,9 +46,15 @@ export const buildSettingsForPropagation = (
46
46
  result = { ...result, navigation: { items } };
47
47
  }
48
48
 
49
+ const authBackendBaseUrl =
50
+ config?.backend?.type === 'shellui' && config.backend.url?.trim()
51
+ ? config.backend.url.trim().replace(/\/+$/, '')
52
+ : null;
53
+
49
54
  result = {
50
55
  ...result,
51
56
  accessToken: options?.includeAuthAccessToken ? (options.accessToken ?? null) : null,
57
+ authBackendBaseUrl,
52
58
  };
53
59
 
54
60
  return result;