@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.
Files changed (295) hide show
  1. package/AGENTS.md +778 -0
  2. package/LICENSE.md +27 -0
  3. package/README.md +400 -0
  4. package/dist-standalone/_deps/crypto/base64.d.ts +29 -0
  5. package/dist-standalone/_deps/crypto/base64.js +97 -0
  6. package/dist-standalone/_deps/crypto/cjs/base64.js +103 -0
  7. package/dist-standalone/_deps/crypto/cjs/errors.js +119 -0
  8. package/dist-standalone/_deps/crypto/cjs/hmac.js +71 -0
  9. package/dist-standalone/_deps/crypto/cjs/index.js +86 -0
  10. package/dist-standalone/_deps/crypto/cjs/padding.js +57 -0
  11. package/dist-standalone/_deps/crypto/cjs/share-header.js +68 -0
  12. package/dist-standalone/_deps/crypto/cjs/shares.js +152 -0
  13. package/dist-standalone/_deps/crypto/cjs/tlv.js +199 -0
  14. package/dist-standalone/_deps/crypto/cjs/uuid.js +61 -0
  15. package/dist-standalone/_deps/crypto/cjs/verify.js +24 -0
  16. package/dist-standalone/_deps/crypto/cjs/xorida.js +221 -0
  17. package/dist-standalone/_deps/crypto/errors.d.ts +51 -0
  18. package/dist-standalone/_deps/crypto/errors.js +109 -0
  19. package/dist-standalone/_deps/crypto/hmac.d.ts +39 -0
  20. package/dist-standalone/_deps/crypto/hmac.js +66 -0
  21. package/dist-standalone/_deps/crypto/index.d.ts +20 -0
  22. package/dist-standalone/_deps/crypto/index.js +45 -0
  23. package/dist-standalone/_deps/crypto/padding.d.ts +19 -0
  24. package/dist-standalone/_deps/crypto/padding.js +53 -0
  25. package/dist-standalone/_deps/crypto/share-header.d.ts +44 -0
  26. package/dist-standalone/_deps/crypto/share-header.js +63 -0
  27. package/dist-standalone/_deps/crypto/shares.d.ts +27 -0
  28. package/dist-standalone/_deps/crypto/shares.js +148 -0
  29. package/dist-standalone/_deps/crypto/tlv.d.ts +26 -0
  30. package/dist-standalone/_deps/crypto/tlv.js +195 -0
  31. package/dist-standalone/_deps/crypto/uuid.d.ts +22 -0
  32. package/dist-standalone/_deps/crypto/uuid.js +56 -0
  33. package/dist-standalone/_deps/crypto/verify.d.ts +15 -0
  34. package/dist-standalone/_deps/crypto/verify.js +15 -0
  35. package/dist-standalone/_deps/crypto/xorida.d.ts +44 -0
  36. package/dist-standalone/_deps/crypto/xorida.js +215 -0
  37. package/dist-standalone/_deps/mldsa-wasm/LICENSE +24 -0
  38. package/dist-standalone/_deps/mldsa-wasm/dist/mldsa.js +1920 -0
  39. package/dist-standalone/_deps/mldsa-wasm/package.json +46 -0
  40. package/dist-standalone/_deps/mldsa-wasm/types/mldsa.d.ts +30 -0
  41. package/dist-standalone/_deps/shared/cjs/errors.js +582 -0
  42. package/dist-standalone/_deps/shared/cjs/index.js +492 -0
  43. package/dist-standalone/_deps/shared/cjs/package.json +1 -0
  44. package/dist-standalone/_deps/shared/cjs/types.js +403 -0
  45. package/dist-standalone/_deps/shared/errors.d.ts +48 -0
  46. package/dist-standalone/_deps/shared/errors.d.ts.map +1 -0
  47. package/dist-standalone/_deps/shared/errors.js +192 -0
  48. package/dist-standalone/_deps/shared/errors.js.map +1 -0
  49. package/dist-standalone/_deps/shared/index.d.ts +4 -0
  50. package/dist-standalone/_deps/shared/index.d.ts.map +1 -0
  51. package/dist-standalone/_deps/shared/index.js +78 -0
  52. package/dist-standalone/_deps/shared/index.js.map +1 -0
  53. package/dist-standalone/_deps/shared/types.d.ts +1097 -0
  54. package/dist-standalone/_deps/shared/types.d.ts.map +1 -0
  55. package/dist-standalone/_deps/shared/types.js +89 -0
  56. package/dist-standalone/_deps/shared/types.js.map +1 -0
  57. package/dist-standalone/_deps/ux-helpers/cjs/errors.d.ts +115 -0
  58. package/dist-standalone/_deps/ux-helpers/cjs/errors.d.ts.map +1 -0
  59. package/dist-standalone/_deps/ux-helpers/cjs/errors.js +1 -0
  60. package/dist-standalone/_deps/ux-helpers/cjs/errors.js.map +1 -0
  61. package/dist-standalone/_deps/ux-helpers/cjs/index.d.ts +13 -0
  62. package/dist-standalone/_deps/ux-helpers/cjs/index.d.ts.map +1 -0
  63. package/dist-standalone/_deps/ux-helpers/cjs/index.js +1 -0
  64. package/dist-standalone/_deps/ux-helpers/cjs/index.js.map +1 -0
  65. package/dist-standalone/_deps/ux-helpers/cjs/package.json +1 -0
  66. package/dist-standalone/_deps/ux-helpers/cjs/pagination.d.ts +39 -0
  67. package/dist-standalone/_deps/ux-helpers/cjs/pagination.d.ts.map +1 -0
  68. package/dist-standalone/_deps/ux-helpers/cjs/pagination.js +83 -0
  69. package/dist-standalone/_deps/ux-helpers/cjs/pagination.js.map +1 -0
  70. package/dist-standalone/_deps/ux-helpers/cjs/progress.d.ts +99 -0
  71. package/dist-standalone/_deps/ux-helpers/cjs/progress.d.ts.map +1 -0
  72. package/dist-standalone/_deps/ux-helpers/cjs/progress.js +143 -0
  73. package/dist-standalone/_deps/ux-helpers/cjs/progress.js.map +1 -0
  74. package/dist-standalone/_deps/ux-helpers/cjs/search.d.ts +32 -0
  75. package/dist-standalone/_deps/ux-helpers/cjs/search.d.ts.map +1 -0
  76. package/dist-standalone/_deps/ux-helpers/cjs/search.js +119 -0
  77. package/dist-standalone/_deps/ux-helpers/cjs/search.js.map +1 -0
  78. package/dist-standalone/_deps/ux-helpers/cjs/types.d.ts +109 -0
  79. package/dist-standalone/_deps/ux-helpers/cjs/types.d.ts.map +1 -0
  80. package/dist-standalone/_deps/ux-helpers/cjs/types.js +8 -0
  81. package/dist-standalone/_deps/ux-helpers/cjs/types.js.map +1 -0
  82. package/dist-standalone/_deps/ux-helpers/errors.d.ts +115 -0
  83. package/dist-standalone/_deps/ux-helpers/errors.d.ts.map +1 -0
  84. package/dist-standalone/_deps/ux-helpers/errors.js +253 -0
  85. package/dist-standalone/_deps/ux-helpers/errors.js.map +1 -0
  86. package/dist-standalone/_deps/ux-helpers/index.d.ts +13 -0
  87. package/dist-standalone/_deps/ux-helpers/index.d.ts.map +1 -0
  88. package/dist-standalone/_deps/ux-helpers/index.js +16 -0
  89. package/dist-standalone/_deps/ux-helpers/index.js.map +1 -0
  90. package/dist-standalone/_deps/ux-helpers/pagination.d.ts +39 -0
  91. package/dist-standalone/_deps/ux-helpers/pagination.d.ts.map +1 -0
  92. package/dist-standalone/_deps/ux-helpers/pagination.js +79 -0
  93. package/dist-standalone/_deps/ux-helpers/pagination.js.map +1 -0
  94. package/dist-standalone/_deps/ux-helpers/progress.d.ts +99 -0
  95. package/dist-standalone/_deps/ux-helpers/progress.d.ts.map +1 -0
  96. package/dist-standalone/_deps/ux-helpers/progress.js +138 -0
  97. package/dist-standalone/_deps/ux-helpers/progress.js.map +1 -0
  98. package/dist-standalone/_deps/ux-helpers/search.d.ts +32 -0
  99. package/dist-standalone/_deps/ux-helpers/search.d.ts.map +1 -0
  100. package/dist-standalone/_deps/ux-helpers/search.js +116 -0
  101. package/dist-standalone/_deps/ux-helpers/search.js.map +1 -0
  102. package/dist-standalone/_deps/ux-helpers/types.d.ts +109 -0
  103. package/dist-standalone/_deps/ux-helpers/types.d.ts.map +1 -0
  104. package/dist-standalone/_deps/ux-helpers/types.js +7 -0
  105. package/dist-standalone/_deps/ux-helpers/types.js.map +1 -0
  106. package/dist-standalone/_deps/xchange/auto-accept.d.ts +127 -0
  107. package/dist-standalone/_deps/xchange/auto-accept.js +1 -0
  108. package/dist-standalone/_deps/xchange/cjs/auto-accept.js +1 -0
  109. package/dist-standalone/_deps/xchange/cjs/errors.js +1 -0
  110. package/dist-standalone/_deps/xchange/cjs/index.js +1 -0
  111. package/dist-standalone/_deps/xchange/cjs/invite-client.js +1 -0
  112. package/dist-standalone/_deps/xchange/cjs/lazy-init.js +1 -0
  113. package/dist-standalone/_deps/xchange/cjs/package.json +1 -0
  114. package/dist-standalone/_deps/xchange/cjs/trust-integration.js +1 -0
  115. package/dist-standalone/_deps/xchange/cjs/xchange.js +1 -0
  116. package/dist-standalone/_deps/xchange/errors.d.ts +69 -0
  117. package/dist-standalone/_deps/xchange/errors.js +1 -0
  118. package/dist-standalone/_deps/xchange/index.d.ts +15 -0
  119. package/dist-standalone/_deps/xchange/index.js +1 -0
  120. package/dist-standalone/_deps/xchange/invite-client.d.ts +178 -0
  121. package/dist-standalone/_deps/xchange/invite-client.js +1 -0
  122. package/dist-standalone/_deps/xchange/lazy-init.d.ts +176 -0
  123. package/dist-standalone/_deps/xchange/lazy-init.js +1 -0
  124. package/dist-standalone/_deps/xchange/trust-integration.d.ts +102 -0
  125. package/dist-standalone/_deps/xchange/trust-integration.js +1 -0
  126. package/dist-standalone/_deps/xchange/xchange.d.ts +60 -0
  127. package/dist-standalone/_deps/xchange/xchange.js +1 -0
  128. package/dist-standalone/_deps/xregistry/cjs/discovery.js +1 -0
  129. package/dist-standalone/_deps/xregistry/cjs/errors.js +1 -0
  130. package/dist-standalone/_deps/xregistry/cjs/index.js +1 -0
  131. package/dist-standalone/_deps/xregistry/cjs/package.json +1 -0
  132. package/dist-standalone/_deps/xregistry/cjs/registry.js +1 -0
  133. package/dist-standalone/_deps/xregistry/cjs/schema.js +1 -0
  134. package/dist-standalone/_deps/xregistry/cjs/types.js +1 -0
  135. package/dist-standalone/_deps/xregistry/discovery.d.ts +126 -0
  136. package/dist-standalone/_deps/xregistry/discovery.d.ts.map +1 -0
  137. package/dist-standalone/_deps/xregistry/discovery.js +1 -0
  138. package/dist-standalone/_deps/xregistry/discovery.js.map +1 -0
  139. package/dist-standalone/_deps/xregistry/errors.d.ts +41 -0
  140. package/dist-standalone/_deps/xregistry/errors.d.ts.map +1 -0
  141. package/dist-standalone/_deps/xregistry/errors.js +1 -0
  142. package/dist-standalone/_deps/xregistry/errors.js.map +1 -0
  143. package/dist-standalone/_deps/xregistry/index.d.ts +8 -0
  144. package/dist-standalone/_deps/xregistry/index.d.ts.map +1 -0
  145. package/dist-standalone/_deps/xregistry/index.js +1 -0
  146. package/dist-standalone/_deps/xregistry/index.js.map +1 -0
  147. package/dist-standalone/_deps/xregistry/registry.d.ts +85 -0
  148. package/dist-standalone/_deps/xregistry/registry.d.ts.map +1 -0
  149. package/dist-standalone/_deps/xregistry/registry.js +1 -0
  150. package/dist-standalone/_deps/xregistry/registry.js.map +1 -0
  151. package/dist-standalone/_deps/xregistry/schema.d.ts +81 -0
  152. package/dist-standalone/_deps/xregistry/schema.d.ts.map +1 -0
  153. package/dist-standalone/_deps/xregistry/schema.js +1 -0
  154. package/dist-standalone/_deps/xregistry/schema.js.map +1 -0
  155. package/dist-standalone/_deps/xregistry/types.d.ts +95 -0
  156. package/dist-standalone/_deps/xregistry/types.d.ts.map +1 -0
  157. package/dist-standalone/_deps/xregistry/types.js +1 -0
  158. package/dist-standalone/_deps/xregistry/types.js.map +1 -0
  159. package/dist-standalone/agent-call.d.ts +286 -0
  160. package/dist-standalone/agent-call.js +642 -0
  161. package/dist-standalone/agent-sdk.d.ts +207 -0
  162. package/dist-standalone/agent-sdk.js +328 -0
  163. package/dist-standalone/agent.d.ts +670 -0
  164. package/dist-standalone/agent.js +1529 -0
  165. package/dist-standalone/approval.d.ts +145 -0
  166. package/dist-standalone/approval.js +193 -0
  167. package/dist-standalone/auth.d.ts +75 -0
  168. package/dist-standalone/auth.js +219 -0
  169. package/dist-standalone/auto-accept.d.ts +102 -0
  170. package/dist-standalone/auto-accept.js +229 -0
  171. package/dist-standalone/backup-config.d.ts +150 -0
  172. package/dist-standalone/backup-config.js +201 -0
  173. package/dist-standalone/checkpoint.d.ts +125 -0
  174. package/dist-standalone/checkpoint.js +186 -0
  175. package/dist-standalone/cjs/agent-call.js +651 -0
  176. package/dist-standalone/cjs/agent-sdk.js +332 -0
  177. package/dist-standalone/cjs/agent.js +1566 -0
  178. package/dist-standalone/cjs/approval.js +199 -0
  179. package/dist-standalone/cjs/auth.js +225 -0
  180. package/dist-standalone/cjs/auto-accept.js +233 -0
  181. package/dist-standalone/cjs/backup-config.js +207 -0
  182. package/dist-standalone/cjs/checkpoint.js +193 -0
  183. package/dist-standalone/cjs/cli/init.js +487 -0
  184. package/dist-standalone/cjs/connect.js +312 -0
  185. package/dist-standalone/cjs/did-document.js +101 -0
  186. package/dist-standalone/cjs/did-privateme.js +130 -0
  187. package/dist-standalone/cjs/did-web.js +201 -0
  188. package/dist-standalone/cjs/discovery.js +462 -0
  189. package/dist-standalone/cjs/dual-mode.js +251 -0
  190. package/dist-standalone/cjs/email-templates.js +313 -0
  191. package/dist-standalone/cjs/email-transport.js +239 -0
  192. package/dist-standalone/cjs/envelope.js +510 -0
  193. package/dist-standalone/cjs/errors.js +562 -0
  194. package/dist-standalone/cjs/gateway-state.js +55 -0
  195. package/dist-standalone/cjs/gateway-transport.js +120 -0
  196. package/dist-standalone/cjs/guardrails.js +223 -0
  197. package/dist-standalone/cjs/http-compat.js +272 -0
  198. package/dist-standalone/cjs/identity.js +541 -0
  199. package/dist-standalone/cjs/index.js +224 -0
  200. package/dist-standalone/cjs/invitation.js +421 -0
  201. package/dist-standalone/cjs/invite.js +328 -0
  202. package/dist-standalone/cjs/key-agreement.js +246 -0
  203. package/dist-standalone/cjs/lazy-init.js +300 -0
  204. package/dist-standalone/cjs/mdns-discovery.js +202 -0
  205. package/dist-standalone/cjs/nonce-store.js +66 -0
  206. package/dist-standalone/cjs/package.json +3 -0
  207. package/dist-standalone/cjs/pairing-manager.js +223 -0
  208. package/dist-standalone/cjs/policy.js +320 -0
  209. package/dist-standalone/cjs/redis-nonce-store.js +76 -0
  210. package/dist-standalone/cjs/registry-middleware.js +50 -0
  211. package/dist-standalone/cjs/retry-transport.js +102 -0
  212. package/dist-standalone/cjs/security-policy.js +204 -0
  213. package/dist-standalone/cjs/split-channel.js +177 -0
  214. package/dist-standalone/cjs/subscription-proof.js +230 -0
  215. package/dist-standalone/cjs/succession.js +148 -0
  216. package/dist-standalone/cjs/transport.js +63 -0
  217. package/dist-standalone/cjs/trust-registry.js +742 -0
  218. package/dist-standalone/cjs/verify.js +25 -0
  219. package/dist-standalone/cjs/xfetch.js +252 -0
  220. package/dist-standalone/cli/init.d.ts +63 -0
  221. package/dist-standalone/cli/init.js +450 -0
  222. package/dist-standalone/connect.d.ts +143 -0
  223. package/dist-standalone/connect.js +274 -0
  224. package/dist-standalone/did-document.d.ts +65 -0
  225. package/dist-standalone/did-document.js +96 -0
  226. package/dist-standalone/did-privateme.d.ts +70 -0
  227. package/dist-standalone/did-privateme.js +121 -0
  228. package/dist-standalone/did-web.d.ts +73 -0
  229. package/dist-standalone/did-web.js +196 -0
  230. package/dist-standalone/discovery.d.ts +176 -0
  231. package/dist-standalone/discovery.js +458 -0
  232. package/dist-standalone/dual-mode.d.ts +145 -0
  233. package/dist-standalone/dual-mode.js +247 -0
  234. package/dist-standalone/email-templates.d.ts +41 -0
  235. package/dist-standalone/email-templates.js +309 -0
  236. package/dist-standalone/email-transport.d.ts +139 -0
  237. package/dist-standalone/email-transport.js +232 -0
  238. package/dist-standalone/envelope.d.ts +288 -0
  239. package/dist-standalone/envelope.js +497 -0
  240. package/dist-standalone/errors.d.ts +74 -0
  241. package/dist-standalone/errors.js +548 -0
  242. package/dist-standalone/gateway-state.d.ts +32 -0
  243. package/dist-standalone/gateway-state.js +51 -0
  244. package/dist-standalone/gateway-transport.d.ts +59 -0
  245. package/dist-standalone/gateway-transport.js +116 -0
  246. package/dist-standalone/guardrails.d.ts +136 -0
  247. package/dist-standalone/guardrails.js +216 -0
  248. package/dist-standalone/http-compat.d.ts +150 -0
  249. package/dist-standalone/http-compat.js +267 -0
  250. package/dist-standalone/identity.d.ts +176 -0
  251. package/dist-standalone/identity.js +516 -0
  252. package/dist-standalone/index.d.ts +83 -0
  253. package/dist-standalone/index.js +51 -0
  254. package/dist-standalone/invitation.d.ts +211 -0
  255. package/dist-standalone/invitation.js +415 -0
  256. package/dist-standalone/invite.d.ts +192 -0
  257. package/dist-standalone/invite.js +324 -0
  258. package/dist-standalone/key-agreement.d.ts +122 -0
  259. package/dist-standalone/key-agreement.js +236 -0
  260. package/dist-standalone/lazy-init.d.ts +167 -0
  261. package/dist-standalone/lazy-init.js +295 -0
  262. package/dist-standalone/mdns-discovery.d.ts +117 -0
  263. package/dist-standalone/mdns-discovery.js +195 -0
  264. package/dist-standalone/nonce-store.d.ts +39 -0
  265. package/dist-standalone/nonce-store.js +62 -0
  266. package/dist-standalone/package.json +11 -0
  267. package/dist-standalone/pairing-manager.d.ts +147 -0
  268. package/dist-standalone/pairing-manager.js +219 -0
  269. package/dist-standalone/policy.d.ts +150 -0
  270. package/dist-standalone/policy.js +315 -0
  271. package/dist-standalone/redis-nonce-store.d.ts +93 -0
  272. package/dist-standalone/redis-nonce-store.js +72 -0
  273. package/dist-standalone/registry-middleware.d.ts +38 -0
  274. package/dist-standalone/registry-middleware.js +47 -0
  275. package/dist-standalone/retry-transport.d.ts +76 -0
  276. package/dist-standalone/retry-transport.js +98 -0
  277. package/dist-standalone/security-policy.d.ts +146 -0
  278. package/dist-standalone/security-policy.js +198 -0
  279. package/dist-standalone/split-channel.d.ts +69 -0
  280. package/dist-standalone/split-channel.js +171 -0
  281. package/dist-standalone/subscription-proof.d.ts +103 -0
  282. package/dist-standalone/subscription-proof.js +224 -0
  283. package/dist-standalone/succession.d.ts +57 -0
  284. package/dist-standalone/succession.js +142 -0
  285. package/dist-standalone/transport.d.ts +50 -0
  286. package/dist-standalone/transport.js +59 -0
  287. package/dist-standalone/trust-registry.d.ts +286 -0
  288. package/dist-standalone/trust-registry.js +702 -0
  289. package/dist-standalone/verify.d.ts +16 -0
  290. package/dist-standalone/verify.js +16 -0
  291. package/dist-standalone/xfetch.d.ts +129 -0
  292. package/dist-standalone/xfetch.js +247 -0
  293. package/llms.txt +800 -0
  294. package/package.json +79 -0
  295. package/share1.dat +0 -0
@@ -0,0 +1,670 @@
1
+ import type { Result } from '@private.me/shared';
2
+ import type { AgentIdentity } from './identity.js';
3
+ import { generateSharedKey } from './envelope.js';
4
+ import type { TransportEnvelopeV4, AnyTransportEnvelope } from './envelope.js';
5
+ import type { NonceStore } from './nonce-store.js';
6
+ import type { SplitChannelConfig } from './split-channel.js';
7
+ import type { XailTransportAdapter, TransportError } from './transport.js';
8
+ import type { TrustRegistry } from './trust-registry.js';
9
+ import type { ProgressCallback } from '@private.me/ux-helpers';
10
+ import type { SecurityPolicy, SecurityLevel, SecurityDecision } from './security-policy.js';
11
+ /**
12
+ * Simplified options for Agent constructor (agent-first API).
13
+ *
14
+ * For full control, use Agent.create() with AgentCreateOptions.
15
+ */
16
+ export interface AgentOptions {
17
+ /**
18
+ * Identity mode:
19
+ * - 'persistent': Long-lived DID, registered with trust registry
20
+ * - 'ephemeral': Short-lived DID, auto-cleanup after TTL expires
21
+ */
22
+ readonly identity?: 'persistent' | 'ephemeral';
23
+ /**
24
+ * Time-to-live for ephemeral identities (milliseconds).
25
+ *
26
+ * After this duration, the identity is auto-deregistered and cleaned up.
27
+ * Only applies when identity === 'ephemeral'.
28
+ *
29
+ * Default: 3600000 (1 hour)
30
+ */
31
+ readonly identityTTL?: number;
32
+ /**
33
+ * Trust registry (instance or URL for HttpTrustRegistry).
34
+ *
35
+ * Optional for ephemeral identities (uses MemoryTrustRegistry by default).
36
+ * Required for persistent identities.
37
+ */
38
+ readonly registry?: TrustRegistry | string;
39
+ /**
40
+ * Transport adapter(s) for envelope delivery.
41
+ *
42
+ * Optional - uses HttpsTransportAdapter by default.
43
+ */
44
+ readonly transport?: XailTransportAdapter | XailTransportAdapter[];
45
+ /**
46
+ * Security policy for automatic risk-based Xorida activation.
47
+ *
48
+ * Uses DefaultSecurityPolicy if omitted.
49
+ */
50
+ readonly securityPolicy?: SecurityPolicy;
51
+ /**
52
+ * Enable post-quantum signatures (ML-DSA-65).
53
+ *
54
+ * Default: false
55
+ */
56
+ readonly postQuantumSig?: boolean;
57
+ /**
58
+ * XorIDA backup configuration for key splitting.
59
+ *
60
+ * Uses DEFAULT_BACKUP_CONFIG (k=2, n=3) if omitted.
61
+ */
62
+ readonly backupConfig?: import('./backup-config.js').BackupConfig;
63
+ }
64
+ /** Options for Agent.create() (full-featured API). */
65
+ export interface AgentCreateOptions {
66
+ /** Display name for the agent. */
67
+ readonly name: string;
68
+ /** Trust registry (instance or URL for HttpTrustRegistry). */
69
+ readonly registry: TrustRegistry;
70
+ /**
71
+ * Transport adapter(s) for envelope delivery.
72
+ *
73
+ * For split-channel security, provide one transport per share channel.
74
+ * Each share routes to transports[shareIndex % transports.length].
75
+ * With a single transport, all shares travel the same channel —
76
+ * data is split but channel separation is not achieved.
77
+ */
78
+ readonly transport: XailTransportAdapter | XailTransportAdapter[];
79
+ /** NonceStore for replay prevention. Uses MemoryNonceStore if omitted. */
80
+ readonly nonceStore?: NonceStore;
81
+ /** Scopes this agent requests. */
82
+ readonly scopes?: string[];
83
+ /** Timestamp validity window in ms. Default 30 000 (30 s). */
84
+ readonly timestampWindowMs?: number;
85
+ /** Enable ML-DSA-65 post-quantum signatures (v3 envelopes). Default: false. */
86
+ readonly postQuantumSig?: boolean;
87
+ /** Advertise Xchange mode support. Default: false. When true, peers MAY send Xchange envelopes (faster, single security layer). */
88
+ readonly xchange?: boolean;
89
+ /**
90
+ * Security policy for automatic risk-based Xorida activation.
91
+ *
92
+ * Uses DefaultSecurityPolicy if omitted. Enterprise users can provide
93
+ * EnterpriseSecurityPolicy with custom rules.
94
+ */
95
+ readonly securityPolicy?: SecurityPolicy;
96
+ }
97
+ /** Options for agent.send(). */
98
+ export interface AgentSendOptions {
99
+ /** Recipient DID. */
100
+ readonly to: string;
101
+ /** Payload (serialized to JSON). */
102
+ readonly payload: unknown;
103
+ /** Permission scope. */
104
+ readonly scope: string;
105
+ /**
106
+ * Action being performed (e.g., 'transfer', 'execute', 'send').
107
+ *
108
+ * Used by security policy to determine when to auto-apply XorIDA split-channel.
109
+ * If omitted, defaults to 'send'.
110
+ */
111
+ readonly action?: string;
112
+ /**
113
+ * Security level override.
114
+ *
115
+ * - 'auto' (default): Let security policy decide based on action + params
116
+ * - 'standard': Force standard encrypted transport (disable auto-upgrade)
117
+ * - 'high': Force multi-party approval (3 shares, 2-of-3 threshold)
118
+ * - 'critical': Force critical security (5 shares, 3-of-5 threshold)
119
+ *
120
+ * Most users should use 'auto' and let the system decide.
121
+ */
122
+ readonly security?: SecurityLevel;
123
+ /**
124
+ * Enable XorIDA split-channel.
125
+ *
126
+ * @deprecated Use `security: 'high'` instead. This field is maintained for
127
+ * backward compatibility but will be removed in v3.0.
128
+ */
129
+ readonly splitChannel?: boolean;
130
+ /**
131
+ * Split-channel configuration (totalShares, threshold).
132
+ *
133
+ * @deprecated Security policy now determines share configuration automatically.
134
+ * This field is maintained for backward compatibility but will be removed in v3.0.
135
+ */
136
+ readonly splitChannelConfig?: SplitChannelConfig;
137
+ /**
138
+ * Use Xchange mode (faster, single security layer instead of three).
139
+ *
140
+ * @deprecated Set `payload.xchange: true` instead. The security policy will
141
+ * detect this and apply Xchange mode automatically.
142
+ */
143
+ readonly xchange?: boolean;
144
+ /** Optional progress callback for long-running operations. */
145
+ readonly onProgress?: ProgressCallback;
146
+ }
147
+ /** Verified message from receive/middleware. */
148
+ export interface AgentMessage {
149
+ readonly sender: string;
150
+ readonly payload: unknown;
151
+ readonly scope: string;
152
+ readonly timestamp: number;
153
+ /** Protocol metadata for viral exposure */
154
+ readonly metadata?: {
155
+ readonly protocol: string;
156
+ readonly documentationUrl: string;
157
+ };
158
+ }
159
+ /** Options for agent.receive(). */
160
+ export interface AgentReceiveOptions {
161
+ /**
162
+ * When true, accept signed-but-unencrypted envelopes as cleartext.
163
+ *
164
+ * If decryption fails, the payload is parsed as plaintext JSON instead
165
+ * of returning a decryption error. Useful for IoT gateways that accept
166
+ * both encrypted and signed-only telemetry.
167
+ */
168
+ readonly allowCleartext?: boolean;
169
+ /** Optional progress callback for long-running operations. */
170
+ readonly onProgress?: ProgressCallback;
171
+ }
172
+ /** Parsed error detail with step context. */
173
+ export interface AgentErrorDetail {
174
+ /** Base error code (e.g. 'TIMESTAMP_EXPIRED'). */
175
+ readonly code: string;
176
+ /** Sub-code if present (e.g. 'DECRYPTION' from 'DECRYPT_FAILED:DECRYPTION'). */
177
+ readonly subCode?: string;
178
+ /** Human-readable diagnostic detail from the verification step. */
179
+ readonly step?: string;
180
+ }
181
+ /**
182
+ * Parse an AgentError string into structured detail.
183
+ *
184
+ * Splits colon-separated error codes into base code and sub-code.
185
+ *
186
+ * @param error - An AgentError string (e.g. 'DECRYPT_FAILED:KEY_AGREEMENT').
187
+ * @returns Parsed error detail.
188
+ */
189
+ export declare function parseAgentError(error: string): AgentErrorDetail;
190
+ /** Agent-level error codes. Sub-codes give precise failure context. */
191
+ export type AgentError = TransportError | 'IDENTITY_FAILED' | 'IDENTITY_FAILED:KEYGEN' | 'REGISTRATION_FAILED' | 'REGISTRATION_FAILED:ALREADY_REGISTERED' | 'REGISTRATION_FAILED:NETWORK_ERROR' | 'RECIPIENT_NOT_FOUND' | 'RECIPIENT_REVOKED' | 'KEY_AGREEMENT_FAILED' | 'KEY_AGREEMENT_FAILED:RECIPIENT_HAS_NO_X25519_KEY' | 'ENVELOPE_FAILED' | 'ENVELOPE_FAILED:ENCRYPT' | 'ENVELOPE_FAILED:SIGN' | 'ENVELOPE_FAILED:SPLIT' | 'VERIFICATION_FAILED' | 'VERIFICATION_FAILED:UNSUPPORTED_VERSION' | 'VERIFICATION_FAILED:DID_NOT_IN_REGISTRY' | 'VERIFICATION_FAILED:KEY_IMPORT_FAILED' | 'VERIFICATION_FAILED:SIGNATURE_MISMATCH' | 'VERIFICATION_FAILED:PQ_KEY_MISSING' | 'VERIFICATION_FAILED:PQ_SIGNATURE_MISMATCH' | 'ENVELOPE_FAILED:PQ_KEY_MISSING' | 'REPLAY_DETECTED' | 'SCOPE_DENIED' | 'RECEIVER_SCOPE_DENIED' | 'TIMESTAMP_EXPIRED' | 'DECRYPT_FAILED' | 'DECRYPT_FAILED:KEY_AGREEMENT' | 'DECRYPT_FAILED:NO_EPHEMERAL_KEY' | 'DECRYPT_FAILED:DECRYPTION' | 'DECRYPT_FAILED:PARSE' | 'SEND_FAILED:BELOW_THRESHOLD';
192
+ /**
193
+ * Top-level Xail Agent SDK API.
194
+ *
195
+ * Matches xail.io/sdk specification:
196
+ * - Agent.create({ name, registry }) — generate identity + register
197
+ * - agent.send({ to, payload, scope }) — encrypt, sign, deliver
198
+ * - agent.receive(envelope) — verify, decrypt, return message
199
+ */
200
+ export declare class Agent {
201
+ readonly identity: AgentIdentity;
202
+ readonly name: string;
203
+ private readonly registry;
204
+ private readonly transports;
205
+ private readonly nonceStore;
206
+ private readonly timestampWindowMs;
207
+ private readonly securityPolicy;
208
+ private readonly backupConfig;
209
+ /** Accumulates split-channel shares by groupId until threshold is met. */
210
+ private readonly shareAccumulator;
211
+ /** Diagnostic detail from the last failed verification step. */
212
+ private lastDetail;
213
+ /** Last security decision made by the policy (for debugging/logging). */
214
+ private lastSecurityDecision?;
215
+ /** Timer for ephemeral agent auto-cleanup. */
216
+ private cleanupTimer?;
217
+ /**
218
+ * Human-readable diagnostic from the last failed receive/verify call.
219
+ *
220
+ * Populated during verification with context like age vs max window.
221
+ * Empty string if no error has occurred or after a successful call.
222
+ */
223
+ get lastErrorDetail(): string;
224
+ /**
225
+ * Last security decision made by the security policy.
226
+ *
227
+ * Shows which security mode was selected and why. Useful for debugging
228
+ * and understanding when/why Xorida split-channel was activated.
229
+ *
230
+ * Returns undefined if no send() has been called yet.
231
+ */
232
+ get lastSecurity(): SecurityDecision | undefined;
233
+ private constructor();
234
+ /** The agent's DID. */
235
+ get did(): string;
236
+ /**
237
+ * Check whether the runtime supports the SDK's crypto requirements.
238
+ *
239
+ * Verifies that `crypto.subtle` is available and supports Ed25519 +
240
+ * AES-256-GCM. Call this before lazy-loading the SDK in middleware
241
+ * to avoid failing on the first `Agent.create()` call.
242
+ *
243
+ * @returns `true` if the runtime has the required Web Crypto APIs.
244
+ */
245
+ static isSupported(): boolean;
246
+ /**
247
+ * Create an Agent from a persisted identity (skips keygen + registration).
248
+ *
249
+ * Use this with importFromPKCS8 or importIdentity to restore a
250
+ * previously created agent across process restarts.
251
+ *
252
+ * @param identity - A previously exported AgentIdentity.
253
+ * @param opts - Agent options (registry, transport, etc.).
254
+ * @returns Agent instance or error.
255
+ */
256
+ static fromIdentity(identity: AgentIdentity, opts: Omit<AgentCreateOptions, 'name'> & {
257
+ name?: string;
258
+ backupConfig?: import('./backup-config.js').BackupConfig;
259
+ }): Promise<Result<Agent, AgentError>>;
260
+ /**
261
+ * Build an Agent from pre-constructed parts (synchronous).
262
+ *
263
+ * Unlike `create()` this does NOT generate keys or register with the
264
+ * registry — the caller is responsible for both. Useful when identity
265
+ * is provisioned in a factory step, registration is handled by an
266
+ * external system, or transport is wired up at runtime.
267
+ *
268
+ * @param identity - A previously generated or imported AgentIdentity.
269
+ * @param registry - Trust registry the agent will query for peers.
270
+ * @param transport - Transport adapter for envelope delivery.
271
+ * @param opts - Optional overrides (name, nonceStore, timestampWindowMs).
272
+ * @returns A fully wired Agent instance.
273
+ */
274
+ static fromParts(identity: AgentIdentity, registry: TrustRegistry, transport: XailTransportAdapter | XailTransportAdapter[], opts?: {
275
+ name?: string;
276
+ nonceStore?: NonceStore;
277
+ timestampWindowMs?: number;
278
+ securityPolicy?: SecurityPolicy;
279
+ backupConfig?: import('./backup-config.js').BackupConfig;
280
+ }): Agent;
281
+ /**
282
+ * Create an Agent from a deterministic 32-byte seed.
283
+ *
284
+ * Uses HKDF-SHA256 to derive Ed25519 + X25519 keys from the seed.
285
+ * The same seed always produces the same DID and keys. Skips registry
286
+ * registration — the caller is responsible for registering externally.
287
+ *
288
+ * Ideal for IoT: factory burns seed → field deploys → boot derives identity.
289
+ *
290
+ * @param seed - Exactly 32 bytes of high-entropy key material.
291
+ * @param opts - Agent options (registry, transport, etc.).
292
+ * @returns Agent instance or error.
293
+ */
294
+ static fromSeed(seed: Uint8Array, opts: Omit<AgentCreateOptions, 'name'> & {
295
+ name?: string;
296
+ backupConfig?: import('./backup-config.js').BackupConfig;
297
+ }): Promise<Result<Agent, AgentError>>;
298
+ /**
299
+ * Create a lazy agent that initializes on first use (zero-click onboarding).
300
+ *
301
+ * Defers invite acceptance and identity generation until first send/receive.
302
+ * Reads invite code from XBIND_INVITE_CODE environment variable.
303
+ * Auto-accepts invite and configures registry/transport automatically.
304
+ *
305
+ * @param config - Lazy agent configuration (name required).
306
+ * @returns Lazy agent wrapper (synchronous).
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * // Environment: XBIND_INVITE_CODE=XBD-abc123, XBIND_AUTO_ACCEPT=true
311
+ *
312
+ * // Synchronous construction (no await):
313
+ * const agent = Agent.lazy({ name: 'my-service' });
314
+ *
315
+ * // Auto-accept happens on first send/receive:
316
+ * await agent.send({
317
+ * to: 'did:key:z6Mk...',
318
+ * payload: { action: 'test' },
319
+ * scope: 'test',
320
+ * });
321
+ * ```
322
+ */
323
+ static lazy(config: {
324
+ name: string;
325
+ inviteCode?: string;
326
+ endpoint?: string;
327
+ postQuantumSig?: boolean;
328
+ xchange?: boolean;
329
+ }): Promise<import('./lazy-init.js').LazyAgent>;
330
+ /**
331
+ * Check whether this agent is fully initialized and ready to send/receive.
332
+ *
333
+ * Returns `true` if identity, registry, and transport are all present.
334
+ * Construction always produces a ready agent (invalid inputs cause the
335
+ * factory to return an error instead), so this is primarily useful in
336
+ * middleware that lazily initializes agents and needs a guard.
337
+ *
338
+ * @returns `true` if the agent can send and receive messages.
339
+ */
340
+ isReady(): boolean;
341
+ /** Create a new agent, generate identity, register with trust registry. */
342
+ static create(opts: AgentCreateOptions): Promise<Result<Agent, AgentError>>;
343
+ /**
344
+ * Quickstart: create an agent with zero configuration.
345
+ *
346
+ * Creates an ephemeral agent with auto-cleanup after 1 hour. No policy
347
+ * restrictions by default (allow all operations). Ideal for getting
348
+ * started, prototyping, and simple use cases.
349
+ *
350
+ * Uses in-memory registry and default transport. Identity auto-expires
351
+ * and is deregistered after TTL.
352
+ *
353
+ * @param opts - Optional configuration (name only)
354
+ * @returns Agent instance (throws on error for simpler API)
355
+ *
356
+ * @example
357
+ * ```ts
358
+ * // Zero config (ephemeral identity, 1-hour TTL):
359
+ * const agent = await Agent.quickstart();
360
+ *
361
+ * // With custom name:
362
+ * const agent = await Agent.quickstart({ name: 'my-service' });
363
+ *
364
+ * // Agent is ready to use immediately:
365
+ * await agent.send({
366
+ * to: 'did:key:z6Mk...',
367
+ * payload: { action: 'test' },
368
+ * scope: 'test',
369
+ * });
370
+ * ```
371
+ */
372
+ static quickstart(opts?: {
373
+ /** Agent name (default: auto-generated) */
374
+ name?: string;
375
+ }): Promise<Agent>;
376
+ /**
377
+ * Create agent from simplified options (async factory).
378
+ *
379
+ * This is the async-safe way to construct agents with AgentOptions.
380
+ *
381
+ * @param options - Agent configuration
382
+ * @returns Agent instance
383
+ *
384
+ * @example
385
+ * ```typescript
386
+ * import { Agent } from '@private.me/xbind';
387
+ *
388
+ * // Ephemeral agent (auto-cleanup after 1 hour)
389
+ * const agent = await Agent.from({
390
+ * identity: 'ephemeral',
391
+ * identityTTL: 3600, // seconds
392
+ * });
393
+ *
394
+ * // Use the agent
395
+ * await agent.send({ to, payload, scope: 'read' });
396
+ * ```
397
+ */
398
+ static from(options?: AgentOptions): Promise<Agent>;
399
+ /** Send a message to a recipient. */
400
+ send(opts: AgentSendOptions): Promise<Result<void, AgentError>>;
401
+ /**
402
+ * Verify and decrypt an incoming encrypted envelope (v1 or v2).
403
+ *
404
+ * @param envelope - Incoming transport envelope.
405
+ * @param opts - Optional receive options (e.g. allowCleartext).
406
+ */
407
+ receive(envelope: AnyTransportEnvelope, opts?: AgentReceiveOptions): Promise<Result<AgentMessage, AgentError>>;
408
+ /**
409
+ * Verify only the signature on an envelope without consuming the nonce.
410
+ *
411
+ * Does NOT check timestamp, nonce, or scope. Use this for pre-screening
412
+ * or audit logging where you need to confirm the sender but don't want
413
+ * to consume replay-prevention state.
414
+ *
415
+ * @param envelope - The envelope to verify.
416
+ * @returns `{ sender, valid }` or error if the DID cannot be resolved.
417
+ */
418
+ verifySignature(envelope: AnyTransportEnvelope): Promise<Result<{
419
+ sender: string;
420
+ valid: boolean;
421
+ }, AgentError>>;
422
+ /**
423
+ * Export the raw 32-byte private key seeds for both Ed25519 and X25519.
424
+ *
425
+ * These are the raw private key bytes extracted from PKCS8, NOT the
426
+ * original HKDF seed (that derivation is one-way). Use these for
427
+ * persistence or cross-device transfer.
428
+ *
429
+ * @returns Two 32-byte Uint8Arrays or error.
430
+ */
431
+ exportSeeds(): Promise<Result<{
432
+ ed25519: Uint8Array;
433
+ x25519: Uint8Array;
434
+ mlKemSecretKey?: Uint8Array;
435
+ mlKemPublicKey?: Uint8Array;
436
+ }, AgentError>>;
437
+ /**
438
+ * Split a cryptographic key into backup shares using XorIDA.
439
+ *
440
+ * Uses the agent's backup configuration (default: k=2, n=3).
441
+ * Any `threshold` shares can reconstruct the original key.
442
+ * Each share reveals zero information (information-theoretic security).
443
+ *
444
+ * @param key - The key to split (32 or 64 bytes typical).
445
+ * @returns Array of backup shares or error.
446
+ *
447
+ * @example
448
+ * ```typescript
449
+ * // Generate a key and split it
450
+ * const key = crypto.getRandomValues(new Uint8Array(32));
451
+ * const shares = await agent.splitKey(key);
452
+ *
453
+ * if (shares.ok) {
454
+ * // Store shares in separate locations
455
+ * shares.value.forEach((share, i) => {
456
+ * storeShare(`backup-${i}.json`, JSON.stringify(share));
457
+ * });
458
+ * }
459
+ * ```
460
+ */
461
+ splitKey(key: Uint8Array): Promise<Result<import('./backup-config.js').BackupShare[], AgentError>>;
462
+ /**
463
+ * Reconstruct a cryptographic key from backup shares.
464
+ *
465
+ * Requires at least `threshold` shares. Verifies HMAC before returning
466
+ * the reconstructed key to prevent tampering.
467
+ *
468
+ * @param shares - Backup shares (must be >= threshold).
469
+ * @returns Reconstructed key or error.
470
+ *
471
+ * @example
472
+ * ```typescript
473
+ * // Load shares from storage
474
+ * const share0 = JSON.parse(loadShare('backup-0.json'));
475
+ * const share1 = JSON.parse(loadShare('backup-1.json'));
476
+ *
477
+ * // Reconstruct from any 2 shares (threshold=2)
478
+ * const key = await agent.reconstructKey([share0, share1]);
479
+ *
480
+ * if (key.ok) {
481
+ * // Use reconstructed key
482
+ * console.log('Key recovered:', key.value);
483
+ * }
484
+ * ```
485
+ */
486
+ reconstructKey(shares: import('./backup-config.js').BackupShare[]): Promise<Result<Uint8Array, AgentError>>;
487
+ /**
488
+ * Verify a signed (unencrypted) envelope and return the message.
489
+ *
490
+ * Use for envelopes created with createSignedEnvelope().
491
+ * Verifies signature, timestamp, nonce, and scope — skips decryption.
492
+ *
493
+ * @param envelope - A signed (unencrypted) transport envelope.
494
+ * @returns Verified message or error with sub-code.
495
+ */
496
+ receiveSigned(envelope: AnyTransportEnvelope): Promise<Result<AgentMessage, AgentError>>;
497
+ /**
498
+ * Discover available tools in the registry.
499
+ *
500
+ * Query xRegistry for tools matching the given service prefix or capability.
501
+ * Returns tool metadata including name, description, schema, and trust level.
502
+ *
503
+ * @param service - Optional service prefix to filter by (e.g., "payments")
504
+ * @returns Array of tool metadata or empty array if none found
505
+ *
506
+ * @example
507
+ * ```typescript
508
+ * import { Agent } from '@private.me/xbind';
509
+ * import { ToolRegistry } from '@private.me/xregistry';
510
+ * import { setToolRegistry } from '@private.me/xbind/agent-call';
511
+ *
512
+ * const registry = new ToolRegistry();
513
+ * registry.register({
514
+ * name: 'payments:createCharge',
515
+ * description: 'Create a payment charge',
516
+ * schema: { type: 'object', properties: { amount: { type: 'number' } } },
517
+ * trustLevel: 'verified',
518
+ * endpoint: 'https://api.stripe.com/v1/charges',
519
+ * capabilities: ['payment', 'charge']
520
+ * });
521
+ *
522
+ * setToolRegistry(registry);
523
+ *
524
+ * const agent = await Agent.quickstart();
525
+ *
526
+ * // Discover all payment tools
527
+ * const tools = await agent.discover('payments');
528
+ * console.log(tools); // [{ name: 'payments:createCharge', ... }]
529
+ *
530
+ * // Discover all tools
531
+ * const allTools = await agent.discover();
532
+ * ```
533
+ */
534
+ discover(service?: string): Promise<readonly import('@private.me/xregistry').ToolMetadata[]>;
535
+ /** Generate an Express-compatible middleware handler. */
536
+ middleware(): (req: {
537
+ body?: unknown;
538
+ }, res: {
539
+ status: (code: number) => {
540
+ json: (data: unknown) => void;
541
+ };
542
+ }, next: (err?: unknown) => void) => Promise<void>;
543
+ /**
544
+ * Cleanup resources (timers, handlers, etc.)
545
+ *
546
+ * Call this in tests or when disposing an agent to prevent timer leaks.
547
+ * Clears the ephemeral identity auto-cleanup timer if present.
548
+ */
549
+ cleanup(): void;
550
+ /**
551
+ * Dispose of agent resources (alias for cleanup)
552
+ *
553
+ * Provided for compatibility with test cleanup patterns.
554
+ */
555
+ dispose(): void;
556
+ /**
557
+ * Attempt sender-side key agreement.
558
+ *
559
+ * If both sides support ML-KEM-768, uses hybrid (X25519 + ML-KEM-768).
560
+ * Otherwise falls back to X25519-only ECDH.
561
+ * Returns null if recipient has no X25519 key registered.
562
+ * Also returns whether recipient supports ML-DSA-65 for v3 envelopes.
563
+ */
564
+ private trySenderECDH;
565
+ /** Send with ECDH forward secrecy (ephemeral key in envelope). */
566
+ private sendWithECDH;
567
+ /** Send with hybrid KEM (X25519 + ML-KEM-768) via v2 envelope. */
568
+ private sendWithHybrid;
569
+ /** Send with hybrid KEM + dual signatures via v3 envelope. */
570
+ private sendWithHybridV3;
571
+ private sendDirect;
572
+ /**
573
+ * Check whether the recipient supports Xchange (XorIDA key transport).
574
+ *
575
+ * @param recipientDid - Recipient DID to check.
576
+ * @returns True if recipient has xchange: true in registry.
577
+ */
578
+ private canUseXchange;
579
+ /**
580
+ * Send via Xchange mode: random key + AES-GCM encrypt, bundle, XorIDA split, v4 envelopes.
581
+ *
582
+ * Opt-in performance mode. No KEM, no key agreement — the random key is
583
+ * embedded in the bundle and split across channels. Single security layer
584
+ * (information-theoretic) + Ed25519 authentication. ~180x faster than V3.
585
+ */
586
+ private sendXchange;
587
+ /**
588
+ * Split plaintext via XorIDA and send each share as a separate V3 envelope.
589
+ *
590
+ * Default split-channel path with three independent cryptographic layers:
591
+ * XorIDA payload split, hybrid PQ KEM, and dual signatures.
592
+ * Returns ok() if at least threshold sends succeed.
593
+ */
594
+ private sendSplitChannel;
595
+ /**
596
+ * Create and send an envelope for each share independently.
597
+ *
598
+ * Routes share[i] to transports[i % transports.length] for channel separation.
599
+ */
600
+ private sendShareEnvelopes;
601
+ /**
602
+ * Receive and accumulate a split-channel share envelope.
603
+ *
604
+ * Verifies the envelope, extracts share metadata, accumulates shares.
605
+ * When threshold is reached, reconstructs the original plaintext.
606
+ *
607
+ * @param envelope - A share envelope with split-channel metadata
608
+ * @returns AgentMessage if threshold met, null if more shares needed
609
+ */
610
+ receiveSplitShare(envelope: AnyTransportEnvelope): Promise<Result<AgentMessage | null, AgentError>>;
611
+ /**
612
+ * Receive and accumulate a v4 Xchange share envelope.
613
+ *
614
+ * Verifies Ed25519 signature, extracts raw share data (no decryption —
615
+ * the XorIDA share IS the payload). When threshold is reached,
616
+ * reconstructs and decrypts via Xchange.
617
+ *
618
+ * @param envelope - A v4 Xchange envelope with share metadata.
619
+ * @returns AgentMessage if threshold met, null if more shares needed.
620
+ */
621
+ receiveXchangeShare(envelope: TransportEnvelopeV4): Promise<Result<AgentMessage | null, AgentError>>;
622
+ /**
623
+ * Accumulate a Xchange share and attempt reconstruction + decryption.
624
+ *
625
+ * When threshold is met:
626
+ * 1. Reconstruct padded bundle from XorIDA shares
627
+ * 2. Verify HMAC (BEFORE decrypt — CRITICAL)
628
+ * 3. Unpad → extract bundle → xchangeDecrypt → plaintext
629
+ */
630
+ private accumulateXchangeShare;
631
+ /**
632
+ * Accumulate a share and attempt reconstruction when threshold is met.
633
+ */
634
+ private accumulateShare;
635
+ /**
636
+ * Common envelope verification: version, timestamp, nonce, DID, signature, scope.
637
+ *
638
+ * Used by receive(), receiveSigned(), and receiveRaw() to avoid duplication.
639
+ * Consumes the nonce on success (replay prevention).
640
+ */
641
+ private verifyEnvelope;
642
+ /**
643
+ * Verify and decrypt an envelope, returning raw text (no JSON parse).
644
+ * Used by receiveSplitShare to get the raw decrypted share data.
645
+ */
646
+ private receiveRaw;
647
+ /**
648
+ * Send email invitation to establish connection.
649
+ *
650
+ * Uses email transport to send branded invitation with one-click acceptance.
651
+ * Requires EmailTransport to be configured in agent options.
652
+ *
653
+ * @param opts - Invitation options
654
+ * @returns Result with success status
655
+ *
656
+ * @example
657
+ * ```ts
658
+ * await agent.invite({
659
+ * to: 'fulfillment@acme.com',
660
+ * message: 'Connect our payment systems'
661
+ * });
662
+ * ```
663
+ */
664
+ invite(opts: {
665
+ to: string;
666
+ message?: string;
667
+ template?: string;
668
+ }): Promise<Result<void, AgentError>>;
669
+ }
670
+ export { generateSharedKey };