@graphprotocol/hypergraph 0.0.14 → 0.2.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/Entity.d.ts +69 -0
- package/dist/Entity.d.ts.map +1 -0
- package/dist/Entity.js +174 -0
- package/dist/Entity.js.map +1 -0
- 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/create-identity-keys.d.ts +3 -0
- package/dist/identity/create-identity-keys.d.ts.map +1 -0
- package/dist/identity/create-identity-keys.js +20 -0
- package/dist/identity/create-identity-keys.js.map +1 -0
- 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/login.d.ts +38 -0
- package/dist/identity/login.d.ts.map +1 -0
- package/dist/identity/login.js +241 -0
- package/dist/identity/login.js.map +1 -0
- 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 +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mapping/Mapping.d.ts +418 -0
- package/dist/mapping/Mapping.d.ts.map +1 -0
- package/dist/mapping/Mapping.js +554 -0
- package/dist/mapping/Mapping.js.map +1 -0
- package/dist/mapping/Utils.d.ts +74 -0
- package/dist/mapping/Utils.d.ts.map +1 -0
- package/dist/mapping/Utils.js +144 -0
- package/dist/mapping/Utils.js.map +1 -0
- package/dist/mapping/index.d.ts +3 -0
- package/dist/mapping/index.d.ts.map +1 -0
- package/dist/mapping/index.js +3 -0
- package/dist/mapping/index.js.map +1 -0
- 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/dist/utils/hasArrayField.d.ts +2 -0
- package/dist/utils/hasArrayField.d.ts.map +1 -0
- package/dist/utils/hasArrayField.js +5 -0
- package/dist/utils/hasArrayField.js.map +1 -0
- package/package.json +4 -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 +2 -1
- package/src/mapping/Mapping.ts +771 -0
- package/src/mapping/Utils.ts +156 -0
- package/src/mapping/index.ts +2 -0
- 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/dist/type/type.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export declare const Text: typeof Schema.String;
|
|
|
4
4
|
export declare const Number: typeof Schema.Number;
|
|
5
5
|
export declare const Checkbox: typeof Schema.Boolean;
|
|
6
6
|
export declare const Date: typeof Schema.Date;
|
|
7
|
-
export declare const Url: typeof Schema.URL;
|
|
8
7
|
export declare const Point: Schema.transform<typeof Schema.String, Schema.Array$<typeof Schema.Number>>;
|
|
9
8
|
export declare const Relation: <S extends AnyNoContext>(schema: S) => import("../entity/variant-schema.js").Field<{
|
|
10
9
|
readonly select: Schema.Schema<ReadonlyArray<EntityWithRelation<S>>>;
|
package/dist/type/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/type/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE3E,eAAO,MAAM,IAAI,sBAAgB,CAAC;AAElC,eAAO,MAAM,MAAM,sBAAgB,CAAC;AACpC,eAAO,MAAM,QAAQ,uBAAiB,CAAC;AAEvC,eAAO,MAAM,IAAI,oBAAc,CAAC;AAChC,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/type/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE3E,eAAO,MAAM,IAAI,sBAAgB,CAAC;AAElC,eAAO,MAAM,MAAM,sBAAgB,CAAC;AACpC,eAAO,MAAM,QAAQ,uBAAiB,CAAC;AAEvC,eAAO,MAAM,IAAI,oBAAc,CAAC;AAChC,eAAO,MAAM,KAAK,6EAMhB,CAAC;AAEH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,YAAY,EAAE,QAAQ,CAAC;qBAEX,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;;;EAKjG,CAAC"}
|
package/dist/type/type.js
CHANGED
|
@@ -6,7 +6,6 @@ export const Number = Schema.Number;
|
|
|
6
6
|
export const Checkbox = Schema.Boolean;
|
|
7
7
|
// biome-ignore lint/suspicious/noShadowRestrictedNames: is part of a namespaces module and therefor ok
|
|
8
8
|
export const Date = Schema.Date;
|
|
9
|
-
export const Url = Schema.URL;
|
|
10
9
|
export const Point = /*#__PURE__*/Schema.transform(Schema.String, /*#__PURE__*/Schema.Array(Number), {
|
|
11
10
|
strict: true,
|
|
12
11
|
decode: str => {
|
package/dist/type/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","names":["Schema","Field","Text","String","Number","Checkbox","Boolean","Date","
|
|
1
|
+
{"version":3,"file":"type.js","names":["Schema","Field","Text","String","Number","Checkbox","Boolean","Date","Point","transform","Array","strict","decode","str","split","map","n","globalThis","encode","points","join","Relation","schema","relationSchema","select","insert","optional","update","Undefined"],"sources":["../../src/type/type.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,SAASC,KAAK,QAAQ,qBAAqB;AAG3C,OAAO,MAAMC,IAAI,GAAGF,MAAM,CAACG,MAAM;AACjC;AACA,OAAO,MAAMC,MAAM,GAAGJ,MAAM,CAACI,MAAM;AACnC,OAAO,MAAMC,QAAQ,GAAGL,MAAM,CAACM,OAAO;AACtC;AACA,OAAO,MAAMC,IAAI,GAAGP,MAAM,CAACO,IAAI;AAC/B,OAAO,MAAMC,KAAK,gBAAGR,MAAM,CAACS,SAAS,CAACT,MAAM,CAACG,MAAM,eAAEH,MAAM,CAACU,KAAK,CAACN,MAAM,CAAC,EAAE;EACzEO,MAAM,EAAE,IAAI;EACZC,MAAM,EAAGC,GAAW,IAAI;IACtB,OAAOA,GAAG,CAACC,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAEC,CAAS,IAAKC,UAAU,CAACb,MAAM,CAACY,CAAC,CAAC,CAAC;EAChE,CAAC;EACDE,MAAM,EAAGC,MAAyB,IAAKA,MAAM,CAACC,IAAI,CAAC,GAAG;CACvD,CAAC;AAEF,OAAO,MAAMC,QAAQ,GAA4BC,MAAS,IAAI;EAC5D,MAAMC,cAAc,GAAGtB,KAAK,CAAC;IAC3BuB,MAAM,EAAExB,MAAM,CAACU,KAAK,CAACY,MAAM,CAAmE;IAC9FG,MAAM,EAAEzB,MAAM,CAAC0B,QAAQ,CAAC1B,MAAM,CAACU,KAAK,CAACV,MAAM,CAACG,MAAM,CAAC,CAAC;IACpDwB,MAAM,EAAE3B,MAAM,CAAC4B;GAChB,CAAC;EACF,OAAOL,cAAc;AACvB,CAAC","ignoreList":[]}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Id as Grc20Id } from '@graphprotocol/grc-20';
|
|
2
1
|
import * as Schema from 'effect/Schema';
|
|
3
2
|
export declare const SignatureWithRecovery: Schema.Struct<{
|
|
4
3
|
hex: typeof Schema.String;
|
|
@@ -64,17 +63,5 @@ export declare class FailedToParseAuthCallbackUrl extends FailedToParseAuthCallb
|
|
|
64
63
|
message: string;
|
|
65
64
|
}> {
|
|
66
65
|
}
|
|
67
|
-
export type MappingEntry = {
|
|
68
|
-
typeIds: Grc20Id.Id[];
|
|
69
|
-
properties?: {
|
|
70
|
-
[key: string]: Grc20Id.Id;
|
|
71
|
-
};
|
|
72
|
-
relations?: {
|
|
73
|
-
[key: string]: Grc20Id.Id;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
export type Mapping = {
|
|
77
|
-
[key: string]: MappingEntry;
|
|
78
|
-
};
|
|
79
66
|
export {};
|
|
80
67
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,qBAAqB;;;EAGhC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAErF,eAAO,MAAM,kBAAkB;;;;EAI7B,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE/E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;EAahC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAErF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;EAIvC,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,4BAA4B,CAAC,CAAC;;;;AAEnG,qBAAa,2BAA4B,SAAQ,iCAAgD;IAC/F,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;CAAG;;;;AAEL,qBAAa,4BAA6B,SAAQ,kCAAiD;IACjG,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;CAAG"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["Data","Schema","SignatureWithRecovery","Struct","hex","String","recovery","Number","ConnectAuthPayload","expiry","encryptionPublicKey","appId","ConnectCallbackResult","appIdentityAddress","appIdentityAddressPrivateKey","accountAddress","permissionId","signaturePublicKey","signaturePrivateKey","encryptionPrivateKey","sessionToken","sessionTokenExpires","Date","privateSpaces","Array","id","publicSpaces","ConnectCallbackDecryptedData","fields","FailedToParseConnectAuthUrl","TaggedError","FailedToParseAuthCallbackUrl"],"sources":["../src/types.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","names":["Data","Schema","SignatureWithRecovery","Struct","hex","String","recovery","Number","ConnectAuthPayload","expiry","encryptionPublicKey","appId","ConnectCallbackResult","appIdentityAddress","appIdentityAddressPrivateKey","accountAddress","permissionId","signaturePublicKey","signaturePrivateKey","encryptionPrivateKey","sessionToken","sessionTokenExpires","Date","privateSpaces","Array","id","publicSpaces","ConnectCallbackDecryptedData","fields","FailedToParseConnectAuthUrl","TaggedError","FailedToParseAuthCallbackUrl"],"sources":["../src/types.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,MAAMC,qBAAqB,gBAAGD,MAAM,CAACE,MAAM,CAAC;EACjDC,GAAG,EAAEH,MAAM,CAACI,MAAM;EAClBC,QAAQ,EAAEL,MAAM,CAACM;CAClB,CAAC;AAIF,OAAO,MAAMC,kBAAkB,gBAAGP,MAAM,CAACE,MAAM,CAAC;EAC9CM,MAAM,EAAER,MAAM,CAACM,MAAM;EACrBG,mBAAmB,EAAET,MAAM,CAACI,MAAM;EAClCM,KAAK,EAAEV,MAAM,CAACI;CACf,CAAC;AAIF,OAAO,MAAMO,qBAAqB,gBAAGX,MAAM,CAACE,MAAM,CAAC;EACjDU,kBAAkB,EAAEZ,MAAM,CAACI,MAAM;EACjCS,4BAA4B,EAAEb,MAAM,CAACI,MAAM;EAC3CU,cAAc,EAAEd,MAAM,CAACI,MAAM;EAC7BW,YAAY,EAAEf,MAAM,CAACI,MAAM;EAC3BY,kBAAkB,EAAEhB,MAAM,CAACI,MAAM;EACjCa,mBAAmB,EAAEjB,MAAM,CAACI,MAAM;EAClCK,mBAAmB,EAAET,MAAM,CAACI,MAAM;EAClCc,oBAAoB,EAAElB,MAAM,CAACI,MAAM;EACnCe,YAAY,EAAEnB,MAAM,CAACI,MAAM;EAC3BgB,mBAAmB,EAAEpB,MAAM,CAACqB,IAAI;EAChCC,aAAa,eAAEtB,MAAM,CAACuB,KAAK,cAACvB,MAAM,CAACE,MAAM,CAAC;IAAEsB,EAAE,EAAExB,MAAM,CAACI;EAAM,CAAE,CAAC,CAAC;EACjEqB,YAAY,eAAEzB,MAAM,CAACuB,KAAK,cAACvB,MAAM,CAACE,MAAM,CAAC;IAAEsB,EAAE,EAAExB,MAAM,CAACI;EAAM,CAAE,CAAC;CAChE,CAAC;AAIF,OAAO,MAAMsB,4BAA4B,gBAAG1B,MAAM,CAACE,MAAM,CAAC;EACxD,GAAGS,qBAAqB,CAACgB,MAAM;EAC/BP,mBAAmB,EAAEpB,MAAM,CAACM,MAAM;EAClCE,MAAM,EAAER,MAAM,CAACM;CAChB,CAAC;AAIF,OAAM,MAAOsB,2BAA4B,sBAAQ7B,IAAI,CAAC8B,WAAW,CAAC,6BAA6B,CAE7F;AAEF,OAAM,MAAOC,4BAA6B,sBAAQ/B,IAAI,CAAC8B,WAAW,CAAC,8BAA8B,CAE/F","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasArrayField.d.ts","sourceRoot":"","sources":["../../src/utils/hasArrayField.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,KAAK,OAAO,EAAE,KAAK,MAAM,KAAG,GAAG,IAAI,GAAG,CAAC,IAAI,MAAM,GAAG,MAAM,EAAE,GAGzF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasArrayField.js","names":["hasArrayField","obj","key","Array","isArray"],"sources":["../../src/utils/hasArrayField.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,MAAMA,aAAa,GAAGA,CAACC,GAAY,EAAEC,GAAW,KAAwC;EAC7F;EACA,OAAOD,GAAG,KAAK,IAAI,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAIC,GAAG,IAAID,GAAG,IAAIE,KAAK,CAACC,OAAO,CAAEH,GAAW,CAACC,GAAG,CAAC,CAAC;AAClG,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphprotocol/hypergraph",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "SDK for building performant, type-safe, local-first dapps on top of The Graph ecosystem knowledge graphs.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"main": "./dist/index.js",
|
|
13
13
|
"module": "./dist/index.js",
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
|
+
"sideEffects": [],
|
|
15
16
|
"exports": {
|
|
16
17
|
".": "./dist/index.js",
|
|
17
18
|
"./connect": "./dist/connect/index.js",
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
"./identity": "./dist/identity/index.js",
|
|
22
23
|
"./inboxes": "./dist/inboxes/index.js",
|
|
23
24
|
"./key": "./dist/key/index.js",
|
|
25
|
+
"./mapping": "./dist/mapping/index.js",
|
|
24
26
|
"./messages": "./dist/messages/index.js",
|
|
25
27
|
"./space-events": "./dist/space-events/index.js",
|
|
26
28
|
"./space-info": "./dist/space-info/index.js",
|
|
@@ -28,7 +30,6 @@
|
|
|
28
30
|
"./store-connect": "./dist/store-connect.js",
|
|
29
31
|
"./types": "./dist/types.js"
|
|
30
32
|
},
|
|
31
|
-
"sideEffects": [],
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"@automerge/automerge": "^2.2.9",
|
|
34
35
|
"@automerge/automerge-repo": "^2.0.6",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"@serenity-kit/noble-sodium": "^0.2.1",
|
|
43
44
|
"@xstate/store": "^3.5.1",
|
|
44
45
|
"bs58check": "^4.0.0",
|
|
45
|
-
"effect": "^3.
|
|
46
|
+
"effect": "^3.17.1",
|
|
46
47
|
"permissionless": "^0.2.47",
|
|
47
48
|
"siwe": "^3.0.0",
|
|
48
49
|
"uuid": "^11.1.0",
|
|
@@ -2,12 +2,17 @@ import { gcm } from '@noble/ciphers/aes';
|
|
|
2
2
|
import { randomBytes } from '@noble/ciphers/webcrypto';
|
|
3
3
|
import { hkdf } from '@noble/hashes/hkdf';
|
|
4
4
|
import { sha256 } from '@noble/hashes/sha256';
|
|
5
|
+
import { cryptoBoxSeal, cryptoBoxSealOpen } from '@serenity-kit/noble-sodium';
|
|
5
6
|
import type { Hex } from 'viem';
|
|
6
7
|
import { verifyMessage } from 'viem';
|
|
7
|
-
|
|
8
8
|
import { bytesToHex, canonicalize, hexToBytes } from '../utils/index.js';
|
|
9
9
|
import type { IdentityKeys, PrivateAppIdentity, Signer } from './types.js';
|
|
10
10
|
|
|
11
|
+
export type AppIdentityForEncryption = Omit<
|
|
12
|
+
PrivateAppIdentity,
|
|
13
|
+
'sessionToken' | 'sessionTokenExpires' | 'accountAddress'
|
|
14
|
+
>;
|
|
15
|
+
|
|
11
16
|
// Adapted from the XMTP approach to encrypt keys
|
|
12
17
|
// See: https://github.com/xmtp/xmtp-js/blob/8d6e5a65813902926baac8150a648587acbaad92/sdks/js-sdk/src/keystore/providers/NetworkKeyManager.ts#L79-L116
|
|
13
18
|
// (We reimplement their encrypt/decrypt functions using noble).
|
|
@@ -113,7 +118,7 @@ export const decryptIdentity = async (signer: Signer, ciphertext: string, nonce:
|
|
|
113
118
|
let keysMsg: Uint8Array;
|
|
114
119
|
try {
|
|
115
120
|
keysMsg = await decrypt(ciphertext, secretKey);
|
|
116
|
-
} catch (
|
|
121
|
+
} catch (_e) {
|
|
117
122
|
// See https://github.com/xmtp/xmtp-js/blob/8d6e5a65813902926baac8150a648587acbaad92/sdks/js-sdk/src/keystore/providers/NetworkKeyManager.ts#L142-L146
|
|
118
123
|
if (secretKey.length !== 65) {
|
|
119
124
|
throw new Error('Expected 65 bytes before trying a different recovery byte');
|
|
@@ -134,86 +139,45 @@ export const decryptIdentity = async (signer: Signer, ciphertext: string, nonce:
|
|
|
134
139
|
};
|
|
135
140
|
|
|
136
141
|
export const encryptAppIdentity = async (
|
|
137
|
-
|
|
138
|
-
appIdentityAddress: string,
|
|
139
|
-
appIdentityAddressPrivateKey: string,
|
|
140
|
-
permissionId: string,
|
|
142
|
+
appIdentity: AppIdentityForEncryption,
|
|
141
143
|
keys: IdentityKeys,
|
|
142
|
-
): Promise<{ ciphertext: string
|
|
143
|
-
const nonce = randomBytes(32);
|
|
144
|
-
const message = signatureMessage(nonce);
|
|
145
|
-
const signature = (await signer.signMessage(message)) as Hex;
|
|
146
|
-
|
|
147
|
-
// Check that the signature is valid
|
|
148
|
-
const valid = await verifyMessage({
|
|
149
|
-
address: (await signer.getAddress()) as Hex,
|
|
150
|
-
message,
|
|
151
|
-
signature,
|
|
152
|
-
});
|
|
153
|
-
if (!valid) {
|
|
154
|
-
throw new Error('Invalid signature');
|
|
155
|
-
}
|
|
156
|
-
const secretKey = hexToBytes(signature);
|
|
144
|
+
): Promise<{ ciphertext: string }> => {
|
|
157
145
|
// We use a simple plaintext encoding:
|
|
158
146
|
// Hex keys separated by newlines
|
|
159
147
|
const keysTxt = [
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
permissionId,
|
|
148
|
+
appIdentity.encryptionPublicKey,
|
|
149
|
+
appIdentity.encryptionPrivateKey,
|
|
150
|
+
appIdentity.signaturePublicKey,
|
|
151
|
+
appIdentity.signaturePrivateKey,
|
|
152
|
+
appIdentity.address,
|
|
153
|
+
appIdentity.addressPrivateKey,
|
|
154
|
+
appIdentity.permissionId,
|
|
167
155
|
].join('\n');
|
|
168
156
|
const keysMsg = new TextEncoder().encode(keysTxt);
|
|
169
|
-
const ciphertext =
|
|
170
|
-
|
|
157
|
+
const ciphertext = bytesToHex(
|
|
158
|
+
cryptoBoxSeal({
|
|
159
|
+
message: keysMsg,
|
|
160
|
+
publicKey: hexToBytes(keys.encryptionPublicKey),
|
|
161
|
+
}),
|
|
162
|
+
);
|
|
163
|
+
return { ciphertext };
|
|
171
164
|
};
|
|
172
165
|
|
|
173
|
-
export const decryptAppIdentity = async (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const signature = (await signer.signMessage(message)) as Hex;
|
|
180
|
-
|
|
181
|
-
// Check that the signature is valid
|
|
182
|
-
const valid = await verifyMessage({
|
|
183
|
-
address: (await signer.getAddress()) as Hex,
|
|
184
|
-
message,
|
|
185
|
-
signature,
|
|
166
|
+
export const decryptAppIdentity = async (ciphertext: string, keys: IdentityKeys): Promise<AppIdentityForEncryption> => {
|
|
167
|
+
const ciphertextBytes = hexToBytes(ciphertext);
|
|
168
|
+
const keysMsg = cryptoBoxSealOpen({
|
|
169
|
+
ciphertext: ciphertextBytes,
|
|
170
|
+
privateKey: hexToBytes(keys.encryptionPrivateKey),
|
|
171
|
+
publicKey: hexToBytes(keys.encryptionPublicKey),
|
|
186
172
|
});
|
|
187
|
-
if (!valid) {
|
|
188
|
-
throw new Error('Invalid signature');
|
|
189
|
-
}
|
|
190
|
-
const secretKey = hexToBytes(signature);
|
|
191
|
-
let keysMsg: Uint8Array;
|
|
192
|
-
try {
|
|
193
|
-
keysMsg = await decrypt(ciphertext, secretKey);
|
|
194
|
-
} catch (e) {
|
|
195
|
-
// See https://github.com/xmtp/xmtp-js/blob/8d6e5a65813902926baac8150a648587acbaad92/sdks/js-sdk/src/keystore/providers/NetworkKeyManager.ts#L142-L146
|
|
196
|
-
if (secretKey.length !== 65) {
|
|
197
|
-
throw new Error('Expected 65 bytes before trying a different recovery byte');
|
|
198
|
-
}
|
|
199
|
-
// Try the other version of recovery byte, either +27 or -27
|
|
200
|
-
const lastByte = secretKey[secretKey.length - 1];
|
|
201
|
-
let newSecret = secretKey.slice(0, secretKey.length - 1);
|
|
202
|
-
if (lastByte < 27) {
|
|
203
|
-
newSecret = new Uint8Array([...newSecret, lastByte + 27]);
|
|
204
|
-
} else {
|
|
205
|
-
newSecret = new Uint8Array([...newSecret, lastByte - 27]);
|
|
206
|
-
}
|
|
207
|
-
keysMsg = await decrypt(ciphertext, newSecret);
|
|
208
|
-
}
|
|
209
173
|
const keysTxt = new TextDecoder().decode(keysMsg);
|
|
210
174
|
const [
|
|
211
175
|
encryptionPublicKey,
|
|
212
176
|
encryptionPrivateKey,
|
|
213
177
|
signaturePublicKey,
|
|
214
178
|
signaturePrivateKey,
|
|
215
|
-
|
|
216
|
-
|
|
179
|
+
address,
|
|
180
|
+
addressPrivateKey,
|
|
217
181
|
permissionId,
|
|
218
182
|
] = keysTxt.split('\n');
|
|
219
183
|
return {
|
|
@@ -221,8 +185,8 @@ export const decryptAppIdentity = async (
|
|
|
221
185
|
encryptionPrivateKey,
|
|
222
186
|
signaturePublicKey,
|
|
223
187
|
signaturePrivateKey,
|
|
224
|
-
address
|
|
225
|
-
addressPrivateKey
|
|
188
|
+
address,
|
|
189
|
+
addressPrivateKey,
|
|
226
190
|
permissionId,
|
|
227
191
|
};
|
|
228
192
|
};
|
package/src/connect/login.ts
CHANGED
|
@@ -9,17 +9,17 @@ import { loadAccountAddress, storeAccountAddress, storeKeys } from './auth-stora
|
|
|
9
9
|
import { createIdentityKeys } from './create-identity-keys.js';
|
|
10
10
|
import { decryptIdentity, encryptIdentity } from './identity-encryption.js';
|
|
11
11
|
import {
|
|
12
|
-
type SmartAccountParams,
|
|
13
12
|
addSmartAccountOwner,
|
|
14
13
|
getSmartAccountWalletClient,
|
|
15
14
|
isSmartAccountDeployed,
|
|
15
|
+
type SmartAccountParams,
|
|
16
16
|
smartAccountNeedsUpdate,
|
|
17
17
|
updateLegacySmartAccount,
|
|
18
18
|
} from './smart-account.js';
|
|
19
19
|
import type { IdentityKeys, Signer, Storage } from './types.js';
|
|
20
20
|
|
|
21
21
|
export async function identityExists(accountAddress: string, syncServerUri: string) {
|
|
22
|
-
const res = await fetch(new URL(`/identity?accountAddress=${accountAddress}`, syncServerUri), {
|
|
22
|
+
const res = await fetch(new URL(`/connect/identity?accountAddress=${accountAddress}`, syncServerUri), {
|
|
23
23
|
method: 'GET',
|
|
24
24
|
});
|
|
25
25
|
return res.status === 200;
|
|
@@ -27,7 +27,7 @@ export async function identityExists(accountAddress: string, syncServerUri: stri
|
|
|
27
27
|
|
|
28
28
|
export async function signup(
|
|
29
29
|
signer: Signer,
|
|
30
|
-
|
|
30
|
+
_walletClient: WalletClient,
|
|
31
31
|
smartAccountClient: SmartAccountClient,
|
|
32
32
|
accountAddress: Address,
|
|
33
33
|
syncServerUri: string,
|
|
@@ -31,7 +31,7 @@ export const parseAuthParams = (
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
return Effect.succeed({ payload: result.right, redirect, nonce });
|
|
34
|
-
} catch (
|
|
34
|
+
} catch (_error) {
|
|
35
35
|
return Effect.fail(new FailedToParseConnectAuthUrl({ message: 'Failed to parse connect auth payload' }));
|
|
36
36
|
}
|
|
37
37
|
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { MAINNET, TESTNET } from '@graphprotocol/grc-20/contracts';
|
|
2
2
|
import { randomBytes } from '@noble/hashes/utils';
|
|
3
3
|
import {
|
|
4
|
-
OWNABLE_VALIDATOR_ADDRESS,
|
|
5
|
-
RHINESTONE_ATTESTER_ADDRESS,
|
|
6
|
-
type Session,
|
|
7
|
-
SmartSessionMode,
|
|
8
4
|
encodeSmartSessionSignature,
|
|
9
5
|
encodeValidationData,
|
|
10
6
|
encodeValidatorNonce,
|
|
@@ -20,37 +16,41 @@ import {
|
|
|
20
16
|
getUniversalActionPolicy,
|
|
21
17
|
getUsageLimitPolicy,
|
|
22
18
|
getValueLimitPolicy,
|
|
19
|
+
OWNABLE_VALIDATOR_ADDRESS,
|
|
20
|
+
RHINESTONE_ATTESTER_ADDRESS,
|
|
21
|
+
type Session,
|
|
22
|
+
SmartSessionMode,
|
|
23
23
|
} from '@rhinestone/module-sdk';
|
|
24
|
-
import {
|
|
24
|
+
import { createSmartAccountClient, encodeInstallModule, type SmartAccountClient } from 'permissionless';
|
|
25
25
|
import { type ToSafeSmartAccountParameters, toSafeSmartAccount } from 'permissionless/accounts';
|
|
26
26
|
import { getAccountNonce } from 'permissionless/actions';
|
|
27
27
|
import { erc7579Actions } from 'permissionless/actions/erc7579';
|
|
28
28
|
import { createPimlicoClient } from 'permissionless/clients/pimlico';
|
|
29
29
|
import {
|
|
30
|
-
http,
|
|
31
30
|
type AbiFunction,
|
|
32
31
|
type Account,
|
|
33
32
|
type Address,
|
|
34
33
|
type Calls,
|
|
35
34
|
type Chain,
|
|
36
35
|
ContractFunctionExecutionError,
|
|
36
|
+
createPublicClient,
|
|
37
|
+
encodeFunctionData,
|
|
38
|
+
getAbiItem,
|
|
37
39
|
type Hex,
|
|
40
|
+
http,
|
|
38
41
|
type Narrow,
|
|
39
42
|
type PrivateKeyAccount,
|
|
40
43
|
type SignableMessage,
|
|
41
|
-
type WalletClient,
|
|
42
|
-
createPublicClient,
|
|
43
|
-
encodeFunctionData,
|
|
44
|
-
getAbiItem,
|
|
45
44
|
toBytes,
|
|
46
45
|
toFunctionSelector,
|
|
47
46
|
toHex,
|
|
47
|
+
type WalletClient,
|
|
48
48
|
} from 'viem';
|
|
49
49
|
import {
|
|
50
|
-
type UserOperation,
|
|
51
|
-
type WaitForUserOperationReceiptReturnType,
|
|
52
50
|
entryPoint07Address,
|
|
53
51
|
getUserOperationHash,
|
|
52
|
+
type UserOperation,
|
|
53
|
+
type WaitForUserOperationReceiptReturnType,
|
|
54
54
|
} from 'viem/account-abstraction';
|
|
55
55
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
56
56
|
import { bytesToHex } from '../utils/hexBytesAddressUtils.js';
|
package/src/connect/types.ts
CHANGED
package/src/entity/findMany.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as Schema from 'effect/Schema';
|
|
|
3
3
|
import { deepMerge } from '../utils/internal/deep-merge.js';
|
|
4
4
|
import { isRelationField } from '../utils/isRelationField.js';
|
|
5
5
|
import { canonicalize } from '../utils/jsc.js';
|
|
6
|
-
import { type DecodedEntitiesCacheEntry, type QueryEntry
|
|
6
|
+
import { type DecodedEntitiesCacheEntry, decodedEntitiesCache, type QueryEntry } from './decodedEntitiesCache.js';
|
|
7
7
|
import { entityRelationParentsMap } from './entityRelationParentsMap.js';
|
|
8
8
|
import { getEntityRelations } from './getEntityRelations.js';
|
|
9
9
|
import { hasValidTypesProperty } from './hasValidTypesProperty.js';
|
|
@@ -367,7 +367,7 @@ export function findMany<const S extends AnyNoContext>(
|
|
|
367
367
|
decoded.__schema = type;
|
|
368
368
|
filtered.push(decoded);
|
|
369
369
|
}
|
|
370
|
-
} catch (
|
|
370
|
+
} catch (_error) {
|
|
371
371
|
corruptEntityIds.push(id);
|
|
372
372
|
}
|
|
373
373
|
}
|
package/src/entity/update.ts
CHANGED
|
@@ -19,7 +19,7 @@ export const update = <const S extends AnyNoContext>(handle: DocHandle<DocumentC
|
|
|
19
19
|
validate(data);
|
|
20
20
|
|
|
21
21
|
// apply changes to the repo -> updates the existing entity to the repo entities document
|
|
22
|
-
let updated: Schema.Schema.Type<S> | undefined
|
|
22
|
+
let updated: Schema.Schema.Type<S> | undefined;
|
|
23
23
|
handle.change((doc) => {
|
|
24
24
|
if (doc.entities === undefined) {
|
|
25
25
|
return;
|
|
@@ -6,6 +6,8 @@ import { verifyIdentityOwnership } from './prove-ownership.js';
|
|
|
6
6
|
|
|
7
7
|
export const getVerifiedIdentity = async (
|
|
8
8
|
accountAddress: string,
|
|
9
|
+
signaturePublicKey: string | null,
|
|
10
|
+
appId: string | null,
|
|
9
11
|
syncServerUri: string,
|
|
10
12
|
chain: Chain,
|
|
11
13
|
rpcUrl: string,
|
|
@@ -14,8 +16,19 @@ export const getVerifiedIdentity = async (
|
|
|
14
16
|
encryptionPublicKey: string;
|
|
15
17
|
signaturePublicKey: string;
|
|
16
18
|
}> => {
|
|
19
|
+
if (signaturePublicKey && appId) {
|
|
20
|
+
throw new Error('Cannot specify both signaturePublicKey and appId');
|
|
21
|
+
}
|
|
22
|
+
if (!signaturePublicKey && !appId) {
|
|
23
|
+
throw new Error('Must specify either signaturePublicKey or appId');
|
|
24
|
+
}
|
|
17
25
|
const storeState = store.getSnapshot();
|
|
18
|
-
const identity = storeState.context.identities[accountAddress]
|
|
26
|
+
const identity = storeState.context.identities[accountAddress]?.find((identity) => {
|
|
27
|
+
if (signaturePublicKey) {
|
|
28
|
+
return identity.signaturePublicKey === signaturePublicKey;
|
|
29
|
+
}
|
|
30
|
+
return identity.appId === appId;
|
|
31
|
+
});
|
|
19
32
|
if (identity) {
|
|
20
33
|
return {
|
|
21
34
|
accountAddress,
|
|
@@ -23,7 +36,8 @@ export const getVerifiedIdentity = async (
|
|
|
23
36
|
signaturePublicKey: identity.signaturePublicKey,
|
|
24
37
|
};
|
|
25
38
|
}
|
|
26
|
-
const
|
|
39
|
+
const query = signaturePublicKey ? `&signaturePublicKey=${signaturePublicKey}` : `&appId=${appId}`;
|
|
40
|
+
const res = await fetch(`${syncServerUri}/identity?accountAddress=${accountAddress}${query}`);
|
|
27
41
|
if (res.status !== 200) {
|
|
28
42
|
throw new Error('Failed to fetch identity');
|
|
29
43
|
}
|
|
@@ -49,6 +63,7 @@ export const getVerifiedIdentity = async (
|
|
|
49
63
|
signaturePublicKey: resDecoded.signaturePublicKey,
|
|
50
64
|
accountProof: resDecoded.accountProof,
|
|
51
65
|
keyProof: resDecoded.keyProof,
|
|
66
|
+
appId: resDecoded.appId ?? null,
|
|
52
67
|
});
|
|
53
68
|
return {
|
|
54
69
|
accountAddress: resDecoded.accountAddress,
|
|
@@ -119,7 +119,7 @@ export const decryptIdentity = async (
|
|
|
119
119
|
let keysMsg: Uint8Array;
|
|
120
120
|
try {
|
|
121
121
|
keysMsg = await decrypt(ciphertext, secretKey);
|
|
122
|
-
} catch (
|
|
122
|
+
} catch (_e) {
|
|
123
123
|
// See https://github.com/xmtp/xmtp-js/blob/8d6e5a65813902926baac8150a648587acbaad92/sdks/js-sdk/src/keystore/providers/NetworkKeyManager.ts#L142-L146
|
|
124
124
|
if (secretKey.length !== 65) {
|
|
125
125
|
throw new Error('Expected 65 bytes before trying a different recovery byte');
|
package/src/identity/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { http, type Chain, type Hex, createPublicClient, verifyMessage } from 'viem';
|
|
2
|
-
import { privateKeyToAccount } from 'viem/accounts';
|
|
3
|
-
|
|
4
1
|
import type { SmartAccountClient } from 'permissionless';
|
|
2
|
+
import { type Chain, createPublicClient, type Hex, http, verifyMessage } from 'viem';
|
|
3
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
5
4
|
import { publicKeyToAddress } from '../utils/index.js';
|
|
6
5
|
import type { IdentityKeys } from './types.js';
|
|
7
6
|
|
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
|
@@ -3,11 +3,12 @@ export * as Entity from './entity/index.js';
|
|
|
3
3
|
export * as Identity from './identity/index.js';
|
|
4
4
|
export * as Inboxes from './inboxes/index.js';
|
|
5
5
|
export * as Key from './key/index.js';
|
|
6
|
+
export * as Mapping from './mapping/index.js';
|
|
6
7
|
export * as Messages from './messages/index.js';
|
|
7
8
|
export * as SpaceEvents from './space-events/index.js';
|
|
8
9
|
export * as SpaceInfo from './space-info/index.js';
|
|
9
|
-
export * as StoreConnect from './store-connect.js';
|
|
10
10
|
export * from './store.js';
|
|
11
|
+
export * as StoreConnect from './store-connect.js';
|
|
11
12
|
export * as Type from './type/type.js';
|
|
12
13
|
export * from './types.js';
|
|
13
14
|
export * as Utils from './utils/index.js';
|