@decionis/agentsafe 0.7.0 → 0.9.0

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.
Files changed (176) hide show
  1. package/README.md +6 -1
  2. package/dist/Cli.js +13 -3
  3. package/dist/Cli.js.map +1 -1
  4. package/dist/acceptance/AcceptancePlan.d.ts +109 -0
  5. package/dist/acceptance/AcceptancePlan.d.ts.map +1 -0
  6. package/dist/acceptance/AcceptancePlan.js +128 -0
  7. package/dist/acceptance/AcceptancePlan.js.map +1 -0
  8. package/dist/acceptance/AcceptanceReport.d.ts +596 -0
  9. package/dist/acceptance/AcceptanceReport.d.ts.map +1 -0
  10. package/dist/acceptance/AcceptanceReport.js +361 -0
  11. package/dist/acceptance/AcceptanceReport.js.map +1 -0
  12. package/dist/acceptance/AcceptanceRun.d.ts +118 -0
  13. package/dist/acceptance/AcceptanceRun.d.ts.map +1 -0
  14. package/dist/acceptance/AcceptanceRun.js +419 -0
  15. package/dist/acceptance/AcceptanceRun.js.map +1 -0
  16. package/dist/acceptance/Coverage.d.ts +12 -0
  17. package/dist/acceptance/Coverage.d.ts.map +1 -0
  18. package/dist/acceptance/Coverage.js +48 -0
  19. package/dist/acceptance/Coverage.js.map +1 -0
  20. package/dist/acceptance/OutageDoubles.d.ts +34 -0
  21. package/dist/acceptance/OutageDoubles.d.ts.map +1 -0
  22. package/dist/acceptance/OutageDoubles.js +67 -0
  23. package/dist/acceptance/OutageDoubles.js.map +1 -0
  24. package/dist/acceptance/ZoneProbes.d.ts +368 -0
  25. package/dist/acceptance/ZoneProbes.d.ts.map +1 -0
  26. package/dist/acceptance/ZoneProbes.js +488 -0
  27. package/dist/acceptance/ZoneProbes.js.map +1 -0
  28. package/dist/adapters/JcsDigest.d.ts +6 -5
  29. package/dist/adapters/JcsDigest.d.ts.map +1 -1
  30. package/dist/adapters/JcsDigest.js +9 -8
  31. package/dist/adapters/JcsDigest.js.map +1 -1
  32. package/dist/cli/Accept.d.ts +9 -0
  33. package/dist/cli/Accept.d.ts.map +1 -0
  34. package/dist/cli/Accept.js +209 -0
  35. package/dist/cli/Accept.js.map +1 -0
  36. package/dist/cli/Actions.d.ts +6 -4
  37. package/dist/cli/Actions.d.ts.map +1 -1
  38. package/dist/cli/Actions.js +33 -7
  39. package/dist/cli/Actions.js.map +1 -1
  40. package/dist/cli/Commands.d.ts +1 -1
  41. package/dist/cli/Commands.d.ts.map +1 -1
  42. package/dist/cli/Commands.js +5 -0
  43. package/dist/cli/Commands.js.map +1 -1
  44. package/dist/cli/ConfigCommand.d.ts.map +1 -1
  45. package/dist/cli/ConfigCommand.js +5 -0
  46. package/dist/cli/ConfigCommand.js.map +1 -1
  47. package/dist/cli/Doctor.d.ts.map +1 -1
  48. package/dist/cli/Doctor.js +67 -1
  49. package/dist/cli/Doctor.js.map +1 -1
  50. package/dist/cli/Help.d.ts.map +1 -1
  51. package/dist/cli/Help.js +6 -1
  52. package/dist/cli/Help.js.map +1 -1
  53. package/dist/cli/Identity.d.ts +13 -1
  54. package/dist/cli/Identity.d.ts.map +1 -1
  55. package/dist/cli/Identity.js +25 -2
  56. package/dist/cli/Identity.js.map +1 -1
  57. package/dist/cli/Status.d.ts +23 -0
  58. package/dist/cli/Status.d.ts.map +1 -1
  59. package/dist/cli/Status.js +80 -18
  60. package/dist/cli/Status.js.map +1 -1
  61. package/dist/cli/VerifyAcceptance.d.ts +38 -0
  62. package/dist/cli/VerifyAcceptance.d.ts.map +1 -0
  63. package/dist/cli/VerifyAcceptance.js +143 -0
  64. package/dist/cli/VerifyAcceptance.js.map +1 -0
  65. package/dist/config/ExecutorConfig.d.ts +6 -1
  66. package/dist/config/ExecutorConfig.d.ts.map +1 -1
  67. package/dist/config/ExecutorConfig.js.map +1 -1
  68. package/dist/egress/ZoneHttpClient.d.ts +3 -0
  69. package/dist/egress/ZoneHttpClient.d.ts.map +1 -0
  70. package/dist/egress/ZoneHttpClient.js +72 -0
  71. package/dist/egress/ZoneHttpClient.js.map +1 -0
  72. package/dist/exposure/DecionisExposureLedger.d.ts +44 -0
  73. package/dist/exposure/DecionisExposureLedger.d.ts.map +1 -0
  74. package/dist/exposure/DecionisExposureLedger.js +175 -0
  75. package/dist/exposure/DecionisExposureLedger.js.map +1 -0
  76. package/dist/exposure/ExposureDeclaration.d.ts +68 -0
  77. package/dist/exposure/ExposureDeclaration.d.ts.map +1 -0
  78. package/dist/exposure/ExposureDeclaration.js +120 -0
  79. package/dist/exposure/ExposureDeclaration.js.map +1 -0
  80. package/dist/exposure/ExposureFacts.d.ts +61 -0
  81. package/dist/exposure/ExposureFacts.d.ts.map +1 -0
  82. package/dist/exposure/ExposureFacts.js +220 -0
  83. package/dist/exposure/ExposureFacts.js.map +1 -0
  84. package/dist/exposure/ExposureGate.d.ts +144 -0
  85. package/dist/exposure/ExposureGate.d.ts.map +1 -0
  86. package/dist/exposure/ExposureGate.js +446 -0
  87. package/dist/exposure/ExposureGate.js.map +1 -0
  88. package/dist/exposure/ExposureLedger.d.ts +93 -0
  89. package/dist/exposure/ExposureLedger.d.ts.map +1 -0
  90. package/dist/exposure/ExposureLedger.js +24 -0
  91. package/dist/exposure/ExposureLedger.js.map +1 -0
  92. package/dist/gateway/AttemptStore.d.ts +83 -0
  93. package/dist/gateway/AttemptStore.d.ts.map +1 -0
  94. package/dist/gateway/AttemptStore.js +229 -0
  95. package/dist/gateway/AttemptStore.js.map +1 -0
  96. package/dist/gateway/ForwardHandler.d.ts +29 -3
  97. package/dist/gateway/ForwardHandler.d.ts.map +1 -1
  98. package/dist/gateway/ForwardHandler.js +32 -5
  99. package/dist/gateway/ForwardHandler.js.map +1 -1
  100. package/dist/gateway/Gateway.d.ts +229 -17
  101. package/dist/gateway/Gateway.d.ts.map +1 -1
  102. package/dist/gateway/Gateway.js +1045 -81
  103. package/dist/gateway/Gateway.js.map +1 -1
  104. package/dist/gateway/GatewayConfig.d.ts +186 -0
  105. package/dist/gateway/GatewayConfig.d.ts.map +1 -1
  106. package/dist/gateway/GatewayConfig.js +219 -5
  107. package/dist/gateway/GatewayConfig.js.map +1 -1
  108. package/dist/gateway/GatewayManifest.d.ts +18 -0
  109. package/dist/gateway/GatewayManifest.d.ts.map +1 -0
  110. package/dist/gateway/GatewayManifest.js +42 -0
  111. package/dist/gateway/GatewayManifest.js.map +1 -0
  112. package/dist/gateway/GatewayMetrics.d.ts +12 -4
  113. package/dist/gateway/GatewayMetrics.d.ts.map +1 -1
  114. package/dist/gateway/GatewayMetrics.js +5 -0
  115. package/dist/gateway/GatewayMetrics.js.map +1 -1
  116. package/dist/gateway/GatewayReport.d.ts +34 -1
  117. package/dist/gateway/GatewayReport.d.ts.map +1 -1
  118. package/dist/gateway/GatewayReport.js +11 -0
  119. package/dist/gateway/GatewayReport.js.map +1 -1
  120. package/dist/gateway/HoldStore.d.ts +89 -0
  121. package/dist/gateway/HoldStore.d.ts.map +1 -0
  122. package/dist/gateway/HoldStore.js +280 -0
  123. package/dist/gateway/HoldStore.js.map +1 -0
  124. package/dist/gateway/InterceptedRequest.d.ts +10 -0
  125. package/dist/gateway/InterceptedRequest.d.ts.map +1 -1
  126. package/dist/gateway/InterceptedRequest.js +20 -0
  127. package/dist/gateway/InterceptedRequest.js.map +1 -1
  128. package/dist/gateway/RouteTable.d.ts +33 -5
  129. package/dist/gateway/RouteTable.d.ts.map +1 -1
  130. package/dist/gateway/RouteTable.js +76 -1
  131. package/dist/gateway/RouteTable.js.map +1 -1
  132. package/dist/gateway/ShadowLedger.d.ts +11 -0
  133. package/dist/gateway/ShadowLedger.d.ts.map +1 -1
  134. package/dist/gateway/ShadowLedger.js +11 -0
  135. package/dist/gateway/ShadowLedger.js.map +1 -1
  136. package/dist/gateway/TargetEffect.d.ts +74 -0
  137. package/dist/gateway/TargetEffect.d.ts.map +1 -0
  138. package/dist/gateway/TargetEffect.js +95 -0
  139. package/dist/gateway/TargetEffect.js.map +1 -0
  140. package/dist/gateway/TargetReader.d.ts +70 -0
  141. package/dist/gateway/TargetReader.d.ts.map +1 -0
  142. package/dist/gateway/TargetReader.js +106 -0
  143. package/dist/gateway/TargetReader.js.map +1 -0
  144. package/dist/gateway/Upstream.d.ts +15 -0
  145. package/dist/gateway/Upstream.d.ts.map +1 -1
  146. package/dist/gateway/Upstream.js +24 -2
  147. package/dist/gateway/Upstream.js.map +1 -1
  148. package/dist/hosted/TenantHost.d.ts +3 -2
  149. package/dist/hosted/TenantHost.d.ts.map +1 -1
  150. package/dist/hosted/TenantHost.js +7 -1
  151. package/dist/hosted/TenantHost.js.map +1 -1
  152. package/dist/hosted/TenantRegistry.d.ts +8 -0
  153. package/dist/hosted/TenantRegistry.d.ts.map +1 -1
  154. package/dist/hosted/TenantRegistry.js +14 -1
  155. package/dist/hosted/TenantRegistry.js.map +1 -1
  156. package/dist/http/GatewayHttpServer.d.ts +7 -0
  157. package/dist/http/GatewayHttpServer.d.ts.map +1 -1
  158. package/dist/http/GatewayHttpServer.js +57 -1
  159. package/dist/http/GatewayHttpServer.js.map +1 -1
  160. package/dist/outcomes/OutcomeEvidence.d.ts +4 -4
  161. package/dist/posture/ActionSpaceDrift.d.ts +40 -0
  162. package/dist/posture/ActionSpaceDrift.d.ts.map +1 -0
  163. package/dist/posture/ActionSpaceDrift.js +67 -0
  164. package/dist/posture/ActionSpaceDrift.js.map +1 -0
  165. package/dist/posture/DeploymentFingerprint.d.ts +88 -0
  166. package/dist/posture/DeploymentFingerprint.d.ts.map +1 -0
  167. package/dist/posture/DeploymentFingerprint.js +78 -0
  168. package/dist/posture/DeploymentFingerprint.js.map +1 -0
  169. package/dist/secrets/SecretStore.d.ts +6 -1
  170. package/dist/secrets/SecretStore.d.ts.map +1 -1
  171. package/dist/secrets/SecretStore.js.map +1 -1
  172. package/dist/service/EscalationResolver.d.ts +6 -6
  173. package/dist/service/EscalationResolver.d.ts.map +1 -1
  174. package/dist/service/EscalationResolver.js +8 -4
  175. package/dist/service/EscalationResolver.js.map +1 -1
  176. package/package.json +3 -3
@@ -0,0 +1,120 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The action types a cumulative limit may name, as the Decionis exposure
4
+ * ledger names them (`COMMERCE_EXPOSURE_ACTION_TYPES`). A route that releases
5
+ * money states one of these; `PAYMENT_RELEASE` unless it says otherwise.
6
+ */
7
+ export const EXPOSURE_ACTION_TYPES = [
8
+ "PRICE_CHANGE",
9
+ "INVENTORY_MUTATION",
10
+ "ORDER_ACCEPTANCE",
11
+ "FULFILLMENT_ACTION",
12
+ "PROMOTION_CHANGE",
13
+ "REFUND_REQUEST",
14
+ "RETURN_AUTHORIZATION",
15
+ "PAYMENT_RELEASE",
16
+ "VENDOR_BANK_CHANGE",
17
+ "EARLY_PAYMENT_DISCOUNT",
18
+ "CREDIT_HOLD_RELEASE",
19
+ ];
20
+ export const DEFAULT_EXPOSURE_ACTION_TYPE = "PAYMENT_RELEASE";
21
+ /**
22
+ * The subjects a route can name, beside `org`, which every route supplies:
23
+ * the organisation is the gateway's own tenant.
24
+ */
25
+ export const EXPOSURE_ROUTE_SUBJECTS = ["vendor", "customer", "sku", "agent"];
26
+ /** RFC 6901 pointers into the request as the gateway reads it: path parameters, query, headers, JSON body. */
27
+ const REQUEST_POINTER = /^\/(?:path|query|headers|body)(?:\/\P{Cc}*)?$/u;
28
+ /** A pointer into a forwarded write's JSON answer. */
29
+ const RESPONSE_POINTER = /^\/body(?:\/\P{Cc}*)?$/u;
30
+ const CURRENCY_CODE = /^[a-z]{3}$/i;
31
+ const requestPointer = z.string().trim().min(2).max(300).regex(REQUEST_POINTER);
32
+ const lower = (values) => z.preprocess((value) => (typeof value === "string" ? value.trim().toLowerCase() : value), z.enum(values));
33
+ /**
34
+ * The action types that move no money: a step a sequence limit counts, never
35
+ * an amount. A route of one of these may omit `amount` and `currency`.
36
+ */
37
+ export const EXPOSURE_STEP_ONLY_ACTION_TYPES = [
38
+ "VENDOR_BANK_CHANGE",
39
+ ];
40
+ /**
41
+ * A route's `exposure` section in `agentsafe.yaml`: the route releases money,
42
+ * and says where in the request the amount, the currency and the subjects
43
+ * are. The values are read from the request the authority evaluated and the
44
+ * gateway forwards, never from a header the gateway adds. A route whose action
45
+ * moves no money (a change of a vendor's bank details) states no amount: the
46
+ * ledger records it as a step of the vendor's segregation of duties, which is
47
+ * what starts the hold on payments to that vendor.
48
+ */
49
+ const RouteExposureObject = z.strictObject({
50
+ actionType: z
51
+ .preprocess((value) => (typeof value === "string" ? value.trim().toUpperCase() : value), z.enum(EXPOSURE_ACTION_TYPES))
52
+ .optional(),
53
+ amount: requestPointer.optional(),
54
+ amountUnit: lower(["minor", "major"]).optional(),
55
+ /** A pointer into the request, or a fixed ISO 4217 code for a route in one currency. */
56
+ currency: z
57
+ .string()
58
+ .trim()
59
+ .min(2)
60
+ .max(300)
61
+ .refine((value) => CURRENCY_CODE.test(value) || REQUEST_POINTER.test(value), "an ISO 4217 code or a pointer into the request")
62
+ .optional(),
63
+ subjects: z
64
+ .strictObject({
65
+ vendor: requestPointer.optional(),
66
+ customer: requestPointer.optional(),
67
+ sku: requestPointer.optional(),
68
+ agent: requestPointer.optional(),
69
+ })
70
+ .optional(),
71
+ /** Where a 2xx answer states the amount that actually moved; the reserved amount is settled without it. */
72
+ settledAmount: z.string().trim().min(5).max(300).regex(RESPONSE_POINTER).optional(),
73
+ /** `failClosed` (the default) refuses a payment the ledger could not be asked about. */
74
+ failurePolicy: lower(["failclosed", "failopen"]).optional(),
75
+ });
76
+ export const RouteExposureSchema = RouteExposureObject.superRefine((value, context) => {
77
+ const stepOnly = EXPOSURE_STEP_ONLY_ACTION_TYPES.includes(value.actionType ?? DEFAULT_EXPOSURE_ACTION_TYPE);
78
+ const stated = Number(value.amount !== undefined) + Number(value.currency !== undefined);
79
+ if (!stepOnly && stated < 2)
80
+ context.addIssue({
81
+ code: "custom",
82
+ path: [value.amount === undefined ? "amount" : "currency"],
83
+ message: "a route that moves money states its amount and currency",
84
+ });
85
+ if (stepOnly && stated === 1)
86
+ context.addIssue({
87
+ code: "custom",
88
+ path: [value.amount === undefined ? "amount" : "currency"],
89
+ message: "state both the amount and the currency, or neither",
90
+ });
91
+ if (value.settledAmount !== undefined && value.amount === undefined)
92
+ context.addIssue({
93
+ code: "custom",
94
+ path: ["settledAmount"],
95
+ message: "a settled amount needs the amount it settles",
96
+ });
97
+ });
98
+ /** The declaration a route's file section resolves to. */
99
+ export function exposureDeclaration(file) {
100
+ const subjects = {};
101
+ for (const kind of EXPOSURE_ROUTE_SUBJECTS) {
102
+ const pointer = file.subjects?.[kind];
103
+ if (pointer !== undefined)
104
+ subjects[kind] = pointer;
105
+ }
106
+ return {
107
+ actionType: file.actionType ?? DEFAULT_EXPOSURE_ACTION_TYPE,
108
+ amount: file.amount ?? null,
109
+ amountUnit: file.amountUnit === "major" ? "MAJOR" : "MINOR",
110
+ currency: file.currency === undefined
111
+ ? null
112
+ : file.currency.startsWith("/")
113
+ ? file.currency
114
+ : file.currency.toUpperCase(),
115
+ subjects,
116
+ settledAmount: file.settledAmount ?? null,
117
+ failurePolicy: file.failurePolicy === "failopen" ? "FAIL_OPEN" : "FAIL_CLOSED",
118
+ };
119
+ }
120
+ //# sourceMappingURL=ExposureDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExposureDeclaration.js","sourceRoot":"","sources":["../../src/exposure/ExposureDeclaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,cAAc;IACd,oBAAoB;IACpB,kBAAkB;IAClB,oBAAoB;IACpB,kBAAkB;IAClB,gBAAgB;IAChB,sBAAsB;IACtB,iBAAiB;IACjB,oBAAoB;IACpB,wBAAwB;IACxB,qBAAqB;CACb,CAAC;AAEX,MAAM,CAAC,MAAM,4BAA4B,GAAuB,iBAAiB,CAAC;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,O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C,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;gBAC7B,CAAC,CAAC,IAAI,CAAC,QAAQ;gBACf,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;QACnC,QAAQ;QACR,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,IAAI;QACzC,aAAa,EAAE,IAAI,CAAC,aAAa,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa;KAC/E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { InterceptedRequest } from "../gateway/InterceptedRequest.js";
2
+ import type { ExposureActionType, ExposureDeclaration, ExposureRouteSubject } from "./ExposureDeclaration.js";
3
+ /**
4
+ * What a money-releasing request states, as the ledger counts it: the action
5
+ * type, the amount in integer minor units, the currency, and each subject's
6
+ * identifier. The identifiers stay in this process: the ledger receives
7
+ * only their digests (ExposureGate).
8
+ */
9
+ export interface ExposureFacts {
10
+ readonly actionType: ExposureActionType;
11
+ readonly amount: number;
12
+ readonly currency: string;
13
+ readonly subjects: Readonly<Partial<Record<ExposureRouteSubject, string>>>;
14
+ }
15
+ /** Why a declared fact could not be read; the request is never counted on a guess. */
16
+ export type ExposureFactsRefusal = "EXPOSURE_AMOUNT_UNREADABLE" | "EXPOSURE_CURRENCY_UNREADABLE" | "EXPOSURE_SUBJECT_UNREADABLE";
17
+ export type ExposureFactsResult = {
18
+ readonly ok: true;
19
+ readonly facts: ExposureFacts;
20
+ } | {
21
+ readonly ok: false;
22
+ readonly code: ExposureFactsRefusal;
23
+ };
24
+ /** The longest identifier a subject may be: an identifier, never a payload. */
25
+ export declare const MAX_SUBJECT_LENGTH = 200;
26
+ type Json = null | boolean | number | string | readonly Json[] | {
27
+ readonly [key: string]: Json;
28
+ };
29
+ /** The minor-unit exponent of a currency. */
30
+ export declare function currencyExponent(currency: string): number;
31
+ /**
32
+ * Walks an RFC 6901 pointer, one token per segment and nothing that
33
+ * backtracks. Only an object's own keys and an array's decimal indexes are
34
+ * followed, so a pointer cannot reach a prototype.
35
+ */
36
+ export declare function walkPointer(root: Json | undefined, pointer: string): Json | undefined;
37
+ /**
38
+ * An amount as integer minor units, exactly: a minor amount is an integer;
39
+ * a major amount is a decimal with no more fractional digits than the
40
+ * currency has. A negative, fractional-minor, exponent-notation or
41
+ * over-precise amount is unreadable rather than rounded.
42
+ */
43
+ export declare function minorUnits(value: Json | undefined, unit: ExposureDeclaration["amountUnit"], currency: string): number | null;
44
+ /**
45
+ * Reads what a route declares from the request it governs. The agent, when
46
+ * the route names no pointer for it, is the gateway's own configured actor:
47
+ * the identity the intent already names, which the caller cannot choose.
48
+ */
49
+ export declare function readExposureFacts(declaration: ExposureDeclaration, request: InterceptedRequest, routePath: string, actorId: string): ExposureFactsResult;
50
+ /**
51
+ * The amount a committed payment's answer says moved, when the route names
52
+ * where: in the route's unit and the request's currency, and only when it is
53
+ * no more than was reserved. Anything else settles the reserved amount, which
54
+ * errs toward the cap.
55
+ */
56
+ export declare function readSettledAmount(declaration: ExposureDeclaration, facts: ExposureFacts, answer: {
57
+ readonly headers: readonly (readonly [string, string])[];
58
+ readonly body: Buffer;
59
+ }): number | null;
60
+ export {};
61
+ //# sourceMappingURL=ExposureFacts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExposureFacts.d.ts","sourceRoot":"","sources":["../../src/exposure/ExposureFacts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAElC;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EA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W,EAAE,mBAAmB,EAChC,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1F,MAAM,GAAG,IAAI,CAiBf"}
@@ -0,0 +1,220 @@
1
+ /** The longest identifier a subject may be: an identifier, never a payload. */
2
+ export const MAX_SUBJECT_LENGTH = 200;
3
+ /** ISO 4217 currencies without minor units, and those with three; every other has two. */
4
+ const ZERO_DECIMALS = new Set([
5
+ "BIF",
6
+ "CLP",
7
+ "DJF",
8
+ "GNF",
9
+ "ISK",
10
+ "JPY",
11
+ "KMF",
12
+ "KRW",
13
+ "PYG",
14
+ "RWF",
15
+ "UGX",
16
+ "UYI",
17
+ "VND",
18
+ "VUV",
19
+ "XAF",
20
+ "XOF",
21
+ "XPF",
22
+ ]);
23
+ const THREE_DECIMALS = new Set([
24
+ "BHD",
25
+ "IQD",
26
+ "JOD",
27
+ "KWD",
28
+ "LYD",
29
+ "OMR",
30
+ "TND",
31
+ ]);
32
+ const CURRENCY = /^[A-Z]{3}$/;
33
+ /** ISO 4217's code for "no currency": what a step that moves no money states to the ledger. */
34
+ const NO_CURRENCY = "XXX";
35
+ const INDEX = /^(?:0|[1-9]\d{0,8})$/;
36
+ const MINOR = /^\d{1,16}$/;
37
+ const MAJOR = /^(\d{1,16})(?:\.(\d{1,3}))?$/;
38
+ /** The minor-unit exponent of a currency. */
39
+ export function currencyExponent(currency) {
40
+ if (ZERO_DECIMALS.has(currency))
41
+ return 0;
42
+ return THREE_DECIMALS.has(currency) ? 3 : 2;
43
+ }
44
+ /**
45
+ * Walks an RFC 6901 pointer, one token per segment and nothing that
46
+ * backtracks. Only an object's own keys and an array's decimal indexes are
47
+ * followed, so a pointer cannot reach a prototype.
48
+ */
49
+ export function walkPointer(root, pointer) {
50
+ let node = root;
51
+ for (const raw of pointer.split("/").slice(1)) {
52
+ if (node === undefined || node === null || typeof node !== "object")
53
+ return undefined;
54
+ const token = raw.replaceAll("~1", "/").replaceAll("~0", "~");
55
+ if (Array.isArray(node)) {
56
+ const list = node;
57
+ node = INDEX.test(token) ? list[Number(token)] : undefined;
58
+ }
59
+ else {
60
+ const record = node;
61
+ node = Object.prototype.hasOwnProperty.call(record, token) ? record[token] : undefined;
62
+ }
63
+ }
64
+ return node;
65
+ }
66
+ /** A scalar as text: a string, or a finite number; anything else is not one. */
67
+ function scalar(value) {
68
+ if (typeof value === "string")
69
+ return value;
70
+ if (typeof value === "number" && Number.isFinite(value))
71
+ return String(value);
72
+ return undefined;
73
+ }
74
+ /**
75
+ * An amount as integer minor units, exactly: a minor amount is an integer;
76
+ * a major amount is a decimal with no more fractional digits than the
77
+ * currency has. A negative, fractional-minor, exponent-notation or
78
+ * over-precise amount is unreadable rather than rounded.
79
+ */
80
+ export function minorUnits(value, unit, currency) {
81
+ const text = scalar(value)?.trim();
82
+ if (text === undefined)
83
+ return null;
84
+ let minor;
85
+ if (unit === "MINOR") {
86
+ if (!MINOR.test(text))
87
+ return null;
88
+ minor = Number(text);
89
+ }
90
+ else {
91
+ const match = MAJOR.exec(text);
92
+ if (match === null)
93
+ return null;
94
+ const exponent = currencyExponent(currency);
95
+ const fraction = match[2] ?? "";
96
+ if (fraction.length > exponent)
97
+ return null;
98
+ minor = Number(`${match[1] ?? ""}${fraction.padEnd(exponent, "0")}`);
99
+ }
100
+ return Number.isSafeInteger(minor) ? minor : null;
101
+ }
102
+ /** A route pattern's `:name` segments, each to the request's segment in its place. */
103
+ function pathParameters(pattern, path) {
104
+ const names = pattern.split("/").filter((segment) => segment !== "");
105
+ const values = path.split("/").filter((segment) => segment !== "");
106
+ const parameters = {};
107
+ names.forEach((name, index) => {
108
+ const value = values[index];
109
+ if (!name.startsWith(":") || value === undefined)
110
+ return;
111
+ try {
112
+ parameters[name.slice(1)] = decodeURIComponent(value);
113
+ }
114
+ catch {
115
+ // An undecodable segment states nothing; the route table refused it already.
116
+ }
117
+ });
118
+ return parameters;
119
+ }
120
+ function queryRoot(search) {
121
+ const query = {};
122
+ for (const [key, value] of new URLSearchParams(search)) {
123
+ if (!Object.prototype.hasOwnProperty.call(query, key))
124
+ query[key] = value;
125
+ else {
126
+ const current = query[key];
127
+ query[key] = Array.isArray(current) ? [...current, value] : [current, value];
128
+ }
129
+ }
130
+ return query;
131
+ }
132
+ function bodyRoot(request) {
133
+ if (request.body.length === 0 || !/json/i.test(request.headers["content-type"] ?? "")) {
134
+ return undefined;
135
+ }
136
+ try {
137
+ return JSON.parse(request.body.toString("utf8"));
138
+ }
139
+ catch {
140
+ return undefined;
141
+ }
142
+ }
143
+ /**
144
+ * Reads what a route declares from the request it governs. The agent, when
145
+ * the route names no pointer for it, is the gateway's own configured actor:
146
+ * the identity the intent already names, which the caller cannot choose.
147
+ */
148
+ export function readExposureFacts(declaration, request, routePath, actorId) {
149
+ const root = {
150
+ path: pathParameters(routePath, request.path),
151
+ query: queryRoot(request.search),
152
+ headers: { ...request.headers },
153
+ };
154
+ const body = bodyRoot(request);
155
+ if (body !== undefined)
156
+ root["body"] = body;
157
+ // A step that moves no money (a change of a vendor's bank details): no
158
+ // amount, and ISO 4217's "no currency", so only a sequence limit counts it.
159
+ if (declaration.amount === null || declaration.currency === null) {
160
+ const subjects = readSubjects(declaration, root, actorId);
161
+ if (subjects === null)
162
+ return { ok: false, code: "EXPOSURE_SUBJECT_UNREADABLE" };
163
+ return {
164
+ ok: true,
165
+ facts: { actionType: declaration.actionType, amount: 0, currency: NO_CURRENCY, subjects },
166
+ };
167
+ }
168
+ const currency = (declaration.currency.startsWith("/")
169
+ ? (scalar(walkPointer(root, declaration.currency)) ?? "")
170
+ : declaration.currency)
171
+ .trim()
172
+ .toUpperCase();
173
+ if (!CURRENCY.test(currency))
174
+ return { ok: false, code: "EXPOSURE_CURRENCY_UNREADABLE" };
175
+ const amount = minorUnits(walkPointer(root, declaration.amount), declaration.amountUnit, currency);
176
+ if (amount === null)
177
+ return { ok: false, code: "EXPOSURE_AMOUNT_UNREADABLE" };
178
+ const subjects = readSubjects(declaration, root, actorId);
179
+ if (subjects === null)
180
+ return { ok: false, code: "EXPOSURE_SUBJECT_UNREADABLE" };
181
+ return {
182
+ ok: true,
183
+ facts: { actionType: declaration.actionType, amount, currency, subjects },
184
+ };
185
+ }
186
+ /** Each declared subject from the request; the agent defaults to the gateway's actor. Null when one cannot be read. */
187
+ function readSubjects(declaration, root, actorId) {
188
+ const subjects = {};
189
+ for (const [kind, pointer] of Object.entries(declaration.subjects)) {
190
+ const value = scalar(walkPointer(root, pointer))?.trim();
191
+ if (value === undefined || value === "" || value.length > MAX_SUBJECT_LENGTH)
192
+ return null;
193
+ subjects[kind] = value;
194
+ }
195
+ subjects.agent ??= actorId;
196
+ return subjects;
197
+ }
198
+ /**
199
+ * The amount a committed payment's answer says moved, when the route names
200
+ * where: in the route's unit and the request's currency, and only when it is
201
+ * no more than was reserved. Anything else settles the reserved amount, which
202
+ * errs toward the cap.
203
+ */
204
+ export function readSettledAmount(declaration, facts, answer) {
205
+ if (declaration.settledAmount === null || declaration.amount === null || answer.body.length === 0)
206
+ return null;
207
+ const type = answer.headers.find(([name]) => name.toLowerCase() === "content-type")?.[1] ?? "";
208
+ if (!/json/i.test(type))
209
+ return null;
210
+ let body;
211
+ try {
212
+ body = JSON.parse(answer.body.toString("utf8"));
213
+ }
214
+ catch {
215
+ return null;
216
+ }
217
+ const amount = minorUnits(walkPointer({ body }, declaration.settledAmount), declaration.amountUnit, facts.currency);
218
+ return amount !== null && amount <= facts.amount ? amount : null;
219
+ }
220
+ //# sourceMappingURL=ExposureFacts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExposureFacts.js","sourceRoot":"","sources":["../../src/exposure/ExposureFacts.ts"],"names":[],"mappings":"AA4BA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE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C3B,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,WAAgC,EAChC,KAAoB,EACpB,MAA2F;IAE3F,IAAI,WAAW,CAAC,aAAa,KAAK,IAAI,IAAI,WAAW,CAAC,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QAC/F,OAAO,IAAI,CAAC;IACd,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/F,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,IAAI,IAAU,CAAC;IACf,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG,UAAU,CACvB,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE,WAAW,CAAC,aAAa,CAAC,EAChD,WAAW,CAAC,UAAU,EACtB,KAAK,CAAC,QAAQ,CACf,CAAC;IACF,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACnE,CAAC"}
@@ -0,0 +1,144 @@
1
+ import type { ChainFields } from "../audit/HashChain.js";
2
+ import type { ExposureFacts } from "./ExposureFacts.js";
3
+ import { type ExposureLedger } from "./ExposureLedger.js";
4
+ /**
5
+ * The subject digest scheme Decionis Commerce uses (`Subject.digest`), so one
6
+ * vendor is one subject whichever channel paid it: the identifier trimmed and
7
+ * lower-cased, scoped by the organisation.
8
+ */
9
+ export declare const EXPOSURE_DIGEST_VERSION = "decionis-exposure-v1";
10
+ /** An enforced reservation key: what an earlier attempt's record may name. */
11
+ export declare const RESERVATION_KEY: RegExp;
12
+ /** One reservation held against one limit. */
13
+ export interface HeldReservation {
14
+ readonly limitKey: string;
15
+ readonly reservationId: string;
16
+ }
17
+ /** What the intent the reservations are made for is, as the ledger and the evidence name it. */
18
+ export interface ExposureBinding {
19
+ readonly intentId: string;
20
+ readonly intentHash: string;
21
+ readonly capturedAt: string;
22
+ /**
23
+ * The reservation key of the INDETERMINATE attempt this one retries under
24
+ * the same idempotency key, for the same request. The retry reserves under
25
+ * it, so the ledger answers with what the earlier attempt kept: one
26
+ * operation, drawn once, and ended once its outcome is known.
27
+ */
28
+ readonly retryOf?: string;
29
+ }
30
+ /**
31
+ * What the ledger said about one money release, across every limit that
32
+ * covers it. `unstated` names a limit that covers the action but whose
33
+ * subject the route does not state: the payment is not counted against it,
34
+ * and the evidence says so.
35
+ */
36
+ export type ExposureCheck = {
37
+ readonly status: "WITHIN_LIMIT";
38
+ readonly held: readonly HeldReservation[];
39
+ readonly unstated: readonly string[];
40
+ /** The limits whose reservation the ledger already held under the key: no second draw. */
41
+ readonly replayed?: readonly string[];
42
+ } | {
43
+ readonly status: "EXCEEDED";
44
+ readonly limitKey: string;
45
+ readonly onExceed: "HOLD" | "ESCALATE";
46
+ readonly reasonCode: string;
47
+ readonly unstated: readonly string[];
48
+ } | {
49
+ readonly status: "UNAVAILABLE";
50
+ readonly code: string;
51
+ /** Kept only under a route's explicit fail-open; released otherwise. */
52
+ readonly held: readonly HeldReservation[];
53
+ readonly unstated: readonly string[];
54
+ /** The route fails open: the payment goes on, uncounted where nothing was held. */
55
+ readonly ungoverned: boolean;
56
+ };
57
+ /** How the forwarded payment ended, as the executor classified it. */
58
+ export type PaymentOutcome = "COMMITTED" | "NOT_EXECUTED" | "INDETERMINATE";
59
+ /** What became of the reservations once the payment's outcome was known. */
60
+ export type Settlement = "SETTLED" | "RELEASED" | "KEPT" | "NONE" | "FAILED";
61
+ export interface ExposureGateOptions {
62
+ readonly ledger: ExposureLedger;
63
+ /** The organisation that scopes every subject digest: the gateway's tenant. */
64
+ readonly orgId: string;
65
+ /** The gateway's actor type, for a limit restricted to some actor types. */
66
+ readonly actorType: string;
67
+ /** Writes one chained line on the gateway's own stream. */
68
+ readonly evidence: (fields: ChainFields) => void;
69
+ /** Counts each outcome, by a code the gateway produced. */
70
+ readonly count?: (outcome: string) => void;
71
+ /** How many times a settle or release is attempted before it is recorded as failed. */
72
+ readonly attempts?: number;
73
+ readonly retryDelayMs?: number;
74
+ readonly sleep?: (ms: number) => Promise<void>;
75
+ }
76
+ /**
77
+ * The cumulative-limit check on the execution path. After the authority's
78
+ * ALLOW and the claim of its grant, and before the payment is sent, it
79
+ * reserves the amount against every limit in the organisation's policy that
80
+ * covers the route's action type, in key order, under a reservation key
81
+ * derived from the intent hash, so the same intent never draws twice. Any
82
+ * limit that would be exceeded refuses the payment and gives back what was
83
+ * already reserved. Once the upstream has answered, a committed payment is
84
+ * settled, one that was not executed is released, and one whose outcome is
85
+ * unknown keeps its reservation, so the ledger errs toward the cap.
86
+ */
87
+ export declare class ExposureGate {
88
+ private readonly options;
89
+ private readonly attempts;
90
+ private readonly retryDelayMs;
91
+ private readonly sleep;
92
+ constructor(options: ExposureGateOptions);
93
+ /** A subject's digest as the ledger receives it; the identifier itself never leaves. */
94
+ digest(kind: string, id: string): string;
95
+ /**
96
+ * The reservation key for an intent: the same intent, the same key, on
97
+ * every retry. A retry of an INDETERMINATE attempt takes that attempt's
98
+ * key; a shadow observation never does.
99
+ */
100
+ static reservationKey(binding: ExposureBinding, shadow?: boolean): string;
101
+ /** The key derived from the intent's own hash. */
102
+ private static ownKey;
103
+ /**
104
+ * Reserves against every covering limit. A refusal releases what was
105
+ * held; so does a fault, unless the route explicitly fails open, when
106
+ * what was held is kept to be settled or released with the payment.
107
+ */
108
+ reserve(facts: ExposureFacts, binding: ExposureBinding, failOpen: boolean): Promise<ExposureCheck>;
109
+ /**
110
+ * In shadow, what the ledger would have said, without counting the
111
+ * payment. A ledger that reports a subject's usage read-only is asked
112
+ * that, and nothing is reserved: the amount is compared with each
113
+ * covering limit's cap exactly as the ledger compares it (over the cap
114
+ * when used + amount exceeds it; a currency without a cap is not
115
+ * limited). A sequence limit counts steps, not amounts, so it cannot be
116
+ * previewed and is named as such. A ledger without that read is asked by
117
+ * reserving under a shadow key and releasing at once. The payment itself
118
+ * went through unchanged.
119
+ */
120
+ observe(facts: ExposureFacts, binding: ExposureBinding): Promise<ExposureCheck>;
121
+ /** Shadow's read-only answer: usage plus this amount against each covering limit's cap. */
122
+ private preview;
123
+ /**
124
+ * Ends the reservations once the payment's outcome is known: settled
125
+ * when it committed (for the amount the answer states, when the route
126
+ * names where and it is no more than reserved), released when it was not
127
+ * executed, kept when nobody can say. A failure to settle or release is
128
+ * retried and then recorded; it never changes what already executed.
129
+ */
130
+ conclude(check: ExposureCheck, outcome: PaymentOutcome, binding: ExposureBinding, settledAmount?: number | null): Promise<Settlement>;
131
+ /** The limits that cover the facts, the reservations made against them, in key order. */
132
+ private draw;
133
+ /** Whether a limit governs this action: its action type, its actor type, and an amount to count. */
134
+ private covers;
135
+ /** The reservation for one limit; null when the route does not state its subject. */
136
+ private request;
137
+ /** Settles or releases each reservation; the ones that still failed, each recorded. */
138
+ private end;
139
+ /** Asks again only where asking again cannot count twice, a bounded number of times. */
140
+ private retrying;
141
+ private record;
142
+ private static codeOf;
143
+ }
144
+ //# sourceMappingURL=ExposureGate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExposureGate.d.ts","sourceRoot":"","sources":["../../src/exposure/ExposureGate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAA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