@graphprotocol/hypergraph 0.0.14 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connect/identity-encryption.d.ts +3 -3
- package/dist/connect/identity-encryption.d.ts.map +1 -1
- package/dist/connect/identity-encryption.js +18 -52
- package/dist/connect/identity-encryption.js.map +1 -1
- package/dist/connect/login.d.ts +1 -1
- package/dist/connect/login.d.ts.map +1 -1
- package/dist/connect/login.js +2 -2
- package/dist/connect/login.js.map +1 -1
- package/dist/connect/parse-auth-params.js +1 -1
- package/dist/connect/parse-auth-params.js.map +1 -1
- package/dist/connect/smart-account.d.ts.map +1 -1
- package/dist/connect/smart-account.js +2 -2
- package/dist/connect/smart-account.js.map +1 -1
- package/dist/connect/types.d.ts +0 -1
- package/dist/connect/types.d.ts.map +1 -1
- package/dist/connect/types.js +0 -1
- package/dist/connect/types.js.map +1 -1
- package/dist/entity/findMany.js +1 -1
- package/dist/entity/findMany.js.map +1 -1
- package/dist/entity/update.js +1 -1
- package/dist/entity/update.js.map +1 -1
- package/dist/identity/get-verified-identity.d.ts +1 -1
- package/dist/identity/get-verified-identity.d.ts.map +1 -1
- package/dist/identity/get-verified-identity.js +17 -4
- package/dist/identity/get-verified-identity.js.map +1 -1
- package/dist/identity/identity-encryption.js +1 -1
- package/dist/identity/identity-encryption.js.map +1 -1
- package/dist/identity/index.d.ts +1 -1
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +1 -1
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/prove-ownership.d.ts +1 -1
- package/dist/identity/prove-ownership.d.ts.map +1 -1
- package/dist/identity/prove-ownership.js +1 -1
- package/dist/identity/prove-ownership.js.map +1 -1
- package/dist/inboxes/index.d.ts +1 -1
- package/dist/inboxes/index.d.ts.map +1 -1
- package/dist/inboxes/index.js +1 -1
- package/dist/inboxes/index.js.map +1 -1
- package/dist/inboxes/message-validation.d.ts.map +1 -1
- package/dist/inboxes/message-validation.js +2 -2
- package/dist/inboxes/message-validation.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/messages/types.d.ts +1 -1
- package/dist/messages/types.d.ts.map +1 -1
- package/dist/messages/types.js +2 -2
- package/dist/messages/types.js.map +1 -1
- package/dist/space-events/apply-event.d.ts +1 -1
- package/dist/space-events/apply-event.d.ts.map +1 -1
- package/dist/space-events/apply-event.js +1 -1
- package/dist/space-events/apply-event.js.map +1 -1
- package/dist/space-info/decrypt-space-info.d.ts +1 -1
- package/dist/space-info/decrypt-space-info.d.ts.map +1 -1
- package/dist/space-info/decrypt-space-info.js.map +1 -1
- package/dist/store-connect.d.ts.map +1 -1
- package/dist/store-connect.js.map +1 -1
- package/dist/store.d.ts +4 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +23 -3
- package/dist/store.js.map +1 -1
- package/dist/type/type.d.ts +0 -1
- package/dist/type/type.d.ts.map +1 -1
- package/dist/type/type.js +0 -1
- package/dist/type/type.js.map +1 -1
- package/dist/types.d.ts +0 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +6 -3
- package/src/connect/identity-encryption.ts +33 -69
- package/src/connect/login.ts +3 -3
- package/src/connect/parse-auth-params.ts +1 -1
- package/src/connect/smart-account.ts +12 -12
- package/src/connect/types.ts +0 -1
- package/src/entity/findMany.ts +2 -2
- package/src/entity/update.ts +1 -1
- package/src/identity/get-verified-identity.ts +17 -2
- package/src/identity/identity-encryption.ts +1 -1
- package/src/identity/index.ts +1 -1
- package/src/identity/prove-ownership.ts +2 -3
- package/src/inboxes/index.ts +1 -1
- package/src/inboxes/message-validation.ts +4 -0
- package/src/index.ts +1 -1
- package/src/messages/types.ts +1 -1
- package/src/space-events/apply-event.ts +5 -2
- package/src/space-info/decrypt-space-info.ts +1 -7
- package/src/store-connect.ts +1 -1
- package/src/store.ts +39 -9
- package/src/type/type.ts +0 -1
- package/src/types.ts +0 -15
package/src/inboxes/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './create-inbox.js';
|
|
2
2
|
export * from './get-list-inboxes.js';
|
|
3
|
+
export * from './merge-messages.js';
|
|
3
4
|
export * from './message-encryption.js';
|
|
4
5
|
export * from './message-validation.js';
|
|
5
6
|
export * from './prepare-message.js';
|
|
6
7
|
export * from './recover-inbox-creator.js';
|
|
7
8
|
export * from './recover-inbox-message-signer.js';
|
|
8
9
|
export * from './send-message.js';
|
|
9
|
-
export * from './merge-messages.js';
|
|
10
10
|
export * from './types.js';
|
|
@@ -24,6 +24,8 @@ export const validateSpaceInboxMessage = async (
|
|
|
24
24
|
const signer = recoverSpaceInboxMessageSigner(message, spaceId, inbox.inboxId);
|
|
25
25
|
const verifiedIdentity = await Identity.getVerifiedIdentity(
|
|
26
26
|
message.authorAccountAddress,
|
|
27
|
+
signer,
|
|
28
|
+
null,
|
|
27
29
|
syncServerUri,
|
|
28
30
|
chain,
|
|
29
31
|
rpcUrl,
|
|
@@ -62,6 +64,8 @@ export const validateAccountInboxMessage = async (
|
|
|
62
64
|
const signer = recoverAccountInboxMessageSigner(message, accountAddress, inbox.inboxId);
|
|
63
65
|
const verifiedIdentity = await Identity.getVerifiedIdentity(
|
|
64
66
|
message.authorAccountAddress,
|
|
67
|
+
signer,
|
|
68
|
+
null,
|
|
65
69
|
syncServerUri,
|
|
66
70
|
chain,
|
|
67
71
|
rpcUrl,
|
package/src/index.ts
CHANGED
|
@@ -6,8 +6,8 @@ export * as Key from './key/index.js';
|
|
|
6
6
|
export * as Messages from './messages/index.js';
|
|
7
7
|
export * as SpaceEvents from './space-events/index.js';
|
|
8
8
|
export * as SpaceInfo from './space-info/index.js';
|
|
9
|
-
export * as StoreConnect from './store-connect.js';
|
|
10
9
|
export * from './store.js';
|
|
10
|
+
export * as StoreConnect from './store-connect.js';
|
|
11
11
|
export * as Type from './type/type.js';
|
|
12
12
|
export * from './types.js';
|
|
13
13
|
export * as Utils from './utils/index.js';
|
package/src/messages/types.ts
CHANGED
|
@@ -245,7 +245,6 @@ export const RequestConnectCreateAppIdentity = Schema.Struct({
|
|
|
245
245
|
address: Schema.String,
|
|
246
246
|
accountAddress: Schema.String,
|
|
247
247
|
ciphertext: Schema.String,
|
|
248
|
-
nonce: Schema.String,
|
|
249
248
|
signaturePublicKey: Schema.String,
|
|
250
249
|
encryptionPublicKey: Schema.String,
|
|
251
250
|
accountProof: Schema.String,
|
|
@@ -450,6 +449,7 @@ export const ResponseIdentity = Schema.Struct({
|
|
|
450
449
|
encryptionPublicKey: Schema.String,
|
|
451
450
|
accountProof: Schema.String,
|
|
452
451
|
keyProof: Schema.String,
|
|
452
|
+
appId: Schema.optional(Schema.String),
|
|
453
453
|
});
|
|
454
454
|
|
|
455
455
|
export type ResponseIdentity = Schema.Schema.Type<typeof ResponseIdentity>;
|
|
@@ -18,7 +18,10 @@ import {
|
|
|
18
18
|
type Params = {
|
|
19
19
|
state: SpaceState | undefined;
|
|
20
20
|
event: SpaceEvent;
|
|
21
|
-
getVerifiedIdentity: (
|
|
21
|
+
getVerifiedIdentity: (
|
|
22
|
+
accountAddress: string,
|
|
23
|
+
publicKey: string,
|
|
24
|
+
) => Effect.Effect<PublicIdentity, InvalidIdentityError>;
|
|
22
25
|
};
|
|
23
26
|
|
|
24
27
|
const decodeSpaceEvent = Schema.decodeUnknownEither(SpaceEvent);
|
|
@@ -50,7 +53,7 @@ export const applyEvent = ({
|
|
|
50
53
|
const authorPublicKey = `0x${signatureInstance.recoverPublicKey(sha256(encodedTransaction)).toHex()}`;
|
|
51
54
|
|
|
52
55
|
return Effect.gen(function* () {
|
|
53
|
-
const identity = yield* getVerifiedIdentity(event.author.accountAddress);
|
|
56
|
+
const identity = yield* getVerifiedIdentity(event.author.accountAddress, authorPublicKey);
|
|
54
57
|
if (authorPublicKey !== identity.signaturePublicKey) {
|
|
55
58
|
yield* Effect.fail(new VerifySignatureError());
|
|
56
59
|
}
|
|
@@ -6,13 +6,7 @@ import { SpaceInfoContent } from './types.js';
|
|
|
6
6
|
|
|
7
7
|
const decodeSpaceInfoContent = Schema.decodeSync(SpaceInfoContent);
|
|
8
8
|
|
|
9
|
-
export const decryptSpaceInfo = ({
|
|
10
|
-
spaceInfo,
|
|
11
|
-
secretKey,
|
|
12
|
-
}: {
|
|
13
|
-
spaceInfo: Uint8Array;
|
|
14
|
-
secretKey: string;
|
|
15
|
-
}) => {
|
|
9
|
+
export const decryptSpaceInfo = ({ spaceInfo, secretKey }: { spaceInfo: Uint8Array; secretKey: string }) => {
|
|
16
10
|
const decrypted = decryptMessage({
|
|
17
11
|
nonceAndCiphertext: spaceInfo,
|
|
18
12
|
secretKey: hexToBytes(secretKey),
|
package/src/store-connect.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyDocumentId, DocHandle, Repo } from '@automerge/automerge-repo';
|
|
2
|
-
import { type Store
|
|
2
|
+
import { createStore, type Store } from '@xstate/store';
|
|
3
3
|
import type { Address } from 'viem';
|
|
4
4
|
import { mergeMessages } from './inboxes/merge-messages.js';
|
|
5
5
|
import type { InboxSenderAuthPolicy } from './inboxes/types.js';
|
package/src/store.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { AnyDocumentId, DocHandle, Repo } from '@automerge/automerge-repo';
|
|
2
|
-
import
|
|
2
|
+
import type { Mapping } from '@graphprotocol/typesync/Mapping';
|
|
3
|
+
import { createStore, type Store } from '@xstate/store';
|
|
3
4
|
import type { PrivateAppIdentity } from './connect/types.js';
|
|
4
5
|
import type { DocumentContent } from './entity/types.js';
|
|
5
6
|
import { mergeMessages } from './inboxes/merge-messages.js';
|
|
6
7
|
import type { InboxSenderAuthPolicy } from './inboxes/types.js';
|
|
7
8
|
import type { Invitation, Updates } from './messages/index.js';
|
|
8
9
|
import type { SpaceEvent, SpaceState } from './space-events/index.js';
|
|
9
|
-
import type { Mapping } from './types.js';
|
|
10
10
|
import { idToAutomergeId } from './utils/automergeId.js';
|
|
11
11
|
|
|
12
12
|
export type InboxMessageStorageEntry = {
|
|
@@ -64,7 +64,8 @@ interface StoreContext {
|
|
|
64
64
|
signaturePublicKey: string;
|
|
65
65
|
accountProof: string;
|
|
66
66
|
keyProof: string;
|
|
67
|
-
|
|
67
|
+
appId: string | null;
|
|
68
|
+
}[];
|
|
68
69
|
};
|
|
69
70
|
authenticated: boolean;
|
|
70
71
|
identity: PrivateAppIdentity | null;
|
|
@@ -104,6 +105,7 @@ type StoreEvent =
|
|
|
104
105
|
signaturePublicKey: string;
|
|
105
106
|
accountProof: string;
|
|
106
107
|
keyProof: string;
|
|
108
|
+
appId: string | null;
|
|
107
109
|
}
|
|
108
110
|
| {
|
|
109
111
|
type: 'setSpaceInbox';
|
|
@@ -291,18 +293,46 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
|
|
|
291
293
|
signaturePublicKey: string;
|
|
292
294
|
accountProof: string;
|
|
293
295
|
keyProof: string;
|
|
296
|
+
appId: string | null;
|
|
294
297
|
},
|
|
295
298
|
) => {
|
|
299
|
+
const existingIdentity = context.identities[event.accountAddress]?.find(
|
|
300
|
+
(identity) => identity.signaturePublicKey === event.signaturePublicKey,
|
|
301
|
+
);
|
|
302
|
+
if (existingIdentity) {
|
|
303
|
+
return context;
|
|
304
|
+
}
|
|
305
|
+
if (context.identities[event.accountAddress]) {
|
|
306
|
+
return {
|
|
307
|
+
...context,
|
|
308
|
+
identities: {
|
|
309
|
+
...context.identities,
|
|
310
|
+
[event.accountAddress]: [
|
|
311
|
+
...context.identities[event.accountAddress],
|
|
312
|
+
{
|
|
313
|
+
encryptionPublicKey: event.encryptionPublicKey,
|
|
314
|
+
signaturePublicKey: event.signaturePublicKey,
|
|
315
|
+
accountProof: event.accountProof,
|
|
316
|
+
keyProof: event.keyProof,
|
|
317
|
+
appId: event.appId,
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
}
|
|
296
323
|
return {
|
|
297
324
|
...context,
|
|
298
325
|
identities: {
|
|
299
326
|
...context.identities,
|
|
300
|
-
[event.accountAddress]:
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
327
|
+
[event.accountAddress]: [
|
|
328
|
+
{
|
|
329
|
+
encryptionPublicKey: event.encryptionPublicKey,
|
|
330
|
+
signaturePublicKey: event.signaturePublicKey,
|
|
331
|
+
accountProof: event.accountProof,
|
|
332
|
+
keyProof: event.keyProof,
|
|
333
|
+
appId: event.appId,
|
|
334
|
+
},
|
|
335
|
+
],
|
|
306
336
|
},
|
|
307
337
|
};
|
|
308
338
|
},
|
package/src/type/type.ts
CHANGED
|
@@ -8,7 +8,6 @@ export const Number = Schema.Number;
|
|
|
8
8
|
export const Checkbox = Schema.Boolean;
|
|
9
9
|
// biome-ignore lint/suspicious/noShadowRestrictedNames: is part of a namespaces module and therefor ok
|
|
10
10
|
export const Date = Schema.Date;
|
|
11
|
-
export const Url = Schema.URL;
|
|
12
11
|
export const Point = Schema.transform(Schema.String, Schema.Array(Number), {
|
|
13
12
|
strict: true,
|
|
14
13
|
decode: (str: string) => {
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Id as Grc20Id } from '@graphprotocol/grc-20';
|
|
2
1
|
import * as Data from 'effect/Data';
|
|
3
2
|
import * as Schema from 'effect/Schema';
|
|
4
3
|
|
|
@@ -49,17 +48,3 @@ export class FailedToParseConnectAuthUrl extends Data.TaggedError('FailedToParse
|
|
|
49
48
|
export class FailedToParseAuthCallbackUrl extends Data.TaggedError('FailedToParseAuthCallbackUrl')<{
|
|
50
49
|
message: string;
|
|
51
50
|
}> {}
|
|
52
|
-
|
|
53
|
-
export type MappingEntry = {
|
|
54
|
-
typeIds: Grc20Id.Id[];
|
|
55
|
-
properties?: {
|
|
56
|
-
[key: string]: Grc20Id.Id;
|
|
57
|
-
};
|
|
58
|
-
relations?: {
|
|
59
|
-
[key: string]: Grc20Id.Id;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export type Mapping = {
|
|
64
|
-
[key: string]: MappingEntry;
|
|
65
|
-
};
|