@pincerpay/core 0.1.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/LICENSE +21 -0
- package/README.md +157 -0
- package/dist/chains/index.d.ts +25 -0
- package/dist/chains/index.d.ts.map +1 -0
- package/dist/chains/index.js +121 -0
- package/dist/chains/index.js.map +1 -0
- package/dist/constants.d.ts +32 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +32 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +246 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PincerPay
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# @pincerpay/core
|
|
2
|
+
|
|
3
|
+
Shared types, chain configurations, and constants for the PincerPay ecosystem.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @pincerpay/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { resolveChain, toCAIP2, DEFAULT_FACILITATOR_URL } from "@pincerpay/core";
|
|
15
|
+
import type { ChainConfig, TransactionStatus } from "@pincerpay/core/types";
|
|
16
|
+
|
|
17
|
+
const chain = resolveChain("solana");
|
|
18
|
+
// { caip2Id: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", name: "Solana Devnet", ... }
|
|
19
|
+
|
|
20
|
+
const caip2 = toCAIP2("base");
|
|
21
|
+
// "eip155:8453"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API Reference
|
|
25
|
+
|
|
26
|
+
### Chain Resolution
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
function resolveChain(input: string): ChainConfig | undefined;
|
|
30
|
+
function toCAIP2(shorthand: string): string;
|
|
31
|
+
function getMainnetChains(): ChainConfig[];
|
|
32
|
+
function getTestnetChains(): ChainConfig[];
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Chain Config
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
interface ChainConfig {
|
|
39
|
+
caip2Id: string; // CAIP-2 identifier
|
|
40
|
+
shorthand: string; // "solana", "base", "polygon"
|
|
41
|
+
name: string; // Display name
|
|
42
|
+
namespace: "eip155" | "solana";
|
|
43
|
+
chainId?: number; // EVM only
|
|
44
|
+
usdcAddress: string; // USDC token address
|
|
45
|
+
usdcDecimals: number; // Always 6
|
|
46
|
+
rpcUrl: string; // Default public RPC
|
|
47
|
+
testnet: boolean;
|
|
48
|
+
explorerUrl: string;
|
|
49
|
+
blockTimeMs: number;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Constants
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const DEFAULT_FACILITATOR_URL = "https://facilitator.pincerpay.com";
|
|
57
|
+
const API_VERSION = "v1";
|
|
58
|
+
const USDC_DECIMALS = 6;
|
|
59
|
+
const OPTIMISTIC_THRESHOLD = "1000000"; // 1 USDC
|
|
60
|
+
const API_KEY_HEADER = "x-pincerpay-api-key";
|
|
61
|
+
|
|
62
|
+
const FACILITATOR_ROUTES = {
|
|
63
|
+
verify: "/v1/verify",
|
|
64
|
+
settle: "/v1/settle",
|
|
65
|
+
status: "/v1/status",
|
|
66
|
+
supported: "/v1/supported",
|
|
67
|
+
health: "/health",
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Key Types
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
type ChainNamespace = "eip155" | "solana";
|
|
75
|
+
type TransactionStatus = "pending" | "mempool" | "optimistic" | "confirmed" | "failed";
|
|
76
|
+
type SettlementType = "x402" | "direct";
|
|
77
|
+
type AgentStatus = "active" | "paused" | "revoked";
|
|
78
|
+
|
|
79
|
+
interface PincerPayConfig {
|
|
80
|
+
apiKey: string;
|
|
81
|
+
merchantAddress: string;
|
|
82
|
+
facilitatorUrl?: string;
|
|
83
|
+
routes: Record<string, RoutePaywallConfig>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface AgentConfig {
|
|
87
|
+
chains: string[];
|
|
88
|
+
evmPrivateKey?: string;
|
|
89
|
+
solanaPrivateKey?: string;
|
|
90
|
+
policies?: SpendingPolicy[];
|
|
91
|
+
facilitatorUrl?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface SpendingPolicy {
|
|
95
|
+
maxPerTransaction?: string;
|
|
96
|
+
maxPerDay?: string;
|
|
97
|
+
allowedMerchants?: string[];
|
|
98
|
+
allowedChains?: string[];
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Supported Chains
|
|
103
|
+
|
|
104
|
+
| Chain | CAIP-2 ID | Shorthand | Testnet |
|
|
105
|
+
|---|---|---|---|
|
|
106
|
+
| Base | `eip155:8453` | `base` | No |
|
|
107
|
+
| Base Sepolia | `eip155:84532` | `base-sepolia` | Yes |
|
|
108
|
+
| Polygon | `eip155:137` | `polygon` | No |
|
|
109
|
+
| Polygon Amoy | `eip155:80002` | `polygon-amoy` | Yes |
|
|
110
|
+
| Solana | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | `solana` | No |
|
|
111
|
+
| Solana Devnet | `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1` | `solana-devnet` | Yes |
|
|
112
|
+
|
|
113
|
+
## Common Patterns
|
|
114
|
+
|
|
115
|
+
### Resolve chain by shorthand or CAIP-2 ID
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { resolveChain } from "@pincerpay/core";
|
|
119
|
+
|
|
120
|
+
resolveChain("solana"); // by shorthand
|
|
121
|
+
resolveChain("eip155:8453"); // by CAIP-2 ID
|
|
122
|
+
resolveChain("solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"); // by full CAIP-2
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Type-safe transaction handling
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import type { TransactionStatus } from "@pincerpay/core/types";
|
|
129
|
+
|
|
130
|
+
function handleStatus(status: TransactionStatus) {
|
|
131
|
+
switch (status) {
|
|
132
|
+
case "optimistic": return "Payment accepted (fast)";
|
|
133
|
+
case "confirmed": return "Payment confirmed on-chain";
|
|
134
|
+
case "failed": return "Payment failed";
|
|
135
|
+
default: return "Processing...";
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Anti-Patterns
|
|
141
|
+
|
|
142
|
+
### Don't hardcode CAIP-2 IDs
|
|
143
|
+
|
|
144
|
+
Use `toCAIP2()` or `resolveChain()` instead of hardcoding chain identifiers.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
// Bad
|
|
148
|
+
const network = "eip155:8453";
|
|
149
|
+
|
|
150
|
+
// Good
|
|
151
|
+
import { toCAIP2 } from "@pincerpay/core";
|
|
152
|
+
const network = toCAIP2("base");
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Don't assume USDC decimals
|
|
156
|
+
|
|
157
|
+
Always use `USDC_DECIMALS` or `chain.usdcDecimals` instead of hardcoding `6`.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ChainConfig } from "../types/index.js";
|
|
2
|
+
export declare const BASE_MAINNET: ChainConfig;
|
|
3
|
+
export declare const POLYGON_MAINNET: ChainConfig;
|
|
4
|
+
export declare const SOLANA_MAINNET: ChainConfig;
|
|
5
|
+
export declare const BASE_SEPOLIA: ChainConfig;
|
|
6
|
+
export declare const POLYGON_AMOY: ChainConfig;
|
|
7
|
+
export declare const SOLANA_DEVNET: ChainConfig;
|
|
8
|
+
export declare const CHAINS: Record<string, ChainConfig>;
|
|
9
|
+
/** Reverse lookup: CAIP-2 ID → ChainConfig */
|
|
10
|
+
export declare const CHAINS_BY_CAIP2: Record<string, ChainConfig>;
|
|
11
|
+
/**
|
|
12
|
+
* Resolve a chain shorthand (e.g., "base") or CAIP-2 ID (e.g., "eip155:8453")
|
|
13
|
+
* to a ChainConfig. Returns undefined if not found.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveChain(input: string): ChainConfig | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a chain shorthand to its CAIP-2 ID.
|
|
18
|
+
* Throws if the chain is not recognized.
|
|
19
|
+
*/
|
|
20
|
+
export declare function toCAIP2(shorthand: string): string;
|
|
21
|
+
/** Get all supported mainnet chain configs */
|
|
22
|
+
export declare function getMainnetChains(): ChainConfig[];
|
|
23
|
+
/** Get all supported testnet chain configs */
|
|
24
|
+
export declare function getTestnetChains(): ChainConfig[];
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chains/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,eAAO,MAAM,YAAY,EAAE,WAa1B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,WAa7B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,WAY5B,CAAC;AAIF,eAAO,MAAM,YAAY,EAAE,WAY1B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,WAY1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,WAW3B,CAAC;AAIF,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAS9C,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAEvD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEnE;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED,8CAA8C;AAC9C,wBAAgB,gBAAgB,IAAI,WAAW,EAAE,CAEhD;AAED,8CAA8C;AAC9C,wBAAgB,gBAAgB,IAAI,WAAW,EAAE,CAEhD"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// ─── Mainnet Chains ───
|
|
2
|
+
export const BASE_MAINNET = {
|
|
3
|
+
caip2Id: "eip155:8453",
|
|
4
|
+
shorthand: "base",
|
|
5
|
+
name: "Base",
|
|
6
|
+
namespace: "eip155",
|
|
7
|
+
chainId: 8453,
|
|
8
|
+
usdcAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
9
|
+
usdcDecimals: 6,
|
|
10
|
+
rpcUrl: "https://mainnet.base.org",
|
|
11
|
+
wsRpcUrl: "wss://base-mainnet.g.alchemy.com/v2",
|
|
12
|
+
testnet: false,
|
|
13
|
+
explorerUrl: "https://basescan.org",
|
|
14
|
+
blockTimeMs: 2000,
|
|
15
|
+
};
|
|
16
|
+
export const POLYGON_MAINNET = {
|
|
17
|
+
caip2Id: "eip155:137",
|
|
18
|
+
shorthand: "polygon",
|
|
19
|
+
name: "Polygon",
|
|
20
|
+
namespace: "eip155",
|
|
21
|
+
chainId: 137,
|
|
22
|
+
usdcAddress: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
|
|
23
|
+
usdcDecimals: 6,
|
|
24
|
+
rpcUrl: "https://polygon-rpc.com",
|
|
25
|
+
wsRpcUrl: "wss://polygon-mainnet.g.alchemy.com/v2",
|
|
26
|
+
testnet: false,
|
|
27
|
+
explorerUrl: "https://polygonscan.com",
|
|
28
|
+
blockTimeMs: 2000,
|
|
29
|
+
};
|
|
30
|
+
export const SOLANA_MAINNET = {
|
|
31
|
+
caip2Id: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
32
|
+
shorthand: "solana",
|
|
33
|
+
name: "Solana",
|
|
34
|
+
namespace: "solana",
|
|
35
|
+
usdcAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
36
|
+
usdcDecimals: 6,
|
|
37
|
+
rpcUrl: "https://api.mainnet-beta.solana.com",
|
|
38
|
+
wsRpcUrl: "wss://api.mainnet-beta.solana.com",
|
|
39
|
+
testnet: false,
|
|
40
|
+
explorerUrl: "https://explorer.solana.com",
|
|
41
|
+
blockTimeMs: 400,
|
|
42
|
+
};
|
|
43
|
+
// ─── Testnet Chains ───
|
|
44
|
+
export const BASE_SEPOLIA = {
|
|
45
|
+
caip2Id: "eip155:84532",
|
|
46
|
+
shorthand: "base-sepolia",
|
|
47
|
+
name: "Base Sepolia",
|
|
48
|
+
namespace: "eip155",
|
|
49
|
+
chainId: 84532,
|
|
50
|
+
usdcAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
51
|
+
usdcDecimals: 6,
|
|
52
|
+
rpcUrl: "https://sepolia.base.org",
|
|
53
|
+
testnet: true,
|
|
54
|
+
explorerUrl: "https://sepolia.basescan.org",
|
|
55
|
+
blockTimeMs: 2000,
|
|
56
|
+
};
|
|
57
|
+
export const POLYGON_AMOY = {
|
|
58
|
+
caip2Id: "eip155:80002",
|
|
59
|
+
shorthand: "polygon-amoy",
|
|
60
|
+
name: "Polygon Amoy",
|
|
61
|
+
namespace: "eip155",
|
|
62
|
+
chainId: 80002,
|
|
63
|
+
usdcAddress: "0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582",
|
|
64
|
+
usdcDecimals: 6,
|
|
65
|
+
rpcUrl: "https://rpc-amoy.polygon.technology",
|
|
66
|
+
testnet: true,
|
|
67
|
+
explorerUrl: "https://amoy.polygonscan.com",
|
|
68
|
+
blockTimeMs: 2000,
|
|
69
|
+
};
|
|
70
|
+
export const SOLANA_DEVNET = {
|
|
71
|
+
caip2Id: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
|
|
72
|
+
shorthand: "solana-devnet",
|
|
73
|
+
name: "Solana Devnet",
|
|
74
|
+
namespace: "solana",
|
|
75
|
+
usdcAddress: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
|
|
76
|
+
usdcDecimals: 6,
|
|
77
|
+
rpcUrl: "https://api.devnet.solana.com",
|
|
78
|
+
testnet: true,
|
|
79
|
+
explorerUrl: "https://explorer.solana.com?cluster=devnet",
|
|
80
|
+
blockTimeMs: 400,
|
|
81
|
+
};
|
|
82
|
+
// ─── Chain Registry ───
|
|
83
|
+
export const CHAINS = {
|
|
84
|
+
// Mainnets
|
|
85
|
+
base: BASE_MAINNET,
|
|
86
|
+
polygon: POLYGON_MAINNET,
|
|
87
|
+
solana: SOLANA_MAINNET,
|
|
88
|
+
// Testnets
|
|
89
|
+
"base-sepolia": BASE_SEPOLIA,
|
|
90
|
+
"polygon-amoy": POLYGON_AMOY,
|
|
91
|
+
"solana-devnet": SOLANA_DEVNET,
|
|
92
|
+
};
|
|
93
|
+
/** Reverse lookup: CAIP-2 ID → ChainConfig */
|
|
94
|
+
export const CHAINS_BY_CAIP2 = Object.fromEntries(Object.values(CHAINS).map((c) => [c.caip2Id, c]));
|
|
95
|
+
/**
|
|
96
|
+
* Resolve a chain shorthand (e.g., "base") or CAIP-2 ID (e.g., "eip155:8453")
|
|
97
|
+
* to a ChainConfig. Returns undefined if not found.
|
|
98
|
+
*/
|
|
99
|
+
export function resolveChain(input) {
|
|
100
|
+
return CHAINS[input] ?? CHAINS_BY_CAIP2[input];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Resolve a chain shorthand to its CAIP-2 ID.
|
|
104
|
+
* Throws if the chain is not recognized.
|
|
105
|
+
*/
|
|
106
|
+
export function toCAIP2(shorthand) {
|
|
107
|
+
const chain = resolveChain(shorthand);
|
|
108
|
+
if (!chain) {
|
|
109
|
+
throw new Error(`Unknown chain: "${shorthand}". Valid chains: ${Object.keys(CHAINS).join(", ")}`);
|
|
110
|
+
}
|
|
111
|
+
return chain.caip2Id;
|
|
112
|
+
}
|
|
113
|
+
/** Get all supported mainnet chain configs */
|
|
114
|
+
export function getMainnetChains() {
|
|
115
|
+
return Object.values(CHAINS).filter((c) => !c.testnet);
|
|
116
|
+
}
|
|
117
|
+
/** Get all supported testnet chain configs */
|
|
118
|
+
export function getTestnetChains() {
|
|
119
|
+
return Object.values(CHAINS).filter((c) => c.testnet);
|
|
120
|
+
}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AAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CACjD,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,SAAiB;IACvC,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,SAAS,oBAAoB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpG,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC;AACvB,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,gBAAgB;IAC9B,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AACzD,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,gBAAgB;IAC9B,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Default PincerPay facilitator URL */
|
|
2
|
+
export declare const DEFAULT_FACILITATOR_URL = "https://facilitator.pincerpay.com";
|
|
3
|
+
/** Facilitator API version prefix */
|
|
4
|
+
export declare const API_VERSION = "v1";
|
|
5
|
+
/** Facilitator routes */
|
|
6
|
+
export declare const FACILITATOR_ROUTES: {
|
|
7
|
+
readonly verify: "/v1/verify";
|
|
8
|
+
readonly settle: "/v1/settle";
|
|
9
|
+
readonly status: "/v1/status";
|
|
10
|
+
readonly supported: "/v1/supported";
|
|
11
|
+
readonly health: "/health";
|
|
12
|
+
};
|
|
13
|
+
/** USDC decimals (consistent across all chains) */
|
|
14
|
+
export declare const USDC_DECIMALS = 6;
|
|
15
|
+
/** Optimistic finality threshold in USDC base units (1 USDC = 1_000_000) */
|
|
16
|
+
export declare const OPTIMISTIC_THRESHOLD = "1000000";
|
|
17
|
+
/** API key prefix length (shown to users, e.g., "pp_live_abc...") */
|
|
18
|
+
export declare const API_KEY_PREFIX_LENGTH = 12;
|
|
19
|
+
/** API key header name */
|
|
20
|
+
export declare const API_KEY_HEADER = "x-pincerpay-api-key";
|
|
21
|
+
/** Rate limit defaults */
|
|
22
|
+
export declare const RATE_LIMIT: {
|
|
23
|
+
/** Max requests per minute per API key */
|
|
24
|
+
readonly perMinute: 120;
|
|
25
|
+
/** Max requests per second per API key (burst) */
|
|
26
|
+
readonly perSecond: 20;
|
|
27
|
+
};
|
|
28
|
+
/** Transaction status poll interval in ms */
|
|
29
|
+
export declare const TX_POLL_INTERVAL_MS = 2000;
|
|
30
|
+
/** Maximum time to wait for tx confirmation in ms */
|
|
31
|
+
export declare const TX_CONFIRMATION_TIMEOUT_MS = 120000;
|
|
32
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,eAAO,MAAM,uBAAuB,sCAAsC,CAAC;AAE3E,qCAAqC;AACrC,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC,yBAAyB;AACzB,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AAEX,mDAAmD;AACnD,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAE9C,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,0BAA0B;AAC1B,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,0BAA0B;AAC1B,eAAO,MAAM,UAAU;IACrB,0CAA0C;;IAE1C,kDAAkD;;CAE1C,CAAC;AAEX,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,qDAAqD;AACrD,eAAO,MAAM,0BAA0B,SAAU,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Default PincerPay facilitator URL */
|
|
2
|
+
export const DEFAULT_FACILITATOR_URL = "https://facilitator.pincerpay.com";
|
|
3
|
+
/** Facilitator API version prefix */
|
|
4
|
+
export const API_VERSION = "v1";
|
|
5
|
+
/** Facilitator routes */
|
|
6
|
+
export const FACILITATOR_ROUTES = {
|
|
7
|
+
verify: `/${API_VERSION}/verify`,
|
|
8
|
+
settle: `/${API_VERSION}/settle`,
|
|
9
|
+
status: `/${API_VERSION}/status`,
|
|
10
|
+
supported: `/${API_VERSION}/supported`,
|
|
11
|
+
health: "/health",
|
|
12
|
+
};
|
|
13
|
+
/** USDC decimals (consistent across all chains) */
|
|
14
|
+
export const USDC_DECIMALS = 6;
|
|
15
|
+
/** Optimistic finality threshold in USDC base units (1 USDC = 1_000_000) */
|
|
16
|
+
export const OPTIMISTIC_THRESHOLD = "1000000";
|
|
17
|
+
/** API key prefix length (shown to users, e.g., "pp_live_abc...") */
|
|
18
|
+
export const API_KEY_PREFIX_LENGTH = 12;
|
|
19
|
+
/** API key header name */
|
|
20
|
+
export const API_KEY_HEADER = "x-pincerpay-api-key";
|
|
21
|
+
/** Rate limit defaults */
|
|
22
|
+
export const RATE_LIMIT = {
|
|
23
|
+
/** Max requests per minute per API key */
|
|
24
|
+
perMinute: 120,
|
|
25
|
+
/** Max requests per second per API key (burst) */
|
|
26
|
+
perSecond: 20,
|
|
27
|
+
};
|
|
28
|
+
/** Transaction status poll interval in ms */
|
|
29
|
+
export const TX_POLL_INTERVAL_MS = 2000;
|
|
30
|
+
/** Maximum time to wait for tx confirmation in ms */
|
|
31
|
+
export const TX_CONFIRMATION_TIMEOUT_MS = 120_000;
|
|
32
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,MAAM,CAAC,MAAM,uBAAuB,GAAG,mCAAmC,CAAC;AAE3E,qCAAqC;AACrC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC;AAEhC,yBAAyB;AACzB,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,MAAM,EAAE,IAAI,WAAW,SAAS;IAChC,MAAM,EAAE,IAAI,WAAW,SAAS;IAChC,MAAM,EAAE,IAAI,WAAW,SAAS;IAChC,SAAS,EAAE,IAAI,WAAW,YAAY;IACtC,MAAM,EAAE,SAAS;CACT,CAAC;AAEX,mDAAmD;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAE9C,qEAAqE;AACrE,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC,0BAA0B;AAC1B,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAEpD,0BAA0B;AAC1B,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,0CAA0C;IAC1C,SAAS,EAAE,GAAG;IACd,kDAAkD;IAClD,SAAS,EAAE,EAAE;CACL,CAAC;AAEX,6CAA6C;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAExC,qDAAqD;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type ChainNamespace = "eip155" | "solana";
|
|
3
|
+
export interface ChainConfig {
|
|
4
|
+
/** CAIP-2 chain ID (e.g., "eip155:8453" for Base) */
|
|
5
|
+
caip2Id: string;
|
|
6
|
+
/** Human-readable shorthand (e.g., "base", "solana") */
|
|
7
|
+
shorthand: string;
|
|
8
|
+
/** Display name */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Chain namespace */
|
|
11
|
+
namespace: ChainNamespace;
|
|
12
|
+
/** Numeric chain ID (EVM only) */
|
|
13
|
+
chainId?: number;
|
|
14
|
+
/** USDC contract address on this chain */
|
|
15
|
+
usdcAddress: string;
|
|
16
|
+
/** USDC decimals (6 for all current deployments) */
|
|
17
|
+
usdcDecimals: number;
|
|
18
|
+
/** Default RPC URL (overridable) */
|
|
19
|
+
rpcUrl: string;
|
|
20
|
+
/** WebSocket RPC URL (optional, for mempool monitoring) */
|
|
21
|
+
wsRpcUrl?: string;
|
|
22
|
+
/** Whether this is a testnet */
|
|
23
|
+
testnet: boolean;
|
|
24
|
+
/** Block explorer URL */
|
|
25
|
+
explorerUrl: string;
|
|
26
|
+
/** Average block time in milliseconds */
|
|
27
|
+
blockTimeMs: number;
|
|
28
|
+
}
|
|
29
|
+
export interface MerchantProfile {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
walletAddress: string;
|
|
33
|
+
supportedChains: string[];
|
|
34
|
+
webhookUrl?: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
}
|
|
37
|
+
export interface ApiKeyRecord {
|
|
38
|
+
id: string;
|
|
39
|
+
merchantId: string;
|
|
40
|
+
keyHash: string;
|
|
41
|
+
prefix: string;
|
|
42
|
+
label: string;
|
|
43
|
+
isActive: boolean;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
lastUsedAt?: Date;
|
|
46
|
+
}
|
|
47
|
+
export interface PaywallConfig {
|
|
48
|
+
id: string;
|
|
49
|
+
merchantId: string;
|
|
50
|
+
/** HTTP method + path pattern (e.g., "GET /api/weather") */
|
|
51
|
+
endpointPattern: string;
|
|
52
|
+
/** USDC amount as string (e.g., "0.01") */
|
|
53
|
+
amount: string;
|
|
54
|
+
/** Supported chains for this paywall (defaults to merchant's chains) */
|
|
55
|
+
chains?: string[];
|
|
56
|
+
/** Human-readable description */
|
|
57
|
+
description: string;
|
|
58
|
+
isActive: boolean;
|
|
59
|
+
}
|
|
60
|
+
export type TransactionStatus = "pending" | "mempool" | "optimistic" | "confirmed" | "failed";
|
|
61
|
+
/** Settlement type: x402 (off-chain via x402 protocol) or direct (on-chain via Anchor program) */
|
|
62
|
+
export type SettlementType = "x402" | "direct";
|
|
63
|
+
/** Solana commitment levels for confirmation */
|
|
64
|
+
export type SolanaConfirmationLevel = "processed" | "confirmed" | "finalized";
|
|
65
|
+
export interface Transaction {
|
|
66
|
+
id: string;
|
|
67
|
+
merchantId: string;
|
|
68
|
+
/** CAIP-2 chain ID */
|
|
69
|
+
chainId: string;
|
|
70
|
+
txHash: string;
|
|
71
|
+
fromAddress: string;
|
|
72
|
+
toAddress: string;
|
|
73
|
+
/** USDC amount in base units (e.g., "1000000" = 1 USDC) */
|
|
74
|
+
amount: string;
|
|
75
|
+
/** Gas/fee cost in base units of gasToken */
|
|
76
|
+
gasCost: string;
|
|
77
|
+
/** Token used for transaction fees (e.g., "ETH", "SOL", "MATIC", "USDC") */
|
|
78
|
+
gasToken: string;
|
|
79
|
+
status: TransactionStatus;
|
|
80
|
+
/** Whether optimistic finality was used */
|
|
81
|
+
optimistic: boolean;
|
|
82
|
+
/** Settlement path used: x402 (off-chain) or direct (on-chain Anchor program) */
|
|
83
|
+
settlementType?: SettlementType;
|
|
84
|
+
/** On-chain settlement nonce (links to SettlementRecord PDA) */
|
|
85
|
+
programNonce?: string;
|
|
86
|
+
/** Solana slot number (null for EVM) */
|
|
87
|
+
slot?: string;
|
|
88
|
+
/** Solana priority fee in microlamports (null for EVM) */
|
|
89
|
+
priorityFee?: string;
|
|
90
|
+
/** Solana compute units consumed (null for EVM) */
|
|
91
|
+
computeUnits?: string;
|
|
92
|
+
createdAt: Date;
|
|
93
|
+
confirmedAt?: Date;
|
|
94
|
+
}
|
|
95
|
+
/** On-chain settlement record from the Anchor program */
|
|
96
|
+
export interface OnChainSettlement {
|
|
97
|
+
nonce: string;
|
|
98
|
+
agent: string;
|
|
99
|
+
merchant: string;
|
|
100
|
+
merchantAccount: string;
|
|
101
|
+
amount: string;
|
|
102
|
+
slot: string;
|
|
103
|
+
/** 0 = direct on-chain, 1 = x402 recorded */
|
|
104
|
+
txType: number;
|
|
105
|
+
x402TxHash: string;
|
|
106
|
+
timestamp: number;
|
|
107
|
+
}
|
|
108
|
+
export type AgentStatus = "active" | "paused" | "revoked";
|
|
109
|
+
export interface AgentProfile {
|
|
110
|
+
id: string;
|
|
111
|
+
merchantId: string;
|
|
112
|
+
name: string;
|
|
113
|
+
solanaAddress: string;
|
|
114
|
+
smartAccountPda?: string;
|
|
115
|
+
settingsPda?: string;
|
|
116
|
+
spendingLimitPda?: string;
|
|
117
|
+
maxPerTransaction?: string;
|
|
118
|
+
maxPerDay?: string;
|
|
119
|
+
status: AgentStatus;
|
|
120
|
+
createdAt: Date;
|
|
121
|
+
updatedAt: Date;
|
|
122
|
+
}
|
|
123
|
+
export interface SolanaSmartAgentConfig extends AgentConfig {
|
|
124
|
+
/** Squads Settings PDA */
|
|
125
|
+
settingsPda?: string;
|
|
126
|
+
/** Smart Account index for PDA derivation */
|
|
127
|
+
smartAccountIndex?: number;
|
|
128
|
+
/** Spending Limit index for PDA derivation */
|
|
129
|
+
spendingLimitIndex?: number;
|
|
130
|
+
}
|
|
131
|
+
export interface SpendingPolicy {
|
|
132
|
+
/** Max USDC per transaction (base units) */
|
|
133
|
+
maxPerTransaction?: string;
|
|
134
|
+
/** Max USDC per day (base units) */
|
|
135
|
+
maxPerDay?: string;
|
|
136
|
+
/** Allowed merchant addresses */
|
|
137
|
+
allowedMerchants?: string[];
|
|
138
|
+
/** Allowed chains (shorthands) */
|
|
139
|
+
allowedChains?: string[];
|
|
140
|
+
}
|
|
141
|
+
export interface PincerPayConfig {
|
|
142
|
+
/** Merchant API key */
|
|
143
|
+
apiKey: string;
|
|
144
|
+
/** Merchant wallet address */
|
|
145
|
+
merchantAddress: string;
|
|
146
|
+
/** Facilitator URL (defaults to PincerPay hosted) */
|
|
147
|
+
facilitatorUrl?: string;
|
|
148
|
+
/** Route-level paywall configs */
|
|
149
|
+
routes: Record<string, RoutePaywallConfig>;
|
|
150
|
+
}
|
|
151
|
+
export interface RoutePaywallConfig {
|
|
152
|
+
/** USDC price as string (e.g., "0.01") */
|
|
153
|
+
price: string;
|
|
154
|
+
/** Preferred chain shorthand */
|
|
155
|
+
chain?: string;
|
|
156
|
+
/** Multiple chain shorthands */
|
|
157
|
+
chains?: string[];
|
|
158
|
+
/** Description shown in 402 response */
|
|
159
|
+
description?: string;
|
|
160
|
+
}
|
|
161
|
+
export interface AgentConfig {
|
|
162
|
+
/** Supported chain shorthands */
|
|
163
|
+
chains: string[];
|
|
164
|
+
/** EVM private key (hex) */
|
|
165
|
+
evmPrivateKey?: string;
|
|
166
|
+
/** Solana private key (base58) */
|
|
167
|
+
solanaPrivateKey?: string;
|
|
168
|
+
/** Spending policies */
|
|
169
|
+
policies?: SpendingPolicy[];
|
|
170
|
+
/** Custom facilitator URL */
|
|
171
|
+
facilitatorUrl?: string;
|
|
172
|
+
}
|
|
173
|
+
export declare const RoutePaywallConfigSchema: z.ZodObject<{
|
|
174
|
+
price: z.ZodString;
|
|
175
|
+
chain: z.ZodOptional<z.ZodString>;
|
|
176
|
+
chains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
177
|
+
description: z.ZodOptional<z.ZodString>;
|
|
178
|
+
}, "strip", z.ZodTypeAny, {
|
|
179
|
+
price: string;
|
|
180
|
+
chain?: string | undefined;
|
|
181
|
+
chains?: string[] | undefined;
|
|
182
|
+
description?: string | undefined;
|
|
183
|
+
}, {
|
|
184
|
+
price: string;
|
|
185
|
+
chain?: string | undefined;
|
|
186
|
+
chains?: string[] | undefined;
|
|
187
|
+
description?: string | undefined;
|
|
188
|
+
}>;
|
|
189
|
+
export declare const PincerPayConfigSchema: z.ZodObject<{
|
|
190
|
+
apiKey: z.ZodString;
|
|
191
|
+
merchantAddress: z.ZodString;
|
|
192
|
+
facilitatorUrl: z.ZodOptional<z.ZodString>;
|
|
193
|
+
routes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
194
|
+
price: z.ZodString;
|
|
195
|
+
chain: z.ZodOptional<z.ZodString>;
|
|
196
|
+
chains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
197
|
+
description: z.ZodOptional<z.ZodString>;
|
|
198
|
+
}, "strip", z.ZodTypeAny, {
|
|
199
|
+
price: string;
|
|
200
|
+
chain?: string | undefined;
|
|
201
|
+
chains?: string[] | undefined;
|
|
202
|
+
description?: string | undefined;
|
|
203
|
+
}, {
|
|
204
|
+
price: string;
|
|
205
|
+
chain?: string | undefined;
|
|
206
|
+
chains?: string[] | undefined;
|
|
207
|
+
description?: string | undefined;
|
|
208
|
+
}>>;
|
|
209
|
+
}, "strip", z.ZodTypeAny, {
|
|
210
|
+
apiKey: string;
|
|
211
|
+
merchantAddress: string;
|
|
212
|
+
routes: Record<string, {
|
|
213
|
+
price: string;
|
|
214
|
+
chain?: string | undefined;
|
|
215
|
+
chains?: string[] | undefined;
|
|
216
|
+
description?: string | undefined;
|
|
217
|
+
}>;
|
|
218
|
+
facilitatorUrl?: string | undefined;
|
|
219
|
+
}, {
|
|
220
|
+
apiKey: string;
|
|
221
|
+
merchantAddress: string;
|
|
222
|
+
routes: Record<string, {
|
|
223
|
+
price: string;
|
|
224
|
+
chain?: string | undefined;
|
|
225
|
+
chains?: string[] | undefined;
|
|
226
|
+
description?: string | undefined;
|
|
227
|
+
}>;
|
|
228
|
+
facilitatorUrl?: string | undefined;
|
|
229
|
+
}>;
|
|
230
|
+
export declare const SpendingPolicySchema: z.ZodObject<{
|
|
231
|
+
maxPerTransaction: z.ZodOptional<z.ZodString>;
|
|
232
|
+
maxPerDay: z.ZodOptional<z.ZodString>;
|
|
233
|
+
allowedMerchants: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
234
|
+
allowedChains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
235
|
+
}, "strip", z.ZodTypeAny, {
|
|
236
|
+
maxPerTransaction?: string | undefined;
|
|
237
|
+
maxPerDay?: string | undefined;
|
|
238
|
+
allowedMerchants?: string[] | undefined;
|
|
239
|
+
allowedChains?: string[] | undefined;
|
|
240
|
+
}, {
|
|
241
|
+
maxPerTransaction?: string | undefined;
|
|
242
|
+
maxPerDay?: string | undefined;
|
|
243
|
+
allowedMerchants?: string[] | undefined;
|
|
244
|
+
allowedChains?: string[] | undefined;
|
|
245
|
+
}>;
|
|
246
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,SAAS,EAAE,M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D;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,4BAA4B;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wBAAwB;IACxB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,6BAA6B;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAID,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAKnC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKhC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;EAK/B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ─── Zod Schemas ───
|
|
3
|
+
export const RoutePaywallConfigSchema = z.object({
|
|
4
|
+
price: z.string().regex(/^\d+\.?\d*$/, "Must be a valid USDC amount"),
|
|
5
|
+
chain: z.string().optional(),
|
|
6
|
+
chains: z.array(z.string()).optional(),
|
|
7
|
+
description: z.string().optional(),
|
|
8
|
+
});
|
|
9
|
+
export const PincerPayConfigSchema = z.object({
|
|
10
|
+
apiKey: z.string().min(1),
|
|
11
|
+
merchantAddress: z.string().min(1),
|
|
12
|
+
facilitatorUrl: z.string().url().optional(),
|
|
13
|
+
routes: z.record(z.string(), RoutePaywallConfigSchema),
|
|
14
|
+
});
|
|
15
|
+
export const SpendingPolicySchema = z.object({
|
|
16
|
+
maxPerTransaction: z.string().optional(),
|
|
17
|
+
maxPerDay: z.string().optional(),
|
|
18
|
+
allowedMerchants: z.array(z.string()).optional(),
|
|
19
|
+
allowedChains: z.array(z.string()).optional(),
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiNxB,sBAAsB;AAEtB,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,6BAA6B,CAAC;IACrE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACtC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAClC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC3C,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,wBAAwB,CAAC;CACvD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACxC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,gBAAgB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAChD,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC9C,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pincerpay/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Shared types, chain configs, and constants for PincerPay on-chain payment gateway",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://pincerpay.com",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/ds1/pincerpay.git",
|
|
14
|
+
"directory": "packages/core"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/ds1/pincerpay/issues"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"pincerpay",
|
|
21
|
+
"x402",
|
|
22
|
+
"usdc",
|
|
23
|
+
"payments",
|
|
24
|
+
"ai-agents",
|
|
25
|
+
"solana",
|
|
26
|
+
"payment-gateway",
|
|
27
|
+
"stablecoin"
|
|
28
|
+
],
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"main": "dist/index.js",
|
|
35
|
+
"types": "dist/index.d.ts",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"import": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./types": {
|
|
42
|
+
"types": "./dist/types/index.d.ts",
|
|
43
|
+
"import": "./dist/types/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./chains": {
|
|
46
|
+
"types": "./dist/chains/index.d.ts",
|
|
47
|
+
"import": "./dist/chains/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"zod": "^3.24"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"typescript": "^5.7"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsc",
|
|
58
|
+
"test": "vitest run",
|
|
59
|
+
"typecheck": "tsc --noEmit",
|
|
60
|
+
"clean": "rm -rf dist"
|
|
61
|
+
}
|
|
62
|
+
}
|