@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,274 @@
1
+ /**
2
+ * @module connect
3
+ * High-level connect() API for zero-config XBind connections.
4
+ *
5
+ * Enables: `const service = await connect('payments-service')`
6
+ *
7
+ * Combines:
8
+ * - Service discovery
9
+ * - Trust verification
10
+ * - Agent creation
11
+ * - Connection establishment
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { connect } from '@private.me/xbind';
16
+ *
17
+ * // Connect by name (uses registry):
18
+ * const payments = await connect('payments-service');
19
+ *
20
+ * // Connect by domain (uses .well-known):
21
+ * const payments = await connect('payments.example.com');
22
+ *
23
+ * // Connect by URL (direct):
24
+ * const payments = await connect('https://api.payments.com/xbind');
25
+ *
26
+ * // Use the connection:
27
+ * await payments.send({
28
+ * to: payments.did,
29
+ * payload: { action: 'createCharge', amount: 100 },
30
+ * scope: 'payments',
31
+ * });
32
+ * ```
33
+ */
34
+ import { ok, err } from"./_deps/shared/index.js";
35
+ import { fromBase64, toBase64 } from"./_deps/crypto/index.js";
36
+ import { Agent } from './agent.js';
37
+ import { ServiceDiscovery } from './discovery.js';
38
+ import { HttpsTransportAdapter } from './transport.js';
39
+ import { MemoryTrustRegistry } from './trust-registry.js';
40
+ import { importPublicKey } from './identity.js';
41
+ /**
42
+ * Connect error codes.
43
+ */
44
+ export var ConnectErrorCode;
45
+ (function (ConnectErrorCode) {
46
+ ConnectErrorCode["DISCOVERY_FAILED"] = "CONNECT_DISCOVERY_FAILED";
47
+ ConnectErrorCode["AGENT_CREATION_FAILED"] = "CONNECT_AGENT_CREATION_FAILED";
48
+ ConnectErrorCode["TRUST_VERIFICATION_FAILED"] = "CONNECT_TRUST_VERIFICATION_FAILED";
49
+ ConnectErrorCode["INVALID_SERVICE_INFO"] = "CONNECT_INVALID_SERVICE_INFO";
50
+ })(ConnectErrorCode || (ConnectErrorCode = {}));
51
+ /**
52
+ * Connect to a service with zero configuration.
53
+ *
54
+ * @param nameOrUrl - Service name, domain, or URL
55
+ * @param options - Connection options
56
+ * @returns Connection or error
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * // Minimal:
61
+ * const connection = await connect('payments-service');
62
+ * if (connection.ok) {
63
+ * await connection.value.agent.send({
64
+ * to: connection.value.did,
65
+ * payload: { action: 'test' },
66
+ * scope: 'test',
67
+ * });
68
+ * }
69
+ *
70
+ * // With options:
71
+ * const connection = await connect('payments-service', {
72
+ * name: 'billing-service',
73
+ * xchange: true, // Use faster Xchange mode
74
+ * splitChannel: true, // Use split-channel by default
75
+ * });
76
+ * ```
77
+ */
78
+ export async function connect(nameOrUrl, options = {}) {
79
+ // Step 1: Discover service
80
+ const discovery = options.discovery || new ServiceDiscovery();
81
+ const serviceResult = await discovery.discover(nameOrUrl);
82
+ if (!serviceResult.ok) {
83
+ return err({
84
+ code: ConnectErrorCode.DISCOVERY_FAILED,
85
+ message: `Failed to discover service: ${serviceResult.error.message}`,
86
+ hint: serviceResult.error.hint,
87
+ cause: serviceResult.error,
88
+ });
89
+ }
90
+ const service = serviceResult.value;
91
+ // Step 2: Validate service info
92
+ if (!service.did || !service.endpoint || !service.publicKey) {
93
+ return err({
94
+ code: ConnectErrorCode.INVALID_SERVICE_INFO,
95
+ message: 'Service info missing required fields (did, endpoint, publicKey)',
96
+ hint: 'Service must provide complete metadata',
97
+ });
98
+ }
99
+ // Step 3: Create trust registry and add service
100
+ const registry = options.registry || new MemoryTrustRegistry();
101
+ try {
102
+ // Import public key (convert from base64 string)
103
+ const publicKeyBytes = fromBase64(service.publicKey);
104
+ const publicKeyResult = await importPublicKey(publicKeyBytes);
105
+ if (!publicKeyResult.ok) {
106
+ return err({
107
+ code: ConnectErrorCode.TRUST_VERIFICATION_FAILED,
108
+ message: 'Invalid service public key',
109
+ cause: publicKeyResult.error,
110
+ });
111
+ }
112
+ // Add to trust registry
113
+ await registry.add({
114
+ did: service.did,
115
+ publicKey: publicKeyResult.value,
116
+ x25519PublicKey: service.x25519PublicKey
117
+ ? await importPublicKey(fromBase64(service.x25519PublicKey)).then(r => r.ok ? r.value : undefined)
118
+ : undefined,
119
+ mlKemPublicKey: service.mlKemPublicKey
120
+ ? fromBase64(service.mlKemPublicKey)
121
+ : undefined,
122
+ });
123
+ }
124
+ catch (error) {
125
+ return err({
126
+ code: ConnectErrorCode.TRUST_VERIFICATION_FAILED,
127
+ message: 'Failed to verify service public key',
128
+ cause: error,
129
+ });
130
+ }
131
+ // Step 4: Create transport
132
+ const transport = options.transport || new HttpsTransportAdapter({
133
+ baseUrl: service.endpoint,
134
+ });
135
+ // Step 5: Create agent
136
+ const agentName = options.name || `client-${Date.now()}`;
137
+ const agentOptions = {
138
+ name: agentName,
139
+ registry,
140
+ transport,
141
+ xchange: options.xchange,
142
+ postQuantumSig: options.postQuantumSig,
143
+ };
144
+ const agentResult = await Agent.create(agentOptions);
145
+ if (!agentResult.ok) {
146
+ return err({
147
+ code: ConnectErrorCode.AGENT_CREATION_FAILED,
148
+ message: 'Failed to create agent',
149
+ cause: agentResult.error,
150
+ });
151
+ }
152
+ // Step 6: Return connection
153
+ return ok({
154
+ agent: agentResult.value,
155
+ service,
156
+ did: service.did,
157
+ endpoint: service.endpoint,
158
+ });
159
+ }
160
+ /**
161
+ * Accept an invite and establish connection.
162
+ *
163
+ * @param inviteUrl - Invite URL
164
+ * @param options - Connection options
165
+ * @returns Connection or error
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * const connection = await acceptInvite('https://xbind.to/invite/abc123', {
170
+ * name: 'my-service',
171
+ * });
172
+ *
173
+ * if (connection.ok) {
174
+ * console.log('Connected to:', connection.value.service.name);
175
+ * }
176
+ * ```
177
+ */
178
+ export async function acceptInvite(inviteUrl, options = {}) {
179
+ const { InviteService } = await import('./invite.js');
180
+ const inviteService = new InviteService();
181
+ // Get invite details
182
+ const inviteResult = await inviteService.get(inviteUrl);
183
+ if (!inviteResult.ok) {
184
+ return err({
185
+ code: ConnectErrorCode.DISCOVERY_FAILED,
186
+ message: `Failed to get invite: ${inviteResult.error.message}`,
187
+ cause: inviteResult.error,
188
+ });
189
+ }
190
+ const invite = inviteResult.value;
191
+ // Convert invite.from to ServiceInfo
192
+ const service = {
193
+ name: invite.from.name,
194
+ did: invite.from.did,
195
+ endpoint: invite.from.endpoint,
196
+ publicKey: invite.from.publicKey,
197
+ x25519PublicKey: invite.from.x25519PublicKey,
198
+ mlKemPublicKey: invite.from.mlKemPublicKey,
199
+ };
200
+ // Connect to service (same as connect())
201
+ // Create trust registry and add service
202
+ const registry = options.registry || new MemoryTrustRegistry();
203
+ try {
204
+ // Import public key (convert from base64 string)
205
+ const publicKeyBytes = fromBase64(service.publicKey);
206
+ const publicKeyResult = await importPublicKey(publicKeyBytes);
207
+ if (!publicKeyResult.ok) {
208
+ return err({
209
+ code: ConnectErrorCode.TRUST_VERIFICATION_FAILED,
210
+ message: 'Invalid service public key',
211
+ cause: publicKeyResult.error,
212
+ });
213
+ }
214
+ await registry.add({
215
+ did: service.did,
216
+ publicKey: publicKeyResult.value,
217
+ x25519PublicKey: service.x25519PublicKey
218
+ ? await importPublicKey(fromBase64(service.x25519PublicKey)).then(r => r.ok ? r.value : undefined)
219
+ : undefined,
220
+ mlKemPublicKey: service.mlKemPublicKey
221
+ ? fromBase64(service.mlKemPublicKey)
222
+ : undefined,
223
+ });
224
+ }
225
+ catch (error) {
226
+ return err({
227
+ code: ConnectErrorCode.TRUST_VERIFICATION_FAILED,
228
+ message: 'Failed to verify service public key',
229
+ cause: error,
230
+ });
231
+ }
232
+ const transport = options.transport || new HttpsTransportAdapter({
233
+ baseUrl: service.endpoint,
234
+ });
235
+ const agentName = options.name || `client-${Date.now()}`;
236
+ const agentOptions = {
237
+ name: agentName,
238
+ registry,
239
+ transport,
240
+ xchange: options.xchange,
241
+ postQuantumSig: options.postQuantumSig,
242
+ };
243
+ const agentResult = await Agent.create(agentOptions);
244
+ if (!agentResult.ok) {
245
+ return err({
246
+ code: ConnectErrorCode.AGENT_CREATION_FAILED,
247
+ message: 'Failed to create agent',
248
+ cause: agentResult.error,
249
+ });
250
+ }
251
+ // Accept the invite
252
+ const acceptResult = await inviteService.accept({
253
+ inviteUrl,
254
+ acceptor: {
255
+ name: agentOptions.name,
256
+ did: agentResult.value.did,
257
+ endpoint: options.endpoint || '', // Agent's endpoint (where it can be reached), empty for client-only agents
258
+ publicKey: toBase64(agentResult.value.identity.rawPublicKey),
259
+ x25519PublicKey: agentResult.value.identity.rawX25519PublicKey
260
+ ? toBase64(agentResult.value.identity.rawX25519PublicKey)
261
+ : undefined,
262
+ },
263
+ });
264
+ if (!acceptResult.ok) {
265
+ // Connection created but invite acceptance failed - still return connection
266
+ // (invite acceptance is for tracking/notification, not required for connectivity)
267
+ }
268
+ return ok({
269
+ agent: agentResult.value,
270
+ service,
271
+ did: service.did,
272
+ endpoint: service.endpoint,
273
+ });
274
+ }
@@ -0,0 +1,65 @@
1
+ import type { Result } from '@private.me/shared';
2
+ /**
3
+ * DID Document representation for did:key and did:privateme DIDs.
4
+ *
5
+ * Mechanism 3: Includes service endpoints for viral exposure.
6
+ * When Bob receives a message from Alice, Bob's agent can resolve Alice's
7
+ * DID to retrieve the service endpoint, learning about PRIVATE.ME/xBind.
8
+ */
9
+ export interface DidDocument {
10
+ '@context': string[];
11
+ id: string;
12
+ name?: string;
13
+ publicKey?: Array<{
14
+ id: string;
15
+ type: string;
16
+ controller: string;
17
+ publicKeyBase64?: string;
18
+ publicKeyMultibase?: string;
19
+ }>;
20
+ authentication?: string[];
21
+ assertionMethod?: string[];
22
+ keyAgreement?: string[];
23
+ service?: Array<{
24
+ id: string;
25
+ type: string;
26
+ serviceEndpoint: string | Record<string, unknown>;
27
+ description?: string;
28
+ }>;
29
+ }
30
+ /**
31
+ * Generate a DID document for a given DID.
32
+ *
33
+ * Includes service endpoints that advertise PRIVATE.ME/xBind.
34
+ * Both did:key and did:privateme DIDs generate the same service endpoints.
35
+ *
36
+ * @param did - The DID (did:key:z... or did:privateme:z...)
37
+ * @param rawPublicKey - The 32-byte Ed25519 public key
38
+ * @param name - Optional name for the identity
39
+ * @returns DID document with service endpoints
40
+ */
41
+ export declare function generateDidDocument(did: string, rawPublicKey: Uint8Array, name?: string): Result<DidDocument, string>;
42
+ /**
43
+ * Resolve a DID to its document (simulated).
44
+ *
45
+ * In a production system, this would query a DID resolver.
46
+ * For now, this generates a synthetic document based on the DID.
47
+ *
48
+ * @param did - The DID to resolve
49
+ * @param rawPublicKey - The 32-byte Ed25519 public key
50
+ * @returns DID document or error
51
+ */
52
+ export declare function resolveDid(did: string, rawPublicKey: Uint8Array): Promise<Result<DidDocument, string>>;
53
+ /**
54
+ * Extract service endpoints from a DID document.
55
+ *
56
+ * Filters for PRIVATE.ME service endpoints to provide discovery information.
57
+ *
58
+ * @param document - The DID document
59
+ * @returns Array of service endpoints advertising PRIVATE.ME services
60
+ */
61
+ export declare function getServiceEndpoints(document: DidDocument): Array<{
62
+ type: string;
63
+ endpoint: string;
64
+ description?: string;
65
+ }>;
@@ -0,0 +1,96 @@
1
+ import { ok, err } from"./_deps/shared/index.js";
2
+ import { toBase64 } from"./_deps/crypto/index.js";
3
+ /**
4
+ * Generate a DID document for a given DID.
5
+ *
6
+ * Includes service endpoints that advertise PRIVATE.ME/xBind.
7
+ * Both did:key and did:privateme DIDs generate the same service endpoints.
8
+ *
9
+ * @param did - The DID (did:key:z... or did:privateme:z...)
10
+ * @param rawPublicKey - The 32-byte Ed25519 public key
11
+ * @param name - Optional name for the identity
12
+ * @returns DID document with service endpoints
13
+ */
14
+ export function generateDidDocument(did, rawPublicKey, name) {
15
+ if (!did.startsWith('did:key:') && !did.startsWith('did:privateme:')) {
16
+ return err('INVALID_DID_FORMAT');
17
+ }
18
+ // Convert public key to base64 for inclusion in document
19
+ const publicKeyBase64 = toBase64(rawPublicKey);
20
+ const document = {
21
+ '@context': [
22
+ 'https://www.w3.org/ns/did/v1',
23
+ 'https://w3id.org/security/suites/ed25519-2020/v1',
24
+ ],
25
+ id: did,
26
+ publicKey: [
27
+ {
28
+ id: `${did}#key-1`,
29
+ type: 'Ed25519VerificationKey2020',
30
+ controller: did,
31
+ publicKeyBase64,
32
+ },
33
+ ],
34
+ authentication: [`${did}#key-1`],
35
+ assertionMethod: [`${did}#key-1`],
36
+ keyAgreement: [`${did}#key-1`],
37
+ service: [
38
+ {
39
+ id: `${did}#identity-provider`,
40
+ type: 'IdentityProvider',
41
+ serviceEndpoint: 'https://private.me',
42
+ description: 'PRIVATE.ME xBind Agent - M2M identity authentication',
43
+ },
44
+ {
45
+ id: `${did}#documentation`,
46
+ type: 'Documentation',
47
+ serviceEndpoint: 'https://private.me/docs/xbind.html',
48
+ description: 'Learn more about PRIVATE.ME/xBind protocol',
49
+ },
50
+ ],
51
+ ...(name ? { name } : {}),
52
+ };
53
+ return ok(document);
54
+ }
55
+ /**
56
+ * Resolve a DID to its document (simulated).
57
+ *
58
+ * In a production system, this would query a DID resolver.
59
+ * For now, this generates a synthetic document based on the DID.
60
+ *
61
+ * @param did - The DID to resolve
62
+ * @param rawPublicKey - The 32-byte Ed25519 public key
63
+ * @returns DID document or error
64
+ */
65
+ export async function resolveDid(did, rawPublicKey) {
66
+ // In a production system, this would make an HTTP request to a DID resolver
67
+ // For now, generate a synthetic document
68
+ return generateDidDocument(did, rawPublicKey);
69
+ }
70
+ /**
71
+ * Extract service endpoints from a DID document.
72
+ *
73
+ * Filters for PRIVATE.ME service endpoints to provide discovery information.
74
+ *
75
+ * @param document - The DID document
76
+ * @returns Array of service endpoints advertising PRIVATE.ME services
77
+ */
78
+ export function getServiceEndpoints(document) {
79
+ if (!document.service)
80
+ return [];
81
+ return document.service
82
+ .filter((svc) => {
83
+ const endpoint = typeof svc.serviceEndpoint === 'string' ? svc.serviceEndpoint : '';
84
+ return (endpoint.includes('private.me') ||
85
+ svc.type.includes('PRIVATE.ME') ||
86
+ svc.type === 'IdentityProvider' ||
87
+ svc.type === 'Documentation');
88
+ })
89
+ .map((svc) => ({
90
+ type: svc.type,
91
+ endpoint: typeof svc.serviceEndpoint === 'string'
92
+ ? svc.serviceEndpoint
93
+ : JSON.stringify(svc.serviceEndpoint),
94
+ description: svc.description,
95
+ }));
96
+ }
@@ -0,0 +1,70 @@
1
+ import type { Result } from '@private.me/shared';
2
+ /**
3
+ * Mechanism 4: Convert Ed25519 public key to did:privateme DID.
4
+ *
5
+ * Format: did:privateme:z + base58btc(0xed01 || publicKey)
6
+ *
7
+ * This is a new DID method identifier for PRIVATE.ME ACIs.
8
+ * It uses the same base58btc encoding as did:key for compatibility,
9
+ * but signals that the identity is backed by PRIVATE.ME infrastructure.
10
+ *
11
+ * Backward compatible: agents accept both did:key and did:privateme formats.
12
+ *
13
+ * @param rawPublicKey - 32-byte Ed25519 public key
14
+ * @returns DID in format did:privateme:z...
15
+ */
16
+ export declare function publicKeyToPrivateMeDid(rawPublicKey: Uint8Array): string;
17
+ /**
18
+ * Extract raw 32-byte public key from a did:privateme DID.
19
+ *
20
+ * Format: did:privateme:z + base58btc(0xed01 || publicKey)
21
+ *
22
+ * @param did - DID in format did:privateme:z...
23
+ * @returns 32-byte public key or error
24
+ */
25
+ export declare function privateMeDidToPublicKeyBytes(did: string): Result<Uint8Array, string>;
26
+ /**
27
+ * Determine if a DID is in the new did:privateme format.
28
+ *
29
+ * @param did - The DID to check
30
+ * @returns true if DID is did:privateme format, false otherwise
31
+ */
32
+ export declare function isPrivateMeDid(did: string): boolean;
33
+ /**
34
+ * Determine if a DID is in the did:key format.
35
+ *
36
+ * @param did - The DID to check
37
+ * @returns true if DID is did:key format, false otherwise
38
+ */
39
+ export declare function isDidKeyFormat(did: string): boolean;
40
+ /**
41
+ * Convert between DID formats (did:key ↔ did:privateme).
42
+ *
43
+ * Allows backward compatibility between old did:key and new did:privateme formats.
44
+ * The public key remains the same; only the method identifier changes.
45
+ *
46
+ * @param did - Source DID in either format
47
+ * @returns Converted DID in the other format, or error
48
+ */
49
+ export declare function convertDidFormat(did: string): Result<string, string>;
50
+ /**
51
+ * Normalize a DID to the canonical format (did:privateme).
52
+ *
53
+ * All DIDs are converted to did:privateme format for consistency.
54
+ * Existing did:key DIDs are automatically upgraded.
55
+ *
56
+ * @param did - Source DID in any supported format
57
+ * @returns Normalized DID in did:privateme format
58
+ */
59
+ export declare function normalizeDid(did: string): Result<string, string>;
60
+ /**
61
+ * Parse a DID into method, identifier, and fragment.
62
+ *
63
+ * @param did - Full DID string
64
+ * @returns Parsed DID components or error
65
+ */
66
+ export declare function parseDid(did: string): Result<{
67
+ method: string;
68
+ identifier: string;
69
+ fragment?: string;
70
+ }, string>;
@@ -0,0 +1,121 @@
1
+ import { ok, err } from"./_deps/shared/index.js";
2
+ import { publicKeyToDid, didToPublicKeyBytes } from './identity.js';
3
+ /**
4
+ * Mechanism 4: Convert Ed25519 public key to did:privateme DID.
5
+ *
6
+ * Format: did:privateme:z + base58btc(0xed01 || publicKey)
7
+ *
8
+ * This is a new DID method identifier for PRIVATE.ME ACIs.
9
+ * It uses the same base58btc encoding as did:key for compatibility,
10
+ * but signals that the identity is backed by PRIVATE.ME infrastructure.
11
+ *
12
+ * Backward compatible: agents accept both did:key and did:privateme formats.
13
+ *
14
+ * @param rawPublicKey - 32-byte Ed25519 public key
15
+ * @returns DID in format did:privateme:z...
16
+ */
17
+ export function publicKeyToPrivateMeDid(rawPublicKey) {
18
+ // Use same encoding as did:key, but with privateme method
19
+ const didKeyFormat = publicKeyToDid(rawPublicKey);
20
+ // Replace did:key: with did:privateme:
21
+ return didKeyFormat.replace(/^did:key:/, 'did:privateme:');
22
+ }
23
+ /**
24
+ * Extract raw 32-byte public key from a did:privateme DID.
25
+ *
26
+ * Format: did:privateme:z + base58btc(0xed01 || publicKey)
27
+ *
28
+ * @param did - DID in format did:privateme:z...
29
+ * @returns 32-byte public key or error
30
+ */
31
+ export function privateMeDidToPublicKeyBytes(did) {
32
+ if (!did.startsWith('did:privateme:z')) {
33
+ return err('INVALID_DID_FORMAT');
34
+ }
35
+ // Convert to did:key format temporarily for parsing
36
+ const didKeyFormat = did.replace(/^did:privateme:/, 'did:key:');
37
+ // Use the existing parser
38
+ const result = didToPublicKeyBytes(didKeyFormat);
39
+ if (!result.ok) {
40
+ return err(result.error);
41
+ }
42
+ return ok(result.value);
43
+ }
44
+ /**
45
+ * Determine if a DID is in the new did:privateme format.
46
+ *
47
+ * @param did - The DID to check
48
+ * @returns true if DID is did:privateme format, false otherwise
49
+ */
50
+ export function isPrivateMeDid(did) {
51
+ return did.startsWith('did:privateme:');
52
+ }
53
+ /**
54
+ * Determine if a DID is in the did:key format.
55
+ *
56
+ * @param did - The DID to check
57
+ * @returns true if DID is did:key format, false otherwise
58
+ */
59
+ export function isDidKeyFormat(did) {
60
+ return did.startsWith('did:key:');
61
+ }
62
+ /**
63
+ * Convert between DID formats (did:key ↔ did:privateme).
64
+ *
65
+ * Allows backward compatibility between old did:key and new did:privateme formats.
66
+ * The public key remains the same; only the method identifier changes.
67
+ *
68
+ * @param did - Source DID in either format
69
+ * @returns Converted DID in the other format, or error
70
+ */
71
+ export function convertDidFormat(did) {
72
+ if (isDidKeyFormat(did)) {
73
+ // Convert did:key to did:privateme
74
+ return ok(did.replace(/^did:key:/, 'did:privateme:'));
75
+ }
76
+ if (isPrivateMeDid(did)) {
77
+ // Convert did:privateme to did:key
78
+ return ok(did.replace(/^did:privateme:/, 'did:key:'));
79
+ }
80
+ return err('UNSUPPORTED_DID_FORMAT');
81
+ }
82
+ /**
83
+ * Normalize a DID to the canonical format (did:privateme).
84
+ *
85
+ * All DIDs are converted to did:privateme format for consistency.
86
+ * Existing did:key DIDs are automatically upgraded.
87
+ *
88
+ * @param did - Source DID in any supported format
89
+ * @returns Normalized DID in did:privateme format
90
+ */
91
+ export function normalizeDid(did) {
92
+ if (isPrivateMeDid(did)) {
93
+ // Already in target format
94
+ return ok(did);
95
+ }
96
+ if (isDidKeyFormat(did)) {
97
+ // Convert to did:privateme
98
+ return ok(did.replace(/^did:key:/, 'did:privateme:'));
99
+ }
100
+ return err('UNSUPPORTED_DID_FORMAT');
101
+ }
102
+ /**
103
+ * Parse a DID into method, identifier, and fragment.
104
+ *
105
+ * @param did - Full DID string
106
+ * @returns Parsed DID components or error
107
+ */
108
+ export function parseDid(did) {
109
+ const fragmentMatch = did.indexOf('#');
110
+ const base = fragmentMatch >= 0 ? did.substring(0, fragmentMatch) : did;
111
+ const fragment = fragmentMatch >= 0 ? did.substring(fragmentMatch + 1) : undefined;
112
+ const parts = base.split(':');
113
+ if (parts.length < 3 || parts[0] !== 'did') {
114
+ return err('INVALID_DID_FORMAT');
115
+ }
116
+ return ok({
117
+ method: parts[1],
118
+ identifier: parts.slice(2).join(':'),
119
+ fragment,
120
+ });
121
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * did:web resolver — resolves DIDs hosted on developer domains.
3
+ *
4
+ * Implements the W3C did:web method:
5
+ * did:web:example.com -> https://example.com/.well-known/did.json
6
+ * did:web:example.com:path:to -> https://example.com/path/to/did.json
7
+ *
8
+ * Enables direct agent-to-agent communication without a centralized registry.
9
+ * Implements TrustRegistry interface for drop-in use with Agent class.
10
+ */
11
+ import type { Result } from '@private.me/shared';
12
+ import type { TrustRegistry, RegistryEntry, RegistryError } from './trust-registry.js';
13
+ /** Options for DidWebResolver. */
14
+ export interface DidWebResolverOptions {
15
+ /** Custom fetch implementation (for testing). */
16
+ readonly fetch?: typeof globalThis.fetch;
17
+ /** Cache TTL in ms. Default: 300000 (5 min). */
18
+ readonly cacheTtlMs?: number;
19
+ }
20
+ /**
21
+ * Resolve did:web DIDs by fetching DID documents from the hosting domain.
22
+ *
23
+ * Implements TrustRegistry interface so it can be used as a drop-in
24
+ * replacement for MemoryTrustRegistry or HttpTrustRegistry.
25
+ */
26
+ export declare class DidWebResolver implements TrustRegistry {
27
+ private readonly fetchFn;
28
+ private readonly cacheTtlMs;
29
+ private readonly cache;
30
+ constructor(opts?: DidWebResolverOptions);
31
+ /** Registration not supported for did:web (developers host their own). */
32
+ register(_did: string, _publicKey: Uint8Array, _name: string, _scopes?: string[], _x25519PublicKey?: Uint8Array): Promise<Result<void, RegistryError>>;
33
+ /**
34
+ * Resolve a did:web DID to its raw public key bytes.
35
+ * @param did - A did:web DID string.
36
+ * @returns Public key bytes or error.
37
+ */
38
+ resolve(did: string): Promise<Result<Uint8Array, RegistryError>>;
39
+ /**
40
+ * Check if a did:web DID has a specific scope.
41
+ * @param did - The DID to check.
42
+ * @param scope - The scope to verify.
43
+ * @returns True if scope is granted.
44
+ */
45
+ hasScope(did: string, scope: string): Promise<boolean>;
46
+ /**
47
+ * Check if a did:web DID has a specific receive scope.
48
+ * @param did - The DID to check.
49
+ * @param scope - The scope to verify.
50
+ * @returns True if receive scope is granted.
51
+ */
52
+ hasReceiveScope(did: string, scope: string): Promise<boolean>;
53
+ /** Revocation not supported for did:web (developer controls their domain). */
54
+ revoke(_did: string): Promise<Result<void, RegistryError>>;
55
+ /**
56
+ * Get the full registry entry for a did:web DID.
57
+ * @param did - The DID to look up.
58
+ * @returns Full entry or error.
59
+ */
60
+ getEntry(did: string): Promise<Result<RegistryEntry, RegistryError>>;
61
+ /** Number of cached entries (for testing). */
62
+ get cacheSize(): number;
63
+ /** Fetch and parse a DID document, with caching. */
64
+ private fetchEntry;
65
+ }
66
+ /**
67
+ * Convert a did:web DID to its HTTPS URL.
68
+ * did:web:example.com -> https://example.com/.well-known/did.json
69
+ * did:web:example.com:path:to -> https://example.com/path/to/did.json
70
+ * @param did - The did:web DID string.
71
+ * @returns HTTPS URL or null if invalid.
72
+ */
73
+ export declare function didWebToUrl(did: string): string | null;