Compare commits

..

12 Commits

Author SHA1 Message Date
Anselm
ea882aba63 Hotfix release 2024-08-21 15:59:16 +01:00
Anselm
513a78ab9b Better logging for failed transactions 2024-08-21 15:58:38 +01:00
Anselm
406ab9b0da Hotfix release 2024-08-21 15:24:27 +01:00
Anselm
140f6616cb Remove WS buffer filling log message 2024-08-21 15:23:41 +01:00
Anselm
b09589b15e Hotfix release 2024-08-21 11:39:18 +01:00
Anselm
00638897f4 only one async transaction per covalue again 2024-08-21 11:36:47 +01:00
Anselm
5094e6d536 Hotfix release 2024-08-20 18:03:01 +01:00
Anselm
39242e7f68 Start introducing neverthrow, make tryAddNewTransactionsAsync and handleNewContent less throwy 2024-08-20 18:02:26 +01:00
Anselm Eickhoff
be7e208b1c Merge pull request #333 from gardencmp/anselm-jazz-265
Make sure errors in storage peer completely crash jazz context instead of failing silently
2024-08-20 14:09:19 +01:00
Anselm
c3bffbf4de Release 2024-08-20 14:02:53 +01:00
Anselm
d46467f318 Hotfix release 2024-08-20 12:58:09 +01:00
Anselm
6d21400803 Get rid of simulated errors 2024-08-20 12:57:50 +01:00
50 changed files with 1128 additions and 358 deletions

View File

@@ -1,5 +0,0 @@
---
"cojson": patch
---
Improve logging

View File

@@ -1,5 +0,0 @@
---
"cojson-transport-ws": patch
---
Wait if WS buffer is full

View File

@@ -0,0 +1,5 @@
---
"cojson": patch
---
Start introducing neverthrow, make tryAddNewTransactionsAsync and handleNewContent less throwy

View File

@@ -0,0 +1,5 @@
---
"cojson": patch
---
Only one async transaction per CoValue at a time again

View File

@@ -1,29 +1,27 @@
{
"mode": "pre",
"tag": "hotfixes",
"tag": "neverthrow",
"initialVersions": {
"jazz-example-chat": "0.0.79",
"jazz-inspector": "0.0.57",
"jazz-example-pets": "0.0.97",
"jazz-example-todo": "0.0.96",
"cojson": "0.7.31",
"cojson-storage-indexeddb": "0.7.31",
"cojson-storage-sqlite": "0.7.31",
"cojson-transport-ws": "0.7.31",
"jazz-example-chat": "0.0.80",
"jazz-inspector": "0.0.58",
"jazz-example-pets": "0.0.98",
"jazz-example-todo": "0.0.97",
"cojson": "0.7.33",
"cojson-storage-indexeddb": "0.7.33",
"cojson-storage-sqlite": "0.7.33",
"cojson-transport-ws": "0.7.33",
"hash-slash": "0.2.0",
"jazz-browser": "0.7.32",
"jazz-browser-media-images": "0.7.32",
"jazz-nodejs": "0.7.32",
"jazz-react": "0.7.32",
"jazz-run": "0.7.32",
"jazz-tools": "0.7.32"
"jazz-browser": "0.7.33",
"jazz-browser-media-images": "0.7.33",
"jazz-nodejs": "0.7.33",
"jazz-react": "0.7.33",
"jazz-run": "0.7.33",
"jazz-tools": "0.7.33"
},
"changesets": [
"angry-carpets-explain",
"bright-files-help",
"calm-experts-dance",
"rude-carrots-fetch",
"shaggy-hats-beg",
"small-items-laugh"
"early-files-lick",
"mighty-cameras-tickle",
"rich-tigers-cross",
"tidy-rice-speak"
]
}

View File

@@ -2,4 +2,4 @@
"cojson-transport-ws": patch
---
Handle ws closing while buffering
Remove WS buffer filling log message

View File

@@ -1,8 +0,0 @@
---
"cojson-storage-indexeddb": patch
"cojson-storage-sqlite": patch
"cojson-transport-ws": patch
"cojson": patch
---
Allow crashing whole node on peer errors

View File

@@ -1,5 +0,0 @@
---
"cojson": patch
---
Throw properly on peer that should crash on close

View File

@@ -1,6 +0,0 @@
---
"cojson-storage-sqlite": patch
"cojson": patch
---
Make simulated errors even more likely

View File

@@ -0,0 +1,5 @@
---
"cojson": patch
---
Better log message for failed transactions

View File

@@ -1,5 +1,50 @@
# jazz-example-chat
## 0.0.81-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
- jazz-react@0.7.34-neverthrow.3
- jazz-tools@0.7.34-neverthrow.3
## 0.0.81-neverthrow.2
### Patch Changes
- jazz-react@0.7.34-neverthrow.2
## 0.0.81-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
- jazz-react@0.7.34-neverthrow.1
- jazz-tools@0.7.34-neverthrow.1
## 0.0.81-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
- jazz-react@0.7.34-neverthrow.0
- jazz-tools@0.7.34-neverthrow.0
## 0.0.80
### Patch Changes
- Updated dependencies [b297c93]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson@0.7.33
- jazz-react@0.7.33
- jazz-tools@0.7.33
## 0.0.80-hotfixes.5
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-chat",
"private": true,
"version": "0.0.80-hotfixes.5",
"version": "0.0.81-neverthrow.3",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,5 +1,49 @@
# jazz-example-chat
## 0.0.59-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
- cojson-transport-ws@0.7.34-neverthrow.3
## 0.0.59-neverthrow.2
### Patch Changes
- Updated dependencies
- cojson-transport-ws@0.7.34-neverthrow.2
## 0.0.59-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
- cojson-transport-ws@0.7.34-neverthrow.1
## 0.0.59-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
- cojson-transport-ws@0.7.34-neverthrow.0
## 0.0.58
### Patch Changes
- Updated dependencies [fdde8db]
- Updated dependencies [b297c93]
- Updated dependencies [07fe2b9]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson-transport-ws@0.7.33
- cojson@0.7.33
## 0.0.58-hotfixes.5
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-inspector",
"private": true,
"version": "0.0.58-hotfixes.5",
"version": "0.0.59-neverthrow.3",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,5 +1,44 @@
# jazz-example-pets
## 0.0.99-neverthrow.3
### Patch Changes
- jazz-react@0.7.34-neverthrow.3
- jazz-tools@0.7.34-neverthrow.3
- jazz-browser-media-images@0.7.34-neverthrow.3
## 0.0.99-neverthrow.2
### Patch Changes
- jazz-browser-media-images@0.7.34-neverthrow.2
- jazz-react@0.7.34-neverthrow.2
## 0.0.99-neverthrow.1
### Patch Changes
- jazz-react@0.7.34-neverthrow.1
- jazz-tools@0.7.34-neverthrow.1
- jazz-browser-media-images@0.7.34-neverthrow.1
## 0.0.99-neverthrow.0
### Patch Changes
- jazz-react@0.7.34-neverthrow.0
- jazz-tools@0.7.34-neverthrow.0
- jazz-browser-media-images@0.7.34-neverthrow.0
## 0.0.98
### Patch Changes
- jazz-react@0.7.33
- jazz-tools@0.7.33
- jazz-browser-media-images@0.7.33
## 0.0.98-hotfixes.5
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-pets",
"private": true,
"version": "0.0.98-hotfixes.5",
"version": "0.0.99-neverthrow.3",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,5 +1,39 @@
# jazz-example-todo
## 0.0.98-neverthrow.3
### Patch Changes
- jazz-react@0.7.34-neverthrow.3
- jazz-tools@0.7.34-neverthrow.3
## 0.0.98-neverthrow.2
### Patch Changes
- jazz-react@0.7.34-neverthrow.2
## 0.0.98-neverthrow.1
### Patch Changes
- jazz-react@0.7.34-neverthrow.1
- jazz-tools@0.7.34-neverthrow.1
## 0.0.98-neverthrow.0
### Patch Changes
- jazz-react@0.7.34-neverthrow.0
- jazz-tools@0.7.34-neverthrow.0
## 0.0.97
### Patch Changes
- jazz-react@0.7.33
- jazz-tools@0.7.33
## 0.0.97-hotfixes.5
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-todo",
"private": true,
"version": "0.0.97-hotfixes.5",
"version": "0.0.98-neverthrow.3",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,5 +1,37 @@
# cojson-storage-indexeddb
## 0.7.34-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
## 0.7.34-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
## 0.7.34-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
## 0.7.33
### Patch Changes
- 3bf5127: Allow crashing whole node on peer errors
- Updated dependencies [b297c93]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson@0.7.33
## 0.7.33-hotfixes.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "cojson-storage-indexeddb",
"version": "0.7.33-hotfixes.5",
"version": "0.7.34-neverthrow.3",
"main": "dist/index.js",
"type": "module",
"types": "src/index.ts",

View File

@@ -1,5 +1,43 @@
# cojson-storage-sqlite
## 0.7.34-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
## 0.7.34-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
## 0.7.34-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
## 0.7.33
### Patch Changes
- 3bf5127: Allow crashing whole node on peer errors
- Updated dependencies [b297c93]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson@0.7.33
## 0.7.33-hotfixes.6
### Patch Changes
- Get rid of simulated errors
## 0.7.33-hotfixes.5
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "cojson-storage-sqlite",
"type": "module",
"version": "0.7.33-hotfixes.5",
"version": "0.7.34-neverthrow.3",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",

View File

@@ -55,9 +55,6 @@ export class SQLiteStorage {
const processMessages = async () => {
for await (const msg of fromLocalNode) {
if (Math.random() < 1/1000) {
void toLocalNode.push("Simulated error" as unknown as SyncMessage)
}
try {
if (msg === "Disconnected" || msg === "PingTimeout") {
throw new Error("Unexpected Disconnected message");

View File

@@ -1,5 +1,45 @@
# cojson-transport-nodejs-ws
## 0.7.34-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
## 0.7.34-neverthrow.2
### Patch Changes
- Remove WS buffer filling log message
## 0.7.34-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
## 0.7.34-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
## 0.7.33
### Patch Changes
- fdde8db: Handle ws closing while buffering
- 07fe2b9: Wait if WS buffer is full
- 3bf5127: Allow crashing whole node on peer errors
- Updated dependencies [b297c93]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson@0.7.33
## 0.7.33-hotfixes.5
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "cojson-transport-ws",
"type": "module",
"version": "0.7.33-hotfixes.5",
"version": "0.7.34-neverthrow.3",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",

View File

@@ -110,7 +110,6 @@ export function createWebSocketPeer({
await websocketOpen;
if (websocket.readyState === 1) {
while (websocket.bufferedAmount > 1_000_000) {
console.log("WS buffer filling", id, websocket.bufferedAmount);
await new Promise((resolve) =>
setTimeout(resolve, 100),
);

View File

@@ -3,10 +3,10 @@ module.exports = {
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:require-extensions/recommended",
"prettier"
"prettier",
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "require-extensions"],
plugins: ["@typescript-eslint", "require-extensions", "neverthrow"],
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
@@ -20,5 +20,6 @@ module.exports = {
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
"@typescript-eslint/no-floating-promises": "error",
"neverthrow/must-use-result": "error",
},
}
};

View File

@@ -1,5 +1,31 @@
# cojson
## 0.7.34-neverthrow.3
### Patch Changes
- Better log message for failed transactions
## 0.7.34-neverthrow.1
### Patch Changes
- Only one async transaction per CoValue at a time again
## 0.7.34-neverthrow.0
### Patch Changes
- Start introducing neverthrow, make tryAddNewTransactionsAsync and handleNewContent less throwy
## 0.7.33
### Patch Changes
- b297c93: Improve logging
- 3bf5127: Allow crashing whole node on peer errors
- a8b74ff: Throw properly on peer that should crash on close
## 0.7.33-hotfixes.5
### Patch Changes

View File

@@ -5,13 +5,14 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.7.33-hotfixes.5",
"version": "0.7.34-neverthrow.3",
"devDependencies": {
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"eslint": "^8.46.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-neverthrow": "^1.1.4",
"eslint-plugin-require-extensions": "^0.1.3",
"typescript": "5.0.2",
"vitest": "^0.34.6"
@@ -23,6 +24,7 @@
"@noble/hashes": "^1.4.0",
"@scure/base": "^1.1.1",
"hash-wasm": "^4.9.0",
"neverthrow": "^7.0.1",
"queueable": "^5.3.2"
},
"scripts": {

View File

@@ -7,6 +7,7 @@ import {
StreamingHash,
KeyID,
CryptoProvider,
SignerID,
} from "./crypto/crypto.js";
import { JsonObject, JsonValue } from "./jsonValue.js";
import { base58 } from "@scure/base";
@@ -16,7 +17,7 @@ import {
isKeyForKeyField,
} from "./permissions.js";
import { RawGroup } from "./coValues/group.js";
import { LocalNode } from "./localNode.js";
import { LocalNode, ResolveAccountAgentError } from "./localNode.js";
import { CoValueKnownState, NewContentMessage } from "./sync.js";
import { AgentID, RawCoID, SessionID, TransactionID } from "./ids.js";
import { AccountID, ControlledAccountOrAgent } from "./coValues/account.js";
@@ -25,6 +26,7 @@ import { coreToCoValue } from "./coreToCoValue.js";
import { expectGroup } from "./typeUtils/expectGroup.js";
import { isAccountID } from "./typeUtils/isAccountID.js";
import { accountOrAgentIDfromSessionID } from "./typeUtils/accountOrAgentIDfromSessionID.js";
import { err, ok, Result, ResultAsync } from "neverthrow";
/**
In order to not block other concurrently syncing CoValues we introduce a maximum size of transactions,
@@ -103,10 +105,10 @@ export class CoValueCore {
_decryptionCache: {
[key: Encrypted<JsonValue[], JsonValue>]: JsonValue[] | undefined;
} = {};
currentlyAsyncApplyingTxDone?: Promise<void>;
_cachedKnownState?: CoValueKnownState;
_cachedDependentOn?: RawCoID[];
_cachedNewContentSinceEmpty?: NewContentMessage[] | undefined;
_currentAsyncAddTransaction?: Promise<void>;
constructor(
header: CoValueHeader,
@@ -182,7 +184,9 @@ export class CoValueCore {
this.header.meta?.type === "account"
? (this.node.currentSessionID.replace(
this.node.account.id,
this.node.account.currentAgentID(),
this.node.account
.currentAgentID()
._unsafeUnwrap({ withStackTrace: true }),
) as SessionID)
: this.node.currentSessionID;
@@ -197,166 +201,197 @@ export class CoValueCore {
newTransactions: Transaction[],
givenExpectedNewHash: Hash | undefined,
newSignature: Signature,
): boolean {
const signerID = this.crypto.getAgentSignerID(
this.node.resolveAccountAgent(
): Result<true, TryAddTransactionsError> {
return this.node
.resolveAccountAgent(
accountOrAgentIDfromSessionID(sessionID),
"Expected to know signer of transaction",
),
);
)
.andThen((agent) => {
const signerID = this.crypto.getAgentSignerID(agent);
if (!signerID) {
console.warn(
"Unknown agent",
accountOrAgentIDfromSessionID(sessionID),
);
return false;
}
// const beforeHash = performance.now();
const { expectedNewHash, newStreamingHash } =
this.expectedNewHashAfter(sessionID, newTransactions);
// const afterHash = performance.now();
// console.log(
// "Hashing took",
// afterHash - beforeHash
// );
// const beforeHash = performance.now();
const { expectedNewHash, newStreamingHash } = this.expectedNewHashAfter(
sessionID,
newTransactions,
);
// const afterHash = performance.now();
// console.log(
// "Hashing took",
// afterHash - beforeHash
// );
if (
givenExpectedNewHash &&
givenExpectedNewHash !== expectedNewHash
) {
return err({
type: "InvalidHash",
id: this.id,
expectedNewHash,
givenExpectedNewHash,
} satisfies InvalidHashError);
}
if (givenExpectedNewHash && givenExpectedNewHash !== expectedNewHash) {
console.warn("Invalid hash", {
expectedNewHash,
givenExpectedNewHash,
// const beforeVerify = performance.now();
if (
!this.crypto.verify(newSignature, expectedNewHash, signerID)
) {
return err({
type: "InvalidSignature",
id: this.id,
newSignature,
sessionID,
signerID,
} satisfies InvalidSignatureError);
}
// const afterVerify = performance.now();
// console.log(
// "Verify took",
// afterVerify - beforeVerify
// );
this.doAddTransactions(
sessionID,
newTransactions,
newSignature,
expectedNewHash,
newStreamingHash,
"immediate",
);
return ok(true as const);
});
return false;
}
// const beforeVerify = performance.now();
if (!this.crypto.verify(newSignature, expectedNewHash, signerID)) {
console.warn(
"Invalid signature in",
this.id,
newSignature,
expectedNewHash,
signerID,
);
return false;
}
// const afterVerify = performance.now();
// console.log(
// "Verify took",
// afterVerify - beforeVerify
// );
this.doAddTransactions(
sessionID,
newTransactions,
newSignature,
expectedNewHash,
newStreamingHash,
"immediate",
);
return true;
}
async tryAddTransactionsAsync(
tryAddTransactionsAsync(
sessionID: SessionID,
newTransactions: Transaction[],
givenExpectedNewHash: Hash | undefined,
newSignature: Signature,
): Promise<boolean> {
if (this.currentlyAsyncApplyingTxDone) {
await this.currentlyAsyncApplyingTxDone;
}
let resolveDone!: () => void;
): ResultAsync<true, TryAddTransactionsError> {
const currentAsyncAddTransaction = this._currentAsyncAddTransaction;
let maybeAwaitPrevious:
| ResultAsync<void, TryAddTransactionsError>
| undefined;
let thisDone = () => {};
this.currentlyAsyncApplyingTxDone = new Promise((resolve) => {
resolveDone = resolve;
});
const signerID = this.crypto.getAgentSignerID(
await this.node.resolveAccountAgentAsync(
accountOrAgentIDfromSessionID(sessionID),
"Expected to know signer of transaction",
),
);
if (!signerID) {
console.warn(
"Unknown agent",
accountOrAgentIDfromSessionID(sessionID),
if (currentAsyncAddTransaction) {
// eslint-disable-next-line neverthrow/must-use-result
maybeAwaitPrevious = ResultAsync.fromSafePromise(
currentAsyncAddTransaction,
);
resolveDone();
return false;
}
const nTxBefore =
this.sessionLogs.get(sessionID)?.transactions.length ?? 0;
// const beforeHash = performance.now();
const { expectedNewHash, newStreamingHash } =
await this.expectedNewHashAfterAsync(sessionID, newTransactions);
// const afterHash = performance.now();
// console.log(
// "Hashing took",
// afterHash - beforeHash
// );
const nTxAfter =
this.sessionLogs.get(sessionID)?.transactions.length ?? 0;
if (nTxAfter !== nTxBefore) {
const newTransactionLengthBefore = newTransactions.length;
newTransactions = newTransactions.slice(nTxAfter - nTxBefore);
console.warn("Transactions changed while async hashing", {
nTxBefore,
nTxAfter,
newTransactionLengthBefore,
remainingNewTransactions: newTransactions.length,
} else {
// eslint-disable-next-line neverthrow/must-use-result
maybeAwaitPrevious = ResultAsync.fromSafePromise(Promise.resolve());
this._currentAsyncAddTransaction = new Promise((resolve) => {
thisDone = resolve;
});
}
if (givenExpectedNewHash && givenExpectedNewHash !== expectedNewHash) {
console.warn("Invalid hash", {
expectedNewHash,
givenExpectedNewHash,
return maybeAwaitPrevious
.andThen((_previousDone) =>
this.node
.resolveAccountAgentAsync(
accountOrAgentIDfromSessionID(sessionID),
"Expected to know signer of transaction",
)
.andThen((agent) => {
const signerID = this.crypto.getAgentSignerID(agent);
const nTxBefore =
this.sessionLogs.get(sessionID)?.transactions
.length ?? 0;
// const beforeHash = performance.now();
return ResultAsync.fromSafePromise(
this.expectedNewHashAfterAsync(
sessionID,
newTransactions,
),
).andThen(({ expectedNewHash, newStreamingHash }) => {
// const afterHash = performance.now();
// console.log(
// "Hashing took",
// afterHash - beforeHash
// );
const nTxAfter =
this.sessionLogs.get(sessionID)?.transactions
.length ?? 0;
if (nTxAfter !== nTxBefore) {
const newTransactionLengthBefore =
newTransactions.length;
newTransactions = newTransactions.slice(
nTxAfter - nTxBefore,
);
console.warn(
"Transactions changed while async hashing",
{
nTxBefore,
nTxAfter,
newTransactionLengthBefore,
remainingNewTransactions:
newTransactions.length,
},
);
}
if (
givenExpectedNewHash &&
givenExpectedNewHash !== expectedNewHash
) {
return err({
type: "InvalidHash",
id: this.id,
expectedNewHash,
givenExpectedNewHash,
} satisfies InvalidHashError);
}
performance.mark("verifyStart" + this.id);
if (
!this.crypto.verify(
newSignature,
expectedNewHash,
signerID,
)
) {
return err({
type: "InvalidSignature",
id: this.id,
newSignature,
sessionID,
signerID,
} satisfies InvalidSignatureError);
}
performance.mark("verifyEnd" + this.id);
performance.measure(
"verify" + this.id,
"verifyStart" + this.id,
"verifyEnd" + this.id,
);
this.doAddTransactions(
sessionID,
newTransactions,
newSignature,
expectedNewHash,
newStreamingHash,
"deferred",
);
return ok(true as const);
});
}),
)
.map((trueResult) => {
thisDone();
return trueResult;
})
.mapErr((err) => {
thisDone();
return err;
});
resolveDone();
return false;
}
performance.mark("verifyStart" + this.id);
if (!this.crypto.verify(newSignature, expectedNewHash, signerID)) {
console.warn(
"Invalid signature in",
this.id,
newSignature,
expectedNewHash,
signerID,
);
resolveDone();
return false;
}
performance.mark("verifyEnd" + this.id);
performance.measure(
"verify" + this.id,
"verifyStart" + this.id,
"verifyEnd" + this.id,
);
this.doAddTransactions(
sessionID,
newTransactions,
newSignature,
expectedNewHash,
newStreamingHash,
"deferred",
);
resolveDone();
return true;
}
private doAddTransactions(
@@ -545,7 +580,9 @@ export class CoValueCore {
this.header.meta?.type === "account"
? (this.node.currentSessionID.replace(
this.node.account.id,
this.node.account.currentAgentID(),
this.node.account
.currentAgentID()
._unsafeUnwrap({ withStackTrace: true }),
) as SessionID)
: this.node.currentSessionID;
@@ -563,7 +600,7 @@ export class CoValueCore {
[transaction],
expectedNewHash,
signature,
);
)._unsafeUnwrap({ withStackTrace: true });
if (success) {
void this.node.syncManager.syncCoValue(this);
@@ -709,7 +746,9 @@ export class CoValueCore {
// Try to find key revelation for us
const lookupAccountOrAgentID =
this.header.meta?.type === "account"
? this.node.account.currentAgentID()
? this.node.account
.currentAgentID()
._unsafeUnwrap({ withStackTrace: true })
: this.node.account.id;
const lastReadyKeyEdit = content.lastEditAt(
@@ -718,10 +757,9 @@ export class CoValueCore {
if (lastReadyKeyEdit?.value) {
const revealer = lastReadyKeyEdit.by;
const revealerAgent = this.node.resolveAccountAgent(
revealer,
"Expected to know revealer",
);
const revealerAgent = this.node
.resolveAccountAgent(revealer, "Expected to know revealer")
._unsafeUnwrap({ withStackTrace: true });
const secret = this.crypto.unseal(
lastReadyKeyEdit.value,
@@ -986,3 +1024,23 @@ function getNextKnownSignatureIdx(
idx >= (sentStateForSessionID ?? knownStateForSessionID ?? -1),
);
}
export type InvalidHashError = {
type: "InvalidHash";
id: RawCoID;
expectedNewHash: Hash;
givenExpectedNewHash: Hash;
};
export type InvalidSignatureError = {
type: "InvalidSignature";
id: RawCoID;
newSignature: Signature;
sessionID: SessionID;
signerID: SignerID;
};
export type TryAddTransactionsError =
| ResolveAccountAgentError
| InvalidHashError
| InvalidSignatureError;

View File

@@ -13,6 +13,7 @@ import { RawCoMap } from "./coMap.js";
import { RawGroup, InviteSecret } from "./group.js";
import { LocalNode } from "../index.js";
import { JsonObject } from "../jsonValue.js";
import { err, ok, Result } from "neverthrow";
export function accountHeaderForInitialAgentSecret(
agentSecret: AgentSecret,
@@ -30,28 +31,34 @@ export function accountHeaderForInitialAgentSecret(
};
}
export type InvalidAccountAgentIDError = {
type: "InvalidAccountAgentID";
reason: string;
};
export class RawAccount<
Meta extends AccountMeta = AccountMeta,
> extends RawGroup<Meta> {
_cachedCurrentAgentID: AgentID | undefined;
currentAgentID(): AgentID {
currentAgentID(): Result<AgentID, InvalidAccountAgentIDError> {
if (this._cachedCurrentAgentID) {
return this._cachedCurrentAgentID;
return ok(this._cachedCurrentAgentID);
}
const agents = this.keys().filter((k): k is AgentID =>
k.startsWith("sealer_"),
);
if (agents.length !== 1) {
throw new Error(
"Expected exactly one agent in account, got " + agents.length,
);
return err({
type: "InvalidAccountAgentID",
reason: "Account has " + agents.length + " agents",
});
}
this._cachedCurrentAgentID = agents[0];
return agents[0]!;
return ok(agents[0]!);
}
}
@@ -59,10 +66,10 @@ export interface ControlledAccountOrAgent {
id: AccountID | AgentID;
agentSecret: AgentSecret;
currentAgentID: () => AgentID;
currentSignerID: () => SignerID;
currentAgentID: () => Result<AgentID, InvalidAccountAgentIDError>;
currentSignerID: () => Result<SignerID, InvalidAccountAgentIDError>;
currentSignerSecret: () => SignerSecret;
currentSealerID: () => SealerID;
currentSealerID: () => Result<SealerID, InvalidAccountAgentIDError>;
currentSealerSecret: () => SealerSecret;
}
@@ -96,25 +103,29 @@ export class RawControlledAccount<Meta extends AccountMeta = AccountMeta>
return this.core.node.acceptInvite(groupOrOwnedValueID, inviteSecret);
}
currentAgentID(): AgentID {
currentAgentID(): Result<AgentID, InvalidAccountAgentIDError> {
if (this._cachedCurrentAgentID) {
return this._cachedCurrentAgentID;
return ok(this._cachedCurrentAgentID);
}
const agentID = this.crypto.getAgentID(this.agentSecret);
this._cachedCurrentAgentID = agentID;
return agentID;
return ok(agentID);
}
currentSignerID(): SignerID {
return this.crypto.getAgentSignerID(this.currentAgentID());
currentSignerID() {
return this.currentAgentID().map((id) =>
this.crypto.getAgentSignerID(id),
);
}
currentSignerSecret(): SignerSecret {
return this.crypto.getAgentSignerSecret(this.agentSecret);
}
currentSealerID(): SealerID {
return this.crypto.getAgentSealerID(this.currentAgentID());
currentSealerID() {
return this.currentAgentID().map((id) =>
this.crypto.getAgentSealerID(id),
);
}
currentSealerSecret(): SealerSecret {
@@ -133,20 +144,24 @@ export class ControlledAgent implements ControlledAccountOrAgent {
return this.crypto.getAgentID(this.agentSecret);
}
currentAgentID(): AgentID {
return this.crypto.getAgentID(this.agentSecret);
currentAgentID() {
return ok(this.crypto.getAgentID(this.agentSecret));
}
currentSignerID(): SignerID {
return this.crypto.getAgentSignerID(this.currentAgentID());
currentSignerID() {
return this.currentAgentID().map((id) =>
this.crypto.getAgentSignerID(id),
);
}
currentSignerSecret(): SignerSecret {
return this.crypto.getAgentSignerSecret(this.agentSecret);
}
currentSealerID(): SealerID {
return this.crypto.getAgentSealerID(this.currentAgentID());
currentSealerID() {
return this.currentAgentID().map((id) =>
this.crypto.getAgentSealerID(id),
);
}
currentSealerSecret(): SealerSecret {

View File

@@ -120,7 +120,9 @@ export class RawGroup<
const agent =
typeof account === "string"
? account
: account.currentAgentID();
: account
.currentAgentID()
._unsafeUnwrap({ withStackTrace: true });
this.set(memberKey, role, "trusting");
if (this.get(memberKey) !== role) {
@@ -175,7 +177,7 @@ export class RawGroup<
const reader = this.core.node.resolveAccountAgent(
readerID,
"Expected to know currently permitted reader",
);
)._unsafeUnwrap({ withStackTrace: true });
this.set(
`${newReadKey.id}_for_${readerID}`,

View File

@@ -22,9 +22,11 @@ import {
AccountID,
RawProfile,
RawAccountMigration,
InvalidAccountAgentIDError,
} from "./coValues/account.js";
import { Profile, RawCoValue } from "./index.js";
import { expectGroup } from "./typeUtils/expectGroup.js";
import { err, ok, okAsync, Result, ResultAsync } from "neverthrow";
/** A `LocalNode` represents a local view of a set of loaded `CoValue`s, from the perspective of a particular account (or primitive cryptographic agent).
@@ -243,7 +245,9 @@ export class LocalNode {
/** @internal */
createCoValue(header: CoValueHeader): CoValueCore {
if (this.crashed) {
throw new Error("Trying to create CoValue after node has crashed", { cause: this.crashed });
throw new Error("Trying to create CoValue after node has crashed", {
cause: this.crashed,
});
}
const coValue = new CoValueCore(header, this);
@@ -264,7 +268,9 @@ export class LocalNode {
} = {},
): Promise<CoValueCore | "unavailable"> {
if (this.crashed) {
throw new Error("Trying to load CoValue after node has crashed", { cause: this.crashed });
throw new Error("Trying to load CoValue after node has crashed", {
cause: this.crashed,
});
}
let entry = this.coValues[id];
@@ -529,9 +535,9 @@ export class LocalNode {
resolveAccountAgent(
id: AccountID | AgentID,
expectation?: string,
): AgentID {
): Result<AgentID, ResolveAccountAgentError> {
if (isAgentID(id)) {
return id;
return ok(id);
}
const coValue = this.expectCoValueLoaded(id, expectation);
@@ -543,49 +549,58 @@ export class LocalNode {
!("type" in coValue.header.meta) ||
coValue.header.meta.type !== "account"
) {
throw new Error(
`${
expectation ? expectation + ": " : ""
}CoValue ${id} is not an account`,
);
return err({
type: "UnexpectedlyNotAccount",
expectation,
id,
} satisfies UnexpectedlyNotAccountError);
}
return (coValue.getCurrentContent() as RawAccount).currentAgentID();
}
async resolveAccountAgentAsync(
resolveAccountAgentAsync(
id: AccountID | AgentID,
expectation?: string,
): Promise<AgentID> {
): ResultAsync<AgentID, ResolveAccountAgentError> {
if (isAgentID(id)) {
return id;
return okAsync(id);
}
const coValue = await this.loadCoValueCore(id);
return ResultAsync.fromPromise(
this.loadCoValueCore(id),
(e) =>
({
type: "ErrorLoadingCoValueCore",
expectation,
id,
error: e,
}) satisfies LoadCoValueCoreError,
).andThen((coValue) => {
if (coValue === "unavailable") {
return err({
type: "AccountUnavailableFromAllPeers" as const,
expectation,
id,
} satisfies AccountUnavailableFromAllPeersError);
}
if (coValue === "unavailable") {
throw new Error(
`${
expectation ? expectation + ": " : ""
}Account ${id} is unavailable from all peers`,
);
}
if (
coValue.header.type !== "comap" ||
coValue.header.ruleset.type !== "group" ||
!coValue.header.meta ||
!("type" in coValue.header.meta) ||
coValue.header.meta.type !== "account"
) {
return err({
type: "UnexpectedlyNotAccount" as const,
expectation,
id,
} satisfies UnexpectedlyNotAccountError);
}
if (
coValue.header.type !== "comap" ||
coValue.header.ruleset.type !== "group" ||
!coValue.header.meta ||
!("type" in coValue.header.meta) ||
coValue.header.meta.type !== "account"
) {
throw new Error(
`${
expectation ? expectation + ": " : ""
}CoValue ${id} is not an account`,
);
}
return (coValue.getCurrentContent() as RawAccount).currentAgentID();
return (coValue.getCurrentContent() as RawAccount).currentAgentID();
});
}
/**
@@ -610,7 +625,9 @@ export class LocalNode {
this.crypto.seal({
message: readKey.secret,
from: this.account.currentSealerSecret(),
to: this.account.currentSealerID(),
to: this.account
.currentSealerID()
._unsafeUnwrap({ withStackTrace: true }),
nOnceMaterial: {
in: groupCoValue.id,
tx: groupCoValue.nextTransactionID(),
@@ -710,6 +727,31 @@ type CoValueState =
onProgress?: (progress: number) => void;
};
export type LoadCoValueCoreError = {
type: "ErrorLoadingCoValueCore";
error: unknown;
expectation?: string;
id: AccountID;
};
export type AccountUnavailableFromAllPeersError = {
type: "AccountUnavailableFromAllPeers";
expectation?: string;
id: AccountID;
};
export type UnexpectedlyNotAccountError = {
type: "UnexpectedlyNotAccount";
expectation?: string;
id: AccountID;
};
export type ResolveAccountAgentError =
| InvalidAccountAgentIDError
| LoadCoValueCoreError
| AccountUnavailableFromAllPeersError
| UnexpectedlyNotAccountError;
/** @internal */
export function newLoadingState(
currentPeerIds: Set<PeerID>,

View File

@@ -249,8 +249,22 @@ export function determineValidTransactions(
const effectiveTransactor =
transactor === groupContent.id &&
groupAtTime instanceof RawAccount
? groupAtTime.currentAgentID()
? groupAtTime.currentAgentID().match(
(agentID) => agentID,
(e) => {
console.error(
"Error while determining current agent ID in valid transactions",
e,
);
return undefined;
},
)
: transactor;
if (!effectiveTransactor) {
return false;
}
const transactorRoleAtTxTime =
groupAtTime.get(effectiveTransactor) ||
groupAtTime.get(EVERYONE);

View File

@@ -392,22 +392,31 @@ export class SyncManager {
}
};
processMessages().then(() => {
if (peer.crashOnClose) {
console.error("Unexepcted close from peer", peer.id);
this.local.crashed = new Error("Unexpected close from peer");
throw new Error("Unexpected close from peer");
}
}).catch((e) => {
console.error("Error processing messages from peer", peer.id, e);
if (peer.crashOnClose) {
this.local.crashed = e;
throw new Error(e);
}
}).finally(() => {
peer.outgoing.close();
delete this.peers[peer.id];
});
processMessages()
.then(() => {
if (peer.crashOnClose) {
console.error("Unexepcted close from peer", peer.id);
this.local.crashed = new Error(
"Unexpected close from peer",
);
throw new Error("Unexpected close from peer");
}
})
.catch((e) => {
console.error(
"Error processing messages from peer",
peer.id,
e,
);
if (peer.crashOnClose) {
this.local.crashed = e;
throw new Error(e);
}
})
.finally(() => {
peer.outgoing.close();
delete this.peers[peer.id];
});
}
trySendToPeer(peer: PeerState, msg: SyncMessage) {
@@ -552,9 +561,10 @@ export class SyncManager {
let entry = this.local.coValues[msg.id];
if (!entry) {
throw new Error(
console.error(
`Expected coValue entry for ${msg.id} to be created on new content, missing subscribe?`,
);
return;
}
let resolveAfterDone: ((coValue: CoValueCore) => void) | undefined;
@@ -562,14 +572,16 @@ export class SyncManager {
const peerOptimisticKnownState = peer.optimisticKnownStates[msg.id];
if (!peerOptimisticKnownState) {
throw new Error(
console.error(
"Expected optimisticKnownState to be set for coValue we receive new content for",
);
return;
}
if (entry.state === "loading") {
if (!msg.header) {
throw new Error("Expected header to be sent in first message");
console.error("Expected header to be sent in first message");
return;
}
const firstPeerStateEntry = entry.firstPeerState[peer.id];
@@ -621,7 +633,8 @@ export class SyncManager {
}
const before = performance.now();
const success = await coValue.tryAddTransactionsAsync(
// eslint-disable-next-line neverthrow/must-use-result
const result = await coValue.tryAddTransactionsAsync(
sessionID,
newTransactions,
undefined,
@@ -657,13 +670,16 @@ export class SyncManager {
entry.onProgress?.(ourTotalnTxs / theirTotalnTxs);
if (!success) {
if (result.isErr()) {
console.error(
"Failed to add transactions",
"Failed to add transactions from",
peer.id,
result.error,
msg.id,
newTransactions.length + ' new transactions',
'we have' + ourTotalnTxs,
'they have' + theirTotalnTxs,
newTransactions.length + " new transactions",
"after: " + newContentForSession.after,
"our last known tx idx initially: " + ourKnownTxIdx,
"our last known tx idx now: " + coValue.sessionLogs.get(sessionID)?.transactions.length,
);
continue;
}

View File

@@ -36,12 +36,14 @@ test("Can create coValue with new agent credentials and add transaction to it",
);
expect(
coValue.tryAddTransactions(
node.currentSessionID,
[transaction],
expectedNewHash,
Crypto.sign(account.currentSignerSecret(), expectedNewHash),
),
coValue
.tryAddTransactions(
node.currentSessionID,
[transaction],
expectedNewHash,
Crypto.sign(account.currentSignerSecret(), expectedNewHash),
)
._unsafeUnwrap(),
).toBe(true);
});
@@ -72,8 +74,9 @@ test("transactions with wrong signature are rejected", () => {
[transaction],
);
expect(
coValue.tryAddTransactions(
// eslint-disable-next-line neverthrow/must-use-result
coValue
.tryAddTransactions(
node.currentSessionID,
[transaction],
expectedNewHash,
@@ -81,8 +84,8 @@ test("transactions with wrong signature are rejected", () => {
Crypto.getAgentSignerSecret(wrongAgent),
expectedNewHash,
),
),
).toBe(false);
)
._unsafeUnwrapErr({ withStackTrace: true });
});
test("transactions with correctly signed, but wrong hash are rejected", () => {
@@ -121,14 +124,15 @@ test("transactions with correctly signed, but wrong hash are rejected", () => {
],
);
expect(
coValue.tryAddTransactions(
// eslint-disable-next-line neverthrow/must-use-result
coValue
.tryAddTransactions(
node.currentSessionID,
[transaction],
expectedNewHash,
Crypto.sign(account.currentSignerSecret(), expectedNewHash),
),
).toBe(false);
)
._unsafeUnwrapErr({ withStackTrace: true });
});
test("New transactions in a group correctly update owned values, including subscriptions", async () => {
@@ -174,12 +178,14 @@ test("New transactions in a group correctly update owned values, including subsc
expect(map.core.getValidSortedTransactions().length).toBe(1);
const manuallyAdddedTxSuccess = group.core.tryAddTransactions(
node.currentSessionID,
[resignationThatWeJustLearnedAbout],
expectedNewHash,
signature,
);
const manuallyAdddedTxSuccess = group.core
.tryAddTransactions(
node.currentSessionID,
[resignationThatWeJustLearnedAbout],
expectedNewHash,
signature,
)
._unsafeUnwrap({ withStackTrace: true });
expect(manuallyAdddedTxSuccess).toBe(true);

View File

@@ -354,7 +354,7 @@ test("Admins can set group read key and then use it to create and read private t
const revelation = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -410,7 +410,7 @@ test("Admins can set group read key and then writers can use it to create and re
const revelation1 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -422,7 +422,7 @@ test("Admins can set group read key and then writers can use it to create and re
const revelation2 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: writer.currentSealerID(),
to: writer.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -489,7 +489,7 @@ test("Admins can set group read key and then use it to create private transactio
const revelation1 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -501,7 +501,7 @@ test("Admins can set group read key and then use it to create private transactio
const revelation2 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: reader.currentSealerID(),
to: reader.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -576,7 +576,7 @@ test("Admins can set group read key and then use it to create private transactio
const revelation1 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -588,7 +588,7 @@ test("Admins can set group read key and then use it to create private transactio
const revelation2 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: reader1.currentSealerID(),
to: reader1.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -627,7 +627,7 @@ test("Admins can set group read key and then use it to create private transactio
const revelation3 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: reader2.currentSealerID(),
to: reader2.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -692,7 +692,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
const revelation1 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -722,7 +722,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
const revelation2 = Crypto.seal({
message: readKey2,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -775,7 +775,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
const revelation = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -802,7 +802,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
const revelation2 = Crypto.seal({
message: readKey2,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -814,7 +814,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
const revelation3 = Crypto.seal({
message: readKey2,
from: admin.currentSealerSecret(),
to: reader.currentSealerID(),
to: reader.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -910,7 +910,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
const revelation1 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -922,7 +922,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
const revelation2 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: reader.currentSealerID(),
to: reader.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -934,7 +934,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
const revelation3 = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: reader2.currentSealerID(),
to: reader2.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -980,7 +980,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
const newRevelation1 = Crypto.seal({
message: readKey2,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -996,7 +996,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
const newRevelation2 = Crypto.seal({
message: readKey2,
from: admin.currentSealerSecret(),
to: reader2.currentSealerID(),
to: reader2.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -1121,7 +1121,7 @@ test("Admins can create an adminInvite, which can add an admin", () => {
const revelation = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -1231,7 +1231,7 @@ test("Admins can create a writerInvite, which can add a writer", () => {
const revelation = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -1334,7 +1334,7 @@ test("Admins can create a readerInvite, which can add a reader", () => {
const revelation = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -1427,7 +1427,7 @@ test("WriterInvites can not invite admins", () => {
const revelation = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -1481,7 +1481,7 @@ test("ReaderInvites can not invite admins", () => {
const revelation = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -1535,7 +1535,7 @@ test("ReaderInvites can not invite writers", () => {
const revelation = Crypto.seal({
message: readKey,
from: admin.currentSealerSecret(),
to: admin.currentSealerID(),
to: admin.currentSealerID()._unsafeUnwrap(),
nOnceMaterial: {
in: groupCore.id,
tx: groupCore.nextTransactionID(),
@@ -1610,7 +1610,7 @@ test("Can give read permission to 'everyone'", () => {
childObject
.testWithDifferentAccount(
newAccount,
newRandomSessionID(newAccount.currentAgentID()),
newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
)
.getCurrentContent(),
);
@@ -1639,7 +1639,7 @@ test("Can give read permissions to 'everyone' (high-level)", async () => {
childObject.core
.testWithDifferentAccount(
new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto),
newRandomSessionID(newAccount.currentAgentID()),
newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
)
.getCurrentContent(),
);
@@ -1680,7 +1680,7 @@ test("Can give write permission to 'everyone'", async () => {
childObject
.testWithDifferentAccount(
newAccount,
newRandomSessionID(newAccount.currentAgentID()),
newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
)
.getCurrentContent(),
);
@@ -1715,7 +1715,7 @@ test("Can give write permissions to 'everyone' (high-level)", async () => {
childObject.core
.testWithDifferentAccount(
newAccount,
newRandomSessionID(newAccount.currentAgentID()),
newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
)
.getCurrentContent(),
);

View File

@@ -1,5 +1,39 @@
# jazz-browser-media-images
## 0.7.34-neverthrow.3
### Patch Changes
- jazz-browser@0.7.34-neverthrow.3
- jazz-tools@0.7.34-neverthrow.3
## 0.7.34-neverthrow.2
### Patch Changes
- jazz-browser@0.7.34-neverthrow.2
## 0.7.34-neverthrow.1
### Patch Changes
- jazz-browser@0.7.34-neverthrow.1
- jazz-tools@0.7.34-neverthrow.1
## 0.7.34-neverthrow.0
### Patch Changes
- jazz-browser@0.7.34-neverthrow.0
- jazz-tools@0.7.34-neverthrow.0
## 0.7.33
### Patch Changes
- jazz-browser@0.7.33
- jazz-tools@0.7.33
## 0.7.33-hotfixes.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-browser-media-images",
"version": "0.7.33-hotfixes.5",
"version": "0.7.34-neverthrow.3",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",

View File

@@ -1,5 +1,57 @@
# jazz-browser
## 0.7.34-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
- cojson-storage-indexeddb@0.7.34-neverthrow.3
- cojson-transport-ws@0.7.34-neverthrow.3
- jazz-tools@0.7.34-neverthrow.3
## 0.7.34-neverthrow.2
### Patch Changes
- Updated dependencies
- cojson-transport-ws@0.7.34-neverthrow.2
## 0.7.34-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
- cojson-storage-indexeddb@0.7.34-neverthrow.1
- cojson-transport-ws@0.7.34-neverthrow.1
- jazz-tools@0.7.34-neverthrow.1
## 0.7.34-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
- cojson-storage-indexeddb@0.7.34-neverthrow.0
- cojson-transport-ws@0.7.34-neverthrow.0
- jazz-tools@0.7.34-neverthrow.0
## 0.7.33
### Patch Changes
- Updated dependencies [fdde8db]
- Updated dependencies [b297c93]
- Updated dependencies [07fe2b9]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson-transport-ws@0.7.33
- cojson@0.7.33
- cojson-storage-indexeddb@0.7.33
- jazz-tools@0.7.33
## 0.7.33-hotfixes.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-browser",
"version": "0.7.33-hotfixes.5",
"version": "0.7.34-neverthrow.3",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",

View File

@@ -1,5 +1,53 @@
# jazz-autosub
## 0.7.34-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
- cojson-transport-ws@0.7.34-neverthrow.3
- jazz-tools@0.7.34-neverthrow.3
## 0.7.34-neverthrow.2
### Patch Changes
- Updated dependencies
- cojson-transport-ws@0.7.34-neverthrow.2
## 0.7.34-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
- cojson-transport-ws@0.7.34-neverthrow.1
- jazz-tools@0.7.34-neverthrow.1
## 0.7.34-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
- cojson-transport-ws@0.7.34-neverthrow.0
- jazz-tools@0.7.34-neverthrow.0
## 0.7.33
### Patch Changes
- Updated dependencies [fdde8db]
- Updated dependencies [b297c93]
- Updated dependencies [07fe2b9]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson-transport-ws@0.7.33
- cojson@0.7.33
- jazz-tools@0.7.33
## 0.7.33-hotfixes.5
### Patch Changes

View File

@@ -5,7 +5,7 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.7.33-hotfixes.5",
"version": "0.7.34-neverthrow.3",
"dependencies": {
"cojson": "workspace:*",
"cojson-transport-ws": "workspace:*",

View File

@@ -1,5 +1,50 @@
# jazz-react
## 0.7.34-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
- jazz-browser@0.7.34-neverthrow.3
- jazz-tools@0.7.34-neverthrow.3
## 0.7.34-neverthrow.2
### Patch Changes
- jazz-browser@0.7.34-neverthrow.2
## 0.7.34-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
- jazz-browser@0.7.34-neverthrow.1
- jazz-tools@0.7.34-neverthrow.1
## 0.7.34-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
- jazz-browser@0.7.34-neverthrow.0
- jazz-tools@0.7.34-neverthrow.0
## 0.7.33
### Patch Changes
- Updated dependencies [b297c93]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson@0.7.33
- jazz-browser@0.7.33
- jazz-tools@0.7.33
## 0.7.33-hotfixes.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-react",
"version": "0.7.33-hotfixes.5",
"version": "0.7.34-neverthrow.3",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",

View File

@@ -1,5 +1,53 @@
# jazz-autosub
## 0.7.34-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
- cojson-transport-ws@0.7.34-neverthrow.3
- jazz-tools@0.7.34-neverthrow.3
## 0.7.34-neverthrow.2
### Patch Changes
- Updated dependencies
- cojson-transport-ws@0.7.34-neverthrow.2
## 0.7.34-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
- cojson-transport-ws@0.7.34-neverthrow.1
- jazz-tools@0.7.34-neverthrow.1
## 0.7.34-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
- cojson-transport-ws@0.7.34-neverthrow.0
- jazz-tools@0.7.34-neverthrow.0
## 0.7.33
### Patch Changes
- Updated dependencies [fdde8db]
- Updated dependencies [b297c93]
- Updated dependencies [07fe2b9]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson-transport-ws@0.7.33
- cojson@0.7.33
- jazz-tools@0.7.33
## 0.7.33-hotfixes.5
### Patch Changes

View File

@@ -3,7 +3,7 @@
"bin": "./dist/index.js",
"type": "module",
"license": "MIT",
"version": "0.7.33-hotfixes.5",
"version": "0.7.34-neverthrow.3",
"scripts": {
"lint": "eslint . --ext ts,tsx",
"format": "prettier --write './src/**/*.{ts,tsx}'",

View File

@@ -1,5 +1,36 @@
# jazz-autosub
## 0.7.34-neverthrow.3
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.3
## 0.7.34-neverthrow.1
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.1
## 0.7.34-neverthrow.0
### Patch Changes
- Updated dependencies
- cojson@0.7.34-neverthrow.0
## 0.7.33
### Patch Changes
- Updated dependencies [b297c93]
- Updated dependencies [3bf5127]
- Updated dependencies [a8b74ff]
- Updated dependencies [db53161]
- cojson@0.7.33
## 0.7.33-hotfixes.5
### Patch Changes

View File

@@ -5,7 +5,7 @@
"types": "./src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.7.33-hotfixes.5",
"version": "0.7.34-neverthrow.3",
"dependencies": {
"cojson": "workspace:*",
"fast-check": "^3.17.2"

78
pnpm-lock.yaml generated
View File

@@ -444,6 +444,9 @@ importers:
hash-wasm:
specifier: ^4.9.0
version: 4.11.0
neverthrow:
specifier: ^7.0.1
version: 7.0.1
queueable:
specifier: ^5.3.2
version: 5.3.2
@@ -463,6 +466,9 @@ importers:
eslint-config-prettier:
specifier: ^9.1.0
version: 9.1.0(eslint@8.56.0)
eslint-plugin-neverthrow:
specifier: ^1.1.4
version: 1.1.4(@typescript-eslint/parser@6.15.0(eslint@8.56.0)(typescript@5.0.2))(eslint@8.56.0)(typescript@5.0.2)
eslint-plugin-require-extensions:
specifier: ^0.1.3
version: 0.1.3(eslint@8.56.0)
@@ -1683,6 +1689,12 @@ packages:
'@types/chai@4.3.11':
resolution: {integrity: sha512-qQR1dr2rGIHYlJulmr8Ioq3De0Le9E4MJ5AiaeAETJJpndT1uUNHsGFK3L/UIu+rbkQSdj8J/w2bCsBZc/Y5fQ==}
'@types/eslint-utils@3.0.5':
resolution: {integrity: sha512-dGOLJqHXpjomkPgZiC7vnVSJtFIOM1Y6L01EyUhzPuD0y0wfIGiqxiGs3buUBfzxLIQHrCvZsIMDaCZ8R5IIoA==}
'@types/eslint@9.6.0':
resolution: {integrity: sha512-gi6WQJ7cHRgZxtkQEoyHMppPjq9Kxo5Tjn2prSKDSmZrCz8TZ3jSRCeTJm+WoM+oB0WG37bRqLzaaU3q7JypGg==}
'@types/estree@1.0.5':
resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==}
@@ -2504,6 +2516,13 @@ packages:
peerDependencies:
eslint: '>=7.0.0'
eslint-plugin-neverthrow@1.1.4:
resolution: {integrity: sha512-+8zsE5rDqsDfKYAOq0Fr2jbuxHXTmntIWWJqJA3ms1GAKcVCjl0ycetzOu/hTxot9ctr+WYQpCBgB3F2HATR7A==}
engines: {node: '>=14.17'}
peerDependencies:
'@typescript-eslint/parser': '>=4.20.0'
eslint: '>=5.16.0'
eslint-plugin-react-hooks@4.6.0:
resolution: {integrity: sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==}
engines: {node: '>=10'}
@@ -2525,6 +2544,16 @@ packages:
resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
eslint-utils@3.0.0:
resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==}
engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0}
peerDependencies:
eslint: '>=5'
eslint-visitor-keys@2.1.0:
resolution: {integrity: sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==}
engines: {node: '>=10'}
eslint-visitor-keys@3.4.3:
resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -3384,6 +3413,10 @@ packages:
resolution: {integrity: sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==}
engines: {node: '>= 0.4.0'}
neverthrow@7.0.1:
resolution: {integrity: sha512-NY1sD1wZn6dwwzV9/5KZ4wRIpH4xC7ARy3fGmnEi2Pi8CHDTWlp+WSF+if8cudrwuCWGrk2y2BE/dnGh070iuA==}
engines: {node: '>=18'}
node-abi@3.62.0:
resolution: {integrity: sha512-CPMcGa+y33xuL1E0TcNIu4YyaZCxnnvkVaEXrsosR3FxN+fV8xvb7Mzpb7IgKler10qeMkE6+Dp8qJhpzdq35g==}
engines: {node: '>=10'}
@@ -4257,9 +4290,18 @@ packages:
'@swc/wasm':
optional: true
tslib@1.14.1:
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
tslib@2.6.2:
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
tsutils@3.21.0:
resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==}
engines: {node: '>= 6'}
peerDependencies:
typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta'
tty-table@4.2.3:
resolution: {integrity: sha512-Fs15mu0vGzCrj8fmJNP7Ynxt5J7praPXqFN0leZeZBXJwkMxv9cb2D454k1ltrtUSJbZ4yH4e0CynsHLxmUfFA==}
engines: {node: '>=8.0.0'}
@@ -5644,6 +5686,16 @@ snapshots:
'@types/chai@4.3.11': {}
'@types/eslint-utils@3.0.5':
dependencies:
'@types/eslint': 9.6.0
'@types/estree': 1.0.5
'@types/eslint@9.6.0':
dependencies:
'@types/estree': 1.0.5
'@types/json-schema': 7.0.15
'@types/estree@1.0.5': {}
'@types/http-cache-semantics@4.0.4': {}
@@ -6724,6 +6776,16 @@ snapshots:
dependencies:
eslint: 8.56.0
eslint-plugin-neverthrow@1.1.4(@typescript-eslint/parser@6.15.0(eslint@8.56.0)(typescript@5.0.2))(eslint@8.56.0)(typescript@5.0.2):
dependencies:
'@types/eslint-utils': 3.0.5
'@typescript-eslint/parser': 6.15.0(eslint@8.56.0)(typescript@5.0.2)
eslint: 8.56.0
eslint-utils: 3.0.0(eslint@8.56.0)
tsutils: 3.21.0(typescript@5.0.2)
transitivePeerDependencies:
- typescript
eslint-plugin-react-hooks@4.6.0(eslint@8.56.0):
dependencies:
eslint: 8.56.0
@@ -6741,6 +6803,13 @@ snapshots:
esrecurse: 4.3.0
estraverse: 5.3.0
eslint-utils@3.0.0(eslint@8.56.0):
dependencies:
eslint: 8.56.0
eslint-visitor-keys: 2.1.0
eslint-visitor-keys@2.1.0: {}
eslint-visitor-keys@3.4.3: {}
eslint@8.56.0:
@@ -7641,6 +7710,8 @@ snapshots:
netmask@2.0.2: {}
neverthrow@7.0.1: {}
node-abi@3.62.0:
dependencies:
semver: 7.5.4
@@ -8606,8 +8677,15 @@ snapshots:
optionalDependencies:
'@swc/core': 1.3.101
tslib@1.14.1: {}
tslib@2.6.2: {}
tsutils@3.21.0(typescript@5.0.2):
dependencies:
tslib: 1.14.1
typescript: 5.0.2
tty-table@4.2.3:
dependencies:
chalk: 4.1.2