New:Socket for Asana Is Now Available.Learn more
Get Started

genosdb

Package Overview
Dependencies
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

genosdb - npm Package Compare versions

Comparing version
0.27.1
to
0.28.0
+1
-1
dist/sm-acls.min.js
var log=(()=>{const n=()=>{};return new Proxy(console,{get:(c,m)=>globalThis.__gdbDebug?c[m].bind(c):n})})();
var _=async(F,V)=>{if(!V)return null;let G="owner",H="collaborators",Q=()=>{let h=F.sm.getActiveEthAddress();if(!h)throw Error("❌ [SM-ACLs] Active user session required.");return h},X=(h)=>Error(`❌ [SM-ACLs] Only the owner can ${h}.`),Z=async(h,k)=>{let x=[];for(let z of h){let{signer:D,type:J,id:P}=z;if(!D||!P){x.push(z);continue}let T=k.get(P),{[G]:K,[H]:Y={}}=T?.value||{};if(J==="upsert"||J==="put"){if(!T||K===void 0||D===K||Y[D]==="write"||Y[D]==="delete")x.push(z);else log.warn(`⚠️ [SM-ACLs] DENIED (put): ${D} → ${P}`);continue}if(J==="remove"){if(!T||K===void 0||D===K||Y[D]==="delete")x.push(z);else log.warn(`⚠️ [SM-ACLs] DENIED (remove): ${D} → ${P}`);continue}x.push(z)}return x};return F.use(Z),{async set(h,k){let x=Q(),{result:z}=await F.get(k);if(z){let{[G]:D,[H]:J={}}=z.value;if(x!==D&&J[x]!=="write")throw Error(`\uD83D\uDEE1️ [SM-ACLs] Write denied for node ${k}.`);let{[G]:P,[H]:T,...K}=h;return F.put({...z.value,...K},k)}return F.put({...h,[G]:x,[H]:{}},k)},async grant(h,k,x){let z=Q();if(!["read","write","delete"].includes(x))throw Error("\uD83D\uDEE1️ [SM-ACLs] Permission must be 'read', 'write' or 'delete'.");let{result:D}=await F.get(h);if(!D)throw Error(`❌ [SM-ACLs] Node ${h} not found.`);if(D.value[G]!==z)throw X("grant permissions");let J={...D.value[H]??{},[k]:x};await F.put({...D.value,[H]:J},h)},async revoke(h,k){let x=Q(),{result:z}=await F.get(h);if(!z)throw Error(`❌ [SM-ACLs] Node ${h} not found.`);if(z.value[G]!==x)throw X("revoke permissions");let{[k]:D,...J}=z.value[H]??{};await F.put({...z.value,[H]:J},h)},async delete(h){let k=Q(),{result:x}=await F.get(h);if(!x)return;if(x.value[G]!==k&&x.value[H]?.[k]!=="delete")throw X("delete this node");await F.remove(h)},async getPermissions(h){let{result:k}=await F.get(h);if(!k||k.value[G]===void 0)return null;return{owner:k.value[G],collaborators:k.value[H]??{}}}}};async function f(F,V){log.info("\uD83D\uDEE1️ [SM-ACLs] Starting ACL module...");try{let G=await _(F,V);if(G)try{Object.defineProperty(F.sm,"acls",{value:G,writable:!0,enumerable:!1,configurable:!0}),log.info("\uD83D\uDEE1️ [SM-ACLs] Module initialized and attached to gdb.sm.acls.")}catch(H){throw log.error("❌ [SM-ACLs] Failed to attach: gdb.sm not extensible.",H.message),Error("❌ [SM-ACLs] Cannot attach ACL module to gdb.sm. Ensure gdb.sm is extensible.")}else log.warn("⚠️ [SM-ACLs] Module not activated (options missing).")}catch(G){throw log.error("❌ [SM-ACLs] Failed to start ACL module.",G),G}}export{f as start,_ as createAclModule};
var N=async(H,X,Z)=>{if(!X)return null;let Q="owner",K="collaborators",U="SM_ID_PREFIX_",F=async(h)=>{let x=(await H.get(h)).result;if(x)return{node:x,gid:h};let z=(await H.get(U+h)).result;return z?{node:z,gid:U+h}:{node:null,gid:h}},j=(h)=>h?.[Q]??h?._meta?.owner,P=()=>{let h=H.sm.getActiveEthAddress();if(!h)throw Error("❌ [SM-ACLs] Active user session required.");return h},_=(h)=>Error(`❌ [SM-ACLs] Only the owner can ${h}.`),f=async(h,x)=>{let z=[];for(let D of h){let{signer:G,type:Y,id:T}=D;if(!G||!T){z.push(D);continue}let J=x.get(T),{[Q]:V,[K]:$={}}=J?.value||{};if(Y==="upsert"||Y==="put"){if(!J||V===void 0||G===V||$[G]==="write"||$[G]==="delete")z.push(D);else log.warn(`⚠️ [SM-ACLs] DENIED (put): ${G} → ${T}`);continue}if(Y==="remove"){if(!J||V===void 0||G===V||$[G]==="delete")z.push(D);else log.warn(`⚠️ [SM-ACLs] DENIED (remove): ${G} → ${T}`);continue}z.push(D)}return z};return H.use(f),{async set(h,x){let z=P(),{result:D}=await H.get(x);if(D){let{[Q]:G,[K]:Y={}}=D.value;if(z!==G&&Y[z]!=="write")throw Error(`\uD83D\uDEE1️ [SM-ACLs] Write denied for node ${x}.`);let{[Q]:T,[K]:J,...V}=h;return H.put({...D.value,...V},x)}return H.put({...h,[Q]:z,[K]:{}},x)},async grant(h,x,z){let D=P();if(!["read","write","delete"].includes(z))throw Error("\uD83D\uDEE1️ [SM-ACLs] Permission must be 'read', 'write' or 'delete'.");let{node:G,gid:Y}=await F(h);if(!G)throw Error(`❌ [SM-ACLs] Node ${h} not found.`);if(j(G.value)!==D)throw _("grant permissions");let T={...G.value[K]??{},[x]:z},J=G.value._meta;if(J?.keys){let V=(await H.get(`user:${x}`)).result?.value?.pub;if(!V)throw Error(`❌ [SM-ACLs] ${x} has no published key yet (requires one login).`);let $=await Z.unwrapKey(J.keys[D]),q={...J.keys,[x]:await Z.wrapKeyFor(V,$,x)};return H.put({...G.value,[K]:T,_meta:{...J,keys:q}},Y)}await H.put({...G.value,[K]:T},Y)},async revoke(h,x){let z=P(),{node:D,gid:G}=await F(h);if(!D)throw Error(`❌ [SM-ACLs] Node ${h} not found.`);if(j(D.value)!==z)throw _("revoke permissions");let{[x]:Y,...T}=D.value[K]??{},J=D.value._meta;if(J?.keys){let V=await Z.openWithKey(D.value._payload,J.iv,await Z.unwrapKey(J.keys[z])),$=crypto.getRandomValues(new Uint8Array(32)),{iv:q,encrypted:k}=await Z.sealWithKey(V,$),W={};for(let[M,R]of Object.entries(J.keys))if(M!==x)W[M]=await Z.wrapKeyFor(R.r,$,M);return H.put({...D.value,_payload:k,[K]:T,_meta:{...J,iv:q,keys:W}},G)}await H.put({...D.value,[K]:T},G)},async delete(h){let x=P(),{node:z,gid:D}=await F(h);if(!z)return;if(j(z.value)!==x&&z.value[K]?.[x]!=="delete")throw _("delete this node");await H.remove(D)},async getPermissions(h){let{node:x}=await F(h);if(!x||j(x.value)===void 0)return null;return{owner:j(x.value),collaborators:x.value[K]??{}}}}};async function y(H,X,Z){log.info("\uD83D\uDEE1️ [SM-ACLs] Starting ACL module...");try{let Q=await N(H,X,Z);if(Q)try{Object.defineProperty(H.sm,"acls",{value:Q,writable:!0,enumerable:!1,configurable:!0}),log.info("\uD83D\uDEE1️ [SM-ACLs] Module initialized and attached to gdb.sm.acls.")}catch(K){throw log.error("❌ [SM-ACLs] Failed to attach: gdb.sm not extensible.",K.message),Error("❌ [SM-ACLs] Cannot attach ACL module to gdb.sm. Ensure gdb.sm is extensible.")}else log.warn("⚠️ [SM-ACLs] Module not activated (options missing).")}catch(Q){throw log.error("❌ [SM-ACLs] Failed to start ACL module.",Q),Q}}export{y as start,N as createAclModule};
{
"name": "genosdb",
"version": "0.27.1",
"version": "0.28.0",
"description": "GenosDB (GDB): distributed graph database in real-time, peer-to-peer, scalable storage - efficient querying of complex relationships.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -91,3 +91,3 @@ # GenosDB (GDB) – Decentralized P2P Graph Database

GenosDB overcomes the limitations of naive P2P sync with an intelligent, dual-mode engine. It automatically exchanges tiny, compressed Deltas between active peers using a sliding-window Oplog for blazing-fast, low-latency updates. For peers that are too far out of sync, it seamlessly switches to a robust Full-State Fallback, guaranteeing absolute data consistency for everyone, no matter how long they've been offline.
- **Access Control Lists (ACLs):** Optional submodule for fine-grained, node-level permissions, allowing owners to grant/revoke specific permissions ('read', 'write', 'delete') to other users per node, complementing the existing RBAC system.
- **Access Control Lists (ACLs):** Optional submodule for fine-grained, node-level permissions, allowing owners to grant/revoke specific permissions ('read', 'write', 'delete') to other users per node, complementing the existing RBAC system. On encrypted (`db.sm.put`) records these are cryptographic: `grant` shares a per-record key envelope and `revoke` rotates the key, so revoked readers cannot decrypt anything written afterwards.
- **Governance (Role Promotion & Demotion):** Optional engine that resolves each user's role from declarative rules (native GenosDB queries) using **last-match-wins** — a merit ladder where climbing overrides lower tiers and losing the condition auto-demotes. Every change is signed by a superadmin — from a browser session, or by the always-on Fallback Server. ([Governance](https://github.com/estebanrfp/gdb/blob/main/docs/governance.md))

@@ -94,0 +94,0 @@ - **Fallback Server (GenosSRV):** Optional always-on superpeer shipped with the dist as a single zero-dependency file — durable memory, availability anchor for peers that reconnect, both transports (full mesh and Cellular Mesh), **24/7 governance**, and optionally the room's **signaling**, so discovery itself runs on your infrastructure. The entire stack in one deployable file: one command anywhere Bun runs, or a one-click deploy on any container platform. ([Fallback Server](https://github.com/estebanrfp/gdb/blob/main/docs/genosdb-fallback-server.md))

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet