jazz-tools 0.18.24 → 0.18.26

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.
Files changed (112) hide show
  1. package/.svelte-kit/__package__/Provider.svelte +2 -0
  2. package/.svelte-kit/__package__/Provider.svelte.d.ts.map +1 -1
  3. package/.turbo/turbo-build.log +49 -49
  4. package/CHANGELOG.md +24 -0
  5. package/dist/browser/index.js +9 -9
  6. package/dist/browser/index.js.map +1 -1
  7. package/dist/{chunk-BOMSRY5H.js → chunk-M2HGBOXS.js} +2 -2
  8. package/dist/chunk-M2HGBOXS.js.map +1 -0
  9. package/dist/{chunk-W7JT3QUN.js → chunk-ZIAN4UY5.js} +406 -40
  10. package/dist/chunk-ZIAN4UY5.js.map +1 -0
  11. package/dist/index.js +2 -2
  12. package/dist/inspector/{custom-element-XDJT5T57.js → custom-element-A7UAELEG.js} +3 -1
  13. package/dist/inspector/{custom-element-XDJT5T57.js.map → custom-element-A7UAELEG.js.map} +1 -1
  14. package/dist/inspector/index.js +2 -0
  15. package/dist/inspector/index.js.map +1 -1
  16. package/dist/inspector/register-custom-element.js +1 -1
  17. package/dist/inspector/viewer/use-open-inspector.d.ts.map +1 -1
  18. package/dist/inspector/viewer/use-page-path.d.ts.map +1 -1
  19. package/dist/react/index.js +4 -2
  20. package/dist/react/index.js.map +1 -1
  21. package/dist/react/provider.d.ts +2 -1
  22. package/dist/react/provider.d.ts.map +1 -1
  23. package/dist/react/ssr.js +1 -1
  24. package/dist/react/ssr.js.map +1 -1
  25. package/dist/react-native-core/index.js +12 -11
  26. package/dist/react-native-core/index.js.map +1 -1
  27. package/dist/react-native-core/provider.d.ts +2 -1
  28. package/dist/react-native-core/provider.d.ts.map +1 -1
  29. package/dist/svelte/Provider.svelte +2 -0
  30. package/dist/svelte/Provider.svelte.d.ts.map +1 -1
  31. package/dist/testing.js +4 -4
  32. package/dist/testing.js.map +1 -1
  33. package/dist/tools/auth/AuthSecretStorage.d.ts +3 -1
  34. package/dist/tools/auth/AuthSecretStorage.d.ts.map +1 -1
  35. package/dist/tools/coValues/account.d.ts +3 -3
  36. package/dist/tools/coValues/account.d.ts.map +1 -1
  37. package/dist/tools/coValues/coVector.d.ts +127 -0
  38. package/dist/tools/coValues/coVector.d.ts.map +1 -0
  39. package/dist/tools/coValues/group.d.ts +20 -1
  40. package/dist/tools/coValues/group.d.ts.map +1 -1
  41. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  42. package/dist/tools/implementation/ContextManager.d.ts +1 -0
  43. package/dist/tools/implementation/ContextManager.d.ts.map +1 -1
  44. package/dist/tools/implementation/createContext.d.ts +7 -7
  45. package/dist/tools/implementation/createContext.d.ts.map +1 -1
  46. package/dist/tools/implementation/zodSchema/coExport.d.ts +2 -1
  47. package/dist/tools/implementation/zodSchema/coExport.d.ts.map +1 -1
  48. package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts.map +1 -1
  49. package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts +47 -0
  50. package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts.map +1 -0
  51. package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts +5 -0
  52. package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts.map +1 -1
  53. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +2 -2
  54. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
  55. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +2 -2
  56. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
  57. package/dist/tools/implementation/zodSchema/zodCo.d.ts +2 -1
  58. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  59. package/dist/tools/implementation/zodSchema/zodSchema.d.ts +3 -2
  60. package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
  61. package/dist/tools/internal.d.ts +2 -0
  62. package/dist/tools/internal.d.ts.map +1 -1
  63. package/dist/tools/ssr.js +1 -1
  64. package/dist/tools/testing.d.ts.map +1 -1
  65. package/dist/tools/tests/coVector.test-d.d.ts +2 -0
  66. package/dist/tools/tests/coVector.test-d.d.ts.map +1 -0
  67. package/dist/tools/tests/coVector.test.d.ts +2 -0
  68. package/dist/tools/tests/coVector.test.d.ts.map +1 -0
  69. package/dist/worker/index.js +3 -3
  70. package/dist/worker/index.js.map +1 -1
  71. package/package.json +4 -4
  72. package/src/better-auth/database-adapter/tests/sync-utils.ts +1 -1
  73. package/src/browser/createBrowserContext.ts +9 -9
  74. package/src/browser/tests/utils.ts +2 -2
  75. package/src/inspector/viewer/use-open-inspector.ts +1 -0
  76. package/src/inspector/viewer/use-page-path.ts +1 -0
  77. package/src/react/provider.tsx +3 -0
  78. package/src/react-native-core/platform.ts +9 -9
  79. package/src/react-native-core/provider.tsx +3 -1
  80. package/src/svelte/Provider.svelte +2 -0
  81. package/src/tools/auth/AuthSecretStorage.ts +16 -9
  82. package/src/tools/coValues/account.ts +5 -5
  83. package/src/tools/coValues/coVector.ts +432 -0
  84. package/src/tools/coValues/group.ts +33 -0
  85. package/src/tools/coValues/interfaces.ts +4 -1
  86. package/src/tools/implementation/ContextManager.ts +7 -3
  87. package/src/tools/implementation/createContext.ts +12 -12
  88. package/src/tools/implementation/zodSchema/coExport.ts +2 -0
  89. package/src/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.ts +13 -0
  90. package/src/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.ts +105 -0
  91. package/src/tools/implementation/zodSchema/schemaTypes/GroupSchema.ts +7 -1
  92. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +9 -5
  93. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +15 -9
  94. package/src/tools/implementation/zodSchema/zodCo.ts +15 -0
  95. package/src/tools/implementation/zodSchema/zodSchema.ts +15 -6
  96. package/src/tools/internal.ts +2 -0
  97. package/src/tools/ssr/ssr.ts +1 -1
  98. package/src/tools/testing.ts +3 -3
  99. package/src/tools/tests/AuthSecretStorage.test.ts +59 -1
  100. package/src/tools/tests/ContextManager.test.ts +11 -1
  101. package/src/tools/tests/account.test.ts +16 -0
  102. package/src/tools/tests/coPlainText.test.ts +2 -2
  103. package/src/tools/tests/coVector.test-d.ts +40 -0
  104. package/src/tools/tests/coVector.test.ts +891 -0
  105. package/src/tools/tests/createContext.test.ts +19 -19
  106. package/src/tools/tests/deepLoading.test.ts +2 -2
  107. package/src/tools/tests/group.test.ts +59 -0
  108. package/src/tools/tests/inbox.test.ts +2 -2
  109. package/src/tools/tests/utils.ts +3 -3
  110. package/src/worker/index.ts +3 -3
  111. package/dist/chunk-BOMSRY5H.js.map +0 -1
  112. package/dist/chunk-W7JT3QUN.js.map +0 -1
@@ -0,0 +1,105 @@
1
+ import {
2
+ Account,
3
+ AnonymousJazzAgent,
4
+ CoVector,
5
+ Group,
6
+ InstanceOrPrimitiveOfSchema,
7
+ InstanceOrPrimitiveOfSchemaCoValuesNullable,
8
+ coOptionalDefiner,
9
+ } from "../../../internal.js";
10
+ import { CoOptionalSchema } from "./CoOptionalSchema.js";
11
+ import { CoreCoValueSchema } from "./CoValueSchema.js";
12
+
13
+ export interface CoreCoVectorSchema extends CoreCoValueSchema {
14
+ builtin: "CoVector";
15
+ dimensions: number;
16
+ }
17
+
18
+ export function createCoreCoVectorSchema(
19
+ dimensions: number,
20
+ ): CoreCoVectorSchema {
21
+ return {
22
+ collaborative: true as const,
23
+ builtin: "CoVector" as const,
24
+ dimensions,
25
+ };
26
+ }
27
+
28
+ export class CoVectorSchema implements CoreCoVectorSchema {
29
+ readonly collaborative = true as const;
30
+ readonly builtin = "CoVector" as const;
31
+
32
+ constructor(
33
+ public dimensions: number,
34
+ private coValueClass: typeof CoVector,
35
+ ) {}
36
+
37
+ /**
38
+ * Create a `CoVector` from a given vector.
39
+ */
40
+ create(
41
+ vector: number[] | Float32Array,
42
+ options?: { owner: Group } | Group,
43
+ ): CoVectorInstance;
44
+ /**
45
+ * Create a `CoVector` from a given vector.
46
+ *
47
+ * @deprecated Creating CoValues with an Account as owner is deprecated. Use a Group instead.
48
+ */
49
+ create(
50
+ vector: number[] | Float32Array,
51
+ options?: { owner: Account | Group } | Account | Group,
52
+ ): CoVectorInstance;
53
+ create(
54
+ vector: number[] | Float32Array,
55
+ options?: { owner: Account | Group } | Account | Group,
56
+ ): CoVectorInstance {
57
+ return this.coValueClass.create(vector, options);
58
+ }
59
+
60
+ /**
61
+ * Load a `CoVector` with a given ID.
62
+ */
63
+ load(
64
+ id: string,
65
+ options?: { loadAs: Account | AnonymousJazzAgent },
66
+ ): Promise<CoVectorInstanceNullable> {
67
+ return this.coValueClass.load(id, options);
68
+ }
69
+
70
+ /**
71
+ * Subscribe to a `CoVector`, when you have an ID but don't have a `CoVector` instance yet
72
+ */
73
+ subscribe(
74
+ id: string,
75
+ options: { loadAs: Account | AnonymousJazzAgent },
76
+ listener: (
77
+ value: CoVectorInstanceNullable,
78
+ unsubscribe: () => void,
79
+ ) => void,
80
+ ): () => void;
81
+ subscribe(
82
+ id: string,
83
+ listener: (
84
+ value: CoVectorInstanceNullable,
85
+ unsubscribe: () => void,
86
+ ) => void,
87
+ ): () => void;
88
+ subscribe(...args: [any, ...any[]]) {
89
+ // @ts-expect-error
90
+ return this.coValueClass.subscribe(...args);
91
+ }
92
+
93
+ getCoValueClass(): typeof CoVector {
94
+ return this.coValueClass;
95
+ }
96
+
97
+ optional(): CoOptionalSchema<this> {
98
+ return coOptionalDefiner(this);
99
+ }
100
+ }
101
+
102
+ export type CoVectorInstance = InstanceOrPrimitiveOfSchema<CoVectorSchema>;
103
+
104
+ export type CoVectorInstanceNullable =
105
+ InstanceOrPrimitiveOfSchemaCoValuesNullable<CoVectorSchema>;
@@ -14,6 +14,7 @@ import {
14
14
  import { CoreCoValueSchema } from "./CoValueSchema.js";
15
15
  import { coOptionalDefiner } from "../zodCo.js";
16
16
  import { CoOptionalSchema } from "./CoOptionalSchema.js";
17
+ import type { AccountRole, InviteSecret } from "cojson";
17
18
 
18
19
  export interface CoreGroupSchema extends CoreCoValueSchema {
19
20
  builtin: "Group";
@@ -51,7 +52,12 @@ export class GroupSchema implements CoreGroupSchema {
51
52
  ): Promise<Group | null> {
52
53
  return Group.load(id, options);
53
54
  }
54
-
55
+ createInvite<G extends Group>(
56
+ id: ID<G>,
57
+ options?: { role?: AccountRole; loadAs?: Account },
58
+ ): Promise<InviteSecret> {
59
+ return Group.createInvite(id, options);
60
+ }
55
61
  subscribe<G extends Group, const R extends RefsToResolve<G>>(
56
62
  id: ID<G>,
57
63
  listener: (value: Resolved<G, R>, unsubscribe: () => void) => void,
@@ -7,9 +7,11 @@ import {
7
7
  CoMap,
8
8
  CoPlainText,
9
9
  CoRichText,
10
+ CoVector,
10
11
  CoValueClass,
11
12
  CoreAccountSchema,
12
13
  CoreCoRecordSchema,
14
+ CoreCoVectorSchema,
13
15
  FileStream,
14
16
  Group,
15
17
  } from "../../../internal.js";
@@ -63,11 +65,13 @@ export type InstanceOfSchema<S extends CoValueClass | AnyZodOrCoValueSchema> =
63
65
  ? CoRichText
64
66
  : S extends CoreFileStreamSchema
65
67
  ? FileStream
66
- : S extends CoreCoOptionalSchema<infer T>
67
- ? InstanceOrPrimitiveOfSchema<T> | undefined
68
- : S extends CoDiscriminatedUnionSchema<infer Members>
69
- ? InstanceOrPrimitiveOfSchema<Members[number]>
70
- : never
68
+ : S extends CoreCoVectorSchema
69
+ ? Readonly<CoVector>
70
+ : S extends CoreCoOptionalSchema<infer T>
71
+ ? InstanceOrPrimitiveOfSchema<T> | undefined
72
+ : S extends CoDiscriminatedUnionSchema<infer Members>
73
+ ? InstanceOrPrimitiveOfSchema<Members[number]>
74
+ : never
71
75
  : S extends CoValueClass
72
76
  ? InstanceType<S>
73
77
  : never;
@@ -13,6 +13,8 @@ import {
13
13
  CoreCoListSchema,
14
14
  CoreCoMapSchema,
15
15
  CoreCoRecordSchema,
16
+ CoreCoVectorSchema,
17
+ CoVector,
16
18
  FileStream,
17
19
  Group,
18
20
  } from "../../../internal.js";
@@ -70,15 +72,19 @@ export type InstanceOfSchemaCoValuesNullable<
70
72
  ? CoRichText | null
71
73
  : S extends CoreFileStreamSchema
72
74
  ? FileStream | null
73
- : S extends CoreCoOptionalSchema<infer Inner>
74
- ?
75
- | InstanceOrPrimitiveOfSchemaCoValuesNullable<Inner>
76
- | undefined
77
- : S extends CoreCoDiscriminatedUnionSchema<infer Members>
78
- ? InstanceOrPrimitiveOfSchemaCoValuesNullable<
79
- Members[number]
80
- >
81
- : never
75
+ : S extends CoreCoVectorSchema
76
+ ? Readonly<CoVector> | null
77
+ : S extends CoreCoOptionalSchema<infer Inner>
78
+ ?
79
+ | InstanceOrPrimitiveOfSchemaCoValuesNullable<Inner>
80
+ | undefined
81
+ : S extends CoreCoDiscriminatedUnionSchema<
82
+ infer Members
83
+ >
84
+ ? InstanceOrPrimitiveOfSchemaCoValuesNullable<
85
+ Members[number]
86
+ >
87
+ : never
82
88
  : S extends CoValueClass
83
89
  ? InstanceType<S> | null
84
90
  : never;
@@ -9,6 +9,7 @@ import {
9
9
  type CoRecordSchema,
10
10
  type DefaultProfileShape,
11
11
  type FileStreamSchema,
12
+ type CoVectorSchema,
12
13
  ImageDefinition,
13
14
  type PlainTextSchema,
14
15
  type Simplify,
@@ -18,6 +19,7 @@ import {
18
19
  createCoreCoMapSchema,
19
20
  createCoreCoPlainTextSchema,
20
21
  createCoreFileStreamSchema,
22
+ createCoreCoVectorSchema,
21
23
  hydrateCoreCoValueSchema,
22
24
  isAnyCoValueSchema,
23
25
  isCoValueClass,
@@ -193,6 +195,19 @@ export const coFileStreamDefiner = (): FileStreamSchema => {
193
195
  return hydrateCoreCoValueSchema(coreSchema);
194
196
  };
195
197
 
198
+ export const coVectorDefiner = (dimensions: number): CoVectorSchema => {
199
+ const isPositiveInteger = Number.isInteger(dimensions) && dimensions > 0;
200
+
201
+ if (!isPositiveInteger) {
202
+ throw new Error(
203
+ "co.vector() expects the vector dimensions count to be a positive integer",
204
+ );
205
+ }
206
+
207
+ const coreSchema = createCoreCoVectorSchema(dimensions);
208
+ return hydrateCoreCoValueSchema(coreSchema);
209
+ };
210
+
196
211
  export const coPlainTextDefiner = (): PlainTextSchema => {
197
212
  const coreSchema = createCoreCoPlainTextSchema();
198
213
  return hydrateCoreCoValueSchema(coreSchema);
@@ -33,6 +33,10 @@ import {
33
33
  CoreFileStreamSchema,
34
34
  FileStreamSchema,
35
35
  } from "./schemaTypes/FileStreamSchema.js";
36
+ import {
37
+ CoreCoVectorSchema,
38
+ CoVectorSchema,
39
+ } from "./schemaTypes/CoVectorSchema.js";
36
40
  import {
37
41
  CorePlainTextSchema,
38
42
  PlainTextSchema,
@@ -75,11 +79,15 @@ export type CoValueSchemaFromCoreSchema<S extends CoreCoValueSchema> =
75
79
  ? RichTextSchema
76
80
  : S extends CoreFileStreamSchema
77
81
  ? FileStreamSchema
78
- : S extends CoreCoOptionalSchema<infer Inner>
79
- ? CoOptionalSchema<Inner>
80
- : S extends CoreCoDiscriminatedUnionSchema<infer Members>
81
- ? CoDiscriminatedUnionSchema<Members>
82
- : never;
82
+ : S extends CoreCoVectorSchema
83
+ ? CoVectorSchema
84
+ : S extends CoreCoOptionalSchema<infer Inner>
85
+ ? CoOptionalSchema<Inner>
86
+ : S extends CoreCoDiscriminatedUnionSchema<
87
+ infer Members
88
+ >
89
+ ? CoDiscriminatedUnionSchema<Members>
90
+ : never;
83
91
 
84
92
  export type CoValueClassFromAnySchema<S extends CoValueClassOrSchema> =
85
93
  S extends CoValueClass<any>
@@ -104,7 +112,8 @@ export type AnyCoreCoValueSchema =
104
112
  | CoreCoOptionalSchema
105
113
  | CorePlainTextSchema
106
114
  | CoreRichTextSchema
107
- | CoreFileStreamSchema;
115
+ | CoreFileStreamSchema
116
+ | CoreCoVectorSchema;
108
117
 
109
118
  export type AnyZodSchema = z.core.$ZodType;
110
119
 
@@ -16,6 +16,7 @@ export * from "./coValues/inbox.js";
16
16
  export * from "./coValues/coPlainText.js";
17
17
  export * from "./coValues/coRichText.js";
18
18
  export * from "./coValues/schemaUnion.js";
19
+ export * from "./coValues/coVector.js";
19
20
 
20
21
  export type * from "./subscribe/types.js";
21
22
 
@@ -43,6 +44,7 @@ export * from "./implementation/zodSchema/schemaTypes/CoListSchema.js";
43
44
  export * from "./implementation/zodSchema/schemaTypes/CoFeedSchema.js";
44
45
  export * from "./implementation/zodSchema/schemaTypes/AccountSchema.js";
45
46
  export * from "./implementation/zodSchema/schemaTypes/FileStreamSchema.js";
47
+ export * from "./implementation/zodSchema/schemaTypes/CoVectorSchema.js";
46
48
  export * from "./implementation/zodSchema/schemaTypes/PlainTextSchema.js";
47
49
  export * from "./implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.js";
48
50
  export * from "./implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.js";
@@ -5,7 +5,7 @@ import { createAnonymousJazzContext } from "jazz-tools";
5
5
  export function createSSRJazzAgent(opts: { peer: string }) {
6
6
  const ssrNode = createAnonymousJazzContext({
7
7
  crypto: new PureJSCrypto(),
8
- peersToLoadFrom: [],
8
+ peers: [],
9
9
  });
10
10
 
11
11
  const wsPeer = new WebSocketPeerWithReconnection({
@@ -112,7 +112,7 @@ export async function createJazzTestAccount<
112
112
  },
113
113
  initialAgentSecret: crypto.agentSecretFromSecretSeed(secretSeed),
114
114
  crypto,
115
- peersToLoadFrom: peers,
115
+ peers: peers,
116
116
  migration: async (rawAccount, _node, creationProps) => {
117
117
  if (isMigrationActive) {
118
118
  throw new Error(
@@ -185,7 +185,7 @@ export function runWithoutActiveAccount<Result>(
185
185
  export async function createJazzTestGuest() {
186
186
  const ctx = await createAnonymousJazzContext({
187
187
  crypto: await PureJSCrypto.create(),
188
- peersToLoadFrom: [],
188
+ peers: [],
189
189
  });
190
190
 
191
191
  return {
@@ -318,7 +318,7 @@ export class TestJazzContextManager<
318
318
  credentials: authProps?.credentials,
319
319
  defaultProfileName: props.defaultProfileName,
320
320
  newAccountProps: authProps?.newAccountProps,
321
- peersToLoadFrom: [getPeerConnectedToTestSyncServer()],
321
+ peers: [getPeerConnectedToTestSyncServer()],
322
322
  crypto: await TestJSCrypto.create(),
323
323
  sessionProvider: randomSessionProvider,
324
324
  authSecretStorage: this.getAuthSecretStorage(),
@@ -1,6 +1,6 @@
1
1
  // @vitest-environment happy-dom
2
2
 
3
- import { beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
4
4
  import { AuthSecretStorage } from "../auth/AuthSecretStorage";
5
5
  import { InMemoryKVStore } from "../auth/InMemoryKVStore.js";
6
6
  import KvStoreContext from "../auth/KvStoreContext";
@@ -428,4 +428,62 @@ describe("AuthSecretStorage", () => {
428
428
  });
429
429
  });
430
430
  });
431
+
432
+ describe("configurable secret storage key", () => {
433
+ const KEY = "test-auth-secret";
434
+ beforeEach(() => {
435
+ kvStore.clearAll();
436
+ authSecretStorage = new AuthSecretStorage(KEY);
437
+ });
438
+
439
+ afterAll(() => {
440
+ // Restore the default storage key
441
+ authSecretStorage = new AuthSecretStorage();
442
+ });
443
+
444
+ it("should throw an error if the storage key is empty", () => {
445
+ expect(() => new AuthSecretStorage("")).toThrow(
446
+ "Too small: expected string to have >=1 characters",
447
+ );
448
+ });
449
+
450
+ it("should use the configured storage key on get", async () => {
451
+ const credentials = {
452
+ accountID: "test123",
453
+ secretSeed: [1, 2, 3],
454
+ accountSecret: "secret123",
455
+ provider: "anonymous",
456
+ };
457
+ await kvStore.set(KEY, JSON.stringify(credentials));
458
+
459
+ const result = await authSecretStorage.get();
460
+
461
+ expect(result).toEqual({
462
+ accountID: "test123",
463
+ secretSeed: new Uint8Array([1, 2, 3]),
464
+ accountSecret: "secret123",
465
+ provider: "anonymous",
466
+ });
467
+ });
468
+
469
+ it("should use the configured storage key on set", async () => {
470
+ const payload = {
471
+ accountID: "test123" as ID<Account>,
472
+ secretSeed: new Uint8Array([1, 2, 3]),
473
+ accountSecret:
474
+ "secret123" as `sealerSecret_z${string}/signerSecret_z${string}`,
475
+ provider: "passphrase",
476
+ };
477
+
478
+ await authSecretStorage.set(payload);
479
+
480
+ const stored = JSON.parse((await kvStore.get(KEY))!);
481
+ expect(stored).toEqual({
482
+ accountID: "test123",
483
+ secretSeed: [1, 2, 3],
484
+ accountSecret: "secret123",
485
+ provider: "passphrase",
486
+ });
487
+ });
488
+ });
431
489
  });
@@ -56,7 +56,7 @@ class TestJazzContextManager<Acc extends Account> extends JazzContextManager<
56
56
  credentials: authProps?.credentials,
57
57
  defaultProfileName: props.defaultProfileName,
58
58
  newAccountProps: authProps?.newAccountProps,
59
- peersToLoadFrom: [getPeerConnectedToTestSyncServer()],
59
+ peers: [getPeerConnectedToTestSyncServer()],
60
60
  crypto: Crypto,
61
61
  sessionProvider: randomSessionProvider,
62
62
  authSecretStorage: this.getAuthSecretStorage(),
@@ -541,6 +541,16 @@ describe("ContextManager", () => {
541
541
  ).rejects.toThrow("Props required");
542
542
  });
543
543
 
544
+ describe("configurable storage key", () => {
545
+ test("uses the configured storage key", async () => {
546
+ const KEY = "test-auth-secret";
547
+ const manager = new TestJazzContextManager<Account>({
548
+ authSecretStorageKey: KEY,
549
+ });
550
+ expect(manager.getAuthSecretStorage().getStorageKey()).toBe(KEY);
551
+ });
552
+ });
553
+
544
554
  describe("Race condition handling", () => {
545
555
  test("prevents concurrent authentication attempts", async () => {
546
556
  const account = await createJazzTestAccount();
@@ -409,3 +409,19 @@ describe("account.toJSON", () => {
409
409
  });
410
410
  });
411
411
  });
412
+
413
+ describe("accepting invites", () => {
414
+ test("accepting an invite to a Group", async () => {
415
+ const account = await createJazzTestAccount({
416
+ isCurrentActiveAccount: true,
417
+ });
418
+ const group = co.group().create();
419
+ const invite = group.$jazz.createInvite("reader");
420
+ const newAccount = await createJazzTestAccount({
421
+ isCurrentActiveAccount: true,
422
+ });
423
+ expect(group.getRoleOf(newAccount.$jazz.id)).toBeUndefined();
424
+ await newAccount.acceptInvite(group.$jazz.id, invite);
425
+ expect(group.getRoleOf(newAccount.$jazz.id)).toBe("reader");
426
+ });
427
+ });
@@ -205,7 +205,7 @@ describe("CoPlainText", () => {
205
205
  secret: me.$jazz.localNode.getCurrentAgent().agentSecret,
206
206
  },
207
207
  sessionProvider: randomSessionProvider,
208
- peersToLoadFrom: [initialAsPeer],
208
+ peers: [initialAsPeer],
209
209
  crypto: Crypto,
210
210
  asActiveAccount: true,
211
211
  });
@@ -237,7 +237,7 @@ describe("CoPlainText", () => {
237
237
  secret: me.$jazz.localNode.getCurrentAgent().agentSecret,
238
238
  },
239
239
  sessionProvider: randomSessionProvider,
240
- peersToLoadFrom: [initialAsPeer],
240
+ peers: [initialAsPeer],
241
241
  crypto: Crypto,
242
242
  asActiveAccount: true,
243
243
  });
@@ -0,0 +1,40 @@
1
+ import { describe, expectTypeOf, test } from "vitest";
2
+ import { Group, co } from "../exports.js";
3
+ import { CoVectorSchema } from "../internal.js";
4
+
5
+ describe("CoVector types", () => {
6
+ test("co.vector() • defines a correct CoVectorSchema", () => {
7
+ type ExpectedType = CoVectorSchema;
8
+
9
+ function matches(value: ExpectedType) {
10
+ return value;
11
+ }
12
+
13
+ matches(co.vector(384));
14
+ });
15
+
16
+ test("co.vector().create() • creates a CoVector with Float32Array-like typing", () => {
17
+ const embedding = co.vector(3).create([1, 2, 3]);
18
+
19
+ type ExpectedType = Readonly<Float32Array>;
20
+
21
+ function matches(value: ExpectedType) {
22
+ return value;
23
+ }
24
+
25
+ matches(embedding);
26
+ });
27
+
28
+ test("CoVector instance • has the owner property", () => {
29
+ const embedding = co.vector(3).create([1, 2, 3]);
30
+
31
+ expectTypeOf(embedding.$jazz.owner).toEqualTypeOf<Group>();
32
+ });
33
+
34
+ test("setting a value via index access • is a type error", () => {
35
+ const embedding = co.vector(3).create([1, 2, 3]);
36
+
37
+ // @ts-expect-error: assignment to index should be disallowed
38
+ embedding[0] = 6;
39
+ });
40
+ });