@private.me/xbind 1.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/AGENTS.md +778 -0
- package/LICENSE.md +27 -0
- package/README.md +400 -0
- package/dist-standalone/_deps/crypto/base64.d.ts +29 -0
- package/dist-standalone/_deps/crypto/base64.js +97 -0
- package/dist-standalone/_deps/crypto/cjs/base64.js +103 -0
- package/dist-standalone/_deps/crypto/cjs/errors.js +119 -0
- package/dist-standalone/_deps/crypto/cjs/hmac.js +71 -0
- package/dist-standalone/_deps/crypto/cjs/index.js +86 -0
- package/dist-standalone/_deps/crypto/cjs/padding.js +57 -0
- package/dist-standalone/_deps/crypto/cjs/share-header.js +68 -0
- package/dist-standalone/_deps/crypto/cjs/shares.js +152 -0
- package/dist-standalone/_deps/crypto/cjs/tlv.js +199 -0
- package/dist-standalone/_deps/crypto/cjs/uuid.js +61 -0
- package/dist-standalone/_deps/crypto/cjs/verify.js +24 -0
- package/dist-standalone/_deps/crypto/cjs/xorida.js +221 -0
- package/dist-standalone/_deps/crypto/errors.d.ts +51 -0
- package/dist-standalone/_deps/crypto/errors.js +109 -0
- package/dist-standalone/_deps/crypto/hmac.d.ts +39 -0
- package/dist-standalone/_deps/crypto/hmac.js +66 -0
- package/dist-standalone/_deps/crypto/index.d.ts +20 -0
- package/dist-standalone/_deps/crypto/index.js +45 -0
- package/dist-standalone/_deps/crypto/padding.d.ts +19 -0
- package/dist-standalone/_deps/crypto/padding.js +53 -0
- package/dist-standalone/_deps/crypto/share-header.d.ts +44 -0
- package/dist-standalone/_deps/crypto/share-header.js +63 -0
- package/dist-standalone/_deps/crypto/shares.d.ts +27 -0
- package/dist-standalone/_deps/crypto/shares.js +148 -0
- package/dist-standalone/_deps/crypto/tlv.d.ts +26 -0
- package/dist-standalone/_deps/crypto/tlv.js +195 -0
- package/dist-standalone/_deps/crypto/uuid.d.ts +22 -0
- package/dist-standalone/_deps/crypto/uuid.js +56 -0
- package/dist-standalone/_deps/crypto/verify.d.ts +15 -0
- package/dist-standalone/_deps/crypto/verify.js +15 -0
- package/dist-standalone/_deps/crypto/xorida.d.ts +44 -0
- package/dist-standalone/_deps/crypto/xorida.js +215 -0
- package/dist-standalone/_deps/mldsa-wasm/LICENSE +24 -0
- package/dist-standalone/_deps/mldsa-wasm/dist/mldsa.js +1920 -0
- package/dist-standalone/_deps/mldsa-wasm/package.json +46 -0
- package/dist-standalone/_deps/mldsa-wasm/types/mldsa.d.ts +30 -0
- package/dist-standalone/_deps/shared/cjs/errors.js +582 -0
- package/dist-standalone/_deps/shared/cjs/index.js +492 -0
- package/dist-standalone/_deps/shared/cjs/package.json +1 -0
- package/dist-standalone/_deps/shared/cjs/types.js +403 -0
- package/dist-standalone/_deps/shared/errors.d.ts +48 -0
- package/dist-standalone/_deps/shared/errors.d.ts.map +1 -0
- package/dist-standalone/_deps/shared/errors.js +192 -0
- package/dist-standalone/_deps/shared/errors.js.map +1 -0
- package/dist-standalone/_deps/shared/index.d.ts +4 -0
- package/dist-standalone/_deps/shared/index.d.ts.map +1 -0
- package/dist-standalone/_deps/shared/index.js +78 -0
- package/dist-standalone/_deps/shared/index.js.map +1 -0
- package/dist-standalone/_deps/shared/types.d.ts +1097 -0
- package/dist-standalone/_deps/shared/types.d.ts.map +1 -0
- package/dist-standalone/_deps/shared/types.js +89 -0
- package/dist-standalone/_deps/shared/types.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/errors.d.ts +115 -0
- package/dist-standalone/_deps/ux-helpers/cjs/errors.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/errors.js +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/errors.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/index.d.ts +13 -0
- package/dist-standalone/_deps/ux-helpers/cjs/index.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/index.js +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/index.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/package.json +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.d.ts +39 -0
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.js +83 -0
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/progress.d.ts +99 -0
- package/dist-standalone/_deps/ux-helpers/cjs/progress.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/progress.js +143 -0
- package/dist-standalone/_deps/ux-helpers/cjs/progress.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/search.d.ts +32 -0
- package/dist-standalone/_deps/ux-helpers/cjs/search.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/search.js +119 -0
- package/dist-standalone/_deps/ux-helpers/cjs/search.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/types.d.ts +109 -0
- package/dist-standalone/_deps/ux-helpers/cjs/types.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/cjs/types.js +8 -0
- package/dist-standalone/_deps/ux-helpers/cjs/types.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/errors.d.ts +115 -0
- package/dist-standalone/_deps/ux-helpers/errors.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/errors.js +253 -0
- package/dist-standalone/_deps/ux-helpers/errors.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/index.d.ts +13 -0
- package/dist-standalone/_deps/ux-helpers/index.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/index.js +16 -0
- package/dist-standalone/_deps/ux-helpers/index.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/pagination.d.ts +39 -0
- package/dist-standalone/_deps/ux-helpers/pagination.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/pagination.js +79 -0
- package/dist-standalone/_deps/ux-helpers/pagination.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/progress.d.ts +99 -0
- package/dist-standalone/_deps/ux-helpers/progress.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/progress.js +138 -0
- package/dist-standalone/_deps/ux-helpers/progress.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/search.d.ts +32 -0
- package/dist-standalone/_deps/ux-helpers/search.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/search.js +116 -0
- package/dist-standalone/_deps/ux-helpers/search.js.map +1 -0
- package/dist-standalone/_deps/ux-helpers/types.d.ts +109 -0
- package/dist-standalone/_deps/ux-helpers/types.d.ts.map +1 -0
- package/dist-standalone/_deps/ux-helpers/types.js +7 -0
- package/dist-standalone/_deps/ux-helpers/types.js.map +1 -0
- package/dist-standalone/_deps/xchange/auto-accept.d.ts +127 -0
- package/dist-standalone/_deps/xchange/auto-accept.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/auto-accept.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/errors.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/index.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/invite-client.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/lazy-init.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/package.json +1 -0
- package/dist-standalone/_deps/xchange/cjs/trust-integration.js +1 -0
- package/dist-standalone/_deps/xchange/cjs/xchange.js +1 -0
- package/dist-standalone/_deps/xchange/errors.d.ts +69 -0
- package/dist-standalone/_deps/xchange/errors.js +1 -0
- package/dist-standalone/_deps/xchange/index.d.ts +15 -0
- package/dist-standalone/_deps/xchange/index.js +1 -0
- package/dist-standalone/_deps/xchange/invite-client.d.ts +178 -0
- package/dist-standalone/_deps/xchange/invite-client.js +1 -0
- package/dist-standalone/_deps/xchange/lazy-init.d.ts +176 -0
- package/dist-standalone/_deps/xchange/lazy-init.js +1 -0
- package/dist-standalone/_deps/xchange/trust-integration.d.ts +102 -0
- package/dist-standalone/_deps/xchange/trust-integration.js +1 -0
- package/dist-standalone/_deps/xchange/xchange.d.ts +60 -0
- package/dist-standalone/_deps/xchange/xchange.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/discovery.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/errors.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/index.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/package.json +1 -0
- package/dist-standalone/_deps/xregistry/cjs/registry.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/schema.js +1 -0
- package/dist-standalone/_deps/xregistry/cjs/types.js +1 -0
- package/dist-standalone/_deps/xregistry/discovery.d.ts +126 -0
- package/dist-standalone/_deps/xregistry/discovery.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/discovery.js +1 -0
- package/dist-standalone/_deps/xregistry/discovery.js.map +1 -0
- package/dist-standalone/_deps/xregistry/errors.d.ts +41 -0
- package/dist-standalone/_deps/xregistry/errors.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/errors.js +1 -0
- package/dist-standalone/_deps/xregistry/errors.js.map +1 -0
- package/dist-standalone/_deps/xregistry/index.d.ts +8 -0
- package/dist-standalone/_deps/xregistry/index.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/index.js +1 -0
- package/dist-standalone/_deps/xregistry/index.js.map +1 -0
- package/dist-standalone/_deps/xregistry/registry.d.ts +85 -0
- package/dist-standalone/_deps/xregistry/registry.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/registry.js +1 -0
- package/dist-standalone/_deps/xregistry/registry.js.map +1 -0
- package/dist-standalone/_deps/xregistry/schema.d.ts +81 -0
- package/dist-standalone/_deps/xregistry/schema.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/schema.js +1 -0
- package/dist-standalone/_deps/xregistry/schema.js.map +1 -0
- package/dist-standalone/_deps/xregistry/types.d.ts +95 -0
- package/dist-standalone/_deps/xregistry/types.d.ts.map +1 -0
- package/dist-standalone/_deps/xregistry/types.js +1 -0
- package/dist-standalone/_deps/xregistry/types.js.map +1 -0
- package/dist-standalone/agent-call.d.ts +286 -0
- package/dist-standalone/agent-call.js +642 -0
- package/dist-standalone/agent-sdk.d.ts +207 -0
- package/dist-standalone/agent-sdk.js +328 -0
- package/dist-standalone/agent.d.ts +670 -0
- package/dist-standalone/agent.js +1529 -0
- package/dist-standalone/approval.d.ts +145 -0
- package/dist-standalone/approval.js +193 -0
- package/dist-standalone/auth.d.ts +75 -0
- package/dist-standalone/auth.js +219 -0
- package/dist-standalone/auto-accept.d.ts +102 -0
- package/dist-standalone/auto-accept.js +229 -0
- package/dist-standalone/backup-config.d.ts +150 -0
- package/dist-standalone/backup-config.js +201 -0
- package/dist-standalone/checkpoint.d.ts +125 -0
- package/dist-standalone/checkpoint.js +186 -0
- package/dist-standalone/cjs/agent-call.js +651 -0
- package/dist-standalone/cjs/agent-sdk.js +332 -0
- package/dist-standalone/cjs/agent.js +1566 -0
- package/dist-standalone/cjs/approval.js +199 -0
- package/dist-standalone/cjs/auth.js +225 -0
- package/dist-standalone/cjs/auto-accept.js +233 -0
- package/dist-standalone/cjs/backup-config.js +207 -0
- package/dist-standalone/cjs/checkpoint.js +193 -0
- package/dist-standalone/cjs/cli/init.js +487 -0
- package/dist-standalone/cjs/connect.js +312 -0
- package/dist-standalone/cjs/did-document.js +101 -0
- package/dist-standalone/cjs/did-privateme.js +130 -0
- package/dist-standalone/cjs/did-web.js +201 -0
- package/dist-standalone/cjs/discovery.js +462 -0
- package/dist-standalone/cjs/dual-mode.js +251 -0
- package/dist-standalone/cjs/email-templates.js +313 -0
- package/dist-standalone/cjs/email-transport.js +239 -0
- package/dist-standalone/cjs/envelope.js +510 -0
- package/dist-standalone/cjs/errors.js +562 -0
- package/dist-standalone/cjs/gateway-state.js +55 -0
- package/dist-standalone/cjs/gateway-transport.js +120 -0
- package/dist-standalone/cjs/guardrails.js +223 -0
- package/dist-standalone/cjs/http-compat.js +272 -0
- package/dist-standalone/cjs/identity.js +541 -0
- package/dist-standalone/cjs/index.js +224 -0
- package/dist-standalone/cjs/invitation.js +421 -0
- package/dist-standalone/cjs/invite.js +328 -0
- package/dist-standalone/cjs/key-agreement.js +246 -0
- package/dist-standalone/cjs/lazy-init.js +300 -0
- package/dist-standalone/cjs/mdns-discovery.js +202 -0
- package/dist-standalone/cjs/nonce-store.js +66 -0
- package/dist-standalone/cjs/package.json +3 -0
- package/dist-standalone/cjs/pairing-manager.js +223 -0
- package/dist-standalone/cjs/policy.js +320 -0
- package/dist-standalone/cjs/redis-nonce-store.js +76 -0
- package/dist-standalone/cjs/registry-middleware.js +50 -0
- package/dist-standalone/cjs/retry-transport.js +102 -0
- package/dist-standalone/cjs/security-policy.js +204 -0
- package/dist-standalone/cjs/split-channel.js +177 -0
- package/dist-standalone/cjs/subscription-proof.js +230 -0
- package/dist-standalone/cjs/succession.js +148 -0
- package/dist-standalone/cjs/transport.js +63 -0
- package/dist-standalone/cjs/trust-registry.js +742 -0
- package/dist-standalone/cjs/verify.js +25 -0
- package/dist-standalone/cjs/xfetch.js +252 -0
- package/dist-standalone/cli/init.d.ts +63 -0
- package/dist-standalone/cli/init.js +450 -0
- package/dist-standalone/connect.d.ts +143 -0
- package/dist-standalone/connect.js +274 -0
- package/dist-standalone/did-document.d.ts +65 -0
- package/dist-standalone/did-document.js +96 -0
- package/dist-standalone/did-privateme.d.ts +70 -0
- package/dist-standalone/did-privateme.js +121 -0
- package/dist-standalone/did-web.d.ts +73 -0
- package/dist-standalone/did-web.js +196 -0
- package/dist-standalone/discovery.d.ts +176 -0
- package/dist-standalone/discovery.js +458 -0
- package/dist-standalone/dual-mode.d.ts +145 -0
- package/dist-standalone/dual-mode.js +247 -0
- package/dist-standalone/email-templates.d.ts +41 -0
- package/dist-standalone/email-templates.js +309 -0
- package/dist-standalone/email-transport.d.ts +139 -0
- package/dist-standalone/email-transport.js +232 -0
- package/dist-standalone/envelope.d.ts +288 -0
- package/dist-standalone/envelope.js +497 -0
- package/dist-standalone/errors.d.ts +74 -0
- package/dist-standalone/errors.js +548 -0
- package/dist-standalone/gateway-state.d.ts +32 -0
- package/dist-standalone/gateway-state.js +51 -0
- package/dist-standalone/gateway-transport.d.ts +59 -0
- package/dist-standalone/gateway-transport.js +116 -0
- package/dist-standalone/guardrails.d.ts +136 -0
- package/dist-standalone/guardrails.js +216 -0
- package/dist-standalone/http-compat.d.ts +150 -0
- package/dist-standalone/http-compat.js +267 -0
- package/dist-standalone/identity.d.ts +176 -0
- package/dist-standalone/identity.js +516 -0
- package/dist-standalone/index.d.ts +83 -0
- package/dist-standalone/index.js +51 -0
- package/dist-standalone/invitation.d.ts +211 -0
- package/dist-standalone/invitation.js +415 -0
- package/dist-standalone/invite.d.ts +192 -0
- package/dist-standalone/invite.js +324 -0
- package/dist-standalone/key-agreement.d.ts +122 -0
- package/dist-standalone/key-agreement.js +236 -0
- package/dist-standalone/lazy-init.d.ts +167 -0
- package/dist-standalone/lazy-init.js +295 -0
- package/dist-standalone/mdns-discovery.d.ts +117 -0
- package/dist-standalone/mdns-discovery.js +195 -0
- package/dist-standalone/nonce-store.d.ts +39 -0
- package/dist-standalone/nonce-store.js +62 -0
- package/dist-standalone/package.json +11 -0
- package/dist-standalone/pairing-manager.d.ts +147 -0
- package/dist-standalone/pairing-manager.js +219 -0
- package/dist-standalone/policy.d.ts +150 -0
- package/dist-standalone/policy.js +315 -0
- package/dist-standalone/redis-nonce-store.d.ts +93 -0
- package/dist-standalone/redis-nonce-store.js +72 -0
- package/dist-standalone/registry-middleware.d.ts +38 -0
- package/dist-standalone/registry-middleware.js +47 -0
- package/dist-standalone/retry-transport.d.ts +76 -0
- package/dist-standalone/retry-transport.js +98 -0
- package/dist-standalone/security-policy.d.ts +146 -0
- package/dist-standalone/security-policy.js +198 -0
- package/dist-standalone/split-channel.d.ts +69 -0
- package/dist-standalone/split-channel.js +171 -0
- package/dist-standalone/subscription-proof.d.ts +103 -0
- package/dist-standalone/subscription-proof.js +224 -0
- package/dist-standalone/succession.d.ts +57 -0
- package/dist-standalone/succession.js +142 -0
- package/dist-standalone/transport.d.ts +50 -0
- package/dist-standalone/transport.js +59 -0
- package/dist-standalone/trust-registry.d.ts +286 -0
- package/dist-standalone/trust-registry.js +702 -0
- package/dist-standalone/verify.d.ts +16 -0
- package/dist-standalone/verify.js +16 -0
- package/dist-standalone/xfetch.d.ts +129 -0
- package/dist-standalone/xfetch.js +247 -0
- package/llms.txt +800 -0
- package/package.json +79 -0
- package/share1.dat +0 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import type { Result } from '@private.me/shared';
|
|
2
|
+
import type { DIDStateCheckpoint } from './checkpoint.js';
|
|
3
|
+
/** Trust registry error codes. */
|
|
4
|
+
export type RegistryError = 'NOT_FOUND' | 'ALREADY_REGISTERED' | 'REVOKED' | 'NETWORK_ERROR';
|
|
5
|
+
/** Metadata stored for a registered DID. */
|
|
6
|
+
export interface RegistryEntry {
|
|
7
|
+
readonly did: string;
|
|
8
|
+
readonly publicKey: Uint8Array;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly scopes: ReadonlySet<string>;
|
|
11
|
+
/** Scopes this agent accepts for incoming messages. Undefined = accept all. */
|
|
12
|
+
readonly receiveScopes?: ReadonlySet<string>;
|
|
13
|
+
readonly revoked: boolean;
|
|
14
|
+
/** Optional X25519 public key for ECDH forward secrecy. */
|
|
15
|
+
readonly x25519PublicKey?: Uint8Array;
|
|
16
|
+
/** Optional ML-KEM-768 public key for hybrid post-quantum KEM (1184 bytes). */
|
|
17
|
+
readonly mlKemPublicKey?: Uint8Array;
|
|
18
|
+
/** Optional ML-DSA-65 public key for hybrid post-quantum signatures (1952 bytes). */
|
|
19
|
+
readonly mlDsaPublicKey?: Uint8Array;
|
|
20
|
+
/** Whether this agent supports Xchange (XorIDA key transport). */
|
|
21
|
+
readonly xchange?: boolean;
|
|
22
|
+
/** Current rotation sequence for this DID (prevents rollback attacks). */
|
|
23
|
+
readonly rotation_sequence: number;
|
|
24
|
+
}
|
|
25
|
+
/** Trust event types for real-time registry updates. */
|
|
26
|
+
export interface TrustEvent {
|
|
27
|
+
/** Event type: 'revocation' (DID revoked) or 'succession' (key rotated). */
|
|
28
|
+
readonly type: 'revocation' | 'succession';
|
|
29
|
+
/** DID that triggered the event. */
|
|
30
|
+
readonly did: string;
|
|
31
|
+
/** Unix timestamp (milliseconds) when the event occurred. */
|
|
32
|
+
readonly timestamp: number;
|
|
33
|
+
/** Cryptographic proof for succession events (e.g., signature from old key). */
|
|
34
|
+
readonly proof?: Uint8Array;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Trust registry for DID registration, resolution, and scope validation.
|
|
38
|
+
*
|
|
39
|
+
* MemoryTrustRegistry for development, HttpTrustRegistry for production.
|
|
40
|
+
*/
|
|
41
|
+
export interface TrustRegistry {
|
|
42
|
+
/** Register a DID with its public key, name, and scopes. */
|
|
43
|
+
register(did: string, publicKey: Uint8Array, name: string, scopes?: string[], x25519PublicKey?: Uint8Array, mlKemPublicKey?: Uint8Array, mlDsaPublicKey?: Uint8Array, xchange?: boolean, receiveScopes?: string[]): Promise<Result<void, RegistryError>>;
|
|
44
|
+
/** Resolve a DID to its raw public key bytes. */
|
|
45
|
+
resolve(did: string): Promise<Result<Uint8Array, RegistryError>>;
|
|
46
|
+
/** Check if a DID has a specific scope permission. */
|
|
47
|
+
hasScope(did: string, scope: string): Promise<boolean>;
|
|
48
|
+
/** Check if a DID accepts a specific scope for incoming messages. */
|
|
49
|
+
hasReceiveScope(did: string, scope: string): Promise<boolean>;
|
|
50
|
+
/** Revoke a DID immediately. */
|
|
51
|
+
revoke(did: string): Promise<Result<void, RegistryError>>;
|
|
52
|
+
/** Get the full registry entry for a DID. */
|
|
53
|
+
getEntry(did: string): Promise<Result<RegistryEntry, RegistryError>>;
|
|
54
|
+
/**
|
|
55
|
+
* Rotate the public key for a DID (key succession).
|
|
56
|
+
* Optional method - not all implementations support key rotation.
|
|
57
|
+
*
|
|
58
|
+
* @param did - DID to update
|
|
59
|
+
* @param newPublicKey - New public key bytes
|
|
60
|
+
* @param proof - Cryptographic proof (e.g., signature from old key authorizing rotation)
|
|
61
|
+
* @param rotationSequence - New rotation sequence number (must be > current)
|
|
62
|
+
*/
|
|
63
|
+
rotate?(did: string, newPublicKey: Uint8Array, proof: Uint8Array, rotationSequence: number): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribe to real-time trust events (revocations, key rotations).
|
|
66
|
+
* Optional method - not all implementations support subscriptions.
|
|
67
|
+
*
|
|
68
|
+
* @param dids - Array of DIDs to watch
|
|
69
|
+
* @param callback - Function called when events occur
|
|
70
|
+
* @returns Unsubscribe function to stop watching
|
|
71
|
+
*/
|
|
72
|
+
subscribe?(dids: string[], callback: (event: TrustEvent) => void): Promise<() => void>;
|
|
73
|
+
/**
|
|
74
|
+
* Update scopes for existing DID without revoking.
|
|
75
|
+
* @param did - DID to update
|
|
76
|
+
* @param scopes - New scopes (replaces existing)
|
|
77
|
+
*/
|
|
78
|
+
updateScopes?(did: string, scopes: string[]): Promise<Result<void, RegistryError>>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* In-memory trust registry for development and testing.
|
|
82
|
+
*/
|
|
83
|
+
export declare class MemoryTrustRegistry implements TrustRegistry {
|
|
84
|
+
private readonly entries;
|
|
85
|
+
register(did: string, publicKey: Uint8Array, name: string, scopes?: string[], x25519PublicKey?: Uint8Array, mlKemPublicKey?: Uint8Array, mlDsaPublicKey?: Uint8Array, xchange?: boolean, receiveScopes?: string[]): Promise<Result<void, RegistryError>>;
|
|
86
|
+
resolve(did: string): Promise<Result<Uint8Array, RegistryError>>;
|
|
87
|
+
hasScope(did: string, scope: string): Promise<boolean>;
|
|
88
|
+
hasReceiveScope(did: string, scope: string): Promise<boolean>;
|
|
89
|
+
revoke(did: string): Promise<Result<void, RegistryError>>;
|
|
90
|
+
getEntry(did: string): Promise<Result<RegistryEntry, RegistryError>>;
|
|
91
|
+
updateScopes(did: string, scopes: string[]): Promise<Result<void, RegistryError>>;
|
|
92
|
+
/** Number of entries (for testing). */
|
|
93
|
+
get size(): number;
|
|
94
|
+
}
|
|
95
|
+
/** Options for HttpTrustRegistry. */
|
|
96
|
+
export interface HttpTrustRegistryOptions {
|
|
97
|
+
/** Base URL of the trust registry server (e.g. https://atelier.xail.io). */
|
|
98
|
+
readonly baseUrl: string;
|
|
99
|
+
/** Custom fetch implementation (for testing). */
|
|
100
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
101
|
+
/** Cache TTL in ms for resolve/getEntry results. Default: 30000 (30s). Set to 0 to disable. */
|
|
102
|
+
readonly cacheTtlMs?: number;
|
|
103
|
+
/** Cache failure behavior. Default: 'fail-secure' */
|
|
104
|
+
readonly cacheFailureMode?: 'fail-secure' | 'fail-open';
|
|
105
|
+
/** Enable push notification subscription. Default: false */
|
|
106
|
+
readonly enablePush?: boolean;
|
|
107
|
+
/** Bloom filter size for push filtering. Default: 10000 */
|
|
108
|
+
readonly bloomFilterSize?: number;
|
|
109
|
+
/** Bloom filter false positive rate. Default: 0.01 */
|
|
110
|
+
readonly bloomFilterFpr?: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* HTTP-backed trust registry for production use.
|
|
114
|
+
* Delegates to a remote atelier.xail.io service.
|
|
115
|
+
*/
|
|
116
|
+
export declare class HttpTrustRegistry implements TrustRegistry {
|
|
117
|
+
private readonly baseUrl;
|
|
118
|
+
private readonly fetchFn;
|
|
119
|
+
private readonly cacheTtlMs;
|
|
120
|
+
private readonly cacheFailureMode;
|
|
121
|
+
private readonly enablePush;
|
|
122
|
+
private readonly bloomFilterSize;
|
|
123
|
+
private readonly bloomFilterFpr;
|
|
124
|
+
private readonly resolveCache;
|
|
125
|
+
private readonly entryCache;
|
|
126
|
+
constructor(opts: HttpTrustRegistryOptions);
|
|
127
|
+
/** Clear all cached entries. Call after registration or revocation. */
|
|
128
|
+
clearCache(): void;
|
|
129
|
+
register(did: string, publicKey: Uint8Array, name: string, scopes?: string[], x25519PublicKey?: Uint8Array, mlKemPublicKey?: Uint8Array, mlDsaPublicKey?: Uint8Array, xchange?: boolean, receiveScopes?: string[]): Promise<Result<void, RegistryError>>;
|
|
130
|
+
resolve(did: string): Promise<Result<Uint8Array, RegistryError>>;
|
|
131
|
+
hasScope(did: string, scope: string): Promise<boolean>;
|
|
132
|
+
hasReceiveScope(did: string, scope: string): Promise<boolean>;
|
|
133
|
+
revoke(did: string): Promise<Result<void, RegistryError>>;
|
|
134
|
+
getEntry(did: string): Promise<Result<RegistryEntry, RegistryError>>;
|
|
135
|
+
/**
|
|
136
|
+
* Rotate a DID to a new public key with cryptographic proof.
|
|
137
|
+
*
|
|
138
|
+
* Sends rotation request to gateway and invalidates local cache.
|
|
139
|
+
*
|
|
140
|
+
* @param did - DID being rotated (old key)
|
|
141
|
+
* @param newPublicKey - New public key bytes
|
|
142
|
+
* @param proof - Succession announcement (dual signatures from old and new keys)
|
|
143
|
+
* @param rotationSequence - Monotonically increasing sequence number (prevents rollback)
|
|
144
|
+
*/
|
|
145
|
+
rotate(did: string, newPublicKey: Uint8Array, proof: Uint8Array, rotationSequence: number): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Subscribe to real-time trust events (revocation, key rotation).
|
|
148
|
+
*
|
|
149
|
+
* Creates a bloom filter from DIDs and connects WebSocket to gateway.
|
|
150
|
+
* Events matching subscribed DIDs trigger the callback and invalidate cache.
|
|
151
|
+
*
|
|
152
|
+
* @param dids - Array of DIDs to monitor
|
|
153
|
+
* @param callback - Function called when trust events occur
|
|
154
|
+
* @returns Unsubscribe function to stop watching
|
|
155
|
+
*
|
|
156
|
+
* @throws Error if push notifications not enabled (enablePush: true)
|
|
157
|
+
*/
|
|
158
|
+
subscribe(dids: string[], callback: (event: TrustEvent) => void): Promise<() => void>;
|
|
159
|
+
/**
|
|
160
|
+
* Simple hash function for bloom filter (DID → number).
|
|
161
|
+
* Production implementation would use proper bloom filter hashing.
|
|
162
|
+
*/
|
|
163
|
+
private hashDid;
|
|
164
|
+
/**
|
|
165
|
+
* Resume subscriptions on this gateway using proofs from another gateway.
|
|
166
|
+
*
|
|
167
|
+
* Allows clients to migrate between gateways without re-subscribing.
|
|
168
|
+
* Validates proofs and restores subscription state.
|
|
169
|
+
*
|
|
170
|
+
* @param proofs - Array of subscription proofs from previous gateway.
|
|
171
|
+
* @returns Success or error.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* const registry = new HttpTrustRegistry({ baseUrl: 'https://atelier2.xail.io' });
|
|
176
|
+
* const result = await registry.resumeSubscriptions([proof1, proof2]);
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
resumeSubscriptions(proofs: Array<{
|
|
180
|
+
peer_did: string;
|
|
181
|
+
bloom_filter_hash: string;
|
|
182
|
+
peer_signature: string;
|
|
183
|
+
}>): Promise<Result<void, RegistryError>>;
|
|
184
|
+
/**
|
|
185
|
+
* Fetch signed checkpoint for a DID (freshness primitive).
|
|
186
|
+
*
|
|
187
|
+
* Checkpoints provide cryptographic proof of DID state at a specific timestamp.
|
|
188
|
+
* Clients verify checkpoint signature and compare rotation_sequence to detect staleness.
|
|
189
|
+
*
|
|
190
|
+
* @param did - DID to fetch checkpoint for
|
|
191
|
+
* @returns Signed checkpoint or error
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const checkpoint = await registry.fetchCheckpoint('did:key:z6Mk...');
|
|
196
|
+
* if (checkpoint.ok) {
|
|
197
|
+
* const verified = await verifyCheckpoint(checkpoint.value, gatewayPubKey);
|
|
198
|
+
* if (verified.ok && verified.value) {
|
|
199
|
+
* // Use checkpoint for staleness detection
|
|
200
|
+
* if (isCacheStale(localCache, checkpoint.value)) {
|
|
201
|
+
* // Refresh cache
|
|
202
|
+
* }
|
|
203
|
+
* }
|
|
204
|
+
* }
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
fetchCheckpoint(did: string): Promise<Result<DIDStateCheckpoint, RegistryError>>;
|
|
208
|
+
updateScopes(did: string, scopes: string[]): Promise<Result<void, RegistryError>>;
|
|
209
|
+
}
|
|
210
|
+
/** Options for FileTrustRegistry. */
|
|
211
|
+
export interface FileTrustRegistryOptions {
|
|
212
|
+
/** Path to JSONL file for persistent storage. */
|
|
213
|
+
readonly path: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* File-based trust registry using JSONL append-only log.
|
|
217
|
+
* Replays all entries on initialization, keeps in-memory Map for fast access.
|
|
218
|
+
* Suitable for production deployments with local persistence.
|
|
219
|
+
*/
|
|
220
|
+
export declare class FileTrustRegistry implements TrustRegistry {
|
|
221
|
+
private readonly path;
|
|
222
|
+
private readonly entries;
|
|
223
|
+
private initialized;
|
|
224
|
+
constructor(opts: FileTrustRegistryOptions);
|
|
225
|
+
/** Initialize by replaying JSONL log. Called automatically on first operation. */
|
|
226
|
+
private init;
|
|
227
|
+
/** Append record to JSONL file. */
|
|
228
|
+
private append;
|
|
229
|
+
register(did: string, publicKey: Uint8Array, name: string, scopes?: string[], x25519PublicKey?: Uint8Array, mlKemPublicKey?: Uint8Array, mlDsaPublicKey?: Uint8Array, xchange?: boolean, receiveScopes?: string[]): Promise<Result<void, RegistryError>>;
|
|
230
|
+
resolve(did: string): Promise<Result<Uint8Array, RegistryError>>;
|
|
231
|
+
hasScope(did: string, scope: string): Promise<boolean>;
|
|
232
|
+
hasReceiveScope(did: string, scope: string): Promise<boolean>;
|
|
233
|
+
revoke(did: string): Promise<Result<void, RegistryError>>;
|
|
234
|
+
getEntry(did: string): Promise<Result<RegistryEntry, RegistryError>>;
|
|
235
|
+
updateScopes(did: string, scopes: string[]): Promise<Result<void, RegistryError>>;
|
|
236
|
+
/**
|
|
237
|
+
* Rotate a DID to a new public key with rollback protection.
|
|
238
|
+
*
|
|
239
|
+
* Validates that rotationSequence is greater than current sequence to prevent
|
|
240
|
+
* rollback attacks. Appends rotation event to JSONL and updates in-memory state.
|
|
241
|
+
*
|
|
242
|
+
* @param did - DID being rotated
|
|
243
|
+
* @param newPublicKey - New public key bytes
|
|
244
|
+
* @param proof - Cryptographic proof (e.g., signature from old key)
|
|
245
|
+
* @param rotationSequence - Monotonically increasing sequence number
|
|
246
|
+
* @throws Error if DID not found or sequence validation fails
|
|
247
|
+
*/
|
|
248
|
+
rotate(did: string, newPublicKey: Uint8Array, proof: Uint8Array, rotationSequence: number): Promise<void>;
|
|
249
|
+
/** Number of entries (for testing). */
|
|
250
|
+
get size(): number;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Create an enterprise trust registry with optional pre-population.
|
|
254
|
+
* Suitable for corporate deployments with centralized trust management.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* const registry = await TrustRegistry.enterprise({
|
|
259
|
+
* storage: 'file',
|
|
260
|
+
* path: '/opt/corp/trust.jsonl',
|
|
261
|
+
* preload: [
|
|
262
|
+
* { did: 'did:web:corp.example.com', publicKey: ..., name: 'Corporate Gateway' }
|
|
263
|
+
* ]
|
|
264
|
+
* });
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export declare function createEnterpriseTrustRegistry(opts: {
|
|
268
|
+
/** Storage backend: 'memory', 'file', or 'http'. */
|
|
269
|
+
readonly storage: 'memory' | 'file' | 'http';
|
|
270
|
+
/** File path (required if storage='file'). */
|
|
271
|
+
readonly path?: string;
|
|
272
|
+
/** HTTP base URL (required if storage='http'). */
|
|
273
|
+
readonly baseUrl?: string;
|
|
274
|
+
/** Pre-populate with these entries. */
|
|
275
|
+
readonly preload?: Array<{
|
|
276
|
+
did: string;
|
|
277
|
+
publicKey: Uint8Array;
|
|
278
|
+
name: string;
|
|
279
|
+
scopes?: string[];
|
|
280
|
+
receiveScopes?: string[];
|
|
281
|
+
x25519PublicKey?: Uint8Array;
|
|
282
|
+
mlKemPublicKey?: Uint8Array;
|
|
283
|
+
mlDsaPublicKey?: Uint8Array;
|
|
284
|
+
xchange?: boolean;
|
|
285
|
+
}>;
|
|
286
|
+
}): Promise<TrustRegistry>;
|