@opendatalabs/personal-server-ts-core 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.d.ts +41 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +298 -87
- package/dist/api/index.js.map +1 -1
- package/dist/contracts/binary.d.ts +12 -0
- package/dist/contracts/binary.d.ts.map +1 -1
- package/dist/contracts/binary.js +31 -0
- package/dist/contracts/binary.js.map +1 -1
- package/dist/contracts/data.d.ts +35 -0
- package/dist/contracts/data.d.ts.map +1 -1
- package/dist/contracts/data.js +96 -14
- package/dist/contracts/data.js.map +1 -1
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/errors/catalog.d.ts +34 -0
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/catalog.js +41 -0
- package/dist/errors/catalog.js.map +1 -1
- package/dist/lineage/attestation.d.ts +42 -0
- package/dist/lineage/attestation.d.ts.map +1 -0
- package/dist/lineage/attestation.js +25 -0
- package/dist/lineage/attestation.js.map +1 -0
- package/dist/lineage/gateway.d.ts +105 -0
- package/dist/lineage/gateway.d.ts.map +1 -0
- package/dist/lineage/gateway.js +242 -0
- package/dist/lineage/gateway.js.map +1 -0
- package/dist/lineage/index.d.ts +5 -0
- package/dist/lineage/index.d.ts.map +1 -0
- package/dist/lineage/index.js +5 -0
- package/dist/lineage/index.js.map +1 -0
- package/dist/lineage/lineage.d.ts +141 -0
- package/dist/lineage/lineage.d.ts.map +1 -0
- package/dist/lineage/lineage.js +255 -0
- package/dist/lineage/lineage.js.map +1 -0
- package/dist/logging/access-log.d.ts +1 -1
- package/dist/logging/access-log.d.ts.map +1 -1
- package/dist/policy/data-read.d.ts +8 -0
- package/dist/policy/data-read.d.ts.map +1 -1
- package/dist/policy/data-read.js +9 -2
- package/dist/policy/data-read.js.map +1 -1
- package/dist/policy/data-write.d.ts +69 -0
- package/dist/policy/data-write.d.ts.map +1 -0
- package/dist/policy/data-write.js +131 -0
- package/dist/policy/data-write.js.map +1 -0
- package/dist/policy/index.d.ts +2 -1
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/index.js +2 -1
- package/dist/policy/index.js.map +1 -1
- package/dist/signing/request-signer.d.ts +2 -0
- package/dist/signing/request-signer.d.ts.map +1 -1
- package/dist/signing/request-signer.js +1 -0
- package/dist/signing/request-signer.js.map +1 -1
- package/dist/signing/signer.d.ts +8 -0
- package/dist/signing/signer.d.ts.map +1 -1
- package/dist/signing/signer.js +9 -0
- package/dist/signing/signer.js.map +1 -1
- package/dist/sync/data-point-id.d.ts +7 -0
- package/dist/sync/data-point-id.d.ts.map +1 -0
- package/dist/sync/data-point-id.js +16 -0
- package/dist/sync/data-point-id.js.map +1 -0
- package/dist/sync/workers/upload.d.ts +10 -6
- package/dist/sync/workers/upload.d.ts.map +1 -1
- package/dist/sync/workers/upload.js +39 -17
- package/dist/sync/workers/upload.js.map +1 -1
- package/dist/write/attribution.d.ts +167 -0
- package/dist/write/attribution.d.ts.map +1 -0
- package/dist/write/attribution.js +325 -0
- package/dist/write/attribution.js.map +1 -0
- package/dist/write/index.d.ts +3 -0
- package/dist/write/index.d.ts.map +1 -0
- package/dist/write/index.js +3 -0
- package/dist/write/index.js.map +1 -0
- package/dist/write/session.d.ts +96 -0
- package/dist/write/session.d.ts.map +1 -0
- package/dist/write/session.js +136 -0
- package/dist/write/session.js.map +1 -0
- package/package.json +9 -1
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder attribution for delegated writes.
|
|
3
|
+
*
|
|
4
|
+
* The write-session token authorizes a write; it does not PROVE who authored
|
|
5
|
+
* the payload (a bearer token is not a signature). For cryptographic
|
|
6
|
+
* attribution the builder also signs the payload: a Web3Signed proof over the
|
|
7
|
+
* exact write request (aud / method / uri / bodyHash / iat / exp), carried in
|
|
8
|
+
* the `X-Vana-Write-Signature` header and signed by the builder key proven at
|
|
9
|
+
* handshake. The PS verifies the proof recovers to the session's builder and
|
|
10
|
+
* that its bodyHash commits to the received bytes, then stores the proof and
|
|
11
|
+
* the builder identity WITH the record — inside the envelope's `data` under
|
|
12
|
+
* the reserved `$writtenBy` key (same in-`data` marker idiom as `$binary`),
|
|
13
|
+
* so attribution travels through the unchanged encrypt / upload / register
|
|
14
|
+
* path and back out on read. The on-chain shape is untouched.
|
|
15
|
+
*
|
|
16
|
+
* The proof binds the write to its context, not just its bytes: the signed
|
|
17
|
+
* claims carry the request path (whose last segment is the scope), the
|
|
18
|
+
* method, the audience (this server's origin) and the session's grantId,
|
|
19
|
+
* which the PS requires to match the session at ingest. A stored `$writtenBy`
|
|
20
|
+
* therefore cannot be lifted onto another scope's record or relabelled with a
|
|
21
|
+
* different grant and still verify.
|
|
22
|
+
*
|
|
23
|
+
* What the builder signs is the STORED representation, not the wire body:
|
|
24
|
+
* the compact JSON of the envelope `data` record the PS will write (minus
|
|
25
|
+
* `$writtenBy`). A third party holding the envelope can therefore verify
|
|
26
|
+
* authorship from the envelope ALONE (verifyStoredWriterAttribution): recover
|
|
27
|
+
* the signer over the stored proof's base64url payload (EIP-191), check the
|
|
28
|
+
* signed claims against the envelope's scope and stored grantId, and hash
|
|
29
|
+
* JSON.stringify(data minus the server-stamped keys `$writtenBy` and
|
|
30
|
+
* `$lineage`) against the signed bodyHash.
|
|
31
|
+
* - JSON writes: the body IS the stored record, so the builder signs the
|
|
32
|
+
* body bytes, which must be compact JSON (what JSON.stringify emits: no
|
|
33
|
+
* insignificant whitespace, keys in the order given). JSON.parse /
|
|
34
|
+
* JSON.stringify round-trips that byte-for-byte; a body that does not
|
|
35
|
+
* round-trip is rejected at write time (WRITE_BODY_NOT_CANONICAL) instead
|
|
36
|
+
* of being stored with an attribution nobody can check.
|
|
37
|
+
* - Binary writes: the stored record is the `$binary` envelope data (media
|
|
38
|
+
* type, filename, caller metadata, size, content hash, base64 content),
|
|
39
|
+
* so the builder signs its compact JSON (binaryWriteSignedBytes). That
|
|
40
|
+
* binds the caller-controlled representation headers (Content-Type,
|
|
41
|
+
* X-Filename / Content-Disposition, X-Vana-Metadata) to the signature and
|
|
42
|
+
* makes a JSON-vs-binary switch of the same bytes fail verification.
|
|
43
|
+
*/
|
|
44
|
+
import { computeBodyHash, parseWeb3SignedHeader, verifyWeb3Signed, } from "@opendatalabs/vana-sdk/browser";
|
|
45
|
+
import { recoverMessageAddress } from "viem";
|
|
46
|
+
import { ProtocolError } from "../errors/catalog.js";
|
|
47
|
+
import { hashConnectionToken as sha256HexOf } from "../mcp/connection-api.js";
|
|
48
|
+
import { binaryFilename, binaryMimeType, buildBinaryEnvelopeData, isJsonContentType, normalizeBinaryMimeType, parseMetadataHeader, sha256Hex, } from "../contracts/binary.js";
|
|
49
|
+
import { LINEAGE_KEY, StoredLineageMalformedError, extractLineageField, readStoredLineage, } from "../lineage/lineage.js";
|
|
50
|
+
import { isBinaryEnvelope } from "../contracts/binary.js";
|
|
51
|
+
/** Header carrying the builder's signed-payload proof on a session write. */
|
|
52
|
+
export const WRITE_SIGNATURE_HEADER = "x-vana-write-signature";
|
|
53
|
+
/**
|
|
54
|
+
* Reserved key inside the envelope's `data` record for builder attribution.
|
|
55
|
+
* Mirrors the `$binary` marker convention (contracts/binary.ts).
|
|
56
|
+
*/
|
|
57
|
+
export const WRITER_ATTRIBUTION_KEY = "$writtenBy";
|
|
58
|
+
function resolveOrigin(origin) {
|
|
59
|
+
return typeof origin === "function" ? origin() : origin;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The bytes a builder signs (as the Web3Signed body) for a BINARY session
|
|
63
|
+
* write: the compact JSON of the `$binary` record the PS stores for these
|
|
64
|
+
* headers and bytes. Mirrors ingest exactly (same media-type normalization,
|
|
65
|
+
* metadata parsing and envelope builder), so the signature covers the stored
|
|
66
|
+
* representation and verifyStoredWriterAttribution can re-derive it.
|
|
67
|
+
*/
|
|
68
|
+
export async function binaryWriteSignedBytes(input) {
|
|
69
|
+
const data = buildBinaryEnvelopeData({
|
|
70
|
+
bytes: input.bytes,
|
|
71
|
+
mimeType: normalizeBinaryMimeType(input.contentType),
|
|
72
|
+
filename: input.filename,
|
|
73
|
+
contentHash: await sha256Hex(input.bytes),
|
|
74
|
+
metadata: parseMetadataHeader(input.metadataHeader ?? null),
|
|
75
|
+
});
|
|
76
|
+
return new TextEncoder().encode(JSON.stringify(data));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The bytes the proof must commit to for this request: the body itself for
|
|
80
|
+
* a JSON write, the stored `$binary` representation for anything else.
|
|
81
|
+
*/
|
|
82
|
+
async function signedBytesFor(request, bodyBytes) {
|
|
83
|
+
if (isJsonContentType(request))
|
|
84
|
+
return bodyBytes;
|
|
85
|
+
return binaryWriteSignedBytes({
|
|
86
|
+
bytes: bodyBytes,
|
|
87
|
+
contentType: binaryMimeType(request),
|
|
88
|
+
filename: binaryFilename(request),
|
|
89
|
+
metadataHeader: request.headers.get("x-vana-metadata") ?? undefined,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Verify the `X-Vana-Write-Signature` proof on a session write and produce
|
|
94
|
+
* the attribution record to store with the data. Throws ProtocolError(401)
|
|
95
|
+
* when the proof is missing, malformed, expired, fails EIP-191 recovery /
|
|
96
|
+
* bodyHash binding (the hash covers the stored representation, see
|
|
97
|
+
* signedBytesFor), recovers to a different key than the session builder, or
|
|
98
|
+
* does not carry the session's grantId as a signed claim.
|
|
99
|
+
*/
|
|
100
|
+
export async function verifyWriterAttribution(input) {
|
|
101
|
+
const headerValue = input.request.headers.get(WRITE_SIGNATURE_HEADER) ?? undefined;
|
|
102
|
+
if (!headerValue) {
|
|
103
|
+
throw new ProtocolError(401, "WRITE_ATTRIBUTION_REQUIRED", `Session writes must carry a builder-signed payload proof in ${WRITE_SIGNATURE_HEADER}`);
|
|
104
|
+
}
|
|
105
|
+
const url = new URL(input.request.url);
|
|
106
|
+
const bodyBytes = new Uint8Array(await input.request.clone().arrayBuffer());
|
|
107
|
+
let verified;
|
|
108
|
+
try {
|
|
109
|
+
verified = await verifyWeb3Signed({
|
|
110
|
+
headerValue,
|
|
111
|
+
expectedOrigin: resolveOrigin(input.serverOrigin),
|
|
112
|
+
expectedMethod: input.request.method,
|
|
113
|
+
expectedPath: url.pathname,
|
|
114
|
+
bodyBytes: await signedBytesFor(input.request, bodyBytes),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
throw new ProtocolError(401, "WRITE_ATTRIBUTION_INVALID", err instanceof Error ? err.message : String(err));
|
|
119
|
+
}
|
|
120
|
+
if (verified.signer.toLowerCase() !== input.builderAddress.toLowerCase()) {
|
|
121
|
+
throw new ProtocolError(401, "WRITE_ATTRIBUTION_SIGNER_MISMATCH", "Payload proof is not signed by the session builder", { expected: input.builderAddress, actual: verified.signer });
|
|
122
|
+
}
|
|
123
|
+
// The grant is a signed claim, so the stored attribution's grantId is
|
|
124
|
+
// covered by the builder's signature rather than being a bare label.
|
|
125
|
+
if (verified.payload.grantId !== input.grantId) {
|
|
126
|
+
throw new ProtocolError(401, "WRITE_ATTRIBUTION_GRANT_MISMATCH", "Payload proof must carry the write session's grantId as a signed claim", { expected: input.grantId, actual: verified.payload.grantId ?? null });
|
|
127
|
+
}
|
|
128
|
+
if (isJsonContentType(input.request)) {
|
|
129
|
+
assertCanonicalJsonBody(bodyBytes);
|
|
130
|
+
}
|
|
131
|
+
// Replay guard, last: only a proof that passed every check is consumed,
|
|
132
|
+
// so a rejected request never burns a proof.
|
|
133
|
+
let releaseProof;
|
|
134
|
+
if (input.replayStore) {
|
|
135
|
+
const store = input.replayStore;
|
|
136
|
+
const proofId = await sha256HexOf(headerValue);
|
|
137
|
+
const replayed = await store.consume(proofId, verified.payload.exp * 1000);
|
|
138
|
+
if (replayed) {
|
|
139
|
+
throw new ProtocolError(401, "WRITE_ATTRIBUTION_REPLAY", "Payload proof already used; sign a fresh proof for each write");
|
|
140
|
+
}
|
|
141
|
+
releaseProof = async () => {
|
|
142
|
+
await store.release?.(proofId);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
// Store the compact `{payload}.{signature}` form (scheme prefix stripped)
|
|
146
|
+
// so verifiers don't need to know the header framing.
|
|
147
|
+
const { payloadBase64, signature } = parseWeb3SignedHeader(headerValue);
|
|
148
|
+
return {
|
|
149
|
+
builder: input.builderAddress,
|
|
150
|
+
grantId: input.grantId,
|
|
151
|
+
signature: `${payloadBase64}.${signature}`,
|
|
152
|
+
bodyHash: verified.payload.bodyHash,
|
|
153
|
+
writtenAt: (input.now?.() ?? new Date()).toISOString(),
|
|
154
|
+
...(releaseProof ? { releaseProof } : {}),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Stamp attribution into an envelope `data` record. The reserved key must not
|
|
159
|
+
* appear in the caller's payload — a builder must not be able to forge (or
|
|
160
|
+
* shadow) its own attribution.
|
|
161
|
+
*/
|
|
162
|
+
export function stampWriterAttribution(data, attribution) {
|
|
163
|
+
return { ...data, [WRITER_ATTRIBUTION_KEY]: attribution };
|
|
164
|
+
}
|
|
165
|
+
export function hasReservedWriterKey(data) {
|
|
166
|
+
return Object.prototype.hasOwnProperty.call(data, WRITER_ATTRIBUTION_KEY);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A JSON session write must be the compact serialization of its own parsed
|
|
170
|
+
* value, so the record stored after JSON.parse re-serializes to the signed
|
|
171
|
+
* bytes. Bodies that do not parse are left to the ingest path, which reports
|
|
172
|
+
* the parse error itself.
|
|
173
|
+
*/
|
|
174
|
+
function assertCanonicalJsonBody(bodyBytes) {
|
|
175
|
+
const text = new TextDecoder().decode(bodyBytes);
|
|
176
|
+
let parsed;
|
|
177
|
+
try {
|
|
178
|
+
parsed = JSON.parse(text);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (JSON.stringify(parsed) !== text) {
|
|
184
|
+
throw new ProtocolError(400, "WRITE_BODY_NOT_CANONICAL", "Session writes must send compact JSON (the JSON.stringify form) so the stored record re-serializes to the signed bytes and the attribution bodyHash stays verifiable");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** Proof scheme prefix the compact stored signature was stripped of. */
|
|
188
|
+
const WEB3_SIGNED_SCHEME = "Web3Signed";
|
|
189
|
+
export class WriterAttributionVerificationError extends Error {
|
|
190
|
+
reason;
|
|
191
|
+
constructor(reason, message) {
|
|
192
|
+
super(message);
|
|
193
|
+
this.reason = reason;
|
|
194
|
+
this.name = "WriterAttributionVerificationError";
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function isWriterAttribution(value) {
|
|
198
|
+
if (typeof value !== "object" || value === null)
|
|
199
|
+
return false;
|
|
200
|
+
const v = value;
|
|
201
|
+
return (typeof v.builder === "string" &&
|
|
202
|
+
v.builder.startsWith("0x") &&
|
|
203
|
+
typeof v.grantId === "string" &&
|
|
204
|
+
typeof v.signature === "string" &&
|
|
205
|
+
typeof v.bodyHash === "string" &&
|
|
206
|
+
typeof v.writtenAt === "string");
|
|
207
|
+
}
|
|
208
|
+
/** Last path segment of the signed request uri, i.e. the scope written to. */
|
|
209
|
+
function signedScopeOf(uri) {
|
|
210
|
+
const path = uri.split("?")[0] ?? "";
|
|
211
|
+
const segment = path.slice(path.lastIndexOf("/") + 1);
|
|
212
|
+
if (!segment)
|
|
213
|
+
return null;
|
|
214
|
+
try {
|
|
215
|
+
return decodeURIComponent(segment);
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Verify builder attribution from a stored envelope alone (no request, no
|
|
223
|
+
* server state, no expiry check: the proof is evidence of who wrote the
|
|
224
|
+
* record at the time, not a live credential). Checks, in order: the envelope
|
|
225
|
+
* carries an attribution; the stored representation (compact JSON of the
|
|
226
|
+
* data minus the server-stamped `$writtenBy` and `$lineage` keys, for JSON
|
|
227
|
+
* and `$binary` records alike) re-hashes
|
|
228
|
+
* to the signed bodyHash; the proof parses and recovers to the attributed
|
|
229
|
+
* builder; and the signed claims bind the proof to THIS record: a POST whose
|
|
230
|
+
* path names the envelope's scope, the stored grantId, and (when given) the
|
|
231
|
+
* server origin. Throws WriterAttributionVerificationError with the reason.
|
|
232
|
+
*/
|
|
233
|
+
export async function verifyStoredWriterAttribution(envelope, options = {}) {
|
|
234
|
+
const data = envelope.data;
|
|
235
|
+
const attribution = data[WRITER_ATTRIBUTION_KEY];
|
|
236
|
+
if (!isWriterAttribution(attribution)) {
|
|
237
|
+
throw new WriterAttributionVerificationError("ATTRIBUTION_MISSING", `Record carries no ${WRITER_ATTRIBUTION_KEY} attribution`);
|
|
238
|
+
}
|
|
239
|
+
// Every server-stamped reserved key is stripped, not just the attribution:
|
|
240
|
+
// `$lineage` is the server's validated mirror of the caller's `lineage`
|
|
241
|
+
// field (the field itself stays inside the signed bytes), so a derivative
|
|
242
|
+
// record re-hashes to the same signed bodyHash as a root record.
|
|
243
|
+
const { [WRITER_ATTRIBUTION_KEY]: _attribution, [LINEAGE_KEY]: storedLineage, ...payloadData } = data;
|
|
244
|
+
const bodyHash = computeBodyHash(new TextEncoder().encode(JSON.stringify(payloadData)));
|
|
245
|
+
if (bodyHash !== attribution.bodyHash) {
|
|
246
|
+
throw new WriterAttributionVerificationError("BODY_HASH_MISMATCH", "Stored record does not hash to the attribution bodyHash");
|
|
247
|
+
}
|
|
248
|
+
let proof;
|
|
249
|
+
let signer;
|
|
250
|
+
try {
|
|
251
|
+
proof = parseWeb3SignedHeader(`${WEB3_SIGNED_SCHEME} ${attribution.signature}`);
|
|
252
|
+
signer = await recoverMessageAddress({
|
|
253
|
+
message: proof.payloadBase64,
|
|
254
|
+
signature: proof.signature,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
throw new WriterAttributionVerificationError("PROOF_INVALID", err instanceof Error ? err.message : String(err));
|
|
259
|
+
}
|
|
260
|
+
if (proof.payload.bodyHash !== bodyHash) {
|
|
261
|
+
throw new WriterAttributionVerificationError("BODY_HASH_MISMATCH", "Stored proof does not commit to the attribution bodyHash");
|
|
262
|
+
}
|
|
263
|
+
if (signer.toLowerCase() !== attribution.builder.toLowerCase()) {
|
|
264
|
+
throw new WriterAttributionVerificationError("SIGNER_MISMATCH", "Stored proof is not signed by the attributed builder");
|
|
265
|
+
}
|
|
266
|
+
// Context binding: the signed claims must describe a write of THIS record.
|
|
267
|
+
if (proof.payload.method !== "POST" ||
|
|
268
|
+
signedScopeOf(proof.payload.uri) !== envelope.scope) {
|
|
269
|
+
throw new WriterAttributionVerificationError("SCOPE_MISMATCH", `Stored proof is not a write to scope ${envelope.scope}`);
|
|
270
|
+
}
|
|
271
|
+
if (proof.payload.grantId !== attribution.grantId) {
|
|
272
|
+
throw new WriterAttributionVerificationError("GRANT_MISMATCH", "Stored grantId is not the grant the builder signed");
|
|
273
|
+
}
|
|
274
|
+
if (options.expectedOrigin !== undefined &&
|
|
275
|
+
proof.payload.aud !== options.expectedOrigin) {
|
|
276
|
+
throw new WriterAttributionVerificationError("AUDIENCE_MISMATCH", "Stored proof was not addressed to this server");
|
|
277
|
+
}
|
|
278
|
+
// The stripped mirror is not unauthenticated for that: it must restate
|
|
279
|
+
// the builder-signed `lineage` field (body top level, or the binary
|
|
280
|
+
// record's metadata object) in both directions, so a `$lineage` edited
|
|
281
|
+
// after the write, or one removed to hide a derivative's sources, is
|
|
282
|
+
// caught even though it is outside the hashed bytes. A signed list
|
|
283
|
+
// (empty included: an explicit root statement) must have its mirror; an
|
|
284
|
+
// absent signed field must have none.
|
|
285
|
+
const signedField = extractLineageField(isBinaryEnvelope({ data: payloadData })
|
|
286
|
+
? payloadData.metadata
|
|
287
|
+
: payloadData);
|
|
288
|
+
// Absent or null means "no statement". Anything else that is not a list
|
|
289
|
+
// of strings is a malformed signed field: an independently constructed
|
|
290
|
+
// record must not pass verification just because its lineage claim is
|
|
291
|
+
// unreadable, so it is a mismatch, never "absent".
|
|
292
|
+
const signedAbsent = signedField === undefined || signedField === null;
|
|
293
|
+
const signedWellFormed = Array.isArray(signedField) &&
|
|
294
|
+
signedField.every((id) => typeof id === "string");
|
|
295
|
+
const signed = signedAbsent || !signedWellFormed
|
|
296
|
+
? null
|
|
297
|
+
: signedField.map((id) => id.toLowerCase());
|
|
298
|
+
let mirror;
|
|
299
|
+
try {
|
|
300
|
+
mirror = storedLineage === undefined ? null : readStoredLineage(data);
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
if (error instanceof StoredLineageMalformedError) {
|
|
304
|
+
throw new WriterAttributionVerificationError("LINEAGE_MISMATCH", `stored $lineage mirror is malformed: ${error.message}`);
|
|
305
|
+
}
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
const consistent = !signedAbsent && !signedWellFormed
|
|
309
|
+
? false
|
|
310
|
+
: signed === null
|
|
311
|
+
? storedLineage === undefined
|
|
312
|
+
: mirror !== null &&
|
|
313
|
+
signed.length === mirror.sources.length &&
|
|
314
|
+
signed.every((id, i) => id === mirror.sources[i]);
|
|
315
|
+
if (!consistent) {
|
|
316
|
+
throw new WriterAttributionVerificationError("LINEAGE_MISMATCH", "Stored $lineage does not restate the builder-signed lineage field");
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
builder: attribution.builder,
|
|
320
|
+
grantId: attribution.grantId,
|
|
321
|
+
bodyHash,
|
|
322
|
+
payload: proof.payload,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=attribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribution.js","sourceRoot":"","sources":["../../src/write/attribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,KAAK;QACP,CAAC,CAAC,MAAM,KAAK,IAAI;YACf,CAAC,CAAC,aAAa,KAAK,SAAS;YAC7B,CAAC,CAAC,MAAM,KAAK,IAAI;gBACf,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,OAAO,CAAC,MAAM;gBACvC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,kCAAkC,CAC1C,kBAAkB,EAClB,mEAAmE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,QAAQ;QACR,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createInMemoryWriteProofReplayStore, createInMemoryWriteSessionStore, createWriteSession, hashWriteSessionToken, type CreateWriteSessionInput, type CreateWriteSessionOptions, type CreateWriteSessionResult, type WriteProofReplayStore, type WriteSessionRecord, type WriteSessionStore, } from "./session.js";
|
|
2
|
+
export { WRITE_SIGNATURE_HEADER, WRITER_ATTRIBUTION_KEY, binaryWriteSignedBytes, hasReservedWriterKey, stampWriterAttribution, verifyStoredWriterAttribution, verifyWriterAttribution, WriterAttributionVerificationError, type BinaryWriteSignedBytesInput, type StoredWriterAttributionVerification, type VerifiedWriterAttribution, type VerifyStoredWriterAttributionOptions, type VerifyWriterAttributionInput, type WriterAttribution, } from "./attribution.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/write/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EACnC,+BAA+B,EAC/B,kBAAkB,EAClB,qBAAqB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,kCAAkC,EAClC,KAAK,2BAA2B,EAChC,KAAK,mCAAmC,EACxC,KAAK,yBAAyB,EAC9B,KAAK,oCAAoC,EACzC,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createInMemoryWriteProofReplayStore, createInMemoryWriteSessionStore, createWriteSession, hashWriteSessionToken, } from "./session.js";
|
|
2
|
+
export { WRITE_SIGNATURE_HEADER, WRITER_ATTRIBUTION_KEY, binaryWriteSignedBytes, hasReservedWriterKey, stampWriterAttribution, verifyStoredWriterAttribution, verifyWriterAttribution, WriterAttributionVerificationError, } from "./attribution.js";
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/write/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mCAAmC,EACnC,+BAA+B,EAC/B,kBAAkB,EAClB,qBAAqB,GAOtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,kCAAkC,GAOnC,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write API session (server-signed delegated writes, v1).
|
|
3
|
+
*
|
|
4
|
+
* A registered builder that holds its OWN key and a WRITE-grant proves control
|
|
5
|
+
* of that key ONCE — a Web3Signed handshake to `POST /v1/write/session` — and
|
|
6
|
+
* the PS mints a short-lived bearer token bound to `{ builderAddress, grantId }`
|
|
7
|
+
* (the grant's `write:`-prefixed scope entries define what it may write).
|
|
8
|
+
* Writes then present that token on the EXISTING ingest endpoint
|
|
9
|
+
* (`POST /v1/data/:scope`); each write authorizes as the builder via
|
|
10
|
+
* `verifyDataWritePolicy` and the PS ingests / encrypts / uploads / registers
|
|
11
|
+
* through the normal owner path — the PS signs AddData as the owner exactly as
|
|
12
|
+
* it does today, and the builder never holds the owner key.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately the same handshake shape as the self-signing MCP session
|
|
15
|
+
* (mcp/session.ts): prove key control once, short-lived bearer after. The
|
|
16
|
+
* session token is authorization only; per-write builder ATTRIBUTION is a
|
|
17
|
+
* separate signed proof (see ./attribution.ts).
|
|
18
|
+
*/
|
|
19
|
+
import { hashConnectionToken } from "../mcp/connection-api.js";
|
|
20
|
+
import { createInMemoryMcpProofReplayStore, type McpProofReplayStore } from "../mcp/session.js";
|
|
21
|
+
import type { AuthSessionVerifierPort, GrantVerifierPort } from "../ports/index.js";
|
|
22
|
+
export type WriteProofReplayStore = McpProofReplayStore;
|
|
23
|
+
export declare const createInMemoryWriteProofReplayStore: typeof createInMemoryMcpProofReplayStore;
|
|
24
|
+
export declare const hashWriteSessionToken: typeof hashConnectionToken;
|
|
25
|
+
export interface WriteSessionRecord {
|
|
26
|
+
/** SHA-256 hex of the raw session token. Only the hash is stored. */
|
|
27
|
+
tokenHash: string;
|
|
28
|
+
/** The builder's address (recovered from the handshake proof). */
|
|
29
|
+
builderAddress: `0x${string}`;
|
|
30
|
+
/** The write-grant id the builder was issued (grantee == builder). */
|
|
31
|
+
grantId: string;
|
|
32
|
+
/** The grant's write patterns at handshake time (prefix stripped). */
|
|
33
|
+
writeScopes: string[];
|
|
34
|
+
createdAt: string;
|
|
35
|
+
expiresAtMs: number;
|
|
36
|
+
}
|
|
37
|
+
export interface WriteSessionStore {
|
|
38
|
+
create(record: WriteSessionRecord): Promise<void>;
|
|
39
|
+
/** Returns a live (non-expired) session, or null. */
|
|
40
|
+
getByTokenHash(tokenHash: string): Promise<WriteSessionRecord | null>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* KNOWN LIMITATION: in-memory only, same trade-off as the MCP session store —
|
|
44
|
+
* a process restart drops live tokens and the builder must re-handshake.
|
|
45
|
+
* Acceptable for today's single-instance Personal Server; persist via the
|
|
46
|
+
* host's state store before multi-instance.
|
|
47
|
+
*/
|
|
48
|
+
export declare function createInMemoryWriteSessionStore(): WriteSessionStore;
|
|
49
|
+
export interface CreateWriteSessionInput {
|
|
50
|
+
builderAddress: `0x${string}`;
|
|
51
|
+
grantId: string;
|
|
52
|
+
/**
|
|
53
|
+
* Handshake-proof replay guard. When supplied together with a `replayStore`,
|
|
54
|
+
* a proof id already seen (and still live) is rejected instead of minting a
|
|
55
|
+
* fresh token. `expiresAtMs` bounds how long the id is remembered (the
|
|
56
|
+
* proof's own expiry).
|
|
57
|
+
*/
|
|
58
|
+
proof?: {
|
|
59
|
+
id: string;
|
|
60
|
+
expiresAtMs: number;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface CreateWriteSessionOptions {
|
|
64
|
+
store: WriteSessionStore;
|
|
65
|
+
authSessionVerifier: AuthSessionVerifierPort;
|
|
66
|
+
grantVerifier: GrantVerifierPort;
|
|
67
|
+
/**
|
|
68
|
+
* This server's owner address. The grant's grantor MUST equal it — mirrors
|
|
69
|
+
* `verifyDataWritePolicy`'s ownership binding, applied at handshake so a
|
|
70
|
+
* wrong-owner grant fails with a clear error instead of minting a token
|
|
71
|
+
* whose every write would 403.
|
|
72
|
+
*/
|
|
73
|
+
serverOwner: `0x${string}`;
|
|
74
|
+
randomToken: () => string;
|
|
75
|
+
ttlMs?: number;
|
|
76
|
+
now?: () => number;
|
|
77
|
+
/** Optional replay guard for the handshake proof (see `input.proof`). */
|
|
78
|
+
replayStore?: WriteProofReplayStore;
|
|
79
|
+
}
|
|
80
|
+
export interface CreateWriteSessionResult {
|
|
81
|
+
accessToken: string;
|
|
82
|
+
expiresInSeconds: number;
|
|
83
|
+
grantId: string;
|
|
84
|
+
/** Write patterns (prefix stripped) the session may write into. */
|
|
85
|
+
writeScopes: string[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Validate the handshake identity and mint a write-session token. Same
|
|
89
|
+
* division of labor as createMcpSession: the handshake does the minimal
|
|
90
|
+
* checks that give a clear error (builder registered, grant exists + not
|
|
91
|
+
* revoked + carries write scopes, grantee == builder, grantor == owner);
|
|
92
|
+
* per-scope / expiry enforcement stays authoritative at write time, where
|
|
93
|
+
* `verifyDataWritePolicy` runs against the live grant on every POST.
|
|
94
|
+
*/
|
|
95
|
+
export declare function createWriteSession(input: CreateWriteSessionInput, options: CreateWriteSessionOptions): Promise<CreateWriteSessionResult>;
|
|
96
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/write/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,iCAAiC,EACjC,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAc3B,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AACxD,eAAO,MAAM,mCAAmC,0CACb,CAAC;AACpC,eAAO,MAAM,qBAAqB,4BAAsB,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,cAAc,EAAE,KAAK,MAAM,EAAE,CAAC;IAC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E,uBAAuB,EAC9B,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CA4FnC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write API session (server-signed delegated writes, v1).
|
|
3
|
+
*
|
|
4
|
+
* A registered builder that holds its OWN key and a WRITE-grant proves control
|
|
5
|
+
* of that key ONCE — a Web3Signed handshake to `POST /v1/write/session` — and
|
|
6
|
+
* the PS mints a short-lived bearer token bound to `{ builderAddress, grantId }`
|
|
7
|
+
* (the grant's `write:`-prefixed scope entries define what it may write).
|
|
8
|
+
* Writes then present that token on the EXISTING ingest endpoint
|
|
9
|
+
* (`POST /v1/data/:scope`); each write authorizes as the builder via
|
|
10
|
+
* `verifyDataWritePolicy` and the PS ingests / encrypts / uploads / registers
|
|
11
|
+
* through the normal owner path — the PS signs AddData as the owner exactly as
|
|
12
|
+
* it does today, and the builder never holds the owner key.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately the same handshake shape as the self-signing MCP session
|
|
15
|
+
* (mcp/session.ts): prove key control once, short-lived bearer after. The
|
|
16
|
+
* session token is authorization only; per-write builder ATTRIBUTION is a
|
|
17
|
+
* separate signed proof (see ./attribution.ts).
|
|
18
|
+
*/
|
|
19
|
+
import { hashConnectionToken } from "../mcp/connection-api.js";
|
|
20
|
+
import { createInMemoryMcpProofReplayStore, } from "../mcp/session.js";
|
|
21
|
+
import { writeScopePatterns } from "../policy/data-write.js";
|
|
22
|
+
import { GrantOwnerMismatchError, GrantRequiredError, GrantRevokedError, InvalidSignatureError, ProtocolError, ScopeMismatchError, UnregisteredBuilderError, } from "../errors/catalog.js";
|
|
23
|
+
export const createInMemoryWriteProofReplayStore = createInMemoryMcpProofReplayStore;
|
|
24
|
+
export const hashWriteSessionToken = hashConnectionToken;
|
|
25
|
+
/**
|
|
26
|
+
* KNOWN LIMITATION: in-memory only, same trade-off as the MCP session store —
|
|
27
|
+
* a process restart drops live tokens and the builder must re-handshake.
|
|
28
|
+
* Acceptable for today's single-instance Personal Server; persist via the
|
|
29
|
+
* host's state store before multi-instance.
|
|
30
|
+
*/
|
|
31
|
+
export function createInMemoryWriteSessionStore() {
|
|
32
|
+
const byHash = new Map();
|
|
33
|
+
return {
|
|
34
|
+
async create(record) {
|
|
35
|
+
byHash.set(record.tokenHash, record);
|
|
36
|
+
},
|
|
37
|
+
async getByTokenHash(tokenHash) {
|
|
38
|
+
const record = byHash.get(tokenHash);
|
|
39
|
+
if (!record)
|
|
40
|
+
return null;
|
|
41
|
+
if (record.expiresAtMs <= Date.now()) {
|
|
42
|
+
byHash.delete(tokenHash);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return record;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const DEFAULT_SESSION_TTL_MS = 60 * 60 * 1000;
|
|
50
|
+
/**
|
|
51
|
+
* Validate the handshake identity and mint a write-session token. Same
|
|
52
|
+
* division of labor as createMcpSession: the handshake does the minimal
|
|
53
|
+
* checks that give a clear error (builder registered, grant exists + not
|
|
54
|
+
* revoked + carries write scopes, grantee == builder, grantor == owner);
|
|
55
|
+
* per-scope / expiry enforcement stays authoritative at write time, where
|
|
56
|
+
* `verifyDataWritePolicy` runs against the live grant on every POST.
|
|
57
|
+
*/
|
|
58
|
+
export async function createWriteSession(input, options) {
|
|
59
|
+
const builder = await options.authSessionVerifier.getBuilder(input.builderAddress);
|
|
60
|
+
if (!builder)
|
|
61
|
+
throw new UnregisteredBuilderError();
|
|
62
|
+
const grant = await options.grantVerifier.getGrant(input.grantId);
|
|
63
|
+
if (!grant) {
|
|
64
|
+
throw new GrantRequiredError({
|
|
65
|
+
reason: "Grant not found",
|
|
66
|
+
grantId: input.grantId,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (grant.revokedAt !== null) {
|
|
70
|
+
throw new GrantRevokedError({ grantId: grant.id });
|
|
71
|
+
}
|
|
72
|
+
const patterns = writeScopePatterns(grant.scopes ?? []);
|
|
73
|
+
if (patterns.length === 0) {
|
|
74
|
+
throw new ScopeMismatchError({
|
|
75
|
+
reason: "Grant has no write scopes (write-grant entries use the write: prefix)",
|
|
76
|
+
grantedScopes: grant.scopes ?? [],
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (builder.id.toLowerCase() !== grant.granteeId.toLowerCase()) {
|
|
80
|
+
throw new InvalidSignatureError({
|
|
81
|
+
reason: "Handshake signer is not the grant builder",
|
|
82
|
+
expected: grant.granteeId,
|
|
83
|
+
actual: input.builderAddress,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
// Ownership binding — fail closed on a grantor-less grant: gateway
|
|
87
|
+
// responses are untrusted runtime data, despite their type.
|
|
88
|
+
if (!grant.grantorAddress ||
|
|
89
|
+
grant.grantorAddress.toLowerCase() !== options.serverOwner.toLowerCase()) {
|
|
90
|
+
throw new GrantOwnerMismatchError({
|
|
91
|
+
grantId: grant.id,
|
|
92
|
+
expected: options.serverOwner,
|
|
93
|
+
actual: grant.grantorAddress ?? null,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// Prepare the token first (deterministic, can't meaningfully fail) so the
|
|
97
|
+
// only fallible step after consuming the proof is persistence.
|
|
98
|
+
const token = options.randomToken();
|
|
99
|
+
const tokenHash = await hashWriteSessionToken(token);
|
|
100
|
+
const ttlMs = options.ttlMs ?? DEFAULT_SESSION_TTL_MS;
|
|
101
|
+
const nowMs = options.now?.() ?? Date.now();
|
|
102
|
+
// Replay guard: a still-valid handshake proof must mint at most one token.
|
|
103
|
+
// Same consume/rollback discipline as createMcpSession.
|
|
104
|
+
const usingReplayGuard = Boolean(input.proof && options.replayStore);
|
|
105
|
+
if (input.proof && options.replayStore) {
|
|
106
|
+
const replayed = await options.replayStore.consume(input.proof.id, input.proof.expiresAtMs);
|
|
107
|
+
if (replayed) {
|
|
108
|
+
throw new ProtocolError(401, "WRITE_SESSION_PROOF_REPLAY", "Handshake proof already used; sign a fresh proof");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
await options.store.create({
|
|
113
|
+
tokenHash,
|
|
114
|
+
builderAddress: input.builderAddress,
|
|
115
|
+
grantId: grant.id,
|
|
116
|
+
writeScopes: patterns,
|
|
117
|
+
createdAt: new Date(nowMs).toISOString(),
|
|
118
|
+
expiresAtMs: nowMs + ttlMs,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
// Persistence failed — release the reservation so a legitimate retry with
|
|
123
|
+
// the same still-valid proof isn't rejected as a replay.
|
|
124
|
+
if (usingReplayGuard && input.proof && options.replayStore?.release) {
|
|
125
|
+
await options.replayStore.release(input.proof.id);
|
|
126
|
+
}
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
accessToken: token,
|
|
131
|
+
expiresInSeconds: Math.floor(ttlMs / 1000),
|
|
132
|
+
grantId: grant.id,
|
|
133
|
+
writeScopes: patterns,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/write/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,iCAAiC,GAElC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAM9B,MAAM,CAAC,MAAM,mCAAmC,GAC9C,iCAAiC,CAAC;AACpC,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAqBz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W,EAAE,QAAQ;KACtB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendatalabs/personal-server-ts-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Protocol logic for the Vana Personal Server — auth, grants, scopes, storage, keys",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -80,6 +80,10 @@
|
|
|
80
80
|
"types": "./dist/policy/index.d.ts",
|
|
81
81
|
"import": "./dist/policy/index.js"
|
|
82
82
|
},
|
|
83
|
+
"./lineage": {
|
|
84
|
+
"types": "./dist/lineage/index.d.ts",
|
|
85
|
+
"import": "./dist/lineage/index.js"
|
|
86
|
+
},
|
|
83
87
|
"./ports": {
|
|
84
88
|
"types": "./dist/ports/index.d.ts",
|
|
85
89
|
"import": "./dist/ports/index.js"
|
|
@@ -123,6 +127,10 @@
|
|
|
123
127
|
"./payment": {
|
|
124
128
|
"types": "./dist/payment/index.d.ts",
|
|
125
129
|
"import": "./dist/payment/index.js"
|
|
130
|
+
},
|
|
131
|
+
"./write": {
|
|
132
|
+
"types": "./dist/write/index.d.ts",
|
|
133
|
+
"import": "./dist/write/index.js"
|
|
126
134
|
}
|
|
127
135
|
},
|
|
128
136
|
"scripts": {
|