@odatano/core 2.0.0-rc.6 → 2.0.0-rc.7

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.
@@ -10,8 +10,15 @@ import * as __ from './../_';
10
10
  * - status function + pause/resume actions delegating to the crawler singleton
11
11
  *
12
12
  * Security note: see CardanoODataService (cardano-service.cds) for the rationale on
13
- * service-level auth. pause/resume are operational actions — gate behind a dedicated
14
- * Admin scope. Read-only status and audit data remain available to authenticated users.
13
+ * auth. pause/resume are operational actions — gate behind a dedicated Admin scope.
14
+ * Read-only status and audit data remain available to authenticated users.
15
+ *
16
+ * Deliberately NO service-level @requires: CAP checks a service-level requirement
17
+ * on every request BEFORE the operation's own annotation, so an operation-level
18
+ * `@requires: 'any'` can never open a single function on an otherwise
19
+ * authenticated service (anonymous callers get the 401 challenge first). The
20
+ * requirement therefore sits on each element, and getLiveness() alone is 'any' —
21
+ * the same layout as NIGHTGATE's indexer service.
15
22
  */
16
23
  export default class {
17
24
  static readonly getStatus: typeof getStatus;
@@ -12,8 +12,11 @@ import * as _odatano_cardano from './../odatano/cardano';
12
12
  * - Submitting verified transactions to the blockchain and tracking submission status
13
13
  * - Providing actions for signing with a Hardware Security Module (HSM) and retrieving HSM status
14
14
  *
15
- * Security note: see CardanoODataService (cardano-service.cds) for the rationale
16
- * on service-level auth without per-resource ownership enforcement.
15
+ * Security note: see CardanoODataService (cardano-service.cds) for the rationale on auth
16
+ * without per-resource ownership enforcement. Deliberately NO service-level @requires:
17
+ * CAP checks it on every request BEFORE the operation annotation, which silenced the
18
+ * `any` on VerifyDataSignature (anonymous callers got the 401 challenge first). The
19
+ * requirement therefore sits on each element; VerifyDataSignature alone is public.
17
20
  */
18
21
  export default class {
19
22
  static readonly VerifySignature: typeof VerifySignature;
package/README.md CHANGED
@@ -1,186 +1,185 @@
1
- ![alt text](docs/assets/odatano_logo/logo_odatano_white.png)
2
-
3
- # Enterprise OData Services for the Cardano Blockchain
4
-
5
- Funded by [Cardano Catalyst Fund 14](https://projectcatalyst.io/funds/14/sponsored-by-leftovers/sap-cardano-odata-v4-api-with-cap-and-sap-cardano-sdk) all four milestones completed and approved (April 2026).
6
-
7
- **ODATANO** is an SAP CAP–based service that exposes the Cardano blockchain via a standardized **OData V4** interface, enabling enterprise-grade read and write access with native transaction building.
8
-
9
- [![Tests](https://github.com/ODATANO/ODATANO/actions/workflows/test.yaml/badge.svg)](https://github.com/ODATANO/ODATANO/actions/workflows/test.yaml)
10
- [![Coverage](https://codecov.io/gh/ODATANO/ODATANO/branch/main/graph/badge.svg)](https://codecov.io/gh/ODATANO/ODATANO)
11
- [![npm version](https://img.shields.io/npm/v/@odatano/core?logo=npm)](https://www.npmjs.com/package/@odatano/core)
12
- [![npm downloads](https://img.shields.io/npm/dt/@odatano/core?logo=npm&label=downloads&color=blue)](https://www.npmjs.com/package/@odatano/core)
13
- [![License](https://img.shields.io/badge/license-Apache%202.0-yellow)](LICENSE)
14
-
15
-
16
- ## Quick Start
17
-
18
- ### As CAP Plugin (recommended)
19
-
20
- Add ODATANO to any existing SAP CAP project:
21
-
22
- ```bash
23
- npm install @odatano/core @cap-js/sqlite
24
- ```
25
-
26
- ```json
27
- {
28
- "cds": {
29
- "requires": {
30
- "db": { "kind": "sqlite" },
31
- "odatano-core": {
32
- "network": "preview",
33
- "backends": ["blockfrost"]
34
- }
35
- }
36
- }
37
- }
38
- ```
39
-
40
- Put your API key in a `.env` file in the project root (loaded automatically by `cds serve` / `cds watch`) — don't commit it to `package.json`:
41
-
42
- ```bash
43
- # .env
44
- BLOCKFROST_API_KEY=preview_your_api_key_here
45
- ```
46
-
47
- ```bash
48
- cds deploy --to sqlite
49
- cds serve
50
- ```
51
-
52
- > Config in `cds.requires.odatano-core` takes precedence over environment
53
- > variables; a `blockfrostApiKey` set there would override the `.env` value.
54
-
55
- > **Self-hosted Blockfrost-compatible node?** (Dolos MiniBF, Demeter Self-Hosted)
56
- > Set `blockfrostCustomBackend` to the node's base URL (e.g. `http://localhost:3010/api/v0`).
57
- > When set, `blockfrostApiKey` becomes optional. See the [Backend Configuration Guide](docs/guides/BACKEND_CONFIGURATION.md#self-hosted-blockfrost-compatible-backends).
58
-
59
- ### Standalone
60
-
61
- Run ODATANO as a self-contained service (no host CAP project needed):
62
-
63
- ```bash
64
- git clone https://github.com/ODATANO/ODATANO && cd ODATANO
65
- npm ci
66
- cp .env.example .env # set BLOCKFROST_API_KEY, NETWORK, BACKENDS
67
- cds deploy --to sqlite
68
- cds serve
69
- ```
70
-
71
- Or with Docker — this brings up a local **cardano-node + Ogmios + ODATANO** stack
72
- (Preview), with the service pre-wired to the local Ogmios backend:
73
-
74
- ```bash
75
- docker compose up -d # full stack
76
- docker compose up -d cardano-node ogmios # just the chain backend (pre-sync)
77
- docker compose logs -f ogmios # watch sync (/health: 202 syncing, 200 near tip)
78
- ```
79
-
80
- > First sync from genesis takes hours; the node DB persists in a Docker volume so
81
- > restarts resume. Until Ogmios catches up, historical queries fall back to
82
- > Blockfrost (set `BLOCKFROST_API_KEY`).
83
-
84
- Service available at `http://localhost:4004`. See the [Quick Start Guide](docs/QUICK_START.md#local-ogmios--cardano-node-docker) for the local Ogmios stack and full details.
85
-
86
- ## Dev Mode: Mocked Authentication
87
-
88
- > **Heads-up.** `cds serve` uses CAP's mocked auth: `@requires: 'authenticated-user'` accepts any Basic-Auth header against a mock user (`alice`, `bob`, …) — passwords are not checked. Anonymous requests get 401, but anyone reaching the port can authenticate.
89
- >
90
- > Production needs the `[production]` profile (`NODE_ENV=production`), which switches to `auth: xsuaa`. Don't expose a dev-mode instance. See the [Security Guide](docs/guides/SECURITY_GUIDE.md#authentication-xsuaa).
91
-
92
- ## Services
93
-
94
- | Service | Path | Purpose |
95
- |---|---|---|
96
- | CardanoODataService | `/odata/v4/cardano-odata/` | Read blockchain data (20 entities, 19 actions) |
97
- | CardanoTransactionService | `/odata/v4/cardano-transaction/` | Build & submit transactions (13 actions) |
98
- | CardanoSignService | `/odata/v4/cardano-sign/` | External signing + HSM (9 actions) |
99
- | CardanoIndexerService | `/odata/v4/cardano-indexer/` | Chain crawler / pre-sync control (v2.0, off by default) |
100
- | CardanoWorkerService | `/odata/v4/cardano-worker/` | Asynchronous wallet jobs (v2.0, off by default) |
101
- | CardanoAgentService | `/odata/v4/cardano-agent/` | Agent grants: scoped bearer tokens for agents (v2.0, off by default) |
102
-
103
- Both v2.0 services also publish **CAP events**, so a consumer can subscribe instead of polling —
104
- in-process, no broker required:
105
-
106
- ```js
107
- (await cds.connect.to('CardanoWorkerService')).on('jobConfirmed', ({ data }) => …)
108
- (await cds.connect.to('CardanoIndexerService')).on('blockIndexed', ({ data }) => …)
109
- ```
110
-
111
- ## Agent grants (v2.0, off by default)
112
-
113
- Hand an agent a **scoped, budgeted token** instead of a user. Design and rationale:
114
- [AGENT_GRANTS_DESIGN.md](AGENT_GRANTS_DESIGN.md).
115
-
116
- ```bash
117
- AGENT_GRANTS_ENABLED=true # or cds.requires.odatano-core.agentGrants.enabled
118
- AGENT_GRANTS_DELEGATE=mocked # CAP auth kind that keeps authenticating non-token requests (default: configured kind)
119
- AGENT_GRANT_ADMIN_RATE_LIMIT=10 # grant administration calls per principal per hour (or agentGrants.adminRateLimit)
120
- ```
121
-
122
- 1. An **Admin** issues a grant (`POST /odata/v4/cardano-agent/CreateAgentGrant`): an allow list of
123
- actions, optionally a worker `walletId` (required for `SubmitWalletJob`/`CancelJob`), allowed job
124
- kinds, a daily budget and an expiry. The response carries the token `odat_…` **once**; the
125
- server stores only its SHA-256.
126
- 2. The agent sends `x-agent-token: odat_…` on any of the six service paths. It runs as the principal
127
- `agent:<grantId>` with the single role `agent-grant`, never as the operator: every
128
- `@requires: 'Admin'` surface (pause/resume, HSM signing, grant administration) refuses it by
129
- construction. Reads and compute-only actions are always allowed; allow-listed actions each cost
130
- one budget unit per UTC day (a build is the service an agent buys); everything else is 403.
131
- Wallet jobs are pinned to the grant's wallet and visible only to the grant that queued them.
132
- 3. `GET /odata/v4/cardano-agent/GetGrantStatus()` tells the agent what it may do and how much budget
133
- is left; `RevokeAgentGrant` turns the token into an unknown token immediately.
134
- 4. Lifecycle (Admin, same semantics as NIGHTGATE's agent grants so a gateway drives both with one
135
- code path): `UpdateAgentGrant` changes label, allow list, job kinds, daily budget or expiry
136
- (absent = untouched, explicit `null` = cleared; the wallet binding is immutable, 409
137
- `GRANT_REVOKED` on a revoked grant); `RotateAgentGrantToken` returns a fresh token once, the old
138
- one is unknown from the next request; `GetGrantUsage(grantId, since, until)` lists admitted calls
139
- per service and action over up to 366 days (an Admin for any grant, a token for its own). All
140
- administration calls share the per-principal hourly rate limit above.
141
-
142
- Grantable: `Build*`, `SetCollateral`, `CreateSigningRequest`, `VerifySignature`, `Submit*`,
143
- `CheckSubmissionStatus`, `SubmitWalletJob`, `CancelJob`. Never: `SignWithHsm*`, `Pause*`/`Resume*`,
144
- `pauseCrawler`/`resumeCrawler`, grant administration.
145
-
146
- Programmatic seams for other packages (`@odatano/x402` sells grants against a 402 payment):
147
- `issueAgentGrant()`, `updateAgentGrant()`, `rotateAgentGrantToken()`, `revokeAgentGrantById()`,
148
- `getGrantUsage()`, `registerTransportLane()` from `@odatano/core`.
149
-
150
- ## Liveness probe
151
-
152
- `GET /odata/v4/cardano-indexer/getLiveness()` answers `200 { status: "alive", timestamp, uptime,
153
- version, network }` **without credentials** (`@requires: 'any'`) as long as the process runs — no
154
- backend or DB probe, no secrets. The Docker `HEALTHCHECK`, compose and upstream probes use it
155
- instead of the service document, so a wrong operator password no longer reads as "ODATANO down".
156
- Readiness (crawler, worker, backends) stays authenticated: `getStatus()`, `GetWorkerStatus()`,
157
- `GetNetworkInformation`.
158
-
159
- ## Requirements
160
-
161
- - **Node.js >= 22.5** and **@sap/cds >= 10** (peer dependency). CAP 9 hosts cannot load `@odatano/core@2`.
162
- - Upgrading a consumer from 1.x: run **`cds deploy`**. 2.0 adds six tables (`CardanoSyncState`,
163
- `CardanoReorgLog`, `CardanoWorkerWallets`, `CardanoWalletJobs`, `CardanoAgentGrants`,
164
- `CardanoAgentGrantUsage`) plus a `dedupKey` column; without the redeploy the new services answer
165
- `no such table` while the old ones keep working.
166
-
167
- ## Documentation
168
-
169
- | Guide | Description |
170
- |-------|-------------|
171
- | [Quick Start](docs/QUICK_START.md) | Get running in 5 minutes |
172
- | [User Guide](docs/guides/USER_GUIDE.md) | API usage, entities, and examples |
173
- | [Developer Guide](docs/guides/DEVELOPER_GUIDE.md) | Architecture and development |
174
- | [Transaction Workflow](docs/guides/TRANSACTION_WORKFLOW.md) | Build → Sign → Submit flow |
175
- | [Security Guide](docs/guides/SECURITY_GUIDE.md) | Authentication, signing security, HSM |
176
- | [Docker Deployment](docs/guides/DOCKER_DEPLOYMENT.md) | Container deployment |
177
-
178
- ## License
179
-
180
- Apache License 2.0 - see [LICENSE](LICENSE)
181
-
182
- ## Support
183
-
184
- - **Issues**: [GitHub Issues](https://github.com/ODATANO/ODATANO/issues)
185
- - **Project Lead**: Max Weber
186
- - **Contact**: info@odatano.dev
1
+ ![alt text](docs/assets/odatano_logo/logo_odatano_white.png)
2
+
3
+ # Enterprise OData Services for the Cardano Blockchain
4
+
5
+ Funded by [Cardano Catalyst Fund 14](https://projectcatalyst.io/funds/14/sponsored-by-leftovers/sap-cardano-odata-v4-api-with-cap-and-sap-cardano-sdk) all four milestones completed and approved (April 2026).
6
+
7
+ **ODATANO** is an SAP CAP–based service that exposes the Cardano blockchain via a standardized **OData V4** interface, enabling enterprise-grade read and write access with native transaction building.
8
+
9
+ [![Tests](https://github.com/ODATANO/ODATANO/actions/workflows/test.yaml/badge.svg)](https://github.com/ODATANO/ODATANO/actions/workflows/test.yaml)
10
+ [![Coverage](https://codecov.io/gh/ODATANO/ODATANO/branch/main/graph/badge.svg)](https://codecov.io/gh/ODATANO/ODATANO)
11
+ [![npm version](https://img.shields.io/npm/v/@odatano/core?logo=npm)](https://www.npmjs.com/package/@odatano/core)
12
+ [![npm downloads](https://img.shields.io/npm/dt/@odatano/core?logo=npm&label=downloads&color=blue)](https://www.npmjs.com/package/@odatano/core)
13
+ [![License](https://img.shields.io/badge/license-Apache%202.0-yellow)](LICENSE)
14
+
15
+
16
+ ## Quick Start
17
+
18
+ ### As CAP Plugin (recommended)
19
+
20
+ Add ODATANO to any existing SAP CAP project:
21
+
22
+ ```bash
23
+ npm install @odatano/core @cap-js/sqlite
24
+ ```
25
+
26
+ ```json
27
+ {
28
+ "cds": {
29
+ "requires": {
30
+ "db": { "kind": "sqlite" },
31
+ "odatano-core": {
32
+ "network": "preview",
33
+ "backends": ["blockfrost"]
34
+ }
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ Put your API key in a `.env` file in the project root (loaded automatically by `cds serve` / `cds watch`) — don't commit it to `package.json`:
41
+
42
+ ```bash
43
+ # .env
44
+ BLOCKFROST_API_KEY=preview_your_api_key_here
45
+ ```
46
+
47
+ ```bash
48
+ cds deploy --to sqlite
49
+ cds serve
50
+ ```
51
+
52
+ > Config in `cds.requires.odatano-core` takes precedence over environment
53
+ > variables; a `blockfrostApiKey` set there would override the `.env` value.
54
+
55
+ > **Self-hosted Blockfrost-compatible node?** (Dolos MiniBF, Demeter Self-Hosted)
56
+ > Set `blockfrostCustomBackend` to the node's base URL (e.g. `http://localhost:3010/api/v0`).
57
+ > When set, `blockfrostApiKey` becomes optional. See the [Backend Configuration Guide](docs/guides/BACKEND_CONFIGURATION.md#self-hosted-blockfrost-compatible-backends).
58
+
59
+ ### Standalone
60
+
61
+ Run ODATANO as a self-contained service (no host CAP project needed):
62
+
63
+ ```bash
64
+ git clone https://github.com/ODATANO/ODATANO && cd ODATANO
65
+ npm ci
66
+ cp .env.example .env # set BLOCKFROST_API_KEY, NETWORK, BACKENDS
67
+ cds deploy --to sqlite
68
+ cds serve
69
+ ```
70
+
71
+ Or with Docker — this brings up a local **cardano-node + Ogmios + ODATANO** stack
72
+ (Preview), with the service pre-wired to the local Ogmios backend:
73
+
74
+ ```bash
75
+ docker compose up -d # full stack
76
+ docker compose up -d cardano-node ogmios # just the chain backend (pre-sync)
77
+ docker compose logs -f ogmios # watch sync (/health: 202 syncing, 200 near tip)
78
+ ```
79
+
80
+ > First sync from genesis takes hours; the node DB persists in a Docker volume so
81
+ > restarts resume. Until Ogmios catches up, historical queries fall back to
82
+ > Blockfrost (set `BLOCKFROST_API_KEY`).
83
+
84
+ Service available at `http://localhost:4004`. See the [Quick Start Guide](docs/QUICK_START.md#local-ogmios--cardano-node-docker) for the local Ogmios stack and full details.
85
+
86
+ ## Dev Mode: Mocked Authentication
87
+
88
+ > **Heads-up.** `cds serve` uses CAP's mocked auth: `@requires: 'authenticated-user'` accepts any Basic-Auth header against a mock user (`alice`, `bob`, …) — passwords are not checked. Anonymous requests get 401, but anyone reaching the port can authenticate.
89
+ >
90
+ > Production needs the `[production]` profile (`NODE_ENV=production`), which switches to `auth: xsuaa`. Don't expose a dev-mode instance. See the [Security Guide](docs/guides/SECURITY_GUIDE.md#authentication-xsuaa).
91
+
92
+ ## Services
93
+
94
+ | Service | Path | Purpose |
95
+ |---|---|---|
96
+ | CardanoODataService | `/odata/v4/cardano-odata/` | Read blockchain data (20 entities, 19 actions) |
97
+ | CardanoTransactionService | `/odata/v4/cardano-transaction/` | Build & submit transactions (13 actions) |
98
+ | CardanoSignService | `/odata/v4/cardano-sign/` | External signing + HSM (9 actions) |
99
+ | CardanoIndexerService | `/odata/v4/cardano-indexer/` | Chain crawler / pre-sync control (v2.0, off by default) |
100
+ | CardanoWorkerService | `/odata/v4/cardano-worker/` | Asynchronous wallet jobs (v2.0, off by default) |
101
+ | CardanoAgentService | `/odata/v4/cardano-agent/` | Agent grants: scoped bearer tokens for agents (v2.0, off by default) |
102
+
103
+ Both v2.0 services also publish **CAP events**, so a consumer can subscribe instead of polling —
104
+ in-process, no broker required:
105
+
106
+ ```js
107
+ (await cds.connect.to('CardanoWorkerService')).on('jobConfirmed', ({ data }) => …)
108
+ (await cds.connect.to('CardanoIndexerService')).on('blockIndexed', ({ data }) => …)
109
+ ```
110
+
111
+ ## Agent grants (v2.0, off by default)
112
+
113
+ Hand an agent a **scoped, budgeted token** instead of a user.
114
+
115
+ ```bash
116
+ AGENT_GRANTS_ENABLED=true # or cds.requires.odatano-core.agentGrants.enabled
117
+ AGENT_GRANTS_DELEGATE=mocked # CAP auth kind that keeps authenticating non-token requests (default: configured kind)
118
+ AGENT_GRANT_ADMIN_RATE_LIMIT=10 # grant administration calls per principal per hour (or agentGrants.adminRateLimit)
119
+ ```
120
+
121
+ 1. An **Admin** issues a grant (`POST /odata/v4/cardano-agent/CreateAgentGrant`): an allow list of
122
+ actions, optionally a worker `walletId` (required for `SubmitWalletJob`/`CancelJob`), allowed job
123
+ kinds, a daily budget and an expiry. The response carries the token `odat_…` **once**; the
124
+ server stores only its SHA-256.
125
+ 2. The agent sends `x-agent-token: odat_…` on any of the six service paths. It runs as the principal
126
+ `agent:<grantId>` with the single role `agent-grant`, never as the operator: every
127
+ `@requires: 'Admin'` surface (pause/resume, HSM signing, grant administration) refuses it by
128
+ construction. Reads and compute-only actions are always allowed; allow-listed actions each cost
129
+ one budget unit per UTC day (a build is the service an agent buys); everything else is 403.
130
+ Wallet jobs are pinned to the grant's wallet and visible only to the grant that queued them.
131
+ 3. `GET /odata/v4/cardano-agent/GetGrantStatus()` tells the agent what it may do and how much budget
132
+ is left; `RevokeAgentGrant` turns the token into an unknown token immediately.
133
+ 4. Lifecycle (Admin, same semantics as NIGHTGATE's agent grants so a gateway drives both with one
134
+ code path): `UpdateAgentGrant` changes label, allow list, job kinds, daily budget or expiry
135
+ (absent = untouched, explicit `null` = cleared; the wallet binding is immutable, 409
136
+ `GRANT_REVOKED` on a revoked grant); `RotateAgentGrantToken` returns a fresh token once, the old
137
+ one is unknown from the next request; `GetGrantUsage(grantId, since, until)` lists admitted calls
138
+ per service and action over up to 366 days (an Admin for any grant, a token for its own). All
139
+ administration calls share the per-principal hourly rate limit above.
140
+
141
+ Grantable: `Build*`, `SetCollateral`, `CreateSigningRequest`, `VerifySignature`, `Submit*`,
142
+ `CheckSubmissionStatus`, `SubmitWalletJob`, `CancelJob`. Never: `SignWithHsm*`, `Pause*`/`Resume*`,
143
+ `pauseCrawler`/`resumeCrawler`, grant administration.
144
+
145
+ Programmatic seams for other packages (`@odatano/x402` sells grants against a 402 payment):
146
+ `issueAgentGrant()`, `updateAgentGrant()`, `rotateAgentGrantToken()`, `revokeAgentGrantById()`,
147
+ `getGrantUsage()`, `registerTransportLane()` from `@odatano/core`.
148
+
149
+ ## Liveness probe
150
+
151
+ `GET /odata/v4/cardano-indexer/getLiveness()` answers `200 { status: "alive", timestamp, uptime,
152
+ version, network }` **without credentials** (`@requires: 'any'`) as long as the process runs — no
153
+ backend or DB probe, no secrets. The Docker `HEALTHCHECK`, compose and upstream probes use it
154
+ instead of the service document, so a wrong operator password no longer reads as "ODATANO down".
155
+ Readiness (crawler, worker, backends) stays authenticated: `getStatus()`, `GetWorkerStatus()`,
156
+ `GetNetworkInformation`.
157
+
158
+ ## Requirements
159
+
160
+ - **Node.js >= 22.5** and **@sap/cds >= 10** (peer dependency). CAP 9 hosts cannot load `@odatano/core@2`.
161
+ - Upgrading a consumer from 1.x: run **`cds deploy`**. 2.0 adds six tables (`CardanoSyncState`,
162
+ `CardanoReorgLog`, `CardanoWorkerWallets`, `CardanoWalletJobs`, `CardanoAgentGrants`,
163
+ `CardanoAgentGrantUsage`) plus a `dedupKey` column; without the redeploy the new services answer
164
+ `no such table` while the old ones keep working.
165
+
166
+ ## Documentation
167
+
168
+ | Guide | Description |
169
+ |-------|-------------|
170
+ | [Quick Start](docs/QUICK_START.md) | Get running in 5 minutes |
171
+ | [User Guide](docs/guides/USER_GUIDE.md) | API usage, entities, and examples |
172
+ | [Developer Guide](docs/guides/DEVELOPER_GUIDE.md) | Architecture and development |
173
+ | [Transaction Workflow](docs/guides/TRANSACTION_WORKFLOW.md) | Build → Sign → Submit flow |
174
+ | [Security Guide](docs/guides/SECURITY_GUIDE.md) | Authentication, signing security, HSM |
175
+ | [Docker Deployment](docs/guides/DOCKER_DEPLOYMENT.md) | Container deployment |
176
+
177
+ ## License
178
+
179
+ Apache License 2.0 - see [LICENSE](LICENSE)
180
+
181
+ ## Support
182
+
183
+ - **Issues**: [GitHub Issues](https://github.com/ODATANO/ODATANO/issues)
184
+ - **Project Lead**: Max Weber
185
+ - **Contact**: info@odatano.dev
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odatano/core",
3
- "version": "2.0.0-rc.6",
3
+ "version": "2.0.0-rc.7",
4
4
  "description": "SAP CAP plugin for Cardano blockchain OData V4 integration",
5
5
  "imports": {
6
6
  "#cds-models/*": "./@cds-models/*/index.js"
@@ -95,6 +95,9 @@
95
95
  "kind": "sqlite",
96
96
  "credentials": {
97
97
  "url": "db.sqlite"
98
+ },
99
+ "client": {
100
+ "timeout": 5000
98
101
  }
99
102
  },
100
103
  "[production]": {
@@ -1,93 +1,106 @@
1
- using {odatano.cardano as db} from '../db/schema';
2
-
3
- /**
4
- * Cardano Indexer Service (v2.0)
5
- *
6
- * Control + observability surface for the chain crawler / pre-sync engine:
7
- * - read-only projections of the sync cursor and reorg audit log
8
- * - status function + pause/resume actions delegating to the crawler singleton
9
- *
10
- * Security note: see CardanoODataService (cardano-service.cds) for the rationale on
11
- * service-level auth. pause/resume are operational actions — gate behind a dedicated
12
- * Admin scope. Read-only status and audit data remain available to authenticated users.
13
- */
14
- @requires: 'authenticated-user'
15
- service CardanoIndexerService @(impl: './cardano-indexer-service') {
16
-
17
- @readonly
18
- @title : 'Sync State'
19
- @description: 'Singleton crawl cursor — pre-sync progress, tip lag, status, errors'
20
- entity SyncState as projection on db.CardanoSyncState;
21
-
22
- @readonly
23
- @title : 'Reorg Log'
24
- @description: 'Audit trail of chain rollbacks handled by the crawler'
25
- entity ReorgLog as projection on db.CardanoReorgLog;
26
-
27
- @title : 'Crawler Status'
28
- @description: 'Live crawler status summary (numeric fields as strings, CAP-10 aligned)'
29
- type CrawlerStatus {
30
- running : Boolean;
31
- syncStatus : String;
32
- lastSlot : String;
33
- lastHeight : String;
34
- tipHeight : String;
35
- syncProgress : String;
36
- consecutiveErrors : Integer;
37
- }
38
-
39
- @title : 'Get Crawler Status'
40
- @description: 'Return the current crawler run state and sync progress'
41
- /**
42
- * Emitted AFTER each block is committed. Subscribe instead of polling:
43
- * (await cds.connect.to('CardanoIndexerService')).on('blockIndexed', ({ data }) => …)
44
- * In-process (plugin mode) this needs no messaging service.
45
- */
46
- event blockIndexed {
47
- hash : String(64);
48
- slot : Integer64;
49
- height : Integer64;
50
- txHashes : many String(64);
51
- tipSlot : Integer64;
52
- tipHeight: Integer64;
53
- }
54
-
55
- /** Emitted AFTER a rollback is committed. Everything above `forkSlot` was removed. */
56
- event reorg {
57
- forkSlot : Integer64;
58
- forkHeight : Integer64;
59
- blocksRolledBack : Integer;
60
- }
61
-
62
- function getStatus() returns CrawlerStatus;
63
-
64
- @title : 'Liveness'
65
- type Liveness {
66
- status : String; // 'alive'
67
- timestamp : Timestamp;
68
- uptime : Integer; // seconds since process start
69
- version : String; // @odatano/core version
70
- network : String; // configured network
71
- }
72
-
73
- // Public override (see VerifyDataSignature in cardano-sign-service.cds): a
74
- // liveness probe carries no credentials. 200 as long as the process answers —
75
- // no backend or DB probe, no secrets, no backend names, no API key state. That
76
- // stays with getStatus and the backend health entities, which remain
77
- // authenticated. Mirrors NIGHTGATE's `/api/v1/indexer/getLiveness()`, so a
78
- // gateway probes both products the same way.
79
- @title : 'Get Liveness'
80
- @description: 'Unauthenticated liveness probe: 200 while the process answers. Docker HEALTHCHECK and upstream probes use this instead of the service document.'
81
- @requires : 'any'
82
- function getLiveness() returns Liveness;
83
-
84
- @title : 'Pause Crawler'
85
- @description: 'Stop the crawler (closes the chain-sync stream). Resume continues from the cursor.'
86
- @requires : 'Admin'
87
- action pauseCrawler() returns Boolean;
88
-
89
- @title : 'Resume Crawler'
90
- @description: 'Start/restart the crawler from the persisted cursor using the configured source.'
91
- @requires : 'Admin'
92
- action resumeCrawler() returns Boolean;
93
- }
1
+ using {odatano.cardano as db} from '../db/schema';
2
+
3
+ /**
4
+ * Cardano Indexer Service (v2.0)
5
+ *
6
+ * Control + observability surface for the chain crawler / pre-sync engine:
7
+ * - read-only projections of the sync cursor and reorg audit log
8
+ * - status function + pause/resume actions delegating to the crawler singleton
9
+ *
10
+ * Security note: see CardanoODataService (cardano-service.cds) for the rationale on
11
+ * auth. pause/resume are operational actions — gate behind a dedicated Admin scope.
12
+ * Read-only status and audit data remain available to authenticated users.
13
+ *
14
+ * Deliberately NO service-level @requires: CAP checks a service-level requirement
15
+ * on every request BEFORE the operation's own annotation, so an operation-level
16
+ * `@requires: 'any'` can never open a single function on an otherwise
17
+ * authenticated service (anonymous callers get the 401 challenge first). The
18
+ * requirement therefore sits on each element, and getLiveness() alone is 'any' —
19
+ * the same layout as NIGHTGATE's indexer service.
20
+ */
21
+ // Service-level 'any' on purpose: CAP authorizes the service BEFORE the operation and
22
+ // treats a service without a service-level @requires as authenticated-user under
23
+ // NODE_ENV=production, which would 401 the anonymous operation below despite its own
24
+ // 'any'. Every element carries its requirement; the service itself refuses nothing.
25
+ @requires: 'any'
26
+ service CardanoIndexerService @(impl: './cardano-indexer-service') {
27
+
28
+ @readonly
29
+ @requires : 'authenticated-user'
30
+ @title : 'Sync State'
31
+ @description: 'Singleton crawl cursor — pre-sync progress, tip lag, status, errors'
32
+ entity SyncState as projection on db.CardanoSyncState;
33
+
34
+ @readonly
35
+ @requires : 'authenticated-user'
36
+ @title : 'Reorg Log'
37
+ @description: 'Audit trail of chain rollbacks handled by the crawler'
38
+ entity ReorgLog as projection on db.CardanoReorgLog;
39
+
40
+ @title : 'Crawler Status'
41
+ @description: 'Live crawler status summary (numeric fields as strings, CAP-10 aligned)'
42
+ type CrawlerStatus {
43
+ running : Boolean;
44
+ syncStatus : String;
45
+ lastSlot : String;
46
+ lastHeight : String;
47
+ tipHeight : String;
48
+ syncProgress : String;
49
+ consecutiveErrors : Integer;
50
+ }
51
+
52
+ @title : 'Get Crawler Status'
53
+ @description: 'Return the current crawler run state and sync progress'
54
+ /**
55
+ * Emitted AFTER each block is committed. Subscribe instead of polling:
56
+ * (await cds.connect.to('CardanoIndexerService')).on('blockIndexed', ({ data }) => …)
57
+ * In-process (plugin mode) this needs no messaging service.
58
+ */
59
+ event blockIndexed {
60
+ hash : String(64);
61
+ slot : Integer64;
62
+ height : Integer64;
63
+ txHashes : many String(64);
64
+ tipSlot : Integer64;
65
+ tipHeight: Integer64;
66
+ }
67
+
68
+ /** Emitted AFTER a rollback is committed. Everything above `forkSlot` was removed. */
69
+ event reorg {
70
+ forkSlot : Integer64;
71
+ forkHeight : Integer64;
72
+ blocksRolledBack : Integer;
73
+ }
74
+
75
+ @requires : 'authenticated-user'
76
+ function getStatus() returns CrawlerStatus;
77
+
78
+ @title : 'Liveness'
79
+ type Liveness {
80
+ status : String; // 'alive'
81
+ timestamp : Timestamp;
82
+ uptime : Integer; // seconds since process start
83
+ version : String; // @odatano/core version
84
+ network : String; // configured network
85
+ }
86
+
87
+ // Anonymous on purpose: a liveness probe carries no credentials. 200 as long
88
+ // as the process answers — no backend or DB probe, no secrets, no backend
89
+ // names, no API key state. Readiness stays with getStatus and the worker
90
+ // status, which remain authenticated. Mirrors NIGHTGATE's
91
+ // `/api/v1/indexer/getLiveness()`, so a gateway probes both products the same way.
92
+ @title : 'Get Liveness'
93
+ @description: 'Unauthenticated liveness probe: 200 while the process answers. Docker HEALTHCHECK and upstream probes use this instead of the service document.'
94
+ @requires : 'any'
95
+ function getLiveness() returns Liveness;
96
+
97
+ @title : 'Pause Crawler'
98
+ @description: 'Stop the crawler (closes the chain-sync stream). Resume continues from the cursor.'
99
+ @requires : 'Admin'
100
+ action pauseCrawler() returns Boolean;
101
+
102
+ @title : 'Resume Crawler'
103
+ @description: 'Start/restart the crawler from the persisted cursor using the configured source.'
104
+ @requires : 'Admin'
105
+ action resumeCrawler() returns Boolean;
106
+ }
@@ -1,180 +1,200 @@
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} 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 on auth
14
+ * without per-resource ownership enforcement. Deliberately NO service-level @requires:
15
+ * CAP checks it on every request BEFORE the operation annotation, which silenced the
16
+ * `any` on VerifyDataSignature (anonymous callers got the 401 challenge first). The
17
+ * requirement therefore sits on each element; VerifyDataSignature alone is public.
18
+ */
19
+ // Service-level 'any' on purpose: CAP authorizes the service BEFORE the operation and
20
+ // treats a service without a service-level @requires as authenticated-user under
21
+ // NODE_ENV=production, which would 401 the anonymous operation below despite its own
22
+ // 'any'. Every element carries its requirement; the service itself refuses nothing.
23
+ @requires: 'any'
24
+ service CardanoSignService @(impl: './cardano-sign-service') {
25
+
26
+ // ---------------------------------------------------------------------------
27
+ // Signing Workflow Projections
28
+ // ---------------------------------------------------------------------------
29
+ @readonly
30
+ @title : 'Signature Verifications'
31
+ @description: 'Projection for Signature Verifications - stores verification results'
32
+ @requires : 'authenticated-user'
33
+ entity SignatureVerifications as projection on db.SignatureVerifications;
34
+
35
+ @readonly
36
+ @title : 'Address Signing Requests'
37
+ @description: 'Projection for retrieving signing requests by address'
38
+ @requires : 'authenticated-user'
39
+ entity AddressSigningRequests as projection on db.AddressSigningRequests;
40
+
41
+ @readonly
42
+ @title : 'Transaction Builds'
43
+ @description: 'Projection for Transaction Builds - needed by CreateSigningRequest to look up build details'
44
+ @requires : 'authenticated-user'
45
+ entity TransactionBuilds as projection on db.TransactionBuilds;
46
+
47
+
48
+ @readonly
49
+ @title : 'Transaction Submissions'
50
+ @description: 'Projection for Transaction Submissions - stores submission results'
51
+ @requires : 'authenticated-user'
52
+ entity TransactionSubmissions as projection on db.TransactionSubmissions;
53
+
54
+ @readonly
55
+ @title : 'Signing Requests'
56
+ @description: 'Projection for Signing Requests - tracks signing workflow'
57
+ @requires : 'authenticated-user'
58
+ entity SigningRequests as projection on db.SigningRequests;
59
+
60
+ @title : 'Verify Signature'
61
+ @description: 'Verify the signature of a signed transaction. Stores the verification result for audit trail.'
62
+ @requires : 'authenticated-user'
63
+ action VerifySignature(
64
+ @title: 'Signing Request ID'
65
+ @description: 'The unique identifier of the signing request'
66
+ signingRequestId: UUID,
67
+ @title: 'Signed Transaction CBOR'
68
+ @description: 'The signed transaction CBOR to verify'
69
+ signedTxCbor: String,
70
+ @title: 'Signer Type'
71
+ @description: 'Type of signer used (cardano-cli | browser-wallet | hardware-wallet | custom)'
72
+ signerType: String(20),
73
+ @title: 'Signer Info'
74
+ @description: 'Additional signer information (wallet name, etc.)'
75
+ signerInfo: String(100),
76
+ @title: 'Sender Address'
77
+ @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
78
+ address: Bech32) returns SignatureVerifications;
79
+
80
+ @title : 'Submit Verified Transaction'
81
+ @description: 'Verify and submit a signed transaction in one step. Updates the signing request status and creates submission record.'
82
+ @requires : 'authenticated-user'
83
+ action SubmitVerifiedTransaction(
84
+ @title: 'Signing Request ID'
85
+ @description: 'The unique identifier of the signing request'
86
+ signingRequestId: UUID,
87
+ @title: 'Signed Transaction CBOR'
88
+ @description: 'The signed transaction CBOR'
89
+ signedTxCbor: String,
90
+ @title: 'Signer Type'
91
+ @description: 'Type of signer used'
92
+ signerType: String(20),
93
+ @title: 'Signer Info'
94
+ @description: 'Additional signer information'
95
+ signerInfo: String(100),
96
+ @title: 'Sender Address'
97
+ @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
98
+ address: Bech32,
99
+ @title: 'Defer Submit'
100
+ @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.'
101
+ deferSubmit: Boolean) returns TransactionSubmissions;
102
+
103
+
104
+ // ---------------------------------------------------------------------------
105
+ // CIP-30 signData (COSE_Sign1) message-signature verification
106
+ // ---------------------------------------------------------------------------
107
+
108
+ // Public override: this action is the crypto check behind wallet-based LOGIN,
109
+ // so the caller is not yet authenticated. It is a stateless verification —
110
+ // no DB write, no key access, no state — so exposing it leaks nothing.
111
+ @requires : 'any'
112
+ @title : 'Verify Data Signature (CIP-30 signData)'
113
+ @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.'
114
+ action VerifyDataSignature(
115
+ @description: 'Bech32 address the wallet claimed to sign with'
116
+ address : Bech32,
117
+ @description: 'Hex-encoded COSE_Sign1 CBOR (the `signature` field from CIP-30 signData)'
118
+ coseSignature : String,
119
+ @description: 'Hex-encoded COSE_Key CBOR (the `key` field from CIP-30 signData)'
120
+ coseKey : String,
121
+ @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.'
122
+ expectedPayload: String) returns {
123
+ @description: 'Whether the signature is valid and all checks passed' valid : Boolean;
124
+ @description: 'Failure detail when not valid' reason : String;
125
+ @description: 'UTF-8 of the signed payload, echoed back' signedPayload : String;
126
+ @description: 'Hex blake2b-224 of the signer public key' signerVkh : String;
127
+ };
128
+
129
+ // ---------------------------------------------------------------------------
130
+ // General Signing Workflow Actions
131
+ // ---------------------------------------------------------------------------
132
+
133
+ @title : 'Create Signing Request'
134
+ @description: 'Create a signing request for external signing. Returns transaction details, signing instructions, and CLI commands. The request is persisted for audit trail.'
135
+ @requires : 'authenticated-user'
136
+ action CreateSigningRequest(
137
+ @title: 'Build ID'
138
+ @description: 'The unique identifier of the transaction build'
139
+ buildId: UUID,
140
+ @title: 'Message to Signer'
141
+ @description: 'A message to include for the signer'
142
+ message: String) returns SigningRequests;
143
+
144
+ @title : 'Get Signing Request'
145
+ @description: 'Retrieve an existing signing request by ID'
146
+ @requires : 'authenticated-user'
147
+ action GetSigningRequest(
148
+ @title: 'Signing Request ID'
149
+ @description: 'The unique identifier of the signing request'
150
+ signingRequestId: UUID) returns SigningRequests;
151
+
152
+ @title : 'Address Signing Requests'
153
+ @description: 'Projection for retrieving signing requests by address'
154
+ @requires : 'authenticated-user'
155
+ action GetSigningRequestsByAddress(
156
+ @title: 'Bech32 Address'
157
+ @description: 'The Bech32 encoded address to retrieve signing requests for'
158
+ address: Bech32) returns array of AddressSigningRequests;
159
+
160
+ // ---------------------------------------------------------------------------
161
+ // HSM (Hardware Security Module) Signing Actions
162
+ // ---------------------------------------------------------------------------
163
+
164
+ @title : 'Sign with HSM'
165
+ @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.'
166
+ @requires : 'authenticated-user'
167
+ action SignWithHsm(
168
+ @title: 'Build ID'
169
+ @description: 'The unique identifier of the transaction build to sign'
170
+ buildId: UUID,
171
+ @title: 'Sender Address'
172
+ @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
173
+ address: Bech32) returns SigningRequests;
174
+
175
+ @title : 'Sign and Submit with HSM'
176
+ @description: 'Sign a transaction using the HSM and submit it to the blockchain in one atomic operation. Returns the transaction submission details.'
177
+ @requires : 'authenticated-user'
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 : 'Get HSM Status'
190
+ @description: 'Check the current status of the HSM connection and key availability.'
191
+ @requires : 'authenticated-user'
192
+ action GetHsmStatus() returns {
193
+ @title: 'Connected' @description: 'Whether the HSM session is active' connected : Boolean;
194
+ @title: 'Key ID' @description: 'The PKCS#11 key identifier in use' keyId : String;
195
+ @title: 'Key Label' @description: 'The PKCS#11 key label in use' keyLabel : String;
196
+ @title: 'Public Key Hash' @description: 'Blake2b-224 hash of the HSM Ed25519 public key (= Cardano verification key hash)' publicKeyHash : String;
197
+ @title: 'Cardano Address' @description: 'Enterprise Cardano address derived from the HSM public key' cardanoAddress : String;
198
+ };
199
+
200
+ }