@evolu/common 7.4.1 → 8.0.0-next.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 +4 -61
- package/dist/src/Array.d.ts +343 -102
- package/dist/src/Array.d.ts.map +1 -1
- package/dist/src/Array.js +181 -85
- package/dist/src/Assert.d.ts +57 -11
- package/dist/src/Assert.d.ts.map +1 -1
- package/dist/src/Assert.js +47 -11
- package/dist/src/BigInt.d.ts +6 -1
- package/dist/src/BigInt.d.ts.map +1 -1
- package/dist/src/BigInt.js +5 -0
- package/dist/src/Brand.d.ts +40 -12
- package/dist/src/Brand.d.ts.map +1 -1
- package/dist/src/Brand.js +5 -0
- package/dist/src/Buffer.d.ts +6 -1
- package/dist/src/Buffer.d.ts.map +1 -1
- package/dist/src/Buffer.js +7 -2
- package/dist/src/Cache.d.ts +10 -2
- package/dist/src/Cache.d.ts.map +1 -1
- package/dist/src/Cache.js +6 -0
- package/dist/src/Callbacks.d.ts +10 -7
- package/dist/src/Callbacks.d.ts.map +1 -1
- package/dist/src/Callbacks.js +23 -13
- package/dist/src/Console.d.ts +361 -69
- package/dist/src/Console.d.ts.map +1 -1
- package/dist/src/Console.js +217 -117
- package/dist/src/Crypto.d.ts +70 -21
- package/dist/src/Crypto.d.ts.map +1 -1
- package/dist/src/Crypto.js +72 -27
- package/dist/src/Eq.d.ts +22 -2
- package/dist/src/Eq.d.ts.map +1 -1
- package/dist/src/Eq.js +21 -1
- package/dist/src/Error.d.ts +23 -12
- package/dist/src/Error.d.ts.map +1 -1
- package/dist/src/Error.js +27 -11
- package/dist/src/Function.d.ts +128 -56
- package/dist/src/Function.d.ts.map +1 -1
- package/dist/src/Function.js +118 -14
- package/dist/src/Identicon.d.ts +5 -0
- package/dist/src/Identicon.d.ts.map +1 -1
- package/dist/src/Identicon.js +6 -1
- package/dist/src/Lookup.d.ts +160 -0
- package/dist/src/Lookup.d.ts.map +1 -0
- package/dist/src/Lookup.js +192 -0
- package/dist/src/Microtask.d.ts +21 -0
- package/dist/src/Microtask.d.ts.map +1 -0
- package/dist/src/Microtask.js +37 -0
- package/dist/src/Number.d.ts +18 -4
- package/dist/src/Number.d.ts.map +1 -1
- package/dist/src/Number.js +23 -1
- package/dist/src/Object.d.ts +110 -5
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/Object.js +108 -5
- package/dist/src/Option.d.ts +58 -0
- package/dist/src/Option.d.ts.map +1 -0
- package/dist/src/Option.js +43 -0
- package/dist/src/Order.d.ts +5 -0
- package/dist/src/Order.d.ts.map +1 -1
- package/dist/src/Order.js +8 -3
- package/dist/src/Platform.d.ts +36 -2
- package/dist/src/Platform.d.ts.map +1 -1
- package/dist/src/Platform.js +10 -6
- package/dist/src/Polyfills.d.ts +27 -0
- package/dist/src/Polyfills.d.ts.map +1 -0
- package/dist/src/Polyfills.js +299 -0
- package/dist/src/Random.d.ts +18 -7
- package/dist/src/Random.d.ts.map +1 -1
- package/dist/src/Random.js +9 -7
- package/dist/src/Redacted.d.ts +7 -4
- package/dist/src/Redacted.d.ts.map +1 -1
- package/dist/src/Redacted.js +5 -0
- package/dist/src/Ref.d.ts +31 -16
- package/dist/src/Ref.d.ts.map +1 -1
- package/dist/src/Ref.js +35 -7
- package/dist/src/RefCount.d.ts +62 -0
- package/dist/src/RefCount.d.ts.map +1 -0
- package/dist/src/RefCount.js +83 -0
- package/dist/src/Relation.d.ts +84 -29
- package/dist/src/Relation.d.ts.map +1 -1
- package/dist/src/Relation.js +83 -105
- package/dist/src/Resource.d.ts +263 -0
- package/dist/src/Resource.d.ts.map +1 -0
- package/dist/src/Resource.js +389 -0
- package/dist/src/Result.d.ts +390 -374
- package/dist/src/Result.d.ts.map +1 -1
- package/dist/src/Result.js +142 -70
- package/dist/src/Schedule.d.ts +953 -0
- package/dist/src/Schedule.d.ts.map +1 -0
- package/dist/src/Schedule.js +1199 -0
- package/dist/src/Set.d.ts +181 -0
- package/dist/src/Set.d.ts.map +1 -0
- package/dist/src/Set.js +137 -0
- package/dist/src/Skiplist.d.ts +6 -1
- package/dist/src/Skiplist.d.ts.map +1 -1
- package/dist/src/Skiplist.js +5 -0
- package/dist/src/Sqlite.d.ts +160 -60
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +290 -190
- package/dist/src/Store.d.ts +36 -28
- package/dist/src/Store.d.ts.map +1 -1
- package/dist/src/Store.js +55 -15
- package/dist/src/String.d.ts +5 -0
- package/dist/src/String.d.ts.map +1 -1
- package/dist/src/String.js +5 -0
- package/dist/src/Task.d.ts +2263 -423
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +1488 -348
- package/dist/src/Test.d.ts +122 -0
- package/dist/src/Test.d.ts.map +1 -0
- package/dist/src/Test.js +66 -0
- package/dist/src/Time.d.ts +201 -48
- package/dist/src/Time.d.ts.map +1 -1
- package/dist/src/Time.js +190 -86
- package/dist/src/Tracer.d.ts +48 -0
- package/dist/src/Tracer.d.ts.map +1 -0
- package/dist/src/Tracer.js +6 -0
- package/dist/src/Type.d.ts +582 -209
- package/dist/src/Type.d.ts.map +1 -1
- package/dist/src/Type.js +362 -240
- package/dist/src/Types.d.ts +160 -6
- package/dist/src/Types.d.ts.map +1 -1
- package/dist/src/Types.js +22 -2
- package/dist/src/WebSocket.d.ts +113 -58
- package/dist/src/WebSocket.d.ts.map +1 -1
- package/dist/src/WebSocket.js +210 -118
- package/dist/src/Worker.d.ts +245 -60
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/Worker.js +220 -64
- package/dist/src/index.d.ts +25 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +19 -3
- package/dist/src/local-first/Db.d.ts +24 -213
- package/dist/src/local-first/Db.d.ts.map +1 -1
- package/dist/src/local-first/Db.js +622 -293
- package/dist/src/local-first/Error.d.ts +12 -0
- package/dist/src/local-first/Error.d.ts.map +1 -0
- package/dist/src/local-first/Error.js +6 -0
- package/dist/src/local-first/Evolu.d.ts +330 -285
- package/dist/src/local-first/Evolu.d.ts.map +1 -1
- package/dist/src/local-first/Evolu.js +472 -402
- package/dist/src/local-first/LocalAuth.d.ts +10 -10
- package/dist/src/local-first/LocalAuth.d.ts.map +1 -1
- package/dist/src/local-first/LocalAuth.js +6 -1
- package/dist/src/local-first/Owner.d.ts +70 -27
- package/dist/src/local-first/Owner.d.ts.map +1 -1
- package/dist/src/local-first/Owner.js +27 -14
- package/dist/src/local-first/Protocol.d.ts +58 -50
- package/dist/src/local-first/Protocol.d.ts.map +1 -1
- package/dist/src/local-first/Protocol.js +253 -155
- package/dist/src/local-first/Query.d.ts +133 -43
- package/dist/src/local-first/Query.d.ts.map +1 -1
- package/dist/src/local-first/Query.js +139 -90
- package/dist/src/local-first/Relay.d.ts +18 -38
- package/dist/src/local-first/Relay.d.ts.map +1 -1
- package/dist/src/local-first/Relay.js +59 -171
- package/dist/src/local-first/Schema.d.ts +139 -144
- package/dist/src/local-first/Schema.d.ts.map +1 -1
- package/dist/src/local-first/Schema.js +78 -163
- package/dist/src/local-first/Shared.d.ts +125 -0
- package/dist/src/local-first/Shared.d.ts.map +1 -0
- package/dist/src/local-first/Shared.js +569 -0
- package/dist/src/local-first/Storage.d.ts +50 -53
- package/dist/src/local-first/Storage.d.ts.map +1 -1
- package/dist/src/local-first/Storage.js +121 -173
- package/dist/src/local-first/Timestamp.d.ts +28 -35
- package/dist/src/local-first/Timestamp.d.ts.map +1 -1
- package/dist/src/local-first/Timestamp.js +24 -25
- package/dist/src/local-first/index.d.ts +2 -15
- package/dist/src/local-first/index.d.ts.map +1 -1
- package/dist/src/local-first/index.js +2 -15
- package/package.json +36 -26
- package/src/Array.ts +467 -106
- package/src/Assert.ts +87 -12
- package/src/BigInt.ts +7 -1
- package/src/Brand.ts +41 -12
- package/src/Buffer.ts +10 -4
- package/src/Cache.ts +11 -2
- package/src/Callbacks.ts +33 -23
- package/src/Console.ts +567 -178
- package/src/Crypto.ts +111 -62
- package/src/Eq.ts +30 -3
- package/src/Error.ts +50 -34
- package/src/Function.ts +140 -68
- package/src/Identicon.ts +7 -1
- package/src/Lookup.ts +415 -0
- package/src/Microtask.ts +58 -0
- package/src/Number.ts +40 -7
- package/src/Object.ts +155 -16
- package/src/Option.ts +74 -0
- package/src/Order.ts +11 -3
- package/src/Platform.ts +43 -7
- package/src/Polyfills.ts +465 -0
- package/src/Random.ts +25 -11
- package/src/Redacted.ts +8 -4
- package/src/Ref.ts +72 -21
- package/src/RefCount.ts +170 -0
- package/src/Relation.ts +188 -136
- package/src/Resource.ts +864 -0
- package/src/Result.ts +548 -381
- package/src/Schedule.ts +1471 -0
- package/src/Set.ts +247 -0
- package/src/Skiplist.ts +7 -1
- package/src/Sqlite.ts +409 -304
- package/src/Store.ts +94 -48
- package/src/String.ts +6 -0
- package/src/Task.ts +3685 -740
- package/src/Test.ts +162 -0
- package/src/Time.ts +348 -145
- package/src/Tracer.ts +54 -0
- package/src/Type.ts +851 -430
- package/src/Types.ts +202 -7
- package/src/WebSocket.ts +311 -178
- package/src/Worker.ts +527 -147
- package/src/index.ts +74 -3
- package/src/local-first/Db.ts +871 -597
- package/src/local-first/Error.ts +17 -0
- package/src/local-first/Evolu.ts +884 -824
- package/src/local-first/LocalAuth.ts +10 -10
- package/src/local-first/Owner.ts +94 -42
- package/src/local-first/Protocol.ts +440 -303
- package/src/local-first/Query.ts +243 -194
- package/src/local-first/Relay.ts +91 -252
- package/src/local-first/Schema.ts +284 -394
- package/src/local-first/Shared.ts +932 -0
- package/src/local-first/Storage.ts +206 -277
- package/src/local-first/Timestamp.ts +38 -45
- package/src/local-first/index.ts +2 -16
- package/LICENSE +0 -21
- package/dist/src/Instances.d.ts +0 -34
- package/dist/src/Instances.d.ts.map +0 -1
- package/dist/src/Instances.js +0 -44
- package/dist/src/Resources.d.ts +0 -118
- package/dist/src/Resources.d.ts.map +0 -1
- package/dist/src/Resources.js +0 -197
- package/dist/src/local-first/Platform.d.ts +0 -25
- package/dist/src/local-first/Platform.d.ts.map +0 -1
- package/dist/src/local-first/Platform.js +0 -1
- package/dist/src/local-first/Public.d.ts +0 -22
- package/dist/src/local-first/Public.d.ts.map +0 -1
- package/dist/src/local-first/Public.js +0 -15
- package/dist/src/local-first/PublicKysely.d.ts +0 -148
- package/dist/src/local-first/PublicKysely.d.ts.map +0 -1
- package/dist/src/local-first/PublicKysely.js +0 -184
- package/dist/src/local-first/Sync.d.ts +0 -112
- package/dist/src/local-first/Sync.d.ts.map +0 -1
- package/dist/src/local-first/Sync.js +0 -526
- package/src/Instances.ts +0 -92
- package/src/Resources.ts +0 -367
- package/src/local-first/Platform.ts +0 -27
- package/src/local-first/Public.ts +0 -42
- package/src/local-first/PublicKysely.ts +0 -239
- package/src/local-first/Sync.ts +0 -949
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Console.d.ts","sourceRoot":"","sources":["../../src/Console.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Console.d.ts","sourceRoot":"","sources":["../../src/Console.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,WAAW,OAAO;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAExC;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,YAAY,CAAC;IAEtC;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,KAAK,IAAI,CAAC;IAExD,0EAA0E;IAC1E,QAAQ,CAAC,W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|
34
|
-
|
|
35
|
-
timeLog: (label, ...data) => {
|
|
36
|
-
// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-argument
|
|
37
|
-
if (instance.enabled)
|
|
38
|
-
console.timeLog(label, ...data);
|
|
39
|
-
},
|
|
40
|
-
timeEnd: (label) => {
|
|
41
|
-
// eslint-disable-next-line no-console
|
|
42
|
-
if (instance.enabled)
|
|
43
|
-
console.timeEnd(label);
|
|
44
|
-
},
|
|
45
|
-
dir: (object, options) => {
|
|
46
|
-
// eslint-disable-next-line no-console
|
|
47
|
-
if (instance.enabled)
|
|
48
|
-
console.dir(object, options);
|
|
49
|
-
},
|
|
50
|
-
table: (tabularData, properties) => {
|
|
51
|
-
// eslint-disable-next-line no-console
|
|
52
|
-
if (instance.enabled)
|
|
53
|
-
console.table(tabularData, properties);
|
|
54
|
-
},
|
|
55
|
-
count: (label) => {
|
|
56
|
-
// eslint-disable-next-line no-console
|
|
57
|
-
if (instance.enabled)
|
|
58
|
-
console.count(label);
|
|
59
|
-
},
|
|
60
|
-
countReset: (label) => {
|
|
61
|
-
// eslint-disable-next-line no-console
|
|
62
|
-
if (instance.enabled)
|
|
63
|
-
console.countReset(label);
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic console with structured logging.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { objectFrom } from "./Object.js";
|
|
7
|
+
import { createStore } from "./Store.js";
|
|
8
|
+
import { createTime, formatMillisAsClockTime, formatMillisAsDuration, } from "./Time.js";
|
|
9
|
+
const levelOrder = {
|
|
10
|
+
trace: 0,
|
|
11
|
+
debug: 1,
|
|
12
|
+
log: 2,
|
|
13
|
+
info: 3,
|
|
14
|
+
warn: 4,
|
|
15
|
+
error: 5,
|
|
16
|
+
silent: 6,
|
|
17
|
+
};
|
|
18
|
+
/** Creates a {@link Console}. */
|
|
19
|
+
export const createConsole = ({ name = "", level = "log", output = createNativeConsoleOutput(), path = [], formatter, } = {}) => {
|
|
20
|
+
const childrenSet = new Set();
|
|
21
|
+
let ownLevel = null;
|
|
22
|
+
const getLevel = () => ownLevel ?? level;
|
|
23
|
+
const createMethod = (method, methodLevel, formatter) => (...args) => {
|
|
24
|
+
if (levelOrder[methodLevel] >= levelOrder[getLevel()])
|
|
25
|
+
output.write({ method, path, args }, formatter);
|
|
26
|
+
};
|
|
27
|
+
const levelMethod = (method) => createMethod(method, method, formatter);
|
|
28
|
+
const debugMethod = (method) => createMethod(method, "debug");
|
|
29
|
+
return {
|
|
30
|
+
name,
|
|
31
|
+
children: childrenSet,
|
|
32
|
+
getLevel,
|
|
33
|
+
setLevel: (level) => {
|
|
34
|
+
ownLevel = level;
|
|
64
35
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
36
|
+
hasOwnLevel: () => ownLevel !== null,
|
|
37
|
+
child: (name) => {
|
|
38
|
+
const childConsole = createConsole({
|
|
39
|
+
name,
|
|
40
|
+
level,
|
|
41
|
+
output,
|
|
42
|
+
path: [...path, name],
|
|
43
|
+
...(formatter && { formatter }),
|
|
44
|
+
});
|
|
45
|
+
childrenSet.add(childConsole);
|
|
46
|
+
return childConsole;
|
|
69
47
|
},
|
|
70
|
-
trace
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
48
|
+
...objectFrom(["trace", "debug", "log", "info", "warn", "error"], levelMethod),
|
|
49
|
+
...objectFrom(["dir", "table", "time", "timeLog", "timeEnd", "count", "countReset"], debugMethod),
|
|
50
|
+
write: (entry) => {
|
|
51
|
+
output.write(entry, formatter);
|
|
74
52
|
},
|
|
75
53
|
};
|
|
76
|
-
return instance;
|
|
77
54
|
};
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Creates a {@link ConsoleOutput} that writes to `globalThis.console`.
|
|
57
|
+
*
|
|
58
|
+
* Pure transport - just calls the native console method with the entry args.
|
|
59
|
+
* Use {@link createConsoleFormatter} with {@link ConsoleConfig.formatter} for
|
|
60
|
+
* timestamps and path prefixes.
|
|
61
|
+
*
|
|
62
|
+
* ### Example
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* const output = createNativeConsoleOutput();
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export const createNativeConsoleOutput = () => ({
|
|
69
|
+
write: (entry, formatter) => {
|
|
70
|
+
const args = formatter ? formatter(entry) : entry.args;
|
|
71
|
+
const fn = globalThis.console[entry.method];
|
|
72
|
+
fn(...args);
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Creates a {@link ConsoleFormatter} for {@link ConsoleConfig.formatter}.
|
|
77
|
+
*
|
|
78
|
+
* Prepends timestamps and path prefixes to entry args.
|
|
79
|
+
*
|
|
80
|
+
* ### Example
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* const root = createConsole({
|
|
84
|
+
* formatter: createConsoleFormatter()({
|
|
85
|
+
* timestampFormat: "relative",
|
|
86
|
+
* }),
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* // Relative — elapsed since start
|
|
90
|
+
* const relay = root.child("relay");
|
|
91
|
+
* relay.log("connected"); // +0.000s [relay] connected
|
|
92
|
+
* relay.log("synced"); // +1.500s [relay] synced
|
|
93
|
+
*
|
|
94
|
+
* // Nested children
|
|
95
|
+
* const db = relay.child("db");
|
|
96
|
+
* db.log("opened"); // +1.500s [relay] [db] opened
|
|
97
|
+
*
|
|
98
|
+
* // Absolute — local clock time (HH:MM:SS.mmm)
|
|
99
|
+
* // relay.log("connected"); // 15:30:15.123 [relay] connected
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export const createConsoleFormatter = ({ time = createTime() } = {}) => (config = {}) => {
|
|
103
|
+
const format = config.timestampFormat ?? "none";
|
|
104
|
+
let startTime = config.startTime;
|
|
105
|
+
return (entry) => {
|
|
106
|
+
const now = time.now();
|
|
107
|
+
startTime ??= now;
|
|
108
|
+
let timestamp;
|
|
109
|
+
switch (format) {
|
|
110
|
+
case "none":
|
|
111
|
+
timestamp = "";
|
|
112
|
+
break;
|
|
113
|
+
case "relative":
|
|
114
|
+
timestamp = `+${formatMillisAsDuration((now - startTime))}`;
|
|
115
|
+
break;
|
|
116
|
+
case "absolute":
|
|
117
|
+
timestamp = formatMillisAsClockTime(now);
|
|
118
|
+
break;
|
|
119
|
+
case "iso":
|
|
120
|
+
timestamp = new globalThis.Date(now).toISOString();
|
|
121
|
+
break;
|
|
112
122
|
}
|
|
123
|
+
const path = entry.path.length > 0 ? entry.path.map((p) => `[${p}]`).join(" ") : "";
|
|
124
|
+
const prefix = timestamp && path ? `${timestamp} ${path}` : timestamp || path;
|
|
125
|
+
return prefix ? [prefix, ...entry.args] : entry.args;
|
|
113
126
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
};
|
|
128
|
+
/** Creates a {@link ConsoleStoreOutput}. */
|
|
129
|
+
export const createConsoleStoreOutput = () => {
|
|
130
|
+
const entry = createStore(null);
|
|
131
|
+
return {
|
|
132
|
+
write: entry.set,
|
|
133
|
+
entry,
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Creates a {@link ConsoleOutput} that captures entries to an array.
|
|
138
|
+
*
|
|
139
|
+
* Useful for testing. Pass your own array to inspect captured entries.
|
|
140
|
+
*
|
|
141
|
+
* ### Example
|
|
142
|
+
*
|
|
143
|
+
* ```ts
|
|
144
|
+
* const entries: Array<ConsoleEntry> = [];
|
|
145
|
+
* const output = createConsoleArrayOutput(entries);
|
|
146
|
+
*
|
|
147
|
+
* // After logging...
|
|
148
|
+
* expect(entries).toMatchInlineSnapshot();
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export const createConsoleArrayOutput = (entries) => ({
|
|
152
|
+
write: (entry) => {
|
|
153
|
+
entries.push(entry);
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
/**
|
|
157
|
+
* Creates a {@link ConsoleOutput} that fans out to multiple outputs.
|
|
158
|
+
*
|
|
159
|
+
* Each entry is written to all outputs in order. Useful for combining a native
|
|
160
|
+
* console output with a store output for forwarding.
|
|
161
|
+
*
|
|
162
|
+
* ### Example
|
|
163
|
+
*
|
|
164
|
+
* ```ts
|
|
165
|
+
* const storeOutput = createConsoleStoreOutput();
|
|
166
|
+
* const console = createConsole({
|
|
167
|
+
* output: createMultiOutput([createNativeConsoleOutput(), storeOutput]),
|
|
168
|
+
* });
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export const createMultiOutput = (outputs) => ({
|
|
172
|
+
write: (entry, formatter) => {
|
|
173
|
+
for (const output of outputs)
|
|
174
|
+
output.write(entry, formatter);
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
/**
|
|
178
|
+
* Creates a {@link TestConsole} that captures all output for testing.
|
|
179
|
+
*
|
|
180
|
+
* Unlike {@link createConsole}, this doesn't require dependencies and uses a
|
|
181
|
+
* simple incrementing counter for timestamps (starting at 0).
|
|
182
|
+
*
|
|
183
|
+
* ### Example
|
|
184
|
+
*
|
|
185
|
+
* ```ts
|
|
186
|
+
* test("logging", () => {
|
|
187
|
+
* const console = testCreateConsole();
|
|
188
|
+
* console.info("Hello");
|
|
189
|
+
*
|
|
190
|
+
* expect(console.getEntriesSnapshot()).toMatchInlineSnapshot(`
|
|
191
|
+
* [
|
|
192
|
+
* {
|
|
193
|
+
* "method": "info",
|
|
194
|
+
* "path": [],
|
|
195
|
+
* "args": ["Hello"]
|
|
196
|
+
* }
|
|
197
|
+
* ]
|
|
198
|
+
* `);
|
|
199
|
+
* });
|
|
200
|
+
*
|
|
201
|
+
* test("level filtering", () => {
|
|
202
|
+
* const console = testCreateConsole({ level: "warn" });
|
|
203
|
+
* console.debug("ignored");
|
|
204
|
+
* console.warn("logged");
|
|
205
|
+
* expect(console.getEntriesSnapshot()).toHaveLength(1);
|
|
206
|
+
* });
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
export const testCreateConsole = ({ level = "trace", } = {}) => {
|
|
210
|
+
const entries = [];
|
|
211
|
+
const console = createConsole({
|
|
212
|
+
level,
|
|
213
|
+
output: createConsoleArrayOutput(entries),
|
|
214
|
+
});
|
|
215
|
+
return {
|
|
216
|
+
...console,
|
|
217
|
+
getEntriesSnapshot: () => {
|
|
218
|
+
const snapshot = [...entries];
|
|
219
|
+
entries.length = 0;
|
|
220
|
+
return snapshot;
|
|
221
|
+
},
|
|
222
|
+
clearEntries: () => {
|
|
223
|
+
entries.length = 0;
|
|
224
|
+
},
|
|
117
225
|
};
|
|
118
|
-
// Override methods that should have timestamps
|
|
119
|
-
console.log = withTimestamp(console.log);
|
|
120
|
-
console.info = withTimestamp(console.info);
|
|
121
|
-
console.warn = withTimestamp(console.warn);
|
|
122
|
-
console.error = withTimestamp(console.error);
|
|
123
|
-
console.debug = withTimestamp(console.debug);
|
|
124
|
-
console.trace = withTimestamp(console.trace);
|
|
125
|
-
return console;
|
|
126
226
|
};
|
package/dist/src/Crypto.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic utilities.
|
|
3
|
+
*
|
|
4
|
+
* Type-safe cryptographic operations including random bytes generation, SLIP21
|
|
5
|
+
* key derivation, XChaCha20-Poly1305 symmetric encryption, PADMÉ padding, and
|
|
6
|
+
* timing-safe comparisons.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { RandomLibDep } from "./Random.js";
|
|
11
|
+
import type { Result } from "./Result.js";
|
|
12
|
+
import { NonNegativeInt, type Typed } from "./Type.js";
|
|
3
13
|
export interface RandomBytes {
|
|
4
14
|
/**
|
|
5
15
|
* Creates cryptographically secure random bytes with type-safe length
|
|
@@ -9,11 +19,12 @@ export interface RandomBytes {
|
|
|
9
19
|
* generator (crypto.getRandomValues) to generate high-quality entropy
|
|
10
20
|
* suitable for cryptographic operations.
|
|
11
21
|
*
|
|
12
|
-
*
|
|
22
|
+
* ## Type Safety
|
|
13
23
|
*
|
|
14
24
|
* Returns specific branded types for common sizes:
|
|
15
25
|
*
|
|
16
26
|
* - `Random16` for 16-byte values (128 bits)
|
|
27
|
+
* - `Random24` for 24-byte values (192 bits)
|
|
17
28
|
* - `Random32` for 32-byte values (256 bits)
|
|
18
29
|
* - `Random64` for 64-byte values (512 bits)
|
|
19
30
|
* - `Random` for any other size
|
|
@@ -22,12 +33,14 @@ export interface RandomBytes {
|
|
|
22
33
|
*
|
|
23
34
|
* ```ts
|
|
24
35
|
* const nonce = randomBytes.create(16); // Type: Random16
|
|
36
|
+
* const nonce24 = randomBytes.create(24); // Type: Random24
|
|
25
37
|
* const key = randomBytes.create(32); // Type: Random32
|
|
26
38
|
* const seed = randomBytes.create(64); // Type: Random64
|
|
27
39
|
* const custom = randomBytes.create(48); // Type: Random
|
|
28
40
|
* ```
|
|
29
41
|
*/
|
|
30
42
|
create(bytesLength: 16): Entropy16;
|
|
43
|
+
create(bytesLength: 24): Entropy24;
|
|
31
44
|
create(bytesLength: 32): Entropy32;
|
|
32
45
|
create(bytesLength: 64): Entropy64;
|
|
33
46
|
create(bytesLength: number): Entropy;
|
|
@@ -39,11 +52,15 @@ declare const Entropy: import("./Type.js").BrandType<import("./Type.js").Type<"U
|
|
|
39
52
|
type Entropy = typeof Entropy.Type;
|
|
40
53
|
export declare const Entropy16: import("./Type.js").BrandType<import("./Type.js").Type<"Brand", Uint8Array<ArrayBufferLike> & import("./Brand.js").Brand<"Entropy">, Uint8Array<ArrayBufferLike>, import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError>, Uint8Array<ArrayBufferLike>, never>, "Length16", import("./Type.js").LengthError<16>, import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError>>;
|
|
41
54
|
export type Entropy16 = typeof Entropy16.Type;
|
|
55
|
+
export declare const Entropy24: import("./Type.js").BrandType<import("./Type.js").Type<"Brand", Uint8Array<ArrayBufferLike> & import("./Brand.js").Brand<"Entropy">, Uint8Array<ArrayBufferLike>, import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError>, Uint8Array<ArrayBufferLike>, never>, "Length24", import("./Type.js").LengthError<24>, import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError>>;
|
|
56
|
+
export type Entropy24 = typeof Entropy24.Type;
|
|
42
57
|
export declare const Entropy32: import("./Type.js").BrandType<import("./Type.js").Type<"Brand", Uint8Array<ArrayBufferLike> & import("./Brand.js").Brand<"Entropy">, Uint8Array<ArrayBufferLike>, import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError>, Uint8Array<ArrayBufferLike>, never>, "Length32", import("./Type.js").LengthError<32>, import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError>>;
|
|
43
58
|
export type Entropy32 = typeof Entropy32.Type;
|
|
44
59
|
export declare const Entropy64: import("./Type.js").BrandType<import("./Type.js").Type<"Brand", Uint8Array<ArrayBufferLike> & import("./Brand.js").Brand<"Entropy">, Uint8Array<ArrayBufferLike>, import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError>, Uint8Array<ArrayBufferLike>, never>, "Length64", import("./Type.js").LengthError<64>, import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError>>;
|
|
45
60
|
export type Entropy64 = typeof Entropy64.Type;
|
|
46
61
|
export declare const createRandomBytes: () => RandomBytes;
|
|
62
|
+
/** Creates seeded random bytes for deterministic tests. */
|
|
63
|
+
export declare const testCreateRandomBytes: (deps: RandomLibDep) => RandomBytes;
|
|
47
64
|
/**
|
|
48
65
|
* SLIP21.
|
|
49
66
|
*
|
|
@@ -56,31 +73,63 @@ export declare const createSlip21: (seed: Entropy16 | Entropy32 | Entropy64, pat
|
|
|
56
73
|
* @see {@link createSlip21}
|
|
57
74
|
*/
|
|
58
75
|
export declare const deriveSlip21Node: (label: string, parentNode: Entropy64) => Entropy64;
|
|
59
|
-
/** The encryption key for
|
|
76
|
+
/** The encryption key for symmetric encryption. */
|
|
60
77
|
export declare const EncryptionKey: import("./Type.js").BrandType<import("./Type.js").BrandType<import("./Type.js").Type<"Brand", Uint8Array<ArrayBufferLike> & import("./Brand.js").Brand<"Entropy">, Uint8Array<ArrayBufferLike>, import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError>, Uint8Array<ArrayBufferLike>, never>, "Length32", import("./Type.js").LengthError<32>, import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError>>, "EncryptionKey", import("./Type.js").BrandWithoutRefineError<"EncryptionKey", import("./Type.js").BrandWithoutRefineError<"Entropy", import("./Type.js").Uint8ArrayError> | import("./Type.js").LengthError<32>>, never>;
|
|
61
78
|
export type EncryptionKey = typeof EncryptionKey.Type;
|
|
62
|
-
/**
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
/** The nonce length for XChaCha20-Poly1305 encryption. */
|
|
80
|
+
export declare const xChaCha20Poly1305NonceLength = 24;
|
|
81
|
+
/**
|
|
82
|
+
* Branded Uint8Array for XChaCha20-Poly1305 encryption.
|
|
83
|
+
*
|
|
84
|
+
* @see {@link encryptWithXChaCha20Poly1305}
|
|
85
|
+
*/
|
|
86
|
+
export declare const XChaCha20Poly1305Ciphertext: import("./Type.js").BrandType<import("./Type.js").Type<"Uint8Array", Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, import("./Type.js").Uint8ArrayError, Uint8Array<ArrayBufferLike>, import("./Type.js").Uint8ArrayError>, "XChaCha20Poly1305Ciphertext", import("./Type.js").BrandWithoutRefineError<"XChaCha20Poly1305Ciphertext", import("./Type.js").Uint8ArrayError>, never>;
|
|
87
|
+
export type XChaCha20Poly1305Ciphertext = typeof XChaCha20Poly1305Ciphertext.Type;
|
|
88
|
+
/**
|
|
89
|
+
* Encrypts plaintext with XChaCha20-Poly1305.
|
|
90
|
+
*
|
|
91
|
+
* Generates a random nonce internally and returns both the ciphertext and
|
|
92
|
+
* nonce. The nonce must be stored alongside the ciphertext for decryption.
|
|
93
|
+
*
|
|
94
|
+
* ### Example
|
|
95
|
+
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* const deps = { randomBytes: createRandomBytes() };
|
|
98
|
+
* const [ciphertext, nonce] = encryptWithXChaCha20Poly1305(deps)(
|
|
99
|
+
* utf8ToBytes("secret message"),
|
|
100
|
+
* encryptionKey,
|
|
101
|
+
* );
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @see https://github.com/paulmillr/noble-ciphers
|
|
105
|
+
*/
|
|
106
|
+
export declare const encryptWithXChaCha20Poly1305: (deps: RandomBytesDep) => (plaintext: Uint8Array, encryptionKey: EncryptionKey) => [XChaCha20Poly1305Ciphertext, Entropy24];
|
|
107
|
+
export interface DecryptWithXChaCha20Poly1305Error extends Typed<"DecryptWithXChaCha20Poly1305Error"> {
|
|
76
108
|
readonly error: unknown;
|
|
77
109
|
}
|
|
78
110
|
/**
|
|
79
|
-
* XChaCha20-Poly1305
|
|
111
|
+
* Decrypts ciphertext with XChaCha20-Poly1305.
|
|
112
|
+
*
|
|
113
|
+
* Requires the same nonce that was used during encryption. Returns a
|
|
114
|
+
* {@link Result} that may contain a decryption error if the ciphertext was
|
|
115
|
+
* tampered with or the wrong key/nonce was used.
|
|
116
|
+
*
|
|
117
|
+
* ### Example
|
|
80
118
|
*
|
|
81
|
-
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* const result = decryptWithXChaCha20Poly1305(
|
|
121
|
+
* ciphertext,
|
|
122
|
+
* nonce,
|
|
123
|
+
* encryptionKey,
|
|
124
|
+
* );
|
|
125
|
+
* if (!result.ok) {
|
|
126
|
+
* // Handle decryption error
|
|
127
|
+
* return result;
|
|
128
|
+
* }
|
|
129
|
+
* const plaintext = result.value;
|
|
130
|
+
* ```
|
|
82
131
|
*/
|
|
83
|
-
export declare const
|
|
132
|
+
export declare const decryptWithXChaCha20Poly1305: (ciphertext: XChaCha20Poly1305Ciphertext, nonce: Entropy24, encryptionKey: EncryptionKey) => Result<Uint8Array, DecryptWithXChaCha20Poly1305Error>;
|
|
84
133
|
/**
|
|
85
134
|
* Returns the PADMÉ padded length for a given input length.
|
|
86
135
|
*
|
package/dist/src/Crypto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Crypto.d.ts","sourceRoot":"","sources":["../../src/Crypto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Crypto.d.ts","sourceRoot":"","sources":["../../src/Crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAGL,cAAc,EAEd,KAAK,KAAK,EAEX,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;;;;;;;;;;;;;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