Skip to content

Commit 73d3752

Browse files
committed
chore: include accountId in signature and message
1 parent 723552d commit 73d3752

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

packages/hypergraph-react/src/HypergraphAppContext.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,10 @@ export function HypergraphAppProvider({
465465
// Handle WebSocket messages in a separate effect
466466
useEffect(() => {
467467
if (!websocketConnection) return;
468+
if (!accountId) {
469+
console.error('No accountId found');
470+
return;
471+
}
468472
const encryptionPrivateKey = keys?.encryptionPrivateKey;
469473
if (!encryptionPrivateKey) {
470474
console.error('No encryption private key found');
@@ -567,6 +571,7 @@ export function HypergraphAppProvider({
567571
const ephemeralId = uuid();
568572

569573
const messageToSend = Messages.signedUpdateMessage({
574+
accountId,
570575
ephemeralId,
571576
spaceId: space.id,
572577
message: lastLocalChange,
@@ -666,7 +671,7 @@ export function HypergraphAppProvider({
666671
return () => {
667672
websocketConnection.removeEventListener('message', onMessage);
668673
};
669-
}, [websocketConnection, spaces, keys?.encryptionPrivateKey, keys?.signaturePrivateKey]);
674+
}, [websocketConnection, spaces, accountId, keys?.encryptionPrivateKey, keys?.signaturePrivateKey]);
670675

671676
const createSpaceForContext = async () => {
672677
if (!accountId) {

packages/hypergraph/src/messages/signed-update-message.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { encryptMessage } from './encrypt-message.js';
44
import type { RequestCreateUpdate } from './types.js';
55

66
interface Params {
7+
accountId: string;
78
ephemeralId: string;
89
spaceId: string;
910
message: Uint8Array;
@@ -12,6 +13,7 @@ interface Params {
1213
}
1314

1415
export const signedUpdateMessage = ({
16+
accountId,
1517
ephemeralId,
1618
spaceId,
1719
message,
@@ -25,6 +27,7 @@ export const signedUpdateMessage = ({
2527

2628
const messageToSign = stringToUint8Array(
2729
canonicalize({
30+
accountId,
2831
ephemeralId,
2932
update,
3033
spaceId,
@@ -38,6 +41,7 @@ export const signedUpdateMessage = ({
3841
ephemeralId,
3942
update,
4043
spaceId,
44+
accountId,
4145
signature,
4246
};
4347
};

packages/hypergraph/src/messages/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export type RequestListInvitations = Schema.Schema.Type<typeof RequestListInvita
8383

8484
export const RequestCreateUpdate = Schema.Struct({
8585
type: Schema.Literal('create-update'),
86+
accountId: Schema.String,
8687
update: Schema.Uint8Array,
8788
spaceId: Schema.String,
8889
ephemeralId: Schema.String, // used to identify the confirmation message

0 commit comments

Comments
 (0)