@puga-labs/x402-mantle-sdk 0.3.7 → 0.3.9

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 (49) hide show
  1. package/dist/chunk-33WHNZDS.js +74 -0
  2. package/dist/chunk-B4GST723.js +101 -0
  3. package/dist/chunk-CKBTOS7X.js +86 -0
  4. package/dist/chunk-IEJB5W26.js +113 -0
  5. package/dist/chunk-IXIFGPJ2.js +250 -0
  6. package/dist/chunk-OW2BDRGZ.js +239 -0
  7. package/dist/chunk-T4DIHTBP.js +83 -0
  8. package/dist/chunk-T63MVWX3.js +71 -0
  9. package/dist/express-D8L5Dg1D.d.ts +68 -0
  10. package/dist/express-DqyVgO5n.d.cts +68 -0
  11. package/dist/express-DxxlKmmF.d.ts +68 -0
  12. package/dist/express-Pukmnwuu.d.cts +68 -0
  13. package/dist/index.cjs +39 -12
  14. package/dist/index.d.cts +3 -3
  15. package/dist/index.d.ts +3 -3
  16. package/dist/index.js +2 -2
  17. package/dist/nextjs-CSUWjcxv.d.cts +89 -0
  18. package/dist/nextjs-DGcN_MGa.d.ts +89 -0
  19. package/dist/nextjs-DUdgN0d_.d.ts +89 -0
  20. package/dist/nextjs-EoISXVEo.d.cts +89 -0
  21. package/dist/server-express.cjs +39 -12
  22. package/dist/server-express.d.cts +2 -2
  23. package/dist/server-express.d.ts +2 -2
  24. package/dist/server-express.js +2 -2
  25. package/dist/server-nextjs.cjs +38 -12
  26. package/dist/server-nextjs.d.cts +2 -2
  27. package/dist/server-nextjs.d.ts +2 -2
  28. package/dist/server-nextjs.js +2 -2
  29. package/dist/server-web.cjs +38 -12
  30. package/dist/server-web.d.cts +2 -2
  31. package/dist/server-web.d.ts +2 -2
  32. package/dist/server-web.js +2 -2
  33. package/dist/server.cjs +69 -16
  34. package/dist/server.d.cts +6 -6
  35. package/dist/server.d.ts +6 -6
  36. package/dist/server.js +4 -4
  37. package/dist/types-B87bD2yo.d.cts +102 -0
  38. package/dist/types-BWfKovFm.d.cts +103 -0
  39. package/dist/types-BmK0G74m.d.cts +93 -0
  40. package/dist/types-CXdNC0Ra.d.ts +93 -0
  41. package/dist/types-DgfVPQFb.d.ts +103 -0
  42. package/dist/types-DvKDSdL6.d.ts +106 -0
  43. package/dist/types-X6DeBEgb.d.cts +106 -0
  44. package/dist/types-vicT7qsY.d.ts +102 -0
  45. package/dist/web-standards-BJcdcxD6.d.ts +77 -0
  46. package/dist/web-standards-BvMLEKlU.d.cts +77 -0
  47. package/dist/web-standards-C6JwCDmd.d.cts +77 -0
  48. package/dist/web-standards-g2rYUpgc.d.ts +77 -0
  49. package/package.json +1 -1
@@ -0,0 +1,103 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { N as NetworkId, P as PaymentRequirements } from './types-BFUqKBBO.cjs';
3
+
4
+ /** Unique key for a protected route, e.g. "GET /api/protected". */
5
+ type RouteKey = string;
6
+ /** Pricing config for a single route. */
7
+ interface RoutePricingConfig {
8
+ /** Price in USD cents, e.g. 1 => $0.01. */
9
+ priceUsdCents: number;
10
+ /** Network identifier (e.g. "mantle-mainnet"). */
11
+ network: NetworkId;
12
+ }
13
+ /** Map of route keys to pricing config. */
14
+ type RoutesConfig = Record<RouteKey, RoutePricingConfig>;
15
+ /** Log entry for a successfully settled payment. */
16
+ interface PaymentLogEntry {
17
+ id: string;
18
+ from: string;
19
+ to: string;
20
+ valueAtomic: string;
21
+ network: NetworkId;
22
+ asset: string;
23
+ route?: RouteKey;
24
+ txHash?: string;
25
+ timestamp: number;
26
+ facilitatorUrl?: string;
27
+ paymentRequirements?: PaymentRequirements;
28
+ }
29
+ /** Config for optional telemetry (billing/analytics). */
30
+ interface TelemetryConfig {
31
+ /** Project key from nosubs.ai dashboard. */
32
+ projectKey: string;
33
+ /**
34
+ * Telemetry endpoint URL.
35
+ * If not specified, uses DEFAULT_TELEMETRY_ENDPOINT (see server/constants.ts).
36
+ * If both are undefined, telemetry is not sent.
37
+ */
38
+ endpoint?: string;
39
+ }
40
+ /** Telemetry event payload for payment_verified. */
41
+ interface TelemetryEvent {
42
+ event: "payment_verified";
43
+ ts: number;
44
+ projectKey: string;
45
+ network: string;
46
+ buyer: string;
47
+ payTo: string;
48
+ amountAtomic: string;
49
+ asset: string;
50
+ decimals: number;
51
+ nonce: string;
52
+ route: string;
53
+ facilitatorType: "hosted" | "self-hosted";
54
+ facilitatorUrl?: string;
55
+ facilitatorAddress?: string;
56
+ txHash?: string;
57
+ priceUsd?: string;
58
+ }
59
+ /** Config for createPaymentMiddleware. */
60
+ interface PaymentMiddlewareConfig {
61
+ /** Base URL of facilitator, e.g. https://facilitator.nosubs.ai */
62
+ facilitatorUrl: string;
63
+ /** Recipient address (developer). Validated at runtime. */
64
+ receiverAddress: string;
65
+ /** Map of protected routes and their pricing. */
66
+ routes: RoutesConfig;
67
+ /**
68
+ * Optional hook called whenever a payment is successfully settled.
69
+ * You can use this to push logs into your DB / analytics pipeline.
70
+ */
71
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
72
+ /** Optional: Send usage telemetry for billing/analytics. */
73
+ telemetry?: TelemetryConfig;
74
+ }
75
+ /**
76
+ * Minimal config for mantlePaywall() - simplified API for single-route protection.
77
+ * This is the "sweet path" for Mantle mainnet + USDC with sensible defaults.
78
+ */
79
+ interface MinimalPaywallOptions {
80
+ /** Price in USD (e.g. 0.01 for 1 cent). */
81
+ priceUsd: number;
82
+ /** Recipient address (developer wallet). Validated at runtime. */
83
+ payTo: string;
84
+ /** Optional facilitator URL (defaults to localhost:8080 or NEXT_PUBLIC_FACILITATOR_URL). */
85
+ facilitatorUrl?: string;
86
+ /**
87
+ * Optional API key for hosted facilitator billing.
88
+ * Required when using hosted facilitator (e.g., https://facilitator.x402mantlesdk.xyz).
89
+ * Not needed for self-hosted facilitator.
90
+ */
91
+ apiKey?: string;
92
+ /** Optional telemetry config. */
93
+ telemetry?: TelemetryConfig;
94
+ /** Optional payment settled hook. */
95
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
96
+ }
97
+ /**
98
+ * Express middleware function type for Mantle paywall.
99
+ * Async function that returns Promise<void>.
100
+ */
101
+ type MantleMiddleware = (req: Request, res: Response, next: NextFunction) => Promise<void>;
102
+
103
+ export type { MantleMiddleware as M, PaymentLogEntry as P, RouteKey as R, TelemetryConfig as T, RoutePricingConfig as a, RoutesConfig as b, TelemetryEvent as c, PaymentMiddlewareConfig as d, MinimalPaywallOptions as e };
@@ -0,0 +1,93 @@
1
+ import { N as NetworkId, P as PaymentRequirements } from './types-BFUqKBBO.cjs';
2
+
3
+ /** Unique key for a protected route, e.g. "GET /api/protected". */
4
+ type RouteKey = string;
5
+ /** Pricing config for a single route. */
6
+ interface RoutePricingConfig {
7
+ /** Price in USD cents, e.g. 1 => $0.01. */
8
+ priceUsdCents: number;
9
+ /** Network identifier (e.g. "mantle-mainnet"). */
10
+ network: NetworkId;
11
+ }
12
+ /** Map of route keys to pricing config. */
13
+ type RoutesConfig = Record<RouteKey, RoutePricingConfig>;
14
+ /** Log entry for a successfully settled payment. */
15
+ interface PaymentLogEntry {
16
+ id: string;
17
+ from: string;
18
+ to: string;
19
+ valueAtomic: string;
20
+ network: NetworkId;
21
+ asset: string;
22
+ route?: RouteKey;
23
+ txHash?: string;
24
+ timestamp: number;
25
+ facilitatorUrl?: string;
26
+ paymentRequirements?: PaymentRequirements;
27
+ }
28
+ /** Config for optional telemetry (billing/analytics). */
29
+ interface TelemetryConfig {
30
+ /** Project key from nosubs.ai dashboard. */
31
+ projectKey: string;
32
+ /**
33
+ * Telemetry endpoint URL.
34
+ * If not specified, uses DEFAULT_TELEMETRY_ENDPOINT (see server/constants.ts).
35
+ */
36
+ endpoint?: string;
37
+ }
38
+ /**
39
+ * Minimal config for mantlePaywall() - simplified API for single-route protection.
40
+ * This is the "sweet path" for Mantle mainnet + USDC with sensible defaults.
41
+ */
42
+ interface MinimalPaywallOptions {
43
+ /** Price in USD (e.g. 0.01 for 1 cent). */
44
+ priceUsd: number;
45
+ /** Recipient address (developer wallet). Validated at runtime. */
46
+ payTo: string;
47
+ /** Optional facilitator URL (defaults to localhost:8080 or NEXT_PUBLIC_FACILITATOR_URL). */
48
+ facilitatorUrl?: string;
49
+ /**
50
+ * Optional API key for hosted facilitator billing.
51
+ * Required when using hosted facilitator (e.g., https://facilitator.x402mantlesdk.xyz).
52
+ * Not needed for self-hosted facilitator.
53
+ */
54
+ apiKey?: string;
55
+ /** Optional telemetry config. */
56
+ telemetry?: TelemetryConfig;
57
+ /** Optional payment settled hook. */
58
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
59
+ }
60
+ /** Input for checkPayment function. */
61
+ interface PaymentCheckInput {
62
+ /** X-PAYMENT header value (base64 encoded), or null if not present. */
63
+ paymentHeader: string | null;
64
+ /** Payment requirements for this route. */
65
+ paymentRequirements: PaymentRequirements;
66
+ /** Facilitator URL for verification. */
67
+ facilitatorUrl: string;
68
+ /** Optional API key for hosted facilitator billing. */
69
+ apiKey?: string;
70
+ /** Route key for logging, e.g. "POST /api/generate-image". */
71
+ routeKey?: RouteKey;
72
+ /** Network ID for this payment. */
73
+ network: NetworkId;
74
+ /** Asset address (ERC-20 token). */
75
+ asset: string;
76
+ /** Telemetry config (optional). */
77
+ telemetry?: TelemetryConfig;
78
+ /** Payment settled callback (optional). */
79
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
80
+ }
81
+ /** Result from checkPayment function. */
82
+ interface PaymentCheckResult {
83
+ /** Status of the payment check. */
84
+ status: "require_payment" | "verification_error" | "invalid_payment" | "verified";
85
+ /** HTTP status code to return. */
86
+ statusCode: 402 | 500 | 200;
87
+ /** Response body to return (null if verified). */
88
+ responseBody: any | null;
89
+ /** Whether payment is valid (only true if status is "verified"). */
90
+ isValid: boolean;
91
+ }
92
+
93
+ export type { MinimalPaywallOptions as M, PaymentLogEntry as P, RouteKey as R, TelemetryConfig as T, RoutePricingConfig as a, RoutesConfig as b, PaymentCheckInput as c, PaymentCheckResult as d };
@@ -0,0 +1,93 @@
1
+ import { N as NetworkId, P as PaymentRequirements } from './types-BFUqKBBO.js';
2
+
3
+ /** Unique key for a protected route, e.g. "GET /api/protected". */
4
+ type RouteKey = string;
5
+ /** Pricing config for a single route. */
6
+ interface RoutePricingConfig {
7
+ /** Price in USD cents, e.g. 1 => $0.01. */
8
+ priceUsdCents: number;
9
+ /** Network identifier (e.g. "mantle-mainnet"). */
10
+ network: NetworkId;
11
+ }
12
+ /** Map of route keys to pricing config. */
13
+ type RoutesConfig = Record<RouteKey, RoutePricingConfig>;
14
+ /** Log entry for a successfully settled payment. */
15
+ interface PaymentLogEntry {
16
+ id: string;
17
+ from: string;
18
+ to: string;
19
+ valueAtomic: string;
20
+ network: NetworkId;
21
+ asset: string;
22
+ route?: RouteKey;
23
+ txHash?: string;
24
+ timestamp: number;
25
+ facilitatorUrl?: string;
26
+ paymentRequirements?: PaymentRequirements;
27
+ }
28
+ /** Config for optional telemetry (billing/analytics). */
29
+ interface TelemetryConfig {
30
+ /** Project key from nosubs.ai dashboard. */
31
+ projectKey: string;
32
+ /**
33
+ * Telemetry endpoint URL.
34
+ * If not specified, uses DEFAULT_TELEMETRY_ENDPOINT (see server/constants.ts).
35
+ */
36
+ endpoint?: string;
37
+ }
38
+ /**
39
+ * Minimal config for mantlePaywall() - simplified API for single-route protection.
40
+ * This is the "sweet path" for Mantle mainnet + USDC with sensible defaults.
41
+ */
42
+ interface MinimalPaywallOptions {
43
+ /** Price in USD (e.g. 0.01 for 1 cent). */
44
+ priceUsd: number;
45
+ /** Recipient address (developer wallet). Validated at runtime. */
46
+ payTo: string;
47
+ /** Optional facilitator URL (defaults to localhost:8080 or NEXT_PUBLIC_FACILITATOR_URL). */
48
+ facilitatorUrl?: string;
49
+ /**
50
+ * Optional API key for hosted facilitator billing.
51
+ * Required when using hosted facilitator (e.g., https://facilitator.x402mantlesdk.xyz).
52
+ * Not needed for self-hosted facilitator.
53
+ */
54
+ apiKey?: string;
55
+ /** Optional telemetry config. */
56
+ telemetry?: TelemetryConfig;
57
+ /** Optional payment settled hook. */
58
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
59
+ }
60
+ /** Input for checkPayment function. */
61
+ interface PaymentCheckInput {
62
+ /** X-PAYMENT header value (base64 encoded), or null if not present. */
63
+ paymentHeader: string | null;
64
+ /** Payment requirements for this route. */
65
+ paymentRequirements: PaymentRequirements;
66
+ /** Facilitator URL for verification. */
67
+ facilitatorUrl: string;
68
+ /** Optional API key for hosted facilitator billing. */
69
+ apiKey?: string;
70
+ /** Route key for logging, e.g. "POST /api/generate-image". */
71
+ routeKey?: RouteKey;
72
+ /** Network ID for this payment. */
73
+ network: NetworkId;
74
+ /** Asset address (ERC-20 token). */
75
+ asset: string;
76
+ /** Telemetry config (optional). */
77
+ telemetry?: TelemetryConfig;
78
+ /** Payment settled callback (optional). */
79
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
80
+ }
81
+ /** Result from checkPayment function. */
82
+ interface PaymentCheckResult {
83
+ /** Status of the payment check. */
84
+ status: "require_payment" | "verification_error" | "invalid_payment" | "verified";
85
+ /** HTTP status code to return. */
86
+ statusCode: 402 | 500 | 200;
87
+ /** Response body to return (null if verified). */
88
+ responseBody: any | null;
89
+ /** Whether payment is valid (only true if status is "verified"). */
90
+ isValid: boolean;
91
+ }
92
+
93
+ export type { MinimalPaywallOptions as M, PaymentLogEntry as P, RouteKey as R, TelemetryConfig as T, RoutePricingConfig as a, RoutesConfig as b, PaymentCheckInput as c, PaymentCheckResult as d };
@@ -0,0 +1,103 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { N as NetworkId, P as PaymentRequirements } from './types-BFUqKBBO.js';
3
+
4
+ /** Unique key for a protected route, e.g. "GET /api/protected". */
5
+ type RouteKey = string;
6
+ /** Pricing config for a single route. */
7
+ interface RoutePricingConfig {
8
+ /** Price in USD cents, e.g. 1 => $0.01. */
9
+ priceUsdCents: number;
10
+ /** Network identifier (e.g. "mantle-mainnet"). */
11
+ network: NetworkId;
12
+ }
13
+ /** Map of route keys to pricing config. */
14
+ type RoutesConfig = Record<RouteKey, RoutePricingConfig>;
15
+ /** Log entry for a successfully settled payment. */
16
+ interface PaymentLogEntry {
17
+ id: string;
18
+ from: string;
19
+ to: string;
20
+ valueAtomic: string;
21
+ network: NetworkId;
22
+ asset: string;
23
+ route?: RouteKey;
24
+ txHash?: string;
25
+ timestamp: number;
26
+ facilitatorUrl?: string;
27
+ paymentRequirements?: PaymentRequirements;
28
+ }
29
+ /** Config for optional telemetry (billing/analytics). */
30
+ interface TelemetryConfig {
31
+ /** Project key from nosubs.ai dashboard. */
32
+ projectKey: string;
33
+ /**
34
+ * Telemetry endpoint URL.
35
+ * If not specified, uses DEFAULT_TELEMETRY_ENDPOINT (see server/constants.ts).
36
+ * If both are undefined, telemetry is not sent.
37
+ */
38
+ endpoint?: string;
39
+ }
40
+ /** Telemetry event payload for payment_verified. */
41
+ interface TelemetryEvent {
42
+ event: "payment_verified";
43
+ ts: number;
44
+ projectKey: string;
45
+ network: string;
46
+ buyer: string;
47
+ payTo: string;
48
+ amountAtomic: string;
49
+ asset: string;
50
+ decimals: number;
51
+ nonce: string;
52
+ route: string;
53
+ facilitatorType: "hosted" | "self-hosted";
54
+ facilitatorUrl?: string;
55
+ facilitatorAddress?: string;
56
+ txHash?: string;
57
+ priceUsd?: string;
58
+ }
59
+ /** Config for createPaymentMiddleware. */
60
+ interface PaymentMiddlewareConfig {
61
+ /** Base URL of facilitator, e.g. https://facilitator.nosubs.ai */
62
+ facilitatorUrl: string;
63
+ /** Recipient address (developer). Validated at runtime. */
64
+ receiverAddress: string;
65
+ /** Map of protected routes and their pricing. */
66
+ routes: RoutesConfig;
67
+ /**
68
+ * Optional hook called whenever a payment is successfully settled.
69
+ * You can use this to push logs into your DB / analytics pipeline.
70
+ */
71
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
72
+ /** Optional: Send usage telemetry for billing/analytics. */
73
+ telemetry?: TelemetryConfig;
74
+ }
75
+ /**
76
+ * Minimal config for mantlePaywall() - simplified API for single-route protection.
77
+ * This is the "sweet path" for Mantle mainnet + USDC with sensible defaults.
78
+ */
79
+ interface MinimalPaywallOptions {
80
+ /** Price in USD (e.g. 0.01 for 1 cent). */
81
+ priceUsd: number;
82
+ /** Recipient address (developer wallet). Validated at runtime. */
83
+ payTo: string;
84
+ /** Optional facilitator URL (defaults to localhost:8080 or NEXT_PUBLIC_FACILITATOR_URL). */
85
+ facilitatorUrl?: string;
86
+ /**
87
+ * Optional API key for hosted facilitator billing.
88
+ * Required when using hosted facilitator (e.g., https://facilitator.x402mantlesdk.xyz).
89
+ * Not needed for self-hosted facilitator.
90
+ */
91
+ apiKey?: string;
92
+ /** Optional telemetry config. */
93
+ telemetry?: TelemetryConfig;
94
+ /** Optional payment settled hook. */
95
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
96
+ }
97
+ /**
98
+ * Express middleware function type for Mantle paywall.
99
+ * Async function that returns Promise<void>.
100
+ */
101
+ type MantleMiddleware = (req: Request, res: Response, next: NextFunction) => Promise<void>;
102
+
103
+ export type { MantleMiddleware as M, PaymentLogEntry as P, RouteKey as R, TelemetryConfig as T, RoutePricingConfig as a, RoutesConfig as b, TelemetryEvent as c, PaymentMiddlewareConfig as d, MinimalPaywallOptions as e };
@@ -0,0 +1,106 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { N as NetworkId, P as PaymentRequirements } from './types-BFUqKBBO.js';
3
+
4
+ /** Unique key for a protected route, e.g. "GET /api/protected". */
5
+ type RouteKey = string;
6
+ /** Pricing config for a single route. */
7
+ interface RoutePricingConfig {
8
+ /** Price in USD cents, e.g. 1 => $0.01. */
9
+ priceUsdCents: number;
10
+ /** Network identifier (e.g. "mantle-mainnet"). */
11
+ network: NetworkId;
12
+ }
13
+ /** Map of route keys to pricing config. */
14
+ type RoutesConfig = Record<RouteKey, RoutePricingConfig>;
15
+ /** Log entry for a successfully settled payment. */
16
+ interface PaymentLogEntry {
17
+ id: string;
18
+ from: string;
19
+ to: string;
20
+ valueAtomic: string;
21
+ network: NetworkId;
22
+ asset: string;
23
+ route?: RouteKey;
24
+ txHash?: string;
25
+ timestamp: number;
26
+ facilitatorUrl?: string;
27
+ paymentRequirements?: PaymentRequirements;
28
+ }
29
+ /** Config for optional telemetry (billing/analytics). */
30
+ interface TelemetryConfig {
31
+ /** Project key from nosubs.ai dashboard. */
32
+ projectKey: string;
33
+ /**
34
+ * Telemetry endpoint URL.
35
+ * If not specified, uses DEFAULT_TELEMETRY_ENDPOINT (see server/constants.ts).
36
+ * If both are undefined, telemetry is not sent.
37
+ */
38
+ endpoint?: string;
39
+ }
40
+ /** Telemetry event payload for payment_verified. */
41
+ interface TelemetryEvent {
42
+ event: "payment_verified";
43
+ ts: number;
44
+ projectKey: string;
45
+ network: string;
46
+ buyer: string;
47
+ payTo: string;
48
+ amountAtomic: string;
49
+ asset: string;
50
+ decimals: number;
51
+ nonce: string;
52
+ route: string;
53
+ facilitatorType: "hosted" | "self-hosted";
54
+ facilitatorUrl?: string;
55
+ facilitatorAddress?: string;
56
+ txHash?: string;
57
+ priceUsd?: string;
58
+ responseStatus?: number;
59
+ errorMessage?: string;
60
+ serviceDelivered?: boolean;
61
+ }
62
+ /** Config for createPaymentMiddleware. */
63
+ interface PaymentMiddlewareConfig {
64
+ /** Base URL of facilitator, e.g. https://facilitator.nosubs.ai */
65
+ facilitatorUrl: string;
66
+ /** Recipient address (developer). Validated at runtime. */
67
+ receiverAddress: string;
68
+ /** Map of protected routes and their pricing. */
69
+ routes: RoutesConfig;
70
+ /**
71
+ * Optional hook called whenever a payment is successfully settled.
72
+ * You can use this to push logs into your DB / analytics pipeline.
73
+ */
74
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
75
+ /** Optional: Send usage telemetry for billing/analytics. */
76
+ telemetry?: TelemetryConfig;
77
+ }
78
+ /**
79
+ * Minimal config for mantlePaywall() - simplified API for single-route protection.
80
+ * This is the "sweet path" for Mantle mainnet + USDC with sensible defaults.
81
+ */
82
+ interface MinimalPaywallOptions {
83
+ /** Price in USD (e.g. 0.01 for 1 cent). */
84
+ priceUsd: number;
85
+ /** Recipient address (developer wallet). Validated at runtime. */
86
+ payTo: string;
87
+ /** Optional facilitator URL (defaults to localhost:8080 or NEXT_PUBLIC_FACILITATOR_URL). */
88
+ facilitatorUrl?: string;
89
+ /**
90
+ * Optional API key for hosted facilitator billing.
91
+ * Required when using hosted facilitator (e.g., https://facilitator.x402mantlesdk.xyz).
92
+ * Not needed for self-hosted facilitator.
93
+ */
94
+ apiKey?: string;
95
+ /** Optional telemetry config. */
96
+ telemetry?: TelemetryConfig;
97
+ /** Optional payment settled hook. */
98
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
99
+ }
100
+ /**
101
+ * Express middleware function type for Mantle paywall.
102
+ * Async function that returns Promise<void>.
103
+ */
104
+ type MantleMiddleware = (req: Request, res: Response, next: NextFunction) => Promise<void>;
105
+
106
+ export type { MantleMiddleware as M, PaymentLogEntry as P, RouteKey as R, TelemetryConfig as T, RoutePricingConfig as a, RoutesConfig as b, TelemetryEvent as c, PaymentMiddlewareConfig as d, MinimalPaywallOptions as e };
@@ -0,0 +1,106 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { N as NetworkId, P as PaymentRequirements } from './types-BFUqKBBO.cjs';
3
+
4
+ /** Unique key for a protected route, e.g. "GET /api/protected". */
5
+ type RouteKey = string;
6
+ /** Pricing config for a single route. */
7
+ interface RoutePricingConfig {
8
+ /** Price in USD cents, e.g. 1 => $0.01. */
9
+ priceUsdCents: number;
10
+ /** Network identifier (e.g. "mantle-mainnet"). */
11
+ network: NetworkId;
12
+ }
13
+ /** Map of route keys to pricing config. */
14
+ type RoutesConfig = Record<RouteKey, RoutePricingConfig>;
15
+ /** Log entry for a successfully settled payment. */
16
+ interface PaymentLogEntry {
17
+ id: string;
18
+ from: string;
19
+ to: string;
20
+ valueAtomic: string;
21
+ network: NetworkId;
22
+ asset: string;
23
+ route?: RouteKey;
24
+ txHash?: string;
25
+ timestamp: number;
26
+ facilitatorUrl?: string;
27
+ paymentRequirements?: PaymentRequirements;
28
+ }
29
+ /** Config for optional telemetry (billing/analytics). */
30
+ interface TelemetryConfig {
31
+ /** Project key from nosubs.ai dashboard. */
32
+ projectKey: string;
33
+ /**
34
+ * Telemetry endpoint URL.
35
+ * If not specified, uses DEFAULT_TELEMETRY_ENDPOINT (see server/constants.ts).
36
+ * If both are undefined, telemetry is not sent.
37
+ */
38
+ endpoint?: string;
39
+ }
40
+ /** Telemetry event payload for payment_verified. */
41
+ interface TelemetryEvent {
42
+ event: "payment_verified";
43
+ ts: number;
44
+ projectKey: string;
45
+ network: string;
46
+ buyer: string;
47
+ payTo: string;
48
+ amountAtomic: string;
49
+ asset: string;
50
+ decimals: number;
51
+ nonce: string;
52
+ route: string;
53
+ facilitatorType: "hosted" | "self-hosted";
54
+ facilitatorUrl?: string;
55
+ facilitatorAddress?: string;
56
+ txHash?: string;
57
+ priceUsd?: string;
58
+ responseStatus?: number;
59
+ errorMessage?: string;
60
+ serviceDelivered?: boolean;
61
+ }
62
+ /** Config for createPaymentMiddleware. */
63
+ interface PaymentMiddlewareConfig {
64
+ /** Base URL of facilitator, e.g. https://facilitator.nosubs.ai */
65
+ facilitatorUrl: string;
66
+ /** Recipient address (developer). Validated at runtime. */
67
+ receiverAddress: string;
68
+ /** Map of protected routes and their pricing. */
69
+ routes: RoutesConfig;
70
+ /**
71
+ * Optional hook called whenever a payment is successfully settled.
72
+ * You can use this to push logs into your DB / analytics pipeline.
73
+ */
74
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
75
+ /** Optional: Send usage telemetry for billing/analytics. */
76
+ telemetry?: TelemetryConfig;
77
+ }
78
+ /**
79
+ * Minimal config for mantlePaywall() - simplified API for single-route protection.
80
+ * This is the "sweet path" for Mantle mainnet + USDC with sensible defaults.
81
+ */
82
+ interface MinimalPaywallOptions {
83
+ /** Price in USD (e.g. 0.01 for 1 cent). */
84
+ priceUsd: number;
85
+ /** Recipient address (developer wallet). Validated at runtime. */
86
+ payTo: string;
87
+ /** Optional facilitator URL (defaults to localhost:8080 or NEXT_PUBLIC_FACILITATOR_URL). */
88
+ facilitatorUrl?: string;
89
+ /**
90
+ * Optional API key for hosted facilitator billing.
91
+ * Required when using hosted facilitator (e.g., https://facilitator.x402mantlesdk.xyz).
92
+ * Not needed for self-hosted facilitator.
93
+ */
94
+ apiKey?: string;
95
+ /** Optional telemetry config. */
96
+ telemetry?: TelemetryConfig;
97
+ /** Optional payment settled hook. */
98
+ onPaymentSettled?: (entry: PaymentLogEntry) => void;
99
+ }
100
+ /**
101
+ * Express middleware function type for Mantle paywall.
102
+ * Async function that returns Promise<void>.
103
+ */
104
+ type MantleMiddleware = (req: Request, res: Response, next: NextFunction) => Promise<void>;
105
+
106
+ export type { MantleMiddleware as M, PaymentLogEntry as P, RouteKey as R, TelemetryConfig as T, RoutePricingConfig as a, RoutesConfig as b, TelemetryEvent as c, PaymentMiddlewareConfig as d, MinimalPaywallOptions as e };