@awiki/anp-typescript-sdk 0.2.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/CHANGELOG.md +14 -0
- package/LICENSE +201 -0
- package/README.md +191 -0
- package/dist/index.cjs +4991 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +790 -0
- package/dist/index.d.ts +790 -0
- package/dist/index.js +4868 -0
- package/dist/index.js.map +1 -0
- package/package.json +81 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
declare class ANPError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
constructor(message: string, code: string, cause?: Error);
|
|
4
|
+
}
|
|
5
|
+
declare class CryptoError extends ANPError {
|
|
6
|
+
constructor(message: string, cause?: Error);
|
|
7
|
+
}
|
|
8
|
+
declare class AuthenticationError extends ANPError {
|
|
9
|
+
constructor(message: string, cause?: Error);
|
|
10
|
+
}
|
|
11
|
+
declare class ProofError extends ANPError {
|
|
12
|
+
constructor(message: string, cause?: Error);
|
|
13
|
+
}
|
|
14
|
+
declare class NetworkError extends ANPError {
|
|
15
|
+
readonly statusCode?: number | undefined;
|
|
16
|
+
constructor(message: string, statusCode?: number | undefined, cause?: Error);
|
|
17
|
+
}
|
|
18
|
+
declare class WnsError extends ANPError {
|
|
19
|
+
constructor(message: string, code?: string, cause?: Error);
|
|
20
|
+
}
|
|
21
|
+
declare class HandleValidationError extends WnsError {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
declare class HandleResolutionError extends WnsError {
|
|
25
|
+
readonly statusCode?: number | undefined;
|
|
26
|
+
constructor(message: string, statusCode?: number | undefined, cause?: Error);
|
|
27
|
+
}
|
|
28
|
+
declare class HandleNotFoundError extends HandleResolutionError {
|
|
29
|
+
constructor(message: string);
|
|
30
|
+
}
|
|
31
|
+
declare class HandleGoneError extends HandleResolutionError {
|
|
32
|
+
constructor(message: string);
|
|
33
|
+
}
|
|
34
|
+
declare class HandleMovedError extends HandleResolutionError {
|
|
35
|
+
readonly redirectUrl: string;
|
|
36
|
+
constructor(message: string, redirectUrl?: string);
|
|
37
|
+
}
|
|
38
|
+
declare class HandleBindingError extends WnsError {
|
|
39
|
+
constructor(message: string);
|
|
40
|
+
}
|
|
41
|
+
declare class WbaUriParseError extends WnsError {
|
|
42
|
+
constructor(message: string);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type KeyType = 'secp256k1' | 'secp256r1' | 'ed25519' | 'x25519';
|
|
46
|
+
type PrivateKeyInput = string | PrivateKeyMaterial;
|
|
47
|
+
type PublicKeyInput = string | PublicKeyMaterial;
|
|
48
|
+
interface PrivateKeyMaterial {
|
|
49
|
+
type: KeyType;
|
|
50
|
+
bytes: Uint8Array;
|
|
51
|
+
}
|
|
52
|
+
interface PublicKeyMaterial {
|
|
53
|
+
type: KeyType;
|
|
54
|
+
bytes: Uint8Array;
|
|
55
|
+
}
|
|
56
|
+
interface GeneratedKeyPairPem {
|
|
57
|
+
privateKeyPem: string;
|
|
58
|
+
publicKeyPem: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type JsonPrimitive = null | boolean | number | string;
|
|
62
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
63
|
+
interface JsonObject {
|
|
64
|
+
[key: string]: JsonValue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare enum DidProfile {
|
|
68
|
+
E1 = "e1",
|
|
69
|
+
K1 = "k1",
|
|
70
|
+
PlainLegacy = "plain_legacy"
|
|
71
|
+
}
|
|
72
|
+
declare enum AuthMode {
|
|
73
|
+
HttpSignatures = "http_signatures",
|
|
74
|
+
LegacyDidWba = "legacy_didwba",
|
|
75
|
+
Auto = "auto"
|
|
76
|
+
}
|
|
77
|
+
interface ProofRecord {
|
|
78
|
+
type: string;
|
|
79
|
+
created: string;
|
|
80
|
+
verificationMethod: string;
|
|
81
|
+
proofPurpose: string;
|
|
82
|
+
proofValue: string;
|
|
83
|
+
cryptosuite?: string;
|
|
84
|
+
domain?: string;
|
|
85
|
+
challenge?: string;
|
|
86
|
+
}
|
|
87
|
+
interface VerificationMethodRecord {
|
|
88
|
+
id: string;
|
|
89
|
+
type: string;
|
|
90
|
+
controller: string;
|
|
91
|
+
publicKeyJwk?: JsonWebKey;
|
|
92
|
+
publicKeyMultibase?: string;
|
|
93
|
+
publicKeyBase58?: string;
|
|
94
|
+
}
|
|
95
|
+
interface ServiceRecord {
|
|
96
|
+
id: string;
|
|
97
|
+
type: string;
|
|
98
|
+
serviceEndpoint: unknown;
|
|
99
|
+
serviceDid?: string;
|
|
100
|
+
profiles?: string[];
|
|
101
|
+
securityProfiles?: string[];
|
|
102
|
+
accepts?: string[];
|
|
103
|
+
priority?: number | string;
|
|
104
|
+
authSchemes?: string[];
|
|
105
|
+
}
|
|
106
|
+
interface AnpMessageServiceOptions {
|
|
107
|
+
fragment?: string;
|
|
108
|
+
serviceDid?: string;
|
|
109
|
+
profiles?: string[];
|
|
110
|
+
securityProfiles?: string[];
|
|
111
|
+
accepts?: string[];
|
|
112
|
+
priority?: number | string;
|
|
113
|
+
authSchemes?: string[];
|
|
114
|
+
}
|
|
115
|
+
interface DidDocument {
|
|
116
|
+
'@context': string[];
|
|
117
|
+
id: string;
|
|
118
|
+
verificationMethod: VerificationMethodRecord[];
|
|
119
|
+
authentication: Array<string | VerificationMethodRecord>;
|
|
120
|
+
assertionMethod?: Array<string | VerificationMethodRecord>;
|
|
121
|
+
keyAgreement?: Array<string | VerificationMethodRecord>;
|
|
122
|
+
service?: ServiceRecord[];
|
|
123
|
+
proof?: ProofRecord;
|
|
124
|
+
}
|
|
125
|
+
interface DidDocumentOptions {
|
|
126
|
+
port?: number;
|
|
127
|
+
pathSegments?: string[];
|
|
128
|
+
agentDescriptionUrl?: string;
|
|
129
|
+
services?: Array<ServiceRecord | JsonObject>;
|
|
130
|
+
proofPurpose?: string;
|
|
131
|
+
verificationMethod?: string;
|
|
132
|
+
domain?: string;
|
|
133
|
+
challenge?: string;
|
|
134
|
+
created?: string;
|
|
135
|
+
enableE2ee?: boolean;
|
|
136
|
+
didProfile?: DidProfile;
|
|
137
|
+
}
|
|
138
|
+
interface DidDocumentBundle {
|
|
139
|
+
didDocument: DidDocument;
|
|
140
|
+
keys: Record<string, GeneratedKeyPairPem>;
|
|
141
|
+
}
|
|
142
|
+
interface ParsedAuthHeader {
|
|
143
|
+
did: string;
|
|
144
|
+
nonce: string;
|
|
145
|
+
timestamp: string;
|
|
146
|
+
verificationMethod: string;
|
|
147
|
+
signature: string;
|
|
148
|
+
version: string;
|
|
149
|
+
}
|
|
150
|
+
interface LegacyAuthOptions {
|
|
151
|
+
nonce?: string;
|
|
152
|
+
timestamp?: string;
|
|
153
|
+
}
|
|
154
|
+
interface DidResolutionOptions {
|
|
155
|
+
timeoutSeconds?: number;
|
|
156
|
+
verifySsl?: boolean;
|
|
157
|
+
baseUrlOverride?: string;
|
|
158
|
+
headers?: Record<string, string>;
|
|
159
|
+
}
|
|
160
|
+
type DidResolver = (did: string) => DidDocument | null | undefined | Promise<DidDocument | null | undefined>;
|
|
161
|
+
interface HttpSignatureOptions {
|
|
162
|
+
keyid?: string;
|
|
163
|
+
nonce?: string;
|
|
164
|
+
created?: number;
|
|
165
|
+
expires?: number;
|
|
166
|
+
coveredComponents?: string[];
|
|
167
|
+
}
|
|
168
|
+
interface FederatedVerificationOptions {
|
|
169
|
+
senderDidDocument?: DidDocument;
|
|
170
|
+
serviceDidDocument?: DidDocument;
|
|
171
|
+
serviceId?: string;
|
|
172
|
+
serviceEndpoint?: string;
|
|
173
|
+
verifySenderDidProof?: boolean;
|
|
174
|
+
verifyServiceDidProof?: boolean;
|
|
175
|
+
didResolutionOptions?: DidResolutionOptions;
|
|
176
|
+
}
|
|
177
|
+
interface SignatureMetadata {
|
|
178
|
+
label: string;
|
|
179
|
+
components: string[];
|
|
180
|
+
keyid: string;
|
|
181
|
+
nonce?: string;
|
|
182
|
+
created: number;
|
|
183
|
+
expires?: number;
|
|
184
|
+
}
|
|
185
|
+
interface FederatedVerificationResult {
|
|
186
|
+
senderDid: string;
|
|
187
|
+
serviceDid: string;
|
|
188
|
+
serviceId: string;
|
|
189
|
+
signatureMetadata: SignatureMetadata;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare class VerificationMethod {
|
|
193
|
+
readonly id: string;
|
|
194
|
+
readonly methodType: string;
|
|
195
|
+
readonly publicKey: PublicKeyMaterial;
|
|
196
|
+
constructor(id: string, methodType: string, publicKey: PublicKeyMaterial);
|
|
197
|
+
verifySignature(content: Uint8Array, signature: string): boolean;
|
|
198
|
+
encodeSignature(signatureBytes: Uint8Array): string;
|
|
199
|
+
}
|
|
200
|
+
declare function createVerificationMethod(method: VerificationMethodRecord): VerificationMethod;
|
|
201
|
+
declare function extractPublicKey(method: VerificationMethodRecord): PublicKeyMaterial;
|
|
202
|
+
|
|
203
|
+
declare const VM_KEY_AUTH = "key-1";
|
|
204
|
+
declare const VM_KEY_E2EE_SIGNING = "key-2";
|
|
205
|
+
declare const VM_KEY_E2EE_AGREEMENT = "key-3";
|
|
206
|
+
declare const ANP_MESSAGE_SERVICE_TYPE = "ANPMessageService";
|
|
207
|
+
declare function resolveDidWbaDocument(did: string, verifyProof?: boolean, options?: DidResolutionOptions): Promise<DidDocument>;
|
|
208
|
+
declare function buildAnpMessageService(didOrServiceRef: string, serviceEndpoint: string, options?: AnpMessageServiceOptions): ServiceRecord;
|
|
209
|
+
declare function buildAgentMessageService(didOrServiceRef: string, serviceEndpoint: string, options?: AnpMessageServiceOptions): ServiceRecord;
|
|
210
|
+
declare function buildGroupMessageService(didOrServiceRef: string, serviceEndpoint: string, options?: AnpMessageServiceOptions): ServiceRecord;
|
|
211
|
+
declare function createDidWbaDocument(hostname: string, options?: DidDocumentOptions): DidDocumentBundle;
|
|
212
|
+
declare function createDidWbaDocumentWithKeyBinding(hostname: string, options?: DidDocumentOptions): DidDocumentBundle;
|
|
213
|
+
declare function computeJwkFingerprint(publicKeyInput: PublicKeyInput): string;
|
|
214
|
+
declare function computeMultikeyFingerprint(publicKeyInput: PublicKeyInput): string;
|
|
215
|
+
declare function verifyDidKeyBinding(did: string, bindingMaterial: VerificationMethodRecord | PublicKeyMaterial | string): boolean;
|
|
216
|
+
declare function validateDidDocumentBinding(didDocument: DidDocument, verifyProof?: boolean): boolean;
|
|
217
|
+
declare function generateAuthHeader(didDocument: DidDocument, serviceDomain: string, privateKeyInput: string, version?: string, options?: LegacyAuthOptions): string;
|
|
218
|
+
declare function generateAuthJson(didDocument: DidDocument, serviceDomain: string, privateKeyInput: string, version?: string, options?: LegacyAuthOptions): string;
|
|
219
|
+
declare function extractAuthHeaderParts(authHeader: string): ParsedAuthHeader;
|
|
220
|
+
declare function verifyAuthHeaderSignature(authHeader: string, didDocument: DidDocument, serviceDomain: string): boolean;
|
|
221
|
+
declare function verifyAuthJsonSignature(authJson: string, didDocument: DidDocument, serviceDomain: string): boolean;
|
|
222
|
+
declare function findVerificationMethod(didDocument: DidDocument, verificationMethodId: string): VerificationMethodRecord | undefined;
|
|
223
|
+
declare function isAuthenticationAuthorized(didDocument: DidDocument, verificationMethodId: string): boolean;
|
|
224
|
+
declare function isAssertionMethodAuthorized(didDocument: DidDocument, verificationMethodId: string): boolean;
|
|
225
|
+
|
|
226
|
+
declare function resolveDidDocument(did: string, verifyProof?: boolean, options?: DidResolutionOptions): Promise<DidDocument>;
|
|
227
|
+
|
|
228
|
+
declare function buildContentDigest(body: Uint8Array | string): string;
|
|
229
|
+
declare function verifyContentDigest(body: Uint8Array | string, contentDigest: string): boolean;
|
|
230
|
+
declare function generateHttpSignatureHeaders(didDocument: DidDocument, requestUrl: string, requestMethod: string, privateKeyInput: PrivateKeyInput, headers?: Record<string, string>, body?: Uint8Array | string, options?: HttpSignatureOptions): Record<string, string>;
|
|
231
|
+
declare function extractSignatureMetadata(headers: Record<string, string>): SignatureMetadata;
|
|
232
|
+
declare function verifyHttpMessageSignature(didDocument: DidDocument, requestMethod: string, requestUrl: string, headers: Record<string, string>, body?: Uint8Array | string): SignatureMetadata;
|
|
233
|
+
|
|
234
|
+
declare class DIDWbaAuthHeader {
|
|
235
|
+
private readonly didDocumentPath;
|
|
236
|
+
private readonly privateKeyPath;
|
|
237
|
+
private readonly authMode;
|
|
238
|
+
private didDocumentCache?;
|
|
239
|
+
private readonly tokens;
|
|
240
|
+
constructor(didDocumentPath: string, privateKeyPath: string, authMode?: AuthMode);
|
|
241
|
+
getAuthHeaders(serverUrl: string, forceNew?: boolean, method?: string, headers?: Record<string, string>, body?: Uint8Array | string): Promise<Record<string, string>>;
|
|
242
|
+
getAuthHeader(serverUrl: string, forceNew?: boolean, method?: string, headers?: Record<string, string>, body?: Uint8Array | string): Promise<Record<string, string>>;
|
|
243
|
+
updateToken(serverUrl: string, headers: Record<string, string>): string | undefined;
|
|
244
|
+
clearToken(serverUrl: string): void;
|
|
245
|
+
clearAllTokens(): void;
|
|
246
|
+
shouldRetryAfter401(responseHeaders: Record<string, string>): boolean;
|
|
247
|
+
getChallengeAuthHeaders(serverUrl: string, responseHeaders: Record<string, string>, method?: string, headers?: Record<string, string>, body?: Uint8Array | string): Promise<Record<string, string>>;
|
|
248
|
+
getChallengeAuthHeader(serverUrl: string, responseHeaders: Record<string, string>, method?: string, headers?: Record<string, string>, body?: Uint8Array | string): Promise<Record<string, string>>;
|
|
249
|
+
private loadDidDocument;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
interface DidWbaVerifierConfig {
|
|
253
|
+
jwtPrivateKey?: string;
|
|
254
|
+
jwtPublicKey?: string;
|
|
255
|
+
jwtAlgorithm?: string;
|
|
256
|
+
accessTokenExpireMinutes?: number;
|
|
257
|
+
nonceExpirationMinutes?: number;
|
|
258
|
+
timestampExpirationMinutes?: number;
|
|
259
|
+
allowedDomains?: string[];
|
|
260
|
+
allowHttpSignatures?: boolean;
|
|
261
|
+
allowLegacyDidwba?: boolean;
|
|
262
|
+
emitAuthenticationInfoHeader?: boolean;
|
|
263
|
+
emitLegacyAuthorizationHeader?: boolean;
|
|
264
|
+
requireNonceForHttpSignatures?: boolean;
|
|
265
|
+
didResolutionOptions?: DidResolutionOptions;
|
|
266
|
+
didResolver?: DidResolver;
|
|
267
|
+
externalNonceValidator?: (did: string, nonce: string) => boolean | Promise<boolean>;
|
|
268
|
+
}
|
|
269
|
+
interface VerificationSuccess {
|
|
270
|
+
did: string;
|
|
271
|
+
authScheme: string;
|
|
272
|
+
responseHeaders: Record<string, string>;
|
|
273
|
+
accessToken?: string;
|
|
274
|
+
tokenType?: 'bearer';
|
|
275
|
+
}
|
|
276
|
+
declare class DidWbaVerifierError extends Error {
|
|
277
|
+
readonly statusCode: number;
|
|
278
|
+
readonly headers: Record<string, string>;
|
|
279
|
+
constructor(message: string, statusCode?: number, headers?: Record<string, string>);
|
|
280
|
+
}
|
|
281
|
+
declare class DidWbaVerifier {
|
|
282
|
+
private readonly config;
|
|
283
|
+
private readonly usedNonces;
|
|
284
|
+
constructor(config?: DidWbaVerifierConfig);
|
|
285
|
+
verifyRequest(method: string, url: string, headers: Record<string, string>, body?: Uint8Array | string | null, domain?: string): Promise<VerificationSuccess>;
|
|
286
|
+
verifyRequestWithDidDocument(method: string, url: string, headers: Record<string, string>, didDocument: DidDocument, body?: Uint8Array | string | null, domain?: string): Promise<VerificationSuccess>;
|
|
287
|
+
private verifyRequestWithOptionalDidDocument;
|
|
288
|
+
private handleHttpSignatureAuth;
|
|
289
|
+
private handleLegacyDidAuth;
|
|
290
|
+
private handleBearerAuth;
|
|
291
|
+
private createAccessToken;
|
|
292
|
+
private buildSuccessResult;
|
|
293
|
+
private verifyLegacyTimestamp;
|
|
294
|
+
private verifyHttpSignatureTimeWindow;
|
|
295
|
+
private isValidServerNonce;
|
|
296
|
+
private resolveDidDocument;
|
|
297
|
+
private validateAllowedDomain;
|
|
298
|
+
private challengeError;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
declare function verifyFederatedHttpRequest(senderDid: string, requestMethod: string, requestUrl: string, headers: Record<string, string>, body?: Uint8Array | string, options?: FederatedVerificationOptions): Promise<FederatedVerificationResult>;
|
|
302
|
+
|
|
303
|
+
declare const didDocuments: {
|
|
304
|
+
ANP_MESSAGE_SERVICE_TYPE: string;
|
|
305
|
+
buildAnpMessageService: typeof buildAnpMessageService;
|
|
306
|
+
buildAgentMessageService: typeof buildAgentMessageService;
|
|
307
|
+
buildGroupMessageService: typeof buildGroupMessageService;
|
|
308
|
+
create: typeof createDidWbaDocument;
|
|
309
|
+
createWithKeyBinding: typeof createDidWbaDocumentWithKeyBinding;
|
|
310
|
+
resolve: typeof resolveDidDocument;
|
|
311
|
+
validateBinding: typeof validateDidDocumentBinding;
|
|
312
|
+
verifyKeyBinding: typeof verifyDidKeyBinding;
|
|
313
|
+
};
|
|
314
|
+
declare const legacyAuth: {
|
|
315
|
+
createHeader: typeof generateAuthHeader;
|
|
316
|
+
createPayload: typeof generateAuthJson;
|
|
317
|
+
parseHeader: typeof extractAuthHeaderParts;
|
|
318
|
+
verifyHeader: typeof verifyAuthHeaderSignature;
|
|
319
|
+
verifyPayload: typeof verifyAuthJsonSignature;
|
|
320
|
+
};
|
|
321
|
+
declare const httpSignatures: {
|
|
322
|
+
buildContentDigest: typeof buildContentDigest;
|
|
323
|
+
verifyContentDigest: typeof verifyContentDigest;
|
|
324
|
+
createHeaders: typeof generateHttpSignatureHeaders;
|
|
325
|
+
verifyMessage: typeof verifyHttpMessageSignature;
|
|
326
|
+
parseMetadata: typeof extractSignatureMetadata;
|
|
327
|
+
};
|
|
328
|
+
declare const authentication: {
|
|
329
|
+
didDocuments: {
|
|
330
|
+
ANP_MESSAGE_SERVICE_TYPE: string;
|
|
331
|
+
buildAnpMessageService: typeof buildAnpMessageService;
|
|
332
|
+
buildAgentMessageService: typeof buildAgentMessageService;
|
|
333
|
+
buildGroupMessageService: typeof buildGroupMessageService;
|
|
334
|
+
create: typeof createDidWbaDocument;
|
|
335
|
+
createWithKeyBinding: typeof createDidWbaDocumentWithKeyBinding;
|
|
336
|
+
resolve: typeof resolveDidDocument;
|
|
337
|
+
validateBinding: typeof validateDidDocumentBinding;
|
|
338
|
+
verifyKeyBinding: typeof verifyDidKeyBinding;
|
|
339
|
+
};
|
|
340
|
+
legacyAuth: {
|
|
341
|
+
createHeader: typeof generateAuthHeader;
|
|
342
|
+
createPayload: typeof generateAuthJson;
|
|
343
|
+
parseHeader: typeof extractAuthHeaderParts;
|
|
344
|
+
verifyHeader: typeof verifyAuthHeaderSignature;
|
|
345
|
+
verifyPayload: typeof verifyAuthJsonSignature;
|
|
346
|
+
};
|
|
347
|
+
httpSignatures: {
|
|
348
|
+
buildContentDigest: typeof buildContentDigest;
|
|
349
|
+
verifyContentDigest: typeof verifyContentDigest;
|
|
350
|
+
createHeaders: typeof generateHttpSignatureHeaders;
|
|
351
|
+
verifyMessage: typeof verifyHttpMessageSignature;
|
|
352
|
+
parseMetadata: typeof extractSignatureMetadata;
|
|
353
|
+
};
|
|
354
|
+
federation: {
|
|
355
|
+
verifyRequest: typeof verifyFederatedHttpRequest;
|
|
356
|
+
};
|
|
357
|
+
DidAuthHeaders: typeof DIDWbaAuthHeader;
|
|
358
|
+
RequestVerifier: typeof DidWbaVerifier;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
declare const PROOF_TYPE_SECP256K1 = "EcdsaSecp256k1Signature2019";
|
|
362
|
+
declare const PROOF_TYPE_ED25519 = "Ed25519Signature2020";
|
|
363
|
+
declare const PROOF_TYPE_DATA_INTEGRITY = "DataIntegrityProof";
|
|
364
|
+
declare const CRYPTOSUITE_EDDSA_JCS_2022 = "eddsa-jcs-2022";
|
|
365
|
+
declare const CRYPTOSUITE_DIDWBA_SECP256K1_2025 = "didwba-jcs-ecdsa-secp256k1-2025";
|
|
366
|
+
interface ProofGenerationOptions {
|
|
367
|
+
proofPurpose?: string;
|
|
368
|
+
proofType?: string;
|
|
369
|
+
cryptosuite?: string;
|
|
370
|
+
created?: string;
|
|
371
|
+
domain?: string;
|
|
372
|
+
challenge?: string;
|
|
373
|
+
}
|
|
374
|
+
interface ProofVerificationOptions {
|
|
375
|
+
expectedPurpose?: string;
|
|
376
|
+
expectedDomain?: string;
|
|
377
|
+
expectedChallenge?: string;
|
|
378
|
+
}
|
|
379
|
+
interface ProofObject {
|
|
380
|
+
type: string;
|
|
381
|
+
created: string;
|
|
382
|
+
verificationMethod: string;
|
|
383
|
+
proofPurpose: string;
|
|
384
|
+
proofValue: string;
|
|
385
|
+
cryptosuite?: string;
|
|
386
|
+
domain?: string;
|
|
387
|
+
challenge?: string;
|
|
388
|
+
}
|
|
389
|
+
declare function generateW3cProof<T extends object>(document: T, privateKeyInput: PrivateKeyInput, verificationMethod: string, options?: ProofGenerationOptions): T & {
|
|
390
|
+
proof: ProofObject;
|
|
391
|
+
};
|
|
392
|
+
declare function verifyW3cProof(document: object, publicKeyInput: PublicKeyInput, options?: ProofVerificationOptions): boolean;
|
|
393
|
+
declare function verifyW3cProofDetailed(document: object, publicKeyInput: PublicKeyInput, options?: ProofVerificationOptions): void;
|
|
394
|
+
|
|
395
|
+
declare const IM_PROOF_DEFAULT_COMPONENTS: readonly ["@method", "@target-uri", "content-digest"];
|
|
396
|
+
declare const IM_PROOF_RELATION_AUTHENTICATION: "authentication";
|
|
397
|
+
declare const IM_PROOF_RELATION_ASSERTION_METHOD: "assertionMethod";
|
|
398
|
+
type ImProofVerificationRelationship = typeof IM_PROOF_RELATION_AUTHENTICATION | typeof IM_PROOF_RELATION_ASSERTION_METHOD;
|
|
399
|
+
interface ImProof {
|
|
400
|
+
contentDigest: string;
|
|
401
|
+
signatureInput: string;
|
|
402
|
+
signature: string;
|
|
403
|
+
}
|
|
404
|
+
interface ParsedImSignatureInput {
|
|
405
|
+
label: string;
|
|
406
|
+
components: string[];
|
|
407
|
+
signatureParams: string;
|
|
408
|
+
keyid: string;
|
|
409
|
+
nonce?: string;
|
|
410
|
+
created?: number;
|
|
411
|
+
expires?: number;
|
|
412
|
+
}
|
|
413
|
+
interface ImProofGenerationOptions {
|
|
414
|
+
label?: string;
|
|
415
|
+
components?: string[];
|
|
416
|
+
created?: number;
|
|
417
|
+
expires?: number;
|
|
418
|
+
nonce?: string;
|
|
419
|
+
}
|
|
420
|
+
interface ImProofVerificationResult {
|
|
421
|
+
parsedSignatureInput: ParsedImSignatureInput;
|
|
422
|
+
verificationMethod: VerificationMethodRecord;
|
|
423
|
+
}
|
|
424
|
+
interface ImProofVerificationTarget {
|
|
425
|
+
didDocument?: DidDocument;
|
|
426
|
+
verificationMethod?: VerificationMethodRecord;
|
|
427
|
+
verificationRelationship?: ImProofVerificationRelationship;
|
|
428
|
+
}
|
|
429
|
+
declare function buildImContentDigest(payload: Uint8Array | string): string;
|
|
430
|
+
declare function verifyImContentDigest(payload: Uint8Array | string, contentDigest: string): boolean;
|
|
431
|
+
declare function buildImSignatureInput(keyid: string, options?: ImProofGenerationOptions): string;
|
|
432
|
+
declare function parseImSignatureInput(value: string): ParsedImSignatureInput;
|
|
433
|
+
declare function encodeImSignature(signatureBytes: Uint8Array, label?: string): string;
|
|
434
|
+
declare function decodeImSignature(signature: string): {
|
|
435
|
+
label?: string;
|
|
436
|
+
signatureBytes: Uint8Array;
|
|
437
|
+
};
|
|
438
|
+
declare function generateImProof(payload: Uint8Array | string, signatureBase: Uint8Array | string, privateKeyInput: PrivateKeyInput, keyid: string, options?: ImProofGenerationOptions): ImProof;
|
|
439
|
+
declare function verifyImProof(proof: ImProof, payload: Uint8Array | string, signatureBase: Uint8Array | string, verificationTarget: ImProofVerificationTarget, expectedSignerDid?: string): ImProofVerificationResult;
|
|
440
|
+
|
|
441
|
+
declare const imProof_IM_PROOF_DEFAULT_COMPONENTS: typeof IM_PROOF_DEFAULT_COMPONENTS;
|
|
442
|
+
declare const imProof_IM_PROOF_RELATION_ASSERTION_METHOD: typeof IM_PROOF_RELATION_ASSERTION_METHOD;
|
|
443
|
+
declare const imProof_IM_PROOF_RELATION_AUTHENTICATION: typeof IM_PROOF_RELATION_AUTHENTICATION;
|
|
444
|
+
type imProof_ImProof = ImProof;
|
|
445
|
+
type imProof_ImProofGenerationOptions = ImProofGenerationOptions;
|
|
446
|
+
type imProof_ImProofVerificationRelationship = ImProofVerificationRelationship;
|
|
447
|
+
type imProof_ImProofVerificationResult = ImProofVerificationResult;
|
|
448
|
+
type imProof_ImProofVerificationTarget = ImProofVerificationTarget;
|
|
449
|
+
type imProof_ParsedImSignatureInput = ParsedImSignatureInput;
|
|
450
|
+
declare const imProof_buildImContentDigest: typeof buildImContentDigest;
|
|
451
|
+
declare const imProof_buildImSignatureInput: typeof buildImSignatureInput;
|
|
452
|
+
declare const imProof_decodeImSignature: typeof decodeImSignature;
|
|
453
|
+
declare const imProof_encodeImSignature: typeof encodeImSignature;
|
|
454
|
+
declare const imProof_generateImProof: typeof generateImProof;
|
|
455
|
+
declare const imProof_parseImSignatureInput: typeof parseImSignatureInput;
|
|
456
|
+
declare const imProof_verifyImContentDigest: typeof verifyImContentDigest;
|
|
457
|
+
declare const imProof_verifyImProof: typeof verifyImProof;
|
|
458
|
+
declare namespace imProof {
|
|
459
|
+
export { imProof_IM_PROOF_DEFAULT_COMPONENTS as IM_PROOF_DEFAULT_COMPONENTS, imProof_IM_PROOF_RELATION_ASSERTION_METHOD as IM_PROOF_RELATION_ASSERTION_METHOD, imProof_IM_PROOF_RELATION_AUTHENTICATION as IM_PROOF_RELATION_AUTHENTICATION, type imProof_ImProof as ImProof, type imProof_ImProofGenerationOptions as ImProofGenerationOptions, type imProof_ImProofVerificationRelationship as ImProofVerificationRelationship, type imProof_ImProofVerificationResult as ImProofVerificationResult, type imProof_ImProofVerificationTarget as ImProofVerificationTarget, type imProof_ParsedImSignatureInput as ParsedImSignatureInput, imProof_buildImContentDigest as buildImContentDigest, imProof_buildImSignatureInput as buildImSignatureInput, imProof_decodeImSignature as decodeImSignature, imProof_encodeImSignature as encodeImSignature, imProof_generateImProof as generateImProof, imProof_parseImSignatureInput as parseImSignatureInput, imProof_verifyImContentDigest as verifyImContentDigest, imProof_verifyImProof as verifyImProof };
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
declare const proof: {
|
|
463
|
+
create: typeof generateW3cProof;
|
|
464
|
+
verify: typeof verifyW3cProof;
|
|
465
|
+
verifyDetailed: typeof verifyW3cProofDetailed;
|
|
466
|
+
im: typeof imProof;
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
type BindingGeneration = string & {
|
|
470
|
+
readonly __bindingGeneration: unique symbol;
|
|
471
|
+
};
|
|
472
|
+
declare function canonicalizeBindingGeneration(value: unknown): BindingGeneration;
|
|
473
|
+
declare function compareBindingGenerations(current: BindingGeneration | string, previous: BindingGeneration | string): number;
|
|
474
|
+
|
|
475
|
+
declare const ANP_HANDLE_SERVICE_TYPE = "ANPHandleService";
|
|
476
|
+
declare enum HandleStatus {
|
|
477
|
+
Active = "active",
|
|
478
|
+
Suspended = "suspended",
|
|
479
|
+
Revoked = "revoked"
|
|
480
|
+
}
|
|
481
|
+
declare enum SubjectType {
|
|
482
|
+
Person = "person",
|
|
483
|
+
Agent = "agent",
|
|
484
|
+
Group = "group",
|
|
485
|
+
Organization = "organization",
|
|
486
|
+
Service = "service",
|
|
487
|
+
Application = "application",
|
|
488
|
+
Unknown = "unknown"
|
|
489
|
+
}
|
|
490
|
+
interface DIDSubjectProfile {
|
|
491
|
+
type?: string;
|
|
492
|
+
subject_did: string;
|
|
493
|
+
subject_type?: SubjectType;
|
|
494
|
+
handle?: string;
|
|
495
|
+
display_name?: string;
|
|
496
|
+
description?: string;
|
|
497
|
+
avatar_uri?: string;
|
|
498
|
+
profile_uri?: string;
|
|
499
|
+
discoverability?: string;
|
|
500
|
+
labels?: Record<string, unknown>;
|
|
501
|
+
updated?: string;
|
|
502
|
+
versionId?: string;
|
|
503
|
+
ttl?: number;
|
|
504
|
+
proof?: Record<string, unknown>;
|
|
505
|
+
}
|
|
506
|
+
interface HandleResolutionDocument {
|
|
507
|
+
handle: string;
|
|
508
|
+
did: string;
|
|
509
|
+
status: HandleStatus;
|
|
510
|
+
binding_generation: BindingGeneration;
|
|
511
|
+
updated?: string;
|
|
512
|
+
versionId?: string;
|
|
513
|
+
ttl?: number;
|
|
514
|
+
profile?: DIDSubjectProfile;
|
|
515
|
+
}
|
|
516
|
+
interface HandleServiceEntry {
|
|
517
|
+
id: string;
|
|
518
|
+
type: string;
|
|
519
|
+
serviceEndpoint: string;
|
|
520
|
+
}
|
|
521
|
+
interface ParsedWbaUri {
|
|
522
|
+
localPart: string;
|
|
523
|
+
domain: string;
|
|
524
|
+
handle: string;
|
|
525
|
+
originalUri: string;
|
|
526
|
+
}
|
|
527
|
+
interface ResolveHandleOptions {
|
|
528
|
+
timeoutSeconds?: number;
|
|
529
|
+
verifySsl?: boolean;
|
|
530
|
+
baseUrlOverride?: string;
|
|
531
|
+
}
|
|
532
|
+
interface BindingVerificationOptions {
|
|
533
|
+
didDocument?: DidDocument;
|
|
534
|
+
resolutionOptions?: ResolveHandleOptions;
|
|
535
|
+
didResolutionOptions?: DidResolutionOptions;
|
|
536
|
+
}
|
|
537
|
+
interface BindingVerificationResult {
|
|
538
|
+
isValid: boolean;
|
|
539
|
+
handle: string;
|
|
540
|
+
did: string;
|
|
541
|
+
bindingGeneration?: BindingGeneration;
|
|
542
|
+
forwardVerified: boolean;
|
|
543
|
+
reverseVerified: boolean;
|
|
544
|
+
errorMessage?: string;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
declare function validateLocalPart(localPart: string): boolean;
|
|
548
|
+
declare function validateHandle(handle: string): [string, string];
|
|
549
|
+
declare function normalizeHandle(handle: string): string;
|
|
550
|
+
declare function parseWbaUri(uri: string): ParsedWbaUri;
|
|
551
|
+
declare function buildResolutionUrl(localPart: string, domain: string): string;
|
|
552
|
+
declare function buildWbaUri(localPart: string, domain: string): string;
|
|
553
|
+
|
|
554
|
+
declare function resolveHandle(handle: string, options?: ResolveHandleOptions): Promise<HandleResolutionDocument>;
|
|
555
|
+
declare function resolveHandleFromUri(wbaUri: string, options?: ResolveHandleOptions): Promise<HandleResolutionDocument>;
|
|
556
|
+
|
|
557
|
+
declare function verifyHandleBinding(handle: string, options?: BindingVerificationOptions): Promise<BindingVerificationResult>;
|
|
558
|
+
declare function buildHandleServiceEntry(did: string, localPart: string, domain: string): HandleServiceEntry;
|
|
559
|
+
declare function extractHandleServiceFromDidDocument(didDocument: DidDocument): HandleServiceEntry[];
|
|
560
|
+
|
|
561
|
+
declare const wns: {
|
|
562
|
+
validateLocalPart: typeof validateLocalPart;
|
|
563
|
+
validateHandle: typeof validateHandle;
|
|
564
|
+
normalizeHandle: typeof normalizeHandle;
|
|
565
|
+
parseUri: typeof parseWbaUri;
|
|
566
|
+
buildResolutionUrl: typeof buildResolutionUrl;
|
|
567
|
+
buildUri: typeof buildWbaUri;
|
|
568
|
+
resolveHandle: typeof resolveHandle;
|
|
569
|
+
resolveUri: typeof resolveHandleFromUri;
|
|
570
|
+
verifyBinding: typeof verifyHandleBinding;
|
|
571
|
+
createHandleServiceEntry: typeof buildHandleServiceEntry;
|
|
572
|
+
extractHandleServices: typeof extractHandleServiceFromDidDocument;
|
|
573
|
+
canonicalizeBindingGeneration: typeof canonicalizeBindingGeneration;
|
|
574
|
+
compareBindingGenerations: typeof compareBindingGenerations;
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
/** Public, high-level AWiki IM client types. */
|
|
578
|
+
declare const AWIKI_IM_ID: unique symbol;
|
|
579
|
+
/** String identifier that remains nominally distinct across IM domains. */
|
|
580
|
+
type AwikiImId<Kind extends string> = string & {
|
|
581
|
+
readonly [AWIKI_IM_ID]: Kind;
|
|
582
|
+
};
|
|
583
|
+
/** Stable AWiki decentralized identifier. */
|
|
584
|
+
type AwikiDid = AwikiImId<'did'>;
|
|
585
|
+
/** Validated AWiki handle. */
|
|
586
|
+
type AwikiHandle = AwikiImId<'handle'>;
|
|
587
|
+
/** Stable conversation identifier. */
|
|
588
|
+
type AwikiConversationId = AwikiImId<'conversation'>;
|
|
589
|
+
/** Stable message identifier. */
|
|
590
|
+
type AwikiMessageId = AwikiImId<'message'>;
|
|
591
|
+
/** Stable attachment identifier. */
|
|
592
|
+
type AwikiAttachmentId = AwikiImId<'attachment'>;
|
|
593
|
+
/** Opaque pagination cursor returned by AWiki. */
|
|
594
|
+
type AwikiCursor = AwikiImId<'cursor'>;
|
|
595
|
+
/** Persisted identity metadata. Private keys and access tokens are excluded. */
|
|
596
|
+
interface AwikiIdentity {
|
|
597
|
+
readonly handle: AwikiHandle;
|
|
598
|
+
readonly did: AwikiDid;
|
|
599
|
+
readonly registeredAt: number;
|
|
600
|
+
}
|
|
601
|
+
/** Request for one registration verification code. */
|
|
602
|
+
interface SendRegistrationOtpRequest {
|
|
603
|
+
readonly handle: string;
|
|
604
|
+
readonly phone: string;
|
|
605
|
+
}
|
|
606
|
+
/** Server-issued registration challenge metadata. */
|
|
607
|
+
interface SendRegistrationOtpResult {
|
|
608
|
+
readonly retryAfterSeconds: number;
|
|
609
|
+
readonly retryAt: string;
|
|
610
|
+
}
|
|
611
|
+
/** Complete a new identity registration from a verified phone challenge. */
|
|
612
|
+
interface RegisterIdentityRequest {
|
|
613
|
+
readonly handle: string;
|
|
614
|
+
readonly phone: string;
|
|
615
|
+
readonly otp: string;
|
|
616
|
+
}
|
|
617
|
+
/** Existing direct-message conversation. */
|
|
618
|
+
interface AwikiDirectConversation {
|
|
619
|
+
readonly kind: 'direct';
|
|
620
|
+
readonly id: AwikiConversationId;
|
|
621
|
+
readonly peerDid: AwikiDid;
|
|
622
|
+
readonly peerHandle?: AwikiHandle;
|
|
623
|
+
readonly title: string;
|
|
624
|
+
readonly lastMessageAt?: number;
|
|
625
|
+
}
|
|
626
|
+
/** Existing group conversation. */
|
|
627
|
+
interface AwikiGroupConversation {
|
|
628
|
+
readonly kind: 'group';
|
|
629
|
+
readonly id: AwikiConversationId;
|
|
630
|
+
readonly groupDid: AwikiDid;
|
|
631
|
+
readonly title: string;
|
|
632
|
+
readonly lastMessageAt?: number;
|
|
633
|
+
}
|
|
634
|
+
/** Conversation visible to the registered identity. */
|
|
635
|
+
type AwikiConversation = AwikiDirectConversation | AwikiGroupConversation;
|
|
636
|
+
/** Direct-message destination resolved by handle or DID. */
|
|
637
|
+
interface AwikiDirectTarget {
|
|
638
|
+
readonly kind: 'direct';
|
|
639
|
+
readonly peer: string;
|
|
640
|
+
}
|
|
641
|
+
/** Existing group destination. Group creation is outside this API. */
|
|
642
|
+
interface AwikiGroupTarget {
|
|
643
|
+
readonly kind: 'group';
|
|
644
|
+
readonly group: string;
|
|
645
|
+
}
|
|
646
|
+
/** Destination accepted by text and attachment sends. */
|
|
647
|
+
type AwikiMessageTarget = AwikiDirectTarget | AwikiGroupTarget;
|
|
648
|
+
/** Attachment metadata safe to expose to an IM SDK consumer. */
|
|
649
|
+
interface AwikiAttachment {
|
|
650
|
+
readonly id: AwikiAttachmentId;
|
|
651
|
+
readonly fileName: string;
|
|
652
|
+
readonly mimeType: string;
|
|
653
|
+
readonly size: number;
|
|
654
|
+
readonly sha256: string;
|
|
655
|
+
}
|
|
656
|
+
/** Plain text message content. */
|
|
657
|
+
interface AwikiTextContent {
|
|
658
|
+
readonly kind: 'text';
|
|
659
|
+
readonly text: string;
|
|
660
|
+
}
|
|
661
|
+
/** Attachment message content. */
|
|
662
|
+
interface AwikiAttachmentContent {
|
|
663
|
+
readonly kind: 'attachment';
|
|
664
|
+
readonly attachment: AwikiAttachment;
|
|
665
|
+
readonly caption?: string;
|
|
666
|
+
}
|
|
667
|
+
/** Content types supported by the first AWiki Harness integration. */
|
|
668
|
+
type AwikiMessageContent = AwikiTextContent | AwikiAttachmentContent;
|
|
669
|
+
/** One direct or group message. */
|
|
670
|
+
interface AwikiMessage {
|
|
671
|
+
readonly id: AwikiMessageId;
|
|
672
|
+
readonly conversationId: AwikiConversationId;
|
|
673
|
+
readonly conversationKind: AwikiConversation['kind'];
|
|
674
|
+
readonly senderDid: AwikiDid;
|
|
675
|
+
readonly senderHandle?: AwikiHandle;
|
|
676
|
+
readonly sentAt: number;
|
|
677
|
+
readonly outgoing: boolean;
|
|
678
|
+
readonly content: AwikiMessageContent;
|
|
679
|
+
}
|
|
680
|
+
/** One immutable page from an AWiki collection. */
|
|
681
|
+
interface AwikiPage<Item> {
|
|
682
|
+
readonly items: readonly Item[];
|
|
683
|
+
readonly nextCursor?: AwikiCursor;
|
|
684
|
+
readonly hasMore: boolean;
|
|
685
|
+
}
|
|
686
|
+
/** Common cursor request for conversation and history reads. */
|
|
687
|
+
interface AwikiPageRequest {
|
|
688
|
+
readonly cursor?: AwikiCursor;
|
|
689
|
+
readonly limit?: number;
|
|
690
|
+
}
|
|
691
|
+
/** Request for one conversation's message history. */
|
|
692
|
+
interface GetAwikiHistoryRequest extends AwikiPageRequest {
|
|
693
|
+
readonly conversationId: AwikiConversationId;
|
|
694
|
+
}
|
|
695
|
+
/** Send one plain text message. */
|
|
696
|
+
interface SendAwikiTextRequest {
|
|
697
|
+
readonly target: AwikiMessageTarget;
|
|
698
|
+
readonly text: string;
|
|
699
|
+
readonly idempotencyKey: string;
|
|
700
|
+
}
|
|
701
|
+
/** Bytes and public metadata for one attachment upload. */
|
|
702
|
+
interface AwikiUpload {
|
|
703
|
+
readonly fileName: string;
|
|
704
|
+
readonly mimeType: string;
|
|
705
|
+
readonly bytes: Uint8Array;
|
|
706
|
+
}
|
|
707
|
+
/** Upload and send one attachment message. */
|
|
708
|
+
interface SendAwikiAttachmentRequest {
|
|
709
|
+
readonly target: AwikiMessageTarget;
|
|
710
|
+
readonly attachment: AwikiUpload;
|
|
711
|
+
readonly caption?: string;
|
|
712
|
+
readonly idempotencyKey: string;
|
|
713
|
+
}
|
|
714
|
+
/** Download request for one attachment visible to the current identity. */
|
|
715
|
+
interface DownloadAwikiAttachmentRequest {
|
|
716
|
+
readonly attachmentId: AwikiAttachmentId;
|
|
717
|
+
readonly messageId: AwikiMessageId;
|
|
718
|
+
}
|
|
719
|
+
/** Verified attachment bytes and public metadata. */
|
|
720
|
+
interface DownloadedAwikiAttachment {
|
|
721
|
+
readonly attachment: AwikiAttachment;
|
|
722
|
+
readonly bytes: Uint8Array;
|
|
723
|
+
}
|
|
724
|
+
/** Stable public error categories normalized from AWiki services. */
|
|
725
|
+
type AwikiImErrorCode = 'not-registered' | 'already-registered' | 'invalid-request' | 'invalid-otp' | 'challenge-expired' | 'handle-unavailable' | 'not-found' | 'forbidden' | 'conflict' | 'rate-limited' | 'network' | 'remote';
|
|
726
|
+
/** Options for the Node.js AWiki IM client. */
|
|
727
|
+
interface AwikiImClientOptions {
|
|
728
|
+
readonly userServiceUrl: string;
|
|
729
|
+
/** Handle domain administered by the User Service; it need not equal the service URL host. */
|
|
730
|
+
readonly userServiceDomain: string;
|
|
731
|
+
readonly messageServiceUrl: string;
|
|
732
|
+
/** Public Message Service base URL advertised in the identity DID document. */
|
|
733
|
+
readonly messageServicePublicUrl: string;
|
|
734
|
+
/** Authoritative Home Message Service DID advertised in the registered DID document. */
|
|
735
|
+
readonly messageServiceDid: string;
|
|
736
|
+
/** Exact HTTPS origins permitted for DID discovery, attachment service endpoints, and objects. */
|
|
737
|
+
readonly allowedAttachmentOrigins: readonly string[];
|
|
738
|
+
/** Maximum attachment size accepted for both upload and download. */
|
|
739
|
+
readonly attachmentMaxBytes: number;
|
|
740
|
+
/** Permit HTTP loopback URLs only in an explicitly controlled test environment. */
|
|
741
|
+
readonly allowInsecureLoopbackForTesting?: boolean;
|
|
742
|
+
readonly statePath: string;
|
|
743
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* High-level AWiki IM API. Implementations own credentials, request signing,
|
|
747
|
+
* handle resolution, pagination, idempotency, attachment transfer, and
|
|
748
|
+
* persistent identity state.
|
|
749
|
+
*/
|
|
750
|
+
interface AwikiImClient {
|
|
751
|
+
/** Return the persisted default identity without exposing secret material. */
|
|
752
|
+
getIdentity(): Promise<AwikiIdentity | null>;
|
|
753
|
+
/** Send one phone verification code for registration. */
|
|
754
|
+
sendRegistrationOtp(request: SendRegistrationOtpRequest): Promise<SendRegistrationOtpResult>;
|
|
755
|
+
/** Register and persist the deployment's only identity. */
|
|
756
|
+
registerIdentity(request: RegisterIdentityRequest): Promise<AwikiIdentity>;
|
|
757
|
+
/** List direct and existing group conversations. */
|
|
758
|
+
listConversations(request?: AwikiPageRequest): Promise<AwikiPage<AwikiConversation>>;
|
|
759
|
+
/** Read one conversation's paginated history. */
|
|
760
|
+
getHistory(request: GetAwikiHistoryRequest): Promise<AwikiPage<AwikiMessage>>;
|
|
761
|
+
/** Send one idempotent text message. */
|
|
762
|
+
sendText(request: SendAwikiTextRequest): Promise<AwikiMessage>;
|
|
763
|
+
/** Upload and send one idempotent attachment message. */
|
|
764
|
+
sendAttachment(request: SendAwikiAttachmentRequest): Promise<AwikiMessage>;
|
|
765
|
+
/** Download and verify one attachment before returning its bytes. */
|
|
766
|
+
downloadAttachment(request: DownloadAwikiAttachmentRequest): Promise<DownloadedAwikiAttachment>;
|
|
767
|
+
/** Stop background work and release owned resources. */
|
|
768
|
+
dispose(): Promise<void>;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/** Create one high-level Node.js AWiki IM client. */
|
|
772
|
+
declare function createAwikiImClient(options: AwikiImClientOptions): AwikiImClient;
|
|
773
|
+
|
|
774
|
+
/** A stable AWiki IM failure that does not expose credentials or private protocol fields. */
|
|
775
|
+
declare class AwikiImError extends Error {
|
|
776
|
+
readonly code: AwikiImErrorCode;
|
|
777
|
+
readonly status?: number | undefined;
|
|
778
|
+
/**
|
|
779
|
+
* Create a normalized AWiki IM error.
|
|
780
|
+
*
|
|
781
|
+
* @param code Stable category for callers.
|
|
782
|
+
* @param message Public diagnostic message.
|
|
783
|
+
* @param options Optional transport status and underlying cause.
|
|
784
|
+
*/
|
|
785
|
+
constructor(code: AwikiImErrorCode, message: string, status?: number | undefined, options?: {
|
|
786
|
+
cause?: unknown;
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
export { ANPError, ANP_HANDLE_SERVICE_TYPE, ANP_MESSAGE_SERVICE_TYPE, type AnpMessageServiceOptions, AuthMode, AuthenticationError, type AwikiAttachment, type AwikiAttachmentContent, type AwikiAttachmentId, type AwikiConversation, type AwikiConversationId, type AwikiCursor, type AwikiDid, type AwikiDirectConversation, type AwikiDirectTarget, type AwikiGroupConversation, type AwikiGroupTarget, type AwikiHandle, type AwikiIdentity, type AwikiImClient, type AwikiImClientOptions, AwikiImError, type AwikiImErrorCode, type AwikiImId, type AwikiMessage, type AwikiMessageContent, type AwikiMessageId, type AwikiMessageTarget, type AwikiPage, type AwikiPageRequest, type AwikiTextContent, type AwikiUpload, type BindingGeneration, type BindingVerificationOptions, type BindingVerificationResult, CRYPTOSUITE_DIDWBA_SECP256K1_2025, CRYPTOSUITE_EDDSA_JCS_2022, CryptoError, type DIDSubjectProfile, DIDWbaAuthHeader, DIDWbaAuthHeader as DidAuthHeaders, type DidDocument, type DidDocumentBundle, type DidDocumentOptions, DidProfile, type DidResolutionOptions, type DidResolver, DidWbaVerifier, type DidWbaVerifierConfig, DidWbaVerifierError, type DownloadAwikiAttachmentRequest, type DownloadedAwikiAttachment, type FederatedVerificationOptions, type FederatedVerificationResult, type GetAwikiHistoryRequest, HandleBindingError, HandleGoneError, HandleMovedError, HandleNotFoundError, type HandleResolutionDocument, HandleResolutionError, type HandleServiceEntry, HandleStatus, HandleValidationError, type HttpSignatureOptions, IM_PROOF_DEFAULT_COMPONENTS, IM_PROOF_RELATION_ASSERTION_METHOD, IM_PROOF_RELATION_AUTHENTICATION, type ImProof, type ImProofGenerationOptions, type ImProofVerificationRelationship, type ImProofVerificationResult, type ImProofVerificationTarget, type LegacyAuthOptions, NetworkError, PROOF_TYPE_DATA_INTEGRITY, PROOF_TYPE_ED25519, PROOF_TYPE_SECP256K1, type ParsedAuthHeader, type ParsedImSignatureInput, type ParsedWbaUri, ProofError, type ProofGenerationOptions, type ProofObject, type ProofRecord, type ProofVerificationOptions, type RegisterIdentityRequest, DidWbaVerifier as RequestVerifier, DidWbaVerifierError as RequestVerifierError, type ResolveHandleOptions, type SendAwikiAttachmentRequest, type SendAwikiTextRequest, type SendRegistrationOtpRequest, type SendRegistrationOtpResult, type ServiceRecord, type SignatureMetadata, SubjectType, VM_KEY_AUTH, VM_KEY_E2EE_AGREEMENT, VM_KEY_E2EE_SIGNING, VerificationMethod, type VerificationMethodRecord, type VerificationSuccess, WbaUriParseError, WnsError, authentication, buildAgentMessageService, buildAnpMessageService, buildContentDigest, buildGroupMessageService, buildHandleServiceEntry, buildImContentDigest, buildImSignatureInput, buildResolutionUrl, buildWbaUri as buildUri, buildWbaUri, canonicalizeBindingGeneration, compareBindingGenerations, computeJwkFingerprint, computeMultikeyFingerprint, createAwikiImClient, createDidWbaDocument as createDidDocument, createDidWbaDocumentWithKeyBinding as createDidDocumentWithKeyBinding, createDidWbaDocument, createDidWbaDocumentWithKeyBinding, buildHandleServiceEntry as createHandleServiceEntry, generateAuthHeader as createLegacyAuthHeader, generateAuthJson as createLegacyAuthPayload, generateW3cProof as createProof, generateHttpSignatureHeaders as createSignatureHeaders, createVerificationMethod, decodeImSignature, didDocuments, encodeImSignature, extractAuthHeaderParts, extractHandleServiceFromDidDocument, extractHandleServiceFromDidDocument as extractHandleServices, extractPublicKey, extractSignatureMetadata, findVerificationMethod, generateAuthHeader, generateAuthJson, generateHttpSignatureHeaders, generateImProof, generateW3cProof, httpSignatures, isAssertionMethodAuthorized, isAuthenticationAuthorized, legacyAuth, normalizeHandle, parseImSignatureInput, extractAuthHeaderParts as parseLegacyAuthHeader, extractSignatureMetadata as parseSignatureMetadata, parseWbaUri as parseUri, parseWbaUri, proof, resolveDidDocument, resolveDidWbaDocument, resolveHandle, resolveHandleFromUri, resolveHandleFromUri as resolveUri, validateDidDocumentBinding as validateDidBinding, validateDidDocumentBinding, validateHandle, validateLocalPart, verifyAuthHeaderSignature, verifyAuthJsonSignature, verifyHandleBinding as verifyBinding, verifyContentDigest, verifyDidKeyBinding as verifyDidBinding, verifyDidKeyBinding, verifyFederatedHttpRequest, verifyHandleBinding, verifyHttpMessageSignature, verifyImContentDigest, verifyImProof, verifyAuthHeaderSignature as verifyLegacyAuthHeader, verifyAuthJsonSignature as verifyLegacyAuthPayload, verifyW3cProof as verifyProof, verifyW3cProofDetailed as verifyProofDetailed, verifyHttpMessageSignature as verifySignatureHeaders, verifyW3cProof, verifyW3cProofDetailed, wns };
|