nostr-wot-sdk 0.3.0 → 0.3.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/README.md CHANGED
@@ -161,17 +161,22 @@ const config = await wot.getExtensionConfig();
161
161
 
162
162
  ### Batch Operations
163
163
 
164
- #### `getDistanceBatch(targets)`
164
+ #### `getDistanceBatch(targets, includePaths?)`
165
165
 
166
166
  Get distances for multiple pubkeys in a single call.
167
167
  ```javascript
168
+ // Without paths (faster, default)
168
169
  const distances = await wot.getDistanceBatch(['pk1...', 'pk2...']);
169
170
  // Returns: { 'pk1...': 2, 'pk2...': null }
171
+
172
+ // With paths (includes path count for scoring)
173
+ const details = await wot.getDistanceBatch(['pk1...', 'pk2...'], true);
174
+ // Returns: { 'pk1...': { hops: 2, paths: 5 }, 'pk2...': null }
170
175
  ```
171
176
 
172
177
  #### `getTrustScoreBatch(targets)`
173
178
 
174
- Get trust scores for multiple pubkeys in a single call.
179
+ Get trust scores for multiple pubkeys in a single call. Uses path counts internally for accurate scoring.
175
180
  ```javascript
176
181
  const scores = await wot.getTrustScoreBatch(['pk1...', 'pk2...']);
177
182
  // Returns: { 'pk1...': 0.72, 'pk2...': null }
package/dist/index.cjs CHANGED
@@ -844,12 +844,7 @@ var WoT = class {
844
844
  const normalizedTarget = this.validatePubkey(target, "target");
845
845
  return ext.getPath(normalizedTarget);
846
846
  }
847
- /**
848
- * Get distances for multiple pubkeys in a single call
849
- * @param targets - Array of target pubkeys
850
- * @returns Record of pubkey to hop count (null if not connected)
851
- */
852
- async getDistanceBatch(targets) {
847
+ async getDistanceBatch(targets, includePaths = false) {
853
848
  if (!Array.isArray(targets) || targets.length === 0) {
854
849
  return {};
855
850
  }
@@ -858,7 +853,20 @@ var WoT = class {
858
853
  );
859
854
  const ext = await this.getExtension();
860
855
  if (ext) {
861
- return ext.getDistanceBatch(normalizedTargets);
856
+ if (includePaths) {
857
+ return ext.getDistanceBatch(normalizedTargets, true);
858
+ }
859
+ return ext.getDistanceBatch(normalizedTargets, false);
860
+ }
861
+ if (includePaths) {
862
+ const results2 = {};
863
+ await Promise.all(
864
+ normalizedTargets.map(async (pubkey) => {
865
+ const details = await this.getDetails(pubkey);
866
+ results2[pubkey] = details ? { hops: details.hops, paths: details.paths } : null;
867
+ })
868
+ );
869
+ return results2;
862
870
  }
863
871
  const results = {};
864
872
  await Promise.all(
package/dist/index.d.cts CHANGED
@@ -328,9 +328,19 @@ interface NostrWoTExtension {
328
328
  getConfig(): Promise<ExtensionConfig>;
329
329
  /**
330
330
  * Get distances for multiple pubkeys in a single call
331
- * @returns Map of pubkey to hop count (null if not connected)
332
- */
333
- getDistanceBatch(targets: string[]): Promise<Record<string, number | null>>;
331
+ * @param targets - Array of target pubkeys
332
+ * @param includePaths - When true, includes path count for each target
333
+ * @returns Map of pubkey to hop count (or { hops, paths } if includePaths is true)
334
+ */
335
+ getDistanceBatch(targets: string[], includePaths?: false): Promise<Record<string, number | null>>;
336
+ getDistanceBatch(targets: string[], includePaths: true): Promise<Record<string, {
337
+ hops: number;
338
+ paths: number;
339
+ } | null>>;
340
+ getDistanceBatch(targets: string[], includePaths?: boolean): Promise<Record<string, number | {
341
+ hops: number;
342
+ paths: number;
343
+ } | null>>;
334
344
  /**
335
345
  * Get trust scores for multiple pubkeys in a single call
336
346
  * @returns Map of pubkey to trust score (null if not connected)
@@ -537,9 +547,18 @@ declare class WoT {
537
547
  /**
538
548
  * Get distances for multiple pubkeys in a single call
539
549
  * @param targets - Array of target pubkeys
540
- * @returns Record of pubkey to hop count (null if not connected)
541
- */
542
- getDistanceBatch(targets: string[]): Promise<Record<string, number | null>>;
550
+ * @param includePaths - When true, includes path count for each target
551
+ * @returns Record of pubkey to hop count (or { hops, paths } if includePaths is true)
552
+ */
553
+ getDistanceBatch(targets: string[], includePaths?: false): Promise<Record<string, number | null>>;
554
+ getDistanceBatch(targets: string[], includePaths: true): Promise<Record<string, {
555
+ hops: number;
556
+ paths: number;
557
+ } | null>>;
558
+ getDistanceBatch(targets: string[], includePaths?: boolean): Promise<Record<string, number | {
559
+ hops: number;
560
+ paths: number;
561
+ } | null>>;
543
562
  /**
544
563
  * Get trust scores for multiple pubkeys in a single call
545
564
  * @param targets - Array of target pubkeys
package/dist/index.d.ts CHANGED
@@ -328,9 +328,19 @@ interface NostrWoTExtension {
328
328
  getConfig(): Promise<ExtensionConfig>;
329
329
  /**
330
330
  * Get distances for multiple pubkeys in a single call
331
- * @returns Map of pubkey to hop count (null if not connected)
332
- */
333
- getDistanceBatch(targets: string[]): Promise<Record<string, number | null>>;
331
+ * @param targets - Array of target pubkeys
332
+ * @param includePaths - When true, includes path count for each target
333
+ * @returns Map of pubkey to hop count (or { hops, paths } if includePaths is true)
334
+ */
335
+ getDistanceBatch(targets: string[], includePaths?: false): Promise<Record<string, number | null>>;
336
+ getDistanceBatch(targets: string[], includePaths: true): Promise<Record<string, {
337
+ hops: number;
338
+ paths: number;
339
+ } | null>>;
340
+ getDistanceBatch(targets: string[], includePaths?: boolean): Promise<Record<string, number | {
341
+ hops: number;
342
+ paths: number;
343
+ } | null>>;
334
344
  /**
335
345
  * Get trust scores for multiple pubkeys in a single call
336
346
  * @returns Map of pubkey to trust score (null if not connected)
@@ -537,9 +547,18 @@ declare class WoT {
537
547
  /**
538
548
  * Get distances for multiple pubkeys in a single call
539
549
  * @param targets - Array of target pubkeys
540
- * @returns Record of pubkey to hop count (null if not connected)
541
- */
542
- getDistanceBatch(targets: string[]): Promise<Record<string, number | null>>;
550
+ * @param includePaths - When true, includes path count for each target
551
+ * @returns Record of pubkey to hop count (or { hops, paths } if includePaths is true)
552
+ */
553
+ getDistanceBatch(targets: string[], includePaths?: false): Promise<Record<string, number | null>>;
554
+ getDistanceBatch(targets: string[], includePaths: true): Promise<Record<string, {
555
+ hops: number;
556
+ paths: number;
557
+ } | null>>;
558
+ getDistanceBatch(targets: string[], includePaths?: boolean): Promise<Record<string, number | {
559
+ hops: number;
560
+ paths: number;
561
+ } | null>>;
543
562
  /**
544
563
  * Get trust scores for multiple pubkeys in a single call
545
564
  * @param targets - Array of target pubkeys
package/dist/index.js CHANGED
@@ -842,12 +842,7 @@ var WoT = class {
842
842
  const normalizedTarget = this.validatePubkey(target, "target");
843
843
  return ext.getPath(normalizedTarget);
844
844
  }
845
- /**
846
- * Get distances for multiple pubkeys in a single call
847
- * @param targets - Array of target pubkeys
848
- * @returns Record of pubkey to hop count (null if not connected)
849
- */
850
- async getDistanceBatch(targets) {
845
+ async getDistanceBatch(targets, includePaths = false) {
851
846
  if (!Array.isArray(targets) || targets.length === 0) {
852
847
  return {};
853
848
  }
@@ -856,7 +851,20 @@ var WoT = class {
856
851
  );
857
852
  const ext = await this.getExtension();
858
853
  if (ext) {
859
- return ext.getDistanceBatch(normalizedTargets);
854
+ if (includePaths) {
855
+ return ext.getDistanceBatch(normalizedTargets, true);
856
+ }
857
+ return ext.getDistanceBatch(normalizedTargets, false);
858
+ }
859
+ if (includePaths) {
860
+ const results2 = {};
861
+ await Promise.all(
862
+ normalizedTargets.map(async (pubkey) => {
863
+ const details = await this.getDetails(pubkey);
864
+ results2[pubkey] = details ? { hops: details.hops, paths: details.paths } : null;
865
+ })
866
+ );
867
+ return results2;
860
868
  }
861
869
  const results = {};
862
870
  await Promise.all(
@@ -812,12 +812,7 @@ var WoT = class {
812
812
  const normalizedTarget = this.validatePubkey(target, "target");
813
813
  return ext.getPath(normalizedTarget);
814
814
  }
815
- /**
816
- * Get distances for multiple pubkeys in a single call
817
- * @param targets - Array of target pubkeys
818
- * @returns Record of pubkey to hop count (null if not connected)
819
- */
820
- async getDistanceBatch(targets) {
815
+ async getDistanceBatch(targets, includePaths = false) {
821
816
  if (!Array.isArray(targets) || targets.length === 0) {
822
817
  return {};
823
818
  }
@@ -826,7 +821,20 @@ var WoT = class {
826
821
  );
827
822
  const ext = await this.getExtension();
828
823
  if (ext) {
829
- return ext.getDistanceBatch(normalizedTargets);
824
+ if (includePaths) {
825
+ return ext.getDistanceBatch(normalizedTargets, true);
826
+ }
827
+ return ext.getDistanceBatch(normalizedTargets, false);
828
+ }
829
+ if (includePaths) {
830
+ const results2 = {};
831
+ await Promise.all(
832
+ normalizedTargets.map(async (pubkey) => {
833
+ const details = await this.getDetails(pubkey);
834
+ results2[pubkey] = details ? { hops: details.hops, paths: details.paths } : null;
835
+ })
836
+ );
837
+ return results2;
830
838
  }
831
839
  const results = {};
832
840
  await Promise.all(