cojson 0.3.7 → 0.4.1
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 +20 -20
- package/dist/coValues/coStream.js +2 -1
- 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 +13 -17
- package/dist/queriedCoValues/queriedCoStream.js +57 -32
- 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/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 +22 -28
- 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 +105 -79
- package/src/queriedCoValues/queriedGroup.ts +90 -0
- package/src/queries.ts +181 -60
- 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 +162 -82
- 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,6 +1,8 @@
|
|
|
1
|
-
import { CoID, CoValue,
|
|
2
|
-
import { CoMap } from "./
|
|
3
|
-
import {
|
|
1
|
+
import { CoID, CoValue, expectMap } from "../coValue.js";
|
|
2
|
+
import { CoMap } from "./coMap.js";
|
|
3
|
+
import { CoList } from "./coList.js";
|
|
4
|
+
import { JsonObject } from "../jsonValue.js";
|
|
5
|
+
import { BinaryCoStream, CoStream } from "./coStream.js";
|
|
4
6
|
import {
|
|
5
7
|
Encrypted,
|
|
6
8
|
KeyID,
|
|
@@ -14,37 +16,40 @@ import {
|
|
|
14
16
|
newRandomSecretSeed,
|
|
15
17
|
agentSecretFromSecretSeed,
|
|
16
18
|
getAgentID,
|
|
17
|
-
} from "
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { Role } from "./permissions.js";
|
|
19
|
+
} from "../crypto.js";
|
|
20
|
+
import { AgentID, isAgentID } from "../ids.js";
|
|
21
|
+
import { AccountID, Profile } from "./account.js";
|
|
22
|
+
import { Role } from "../permissions.js";
|
|
22
23
|
import { base58 } from "@scure/base";
|
|
23
|
-
import {
|
|
24
|
-
BinaryCoStream,
|
|
25
|
-
BinaryCoStreamMeta,
|
|
26
|
-
CoStream,
|
|
27
|
-
} from "./coValues/coStream.js";
|
|
28
24
|
|
|
29
|
-
export
|
|
30
|
-
|
|
25
|
+
export const EVERYONE = "everyone" as const;
|
|
26
|
+
export type Everyone = "everyone";
|
|
27
|
+
|
|
28
|
+
export type GroupShape<P extends Profile, R extends CoMap> = {
|
|
29
|
+
profile?: CoID<P> | null;
|
|
30
|
+
root?: CoID<R> | null;
|
|
31
31
|
[key: AccountID | AgentID]: Role;
|
|
32
|
+
[EVERYONE]?: Role;
|
|
32
33
|
readKey?: KeyID;
|
|
33
34
|
[revelationFor: `${KeyID}_for_${AccountID | AgentID}`]: Sealed<KeySecret>;
|
|
35
|
+
[revelationFor: `${KeyID}_for_${Everyone}`]: KeySecret;
|
|
34
36
|
[oldKeyForNewKey: `${KeyID}_for_${KeyID}`]: Encrypted<
|
|
35
37
|
KeySecret,
|
|
36
38
|
{ encryptedID: KeyID; encryptingID: KeyID }
|
|
37
39
|
>;
|
|
38
40
|
};
|
|
39
41
|
|
|
40
|
-
export function
|
|
41
|
-
content
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
export function expectGroup(content: CoValue): Group {
|
|
43
|
+
const map = expectMap(content);
|
|
44
|
+
if (map.core.header.ruleset.type !== "group") {
|
|
45
|
+
throw new Error("Expected group ruleset in group");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!(map instanceof Group)) {
|
|
49
|
+
throw new Error("Expected group");
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
return
|
|
52
|
+
return map;
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
/** A `Group` is a scope for permissions of its members (`"reader" | "writer" | "admin"`), applying to objects owned by that group.
|
|
@@ -68,30 +73,11 @@ export function expectGroupContent(
|
|
|
68
73
|
* const localNode.createGroup();
|
|
69
74
|
* ```
|
|
70
75
|
* */
|
|
71
|
-
export class Group
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/** @internal */
|
|
78
|
-
constructor(
|
|
79
|
-
underlyingMap: CoMap<GroupContent, JsonObject | null>,
|
|
80
|
-
node: LocalNode
|
|
81
|
-
) {
|
|
82
|
-
this.underlyingMap = underlyingMap;
|
|
83
|
-
this.node = node;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Returns the `CoID` of the `Group`.
|
|
88
|
-
*
|
|
89
|
-
* @category 4. Underlying CoMap
|
|
90
|
-
*/
|
|
91
|
-
get id(): CoID<CoMap<GroupContent, JsonObject | null>> {
|
|
92
|
-
return this.underlyingMap.id;
|
|
93
|
-
}
|
|
94
|
-
|
|
76
|
+
export class Group<
|
|
77
|
+
P extends Profile = Profile,
|
|
78
|
+
R extends CoMap = CoMap,
|
|
79
|
+
Meta extends JsonObject | null = JsonObject | null
|
|
80
|
+
> extends CoMap<GroupShape<P, R>, Meta> {
|
|
95
81
|
/**
|
|
96
82
|
* Returns the current role of a given account.
|
|
97
83
|
*
|
|
@@ -103,7 +89,7 @@ export class Group {
|
|
|
103
89
|
|
|
104
90
|
/** @internal */
|
|
105
91
|
roleOfInternal(accountID: AccountID | AgentID): Role | undefined {
|
|
106
|
-
return this.
|
|
92
|
+
return this.get(accountID);
|
|
107
93
|
}
|
|
108
94
|
|
|
109
95
|
/**
|
|
@@ -112,7 +98,7 @@ export class Group {
|
|
|
112
98
|
* @category 1. Role reading
|
|
113
99
|
*/
|
|
114
100
|
myRole(): Role | undefined {
|
|
115
|
-
return this.roleOfInternal(this.node.account.id);
|
|
101
|
+
return this.roleOfInternal(this.core.node.account.id);
|
|
116
102
|
}
|
|
117
103
|
|
|
118
104
|
/**
|
|
@@ -121,64 +107,81 @@ export class Group {
|
|
|
121
107
|
*
|
|
122
108
|
* @category 2. Role changing
|
|
123
109
|
*/
|
|
124
|
-
addMember(accountID: AccountID, role: Role) {
|
|
125
|
-
this.addMemberInternal(accountID, role);
|
|
110
|
+
addMember(accountID: AccountID | Everyone, role: Role): this {
|
|
111
|
+
return this.addMemberInternal(accountID, role);
|
|
126
112
|
}
|
|
127
113
|
|
|
128
114
|
/** @internal */
|
|
129
|
-
addMemberInternal(
|
|
130
|
-
|
|
131
|
-
|
|
115
|
+
addMemberInternal(
|
|
116
|
+
accountID: AccountID | AgentID | Everyone,
|
|
117
|
+
role: Role
|
|
118
|
+
): this {
|
|
119
|
+
return this.mutate((mutable) => {
|
|
120
|
+
const currentReadKey = this.core.getCurrentReadKey();
|
|
132
121
|
|
|
133
122
|
if (!currentReadKey.secret) {
|
|
134
123
|
throw new Error("Can't add member without read key secret");
|
|
135
124
|
}
|
|
136
125
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
126
|
+
if (accountID === EVERYONE) {
|
|
127
|
+
if (!(role === "reader" || role === "writer")) {
|
|
128
|
+
throw new Error(
|
|
129
|
+
"Can't make everyone something other than reader or writer"
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
mutable.set(accountID, role, "trusting");
|
|
141
133
|
|
|
142
|
-
|
|
134
|
+
if (mutable.get(accountID) !== role) {
|
|
135
|
+
throw new Error("Failed to set role");
|
|
136
|
+
}
|
|
143
137
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
138
|
+
mutable.set(
|
|
139
|
+
`${currentReadKey.id}_for_${EVERYONE}`,
|
|
140
|
+
currentReadKey.secret,
|
|
141
|
+
"trusting"
|
|
142
|
+
);
|
|
143
|
+
} else {
|
|
144
|
+
const agent = this.core.node.resolveAccountAgent(
|
|
145
|
+
accountID,
|
|
146
|
+
"Expected to know agent to add them to group"
|
|
147
|
+
);
|
|
148
|
+
mutable.set(accountID, role, "trusting");
|
|
147
149
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
150
|
+
if (mutable.get(accountID) !== role) {
|
|
151
|
+
throw new Error("Failed to set role");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
mutable.set(
|
|
155
|
+
`${currentReadKey.id}_for_${accountID}`,
|
|
156
|
+
seal({
|
|
157
|
+
message: currentReadKey.secret,
|
|
158
|
+
from: this.core.node.account.currentSealerSecret(),
|
|
159
|
+
to: getAgentSealerID(agent),
|
|
160
|
+
nOnceMaterial: {
|
|
161
|
+
in: this.id,
|
|
162
|
+
tx: this.core.nextTransactionID(),
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
"trusting"
|
|
166
|
+
);
|
|
167
|
+
}
|
|
161
168
|
});
|
|
162
169
|
}
|
|
163
170
|
|
|
164
171
|
/** @internal */
|
|
165
|
-
rotateReadKey() {
|
|
166
|
-
const currentlyPermittedReaders = this.
|
|
167
|
-
.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
} else {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
}) as (AccountID | AgentID)[];
|
|
172
|
+
rotateReadKey(): this {
|
|
173
|
+
const currentlyPermittedReaders = this.keys().filter((key) => {
|
|
174
|
+
if (key.startsWith("co_") || isAgentID(key)) {
|
|
175
|
+
const role = this.get(key);
|
|
176
|
+
return (
|
|
177
|
+
role === "admin" || role === "writer" || role === "reader"
|
|
178
|
+
);
|
|
179
|
+
} else {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}) as (AccountID | AgentID)[];
|
|
180
183
|
|
|
181
|
-
const maybeCurrentReadKey = this.
|
|
184
|
+
const maybeCurrentReadKey = this.core.getCurrentReadKey();
|
|
182
185
|
|
|
183
186
|
if (!maybeCurrentReadKey.secret) {
|
|
184
187
|
throw new Error(
|
|
@@ -193,29 +196,29 @@ export class Group {
|
|
|
193
196
|
|
|
194
197
|
const newReadKey = newRandomKeySecret();
|
|
195
198
|
|
|
196
|
-
|
|
199
|
+
return this.mutate((mutable) => {
|
|
197
200
|
for (const readerID of currentlyPermittedReaders) {
|
|
198
|
-
const reader = this.node.resolveAccountAgent(
|
|
201
|
+
const reader = this.core.node.resolveAccountAgent(
|
|
199
202
|
readerID,
|
|
200
203
|
"Expected to know currently permitted reader"
|
|
201
204
|
);
|
|
202
205
|
|
|
203
|
-
|
|
206
|
+
mutable.set(
|
|
204
207
|
`${newReadKey.id}_for_${readerID}`,
|
|
205
208
|
seal({
|
|
206
209
|
message: newReadKey.secret,
|
|
207
|
-
from: this.
|
|
210
|
+
from: this.core.node.account.currentSealerSecret(),
|
|
208
211
|
to: getAgentSealerID(reader),
|
|
209
212
|
nOnceMaterial: {
|
|
210
|
-
in: this.
|
|
211
|
-
tx: this.
|
|
213
|
+
in: this.id,
|
|
214
|
+
tx: this.core.nextTransactionID(),
|
|
212
215
|
},
|
|
213
216
|
}),
|
|
214
217
|
"trusting"
|
|
215
218
|
);
|
|
216
219
|
}
|
|
217
220
|
|
|
218
|
-
|
|
221
|
+
mutable.set(
|
|
219
222
|
`${currentReadKey.id}_for_${newReadKey.id}`,
|
|
220
223
|
encryptKeySecret({
|
|
221
224
|
encrypting: newReadKey,
|
|
@@ -224,7 +227,7 @@ export class Group {
|
|
|
224
227
|
"trusting"
|
|
225
228
|
);
|
|
226
229
|
|
|
227
|
-
|
|
230
|
+
mutable.set("readKey", newReadKey.id, "trusting");
|
|
228
231
|
});
|
|
229
232
|
}
|
|
230
233
|
|
|
@@ -235,17 +238,17 @@ export class Group {
|
|
|
235
238
|
*
|
|
236
239
|
* @category 2. Role changing
|
|
237
240
|
*/
|
|
238
|
-
removeMember(accountID: AccountID) {
|
|
239
|
-
this.removeMemberInternal(accountID);
|
|
241
|
+
removeMember(accountID: AccountID): this {
|
|
242
|
+
return this.removeMemberInternal(accountID);
|
|
240
243
|
}
|
|
241
244
|
|
|
242
245
|
/** @internal */
|
|
243
|
-
removeMemberInternal(accountID: AccountID | AgentID) {
|
|
244
|
-
|
|
246
|
+
removeMemberInternal(accountID: AccountID | AgentID): this {
|
|
247
|
+
const afterRevoke = this.mutate((map) => {
|
|
245
248
|
map.set(accountID, "revoked", "trusting");
|
|
246
249
|
});
|
|
247
250
|
|
|
248
|
-
|
|
251
|
+
return afterRevoke.rotateReadKey();
|
|
249
252
|
}
|
|
250
253
|
|
|
251
254
|
/**
|
|
@@ -272,21 +275,17 @@ export class Group {
|
|
|
272
275
|
*
|
|
273
276
|
* @category 3. Value creation
|
|
274
277
|
*/
|
|
275
|
-
createMap<M extends
|
|
276
|
-
init?:
|
|
277
|
-
[K in keyof M["_shape"]]: M["_shape"][K] extends AnyCoValue
|
|
278
|
-
? M["_shape"][K] | CoID<M["_shape"][K]>
|
|
279
|
-
: M["_shape"][K];
|
|
280
|
-
},
|
|
278
|
+
createMap<M extends CoMap>(
|
|
279
|
+
init?: M["_shape"],
|
|
281
280
|
meta?: M["meta"],
|
|
282
|
-
initPrivacy: "trusting" | "private" = "
|
|
281
|
+
initPrivacy: "trusting" | "private" = "private"
|
|
283
282
|
): M {
|
|
284
|
-
let map = this.node
|
|
283
|
+
let map = this.core.node
|
|
285
284
|
.createCoValue({
|
|
286
285
|
type: "comap",
|
|
287
286
|
ruleset: {
|
|
288
287
|
type: "ownedByGroup",
|
|
289
|
-
group: this.
|
|
288
|
+
group: this.id,
|
|
290
289
|
},
|
|
291
290
|
meta: meta || null,
|
|
292
291
|
...createdNowUnique(),
|
|
@@ -308,19 +307,17 @@ export class Group {
|
|
|
308
307
|
*
|
|
309
308
|
* @category 3. Value creation
|
|
310
309
|
*/
|
|
311
|
-
createList<L extends
|
|
312
|
-
init?:
|
|
313
|
-
? CoID<L["_item"]> | L["_item"]
|
|
314
|
-
: L["_item"])[],
|
|
310
|
+
createList<L extends CoList>(
|
|
311
|
+
init?: L["_item"][],
|
|
315
312
|
meta?: L["meta"],
|
|
316
|
-
initPrivacy: "trusting" | "private" = "
|
|
313
|
+
initPrivacy: "trusting" | "private" = "private"
|
|
317
314
|
): L {
|
|
318
|
-
let list = this.node
|
|
315
|
+
let list = this.core.node
|
|
319
316
|
.createCoValue({
|
|
320
317
|
type: "colist",
|
|
321
318
|
ruleset: {
|
|
322
319
|
type: "ownedByGroup",
|
|
323
|
-
group: this.
|
|
320
|
+
group: this.id,
|
|
324
321
|
},
|
|
325
322
|
meta: meta || null,
|
|
326
323
|
...createdNowUnique(),
|
|
@@ -337,15 +334,13 @@ export class Group {
|
|
|
337
334
|
}
|
|
338
335
|
|
|
339
336
|
/** @category 3. Value creation */
|
|
340
|
-
createStream<C extends CoStream
|
|
341
|
-
|
|
342
|
-
): C {
|
|
343
|
-
return this.node
|
|
337
|
+
createStream<C extends CoStream>(meta?: C["meta"]): C {
|
|
338
|
+
return this.core.node
|
|
344
339
|
.createCoValue({
|
|
345
340
|
type: "costream",
|
|
346
341
|
ruleset: {
|
|
347
342
|
type: "ownedByGroup",
|
|
348
|
-
group: this.
|
|
343
|
+
group: this.id,
|
|
349
344
|
},
|
|
350
345
|
meta: meta || null,
|
|
351
346
|
...createdNowUnique(),
|
|
@@ -354,36 +349,21 @@ export class Group {
|
|
|
354
349
|
}
|
|
355
350
|
|
|
356
351
|
/** @category 3. Value creation */
|
|
357
|
-
createBinaryStream<C extends BinaryCoStream
|
|
352
|
+
createBinaryStream<C extends BinaryCoStream>(
|
|
358
353
|
meta: C["meta"] = { type: "binary" }
|
|
359
354
|
): C {
|
|
360
|
-
return this.node
|
|
355
|
+
return this.core.node
|
|
361
356
|
.createCoValue({
|
|
362
357
|
type: "costream",
|
|
363
358
|
ruleset: {
|
|
364
359
|
type: "ownedByGroup",
|
|
365
|
-
group: this.
|
|
360
|
+
group: this.id,
|
|
366
361
|
},
|
|
367
362
|
meta: meta,
|
|
368
363
|
...createdNowUnique(),
|
|
369
364
|
})
|
|
370
365
|
.getCurrentContent() as C;
|
|
371
366
|
}
|
|
372
|
-
|
|
373
|
-
/** @internal */
|
|
374
|
-
testWithDifferentAccount(
|
|
375
|
-
account: GeneralizedControlledAccount,
|
|
376
|
-
sessionId: SessionID
|
|
377
|
-
): Group {
|
|
378
|
-
return new Group(
|
|
379
|
-
expectGroupContent(
|
|
380
|
-
this.underlyingMap.core
|
|
381
|
-
.testWithDifferentAccount(account, sessionId)
|
|
382
|
-
.getCurrentContent()
|
|
383
|
-
),
|
|
384
|
-
this.node
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
367
|
}
|
|
388
368
|
|
|
389
369
|
export type InviteSecret = `inviteSecret_z${string}`;
|
package/src/ids.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
CoValueCore,
|
|
3
3
|
newRandomSessionID,
|
|
4
4
|
MAX_RECOMMENDED_TX_SIZE,
|
|
5
|
+
accountOrAgentIDfromSessionID
|
|
5
6
|
} from "./coValueCore.js";
|
|
6
7
|
import { LocalNode } from "./localNode.js";
|
|
7
8
|
import type { CoValue } from "./coValue.js";
|
|
@@ -25,18 +26,24 @@ import {
|
|
|
25
26
|
cryptoReady,
|
|
26
27
|
} from "./crypto.js";
|
|
27
28
|
import { connectedPeers } from "./streamUtils.js";
|
|
28
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
AnonymousControlledAccount,
|
|
31
|
+
ControlledAccount,
|
|
32
|
+
} from "./coValues/account.js";
|
|
29
33
|
import { rawCoIDtoBytes, rawCoIDfromBytes } from "./ids.js";
|
|
30
|
-
import { Group,
|
|
34
|
+
import { Group, expectGroup, EVERYONE } from "./coValues/group.js";
|
|
31
35
|
import { base64URLtoBytes, bytesToBase64url } from "./base64url.js";
|
|
32
36
|
import { parseJSON } from "./jsonStringify.js";
|
|
37
|
+
import { Account, Profile, isAccountID } from "./coValues/account.js";
|
|
33
38
|
|
|
34
39
|
import type { SessionID, AgentID } from "./ids.js";
|
|
35
40
|
import type { CoID, AnyCoValue } from "./coValue.js";
|
|
36
|
-
import type { Queried } from "./queries.js";
|
|
41
|
+
import type { Queried, QueryExtension } from "./queries.js";
|
|
37
42
|
import type { QueriedCoStream } from "./queriedCoValues/queriedCoStream.js";
|
|
38
43
|
import type { QueriedCoList } from "./queriedCoValues/queriedCoList.js";
|
|
39
44
|
import type { QueriedCoMap } from "./queriedCoValues/queriedCoMap.js";
|
|
45
|
+
import { QueriedAccount } from "./queriedCoValues/queriedAccount.js";
|
|
46
|
+
import { QueriedGroup } from "./queriedCoValues/queriedGroup.js";
|
|
40
47
|
import type {
|
|
41
48
|
BinaryStreamInfo,
|
|
42
49
|
BinaryCoStreamMeta,
|
|
@@ -44,8 +51,8 @@ import type {
|
|
|
44
51
|
import type { JsonValue } from "./jsonValue.js";
|
|
45
52
|
import type { SyncMessage, Peer } from "./sync.js";
|
|
46
53
|
import type { AgentSecret } from "./crypto.js";
|
|
47
|
-
import type { AccountID,
|
|
48
|
-
import type { InviteSecret } from "./group.js";
|
|
54
|
+
import type { AccountID, AccountMeta, AccountMigration, ProfileMeta } from "./coValues/account.js";
|
|
55
|
+
import type { InviteSecret } from "./coValues/group.js";
|
|
49
56
|
import type * as Media from "./media.js";
|
|
50
57
|
|
|
51
58
|
type Value = JsonValue | AnyCoValue;
|
|
@@ -64,15 +71,18 @@ export const cojsonInternals = {
|
|
|
64
71
|
agentSecretFromSecretSeed,
|
|
65
72
|
secretSeedLength,
|
|
66
73
|
shortHashLength,
|
|
67
|
-
|
|
74
|
+
expectGroup,
|
|
68
75
|
base64URLtoBytes,
|
|
69
76
|
bytesToBase64url,
|
|
70
77
|
parseJSON,
|
|
78
|
+
accountOrAgentIDfromSessionID,
|
|
79
|
+
isAccountID,
|
|
71
80
|
};
|
|
72
81
|
|
|
73
82
|
export {
|
|
74
83
|
LocalNode,
|
|
75
84
|
Group,
|
|
85
|
+
EVERYONE,
|
|
76
86
|
CoMap,
|
|
77
87
|
MutableCoMap,
|
|
78
88
|
CoList,
|
|
@@ -88,9 +98,14 @@ export {
|
|
|
88
98
|
QueriedCoMap,
|
|
89
99
|
QueriedCoList,
|
|
90
100
|
QueriedCoStream,
|
|
91
|
-
|
|
101
|
+
QueriedGroup,
|
|
102
|
+
QueriedAccount,
|
|
92
103
|
Account,
|
|
104
|
+
AccountID,
|
|
105
|
+
AccountMeta,
|
|
106
|
+
AccountMigration,
|
|
93
107
|
Profile,
|
|
108
|
+
ProfileMeta,
|
|
94
109
|
SessionID,
|
|
95
110
|
Media,
|
|
96
111
|
CoValueCore,
|
|
@@ -107,6 +122,7 @@ export {
|
|
|
107
122
|
AgentSecret,
|
|
108
123
|
InviteSecret,
|
|
109
124
|
SyncMessage,
|
|
125
|
+
QueryExtension,
|
|
110
126
|
};
|
|
111
127
|
|
|
112
128
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
@@ -120,9 +136,8 @@ export namespace CojsonInternalTypes {
|
|
|
120
136
|
export type Transaction = import("./coValueCore.js").Transaction;
|
|
121
137
|
export type Signature = import("./crypto.js").Signature;
|
|
122
138
|
export type RawCoID = import("./ids.js").RawCoID;
|
|
123
|
-
export type
|
|
124
|
-
export type
|
|
125
|
-
export type ProfileMeta = import("./account.js").ProfileMeta;
|
|
139
|
+
export type ProfileShape = import("./coValues/account.js").ProfileShape;
|
|
140
|
+
export type ProfileMeta = import("./coValues/account.js").ProfileMeta;
|
|
126
141
|
export type SealerSecret = import("./crypto.js").SealerSecret;
|
|
127
142
|
export type SignerSecret = import("./crypto.js").SignerSecret;
|
|
128
143
|
}
|