@odatano/core 2.0.0-rc.1 → 2.0.0-rc.11
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.
- package/@cds-models/CardanoAgentService/index.d.ts +255 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +37 -2
- package/@cds-models/CardanoIndexerService/index.js +4 -0
- package/@cds-models/CardanoSignService/index.d.ts +5 -2
- package/@cds-models/CardanoTransactionService/index.d.ts +9 -9
- package/@cds-models/odatano/cardano/index.d.ts +86 -0
- package/@cds-models/odatano/cardano/index.js +6 -0
- package/README.md +62 -4
- package/db/schema.cds +105 -0
- package/package.json +9 -3
- package/src/index.d.ts +6 -0
- package/src/index.js +21 -1
- package/src/plugin.js +33 -30
- package/srv/blockchain/backends/blockfrost-backend.js +1 -10
- package/srv/blockchain/backends/koios-backend.js +1 -10
- package/srv/blockchain/backends/ogmios-backend.d.ts +29 -4
- package/srv/blockchain/backends/ogmios-backend.js +96 -7
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +77 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +181 -0
- package/srv/blockchain/cardano-indexer.d.ts +18 -0
- package/srv/blockchain/cardano-indexer.js +58 -3
- package/srv/blockchain/crawler/crawler.d.ts +55 -0
- package/srv/blockchain/crawler/crawler.js +153 -3
- package/srv/blockchain/crawler/index.d.ts +9 -0
- package/srv/blockchain/crawler/index.js +37 -4
- package/srv/blockchain/crawler/sync-state.d.ts +13 -1
- package/srv/blockchain/crawler/sync-state.js +24 -2
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +20 -0
- package/srv/blockchain/transaction-building/buildooor-tx.js +104 -20
- package/srv/blockchain/wallet-worker/build-request.js +35 -6
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +32 -1
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +91 -29
- package/srv/blockchain/wallet-worker/job-store.d.ts +11 -0
- package/srv/blockchain/wallet-worker/job-store.js +42 -9
- package/srv/cardano-agent-service.cds +150 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +16 -0
- package/srv/cardano-indexer-service.cds +36 -3
- package/srv/cardano-indexer-service.js +3 -0
- package/srv/cardano-service.js +57 -3
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-tx-service.cds +32 -26
- package/srv/cardano-tx-service.js +96 -38
- package/srv/cardano-worker-service.cds +125 -125
- package/srv/server.d.ts +2 -1
- package/srv/server.js +18 -34
- package/srv/utils/agent-grants-config.d.ts +65 -0
- package/srv/utils/agent-grants-config.js +148 -0
- package/srv/utils/agent-grants.d.ts +314 -0
- package/srv/utils/agent-grants.js +821 -0
- package/srv/utils/agent-token-auth.d.ts +19 -0
- package/srv/utils/agent-token-auth.js +81 -0
- package/srv/utils/db-sanitize.d.ts +40 -0
- package/srv/utils/db-sanitize.js +98 -0
- package/srv/utils/errors.d.ts +18 -0
- package/srv/utils/errors.js +24 -1
- package/srv/utils/liveness.d.ts +23 -0
- package/srv/utils/liveness.js +49 -0
- package/srv/utils/mappers.d.ts +27 -0
- package/srv/utils/mappers.js +67 -7
- package/srv/utils/rate-limiter.d.ts +57 -0
- package/srv/utils/rate-limiter.js +126 -0
- package/srv/utils/tx-request-parsers.d.ts +13 -0
- package/srv/utils/tx-request-parsers.js +32 -0
- package/srv/utils/types.d.ts +34 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// This is an automatically generated file. Please do not change its contents manually!
|
|
2
|
+
import * as __ from './../_';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cardano Agent Service (v2.0)
|
|
6
|
+
*
|
|
7
|
+
* Agent grants: scoped, budgeted bearer capabilities an Admin hands to an agent
|
|
8
|
+
* instead of a full user (see AGENT_GRANTS_DESIGN.md).
|
|
9
|
+
*
|
|
10
|
+
* - CreateAgentGrant / UpdateAgentGrant / RotateAgentGrantToken / RevokeAgentGrant:
|
|
11
|
+
* Admin-only administration, rate limited per principal per hour
|
|
12
|
+
* (AGENT_GRANT_ADMIN_RATE_LIMIT, default 10). The token is returned ONCE from
|
|
13
|
+
* CreateAgentGrant and RotateAgentGrantToken and stored as SHA-256 only.
|
|
14
|
+
* - AgentGrants: Admin-only projection (no token hash). A request carrying a token
|
|
15
|
+
* runs as the principal `agent:<grantId>` with the role `agent-grant` and sees
|
|
16
|
+
* exactly its own row through the row-level restriction below.
|
|
17
|
+
* - GetGrantStatus: token self-service — what am I allowed to do, how much budget
|
|
18
|
+
* is left, when do I expire. What an MCP tool needs to describe itself honestly.
|
|
19
|
+
* - GetGrantUsage: admitted calls per service and action over a window — an Admin
|
|
20
|
+
* for any grant, a token for its own (a partner usage view, ledger reconciliation).
|
|
21
|
+
*
|
|
22
|
+
* Names are this repo's PascalCase; semantics mirror NIGHTGATE's agent grants
|
|
23
|
+
* (createAgentGrant / updateAgentGrant / rotateAgentGrantToken / revokeAgentGrant /
|
|
24
|
+
* getGrantUsage), so a gateway drives both products with one code path.
|
|
25
|
+
*
|
|
26
|
+
* A token request never inherits the operator's roles: `@requires: 'Admin'` on the
|
|
27
|
+
* four actions, on PauseWorker / ResumeWorker / pauseCrawler / resumeCrawler and on
|
|
28
|
+
* every other Admin surface therefore refuses it by construction. The allow list,
|
|
29
|
+
* wallet pinning and daily budget are enforced by a before('*') hook on all six
|
|
30
|
+
* ODATANO services (srv/utils/agent-grants.ts). The `x-agent-token` header only
|
|
31
|
+
* reaches the services when cds.requires.odatano-core.agentGrants.enabled is set
|
|
32
|
+
* (srv/utils/agent-token-auth.ts).
|
|
33
|
+
*/
|
|
34
|
+
export default class {
|
|
35
|
+
static readonly GetGrantStatus: typeof GetGrantStatus;
|
|
36
|
+
static readonly CreateAgentGrant: typeof CreateAgentGrant;
|
|
37
|
+
static readonly RevokeAgentGrant: typeof RevokeAgentGrant;
|
|
38
|
+
static readonly RotateAgentGrantToken: typeof RotateAgentGrantToken;
|
|
39
|
+
static readonly UpdateAgentGrant: typeof UpdateAgentGrant;
|
|
40
|
+
static readonly GetGrantUsage: typeof GetGrantUsage;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// entity 'AgentGrant'
|
|
44
|
+
export declare function _AgentGrantAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
45
|
+
new (...args: any[]): {
|
|
46
|
+
ID?: __.Key<string>
|
|
47
|
+
userId?: string
|
|
48
|
+
agentLabel?: string | null
|
|
49
|
+
allowedActions?: string
|
|
50
|
+
walletId?: string | null
|
|
51
|
+
allowedJobKinds?: string | null
|
|
52
|
+
maxJobsPerDay?: number | null
|
|
53
|
+
jobsUsedToday?: number | null
|
|
54
|
+
budgetWindow?: string | null
|
|
55
|
+
validUntil?: __.CdsTimestamp | null
|
|
56
|
+
isActive?: boolean | null
|
|
57
|
+
revokedAt?: __.CdsTimestamp | null
|
|
58
|
+
createdAt?: __.CdsTimestamp | null
|
|
59
|
+
lastUsedAt?: __.CdsTimestamp | null
|
|
60
|
+
} & InstanceType<TBase>
|
|
61
|
+
readonly kind: 'entity';
|
|
62
|
+
readonly keys: __.KeysOf<AgentGrant>;
|
|
63
|
+
readonly elements: __.ElementsOf<AgentGrant>;
|
|
64
|
+
readonly actions: globalThis.Record<never, never>;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Agent grants (v2.0): scoped bearer capabilities an Admin hands to an agent
|
|
68
|
+
* instead of a full user. The token is a capability, not an identity — it is
|
|
69
|
+
* stored as SHA-256 only, and a request carrying it runs as the principal
|
|
70
|
+
* `agent:<ID>` with the role `agent-grant`, never as the operator. Enforcement
|
|
71
|
+
* (allow list, wallet pinning, daily budget) lives in srv/utils/agent-grants.ts;
|
|
72
|
+
* the transport lane that admits `x-agent-token` in srv/utils/agent-token-auth.ts.
|
|
73
|
+
* Admin-only table: creation and revocation happen through CardanoAgentService
|
|
74
|
+
* actions, a token request may read its own row only.
|
|
75
|
+
*/
|
|
76
|
+
export class AgentGrant extends _AgentGrantAspect(__.Entity) {
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Agent grants (v2.0): scoped bearer capabilities an Admin hands to an agent
|
|
80
|
+
* instead of a full user. The token is a capability, not an identity — it is
|
|
81
|
+
* stored as SHA-256 only, and a request carrying it runs as the principal
|
|
82
|
+
* `agent:<ID>` with the role `agent-grant`, never as the operator. Enforcement
|
|
83
|
+
* (allow list, wallet pinning, daily budget) lives in srv/utils/agent-grants.ts;
|
|
84
|
+
* the transport lane that admits `x-agent-token` in srv/utils/agent-token-auth.ts.
|
|
85
|
+
* Admin-only table: creation and revocation happen through CardanoAgentService
|
|
86
|
+
* actions, a token request may read its own row only.
|
|
87
|
+
*/
|
|
88
|
+
export class AgentGrants extends Array<AgentGrant> {
|
|
89
|
+
$count?: number
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// entity 'GrantStatus'
|
|
93
|
+
export declare function _GrantStatusAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
94
|
+
new (...args: any[]): {
|
|
95
|
+
grantId?: string | null
|
|
96
|
+
agentLabel?: string | null
|
|
97
|
+
allowedActions?: Array<string>
|
|
98
|
+
walletId?: string | null
|
|
99
|
+
allowedJobKinds?: Array<string>
|
|
100
|
+
maxJobsPerDay?: number | null
|
|
101
|
+
jobsUsedToday?: number | null
|
|
102
|
+
budgetWindow?: string | null
|
|
103
|
+
validUntil?: __.CdsTimestamp | null
|
|
104
|
+
isActive?: boolean | null
|
|
105
|
+
} & InstanceType<TBase>
|
|
106
|
+
readonly kind: 'type';
|
|
107
|
+
readonly keys: __.KeysOf<GrantStatus>;
|
|
108
|
+
readonly elements: __.ElementsOf<GrantStatus>;
|
|
109
|
+
readonly actions: globalThis.Record<never, never>;
|
|
110
|
+
};
|
|
111
|
+
export class GrantStatus extends _GrantStatusAspect(__.Entity) {
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// entity 'IssuedGrant'
|
|
115
|
+
export declare function _IssuedGrantAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
116
|
+
new (...args: any[]): {
|
|
117
|
+
grantId?: string | null
|
|
118
|
+
token?: string | null
|
|
119
|
+
allowedActions?: Array<string>
|
|
120
|
+
walletId?: string | null
|
|
121
|
+
allowedJobKinds?: Array<string>
|
|
122
|
+
maxJobsPerDay?: number | null
|
|
123
|
+
validUntil?: __.CdsTimestamp | null
|
|
124
|
+
} & InstanceType<TBase>
|
|
125
|
+
readonly kind: 'type';
|
|
126
|
+
readonly keys: __.KeysOf<IssuedGrant>;
|
|
127
|
+
readonly elements: __.ElementsOf<IssuedGrant>;
|
|
128
|
+
readonly actions: globalThis.Record<never, never>;
|
|
129
|
+
};
|
|
130
|
+
export class IssuedGrant extends _IssuedGrantAspect(__.Entity) {
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// entity 'RotatedGrant'
|
|
134
|
+
export declare function _RotatedGrantAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
135
|
+
new (...args: any[]): {
|
|
136
|
+
grantId?: string | null
|
|
137
|
+
token?: string | null
|
|
138
|
+
} & InstanceType<TBase>
|
|
139
|
+
readonly kind: 'type';
|
|
140
|
+
readonly keys: __.KeysOf<RotatedGrant>;
|
|
141
|
+
readonly elements: __.ElementsOf<RotatedGrant>;
|
|
142
|
+
readonly actions: globalThis.Record<never, never>;
|
|
143
|
+
};
|
|
144
|
+
export class RotatedGrant extends _RotatedGrantAspect(__.Entity) {
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// entity 'UpdatedGrant'
|
|
148
|
+
export declare function _UpdatedGrantAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
149
|
+
new (...args: any[]): {
|
|
150
|
+
grantId?: string | null
|
|
151
|
+
updated?: Array<string>
|
|
152
|
+
} & InstanceType<TBase>
|
|
153
|
+
readonly kind: 'type';
|
|
154
|
+
readonly keys: __.KeysOf<UpdatedGrant>;
|
|
155
|
+
readonly elements: __.ElementsOf<UpdatedGrant>;
|
|
156
|
+
readonly actions: globalThis.Record<never, never>;
|
|
157
|
+
};
|
|
158
|
+
export class UpdatedGrant extends _UpdatedGrantAspect(__.Entity) {
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// entity 'GrantUsageCall'
|
|
162
|
+
export declare function _GrantUsageCallAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
163
|
+
new (...args: any[]): {
|
|
164
|
+
service?: string | null
|
|
165
|
+
action?: string | null
|
|
166
|
+
count?: number | null
|
|
167
|
+
refunded?: number | null
|
|
168
|
+
} & InstanceType<TBase>
|
|
169
|
+
readonly kind: 'type';
|
|
170
|
+
readonly keys: __.KeysOf<GrantUsageCall>;
|
|
171
|
+
readonly elements: __.ElementsOf<GrantUsageCall>;
|
|
172
|
+
readonly actions: globalThis.Record<never, never>;
|
|
173
|
+
};
|
|
174
|
+
export class GrantUsageCall extends _GrantUsageCallAspect(__.Entity) {
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// entity 'GrantUsage'
|
|
178
|
+
export declare function _GrantUsageAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
179
|
+
new (...args: any[]): {
|
|
180
|
+
grantId?: string | null
|
|
181
|
+
since?: __.CdsTimestamp | null
|
|
182
|
+
until?: __.CdsTimestamp | null
|
|
183
|
+
calls?: Array<GrantUsageCall>
|
|
184
|
+
total?: number | null
|
|
185
|
+
jobsUsedToday?: number | null
|
|
186
|
+
maxJobsPerDay?: number | null
|
|
187
|
+
} & InstanceType<TBase>
|
|
188
|
+
readonly kind: 'type';
|
|
189
|
+
readonly keys: __.KeysOf<GrantUsage>;
|
|
190
|
+
readonly elements: __.ElementsOf<GrantUsage>;
|
|
191
|
+
readonly actions: globalThis.Record<never, never>;
|
|
192
|
+
};
|
|
193
|
+
export class GrantUsage extends _GrantUsageAspect(__.Entity) {
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
export declare const GetGrantStatus: {
|
|
198
|
+
// positional
|
|
199
|
+
(): globalThis.Promise<GrantStatus | null> | GrantStatus | null
|
|
200
|
+
// named
|
|
201
|
+
({}: globalThis.Record<never, never>): globalThis.Promise<GrantStatus | null> | GrantStatus | null
|
|
202
|
+
// metadata (do not use)
|
|
203
|
+
__parameters: globalThis.Record<never, never>, __returns: globalThis.Promise<GrantStatus | null> | GrantStatus | null, __self: never
|
|
204
|
+
kind: 'function'
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export declare const CreateAgentGrant: {
|
|
208
|
+
// positional
|
|
209
|
+
(allowedActions: Array<string>, walletId: string | null, allowedJobKinds: Array<string>, maxJobsPerDay: number | null, validUntil: __.CdsTimestamp | null, agentLabel: string | null): globalThis.Promise<IssuedGrant | null> | IssuedGrant | null
|
|
210
|
+
// named
|
|
211
|
+
({allowedActions, walletId, allowedJobKinds, maxJobsPerDay, validUntil, agentLabel}: {allowedActions?: Array<string>, walletId?: string | null, allowedJobKinds?: Array<string>, maxJobsPerDay?: number | null, validUntil?: __.CdsTimestamp | null, agentLabel?: string | null}): globalThis.Promise<IssuedGrant | null> | IssuedGrant | null
|
|
212
|
+
// metadata (do not use)
|
|
213
|
+
__parameters: {allowedActions?: Array<string>, walletId?: string | null, allowedJobKinds?: Array<string>, maxJobsPerDay?: number | null, validUntil?: __.CdsTimestamp | null, agentLabel?: string | null}, __returns: globalThis.Promise<IssuedGrant | null> | IssuedGrant | null, __self: never
|
|
214
|
+
kind: 'action'
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export declare const RevokeAgentGrant: {
|
|
218
|
+
// positional
|
|
219
|
+
(grantId: string | null): globalThis.Promise<boolean | null> | boolean | null
|
|
220
|
+
// named
|
|
221
|
+
({grantId}: {grantId?: string | null}): globalThis.Promise<boolean | null> | boolean | null
|
|
222
|
+
// metadata (do not use)
|
|
223
|
+
__parameters: {grantId?: string | null}, __returns: globalThis.Promise<boolean | null> | boolean | null, __self: never
|
|
224
|
+
kind: 'action'
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export declare const RotateAgentGrantToken: {
|
|
228
|
+
// positional
|
|
229
|
+
(grantId: string | null): globalThis.Promise<RotatedGrant | null> | RotatedGrant | null
|
|
230
|
+
// named
|
|
231
|
+
({grantId}: {grantId?: string | null}): globalThis.Promise<RotatedGrant | null> | RotatedGrant | null
|
|
232
|
+
// metadata (do not use)
|
|
233
|
+
__parameters: {grantId?: string | null}, __returns: globalThis.Promise<RotatedGrant | null> | RotatedGrant | null, __self: never
|
|
234
|
+
kind: 'action'
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export declare const UpdateAgentGrant: {
|
|
238
|
+
// positional
|
|
239
|
+
(grantId: string | null, agentLabel: string | null, allowedActions: Array<string>, allowedJobKinds: Array<string>, maxJobsPerDay: number | null, validUntil: __.CdsTimestamp | null): globalThis.Promise<UpdatedGrant | null> | UpdatedGrant | null
|
|
240
|
+
// named
|
|
241
|
+
({grantId, agentLabel, allowedActions, allowedJobKinds, maxJobsPerDay, validUntil}: {grantId?: string | null, agentLabel?: string | null, allowedActions?: Array<string>, allowedJobKinds?: Array<string>, maxJobsPerDay?: number | null, validUntil?: __.CdsTimestamp | null}): globalThis.Promise<UpdatedGrant | null> | UpdatedGrant | null
|
|
242
|
+
// metadata (do not use)
|
|
243
|
+
__parameters: {grantId?: string | null, agentLabel?: string | null, allowedActions?: Array<string>, allowedJobKinds?: Array<string>, maxJobsPerDay?: number | null, validUntil?: __.CdsTimestamp | null}, __returns: globalThis.Promise<UpdatedGrant | null> | UpdatedGrant | null, __self: never
|
|
244
|
+
kind: 'action'
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export declare const GetGrantUsage: {
|
|
248
|
+
// positional
|
|
249
|
+
(grantId: string | null, since: __.CdsTimestamp | null, until: __.CdsTimestamp | null): globalThis.Promise<GrantUsage | null> | GrantUsage | null
|
|
250
|
+
// named
|
|
251
|
+
({grantId, since, until}: {grantId?: string | null, since?: __.CdsTimestamp | null, until?: __.CdsTimestamp | null}): globalThis.Promise<GrantUsage | null> | GrantUsage | null
|
|
252
|
+
// metadata (do not use)
|
|
253
|
+
__parameters: {grantId?: string | null, since?: __.CdsTimestamp | null, until?: __.CdsTimestamp | null}, __returns: globalThis.Promise<GrantUsage | null> | GrantUsage | null, __self: never
|
|
254
|
+
kind: 'function'
|
|
255
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// This is an automatically generated file. Please do not change its contents manually!
|
|
2
|
+
const { createEntityProxy } = require('./../_')
|
|
3
|
+
// service
|
|
4
|
+
const CardanoAgentService = { name: 'CardanoAgentService' }
|
|
5
|
+
module.exports = CardanoAgentService
|
|
6
|
+
module.exports.CardanoAgentService = CardanoAgentService
|
|
7
|
+
// AgentGrants
|
|
8
|
+
module.exports.AgentGrant = createEntityProxy(['CardanoAgentService', 'AgentGrants'], { target: { is_singular: true } })
|
|
9
|
+
module.exports.AgentGrants = createEntityProxy(['CardanoAgentService', 'AgentGrants'], { target: { is_singular: false }})
|
|
10
|
+
// GrantStatus
|
|
11
|
+
module.exports.GrantStatus = createEntityProxy(['CardanoAgentService', 'GrantStatus'], { target: { is_singular: true } })
|
|
12
|
+
module.exports.__Array_GrantStatus_ = createEntityProxy(['CardanoAgentService', 'GrantStatus'], { target: { is_singular: false }})
|
|
13
|
+
// IssuedGrant
|
|
14
|
+
module.exports.IssuedGrant = createEntityProxy(['CardanoAgentService', 'IssuedGrant'], { target: { is_singular: true } })
|
|
15
|
+
module.exports.__Array_IssuedGrant_ = createEntityProxy(['CardanoAgentService', 'IssuedGrant'], { target: { is_singular: false }})
|
|
16
|
+
// RotatedGrant
|
|
17
|
+
module.exports.RotatedGrant = createEntityProxy(['CardanoAgentService', 'RotatedGrant'], { target: { is_singular: true } })
|
|
18
|
+
module.exports.__Array_RotatedGrant_ = createEntityProxy(['CardanoAgentService', 'RotatedGrant'], { target: { is_singular: false }})
|
|
19
|
+
// UpdatedGrant
|
|
20
|
+
module.exports.UpdatedGrant = createEntityProxy(['CardanoAgentService', 'UpdatedGrant'], { target: { is_singular: true } })
|
|
21
|
+
module.exports.__Array_UpdatedGrant_ = createEntityProxy(['CardanoAgentService', 'UpdatedGrant'], { target: { is_singular: false }})
|
|
22
|
+
// GrantUsageCall
|
|
23
|
+
module.exports.GrantUsageCall = createEntityProxy(['CardanoAgentService', 'GrantUsageCall'], { target: { is_singular: true } })
|
|
24
|
+
module.exports.__Array_GrantUsageCall_ = createEntityProxy(['CardanoAgentService', 'GrantUsageCall'], { target: { is_singular: false }})
|
|
25
|
+
// GrantUsage
|
|
26
|
+
module.exports.GrantUsage = createEntityProxy(['CardanoAgentService', 'GrantUsage'], { target: { is_singular: true } })
|
|
27
|
+
module.exports.__Array_GrantUsage_ = createEntityProxy(['CardanoAgentService', 'GrantUsage'], { target: { is_singular: false }})
|
|
28
|
+
// events
|
|
29
|
+
// actions
|
|
30
|
+
module.exports.GetGrantStatus = 'GetGrantStatus'
|
|
31
|
+
module.exports.CreateAgentGrant = 'CreateAgentGrant'
|
|
32
|
+
module.exports.RevokeAgentGrant = 'RevokeAgentGrant'
|
|
33
|
+
module.exports.RotateAgentGrantToken = 'RotateAgentGrantToken'
|
|
34
|
+
module.exports.UpdateAgentGrant = 'UpdateAgentGrant'
|
|
35
|
+
module.exports.GetGrantUsage = 'GetGrantUsage'
|
|
36
|
+
// enums
|
|
@@ -10,11 +10,19 @@ 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
|
-
*
|
|
14
|
-
*
|
|
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;
|
|
25
|
+
static readonly getLiveness: typeof getLiveness;
|
|
18
26
|
static readonly pauseCrawler: typeof pauseCrawler;
|
|
19
27
|
static readonly resumeCrawler: typeof resumeCrawler;
|
|
20
28
|
}
|
|
@@ -93,6 +101,23 @@ export declare function _CrawlerStatusAspect<TBase extends new (...args: any[])
|
|
|
93
101
|
export class CrawlerStatus extends _CrawlerStatusAspect(__.Entity) {
|
|
94
102
|
}
|
|
95
103
|
|
|
104
|
+
// entity 'Liveness'
|
|
105
|
+
export declare function _LivenessAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
106
|
+
new (...args: any[]): {
|
|
107
|
+
status?: string | null
|
|
108
|
+
timestamp?: __.CdsTimestamp | null
|
|
109
|
+
uptime?: number | null
|
|
110
|
+
version?: string | null
|
|
111
|
+
network?: string | null
|
|
112
|
+
} & InstanceType<TBase>
|
|
113
|
+
readonly kind: 'type';
|
|
114
|
+
readonly keys: __.KeysOf<Liveness>;
|
|
115
|
+
readonly elements: __.ElementsOf<Liveness>;
|
|
116
|
+
readonly actions: globalThis.Record<never, never>;
|
|
117
|
+
};
|
|
118
|
+
export class Liveness extends _LivenessAspect(__.Entity) {
|
|
119
|
+
}
|
|
120
|
+
|
|
96
121
|
// event
|
|
97
122
|
export declare class blockIndexed {
|
|
98
123
|
readonly kind: 'event';
|
|
@@ -121,6 +146,16 @@ export declare const getStatus: {
|
|
|
121
146
|
kind: 'function'
|
|
122
147
|
}
|
|
123
148
|
|
|
149
|
+
export declare const getLiveness: {
|
|
150
|
+
// positional
|
|
151
|
+
(): globalThis.Promise<Liveness | null> | Liveness | null
|
|
152
|
+
// named
|
|
153
|
+
({}: globalThis.Record<never, never>): globalThis.Promise<Liveness | null> | Liveness | null
|
|
154
|
+
// metadata (do not use)
|
|
155
|
+
__parameters: globalThis.Record<never, never>, __returns: globalThis.Promise<Liveness | null> | Liveness | null, __self: never
|
|
156
|
+
kind: 'function'
|
|
157
|
+
}
|
|
158
|
+
|
|
124
159
|
export declare const pauseCrawler: {
|
|
125
160
|
// positional
|
|
126
161
|
(): globalThis.Promise<boolean | null> | boolean | null
|
|
@@ -13,11 +13,15 @@ module.exports.ReorgLog_ = createEntityProxy(['CardanoIndexerService', 'ReorgLog
|
|
|
13
13
|
// CrawlerStatus
|
|
14
14
|
module.exports.CrawlerStatus = createEntityProxy(['CardanoIndexerService', 'CrawlerStatus'], { target: { is_singular: true } })
|
|
15
15
|
module.exports.__Array_CrawlerStatus_ = createEntityProxy(['CardanoIndexerService', 'CrawlerStatus'], { target: { is_singular: false }})
|
|
16
|
+
// Liveness
|
|
17
|
+
module.exports.Liveness = createEntityProxy(['CardanoIndexerService', 'Liveness'], { target: { is_singular: true } })
|
|
18
|
+
module.exports.__Array_Liveness_ = createEntityProxy(['CardanoIndexerService', 'Liveness'], { target: { is_singular: false }})
|
|
16
19
|
// events
|
|
17
20
|
module.exports.blockIndexed = 'CardanoIndexerService.blockIndexed'
|
|
18
21
|
module.exports.reorg = 'CardanoIndexerService.reorg'
|
|
19
22
|
// actions
|
|
20
23
|
module.exports.getStatus = 'getStatus'
|
|
24
|
+
module.exports.getLiveness = 'getLiveness'
|
|
21
25
|
module.exports.pauseCrawler = 'pauseCrawler'
|
|
22
26
|
module.exports.resumeCrawler = 'resumeCrawler'
|
|
23
27
|
// enums
|
|
@@ -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
|
-
*
|
|
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;
|
|
@@ -196,17 +196,17 @@ export declare function _TransactionSubmissionAspect<TBase extends new (...args:
|
|
|
196
196
|
};
|
|
197
197
|
/**
|
|
198
198
|
* TransactionSubmissions status flow:
|
|
199
|
-
* pending
|
|
200
|
-
* submitted
|
|
201
|
-
* pending | submitted
|
|
199
|
+
* pending -> [submit to chain] -> submitted (internal, in SubmitTransaction handler)
|
|
200
|
+
* submitted -> [CheckSubmissionStatus] confirmed | stays submitted (conditional)
|
|
201
|
+
* pending | submitted -> failed (blockchain error)
|
|
202
202
|
*/
|
|
203
203
|
export class TransactionSubmission extends _TransactionSubmissionAspect(__.Entity) {
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
206
206
|
* TransactionSubmissions status flow:
|
|
207
|
-
* pending
|
|
208
|
-
* submitted
|
|
209
|
-
* pending | submitted
|
|
207
|
+
* pending -> [submit to chain] -> submitted (internal, in SubmitTransaction handler)
|
|
208
|
+
* submitted -> [CheckSubmissionStatus] confirmed | stays submitted (conditional)
|
|
209
|
+
* pending | submitted -> failed (blockchain error)
|
|
210
210
|
*/
|
|
211
211
|
export class TransactionSubmissions extends Array<TransactionSubmission> {
|
|
212
212
|
$count?: number
|
|
@@ -420,11 +420,11 @@ export declare const BuildMultiAssetTransaction: {
|
|
|
420
420
|
|
|
421
421
|
export declare const BuildMintTransaction: {
|
|
422
422
|
// positional
|
|
423
|
-
(senderAddress: _.Bech32 | null, recipientAddress: _.Bech32 | null, lovelaceAmount: _.Lovelace | null, mintActionsJson: string | null, mintingPolicyScript: string | null, changeAddress: _.Bech32 | null, requiredSignersJson: string | null, scriptParamsJson: string | null, inlineDatumJson: string | null, mintRedeemerJson: string | null, lockOnScript: boolean | null, forceInputsJson: string | null, referenceInputsJson: string | null, metadataJson: string | null, referenceScriptHex: string | null, validityStartMs: string | null, validityEndMs: string | null): globalThis.Promise<TransactionBuild | null> | TransactionBuild | null
|
|
423
|
+
(senderAddress: _.Bech32 | null, recipientAddress: _.Bech32 | null, lovelaceAmount: _.Lovelace | null, mintActionsJson: string | null, mintingPolicyScript: string | null, changeAddress: _.Bech32 | null, requiredSignersJson: string | null, scriptParamsJson: string | null, inlineDatumJson: string | null, mintRedeemerJson: string | null, lockOnScript: boolean | null, forceInputsJson: string | null, referenceInputsJson: string | null, extraOutputsJson: string | null, metadataJson: string | null, referenceScriptHex: string | null, validityStartMs: string | null, validityEndMs: string | null): globalThis.Promise<TransactionBuild | null> | TransactionBuild | null
|
|
424
424
|
// named
|
|
425
|
-
({senderAddress, recipientAddress, lovelaceAmount, mintActionsJson, mintingPolicyScript, changeAddress, requiredSignersJson, scriptParamsJson, inlineDatumJson, mintRedeemerJson, lockOnScript, forceInputsJson, referenceInputsJson, metadataJson, referenceScriptHex, validityStartMs, validityEndMs}: {senderAddress?: _.Bech32 | null, recipientAddress?: _.Bech32 | null, lovelaceAmount?: _.Lovelace | null, mintActionsJson?: string | null, mintingPolicyScript?: string | null, changeAddress?: _.Bech32 | null, requiredSignersJson?: string | null, scriptParamsJson?: string | null, inlineDatumJson?: string | null, mintRedeemerJson?: string | null, lockOnScript?: boolean | null, forceInputsJson?: string | null, referenceInputsJson?: string | null, metadataJson?: string | null, referenceScriptHex?: string | null, validityStartMs?: string | null, validityEndMs?: string | null}): globalThis.Promise<TransactionBuild | null> | TransactionBuild | null
|
|
425
|
+
({senderAddress, recipientAddress, lovelaceAmount, mintActionsJson, mintingPolicyScript, changeAddress, requiredSignersJson, scriptParamsJson, inlineDatumJson, mintRedeemerJson, lockOnScript, forceInputsJson, referenceInputsJson, extraOutputsJson, metadataJson, referenceScriptHex, validityStartMs, validityEndMs}: {senderAddress?: _.Bech32 | null, recipientAddress?: _.Bech32 | null, lovelaceAmount?: _.Lovelace | null, mintActionsJson?: string | null, mintingPolicyScript?: string | null, changeAddress?: _.Bech32 | null, requiredSignersJson?: string | null, scriptParamsJson?: string | null, inlineDatumJson?: string | null, mintRedeemerJson?: string | null, lockOnScript?: boolean | null, forceInputsJson?: string | null, referenceInputsJson?: string | null, extraOutputsJson?: string | null, metadataJson?: string | null, referenceScriptHex?: string | null, validityStartMs?: string | null, validityEndMs?: string | null}): globalThis.Promise<TransactionBuild | null> | TransactionBuild | null
|
|
426
426
|
// metadata (do not use)
|
|
427
|
-
__parameters: {senderAddress?: _.Bech32 | null, recipientAddress?: _.Bech32 | null, lovelaceAmount?: _.Lovelace | null, mintActionsJson?: string | null, mintingPolicyScript?: string | null, changeAddress?: _.Bech32 | null, requiredSignersJson?: string | null, scriptParamsJson?: string | null, inlineDatumJson?: string | null, mintRedeemerJson?: string | null, lockOnScript?: boolean | null, forceInputsJson?: string | null, referenceInputsJson?: string | null, metadataJson?: string | null, referenceScriptHex?: string | null, validityStartMs?: string | null, validityEndMs?: string | null}, __returns: globalThis.Promise<TransactionBuild | null> | TransactionBuild | null, __self: never
|
|
427
|
+
__parameters: {senderAddress?: _.Bech32 | null, recipientAddress?: _.Bech32 | null, lovelaceAmount?: _.Lovelace | null, mintActionsJson?: string | null, mintingPolicyScript?: string | null, changeAddress?: _.Bech32 | null, requiredSignersJson?: string | null, scriptParamsJson?: string | null, inlineDatumJson?: string | null, mintRedeemerJson?: string | null, lockOnScript?: boolean | null, forceInputsJson?: string | null, referenceInputsJson?: string | null, extraOutputsJson?: string | null, metadataJson?: string | null, referenceScriptHex?: string | null, validityStartMs?: string | null, validityEndMs?: string | null}, __returns: globalThis.Promise<TransactionBuild | null> | TransactionBuild | null, __self: never
|
|
428
428
|
kind: 'action'
|
|
429
429
|
}
|
|
430
430
|
|
|
@@ -958,3 +958,89 @@ export class CardanoWalletJob extends _CardanoWalletJobAspect(__.Entity) {
|
|
|
958
958
|
export class CardanoWalletJobs extends Array<CardanoWalletJob> {
|
|
959
959
|
$count?: number
|
|
960
960
|
}
|
|
961
|
+
|
|
962
|
+
// entity 'CardanoAgentGrant'
|
|
963
|
+
export declare function _CardanoAgentGrantAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
964
|
+
new (...args: any[]): {
|
|
965
|
+
ID?: __.Key<string>
|
|
966
|
+
userId?: string
|
|
967
|
+
agentLabel?: string | null
|
|
968
|
+
tokenHash?: string
|
|
969
|
+
allowedActions?: string
|
|
970
|
+
walletId?: string | null
|
|
971
|
+
allowedJobKinds?: string | null
|
|
972
|
+
maxJobsPerDay?: number | null
|
|
973
|
+
jobsUsedToday?: number | null
|
|
974
|
+
budgetWindow?: string | null
|
|
975
|
+
validUntil?: __.CdsTimestamp | null
|
|
976
|
+
isActive?: boolean | null
|
|
977
|
+
revokedAt?: __.CdsTimestamp | null
|
|
978
|
+
createdAt?: __.CdsTimestamp | null
|
|
979
|
+
lastUsedAt?: __.CdsTimestamp | null
|
|
980
|
+
} & InstanceType<TBase>
|
|
981
|
+
readonly kind: 'entity';
|
|
982
|
+
readonly keys: __.KeysOf<CardanoAgentGrant>;
|
|
983
|
+
readonly elements: __.ElementsOf<CardanoAgentGrant>;
|
|
984
|
+
readonly actions: globalThis.Record<never, never>;
|
|
985
|
+
};
|
|
986
|
+
/**
|
|
987
|
+
* Agent grants (v2.0): scoped bearer capabilities an Admin hands to an agent
|
|
988
|
+
* instead of a full user. The token is a capability, not an identity — it is
|
|
989
|
+
* stored as SHA-256 only, and a request carrying it runs as the principal
|
|
990
|
+
* `agent:<ID>` with the role `agent-grant`, never as the operator. Enforcement
|
|
991
|
+
* (allow list, wallet pinning, daily budget) lives in srv/utils/agent-grants.ts;
|
|
992
|
+
* the transport lane that admits `x-agent-token` in srv/utils/agent-token-auth.ts.
|
|
993
|
+
* Admin-only table: creation and revocation happen through CardanoAgentService
|
|
994
|
+
* actions, a token request may read its own row only.
|
|
995
|
+
*/
|
|
996
|
+
export class CardanoAgentGrant extends _CardanoAgentGrantAspect(__.Entity) {
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Agent grants (v2.0): scoped bearer capabilities an Admin hands to an agent
|
|
1000
|
+
* instead of a full user. The token is a capability, not an identity — it is
|
|
1001
|
+
* stored as SHA-256 only, and a request carrying it runs as the principal
|
|
1002
|
+
* `agent:<ID>` with the role `agent-grant`, never as the operator. Enforcement
|
|
1003
|
+
* (allow list, wallet pinning, daily budget) lives in srv/utils/agent-grants.ts;
|
|
1004
|
+
* the transport lane that admits `x-agent-token` in srv/utils/agent-token-auth.ts.
|
|
1005
|
+
* Admin-only table: creation and revocation happen through CardanoAgentService
|
|
1006
|
+
* actions, a token request may read its own row only.
|
|
1007
|
+
*/
|
|
1008
|
+
export class CardanoAgentGrants extends Array<CardanoAgentGrant> {
|
|
1009
|
+
$count?: number
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// entity 'CardanoAgentGrantUsage'
|
|
1013
|
+
export declare function _CardanoAgentGrantUsageAspect<TBase extends new (...args: any[]) => object>(Base: TBase): {
|
|
1014
|
+
new (...args: any[]): {
|
|
1015
|
+
grant?: __.Key<__.Association.to<CardanoAgentGrant>>
|
|
1016
|
+
grant_ID?: __.Key<string>
|
|
1017
|
+
day?: __.Key<string>
|
|
1018
|
+
service?: __.Key<string>
|
|
1019
|
+
action?: __.Key<string>
|
|
1020
|
+
calls?: number | null
|
|
1021
|
+
refunded?: number | null
|
|
1022
|
+
} & InstanceType<TBase>
|
|
1023
|
+
readonly kind: 'entity';
|
|
1024
|
+
readonly keys: __.KeysOf<CardanoAgentGrantUsage>;
|
|
1025
|
+
readonly elements: __.ElementsOf<CardanoAgentGrantUsage>;
|
|
1026
|
+
readonly actions: globalThis.Record<never, never>;
|
|
1027
|
+
};
|
|
1028
|
+
/**
|
|
1029
|
+
* Daily per-action counters of admitted calls under a grant (feeds
|
|
1030
|
+
* CardanoAgentService.GetGrantUsage). Written by the enforcement hook next to
|
|
1031
|
+
* the daily budget: `calls + 1` when a call is admitted, `refunded + 1` when the
|
|
1032
|
+
* handler then refuses its input. Not exposed as an entity — the function is
|
|
1033
|
+
* the contract. A few dozen rows per grant and day at most; no retention job yet.
|
|
1034
|
+
*/
|
|
1035
|
+
export class CardanoAgentGrantUsage extends _CardanoAgentGrantUsageAspect(__.Entity) {
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Daily per-action counters of admitted calls under a grant (feeds
|
|
1039
|
+
* CardanoAgentService.GetGrantUsage). Written by the enforcement hook next to
|
|
1040
|
+
* the daily budget: `calls + 1` when a call is admitted, `refunded + 1` when the
|
|
1041
|
+
* handler then refuses its input. Not exposed as an entity — the function is
|
|
1042
|
+
* the contract. A few dozen rows per grant and day at most; no retention job yet.
|
|
1043
|
+
*/
|
|
1044
|
+
export class CardanoAgentGrantUsage_ extends Array<CardanoAgentGrantUsage> {
|
|
1045
|
+
$count?: number
|
|
1046
|
+
}
|
|
@@ -105,6 +105,12 @@ module.exports.CardanoWorkerWallets = createEntityProxy(['odatano.cardano', 'Car
|
|
|
105
105
|
// CardanoWalletJobs
|
|
106
106
|
module.exports.CardanoWalletJob = createEntityProxy(['odatano.cardano', 'CardanoWalletJobs'], { target: { is_singular: true } })
|
|
107
107
|
module.exports.CardanoWalletJobs = createEntityProxy(['odatano.cardano', 'CardanoWalletJobs'], { target: { is_singular: false }})
|
|
108
|
+
// CardanoAgentGrants
|
|
109
|
+
module.exports.CardanoAgentGrant = createEntityProxy(['odatano.cardano', 'CardanoAgentGrants'], { target: { is_singular: true } })
|
|
110
|
+
module.exports.CardanoAgentGrants = createEntityProxy(['odatano.cardano', 'CardanoAgentGrants'], { target: { is_singular: false }})
|
|
111
|
+
// CardanoAgentGrantUsage
|
|
112
|
+
module.exports.CardanoAgentGrantUsage = createEntityProxy(['odatano.cardano', 'CardanoAgentGrantUsage'], { target: { is_singular: true } })
|
|
113
|
+
module.exports.CardanoAgentGrantUsage_ = createEntityProxy(['odatano.cardano', 'CardanoAgentGrantUsage'], { target: { is_singular: false }})
|
|
108
114
|
// events
|
|
109
115
|
// actions
|
|
110
116
|
// enums
|
package/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/npm/@odatano/brand@1/logos/odatano-core-logo-on-dark.svg">
|
|
4
|
+
<img src="https://cdn.jsdelivr.net/npm/@odatano/brand@1/logos/odatano-core-logo.svg" alt="ODATANO CORE" height="84">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
8
|
# Enterprise OData Services for the Cardano Blockchain
|
|
4
9
|
|
|
@@ -88,6 +93,10 @@ Service available at `http://localhost:4004`. See the [Quick Start Guide](docs/Q
|
|
|
88
93
|
> **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
94
|
>
|
|
90
95
|
> 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).
|
|
96
|
+
>
|
|
97
|
+
> The Docker image runs `NODE_ENV=production` with HTTP basic auth via `@odatano/cap-auth` (`ODATANO_HTTP_PASSWORD` required, user `ODATANO_HTTP_USER` default `odatano`, roles `ODATANO_HTTP_ROLES` default `Admin`; 20 failed attempts per 15 min per client address and user, then 429). `ODATANO_AUTH=dummy` disables authentication for local testing only. `getLiveness()` and `VerifyDataSignature` stay anonymous.
|
|
98
|
+
>
|
|
99
|
+
> Database of the image: `ODATANO_DB_URL=postgres://user:pw@host:5432/db` selects PostgreSQL (schema deployed on every boot); otherwise SQLite at `ODATANO_DB_PATH` (default `/data/db.sqlite`). `docker compose run --rm --no-deps odatano migrate --from /data/db.sqlite` copies an existing SQLite file into a freshly deployed PostgreSQL.
|
|
91
100
|
|
|
92
101
|
## Services
|
|
93
102
|
|
|
@@ -98,6 +107,7 @@ Service available at `http://localhost:4004`. See the [Quick Start Guide](docs/Q
|
|
|
98
107
|
| CardanoSignService | `/odata/v4/cardano-sign/` | External signing + HSM (9 actions) |
|
|
99
108
|
| CardanoIndexerService | `/odata/v4/cardano-indexer/` | Chain crawler / pre-sync control (v2.0, off by default) |
|
|
100
109
|
| CardanoWorkerService | `/odata/v4/cardano-worker/` | Asynchronous wallet jobs (v2.0, off by default) |
|
|
110
|
+
| CardanoAgentService | `/odata/v4/cardano-agent/` | Agent grants: scoped bearer tokens for agents (v2.0, off by default) |
|
|
101
111
|
|
|
102
112
|
Both v2.0 services also publish **CAP events**, so a consumer can subscribe instead of polling —
|
|
103
113
|
in-process, no broker required:
|
|
@@ -107,12 +117,60 @@ in-process, no broker required:
|
|
|
107
117
|
(await cds.connect.to('CardanoIndexerService')).on('blockIndexed', ({ data }) => …)
|
|
108
118
|
```
|
|
109
119
|
|
|
120
|
+
## Agent grants (v2.0, off by default)
|
|
121
|
+
|
|
122
|
+
Hand an agent a **scoped, budgeted token** instead of a user.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
AGENT_GRANTS_ENABLED=true # or cds.requires.odatano-core.agentGrants.enabled
|
|
126
|
+
AGENT_GRANTS_DELEGATE=mocked # CAP auth kind that keeps authenticating non-token requests (default: configured kind)
|
|
127
|
+
AGENT_GRANT_ADMIN_RATE_LIMIT=10 # grant administration calls per principal per hour (or agentGrants.adminRateLimit)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
1. An **Admin** issues a grant (`POST /odata/v4/cardano-agent/CreateAgentGrant`): an allow list of
|
|
131
|
+
actions, optionally a worker `walletId` (required for `SubmitWalletJob`/`CancelJob`), allowed job
|
|
132
|
+
kinds, a daily budget and an expiry. The response carries the token `odat_…` **once**; the
|
|
133
|
+
server stores only its SHA-256.
|
|
134
|
+
2. The agent sends `x-agent-token: odat_…` on any of the six service paths. It runs as the principal
|
|
135
|
+
`agent:<grantId>` with the single role `agent-grant`, never as the operator: every
|
|
136
|
+
`@requires: 'Admin'` surface (pause/resume, HSM signing, grant administration) refuses it by
|
|
137
|
+
construction. Reads and compute-only actions are always allowed; allow-listed actions each cost
|
|
138
|
+
one budget unit per UTC day (a build is the service an agent buys); everything else is 403.
|
|
139
|
+
Wallet jobs are pinned to the grant's wallet and visible only to the grant that queued them.
|
|
140
|
+
3. `GET /odata/v4/cardano-agent/GetGrantStatus()` tells the agent what it may do and how much budget
|
|
141
|
+
is left; `RevokeAgentGrant` turns the token into an unknown token immediately.
|
|
142
|
+
4. Lifecycle (Admin, same semantics as NIGHTGATE's agent grants so a gateway drives both with one
|
|
143
|
+
code path): `UpdateAgentGrant` changes label, allow list, job kinds, daily budget or expiry
|
|
144
|
+
(absent = untouched, explicit `null` = cleared; the wallet binding is immutable, 409
|
|
145
|
+
`GRANT_REVOKED` on a revoked grant); `RotateAgentGrantToken` returns a fresh token once, the old
|
|
146
|
+
one is unknown from the next request; `GetGrantUsage(grantId, since, until)` lists admitted calls
|
|
147
|
+
per service and action over up to 366 days (an Admin for any grant, a token for its own). All
|
|
148
|
+
administration calls share the per-principal hourly rate limit above.
|
|
149
|
+
|
|
150
|
+
Grantable: `Build*`, `SetCollateral`, `CreateSigningRequest`, `VerifySignature`, `Submit*`,
|
|
151
|
+
`CheckSubmissionStatus`, `SubmitWalletJob`, `CancelJob`. Never: `SignWithHsm*`, `Pause*`/`Resume*`,
|
|
152
|
+
`pauseCrawler`/`resumeCrawler`, grant administration.
|
|
153
|
+
|
|
154
|
+
Programmatic seams for other packages (`@odatano/x402` sells grants against a 402 payment):
|
|
155
|
+
`issueAgentGrant()`, `updateAgentGrant()`, `rotateAgentGrantToken()`, `revokeAgentGrantById()`,
|
|
156
|
+
`getGrantUsage()`, `registerTransportLane()` from `@odatano/core`.
|
|
157
|
+
|
|
158
|
+
## Liveness probe
|
|
159
|
+
|
|
160
|
+
`GET /odata/v4/cardano-indexer/getLiveness()` answers `200 { status: "alive", timestamp, uptime,
|
|
161
|
+
version, network }` **without credentials** (`@requires: 'any'`) as long as the process runs — no
|
|
162
|
+
backend or DB probe, no secrets. The Docker `HEALTHCHECK`, compose and upstream probes use it
|
|
163
|
+
instead of the service document, so a wrong operator password no longer reads as "ODATANO down".
|
|
164
|
+
Readiness (crawler, worker, backends) stays authenticated: `getStatus()`, `GetWorkerStatus()`,
|
|
165
|
+
`GetNetworkInformation`.
|
|
166
|
+
|
|
110
167
|
## Requirements
|
|
111
168
|
|
|
112
169
|
- **Node.js >= 22.5** and **@sap/cds >= 10** (peer dependency). CAP 9 hosts cannot load `@odatano/core@2`.
|
|
113
|
-
- Upgrading a consumer from 1.x: run **`cds deploy`**. 2.0 adds
|
|
114
|
-
`CardanoReorgLog`, `CardanoWorkerWallets`, `CardanoWalletJobs
|
|
115
|
-
|
|
170
|
+
- Upgrading a consumer from 1.x: run **`cds deploy`**. 2.0 adds six tables (`CardanoSyncState`,
|
|
171
|
+
`CardanoReorgLog`, `CardanoWorkerWallets`, `CardanoWalletJobs`, `CardanoAgentGrants`,
|
|
172
|
+
`CardanoAgentGrantUsage`) plus a `dedupKey` column; without the redeploy the new services answer
|
|
173
|
+
`no such table` while the old ones keep working.
|
|
116
174
|
|
|
117
175
|
## Documentation
|
|
118
176
|
|