@odatano/core 2.0.0-rc.3 → 2.0.0-rc.30
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 +251 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +194 -2
- package/@cds-models/CardanoIndexerService/index.js +25 -0
- package/@cds-models/CardanoODataService/index.d.ts +294 -7
- package/@cds-models/CardanoODataService/index.js +33 -0
- package/@cds-models/CardanoSignService/index.d.ts +28 -3
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +52 -19
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/index.d.ts +18 -0
- package/@cds-models/index.js +3 -0
- package/@cds-models/odatano/cardano/index.d.ts +408 -7
- package/@cds-models/odatano/cardano/index.js +42 -0
- package/README.md +64 -5
- package/db/schema.cds +677 -13
- package/db/types.cds +27 -0
- package/package.json +182 -173
- package/scripts/migrate-slot-leader.mjs +104 -0
- package/scripts/migrate-txseq.mjs +147 -0
- package/src/index.d.ts +11 -10
- package/src/index.js +28 -14
- package/src/plugin.js +39 -52
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +49 -160
- package/srv/blockchain/backends/cardano-backend.d.ts +104 -158
- package/srv/blockchain/backends/cardano-backend.js +19 -5
- package/srv/blockchain/backends/koios-backend.d.ts +126 -60
- package/srv/blockchain/backends/koios-backend.js +356 -217
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +170 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +162 -94
- package/srv/blockchain/backends/ogmios-backend.js +548 -197
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
- package/srv/blockchain/cardano-client.d.ts +78 -205
- package/srv/blockchain/cardano-client.js +186 -242
- package/srv/blockchain/cardano-indexer.d.ts +302 -242
- package/srv/blockchain/cardano-indexer.js +1191 -362
- package/srv/blockchain/cardano-tx-builder.d.ts +43 -81
- package/srv/blockchain/cardano-tx-builder.js +177 -132
- package/srv/blockchain/crawler/certificate-backfill.d.ts +67 -0
- package/srv/blockchain/crawler/certificate-backfill.js +169 -0
- package/srv/blockchain/crawler/crawler.d.ts +139 -54
- package/srv/blockchain/crawler/crawler.js +478 -96
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +5 -0
- package/srv/blockchain/crawler/index.js +35 -7
- package/srv/blockchain/crawler/sync-state.d.ts +46 -28
- package/srv/blockchain/crawler/sync-state.js +128 -43
- package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/transaction-backfill.js +283 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +78 -0
- package/srv/blockchain/crawler/utxo-set-import.js +363 -0
- package/srv/blockchain/ledger-state.d.ts +101 -0
- package/srv/blockchain/ledger-state.js +432 -0
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -0
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +8 -44
- package/srv/blockchain/signing/signature-verifier.js +13 -54
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -49
- package/srv/blockchain/stored-chain.d.ts +33 -0
- package/srv/blockchain/stored-chain.js +234 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +108 -160
- package/srv/blockchain/transaction-building/buildooor-tx.js +620 -285
- package/srv/blockchain/transaction-building/caller-datums.d.ts +17 -0
- package/srv/blockchain/transaction-building/caller-datums.js +50 -0
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +10 -35
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +43 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +48 -24
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
- package/srv/cardano-agent-service.cds +146 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +12 -0
- package/srv/cardano-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +244 -0
- package/srv/cardano-indexer-service.cds +201 -73
- package/srv/cardano-indexer-service.js +280 -11
- package/srv/cardano-service.cds +56 -1
- package/srv/cardano-service.js +52 -113
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-sign-service.js +55 -173
- package/srv/cardano-tx-service.cds +439 -364
- package/srv/cardano-tx-service.js +305 -209
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.js +7 -15
- package/srv/cbor/parse.js +13 -1
- package/srv/server.d.ts +28 -86
- package/srv/server.js +127 -135
- package/srv/utils/agent-grants-config.d.ts +37 -0
- package/srv/utils/agent-grants-config.js +138 -0
- package/srv/utils/agent-grants.d.ts +262 -0
- package/srv/utils/agent-grants.js +922 -0
- package/srv/utils/agent-token-auth.d.ts +16 -0
- package/srv/utils/agent-token-auth.js +78 -0
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +30 -67
- package/srv/utils/const.js +32 -72
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +25 -0
- package/srv/utils/db-indexes.js +94 -0
- package/srv/utils/db-sanitize.d.ts +27 -0
- package/srv/utils/db-sanitize.js +85 -0
- package/srv/utils/epoch-slots.d.ts +13 -0
- package/srv/utils/epoch-slots.js +25 -0
- package/srv/utils/error-codes.d.ts +20 -73
- package/srv/utils/error-codes.js +19 -70
- package/srv/utils/errors.d.ts +50 -177
- package/srv/utils/errors.js +94 -218
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +40 -0
- package/srv/utils/mappers.d.ts +128 -214
- package/srv/utils/mappers.js +354 -299
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +62 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +56 -0
- package/srv/utils/plutus-placeholders.d.ts +23 -16
- package/srv/utils/plutus-placeholders.js +63 -27
- package/srv/utils/rate-limiter.d.ts +46 -0
- package/srv/utils/rate-limiter.js +116 -0
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +3 -18
- package/srv/utils/signing-helper.js +10 -32
- package/srv/utils/tx-build-helper.d.ts +26 -92
- package/srv/utils/tx-build-helper.js +68 -123
- package/srv/utils/tx-request-parsers.d.ts +107 -21
- package/srv/utils/tx-request-parsers.js +433 -34
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +238 -169
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +24 -90
- package/srv/utils/validators.js +50 -147
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;
|
|
@@ -26,17 +27,38 @@ const cardano_tx_builder_1 = require("./blockchain/cardano-tx-builder");
|
|
|
26
27
|
const hsm_signer_1 = require("./blockchain/signing/hsm-signer");
|
|
27
28
|
const errors_1 = require("./utils/errors");
|
|
28
29
|
const network_context_1 = require("./utils/network-context");
|
|
30
|
+
const db_sanitize_1 = require("./utils/db-sanitize");
|
|
31
|
+
const db_indexes_1 = require("./utils/db-indexes");
|
|
32
|
+
const pg_order_nulls_1 = require("./utils/pg-order-nulls");
|
|
33
|
+
const pg_inline_json_1 = require("./utils/pg-inline-json");
|
|
29
34
|
const crawler_1 = require("./blockchain/crawler");
|
|
30
35
|
const wallet_worker_1 = require("./blockchain/wallet-worker");
|
|
36
|
+
const agent_grants_config_1 = require("./utils/agent-grants-config");
|
|
31
37
|
const process_1 = require("process");
|
|
32
38
|
const logger = cds_1.default.log('ODATANO');
|
|
33
39
|
const VALID_NETWORKS = ['mainnet', 'preview', 'preprod'];
|
|
34
|
-
|
|
40
|
+
function coreCdsConfig() {
|
|
41
|
+
const requires = cds_1.default.env?.requires;
|
|
42
|
+
return requires?.['odatano-core'] ?? {};
|
|
43
|
+
}
|
|
44
|
+
const VALID_BACKENDS = ['blockfrost', 'koios', 'ogmios', 'odatano'];
|
|
35
45
|
const CRAWLER_LIMITS = {
|
|
36
46
|
batchSize: { min: 1, max: 100 },
|
|
37
47
|
confirmationDepth: { min: 0, max: 2160 },
|
|
38
48
|
pollIntervalMs: { min: 1000, max: 3_600_000 },
|
|
49
|
+
assetEnrichRate: { min: 1, max: 20 },
|
|
39
50
|
};
|
|
51
|
+
const VALID_ASSET_CATALOGUE_MODES = ['off', 'bare', 'enrich'];
|
|
52
|
+
/** Parse a boolean crawler flag that defaults to `fallback` when unset. */
|
|
53
|
+
function crawlerBoolean(raw, name, fallback) {
|
|
54
|
+
if (raw === undefined || raw === null)
|
|
55
|
+
return fallback;
|
|
56
|
+
if (raw === true || raw === 'true')
|
|
57
|
+
return true;
|
|
58
|
+
if (raw === false || raw === 'false')
|
|
59
|
+
return false;
|
|
60
|
+
throw new errors_1.ConfigError(`Invalid ${name} "${String(raw)}". Must be true or false.`);
|
|
61
|
+
}
|
|
40
62
|
/** Parse an integer without allowing JavaScript's lossy/implicit coercions. */
|
|
41
63
|
function crawlerInteger(raw, name, min, max, defaultValue) {
|
|
42
64
|
if (raw == null)
|
|
@@ -54,24 +76,32 @@ function crawlerInteger(raw, name, min, max, defaultValue) {
|
|
|
54
76
|
let appContext = null;
|
|
55
77
|
let bootstrapError = null;
|
|
56
78
|
/**
|
|
57
|
-
* Initialize the application context
|
|
58
|
-
*
|
|
59
|
-
* @param config - CardanoClientConfig
|
|
60
|
-
* @param protocolParams - Optional protocol parameters (for tests to skip backend call)
|
|
79
|
+
* Initialize the application context; every start path (standalone hook, plugin) comes through here.
|
|
80
|
+
* @param protocolParams - optional, lets tests skip the backend call
|
|
61
81
|
*/
|
|
62
82
|
async function initializeAppContext(config, protocolParams, hsmConfig) {
|
|
63
83
|
logger.debug('Initializing blockchain components...');
|
|
64
|
-
//
|
|
84
|
+
// Database first. Postgres ORDER BY without a NULLS clause on key / NOT NULL columns so
|
|
85
|
+
// the indexes serve `$top` / `$orderby`, bulk rows inline instead of through a COPY buffer;
|
|
86
|
+
// then the secondary indexes the model cannot declare.
|
|
87
|
+
(0, pg_order_nulls_1.installPostgresOrderNulls)();
|
|
88
|
+
(0, pg_inline_json_1.installPostgresInlineJson)();
|
|
89
|
+
try {
|
|
90
|
+
await (0, db_indexes_1.ensureDbIndexes)();
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
logger.warn('secondary indexes not ensured (non-fatal):', err);
|
|
94
|
+
}
|
|
65
95
|
const cardanoClient = new cardano_client_1.CardanoClient(config);
|
|
66
|
-
//
|
|
67
|
-
// without forcing them to import this module / the full server graph.
|
|
96
|
+
// Lets leaf utilities (network-aware validators) read the network without importing this module.
|
|
68
97
|
(0, network_context_1.setActiveNetwork)(config.network);
|
|
69
|
-
// Create CardanoTransactionBuilder with the client
|
|
70
98
|
const cardanoTxBuilder = new cardano_tx_builder_1.CardanoTransactionBuilder(cardanoClient);
|
|
71
99
|
await cardanoTxBuilder.init(protocolParams);
|
|
72
|
-
//
|
|
100
|
+
// PostgreSQL rejects U+0000 in text/JSON; one db-level `before` hook covers every write.
|
|
101
|
+
if ((0, db_sanitize_1.installDbSanitizer)())
|
|
102
|
+
logger.debug('DB NUL sanitizer installed');
|
|
73
103
|
const cardanoIndexer = new cardano_indexer_1.CardanoIndexer(cardanoClient, cardanoTxBuilder);
|
|
74
|
-
//
|
|
104
|
+
// HSM signer failure is non-fatal
|
|
75
105
|
if (hsmConfig?.enabled) {
|
|
76
106
|
try {
|
|
77
107
|
const hsmSigner = new hsm_signer_1.HsmSigner(hsmConfig);
|
|
@@ -91,11 +121,16 @@ async function initializeAppContext(config, protocolParams, hsmConfig) {
|
|
|
91
121
|
cardanoTxBuilder,
|
|
92
122
|
};
|
|
93
123
|
}
|
|
124
|
+
/** Agent-grant feature switch; its own module so src/plugin.ts can read it at load. */
|
|
125
|
+
var agent_grants_config_2 = require("./utils/agent-grants-config");
|
|
126
|
+
Object.defineProperty(exports, "loadAgentGrantsConfig", { enumerable: true, get: function () { return agent_grants_config_2.loadAgentGrantsConfig; } });
|
|
127
|
+
Object.defineProperty(exports, "activateAgentGrants", { enumerable: true, get: function () { return agent_grants_config_2.activateAgentGrants; } });
|
|
128
|
+
// Standalone mode never loads src/plugin.ts, so swap the auth impl here as well
|
|
129
|
+
// (bin/serve.js imports this file before the middlewares exist). Idempotent.
|
|
130
|
+
(0, agent_grants_config_1.activateAgentGrants)();
|
|
94
131
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @throws {ProviderUnavailableError} 503 when uninitialized
|
|
97
|
-
* handleRequest/mapError translate this into a clean 503 response instead of a raw 500.
|
|
98
|
-
* If bootstrap actively failed, the cause is appended to the message.
|
|
132
|
+
* The application context.
|
|
133
|
+
* @throws {ProviderUnavailableError} 503 when uninitialized; a bootstrap failure is appended as cause.
|
|
99
134
|
*/
|
|
100
135
|
function getAppContext() {
|
|
101
136
|
if (!appContext) {
|
|
@@ -107,45 +142,25 @@ function getAppContext() {
|
|
|
107
142
|
}
|
|
108
143
|
return appContext;
|
|
109
144
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Get the CardanoIndexer instance
|
|
112
|
-
* Convenience function for services
|
|
113
|
-
*/
|
|
114
145
|
function getCardanoIndexer() {
|
|
115
146
|
return getAppContext().cardanoIndexer;
|
|
116
147
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Get the CardanoClient instance
|
|
119
|
-
* Convenience function for services
|
|
120
|
-
*/
|
|
121
148
|
function getCardanoClient() {
|
|
122
149
|
return getAppContext().cardanoClient;
|
|
123
150
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Get the CardanoTransactionBuilder instance
|
|
126
|
-
* Convenience function for services and plugin consumers
|
|
127
|
-
*/
|
|
128
151
|
function getCardanoTxBuilder() {
|
|
129
152
|
return getAppContext().cardanoTxBuilder;
|
|
130
153
|
}
|
|
131
154
|
let hsmConfigInstance;
|
|
132
|
-
/**
|
|
133
|
-
* Get the HSM configuration (if HSM is enabled).
|
|
134
|
-
* Used by sign service to check requiresRole.
|
|
135
|
-
*/
|
|
155
|
+
/** HSM configuration when enabled; the sign service reads requiresRole from it. */
|
|
136
156
|
function getHsmConfig() {
|
|
137
157
|
return hsmConfigInstance;
|
|
138
158
|
}
|
|
139
159
|
/**
|
|
140
|
-
* Initialize from a pre-built config (
|
|
141
|
-
*
|
|
142
|
-
* @param protocolParams - Optional protocol parameters (for tests)
|
|
160
|
+
* Initialize from a pre-built config (plugin path). Idempotent: a second call must not
|
|
161
|
+
* create a duplicate CardanoClient; tests reinitialize via resetAppContext() / createTestContext().
|
|
143
162
|
*/
|
|
144
163
|
async function initializeFromConfig(config, protocolParams, hsmConfig) {
|
|
145
|
-
// Idempotent: a previous call (plugin's cds.on('served'), server.ts's served hook,
|
|
146
|
-
// or an earlier programmatic initialize()) already built the context. Direct callers
|
|
147
|
-
// such as @odatano/x402's bridge must not produce a duplicate CardanoClient.
|
|
148
|
-
// Tests that need to reinitialize should use resetAppContext() / createTestContext().
|
|
149
164
|
if (appContext) {
|
|
150
165
|
logger.debug('initializeFromConfig: appContext already initialized, skipping');
|
|
151
166
|
return;
|
|
@@ -156,37 +171,27 @@ async function initializeFromConfig(config, protocolParams, hsmConfig) {
|
|
|
156
171
|
bootstrapError = null;
|
|
157
172
|
}
|
|
158
173
|
catch (err) {
|
|
159
|
-
//
|
|
160
|
-
// even in PLUGIN mode (src/plugin.ts only logs the error) — previously bootstrapError
|
|
161
|
-
// stayed null there and the failure showed up as a causeless "not initialized".
|
|
174
|
+
// Keep the cause so getAppContext() can surface a structured 503 in plugin mode too.
|
|
162
175
|
bootstrapError = err instanceof Error ? err : new Error(String(err));
|
|
163
|
-
throw err;
|
|
176
|
+
throw err;
|
|
164
177
|
}
|
|
165
178
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Reset the application context (for testing only)
|
|
168
|
-
* Allows tests to inject their own instances
|
|
169
|
-
*/
|
|
179
|
+
/** Reset the application context (tests only); lets tests inject their own instances. */
|
|
170
180
|
function resetAppContext(context) {
|
|
171
181
|
if (process.env.NODE_ENV === 'production') {
|
|
172
182
|
throw new Error('resetAppContext() is not available in production');
|
|
173
183
|
}
|
|
174
184
|
appContext = context;
|
|
175
185
|
bootstrapError = null;
|
|
176
|
-
// Keep the published network in sync with the injected context (or clear it).
|
|
177
186
|
(0, network_context_1.setActiveNetwork)(context?.cardanoClient.network ?? null);
|
|
178
187
|
logger.debug('Application context reset');
|
|
179
188
|
}
|
|
180
189
|
/**
|
|
181
|
-
* Create
|
|
182
|
-
*
|
|
183
|
-
* @param
|
|
184
|
-
* @param _txBuilderName Deprecated/ignored — Buildooor is the sole transaction builder (kept for signature compatibility)
|
|
185
|
-
* @param protocolParams Optional protocol parameters (to skip backend call during init)
|
|
186
|
-
* @returns Promise<AppContext> The created application context
|
|
190
|
+
* Create an isolated test context with the given backends.
|
|
191
|
+
* @param _txBuilderName ignored; Buildooor is the sole builder (kept for signature compatibility)
|
|
192
|
+
* @param protocolParams optional, skips the backend call during init
|
|
187
193
|
*/
|
|
188
|
-
async function createTestContext(backends, _txBuilderName = 'buildooor',
|
|
189
|
-
protocolParams) {
|
|
194
|
+
async function createTestContext(backends, _txBuilderName = 'buildooor', protocolParams) {
|
|
190
195
|
const config = {
|
|
191
196
|
network: process_1.env.NETWORK || 'preview',
|
|
192
197
|
backends,
|
|
@@ -194,6 +199,8 @@ protocolParams) {
|
|
|
194
199
|
blockfrostCustomBackend: process_1.env.BLOCKFROST_CUSTOM_BACKEND || undefined,
|
|
195
200
|
koiosApiKey: process_1.env.KOIOS_API_KEY || '',
|
|
196
201
|
ogmiosUrl: process_1.env.OGMIOS_URL || '',
|
|
202
|
+
odatanoUrl: process_1.env.ODATANO_URL || undefined,
|
|
203
|
+
odatanoApiKey: process_1.env.ODATANO_API_KEY || undefined,
|
|
197
204
|
transactionBuilders: ['buildooor'],
|
|
198
205
|
primaryTimeoutMs: Number(process_1.env.PRIMARY_TIMEOUT_MS) || 30000, // || intentional: NaN (missing env var) falls back to default
|
|
199
206
|
fallbackTimeoutMs: Number(process_1.env.FALLBACK_TIMEOUT_MS) || 60000,
|
|
@@ -201,19 +208,15 @@ protocolParams) {
|
|
|
201
208
|
};
|
|
202
209
|
return await initializeAppContext(config, protocolParams);
|
|
203
210
|
}
|
|
204
|
-
/**
|
|
205
|
-
* Shutdown the application context (for cleanup in tests)
|
|
206
|
-
* Closes all backend connections to allow process to exit cleanly
|
|
207
|
-
*/
|
|
211
|
+
/** Stop worker and crawler, then close all backend connections. */
|
|
208
212
|
async function shutdownAppContext() {
|
|
209
|
-
//
|
|
213
|
+
// Worker and crawler first: their in-flight writes must not hit a torn-down client.
|
|
210
214
|
try {
|
|
211
215
|
await (0, wallet_worker_1.stopWalletWorker)();
|
|
212
216
|
}
|
|
213
217
|
catch (err) {
|
|
214
218
|
logger.warn('Wallet worker shutdown failed (continuing):', err);
|
|
215
219
|
}
|
|
216
|
-
// Stop the crawler so its in-flight block writes don't hit a torn-down client.
|
|
217
220
|
try {
|
|
218
221
|
await (0, crawler_1.stopCrawler)();
|
|
219
222
|
}
|
|
@@ -222,7 +225,6 @@ async function shutdownAppContext() {
|
|
|
222
225
|
}
|
|
223
226
|
if (appContext) {
|
|
224
227
|
logger.info('Shutting down application context...');
|
|
225
|
-
// Shutdown HSM signer if active
|
|
226
228
|
const hsm = (0, hsm_signer_1.getHsmSigner)();
|
|
227
229
|
if (hsm) {
|
|
228
230
|
hsm.shutdown();
|
|
@@ -235,36 +237,29 @@ async function shutdownAppContext() {
|
|
|
235
237
|
}
|
|
236
238
|
}
|
|
237
239
|
/**
|
|
238
|
-
* Load and validate CardanoClientConfig
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* { "cds": { "requires": { "odatano-core": { "network": "preview", "backends": ["blockfrost"], ... }}}}
|
|
242
|
-
*
|
|
243
|
-
* Priority: cds.env.requires["odatano-core"].X > process.env.X > default
|
|
244
|
-
*
|
|
245
|
-
* @returns validated CardanoClientConfig
|
|
246
|
-
* @throws {Error} if any config value is invalid
|
|
240
|
+
* Load and validate CardanoClientConfig.
|
|
241
|
+
* Priority: cds.env.requires["odatano-core"].X > process.env.X > default.
|
|
242
|
+
* @throws {ConfigError} if any value is invalid
|
|
247
243
|
*/
|
|
248
244
|
function loadConfigFromEnv() {
|
|
249
|
-
|
|
250
|
-
const cdsConfig = cds_1.default.env?.requires?.['odatano-core'] ?? {};
|
|
245
|
+
const cdsConfig = coreCdsConfig();
|
|
251
246
|
const network = (cdsConfig.network || process_1.env.NETWORK || 'preview');
|
|
252
247
|
if (!VALID_NETWORKS.includes(network)) {
|
|
253
248
|
throw new errors_1.ConfigError(`Invalid NETWORK "${cdsConfig.network || process_1.env.NETWORK}". Must be one of: ${VALID_NETWORKS.join(', ')}`);
|
|
254
249
|
}
|
|
255
|
-
const
|
|
256
|
-
|
|
250
|
+
const backendsRaw = cdsConfig.backends ?? process_1.env.BACKENDS;
|
|
251
|
+
const backendStrings = Array.isArray(backendsRaw) ? backendsRaw
|
|
252
|
+
: backendsRaw ? String(backendsRaw).split(',').map(b => b.trim()) : ['koios'];
|
|
257
253
|
const invalidBackends = backendStrings.filter(b => !VALID_BACKENDS.includes(b));
|
|
258
254
|
if (invalidBackends.length > 0) {
|
|
259
255
|
throw new errors_1.ConfigError(`Invalid BACKENDS: "${invalidBackends.join(', ')}". Must be one of: ${VALID_BACKENDS.join(', ')}`);
|
|
260
256
|
}
|
|
261
257
|
const backends = backendStrings;
|
|
262
|
-
// Buildooor is the sole transaction builder;
|
|
258
|
+
// Buildooor is the sole transaction builder; txBuilders/TX_BUILDERS config is ignored.
|
|
263
259
|
const txBuilders = ['buildooor'];
|
|
264
260
|
const primaryTimeout = cdsConfig.primaryTimeoutMs ?? process_1.env.PRIMARY_TIMEOUT_MS;
|
|
265
261
|
const fallbackTimeout = cdsConfig.fallbackTimeoutMs ?? process_1.env.FALLBACK_TIMEOUT_MS;
|
|
266
|
-
// `!= null
|
|
267
|
-
// skipped the <=0 check and 0 then silently became the default via `Number(0)||default`.
|
|
262
|
+
// `!= null`, not truthiness: a CDS-config 0 must reach the <= 0 check.
|
|
268
263
|
if (primaryTimeout != null && isNaN(Number(primaryTimeout))) {
|
|
269
264
|
throw new errors_1.ConfigError(`Invalid PRIMARY_TIMEOUT_MS "${primaryTimeout}". Must be a number.`);
|
|
270
265
|
}
|
|
@@ -285,7 +280,17 @@ function loadConfigFromEnv() {
|
|
|
285
280
|
}
|
|
286
281
|
const koiosApiKey = cdsConfig.koiosApiKey || process_1.env.KOIOS_API_KEY || '';
|
|
287
282
|
const ogmiosUrl = cdsConfig.ogmiosUrl || process_1.env.OGMIOS_URL || '';
|
|
288
|
-
|
|
283
|
+
const odatanoUrl = cdsConfig.odatanoUrl || process_1.env.ODATANO_URL || '';
|
|
284
|
+
const odatanoApiKey = cdsConfig.odatanoApiKey || process_1.env.ODATANO_API_KEY || '';
|
|
285
|
+
if (odatanoUrl && !/^https?:\/\//i.test(odatanoUrl)) {
|
|
286
|
+
throw new errors_1.ConfigError(`Invalid ODATANO_URL "${odatanoUrl}". Must be an http(s) URL (e.g. https://api.preprod.odatano.dev).`);
|
|
287
|
+
}
|
|
288
|
+
if (backends.includes('odatano') && !odatanoUrl && network === 'mainnet') {
|
|
289
|
+
throw new errors_1.ConfigError('ODATANO_URL is required for the odatano backend on mainnet.');
|
|
290
|
+
}
|
|
291
|
+
if (backends.includes('odatano') && !odatanoApiKey) {
|
|
292
|
+
logger.warn('ODATANO_API_KEY is not set but odatano is listed in BACKENDS; the public API refuses calls without a key');
|
|
293
|
+
}
|
|
289
294
|
if (backends.includes('blockfrost') && !blockfrostApiKey && !blockfrostCustomBackend) {
|
|
290
295
|
logger.warn('Neither BLOCKFROST_API_KEY nor BLOCKFROST_CUSTOM_BACKEND is set but blockfrost is listed in BACKENDS');
|
|
291
296
|
}
|
|
@@ -302,6 +307,8 @@ function loadConfigFromEnv() {
|
|
|
302
307
|
blockfrostCustomBackend: blockfrostCustomBackend || undefined,
|
|
303
308
|
koiosApiKey,
|
|
304
309
|
ogmiosUrl,
|
|
310
|
+
odatanoUrl: odatanoUrl || undefined,
|
|
311
|
+
odatanoApiKey: odatanoApiKey || undefined,
|
|
305
312
|
transactionBuilders: txBuilders,
|
|
306
313
|
primaryTimeoutMs: Number(primaryTimeout) || 30000, // || intentional: NaN (missing config) falls back to default
|
|
307
314
|
fallbackTimeoutMs: Number(fallbackTimeout) || 60000,
|
|
@@ -309,16 +316,11 @@ function loadConfigFromEnv() {
|
|
|
309
316
|
};
|
|
310
317
|
}
|
|
311
318
|
/**
|
|
312
|
-
* Load HSM configuration
|
|
313
|
-
* Returns undefined
|
|
314
|
-
*
|
|
315
|
-
* Plugin mode: cds.requires.odatano-core.hsm.enabled = true
|
|
316
|
-
* Env mode: HSM_ENABLED=true
|
|
317
|
-
*
|
|
318
|
-
* @returns HsmConfig or undefined
|
|
319
|
+
* Load the HSM configuration (cds.requires.odatano-core.hsm.* or HSM_* env vars).
|
|
320
|
+
* Returns undefined when HSM is not enabled.
|
|
319
321
|
*/
|
|
320
322
|
function loadHsmConfigFromEnv() {
|
|
321
|
-
const cdsConfig =
|
|
323
|
+
const cdsConfig = coreCdsConfig();
|
|
322
324
|
const hsmCds = cdsConfig.hsm ?? {};
|
|
323
325
|
const hsmEnabled = hsmCds.enabled === true || process_1.env.HSM_ENABLED === 'true';
|
|
324
326
|
if (!hsmEnabled)
|
|
@@ -335,8 +337,7 @@ function loadHsmConfigFromEnv() {
|
|
|
335
337
|
if (!Number.isInteger(slot) || slot < 0) {
|
|
336
338
|
throw new errors_1.ConfigError(`Invalid HSM slot: "${hsmCds.slot ?? process_1.env.HSM_SLOT}" — must be a non-negative integer`);
|
|
337
339
|
}
|
|
338
|
-
// Fail
|
|
339
|
-
// that an authenticated user cannot drain the HSM-controlled wallet by default.
|
|
340
|
+
// Fail closed: the HSM holds a real signing key, so an explicit role gate is mandatory.
|
|
340
341
|
const requiresRole = hsmCds.requiresRole || process_1.env.HSM_REQUIRES_ROLE || '';
|
|
341
342
|
if (!requiresRole) {
|
|
342
343
|
throw new errors_1.ConfigError('HSM_REQUIRES_ROLE (or cds.requires.odatano-core.hsm.requiresRole) is required when HSM is enabled — set it to the XSUAA scope name allowed to invoke HSM signing actions');
|
|
@@ -352,17 +353,13 @@ function loadHsmConfigFromEnv() {
|
|
|
352
353
|
};
|
|
353
354
|
}
|
|
354
355
|
/**
|
|
355
|
-
* Load the chain-crawler configuration
|
|
356
|
-
* Returns { enabled:false } when the crawler is
|
|
357
|
-
* existing deployments are unaffected.
|
|
358
|
-
*
|
|
359
|
-
* Plugin mode: cds.requires.odatano-core.crawler.{enabled,startSlot,startBlockHash,...}
|
|
360
|
-
* Env mode: CRAWLER_ENABLED / CRAWLER_START_SLOT / CRAWLER_START_HASH / ...
|
|
356
|
+
* Load the chain-crawler configuration (cds.requires.odatano-core.crawler.* or CRAWLER_* env vars).
|
|
357
|
+
* Returns { enabled: false } when the crawler is off (the default).
|
|
361
358
|
*/
|
|
362
359
|
function loadCrawlerConfigFromEnv() {
|
|
363
|
-
const cdsConfig =
|
|
360
|
+
const cdsConfig = coreCdsConfig();
|
|
364
361
|
const c = cdsConfig.crawler ?? {};
|
|
365
|
-
// A CDS value, including explicit `false`, wins over the environment.
|
|
362
|
+
// A CDS value, including an explicit `false`, wins over the environment.
|
|
366
363
|
const enabledRaw = c.enabled !== undefined ? c.enabled : process_1.env.CRAWLER_ENABLED;
|
|
367
364
|
let enabled = false;
|
|
368
365
|
if (enabledRaw === true || enabledRaw === 'true') {
|
|
@@ -389,13 +386,27 @@ function loadCrawlerConfigFromEnv() {
|
|
|
389
386
|
if (!['ogmios', 'pagination', 'auto'].includes(source)) {
|
|
390
387
|
throw new errors_1.ConfigError(`Invalid CRAWLER_SOURCE "${source}". Must be one of: ogmios, pagination, auto.`);
|
|
391
388
|
}
|
|
392
|
-
|
|
389
|
+
// Analytics coverage: mint/burn and the bare catalogue are free by-products of a crawled
|
|
390
|
+
// block and on by default; enrichment and epoch snapshots cost provider calls and are opt-in.
|
|
391
|
+
const assetHistory = crawlerBoolean(c.assetHistory ?? process_1.env.CRAWLER_ASSET_HISTORY, 'CRAWLER_ASSET_HISTORY', true);
|
|
392
|
+
const assetCatalogue = (c.assetCatalogue ?? process_1.env.CRAWLER_ASSET_CATALOGUE ?? 'bare');
|
|
393
|
+
if (!VALID_ASSET_CATALOGUE_MODES.includes(assetCatalogue)) {
|
|
394
|
+
throw new errors_1.ConfigError(`Invalid CRAWLER_ASSET_CATALOGUE "${assetCatalogue}". Must be one of: ${VALID_ASSET_CATALOGUE_MODES.join(', ')}.`);
|
|
395
|
+
}
|
|
396
|
+
const assetEnrichRate = crawlerInteger(c.assetEnrichRate ?? process_1.env.CRAWLER_ASSET_ENRICH_RATE, 'CRAWLER_ASSET_ENRICH_RATE', CRAWLER_LIMITS.assetEnrichRate.min, CRAWLER_LIMITS.assetEnrichRate.max, 2);
|
|
397
|
+
const epochSnapshots = crawlerBoolean(c.epochSnapshots ?? process_1.env.CRAWLER_EPOCH_SNAPSHOTS, 'CRAWLER_EPOCH_SNAPSHOTS', false);
|
|
398
|
+
// Certificates + withdrawals are block content (no extra request) but opt-in to keep write volume stable.
|
|
399
|
+
const certificates = crawlerBoolean(c.certificates ?? process_1.env.CRAWLER_CERTIFICATES, 'CRAWLER_CERTIFICATES', false);
|
|
400
|
+
// UTxO set: opt-in, inert until a snapshot has been imported (importUtxoSet).
|
|
401
|
+
const utxoSet = crawlerBoolean(c.utxoSet ?? process_1.env.CRAWLER_UTXO_SET, 'CRAWLER_UTXO_SET', false);
|
|
402
|
+
// Crawled chain answers misses with 404 instead of a provider call.
|
|
403
|
+
const authoritative = crawlerBoolean(c.authoritative ?? process_1.env.CRAWLER_AUTHORITATIVE, 'CRAWLER_AUTHORITATIVE', false);
|
|
404
|
+
return {
|
|
405
|
+
enabled, startSlot, startBlockHash, startHeight, source, batchSize, confirmationDepth, pollIntervalMs,
|
|
406
|
+
assetHistory, assetCatalogue, assetEnrichRate, epochSnapshots, certificates, utxoSet, authoritative,
|
|
407
|
+
};
|
|
393
408
|
}
|
|
394
|
-
/**
|
|
395
|
-
* Start the chain crawler if it is enabled and the app context is ready. Never throws
|
|
396
|
-
* (crawler failure must not affect request serving) — errors are logged. Idempotent:
|
|
397
|
-
* startCrawler() is a no-op when one is already running.
|
|
398
|
-
*/
|
|
409
|
+
/** Start the crawler if enabled and the app context is ready. Never throws; idempotent. */
|
|
399
410
|
async function startCrawlerIfConfigured() {
|
|
400
411
|
if (process_1.env.SKIP_AUTO_INIT === 'true' || !appContext)
|
|
401
412
|
return;
|
|
@@ -430,14 +441,11 @@ const WALLET_WORKER_LIMITS = {
|
|
|
430
441
|
maxAttempts: { min: 1, max: 10 },
|
|
431
442
|
};
|
|
432
443
|
/**
|
|
433
|
-
* Load the wallet-worker configuration
|
|
434
|
-
* Returns { enabled:false } when the worker is
|
|
435
|
-
*
|
|
436
|
-
* Plugin mode: cds.requires.odatano-core.walletWorker.{enabled,wallets,...}
|
|
437
|
-
* Env mode: WALLET_WORKER_ENABLED / WALLET_WORKER_WALLETS (JSON) / ...
|
|
444
|
+
* Load the wallet-worker configuration (cds.requires.odatano-core.walletWorker.* or WALLET_WORKER_* env vars).
|
|
445
|
+
* Returns { enabled: false } when the worker is off (the default).
|
|
438
446
|
*/
|
|
439
447
|
function loadWalletWorkerConfigFromEnv() {
|
|
440
|
-
const cdsConfig =
|
|
448
|
+
const cdsConfig = coreCdsConfig();
|
|
441
449
|
const w = cdsConfig.walletWorker ?? {};
|
|
442
450
|
const enabledRaw = w.enabled !== undefined ? w.enabled : process_1.env.WALLET_WORKER_ENABLED;
|
|
443
451
|
let enabled = false;
|
|
@@ -503,11 +511,7 @@ function loadWalletWorkerConfigFromEnv() {
|
|
|
503
511
|
resubmitOnRollback,
|
|
504
512
|
};
|
|
505
513
|
}
|
|
506
|
-
/**
|
|
507
|
-
* Start the wallet worker if it is enabled and the app context is ready. Never
|
|
508
|
-
* throws (worker failure must not affect request serving) — errors are logged.
|
|
509
|
-
* Idempotent: startWalletWorker() is a no-op when one is already running.
|
|
510
|
-
*/
|
|
514
|
+
/** Start the wallet worker if enabled and the app context is ready. Never throws; idempotent. */
|
|
511
515
|
async function startWalletWorkerIfConfigured() {
|
|
512
516
|
if (process_1.env.SKIP_AUTO_INIT === 'true' || !appContext)
|
|
513
517
|
return;
|
|
@@ -535,11 +539,9 @@ async function startWalletWorkerIfConfigured() {
|
|
|
535
539
|
}
|
|
536
540
|
}
|
|
537
541
|
/**
|
|
538
|
-
* Re-drive deferred submissions
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
* submitted tx finalizes via the TransactionAlreadySubmittedError path.
|
|
542
|
-
* Non-fatal, mirrors startCrawlerIfConfigured/startWalletWorkerIfConfigured.
|
|
542
|
+
* Re-drive deferred submissions claimed as 'submitting' whose detached submit never ran
|
|
543
|
+
* (process died first). Idempotent: an already submitted tx finalizes via
|
|
544
|
+
* TransactionAlreadySubmittedError. Never throws.
|
|
543
545
|
*/
|
|
544
546
|
async function redriveInterruptedSubmissionsIfConfigured() {
|
|
545
547
|
if (process_1.env.SKIP_AUTO_INIT === 'true' || !appContext)
|
|
@@ -554,20 +556,16 @@ async function redriveInterruptedSubmissionsIfConfigured() {
|
|
|
554
556
|
logger.error('Failed to re-drive interrupted submissions (non-fatal):', err);
|
|
555
557
|
}
|
|
556
558
|
}
|
|
557
|
-
//
|
|
559
|
+
// Standalone bootstrap; skipped when the plugin already initialized the context.
|
|
558
560
|
cds_1.default.on('served', async () => {
|
|
559
|
-
// Skip if already initialized by plugin (src/plugin.ts runs first)
|
|
560
561
|
if (appContext)
|
|
561
562
|
return;
|
|
562
|
-
//
|
|
563
|
+
// SKIP_AUTO_INIT: tests with mocked backends
|
|
563
564
|
if (process_1.env.SKIP_AUTO_INIT === 'true') {
|
|
564
565
|
logger.info('Skipping auto-initialization (SKIP_AUTO_INIT=true)');
|
|
565
566
|
return;
|
|
566
567
|
}
|
|
567
|
-
//
|
|
568
|
-
// throw ConfigError synchronously (missing HSM_PIN, bad slot, no requiresRole…).
|
|
569
|
-
// Outside the try that would crash the host app's bootstrap in plugin mode,
|
|
570
|
-
// violating the plugin contract ("never throw on failure").
|
|
568
|
+
// Config loading stays inside the try: a ConfigError must never crash the host app.
|
|
571
569
|
let config;
|
|
572
570
|
try {
|
|
573
571
|
config = loadConfigFromEnv();
|
|
@@ -578,25 +576,19 @@ cds_1.default.on('served', async () => {
|
|
|
578
576
|
logger.info('CAP server bootstrap complete');
|
|
579
577
|
}
|
|
580
578
|
catch (err) {
|
|
581
|
-
//
|
|
582
|
-
// Capture the cause so getAppContext() can surface a structured 503 with diagnostics
|
|
583
|
-
// instead of the raw "Application not initialized" Error landing as a generic 500.
|
|
579
|
+
// Never throw; keep the cause so getAppContext() surfaces a structured 503.
|
|
584
580
|
bootstrapError = err instanceof Error ? err : new Error(String(err));
|
|
585
|
-
//
|
|
586
|
-
// suppress console.error (vitest.setup.ts in this repo silences it).
|
|
581
|
+
// stderr directly: the cause stays visible when a test runner silences console.error.
|
|
587
582
|
const where = config ? `backends={${config.backends.join(',')}} network=${config.network}` : 'config load';
|
|
588
583
|
const msg = err instanceof Error ? `${err.name}: ${err.message}\n${err.stack ?? ''}` : String(err);
|
|
589
584
|
process.stderr.write(`[ODATANO] Failed to initialize blockchain components — ${where}\n${msg}\n`);
|
|
590
585
|
logger.error('Failed to initialize blockchain components:', err);
|
|
591
586
|
}
|
|
592
|
-
//
|
|
587
|
+
// Optional subsystems; each is non-fatal.
|
|
593
588
|
await startCrawlerIfConfigured();
|
|
594
|
-
// Start the wallet worker if configured (standalone mode). Non-fatal.
|
|
595
589
|
await startWalletWorkerIfConfigured();
|
|
596
|
-
// Re-drive deferred submissions interrupted by a restart (standalone mode). Non-fatal.
|
|
597
590
|
await redriveInterruptedSubmissionsIfConfigured();
|
|
598
591
|
});
|
|
599
|
-
// Shutdown hook - runs when CAP server is shutting down (e.g., cds.shutdown() in tests)
|
|
600
592
|
cds_1.default.on('shutdown', async () => {
|
|
601
593
|
await shutdownAppContext();
|
|
602
594
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-grant feature switch from `cds.requires.odatano-core.agentGrants`, else the environment
|
|
3
|
+
* (AGENT_GRANTS_ENABLED, AGENT_GRANTS_DELEGATE, AGENT_GRANT_ADMIN_RATE_LIMIT). Own module because
|
|
4
|
+
* src/plugin.ts reads it at plugin load, before any blockchain module is required.
|
|
5
|
+
*/
|
|
6
|
+
export interface AgentGrantsConfig {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
/** CAP auth kind the transport middleware delegates to for non-token requests. */
|
|
9
|
+
delegate: string;
|
|
10
|
+
/** Grant administration calls per principal per hour (integer >= 1). */
|
|
11
|
+
adminRateLimit: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const AGENT_GRANTS_DELEGATES: readonly string[];
|
|
14
|
+
export declare const AGENT_GRANT_ADMIN_RATE_LIMIT_DEFAULT = 10;
|
|
15
|
+
/**
|
|
16
|
+
* Grant-administration calls per principal per hour: `agentGrants.adminRateLimit`, then
|
|
17
|
+
* `AGENT_GRANT_ADMIN_RATE_LIMIT`, default 10. An unusable value is logged and falls back, never disables the feature.
|
|
18
|
+
*/
|
|
19
|
+
export declare function loadGrantAdminRateLimit(env?: Record<string, string | undefined>): number;
|
|
20
|
+
export declare const AGENT_TOKEN_CACHE_MS_DEFAULT = 10000;
|
|
21
|
+
/**
|
|
22
|
+
* How long the transport lane reuses a resolved grant row before re-reading the DB: `agentGrants.tokenCacheMs`,
|
|
23
|
+
* then `AGENT_TOKEN_CACHE_MS`, default 10 s, 0 disables. Bounds how late a revoke on another replica takes effect.
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadTokenCacheMs(env?: Record<string, string | undefined>): number;
|
|
26
|
+
/** The configured `cds.requires.auth` as an object (the shorthand `"auth": "xsuaa"` is a string). */
|
|
27
|
+
export declare function configuredAuth(): Record<string, unknown>;
|
|
28
|
+
/** A host-configured custom `cds.requires.auth.impl` (not this package's middleware); the lane wraps it. */
|
|
29
|
+
export declare function customAuthImpl(auth?: Record<string, unknown>): string | null;
|
|
30
|
+
export declare function loadAgentGrantsConfig(env?: Record<string, string | undefined>): AgentGrantsConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Switch agent grants on when configured: installs @odatano/cap-auth with the `x-agent-token` lane
|
|
33
|
+
* (previous strategy kept as delegate) and attaches the enforcement hook to each service on `serving`.
|
|
34
|
+
* Called from src/plugin.ts and srv/server.ts, before cds.server() builds middlewares. Never throws.
|
|
35
|
+
*/
|
|
36
|
+
export declare function activateAgentGrants(): boolean;
|
|
37
|
+
//# sourceMappingURL=agent-grants-config.d.ts.map
|