@openentity/sdk 0.1.0 → 0.3.0
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 +110 -3
- package/dist/index.js +1150 -221
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -43,8 +43,11 @@ type VerifyResult = {
|
|
|
43
43
|
signer?: string;
|
|
44
44
|
error?: string;
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
export declare function
|
|
46
|
+
/** eddsa-jcs-2022 hashData: sha256(JCS(proof config)) || sha256(JCS(document)). */
|
|
47
|
+
export declare function hashData(obj: object, config: Omit<Proof, "proofValue">): Uint8Array;
|
|
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 & {
|
|
48
51
|
proof: Proof;
|
|
49
52
|
}>;
|
|
50
53
|
export declare function verifyProof(obj: object, proof: Proof, resolver?: Resolver): Promise<VerifyResult>;
|
|
@@ -72,9 +75,36 @@ export declare function buildDeclaration(input: {
|
|
|
72
75
|
name: string;
|
|
73
76
|
created?: string;
|
|
74
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
|
+
}>;
|
|
75
105
|
/** sha256 hex of the canonical entry INCLUDING its proof: the next entry's `prev` (spec 7.4). */
|
|
76
106
|
export declare function recordEntryHash(entry: object): Promise<string>;
|
|
77
|
-
type ObjectType = "EntityDocument" | "Declaration" | "Withdrawal" | "RecordEntry" | "Attestation" | "Revocation" | "ContinuityLink" | "Dispute" | "LogLeaf";
|
|
107
|
+
type ObjectType = "EntityDocument" | "Declaration" | "Withdrawal" | "Redaction" | "RecordEntry" | "Attestation" | "Revocation" | "ContinuityLink" | "Dispute" | "Presentation" | "LogLeaf";
|
|
78
108
|
/** Schema check (spec Appendix A) plus size caps: 16 KB for a RecordEntry (7.4), 64 KB for anything else (5.2). */
|
|
79
109
|
export declare function validate(type: ObjectType, obj: unknown): {
|
|
80
110
|
ok: boolean;
|
|
@@ -101,4 +131,81 @@ export declare function signNote(body: string, keyName: string, kp: KeyPair): Pr
|
|
|
101
131
|
/** C2SP vkey for a note key: `<name>+<key id hex>+<base64(0x01 || pubkey)>`. */
|
|
102
132
|
export declare function noteVkey(keyName: string, publicKey: Uint8Array): string;
|
|
103
133
|
export declare function verifyNote(note: string, keyName: string, publicKey: Uint8Array): Promise<boolean>;
|
|
134
|
+
/** Sign a proof of control of `kp`'s EID for one audience and one verifier-issued nonce, optionally carrying attestations. */
|
|
135
|
+
export declare function buildPresentation(kp: KeyPair, opts: {
|
|
136
|
+
audience: string;
|
|
137
|
+
nonce: string;
|
|
138
|
+
attestations?: object[];
|
|
139
|
+
}): Promise<object>;
|
|
140
|
+
type AttestationCheck = {
|
|
141
|
+
claim_type?: string;
|
|
142
|
+
issuer?: string;
|
|
143
|
+
ok: boolean;
|
|
144
|
+
error?: string;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Check a presentation the verifier asked for: schema, signature by the EID itself, audience, nonce, freshness (5 minutes).
|
|
148
|
+
* Each carried attestation is checked for subject, expiry and its issuer's signature; revocation needs the issuer or a
|
|
149
|
+
* registry and is the caller's to check when online. `ok` covers the presentation; attestations are reported one by one.
|
|
150
|
+
*/
|
|
151
|
+
export declare function verifyPresentation(p: any, opts: {
|
|
152
|
+
audience: string;
|
|
153
|
+
nonce: string;
|
|
154
|
+
now?: Date;
|
|
155
|
+
maxAgeSeconds?: number;
|
|
156
|
+
resolver?: Resolver;
|
|
157
|
+
}): Promise<{
|
|
158
|
+
ok: boolean;
|
|
159
|
+
eid?: string;
|
|
160
|
+
errors: string[];
|
|
161
|
+
attestations: AttestationCheck[];
|
|
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
|
+
};
|
|
104
211
|
export {};
|