@aithos/sdk 0.1.0-alpha.7 → 0.1.0-alpha.8

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.
@@ -50,13 +50,18 @@ export function parseDelegateBundle(text) {
50
50
  }
51
51
  const m = mandate;
52
52
  const mandateId = m["id"];
53
- const subjectDid = m["subject_did"] ?? m["subjectDid"];
53
+ // The mandate subject's DID is carried by `issuer` in the wire format
54
+ // emitted by `mintDelegateBundle()` (cf. SignedMandate.issuer in
55
+ // protocol-client). We accept the legacy `subject_did` / camelCase
56
+ // variants too so older test fixtures and any externally-minted
57
+ // bundles using the older shape keep working.
58
+ const subjectDid = m["issuer"] ?? m["subject_did"] ?? m["subjectDid"];
54
59
  const grantee = m["grantee"];
55
60
  if (typeof mandateId !== "string" || !mandateId) {
56
61
  throw bad("mandate.id missing");
57
62
  }
58
63
  if (typeof subjectDid !== "string" || !subjectDid.startsWith("did:")) {
59
- throw bad("mandate.subject_did missing or malformed");
64
+ throw bad("mandate.issuer missing or malformed (expected a `did:` URL)");
60
65
  }
61
66
  if (typeof grantee !== "object" || grantee === null) {
62
67
  throw bad("mandate.grantee missing");
@@ -90,7 +90,7 @@ describe("recovery file: parse + serialize", () => {
90
90
  /* parseDelegateBundle */
91
91
  /* -------------------------------------------------------------------------- */
92
92
  describe("delegate bundle: parse", () => {
93
- it("parses a well-formed bundle", () => {
93
+ it("parses a well-formed bundle (legacy subject_did field)", () => {
94
94
  const text = delegateBundleText({
95
95
  mandateId: "mandate:01H8XYZ",
96
96
  subjectDid: "did:aithos:zCarol",
@@ -103,6 +103,37 @@ describe("delegate bundle: parse", () => {
103
103
  assert.equal(parsed.granteeId, "urn:aithos:agent:bob1");
104
104
  assert.equal(parsed.delegateSeedHex.length, 64);
105
105
  });
106
+ it("parses a bundle minted by mintDelegateBundle (issuer field)", () => {
107
+ // Real wire shape emitted by `mintDelegateBundle` in protocol-client:
108
+ // SignedMandate carries the subject's DID under `issuer`, NOT
109
+ // `subject_did`. Regression test for the import flow that broke
110
+ // every freshly-minted mandate before this fix.
111
+ const text = JSON.stringify({
112
+ aithos_delegate_version: "0.1.0",
113
+ mandate: {
114
+ "aithos-mandate": "0.1",
115
+ id: "mandate:01H8ISSUER",
116
+ issuer: "did:aithos:zCarol",
117
+ issued_by_key: "did:aithos:zCarol#root",
118
+ grantee: {
119
+ id: "urn:aithos:agent:bob1",
120
+ pubkey: "z6MkqGenericPubKey",
121
+ },
122
+ actor_sphere: "self",
123
+ scopes: ["ethos.read.public", "ethos.write.public"],
124
+ not_before: "2026-05-10T00:00:00Z",
125
+ not_after: "2026-05-11T00:00:00Z",
126
+ issued_at: "2026-05-10T00:00:00Z",
127
+ nonce: "abc",
128
+ signature: { alg: "ed25519", key: "...", value: "..." },
129
+ },
130
+ delegate_seed_hex: "11".repeat(32),
131
+ });
132
+ const parsed = parseDelegateBundle(text);
133
+ assert.equal(parsed.subjectDid, "did:aithos:zCarol");
134
+ assert.equal(parsed.mandateId, "mandate:01H8ISSUER");
135
+ assert.equal(parsed.granteeId, "urn:aithos:agent:bob1");
136
+ });
106
137
  it("readDelegateBundleText accepts string passthrough", async () => {
107
138
  const text = delegateBundleText({
108
139
  mandateId: "m",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aithos/sdk",
3
- "version": "0.1.0-alpha.7",
3
+ "version": "0.1.0-alpha.8",
4
4
  "description": "Aithos SDK — 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",