jazz-tools 0.9.23 → 0.10.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/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +19 -0
- package/dist/{chunk-OJIEP4WE.js → chunk-UBD75Z27.js} +566 -118
- package/dist/chunk-UBD75Z27.js.map +1 -0
- package/dist/index.native.js +17 -5
- package/dist/index.native.js.map +1 -1
- package/dist/index.web.js +17 -5
- package/dist/index.web.js.map +1 -1
- package/dist/testing.js +124 -33
- package/dist/testing.js.map +1 -1
- package/package.json +5 -3
- 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/testing.ts +171 -33
- 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 +44 -39
- package/src/tests/coList.test.ts +21 -20
- package/src/tests/coMap.test.ts +21 -20
- package/src/tests/coPlainText.test.ts +21 -20
- package/src/tests/coRichText.test.ts +21 -20
- package/src/tests/createContext.test.ts +339 -0
- package/src/tests/deepLoading.test.ts +41 -42
- package/src/tests/fixtures.ts +2050 -0
- package/src/tests/groupsAndAccounts.test.ts +2 -2
- package/src/tests/subscribe.test.ts +42 -9
- package/src/tests/testing.test.ts +56 -0
- package/src/tests/utils.ts +11 -11
- package/src/types.ts +54 -0
- package/dist/chunk-OJIEP4WE.js.map +0 -1
package/src/tests/coFeed.test.ts
CHANGED
@@ -9,11 +9,12 @@ import {
|
|
9
9
|
WasmCrypto,
|
10
10
|
co,
|
11
11
|
cojsonInternals,
|
12
|
-
createJazzContext,
|
13
|
-
fixedCredentialsAuth,
|
14
12
|
isControlledAccount,
|
15
13
|
} from "../index.web.js";
|
16
|
-
import {
|
14
|
+
import {
|
15
|
+
createJazzContextFromExistingCredentials,
|
16
|
+
randomSessionProvider,
|
17
|
+
} from "../internal.js";
|
17
18
|
import { createJazzTestAccount } from "../testing.js";
|
18
19
|
import { setupTwoNodes } from "./utils.js";
|
19
20
|
|
@@ -111,15 +112,16 @@ describe("CoFeed resolution", async () => {
|
|
111
112
|
throw "me is not a controlled account";
|
112
113
|
}
|
113
114
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
114
|
-
const { account: meOnSecondPeer } =
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
115
|
+
const { account: meOnSecondPeer } =
|
116
|
+
await createJazzContextFromExistingCredentials({
|
117
|
+
credentials: {
|
118
|
+
accountID: me.id,
|
119
|
+
secret: me._raw.agentSecret,
|
120
|
+
},
|
121
|
+
sessionProvider: randomSessionProvider,
|
122
|
+
peersToLoadFrom: [initialAsPeer],
|
123
|
+
crypto: Crypto,
|
124
|
+
});
|
123
125
|
|
124
126
|
const loadedStream = await TestStream.load(stream.id, meOnSecondPeer, []);
|
125
127
|
|
@@ -196,15 +198,16 @@ describe("CoFeed resolution", async () => {
|
|
196
198
|
if (!isControlledAccount(me)) {
|
197
199
|
throw "me is not a controlled account";
|
198
200
|
}
|
199
|
-
const { account: meOnSecondPeer } =
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
201
|
+
const { account: meOnSecondPeer } =
|
202
|
+
await createJazzContextFromExistingCredentials({
|
203
|
+
credentials: {
|
204
|
+
accountID: me.id,
|
205
|
+
secret: me._raw.agentSecret,
|
206
|
+
},
|
207
|
+
sessionProvider: randomSessionProvider,
|
208
|
+
peersToLoadFrom: [initialAsPeer],
|
209
|
+
crypto: Crypto,
|
210
|
+
});
|
208
211
|
|
209
212
|
const queue = new cojsonInternals.Channel();
|
210
213
|
|
@@ -315,15 +318,16 @@ describe("FileStream loading & Subscription", async () => {
|
|
315
318
|
throw "me is not a controlled account";
|
316
319
|
}
|
317
320
|
me._raw.core.node.syncManager.addPeer(secondAsPeer);
|
318
|
-
const { account: meOnSecondPeer } =
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
321
|
+
const { account: meOnSecondPeer } =
|
322
|
+
await createJazzContextFromExistingCredentials({
|
323
|
+
credentials: {
|
324
|
+
accountID: me.id,
|
325
|
+
secret: me._raw.agentSecret,
|
326
|
+
},
|
327
|
+
sessionProvider: randomSessionProvider,
|
328
|
+
peersToLoadFrom: [initialAsPeer],
|
329
|
+
crypto: Crypto,
|
330
|
+
});
|
327
331
|
|
328
332
|
const loadedStream = await FileStream.load(stream.id, meOnSecondPeer, []);
|
329
333
|
|
@@ -346,15 +350,16 @@ describe("FileStream loading & Subscription", async () => {
|
|
346
350
|
if (!isControlledAccount(me)) {
|
347
351
|
throw "me is not a controlled account";
|
348
352
|
}
|
349
|
-
const { account: meOnSecondPeer } =
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
353
|
+
const { account: meOnSecondPeer } =
|
354
|
+
await createJazzContextFromExistingCredentials({
|
355
|
+
credentials: {
|
356
|
+
accountID: me.id,
|
357
|
+
secret: me._raw.agentSecret,
|
358
|
+
},
|
359
|
+
sessionProvider: randomSessionProvider,
|
360
|
+
peersToLoadFrom: [initialAsPeer],
|
361
|
+
crypto: Crypto,
|
362
|
+
});
|
358
363
|
|
359
364
|
const queue = new cojsonInternals.Channel();
|
360
365
|
|
package/src/tests/coList.test.ts
CHANGED
@@ -7,8 +7,7 @@ import {
|
|
7
7
|
WasmCrypto,
|
8
8
|
co,
|
9
9
|
cojsonInternals,
|
10
|
-
|
11
|
-
fixedCredentialsAuth,
|
10
|
+
createJazzContextFromExistingCredentials,
|
12
11
|
isControlledAccount,
|
13
12
|
} from "../index.web.js";
|
14
13
|
import { randomSessionProvider } from "../internal.js";
|
@@ -170,15 +169,16 @@ describe("CoList resolution", async () => {
|
|
170
169
|
throw "me is not a controlled account";
|
171
170
|
}
|
172
171
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
173
|
-
const { account: meOnSecondPeer } =
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
172
|
+
const { account: meOnSecondPeer } =
|
173
|
+
await createJazzContextFromExistingCredentials({
|
174
|
+
credentials: {
|
175
|
+
accountID: me.id,
|
176
|
+
secret: me._raw.agentSecret,
|
177
|
+
},
|
178
|
+
sessionProvider: randomSessionProvider,
|
179
|
+
peersToLoadFrom: [initialAsPeer],
|
180
|
+
crypto: Crypto,
|
181
|
+
});
|
182
182
|
|
183
183
|
const loadedList = await TestList.load(list.id, meOnSecondPeer, []);
|
184
184
|
|
@@ -241,15 +241,16 @@ describe("CoList resolution", async () => {
|
|
241
241
|
throw "me is not a controlled account";
|
242
242
|
}
|
243
243
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
244
|
-
const { account: meOnSecondPeer } =
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
244
|
+
const { account: meOnSecondPeer } =
|
245
|
+
await createJazzContextFromExistingCredentials({
|
246
|
+
credentials: {
|
247
|
+
accountID: me.id,
|
248
|
+
secret: me._raw.agentSecret,
|
249
|
+
},
|
250
|
+
sessionProvider: randomSessionProvider,
|
251
|
+
peersToLoadFrom: [initialAsPeer],
|
252
|
+
crypto: Crypto,
|
253
|
+
});
|
253
254
|
|
254
255
|
const queue = new cojsonInternals.Channel();
|
255
256
|
|
package/src/tests/coMap.test.ts
CHANGED
@@ -8,8 +8,7 @@ import {
|
|
8
8
|
WasmCrypto,
|
9
9
|
co,
|
10
10
|
cojsonInternals,
|
11
|
-
|
12
|
-
fixedCredentialsAuth,
|
11
|
+
createJazzContextFromExistingCredentials,
|
13
12
|
isControlledAccount,
|
14
13
|
} from "../index.web.js";
|
15
14
|
import { setupTwoNodes } from "./utils.js";
|
@@ -408,15 +407,16 @@ describe("CoMap resolution", async () => {
|
|
408
407
|
throw "me is not a controlled account";
|
409
408
|
}
|
410
409
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
411
|
-
const { account: meOnSecondPeer } =
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
410
|
+
const { account: meOnSecondPeer } =
|
411
|
+
await createJazzContextFromExistingCredentials({
|
412
|
+
credentials: {
|
413
|
+
accountID: me.id,
|
414
|
+
secret: me._raw.agentSecret,
|
415
|
+
},
|
416
|
+
sessionProvider: randomSessionProvider,
|
417
|
+
peersToLoadFrom: [initialAsPeer],
|
418
|
+
crypto: Crypto,
|
419
|
+
});
|
420
420
|
|
421
421
|
const loadedMap = await TestMap.load(map.id, meOnSecondPeer, {});
|
422
422
|
|
@@ -479,15 +479,16 @@ describe("CoMap resolution", async () => {
|
|
479
479
|
throw "me is not a controlled account";
|
480
480
|
}
|
481
481
|
me._raw.core.node.syncManager.addPeer(secondAsPeer);
|
482
|
-
const { account: meOnSecondPeer } =
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
482
|
+
const { account: meOnSecondPeer } =
|
483
|
+
await createJazzContextFromExistingCredentials({
|
484
|
+
credentials: {
|
485
|
+
accountID: me.id,
|
486
|
+
secret: me._raw.agentSecret,
|
487
|
+
},
|
488
|
+
sessionProvider: randomSessionProvider,
|
489
|
+
peersToLoadFrom: [initialAsPeer],
|
490
|
+
crypto: Crypto,
|
491
|
+
});
|
491
492
|
|
492
493
|
const queue = new cojsonInternals.Channel<TestMap>();
|
493
494
|
|
@@ -5,8 +5,7 @@ import {
|
|
5
5
|
CoPlainText,
|
6
6
|
WasmCrypto,
|
7
7
|
cojsonInternals,
|
8
|
-
|
9
|
-
fixedCredentialsAuth,
|
8
|
+
createJazzContextFromExistingCredentials,
|
10
9
|
isControlledAccount,
|
11
10
|
} from "../index.web.js";
|
12
11
|
import { randomSessionProvider } from "../internal.js";
|
@@ -97,15 +96,16 @@ describe("CoPlainText", () => {
|
|
97
96
|
throw "me is not a controlled account";
|
98
97
|
}
|
99
98
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
100
|
-
const { account: meOnSecondPeer } =
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
99
|
+
const { account: meOnSecondPeer } =
|
100
|
+
await createJazzContextFromExistingCredentials({
|
101
|
+
credentials: {
|
102
|
+
accountID: me.id,
|
103
|
+
secret: me._raw.agentSecret,
|
104
|
+
},
|
105
|
+
sessionProvider: randomSessionProvider,
|
106
|
+
peersToLoadFrom: [initialAsPeer],
|
107
|
+
crypto: Crypto,
|
108
|
+
});
|
109
109
|
|
110
110
|
// Load the text on the second peer
|
111
111
|
const loaded = await CoPlainText.load(id, meOnSecondPeer);
|
@@ -127,15 +127,16 @@ describe("CoPlainText", () => {
|
|
127
127
|
throw "me is not a controlled account";
|
128
128
|
}
|
129
129
|
me._raw.core.node.syncManager.addPeer(secondPeer);
|
130
|
-
const { account: meOnSecondPeer } =
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
130
|
+
const { account: meOnSecondPeer } =
|
131
|
+
await createJazzContextFromExistingCredentials({
|
132
|
+
credentials: {
|
133
|
+
accountID: me.id,
|
134
|
+
secret: me._raw.agentSecret,
|
135
|
+
},
|
136
|
+
sessionProvider: randomSessionProvider,
|
137
|
+
peersToLoadFrom: [initialAsPeer],
|
138
|
+
crypto: Crypto,
|
139
|
+
});
|
139
140
|
|
140
141
|
const queue = new cojsonInternals.Channel();
|
141
142
|
|
@@ -9,8 +9,7 @@ import {
|
|
9
9
|
type TreeNode,
|
10
10
|
WasmCrypto,
|
11
11
|
cojsonInternals,
|
12
|
-
|
13
|
-
fixedCredentialsAuth,
|
12
|
+
createJazzContextFromExistingCredentials,
|
14
13
|
isControlledAccount,
|
15
14
|
} from "../index.web.js";
|
16
15
|
import { randomSessionProvider } from "../internal.js";
|
@@ -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
|
|