jazz-tools 0.17.11 → 0.17.13
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 +38 -38
- package/CHANGELOG.md +24 -0
- package/dist/expo/auth/clerk/index.d.ts.map +1 -1
- package/dist/expo/index.js +6 -2
- package/dist/expo/index.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/inspector/{custom-element-I7L56H6B.js → custom-element-ZSNTCECD.js} +50 -9
- package/dist/inspector/{custom-element-I7L56H6B.js.map → custom-element-ZSNTCECD.js.map} +1 -1
- package/dist/inspector/index.js +49 -8
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/inspector/viewer/page.d.ts.map +1 -1
- package/dist/inspector/viewer/table-viewer.d.ts +2 -1
- package/dist/inspector/viewer/table-viewer.d.ts.map +1 -1
- package/dist/react/auth/Clerk.d.ts.map +1 -1
- package/dist/react/index.js +6 -2
- package/dist/react/index.js.map +1 -1
- package/dist/tools/auth/clerk/index.d.ts +2 -1
- package/dist/tools/auth/clerk/index.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/expo/auth/clerk/index.tsx +6 -2
- package/src/inspector/viewer/page.tsx +30 -2
- package/src/inspector/viewer/table-viewer.tsx +26 -1
- package/src/react/auth/Clerk.tsx +6 -2
- package/src/react-core/tests/useCoState.test.ts +1 -1
- package/src/tools/auth/clerk/index.ts +2 -0
- package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +56 -6
- package/src/tools/tests/coMap.test.ts +10 -6
- package/src/tools/tests/exportImport.test.ts +6 -6
- package/src/tools/tests/load.test.ts +6 -4
- package/src/tools/tests/subscribe.test.ts +10 -6
@@ -13,6 +13,7 @@ const authSecretStorage = new AuthSecretStorage();
|
|
13
13
|
|
14
14
|
describe("JazzClerkAuth", () => {
|
15
15
|
const mockAuthenticate = vi.fn();
|
16
|
+
const mockLogOut = vi.fn();
|
16
17
|
let auth: JazzClerkAuth;
|
17
18
|
|
18
19
|
beforeEach(async () => {
|
@@ -21,7 +22,7 @@ describe("JazzClerkAuth", () => {
|
|
21
22
|
await createJazzTestAccount({
|
22
23
|
isCurrentActiveAccount: true,
|
23
24
|
});
|
24
|
-
auth = new JazzClerkAuth(mockAuthenticate, authSecretStorage);
|
25
|
+
auth = new JazzClerkAuth(mockAuthenticate, mockLogOut, authSecretStorage);
|
25
26
|
});
|
26
27
|
|
27
28
|
describe("onClerkUserChange", () => {
|
@@ -118,6 +119,35 @@ describe("JazzClerkAuth", () => {
|
|
118
119
|
provider: "clerk",
|
119
120
|
});
|
120
121
|
});
|
122
|
+
|
123
|
+
it("should call LogOut", async () => {
|
124
|
+
// Set up local auth
|
125
|
+
await authSecretStorage.set({
|
126
|
+
accountID: "xxxx" as ID<Account>,
|
127
|
+
secretSeed: new Uint8Array([2, 2, 2]),
|
128
|
+
accountSecret: "xxxx" as AgentSecret,
|
129
|
+
provider: "anonymous",
|
130
|
+
});
|
131
|
+
|
132
|
+
const mockClerk = {
|
133
|
+
user: {
|
134
|
+
fullName: "Guido",
|
135
|
+
unsafeMetadata: {
|
136
|
+
jazzAccountID: "test123",
|
137
|
+
jazzAccountSecret: "secret123",
|
138
|
+
jazzAccountSeed: [1, 2, 3],
|
139
|
+
},
|
140
|
+
},
|
141
|
+
signOut: vi.fn(),
|
142
|
+
} as unknown as MinimalClerkClient;
|
143
|
+
|
144
|
+
await auth.onClerkUserChange(mockClerk);
|
145
|
+
|
146
|
+
await auth.onClerkUserChange({ user: null });
|
147
|
+
|
148
|
+
expect(authSecretStorage.isAuthenticated).toBe(false);
|
149
|
+
expect(mockLogOut).toHaveBeenCalled();
|
150
|
+
});
|
121
151
|
});
|
122
152
|
|
123
153
|
describe("registerListener", () => {
|
@@ -147,7 +177,11 @@ describe("JazzClerkAuth", () => {
|
|
147
177
|
it("should call onClerkUserChange on the first trigger", async () => {
|
148
178
|
const { client, triggerUserChange } = setupMockClerk(null);
|
149
179
|
|
150
|
-
const auth = new JazzClerkAuth(
|
180
|
+
const auth = new JazzClerkAuth(
|
181
|
+
mockAuthenticate,
|
182
|
+
mockLogOut,
|
183
|
+
authSecretStorage,
|
184
|
+
);
|
151
185
|
const onClerkUserChangeSpy = vi.spyOn(auth, "onClerkUserChange");
|
152
186
|
|
153
187
|
auth.registerListener(client);
|
@@ -160,7 +194,11 @@ describe("JazzClerkAuth", () => {
|
|
160
194
|
it("should call onClerkUserChange when user changes", async () => {
|
161
195
|
const { client, triggerUserChange } = setupMockClerk(null);
|
162
196
|
|
163
|
-
const auth = new JazzClerkAuth(
|
197
|
+
const auth = new JazzClerkAuth(
|
198
|
+
mockAuthenticate,
|
199
|
+
mockLogOut,
|
200
|
+
authSecretStorage,
|
201
|
+
);
|
164
202
|
const onClerkUserChangeSpy = vi.spyOn(auth, "onClerkUserChange");
|
165
203
|
|
166
204
|
auth.registerListener(client);
|
@@ -181,7 +219,11 @@ describe("JazzClerkAuth", () => {
|
|
181
219
|
it("should call onClerkUserChange when user passes from null to non-null", async () => {
|
182
220
|
const { client, triggerUserChange } = setupMockClerk(null);
|
183
221
|
|
184
|
-
const auth = new JazzClerkAuth(
|
222
|
+
const auth = new JazzClerkAuth(
|
223
|
+
mockAuthenticate,
|
224
|
+
mockLogOut,
|
225
|
+
authSecretStorage,
|
226
|
+
);
|
185
227
|
const onClerkUserChangeSpy = vi.spyOn(auth, "onClerkUserChange");
|
186
228
|
|
187
229
|
auth.registerListener(client);
|
@@ -194,7 +236,11 @@ describe("JazzClerkAuth", () => {
|
|
194
236
|
it("should not call onClerkUserChange when user is the same", async () => {
|
195
237
|
const { client, triggerUserChange } = setupMockClerk(null);
|
196
238
|
|
197
|
-
const auth = new JazzClerkAuth(
|
239
|
+
const auth = new JazzClerkAuth(
|
240
|
+
mockAuthenticate,
|
241
|
+
mockLogOut,
|
242
|
+
authSecretStorage,
|
243
|
+
);
|
198
244
|
const onClerkUserChangeSpy = vi.spyOn(auth, "onClerkUserChange");
|
199
245
|
|
200
246
|
auth.registerListener(client);
|
@@ -221,7 +267,11 @@ describe("JazzClerkAuth", () => {
|
|
221
267
|
it("should not call onClerkUserChange when user switches from undefined to null", async () => {
|
222
268
|
const { client, triggerUserChange } = setupMockClerk(null);
|
223
269
|
|
224
|
-
const auth = new JazzClerkAuth(
|
270
|
+
const auth = new JazzClerkAuth(
|
271
|
+
mockAuthenticate,
|
272
|
+
mockLogOut,
|
273
|
+
authSecretStorage,
|
274
|
+
);
|
225
275
|
const onClerkUserChangeSpy = vi.spyOn(auth, "onClerkUserChange");
|
226
276
|
|
227
277
|
auth.registerListener(client);
|
@@ -726,9 +726,11 @@ describe("CoMap resolution", async () => {
|
|
726
726
|
const currentAccount = Account.getMe();
|
727
727
|
|
728
728
|
// Disconnect the current account
|
729
|
-
currentAccount._raw.core.node.syncManager
|
730
|
-
|
731
|
-
|
729
|
+
currentAccount._raw.core.node.syncManager
|
730
|
+
.getServerPeers(currentAccount._raw.id)
|
731
|
+
.forEach((peer) => {
|
732
|
+
peer.gracefulShutdown();
|
733
|
+
});
|
732
734
|
|
733
735
|
const group = Group.create();
|
734
736
|
group.addMember("everyone", "writer");
|
@@ -771,9 +773,11 @@ describe("CoMap resolution", async () => {
|
|
771
773
|
const currentAccount = Account.getMe();
|
772
774
|
|
773
775
|
// Disconnect the current account
|
774
|
-
currentAccount._raw.core.node.syncManager
|
775
|
-
|
776
|
-
|
776
|
+
currentAccount._raw.core.node.syncManager
|
777
|
+
.getServerPeers(currentAccount._raw.id)
|
778
|
+
.forEach((peer) => {
|
779
|
+
peer.gracefulShutdown();
|
780
|
+
});
|
777
781
|
|
778
782
|
const group = Group.create();
|
779
783
|
group.addMember("everyone", "writer");
|
@@ -257,7 +257,7 @@ describe("importContentPieces", () => {
|
|
257
257
|
const alice = await createJazzTestAccount();
|
258
258
|
const bob = await createJazzTestAccount();
|
259
259
|
|
260
|
-
bob._raw.core.node.syncManager.
|
260
|
+
bob._raw.core.node.syncManager.getClientPeers().forEach((peer) => {
|
261
261
|
peer.gracefulShutdown();
|
262
262
|
});
|
263
263
|
|
@@ -300,7 +300,7 @@ describe("importContentPieces", () => {
|
|
300
300
|
const alice = await createJazzTestAccount();
|
301
301
|
const bob = await createJazzTestAccount();
|
302
302
|
|
303
|
-
bob._raw.core.node.syncManager.
|
303
|
+
bob._raw.core.node.syncManager.getClientPeers().forEach((peer) => {
|
304
304
|
peer.gracefulShutdown();
|
305
305
|
});
|
306
306
|
|
@@ -340,7 +340,7 @@ describe("importContentPieces", () => {
|
|
340
340
|
const alice = await createJazzTestAccount();
|
341
341
|
const { guest } = await createJazzTestGuest();
|
342
342
|
|
343
|
-
guest.node.syncManager.
|
343
|
+
guest.node.syncManager.getClientPeers().forEach((peer) => {
|
344
344
|
peer.gracefulShutdown();
|
345
345
|
});
|
346
346
|
|
@@ -374,7 +374,7 @@ describe("importContentPieces", () => {
|
|
374
374
|
isCurrentActiveAccount: true,
|
375
375
|
});
|
376
376
|
|
377
|
-
bob._raw.core.node.syncManager.
|
377
|
+
bob._raw.core.node.syncManager.getClientPeers().forEach((peer) => {
|
378
378
|
peer.gracefulShutdown();
|
379
379
|
});
|
380
380
|
|
@@ -415,7 +415,7 @@ describe("importContentPieces", () => {
|
|
415
415
|
const alice = await createJazzTestAccount();
|
416
416
|
const bob = await createJazzTestAccount();
|
417
417
|
|
418
|
-
bob._raw.core.node.syncManager.
|
418
|
+
bob._raw.core.node.syncManager.getClientPeers().forEach((peer) => {
|
419
419
|
peer.gracefulShutdown();
|
420
420
|
});
|
421
421
|
|
@@ -479,7 +479,7 @@ describe("importContentPieces", () => {
|
|
479
479
|
const alice = await createJazzTestAccount();
|
480
480
|
const bob = await createJazzTestAccount();
|
481
481
|
|
482
|
-
bob._raw.core.node.syncManager.
|
482
|
+
bob._raw.core.node.syncManager.getClientPeers().forEach((peer) => {
|
483
483
|
peer.gracefulShutdown();
|
484
484
|
});
|
485
485
|
|
@@ -137,7 +137,7 @@ test("retry an unavailable value", async () => {
|
|
137
137
|
const currentAccount = Account.getMe();
|
138
138
|
|
139
139
|
// Disconnect the current account
|
140
|
-
currentAccount._raw.core.node.syncManager.
|
140
|
+
currentAccount._raw.core.node.syncManager.getClientPeers().forEach((peer) => {
|
141
141
|
peer.gracefulShutdown();
|
142
142
|
});
|
143
143
|
|
@@ -169,9 +169,11 @@ test("returns null if the value is unavailable after retries", async () => {
|
|
169
169
|
const currentAccount = Account.getMe();
|
170
170
|
|
171
171
|
// Disconnect the current account
|
172
|
-
currentAccount._raw.core.node.syncManager
|
173
|
-
|
174
|
-
|
172
|
+
currentAccount._raw.core.node.syncManager
|
173
|
+
.getServerPeers(currentAccount._raw.id)
|
174
|
+
.forEach((peer) => {
|
175
|
+
peer.gracefulShutdown();
|
176
|
+
});
|
175
177
|
|
176
178
|
const group = Group.create();
|
177
179
|
const map = Person.create({ name: "John" }, group);
|
@@ -503,9 +503,11 @@ describe("subscribeToCoValue", () => {
|
|
503
503
|
});
|
504
504
|
|
505
505
|
// Disconnect the creator from the sync server
|
506
|
-
creator._raw.core.node.syncManager
|
507
|
-
|
508
|
-
|
506
|
+
creator._raw.core.node.syncManager
|
507
|
+
.getServerPeers(creator._raw.id)
|
508
|
+
.forEach((peer) => {
|
509
|
+
peer.gracefulShutdown();
|
510
|
+
});
|
509
511
|
|
510
512
|
const everyone = Group.create(creator);
|
511
513
|
everyone.addMember("everyone", "reader");
|
@@ -867,9 +869,11 @@ describe("subscribeToCoValue", () => {
|
|
867
869
|
await person.waitForSync();
|
868
870
|
|
869
871
|
// Disconnect from the sync server, so we can change permissions but not sync them
|
870
|
-
creator._raw.core.node.syncManager
|
871
|
-
|
872
|
-
|
872
|
+
creator._raw.core.node.syncManager
|
873
|
+
.getServerPeers(creator._raw.id)
|
874
|
+
.forEach((peer) => {
|
875
|
+
peer.gracefulShutdown();
|
876
|
+
});
|
873
877
|
|
874
878
|
group.removeMember(writer1);
|
875
879
|
group.addMember(writer2, "writer");
|