cojson 0.7.0-alpha.5 → 0.7.0
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/.eslintrc.cjs +3 -2
- package/.prettierrc.js +9 -0
- package/.turbo/turbo-build.log +3 -30
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +1106 -0
- package/CHANGELOG.md +104 -0
- package/README.md +3 -1
- package/dist/base64url.test.js +25 -0
- package/dist/base64url.test.js.map +1 -0
- package/dist/coValueCore.js +60 -37
- package/dist/coValueCore.js.map +1 -1
- package/dist/coValues/account.js +16 -15
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +1 -1
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +17 -8
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/group.js +13 -14
- package/dist/coValues/group.js.map +1 -1
- package/dist/coreToCoValue.js.map +1 -1
- package/dist/crypto/PureJSCrypto.js +89 -0
- package/dist/crypto/PureJSCrypto.js.map +1 -0
- package/dist/crypto/WasmCrypto.js +127 -0
- package/dist/crypto/WasmCrypto.js.map +1 -0
- package/dist/crypto/crypto.js +151 -0
- package/dist/crypto/crypto.js.map +1 -0
- package/dist/ids.js +4 -2
- package/dist/ids.js.map +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/jsonStringify.js.map +1 -1
- package/dist/localNode.js +41 -38
- package/dist/localNode.js.map +1 -1
- package/dist/permissions.js +6 -6
- package/dist/permissions.js.map +1 -1
- package/dist/storage/FileSystem.js +61 -0
- package/dist/storage/FileSystem.js.map +1 -0
- package/dist/storage/chunksAndKnownStates.js +97 -0
- package/dist/storage/chunksAndKnownStates.js.map +1 -0
- package/dist/storage/index.js +265 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/sync.js +29 -25
- package/dist/sync.js.map +1 -1
- package/dist/tests/account.test.js +58 -0
- package/dist/tests/account.test.js.map +1 -0
- package/dist/tests/coList.test.js +76 -0
- package/dist/tests/coList.test.js.map +1 -0
- package/dist/tests/coMap.test.js +136 -0
- package/dist/tests/coMap.test.js.map +1 -0
- package/dist/tests/coStream.test.js +172 -0
- package/dist/tests/coStream.test.js.map +1 -0
- package/dist/tests/coValueCore.test.js +114 -0
- package/dist/tests/coValueCore.test.js.map +1 -0
- package/dist/tests/crypto.test.js +118 -0
- package/dist/tests/crypto.test.js.map +1 -0
- package/dist/tests/cryptoImpl.test.js +113 -0
- package/dist/tests/cryptoImpl.test.js.map +1 -0
- package/dist/tests/group.test.js +34 -0
- package/dist/tests/group.test.js.map +1 -0
- package/dist/tests/permissions.test.js +1060 -0
- package/dist/tests/permissions.test.js.map +1 -0
- package/dist/tests/sync.test.js +816 -0
- package/dist/tests/sync.test.js.map +1 -0
- package/dist/tests/testUtils.js +12 -11
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/typeUtils/accountOrAgentIDfromSessionID.js.map +1 -1
- package/dist/typeUtils/isAccountID.js.map +1 -1
- package/dist/typeUtils/isCoValue.js.map +1 -1
- package/package.json +14 -27
- package/src/base64url.test.ts +6 -5
- package/src/coValue.ts +1 -1
- package/src/coValueCore.ts +179 -126
- package/src/coValues/account.ts +30 -32
- package/src/coValues/coList.ts +11 -11
- package/src/coValues/coMap.ts +27 -17
- package/src/coValues/coStream.ts +17 -17
- package/src/coValues/group.ts +93 -109
- package/src/coreToCoValue.ts +5 -2
- package/src/crypto/PureJSCrypto.ts +200 -0
- package/src/crypto/WasmCrypto.ts +259 -0
- package/src/crypto/crypto.ts +336 -0
- package/src/ids.ts +8 -7
- package/src/index.ts +24 -24
- package/src/jsonStringify.ts +6 -4
- package/src/jsonValue.ts +2 -2
- package/src/localNode.ts +103 -109
- package/src/media.ts +3 -3
- package/src/permissions.ts +19 -21
- package/src/storage/FileSystem.ts +152 -0
- package/src/storage/chunksAndKnownStates.ts +139 -0
- package/src/storage/index.ts +479 -0
- package/src/streamUtils.ts +12 -12
- package/src/sync.ts +79 -63
- package/src/tests/account.test.ts +15 -15
- package/src/tests/coList.test.ts +94 -0
- package/src/tests/coMap.test.ts +162 -0
- package/src/tests/coStream.test.ts +246 -0
- package/src/tests/coValueCore.test.ts +36 -37
- package/src/tests/crypto.test.ts +66 -72
- package/src/tests/cryptoImpl.test.ts +183 -0
- package/src/tests/group.test.ts +16 -17
- package/src/tests/permissions.test.ts +269 -283
- package/src/tests/sync.test.ts +122 -123
- package/src/tests/testUtils.ts +24 -21
- package/src/typeUtils/accountOrAgentIDfromSessionID.ts +1 -2
- package/src/typeUtils/expectGroup.ts +1 -1
- package/src/typeUtils/isAccountID.ts +0 -1
- package/src/typeUtils/isCoValue.ts +1 -2
- package/tsconfig.json +0 -1
- package/dist/crypto.js +0 -254
- package/dist/crypto.js.map +0 -1
- package/src/crypto.ts +0 -484
- package/src/tests/coValue.test.ts +0 -497
package/src/index.ts
CHANGED
|
@@ -11,16 +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
|
-
|
|
23
|
-
|
|
16
|
+
StreamingHash,
|
|
17
|
+
CryptoProvider,
|
|
18
|
+
} from "./crypto/crypto.js";
|
|
19
|
+
import { WasmCrypto } from "./crypto/WasmCrypto.js";
|
|
20
|
+
import { PureJSCrypto } from "./crypto/PureJSCrypto.js";
|
|
24
21
|
import { connectedPeers } from "./streamUtils.js";
|
|
25
22
|
import { ControlledAgent, RawControlledAccount } from "./coValues/account.js";
|
|
26
23
|
import type { Role } from "./permissions.js";
|
|
@@ -45,30 +42,31 @@ import type {
|
|
|
45
42
|
} from "./coValues/coStream.js";
|
|
46
43
|
import type { JsonValue } from "./jsonValue.js";
|
|
47
44
|
import type { SyncMessage, Peer } from "./sync.js";
|
|
48
|
-
import type { AgentSecret } from "./crypto.js";
|
|
45
|
+
import type { AgentSecret } from "./crypto/crypto.js";
|
|
49
46
|
import type {
|
|
50
47
|
AccountID,
|
|
51
48
|
AccountMeta,
|
|
52
49
|
RawAccountMigration,
|
|
53
|
-
ProfileMeta,
|
|
54
50
|
} from "./coValues/account.js";
|
|
55
51
|
import type { InviteSecret } from "./coValues/group.js";
|
|
56
52
|
import type * as Media from "./media.js";
|
|
57
53
|
|
|
58
54
|
type Value = JsonValue | AnyRawCoValue;
|
|
59
55
|
|
|
56
|
+
import {
|
|
57
|
+
LSMStorage,
|
|
58
|
+
FSErr,
|
|
59
|
+
BlockFilename,
|
|
60
|
+
WalFilename,
|
|
61
|
+
} from "./storage/index.js";
|
|
62
|
+
import { FileSystem } from "./storage/FileSystem.js";
|
|
63
|
+
|
|
60
64
|
/** @hidden */
|
|
61
65
|
export const cojsonInternals = {
|
|
62
|
-
agentSecretFromBytes,
|
|
63
|
-
agentSecretToBytes,
|
|
64
66
|
newRandomSessionID,
|
|
65
|
-
newRandomAgentSecret,
|
|
66
67
|
connectedPeers,
|
|
67
|
-
getAgentID,
|
|
68
68
|
rawCoIDtoBytes,
|
|
69
69
|
rawCoIDfromBytes,
|
|
70
|
-
newRandomSecretSeed,
|
|
71
|
-
agentSecretFromSecretSeed,
|
|
72
70
|
secretSeedLength,
|
|
73
71
|
shortHashLength,
|
|
74
72
|
expectGroup,
|
|
@@ -79,6 +77,7 @@ export const cojsonInternals = {
|
|
|
79
77
|
isAccountID,
|
|
80
78
|
accountHeaderForInitialAgentSecret,
|
|
81
79
|
idforHeader,
|
|
80
|
+
StreamingHash,
|
|
82
81
|
};
|
|
83
82
|
|
|
84
83
|
export {
|
|
@@ -99,13 +98,11 @@ export {
|
|
|
99
98
|
AccountMeta,
|
|
100
99
|
RawAccountMigration,
|
|
101
100
|
RawProfile as Profile,
|
|
102
|
-
ProfileMeta,
|
|
103
101
|
SessionID,
|
|
104
102
|
Media,
|
|
105
103
|
CoValueCore,
|
|
106
104
|
ControlledAgent,
|
|
107
105
|
RawControlledAccount,
|
|
108
|
-
cryptoReady as cojsonReady,
|
|
109
106
|
MAX_RECOMMENDED_TX_SIZE,
|
|
110
107
|
JsonValue,
|
|
111
108
|
Peer,
|
|
@@ -114,11 +111,15 @@ export {
|
|
|
114
111
|
AgentID,
|
|
115
112
|
AgentSecret,
|
|
116
113
|
InviteSecret,
|
|
114
|
+
CryptoProvider,
|
|
115
|
+
WasmCrypto,
|
|
116
|
+
PureJSCrypto,
|
|
117
117
|
SyncMessage,
|
|
118
|
-
isRawCoID
|
|
118
|
+
isRawCoID,
|
|
119
|
+
LSMStorage,
|
|
119
120
|
};
|
|
120
121
|
|
|
121
|
-
export type { Value };
|
|
122
|
+
export type { Value, FileSystem, FSErr, BlockFilename, WalFilename };
|
|
122
123
|
|
|
123
124
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
124
125
|
export namespace CojsonInternalTypes {
|
|
@@ -130,11 +131,10 @@ export namespace CojsonInternalTypes {
|
|
|
130
131
|
export type CoValueHeader = import("./coValueCore.js").CoValueHeader;
|
|
131
132
|
export type Transaction = import("./coValueCore.js").Transaction;
|
|
132
133
|
export type TransactionID = import("./ids.js").TransactionID;
|
|
133
|
-
export type Signature = import("./crypto.js").Signature;
|
|
134
|
+
export type Signature = import("./crypto/crypto.js").Signature;
|
|
134
135
|
export type RawCoID = import("./ids.js").RawCoID;
|
|
135
136
|
export type ProfileShape = import("./coValues/account.js").ProfileShape;
|
|
136
|
-
export type
|
|
137
|
-
export type
|
|
138
|
-
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;
|
|
139
139
|
export type JsonObject = import("./jsonValue.js").JsonObject;
|
|
140
140
|
}
|
package/src/jsonStringify.ts
CHANGED
|
@@ -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>(
|
|
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
|
|
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 };
|