cojson 0.13.17 → 0.13.20
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 +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/PeerState.d.ts +4 -1
- package/dist/PeerState.d.ts.map +1 -1
- package/dist/PeerState.js +16 -36
- package/dist/PeerState.js.map +1 -1
- package/dist/SyncStateManager.d.ts.map +1 -1
- package/dist/SyncStateManager.js +2 -3
- package/dist/SyncStateManager.js.map +1 -1
- package/dist/coValue.d.ts +4 -4
- package/dist/coValue.d.ts.map +1 -1
- package/dist/coValue.js +4 -4
- package/dist/coValue.js.map +1 -1
- package/dist/coValueCore/coValueCore.d.ts +143 -0
- package/dist/coValueCore/coValueCore.d.ts.map +1 -0
- package/dist/{coValueCore.js → coValueCore/coValueCore.js} +325 -253
- package/dist/coValueCore/coValueCore.js.map +1 -0
- package/dist/coValueCore/verifiedState.d.ts +65 -0
- package/dist/coValueCore/verifiedState.d.ts.map +1 -0
- package/dist/coValueCore/verifiedState.js +210 -0
- package/dist/coValueCore/verifiedState.js.map +1 -0
- package/dist/coValues/account.d.ts +8 -10
- package/dist/coValues/account.d.ts.map +1 -1
- package/dist/coValues/account.js +12 -13
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.d.ts +3 -3
- package/dist/coValues/coList.d.ts.map +1 -1
- package/dist/coValues/coList.js +6 -3
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.d.ts +3 -3
- package/dist/coValues/coMap.d.ts.map +1 -1
- package/dist/coValues/coMap.js +3 -3
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coPlainText.d.ts +2 -2
- package/dist/coValues/coPlainText.d.ts.map +1 -1
- package/dist/coValues/coPlainText.js +4 -4
- package/dist/coValues/coPlainText.js.map +1 -1
- package/dist/coValues/coStream.d.ts +3 -3
- package/dist/coValues/coStream.d.ts.map +1 -1
- package/dist/coValues/coStream.js +3 -3
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/group.d.ts +7 -2
- package/dist/coValues/group.d.ts.map +1 -1
- package/dist/coValues/group.js +29 -26
- package/dist/coValues/group.js.map +1 -1
- package/dist/coreToCoValue.d.ts +2 -2
- package/dist/coreToCoValue.d.ts.map +1 -1
- package/dist/coreToCoValue.js +10 -14
- package/dist/coreToCoValue.js.map +1 -1
- package/dist/exports.d.ts +6 -5
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +3 -4
- package/dist/exports.js.map +1 -1
- package/dist/localNode.d.ts +30 -24
- package/dist/localNode.d.ts.map +1 -1
- package/dist/localNode.js +147 -173
- package/dist/localNode.js.map +1 -1
- package/dist/permissions.d.ts +2 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +15 -11
- package/dist/permissions.js.map +1 -1
- package/dist/priority.d.ts +1 -1
- package/dist/priority.d.ts.map +1 -1
- package/dist/streamUtils.d.ts +5 -5
- package/dist/streamUtils.d.ts.map +1 -1
- package/dist/streamUtils.js +5 -20
- package/dist/streamUtils.js.map +1 -1
- package/dist/sync.d.ts +8 -6
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +121 -74
- package/dist/sync.js.map +1 -1
- package/dist/tests/PeerState.test.js +0 -31
- package/dist/tests/PeerState.test.js.map +1 -1
- package/dist/tests/SyncStateManager.test.js +41 -6
- package/dist/tests/SyncStateManager.test.js.map +1 -1
- package/dist/tests/account.test.js +16 -0
- package/dist/tests/account.test.js.map +1 -1
- package/dist/tests/coList.test.js +19 -16
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coMap.test.js +12 -13
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coPlainText.test.js +9 -10
- package/dist/tests/coPlainText.test.js.map +1 -1
- package/dist/tests/coStream.test.js +22 -17
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/coValueCore.test.js +22 -28
- package/dist/tests/coValueCore.test.js.map +1 -1
- package/dist/tests/coValueCoreLoadingState.test.d.ts +2 -0
- package/dist/tests/coValueCoreLoadingState.test.d.ts.map +1 -0
- package/dist/tests/{coValueState.test.js → coValueCoreLoadingState.test.js} +62 -46
- package/dist/tests/coValueCoreLoadingState.test.js.map +1 -0
- package/dist/tests/group.test.js +42 -43
- package/dist/tests/group.test.js.map +1 -1
- package/dist/tests/messagesTestUtils.d.ts +2 -2
- package/dist/tests/messagesTestUtils.d.ts.map +1 -1
- package/dist/tests/messagesTestUtils.js +1 -1
- package/dist/tests/messagesTestUtils.js.map +1 -1
- package/dist/tests/permissions.test.js +224 -292
- package/dist/tests/permissions.test.js.map +1 -1
- package/dist/tests/priority.test.js +13 -14
- package/dist/tests/priority.test.js.map +1 -1
- package/dist/tests/sync.auth.test.d.ts +2 -0
- package/dist/tests/sync.auth.test.d.ts.map +1 -0
- package/dist/tests/sync.auth.test.js +190 -0
- package/dist/tests/sync.auth.test.js.map +1 -0
- package/dist/tests/sync.load.test.js +6 -6
- package/dist/tests/sync.load.test.js.map +1 -1
- package/dist/tests/sync.mesh.test.js +25 -12
- package/dist/tests/sync.mesh.test.js.map +1 -1
- package/dist/tests/sync.peerReconciliation.test.js +19 -19
- package/dist/tests/sync.peerReconciliation.test.js.map +1 -1
- package/dist/tests/sync.storage.test.js +20 -13
- package/dist/tests/sync.storage.test.js.map +1 -1
- package/dist/tests/sync.test.js +32 -39
- package/dist/tests/sync.test.js.map +1 -1
- package/dist/tests/sync.upload.test.js +126 -37
- package/dist/tests/sync.upload.test.js.map +1 -1
- package/dist/tests/testUtils.d.ts +35 -17
- package/dist/tests/testUtils.d.ts.map +1 -1
- package/dist/tests/testUtils.js +103 -79
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/typeUtils/expectGroup.js +1 -1
- package/dist/typeUtils/expectGroup.js.map +1 -1
- package/package.json +1 -1
- package/src/PeerState.ts +19 -40
- package/src/SyncStateManager.ts +2 -3
- package/src/coValue.ts +11 -8
- package/src/{coValueCore.ts → coValueCore/coValueCore.ts} +478 -422
- package/src/coValueCore/verifiedState.ts +376 -0
- package/src/coValues/account.ts +20 -25
- package/src/coValues/coList.ts +12 -6
- package/src/coValues/coMap.ts +9 -6
- package/src/coValues/coPlainText.ts +9 -6
- package/src/coValues/coStream.ts +9 -6
- package/src/coValues/group.ts +50 -28
- package/src/coreToCoValue.ts +14 -15
- package/src/exports.ts +9 -7
- package/src/localNode.ts +236 -275
- package/src/permissions.ts +18 -12
- package/src/priority.ts +1 -1
- package/src/streamUtils.ts +7 -34
- package/src/sync.ts +146 -84
- package/src/tests/PeerState.test.ts +0 -37
- package/src/tests/SyncStateManager.test.ts +56 -6
- package/src/tests/account.test.ts +24 -0
- package/src/tests/coList.test.ts +21 -15
- package/src/tests/coMap.test.ts +12 -13
- package/src/tests/coPlainText.test.ts +12 -9
- package/src/tests/coStream.test.ts +25 -16
- package/src/tests/coValueCore.test.ts +30 -27
- package/src/tests/{coValueState.test.ts → coValueCoreLoadingState.test.ts} +67 -57
- package/src/tests/group.test.ts +44 -69
- package/src/tests/messagesTestUtils.ts +3 -8
- package/src/tests/permissions.test.ts +283 -449
- package/src/tests/priority.test.ts +17 -13
- package/src/tests/sync.auth.test.ts +246 -0
- package/src/tests/sync.load.test.ts +7 -6
- package/src/tests/sync.mesh.test.ts +25 -12
- package/src/tests/sync.peerReconciliation.test.ts +25 -25
- package/src/tests/sync.storage.test.ts +20 -13
- package/src/tests/sync.test.ts +43 -43
- package/src/tests/sync.upload.test.ts +157 -37
- package/src/tests/testUtils.ts +143 -96
- package/src/typeUtils/expectGroup.ts +1 -1
- package/dist/CoValuesStore.d.ts +0 -14
- package/dist/CoValuesStore.d.ts.map +0 -1
- package/dist/CoValuesStore.js +0 -32
- package/dist/CoValuesStore.js.map +0 -1
- package/dist/coValueCore.d.ts +0 -142
- package/dist/coValueCore.d.ts.map +0 -1
- package/dist/coValueCore.js.map +0 -1
- package/dist/coValueState.d.ts +0 -34
- package/dist/coValueState.d.ts.map +0 -1
- package/dist/coValueState.js +0 -190
- package/dist/coValueState.js.map +0 -1
- package/dist/tests/coValueState.test.d.ts +0 -2
- package/dist/tests/coValueState.test.d.ts.map +0 -1
- package/dist/tests/coValueState.test.js.map +0 -1
- package/src/CoValuesStore.ts +0 -41
- package/src/coValueState.ts +0 -245
package/src/coValues/group.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { base58 } from "@scure/base";
|
|
2
2
|
import { CoID } from "../coValue.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
AvailableCoValueCore,
|
|
5
|
+
CoValueCore,
|
|
6
|
+
} from "../coValueCore/coValueCore.js";
|
|
7
|
+
import { CoValueUniqueness } from "../coValueCore/verifiedState.js";
|
|
8
|
+
import {
|
|
9
|
+
CryptoProvider,
|
|
10
|
+
Encrypted,
|
|
11
|
+
KeyID,
|
|
12
|
+
KeySecret,
|
|
13
|
+
Sealed,
|
|
14
|
+
} from "../crypto/crypto.js";
|
|
5
15
|
import {
|
|
6
16
|
AgentID,
|
|
7
17
|
ChildGroupReference,
|
|
@@ -17,6 +27,7 @@ import { logger } from "../logger.js";
|
|
|
17
27
|
import { AccountRole, Role } from "../permissions.js";
|
|
18
28
|
import { expectGroup } from "../typeUtils/expectGroup.js";
|
|
19
29
|
import {
|
|
30
|
+
ControlledAccount,
|
|
20
31
|
ControlledAccountOrAgent,
|
|
21
32
|
RawAccount,
|
|
22
33
|
RawAccountID,
|
|
@@ -77,6 +88,18 @@ export type GroupShape = {
|
|
|
77
88
|
export class RawGroup<
|
|
78
89
|
Meta extends JsonObject | null = JsonObject | null,
|
|
79
90
|
> extends RawCoMap<GroupShape, Meta> {
|
|
91
|
+
protected readonly crypto: CryptoProvider;
|
|
92
|
+
|
|
93
|
+
constructor(
|
|
94
|
+
core: AvailableCoValueCore,
|
|
95
|
+
options?: {
|
|
96
|
+
ignorePrivateTransactions: boolean;
|
|
97
|
+
},
|
|
98
|
+
) {
|
|
99
|
+
super(core, options);
|
|
100
|
+
this.crypto = core.node.crypto;
|
|
101
|
+
}
|
|
102
|
+
|
|
80
103
|
/**
|
|
81
104
|
* Returns the current role of a given account.
|
|
82
105
|
*
|
|
@@ -174,7 +197,6 @@ export class RawGroup<
|
|
|
174
197
|
|
|
175
198
|
loadAllChildGroups() {
|
|
176
199
|
const requests: Promise<unknown>[] = [];
|
|
177
|
-
const store = this.core.node.coValuesStore;
|
|
178
200
|
const peers = this.core.node.syncManager.getServerAndStoragePeers();
|
|
179
201
|
|
|
180
202
|
for (const key of this.keys()) {
|
|
@@ -183,11 +205,11 @@ export class RawGroup<
|
|
|
183
205
|
}
|
|
184
206
|
|
|
185
207
|
const id = getChildGroupId(key);
|
|
186
|
-
const child =
|
|
208
|
+
const child = this.core.node.getCoValue(id);
|
|
187
209
|
|
|
188
210
|
if (
|
|
189
|
-
child.
|
|
190
|
-
child.
|
|
211
|
+
child.loadingState === "unknown" ||
|
|
212
|
+
child.loadingState === "unavailable"
|
|
191
213
|
) {
|
|
192
214
|
child.loadFromPeers(peers).catch(() => {
|
|
193
215
|
logger.error(`Failed to load child group ${id}`);
|
|
@@ -195,8 +217,8 @@ export class RawGroup<
|
|
|
195
217
|
}
|
|
196
218
|
|
|
197
219
|
requests.push(
|
|
198
|
-
child.
|
|
199
|
-
if (coValue
|
|
220
|
+
child.waitForAvailableOrUnavailable().then((coValue) => {
|
|
221
|
+
if (!coValue.isAvailable()) {
|
|
200
222
|
throw new Error(`Child group ${child.id} is unavailable`);
|
|
201
223
|
}
|
|
202
224
|
|
|
@@ -236,7 +258,7 @@ export class RawGroup<
|
|
|
236
258
|
* @category 1. Role reading
|
|
237
259
|
*/
|
|
238
260
|
myRole(): Role | undefined {
|
|
239
|
-
return this.roleOfInternal(this.core.node.
|
|
261
|
+
return this.roleOfInternal(this.core.node.getCurrentAgent().id);
|
|
240
262
|
}
|
|
241
263
|
|
|
242
264
|
/**
|
|
@@ -357,7 +379,7 @@ export class RawGroup<
|
|
|
357
379
|
memberKey: RawAccountID | AgentID,
|
|
358
380
|
agent: AgentID,
|
|
359
381
|
) {
|
|
360
|
-
const writeKeyForNewMember = this.
|
|
382
|
+
const writeKeyForNewMember = this.crypto.newRandomKeySecret();
|
|
361
383
|
|
|
362
384
|
this.set(`writeKeyFor_${memberKey}`, writeKeyForNewMember.id, "trusting");
|
|
363
385
|
|
|
@@ -404,10 +426,10 @@ export class RawGroup<
|
|
|
404
426
|
) {
|
|
405
427
|
this.set(
|
|
406
428
|
`${keyID}_for_${memberKey}`,
|
|
407
|
-
this.
|
|
429
|
+
this.crypto.seal({
|
|
408
430
|
message: secret,
|
|
409
|
-
from: this.core.node.
|
|
410
|
-
to: this.
|
|
431
|
+
from: this.core.node.getCurrentAgent().currentSealerSecret(),
|
|
432
|
+
to: this.crypto.getAgentSealerID(agent),
|
|
411
433
|
nOnceMaterial: {
|
|
412
434
|
in: this.id,
|
|
413
435
|
tx: this.core.nextTransactionID(),
|
|
@@ -433,7 +455,7 @@ export class RawGroup<
|
|
|
433
455
|
|
|
434
456
|
getCurrentReadKeyId() {
|
|
435
457
|
if (this.myRole() === "writeOnly") {
|
|
436
|
-
const accountId = this.core.node.
|
|
458
|
+
const accountId = this.core.node.getCurrentAgent().id;
|
|
437
459
|
|
|
438
460
|
const key = this.get(`writeKeyFor_${accountId}`) as KeyID;
|
|
439
461
|
|
|
@@ -441,7 +463,7 @@ export class RawGroup<
|
|
|
441
463
|
if (!key && this.get("everyone") === "writeOnly") {
|
|
442
464
|
this.internalCreateWriteOnlyKeyForMember(
|
|
443
465
|
accountId,
|
|
444
|
-
this.core.node.
|
|
466
|
+
this.core.node.getCurrentAgent().currentAgentID(),
|
|
445
467
|
);
|
|
446
468
|
|
|
447
469
|
return this.get(`writeKeyFor_${accountId}`) as KeyID;
|
|
@@ -509,7 +531,7 @@ export class RawGroup<
|
|
|
509
531
|
secret: maybeCurrentReadKey.secret,
|
|
510
532
|
};
|
|
511
533
|
|
|
512
|
-
const newReadKey = this.
|
|
534
|
+
const newReadKey = this.crypto.newRandomKeySecret();
|
|
513
535
|
|
|
514
536
|
for (const readerID of currentlyPermittedReaders) {
|
|
515
537
|
const agent = this.core.node
|
|
@@ -539,7 +561,7 @@ export class RawGroup<
|
|
|
539
561
|
)
|
|
540
562
|
._unsafeUnwrap({ withStackTrace: true });
|
|
541
563
|
|
|
542
|
-
const writeOnlyKey = this.
|
|
564
|
+
const writeOnlyKey = this.crypto.newRandomKeySecret();
|
|
543
565
|
|
|
544
566
|
this.storeKeyRevelationForMember(
|
|
545
567
|
writeOnlyMemberID,
|
|
@@ -568,7 +590,7 @@ export class RawGroup<
|
|
|
568
590
|
|
|
569
591
|
this.set(
|
|
570
592
|
`${currentReadKey.id}_for_${newReadKey.id}`,
|
|
571
|
-
this.
|
|
593
|
+
this.crypto.encryptKeySecret({
|
|
572
594
|
encrypting: newReadKey,
|
|
573
595
|
toEncrypt: currentReadKey,
|
|
574
596
|
}).encrypted,
|
|
@@ -594,7 +616,7 @@ export class RawGroup<
|
|
|
594
616
|
|
|
595
617
|
this.set(
|
|
596
618
|
`${newReadKey.id}_for_${parentReadKeyID}`,
|
|
597
|
-
this.
|
|
619
|
+
this.crypto.encryptKeySecret({
|
|
598
620
|
encrypting: {
|
|
599
621
|
id: parentReadKeyID,
|
|
600
622
|
secret: parentReadKeySecret,
|
|
@@ -678,7 +700,7 @@ export class RawGroup<
|
|
|
678
700
|
|
|
679
701
|
this.set(
|
|
680
702
|
`${childReadKeyID}_for_${parentReadKeyID}`,
|
|
681
|
-
this.
|
|
703
|
+
this.crypto.encryptKeySecret({
|
|
682
704
|
encrypting: {
|
|
683
705
|
id: parentReadKeyID,
|
|
684
706
|
secret: parentReadKeySecret,
|
|
@@ -763,10 +785,10 @@ export class RawGroup<
|
|
|
763
785
|
* @category 2. Role changing
|
|
764
786
|
*/
|
|
765
787
|
createInvite(role: AccountRole): InviteSecret {
|
|
766
|
-
const secretSeed = this.
|
|
788
|
+
const secretSeed = this.crypto.newRandomSecretSeed();
|
|
767
789
|
|
|
768
|
-
const inviteSecret = this.
|
|
769
|
-
const inviteID = this.
|
|
790
|
+
const inviteSecret = this.crypto.agentSecretFromSecretSeed(secretSeed);
|
|
791
|
+
const inviteID = this.crypto.getAgentID(inviteSecret);
|
|
770
792
|
|
|
771
793
|
this.addMemberInternal(inviteID, `${role}Invite` as Role);
|
|
772
794
|
|
|
@@ -783,7 +805,7 @@ export class RawGroup<
|
|
|
783
805
|
init?: M["_shape"],
|
|
784
806
|
meta?: M["headerMeta"],
|
|
785
807
|
initPrivacy: "trusting" | "private" = "private",
|
|
786
|
-
uniqueness: CoValueUniqueness = this.
|
|
808
|
+
uniqueness: CoValueUniqueness = this.crypto.createdNowUnique(),
|
|
787
809
|
): M {
|
|
788
810
|
const map = this.core.node
|
|
789
811
|
.createCoValue({
|
|
@@ -814,7 +836,7 @@ export class RawGroup<
|
|
|
814
836
|
init?: L["_item"][],
|
|
815
837
|
meta?: L["headerMeta"],
|
|
816
838
|
initPrivacy: "trusting" | "private" = "private",
|
|
817
|
-
uniqueness: CoValueUniqueness = this.
|
|
839
|
+
uniqueness: CoValueUniqueness = this.crypto.createdNowUnique(),
|
|
818
840
|
): L {
|
|
819
841
|
const list = this.core.node
|
|
820
842
|
.createCoValue({
|
|
@@ -854,7 +876,7 @@ export class RawGroup<
|
|
|
854
876
|
group: this.id,
|
|
855
877
|
},
|
|
856
878
|
meta: meta || null,
|
|
857
|
-
...this.
|
|
879
|
+
...this.crypto.createdNowUnique(),
|
|
858
880
|
})
|
|
859
881
|
.getCurrentContent() as T;
|
|
860
882
|
|
|
@@ -868,7 +890,7 @@ export class RawGroup<
|
|
|
868
890
|
/** @category 3. Value creation */
|
|
869
891
|
createStream<C extends RawCoStream>(
|
|
870
892
|
meta?: C["headerMeta"],
|
|
871
|
-
uniqueness: CoValueUniqueness = this.
|
|
893
|
+
uniqueness: CoValueUniqueness = this.crypto.createdNowUnique(),
|
|
872
894
|
): C {
|
|
873
895
|
return this.core.node
|
|
874
896
|
.createCoValue({
|
|
@@ -886,7 +908,7 @@ export class RawGroup<
|
|
|
886
908
|
/** @category 3. Value creation */
|
|
887
909
|
createBinaryStream<C extends RawBinaryCoStream>(
|
|
888
910
|
meta: C["headerMeta"] = { type: "binary" },
|
|
889
|
-
uniqueness: CoValueUniqueness = this.
|
|
911
|
+
uniqueness: CoValueUniqueness = this.crypto.createdNowUnique(),
|
|
890
912
|
): C {
|
|
891
913
|
return this.core.node
|
|
892
914
|
.createCoValue({
|
package/src/coreToCoValue.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RawUnknownCoValue } from "./coValue.js";
|
|
2
|
-
import type {
|
|
3
|
-
import { RawAccount
|
|
2
|
+
import type { AvailableCoValueCore } from "./coValueCore/coValueCore.js";
|
|
3
|
+
import { RawAccount } from "./coValues/account.js";
|
|
4
4
|
import { RawCoList } from "./coValues/coList.js";
|
|
5
5
|
import { RawCoMap } from "./coValues/coMap.js";
|
|
6
6
|
import { RawCoPlainText } from "./coValues/coPlainText.js";
|
|
@@ -8,32 +8,31 @@ import { RawBinaryCoStream, RawCoStream } from "./coValues/coStream.js";
|
|
|
8
8
|
import { RawGroup } from "./coValues/group.js";
|
|
9
9
|
|
|
10
10
|
export function coreToCoValue(
|
|
11
|
-
core:
|
|
11
|
+
core: AvailableCoValueCore,
|
|
12
12
|
options?: { ignorePrivateTransactions: true },
|
|
13
13
|
) {
|
|
14
|
-
if (core.header.type === "comap") {
|
|
15
|
-
if (core.header.ruleset.type === "group") {
|
|
14
|
+
if (core.verified.header.type === "comap") {
|
|
15
|
+
if (core.verified.header.ruleset.type === "group") {
|
|
16
16
|
if (
|
|
17
|
-
core.header.meta?.type === "account" &&
|
|
17
|
+
core.verified.header.meta?.type === "account" &&
|
|
18
18
|
!options?.ignorePrivateTransactions
|
|
19
19
|
) {
|
|
20
|
-
|
|
21
|
-
return new RawControlledAccount(core, core.node.account.agentSecret);
|
|
22
|
-
} else {
|
|
23
|
-
return new RawAccount(core);
|
|
24
|
-
}
|
|
20
|
+
return new RawAccount(core);
|
|
25
21
|
} else {
|
|
26
22
|
return new RawGroup(core, options);
|
|
27
23
|
}
|
|
28
24
|
} else {
|
|
29
25
|
return new RawCoMap(core);
|
|
30
26
|
}
|
|
31
|
-
} else if (core.header.type === "coplaintext") {
|
|
27
|
+
} else if (core.verified.header.type === "coplaintext") {
|
|
32
28
|
return new RawCoPlainText(core);
|
|
33
|
-
} else if (core.header.type === "colist") {
|
|
29
|
+
} else if (core.verified.header.type === "colist") {
|
|
34
30
|
return new RawCoList(core);
|
|
35
|
-
} else if (core.header.type === "costream") {
|
|
36
|
-
if (
|
|
31
|
+
} else if (core.verified.header.type === "costream") {
|
|
32
|
+
if (
|
|
33
|
+
core.verified.header.meta &&
|
|
34
|
+
core.verified.header.meta.type === "binary"
|
|
35
|
+
) {
|
|
37
36
|
return new RawBinaryCoStream(core);
|
|
38
37
|
} else {
|
|
39
38
|
return new RawCoStream(core);
|
package/src/exports.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { base64URLtoBytes, bytesToBase64url } from "./base64url.js";
|
|
2
2
|
import { type RawCoValue } from "./coValue.js";
|
|
3
3
|
import {
|
|
4
|
+
CO_VALUE_LOADING_CONFIG,
|
|
4
5
|
CoValueCore,
|
|
5
|
-
type CoValueUniqueness,
|
|
6
6
|
MAX_RECOMMENDED_TX_SIZE,
|
|
7
7
|
idforHeader,
|
|
8
|
-
} from "./coValueCore.js";
|
|
8
|
+
} from "./coValueCore/coValueCore.js";
|
|
9
|
+
import { CoValueUniqueness } from "./coValueCore/verifiedState.js";
|
|
9
10
|
import {
|
|
11
|
+
ControlledAccount,
|
|
10
12
|
ControlledAgent,
|
|
11
13
|
RawAccount,
|
|
12
|
-
RawControlledAccount,
|
|
13
14
|
RawProfile,
|
|
14
15
|
accountHeaderForInitialAgentSecret,
|
|
15
16
|
} from "./coValues/account.js";
|
|
@@ -76,7 +77,6 @@ import {
|
|
|
76
77
|
|
|
77
78
|
type Value = JsonValue | AnyRawCoValue;
|
|
78
79
|
|
|
79
|
-
import { CO_VALUE_LOADING_CONFIG } from "./coValueState.js";
|
|
80
80
|
import { logger } from "./logger.js";
|
|
81
81
|
import { getPriorityFromHeader } from "./priority.js";
|
|
82
82
|
|
|
@@ -121,6 +121,7 @@ export {
|
|
|
121
121
|
AnyRawCoValue,
|
|
122
122
|
RawAccount,
|
|
123
123
|
RawAccountID,
|
|
124
|
+
ControlledAccount,
|
|
124
125
|
AccountMeta,
|
|
125
126
|
RawAccountMigration,
|
|
126
127
|
RawProfile as Profile,
|
|
@@ -128,7 +129,6 @@ export {
|
|
|
128
129
|
Media,
|
|
129
130
|
CoValueCore,
|
|
130
131
|
ControlledAgent,
|
|
131
|
-
RawControlledAccount,
|
|
132
132
|
MAX_RECOMMENDED_TX_SIZE,
|
|
133
133
|
JsonObject,
|
|
134
134
|
JsonValue,
|
|
@@ -173,8 +173,10 @@ export namespace CojsonInternalTypes {
|
|
|
173
173
|
export type LoadMessage = import("./sync.js").LoadMessage;
|
|
174
174
|
export type NewContentMessage = import("./sync.js").NewContentMessage;
|
|
175
175
|
export type SessionNewContent = import("./sync.js").SessionNewContent;
|
|
176
|
-
|
|
177
|
-
export type
|
|
176
|
+
// biome-ignore format: inserts spurious trialing comma that breaks some parsers
|
|
177
|
+
export type CoValueHeader = import("./coValueCore/verifiedState.js").CoValueHeader;
|
|
178
|
+
// biome-ignore format: inserts spurious trialing comma that breaks some parsers
|
|
179
|
+
export type Transaction = import("./coValueCore/verifiedState.js").Transaction;
|
|
178
180
|
export type TransactionID = import("./ids.js").TransactionID;
|
|
179
181
|
export type Signature = import("./crypto/crypto.js").Signature;
|
|
180
182
|
export type RawCoID = import("./ids.js").RawCoID;
|