cojson 0.2.2 → 0.3.0-alpha.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 +1 -0
- package/dist/account.d.ts +8 -8
- package/dist/account.js +2 -2
- package/dist/account.js.map +1 -1
- package/dist/coValue.d.ts +22 -27
- package/dist/coValue.js +21 -0
- package/dist/coValue.js.map +1 -1
- package/dist/coValueCore.d.ts +7 -7
- package/dist/coValueCore.js +11 -14
- package/dist/coValueCore.js.map +1 -1
- package/dist/coValues/coList.d.ts +107 -42
- package/dist/coValues/coList.js +163 -72
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.d.ts +109 -50
- package/dist/coValues/coMap.js +161 -109
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.d.ts +78 -33
- package/dist/coValues/coStream.js +134 -53
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/crypto.d.ts +8 -3
- package/dist/crypto.js +6 -6
- package/dist/crypto.js.map +1 -1
- package/dist/group.d.ts +59 -23
- package/dist/group.js +83 -25
- package/dist/group.js.map +1 -1
- package/dist/index.d.ts +14 -11
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/{node.d.ts → localNode.d.ts} +23 -11
- package/dist/{node.js → localNode.js} +80 -42
- package/dist/localNode.js.map +1 -0
- package/dist/media.d.ts +1 -2
- package/dist/permissions.js +6 -3
- package/dist/permissions.js.map +1 -1
- package/dist/queriedCoValues/queriedCoList.d.ts +66 -0
- package/dist/queriedCoValues/queriedCoList.js +120 -0
- package/dist/queriedCoValues/queriedCoList.js.map +1 -0
- package/dist/queriedCoValues/queriedCoMap.d.ts +47 -0
- package/dist/queriedCoValues/queriedCoMap.js +83 -0
- package/dist/queriedCoValues/queriedCoMap.js.map +1 -0
- package/dist/queriedCoValues/queriedCoStream.d.ts +40 -0
- package/dist/queriedCoValues/queriedCoStream.js +72 -0
- package/dist/queriedCoValues/queriedCoStream.js.map +1 -0
- package/dist/queries.d.ts +31 -0
- package/dist/queries.js +77 -0
- package/dist/queries.js.map +1 -0
- package/dist/sync.d.ts +1 -1
- package/dist/sync.js +1 -1
- package/dist/sync.js.map +1 -1
- package/dist/{testUtils.d.ts → tests/testUtils.d.ts} +9 -9
- package/dist/{testUtils.js → tests/testUtils.js} +9 -7
- package/dist/tests/testUtils.js.map +1 -0
- package/package.json +2 -2
- package/src/account.ts +6 -6
- package/src/coValue.ts +65 -34
- package/src/coValueCore.ts +18 -22
- package/src/coValues/coList.ts +272 -122
- package/src/coValues/coMap.ts +349 -152
- package/src/coValues/coStream.ts +258 -94
- package/src/crypto.ts +37 -24
- package/src/group.ts +112 -46
- package/src/index.ts +42 -30
- package/src/{node.ts → localNode.ts} +117 -66
- package/src/media.ts +1 -2
- package/src/permissions.ts +15 -18
- package/src/queriedCoValues/queriedCoList.ts +248 -0
- package/src/queriedCoValues/queriedCoMap.ts +180 -0
- package/src/queriedCoValues/queriedCoStream.ts +125 -0
- package/src/queries.ts +142 -0
- package/src/sync.ts +2 -2
- package/src/{account.test.ts → tests/account.test.ts} +6 -9
- package/src/{coValue.test.ts → tests/coValue.test.ts} +120 -114
- package/src/{coValueCore.test.ts → tests/coValueCore.test.ts} +7 -7
- package/src/{crypto.test.ts → tests/crypto.test.ts} +19 -21
- package/src/{group.test.ts → tests/group.test.ts} +2 -2
- package/src/{permissions.test.ts → tests/permissions.test.ts} +260 -247
- package/src/tests/queries.test.ts +318 -0
- package/src/{sync.test.ts → tests/sync.test.ts} +39 -39
- package/src/{testUtils.ts → tests/testUtils.ts} +10 -8
- package/dist/coValues/static.d.ts +0 -14
- package/dist/coValues/static.js +0 -20
- package/dist/coValues/static.js.map +0 -1
- package/dist/node.js.map +0 -1
- package/dist/testUtils.js.map +0 -1
- package/src/coValues/static.ts +0 -31
package/dist/group.js
CHANGED
|
@@ -34,11 +34,19 @@ export class Group {
|
|
|
34
34
|
this.underlyingMap = underlyingMap;
|
|
35
35
|
this.node = node;
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Returns the `CoID` of the `Group`.
|
|
39
|
+
*
|
|
40
|
+
* @category 4. Underlying CoMap
|
|
41
|
+
*/
|
|
38
42
|
get id() {
|
|
39
43
|
return this.underlyingMap.id;
|
|
40
44
|
}
|
|
41
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Returns the current role of a given account.
|
|
47
|
+
*
|
|
48
|
+
* @category 1. Role reading
|
|
49
|
+
*/
|
|
42
50
|
roleOf(accountID) {
|
|
43
51
|
return this.roleOfInternal(accountID);
|
|
44
52
|
}
|
|
@@ -46,18 +54,26 @@ export class Group {
|
|
|
46
54
|
roleOfInternal(accountID) {
|
|
47
55
|
return this.underlyingMap.get(accountID);
|
|
48
56
|
}
|
|
49
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Returns the role of the current account in the group.
|
|
59
|
+
*
|
|
60
|
+
* @category 1. Role reading
|
|
61
|
+
*/
|
|
50
62
|
myRole() {
|
|
51
63
|
return this.roleOfInternal(this.node.account.id);
|
|
52
64
|
}
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
65
|
+
/**
|
|
66
|
+
* Directly grants a new member a role in the group. The current account must be an
|
|
67
|
+
* admin to be able to do so. Throws otherwise.
|
|
68
|
+
*
|
|
69
|
+
* @category 2. Role changing
|
|
70
|
+
*/
|
|
55
71
|
addMember(accountID, role) {
|
|
56
72
|
this.addMemberInternal(accountID, role);
|
|
57
73
|
}
|
|
58
74
|
/** @internal */
|
|
59
75
|
addMemberInternal(accountID, role) {
|
|
60
|
-
this.underlyingMap = this.underlyingMap.
|
|
76
|
+
this.underlyingMap = this.underlyingMap.mutate((map) => {
|
|
61
77
|
const currentReadKey = this.underlyingMap.core.getCurrentReadKey();
|
|
62
78
|
if (!currentReadKey.secret) {
|
|
63
79
|
throw new Error("Can't add member without read key secret");
|
|
@@ -67,9 +83,14 @@ export class Group {
|
|
|
67
83
|
if (map.get(accountID) !== role) {
|
|
68
84
|
throw new Error("Failed to set role");
|
|
69
85
|
}
|
|
70
|
-
map.set(`${currentReadKey.id}_for_${accountID}`, seal(
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
map.set(`${currentReadKey.id}_for_${accountID}`, seal({
|
|
87
|
+
message: currentReadKey.secret,
|
|
88
|
+
from: this.underlyingMap.core.node.account.currentSealerSecret(),
|
|
89
|
+
to: getAgentSealerID(agent),
|
|
90
|
+
nOnceMaterial: {
|
|
91
|
+
in: this.underlyingMap.core.id,
|
|
92
|
+
tx: this.underlyingMap.core.nextTransactionID(),
|
|
93
|
+
},
|
|
73
94
|
}), "trusting");
|
|
74
95
|
});
|
|
75
96
|
}
|
|
@@ -97,12 +118,17 @@ export class Group {
|
|
|
97
118
|
secret: maybeCurrentReadKey.secret,
|
|
98
119
|
};
|
|
99
120
|
const newReadKey = newRandomKeySecret();
|
|
100
|
-
this.underlyingMap = this.underlyingMap.
|
|
121
|
+
this.underlyingMap = this.underlyingMap.mutate((map) => {
|
|
101
122
|
for (const readerID of currentlyPermittedReaders) {
|
|
102
123
|
const reader = this.node.resolveAccountAgent(readerID, "Expected to know currently permitted reader");
|
|
103
|
-
map.set(`${newReadKey.id}_for_${readerID}`, seal(
|
|
104
|
-
|
|
105
|
-
|
|
124
|
+
map.set(`${newReadKey.id}_for_${readerID}`, seal({
|
|
125
|
+
message: newReadKey.secret,
|
|
126
|
+
from: this.underlyingMap.core.node.account.currentSealerSecret(),
|
|
127
|
+
to: getAgentSealerID(reader),
|
|
128
|
+
nOnceMaterial: {
|
|
129
|
+
in: this.underlyingMap.core.id,
|
|
130
|
+
tx: this.underlyingMap.core.nextTransactionID(),
|
|
131
|
+
},
|
|
106
132
|
}), "trusting");
|
|
107
133
|
}
|
|
108
134
|
map.set(`${currentReadKey.id}_for_${newReadKey.id}`, encryptKeySecret({
|
|
@@ -112,20 +138,30 @@ export class Group {
|
|
|
112
138
|
map.set("readKey", newReadKey.id, "trusting");
|
|
113
139
|
});
|
|
114
140
|
}
|
|
115
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Strips the specified member of all roles (preventing future writes in
|
|
116
143
|
* the group and owned values) and rotates the read encryption key for that group
|
|
117
|
-
* (preventing reads of new content in the group and owned values)
|
|
144
|
+
* (preventing reads of new content in the group and owned values)
|
|
145
|
+
*
|
|
146
|
+
* @category 2. Role changing
|
|
147
|
+
*/
|
|
118
148
|
removeMember(accountID) {
|
|
119
149
|
this.removeMemberInternal(accountID);
|
|
120
150
|
}
|
|
121
151
|
/** @internal */
|
|
122
152
|
removeMemberInternal(accountID) {
|
|
123
|
-
this.underlyingMap = this.underlyingMap.
|
|
153
|
+
this.underlyingMap = this.underlyingMap.mutate((map) => {
|
|
124
154
|
map.set(accountID, "revoked", "trusting");
|
|
125
155
|
});
|
|
126
156
|
this.rotateReadKey();
|
|
127
157
|
}
|
|
128
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Creates an invite for new members to indirectly join the group,
|
|
160
|
+
* allowing them to grant themselves the specified role with the InviteSecret
|
|
161
|
+
* (a string starting with "inviteSecret_") - use `LocalNode.acceptInvite()` for this purpose.
|
|
162
|
+
*
|
|
163
|
+
* @category 2. Role changing
|
|
164
|
+
*/
|
|
129
165
|
createInvite(role) {
|
|
130
166
|
const secretSeed = newRandomSecretSeed();
|
|
131
167
|
const inviteSecret = agentSecretFromSecretSeed(secretSeed);
|
|
@@ -133,10 +169,14 @@ export class Group {
|
|
|
133
169
|
this.addMemberInternal(inviteID, `${role}Invite`);
|
|
134
170
|
return inviteSecretFromSecretSeed(secretSeed);
|
|
135
171
|
}
|
|
136
|
-
/**
|
|
137
|
-
*
|
|
138
|
-
|
|
139
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Creates a new `CoMap` within this group, with the specified specialized
|
|
174
|
+
* `CoMap` type `M` and optional static metadata.
|
|
175
|
+
*
|
|
176
|
+
* @category 3. Value creation
|
|
177
|
+
*/
|
|
178
|
+
createMap(init, meta, initPrivacy = "trusting") {
|
|
179
|
+
let map = this.node
|
|
140
180
|
.createCoValue({
|
|
141
181
|
type: "comap",
|
|
142
182
|
ruleset: {
|
|
@@ -147,11 +187,21 @@ export class Group {
|
|
|
147
187
|
...createdNowUnique(),
|
|
148
188
|
})
|
|
149
189
|
.getCurrentContent();
|
|
190
|
+
if (init) {
|
|
191
|
+
for (const [key, value] of Object.entries(init)) {
|
|
192
|
+
map = map.set(key, value, initPrivacy);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return map;
|
|
150
196
|
}
|
|
151
|
-
/**
|
|
152
|
-
* `CoList`
|
|
153
|
-
|
|
154
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Creates a new `CoList` within this group, with the specified specialized
|
|
199
|
+
* `CoList` type `L` and optional static metadata.
|
|
200
|
+
*
|
|
201
|
+
* @category 3. Value creation
|
|
202
|
+
*/
|
|
203
|
+
createList(init, meta, initPrivacy = "trusting") {
|
|
204
|
+
let list = this.node
|
|
155
205
|
.createCoValue({
|
|
156
206
|
type: "colist",
|
|
157
207
|
ruleset: {
|
|
@@ -162,7 +212,14 @@ export class Group {
|
|
|
162
212
|
...createdNowUnique(),
|
|
163
213
|
})
|
|
164
214
|
.getCurrentContent();
|
|
215
|
+
if (init) {
|
|
216
|
+
for (const item of init) {
|
|
217
|
+
list = list.append(item, undefined, initPrivacy);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return list;
|
|
165
221
|
}
|
|
222
|
+
/** @category 3. Value creation */
|
|
166
223
|
createStream(meta) {
|
|
167
224
|
return this.node
|
|
168
225
|
.createCoValue({
|
|
@@ -176,6 +233,7 @@ export class Group {
|
|
|
176
233
|
})
|
|
177
234
|
.getCurrentContent();
|
|
178
235
|
}
|
|
236
|
+
/** @category 3. Value creation */
|
|
179
237
|
createBinaryStream(meta = { type: "binary" }) {
|
|
180
238
|
return this.node
|
|
181
239
|
.createCoValue({
|
package/dist/group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.js","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAGA,OAAO,EAIH,gBAAgB,EAChB,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAEhB,mBAAmB,EACnB,yBAAyB,EACzB,UAAU,GACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAsB,SAAS,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAGA,OAAO,EAIH,gBAAgB,EAChB,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAEhB,mBAAmB,EACnB,yBAAyB,EACzB,UAAU,GACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAsB,SAAS,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAkBrC,MAAM,UAAU,kBAAkB,CAC9B,OAAgB;IAEhB,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;KACnC;IAED,OAAO,OAAiD,CAAC;AAC7D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;KAoBK;AACL,MAAM,OAAO,KAAK;IAMd,gBAAgB;IAChB,YACI,aAAqD,EACrD,IAAe;QAEf,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,EAAE;QACF,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAoB;QACvB,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED,gBAAgB;IAChB,cA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C;AACxD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,YAA0B;IACjE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QAC5C,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;KAC5C;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CoValueCore, newRandomSessionID, MAX_RECOMMENDED_TX_SIZE } from "./coValueCore.js";
|
|
2
|
-
import { LocalNode } from "./
|
|
3
|
-
import type { CoValue
|
|
4
|
-
import { CoMap,
|
|
5
|
-
import { CoList,
|
|
6
|
-
import { CoStream,
|
|
2
|
+
import { LocalNode } from "./localNode.js";
|
|
3
|
+
import type { CoValue } from "./coValue.js";
|
|
4
|
+
import { CoMap, MutableCoMap } from "./coValues/coMap.js";
|
|
5
|
+
import { CoList, MutableCoList } from "./coValues/coList.js";
|
|
6
|
+
import { CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream } from "./coValues/coStream.js";
|
|
7
7
|
import { agentSecretFromBytes, agentSecretToBytes, getAgentID, newRandomAgentSecret, newRandomSecretSeed, agentSecretFromSecretSeed, cryptoReady } from "./crypto.js";
|
|
8
8
|
import { connectedPeers } from "./streamUtils.js";
|
|
9
9
|
import { AnonymousControlledAccount, ControlledAccount } from "./account.js";
|
|
@@ -12,15 +12,19 @@ import { Group, expectGroupContent } from "./group.js";
|
|
|
12
12
|
import { base64URLtoBytes, bytesToBase64url } from "./base64url.js";
|
|
13
13
|
import { parseJSON } from "./jsonStringify.js";
|
|
14
14
|
import type { SessionID, AgentID } from "./ids.js";
|
|
15
|
-
import type { CoID,
|
|
16
|
-
import type {
|
|
15
|
+
import type { CoID, AnyCoValue } from "./coValue.js";
|
|
16
|
+
import type { Queried } from "./queries.js";
|
|
17
|
+
import type { QueriedCoStream } from "./queriedCoValues/queriedCoStream.js";
|
|
18
|
+
import type { QueriedCoList } from "./queriedCoValues/queriedCoList.js";
|
|
19
|
+
import type { QueriedCoMap } from "./queriedCoValues/queriedCoMap.js";
|
|
20
|
+
import type { BinaryStreamInfo, BinaryCoStreamMeta } from "./coValues/coStream.js";
|
|
17
21
|
import type { JsonValue } from "./jsonValue.js";
|
|
18
22
|
import type { SyncMessage, Peer } from "./sync.js";
|
|
19
23
|
import type { AgentSecret } from "./crypto.js";
|
|
20
|
-
import type { AccountID, Profile } from "./account.js";
|
|
24
|
+
import type { AccountID, Account, Profile } from "./account.js";
|
|
21
25
|
import type { InviteSecret } from "./group.js";
|
|
22
26
|
import type * as Media from "./media.js";
|
|
23
|
-
type Value = JsonValue |
|
|
27
|
+
type Value = JsonValue | AnyCoValue;
|
|
24
28
|
/** @hidden */
|
|
25
29
|
export declare const cojsonInternals: {
|
|
26
30
|
agentSecretFromBytes: typeof agentSecretFromBytes;
|
|
@@ -40,8 +44,7 @@ export declare const cojsonInternals: {
|
|
|
40
44
|
bytesToBase64url: typeof bytesToBase64url;
|
|
41
45
|
parseJSON: typeof parseJSON;
|
|
42
46
|
};
|
|
43
|
-
export { LocalNode, Group, CoMap,
|
|
44
|
-
export type { Value, JsonValue, CoValue, ReadableCoValue, CoValueImpl, CoID, AccountID, Profile, SessionID, Peer, BinaryChunkInfo, BinaryCoStreamMeta, AgentID, AgentSecret, InviteSecret, SyncMessage, Media };
|
|
47
|
+
export { LocalNode, Group, CoMap, MutableCoMap, CoList, MutableCoList, CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream, CoValue, CoID, AnyCoValue, Queried, QueriedCoMap, QueriedCoList, QueriedCoStream, AccountID, Account, Profile, SessionID, Media, CoValueCore, AnonymousControlledAccount, ControlledAccount, cryptoReady as cojsonReady, MAX_RECOMMENDED_TX_SIZE, Value, JsonValue, Peer, BinaryStreamInfo, BinaryCoStreamMeta, AgentID, AgentSecret, InviteSecret, SyncMessage, };
|
|
45
48
|
export declare namespace CojsonInternalTypes {
|
|
46
49
|
type CoValueKnownState = import("./sync.js").CoValueKnownState;
|
|
47
50
|
type DoneMessage = import("./sync.js").DoneMessage;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CoValueCore, newRandomSessionID, MAX_RECOMMENDED_TX_SIZE } from "./coValueCore.js";
|
|
2
|
-
import { LocalNode } from "./
|
|
3
|
-
import { CoMap,
|
|
4
|
-
import { CoList,
|
|
5
|
-
import { CoStream,
|
|
6
|
-
import { agentSecretFromBytes, agentSecretToBytes, getAgentID, newRandomAgentSecret, newRandomSecretSeed, agentSecretFromSecretSeed, secretSeedLength, shortHashLength, cryptoReady } from "./crypto.js";
|
|
1
|
+
import { CoValueCore, newRandomSessionID, MAX_RECOMMENDED_TX_SIZE, } from "./coValueCore.js";
|
|
2
|
+
import { LocalNode } from "./localNode.js";
|
|
3
|
+
import { CoMap, MutableCoMap } from "./coValues/coMap.js";
|
|
4
|
+
import { CoList, MutableCoList } from "./coValues/coList.js";
|
|
5
|
+
import { CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream, } from "./coValues/coStream.js";
|
|
6
|
+
import { agentSecretFromBytes, agentSecretToBytes, getAgentID, newRandomAgentSecret, newRandomSecretSeed, agentSecretFromSecretSeed, secretSeedLength, shortHashLength, cryptoReady, } from "./crypto.js";
|
|
7
7
|
import { connectedPeers } from "./streamUtils.js";
|
|
8
8
|
import { AnonymousControlledAccount, ControlledAccount } from "./account.js";
|
|
9
9
|
import { rawCoIDtoBytes, rawCoIDfromBytes } from "./ids.js";
|
|
@@ -27,7 +27,7 @@ export const cojsonInternals = {
|
|
|
27
27
|
expectGroupContent,
|
|
28
28
|
base64URLtoBytes,
|
|
29
29
|
bytesToBase64url,
|
|
30
|
-
parseJSON
|
|
30
|
+
parseJSON,
|
|
31
31
|
};
|
|
32
|
-
export { LocalNode, Group, CoMap,
|
|
32
|
+
export { LocalNode, Group, CoMap, MutableCoMap, CoList, MutableCoList, CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream, CoValueCore, AnonymousControlledAccount, ControlledAccount, cryptoReady as cojsonReady, MAX_RECOMMENDED_TX_SIZE, };
|
|
33
33
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,uBAAuB,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACH,QAAQ,EACR,eAAe,EACf,cAAc,EACd,qBAAqB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACH,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EACf,WAAW,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAqB/C,cAAc;AACd,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,oBAAoB;IACpB,kBAAkB;IAClB,kBAAkB;IAClB,oBAAoB;IACpB,cAAc;IACd,UAAU;IACV,cAAc;IACd,gBAAgB;IAChB,mBAAmB;IACnB,yBAAyB;IACzB,gBAAgB;IAChB,eAAe;IACf,kBAAkB;IAClB,gBAAgB;IAChB,gBAAgB;IAChB,SAAS;CACZ,CAAC;AAEF,OAAO,EACH,SAAS,EACT,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,aAAa,EACb,QAAQ,EACR,eAAe,EACf,cAAc,EACd,qBAAqB,EAarB,WAAW,EACX,0BAA0B,EAC1B,iBAAiB,EACjB,WAAW,IAAI,WAAW,EAC1B,uBAAuB,GAU1B,CAAC"}
|
|
@@ -3,8 +3,10 @@ import { CoValueCore, CoValueHeader } from "./coValueCore.js";
|
|
|
3
3
|
import { InviteSecret, Group } from "./group.js";
|
|
4
4
|
import { Peer, SyncManager } from "./sync.js";
|
|
5
5
|
import { AgentID, RawCoID, SessionID } from "./ids.js";
|
|
6
|
-
import { CoID
|
|
6
|
+
import { CoID } from "./coValue.js";
|
|
7
|
+
import { Queried } from "./queries.js";
|
|
7
8
|
import { GeneralizedControlledAccount, ControlledAccount, AccountID, Profile } from "./account.js";
|
|
9
|
+
import { CoValue } from "./index.js";
|
|
8
10
|
/** A `LocalNode` represents a local view of a set of loaded `CoValue`s, from the perspective of a particular account (or primitive cryptographic agent).
|
|
9
11
|
|
|
10
12
|
A `LocalNode` can have peers that it syncs to, for example some form of local persistence, or a sync server, such as `sync.jazz.tools` (Jazz Global Mesh).
|
|
@@ -21,17 +23,22 @@ export declare class LocalNode {
|
|
|
21
23
|
coValues: {
|
|
22
24
|
[key: RawCoID]: CoValueState;
|
|
23
25
|
};
|
|
24
|
-
/** @
|
|
26
|
+
/** @category 3. Low-level */
|
|
25
27
|
account: GeneralizedControlledAccount;
|
|
28
|
+
/** @category 3. Low-level */
|
|
26
29
|
currentSessionID: SessionID;
|
|
27
|
-
|
|
30
|
+
/** @category 3. Low-level */
|
|
31
|
+
syncManager: SyncManager;
|
|
32
|
+
/** @category 3. Low-level */
|
|
28
33
|
constructor(account: GeneralizedControlledAccount, currentSessionID: SessionID);
|
|
34
|
+
/** @category 2. Node Creation */
|
|
29
35
|
static withNewlyCreatedAccount(name: string, initialAgentSecret?: `sealerSecret_z${string}/signerSecret_z${string}`): {
|
|
30
36
|
node: LocalNode;
|
|
31
37
|
accountID: AccountID;
|
|
32
38
|
accountSecret: AgentSecret;
|
|
33
39
|
sessionID: SessionID;
|
|
34
40
|
};
|
|
41
|
+
/** @category 2. Node Creation */
|
|
35
42
|
static withLoadedAccount(accountID: AccountID, accountSecret: AgentSecret, sessionID: SessionID, peersToLoadFrom: Peer[]): Promise<LocalNode>;
|
|
36
43
|
/** @internal */
|
|
37
44
|
createCoValue(header: CoValueHeader): CoValueCore;
|
|
@@ -41,14 +48,16 @@ export declare class LocalNode {
|
|
|
41
48
|
* Loads a CoValue's content, syncing from peers as necessary and resolving the returned
|
|
42
49
|
* promise once a first version has been loaded. See `coValue.subscribe()` and `node.useTelepathicData()`
|
|
43
50
|
* for listening to subsequent updates to the CoValue.
|
|
51
|
+
*
|
|
52
|
+
* @category 3. Low-level
|
|
44
53
|
*/
|
|
45
|
-
load<T extends
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
acceptInvite<T extends
|
|
54
|
+
load<T extends CoValue>(id: CoID<T>): Promise<T>;
|
|
55
|
+
/** @category 3. Low-level */
|
|
56
|
+
subscribe<T extends CoValue>(id: CoID<T>, callback: (update: T) => void): () => void;
|
|
57
|
+
/** @category 1. High-level */
|
|
58
|
+
query<T extends CoValue>(id: CoID<T>, callback: (update: Queried<T> | undefined) => void): () => void;
|
|
59
|
+
/** @category 1. High-level */
|
|
60
|
+
acceptInvite<T extends CoValue>(groupOrOwnedValueID: CoID<T>, inviteSecret: InviteSecret): Promise<void>;
|
|
52
61
|
/** @internal */
|
|
53
62
|
expectCoValueLoaded(id: RawCoID, expectation?: string): CoValueCore;
|
|
54
63
|
/** @internal */
|
|
@@ -57,7 +66,10 @@ export declare class LocalNode {
|
|
|
57
66
|
createAccount(name: string, agentSecret?: `sealerSecret_z${string}/signerSecret_z${string}`): ControlledAccount;
|
|
58
67
|
/** @internal */
|
|
59
68
|
resolveAccountAgent(id: AccountID | AgentID, expectation?: string): AgentID;
|
|
60
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new group (with the current account as the group's first admin).
|
|
71
|
+
* @category 1. High-level
|
|
72
|
+
*/
|
|
61
73
|
createGroup(): Group;
|
|
62
74
|
/** @internal */
|
|
63
75
|
testWithDifferentAccount(account: GeneralizedControlledAccount, currentSessionID: SessionID): LocalNode;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { agentSecretFromSecretSeed, createdNowUnique, getAgentID, getAgentSealerID, getAgentSealerSecret, newRandomAgentSecret, newRandomKeySecret, seal, } from "./crypto.js";
|
|
2
|
-
import { CoValueCore, newRandomSessionID } from "./coValueCore.js";
|
|
2
|
+
import { CoValueCore, newRandomSessionID, } from "./coValueCore.js";
|
|
3
3
|
import { Group, expectGroupContent, secretSeedFromInviteSecret, } from "./group.js";
|
|
4
4
|
import { SyncManager } from "./sync.js";
|
|
5
5
|
import { isAgentID } from "./ids.js";
|
|
6
|
-
import {
|
|
6
|
+
import { query } from "./queries.js";
|
|
7
|
+
import { AccountGroup, accountHeaderForInitialAgentSecret, ControlledAccount, AnonymousControlledAccount, } from "./account.js";
|
|
7
8
|
/** A `LocalNode` represents a local view of a set of loaded `CoValue`s, from the perspective of a particular account (or primitive cryptographic agent).
|
|
8
9
|
|
|
9
10
|
A `LocalNode` can have peers that it syncs to, for example some form of local persistence, or a sync server, such as `sync.jazz.tools` (Jazz Global Mesh).
|
|
@@ -16,13 +17,16 @@ const { localNode } = useJazz();
|
|
|
16
17
|
```
|
|
17
18
|
*/
|
|
18
19
|
export class LocalNode {
|
|
20
|
+
/** @category 3. Low-level */
|
|
19
21
|
constructor(account, currentSessionID) {
|
|
20
22
|
/** @internal */
|
|
21
23
|
this.coValues = {};
|
|
22
|
-
|
|
24
|
+
/** @category 3. Low-level */
|
|
25
|
+
this.syncManager = new SyncManager(this);
|
|
23
26
|
this.account = account;
|
|
24
27
|
this.currentSessionID = currentSessionID;
|
|
25
28
|
}
|
|
29
|
+
/** @category 2. Node Creation */
|
|
26
30
|
static withNewlyCreatedAccount(name, initialAgentSecret = newRandomAgentSecret()) {
|
|
27
31
|
const throwawayAgent = newRandomAgentSecret();
|
|
28
32
|
const setupNode = new LocalNode(new AnonymousControlledAccount(throwawayAgent), newRandomSessionID(getAgentID(throwawayAgent)));
|
|
@@ -35,24 +39,25 @@ export class LocalNode {
|
|
|
35
39
|
sessionID: nodeWithAccount.currentSessionID,
|
|
36
40
|
};
|
|
37
41
|
}
|
|
42
|
+
/** @category 2. Node Creation */
|
|
38
43
|
static async withLoadedAccount(accountID, accountSecret, sessionID, peersToLoadFrom) {
|
|
39
44
|
const loadingNode = new LocalNode(new AnonymousControlledAccount(accountSecret), newRandomSessionID(accountID));
|
|
40
45
|
const accountPromise = loadingNode.load(accountID);
|
|
41
46
|
for (const peer of peersToLoadFrom) {
|
|
42
|
-
loadingNode.
|
|
47
|
+
loadingNode.syncManager.addPeer(peer);
|
|
43
48
|
}
|
|
44
49
|
const account = await accountPromise;
|
|
45
50
|
// since this is all synchronous, we can just swap out nodes for the SyncManager
|
|
46
51
|
const node = loadingNode.testWithDifferentAccount(new ControlledAccount(accountSecret, account, loadingNode), sessionID);
|
|
47
|
-
node.
|
|
48
|
-
node.
|
|
52
|
+
node.syncManager = loadingNode.syncManager;
|
|
53
|
+
node.syncManager.local = node;
|
|
49
54
|
return node;
|
|
50
55
|
}
|
|
51
56
|
/** @internal */
|
|
52
57
|
createCoValue(header) {
|
|
53
58
|
const coValue = new CoValueCore(header, this);
|
|
54
59
|
this.coValues[coValue.id] = { state: "loaded", coValue: coValue };
|
|
55
|
-
void this.
|
|
60
|
+
void this.syncManager.syncCoValue(coValue);
|
|
56
61
|
return coValue;
|
|
57
62
|
}
|
|
58
63
|
/** @internal */
|
|
@@ -61,7 +66,7 @@ export class LocalNode {
|
|
|
61
66
|
if (!entry) {
|
|
62
67
|
entry = newLoadingState();
|
|
63
68
|
this.coValues[id] = entry;
|
|
64
|
-
this.
|
|
69
|
+
this.syncManager.loadFromPeers(id);
|
|
65
70
|
}
|
|
66
71
|
if (entry.state === "loaded") {
|
|
67
72
|
return Promise.resolve(entry.coValue);
|
|
@@ -72,22 +77,38 @@ export class LocalNode {
|
|
|
72
77
|
* Loads a CoValue's content, syncing from peers as necessary and resolving the returned
|
|
73
78
|
* promise once a first version has been loaded. See `coValue.subscribe()` and `node.useTelepathicData()`
|
|
74
79
|
* for listening to subsequent updates to the CoValue.
|
|
80
|
+
*
|
|
81
|
+
* @category 3. Low-level
|
|
75
82
|
*/
|
|
76
83
|
async load(id) {
|
|
77
84
|
return (await this.loadCoValue(id)).getCurrentContent();
|
|
78
85
|
}
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
/** @category 3. Low-level */
|
|
87
|
+
subscribe(id, callback) {
|
|
88
|
+
let stopped = false;
|
|
89
|
+
let unsubscribe;
|
|
90
|
+
console.log("Subscribing to " + id);
|
|
91
|
+
this.load(id)
|
|
92
|
+
.then((coValue) => {
|
|
93
|
+
if (stopped) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
unsubscribe = coValue.subscribe(callback);
|
|
97
|
+
})
|
|
98
|
+
.catch((e) => {
|
|
99
|
+
console.error("Error subscribing to ", id, e);
|
|
100
|
+
});
|
|
101
|
+
return () => {
|
|
102
|
+
console.log("Unsubscribing from " + id);
|
|
103
|
+
stopped = true;
|
|
104
|
+
unsubscribe?.();
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** @category 1. High-level */
|
|
108
|
+
query(id, callback) {
|
|
109
|
+
return query(id, this, callback);
|
|
90
110
|
}
|
|
111
|
+
/** @category 1. High-level */
|
|
91
112
|
async acceptInvite(groupOrOwnedValueID, inviteSecret) {
|
|
92
113
|
const groupOrOwnedValue = await this.load(groupOrOwnedValueID);
|
|
93
114
|
if (groupOrOwnedValue.core.header.ruleset.type === "ownedByGroup") {
|
|
@@ -125,7 +146,8 @@ export class LocalNode {
|
|
|
125
146
|
: inviteRole === "writerInvite"
|
|
126
147
|
? "writer"
|
|
127
148
|
: "reader");
|
|
128
|
-
group.underlyingMap.core._sessions =
|
|
149
|
+
group.underlyingMap.core._sessions =
|
|
150
|
+
groupAsInvite.underlyingMap.core.sessions;
|
|
129
151
|
group.underlyingMap.core._cachedContent = undefined;
|
|
130
152
|
for (const groupListener of group.underlyingMap.core.listeners) {
|
|
131
153
|
groupListener(group.underlyingMap.core.getCurrentContent());
|
|
@@ -153,30 +175,38 @@ export class LocalNode {
|
|
|
153
175
|
}
|
|
154
176
|
/** @internal */
|
|
155
177
|
createAccount(name, agentSecret = newRandomAgentSecret()) {
|
|
156
|
-
const
|
|
178
|
+
const accountAgentID = getAgentID(agentSecret);
|
|
179
|
+
const account = this.createCoValue(accountHeaderForInitialAgentSecret(agentSecret)).testWithDifferentAccount(new AnonymousControlledAccount(agentSecret), newRandomSessionID(accountAgentID));
|
|
157
180
|
const accountAsGroup = new Group(expectGroupContent(account.getCurrentContent()), account.node);
|
|
158
|
-
accountAsGroup.underlyingMap.
|
|
159
|
-
editable.set(
|
|
181
|
+
accountAsGroup.underlyingMap.mutate((editable) => {
|
|
182
|
+
editable.set(accountAgentID, "admin", "trusting");
|
|
160
183
|
const readKey = newRandomKeySecret();
|
|
161
|
-
editable.set(`${readKey.id}_for_${
|
|
162
|
-
|
|
163
|
-
|
|
184
|
+
editable.set(`${readKey.id}_for_${accountAgentID}`, seal({
|
|
185
|
+
message: readKey.secret,
|
|
186
|
+
from: getAgentSealerSecret(agentSecret),
|
|
187
|
+
to: getAgentSealerID(accountAgentID),
|
|
188
|
+
nOnceMaterial: {
|
|
189
|
+
in: account.id,
|
|
190
|
+
tx: account.nextTransactionID(),
|
|
191
|
+
},
|
|
164
192
|
}), "trusting");
|
|
165
193
|
editable.set("readKey", readKey.id, "trusting");
|
|
166
194
|
});
|
|
167
195
|
const controlledAccount = new ControlledAccount(agentSecret, account.getCurrentContent(), account.node);
|
|
168
|
-
const profile = accountAsGroup.createMap({
|
|
196
|
+
const profile = accountAsGroup.createMap({ name }, {
|
|
169
197
|
type: "profile",
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
editable.set("name", name, "trusting");
|
|
173
|
-
});
|
|
174
|
-
accountAsGroup.underlyingMap.edit((editable) => {
|
|
175
|
-
editable.set("profile", profile.id, "trusting");
|
|
176
|
-
});
|
|
198
|
+
}, "trusting");
|
|
199
|
+
accountAsGroup.underlyingMap.set("profile", profile.id, "trusting");
|
|
177
200
|
const accountOnThisNode = this.expectCoValueLoaded(account.id);
|
|
178
|
-
accountOnThisNode._sessions = {
|
|
201
|
+
accountOnThisNode._sessions = {
|
|
202
|
+
...accountAsGroup.underlyingMap.core.sessions,
|
|
203
|
+
};
|
|
179
204
|
accountOnThisNode._cachedContent = undefined;
|
|
205
|
+
const profileOnThisNode = this.createCoValue(profile.core.header);
|
|
206
|
+
profileOnThisNode._sessions = {
|
|
207
|
+
...profile.core.sessions,
|
|
208
|
+
};
|
|
209
|
+
profileOnThisNode._cachedContent = undefined;
|
|
180
210
|
return controlledAccount;
|
|
181
211
|
}
|
|
182
212
|
/** @internal */
|
|
@@ -192,9 +222,12 @@ export class LocalNode {
|
|
|
192
222
|
coValue.header.meta.type !== "account") {
|
|
193
223
|
throw new Error(`${expectation ? expectation + ": " : ""}CoValue ${id} is not an account`);
|
|
194
224
|
}
|
|
195
|
-
return new
|
|
225
|
+
return new AccountGroup(coValue.getCurrentContent(), this).getCurrentAgentID();
|
|
196
226
|
}
|
|
197
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* Creates a new group (with the current account as the group's first admin).
|
|
229
|
+
* @category 1. High-level
|
|
230
|
+
*/
|
|
198
231
|
createGroup() {
|
|
199
232
|
const groupCoValue = this.createCoValue({
|
|
200
233
|
type: "comap",
|
|
@@ -203,12 +236,17 @@ export class LocalNode {
|
|
|
203
236
|
...createdNowUnique(),
|
|
204
237
|
});
|
|
205
238
|
let groupContent = expectGroupContent(groupCoValue.getCurrentContent());
|
|
206
|
-
groupContent = groupContent.
|
|
239
|
+
groupContent = groupContent.mutate((editable) => {
|
|
207
240
|
editable.set(this.account.id, "admin", "trusting");
|
|
208
241
|
const readKey = newRandomKeySecret();
|
|
209
|
-
editable.set(`${readKey.id}_for_${this.account.id}`, seal(
|
|
210
|
-
|
|
211
|
-
|
|
242
|
+
editable.set(`${readKey.id}_for_${this.account.id}`, seal({
|
|
243
|
+
message: readKey.secret,
|
|
244
|
+
from: this.account.currentSealerSecret(),
|
|
245
|
+
to: this.account.currentSealerID(),
|
|
246
|
+
nOnceMaterial: {
|
|
247
|
+
in: groupCoValue.id,
|
|
248
|
+
tx: groupCoValue.nextTransactionID(),
|
|
249
|
+
},
|
|
212
250
|
}), "trusting");
|
|
213
251
|
editable.set("readKey", readKey.id, "trusting");
|
|
214
252
|
});
|
|
@@ -256,4 +294,4 @@ export function newLoadingState() {
|
|
|
256
294
|
resolve: resolve,
|
|
257
295
|
};
|
|
258
296
|
}
|
|
259
|
-
//# sourceMappingURL=
|
|
297
|
+
//# sourceMappingURL=localNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localNode.js","sourceRoot":"","sources":["../src/localNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,yBAAyB,EACzB,gBAAgB,EAChB,UAAU,EACV,gBA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