@belticlabs/agent-risk-sdk 0.1.0 → 0.2.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/dist/adapter-CF-cUYSA.d.ts +28 -0
- package/dist/ai/index.d.ts +6 -6
- package/dist/ai/index.js +4 -3
- package/dist/{chunk-GCKCAKHA.js → chunk-46QN2KEZ.js} +199 -33
- package/dist/chunk-GSH5APZW.js +39 -0
- package/dist/{chunk-U5Z5Z2BQ.js → chunk-LM4NIYE5.js} +26 -20
- package/dist/{chunk-YVMJ5CZX.js → chunk-SO6HPRJT.js} +10 -23
- package/dist/chunk-U7HM37CB.js +17 -0
- package/dist/client-C-mV_3A0.d.ts +91 -0
- package/dist/index-Bjs3BPPU.d.ts +547 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.js +117 -16
- package/dist/mcp/index.d.ts +6 -5
- package/dist/mcp/index.js +11 -8
- package/dist/middleware-BwAYpBTl.d.ts +15 -0
- package/dist/protocol/index.d.ts +158 -0
- package/dist/protocol/index.js +152 -0
- package/dist/seller/anti-fraud-gateway.d.ts +14 -4
- package/dist/seller/anti-fraud-gateway.js +13 -14
- package/dist/{session-BMNB1N1g.d.ts → session-5TClPLI4.d.ts} +70 -4
- package/dist/verdict-BAahb5po.d.ts +26 -0
- package/dist/x402/express.d.ts +7 -6
- package/dist/x402/express.js +6 -5
- package/dist/x402/hono.d.ts +7 -6
- package/dist/x402/hono.js +6 -5
- package/dist/x402/index.d.ts +95 -19
- package/dist/x402/index.js +83 -32
- package/package.json +5 -1
- package/dist/chunk-5TWO73OD.js +0 -35
- package/dist/client-CVx9LgJC.d.ts +0 -63
- package/dist/middleware-_DSwvNIx.d.ts +0 -40
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { OnReview, PaymentSummary, EvaluateOutput } from './api.js';
|
|
2
|
-
import { a as ApiClient, T as Transport, d as Sessions, A as AgentIdentity, b as ApiClientOptions, g as TransportOptions, R as RedactFn } from './session-BMNB1N1g.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Correlation without binding (Fraud SDK RFC › Protocol Adapter — x402:
|
|
6
|
-
* "binding travels on the call that initiates the purchase, not
|
|
7
|
-
* necessarily on the payment artifact"). The merchant binds a key it will
|
|
8
|
-
* see again (a checkout session id, a challenge nonce) to the buyer's
|
|
9
|
-
* session; the adapter resolves it when the settlement arrives (GAP-31).
|
|
10
|
-
*/
|
|
11
|
-
interface CorrelationStore {
|
|
12
|
-
bind(key: string, sessionId: string, ttlMs?: number): Promise<void>;
|
|
13
|
-
resolve(key: string): Promise<string | null>;
|
|
14
|
-
}
|
|
15
|
-
declare class MemoryCorrelationStore implements CorrelationStore {
|
|
16
|
-
private readonly defaultTtlMs;
|
|
17
|
-
private readonly entries;
|
|
18
|
-
constructor(defaultTtlMs?: number);
|
|
19
|
-
bind(key: string, sessionId: string, ttlMs?: number): Promise<void>;
|
|
20
|
-
resolve(key: string): Promise<string | null>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* One SDK, two halves (Fraud SDK RFC › Summary). `Beltic` is the single
|
|
25
|
-
* client: sessions and evidence for both halves, `evaluate` for the seller
|
|
26
|
-
* half. Protocol integrations are plain functions behind subpath exports,
|
|
27
|
-
* each pulling exactly one optional peer:
|
|
28
|
-
*
|
|
29
|
-
* @belticlabs/agent-risk-sdk/ai → middleware(session), wrapTools(session, …)
|
|
30
|
-
* @belticlabs/agent-risk-sdk/x402 → belticFetch(session), attachX402(beltic, …)
|
|
31
|
-
* @belticlabs/agent-risk-sdk/hono → belticPaymentMiddleware(beltic, …) (and /express)
|
|
32
|
-
* @belticlabs/agent-risk-sdk/mcp → wrapClient(session, …), wrapServer(beltic, …)
|
|
33
|
-
*
|
|
34
|
-
* Neither half decides risk locally: verdicts are platform-side.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
declare const SDK_VERSION = "0.1.0";
|
|
38
|
-
interface BelticOptions extends Omit<ApiClientOptions, 'userAgent'> {
|
|
39
|
-
/** Buyer half. Without it, `sessions.start` is unavailable; the seller half works. */
|
|
40
|
-
identity?: AgentIdentity | undefined;
|
|
41
|
-
transport?: Partial<TransportOptions> | undefined;
|
|
42
|
-
/** What a synchronous seller hook does with REVIEW (GAP-52). */
|
|
43
|
-
onReview?: OnReview | undefined;
|
|
44
|
-
correlation?: CorrelationStore | undefined;
|
|
45
|
-
redact?: RedactFn | undefined;
|
|
46
|
-
now?: (() => Date) | undefined;
|
|
47
|
-
}
|
|
48
|
-
declare class Beltic {
|
|
49
|
-
readonly api: ApiClient;
|
|
50
|
-
readonly transport: Transport;
|
|
51
|
-
readonly sessions: Sessions;
|
|
52
|
-
readonly identity: AgentIdentity | undefined;
|
|
53
|
-
readonly correlation: CorrelationStore;
|
|
54
|
-
readonly onReview: OnReview;
|
|
55
|
-
constructor(opts: BelticOptions);
|
|
56
|
-
/** Read-your-writes: the platform must hold the evidence before it judges it (GAP-16). */
|
|
57
|
-
evaluate(sessionId: string, payment: PaymentSummary): Promise<EvaluateOutput>;
|
|
58
|
-
flush(): Promise<void>;
|
|
59
|
-
shutdown(): Promise<void>;
|
|
60
|
-
}
|
|
61
|
-
declare function createBeltic(opts: BelticOptions): Beltic;
|
|
62
|
-
|
|
63
|
-
export { Beltic as B, type CorrelationStore as C, MemoryCorrelationStore as M, SDK_VERSION as S, type BelticOptions as a, createBeltic as c };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { x402ResourceServer, x402HTTPResourceServer, PaywallConfig, RoutesConfig } from '@x402/core/server';
|
|
2
|
-
import { B as Beltic } from './client-CVx9LgJC.js';
|
|
3
|
-
import { Decision } from './api.js';
|
|
4
|
-
import { c as SessionBorn, S as Session } from './session-BMNB1N1g.js';
|
|
5
|
-
|
|
6
|
-
interface CorrelationContext {
|
|
7
|
-
path: string;
|
|
8
|
-
method: string;
|
|
9
|
-
header: (name: string) => string | undefined;
|
|
10
|
-
}
|
|
11
|
-
interface AttachOptions {
|
|
12
|
-
/** A key the merchant will see again at verify time, for delegated flows (GAP-31). */
|
|
13
|
-
correlate?: ((ctx: CorrelationContext) => string | null) | undefined;
|
|
14
|
-
/** Called with every decision; the default logs nothing. */
|
|
15
|
-
onDecision?: ((d: {
|
|
16
|
-
sessionId: string;
|
|
17
|
-
decision: Decision;
|
|
18
|
-
reasonCodes: string[];
|
|
19
|
-
born: SessionBorn;
|
|
20
|
-
}) => void) | undefined;
|
|
21
|
-
}
|
|
22
|
-
interface AttachedX402 {
|
|
23
|
-
/** Sessions resolved at verify time, keyed by payment digest — for tests and settle hooks. */
|
|
24
|
-
readonly inFlight: ReadonlyMap<string, Session>;
|
|
25
|
-
}
|
|
26
|
-
declare function attachX402(beltic: Beltic, server: x402ResourceServer, http?: x402HTTPResourceServer, opts?: AttachOptions): AttachedX402;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The seller half as one middleware: the framework's `@x402/*` payment
|
|
30
|
-
* middleware over an `x402HTTPResourceServer` with the Beltic hooks
|
|
31
|
-
* attached. `@belticlabs/agent-risk-sdk/hono` and `@belticlabs/agent-risk-sdk/express` differ only in
|
|
32
|
-
* which `paymentMiddlewareFromHTTPServer` they hand in.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
type GuardedMiddlewareOptions = AttachOptions & {
|
|
36
|
-
paywall?: PaywallConfig | undefined;
|
|
37
|
-
};
|
|
38
|
-
declare function guardedPaymentMiddleware<M>(fromHTTPServer: (http: x402HTTPResourceServer, paywall?: PaywallConfig) => M, beltic: Beltic, routes: RoutesConfig, server: x402ResourceServer, opts?: GuardedMiddlewareOptions): M;
|
|
39
|
-
|
|
40
|
-
export { type AttachOptions as A, type CorrelationContext as C, type GuardedMiddlewareOptions as G, attachX402 as a, type AttachedX402 as b, guardedPaymentMiddleware as g };
|