@openentity/sdk 0.2.0 → 0.4.1

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/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export interface KeyPair {
20
20
  }
21
21
  export declare function keyPairFromJwk(privateJwk: JsonWebKey): Promise<KeyPair>;
22
22
  export declare function generateKeyPair(): Promise<KeyPair>;
23
- /** Deterministic key pair from a 32-byte seed. For test vectors only. */
23
+ /** Deterministic key pair from a 32-byte seed: test vectors, and `Identity` (sdk/ts/src/node.ts), which keeps the seed. */
24
24
  export declare function keyPairFromSeed(seed32: Uint8Array): Promise<KeyPair>;
25
25
  export declare function didKeyFromPublicKey(pk: Uint8Array): string;
26
26
  export declare function publicKeyFromDidKey(did: string): Uint8Array;
@@ -45,8 +45,9 @@ type VerifyResult = {
45
45
  };
46
46
  /** eddsa-jcs-2022 hashData: sha256(JCS(proof config)) || sha256(JCS(document)). */
47
47
  export declare function hashData(obj: object, config: Omit<Proof, "proofValue">): Uint8Array;
48
- export declare function signProof(obj: object, kp: KeyPair, created?: string): Promise<Proof>;
49
- export declare function signObject<T extends object>(obj: T, kp: KeyPair, created?: string): Promise<T & {
48
+ /** `verificationMethod` defaults to the did:key of `kp`; a did:web signer passes its own method id (for example `did:web:x#key-1`). */
49
+ export declare function signProof(obj: object, kp: KeyPair, created?: string, verificationMethod?: string): Promise<Proof>;
50
+ export declare function signObject<T extends object>(obj: T, kp: KeyPair, created?: string, verificationMethod?: string): Promise<T & {
50
51
  proof: Proof;
51
52
  }>;
52
53
  export declare function verifyProof(obj: object, proof: Proof, resolver?: Resolver): Promise<VerifyResult>;
@@ -74,9 +75,36 @@ export declare function buildDeclaration(input: {
74
75
  name: string;
75
76
  created?: string;
76
77
  }): object;
78
+ /** The successor's unsigned seq 1 Entity Document: `prev` re-keyed, aliases dropped (their proofs name the old EID), `continuity.previous` set. */
79
+ export declare function successorDocument(prev: Record<string, any>, next: KeyPair, created?: string): Record<string, any>;
80
+ /** A Continuity Link signed by both keys (spec 9.2) plus the successor's document signed by the successor: the body of `POST /v1/continuity`. */
81
+ export declare function buildRotation(previous: KeyPair, successor: KeyPair, document: Record<string, any>, o?: {
82
+ basis?: "rotation" | "migration";
83
+ created?: string;
84
+ nonce?: string;
85
+ }): Promise<{
86
+ link: Record<string, any>;
87
+ document: Record<string, any>;
88
+ }>;
89
+ /**
90
+ * Rotate `previous` to a new key in one call: fetch the current document, build and sign the link, mint the stamp for the
91
+ * successor and submit. Nothing is persisted: on success the caller saves `successor` (its `privateJwk`) and only then retires
92
+ * the old key. Throws on any non-2xx answer.
93
+ */
94
+ export declare function rotate(o: {
95
+ previous: KeyPair;
96
+ registry?: string;
97
+ successor?: KeyPair;
98
+ basis?: "rotation" | "migration";
99
+ }): Promise<{
100
+ successor: KeyPair;
101
+ link: Record<string, any>;
102
+ document: Record<string, any>;
103
+ response: any;
104
+ }>;
77
105
  /** sha256 hex of the canonical entry INCLUDING its proof: the next entry's `prev` (spec 7.4). */
78
106
  export declare function recordEntryHash(entry: object): Promise<string>;
79
- type ObjectType = "EntityDocument" | "Declaration" | "Withdrawal" | "RecordEntry" | "Attestation" | "Revocation" | "ContinuityLink" | "Dispute" | "Presentation" | "LogLeaf";
107
+ type ObjectType = "EntityDocument" | "Declaration" | "Withdrawal" | "Redaction" | "RecordEntry" | "Attestation" | "Revocation" | "ContinuityLink" | "Dispute" | "Presentation" | "LogLeaf";
80
108
  /** Schema check (spec Appendix A) plus size caps: 16 KB for a RecordEntry (7.4), 64 KB for anything else (5.2). */
81
109
  export declare function validate(type: ObjectType, obj: unknown): {
82
110
  ok: boolean;
@@ -132,4 +160,203 @@ export declare function verifyPresentation(p: any, opts: {
132
160
  errors: string[];
133
161
  attestations: AttestationCheck[];
134
162
  }>;
163
+ export declare const A2A_EXTENSION_URI = "https://openentity.org/spec/1.0";
164
+ /** The AgentExtension entry that carries an EID in an A2A Agent Card's `capabilities.extensions`. */
165
+ export declare function a2aExtension(eid: string, documentUrl: string): {
166
+ uri: string;
167
+ description: string;
168
+ required: boolean;
169
+ params: {
170
+ eid: string;
171
+ document: string;
172
+ };
173
+ };
174
+ /** A full A2A AgentCard for an Entity Document: each capability slug becomes a skill. `url` is the agent's A2A endpoint. */
175
+ export declare function agentCard(doc: {
176
+ eid: string;
177
+ name: string;
178
+ description: string;
179
+ capabilities?: string[];
180
+ }, opts: {
181
+ url: string;
182
+ documentUrl: string;
183
+ version?: string;
184
+ }): {
185
+ name: string;
186
+ description: string;
187
+ url: string;
188
+ version: string;
189
+ capabilities: {
190
+ streaming: boolean;
191
+ pushNotifications: boolean;
192
+ extensions: {
193
+ uri: string;
194
+ description: string;
195
+ required: boolean;
196
+ params: {
197
+ eid: string;
198
+ document: string;
199
+ };
200
+ }[];
201
+ };
202
+ defaultInputModes: string[];
203
+ defaultOutputModes: string[];
204
+ skills: {
205
+ id: string;
206
+ name: string;
207
+ description: string;
208
+ tags: string[];
209
+ }[];
210
+ };
211
+ type IssuerOpts = {
212
+ issuer?: string;
213
+ keyId?: string;
214
+ now?: Date;
215
+ };
216
+ /** A signed Attestation (spec 8.2). `ttlSeconds` defaults to 90 days and is capped at one year. */
217
+ export declare function signAttestation(kp: KeyPair, o: IssuerOpts & {
218
+ subject: string;
219
+ claimType: string;
220
+ claim: object;
221
+ evidence?: object;
222
+ confidence?: number;
223
+ ttlSeconds?: number;
224
+ }): Promise<{
225
+ spec: string;
226
+ type: string;
227
+ issuer: string;
228
+ subject: string;
229
+ claim_type: string;
230
+ claim: object;
231
+ evidence?: object | undefined;
232
+ confidence?: number | undefined;
233
+ created: string;
234
+ expires: string;
235
+ } & {
236
+ proof: Proof;
237
+ }>;
238
+ /** A signed Revocation naming the attestation (the object, or its SHA-256 hex) (spec 8.4). */
239
+ export declare function signRevocation(kp: KeyPair, attested: object | string, o?: IssuerOpts & {
240
+ reason?: string;
241
+ }): Promise<{
242
+ spec: string;
243
+ type: string;
244
+ issuer: string;
245
+ attestation_sha256: string;
246
+ reason?: string | undefined;
247
+ created: string;
248
+ } & {
249
+ proof: Proof;
250
+ }>;
251
+ /** The body of `https://<domain>/.well-known/did.json` for a did:web issuer. */
252
+ export declare function buildDidDocument(did: string, publicKey: Uint8Array, keyId?: string): {
253
+ "@context": string[];
254
+ id: string;
255
+ verificationMethod: {
256
+ id: string;
257
+ type: string;
258
+ controller: string;
259
+ publicKeyMultibase: string;
260
+ }[];
261
+ assertionMethod: string[];
262
+ authentication: string[];
263
+ };
264
+ /** The unsigned body of `https://<domain>/.well-known/openentity.json`: the domain alias proof (spec 3.4) and, under
265
+ * `extensions["openentity:observer"]`, an observer's methodology (spec 8.4). */
266
+ export declare function buildOpenEntityJson(did: string, publicKey: Uint8Array, o: {
267
+ name: string;
268
+ description: string;
269
+ keyId?: string;
270
+ operator?: object;
271
+ extensions?: object;
272
+ }): {
273
+ spec: string;
274
+ eid: string;
275
+ name: string;
276
+ description: string;
277
+ keys: {
278
+ id: string;
279
+ type: string;
280
+ publicKeyMultibase: string;
281
+ }[];
282
+ operator: object;
283
+ extensions?: object | undefined;
284
+ };
285
+ /** The registry's allowlist for the unsigned `client` label on POST /v1/adopt. */
286
+ export declare const CLIENTS: readonly ["adk", "goose", "langchain", "ui-tars", "cli", "other"];
287
+ export type Client = (typeof CLIENTS)[number];
288
+ /** Adopt `kp` on a registry: document, Declaration and the seq-1 declaration entry (spec 5.2, 6.2, 7.3). `client` is not signed. */
289
+ export declare function adopt(kp: KeyPair, o: {
290
+ name: string;
291
+ description?: string;
292
+ registry?: string;
293
+ client?: Client;
294
+ }): Promise<{
295
+ response: any;
296
+ did: string;
297
+ document: object & {
298
+ proof: Proof;
299
+ };
300
+ declaration: object & {
301
+ proof: Proof;
302
+ };
303
+ recordEntry: {
304
+ spec: string;
305
+ type: string;
306
+ eid: string;
307
+ seq: number;
308
+ prev: null;
309
+ kind: string;
310
+ at: string;
311
+ payload: {
312
+ declaration_version: string;
313
+ sha256: string;
314
+ };
315
+ } & {
316
+ proof: Proof;
317
+ };
318
+ recordPushed: boolean;
319
+ }>;
320
+ export interface TrustReport {
321
+ eid: string;
322
+ /** false: a read failed or a signature did not verify. Treat the entity as untrusted. */
323
+ ok: boolean;
324
+ error?: string;
325
+ level?: string;
326
+ withdrawn: boolean;
327
+ /** issuer DID to its newest live tier (0 to 4) */
328
+ trustTier: Record<string, number>;
329
+ /** claim of the newest live custom:securemyagent:security_posture */
330
+ securityPosture: Record<string, any> | null;
331
+ /** live custom:clawgrc:violation */
332
+ violations: {
333
+ issuer: string;
334
+ severity: string;
335
+ policy: string;
336
+ observed_at: string;
337
+ sha256: string;
338
+ }[];
339
+ /** verified revocations of the accepted attestations */
340
+ revocations: {
341
+ sha256: string;
342
+ claim_type: string;
343
+ issuer: string;
344
+ reason?: string;
345
+ at: string;
346
+ }[];
347
+ }
348
+ type FetchJson = (url: string) => Promise<any>;
349
+ export declare const clearTrustCache: () => void;
350
+ /** did:web through /.well-known/did.json (or <path>/did.json); everything else offline. */
351
+ export declare function didWebResolver(fetchJson?: FetchJson): Resolver;
352
+ /**
353
+ * One TrustReport from `GET /v1/entities/{eid}` and `/attestations` only. Every attestation and revocation from the accepted
354
+ * issuers is verified locally against the issuer's key; any failure returns an untrusted report. Cached for 5 minutes.
355
+ */
356
+ export declare function trust(eid: string, o?: {
357
+ registry?: string;
358
+ now?: Date;
359
+ fetchJson?: FetchJson;
360
+ resolver?: Resolver;
361
+ }): Promise<TrustReport>;
135
362
  export {};