@private.me/xbind 3.0.2 → 3.0.3

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 (221) hide show
  1. package/README.md +2366 -204
  2. package/README.md.backup +2121 -0
  3. package/dist-standalone/_deps/mldsa-wasm/dist/mldsa.js +1 -1920
  4. package/dist-standalone/_deps/shared/cjs/errors.js +1 -729
  5. package/dist-standalone/_deps/shared/cjs/index.js +1 -463
  6. package/dist-standalone/_deps/shared/cjs/types.js +1 -315
  7. package/dist-standalone/_deps/shared/errors.js +1 -244
  8. package/dist-standalone/_deps/shared/index.js +1 -72
  9. package/dist-standalone/_deps/shared/types.js +1 -86
  10. package/dist-standalone/_deps/ux-helpers/cjs/errors.js +1 -1
  11. package/dist-standalone/_deps/ux-helpers/cjs/index.js +1 -1
  12. package/dist-standalone/_deps/ux-helpers/cjs/pagination.js +1 -1
  13. package/dist-standalone/_deps/ux-helpers/cjs/progress.js +1 -1
  14. package/dist-standalone/_deps/ux-helpers/cjs/search.js +1 -1
  15. package/dist-standalone/_deps/ux-helpers/cjs/types.js +1 -1
  16. package/dist-standalone/_deps/ux-helpers/errors.js +1 -1
  17. package/dist-standalone/_deps/ux-helpers/index.js +1 -1
  18. package/dist-standalone/_deps/ux-helpers/pagination.js +1 -1
  19. package/dist-standalone/_deps/ux-helpers/progress.js +1 -1
  20. package/dist-standalone/_deps/ux-helpers/search.js +1 -1
  21. package/dist-standalone/_deps/xchange/auto-accept.js +1 -1
  22. package/dist-standalone/_deps/xchange/cjs/auto-accept.js +1 -1
  23. package/dist-standalone/_deps/xchange/cjs/errors.js +1 -1
  24. package/dist-standalone/_deps/xchange/cjs/index.js +1 -1
  25. package/dist-standalone/_deps/xchange/cjs/invite-client.js +1 -1
  26. package/dist-standalone/_deps/xchange/cjs/lazy-init.js +1 -1
  27. package/dist-standalone/_deps/xchange/cjs/trust-integration.js +1 -1
  28. package/dist-standalone/_deps/xchange/cjs/xchange.js +1 -1
  29. package/dist-standalone/_deps/xchange/errors.js +1 -1
  30. package/dist-standalone/_deps/xchange/index.js +1 -1
  31. package/dist-standalone/_deps/xchange/invite-client.js +1 -1
  32. package/dist-standalone/_deps/xchange/lazy-init.js +1 -1
  33. package/dist-standalone/_deps/xchange/trust-integration.js +1 -1
  34. package/dist-standalone/_deps/xchange/xchange.js +1 -1
  35. package/dist-standalone/_deps/xregistry/cjs/discovery.js +1 -1
  36. package/dist-standalone/_deps/xregistry/cjs/errors.js +1 -1
  37. package/dist-standalone/_deps/xregistry/cjs/index.js +1 -1
  38. package/dist-standalone/_deps/xregistry/cjs/registry.js +1 -1
  39. package/dist-standalone/_deps/xregistry/cjs/schema.js +1 -1
  40. package/dist-standalone/_deps/xregistry/cjs/types.js +1 -1
  41. package/dist-standalone/_deps/xregistry/discovery.js +1 -1
  42. package/dist-standalone/_deps/xregistry/errors.js +1 -1
  43. package/dist-standalone/_deps/xregistry/index.js +1 -1
  44. package/dist-standalone/_deps/xregistry/registry.js +1 -1
  45. package/dist-standalone/_deps/xregistry/schema.js +1 -1
  46. package/dist-standalone/_deps/xregistry/types.js +1 -1
  47. package/dist-standalone/agent-call.d.ts +2 -2
  48. package/dist-standalone/agent-call.js +1 -659
  49. package/dist-standalone/agent-sdk.js +1 -328
  50. package/dist-standalone/agent.d.ts +2 -0
  51. package/dist-standalone/agent.js +1 -1800
  52. package/dist-standalone/approval.js +1 -193
  53. package/dist-standalone/async-iterators.d.ts +3 -3
  54. package/dist-standalone/async-iterators.js +1 -382
  55. package/dist-standalone/auth.js +1 -219
  56. package/dist-standalone/auto-accept.js +1 -229
  57. package/dist-standalone/backup-config.js +1 -201
  58. package/dist-standalone/backup.js +1 -326
  59. package/dist-standalone/batch-operations.js +1 -388
  60. package/dist-standalone/cancellation.js +1 -477
  61. package/dist-standalone/checkpoint.js +1 -186
  62. package/dist-standalone/circuit-breaker.js +1 -468
  63. package/dist-standalone/cjs/agent-call.js +1 -701
  64. package/dist-standalone/cjs/agent-sdk.js +1 -332
  65. package/dist-standalone/cjs/agent.js +1 -1837
  66. package/dist-standalone/cjs/approval.js +1 -199
  67. package/dist-standalone/cjs/async-iterators.js +1 -392
  68. package/dist-standalone/cjs/auth.js +1 -225
  69. package/dist-standalone/cjs/auto-accept.js +1 -233
  70. package/dist-standalone/cjs/backup-config.js +1 -207
  71. package/dist-standalone/cjs/backup.js +1 -330
  72. package/dist-standalone/cjs/batch-operations.js +1 -397
  73. package/dist-standalone/cjs/cancellation.js +1 -490
  74. package/dist-standalone/cjs/checkpoint.js +1 -193
  75. package/dist-standalone/cjs/circuit-breaker.js +1 -476
  76. package/dist-standalone/cjs/cli/init.js +1 -492
  77. package/dist-standalone/cjs/config-validation.js +1 -522
  78. package/dist-standalone/cjs/connect.js +1 -312
  79. package/dist-standalone/cjs/connection-pool.js +1 -506
  80. package/dist-standalone/cjs/correlation-id.js +1 -339
  81. package/dist-standalone/cjs/crypto-utils.js +1 -176
  82. package/dist-standalone/cjs/debug-mode.js +1 -534
  83. package/dist-standalone/cjs/did-document.js +1 -101
  84. package/dist-standalone/cjs/did-privateme.js +1 -130
  85. package/dist-standalone/cjs/did-web.js +1 -201
  86. package/dist-standalone/cjs/discovery.js +1 -462
  87. package/dist-standalone/cjs/dual-mode.js +1 -251
  88. package/dist-standalone/cjs/email-templates.js +1 -313
  89. package/dist-standalone/cjs/email-transport.js +1 -239
  90. package/dist-standalone/cjs/envelope.js +1 -538
  91. package/dist-standalone/cjs/errors.js +1 -913
  92. package/dist-standalone/cjs/event-emitter.js +1 -461
  93. package/dist-standalone/cjs/gateway-state.js +1 -55
  94. package/dist-standalone/cjs/gateway-transport.js +1 -120
  95. package/dist-standalone/cjs/graceful-degradation.js +1 -403
  96. package/dist-standalone/cjs/guardrails.js +1 -223
  97. package/dist-standalone/cjs/health-check.js +1 -336
  98. package/dist-standalone/cjs/http-compat.js +1 -272
  99. package/dist-standalone/cjs/http-status-map.js +1 -571
  100. package/dist-standalone/cjs/identity.js +1 -645
  101. package/dist-standalone/cjs/index.js +1 -406
  102. package/dist-standalone/cjs/invitation.js +1 -421
  103. package/dist-standalone/cjs/invite.js +1 -328
  104. package/dist-standalone/cjs/key-agreement.js +1 -335
  105. package/dist-standalone/cjs/lazy-init.js +1 -300
  106. package/dist-standalone/cjs/logger.js +1 -291
  107. package/dist-standalone/cjs/loopback-transport.js +1 -0
  108. package/dist-standalone/cjs/mdns-discovery.js +1 -202
  109. package/dist-standalone/cjs/nonce-store.js +1 -80
  110. package/dist-standalone/cjs/pairing-manager.js +1 -223
  111. package/dist-standalone/cjs/plugin-system.js +1 -264
  112. package/dist-standalone/cjs/plugins/logging.js +1 -168
  113. package/dist-standalone/cjs/plugins/metrics.js +1 -181
  114. package/dist-standalone/cjs/plugins/validation.js +1 -302
  115. package/dist-standalone/cjs/policy.js +1 -320
  116. package/dist-standalone/cjs/progress-callbacks.js +1 -583
  117. package/dist-standalone/cjs/redis-nonce-store.js +1 -76
  118. package/dist-standalone/cjs/registry-middleware.js +1 -50
  119. package/dist-standalone/cjs/retry-strategies.js +1 -544
  120. package/dist-standalone/cjs/retry-transport.js +1 -102
  121. package/dist-standalone/cjs/runtime/browser.js +1 -533
  122. package/dist-standalone/cjs/runtime/edge.js +1 -526
  123. package/dist-standalone/cjs/runtime/react-native.js +1 -394
  124. package/dist-standalone/cjs/security-policy.js +1 -245
  125. package/dist-standalone/cjs/serialization.js +1 -1040
  126. package/dist-standalone/cjs/split-channel.js +1 -225
  127. package/dist-standalone/cjs/subscription-proof.js +1 -230
  128. package/dist-standalone/cjs/succession.js +1 -148
  129. package/dist-standalone/cjs/timeouts.js +1 -412
  130. package/dist-standalone/cjs/trace-context.js +1 -424
  131. package/dist-standalone/cjs/trace-spans.js +1 -495
  132. package/dist-standalone/cjs/transport.js +1 -63
  133. package/dist-standalone/cjs/trust-registry.js +1 -991
  134. package/dist-standalone/cjs/types/error-response.js +1 -56
  135. package/dist-standalone/cjs/vault-auth.js +1 -178
  136. package/dist-standalone/cjs/vault-store-loader.js +1 -194
  137. package/dist-standalone/cjs/verify.js +1 -25
  138. package/dist-standalone/cjs/version-info.js +1 -543
  139. package/dist-standalone/cjs/xfetch.js +1 -340
  140. package/dist-standalone/cli/init.js +1 -455
  141. package/dist-standalone/cli/setup.js +1 -514
  142. package/dist-standalone/cli/types.js +1 -27
  143. package/dist-standalone/cli/xbind.js +1 -148
  144. package/dist-standalone/config-validation.js +1 -513
  145. package/dist-standalone/connect.js +1 -274
  146. package/dist-standalone/connection-pool.js +1 -500
  147. package/dist-standalone/correlation-id.js +1 -326
  148. package/dist-standalone/crypto-utils.d.ts +2 -7
  149. package/dist-standalone/crypto-utils.js +1 -157
  150. package/dist-standalone/debug-mode.js +1 -510
  151. package/dist-standalone/did-document.js +1 -96
  152. package/dist-standalone/did-privateme.js +1 -121
  153. package/dist-standalone/did-web.js +1 -196
  154. package/dist-standalone/discovery.js +1 -458
  155. package/dist-standalone/dual-mode.js +1 -247
  156. package/dist-standalone/email-templates.js +1 -309
  157. package/dist-standalone/email-transport.d.ts +2 -2
  158. package/dist-standalone/email-transport.js +1 -232
  159. package/dist-standalone/envelope.js +1 -525
  160. package/dist-standalone/errors.d.ts +13 -3
  161. package/dist-standalone/errors.js +1 -896
  162. package/dist-standalone/event-emitter.js +1 -456
  163. package/dist-standalone/gateway-state.d.ts +1 -1
  164. package/dist-standalone/gateway-state.js +1 -51
  165. package/dist-standalone/gateway-transport.js +1 -116
  166. package/dist-standalone/graceful-degradation.js +1 -396
  167. package/dist-standalone/guardrails.js +1 -216
  168. package/dist-standalone/health-check.d.ts +5 -1
  169. package/dist-standalone/health-check.js +1 -332
  170. package/dist-standalone/http-compat.d.ts +1 -1
  171. package/dist-standalone/http-compat.js +1 -267
  172. package/dist-standalone/http-status-map.js +1 -561
  173. package/dist-standalone/identity.js +1 -619
  174. package/dist-standalone/index.d.ts +15 -4
  175. package/dist-standalone/index.js +1 -78
  176. package/dist-standalone/invitation.js +1 -415
  177. package/dist-standalone/invite.js +1 -324
  178. package/dist-standalone/key-agreement.js +1 -325
  179. package/dist-standalone/lazy-init.d.ts +11 -6
  180. package/dist-standalone/lazy-init.js +1 -295
  181. package/dist-standalone/logger.js +1 -285
  182. package/dist-standalone/loopback-transport.d.ts +87 -0
  183. package/dist-standalone/loopback-transport.js +1 -0
  184. package/dist-standalone/mdns-discovery.js +1 -195
  185. package/dist-standalone/nonce-store.js +1 -76
  186. package/dist-standalone/pairing-manager.js +1 -219
  187. package/dist-standalone/plugin-system.js +1 -257
  188. package/dist-standalone/plugins/logging.js +1 -163
  189. package/dist-standalone/plugins/metrics.d.ts +4 -4
  190. package/dist-standalone/plugins/metrics.js +1 -176
  191. package/dist-standalone/plugins/validation.js +1 -297
  192. package/dist-standalone/policy.js +1 -315
  193. package/dist-standalone/progress-callbacks.js +1 -576
  194. package/dist-standalone/redis-nonce-store.js +1 -72
  195. package/dist-standalone/registry-middleware.js +1 -47
  196. package/dist-standalone/retry-strategies.js +1 -534
  197. package/dist-standalone/retry-transport.js +1 -98
  198. package/dist-standalone/runtime/browser.js +1 -516
  199. package/dist-standalone/runtime/edge.js +1 -511
  200. package/dist-standalone/runtime/react-native.d.ts +1 -1
  201. package/dist-standalone/runtime/react-native.js +1 -383
  202. package/dist-standalone/security-policy.js +1 -239
  203. package/dist-standalone/serialization.js +1 -1031
  204. package/dist-standalone/split-channel.js +1 -219
  205. package/dist-standalone/subscription-proof.js +1 -224
  206. package/dist-standalone/succession.js +1 -142
  207. package/dist-standalone/timeouts.js +1 -398
  208. package/dist-standalone/trace-context.js +1 -414
  209. package/dist-standalone/trace-spans.js +1 -488
  210. package/dist-standalone/transport.js +1 -59
  211. package/dist-standalone/trust-registry.d.ts +3 -3
  212. package/dist-standalone/trust-registry.js +1 -950
  213. package/dist-standalone/types/error-response.js +1 -52
  214. package/dist-standalone/vault-auth.js +1 -174
  215. package/dist-standalone/vault-store-loader.d.ts +9 -0
  216. package/dist-standalone/vault-store-loader.js +1 -187
  217. package/dist-standalone/verify.js +1 -16
  218. package/dist-standalone/version-info.js +1 -530
  219. package/dist-standalone/xfetch.js +1 -335
  220. package/package.json +1 -1
  221. package/share1.dat +0 -0
@@ -1,534 +1 @@
1
- "use strict";
2
- /**
3
- * @module debug-mode
4
- * Debug mode for enhanced developer experience with verbose logging and state inspection
5
- *
6
- * Provides comprehensive debugging capabilities including:
7
- * - Verbose logging of all operations
8
- * - Internal state dumping and inspection
9
- * - Network request/response logging
10
- * - Crypto operation tracing
11
- * - Performance profiling and timing
12
- * - Memory usage tracking
13
- *
14
- * Usage:
15
- * ```typescript
16
- * import { enableDebugMode, dumpState, createDebugLogger } from '@private.me/xbind/debug-mode';
17
- *
18
- * // Enable debug mode globally
19
- * enableDebugMode({ verbose: true, traceNetwork: true });
20
- *
21
- * // Create debug logger for component
22
- * const debug = createDebugLogger('agent');
23
- * debug.trace('Operation starting', { did: 'did:key:...' });
24
- *
25
- * // Dump internal state
26
- * const state = dumpState(agent);
27
- * console.log(state);
28
- * ```
29
- */
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.enableDebugMode = enableDebugMode;
32
- exports.disableDebugMode = disableDebugMode;
33
- exports.isDebugEnabled = isDebugEnabled;
34
- exports.getDebugOptions = getDebugOptions;
35
- exports.createDebugLogger = createDebugLogger;
36
- exports.startProfiling = startProfiling;
37
- exports.endProfiling = endProfiling;
38
- exports.getPerformanceMeasurements = getPerformanceMeasurements;
39
- exports.clearPerformanceMeasurements = clearPerformanceMeasurements;
40
- exports.traceNetworkRequest = traceNetworkRequest;
41
- exports.traceNetworkResponse = traceNetworkResponse;
42
- exports.getNetworkTraces = getNetworkTraces;
43
- exports.clearNetworkTraces = clearNetworkTraces;
44
- exports.traceCryptoOperation = traceCryptoOperation;
45
- exports.getCryptoTraces = getCryptoTraces;
46
- exports.clearCryptoTraces = clearCryptoTraces;
47
- exports.dumpState = dumpState;
48
- exports.getStateSnapshots = getStateSnapshots;
49
- exports.clearStateSnapshots = clearStateSnapshots;
50
- exports.exportDebugData = exportDebugData;
51
- exports.clearAllDebugData = clearAllDebugData;
52
- exports.generateDebugReport = generateDebugReport;
53
- const logger_js_1 = require("./logger.js");
54
- /**
55
- * Global debug mode state
56
- */
57
- class DebugModeState {
58
- enabled = false;
59
- options = {};
60
- measurements = [];
61
- networkTraces = [];
62
- cryptoTraces = [];
63
- stateSnapshots = [];
64
- activeTimers = new Map();
65
- }
66
- const globalDebugState = new DebugModeState();
67
- /**
68
- * Enable debug mode with optional configuration
69
- *
70
- * @param options - Debug mode options
71
- */
72
- function enableDebugMode(options = {}) {
73
- globalDebugState.enabled = true;
74
- globalDebugState.options = {
75
- verbose: options.verbose ?? false,
76
- traceNetwork: options.traceNetwork ?? false,
77
- traceCrypto: options.traceCrypto ?? false,
78
- profile: options.profile ?? false,
79
- trackMemory: options.trackMemory ?? false,
80
- traceState: options.traceState ?? false,
81
- output: options.output ?? console.log,
82
- filters: options.filters,
83
- };
84
- const logger = (0, logger_js_1.createLogger)('debug-mode');
85
- logger.setLevel(logger_js_1.LogLevel.DEBUG);
86
- logger.info('Debug mode enabled', { options: globalDebugState.options });
87
- }
88
- /**
89
- * Disable debug mode and clear collected data
90
- */
91
- function disableDebugMode() {
92
- globalDebugState.enabled = false;
93
- globalDebugState.measurements = [];
94
- globalDebugState.networkTraces = [];
95
- globalDebugState.cryptoTraces = [];
96
- globalDebugState.stateSnapshots = [];
97
- globalDebugState.activeTimers.clear();
98
- const logger = (0, logger_js_1.createLogger)('debug-mode');
99
- logger.info('Debug mode disabled');
100
- }
101
- /**
102
- * Check if debug mode is enabled
103
- */
104
- function isDebugEnabled() {
105
- return globalDebugState.enabled;
106
- }
107
- /**
108
- * Get current debug mode options
109
- */
110
- function getDebugOptions() {
111
- return { ...globalDebugState.options };
112
- }
113
- /**
114
- * Create a debug logger for a specific component
115
- *
116
- * @param component - Component name
117
- * @returns Logger instance with debug capabilities
118
- */
119
- function createDebugLogger(component) {
120
- const logger = (0, logger_js_1.createLogger)(component);
121
- if (globalDebugState.enabled && globalDebugState.options.verbose) {
122
- logger.setLevel(logger_js_1.LogLevel.DEBUG);
123
- }
124
- return {
125
- ...logger,
126
- trace(message, context) {
127
- if (!globalDebugState.enabled || !globalDebugState.options.verbose) {
128
- return;
129
- }
130
- // Apply filters if configured
131
- if (globalDebugState.options.filters) {
132
- const { include, exclude } = globalDebugState.options.filters;
133
- if (include && !include.some((pattern) => pattern.test(message))) {
134
- return;
135
- }
136
- if (exclude && exclude.some((pattern) => pattern.test(message))) {
137
- return;
138
- }
139
- }
140
- logger.debug(message, context);
141
- },
142
- };
143
- }
144
- /**
145
- * Start performance measurement for an operation
146
- *
147
- * @param operation - Operation name
148
- * @param context - Optional context
149
- */
150
- function startProfiling(operation, context) {
151
- if (!globalDebugState.enabled || !globalDebugState.options.profile) {
152
- return;
153
- }
154
- const startTime = performance.now();
155
- globalDebugState.activeTimers.set(operation, { startTime, context });
156
- const logger = createDebugLogger('profiler');
157
- logger.trace(`[PROFILE] Starting: ${operation}`, context);
158
- }
159
- /**
160
- * End performance measurement and record result
161
- *
162
- * @param operation - Operation name
163
- * @param context - Optional context (overrides context from startProfiling if provided)
164
- */
165
- function endProfiling(operation, context) {
166
- if (!globalDebugState.enabled || !globalDebugState.options.profile) {
167
- return;
168
- }
169
- const timerData = globalDebugState.activeTimers.get(operation);
170
- if (!timerData) {
171
- const logger = createDebugLogger('profiler');
172
- logger.warn(`[PROFILE] No start time found for: ${operation}`);
173
- return;
174
- }
175
- const endTime = performance.now();
176
- const duration = endTime - timerData.startTime;
177
- // Use context from endProfiling if provided, otherwise use context from startProfiling
178
- const finalContext = context ?? timerData.context;
179
- let memoryBefore;
180
- let memoryAfter;
181
- let memoryDelta;
182
- if (globalDebugState.options.trackMemory && typeof process !== 'undefined' && process.memoryUsage) {
183
- const mem = process.memoryUsage();
184
- memoryAfter = mem.heapUsed;
185
- // Estimate (not precise without tracking before)
186
- memoryBefore = memoryAfter;
187
- memoryDelta = 0;
188
- }
189
- const measurement = {
190
- operation,
191
- startTime: timerData.startTime,
192
- endTime,
193
- duration,
194
- memoryBefore,
195
- memoryAfter,
196
- memoryDelta,
197
- context: finalContext,
198
- };
199
- globalDebugState.measurements.push(measurement);
200
- globalDebugState.activeTimers.delete(operation);
201
- const logger = createDebugLogger('profiler');
202
- logger.trace(`[PROFILE] Completed: ${operation} (${duration.toFixed(2)}ms)`, {
203
- duration,
204
- memoryDelta,
205
- ...context,
206
- });
207
- }
208
- /**
209
- * Get all performance measurements
210
- */
211
- function getPerformanceMeasurements() {
212
- return [...globalDebugState.measurements];
213
- }
214
- /**
215
- * Clear performance measurements
216
- */
217
- function clearPerformanceMeasurements() {
218
- globalDebugState.measurements = [];
219
- globalDebugState.activeTimers.clear();
220
- }
221
- /**
222
- * Log network request start
223
- *
224
- * @param id - Request ID
225
- * @param method - HTTP method
226
- * @param url - URL
227
- * @param headers - Request headers
228
- * @param body - Request body
229
- */
230
- function traceNetworkRequest(id, method, url, headers, body) {
231
- if (!globalDebugState.enabled || !globalDebugState.options.traceNetwork) {
232
- return;
233
- }
234
- const trace = {
235
- id,
236
- method,
237
- url,
238
- requestHeaders: redactHeaders(headers),
239
- requestBody: truncateBody(body),
240
- startTime: performance.now(),
241
- };
242
- globalDebugState.networkTraces.push(trace);
243
- const logger = createDebugLogger('network');
244
- logger.trace(`[NETWORK] ${method} ${url}`, {
245
- requestId: id,
246
- headers: trace.requestHeaders,
247
- bodyLength: body?.length ?? 0,
248
- });
249
- }
250
- /**
251
- * Log network response
252
- *
253
- * @param id - Request ID
254
- * @param status - HTTP status code
255
- * @param headers - Response headers
256
- * @param body - Response body
257
- * @param error - Error (if failed)
258
- */
259
- function traceNetworkResponse(id, status, headers, body, error) {
260
- if (!globalDebugState.enabled || !globalDebugState.options.traceNetwork) {
261
- return;
262
- }
263
- const trace = globalDebugState.networkTraces.find((t) => t.id === id);
264
- if (!trace) {
265
- return;
266
- }
267
- trace.endTime = performance.now();
268
- trace.duration = trace.endTime - trace.startTime;
269
- trace.status = status;
270
- trace.responseHeaders = headers ? redactHeaders(headers) : undefined;
271
- trace.responseBody = truncateBody(body);
272
- trace.error = error;
273
- const logger = createDebugLogger('network');
274
- logger.trace(`[NETWORK] Response ${status ?? 'ERROR'} (${trace.duration.toFixed(2)}ms)`, {
275
- requestId: id,
276
- status,
277
- duration: trace.duration,
278
- error,
279
- });
280
- }
281
- /**
282
- * Get all network traces
283
- */
284
- function getNetworkTraces() {
285
- return [...globalDebugState.networkTraces];
286
- }
287
- /**
288
- * Clear network traces
289
- */
290
- function clearNetworkTraces() {
291
- globalDebugState.networkTraces = [];
292
- }
293
- /**
294
- * Log crypto operation
295
- *
296
- * @param operation - Operation type
297
- * @param algorithm - Algorithm name
298
- * @param inputSize - Input size (bytes)
299
- * @param outputSize - Output size (bytes)
300
- * @param duration - Duration (ms)
301
- * @param success - Success flag
302
- * @param error - Error message (if failed)
303
- */
304
- function traceCryptoOperation(operation, algorithm, inputSize, outputSize, duration, success, error) {
305
- if (!globalDebugState.enabled || !globalDebugState.options.traceCrypto) {
306
- return;
307
- }
308
- const trace = {
309
- operation,
310
- algorithm,
311
- inputSize,
312
- outputSize,
313
- duration: duration ?? 0,
314
- success: success ?? true,
315
- error,
316
- timestamp: Date.now(),
317
- };
318
- globalDebugState.cryptoTraces.push(trace);
319
- const logger = createDebugLogger('crypto');
320
- logger.trace(`[CRYPTO] ${operation} (${algorithm})`, {
321
- inputSize,
322
- outputSize,
323
- duration,
324
- success,
325
- error,
326
- });
327
- }
328
- /**
329
- * Get all crypto traces
330
- */
331
- function getCryptoTraces() {
332
- return [...globalDebugState.cryptoTraces];
333
- }
334
- /**
335
- * Clear crypto traces
336
- */
337
- function clearCryptoTraces() {
338
- globalDebugState.cryptoTraces = [];
339
- }
340
- /**
341
- * Dump internal state of an agent
342
- *
343
- * @param agent - Agent instance
344
- * @returns State snapshot
345
- */
346
- function dumpState(agent) {
347
- const snapshot = {
348
- did: agent.did,
349
- identityMode: agent.identityMode ?? 'persistent',
350
- registered: agent.registered ?? false,
351
- registryUrl: agent.registry?.url,
352
- nonceStoreType: agent.nonceStore?.constructor?.name ?? 'unknown',
353
- nonceCount: agent.nonceStore?.size ?? 0,
354
- transportType: agent.transport?.constructor?.name ?? 'unknown',
355
- securityPolicy: {
356
- level: agent.securityPolicy?.level ?? 'unknown',
357
- replayWindow: agent.securityPolicy?.replayWindow ?? 0,
358
- timestampTolerance: agent.securityPolicy?.timestampTolerance ?? 0,
359
- },
360
- postQuantum: agent.postQuantum ?? false,
361
- memoryUsage: typeof process !== 'undefined' && process.memoryUsage
362
- ? process.memoryUsage().heapUsed
363
- : undefined,
364
- timestamp: Date.now(),
365
- };
366
- if (globalDebugState.enabled && globalDebugState.options.traceState) {
367
- globalDebugState.stateSnapshots.push(snapshot);
368
- }
369
- const logger = createDebugLogger('state');
370
- logger.trace('[STATE] Agent snapshot', snapshot);
371
- return snapshot;
372
- }
373
- /**
374
- * Get all state snapshots
375
- */
376
- function getStateSnapshots() {
377
- return [...globalDebugState.stateSnapshots];
378
- }
379
- /**
380
- * Clear state snapshots
381
- */
382
- function clearStateSnapshots() {
383
- globalDebugState.stateSnapshots = [];
384
- }
385
- /**
386
- * Export all debug data as JSON
387
- *
388
- * @returns JSON string with all debug data
389
- */
390
- function exportDebugData() {
391
- const data = {
392
- enabled: globalDebugState.enabled,
393
- options: globalDebugState.options,
394
- measurements: globalDebugState.measurements,
395
- networkTraces: globalDebugState.networkTraces,
396
- cryptoTraces: globalDebugState.cryptoTraces,
397
- stateSnapshots: globalDebugState.stateSnapshots,
398
- exportedAt: new Date().toISOString(),
399
- };
400
- return JSON.stringify(data, null, 2);
401
- }
402
- /**
403
- * Clear all debug data
404
- */
405
- function clearAllDebugData() {
406
- clearPerformanceMeasurements();
407
- clearNetworkTraces();
408
- clearCryptoTraces();
409
- clearStateSnapshots();
410
- }
411
- /**
412
- * Redact sensitive headers
413
- */
414
- function redactHeaders(headers) {
415
- const redacted = {};
416
- const sensitiveHeaders = new Set([
417
- 'authorization',
418
- 'cookie',
419
- 'set-cookie',
420
- 'x-api-key',
421
- 'x-auth-token',
422
- ]);
423
- for (const [key, value] of Object.entries(headers)) {
424
- const lowerKey = key.toLowerCase();
425
- if (sensitiveHeaders.has(lowerKey)) {
426
- redacted[key] = '[REDACTED]';
427
- }
428
- else {
429
- redacted[key] = value;
430
- }
431
- }
432
- return redacted;
433
- }
434
- /**
435
- * Truncate body to reasonable size for logging
436
- */
437
- function truncateBody(body) {
438
- if (!body)
439
- return undefined;
440
- const maxLength = 1000;
441
- if (body.length <= maxLength) {
442
- return body;
443
- }
444
- return body.substring(0, maxLength) + `... (${body.length - maxLength} more bytes)`;
445
- }
446
- /**
447
- * Generate debug report
448
- *
449
- * @returns Human-readable debug report
450
- */
451
- function generateDebugReport() {
452
- const lines = [];
453
- lines.push('='.repeat(80));
454
- lines.push('xBind Debug Report');
455
- lines.push('='.repeat(80));
456
- lines.push('');
457
- lines.push(`Generated: ${new Date().toISOString()}`);
458
- lines.push(`Debug Mode: ${globalDebugState.enabled ? 'ENABLED' : 'DISABLED'}`);
459
- lines.push('');
460
- if (globalDebugState.measurements.length > 0) {
461
- lines.push('Performance Measurements:');
462
- lines.push('-'.repeat(80));
463
- for (const m of globalDebugState.measurements) {
464
- lines.push(` ${m.operation}: ${m.duration.toFixed(2)}ms`);
465
- if (m.memoryDelta !== undefined) {
466
- lines.push(` Memory: ${formatBytes(m.memoryDelta)}`);
467
- }
468
- }
469
- lines.push('');
470
- }
471
- if (globalDebugState.networkTraces.length > 0) {
472
- lines.push('Network Traces:');
473
- lines.push('-'.repeat(80));
474
- for (const n of globalDebugState.networkTraces) {
475
- lines.push(` ${n.method} ${n.url}`);
476
- if (n.status) {
477
- lines.push(` Status: ${n.status}`);
478
- }
479
- if (n.duration) {
480
- lines.push(` Duration: ${n.duration.toFixed(2)}ms`);
481
- }
482
- if (n.error) {
483
- lines.push(` Error: ${n.error}`);
484
- }
485
- }
486
- lines.push('');
487
- }
488
- if (globalDebugState.cryptoTraces.length > 0) {
489
- lines.push('Crypto Operations:');
490
- lines.push('-'.repeat(80));
491
- for (const c of globalDebugState.cryptoTraces) {
492
- lines.push(` ${c.operation} (${c.algorithm})`);
493
- lines.push(` Input: ${formatBytes(c.inputSize)}`);
494
- if (c.outputSize) {
495
- lines.push(` Output: ${formatBytes(c.outputSize)}`);
496
- }
497
- lines.push(` Duration: ${c.duration.toFixed(2)}ms`);
498
- lines.push(` Success: ${c.success}`);
499
- if (c.error) {
500
- lines.push(` Error: ${c.error}`);
501
- }
502
- }
503
- lines.push('');
504
- }
505
- if (globalDebugState.stateSnapshots.length > 0) {
506
- lines.push('State Snapshots:');
507
- lines.push('-'.repeat(80));
508
- const latest = globalDebugState.stateSnapshots[globalDebugState.stateSnapshots.length - 1];
509
- if (latest) {
510
- lines.push(` DID: ${latest.did}`);
511
- lines.push(` Mode: ${latest.identityMode}`);
512
- lines.push(` Registered: ${latest.registered}`);
513
- lines.push(` Post-Quantum: ${latest.postQuantum}`);
514
- lines.push(` Nonce Count: ${latest.nonceCount}`);
515
- if (latest.memoryUsage) {
516
- lines.push(` Memory Usage: ${formatBytes(latest.memoryUsage)}`);
517
- }
518
- }
519
- lines.push('');
520
- }
521
- lines.push('='.repeat(80));
522
- return lines.join('\n');
523
- }
524
- /**
525
- * Format bytes as human-readable string
526
- */
527
- function formatBytes(bytes) {
528
- if (bytes === 0)
529
- return '0 B';
530
- const units = ['B', 'KB', 'MB', 'GB'];
531
- const i = Math.floor(Math.log(Math.abs(bytes)) / Math.log(1024));
532
- const value = bytes / Math.pow(1024, i);
533
- return `${value.toFixed(2)} ${units[i]}`;
534
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.enableDebugMode=enableDebugMode,exports.disableDebugMode=disableDebugMode,exports.isDebugEnabled=isDebugEnabled,exports.getDebugOptions=getDebugOptions,exports.createDebugLogger=createDebugLogger,exports.startProfiling=startProfiling,exports.endProfiling=endProfiling,exports.getPerformanceMeasurements=getPerformanceMeasurements,exports.clearPerformanceMeasurements=clearPerformanceMeasurements,exports.traceNetworkRequest=traceNetworkRequest,exports.traceNetworkResponse=traceNetworkResponse,exports.getNetworkTraces=getNetworkTraces,exports.clearNetworkTraces=clearNetworkTraces,exports.traceCryptoOperation=traceCryptoOperation,exports.getCryptoTraces=getCryptoTraces,exports.clearCryptoTraces=clearCryptoTraces,exports.dumpState=dumpState,exports.getStateSnapshots=getStateSnapshots,exports.clearStateSnapshots=clearStateSnapshots,exports.exportDebugData=exportDebugData,exports.clearAllDebugData=clearAllDebugData,exports.generateDebugReport=generateDebugReport;const logger_js_1=require("./logger.js");class DebugModeState{enabled=!1;options={};measurements=[];networkTraces=[];cryptoTraces=[];stateSnapshots=[];activeTimers=new Map}const globalDebugState=new DebugModeState;function enableDebugMode(e={}){globalDebugState.enabled=!0,globalDebugState.options={verbose:e.verbose??!1,traceNetwork:e.traceNetwork??!1,traceCrypto:e.traceCrypto??!1,profile:e.profile??!1,trackMemory:e.trackMemory??!1,traceState:e.traceState??!1,output:e.output??console.log,filters:e.filters};const t=(0,logger_js_1.createLogger)("debug-mode");t.setLevel(logger_js_1.LogLevel.DEBUG),t.info("Debug mode enabled",{options:globalDebugState.options})}function disableDebugMode(){globalDebugState.enabled=!1,globalDebugState.measurements=[],globalDebugState.networkTraces=[],globalDebugState.cryptoTraces=[],globalDebugState.stateSnapshots=[],globalDebugState.activeTimers.clear();(0,logger_js_1.createLogger)("debug-mode").info("Debug mode disabled")}function isDebugEnabled(){return globalDebugState.enabled}function getDebugOptions(){return{...globalDebugState.options}}function createDebugLogger(e){const t=(0,logger_js_1.createLogger)(e);return globalDebugState.enabled&&globalDebugState.options.verbose&&t.setLevel(logger_js_1.LogLevel.DEBUG),{...t,trace(e,o){if(globalDebugState.enabled&&globalDebugState.options.verbose){if(globalDebugState.options.filters){const{include:t,exclude:o}=globalDebugState.options.filters;if(t&&!t.some(t=>t.test(e)))return;if(o&&o.some(t=>t.test(e)))return}t.debug(e,o)}}}}function startProfiling(e,t){if(!globalDebugState.enabled||!globalDebugState.options.profile)return;const o=performance.now();globalDebugState.activeTimers.set(e,{startTime:o,context:t});createDebugLogger("profiler").trace(`[PROFILE] Starting: ${e}`,t)}function endProfiling(e,t){if(!globalDebugState.enabled||!globalDebugState.options.profile)return;const o=globalDebugState.activeTimers.get(e);if(!o){return void createDebugLogger("profiler").warn(`[PROFILE] No start time found for: ${e}`)}const r=performance.now(),a=r-o.startTime,s=t??o.context;let n,u,g;if(globalDebugState.options.trackMemory&&"undefined"!=typeof process&&process.memoryUsage){u=process.memoryUsage().heapUsed,n=u,g=0}const l={operation:e,startTime:o.startTime,endTime:r,duration:a,memoryBefore:n,memoryAfter:u,memoryDelta:g,context:s};globalDebugState.measurements.push(l),globalDebugState.activeTimers.delete(e);createDebugLogger("profiler").trace(`[PROFILE] Completed: ${e} (${a.toFixed(2)}ms)`,{duration:a,memoryDelta:g,...t})}function getPerformanceMeasurements(){return[...globalDebugState.measurements]}function clearPerformanceMeasurements(){globalDebugState.measurements=[],globalDebugState.activeTimers.clear()}function traceNetworkRequest(e,t,o,r,a){if(!globalDebugState.enabled||!globalDebugState.options.traceNetwork)return;const s={id:e,method:t,url:o,requestHeaders:redactHeaders(r),requestBody:truncateBody(a),startTime:performance.now()};globalDebugState.networkTraces.push(s);createDebugLogger("network").trace(`[NETWORK] ${t} ${o}`,{requestId:e,headers:s.requestHeaders,bodyLength:a?.length??0})}function traceNetworkResponse(e,t,o,r,a){if(!globalDebugState.enabled||!globalDebugState.options.traceNetwork)return;const s=globalDebugState.networkTraces.find(t=>t.id===e);if(!s)return;s.endTime=performance.now(),s.duration=s.endTime-s.startTime,s.status=t,s.responseHeaders=o?redactHeaders(o):void 0,s.responseBody=truncateBody(r),s.error=a;createDebugLogger("network").trace(`[NETWORK] Response ${t??"ERROR"} (${s.duration.toFixed(2)}ms)`,{requestId:e,status:t,duration:s.duration,error:a})}function getNetworkTraces(){return[...globalDebugState.networkTraces]}function clearNetworkTraces(){globalDebugState.networkTraces=[]}function traceCryptoOperation(e,t,o,r,a,s,n){if(!globalDebugState.enabled||!globalDebugState.options.traceCrypto)return;const u={operation:e,algorithm:t,inputSize:o,outputSize:r,duration:a??0,success:s??!0,error:n,timestamp:Date.now()};globalDebugState.cryptoTraces.push(u);createDebugLogger("crypto").trace(`[CRYPTO] ${e} (${t})`,{inputSize:o,outputSize:r,duration:a,success:s,error:n})}function getCryptoTraces(){return[...globalDebugState.cryptoTraces]}function clearCryptoTraces(){globalDebugState.cryptoTraces=[]}function dumpState(e){const t=e,o={did:e.did,identityMode:t.identityMode??"persistent",registered:t.registered??!1,registryUrl:t.registry?.url,nonceStoreType:t.nonceStore?.constructor?.name??"unknown",nonceCount:t.nonceStore?.size??0,transportType:t.transport?.constructor?.name??"unknown",securityPolicy:{level:t.securityPolicy?.level??"unknown",replayWindow:t.securityPolicy?.replayWindow??0,timestampTolerance:t.securityPolicy?.timestampTolerance??0},postQuantum:t.postQuantum??!1,memoryUsage:"undefined"!=typeof process&&process.memoryUsage?process.memoryUsage().heapUsed:void 0,timestamp:Date.now()};globalDebugState.enabled&&globalDebugState.options.traceState&&globalDebugState.stateSnapshots.push(o);return createDebugLogger("state").trace("[STATE] Agent snapshot",o),o}function getStateSnapshots(){return[...globalDebugState.stateSnapshots]}function clearStateSnapshots(){globalDebugState.stateSnapshots=[]}function exportDebugData(){const e={enabled:globalDebugState.enabled,options:globalDebugState.options,measurements:globalDebugState.measurements,networkTraces:globalDebugState.networkTraces,cryptoTraces:globalDebugState.cryptoTraces,stateSnapshots:globalDebugState.stateSnapshots,exportedAt:(new Date).toISOString()};return JSON.stringify(e,null,2)}function clearAllDebugData(){clearPerformanceMeasurements(),clearNetworkTraces(),clearCryptoTraces(),clearStateSnapshots()}function redactHeaders(e){const t={},o=new Set(["authorization","cookie","set-cookie","x-api-key","x-auth-token"]);for(const[r,a]of Object.entries(e)){const e=r.toLowerCase();o.has(e)?t[r]="[REDACTED]":t[r]=a}return t}function truncateBody(e){if(!e)return;const t=1e3;return e.length<=t?e:e.substring(0,t)+`... (${e.length-t} more bytes)`}function generateDebugReport(){const e=[];if(e.push("=".repeat(80)),e.push("xBind Debug Report"),e.push("=".repeat(80)),e.push(""),e.push(`Generated: ${(new Date).toISOString()}`),e.push("Debug Mode: "+(globalDebugState.enabled?"ENABLED":"DISABLED")),e.push(""),globalDebugState.measurements.length>0){e.push("Performance Measurements:"),e.push("-".repeat(80));for(const t of globalDebugState.measurements)e.push(` ${t.operation}: ${t.duration.toFixed(2)}ms`),void 0!==t.memoryDelta&&e.push(` Memory: ${formatBytes(t.memoryDelta)}`);e.push("")}if(globalDebugState.networkTraces.length>0){e.push("Network Traces:"),e.push("-".repeat(80));for(const t of globalDebugState.networkTraces)e.push(` ${t.method} ${t.url}`),t.status&&e.push(` Status: ${t.status}`),t.duration&&e.push(` Duration: ${t.duration.toFixed(2)}ms`),t.error&&e.push(` Error: ${t.error}`);e.push("")}if(globalDebugState.cryptoTraces.length>0){e.push("Crypto Operations:"),e.push("-".repeat(80));for(const t of globalDebugState.cryptoTraces)e.push(` ${t.operation} (${t.algorithm})`),e.push(` Input: ${formatBytes(t.inputSize)}`),t.outputSize&&e.push(` Output: ${formatBytes(t.outputSize)}`),e.push(` Duration: ${t.duration.toFixed(2)}ms`),e.push(` Success: ${t.success}`),t.error&&e.push(` Error: ${t.error}`);e.push("")}if(globalDebugState.stateSnapshots.length>0){e.push("State Snapshots:"),e.push("-".repeat(80));const t=globalDebugState.stateSnapshots[globalDebugState.stateSnapshots.length-1];t&&(e.push(` DID: ${t.did}`),e.push(` Mode: ${t.identityMode}`),e.push(` Registered: ${t.registered}`),e.push(` Post-Quantum: ${t.postQuantum}`),e.push(` Nonce Count: ${t.nonceCount}`),t.memoryUsage&&e.push(` Memory Usage: ${formatBytes(t.memoryUsage)}`)),e.push("")}return e.push("=".repeat(80)),e.join("\n")}function formatBytes(e){if(0===e)return"0 B";const t=Math.floor(Math.log(Math.abs(e))/Math.log(1024));return`${(e/Math.pow(1024,t)).toFixed(2)} ${["B","KB","MB","GB"][t]}`}
@@ -1,101 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateDidDocument = generateDidDocument;
4
- exports.resolveDid = resolveDid;
5
- exports.getServiceEndpoints = getServiceEndpoints;
6
- const shared_1 = require("../_deps/shared/index.js");
7
- const crypto_utils_js_1 = require("./crypto-utils.js");
8
- /**
9
- * Generate a DID document for a given DID.
10
- *
11
- * Includes service endpoints that advertise PRIVATE.ME/xBind.
12
- * Both did:key and did:privateme DIDs generate the same service endpoints.
13
- *
14
- * @param did - The DID (did:key:z... or did:privateme:z...)
15
- * @param rawPublicKey - The 32-byte Ed25519 public key
16
- * @param name - Optional name for the identity
17
- * @returns DID document with service endpoints
18
- */
19
- function generateDidDocument(did, rawPublicKey, name) {
20
- if (!did.startsWith('did:key:') && !did.startsWith('did:privateme:')) {
21
- return (0, shared_1.err)('INVALID_DID_FORMAT');
22
- }
23
- // Convert public key to base64 for inclusion in document
24
- const publicKeyBase64 = (0, crypto_utils_js_1.toBase64)(rawPublicKey);
25
- const document = {
26
- '@context': [
27
- 'https://www.w3.org/ns/did/v1',
28
- 'https://w3id.org/security/suites/ed25519-2020/v1',
29
- ],
30
- id: did,
31
- publicKey: [
32
- {
33
- id: `${did}#key-1`,
34
- type: 'Ed25519VerificationKey2020',
35
- controller: did,
36
- publicKeyBase64,
37
- },
38
- ],
39
- authentication: [`${did}#key-1`],
40
- assertionMethod: [`${did}#key-1`],
41
- keyAgreement: [`${did}#key-1`],
42
- service: [
43
- {
44
- id: `${did}#identity-provider`,
45
- type: 'IdentityProvider',
46
- serviceEndpoint: 'https://private.me',
47
- description: 'PRIVATE.ME xBind Agent - M2M identity authentication',
48
- },
49
- {
50
- id: `${did}#documentation`,
51
- type: 'Documentation',
52
- serviceEndpoint: 'https://private.me/docs/xbind.html',
53
- description: 'Learn more about PRIVATE.ME/xBind protocol',
54
- },
55
- ],
56
- ...(name ? { name } : {}),
57
- };
58
- return (0, shared_1.ok)(document);
59
- }
60
- /**
61
- * Resolve a DID to its document (simulated).
62
- *
63
- * In a production system, this would query a DID resolver.
64
- * For now, this generates a synthetic document based on the DID.
65
- *
66
- * @param did - The DID to resolve
67
- * @param rawPublicKey - The 32-byte Ed25519 public key
68
- * @returns DID document or error
69
- */
70
- async function resolveDid(did, rawPublicKey) {
71
- // In a production system, this would make an HTTP request to a DID resolver
72
- // For now, generate a synthetic document
73
- return generateDidDocument(did, rawPublicKey);
74
- }
75
- /**
76
- * Extract service endpoints from a DID document.
77
- *
78
- * Filters for PRIVATE.ME service endpoints to provide discovery information.
79
- *
80
- * @param document - The DID document
81
- * @returns Array of service endpoints advertising PRIVATE.ME services
82
- */
83
- function getServiceEndpoints(document) {
84
- if (!document.service)
85
- return [];
86
- return document.service
87
- .filter((svc) => {
88
- const endpoint = typeof svc.serviceEndpoint === 'string' ? svc.serviceEndpoint : '';
89
- return (endpoint.includes('private.me') ||
90
- svc.type.includes('PRIVATE.ME') ||
91
- svc.type === 'IdentityProvider' ||
92
- svc.type === 'Documentation');
93
- })
94
- .map((svc) => ({
95
- type: svc.type,
96
- endpoint: typeof svc.serviceEndpoint === 'string'
97
- ? svc.serviceEndpoint
98
- : JSON.stringify(svc.serviceEndpoint),
99
- description: svc.description,
100
- }));
101
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateDidDocument=generateDidDocument,exports.resolveDid=resolveDid,exports.getServiceEndpoints=getServiceEndpoints;const shared_1=require("../_deps/shared/index.js"),crypto_utils_js_1=require("./crypto-utils.js");function generateDidDocument(e,t,i){if(!e.startsWith("did:key:")&&!e.startsWith("did:privateme:"))return(0,shared_1.err)("INVALID_DID_FORMAT");const n={"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/ed25519-2020/v1"],id:e,publicKey:[{id:`${e}#key-1`,type:"Ed25519VerificationKey2020",controller:e,publicKeyBase64:(0,crypto_utils_js_1.toBase64)(t)}],authentication:[`${e}#key-1`],assertionMethod:[`${e}#key-1`],keyAgreement:[`${e}#key-1`],service:[{id:`${e}#identity-provider`,type:"IdentityProvider",serviceEndpoint:"https://private.me",description:"PRIVATE.ME xBind Agent - M2M identity authentication"},{id:`${e}#documentation`,type:"Documentation",serviceEndpoint:"https://private.me/docs/xbind.html",description:"Learn more about PRIVATE.ME/xBind protocol"}],...i?{name:i}:{}};return(0,shared_1.ok)(n)}async function resolveDid(e,t){return generateDidDocument(e,t)}function getServiceEndpoints(e){return e.service?e.service.filter(e=>("string"==typeof e.serviceEndpoint?e.serviceEndpoint:"").includes("private.me")||e.type.includes("PRIVATE.ME")||"IdentityProvider"===e.type||"Documentation"===e.type).map(e=>({type:e.type,endpoint:"string"==typeof e.serviceEndpoint?e.serviceEndpoint:JSON.stringify(e.serviceEndpoint),description:e.description})):[]}