@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,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module mdns-discovery
|
|
3
|
+
* mDNS service discovery for local network device pairing.
|
|
4
|
+
*
|
|
5
|
+
* Service Type: _privateme._tcp.local (RFC 6763 compliant)
|
|
6
|
+
* Port: 58472 (dynamic range 58000-58999)
|
|
7
|
+
* TXT Record: did=z6Mk..., endpoint=http://192.168.1.5:58472, name=Desktop
|
|
8
|
+
*
|
|
9
|
+
* Security properties:
|
|
10
|
+
* - Physical proximity required (same LAN)
|
|
11
|
+
* - User confirmation on both devices
|
|
12
|
+
* - Nonce-based challenge-response
|
|
13
|
+
* - 60-second timeout
|
|
14
|
+
* - Gold Standard compliant (GS-CONNECT requirement #26)
|
|
15
|
+
*/
|
|
16
|
+
import { Result } from '@private.me/shared';
|
|
17
|
+
/**
|
|
18
|
+
* mDNS service information.
|
|
19
|
+
*/
|
|
20
|
+
export interface MdnsServiceInfo {
|
|
21
|
+
/** Service name (e.g., "Desktop", "MacBook Pro") */
|
|
22
|
+
readonly name: string;
|
|
23
|
+
/** Device DID */
|
|
24
|
+
readonly did: string;
|
|
25
|
+
/** HTTP endpoint (e.g., "http://192.168.1.5:58472") */
|
|
26
|
+
readonly endpoint: string;
|
|
27
|
+
/** IPv4 addresses */
|
|
28
|
+
readonly addresses: readonly string[];
|
|
29
|
+
/** Port number */
|
|
30
|
+
readonly port: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Discovery error types.
|
|
34
|
+
*/
|
|
35
|
+
export declare enum DiscoveryErrorCode {
|
|
36
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
37
|
+
TIMEOUT = "TIMEOUT",
|
|
38
|
+
NO_SERVICES = "NO_SERVICES",
|
|
39
|
+
INVALID_SERVICE = "INVALID_SERVICE"
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Discovery error.
|
|
43
|
+
*/
|
|
44
|
+
export interface DiscoveryError {
|
|
45
|
+
readonly code: DiscoveryErrorCode;
|
|
46
|
+
readonly message: string;
|
|
47
|
+
readonly hint?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* mDNS discovery manager.
|
|
51
|
+
*
|
|
52
|
+
* Advertises service on local network and scans for other devices.
|
|
53
|
+
* Uses bonjour-service library (RFC 6763/6762 compliant).
|
|
54
|
+
*/
|
|
55
|
+
export declare class MdnsDiscoveryManager {
|
|
56
|
+
private readonly bonjour;
|
|
57
|
+
private service;
|
|
58
|
+
private readonly serviceType;
|
|
59
|
+
private readonly protocol;
|
|
60
|
+
private readonly port;
|
|
61
|
+
constructor();
|
|
62
|
+
/**
|
|
63
|
+
* Advertise service on local network.
|
|
64
|
+
*
|
|
65
|
+
* Broadcasts mDNS announcement with device DID and HTTP endpoint.
|
|
66
|
+
* Other devices on the same LAN can discover this service via scan().
|
|
67
|
+
*
|
|
68
|
+
* @param name - Device name (e.g., "Desktop", "MacBook Pro")
|
|
69
|
+
* @param did - Device DID
|
|
70
|
+
* @param port - Local HTTP server port (default: 58472)
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const manager = new MdnsDiscoveryManager();
|
|
75
|
+
* manager.advertise('Desktop', 'did:key:z6Mk...', 58472);
|
|
76
|
+
* // Service now visible to other devices on LAN
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
advertise(name: string, did: string, port?: number): void;
|
|
80
|
+
/**
|
|
81
|
+
* Scan local network for services.
|
|
82
|
+
*
|
|
83
|
+
* Discovers all Private.Me devices on the same LAN.
|
|
84
|
+
* Filters out own DID from results (can't pair with self).
|
|
85
|
+
*
|
|
86
|
+
* @param ownDid - Own device DID (to filter out)
|
|
87
|
+
* @param timeoutMs - Scan timeout in milliseconds (default: 5000ms)
|
|
88
|
+
* @returns Array of discovered services
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const manager = new MdnsDiscoveryManager();
|
|
93
|
+
* const result = await manager.scan('did:key:z6Mk...myDid', 5000);
|
|
94
|
+
* if (result.ok) {
|
|
95
|
+
* console.log(`Found ${result.value.length} devices`);
|
|
96
|
+
* for (const service of result.value) {
|
|
97
|
+
* console.log(`${service.name} - ${service.did}`);
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
scan(ownDid: string, timeoutMs?: number): Promise<Result<MdnsServiceInfo[], DiscoveryError>>;
|
|
103
|
+
/**
|
|
104
|
+
* Stop advertising service.
|
|
105
|
+
*
|
|
106
|
+
* Removes mDNS announcement from local network.
|
|
107
|
+
* Other devices will no longer see this service.
|
|
108
|
+
*/
|
|
109
|
+
stopAdvertising(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Release resources.
|
|
112
|
+
*
|
|
113
|
+
* Stops advertising and cleans up Bonjour instance.
|
|
114
|
+
* Call this when shutting down the application.
|
|
115
|
+
*/
|
|
116
|
+
destroy(): void;
|
|
117
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module mdns-discovery
|
|
3
|
+
* mDNS service discovery for local network device pairing.
|
|
4
|
+
*
|
|
5
|
+
* Service Type: _privateme._tcp.local (RFC 6763 compliant)
|
|
6
|
+
* Port: 58472 (dynamic range 58000-58999)
|
|
7
|
+
* TXT Record: did=z6Mk..., endpoint=http://192.168.1.5:58472, name=Desktop
|
|
8
|
+
*
|
|
9
|
+
* Security properties:
|
|
10
|
+
* - Physical proximity required (same LAN)
|
|
11
|
+
* - User confirmation on both devices
|
|
12
|
+
* - Nonce-based challenge-response
|
|
13
|
+
* - 60-second timeout
|
|
14
|
+
* - Gold Standard compliant (GS-CONNECT requirement #26)
|
|
15
|
+
*/
|
|
16
|
+
import Bonjour from 'bonjour-service';
|
|
17
|
+
import { ok, err } from"./_deps/shared/index.js";
|
|
18
|
+
/**
|
|
19
|
+
* Discovery error types.
|
|
20
|
+
*/
|
|
21
|
+
export var DiscoveryErrorCode;
|
|
22
|
+
(function (DiscoveryErrorCode) {
|
|
23
|
+
DiscoveryErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
24
|
+
DiscoveryErrorCode["TIMEOUT"] = "TIMEOUT";
|
|
25
|
+
DiscoveryErrorCode["NO_SERVICES"] = "NO_SERVICES";
|
|
26
|
+
DiscoveryErrorCode["INVALID_SERVICE"] = "INVALID_SERVICE";
|
|
27
|
+
})(DiscoveryErrorCode || (DiscoveryErrorCode = {}));
|
|
28
|
+
/**
|
|
29
|
+
* mDNS discovery manager.
|
|
30
|
+
*
|
|
31
|
+
* Advertises service on local network and scans for other devices.
|
|
32
|
+
* Uses bonjour-service library (RFC 6763/6762 compliant).
|
|
33
|
+
*/
|
|
34
|
+
export class MdnsDiscoveryManager {
|
|
35
|
+
bonjour;
|
|
36
|
+
service = null;
|
|
37
|
+
serviceType = 'privateme';
|
|
38
|
+
protocol = 'tcp';
|
|
39
|
+
port = 58472;
|
|
40
|
+
constructor() {
|
|
41
|
+
this.bonjour = new Bonjour();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Advertise service on local network.
|
|
45
|
+
*
|
|
46
|
+
* Broadcasts mDNS announcement with device DID and HTTP endpoint.
|
|
47
|
+
* Other devices on the same LAN can discover this service via scan().
|
|
48
|
+
*
|
|
49
|
+
* @param name - Device name (e.g., "Desktop", "MacBook Pro")
|
|
50
|
+
* @param did - Device DID
|
|
51
|
+
* @param port - Local HTTP server port (default: 58472)
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const manager = new MdnsDiscoveryManager();
|
|
56
|
+
* manager.advertise('Desktop', 'did:key:z6Mk...', 58472);
|
|
57
|
+
* // Service now visible to other devices on LAN
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
advertise(name, did, port = this.port) {
|
|
61
|
+
// Stop existing advertisement
|
|
62
|
+
if (this.service) {
|
|
63
|
+
this.service.stop?.();
|
|
64
|
+
}
|
|
65
|
+
// Publish service
|
|
66
|
+
this.service = this.bonjour.publish({
|
|
67
|
+
name,
|
|
68
|
+
type: this.serviceType,
|
|
69
|
+
protocol: this.protocol,
|
|
70
|
+
port,
|
|
71
|
+
txt: {
|
|
72
|
+
did,
|
|
73
|
+
endpoint: `http://localhost:${port}`, // Will be replaced with actual IP by Bonjour
|
|
74
|
+
name,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Scan local network for services.
|
|
80
|
+
*
|
|
81
|
+
* Discovers all Private.Me devices on the same LAN.
|
|
82
|
+
* Filters out own DID from results (can't pair with self).
|
|
83
|
+
*
|
|
84
|
+
* @param ownDid - Own device DID (to filter out)
|
|
85
|
+
* @param timeoutMs - Scan timeout in milliseconds (default: 5000ms)
|
|
86
|
+
* @returns Array of discovered services
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const manager = new MdnsDiscoveryManager();
|
|
91
|
+
* const result = await manager.scan('did:key:z6Mk...myDid', 5000);
|
|
92
|
+
* if (result.ok) {
|
|
93
|
+
* console.log(`Found ${result.value.length} devices`);
|
|
94
|
+
* for (const service of result.value) {
|
|
95
|
+
* console.log(`${service.name} - ${service.did}`);
|
|
96
|
+
* }
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
async scan(ownDid, timeoutMs = 5000) {
|
|
101
|
+
return new Promise((resolve) => {
|
|
102
|
+
const discovered = new Map();
|
|
103
|
+
let resolved = false;
|
|
104
|
+
// Browse for services
|
|
105
|
+
const browser = this.bonjour.find({
|
|
106
|
+
type: this.serviceType,
|
|
107
|
+
protocol: this.protocol,
|
|
108
|
+
});
|
|
109
|
+
// Handle service discovery
|
|
110
|
+
browser.on('up', (service) => {
|
|
111
|
+
try {
|
|
112
|
+
// Parse TXT record
|
|
113
|
+
const txt = service.txt;
|
|
114
|
+
if (!txt || !txt.did || !txt.name) {
|
|
115
|
+
return; // Invalid service - missing required fields
|
|
116
|
+
}
|
|
117
|
+
// Filter out own DID
|
|
118
|
+
if (txt.did === ownDid) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// Extract endpoint
|
|
122
|
+
const endpoint = txt.endpoint || `http://${service.host || 'localhost'}:${service.port}`;
|
|
123
|
+
// Extract addresses (filter IPv4 only)
|
|
124
|
+
const addresses = (service.addresses || []).filter((addr) => {
|
|
125
|
+
// Simple IPv4 check (contains dots, not colons)
|
|
126
|
+
return addr.includes('.') && !addr.includes(':');
|
|
127
|
+
});
|
|
128
|
+
const info = {
|
|
129
|
+
name: txt.name,
|
|
130
|
+
did: txt.did,
|
|
131
|
+
endpoint,
|
|
132
|
+
addresses,
|
|
133
|
+
port: service.port || this.port,
|
|
134
|
+
};
|
|
135
|
+
discovered.set(txt.did, info);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
// Ignore invalid service
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
// Timeout after specified duration
|
|
142
|
+
const timeoutId = setTimeout(() => {
|
|
143
|
+
if (resolved)
|
|
144
|
+
return;
|
|
145
|
+
resolved = true;
|
|
146
|
+
browser.stop();
|
|
147
|
+
if (discovered.size === 0) {
|
|
148
|
+
resolve(err({
|
|
149
|
+
code: DiscoveryErrorCode.NO_SERVICES,
|
|
150
|
+
message: 'No devices found on local network',
|
|
151
|
+
hint: 'Ensure both devices are on the same Wi-Fi network',
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
resolve(ok(Array.from(discovered.values())));
|
|
156
|
+
}
|
|
157
|
+
}, timeoutMs);
|
|
158
|
+
// Allow cleanup if promise resolves early
|
|
159
|
+
browser.on('error', (error) => {
|
|
160
|
+
if (resolved)
|
|
161
|
+
return;
|
|
162
|
+
resolved = true;
|
|
163
|
+
clearTimeout(timeoutId);
|
|
164
|
+
browser.stop();
|
|
165
|
+
resolve(err({
|
|
166
|
+
code: DiscoveryErrorCode.NETWORK_ERROR,
|
|
167
|
+
message: error.message,
|
|
168
|
+
hint: 'Check firewall settings and network connectivity',
|
|
169
|
+
}));
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Stop advertising service.
|
|
175
|
+
*
|
|
176
|
+
* Removes mDNS announcement from local network.
|
|
177
|
+
* Other devices will no longer see this service.
|
|
178
|
+
*/
|
|
179
|
+
stopAdvertising() {
|
|
180
|
+
if (this.service) {
|
|
181
|
+
this.service.stop?.();
|
|
182
|
+
this.service = null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Release resources.
|
|
187
|
+
*
|
|
188
|
+
* Stops advertising and cleans up Bonjour instance.
|
|
189
|
+
* Call this when shutting down the application.
|
|
190
|
+
*/
|
|
191
|
+
destroy() {
|
|
192
|
+
this.stopAdvertising();
|
|
193
|
+
this.bonjour.destroy();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Interface for nonce stores that prevent replay attacks. */
|
|
2
|
+
export interface NonceStore {
|
|
3
|
+
/**
|
|
4
|
+
* Check if a nonce is fresh and record it atomically.
|
|
5
|
+
* @returns true if nonce is new (accepted), false if duplicate (rejected).
|
|
6
|
+
*/
|
|
7
|
+
check(nonce: string, senderDid: string): Promise<boolean>;
|
|
8
|
+
/** Remove expired entries. Called automatically on interval. */
|
|
9
|
+
cleanup(): void;
|
|
10
|
+
/** Shut down the store and clear any timers. */
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}
|
|
13
|
+
/** Options for MemoryNonceStore. */
|
|
14
|
+
export interface MemoryNonceStoreOptions {
|
|
15
|
+
/** TTL in milliseconds for nonce entries. Default: 10 minutes. */
|
|
16
|
+
readonly ttlMs?: number;
|
|
17
|
+
/** Cleanup interval in milliseconds. Default: 60 seconds. */
|
|
18
|
+
readonly cleanupIntervalMs?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* In-memory nonce store for development and single-process deployments.
|
|
22
|
+
*
|
|
23
|
+
* Stores nonces in a Map keyed by "senderDid:nonce" with expiry timestamps.
|
|
24
|
+
* Periodic cleanup removes expired entries to prevent unbounded growth.
|
|
25
|
+
*/
|
|
26
|
+
export declare class MemoryNonceStore implements NonceStore {
|
|
27
|
+
private readonly seen;
|
|
28
|
+
private readonly ttlMs;
|
|
29
|
+
private readonly cleanupIntervalMs;
|
|
30
|
+
private timer;
|
|
31
|
+
constructor(opts?: MemoryNonceStoreOptions);
|
|
32
|
+
/** Start cleanup timer on first use. */
|
|
33
|
+
private ensureTimer;
|
|
34
|
+
check(nonce: string, senderDid: string): Promise<boolean>;
|
|
35
|
+
cleanup(): void;
|
|
36
|
+
dispose(): void;
|
|
37
|
+
/** Number of active (non-expired) entries. Useful for testing. */
|
|
38
|
+
get size(): number;
|
|
39
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* ── NonceStore — Replay Prevention ── */
|
|
2
|
+
/** Default TTL for nonce entries: 10 minutes. */
|
|
3
|
+
const DEFAULT_TTL_MS = 10 * 60 * 1000;
|
|
4
|
+
/** Default cleanup interval: 60 seconds. */
|
|
5
|
+
const DEFAULT_CLEANUP_INTERVAL_MS = 60 * 1000;
|
|
6
|
+
/**
|
|
7
|
+
* In-memory nonce store for development and single-process deployments.
|
|
8
|
+
*
|
|
9
|
+
* Stores nonces in a Map keyed by "senderDid:nonce" with expiry timestamps.
|
|
10
|
+
* Periodic cleanup removes expired entries to prevent unbounded growth.
|
|
11
|
+
*/
|
|
12
|
+
export class MemoryNonceStore {
|
|
13
|
+
seen = new Map();
|
|
14
|
+
ttlMs;
|
|
15
|
+
cleanupIntervalMs;
|
|
16
|
+
timer = null;
|
|
17
|
+
constructor(opts) {
|
|
18
|
+
this.ttlMs = opts?.ttlMs ?? DEFAULT_TTL_MS;
|
|
19
|
+
this.cleanupIntervalMs = opts?.cleanupIntervalMs ?? DEFAULT_CLEANUP_INTERVAL_MS;
|
|
20
|
+
// Timer starts lazily on first check() to avoid blocking process exit in tests
|
|
21
|
+
}
|
|
22
|
+
/** Start cleanup timer on first use. */
|
|
23
|
+
ensureTimer() {
|
|
24
|
+
if (this.timer !== null)
|
|
25
|
+
return;
|
|
26
|
+
const t = setInterval(() => this.cleanup(), this.cleanupIntervalMs);
|
|
27
|
+
// Unref so the timer doesn't block Node.js process exit
|
|
28
|
+
if (typeof t === 'object' && 'unref' in t) {
|
|
29
|
+
t.unref(); // SAFETY: runtime check guards access
|
|
30
|
+
}
|
|
31
|
+
this.timer = t;
|
|
32
|
+
}
|
|
33
|
+
async check(nonce, senderDid) {
|
|
34
|
+
this.ensureTimer();
|
|
35
|
+
const key = `${senderDid}:${nonce}`;
|
|
36
|
+
const existing = this.seen.get(key);
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
if (existing !== undefined && existing > now) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
this.seen.set(key, now + this.ttlMs);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
cleanup() {
|
|
45
|
+
const now = Date.now();
|
|
46
|
+
for (const [key, expiry] of this.seen) {
|
|
47
|
+
if (expiry <= now)
|
|
48
|
+
this.seen.delete(key);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
dispose() {
|
|
52
|
+
if (this.timer !== null) {
|
|
53
|
+
clearInterval(this.timer);
|
|
54
|
+
this.timer = null;
|
|
55
|
+
}
|
|
56
|
+
this.seen.clear();
|
|
57
|
+
}
|
|
58
|
+
/** Number of active (non-expired) entries. Useful for testing. */
|
|
59
|
+
get size() {
|
|
60
|
+
return this.seen.size;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"imports": {
|
|
4
|
+
"@private.me/shared": "./_deps/shared/index.js",
|
|
5
|
+
"@private.me/crypto": "./_deps/crypto/index.js",
|
|
6
|
+
"@private.me/xchange": "./_deps/xchange/index.js",
|
|
7
|
+
"@private.me/ux-helpers": "./_deps/ux-helpers/index.js",
|
|
8
|
+
"@private.me/xregistry": "./_deps/xregistry/index.js",
|
|
9
|
+
"mldsa-wasm": "./_deps/mldsa-wasm/dist/mldsa.js"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module pairing-manager
|
|
3
|
+
* Security validation for peer-to-peer device pairing via mDNS.
|
|
4
|
+
*
|
|
5
|
+
* Security properties:
|
|
6
|
+
* - 16-byte cryptographically secure nonce (prevents replay attacks)
|
|
7
|
+
* - 60-second timeout (limits attack window)
|
|
8
|
+
* - User confirmation required on BOTH devices
|
|
9
|
+
* - Nonce echo in response (prevents MITM substitution)
|
|
10
|
+
* - Trust registry integration (stores paired DIDs with scopes)
|
|
11
|
+
* - Gold Standard compliant (GS-CONNECT requirement #26, GS-SEC-RNG compliant)
|
|
12
|
+
*/
|
|
13
|
+
import { Result } from '@private.me/shared';
|
|
14
|
+
import type { TrustRegistry } from './trust-registry';
|
|
15
|
+
/**
|
|
16
|
+
* Pairing request (Device A → Device B).
|
|
17
|
+
*/
|
|
18
|
+
export interface PairingRequest {
|
|
19
|
+
/** DID of initiating device (Device A) */
|
|
20
|
+
readonly device_a_did: string;
|
|
21
|
+
/** Cryptographically secure nonce (16 bytes, hex-encoded) */
|
|
22
|
+
readonly nonce: string;
|
|
23
|
+
/** Request timestamp (milliseconds since epoch) */
|
|
24
|
+
readonly timestamp: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pairing response (Device B → Device A).
|
|
28
|
+
*/
|
|
29
|
+
export interface PairingResponse {
|
|
30
|
+
/** DID of responding device (Device B) */
|
|
31
|
+
readonly device_b_did: string;
|
|
32
|
+
/** Whether pairing was accepted */
|
|
33
|
+
readonly accepted: boolean;
|
|
34
|
+
/** Echo of nonce from request (prevents MITM) */
|
|
35
|
+
readonly nonce: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Pairing manager for secure peer-to-peer device pairing.
|
|
39
|
+
*
|
|
40
|
+
* Implements challenge-response protocol with user confirmation.
|
|
41
|
+
* Integrates with trust registry for persistent pairing storage.
|
|
42
|
+
*/
|
|
43
|
+
export declare class PairingManager {
|
|
44
|
+
private readonly pendingNonces;
|
|
45
|
+
private readonly registry;
|
|
46
|
+
private readonly deviceDid;
|
|
47
|
+
/**
|
|
48
|
+
* Create pairing manager.
|
|
49
|
+
*
|
|
50
|
+
* @param deviceDid - DID of this device
|
|
51
|
+
* @param registry - Trust registry instance
|
|
52
|
+
*/
|
|
53
|
+
constructor(deviceDid: string, registry: TrustRegistry);
|
|
54
|
+
/**
|
|
55
|
+
* Create pairing request.
|
|
56
|
+
*
|
|
57
|
+
* Generates cryptographically secure nonce and stores it for validation.
|
|
58
|
+
* Device A calls this before sending request to Device B.
|
|
59
|
+
*
|
|
60
|
+
* @returns Pairing request to send to remote device
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const manager = new PairingManager('did:key:z6MkA...', registry);
|
|
65
|
+
* const request = manager.createRequest();
|
|
66
|
+
* // Send request to Device B via HTTP POST
|
|
67
|
+
* const response = await fetch(`${deviceB.endpoint}/pair`, {
|
|
68
|
+
* method: 'POST',
|
|
69
|
+
* body: JSON.stringify(request),
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
createRequest(): PairingRequest;
|
|
74
|
+
/**
|
|
75
|
+
* Validate pairing request.
|
|
76
|
+
*
|
|
77
|
+
* Checks timeout and nonce uniqueness.
|
|
78
|
+
* Device B calls this when receiving request from Device A.
|
|
79
|
+
*
|
|
80
|
+
* @param request - Pairing request from remote device
|
|
81
|
+
* @returns Ok if valid, Err with reason if invalid
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // Device B receives request
|
|
86
|
+
* const validation = manager.validateRequest(request);
|
|
87
|
+
* if (!validation.ok) {
|
|
88
|
+
* return res.status(400).json({ error: validation.error });
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
validateRequest(request: PairingRequest): Result<void, string>;
|
|
93
|
+
/**
|
|
94
|
+
* Accept pairing request.
|
|
95
|
+
*
|
|
96
|
+
* Shows UI prompt for user confirmation, then stores in trust registry.
|
|
97
|
+
* Device B calls this after validating request.
|
|
98
|
+
*
|
|
99
|
+
* @param request - Validated pairing request
|
|
100
|
+
* @param promptCallback - Async function to show UI prompt (returns true if accepted)
|
|
101
|
+
* @returns Pairing response to send back to Device A
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const response = await manager.acceptPairing(request, async () => {
|
|
106
|
+
* // Show modal: "Device {name} wants to pair. Accept?"
|
|
107
|
+
* return await showConfirmationDialog({
|
|
108
|
+
* title: 'Pair with Device?',
|
|
109
|
+
* message: `DID: ${request.device_a_did.slice(0, 20)}...`,
|
|
110
|
+
* });
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* if (response.ok && response.value.accepted) {
|
|
114
|
+
* // Send response back to Device A
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
acceptPairing(request: PairingRequest, promptCallback: () => Promise<boolean>): Promise<Result<PairingResponse, string>>;
|
|
119
|
+
/**
|
|
120
|
+
* Finalize pairing.
|
|
121
|
+
*
|
|
122
|
+
* Verifies response nonce and stores remote DID in trust registry.
|
|
123
|
+
* Device A calls this after receiving response from Device B.
|
|
124
|
+
*
|
|
125
|
+
* @param response - Pairing response from Device B
|
|
126
|
+
* @param expectedNonce - Nonce from original request (for verification)
|
|
127
|
+
* @returns Ok if successful, Err if nonce mismatch or storage failed
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const request = manager.createRequest();
|
|
132
|
+
* const response = await sendPairingRequest(deviceB.endpoint, request);
|
|
133
|
+
*
|
|
134
|
+
* const result = await manager.finalizePairing(response, request.nonce);
|
|
135
|
+
* if (result.ok) {
|
|
136
|
+
* console.log('Pairing successful!');
|
|
137
|
+
* } else {
|
|
138
|
+
* console.error('Pairing failed:', result.error);
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
finalizePairing(response: PairingResponse, expectedNonce: string): Promise<Result<void, string>>;
|
|
143
|
+
/**
|
|
144
|
+
* Get pending nonce count (for debugging/monitoring).
|
|
145
|
+
*/
|
|
146
|
+
getPendingNonceCount(): number;
|
|
147
|
+
}
|