Skip to content

Commit 427d174

Browse files
committed
fix: inboxes and app keys
1 parent 8a24c4b commit 427d174

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

apps/connect/src/routes/authenticate.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ function AuthenticateComponent() {
407407
appId: state.appInfo.appId,
408408
address: newAppIdentity.address,
409409
accountAddress,
410-
signaturePublicKey: newAppIdentity.signaturePublicKey,
411-
encryptionPublicKey: newAppIdentity.encryptionPublicKey,
410+
signaturePublicKey: keys.signaturePublicKey,
411+
encryptionPublicKey: keys.encryptionPublicKey,
412412
ciphertext,
413413
nonce,
414414
accountProof,
@@ -424,6 +424,8 @@ function AuthenticateComponent() {
424424
body: JSON.stringify(message),
425425
});
426426
const appIdentityResponse = await response.json();
427+
// TODO: All apps are essentially using the same keys, we should change to using
428+
// the newly created app identity keys, but that requires changing a lot of the verification logic in the server and HypergraphAppContext
427429
await encryptSpacesAndRedirect({
428430
accountAddress,
429431
appIdentity: {
@@ -432,8 +434,8 @@ function AuthenticateComponent() {
432434
accountAddress,
433435
encryptionPrivateKey: keys.encryptionPrivateKey,
434436
signaturePrivateKey: keys.signaturePrivateKey,
435-
encryptionPublicKey: newAppIdentity.encryptionPublicKey,
436-
signaturePublicKey: newAppIdentity.signaturePublicKey,
437+
encryptionPublicKey: keys.encryptionPublicKey,
438+
signaturePublicKey: keys.signaturePublicKey,
437439
sessionToken: appIdentityResponse.appIdentity.sessionToken,
438440
sessionTokenExpires: new Date(appIdentityResponse.appIdentity.sessionTokenExpires),
439441
permissionId,

packages/hypergraph-react/src/HypergraphAppContext.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ export function HypergraphAppProvider({
627627
}
628628
const inboxCreator = Inboxes.recoverAccountInboxCreatorKey(response.inbox);
629629
if (inboxCreator !== identity.signaturePublicKey) {
630-
console.error('Invalid inbox creator', response.inbox);
630+
console.error('Invalid inbox creator', response.inbox, inboxCreator, identity.signaturePublicKey);
631631
return;
632632
}
633633

@@ -1019,7 +1019,7 @@ export function HypergraphAppProvider({
10191019
}
10201020
const message = await Inboxes.createSpaceInboxCreationMessage({
10211021
author: {
1022-
accountAddress: identity.address,
1022+
accountAddress: identity.accountAddress,
10231023
signaturePublicKey,
10241024
encryptionPublicKey,
10251025
signaturePrivateKey,
@@ -1118,7 +1118,7 @@ export function HypergraphAppProvider({
11181118
throw new Error('Missing keys');
11191119
}
11201120
const message = await Inboxes.createAccountInboxCreationMessage({
1121-
accountAddress: identity.address,
1121+
accountAddress: identity.accountAddress,
11221122
isPublic,
11231123
authPolicy,
11241124
encryptionPublicKey,

packages/hypergraph-react/src/hooks/useExternalSpaceInbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export function useExternalSpaceInbox({
5151

5252
let authorAccountAddress: string | null = null;
5353
let signaturePrivateKey: string | null = null;
54-
if (identity?.address && inbox.authPolicy !== 'anonymous') {
55-
authorAccountAddress = identity.address;
54+
if (identity?.accountAddress && inbox.authPolicy !== 'anonymous') {
55+
authorAccountAddress = identity.accountAddress;
5656
signaturePrivateKey = identity.signaturePrivateKey;
5757
} else if (inbox.authPolicy === 'requires_auth') {
5858
throw new Error('Cannot send message to a required auth inbox without an identity');

packages/hypergraph-react/src/hooks/useOwnSpaceInbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ export function useOwnSpaceInbox({
104104

105105
let authorAccountAddress: string | null = null;
106106
let signaturePrivateKey: string | null = null;
107-
if (identity?.address && ownInbox.authPolicy !== 'anonymous') {
108-
authorAccountAddress = identity.address;
107+
if (identity?.accountAddress && ownInbox.authPolicy !== 'anonymous') {
108+
authorAccountAddress = identity.accountAddress;
109109
signaturePrivateKey = identity.signaturePrivateKey;
110110
} else if (ownInbox.authPolicy === 'requires_auth') {
111111
throw new Error('Cannot send message to a required auth inbox without an identity');

0 commit comments

Comments
 (0)