@opendatalabs/vana-sdk 3.4.0 → 3.4.1-canary.7afbfe0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.d.ts +7 -3
- package/dist/index.browser.js +423 -128
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +448 -133
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +7 -3
- package/dist/index.node.js +423 -128
- package/dist/index.node.js.map +4 -4
- 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/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 +110 -38
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +238 -56
- package/dist/protocol/gateway.js +110 -38
- 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/package.json +3 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Web3SignedSignFn } from "../auth/web3-signed-builder";
|
|
2
|
+
import { type DataFileEnvelope } from "./data-file";
|
|
3
|
+
export interface BuildPersonalServerDataReadRequestParams {
|
|
4
|
+
personalServerUrl: string;
|
|
5
|
+
scope: string;
|
|
6
|
+
grantId: string;
|
|
7
|
+
signMessage: Web3SignedSignFn;
|
|
8
|
+
audience?: string;
|
|
9
|
+
headers?: HeadersInit;
|
|
10
|
+
}
|
|
11
|
+
export interface ReadPersonalServerDataParams extends BuildPersonalServerDataReadRequestParams {
|
|
12
|
+
fetch?: typeof fetch;
|
|
13
|
+
}
|
|
14
|
+
export declare function personalServerDataReadPath(scope: string): string;
|
|
15
|
+
export declare function buildPersonalServerDataReadRequest(params: BuildPersonalServerDataReadRequestParams): Promise<Request>;
|
|
16
|
+
export declare function readPersonalServerData(params: ReadPersonalServerDataParams): Promise<DataFileEnvelope>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildWeb3SignedHeader
|
|
3
|
+
} from "../auth/web3-signed-builder.js";
|
|
4
|
+
import { DataFileEnvelopeSchema } from "./data-file.js";
|
|
5
|
+
function personalServerDataReadPath(scope) {
|
|
6
|
+
return `/v1/data/${encodeURIComponent(scope)}`;
|
|
7
|
+
}
|
|
8
|
+
async function buildPersonalServerDataReadRequest(params) {
|
|
9
|
+
const path = personalServerDataReadPath(params.scope);
|
|
10
|
+
const baseUrl = params.personalServerUrl.replace(/\/+$/, "");
|
|
11
|
+
const audience = params.audience ?? baseUrl;
|
|
12
|
+
const headers = new Headers(params.headers);
|
|
13
|
+
headers.set(
|
|
14
|
+
"Authorization",
|
|
15
|
+
await buildWeb3SignedHeader({
|
|
16
|
+
aud: audience,
|
|
17
|
+
grantId: params.grantId,
|
|
18
|
+
method: "GET",
|
|
19
|
+
signMessage: params.signMessage,
|
|
20
|
+
uri: path
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
return new Request(`${baseUrl}${path}`, {
|
|
24
|
+
headers,
|
|
25
|
+
method: "GET"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async function readPersonalServerData(params) {
|
|
29
|
+
const fetchFn = params.fetch ?? globalThis.fetch;
|
|
30
|
+
if (fetchFn === void 0) {
|
|
31
|
+
throw new Error("No fetch implementation available");
|
|
32
|
+
}
|
|
33
|
+
const request = await buildPersonalServerDataReadRequest(params);
|
|
34
|
+
const response = await fetchFn(request);
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Personal Server data read failed: ${response.status} ${response.statusText}`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return DataFileEnvelopeSchema.parse(await response.json());
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
buildPersonalServerDataReadRequest,
|
|
44
|
+
personalServerDataReadPath,
|
|
45
|
+
readPersonalServerData
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=personal-server-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/personal-server-data.ts"],"sourcesContent":["import {\n buildWeb3SignedHeader,\n type Web3SignedSignFn,\n} from \"../auth/web3-signed-builder\";\nimport { DataFileEnvelopeSchema, type DataFileEnvelope } from \"./data-file\";\n\nexport interface BuildPersonalServerDataReadRequestParams {\n personalServerUrl: string;\n scope: string;\n grantId: string;\n signMessage: Web3SignedSignFn;\n audience?: string;\n headers?: HeadersInit;\n}\n\nexport interface ReadPersonalServerDataParams extends BuildPersonalServerDataReadRequestParams {\n fetch?: typeof fetch;\n}\n\nexport function personalServerDataReadPath(scope: string): string {\n return `/v1/data/${encodeURIComponent(scope)}`;\n}\n\nexport async function buildPersonalServerDataReadRequest(\n params: BuildPersonalServerDataReadRequestParams,\n): Promise<Request> {\n const path = personalServerDataReadPath(params.scope);\n const baseUrl = params.personalServerUrl.replace(/\\/+$/, \"\");\n const audience = params.audience ?? baseUrl;\n const headers = new Headers(params.headers);\n\n headers.set(\n \"Authorization\",\n await buildWeb3SignedHeader({\n aud: audience,\n grantId: params.grantId,\n method: \"GET\",\n signMessage: params.signMessage,\n uri: path,\n }),\n );\n\n return new Request(`${baseUrl}${path}`, {\n headers,\n method: \"GET\",\n });\n}\n\nexport async function readPersonalServerData(\n params: ReadPersonalServerDataParams,\n): Promise<DataFileEnvelope> {\n const fetchFn = params.fetch ?? globalThis.fetch;\n if (fetchFn === undefined) {\n throw new Error(\"No fetch implementation available\");\n }\n\n const request = await buildPersonalServerDataReadRequest(params);\n const response = await fetchFn(request);\n\n if (!response.ok) {\n throw new Error(\n `Personal Server data read failed: ${response.status} ${response.statusText}`,\n );\n }\n\n return DataFileEnvelopeSchema.parse(await response.json());\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAEK;AACP,SAAS,8BAAqD;AAevD,SAAS,2BAA2B,OAAuB;AAChE,SAAO,YAAY,mBAAmB,KAAK,CAAC;AAC9C;AAEA,eAAsB,mCACpB,QACkB;AAClB,QAAM,OAAO,2BAA2B,OAAO,KAAK;AACpD,QAAM,UAAU,OAAO,kBAAkB,QAAQ,QAAQ,EAAE;AAC3D,QAAM,WAAW,OAAO,YAAY;AACpC,QAAM,UAAU,IAAI,QAAQ,OAAO,OAAO;AAE1C,UAAQ;AAAA,IACN;AAAA,IACA,MAAM,sBAAsB;AAAA,MAC1B,KAAK;AAAA,MACL,SAAS,OAAO;AAAA,MAChB,QAAQ;AAAA,MACR,aAAa,OAAO;AAAA,MACpB,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AAEA,SAAO,IAAI,QAAQ,GAAG,OAAO,GAAG,IAAI,IAAI;AAAA,IACtC;AAAA,IACA,QAAQ;AAAA,EACV,CAAC;AACH;AAEA,eAAsB,uBACpB,QAC2B;AAC3B,QAAM,UAAU,OAAO,SAAS,WAAW;AAC3C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI,MAAM,mCAAmC;AAAA,EACrD;AAEA,QAAM,UAAU,MAAM,mCAAmC,MAAM;AAC/D,QAAM,WAAW,MAAM,QAAQ,OAAO;AAEtC,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI;AAAA,MACR,qCAAqC,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,IAC7E;AAAA,EACF;AAEA,SAAO,uBAAuB,MAAM,MAAM,SAAS,KAAK,CAAC;AAC3D;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendatalabs/vana-sdk",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.1-canary.7afbfe0",
|
|
4
4
|
"description": "A TypeScript library for interacting with Vana Network smart contracts.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -101,7 +101,8 @@
|
|
|
101
101
|
"test:coverage:verbose": "vitest run --coverage --reporter=verbose --coverage.reporter=text",
|
|
102
102
|
"discover-addresses": "tsx scripts/discover-addresses.ts",
|
|
103
103
|
"fetch-abis": "tsx scripts/fetch-abis.ts",
|
|
104
|
-
"generate": "npm run discover-addresses && npm run fetch-abis"
|
|
104
|
+
"generate": "npm run discover-addresses && npm run fetch-abis",
|
|
105
|
+
"e2e:deposit": "tsx scripts/e2e-escrow-deposit.ts"
|
|
105
106
|
},
|
|
106
107
|
"keywords": [
|
|
107
108
|
"vana",
|