@decionis/agentsafe 0.2.4 → 0.3.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.
- package/README.md +135 -20
- package/dist/Cli.js +20 -0
- package/dist/Cli.js.map +1 -1
- package/dist/Index.d.ts +22 -5
- package/dist/Index.d.ts.map +1 -1
- package/dist/Index.js +19 -2
- package/dist/Index.js.map +1 -1
- package/dist/TrustedExecutor.d.ts.map +1 -1
- package/dist/TrustedExecutor.js +1 -0
- package/dist/TrustedExecutor.js.map +1 -1
- package/dist/adapters/AdapterActionHandler.d.ts.map +1 -1
- package/dist/adapters/AdapterActionHandler.js +8 -4
- package/dist/adapters/AdapterActionHandler.js.map +1 -1
- package/dist/adapters/EffectAdapter.d.ts +6 -1
- package/dist/adapters/EffectAdapter.d.ts.map +1 -1
- package/dist/adapters/EffectAdapter.js +7 -1
- package/dist/adapters/EffectAdapter.js.map +1 -1
- package/dist/adapters/banking/CoreBankingHttpAdapter.d.ts.map +1 -1
- package/dist/adapters/banking/CoreBankingHttpAdapter.js +4 -4
- package/dist/adapters/banking/CoreBankingHttpAdapter.js.map +1 -1
- package/dist/adapters/cards/CardAuthorizationMatcher.d.ts +44 -0
- package/dist/adapters/cards/CardAuthorizationMatcher.d.ts.map +1 -0
- package/dist/adapters/cards/CardAuthorizationMatcher.js +39 -0
- package/dist/adapters/cards/CardAuthorizationMatcher.js.map +1 -0
- package/dist/adapters/cards/CardEffect.d.ts +52 -0
- package/dist/adapters/cards/CardEffect.d.ts.map +1 -0
- package/dist/adapters/cards/CardEffect.js +117 -0
- package/dist/adapters/cards/CardEffect.js.map +1 -0
- package/dist/adapters/cards/CardHandlers.d.ts +15 -0
- package/dist/adapters/cards/CardHandlers.d.ts.map +1 -0
- package/dist/adapters/cards/CardHandlers.js +26 -0
- package/dist/adapters/cards/CardHandlers.js.map +1 -0
- package/dist/adapters/cards/CardPurchase.d.ts +61 -0
- package/dist/adapters/cards/CardPurchase.d.ts.map +1 -0
- package/dist/adapters/cards/CardPurchase.js +116 -0
- package/dist/adapters/cards/CardPurchase.js.map +1 -0
- package/dist/adapters/cards/HeldCardGrants.d.ts +70 -0
- package/dist/adapters/cards/HeldCardGrants.d.ts.map +1 -0
- package/dist/adapters/cards/HeldCardGrants.js +79 -0
- package/dist/adapters/cards/HeldCardGrants.js.map +1 -0
- package/dist/adapters/cards/Pan.d.ts +17 -0
- package/dist/adapters/cards/Pan.d.ts.map +1 -0
- package/dist/adapters/cards/Pan.js +52 -0
- package/dist/adapters/cards/Pan.js.map +1 -0
- package/dist/adapters/mcp/McpGuard.d.ts +91 -0
- package/dist/adapters/mcp/McpGuard.d.ts.map +1 -0
- package/dist/adapters/mcp/McpGuard.js +147 -0
- package/dist/adapters/mcp/McpGuard.js.map +1 -0
- package/dist/adapters/mcp/McpIntentBinder.d.ts +54 -0
- package/dist/adapters/mcp/McpIntentBinder.d.ts.map +1 -0
- package/dist/adapters/mcp/McpIntentBinder.js +79 -0
- package/dist/adapters/mcp/McpIntentBinder.js.map +1 -0
- package/dist/adapters/mcp/McpInvocation.d.ts +55 -0
- package/dist/adapters/mcp/McpInvocation.d.ts.map +1 -0
- package/dist/adapters/mcp/McpInvocation.js +88 -0
- package/dist/adapters/mcp/McpInvocation.js.map +1 -0
- package/dist/audit/HashChain.d.ts +8 -2
- package/dist/audit/HashChain.d.ts.map +1 -1
- package/dist/audit/HashChain.js +14 -2
- package/dist/audit/HashChain.js.map +1 -1
- package/dist/boundary/BoundaryIdentity.d.ts +88 -0
- package/dist/boundary/BoundaryIdentity.d.ts.map +1 -0
- package/dist/boundary/BoundaryIdentity.js +126 -0
- package/dist/boundary/BoundaryIdentity.js.map +1 -0
- package/dist/cli/Commands.d.ts +1 -1
- package/dist/cli/Commands.d.ts.map +1 -1
- package/dist/cli/Commands.js +10 -0
- package/dist/cli/Commands.js.map +1 -1
- package/dist/cli/Edge.d.ts +4 -0
- package/dist/cli/Edge.d.ts.map +1 -0
- package/dist/cli/Edge.js +250 -0
- package/dist/cli/Edge.js.map +1 -0
- package/dist/cli/Help.d.ts.map +1 -1
- package/dist/cli/Help.js +9 -0
- package/dist/cli/Help.js.map +1 -1
- package/dist/cli/Host.d.ts +36 -0
- package/dist/cli/Host.d.ts.map +1 -0
- package/dist/cli/Host.js +247 -0
- package/dist/cli/Host.js.map +1 -0
- package/dist/cli/Identity.d.ts +47 -0
- package/dist/cli/Identity.d.ts.map +1 -0
- package/dist/cli/Identity.js +145 -0
- package/dist/cli/Identity.js.map +1 -0
- package/dist/cli/TcpBrokerCli.d.ts +4 -0
- package/dist/cli/TcpBrokerCli.d.ts.map +1 -0
- package/dist/cli/TcpBrokerCli.js +93 -0
- package/dist/cli/TcpBrokerCli.js.map +1 -0
- package/dist/cli/TcpClientCli.d.ts +16 -0
- package/dist/cli/TcpClientCli.d.ts.map +1 -0
- package/dist/cli/TcpClientCli.js +175 -0
- package/dist/cli/TcpClientCli.js.map +1 -0
- package/dist/cli/TestCommand.d.ts +8 -0
- package/dist/cli/TestCommand.d.ts.map +1 -1
- package/dist/cli/TestCommand.js +25 -5
- package/dist/cli/TestCommand.js.map +1 -1
- package/dist/config/ConfigKeys.d.ts +2 -2
- package/dist/config/ConfigKeys.d.ts.map +1 -1
- package/dist/config/ConfigKeys.js +19 -0
- package/dist/config/ConfigKeys.js.map +1 -1
- package/dist/config/ExecutorConfig.d.ts +62 -0
- package/dist/config/ExecutorConfig.d.ts.map +1 -1
- package/dist/config/ExecutorConfig.js +124 -0
- package/dist/config/ExecutorConfig.js.map +1 -1
- package/dist/edge/EdgeLicence.d.ts +25 -0
- package/dist/edge/EdgeLicence.d.ts.map +1 -0
- package/dist/edge/EdgeLicence.js +42 -0
- package/dist/edge/EdgeLicence.js.map +1 -0
- package/dist/edge/EdgeReplay.d.ts +45 -0
- package/dist/edge/EdgeReplay.d.ts.map +1 -0
- package/dist/edge/EdgeReplay.js +69 -0
- package/dist/edge/EdgeReplay.js.map +1 -0
- package/dist/edge/Entitlement.d.ts +57 -0
- package/dist/edge/Entitlement.d.ts.map +1 -0
- package/dist/edge/Entitlement.js +139 -0
- package/dist/edge/Entitlement.js.map +1 -0
- package/dist/edge/EntitlementEvaluation.d.ts +66 -0
- package/dist/edge/EntitlementEvaluation.d.ts.map +1 -0
- package/dist/edge/EntitlementEvaluation.js +74 -0
- package/dist/edge/EntitlementEvaluation.js.map +1 -0
- package/dist/edge/UsageCount.d.ts +40 -0
- package/dist/edge/UsageCount.d.ts.map +1 -0
- package/dist/edge/UsageCount.js +140 -0
- package/dist/edge/UsageCount.js.map +1 -0
- package/dist/edge/UsageKeyRegistration.d.ts +34 -0
- package/dist/edge/UsageKeyRegistration.d.ts.map +1 -0
- package/dist/edge/UsageKeyRegistration.js +74 -0
- package/dist/edge/UsageKeyRegistration.js.map +1 -0
- package/dist/edge/UsageMeter.d.ts +89 -0
- package/dist/edge/UsageMeter.d.ts.map +1 -0
- package/dist/edge/UsageMeter.js +275 -0
- package/dist/edge/UsageMeter.js.map +1 -0
- package/dist/edge/UsagePeriod.d.ts +23 -0
- package/dist/edge/UsagePeriod.d.ts.map +1 -0
- package/dist/edge/UsagePeriod.js +31 -0
- package/dist/edge/UsagePeriod.js.map +1 -0
- package/dist/edge/UsageReport.d.ts +92 -0
- package/dist/edge/UsageReport.d.ts.map +1 -0
- package/dist/edge/UsageReport.js +153 -0
- package/dist/edge/UsageReport.js.map +1 -0
- package/dist/edge/UsageTally.d.ts +63 -0
- package/dist/edge/UsageTally.d.ts.map +1 -0
- package/dist/edge/UsageTally.js +89 -0
- package/dist/edge/UsageTally.js.map +1 -0
- package/dist/egress/EgressError.d.ts +7 -1
- package/dist/egress/EgressError.d.ts.map +1 -1
- package/dist/egress/EgressError.js.map +1 -1
- package/dist/egress/EgressPolicy.d.ts +16 -3
- package/dist/egress/EgressPolicy.d.ts.map +1 -1
- package/dist/egress/EgressPolicy.js +33 -3
- package/dist/egress/EgressPolicy.js.map +1 -1
- package/dist/egress/GuardedFetch.d.ts +38 -1
- package/dist/egress/GuardedFetch.d.ts.map +1 -1
- package/dist/egress/GuardedFetch.js +52 -7
- package/dist/egress/GuardedFetch.js.map +1 -1
- package/dist/egress/TcpClient.d.ts +103 -0
- package/dist/egress/TcpClient.d.ts.map +1 -0
- package/dist/egress/TcpClient.js +490 -0
- package/dist/egress/TcpClient.js.map +1 -0
- package/dist/egress/TcpControlClient.d.ts +49 -0
- package/dist/egress/TcpControlClient.d.ts.map +1 -0
- package/dist/egress/TcpControlClient.js +186 -0
- package/dist/egress/TcpControlClient.js.map +1 -0
- package/dist/gateway/AuthorityAttacks.d.ts +39 -0
- package/dist/gateway/AuthorityAttacks.d.ts.map +1 -0
- package/dist/gateway/AuthorityAttacks.js +158 -0
- package/dist/gateway/AuthorityAttacks.js.map +1 -0
- package/dist/gateway/ForwardHandler.d.ts.map +1 -1
- package/dist/gateway/ForwardHandler.js +7 -4
- package/dist/gateway/ForwardHandler.js.map +1 -1
- package/dist/gateway/Gateway.d.ts +197 -10
- package/dist/gateway/Gateway.d.ts.map +1 -1
- package/dist/gateway/Gateway.js +524 -63
- package/dist/gateway/Gateway.js.map +1 -1
- package/dist/gateway/GatewayConfig.d.ts +78 -0
- package/dist/gateway/GatewayConfig.d.ts.map +1 -1
- package/dist/gateway/GatewayConfig.js +167 -2
- package/dist/gateway/GatewayConfig.js.map +1 -1
- package/dist/gateway/GatewayReport.d.ts +31 -1
- package/dist/gateway/GatewayReport.d.ts.map +1 -1
- package/dist/gateway/GatewayReport.js +12 -0
- package/dist/gateway/GatewayReport.js.map +1 -1
- package/dist/gateway/InterceptedRequest.d.ts +9 -2
- package/dist/gateway/InterceptedRequest.d.ts.map +1 -1
- package/dist/gateway/InterceptedRequest.js +41 -9
- package/dist/gateway/InterceptedRequest.js.map +1 -1
- package/dist/gateway/RateLimit.d.ts +29 -0
- package/dist/gateway/RateLimit.d.ts.map +1 -0
- package/dist/gateway/RateLimit.js +33 -0
- package/dist/gateway/RateLimit.js.map +1 -0
- package/dist/gateway/RefusalSampler.d.ts +28 -0
- package/dist/gateway/RefusalSampler.d.ts.map +1 -0
- package/dist/gateway/RefusalSampler.js +52 -0
- package/dist/gateway/RefusalSampler.js.map +1 -0
- package/dist/gateway/RouteTable.d.ts +3 -0
- package/dist/gateway/RouteTable.d.ts.map +1 -1
- package/dist/gateway/RouteTable.js +44 -7
- package/dist/gateway/RouteTable.js.map +1 -1
- package/dist/gateway/Upstream.d.ts +26 -0
- package/dist/gateway/Upstream.d.ts.map +1 -1
- package/dist/gateway/Upstream.js +41 -2
- package/dist/gateway/Upstream.js.map +1 -1
- package/dist/gateway/UpstreamProof.d.ts +235 -0
- package/dist/gateway/UpstreamProof.d.ts.map +1 -0
- package/dist/gateway/UpstreamProof.js +375 -0
- package/dist/gateway/UpstreamProof.js.map +1 -0
- package/dist/handlers/ForwardRequestHandler.d.ts +5 -1
- package/dist/handlers/ForwardRequestHandler.d.ts.map +1 -1
- package/dist/handlers/ForwardRequestHandler.js +12 -2
- package/dist/handlers/ForwardRequestHandler.js.map +1 -1
- package/dist/hosted/TenantHost.d.ts +180 -0
- package/dist/hosted/TenantHost.d.ts.map +1 -0
- package/dist/hosted/TenantHost.js +432 -0
- package/dist/hosted/TenantHost.js.map +1 -0
- package/dist/hosted/TenantRegistry.d.ts +73 -0
- package/dist/hosted/TenantRegistry.d.ts.map +1 -0
- package/dist/hosted/TenantRegistry.js +123 -0
- package/dist/hosted/TenantRegistry.js.map +1 -0
- package/dist/http/ExecutorHttpServer.d.ts +7 -0
- package/dist/http/ExecutorHttpServer.d.ts.map +1 -1
- package/dist/http/ExecutorHttpServer.js +30 -5
- package/dist/http/ExecutorHttpServer.js.map +1 -1
- package/dist/http/GatewayHttpServer.d.ts +55 -3
- package/dist/http/GatewayHttpServer.d.ts.map +1 -1
- package/dist/http/GatewayHttpServer.js +157 -17
- package/dist/http/GatewayHttpServer.js.map +1 -1
- package/dist/http/RedirectServer.d.ts +26 -0
- package/dist/http/RedirectServer.d.ts.map +1 -0
- package/dist/http/RedirectServer.js +62 -0
- package/dist/http/RedirectServer.js.map +1 -0
- package/dist/http/Routes.d.ts +17 -0
- package/dist/http/Routes.d.ts.map +1 -1
- package/dist/http/Routes.js +21 -0
- package/dist/http/Routes.js.map +1 -1
- package/dist/http/TcpBroker.d.ts +57 -0
- package/dist/http/TcpBroker.d.ts.map +1 -0
- package/dist/http/TcpBroker.js +299 -0
- package/dist/http/TcpBroker.js.map +1 -0
- package/dist/http/TcpHostRelay.d.ts +24 -0
- package/dist/http/TcpHostRelay.d.ts.map +1 -0
- package/dist/http/TcpHostRelay.js +194 -0
- package/dist/http/TcpHostRelay.js.map +1 -0
- package/dist/http/TcpRelayStreams.d.ts +24 -0
- package/dist/http/TcpRelayStreams.d.ts.map +1 -0
- package/dist/http/TcpRelayStreams.js +128 -0
- package/dist/http/TcpRelayStreams.js.map +1 -0
- package/dist/http/TlsListener.d.ts +3 -1
- package/dist/http/TlsListener.d.ts.map +1 -1
- package/dist/http/TlsListener.js +7 -2
- package/dist/http/TlsListener.js.map +1 -1
- package/dist/identity/PrincipalsFile.d.ts +3 -1
- package/dist/identity/PrincipalsFile.d.ts.map +1 -1
- package/dist/identity/PrincipalsFile.js +1 -0
- package/dist/identity/PrincipalsFile.js.map +1 -1
- package/dist/incident/Metrics.d.ts +2 -0
- package/dist/incident/Metrics.d.ts.map +1 -1
- package/dist/incident/Metrics.js +10 -0
- package/dist/incident/Metrics.js.map +1 -1
- package/dist/incident/SecurityEvents.d.ts +89 -0
- package/dist/incident/SecurityEvents.d.ts.map +1 -1
- package/dist/incident/SecurityEvents.js +93 -2
- package/dist/incident/SecurityEvents.js.map +1 -1
- package/dist/journal/ExecutionJournal.d.ts +27 -0
- package/dist/journal/ExecutionJournal.d.ts.map +1 -1
- package/dist/journal/ExecutionJournal.js +28 -0
- package/dist/journal/ExecutionJournal.js.map +1 -1
- package/dist/journal/FileExecutionJournal.d.ts +2 -1
- package/dist/journal/FileExecutionJournal.d.ts.map +1 -1
- package/dist/journal/FileExecutionJournal.js +4 -1
- package/dist/journal/FileExecutionJournal.js.map +1 -1
- package/dist/journal/InMemoryExecutionJournal.d.ts +2 -1
- package/dist/journal/InMemoryExecutionJournal.d.ts.map +1 -1
- package/dist/journal/InMemoryExecutionJournal.js +4 -1
- package/dist/journal/InMemoryExecutionJournal.js.map +1 -1
- package/dist/provenance/DockerProvenanceProvider.d.ts +23 -0
- package/dist/provenance/DockerProvenanceProvider.d.ts.map +1 -0
- package/dist/provenance/DockerProvenanceProvider.js +24 -0
- package/dist/provenance/DockerProvenanceProvider.js.map +1 -0
- package/dist/provenance/KubernetesProvenanceProvider.d.ts +17 -0
- package/dist/provenance/KubernetesProvenanceProvider.d.ts.map +1 -0
- package/dist/provenance/KubernetesProvenanceProvider.js +18 -0
- package/dist/provenance/KubernetesProvenanceProvider.js.map +1 -0
- package/dist/provenance/NoneProvenanceProvider.d.ts +15 -0
- package/dist/provenance/NoneProvenanceProvider.d.ts.map +1 -0
- package/dist/provenance/NoneProvenanceProvider.js +16 -0
- package/dist/provenance/NoneProvenanceProvider.js.map +1 -0
- package/dist/provenance/ProvenanceProvider.d.ts +94 -0
- package/dist/provenance/ProvenanceProvider.d.ts.map +1 -0
- package/dist/provenance/ProvenanceProvider.js +118 -0
- package/dist/provenance/ProvenanceProvider.js.map +1 -0
- package/dist/provenance/StaticProvenanceProvider.d.ts +18 -0
- package/dist/provenance/StaticProvenanceProvider.d.ts.map +1 -0
- package/dist/provenance/StaticProvenanceProvider.js +25 -0
- package/dist/provenance/StaticProvenanceProvider.js.map +1 -0
- package/dist/service/AuthorityClients.d.ts +8 -1
- package/dist/service/AuthorityClients.d.ts.map +1 -1
- package/dist/service/AuthorityClients.js +33 -5
- package/dist/service/AuthorityClients.js.map +1 -1
- package/dist/service/EdgeRuntime.d.ts +73 -0
- package/dist/service/EdgeRuntime.d.ts.map +1 -0
- package/dist/service/EdgeRuntime.js +209 -0
- package/dist/service/EdgeRuntime.js.map +1 -0
- package/dist/service/EscalationResolver.d.ts +82 -2
- package/dist/service/EscalationResolver.d.ts.map +1 -1
- package/dist/service/EscalationResolver.js +39 -3
- package/dist/service/EscalationResolver.js.map +1 -1
- package/dist/service/Requests.d.ts +28 -2
- package/dist/service/Requests.d.ts.map +1 -1
- package/dist/service/TrustedExecutorService.d.ts +71 -1
- package/dist/service/TrustedExecutorService.d.ts.map +1 -1
- package/dist/service/TrustedExecutorService.js +461 -27
- package/dist/service/TrustedExecutorService.js.map +1 -1
- package/dist/tcp/TcpWire.d.ts +18 -0
- package/dist/tcp/TcpWire.d.ts.map +1 -0
- package/dist/tcp/TcpWire.js +114 -0
- package/dist/tcp/TcpWire.js.map +1 -0
- package/dist/verify/VerifyAuditChain.d.ts +5 -0
- package/dist/verify/VerifyAuditChain.d.ts.map +1 -1
- package/dist/verify/VerifyAuditChain.js +20 -4
- package/dist/verify/VerifyAuditChain.js.map +1 -1
- package/package.json +7 -3
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The one card action this family registers: a purchase the issuer will authorize later. */
|
|
3
|
+
export declare const CARD_PURCHASE_ACTION = "card.purchase";
|
|
4
|
+
export declare class CardActionError extends Error {
|
|
5
|
+
readonly code: string;
|
|
6
|
+
constructor(code: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The parameters of `card.purchase`: what the agent wants to buy, with which
|
|
10
|
+
* card, from whom, for at most how much. The card is named by its token
|
|
11
|
+
* reference, never by its number; the amount is minor units of a currency
|
|
12
|
+
* this build knows the exponent of, and it is the ceiling the issuer's
|
|
13
|
+
* authorization will be matched against.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CardPurchaseSchema: z.ZodObject<{
|
|
16
|
+
cardTokenRef: z.ZodString;
|
|
17
|
+
amountMinor: z.ZodNumber;
|
|
18
|
+
currency: z.ZodString;
|
|
19
|
+
merchantId: z.ZodString;
|
|
20
|
+
mcc: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
export type CardPurchase = z.infer<typeof CardPurchaseSchema>;
|
|
23
|
+
/** What the issuer's real-time authorization hook asks. */
|
|
24
|
+
export declare const CardAuthorizationRequestSchema: z.ZodObject<{
|
|
25
|
+
authorization_id: z.ZodString;
|
|
26
|
+
card_token_ref: z.ZodString;
|
|
27
|
+
amount_minor: z.ZodNumber;
|
|
28
|
+
currency: z.ZodString;
|
|
29
|
+
merchant_id: z.ZodString;
|
|
30
|
+
mcc: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
export type CardAuthorizationRequest = z.infer<typeof CardAuthorizationRequestSchema>;
|
|
33
|
+
/** What the issuer says it did with an authorization it asked about. */
|
|
34
|
+
export declare const CardAuthorizationResultSchema: z.ZodObject<{
|
|
35
|
+
status: z.ZodEnum<{
|
|
36
|
+
APPROVED: "APPROVED";
|
|
37
|
+
DECLINED: "DECLINED";
|
|
38
|
+
}>;
|
|
39
|
+
approved_amount_minor: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
auth_code: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
export type CardAuthorizationResult = z.infer<typeof CardAuthorizationResultSchema>;
|
|
43
|
+
/** The action as the profile reads it, or the refusal that says why not. */
|
|
44
|
+
export declare function cardPurchaseOf(parameters: unknown): CardPurchase;
|
|
45
|
+
/**
|
|
46
|
+
* The binding between the transport and the action: the target is derived
|
|
47
|
+
* from the card, so a caller describing one card and asking for another is
|
|
48
|
+
* refused before the authority is asked.
|
|
49
|
+
*/
|
|
50
|
+
export declare function bindCardPurchase(input: {
|
|
51
|
+
readonly target: string;
|
|
52
|
+
readonly parameters: unknown;
|
|
53
|
+
}): CardPurchase;
|
|
54
|
+
/** The transport target a card purchase names: the card it spends from. */
|
|
55
|
+
export declare function cardTarget(purchase: CardPurchase): string;
|
|
56
|
+
export declare function cardAuthorizationOf(input: unknown): CardAuthorizationRequest;
|
|
57
|
+
export declare function cardAuthorizationResultOf(input: unknown): CardAuthorizationResult;
|
|
58
|
+
/** An authorization id as it arrives in a path segment, held to the same rule as everywhere else. */
|
|
59
|
+
export declare function isCardReference(value: string): boolean;
|
|
60
|
+
export declare function isCardActionName(action: string): boolean;
|
|
61
|
+
//# sourceMappingURL=CardPurchase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardPurchase.d.ts","sourceRoot":"","sources":["../../../src/adapters/cards/CardPurchase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,6FAA6F;AAC7F,eAAO,MAAM,oBAAoB,kBAAkB,CAAC;AAEpD,qBAAa,eAAgB,SAAQ,KAAK;aACL,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;CAIhD;AAiBD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;;;;kBAM7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,2DAA2D;AAC3D,eAAO,MAAM,8BAA8B;;;;;;;kBAOzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,wEAAwE;AACxE,eAAO,MAAM,6BAA6B;;;;;;;kBAOxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAYpF,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,UAAU,EAAE,OAAO,GAAG,YAAY,CAShE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B,GAAG,YAAY,CAIf;AAED,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAEzD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAK5E;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAIjF;AAED,qGAAqG;AACrG,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { isSupportedCurrency } from "../banking/Currency.js";
|
|
3
|
+
import { containsPan } from "./Pan.js";
|
|
4
|
+
/** The one card action this family registers: a purchase the issuer will authorize later. */
|
|
5
|
+
export const CARD_PURCHASE_ACTION = "card.purchase";
|
|
6
|
+
export class CardActionError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
constructor(code) {
|
|
9
|
+
super(code);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.name = "CardActionError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A reference: a card token reference, a merchant id, an authorization id.
|
|
16
|
+
* Opaque to this boundary, bounded, and in a character set no header,
|
|
17
|
+
* path segment or log line has to escape.
|
|
18
|
+
*/
|
|
19
|
+
const REFERENCE = /^[\w.:-]{1,200}$/;
|
|
20
|
+
const CURRENCY = /^[A-Z]{3}$/;
|
|
21
|
+
const MCC = /^\d{4}$/;
|
|
22
|
+
const reference = z.string().regex(REFERENCE);
|
|
23
|
+
/** A card reference is a reference that is not, and does not contain, a card number. */
|
|
24
|
+
const cardReference = reference.refine((value) => !containsPan(value));
|
|
25
|
+
/** Minor units, as a JSON integer: at least one, and exact in a double. */
|
|
26
|
+
const minorUnits = z.number().int().positive();
|
|
27
|
+
/**
|
|
28
|
+
* The parameters of `card.purchase`: what the agent wants to buy, with which
|
|
29
|
+
* card, from whom, for at most how much. The card is named by its token
|
|
30
|
+
* reference, never by its number; the amount is minor units of a currency
|
|
31
|
+
* this build knows the exponent of, and it is the ceiling the issuer's
|
|
32
|
+
* authorization will be matched against.
|
|
33
|
+
*/
|
|
34
|
+
export const CardPurchaseSchema = z.strictObject({
|
|
35
|
+
cardTokenRef: cardReference,
|
|
36
|
+
amountMinor: minorUnits,
|
|
37
|
+
currency: z.string().regex(CURRENCY),
|
|
38
|
+
merchantId: reference,
|
|
39
|
+
mcc: z.string().regex(MCC).optional(),
|
|
40
|
+
});
|
|
41
|
+
/** What the issuer's real-time authorization hook asks. */
|
|
42
|
+
export const CardAuthorizationRequestSchema = z.strictObject({
|
|
43
|
+
authorization_id: reference,
|
|
44
|
+
card_token_ref: cardReference,
|
|
45
|
+
amount_minor: minorUnits,
|
|
46
|
+
currency: z.string().regex(CURRENCY),
|
|
47
|
+
merchant_id: reference,
|
|
48
|
+
mcc: z.string().regex(MCC).optional(),
|
|
49
|
+
});
|
|
50
|
+
/** What the issuer says it did with an authorization it asked about. */
|
|
51
|
+
export const CardAuthorizationResultSchema = z.strictObject({
|
|
52
|
+
status: z.enum(["APPROVED", "DECLINED"]),
|
|
53
|
+
approved_amount_minor: minorUnits.optional(),
|
|
54
|
+
auth_code: z
|
|
55
|
+
.string()
|
|
56
|
+
.regex(/^[A-Z0-9]{1,12}$/)
|
|
57
|
+
.optional(),
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* A card number anywhere it could be read is refused under its own code,
|
|
61
|
+
* before any other rule, so a caller learns that it sent one and never the
|
|
62
|
+
* value: no response, record or line repeats a parameter. Whatever JSON type
|
|
63
|
+
* carries it, a number written as digits is still a card number.
|
|
64
|
+
*/
|
|
65
|
+
function refusePan(value) {
|
|
66
|
+
if (containsPan(String(value)))
|
|
67
|
+
throw new CardActionError("CARD_PAN_REFUSED");
|
|
68
|
+
}
|
|
69
|
+
/** The action as the profile reads it, or the refusal that says why not. */
|
|
70
|
+
export function cardPurchaseOf(parameters) {
|
|
71
|
+
refusePan(parameters?.cardTokenRef);
|
|
72
|
+
const parsed = CardPurchaseSchema.safeParse(parameters);
|
|
73
|
+
if (!parsed.success)
|
|
74
|
+
throw new CardActionError("CARD_PURCHASE_INVALID");
|
|
75
|
+
// A currency is only a number once its exponent is known; one this build lacks is refused.
|
|
76
|
+
if (!isSupportedCurrency(parsed.data.currency)) {
|
|
77
|
+
throw new CardActionError("CARD_CURRENCY_UNSUPPORTED");
|
|
78
|
+
}
|
|
79
|
+
return parsed.data;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The binding between the transport and the action: the target is derived
|
|
83
|
+
* from the card, so a caller describing one card and asking for another is
|
|
84
|
+
* refused before the authority is asked.
|
|
85
|
+
*/
|
|
86
|
+
export function bindCardPurchase(input) {
|
|
87
|
+
const purchase = cardPurchaseOf(input.parameters);
|
|
88
|
+
if (input.target !== cardTarget(purchase))
|
|
89
|
+
throw new CardActionError("CARD_TARGET_MISMATCH");
|
|
90
|
+
return purchase;
|
|
91
|
+
}
|
|
92
|
+
/** The transport target a card purchase names: the card it spends from. */
|
|
93
|
+
export function cardTarget(purchase) {
|
|
94
|
+
return `card:${purchase.cardTokenRef}`;
|
|
95
|
+
}
|
|
96
|
+
export function cardAuthorizationOf(input) {
|
|
97
|
+
refusePan(input?.card_token_ref);
|
|
98
|
+
const parsed = CardAuthorizationRequestSchema.safeParse(input);
|
|
99
|
+
if (!parsed.success)
|
|
100
|
+
throw new CardActionError("CARD_AUTHORIZATION_INVALID");
|
|
101
|
+
return parsed.data;
|
|
102
|
+
}
|
|
103
|
+
export function cardAuthorizationResultOf(input) {
|
|
104
|
+
const parsed = CardAuthorizationResultSchema.safeParse(input);
|
|
105
|
+
if (!parsed.success)
|
|
106
|
+
throw new CardActionError("CARD_AUTHORIZATION_RESULT_INVALID");
|
|
107
|
+
return parsed.data;
|
|
108
|
+
}
|
|
109
|
+
/** An authorization id as it arrives in a path segment, held to the same rule as everywhere else. */
|
|
110
|
+
export function isCardReference(value) {
|
|
111
|
+
return REFERENCE.test(value);
|
|
112
|
+
}
|
|
113
|
+
export function isCardActionName(action) {
|
|
114
|
+
return action === CARD_PURCHASE_ACTION;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=CardPurchase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardPurchase.js","sourceRoot":"","sources":["../../../src/adapters/cards/CardPurchase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAe,CAAC;AAEpD,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACL;IAAnC,YAAmC,IAAY;QAC7C,KAAK,CAAC,IAAI,CAAC,CAAC;QADqB,SAAI,GAAJ,IAAI,CAAQ;QAE7C,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,SAAS,GAAG,kBAAkB,CAAC;AACrC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAC9B,MAAM,GAAG,GAAG,SAAS,CAAC;AAEtB,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAC9C,wFAAwF;AACxF,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,2EAA2E;AAC3E,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC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,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,OAAO,MAAM,KAAK,oBAAoB,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { HeldExecution, SafeExecutor, VerifiedAuthorization } from "@decionis/agent-safe-pipeline";
|
|
2
|
+
import type { CardAuthorizationAnswer } from "../../service/Requests.js";
|
|
3
|
+
import type { PreparedAction } from "../EffectAdapter.js";
|
|
4
|
+
import type { HeldCardGrantView } from "./CardAuthorizationMatcher.js";
|
|
5
|
+
import type { CardAuthorizationRequest, CardPurchase } from "./CardPurchase.js";
|
|
6
|
+
/** One held grant: the purchase, the executor's handle on it, and whether it is spent. */
|
|
7
|
+
export interface HeldCardGrant extends HeldCardGrantView {
|
|
8
|
+
readonly purchase: CardPurchase;
|
|
9
|
+
readonly prepared: PreparedAction;
|
|
10
|
+
readonly held: HeldExecution;
|
|
11
|
+
/** The executor that issued the hold; only it can claim it. */
|
|
12
|
+
readonly executor: SafeExecutor;
|
|
13
|
+
used: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** What the issuer was answered when an authorization matched, kept for a retry of the same one. */
|
|
16
|
+
export type CardApproval = Extract<CardAuthorizationAnswer, {
|
|
17
|
+
readonly decision: "APPROVE";
|
|
18
|
+
}>;
|
|
19
|
+
/** An authorization that claimed a grant, until its result is recorded or it is forgotten. */
|
|
20
|
+
export interface ClaimedCardAuthorization {
|
|
21
|
+
readonly grant: HeldCardGrant;
|
|
22
|
+
readonly request: CardAuthorizationRequest;
|
|
23
|
+
readonly authorization: VerifiedAuthorization;
|
|
24
|
+
readonly leaseExpiresAtMs: number;
|
|
25
|
+
readonly answer: CardApproval;
|
|
26
|
+
readonly retainUntilMs: number;
|
|
27
|
+
settled: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface HeldCardGrantsOptions {
|
|
30
|
+
/** Entries of each kind this process keeps at most; a hold beyond it is refused. */
|
|
31
|
+
readonly maxEntries?: number;
|
|
32
|
+
/** How long a claimed authorization waits for its result before it is forgotten. */
|
|
33
|
+
readonly claimRetentionMs?: number;
|
|
34
|
+
readonly clock?: () => number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Grants held for a card authorization that has not happened yet, keyed by
|
|
38
|
+
* the card token reference, and the authorizations that claimed one, keyed
|
|
39
|
+
* by the issuer's authorization id. In memory and bounded on purpose: a hold
|
|
40
|
+
* lives no longer than its grant, which the authority caps in minutes, and a
|
|
41
|
+
* restart that loses one loses only a grant nobody claimed, which expires
|
|
42
|
+
* with no effect. A claimed authorization is already in the journal.
|
|
43
|
+
*
|
|
44
|
+
* One card has at most one spendable hold. An agent that wants a second
|
|
45
|
+
* purchase on the same card waits for the first to be authorised or to
|
|
46
|
+
* expire, so an authorization can never be matched to the wrong one of two.
|
|
47
|
+
*/
|
|
48
|
+
export declare class HeldCardGrants {
|
|
49
|
+
private readonly holds;
|
|
50
|
+
private readonly claims;
|
|
51
|
+
private readonly maxEntries;
|
|
52
|
+
private readonly claimRetentionMs;
|
|
53
|
+
private readonly clock;
|
|
54
|
+
constructor(options?: HeldCardGrantsOptions);
|
|
55
|
+
/** Whether the card has a hold an authorization could still match. */
|
|
56
|
+
spendable(cardTokenRef: string): boolean;
|
|
57
|
+
/** The hold for a card, spent, expired or neither, until it is forgotten. */
|
|
58
|
+
grant(cardTokenRef: string): HeldCardGrant | undefined;
|
|
59
|
+
/** Keeps a hold; false when the card already has a spendable one or the store is full. */
|
|
60
|
+
hold(grant: HeldCardGrant): boolean;
|
|
61
|
+
claimed(authorizationId: string): ClaimedCardAuthorization | undefined;
|
|
62
|
+
/** Remembers a claim for its result; a full store forgets the oldest, which the journal still holds. */
|
|
63
|
+
recordClaim(authorizationId: string, claim: Omit<ClaimedCardAuthorization, "retainUntilMs" | "settled">): ClaimedCardAuthorization;
|
|
64
|
+
get size(): {
|
|
65
|
+
readonly holds: number;
|
|
66
|
+
readonly claims: number;
|
|
67
|
+
};
|
|
68
|
+
private sweep;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=HeldCardGrants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeldCardGrants.d.ts","sourceRoot":"","sources":["../../../src/adapters/cards/HeldCardGrants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,qBAAqB,EACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEhF,0FAA0F;AAC1F,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,IAAI,EAAE,OAAO,CAAC;CACf;AAED,oGAAoG;AACpG,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,uBAAuB,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAE9F,8FAA8F;AAC9F,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,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AErE;IAED,OAAO,CAAC,KAAK;CAWd"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grants held for a card authorization that has not happened yet, keyed by
|
|
3
|
+
* the card token reference, and the authorizations that claimed one, keyed
|
|
4
|
+
* by the issuer's authorization id. In memory and bounded on purpose: a hold
|
|
5
|
+
* lives no longer than its grant, which the authority caps in minutes, and a
|
|
6
|
+
* restart that loses one loses only a grant nobody claimed, which expires
|
|
7
|
+
* with no effect. A claimed authorization is already in the journal.
|
|
8
|
+
*
|
|
9
|
+
* One card has at most one spendable hold. An agent that wants a second
|
|
10
|
+
* purchase on the same card waits for the first to be authorised or to
|
|
11
|
+
* expire, so an authorization can never be matched to the wrong one of two.
|
|
12
|
+
*/
|
|
13
|
+
export class HeldCardGrants {
|
|
14
|
+
holds = new Map();
|
|
15
|
+
claims = new Map();
|
|
16
|
+
maxEntries;
|
|
17
|
+
claimRetentionMs;
|
|
18
|
+
clock;
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this.maxEntries = options.maxEntries ?? 10_000;
|
|
21
|
+
this.claimRetentionMs = options.claimRetentionMs ?? 15 * 60_000;
|
|
22
|
+
this.clock = options.clock ?? (() => Date.now());
|
|
23
|
+
}
|
|
24
|
+
/** Whether the card has a hold an authorization could still match. */
|
|
25
|
+
spendable(cardTokenRef) {
|
|
26
|
+
const grant = this.grant(cardTokenRef);
|
|
27
|
+
return grant !== undefined && !grant.used && grant.expiresAtMs > this.clock();
|
|
28
|
+
}
|
|
29
|
+
/** The hold for a card, spent, expired or neither, until it is forgotten. */
|
|
30
|
+
grant(cardTokenRef) {
|
|
31
|
+
this.sweep();
|
|
32
|
+
return this.holds.get(cardTokenRef);
|
|
33
|
+
}
|
|
34
|
+
/** Keeps a hold; false when the card already has a spendable one or the store is full. */
|
|
35
|
+
hold(grant) {
|
|
36
|
+
if (this.spendable(grant.cardTokenRef))
|
|
37
|
+
return false;
|
|
38
|
+
this.holds.delete(grant.cardTokenRef);
|
|
39
|
+
if (this.holds.size >= this.maxEntries)
|
|
40
|
+
return false;
|
|
41
|
+
this.holds.set(grant.cardTokenRef, grant);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
claimed(authorizationId) {
|
|
45
|
+
this.sweep();
|
|
46
|
+
return this.claims.get(authorizationId);
|
|
47
|
+
}
|
|
48
|
+
/** Remembers a claim for its result; a full store forgets the oldest, which the journal still holds. */
|
|
49
|
+
recordClaim(authorizationId, claim) {
|
|
50
|
+
const record = {
|
|
51
|
+
...claim,
|
|
52
|
+
retainUntilMs: this.clock() + this.claimRetentionMs,
|
|
53
|
+
settled: false,
|
|
54
|
+
};
|
|
55
|
+
if (this.claims.size >= this.maxEntries) {
|
|
56
|
+
const oldest = this.claims.keys().next().value;
|
|
57
|
+
this.claims.delete(oldest);
|
|
58
|
+
}
|
|
59
|
+
this.claims.set(authorizationId, record);
|
|
60
|
+
return record;
|
|
61
|
+
}
|
|
62
|
+
get size() {
|
|
63
|
+
return { holds: this.holds.size, claims: this.claims.size };
|
|
64
|
+
}
|
|
65
|
+
sweep() {
|
|
66
|
+
const now = this.clock();
|
|
67
|
+
// An expired hold is kept as long as a claim would be, so an authorization
|
|
68
|
+
// that arrives late is told its grant expired rather than that none existed.
|
|
69
|
+
for (const [key, grant] of this.holds) {
|
|
70
|
+
if (grant.expiresAtMs + this.claimRetentionMs <= now)
|
|
71
|
+
this.holds.delete(key);
|
|
72
|
+
}
|
|
73
|
+
for (const [key, claim] of this.claims) {
|
|
74
|
+
if (claim.retainUntilMs <= now)
|
|
75
|
+
this.claims.delete(key);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=HeldCardGrants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeldCardGrants.js","sourceRoot":"","sources":["../../../src/adapters/cards/HeldCardGrants.ts"],"names":[],"mappings":"AA0CA;;;;;;;;;;;GAWG;AACH,MAAM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AC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACvC,IAAI,KAAK,CAAC,aAAa,IAAI,GAAG;gBAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a value carries something shaped like a primary account number:
|
|
3
|
+
* 13 to 19 digits that pass the Luhn check, written together or grouped by
|
|
4
|
+
* spaces, hyphens or other punctuation (`4111 1111 1111 1111`,
|
|
5
|
+
* `4111-1111-1111-1111`). A letter ends a run, so `tok_4111111111111111`
|
|
6
|
+
* is still caught by the digits after the prefix.
|
|
7
|
+
*
|
|
8
|
+
* A card reference crosses this boundary into a hashed intent, a Decision
|
|
9
|
+
* Dossier and an evidence line, and none of those may ever hold a card
|
|
10
|
+
* number; so a value that merely looks like one is refused, and a reference
|
|
11
|
+
* that is refused by mistake costs a caller a different reference, which is
|
|
12
|
+
* the right side to err on. Both the contiguous run and the run joined
|
|
13
|
+
* across punctuation are checked, so a number cannot hide behind a trailing
|
|
14
|
+
* group of other digits written after a separator.
|
|
15
|
+
*/
|
|
16
|
+
export declare function containsPan(value: string): boolean;
|
|
17
|
+
//# sourceMappingURL=Pan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pan.d.ts","sourceRoot":"","sources":["../../../src/adapters/cards/Pan.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAmBlD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value a doubled digit contributes to a Luhn sum, by digit: 2 × d, with
|
|
3
|
+
* the two digits of a two-digit product added together.
|
|
4
|
+
*/
|
|
5
|
+
const DOUBLED = "0246813579";
|
|
6
|
+
/** A run of digits a card number could be: 13 to 19 of them, passing Luhn. */
|
|
7
|
+
function panShaped(digits) {
|
|
8
|
+
if (digits.length < 13 || digits.length > 19)
|
|
9
|
+
return false;
|
|
10
|
+
const sum = [...digits].reverse().reduce((total, digit, index) =>
|
|
11
|
+
// Stryker disable next-line ArithmeticOperator: divisibility by ten does not depend on the sum's sign.
|
|
12
|
+
total + Number(index % 2 === 0 ? digit : DOUBLED[Number(digit)]), 0);
|
|
13
|
+
return sum % 10 === 0;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Whether a value carries something shaped like a primary account number:
|
|
17
|
+
* 13 to 19 digits that pass the Luhn check, written together or grouped by
|
|
18
|
+
* spaces, hyphens or other punctuation (`4111 1111 1111 1111`,
|
|
19
|
+
* `4111-1111-1111-1111`). A letter ends a run, so `tok_4111111111111111`
|
|
20
|
+
* is still caught by the digits after the prefix.
|
|
21
|
+
*
|
|
22
|
+
* A card reference crosses this boundary into a hashed intent, a Decision
|
|
23
|
+
* Dossier and an evidence line, and none of those may ever hold a card
|
|
24
|
+
* number; so a value that merely looks like one is refused, and a reference
|
|
25
|
+
* that is refused by mistake costs a caller a different reference, which is
|
|
26
|
+
* the right side to err on. Both the contiguous run and the run joined
|
|
27
|
+
* across punctuation are checked, so a number cannot hide behind a trailing
|
|
28
|
+
* group of other digits written after a separator.
|
|
29
|
+
*/
|
|
30
|
+
export function containsPan(value) {
|
|
31
|
+
let contiguous = "";
|
|
32
|
+
let joined = "";
|
|
33
|
+
// The trailing letter ends the last run, so it is checked like every other.
|
|
34
|
+
for (const character of `${value}x`) {
|
|
35
|
+
if (character >= "0" && character <= "9") {
|
|
36
|
+
contiguous += character;
|
|
37
|
+
joined += character;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (panShaped(contiguous))
|
|
41
|
+
return true;
|
|
42
|
+
contiguous = "";
|
|
43
|
+
// A letter is a character with case; punctuation and spaces have none.
|
|
44
|
+
if (character.toLowerCase() !== character.toUpperCase()) {
|
|
45
|
+
if (panShaped(joined))
|
|
46
|
+
return true;
|
|
47
|
+
joined = "";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=Pan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pan.js","sourceRoot":"","sources":["../../../src/adapters/cards/Pan.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,GAAG,YAAY,CAAC;AAE7B,8EAA8E;AAC9E,SAAS,SAAS,CAAC,MAAc;IAC/B,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE;QAAE,OAAO,KAAK,CAAC;IAC3D,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,MAAM,CACtC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;IACtB,uGAAuG;IACvG,KAAK,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAClE,CAAC,CACF,CAAC;IACF,OAAO,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,4EAA4E;IAC5E,KAAK,MAAM,SAAS,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QACpC,IAAI,SAAS,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC;YACzC,UAAU,IAAI,SAAS,CAAC;YACxB,MAAM,IAAI,SAAS,CAAC;YACpB,SAAS;QACX,CAAC;QACD,IAAI,SAAS,CAAC,UAAU,CAAC;YAAE,OAAO,IAAI,CAAC;QACvC,UAAU,GAAG,EAAE,CAAC;QAChB,uEAAuE;QACvE,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;YACxD,IAAI,SAAS,CAAC,MAAM,CAAC;gBAAE,OAAO,IAAI,CAAC;YACnC,MAAM,GAAG,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { IntentCapture, type AuditRecorder, type AuthorizationVerifier, type DecisionAuthority, type ExecutionSignals, type IntentActor, type JsonObject } from "@decionis/agent-safe-pipeline";
|
|
2
|
+
import { McpBindingError } from "./McpIntentBinder.js";
|
|
3
|
+
import type { McpInvocation, McpToolBinding } from "./McpInvocation.js";
|
|
4
|
+
/**
|
|
5
|
+
* One consequential MCP tool: what an operator declared about it, and what it
|
|
6
|
+
* actually does. `invoke` runs only behind a claimed single-use grant, with
|
|
7
|
+
* the arguments the authority evaluated.
|
|
8
|
+
*/
|
|
9
|
+
export interface McpTool<TResult = unknown> {
|
|
10
|
+
readonly binding: McpToolBinding;
|
|
11
|
+
invoke(args: JsonObject): Promise<TResult>;
|
|
12
|
+
}
|
|
13
|
+
export interface McpGuardOptions {
|
|
14
|
+
readonly tools: readonly McpTool[];
|
|
15
|
+
readonly authority: DecisionAuthority;
|
|
16
|
+
readonly verifier: AuthorizationVerifier;
|
|
17
|
+
readonly tenantId: string;
|
|
18
|
+
readonly actor: IntentActor;
|
|
19
|
+
readonly audit?: AuditRecorder;
|
|
20
|
+
readonly capture?: IntentCapture;
|
|
21
|
+
/** The boundary and workload this process is, bound into every intent. */
|
|
22
|
+
readonly signals?: ExecutionSignals;
|
|
23
|
+
readonly boundaryId?: string;
|
|
24
|
+
readonly workloadDigest?: string;
|
|
25
|
+
readonly createIdempotencyKey?: (invocation: McpInvocation) => string;
|
|
26
|
+
}
|
|
27
|
+
export type McpRefusal = McpBindingError["code"] | "MCP_ARGUMENTS_MISMATCH" | string;
|
|
28
|
+
/**
|
|
29
|
+
* What became of one invocation. `executed` follows the executor's own
|
|
30
|
+
* vocabulary rather than simplifying it: `null` is a tool that was authorized
|
|
31
|
+
* and dispatched and whose outcome was lost, which is not the same answer as
|
|
32
|
+
* "no" and must never be reported as one. Re-invoking on `null` would be a
|
|
33
|
+
* second attempt at an effect that may already exist; reconcile instead.
|
|
34
|
+
*/
|
|
35
|
+
export type McpOutcome<TResult = unknown> = {
|
|
36
|
+
readonly executed: true;
|
|
37
|
+
readonly intentHash: string;
|
|
38
|
+
readonly verdict: "ALLOW";
|
|
39
|
+
readonly dossierId: string | null;
|
|
40
|
+
readonly result: TResult;
|
|
41
|
+
} | {
|
|
42
|
+
readonly executed: false;
|
|
43
|
+
/** Null when the invocation was refused before an intent existed. */
|
|
44
|
+
readonly intentHash: string | null;
|
|
45
|
+
readonly verdict: "ALLOW" | "BLOCK" | "ESCALATE" | null;
|
|
46
|
+
readonly dossierId: string | null;
|
|
47
|
+
readonly reason: McpRefusal;
|
|
48
|
+
} | {
|
|
49
|
+
readonly executed: null;
|
|
50
|
+
readonly intentHash: string;
|
|
51
|
+
readonly verdict: "ALLOW";
|
|
52
|
+
readonly dossierId: string | null;
|
|
53
|
+
readonly reason: "PROVIDER_OUTCOME_UNKNOWN";
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The authority boundary for MCP tool execution.
|
|
57
|
+
*
|
|
58
|
+
* MCP has already decided how the agent calls the tool. This decides whether
|
|
59
|
+
* this exact invocation may run, and it is the only thing between a selected
|
|
60
|
+
* tool and its effect:
|
|
61
|
+
*
|
|
62
|
+
* tool selected → arguments constructed → **guard** → intent →
|
|
63
|
+
* enforce-and-bind → authority → atomic claim → the tool runs, once
|
|
64
|
+
*
|
|
65
|
+
* It is not an MCP server, an MCP registry, or a replacement for MCP's own
|
|
66
|
+
* authentication. It holds no opinion about transports and depends on no MCP
|
|
67
|
+
* SDK; a server hands it an invocation and gets back a verdict and, when the
|
|
68
|
+
* verdict is ALLOW and the grant was claimed, a result.
|
|
69
|
+
*
|
|
70
|
+
* The property worth stating plainly: **arguments that change after the
|
|
71
|
+
* authority is issued invalidate it.** They are inside the canonical intent
|
|
72
|
+
* hash, so a changed argument is a different intent whose grant does not
|
|
73
|
+
* match; and independently, the handler recomputes their canonical digest
|
|
74
|
+
* immediately before the point of no return and refuses if it is not the one
|
|
75
|
+
* the intent bound. A tool therefore receives the arguments a policy saw, or
|
|
76
|
+
* receives nothing.
|
|
77
|
+
*/
|
|
78
|
+
export declare class McpGuard {
|
|
79
|
+
private readonly bindings;
|
|
80
|
+
private readonly tools;
|
|
81
|
+
private readonly held;
|
|
82
|
+
private readonly capture;
|
|
83
|
+
private readonly executor;
|
|
84
|
+
private readonly options;
|
|
85
|
+
constructor(options: McpGuardOptions);
|
|
86
|
+
/** Every tool this guard governs, for a server publishing its tool list. */
|
|
87
|
+
governs(tool: string): boolean;
|
|
88
|
+
guard<TResult = unknown>(invocation: McpInvocation): Promise<McpOutcome<TResult>>;
|
|
89
|
+
private outcomeOf;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=McpGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpGuard.d.ts","sourceRoot":"","sources":["../../../src/adapters/mcp/McpGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAGb,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,KAAK,UAAU,EAEhB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAiC,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAExE;;;;GAIG;AACH,MAAM,WAAW,OAAO,CAAC,OAAO,GAAG,OAAO;IACxC,QAAQ,CAAC,OAAO,EAA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