nervur 0.6.0 → 0.7.1

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/being.mjs CHANGED
@@ -169,6 +169,9 @@ const Being = ({ voice, address, modules, registry, vouched, watch }) => {
169
169
  }
170
170
  const rights = self ? 'SELF' : (row?.rights ?? 'STRANGER');
171
171
  if (op?.describe !== undefined) {
172
+ if (program !== undefined && !program.visible(rights)) {
173
+ return undefined;
174
+ }
172
175
  return answer({
173
176
  address,
174
177
  digest: program?.digest,
package/ground.mjs CHANGED
@@ -81,15 +81,27 @@ const Ground = (modules = {}) => {
81
81
  ),
82
82
  ]),
83
83
  );
84
+ const introduced = (unscoped, address) =>
85
+ Object.fromEntries(
86
+ Object.entries(unscoped).map(([name, one]) => [
87
+ name,
88
+ typeof one?.scope === 'function' ? one.scope(address) : one,
89
+ ]),
90
+ );
84
91
  const modulesFor = (voice) =>
85
- Object.freeze({
86
- ...extra,
87
- ...boundFor(voice),
88
- deliver: (envelope) => deliver(envelope),
89
- memory,
90
- paths,
91
- wire,
92
- });
92
+ Object.freeze(
93
+ introduced(
94
+ {
95
+ ...extra,
96
+ ...boundFor(voice),
97
+ deliver: (envelope) => deliver(envelope),
98
+ memory,
99
+ paths,
100
+ wire,
101
+ },
102
+ Tools.address(voice.pk),
103
+ ),
104
+ );
93
105
  const adminModules = modulesFor(adminVoice);
94
106
 
95
107
  const adminMine = Compartment({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nervur",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "A distributed system of sovereign beings — one door, one question: by whose authority.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Razvan Gherghina",
package/program.mjs CHANGED
@@ -68,6 +68,16 @@ const Program = (source) => {
68
68
  name: blueprint.name,
69
69
  rights: blueprint.rights,
70
70
  sdlFor: blueprint.sdlFor,
71
+ visible: (held) => {
72
+ const filtered = seenBy(held);
73
+ if (filtered === undefined) {
74
+ return false;
75
+ }
76
+ const rooted = [filtered.getQueryType(), filtered.getMutationType()].filter(
77
+ (one) => one !== undefined && one !== null,
78
+ );
79
+ return rooted.some((one) => Object.keys(one.getFields()).length > 0);
80
+ },
71
81
  });
72
82
  };
73
83