jazz-tools 0.8.32 → 0.8.35

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.8.35
4
+
5
+ ### Patch Changes
6
+
7
+ - 8b87117: Implement Group Inheritance
8
+ - Updated dependencies [3f15a23]
9
+ - Updated dependencies [46f2ab8]
10
+ - Updated dependencies [8b87117]
11
+ - Updated dependencies [a6b6ccf]
12
+ - cojson@0.8.35
13
+
14
+ ## 0.8.34
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [e4f110f]
19
+ - cojson@0.8.34
20
+
3
21
  ## 0.8.32
4
22
 
5
23
  ### Patch Changes
@@ -60,6 +60,10 @@ export class Group extends CoValueBase {
60
60
  this._raw.addMember(member === "everyone" ? member : member._raw, role);
61
61
  return this;
62
62
  }
63
+ removeMember(member) {
64
+ this._raw.removeMember(member === "everyone" ? member : member._raw);
65
+ return this;
66
+ }
63
67
  get members() {
64
68
  return this._raw
65
69
  .keys()
@@ -82,6 +86,10 @@ export class Group extends CoValueBase {
82
86
  };
83
87
  });
84
88
  }
89
+ extend(parent) {
90
+ this._raw.extend(parent._raw);
91
+ return this;
92
+ }
85
93
  /** @category Subscription & Loading */
86
94
  static load(id, as, depth) {
87
95
  return loadCoValue(this, id, as, depth);
@@ -1 +1 @@
1
- {"version":3,"file":"group.js","sourceRoot":"","sources":["../../../src/coValues/group.ts"],"names":[],"mappings":";AAUA,OAAO,EACL,OAAO,EACP,2BAA2B,EAC3B,KAAK,EACL,WAAW,EACX,UAAU,EACV,GAAG,EACH,EAAE,EACF,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAExB,uCAAuC;AACvC,MAAM,OAAO,OAAQ,SAAQ,KAAK;IAAlC;;QACE,SAAI,GAAG,EAAE,CAAC,MAAM,CAAC;IACnB,CAAC;CAAA;AAED,uCAAuC;AACvC,M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D,OAAO,kBAAkB,CAAW,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC;IAED,uCAAuC;IACvC,YAAY,CAEV,KAA0B;QAE1B,OAAO,mBAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,uCAAuC;IACvC,SAAS,CAEP,KAA0B,EAC1B,QAAiD;QAEjD,OAAO,0BAA0B,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACF;;AA3LC;IACE,GAAK,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC;AACjC,CAAC,GAAA,CAAA;AAYD;IACE,GAAK,OAAO,GAAG;QACb,OAAO,EAAE,MAAuB;QAChC,IAAI,EAAE,MAAuB;QAC7B,CAAC,UAAU,CAAC,EAAE;YACZ,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO;YAClB,QAAQ,EAAE,KAAK;SACc;QAC/B,8DAA8D;KACxD,CAAC;IACT,MAAM,CAAC,cAAc,CAAC,GAAK,SAAS,EAAE,SAAS,EAAE;QAC/C,GAAG,EAAE,GAAG,EAAE,CAAC,GAAK,OAAO;KACxB,CAAC,CAAC;AACL,CAAC,GAAA,CAAA"}
@@ -108,12 +108,20 @@ export function subscribeToCoValue(cls, id, as, depth, listener, onUnavailable)
108
108
  }
109
109
  export function createCoValueObservable() {
110
110
  let currentValue = undefined;
111
+ let subscriberCount = 0;
111
112
  function subscribe(cls, id, as, depth, listener, onUnavailable) {
113
+ subscriberCount++;
112
114
  const unsubscribe = subscribeToCoValue(cls, id, as, depth, (value) => {
113
115
  currentValue = value;
114
116
  listener();
115
117
  }, onUnavailable);
116
- return unsubscribe;
118
+ return () => {
119
+ unsubscribe();
120
+ subscriberCount--;
121
+ if (subscriberCount === 0) {
122
+ currentValue = undefined;
123
+ }
124
+ };
117
125
  }
118
126
  const observable = {
119
127
  getCurrentValue: () => currentValue,
@@ -1 +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nC,SAAS;KACV,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,QAAW,EACX,KAA0B,EAC1B,QAAiD;IAEjD,OAAO,kBAAkB,CACvB,QAAQ,CAAC,WAA8B,EACvC,QAAQ,CAAC,EAAE,EACX,QAAQ,CAAC,SAAS,EAClB,KAAK,EACL,QAAQ,CACT,CAAC;AACJ,CAAC"}
@@ -60,6 +60,10 @@ export class Group extends CoValueBase {
60
60
  this._raw.addMember(member === "everyone" ? member : member._raw, role);
61
61
  return this;
62
62
  }
63
+ removeMember(member) {
64
+ this._raw.removeMember(member === "everyone" ? member : member._raw);
65
+ return this;
66
+ }
63
67
  get members() {
64
68
  return this._raw
65
69
  .keys()
@@ -82,6 +86,10 @@ export class Group extends CoValueBase {
82
86
  };
83
87
  });
84
88
  }
89
+ extend(parent) {
90
+ this._raw.extend(parent._raw);
91
+ return this;
92
+ }
85
93
  /** @category Subscription & Loading */
86
94
  static load(id, as, depth) {
87
95
  return loadCoValue(this, id, as, depth);
@@ -1 +1 @@
1
- {"version":3,"file":"group.js","sourceRoot":"","sources":["../../../src/coValues/group.ts"],"names":[],"mappings":";AAUA,OAAO,EACL,OAAO,EACP,2BAA2B,EAC3B,KAAK,EACL,WAAW,EACX,UAAU,EACV,GAAG,EACH,EAAE,EACF,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AAExB,uCAAuC;AACvC,MAAM,OAAO,OAAQ,SAAQ,KAAK;IAAlC;;QACE,SAAI,GAAG,EAAE,CAAC,MAAM,CAAC;IACnB,CAAC;CAAA;AAED,uCAAuC;AACvC,MAAM,OAAO,KAAM,SAAQ,WAAW;IAUpC,IAAI,OAAO;QAKT,OAAQ,IAAI,CAAC,WAA4B,CAAC,OAAO,CAAC;IACpD,CAAC;IAoBD,IAAI,KAAK;QAIP,MAAM,SAAS,GAAG,IAAI,CAAC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C,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,uCAAuC;IACvC,SAAS,CAEP,KAA0B,EAC1B,QAAiD;QAEjD,OAAO,0BAA0B,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACF;;AA3LC;IACE,GAAK,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC;AACjC,CAAC,GAAA,CAAA;AAYD;IACE,GAAK,OAAO,GAAG;QACb,OAAO,EAAE,MAAuB;QAChC,IAAI,EAAE,MAAuB;QAC7B,CAAC,UAAU,CAAC,EAAE;YACZ,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO;YAClB,QAAQ,EAAE,KAAK;SACc;QAC/B,8DAA8D;KACxD,CAAC;IACT,MAAM,CAAC,cAAc,CAAC,GAAK,SAAS,EAAE,SAAS,EAAE;QAC/C,GAAG,EAAE,GAAG,EAAE,CAAC,GAAK,OAAO;KACxB,CAAC,CAAC;AACL,CAAC,GAAA,CAAA"}
@@ -108,12 +108,20 @@ export function subscribeToCoValue(cls, id, as, depth, listener, onUnavailable)
108
108
  }
109
109
  export function createCoValueObservable() {
110
110
  let currentValue = undefined;
111
+ let subscriberCount = 0;
111
112
  function subscribe(cls, id, as, depth, listener, onUnavailable) {
113
+ subscriberCount++;
112
114
  const unsubscribe = subscribeToCoValue(cls, id, as, depth, (value) => {
113
115
  currentValue = value;
114
116
  listener();
115
117
  }, onUnavailable);
116
- return unsubscribe;
118
+ return () => {
119
+ unsubscribe();
120
+ subscriberCount--;
121
+ if (subscriberCount === 0) {
122
+ currentValue = undefined;
123
+ }
124
+ };
117
125
  }
118
126
  const observable = {
119
127
  getCurrentValue: () => currentValue,
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/coValues/interfaces.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EACL,OAAO,EACP,kBAAkB,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B,EACvC,QAAQ,CAAC,EAAE,EACX,QAAQ,CAAC,SAAS,EAClB,KAAK,EACL,QAAQ,CACT,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -19,10 +19,10 @@
19
19
  },
20
20
  "type": "module",
21
21
  "license": "MIT",
22
- "version": "0.8.32",
22
+ "version": "0.8.35",
23
23
  "dependencies": {
24
24
  "fast-check": "^3.17.2",
25
- "cojson": "0.8.32"
25
+ "cojson": "0.8.35"
26
26
  },
27
27
  "devDependencies": {
28
28
  "typescript": "^5.3.3",
@@ -142,6 +142,11 @@ export class Group extends CoValueBase implements CoValue {
142
142
  return this;
143
143
  }
144
144
 
145
+ removeMember(member: Everyone | Account) {
146
+ this._raw.removeMember(member === "everyone" ? member : member._raw);
147
+ return this;
148
+ }
149
+
145
150
  get members() {
146
151
  return this._raw
147
152
  .keys()
@@ -172,6 +177,11 @@ export class Group extends CoValueBase implements CoValue {
172
177
  });
173
178
  }
174
179
 
180
+ extend(parent: Group) {
181
+ this._raw.extend(parent._raw);
182
+ return this;
183
+ }
184
+
175
185
  /** @category Subscription & Loading */
176
186
  static load<G extends Group, Depth>(
177
187
  this: CoValueClass<G>,
@@ -228,6 +228,7 @@ export function subscribeToCoValue<V extends CoValue, Depth>(
228
228
 
229
229
  export function createCoValueObservable<V extends CoValue, Depth>() {
230
230
  let currentValue: DeeplyLoaded<V, Depth> | undefined = undefined;
231
+ let subscriberCount = 0;
231
232
 
232
233
  function subscribe(
233
234
  cls: CoValueClass<V>,
@@ -237,6 +238,8 @@ export function createCoValueObservable<V extends CoValue, Depth>() {
237
238
  listener: () => void,
238
239
  onUnavailable?: () => void,
239
240
  ) {
241
+ subscriberCount++;
242
+
240
243
  const unsubscribe = subscribeToCoValue(
241
244
  cls,
242
245
  id,
@@ -249,7 +252,13 @@ export function createCoValueObservable<V extends CoValue, Depth>() {
249
252
  onUnavailable,
250
253
  );
251
254
 
252
- return unsubscribe;
255
+ return () => {
256
+ unsubscribe();
257
+ subscriberCount--;
258
+ if (subscriberCount === 0) {
259
+ currentValue = undefined;
260
+ }
261
+ };
253
262
  }
254
263
 
255
264
  const observable = {
@@ -1,5 +1,7 @@
1
+ import { RawGroup } from "cojson";
1
2
  import { describe, expect, test } from "vitest";
2
3
  import { Account, CoMap, Group, WasmCrypto, co } from "../index.web.js";
4
+ import { waitFor } from "./utils.js";
3
5
 
4
6
  const Crypto = await WasmCrypto.create();
5
7
 
@@ -85,3 +87,144 @@ describe("Custom accounts and groups", async () => {
85
87
  expect(map._owner.castAs(CustomGroup).nMembers).toBe(2);
86
88
  });
87
89
  });
90
+
91
+ describe("Group inheritance", () => {
92
+ class TestMap extends CoMap {
93
+ title = co.string;
94
+ }
95
+
96
+ test("Group inheritance", async () => {
97
+ const me = await Account.create({
98
+ creationProps: { name: "Hermes Puggington" },
99
+ crypto: Crypto,
100
+ });
101
+
102
+ const parentGroup = Group.create({ owner: me });
103
+ const group = Group.create({ owner: me });
104
+
105
+ group.extend(parentGroup);
106
+
107
+ const reader = await Account.createAs(me, {
108
+ creationProps: { name: "Reader" },
109
+ });
110
+
111
+ parentGroup.addMember(reader, "reader");
112
+
113
+ const mapInChild = TestMap.create({ title: "In Child" }, { owner: group });
114
+
115
+ const mapAsReader = await TestMap.load(mapInChild.id, reader, {});
116
+ expect(mapAsReader?.title).toBe("In Child");
117
+
118
+ parentGroup.removeMember(reader);
119
+
120
+ mapInChild.title = "In Child (updated)";
121
+
122
+ const mapAsReaderAfterUpdate = await TestMap.load(
123
+ mapInChild.id,
124
+ reader,
125
+ {},
126
+ );
127
+ expect(mapAsReaderAfterUpdate?.title).toBe("In Child");
128
+ });
129
+
130
+ test("Group inheritance with grand-children", async () => {
131
+ const me = await Account.create({
132
+ creationProps: { name: "Hermes Puggington" },
133
+ crypto: Crypto,
134
+ });
135
+
136
+ const grandParentGroup = Group.create({ owner: me });
137
+ const parentGroup = Group.create({ owner: me });
138
+ const group = Group.create({ owner: me });
139
+
140
+ group.extend(parentGroup);
141
+ parentGroup.extend(grandParentGroup);
142
+
143
+ const reader = await Account.createAs(me, {
144
+ creationProps: { name: "Reader" },
145
+ });
146
+
147
+ grandParentGroup.addMember(reader, "reader");
148
+
149
+ const mapInGrandChild = TestMap.create(
150
+ { title: "In Grand Child" },
151
+ { owner: group },
152
+ );
153
+
154
+ const mapAsReader = await TestMap.load(mapInGrandChild.id, reader, {});
155
+ expect(mapAsReader?.title).toBe("In Grand Child");
156
+
157
+ grandParentGroup.removeMember(reader);
158
+
159
+ mapInGrandChild.title = "In Grand Child (updated)";
160
+
161
+ const mapAsReaderAfterUpdate = await TestMap.load(
162
+ mapInGrandChild.id,
163
+ reader,
164
+ {},
165
+ );
166
+ expect(mapAsReaderAfterUpdate?.title).toBe("In Grand Child");
167
+ });
168
+
169
+ test("Group inheritance should fail if the current account doesn't have admin role in both groups", async () => {
170
+ const me = await Account.create({
171
+ creationProps: { name: "Hermes Puggington" },
172
+ crypto: Crypto,
173
+ });
174
+
175
+ const other = await Account.createAs(me, {
176
+ creationProps: { name: "Another user" },
177
+ });
178
+
179
+ const parentGroup = Group.create({ owner: me });
180
+ parentGroup.addMember(other, "writer");
181
+ const group = Group.create({ owner: me });
182
+ group.addMember(other, "admin");
183
+
184
+ const parentGroupOnTheOtherSide = await Group.load(
185
+ parentGroup.id,
186
+ other,
187
+ {},
188
+ );
189
+ const groupOnTheOtherSide = await Group.load(group.id, other, {});
190
+
191
+ if (!groupOnTheOtherSide || !parentGroupOnTheOtherSide) {
192
+ throw new Error("CoValue not available");
193
+ }
194
+
195
+ expect(() => groupOnTheOtherSide.extend(parentGroupOnTheOtherSide)).toThrow(
196
+ "To extend a group, the current account must have admin role in both groups",
197
+ );
198
+ });
199
+
200
+ test("Group inheritance should work if the current account has admin role in both groups", async () => {
201
+ const me = await Account.create({
202
+ creationProps: { name: "Hermes Puggington" },
203
+ crypto: Crypto,
204
+ });
205
+
206
+ const other = await Account.createAs(me, {
207
+ creationProps: { name: "Another user" },
208
+ });
209
+
210
+ const parentGroup = Group.create({ owner: me });
211
+ parentGroup.addMember(other, "admin");
212
+ const group = Group.create({ owner: me });
213
+ group.addMember(other, "admin");
214
+
215
+ const parentGroupOnTheOtherSide = await Group.load(
216
+ parentGroup.id,
217
+ other,
218
+ {},
219
+ );
220
+ const groupOnTheOtherSide = await Group.load(group.id, other, {});
221
+
222
+ if (!groupOnTheOtherSide || !parentGroupOnTheOtherSide) {
223
+ throw new Error("CoValue not available");
224
+ }
225
+
226
+ expect(() =>
227
+ groupOnTheOtherSide.extend(parentGroupOnTheOtherSide),
228
+ ).not.toThrow();
229
+ });
230
+ });
@@ -1,23 +1,13 @@
1
- const Crypto = await WasmCrypto.create();
2
- import { connectedPeers } from "cojson/src/streamUtils.js";
3
1
  import { describe, expect, it, onTestFinished, vi } from "vitest";
2
+ import { Account, CoFeed, CoList, CoMap, co } from "../index.web.js";
4
3
  import {
5
- Account,
6
- CoFeed,
7
- CoList,
8
- CoMap,
9
- WasmCrypto,
10
- co,
11
- createJazzContext,
12
- fixedCredentialsAuth,
13
- isControlledAccount,
14
- } from "../index.web.js";
15
- import {
4
+ type DepthsIn,
16
5
  FileStream,
17
6
  Group,
18
- randomSessionProvider,
7
+ createCoValueObservable,
19
8
  subscribeToCoValue,
20
9
  } from "../internal.js";
10
+ import { setupAccount, waitFor } from "./utils.js";
21
11
 
22
12
  class ChatRoom extends CoMap {
23
13
  messages = co.ref(MessagesList);
@@ -33,34 +23,6 @@ class Message extends CoMap {
33
23
  class MessagesList extends CoList.Of(co.ref(Message)) {}
34
24
  class ReactionsStream extends CoFeed.Of(co.string) {}
35
25
 
36
- async function setupAccount() {
37
- const me = await Account.create({
38
- creationProps: { name: "Hermes Puggington" },
39
- crypto: Crypto,
40
- });
41
-
42
- const [initialAsPeer, secondPeer] = connectedPeers("initial", "second", {
43
- peer1role: "server",
44
- peer2role: "client",
45
- });
46
-
47
- if (!isControlledAccount(me)) {
48
- throw "me is not a controlled account";
49
- }
50
- me._raw.core.node.syncManager.addPeer(secondPeer);
51
- const { account: meOnSecondPeer } = await createJazzContext({
52
- auth: fixedCredentialsAuth({
53
- accountID: me.id,
54
- secret: me._raw.agentSecret,
55
- }),
56
- sessionProvider: randomSessionProvider,
57
- peersToLoadFrom: [initialAsPeer],
58
- crypto: Crypto,
59
- });
60
-
61
- return { me, meOnSecondPeer };
62
- }
63
-
64
26
  function createChatRoom(me: Account | Group, name: string) {
65
27
  return ChatRoom.create(
66
28
  { messages: MessagesList.create([], { owner: me }), name },
@@ -332,30 +294,69 @@ describe("subscribeToCoValue", () => {
332
294
  });
333
295
  });
334
296
 
335
- function waitFor(callback: () => boolean | void) {
336
- return new Promise<void>((resolve, reject) => {
337
- const checkPassed = () => {
338
- try {
339
- return { ok: callback(), error: null };
340
- } catch (error) {
341
- return { ok: false, error };
342
- }
343
- };
344
-
345
- let retries = 0;
346
-
347
- const interval = setInterval(() => {
348
- const { ok, error } = checkPassed();
349
-
350
- if (ok !== false) {
351
- clearInterval(interval);
352
- resolve();
353
- }
354
-
355
- if (++retries > 10) {
356
- clearInterval(interval);
357
- reject(error);
358
- }
359
- }, 100);
297
+ describe("createCoValueObservable", () => {
298
+ class TestMap extends CoMap {
299
+ color = co.string;
300
+ }
301
+
302
+ function createTestMap(me: Account | Group) {
303
+ return TestMap.create({ color: "red" }, { owner: me });
304
+ }
305
+
306
+ it("should return undefined when there are no subscribers", async () => {
307
+ const observable = createCoValueObservable();
308
+
309
+ expect(observable.getCurrentValue()).toBeUndefined();
360
310
  });
361
- }
311
+
312
+ it("should update currentValue when subscribed", async () => {
313
+ const { me, meOnSecondPeer } = await setupAccount();
314
+ const testMap = createTestMap(me);
315
+ const observable = createCoValueObservable<TestMap, DepthsIn<TestMap>>();
316
+ const mockListener = vi.fn();
317
+
318
+ const unsubscribe = observable.subscribe(
319
+ TestMap,
320
+ testMap.id,
321
+ meOnSecondPeer,
322
+ {},
323
+ () => {
324
+ mockListener();
325
+ },
326
+ );
327
+
328
+ testMap.color = "blue";
329
+
330
+ await waitFor(() => mockListener.mock.calls.length > 0);
331
+
332
+ expect(observable.getCurrentValue()).toMatchObject({
333
+ id: testMap.id,
334
+ color: "blue",
335
+ });
336
+
337
+ unsubscribe();
338
+ });
339
+
340
+ it("should reset to undefined after unsubscribe", async () => {
341
+ const { me, meOnSecondPeer } = await setupAccount();
342
+ const testMap = createTestMap(me);
343
+ const observable = createCoValueObservable<TestMap, DepthsIn<TestMap>>();
344
+ const mockListener = vi.fn();
345
+
346
+ const unsubscribe = observable.subscribe(
347
+ TestMap,
348
+ testMap.id,
349
+ meOnSecondPeer,
350
+ {},
351
+ () => {
352
+ mockListener();
353
+ },
354
+ );
355
+
356
+ await waitFor(() => mockListener.mock.calls.length > 0);
357
+ expect(observable.getCurrentValue()).toBeDefined();
358
+
359
+ unsubscribe();
360
+ expect(observable.getCurrentValue()).toBeUndefined();
361
+ });
362
+ });
@@ -0,0 +1,68 @@
1
+ import { isControlledAccount } from "../coValues/account";
2
+
3
+ import { connectedPeers } from "cojson/src/streamUtils.js";
4
+ import {
5
+ Account,
6
+ WasmCrypto,
7
+ createJazzContext,
8
+ fixedCredentialsAuth,
9
+ randomSessionProvider,
10
+ } from "../index.web";
11
+
12
+ const Crypto = await WasmCrypto.create();
13
+
14
+ export async function setupAccount() {
15
+ const me = await Account.create({
16
+ creationProps: { name: "Hermes Puggington" },
17
+ crypto: Crypto,
18
+ });
19
+
20
+ const [initialAsPeer, secondPeer] = connectedPeers("initial", "second", {
21
+ peer1role: "server",
22
+ peer2role: "client",
23
+ });
24
+
25
+ if (!isControlledAccount(me)) {
26
+ throw "me is not a controlled account";
27
+ }
28
+ me._raw.core.node.syncManager.addPeer(secondPeer);
29
+ const { account: meOnSecondPeer } = await createJazzContext({
30
+ auth: fixedCredentialsAuth({
31
+ accountID: me.id,
32
+ secret: me._raw.agentSecret,
33
+ }),
34
+ sessionProvider: randomSessionProvider,
35
+ peersToLoadFrom: [initialAsPeer],
36
+ crypto: Crypto,
37
+ });
38
+
39
+ return { me, meOnSecondPeer };
40
+ }
41
+
42
+ export function waitFor(callback: () => boolean | void) {
43
+ return new Promise<void>((resolve, reject) => {
44
+ const checkPassed = () => {
45
+ try {
46
+ return { ok: callback(), error: null };
47
+ } catch (error) {
48
+ return { ok: false, error };
49
+ }
50
+ };
51
+
52
+ let retries = 0;
53
+
54
+ const interval = setInterval(() => {
55
+ const { ok, error } = checkPassed();
56
+
57
+ if (ok !== false) {
58
+ clearInterval(interval);
59
+ resolve();
60
+ }
61
+
62
+ if (++retries > 10) {
63
+ clearInterval(interval);
64
+ reject(error);
65
+ }
66
+ }, 100);
67
+ });
68
+ }