Skip to content

Commit fc20c53

Browse files
committed
fix: inboxes and app keys
1 parent 42d9a3b commit fc20c53

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
@@ -424,8 +424,8 @@ function AuthenticateComponent() {
424424
appId: state.appInfo.appId,
425425
address: newAppIdentity.address,
426426
accountAddress,
427-
signaturePublicKey: newAppIdentity.signaturePublicKey,
428-
encryptionPublicKey: newAppIdentity.encryptionPublicKey,
427+
signaturePublicKey: keys.signaturePublicKey,
428+
encryptionPublicKey: keys.encryptionPublicKey,
429429
ciphertext,
430430
nonce,
431431
accountProof,
@@ -441,6 +441,8 @@ function AuthenticateComponent() {
441441
body: JSON.stringify(message),
442442
});
443443
const appIdentityResponse = await response.json();
444+
// TODO: All apps are essentially using the same keys, we should change to using
445+
// the newly created app identity keys, but that requires changing a lot of the verification logic in the server and HypergraphAppContext
444446
await encryptSpacesAndRedirect({
445447
accountAddress,
446448
appIdentity: {
@@ -449,8 +451,8 @@ function AuthenticateComponent() {
449451
accountAddress,
450452
encryptionPrivateKey: keys.encryptionPrivateKey,
451453
signaturePrivateKey: keys.signaturePrivateKey,
452-
encryptionPublicKey: newAppIdentity.encryptionPublicKey,
453-
signaturePublicKey: newAppIdentity.signaturePublicKey,
454+
encryptionPublicKey: keys.encryptionPublicKey,
455+
signaturePublicKey: keys.signaturePublicKey,
454456
sessionToken: appIdentityResponse.appIdentity.sessionToken,
455457
sessionTokenExpires: new Date(appIdentityResponse.appIdentity.sessionTokenExpires),
456458
permissionId,

packages/hypergraph-react/src/HypergraphAppContext.tsx

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

@@ -1016,7 +1016,7 @@ export function HypergraphAppProvider({
10161016
}
10171017
const message = await Inboxes.createSpaceInboxCreationMessage({
10181018
author: {
1019-
accountAddress: identity.address,
1019+
accountAddress: identity.accountAddress,
10201020
signaturePublicKey,
10211021
encryptionPublicKey,
10221022
signaturePrivateKey,
@@ -1115,7 +1115,7 @@ export function HypergraphAppProvider({
11151115
throw new Error('Missing keys');
11161116
}
11171117
const message = await Inboxes.createAccountInboxCreationMessage({
1118-
accountAddress: identity.address,
1118+
accountAddress: identity.accountAddress,
11191119
isPublic,
11201120
authPolicy,
11211121
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)