@opendatalabs/vana-sdk 3.4.1 → 3.5.1-pr.159.12a6f39
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 +116 -0
- package/dist/account/personal-server-lite-owner-binding.cjs +3 -3
- package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -1
- package/dist/account/personal-server-lite-owner-binding.d.ts +2 -2
- package/dist/account/personal-server-lite-owner-binding.js +1 -1
- package/dist/account/personal-server-lite-owner-binding.js.map +1 -1
- package/dist/direct/access-request-client.cjs +104 -0
- package/dist/direct/access-request-client.cjs.map +1 -0
- package/dist/direct/access-request-client.d.ts +51 -0
- package/dist/direct/access-request-client.js +79 -0
- package/dist/direct/access-request-client.js.map +1 -0
- package/dist/direct/access-request-client.test.d.ts +1 -0
- package/dist/direct/connect-flow.cjs +152 -0
- package/dist/direct/connect-flow.cjs.map +1 -0
- package/dist/direct/connect-flow.d.ts +85 -0
- package/dist/direct/connect-flow.js +128 -0
- package/dist/direct/connect-flow.js.map +1 -0
- package/dist/direct/connect-flow.test.d.ts +1 -0
- package/dist/direct/controller.cjs +129 -0
- package/dist/direct/controller.cjs.map +1 -0
- package/dist/direct/controller.d.ts +152 -0
- package/dist/direct/controller.js +109 -0
- package/dist/direct/controller.js.map +1 -0
- package/dist/direct/controller.test.d.ts +1 -0
- package/dist/direct/endpoints.cjs +45 -0
- package/dist/direct/endpoints.cjs.map +1 -0
- package/dist/direct/endpoints.d.ts +22 -0
- package/dist/direct/endpoints.js +19 -0
- package/dist/direct/endpoints.js.map +1 -0
- package/dist/direct/errors.cjs +65 -0
- package/dist/direct/errors.cjs.map +1 -0
- package/dist/direct/errors.d.ts +44 -0
- package/dist/direct/errors.js +38 -0
- package/dist/direct/errors.js.map +1 -0
- package/dist/direct/escrow-payment.cjs +96 -0
- package/dist/direct/escrow-payment.cjs.map +1 -0
- package/dist/direct/escrow-payment.d.ts +81 -0
- package/dist/direct/escrow-payment.js +72 -0
- package/dist/direct/escrow-payment.js.map +1 -0
- package/dist/direct/escrow-payment.test.d.ts +1 -0
- package/dist/direct/personal-server-read.cjs +149 -0
- package/dist/direct/personal-server-read.cjs.map +1 -0
- package/dist/direct/personal-server-read.d.ts +103 -0
- package/dist/direct/personal-server-read.js +124 -0
- package/dist/direct/personal-server-read.js.map +1 -0
- package/dist/direct/personal-server-read.test.d.ts +1 -0
- package/dist/direct/types.cjs +35 -0
- package/dist/direct/types.cjs.map +1 -0
- package/dist/direct/types.d.ts +205 -0
- package/dist/direct/types.js +11 -0
- package/dist/direct/types.js.map +1 -0
- package/dist/direct/use-direct-vana-connect.cjs +68 -0
- package/dist/direct/use-direct-vana-connect.cjs.map +1 -0
- package/dist/direct/use-direct-vana-connect.d.ts +45 -0
- package/dist/direct/use-direct-vana-connect.js +46 -0
- package/dist/direct/use-direct-vana-connect.js.map +1 -0
- package/dist/index.browser.d.ts +9 -4
- package/dist/index.browser.js +644 -178
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +672 -183
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +9 -4
- package/dist/index.node.js +644 -178
- package/dist/index.node.js.map +4 -4
- package/dist/personal-server-lite/owner-binding.cjs +93 -0
- package/dist/personal-server-lite/owner-binding.cjs.map +1 -0
- package/dist/personal-server-lite/owner-binding.d.ts +44 -0
- package/dist/personal-server-lite/owner-binding.js +65 -0
- package/dist/personal-server-lite/owner-binding.js.map +1 -0
- package/dist/personal-server-lite/owner-binding.test.d.ts +1 -0
- package/dist/protocol/data-point-status.cjs +80 -0
- package/dist/protocol/data-point-status.cjs.map +1 -0
- package/dist/protocol/data-point-status.d.ts +34 -0
- package/dist/protocol/data-point-status.js +51 -0
- package/dist/protocol/data-point-status.js.map +1 -0
- package/dist/protocol/data-point-status.test.d.ts +1 -0
- package/dist/protocol/eip712.cjs +53 -31
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +98 -43
- package/dist/protocol/eip712.js +47 -27
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow-deposit.cjs +89 -0
- package/dist/protocol/escrow-deposit.cjs.map +1 -0
- package/dist/protocol/escrow-deposit.d.ts +47 -0
- package/dist/protocol/escrow-deposit.js +60 -0
- package/dist/protocol/escrow-deposit.js.map +1 -0
- package/dist/protocol/escrow-deposit.test.d.ts +1 -0
- package/dist/protocol/escrow-flow.test.d.ts +21 -0
- package/dist/protocol/escrow.cjs +146 -0
- package/dist/protocol/escrow.cjs.map +1 -0
- package/dist/protocol/escrow.d.ts +336 -0
- package/dist/protocol/escrow.js +118 -0
- package/dist/protocol/escrow.js.map +1 -0
- package/dist/protocol/escrow.test.d.ts +1 -0
- package/dist/protocol/fee-registry.cjs +116 -0
- package/dist/protocol/fee-registry.cjs.map +1 -0
- package/dist/protocol/fee-registry.d.ts +151 -0
- package/dist/protocol/fee-registry.js +89 -0
- package/dist/protocol/fee-registry.js.map +1 -0
- package/dist/protocol/fee-registry.test.d.ts +1 -0
- package/dist/protocol/gateway.cjs +107 -37
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +223 -57
- package/dist/protocol/gateway.js +107 -37
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/grants.cjs +27 -64
- package/dist/protocol/grants.cjs.map +1 -1
- package/dist/protocol/grants.d.ts +6 -13
- package/dist/protocol/grants.js +27 -63
- package/dist/protocol/grants.js.map +1 -1
- package/dist/protocol/personal-server-data.cjs +71 -0
- package/dist/protocol/personal-server-data.cjs.map +1 -0
- package/dist/protocol/personal-server-data.d.ts +16 -0
- package/dist/protocol/personal-server-data.js +47 -0
- package/dist/protocol/personal-server-data.js.map +1 -0
- package/dist/protocol/personal-server-data.test.d.ts +1 -0
- package/dist/protocol/personal-server-registration.cjs +16 -4
- package/dist/protocol/personal-server-registration.cjs.map +1 -1
- package/dist/protocol/personal-server-registration.d.ts +5 -2
- package/dist/protocol/personal-server-registration.js +16 -4
- package/dist/protocol/personal-server-registration.js.map +1 -1
- package/dist/react.cjs +32 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.ts +33 -0
- package/dist/react.js +11 -0
- package/dist/react.js.map +1 -0
- package/dist/server.cjs +73 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.ts +32 -0
- package/dist/server.js +55 -0
- package/dist/server.js.map +1 -0
- package/dist/storage/providers/vana-storage.cjs +75 -17
- package/dist/storage/providers/vana-storage.cjs.map +1 -1
- package/dist/storage/providers/vana-storage.js +75 -17
- package/dist/storage/providers/vana-storage.js.map +1 -1
- package/package.json +20 -1
|
@@ -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 owner_binding_exports = {};
|
|
20
|
+
__export(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(owner_binding_exports);
|
|
30
|
+
var import_viem = require("viem");
|
|
31
|
+
const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.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=owner-binding.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/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 Personal Server Lite\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 =\n \"vana.ps-lite.owner-binding.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,6CACX;AACK,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 Personal Server Lite
|
|
9
|
+
*/
|
|
10
|
+
import { type Account, type Address, type Hex, type SignableMessage } from "viem";
|
|
11
|
+
export declare const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.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.ps-lite.owner-binding.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.ps-lite.owner-binding.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=owner-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/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 Personal Server Lite\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 =\n \"vana.ps-lite.owner-binding.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,6CACX;AACK,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,80 @@
|
|
|
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 data_point_status_exports = {};
|
|
20
|
+
__export(data_point_status_exports, {
|
|
21
|
+
DATA_REGISTRY_STATUS_ABI: () => DATA_REGISTRY_STATUS_ABI,
|
|
22
|
+
DataPointStatus: () => DataPointStatus,
|
|
23
|
+
buildMarkDataPointUnavailableRequest: () => buildMarkDataPointUnavailableRequest,
|
|
24
|
+
buildSetDataPointStatusRequest: () => buildSetDataPointStatusRequest,
|
|
25
|
+
dataRegistryContractAddress: () => dataRegistryContractAddress,
|
|
26
|
+
encodeSetDataPointStatusData: () => encodeSetDataPointStatusData
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(data_point_status_exports);
|
|
29
|
+
var import_viem = require("viem");
|
|
30
|
+
var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
|
|
31
|
+
DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
|
|
32
|
+
DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
|
|
33
|
+
DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
|
|
34
|
+
DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
|
|
35
|
+
return DataPointStatus2;
|
|
36
|
+
})(DataPointStatus || {});
|
|
37
|
+
const DATA_REGISTRY_STATUS_ABI = [
|
|
38
|
+
{
|
|
39
|
+
type: "function",
|
|
40
|
+
name: "setStatus",
|
|
41
|
+
stateMutability: "nonpayable",
|
|
42
|
+
inputs: [
|
|
43
|
+
{ name: "scope", type: "string" },
|
|
44
|
+
{ name: "newStatus", type: "uint8" }
|
|
45
|
+
],
|
|
46
|
+
outputs: []
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
function dataRegistryContractAddress(config) {
|
|
50
|
+
return config.contracts.dataRegistry;
|
|
51
|
+
}
|
|
52
|
+
function encodeSetDataPointStatusData(input) {
|
|
53
|
+
return (0, import_viem.encodeFunctionData)({
|
|
54
|
+
abi: DATA_REGISTRY_STATUS_ABI,
|
|
55
|
+
functionName: "setStatus",
|
|
56
|
+
args: [input.scope, input.status]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function buildSetDataPointStatusRequest(config, input) {
|
|
60
|
+
return {
|
|
61
|
+
to: dataRegistryContractAddress(config),
|
|
62
|
+
data: encodeSetDataPointStatusData(input)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function buildMarkDataPointUnavailableRequest(config, input) {
|
|
66
|
+
return buildSetDataPointStatusRequest(config, {
|
|
67
|
+
scope: input.scope,
|
|
68
|
+
status: 3 /* Unavailable */
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
DATA_REGISTRY_STATUS_ABI,
|
|
74
|
+
DataPointStatus,
|
|
75
|
+
buildMarkDataPointUnavailableRequest,
|
|
76
|
+
buildSetDataPointStatusRequest,
|
|
77
|
+
dataRegistryContractAddress,
|
|
78
|
+
encodeSetDataPointStatusData
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=data-point-status.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/data-point-status.ts"],"sourcesContent":["/**\n * On-chain status mutation primitives for DataRegistryV2 data points.\n *\n * The v2 contract drops the file concept in favor of versioned data points\n * keyed on (owner, scope). Each data point has a lifecycle Status that the\n * owner can change directly — there's no EIP-712 signature flow and no\n * gateway endpoint that mediates this, because the contract enforces\n * `msg.sender == owner` for `setStatus`. The owner therefore has to sign\n * and broadcast the tx from their own wallet.\n *\n * These helpers are signer/transport-agnostic — they return the raw\n * `{to, data}` request object so callers can feed it to any wallet stack\n * (viem `sendTransaction`/`writeContract`, ethers, wallet-rpc, MPC,\n * Safe transactions, etc.). Mirrors the shape used by `escrow-deposit.ts`.\n *\n * @category Protocol\n */\nimport { encodeFunctionData } from \"viem\";\nimport type { DataPortabilityGatewayConfig } from \"./eip712\";\n\n// Lifecycle states from IDataRegistryV2.Status. Wire encoding is uint8.\n// - None: no data point exists for this (owner, scope).\n// - Active: has data, served on /v1/escrow/pay's recordDataAccess path.\n// - Inactive: owner-paused — refuses new versions until re-activated.\n// `addData` (or addDataWithSignature) auto-revives Inactive → Active.\n// - Unavailable: terminal soft-delete — `addData` and recordDataAccess both\n// revert. The owner can still resurrect by calling setStatus(Active), but\n// that signals intent to bring the data point back online; a downstream\n// client treating Unavailable as a delete tombstone should re-fetch after\n// any DataPointStatusChanged event.\nexport enum DataPointStatus {\n None = 0,\n Active = 1,\n Inactive = 2,\n Unavailable = 3,\n}\n\n// Minimal ABI fragment for the owner-only `setStatus(scope, newStatus)`\n// entry point. Kept inline so callers don't have to load the full contract\n// ABI just to change a status.\nexport const DATA_REGISTRY_STATUS_ABI = [\n {\n type: \"function\",\n name: \"setStatus\",\n stateMutability: \"nonpayable\",\n inputs: [\n { name: \"scope\", type: \"string\" },\n { name: \"newStatus\", type: \"uint8\" },\n ],\n outputs: [],\n },\n] as const;\n\nexport function dataRegistryContractAddress(\n config: DataPortabilityGatewayConfig,\n): `0x${string}` {\n return config.contracts.dataRegistry as `0x${string}`;\n}\n\nexport interface SetDataPointStatusInput {\n scope: string;\n status: DataPointStatus;\n}\n\n// Shape compatible with viem's `sendTransaction` / `writeContract` request\n// objects. No `value` — `setStatus` is non-payable.\nexport interface DataPointStatusTransactionRequest {\n to: `0x${string}`;\n data: `0x${string}`;\n}\n\nexport function encodeSetDataPointStatusData(\n input: SetDataPointStatusInput,\n): `0x${string}` {\n return encodeFunctionData({\n abi: DATA_REGISTRY_STATUS_ABI,\n functionName: \"setStatus\",\n args: [input.scope, input.status],\n });\n}\n\n// Build the full tx request for a status change. Feed straight to\n// `walletClient.sendTransaction({...req, account, chain})`. The caller's\n// `account` MUST equal the data point's owner — the contract reverts\n// otherwise.\nexport function buildSetDataPointStatusRequest(\n config: DataPortabilityGatewayConfig,\n input: SetDataPointStatusInput,\n): DataPointStatusTransactionRequest {\n return {\n to: dataRegistryContractAddress(config),\n data: encodeSetDataPointStatusData(input),\n };\n}\n\n// Convenience for the \"remove this data point\" intent — the v2 equivalent\n// of the old DELETE /v1/files/:id flow. Sets the status to Unavailable so\n// downstream readers (recordDataAccess, future addData) revert. Callers\n// that want the data point pausable rather than tombstoned should use\n// `buildSetDataPointStatusRequest` with `DataPointStatus.Inactive`.\nexport function buildMarkDataPointUnavailableRequest(\n config: DataPortabilityGatewayConfig,\n input: { scope: string },\n): DataPointStatusTransactionRequest {\n return buildSetDataPointStatusRequest(config, {\n scope: input.scope,\n status: DataPointStatus.Unavailable,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,kBAAmC;AAa5B,IAAK,kBAAL,kBAAKA,qBAAL;AACL,EAAAA,kCAAA,UAAO,KAAP;AACA,EAAAA,kCAAA,YAAS,KAAT;AACA,EAAAA,kCAAA,cAAW,KAAX;AACA,EAAAA,kCAAA,iBAAc,KAAd;AAJU,SAAAA;AAAA,GAAA;AAUL,MAAM,2BAA2B;AAAA,EACtC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ;AAAA,MACN,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,MAChC,EAAE,MAAM,aAAa,MAAM,QAAQ;AAAA,IACrC;AAAA,IACA,SAAS,CAAC;AAAA,EACZ;AACF;AAEO,SAAS,4BACd,QACe;AACf,SAAO,OAAO,UAAU;AAC1B;AAcO,SAAS,6BACd,OACe;AACf,aAAO,gCAAmB;AAAA,IACxB,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,MAAM,OAAO,MAAM,MAAM;AAAA,EAClC,CAAC;AACH;AAMO,SAAS,+BACd,QACA,OACmC;AACnC,SAAO;AAAA,IACL,IAAI,4BAA4B,MAAM;AAAA,IACtC,MAAM,6BAA6B,KAAK;AAAA,EAC1C;AACF;AAOO,SAAS,qCACd,QACA,OACmC;AACnC,SAAO,+BAA+B,QAAQ;AAAA,IAC5C,OAAO,MAAM;AAAA,IACb,QAAQ;AAAA,EACV,CAAC;AACH;","names":["DataPointStatus"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DataPortabilityGatewayConfig } from "./eip712";
|
|
2
|
+
export declare enum DataPointStatus {
|
|
3
|
+
None = 0,
|
|
4
|
+
Active = 1,
|
|
5
|
+
Inactive = 2,
|
|
6
|
+
Unavailable = 3
|
|
7
|
+
}
|
|
8
|
+
export declare const DATA_REGISTRY_STATUS_ABI: readonly [{
|
|
9
|
+
readonly type: "function";
|
|
10
|
+
readonly name: "setStatus";
|
|
11
|
+
readonly stateMutability: "nonpayable";
|
|
12
|
+
readonly inputs: readonly [{
|
|
13
|
+
readonly name: "scope";
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "newStatus";
|
|
17
|
+
readonly type: "uint8";
|
|
18
|
+
}];
|
|
19
|
+
readonly outputs: readonly [];
|
|
20
|
+
}];
|
|
21
|
+
export declare function dataRegistryContractAddress(config: DataPortabilityGatewayConfig): `0x${string}`;
|
|
22
|
+
export interface SetDataPointStatusInput {
|
|
23
|
+
scope: string;
|
|
24
|
+
status: DataPointStatus;
|
|
25
|
+
}
|
|
26
|
+
export interface DataPointStatusTransactionRequest {
|
|
27
|
+
to: `0x${string}`;
|
|
28
|
+
data: `0x${string}`;
|
|
29
|
+
}
|
|
30
|
+
export declare function encodeSetDataPointStatusData(input: SetDataPointStatusInput): `0x${string}`;
|
|
31
|
+
export declare function buildSetDataPointStatusRequest(config: DataPortabilityGatewayConfig, input: SetDataPointStatusInput): DataPointStatusTransactionRequest;
|
|
32
|
+
export declare function buildMarkDataPointUnavailableRequest(config: DataPortabilityGatewayConfig, input: {
|
|
33
|
+
scope: string;
|
|
34
|
+
}): DataPointStatusTransactionRequest;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { encodeFunctionData } from "viem";
|
|
2
|
+
var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
|
|
3
|
+
DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
|
|
4
|
+
DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
|
|
5
|
+
DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
|
|
6
|
+
DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
|
|
7
|
+
return DataPointStatus2;
|
|
8
|
+
})(DataPointStatus || {});
|
|
9
|
+
const DATA_REGISTRY_STATUS_ABI = [
|
|
10
|
+
{
|
|
11
|
+
type: "function",
|
|
12
|
+
name: "setStatus",
|
|
13
|
+
stateMutability: "nonpayable",
|
|
14
|
+
inputs: [
|
|
15
|
+
{ name: "scope", type: "string" },
|
|
16
|
+
{ name: "newStatus", type: "uint8" }
|
|
17
|
+
],
|
|
18
|
+
outputs: []
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
function dataRegistryContractAddress(config) {
|
|
22
|
+
return config.contracts.dataRegistry;
|
|
23
|
+
}
|
|
24
|
+
function encodeSetDataPointStatusData(input) {
|
|
25
|
+
return encodeFunctionData({
|
|
26
|
+
abi: DATA_REGISTRY_STATUS_ABI,
|
|
27
|
+
functionName: "setStatus",
|
|
28
|
+
args: [input.scope, input.status]
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function buildSetDataPointStatusRequest(config, input) {
|
|
32
|
+
return {
|
|
33
|
+
to: dataRegistryContractAddress(config),
|
|
34
|
+
data: encodeSetDataPointStatusData(input)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function buildMarkDataPointUnavailableRequest(config, input) {
|
|
38
|
+
return buildSetDataPointStatusRequest(config, {
|
|
39
|
+
scope: input.scope,
|
|
40
|
+
status: 3 /* Unavailable */
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
DATA_REGISTRY_STATUS_ABI,
|
|
45
|
+
DataPointStatus,
|
|
46
|
+
buildMarkDataPointUnavailableRequest,
|
|
47
|
+
buildSetDataPointStatusRequest,
|
|
48
|
+
dataRegistryContractAddress,
|
|
49
|
+
encodeSetDataPointStatusData
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=data-point-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/data-point-status.ts"],"sourcesContent":["/**\n * On-chain status mutation primitives for DataRegistryV2 data points.\n *\n * The v2 contract drops the file concept in favor of versioned data points\n * keyed on (owner, scope). Each data point has a lifecycle Status that the\n * owner can change directly — there's no EIP-712 signature flow and no\n * gateway endpoint that mediates this, because the contract enforces\n * `msg.sender == owner` for `setStatus`. The owner therefore has to sign\n * and broadcast the tx from their own wallet.\n *\n * These helpers are signer/transport-agnostic — they return the raw\n * `{to, data}` request object so callers can feed it to any wallet stack\n * (viem `sendTransaction`/`writeContract`, ethers, wallet-rpc, MPC,\n * Safe transactions, etc.). Mirrors the shape used by `escrow-deposit.ts`.\n *\n * @category Protocol\n */\nimport { encodeFunctionData } from \"viem\";\nimport type { DataPortabilityGatewayConfig } from \"./eip712\";\n\n// Lifecycle states from IDataRegistryV2.Status. Wire encoding is uint8.\n// - None: no data point exists for this (owner, scope).\n// - Active: has data, served on /v1/escrow/pay's recordDataAccess path.\n// - Inactive: owner-paused — refuses new versions until re-activated.\n// `addData` (or addDataWithSignature) auto-revives Inactive → Active.\n// - Unavailable: terminal soft-delete — `addData` and recordDataAccess both\n// revert. The owner can still resurrect by calling setStatus(Active), but\n// that signals intent to bring the data point back online; a downstream\n// client treating Unavailable as a delete tombstone should re-fetch after\n// any DataPointStatusChanged event.\nexport enum DataPointStatus {\n None = 0,\n Active = 1,\n Inactive = 2,\n Unavailable = 3,\n}\n\n// Minimal ABI fragment for the owner-only `setStatus(scope, newStatus)`\n// entry point. Kept inline so callers don't have to load the full contract\n// ABI just to change a status.\nexport const DATA_REGISTRY_STATUS_ABI = [\n {\n type: \"function\",\n name: \"setStatus\",\n stateMutability: \"nonpayable\",\n inputs: [\n { name: \"scope\", type: \"string\" },\n { name: \"newStatus\", type: \"uint8\" },\n ],\n outputs: [],\n },\n] as const;\n\nexport function dataRegistryContractAddress(\n config: DataPortabilityGatewayConfig,\n): `0x${string}` {\n return config.contracts.dataRegistry as `0x${string}`;\n}\n\nexport interface SetDataPointStatusInput {\n scope: string;\n status: DataPointStatus;\n}\n\n// Shape compatible with viem's `sendTransaction` / `writeContract` request\n// objects. No `value` — `setStatus` is non-payable.\nexport interface DataPointStatusTransactionRequest {\n to: `0x${string}`;\n data: `0x${string}`;\n}\n\nexport function encodeSetDataPointStatusData(\n input: SetDataPointStatusInput,\n): `0x${string}` {\n return encodeFunctionData({\n abi: DATA_REGISTRY_STATUS_ABI,\n functionName: \"setStatus\",\n args: [input.scope, input.status],\n });\n}\n\n// Build the full tx request for a status change. Feed straight to\n// `walletClient.sendTransaction({...req, account, chain})`. The caller's\n// `account` MUST equal the data point's owner — the contract reverts\n// otherwise.\nexport function buildSetDataPointStatusRequest(\n config: DataPortabilityGatewayConfig,\n input: SetDataPointStatusInput,\n): DataPointStatusTransactionRequest {\n return {\n to: dataRegistryContractAddress(config),\n data: encodeSetDataPointStatusData(input),\n };\n}\n\n// Convenience for the \"remove this data point\" intent — the v2 equivalent\n// of the old DELETE /v1/files/:id flow. Sets the status to Unavailable so\n// downstream readers (recordDataAccess, future addData) revert. Callers\n// that want the data point pausable rather than tombstoned should use\n// `buildSetDataPointStatusRequest` with `DataPointStatus.Inactive`.\nexport function buildMarkDataPointUnavailableRequest(\n config: DataPortabilityGatewayConfig,\n input: { scope: string },\n): DataPointStatusTransactionRequest {\n return buildSetDataPointStatusRequest(config, {\n scope: input.scope,\n status: DataPointStatus.Unavailable,\n });\n}\n"],"mappings":"AAiBA,SAAS,0BAA0B;AAa5B,IAAK,kBAAL,kBAAKA,qBAAL;AACL,EAAAA,kCAAA,UAAO,KAAP;AACA,EAAAA,kCAAA,YAAS,KAAT;AACA,EAAAA,kCAAA,cAAW,KAAX;AACA,EAAAA,kCAAA,iBAAc,KAAd;AAJU,SAAAA;AAAA,GAAA;AAUL,MAAM,2BAA2B;AAAA,EACtC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ;AAAA,MACN,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,MAChC,EAAE,MAAM,aAAa,MAAM,QAAQ;AAAA,IACrC;AAAA,IACA,SAAS,CAAC;AAAA,EACZ;AACF;AAEO,SAAS,4BACd,QACe;AACf,SAAO,OAAO,UAAU;AAC1B;AAcO,SAAS,6BACd,OACe;AACf,SAAO,mBAAmB;AAAA,IACxB,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,MAAM,OAAO,MAAM,MAAM;AAAA,EAClC,CAAC;AACH;AAMO,SAAS,+BACd,QACA,OACmC;AACnC,SAAO;AAAA,IACL,IAAI,4BAA4B,MAAM;AAAA,IACtC,MAAM,6BAA6B,KAAK;AAAA,EAC1C;AACF;AAOO,SAAS,qCACd,QACA,OACmC;AACnC,SAAO,+BAA+B,QAAQ;AAAA,IAC5C,OAAO,MAAM;AAAA,IACb,QAAQ;AAAA,EACV,CAAC;AACH;","names":["DataPointStatus"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/protocol/eip712.cjs
CHANGED
|
@@ -18,15 +18,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var eip712_exports = {};
|
|
20
20
|
__export(eip712_exports, {
|
|
21
|
+
ADD_DATA_TYPES: () => ADD_DATA_TYPES,
|
|
21
22
|
BUILDER_REGISTRATION_TYPES: () => BUILDER_REGISTRATION_TYPES,
|
|
22
|
-
|
|
23
|
-
FILE_REGISTRATION_TYPES: () => FILE_REGISTRATION_TYPES,
|
|
23
|
+
GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
|
|
24
24
|
GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
|
|
25
25
|
GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
|
|
26
|
+
NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
|
|
27
|
+
RECORD_DATA_ACCESS_TYPES: () => RECORD_DATA_ACCESS_TYPES,
|
|
26
28
|
SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
|
|
27
29
|
builderRegistrationDomain: () => builderRegistrationDomain,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
dataRegistryDomain: () => dataRegistryDomain,
|
|
31
|
+
escrowPaymentDomain: () => escrowPaymentDomain,
|
|
30
32
|
grantRegistrationDomain: () => grantRegistrationDomain,
|
|
31
33
|
grantRevocationDomain: () => grantRevocationDomain,
|
|
32
34
|
serverRegistrationDomain: () => serverRegistrationDomain
|
|
@@ -34,6 +36,7 @@ __export(eip712_exports, {
|
|
|
34
36
|
module.exports = __toCommonJS(eip712_exports);
|
|
35
37
|
const DOMAIN_NAME = "Vana Data Portability";
|
|
36
38
|
const DOMAIN_VERSION = "1";
|
|
39
|
+
const NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
37
40
|
function buildDomain(chainId, verifyingContract) {
|
|
38
41
|
return {
|
|
39
42
|
name: DOMAIN_NAME,
|
|
@@ -42,13 +45,7 @@ function buildDomain(chainId, verifyingContract) {
|
|
|
42
45
|
verifyingContract
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
|
-
function
|
|
46
|
-
return buildDomain(
|
|
47
|
-
config.chainId,
|
|
48
|
-
config.contracts.dataRegistry
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
function fileDeletionDomain(config) {
|
|
48
|
+
function dataRegistryDomain(config) {
|
|
52
49
|
return buildDomain(
|
|
53
50
|
config.chainId,
|
|
54
51
|
config.contracts.dataRegistry
|
|
@@ -78,31 +75,26 @@ function builderRegistrationDomain(config) {
|
|
|
78
75
|
config.contracts.dataPortabilityGrantees
|
|
79
76
|
);
|
|
80
77
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
const FILE_DELETION_TYPES = {
|
|
89
|
-
FileDeletion: [
|
|
90
|
-
{ name: "ownerAddress", type: "address" },
|
|
91
|
-
{ name: "fileId", type: "bytes32" }
|
|
92
|
-
]
|
|
93
|
-
};
|
|
78
|
+
function escrowPaymentDomain(config) {
|
|
79
|
+
return buildDomain(
|
|
80
|
+
config.chainId,
|
|
81
|
+
config.contracts.dataPortabilityEscrow
|
|
82
|
+
);
|
|
83
|
+
}
|
|
94
84
|
const GRANT_REGISTRATION_TYPES = {
|
|
95
85
|
GrantRegistration: [
|
|
96
86
|
{ name: "grantorAddress", type: "address" },
|
|
97
87
|
{ name: "granteeId", type: "bytes32" },
|
|
98
|
-
{ name: "
|
|
99
|
-
{ name: "
|
|
88
|
+
{ name: "scopes", type: "string[]" },
|
|
89
|
+
{ name: "grantVersion", type: "uint256" },
|
|
90
|
+
{ name: "expiresAt", type: "uint256" }
|
|
100
91
|
]
|
|
101
92
|
};
|
|
102
93
|
const GRANT_REVOCATION_TYPES = {
|
|
103
94
|
GrantRevocation: [
|
|
104
95
|
{ name: "grantorAddress", type: "address" },
|
|
105
|
-
{ name: "grantId", type: "bytes32" }
|
|
96
|
+
{ name: "grantId", type: "bytes32" },
|
|
97
|
+
{ name: "grantVersion", type: "uint256" }
|
|
106
98
|
]
|
|
107
99
|
};
|
|
108
100
|
const SERVER_REGISTRATION_TYPES = {
|
|
@@ -121,17 +113,47 @@ const BUILDER_REGISTRATION_TYPES = {
|
|
|
121
113
|
{ name: "appUrl", type: "string" }
|
|
122
114
|
]
|
|
123
115
|
};
|
|
116
|
+
const GENERIC_PAYMENT_TYPES = {
|
|
117
|
+
GenericPayment: [
|
|
118
|
+
{ name: "payerAddress", type: "address" },
|
|
119
|
+
{ name: "opType", type: "string" },
|
|
120
|
+
{ name: "opId", type: "bytes32" },
|
|
121
|
+
{ name: "asset", type: "address" },
|
|
122
|
+
{ name: "amount", type: "uint256" },
|
|
123
|
+
{ name: "paymentNonce", type: "uint256" }
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
const ADD_DATA_TYPES = {
|
|
127
|
+
AddData: [
|
|
128
|
+
{ name: "ownerAddress", type: "address" },
|
|
129
|
+
{ name: "scope", type: "string" },
|
|
130
|
+
{ name: "dataHash", type: "bytes32" },
|
|
131
|
+
{ name: "metadataHash", type: "bytes32" },
|
|
132
|
+
{ name: "expectedVersion", type: "uint256" }
|
|
133
|
+
]
|
|
134
|
+
};
|
|
135
|
+
const RECORD_DATA_ACCESS_TYPES = {
|
|
136
|
+
RecordDataAccess: [
|
|
137
|
+
{ name: "ownerAddress", type: "address" },
|
|
138
|
+
{ name: "scope", type: "string" },
|
|
139
|
+
{ name: "version", type: "uint256" },
|
|
140
|
+
{ name: "accessor", type: "address" },
|
|
141
|
+
{ name: "recordId", type: "bytes32" }
|
|
142
|
+
]
|
|
143
|
+
};
|
|
124
144
|
// Annotate the CommonJS export names for ESM import in node:
|
|
125
145
|
0 && (module.exports = {
|
|
146
|
+
ADD_DATA_TYPES,
|
|
126
147
|
BUILDER_REGISTRATION_TYPES,
|
|
127
|
-
|
|
128
|
-
FILE_REGISTRATION_TYPES,
|
|
148
|
+
GENERIC_PAYMENT_TYPES,
|
|
129
149
|
GRANT_REGISTRATION_TYPES,
|
|
130
150
|
GRANT_REVOCATION_TYPES,
|
|
151
|
+
NATIVE_VANA_ASSET,
|
|
152
|
+
RECORD_DATA_ACCESS_TYPES,
|
|
131
153
|
SERVER_REGISTRATION_TYPES,
|
|
132
154
|
builderRegistrationDomain,
|
|
133
|
-
|
|
134
|
-
|
|
155
|
+
dataRegistryDomain,
|
|
156
|
+
escrowPaymentDomain,
|
|
135
157
|
grantRegistrationDomain,
|
|
136
158
|
grantRevocationDomain,
|
|
137
159
|
serverRegistrationDomain
|
|
@@ -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 fileDeletionDomain(\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 FILE_DELETION_TYPES = {\n FileDeletion: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"fileId\", 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 FileDeletionMessage {\n ownerAddress: `0x${string}`;\n /**\n * Off-chain gateway file ID — bytes32, as returned by `GET /v1/files`. This is NOT the on-chain\n * uint256 DataRegistry file ID; consumers (e.g. the PS delete cascade) must source it from the\n * gateway, not derive it from a numeric on-chain ID.\n */\n fileId: `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;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,mBACd,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,sBAAsB;AAAA,EACjC,cAAc;AAAA,IACZ,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,EACpC;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":[]}
|
|
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 // DataPortabilityEscrow — verifies GENERIC_PAYMENT_TYPES signatures backing\n // /v1/escrow/pay (the data-access payment path).\n dataPortabilityEscrow: string;\n // FeeRegistry — per-operation `{amount, asset, payee, enabled}` records\n // keyed on `keccak256(name)`. The gateway re-resolves fees against this\n // contract on every /v1/escrow/pay so the SDK has to read the same\n // source of truth to size payment amounts.\n feeRegistry: string;\n}\n\n// Native VANA asset sentinel used by /v1/escrow/pay's `asset` field — pay any\n// other ERC-20 by passing its contract address instead.\nexport const NATIVE_VANA_ASSET =\n \"0x0000000000000000000000000000000000000000\" as const;\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\n// Domain for the DataRegistryV2 contract — verifies the AddData and\n// RecordDataAccess EIP-712 signatures. The v2 contract dropped the file\n// concept entirely in favor of versioned data points keyed on (owner,\n// scope); the primaryType distinguishes the two flows.\nexport function dataRegistryDomain(\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\n// Domain for the generic-payment EIP-712 signature consumed by\n// /v1/escrow/pay. The verifyingContract is the escrow itself (not the per-op\n// contract), so a single signature debits the payer's escrow balance for any\n// supported op — `grant` today; file/builder/schema in the future.\nexport function escrowPaymentDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityEscrow as `0x${string}`,\n );\n}\n\n// grantVersion is a monotonic uint256 nonce per (grantor, grantee) pair. The\n// gateway rejects any registration whose version is <= the stored value,\n// which is the replay-attack defence now that re-registering the same pair\n// is a permitted override. expiresAt is unix seconds; 0 = no expiry.\nexport const GRANT_REGISTRATION_TYPES = {\n GrantRegistration: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"granteeId\", type: \"bytes32\" },\n { name: \"scopes\", type: \"string[]\" },\n { name: \"grantVersion\", type: \"uint256\" },\n { name: \"expiresAt\", type: \"uint256\" },\n ],\n} as const;\n\n// Revocation shares the (grantor, grantee) monotonic nonce with registration —\n// both events advance the same grantVersion counter so an old revocation sig\n// can't be replayed across a revoke → re-register cycle.\nexport const GRANT_REVOCATION_TYPES = {\n GrantRevocation: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"grantId\", type: \"bytes32\" },\n { name: \"grantVersion\", type: \"uint256\" },\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\n// Generic payment for the escrow flow. The (opType, opId) pair routes the\n// debit to the right op-row; paymentNonce is per-payer monotonic so the same\n// signed message can't be replayed after a revoke + re-register cycle.\n//\n// Today opType is always 'grant' and opId is the bytes32 grantId.\nexport const GENERIC_PAYMENT_TYPES = {\n GenericPayment: [\n { name: \"payerAddress\", type: \"address\" },\n { name: \"opType\", type: \"string\" },\n { name: \"opId\", type: \"bytes32\" },\n { name: \"asset\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n { name: \"paymentNonce\", type: \"uint256\" },\n ],\n} as const;\n\n// AddData is signed by the data point's owner — registers (scope, dataHash,\n// metadataHash) on DataRegistryV2. expectedVersion is the version the caller\n// believes is current; the contract rejects with a CAS error if it isn't.\n// Used at POST /v1/data.\nexport const ADD_DATA_TYPES = {\n AddData: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"scope\", type: \"string\" },\n { name: \"dataHash\", type: \"bytes32\" },\n { name: \"metadataHash\", type: \"bytes32\" },\n { name: \"expectedVersion\", type: \"uint256\" },\n ],\n} as const;\n\n// RecordDataAccess is signed by a *trusted personal server* of `ownerAddress`\n// — attests that (scope, version) was served to `accessor`. recordId is a\n// per-event bytes32 the contract pins in `_usedRecordIds` to prevent replay.\n// Used as the optional `accessRecord` on POST /v1/escrow/pay.\nexport const RECORD_DATA_ACCESS_TYPES = {\n RecordDataAccess: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"scope\", type: \"string\" },\n { name: \"version\", type: \"uint256\" },\n { name: \"accessor\", type: \"address\" },\n { name: \"recordId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport interface GrantRegistrationMessage {\n grantorAddress: `0x${string}`;\n granteeId: `0x${string}`;\n scopes: string[];\n grantVersion: bigint;\n expiresAt: bigint;\n}\n\nexport interface GrantRevocationMessage {\n grantorAddress: `0x${string}`;\n grantId: `0x${string}`;\n grantVersion: bigint;\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\nexport interface GenericPaymentMessage {\n payerAddress: `0x${string}`;\n // 'grant' today — extensible to 'file' | 'builder' | 'schema' as those\n // op-types become payable. Sent verbatim over the wire and into the\n // typed-data string field, so callers must match the gateway's spelling.\n opType: string;\n opId: `0x${string}`;\n // NATIVE_VANA_ASSET for native VANA; an ERC-20 contract address otherwise.\n asset: `0x${string}`;\n amount: bigint;\n paymentNonce: bigint;\n}\n\nexport interface AddDataMessage {\n ownerAddress: `0x${string}`;\n scope: string;\n dataHash: `0x${string}`;\n metadataHash: `0x${string}`;\n expectedVersion: bigint;\n}\n\nexport interface RecordDataAccessMessage {\n ownerAddress: `0x${string}`;\n scope: string;\n version: bigint;\n accessor: `0x${string}`;\n recordId: `0x${string}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAmBhB,MAAM,oBACX;AAOF,SAAS,YACP,SACA,mBACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAMO,SAAS,mBACd,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;AAMO,SAAS,oBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAMO,MAAM,2BAA2B;AAAA,EACtC,mBAAmB;AAAA,IACjB,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,UAAU;AAAA,IACrC,EAAE,MAAM,UAAU,MAAM,WAAW;AAAA,IACnC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,aAAa,MAAM,UAAU;AAAA,EACvC;AACF;AAKO,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,IACf,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,IACnC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,EAC1C;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;AAOO,MAAM,wBAAwB;AAAA,EACnC,gBAAgB;AAAA,IACd,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,UAAU,MAAM,SAAS;AAAA,IACjC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,IAChC,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,IACjC,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,IAClC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,EAC1C;AACF;AAMO,MAAM,iBAAiB;AAAA,EAC5B,SAAS;AAAA,IACP,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,IACpC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,mBAAmB,MAAM,UAAU;AAAA,EAC7C;AACF;AAMO,MAAM,2BAA2B;AAAA,EACtC,kBAAkB;AAAA,IAChB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,IACnC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,IACpC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,EACtC;AACF;","names":[]}
|