@aithos/sdk 0.1.0-alpha.4 → 0.1.0-alpha.41

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.
Files changed (80) hide show
  1. package/README.md +211 -7
  2. package/dist/src/apps.d.ts +155 -0
  3. package/dist/src/apps.js +288 -0
  4. package/dist/src/assets.d.ts +207 -0
  5. package/dist/src/assets.js +533 -0
  6. package/dist/src/auth-api.d.ts +138 -0
  7. package/dist/src/auth-api.js +168 -0
  8. package/dist/src/auth.d.ts +536 -119
  9. package/dist/src/auth.js +1207 -152
  10. package/dist/src/compute.d.ts +251 -9
  11. package/dist/src/compute.js +293 -16
  12. package/dist/src/data-schema-contacts-v1.d.ts +14 -0
  13. package/dist/src/data-schema-contacts-v1.js +28 -0
  14. package/dist/src/data.d.ts +153 -0
  15. package/dist/src/data.js +670 -0
  16. package/dist/src/endpoints.d.ts +9 -0
  17. package/dist/src/endpoints.js +5 -0
  18. package/dist/src/ethos.d.ts +202 -1
  19. package/dist/src/ethos.js +821 -16
  20. package/dist/src/index.d.ts +18 -6
  21. package/dist/src/index.js +39 -6
  22. package/dist/src/internal/delegate-bundle.d.ts +18 -0
  23. package/dist/src/internal/delegate-bundle.js +94 -0
  24. package/dist/src/internal/delegate-state.d.ts +45 -0
  25. package/dist/src/internal/delegate-state.js +120 -0
  26. package/dist/src/internal/envelope.d.ts +77 -0
  27. package/dist/src/internal/envelope.js +154 -0
  28. package/dist/src/internal/owner-signers.d.ts +78 -0
  29. package/dist/src/internal/owner-signers.js +179 -0
  30. package/dist/src/internal/protocol-client-bridge.d.ts +8 -0
  31. package/dist/src/internal/protocol-client-bridge.js +20 -0
  32. package/dist/src/internal/recovery-file.d.ts +29 -0
  33. package/dist/src/internal/recovery-file.js +98 -0
  34. package/dist/src/internal/signer.d.ts +59 -0
  35. package/dist/src/internal/signer.js +86 -0
  36. package/dist/src/key-store.d.ts +128 -0
  37. package/dist/src/key-store.js +244 -0
  38. package/dist/src/mandates.d.ts +163 -1
  39. package/dist/src/mandates.js +286 -8
  40. package/dist/src/react/AithosAsset.d.ts +66 -0
  41. package/dist/src/react/AithosAsset.js +67 -0
  42. package/dist/src/react/context.d.ts +29 -0
  43. package/dist/src/react/context.js +31 -0
  44. package/dist/src/react/index.d.ts +28 -0
  45. package/dist/src/react/index.js +30 -0
  46. package/dist/src/react/use-aithos-asset.d.ts +39 -0
  47. package/dist/src/react/use-aithos-asset.js +118 -0
  48. package/dist/src/sdk.d.ts +46 -3
  49. package/dist/src/sdk.js +49 -23
  50. package/dist/src/wallet.d.ts +4 -6
  51. package/dist/src/wallet.js +18 -8
  52. package/dist/src/web.d.ts +279 -0
  53. package/dist/src/web.js +186 -0
  54. package/dist/test/auth-j3.test.d.ts +2 -0
  55. package/dist/test/auth-j3.test.js +391 -0
  56. package/dist/test/compute-delegate-path.test.d.ts +2 -0
  57. package/dist/test/compute-delegate-path.test.js +183 -0
  58. package/dist/test/compute.test.js +26 -11
  59. package/dist/test/endpoints.test.js +20 -1
  60. package/dist/test/envelope.test.d.ts +2 -0
  61. package/dist/test/envelope.test.js +318 -0
  62. package/dist/test/ethos-first-edition.test.d.ts +2 -0
  63. package/dist/test/ethos-first-edition.test.js +248 -0
  64. package/dist/test/ethos.test.d.ts +2 -0
  65. package/dist/test/ethos.test.js +219 -0
  66. package/dist/test/key-store.test.d.ts +2 -0
  67. package/dist/test/key-store.test.js +161 -0
  68. package/dist/test/mandates-compute.test.d.ts +2 -0
  69. package/dist/test/mandates-compute.test.js +256 -0
  70. package/dist/test/mandates.test.d.ts +2 -0
  71. package/dist/test/mandates.test.js +93 -0
  72. package/dist/test/sdk.test.js +70 -30
  73. package/dist/test/signer.test.d.ts +2 -0
  74. package/dist/test/signer.test.js +117 -0
  75. package/dist/test/signup-bootstrap.test.d.ts +2 -0
  76. package/dist/test/signup-bootstrap.test.js +311 -0
  77. package/dist/test/wallet.test.js +20 -9
  78. package/dist/test/web.test.d.ts +2 -0
  79. package/dist/test/web.test.js +270 -0
  80. package/package.json +18 -3
@@ -0,0 +1,28 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright 2026 Mathieu Colla
3
+ export const contactsV1 = {
4
+ schema: "aithos.contacts.v1",
5
+ indexable: new Set([
6
+ "name",
7
+ "email",
8
+ "phone_hash",
9
+ "status",
10
+ "tags",
11
+ "source",
12
+ "created_at",
13
+ "modified_at",
14
+ "last_contacted_at",
15
+ ]),
16
+ encrypted: new Set([
17
+ "phone",
18
+ "notes",
19
+ "conversation_log",
20
+ "form_responses",
21
+ "custom_fields",
22
+ ]),
23
+ auto: new Set(["created_at", "modified_at"]),
24
+ defaults: {
25
+ status: "lead",
26
+ },
27
+ };
28
+ //# sourceMappingURL=data-schema-contacts-v1.js.map
@@ -0,0 +1,153 @@
1
+ export interface AithosSchemaLite {
2
+ readonly schema: string;
3
+ readonly indexable: ReadonlySet<string>;
4
+ readonly encrypted: ReadonlySet<string>;
5
+ readonly auto: ReadonlySet<string>;
6
+ readonly defaults: Readonly<Record<string, unknown>>;
7
+ }
8
+ export interface CreateDataClientArgs {
9
+ /** Base URL of the deployed PDS (e.g. https://abc.execute-api.eu-west-3.amazonaws.com). */
10
+ readonly pdsUrl: string;
11
+ /** Subject DID — typically did:key:… in dev, did:aithos:… in prod. */
12
+ readonly did: string;
13
+ /**
14
+ * Ed25519 sphere seed (32 bytes). For did:key this is the same as
15
+ * the key embedded in the DID itself. For did:aithos this is the
16
+ * subject's `#data` (or `#public`) sphere key.
17
+ */
18
+ readonly sphereSeed: Uint8Array;
19
+ /**
20
+ * The verification method URL within the DID document used to sign
21
+ * envelopes. For did:key this is `<did>#<multibase>`. For did:aithos
22
+ * this is `<did>#data` (or `#public`).
23
+ */
24
+ readonly verificationMethod: string;
25
+ /** Optional fetch implementation. Defaults to globalThis.fetch. */
26
+ readonly fetch?: typeof fetch;
27
+ /**
28
+ * Optional list of app-defined schema definitions, in addition to
29
+ * the SDK-bundled core schemas (currently `aithos.contacts.v1`).
30
+ *
31
+ * Apps in the vendor namespace (`aithos.x.<vendor>.<name>.v<N>`) or
32
+ * non-`aithos.*` namespaces MUST supply their schemas here so the
33
+ * SDK can split records into indexable metadata vs encrypted payload.
34
+ *
35
+ * When the same schema id appears in both the bundled core registry
36
+ * and this list, the app-supplied definition wins (intentional —
37
+ * allows local overrides for testing, though immutability per spec
38
+ * §3.5 means a published schema id should never change shape).
39
+ *
40
+ * Schemas are scoped to the {@link DataClient} instance — they don't
41
+ * leak to other clients in the same process.
42
+ */
43
+ readonly schemas?: readonly AithosSchemaLite[];
44
+ }
45
+ export interface DataClient {
46
+ /** Get / create a collection handle. */
47
+ collection(name: string): DataCollection;
48
+ /** Initialize a new collection with an explicit schema. */
49
+ createCollection(args: {
50
+ name: string;
51
+ schema: string;
52
+ forwardSecrecy?: "best_effort" | "strict";
53
+ }): Promise<void>;
54
+ /** List collections owned by this subject. */
55
+ listCollections(): Promise<readonly {
56
+ name: string;
57
+ schema: string;
58
+ record_count: number;
59
+ }[]>;
60
+ /** List gamma audit entries. */
61
+ listGammaEntries(opts?: {
62
+ limit?: number;
63
+ opPrefix?: string;
64
+ verify?: boolean;
65
+ }): Promise<unknown>;
66
+ /**
67
+ * Idempotently publish a vendor (`aithos.x.<vendor>.<name>.v<N>`)
68
+ * JSON Schema document to this subject's PDS. Once published, the
69
+ * PDS validates record writes against the schema doc server-side,
70
+ * closing the gap A2a left open (cf. Aithos-protocol/PLAN-A2b-…).
71
+ *
72
+ * Safe to call on every app boot — re-registering the same document
73
+ * (same canonical hash) resolves to `{ created: false }`. A different
74
+ * document for the same `aithos:schema` id is REJECTED with code
75
+ * -32082 `AITHOS_DATA_SCHEMA_IMMUTABLE` ; the caller must bump the
76
+ * version segment in `aithos:schema` and retry.
77
+ *
78
+ * Core schemas (`aithos.<name>.v<N>` without `.x.`) cannot be
79
+ * registered via this RPC ; they're bundled by the platform per spec
80
+ * §3.7.2.
81
+ *
82
+ * @param schemaDoc Full JSON Schema 2020-12 document. MUST carry
83
+ * `aithos:schema` and `aithos:version` top-level fields.
84
+ */
85
+ registerSchema(schemaDoc: object): Promise<{
86
+ schemaId: string;
87
+ docHash: string;
88
+ created: boolean;
89
+ createdAt?: string;
90
+ }>;
91
+ /**
92
+ * Fetch a published schema document from the PDS.
93
+ *
94
+ * For core schemas (`aithos.<name>.v<N>`) the lookup is global ;
95
+ * `subjectDid` is ignored. For vendor schemas (`aithos.x.*`) the
96
+ * `subjectDid` arg selects whose published registry to query and
97
+ * defaults to this client's own DID.
98
+ *
99
+ * Returns null when the lookup misses (rather than throwing) so
100
+ * call sites can branch on the result.
101
+ */
102
+ getSchema(schemaId: string, opts?: {
103
+ subjectDid?: string;
104
+ }): Promise<object | null>;
105
+ /** Drop in-memory cache (CMK, collection metadata, …). */
106
+ reset(): void;
107
+ }
108
+ export interface DataCollection {
109
+ readonly name: string;
110
+ /**
111
+ * Insert a record. The object MAY contain both indexable and
112
+ * encrypted fields per the schema; the SDK splits them.
113
+ */
114
+ insert(record: Record<string, unknown>): Promise<string>;
115
+ /** Fetch one record by id (decrypted client-side). */
116
+ get(recordId: string): Promise<Record<string, unknown> | null>;
117
+ /** List records, decrypted. Pagination via opaque cursor. */
118
+ list(opts?: ListOpts): Promise<{
119
+ items: Record<string, unknown>[];
120
+ nextCursor?: string;
121
+ }>;
122
+ /**
123
+ * Replace a record. Same shape as insert; the SDK splits indexable
124
+ * vs encrypted again per the schema.
125
+ */
126
+ update(recordId: string, record: Record<string, unknown>): Promise<void>;
127
+ /** Soft-delete a record. */
128
+ delete(recordId: string): Promise<void>;
129
+ }
130
+ export interface ListOpts {
131
+ readonly filter?: {
132
+ readonly equals?: {
133
+ field: string;
134
+ value: unknown;
135
+ };
136
+ readonly contains?: {
137
+ field: string;
138
+ value: string;
139
+ };
140
+ readonly tagsAny?: readonly string[];
141
+ readonly tagsAll?: readonly string[];
142
+ readonly range?: {
143
+ field: string;
144
+ gte?: string;
145
+ lte?: string;
146
+ };
147
+ };
148
+ readonly order?: "newest" | "oldest";
149
+ readonly limit?: number;
150
+ readonly cursor?: string;
151
+ }
152
+ export declare function createDataClient(args: CreateDataClientArgs): DataClient;
153
+ //# sourceMappingURL=data.d.ts.map