@opendatalabs/vana-sdk 3.1.0 → 3.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/README.md +2 -1
- package/dist/account/personal-server-lite-owner-binding.cjs +81 -0
- package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -0
- package/dist/account/personal-server-lite-owner-binding.d.ts +30 -0
- package/dist/account/personal-server-lite-owner-binding.js +59 -0
- package/dist/account/personal-server-lite-owner-binding.js.map +1 -0
- package/dist/account/personal-server-lite-owner-binding.test.d.ts +1 -0
- package/dist/account/personal-server-registration.cjs +263 -0
- package/dist/account/personal-server-registration.cjs.map +1 -0
- package/dist/account/personal-server-registration.d.ts +66 -0
- package/dist/account/personal-server-registration.js +240 -0
- package/dist/account/personal-server-registration.js.map +1 -0
- package/dist/account/personal-server-registration.test.d.ts +1 -0
- package/dist/auth/errors.js +1 -1
- package/dist/auth/oauth-client.js +2 -2
- package/dist/auth/web3-signed-builder.js +1 -1
- package/dist/auth/web3-signed.js +3 -3
- package/dist/browser.js +1 -1
- package/dist/chains/definitions.js +1 -1
- package/dist/chains/index.js +1 -1
- package/dist/chains.browser.js +1 -1
- package/dist/chains.js +1 -1
- package/dist/chains.node.js +1 -1
- package/dist/contracts/contractController.js +4 -4
- package/dist/core/client.js +1 -1
- package/dist/crypto/ecies/base.js +3 -3
- package/dist/crypto/ecies/browser.js +1 -1
- package/dist/crypto/ecies/index.js +1 -1
- package/dist/crypto/ecies/interface.js +1 -1
- package/dist/crypto/ecies/node.js +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.js +1 -1
- package/dist/generated/abi/index.js +26 -26
- package/dist/index.browser.d.ts +4 -0
- package/dist/index.browser.js +447 -3
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +464 -5
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +4 -0
- package/dist/index.node.js +447 -3
- package/dist/index.node.js.map +4 -4
- package/dist/node.js +1 -1
- package/dist/platform/browser-only.js +1 -1
- package/dist/platform/browser-safe.js +1 -1
- package/dist/platform/browser.js +6 -6
- package/dist/platform/index.js +4 -4
- package/dist/platform/node.js +8 -8
- package/dist/platform/utils.js +2 -2
- package/dist/platform.browser.js +3 -3
- package/dist/platform.js +4 -4
- package/dist/platform.node.js +4 -4
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +1 -1
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/grants.js +1 -1
- package/dist/protocol/personal-server-lite-owner-binding.cjs +93 -0
- package/dist/protocol/personal-server-lite-owner-binding.cjs.map +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.d.ts +44 -0
- package/dist/protocol/personal-server-lite-owner-binding.js +65 -0
- package/dist/protocol/personal-server-lite-owner-binding.js.map +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +1 -0
- package/dist/protocol/personal-server-registration.cjs +122 -0
- package/dist/protocol/personal-server-registration.cjs.map +1 -0
- package/dist/protocol/personal-server-registration.d.ts +62 -0
- package/dist/protocol/personal-server-registration.js +97 -0
- package/dist/protocol/personal-server-registration.js.map +1 -0
- package/dist/protocol/personal-server-registration.test.d.ts +1 -0
- package/dist/storage/default.js +1 -1
- package/dist/storage/index.js +10 -10
- package/dist/storage/manager.js +1 -1
- package/dist/storage/providers/callback-storage.js +1 -1
- package/dist/storage/providers/dropbox.js +1 -1
- package/dist/storage/providers/google-drive.js +1 -1
- package/dist/storage/providers/ipfs.js +2 -2
- package/dist/storage/providers/pinata.js +1 -1
- package/dist/storage/providers/r2.js +1 -1
- package/dist/storage/providers/vana-storage.js +2 -2
- package/dist/types/index.js +2 -2
- package/dist/types.js +1 -1
- package/package.json +4 -2
package/dist/node.js
CHANGED
package/dist/platform/browser.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getPGPKeyGenParams } from "./shared/pgp-utils";
|
|
2
|
-
import { wrapCryptoError } from "./shared/error-utils";
|
|
3
|
-
import { lazyImport } from "../utils/lazy-import";
|
|
4
|
-
import { WalletKeyEncryptionService } from "../crypto/services/WalletKeyEncryptionService";
|
|
5
|
-
import { parseEncryptedDataBuffer } from "../utils/crypto-utils";
|
|
1
|
+
import { getPGPKeyGenParams } from "./shared/pgp-utils.js";
|
|
2
|
+
import { wrapCryptoError } from "./shared/error-utils.js";
|
|
3
|
+
import { lazyImport } from "../utils/lazy-import.js";
|
|
4
|
+
import { WalletKeyEncryptionService } from "../crypto/services/WalletKeyEncryptionService.js";
|
|
5
|
+
import { parseEncryptedDataBuffer } from "../utils/crypto-utils.js";
|
|
6
6
|
import { toHex, fromHex, stringToBytes, bytesToString, concat } from "viem";
|
|
7
7
|
import * as secp256k1 from "@noble/secp256k1";
|
|
8
|
-
import { BrowserECIESUint8Provider } from "../crypto/ecies/browser";
|
|
8
|
+
import { BrowserECIESUint8Provider } from "../crypto/ecies/browser.js";
|
|
9
9
|
const getOpenPGP = lazyImport(() => import("openpgp"));
|
|
10
10
|
class BrowserCryptoAdapter {
|
|
11
11
|
eciesProvider = new BrowserECIESUint8Provider();
|
package/dist/platform/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { NodePlatformAdapter } from "./node";
|
|
2
|
-
import { BrowserPlatformAdapter } from "./browser";
|
|
1
|
+
import { NodePlatformAdapter } from "./node.js";
|
|
2
|
+
import { BrowserPlatformAdapter } from "./browser.js";
|
|
3
3
|
import {
|
|
4
4
|
detectPlatform,
|
|
5
5
|
createPlatformAdapter,
|
|
6
6
|
createPlatformAdapterFor,
|
|
7
7
|
isPlatformSupported,
|
|
8
8
|
getPlatformCapabilities
|
|
9
|
-
} from "./utils";
|
|
9
|
+
} from "./utils.js";
|
|
10
10
|
import {
|
|
11
11
|
createNodePlatformAdapter,
|
|
12
12
|
createBrowserPlatformAdapter,
|
|
13
13
|
createPlatformAdapterSafe
|
|
14
|
-
} from "./browser-safe";
|
|
14
|
+
} from "./browser-safe.js";
|
|
15
15
|
export {
|
|
16
16
|
BrowserPlatformAdapter,
|
|
17
17
|
NodePlatformAdapter,
|
package/dist/platform/node.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { getPGPKeyGenParams } from "./shared/pgp-utils";
|
|
2
|
-
import { wrapCryptoError } from "./shared/error-utils";
|
|
3
|
-
import { streamToUint8Array } from "./shared/stream-utils";
|
|
4
|
-
import { lazyImport } from "../utils/lazy-import";
|
|
5
|
-
import { WalletKeyEncryptionService } from "../crypto/services/WalletKeyEncryptionService";
|
|
1
|
+
import { getPGPKeyGenParams } from "./shared/pgp-utils.js";
|
|
2
|
+
import { wrapCryptoError } from "./shared/error-utils.js";
|
|
3
|
+
import { streamToUint8Array } from "./shared/stream-utils.js";
|
|
4
|
+
import { lazyImport } from "../utils/lazy-import.js";
|
|
5
|
+
import { WalletKeyEncryptionService } from "../crypto/services/WalletKeyEncryptionService.js";
|
|
6
6
|
import {
|
|
7
7
|
processWalletPrivateKey,
|
|
8
8
|
parseEncryptedDataBuffer,
|
|
9
9
|
processWalletPublicKey
|
|
10
|
-
} from "../utils/crypto-utils";
|
|
10
|
+
} from "../utils/crypto-utils.js";
|
|
11
11
|
const getOpenPGP = lazyImport(() => import("openpgp"));
|
|
12
|
-
import { NodeECIESUint8Provider } from "../crypto/ecies/node";
|
|
13
|
-
import { ECIESError } from "../crypto/ecies/interface";
|
|
12
|
+
import { NodeECIESUint8Provider } from "../crypto/ecies/node.js";
|
|
13
|
+
import { ECIESError } from "../crypto/ecies/interface.js";
|
|
14
14
|
import { randomBytes } from "crypto";
|
|
15
15
|
import secp256k1Import from "secp256k1";
|
|
16
16
|
class NodeCryptoAdapter {
|
package/dist/platform/utils.js
CHANGED
|
@@ -20,7 +20,7 @@ async function createPlatformAdapter() {
|
|
|
20
20
|
const { NodePlatformAdapter } = await import(moduleName);
|
|
21
21
|
return new NodePlatformAdapter();
|
|
22
22
|
} else {
|
|
23
|
-
const { BrowserPlatformAdapter } = await import("./browser");
|
|
23
|
+
const { BrowserPlatformAdapter } = await import("./browser.js");
|
|
24
24
|
return new BrowserPlatformAdapter();
|
|
25
25
|
}
|
|
26
26
|
} catch (error) {
|
|
@@ -41,7 +41,7 @@ async function createPlatformAdapterFor(platformType) {
|
|
|
41
41
|
const { NodePlatformAdapter } = await import(moduleName);
|
|
42
42
|
return new NodePlatformAdapter();
|
|
43
43
|
} else {
|
|
44
|
-
const { BrowserPlatformAdapter } = await import("./browser");
|
|
44
|
+
const { BrowserPlatformAdapter } = await import("./browser.js");
|
|
45
45
|
return new BrowserPlatformAdapter();
|
|
46
46
|
}
|
|
47
47
|
} catch (error) {
|
package/dist/platform.browser.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { BrowserPlatformAdapter } from "./platform/browser";
|
|
1
|
+
import { BrowserPlatformAdapter } from "./platform/browser.js";
|
|
2
2
|
import {
|
|
3
3
|
createBrowserPlatformAdapter,
|
|
4
4
|
createPlatformAdapterSafe
|
|
5
|
-
} from "./platform/browser-only";
|
|
5
|
+
} from "./platform/browser-only.js";
|
|
6
6
|
import {
|
|
7
7
|
detectPlatform,
|
|
8
8
|
isPlatformSupported,
|
|
9
9
|
getPlatformCapabilities
|
|
10
|
-
} from "./platform/utils";
|
|
10
|
+
} from "./platform/utils.js";
|
|
11
11
|
export {
|
|
12
12
|
BrowserPlatformAdapter,
|
|
13
13
|
createBrowserPlatformAdapter,
|
package/dist/platform.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { BrowserPlatformAdapter } from "./platform/browser";
|
|
2
|
-
import { NodePlatformAdapter } from "./platform/node";
|
|
1
|
+
import { BrowserPlatformAdapter } from "./platform/browser.js";
|
|
2
|
+
import { NodePlatformAdapter } from "./platform/node.js";
|
|
3
3
|
import {
|
|
4
4
|
detectPlatform,
|
|
5
5
|
createPlatformAdapter,
|
|
6
6
|
createPlatformAdapterFor,
|
|
7
7
|
isPlatformSupported,
|
|
8
8
|
getPlatformCapabilities
|
|
9
|
-
} from "./platform/utils";
|
|
9
|
+
} from "./platform/utils.js";
|
|
10
10
|
import {
|
|
11
11
|
createNodePlatformAdapter,
|
|
12
12
|
createBrowserPlatformAdapter,
|
|
13
13
|
createPlatformAdapterSafe
|
|
14
|
-
} from "./platform/browser-safe";
|
|
14
|
+
} from "./platform/browser-safe.js";
|
|
15
15
|
export {
|
|
16
16
|
BrowserPlatformAdapter,
|
|
17
17
|
NodePlatformAdapter,
|
package/dist/platform.node.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { BrowserPlatformAdapter } from "./platform/browser";
|
|
2
|
-
import { NodePlatformAdapter } from "./platform/node";
|
|
1
|
+
import { BrowserPlatformAdapter } from "./platform/browser.js";
|
|
2
|
+
import { NodePlatformAdapter } from "./platform/node.js";
|
|
3
3
|
import {
|
|
4
4
|
detectPlatform,
|
|
5
5
|
createPlatformAdapter,
|
|
6
6
|
createPlatformAdapterFor,
|
|
7
7
|
isPlatformSupported,
|
|
8
8
|
getPlatformCapabilities
|
|
9
|
-
} from "./platform/utils";
|
|
9
|
+
} from "./platform/utils.js";
|
|
10
10
|
import {
|
|
11
11
|
createNodePlatformAdapter,
|
|
12
12
|
createBrowserPlatformAdapter,
|
|
13
13
|
createPlatformAdapterSafe
|
|
14
|
-
} from "./platform/browser-safe";
|
|
14
|
+
} from "./platform/browser-safe.js";
|
|
15
15
|
export {
|
|
16
16
|
BrowserPlatformAdapter,
|
|
17
17
|
NodePlatformAdapter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/protocol/eip712.ts"],"sourcesContent":["/**\n * EIP-712 domain and type builders for Data Portability protocol writes.\n *\n * These helpers are shared primitives only. Personal Server runtimes own when\n * to sign and submit these payloads.\n *\n * @category Protocol\n */\n\nimport type { TypedDataDomain } from \"viem\";\n\nconst DOMAIN_NAME = \"Vana Data Portability\";\nconst DOMAIN_VERSION = \"1\";\n\nexport interface DataPortabilityContracts {\n dataRegistry: string;\n dataPortabilityPermissions: string;\n dataPortabilityServer: string;\n dataPortabilityGrantees: string;\n}\n\nexport interface DataPortabilityGatewayConfig {\n chainId: number;\n contracts: DataPortabilityContracts;\n}\n\nfunction buildDomain(\n chainId: number,\n verifyingContract: `0x${string}`,\n): TypedDataDomain {\n return {\n name: DOMAIN_NAME,\n version: DOMAIN_VERSION,\n chainId,\n verifyingContract,\n };\n}\n\nexport function fileRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataRegistry as `0x${string}`,\n );\n}\n\nexport function grantRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function grantRevocationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function serverRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityServer as `0x${string}`,\n );\n}\n\nexport function builderRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityGrantees as `0x${string}`,\n );\n}\n\nexport const FILE_REGISTRATION_TYPES = {\n FileRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"url\", type: \"string\" },\n { name: \"schemaId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const GRANT_REGISTRATION_TYPES = {\n GrantRegistration: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"granteeId\", type: \"bytes32\" },\n { name: \"grant\", type: \"string\" },\n { name: \"fileIds\", type: \"uint256[]\" },\n ],\n} as const;\n\nexport const GRANT_REVOCATION_TYPES = {\n GrantRevocation: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"grantId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const SERVER_REGISTRATION_TYPES = {\n ServerRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"serverAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"serverUrl\", type: \"string\" },\n ],\n} as const;\n\nexport const BUILDER_REGISTRATION_TYPES = {\n BuilderRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"granteeAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"appUrl\", type: \"string\" },\n ],\n} as const;\n\nexport interface FileRegistrationMessage {\n ownerAddress: `0x${string}`;\n url: string;\n schemaId: `0x${string}`;\n}\n\nexport interface GrantRegistrationMessage {\n grantorAddress: `0x${string}`;\n granteeId: `0x${string}`;\n grant: string;\n fileIds: bigint[];\n}\n\nexport interface GrantRevocationMessage {\n grantorAddress: `0x${string}`;\n grantId: `0x${string}`;\n}\n\nexport interface ServerRegistrationMessage {\n ownerAddress: `0x${string}`;\n serverAddress: `0x${string}`;\n publicKey:
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/eip712.ts"],"sourcesContent":["/**\n * EIP-712 domain and type builders for Data Portability protocol writes.\n *\n * These helpers are shared primitives only. Personal Server runtimes own when\n * to sign and submit these payloads.\n *\n * @category Protocol\n */\n\nimport type { TypedDataDomain } from \"viem\";\n\nconst DOMAIN_NAME = \"Vana Data Portability\";\nconst DOMAIN_VERSION = \"1\";\n\nexport interface DataPortabilityContracts {\n dataRegistry: string;\n dataPortabilityPermissions: string;\n dataPortabilityServer: string;\n dataPortabilityGrantees: string;\n}\n\nexport interface DataPortabilityGatewayConfig {\n chainId: number;\n contracts: DataPortabilityContracts;\n}\n\nfunction buildDomain(\n chainId: number,\n verifyingContract: `0x${string}`,\n): TypedDataDomain {\n return {\n name: DOMAIN_NAME,\n version: DOMAIN_VERSION,\n chainId,\n verifyingContract,\n };\n}\n\nexport function fileRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataRegistry as `0x${string}`,\n );\n}\n\nexport function grantRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function grantRevocationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function serverRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityServer as `0x${string}`,\n );\n}\n\nexport function builderRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityGrantees as `0x${string}`,\n );\n}\n\nexport const FILE_REGISTRATION_TYPES = {\n FileRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"url\", type: \"string\" },\n { name: \"schemaId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const GRANT_REGISTRATION_TYPES = {\n GrantRegistration: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"granteeId\", type: \"bytes32\" },\n { name: \"grant\", type: \"string\" },\n { name: \"fileIds\", type: \"uint256[]\" },\n ],\n} as const;\n\nexport const GRANT_REVOCATION_TYPES = {\n GrantRevocation: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"grantId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const SERVER_REGISTRATION_TYPES = {\n ServerRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"serverAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"serverUrl\", type: \"string\" },\n ],\n} as const;\n\nexport const BUILDER_REGISTRATION_TYPES = {\n BuilderRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"granteeAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"appUrl\", type: \"string\" },\n ],\n} as const;\n\nexport interface FileRegistrationMessage {\n ownerAddress: `0x${string}`;\n url: string;\n schemaId: `0x${string}`;\n}\n\nexport interface GrantRegistrationMessage {\n grantorAddress: `0x${string}`;\n granteeId: `0x${string}`;\n grant: string;\n fileIds: bigint[];\n}\n\nexport interface GrantRevocationMessage {\n grantorAddress: `0x${string}`;\n grantId: `0x${string}`;\n}\n\nexport interface ServerRegistrationMessage {\n ownerAddress: `0x${string}`;\n serverAddress: `0x${string}`;\n publicKey: string;\n serverUrl: string;\n}\n\nexport interface BuilderRegistrationMessage {\n ownerAddress: `0x${string}`;\n granteeAddress: `0x${string}`;\n publicKey: string;\n appUrl: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAcvB,SAAS,YACP,SACA,mBACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,uBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,wBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,sBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,yBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,0BACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,MAAM,0BAA0B;AAAA,EACrC,kBAAkB;AAAA,IAChB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,OAAO,MAAM,SAAS;AAAA,IAC9B,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,EACtC;AACF;AAEO,MAAM,2BAA2B;AAAA,EACtC,mBAAmB;AAAA,IACjB,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,UAAU;AAAA,IACrC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,WAAW,MAAM,YAAY;AAAA,EACvC;AACF;AAEO,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,IACf,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,EACrC;AACF;AAEO,MAAM,4BAA4B;AAAA,EACvC,oBAAoB;AAAA,IAClB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,iBAAiB,MAAM,UAAU;AAAA,IACzC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,EACtC;AACF;AAEO,MAAM,6BAA6B;AAAA,EACxC,qBAAqB;AAAA,IACnB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,UAAU,MAAM,SAAS;AAAA,EACnC;AACF;","names":[]}
|
|
@@ -106,7 +106,7 @@ export interface GrantRevocationMessage {
|
|
|
106
106
|
export interface ServerRegistrationMessage {
|
|
107
107
|
ownerAddress: `0x${string}`;
|
|
108
108
|
serverAddress: `0x${string}`;
|
|
109
|
-
publicKey:
|
|
109
|
+
publicKey: string;
|
|
110
110
|
serverUrl: string;
|
|
111
111
|
}
|
|
112
112
|
export interface BuilderRegistrationMessage {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/protocol/eip712.ts"],"sourcesContent":["/**\n * EIP-712 domain and type builders for Data Portability protocol writes.\n *\n * These helpers are shared primitives only. Personal Server runtimes own when\n * to sign and submit these payloads.\n *\n * @category Protocol\n */\n\nimport type { TypedDataDomain } from \"viem\";\n\nconst DOMAIN_NAME = \"Vana Data Portability\";\nconst DOMAIN_VERSION = \"1\";\n\nexport interface DataPortabilityContracts {\n dataRegistry: string;\n dataPortabilityPermissions: string;\n dataPortabilityServer: string;\n dataPortabilityGrantees: string;\n}\n\nexport interface DataPortabilityGatewayConfig {\n chainId: number;\n contracts: DataPortabilityContracts;\n}\n\nfunction buildDomain(\n chainId: number,\n verifyingContract: `0x${string}`,\n): TypedDataDomain {\n return {\n name: DOMAIN_NAME,\n version: DOMAIN_VERSION,\n chainId,\n verifyingContract,\n };\n}\n\nexport function fileRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataRegistry as `0x${string}`,\n );\n}\n\nexport function grantRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function grantRevocationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function serverRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityServer as `0x${string}`,\n );\n}\n\nexport function builderRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityGrantees as `0x${string}`,\n );\n}\n\nexport const FILE_REGISTRATION_TYPES = {\n FileRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"url\", type: \"string\" },\n { name: \"schemaId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const GRANT_REGISTRATION_TYPES = {\n GrantRegistration: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"granteeId\", type: \"bytes32\" },\n { name: \"grant\", type: \"string\" },\n { name: \"fileIds\", type: \"uint256[]\" },\n ],\n} as const;\n\nexport const GRANT_REVOCATION_TYPES = {\n GrantRevocation: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"grantId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const SERVER_REGISTRATION_TYPES = {\n ServerRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"serverAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"serverUrl\", type: \"string\" },\n ],\n} as const;\n\nexport const BUILDER_REGISTRATION_TYPES = {\n BuilderRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"granteeAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"appUrl\", type: \"string\" },\n ],\n} as const;\n\nexport interface FileRegistrationMessage {\n ownerAddress: `0x${string}`;\n url: string;\n schemaId: `0x${string}`;\n}\n\nexport interface GrantRegistrationMessage {\n grantorAddress: `0x${string}`;\n granteeId: `0x${string}`;\n grant: string;\n fileIds: bigint[];\n}\n\nexport interface GrantRevocationMessage {\n grantorAddress: `0x${string}`;\n grantId: `0x${string}`;\n}\n\nexport interface ServerRegistrationMessage {\n ownerAddress: `0x${string}`;\n serverAddress: `0x${string}`;\n publicKey:
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/eip712.ts"],"sourcesContent":["/**\n * EIP-712 domain and type builders for Data Portability protocol writes.\n *\n * These helpers are shared primitives only. Personal Server runtimes own when\n * to sign and submit these payloads.\n *\n * @category Protocol\n */\n\nimport type { TypedDataDomain } from \"viem\";\n\nconst DOMAIN_NAME = \"Vana Data Portability\";\nconst DOMAIN_VERSION = \"1\";\n\nexport interface DataPortabilityContracts {\n dataRegistry: string;\n dataPortabilityPermissions: string;\n dataPortabilityServer: string;\n dataPortabilityGrantees: string;\n}\n\nexport interface DataPortabilityGatewayConfig {\n chainId: number;\n contracts: DataPortabilityContracts;\n}\n\nfunction buildDomain(\n chainId: number,\n verifyingContract: `0x${string}`,\n): TypedDataDomain {\n return {\n name: DOMAIN_NAME,\n version: DOMAIN_VERSION,\n chainId,\n verifyingContract,\n };\n}\n\nexport function fileRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataRegistry as `0x${string}`,\n );\n}\n\nexport function grantRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function grantRevocationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function serverRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityServer as `0x${string}`,\n );\n}\n\nexport function builderRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityGrantees as `0x${string}`,\n );\n}\n\nexport const FILE_REGISTRATION_TYPES = {\n FileRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"url\", type: \"string\" },\n { name: \"schemaId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const GRANT_REGISTRATION_TYPES = {\n GrantRegistration: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"granteeId\", type: \"bytes32\" },\n { name: \"grant\", type: \"string\" },\n { name: \"fileIds\", type: \"uint256[]\" },\n ],\n} as const;\n\nexport const GRANT_REVOCATION_TYPES = {\n GrantRevocation: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"grantId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const SERVER_REGISTRATION_TYPES = {\n ServerRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"serverAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"serverUrl\", type: \"string\" },\n ],\n} as const;\n\nexport const BUILDER_REGISTRATION_TYPES = {\n BuilderRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"granteeAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"appUrl\", type: \"string\" },\n ],\n} as const;\n\nexport interface FileRegistrationMessage {\n ownerAddress: `0x${string}`;\n url: string;\n schemaId: `0x${string}`;\n}\n\nexport interface GrantRegistrationMessage {\n grantorAddress: `0x${string}`;\n granteeId: `0x${string}`;\n grant: string;\n fileIds: bigint[];\n}\n\nexport interface GrantRevocationMessage {\n grantorAddress: `0x${string}`;\n grantId: `0x${string}`;\n}\n\nexport interface ServerRegistrationMessage {\n ownerAddress: `0x${string}`;\n serverAddress: `0x${string}`;\n publicKey: string;\n serverUrl: string;\n}\n\nexport interface BuilderRegistrationMessage {\n ownerAddress: `0x${string}`;\n granteeAddress: `0x${string}`;\n publicKey: string;\n appUrl: string;\n}\n"],"mappings":"AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAcvB,SAAS,YACP,SACA,mBACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,uBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,wBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,sBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,yBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,0BACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,MAAM,0BAA0B;AAAA,EACrC,kBAAkB;AAAA,IAChB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,OAAO,MAAM,SAAS;AAAA,IAC9B,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,EACtC;AACF;AAEO,MAAM,2BAA2B;AAAA,EACtC,mBAAmB;AAAA,IACjB,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,UAAU;AAAA,IACrC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,WAAW,MAAM,YAAY;AAAA,EACvC;AACF;AAEO,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,IACf,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,EACrC;AACF;AAEO,MAAM,4BAA4B;AAAA,EACvC,oBAAoB;AAAA,IAClB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,iBAAiB,MAAM,UAAU;AAAA,IACzC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,EACtC;AACF;AAEO,MAAM,6BAA6B;AAAA,EACxC,qBAAqB;AAAA,IACnB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,UAAU,MAAM,SAAS;AAAA,EACnC;AACF;","names":[]}
|
package/dist/protocol/grants.js
CHANGED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var personal_server_lite_owner_binding_exports = {};
|
|
20
|
+
__export(personal_server_lite_owner_binding_exports, {
|
|
21
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX: () => PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
22
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE: () => PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
23
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION: () => PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
24
|
+
buildPersonalServerLiteOwnerBindingMessage: () => buildPersonalServerLiteOwnerBindingMessage,
|
|
25
|
+
buildPersonalServerLiteOwnerBindingSignature: () => buildPersonalServerLiteOwnerBindingSignature,
|
|
26
|
+
createViemPersonalServerLiteOwnerBindingSigner: () => createViemPersonalServerLiteOwnerBindingSigner,
|
|
27
|
+
signPersonalServerLiteOwnerBinding: () => signPersonalServerLiteOwnerBinding
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(personal_server_lite_owner_binding_exports);
|
|
30
|
+
var import_viem = require("viem");
|
|
31
|
+
const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.account.v1";
|
|
32
|
+
const PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
33
|
+
const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
34
|
+
function assertAddress(value, name) {
|
|
35
|
+
if (!(0, import_viem.isAddress)(value)) {
|
|
36
|
+
throw new Error(`${name} must be a valid EVM address`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function getAccountAddress(account) {
|
|
40
|
+
if (!account) {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
return typeof account === "string" ? account : account.address;
|
|
44
|
+
}
|
|
45
|
+
function isPersonalServerLiteOwnerBindingSigner(source) {
|
|
46
|
+
return "address" in source && typeof source.signMessage === "function";
|
|
47
|
+
}
|
|
48
|
+
function buildPersonalServerLiteOwnerBindingMessage(ownerAddress) {
|
|
49
|
+
assertAddress(ownerAddress, "ownerAddress");
|
|
50
|
+
return `${PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${ownerAddress.toLowerCase()}`;
|
|
51
|
+
}
|
|
52
|
+
function createViemPersonalServerLiteOwnerBindingSigner(source, options = {}) {
|
|
53
|
+
if (isPersonalServerLiteOwnerBindingSigner(source)) {
|
|
54
|
+
return source;
|
|
55
|
+
}
|
|
56
|
+
const accountAddress = getAccountAddress(options.account) ?? getAccountAddress(source.account);
|
|
57
|
+
if (accountAddress) {
|
|
58
|
+
return {
|
|
59
|
+
address: accountAddress,
|
|
60
|
+
signMessage: ({ message }) => source.signMessage({
|
|
61
|
+
account: options.account ?? source.account ?? accountAddress,
|
|
62
|
+
message
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
throw new Error(
|
|
67
|
+
"Viem wallet client requires an account option or account property"
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
async function buildPersonalServerLiteOwnerBindingSignature(input) {
|
|
71
|
+
const message = buildPersonalServerLiteOwnerBindingMessage(
|
|
72
|
+
input.signer.address
|
|
73
|
+
);
|
|
74
|
+
const signature = await input.signer.signMessage({ message });
|
|
75
|
+
return {
|
|
76
|
+
signature,
|
|
77
|
+
signerAddress: input.signer.address,
|
|
78
|
+
message,
|
|
79
|
+
purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSignature;
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
86
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
87
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
88
|
+
buildPersonalServerLiteOwnerBindingMessage,
|
|
89
|
+
buildPersonalServerLiteOwnerBindingSignature,
|
|
90
|
+
createViemPersonalServerLiteOwnerBindingSigner,
|
|
91
|
+
signPersonalServerLiteOwnerBinding
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=personal-server-lite-owner-binding.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/personal-server-lite-owner-binding.ts"],"sourcesContent":["/**\n * PS Lite owner-binding message and signing helpers.\n *\n * PS Lite uses this replayable personal-sign message as a wallet-owned input\n * for opening the user's local encrypted runtime. This is intentionally\n * separate from Personal Server registration, which is EIP-712 typed data.\n *\n * @category Protocol\n */\n\nimport {\n isAddress,\n type Account,\n type Address,\n type Hex,\n type SignableMessage,\n} from \"viem\";\n\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = \"vana.account.v1\";\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = \"ps-lite-owner\";\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX =\n `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:` as const;\n\nexport type PersonalServerLiteOwnerBindingPurpose =\n typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE;\n\nexport type PersonalServerLiteOwnerBindingMessage =\n `${typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${Lowercase<Address>}`;\n\nexport interface PersonalServerLiteOwnerBindingSigner {\n address: Address;\n signMessage(input: {\n message: PersonalServerLiteOwnerBindingMessage;\n }): Promise<Hex> | Hex;\n}\n\nexport interface ViemPersonalServerLiteOwnerBindingWalletClient {\n account?: Account | Address | null;\n signMessage(input: {\n account?: Account | Address;\n message: SignableMessage;\n }): Promise<Hex>;\n}\n\nexport type ViemPersonalServerLiteOwnerBindingSignerSource =\n | PersonalServerLiteOwnerBindingSigner\n | ViemPersonalServerLiteOwnerBindingWalletClient;\n\nexport interface BuildPersonalServerLiteOwnerBindingSignatureInput {\n signer: PersonalServerLiteOwnerBindingSigner;\n}\n\nexport interface PersonalServerLiteOwnerBindingSignature {\n signature: Hex;\n signerAddress: Address;\n message: PersonalServerLiteOwnerBindingMessage;\n purpose: PersonalServerLiteOwnerBindingPurpose;\n}\n\nfunction assertAddress(value: Address, name: string): void {\n if (!isAddress(value)) {\n throw new Error(`${name} must be a valid EVM address`);\n }\n}\n\nfunction getAccountAddress(\n account: Account | Address | null | undefined,\n): Address | undefined {\n if (!account) {\n return undefined;\n }\n\n return typeof account === \"string\" ? account : account.address;\n}\n\nfunction isPersonalServerLiteOwnerBindingSigner(\n source: ViemPersonalServerLiteOwnerBindingSignerSource,\n): source is PersonalServerLiteOwnerBindingSigner {\n return \"address\" in source && typeof source.signMessage === \"function\";\n}\n\nexport function buildPersonalServerLiteOwnerBindingMessage(\n ownerAddress: Address,\n): PersonalServerLiteOwnerBindingMessage {\n assertAddress(ownerAddress, \"ownerAddress\");\n return `${PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${ownerAddress.toLowerCase()}` as PersonalServerLiteOwnerBindingMessage;\n}\n\nexport function createViemPersonalServerLiteOwnerBindingSigner(\n source: ViemPersonalServerLiteOwnerBindingSignerSource,\n options: { account?: Account | Address } = {},\n): PersonalServerLiteOwnerBindingSigner {\n if (isPersonalServerLiteOwnerBindingSigner(source)) {\n return source;\n }\n\n const accountAddress =\n getAccountAddress(options.account) ?? getAccountAddress(source.account);\n\n if (accountAddress) {\n return {\n address: accountAddress,\n signMessage: ({ message }) =>\n source.signMessage({\n account: options.account ?? source.account ?? accountAddress,\n message,\n }),\n };\n }\n\n throw new Error(\n \"Viem wallet client requires an account option or account property\",\n );\n}\n\nexport async function buildPersonalServerLiteOwnerBindingSignature(\n input: BuildPersonalServerLiteOwnerBindingSignatureInput,\n): Promise<PersonalServerLiteOwnerBindingSignature> {\n const message = buildPersonalServerLiteOwnerBindingMessage(\n input.signer.address,\n );\n const signature = await input.signer.signMessage({ message });\n\n return {\n signature,\n signerAddress: input.signer.address,\n message,\n purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,\n };\n}\n\nexport const signPersonalServerLiteOwnerBinding =\n buildPersonalServerLiteOwnerBindingSignature;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,kBAMO;AAEA,MAAM,6CAA6C;AACnD,MAAM,6CAA6C;AACnD,MAAM,4CACX,GAAG,0CAA0C,IAAI,0CAA0C;AAsC7F,SAAS,cAAc,OAAgB,MAAoB;AACzD,MAAI,KAAC,uBAAU,KAAK,GAAG;AACrB,UAAM,IAAI,MAAM,GAAG,IAAI,8BAA8B;AAAA,EACvD;AACF;AAEA,SAAS,kBACP,SACqB;AACrB,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ;AACzD;AAEA,SAAS,uCACP,QACgD;AAChD,SAAO,aAAa,UAAU,OAAO,OAAO,gBAAgB;AAC9D;AAEO,SAAS,2CACd,cACuC;AACvC,gBAAc,cAAc,cAAc;AAC1C,SAAO,GAAG,yCAAyC,GAAG,aAAa,YAAY,CAAC;AAClF;AAEO,SAAS,+CACd,QACA,UAA2C,CAAC,GACN;AACtC,MAAI,uCAAuC,MAAM,GAAG;AAClD,WAAO;AAAA,EACT;AAEA,QAAM,iBACJ,kBAAkB,QAAQ,OAAO,KAAK,kBAAkB,OAAO,OAAO;AAExE,MAAI,gBAAgB;AAClB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,aAAa,CAAC,EAAE,QAAQ,MACtB,OAAO,YAAY;AAAA,QACjB,SAAS,QAAQ,WAAW,OAAO,WAAW;AAAA,QAC9C;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEA,eAAsB,6CACpB,OACkD;AAClD,QAAM,UAAU;AAAA,IACd,MAAM,OAAO;AAAA,EACf;AACA,QAAM,YAAY,MAAM,MAAM,OAAO,YAAY,EAAE,QAAQ,CAAC;AAE5D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,MAAM,OAAO;AAAA,IAC5B;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAEO,MAAM,qCACX;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PS Lite owner-binding message and signing helpers.
|
|
3
|
+
*
|
|
4
|
+
* PS Lite uses this replayable personal-sign message as a wallet-owned input
|
|
5
|
+
* for opening the user's local encrypted runtime. This is intentionally
|
|
6
|
+
* separate from Personal Server registration, which is EIP-712 typed data.
|
|
7
|
+
*
|
|
8
|
+
* @category Protocol
|
|
9
|
+
*/
|
|
10
|
+
import { type Account, type Address, type Hex, type SignableMessage } from "viem";
|
|
11
|
+
export declare const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.account.v1";
|
|
12
|
+
export declare const PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
13
|
+
export declare const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX: "vana.account.v1:ps-lite-owner:";
|
|
14
|
+
export type PersonalServerLiteOwnerBindingPurpose = typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE;
|
|
15
|
+
export type PersonalServerLiteOwnerBindingMessage = `${typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${Lowercase<Address>}`;
|
|
16
|
+
export interface PersonalServerLiteOwnerBindingSigner {
|
|
17
|
+
address: Address;
|
|
18
|
+
signMessage(input: {
|
|
19
|
+
message: PersonalServerLiteOwnerBindingMessage;
|
|
20
|
+
}): Promise<Hex> | Hex;
|
|
21
|
+
}
|
|
22
|
+
export interface ViemPersonalServerLiteOwnerBindingWalletClient {
|
|
23
|
+
account?: Account | Address | null;
|
|
24
|
+
signMessage(input: {
|
|
25
|
+
account?: Account | Address;
|
|
26
|
+
message: SignableMessage;
|
|
27
|
+
}): Promise<Hex>;
|
|
28
|
+
}
|
|
29
|
+
export type ViemPersonalServerLiteOwnerBindingSignerSource = PersonalServerLiteOwnerBindingSigner | ViemPersonalServerLiteOwnerBindingWalletClient;
|
|
30
|
+
export interface BuildPersonalServerLiteOwnerBindingSignatureInput {
|
|
31
|
+
signer: PersonalServerLiteOwnerBindingSigner;
|
|
32
|
+
}
|
|
33
|
+
export interface PersonalServerLiteOwnerBindingSignature {
|
|
34
|
+
signature: Hex;
|
|
35
|
+
signerAddress: Address;
|
|
36
|
+
message: PersonalServerLiteOwnerBindingMessage;
|
|
37
|
+
purpose: PersonalServerLiteOwnerBindingPurpose;
|
|
38
|
+
}
|
|
39
|
+
export declare function buildPersonalServerLiteOwnerBindingMessage(ownerAddress: Address): PersonalServerLiteOwnerBindingMessage;
|
|
40
|
+
export declare function createViemPersonalServerLiteOwnerBindingSigner(source: ViemPersonalServerLiteOwnerBindingSignerSource, options?: {
|
|
41
|
+
account?: Account | Address;
|
|
42
|
+
}): PersonalServerLiteOwnerBindingSigner;
|
|
43
|
+
export declare function buildPersonalServerLiteOwnerBindingSignature(input: BuildPersonalServerLiteOwnerBindingSignatureInput): Promise<PersonalServerLiteOwnerBindingSignature>;
|
|
44
|
+
export declare const signPersonalServerLiteOwnerBinding: typeof buildPersonalServerLiteOwnerBindingSignature;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAddress
|
|
3
|
+
} from "viem";
|
|
4
|
+
const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.account.v1";
|
|
5
|
+
const PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
6
|
+
const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
7
|
+
function assertAddress(value, name) {
|
|
8
|
+
if (!isAddress(value)) {
|
|
9
|
+
throw new Error(`${name} must be a valid EVM address`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function getAccountAddress(account) {
|
|
13
|
+
if (!account) {
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
return typeof account === "string" ? account : account.address;
|
|
17
|
+
}
|
|
18
|
+
function isPersonalServerLiteOwnerBindingSigner(source) {
|
|
19
|
+
return "address" in source && typeof source.signMessage === "function";
|
|
20
|
+
}
|
|
21
|
+
function buildPersonalServerLiteOwnerBindingMessage(ownerAddress) {
|
|
22
|
+
assertAddress(ownerAddress, "ownerAddress");
|
|
23
|
+
return `${PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${ownerAddress.toLowerCase()}`;
|
|
24
|
+
}
|
|
25
|
+
function createViemPersonalServerLiteOwnerBindingSigner(source, options = {}) {
|
|
26
|
+
if (isPersonalServerLiteOwnerBindingSigner(source)) {
|
|
27
|
+
return source;
|
|
28
|
+
}
|
|
29
|
+
const accountAddress = getAccountAddress(options.account) ?? getAccountAddress(source.account);
|
|
30
|
+
if (accountAddress) {
|
|
31
|
+
return {
|
|
32
|
+
address: accountAddress,
|
|
33
|
+
signMessage: ({ message }) => source.signMessage({
|
|
34
|
+
account: options.account ?? source.account ?? accountAddress,
|
|
35
|
+
message
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
throw new Error(
|
|
40
|
+
"Viem wallet client requires an account option or account property"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
async function buildPersonalServerLiteOwnerBindingSignature(input) {
|
|
44
|
+
const message = buildPersonalServerLiteOwnerBindingMessage(
|
|
45
|
+
input.signer.address
|
|
46
|
+
);
|
|
47
|
+
const signature = await input.signer.signMessage({ message });
|
|
48
|
+
return {
|
|
49
|
+
signature,
|
|
50
|
+
signerAddress: input.signer.address,
|
|
51
|
+
message,
|
|
52
|
+
purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSignature;
|
|
56
|
+
export {
|
|
57
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
58
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
59
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
60
|
+
buildPersonalServerLiteOwnerBindingMessage,
|
|
61
|
+
buildPersonalServerLiteOwnerBindingSignature,
|
|
62
|
+
createViemPersonalServerLiteOwnerBindingSigner,
|
|
63
|
+
signPersonalServerLiteOwnerBinding
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=personal-server-lite-owner-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/personal-server-lite-owner-binding.ts"],"sourcesContent":["/**\n * PS Lite owner-binding message and signing helpers.\n *\n * PS Lite uses this replayable personal-sign message as a wallet-owned input\n * for opening the user's local encrypted runtime. This is intentionally\n * separate from Personal Server registration, which is EIP-712 typed data.\n *\n * @category Protocol\n */\n\nimport {\n isAddress,\n type Account,\n type Address,\n type Hex,\n type SignableMessage,\n} from \"viem\";\n\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = \"vana.account.v1\";\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = \"ps-lite-owner\";\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX =\n `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:` as const;\n\nexport type PersonalServerLiteOwnerBindingPurpose =\n typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE;\n\nexport type PersonalServerLiteOwnerBindingMessage =\n `${typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${Lowercase<Address>}`;\n\nexport interface PersonalServerLiteOwnerBindingSigner {\n address: Address;\n signMessage(input: {\n message: PersonalServerLiteOwnerBindingMessage;\n }): Promise<Hex> | Hex;\n}\n\nexport interface ViemPersonalServerLiteOwnerBindingWalletClient {\n account?: Account | Address | null;\n signMessage(input: {\n account?: Account | Address;\n message: SignableMessage;\n }): Promise<Hex>;\n}\n\nexport type ViemPersonalServerLiteOwnerBindingSignerSource =\n | PersonalServerLiteOwnerBindingSigner\n | ViemPersonalServerLiteOwnerBindingWalletClient;\n\nexport interface BuildPersonalServerLiteOwnerBindingSignatureInput {\n signer: PersonalServerLiteOwnerBindingSigner;\n}\n\nexport interface PersonalServerLiteOwnerBindingSignature {\n signature: Hex;\n signerAddress: Address;\n message: PersonalServerLiteOwnerBindingMessage;\n purpose: PersonalServerLiteOwnerBindingPurpose;\n}\n\nfunction assertAddress(value: Address, name: string): void {\n if (!isAddress(value)) {\n throw new Error(`${name} must be a valid EVM address`);\n }\n}\n\nfunction getAccountAddress(\n account: Account | Address | null | undefined,\n): Address | undefined {\n if (!account) {\n return undefined;\n }\n\n return typeof account === \"string\" ? account : account.address;\n}\n\nfunction isPersonalServerLiteOwnerBindingSigner(\n source: ViemPersonalServerLiteOwnerBindingSignerSource,\n): source is PersonalServerLiteOwnerBindingSigner {\n return \"address\" in source && typeof source.signMessage === \"function\";\n}\n\nexport function buildPersonalServerLiteOwnerBindingMessage(\n ownerAddress: Address,\n): PersonalServerLiteOwnerBindingMessage {\n assertAddress(ownerAddress, \"ownerAddress\");\n return `${PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${ownerAddress.toLowerCase()}` as PersonalServerLiteOwnerBindingMessage;\n}\n\nexport function createViemPersonalServerLiteOwnerBindingSigner(\n source: ViemPersonalServerLiteOwnerBindingSignerSource,\n options: { account?: Account | Address } = {},\n): PersonalServerLiteOwnerBindingSigner {\n if (isPersonalServerLiteOwnerBindingSigner(source)) {\n return source;\n }\n\n const accountAddress =\n getAccountAddress(options.account) ?? getAccountAddress(source.account);\n\n if (accountAddress) {\n return {\n address: accountAddress,\n signMessage: ({ message }) =>\n source.signMessage({\n account: options.account ?? source.account ?? accountAddress,\n message,\n }),\n };\n }\n\n throw new Error(\n \"Viem wallet client requires an account option or account property\",\n );\n}\n\nexport async function buildPersonalServerLiteOwnerBindingSignature(\n input: BuildPersonalServerLiteOwnerBindingSignatureInput,\n): Promise<PersonalServerLiteOwnerBindingSignature> {\n const message = buildPersonalServerLiteOwnerBindingMessage(\n input.signer.address,\n );\n const signature = await input.signer.signMessage({ message });\n\n return {\n signature,\n signerAddress: input.signer.address,\n message,\n purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,\n };\n}\n\nexport const signPersonalServerLiteOwnerBinding =\n buildPersonalServerLiteOwnerBindingSignature;\n"],"mappings":"AAUA;AAAA,EACE;AAAA,OAKK;AAEA,MAAM,6CAA6C;AACnD,MAAM,6CAA6C;AACnD,MAAM,4CACX,GAAG,0CAA0C,IAAI,0CAA0C;AAsC7F,SAAS,cAAc,OAAgB,MAAoB;AACzD,MAAI,CAAC,UAAU,KAAK,GAAG;AACrB,UAAM,IAAI,MAAM,GAAG,IAAI,8BAA8B;AAAA,EACvD;AACF;AAEA,SAAS,kBACP,SACqB;AACrB,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ;AACzD;AAEA,SAAS,uCACP,QACgD;AAChD,SAAO,aAAa,UAAU,OAAO,OAAO,gBAAgB;AAC9D;AAEO,SAAS,2CACd,cACuC;AACvC,gBAAc,cAAc,cAAc;AAC1C,SAAO,GAAG,yCAAyC,GAAG,aAAa,YAAY,CAAC;AAClF;AAEO,SAAS,+CACd,QACA,UAA2C,CAAC,GACN;AACtC,MAAI,uCAAuC,MAAM,GAAG;AAClD,WAAO;AAAA,EACT;AAEA,QAAM,iBACJ,kBAAkB,QAAQ,OAAO,KAAK,kBAAkB,OAAO,OAAO;AAExE,MAAI,gBAAgB;AAClB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,aAAa,CAAC,EAAE,QAAQ,MACtB,OAAO,YAAY;AAAA,QACjB,SAAS,QAAQ,WAAW,OAAO,WAAW;AAAA,QAC9C;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEA,eAAsB,6CACpB,OACkD;AAClD,QAAM,UAAU;AAAA,IACd,MAAM,OAAO;AAAA,EACf;AACA,QAAM,YAAY,MAAM,MAAM,OAAO,YAAY,EAAE,QAAQ,CAAC;AAE5D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,MAAM,OAAO;AAAA,IAC5B;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAEO,MAAM,qCACX;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var personal_server_registration_exports = {};
|
|
20
|
+
__export(personal_server_registration_exports, {
|
|
21
|
+
PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID: () => PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
22
|
+
PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT: () => PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT,
|
|
23
|
+
buildPersonalServerRegistrationSignature: () => buildPersonalServerRegistrationSignature,
|
|
24
|
+
buildPersonalServerRegistrationTypedData: () => buildPersonalServerRegistrationTypedData,
|
|
25
|
+
createViemPersonalServerRegistrationSigner: () => createViemPersonalServerRegistrationSigner,
|
|
26
|
+
personalServerRegistrationDomain: () => personalServerRegistrationDomain,
|
|
27
|
+
registerPersonalServerSignature: () => registerPersonalServerSignature
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(personal_server_registration_exports);
|
|
30
|
+
var import_viem = require("viem");
|
|
31
|
+
var import_eip712 = require("./eip712");
|
|
32
|
+
const PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;
|
|
33
|
+
const PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c";
|
|
34
|
+
function assertAddress(value, name) {
|
|
35
|
+
if (!(0, import_viem.isAddress)(value)) {
|
|
36
|
+
throw new Error(`${name} must be a valid EVM address`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function getAccountAddress(account) {
|
|
40
|
+
if (!account) {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
return typeof account === "string" ? account : account.address;
|
|
44
|
+
}
|
|
45
|
+
function isPersonalServerRegistrationSigner(source) {
|
|
46
|
+
return "address" in source && typeof source.signTypedData === "function";
|
|
47
|
+
}
|
|
48
|
+
function createViemPersonalServerRegistrationSigner(source, options = {}) {
|
|
49
|
+
if (isPersonalServerRegistrationSigner(source)) {
|
|
50
|
+
return source;
|
|
51
|
+
}
|
|
52
|
+
const accountAddress = getAccountAddress(options.account) ?? getAccountAddress(source.account);
|
|
53
|
+
if (accountAddress) {
|
|
54
|
+
return {
|
|
55
|
+
address: accountAddress,
|
|
56
|
+
signTypedData: (typedData) => source.signTypedData({
|
|
57
|
+
...typedData,
|
|
58
|
+
account: options.account ?? source.account ?? accountAddress
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
throw new Error(
|
|
63
|
+
"Viem wallet client requires an account option or account property"
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function personalServerRegistrationDomain(input = {}) {
|
|
67
|
+
if (input.config) {
|
|
68
|
+
return (0, import_eip712.serverRegistrationDomain)(input.config);
|
|
69
|
+
}
|
|
70
|
+
const verifyingContract = input.verifyingContract ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT;
|
|
71
|
+
assertAddress(verifyingContract, "verifyingContract");
|
|
72
|
+
return {
|
|
73
|
+
name: "Vana Data Portability",
|
|
74
|
+
version: "1",
|
|
75
|
+
chainId: input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
76
|
+
verifyingContract
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function buildPersonalServerRegistrationTypedData(input) {
|
|
80
|
+
assertAddress(input.ownerAddress, "ownerAddress");
|
|
81
|
+
assertAddress(input.serverAddress, "serverAddress");
|
|
82
|
+
return {
|
|
83
|
+
domain: personalServerRegistrationDomain(input),
|
|
84
|
+
types: import_eip712.SERVER_REGISTRATION_TYPES,
|
|
85
|
+
primaryType: "ServerRegistration",
|
|
86
|
+
message: {
|
|
87
|
+
ownerAddress: input.ownerAddress,
|
|
88
|
+
serverAddress: input.serverAddress,
|
|
89
|
+
publicKey: input.serverPublicKey,
|
|
90
|
+
serverUrl: input.serverUrl
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
async function buildPersonalServerRegistrationSignature(input) {
|
|
95
|
+
const typedData = buildPersonalServerRegistrationTypedData({
|
|
96
|
+
ownerAddress: input.signer.address,
|
|
97
|
+
serverAddress: input.serverAddress,
|
|
98
|
+
serverPublicKey: input.serverPublicKey,
|
|
99
|
+
serverUrl: input.serverUrl,
|
|
100
|
+
config: input.config,
|
|
101
|
+
chainId: input.chainId,
|
|
102
|
+
verifyingContract: input.verifyingContract
|
|
103
|
+
});
|
|
104
|
+
const signature = await input.signer.signTypedData(typedData);
|
|
105
|
+
return {
|
|
106
|
+
signature,
|
|
107
|
+
signerAddress: input.signer.address,
|
|
108
|
+
typedData
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
115
|
+
PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT,
|
|
116
|
+
buildPersonalServerRegistrationSignature,
|
|
117
|
+
buildPersonalServerRegistrationTypedData,
|
|
118
|
+
createViemPersonalServerRegistrationSigner,
|
|
119
|
+
personalServerRegistrationDomain,
|
|
120
|
+
registerPersonalServerSignature
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=personal-server-registration.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/personal-server-registration.ts"],"sourcesContent":["/**\n * Personal Server registration typed-data and signing helpers.\n *\n * These helpers are protocol-owned and runtime-neutral. Apps can sign with\n * viem local accounts, wallet clients, Account products, or any equivalent\n * signer by adapting to {@link PersonalServerRegistrationSigner}.\n *\n * @category Protocol\n */\n\nimport {\n isAddress,\n type Account,\n type Address,\n type Hex,\n type TypedDataDomain,\n type TypedDataDefinition,\n} from \"viem\";\nimport {\n SERVER_REGISTRATION_TYPES,\n serverRegistrationDomain,\n type DataPortabilityGatewayConfig,\n type ServerRegistrationMessage,\n} from \"./eip712\";\n\nexport const PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;\nexport const PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT =\n \"0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c\" as const;\n\nexport type PersonalServerRegistrationTypedData = TypedDataDefinition<\n typeof SERVER_REGISTRATION_TYPES,\n \"ServerRegistration\"\n> & {\n message: ServerRegistrationMessage;\n};\n\nexport interface PersonalServerRegistrationSigner {\n address: Address;\n signTypedData(\n typedData: PersonalServerRegistrationTypedData,\n ): Promise<Hex> | Hex;\n}\n\nexport interface ViemPersonalServerRegistrationWalletClient {\n account?: Account | Address | null;\n signTypedData(\n typedData: PersonalServerRegistrationTypedData & {\n account?: Account | Address;\n },\n ): Promise<Hex>;\n}\n\nexport type ViemPersonalServerRegistrationSignerSource =\n | PersonalServerRegistrationSigner\n | ViemPersonalServerRegistrationWalletClient;\n\nexport interface BuildPersonalServerRegistrationTypedDataInput {\n ownerAddress: Address;\n serverAddress: Address;\n serverPublicKey: string;\n serverUrl: string;\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nexport interface BuildPersonalServerRegistrationSignatureInput {\n signer: PersonalServerRegistrationSigner;\n serverAddress: Address;\n serverPublicKey: string;\n serverUrl: string;\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nexport interface PersonalServerRegistrationSignature {\n signature: Hex;\n signerAddress: Address;\n typedData: PersonalServerRegistrationTypedData;\n}\n\nexport interface PersonalServerRegistrationDomainInput {\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nfunction assertAddress(value: Address, name: string): void {\n if (!isAddress(value)) {\n throw new Error(`${name} must be a valid EVM address`);\n }\n}\n\nfunction getAccountAddress(\n account: Account | Address | null | undefined,\n): Address | undefined {\n if (!account) {\n return undefined;\n }\n\n return typeof account === \"string\" ? account : account.address;\n}\n\nfunction isPersonalServerRegistrationSigner(\n source: ViemPersonalServerRegistrationSignerSource,\n): source is PersonalServerRegistrationSigner {\n return \"address\" in source && typeof source.signTypedData === \"function\";\n}\n\nexport function createViemPersonalServerRegistrationSigner(\n source: ViemPersonalServerRegistrationSignerSource,\n options: { account?: Account | Address } = {},\n): PersonalServerRegistrationSigner {\n if (isPersonalServerRegistrationSigner(source)) {\n return source;\n }\n\n const accountAddress =\n getAccountAddress(options.account) ?? getAccountAddress(source.account);\n\n if (accountAddress) {\n return {\n address: accountAddress,\n signTypedData: (typedData) =>\n source.signTypedData({\n ...typedData,\n account: options.account ?? source.account ?? accountAddress,\n }),\n };\n }\n\n throw new Error(\n \"Viem wallet client requires an account option or account property\",\n );\n}\n\nexport function personalServerRegistrationDomain(\n input: PersonalServerRegistrationDomainInput = {},\n): TypedDataDomain {\n if (input.config) {\n return serverRegistrationDomain(input.config);\n }\n\n const verifyingContract =\n input.verifyingContract ??\n PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT;\n assertAddress(verifyingContract, \"verifyingContract\");\n\n return {\n name: \"Vana Data Portability\",\n version: \"1\",\n chainId: input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,\n verifyingContract,\n };\n}\n\nexport function buildPersonalServerRegistrationTypedData(\n input: BuildPersonalServerRegistrationTypedDataInput,\n): PersonalServerRegistrationTypedData {\n assertAddress(input.ownerAddress, \"ownerAddress\");\n assertAddress(input.serverAddress, \"serverAddress\");\n\n return {\n domain: personalServerRegistrationDomain(input),\n types: SERVER_REGISTRATION_TYPES,\n primaryType: \"ServerRegistration\",\n message: {\n ownerAddress: input.ownerAddress,\n serverAddress: input.serverAddress,\n publicKey: input.serverPublicKey,\n serverUrl: input.serverUrl,\n },\n };\n}\n\nexport async function buildPersonalServerRegistrationSignature(\n input: BuildPersonalServerRegistrationSignatureInput,\n): Promise<PersonalServerRegistrationSignature> {\n const typedData = buildPersonalServerRegistrationTypedData({\n ownerAddress: input.signer.address,\n serverAddress: input.serverAddress,\n serverPublicKey: input.serverPublicKey,\n serverUrl: input.serverUrl,\n config: input.config,\n chainId: input.chainId,\n verifyingContract: input.verifyingContract,\n });\n const signature = await input.signer.signTypedData(typedData);\n\n return {\n signature,\n signerAddress: input.signer.address,\n typedData,\n };\n}\n\nexport const registerPersonalServerSignature =\n buildPersonalServerRegistrationSignature;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,kBAOO;AACP,oBAKO;AAEA,MAAM,gDAAgD;AACtD,MAAM,0DACX;AA6DF,SAAS,cAAc,OAAgB,MAAoB;AACzD,MAAI,KAAC,uBAAU,KAAK,GAAG;AACrB,UAAM,IAAI,MAAM,GAAG,IAAI,8BAA8B;AAAA,EACvD;AACF;AAEA,SAAS,kBACP,SACqB;AACrB,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ;AACzD;AAEA,SAAS,mCACP,QAC4C;AAC5C,SAAO,aAAa,UAAU,OAAO,OAAO,kBAAkB;AAChE;AAEO,SAAS,2CACd,QACA,UAA2C,CAAC,GACV;AAClC,MAAI,mCAAmC,MAAM,GAAG;AAC9C,WAAO;AAAA,EACT;AAEA,QAAM,iBACJ,kBAAkB,QAAQ,OAAO,KAAK,kBAAkB,OAAO,OAAO;AAExE,MAAI,gBAAgB;AAClB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,eAAe,CAAC,cACd,OAAO,cAAc;AAAA,QACnB,GAAG;AAAA,QACH,SAAS,QAAQ,WAAW,OAAO,WAAW;AAAA,MAChD,CAAC;AAAA,IACL;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEO,SAAS,iCACd,QAA+C,CAAC,GAC/B;AACjB,MAAI,MAAM,QAAQ;AAChB,eAAO,wCAAyB,MAAM,MAAM;AAAA,EAC9C;AAEA,QAAM,oBACJ,MAAM,qBACN;AACF,gBAAc,mBAAmB,mBAAmB;AAEpD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,MAAM,WAAW;AAAA,IAC1B;AAAA,EACF;AACF;AAEO,SAAS,yCACd,OACqC;AACrC,gBAAc,MAAM,cAAc,cAAc;AAChD,gBAAc,MAAM,eAAe,eAAe;AAElD,SAAO;AAAA,IACL,QAAQ,iCAAiC,KAAK;AAAA,IAC9C,OAAO;AAAA,IACP,aAAa;AAAA,IACb,SAAS;AAAA,MACP,cAAc,MAAM;AAAA,MACpB,eAAe,MAAM;AAAA,MACrB,WAAW,MAAM;AAAA,MACjB,WAAW,MAAM;AAAA,IACnB;AAAA,EACF;AACF;AAEA,eAAsB,yCACpB,OAC8C;AAC9C,QAAM,YAAY,yCAAyC;AAAA,IACzD,cAAc,MAAM,OAAO;AAAA,IAC3B,eAAe,MAAM;AAAA,IACrB,iBAAiB,MAAM;AAAA,IACvB,WAAW,MAAM;AAAA,IACjB,QAAQ,MAAM;AAAA,IACd,SAAS,MAAM;AAAA,IACf,mBAAmB,MAAM;AAAA,EAC3B,CAAC;AACD,QAAM,YAAY,MAAM,MAAM,OAAO,cAAc,SAAS;AAE5D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,MAAM,OAAO;AAAA,IAC5B;AAAA,EACF;AACF;AAEO,MAAM,kCACX;","names":[]}
|