@aithos/sdk 0.1.0-alpha.49 → 0.1.0-alpha.50
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/assets.d.ts +3 -2
- package/dist/src/assets.js +2 -1
- package/dist/src/data.d.ts +12 -6
- package/dist/src/data.js +2 -1
- package/dist/src/endpoints.d.ts +9 -0
- package/dist/src/endpoints.js +1 -0
- package/dist/test/endpoints.test.js +5 -0
- package/dist/test/sdk.test.js +2 -0
- package/package.json +1 -1
package/dist/src/assets.d.ts
CHANGED
|
@@ -35,8 +35,9 @@
|
|
|
35
35
|
*/
|
|
36
36
|
import { type AssetMetadata, type AssetReference } from "@aithos/assets-crypto";
|
|
37
37
|
export interface CreateAssetsClientArgs {
|
|
38
|
-
/** Base URL of the
|
|
39
|
-
|
|
38
|
+
/** Base URL of the assets PDS. Defaults to `https://pds.aithos.be` (the
|
|
39
|
+
* production vanity domain) when omitted. Override for self-hosting/staging. */
|
|
40
|
+
readonly pdsUrl?: string;
|
|
40
41
|
/** Subject DID. */
|
|
41
42
|
readonly did: string;
|
|
42
43
|
/** Ed25519 sphere seed (32 bytes). */
|
package/dist/src/assets.js
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
import { generateAMK, wrapAMKForRecipient, unwrapAMK, encryptAssetBytes, decryptAssetBytes, plaintextSha256Hex, } from "@aithos/assets-crypto";
|
|
39
39
|
import { x25519 } from "@noble/curves/ed25519.js";
|
|
40
40
|
import { sha512 } from "@noble/hashes/sha2.js";
|
|
41
|
+
import { DEFAULT_SDK_ENDPOINTS } from "./endpoints.js";
|
|
41
42
|
import { signOwnerEnvelope } from "./internal/envelope.js";
|
|
42
43
|
/* -------------------------------------------------------------------------- */
|
|
43
44
|
/* Public factory */
|
|
@@ -58,7 +59,7 @@ export class AssetsClient {
|
|
|
58
59
|
/** Cache: URN → AMK (recovered on first fetch, reused thereafter). */
|
|
59
60
|
#amkCache = new Map();
|
|
60
61
|
constructor(args) {
|
|
61
|
-
this.#pdsUrl = args.pdsUrl.replace(/\/$/, "");
|
|
62
|
+
this.#pdsUrl = (args.pdsUrl ?? DEFAULT_SDK_ENDPOINTS.pds).replace(/\/$/, "");
|
|
62
63
|
this.#did = args.did;
|
|
63
64
|
this.#seed = args.sphereSeed;
|
|
64
65
|
this.#verificationMethod = args.verificationMethod;
|
package/dist/src/data.d.ts
CHANGED
|
@@ -7,8 +7,12 @@ export interface AithosSchemaLite {
|
|
|
7
7
|
readonly defaults: Readonly<Record<string, unknown>>;
|
|
8
8
|
}
|
|
9
9
|
export interface CreateDataClientArgs {
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* PDS base URL. Defaults to `https://pds.aithos.be` (the production vanity
|
|
12
|
+
* domain, CloudFront-fronted) when omitted. Override for self-hosting or
|
|
13
|
+
* staging (e.g. a raw `execute-api` URL).
|
|
14
|
+
*/
|
|
15
|
+
readonly pdsUrl?: string;
|
|
12
16
|
/** Subject DID — typically did:key:… in dev, did:aithos:… in prod. */
|
|
13
17
|
readonly did: string;
|
|
14
18
|
/**
|
|
@@ -240,8 +244,9 @@ export interface ListOpts {
|
|
|
240
244
|
}
|
|
241
245
|
export declare function createDataClient(args: CreateDataClientArgs): DataClient;
|
|
242
246
|
export interface CreateDelegateDataClientArgs {
|
|
243
|
-
/** PDS base URL (same endpoint the owner writes to).
|
|
244
|
-
|
|
247
|
+
/** PDS base URL (same endpoint the owner writes to). Defaults to
|
|
248
|
+
* `https://pds.aithos.be` when omitted. */
|
|
249
|
+
readonly pdsUrl?: string;
|
|
245
250
|
/** DID of the SUBJECT whose data is being read (the mandate issuer). */
|
|
246
251
|
readonly subjectDid: string;
|
|
247
252
|
/**
|
|
@@ -295,8 +300,9 @@ export interface AppendOnlyDataClient {
|
|
|
295
300
|
reset(): void;
|
|
296
301
|
}
|
|
297
302
|
export interface CreateAppendDataClientArgs {
|
|
298
|
-
/** PDS base URL (same endpoint the owner writes to).
|
|
299
|
-
|
|
303
|
+
/** PDS base URL (same endpoint the owner writes to). Defaults to
|
|
304
|
+
* `https://pds.aithos.be` when omitted. */
|
|
305
|
+
readonly pdsUrl?: string;
|
|
300
306
|
/** DID of the SUBJECT who owns the target collection (the mandate issuer). */
|
|
301
307
|
readonly subjectDid: string;
|
|
302
308
|
/**
|
package/dist/src/data.js
CHANGED
|
@@ -41,6 +41,7 @@ import * as ed from "@noble/ed25519";
|
|
|
41
41
|
import { multibaseToEd25519PublicKey, edPubToX25519Pub, } from "@aithos/protocol-client";
|
|
42
42
|
import { canonicalize } from "@aithos/protocol-core/canonical";
|
|
43
43
|
import { contactsV1 } from "./data-schema-contacts-v1.js";
|
|
44
|
+
import { DEFAULT_SDK_ENDPOINTS } from "./endpoints.js";
|
|
44
45
|
import { signOwnerEnvelope } from "./internal/envelope.js";
|
|
45
46
|
// noble/ed25519 v2 needs sha512 wired in for sync sign/verify
|
|
46
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -159,7 +160,7 @@ class DataClientImpl {
|
|
|
159
160
|
#cmkCache = new Map();
|
|
160
161
|
#colCache = new Map();
|
|
161
162
|
constructor(args) {
|
|
162
|
-
this.#pdsUrl = args.pdsUrl.replace(/\/$/, "");
|
|
163
|
+
this.#pdsUrl = (args.pdsUrl ?? DEFAULT_SDK_ENDPOINTS.pds).replace(/\/$/, "");
|
|
163
164
|
this.#did = args.did;
|
|
164
165
|
this.#seed = args.sphereSeed;
|
|
165
166
|
this.#vm = args.verificationMethod;
|
package/dist/src/endpoints.d.ts
CHANGED
|
@@ -17,6 +17,15 @@ export interface AithosSdkEndpoints {
|
|
|
17
17
|
* scope without the other.
|
|
18
18
|
*/
|
|
19
19
|
readonly web: string;
|
|
20
|
+
/**
|
|
21
|
+
* Personal Data Store base URL — the `aithos.data.*` sub-protocol PDS
|
|
22
|
+
* (and the assets sub-protocol, which shares the same host). Default
|
|
23
|
+
* `https://pds.aithos.be`. Previously every app had to pass a raw
|
|
24
|
+
* `execute-api` URL to `createDataClient` / `createAssetsClient`; this
|
|
25
|
+
* centralizes it on the vanity domain (CloudFront-fronted, same as the
|
|
26
|
+
* other surfaces). Override for self-hosting or staging.
|
|
27
|
+
*/
|
|
28
|
+
readonly pds: string;
|
|
20
29
|
}
|
|
21
30
|
/** Production defaults. */
|
|
22
31
|
export declare const DEFAULT_SDK_ENDPOINTS: AithosSdkEndpoints;
|
package/dist/src/endpoints.js
CHANGED
|
@@ -5,6 +5,7 @@ export const DEFAULT_SDK_ENDPOINTS = {
|
|
|
5
5
|
compute: "https://compute.aithos.be",
|
|
6
6
|
wallet: "https://wallet.aithos.be",
|
|
7
7
|
web: "https://extract.aithos.be",
|
|
8
|
+
pds: "https://pds.aithos.be",
|
|
8
9
|
};
|
|
9
10
|
/** Compose the full compute-invoke URL: `${compute}/v1/invoke`. */
|
|
10
11
|
export function computeInvokeUrl(endpoints) {
|
|
@@ -24,6 +24,7 @@ describe("computeInvokeUrl", () => {
|
|
|
24
24
|
compute: "https://compute.aithos.be",
|
|
25
25
|
wallet: "https://wallet.aithos.be",
|
|
26
26
|
web: "https://extract.aithos.be",
|
|
27
|
+
pds: "https://pds.aithos.be",
|
|
27
28
|
}), "https://compute.aithos.be/v1/invoke");
|
|
28
29
|
});
|
|
29
30
|
it("trims a trailing slash on the compute base", () => {
|
|
@@ -31,6 +32,7 @@ describe("computeInvokeUrl", () => {
|
|
|
31
32
|
compute: "https://compute.aithos.be/",
|
|
32
33
|
wallet: "https://wallet.aithos.be",
|
|
33
34
|
web: "https://extract.aithos.be",
|
|
35
|
+
pds: "https://pds.aithos.be",
|
|
34
36
|
}), "https://compute.aithos.be/v1/invoke");
|
|
35
37
|
});
|
|
36
38
|
});
|
|
@@ -40,6 +42,7 @@ describe("walletTopupCheckoutUrl", () => {
|
|
|
40
42
|
compute: "https://compute.aithos.be",
|
|
41
43
|
wallet: "https://wallet.aithos.be",
|
|
42
44
|
web: "https://extract.aithos.be",
|
|
45
|
+
pds: "https://pds.aithos.be",
|
|
43
46
|
}), "https://wallet.aithos.be/v1/wallet/topup/checkout");
|
|
44
47
|
});
|
|
45
48
|
});
|
|
@@ -49,6 +52,7 @@ describe("webInvokeUrl", () => {
|
|
|
49
52
|
compute: "https://compute.aithos.be",
|
|
50
53
|
wallet: "https://wallet.aithos.be",
|
|
51
54
|
web: "https://extract.aithos.be",
|
|
55
|
+
pds: "https://pds.aithos.be",
|
|
52
56
|
}), "https://extract.aithos.be/v1/invoke");
|
|
53
57
|
});
|
|
54
58
|
it("trims a trailing slash on the web base", () => {
|
|
@@ -56,6 +60,7 @@ describe("webInvokeUrl", () => {
|
|
|
56
60
|
compute: "https://compute.aithos.be",
|
|
57
61
|
wallet: "https://wallet.aithos.be",
|
|
58
62
|
web: "https://extract.aithos.be/",
|
|
63
|
+
pds: "https://pds.aithos.be",
|
|
59
64
|
}), "https://extract.aithos.be/v1/invoke");
|
|
60
65
|
});
|
|
61
66
|
});
|
package/dist/test/sdk.test.js
CHANGED
|
@@ -33,6 +33,8 @@ describe("DEFAULT_SDK_ENDPOINTS", () => {
|
|
|
33
33
|
it("points at the production Aithos hosts", () => {
|
|
34
34
|
assert.equal(DEFAULT_SDK_ENDPOINTS.compute, "https://compute.aithos.be");
|
|
35
35
|
assert.equal(DEFAULT_SDK_ENDPOINTS.wallet, "https://wallet.aithos.be");
|
|
36
|
+
assert.equal(DEFAULT_SDK_ENDPOINTS.web, "https://extract.aithos.be");
|
|
37
|
+
assert.equal(DEFAULT_SDK_ENDPOINTS.pds, "https://pds.aithos.be");
|
|
36
38
|
});
|
|
37
39
|
});
|
|
38
40
|
describe("AithosSDK constructor", () => {
|
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.50",
|
|
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",
|