@openentity/sdk 0.3.0 → 0.5.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;
@@ -208,4 +208,186 @@ export declare function agentCard(doc: {
208
208
  tags: string[];
209
209
  }[];
210
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>;
362
+ export declare class HttpSigError extends Error {
363
+ code: string;
364
+ constructor(code: string);
365
+ }
366
+ export declare function httpSigBase(method: string, url: string, components: string[], digest: string | undefined, params: string): Uint8Array;
367
+ /** Sign a request. `privateKey` is a KeyPair or a 32-byte Ed25519 seed. Returns Signature-Input, Signature and, for a non-empty body, Content-Digest. */
368
+ export declare function signRequest(o: {
369
+ method: string;
370
+ url: string;
371
+ body?: Uint8Array;
372
+ privateKey: KeyPair | Uint8Array;
373
+ did: string;
374
+ created?: number;
375
+ expiresIn?: number;
376
+ nonce?: string;
377
+ }): Promise<Record<string, string>>;
378
+ /** Verify a request signed by signRequest. Throws HttpSigError with `.code`. Nonce replay tracking is the caller's job. */
379
+ export declare function verifyRequest(o: {
380
+ method: string;
381
+ url: string;
382
+ headers: Record<string, string>;
383
+ body?: Uint8Array;
384
+ now?: number;
385
+ maxAge?: number;
386
+ }): Promise<{
387
+ did: string;
388
+ keyid: string;
389
+ created: number;
390
+ expires: number;
391
+ nonce: string;
392
+ }>;
211
393
  export {};