cojson 0.7.0-alpha.36 → 0.7.0-alpha.38

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 (106) hide show
  1. package/.eslintrc.cjs +3 -2
  2. package/.prettierrc.js +9 -0
  3. package/.turbo/turbo-build.log +3 -36
  4. package/.turbo/turbo-lint.log +4 -0
  5. package/.turbo/turbo-test.log +1106 -0
  6. package/CHANGELOG.md +12 -0
  7. package/README.md +3 -1
  8. package/dist/base64url.test.js +25 -0
  9. package/dist/base64url.test.js.map +1 -0
  10. package/dist/coValueCore.js +16 -15
  11. package/dist/coValueCore.js.map +1 -1
  12. package/dist/coValues/account.js +16 -15
  13. package/dist/coValues/account.js.map +1 -1
  14. package/dist/coValues/group.js +13 -14
  15. package/dist/coValues/group.js.map +1 -1
  16. package/dist/coreToCoValue.js.map +1 -1
  17. package/dist/crypto/PureJSCrypto.js +89 -0
  18. package/dist/crypto/PureJSCrypto.js.map +1 -0
  19. package/dist/crypto/WasmCrypto.js +127 -0
  20. package/dist/crypto/WasmCrypto.js.map +1 -0
  21. package/dist/crypto/crypto.js +151 -0
  22. package/dist/crypto/crypto.js.map +1 -0
  23. package/dist/ids.js +4 -2
  24. package/dist/ids.js.map +1 -1
  25. package/dist/index.js +5 -9
  26. package/dist/index.js.map +1 -1
  27. package/dist/jsonStringify.js.map +1 -1
  28. package/dist/localNode.js +24 -24
  29. package/dist/localNode.js.map +1 -1
  30. package/dist/permissions.js.map +1 -1
  31. package/dist/storage/FileSystem.js +2 -2
  32. package/dist/storage/FileSystem.js.map +1 -1
  33. package/dist/storage/chunksAndKnownStates.js +2 -2
  34. package/dist/storage/chunksAndKnownStates.js.map +1 -1
  35. package/dist/storage/index.js.map +1 -1
  36. package/dist/sync.js +6 -2
  37. package/dist/sync.js.map +1 -1
  38. package/dist/tests/account.test.js +58 -0
  39. package/dist/tests/account.test.js.map +1 -0
  40. package/dist/tests/coList.test.js +76 -0
  41. package/dist/tests/coList.test.js.map +1 -0
  42. package/dist/tests/coMap.test.js +136 -0
  43. package/dist/tests/coMap.test.js.map +1 -0
  44. package/dist/tests/coStream.test.js +172 -0
  45. package/dist/tests/coStream.test.js.map +1 -0
  46. package/dist/tests/coValueCore.test.js +114 -0
  47. package/dist/tests/coValueCore.test.js.map +1 -0
  48. package/dist/tests/crypto.test.js +118 -0
  49. package/dist/tests/crypto.test.js.map +1 -0
  50. package/dist/tests/cryptoImpl.test.js +113 -0
  51. package/dist/tests/cryptoImpl.test.js.map +1 -0
  52. package/dist/tests/group.test.js +34 -0
  53. package/dist/tests/group.test.js.map +1 -0
  54. package/dist/tests/permissions.test.js +1060 -0
  55. package/dist/tests/permissions.test.js.map +1 -0
  56. package/dist/tests/sync.test.js +816 -0
  57. package/dist/tests/sync.test.js.map +1 -0
  58. package/dist/tests/testUtils.js +10 -9
  59. package/dist/tests/testUtils.js.map +1 -1
  60. package/dist/typeUtils/accountOrAgentIDfromSessionID.js.map +1 -1
  61. package/dist/typeUtils/isAccountID.js.map +1 -1
  62. package/dist/typeUtils/isCoValue.js.map +1 -1
  63. package/package.json +14 -28
  64. package/src/base64url.test.ts +6 -6
  65. package/src/coValue.ts +1 -1
  66. package/src/coValueCore.ts +87 -85
  67. package/src/coValues/account.ts +26 -28
  68. package/src/coValues/coList.ts +10 -10
  69. package/src/coValues/coMap.ts +10 -10
  70. package/src/coValues/coStream.ts +17 -17
  71. package/src/coValues/group.ts +93 -109
  72. package/src/coreToCoValue.ts +5 -2
  73. package/src/crypto/PureJSCrypto.ts +200 -0
  74. package/src/crypto/WasmCrypto.ts +259 -0
  75. package/src/crypto/crypto.ts +336 -0
  76. package/src/ids.ts +8 -7
  77. package/src/index.ts +14 -26
  78. package/src/jsonStringify.ts +6 -4
  79. package/src/jsonValue.ts +2 -2
  80. package/src/localNode.ts +86 -80
  81. package/src/media.ts +3 -3
  82. package/src/permissions.ts +14 -16
  83. package/src/storage/FileSystem.ts +31 -30
  84. package/src/storage/chunksAndKnownStates.ts +24 -17
  85. package/src/storage/index.ts +42 -38
  86. package/src/streamUtils.ts +12 -12
  87. package/src/sync.ts +56 -40
  88. package/src/tests/account.test.ts +8 -12
  89. package/src/tests/coList.test.ts +19 -25
  90. package/src/tests/coMap.test.ts +25 -30
  91. package/src/tests/coStream.test.ts +28 -38
  92. package/src/tests/coValueCore.test.ts +35 -36
  93. package/src/tests/crypto.test.ts +66 -72
  94. package/src/tests/cryptoImpl.test.ts +183 -0
  95. package/src/tests/group.test.ts +16 -17
  96. package/src/tests/permissions.test.ts +237 -254
  97. package/src/tests/sync.test.ts +119 -120
  98. package/src/tests/testUtils.ts +22 -19
  99. package/src/typeUtils/accountOrAgentIDfromSessionID.ts +1 -2
  100. package/src/typeUtils/expectGroup.ts +1 -1
  101. package/src/typeUtils/isAccountID.ts +0 -1
  102. package/src/typeUtils/isCoValue.ts +1 -2
  103. package/tsconfig.json +0 -1
  104. package/dist/crypto.js +0 -255
  105. package/dist/crypto.js.map +0 -1
  106. package/src/crypto.ts +0 -485
@@ -0,0 +1,336 @@
1
+ import { JsonValue } from "../jsonValue.js";
2
+ import { base58 } from "@scure/base";
3
+ import { AgentID, RawCoID, TransactionID } from "../ids.js";
4
+ import { Stringified, parseJSON, stableStringify } from "../jsonStringify.js";
5
+
6
+ export type SignerSecret = `signerSecret_z${string}`;
7
+ export type SignerID = `signer_z${string}`;
8
+ export type Signature = `signature_z${string}`;
9
+
10
+ export type SealerSecret = `sealerSecret_z${string}`;
11
+ export type SealerID = `sealer_z${string}`;
12
+ export type Sealed<T> = `sealed_U${string}` & { __type: T };
13
+
14
+ export type AgentSecret = `${SealerSecret}/${SignerSecret}`;
15
+
16
+ export const textEncoder = new TextEncoder();
17
+ export const textDecoder = new TextDecoder();
18
+
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ export abstract class CryptoProvider<Blake3State = any> {
21
+ abstract randomBytes(length: number): Uint8Array;
22
+
23
+ abstract newEd25519SigningKey(): Uint8Array;
24
+
25
+ newRandomSigner(): SignerSecret {
26
+ return `signerSecret_z${base58.encode(this.newEd25519SigningKey())}`;
27
+ }
28
+
29
+ signerSecretToBytes(secret: SignerSecret): Uint8Array {
30
+ return base58.decode(secret.substring("signerSecret_z".length));
31
+ }
32
+
33
+ signerSecretFromBytes(bytes: Uint8Array): SignerSecret {
34
+ return `signerSecret_z${base58.encode(bytes)}`;
35
+ }
36
+
37
+ abstract getSignerID(secret: SignerSecret): SignerID;
38
+
39
+ abstract sign(secret: SignerSecret, message: JsonValue): Signature;
40
+
41
+ abstract verify(
42
+ signature: Signature,
43
+ message: JsonValue,
44
+ id: SignerID,
45
+ ): boolean;
46
+
47
+ abstract newX25519StaticSecret(): Uint8Array;
48
+
49
+ newRandomSealer(): SealerSecret {
50
+ return `sealerSecret_z${base58.encode(this.newX25519StaticSecret())}`;
51
+ }
52
+
53
+ sealerSecretToBytes(secret: SealerSecret): Uint8Array {
54
+ return base58.decode(secret.substring("sealerSecret_z".length));
55
+ }
56
+
57
+ sealerSecretFromBytes(bytes: Uint8Array): SealerSecret {
58
+ return `sealerSecret_z${base58.encode(bytes)}`;
59
+ }
60
+
61
+ abstract getSealerID(secret: SealerSecret): SealerID;
62
+
63
+ newRandomAgentSecret(): AgentSecret {
64
+ return `${this.newRandomSealer()}/${this.newRandomSigner()}`;
65
+ }
66
+
67
+ agentSecretToBytes(secret: AgentSecret): Uint8Array {
68
+ const [sealerSecret, signerSecret] = secret.split("/");
69
+ return new Uint8Array([
70
+ ...this.sealerSecretToBytes(sealerSecret as SealerSecret),
71
+ ...this.signerSecretToBytes(signerSecret as SignerSecret),
72
+ ]);
73
+ }
74
+
75
+ agentSecretFromBytes(bytes: Uint8Array): AgentSecret {
76
+ const sealerSecret = this.sealerSecretFromBytes(bytes.slice(0, 32));
77
+ const signerSecret = this.signerSecretFromBytes(bytes.slice(32));
78
+ return `${sealerSecret}/${signerSecret}`;
79
+ }
80
+
81
+ getAgentID(secret: AgentSecret): AgentID {
82
+ const [sealerSecret, signerSecret] = secret.split("/");
83
+ return `${this.getSealerID(
84
+ sealerSecret as SealerSecret,
85
+ )}/${this.getSignerID(signerSecret as SignerSecret)}`;
86
+ }
87
+
88
+ getAgentSignerID(agentId: AgentID): SignerID {
89
+ return agentId.split("/")[1] as SignerID;
90
+ }
91
+
92
+ getAgentSignerSecret(agentSecret: AgentSecret): SignerSecret {
93
+ return agentSecret.split("/")[1] as SignerSecret;
94
+ }
95
+
96
+ getAgentSealerID(agentId: AgentID): SealerID {
97
+ return agentId.split("/")[0] as SealerID;
98
+ }
99
+
100
+ getAgentSealerSecret(agentSecret: AgentSecret): SealerSecret {
101
+ return agentSecret.split("/")[0] as SealerSecret;
102
+ }
103
+
104
+ abstract emptyBlake3State(): Blake3State;
105
+ abstract blake3HashOnce(data: Uint8Array): Uint8Array;
106
+ abstract blake3HashOnceWithContext(
107
+ data: Uint8Array,
108
+ { context }: { context: Uint8Array },
109
+ ): Uint8Array;
110
+ abstract blake3IncrementalUpdate(
111
+ state: Blake3State,
112
+ data: Uint8Array,
113
+ ): Blake3State;
114
+ abstract blake3DigestForState(state: Blake3State): Uint8Array;
115
+
116
+ secureHash(value: JsonValue): Hash {
117
+ return `hash_z${base58.encode(
118
+ this.blake3HashOnce(textEncoder.encode(stableStringify(value))),
119
+ )}`;
120
+ }
121
+
122
+ shortHash(value: JsonValue): ShortHash {
123
+ return `shortHash_z${base58.encode(
124
+ this.blake3HashOnce(
125
+ textEncoder.encode(stableStringify(value)),
126
+ ).slice(0, shortHashLength),
127
+ )}`;
128
+ }
129
+
130
+ abstract encrypt<T extends JsonValue, N extends JsonValue>(
131
+ value: T,
132
+ keySecret: KeySecret,
133
+ nOnceMaterial: N,
134
+ ): Encrypted<T, N>;
135
+
136
+ encryptForTransaction<T extends JsonValue>(
137
+ value: T,
138
+ keySecret: KeySecret,
139
+ nOnceMaterial: { in: RawCoID; tx: TransactionID },
140
+ ): Encrypted<T, { in: RawCoID; tx: TransactionID }> {
141
+ return this.encrypt(value, keySecret, nOnceMaterial);
142
+ }
143
+
144
+ abstract decryptRaw<T extends JsonValue, N extends JsonValue>(
145
+ encrypted: Encrypted<T, N>,
146
+ keySecret: KeySecret,
147
+ nOnceMaterial: N,
148
+ ): Stringified<T>;
149
+
150
+ decrypt<T extends JsonValue, N extends JsonValue>(
151
+ encrypted: Encrypted<T, N>,
152
+ keySecret: KeySecret,
153
+ nOnceMaterial: N,
154
+ ): T | undefined {
155
+ try {
156
+ return parseJSON(
157
+ this.decryptRaw(encrypted, keySecret, nOnceMaterial),
158
+ );
159
+ } catch (e) {
160
+ console.error("Decryption error", e);
161
+ return undefined;
162
+ }
163
+ }
164
+
165
+ newRandomKeySecret(): { secret: KeySecret; id: KeyID } {
166
+ return {
167
+ secret: `keySecret_z${base58.encode(this.randomBytes(32))}`,
168
+ id: `key_z${base58.encode(this.randomBytes(12))}`,
169
+ };
170
+ }
171
+
172
+ decryptRawForTransaction<T extends JsonValue>(
173
+ encrypted: Encrypted<T, { in: RawCoID; tx: TransactionID }>,
174
+ keySecret: KeySecret,
175
+ nOnceMaterial: { in: RawCoID; tx: TransactionID },
176
+ ): Stringified<T> | undefined {
177
+ return this.decryptRaw(encrypted, keySecret, nOnceMaterial);
178
+ }
179
+
180
+ decryptForTransaction<T extends JsonValue>(
181
+ encrypted: Encrypted<T, { in: RawCoID; tx: TransactionID }>,
182
+ keySecret: KeySecret,
183
+ nOnceMaterial: { in: RawCoID; tx: TransactionID },
184
+ ): T | undefined {
185
+ return this.decrypt(encrypted, keySecret, nOnceMaterial);
186
+ }
187
+
188
+ encryptKeySecret(keys: {
189
+ toEncrypt: { id: KeyID; secret: KeySecret };
190
+ encrypting: { id: KeyID; secret: KeySecret };
191
+ }): {
192
+ encryptedID: KeyID;
193
+ encryptingID: KeyID;
194
+ encrypted: Encrypted<
195
+ KeySecret,
196
+ { encryptedID: KeyID; encryptingID: KeyID }
197
+ >;
198
+ } {
199
+ const nOnceMaterial = {
200
+ encryptedID: keys.toEncrypt.id,
201
+ encryptingID: keys.encrypting.id,
202
+ };
203
+
204
+ return {
205
+ encryptedID: keys.toEncrypt.id,
206
+ encryptingID: keys.encrypting.id,
207
+ encrypted: this.encrypt(
208
+ keys.toEncrypt.secret,
209
+ keys.encrypting.secret,
210
+ nOnceMaterial,
211
+ ),
212
+ };
213
+ }
214
+
215
+ decryptKeySecret(
216
+ encryptedInfo: {
217
+ encryptedID: KeyID;
218
+ encryptingID: KeyID;
219
+ encrypted: Encrypted<
220
+ KeySecret,
221
+ { encryptedID: KeyID; encryptingID: KeyID }
222
+ >;
223
+ },
224
+ sealingSecret: KeySecret,
225
+ ): KeySecret | undefined {
226
+ const nOnceMaterial = {
227
+ encryptedID: encryptedInfo.encryptedID,
228
+ encryptingID: encryptedInfo.encryptingID,
229
+ };
230
+
231
+ return this.decrypt(
232
+ encryptedInfo.encrypted,
233
+ sealingSecret,
234
+ nOnceMaterial,
235
+ );
236
+ }
237
+
238
+ abstract seal<T extends JsonValue>({
239
+ message,
240
+ from,
241
+ to,
242
+ nOnceMaterial,
243
+ }: {
244
+ message: T;
245
+ from: SealerSecret;
246
+ to: SealerID;
247
+ nOnceMaterial: { in: RawCoID; tx: TransactionID };
248
+ }): Sealed<T>;
249
+
250
+ abstract unseal<T extends JsonValue>(
251
+ sealed: Sealed<T>,
252
+ sealer: SealerSecret,
253
+ from: SealerID,
254
+ nOnceMaterial: { in: RawCoID; tx: TransactionID },
255
+ ): T | undefined;
256
+
257
+ uniquenessForHeader(): `z${string}` {
258
+ return `z${base58.encode(this.randomBytes(12))}`;
259
+ }
260
+
261
+ createdNowUnique(): {
262
+ createdAt: `2${string}`;
263
+ uniqueness: `z${string}`;
264
+ } {
265
+ const createdAt = new Date().toISOString() as `2${string}`;
266
+ return {
267
+ createdAt,
268
+ uniqueness: this.uniquenessForHeader(),
269
+ };
270
+ }
271
+
272
+ newRandomSecretSeed(): Uint8Array {
273
+ return this.randomBytes(secretSeedLength);
274
+ }
275
+
276
+ agentSecretFromSecretSeed(secretSeed: Uint8Array): AgentSecret {
277
+ if (secretSeed.length !== secretSeedLength) {
278
+ throw new Error(
279
+ `Secret seed needs to be ${secretSeedLength} bytes long`,
280
+ );
281
+ }
282
+
283
+ return `sealerSecret_z${base58.encode(
284
+ this.blake3HashOnceWithContext(secretSeed, {
285
+ context: textEncoder.encode("seal"),
286
+ }),
287
+ )}/signerSecret_z${base58.encode(
288
+ this.blake3HashOnceWithContext(secretSeed, {
289
+ context: textEncoder.encode("sign"),
290
+ }),
291
+ )}`;
292
+ }
293
+ }
294
+
295
+ export type Hash = `hash_z${string}`;
296
+
297
+ export class StreamingHash {
298
+ state: Uint8Array;
299
+ crypto: CryptoProvider;
300
+
301
+ constructor(crypto: CryptoProvider, fromClone?: Uint8Array) {
302
+ this.state = fromClone || crypto.emptyBlake3State();
303
+ this.crypto = crypto;
304
+ }
305
+
306
+ update(value: JsonValue): Uint8Array {
307
+ const encoded = textEncoder.encode(stableStringify(value));
308
+ // const before = performance.now();
309
+ this.state = this.crypto.blake3IncrementalUpdate(this.state, encoded);
310
+ // const after = performance.now();
311
+ // console.log(`Hashing throughput in MB/s`, 1000 * (encoded.length / (after - before)) / (1024 * 1024));
312
+ return encoded;
313
+ }
314
+
315
+ digest(): Hash {
316
+ const hash = this.crypto.blake3DigestForState(this.state);
317
+ return `hash_z${base58.encode(hash)}`;
318
+ }
319
+
320
+ clone(): StreamingHash {
321
+ return new StreamingHash(this.crypto, new Uint8Array(this.state));
322
+ }
323
+ }
324
+
325
+ export type ShortHash = `shortHash_z${string}`;
326
+ export const shortHashLength = 19;
327
+
328
+ export type Encrypted<
329
+ T extends JsonValue,
330
+ N extends JsonValue,
331
+ > = `encrypted_U${string}` & { __type: T; __nOnceMaterial: N };
332
+
333
+ export type KeySecret = `keySecret_z${string}`;
334
+ export type KeyID = `key_z${string}`;
335
+
336
+ export const secretSeedLength = 32;
package/src/ids.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { AccountID } from './coValues/account.js';
1
+ import { AccountID } from "./coValues/account.js";
2
2
  import { base58 } from "@scure/base";
3
- import { shortHashLength } from './crypto.js';
4
-
3
+ import { shortHashLength } from "./crypto/crypto.js";
5
4
 
6
5
  export type RawCoID = `co_z${string}`;
7
6
 
@@ -10,9 +9,7 @@ export function isRawCoID(id: unknown): id is RawCoID {
10
9
  }
11
10
 
12
11
  export function rawCoIDtoBytes(id: RawCoID): Uint8Array {
13
- return base58.decode(
14
- id.substring("co_z".length)
15
- )
12
+ return base58.decode(id.substring("co_z".length));
16
13
  }
17
14
 
18
15
  export function rawCoIDfromBytes(bytes: Uint8Array): RawCoID {
@@ -24,7 +21,11 @@ export type TransactionID = { sessionID: SessionID; txIndex: number };
24
21
  export type AgentID = `sealer_z${string}/signer_z${string}`;
25
22
 
26
23
  export function isAgentID(id: string): id is AgentID {
27
- return typeof id === "string" && id.startsWith("sealer_") && id.includes("/signer_");
24
+ return (
25
+ typeof id === "string" &&
26
+ id.startsWith("sealer_") &&
27
+ id.includes("/signer_")
28
+ );
28
29
  }
29
30
 
30
31
  export type SessionID = `${AccountID | AgentID}_session_z${string}`;
package/src/index.ts CHANGED
@@ -11,17 +11,13 @@ import { RawCoMap } from "./coValues/coMap.js";
11
11
  import { RawCoList } from "./coValues/coList.js";
12
12
  import { RawCoStream, RawBinaryCoStream } from "./coValues/coStream.js";
13
13
  import {
14
- agentSecretFromBytes,
15
- agentSecretToBytes,
16
- getAgentID,
17
- newRandomAgentSecret,
18
- newRandomSecretSeed,
19
- agentSecretFromSecretSeed,
20
14
  secretSeedLength,
21
15
  shortHashLength,
22
- cryptoReady,
23
- StreamingHash
24
- } from "./crypto.js";
16
+ StreamingHash,
17
+ CryptoProvider,
18
+ } from "./crypto/crypto.js";
19
+ import { WasmCrypto } from "./crypto/WasmCrypto.js";
20
+ import { PureJSCrypto } from "./crypto/PureJSCrypto.js";
25
21
  import { connectedPeers } from "./streamUtils.js";
26
22
  import { ControlledAgent, RawControlledAccount } from "./coValues/account.js";
27
23
  import type { Role } from "./permissions.js";
@@ -46,7 +42,7 @@ import type {
46
42
  } from "./coValues/coStream.js";
47
43
  import type { JsonValue } from "./jsonValue.js";
48
44
  import type { SyncMessage, Peer } from "./sync.js";
49
- import type { AgentSecret } from "./crypto.js";
45
+ import type { AgentSecret } from "./crypto/crypto.js";
50
46
  import type {
51
47
  AccountID,
52
48
  AccountMeta,
@@ -67,16 +63,10 @@ import { FileSystem } from "./storage/FileSystem.js";
67
63
 
68
64
  /** @hidden */
69
65
  export const cojsonInternals = {
70
- agentSecretFromBytes,
71
- agentSecretToBytes,
72
66
  newRandomSessionID,
73
- newRandomAgentSecret,
74
67
  connectedPeers,
75
- getAgentID,
76
68
  rawCoIDtoBytes,
77
69
  rawCoIDfromBytes,
78
- newRandomSecretSeed,
79
- agentSecretFromSecretSeed,
80
70
  secretSeedLength,
81
71
  shortHashLength,
82
72
  expectGroup,
@@ -87,7 +77,7 @@ export const cojsonInternals = {
87
77
  isAccountID,
88
78
  accountHeaderForInitialAgentSecret,
89
79
  idforHeader,
90
- StreamingHash
80
+ StreamingHash,
91
81
  };
92
82
 
93
83
  export {
@@ -113,7 +103,6 @@ export {
113
103
  CoValueCore,
114
104
  ControlledAgent,
115
105
  RawControlledAccount,
116
- cryptoReady as cojsonReady,
117
106
  MAX_RECOMMENDED_TX_SIZE,
118
107
  JsonValue,
119
108
  Peer,
@@ -122,16 +111,15 @@ export {
122
111
  AgentID,
123
112
  AgentSecret,
124
113
  InviteSecret,
114
+ CryptoProvider,
115
+ WasmCrypto,
116
+ PureJSCrypto,
125
117
  SyncMessage,
126
118
  isRawCoID,
127
- FileSystem,
128
119
  LSMStorage,
129
- FSErr,
130
- BlockFilename,
131
- WalFilename,
132
120
  };
133
121
 
134
- export type { Value };
122
+ export type { Value, FileSystem, FSErr, BlockFilename, WalFilename };
135
123
 
136
124
  // eslint-disable-next-line @typescript-eslint/no-namespace
137
125
  export namespace CojsonInternalTypes {
@@ -143,10 +131,10 @@ export namespace CojsonInternalTypes {
143
131
  export type CoValueHeader = import("./coValueCore.js").CoValueHeader;
144
132
  export type Transaction = import("./coValueCore.js").Transaction;
145
133
  export type TransactionID = import("./ids.js").TransactionID;
146
- export type Signature = import("./crypto.js").Signature;
134
+ export type Signature = import("./crypto/crypto.js").Signature;
147
135
  export type RawCoID = import("./ids.js").RawCoID;
148
136
  export type ProfileShape = import("./coValues/account.js").ProfileShape;
149
- export type SealerSecret = import("./crypto.js").SealerSecret;
150
- export type SignerSecret = import("./crypto.js").SignerSecret;
137
+ export type SealerSecret = import("./crypto/crypto.js").SealerSecret;
138
+ export type SignerSecret = import("./crypto/crypto.js").SignerSecret;
151
139
  export type JsonObject = import("./jsonValue.js").JsonObject;
152
140
  }
@@ -2,9 +2,11 @@
2
2
 
3
3
  export type Stringified<T> = string & { __type: T };
4
4
 
5
- export function stableStringify<T>(data: T): Stringified<T>
6
- export function stableStringify(data: undefined): undefined
7
- export function stableStringify<T>(data: T | undefined): Stringified<T> | undefined {
5
+ export function stableStringify<T>(data: T): Stringified<T>;
6
+ export function stableStringify(data: undefined): undefined;
7
+ export function stableStringify<T>(
8
+ data: T | undefined,
9
+ ): Stringified<T> | undefined {
8
10
  const cycles = false;
9
11
 
10
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -63,4 +65,4 @@ export function stableStringify<T>(data: T | undefined): Stringified<T> | undefi
63
65
 
64
66
  export function parseJSON<T>(json: Stringified<T>): T {
65
67
  return JSON.parse(json);
66
- }
68
+ }
package/src/jsonValue.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { RawCoID } from './ids.js';
1
+ import { RawCoID } from "./ids.js";
2
2
 
3
3
  export type JsonAtom = string | number | boolean | null;
4
4
  export type JsonValue = JsonAtom | JsonArray | JsonObject | RawCoID;
5
5
  export type JsonArray = JsonValue[] | readonly JsonValue[];
6
- export type JsonObject = { [key: string]: JsonValue | undefined; };
6
+ export type JsonObject = { [key: string]: JsonValue | undefined };