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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,180 +1,200 @@
1
- using {odatano.cardano as db} from '../db/schema';
2
- using {Bech32} from '../db/types';
3
-
4
- /**
5
- * Cardano Sign Service
6
- *
7
- * Handles the external signing workflow for Cardano transactions, including:
8
- * - Creating signing requests with transaction details and signing instructions
9
- * - Verifying signatures of signed transactions and storing verification results
10
- * - Submitting verified transactions to the blockchain and tracking submission status
11
- * - Providing actions for signing with a Hardware Security Module (HSM) and retrieving HSM status
12
- *
13
- * Security note: see CardanoODataService (cardano-service.cds) for the rationale
14
- * on service-level auth without per-resource ownership enforcement.
15
- */
16
- @requires: 'authenticated-user'
17
- service CardanoSignService @(impl: './cardano-sign-service') {
18
-
19
- // ---------------------------------------------------------------------------
20
- // Signing Workflow Projections
21
- // ---------------------------------------------------------------------------
22
- @readonly
23
- @title : 'Signature Verifications'
24
- @description: 'Projection for Signature Verifications - stores verification results'
25
- entity SignatureVerifications as projection on db.SignatureVerifications;
26
-
27
- @readonly
28
- @title : 'Address Signing Requests'
29
- @description: 'Projection for retrieving signing requests by address'
30
- entity AddressSigningRequests as projection on db.AddressSigningRequests;
31
-
32
- @readonly
33
- @title : 'Transaction Builds'
34
- @description: 'Projection for Transaction Builds - needed by CreateSigningRequest to look up build details'
35
- entity TransactionBuilds as projection on db.TransactionBuilds;
36
-
37
-
38
- @readonly
39
- @title : 'Transaction Submissions'
40
- @description: 'Projection for Transaction Submissions - stores submission results'
41
- entity TransactionSubmissions as projection on db.TransactionSubmissions;
42
-
43
- @readonly
44
- @title : 'Signing Requests'
45
- @description: 'Projection for Signing Requests - tracks signing workflow'
46
- entity SigningRequests as projection on db.SigningRequests;
47
-
48
- @title : 'Verify Signature'
49
- @description: 'Verify the signature of a signed transaction. Stores the verification result for audit trail.'
50
- action VerifySignature(
51
- @title: 'Signing Request ID'
52
- @description: 'The unique identifier of the signing request'
53
- signingRequestId: UUID,
54
- @title: 'Signed Transaction CBOR'
55
- @description: 'The signed transaction CBOR to verify'
56
- signedTxCbor: String,
57
- @title: 'Signer Type'
58
- @description: 'Type of signer used (cardano-cli | browser-wallet | hardware-wallet | custom)'
59
- signerType: String(20),
60
- @title: 'Signer Info'
61
- @description: 'Additional signer information (wallet name, etc.)'
62
- signerInfo: String(100),
63
- @title: 'Sender Address'
64
- @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
65
- address: Bech32) returns SignatureVerifications;
66
-
67
- @title : 'Submit Verified Transaction'
68
- @description: 'Verify and submit a signed transaction in one step. Updates the signing request status and creates submission record.'
69
- action SubmitVerifiedTransaction(
70
- @title: 'Signing Request ID'
71
- @description: 'The unique identifier of the signing request'
72
- signingRequestId: UUID,
73
- @title: 'Signed Transaction CBOR'
74
- @description: 'The signed transaction CBOR'
75
- signedTxCbor: String,
76
- @title: 'Signer Type'
77
- @description: 'Type of signer used'
78
- signerType: String(20),
79
- @title: 'Signer Info'
80
- @description: 'Additional signer information'
81
- signerInfo: String(100),
82
- @title: 'Sender Address'
83
- @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
84
- address: Bech32,
85
- @title: 'Defer Submit'
86
- @description: 'When true, verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit. Returns immediately with the tx hash (= tx body hash) and status ''pending''. Designed for in-process CAP consumers whose request transaction would otherwise deadlock the pooled sqlite connection (KNOWN_ISSUES #11). Track the outcome via the signing request / submission status.'
87
- deferSubmit: Boolean) returns TransactionSubmissions;
88
-
89
-
90
- // ---------------------------------------------------------------------------
91
- // CIP-30 signData (COSE_Sign1) message-signature verification
92
- // ---------------------------------------------------------------------------
93
-
94
- // Public override: this action is the crypto check behind wallet-based LOGIN,
95
- // so the caller is not yet authenticated. It is a stateless verification —
96
- // no DB write, no key access, no state — so exposing it leaks nothing.
97
- @requires : 'any'
98
- @title : 'Verify Data Signature (CIP-30 signData)'
99
- @description: 'Verify a COSE_Sign1 message signature against a bech32 address. Confirms the Ed25519 signature, that the signer key hashes to the address payment credential, and (optionally) that the signed payload matches an expected value.'
100
- action VerifyDataSignature(
101
- @description: 'Bech32 address the wallet claimed to sign with'
102
- address : Bech32,
103
- @description: 'Hex-encoded COSE_Sign1 CBOR (the `signature` field from CIP-30 signData)'
104
- coseSignature : String,
105
- @description: 'Hex-encoded COSE_Key CBOR (the `key` field from CIP-30 signData)'
106
- coseKey : String,
107
- @description: 'Optional expected UTF-8 payload; when set, the signed payload must equal it (anti-replay). When omitted, the decoded payload is returned for the caller to check.'
108
- expectedPayload: String) returns {
109
- @description: 'Whether the signature is valid and all checks passed' valid : Boolean;
110
- @description: 'Failure detail when not valid' reason : String;
111
- @description: 'UTF-8 of the signed payload, echoed back' signedPayload : String;
112
- @description: 'Hex blake2b-224 of the signer public key' signerVkh : String;
113
- };
114
-
115
- // ---------------------------------------------------------------------------
116
- // General Signing Workflow Actions
117
- // ---------------------------------------------------------------------------
118
-
119
- @title : 'Create Signing Request'
120
- @description: 'Create a signing request for external signing. Returns transaction details, signing instructions, and CLI commands. The request is persisted for audit trail.'
121
- action CreateSigningRequest(
122
- @title: 'Build ID'
123
- @description: 'The unique identifier of the transaction build'
124
- buildId: UUID,
125
- @title: 'Message to Signer'
126
- @description: 'A message to include for the signer'
127
- message: String) returns SigningRequests;
128
-
129
- @title : 'Get Signing Request'
130
- @description: 'Retrieve an existing signing request by ID'
131
- action GetSigningRequest(
132
- @title: 'Signing Request ID'
133
- @description: 'The unique identifier of the signing request'
134
- signingRequestId: UUID) returns SigningRequests;
135
-
136
- @title : 'Address Signing Requests'
137
- @description: 'Projection for retrieving signing requests by address'
138
- action GetSigningRequestsByAddress(
139
- @title: 'Bech32 Address'
140
- @description: 'The Bech32 encoded address to retrieve signing requests for'
141
- address: Bech32) returns array of AddressSigningRequests;
142
-
143
- // ---------------------------------------------------------------------------
144
- // HSM (Hardware Security Module) Signing Actions
145
- // ---------------------------------------------------------------------------
146
-
147
- @title : 'Sign with HSM'
148
- @description: 'Sign a transaction using the configured Hardware Security Module. Creates a signing request, signs with the HSM, and verifies the signature. Returns the signing request with status verified.'
149
- action SignWithHsm(
150
- @title: 'Build ID'
151
- @description: 'The unique identifier of the transaction build to sign'
152
- buildId: UUID,
153
- @title: 'Sender Address'
154
- @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
155
- address: Bech32) returns SigningRequests;
156
-
157
- @title : 'Sign and Submit with HSM'
158
- @description: 'Sign a transaction using the HSM and submit it to the blockchain in one atomic operation. Returns the transaction submission details.'
159
- action SignAndSubmitWithHsm(
160
- @title: 'Build ID'
161
- @description: 'The unique identifier of the transaction build to sign and submit'
162
- buildId: UUID,
163
- @title: 'Sender Address'
164
- @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
165
- address: Bech32,
166
- @title: 'Defer Submit'
167
- @description: 'When true, sign + verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit (see SubmitVerifiedTransaction.deferSubmit).'
168
- deferSubmit: Boolean) returns TransactionSubmissions;
169
-
170
- @title : 'Get HSM Status'
171
- @description: 'Check the current status of the HSM connection and key availability.'
172
- action GetHsmStatus() returns {
173
- @title: 'Connected' @description: 'Whether the HSM session is active' connected : Boolean;
174
- @title: 'Key ID' @description: 'The PKCS#11 key identifier in use' keyId : String;
175
- @title: 'Key Label' @description: 'The PKCS#11 key label in use' keyLabel : String;
176
- @title: 'Public Key Hash' @description: 'Blake2b-224 hash of the HSM Ed25519 public key (= Cardano verification key hash)' publicKeyHash : String;
177
- @title: 'Cardano Address' @description: 'Enterprise Cardano address derived from the HSM public key' cardanoAddress : String;
178
- };
179
-
180
- }
1
+ using {odatano.cardano as db} from '../db/schema';
2
+ using {Bech32} from '../db/types';
3
+
4
+ /**
5
+ * Cardano Sign Service
6
+ *
7
+ * Handles the external signing workflow for Cardano transactions, including:
8
+ * - Creating signing requests with transaction details and signing instructions
9
+ * - Verifying signatures of signed transactions and storing verification results
10
+ * - Submitting verified transactions to the blockchain and tracking submission status
11
+ * - Providing actions for signing with a Hardware Security Module (HSM) and retrieving HSM status
12
+ *
13
+ * Security note: see CardanoODataService (cardano-service.cds) for the rationale on auth
14
+ * without per-resource ownership enforcement. Deliberately NO service-level @requires:
15
+ * CAP checks it on every request BEFORE the operation annotation, which silenced the
16
+ * `any` on VerifyDataSignature (anonymous callers got the 401 challenge first). The
17
+ * requirement therefore sits on each element; VerifyDataSignature alone is public.
18
+ */
19
+ // Service-level 'any' on purpose: CAP authorizes the service BEFORE the operation and
20
+ // treats a service without a service-level @requires as authenticated-user under
21
+ // NODE_ENV=production, which would 401 the anonymous operation below despite its own
22
+ // 'any'. Every element carries its requirement; the service itself refuses nothing.
23
+ @requires: 'any'
24
+ service CardanoSignService @(impl: './cardano-sign-service') {
25
+
26
+ // ---------------------------------------------------------------------------
27
+ // Signing Workflow Projections
28
+ // ---------------------------------------------------------------------------
29
+ @readonly
30
+ @title : 'Signature Verifications'
31
+ @description: 'Projection for Signature Verifications - stores verification results'
32
+ @requires : 'authenticated-user'
33
+ entity SignatureVerifications as projection on db.SignatureVerifications;
34
+
35
+ @readonly
36
+ @title : 'Address Signing Requests'
37
+ @description: 'Projection for retrieving signing requests by address'
38
+ @requires : 'authenticated-user'
39
+ entity AddressSigningRequests as projection on db.AddressSigningRequests;
40
+
41
+ @readonly
42
+ @title : 'Transaction Builds'
43
+ @description: 'Projection for Transaction Builds - needed by CreateSigningRequest to look up build details'
44
+ @requires : 'authenticated-user'
45
+ entity TransactionBuilds as projection on db.TransactionBuilds;
46
+
47
+
48
+ @readonly
49
+ @title : 'Transaction Submissions'
50
+ @description: 'Projection for Transaction Submissions - stores submission results'
51
+ @requires : 'authenticated-user'
52
+ entity TransactionSubmissions as projection on db.TransactionSubmissions;
53
+
54
+ @readonly
55
+ @title : 'Signing Requests'
56
+ @description: 'Projection for Signing Requests - tracks signing workflow'
57
+ @requires : 'authenticated-user'
58
+ entity SigningRequests as projection on db.SigningRequests;
59
+
60
+ @title : 'Verify Signature'
61
+ @description: 'Verify the signature of a signed transaction. Stores the verification result for audit trail.'
62
+ @requires : 'authenticated-user'
63
+ action VerifySignature(
64
+ @title: 'Signing Request ID'
65
+ @description: 'The unique identifier of the signing request'
66
+ signingRequestId: UUID,
67
+ @title: 'Signed Transaction CBOR'
68
+ @description: 'The signed transaction CBOR to verify'
69
+ signedTxCbor: String,
70
+ @title: 'Signer Type'
71
+ @description: 'Type of signer used (cardano-cli | browser-wallet | hardware-wallet | custom)'
72
+ signerType: String(20),
73
+ @title: 'Signer Info'
74
+ @description: 'Additional signer information (wallet name, etc.)'
75
+ signerInfo: String(100),
76
+ @title: 'Sender Address'
77
+ @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
78
+ address: Bech32) returns SignatureVerifications;
79
+
80
+ @title : 'Submit Verified Transaction'
81
+ @description: 'Verify and submit a signed transaction in one step. Updates the signing request status and creates submission record.'
82
+ @requires : 'authenticated-user'
83
+ action SubmitVerifiedTransaction(
84
+ @title: 'Signing Request ID'
85
+ @description: 'The unique identifier of the signing request'
86
+ signingRequestId: UUID,
87
+ @title: 'Signed Transaction CBOR'
88
+ @description: 'The signed transaction CBOR'
89
+ signedTxCbor: String,
90
+ @title: 'Signer Type'
91
+ @description: 'Type of signer used'
92
+ signerType: String(20),
93
+ @title: 'Signer Info'
94
+ @description: 'Additional signer information'
95
+ signerInfo: String(100),
96
+ @title: 'Sender Address'
97
+ @description: 'Optional sender address for ownership verification. When provided, verifies the signing request belongs to this address.'
98
+ address: Bech32,
99
+ @title: 'Defer Submit'
100
+ @description: 'When true, verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit. Returns immediately with the tx hash (= tx body hash) and status ''pending''. Designed for in-process CAP consumers whose request transaction would otherwise deadlock the pooled sqlite connection (KNOWN_ISSUES #11). Track the outcome via the signing request / submission status.'
101
+ deferSubmit: Boolean) returns TransactionSubmissions;
102
+
103
+
104
+ // ---------------------------------------------------------------------------
105
+ // CIP-30 signData (COSE_Sign1) message-signature verification
106
+ // ---------------------------------------------------------------------------
107
+
108
+ // Public override: this action is the crypto check behind wallet-based LOGIN,
109
+ // so the caller is not yet authenticated. It is a stateless verification —
110
+ // no DB write, no key access, no state — so exposing it leaks nothing.
111
+ @requires : 'any'
112
+ @title : 'Verify Data Signature (CIP-30 signData)'
113
+ @description: 'Verify a COSE_Sign1 message signature against a bech32 address. Confirms the Ed25519 signature, that the signer key hashes to the address payment credential, and (optionally) that the signed payload matches an expected value.'
114
+ action VerifyDataSignature(
115
+ @description: 'Bech32 address the wallet claimed to sign with'
116
+ address : Bech32,
117
+ @description: 'Hex-encoded COSE_Sign1 CBOR (the `signature` field from CIP-30 signData)'
118
+ coseSignature : String,
119
+ @description: 'Hex-encoded COSE_Key CBOR (the `key` field from CIP-30 signData)'
120
+ coseKey : String,
121
+ @description: 'Optional expected UTF-8 payload; when set, the signed payload must equal it (anti-replay). When omitted, the decoded payload is returned for the caller to check.'
122
+ expectedPayload: String) returns {
123
+ @description: 'Whether the signature is valid and all checks passed' valid : Boolean;
124
+ @description: 'Failure detail when not valid' reason : String;
125
+ @description: 'UTF-8 of the signed payload, echoed back' signedPayload : String;
126
+ @description: 'Hex blake2b-224 of the signer public key' signerVkh : String;
127
+ };
128
+
129
+ // ---------------------------------------------------------------------------
130
+ // General Signing Workflow Actions
131
+ // ---------------------------------------------------------------------------
132
+
133
+ @title : 'Create Signing Request'
134
+ @description: 'Create a signing request for external signing. Returns transaction details, signing instructions, and CLI commands. The request is persisted for audit trail.'
135
+ @requires : 'authenticated-user'
136
+ action CreateSigningRequest(
137
+ @title: 'Build ID'
138
+ @description: 'The unique identifier of the transaction build'
139
+ buildId: UUID,
140
+ @title: 'Message to Signer'
141
+ @description: 'A message to include for the signer'
142
+ message: String) returns SigningRequests;
143
+
144
+ @title : 'Get Signing Request'
145
+ @description: 'Retrieve an existing signing request by ID'
146
+ @requires : 'authenticated-user'
147
+ action GetSigningRequest(
148
+ @title: 'Signing Request ID'
149
+ @description: 'The unique identifier of the signing request'
150
+ signingRequestId: UUID) returns SigningRequests;
151
+
152
+ @title : 'Address Signing Requests'
153
+ @description: 'Projection for retrieving signing requests by address'
154
+ @requires : 'authenticated-user'
155
+ action GetSigningRequestsByAddress(
156
+ @title: 'Bech32 Address'
157
+ @description: 'The Bech32 encoded address to retrieve signing requests for'
158
+ address: Bech32) returns array of AddressSigningRequests;
159
+
160
+ // ---------------------------------------------------------------------------
161
+ // HSM (Hardware Security Module) Signing Actions
162
+ // ---------------------------------------------------------------------------
163
+
164
+ @title : 'Sign with HSM'
165
+ @description: 'Sign a transaction using the configured Hardware Security Module. Creates a signing request, signs with the HSM, and verifies the signature. Returns the signing request with status verified.'
166
+ @requires : 'authenticated-user'
167
+ action SignWithHsm(
168
+ @title: 'Build ID'
169
+ @description: 'The unique identifier of the transaction build to sign'
170
+ buildId: UUID,
171
+ @title: 'Sender Address'
172
+ @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
173
+ address: Bech32) returns SigningRequests;
174
+
175
+ @title : 'Sign and Submit with HSM'
176
+ @description: 'Sign a transaction using the HSM and submit it to the blockchain in one atomic operation. Returns the transaction submission details.'
177
+ @requires : 'authenticated-user'
178
+ action SignAndSubmitWithHsm(
179
+ @title: 'Build ID'
180
+ @description: 'The unique identifier of the transaction build to sign and submit'
181
+ buildId: UUID,
182
+ @title: 'Sender Address'
183
+ @description: 'Optional sender address for ownership verification. When provided, verifies the build belongs to this address.'
184
+ address: Bech32,
185
+ @title: 'Defer Submit'
186
+ @description: 'When true, sign + verify + claim run on the caller''s transaction and the network submit happens detached AFTER the caller''s commit (see SubmitVerifiedTransaction.deferSubmit).'
187
+ deferSubmit: Boolean) returns TransactionSubmissions;
188
+
189
+ @title : 'Get HSM Status'
190
+ @description: 'Check the current status of the HSM connection and key availability.'
191
+ @requires : 'authenticated-user'
192
+ action GetHsmStatus() returns {
193
+ @title: 'Connected' @description: 'Whether the HSM session is active' connected : Boolean;
194
+ @title: 'Key ID' @description: 'The PKCS#11 key identifier in use' keyId : String;
195
+ @title: 'Key Label' @description: 'The PKCS#11 key label in use' keyLabel : String;
196
+ @title: 'Public Key Hash' @description: 'Blake2b-224 hash of the HSM Ed25519 public key (= Cardano verification key hash)' publicKeyHash : String;
197
+ @title: 'Cardano Address' @description: 'Enterprise Cardano address derived from the HSM public key' cardanoAddress : String;
198
+ };
199
+
200
+ }
@@ -4,19 +4,35 @@
4
4
  * src/plugin.ts reads it at plugin load, before any blockchain module may be
5
5
  * required.
6
6
  *
7
- * cds: "odatano-core": { "agentGrants": { "enabled": true, "delegate": "mocked" } }
7
+ * cds: "odatano-core": { "agentGrants": { "enabled": true, "delegate": "mocked", "adminRateLimit": 10 } }
8
8
  * env: AGENT_GRANTS_ENABLED=true AGENT_GRANTS_DELEGATE=mocked|basic|jwt|xsuaa|ias|dummy
9
+ * AGENT_GRANT_ADMIN_RATE_LIMIT=10
9
10
  *
10
11
  * `delegate` names the CAP auth strategy that keeps authenticating every
11
12
  * request WITHOUT an `x-agent-token` header (the transport lane only adds the
12
13
  * token path next to it). Default: the configured `cds.requires.auth.kind`.
14
+ *
15
+ * `adminRateLimit` is the number of grant-administration calls
16
+ * (CreateAgentGrant, UpdateAgentGrant, RotateAgentGrantToken, RevokeAgentGrant)
17
+ * one principal may make per hour; NIGHTGATE's `NIGHTGATE_GRANT_ADMIN_RATE_LIMIT`.
18
+ * A gateway that mints for everybody (ODATANO ACCESS) raises it.
13
19
  */
14
20
  export interface AgentGrantsConfig {
15
21
  enabled: boolean;
16
22
  /** CAP auth kind the transport middleware delegates to for non-token requests. */
17
23
  delegate: string;
24
+ /** Grant administration calls per principal per hour (integer >= 1). */
25
+ adminRateLimit: number;
18
26
  }
19
27
  export declare const AGENT_GRANTS_DELEGATES: readonly string[];
28
+ export declare const AGENT_GRANT_ADMIN_RATE_LIMIT_DEFAULT = 10;
29
+ /**
30
+ * The admin rate limit: `agentGrants.adminRateLimit`, then
31
+ * `AGENT_GRANT_ADMIN_RATE_LIMIT`, default 10. An unusable value (not an
32
+ * integer, below 1) is logged once and falls back to the default — a typo in
33
+ * this knob must not switch the whole feature off, unlike a wrong delegate.
34
+ */
35
+ export declare function loadGrantAdminRateLimit(env?: Record<string, string | undefined>): number;
20
36
  /** The configured `cds.requires.auth` as an object (the shorthand `"auth": "xsuaa"` is a string). */
21
37
  export declare function configuredAuth(): Record<string, unknown>;
22
38
  /**
@@ -3,7 +3,8 @@ 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.AGENT_GRANTS_DELEGATES = void 0;
6
+ exports.AGENT_GRANT_ADMIN_RATE_LIMIT_DEFAULT = exports.AGENT_GRANTS_DELEGATES = void 0;
7
+ exports.loadGrantAdminRateLimit = loadGrantAdminRateLimit;
7
8
  exports.configuredAuth = configuredAuth;
8
9
  exports.customAuthImpl = customAuthImpl;
9
10
  exports.loadAgentGrantsConfig = loadAgentGrantsConfig;
@@ -11,6 +12,25 @@ exports.activateAgentGrants = activateAgentGrants;
11
12
  const cds_1 = __importDefault(require("@sap/cds"));
12
13
  const path_1 = __importDefault(require("path"));
13
14
  exports.AGENT_GRANTS_DELEGATES = ['mocked', 'basic', 'jwt', 'xsuaa', 'ias', 'dummy'];
15
+ exports.AGENT_GRANT_ADMIN_RATE_LIMIT_DEFAULT = 10;
16
+ /**
17
+ * The admin rate limit: `agentGrants.adminRateLimit`, then
18
+ * `AGENT_GRANT_ADMIN_RATE_LIMIT`, default 10. An unusable value (not an
19
+ * integer, below 1) is logged once and falls back to the default — a typo in
20
+ * this knob must not switch the whole feature off, unlike a wrong delegate.
21
+ */
22
+ function loadGrantAdminRateLimit(env = process.env) {
23
+ const cfg = envRecord();
24
+ const raw = cfg.adminRateLimit !== undefined ? cfg.adminRateLimit : env.AGENT_GRANT_ADMIN_RATE_LIMIT;
25
+ if (raw === undefined || raw === null || String(raw).trim() === '')
26
+ return exports.AGENT_GRANT_ADMIN_RATE_LIMIT_DEFAULT;
27
+ const n = Number(raw);
28
+ if (!Number.isInteger(n) || n < 1) {
29
+ cds_1.default.log('ODATANO').warn(`AGENT_GRANT_ADMIN_RATE_LIMIT "${String(raw)}" is not an integer >= 1; using ${exports.AGENT_GRANT_ADMIN_RATE_LIMIT_DEFAULT}`);
30
+ return exports.AGENT_GRANT_ADMIN_RATE_LIMIT_DEFAULT;
31
+ }
32
+ return n;
33
+ }
14
34
  function envRecord() {
15
35
  const requires = (cds_1.default.env?.requires ?? {});
16
36
  const core = (requires['odatano-core'] ?? {});
@@ -54,7 +74,7 @@ function loadAgentGrantsConfig(env = process.env) {
54
74
  if (enabled && delegate === 'custom' && !customAuthImpl(auth)) {
55
75
  throw new Error('agentGrants.delegate "custom" needs a custom cds.requires.auth.impl to delegate to');
56
76
  }
57
- return { enabled, delegate };
77
+ return { enabled, delegate, adminRateLimit: loadGrantAdminRateLimit(env) };
58
78
  }
59
79
  /**
60
80
  * Marker on the shared `cds` facade: the activation below must run exactly once