Get rid of public nickname feature

This commit is contained in:
Anselm
2023-08-14 17:47:21 +01:00
parent 4c13b67696
commit 813767145e
8 changed files with 12 additions and 33 deletions

View File

@@ -45,18 +45,11 @@ export type CoValueHeader = {
meta: JsonObject | null;
createdAt: `2${string}` | null;
uniqueness: `z${string}` | null;
publicNickname?: string;
};
export function coValueIDforHeader(header: CoValueHeader): RawCoValueID {
const hash = shortHash(header);
if (header.publicNickname) {
return `co_${header.publicNickname}_z${hash.slice(
"shortHash_z".length
)}`;
} else {
return `co_z${hash.slice("shortHash_z".length)}`;
}
return `co_z${hash.slice("shortHash_z".length)}`;
}
export function accountOrAgentIDfromSessionID(

View File

@@ -49,7 +49,7 @@ test("encrypting round-trips, but invalid receiver can't unseal", () => {
const nOnceMaterial = {
in: "co_zTEST",
tx: { sessionID: "co_agent_zTEST_session_zTEST", txIndex: 0 },
tx: { sessionID: "co_zTEST_session_zTEST", txIndex: 0 },
} as const;
const sealed = seal(
@@ -101,22 +101,22 @@ test("Encryption for transactions round-trips", () => {
const encrypted1 = encryptForTransaction({ a: "hello" }, secret, {
in: "co_zTEST",
tx: { sessionID: "co_agent_zTEST_session_zTEST", txIndex: 0 },
tx: { sessionID: "co_zTEST_session_zTEST", txIndex: 0 },
});
const encrypted2 = encryptForTransaction({ b: "world" }, secret, {
in: "co_zTEST",
tx: { sessionID: "co_agent_zTEST_session_zTEST", txIndex: 1 },
tx: { sessionID: "co_zTEST_session_zTEST", txIndex: 1 },
});
const decrypted1 = decryptForTransaction(encrypted1, secret, {
in: "co_zTEST",
tx: { sessionID: "co_agent_zTEST_session_zTEST", txIndex: 0 },
tx: { sessionID: "co_zTEST_session_zTEST", txIndex: 0 },
});
const decrypted2 = decryptForTransaction(encrypted2, secret, {
in: "co_zTEST",
tx: { sessionID: "co_agent_zTEST_session_zTEST", txIndex: 1 },
tx: { sessionID: "co_zTEST_session_zTEST", txIndex: 1 },
});
expect([decrypted1, decrypted2]).toEqual([{ a: "hello" }, { b: "world" }]);
@@ -128,22 +128,22 @@ test("Encryption for transactions doesn't decrypt with a wrong key", () => {
const encrypted1 = encryptForTransaction({ a: "hello" }, secret, {
in: "co_zTEST",
tx: { sessionID: "co_agent_zTEST_session_zTEST", txIndex: 0 },
tx: { sessionID: "co_zTEST_session_zTEST", txIndex: 0 },
});
const encrypted2 = encryptForTransaction({ b: "world" }, secret, {
in: "co_zTEST",
tx: { sessionID: "co_agent_zTEST_session_zTEST", txIndex: 1 },
tx: { sessionID: "co_zTEST_session_zTEST", txIndex: 1 },
});
const decrypted1 = decryptForTransaction(encrypted1, secret2, {
in: "co_zTEST",
tx: { sessionID: "co_agent_zTEST_session_zTEST", txIndex: 0 },
tx: { sessionID: "co_zTEST_session_zTEST", txIndex: 0 },
});
const decrypted2 = decryptForTransaction(encrypted2, secret2, {
in: "co_zTEST",
tx: { sessionID: "co_agent_zTEST_session_zTEST", txIndex: 1 },
tx: { sessionID: "co_zTEST_session_zTEST", txIndex: 1 },
});
expect([decrypted1, decrypted2]).toEqual([undefined, undefined]);

View File

@@ -1,6 +1,6 @@
import { AccountIDOrAgentID } from './account.js';
export type RawCoValueID = `co_z${string}` | `co_${string}_z${string}`;
export type RawCoValueID = `co_z${string}`;
export type TransactionID = { sessionID: SessionID; txIndex: number };

View File

@@ -154,7 +154,6 @@ export class LocalNode {
ruleset: { type: "team", initialAdmin: this.account.id },
meta: null,
...createdNowUnique(),
publicNickname: "team",
});
let teamContent = expectTeamContent(teamCoValue.getCurrentContent());

View File

@@ -266,7 +266,6 @@ test("Admins can write to an object that is owned by their team", () => {
ruleset: { type: "ownedByTeam", team: team.id },
meta: null,
...createdNowUnique(),
publicNickname: "childObject",
});
let childContent = expectMap(childObject.getCurrentContent());
@@ -309,7 +308,6 @@ test("Writers can write to an object that is owned by their team", () => {
ruleset: { type: "ownedByTeam", team: team.id },
meta: null,
...createdNowUnique(),
publicNickname: "childObject",
});
const childObjectAsWriter = childObject.testWithDifferentAccount(
@@ -369,7 +367,6 @@ test("Readers can not write to an object that is owned by their team", () => {
ruleset: { type: "ownedByTeam", team: team.id },
meta: null,
...createdNowUnique(),
publicNickname: "childObject",
});
const childObjectAsReader = childObject.testWithDifferentAccount(
@@ -449,7 +446,6 @@ test("Admins can set team read key and then use it to create and read private tr
ruleset: { type: "ownedByTeam", team: team.id },
meta: null,
...createdNowUnique(),
publicNickname: "childObject",
});
let childContent = expectMap(childObject.getCurrentContent());
@@ -521,7 +517,6 @@ test("Admins can set team read key and then writers can use it to create and rea
ruleset: { type: "ownedByTeam", team: team.id },
meta: null,
...createdNowUnique(),
publicNickname: "childObject",
});
const childObjectAsWriter = childObject.testWithDifferentAccount(
@@ -613,7 +608,6 @@ test("Admins can set team read key and then use it to create private transaction
ruleset: { type: "ownedByTeam", team: team.id },
meta: null,
...createdNowUnique(),
publicNickname: "childObject",
});
expectMap(childObject.getCurrentContent()).edit((editable) => {
@@ -705,7 +699,6 @@ test("Admins can set team read key and then use it to create private transaction
ruleset: { type: "ownedByTeam", team: team.id },
meta: null,
...createdNowUnique(),
publicNickname: "childObject",
});
expectMap(childObject.getCurrentContent()).edit((editable) => {
@@ -818,7 +811,6 @@ test("Admins can set team read key, make a private transaction in an owned objec
ruleset: { type: "ownedByTeam", team: team.id },
meta: null,
...createdNowUnique(),
publicNickname: "childObject",
});
let childContent = expectMap(childObject.getCurrentContent());
@@ -898,7 +890,6 @@ test("Admins can set team read key, make a private transaction in an owned objec
ruleset: { type: "ownedByTeam", team: team.id },
meta: null,
...createdNowUnique(),
publicNickname: "childObject",
});
const teamContent = expectTeamContent(team.getCurrentContent());
@@ -1044,7 +1035,6 @@ test("Admins can set team read rey, make a private transaction in an owned objec
ruleset: { type: "ownedByTeam", team: team.id },
meta: null,
...createdNowUnique(),
publicNickname: "childObject",
});
const teamContent = expectTeamContent(team.getCurrentContent());

View File

@@ -354,7 +354,6 @@ export class Team {
},
meta: meta || null,
...createdNowUnique(),
publicNickname: "map",
})
.getCurrentContent() as CoMap<M, Meta>;
}

View File

@@ -68,7 +68,6 @@ test("Node replies with initial tx and header to empty subscribe", async () => {
meta: null,
createdAt: map.coValue.header.createdAt,
uniqueness: map.coValue.header.uniqueness,
publicNickname: "map",
},
newContent: {
[node.ownSessionID]: {
@@ -1062,7 +1061,7 @@ test("When a peer's outgoing/writable stream closes, we remove the peer", async
});
test("If we start loading a coValue before connecting to a peer that has it, it will load it once we connect", async () => {
const [admin, session] = randomAnonymousAccountAndSessionID();
const [admin, session] = randomAnonymousAccountAndSessionID();
const node1 = new LocalNode(admin, session);

View File

@@ -23,7 +23,6 @@ export function newTeam() {
ruleset: { type: "team", initialAdmin: admin.id },
meta: null,
...createdNowUnique(),
publicNickname: "team",
});
const teamContent = expectTeamContent(team.getCurrentContent());