cojson 0.4.1 → 0.4.6
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.js +0 -9
- package/dist/coValue.js.map +1 -1
- package/dist/coValueCore.js +4 -34
- package/dist/coValueCore.js.map +1 -1
- package/dist/coValues/coList.js +2 -2
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +2 -2
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +2 -2
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/group.js.map +1 -1
- package/dist/coreToCoValue.js +37 -0
- package/dist/coreToCoValue.js.map +1 -0
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/isCoValue.js +10 -0
- package/dist/isCoValue.js.map +1 -0
- package/dist/localNode.js +1 -14
- package/dist/localNode.js.map +1 -1
- package/package.json +4 -4
- package/src/coValue.ts +11 -19
- package/src/coValueCore.ts +2 -25
- package/src/coValues/coList.ts +3 -2
- package/src/coValues/coMap.ts +3 -2
- package/src/coValues/coStream.ts +3 -4
- package/src/coValues/group.ts +4 -4
- package/src/coreToCoValue.ts +37 -0
- package/src/index.ts +16 -16
- package/src/isCoValue.ts +16 -0
- package/src/localNode.ts +6 -47
- package/src/tests/coValue.test.ts +5 -5
- package/src/tests/group.test.ts +1 -1
- package/dist/base64url.d.ts +0 -2
- package/dist/coValue.d.ts +0 -38
- package/dist/coValueCore.d.ts +0 -103
- package/dist/coValues/account.d.ts +0 -62
- package/dist/coValues/coList.d.ts +0 -179
- package/dist/coValues/coMap.d.ts +0 -149
- package/dist/coValues/coStream.d.ts +0 -123
- package/dist/coValues/group.d.ts +0 -111
- package/dist/crypto.d.ts +0 -120
- package/dist/ids.d.ts +0 -11
- package/dist/index.d.ts +0 -67
- package/dist/jsonStringify.d.ts +0 -6
- package/dist/jsonValue.d.ts +0 -7
- package/dist/localNode.d.ts +0 -101
- package/dist/media.d.ts +0 -7
- package/dist/permissions.d.ts +0 -20
- package/dist/queriedCoValues/queriedAccount.d.ts +0 -13
- package/dist/queriedCoValues/queriedAccount.js +0 -24
- package/dist/queriedCoValues/queriedAccount.js.map +0 -1
- package/dist/queriedCoValues/queriedCoList.d.ts +0 -66
- package/dist/queriedCoValues/queriedCoList.js +0 -116
- package/dist/queriedCoValues/queriedCoList.js.map +0 -1
- package/dist/queriedCoValues/queriedCoMap.d.ts +0 -40
- package/dist/queriedCoValues/queriedCoMap.js +0 -82
- package/dist/queriedCoValues/queriedCoMap.js.map +0 -1
- package/dist/queriedCoValues/queriedCoStream.d.ts +0 -36
- package/dist/queriedCoValues/queriedCoStream.js +0 -97
- package/dist/queriedCoValues/queriedCoStream.js.map +0 -1
- package/dist/queriedCoValues/queriedGroup.d.ts +0 -29
- package/dist/queriedCoValues/queriedGroup.js +0 -54
- package/dist/queriedCoValues/queriedGroup.js.map +0 -1
- package/dist/queries.d.ts +0 -62
- package/dist/queries.js +0 -142
- package/dist/queries.js.map +0 -1
- package/dist/streamUtils.d.ts +0 -8
- package/dist/sync.d.ts +0 -80
- package/dist/tests/testUtils.d.ts +0 -37
- package/src/queriedCoValues/queriedAccount.ts +0 -40
- package/src/queriedCoValues/queriedCoList.ts +0 -240
- package/src/queriedCoValues/queriedCoMap.ts +0 -168
- package/src/queriedCoValues/queriedCoStream.ts +0 -151
- package/src/queriedCoValues/queriedGroup.ts +0 -90
- package/src/queries.ts +0 -263
- package/src/tests/queries.test.ts +0 -398
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { CoValueCore, CoValueHeader } from "../coValueCore.js";
|
|
2
|
-
import { CoID, CoValue } from "../coValue.js";
|
|
3
|
-
import { AgentSecret, SealerID, SealerSecret, SignerID, SignerSecret } from "../crypto.js";
|
|
4
|
-
import { AgentID } from "../ids.js";
|
|
5
|
-
import { CoMap } from "./coMap.js";
|
|
6
|
-
import { Group, InviteSecret } from "./group.js";
|
|
7
|
-
export declare function accountHeaderForInitialAgentSecret(agentSecret: AgentSecret): CoValueHeader;
|
|
8
|
-
export declare class Account<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta> extends Group<P, R, Meta> {
|
|
9
|
-
getCurrentAgentID(): AgentID;
|
|
10
|
-
}
|
|
11
|
-
export interface GeneralizedControlledAccount {
|
|
12
|
-
id: AccountID | AgentID;
|
|
13
|
-
agentSecret: AgentSecret;
|
|
14
|
-
currentAgentID: () => AgentID;
|
|
15
|
-
currentSignerID: () => SignerID;
|
|
16
|
-
currentSignerSecret: () => SignerSecret;
|
|
17
|
-
currentSealerID: () => SealerID;
|
|
18
|
-
currentSealerSecret: () => SealerSecret;
|
|
19
|
-
}
|
|
20
|
-
/** @hidden */
|
|
21
|
-
export declare class ControlledAccount<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta> extends Account<P, R, Meta> implements GeneralizedControlledAccount {
|
|
22
|
-
agentSecret: AgentSecret;
|
|
23
|
-
constructor(core: CoValueCore, agentSecret: AgentSecret);
|
|
24
|
-
/**
|
|
25
|
-
* Creates a new group (with the current account as the group's first admin).
|
|
26
|
-
* @category 1. High-level
|
|
27
|
-
*/
|
|
28
|
-
createGroup(): Group<Profile<ProfileShape, ProfileMeta>, CoMap<{
|
|
29
|
-
[key: string]: import("../jsonValue.js").JsonValue | undefined;
|
|
30
|
-
}, import("../jsonValue.js").JsonObject | null>, import("../jsonValue.js").JsonObject | null>;
|
|
31
|
-
acceptInvite<T extends CoValue>(groupOrOwnedValueID: CoID<T>, inviteSecret: InviteSecret): Promise<void>;
|
|
32
|
-
currentAgentID(): AgentID;
|
|
33
|
-
currentSignerID(): SignerID;
|
|
34
|
-
currentSignerSecret(): SignerSecret;
|
|
35
|
-
currentSealerID(): SealerID;
|
|
36
|
-
currentSealerSecret(): SealerSecret;
|
|
37
|
-
}
|
|
38
|
-
/** @hidden */
|
|
39
|
-
export declare class AnonymousControlledAccount implements GeneralizedControlledAccount {
|
|
40
|
-
agentSecret: AgentSecret;
|
|
41
|
-
constructor(agentSecret: AgentSecret);
|
|
42
|
-
get id(): AgentID;
|
|
43
|
-
currentAgentID(): AgentID;
|
|
44
|
-
currentSignerID(): SignerID;
|
|
45
|
-
currentSignerSecret(): SignerSecret;
|
|
46
|
-
currentSealerID(): SealerID;
|
|
47
|
-
currentSealerSecret(): SealerSecret;
|
|
48
|
-
}
|
|
49
|
-
export type AccountMeta = {
|
|
50
|
-
type: "account";
|
|
51
|
-
};
|
|
52
|
-
export type AccountID = CoID<Account>;
|
|
53
|
-
export declare function isAccountID(id: AccountID | AgentID): id is AccountID;
|
|
54
|
-
export type ProfileShape = {
|
|
55
|
-
name: string;
|
|
56
|
-
};
|
|
57
|
-
export type ProfileMeta = {
|
|
58
|
-
type: "profile";
|
|
59
|
-
};
|
|
60
|
-
export declare class Profile<Shape extends ProfileShape = ProfileShape, Meta extends ProfileMeta = ProfileMeta> extends CoMap<Shape, Meta> {
|
|
61
|
-
}
|
|
62
|
-
export type AccountMigration<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends AccountMeta = AccountMeta> = (account: ControlledAccount<P, R, Meta>, profile: P) => void;
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { JsonObject, JsonValue } from "../jsonValue.js";
|
|
2
|
-
import { CoID, CoValue } from "../coValue.js";
|
|
3
|
-
import { CoValueCore } from "../coValueCore.js";
|
|
4
|
-
import { AgentID, SessionID, TransactionID } from "../ids.js";
|
|
5
|
-
import { AccountID } from "./account.js";
|
|
6
|
-
import { Group } from "./group.js";
|
|
7
|
-
type OpID = TransactionID & {
|
|
8
|
-
changeIdx: number;
|
|
9
|
-
};
|
|
10
|
-
type InsertionOpPayload<T extends JsonValue> = {
|
|
11
|
-
op: "pre";
|
|
12
|
-
value: T;
|
|
13
|
-
before: OpID | "end";
|
|
14
|
-
} | {
|
|
15
|
-
op: "app";
|
|
16
|
-
value: T;
|
|
17
|
-
after: OpID | "start";
|
|
18
|
-
};
|
|
19
|
-
type DeletionOpPayload = {
|
|
20
|
-
op: "del";
|
|
21
|
-
insertion: OpID;
|
|
22
|
-
};
|
|
23
|
-
export type ListOpPayload<T extends JsonValue> = InsertionOpPayload<T> | DeletionOpPayload;
|
|
24
|
-
type InsertionEntry<T extends JsonValue> = {
|
|
25
|
-
madeAt: number;
|
|
26
|
-
predecessors: OpID[];
|
|
27
|
-
successors: OpID[];
|
|
28
|
-
} & InsertionOpPayload<T>;
|
|
29
|
-
type DeletionEntry = {
|
|
30
|
-
madeAt: number;
|
|
31
|
-
deletionID: OpID;
|
|
32
|
-
} & DeletionOpPayload;
|
|
33
|
-
export declare class CoListView<Item extends JsonValue = JsonValue, Meta extends JsonObject | null = null> implements CoValue {
|
|
34
|
-
/** @category 6. Meta */
|
|
35
|
-
id: CoID<this>;
|
|
36
|
-
/** @category 6. Meta */
|
|
37
|
-
type: "colist";
|
|
38
|
-
/** @category 6. Meta */
|
|
39
|
-
core: CoValueCore;
|
|
40
|
-
/** @internal */
|
|
41
|
-
afterStart: OpID[];
|
|
42
|
-
/** @internal */
|
|
43
|
-
beforeEnd: OpID[];
|
|
44
|
-
/** @internal */
|
|
45
|
-
insertions: {
|
|
46
|
-
[sessionID: SessionID]: {
|
|
47
|
-
[txIdx: number]: {
|
|
48
|
-
[changeIdx: number]: InsertionEntry<Item>;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
/** @internal */
|
|
53
|
-
deletionsByInsertion: {
|
|
54
|
-
[deletedSessionID: SessionID]: {
|
|
55
|
-
[deletedTxIdx: number]: {
|
|
56
|
-
[deletedChangeIdx: number]: DeletionEntry[];
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
/** @category 6. Meta */
|
|
61
|
-
readonly _item: Item;
|
|
62
|
-
/** @internal */
|
|
63
|
-
constructor(core: CoValueCore);
|
|
64
|
-
/** @category 6. Meta */
|
|
65
|
-
get meta(): Meta;
|
|
66
|
-
/** @category 6. Meta */
|
|
67
|
-
get group(): Group;
|
|
68
|
-
/**
|
|
69
|
-
* Not yet implemented
|
|
70
|
-
*
|
|
71
|
-
* @category 4. Time travel
|
|
72
|
-
*/
|
|
73
|
-
atTime(_time: number): this;
|
|
74
|
-
/**
|
|
75
|
-
* Get the item currently at `idx`.
|
|
76
|
-
*
|
|
77
|
-
* @category 1. Reading
|
|
78
|
-
*/
|
|
79
|
-
get(idx: number): Item | undefined;
|
|
80
|
-
/**
|
|
81
|
-
* Returns the current items in the CoList as an array.
|
|
82
|
-
*
|
|
83
|
-
* @category 1. Reading
|
|
84
|
-
**/
|
|
85
|
-
asArray(): Item[];
|
|
86
|
-
/** @internal */
|
|
87
|
-
entries(): {
|
|
88
|
-
value: Item;
|
|
89
|
-
madeAt: number;
|
|
90
|
-
opID: OpID;
|
|
91
|
-
}[];
|
|
92
|
-
/** @internal */
|
|
93
|
-
private fillArrayFromOpID;
|
|
94
|
-
/**
|
|
95
|
-
* Returns the current items in the CoList as an array. (alias of `asArray`)
|
|
96
|
-
*
|
|
97
|
-
* @category 1. Reading
|
|
98
|
-
*/
|
|
99
|
-
toJSON(): Item[];
|
|
100
|
-
/** @category 5. Edit history */
|
|
101
|
-
editAt(idx: number): {
|
|
102
|
-
by: AccountID | AgentID;
|
|
103
|
-
tx: TransactionID;
|
|
104
|
-
at: Date;
|
|
105
|
-
value: Item;
|
|
106
|
-
} | undefined;
|
|
107
|
-
/** @category 5. Edit history */
|
|
108
|
-
deletionEdits(): {
|
|
109
|
-
by: AccountID | AgentID;
|
|
110
|
-
tx: TransactionID;
|
|
111
|
-
at: Date;
|
|
112
|
-
}[];
|
|
113
|
-
/** @category 3. Subscription */
|
|
114
|
-
subscribe(listener: (coList: this) => void): () => void;
|
|
115
|
-
}
|
|
116
|
-
export declare class CoList<Item extends JsonValue = JsonValue, Meta extends JsonObject | null = JsonObject | null> extends CoListView<Item, Meta> implements CoValue {
|
|
117
|
-
/** Returns a new version of this CoList with `item` appended after the item currently at index `after`.
|
|
118
|
-
*
|
|
119
|
-
* If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
|
|
120
|
-
*
|
|
121
|
-
* If `privacy` is `"trusting"`, `item` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
|
|
122
|
-
*
|
|
123
|
-
* @category 2. Editing
|
|
124
|
-
**/
|
|
125
|
-
append(item: Item, after?: number, privacy?: "private" | "trusting"): this;
|
|
126
|
-
/**
|
|
127
|
-
* Returns a new version of this CoList with `item` prepended before the item currently at index `before`.
|
|
128
|
-
*
|
|
129
|
-
* If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
|
|
130
|
-
*
|
|
131
|
-
* If `privacy` is `"trusting"`, `item` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
|
|
132
|
-
*
|
|
133
|
-
* @category 2. Editing
|
|
134
|
-
*/
|
|
135
|
-
prepend(item: Item, before?: number, privacy?: "private" | "trusting"): this;
|
|
136
|
-
/** Returns a new version of this CoList with the item at index `at` deleted from the list.
|
|
137
|
-
*
|
|
138
|
-
* If `privacy` is `"private"` **(default)**, the fact of this deletion is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
|
|
139
|
-
*
|
|
140
|
-
* If `privacy` is `"trusting"`, the fact of this deletion is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
|
|
141
|
-
*
|
|
142
|
-
* @category 2. Editing
|
|
143
|
-
**/
|
|
144
|
-
delete(at: number, privacy?: "private" | "trusting"): this;
|
|
145
|
-
/** @category 2. Editing */
|
|
146
|
-
mutate(mutator: (mutable: MutableCoList<Item, Meta>) => void): this;
|
|
147
|
-
/** @deprecated Use `mutate` instead. */
|
|
148
|
-
edit(mutator: (mutable: MutableCoList<Item, Meta>) => void): this;
|
|
149
|
-
}
|
|
150
|
-
export declare class MutableCoList<Item extends JsonValue = JsonValue, Meta extends JsonObject | null = JsonObject | null> extends CoListView<Item, Meta> implements CoValue {
|
|
151
|
-
/** Appends `item` after the item currently at index `after`.
|
|
152
|
-
*
|
|
153
|
-
* If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
|
|
154
|
-
*
|
|
155
|
-
* If `privacy` is `"trusting"`, `item` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
|
|
156
|
-
*
|
|
157
|
-
* @category 2. Mutating
|
|
158
|
-
**/
|
|
159
|
-
append(item: Item, after?: number, privacy?: "private" | "trusting"): void;
|
|
160
|
-
/** Prepends `item` before the item currently at index `before`.
|
|
161
|
-
*
|
|
162
|
-
* If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
|
|
163
|
-
*
|
|
164
|
-
* If `privacy` is `"trusting"`, `item` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
|
|
165
|
-
*
|
|
166
|
-
* * @category 2. Mutating
|
|
167
|
-
**/
|
|
168
|
-
prepend(item: Item, before?: number, privacy?: "private" | "trusting"): void;
|
|
169
|
-
/** Deletes the item at index `at` from the list.
|
|
170
|
-
*
|
|
171
|
-
* If `privacy` is `"private"` **(default)**, the fact of this deletion is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
|
|
172
|
-
*
|
|
173
|
-
* If `privacy` is `"trusting"`, the fact of this deletion is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
|
|
174
|
-
*
|
|
175
|
-
* * @category 2. Mutating
|
|
176
|
-
**/
|
|
177
|
-
delete(at: number, privacy?: "private" | "trusting"): void;
|
|
178
|
-
}
|
|
179
|
-
export {};
|
package/dist/coValues/coMap.d.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { JsonObject, JsonValue } from "../jsonValue.js";
|
|
2
|
-
import { AgentID, TransactionID } from "../ids.js";
|
|
3
|
-
import { CoID, CoValue } from "../coValue.js";
|
|
4
|
-
import { CoValueCore } from "../coValueCore.js";
|
|
5
|
-
import { AccountID } from "./account.js";
|
|
6
|
-
import { Group } from "./group.js";
|
|
7
|
-
type MapOp<K extends string, V extends JsonValue | undefined> = {
|
|
8
|
-
txID: TransactionID;
|
|
9
|
-
madeAt: number;
|
|
10
|
-
changeIdx: number;
|
|
11
|
-
} & MapOpPayload<K, V>;
|
|
12
|
-
export type MapOpPayload<K extends string, V extends JsonValue | undefined> = {
|
|
13
|
-
op: "set";
|
|
14
|
-
key: K;
|
|
15
|
-
value: V;
|
|
16
|
-
} | {
|
|
17
|
-
op: "del";
|
|
18
|
-
key: K;
|
|
19
|
-
};
|
|
20
|
-
export declare class CoMapView<Shape extends {
|
|
21
|
-
[key: string]: JsonValue | undefined;
|
|
22
|
-
} = {
|
|
23
|
-
[key: string]: JsonValue | undefined;
|
|
24
|
-
}, Meta extends JsonObject | null = JsonObject | null> implements CoValue {
|
|
25
|
-
/** @category 6. Meta */
|
|
26
|
-
id: CoID<this>;
|
|
27
|
-
/** @category 6. Meta */
|
|
28
|
-
type: "comap";
|
|
29
|
-
/** @category 6. Meta */
|
|
30
|
-
core: CoValueCore;
|
|
31
|
-
/** @internal */
|
|
32
|
-
ops: {
|
|
33
|
-
[Key in keyof Shape & string]?: MapOp<Key, Shape[Key]>[];
|
|
34
|
-
};
|
|
35
|
-
/** @internal */
|
|
36
|
-
atTimeFilter?: number;
|
|
37
|
-
/** @category 6. Meta */
|
|
38
|
-
readonly _shape: Shape;
|
|
39
|
-
/** @internal */
|
|
40
|
-
constructor(core: CoValueCore, options?: {
|
|
41
|
-
ignorePrivateTransactions: true;
|
|
42
|
-
});
|
|
43
|
-
/** @category 6. Meta */
|
|
44
|
-
get meta(): Meta;
|
|
45
|
-
/** @category 6. Meta */
|
|
46
|
-
get group(): Group;
|
|
47
|
-
/** @category 4. Time travel */
|
|
48
|
-
atTime(time: number): this;
|
|
49
|
-
/** @internal */
|
|
50
|
-
timeFilteredOps<K extends keyof Shape & string>(key: K): MapOp<K, Shape[K]>[] | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Get all keys currently in the map.
|
|
53
|
-
*
|
|
54
|
-
* @category 1. Reading */
|
|
55
|
-
keys<K extends (keyof Shape & string) = (keyof Shape & string)>(): K[];
|
|
56
|
-
/**
|
|
57
|
-
* Returns the current value for the given key.
|
|
58
|
-
*
|
|
59
|
-
* @category 1. Reading
|
|
60
|
-
**/
|
|
61
|
-
get<K extends keyof Shape & string>(key: K): Shape[K] | undefined;
|
|
62
|
-
/** @category 1. Reading */
|
|
63
|
-
asObject(): {
|
|
64
|
-
[K in keyof Shape & string]: Shape[K];
|
|
65
|
-
};
|
|
66
|
-
/** @category 1. Reading */
|
|
67
|
-
toJSON(): {
|
|
68
|
-
[K in keyof Shape & string]: Shape[K];
|
|
69
|
-
};
|
|
70
|
-
/** @category 5. Edit history */
|
|
71
|
-
nthEditAt<K extends keyof Shape & string>(key: K, n: number): {
|
|
72
|
-
by: AccountID | AgentID;
|
|
73
|
-
tx: TransactionID;
|
|
74
|
-
at: Date;
|
|
75
|
-
value?: Shape[K];
|
|
76
|
-
} | undefined;
|
|
77
|
-
/** @category 5. Edit history */
|
|
78
|
-
lastEditAt<K extends keyof Shape & string>(key: K): {
|
|
79
|
-
by: AccountID | AgentID;
|
|
80
|
-
tx: TransactionID;
|
|
81
|
-
at: Date;
|
|
82
|
-
value?: Shape[K];
|
|
83
|
-
} | undefined;
|
|
84
|
-
/** @category 5. Edit history */
|
|
85
|
-
editsAt<K extends keyof Shape & string>(key: K): Generator<{
|
|
86
|
-
by: AccountID | `sealer_z${string}/signer_z${string}`;
|
|
87
|
-
tx: TransactionID;
|
|
88
|
-
at: Date;
|
|
89
|
-
value?: Shape[K] | undefined;
|
|
90
|
-
}, void, unknown>;
|
|
91
|
-
/** @category 3. Subscription */
|
|
92
|
-
subscribe(listener: (coMap: this) => void): () => void;
|
|
93
|
-
}
|
|
94
|
-
/** A collaborative map with precise shape `Shape` and optional static metadata `Meta` */
|
|
95
|
-
export declare class CoMap<Shape extends {
|
|
96
|
-
[key: string]: JsonValue | undefined;
|
|
97
|
-
} = {
|
|
98
|
-
[key: string]: JsonValue | undefined;
|
|
99
|
-
}, Meta extends JsonObject | null = JsonObject | null> extends CoMapView<Shape, Meta> implements CoValue {
|
|
100
|
-
/** Returns a new version of this CoMap with a new value for the given key.
|
|
101
|
-
*
|
|
102
|
-
* If `privacy` is `"private"` **(default)**, both `key` and `value` are encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
|
|
103
|
-
*
|
|
104
|
-
* If `privacy` is `"trusting"`, both `key` and `value` are stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
|
|
105
|
-
*
|
|
106
|
-
* @category 2. Editing
|
|
107
|
-
**/
|
|
108
|
-
set<K extends keyof Shape & string>(key: K, value: Shape[K], privacy?: "private" | "trusting"): this;
|
|
109
|
-
set(kv: {
|
|
110
|
-
[K in keyof Shape & string]?: Shape[K];
|
|
111
|
-
}, privacy?: "private" | "trusting"): this;
|
|
112
|
-
/** Returns a new version of this CoMap with the given key deleted (setting it to undefined).
|
|
113
|
-
*
|
|
114
|
-
* If `privacy` is `"private"` **(default)**, `key` is encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
|
|
115
|
-
*
|
|
116
|
-
* If `privacy` is `"trusting"`, `key` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
|
|
117
|
-
*
|
|
118
|
-
* @category 2. Editing
|
|
119
|
-
**/
|
|
120
|
-
delete(key: keyof Shape & string, privacy?: "private" | "trusting"): this;
|
|
121
|
-
/** @category 2. Editing */
|
|
122
|
-
mutate(mutator: (mutable: MutableCoMap<Shape, Meta>) => void): this;
|
|
123
|
-
/** @deprecated Use `mutate` instead. */
|
|
124
|
-
edit(mutator: (mutable: MutableCoMap<Shape, Meta>) => void): this;
|
|
125
|
-
}
|
|
126
|
-
export declare class MutableCoMap<Shape extends {
|
|
127
|
-
[key: string]: JsonValue | undefined;
|
|
128
|
-
} = {
|
|
129
|
-
[key: string]: JsonValue | undefined;
|
|
130
|
-
}, Meta extends JsonObject | null = JsonObject | null> extends CoMapView<Shape, Meta> implements CoValue {
|
|
131
|
-
/** Sets a new value for the given key.
|
|
132
|
-
*
|
|
133
|
-
* If `privacy` is `"private"` **(default)**, both `key` and `value` are encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
|
|
134
|
-
*
|
|
135
|
-
* If `privacy` is `"trusting"`, both `key` and `value` are stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
|
|
136
|
-
*
|
|
137
|
-
* @category 2. Mutation
|
|
138
|
-
*/
|
|
139
|
-
set<K extends keyof Shape & string>(key: K, value: Shape[K], privacy?: "private" | "trusting"): void;
|
|
140
|
-
/** Deletes the value for the given key (setting it to undefined).
|
|
141
|
-
*
|
|
142
|
-
* If `privacy` is `"private"` **(default)**, `key` is encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
|
|
143
|
-
*
|
|
144
|
-
* If `privacy` is `"trusting"`, `key` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
|
|
145
|
-
* @category 2. Mutation
|
|
146
|
-
*/
|
|
147
|
-
delete(key: keyof Shape & string, privacy?: "private" | "trusting"): void;
|
|
148
|
-
}
|
|
149
|
-
export {};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { JsonObject, JsonValue } from "../jsonValue.js";
|
|
2
|
-
import { CoValue, CoID } from "../coValue.js";
|
|
3
|
-
import { CoValueCore } from "../coValueCore.js";
|
|
4
|
-
import { Group } from "./group.js";
|
|
5
|
-
import { AgentID, SessionID, TransactionID } from "../ids.js";
|
|
6
|
-
import { AccountID } from "./account.js";
|
|
7
|
-
export type BinaryStreamInfo = {
|
|
8
|
-
mimeType: string;
|
|
9
|
-
fileName?: string;
|
|
10
|
-
totalSizeBytes?: number;
|
|
11
|
-
};
|
|
12
|
-
export type BinaryStreamStart = {
|
|
13
|
-
type: "start";
|
|
14
|
-
} & BinaryStreamInfo;
|
|
15
|
-
export type BinaryStreamChunk = {
|
|
16
|
-
type: "chunk";
|
|
17
|
-
chunk: `binary_U${string}`;
|
|
18
|
-
};
|
|
19
|
-
export type BinaryStreamEnd = {
|
|
20
|
-
type: "end";
|
|
21
|
-
};
|
|
22
|
-
export type BinaryCoStreamMeta = JsonObject & {
|
|
23
|
-
type: "binary";
|
|
24
|
-
};
|
|
25
|
-
export type BinaryStreamItem = BinaryStreamStart | BinaryStreamChunk | BinaryStreamEnd;
|
|
26
|
-
export type CoStreamItem<Item extends JsonValue> = {
|
|
27
|
-
value: Item;
|
|
28
|
-
tx: TransactionID;
|
|
29
|
-
madeAt: number;
|
|
30
|
-
};
|
|
31
|
-
export declare class CoStreamView<Item extends JsonValue = JsonValue, Meta extends JsonObject | null = JsonObject | null> implements CoValue {
|
|
32
|
-
id: CoID<this>;
|
|
33
|
-
type: "costream";
|
|
34
|
-
core: CoValueCore;
|
|
35
|
-
items: {
|
|
36
|
-
[key: SessionID]: CoStreamItem<Item>[];
|
|
37
|
-
};
|
|
38
|
-
readonly _item: Item;
|
|
39
|
-
constructor(core: CoValueCore);
|
|
40
|
-
get meta(): Meta;
|
|
41
|
-
get group(): Group;
|
|
42
|
-
/** Not yet implemented */
|
|
43
|
-
atTime(_time: number): this;
|
|
44
|
-
/** @internal */
|
|
45
|
-
protected fillFromCoValue(): void;
|
|
46
|
-
getSingleStream(): (Item)[] | undefined;
|
|
47
|
-
sessions(): SessionID[];
|
|
48
|
-
accounts(): Set<AccountID>;
|
|
49
|
-
nthItemIn(sessionID: SessionID, n: number): {
|
|
50
|
-
by: AccountID | AgentID;
|
|
51
|
-
tx: TransactionID;
|
|
52
|
-
at: Date;
|
|
53
|
-
value: Item;
|
|
54
|
-
} | undefined;
|
|
55
|
-
lastItemIn(sessionID: SessionID): {
|
|
56
|
-
by: AccountID | AgentID;
|
|
57
|
-
tx: TransactionID;
|
|
58
|
-
at: Date;
|
|
59
|
-
value: Item;
|
|
60
|
-
} | undefined;
|
|
61
|
-
itemsIn(sessionID: SessionID): Generator<{
|
|
62
|
-
by: AccountID | `sealer_z${string}/signer_z${string}`;
|
|
63
|
-
tx: TransactionID;
|
|
64
|
-
at: Date;
|
|
65
|
-
value: Item;
|
|
66
|
-
}, void, unknown>;
|
|
67
|
-
lastItemBy(account: AccountID | AgentID): {
|
|
68
|
-
by: AccountID | AgentID;
|
|
69
|
-
tx: TransactionID;
|
|
70
|
-
at: Date;
|
|
71
|
-
value: Item;
|
|
72
|
-
} | undefined;
|
|
73
|
-
itemsBy(account: AccountID | AgentID): Generator<{
|
|
74
|
-
by: AccountID | `sealer_z${string}/signer_z${string}`;
|
|
75
|
-
tx: TransactionID;
|
|
76
|
-
at: Date;
|
|
77
|
-
value: Item;
|
|
78
|
-
in: `co_z${string}_session_z${string}` | `sealer_z${string}/signer_z${string}_session_z${string}`;
|
|
79
|
-
}, void, unknown>;
|
|
80
|
-
toJSON(): {
|
|
81
|
-
[key: SessionID]: (Item)[];
|
|
82
|
-
};
|
|
83
|
-
subscribe(listener: (coStream: this) => void): () => void;
|
|
84
|
-
}
|
|
85
|
-
export declare class CoStream<Item extends JsonValue = JsonValue, Meta extends JsonObject | null = JsonObject | null> extends CoStreamView<Item, Meta> implements CoValue {
|
|
86
|
-
push(item: Item, privacy?: "private" | "trusting"): this;
|
|
87
|
-
mutate(mutator: (mutable: MutableCoStream<Item, Meta>) => void): this;
|
|
88
|
-
/** @deprecated Use `mutate` instead. */
|
|
89
|
-
edit(mutator: (mutable: MutableCoStream<Item, Meta>) => void): this;
|
|
90
|
-
}
|
|
91
|
-
export declare class MutableCoStream<Item extends JsonValue, Meta extends JsonObject | null = JsonObject | null> extends CoStreamView<Item, Meta> implements CoValue {
|
|
92
|
-
push(item: Item, privacy?: "private" | "trusting"): void;
|
|
93
|
-
}
|
|
94
|
-
export declare class BinaryCoStreamView<Meta extends BinaryCoStreamMeta = {
|
|
95
|
-
type: "binary";
|
|
96
|
-
}> extends CoStreamView<BinaryStreamItem, Meta> implements CoValue {
|
|
97
|
-
id: CoID<this>;
|
|
98
|
-
getBinaryChunks(allowUnfinished?: boolean): (BinaryStreamInfo & {
|
|
99
|
-
chunks: Uint8Array[];
|
|
100
|
-
finished: boolean;
|
|
101
|
-
}) | undefined;
|
|
102
|
-
}
|
|
103
|
-
export declare class BinaryCoStream<Meta extends BinaryCoStreamMeta = {
|
|
104
|
-
type: "binary";
|
|
105
|
-
}> extends BinaryCoStreamView<Meta> implements CoValue {
|
|
106
|
-
/** @internal */
|
|
107
|
-
push(item: BinaryStreamItem, privacy?: "private" | "trusting"): this;
|
|
108
|
-
startBinaryStream(settings: BinaryStreamInfo, privacy?: "private" | "trusting"): this;
|
|
109
|
-
pushBinaryStreamChunk(chunk: Uint8Array, privacy?: "private" | "trusting"): this;
|
|
110
|
-
endBinaryStream(privacy?: "private" | "trusting"): this;
|
|
111
|
-
mutate(mutator: (mutable: MutableBinaryCoStream<Meta>) => void): this;
|
|
112
|
-
/** @deprecated Use `mutate` instead. */
|
|
113
|
-
edit(mutator: (mutable: MutableBinaryCoStream<Meta>) => void): this;
|
|
114
|
-
}
|
|
115
|
-
export declare class MutableBinaryCoStream<Meta extends BinaryCoStreamMeta = {
|
|
116
|
-
type: "binary";
|
|
117
|
-
}> extends BinaryCoStreamView<Meta> implements CoValue {
|
|
118
|
-
/** @internal */
|
|
119
|
-
push(item: BinaryStreamItem, privacy?: "private" | "trusting"): void;
|
|
120
|
-
startBinaryStream(settings: BinaryStreamInfo, privacy?: "private" | "trusting"): void;
|
|
121
|
-
pushBinaryStreamChunk(chunk: Uint8Array, privacy?: "private" | "trusting"): void;
|
|
122
|
-
endBinaryStream(privacy?: "private" | "trusting"): void;
|
|
123
|
-
}
|
package/dist/coValues/group.d.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { CoID, CoValue } 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";
|
|
6
|
-
import { Encrypted, KeyID, KeySecret, Sealed } from "../crypto.js";
|
|
7
|
-
import { AgentID } from "../ids.js";
|
|
8
|
-
import { AccountID, Profile } from "./account.js";
|
|
9
|
-
import { Role } from "../permissions.js";
|
|
10
|
-
export declare const EVERYONE: "everyone";
|
|
11
|
-
export type Everyone = "everyone";
|
|
12
|
-
export type GroupShape<P extends Profile, R extends CoMap> = {
|
|
13
|
-
profile?: CoID<P> | null;
|
|
14
|
-
root?: CoID<R> | null;
|
|
15
|
-
[key: AccountID | AgentID]: Role;
|
|
16
|
-
[EVERYONE]?: Role;
|
|
17
|
-
readKey?: KeyID;
|
|
18
|
-
[revelationFor: `${KeyID}_for_${AccountID | AgentID}`]: Sealed<KeySecret>;
|
|
19
|
-
[revelationFor: `${KeyID}_for_${Everyone}`]: KeySecret;
|
|
20
|
-
[oldKeyForNewKey: `${KeyID}_for_${KeyID}`]: Encrypted<KeySecret, {
|
|
21
|
-
encryptedID: KeyID;
|
|
22
|
-
encryptingID: KeyID;
|
|
23
|
-
}>;
|
|
24
|
-
};
|
|
25
|
-
export declare function expectGroup(content: CoValue): Group;
|
|
26
|
-
/** A `Group` is a scope for permissions of its members (`"reader" | "writer" | "admin"`), applying to objects owned by that group.
|
|
27
|
-
*
|
|
28
|
-
* A `Group` object exposes methods for permission management and allows you to create new CoValues owned by that group.
|
|
29
|
-
*
|
|
30
|
-
* (Internally, a `Group` is also just a `CoMap`, mapping member accounts to roles and containing some
|
|
31
|
-
* state management for making cryptographic keys available to current members)
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* You typically get a group from a CoValue that you already have loaded:
|
|
35
|
-
*
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const group = coMap.group;
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* Or, you can create a new group with a `LocalNode`:
|
|
42
|
-
*
|
|
43
|
-
* ```typescript
|
|
44
|
-
* const localNode.createGroup();
|
|
45
|
-
* ```
|
|
46
|
-
* */
|
|
47
|
-
export declare class Group<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends JsonObject | null = JsonObject | null> extends CoMap<GroupShape<P, R>, Meta> {
|
|
48
|
-
/**
|
|
49
|
-
* Returns the current role of a given account.
|
|
50
|
-
*
|
|
51
|
-
* @category 1. Role reading
|
|
52
|
-
*/
|
|
53
|
-
roleOf(accountID: AccountID): Role | undefined;
|
|
54
|
-
/** @internal */
|
|
55
|
-
roleOfInternal(accountID: AccountID | AgentID): Role | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Returns the role of the current account in the group.
|
|
58
|
-
*
|
|
59
|
-
* @category 1. Role reading
|
|
60
|
-
*/
|
|
61
|
-
myRole(): Role | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Directly grants a new member a role in the group. The current account must be an
|
|
64
|
-
* admin to be able to do so. Throws otherwise.
|
|
65
|
-
*
|
|
66
|
-
* @category 2. Role changing
|
|
67
|
-
*/
|
|
68
|
-
addMember(accountID: AccountID | Everyone, role: Role): this;
|
|
69
|
-
/** @internal */
|
|
70
|
-
addMemberInternal(accountID: AccountID | AgentID | Everyone, role: Role): this;
|
|
71
|
-
/** @internal */
|
|
72
|
-
rotateReadKey(): this;
|
|
73
|
-
/**
|
|
74
|
-
* Strips the specified member of all roles (preventing future writes in
|
|
75
|
-
* the group and owned values) and rotates the read encryption key for that group
|
|
76
|
-
* (preventing reads of new content in the group and owned values)
|
|
77
|
-
*
|
|
78
|
-
* @category 2. Role changing
|
|
79
|
-
*/
|
|
80
|
-
removeMember(accountID: AccountID): this;
|
|
81
|
-
/** @internal */
|
|
82
|
-
removeMemberInternal(accountID: AccountID | AgentID): this;
|
|
83
|
-
/**
|
|
84
|
-
* Creates an invite for new members to indirectly join the group,
|
|
85
|
-
* allowing them to grant themselves the specified role with the InviteSecret
|
|
86
|
-
* (a string starting with "inviteSecret_") - use `LocalNode.acceptInvite()` for this purpose.
|
|
87
|
-
*
|
|
88
|
-
* @category 2. Role changing
|
|
89
|
-
*/
|
|
90
|
-
createInvite(role: "reader" | "writer" | "admin"): InviteSecret;
|
|
91
|
-
/**
|
|
92
|
-
* Creates a new `CoMap` within this group, with the specified specialized
|
|
93
|
-
* `CoMap` type `M` and optional static metadata.
|
|
94
|
-
*
|
|
95
|
-
* @category 3. Value creation
|
|
96
|
-
*/
|
|
97
|
-
createMap<M extends CoMap>(init?: M["_shape"], meta?: M["meta"], initPrivacy?: "trusting" | "private"): M;
|
|
98
|
-
/**
|
|
99
|
-
* Creates a new `CoList` within this group, with the specified specialized
|
|
100
|
-
* `CoList` type `L` and optional static metadata.
|
|
101
|
-
*
|
|
102
|
-
* @category 3. Value creation
|
|
103
|
-
*/
|
|
104
|
-
createList<L extends CoList>(init?: L["_item"][], meta?: L["meta"], initPrivacy?: "trusting" | "private"): L;
|
|
105
|
-
/** @category 3. Value creation */
|
|
106
|
-
createStream<C extends CoStream>(meta?: C["meta"]): C;
|
|
107
|
-
/** @category 3. Value creation */
|
|
108
|
-
createBinaryStream<C extends BinaryCoStream>(meta?: C["meta"]): C;
|
|
109
|
-
}
|
|
110
|
-
export type InviteSecret = `inviteSecret_z${string}`;
|
|
111
|
-
export declare function secretSeedFromInviteSecret(inviteSecret: InviteSecret): Uint8Array;
|