jazz-tools 0.9.23 → 0.10.1
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/.turbo/turbo-build.log +10 -12
- package/CHANGELOG.md +27 -0
- package/dist/{chunk-OJIEP4WE.js → chunk-24EJ3CKA.js} +566 -118
- package/dist/chunk-24EJ3CKA.js.map +1 -0
- package/dist/{index.web.js → index.js} +20 -9
- package/dist/index.js.map +1 -0
- package/dist/testing.js +125 -34
- package/dist/testing.js.map +1 -1
- package/package.json +11 -15
- package/src/auth/AuthSecretStorage.ts +109 -0
- package/src/auth/DemoAuth.ts +188 -0
- package/src/auth/InMemoryKVStore.ts +25 -0
- package/src/auth/KvStoreContext.ts +39 -0
- package/src/auth/PassphraseAuth.ts +113 -0
- package/src/coValues/account.ts +8 -3
- package/src/coValues/coFeed.ts +1 -1
- package/src/coValues/coList.ts +1 -1
- package/src/coValues/coMap.ts +1 -1
- package/src/coValues/group.ts +9 -8
- package/src/coValues/interfaces.ts +14 -5
- package/src/exports.ts +17 -3
- package/src/implementation/ContextManager.ts +178 -0
- package/src/implementation/activeAccountContext.ts +6 -1
- package/src/implementation/createContext.ts +173 -149
- package/src/implementation/schema.ts +3 -3
- package/src/index.ts +3 -0
- package/src/testing.ts +172 -34
- package/src/tests/AuthSecretStorage.test.ts +275 -0
- package/src/tests/ContextManager.test.ts +256 -0
- package/src/tests/DemoAuth.test.ts +269 -0
- package/src/tests/PassphraseAuth.test.ts +152 -0
- package/src/tests/coFeed.test.ts +48 -42
- package/src/tests/coList.test.ts +26 -24
- package/src/tests/coMap.test.ts +25 -23
- package/src/tests/coPlainText.test.ts +25 -23
- package/src/tests/coRichText.test.ts +24 -23
- package/src/tests/createContext.test.ts +339 -0
- package/src/tests/deepLoading.test.ts +44 -45
- package/src/tests/fixtures.ts +2050 -0
- package/src/tests/groupsAndAccounts.test.ts +3 -3
- package/src/tests/schema.test.ts +1 -1
- package/src/tests/schemaUnion.test.ts +2 -2
- package/src/tests/subscribe.test.ts +43 -10
- package/src/tests/testing.test.ts +56 -0
- package/src/tests/utils.ts +13 -13
- package/src/types.ts +54 -0
- package/tsconfig.json +3 -1
- package/tsup.config.ts +1 -2
- package/dist/chunk-OJIEP4WE.js.map +0 -1
- package/dist/index.native.js +0 -75
- package/dist/index.native.js.map +0 -1
- package/dist/index.web.js.map +0 -1
- package/src/index.native.ts +0 -6
- package/src/index.web.ts +0 -3
- package/tsconfig.native.json +0 -5
- package/tsconfig.web.json +0 -5
package/src/tests/coFeed.test.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
2
|
import { describe, expect, test } from "vitest";
|
3
3
|
import {
|
4
4
|
Account,
|
@@ -6,19 +6,21 @@ import {
|
|
6
6
|
FileStream,
|
7
7
|
Group,
|
8
8
|
ID,
|
9
|
-
WasmCrypto,
|
10
9
|
co,
|
11
10
|
cojsonInternals,
|
12
|
-
createJazzContext,
|
13
|
-
fixedCredentialsAuth,
|
14
11
|
isControlledAccount,
|
15
|
-
} from "../index.
|
16
|
-
import {
|
12
|
+
} from "../index.js";
|
13
|
+
import {
|
14
|
+
createJazzContextFromExistingCredentials,
|
15
|
+
randomSessionProvider,
|
16
|
+
} from "../internal.js";
|
17
17
|
import { createJazzTestAccount } from "../testing.js";
|
18
18
|
import { setupTwoNodes } from "./utils.js";
|
19
19
|
|
20
20
|
const Crypto = await WasmCrypto.create();
|
21
21
|
|
22
|
+
const connectedPeers = cojsonInternals.connectedPeers;
|
23
|
+
|
22
24
|
describe("Simple CoFeed operations", async () => {
|
23
25
|
const me = await Account.create({
|
24
26
|
creationProps: { name: "Hermes Puggington" },
|
@@ -111,15 +113,16 @@ describe("CoFeed resolution", async () => {
|
|
111
113
|
throw "me is not a controlled account";
|
112
114
|
}
|
113
115
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
114
|
-
const { account: meOnSecondPeer } =
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
116
|
+
const { account: meOnSecondPeer } =
|
117
|
+
await createJazzContextFromExistingCredentials({
|
118
|
+
credentials: {
|
119
|
+
accountID: me.id,
|
120
|
+
secret: me._raw.agentSecret,
|
121
|
+
},
|
122
|
+
sessionProvider: randomSessionProvider,
|
123
|
+
peersToLoadFrom: [initialAsPeer],
|
124
|
+
crypto: Crypto,
|
125
|
+
});
|
123
126
|
|
124
127
|
const loadedStream = await TestStream.load(stream.id, meOnSecondPeer, []);
|
125
128
|
|
@@ -196,15 +199,16 @@ describe("CoFeed resolution", async () => {
|
|
196
199
|
if (!isControlledAccount(me)) {
|
197
200
|
throw "me is not a controlled account";
|
198
201
|
}
|
199
|
-
const { account: meOnSecondPeer } =
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
202
|
+
const { account: meOnSecondPeer } =
|
203
|
+
await createJazzContextFromExistingCredentials({
|
204
|
+
credentials: {
|
205
|
+
accountID: me.id,
|
206
|
+
secret: me._raw.agentSecret,
|
207
|
+
},
|
208
|
+
sessionProvider: randomSessionProvider,
|
209
|
+
peersToLoadFrom: [initialAsPeer],
|
210
|
+
crypto: Crypto,
|
211
|
+
});
|
208
212
|
|
209
213
|
const queue = new cojsonInternals.Channel();
|
210
214
|
|
@@ -315,15 +319,16 @@ describe("FileStream loading & Subscription", async () => {
|
|
315
319
|
throw "me is not a controlled account";
|
316
320
|
}
|
317
321
|
me._raw.core.node.syncManager.addPeer(secondAsPeer);
|
318
|
-
const { account: meOnSecondPeer } =
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
322
|
+
const { account: meOnSecondPeer } =
|
323
|
+
await createJazzContextFromExistingCredentials({
|
324
|
+
credentials: {
|
325
|
+
accountID: me.id,
|
326
|
+
secret: me._raw.agentSecret,
|
327
|
+
},
|
328
|
+
sessionProvider: randomSessionProvider,
|
329
|
+
peersToLoadFrom: [initialAsPeer],
|
330
|
+
crypto: Crypto,
|
331
|
+
});
|
327
332
|
|
328
333
|
const loadedStream = await FileStream.load(stream.id, meOnSecondPeer, []);
|
329
334
|
|
@@ -346,15 +351,16 @@ describe("FileStream loading & Subscription", async () => {
|
|
346
351
|
if (!isControlledAccount(me)) {
|
347
352
|
throw "me is not a controlled account";
|
348
353
|
}
|
349
|
-
const { account: meOnSecondPeer } =
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
354
|
+
const { account: meOnSecondPeer } =
|
355
|
+
await createJazzContextFromExistingCredentials({
|
356
|
+
credentials: {
|
357
|
+
accountID: me.id,
|
358
|
+
secret: me._raw.agentSecret,
|
359
|
+
},
|
360
|
+
sessionProvider: randomSessionProvider,
|
361
|
+
peersToLoadFrom: [initialAsPeer],
|
362
|
+
crypto: Crypto,
|
363
|
+
});
|
358
364
|
|
359
365
|
const queue = new cojsonInternals.Channel();
|
360
366
|
|
package/src/tests/coList.test.ts
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
import {
|
1
|
+
import { cojsonInternals } from "cojson";
|
2
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
3
|
import { describe, expect, test } from "vitest";
|
3
4
|
import {
|
4
5
|
Account,
|
5
6
|
CoList,
|
6
7
|
Group,
|
7
|
-
WasmCrypto,
|
8
8
|
co,
|
9
|
-
|
10
|
-
createJazzContext,
|
11
|
-
fixedCredentialsAuth,
|
9
|
+
createJazzContextFromExistingCredentials,
|
12
10
|
isControlledAccount,
|
13
|
-
} from "../index.
|
11
|
+
} from "../index.js";
|
14
12
|
import { randomSessionProvider } from "../internal.js";
|
15
13
|
|
14
|
+
const connectedPeers = cojsonInternals.connectedPeers;
|
15
|
+
|
16
16
|
const Crypto = await WasmCrypto.create();
|
17
17
|
|
18
18
|
describe("Simple CoList operations", async () => {
|
@@ -170,15 +170,16 @@ describe("CoList resolution", async () => {
|
|
170
170
|
throw "me is not a controlled account";
|
171
171
|
}
|
172
172
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
173
|
-
const { account: meOnSecondPeer } =
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
173
|
+
const { account: meOnSecondPeer } =
|
174
|
+
await createJazzContextFromExistingCredentials({
|
175
|
+
credentials: {
|
176
|
+
accountID: me.id,
|
177
|
+
secret: me._raw.agentSecret,
|
178
|
+
},
|
179
|
+
sessionProvider: randomSessionProvider,
|
180
|
+
peersToLoadFrom: [initialAsPeer],
|
181
|
+
crypto: Crypto,
|
182
|
+
});
|
182
183
|
|
183
184
|
const loadedList = await TestList.load(list.id, meOnSecondPeer, []);
|
184
185
|
|
@@ -241,15 +242,16 @@ describe("CoList resolution", async () => {
|
|
241
242
|
throw "me is not a controlled account";
|
242
243
|
}
|
243
244
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
244
|
-
const { account: meOnSecondPeer } =
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
245
|
+
const { account: meOnSecondPeer } =
|
246
|
+
await createJazzContextFromExistingCredentials({
|
247
|
+
credentials: {
|
248
|
+
accountID: me.id,
|
249
|
+
secret: me._raw.agentSecret,
|
250
|
+
},
|
251
|
+
sessionProvider: randomSessionProvider,
|
252
|
+
peersToLoadFrom: [initialAsPeer],
|
253
|
+
crypto: Crypto,
|
254
|
+
});
|
253
255
|
|
254
256
|
const queue = new cojsonInternals.Channel();
|
255
257
|
|
package/src/tests/coMap.test.ts
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
import {
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
2
|
import { describe, expect, expectTypeOf, test } from "vitest";
|
3
3
|
import { Group, randomSessionProvider } from "../exports.js";
|
4
4
|
import {
|
5
5
|
Account,
|
6
6
|
CoMap,
|
7
7
|
Encoders,
|
8
|
-
WasmCrypto,
|
9
8
|
co,
|
10
9
|
cojsonInternals,
|
11
|
-
|
12
|
-
fixedCredentialsAuth,
|
10
|
+
createJazzContextFromExistingCredentials,
|
13
11
|
isControlledAccount,
|
14
|
-
} from "../index.
|
12
|
+
} from "../index.js";
|
15
13
|
import { setupTwoNodes } from "./utils.js";
|
16
14
|
|
15
|
+
const connectedPeers = cojsonInternals.connectedPeers;
|
16
|
+
|
17
17
|
const Crypto = await WasmCrypto.create();
|
18
18
|
|
19
19
|
class TestMap extends CoMap {
|
@@ -408,15 +408,16 @@ describe("CoMap resolution", async () => {
|
|
408
408
|
throw "me is not a controlled account";
|
409
409
|
}
|
410
410
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
411
|
-
const { account: meOnSecondPeer } =
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
411
|
+
const { account: meOnSecondPeer } =
|
412
|
+
await createJazzContextFromExistingCredentials({
|
413
|
+
credentials: {
|
414
|
+
accountID: me.id,
|
415
|
+
secret: me._raw.agentSecret,
|
416
|
+
},
|
417
|
+
sessionProvider: randomSessionProvider,
|
418
|
+
peersToLoadFrom: [initialAsPeer],
|
419
|
+
crypto: Crypto,
|
420
|
+
});
|
420
421
|
|
421
422
|
const loadedMap = await TestMap.load(map.id, meOnSecondPeer, {});
|
422
423
|
|
@@ -479,15 +480,16 @@ describe("CoMap resolution", async () => {
|
|
479
480
|
throw "me is not a controlled account";
|
480
481
|
}
|
481
482
|
me._raw.core.node.syncManager.addPeer(secondAsPeer);
|
482
|
-
const { account: meOnSecondPeer } =
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
483
|
+
const { account: meOnSecondPeer } =
|
484
|
+
await createJazzContextFromExistingCredentials({
|
485
|
+
credentials: {
|
486
|
+
accountID: me.id,
|
487
|
+
secret: me._raw.agentSecret,
|
488
|
+
},
|
489
|
+
sessionProvider: randomSessionProvider,
|
490
|
+
peersToLoadFrom: [initialAsPeer],
|
491
|
+
crypto: Crypto,
|
492
|
+
});
|
491
493
|
|
492
494
|
const queue = new cojsonInternals.Channel<TestMap>();
|
493
495
|
|
@@ -1,18 +1,18 @@
|
|
1
|
-
import {
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
2
|
import { describe, expect, test } from "vitest";
|
3
3
|
import {
|
4
4
|
Account,
|
5
5
|
CoPlainText,
|
6
|
-
WasmCrypto,
|
7
6
|
cojsonInternals,
|
8
|
-
|
9
|
-
fixedCredentialsAuth,
|
7
|
+
createJazzContextFromExistingCredentials,
|
10
8
|
isControlledAccount,
|
11
|
-
} from "../index.
|
9
|
+
} from "../index.js";
|
12
10
|
import { randomSessionProvider } from "../internal.js";
|
13
11
|
|
14
12
|
const Crypto = await WasmCrypto.create();
|
15
13
|
|
14
|
+
const connectedPeers = cojsonInternals.connectedPeers;
|
15
|
+
|
16
16
|
describe("CoPlainText", () => {
|
17
17
|
const initNodeAndText = async () => {
|
18
18
|
const me = await Account.create({
|
@@ -97,15 +97,16 @@ describe("CoPlainText", () => {
|
|
97
97
|
throw "me is not a controlled account";
|
98
98
|
}
|
99
99
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
100
|
-
const { account: meOnSecondPeer } =
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
100
|
+
const { account: meOnSecondPeer } =
|
101
|
+
await createJazzContextFromExistingCredentials({
|
102
|
+
credentials: {
|
103
|
+
accountID: me.id,
|
104
|
+
secret: me._raw.agentSecret,
|
105
|
+
},
|
106
|
+
sessionProvider: randomSessionProvider,
|
107
|
+
peersToLoadFrom: [initialAsPeer],
|
108
|
+
crypto: Crypto,
|
109
|
+
});
|
109
110
|
|
110
111
|
// Load the text on the second peer
|
111
112
|
const loaded = await CoPlainText.load(id, meOnSecondPeer);
|
@@ -127,15 +128,16 @@ describe("CoPlainText", () => {
|
|
127
128
|
throw "me is not a controlled account";
|
128
129
|
}
|
129
130
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
130
|
-
const { account: meOnSecondPeer } =
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
131
|
+
const { account: meOnSecondPeer } =
|
132
|
+
await createJazzContextFromExistingCredentials({
|
133
|
+
credentials: {
|
134
|
+
accountID: me.id,
|
135
|
+
secret: me._raw.agentSecret,
|
136
|
+
},
|
137
|
+
sessionProvider: randomSessionProvider,
|
138
|
+
peersToLoadFrom: [initialAsPeer],
|
139
|
+
crypto: Crypto,
|
140
|
+
});
|
139
141
|
|
140
142
|
const queue = new cojsonInternals.Channel();
|
141
143
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
2
|
import { describe, expect, test } from "vitest";
|
3
3
|
import { splitNode } from "../coValues/coRichText.js";
|
4
4
|
import {
|
@@ -7,14 +7,13 @@ import {
|
|
7
7
|
Marks,
|
8
8
|
type TextPos,
|
9
9
|
type TreeNode,
|
10
|
-
WasmCrypto,
|
11
10
|
cojsonInternals,
|
12
|
-
|
13
|
-
fixedCredentialsAuth,
|
11
|
+
createJazzContextFromExistingCredentials,
|
14
12
|
isControlledAccount,
|
15
|
-
} from "../index.
|
13
|
+
} from "../index.js";
|
16
14
|
import { randomSessionProvider } from "../internal.js";
|
17
15
|
|
16
|
+
const connectedPeers = cojsonInternals.connectedPeers;
|
18
17
|
const Crypto = await WasmCrypto.create();
|
19
18
|
|
20
19
|
describe("CoRichText", async () => {
|
@@ -592,15 +591,16 @@ describe("CoRichText", async () => {
|
|
592
591
|
throw "me is not a controlled account";
|
593
592
|
}
|
594
593
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
595
|
-
const { account: meOnSecondPeer } =
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
594
|
+
const { account: meOnSecondPeer } =
|
595
|
+
await createJazzContextFromExistingCredentials({
|
596
|
+
credentials: {
|
597
|
+
accountID: me.id,
|
598
|
+
secret: me._raw.agentSecret,
|
599
|
+
},
|
600
|
+
sessionProvider: randomSessionProvider,
|
601
|
+
peersToLoadFrom: [initialAsPeer],
|
602
|
+
crypto: Crypto,
|
603
|
+
});
|
604
604
|
|
605
605
|
const loadedText = await CoRichText.load(text.id, meOnSecondPeer, {
|
606
606
|
marks: [{}],
|
@@ -631,15 +631,16 @@ describe("CoRichText", async () => {
|
|
631
631
|
throw "me is not a controlled account";
|
632
632
|
}
|
633
633
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
634
|
-
const { account: meOnSecondPeer } =
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
634
|
+
const { account: meOnSecondPeer } =
|
635
|
+
await createJazzContextFromExistingCredentials({
|
636
|
+
credentials: {
|
637
|
+
accountID: me.id,
|
638
|
+
secret: me._raw.agentSecret,
|
639
|
+
},
|
640
|
+
sessionProvider: randomSessionProvider,
|
641
|
+
peersToLoadFrom: [initialAsPeer],
|
642
|
+
crypto: Crypto,
|
643
|
+
});
|
643
644
|
|
644
645
|
const queue = new cojsonInternals.Channel<CoRichText>();
|
645
646
|
|