nostr-wot-sdk 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.4.1] - 2025-02-05
9
+
10
+ ### Changed
11
+
12
+ - **`getDetails` now returns `score`** in addition to `hops` and `paths`
13
+ - Extension: `{ hops: 2, paths: 5, score: 0.65 }`
14
+ - Oracle fallback: `{ hops: 2, paths: 5, score: 0 }` (score is 0 when using oracle)
15
+
16
+ - **`getDistanceBatch` now accepts options object** instead of boolean
17
+ - `{ includePaths: true }` - Include path counts
18
+ - `{ includeScores: true }` - Include trust scores
19
+ - `{ includePaths: true, includeScores: true }` - Include both
20
+ - Legacy boolean `true` still works (backwards compatible, same as `{ includePaths: true }`)
21
+
22
+ ### Added
23
+
24
+ - New `DistanceBatchOptions` type exported for TypeScript users
25
+
8
26
  ## [0.4.0] - 2025-02-05
9
27
 
10
28
  ### Breaking Changes
@@ -153,6 +171,7 @@ function Profile({ pubkey }) {
153
171
  - TypeScript support with full type definitions
154
172
  - Error classes: `WoTError`, `NetworkError`, `NotFoundError`, `TimeoutError`, `ValidationError`
155
173
 
174
+ [0.4.1]: https://github.com/nostr-wot/nostr-wot-sdk/compare/v0.4.0...v0.4.1
156
175
  [0.4.0]: https://github.com/nostr-wot/nostr-wot-sdk/compare/v0.3.2...v0.4.0
157
176
  [0.3.2]: https://github.com/nostr-wot/nostr-wot-sdk/compare/v0.3.1...v0.3.2
158
177
  [0.3.1]: https://github.com/nostr-wot/nostr-wot-sdk/compare/v0.3.0...v0.3.1
package/README.md CHANGED
@@ -124,11 +124,11 @@ const results = await wot.batchCheck(['pk1...', 'pk2...', 'pk3...']);
124
124
 
125
125
  #### `getDetails(target, options?)`
126
126
 
127
- Get distance and path count details.
127
+ Get distance, path count, and score details.
128
128
  ```javascript
129
129
  const details = await wot.getDetails('def456...');
130
- // Returns: { hops: 2, paths: 5 }
131
- // Oracle may also return: bridges, mutual
130
+ // Returns: { hops: 2, paths: 5, score: 0.65 }
131
+ // Oracle may also return: bridges, mutual (but score will be 0)
132
132
  ```
133
133
 
134
134
  #### `getMyPubkey()`
@@ -157,17 +157,28 @@ const config = await wot.getExtensionConfig();
157
157
 
158
158
  ### Batch Operations
159
159
 
160
- #### `getDistanceBatch(targets, includePaths?)`
160
+ #### `getDistanceBatch(targets, options?)`
161
161
 
162
162
  Get distances for multiple pubkeys in a single call.
163
163
  ```javascript
164
- // Without paths (faster, default)
164
+ // Default (just hops)
165
165
  const distances = await wot.getDistanceBatch(['pk1...', 'pk2...']);
166
166
  // Returns: { 'pk1...': 2, 'pk2...': null }
167
167
 
168
- // With paths (includes path count for scoring)
169
- const details = await wot.getDistanceBatch(['pk1...', 'pk2...'], true);
168
+ // With paths
169
+ const withPaths = await wot.getDistanceBatch(['pk1...', 'pk2...'], { includePaths: true });
170
170
  // Returns: { 'pk1...': { hops: 2, paths: 5 }, 'pk2...': null }
171
+
172
+ // With scores
173
+ const withScores = await wot.getDistanceBatch(['pk1...', 'pk2...'], { includeScores: true });
174
+ // Returns: { 'pk1...': { hops: 2, score: 0.65 }, 'pk2...': null }
175
+
176
+ // With both
177
+ const full = await wot.getDistanceBatch(['pk1...', 'pk2...'], { includePaths: true, includeScores: true });
178
+ // Returns: { 'pk1...': { hops: 2, paths: 5, score: 0.65 }, 'pk2...': null }
179
+
180
+ // Legacy boolean still works (backwards compatible)
181
+ const legacy = await wot.getDistanceBatch(['pk1...'], true); // same as { includePaths: true }
171
182
  ```
172
183
 
173
184
  #### `getTrustScoreBatch(targets)`
package/dist/index.cjs CHANGED
@@ -621,10 +621,11 @@ var WoT = class {
621
621
  const myPubkey = await this.getEffectivePubkey();
622
622
  const maxHops = (_a = options == null ? void 0 : options.maxHops) != null ? _a : this.maxHops;
623
623
  try {
624
- return await this.apiRequest(
624
+ const response = await this.apiRequest(
625
625
  `/details/${myPubkey}/${normalizedTarget}?maxHops=${maxHops}`,
626
626
  options
627
627
  );
628
+ return { ...response, score: 0 };
628
629
  } catch (error) {
629
630
  if (error instanceof NotFoundError) {
630
631
  return null;
@@ -745,26 +746,32 @@ var WoT = class {
745
746
  const normalizedTarget = this.validatePubkey(target, "target");
746
747
  return ext.getPath(normalizedTarget);
747
748
  }
748
- async getDistanceBatch(targets, includePaths = false) {
749
+ async getDistanceBatch(targets, options = false) {
749
750
  if (!Array.isArray(targets) || targets.length === 0) {
750
751
  return {};
751
752
  }
752
753
  const normalizedTargets = targets.map(
753
754
  (t, i) => this.validatePubkey(t, `targets[${i}]`)
754
755
  );
756
+ const opts = typeof options === "boolean" ? { includePaths: options } : options || {};
757
+ const { includePaths, includeScores } = opts;
755
758
  const ext = await this.getExtension();
756
759
  if (ext) {
757
- if (includePaths) {
758
- return ext.getDistanceBatch(normalizedTargets, true);
759
- }
760
- return ext.getDistanceBatch(normalizedTargets, false);
760
+ return ext.getDistanceBatch(normalizedTargets, opts);
761
761
  }
762
- if (includePaths) {
762
+ if (includePaths || includeScores) {
763
763
  const results2 = {};
764
764
  await Promise.all(
765
765
  normalizedTargets.map(async (pubkey) => {
766
766
  const details = await this.getDetails(pubkey);
767
- results2[pubkey] = details ? { hops: details.hops, paths: details.paths } : null;
767
+ if (!details) {
768
+ results2[pubkey] = null;
769
+ return;
770
+ }
771
+ const result = { hops: details.hops };
772
+ if (includePaths) result.paths = details.paths;
773
+ if (includeScores) result.score = details.score;
774
+ results2[pubkey] = result;
768
775
  })
769
776
  );
770
777
  return results2;
package/dist/index.d.cts CHANGED
@@ -88,7 +88,7 @@ interface QueryOptions {
88
88
  timeout?: number;
89
89
  }
90
90
  /**
91
- * Distance result from extension (simpler)
91
+ * Distance result from extension
92
92
  */
93
93
  interface ExtensionDistanceResult {
94
94
  /**
@@ -99,6 +99,24 @@ interface ExtensionDistanceResult {
99
99
  * Number of distinct paths to target
100
100
  */
101
101
  paths: number;
102
+ /**
103
+ * Trust score (0-1)
104
+ * Note: Only available from extension, oracle returns 0
105
+ */
106
+ score: number;
107
+ }
108
+ /**
109
+ * Options for getDistanceBatch
110
+ */
111
+ interface DistanceBatchOptions {
112
+ /**
113
+ * Include path count in results
114
+ */
115
+ includePaths?: boolean;
116
+ /**
117
+ * Include trust scores in results
118
+ */
119
+ includeScores?: boolean;
102
120
  }
103
121
  /**
104
122
  * Full distance result with additional details (from oracle)
@@ -231,8 +249,8 @@ interface NostrWoTExtension {
231
249
  */
232
250
  getTrustScore(target: string): Promise<number | null>;
233
251
  /**
234
- * Get distance and path count details
235
- * @returns Object with hops and paths count, or null if not connected
252
+ * Get distance, path count, and score details
253
+ * @returns Object with hops, paths, and score, or null if not connected
236
254
  */
237
255
  getDetails(target: string): Promise<ExtensionDistanceResult | null>;
238
256
  /**
@@ -243,17 +261,40 @@ interface NostrWoTExtension {
243
261
  /**
244
262
  * Get distances for multiple pubkeys in a single call
245
263
  * @param targets - Array of target pubkeys
246
- * @param includePaths - When true, includes path count for each target
247
- * @returns Map of pubkey to hop count (or { hops, paths } if includePaths is true)
248
- */
249
- getDistanceBatch(targets: string[], includePaths?: false): Promise<Record<string, number | null>>;
250
- getDistanceBatch(targets: string[], includePaths: true): Promise<Record<string, {
264
+ * @param options - Options object or boolean for backwards compatibility
265
+ * - `{ includePaths: true }` - Include path counts
266
+ * - `{ includeScores: true }` - Include trust scores
267
+ * - `{ includePaths: true, includeScores: true }` - Include both
268
+ * - `true` (legacy) - Same as `{ includePaths: true }`
269
+ * @returns Map of pubkey to result based on options
270
+ */
271
+ getDistanceBatch(targets: string[], options?: false | undefined): Promise<Record<string, number | null>>;
272
+ getDistanceBatch(targets: string[], options: true | {
273
+ includePaths: true;
274
+ includeScores?: false;
275
+ }): Promise<Record<string, {
251
276
  hops: number;
252
277
  paths: number;
253
278
  } | null>>;
254
- getDistanceBatch(targets: string[], includePaths?: boolean): Promise<Record<string, number | {
279
+ getDistanceBatch(targets: string[], options: {
280
+ includePaths?: false;
281
+ includeScores: true;
282
+ }): Promise<Record<string, {
283
+ hops: number;
284
+ score: number;
285
+ } | null>>;
286
+ getDistanceBatch(targets: string[], options: {
287
+ includePaths: true;
288
+ includeScores: true;
289
+ }): Promise<Record<string, {
255
290
  hops: number;
256
291
  paths: number;
292
+ score: number;
293
+ } | null>>;
294
+ getDistanceBatch(targets: string[], options?: boolean | DistanceBatchOptions): Promise<Record<string, number | {
295
+ hops: number;
296
+ paths?: number;
297
+ score?: number;
257
298
  } | null>>;
258
299
  /**
259
300
  * Get trust scores for multiple pubkeys in a single call
@@ -455,17 +496,40 @@ declare class WoT {
455
496
  /**
456
497
  * Get distances for multiple pubkeys in a single call
457
498
  * @param targets - Array of target pubkeys
458
- * @param includePaths - When true, includes path count for each target
459
- * @returns Record of pubkey to hop count (or { hops, paths } if includePaths is true)
460
- */
461
- getDistanceBatch(targets: string[], includePaths?: false): Promise<Record<string, number | null>>;
462
- getDistanceBatch(targets: string[], includePaths: true): Promise<Record<string, {
499
+ * @param options - Options object or boolean for backwards compatibility
500
+ * - `{ includePaths: true }` - Include path counts
501
+ * - `{ includeScores: true }` - Include trust scores
502
+ * - `{ includePaths: true, includeScores: true }` - Include both
503
+ * - `true` (legacy) - Same as `{ includePaths: true }`
504
+ * @returns Record of pubkey to result based on options
505
+ */
506
+ getDistanceBatch(targets: string[], options?: false | undefined): Promise<Record<string, number | null>>;
507
+ getDistanceBatch(targets: string[], options: true | {
508
+ includePaths: true;
509
+ includeScores?: false;
510
+ }): Promise<Record<string, {
463
511
  hops: number;
464
512
  paths: number;
465
513
  } | null>>;
466
- getDistanceBatch(targets: string[], includePaths?: boolean): Promise<Record<string, number | {
514
+ getDistanceBatch(targets: string[], options: {
515
+ includePaths?: false;
516
+ includeScores: true;
517
+ }): Promise<Record<string, {
518
+ hops: number;
519
+ score: number;
520
+ } | null>>;
521
+ getDistanceBatch(targets: string[], options: {
522
+ includePaths: true;
523
+ includeScores: true;
524
+ }): Promise<Record<string, {
467
525
  hops: number;
468
526
  paths: number;
527
+ score: number;
528
+ } | null>>;
529
+ getDistanceBatch(targets: string[], options?: boolean | DistanceBatchOptions): Promise<Record<string, number | {
530
+ hops: number;
531
+ paths?: number;
532
+ score?: number;
469
533
  } | null>>;
470
534
  /**
471
535
  * Get trust scores for multiple pubkeys in a single call
@@ -644,4 +708,4 @@ declare const MAX_BATCH_SIZE = 10000;
644
708
  */
645
709
  declare function normalizePubkey(pubkey: string): string;
646
710
 
647
- export { type BatchResult, DEFAULT_MAX_HOPS, DEFAULT_ORACLE, DEFAULT_TIMEOUT, type DistanceResult, type ExtensionConfig, type ExtensionConnectionOptions, type ExtensionConnectionResult, type ExtensionConnectionState, ExtensionConnector, type ExtensionDistanceResult, type ExtensionStatus, type GraphStats, MAX_BATCH_SIZE, NetworkError, type NostrContactEvent, type NostrWindow, type NostrWoTExtension, NotFoundError, type QueryOptions, type ScoringConfig, TimeoutError, ValidationError, WoT, WoTError, type WoTFallbackOptions, type WoTOptions, checkAndConnect, checkExtension, connectExtension, getDefaultConnector, isValidOracleUrl, isValidPubkey, normalizePubkey, resetDefaultConnector };
711
+ export { type BatchResult, DEFAULT_MAX_HOPS, DEFAULT_ORACLE, DEFAULT_TIMEOUT, type DistanceBatchOptions, type DistanceResult, type ExtensionConfig, type ExtensionConnectionOptions, type ExtensionConnectionResult, type ExtensionConnectionState, ExtensionConnector, type ExtensionDistanceResult, type ExtensionStatus, type GraphStats, MAX_BATCH_SIZE, NetworkError, type NostrContactEvent, type NostrWindow, type NostrWoTExtension, NotFoundError, type QueryOptions, type ScoringConfig, TimeoutError, ValidationError, WoT, WoTError, type WoTFallbackOptions, type WoTOptions, checkAndConnect, checkExtension, connectExtension, getDefaultConnector, isValidOracleUrl, isValidPubkey, normalizePubkey, resetDefaultConnector };
package/dist/index.d.ts CHANGED
@@ -88,7 +88,7 @@ interface QueryOptions {
88
88
  timeout?: number;
89
89
  }
90
90
  /**
91
- * Distance result from extension (simpler)
91
+ * Distance result from extension
92
92
  */
93
93
  interface ExtensionDistanceResult {
94
94
  /**
@@ -99,6 +99,24 @@ interface ExtensionDistanceResult {
99
99
  * Number of distinct paths to target
100
100
  */
101
101
  paths: number;
102
+ /**
103
+ * Trust score (0-1)
104
+ * Note: Only available from extension, oracle returns 0
105
+ */
106
+ score: number;
107
+ }
108
+ /**
109
+ * Options for getDistanceBatch
110
+ */
111
+ interface DistanceBatchOptions {
112
+ /**
113
+ * Include path count in results
114
+ */
115
+ includePaths?: boolean;
116
+ /**
117
+ * Include trust scores in results
118
+ */
119
+ includeScores?: boolean;
102
120
  }
103
121
  /**
104
122
  * Full distance result with additional details (from oracle)
@@ -231,8 +249,8 @@ interface NostrWoTExtension {
231
249
  */
232
250
  getTrustScore(target: string): Promise<number | null>;
233
251
  /**
234
- * Get distance and path count details
235
- * @returns Object with hops and paths count, or null if not connected
252
+ * Get distance, path count, and score details
253
+ * @returns Object with hops, paths, and score, or null if not connected
236
254
  */
237
255
  getDetails(target: string): Promise<ExtensionDistanceResult | null>;
238
256
  /**
@@ -243,17 +261,40 @@ interface NostrWoTExtension {
243
261
  /**
244
262
  * Get distances for multiple pubkeys in a single call
245
263
  * @param targets - Array of target pubkeys
246
- * @param includePaths - When true, includes path count for each target
247
- * @returns Map of pubkey to hop count (or { hops, paths } if includePaths is true)
248
- */
249
- getDistanceBatch(targets: string[], includePaths?: false): Promise<Record<string, number | null>>;
250
- getDistanceBatch(targets: string[], includePaths: true): Promise<Record<string, {
264
+ * @param options - Options object or boolean for backwards compatibility
265
+ * - `{ includePaths: true }` - Include path counts
266
+ * - `{ includeScores: true }` - Include trust scores
267
+ * - `{ includePaths: true, includeScores: true }` - Include both
268
+ * - `true` (legacy) - Same as `{ includePaths: true }`
269
+ * @returns Map of pubkey to result based on options
270
+ */
271
+ getDistanceBatch(targets: string[], options?: false | undefined): Promise<Record<string, number | null>>;
272
+ getDistanceBatch(targets: string[], options: true | {
273
+ includePaths: true;
274
+ includeScores?: false;
275
+ }): Promise<Record<string, {
251
276
  hops: number;
252
277
  paths: number;
253
278
  } | null>>;
254
- getDistanceBatch(targets: string[], includePaths?: boolean): Promise<Record<string, number | {
279
+ getDistanceBatch(targets: string[], options: {
280
+ includePaths?: false;
281
+ includeScores: true;
282
+ }): Promise<Record<string, {
283
+ hops: number;
284
+ score: number;
285
+ } | null>>;
286
+ getDistanceBatch(targets: string[], options: {
287
+ includePaths: true;
288
+ includeScores: true;
289
+ }): Promise<Record<string, {
255
290
  hops: number;
256
291
  paths: number;
292
+ score: number;
293
+ } | null>>;
294
+ getDistanceBatch(targets: string[], options?: boolean | DistanceBatchOptions): Promise<Record<string, number | {
295
+ hops: number;
296
+ paths?: number;
297
+ score?: number;
257
298
  } | null>>;
258
299
  /**
259
300
  * Get trust scores for multiple pubkeys in a single call
@@ -455,17 +496,40 @@ declare class WoT {
455
496
  /**
456
497
  * Get distances for multiple pubkeys in a single call
457
498
  * @param targets - Array of target pubkeys
458
- * @param includePaths - When true, includes path count for each target
459
- * @returns Record of pubkey to hop count (or { hops, paths } if includePaths is true)
460
- */
461
- getDistanceBatch(targets: string[], includePaths?: false): Promise<Record<string, number | null>>;
462
- getDistanceBatch(targets: string[], includePaths: true): Promise<Record<string, {
499
+ * @param options - Options object or boolean for backwards compatibility
500
+ * - `{ includePaths: true }` - Include path counts
501
+ * - `{ includeScores: true }` - Include trust scores
502
+ * - `{ includePaths: true, includeScores: true }` - Include both
503
+ * - `true` (legacy) - Same as `{ includePaths: true }`
504
+ * @returns Record of pubkey to result based on options
505
+ */
506
+ getDistanceBatch(targets: string[], options?: false | undefined): Promise<Record<string, number | null>>;
507
+ getDistanceBatch(targets: string[], options: true | {
508
+ includePaths: true;
509
+ includeScores?: false;
510
+ }): Promise<Record<string, {
463
511
  hops: number;
464
512
  paths: number;
465
513
  } | null>>;
466
- getDistanceBatch(targets: string[], includePaths?: boolean): Promise<Record<string, number | {
514
+ getDistanceBatch(targets: string[], options: {
515
+ includePaths?: false;
516
+ includeScores: true;
517
+ }): Promise<Record<string, {
518
+ hops: number;
519
+ score: number;
520
+ } | null>>;
521
+ getDistanceBatch(targets: string[], options: {
522
+ includePaths: true;
523
+ includeScores: true;
524
+ }): Promise<Record<string, {
467
525
  hops: number;
468
526
  paths: number;
527
+ score: number;
528
+ } | null>>;
529
+ getDistanceBatch(targets: string[], options?: boolean | DistanceBatchOptions): Promise<Record<string, number | {
530
+ hops: number;
531
+ paths?: number;
532
+ score?: number;
469
533
  } | null>>;
470
534
  /**
471
535
  * Get trust scores for multiple pubkeys in a single call
@@ -644,4 +708,4 @@ declare const MAX_BATCH_SIZE = 10000;
644
708
  */
645
709
  declare function normalizePubkey(pubkey: string): string;
646
710
 
647
- export { type BatchResult, DEFAULT_MAX_HOPS, DEFAULT_ORACLE, DEFAULT_TIMEOUT, type DistanceResult, type ExtensionConfig, type ExtensionConnectionOptions, type ExtensionConnectionResult, type ExtensionConnectionState, ExtensionConnector, type ExtensionDistanceResult, type ExtensionStatus, type GraphStats, MAX_BATCH_SIZE, NetworkError, type NostrContactEvent, type NostrWindow, type NostrWoTExtension, NotFoundError, type QueryOptions, type ScoringConfig, TimeoutError, ValidationError, WoT, WoTError, type WoTFallbackOptions, type WoTOptions, checkAndConnect, checkExtension, connectExtension, getDefaultConnector, isValidOracleUrl, isValidPubkey, normalizePubkey, resetDefaultConnector };
711
+ export { type BatchResult, DEFAULT_MAX_HOPS, DEFAULT_ORACLE, DEFAULT_TIMEOUT, type DistanceBatchOptions, type DistanceResult, type ExtensionConfig, type ExtensionConnectionOptions, type ExtensionConnectionResult, type ExtensionConnectionState, ExtensionConnector, type ExtensionDistanceResult, type ExtensionStatus, type GraphStats, MAX_BATCH_SIZE, NetworkError, type NostrContactEvent, type NostrWindow, type NostrWoTExtension, NotFoundError, type QueryOptions, type ScoringConfig, TimeoutError, ValidationError, WoT, WoTError, type WoTFallbackOptions, type WoTOptions, checkAndConnect, checkExtension, connectExtension, getDefaultConnector, isValidOracleUrl, isValidPubkey, normalizePubkey, resetDefaultConnector };
package/dist/index.js CHANGED
@@ -619,10 +619,11 @@ var WoT = class {
619
619
  const myPubkey = await this.getEffectivePubkey();
620
620
  const maxHops = (_a = options == null ? void 0 : options.maxHops) != null ? _a : this.maxHops;
621
621
  try {
622
- return await this.apiRequest(
622
+ const response = await this.apiRequest(
623
623
  `/details/${myPubkey}/${normalizedTarget}?maxHops=${maxHops}`,
624
624
  options
625
625
  );
626
+ return { ...response, score: 0 };
626
627
  } catch (error) {
627
628
  if (error instanceof NotFoundError) {
628
629
  return null;
@@ -743,26 +744,32 @@ var WoT = class {
743
744
  const normalizedTarget = this.validatePubkey(target, "target");
744
745
  return ext.getPath(normalizedTarget);
745
746
  }
746
- async getDistanceBatch(targets, includePaths = false) {
747
+ async getDistanceBatch(targets, options = false) {
747
748
  if (!Array.isArray(targets) || targets.length === 0) {
748
749
  return {};
749
750
  }
750
751
  const normalizedTargets = targets.map(
751
752
  (t, i) => this.validatePubkey(t, `targets[${i}]`)
752
753
  );
754
+ const opts = typeof options === "boolean" ? { includePaths: options } : options || {};
755
+ const { includePaths, includeScores } = opts;
753
756
  const ext = await this.getExtension();
754
757
  if (ext) {
755
- if (includePaths) {
756
- return ext.getDistanceBatch(normalizedTargets, true);
757
- }
758
- return ext.getDistanceBatch(normalizedTargets, false);
758
+ return ext.getDistanceBatch(normalizedTargets, opts);
759
759
  }
760
- if (includePaths) {
760
+ if (includePaths || includeScores) {
761
761
  const results2 = {};
762
762
  await Promise.all(
763
763
  normalizedTargets.map(async (pubkey) => {
764
764
  const details = await this.getDetails(pubkey);
765
- results2[pubkey] = details ? { hops: details.hops, paths: details.paths } : null;
765
+ if (!details) {
766
+ results2[pubkey] = null;
767
+ return;
768
+ }
769
+ const result = { hops: details.hops };
770
+ if (includePaths) result.paths = details.paths;
771
+ if (includeScores) result.score = details.score;
772
+ results2[pubkey] = result;
766
773
  })
767
774
  );
768
775
  return results2;
@@ -613,10 +613,11 @@ var WoT = class {
613
613
  const myPubkey = await this.getEffectivePubkey();
614
614
  const maxHops = (_a = options == null ? void 0 : options.maxHops) != null ? _a : this.maxHops;
615
615
  try {
616
- return await this.apiRequest(
616
+ const response = await this.apiRequest(
617
617
  `/details/${myPubkey}/${normalizedTarget}?maxHops=${maxHops}`,
618
618
  options
619
619
  );
620
+ return { ...response, score: 0 };
620
621
  } catch (error) {
621
622
  if (error instanceof NotFoundError) {
622
623
  return null;
@@ -737,26 +738,32 @@ var WoT = class {
737
738
  const normalizedTarget = this.validatePubkey(target, "target");
738
739
  return ext.getPath(normalizedTarget);
739
740
  }
740
- async getDistanceBatch(targets, includePaths = false) {
741
+ async getDistanceBatch(targets, options = false) {
741
742
  if (!Array.isArray(targets) || targets.length === 0) {
742
743
  return {};
743
744
  }
744
745
  const normalizedTargets = targets.map(
745
746
  (t, i) => this.validatePubkey(t, `targets[${i}]`)
746
747
  );
748
+ const opts = typeof options === "boolean" ? { includePaths: options } : options || {};
749
+ const { includePaths, includeScores } = opts;
747
750
  const ext = await this.getExtension();
748
751
  if (ext) {
749
- if (includePaths) {
750
- return ext.getDistanceBatch(normalizedTargets, true);
751
- }
752
- return ext.getDistanceBatch(normalizedTargets, false);
752
+ return ext.getDistanceBatch(normalizedTargets, opts);
753
753
  }
754
- if (includePaths) {
754
+ if (includePaths || includeScores) {
755
755
  const results2 = {};
756
756
  await Promise.all(
757
757
  normalizedTargets.map(async (pubkey) => {
758
758
  const details = await this.getDetails(pubkey);
759
- results2[pubkey] = details ? { hops: details.hops, paths: details.paths } : null;
759
+ if (!details) {
760
+ results2[pubkey] = null;
761
+ return;
762
+ }
763
+ const result = { hops: details.hops };
764
+ if (includePaths) result.paths = details.paths;
765
+ if (includeScores) result.score = details.score;
766
+ results2[pubkey] = result;
760
767
  })
761
768
  );
762
769
  return results2;