nucleus-core-ts 0.10.246 → 0.10.248

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/dist/.build-ok CHANGED
@@ -1 +1 @@
1
- 0.10.246
1
+ 0.10.248
@@ -981,7 +981,7 @@ export function createHostPayments(options: any): {
981
981
  message: any;
982
982
  } | {
983
983
  ok: boolean;
984
- refundedMinor: number;
984
+ refundedMinor: any;
985
985
  status: any;
986
986
  }>;
987
987
  transaction: (id: any, scope: any) => Promise<any>;
@@ -16,6 +16,40 @@ function computeIntegrityHash(roles, claims) {
16
16
  }
17
17
  return hash.toString(36);
18
18
  }
19
+ // The verdict is KEPT for the very arrays it judged. Every `hasClaim` /
20
+ // `hasAnyClaim` / `hasAllClaims` / `checkPermission` asks `verifyIntegrity()`, and
21
+ // the check maps, sorts, stringifies and hashes EVERY role and claim the person
22
+ // holds. A godmin or an administrator holds thousands of claims, and a screen
23
+ // asks the gate once per gated control: measured on vorionai.com (2026-11-18,
24
+ // Chrome, a godmin) the home page's composer made 145 gate calls per keystroke,
25
+ // each a sort + JSON.stringify of the whole claim list (3,039 sorts and as many
26
+ // stringifies for 21 keystrokes: ~30 ms per key of a 46 ms render). The arrays
27
+ // are replaced by `hydrate`, `reset`, an assignment or an array method (h-state
28
+ // answers those with a new generation), and a verdict for the same arrays, the
29
+ // same lengths and the same stored hash is reused. A claim EDITED IN PLACE keeps
30
+ // the array's identity in h-state, so the verdict also expires after
31
+ // INTEGRITY_RECHECK_MS: that edit is refused within a fifth of a second, which
32
+ // costs at most a few checks a second instead of a hundred and forty per key.
33
+ const INTEGRITY_RECHECK_MS = 200;
34
+ let judged = null;
35
+ function integrityHolds(roles, claims, hash) {
36
+ const now = Date.now();
37
+ const last = judged;
38
+ if (last && now - last.at < INTEGRITY_RECHECK_MS && last.roles === roles && last.claims === claims && last.rolesLength === roles.length && last.claimsLength === claims.length && last.hash === hash) {
39
+ return last.ok;
40
+ }
41
+ const ok = computeIntegrityHash(roles, claims) === hash;
42
+ judged = {
43
+ roles,
44
+ claims,
45
+ rolesLength: roles.length,
46
+ claimsLength: claims.length,
47
+ hash,
48
+ ok,
49
+ at: now
50
+ };
51
+ return ok;
52
+ }
19
53
  // ─── Godmin ─────────────────────────────────────────────────────────────────
20
54
  // The backend treats the `godmin` ROLE as a full bypass
21
55
  // (Services/Authorization/Middleware: `isGodmin` -> `authorized: true`), and it
@@ -183,7 +217,6 @@ export const { useStore: useAuthGuardStore } = createStore({
183
217
  },
184
218
  verifyIntegrity: (store)=>()=>{
185
219
  if (!store._integrityHash) return true;
186
- const expected = computeIntegrityHash(store.roles, store.claims);
187
- return expected === store._integrityHash;
220
+ return integrityHolds(store.roles, store.claims, store._integrityHash);
188
221
  }
189
222
  });