@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
@@ -1,180 +1,211 @@
1
- using {odatano.cardano as db} from '../db/schema';
2
- using {Bech32} from '../db/types';
3
-
4
- /**
5
- * Cardano Sign Service
6
- *
7
- * Handles the external signing workflow for Cardano transactions, including:
8
- * - Creating signing requests with transaction details and signing instructions
9
- * - Verifying signatures of signed transactions and storing verification results
10
- * - Submitting verified transactions to the blockchain and tracking submission status
11
- * - Providing actions for signing with a Hardware Security Module (HSM) and retrieving HSM status
12
- *
13
- * Security note: see CardanoODataService (cardano-service.cds) for the rationale
14
- * on service-level auth without per-resource ownership enforcement.
15
- */
16
- @requires: 'authenticated-user'
17
- service CardanoSignService @(impl: './cardano-sign-service') {
18
-
19
- // ---------------------------------------------------------------------------
20
- // Signing Workflow Projections
21
- // ---------------------------------------------------------------------------
22
- @readonly
23
- @title : 'Signature Verifications'
24
- @description: 'Projection for Signature Verifications - stores verification results'
25
- entity SignatureVerifications as projection on db.SignatureVerifications;
26
-
27
- @readonly
28
- @title : 'Address Signing Requests'
29
- @description: 'Projection for retrieving signing requests by address'
30
- entity AddressSigningRequests as projection on db.AddressSigningRequests;
31
-
32
- @readonly
33
- @title : 'Transaction Builds'
34
- @description: 'Projection for Transaction Builds - needed by CreateSigningRequest to look up build details'
35
- entity TransactionBuilds as projection on db.TransactionBuilds;
36
-
37
-
38
- @readonly
39
- @title : 'Transaction Submissions'
40
- @description: 'Projection for Transaction Submissions - stores submission results'
41
- entity TransactionSubmissions as projection on db.TransactionSubmissions;
42
-
43
- @readonly
44
- @title : 'Signing Requests'
45
- @description: 'Projection for Signing Requests - tracks signing workflow'
46
- entity SigningRequests as projection on db.SigningRequests;
47
-
48
- @title : 'Verify Signature'
49
- @description: 'Verify the signature of a signed transaction. Stores the verification result for audit trail.'
50
- action VerifySignature(
51
- @title: 'Signing Request ID'
52
- @description: 'The unique identifier of the signing request'
53
- signingRequestId: UUID,
54
- @title: 'Signed Transaction CBOR'
55
- @description: 'The signed transaction CBOR to verify'
56
- signedTxCbor: String,
57
- @title: 'Signer Type'
58
- @description: 'Type of signer used (cardano-cli | browser-wallet | hardware-wallet | custom)'
59
- signerType: String(20),
60
- @title: 'Signer Info'
61
- @description: 'Additional signer information (wallet name, etc.)'
62
- signerInfo: String(100),
63
- @title: 'Sender Address'
64
- @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
65
- address: Bech32) returns SignatureVerifications;
66
-
67
- @title : 'Submit Verified Transaction'
68
- @description: 'Verify and submit a signed transaction in one step. Updates the signing request status and creates submission record.'
69
- action SubmitVerifiedTransaction(
70
- @title: 'Signing Request ID'
71
- @description: 'The unique identifier of the signing request'
72
- signingRequestId: UUID,
73
- @title: 'Signed Transaction CBOR'
74
- @description: 'The signed transaction CBOR'
75
- signedTxCbor: String,
76
- @title: 'Signer Type'
77
- @description: 'Type of signer used'
78
- signerType: String(20),
79
- @title: 'Signer Info'
80
- @description: 'Additional signer information'
81
- signerInfo: String(100),
82
- @title: 'Sender Address'
83
- @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
84
- address: Bech32,
85
- @title: 'Defer Submit'
86
- @description: 'When true, verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit. Returns immediately with the tx hash (= tx body hash) and status ''pending''. Designed for in-process CAP consumers whose request transaction would otherwise deadlock the pooled sqlite connection (KNOWN_ISSUES #11). Track the outcome via the signing request / submission status.'
87
- deferSubmit: Boolean) returns TransactionSubmissions;
88
-
89
-
90
- // ---------------------------------------------------------------------------
91
- // CIP-30 signData (COSE_Sign1) message-signature verification
92
- // ---------------------------------------------------------------------------
93
-
94
- // Public override: this action is the crypto check behind wallet-based LOGIN,
95
- // so the caller is not yet authenticated. It is a stateless verification —
96
- // no DB write, no key access, no state — so exposing it leaks nothing.
97
- @requires : 'any'
98
- @title : 'Verify Data Signature (CIP-30 signData)'
99
- @description: 'Verify a COSE_Sign1 message signature against a bech32 address. Confirms the Ed25519 signature, that the signer key hashes to the address payment credential, and (optionally) that the signed payload matches an expected value.'
100
- action VerifyDataSignature(
101
- @description: 'Bech32 address the wallet claimed to sign with'
102
- address : Bech32,
103
- @description: 'Hex-encoded COSE_Sign1 CBOR (the `signature` field from CIP-30 signData)'
104
- coseSignature : String,
105
- @description: 'Hex-encoded COSE_Key CBOR (the `key` field from CIP-30 signData)'
106
- coseKey : String,
107
- @description: 'Optional expected UTF-8 payload; when set, the signed payload must equal it (anti-replay). When omitted, the decoded payload is returned for the caller to check.'
108
- expectedPayload: String) returns {
109
- @description: 'Whether the signature is valid and all checks passed' valid : Boolean;
110
- @description: 'Failure detail when not valid' reason : String;
111
- @description: 'UTF-8 of the signed payload, echoed back' signedPayload : String;
112
- @description: 'Hex blake2b-224 of the signer public key' signerVkh : String;
113
- };
114
-
115
- // ---------------------------------------------------------------------------
116
- // General Signing Workflow Actions
117
- // ---------------------------------------------------------------------------
118
-
119
- @title : 'Create Signing Request'
120
- @description: 'Create a signing request for external signing. Returns transaction details, signing instructions, and CLI commands. The request is persisted for audit trail.'
121
- action CreateSigningRequest(
122
- @title: 'Build ID'
123
- @description: 'The unique identifier of the transaction build'
124
- buildId: UUID,
125
- @title: 'Message to Signer'
126
- @description: 'A message to include for the signer'
127
- message: String) returns SigningRequests;
128
-
129
- @title : 'Get Signing Request'
130
- @description: 'Retrieve an existing signing request by ID'
131
- action GetSigningRequest(
132
- @title: 'Signing Request ID'
133
- @description: 'The unique identifier of the signing request'
134
- signingRequestId: UUID) returns SigningRequests;
135
-
136
- @title : 'Address Signing Requests'
137
- @description: 'Projection for retrieving signing requests by address'
138
- action GetSigningRequestsByAddress(
139
- @title: 'Bech32 Address'
140
- @description: 'The Bech32 encoded address to retrieve signing requests for'
141
- address: Bech32) returns array of AddressSigningRequests;
142
-
143
- // ---------------------------------------------------------------------------
144
- // HSM (Hardware Security Module) Signing Actions
145
- // ---------------------------------------------------------------------------
146
-
147
- @title : 'Sign with HSM'
148
- @description: 'Sign a transaction using the configured Hardware Security Module. Creates a signing request, signs with the HSM, and verifies the signature. Returns the signing request with status verified.'
149
- action SignWithHsm(
150
- @title: 'Build ID'
151
- @description: 'The unique identifier of the transaction build to sign'
152
- buildId: UUID,
153
- @title: 'Sender Address'
154
- @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
155
- address: Bech32) returns SigningRequests;
156
-
157
- @title : 'Sign and Submit with HSM'
158
- @description: 'Sign a transaction using the HSM and submit it to the blockchain in one atomic operation. Returns the transaction submission details.'
159
- action SignAndSubmitWithHsm(
160
- @title: 'Build ID'
161
- @description: 'The unique identifier of the transaction build to sign and submit'
162
- buildId: UUID,
163
- @title: 'Sender Address'
164
- @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
165
- address: Bech32,
166
- @title: 'Defer Submit'
167
- @description: 'When true, sign + verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit (see SubmitVerifiedTransaction.deferSubmit).'
168
- deferSubmit: Boolean) returns TransactionSubmissions;
169
-
170
- @title : 'Get HSM Status'
171
- @description: 'Check the current status of the HSM connection and key availability.'
172
- action GetHsmStatus() returns {
173
- @title: 'Connected' @description: 'Whether the HSM session is active' connected : Boolean;
174
- @title: 'Key ID' @description: 'The PKCS#11 key identifier in use' keyId : String;
175
- @title: 'Key Label' @description: 'The PKCS#11 key label in use' keyLabel : String;
176
- @title: 'Public Key Hash' @description: 'Blake2b-224 hash of the HSM Ed25519 public key (= Cardano verification key hash)' publicKeyHash : String;
177
- @title: 'Cardano Address' @description: 'Enterprise Cardano address derived from the HSM public key' cardanoAddress : String;
178
- };
179
-
180
- }
1
+ using {odatano.cardano as db} from '../db/schema';
2
+ using {Bech32, ResolvedOutcome} from '../db/types';
3
+
4
+ // External signing: signing requests, signature checks, submission and HSM signing.
5
+ // The service itself is 'any': CAP checks the service before the operation, so anything stricter
6
+ // would 401 the anonymous VerifyDataSignature. Each element carries its own requirement.
7
+ @requires: 'any'
8
+ service CardanoSignService @(impl: './cardano-sign-service') {
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // Signing Workflow Projections
12
+ // ---------------------------------------------------------------------------
13
+ @readonly
14
+ @title : 'Signature Verifications'
15
+ @description: 'Projection for Signature Verifications - stores verification results'
16
+ @requires : 'Sign'
17
+ entity SignatureVerifications as projection on db.SignatureVerifications;
18
+
19
+ @readonly
20
+ @title : 'Address Signing Requests'
21
+ @description: 'Signing requests of an address, ordered by request id'
22
+ @requires : 'Sign'
23
+ entity AddressSigningRequests as projection on db.AddressSigningRequests;
24
+
25
+ @readonly
26
+ @title : 'Transaction Builds'
27
+ @description: 'Projection for Transaction Builds - needed by CreateSigningRequest to look up build details'
28
+ @requires : 'Sign'
29
+ entity TransactionBuilds as projection on db.TransactionBuilds;
30
+
31
+
32
+ @readonly
33
+ @title : 'Transaction Submissions'
34
+ @description: 'Projection for Transaction Submissions - stores submission results'
35
+ @requires : 'Sign'
36
+ entity TransactionSubmissions as projection on db.TransactionSubmissions;
37
+
38
+ @readonly
39
+ @title : 'Signing Requests'
40
+ @description: 'Projection for Signing Requests - tracks signing workflow'
41
+ @requires : 'Sign'
42
+ entity SigningRequests as projection on db.SigningRequests;
43
+
44
+ @title : 'Verify Signature'
45
+ @description: 'Verify the signature of a signed transaction. Stores the verification result for audit trail.'
46
+ @requires : 'Sign'
47
+ @odatano.agent: 'grant'
48
+ action VerifySignature(
49
+ @title: 'Signing Request ID'
50
+ @description: 'The unique identifier of the signing request'
51
+ signingRequestId: UUID,
52
+ @title: 'Signed Transaction CBOR'
53
+ @description: 'The signed transaction CBOR to verify'
54
+ signedTxCbor: String,
55
+ @title: 'Signer Type'
56
+ @description: 'Type of signer used (cardano-cli | browser-wallet | hardware-wallet | custom)'
57
+ signerType: String(20),
58
+ @title: 'Signer Info'
59
+ @description: 'Additional signer information (wallet name, etc.)'
60
+ signerInfo: String(100),
61
+ @title: 'Sender Address'
62
+ @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
63
+ address: Bech32) returns SignatureVerifications;
64
+
65
+ @title : 'Submit Verified Transaction'
66
+ @description: 'Verify and submit a signed transaction in one step. Updates the signing request status and creates submission record.'
67
+ @requires : 'Sign'
68
+ @odatano.agent: 'grant'
69
+ action SubmitVerifiedTransaction(
70
+ @title: 'Signing Request ID'
71
+ @description: 'The unique identifier of the signing request'
72
+ signingRequestId: UUID,
73
+ @title: 'Signed Transaction CBOR'
74
+ @description: 'The signed transaction CBOR'
75
+ signedTxCbor: String,
76
+ @title: 'Signer Type'
77
+ @description: 'Type of signer used'
78
+ signerType: String(20),
79
+ @title: 'Signer Info'
80
+ @description: 'Additional signer information'
81
+ signerInfo: String(100),
82
+ @title: 'Sender Address'
83
+ @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
84
+ address: Bech32,
85
+ @title: 'Defer Submit'
86
+ @description: 'When true, verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit. Returns immediately with the tx hash (= tx body hash) and status ''pending''. Designed for in-process CAP consumers whose request transaction would otherwise deadlock the pooled sqlite connection. Track the outcome via the signing request / submission status.'
87
+ deferSubmit: Boolean) returns TransactionSubmissions;
88
+
89
+
90
+ // ---------------------------------------------------------------------------
91
+ // CIP-30 signData (COSE_Sign1) message-signature verification
92
+ // ---------------------------------------------------------------------------
93
+
94
+ // Public override: this action is the crypto check behind wallet-based LOGIN,
95
+ // so the caller is not yet authenticated. It writes nothing and touches no key, so it leaks nothing.
96
+ @requires : 'any'
97
+ @title : 'Verify Data Signature (CIP-30 signData)'
98
+ @description: 'Verify a COSE_Sign1 message signature against a bech32 address. Confirms EdDSA over an Ed25519 key, that the signed header names the given address, that the signer key hashes to its credential (payment credential, or stake credential of a reward address), the Ed25519 signature, and (optionally) that the signed payload matches an expected value.'
99
+ @odatano.agent: 'read'
100
+ action VerifyDataSignature(
101
+ @description: 'Bech32 payment or reward address the wallet signed with'
102
+ address : Bech32,
103
+ @description: 'Hex-encoded COSE_Sign1 CBOR (the `signature` field from CIP-30 signData)'
104
+ coseSignature : String(65536),
105
+ @description: 'Hex-encoded COSE_Key CBOR (the `key` field from CIP-30 signData)'
106
+ coseKey : String(512),
107
+ @description: 'Optional expected UTF-8 payload; when set, the signed payload must equal it byte for byte (anti-replay). Required when the wallet signed the hash of the message. When omitted, the decoded payload is returned for the caller to check.'
108
+ expectedPayload: String(16384)) returns {
109
+ @description: 'Whether the signature is valid and all checks passed' valid : Boolean;
110
+ @description: 'Failure detail when not valid' reason : String;
111
+ @description: 'The signed message as text; empty when the payload is not UTF-8' signedPayload : String;
112
+ @description: 'The payload bytes as signed, hex; the blake2b-224 of the message when the wallet hashed it' signedPayloadHex : String;
113
+ @description: 'Hex blake2b-224 of the signer public key' signerVkh : String;
114
+ };
115
+
116
+ // ---------------------------------------------------------------------------
117
+ // General Signing Workflow Actions
118
+ // ---------------------------------------------------------------------------
119
+
120
+ @title : 'Create Signing Request'
121
+ @description: 'Create a signing request for external signing. Returns transaction details, signing instructions, and CLI commands. The request is persisted for audit trail.'
122
+ @requires : 'Sign'
123
+ @odatano.agent: 'grant'
124
+ action CreateSigningRequest(
125
+ @title: 'Build ID'
126
+ @description: 'The unique identifier of the transaction build'
127
+ buildId: UUID,
128
+ @title: 'Message to Signer'
129
+ @description: 'A message to include for the signer'
130
+ message: String) returns SigningRequests;
131
+
132
+ @title : 'Get Signing Request'
133
+ @description: 'Retrieve an existing signing request by ID'
134
+ @requires : 'Sign'
135
+ @odatano.agent: 'read'
136
+ action GetSigningRequest(
137
+ @title: 'Signing Request ID'
138
+ @description: 'The unique identifier of the signing request'
139
+ signingRequestId: UUID) returns SigningRequests;
140
+
141
+ @title : 'Address Signing Requests'
142
+ @description: 'Projection for retrieving signing requests by address'
143
+ @requires : 'Sign'
144
+ @odatano.agent: 'read'
145
+ action GetSigningRequestsByAddress(
146
+ @title: 'Bech32 Address'
147
+ @description: 'The Bech32 encoded address to retrieve signing requests for'
148
+ address: Bech32,
149
+ @title: 'Limit'
150
+ @description: 'Maximum number of rows (default 1000, at most 5000)'
151
+ @assert.range: [1, 5000]
152
+ limit: Integer,
153
+ @title: 'Skip'
154
+ @description: 'Number of rows to skip (default 0)'
155
+ @assert.range: [0, _]
156
+ skip: Integer) returns array of AddressSigningRequests;
157
+
158
+ // ---------------------------------------------------------------------------
159
+ // HSM (Hardware Security Module) Signing Actions
160
+ // ---------------------------------------------------------------------------
161
+
162
+ @title : 'Sign with HSM'
163
+ @description: 'Sign a transaction using the configured Hardware Security Module. Creates a signing request, signs with the HSM, and verifies the signature. Returns the signing request with status verified.'
164
+ @requires : 'Sign'
165
+ @odatano.agent: 'operator'
166
+ action SignWithHsm(
167
+ @title: 'Build ID'
168
+ @description: 'The unique identifier of the transaction build to sign'
169
+ buildId: UUID,
170
+ @title: 'Sender Address'
171
+ @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
172
+ address: Bech32) returns SigningRequests;
173
+
174
+ @title : 'Sign and Submit with HSM'
175
+ @description: 'Sign a transaction using the HSM and submit it to the blockchain in one atomic operation. Returns the transaction submission details.'
176
+ @requires : 'Sign'
177
+ @odatano.agent: 'operator'
178
+ action SignAndSubmitWithHsm(
179
+ @title: 'Build ID'
180
+ @description: 'The unique identifier of the transaction build to sign and submit'
181
+ buildId: UUID,
182
+ @title: 'Sender Address'
183
+ @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
184
+ address: Bech32,
185
+ @title: 'Defer Submit'
186
+ @description: 'When true, sign + verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit (see SubmitVerifiedTransaction.deferSubmit).'
187
+ deferSubmit: Boolean) returns TransactionSubmissions;
188
+
189
+ @title : 'Resolve Signing Request'
190
+ @description: 'Settle an unresolved signing request after reading the chain: confirmed when its transaction is on chain with passing scripts (the submission record is then written), failed when it is not and can no longer land; failed is refused with 409 while the transaction is not expired and an input of it is unspent. txHash, when given, must be the request transaction.'
191
+ @requires : 'Admin'
192
+ @odatano.agent: 'operator'
193
+ action ResolveSigningRequest(
194
+ @title: 'Signing Request ID' signingRequestId: UUID not null,
195
+ @title: 'Outcome' @assert.range outcome: ResolvedOutcome not null,
196
+ @title: 'Transaction Hash' txHash: String(64),
197
+ @title: 'Note' note: String(300)) returns SigningRequests;
198
+
199
+ @title : 'Get HSM Status'
200
+ @description: 'Check the current status of the HSM connection and key availability.'
201
+ @requires : 'Sign'
202
+ @odatano.agent: 'read'
203
+ action GetHsmStatus() returns {
204
+ @title: 'Connected' @description: 'Whether the HSM session is active' connected : Boolean;
205
+ @title: 'Key ID' @description: 'The PKCS#11 key identifier in use' keyId : String;
206
+ @title: 'Key Label' @description: 'The PKCS#11 key label in use' keyLabel : String;
207
+ @title: 'Public Key Hash' @description: 'Blake2b-224 hash of the HSM Ed25519 public key (= Cardano verification key hash)' publicKeyHash : String;
208
+ @title: 'Cardano Address' @description: 'Enterprise Cardano address derived from the HSM public key' cardanoAddress : String;
209
+ };
210
+
211
+ }