@odatano/core 2.0.0-rc.44 → 2.0.0-rc.45

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 (168) hide show
  1. package/@cds-models/CardanoAgentService/index.d.ts +0 -46
  2. package/@cds-models/CardanoBackendService/index.d.ts +0 -10
  3. package/@cds-models/CardanoIndexerService/index.d.ts +5 -20
  4. package/@cds-models/CardanoODataService/index.d.ts +18 -47
  5. package/@cds-models/CardanoSignService/index.d.ts +3 -18
  6. package/@cds-models/CardanoTransactionService/index.d.ts +9 -31
  7. package/@cds-models/CardanoWorkerService/index.d.ts +3 -19
  8. package/@cds-models/index.d.ts +17 -0
  9. package/@cds-models/index.js +2 -0
  10. package/@cds-models/odatano/cardano/index.d.ts +0 -34
  11. package/README.md +6 -6
  12. package/db/schema.cds +25 -44
  13. package/db/types.cds +22 -5
  14. package/package.json +3 -1
  15. package/scripts/migrate-slot-leader.mjs +3 -11
  16. package/scripts/migrate-txseq.mjs +3 -12
  17. package/src/index.d.ts +0 -4
  18. package/src/index.js +3 -5
  19. package/src/plugin.js +4 -8
  20. package/srv/blockchain/asset-decimals.d.ts +0 -9
  21. package/srv/blockchain/asset-decimals.js +21 -16
  22. package/srv/blockchain/backends/blockfrost-backend.d.ts +2 -10
  23. package/srv/blockchain/backends/blockfrost-backend.js +15 -21
  24. package/srv/blockchain/backends/cardano-backend.d.ts +12 -71
  25. package/srv/blockchain/backends/koios-backend.d.ts +14 -147
  26. package/srv/blockchain/backends/koios-backend.js +40 -164
  27. package/srv/blockchain/backends/odatano-backend.d.ts +1 -11
  28. package/srv/blockchain/backends/odatano-backend.js +11 -12
  29. package/srv/blockchain/backends/ogmios-backend.d.ts +13 -160
  30. package/srv/blockchain/backends/ogmios-backend.js +48 -175
  31. package/srv/blockchain/backends/ogmios-frame-guard.d.ts +2 -18
  32. package/srv/blockchain/backends/ogmios-frame-guard.js +8 -20
  33. package/srv/blockchain/cardano-client.d.ts +12 -80
  34. package/srv/blockchain/cardano-client.js +36 -88
  35. package/srv/blockchain/cardano-indexer.d.ts +12 -192
  36. package/srv/blockchain/cardano-indexer.js +126 -222
  37. package/srv/blockchain/cardano-tx-builder.d.ts +1 -28
  38. package/srv/blockchain/cardano-tx-builder.js +17 -34
  39. package/srv/blockchain/circuit-breaker.d.ts +1 -13
  40. package/srv/blockchain/circuit-breaker.js +5 -15
  41. package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +0 -5
  42. package/srv/blockchain/crawler/asset-decimals-backfill.js +2 -5
  43. package/srv/blockchain/crawler/certificate-backfill.d.ts +0 -17
  44. package/srv/blockchain/crawler/certificate-backfill.js +8 -22
  45. package/srv/blockchain/crawler/crawler.d.ts +16 -93
  46. package/srv/blockchain/crawler/crawler.js +85 -160
  47. package/srv/blockchain/crawler/credential-backfill.d.ts +0 -10
  48. package/srv/blockchain/crawler/credential-backfill.js +2 -4
  49. package/srv/blockchain/crawler/hooks.d.ts +1 -5
  50. package/srv/blockchain/crawler/index.d.ts +0 -12
  51. package/srv/blockchain/crawler/index.js +6 -20
  52. package/srv/blockchain/crawler/sync-state.d.ts +6 -44
  53. package/srv/blockchain/crawler/sync-state.js +18 -53
  54. package/srv/blockchain/crawler/transaction-backfill.d.ts +0 -11
  55. package/srv/blockchain/crawler/transaction-backfill.js +11 -30
  56. package/srv/blockchain/crawler/utxo-set-import.d.ts +1 -30
  57. package/srv/blockchain/crawler/utxo-set-import.js +27 -53
  58. package/srv/blockchain/ledger-state.d.ts +10 -54
  59. package/srv/blockchain/ledger-state.js +11 -27
  60. package/srv/blockchain/pending-spends.d.ts +0 -12
  61. package/srv/blockchain/pending-spends.js +4 -12
  62. package/srv/blockchain/request-coalescer.d.ts +2 -16
  63. package/srv/blockchain/request-coalescer.js +2 -16
  64. package/srv/blockchain/signing/cose-verifier.d.ts +0 -9
  65. package/srv/blockchain/signing/cose-verifier.js +4 -10
  66. package/srv/blockchain/signing/external-signer.d.ts +1 -4
  67. package/srv/blockchain/signing/external-signer.js +2 -8
  68. package/srv/blockchain/signing/hsm-signer.d.ts +6 -18
  69. package/srv/blockchain/signing/hsm-signer.js +16 -28
  70. package/srv/blockchain/signing/signature-verifier.d.ts +1 -8
  71. package/srv/blockchain/signing/signature-verifier.js +9 -19
  72. package/srv/blockchain/signing/submission-finalizer.d.ts +10 -16
  73. package/srv/blockchain/signing/submission-finalizer.js +48 -19
  74. package/srv/blockchain/stored-chain.d.ts +1 -14
  75. package/srv/blockchain/stored-chain.js +3 -8
  76. package/srv/blockchain/transaction-building/buildooor-fee-patch.d.ts +0 -4
  77. package/srv/blockchain/transaction-building/buildooor-fee-patch.js +4 -9
  78. package/srv/blockchain/transaction-building/buildooor-tx.d.ts +7 -150
  79. package/srv/blockchain/transaction-building/buildooor-tx.js +91 -196
  80. package/srv/blockchain/transaction-building/caller-datums.d.ts +0 -14
  81. package/srv/blockchain/transaction-building/caller-datums.js +3 -9
  82. package/srv/blockchain/transaction-building/cardano-tx.d.ts +1 -4
  83. package/srv/blockchain/wallet-worker/build-request.d.ts +0 -5
  84. package/srv/blockchain/wallet-worker/build-request.js +6 -9
  85. package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +5 -23
  86. package/srv/blockchain/wallet-worker/confirmation-tracker.js +16 -20
  87. package/srv/blockchain/wallet-worker/index.d.ts +1 -1
  88. package/srv/blockchain/wallet-worker/index.js +3 -5
  89. package/srv/blockchain/wallet-worker/job-store.d.ts +15 -65
  90. package/srv/blockchain/wallet-worker/job-store.js +0 -0
  91. package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +2 -10
  92. package/srv/blockchain/wallet-worker/lease-heartbeat.js +6 -12
  93. package/srv/blockchain/wallet-worker/signers.d.ts +3 -11
  94. package/srv/blockchain/wallet-worker/signers.js +3 -6
  95. package/srv/blockchain/wallet-worker/wallet-worker.d.ts +3 -21
  96. package/srv/blockchain/wallet-worker/wallet-worker.js +47 -54
  97. package/srv/cardano-agent-service.cds +123 -146
  98. package/srv/cardano-agent-service.js +2 -5
  99. package/srv/cardano-backend-service.cds +10 -17
  100. package/srv/cardano-backend-service.js +7 -12
  101. package/srv/cardano-indexer-service.cds +16 -37
  102. package/srv/cardano-indexer-service.d.ts +5 -1
  103. package/srv/cardano-indexer-service.js +44 -35
  104. package/srv/cardano-service.cds +56 -40
  105. package/srv/cardano-service.js +42 -69
  106. package/srv/cardano-sign-service.cds +14 -23
  107. package/srv/cardano-sign-service.js +18 -24
  108. package/srv/cardano-tx-service.cds +27 -29
  109. package/srv/cardano-tx-service.js +60 -122
  110. package/srv/cardano-worker-service.cds +109 -125
  111. package/srv/cardano-worker-service.js +21 -31
  112. package/srv/cbor/cip68.d.ts +0 -4
  113. package/srv/cbor/cip68.js +2 -4
  114. package/srv/cbor/parse.d.ts +3 -18
  115. package/srv/cbor/parse.js +2 -7
  116. package/srv/cbor/plutus-data-json.d.ts +0 -4
  117. package/srv/server.d.ts +5 -36
  118. package/srv/server.js +30 -51
  119. package/srv/utils/agent-grants-config.d.ts +0 -18
  120. package/srv/utils/agent-grants-config.js +6 -13
  121. package/srv/utils/agent-grants.d.ts +14 -68
  122. package/srv/utils/agent-grants.js +42 -60
  123. package/srv/utils/agent-token-auth.d.ts +0 -5
  124. package/srv/utils/agent-token-auth.js +2 -5
  125. package/srv/utils/backend-request-handler.d.ts +1 -1
  126. package/srv/utils/collections.d.ts +1 -4
  127. package/srv/utils/collections.js +1 -4
  128. package/srv/utils/const.d.ts +0 -18
  129. package/srv/utils/const.js +7 -18
  130. package/srv/utils/crypto.js +3 -5
  131. package/srv/utils/db-indexes.d.ts +2 -0
  132. package/srv/utils/db-indexes.js +22 -9
  133. package/srv/utils/db-sanitize.d.ts +1 -8
  134. package/srv/utils/db-sanitize.js +3 -8
  135. package/srv/utils/epoch-slots.d.ts +1 -8
  136. package/srv/utils/epoch-slots.js +3 -8
  137. package/srv/utils/error-codes.d.ts +0 -4
  138. package/srv/utils/error-codes.js +2 -4
  139. package/srv/utils/errors.d.ts +2 -22
  140. package/srv/utils/errors.js +13 -27
  141. package/srv/utils/liveness.d.ts +0 -4
  142. package/srv/utils/liveness.js +2 -4
  143. package/srv/utils/mappers.d.ts +0 -37
  144. package/srv/utils/mappers.js +19 -39
  145. package/srv/utils/network-context.js +2 -4
  146. package/srv/utils/paging.d.ts +31 -0
  147. package/srv/utils/paging.js +43 -0
  148. package/srv/utils/pg-inline-json.js +3 -7
  149. package/srv/utils/pg-order-nulls.js +2 -5
  150. package/srv/utils/plutus-placeholders.d.ts +0 -13
  151. package/srv/utils/plutus-placeholders.js +6 -13
  152. package/srv/utils/rate-limiter.d.ts +0 -8
  153. package/srv/utils/rate-limiter.js +2 -4
  154. package/srv/utils/reference-script.d.ts +0 -18
  155. package/srv/utils/reference-script.js +8 -19
  156. package/srv/utils/service-events.d.ts +0 -4
  157. package/srv/utils/service-events.js +2 -4
  158. package/srv/utils/signing-helper.d.ts +1 -8
  159. package/srv/utils/signing-helper.js +3 -8
  160. package/srv/utils/tx-build-helper.d.ts +2 -32
  161. package/srv/utils/tx-build-helper.js +26 -40
  162. package/srv/utils/tx-request-parsers.d.ts +1 -25
  163. package/srv/utils/tx-request-parsers.js +10 -25
  164. package/srv/utils/tx-utils.d.ts +0 -8
  165. package/srv/utils/tx-utils.js +10 -13
  166. package/srv/utils/types.d.ts +2 -37
  167. package/srv/utils/validators.d.ts +0 -4
  168. package/srv/utils/validators.js +2 -4
@@ -11,19 +11,12 @@ const validators_1 = require("./utils/validators");
11
11
  const wallet_worker_1 = require("./blockchain/wallet-worker");
12
12
  const job_store_1 = require("./blockchain/wallet-worker/job-store");
13
13
  const server_1 = require("./server");
14
+ const CardanoWorkerService_1 = require("#cds-models/CardanoWorkerService");
14
15
  const logger = cds_1.default.log('CardanoWorkerService');
15
- /**
16
- * CardanoWorkerService handlers: control surface over the wallet-worker singleton
17
- * (srv/blockchain/wallet-worker). Validates inputs, inserts/reads job rows, starts/stops
18
- * the worker. The job INSERT runs on the request's ambient transaction.
19
- */
20
16
  function isAdmin(req) {
21
17
  return req.user?.is?.('Admin') ?? false;
22
18
  }
23
- /**
24
- * HSM-backed wallets inherit the SignWithHsm role gate (enforceHsmRole in the sign service).
25
- * Returns the role the caller is missing, or null when not HSM-backed, no role configured, or held.
26
- */
19
+ /** The HSM role a caller lacks for an HSM-backed wallet, the same gate SignWithHsm applies; null when none is missing. */
27
20
  function missingHsmRole(req, signerType) {
28
21
  if (signerType !== 'hsm')
29
22
  return null;
@@ -48,23 +41,21 @@ function toJobStatus(job) {
48
41
  finishedAt: job.finishedAt,
49
42
  };
50
43
  }
44
+ /** CardanoWorkerService handlers: job submission and status, worker control. */
51
45
  module.exports = (srv) => {
52
- // SubmitWalletJob — queue an async transaction job; returns the jobId immediately.
53
- srv.on('SubmitWalletJob', async (req) => {
46
+ // SubmitWalletJob: queue an async transaction job; returns the jobId immediately.
47
+ srv.on(CardanoWorkerService_1.SubmitWalletJob, async (req) => {
54
48
  const { walletId, kind, requestJson, idempotencyKey, priority, notBefore } = req.data;
55
49
  if (!walletId?.trim())
56
50
  return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', 'walletId is required', 'walletId');
57
- if (!kind || !job_store_1.WALLET_JOB_KINDS.includes(kind)) {
58
- return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', `Invalid kind "${String(kind)}" — must be one of: ${job_store_1.WALLET_JOB_KINDS.join(', ')}`, 'kind');
59
- }
51
+ // the model rejects an unknown kind and a priority outside 0..10000
52
+ if (!kind)
53
+ return (0, errors_1.rejectMissing)(req, 'SubmitWalletJob', 'kind');
60
54
  if (!requestJson?.trim())
61
55
  return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', 'requestJson is required', 'requestJson');
62
56
  const jsonResult = (0, validators_1.validateJsonWithLimits)(requestJson, 'requestJson');
63
57
  if (!jsonResult.valid)
64
58
  return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', jsonResult.error, 'requestJson');
65
- if (priority != null && (!Number.isInteger(priority) || priority < 0 || priority > 10_000)) {
66
- return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', 'priority must be an integer between 0 and 10000', 'priority');
67
- }
68
59
  if (notBefore != null && Number.isNaN(Date.parse(String(notBefore)))) {
69
60
  return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', 'notBefore must be a valid timestamp', 'notBefore');
70
61
  }
@@ -79,7 +70,7 @@ module.exports = (srv) => {
79
70
  return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', err instanceof Error ? err.message : String(err));
80
71
  }
81
72
  if (!config.enabled) {
82
- return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', 'Wallet worker is not enabled — set cds.requires.odatano-core.walletWorker.enabled (or WALLET_WORKER_ENABLED=true) with configured wallets.');
73
+ return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', 'Wallet worker is not enabled: set cds.requires.odatano-core.walletWorker.enabled (or WALLET_WORKER_ENABLED=true) with configured wallets.');
83
74
  }
84
75
  // Role gate on this instance's config, mirroring the sign service's 403.
85
76
  const configuredRole = missingHsmRole(req, config.wallets.find((w) => w.walletId === walletId)?.signerType);
@@ -89,7 +80,7 @@ module.exports = (srv) => {
89
80
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
90
81
  const wallet = await (0, job_store_1.readWallet)(db, walletId);
91
82
  if (!wallet)
92
- return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', `Unknown wallet "${walletId}" — configured wallets are registered at worker start`, 'walletId');
83
+ return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', `Unknown wallet "${walletId}": configured wallets are registered at worker start`, 'walletId');
93
84
  if (!wallet.enabled)
94
85
  return (0, errors_1.rejectInvalid)(req, 'SubmitWalletJob', `Wallet "${walletId}" is disabled`, 'walletId');
95
86
  // Registered row too: another instance may run the HSM wallet this one has no config for.
@@ -102,7 +93,7 @@ module.exports = (srv) => {
102
93
  kind: kind,
103
94
  request: requestJson,
104
95
  idempotencyKey: idempotencyKey ?? null,
105
- priority,
96
+ priority: priority ?? undefined,
106
97
  notBefore: notBefore ? new Date(notBefore).toISOString() : null,
107
98
  maxAttempts: config.defaultMaxAttempts,
108
99
  createdBy: req.user?.id ?? null,
@@ -111,8 +102,8 @@ module.exports = (srv) => {
111
102
  return result;
112
103
  });
113
104
  });
114
- // CancelJob — pending jobs only; scoped to the creator unless Admin.
115
- srv.on('CancelJob', async (req) => {
105
+ // CancelJob: pending jobs only; scoped to the creator unless Admin.
106
+ srv.on(CardanoWorkerService_1.CancelJob, async (req) => {
116
107
  const { jobId } = req.data;
117
108
  if (!jobId)
118
109
  return (0, errors_1.rejectInvalid)(req, 'CancelJob', 'jobId is required', 'jobId');
@@ -125,13 +116,13 @@ module.exports = (srv) => {
125
116
  }
126
117
  const cancelled = await (0, job_store_1.markCancelled)(db, jobId);
127
118
  if (!cancelled) {
128
- return (0, errors_1.rejectInvalid)(req, 'CancelJob', `Job ${jobId} is ${job.status} — only pending jobs can be cancelled`, 'jobId');
119
+ return (0, errors_1.rejectInvalid)(req, 'CancelJob', `Job ${jobId} is ${job.status}: only pending jobs can be cancelled`, 'jobId');
129
120
  }
130
121
  return true;
131
122
  });
132
123
  });
133
- // GetJobStatus — scoped to the creator unless Admin.
134
- srv.on('GetJobStatus', async (req) => {
124
+ // GetJobStatus: scoped to the creator unless Admin.
125
+ srv.on(CardanoWorkerService_1.GetJobStatus, async (req) => {
135
126
  const { jobId } = req.data;
136
127
  if (!jobId)
137
128
  return (0, errors_1.rejectInvalid)(req, 'GetJobStatus', 'jobId is required', 'jobId');
@@ -143,18 +134,17 @@ module.exports = (srv) => {
143
134
  return toJobStatus(job);
144
135
  });
145
136
  });
146
- // GetWorkerStatus — live summary of the local worker instance.
137
+ // GetWorkerStatus: live summary of the local worker instance.
147
138
  srv.on('GetWorkerStatus', async (req) => {
148
139
  return (0, backend_request_handler_1.handleRequest)(req, async (db) => {
149
140
  const worker = (0, wallet_worker_1.getWalletWorker)();
150
141
  const summary = worker?.getStatusSummary() ?? {
151
142
  running: false, wallets: [], executing: [], awaitingConfirmation: 0,
152
143
  };
153
- const pending = await (0, job_store_1.findDueJobs)(db, new Date(8640000000000000)); // all pending, ignore notBefore
154
- return { ...summary, pendingJobs: pending.length };
144
+ return { ...summary, pendingJobs: await (0, job_store_1.countPendingJobs)(db) };
155
145
  });
156
146
  });
157
- // PauseWorker — stop the local instance; queued jobs stay pending.
147
+ // PauseWorker: stop the local instance; queued jobs stay pending.
158
148
  srv.on('PauseWorker', async (req) => {
159
149
  return (0, backend_request_handler_1.handleRequest)(req, async () => {
160
150
  await (0, wallet_worker_1.stopWalletWorker)();
@@ -162,7 +152,7 @@ module.exports = (srv) => {
162
152
  return true;
163
153
  });
164
154
  });
165
- // ResumeWorker — (re)start the local instance from config. Gated on enabled,
155
+ // ResumeWorker: (re)start the local instance from config. Gated on enabled,
166
156
  // mirroring resumeCrawler.
167
157
  srv.on('ResumeWorker', async (req) => {
168
158
  let config;
@@ -173,7 +163,7 @@ module.exports = (srv) => {
173
163
  return (0, errors_1.rejectInvalid)(req, 'ResumeWorker', err instanceof Error ? err.message : String(err));
174
164
  }
175
165
  if (!config.enabled) {
176
- return (0, errors_1.rejectInvalid)(req, 'ResumeWorker', 'Wallet worker is not enabled — set cds.requires.odatano-core.walletWorker.enabled (or WALLET_WORKER_ENABLED=true) before resuming.');
166
+ return (0, errors_1.rejectInvalid)(req, 'ResumeWorker', 'Wallet worker is not enabled: set cds.requires.odatano-core.walletWorker.enabled (or WALLET_WORKER_ENABLED=true) before resuming.');
177
167
  }
178
168
  return (0, backend_request_handler_1.handleRequest)(req, async () => {
179
169
  const client = (0, server_1.getCardanoClient)();
@@ -9,9 +9,5 @@ export declare const CIP68_LABEL: {
9
9
  export declare function cip68ReferenceUnit(unit: string): string | null;
10
10
  /** The label-333 and label-444 units a CIP-68 reference NFT describes; null for any other unit. */
11
11
  export declare function cip68UserUnits(referenceUnit: string): string[] | null;
12
- /**
13
- * `decimals` of a CIP-68 reference datum: Constr 0 whose first field is the metadata map, keyed
14
- * by UTF-8 byte strings. null when the datum has no such integer in 0..255 or is not that shape.
15
- */
16
12
  export declare function cip68DecimalsFromDatum(cborHex: string): number | null;
17
13
  //# sourceMappingURL=cip68.d.ts.map
package/srv/cbor/cip68.js CHANGED
@@ -28,10 +28,8 @@ function cip68UserUnits(referenceUnit) {
28
28
  return USER_LABELS_WITH_DECIMALS.map((label) => referenceUnit.slice(0, 56) + label + referenceUnit.slice(64));
29
29
  }
30
30
  const DECIMALS_KEY = Buffer.from('decimals');
31
- /**
32
- * `decimals` of a CIP-68 reference datum: Constr 0 whose first field is the metadata map, keyed
33
- * by UTF-8 byte strings. null when the datum has no such integer in 0..255 or is not that shape.
34
- */
31
+ // The datum is Constr 0 with the metadata map, keyed by UTF-8 bytes, as first field.
32
+ // Null when the shape differs or decimals is not an integer in 0..255.
35
33
  function cip68DecimalsFromDatum(cborHex) {
36
34
  let data;
37
35
  try {
@@ -5,7 +5,7 @@ export interface ParsedInput {
5
5
  export interface ParsedAsset {
6
6
  /** `"policyIdHex" + "assetNameHex"` (concatenated, no separator). */
7
7
  unit: string;
8
- /** Signed decimal string — negative for burns in `mint`, always non-negative in outputs. */
8
+ /** Signed decimal string; negative for burns in `mint`, never negative in outputs. */
9
9
  quantity: string;
10
10
  }
11
11
  export interface ParsedOutput {
@@ -37,16 +37,8 @@ export interface ParsedWitnesses {
37
37
  redeemers: number;
38
38
  }
39
39
  export interface ParsedTransaction {
40
- /**
41
- * Blake2b-256 hash of the transaction body. Stable across signed/unsigned
42
- * CBOR — signing adds witnesses without changing the body hash.
43
- */
40
+ /** Blake2b-256 of the body. Signing adds witnesses, so the hash stays the same. */
44
41
  txHash: string;
45
- /**
46
- * `"mainnet"` or `"testnet"` when the body carries a network ID byte, else
47
- * `null`. Preview vs preprod cannot be distinguished from CBOR alone; a
48
- * consumer needing that split must compare against the service network.
49
- */
50
42
  network: 'mainnet' | 'testnet' | null;
51
43
  /** Body field 15: 1 = mainnet, 0 = testnet, null if absent. */
52
44
  networkId: number | null;
@@ -58,7 +50,7 @@ export interface ParsedTransaction {
58
50
  validityEnd: string | null;
59
51
  /** Fee in lovelace (decimal string). */
60
52
  fee: string;
61
- /** Native-asset mint/burn entries; quantities are signed. */
53
+ /** Native-asset mint and burn entries; quantities are signed. */
62
54
  mint: ParsedAsset[];
63
55
  /** Metadata labels present (uint64 → decimal string); full payload via GetMetadataByTxHash for submitted txs. */
64
56
  metadataLabels: string[];
@@ -80,12 +72,5 @@ export interface ParsedTransaction {
80
72
  isValid: boolean;
81
73
  witnesses: ParsedWitnesses;
82
74
  }
83
- /**
84
- * Parse hex-encoded Cardano transaction CBOR (signed or unsigned) into structured
85
- * fields. Pure function — no network call, no DB write. Callers are responsible
86
- * for upstream size/format validation via `isValidTxCborHex`.
87
- *
88
- * @throws TransactionValidationError with code `TX_PARSE_FAILED` on malformed CBOR.
89
- */
90
75
  export declare function parseTransaction(cborHex: string): ParsedTransaction;
91
76
  //# sourceMappingURL=parse.d.ts.map
package/srv/cbor/parse.js CHANGED
@@ -6,13 +6,8 @@ const cardano_ledger_ts_1 = require("@harmoniclabs/cardano-ledger-ts");
6
6
  const cbor_1 = require("@harmoniclabs/cbor");
7
7
  const errors_1 = require("../utils/errors");
8
8
  const error_codes_1 = require("../utils/error-codes");
9
- /**
10
- * Parse hex-encoded Cardano transaction CBOR (signed or unsigned) into structured
11
- * fields. Pure function — no network call, no DB write. Callers are responsible
12
- * for upstream size/format validation via `isValidTxCborHex`.
13
- *
14
- * @throws TransactionValidationError with code `TX_PARSE_FAILED` on malformed CBOR.
15
- */
9
+ // Pure, no network call. Callers validate size and format with `isValidTxCborHex` first.
10
+ // Throws TX_PARSE_FAILED on malformed CBOR.
16
11
  function parseTransaction(cborHex) {
17
12
  let tx;
18
13
  let raw;
@@ -1,8 +1,4 @@
1
1
  import { type Data } from '@harmoniclabs/plutus-data';
2
- /**
3
- * PlutusData as cardano-cli DetailedSchema JSON, the shape the build actions accept as
4
- * outputDatumJson. Integers beyond the safe JS range are decimal strings so no digit is lost.
5
- */
6
2
  export type PlutusDataJson = {
7
3
  constructor: number;
8
4
  fields: PlutusDataJson[];
package/srv/server.d.ts CHANGED
@@ -12,60 +12,29 @@ interface AppContext {
12
12
  }
13
13
  /** Agent-grant feature switch; its own module so src/plugin.ts can read it at load. */
14
14
  export { loadAgentGrantsConfig, activateAgentGrants } from './utils/agent-grants-config';
15
- /**
16
- * The application context.
17
- * @throws {ProviderUnavailableError} 503 when uninitialized; a bootstrap failure is appended as cause.
18
- */
15
+ /** Throws 503 when uninitialized, with a bootstrap failure appended as cause. */
19
16
  export declare function getAppContext(): AppContext;
20
17
  export declare function getCardanoIndexer(): CardanoIndexer;
21
18
  export declare function getCardanoClient(): CardanoClient;
22
19
  export declare function getCardanoTxBuilder(): CardanoTransactionBuilder;
23
20
  /** HSM configuration when enabled; the sign service reads requiresRole from it. */
24
21
  export declare function getHsmConfig(): HsmConfig | undefined;
25
- /**
26
- * Initialize from a pre-built config (plugin path). Idempotent: a second call must not
27
- * create a duplicate CardanoClient; tests reinitialize via resetAppContext() / createTestContext().
28
- */
29
22
  export declare function initializeFromConfig(config: CardanoClientConfig, protocolParams?: LedgerProtocolParameters, hsmConfig?: HsmConfig): Promise<void>;
30
23
  /** Reset the application context (tests only); lets tests inject their own instances. */
31
24
  export declare function resetAppContext(context: AppContext | null): void;
32
- /**
33
- * Create an isolated test context with the given backends.
34
- * @param _txBuilderName ignored; Buildooor is the sole builder (kept for signature compatibility)
35
- * @param protocolParams optional, skips the backend call during init
36
- */
37
25
  export declare function createTestContext(backends: BackendName[], _txBuilderName?: TransactionBuilderName, protocolParams?: LedgerProtocolParameters): Promise<AppContext>;
38
- /** Stop worker and crawler, then close all backend connections. */
26
+ /** Stop worker and crawler, then close all backend connections. Concurrent callers share one run. */
39
27
  export declare function shutdownAppContext(): Promise<void>;
40
- /**
41
- * Load and validate CardanoClientConfig.
42
- * Priority: cds.env.requires["odatano-core"].X > process.env.X > default.
43
- * @throws {ConfigError} if any value is invalid
44
- */
45
28
  export declare function loadConfigFromEnv(): CardanoClientConfig;
46
- /**
47
- * Load the HSM configuration (cds.requires.odatano-core.hsm.* or HSM_* env vars).
48
- * Returns undefined when HSM is not enabled.
49
- */
29
+ /** From cds.requires.odatano-core.hsm or HSM_* env vars. Undefined when HSM is off. */
50
30
  export declare function loadHsmConfigFromEnv(): HsmConfig | undefined;
51
- /**
52
- * Load the chain-crawler configuration (cds.requires.odatano-core.crawler.* or CRAWLER_* env vars).
53
- * Returns { enabled: false } when the crawler is off (the default).
54
- */
31
+ /** From cds.requires.odatano-core.crawler or CRAWLER_* env vars. Off by default. */
55
32
  export declare function loadCrawlerConfigFromEnv(): CrawlerConfig;
56
33
  /** Start the crawler if enabled and the app context is ready. Never throws; idempotent. */
57
34
  export declare function startCrawlerIfConfigured(): Promise<void>;
58
- /**
59
- * Load the wallet-worker configuration (cds.requires.odatano-core.walletWorker.* or WALLET_WORKER_* env vars).
60
- * Returns { enabled: false } when the worker is off (the default).
61
- */
35
+ /** From cds.requires.odatano-core.walletWorker or WALLET_WORKER_* env vars. Off by default. */
62
36
  export declare function loadWalletWorkerConfigFromEnv(): WalletWorkerConfig;
63
37
  /** Start the wallet worker if enabled and the app context is ready. Never throws; idempotent. */
64
38
  export declare function startWalletWorkerIfConfigured(): Promise<void>;
65
- /**
66
- * Re-drive deferred submissions claimed as 'submitting' whose detached submit never ran
67
- * (process died first). Idempotent: an already submitted tx finalizes via
68
- * TransactionAlreadySubmittedError. Never throws.
69
- */
70
39
  export declare function redriveInterruptedSubmissionsIfConfigured(): Promise<void>;
71
40
  //# sourceMappingURL=server.d.ts.map
package/srv/server.js CHANGED
@@ -76,10 +76,7 @@ function crawlerInteger(raw, name, min, max, defaultValue) {
76
76
  }
77
77
  let appContext = null;
78
78
  let bootstrapError = null;
79
- /**
80
- * Initialize the application context; every start path (standalone hook, plugin) comes through here.
81
- * @param protocolParams - optional, lets tests skip the backend call
82
- */
79
+ /** Every start path, standalone hook and plugin, comes through here. */
83
80
  async function initializeAppContext(config, protocolParams, hsmConfig) {
84
81
  logger.debug('Initializing blockchain components...');
85
82
  // Database first. Postgres ORDER BY without a NULLS clause on key / NOT NULL columns so
@@ -130,10 +127,7 @@ Object.defineProperty(exports, "activateAgentGrants", { enumerable: true, get: f
130
127
  // (bin/serve.js imports this file before the middlewares exist). Idempotent.
131
128
  (0, agent_grants_config_1.activateAgentGrants)();
132
129
  (0, legacy_service_paths_1.registerLegacyServicePaths)();
133
- /**
134
- * The application context.
135
- * @throws {ProviderUnavailableError} 503 when uninitialized; a bootstrap failure is appended as cause.
136
- */
130
+ /** Throws 503 when uninitialized, with a bootstrap failure appended as cause. */
137
131
  function getAppContext() {
138
132
  if (!appContext) {
139
133
  const base = 'Application not initialized. This should be called after cds.served event.';
@@ -158,10 +152,8 @@ let hsmConfigInstance;
158
152
  function getHsmConfig() {
159
153
  return hsmConfigInstance;
160
154
  }
161
- /**
162
- * Initialize from a pre-built config (plugin path). Idempotent: a second call must not
163
- * create a duplicate CardanoClient; tests reinitialize via resetAppContext() / createTestContext().
164
- */
155
+ // Plugin path. Idempotent, so a second call never creates a duplicate CardanoClient.
156
+ // Tests reinitialize with resetAppContext() or createTestContext().
165
157
  async function initializeFromConfig(config, protocolParams, hsmConfig) {
166
158
  if (appContext) {
167
159
  logger.debug('initializeFromConfig: appContext already initialized, skipping');
@@ -188,11 +180,8 @@ function resetAppContext(context) {
188
180
  (0, network_context_1.setActiveNetwork)(context?.cardanoClient.network ?? null);
189
181
  logger.debug('Application context reset');
190
182
  }
191
- /**
192
- * Create an isolated test context with the given backends.
193
- * @param _txBuilderName ignored; Buildooor is the sole builder (kept for signature compatibility)
194
- * @param protocolParams optional, skips the backend call during init
195
- */
183
+ // Isolated test context with the given backends.
184
+ // _txBuilderName is ignored and kept for signature compatibility.
196
185
  async function createTestContext(backends, _txBuilderName = 'buildooor', protocolParams) {
197
186
  const config = {
198
187
  network: process_1.env.NETWORK || 'preview',
@@ -210,8 +199,13 @@ async function createTestContext(backends, _txBuilderName = 'buildooor', protoco
210
199
  };
211
200
  return await initializeAppContext(config, protocolParams);
212
201
  }
213
- /** Stop worker and crawler, then close all backend connections. */
214
- async function shutdownAppContext() {
202
+ let shutdownInFlight = null;
203
+ /** Stop worker and crawler, then close all backend connections. Concurrent callers share one run. */
204
+ function shutdownAppContext() {
205
+ shutdownInFlight ??= runShutdown().finally(() => { shutdownInFlight = null; });
206
+ return shutdownInFlight;
207
+ }
208
+ async function runShutdown() {
215
209
  // Worker and crawler first: their in-flight writes must not hit a torn-down client.
216
210
  try {
217
211
  await (0, wallet_worker_1.stopWalletWorker)();
@@ -238,11 +232,8 @@ async function shutdownAppContext() {
238
232
  (0, network_context_1.setActiveNetwork)(null);
239
233
  }
240
234
  }
241
- /**
242
- * Load and validate CardanoClientConfig.
243
- * Priority: cds.env.requires["odatano-core"].X > process.env.X > default.
244
- * @throws {ConfigError} if any value is invalid
245
- */
235
+ // cds.env.requires["odatano-core"] wins over process.env, which wins over the default.
236
+ // Throws ConfigError for an invalid value.
246
237
  function loadConfigFromEnv() {
247
238
  const cdsConfig = coreCdsConfig();
248
239
  const network = (cdsConfig.network || process_1.env.NETWORK || 'preview');
@@ -317,10 +308,7 @@ function loadConfigFromEnv() {
317
308
  indexTtlMs: Number(cdsConfig.indexTtlMs ?? process_1.env.INDEX_TTL_MS) || 3600000,
318
309
  };
319
310
  }
320
- /**
321
- * Load the HSM configuration (cds.requires.odatano-core.hsm.* or HSM_* env vars).
322
- * Returns undefined when HSM is not enabled.
323
- */
311
+ /** From cds.requires.odatano-core.hsm or HSM_* env vars. Undefined when HSM is off. */
324
312
  function loadHsmConfigFromEnv() {
325
313
  const cdsConfig = coreCdsConfig();
326
314
  const hsmCds = cdsConfig.hsm ?? {};
@@ -337,12 +325,12 @@ function loadHsmConfigFromEnv() {
337
325
  }
338
326
  const slot = Number(hsmCds.slot ?? process_1.env.HSM_SLOT ?? 0);
339
327
  if (!Number.isInteger(slot) || slot < 0) {
340
- throw new errors_1.ConfigError(`Invalid HSM slot: "${hsmCds.slot ?? process_1.env.HSM_SLOT}" — must be a non-negative integer`);
328
+ throw new errors_1.ConfigError(`Invalid HSM slot: "${hsmCds.slot ?? process_1.env.HSM_SLOT}": must be a non-negative integer`);
341
329
  }
342
330
  // Fail closed: the HSM holds a real signing key, so an explicit role gate is mandatory.
343
331
  const requiresRole = hsmCds.requiresRole || process_1.env.HSM_REQUIRES_ROLE || '';
344
332
  if (!requiresRole) {
345
- throw new errors_1.ConfigError('HSM_REQUIRES_ROLE (or cds.requires.odatano-core.hsm.requiresRole) is required when HSM is enabled — set it to the XSUAA scope name allowed to invoke HSM signing actions');
333
+ throw new errors_1.ConfigError('HSM_REQUIRES_ROLE (or cds.requires.odatano-core.hsm.requiresRole) is required when HSM is enabled. Set it to the XSUAA scope name allowed to invoke HSM signing actions');
346
334
  }
347
335
  return {
348
336
  enabled: true,
@@ -354,10 +342,7 @@ function loadHsmConfigFromEnv() {
354
342
  requiresRole,
355
343
  };
356
344
  }
357
- /**
358
- * Load the chain-crawler configuration (cds.requires.odatano-core.crawler.* or CRAWLER_* env vars).
359
- * Returns { enabled: false } when the crawler is off (the default).
360
- */
345
+ /** From cds.requires.odatano-core.crawler or CRAWLER_* env vars. Off by default. */
361
346
  function loadCrawlerConfigFromEnv() {
362
347
  const cdsConfig = coreCdsConfig();
363
348
  const c = cdsConfig.crawler ?? {};
@@ -382,7 +367,7 @@ function loadCrawlerConfigFromEnv() {
382
367
  const confirmationDepth = crawlerInteger(c.confirmationDepth ?? process_1.env.CRAWLER_CONFIRMATION_DEPTH, 'CRAWLER_CONFIRMATION_DEPTH', CRAWLER_LIMITS.confirmationDepth.min, CRAWLER_LIMITS.confirmationDepth.max, 3);
383
368
  const pollIntervalMs = crawlerInteger(c.pollIntervalMs ?? process_1.env.CRAWLER_POLL_INTERVAL_MS, 'CRAWLER_POLL_INTERVAL_MS', CRAWLER_LIMITS.pollIntervalMs.min, CRAWLER_LIMITS.pollIntervalMs.max, 20_000);
384
369
  if (enabled && (startSlot == null || Number.isNaN(startSlot) || !startBlockHash)) {
385
- throw new errors_1.ConfigError('Crawler is enabled but no start block is configured — set crawler.startSlot + crawler.startBlockHash ' +
370
+ throw new errors_1.ConfigError('Crawler is enabled but no start block is configured. Set crawler.startSlot + crawler.startBlockHash ' +
386
371
  '(or CRAWLER_START_SLOT + CRAWLER_START_HASH).');
387
372
  }
388
373
  if (!['ogmios', 'pagination', 'auto'].includes(source)) {
@@ -417,7 +402,7 @@ async function startCrawlerIfConfigured() {
417
402
  config = loadCrawlerConfigFromEnv();
418
403
  }
419
404
  catch (err) {
420
- logger.error('Invalid crawler configuration — crawler not started:', err);
405
+ logger.error('Invalid crawler configuration, crawler not started:', err);
421
406
  return;
422
407
  }
423
408
  if (!config.enabled)
@@ -442,10 +427,7 @@ const WALLET_WORKER_LIMITS = {
442
427
  pollIntervalMs: { min: 500, max: 3_600_000 },
443
428
  maxAttempts: { min: 1, max: 10 },
444
429
  };
445
- /**
446
- * Load the wallet-worker configuration (cds.requires.odatano-core.walletWorker.* or WALLET_WORKER_* env vars).
447
- * Returns { enabled: false } when the worker is off (the default).
448
- */
430
+ /** From cds.requires.odatano-core.walletWorker or WALLET_WORKER_* env vars. Off by default. */
449
431
  function loadWalletWorkerConfigFromEnv() {
450
432
  const cdsConfig = coreCdsConfig();
451
433
  const w = cdsConfig.walletWorker ?? {};
@@ -463,19 +445,19 @@ function loadWalletWorkerConfigFromEnv() {
463
445
  walletsRaw = JSON.parse(process_1.env.WALLET_WORKER_WALLETS);
464
446
  }
465
447
  catch {
466
- throw new errors_1.ConfigError('Invalid WALLET_WORKER_WALLETS — must be a JSON array of { walletId, signerType, keyEnv? }.');
448
+ throw new errors_1.ConfigError('Invalid WALLET_WORKER_WALLETS: must be a JSON array of { walletId, signerType, keyEnv? }.');
467
449
  }
468
450
  }
469
451
  const wallets = [];
470
452
  if (walletsRaw !== undefined) {
471
453
  if (!Array.isArray(walletsRaw)) {
472
- throw new errors_1.ConfigError('Invalid walletWorker.wallets — must be an array of { walletId, signerType, keyEnv? }.');
454
+ throw new errors_1.ConfigError('Invalid walletWorker.wallets: must be an array of { walletId, signerType, keyEnv? }.');
473
455
  }
474
456
  for (const entry of walletsRaw) {
475
457
  const walletId = typeof entry?.walletId === 'string' ? entry.walletId.trim() : '';
476
458
  const signerType = entry?.signerType;
477
459
  if (!walletId || (signerType !== 'hsm' && signerType !== 'software')) {
478
- throw new errors_1.ConfigError(`Invalid wallet entry ${JSON.stringify(entry)} — walletId and signerType (hsm|software) are required.`);
460
+ throw new errors_1.ConfigError(`Invalid wallet entry ${JSON.stringify(entry)}: walletId and signerType (hsm|software) are required.`);
479
461
  }
480
462
  if (signerType === 'software' && (typeof entry.keyEnv !== 'string' || !entry.keyEnv.trim())) {
481
463
  throw new errors_1.ConfigError(`Wallet "${walletId}" is signerType=software but has no keyEnv (name of the env var holding the signing key).`);
@@ -500,7 +482,7 @@ function loadWalletWorkerConfigFromEnv() {
500
482
  throw new errors_1.ConfigError(`Invalid WALLET_WORKER_RESUBMIT_ON_ROLLBACK "${String(resubmitRaw)}". Must be true or false.`);
501
483
  }
502
484
  if (enabled && wallets.length === 0) {
503
- throw new errors_1.ConfigError('Wallet worker is enabled but no wallets are configured — set walletWorker.wallets (or WALLET_WORKER_WALLETS).');
485
+ throw new errors_1.ConfigError('Wallet worker is enabled but no wallets are configured. Set walletWorker.wallets (or WALLET_WORKER_WALLETS).');
504
486
  }
505
487
  return {
506
488
  enabled,
@@ -522,7 +504,7 @@ async function startWalletWorkerIfConfigured() {
522
504
  config = loadWalletWorkerConfigFromEnv();
523
505
  }
524
506
  catch (err) {
525
- logger.error('Invalid wallet-worker configuration — worker not started:', err);
507
+ logger.error('Invalid wallet-worker configuration, worker not started:', err);
526
508
  return;
527
509
  }
528
510
  if (!config.enabled)
@@ -540,11 +522,8 @@ async function startWalletWorkerIfConfigured() {
540
522
  logger.error('Failed to start wallet worker (non-fatal):', err);
541
523
  }
542
524
  }
543
- /**
544
- * Re-drive deferred submissions claimed as 'submitting' whose detached submit never ran
545
- * (process died first). Idempotent: an already submitted tx finalizes via
546
- * TransactionAlreadySubmittedError. Never throws.
547
- */
525
+ // Retries submissions left in 'submitting' because the process died first. Idempotent,
526
+ // because an already submitted tx finalizes on TransactionAlreadySubmittedError. Never throws.
548
527
  async function redriveInterruptedSubmissionsIfConfigured() {
549
528
  if (process_1.env.SKIP_AUTO_INIT === 'true' || !appContext)
550
529
  return;
@@ -586,7 +565,7 @@ cds_1.default.on('served', async () => {
586
565
  // stderr directly: the cause stays visible when a test runner silences console.error.
587
566
  const where = config ? `backends={${config.backends.join(',')}} network=${config.network}` : 'config load';
588
567
  const msg = err instanceof Error ? `${err.name}: ${err.message}\n${err.stack ?? ''}` : String(err);
589
- process.stderr.write(`[ODATANO] Failed to initialize blockchain components — ${where}\n${msg}\n`);
568
+ process.stderr.write(`[ODATANO] Failed to initialize blockchain components: ${where}\n${msg}\n`);
590
569
  logger.error('Failed to initialize blockchain components:', err);
591
570
  }
592
571
  // Optional subsystems; each is non-fatal.
@@ -1,8 +1,3 @@
1
- /**
2
- * Agent-grant feature switch from `cds.requires.odatano-core.agentGrants`, else the environment
3
- * (AGENT_GRANTS_ENABLED, AGENT_GRANTS_DELEGATE, AGENT_GRANT_ADMIN_RATE_LIMIT). Own module because
4
- * src/plugin.ts reads it at plugin load, before any blockchain module is required.
5
- */
6
1
  export interface AgentGrantsConfig {
7
2
  enabled: boolean;
8
3
  /** CAP auth kind the transport middleware delegates to for non-token requests. */
@@ -12,26 +7,13 @@ export interface AgentGrantsConfig {
12
7
  }
13
8
  export declare const AGENT_GRANTS_DELEGATES: readonly string[];
14
9
  export declare const AGENT_GRANT_ADMIN_RATE_LIMIT_DEFAULT = 10;
15
- /**
16
- * Grant-administration calls per principal per hour: `agentGrants.adminRateLimit`, then
17
- * `AGENT_GRANT_ADMIN_RATE_LIMIT`, default 10. An unusable value is logged and falls back, never disables the feature.
18
- */
19
10
  export declare function loadGrantAdminRateLimit(env?: Record<string, string | undefined>): number;
20
11
  export declare const AGENT_TOKEN_CACHE_MS_DEFAULT = 10000;
21
- /**
22
- * How long the transport lane reuses a resolved grant row before re-reading the DB: `agentGrants.tokenCacheMs`,
23
- * then `AGENT_TOKEN_CACHE_MS`, default 10 s, 0 disables. Bounds how late a revoke on another replica takes effect.
24
- */
25
12
  export declare function loadTokenCacheMs(env?: Record<string, string | undefined>): number;
26
13
  /** The configured `cds.requires.auth` as an object (the shorthand `"auth": "xsuaa"` is a string). */
27
14
  export declare function configuredAuth(): Record<string, unknown>;
28
15
  /** A host-configured custom `cds.requires.auth.impl` (not this package's middleware); the lane wraps it. */
29
16
  export declare function customAuthImpl(auth?: Record<string, unknown>): string | null;
30
17
  export declare function loadAgentGrantsConfig(env?: Record<string, string | undefined>): AgentGrantsConfig;
31
- /**
32
- * Switch agent grants on when configured: installs @odatano/cap-auth with the `x-agent-token` lane
33
- * (previous strategy kept as delegate) and attaches the enforcement hook to each service on `serving`.
34
- * Called from src/plugin.ts and srv/server.ts, before cds.server() builds middlewares. Never throws.
35
- */
36
18
  export declare function activateAgentGrants(): boolean;
37
19
  //# sourceMappingURL=agent-grants-config.d.ts.map
@@ -13,10 +13,8 @@ exports.activateAgentGrants = activateAgentGrants;
13
13
  const cds_1 = __importDefault(require("@sap/cds"));
14
14
  exports.AGENT_GRANTS_DELEGATES = ['mocked', 'basic', 'jwt', 'xsuaa', 'ias', 'dummy'];
15
15
  exports.AGENT_GRANT_ADMIN_RATE_LIMIT_DEFAULT = 10;
16
- /**
17
- * Grant-administration calls per principal per hour: `agentGrants.adminRateLimit`, then
18
- * `AGENT_GRANT_ADMIN_RATE_LIMIT`, default 10. An unusable value is logged and falls back, never disables the feature.
19
- */
16
+ // Grant administration calls per principal per hour. An invalid value logs a warning
17
+ // and falls back to the default. It never disables the feature.
20
18
  function loadGrantAdminRateLimit(env = process.env) {
21
19
  const cfg = envRecord();
22
20
  const raw = cfg.adminRateLimit !== undefined ? cfg.adminRateLimit : env.AGENT_GRANT_ADMIN_RATE_LIMIT;
@@ -30,10 +28,8 @@ function loadGrantAdminRateLimit(env = process.env) {
30
28
  return n;
31
29
  }
32
30
  exports.AGENT_TOKEN_CACHE_MS_DEFAULT = 10_000;
33
- /**
34
- * How long the transport lane reuses a resolved grant row before re-reading the DB: `agentGrants.tokenCacheMs`,
35
- * then `AGENT_TOKEN_CACHE_MS`, default 10 s, 0 disables. Bounds how late a revoke on another replica takes effect.
36
- */
31
+ // How long a resolved grant row is reused before the DB is read again. 0 disables the cache.
32
+ // This bounds how late a revoke on another replica takes effect.
37
33
  function loadTokenCacheMs(env = process.env) {
38
34
  const cfg = envRecord();
39
35
  const raw = cfg.tokenCacheMs !== undefined ? cfg.tokenCacheMs : env.AGENT_TOKEN_CACHE_MS;
@@ -88,11 +84,8 @@ function loadAgentGrantsConfig(env = process.env) {
88
84
  }
89
85
  /** Once-per-process marker on the `cds` singleton; a module-level flag would not survive a double load. */
90
86
  const ACTIVATED = Symbol.for('odatano.agentGrants.activated');
91
- /**
92
- * Switch agent grants on when configured: installs @odatano/cap-auth with the `x-agent-token` lane
93
- * (previous strategy kept as delegate) and attaches the enforcement hook to each service on `serving`.
94
- * Called from src/plugin.ts and srv/server.ts, before cds.server() builds middlewares. Never throws.
95
- */
87
+ // Installs @odatano/cap-auth with the `x-agent-token` lane and keeps the old strategy as delegate.
88
+ // Must run before cds.server() builds middlewares. Never throws.
96
89
  function activateAgentGrants() {
97
90
  const facade = cds_1.default;
98
91
  if (facade[ACTIVATED] !== undefined)