this.me 3.0.33 → 3.1.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 +12 -82
- package/dist/index.d.ts +1 -1
- package/dist/me.cjs +1 -8
- package/dist/me.es.js +707 -519
- package/dist/me.umd.js +1 -8
- package/dist/src/me.d.ts +3 -0
- package/dist/src/normalizeCall.d.ts +18 -0
- package/dist/src/types.d.ts +34 -0
- package/package.json +19 -9
- package/dist/src/postulate.d.ts +0 -46
package/dist/me.es.js
CHANGED
|
@@ -1,61 +1,121 @@
|
|
|
1
|
-
function ve(
|
|
2
|
-
return { __ptr:
|
|
1
|
+
function ve(l) {
|
|
2
|
+
return { __ptr: l };
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return !!
|
|
4
|
+
function N(l) {
|
|
5
|
+
return !!l && typeof l == "object" && typeof l.__ptr == "string" && l.__ptr.length > 0;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return { __id:
|
|
7
|
+
function be(l) {
|
|
8
|
+
return { __id: l };
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return !!
|
|
10
|
+
function Lt(l) {
|
|
11
|
+
return !!l && typeof l == "object" && typeof l.__id == "string" && l.__id.length > 0;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return !!
|
|
13
|
+
function me(l) {
|
|
14
|
+
return !!l && typeof l == "object" && typeof l.path == "string" && typeof l.hash == "string" && typeof l.timestamp == "number";
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
16
|
+
function C(l) {
|
|
17
|
+
return l.length === 0 ? { scope: [], leaf: null } : { scope: l.slice(0, -1), leaf: l[l.length - 1] };
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
if (
|
|
21
|
-
for (let e = 0; e <
|
|
22
|
-
if (
|
|
19
|
+
function Gt(l, n) {
|
|
20
|
+
if (n.length > l.length) return !1;
|
|
21
|
+
for (let e = 0; e < n.length; e++)
|
|
22
|
+
if (l[e] !== n[e]) return !1;
|
|
23
23
|
return !0;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
throw new Error(`Invalid username length: ${
|
|
29
|
-
if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$/.test(
|
|
25
|
+
function Ht(l) {
|
|
26
|
+
const n = l.trim().toLowerCase();
|
|
27
|
+
if (n.length < 3 || n.length > 63)
|
|
28
|
+
throw new Error(`Invalid username length: ${n.length}. Expected 3..63 characters.`);
|
|
29
|
+
if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$/.test(n))
|
|
30
30
|
throw new Error(
|
|
31
|
-
`Invalid username. Use only [a-z0-9-], and start/end with [a-z0-9]. Got: ${
|
|
31
|
+
`Invalid username. Use only [a-z0-9-], and start/end with [a-z0-9]. Got: ${l}`
|
|
32
32
|
);
|
|
33
|
-
if (
|
|
34
|
-
throw new Error(`Invalid username. "--" is not allowed. Got: ${
|
|
35
|
-
return
|
|
33
|
+
if (n.includes("--"))
|
|
34
|
+
throw new Error(`Invalid username. "--" is not allowed. Got: ${l}`);
|
|
35
|
+
return n;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return c && c.__esModule && Object.prototype.hasOwnProperty.call(c, "default") ? c.default : c;
|
|
37
|
+
function I(l, n) {
|
|
38
|
+
return l[n]?.kind ?? null;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function
|
|
52
|
-
|
|
40
|
+
function ke(l, n) {
|
|
41
|
+
if (l.length !== 1 || l[0] !== "+" || !Array.isArray(n) || n.length < 2) return null;
|
|
42
|
+
const i = String(n[0] ?? "").trim(), r = String(n[1] ?? "").trim();
|
|
43
|
+
return !i || !r || i === "+" ? null : { op: i, kind: r };
|
|
44
|
+
}
|
|
45
|
+
function Se(l, n, e) {
|
|
46
|
+
if (n.length === 0) return null;
|
|
47
|
+
const { scope: i, leaf: r } = C(n);
|
|
48
|
+
return !r || I(l, r) !== "secret" || typeof e != "string" ? null : { scopeKey: i.join(".") };
|
|
49
|
+
}
|
|
50
|
+
function Ae(l, n, e) {
|
|
51
|
+
if (n.length === 0) return null;
|
|
52
|
+
const { scope: i, leaf: r } = C(n);
|
|
53
|
+
return !r || I(l, r) !== "noise" || typeof e != "string" ? null : { scopeKey: i.join(".") };
|
|
54
|
+
}
|
|
55
|
+
function Be(l, n, e) {
|
|
56
|
+
if (n.length === 0) return null;
|
|
57
|
+
const { leaf: i } = C(n);
|
|
58
|
+
if (!i || I(l, i) !== "pointer" || typeof e != "string") return null;
|
|
59
|
+
const r = e.trim().replace(/^\./, "");
|
|
60
|
+
return r ? { targetPath: r } : null;
|
|
61
|
+
}
|
|
62
|
+
function _e(l, n, e) {
|
|
63
|
+
if (n.length === 1 && I(l, n[0]) === "identity")
|
|
64
|
+
return typeof e != "string" ? null : { id: Ht(e), targetPath: [] };
|
|
65
|
+
const { scope: i, leaf: r } = C(n);
|
|
66
|
+
return !r || I(l, r) !== "identity" || typeof e != "string" ? null : { id: Ht(e), targetPath: i };
|
|
67
|
+
}
|
|
68
|
+
function Pe(l, n, e) {
|
|
69
|
+
if (n.length === 0) return null;
|
|
70
|
+
const { scope: i, leaf: r } = C(n);
|
|
71
|
+
if (!r || I(l, r) !== "eval") return null;
|
|
72
|
+
if (typeof e == "function")
|
|
73
|
+
return { mode: "thunk", targetPath: i, thunk: e };
|
|
74
|
+
if (Array.isArray(e) && e.length >= 2) {
|
|
75
|
+
const u = String(e[0] ?? "").trim(), f = String(e[1] ?? "").trim();
|
|
76
|
+
return !u || !f ? null : { mode: "assign", targetPath: i, name: u, expr: f };
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
function we(l, n, e) {
|
|
81
|
+
if (n.length === 0) return null;
|
|
82
|
+
const { scope: i, leaf: r } = C(n);
|
|
83
|
+
if (!r || I(l, r) !== "query") return null;
|
|
84
|
+
let u = null, f;
|
|
85
|
+
if (Array.isArray(e) && e.length > 0)
|
|
86
|
+
Array.isArray(e[0]) && (e.length === 1 || typeof e[1] == "function") ? (u = e[0], f = typeof e[1] == "function" ? e[1] : void 0) : u = e;
|
|
87
|
+
else
|
|
88
|
+
return null;
|
|
89
|
+
if (!Array.isArray(u) || u.length === 0) return null;
|
|
90
|
+
const p = u.map((s) => String(s)).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
91
|
+
return p.length === 0 ? null : { targetPath: i, paths: p, fn: f };
|
|
92
|
+
}
|
|
93
|
+
function xe(l, n, e) {
|
|
94
|
+
if (n.length === 0) return null;
|
|
95
|
+
const { scope: i, leaf: r } = C(n);
|
|
96
|
+
if (!r || I(l, r) !== "remove") return null;
|
|
97
|
+
if (e == null)
|
|
98
|
+
return { targetPath: i };
|
|
99
|
+
if (typeof e == "string") {
|
|
100
|
+
const u = e.split(".").filter(Boolean);
|
|
101
|
+
return { targetPath: [...i, ...u] };
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
var Ce = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
106
|
+
function Oe(l) {
|
|
107
|
+
return l && l.__esModule && Object.prototype.hasOwnProperty.call(l, "default") ? l.default : l;
|
|
108
|
+
}
|
|
109
|
+
var Yt = { exports: {} };
|
|
110
|
+
var ce;
|
|
111
|
+
function Ee() {
|
|
112
|
+
return ce || (ce = 1, (function(l) {
|
|
53
113
|
(function() {
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
for (var
|
|
114
|
+
var n = "input is invalid type", e = "finalize already called", i = typeof window == "object", r = i ? window : {};
|
|
115
|
+
r.JS_SHA3_NO_WINDOW && (i = !1);
|
|
116
|
+
var u = !i && typeof self == "object", f = !r.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node;
|
|
117
|
+
f ? r = Ce : u && (r = self);
|
|
118
|
+
for (var p = !r.JS_SHA3_NO_COMMON_JS && !0 && l.exports, s = !r.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", h = "0123456789abcdef".split(""), k = [31, 7936, 2031616, 520093696], m = [4, 1024, 262144, 67108864], S = [1, 256, 65536, 16777216], B = [6, 1536, 393216, 100663296], A = [0, 8, 16, 24], x = [
|
|
59
119
|
1,
|
|
60
120
|
0,
|
|
61
121
|
32898,
|
|
@@ -104,269 +164,358 @@ function me() {
|
|
|
104
164
|
0,
|
|
105
165
|
2147516424,
|
|
106
166
|
2147483648
|
|
107
|
-
],
|
|
167
|
+
], O = [224, 256, 384, 512], E = [128, 256], M = ["hex", "buffer", "arrayBuffer", "array", "digest"], Xt = {
|
|
108
168
|
128: 168,
|
|
109
169
|
256: 136
|
|
110
|
-
},
|
|
170
|
+
}, se = r.JS_SHA3_NO_NODE_JS || !Array.isArray ? function(t) {
|
|
111
171
|
return Object.prototype.toString.call(t) === "[object Array]";
|
|
112
|
-
} : Array.isArray,
|
|
172
|
+
} : Array.isArray, de = s && (r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) ? function(t) {
|
|
113
173
|
return typeof t == "object" && t.buffer && t.buffer.constructor === ArrayBuffer;
|
|
114
|
-
} : ArrayBuffer.isView,
|
|
115
|
-
var
|
|
116
|
-
if (
|
|
174
|
+
} : ArrayBuffer.isView, Ut = function(t) {
|
|
175
|
+
var o = typeof t;
|
|
176
|
+
if (o === "string")
|
|
117
177
|
return [t, !0];
|
|
118
|
-
if (
|
|
119
|
-
throw new Error(
|
|
120
|
-
if (
|
|
178
|
+
if (o !== "object" || t === null)
|
|
179
|
+
throw new Error(n);
|
|
180
|
+
if (s && t.constructor === ArrayBuffer)
|
|
121
181
|
return [new Uint8Array(t), !1];
|
|
122
|
-
if (!
|
|
123
|
-
throw new Error(
|
|
182
|
+
if (!se(t) && !de(t))
|
|
183
|
+
throw new Error(n);
|
|
124
184
|
return [t, !1];
|
|
125
|
-
},
|
|
126
|
-
return
|
|
127
|
-
},
|
|
128
|
-
for (var
|
|
129
|
-
|
|
130
|
-
return
|
|
131
|
-
},
|
|
132
|
-
return function(
|
|
133
|
-
return new
|
|
185
|
+
}, te = function(t) {
|
|
186
|
+
return Ut(t)[0].length === 0;
|
|
187
|
+
}, Vt = function(t) {
|
|
188
|
+
for (var o = [], c = 0; c < t.length; ++c)
|
|
189
|
+
o[c] = t[c];
|
|
190
|
+
return o;
|
|
191
|
+
}, ee = function(t, o, c) {
|
|
192
|
+
return function(a) {
|
|
193
|
+
return new P(t, o, t).update(a)[c]();
|
|
134
194
|
};
|
|
135
|
-
},
|
|
136
|
-
return function(
|
|
137
|
-
return new
|
|
195
|
+
}, ne = function(t, o, c) {
|
|
196
|
+
return function(a, d) {
|
|
197
|
+
return new P(t, o, d).update(a)[c]();
|
|
138
198
|
};
|
|
139
|
-
},
|
|
140
|
-
return function(
|
|
141
|
-
return
|
|
199
|
+
}, re = function(t, o, c) {
|
|
200
|
+
return function(a, d, y, v) {
|
|
201
|
+
return F["cshake" + t].update(a, d, y, v)[c]();
|
|
142
202
|
};
|
|
143
|
-
},
|
|
144
|
-
return function(
|
|
145
|
-
return
|
|
203
|
+
}, ie = function(t, o, c) {
|
|
204
|
+
return function(a, d, y, v) {
|
|
205
|
+
return F["kmac" + t].update(a, d, y, v)[c]();
|
|
146
206
|
};
|
|
147
|
-
},
|
|
148
|
-
for (var
|
|
149
|
-
var
|
|
150
|
-
t[
|
|
207
|
+
}, W = function(t, o, c, a) {
|
|
208
|
+
for (var d = 0; d < M.length; ++d) {
|
|
209
|
+
var y = M[d];
|
|
210
|
+
t[y] = o(c, a, y);
|
|
151
211
|
}
|
|
152
212
|
return t;
|
|
153
|
-
},
|
|
154
|
-
var
|
|
155
|
-
return
|
|
156
|
-
return new
|
|
157
|
-
},
|
|
158
|
-
return
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
var
|
|
162
|
-
return
|
|
163
|
-
return new
|
|
164
|
-
},
|
|
165
|
-
return
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
var
|
|
169
|
-
return
|
|
170
|
-
return
|
|
171
|
-
},
|
|
172
|
-
return
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
var
|
|
176
|
-
return
|
|
177
|
-
return new
|
|
178
|
-
},
|
|
179
|
-
return
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
{ name: "keccak", padding:
|
|
183
|
-
{ name: "sha3", padding:
|
|
184
|
-
{ name: "shake", padding:
|
|
185
|
-
{ name: "cshake", padding:
|
|
186
|
-
{ name: "kmac", padding:
|
|
187
|
-
],
|
|
188
|
-
for (var
|
|
189
|
-
var
|
|
190
|
-
if (
|
|
191
|
-
var
|
|
192
|
-
|
|
213
|
+
}, oe = function(t, o) {
|
|
214
|
+
var c = ee(t, o, "hex");
|
|
215
|
+
return c.create = function() {
|
|
216
|
+
return new P(t, o, t);
|
|
217
|
+
}, c.update = function(a) {
|
|
218
|
+
return c.create().update(a);
|
|
219
|
+
}, W(c, ee, t, o);
|
|
220
|
+
}, pe = function(t, o) {
|
|
221
|
+
var c = ne(t, o, "hex");
|
|
222
|
+
return c.create = function(a) {
|
|
223
|
+
return new P(t, o, a);
|
|
224
|
+
}, c.update = function(a, d) {
|
|
225
|
+
return c.create(d).update(a);
|
|
226
|
+
}, W(c, ne, t, o);
|
|
227
|
+
}, ye = function(t, o) {
|
|
228
|
+
var c = Xt[t], a = re(t, o, "hex");
|
|
229
|
+
return a.create = function(d, y, v) {
|
|
230
|
+
return te(y) && te(v) ? F["shake" + t].create(d) : new P(t, o, d).bytepad([y, v], c);
|
|
231
|
+
}, a.update = function(d, y, v, g) {
|
|
232
|
+
return a.create(y, v, g).update(d);
|
|
233
|
+
}, W(a, re, t, o);
|
|
234
|
+
}, ge = function(t, o) {
|
|
235
|
+
var c = Xt[t], a = ie(t, o, "hex");
|
|
236
|
+
return a.create = function(d, y, v) {
|
|
237
|
+
return new $t(t, o, y).bytepad(["KMAC", v], c).bytepad([d], c);
|
|
238
|
+
}, a.update = function(d, y, v, g) {
|
|
239
|
+
return a.create(d, v, g).update(y);
|
|
240
|
+
}, W(a, ie, t, o);
|
|
241
|
+
}, le = [
|
|
242
|
+
{ name: "keccak", padding: S, bits: O, createMethod: oe },
|
|
243
|
+
{ name: "sha3", padding: B, bits: O, createMethod: oe },
|
|
244
|
+
{ name: "shake", padding: k, bits: E, createMethod: pe },
|
|
245
|
+
{ name: "cshake", padding: m, bits: E, createMethod: ye },
|
|
246
|
+
{ name: "kmac", padding: m, bits: E, createMethod: ge }
|
|
247
|
+
], F = {}, T = [], K = 0; K < le.length; ++K)
|
|
248
|
+
for (var j = le[K], J = j.bits, D = 0; D < J.length; ++D) {
|
|
249
|
+
var qt = j.name + "_" + J[D];
|
|
250
|
+
if (T.push(qt), F[qt] = j.createMethod(J[D], j.padding), j.name !== "sha3") {
|
|
251
|
+
var ue = j.name + J[D];
|
|
252
|
+
T.push(ue), F[ue] = F[qt];
|
|
193
253
|
}
|
|
194
254
|
}
|
|
195
|
-
function
|
|
196
|
-
this.blocks = [], this.s = [], this.padding =
|
|
197
|
-
for (var
|
|
198
|
-
this.s[
|
|
255
|
+
function P(t, o, c) {
|
|
256
|
+
this.blocks = [], this.s = [], this.padding = o, this.outputBits = c, this.reset = !0, this.finalized = !1, this.block = 0, this.start = 0, this.blockCount = 1600 - (t << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = c >> 5, this.extraBytes = (c & 31) >> 3;
|
|
257
|
+
for (var a = 0; a < 50; ++a)
|
|
258
|
+
this.s[a] = 0;
|
|
199
259
|
}
|
|
200
|
-
|
|
260
|
+
P.prototype.update = function(t) {
|
|
201
261
|
if (this.finalized)
|
|
202
262
|
throw new Error(e);
|
|
203
|
-
var
|
|
204
|
-
t =
|
|
205
|
-
for (var
|
|
263
|
+
var o = Ut(t);
|
|
264
|
+
t = o[0];
|
|
265
|
+
for (var c = o[1], a = this.blocks, d = this.byteCount, y = t.length, v = this.blockCount, g = 0, w = this.s, b, _; g < y; ) {
|
|
206
266
|
if (this.reset)
|
|
207
|
-
for (this.reset = !1,
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
for (
|
|
211
|
-
|
|
267
|
+
for (this.reset = !1, a[0] = this.block, b = 1; b < v + 1; ++b)
|
|
268
|
+
a[b] = 0;
|
|
269
|
+
if (c)
|
|
270
|
+
for (b = this.start; g < y && b < d; ++g)
|
|
271
|
+
_ = t.charCodeAt(g), _ < 128 ? a[b >> 2] |= _ << A[b++ & 3] : _ < 2048 ? (a[b >> 2] |= (192 | _ >> 6) << A[b++ & 3], a[b >> 2] |= (128 | _ & 63) << A[b++ & 3]) : _ < 55296 || _ >= 57344 ? (a[b >> 2] |= (224 | _ >> 12) << A[b++ & 3], a[b >> 2] |= (128 | _ >> 6 & 63) << A[b++ & 3], a[b >> 2] |= (128 | _ & 63) << A[b++ & 3]) : (_ = 65536 + ((_ & 1023) << 10 | t.charCodeAt(++g) & 1023), a[b >> 2] |= (240 | _ >> 18) << A[b++ & 3], a[b >> 2] |= (128 | _ >> 12 & 63) << A[b++ & 3], a[b >> 2] |= (128 | _ >> 6 & 63) << A[b++ & 3], a[b >> 2] |= (128 | _ & 63) << A[b++ & 3]);
|
|
212
272
|
else
|
|
213
|
-
for (
|
|
214
|
-
|
|
215
|
-
if (this.lastByteIndex =
|
|
216
|
-
for (this.start =
|
|
217
|
-
|
|
218
|
-
|
|
273
|
+
for (b = this.start; g < y && b < d; ++g)
|
|
274
|
+
a[b >> 2] |= t[g] << A[b++ & 3];
|
|
275
|
+
if (this.lastByteIndex = b, b >= d) {
|
|
276
|
+
for (this.start = b - d, this.block = a[v], b = 0; b < v; ++b)
|
|
277
|
+
w[b] ^= a[b];
|
|
278
|
+
z(w), this.reset = !0;
|
|
219
279
|
} else
|
|
220
|
-
this.start =
|
|
280
|
+
this.start = b;
|
|
221
281
|
}
|
|
222
282
|
return this;
|
|
223
|
-
},
|
|
224
|
-
var
|
|
225
|
-
for (t = t >> 8,
|
|
226
|
-
|
|
227
|
-
return
|
|
228
|
-
},
|
|
229
|
-
var
|
|
230
|
-
t =
|
|
231
|
-
var
|
|
232
|
-
if (
|
|
233
|
-
for (var
|
|
234
|
-
var
|
|
235
|
-
|
|
283
|
+
}, P.prototype.encode = function(t, o) {
|
|
284
|
+
var c = t & 255, a = 1, d = [c];
|
|
285
|
+
for (t = t >> 8, c = t & 255; c > 0; )
|
|
286
|
+
d.unshift(c), t = t >> 8, c = t & 255, ++a;
|
|
287
|
+
return o ? d.push(a) : d.unshift(a), this.update(d), d.length;
|
|
288
|
+
}, P.prototype.encodeString = function(t) {
|
|
289
|
+
var o = Ut(t);
|
|
290
|
+
t = o[0];
|
|
291
|
+
var c = o[1], a = 0, d = t.length;
|
|
292
|
+
if (c)
|
|
293
|
+
for (var y = 0; y < t.length; ++y) {
|
|
294
|
+
var v = t.charCodeAt(y);
|
|
295
|
+
v < 128 ? a += 1 : v < 2048 ? a += 2 : v < 55296 || v >= 57344 ? a += 3 : (v = 65536 + ((v & 1023) << 10 | t.charCodeAt(++y) & 1023), a += 4);
|
|
236
296
|
}
|
|
237
297
|
else
|
|
238
|
-
|
|
239
|
-
return
|
|
240
|
-
},
|
|
241
|
-
for (var
|
|
242
|
-
|
|
243
|
-
var
|
|
244
|
-
return
|
|
245
|
-
},
|
|
298
|
+
a = d;
|
|
299
|
+
return a += this.encode(a * 8), this.update(t), a;
|
|
300
|
+
}, P.prototype.bytepad = function(t, o) {
|
|
301
|
+
for (var c = this.encode(o), a = 0; a < t.length; ++a)
|
|
302
|
+
c += this.encodeString(t[a]);
|
|
303
|
+
var d = (o - c % o) % o, y = [];
|
|
304
|
+
return y.length = d, this.update(y), this;
|
|
305
|
+
}, P.prototype.finalize = function() {
|
|
246
306
|
if (!this.finalized) {
|
|
247
307
|
this.finalized = !0;
|
|
248
|
-
var t = this.blocks,
|
|
249
|
-
if (t[
|
|
250
|
-
for (t[0] = t[
|
|
251
|
-
t[
|
|
252
|
-
for (t[
|
|
253
|
-
|
|
254
|
-
|
|
308
|
+
var t = this.blocks, o = this.lastByteIndex, c = this.blockCount, a = this.s;
|
|
309
|
+
if (t[o >> 2] |= this.padding[o & 3], this.lastByteIndex === this.byteCount)
|
|
310
|
+
for (t[0] = t[c], o = 1; o < c + 1; ++o)
|
|
311
|
+
t[o] = 0;
|
|
312
|
+
for (t[c - 1] |= 2147483648, o = 0; o < c; ++o)
|
|
313
|
+
a[o] ^= t[o];
|
|
314
|
+
z(a);
|
|
255
315
|
}
|
|
256
|
-
},
|
|
316
|
+
}, P.prototype.toString = P.prototype.hex = function() {
|
|
257
317
|
this.finalize();
|
|
258
|
-
for (var t = this.blockCount,
|
|
259
|
-
for (
|
|
260
|
-
|
|
261
|
-
|
|
318
|
+
for (var t = this.blockCount, o = this.s, c = this.outputBlocks, a = this.extraBytes, d = 0, y = 0, v = "", g; y < c; ) {
|
|
319
|
+
for (d = 0; d < t && y < c; ++d, ++y)
|
|
320
|
+
g = o[d], v += h[g >> 4 & 15] + h[g & 15] + h[g >> 12 & 15] + h[g >> 8 & 15] + h[g >> 20 & 15] + h[g >> 16 & 15] + h[g >> 28 & 15] + h[g >> 24 & 15];
|
|
321
|
+
y % t === 0 && (o = Vt(o), z(o), d = 0);
|
|
262
322
|
}
|
|
263
|
-
return
|
|
264
|
-
},
|
|
323
|
+
return a && (g = o[d], v += h[g >> 4 & 15] + h[g & 15], a > 1 && (v += h[g >> 12 & 15] + h[g >> 8 & 15]), a > 2 && (v += h[g >> 20 & 15] + h[g >> 16 & 15])), v;
|
|
324
|
+
}, P.prototype.arrayBuffer = function() {
|
|
265
325
|
this.finalize();
|
|
266
|
-
var t = this.blockCount,
|
|
267
|
-
|
|
268
|
-
for (var
|
|
269
|
-
for (
|
|
270
|
-
|
|
271
|
-
|
|
326
|
+
var t = this.blockCount, o = this.s, c = this.outputBlocks, a = this.extraBytes, d = 0, y = 0, v = this.outputBits >> 3, g;
|
|
327
|
+
a ? g = new ArrayBuffer(c + 1 << 2) : g = new ArrayBuffer(v);
|
|
328
|
+
for (var w = new Uint32Array(g); y < c; ) {
|
|
329
|
+
for (d = 0; d < t && y < c; ++d, ++y)
|
|
330
|
+
w[y] = o[d];
|
|
331
|
+
y % t === 0 && (o = Vt(o), z(o));
|
|
272
332
|
}
|
|
273
|
-
return
|
|
274
|
-
},
|
|
333
|
+
return a && (w[y] = o[d], g = g.slice(0, v)), g;
|
|
334
|
+
}, P.prototype.buffer = P.prototype.arrayBuffer, P.prototype.digest = P.prototype.array = function() {
|
|
275
335
|
this.finalize();
|
|
276
|
-
for (var t = this.blockCount,
|
|
277
|
-
for (
|
|
278
|
-
|
|
279
|
-
|
|
336
|
+
for (var t = this.blockCount, o = this.s, c = this.outputBlocks, a = this.extraBytes, d = 0, y = 0, v = [], g, w; y < c; ) {
|
|
337
|
+
for (d = 0; d < t && y < c; ++d, ++y)
|
|
338
|
+
g = y << 2, w = o[d], v[g] = w & 255, v[g + 1] = w >> 8 & 255, v[g + 2] = w >> 16 & 255, v[g + 3] = w >> 24 & 255;
|
|
339
|
+
y % t === 0 && (o = Vt(o), z(o));
|
|
280
340
|
}
|
|
281
|
-
return
|
|
341
|
+
return a && (g = y << 2, w = o[d], v[g] = w & 255, a > 1 && (v[g + 1] = w >> 8 & 255), a > 2 && (v[g + 2] = w >> 16 & 255)), v;
|
|
282
342
|
};
|
|
283
|
-
function
|
|
284
|
-
|
|
343
|
+
function $t(t, o, c) {
|
|
344
|
+
P.call(this, t, o, c);
|
|
285
345
|
}
|
|
286
|
-
|
|
287
|
-
return this.encode(this.outputBits, !0),
|
|
346
|
+
$t.prototype = new P(), $t.prototype.finalize = function() {
|
|
347
|
+
return this.encode(this.outputBits, !0), P.prototype.finalize.call(this);
|
|
288
348
|
};
|
|
289
|
-
var
|
|
290
|
-
var
|
|
291
|
-
for (
|
|
292
|
-
|
|
349
|
+
var z = function(t) {
|
|
350
|
+
var o, c, a, d, y, v, g, w, b, _, H, U, V, q, $, L, G, Y, Q, Z, X, tt, et, nt, rt, it, ot, lt, ut, ct, at, ft, ht, st, dt, pt, yt, gt, vt, bt, mt, kt, St, At, Bt, _t, Pt, wt, xt, Ct, Ot, Et, Ft, Kt, It, jt, Nt, Mt, Tt, Dt, zt, Rt, Wt;
|
|
351
|
+
for (a = 0; a < 48; a += 2)
|
|
352
|
+
d = t[0] ^ t[10] ^ t[20] ^ t[30] ^ t[40], y = t[1] ^ t[11] ^ t[21] ^ t[31] ^ t[41], v = t[2] ^ t[12] ^ t[22] ^ t[32] ^ t[42], g = t[3] ^ t[13] ^ t[23] ^ t[33] ^ t[43], w = t[4] ^ t[14] ^ t[24] ^ t[34] ^ t[44], b = t[5] ^ t[15] ^ t[25] ^ t[35] ^ t[45], _ = t[6] ^ t[16] ^ t[26] ^ t[36] ^ t[46], H = t[7] ^ t[17] ^ t[27] ^ t[37] ^ t[47], U = t[8] ^ t[18] ^ t[28] ^ t[38] ^ t[48], V = t[9] ^ t[19] ^ t[29] ^ t[39] ^ t[49], o = U ^ (v << 1 | g >>> 31), c = V ^ (g << 1 | v >>> 31), t[0] ^= o, t[1] ^= c, t[10] ^= o, t[11] ^= c, t[20] ^= o, t[21] ^= c, t[30] ^= o, t[31] ^= c, t[40] ^= o, t[41] ^= c, o = d ^ (w << 1 | b >>> 31), c = y ^ (b << 1 | w >>> 31), t[2] ^= o, t[3] ^= c, t[12] ^= o, t[13] ^= c, t[22] ^= o, t[23] ^= c, t[32] ^= o, t[33] ^= c, t[42] ^= o, t[43] ^= c, o = v ^ (_ << 1 | H >>> 31), c = g ^ (H << 1 | _ >>> 31), t[4] ^= o, t[5] ^= c, t[14] ^= o, t[15] ^= c, t[24] ^= o, t[25] ^= c, t[34] ^= o, t[35] ^= c, t[44] ^= o, t[45] ^= c, o = w ^ (U << 1 | V >>> 31), c = b ^ (V << 1 | U >>> 31), t[6] ^= o, t[7] ^= c, t[16] ^= o, t[17] ^= c, t[26] ^= o, t[27] ^= c, t[36] ^= o, t[37] ^= c, t[46] ^= o, t[47] ^= c, o = _ ^ (d << 1 | y >>> 31), c = H ^ (y << 1 | d >>> 31), t[8] ^= o, t[9] ^= c, t[18] ^= o, t[19] ^= c, t[28] ^= o, t[29] ^= c, t[38] ^= o, t[39] ^= c, t[48] ^= o, t[49] ^= c, q = t[0], $ = t[1], _t = t[11] << 4 | t[10] >>> 28, Pt = t[10] << 4 | t[11] >>> 28, lt = t[20] << 3 | t[21] >>> 29, ut = t[21] << 3 | t[20] >>> 29, Dt = t[31] << 9 | t[30] >>> 23, zt = t[30] << 9 | t[31] >>> 23, kt = t[40] << 18 | t[41] >>> 14, St = t[41] << 18 | t[40] >>> 14, st = t[2] << 1 | t[3] >>> 31, dt = t[3] << 1 | t[2] >>> 31, L = t[13] << 12 | t[12] >>> 20, G = t[12] << 12 | t[13] >>> 20, wt = t[22] << 10 | t[23] >>> 22, xt = t[23] << 10 | t[22] >>> 22, ct = t[33] << 13 | t[32] >>> 19, at = t[32] << 13 | t[33] >>> 19, Rt = t[42] << 2 | t[43] >>> 30, Wt = t[43] << 2 | t[42] >>> 30, Kt = t[5] << 30 | t[4] >>> 2, It = t[4] << 30 | t[5] >>> 2, pt = t[14] << 6 | t[15] >>> 26, yt = t[15] << 6 | t[14] >>> 26, Y = t[25] << 11 | t[24] >>> 21, Q = t[24] << 11 | t[25] >>> 21, Ct = t[34] << 15 | t[35] >>> 17, Ot = t[35] << 15 | t[34] >>> 17, ft = t[45] << 29 | t[44] >>> 3, ht = t[44] << 29 | t[45] >>> 3, nt = t[6] << 28 | t[7] >>> 4, rt = t[7] << 28 | t[6] >>> 4, jt = t[17] << 23 | t[16] >>> 9, Nt = t[16] << 23 | t[17] >>> 9, gt = t[26] << 25 | t[27] >>> 7, vt = t[27] << 25 | t[26] >>> 7, Z = t[36] << 21 | t[37] >>> 11, X = t[37] << 21 | t[36] >>> 11, Et = t[47] << 24 | t[46] >>> 8, Ft = t[46] << 24 | t[47] >>> 8, At = t[8] << 27 | t[9] >>> 5, Bt = t[9] << 27 | t[8] >>> 5, it = t[18] << 20 | t[19] >>> 12, ot = t[19] << 20 | t[18] >>> 12, Mt = t[29] << 7 | t[28] >>> 25, Tt = t[28] << 7 | t[29] >>> 25, bt = t[38] << 8 | t[39] >>> 24, mt = t[39] << 8 | t[38] >>> 24, tt = t[48] << 14 | t[49] >>> 18, et = t[49] << 14 | t[48] >>> 18, t[0] = q ^ ~L & Y, t[1] = $ ^ ~G & Q, t[10] = nt ^ ~it & lt, t[11] = rt ^ ~ot & ut, t[20] = st ^ ~pt & gt, t[21] = dt ^ ~yt & vt, t[30] = At ^ ~_t & wt, t[31] = Bt ^ ~Pt & xt, t[40] = Kt ^ ~jt & Mt, t[41] = It ^ ~Nt & Tt, t[2] = L ^ ~Y & Z, t[3] = G ^ ~Q & X, t[12] = it ^ ~lt & ct, t[13] = ot ^ ~ut & at, t[22] = pt ^ ~gt & bt, t[23] = yt ^ ~vt & mt, t[32] = _t ^ ~wt & Ct, t[33] = Pt ^ ~xt & Ot, t[42] = jt ^ ~Mt & Dt, t[43] = Nt ^ ~Tt & zt, t[4] = Y ^ ~Z & tt, t[5] = Q ^ ~X & et, t[14] = lt ^ ~ct & ft, t[15] = ut ^ ~at & ht, t[24] = gt ^ ~bt & kt, t[25] = vt ^ ~mt & St, t[34] = wt ^ ~Ct & Et, t[35] = xt ^ ~Ot & Ft, t[44] = Mt ^ ~Dt & Rt, t[45] = Tt ^ ~zt & Wt, t[6] = Z ^ ~tt & q, t[7] = X ^ ~et & $, t[16] = ct ^ ~ft & nt, t[17] = at ^ ~ht & rt, t[26] = bt ^ ~kt & st, t[27] = mt ^ ~St & dt, t[36] = Ct ^ ~Et & At, t[37] = Ot ^ ~Ft & Bt, t[46] = Dt ^ ~Rt & Kt, t[47] = zt ^ ~Wt & It, t[8] = tt ^ ~q & L, t[9] = et ^ ~$ & G, t[18] = ft ^ ~nt & it, t[19] = ht ^ ~rt & ot, t[28] = kt ^ ~st & pt, t[29] = St ^ ~dt & yt, t[38] = Et ^ ~At & _t, t[39] = Ft ^ ~Bt & Pt, t[48] = Rt ^ ~Kt & jt, t[49] = Wt ^ ~It & Nt, t[0] ^= x[a], t[1] ^= x[a + 1];
|
|
293
353
|
};
|
|
294
|
-
if (
|
|
295
|
-
|
|
354
|
+
if (p)
|
|
355
|
+
l.exports = F;
|
|
296
356
|
else
|
|
297
|
-
for (
|
|
298
|
-
|
|
357
|
+
for (K = 0; K < T.length; ++K)
|
|
358
|
+
r[T[K]] = F[T[K]];
|
|
299
359
|
})();
|
|
300
|
-
})(
|
|
360
|
+
})(Yt)), Yt.exports;
|
|
301
361
|
}
|
|
302
|
-
var
|
|
303
|
-
const
|
|
304
|
-
function
|
|
305
|
-
return new TextEncoder().encode(
|
|
362
|
+
var Fe = Ee();
|
|
363
|
+
const Ke = /* @__PURE__ */ Oe(Fe), { keccak256: fe } = Ke;
|
|
364
|
+
function Zt(l) {
|
|
365
|
+
return new TextEncoder().encode(l);
|
|
306
366
|
}
|
|
307
|
-
function
|
|
308
|
-
const
|
|
309
|
-
for (let
|
|
310
|
-
e[
|
|
367
|
+
function Ie(l) {
|
|
368
|
+
const n = l.startsWith("0x") ? l.slice(2) : l, e = new Uint8Array(n.length / 2);
|
|
369
|
+
for (let i = 0; i < e.length; i++)
|
|
370
|
+
e[i] = parseInt(n.substring(i * 2, i * 2 + 2), 16);
|
|
311
371
|
return e;
|
|
312
372
|
}
|
|
313
|
-
function
|
|
314
|
-
let
|
|
315
|
-
for (let e = 0; e <
|
|
316
|
-
|
|
317
|
-
return "0x" +
|
|
373
|
+
function je(l) {
|
|
374
|
+
let n = "";
|
|
375
|
+
for (let e = 0; e < l.length; e++)
|
|
376
|
+
n += l[e].toString(16).padStart(2, "0");
|
|
377
|
+
return "0x" + n;
|
|
318
378
|
}
|
|
319
|
-
function
|
|
320
|
-
const
|
|
321
|
-
for (let
|
|
322
|
-
|
|
323
|
-
return
|
|
379
|
+
function Qt(l, n, e) {
|
|
380
|
+
const i = JSON.stringify(l), r = Zt(i), u = fe(n + ":" + e.join(".")), f = Zt(u), p = new Uint8Array(r.length);
|
|
381
|
+
for (let s = 0; s < r.length; s++)
|
|
382
|
+
p[s] = r[s] ^ f[s % f.length];
|
|
383
|
+
return je(p);
|
|
324
384
|
}
|
|
325
|
-
function
|
|
385
|
+
function Jt(l, n, e) {
|
|
326
386
|
try {
|
|
327
|
-
const
|
|
328
|
-
for (let
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
return JSON.parse(
|
|
387
|
+
const i = Ie(l), r = fe(n + ":" + e.join(".")), u = Zt(r), f = new Uint8Array(i.length);
|
|
388
|
+
for (let s = 0; s < i.length; s++)
|
|
389
|
+
f[s] = i[s] ^ u[s % u.length];
|
|
390
|
+
const p = new TextDecoder().decode(f);
|
|
391
|
+
return JSON.parse(p);
|
|
332
392
|
} catch {
|
|
333
393
|
return null;
|
|
334
394
|
}
|
|
335
395
|
}
|
|
336
|
-
function
|
|
337
|
-
if (typeof
|
|
338
|
-
const
|
|
339
|
-
return
|
|
396
|
+
function Ne(l) {
|
|
397
|
+
if (typeof l != "string" || !l.startsWith("0x")) return !1;
|
|
398
|
+
const n = l.slice(2);
|
|
399
|
+
return n.length < 2 || n.length % 2 !== 0 ? !1 : /^[0-9a-fA-F]+$/.test(n);
|
|
340
400
|
}
|
|
341
|
-
function
|
|
342
|
-
if (
|
|
401
|
+
function Me(l, n, e) {
|
|
402
|
+
if (n.length === 0) {
|
|
343
403
|
if (e.length === 1 && typeof e[0] == "string") {
|
|
344
|
-
const
|
|
345
|
-
if (
|
|
346
|
-
const
|
|
347
|
-
return
|
|
404
|
+
const k = e[0].trim(), m = k.startsWith("_") || k.startsWith("~") || k.startsWith("@"), S = k.includes("."), B = /^[a-zA-Z][a-zA-Z0-9_-]*$/.test(k);
|
|
405
|
+
if (S || m || B) {
|
|
406
|
+
const A = k.split(".").filter(Boolean);
|
|
407
|
+
return l.readPath(A);
|
|
348
408
|
}
|
|
349
409
|
}
|
|
350
410
|
if (e.length === 0)
|
|
351
|
-
return
|
|
352
|
-
const
|
|
353
|
-
return
|
|
411
|
+
return l.createProxy([]);
|
|
412
|
+
const s = l.normalizeArgs(e), h = l.postulate([], s);
|
|
413
|
+
return h !== void 0 ? h : l.createProxy([]);
|
|
414
|
+
}
|
|
415
|
+
const i = l.normalizeArgs(e), r = l.postulate(n, i), { scope: u, leaf: f } = l.splitPath(n), p = f ? l.opKind(f) : null;
|
|
416
|
+
if (l.isThought(r)) {
|
|
417
|
+
const s = p ? u : n;
|
|
418
|
+
return l.createProxy(s);
|
|
419
|
+
}
|
|
420
|
+
return r !== void 0 ? r : l.createProxy(n);
|
|
421
|
+
}
|
|
422
|
+
function Te(l, n, e = {}) {
|
|
423
|
+
const { path: i, expression: r } = n, u = ke(i, r);
|
|
424
|
+
if (u)
|
|
425
|
+
return {
|
|
426
|
+
kind: "return",
|
|
427
|
+
value: {
|
|
428
|
+
define: u
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
const f = Se(l, i, r);
|
|
432
|
+
if (f)
|
|
433
|
+
return {
|
|
434
|
+
kind: "commit",
|
|
435
|
+
instructions: [{ path: f.scopeKey ? f.scopeKey.split(".").filter(Boolean) : [], op: "secret", value: r }]
|
|
436
|
+
};
|
|
437
|
+
const p = Ae(l, i, r);
|
|
438
|
+
if (p)
|
|
439
|
+
return {
|
|
440
|
+
kind: "commit",
|
|
441
|
+
instructions: [{ path: p.scopeKey ? p.scopeKey.split(".").filter(Boolean) : [], op: "noise", value: r }]
|
|
442
|
+
};
|
|
443
|
+
const s = Be(l, i, r);
|
|
444
|
+
if (s) {
|
|
445
|
+
const { scope: B } = C(i);
|
|
446
|
+
return {
|
|
447
|
+
kind: "commit",
|
|
448
|
+
instructions: [{ path: B, op: "ptr", value: ve(s.targetPath) }]
|
|
449
|
+
};
|
|
354
450
|
}
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
357
|
-
|
|
358
|
-
|
|
451
|
+
const h = _e(l, i, r);
|
|
452
|
+
if (h)
|
|
453
|
+
return {
|
|
454
|
+
kind: "commit",
|
|
455
|
+
instructions: [{ path: h.targetPath, op: "id", value: be(h.id) }]
|
|
456
|
+
};
|
|
457
|
+
const k = xe(l, i, r);
|
|
458
|
+
if (k)
|
|
459
|
+
return {
|
|
460
|
+
kind: "commit",
|
|
461
|
+
instructions: [{ path: k.targetPath, op: "remove", value: "-" }]
|
|
462
|
+
};
|
|
463
|
+
const m = Pe(l, i, r);
|
|
464
|
+
if (m) {
|
|
465
|
+
if (m.mode === "assign")
|
|
466
|
+
return {
|
|
467
|
+
kind: "commit",
|
|
468
|
+
instructions: [
|
|
469
|
+
{
|
|
470
|
+
path: [...m.targetPath, m.name],
|
|
471
|
+
op: "derive",
|
|
472
|
+
value: {
|
|
473
|
+
kind: "expr",
|
|
474
|
+
source: m.expr
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
]
|
|
478
|
+
};
|
|
479
|
+
if (!e.evaluateThunk)
|
|
480
|
+
throw new Error('Non-serializable derivation: "=" thunk requires `evaluateThunk` or serializable DNA.');
|
|
481
|
+
const B = e.evaluateThunk(m.thunk);
|
|
482
|
+
return m.targetPath.length === 0 ? { kind: "return", value: B } : {
|
|
483
|
+
kind: "commit",
|
|
484
|
+
instructions: [{ path: m.targetPath, op: "derive", value: B }]
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
const S = we(l, i, r);
|
|
488
|
+
if (S) {
|
|
489
|
+
if (!e.readPath)
|
|
490
|
+
return {
|
|
491
|
+
kind: "commit",
|
|
492
|
+
instructions: [
|
|
493
|
+
{
|
|
494
|
+
path: S.targetPath,
|
|
495
|
+
op: "query",
|
|
496
|
+
value: { paths: S.paths }
|
|
497
|
+
}
|
|
498
|
+
]
|
|
499
|
+
};
|
|
500
|
+
const B = S.paths.map((x) => e.readPath(x.split(".").filter(Boolean))), A = S.fn ? S.fn(...B) : B;
|
|
501
|
+
return S.targetPath.length === 0 ? { kind: "return", value: A } : {
|
|
502
|
+
kind: "commit",
|
|
503
|
+
instructions: [{ path: S.targetPath, op: "query", value: A }]
|
|
504
|
+
};
|
|
359
505
|
}
|
|
360
|
-
return
|
|
506
|
+
return {
|
|
507
|
+
kind: "commit",
|
|
508
|
+
instructions: [{ path: i, op: "set", value: r }]
|
|
509
|
+
};
|
|
361
510
|
}
|
|
362
|
-
const
|
|
363
|
-
function R(
|
|
364
|
-
let
|
|
365
|
-
for (let e = 0; e <
|
|
366
|
-
|
|
367
|
-
return ("00000000" + (
|
|
511
|
+
const ae = "+";
|
|
512
|
+
function R(l) {
|
|
513
|
+
let n = 2166136261;
|
|
514
|
+
for (let e = 0; e < l.length; e++)
|
|
515
|
+
n ^= l.charCodeAt(e), n = Math.imul(n, 16777619);
|
|
516
|
+
return ("00000000" + (n >>> 0).toString(16)).slice(-8);
|
|
368
517
|
}
|
|
369
|
-
class
|
|
518
|
+
class he {
|
|
370
519
|
/**
|
|
371
520
|
* Constructor base:
|
|
372
521
|
* me = new ME(expression?)
|
|
@@ -374,7 +523,7 @@ class se {
|
|
|
374
523
|
* Esto es equivalente a llamar:
|
|
375
524
|
* me(expression) en la raíz.
|
|
376
525
|
*/
|
|
377
|
-
constructor(
|
|
526
|
+
constructor(n) {
|
|
378
527
|
this.localSecrets = {}, this.localNoises = {}, this.encryptedBranches = {}, this.index = {}, this._shortTermMemory = [], this.operators = {
|
|
379
528
|
_: { kind: "secret" },
|
|
380
529
|
"~": { kind: "noise" },
|
|
@@ -393,55 +542,55 @@ class se {
|
|
|
393
542
|
"=": { kind: "eval" },
|
|
394
543
|
"?": { kind: "query" },
|
|
395
544
|
"-": { kind: "remove" }
|
|
396
|
-
}, this._shortTermMemory = [],
|
|
545
|
+
}, this._shortTermMemory = [], n !== void 0 && this.postulate([], n), this.rebuildIndex();
|
|
397
546
|
const e = this.createProxy([]);
|
|
398
|
-
return Object.setPrototypeOf(e,
|
|
547
|
+
return Object.setPrototypeOf(e, he.prototype), Object.assign(e, this), e;
|
|
399
548
|
}
|
|
400
549
|
// semantic accessor (property-style)
|
|
401
550
|
get shortTermMemory() {
|
|
402
551
|
return this._shortTermMemory;
|
|
403
552
|
}
|
|
404
|
-
isRemoveCall(
|
|
405
|
-
if (
|
|
406
|
-
const { scope:
|
|
407
|
-
if (!
|
|
553
|
+
isRemoveCall(n, e) {
|
|
554
|
+
if (n.length === 0) return null;
|
|
555
|
+
const { scope: i, leaf: r } = C(n);
|
|
556
|
+
if (!r || this.opKind(r) !== "remove") return null;
|
|
408
557
|
if (e == null)
|
|
409
|
-
return { targetPath:
|
|
558
|
+
return { targetPath: i };
|
|
410
559
|
if (typeof e == "string") {
|
|
411
|
-
const
|
|
412
|
-
return { targetPath: [...
|
|
560
|
+
const u = e.split(".").filter(Boolean);
|
|
561
|
+
return { targetPath: [...i, ...u] };
|
|
413
562
|
}
|
|
414
563
|
return null;
|
|
415
564
|
}
|
|
416
565
|
// ---------------------------------------------------------
|
|
417
566
|
// Proxy infinito: me.foo.bar(...triada)
|
|
418
567
|
// ---------------------------------------------------------
|
|
419
|
-
createProxy(
|
|
420
|
-
const e = this,
|
|
568
|
+
createProxy(n) {
|
|
569
|
+
const e = this, i = (...r) => Me(
|
|
421
570
|
{
|
|
422
|
-
createProxy: (
|
|
423
|
-
normalizeArgs: (
|
|
424
|
-
readPath: (
|
|
425
|
-
postulate: (
|
|
426
|
-
opKind: (
|
|
427
|
-
splitPath:
|
|
428
|
-
isThought:
|
|
571
|
+
createProxy: (u) => e.createProxy(u),
|
|
572
|
+
normalizeArgs: (u) => e.normalizeArgs(u),
|
|
573
|
+
readPath: (u) => e.readPath(u),
|
|
574
|
+
postulate: (u, f) => e.postulate(u, f),
|
|
575
|
+
opKind: (u) => e.opKind(u),
|
|
576
|
+
splitPath: C,
|
|
577
|
+
isThought: me
|
|
429
578
|
},
|
|
430
|
-
|
|
431
|
-
|
|
579
|
+
n,
|
|
580
|
+
r
|
|
432
581
|
);
|
|
433
|
-
return new Proxy(
|
|
434
|
-
get(
|
|
435
|
-
if (typeof
|
|
436
|
-
if (
|
|
437
|
-
const
|
|
438
|
-
return typeof
|
|
582
|
+
return new Proxy(i, {
|
|
583
|
+
get(r, u) {
|
|
584
|
+
if (typeof u == "symbol") return r[u];
|
|
585
|
+
if (u in e) {
|
|
586
|
+
const p = e[u];
|
|
587
|
+
return typeof p == "function" ? p.bind(e) : p;
|
|
439
588
|
}
|
|
440
|
-
const
|
|
441
|
-
return e.createProxy(
|
|
589
|
+
const f = [...n, String(u)];
|
|
590
|
+
return e.createProxy(f);
|
|
442
591
|
},
|
|
443
|
-
apply(
|
|
444
|
-
return Reflect.apply(
|
|
592
|
+
apply(r, u, f) {
|
|
593
|
+
return Reflect.apply(r, void 0, f);
|
|
445
594
|
}
|
|
446
595
|
});
|
|
447
596
|
}
|
|
@@ -453,324 +602,363 @@ class se {
|
|
|
453
602
|
// me["?"](["a.b"], fn)
|
|
454
603
|
// For normal writes, keep single-arg semantics.
|
|
455
604
|
// NOTE: secrets are declared structurally via _("..."), not as args.
|
|
456
|
-
normalizeArgs(
|
|
457
|
-
if (
|
|
458
|
-
return
|
|
459
|
-
}
|
|
460
|
-
opKind(
|
|
461
|
-
return this.operators[
|
|
462
|
-
}
|
|
463
|
-
isSecretScopeCall(
|
|
464
|
-
if (
|
|
465
|
-
const { scope:
|
|
466
|
-
return !
|
|
467
|
-
}
|
|
468
|
-
isNoiseScopeCall(
|
|
469
|
-
if (
|
|
470
|
-
const { scope:
|
|
471
|
-
return !
|
|
472
|
-
}
|
|
473
|
-
isPointerCall(
|
|
474
|
-
if (
|
|
475
|
-
const { leaf:
|
|
476
|
-
if (!
|
|
477
|
-
const
|
|
478
|
-
return
|
|
479
|
-
}
|
|
480
|
-
isIdentityCall(
|
|
481
|
-
if (
|
|
482
|
-
return typeof e != "string" ? null : { id:
|
|
483
|
-
const { scope:
|
|
484
|
-
return !
|
|
485
|
-
}
|
|
486
|
-
isEvalCall(
|
|
487
|
-
if (
|
|
488
|
-
const { scope:
|
|
489
|
-
if (!
|
|
605
|
+
normalizeArgs(n) {
|
|
606
|
+
if (n.length !== 0)
|
|
607
|
+
return n.length === 1 ? n[0] : n;
|
|
608
|
+
}
|
|
609
|
+
opKind(n) {
|
|
610
|
+
return this.operators[n]?.kind ?? null;
|
|
611
|
+
}
|
|
612
|
+
isSecretScopeCall(n, e) {
|
|
613
|
+
if (n.length === 0) return null;
|
|
614
|
+
const { scope: i, leaf: r } = C(n);
|
|
615
|
+
return !r || this.opKind(r) !== "secret" || typeof e != "string" ? null : { scopeKey: i.join(".") };
|
|
616
|
+
}
|
|
617
|
+
isNoiseScopeCall(n, e) {
|
|
618
|
+
if (n.length === 0) return null;
|
|
619
|
+
const { scope: i, leaf: r } = C(n);
|
|
620
|
+
return !r || this.opKind(r) !== "noise" || typeof e != "string" ? null : { scopeKey: i.join(".") };
|
|
621
|
+
}
|
|
622
|
+
isPointerCall(n, e) {
|
|
623
|
+
if (n.length === 0) return null;
|
|
624
|
+
const { leaf: i } = C(n);
|
|
625
|
+
if (!i || this.opKind(i) !== "pointer" || typeof e != "string") return null;
|
|
626
|
+
const r = e.trim().replace(/^\./, "");
|
|
627
|
+
return r ? { targetPath: r } : null;
|
|
628
|
+
}
|
|
629
|
+
isIdentityCall(n, e) {
|
|
630
|
+
if (n.length === 1 && this.opKind(n[0]) === "identity")
|
|
631
|
+
return typeof e != "string" ? null : { id: Ht(e), targetPath: [] };
|
|
632
|
+
const { scope: i, leaf: r } = C(n);
|
|
633
|
+
return !r || this.opKind(r) !== "identity" || typeof e != "string" ? null : { id: Ht(e), targetPath: i };
|
|
634
|
+
}
|
|
635
|
+
isEvalCall(n, e) {
|
|
636
|
+
if (n.length === 0) return null;
|
|
637
|
+
const { scope: i, leaf: r } = C(n);
|
|
638
|
+
if (!r || this.opKind(r) !== "eval") return null;
|
|
490
639
|
if (typeof e == "function")
|
|
491
|
-
return { mode: "thunk", targetPath:
|
|
640
|
+
return { mode: "thunk", targetPath: i, thunk: e };
|
|
492
641
|
if (Array.isArray(e) && e.length >= 2) {
|
|
493
|
-
const
|
|
494
|
-
return !
|
|
642
|
+
const u = String(e[0] ?? "").trim(), f = String(e[1] ?? "").trim();
|
|
643
|
+
return !u || !f ? null : { mode: "assign", targetPath: i, name: u, expr: f };
|
|
495
644
|
}
|
|
496
645
|
return null;
|
|
497
646
|
}
|
|
498
|
-
isQueryCall(
|
|
499
|
-
if (
|
|
500
|
-
const { scope:
|
|
501
|
-
if (!
|
|
502
|
-
let
|
|
647
|
+
isQueryCall(n, e) {
|
|
648
|
+
if (n.length === 0) return null;
|
|
649
|
+
const { scope: i, leaf: r } = C(n);
|
|
650
|
+
if (!r || this.opKind(r) !== "query") return null;
|
|
651
|
+
let u = null, f;
|
|
503
652
|
if (Array.isArray(e) && e.length > 0)
|
|
504
|
-
Array.isArray(e[0]) && (e.length === 1 || typeof e[1] == "function") ? (
|
|
653
|
+
Array.isArray(e[0]) && (e.length === 1 || typeof e[1] == "function") ? (u = e[0], f = typeof e[1] == "function" ? e[1] : void 0) : u = e;
|
|
505
654
|
else
|
|
506
655
|
return null;
|
|
507
|
-
if (!Array.isArray(
|
|
508
|
-
const
|
|
509
|
-
return
|
|
656
|
+
if (!Array.isArray(u) || u.length === 0) return null;
|
|
657
|
+
const p = u.map((s) => String(s)).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
658
|
+
return p.length === 0 ? null : { targetPath: i, paths: p, fn: f };
|
|
659
|
+
}
|
|
660
|
+
isDefineOpCall(n, e) {
|
|
661
|
+
if (n.length !== 1 || n[0] !== ae || !Array.isArray(e) || e.length < 2) return null;
|
|
662
|
+
const r = String(e[0] ?? "").trim(), u = String(e[1] ?? "").trim();
|
|
663
|
+
return !r || !u || r === ae ? null : { op: r, kind: u };
|
|
510
664
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
665
|
+
commitThoughtOnly(n, e, i, r) {
|
|
666
|
+
const u = n.join("."), f = this.computeEffectiveSecret(n), p = JSON.stringify({
|
|
667
|
+
path: u,
|
|
668
|
+
operator: e,
|
|
669
|
+
expression: i,
|
|
670
|
+
value: r,
|
|
671
|
+
effectiveSecret: f
|
|
672
|
+
}), s = R(p), h = Date.now(), k = {
|
|
673
|
+
path: u,
|
|
674
|
+
operator: e,
|
|
675
|
+
expression: i,
|
|
676
|
+
value: r,
|
|
677
|
+
effectiveSecret: f,
|
|
678
|
+
hash: s,
|
|
679
|
+
timestamp: h
|
|
680
|
+
};
|
|
681
|
+
return this._shortTermMemory.push(k), this.rebuildIndex(), k;
|
|
682
|
+
}
|
|
683
|
+
commitValueMapping(n, e, i = null) {
|
|
684
|
+
let r = e;
|
|
685
|
+
const u = n.join("."), f = this.computeEffectiveSecret(n), p = this.resolveBranchScope(n);
|
|
686
|
+
if (p && p.length === 0 && this.localSecrets[""] && this.localSecrets[u], p && p.length > 0) {
|
|
687
|
+
const s = this.computeEffectiveSecret(p), h = n.slice(p.length), k = this.getBranchBlob(p);
|
|
688
|
+
let m = {};
|
|
689
|
+
if (k && s) {
|
|
690
|
+
const S = Jt(k, s, p);
|
|
691
|
+
S && typeof S == "object" && (m = S);
|
|
692
|
+
}
|
|
693
|
+
if (h.length === 0)
|
|
694
|
+
(typeof m != "object" || m === null) && (m = {}), m.expression = e;
|
|
695
|
+
else {
|
|
696
|
+
let S = m;
|
|
697
|
+
for (let B = 0; B < h.length - 1; B++) {
|
|
698
|
+
const A = h[B];
|
|
699
|
+
(!S[A] || typeof S[A] != "object") && (S[A] = {}), S = S[A];
|
|
700
|
+
}
|
|
701
|
+
S[h[h.length - 1]] = e;
|
|
702
|
+
}
|
|
703
|
+
if (s) {
|
|
704
|
+
const S = Qt(m, s, p);
|
|
705
|
+
this.setBranchBlob(p, S);
|
|
706
|
+
}
|
|
707
|
+
r = e;
|
|
708
|
+
} else if (f) {
|
|
709
|
+
const s = i !== "=" && i !== "?";
|
|
710
|
+
N(e) || Lt(e) || !s ? r = e : r = Qt(e, f, n);
|
|
711
|
+
} else
|
|
712
|
+
r = e;
|
|
713
|
+
return this.commitThoughtOnly(n, i, e, r);
|
|
714
|
+
}
|
|
715
|
+
commitMapping(n, e = null) {
|
|
716
|
+
switch (n.op) {
|
|
717
|
+
case "set":
|
|
718
|
+
return this.commitValueMapping(n.path, n.value, e);
|
|
719
|
+
case "ptr":
|
|
720
|
+
return this.commitValueMapping(n.path, n.value, "__");
|
|
721
|
+
case "id":
|
|
722
|
+
return this.commitValueMapping(n.path, n.value, "@");
|
|
723
|
+
case "secret": {
|
|
724
|
+
if (typeof n.value != "string") return;
|
|
725
|
+
const i = n.path.join(".");
|
|
726
|
+
return this.localSecrets[i] = n.value, this.commitThoughtOnly(n.path, "_", "***", "***");
|
|
727
|
+
}
|
|
728
|
+
default:
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
515
731
|
}
|
|
516
732
|
// ---------------------------------------------------------
|
|
517
733
|
// Postulate: semantic write at a given path
|
|
518
734
|
// ---------------------------------------------------------
|
|
519
|
-
postulate(
|
|
520
|
-
let
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
this.operators[
|
|
735
|
+
postulate(n, e, i = null) {
|
|
736
|
+
let r = n;
|
|
737
|
+
const u = this.isDefineOpCall(r, e);
|
|
738
|
+
if (u) {
|
|
739
|
+
this.operators[u.op] = { kind: u.kind };
|
|
524
740
|
return;
|
|
525
741
|
}
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
742
|
+
const { leaf: f } = C(r), p = f ? this.opKind(f) : null;
|
|
743
|
+
if (p === null || p === "secret" || p === "pointer" || p === "identity") {
|
|
744
|
+
const B = Te(this.operators, { path: r, expression: e });
|
|
745
|
+
if (B.kind === "commit") {
|
|
746
|
+
const A = /* @__PURE__ */ new Set(["set", "secret", "ptr", "id"]);
|
|
747
|
+
if (B.instructions.every((O) => A.has(O.op))) {
|
|
748
|
+
let O;
|
|
749
|
+
for (const E of B.instructions) {
|
|
750
|
+
const M = this.commitMapping(E, i);
|
|
751
|
+
M && (O = M);
|
|
752
|
+
}
|
|
753
|
+
if (O) return O;
|
|
754
|
+
}
|
|
531
755
|
}
|
|
532
|
-
const k = [...b.targetPath, b.name];
|
|
533
|
-
return this.postulate(k, b.expr, "=");
|
|
534
756
|
}
|
|
535
|
-
const
|
|
536
|
-
if (
|
|
537
|
-
|
|
538
|
-
|
|
757
|
+
const h = this.isEvalCall(r, e);
|
|
758
|
+
if (h) {
|
|
759
|
+
if (h.mode === "thunk") {
|
|
760
|
+
const A = h.thunk();
|
|
761
|
+
return h.targetPath.length === 0 ? A : this.postulate(h.targetPath, A, "=");
|
|
762
|
+
}
|
|
763
|
+
const B = [...h.targetPath, h.name];
|
|
764
|
+
return this.postulate(B, h.expr, "=");
|
|
765
|
+
}
|
|
766
|
+
const k = this.isQueryCall(r, e);
|
|
767
|
+
if (k) {
|
|
768
|
+
const B = k.paths.map((x) => this.readPath(x.split(".").filter(Boolean))), A = k.fn ? k.fn(...B) : B;
|
|
769
|
+
return k.targetPath.length === 0 ? A : this.postulate(k.targetPath, A, "?");
|
|
539
770
|
}
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
542
|
-
this.removeSubtree(
|
|
771
|
+
const m = this.isRemoveCall(r, e);
|
|
772
|
+
if (m) {
|
|
773
|
+
this.removeSubtree(m.targetPath);
|
|
543
774
|
return;
|
|
544
775
|
}
|
|
545
|
-
const S = this.
|
|
776
|
+
const S = this.isNoiseScopeCall(r, e);
|
|
546
777
|
if (S) {
|
|
547
|
-
this.
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
operator: "_",
|
|
551
|
-
expression: w,
|
|
552
|
-
value: _,
|
|
553
|
-
effectiveSecret: C
|
|
554
|
-
}), I = R(F), j = Date.now(), K = {
|
|
555
|
-
path: x,
|
|
556
|
-
operator: "_",
|
|
557
|
-
expression: w,
|
|
558
|
-
value: _,
|
|
559
|
-
effectiveSecret: C,
|
|
560
|
-
hash: I,
|
|
561
|
-
timestamp: j
|
|
562
|
-
};
|
|
563
|
-
return this._shortTermMemory.push(K), this.rebuildIndex(), K;
|
|
564
|
-
}
|
|
565
|
-
const O = this.isNoiseScopeCall(i, e);
|
|
566
|
-
if (O) {
|
|
567
|
-
this.localNoises[O.scopeKey] = e;
|
|
568
|
-
const k = O.scopeKey ? O.scopeKey.split(".").filter(Boolean) : [], x = k.join("."), C = this.computeEffectiveSecret(k), w = "***", _ = "***", F = JSON.stringify({
|
|
569
|
-
path: x,
|
|
570
|
-
operator: "~",
|
|
571
|
-
expression: w,
|
|
572
|
-
value: _,
|
|
573
|
-
effectiveSecret: C
|
|
574
|
-
}), I = R(F), j = Date.now(), K = {
|
|
575
|
-
path: x,
|
|
576
|
-
operator: "~",
|
|
577
|
-
expression: w,
|
|
578
|
-
value: _,
|
|
579
|
-
effectiveSecret: C,
|
|
580
|
-
hash: I,
|
|
581
|
-
timestamp: j
|
|
582
|
-
};
|
|
583
|
-
return this._shortTermMemory.push(K), this.rebuildIndex(), K;
|
|
584
|
-
}
|
|
585
|
-
const W = this.isPointerCall(i, e);
|
|
586
|
-
if (W) {
|
|
587
|
-
const { scope: k } = N(i);
|
|
588
|
-
i = k, e = ve(W.targetPath), f = e, a === null && (a = "__");
|
|
778
|
+
this.localNoises[S.scopeKey] = e;
|
|
779
|
+
const B = S.scopeKey ? S.scopeKey.split(".").filter(Boolean) : [];
|
|
780
|
+
return this.commitThoughtOnly(B, "~", "***", "***");
|
|
589
781
|
}
|
|
590
|
-
|
|
591
|
-
z && (i = z.targetPath, e = ge(z.id), f = e, a === null && (a = "@"));
|
|
592
|
-
const P = i.join("."), D = this.computeEffectiveSecret(i), E = this.resolveBranchScope(i);
|
|
593
|
-
if (E && E.length === 0 && this.localSecrets[""] && this.localSecrets[P], E && E.length > 0) {
|
|
594
|
-
const k = this.computeEffectiveSecret(E), x = i.slice(E.length), C = this.getBranchBlob(E);
|
|
595
|
-
let w = {};
|
|
596
|
-
if (C && k) {
|
|
597
|
-
const _ = re(C, k, E);
|
|
598
|
-
_ && typeof _ == "object" && (w = _);
|
|
599
|
-
}
|
|
600
|
-
if (x.length === 0)
|
|
601
|
-
(typeof w != "object" || w === null) && (w = {}), w.expression = e;
|
|
602
|
-
else {
|
|
603
|
-
let _ = w;
|
|
604
|
-
for (let F = 0; F < x.length - 1; F++) {
|
|
605
|
-
const I = x[F];
|
|
606
|
-
(!_[I] || typeof _[I] != "object") && (_[I] = {}), _ = _[I];
|
|
607
|
-
}
|
|
608
|
-
_[x[x.length - 1]] = e;
|
|
609
|
-
}
|
|
610
|
-
if (k) {
|
|
611
|
-
const _ = fe(w, k, E);
|
|
612
|
-
this.setBranchBlob(E, _);
|
|
613
|
-
}
|
|
614
|
-
f = e;
|
|
615
|
-
} else if (D) {
|
|
616
|
-
const k = a !== "=" && a !== "?";
|
|
617
|
-
Yt(e) || te(e) || !k ? f = e : f = fe(e, D, i);
|
|
618
|
-
} else
|
|
619
|
-
f = e;
|
|
620
|
-
const J = f, $ = JSON.stringify({
|
|
621
|
-
path: P,
|
|
622
|
-
operator: a,
|
|
623
|
-
expression: e,
|
|
624
|
-
value: J,
|
|
625
|
-
effectiveSecret: D
|
|
626
|
-
}), q = R($), Zt = Date.now(), L = {
|
|
627
|
-
path: P,
|
|
628
|
-
operator: a,
|
|
629
|
-
expression: e,
|
|
630
|
-
value: J,
|
|
631
|
-
effectiveSecret: D,
|
|
632
|
-
hash: q,
|
|
633
|
-
timestamp: Zt
|
|
634
|
-
};
|
|
635
|
-
return this._shortTermMemory.push(L), this.rebuildIndex(), L;
|
|
782
|
+
return this.commitValueMapping(r, e, i);
|
|
636
783
|
}
|
|
637
|
-
removeSubtree(
|
|
638
|
-
const e =
|
|
639
|
-
for (const
|
|
784
|
+
removeSubtree(n) {
|
|
785
|
+
const e = n.join(".");
|
|
786
|
+
for (const h of Object.keys(this.localSecrets)) {
|
|
640
787
|
if (e === "") {
|
|
641
|
-
delete this.localSecrets[
|
|
788
|
+
delete this.localSecrets[h];
|
|
642
789
|
continue;
|
|
643
790
|
}
|
|
644
|
-
(
|
|
791
|
+
(h === e || h.startsWith(e + ".")) && delete this.localSecrets[h];
|
|
645
792
|
}
|
|
646
|
-
for (const
|
|
793
|
+
for (const h of Object.keys(this.localNoises)) {
|
|
647
794
|
if (e === "") {
|
|
648
|
-
delete this.localNoises[
|
|
795
|
+
delete this.localNoises[h];
|
|
649
796
|
continue;
|
|
650
797
|
}
|
|
651
|
-
(
|
|
798
|
+
(h === e || h.startsWith(e + ".")) && delete this.localNoises[h];
|
|
652
799
|
}
|
|
653
|
-
for (const
|
|
800
|
+
for (const h of Object.keys(this.encryptedBranches)) {
|
|
654
801
|
if (e === "") {
|
|
655
|
-
delete this.encryptedBranches[
|
|
802
|
+
delete this.encryptedBranches[h];
|
|
656
803
|
continue;
|
|
657
804
|
}
|
|
658
|
-
(
|
|
805
|
+
if (h === e || h.startsWith(e + ".")) {
|
|
806
|
+
delete this.encryptedBranches[h];
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
const k = h.split(".").filter(Boolean);
|
|
810
|
+
if (!Gt(n, k) || n.length <= k.length) continue;
|
|
811
|
+
const m = this.computeEffectiveSecret(k);
|
|
812
|
+
if (!m) continue;
|
|
813
|
+
const S = this.getBranchBlob(k);
|
|
814
|
+
if (!S) continue;
|
|
815
|
+
const B = Jt(S, m, k);
|
|
816
|
+
if (!B || typeof B != "object") continue;
|
|
817
|
+
const A = n.slice(k.length);
|
|
818
|
+
let x = B;
|
|
819
|
+
for (let O = 0; O < A.length - 1; O++) {
|
|
820
|
+
const E = A[O];
|
|
821
|
+
if (!x || typeof x != "object" || !(E in x)) {
|
|
822
|
+
x = null;
|
|
823
|
+
break;
|
|
824
|
+
}
|
|
825
|
+
x = x[E];
|
|
826
|
+
}
|
|
827
|
+
if (x && typeof x == "object") {
|
|
828
|
+
delete x[A[A.length - 1]];
|
|
829
|
+
const O = Qt(B, m, k);
|
|
830
|
+
this.setBranchBlob(k, O);
|
|
831
|
+
}
|
|
659
832
|
}
|
|
660
|
-
const
|
|
661
|
-
path:
|
|
833
|
+
const i = n.join("."), r = Date.now(), u = this.computeEffectiveSecret(n), f = JSON.stringify({ path: i, operator: "-", expression: "-", value: "-", effectiveSecret: u }), p = R(f), s = {
|
|
834
|
+
path: i,
|
|
662
835
|
operator: "-",
|
|
663
836
|
expression: "-",
|
|
664
837
|
value: "-",
|
|
665
|
-
effectiveSecret:
|
|
666
|
-
hash:
|
|
667
|
-
timestamp:
|
|
838
|
+
effectiveSecret: u,
|
|
839
|
+
hash: p,
|
|
840
|
+
timestamp: r
|
|
668
841
|
};
|
|
669
|
-
this._shortTermMemory.push(
|
|
842
|
+
this._shortTermMemory.push(s), this.rebuildIndex();
|
|
670
843
|
}
|
|
671
844
|
// ---------------------------------------------------------
|
|
672
845
|
// Fractal secret: combina todos los secrets a lo largo de la ruta, o noise acts as a new root for chaining
|
|
673
846
|
// ---------------------------------------------------------
|
|
674
|
-
computeEffectiveSecret(
|
|
675
|
-
let e = null,
|
|
676
|
-
this.localNoises[""] !== void 0 && (e = "",
|
|
677
|
-
for (let
|
|
678
|
-
const
|
|
679
|
-
this.localNoises[
|
|
847
|
+
computeEffectiveSecret(n) {
|
|
848
|
+
let e = null, i = null;
|
|
849
|
+
this.localNoises[""] !== void 0 && (e = "", i = this.localNoises[""]);
|
|
850
|
+
for (let u = 1; u <= n.length; u++) {
|
|
851
|
+
const f = n.slice(0, u).join(".");
|
|
852
|
+
this.localNoises[f] !== void 0 && (e = f, i = this.localNoises[f]);
|
|
680
853
|
}
|
|
681
|
-
let
|
|
682
|
-
|
|
683
|
-
for (let
|
|
684
|
-
const
|
|
685
|
-
if (this.localSecrets[
|
|
854
|
+
let r = "root";
|
|
855
|
+
i ? r = R("noise::" + i) : this.localSecrets[""] && (r = R(r + "::" + this.localSecrets[""])), e === null || e === "" || e.split(".").filter(Boolean).length;
|
|
856
|
+
for (let u = 1; u <= n.length; u++) {
|
|
857
|
+
const f = n.slice(0, u).join(".");
|
|
858
|
+
if (this.localSecrets[f]) {
|
|
686
859
|
if (e !== null && e !== "") {
|
|
687
|
-
const
|
|
688
|
-
if (!(
|
|
860
|
+
const p = e + ".";
|
|
861
|
+
if (!(f === e || f.startsWith(p))) continue;
|
|
689
862
|
}
|
|
690
|
-
|
|
863
|
+
r = R(r + "::" + this.localSecrets[f]);
|
|
691
864
|
}
|
|
692
865
|
}
|
|
693
|
-
return
|
|
866
|
+
return r === "root" ? "" : r;
|
|
694
867
|
}
|
|
695
868
|
// ---------------------------------------------------------
|
|
696
869
|
// Índice derivado
|
|
697
870
|
// ---------------------------------------------------------
|
|
698
871
|
rebuildIndex() {
|
|
699
|
-
const
|
|
872
|
+
const n = {};
|
|
700
873
|
for (const e of this._shortTermMemory) {
|
|
701
|
-
const
|
|
874
|
+
const i = e.path, r = i.split(".").filter(Boolean), u = this.resolveBranchScope(r), f = u && u.length > 0 && Gt(r, u);
|
|
702
875
|
if (e.operator === "-") {
|
|
703
|
-
if (
|
|
704
|
-
for (const
|
|
876
|
+
if (i === "") {
|
|
877
|
+
for (const s of Object.keys(n)) delete n[s];
|
|
705
878
|
continue;
|
|
706
879
|
}
|
|
707
|
-
const
|
|
708
|
-
for (const
|
|
709
|
-
(
|
|
880
|
+
const p = i + ".";
|
|
881
|
+
for (const s of Object.keys(n))
|
|
882
|
+
(s === i || s.startsWith(p)) && delete n[s];
|
|
710
883
|
continue;
|
|
711
884
|
}
|
|
712
|
-
|
|
885
|
+
f || (n[i] = e.value);
|
|
713
886
|
}
|
|
714
|
-
this.index =
|
|
887
|
+
this.index = n;
|
|
715
888
|
}
|
|
716
|
-
getIndex(
|
|
717
|
-
return this.index[
|
|
889
|
+
getIndex(n) {
|
|
890
|
+
return this.index[n.join(".")];
|
|
718
891
|
}
|
|
719
|
-
setIndex(
|
|
720
|
-
this.index[
|
|
892
|
+
setIndex(n, e) {
|
|
893
|
+
this.index[n.join(".")] = e;
|
|
721
894
|
}
|
|
722
|
-
resolveIndexPointerPath(
|
|
723
|
-
let
|
|
724
|
-
for (let
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
727
|
-
|
|
895
|
+
resolveIndexPointerPath(n, e = 8) {
|
|
896
|
+
let i = n;
|
|
897
|
+
for (let r = 0; r < e; r++) {
|
|
898
|
+
const u = this.getIndex(i);
|
|
899
|
+
if (N(u)) {
|
|
900
|
+
i = u.__ptr.split(".").filter(Boolean);
|
|
901
|
+
continue;
|
|
902
|
+
}
|
|
903
|
+
let f = !1;
|
|
904
|
+
for (let p = i.length - 1; p >= 0; p--) {
|
|
905
|
+
const s = i.slice(0, p), h = this.getIndex(s);
|
|
906
|
+
if (!N(h)) continue;
|
|
907
|
+
const k = h.__ptr.split(".").filter(Boolean), m = i.slice(p);
|
|
908
|
+
i = [...k, ...m], f = !0;
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
if (!f)
|
|
912
|
+
return { path: i, raw: u };
|
|
728
913
|
}
|
|
729
|
-
return { path:
|
|
914
|
+
return { path: i, raw: void 0 };
|
|
730
915
|
}
|
|
731
|
-
setBranchBlob(
|
|
732
|
-
const
|
|
733
|
-
this.encryptedBranches[
|
|
916
|
+
setBranchBlob(n, e) {
|
|
917
|
+
const i = n.join(".");
|
|
918
|
+
this.encryptedBranches[i] = e;
|
|
734
919
|
}
|
|
735
|
-
getBranchBlob(
|
|
736
|
-
const e =
|
|
920
|
+
getBranchBlob(n) {
|
|
921
|
+
const e = n.join(".");
|
|
737
922
|
return this.encryptedBranches[e];
|
|
738
923
|
}
|
|
739
|
-
resolveBranchScope(
|
|
924
|
+
resolveBranchScope(n) {
|
|
740
925
|
let e = null;
|
|
741
926
|
this.localSecrets[""] && (e = []);
|
|
742
|
-
for (let
|
|
743
|
-
const
|
|
744
|
-
this.localSecrets[
|
|
927
|
+
for (let i = 1; i <= n.length; i++) {
|
|
928
|
+
const r = n.slice(0, i), u = r.join(".");
|
|
929
|
+
this.localSecrets[u] && (e = r);
|
|
745
930
|
}
|
|
746
931
|
return e;
|
|
747
932
|
}
|
|
748
|
-
readPath(
|
|
749
|
-
const e = this.resolveBranchScope(
|
|
750
|
-
if (e && e.length > 0 &&
|
|
751
|
-
if (
|
|
933
|
+
readPath(n) {
|
|
934
|
+
const e = this.resolveBranchScope(n);
|
|
935
|
+
if (e && e.length > 0 && Gt(n, e)) {
|
|
936
|
+
if (n.length === e.length) return;
|
|
752
937
|
const p = this.computeEffectiveSecret(e);
|
|
753
938
|
if (!p) return null;
|
|
754
|
-
const
|
|
755
|
-
if (!
|
|
756
|
-
const
|
|
757
|
-
if (!
|
|
758
|
-
const
|
|
759
|
-
let
|
|
760
|
-
for (const
|
|
761
|
-
if (!
|
|
762
|
-
|
|
939
|
+
const s = this.getBranchBlob(e);
|
|
940
|
+
if (!s) return;
|
|
941
|
+
const h = Jt(s, p, e);
|
|
942
|
+
if (!h || typeof h != "object") return;
|
|
943
|
+
const k = n.slice(e.length);
|
|
944
|
+
let m = h;
|
|
945
|
+
for (const S of k) {
|
|
946
|
+
if (!m || typeof m != "object") return;
|
|
947
|
+
m = m[S];
|
|
763
948
|
}
|
|
764
|
-
return
|
|
949
|
+
return N(m) ? this.readPath(m.__ptr.split(".").filter(Boolean)) : (Lt(m), m);
|
|
765
950
|
}
|
|
766
|
-
const i = this.
|
|
767
|
-
if (i
|
|
768
|
-
|
|
769
|
-
if (
|
|
770
|
-
|
|
771
|
-
|
|
951
|
+
const i = this.getIndex(n);
|
|
952
|
+
if (N(i)) return i;
|
|
953
|
+
const r = this.resolveIndexPointerPath(n), u = r.raw;
|
|
954
|
+
if (u === void 0)
|
|
955
|
+
return r.path.length === n.length && r.path.every((s, h) => s === n[h]) ? void 0 : this.readPath(r.path);
|
|
956
|
+
if (N(u)) return this.readPath(u.__ptr.split(".").filter(Boolean));
|
|
957
|
+
if (Lt(u) || !Ne(u)) return u;
|
|
958
|
+
const f = this.computeEffectiveSecret(n);
|
|
959
|
+
return f ? Jt(u, f, n) : null;
|
|
772
960
|
}
|
|
773
961
|
}
|
|
774
962
|
export {
|
|
775
|
-
|
|
963
|
+
he as default
|
|
776
964
|
};
|