@odatano/core 2.0.0-rc.5 → 2.0.0-rc.51

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 (239) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +99 -51
  2. package/@cds-models/CardanoAgentService/index.js +15 -0
  3. package/@cds-models/CardanoBackendService/index.d.ts +358 -0
  4. package/@cds-models/CardanoBackendService/index.js +41 -0
  5. package/@cds-models/CardanoIndexerService/index.d.ts +594 -11
  6. package/@cds-models/CardanoIndexerService/index.js +74 -0
  7. package/@cds-models/CardanoODataService/index.d.ts +417 -57
  8. package/@cds-models/CardanoODataService/index.js +42 -0
  9. package/@cds-models/CardanoSignService/index.d.ts +45 -19
  10. package/@cds-models/CardanoSignService/index.js +4 -0
  11. package/@cds-models/CardanoTransactionService/index.d.ts +70 -44
  12. package/@cds-models/CardanoTransactionService/index.js +5 -0
  13. package/@cds-models/CardanoWorkerService/index.d.ts +35 -22
  14. package/@cds-models/CardanoWorkerService/index.js +2 -0
  15. package/@cds-models/index.d.ts +114 -4
  16. package/@cds-models/index.js +20 -4
  17. package/@cds-models/odatano/cardano/index.d.ts +451 -32
  18. package/@cds-models/odatano/cardano/index.js +48 -0
  19. package/README.md +103 -167
  20. package/db/schema.cds +2455 -1705
  21. package/db/types.cds +456 -295
  22. package/package.json +41 -53
  23. package/scripts/deploy-schema.mjs +113 -0
  24. package/scripts/migrate-schema.mjs +528 -0
  25. package/scripts/migrate-slot-leader.mjs +96 -0
  26. package/src/index.d.ts +20 -21
  27. package/src/index.js +45 -31
  28. package/src/plugin.js +17 -35
  29. package/srv/blockchain/asset-decimals.d.ts +7 -0
  30. package/srv/blockchain/asset-decimals.js +91 -0
  31. package/srv/blockchain/backends/blockfrost-backend.d.ts +25 -137
  32. package/srv/blockchain/backends/blockfrost-backend.js +125 -215
  33. package/srv/blockchain/backends/call-signal.d.ts +7 -0
  34. package/srv/blockchain/backends/call-signal.js +22 -0
  35. package/srv/blockchain/backends/cardano-backend.d.ts +100 -189
  36. package/srv/blockchain/backends/cardano-backend.js +29 -5
  37. package/srv/blockchain/backends/koios-backend.d.ts +108 -170
  38. package/srv/blockchain/backends/koios-backend.js +488 -482
  39. package/srv/blockchain/backends/odatano-backend.d.ts +55 -0
  40. package/srv/blockchain/backends/odatano-backend.js +211 -0
  41. package/srv/blockchain/backends/ogmios-backend.d.ts +122 -190
  42. package/srv/blockchain/backends/ogmios-backend.js +683 -327
  43. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +14 -0
  44. package/srv/blockchain/backends/ogmios-frame-guard.js +89 -0
  45. package/srv/blockchain/cardano-client.d.ts +71 -241
  46. package/srv/blockchain/cardano-client.js +354 -322
  47. package/srv/blockchain/cardano-indexer.d.ts +295 -283
  48. package/srv/blockchain/cardano-indexer.js +1690 -502
  49. package/srv/blockchain/cardano-tx-builder.d.ts +25 -89
  50. package/srv/blockchain/cardano-tx-builder.js +164 -140
  51. package/srv/blockchain/circuit-breaker.d.ts +2 -13
  52. package/srv/blockchain/circuit-breaker.js +11 -15
  53. package/srv/blockchain/crawler/account-snapshots.d.ts +29 -0
  54. package/srv/blockchain/crawler/account-snapshots.js +173 -0
  55. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +17 -0
  56. package/srv/blockchain/crawler/asset-decimals-backfill.js +56 -0
  57. package/srv/blockchain/crawler/asset-registry-backfill.d.ts +46 -0
  58. package/srv/blockchain/crawler/asset-registry-backfill.js +157 -0
  59. package/srv/blockchain/crawler/asset-slice-backfill.d.ts +35 -0
  60. package/srv/blockchain/crawler/asset-slice-backfill.js +149 -0
  61. package/srv/blockchain/crawler/certificate-backfill.d.ts +56 -0
  62. package/srv/blockchain/crawler/certificate-backfill.js +174 -0
  63. package/srv/blockchain/crawler/crawler.d.ts +125 -81
  64. package/srv/blockchain/crawler/crawler.js +738 -167
  65. package/srv/blockchain/crawler/credential-backfill.d.ts +30 -0
  66. package/srv/blockchain/crawler/credential-backfill.js +101 -0
  67. package/srv/blockchain/crawler/hooks.d.ts +2 -17
  68. package/srv/blockchain/crawler/index.d.ts +1 -8
  69. package/srv/blockchain/crawler/index.js +31 -17
  70. package/srv/blockchain/crawler/input-asset-copies.d.ts +34 -0
  71. package/srv/blockchain/crawler/input-asset-copies.js +161 -0
  72. package/srv/blockchain/crawler/key-pages.d.ts +12 -0
  73. package/srv/blockchain/crawler/key-pages.js +48 -0
  74. package/srv/blockchain/crawler/metadata-position-backfill.d.ts +22 -0
  75. package/srv/blockchain/crawler/metadata-position-backfill.js +59 -0
  76. package/srv/blockchain/crawler/output-datum-backfill.d.ts +41 -0
  77. package/srv/blockchain/crawler/output-datum-backfill.js +100 -0
  78. package/srv/blockchain/crawler/sync-state.d.ts +31 -47
  79. package/srv/blockchain/crawler/sync-state.js +135 -128
  80. package/srv/blockchain/crawler/transaction-backfill.d.ts +46 -0
  81. package/srv/blockchain/crawler/transaction-backfill.js +271 -0
  82. package/srv/blockchain/crawler/utxo-set-import.d.ts +66 -0
  83. package/srv/blockchain/crawler/utxo-set-import.js +399 -0
  84. package/srv/blockchain/crawler/window-plan.d.ts +31 -0
  85. package/srv/blockchain/crawler/window-plan.js +59 -0
  86. package/srv/blockchain/ledger-state.d.ts +62 -0
  87. package/srv/blockchain/ledger-state.js +521 -0
  88. package/srv/blockchain/pending-spends.d.ts +16 -0
  89. package/srv/blockchain/pending-spends.js +81 -0
  90. package/srv/blockchain/pool-metadata.d.ts +15 -0
  91. package/srv/blockchain/pool-metadata.js +132 -0
  92. package/srv/blockchain/request-coalescer.d.ts +2 -16
  93. package/srv/blockchain/request-coalescer.js +2 -16
  94. package/srv/blockchain/signing/cose-verifier.d.ts +3 -17
  95. package/srv/blockchain/signing/cose-verifier.js +146 -70
  96. package/srv/blockchain/signing/external-signer.d.ts +15 -115
  97. package/srv/blockchain/signing/external-signer.js +22 -131
  98. package/srv/blockchain/signing/failed-recheck.d.ts +17 -0
  99. package/srv/blockchain/signing/failed-recheck.js +135 -0
  100. package/srv/blockchain/signing/hsm-signer.d.ts +10 -54
  101. package/srv/blockchain/signing/hsm-signer.js +28 -79
  102. package/srv/blockchain/signing/landing-proof.d.ts +60 -0
  103. package/srv/blockchain/signing/landing-proof.js +224 -0
  104. package/srv/blockchain/signing/signature-verifier.d.ts +9 -47
  105. package/srv/blockchain/signing/signature-verifier.js +71 -87
  106. package/srv/blockchain/signing/submission-finalizer.d.ts +37 -45
  107. package/srv/blockchain/signing/submission-finalizer.js +280 -86
  108. package/srv/blockchain/stored-chain.d.ts +19 -0
  109. package/srv/blockchain/stored-chain.js +258 -0
  110. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +31 -229
  111. package/srv/blockchain/transaction-building/buildooor-tx.js +663 -421
  112. package/srv/blockchain/transaction-building/cardano-tx.d.ts +9 -37
  113. package/srv/blockchain/transaction-presence.d.ts +12 -0
  114. package/srv/blockchain/transaction-presence.js +29 -0
  115. package/srv/blockchain/transaction-rows.d.ts +12 -0
  116. package/srv/blockchain/transaction-rows.js +44 -0
  117. package/srv/blockchain/wallet-worker/build-request.d.ts +8 -23
  118. package/srv/blockchain/wallet-worker/build-request.js +40 -353
  119. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +27 -47
  120. package/srv/blockchain/wallet-worker/confirmation-tracker.js +158 -61
  121. package/srv/blockchain/wallet-worker/index.d.ts +1 -1
  122. package/srv/blockchain/wallet-worker/index.js +3 -11
  123. package/srv/blockchain/wallet-worker/invalidation.d.ts +35 -0
  124. package/srv/blockchain/wallet-worker/invalidation.js +128 -0
  125. package/srv/blockchain/wallet-worker/job-store.d.ts +58 -150
  126. package/srv/blockchain/wallet-worker/job-store.js +200 -273
  127. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -26
  128. package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -28
  129. package/srv/blockchain/wallet-worker/signers.d.ts +5 -24
  130. package/srv/blockchain/wallet-worker/signers.js +4 -12
  131. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +29 -82
  132. package/srv/blockchain/wallet-worker/wallet-worker.js +334 -198
  133. package/srv/cardano-agent-service.cds +122 -84
  134. package/srv/cardano-agent-service.js +12 -9
  135. package/srv/cardano-backend-service.cds +81 -0
  136. package/srv/cardano-backend-service.d.ts +2 -0
  137. package/srv/cardano-backend-service.js +259 -0
  138. package/srv/cardano-indexer-service.cds +393 -18
  139. package/srv/cardano-indexer-service.d.ts +5 -1
  140. package/srv/cardano-indexer-service.js +477 -16
  141. package/srv/cardano-service.cds +426 -269
  142. package/srv/cardano-service.js +640 -217
  143. package/srv/cardano-sign-service.cds +211 -180
  144. package/srv/cardano-sign-service.js +210 -287
  145. package/srv/cardano-tx-service.cds +462 -370
  146. package/srv/cardano-tx-service.js +283 -800
  147. package/srv/cardano-ui.cds +16 -16
  148. package/srv/cardano-worker-service.cds +141 -125
  149. package/srv/cardano-worker-service.js +104 -61
  150. package/srv/cbor/cip68.d.ts +13 -0
  151. package/srv/cbor/cip68.js +56 -0
  152. package/srv/cbor/index.d.ts +3 -1
  153. package/srv/cbor/index.js +9 -1
  154. package/srv/cbor/parse.d.ts +30 -18
  155. package/srv/cbor/parse.js +44 -9
  156. package/srv/cbor/plutus-data-json.d.ts +20 -0
  157. package/srv/cbor/plutus-data-json.js +32 -0
  158. package/srv/config.d.ts +117 -0
  159. package/srv/config.js +419 -0
  160. package/srv/server.d.ts +15 -110
  161. package/srv/server.js +83 -405
  162. package/srv/utils/agent-access.d.ts +11 -0
  163. package/srv/utils/agent-access.js +86 -0
  164. package/srv/utils/agent-grants-config.d.ts +0 -46
  165. package/srv/utils/agent-grants-config.js +17 -85
  166. package/srv/utils/agent-grants.d.ts +106 -122
  167. package/srv/utils/agent-grants.js +538 -237
  168. package/srv/utils/agent-token-auth.d.ts +4 -99
  169. package/srv/utils/agent-token-auth.js +62 -186
  170. package/srv/utils/backend-request-handler.d.ts +3 -17
  171. package/srv/utils/backend-request-handler.js +3 -18
  172. package/srv/utils/build-request.d.ts +52 -0
  173. package/srv/utils/build-request.js +487 -0
  174. package/srv/utils/collections.d.ts +4 -10
  175. package/srv/utils/collections.js +14 -10
  176. package/srv/utils/const.d.ts +32 -75
  177. package/srv/utils/const.js +40 -80
  178. package/srv/utils/crypto.d.ts +3 -12
  179. package/srv/utils/crypto.js +11 -25
  180. package/srv/utils/db-indexes.d.ts +31 -0
  181. package/srv/utils/db-indexes.js +185 -0
  182. package/srv/utils/db-kind.d.ts +23 -0
  183. package/srv/utils/db-kind.js +42 -0
  184. package/srv/utils/db-sanitize.d.ts +20 -0
  185. package/srv/utils/db-sanitize.js +80 -0
  186. package/srv/utils/deep-json.d.ts +6 -0
  187. package/srv/utils/deep-json.js +240 -0
  188. package/srv/utils/detached-run.d.ts +41 -0
  189. package/srv/utils/detached-run.js +101 -0
  190. package/srv/utils/epoch-slots.d.ts +14 -0
  191. package/srv/utils/epoch-slots.js +45 -0
  192. package/srv/utils/error-codes.d.ts +26 -75
  193. package/srv/utils/error-codes.js +27 -72
  194. package/srv/utils/errors.d.ts +55 -187
  195. package/srv/utils/errors.js +161 -235
  196. package/srv/utils/lease.d.ts +20 -0
  197. package/srv/utils/lease.js +62 -0
  198. package/srv/utils/liveness.d.ts +12 -0
  199. package/srv/utils/liveness.js +35 -0
  200. package/srv/utils/mappers.d.ts +111 -223
  201. package/srv/utils/mappers.js +432 -371
  202. package/srv/utils/navigation.d.ts +17 -0
  203. package/srv/utils/navigation.js +52 -0
  204. package/srv/utils/network-context.d.ts +0 -1
  205. package/srv/utils/network-context.js +9 -15
  206. package/srv/utils/paging.d.ts +31 -0
  207. package/srv/utils/paging.js +43 -0
  208. package/srv/utils/pg-inline-json.d.ts +8 -0
  209. package/srv/utils/pg-inline-json.js +58 -0
  210. package/srv/utils/pg-order-nulls.d.ts +14 -0
  211. package/srv/utils/pg-order-nulls.js +54 -0
  212. package/srv/utils/plutus-placeholders.d.ts +16 -22
  213. package/srv/utils/plutus-placeholders.js +62 -33
  214. package/srv/utils/rate-limiter.d.ts +2 -21
  215. package/srv/utils/rate-limiter.js +5 -17
  216. package/srv/utils/readiness.d.ts +12 -0
  217. package/srv/utils/readiness.js +29 -0
  218. package/srv/utils/reference-script.d.ts +19 -0
  219. package/srv/utils/reference-script.js +84 -0
  220. package/srv/utils/resolution.d.ts +13 -0
  221. package/srv/utils/resolution.js +47 -0
  222. package/srv/utils/result-numbers.d.ts +15 -0
  223. package/srv/utils/result-numbers.js +61 -0
  224. package/srv/utils/row-values.d.ts +7 -0
  225. package/srv/utils/row-values.js +27 -0
  226. package/srv/utils/service-events.d.ts +0 -24
  227. package/srv/utils/service-events.js +3 -25
  228. package/srv/utils/signing-helper.d.ts +3 -20
  229. package/srv/utils/signing-helper.js +35 -64
  230. package/srv/utils/tx-build-helper.d.ts +25 -105
  231. package/srv/utils/tx-build-helper.js +108 -156
  232. package/srv/utils/tx-request-parsers.d.ts +82 -33
  233. package/srv/utils/tx-request-parsers.js +401 -49
  234. package/srv/utils/tx-utils.d.ts +3 -27
  235. package/srv/utils/tx-utils.js +32 -50
  236. package/srv/utils/types.d.ts +294 -232
  237. package/srv/utils/types.js +2 -22
  238. package/srv/utils/validators.d.ts +22 -92
  239. package/srv/utils/validators.js +60 -170
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.publicLookup = exports.POOL_METADATA_MAX_BYTES = void 0;
7
+ exports.validPoolMetadata = validPoolMetadata;
8
+ exports.isPublicAddress = isPublicAddress;
9
+ exports.fetchPoolMetadata = fetchPoolMetadata;
10
+ const cds_1 = __importDefault(require("@sap/cds"));
11
+ const node_dns_1 = __importDefault(require("node:dns"));
12
+ const node_http_1 = __importDefault(require("node:http"));
13
+ const node_https_1 = __importDefault(require("node:https"));
14
+ const node_net_1 = __importDefault(require("node:net"));
15
+ const node_util_1 = require("node:util");
16
+ const crypto_1 = require("@harmoniclabs/crypto");
17
+ const logger = cds_1.default.log('PoolMetadata');
18
+ /** A stake pool's metadata file is at most this many bytes. */
19
+ exports.POOL_METADATA_MAX_BYTES = 512;
20
+ const MAX_REDIRECTS = 5;
21
+ /** For the whole fetch, redirects included. */
22
+ const FETCH_TIMEOUT_MS = 3_000;
23
+ const chars = (s) => [...s].length;
24
+ // The limits cardano-db-sync applies: name up to 50 characters, description up to 255, ticker 3 to 5.
25
+ // Null when a field is missing, not a string or out of range.
26
+ function validPoolMetadata(value) {
27
+ if (!value || typeof value !== 'object' || Array.isArray(value))
28
+ return null;
29
+ const { name, ticker, homepage, description } = value;
30
+ if (typeof name !== 'string' || typeof ticker !== 'string' || typeof homepage !== 'string' || typeof description !== 'string')
31
+ return null;
32
+ if (chars(name) > 50 || chars(description) > 255 || chars(ticker) < 3 || chars(ticker) > 5)
33
+ return null;
34
+ if (Buffer.byteLength(homepage, 'utf8') > exports.POOL_METADATA_MAX_BYTES)
35
+ return null;
36
+ return { name, ticker, homepage, description };
37
+ }
38
+ // Loopback, private, link-local, carrier-grade NAT, multicast and reserved ranges.
39
+ // A pool registers any URL it likes, so the fetch must not reach hosts behind this server.
40
+ const NON_PUBLIC = new node_net_1.default.BlockList();
41
+ for (const [prefix, bits] of [
42
+ ['0.0.0.0', 8], ['10.0.0.0', 8], ['100.64.0.0', 10], ['127.0.0.0', 8], ['169.254.0.0', 16], ['172.16.0.0', 12],
43
+ ['192.0.0.0', 24], ['192.168.0.0', 16], ['198.18.0.0', 15], ['224.0.0.0', 3],
44
+ ])
45
+ NON_PUBLIC.addSubnet(prefix, bits, 'ipv4');
46
+ for (const [prefix, bits] of [['::', 127], ['64:ff9b::', 96], ['fc00::', 7], ['fe80::', 10], ['ff00::', 8]]) {
47
+ NON_PUBLIC.addSubnet(prefix, bits, 'ipv6');
48
+ }
49
+ function isPublicAddress(address) {
50
+ const family = node_net_1.default.isIP(address);
51
+ return family !== 0 && !NON_PUBLIC.check(address, family === 6 ? 'ipv6' : 'ipv4');
52
+ }
53
+ // DNS lookup that refuses a name with any non-public address. The connection uses the checked
54
+ // addresses, so a second, different DNS answer cannot redirect it.
55
+ const publicLookup = (hostname, options, callback) => {
56
+ node_dns_1.default.lookup(hostname, { ...options, all: true }, (err, addresses) => {
57
+ if (err)
58
+ return callback(err, '', 4);
59
+ if (addresses.length === 0 || addresses.some(a => !isPublicAddress(a.address))) {
60
+ return callback(new Error(`${hostname} resolves to a non-public address`), '', 4);
61
+ }
62
+ if (options.all)
63
+ return callback(null, addresses);
64
+ return callback(null, addresses[0].address, addresses[0].family);
65
+ });
66
+ };
67
+ exports.publicLookup = publicLookup;
68
+ function get(url, signal) {
69
+ return new Promise((resolve, reject) => {
70
+ const transport = url.protocol === 'https:' ? node_https_1.default : node_http_1.default;
71
+ const req = transport.get(url, { lookup: exports.publicLookup, signal, headers: { accept: 'application/json' } }, (res) => {
72
+ const chunks = [];
73
+ let size = 0;
74
+ const done = (body) => resolve({ status: res.statusCode ?? 0, location: res.headers.location, body });
75
+ res.on('data', (chunk) => {
76
+ size += chunk.length;
77
+ if (size > exports.POOL_METADATA_MAX_BYTES) {
78
+ res.destroy();
79
+ done(null);
80
+ }
81
+ else {
82
+ chunks.push(chunk);
83
+ }
84
+ });
85
+ res.on('end', () => done(Buffer.concat(chunks)));
86
+ res.on('error', reject);
87
+ });
88
+ req.on('error', reject);
89
+ });
90
+ }
91
+ /** The file behind `url`, following redirects; every hop must be http(s) on a public host. */
92
+ async function download(url) {
93
+ const signal = AbortSignal.timeout(FETCH_TIMEOUT_MS);
94
+ let next = new URL(url);
95
+ for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {
96
+ if (next.protocol !== 'http:' && next.protocol !== 'https:')
97
+ throw new Error(`unsupported protocol ${next.protocol}`);
98
+ // an address literal never reaches the DNS lookup
99
+ const host = next.hostname.replace(/^\[|\]$/g, '');
100
+ if (node_net_1.default.isIP(host) && !isPublicAddress(host))
101
+ throw new Error(`${host} is not a public address`);
102
+ const reply = await get(next, signal);
103
+ if ([301, 302, 303, 307, 308].includes(reply.status) && reply.location) {
104
+ next = new URL(reply.location, next);
105
+ continue;
106
+ }
107
+ if (reply.status !== 200)
108
+ throw new Error(`HTTP ${reply.status}`);
109
+ if (!reply.body)
110
+ throw new Error(`more than ${exports.POOL_METADATA_MAX_BYTES} bytes`);
111
+ return reply.body;
112
+ }
113
+ throw new Error(`more than ${MAX_REDIRECTS} redirects`);
114
+ }
115
+ // Loads a pool's metadata file and returns its fields when the bytes hash to `hash` (blake2b-256,
116
+ // as registered on chain). Null for any failure; never throws.
117
+ async function fetchPoolMetadata(url, hash) {
118
+ try {
119
+ const bytes = await download(url);
120
+ if (Buffer.from((0, crypto_1.blake2b_256)(bytes)).toString('hex') !== hash.toLowerCase())
121
+ throw new Error('hash mismatch');
122
+ const metadata = validPoolMetadata(JSON.parse(new node_util_1.TextDecoder('utf-8', { fatal: true }).decode(bytes)));
123
+ if (!metadata)
124
+ throw new Error('not a valid pool metadata file');
125
+ return metadata;
126
+ }
127
+ catch (err) {
128
+ logger.debug(`Pool metadata ${url} not used: ${err instanceof Error ? err.message : String(err)}`);
129
+ return null;
130
+ }
131
+ }
132
+ //# sourceMappingURL=pool-metadata.js.map
@@ -1,21 +1,7 @@
1
- /**
2
- * RequestCoalescer — Deduplicates concurrent requests for the same resource key.
3
- *
4
- * When multiple callers request the same key simultaneously (e.g., same txHash
5
- * during parallel address indexing), only one backend call is made. All callers
6
- * receive the same Promise/result.
7
- */
1
+ /** Concurrent requests for the same key share one backend call and its result. */
8
2
  export declare class RequestCoalescer<T> {
9
3
  private pending;
10
- /**
11
- * Get a value by key, deduplicating concurrent requests.
12
- * If a request for this key is already in-flight, returns the existing Promise.
13
- * Otherwise, calls the fetcher and caches the Promise until it resolves.
14
- *
15
- * @param key Unique identifier (e.g., txHash, bech32 address)
16
- * @param fetcher Function that performs the actual fetch
17
- * @returns The fetched value
18
- */
4
+ /** Returns the in-flight promise for this key, or starts the fetcher. */
19
5
  get(key: string, fetcher: () => Promise<T>): Promise<T>;
20
6
  /** Number of currently in-flight requests */
21
7
  get size(): number;
@@ -1,24 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RequestCoalescer = void 0;
4
- /**
5
- * RequestCoalescer — Deduplicates concurrent requests for the same resource key.
6
- *
7
- * When multiple callers request the same key simultaneously (e.g., same txHash
8
- * during parallel address indexing), only one backend call is made. All callers
9
- * receive the same Promise/result.
10
- */
4
+ /** Concurrent requests for the same key share one backend call and its result. */
11
5
  class RequestCoalescer {
12
6
  pending = new Map();
13
- /**
14
- * Get a value by key, deduplicating concurrent requests.
15
- * If a request for this key is already in-flight, returns the existing Promise.
16
- * Otherwise, calls the fetcher and caches the Promise until it resolves.
17
- *
18
- * @param key Unique identifier (e.g., txHash, bech32 address)
19
- * @param fetcher Function that performs the actual fetch
20
- * @returns The fetched value
21
- */
7
+ /** Returns the in-flight promise for this key, or starts the fetcher. */
22
8
  async get(key, fetcher) {
23
9
  const existing = this.pending.get(key);
24
10
  if (existing)
@@ -1,8 +1,3 @@
1
- /**
2
- * Input to {@link verifyDataSignature}. Mirrors the CIP-30 `signData` result:
3
- * `coseSignature` is the hex `signature` field (COSE_Sign1), `coseKey` is the
4
- * hex `key` field (COSE_Key).
5
- */
6
1
  export interface CoseVerifyInput {
7
2
  address: string;
8
3
  coseSignature: string;
@@ -14,21 +9,12 @@ export interface CoseVerifyResult {
14
9
  valid: boolean;
15
10
  /** failure detail when !valid; empty string when valid */
16
11
  reason: string;
17
- /** UTF-8 of the signed payload, echoed back for the caller to inspect */
12
+ /** The signed message as text. Empty when the payload is not UTF-8, or hashed and not matched. */
18
13
  signedPayload: string;
14
+ /** hex; the payload bytes as signed (the blake2b-224 of the message when the wallet hashed it) */
15
+ signedPayloadHex: string;
19
16
  /** hex blake2b-224 of the signer public key (empty until the key is parsed) */
20
17
  signerVkh: string;
21
18
  }
22
- /**
23
- * Verify a CIP-30 `signData` (COSE_Sign1) message signature against a bech32
24
- * address. Stateless crypto only & no nonce/replay/session handling.
25
- * Never throws: all failures are returned as `{ valid: false, reason }`.
26
- *
27
- * Checks, in order:
28
- * 1. COSE_Sign1 + COSE_Key parse
29
- * 2. signer key hash (blake2b-224) == the address payment credential (key, not script)
30
- * 3. (optional) signed payload == expectedPayload
31
- * 4. Ed25519 signature over the COSE Sig_structure
32
- */
33
19
  export declare function verifyDataSignature(input: CoseVerifyInput): CoseVerifyResult;
34
20
  //# sourceMappingURL=cose-verifier.d.ts.map
@@ -8,24 +8,45 @@ const cds_1 = __importDefault(require("@sap/cds"));
8
8
  const cbor_1 = require("@harmoniclabs/cbor");
9
9
  const uint8array_utils_1 = require("@harmoniclabs/uint8array-utils");
10
10
  const crypto_1 = require("@harmoniclabs/crypto");
11
- const validators_1 = require("../../utils/validators");
11
+ const bech32_1 = require("bech32");
12
+ const node_util_1 = require("node:util");
13
+ const const_1 = require("../../utils/const");
12
14
  const logger = cds_1.default.log('CoseVerifier');
13
15
  /** CBOR tag 18 = COSE_Sign1 (RFC 8152). signData may or may not wrap in it. */
14
16
  const COSE_SIGN1_TAG = 18;
15
- /** COSE_Key label for the OKP public key x-coordinate (the raw Ed25519 key). */
16
- const COSE_KEY_LABEL_X = -2;
17
+ // The one algorithm CIP-30 signData allows: EdDSA with an Ed25519 key.
18
+ const ALG_EDDSA = -8;
19
+ const KTY_OKP = 1;
20
+ const CRV_ED25519 = 6;
17
21
  const ED25519_PUBKEY_LEN = 32;
18
- /** Find a COSE map entry by its integer label (handles +ve and -ve labels). */
19
- function findIntLabel(map, label) {
20
- const entry = map.map.find(e => {
21
- if (e.k instanceof cbor_1.CborUInt)
22
- return Number(e.k.num) === label;
23
- if (e.k instanceof cbor_1.CborNegInt)
24
- return Number(e.k.num) === label;
25
- return false;
26
- });
27
- return entry?.v;
22
+ const ED25519_SIGNATURE_LEN = 64;
23
+ const BLAKE2B_224_LEN = 28;
24
+ /** Entries of a COSE map by label. Throws on a repeated label, which COSE forbids. */
25
+ function readLabels(obj, what) {
26
+ if (!(obj instanceof cbor_1.CborMap))
27
+ throw new Error(`${what} must be a CBOR map`);
28
+ const labels = new Map();
29
+ for (const { k, v } of obj.map) {
30
+ const label = k instanceof cbor_1.CborUInt || k instanceof cbor_1.CborNegInt ? Number(k.num) : k instanceof cbor_1.CborText ? k.text : undefined;
31
+ if (label === undefined)
32
+ throw new Error(`${what} has a label that is neither an integer nor a text`);
33
+ if (labels.has(label))
34
+ throw new Error(`${what} repeats the label ${label}`);
35
+ labels.set(label, v);
36
+ }
37
+ return labels;
38
+ }
39
+ function intValue(obj) {
40
+ return obj instanceof cbor_1.CborUInt || obj instanceof cbor_1.CborNegInt ? Number(obj.num) : undefined;
28
41
  }
42
+ function optionalBytes(obj, what) {
43
+ if (obj === undefined)
44
+ return undefined;
45
+ if (!(obj instanceof cbor_1.CborBytes))
46
+ throw new Error(`${what} must be a byte string`);
47
+ return obj.bytes;
48
+ }
49
+ const sameBytes = (a, b) => Buffer.from(a).equals(Buffer.from(b));
29
50
  function parseCoseSign1(hex) {
30
51
  let obj = cbor_1.Cbor.parse((0, uint8array_utils_1.fromHex)(hex));
31
52
  // CIP-30 signData may emit the COSE_Sign1 wrapped in tag 18 or bare.
@@ -34,33 +55,59 @@ function parseCoseSign1(hex) {
34
55
  if (!(obj instanceof cbor_1.CborArray) || obj.array.length !== 4) {
35
56
  throw new Error('COSE_Sign1 must be a 4-element array [protected, unprotected, payload, signature]');
36
57
  }
37
- const [prot, , payload, signature] = obj.array;
58
+ const [prot, unprot, payload, signature] = obj.array;
38
59
  if (!(prot instanceof cbor_1.CborBytes))
39
60
  throw new Error('COSE_Sign1 protected header must be a byte string');
40
61
  if (!(payload instanceof cbor_1.CborBytes))
41
62
  throw new Error('COSE_Sign1 payload must be a byte string (detached payloads are not supported)');
42
- if (!(signature instanceof cbor_1.CborBytes))
43
- throw new Error('COSE_Sign1 signature must be a byte string');
44
- return { protectedBytes: prot.bytes, payload: payload.bytes, signature: signature.bytes };
63
+ if (!(signature instanceof cbor_1.CborBytes) || signature.bytes.length !== ED25519_SIGNATURE_LEN) {
64
+ throw new Error(`COSE_Sign1 signature must be a byte string of ${ED25519_SIGNATURE_LEN} bytes`);
65
+ }
66
+ if (prot.bytes.length === 0)
67
+ throw new Error('COSE_Sign1 protected header is empty; alg and address are required');
68
+ const signed = readLabels(cbor_1.Cbor.parse(prot.bytes), 'COSE_Sign1 protected header');
69
+ const unsigned = readLabels(unprot, 'COSE_Sign1 unprotected header');
70
+ for (const label of unsigned.keys()) {
71
+ if (signed.has(label))
72
+ throw new Error(`COSE_Sign1 carries the header ${label} twice`);
73
+ }
74
+ if (intValue(signed.get(1)) !== ALG_EDDSA)
75
+ throw new Error('COSE_Sign1 protected header alg (1) must be EdDSA (-8)');
76
+ const address = optionalBytes(signed.get('address'), 'COSE_Sign1 address header');
77
+ if (!address)
78
+ throw new Error('COSE_Sign1 protected header carries no address');
79
+ const hashed = unsigned.get('hashed') ?? signed.get('hashed');
80
+ if (hashed !== undefined && !(hashed instanceof cbor_1.CborSimple && typeof hashed.simple === 'boolean')) {
81
+ throw new Error('COSE_Sign1 header hashed must be a boolean');
82
+ }
83
+ return {
84
+ protectedBytes: prot.bytes,
85
+ payload: payload.bytes,
86
+ signature: signature.bytes,
87
+ address,
88
+ kid: optionalBytes(signed.get(4), 'COSE_Sign1 kid (4)'),
89
+ hashed: hashed instanceof cbor_1.CborSimple && hashed.simple === true,
90
+ };
45
91
  }
46
- /** Extract the raw 32-byte Ed25519 public key from a COSE_Key (label -2). */
92
+ /** The Ed25519 public key of a COSE_Key, after its key type, algorithm and curve are checked. */
47
93
  function parseCoseKey(hex) {
48
- const obj = cbor_1.Cbor.parse((0, uint8array_utils_1.fromHex)(hex));
49
- if (!(obj instanceof cbor_1.CborMap))
50
- throw new Error('COSE_Key must be a CBOR map');
51
- const x = findIntLabel(obj, COSE_KEY_LABEL_X);
94
+ const key = readLabels(cbor_1.Cbor.parse((0, uint8array_utils_1.fromHex)(hex)), 'COSE_Key');
95
+ if (intValue(key.get(1)) !== KTY_OKP)
96
+ throw new Error('COSE_Key kty (1) must be OKP (1)');
97
+ if (intValue(key.get(3)) !== ALG_EDDSA)
98
+ throw new Error('COSE_Key alg (3) must be EdDSA (-8)');
99
+ if (intValue(key.get(-1)) !== CRV_ED25519)
100
+ throw new Error('COSE_Key crv (-1) must be Ed25519 (6)');
101
+ const x = key.get(-2);
52
102
  if (!(x instanceof cbor_1.CborBytes))
53
103
  throw new Error('COSE_Key is missing the Ed25519 public key (label -2)');
54
104
  if (x.bytes.length !== ED25519_PUBKEY_LEN) {
55
105
  throw new Error(`COSE_Key public key must be ${ED25519_PUBKEY_LEN} bytes, got ${x.bytes.length}`);
56
106
  }
57
- return x.bytes;
107
+ return { publicKey: x.bytes, kid: optionalBytes(key.get(2), 'COSE_Key kid (2)') };
58
108
  }
59
- /**
60
- * Build the COSE Sig_structure that was actually signed and CBOR-encode it:
61
- * [ "Signature1" (tstr), protected (bstr, exact bytes), external_aad (h''), payload (bstr) ]
62
- * external_aad is empty for CIP-8 / CIP-30 signData.
63
- */
109
+ // The signed COSE Sig_structure: ["Signature1", protected, external_aad, payload].
110
+ // external_aad is empty for CIP-8 and CIP-30 signData.
64
111
  function buildSigStructure(protectedBytes, payload) {
65
112
  const sigStruct = new cbor_1.CborArray([
66
113
  new cbor_1.CborText('Signature1'),
@@ -70,59 +117,88 @@ function buildSigStructure(protectedBytes, payload) {
70
117
  ]);
71
118
  return cbor_1.Cbor.encode(sigStruct);
72
119
  }
73
- /**
74
- * Verify a CIP-30 `signData` (COSE_Sign1) message signature against a bech32
75
- * address. Stateless crypto only & no nonce/replay/session handling.
76
- * Never throws: all failures are returned as `{ valid: false, reason }`.
77
- *
78
- * Checks, in order:
79
- * 1. COSE_Sign1 + COSE_Key parse
80
- * 2. signer key hash (blake2b-224) == the address payment credential (key, not script)
81
- * 3. (optional) signed payload == expectedPayload
82
- * 4. Ed25519 signature over the COSE Sig_structure
83
- */
120
+ // The credential whose key signs for an address (CIP-30): the payment credential of a base, pointer
121
+ // or enterprise address, the stake credential of a reward address. Null for anything else.
122
+ function signingCredential(address) {
123
+ let bytes;
124
+ try {
125
+ bytes = Buffer.from(bech32_1.bech32.fromWords(bech32_1.bech32.decode(address, const_1.BECH32_MAX_LENGTH).words));
126
+ }
127
+ catch {
128
+ return null;
129
+ }
130
+ if (bytes.length < 1 + BLAKE2B_224_LEN)
131
+ return null;
132
+ const type = bytes[0] >> 4;
133
+ const hash = bytes.subarray(1, 1 + BLAKE2B_224_LEN).toString('hex');
134
+ if (type <= 7)
135
+ return { bytes, hash, isScript: (type & 1) === 1 };
136
+ if (type === 14 || type === 15)
137
+ return { bytes, hash, isScript: type === 15 };
138
+ return null;
139
+ }
140
+ /** The bytes as text when they are valid UTF-8, else an empty string. */
141
+ function utf8OrEmpty(bytes) {
142
+ try {
143
+ return new node_util_1.TextDecoder('utf-8', { fatal: true }).decode(bytes);
144
+ }
145
+ catch {
146
+ return '';
147
+ }
148
+ }
149
+ // Checks one CIP-30 signData result: structure, address, signer key, payload, then the signature.
150
+ // Stateless: a caller using it for login must issue the message itself, with a nonce and an expiry.
151
+ // Never throws; a failure returns `valid: false` with the reason.
84
152
  function verifyDataSignature(input) {
85
- const result = { valid: false, reason: '', signedPayload: '', signerVkh: '' };
153
+ const result = { valid: false, reason: '', signedPayload: '', signedPayloadHex: '', signerVkh: '' };
154
+ const fail = (reason) => {
155
+ result.reason = reason;
156
+ return result;
157
+ };
86
158
  try {
87
- const { protectedBytes, payload, signature } = parseCoseSign1(input.coseSignature);
88
- const pubKey = parseCoseKey(input.coseKey);
89
- result.signedPayload = Buffer.from(payload).toString('utf8');
90
- result.signerVkh = (0, uint8array_utils_1.toHex)((0, crypto_1.blake2b_224)(pubKey));
91
- // 2. signer key hash must equal the address payment credential (key hash, not script)
92
- const cred = (0, validators_1.extractPaymentCredential)(input.address);
93
- if (!cred) {
94
- result.reason = 'Address could not be decoded or has no payment credential (base/enterprise key-hash address required)';
95
- return result;
159
+ const sign1 = parseCoseSign1(input.coseSignature);
160
+ const key = parseCoseKey(input.coseKey);
161
+ result.signedPayloadHex = (0, uint8array_utils_1.toHex)(sign1.payload);
162
+ result.signerVkh = (0, uint8array_utils_1.toHex)((0, crypto_1.blake2b_224)(key.publicKey));
163
+ if (!sign1.hashed)
164
+ result.signedPayload = utf8OrEmpty(sign1.payload);
165
+ if (sign1.kid && key.kid && !sameBytes(sign1.kid, key.kid))
166
+ return fail('COSE_Sign1 kid and COSE_Key kid differ');
167
+ const signer = signingCredential(input.address);
168
+ if (!signer)
169
+ return fail('Address could not be decoded (a bech32 payment or reward address is required)');
170
+ if (!sameBytes(sign1.address, signer.bytes))
171
+ return fail('The address in the signed header is not the given address');
172
+ if (signer.isScript)
173
+ return fail('Address credential is a script hash; a key-hash address is required');
174
+ if (signer.hash !== result.signerVkh) {
175
+ return fail(`Signer key hash ${result.signerVkh} does not match the address credential ${signer.hash}`);
96
176
  }
97
- if (cred.isScript) {
98
- result.reason = 'Address payment credential is a script hash; a key-hash address is required';
99
- return result;
177
+ // The message is compared byte for byte; a hashed payload by its blake2b-224.
178
+ const expected = input.expectedPayload ?? undefined;
179
+ if (sign1.hashed) {
180
+ if (sign1.payload.length !== BLAKE2B_224_LEN)
181
+ return fail(`A hashed payload must be ${BLAKE2B_224_LEN} bytes (blake2b-224)`);
182
+ if (expected === undefined)
183
+ return fail('The wallet signed the hash of the message; pass expectedPayload to compare it');
184
+ if (!sameBytes((0, crypto_1.blake2b_224)(Buffer.from(expected, 'utf8')), sign1.payload))
185
+ return fail('Signed payload does not match the expected payload');
186
+ result.signedPayload = expected;
100
187
  }
101
- if (cred.hash.toLowerCase() !== result.signerVkh.toLowerCase()) {
102
- result.reason = `Signer key hash ${result.signerVkh} does not match address payment credential ${cred.hash}`;
103
- return result;
188
+ else if (expected !== undefined && !sameBytes(Buffer.from(expected, 'utf8'), sign1.payload)) {
189
+ return fail('Signed payload does not match the expected payload');
104
190
  }
105
- // 3. optional anti-replay payload check
106
- if (input.expectedPayload !== undefined && input.expectedPayload !== null) {
107
- if (result.signedPayload !== input.expectedPayload) {
108
- result.reason = 'Signed payload does not match the expected payload';
109
- return result;
110
- }
111
- }
112
- // 4. Ed25519 signature over the rebuilt Sig_structure
113
- const sigStructure = buildSigStructure(protectedBytes, payload);
114
- if (!(0, crypto_1.verifyEd25519Signature_sync)(signature, sigStructure, pubKey)) {
115
- result.reason = 'Ed25519 signature does not verify against the signed message';
116
- return result;
191
+ const sigStructure = buildSigStructure(sign1.protectedBytes, sign1.payload);
192
+ if (!(0, crypto_1.verifyEd25519Signature_sync)(sign1.signature, sigStructure, key.publicKey)) {
193
+ return fail('Ed25519 signature does not verify against the signed message');
117
194
  }
118
195
  result.valid = true;
119
196
  logger.debug({ signerVkh: result.signerVkh }, 'COSE_Sign1 data signature verified');
120
197
  return result;
121
198
  }
122
199
  catch (err) {
123
- result.reason = `Failed to verify data signature: ${err instanceof Error ? err.message : String(err)}`;
124
- logger.warn(result.reason);
125
- return result;
200
+ logger.warn(`Data signature not verified: ${err instanceof Error ? err.message : String(err)}`);
201
+ return fail(`Failed to verify data signature: ${err instanceof Error ? err.message : String(err)}`);
126
202
  }
127
203
  }
128
204
  //# sourceMappingURL=cose-verifier.js.map
@@ -1,145 +1,45 @@
1
1
  import { SignatureVerifier } from './signature-verifier';
2
2
  import { ExternalSignerType, UnsignedTxExportPayload, SignedTxPayload, SigningWorkflowState, SignatureVerificationResult, VerificationOptions } from '../../utils/types';
3
- /**
4
- * ExternalSignerModule - Manages the external signing workflow
5
- *
6
- * This module orchestrates the complete flow:
7
- * 1. Create signing request from build result
8
- * 2. Export unsigned transaction for external signing
9
- * 3. Receive and verify signed transaction
10
- * 4. Prepare for submission
11
- *
12
- * Key security principles:
13
- * - NO private keys are ever handled by this service
14
- * - Signature verification ensures transaction integrity
15
- * - Complete audit trail of the signing workflow
16
- */
3
+ /** External signing workflow. No private keys are ever handled here. */
17
4
  export declare class ExternalSignerModule {
18
5
  private verifier;
19
6
  private signingTtlMs;
20
7
  constructor(options?: {
21
8
  signingTtlMs?: number;
22
9
  });
23
- /**
24
- * Create an unsigned transaction export payload for external signing
25
- *
26
- * This is the entry point for the external signing workflow.
27
- * Call this after building a transaction to get a standardized
28
- * payload that external signers can use.
29
- *
30
- * @param buildId - The build ID from TransactionBuilds
31
- * @param unsignedTxCbor - The unsigned transaction CBOR
32
- * @param txBodyHash - The transaction body hash
33
- * @param network - The Cardano network
34
- * @param options - Additional options
35
- * @returns Unsigned transaction export payload
36
- */
10
+ /** Create the unsigned-tx export payload that starts a signing request (workflow entry point). */
37
11
  createSigningRequest(buildId: string, unsignedTxCbor: string, txBodyHash: string, network: string, message: string, options?: {
38
12
  requiredSigners?: string[];
39
13
  signerTypeHint?: ExternalSignerType;
40
14
  }): UnsignedTxExportPayload;
41
- /**
42
- * Generate signing instructions for different signer types
43
- */
15
+ /** Signing instructions for the different signer types (CIP-30 request + cardano-cli recipe). */
44
16
  private generateSigningInstructions;
45
- /**
46
- * Verify a signed transaction
47
- *
48
- * Call this after receiving a signed transaction from an external signer.
49
- * This verifies the signature integrity before submission.
50
- *
51
- * @param signedTxCbor - The signed transaction CBOR
52
- * @param expectedTxBodyHash - The expected transaction body hash (from the build)
53
- * @param options - Additional verification options
54
- * @returns Verification result
55
- */
17
+ /** Verify a signed tx against the build's body hash; enforces the signing TTL when `expiresAt` is given. */
56
18
  verifySignedTransaction(signedTxCbor: string, expectedTxBodyHash: string, options?: Omit<VerificationOptions, 'expectedTxBodyHash'> & {
57
19
  expiresAt?: string;
58
20
  }): SignatureVerificationResult;
59
- /**
60
- * Verify signed transaction and throw on failure
61
- *
62
- * @param signedTxCbor - The signed transaction CBOR
63
- * @param expectedTxBodyHash - The expected transaction body hash
64
- * @param options - Additional verification options
65
- * @throws {TransactionValidationError} if verification fails
66
- */
21
+ /** Like verifySignedTransaction, but throws TransactionValidationError on failure. */
67
22
  verifyOrThrow(signedTxCbor: string, expectedTxBodyHash: string, options?: Omit<VerificationOptions, 'expectedTxBodyHash'>): SignatureVerificationResult;
68
- /**
69
- * Create a complete signing workflow state
70
- *
71
- * This creates a trackable workflow state that can be stored
72
- * and updated throughout the signing process.
73
- *
74
- * @param signingRequest - The unsigned transaction export payload
75
- * @returns Initial workflow state
76
- */
23
+ /** Initial (pending) workflow state for a signing request. */
77
24
  createWorkflowState(signingRequest: UnsignedTxExportPayload): SigningWorkflowState;
78
- /**
79
- * Update workflow state after signing
80
- *
81
- * @param state - Current workflow state
82
- * @param signedTxCbor - The signed transaction CBOR
83
- * @returns Updated workflow state
84
- */
25
+ /** Workflow state → signed. */
85
26
  markAsSigned(state: SigningWorkflowState, signedTxCbor: string): SigningWorkflowState;
86
- /**
87
- * Update workflow state after verification
88
- *
89
- * @param state - Current workflow state
90
- * @param verificationResult - The verification result
91
- * @returns Updated workflow state
92
- */
27
+ /** Workflow state → verified, or → failed when the verification result is invalid. */
93
28
  markAsVerified(state: SigningWorkflowState, verificationResult: SignatureVerificationResult): SigningWorkflowState;
94
- /**
95
- * Update workflow state after submission
96
- *
97
- * @param state - Current workflow state
98
- * @param txHash - The submitted transaction hash
99
- * @returns Updated workflow state
100
- */
29
+ /** Workflow state → submitted. */
101
30
  markAsSubmitted(state: SigningWorkflowState, txHash: string): SigningWorkflowState;
102
- /**
103
- * Update workflow state on failure
104
- *
105
- * @param state - Current workflow state
106
- * @param errorMessage - The error message
107
- * @returns Updated workflow state
108
- */
31
+ /** Workflow state → failed. */
109
32
  markAsFailed(state: SigningWorkflowState, errorMessage: string): SigningWorkflowState;
110
- /**
111
- * Check if a signing request has expired
112
- *
113
- * @param expiresAt - The expiration timestamp (ISO 8601)
114
- * @returns true if expired
115
- */
33
+ /** True when the ISO-8601 `expiresAt` lies in the past. */
116
34
  isExpired(expiresAt: string): boolean;
117
- /**
118
- * Validate a signed transaction payload before submission
119
- *
120
- * This performs all pre-submission checks:
121
- * 1. Verify the signature
122
- * 2. Check transaction hasn't been tampered with
123
- * 3. Ensure the build ID matches
124
- *
125
- * @param payload - The signed transaction payload
126
- * @param originalBuildTxBodyHash - The original transaction body hash from the build
127
- * @returns Validation result with verification details
128
- * @throws {TransactionValidationError} if validation fails
129
- */
35
+ /** Pre-submission check: signature + body-hash integrity against the build; throws TransactionValidationError. */
130
36
  validateForSubmission(payload: SignedTxPayload, originalBuildTxBodyHash: string): SignatureVerificationResult;
131
- /**
132
- * Get the signature verifier instance
133
- */
37
+ /** The underlying signature verifier. */
134
38
  getVerifier(): SignatureVerifier;
135
39
  }
136
- /**
137
- * Get the singleton ExternalSignerModule instance
138
- */
40
+ /** Singleton ExternalSignerModule. */
139
41
  export declare function getExternalSignerModule(): ExternalSignerModule;
140
- /**
141
- * Create a new ExternalSignerModule instance with custom options
142
- */
42
+ /** New ExternalSignerModule with custom options (not the singleton). */
143
43
  export declare function createExternalSignerModule(options?: {
144
44
  signingTtlMs?: number;
145
45
  }): ExternalSignerModule;