@bsv/overlay-discovery-services 0.1.3 → 1.1.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 (115) hide show
  1. package/dist/cjs/mod.js +4 -4
  2. package/dist/cjs/mod.js.map +1 -1
  3. package/dist/cjs/package.json +6 -10
  4. package/dist/cjs/src/SHIP/SHIPLookup.docs.js +103 -0
  5. package/dist/cjs/src/SHIP/SHIPLookup.docs.js.map +1 -0
  6. package/dist/cjs/src/SHIP/SHIPLookupService.js +8 -11
  7. package/dist/cjs/src/SHIP/SHIPLookupService.js.map +1 -1
  8. package/dist/cjs/src/SHIP/SHIPTopic.docs.js +60 -0
  9. package/dist/cjs/src/SHIP/SHIPTopic.docs.js.map +1 -0
  10. package/dist/cjs/src/SHIP/SHIPTopicManager.js +20 -22
  11. package/dist/cjs/src/SHIP/SHIPTopicManager.js.map +1 -1
  12. package/dist/cjs/src/SLAP/SLAPLookup.docs.js +97 -0
  13. package/dist/cjs/src/SLAP/SLAPLookup.docs.js.map +1 -0
  14. package/dist/cjs/src/SLAP/SLAPLookupService.js +8 -11
  15. package/dist/cjs/src/SLAP/SLAPLookupService.js.map +1 -1
  16. package/dist/cjs/src/SLAP/SLAPTopic.docs.js +69 -0
  17. package/dist/cjs/src/SLAP/SLAPTopic.docs.js.map +1 -0
  18. package/dist/cjs/src/SLAP/SLAPTopicManager.js +21 -23
  19. package/dist/cjs/src/SLAP/SLAPTopicManager.js.map +1 -1
  20. package/dist/cjs/src/WalletAdvertiser.js +216 -0
  21. package/dist/cjs/src/WalletAdvertiser.js.map +1 -0
  22. package/dist/cjs/src/utils/isAdvertisableURI.js +123 -0
  23. package/dist/cjs/src/utils/isAdvertisableURI.js.map +1 -0
  24. package/dist/cjs/src/utils/isTokenSignatureCorrectlyLinked.js +45 -0
  25. package/dist/cjs/src/utils/isTokenSignatureCorrectlyLinked.js.map +1 -0
  26. package/dist/cjs/src/utils/isValidTopicOrServiceName.js +14 -0
  27. package/dist/cjs/src/utils/isValidTopicOrServiceName.js.map +1 -0
  28. package/dist/cjs/src/utils/verifyToken.js +1 -2
  29. package/dist/cjs/src/utils/verifyToken.js.map +1 -1
  30. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  31. package/dist/esm/mod.js +4 -4
  32. package/dist/esm/mod.js.map +1 -1
  33. package/dist/esm/src/SHIP/SHIPLookup.docs.js +101 -0
  34. package/dist/esm/src/SHIP/SHIPLookup.docs.js.map +1 -0
  35. package/dist/esm/src/SHIP/SHIPLookupService.js +8 -11
  36. package/dist/esm/src/SHIP/SHIPLookupService.js.map +1 -1
  37. package/dist/esm/src/SHIP/SHIPTopic.docs.js +58 -0
  38. package/dist/esm/src/SHIP/SHIPTopic.docs.js.map +1 -0
  39. package/dist/esm/src/SHIP/SHIPTopicManager.js +21 -23
  40. package/dist/esm/src/SHIP/SHIPTopicManager.js.map +1 -1
  41. package/dist/esm/src/SLAP/SLAPLookup.docs.js +95 -0
  42. package/dist/esm/src/SLAP/SLAPLookup.docs.js.map +1 -0
  43. package/dist/esm/src/SLAP/SLAPLookupService.js +8 -11
  44. package/dist/esm/src/SLAP/SLAPLookupService.js.map +1 -1
  45. package/dist/esm/src/SLAP/SLAPTopic.docs.js +67 -0
  46. package/dist/esm/src/SLAP/SLAPTopic.docs.js.map +1 -0
  47. package/dist/esm/src/SLAP/SLAPTopicManager.js +22 -24
  48. package/dist/esm/src/SLAP/SLAPTopicManager.js.map +1 -1
  49. package/dist/esm/src/WalletAdvertiser.js +220 -0
  50. package/dist/esm/src/WalletAdvertiser.js.map +1 -0
  51. package/dist/esm/src/utils/isAdvertisableURI.js +119 -0
  52. package/dist/esm/src/utils/isAdvertisableURI.js.map +1 -0
  53. package/dist/esm/src/utils/isTokenSignatureCorrectlyLinked.js +41 -0
  54. package/dist/esm/src/utils/isTokenSignatureCorrectlyLinked.js.map +1 -0
  55. package/dist/esm/src/utils/isValidTopicOrServiceName.js +10 -0
  56. package/dist/esm/src/utils/isValidTopicOrServiceName.js.map +1 -0
  57. package/dist/esm/src/utils/verifyToken.js +2 -3
  58. package/dist/esm/src/utils/verifyToken.js.map +1 -1
  59. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  60. package/dist/types/mod.d.ts +4 -4
  61. package/dist/types/mod.d.ts.map +1 -1
  62. package/dist/types/src/SHIP/SHIPLookup.docs.d.ts +3 -0
  63. package/dist/types/src/SHIP/SHIPLookup.docs.d.ts.map +1 -0
  64. package/dist/types/src/SHIP/SHIPLookupService.d.ts.map +1 -1
  65. package/dist/types/src/SHIP/SHIPTopic.docs.d.ts +3 -0
  66. package/dist/types/src/SHIP/SHIPTopic.docs.d.ts.map +1 -0
  67. package/dist/types/src/SHIP/SHIPTopicManager.d.ts.map +1 -1
  68. package/dist/types/src/SLAP/SLAPLookup.docs.d.ts +3 -0
  69. package/dist/types/src/SLAP/SLAPLookup.docs.d.ts.map +1 -0
  70. package/dist/types/src/SLAP/SLAPLookupService.d.ts.map +1 -1
  71. package/dist/types/src/SLAP/SLAPTopic.docs.d.ts +3 -0
  72. package/dist/types/src/SLAP/SLAPTopic.docs.d.ts.map +1 -0
  73. package/dist/types/src/SLAP/SLAPTopicManager.d.ts.map +1 -1
  74. package/dist/types/src/WalletAdvertiser.d.ts +61 -0
  75. package/dist/types/src/WalletAdvertiser.d.ts.map +1 -0
  76. package/dist/types/src/utils/isAdvertisableURI.d.ts +19 -0
  77. package/dist/types/src/utils/isAdvertisableURI.d.ts.map +1 -0
  78. package/dist/types/src/utils/isTokenSignatureCorrectlyLinked.d.ts +9 -0
  79. package/dist/types/src/utils/isTokenSignatureCorrectlyLinked.d.ts.map +1 -0
  80. package/dist/types/src/utils/isValidTopicOrServiceName.d.ts +7 -0
  81. package/dist/types/src/utils/isValidTopicOrServiceName.d.ts.map +1 -0
  82. package/dist/types/src/utils/verifyToken.d.ts +2 -1
  83. package/dist/types/src/utils/verifyToken.d.ts.map +1 -1
  84. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  85. package/mod.ts +4 -4
  86. package/package.json +6 -10
  87. package/src/SHIP/SHIPLookup.docs.ts +100 -0
  88. package/src/SHIP/SHIPLookupService.ts +8 -15
  89. package/src/SHIP/SHIPTopic.docs.ts +57 -0
  90. package/src/SHIP/SHIPTopicManager.ts +16 -23
  91. package/src/SLAP/SLAPLookup.docs.ts +94 -0
  92. package/src/SLAP/SLAPLookupService.ts +8 -16
  93. package/src/SLAP/SLAPTopic.docs.ts +66 -0
  94. package/src/SLAP/SLAPTopicManager.ts +16 -27
  95. package/src/WalletAdvertiser.ts +251 -0
  96. package/src/__tests/WalletAdvertiser.test.ts +190 -0
  97. package/src/utils/__tests/isAdvertisableURI.test.ts +99 -0
  98. package/src/utils/__tests/isTokenSignatureCorrectlyLinked.test.ts +90 -0
  99. package/src/utils/__tests/isValidTopicOrServiceName.test.ts +70 -0
  100. package/src/utils/isAdvertisableURI.ts +114 -0
  101. package/src/utils/isTokenSignatureCorrectlyLinked.ts +47 -0
  102. package/src/utils/isValidTopicOrServiceName.ts +9 -0
  103. package/docs/SHIP/ship-lookup-service.md +0 -352
  104. package/docs/SHIP/ship-storage.md +0 -207
  105. package/docs/SHIP/ship-topic-manager.md +0 -122
  106. package/docs/SLAP/slap-lookup-service.md +0 -353
  107. package/docs/SLAP/slap-storage.md +0 -207
  108. package/docs/SLAP/slap-topic-manager.md +0 -122
  109. package/src/LegacyNinjaAdvertiser.ts +0 -260
  110. package/src/types.d.ts +0 -2
  111. package/src/utils/generateDocs.ts +0 -53
  112. package/src/utils/getDocumentation.ts +0 -19
  113. package/src/utils/isValidDomain.ts +0 -10
  114. package/src/utils/isValidServiceName.ts +0 -9
  115. package/src/utils/verifyToken.ts +0 -26
package/dist/cjs/mod.js CHANGED
@@ -20,9 +20,9 @@ __exportStar(require("./src/SHIP/SHIPTopicManager.js"), exports);
20
20
  __exportStar(require("./src/SLAP/SLAPLookupService.js"), exports);
21
21
  __exportStar(require("./src/SLAP/SLAPStorage.js"), exports);
22
22
  __exportStar(require("./src/SLAP/SLAPTopicManager.js"), exports);
23
- __exportStar(require("./src/LegacyNinjaAdvertiser.js"), exports);
24
- __exportStar(require("./src/utils/isValidDomain.js"), exports);
25
- __exportStar(require("./src/utils/isValidServiceName.js"), exports);
26
- __exportStar(require("./src/utils/verifyToken.js"), exports);
23
+ __exportStar(require("./src/WalletAdvertiser.js"), exports);
24
+ __exportStar(require("./src/utils/isAdvertisableURI.js"), exports);
25
+ __exportStar(require("./src/utils/isValidTopicOrServiceName.js"), exports);
26
+ __exportStar(require("./src/utils/isTokenSignatureCorrectlyLinked.js"), exports);
27
27
  __exportStar(require("./src/types.js"), exports);
28
28
  //# sourceMappingURL=mod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../mod.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAA+C;AAC/C,4DAAyC;AACzC,iEAA8C;AAE9C,kEAA+C;AAC/C,4DAAyC;AACzC,iEAA8C;AAE9C,iEAA8C;AAE9C,+DAA4C;AAC5C,oEAAiD;AACjD,6DAA0C;AAE1C,iDAA8B"}
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../mod.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAA+C;AAC/C,4DAAyC;AACzC,iEAA8C;AAE9C,kEAA+C;AAC/C,4DAAyC;AACzC,iEAA8C;AAE9C,4DAAyC;AAEzC,mEAAgD;AAChD,2EAAwD;AACxD,iFAA8D;AAE9D,iDAA8B"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/overlay-discovery-services",
3
- "version": "0.1.2",
3
+ "version": "1.1.0",
4
4
  "type": "commonjs",
5
5
  "description": "BSV Blockchain Overlay Services Engine",
6
6
  "files": [
@@ -18,8 +18,7 @@
18
18
  "build": "tsc -b && tsconfig-to-dual-package tsconfig.cjs.json",
19
19
  "dev": "tsc -b -w",
20
20
  "prepublish": "npm run build",
21
- "doc": "ts2md --inputFilename=mod.ts --outputFilename=API.md --filenameSubstring=API --firstHeadingLevel=1",
22
- "generate-service-docs": "node ./dist/cjs/src/utils/generateDocs.js"
21
+ "doc": "ts2md --inputFilename=mod.ts --outputFilename=API.md --filenameSubstring=API --firstHeadingLevel=1"
23
22
  },
24
23
  "repository": {
25
24
  "type": "git",
@@ -48,12 +47,9 @@
48
47
  "typescript": "^5.2.2"
49
48
  },
50
49
  "dependencies": {
51
- "@bsv/overlay": "^0.1.15",
52
- "@bsv/sdk": "^1.2.3",
53
- "mongodb": "^6.11.0",
54
- "ninja-base": "0.3.46",
55
- "pushdrop": "^0.1.64",
56
- "sendover": "^1.3.27",
57
- "uhrp-url": "^0.1.10"
50
+ "@bsv/overlay": "^0.1.23",
51
+ "@bsv/sdk": "^1.3.24",
52
+ "@bsv/wallet-toolbox-client": "^1.1.30",
53
+ "mongodb": "^6.11.0"
58
54
  }
59
55
  }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = `# SHIP Lookup Service
4
+
5
+ **Protocol Name**: SHIP (Service Host Interconnect Protocol)
6
+ **Lookup Service Name**: \`SHIPLookupService\`
7
+
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ The SHIP Lookup Service is used to **query** the known SHIP tokens in your overlay database. It allows you to discover nodes that have published SHIP outputs, indicating they host or participate in certain topics (prefixed \`tm_\`).
13
+
14
+ This lookup service is typically invoked by sending a [LookupQuestion](https://www.npmjs.com/package/@bsv/overlay#lookupservice) with:
15
+ - \`question.service = 'ls_ship'\`
16
+ - \`question.query\` containing parameters for searching.
17
+
18
+ ---
19
+
20
+ ## Purpose
21
+
22
+ - **Discovery**: Find all hosts that declared themselves via SHIP tokens.
23
+ - **Filtering**: Narrow results by domain, by topic, or both.
24
+
25
+ ---
26
+
27
+ ## Querying the SHIP Lookup Service
28
+
29
+ When you call \`lookup(question)\` on the SHIP Lookup Service, you must include:
30
+
31
+ 1. **\`question.service\`** set to \`"ls_ship"\`.
32
+ 2. **\`question.query\`**: Can be one of the following:
33
+ - \`"findAll"\` (string literal): Returns **all** known SHIP records.
34
+ - An object of type:
35
+ \`\`\`ts
36
+ interface SHIPQuery {
37
+ domain?: string
38
+ topics?: string[]
39
+ }
40
+ \`\`\`
41
+ where:
42
+ - \`domain\` is an optional string. If provided, results will match that domain/advertisedURI.
43
+ - \`topics\` is an optional string array. If provided, results will match any of those \`tm_\` topics.
44
+
45
+ ### Examples
46
+
47
+ 1. **Find all SHIP records**:
48
+ \`\`\`js
49
+ const question = {
50
+ service: 'ls_ship',
51
+ query: 'findAll'
52
+ }
53
+ const results = await overlayClient.lookup(question)
54
+ \`\`\`
55
+
56
+ 2. **Find by domain**:
57
+ \`\`\`js
58
+ const question = {
59
+ service: 'ls_ship',
60
+ query: { domain: 'https://myexample.com' }
61
+ }
62
+ const results = await overlayClient.lookup(question)
63
+ \`\`\`
64
+
65
+ 3. **Find by topics**:
66
+ \`\`\`js
67
+ const question = {
68
+ service: 'ls_ship',
69
+ query: { topics: ['tm_bridge', 'tm_sync'] }
70
+ }
71
+ const results = await overlayClient.lookup(question)
72
+ \`\`\`
73
+
74
+ 4. **Find by domain AND topics**:
75
+ \`\`\`js
76
+ const question = {
77
+ service: 'ls_ship',
78
+ query: {
79
+ domain: 'https://myexample.com',
80
+ topics: ['tm_bridge']
81
+ }
82
+ }
83
+ const results = await overlayClient.lookup(question)
84
+ \`\`\`
85
+
86
+ ---
87
+
88
+ ## Gotchas and Tips
89
+
90
+ - **Topic Prefix**: The SHIP manager expects topics to start with \`tm_\`. If you see no results, ensure you used the correct prefix.
91
+ - **Strict Matching**: Domain matching requires an exact string match. If you have a different protocol (https vs https+bsvauth vs https+bsvauth+smf), be sure to store/lookup accordingly.
92
+ - **Partial Queries**: If you only provide \`topics\`, domain-based filtering is not applied, and vice versa.
93
+ - **Multiple Topics**: Since \`topics\` is an array, the storage will return all records matching **any** listed topic.
94
+
95
+ ---
96
+
97
+ ## Further Reading
98
+
99
+ - **SHIPTopicManager**: For how the outputs are admitted.
100
+ - **BRC-101 Overlays**: The general pattern for these sorts of services.
101
+ - **SLAP**: The complementary protocol for service lookup availability ads.
102
+ `;
103
+ //# sourceMappingURL=SHIPLookup.docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SHIPLookup.docs.js","sourceRoot":"","sources":["../../../../src/SHIP/SHIPLookup.docs.ts"],"names":[],"mappings":";;AAAA,kBAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmGd,CAAA"}
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SHIPLookupService = void 0;
7
- const pushdrop_1 = __importDefault(require("pushdrop"));
8
- const getDocumentation_js_1 = require("../utils/getDocumentation.js");
7
+ const sdk_1 = require("@bsv/sdk");
8
+ const SHIPLookup_docs_js_1 = __importDefault(require("./SHIPLookup.docs.js"));
9
9
  /**
10
10
  * Implements the SHIP lookup service
11
11
  *
@@ -26,14 +26,11 @@ class SHIPLookupService {
26
26
  async outputAdded(txid, outputIndex, outputScript, topic) {
27
27
  if (topic !== 'tm_ship')
28
28
  return;
29
- const result = pushdrop_1.default.decode({
30
- script: outputScript.toHex(),
31
- fieldFormat: 'buffer'
32
- });
33
- const shipIdentifier = result.fields[0].toString();
34
- const identityKey = result.fields[1].toString('hex');
35
- const domain = result.fields[2].toString();
36
- const topicSupported = result.fields[3].toString();
29
+ const result = sdk_1.PushDrop.decode(outputScript);
30
+ const shipIdentifier = sdk_1.Utils.toUTF8(result.fields[0]);
31
+ const identityKey = sdk_1.Utils.toHex(result.fields[1]);
32
+ const domain = sdk_1.Utils.toUTF8(result.fields[2]);
33
+ const topicSupported = sdk_1.Utils.toUTF8(result.fields[3]);
37
34
  if (shipIdentifier !== 'SHIP')
38
35
  return;
39
36
  await this.storage.storeSHIPRecord(txid, outputIndex, identityKey, domain, topicSupported);
@@ -99,7 +96,7 @@ class SHIPLookupService {
99
96
  * @returns A promise that resolves to the documentation string.
100
97
  */
101
98
  async getDocumentation() {
102
- return await (0, getDocumentation_js_1.getDocumentation)('./docs/SHIP/ship-lookup-service.md');
99
+ return SHIPLookup_docs_js_1.default;
103
100
  }
104
101
  /**
105
102
  * Returns metadata associated with this lookup service.
@@ -1 +1 @@
1
- {"version":3,"file":"SHIPLookupService.js","sourceRoot":"","sources":["../../../../src/SHIP/SHIPLookupService.ts"],"names":[],"mappings":";;;;;;AAGA,wDAA+B;AAE/B,sEAA+D;AAE/D;;;;;GAKG;AACH,MAAa,iBAAiB;IAC5B,YAAmB,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;IAAI,CAAC;IAE5C;;;;;;OAMG;IACH,KAAK,CAAC,WAAW,CAAE,IAAY,EAAE,WAAmB,EAAE,YAAoB,EAAE,KAAa;QACvF,IAAI,KAAK,KAAK,SAAS;YAAE,OAAM;QAE/B,MAAM,MAAM,GAAG,kBAAQ,CAAC,MAAM,CAAC;YAC7B,MAAM,EAAE,YAAY,CAAC,KAAK,EAAE;YAC5B,WAAW,EAAE,QAAQ;SACtB,CAAC,CAAA;QAEF,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;QAClD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC1C,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;QAClD,IAAI,cAAc,KAAK,MAAM;YAAE,OAAM;QAErC,MAAM,IAAI,CAA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AAqB;YAC3B,gBAAgB,EAAE,+CAA+C;SAClE,CAAA;IACH,CAAC;CACF;AAtGD,8CAsGC"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = `# SHIP Topic Manager
4
+
5
+ **Protocol Name**: SHIP (Service Host Interconnect Protocol)
6
+ **Manager Name**: \`SHIPTopicManager\`
7
+
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ The SHIP Topic Manager is responsible for identifying _admissible outputs_ in transactions that declare themselves as part of the SHIP protocol. In other words, it looks at transaction outputs (UTXOs) that embed certain metadata via a [PushDrop](https://www.npmjs.com/package/@bsv/sdk#pushdrop) locking script. This metadata must meet SHIP-specific requirements so that your node or application can recognize valid SHIP advertisements.
13
+
14
+ A **SHIP token** (in the context of BRC-101 overlays) is a UTXO containing information that advertises a node or host providing some topic-based service to the network. That topic must be prefixed with \`tm_\` — short for "topic manager."
15
+
16
+ ---
17
+
18
+ ## Purpose
19
+
20
+ - **Announce**: The SHIP token is used to signal that "this identity key is hosting a certain topic (prefixed with \`tm_\`)."
21
+ - **Connect**: By publishing a SHIP output, a node indicates it offers some service or is a participant in a specific overlay "topic."
22
+ - **Authorize**: The SHIP token includes a signature which binds it to an identity key, ensuring authenticity and preventing impersonation.
23
+
24
+ This allows other nodes to discover hosts by querying the lookup service for valid SHIP tokens.
25
+
26
+ ---
27
+
28
+ ## Requirements for a Valid SHIP Output
29
+
30
+ 1. **PushDrop Fields**: Exactly five fields must be present:
31
+ 1. \`"SHIP"\` — The protocol identifier string.
32
+ 2. \`identityKey\` — The 33-byte compressed DER secp256k1 public key that claims to own this UTXO.
33
+ 3. \`advertisedURI\` — A URI string describing how or where to connect (see BRC-101).
34
+ 4. \`topic\` — A string that identifies the topic. Must:
35
+ - Start with \`tm_\`
36
+ - Pass the BRC-87 checks
37
+ 5. \`signature\` — A valid signature (in DER) proving that \`identityKey\` is authorizing this output, in conjunction with the PushDrop locking key.
38
+
39
+ 2. **Signature Verification**:
40
+ - The signature in the last field must be valid for the data in the first 4 fields.
41
+ - It must match the identity key, which in turn must match the locking public key used in the output script.
42
+ - See the code in \`isTokenSignatureCorrectlyLinked\` for the implementation details.
43
+
44
+ 3. **Advertised URI**:
45
+ - Must align with what is contemplated in BRC-101, which enforces certain URI formats (e.g., \`https://\`, \`wss://\`, or custom prefixed \`https+bsvauth...\` URIs).
46
+ - No \`localhost\` or invalid URIs allowed.
47
+
48
+ If any of these checks fail, the SHIP token output is _not_ admitted by the topic manager.
49
+
50
+ ---
51
+
52
+ ## Gotchas and Tips
53
+
54
+ - **Field Ordering**: The fields **must** appear in the exact order specified above (SHIP -> identityKey -> advertisedURI -> topic -> signature).
55
+ - **Exact Five Fields**: More or fewer fields will cause the manager to skip the output.
56
+ - **Proper Locking Script**: Ensure the output is locked with a valid [PushDrop](https://www.npmjs.com/package/@bsv/sdk#pushdrop) format. If the \`lockingScript\` can’t be decoded by \`PushDrop\`, the output is invalid.
57
+ - **Signature Data**: The signature is a raw ECDSA signature over the raw bytes of the preceding fields. The manager expects that the identity key and signature match up with the logic in \`isTokenSignatureCorrectlyLinked\`.
58
+ - **Funding**: Remember to fund your SHIP output with at least one satoshi so it remains unspent if you want your advertisement to be valid.
59
+ `;
60
+ //# sourceMappingURL=SHIPTopic.docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SHIPTopic.docs.js","sourceRoot":"","sources":["../../../../src/SHIP/SHIPTopic.docs.ts"],"names":[],"mappings":";;AAAA,kBAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDd,CAAA"}
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SHIPTopicManager = void 0;
7
7
  const sdk_1 = require("@bsv/sdk");
8
- const pushdrop_1 = __importDefault(require("pushdrop"));
9
- const verifyToken_js_1 = require("../utils/verifyToken.js");
10
- const isValidDomain_js_1 = require("../utils/isValidDomain.js");
11
- const getDocumentation_js_1 = require("../utils/getDocumentation.js");
8
+ const isTokenSignatureCorrectlyLinked_js_1 = require("../utils/isTokenSignatureCorrectlyLinked.js");
9
+ const isAdvertisableURI_js_1 = require("../utils/isAdvertisableURI.js");
10
+ const SHIPTopic_docs_js_1 = __importDefault(require("./SHIPTopic.docs.js"));
11
+ const isValidTopicOrServiceName_js_1 = require("../utils/isValidTopicOrServiceName.js");
12
12
  /**
13
13
  * 🚢 SHIP Topic Manager
14
14
  * Implements the TopicManager interface for SHIP (Service Host Interconnect Protocol) tokens.
@@ -29,24 +29,22 @@ class SHIPTopicManager {
29
29
  const parsedTransaction = sdk_1.Transaction.fromBEEF(beef);
30
30
  for (const [i, output] of parsedTransaction.outputs.entries()) {
31
31
  try {
32
- const result = pushdrop_1.default.decode({
33
- script: output.lockingScript.toHex(),
34
- fieldFormat: 'buffer'
35
- });
36
- if (result.fields.length !== 4)
37
- continue; // SHIP tokens should have 4 fields
38
- const shipIdentifier = result.fields[0].toString();
39
- const identityKey = result.fields[1].toString('hex');
40
- const domain = result.fields[2].toString();
41
- // const topic = result.fields[3].toString()
32
+ const result = sdk_1.PushDrop.decode(output.lockingScript);
33
+ if (result.fields.length !== 5)
34
+ continue; // SHIP tokens have 5 fields
35
+ const shipIdentifier = sdk_1.Utils.toUTF8(result.fields[0]);
42
36
  if (shipIdentifier !== 'SHIP')
43
- continue;
44
- // Validate domain
45
- if (!(0, isValidDomain_js_1.isValidDomain)(domain))
46
- continue;
47
- // Additional validations can be added here
48
- // Verify the token locking key and signature
49
- (0, verifyToken_js_1.verifyToken)(identityKey, result.lockingPublicKey, result.fields, result.signature);
37
+ continue; // SHIP identifier must be present
38
+ const advertisedURI = sdk_1.Utils.toUTF8(result.fields[2]);
39
+ if (!(0, isAdvertisableURI_js_1.isAdvertisableURI)(advertisedURI))
40
+ continue; // Advertised URI must be acceptable
41
+ const topic = sdk_1.Utils.toUTF8(result.fields[3]);
42
+ if (!(0, isValidTopicOrServiceName_js_1.isValidTopicOrServiceName)(topic))
43
+ continue; // Topic or service name must be valid
44
+ if (!topic.startsWith('tm_'))
45
+ continue; // SHIP only accepts "tm_" (topic manager) advertisements
46
+ if (!(0, isTokenSignatureCorrectlyLinked_js_1.isTokenSignatureCorrectlyLinked)(result.lockingPublicKey, result.fields))
47
+ continue; // Signatures must be properly linked
50
48
  outputsToAdmit.push(i);
51
49
  }
52
50
  catch (error) {
@@ -80,7 +78,7 @@ class SHIPTopicManager {
80
78
  * @returns A promise that resolves to the documentation string.
81
79
  */
82
80
  async getDocumentation() {
83
- return await (0, getDocumentation_js_1.getDocumentation)('./docs/SHIP/ship-lookup-service.md');
81
+ return SHIPTopic_docs_js_1.default;
84
82
  }
85
83
  /**
86
84
  * Returns metadata associated with this topic manager.
@@ -1 +1 @@
1
- {"version":3,"file":"SHIPTopicManager.js","sourceRoot":"","sources":["../../../../src/SHIP/SHIPTopicManager.ts"],"names":[],"mappings":";;;;;;AACA,kCAAsC;AACtC,wDAA+B;AAC/B,4DAAqD;AACrD,gEAAyD;AACzD,sEAA+D;AAE/D;;;;;;GAMG;AACH,MAAa,gBAAgB;IAC3B;;;;;OAKG;IACH,KAAK,CAAC,yBAAyB,CAAC,IAAc,EAAE,aAAuB;QACrE,MAAM,cAAc,GAAa,EAAE,CAAA;QACnC,IAAI,CAAC;YACH,MAAM,iBAAiB,GAAG,iBAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YAEpD,KAAK,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC9D,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,kBAAQ,CAAC,MAAM,CAAC;wBAC7B,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE;wBACpC,WAAW,EAAE,QAAQ;qBACtB,CAAC,CAAA;oBAEF,IAAI,MAA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Aa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;gBAClF,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAA;YAClE,CAAC;QACH,CAAC;QAED,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,CAAC,sBAAsB,cAAc,CAAC,MAAM,SAAS,cAAc,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAA;QACxH,CAAC;QAED,IAAI,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9C,OAAO,CAAC,GAAG,CAAC,eAAe,aAAa,CAAC,MAAM,kBAAkB,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAA;QACpH,CAAC;QAED,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;YAClF,OAAO,CAAC,IAAI,CAAC,iEAAiE,CAAC,CAAA;QACjF,CAAC;QAED,OAAO;YACL,cAAc;YACd,aAAa,EAAE,EAAE;SAClB,CAAA;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,gBAAgB;QACpB,OAAO,2BAAa,CAAA;IACtB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW;QAOf,OAAO;YACL,IAAI,EAAE,oBAAoB;YAC1B,gBAAgB,EAAE,oDAAoD;SACvE,CAAA;IACH,CAAC;CACF;AAnFD,4CAmFC"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = `# SLAP Lookup Service
4
+
5
+ **Protocol Name**: SLAP (Service Lookup Availability Protocol)
6
+ **Lookup Service Name**: \`SLAPLookupService\`
7
+
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ The SLAP Lookup Service is an overlay component that answers queries about SLAP advertisements. A SLAP advertisement states that an identity key offers a service (prefixed \`ls_\`) at a given URI. By querying this service, you can find all known SLAP records that match your criteria.
13
+
14
+ ---
15
+
16
+ ## Purpose
17
+
18
+ - **Discovery**: Find all services that have been advertised with the \`SLAP\` protocol.
19
+ - **Filtering**: Narrow results by domain or by the \`ls_\` service name.
20
+
21
+ ---
22
+
23
+ ## How to Query the SLAP Lookup Service
24
+
25
+ You will typically provide a [LookupQuestion](https://www.npmjs.com/package/@bsv/overlay#lookupservice) object to the \`lookup\` method with:
26
+ - \`question.service = 'ls_slap'\`
27
+ - \`question.query\` describing the domain and/or service name you want.
28
+
29
+ ### \`question.query\` Options
30
+
31
+ 1. **\`"findAll"\`** (string literal): Returns every SLAP record in the database.
32
+ 2. **\`SLAPQuery\` object**:
33
+ \`\`\`ts
34
+ interface SLAPQuery {
35
+ domain?: string
36
+ service?: string
37
+ }
38
+ \`\`\`
39
+ - \`domain\`: Optional. If provided, only returns records whose \`advertisedURI\` matches this domain.
40
+ - \`service\`: Optional. Must be a string starting with \`ls_\`.
41
+
42
+ ### Example Usages
43
+
44
+ 1. **Find all**:
45
+ \`\`\`js
46
+ const question = {
47
+ service: 'ls_slap',
48
+ query: 'findAll'
49
+ }
50
+ const answers = await overlayClient.lookup(question)
51
+ \`\`\`
52
+
53
+ 2. **Find by domain**:
54
+ \`\`\`js
55
+ const question = {
56
+ service: 'ls_slap',
57
+ query: { domain: 'https://mylookup.example' }
58
+ }
59
+ const answers = await overlayClient.lookup(question)
60
+ \`\`\`
61
+
62
+ 3. **Find by service (most common)**:
63
+ \`\`\`js
64
+ const question = {
65
+ service: 'ls_slap',
66
+ query: { service: 'ls_treasury' }
67
+ }
68
+ const answers = await overlayClient.lookup(question)
69
+ \`\`\`
70
+
71
+ 4. **Find by domain & service**:
72
+ \`\`\`js
73
+ const question = {
74
+ service: 'ls_slap',
75
+ query: {
76
+ domain: 'https://mylookup.example',
77
+ service: 'ls_treasury'
78
+ }
79
+ }
80
+ const answers = await overlayClient.lookup(question)
81
+ \`\`\`
82
+
83
+ ---
84
+
85
+ ## Gotchas
86
+
87
+ - **Strict Matching**: Domain matching requires an exact string match. If you have a different protocol (https vs https+bsvauth vs https+bsvauth+smf), be sure to store/lookup accordingly.
88
+ - **Must Start with \`ls_\`**: The \`service\` field in the original SLAP advertisement must begin with \`ls_\`. If you query for something that doesn’t match exactly, you may get zero results.
89
+
90
+ ---
91
+
92
+ ## Further Reading
93
+
94
+ - **SLAPTopicManager**: Learn how SLAP outputs are detected and admitted.
95
+ - **BRC-101 Overlays**: The higher-level specification for modular overlay availability schemes.
96
+ `;
97
+ //# sourceMappingURL=SLAPLookup.docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SLAPLookup.docs.js","sourceRoot":"","sources":["../../../../src/SLAP/SLAPLookup.docs.ts"],"names":[],"mappings":";;AAAA,kBAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Fd,CAAA"}
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SLAPLookupService = void 0;
7
- const pushdrop_1 = __importDefault(require("pushdrop"));
8
- const getDocumentation_js_1 = require("../utils/getDocumentation.js");
7
+ const sdk_1 = require("@bsv/sdk");
8
+ const SLAPLookup_docs_js_1 = __importDefault(require("./SLAPLookup.docs.js"));
9
9
  /**
10
10
  * Implements the SLAP lookup service
11
11
  *
@@ -27,14 +27,11 @@ class SLAPLookupService {
27
27
  async outputAdded(txid, outputIndex, outputScript, topic) {
28
28
  if (topic !== 'tm_slap')
29
29
  return;
30
- const result = pushdrop_1.default.decode({
31
- script: outputScript.toHex(),
32
- fieldFormat: 'buffer'
33
- });
34
- const protocol = result.fields[0].toString();
35
- const identityKey = result.fields[1].toString('hex');
36
- const domain = result.fields[2].toString();
37
- const service = result.fields[3].toString();
30
+ const result = sdk_1.PushDrop.decode(outputScript);
31
+ const protocol = sdk_1.Utils.toUTF8(result.fields[0]);
32
+ const identityKey = sdk_1.Utils.toHex(result.fields[1]);
33
+ const domain = sdk_1.Utils.toUTF8(result.fields[2]);
34
+ const service = sdk_1.Utils.toUTF8(result.fields[3]);
38
35
  if (protocol !== 'SLAP')
39
36
  return;
40
37
  await this.storage.storeSLAPRecord(txid, outputIndex, identityKey, domain, service);
@@ -97,7 +94,7 @@ class SLAPLookupService {
97
94
  * @returns A promise that resolves to the documentation string.
98
95
  */
99
96
  async getDocumentation() {
100
- return await (0, getDocumentation_js_1.getDocumentation)('./docs/SLAP/slap-lookup-service.md');
97
+ return SLAPLookup_docs_js_1.default;
101
98
  }
102
99
  /**
103
100
  * Returns metadata associated with this lookup service.
@@ -1 +1 @@
1
- {"version":3,"file":"SLAPLookupService.js","sourceRoot":"","sources":["../../../../src/SLAP/SLAPLookupService.ts"],"names":[],"mappings":";;;;;;AAGA,wDAA+B;AAE/B,sEAA+D;AAE/D;;;;;;GAMG;AACH,MAAa,iBAAiB;IAC5B,YAAmB,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;IAAI,CAAC;IAE5C;;;;;;OAMG;IACH,KAAK,CAAC,WAAW,CAAE,IAAY,EAAE,WAAmB,EAAE,YAAoB,EAAE,KAAa;QACvF,IAAI,KAAK,KAAK,SAAS;YAAE,OAAM;QAE/B,MAAM,MAAM,GAAG,kBAAQ,CAAC,MAAM,CAAC;YAC7B,MAAM,EAAE,YAAY,CAAC,KAAK,EAAE;YAC5B,WAAW,EAAE,QAAQ;SACtB,CAAC,CAAA;QAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC5C,MAAM,WAAW,GAAG,MAAM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OAAO,4BAAc,CAAA;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW;QAOf,OAAO;YACL,IAAI,EAAE,qBAAqB;YAC3B,gBAAgB,EAAE,+CAA+C;SAClE,CAAA;IACH,CAAC;CACF;AAnGD,8CAmGC"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = `# SLAP Topic Manager
4
+
5
+ **Protocol Name**: SLAP (Service Lookup Availability Protocol)
6
+ **Manager Name**: \`SLAPTopicManager\`
7
+
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ The SLAP Topic Manager is responsible for identifying valid SLAP outputs in transactions. These outputs advertise the availability of a **lookup service** that can be accessed within an overlay network. By publishing a SLAP token, a node declares it is providing a specific service, prefixed \`ls_\`.
13
+
14
+ ---
15
+
16
+ ## Purpose
17
+
18
+ - **Announce**: Declare that the identity key provides a certain lookup service, such as \`ls_example\` or other overlay lookups.
19
+ - **Availability**: Indicate that the node or service is currently active and can be queried via the provided URI.
20
+
21
+ ---
22
+
23
+ ## Requirements for a Valid SLAP Output
24
+
25
+ Similar to SHIP, SLAP tokens must follow a specific 5-field structure in a [PushDrop](https://www.npmjs.com/package/@bsv/sdk#pushdrop) script:
26
+
27
+ 1. \`"SLAP"\` — The literal string indicating SLAP protocol.
28
+ 2. \`identityKey\` — The public key that claims ownership of this advertisement.
29
+ 3. \`advertisedURI\` — A valid URI, aligning with what is contemplated in BRC-101.
30
+ 4. \`service\` — The name of the service. Must:
31
+ - Pass the BRC-87 checks.
32
+ - Start with \`ls_\`.
33
+ 5. \`signature\` — The ECDSA signature from \`identityKey\` covering the above 4 fields.
34
+
35
+ ---
36
+
37
+ ## Signature and Locking Key
38
+
39
+ The final field is a signature that **must** link back to the identity key. The \`SLAPTopicManager\` uses the \`isTokenSignatureCorrectlyLinked\` code to confirm:
40
+
41
+ - The signature is valid for the data in the first four fields.
42
+ - The \`lockingPublicKey\` of the UTXO matches the derived key from the identity key used to sign.
43
+
44
+ If any step fails, the SLAP output is rejected.
45
+
46
+ ---
47
+
48
+ ## Data Format and Validation
49
+
50
+ 1. **Exact 5 PushDrop Fields**:
51
+ - If fewer or more than 5 fields are found, the SLAP manager will skip the output.
52
+ 2. **Valid \`service\`**:
53
+ - Must begin with \`ls_\`.
54
+ - Only letters (lowercase) and underscores are allowed, per \`isValidTopicOrServiceName\` (BRC-87).
55
+ 3. **Advertised URI**:
56
+ - Must not be \`localhost\`.
57
+ - Must use a recognized scheme (\`https://\`, \`wss://\`, or specialized custom \`https+bsvauth...\` forms).
58
+ 4. **Signature**:
59
+ - Must be in DER format.
60
+ - Must match the identity key.
61
+
62
+ ---
63
+
64
+ ## Further Reading
65
+
66
+ - **SLAPLookupService**: For how to query these records afterward.
67
+ - **SHIP**: The complementary protocol for advertising "host-based" topics (\`tm_\`).
68
+ `;
69
+ //# sourceMappingURL=SLAPTopic.docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SLAPTopic.docs.js","sourceRoot":"","sources":["../../../../src/SLAP/SLAPTopic.docs.ts"],"names":[],"mappings":";;AAAA,kBAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEd,CAAA"}