@datumesh/verify 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/README.md +56 -2
- package/dist/cjs/ed25519.d.ts +2 -0
- package/dist/cjs/ed25519.js +82 -0
- package/dist/cjs/envelope.d.ts +38 -0
- package/dist/cjs/envelope.js +243 -0
- package/dist/cjs/errors.d.ts +14 -0
- package/dist/cjs/errors.js +65 -0
- package/dist/cjs/hash.d.ts +6 -0
- package/dist/cjs/hash.js +27 -0
- package/dist/cjs/index.d.ts +37 -0
- package/dist/cjs/index.js +101 -0
- package/dist/cjs/jcs.d.ts +5 -0
- package/dist/cjs/jcs.js +25 -0
- package/dist/cjs/json.d.ts +29 -0
- package/dist/cjs/json.js +325 -0
- package/dist/cjs/keys.d.ts +73 -0
- package/dist/cjs/keys.js +257 -0
- package/dist/cjs/lexical.d.ts +69 -0
- package/dist/cjs/lexical.js +231 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/unicode-data.d.ts +8 -0
- package/dist/cjs/unicode-data.js +14 -0
- package/dist/cjs/unicode.d.ts +12 -0
- package/dist/cjs/unicode.js +192 -0
- package/dist/cjs/units-data.d.ts +4 -0
- package/dist/cjs/units-data.js +11 -0
- package/dist/cjs/units.d.ts +24 -0
- package/dist/cjs/units.js +131 -0
- package/dist/cjs/uri.d.ts +43 -0
- package/dist/cjs/uri.js +209 -0
- package/dist/cjs/utf8.d.ts +10 -0
- package/dist/cjs/utf8.js +101 -0
- package/dist/cjs/validate.d.ts +25 -0
- package/dist/cjs/validate.js +408 -0
- package/dist/cjs/verify.d.ts +57 -0
- package/dist/cjs/verify.js +232 -0
- package/dist/esm/ed25519.d.ts +2 -0
- package/dist/esm/ed25519.js +79 -0
- package/dist/esm/envelope.d.ts +38 -0
- package/dist/esm/envelope.js +240 -0
- package/dist/esm/errors.d.ts +14 -0
- package/dist/esm/errors.js +60 -0
- package/dist/esm/hash.d.ts +6 -0
- package/dist/esm/hash.js +21 -0
- package/dist/esm/index.d.ts +37 -0
- package/dist/esm/index.js +79 -0
- package/dist/esm/jcs.d.ts +5 -0
- package/dist/esm/jcs.js +18 -0
- package/dist/esm/json.d.ts +29 -0
- package/dist/esm/json.js +313 -0
- package/dist/esm/keys.d.ts +73 -0
- package/dist/esm/keys.js +249 -0
- package/dist/esm/lexical.d.ts +69 -0
- package/dist/esm/lexical.js +209 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/unicode-data.d.ts +8 -0
- package/dist/esm/unicode-data.js +11 -0
- package/dist/esm/unicode.d.ts +12 -0
- package/dist/esm/unicode.js +184 -0
- package/dist/esm/units-data.d.ts +4 -0
- package/dist/esm/units-data.js +8 -0
- package/dist/esm/units.d.ts +24 -0
- package/dist/esm/units.js +123 -0
- package/dist/esm/uri.d.ts +43 -0
- package/dist/esm/uri.js +204 -0
- package/dist/esm/utf8.d.ts +10 -0
- package/dist/esm/utf8.js +96 -0
- package/dist/esm/validate.d.ts +25 -0
- package/dist/esm/validate.js +397 -0
- package/dist/esm/verify.d.ts +57 -0
- package/dist/esm/verify.js +227 -0
- package/package.json +54 -4
package/dist/esm/uri.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// Cell URIs (SPEC.md section 5).
|
|
2
|
+
import { fail } from './errors.js';
|
|
3
|
+
import { isObject, sortedKeys, toJson } from './json.js';
|
|
4
|
+
import { LIMITS, checkArgName, checkInstant, checkName, checkNamespace, checkTypedValue, isTypeName } from './lexical.js';
|
|
5
|
+
import { utf8Decode, utf8Encode } from './utf8.js';
|
|
6
|
+
import { validate } from './validate.js';
|
|
7
|
+
const SCHEME = 'cell://';
|
|
8
|
+
function isLiteral(c) {
|
|
9
|
+
return /^[A-Za-z0-9\-._~:]$/.test(c);
|
|
10
|
+
}
|
|
11
|
+
function decodeValue(v, path) {
|
|
12
|
+
const bytes = [];
|
|
13
|
+
for (let i = 0; i < v.length;) {
|
|
14
|
+
const c = v[i];
|
|
15
|
+
if (c === '%') {
|
|
16
|
+
const h = v.slice(i + 1, i + 3);
|
|
17
|
+
if (!/^[0-9A-F]{2}$/.test(h))
|
|
18
|
+
fail('E_CANON_PERCENT', 'percent-encoding must be % and two uppercase hex digits', path);
|
|
19
|
+
const b = parseInt(h, 16);
|
|
20
|
+
if (isLiteral(String.fromCharCode(b)))
|
|
21
|
+
fail('E_CANON_PERCENT', `${JSON.stringify(String.fromCharCode(b))} must not be percent-encoded`, path);
|
|
22
|
+
bytes.push(b);
|
|
23
|
+
i += 3;
|
|
24
|
+
}
|
|
25
|
+
else if (isLiteral(c)) {
|
|
26
|
+
bytes.push(c.charCodeAt(0));
|
|
27
|
+
i++;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const cp = v.codePointAt(i);
|
|
31
|
+
fail('E_CANON_PERCENT', `${JSON.stringify(String.fromCodePoint(cp))} must be percent-encoded`, path);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const s = utf8Decode(Uint8Array.from(bytes));
|
|
35
|
+
if (s === null)
|
|
36
|
+
fail('E_CANON_PERCENT', 'percent-encoded bytes are not UTF-8', path);
|
|
37
|
+
return s;
|
|
38
|
+
}
|
|
39
|
+
function encodeValue(s) {
|
|
40
|
+
let out = '';
|
|
41
|
+
for (const b of utf8Encode(s)) {
|
|
42
|
+
const c = String.fromCharCode(b);
|
|
43
|
+
out += isLiteral(c) ? c : `%${b.toString(16).toUpperCase().padStart(2, '0')}`;
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* SPEC 5.4: the signature is taken as given (it comes from a descriptor already checked under
|
|
49
|
+
* section 7); only the declared argument names and types are used. Something that is not a
|
|
50
|
+
* signature at all is a programmer error.
|
|
51
|
+
*/
|
|
52
|
+
function readSignature(signature) {
|
|
53
|
+
let sig;
|
|
54
|
+
try {
|
|
55
|
+
sig = toJson(signature);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new TypeError('parseUri needs the function signature (descriptor.signature) as JSON');
|
|
59
|
+
}
|
|
60
|
+
if (!isObject(sig) || !isObject(sig.args))
|
|
61
|
+
throw new TypeError('parseUri needs the function signature (descriptor.signature): an object with args');
|
|
62
|
+
return sig;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parse a cell URI into a cell reference, taking argument types from the function's
|
|
66
|
+
* signature (SPEC 5.4). Checks run in the order of SPEC 5.4 and the first failure is thrown as
|
|
67
|
+
* a DatumeshError.
|
|
68
|
+
*/
|
|
69
|
+
export function parseUri(uri, signature) {
|
|
70
|
+
if (typeof uri !== 'string')
|
|
71
|
+
throw new TypeError('uri must be a string');
|
|
72
|
+
const sig = readSignature(signature);
|
|
73
|
+
const declared = sig.args;
|
|
74
|
+
// 1. Outer grammar.
|
|
75
|
+
if (!uri.startsWith(SCHEME) || uri.includes('#'))
|
|
76
|
+
fail('E_PARSE_URI', 'not cell://<namespace>/<function>[?<query>] without fragment', '$');
|
|
77
|
+
const rest = uri.slice(SCHEME.length);
|
|
78
|
+
const q = rest.indexOf('?');
|
|
79
|
+
const path = q < 0 ? rest : rest.slice(0, q);
|
|
80
|
+
const query = q < 0 ? null : rest.slice(q + 1);
|
|
81
|
+
if (query === '')
|
|
82
|
+
fail('E_PARSE_URI', 'empty query', '$');
|
|
83
|
+
// SPEC 5.1 lists userinfo and a port among outer-grammar failures (E_PARSE_URI). (The
|
|
84
|
+
// reference tool reports them as E_CANON_NAME; see DEFECTS.md.)
|
|
85
|
+
const authority = path.split('/')[0];
|
|
86
|
+
if (authority.includes('@'))
|
|
87
|
+
fail('E_PARSE_URI', 'a cell URI has no userinfo', '$');
|
|
88
|
+
if (authority.includes(':'))
|
|
89
|
+
fail('E_PARSE_URI', 'a cell URI has no port', '$');
|
|
90
|
+
const params = (query === null ? [] : query.split('&')).map((p) => {
|
|
91
|
+
const e = p.indexOf('=');
|
|
92
|
+
if (e < 0)
|
|
93
|
+
fail('E_PARSE_URI', `parameter without '=': ${JSON.stringify(p)}`, '$');
|
|
94
|
+
return { name: p.slice(0, e), value: p.slice(e + 1) };
|
|
95
|
+
});
|
|
96
|
+
// 2. Namespace and function name.
|
|
97
|
+
const slash = path.lastIndexOf('/');
|
|
98
|
+
if (slash < 0)
|
|
99
|
+
fail('E_CANON_NAME', 'missing namespace', 'uri.path');
|
|
100
|
+
const ns = path.slice(0, slash);
|
|
101
|
+
const fn = path.slice(slash + 1);
|
|
102
|
+
checkNamespace(ns, 'uri.path');
|
|
103
|
+
checkName(fn, 'uri.path');
|
|
104
|
+
if (path.length > LIMITS.function_name)
|
|
105
|
+
fail('E_CANON_LIMIT', 'function name too long', 'uri.path');
|
|
106
|
+
// 3. Parameter names, left to right.
|
|
107
|
+
const at = (n) => `uri.query.${n}`;
|
|
108
|
+
// asof: when the last parameter is asof, that is the asof parameter and any earlier asof is a
|
|
109
|
+
// repetition (E_CANON_ARG_DUPLICATE); otherwise an asof anywhere is out of place
|
|
110
|
+
// (E_CANON_ARG_ORDER). SPEC 5.2 does not say which applies when both do; this matches the
|
|
111
|
+
// reference tool (DEFECTS.md).
|
|
112
|
+
let prev = null;
|
|
113
|
+
const lastIsAsof = params.length > 0 && params[params.length - 1].name === 'asof';
|
|
114
|
+
params.forEach((p, i) => {
|
|
115
|
+
if (p.name === 'asof') {
|
|
116
|
+
if (!lastIsAsof)
|
|
117
|
+
fail('E_CANON_ARG_ORDER', 'asof appears once, as the last parameter', at(p.name));
|
|
118
|
+
if (i !== params.length - 1)
|
|
119
|
+
fail('E_CANON_ARG_DUPLICATE', 'asof repeated', at(p.name));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
checkArgName(p.name, at(p.name));
|
|
123
|
+
if (prev !== null && p.name === prev)
|
|
124
|
+
fail('E_CANON_ARG_DUPLICATE', `argument ${JSON.stringify(p.name)} repeated`, at(p.name));
|
|
125
|
+
if (prev !== null && p.name < prev)
|
|
126
|
+
fail('E_CANON_ARG_ORDER', 'arguments must be sorted by name', at(p.name));
|
|
127
|
+
prev = p.name;
|
|
128
|
+
});
|
|
129
|
+
const argParams = params.filter((p) => p.name !== 'asof');
|
|
130
|
+
// 4. Argument count.
|
|
131
|
+
if (argParams.length > LIMITS.args)
|
|
132
|
+
fail('E_CANON_LIMIT', `more than ${LIMITS.args} arguments`, 'uri.query');
|
|
133
|
+
// 5. Against the signature: unknown arguments, then missing ones.
|
|
134
|
+
for (const p of argParams) {
|
|
135
|
+
if (!Object.prototype.hasOwnProperty.call(declared, p.name))
|
|
136
|
+
fail('E_ARG_UNKNOWN', `function declares no argument ${JSON.stringify(p.name)}`, at(p.name));
|
|
137
|
+
}
|
|
138
|
+
const present = new Set(argParams.map((p) => p.name));
|
|
139
|
+
for (const n of sortedKeys(declared)) {
|
|
140
|
+
if (!present.has(n))
|
|
141
|
+
fail('E_ARG_MISSING', `argument ${JSON.stringify(n)} absent; use ${n}=* for a slice`, 'uri.query');
|
|
142
|
+
}
|
|
143
|
+
// 6. Values, left to right: percent-encoding, then the lexical form.
|
|
144
|
+
const args = {};
|
|
145
|
+
for (const p of argParams) {
|
|
146
|
+
if (p.value === '*') {
|
|
147
|
+
args[p.name] = '*';
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const decl = declared[p.name];
|
|
151
|
+
const type = (isObject(decl) ? decl.type : undefined);
|
|
152
|
+
const s = decodeValue(p.value, at(p.name));
|
|
153
|
+
// The signature is not validated (5.4), but a value is read by its declared type: a
|
|
154
|
+
// declaration without a string type is E_SCHEMA, an unknown type name E_CANON_TYPE.
|
|
155
|
+
if (typeof type !== 'string')
|
|
156
|
+
fail('E_SCHEMA', `the signature declares ${p.name} without a string type`, `signature.args.${p.name}`);
|
|
157
|
+
if (!isTypeName(type))
|
|
158
|
+
fail('E_CANON_TYPE', `unknown type ${JSON.stringify(type)} in the signature`, `signature.args.${p.name}.type`);
|
|
159
|
+
if (type === 'boolean') {
|
|
160
|
+
if (s !== 'true' && s !== 'false')
|
|
161
|
+
fail('E_CANON_TYPE', 'boolean must be true or false', at(p.name));
|
|
162
|
+
args[p.name] = { type, value: s === 'true' };
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
checkTypedValue(type, s, at(p.name));
|
|
166
|
+
args[p.name] = { type, value: s };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// 7. asof.
|
|
170
|
+
const ref = { args, fn, ns };
|
|
171
|
+
const asofParam = params.find((p) => p.name === 'asof');
|
|
172
|
+
if (asofParam) {
|
|
173
|
+
const s = decodeValue(asofParam.value, at('asof'));
|
|
174
|
+
checkInstant(s, at('asof'));
|
|
175
|
+
ref.asof = s;
|
|
176
|
+
}
|
|
177
|
+
return ref;
|
|
178
|
+
}
|
|
179
|
+
/** Write the unique cell URI of a cell reference (SPEC 5.2). Throws DatumeshError if invalid. */
|
|
180
|
+
export function formatUri(ref) {
|
|
181
|
+
const v = toJson(ref);
|
|
182
|
+
validate(v, 'ref');
|
|
183
|
+
const o = v;
|
|
184
|
+
const args = o.args;
|
|
185
|
+
const parts = [];
|
|
186
|
+
for (const k of sortedKeys(args)) {
|
|
187
|
+
const a = args[k];
|
|
188
|
+
if (a === '*')
|
|
189
|
+
parts.push(`${k}=*`);
|
|
190
|
+
else if (isObject(a) && typeof a.value === 'boolean')
|
|
191
|
+
parts.push(`${k}=${a.value ? 'true' : 'false'}`);
|
|
192
|
+
else
|
|
193
|
+
parts.push(`${k}=${encodeValue(a.value)}`);
|
|
194
|
+
}
|
|
195
|
+
if (typeof o.asof === 'string')
|
|
196
|
+
parts.push(`asof=${encodeValue(o.asof)}`);
|
|
197
|
+
return `${SCHEME}${o.ns}/${o.fn}${parts.length ? `?${parts.join('&')}` : ''}`;
|
|
198
|
+
}
|
|
199
|
+
/** The HTTPS URL of a cell URI on mesh host `mesh` (SPEC 5.3). */
|
|
200
|
+
export function httpsUrl(uri, mesh) {
|
|
201
|
+
if (!uri.startsWith(SCHEME))
|
|
202
|
+
fail('E_PARSE_URI', 'not a cell URI', '$');
|
|
203
|
+
return `https://${mesh}/cell/${uri.slice(SCHEME.length)}`;
|
|
204
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Encode a well-formed string as UTF-8. Lone surrogates must have been rejected already. */
|
|
2
|
+
export declare function utf8Encode(s: string): Uint8Array;
|
|
3
|
+
/** Number of UTF-8 bytes in a well-formed string. */
|
|
4
|
+
export declare function utf8Length(s: string): number;
|
|
5
|
+
/**
|
|
6
|
+
* Decode strict UTF-8 (RFC 3629): no overlong forms, no surrogates, nothing above U+10FFFF,
|
|
7
|
+
* no truncated sequences. Returns null when the bytes are not UTF-8. A leading BOM is kept
|
|
8
|
+
* (as U+FEFF) so the caller can reject it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function utf8Decode(b: Uint8Array): string | null;
|
package/dist/esm/utf8.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Strict UTF-8 encoding and decoding, written out so results never depend on the host's
|
|
2
|
+
// TextDecoder (BOM handling, replacement characters) or its ICU build.
|
|
3
|
+
/** Encode a well-formed string as UTF-8. Lone surrogates must have been rejected already. */
|
|
4
|
+
export function utf8Encode(s) {
|
|
5
|
+
const out = [];
|
|
6
|
+
for (let i = 0; i < s.length; i++) {
|
|
7
|
+
let c = s.charCodeAt(i);
|
|
8
|
+
if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {
|
|
9
|
+
const d = s.charCodeAt(i + 1);
|
|
10
|
+
if (d >= 0xdc00 && d <= 0xdfff) {
|
|
11
|
+
c = 0x10000 + ((c - 0xd800) << 10) + (d - 0xdc00);
|
|
12
|
+
i++;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (c < 0x80)
|
|
16
|
+
out.push(c);
|
|
17
|
+
else if (c < 0x800)
|
|
18
|
+
out.push(0xc0 | (c >> 6), 0x80 | (c & 63));
|
|
19
|
+
else if (c < 0x10000)
|
|
20
|
+
out.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));
|
|
21
|
+
else
|
|
22
|
+
out.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 63), 0x80 | ((c >> 6) & 63), 0x80 | (c & 63));
|
|
23
|
+
}
|
|
24
|
+
return Uint8Array.from(out);
|
|
25
|
+
}
|
|
26
|
+
/** Number of UTF-8 bytes in a well-formed string. */
|
|
27
|
+
export function utf8Length(s) {
|
|
28
|
+
let n = 0;
|
|
29
|
+
for (let i = 0; i < s.length; i++) {
|
|
30
|
+
const c = s.charCodeAt(i);
|
|
31
|
+
if (c < 0x80)
|
|
32
|
+
n += 1;
|
|
33
|
+
else if (c < 0x800)
|
|
34
|
+
n += 2;
|
|
35
|
+
else if (c >= 0xd800 && c <= 0xdbff) {
|
|
36
|
+
n += 4;
|
|
37
|
+
i++;
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
n += 3;
|
|
41
|
+
}
|
|
42
|
+
return n;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Decode strict UTF-8 (RFC 3629): no overlong forms, no surrogates, nothing above U+10FFFF,
|
|
46
|
+
* no truncated sequences. Returns null when the bytes are not UTF-8. A leading BOM is kept
|
|
47
|
+
* (as U+FEFF) so the caller can reject it.
|
|
48
|
+
*/
|
|
49
|
+
export function utf8Decode(b) {
|
|
50
|
+
let out = '';
|
|
51
|
+
const parts = [];
|
|
52
|
+
for (let i = 0; i < b.length;) {
|
|
53
|
+
const x = b[i];
|
|
54
|
+
let cp;
|
|
55
|
+
let need;
|
|
56
|
+
let min;
|
|
57
|
+
if (x < 0x80) {
|
|
58
|
+
cp = x;
|
|
59
|
+
need = 0;
|
|
60
|
+
min = 0;
|
|
61
|
+
}
|
|
62
|
+
else if (x >= 0xc2 && x <= 0xdf) {
|
|
63
|
+
cp = x & 0x1f;
|
|
64
|
+
need = 1;
|
|
65
|
+
min = 0x80;
|
|
66
|
+
}
|
|
67
|
+
else if (x >= 0xe0 && x <= 0xef) {
|
|
68
|
+
cp = x & 0x0f;
|
|
69
|
+
need = 2;
|
|
70
|
+
min = 0x800;
|
|
71
|
+
}
|
|
72
|
+
else if (x >= 0xf0 && x <= 0xf4) {
|
|
73
|
+
cp = x & 0x07;
|
|
74
|
+
need = 3;
|
|
75
|
+
min = 0x10000;
|
|
76
|
+
}
|
|
77
|
+
else
|
|
78
|
+
return null;
|
|
79
|
+
for (let k = 1; k <= need; k++) {
|
|
80
|
+
const y = b[i + k];
|
|
81
|
+
if (y === undefined || (y & 0xc0) !== 0x80)
|
|
82
|
+
return null;
|
|
83
|
+
cp = (cp << 6) | (y & 0x3f);
|
|
84
|
+
}
|
|
85
|
+
if (cp < min || cp > 0x10ffff || (cp >= 0xd800 && cp <= 0xdfff))
|
|
86
|
+
return null;
|
|
87
|
+
out += String.fromCodePoint(cp);
|
|
88
|
+
if (out.length > 8192) {
|
|
89
|
+
parts.push(out);
|
|
90
|
+
out = '';
|
|
91
|
+
}
|
|
92
|
+
i += need + 1;
|
|
93
|
+
}
|
|
94
|
+
parts.push(out);
|
|
95
|
+
return parts.join('');
|
|
96
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type JsonObject, type JsonValue } from './json.js';
|
|
2
|
+
export type Kind = 'scalar' | 'cell' | 'ref' | 'function' | 'receipt' | 'jcs';
|
|
3
|
+
export declare const KINDS: readonly Kind[];
|
|
4
|
+
export declare function structSignature(v: JsonValue, path: string): void;
|
|
5
|
+
export declare function canonSignature(sig: JsonObject, path: string): void;
|
|
6
|
+
/** The return type named by a valid signature's `returns` (SPEC 10.1 step 7.4). */
|
|
7
|
+
export declare function returnType(sig: JsonObject): string;
|
|
8
|
+
/** Validate `v` as `kind` (steps 2-3; for receipts also step 4). Throws DatumeshError. */
|
|
9
|
+
export declare function validate(v: JsonValue, kind: Kind, path?: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* The unit of a cell's value (SPEC 7.1, units.md 3). Order: the cell (structure, canonical
|
|
12
|
+
* form), fn_hash against the descriptor (E_FN_HASH_MISMATCH), the descriptor (structure,
|
|
13
|
+
* canonical form), then substitution.
|
|
14
|
+
*/
|
|
15
|
+
export declare function cellUnit(desc: JsonValue, cell: JsonValue, fnHash: (d: JsonValue) => string): string | null;
|
|
16
|
+
/** Receipt step 2 only: true when the receipt has the right members and JSON types. */
|
|
17
|
+
export declare function receiptStructure(v: JsonValue): void;
|
|
18
|
+
/** Receipt steps 3 and 4, after receiptStructure has passed. */
|
|
19
|
+
export declare function receiptCanonicalAndConsistent(v: JsonValue): void;
|
|
20
|
+
/**
|
|
21
|
+
* Infer the kind of an object from its members when the caller gives none: a receipt has
|
|
22
|
+
* `sig`, `proto` or `computed_by`; a descriptor `signature` or `code`; a cell `fn_hash`; a cell
|
|
23
|
+
* reference `fn`, `ns` or `args`; a typed scalar `type` or `value`. Anything else is E_SCHEMA.
|
|
24
|
+
*/
|
|
25
|
+
export declare function inferKind(v: JsonValue): Exclude<Kind, 'jcs'>;
|