@praesidias/sdk 0.1.0 → 0.1.1

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/dist/index.cjs CHANGED
@@ -257,6 +257,8 @@ var SENTENCES = {
257
257
  DENY_POLICY_AUTHORITY_SCOPE_REQUIREMENTS_UNMET: "This agent's access does not cover what the rule requires.",
258
258
  DENY_POLICY_AUTHORITY_PATH_REQUIREMENTS_UNMET: "This agent's access was not given the way the rule requires.",
259
259
  DENY_POLICY_CHANGED_DURING_DECISION: "The rules changed while this was being decided. Ask again.",
260
+ DENY_GROUPS_CHANGED_DURING_DECISION: "This agent's groups changed while this was being decided. Ask again.",
261
+ ALLOW_POLICY_REPORT_ONLY: "A rule allows this.",
260
262
  DENY_PRINCIPAL_NOT_BOUND: "This key may not act as that agent.",
261
263
  DENY_WORKLOAD_NOT_VERIFIED: "This agent must run from its own workload, and this request did not prove that.",
262
264
  DENY_DOMAIN_NO_MATCH: "This action is outside every area, so it is blocked.",
@@ -276,6 +278,10 @@ var isWaitingCode = (code) => WAITING.has(code);
276
278
  function sentenceFor(code) {
277
279
  return SENTENCES[code] ?? (code.startsWith("DENY_") ? "Praesidias blocked this action." : code);
278
280
  }
281
+ function messageOf(reasons, code) {
282
+ const own = reasons?.caseMessage;
283
+ return typeof own === "string" && own.trim() ? own.slice(0, 500) : sentenceFor(code);
284
+ }
279
285
 
280
286
  // src/report.ts
281
287
  var ACTION_NAME = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/;
@@ -545,7 +551,7 @@ var Praesidias = class {
545
551
  return {
546
552
  decisionId: body.decisionId,
547
553
  allowed: result === "ALLOW",
548
- reason: { code, message: sentenceFor(code) },
554
+ reason: { code, message: messageOf(body.reasons, code) },
549
555
  context,
550
556
  caseId: typeof caseId === "string" ? caseId : null,
551
557
  boundPaths: Array.isArray(paths) ? paths.map(String) : [],
package/dist/index.js CHANGED
@@ -201,6 +201,8 @@ var SENTENCES = {
201
201
  DENY_POLICY_AUTHORITY_SCOPE_REQUIREMENTS_UNMET: "This agent's access does not cover what the rule requires.",
202
202
  DENY_POLICY_AUTHORITY_PATH_REQUIREMENTS_UNMET: "This agent's access was not given the way the rule requires.",
203
203
  DENY_POLICY_CHANGED_DURING_DECISION: "The rules changed while this was being decided. Ask again.",
204
+ DENY_GROUPS_CHANGED_DURING_DECISION: "This agent's groups changed while this was being decided. Ask again.",
205
+ ALLOW_POLICY_REPORT_ONLY: "A rule allows this.",
204
206
  DENY_PRINCIPAL_NOT_BOUND: "This key may not act as that agent.",
205
207
  DENY_WORKLOAD_NOT_VERIFIED: "This agent must run from its own workload, and this request did not prove that.",
206
208
  DENY_DOMAIN_NO_MATCH: "This action is outside every area, so it is blocked.",
@@ -220,6 +222,10 @@ var isWaitingCode = (code) => WAITING.has(code);
220
222
  function sentenceFor(code) {
221
223
  return SENTENCES[code] ?? (code.startsWith("DENY_") ? "Praesidias blocked this action." : code);
222
224
  }
225
+ function messageOf(reasons, code) {
226
+ const own = reasons?.caseMessage;
227
+ return typeof own === "string" && own.trim() ? own.slice(0, 500) : sentenceFor(code);
228
+ }
223
229
 
224
230
  // src/report.ts
225
231
  var ACTION_NAME = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/;
@@ -489,7 +495,7 @@ var Praesidias = class {
489
495
  return {
490
496
  decisionId: body.decisionId,
491
497
  allowed: result === "ALLOW",
492
- reason: { code, message: sentenceFor(code) },
498
+ reason: { code, message: messageOf(body.reasons, code) },
493
499
  context,
494
500
  caseId: typeof caseId === "string" ? caseId : null,
495
501
  boundPaths: Array.isArray(paths) ? paths.map(String) : [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@praesidias/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Check every agent action with Praesidias before it runs.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Praesidias",