@opendatalabs/vana-sdk 3.0.0 → 3.0.1-pr.147.a4abdb1
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/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 +196 -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 +172 -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/web3-signed.cjs +28 -3
- package/dist/auth/web3-signed.cjs.map +1 -1
- package/dist/auth/web3-signed.js +28 -3
- package/dist/auth/web3-signed.js.map +1 -1
- package/dist/index.browser.d.ts +5 -0
- package/dist/index.browser.js +562 -16
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +580 -16
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +5 -0
- package/dist/index.node.js +562 -16
- package/dist/index.node.js.map +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.cjs +146 -0
- package/dist/protocol/grants.cjs.map +1 -0
- package/dist/protocol/grants.d.ts +31 -0
- package/dist/protocol/grants.js +123 -0
- package/dist/protocol/grants.js.map +1 -0
- package/dist/protocol/grants.test.d.ts +1 -0
- 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/index.cjs.map +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/providers/vana-storage.cjs +1 -1
- package/dist/storage/providers/vana-storage.cjs.map +1 -1
- package/dist/storage/providers/vana-storage.d.ts +2 -2
- package/dist/storage/providers/vana-storage.js +1 -1
- package/dist/storage/providers/vana-storage.js.map +1 -1
- package/dist/types/ps-errors.cjs +37 -12
- package/dist/types/ps-errors.cjs.map +1 -1
- package/dist/types/ps-errors.d.ts +7 -6
- package/dist/types/ps-errors.js +37 -12
- package/dist/types/ps-errors.js.map +1 -1
- package/package.json +1 -1
package/dist/types/ps-errors.cjs
CHANGED
|
@@ -31,32 +31,57 @@ class PSError extends Error {
|
|
|
31
31
|
code;
|
|
32
32
|
}
|
|
33
33
|
const KNOWN_CODES = /* @__PURE__ */ new Set([
|
|
34
|
+
"missing_auth",
|
|
35
|
+
"invalid_signature",
|
|
36
|
+
"unregistered_builder",
|
|
37
|
+
"not_owner",
|
|
38
|
+
"expired_token",
|
|
34
39
|
"grant_invalid",
|
|
40
|
+
"grant_required",
|
|
41
|
+
"grant_expired",
|
|
35
42
|
"grant_revoked",
|
|
43
|
+
"scope_mismatch",
|
|
36
44
|
"fee_required",
|
|
37
|
-
"ps_unavailable"
|
|
45
|
+
"ps_unavailable",
|
|
46
|
+
"server_not_configured",
|
|
47
|
+
"content_too_large"
|
|
38
48
|
]);
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
function isRecord(value) {
|
|
50
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
51
|
+
}
|
|
52
|
+
function normalizeCode(value) {
|
|
53
|
+
if (typeof value !== "string") {
|
|
41
54
|
return null;
|
|
42
55
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
const code = value.toLowerCase();
|
|
57
|
+
return KNOWN_CODES.has(code) ? code : null;
|
|
58
|
+
}
|
|
59
|
+
function extractPSErrorBody(body) {
|
|
60
|
+
if (!isRecord(body)) {
|
|
47
61
|
return null;
|
|
48
62
|
}
|
|
49
|
-
|
|
63
|
+
const nested = isRecord(body.error) ? body.error : null;
|
|
64
|
+
const code = normalizeCode(
|
|
65
|
+
nested?.errorCode ?? nested?.code ?? body.errorCode ?? body.code
|
|
66
|
+
);
|
|
67
|
+
const message = nested?.message ?? body.message;
|
|
68
|
+
if (!code || typeof message !== "string") {
|
|
50
69
|
return null;
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
return { code, message };
|
|
72
|
+
}
|
|
73
|
+
async function parsePSError(response) {
|
|
74
|
+
if (response.ok) {
|
|
54
75
|
return null;
|
|
55
76
|
}
|
|
56
|
-
|
|
77
|
+
let body;
|
|
78
|
+
try {
|
|
79
|
+
body = await response.json();
|
|
80
|
+
} catch {
|
|
57
81
|
return null;
|
|
58
82
|
}
|
|
59
|
-
|
|
83
|
+
const errorBody = extractPSErrorBody(body);
|
|
84
|
+
return errorBody ? new PSError(errorBody.code, errorBody.message) : null;
|
|
60
85
|
}
|
|
61
86
|
// Annotate the CommonJS export names for ESM import in node:
|
|
62
87
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/ps-errors.ts"],"sourcesContent":["/**\n * Typed errors returned by Personal Server endpoints.\n *\n * @remarks\n *
|
|
1
|
+
{"version":3,"sources":["../../src/types/ps-errors.ts"],"sourcesContent":["/**\n * Typed errors returned by Personal Server endpoints.\n *\n * @remarks\n * vana-connect (and other PS clients) need to branch on a small, stable set\n * of lowercase error codes. Personal Server routes currently return protocol\n * errors as `{ error: { code, errorCode, message } }`, while older PoC\n * clients used `{ code, message }`; the parser accepts both shapes.\n *\n * @category Auth\n */\n\n/** Stable error codes returned by Personal Server. */\nexport type PSErrorCode =\n | \"missing_auth\"\n | \"invalid_signature\"\n | \"unregistered_builder\"\n | \"not_owner\"\n | \"expired_token\"\n | \"grant_invalid\"\n | \"grant_required\"\n | \"grant_expired\"\n | \"grant_revoked\"\n | \"scope_mismatch\"\n | \"fee_required\"\n | \"ps_unavailable\"\n | \"server_not_configured\"\n | \"content_too_large\";\n\n/** Typed error wrapping a non-2xx Personal Server response. */\nexport class PSError extends Error {\n constructor(\n public readonly code: PSErrorCode,\n message: string,\n ) {\n super(message);\n this.name = \"PSError\";\n }\n}\n\nconst KNOWN_CODES: ReadonlySet<PSErrorCode> = new Set<PSErrorCode>([\n \"missing_auth\",\n \"invalid_signature\",\n \"unregistered_builder\",\n \"not_owner\",\n \"expired_token\",\n \"grant_invalid\",\n \"grant_required\",\n \"grant_expired\",\n \"grant_revoked\",\n \"scope_mismatch\",\n \"fee_required\",\n \"ps_unavailable\",\n \"server_not_configured\",\n \"content_too_large\",\n]);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction normalizeCode(value: unknown): PSErrorCode | null {\n if (typeof value !== \"string\") {\n return null;\n }\n const code = value.toLowerCase() as PSErrorCode;\n return KNOWN_CODES.has(code) ? code : null;\n}\n\nfunction extractPSErrorBody(\n body: unknown,\n): { code: PSErrorCode; message: string } | null {\n if (!isRecord(body)) {\n return null;\n }\n\n const nested = isRecord(body.error) ? body.error : null;\n const code = normalizeCode(\n nested?.errorCode ?? nested?.code ?? body.errorCode ?? body.code,\n );\n const message = nested?.message ?? body.message;\n\n if (!code || typeof message !== \"string\") {\n return null;\n }\n\n return { code, message };\n}\n\n/**\n * Read a Personal Server JSON error body from a non-2xx {@link Response} and\n * return the typed {@link PSError}. The returned code is always lowercase.\n *\n * @returns A {@link PSError} for non-2xx responses with a recognised code,\n * or `null` for 2xx responses, malformed JSON, or unrecognised codes.\n */\nexport async function parsePSError(\n response: Response,\n): Promise<PSError | null> {\n if (response.ok) {\n return null;\n }\n\n let body: unknown;\n try {\n body = await response.json();\n } catch {\n return null;\n }\n\n const errorBody = extractPSErrorBody(body);\n return errorBody ? new PSError(errorBody.code, errorBody.message) : null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BO,MAAM,gBAAgB,MAAM;AAAA,EACjC,YACkB,MAChB,SACA;AACA,UAAM,OAAO;AAHG;AAIhB,SAAK,OAAO;AAAA,EACd;AAAA,EALkB;AAMpB;AAEA,MAAM,cAAwC,oBAAI,IAAiB;AAAA,EACjE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,SAAS,OAAkD;AAClE,SAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,cAAc,OAAoC;AACzD,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,QAAM,OAAO,MAAM,YAAY;AAC/B,SAAO,YAAY,IAAI,IAAI,IAAI,OAAO;AACxC;AAEA,SAAS,mBACP,MAC+C;AAC/C,MAAI,CAAC,SAAS,IAAI,GAAG;AACnB,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,SAAS,KAAK,KAAK,IAAI,KAAK,QAAQ;AACnD,QAAM,OAAO;AAAA,IACX,QAAQ,aAAa,QAAQ,QAAQ,KAAK,aAAa,KAAK;AAAA,EAC9D;AACA,QAAM,UAAU,QAAQ,WAAW,KAAK;AAExC,MAAI,CAAC,QAAQ,OAAO,YAAY,UAAU;AACxC,WAAO;AAAA,EACT;AAEA,SAAO,EAAE,MAAM,QAAQ;AACzB;AASA,eAAsB,aACpB,UACyB;AACzB,MAAI,SAAS,IAAI;AACf,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI;AACF,WAAO,MAAM,SAAS,KAAK;AAAA,EAC7B,QAAQ;AACN,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,mBAAmB,IAAI;AACzC,SAAO,YAAY,IAAI,QAAQ,UAAU,MAAM,UAAU,OAAO,IAAI;AACtE;","names":[]}
|
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
* Typed errors returned by Personal Server endpoints.
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* vana-connect (and other PS clients) need to branch on a small, stable set
|
|
6
|
+
* of lowercase error codes. Personal Server routes currently return protocol
|
|
7
|
+
* errors as `{ error: { code, errorCode, message } }`, while older PoC
|
|
8
|
+
* clients used `{ code, message }`; the parser accepts both shapes.
|
|
8
9
|
*
|
|
9
10
|
* @category Auth
|
|
10
11
|
*/
|
|
11
12
|
/** Stable error codes returned by Personal Server. */
|
|
12
|
-
export type PSErrorCode = "grant_invalid" | "grant_revoked" | "fee_required" | "ps_unavailable";
|
|
13
|
+
export type PSErrorCode = "missing_auth" | "invalid_signature" | "unregistered_builder" | "not_owner" | "expired_token" | "grant_invalid" | "grant_required" | "grant_expired" | "grant_revoked" | "scope_mismatch" | "fee_required" | "ps_unavailable" | "server_not_configured" | "content_too_large";
|
|
13
14
|
/** Typed error wrapping a non-2xx Personal Server response. */
|
|
14
15
|
export declare class PSError extends Error {
|
|
15
16
|
readonly code: PSErrorCode;
|
|
16
17
|
constructor(code: PSErrorCode, message: string);
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
|
-
* Read a
|
|
20
|
-
* return the typed {@link PSError}.
|
|
20
|
+
* Read a Personal Server JSON error body from a non-2xx {@link Response} and
|
|
21
|
+
* return the typed {@link PSError}. The returned code is always lowercase.
|
|
21
22
|
*
|
|
22
23
|
* @returns A {@link PSError} for non-2xx responses with a recognised code,
|
|
23
24
|
* or `null` for 2xx responses, malformed JSON, or unrecognised codes.
|
package/dist/types/ps-errors.js
CHANGED
|
@@ -7,32 +7,57 @@ class PSError extends Error {
|
|
|
7
7
|
code;
|
|
8
8
|
}
|
|
9
9
|
const KNOWN_CODES = /* @__PURE__ */ new Set([
|
|
10
|
+
"missing_auth",
|
|
11
|
+
"invalid_signature",
|
|
12
|
+
"unregistered_builder",
|
|
13
|
+
"not_owner",
|
|
14
|
+
"expired_token",
|
|
10
15
|
"grant_invalid",
|
|
16
|
+
"grant_required",
|
|
17
|
+
"grant_expired",
|
|
11
18
|
"grant_revoked",
|
|
19
|
+
"scope_mismatch",
|
|
12
20
|
"fee_required",
|
|
13
|
-
"ps_unavailable"
|
|
21
|
+
"ps_unavailable",
|
|
22
|
+
"server_not_configured",
|
|
23
|
+
"content_too_large"
|
|
14
24
|
]);
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
function isRecord(value) {
|
|
26
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
function normalizeCode(value) {
|
|
29
|
+
if (typeof value !== "string") {
|
|
17
30
|
return null;
|
|
18
31
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
const code = value.toLowerCase();
|
|
33
|
+
return KNOWN_CODES.has(code) ? code : null;
|
|
34
|
+
}
|
|
35
|
+
function extractPSErrorBody(body) {
|
|
36
|
+
if (!isRecord(body)) {
|
|
23
37
|
return null;
|
|
24
38
|
}
|
|
25
|
-
|
|
39
|
+
const nested = isRecord(body.error) ? body.error : null;
|
|
40
|
+
const code = normalizeCode(
|
|
41
|
+
nested?.errorCode ?? nested?.code ?? body.errorCode ?? body.code
|
|
42
|
+
);
|
|
43
|
+
const message = nested?.message ?? body.message;
|
|
44
|
+
if (!code || typeof message !== "string") {
|
|
26
45
|
return null;
|
|
27
46
|
}
|
|
28
|
-
|
|
29
|
-
|
|
47
|
+
return { code, message };
|
|
48
|
+
}
|
|
49
|
+
async function parsePSError(response) {
|
|
50
|
+
if (response.ok) {
|
|
30
51
|
return null;
|
|
31
52
|
}
|
|
32
|
-
|
|
53
|
+
let body;
|
|
54
|
+
try {
|
|
55
|
+
body = await response.json();
|
|
56
|
+
} catch {
|
|
33
57
|
return null;
|
|
34
58
|
}
|
|
35
|
-
|
|
59
|
+
const errorBody = extractPSErrorBody(body);
|
|
60
|
+
return errorBody ? new PSError(errorBody.code, errorBody.message) : null;
|
|
36
61
|
}
|
|
37
62
|
export {
|
|
38
63
|
PSError,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/ps-errors.ts"],"sourcesContent":["/**\n * Typed errors returned by Personal Server endpoints.\n *\n * @remarks\n *
|
|
1
|
+
{"version":3,"sources":["../../src/types/ps-errors.ts"],"sourcesContent":["/**\n * Typed errors returned by Personal Server endpoints.\n *\n * @remarks\n * vana-connect (and other PS clients) need to branch on a small, stable set\n * of lowercase error codes. Personal Server routes currently return protocol\n * errors as `{ error: { code, errorCode, message } }`, while older PoC\n * clients used `{ code, message }`; the parser accepts both shapes.\n *\n * @category Auth\n */\n\n/** Stable error codes returned by Personal Server. */\nexport type PSErrorCode =\n | \"missing_auth\"\n | \"invalid_signature\"\n | \"unregistered_builder\"\n | \"not_owner\"\n | \"expired_token\"\n | \"grant_invalid\"\n | \"grant_required\"\n | \"grant_expired\"\n | \"grant_revoked\"\n | \"scope_mismatch\"\n | \"fee_required\"\n | \"ps_unavailable\"\n | \"server_not_configured\"\n | \"content_too_large\";\n\n/** Typed error wrapping a non-2xx Personal Server response. */\nexport class PSError extends Error {\n constructor(\n public readonly code: PSErrorCode,\n message: string,\n ) {\n super(message);\n this.name = \"PSError\";\n }\n}\n\nconst KNOWN_CODES: ReadonlySet<PSErrorCode> = new Set<PSErrorCode>([\n \"missing_auth\",\n \"invalid_signature\",\n \"unregistered_builder\",\n \"not_owner\",\n \"expired_token\",\n \"grant_invalid\",\n \"grant_required\",\n \"grant_expired\",\n \"grant_revoked\",\n \"scope_mismatch\",\n \"fee_required\",\n \"ps_unavailable\",\n \"server_not_configured\",\n \"content_too_large\",\n]);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction normalizeCode(value: unknown): PSErrorCode | null {\n if (typeof value !== \"string\") {\n return null;\n }\n const code = value.toLowerCase() as PSErrorCode;\n return KNOWN_CODES.has(code) ? code : null;\n}\n\nfunction extractPSErrorBody(\n body: unknown,\n): { code: PSErrorCode; message: string } | null {\n if (!isRecord(body)) {\n return null;\n }\n\n const nested = isRecord(body.error) ? body.error : null;\n const code = normalizeCode(\n nested?.errorCode ?? nested?.code ?? body.errorCode ?? body.code,\n );\n const message = nested?.message ?? body.message;\n\n if (!code || typeof message !== \"string\") {\n return null;\n }\n\n return { code, message };\n}\n\n/**\n * Read a Personal Server JSON error body from a non-2xx {@link Response} and\n * return the typed {@link PSError}. The returned code is always lowercase.\n *\n * @returns A {@link PSError} for non-2xx responses with a recognised code,\n * or `null` for 2xx responses, malformed JSON, or unrecognised codes.\n */\nexport async function parsePSError(\n response: Response,\n): Promise<PSError | null> {\n if (response.ok) {\n return null;\n }\n\n let body: unknown;\n try {\n body = await response.json();\n } catch {\n return null;\n }\n\n const errorBody = extractPSErrorBody(body);\n return errorBody ? new PSError(errorBody.code, errorBody.message) : null;\n}\n"],"mappings":"AA8BO,MAAM,gBAAgB,MAAM;AAAA,EACjC,YACkB,MAChB,SACA;AACA,UAAM,OAAO;AAHG;AAIhB,SAAK,OAAO;AAAA,EACd;AAAA,EALkB;AAMpB;AAEA,MAAM,cAAwC,oBAAI,IAAiB;AAAA,EACjE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,SAAS,OAAkD;AAClE,SAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,cAAc,OAAoC;AACzD,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,QAAM,OAAO,MAAM,YAAY;AAC/B,SAAO,YAAY,IAAI,IAAI,IAAI,OAAO;AACxC;AAEA,SAAS,mBACP,MAC+C;AAC/C,MAAI,CAAC,SAAS,IAAI,GAAG;AACnB,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,SAAS,KAAK,KAAK,IAAI,KAAK,QAAQ;AACnD,QAAM,OAAO;AAAA,IACX,QAAQ,aAAa,QAAQ,QAAQ,KAAK,aAAa,KAAK;AAAA,EAC9D;AACA,QAAM,UAAU,QAAQ,WAAW,KAAK;AAExC,MAAI,CAAC,QAAQ,OAAO,YAAY,UAAU;AACxC,WAAO;AAAA,EACT;AAEA,SAAO,EAAE,MAAM,QAAQ;AACzB;AASA,eAAsB,aACpB,UACyB;AACzB,MAAI,SAAS,IAAI;AACf,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI;AACF,WAAO,MAAM,SAAS,KAAK;AAAA,EAC7B,QAAQ;AACN,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,mBAAmB,IAAI;AACzC,SAAO,YAAY,IAAI,QAAQ,UAAU,MAAM,UAAU,OAAO,IAAI;AACtE;","names":[]}
|