mol_crypto_lib 0.0.210 → 0.0.211
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/node.d.ts +0 -99
- package/node.deps.json +1 -1
- package/node.esm.js +6 -6
- package/node.esm.js.map +1 -1
- package/node.js +6 -6
- package/node.js.map +1 -1
- package/node.test.js +256 -250
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/test.html +2 -2
- package/web.d.ts +0 -99
- package/web.deps.json +1 -1
- package/web.esm.js +6 -6
- package/web.esm.js.map +1 -1
- package/web.js +6 -6
- package/web.js.map +1 -1
- package/web.test.js +174 -168
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -8,7 +8,7 @@ var $;
|
|
|
8
8
|
}
|
|
9
9
|
$.$mol_fail = $mol_fail;
|
|
10
10
|
})($ || ($ = {}));
|
|
11
|
-
//fail.
|
|
11
|
+
//mol/fail/fail.ts
|
|
12
12
|
;
|
|
13
13
|
"use strict";
|
|
14
14
|
var $;
|
|
@@ -18,7 +18,7 @@ var $;
|
|
|
18
18
|
}
|
|
19
19
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
20
20
|
})($ || ($ = {}));
|
|
21
|
-
//hidden.
|
|
21
|
+
//mol/fail/hidden/hidden.ts
|
|
22
22
|
;
|
|
23
23
|
"use strict";
|
|
24
24
|
var $;
|
|
@@ -36,12 +36,18 @@ var $;
|
|
|
36
36
|
$_1.$mol_test_all = [];
|
|
37
37
|
async function $mol_test_run() {
|
|
38
38
|
for (var test of $_1.$mol_test_all) {
|
|
39
|
-
let context = Object.create(
|
|
39
|
+
let context = Object.create($$);
|
|
40
40
|
for (let mock of $_1.$mol_test_mocks)
|
|
41
41
|
await mock(context);
|
|
42
|
-
|
|
42
|
+
const res = test(context);
|
|
43
|
+
if (res instanceof Promise) {
|
|
44
|
+
await new Promise((done, fail) => {
|
|
45
|
+
res.then(done, fail);
|
|
46
|
+
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
43
49
|
}
|
|
44
|
-
|
|
50
|
+
$$.$mol_log3_done({
|
|
45
51
|
place: '$mol_test',
|
|
46
52
|
message: 'All tests passed',
|
|
47
53
|
count: $_1.$mol_test_all.length,
|
|
@@ -59,7 +65,7 @@ var $;
|
|
|
59
65
|
await $mol_test_run();
|
|
60
66
|
}
|
|
61
67
|
finally {
|
|
62
|
-
|
|
68
|
+
$$.$mol_test_complete();
|
|
63
69
|
}
|
|
64
70
|
}, 0);
|
|
65
71
|
}
|
|
@@ -72,10 +78,10 @@ var $;
|
|
|
72
78
|
for (let api of forbidden) {
|
|
73
79
|
context[api] = new Proxy(function () { }, {
|
|
74
80
|
get() {
|
|
75
|
-
$
|
|
81
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
76
82
|
},
|
|
77
83
|
apply() {
|
|
78
|
-
$
|
|
84
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
79
85
|
},
|
|
80
86
|
});
|
|
81
87
|
}
|
|
@@ -103,7 +109,7 @@ var $;
|
|
|
103
109
|
},
|
|
104
110
|
});
|
|
105
111
|
})($ || ($ = {}));
|
|
106
|
-
//test.test.
|
|
112
|
+
//mol/test/test.test.ts
|
|
107
113
|
;
|
|
108
114
|
"use strict";
|
|
109
115
|
var $;
|
|
@@ -112,20 +118,20 @@ var $;
|
|
|
112
118
|
}
|
|
113
119
|
$.$mol_test_complete = $mol_test_complete;
|
|
114
120
|
})($ || ($ = {}));
|
|
115
|
-
//test.web.test.
|
|
121
|
+
//mol/test/test.web.test.ts
|
|
116
122
|
;
|
|
117
123
|
"use strict";
|
|
118
124
|
var $;
|
|
119
125
|
(function ($) {
|
|
120
126
|
})($ || ($ = {}));
|
|
121
|
-
//context.
|
|
127
|
+
//mol/dom/context/context.ts
|
|
122
128
|
;
|
|
123
129
|
"use strict";
|
|
124
130
|
var $;
|
|
125
131
|
(function ($) {
|
|
126
132
|
$.$mol_dom_context = self;
|
|
127
133
|
})($ || ($ = {}));
|
|
128
|
-
//context.web.
|
|
134
|
+
//mol/dom/context/context.web.ts
|
|
129
135
|
;
|
|
130
136
|
"use strict";
|
|
131
137
|
var $;
|
|
@@ -136,7 +142,7 @@ var $;
|
|
|
136
142
|
for (let view of childNodes) {
|
|
137
143
|
if (view == null)
|
|
138
144
|
continue;
|
|
139
|
-
if (view instanceof
|
|
145
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
140
146
|
while (true) {
|
|
141
147
|
if (!nextNode) {
|
|
142
148
|
el.appendChild(view);
|
|
@@ -167,7 +173,7 @@ var $;
|
|
|
167
173
|
nextNode = nextNode.nextSibling;
|
|
168
174
|
}
|
|
169
175
|
else {
|
|
170
|
-
const textNode =
|
|
176
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
171
177
|
el.insertBefore(textNode, nextNode);
|
|
172
178
|
}
|
|
173
179
|
}
|
|
@@ -180,88 +186,88 @@ var $;
|
|
|
180
186
|
}
|
|
181
187
|
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
182
188
|
})($ || ($ = {}));
|
|
183
|
-
//children.
|
|
189
|
+
//mol/dom/render/children/children.ts
|
|
184
190
|
;
|
|
185
191
|
"use strict";
|
|
186
|
-
//error.
|
|
192
|
+
//mol/type/error/error.ts
|
|
187
193
|
;
|
|
188
194
|
"use strict";
|
|
189
|
-
//assert.test.
|
|
195
|
+
//mol/type/assert/assert.test.ts
|
|
190
196
|
;
|
|
191
197
|
"use strict";
|
|
192
|
-
//assert.
|
|
198
|
+
//mol/type/assert/assert.ts
|
|
193
199
|
;
|
|
194
200
|
"use strict";
|
|
195
|
-
//deep.test.
|
|
201
|
+
//mol/type/partial/deep/deep.test.ts
|
|
196
202
|
;
|
|
197
203
|
"use strict";
|
|
198
|
-
//deep.
|
|
204
|
+
//mol/type/partial/deep/deep.ts
|
|
199
205
|
;
|
|
200
206
|
"use strict";
|
|
201
207
|
var $;
|
|
202
208
|
(function ($) {
|
|
203
|
-
|
|
209
|
+
$mol_test({
|
|
204
210
|
'Make empty div'() {
|
|
205
|
-
|
|
211
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
206
212
|
},
|
|
207
213
|
'Define native field'() {
|
|
208
|
-
const dom =
|
|
209
|
-
|
|
210
|
-
|
|
214
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
215
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
216
|
+
$mol_assert_equal(dom.value, '123');
|
|
211
217
|
},
|
|
212
218
|
'Define classes'() {
|
|
213
|
-
const dom =
|
|
214
|
-
|
|
219
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
220
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
215
221
|
},
|
|
216
222
|
'Define styles'() {
|
|
217
|
-
const dom =
|
|
218
|
-
|
|
223
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
224
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
219
225
|
},
|
|
220
226
|
'Define dataset'() {
|
|
221
|
-
const dom =
|
|
222
|
-
|
|
227
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
228
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
223
229
|
},
|
|
224
230
|
'Define attributes'() {
|
|
225
|
-
const dom =
|
|
226
|
-
|
|
231
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
232
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
227
233
|
},
|
|
228
234
|
'Define child nodes'() {
|
|
229
|
-
const dom =
|
|
235
|
+
const dom = $mol_jsx("div", null,
|
|
230
236
|
"hello",
|
|
231
|
-
|
|
237
|
+
$mol_jsx("strong", null, "world"),
|
|
232
238
|
"!");
|
|
233
|
-
|
|
239
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
234
240
|
},
|
|
235
241
|
'Function as component'() {
|
|
236
242
|
const Button = ({ hint }, target) => {
|
|
237
|
-
return
|
|
243
|
+
return $mol_jsx("button", { title: hint }, target());
|
|
238
244
|
};
|
|
239
|
-
const dom =
|
|
240
|
-
|
|
245
|
+
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
246
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
241
247
|
},
|
|
242
248
|
'Nested guid generation'() {
|
|
243
249
|
const Foo = () => {
|
|
244
|
-
return
|
|
245
|
-
|
|
246
|
-
|
|
250
|
+
return $mol_jsx("div", null,
|
|
251
|
+
$mol_jsx(Bar, { id: "/bar" },
|
|
252
|
+
$mol_jsx("img", { id: "/icon" })));
|
|
247
253
|
};
|
|
248
254
|
const Bar = (props, icon) => {
|
|
249
|
-
return
|
|
255
|
+
return $mol_jsx("span", null, icon);
|
|
250
256
|
};
|
|
251
|
-
const dom =
|
|
252
|
-
|
|
257
|
+
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
258
|
+
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
253
259
|
},
|
|
254
260
|
'Fail on non unique ids'() {
|
|
255
261
|
const App = () => {
|
|
256
|
-
return
|
|
257
|
-
|
|
258
|
-
|
|
262
|
+
return $mol_jsx("div", null,
|
|
263
|
+
$mol_jsx("span", { id: "/bar" }),
|
|
264
|
+
$mol_jsx("span", { id: "/bar" }));
|
|
259
265
|
};
|
|
260
|
-
|
|
266
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
261
267
|
},
|
|
262
268
|
});
|
|
263
269
|
})($ || ($ = {}));
|
|
264
|
-
//jsx.test.
|
|
270
|
+
//mol/jsx/jsx.test.tsx
|
|
265
271
|
;
|
|
266
272
|
"use strict";
|
|
267
273
|
var $;
|
|
@@ -270,15 +276,15 @@ var $;
|
|
|
270
276
|
$.$mol_jsx_booked = null;
|
|
271
277
|
$.$mol_jsx_document = {
|
|
272
278
|
getElementById: () => null,
|
|
273
|
-
createElementNS: (space, name) =>
|
|
274
|
-
createDocumentFragment: () =>
|
|
279
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
280
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
275
281
|
};
|
|
276
282
|
$.$mol_jsx_frag = '';
|
|
277
283
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
278
284
|
const id = props && props.id || '';
|
|
279
285
|
if (Elem && $.$mol_jsx_booked) {
|
|
280
286
|
if ($.$mol_jsx_booked.has(id)) {
|
|
281
|
-
|
|
287
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
282
288
|
}
|
|
283
289
|
else {
|
|
284
290
|
$.$mol_jsx_booked.add(id);
|
|
@@ -317,7 +323,7 @@ var $;
|
|
|
317
323
|
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
318
324
|
: $.$mol_jsx_document.createDocumentFragment();
|
|
319
325
|
}
|
|
320
|
-
|
|
326
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
321
327
|
if (!Elem)
|
|
322
328
|
return node;
|
|
323
329
|
for (const key in props) {
|
|
@@ -343,77 +349,77 @@ var $;
|
|
|
343
349
|
}
|
|
344
350
|
$.$mol_jsx = $mol_jsx;
|
|
345
351
|
})($ || ($ = {}));
|
|
346
|
-
//jsx.
|
|
352
|
+
//mol/jsx/jsx.ts
|
|
347
353
|
;
|
|
348
354
|
"use strict";
|
|
349
355
|
var $;
|
|
350
356
|
(function ($) {
|
|
351
|
-
|
|
357
|
+
$mol_test({
|
|
352
358
|
'nulls & undefineds'() {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
359
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
360
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
361
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
362
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
357
363
|
},
|
|
358
364
|
'number'() {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
365
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
366
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
367
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
368
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
369
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
364
370
|
},
|
|
365
371
|
'POJO'() {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
373
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
374
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
375
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
376
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
377
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
372
378
|
},
|
|
373
379
|
'Array'() {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
380
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
381
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
382
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
383
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
378
384
|
},
|
|
379
385
|
'Non POJO are different'() {
|
|
380
386
|
class Thing extends Object {
|
|
381
387
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
388
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
389
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
390
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
385
391
|
},
|
|
386
392
|
'same POJOs with cyclic reference'() {
|
|
387
393
|
const a = { foo: {} };
|
|
388
394
|
a['self'] = a;
|
|
389
395
|
const b = { foo: {} };
|
|
390
396
|
b['self'] = b;
|
|
391
|
-
|
|
397
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
392
398
|
},
|
|
393
399
|
'Date'() {
|
|
394
|
-
|
|
395
|
-
|
|
400
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
401
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
396
402
|
},
|
|
397
403
|
'RegExp'() {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
404
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
405
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
406
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
401
407
|
},
|
|
402
408
|
'Map'() {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
409
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
410
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
411
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
412
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
407
413
|
},
|
|
408
414
|
'Set'() {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
415
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
416
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
417
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
412
418
|
},
|
|
413
419
|
'Uint8Array'() {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
420
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
421
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
422
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
417
423
|
},
|
|
418
424
|
'Custom comparator'() {
|
|
419
425
|
class User {
|
|
@@ -427,17 +433,17 @@ var $;
|
|
|
427
433
|
return this.name;
|
|
428
434
|
}
|
|
429
435
|
}
|
|
430
|
-
|
|
431
|
-
|
|
436
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
437
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
432
438
|
},
|
|
433
439
|
});
|
|
434
440
|
})($ || ($ = {}));
|
|
435
|
-
//deep.test.
|
|
441
|
+
//mol/compare/deep/deep.test.tsx
|
|
436
442
|
;
|
|
437
443
|
"use strict";
|
|
438
444
|
var $;
|
|
439
445
|
(function ($) {
|
|
440
|
-
|
|
446
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
441
447
|
function $mol_compare_deep(left, right) {
|
|
442
448
|
if (Object.is(left, right))
|
|
443
449
|
return true;
|
|
@@ -463,7 +469,7 @@ var $;
|
|
|
463
469
|
return Object.is(left.valueOf(), right['valueOf']());
|
|
464
470
|
if (left instanceof RegExp)
|
|
465
471
|
return left.source === right['source'] && left.flags === right['flags'];
|
|
466
|
-
let left_cache =
|
|
472
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
467
473
|
if (left_cache) {
|
|
468
474
|
const right_cache = left_cache.get(right);
|
|
469
475
|
if (typeof right_cache === 'boolean')
|
|
@@ -471,7 +477,7 @@ var $;
|
|
|
471
477
|
}
|
|
472
478
|
else {
|
|
473
479
|
left_cache = new WeakMap([[right, true]]);
|
|
474
|
-
|
|
480
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
475
481
|
}
|
|
476
482
|
let result;
|
|
477
483
|
try {
|
|
@@ -555,50 +561,50 @@ var $;
|
|
|
555
561
|
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
556
562
|
}
|
|
557
563
|
})($ || ($ = {}));
|
|
558
|
-
//deep.
|
|
564
|
+
//mol/compare/deep/deep.ts
|
|
559
565
|
;
|
|
560
566
|
"use strict";
|
|
561
567
|
var $;
|
|
562
568
|
(function ($) {
|
|
563
569
|
function $mol_dom_serialize(node) {
|
|
564
|
-
const serializer = new
|
|
570
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
565
571
|
return serializer.serializeToString(node);
|
|
566
572
|
}
|
|
567
573
|
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
568
574
|
})($ || ($ = {}));
|
|
569
|
-
//serialize.
|
|
575
|
+
//mol/dom/serialize/serialize.ts
|
|
570
576
|
;
|
|
571
577
|
"use strict";
|
|
572
578
|
var $;
|
|
573
579
|
(function ($) {
|
|
574
|
-
|
|
580
|
+
$mol_test({
|
|
575
581
|
'must be false'() {
|
|
576
|
-
|
|
582
|
+
$mol_assert_not(0);
|
|
577
583
|
},
|
|
578
584
|
'must be true'() {
|
|
579
|
-
|
|
585
|
+
$mol_assert_ok(1);
|
|
580
586
|
},
|
|
581
587
|
'two must be equal'() {
|
|
582
|
-
|
|
588
|
+
$mol_assert_equal(2, 2);
|
|
583
589
|
},
|
|
584
590
|
'three must be equal'() {
|
|
585
|
-
|
|
591
|
+
$mol_assert_equal(2, 2, 2);
|
|
586
592
|
},
|
|
587
593
|
'two must be unique'() {
|
|
588
|
-
|
|
594
|
+
$mol_assert_unique([3], [3]);
|
|
589
595
|
},
|
|
590
596
|
'three must be unique'() {
|
|
591
|
-
|
|
597
|
+
$mol_assert_unique([3], [3], [3]);
|
|
592
598
|
},
|
|
593
599
|
'two must be alike'() {
|
|
594
|
-
|
|
600
|
+
$mol_assert_like([3], [3]);
|
|
595
601
|
},
|
|
596
602
|
'three must be alike'() {
|
|
597
|
-
|
|
603
|
+
$mol_assert_like([3], [3], [3]);
|
|
598
604
|
},
|
|
599
605
|
});
|
|
600
606
|
})($ || ($ = {}));
|
|
601
|
-
//assert.test.
|
|
607
|
+
//mol/assert/assert.test.ts
|
|
602
608
|
;
|
|
603
609
|
"use strict";
|
|
604
610
|
var $;
|
|
@@ -606,13 +612,13 @@ var $;
|
|
|
606
612
|
function $mol_assert_ok(value) {
|
|
607
613
|
if (value)
|
|
608
614
|
return;
|
|
609
|
-
|
|
615
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
610
616
|
}
|
|
611
617
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
612
618
|
function $mol_assert_not(value) {
|
|
613
619
|
if (!value)
|
|
614
620
|
return;
|
|
615
|
-
|
|
621
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
616
622
|
}
|
|
617
623
|
$.$mol_assert_not = $mol_assert_not;
|
|
618
624
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
@@ -636,7 +642,7 @@ var $;
|
|
|
636
642
|
finally {
|
|
637
643
|
$.$mol_fail = fail;
|
|
638
644
|
}
|
|
639
|
-
|
|
645
|
+
$mol_fail(new Error('Not failed'));
|
|
640
646
|
}
|
|
641
647
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
642
648
|
function $mol_assert_equal(...args) {
|
|
@@ -647,7 +653,7 @@ var $;
|
|
|
647
653
|
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
648
654
|
continue;
|
|
649
655
|
if (args[i] !== args[j])
|
|
650
|
-
|
|
656
|
+
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
651
657
|
}
|
|
652
658
|
}
|
|
653
659
|
}
|
|
@@ -658,7 +664,7 @@ var $;
|
|
|
658
664
|
if (i === j)
|
|
659
665
|
continue;
|
|
660
666
|
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
|
661
|
-
|
|
667
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
662
668
|
}
|
|
663
669
|
}
|
|
664
670
|
}
|
|
@@ -666,7 +672,7 @@ var $;
|
|
|
666
672
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
667
673
|
function $mol_assert_like(head, ...tail) {
|
|
668
674
|
for (let [index, value] of Object.entries(tail)) {
|
|
669
|
-
if (
|
|
675
|
+
if (!$mol_compare_deep(value, head)) {
|
|
670
676
|
const print = (val) => {
|
|
671
677
|
if (!val)
|
|
672
678
|
return val;
|
|
@@ -682,118 +688,118 @@ var $;
|
|
|
682
688
|
return val;
|
|
683
689
|
}
|
|
684
690
|
};
|
|
685
|
-
return
|
|
691
|
+
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
686
692
|
}
|
|
687
693
|
}
|
|
688
694
|
}
|
|
689
695
|
$.$mol_assert_like = $mol_assert_like;
|
|
690
696
|
function $mol_assert_dom(left, right) {
|
|
691
|
-
$mol_assert_equal(
|
|
697
|
+
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
|
692
698
|
}
|
|
693
699
|
$.$mol_assert_dom = $mol_assert_dom;
|
|
694
700
|
})($ || ($ = {}));
|
|
695
|
-
//assert.
|
|
701
|
+
//mol/assert/assert.ts
|
|
696
702
|
;
|
|
697
703
|
"use strict";
|
|
698
704
|
var $;
|
|
699
705
|
(function ($) {
|
|
700
|
-
|
|
706
|
+
$mol_test({
|
|
701
707
|
async 'sizes'() {
|
|
702
|
-
const cipher = await
|
|
708
|
+
const cipher = await $mol_crypto_secret.generate();
|
|
703
709
|
const key = await cipher.serial();
|
|
704
|
-
|
|
710
|
+
$mol_assert_equal(key.byteLength, $mol_crypto_secret.size);
|
|
705
711
|
const data = new Uint8Array([1, 2, 3]);
|
|
706
|
-
const salt =
|
|
712
|
+
const salt = $mol_crypto_salt();
|
|
707
713
|
const closed = await cipher.encrypt(data, salt);
|
|
708
|
-
|
|
714
|
+
$mol_assert_equal(closed.byteLength, data.byteLength + $mol_crypto_secret.extra);
|
|
709
715
|
},
|
|
710
716
|
async 'decrypt self encrypted with auto generated key'() {
|
|
711
|
-
const cipher = await
|
|
717
|
+
const cipher = await $mol_crypto_secret.generate();
|
|
712
718
|
const data = new Uint8Array([1, 2, 3]);
|
|
713
|
-
const salt =
|
|
719
|
+
const salt = $mol_crypto_salt();
|
|
714
720
|
const closed = await cipher.encrypt(data, salt);
|
|
715
721
|
const opened = await cipher.decrypt(closed, salt);
|
|
716
|
-
|
|
722
|
+
$mol_assert_like(data, new Uint8Array(opened));
|
|
717
723
|
},
|
|
718
724
|
async 'decrypt encrypted with exported auto generated key'() {
|
|
719
725
|
const data = new Uint8Array([1, 2, 3]);
|
|
720
|
-
const salt =
|
|
721
|
-
const Alice = await
|
|
726
|
+
const salt = $mol_crypto_salt();
|
|
727
|
+
const Alice = await $mol_crypto_secret.generate();
|
|
722
728
|
const closed = await Alice.encrypt(data, salt);
|
|
723
|
-
const Bob = await
|
|
729
|
+
const Bob = await $mol_crypto_secret.from(await Alice.serial());
|
|
724
730
|
const opened = await Bob.decrypt(closed, salt);
|
|
725
|
-
|
|
731
|
+
$mol_assert_like(data, new Uint8Array(opened));
|
|
726
732
|
},
|
|
727
733
|
});
|
|
728
734
|
})($ || ($ = {}));
|
|
729
|
-
//secret.test.
|
|
735
|
+
//mol/crypto/secret/secret.test.ts
|
|
730
736
|
;
|
|
731
737
|
"use strict";
|
|
732
738
|
var $;
|
|
733
739
|
(function ($) {
|
|
734
|
-
|
|
740
|
+
$mol_test({
|
|
735
741
|
async 'sizes'() {
|
|
736
|
-
const pair = await
|
|
742
|
+
const pair = await $$.$mol_crypto_cipher_pair();
|
|
737
743
|
const key_private = await pair.private.serial();
|
|
738
|
-
|
|
739
|
-
|
|
744
|
+
$mol_assert_ok(key_private.byteLength > 630);
|
|
745
|
+
$mol_assert_ok(key_private.byteLength < 640);
|
|
740
746
|
const key_public = await pair.public.serial();
|
|
741
|
-
|
|
747
|
+
$mol_assert_equal(key_public.byteLength, $mol_crypto_cipher_public.size);
|
|
742
748
|
const data = new Uint8Array([1, 2, 3]);
|
|
743
749
|
const closed = await pair.public.encrypt(data);
|
|
744
|
-
|
|
750
|
+
$mol_assert_equal(closed.byteLength, $mol_crypto_cipher_ecrypted_size);
|
|
745
751
|
},
|
|
746
752
|
async 'decrypt self encrypted with auto generated key'() {
|
|
747
|
-
const pair = await
|
|
753
|
+
const pair = await $$.$mol_crypto_cipher_pair();
|
|
748
754
|
const data = new Uint8Array([1, 2, 3]);
|
|
749
755
|
const closed = await pair.public.encrypt(data);
|
|
750
756
|
const opened = await pair.private.decrypt(closed);
|
|
751
|
-
|
|
757
|
+
$mol_assert_like(data, new Uint8Array(opened));
|
|
752
758
|
},
|
|
753
759
|
async 'decrypt encrypted with exported auto generated key'() {
|
|
754
|
-
const pair = await
|
|
760
|
+
const pair = await $$.$mol_crypto_cipher_pair();
|
|
755
761
|
const data = new Uint8Array([1, 2, 3]);
|
|
756
|
-
const Alice = await
|
|
762
|
+
const Alice = await $mol_crypto_cipher_public.from(await pair.public.serial());
|
|
757
763
|
const closed = await Alice.encrypt(data);
|
|
758
|
-
const Bob = await
|
|
764
|
+
const Bob = await $mol_crypto_cipher_private.from(await pair.private.serial());
|
|
759
765
|
const opened = await Bob.decrypt(closed);
|
|
760
|
-
|
|
766
|
+
$mol_assert_like(data, new Uint8Array(opened));
|
|
761
767
|
},
|
|
762
768
|
});
|
|
763
769
|
})($ || ($ = {}));
|
|
764
|
-
//cipher.test.
|
|
770
|
+
//mol/crypto/cipher/cipher.test.ts
|
|
765
771
|
;
|
|
766
772
|
"use strict";
|
|
767
773
|
var $;
|
|
768
774
|
(function ($) {
|
|
769
|
-
|
|
775
|
+
$mol_test({
|
|
770
776
|
async 'sizes'() {
|
|
771
|
-
const pair = await
|
|
777
|
+
const pair = await $$.$mol_crypto_auditor_pair();
|
|
772
778
|
const key_private = await pair.private.serial();
|
|
773
|
-
|
|
779
|
+
$mol_assert_equal(key_private.byteLength, $mol_crypto_auditor_private.size);
|
|
774
780
|
const key_public = await pair.public.serial();
|
|
775
|
-
|
|
781
|
+
$mol_assert_equal(key_public.byteLength, $mol_crypto_auditor_public.size);
|
|
776
782
|
const data = new Uint8Array([1, 2, 3]);
|
|
777
783
|
const sign = await pair.private.sign(data);
|
|
778
|
-
|
|
784
|
+
$mol_assert_equal(sign.byteLength, $mol_crypto_auditor_sign_size);
|
|
779
785
|
},
|
|
780
786
|
async 'verify self signed with auto generated key'() {
|
|
781
|
-
const auditor = await
|
|
787
|
+
const auditor = await $$.$mol_crypto_auditor_pair();
|
|
782
788
|
const data = new Uint8Array([1, 2, 3]);
|
|
783
789
|
const sign = await auditor.private.sign(data);
|
|
784
|
-
|
|
790
|
+
$mol_assert_ok(await auditor.public.verify(data, sign));
|
|
785
791
|
},
|
|
786
792
|
async 'verify signed with exported auto generated key'() {
|
|
787
|
-
const pair = await
|
|
793
|
+
const pair = await $$.$mol_crypto_auditor_pair();
|
|
788
794
|
const data = new Uint8Array([1, 2, 3]);
|
|
789
|
-
const Alice = await
|
|
795
|
+
const Alice = await $mol_crypto_auditor_private.from(await pair.private.serial());
|
|
790
796
|
const sign = await Alice.sign(data);
|
|
791
|
-
const Bob = await
|
|
792
|
-
|
|
797
|
+
const Bob = await $mol_crypto_auditor_public.from(await pair.public.serial());
|
|
798
|
+
$mol_assert_ok(await Bob.verify(data, sign));
|
|
793
799
|
},
|
|
794
800
|
});
|
|
795
801
|
})($ || ($ = {}));
|
|
796
|
-
//auditor.test.
|
|
802
|
+
//mol/crypto/auditor/auditor.test.ts
|
|
797
803
|
;
|
|
798
804
|
"use strict";
|
|
799
805
|
var $;
|
|
@@ -817,18 +823,18 @@ var $;
|
|
|
817
823
|
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
818
824
|
$.$mol_log3_stack = [];
|
|
819
825
|
})($ || ($ = {}));
|
|
820
|
-
//log3.
|
|
826
|
+
//mol/log3/log3.ts
|
|
821
827
|
;
|
|
822
828
|
"use strict";
|
|
823
|
-
//extract.test.
|
|
829
|
+
//mol/type/keys/extract/extract.test.ts
|
|
824
830
|
;
|
|
825
831
|
"use strict";
|
|
826
|
-
//extract.
|
|
832
|
+
//mol/type/keys/extract/extract.ts
|
|
827
833
|
;
|
|
828
834
|
"use strict";
|
|
829
835
|
var $;
|
|
830
836
|
(function ($_1) {
|
|
831
|
-
$
|
|
837
|
+
$mol_test_mocks.push($ => {
|
|
832
838
|
$.$mol_log3_come = () => { };
|
|
833
839
|
$.$mol_log3_done = () => { };
|
|
834
840
|
$.$mol_log3_fail = () => { };
|
|
@@ -837,7 +843,7 @@ var $;
|
|
|
837
843
|
$.$mol_log3_area = () => () => { };
|
|
838
844
|
});
|
|
839
845
|
})($ || ($ = {}));
|
|
840
|
-
//log3.test.
|
|
846
|
+
//mol/log3/log3.test.ts
|
|
841
847
|
;
|
|
842
848
|
"use strict";
|
|
843
849
|
var $;
|
|
@@ -866,12 +872,12 @@ var $;
|
|
|
866
872
|
$.$mol_log3_rise = $mol_log3_web_make('log', 'magenta');
|
|
867
873
|
$.$mol_log3_area = $mol_log3_web_make('group', 'cyan');
|
|
868
874
|
})($ || ($ = {}));
|
|
869
|
-
//log3.web.
|
|
875
|
+
//mol/log3/log3.web.ts
|
|
870
876
|
;
|
|
871
877
|
"use strict";
|
|
872
|
-
//equals.test.
|
|
878
|
+
//mol/type/equals/equals.test.ts
|
|
873
879
|
;
|
|
874
880
|
"use strict";
|
|
875
|
-
//equals.
|
|
881
|
+
//mol/type/equals/equals.ts
|
|
876
882
|
|
|
877
883
|
//# sourceMappingURL=web.test.js.map
|