You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cojson-storage-sqlite

Package Overview
Dependencies
Maintainers
1
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cojson-storage-sqlite - npm Package Compare versions

Comparing version

to
0.3.4

24

dist/index.js

@@ -113,4 +113,11 @@ import { cojsonInternals, MAX_RECOMMENDED_TX_SIZE, } from "cojson";

};
const parsedHeader = (coValueRow?.header &&
JSON.parse(coValueRow.header));
let parsedHeader;
try {
parsedHeader = (coValueRow?.header &&
JSON.parse(coValueRow.header));
}
catch (e) {
console.warn(theirKnown.id, "Invalid JSON in header", e, coValueRow?.header);
return;
}
const newContentPieces = [

@@ -156,3 +163,11 @@ {

}
sessionEntry.newTransactions.push(JSON.parse(tx.tx));
let parsedTx;
try {
parsedTx = JSON.parse(tx.tx);
}
catch (e) {
console.warn(theirKnown.id, "Invalid JSON in transaction", e, tx.tx);
break;
}
sessionEntry.newTransactions.push(parsedTx);
if (signaturesAndIdxs[0] &&

@@ -179,3 +194,4 @@ idx === signaturesAndIdxs[0].idx) {

? newContentPieces
.flatMap((piece) => Object.values(piece.new)).flatMap((sessionEntry) => sessionEntry.newTransactions.flatMap((tx) => {
.flatMap((piece) => Object.values(piece.new))
.flatMap((sessionEntry) => sessionEntry.newTransactions.flatMap((tx) => {
if (tx.privacy !== "trusting")

@@ -182,0 +198,0 @@ return [];

4

package.json
{
"name": "cojson-storage-sqlite",
"type": "module",
"version": "0.3.3",
"version": "0.3.4",
"main": "dist/index.js",

@@ -21,3 +21,3 @@ "types": "dist/index.d.ts",

},
"gitHead": "9c5a6b9833c87c3158019b0f09d11943e800df86"
"gitHead": "b69c9da983b121151ae7c91b5fd8bc8351796355"
}

@@ -240,16 +240,28 @@ import {

const parsedHeader = (coValueRow?.header &&
JSON.parse(coValueRow.header)) as
| CojsonInternalTypes.CoValueHeader
| undefined;
let parsedHeader;
const newContentPieces: CojsonInternalTypes.NewContentMessage[] = [
{
action: "content",
id: theirKnown.id,
header: theirKnown.header ? undefined : parsedHeader,
new: {},
},
];
try {
parsedHeader = (coValueRow?.header &&
JSON.parse(coValueRow.header)) as
| CojsonInternalTypes.CoValueHeader
| undefined;
} catch (e) {
console.warn(
theirKnown.id,
"Invalid JSON in header",
e,
coValueRow?.header
);
return;
}
const newContentPieces: CojsonInternalTypes.NewContentMessage[] = [
{
action: "content",
id: theirKnown.id,
header: theirKnown.header ? undefined : parsedHeader,
new: {},
},
];
for (const sessionRow of allOurSessions) {

@@ -269,3 +281,6 @@ ourKnown.sessions[sessionRow.sessionID] = sessionRow.lastIdx;

)
.all(sessionRow.rowID, firstNewTxIdx) as SignatureAfterRow[];
.all(
sessionRow.rowID,
firstNewTxIdx
) as SignatureAfterRow[];

@@ -300,3 +315,4 @@ // console.log(

after: idx,
lastSignature: "WILL_BE_REPLACED" as CojsonInternalTypes.Signature,
lastSignature:
"WILL_BE_REPLACED" as CojsonInternalTypes.Signature,
newTransactions: [],

@@ -309,4 +325,18 @@ };

sessionEntry.newTransactions.push(JSON.parse(tx.tx));
let parsedTx;
try {
parsedTx = JSON.parse(tx.tx);
} catch (e) {
console.warn(
theirKnown.id,
"Invalid JSON in transaction",
e,
tx.tx
);
break;
}
sessionEntry.newTransactions.push(parsedTx);
if (

@@ -338,24 +368,27 @@ signaturesAndIdxs[0] &&

? newContentPieces
.flatMap((piece) => Object.values(piece.new)).flatMap((sessionEntry) =>
sessionEntry.newTransactions.flatMap((tx) => {
if (tx.privacy !== "trusting") return [];
// TODO: avoid parsing here?
return cojsonInternals
.parseJSON(tx.changes)
.map(
(change) =>
change &&
typeof change === "object" &&
"op" in change &&
change.op === "set" &&
"key" in change &&
change.key
)
.filter(
(key): key is CojsonInternalTypes.RawCoID =>
typeof key === "string" &&
key.startsWith("co_")
);
})
)
.flatMap((piece) => Object.values(piece.new))
.flatMap((sessionEntry) =>
sessionEntry.newTransactions.flatMap((tx) => {
if (tx.privacy !== "trusting") return [];
// TODO: avoid parsing here?
return cojsonInternals
.parseJSON(tx.changes)
.map(
(change) =>
change &&
typeof change === "object" &&
"op" in change &&
change.op === "set" &&
"key" in change &&
change.key
)
.filter(
(
key
): key is CojsonInternalTypes.RawCoID =>
typeof key === "string" &&
key.startsWith("co_")
);
})
)
: parsedHeader?.ruleset.type === "ownedByGroup"

@@ -507,3 +540,3 @@ ? [parsedHeader?.ruleset.group]

sessionUpdate.lastSignature,
sessionUpdate.bytesSinceLastSignature,
sessionUpdate.bytesSinceLastSignature
) as { rowID: number };

@@ -510,0 +543,0 @@

Sorry, the diff of this file is not supported yet