@aithos/sdk 0.1.0-alpha.27 → 0.1.0-alpha.28
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/src/data.js +18 -0
- package/package.json +1 -1
package/dist/src/data.js
CHANGED
|
@@ -137,6 +137,24 @@ class DataClientImpl {
|
|
|
137
137
|
subject_did: this.#did,
|
|
138
138
|
collection_name: name,
|
|
139
139
|
}));
|
|
140
|
+
// Defensive structural validation — some PDS responses have been
|
|
141
|
+
// observed (alpha.27 era) returning a meta object that lacks
|
|
142
|
+
// `cmk_envelope` for missing collections, instead of the documented
|
|
143
|
+
// -32020 JSON-RPC error. Without this check, the next line crashes
|
|
144
|
+
// with "Cannot read properties of undefined (reading 'wraps')" which
|
|
145
|
+
// bypasses the upper-layer's missing-collection handling. We re-emit
|
|
146
|
+
// a clean -32020 here so callers can detect "collection not found"
|
|
147
|
+
// uniformly.
|
|
148
|
+
if (!meta ||
|
|
149
|
+
!meta.cmk_envelope ||
|
|
150
|
+
!Array.isArray(meta.cmk_envelope.wraps) ||
|
|
151
|
+
!meta.urn ||
|
|
152
|
+
!meta.schema) {
|
|
153
|
+
const err = new Error(`sdk.data: collection "${name}" not found or malformed ` +
|
|
154
|
+
`(meta missing required field). PDS returned: ${JSON.stringify(meta).slice(0, 200)}`);
|
|
155
|
+
err.code = -32020;
|
|
156
|
+
throw err;
|
|
157
|
+
}
|
|
140
158
|
// Look up our wrap and unwrap the CMK
|
|
141
159
|
const ourRecipient = `${this.#did}#data-kex`;
|
|
142
160
|
const wrap = meta.cmk_envelope.wraps.find((w) => w.recipient === ourRecipient);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aithos/sdk",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.28",
|
|
4
4
|
"description": "Aithos SDK \u2014 high-level TypeScript developer kit for building agentic apps on the Aithos protocol. Wraps @aithos/protocol-client and exposes the Aithos compute proxy and wallet (Stripe top-up) endpoints.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aithos",
|