Change default set & delete privacy to "private"
This commit is contained in:
@@ -54,12 +54,12 @@ test("Can insert and delete Map entries in edit()", () => {
|
||||
expect(content.type).toEqual("comap");
|
||||
|
||||
content.edit((editable) => {
|
||||
editable.set("hello", "world");
|
||||
editable.set("hello", "world", "trusting");
|
||||
expect(editable.get("hello")).toEqual("world");
|
||||
editable.set("foo", "bar");
|
||||
editable.set("foo", "bar", "trusting");
|
||||
expect(editable.get("foo")).toEqual("bar");
|
||||
expect([...editable.keys()]).toEqual(["hello", "foo"]);
|
||||
editable.delete("foo");
|
||||
editable.delete("foo", "trusting");
|
||||
expect(editable.get("foo")).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
@@ -88,13 +88,13 @@ test("Can get map entry values at different points in time", () => {
|
||||
content.edit((editable) => {
|
||||
const beforeA = Date.now();
|
||||
Bun.sleepSync(1);
|
||||
editable.set("hello", "A");
|
||||
editable.set("hello", "A", "trusting");
|
||||
const beforeB = Date.now();
|
||||
Bun.sleepSync(1);
|
||||
editable.set("hello", "B");
|
||||
editable.set("hello", "B", "trusting");
|
||||
const beforeC = Date.now();
|
||||
Bun.sleepSync(1);
|
||||
editable.set("hello", "C");
|
||||
editable.set("hello", "C", "trusting");
|
||||
expect(editable.get("hello")).toEqual("C");
|
||||
expect(editable.getAtTime("hello", Date.now())).toEqual("C");
|
||||
expect(editable.getAtTime("hello", beforeA)).toEqual(undefined);
|
||||
@@ -125,13 +125,13 @@ test("Can get all historic values of key", () => {
|
||||
expect(content.type).toEqual("comap");
|
||||
|
||||
content.edit((editable) => {
|
||||
editable.set("hello", "A");
|
||||
editable.set("hello", "A", "trusting");
|
||||
const txA = editable.getLastTxID("hello");
|
||||
editable.set("hello", "B");
|
||||
editable.set("hello", "B", "trusting");
|
||||
const txB = editable.getLastTxID("hello");
|
||||
editable.delete("hello");
|
||||
editable.delete("hello", "trusting");
|
||||
const txDel = editable.getLastTxID("hello");
|
||||
editable.set("hello", "C");
|
||||
editable.set("hello", "C", "trusting");
|
||||
const txC = editable.getLastTxID("hello");
|
||||
expect(
|
||||
editable.getHistory("hello")
|
||||
@@ -183,15 +183,15 @@ test("Can get last tx ID for a key", () => {
|
||||
|
||||
content.edit((editable) => {
|
||||
expect(editable.getLastTxID("hello")).toEqual(undefined);
|
||||
editable.set("hello", "A");
|
||||
editable.set("hello", "A", "trusting");
|
||||
const sessionID = editable.getLastTxID("hello")?.sessionID;
|
||||
expect(sessionID && agentIDfromSessionID(sessionID)).toEqual(
|
||||
getAgentID(getAgent(agentCredential))
|
||||
);
|
||||
expect(editable.getLastTxID("hello")?.txIndex).toEqual(0);
|
||||
editable.set("hello", "B");
|
||||
editable.set("hello", "B", "trusting");
|
||||
expect(editable.getLastTxID("hello")?.txIndex).toEqual(1);
|
||||
editable.set("hello", "C");
|
||||
editable.set("hello", "C", "trusting");
|
||||
expect(editable.getLastTxID("hello")?.txIndex).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -166,8 +166,7 @@ export class WriteableCoMap<
|
||||
V extends JsonValue = M[K],
|
||||
MM extends {[key: string]: JsonValue} = {[KK in K]: M[KK]}
|
||||
> extends CoMap<M, Meta, K, V, MM> {
|
||||
// TODO: change default to private
|
||||
set<KK extends K>(key: KK, value: M[KK], privacy: "private" | "trusting" = "trusting"): void {
|
||||
set<KK extends K>(key: KK, value: M[KK], privacy: "private" | "trusting" = "private"): void {
|
||||
this.multiLog.makeTransaction([
|
||||
{
|
||||
op: "insert",
|
||||
@@ -179,8 +178,7 @@ export class WriteableCoMap<
|
||||
this.fillOpsFromMultilog();
|
||||
}
|
||||
|
||||
// TODO: change default to private
|
||||
delete(key: K, privacy: "private" | "trusting" = "trusting"): void {
|
||||
delete(key: K, privacy: "private" | "trusting" = "private"): void {
|
||||
this.multiLog.makeTransaction([
|
||||
{
|
||||
op: "delete",
|
||||
|
||||
@@ -307,7 +307,7 @@ test("Admins can set team read key and then use it to create and read private tr
|
||||
tx: team.nextTransactionID(),
|
||||
}
|
||||
);
|
||||
editable.set("readKey", { keyID: readKeyID, revelation });
|
||||
editable.set("readKey", { keyID: readKeyID, revelation }, "trusting");
|
||||
expect(editable.get("readKey")).toEqual({
|
||||
keyID: readKeyID,
|
||||
revelation,
|
||||
@@ -354,7 +354,7 @@ test("Admins can set team read key and then writers can use it to create and rea
|
||||
tx: team.nextTransactionID(),
|
||||
}
|
||||
);
|
||||
editable.set("readKey", { keyID: readKeyID, revelation });
|
||||
editable.set("readKey", { keyID: readKeyID, revelation }, "trusting");
|
||||
});
|
||||
|
||||
const childObject = node.createMultiLog({
|
||||
@@ -404,7 +404,7 @@ test("Admins can set team read key and then use it to create private transaction
|
||||
tx: team.nextTransactionID(),
|
||||
}
|
||||
);
|
||||
editable.set("readKey", { keyID: readKeyID, revelation });
|
||||
editable.set("readKey", { keyID: readKeyID, revelation }, "trusting");
|
||||
});
|
||||
|
||||
const childObject = node.createMultiLog({
|
||||
@@ -446,7 +446,7 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
||||
tx: team.nextTransactionID(),
|
||||
}
|
||||
);
|
||||
editable.set("readKey", { keyID: readKeyID, revelation });
|
||||
editable.set("readKey", { keyID: readKeyID, revelation }, "trusting");
|
||||
expect(editable.get("readKey")).toEqual({
|
||||
keyID: readKeyID,
|
||||
revelation,
|
||||
@@ -483,7 +483,7 @@ test("Admins can set team read key, make a private transaction in an owned objec
|
||||
}
|
||||
);
|
||||
|
||||
editable.set("readKey", { keyID: readKeyID2, revelation });
|
||||
editable.set("readKey", { keyID: readKeyID2, revelation }, "trusting");
|
||||
expect(editable.get("readKey")).toEqual({
|
||||
keyID: readKeyID2,
|
||||
revelation,
|
||||
|
||||
Reference in New Issue
Block a user