@odatano/core 2.0.0-rc.3 → 2.0.0-rc.5
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 +151 -0
- package/@cds-models/CardanoAgentService/index.js +21 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +9 -9
- package/@cds-models/odatano/cardano/index.d.ts +50 -0
- package/@cds-models/odatano/cardano/index.js +3 -0
- package/README.md +31 -0
- package/db/schema.cds +72 -0
- package/package.json +173 -173
- package/src/index.d.ts +6 -0
- package/src/index.js +17 -1
- package/src/plugin.js +33 -30
- 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 +84 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +16 -0
- package/srv/cardano-tx-service.cds +32 -26
- package/srv/cardano-tx-service.js +96 -38
- package/srv/server.d.ts +2 -1
- package/srv/server.js +12 -0
- package/srv/utils/agent-grants-config.d.ts +48 -0
- package/srv/utils/agent-grants-config.js +124 -0
- package/srv/utils/agent-grants.d.ts +211 -0
- package/srv/utils/agent-grants.js +541 -0
- package/srv/utils/agent-token-auth.d.ts +106 -0
- package/srv/utils/agent-token-auth.js +239 -0
- 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 +15 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
using {odatano.cardano as db} from '../db/schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cardano Agent Service (v2.0)
|
|
5
|
+
*
|
|
6
|
+
* Agent grants: scoped, budgeted bearer capabilities an Admin hands to an agent
|
|
7
|
+
* instead of a full user (see AGENT_GRANTS_DESIGN.md).
|
|
8
|
+
*
|
|
9
|
+
* - CreateAgentGrant / RevokeAgentGrant: Admin-only administration. The token is
|
|
10
|
+
* returned ONCE from CreateAgentGrant and stored as SHA-256 only.
|
|
11
|
+
* - AgentGrants: Admin-only projection (no token hash). A request carrying a token
|
|
12
|
+
* runs as the principal `agent:<grantId>` with the role `agent-grant` and sees
|
|
13
|
+
* exactly its own row through the row-level restriction below.
|
|
14
|
+
* - GetGrantStatus: token self-service — what am I allowed to do, how much budget
|
|
15
|
+
* is left, when do I expire. What an MCP tool needs to describe itself honestly.
|
|
16
|
+
*
|
|
17
|
+
* A token request never inherits the operator's roles: `@requires: 'Admin'` on the
|
|
18
|
+
* two actions, on PauseWorker / ResumeWorker / pauseCrawler / resumeCrawler and on
|
|
19
|
+
* every other Admin surface therefore refuses it by construction. The allow list,
|
|
20
|
+
* wallet pinning and daily budget are enforced by a before('*') hook on all six
|
|
21
|
+
* ODATANO services (srv/utils/agent-grants.ts). The `x-agent-token` header only
|
|
22
|
+
* reaches the services when cds.requires.odatano-core.agentGrants.enabled is set
|
|
23
|
+
* (srv/utils/agent-token-auth.ts).
|
|
24
|
+
*/
|
|
25
|
+
@requires: 'authenticated-user'
|
|
26
|
+
service CardanoAgentService @(impl: './cardano-agent-service') {
|
|
27
|
+
|
|
28
|
+
@readonly
|
|
29
|
+
@title : 'Agent Grants'
|
|
30
|
+
@description: 'Issued grants (token hash excluded). Admins see all, a token sees its own row.'
|
|
31
|
+
@restrict : [
|
|
32
|
+
{ grant: 'READ', to: 'Admin' },
|
|
33
|
+
{ grant: 'READ', to: 'agent-grant', where: 'ID = $user.grantId' }
|
|
34
|
+
]
|
|
35
|
+
entity AgentGrants as projection on db.CardanoAgentGrants excluding { tokenHash };
|
|
36
|
+
|
|
37
|
+
@title : 'Grant Status'
|
|
38
|
+
type GrantStatus {
|
|
39
|
+
grantId : UUID;
|
|
40
|
+
agentLabel : String(100);
|
|
41
|
+
allowedActions : many String;
|
|
42
|
+
walletId : String(50);
|
|
43
|
+
allowedJobKinds : many String;
|
|
44
|
+
maxJobsPerDay : Integer;
|
|
45
|
+
jobsUsedToday : Integer;
|
|
46
|
+
budgetWindow : String(10);
|
|
47
|
+
validUntil : Timestamp;
|
|
48
|
+
isActive : Boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@title : 'Issued Grant'
|
|
52
|
+
type IssuedGrant {
|
|
53
|
+
grantId : UUID;
|
|
54
|
+
token : String; // shown once, never stored
|
|
55
|
+
allowedActions : many String;
|
|
56
|
+
walletId : String(50);
|
|
57
|
+
allowedJobKinds : many String;
|
|
58
|
+
maxJobsPerDay : Integer;
|
|
59
|
+
validUntil : Timestamp;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@title : 'Get Grant Status'
|
|
63
|
+
@description: 'The calling token''s own grant: allow list, wallet, remaining daily budget, expiry. 400 without a token — an operator lists AgentGrants instead.'
|
|
64
|
+
function GetGrantStatus() returns GrantStatus;
|
|
65
|
+
|
|
66
|
+
@title : 'Create Agent Grant'
|
|
67
|
+
@description: 'Issue a scoped bearer token for an agent. Admin only. The token is returned once and stored as SHA-256. allowedActions must be a non-empty subset of the grantable set; walletId is required when SubmitWalletJob or CancelJob is allowed.'
|
|
68
|
+
@requires : 'Admin'
|
|
69
|
+
action CreateAgentGrant(
|
|
70
|
+
@title: 'Allowed Actions' allowedActions : many String,
|
|
71
|
+
@title: 'Wallet Id' walletId : String(50),
|
|
72
|
+
@title: 'Allowed Job Kinds' allowedJobKinds : many String,
|
|
73
|
+
@title: 'Max Jobs Per Day' maxJobsPerDay : Integer,
|
|
74
|
+
@title: 'Valid Until' validUntil : Timestamp,
|
|
75
|
+
@title: 'Agent Label' agentLabel : String(100)
|
|
76
|
+
) returns IssuedGrant;
|
|
77
|
+
|
|
78
|
+
@title : 'Revoke Agent Grant'
|
|
79
|
+
@description: 'Deactivate a grant. Admin only. Its token becomes an unknown token immediately.'
|
|
80
|
+
@requires : 'Admin'
|
|
81
|
+
action RevokeAgentGrant(
|
|
82
|
+
@title: 'Grant Id' grantId : UUID
|
|
83
|
+
) returns Boolean;
|
|
84
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const agent_grants_1 = require("./utils/agent-grants");
|
|
4
|
+
/**
|
|
5
|
+
* CardanoAgentService handlers — grant administration (Admin) and token
|
|
6
|
+
* self-service. Everything lives in srv/utils/agent-grants.ts so the
|
|
7
|
+
* programmatic API (`issueAgentGrant`, used by @odatano/x402 to sell grants) and
|
|
8
|
+
* the OData actions share one code path.
|
|
9
|
+
*
|
|
10
|
+
* The enforcement hook for token requests is attached to all six services from
|
|
11
|
+
* src/plugin.ts (cds.on('serving')), not here.
|
|
12
|
+
*/
|
|
13
|
+
module.exports = (srv) => {
|
|
14
|
+
(0, agent_grants_1.registerAgentGrantHandlers)(srv);
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=cardano-agent-service.js.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
using {odatano.cardano as db} from '../db/schema';
|
|
2
|
-
using {
|
|
2
|
+
using {
|
|
3
|
+
Bech32,
|
|
4
|
+
Lovelace
|
|
5
|
+
} from '../db/types';
|
|
3
6
|
|
|
4
7
|
|
|
5
8
|
/**
|
|
@@ -43,20 +46,21 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
43
46
|
@description: 'Projection for Transaction Build Output Assets'
|
|
44
47
|
entity TransactionBuildOutputAssets as projection on db.TransactionBuildOutputAssets;
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
@readonly
|
|
50
|
+
@title : 'Transaction Submissions'
|
|
51
|
+
@description: 'Projection for Transaction Submissions'
|
|
49
52
|
entity TransactionSubmissions as projection on db.TransactionSubmissions
|
|
50
53
|
actions {
|
|
51
54
|
@title : 'Check Submission Status'
|
|
52
55
|
@description: 'Check the status of a submitted transaction by querying the blockchain for confirmation'
|
|
53
56
|
action CheckSubmissionStatus() returns TransactionSubmissions;
|
|
54
57
|
};
|
|
58
|
+
|
|
55
59
|
/**
|
|
56
60
|
* TransactionSubmissions status flow:
|
|
57
|
-
* pending
|
|
58
|
-
* submitted
|
|
59
|
-
* pending | submitted
|
|
61
|
+
* pending -> [submit to chain] -> submitted (internal, in SubmitTransaction handler)
|
|
62
|
+
* submitted -> [CheckSubmissionStatus] confirmed | stays submitted (conditional)
|
|
63
|
+
* pending | submitted -> failed (blockchain error)
|
|
60
64
|
*/
|
|
61
65
|
annotate CardanoTransactionService.TransactionSubmissions with @flow.status: status actions {
|
|
62
66
|
CheckSubmissionStatus @from : [ #submitted];
|
|
@@ -117,7 +121,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
117
121
|
validityStartMs: String,
|
|
118
122
|
@title: 'Validity End (Posix ms)'
|
|
119
123
|
@description: 'Optional. Validity-interval end in Posix milliseconds. Passed through to the builder only; for non-script transfers the builder leaves bounds unset unless provided.'
|
|
120
|
-
validityEndMs: String)
|
|
124
|
+
validityEndMs: String) returns TransactionBuilds;
|
|
121
125
|
|
|
122
126
|
@title : 'Build Transaction with Metadata'
|
|
123
127
|
@description: 'Build a transaction with custom metadata from sender to recipient with specified amount and change address'
|
|
@@ -136,7 +140,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
136
140
|
changeAddress: Bech32,
|
|
137
141
|
@title: 'Metadata JSON'
|
|
138
142
|
@description: 'The JSON representation of the transaction metadata as string'
|
|
139
|
-
metadataJson: String)
|
|
143
|
+
metadataJson: String) returns TransactionBuilds;
|
|
140
144
|
|
|
141
145
|
@title : 'Build Multi-Asset Transaction'
|
|
142
146
|
@description: 'Build a transaction to send native assets (tokens) along with ADA'
|
|
@@ -167,7 +171,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
167
171
|
validityStartMs: String,
|
|
168
172
|
@title: 'Validity End (Posix ms)'
|
|
169
173
|
@description: 'Optional. Validity-interval end in Posix milliseconds. Passed through to the builder only; for non-script transfers the builder leaves bounds unset unless provided.'
|
|
170
|
-
validityEndMs: String)
|
|
174
|
+
validityEndMs: String) returns TransactionBuilds;
|
|
171
175
|
|
|
172
176
|
@title : 'Build Minting Transaction'
|
|
173
177
|
@description: 'Build a transaction to mint or burn native assets'
|
|
@@ -182,10 +186,10 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
182
186
|
@description: 'The amount of ADA to send with minted assets in lovelace'
|
|
183
187
|
lovelaceAmount: Lovelace,
|
|
184
188
|
@title: 'Mint Actions JSON'
|
|
185
|
-
@description: 'JSON array of mint/burn actions (format: [{"assetUnit":"policyId+assetName","quantity":"amount"}])'
|
|
189
|
+
@description: 'JSON array of mint/burn actions (format: [{"assetUnit":"policyId+assetName","quantity":"amount"}]). Multi-policy mints: each action may additionally carry its own "mintingPolicyScript" (CBOR hex, pre-applied) and "redeemerJson" (JSON-encoded PlutusData string), overriding the top-level policy/redeemer for that action. Actions resolving to the same policy must agree on their redeemer (the ledger carries one redeemer per policy).'
|
|
186
190
|
mintActionsJson: String,
|
|
187
191
|
@title: 'Minting Policy Script'
|
|
188
|
-
@description: 'The minting policy script in CBOR hex format'
|
|
192
|
+
@description: 'The minting policy script in CBOR hex format. Actions without a per-action mintingPolicyScript mint under this script.'
|
|
189
193
|
mintingPolicyScript: String,
|
|
190
194
|
@title: 'Change Address'
|
|
191
195
|
@description: 'The Bech32 encoded address for returning change -defaults to sender address if not specified'
|
|
@@ -211,6 +215,9 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
211
215
|
@title: 'Reference Inputs JSON'
|
|
212
216
|
@description: 'Optional JSON array of {txHash, outputIndex} UTxOs to include as CIP-31 reference inputs (read-only, not consumed). Use for oracle feeds, shared config UTxOs, or script reference UTxOs. Buildooor builder only.'
|
|
213
217
|
referenceInputsJson: String,
|
|
218
|
+
@title: 'Extra Outputs JSON'
|
|
219
|
+
@description: 'Optional JSON array of additional outputs [{address, lovelaceAmount, assets?, inlineDatumJson?, referenceScriptHex?}] appended after the primary recipient output. When present, the extra outputs carry the minted assets (declare each minted unit in an entry''s assets) and the primary output stays ADA-only — used to place each minted token on its own output with its own inline datum (e.g. datum-bound predicate tokens). Each entry is independently min-ADA checked.'
|
|
220
|
+
extraOutputsJson: String,
|
|
214
221
|
@title: 'Metadata JSON'
|
|
215
222
|
@description: 'Optional transaction metadata as JSON (CIP-20 / label-674 etc.). Object keyed by numeric label string. Attached as auxiliary_data to the mint tx so chain-watchers can correlate off-chain context (receipt IDs, free-form notes).'
|
|
216
223
|
metadataJson: String,
|
|
@@ -222,14 +229,14 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
222
229
|
validityStartMs: String,
|
|
223
230
|
@title: 'Validity End (Posix ms)'
|
|
224
231
|
@description: 'Optional. Sets the transaction validity-interval end in Posix milliseconds. Required finite value for Plutus validators that call expect Finite(upper) on tx.validity_range.upper_bound. Defaults to now + 3 600 000 ms when omitted.'
|
|
225
|
-
validityEndMs: String)
|
|
232
|
+
validityEndMs: String) returns TransactionBuilds;
|
|
226
233
|
|
|
227
234
|
@title : 'Get Build Details'
|
|
228
235
|
@description: 'Retrieve transaction build details using the Build Id'
|
|
229
236
|
action GetBuildDetails(
|
|
230
237
|
@title: 'Build Id'
|
|
231
238
|
@description: 'The unique identifier of the transaction build'
|
|
232
|
-
buildId: UUID)
|
|
239
|
+
buildId: UUID) returns TransactionBuilds;
|
|
233
240
|
|
|
234
241
|
@title : 'Submit Transaction'
|
|
235
242
|
@description: 'Submit a transaction to the Cardano network using a build ID and signed CBOR'
|
|
@@ -239,7 +246,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
239
246
|
buildId: UUID,
|
|
240
247
|
@title: 'Signed Transaction CBOR'
|
|
241
248
|
@description: 'The CBOR of the signed transaction'
|
|
242
|
-
signedTxCbor: String)
|
|
249
|
+
signedTxCbor: String) returns TransactionSubmissions;
|
|
243
250
|
|
|
244
251
|
@title : 'Submit Signed Transaction'
|
|
245
252
|
@description: 'Submit a signed transaction to the Cardano network'
|
|
@@ -249,7 +256,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
249
256
|
signedTxCbor: String,
|
|
250
257
|
@title: 'Network'
|
|
251
258
|
@description: 'The Cardano network to submit the transaction to (e.g., mainnet, testnet)'
|
|
252
|
-
network: String(10))
|
|
259
|
+
network: String(10)) returns TransactionSubmissions;
|
|
253
260
|
|
|
254
261
|
@title : 'Build Plutus Spend Transaction'
|
|
255
262
|
@description: 'Build a transaction to spend a UTxO locked at a Plutus script address'
|
|
@@ -326,13 +333,14 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
326
333
|
action SetCollateral(
|
|
327
334
|
@title: 'Address'
|
|
328
335
|
@description: 'The Bech32 encoded address to check and set up collateral for'
|
|
329
|
-
address: Bech32)
|
|
336
|
+
address: Bech32) returns TransactionBuilds;
|
|
337
|
+
|
|
330
338
|
@title : 'Address Transaction Builds'
|
|
331
339
|
@description: 'Projection for retrieving transaction builds by address'
|
|
332
340
|
action GetTransactionBuildsByAddress(
|
|
333
341
|
@title: 'Bech32 Address'
|
|
334
342
|
@description: 'The Bech32 encoded address to retrieve transaction builds for'
|
|
335
|
-
address: Bech32)
|
|
343
|
+
address: Bech32) returns array of AddressTransactionBuilds;
|
|
336
344
|
|
|
337
345
|
@title : 'Derive Script Address'
|
|
338
346
|
@description: 'Utility: Apply optional PlutusData parameters to a validator script and return its enterprise script address (bech32) and script hash (28-byte hex). Pure derivation, no transaction built, no blockchain call.'
|
|
@@ -346,19 +354,17 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
346
354
|
@title: 'Network'
|
|
347
355
|
@description: 'Optional network override (mainnet, preview, preprod). Defaults to the configured network.'
|
|
348
356
|
network: String(10)) returns {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
357
|
+
scriptAddress : String(120);
|
|
358
|
+
scriptHash : String(56);
|
|
359
|
+
};
|
|
352
360
|
|
|
353
361
|
@title : 'Extract Payment Key Hash'
|
|
354
362
|
@description: 'Utility: Decode a Bech32 Cardano address and return its 28-byte payment credential hash (hex). Pure bech32 decoding — no blockchain call. Use to obtain the key hash for requiredSignersJson on Plutus actions.'
|
|
355
363
|
action ExtractPaymentKeyHash(
|
|
356
364
|
@title: 'Address'
|
|
357
365
|
@description: 'The Bech32 encoded Cardano address (addr / addr_test)'
|
|
358
|
-
address: Bech32)
|
|
359
|
-
|
|
360
|
-
|
|
366
|
+
address: Bech32) returns {
|
|
367
|
+
paymentKeyHash : String(56);
|
|
368
|
+
};
|
|
361
369
|
|
|
362
370
|
}
|
|
363
|
-
|
|
364
|
-
|
|
@@ -117,7 +117,7 @@ module.exports = (srv) => {
|
|
|
117
117
|
});
|
|
118
118
|
/**
|
|
119
119
|
* Build a transaction with metadata
|
|
120
|
-
* @param req - CDS request object
|
|
120
|
+
* @param req - CDS request object
|
|
121
121
|
* @returns {TransactionBuild} Transaction build details
|
|
122
122
|
*/
|
|
123
123
|
srv.on('BuildTransactionWithMetadata', async (req) => {
|
|
@@ -138,7 +138,7 @@ module.exports = (srv) => {
|
|
|
138
138
|
});
|
|
139
139
|
/**
|
|
140
140
|
* Build a multi-asset transaction
|
|
141
|
-
* @param req
|
|
141
|
+
* @param req CDS request object
|
|
142
142
|
* @returns {TransactionBuild} Transaction build details
|
|
143
143
|
*/
|
|
144
144
|
srv.on('BuildMultiAssetTransaction', async (req) => {
|
|
@@ -157,10 +157,10 @@ module.exports = (srv) => {
|
|
|
157
157
|
if (!parsedAssets || parsedAssets.length === 0) {
|
|
158
158
|
return (0, errors_1.rejectInvalid)(req, 'BuildMultiAssetTransaction', 'assetsJson must contain at least one asset', 'assetsJson');
|
|
159
159
|
}
|
|
160
|
-
// Validation BEFORE handleRequest
|
|
160
|
+
// Validation BEFORE handleRequest
|
|
161
161
|
const cleanData = { ...req.data };
|
|
162
162
|
delete cleanData.assetsJson;
|
|
163
|
-
// parse optional output datum
|
|
163
|
+
// parse optional output datum
|
|
164
164
|
if (outputDatumJson) {
|
|
165
165
|
const jsonResult = (0, validators_1.validateJsonWithLimits)(outputDatumJson, 'outputDatumJson');
|
|
166
166
|
if (!jsonResult.valid)
|
|
@@ -182,11 +182,11 @@ module.exports = (srv) => {
|
|
|
182
182
|
});
|
|
183
183
|
/**
|
|
184
184
|
* Build a minting transaction
|
|
185
|
-
* @param req
|
|
185
|
+
* @param req CDS request object
|
|
186
186
|
* @returns {TransactionBuild} Transaction build details
|
|
187
187
|
*/
|
|
188
188
|
srv.on('BuildMintTransaction', async (req) => {
|
|
189
|
-
const { senderAddress, recipientAddress, lovelaceAmount, mintActionsJson, mintingPolicyScript, requiredSignersJson, scriptParamsJson, inlineDatumJson, mintRedeemerJson, lockOnScript, forceInputsJson, referenceInputsJson, referenceScriptHex, metadataJson, validityStartMs, validityEndMs } = req.data;
|
|
189
|
+
const { senderAddress, recipientAddress, lovelaceAmount, mintActionsJson, mintingPolicyScript, requiredSignersJson, scriptParamsJson, inlineDatumJson, mintRedeemerJson, lockOnScript, forceInputsJson, referenceInputsJson, referenceScriptHex, extraOutputsJson, metadataJson, validityStartMs, validityEndMs } = req.data;
|
|
190
190
|
// validate inputs (includes JSON and CBOR validation)
|
|
191
191
|
const errors = (0, validators_1.validateTransactionInputs)({ senderAddress, recipientAddress, lovelaceAmount, mintActionsJson, mintingPolicyScript, referenceScriptHex, metadataJson, validityStartMs, validityEndMs }, ['senderAddress', 'recipientAddress', 'lovelaceAmount', 'mintActionsJson', 'mintingPolicyScript']);
|
|
192
192
|
(0, errors_1.throwIfValidationErrors)(req, 'BuildMintTransaction', errors);
|
|
@@ -198,21 +198,41 @@ module.exports = (srv) => {
|
|
|
198
198
|
if (!Array.isArray(parsedMintActionsRaw)) {
|
|
199
199
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', 'mintActionsJson must be a JSON array', 'mintActionsJson');
|
|
200
200
|
}
|
|
201
|
-
const parsedMintActions = parsedMintActionsRaw.map((action) => {
|
|
201
|
+
const parsedMintActions = parsedMintActionsRaw.map((action, actionIndex) => {
|
|
202
202
|
if (!action || typeof action !== 'object') {
|
|
203
203
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', 'Each mint action must be an object with assetUnit and quantity', 'mintActionsJson');
|
|
204
204
|
}
|
|
205
|
-
//
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
// Multi-policy mint FR: optional per-action mintingPolicyScript + redeemerJson.
|
|
206
|
+
const policyFields = (0, tx_request_parsers_1.parseMintActionPolicyFields)(action, actionIndex);
|
|
207
|
+
if (policyFields.error) {
|
|
208
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', policyFields.error, 'mintActionsJson');
|
|
209
|
+
}
|
|
210
|
+
let actionPolicyId;
|
|
211
|
+
if (policyFields.script) {
|
|
212
|
+
try {
|
|
213
|
+
actionPolicyId = cardano_ledger_ts_1.Script.fromCbor(Buffer.from(policyFields.script, 'hex')).hash.toString();
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
217
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `mintActions[${actionIndex}].mintingPolicyScript is not a valid Plutus script: ${errMsg}`, 'mintActionsJson');
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const bareAssetNameForExpansion = (!!scriptParamsJson || !!actionPolicyId) &&
|
|
210
221
|
typeof action.assetUnit === 'string' &&
|
|
211
222
|
action.assetUnit.length < const_1.MIN_FULL_ASSET_UNIT_LENGTH &&
|
|
212
223
|
action.assetUnit.length % 2 === 0 &&
|
|
213
224
|
/^[0-9a-fA-F]*$/.test(action.assetUnit);
|
|
214
225
|
if (typeof action.assetUnit !== 'string' || (!(0, validators_1.isAssetUnit)(action.assetUnit) && !bareAssetNameForExpansion)) {
|
|
215
|
-
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `Invalid assetUnit: "${action.assetUnit}" — must be policyId+assetName hex (or a bare assetName hex when scriptParamsJson is set)`, 'mintActionsJson');
|
|
226
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `Invalid assetUnit: "${action.assetUnit}" — must be policyId+assetName hex (or a bare assetName hex when scriptParamsJson or a per-action mintingPolicyScript is set)`, 'mintActionsJson');
|
|
227
|
+
}
|
|
228
|
+
let assetUnit = action.assetUnit;
|
|
229
|
+
if (actionPolicyId) {
|
|
230
|
+
if (assetUnit.length < const_1.MIN_FULL_ASSET_UNIT_LENGTH) {
|
|
231
|
+
assetUnit = actionPolicyId + assetUnit;
|
|
232
|
+
}
|
|
233
|
+
else if (!assetUnit.toLowerCase().startsWith(actionPolicyId)) {
|
|
234
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `mintActions[${actionIndex}].assetUnit "${assetUnit}" does not start with its own policy id ${actionPolicyId}`, 'mintActionsJson');
|
|
235
|
+
}
|
|
216
236
|
}
|
|
217
237
|
if (typeof action.quantity !== 'string') {
|
|
218
238
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', 'Each mint action must have a string quantity', 'mintActionsJson');
|
|
@@ -221,7 +241,13 @@ module.exports = (srv) => {
|
|
|
221
241
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `Invalid quantity format: "${action.quantity}" — must be an integer string`, 'mintActionsJson');
|
|
222
242
|
}
|
|
223
243
|
try {
|
|
224
|
-
return {
|
|
244
|
+
return {
|
|
245
|
+
assetUnit,
|
|
246
|
+
quantity: BigInt(action.quantity),
|
|
247
|
+
...(action.redeemer !== undefined ? { redeemer: action.redeemer } : {}),
|
|
248
|
+
...(policyFields.script ? { mintingPolicyScript: policyFields.script } : {}),
|
|
249
|
+
...(policyFields.redeemer !== undefined ? { redeemerJson: policyFields.redeemer } : {})
|
|
250
|
+
};
|
|
225
251
|
}
|
|
226
252
|
catch {
|
|
227
253
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `Invalid quantity: "${action.quantity}" — cannot parse as integer`, 'mintActionsJson');
|
|
@@ -263,6 +289,12 @@ module.exports = (srv) => {
|
|
|
263
289
|
if (lockOnScript && (!scriptParams || scriptParams.length === 0)) {
|
|
264
290
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', 'lockOnScript requires scriptParamsJson to derive script address', 'lockOnScript');
|
|
265
291
|
}
|
|
292
|
+
// Parse and validate optional extraOutputsJson (FR-2 on mint: each minted
|
|
293
|
+
// token can sit on its own output with its own inline datum)
|
|
294
|
+
const extraOutputsResult = (0, tx_request_parsers_1.parseExtraOutputs)(extraOutputsJson);
|
|
295
|
+
if (extraOutputsResult.error)
|
|
296
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', extraOutputsResult.error, 'extraOutputsJson');
|
|
297
|
+
const extraOutputs = extraOutputsResult.parsed;
|
|
266
298
|
// Parse and validate optional forceInputsJson
|
|
267
299
|
const forceInputsResult = (0, tx_request_parsers_1.parseUtxoRefArray)(forceInputsJson, 'forceInputsJson');
|
|
268
300
|
if (forceInputsResult.error)
|
|
@@ -273,9 +305,7 @@ module.exports = (srv) => {
|
|
|
273
305
|
if (refInputsResult.error)
|
|
274
306
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', refInputsResult.error, 'referenceInputsJson');
|
|
275
307
|
const referenceInputs = refInputsResult.parsed;
|
|
276
|
-
// Parse and validate optional metadataJson
|
|
277
|
-
// validateTransactionInputs has already JSON-validated the string; re-parse here
|
|
278
|
-
// and enforce the label-object shape that the builder's metadata mapper expects.
|
|
308
|
+
// Parse and validate optional metadataJson
|
|
279
309
|
let parsedMetadata;
|
|
280
310
|
if (metadataJson) {
|
|
281
311
|
try {
|
|
@@ -302,6 +332,7 @@ module.exports = (srv) => {
|
|
|
302
332
|
delete cleanData.lockOnScript;
|
|
303
333
|
delete cleanData.forceInputsJson;
|
|
304
334
|
delete cleanData.referenceInputsJson;
|
|
335
|
+
delete cleanData.extraOutputsJson;
|
|
305
336
|
if (parsedMetadata) {
|
|
306
337
|
cleanData.metadataJson = parsedMetadata;
|
|
307
338
|
}
|
|
@@ -346,14 +377,9 @@ module.exports = (srv) => {
|
|
|
346
377
|
// invalid script CBOR — skip the prefix check; the builder rejects it with its own message
|
|
347
378
|
}
|
|
348
379
|
}
|
|
349
|
-
// BUG 9 fix: the builder mints every action under the policy script's hash and
|
|
350
|
-
// parseAssetUnit silently discards the unit's first 56 hex chars. A bare asset name
|
|
351
|
-
// of 29-32 bytes is length-indistinguishable from a full unit, so a mismatched
|
|
352
|
-
// prefix would mint a truncated name. At this point every action holds a full
|
|
353
|
-
// unit (bare names were expanded above), so all of them must carry the policyId.
|
|
354
380
|
if (effectivePolicyId) {
|
|
355
381
|
const policyId = effectivePolicyId;
|
|
356
|
-
const mismatch = parsedMintActions.find((action) => !action.assetUnit.toLowerCase().startsWith(policyId));
|
|
382
|
+
const mismatch = parsedMintActions.find((action) => !action.mintingPolicyScript && !action.assetUnit.toLowerCase().startsWith(policyId));
|
|
357
383
|
if (mismatch) {
|
|
358
384
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `assetUnit "${mismatch.assetUnit}" does not start with the minting policy id ${policyId} — pass the full unit as policyId+assetName (asset names longer than 28 bytes cannot be passed bare)`, 'mintActionsJson');
|
|
359
385
|
}
|
|
@@ -366,7 +392,8 @@ module.exports = (srv) => {
|
|
|
366
392
|
inlineDatum,
|
|
367
393
|
mintRedeemer,
|
|
368
394
|
forceInputs,
|
|
369
|
-
referenceInputs
|
|
395
|
+
referenceInputs,
|
|
396
|
+
extraOutputs
|
|
370
397
|
});
|
|
371
398
|
// Post-build: compute CIP-14 fingerprint and scriptAddress
|
|
372
399
|
if (buildResult.scriptHash) {
|
|
@@ -374,12 +401,15 @@ module.exports = (srv) => {
|
|
|
374
401
|
const updates = {};
|
|
375
402
|
// CIP-14 asset fingerprint for the first minted asset. The unit is always a
|
|
376
403
|
// full policyId+assetName here: bare names were expanded before the build and
|
|
377
|
-
// the
|
|
378
|
-
// asset name, not a bare 28-byte name).
|
|
404
|
+
// the prefix checks rejected everything else (a 56-hex unit is an empty
|
|
405
|
+
// asset name, not a bare 28-byte name). The policy id comes from the UNIT,
|
|
406
|
+
// not from buildResult.scriptHash: with a per-action mintingPolicyScript the
|
|
407
|
+
// first action may mint under a different policy than the top-level script.
|
|
379
408
|
if (parsedMintActions.length > 0) {
|
|
380
409
|
const firstAssetUnit = parsedMintActions[0].assetUnit;
|
|
410
|
+
const firstPolicyId = firstAssetUnit.slice(0, const_1.POLICY_ID_HEX_LENGTH);
|
|
381
411
|
const assetNameHex = firstAssetUnit.slice(const_1.POLICY_ID_HEX_LENGTH);
|
|
382
|
-
buildResult.fingerprint = (0, mappers_1.computeCip14Fingerprint)(
|
|
412
|
+
buildResult.fingerprint = (0, mappers_1.computeCip14Fingerprint)(firstPolicyId, assetNameHex);
|
|
383
413
|
updates.fingerprint = buildResult.fingerprint;
|
|
384
414
|
}
|
|
385
415
|
// lockOnScript: persist the derived script address on the build record (only when scriptParams were applied)
|
|
@@ -459,8 +489,7 @@ module.exports = (srv) => {
|
|
|
459
489
|
if (extraOutputsResult.error)
|
|
460
490
|
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', extraOutputsResult.error, 'extraOutputsJson');
|
|
461
491
|
const extraOutputs = extraOutputsResult.parsed;
|
|
462
|
-
//
|
|
463
|
-
// mintingPolicyScript is required alongside it. mintRedeemerJson is optional.
|
|
492
|
+
// Optional combined spend+mint parameters
|
|
464
493
|
let parsedMintActions;
|
|
465
494
|
let parsedMintRedeemer;
|
|
466
495
|
if (mintActionsJson) {
|
|
@@ -473,7 +502,7 @@ module.exports = (srv) => {
|
|
|
473
502
|
if (!Array.isArray(mintJson.parsed)) {
|
|
474
503
|
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', 'mintActionsJson must be a JSON array', 'mintActionsJson');
|
|
475
504
|
}
|
|
476
|
-
parsedMintActions = mintJson.parsed.map((rawAction) => {
|
|
505
|
+
parsedMintActions = mintJson.parsed.map((rawAction, actionIndex) => {
|
|
477
506
|
if (!rawAction || typeof rawAction !== 'object') {
|
|
478
507
|
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', 'Each mint action must be an object with assetUnit and quantity', 'mintActionsJson');
|
|
479
508
|
}
|
|
@@ -484,18 +513,45 @@ module.exports = (srv) => {
|
|
|
484
513
|
if (typeof action.assetUnit !== 'string') {
|
|
485
514
|
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', 'Each mint action must have assetUnit string', 'mintActionsJson');
|
|
486
515
|
}
|
|
487
|
-
//
|
|
488
|
-
//
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
516
|
+
// Multi-policy mint FR: optional per-action mintingPolicyScript + redeemerJson
|
|
517
|
+
// (same rules as BuildMintTransaction).
|
|
518
|
+
const policyFields = (0, tx_request_parsers_1.parseMintActionPolicyFields)(action, actionIndex);
|
|
519
|
+
if (policyFields.error) {
|
|
520
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', policyFields.error, 'mintActionsJson');
|
|
521
|
+
}
|
|
522
|
+
let actionPolicyId;
|
|
523
|
+
if (policyFields.script) {
|
|
524
|
+
try {
|
|
525
|
+
actionPolicyId = cardano_ledger_ts_1.Script.fromCbor(Buffer.from(policyFields.script, 'hex')).hash.toString();
|
|
526
|
+
}
|
|
527
|
+
catch (err) {
|
|
528
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
529
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', `mintActions[${actionIndex}].mintingPolicyScript is not a valid Plutus script: ${errMsg}`, 'mintActionsJson');
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
const bareAssetNameForExpansion = ((!!scriptParamsJson && mintingPolicyScript === validatorScript) || !!actionPolicyId) &&
|
|
492
533
|
action.assetUnit.length < const_1.MIN_FULL_ASSET_UNIT_LENGTH &&
|
|
493
534
|
action.assetUnit.length % 2 === 0 &&
|
|
494
535
|
/^[0-9a-fA-F]*$/.test(action.assetUnit);
|
|
495
536
|
if (!(0, validators_1.isAssetUnit)(action.assetUnit) && !bareAssetNameForExpansion) {
|
|
496
|
-
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', `Invalid assetUnit: "${action.assetUnit}" — must be policyId+assetName hex (or a bare assetName hex when scriptParamsJson is set and the policy equals the validator)`, 'mintActionsJson');
|
|
537
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', `Invalid assetUnit: "${action.assetUnit}" — must be policyId+assetName hex (or a bare assetName hex when a per-action mintingPolicyScript is set, or scriptParamsJson is set and the policy equals the validator)`, 'mintActionsJson');
|
|
497
538
|
}
|
|
498
|
-
|
|
539
|
+
let assetUnit = action.assetUnit;
|
|
540
|
+
if (actionPolicyId) {
|
|
541
|
+
if (assetUnit.length < const_1.MIN_FULL_ASSET_UNIT_LENGTH) {
|
|
542
|
+
assetUnit = actionPolicyId + assetUnit;
|
|
543
|
+
}
|
|
544
|
+
else if (!assetUnit.toLowerCase().startsWith(actionPolicyId)) {
|
|
545
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', `mintActions[${actionIndex}].assetUnit "${assetUnit}" does not start with its own policy id ${actionPolicyId}`, 'mintActionsJson');
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return {
|
|
549
|
+
assetUnit,
|
|
550
|
+
quantity: BigInt(action.quantity),
|
|
551
|
+
...(typeof action.redeemer === 'number' ? { redeemer: action.redeemer } : {}),
|
|
552
|
+
...(policyFields.script ? { mintingPolicyScript: policyFields.script } : {}),
|
|
553
|
+
...(policyFields.redeemer !== undefined ? { redeemerJson: policyFields.redeemer } : {})
|
|
554
|
+
};
|
|
499
555
|
});
|
|
500
556
|
if (mintRedeemerJson) {
|
|
501
557
|
const mrJson = (0, validators_1.validateJsonWithLimits)(mintRedeemerJson, 'mintRedeemerJson');
|
|
@@ -556,7 +612,9 @@ module.exports = (srv) => {
|
|
|
556
612
|
}
|
|
557
613
|
if (mintPolicyId) {
|
|
558
614
|
const policyId = mintPolicyId;
|
|
559
|
-
|
|
615
|
+
// Actions with their own per-action script were already checked
|
|
616
|
+
// against THAT script's policy id during parsing.
|
|
617
|
+
const mismatch = parsedMintActions.find((action) => !action.mintingPolicyScript && !action.assetUnit.toLowerCase().startsWith(policyId));
|
|
560
618
|
if (mismatch) {
|
|
561
619
|
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', `assetUnit "${mismatch.assetUnit}" does not start with the minting policy id ${policyId} — pass the full unit as policyId+assetName (asset names longer than 28 bytes cannot be passed bare)`, 'mintActionsJson');
|
|
562
620
|
}
|
package/srv/server.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ interface AppContext {
|
|
|
13
13
|
cardanoIndexer: CardanoIndexer;
|
|
14
14
|
cardanoTxBuilder: CardanoTransactionBuilder;
|
|
15
15
|
}
|
|
16
|
+
/** Agent-grant feature switch (AGENT_GRANTS_DESIGN.md); lives in its own module so src/plugin.ts can read it at load. */
|
|
17
|
+
export { loadAgentGrantsConfig, activateAgentGrants } from './utils/agent-grants-config';
|
|
16
18
|
/**
|
|
17
19
|
* Get the application context (must be called after bootstrap)
|
|
18
20
|
* @throws {ProviderUnavailableError} 503 when uninitialized — request handlers using
|
|
@@ -125,5 +127,4 @@ export declare function startWalletWorkerIfConfigured(): Promise<void>;
|
|
|
125
127
|
* Non-fatal, mirrors startCrawlerIfConfigured/startWalletWorkerIfConfigured.
|
|
126
128
|
*/
|
|
127
129
|
export declare function redriveInterruptedSubmissionsIfConfigured(): Promise<void>;
|
|
128
|
-
export {};
|
|
129
130
|
//# sourceMappingURL=server.d.ts.map
|
package/srv/server.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.activateAgentGrants = exports.loadAgentGrantsConfig = void 0;
|
|
6
7
|
exports.getAppContext = getAppContext;
|
|
7
8
|
exports.getCardanoIndexer = getCardanoIndexer;
|
|
8
9
|
exports.getCardanoClient = getCardanoClient;
|
|
@@ -28,6 +29,7 @@ const errors_1 = require("./utils/errors");
|
|
|
28
29
|
const network_context_1 = require("./utils/network-context");
|
|
29
30
|
const crawler_1 = require("./blockchain/crawler");
|
|
30
31
|
const wallet_worker_1 = require("./blockchain/wallet-worker");
|
|
32
|
+
const agent_grants_config_1 = require("./utils/agent-grants-config");
|
|
31
33
|
const process_1 = require("process");
|
|
32
34
|
const logger = cds_1.default.log('ODATANO');
|
|
33
35
|
const VALID_NETWORKS = ['mainnet', 'preview', 'preprod'];
|
|
@@ -91,6 +93,16 @@ async function initializeAppContext(config, protocolParams, hsmConfig) {
|
|
|
91
93
|
cardanoTxBuilder,
|
|
92
94
|
};
|
|
93
95
|
}
|
|
96
|
+
/** Agent-grant feature switch (AGENT_GRANTS_DESIGN.md); lives in its own module so src/plugin.ts can read it at load. */
|
|
97
|
+
var agent_grants_config_2 = require("./utils/agent-grants-config");
|
|
98
|
+
Object.defineProperty(exports, "loadAgentGrantsConfig", { enumerable: true, get: function () { return agent_grants_config_2.loadAgentGrantsConfig; } });
|
|
99
|
+
Object.defineProperty(exports, "activateAgentGrants", { enumerable: true, get: function () { return agent_grants_config_2.activateAgentGrants; } });
|
|
100
|
+
// Standalone mode (`cds serve` / `cds watch` in this project): CAP loads
|
|
101
|
+
// cds-plugin.js only from dependencies, so src/plugin.ts never runs here and
|
|
102
|
+
// agent grants would stay off regardless of AGENT_GRANTS_ENABLED. bin/serve.js
|
|
103
|
+
// imports this file before cds.server() instantiates the middlewares, so the
|
|
104
|
+
// auth impl can still be swapped. Idempotent: a no-op after the plugin's call.
|
|
105
|
+
(0, agent_grants_config_1.activateAgentGrants)();
|
|
94
106
|
/**
|
|
95
107
|
* Get the application context (must be called after bootstrap)
|
|
96
108
|
* @throws {ProviderUnavailableError} 503 when uninitialized — request handlers using
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-grant feature switch. Read from `cds.requires.odatano-core.agentGrants`
|
|
3
|
+
* first, then from the environment; kept in its own tiny module because
|
|
4
|
+
* src/plugin.ts reads it at plugin load, before any blockchain module may be
|
|
5
|
+
* required.
|
|
6
|
+
*
|
|
7
|
+
* cds: "odatano-core": { "agentGrants": { "enabled": true, "delegate": "mocked" } }
|
|
8
|
+
* env: AGENT_GRANTS_ENABLED=true AGENT_GRANTS_DELEGATE=mocked|basic|jwt|xsuaa|ias|dummy
|
|
9
|
+
*
|
|
10
|
+
* `delegate` names the CAP auth strategy that keeps authenticating every
|
|
11
|
+
* request WITHOUT an `x-agent-token` header (the transport lane only adds the
|
|
12
|
+
* token path next to it). Default: the configured `cds.requires.auth.kind`.
|
|
13
|
+
*/
|
|
14
|
+
export interface AgentGrantsConfig {
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
/** CAP auth kind the transport middleware delegates to for non-token requests. */
|
|
17
|
+
delegate: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const AGENT_GRANTS_DELEGATES: readonly string[];
|
|
20
|
+
/** The configured `cds.requires.auth` as an object (the shorthand `"auth": "xsuaa"` is a string). */
|
|
21
|
+
export declare function configuredAuth(): Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* A custom `cds.requires.auth.impl` the host configured before us (anything
|
|
24
|
+
* that is not this package's middleware). It keeps authenticating every
|
|
25
|
+
* non-token request: the lane wraps it instead of replacing it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function customAuthImpl(auth?: Record<string, unknown>): string | null;
|
|
28
|
+
export declare function loadAgentGrantsConfig(env?: Record<string, string | undefined>): AgentGrantsConfig;
|
|
29
|
+
/**
|
|
30
|
+
* Switch agent grants on for this process when configured. Called from BOTH
|
|
31
|
+
* entry points, because CAP loads `cds-plugin.js` only from a project's
|
|
32
|
+
* dependencies, never from the project itself:
|
|
33
|
+
* - src/plugin.ts at plugin load (consumer app), and
|
|
34
|
+
* - srv/server.ts at module load (standalone `cds serve` / `cds watch`, where
|
|
35
|
+
* bin/serve.js imports the local server.js BEFORE cds.server() builds its
|
|
36
|
+
* middlewares — the last moment `cds.requires.auth.impl` can still change).
|
|
37
|
+
*
|
|
38
|
+
* When enabled:
|
|
39
|
+
* - the transport auth becomes srv/utils/agent-token-auth, which admits the
|
|
40
|
+
* `x-agent-token` header on the six service paths and delegates every other
|
|
41
|
+
* request to the strategy that was configured before (kept as the delegate);
|
|
42
|
+
* - each of the six services gets the enforcement hook once it is served.
|
|
43
|
+
*
|
|
44
|
+
* Never throws: a misconfiguration is logged and the feature stays off, so a
|
|
45
|
+
* host app never fails to start because of it. Returns whether grants are on.
|
|
46
|
+
*/
|
|
47
|
+
export declare function activateAgentGrants(): boolean;
|
|
48
|
+
//# sourceMappingURL=agent-grants-config.d.ts.map
|