@burdenoff/fe-libs 2026.1029.5 → 2026.1029.6

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.
@@ -11,7 +11,7 @@ var e = {
11
11
  zh: "你需要此工作区的编辑者权限才能附加文件。"
12
12
  };
13
13
  function n(n, r) {
14
- let i = t[r.toLowerCase().split("-")[0] ?? "en"] ?? e.fallback;
14
+ let i = t[r.toLowerCase().split("-")[0]] ?? e.fallback;
15
15
  return n(e.key, i);
16
16
  }
17
17
  //#endregion
@@ -1,58 +1,59 @@
1
- import { useSafePermissions as e } from "../providers/shell/PermissionProvider.js";
2
- import { useAssistantStorageFolders as t } from "./product.js";
3
- import { FilesPortError as n, createApolloFilesPort as r } from "../../storage/filesPort.js";
4
- import { createAttachmentCommitter as i } from "./attachmentCommit.js";
5
- import { getActorId as a, getWorkspaceId as o } from "./context.js";
6
- import { probeAttachmentAccess as s } from "./attachmentAccess.js";
7
- import { createContext as c, useCallback as l, useContext as u, useEffect as d, useMemo as f, useRef as p } from "react";
8
- import { getApolloContext as m } from "@apollo/client/react";
1
+ import { useSafeAuth as e } from "../providers/shell/AuthProvider.js";
2
+ import { isSuperAdminBypass as t, useSafePermissions as n } from "../providers/shell/PermissionProvider.js";
3
+ import { useAssistantStorageFolders as r } from "./product.js";
4
+ import { FilesPortError as i, createApolloFilesPort as a } from "../../storage/filesPort.js";
5
+ import { createAttachmentCommitter as o } from "./attachmentCommit.js";
6
+ import { getActorId as s, getWorkspaceId as c } from "./context.js";
7
+ import { probeAttachmentAccess as l } from "./attachmentAccess.js";
8
+ import { createContext as u, useCallback as d, useContext as f, useEffect as p, useMemo as m, useRef as h } from "react";
9
+ import { getApolloContext as g } from "@apollo/client/react";
9
10
  //#region src/shared/assistant/useAttachmentCommitter.ts
10
- var h = c(null);
11
- function g() {
12
- let e = u(h), { client: t } = u(m());
13
- return f(() => e ?? (t ? r(t, { getWorkspaceId: o }) : null), [e, t]);
11
+ var _ = u(null);
12
+ function v() {
13
+ let e = f(_), { client: t } = f(g());
14
+ return m(() => e ?? (t ? a(t, { getWorkspaceId: c }) : null), [e, t]);
14
15
  }
15
- function _() {
16
- let e = g();
17
- return l(async (t) => e ? e.getDownloadUrl(t) : null, [e]);
16
+ function y() {
17
+ let e = v();
18
+ return d(async (t) => e ? e.getDownloadUrl(t) : null, [e]);
18
19
  }
19
- var v = (e) => () => Promise.reject(new n(e, "File storage is not available here.", void 0)), y = {
20
- ensureFolder: v("ensureFolder"),
21
- initiate: v("initiate"),
22
- put: v("put"),
23
- complete: v("complete"),
24
- getSession: v("getSession"),
25
- listSessions: v("listSessions"),
26
- abort: v("abort"),
27
- getDownloadUrl: v("getDownloadUrl"),
28
- deleteFile: v("deleteFile")
20
+ var b = (e) => () => Promise.reject(new i(e, "File storage is not available here.", void 0)), x = {
21
+ ensureFolder: b("ensureFolder"),
22
+ initiate: b("initiate"),
23
+ put: b("put"),
24
+ complete: b("complete"),
25
+ getSession: b("getSession"),
26
+ listSessions: b("listSessions"),
27
+ abort: b("abort"),
28
+ getDownloadUrl: b("getDownloadUrl"),
29
+ deleteFile: b("deleteFile")
29
30
  };
30
- function b() {
31
+ function S() {
31
32
  return {
32
- workspaceId: typeof window < "u" && window.location ? o() : "",
33
- actorId: a()
33
+ workspaceId: typeof window < "u" && window.location ? c() : "",
34
+ actorId: s()
34
35
  };
35
36
  }
36
- function x(n) {
37
- let r = g(), a = e()?.isSuperAdmin ?? !1, o = p(a);
38
- d(() => {
39
- o.current = a;
40
- }, [a]);
41
- let c = t(), l = p(n);
42
- l.current = n;
43
- let u = p(c.attachments);
44
- return u.current = c.attachments, f(() => i({
45
- port: r ?? y,
37
+ function C(i) {
38
+ let a = v(), s = n(), c = e(), u = typeof c?.user?.actorType == "string" ? c.user.actorType : typeof c?.user?.actor_type == "string" ? c.user.actor_type : void 0, d = s?.isSuperAdmin ?? t(c?.isAuthenticated ?? !1, c?.user?.role, u), f = h(d);
39
+ p(() => {
40
+ f.current = d;
41
+ }, [d]);
42
+ let g = r(), _ = h(i);
43
+ _.current = i;
44
+ let y = h(g.attachments);
45
+ return y.current = g.attachments, m(() => o({
46
+ port: a ?? x,
46
47
  preflightAccess: () => {
47
- let { workspaceId: e, actorId: t } = b();
48
- return s(e, t, o.current);
48
+ let { workspaceId: e, actorId: t } = S();
49
+ return l(e, t, f.current);
49
50
  },
50
- getScopeKey: () => JSON.stringify(b()),
51
+ getScopeKey: () => JSON.stringify(S()),
51
52
  get folderPath() {
52
- return u.current;
53
+ return y.current;
53
54
  },
54
- onChange: (e, t) => l.current(e, t)
55
- }), [r]);
55
+ onChange: (e, t) => _.current(e, t)
56
+ }), [a]);
56
57
  }
57
58
  //#endregion
58
- export { h as AttachmentFilesPortContext, x as useAttachmentCommitter, g as useAttachmentFilesPort, _ as useAttachmentUrlResolver };
59
+ export { _ as AttachmentFilesPortContext, C as useAttachmentCommitter, v as useAttachmentFilesPort, y as useAttachmentUrlResolver };
@@ -73,3 +73,5 @@ export interface AuthProviderProps {
73
73
  }
74
74
  export declare function AuthProvider({ children, onTokenExpired, onSessionExpiringSoon, onRefreshToken, bridgeUrl, bridgeAllowedOrigins, bridgeDebug, onBridgeReady, onBeforeIdentityChange, }: AuthProviderProps): import('react/jsx-runtime').JSX.Element;
75
75
  export declare function useAuth(): AuthContextValue;
76
+ /** Optional shell integration: the same session as useAuth, or no provider. */
77
+ export declare function useSafeAuth(): AuthContextValue | null;
@@ -1,17 +1,17 @@
1
1
  import { getActiveProfileId as e, getProfileTokens as t, getProfileUser as n, getProfileWorkspaceToken as ee, getSwitchableProfiles as r, resolveActiveProfileId as te } from "./ProfileStorageManager.js";
2
- import { readShellSsoCookie as i } from "../../utils/authCookie.js";
3
- import { identityKeyOf as a } from "./authProvider/identityChange.js";
4
- import { useBridgeInitialization as o } from "./authProvider/useBridgeInitialization.js";
5
- import { useTokenExpiryTimer as ne } from "./authProvider/useTokenExpiryTimer.js";
6
- import { useStorageSync as re } from "./authProvider/useStorageSync.js";
7
- import { useRemoteSLO as ie } from "./authProvider/useRemoteSLO.js";
2
+ import { readShellSsoCookie as ne } from "../../utils/authCookie.js";
3
+ import { identityKeyOf as i } from "./authProvider/identityChange.js";
4
+ import { useBridgeInitialization as a } from "./authProvider/useBridgeInitialization.js";
5
+ import { useTokenExpiryTimer as re } from "./authProvider/useTokenExpiryTimer.js";
6
+ import { useStorageSync as ie } from "./authProvider/useStorageSync.js";
7
+ import { useRemoteSLO as o } from "./authProvider/useRemoteSLO.js";
8
8
  import { useAuthActions as ae } from "./authProvider/useAuthActions.js";
9
9
  import { useSsoDepositBootGuard as oe } from "./authProvider/useSsoDepositBootGuard.js";
10
10
  import { createContext as s, use as c, useCallback as l, useLayoutEffect as se, useMemo as u, useRef as d, useState as f } from "react";
11
- import { jsx as ce } from "react/jsx-runtime";
11
+ import { jsx as p } from "react/jsx-runtime";
12
12
  //#region src/shared/providers/shell/AuthProvider.tsx
13
- var p = s(null);
14
- function m(e) {
13
+ var m = s(null);
14
+ function h(e) {
15
15
  return r(e).map((t) => ({
16
16
  id: t.id,
17
17
  email: t.email,
@@ -21,29 +21,29 @@ function m(e) {
21
21
  lastLogin: t.lastLogin
22
22
  }));
23
23
  }
24
- function h({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefreshToken: h, bridgeUrl: g, bridgeAllowedOrigins: _, bridgeDebug: v, onBridgeReady: le, onBeforeIdentityChange: y }) {
24
+ function g({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefreshToken: g, bridgeUrl: _, bridgeAllowedOrigins: v, bridgeDebug: ce, onBridgeReady: le, onBeforeIdentityChange: y }) {
25
25
  let b = d(!1), [x, S] = f(() => te()), [C, w] = f(() => x ? n(x) : null), [T, E] = f(() => x ? t(x) : null), [D, O] = f(() => x ? ee(x) : null), [k, A] = f(() => {
26
26
  if (x && n(x)) return !1;
27
- if (g) try {
28
- let e = i()?.id ?? null;
27
+ if (_) try {
28
+ let e = ne()?.id ?? null;
29
29
  if (e && localStorage.getItem(`bf-p-${e}-tokens`)) return !1;
30
30
  } catch {}
31
- return !!g;
32
- }), [j, ue] = f(!1), [M, de] = f(null), [N, P] = f(() => m(x)), F = l(() => {
31
+ return !!_;
32
+ }), [j, ue] = f(!1), [M, de] = f(null), [N, P] = f(() => h(x)), F = l(() => {
33
33
  P([]);
34
34
  }, []), I = l(() => {
35
- P(m(e()));
36
- }, []), L = a(x, C?.id), R = d(L), z = d(!1), B = d(y);
35
+ P(h(e()));
36
+ }, []), L = i(x, C?.id), R = d(L), z = d(!1), B = d(y);
37
37
  se(() => {
38
38
  R.current = L, z.current = !1, B.current = y;
39
39
  });
40
40
  let V = l((e, t) => {
41
- z.current || a(t.profileId, t.userId) !== R.current && (z.current = !0, B.current?.(e));
41
+ z.current || i(t.profileId, t.userId) !== R.current && (z.current = !0, B.current?.(e));
42
42
  }, []);
43
- o({
44
- bridgeUrl: g,
45
- bridgeAllowedOrigins: _,
46
- bridgeDebug: v,
43
+ a({
44
+ bridgeUrl: _,
45
+ bridgeAllowedOrigins: v,
46
+ bridgeDebug: ce,
47
47
  onBridgeReady: le,
48
48
  bridgeSyncInProgress: b,
49
49
  setIsLoading: A,
@@ -60,7 +60,7 @@ function h({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefresh
60
60
  tokens: T,
61
61
  activeId: x,
62
62
  bridgeSyncInProgress: b,
63
- onRefreshToken: h,
63
+ onRefreshToken: g,
64
64
  onTokenExpired: s,
65
65
  setActiveId: S,
66
66
  setUser: w,
@@ -73,13 +73,13 @@ function h({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefresh
73
73
  refreshAccounts: I,
74
74
  announceIdentityChange: V
75
75
  });
76
- ne({
76
+ re({
77
77
  tokens: T,
78
- onRefreshToken: h,
78
+ onRefreshToken: g,
79
79
  onTokenExpired: s,
80
80
  onSessionExpiringSoon: c,
81
81
  refreshAccessToken: K
82
- }), re({
82
+ }), ie({
83
83
  user: C,
84
84
  tokens: T,
85
85
  workspaceToken: D,
@@ -91,9 +91,9 @@ function h({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefresh
91
91
  clearAccounts: F,
92
92
  refreshAccounts: I,
93
93
  announceIdentityChange: V
94
- }), oe(), ie({
94
+ }), oe(), o({
95
95
  tokens: T,
96
- bridgeUrl: g,
96
+ bridgeUrl: _,
97
97
  logout: U,
98
98
  setActiveId: S,
99
99
  setUser: w,
@@ -146,15 +146,18 @@ function h({ children: r, onTokenExpired: s, onSessionExpiringSoon: c, onRefresh
146
146
  Q,
147
147
  W
148
148
  ]);
149
- return /* @__PURE__ */ ce(p.Provider, {
149
+ return /* @__PURE__ */ p(m.Provider, {
150
150
  value: fe,
151
151
  children: r
152
152
  });
153
153
  }
154
- function g() {
155
- let e = c(p);
154
+ function _() {
155
+ let e = c(m);
156
156
  if (!e) throw Error("useAuth must be used within an AuthProvider");
157
157
  return e;
158
158
  }
159
+ function v() {
160
+ return c(m);
161
+ }
159
162
  //#endregion
160
- export { h as AuthProvider, g as useAuth };
163
+ export { g as AuthProvider, _ as useAuth, v as useSafeAuth };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/fe-libs",
3
- "version": "2026.1029.5",
3
+ "version": "2026.1029.6",
4
4
  "description": "Burdenoff frontend primitives and domain libraries",
5
5
  "type": "module",
6
6
  "bin": {