cojson 0.0.7 → 0.0.8
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 +11 -8
- package/dist/coValue.d.ts +97 -0
- package/dist/coValue.js +381 -0
- package/dist/coValue.js.map +1 -0
- package/dist/coValue.test.d.ts +1 -0
- package/dist/coValue.test.js +78 -0
- package/dist/coValue.test.js.map +1 -0
- package/dist/contentType.d.ts +15 -0
- package/dist/contentType.js +7 -0
- package/dist/contentType.js.map +1 -0
- package/dist/contentType.test.d.ts +1 -0
- package/dist/contentType.test.js +149 -0
- package/dist/contentType.test.js.map +1 -0
- package/dist/contentTypes/coList.d.ts +11 -0
- package/dist/contentTypes/coList.js +16 -0
- package/dist/contentTypes/coList.js.map +1 -0
- package/dist/contentTypes/coMap.d.ts +56 -0
- package/dist/contentTypes/coMap.js +126 -0
- package/dist/contentTypes/coMap.js.map +1 -0
- package/dist/contentTypes/coStream.d.ts +11 -0
- package/dist/contentTypes/coStream.js +16 -0
- package/dist/contentTypes/coStream.js.map +1 -0
- package/dist/contentTypes/static.d.ts +11 -0
- package/dist/contentTypes/static.js +14 -0
- package/dist/contentTypes/static.js.map +1 -0
- package/dist/crypto.d.ts +97 -0
- package/dist/crypto.js +156 -0
- package/dist/crypto.js.map +1 -0
- package/dist/crypto.test.d.ts +1 -0
- package/dist/crypto.test.js +115 -0
- package/dist/crypto.test.js.map +1 -0
- package/dist/ids.d.ts +7 -0
- package/dist/ids.js +2 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonValue.d.ts +7 -0
- package/dist/jsonValue.js +2 -0
- package/dist/jsonValue.js.map +1 -0
- package/dist/node.d.ts +33 -0
- package/dist/node.js +113 -0
- package/dist/node.js.map +1 -0
- package/dist/permissions.d.ts +54 -0
- package/dist/permissions.js +218 -0
- package/dist/permissions.js.map +1 -0
- package/dist/permissions.test.d.ts +1 -0
- package/dist/permissions.test.js +794 -0
- package/dist/permissions.test.js.map +1 -0
- package/dist/sync.d.ts +80 -0
- package/dist/sync.js +271 -0
- package/dist/sync.js.map +1 -0
- package/dist/sync.test.d.ts +1 -0
- package/dist/sync.test.js +826 -0
- package/dist/sync.test.js.map +1 -0
- package/package.json +5 -4
- package/src/coValue.test.ts +3 -4
- package/src/coValue.ts +11 -11
- package/src/contentType.test.ts +3 -3
- package/src/contentType.ts +6 -6
- package/src/contentTypes/coList.ts +4 -4
- package/src/contentTypes/coMap.ts +6 -6
- package/src/contentTypes/coStream.ts +4 -4
- package/src/contentTypes/static.ts +5 -5
- package/src/crypto.test.ts +1 -1
- package/src/crypto.ts +2 -2
- package/src/index.ts +8 -8
- package/src/jsonValue.ts +1 -1
- package/src/node.ts +6 -7
- package/src/permissions.test.ts +5 -5
- package/src/permissions.ts +7 -7
- package/src/sync.test.ts +7 -7
- package/src/sync.ts +6 -6
- package/tsconfig.json +1 -7
- package/dist/coValue.mjs +0 -437
- package/dist/coValue.test.mjs +0 -122
- package/dist/contentType.mjs +0 -7
- package/dist/contentType.test.mjs +0 -179
- package/dist/contentTypes/coList.mjs +0 -18
- package/dist/contentTypes/coMap.mjs +0 -126
- package/dist/contentTypes/coStream.mjs +0 -18
- package/dist/contentTypes/static.mjs +0 -16
- package/dist/crypto.mjs +0 -207
- package/dist/crypto.test.mjs +0 -155
- package/dist/ids.mjs +0 -1
- package/dist/index.mjs +0 -21
- package/dist/jsonValue.mjs +0 -1
- package/dist/node.mjs +0 -144
- package/dist/permissions.mjs +0 -244
- package/dist/permissions.test.mjs +0 -985
- package/dist/sync.mjs +0 -318
- package/dist/sync.test.mjs +0 -861
package/.eslintrc.cjs
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
extends: [
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
"eslint:recommended",
|
|
4
|
+
"plugin:@typescript-eslint/recommended",
|
|
5
|
+
"plugin:require-extensions/recommended",
|
|
5
6
|
],
|
|
6
|
-
parser:
|
|
7
|
-
plugins: [
|
|
7
|
+
parser: "@typescript-eslint/parser",
|
|
8
|
+
plugins: ["@typescript-eslint", "require-extensions"],
|
|
8
9
|
parserOptions: {
|
|
9
|
-
project:
|
|
10
|
+
project: "./tsconfig.json",
|
|
10
11
|
},
|
|
11
12
|
root: true,
|
|
12
13
|
rules: {
|
|
13
14
|
"no-unused-vars": "off",
|
|
14
|
-
"@typescript-eslint/no-unused-vars": [
|
|
15
|
+
"@typescript-eslint/no-unused-vars": [
|
|
16
|
+
"error",
|
|
17
|
+
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
|
18
|
+
],
|
|
15
19
|
"@typescript-eslint/no-floating-promises": "error",
|
|
16
20
|
},
|
|
17
|
-
|
|
18
|
-
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ContentType } from './contentType.js';
|
|
2
|
+
import { Encrypted, Hash, KeySecret, RecipientID, RecipientSecret, SignatoryID, SignatorySecret, Signature, StreamingHash, KeyID } from './crypto.js';
|
|
3
|
+
import { JsonValue } from './jsonValue.js';
|
|
4
|
+
import { PermissionsDef as RulesetDef, Team } from './permissions.js';
|
|
5
|
+
import { LocalNode } from './node.js';
|
|
6
|
+
import { CoValueKnownState, NewContentMessage } from './sync.js';
|
|
7
|
+
import { AgentID, RawCoValueID, SessionID, TransactionID } from './ids.js';
|
|
8
|
+
export type CoValueHeader = {
|
|
9
|
+
type: ContentType["type"];
|
|
10
|
+
ruleset: RulesetDef;
|
|
11
|
+
meta: JsonValue;
|
|
12
|
+
createdAt: `2${string}` | null;
|
|
13
|
+
uniqueness: `z${string}` | null;
|
|
14
|
+
publicNickname?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function agentIDfromSessionID(sessionID: SessionID): AgentID;
|
|
17
|
+
export declare function newRandomSessionID(agentID: AgentID): SessionID;
|
|
18
|
+
type SessionLog = {
|
|
19
|
+
transactions: Transaction[];
|
|
20
|
+
lastHash?: Hash;
|
|
21
|
+
streamingHash: StreamingHash;
|
|
22
|
+
lastSignature: Signature;
|
|
23
|
+
};
|
|
24
|
+
export type PrivateTransaction = {
|
|
25
|
+
privacy: "private";
|
|
26
|
+
madeAt: number;
|
|
27
|
+
keyUsed: KeyID;
|
|
28
|
+
encryptedChanges: Encrypted<JsonValue[], {
|
|
29
|
+
in: RawCoValueID;
|
|
30
|
+
tx: TransactionID;
|
|
31
|
+
}>;
|
|
32
|
+
};
|
|
33
|
+
export type TrustingTransaction = {
|
|
34
|
+
privacy: "trusting";
|
|
35
|
+
madeAt: number;
|
|
36
|
+
changes: JsonValue[];
|
|
37
|
+
};
|
|
38
|
+
export type Transaction = PrivateTransaction | TrustingTransaction;
|
|
39
|
+
export type DecryptedTransaction = {
|
|
40
|
+
txID: TransactionID;
|
|
41
|
+
changes: JsonValue[];
|
|
42
|
+
madeAt: number;
|
|
43
|
+
};
|
|
44
|
+
export declare class CoValue {
|
|
45
|
+
id: RawCoValueID;
|
|
46
|
+
node: LocalNode;
|
|
47
|
+
header: CoValueHeader;
|
|
48
|
+
sessions: {
|
|
49
|
+
[key: SessionID]: SessionLog;
|
|
50
|
+
};
|
|
51
|
+
content?: ContentType;
|
|
52
|
+
listeners: Set<(content?: ContentType) => void>;
|
|
53
|
+
constructor(header: CoValueHeader, node: LocalNode);
|
|
54
|
+
testWithDifferentCredentials(agentCredential: AgentCredential, ownSessionID: SessionID): CoValue;
|
|
55
|
+
knownState(): CoValueKnownState;
|
|
56
|
+
get meta(): JsonValue;
|
|
57
|
+
nextTransactionID(): TransactionID;
|
|
58
|
+
tryAddTransactions(sessionID: SessionID, newTransactions: Transaction[], newHash: Hash, newSignature: Signature): boolean;
|
|
59
|
+
subscribe(listener: (content?: ContentType) => void): () => void;
|
|
60
|
+
expectedNewHashAfter(sessionID: SessionID, newTransactions: Transaction[]): {
|
|
61
|
+
expectedNewHash: Hash;
|
|
62
|
+
newStreamingHash: StreamingHash;
|
|
63
|
+
};
|
|
64
|
+
makeTransaction(changes: JsonValue[], privacy: "private" | "trusting"): boolean;
|
|
65
|
+
getCurrentContent(): ContentType;
|
|
66
|
+
getValidSortedTransactions(): DecryptedTransaction[];
|
|
67
|
+
getCurrentReadKey(): {
|
|
68
|
+
secret: KeySecret | undefined;
|
|
69
|
+
id: KeyID;
|
|
70
|
+
};
|
|
71
|
+
getReadKey(keyID: KeyID): KeySecret | undefined;
|
|
72
|
+
getTeam(): Team;
|
|
73
|
+
getTx(txID: TransactionID): Transaction | undefined;
|
|
74
|
+
newContentSince(knownState: CoValueKnownState | undefined): NewContentMessage | undefined;
|
|
75
|
+
getDependedOnCoValues(): RawCoValueID[];
|
|
76
|
+
}
|
|
77
|
+
export type Agent = {
|
|
78
|
+
signatoryID: SignatoryID;
|
|
79
|
+
recipientID: RecipientID;
|
|
80
|
+
publicNickname?: string;
|
|
81
|
+
};
|
|
82
|
+
export declare function getAgent(agentCredential: AgentCredential): {
|
|
83
|
+
signatoryID: `signatory_z${string}`;
|
|
84
|
+
recipientID: `recipient_z${string}`;
|
|
85
|
+
publicNickname: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
export declare function getAgentCoValueHeader(agent: Agent): CoValueHeader;
|
|
88
|
+
export declare function getAgentID(agent: Agent): AgentID;
|
|
89
|
+
export type AgentCredential = {
|
|
90
|
+
signatorySecret: SignatorySecret;
|
|
91
|
+
recipientSecret: RecipientSecret;
|
|
92
|
+
publicNickname?: string;
|
|
93
|
+
};
|
|
94
|
+
export declare function newRandomAgentCredential(publicNickname?: string): AgentCredential;
|
|
95
|
+
export declare function agentCredentialToBytes(cred: AgentCredential): Uint8Array;
|
|
96
|
+
export declare function agentCredentialFromBytes(bytes: Uint8Array): AgentCredential | undefined;
|
|
97
|
+
export {};
|
package/dist/coValue.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { randomBytes } from "@noble/hashes/utils";
|
|
2
|
+
import { Static } from './contentTypes/static.js';
|
|
3
|
+
import { CoStream } from './contentTypes/coStream.js';
|
|
4
|
+
import { CoMap } from './contentTypes/coMap.js';
|
|
5
|
+
import { StreamingHash, getRecipientID, getSignatoryID, newRandomRecipient, newRandomSignatory, openAs, shortHash, sign, verify, encryptForTransaction, decryptForTransaction, unsealKeySecret, signatorySecretToBytes, recipientSecretToBytes, signatorySecretFromBytes, recipientSecretFromBytes, } from './crypto.js';
|
|
6
|
+
import { base58 } from "@scure/base";
|
|
7
|
+
import { Team, determineValidTransactions, expectTeamContent, } from './permissions.js';
|
|
8
|
+
import { CoList } from './contentTypes/coList.js';
|
|
9
|
+
function coValueIDforHeader(header) {
|
|
10
|
+
const hash = shortHash(header);
|
|
11
|
+
if (header.publicNickname) {
|
|
12
|
+
return `co_${header.publicNickname}_z${hash.slice("shortHash_z".length)}`;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return `co_z${hash.slice("shortHash_z".length)}`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function agentIDfromSessionID(sessionID) {
|
|
19
|
+
return sessionID.split("_session")[0];
|
|
20
|
+
}
|
|
21
|
+
export function newRandomSessionID(agentID) {
|
|
22
|
+
return `${agentID}_session_z${base58.encode(randomBytes(8))}`;
|
|
23
|
+
}
|
|
24
|
+
export class CoValue {
|
|
25
|
+
constructor(header, node) {
|
|
26
|
+
this.listeners = new Set();
|
|
27
|
+
this.id = coValueIDforHeader(header);
|
|
28
|
+
this.header = header;
|
|
29
|
+
this.sessions = {};
|
|
30
|
+
this.node = node;
|
|
31
|
+
}
|
|
32
|
+
testWithDifferentCredentials(agentCredential, ownSessionID) {
|
|
33
|
+
const newNode = this.node.testWithDifferentCredentials(agentCredential, ownSessionID);
|
|
34
|
+
return newNode.expectCoValueLoaded(this.id);
|
|
35
|
+
}
|
|
36
|
+
knownState() {
|
|
37
|
+
return {
|
|
38
|
+
coValueID: this.id,
|
|
39
|
+
header: true,
|
|
40
|
+
sessions: Object.fromEntries(Object.entries(this.sessions).map(([k, v]) => [
|
|
41
|
+
k,
|
|
42
|
+
v.transactions.length,
|
|
43
|
+
])),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
get meta() {
|
|
47
|
+
return this.header?.meta ?? null;
|
|
48
|
+
}
|
|
49
|
+
nextTransactionID() {
|
|
50
|
+
const sessionID = this.node.ownSessionID;
|
|
51
|
+
return {
|
|
52
|
+
sessionID,
|
|
53
|
+
txIndex: this.sessions[sessionID]?.transactions.length || 0,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
tryAddTransactions(sessionID, newTransactions, newHash, newSignature) {
|
|
57
|
+
const signatoryID = this.node.expectAgentLoaded(agentIDfromSessionID(sessionID), "Expected to know signatory of transaction").signatoryID;
|
|
58
|
+
if (!signatoryID) {
|
|
59
|
+
console.warn("Unknown agent", agentIDfromSessionID(sessionID));
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const { expectedNewHash, newStreamingHash } = this.expectedNewHashAfter(sessionID, newTransactions);
|
|
63
|
+
if (newHash !== expectedNewHash) {
|
|
64
|
+
console.warn("Invalid hash", { newHash, expectedNewHash });
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (!verify(newSignature, newHash, signatoryID)) {
|
|
68
|
+
console.warn("Invalid signature", newSignature, newHash, signatoryID);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const transactions = this.sessions[sessionID]?.transactions ?? [];
|
|
72
|
+
transactions.push(...newTransactions);
|
|
73
|
+
this.sessions[sessionID] = {
|
|
74
|
+
transactions,
|
|
75
|
+
lastHash: newHash,
|
|
76
|
+
streamingHash: newStreamingHash,
|
|
77
|
+
lastSignature: newSignature,
|
|
78
|
+
};
|
|
79
|
+
this.content = undefined;
|
|
80
|
+
const content = this.getCurrentContent();
|
|
81
|
+
for (const listener of this.listeners) {
|
|
82
|
+
listener(content);
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
subscribe(listener) {
|
|
87
|
+
this.listeners.add(listener);
|
|
88
|
+
listener(this.getCurrentContent());
|
|
89
|
+
return () => {
|
|
90
|
+
this.listeners.delete(listener);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
expectedNewHashAfter(sessionID, newTransactions) {
|
|
94
|
+
const streamingHash = this.sessions[sessionID]?.streamingHash.clone() ??
|
|
95
|
+
new StreamingHash();
|
|
96
|
+
for (const transaction of newTransactions) {
|
|
97
|
+
streamingHash.update(transaction);
|
|
98
|
+
}
|
|
99
|
+
const newStreamingHash = streamingHash.clone();
|
|
100
|
+
return {
|
|
101
|
+
expectedNewHash: streamingHash.digest(),
|
|
102
|
+
newStreamingHash,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
makeTransaction(changes, privacy) {
|
|
106
|
+
const madeAt = Date.now();
|
|
107
|
+
let transaction;
|
|
108
|
+
if (privacy === "private") {
|
|
109
|
+
const { secret: keySecret, id: keyID } = this.getCurrentReadKey();
|
|
110
|
+
if (!keySecret) {
|
|
111
|
+
throw new Error("Can't make transaction without read key secret");
|
|
112
|
+
}
|
|
113
|
+
transaction = {
|
|
114
|
+
privacy: "private",
|
|
115
|
+
madeAt,
|
|
116
|
+
keyUsed: keyID,
|
|
117
|
+
encryptedChanges: encryptForTransaction(changes, keySecret, {
|
|
118
|
+
in: this.id,
|
|
119
|
+
tx: this.nextTransactionID(),
|
|
120
|
+
}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
transaction = {
|
|
125
|
+
privacy: "trusting",
|
|
126
|
+
madeAt,
|
|
127
|
+
changes,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const sessionID = this.node.ownSessionID;
|
|
131
|
+
const { expectedNewHash } = this.expectedNewHashAfter(sessionID, [
|
|
132
|
+
transaction,
|
|
133
|
+
]);
|
|
134
|
+
const signature = sign(this.node.agentCredential.signatorySecret, expectedNewHash);
|
|
135
|
+
const success = this.tryAddTransactions(sessionID, [transaction], expectedNewHash, signature);
|
|
136
|
+
if (success) {
|
|
137
|
+
void this.node.sync.syncCoValue(this);
|
|
138
|
+
}
|
|
139
|
+
return success;
|
|
140
|
+
}
|
|
141
|
+
getCurrentContent() {
|
|
142
|
+
if (this.content) {
|
|
143
|
+
return this.content;
|
|
144
|
+
}
|
|
145
|
+
if (this.header.type === "comap") {
|
|
146
|
+
this.content = new CoMap(this);
|
|
147
|
+
}
|
|
148
|
+
else if (this.header.type === "colist") {
|
|
149
|
+
this.content = new CoList(this);
|
|
150
|
+
}
|
|
151
|
+
else if (this.header.type === "costream") {
|
|
152
|
+
this.content = new CoStream(this);
|
|
153
|
+
}
|
|
154
|
+
else if (this.header.type === "static") {
|
|
155
|
+
this.content = new Static(this);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
throw new Error(`Unknown coValue type ${this.header.type}`);
|
|
159
|
+
}
|
|
160
|
+
return this.content;
|
|
161
|
+
}
|
|
162
|
+
getValidSortedTransactions() {
|
|
163
|
+
const validTransactions = determineValidTransactions(this);
|
|
164
|
+
const allTransactions = validTransactions
|
|
165
|
+
.map(({ txID, tx }) => {
|
|
166
|
+
if (tx.privacy === "trusting") {
|
|
167
|
+
return {
|
|
168
|
+
txID,
|
|
169
|
+
madeAt: tx.madeAt,
|
|
170
|
+
changes: tx.changes,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const readKey = this.getReadKey(tx.keyUsed);
|
|
175
|
+
if (!readKey) {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
const decrytedChanges = decryptForTransaction(tx.encryptedChanges, readKey, {
|
|
180
|
+
in: this.id,
|
|
181
|
+
tx: txID,
|
|
182
|
+
});
|
|
183
|
+
if (!decrytedChanges) {
|
|
184
|
+
console.error("Failed to decrypt transaction despite having key");
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
txID,
|
|
189
|
+
madeAt: tx.madeAt,
|
|
190
|
+
changes: decrytedChanges,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
.filter((x) => !!x);
|
|
196
|
+
allTransactions.sort((a, b) => a.madeAt - b.madeAt ||
|
|
197
|
+
(a.txID.sessionID < b.txID.sessionID ? -1 : 1) ||
|
|
198
|
+
a.txID.txIndex - b.txID.txIndex);
|
|
199
|
+
return allTransactions;
|
|
200
|
+
}
|
|
201
|
+
getCurrentReadKey() {
|
|
202
|
+
if (this.header.ruleset.type === "team") {
|
|
203
|
+
const content = expectTeamContent(this.getCurrentContent());
|
|
204
|
+
const currentKeyId = content.get("readKey")?.keyID;
|
|
205
|
+
if (!currentKeyId) {
|
|
206
|
+
throw new Error("No readKey set");
|
|
207
|
+
}
|
|
208
|
+
const secret = this.getReadKey(currentKeyId);
|
|
209
|
+
return {
|
|
210
|
+
secret: secret,
|
|
211
|
+
id: currentKeyId,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
else if (this.header.ruleset.type === "ownedByTeam") {
|
|
215
|
+
return this.node
|
|
216
|
+
.expectCoValueLoaded(this.header.ruleset.team)
|
|
217
|
+
.getCurrentReadKey();
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
throw new Error("Only teams or values owned by teams have read secrets");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
getReadKey(keyID) {
|
|
224
|
+
if (this.header.ruleset.type === "team") {
|
|
225
|
+
const content = expectTeamContent(this.getCurrentContent());
|
|
226
|
+
const readKeyHistory = content.getHistory("readKey");
|
|
227
|
+
// Try to find direct relevation of key for us
|
|
228
|
+
for (const entry of readKeyHistory) {
|
|
229
|
+
if (entry.value?.keyID === keyID) {
|
|
230
|
+
const revealer = agentIDfromSessionID(entry.txID.sessionID);
|
|
231
|
+
const revealerAgent = this.node.expectAgentLoaded(revealer, "Expected to know revealer");
|
|
232
|
+
const secret = openAs(entry.value.revelation, this.node.agentCredential.recipientSecret, revealerAgent.recipientID, {
|
|
233
|
+
in: this.id,
|
|
234
|
+
tx: entry.txID,
|
|
235
|
+
});
|
|
236
|
+
if (secret)
|
|
237
|
+
return secret;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// Try to find indirect revelation through previousKeys
|
|
241
|
+
for (const entry of readKeyHistory) {
|
|
242
|
+
const encryptedPreviousKey = entry.value?.previousKeys?.[keyID];
|
|
243
|
+
if (entry.value && encryptedPreviousKey) {
|
|
244
|
+
const sealingKeyID = entry.value.keyID;
|
|
245
|
+
const sealingKeySecret = this.getReadKey(sealingKeyID);
|
|
246
|
+
if (!sealingKeySecret) {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const secret = unsealKeySecret({
|
|
250
|
+
sealed: keyID,
|
|
251
|
+
sealing: sealingKeyID,
|
|
252
|
+
encrypted: encryptedPreviousKey,
|
|
253
|
+
}, sealingKeySecret);
|
|
254
|
+
if (secret) {
|
|
255
|
+
return secret;
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
console.error(`Sealing ${sealingKeyID} key didn't unseal ${keyID}`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
else if (this.header.ruleset.type === "ownedByTeam") {
|
|
265
|
+
return this.node
|
|
266
|
+
.expectCoValueLoaded(this.header.ruleset.team)
|
|
267
|
+
.getReadKey(keyID);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
throw new Error("Only teams or values owned by teams have read secrets");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
getTeam() {
|
|
274
|
+
if (this.header.ruleset.type !== "ownedByTeam") {
|
|
275
|
+
throw new Error("Only values owned by teams have teams");
|
|
276
|
+
}
|
|
277
|
+
return new Team(expectTeamContent(this.node
|
|
278
|
+
.expectCoValueLoaded(this.header.ruleset.team)
|
|
279
|
+
.getCurrentContent()), this.node);
|
|
280
|
+
}
|
|
281
|
+
getTx(txID) {
|
|
282
|
+
return this.sessions[txID.sessionID]?.transactions[txID.txIndex];
|
|
283
|
+
}
|
|
284
|
+
newContentSince(knownState) {
|
|
285
|
+
const newContent = {
|
|
286
|
+
action: "newContent",
|
|
287
|
+
coValueID: this.id,
|
|
288
|
+
header: knownState?.header ? undefined : this.header,
|
|
289
|
+
newContent: Object.fromEntries(Object.entries(this.sessions)
|
|
290
|
+
.map(([sessionID, log]) => {
|
|
291
|
+
const newTransactions = log.transactions.slice(knownState?.sessions[sessionID] || 0);
|
|
292
|
+
if (newTransactions.length === 0 ||
|
|
293
|
+
!log.lastHash ||
|
|
294
|
+
!log.lastSignature) {
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
return [
|
|
298
|
+
sessionID,
|
|
299
|
+
{
|
|
300
|
+
after: knownState?.sessions[sessionID] || 0,
|
|
301
|
+
newTransactions,
|
|
302
|
+
lastHash: log.lastHash,
|
|
303
|
+
lastSignature: log.lastSignature,
|
|
304
|
+
},
|
|
305
|
+
];
|
|
306
|
+
})
|
|
307
|
+
.filter((x) => !!x)),
|
|
308
|
+
};
|
|
309
|
+
if (!newContent.header &&
|
|
310
|
+
Object.keys(newContent.newContent).length === 0) {
|
|
311
|
+
return undefined;
|
|
312
|
+
}
|
|
313
|
+
return newContent;
|
|
314
|
+
}
|
|
315
|
+
getDependedOnCoValues() {
|
|
316
|
+
return this.header.ruleset.type === "team"
|
|
317
|
+
? expectTeamContent(this.getCurrentContent())
|
|
318
|
+
.keys()
|
|
319
|
+
.filter((k) => k.startsWith("co_agent"))
|
|
320
|
+
: this.header.ruleset.type === "ownedByTeam"
|
|
321
|
+
? [this.header.ruleset.team]
|
|
322
|
+
: [];
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
export function getAgent(agentCredential) {
|
|
326
|
+
return {
|
|
327
|
+
signatoryID: getSignatoryID(agentCredential.signatorySecret),
|
|
328
|
+
recipientID: getRecipientID(agentCredential.recipientSecret),
|
|
329
|
+
publicNickname: agentCredential.publicNickname,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
export function getAgentCoValueHeader(agent) {
|
|
333
|
+
return {
|
|
334
|
+
type: "comap",
|
|
335
|
+
ruleset: {
|
|
336
|
+
type: "agent",
|
|
337
|
+
initialSignatoryID: agent.signatoryID,
|
|
338
|
+
initialRecipientID: agent.recipientID,
|
|
339
|
+
},
|
|
340
|
+
meta: null,
|
|
341
|
+
createdAt: null,
|
|
342
|
+
uniqueness: null,
|
|
343
|
+
publicNickname: "agent" + (agent.publicNickname ? `-${agent.publicNickname}` : ""),
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
export function getAgentID(agent) {
|
|
347
|
+
return coValueIDforHeader(getAgentCoValueHeader(agent));
|
|
348
|
+
}
|
|
349
|
+
export function newRandomAgentCredential(publicNickname) {
|
|
350
|
+
const signatorySecret = newRandomSignatory();
|
|
351
|
+
const recipientSecret = newRandomRecipient();
|
|
352
|
+
return { signatorySecret, recipientSecret, publicNickname };
|
|
353
|
+
}
|
|
354
|
+
export function agentCredentialToBytes(cred) {
|
|
355
|
+
if (cred.publicNickname) {
|
|
356
|
+
throw new Error("Can't convert agent credential with publicNickname");
|
|
357
|
+
}
|
|
358
|
+
const bytes = new Uint8Array(64);
|
|
359
|
+
const signatorySecretBytes = signatorySecretToBytes(cred.signatorySecret);
|
|
360
|
+
if (signatorySecretBytes.length !== 32) {
|
|
361
|
+
throw new Error("Invalid signatorySecret length");
|
|
362
|
+
}
|
|
363
|
+
bytes.set(signatorySecretBytes);
|
|
364
|
+
const recipientSecretBytes = recipientSecretToBytes(cred.recipientSecret);
|
|
365
|
+
if (recipientSecretBytes.length !== 32) {
|
|
366
|
+
throw new Error("Invalid recipientSecret length");
|
|
367
|
+
}
|
|
368
|
+
bytes.set(recipientSecretBytes, 32);
|
|
369
|
+
return bytes;
|
|
370
|
+
}
|
|
371
|
+
export function agentCredentialFromBytes(bytes) {
|
|
372
|
+
if (bytes.length !== 64) {
|
|
373
|
+
return undefined;
|
|
374
|
+
}
|
|
375
|
+
const signatorySecret = signatorySecretFromBytes(bytes.slice(0, 32));
|
|
376
|
+
const recipientSecret = recipientSecretFromBytes(bytes.slice(32));
|
|
377
|
+
return { signatorySecret, recipientSecret };
|
|
378
|
+
}
|
|
379
|
+
// type Role = "admin" | "writer" | "reader";
|
|
380
|
+
// type PermissionsDef = CJMap<AgentID, Role, {[agent: AgentID]: Role}>;
|
|
381
|
+
//# sourceMappingURL=coValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coValue.js","sourceRoot":"","sources":["../src/coValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EASH,aAAa,EACb,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,IAAI,EACJ,MAAM,EACN,qBAAqB,EACrB,qBAAqB,EAErB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,GAC3B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAEH,IAAI,EACJ,0BAA0B,EAC1B,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAWlD,SAAS,kBAAkB,CAAC,MAAqB;IAC7C,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,cAAc,EAAE;QACvB,OAAO,MAAM,MAAM,CA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AAE,CAAC;AAChD,CAAC;AAED,6CAA6C;AAE7C,wEAAwE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getAgent, getAgentID, newRandomAgentCredential, newRandomSessionID, } from './coValue.js';
|
|
2
|
+
import { LocalNode } from './node.js';
|
|
3
|
+
import { createdNowUnique, sign } from './crypto.js';
|
|
4
|
+
test("Can create coValue with new agent credentials and add transaction to it", () => {
|
|
5
|
+
const agentCredential = newRandomAgentCredential("agent1");
|
|
6
|
+
const node = new LocalNode(agentCredential, newRandomSessionID(getAgentID(getAgent(agentCredential))));
|
|
7
|
+
const coValue = node.createCoValue({
|
|
8
|
+
type: "costream",
|
|
9
|
+
ruleset: { type: "unsafeAllowAll" },
|
|
10
|
+
meta: null,
|
|
11
|
+
...createdNowUnique()
|
|
12
|
+
});
|
|
13
|
+
const transaction = {
|
|
14
|
+
privacy: "trusting",
|
|
15
|
+
madeAt: Date.now(),
|
|
16
|
+
changes: [
|
|
17
|
+
{
|
|
18
|
+
hello: "world",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
const { expectedNewHash } = coValue.expectedNewHashAfter(node.ownSessionID, [transaction]);
|
|
23
|
+
expect(coValue.tryAddTransactions(node.ownSessionID, [transaction], expectedNewHash, sign(agentCredential.signatorySecret, expectedNewHash))).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
test("transactions with wrong signature are rejected", () => {
|
|
26
|
+
const wrongAgent = newRandomAgentCredential("wrongAgent");
|
|
27
|
+
const agentCredential = newRandomAgentCredential("agent1");
|
|
28
|
+
const node = new LocalNode(agentCredential, newRandomSessionID(getAgentID(getAgent(agentCredential))));
|
|
29
|
+
const coValue = node.createCoValue({
|
|
30
|
+
type: "costream",
|
|
31
|
+
ruleset: { type: "unsafeAllowAll" },
|
|
32
|
+
meta: null,
|
|
33
|
+
...createdNowUnique()
|
|
34
|
+
});
|
|
35
|
+
const transaction = {
|
|
36
|
+
privacy: "trusting",
|
|
37
|
+
madeAt: Date.now(),
|
|
38
|
+
changes: [
|
|
39
|
+
{
|
|
40
|
+
hello: "world",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
const { expectedNewHash } = coValue.expectedNewHashAfter(node.ownSessionID, [transaction]);
|
|
45
|
+
expect(coValue.tryAddTransactions(node.ownSessionID, [transaction], expectedNewHash, sign(wrongAgent.signatorySecret, expectedNewHash))).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
test("transactions with correctly signed, but wrong hash are rejected", () => {
|
|
48
|
+
const agentCredential = newRandomAgentCredential("agent1");
|
|
49
|
+
const node = new LocalNode(agentCredential, newRandomSessionID(getAgentID(getAgent(agentCredential))));
|
|
50
|
+
const coValue = node.createCoValue({
|
|
51
|
+
type: "costream",
|
|
52
|
+
ruleset: { type: "unsafeAllowAll" },
|
|
53
|
+
meta: null,
|
|
54
|
+
...createdNowUnique()
|
|
55
|
+
});
|
|
56
|
+
const transaction = {
|
|
57
|
+
privacy: "trusting",
|
|
58
|
+
madeAt: Date.now(),
|
|
59
|
+
changes: [
|
|
60
|
+
{
|
|
61
|
+
hello: "world",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
const { expectedNewHash } = coValue.expectedNewHashAfter(node.ownSessionID, [
|
|
66
|
+
{
|
|
67
|
+
privacy: "trusting",
|
|
68
|
+
madeAt: Date.now(),
|
|
69
|
+
changes: [
|
|
70
|
+
{
|
|
71
|
+
hello: "wrong",
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
expect(coValue.tryAddTransactions(node.ownSessionID, [transaction], expectedNewHash, sign(agentCredential.signatorySecret, expectedNewHash))).toBe(false);
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=coValue.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coValue.test.js","sour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OAAO,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;QACnC,IAAI,EAAE,IAAI;QACV,GAAG,gBAAgB,EAAE;KACxB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAgB;QAC7B,OAAO,EAAE,UAAU;QACnB,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE;QAClB,OAAO,EAAE;YACL;gBACI,KAAK,EAAE,OAAO;aACjB;SACJ;KACJ,CAAC;IAEF,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,oBAAoB,CACpD,IAAI,CAAC,YAAY,EACjB;QACI;YACI,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE;YAClB,OAAO,EAAE;gBACL;oBACI,KAAK,EAAE,OAAO;iBACjB;aACJ;SACJ;KACJ,CACJ,CAAC;IAEF,MAAM,CACF,OAAO,CAAC,kBAAkB,CACtB,IAAI,CAAC,YAAY,EACjB,CAAC,WAAW,CAAC,EACb,eAAe,EACf,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE,eAAe,CAAC,CACzD,CACJ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JsonValue } from './jsonValue.js';
|
|
2
|
+
import { RawCoValueID } from './ids.js';
|
|
3
|
+
import { CoMap } from './contentTypes/coMap.js';
|
|
4
|
+
import { CoStream } from './contentTypes/coStream.js';
|
|
5
|
+
import { Static } from './contentTypes/static.js';
|
|
6
|
+
import { CoList } from './contentTypes/coList.js';
|
|
7
|
+
export type CoValueID<T extends ContentType> = RawCoValueID & {
|
|
8
|
+
readonly __type: T;
|
|
9
|
+
};
|
|
10
|
+
export type ContentType = CoMap<{
|
|
11
|
+
[key: string]: JsonValue;
|
|
12
|
+
}, JsonValue> | CoList<JsonValue, JsonValue> | CoStream<JsonValue, JsonValue> | Static<JsonValue>;
|
|
13
|
+
export declare function expectMap(content: ContentType): CoMap<{
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
}, {}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contentType.js","sourceRoot":"","sources":["../src/contentType.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,SAAS,CAAC,OAAoB;IAC1C,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;KACnC;IAED,OAAO,OAA+C,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|