@aithos/sdk 0.1.0-alpha.4 → 0.1.0-alpha.40
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/README.md +211 -7
- package/dist/src/assets.d.ts +207 -0
- package/dist/src/assets.js +533 -0
- package/dist/src/auth-api.d.ts +138 -0
- package/dist/src/auth-api.js +168 -0
- package/dist/src/auth.d.ts +536 -119
- package/dist/src/auth.js +1207 -152
- package/dist/src/compute.d.ts +221 -9
- package/dist/src/compute.js +293 -16
- package/dist/src/data-schema-contacts-v1.d.ts +14 -0
- package/dist/src/data-schema-contacts-v1.js +28 -0
- package/dist/src/data.d.ts +153 -0
- package/dist/src/data.js +670 -0
- package/dist/src/endpoints.d.ts +9 -0
- package/dist/src/endpoints.js +5 -0
- package/dist/src/ethos.d.ts +202 -1
- package/dist/src/ethos.js +821 -16
- package/dist/src/index.d.ts +16 -6
- package/dist/src/index.js +33 -6
- package/dist/src/internal/delegate-bundle.d.ts +18 -0
- package/dist/src/internal/delegate-bundle.js +94 -0
- package/dist/src/internal/delegate-state.d.ts +45 -0
- package/dist/src/internal/delegate-state.js +120 -0
- package/dist/src/internal/envelope.d.ts +77 -0
- package/dist/src/internal/envelope.js +154 -0
- package/dist/src/internal/owner-signers.d.ts +78 -0
- package/dist/src/internal/owner-signers.js +179 -0
- package/dist/src/internal/protocol-client-bridge.d.ts +8 -0
- package/dist/src/internal/protocol-client-bridge.js +20 -0
- package/dist/src/internal/recovery-file.d.ts +29 -0
- package/dist/src/internal/recovery-file.js +98 -0
- package/dist/src/internal/signer.d.ts +59 -0
- package/dist/src/internal/signer.js +86 -0
- package/dist/src/key-store.d.ts +128 -0
- package/dist/src/key-store.js +244 -0
- package/dist/src/mandates.d.ts +163 -1
- package/dist/src/mandates.js +286 -8
- package/dist/src/react/AithosAsset.d.ts +66 -0
- package/dist/src/react/AithosAsset.js +67 -0
- package/dist/src/react/context.d.ts +29 -0
- package/dist/src/react/context.js +31 -0
- package/dist/src/react/index.d.ts +28 -0
- package/dist/src/react/index.js +30 -0
- package/dist/src/react/use-aithos-asset.d.ts +39 -0
- package/dist/src/react/use-aithos-asset.js +118 -0
- package/dist/src/sdk.d.ts +39 -3
- package/dist/src/sdk.js +36 -23
- package/dist/src/wallet.d.ts +4 -6
- package/dist/src/wallet.js +18 -8
- package/dist/src/web.d.ts +279 -0
- package/dist/src/web.js +186 -0
- package/package.json +18 -3
- package/dist/test/auth.test.d.ts +0 -2
- package/dist/test/auth.test.js +0 -175
- package/dist/test/compute.test.d.ts +0 -2
- package/dist/test/compute.test.js +0 -179
- package/dist/test/endpoints.test.d.ts +0 -2
- package/dist/test/endpoints.test.js +0 -43
- package/dist/test/sdk.test.d.ts +0 -2
- package/dist/test/sdk.test.js +0 -86
- package/dist/test/wallet.test.d.ts +0 -2
- package/dist/test/wallet.test.js +0 -110
|
@@ -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
|