nervur 0.5.0 → 0.6.0
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/README.md +8 -5
- package/admin.mjs +8 -6
- package/being.mjs +8 -4
- package/index.mjs +1 -1
- package/modules.mjs +3 -2
- package/package.json +1 -1
- package/tools.mjs +3 -1
package/README.md
CHANGED
|
@@ -16,13 +16,16 @@ one thing that would be madness to hand-roll: the schema and its execution.
|
|
|
16
16
|
|
|
17
17
|
## Quickstart
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
`npm install nervur` — what ships is this source, byte for byte, one
|
|
20
|
+
dependency (`graphql`). The package is a library and carries no command;
|
|
21
|
+
the `nervur` command on an operator's PATH belongs to the
|
|
22
|
+
[`nervurd`](../nervurd/README.md) package, its name twin. Construction is
|
|
23
|
+
synchronous; every call through a door — `pointer`, `mcp`, `gql`, and each
|
|
24
|
+
function they hand back — is async. This runs today, lifted from the
|
|
25
|
+
bench's own passing suites:
|
|
23
26
|
|
|
24
27
|
```js
|
|
25
|
-
import { Cells, Ground, Keychain, Tools, Voice } from '
|
|
28
|
+
import { Cells, Ground, Keychain, Tools, Voice } from 'nervur';
|
|
26
29
|
|
|
27
30
|
const DIARY = `({
|
|
28
31
|
name: 'acme.diary',
|
package/admin.mjs
CHANGED
|
@@ -13,11 +13,12 @@ const ADMIN = `({
|
|
|
13
13
|
}
|
|
14
14
|
type Mutation {
|
|
15
15
|
init(address: String!, nextPkHash: String): Boolean @rights(is: [SELF, MEMBER, STRANGER])
|
|
16
|
-
create(program: String!, refs: [RefInput!], data: String
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
create(program: String!, refs: [RefInput!], data: String, config: String): String
|
|
17
|
+
@rights(is: [SELF, MEMBER])
|
|
18
|
+
activate(address: String!): String @rights(is: [SELF, MEMBER])
|
|
19
|
+
destroy(address: String!): String @rights(is: [SELF, MEMBER])
|
|
20
|
+
upgrade(address: String!, program: String!): Boolean @rights(is: [SELF, MEMBER])
|
|
21
|
+
alias(name: String!, address: String!): Boolean @rights(is: [SELF, MEMBER])
|
|
21
22
|
}
|
|
22
23
|
\`,
|
|
23
24
|
resolvers: {
|
|
@@ -38,8 +39,9 @@ const ADMIN = `({
|
|
|
38
39
|
nextPkHash: nextPkHash ?? null,
|
|
39
40
|
rights: 'MEMBER',
|
|
40
41
|
}) !== undefined,
|
|
41
|
-
create: (_, { program, refs, data }, { registry }) =>
|
|
42
|
+
create: (_, { program, refs, data, config }, { registry }) =>
|
|
42
43
|
registry.create({
|
|
44
|
+
config: config === undefined ? undefined : JSON.parse(config),
|
|
43
45
|
data: data ? JSON.parse(data) : {},
|
|
44
46
|
program,
|
|
45
47
|
refs: refs ?? [],
|
package/being.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OPEN, STRUCTURAL, coreClass } from './blueprint.mjs';
|
|
2
2
|
import { Program } from './program.mjs';
|
|
3
|
-
import { Stamp, Tools } from './tools.mjs';
|
|
3
|
+
import { MEASURE, Stamp, Tools } from './tools.mjs';
|
|
4
4
|
import { Voice } from './voice.mjs';
|
|
5
5
|
|
|
6
6
|
const Compartment = ({ memory, voice, address, root, classOf }) => {
|
|
@@ -124,7 +124,10 @@ const Being = ({ voice, address, modules, registry, vouched, watch }) => {
|
|
|
124
124
|
root,
|
|
125
125
|
classOf: (key) => program?.classOf(key) ?? coreClass(key),
|
|
126
126
|
});
|
|
127
|
-
const answer = (spoken) =>
|
|
127
|
+
const answer = (spoken) => {
|
|
128
|
+
const body = Tools.canon(spoken);
|
|
129
|
+
return body.length > MEASURE ? undefined : { body: spoken, sig: voice.sign(body) };
|
|
130
|
+
};
|
|
128
131
|
const note = (envelope, outcome) => {
|
|
129
132
|
try {
|
|
130
133
|
watch?.(
|
|
@@ -145,11 +148,12 @@ const Being = ({ voice, address, modules, registry, vouched, watch }) => {
|
|
|
145
148
|
const spoken = await (async () => {
|
|
146
149
|
try {
|
|
147
150
|
const { from, op, seq, sig, to } = envelope;
|
|
151
|
+
const claim = Tools.canon({ from, op, seq, to });
|
|
148
152
|
const callerPk = Tools.pkOf(from);
|
|
149
153
|
const proven =
|
|
154
|
+
claim.length <= MEASURE &&
|
|
150
155
|
callerPk !== null &&
|
|
151
|
-
((vouched !== undefined && token === vouched) ||
|
|
152
|
-
Tools.verifies(callerPk, Tools.canon({ from, op, seq, to }), sig));
|
|
156
|
+
((vouched !== undefined && token === vouched) || Tools.verifies(callerPk, claim, sig));
|
|
153
157
|
if (to !== address || !proven) {
|
|
154
158
|
gated = 'unproven';
|
|
155
159
|
return undefined;
|
package/index.mjs
CHANGED
|
@@ -6,5 +6,5 @@ export { GROUND, Ground } from './ground.mjs';
|
|
|
6
6
|
export { Cells, Clock, Dns, Entropy, Keychain, Memory, Paths, Wire } from './modules.mjs';
|
|
7
7
|
export { Mcp, Pointer } from './pointer.mjs';
|
|
8
8
|
export { Program } from './program.mjs';
|
|
9
|
-
export { Stamp, Tools } from './tools.mjs';
|
|
9
|
+
export { MEASURE, Stamp, Tools } from './tools.mjs';
|
|
10
10
|
export { Voice } from './voice.mjs';
|
package/modules.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { Tools } from './tools.mjs';
|
|
3
3
|
|
|
4
4
|
const Cells = ({ file } = {}) => {
|
|
@@ -7,7 +7,8 @@ const Cells = ({ file } = {}) => {
|
|
|
7
7
|
);
|
|
8
8
|
const flush = () => {
|
|
9
9
|
if (file) {
|
|
10
|
-
writeFileSync(file
|
|
10
|
+
writeFileSync(`${file}.next`, JSON.stringify(Object.fromEntries(cells)));
|
|
11
|
+
renameSync(`${file}.next`, file);
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
14
|
return Object.freeze({
|
package/package.json
CHANGED
package/tools.mjs
CHANGED
|
@@ -13,6 +13,8 @@ const B32 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
|
|
13
13
|
|
|
14
14
|
const VERSION_G = 6 << 3;
|
|
15
15
|
|
|
16
|
+
const MEASURE = 8_388_608;
|
|
17
|
+
|
|
16
18
|
const ordered = (value) =>
|
|
17
19
|
value === null || typeof value !== 'object'
|
|
18
20
|
? value
|
|
@@ -136,4 +138,4 @@ const Stamp = () => {
|
|
|
136
138
|
};
|
|
137
139
|
};
|
|
138
140
|
|
|
139
|
-
export { Stamp, Tools };
|
|
141
|
+
export { MEASURE, Stamp, Tools };
|