Skip to content

fix: inboxes and app keys #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions apps/connect/src/routes/authenticate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ function AuthenticateComponent() {
appId: state.appInfo.appId,
address: newAppIdentity.address,
accountAddress,
signaturePublicKey: newAppIdentity.signaturePublicKey,
encryptionPublicKey: newAppIdentity.encryptionPublicKey,
signaturePublicKey: keys.signaturePublicKey,
encryptionPublicKey: keys.encryptionPublicKey,
ciphertext,
nonce,
accountProof,
Expand All @@ -424,6 +424,8 @@ function AuthenticateComponent() {
body: JSON.stringify(message),
});
const appIdentityResponse = await response.json();
// TODO: All apps are essentially using the same keys, we should change to using
Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO comment spans multiple lines but only shows the first line in the diff. Consider adding a tracking issue reference or deadline to this TODO comment to ensure this architectural concern is addressed.

Suggested change
// TODO: All apps are essentially using the same keys, we should change to using
// TODO (Tracking issue: #1234): All apps are essentially using the same keys, we should change to using

Copilot uses AI. Check for mistakes.

// the newly created app identity keys, but that requires changing a lot of the verification logic in the server and HypergraphAppContext
await encryptSpacesAndRedirect({
accountAddress,
appIdentity: {
Expand All @@ -432,8 +434,8 @@ function AuthenticateComponent() {
accountAddress,
encryptionPrivateKey: keys.encryptionPrivateKey,
signaturePrivateKey: keys.signaturePrivateKey,
encryptionPublicKey: newAppIdentity.encryptionPublicKey,
signaturePublicKey: newAppIdentity.signaturePublicKey,
encryptionPublicKey: keys.encryptionPublicKey,
signaturePublicKey: keys.signaturePublicKey,
sessionToken: appIdentityResponse.appIdentity.sessionToken,
sessionTokenExpires: new Date(appIdentityResponse.appIdentity.sessionTokenExpires),
permissionId,
Expand Down
6 changes: 3 additions & 3 deletions packages/hypergraph-react/src/HypergraphAppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ export function HypergraphAppProvider({
}
const inboxCreator = Inboxes.recoverAccountInboxCreatorKey(response.inbox);
if (inboxCreator !== identity.signaturePublicKey) {
console.error('Invalid inbox creator', response.inbox);
console.error('Invalid inbox creator', response.inbox, inboxCreator, identity.signaturePublicKey);
Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using a more structured logging approach with clear labels for debugging values, such as: console.error('Invalid inbox creator:', { inbox: response.inbox, recovered: inboxCreator, expected: identity.signaturePublicKey })

Suggested change
console.error('Invalid inbox creator', response.inbox, inboxCreator, identity.signaturePublicKey);
console.error('Invalid inbox creator:', {
inbox: response.inbox,
recovered: inboxCreator,
expected: identity.signaturePublicKey,
});

Copilot uses AI. Check for mistakes.

return;
}

Expand Down Expand Up @@ -1019,7 +1019,7 @@ export function HypergraphAppProvider({
}
const message = await Inboxes.createSpaceInboxCreationMessage({
author: {
accountAddress: identity.address,
accountAddress: identity.accountAddress,
signaturePublicKey,
encryptionPublicKey,
signaturePrivateKey,
Expand Down Expand Up @@ -1118,7 +1118,7 @@ export function HypergraphAppProvider({
throw new Error('Missing keys');
}
const message = await Inboxes.createAccountInboxCreationMessage({
accountAddress: identity.address,
accountAddress: identity.accountAddress,
isPublic,
authPolicy,
encryptionPublicKey,
Expand Down
4 changes: 2 additions & 2 deletions packages/hypergraph-react/src/hooks/useExternalSpaceInbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export function useExternalSpaceInbox({

let authorAccountAddress: string | null = null;
let signaturePrivateKey: string | null = null;
if (identity?.address && inbox.authPolicy !== 'anonymous') {
authorAccountAddress = identity.address;
if (identity?.accountAddress && inbox.authPolicy !== 'anonymous') {
authorAccountAddress = identity.accountAddress;
signaturePrivateKey = identity.signaturePrivateKey;
} else if (inbox.authPolicy === 'requires_auth') {
throw new Error('Cannot send message to a required auth inbox without an identity');
Expand Down
4 changes: 2 additions & 2 deletions packages/hypergraph-react/src/hooks/useOwnSpaceInbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export function useOwnSpaceInbox({

let authorAccountAddress: string | null = null;
let signaturePrivateKey: string | null = null;
if (identity?.address && ownInbox.authPolicy !== 'anonymous') {
authorAccountAddress = identity.address;
if (identity?.accountAddress && ownInbox.authPolicy !== 'anonymous') {
authorAccountAddress = identity.accountAddress;
signaturePrivateKey = identity.signaturePrivateKey;
} else if (ownInbox.authPolicy === 'requires_auth') {
throw new Error('Cannot send message to a required auth inbox without an identity');
Expand Down
Loading