cojson 0.3.6 → 0.4.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/dist/coValue.d.ts +7 -12
- package/dist/coValue.js.map +1 -1
- package/dist/coValueCore.d.ts +9 -4
- package/dist/coValueCore.js +69 -33
- package/dist/coValueCore.js.map +1 -1
- package/dist/coValues/account.d.ts +62 -0
- package/dist/{account.js → coValues/account.js} +19 -11
- package/dist/coValues/account.js.map +1 -0
- package/dist/coValues/coList.d.ts +19 -19
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.d.ts +31 -23
- package/dist/coValues/coMap.js +4 -6
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.d.ts +19 -19
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/{group.d.ts → coValues/group.d.ts} +27 -38
- package/dist/{group.js → coValues/group.js} +69 -73
- package/dist/coValues/group.js.map +1 -0
- package/dist/ids.d.ts +1 -1
- package/dist/index.d.ts +15 -11
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/localNode.d.ts +20 -7
- package/dist/localNode.js +74 -39
- package/dist/localNode.js.map +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/permissions.d.ts +1 -1
- package/dist/permissions.js +43 -22
- package/dist/permissions.js.map +1 -1
- package/dist/queriedCoValues/queriedAccount.d.ts +13 -0
- package/dist/queriedCoValues/queriedAccount.js +24 -0
- package/dist/queriedCoValues/queriedAccount.js.map +1 -0
- package/dist/queriedCoValues/queriedCoList.d.ts +10 -10
- package/dist/queriedCoValues/queriedCoList.js +11 -15
- package/dist/queriedCoValues/queriedCoList.js.map +1 -1
- package/dist/queriedCoValues/queriedCoMap.d.ts +14 -21
- package/dist/queriedCoValues/queriedCoMap.js +27 -28
- package/dist/queriedCoValues/queriedCoMap.js.map +1 -1
- package/dist/queriedCoValues/queriedCoStream.d.ts +9 -9
- package/dist/queriedCoValues/queriedCoStream.js +44 -20
- package/dist/queriedCoValues/queriedCoStream.js.map +1 -1
- package/dist/queriedCoValues/queriedGroup.d.ts +29 -0
- package/dist/queriedCoValues/queriedGroup.js +54 -0
- package/dist/queriedCoValues/queriedGroup.js.map +1 -0
- package/dist/queries.d.ts +40 -9
- package/dist/queries.js +104 -39
- package/dist/queries.js.map +1 -1
- package/dist/sync.js +1 -0
- package/dist/sync.js.map +1 -1
- package/dist/tests/testUtils.d.ts +15 -7
- package/dist/tests/testUtils.js +16 -17
- package/dist/tests/testUtils.js.map +1 -1
- package/package.json +2 -2
- package/src/coValue.ts +12 -31
- package/src/coValueCore.ts +100 -40
- package/src/{account.ts → coValues/account.ts} +46 -27
- package/src/coValues/coList.ts +24 -28
- package/src/coValues/coMap.ts +42 -68
- package/src/coValues/coStream.ts +20 -26
- package/src/{group.ts → coValues/group.ts} +121 -141
- package/src/ids.ts +1 -1
- package/src/index.ts +25 -10
- package/src/localNode.ts +180 -77
- package/src/media.ts +1 -1
- package/src/permissions.ts +67 -36
- package/src/queriedCoValues/queriedAccount.ts +40 -0
- package/src/queriedCoValues/queriedCoList.ts +22 -30
- package/src/queriedCoValues/queriedCoMap.ts +60 -72
- package/src/queriedCoValues/queriedCoStream.ts +67 -37
- package/src/queriedCoValues/queriedGroup.ts +90 -0
- package/src/queries.ts +181 -60
- package/src/sync.ts +1 -0
- package/src/tests/account.test.ts +14 -9
- package/src/tests/coValueCore.test.ts +2 -2
- package/src/tests/permissions.test.ts +351 -242
- package/src/tests/queries.test.ts +98 -79
- package/src/tests/sync.test.ts +11 -11
- package/src/tests/testUtils.ts +16 -18
- package/dist/account.d.ts +0 -58
- package/dist/account.js.map +0 -1
- package/dist/group.js.map +0 -1
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { expectMap } from "../coValue.js";
|
|
2
|
+
import { CoMap } from "./coMap.js";
|
|
3
|
+
import { createdNowUnique, newRandomKeySecret, seal, encryptKeySecret, getAgentSealerID, newRandomSecretSeed, agentSecretFromSecretSeed, getAgentID, } from "../crypto.js";
|
|
4
|
+
import { isAgentID } from "../ids.js";
|
|
3
5
|
import { base58 } from "@scure/base";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
export const EVERYONE = "everyone";
|
|
7
|
+
export function expectGroup(content) {
|
|
8
|
+
const map = expectMap(content);
|
|
9
|
+
if (map.core.header.ruleset.type !== "group") {
|
|
10
|
+
throw new Error("Expected group ruleset in group");
|
|
7
11
|
}
|
|
8
|
-
|
|
12
|
+
if (!(map instanceof Group)) {
|
|
13
|
+
throw new Error("Expected group");
|
|
14
|
+
}
|
|
15
|
+
return map;
|
|
9
16
|
}
|
|
10
17
|
/** A `Group` is a scope for permissions of its members (`"reader" | "writer" | "admin"`), applying to objects owned by that group.
|
|
11
18
|
*
|
|
@@ -28,20 +35,7 @@ export function expectGroupContent(content) {
|
|
|
28
35
|
* const localNode.createGroup();
|
|
29
36
|
* ```
|
|
30
37
|
* */
|
|
31
|
-
export class Group {
|
|
32
|
-
/** @internal */
|
|
33
|
-
constructor(underlyingMap, node) {
|
|
34
|
-
this.underlyingMap = underlyingMap;
|
|
35
|
-
this.node = node;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Returns the `CoID` of the `Group`.
|
|
39
|
-
*
|
|
40
|
-
* @category 4. Underlying CoMap
|
|
41
|
-
*/
|
|
42
|
-
get id() {
|
|
43
|
-
return this.underlyingMap.id;
|
|
44
|
-
}
|
|
38
|
+
export class Group extends CoMap {
|
|
45
39
|
/**
|
|
46
40
|
* Returns the current role of a given account.
|
|
47
41
|
*
|
|
@@ -52,7 +46,7 @@ export class Group {
|
|
|
52
46
|
}
|
|
53
47
|
/** @internal */
|
|
54
48
|
roleOfInternal(accountID) {
|
|
55
|
-
return this.
|
|
49
|
+
return this.get(accountID);
|
|
56
50
|
}
|
|
57
51
|
/**
|
|
58
52
|
* Returns the role of the current account in the group.
|
|
@@ -60,7 +54,7 @@ export class Group {
|
|
|
60
54
|
* @category 1. Role reading
|
|
61
55
|
*/
|
|
62
56
|
myRole() {
|
|
63
|
-
return this.roleOfInternal(this.node.account.id);
|
|
57
|
+
return this.roleOfInternal(this.core.node.account.id);
|
|
64
58
|
}
|
|
65
59
|
/**
|
|
66
60
|
* Directly grants a new member a role in the group. The current account must be an
|
|
@@ -69,47 +63,55 @@ export class Group {
|
|
|
69
63
|
* @category 2. Role changing
|
|
70
64
|
*/
|
|
71
65
|
addMember(accountID, role) {
|
|
72
|
-
this.addMemberInternal(accountID, role);
|
|
66
|
+
return this.addMemberInternal(accountID, role);
|
|
73
67
|
}
|
|
74
68
|
/** @internal */
|
|
75
69
|
addMemberInternal(accountID, role) {
|
|
76
|
-
|
|
77
|
-
const currentReadKey = this.
|
|
70
|
+
return this.mutate((mutable) => {
|
|
71
|
+
const currentReadKey = this.core.getCurrentReadKey();
|
|
78
72
|
if (!currentReadKey.secret) {
|
|
79
73
|
throw new Error("Can't add member without read key secret");
|
|
80
74
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
if (accountID === EVERYONE) {
|
|
76
|
+
if (!(role === "reader" || role === "writer")) {
|
|
77
|
+
throw new Error("Can't make everyone something other than reader or writer");
|
|
78
|
+
}
|
|
79
|
+
mutable.set(accountID, role, "trusting");
|
|
80
|
+
if (mutable.get(accountID) !== role) {
|
|
81
|
+
throw new Error("Failed to set role");
|
|
82
|
+
}
|
|
83
|
+
mutable.set(`${currentReadKey.id}_for_${EVERYONE}`, currentReadKey.secret, "trusting");
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const agent = this.core.node.resolveAccountAgent(accountID, "Expected to know agent to add them to group");
|
|
87
|
+
mutable.set(accountID, role, "trusting");
|
|
88
|
+
if (mutable.get(accountID) !== role) {
|
|
89
|
+
throw new Error("Failed to set role");
|
|
90
|
+
}
|
|
91
|
+
mutable.set(`${currentReadKey.id}_for_${accountID}`, seal({
|
|
92
|
+
message: currentReadKey.secret,
|
|
93
|
+
from: this.core.node.account.currentSealerSecret(),
|
|
94
|
+
to: getAgentSealerID(agent),
|
|
95
|
+
nOnceMaterial: {
|
|
96
|
+
in: this.id,
|
|
97
|
+
tx: this.core.nextTransactionID(),
|
|
98
|
+
},
|
|
99
|
+
}), "trusting");
|
|
85
100
|
}
|
|
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
|
-
},
|
|
94
|
-
}), "trusting");
|
|
95
101
|
});
|
|
96
102
|
}
|
|
97
103
|
/** @internal */
|
|
98
104
|
rotateReadKey() {
|
|
99
|
-
const currentlyPermittedReaders = this.
|
|
100
|
-
.keys()
|
|
101
|
-
.filter((key) => {
|
|
105
|
+
const currentlyPermittedReaders = this.keys().filter((key) => {
|
|
102
106
|
if (key.startsWith("co_") || isAgentID(key)) {
|
|
103
|
-
const role = this.
|
|
104
|
-
return (role === "admin" ||
|
|
105
|
-
role === "writer" ||
|
|
106
|
-
role === "reader");
|
|
107
|
+
const role = this.get(key);
|
|
108
|
+
return (role === "admin" || role === "writer" || role === "reader");
|
|
107
109
|
}
|
|
108
110
|
else {
|
|
109
111
|
return false;
|
|
110
112
|
}
|
|
111
113
|
});
|
|
112
|
-
const maybeCurrentReadKey = this.
|
|
114
|
+
const maybeCurrentReadKey = this.core.getCurrentReadKey();
|
|
113
115
|
if (!maybeCurrentReadKey.secret) {
|
|
114
116
|
throw new Error("Can't rotate read key secret we don't have access to");
|
|
115
117
|
}
|
|
@@ -118,24 +120,24 @@ export class Group {
|
|
|
118
120
|
secret: maybeCurrentReadKey.secret,
|
|
119
121
|
};
|
|
120
122
|
const newReadKey = newRandomKeySecret();
|
|
121
|
-
|
|
123
|
+
return this.mutate((mutable) => {
|
|
122
124
|
for (const readerID of currentlyPermittedReaders) {
|
|
123
|
-
const reader = this.node.resolveAccountAgent(readerID, "Expected to know currently permitted reader");
|
|
124
|
-
|
|
125
|
+
const reader = this.core.node.resolveAccountAgent(readerID, "Expected to know currently permitted reader");
|
|
126
|
+
mutable.set(`${newReadKey.id}_for_${readerID}`, seal({
|
|
125
127
|
message: newReadKey.secret,
|
|
126
|
-
from: this.
|
|
128
|
+
from: this.core.node.account.currentSealerSecret(),
|
|
127
129
|
to: getAgentSealerID(reader),
|
|
128
130
|
nOnceMaterial: {
|
|
129
|
-
in: this.
|
|
130
|
-
tx: this.
|
|
131
|
+
in: this.id,
|
|
132
|
+
tx: this.core.nextTransactionID(),
|
|
131
133
|
},
|
|
132
134
|
}), "trusting");
|
|
133
135
|
}
|
|
134
|
-
|
|
136
|
+
mutable.set(`${currentReadKey.id}_for_${newReadKey.id}`, encryptKeySecret({
|
|
135
137
|
encrypting: newReadKey,
|
|
136
138
|
toEncrypt: currentReadKey,
|
|
137
139
|
}).encrypted, "trusting");
|
|
138
|
-
|
|
140
|
+
mutable.set("readKey", newReadKey.id, "trusting");
|
|
139
141
|
});
|
|
140
142
|
}
|
|
141
143
|
/**
|
|
@@ -146,14 +148,14 @@ export class Group {
|
|
|
146
148
|
* @category 2. Role changing
|
|
147
149
|
*/
|
|
148
150
|
removeMember(accountID) {
|
|
149
|
-
this.removeMemberInternal(accountID);
|
|
151
|
+
return this.removeMemberInternal(accountID);
|
|
150
152
|
}
|
|
151
153
|
/** @internal */
|
|
152
154
|
removeMemberInternal(accountID) {
|
|
153
|
-
|
|
155
|
+
const afterRevoke = this.mutate((map) => {
|
|
154
156
|
map.set(accountID, "revoked", "trusting");
|
|
155
157
|
});
|
|
156
|
-
|
|
158
|
+
return afterRevoke.rotateReadKey();
|
|
157
159
|
}
|
|
158
160
|
/**
|
|
159
161
|
* Creates an invite for new members to indirectly join the group,
|
|
@@ -175,13 +177,13 @@ export class Group {
|
|
|
175
177
|
*
|
|
176
178
|
* @category 3. Value creation
|
|
177
179
|
*/
|
|
178
|
-
createMap(init, meta, initPrivacy = "
|
|
179
|
-
let map = this.node
|
|
180
|
+
createMap(init, meta, initPrivacy = "private") {
|
|
181
|
+
let map = this.core.node
|
|
180
182
|
.createCoValue({
|
|
181
183
|
type: "comap",
|
|
182
184
|
ruleset: {
|
|
183
185
|
type: "ownedByGroup",
|
|
184
|
-
group: this.
|
|
186
|
+
group: this.id,
|
|
185
187
|
},
|
|
186
188
|
meta: meta || null,
|
|
187
189
|
...createdNowUnique(),
|
|
@@ -200,13 +202,13 @@ export class Group {
|
|
|
200
202
|
*
|
|
201
203
|
* @category 3. Value creation
|
|
202
204
|
*/
|
|
203
|
-
createList(init, meta, initPrivacy = "
|
|
204
|
-
let list = this.node
|
|
205
|
+
createList(init, meta, initPrivacy = "private") {
|
|
206
|
+
let list = this.core.node
|
|
205
207
|
.createCoValue({
|
|
206
208
|
type: "colist",
|
|
207
209
|
ruleset: {
|
|
208
210
|
type: "ownedByGroup",
|
|
209
|
-
group: this.
|
|
211
|
+
group: this.id,
|
|
210
212
|
},
|
|
211
213
|
meta: meta || null,
|
|
212
214
|
...createdNowUnique(),
|
|
@@ -221,12 +223,12 @@ export class Group {
|
|
|
221
223
|
}
|
|
222
224
|
/** @category 3. Value creation */
|
|
223
225
|
createStream(meta) {
|
|
224
|
-
return this.node
|
|
226
|
+
return this.core.node
|
|
225
227
|
.createCoValue({
|
|
226
228
|
type: "costream",
|
|
227
229
|
ruleset: {
|
|
228
230
|
type: "ownedByGroup",
|
|
229
|
-
group: this.
|
|
231
|
+
group: this.id,
|
|
230
232
|
},
|
|
231
233
|
meta: meta || null,
|
|
232
234
|
...createdNowUnique(),
|
|
@@ -235,24 +237,18 @@ export class Group {
|
|
|
235
237
|
}
|
|
236
238
|
/** @category 3. Value creation */
|
|
237
239
|
createBinaryStream(meta = { type: "binary" }) {
|
|
238
|
-
return this.node
|
|
240
|
+
return this.core.node
|
|
239
241
|
.createCoValue({
|
|
240
242
|
type: "costream",
|
|
241
243
|
ruleset: {
|
|
242
244
|
type: "ownedByGroup",
|
|
243
|
-
group: this.
|
|
245
|
+
group: this.id,
|
|
244
246
|
},
|
|
245
247
|
meta: meta,
|
|
246
248
|
...createdNowUnique(),
|
|
247
249
|
})
|
|
248
250
|
.getCurrentContent();
|
|
249
251
|
}
|
|
250
|
-
/** @internal */
|
|
251
|
-
testWithDifferentAccount(account, sessionId) {
|
|
252
|
-
return new Group(expectGroupContent(this.underlyingMap.core
|
|
253
|
-
.testWithDifferentAccount(account, sessionId)
|
|
254
|
-
.getCurrentContent()), this.node);
|
|
255
|
-
}
|
|
256
252
|
}
|
|
257
253
|
function inviteSecretFromSecretSeed(secretSeed) {
|
|
258
254
|
return `inviteSecret_z${base58.encode(secretSeed)}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/coValues/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAInC,OAAO,EAIH,gBAAgB,EAChB,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAEhB,mBAAmB,EACnB,yBAAyB,EACzB,UAAU,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAW,SAAS,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAmB,CAAC;AAiB5C,MAAM,UAAU,WAAW,CAAC,OAAgB;IACxC,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE;QAC1C,MA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B,CAAC;aACD,iBAAiB,EAAO,CAAC;IAClC,CAAC;IAED,kCAAkC;IAClC,kBAAkB,CACd,OAAkB,EAAE,IAAI,EAAE,QAAQ,EAAE;QAEpC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI;aAChB,aAAa,CAAC;YACX,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE;gBACL,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,IAAI,CAAC,EAAE;aACjB;YACD,IAAI,EAAE,IAAI;YACV,GAAG,gBAAgB,EAAE;SACxB,CAAC;aACD,iBAAiB,EAAO,CAAC;IAClC,CAAC;CACJ;AAID,SAAS,0BAA0B,CAAC,UAAsB;IACtD,OAAO,iBAAiB,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;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/ids.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountID } from './account.js';
|
|
1
|
+
import { AccountID } from './coValues/account.js';
|
|
2
2
|
export type RawCoID = `co_z${string}`;
|
|
3
3
|
export declare function rawCoIDtoBytes(id: RawCoID): Uint8Array;
|
|
4
4
|
export declare function rawCoIDfromBytes(bytes: Uint8Array): RawCoID;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoValueCore, newRandomSessionID, MAX_RECOMMENDED_TX_SIZE } from "./coValueCore.js";
|
|
1
|
+
import { CoValueCore, newRandomSessionID, MAX_RECOMMENDED_TX_SIZE, accountOrAgentIDfromSessionID } from "./coValueCore.js";
|
|
2
2
|
import { LocalNode } from "./localNode.js";
|
|
3
3
|
import type { CoValue } from "./coValue.js";
|
|
4
4
|
import { CoMap, MutableCoMap } from "./coValues/coMap.js";
|
|
@@ -6,23 +6,26 @@ import { CoList, MutableCoList } from "./coValues/coList.js";
|
|
|
6
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
|
-
import { AnonymousControlledAccount, ControlledAccount } from "./account.js";
|
|
9
|
+
import { AnonymousControlledAccount, ControlledAccount } from "./coValues/account.js";
|
|
10
10
|
import { rawCoIDtoBytes, rawCoIDfromBytes } from "./ids.js";
|
|
11
|
-
import { Group,
|
|
11
|
+
import { Group, expectGroup, EVERYONE } from "./coValues/group.js";
|
|
12
12
|
import { base64URLtoBytes, bytesToBase64url } from "./base64url.js";
|
|
13
13
|
import { parseJSON } from "./jsonStringify.js";
|
|
14
|
+
import { Account, Profile, isAccountID } from "./coValues/account.js";
|
|
14
15
|
import type { SessionID, AgentID } from "./ids.js";
|
|
15
16
|
import type { CoID, AnyCoValue } from "./coValue.js";
|
|
16
|
-
import type { Queried } from "./queries.js";
|
|
17
|
+
import type { Queried, QueryExtension } from "./queries.js";
|
|
17
18
|
import type { QueriedCoStream } from "./queriedCoValues/queriedCoStream.js";
|
|
18
19
|
import type { QueriedCoList } from "./queriedCoValues/queriedCoList.js";
|
|
19
20
|
import type { QueriedCoMap } from "./queriedCoValues/queriedCoMap.js";
|
|
21
|
+
import { QueriedAccount } from "./queriedCoValues/queriedAccount.js";
|
|
22
|
+
import { QueriedGroup } from "./queriedCoValues/queriedGroup.js";
|
|
20
23
|
import type { BinaryStreamInfo, BinaryCoStreamMeta } from "./coValues/coStream.js";
|
|
21
24
|
import type { JsonValue } from "./jsonValue.js";
|
|
22
25
|
import type { SyncMessage, Peer } from "./sync.js";
|
|
23
26
|
import type { AgentSecret } from "./crypto.js";
|
|
24
|
-
import type { AccountID,
|
|
25
|
-
import type { InviteSecret } from "./group.js";
|
|
27
|
+
import type { AccountID, AccountMeta, AccountMigration, ProfileMeta } from "./coValues/account.js";
|
|
28
|
+
import type { InviteSecret } from "./coValues/group.js";
|
|
26
29
|
import type * as Media from "./media.js";
|
|
27
30
|
type Value = JsonValue | AnyCoValue;
|
|
28
31
|
/** @hidden */
|
|
@@ -39,12 +42,14 @@ export declare const cojsonInternals: {
|
|
|
39
42
|
agentSecretFromSecretSeed: typeof agentSecretFromSecretSeed;
|
|
40
43
|
secretSeedLength: number;
|
|
41
44
|
shortHashLength: number;
|
|
42
|
-
|
|
45
|
+
expectGroup: typeof expectGroup;
|
|
43
46
|
base64URLtoBytes: typeof base64URLtoBytes;
|
|
44
47
|
bytesToBase64url: typeof bytesToBase64url;
|
|
45
48
|
parseJSON: typeof parseJSON;
|
|
49
|
+
accountOrAgentIDfromSessionID: typeof accountOrAgentIDfromSessionID;
|
|
50
|
+
isAccountID: typeof isAccountID;
|
|
46
51
|
};
|
|
47
|
-
export { LocalNode, Group, CoMap, MutableCoMap, CoList, MutableCoList, CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream, CoValue, CoID, AnyCoValue, Queried, QueriedCoMap, QueriedCoList, QueriedCoStream,
|
|
52
|
+
export { LocalNode, Group, EVERYONE, CoMap, MutableCoMap, CoList, MutableCoList, CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream, CoValue, CoID, AnyCoValue, Queried, QueriedCoMap, QueriedCoList, QueriedCoStream, QueriedGroup, QueriedAccount, Account, AccountID, AccountMeta, AccountMigration, Profile, ProfileMeta, SessionID, Media, CoValueCore, AnonymousControlledAccount, ControlledAccount, cryptoReady as cojsonReady, MAX_RECOMMENDED_TX_SIZE, Value, JsonValue, Peer, BinaryStreamInfo, BinaryCoStreamMeta, AgentID, AgentSecret, InviteSecret, SyncMessage, QueryExtension, };
|
|
48
53
|
export declare namespace CojsonInternalTypes {
|
|
49
54
|
type CoValueKnownState = import("./sync.js").CoValueKnownState;
|
|
50
55
|
type DoneMessage = import("./sync.js").DoneMessage;
|
|
@@ -55,9 +60,8 @@ export declare namespace CojsonInternalTypes {
|
|
|
55
60
|
type Transaction = import("./coValueCore.js").Transaction;
|
|
56
61
|
type Signature = import("./crypto.js").Signature;
|
|
57
62
|
type RawCoID = import("./ids.js").RawCoID;
|
|
58
|
-
type
|
|
59
|
-
type
|
|
60
|
-
type ProfileMeta = import("./account.js").ProfileMeta;
|
|
63
|
+
type ProfileShape = import("./coValues/account.js").ProfileShape;
|
|
64
|
+
type ProfileMeta = import("./coValues/account.js").ProfileMeta;
|
|
61
65
|
type SealerSecret = import("./crypto.js").SealerSecret;
|
|
62
66
|
type SignerSecret = import("./crypto.js").SignerSecret;
|
|
63
67
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { CoValueCore, newRandomSessionID, MAX_RECOMMENDED_TX_SIZE, } from "./coValueCore.js";
|
|
1
|
+
import { CoValueCore, newRandomSessionID, MAX_RECOMMENDED_TX_SIZE, accountOrAgentIDfromSessionID } from "./coValueCore.js";
|
|
2
2
|
import { LocalNode } from "./localNode.js";
|
|
3
3
|
import { CoMap, MutableCoMap } from "./coValues/coMap.js";
|
|
4
4
|
import { CoList, MutableCoList } from "./coValues/coList.js";
|
|
5
5
|
import { CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream, } from "./coValues/coStream.js";
|
|
6
6
|
import { agentSecretFromBytes, agentSecretToBytes, getAgentID, newRandomAgentSecret, newRandomSecretSeed, agentSecretFromSecretSeed, secretSeedLength, shortHashLength, cryptoReady, } from "./crypto.js";
|
|
7
7
|
import { connectedPeers } from "./streamUtils.js";
|
|
8
|
-
import { AnonymousControlledAccount, ControlledAccount } from "./account.js";
|
|
8
|
+
import { AnonymousControlledAccount, ControlledAccount, } from "./coValues/account.js";
|
|
9
9
|
import { rawCoIDtoBytes, rawCoIDfromBytes } from "./ids.js";
|
|
10
|
-
import { Group,
|
|
10
|
+
import { Group, expectGroup, EVERYONE } from "./coValues/group.js";
|
|
11
11
|
import { base64URLtoBytes, bytesToBase64url } from "./base64url.js";
|
|
12
12
|
import { parseJSON } from "./jsonStringify.js";
|
|
13
|
+
import { Account, Profile, isAccountID } from "./coValues/account.js";
|
|
14
|
+
import { QueriedAccount } from "./queriedCoValues/queriedAccount.js";
|
|
15
|
+
import { QueriedGroup } from "./queriedCoValues/queriedGroup.js";
|
|
13
16
|
/** @hidden */
|
|
14
17
|
export const cojsonInternals = {
|
|
15
18
|
agentSecretFromBytes,
|
|
@@ -24,10 +27,12 @@ export const cojsonInternals = {
|
|
|
24
27
|
agentSecretFromSecretSeed,
|
|
25
28
|
secretSeedLength,
|
|
26
29
|
shortHashLength,
|
|
27
|
-
|
|
30
|
+
expectGroup,
|
|
28
31
|
base64URLtoBytes,
|
|
29
32
|
bytesToBase64url,
|
|
30
33
|
parseJSON,
|
|
34
|
+
accountOrAgentIDfromSessionID,
|
|
35
|
+
isAccountID,
|
|
31
36
|
};
|
|
32
|
-
export { LocalNode, Group, CoMap, MutableCoMap, CoList, MutableCoList, CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream, CoValueCore, AnonymousControlledAccount, ControlledAccount, cryptoReady as cojsonReady, MAX_RECOMMENDED_TX_SIZE, };
|
|
37
|
+
export { LocalNode, Group, EVERYONE, CoMap, MutableCoMap, CoList, MutableCoList, CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream, QueriedGroup, QueriedAccount, Account, Profile, CoValueCore, AnonymousControlledAccount, ControlledAccount, cryptoReady as cojsonReady, MAX_RECOMMENDED_TX_SIZE, };
|
|
33
38
|
//# 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,EACH,WAAW,EACX,kBAAkB,EAClB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,uBAAuB,EACvB,6BAA6B,EAChC,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,EACH,0BAA0B,EAC1B,iBAAiB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAQtE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAcjE,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,WAAW;IACX,gBAAgB;IAChB,gBAAgB;IAChB,SAAS;IACT,6BAA6B;IAC7B,WAAW;CACd,CAAC;AAEF,OAAO,EACH,SAAS,EACT,KAAK,EACL,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,MAAM,EACN,aAAa,EACb,QAAQ,EACR,eAAe,EACf,cAAc,EACd,qBAAqB,EAQrB,YAAY,EACZ,cAAc,EACd,OAAO,EAIP,OAAO,EAIP,WAAW,EACX,0BAA0B,EAC1B,iBAAiB,EACjB,WAAW,IAAI,WAAW,EAC1B,uBAAuB,GAW1B,CAAC"}
|
package/dist/localNode.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { AgentSecret } from "./crypto.js";
|
|
2
2
|
import { CoValueCore, CoValueHeader } from "./coValueCore.js";
|
|
3
|
-
import { InviteSecret, Group } from "./group.js";
|
|
3
|
+
import { InviteSecret, Group } from "./coValues/group.js";
|
|
4
4
|
import { Peer, SyncManager } from "./sync.js";
|
|
5
5
|
import { AgentID, RawCoID, SessionID } from "./ids.js";
|
|
6
6
|
import { CoID } from "./coValue.js";
|
|
7
7
|
import { Queried } from "./queries.js";
|
|
8
|
-
import { GeneralizedControlledAccount, ControlledAccount, AccountID, Profile } from "./account.js";
|
|
8
|
+
import { Account, AccountMeta, GeneralizedControlledAccount, ControlledAccount, AccountID, Profile, AccountMigration } from "./coValues/account.js";
|
|
9
|
+
import { CoMap } from "./coValues/coMap.js";
|
|
9
10
|
import { CoValue } from "./index.js";
|
|
11
|
+
import { QueriedAccount } from "./queriedCoValues/queriedAccount.js";
|
|
10
12
|
/** A `LocalNode` represents a local view of a set of loaded `CoValue`s, from the perspective of a particular account (or primitive cryptographic agent).
|
|
11
13
|
|
|
12
14
|
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).
|
|
@@ -32,14 +34,24 @@ export declare class LocalNode {
|
|
|
32
34
|
/** @category 3. Low-level */
|
|
33
35
|
constructor(account: GeneralizedControlledAccount, currentSessionID: SessionID);
|
|
34
36
|
/** @category 2. Node Creation */
|
|
35
|
-
static withNewlyCreatedAccount(name
|
|
37
|
+
static withNewlyCreatedAccount<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta>({ name, migration, initialAgentSecret, }: {
|
|
38
|
+
name: string;
|
|
39
|
+
migration?: AccountMigration<P, R, Meta>;
|
|
40
|
+
initialAgentSecret?: AgentSecret;
|
|
41
|
+
}): {
|
|
36
42
|
node: LocalNode;
|
|
37
43
|
accountID: AccountID;
|
|
38
44
|
accountSecret: AgentSecret;
|
|
39
45
|
sessionID: SessionID;
|
|
40
46
|
};
|
|
41
47
|
/** @category 2. Node Creation */
|
|
42
|
-
static withLoadedAccount(accountID
|
|
48
|
+
static withLoadedAccount<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta>({ accountID, accountSecret, sessionID, peersToLoadFrom, migration, }: {
|
|
49
|
+
accountID: AccountID;
|
|
50
|
+
accountSecret: AgentSecret;
|
|
51
|
+
sessionID: SessionID;
|
|
52
|
+
peersToLoadFrom: Peer[];
|
|
53
|
+
migration?: AccountMigration<P, R, Meta>;
|
|
54
|
+
}): Promise<LocalNode>;
|
|
43
55
|
/** @internal */
|
|
44
56
|
createCoValue(header: CoValueHeader): CoValueCore;
|
|
45
57
|
/** @internal */
|
|
@@ -56,7 +68,9 @@ export declare class LocalNode {
|
|
|
56
68
|
subscribe<T extends CoValue>(id: CoID<T>, callback: (update: T) => void): () => void;
|
|
57
69
|
/** @category 1. High-level */
|
|
58
70
|
query<T extends CoValue>(id: CoID<T>, callback: (update: Queried<T> | undefined) => void): () => void;
|
|
59
|
-
|
|
71
|
+
query<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta>(id: "me", callback: (update: QueriedAccount<Account<P, R, Meta>> | undefined) => void): () => void;
|
|
72
|
+
query(id: CoID<CoValue> | "me", callback: (update: Queried<CoValue> | QueriedAccount | undefined) => void): () => void;
|
|
73
|
+
/** @deprecated Use Account.acceptInvite instead */
|
|
60
74
|
acceptInvite<T extends CoValue>(groupOrOwnedValueID: CoID<T>, inviteSecret: InviteSecret): Promise<void>;
|
|
61
75
|
/** @internal */
|
|
62
76
|
expectCoValueLoaded(id: RawCoID, expectation?: string): CoValueCore;
|
|
@@ -67,8 +81,7 @@ export declare class LocalNode {
|
|
|
67
81
|
/** @internal */
|
|
68
82
|
resolveAccountAgent(id: AccountID | AgentID, expectation?: string): AgentID;
|
|
69
83
|
/**
|
|
70
|
-
*
|
|
71
|
-
* @category 1. High-level
|
|
84
|
+
* @deprecated use Account.createGroup() instead
|
|
72
85
|
*/
|
|
73
86
|
createGroup(): Group;
|
|
74
87
|
/** @internal */
|