@opendatalabs/vana-sdk 3.18.1 → 3.19.1
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 +141 -0
- package/dist/auth/web3-signed-builder.cjs +3 -0
- package/dist/auth/web3-signed-builder.cjs.map +1 -1
- package/dist/auth/web3-signed-builder.d.ts +14 -0
- package/dist/auth/web3-signed-builder.js +3 -0
- package/dist/auth/web3-signed-builder.js.map +1 -1
- package/dist/errors.cjs +69 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +117 -2
- package/dist/errors.js +60 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.js +577 -29
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +605 -29
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +1 -0
- package/dist/index.node.js +577 -29
- package/dist/index.node.js.map +4 -4
- package/dist/protocol/derivative-questions.cjs +518 -0
- package/dist/protocol/derivative-questions.cjs.map +1 -0
- package/dist/protocol/derivative-questions.d.ts +396 -0
- package/dist/protocol/derivative-questions.js +507 -0
- package/dist/protocol/derivative-questions.js.map +1 -0
- package/dist/protocol/derivative-questions.test.d.ts +1 -0
- package/dist/protocol/personal-server-write.cjs +12 -108
- package/dist/protocol/personal-server-write.cjs.map +1 -1
- package/dist/protocol/personal-server-write.d.ts +2 -17
- package/dist/protocol/personal-server-write.js +7 -98
- package/dist/protocol/personal-server-write.js.map +1 -1
- package/dist/protocol/write-request.cjs +156 -0
- package/dist/protocol/write-request.cjs.map +1 -0
- package/dist/protocol/write-request.d.ts +75 -0
- package/dist/protocol/write-request.js +124 -0
- package/dist/protocol/write-request.js.map +1 -0
- package/dist/tests/mock-personal-server.d.ts +54 -0
- package/package.json +1 -1
|
@@ -14,6 +14,16 @@
|
|
|
14
14
|
* proof single-use; `lineage` is the body's top-level field (JSON) or
|
|
15
15
|
* the metadata object's field (binary), validated per
|
|
16
16
|
* docs/derivative-data-api.md and mirrored to `$lineage`
|
|
17
|
+
* - derivative questions (`/v1/derivatives/questions`): the same builder
|
|
18
|
+
* credential as a write (bearer + X-Vana-Write-Signature over the whole
|
|
19
|
+
* request TARGET, query string INCLUDED and compared in canonical form),
|
|
20
|
+
* the optional `nonce` claim as the replay key when present, authorized
|
|
21
|
+
* against `write:<derivedScope>`, compact JSON bodies, the consent rule
|
|
22
|
+
* (every source scope read-granted to the builder), the cycle guard, the
|
|
23
|
+
* 404 for a question this builder did not register AND for an unknown id
|
|
24
|
+
* presented with a live write session, and the 400
|
|
25
|
+
* `DERIVATIVE_DERIVED_SCOPE_REQUIRED` for a builder list with no
|
|
26
|
+
* `?derivedScope=`
|
|
17
27
|
* - lineage reads on both the Personal Server and the gateway: Web3Signed
|
|
18
28
|
* over the bare path (`/lineage[/:version]`, the version is a path
|
|
19
29
|
* segment, any query is 400), grant view from the signed `grantId` claim
|
|
@@ -55,6 +65,30 @@ export interface MockPersonalServerOptions {
|
|
|
55
65
|
status?: "stored" | "syncing";
|
|
56
66
|
sessionTtlSeconds?: number;
|
|
57
67
|
now?: () => number;
|
|
68
|
+
/** Answer every `/v1/derivatives` route 503, as a server with no compute. */
|
|
69
|
+
computeUnavailable?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** A question registration the mock server holds. */
|
|
72
|
+
export interface MockQuestion {
|
|
73
|
+
questionId: string;
|
|
74
|
+
derivedScope: string;
|
|
75
|
+
sourceScopes: string[];
|
|
76
|
+
question: string;
|
|
77
|
+
model: string | null;
|
|
78
|
+
registeredBy: {
|
|
79
|
+
kind: "owner";
|
|
80
|
+
} | {
|
|
81
|
+
kind: "builder";
|
|
82
|
+
builder: Address;
|
|
83
|
+
grantId: string;
|
|
84
|
+
};
|
|
85
|
+
status: "pending" | "ready" | "failed" | "stale";
|
|
86
|
+
error: string | null;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
updatedAt: string;
|
|
89
|
+
lastComputedAt: string | null;
|
|
90
|
+
derivedVersion: number | null;
|
|
91
|
+
derivedCollectedAt: string | null;
|
|
58
92
|
}
|
|
59
93
|
export interface MockRequestLog {
|
|
60
94
|
method: string;
|
|
@@ -75,6 +109,26 @@ export interface MockPersonalServer {
|
|
|
75
109
|
respondNextWith(status: number, body: unknown): void;
|
|
76
110
|
/** Sessions minted (token -> record). */
|
|
77
111
|
sessions: Map<string, MockSession>;
|
|
112
|
+
/** Question registrations (id -> row), in registration order. */
|
|
113
|
+
questions: Map<string, MockQuestion>;
|
|
114
|
+
/**
|
|
115
|
+
* Forget every minted session, the way a restarted Personal Server does:
|
|
116
|
+
* the next call with an old bearer answers 401.
|
|
117
|
+
*/
|
|
118
|
+
dropSessions(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Settle a question the way a compute would: set its status and, for a
|
|
121
|
+
* `ready` one, store the derived record the builder then reads.
|
|
122
|
+
*/
|
|
123
|
+
settleQuestion(questionId: string, outcome: {
|
|
124
|
+
status: "ready";
|
|
125
|
+
data?: Record<string, unknown>;
|
|
126
|
+
} | {
|
|
127
|
+
status: "failed";
|
|
128
|
+
error: string;
|
|
129
|
+
} | {
|
|
130
|
+
status: "stale" | "pending";
|
|
131
|
+
}): void;
|
|
78
132
|
}
|
|
79
133
|
export interface MockSession {
|
|
80
134
|
token: string;
|