@dimcool/sdk 0.1.2 → 0.1.6
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 +19 -0
- package/dist/index.cjs +1820 -1696
- package/dist/index.d.cts +85 -2
- package/dist/index.d.ts +85 -2
- package/dist/index.js +1820 -1696
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,6 +68,11 @@ const sdk = new SDK({
|
|
|
68
68
|
appId: 'dim-agents',
|
|
69
69
|
baseUrl: 'https://api.dim.cool',
|
|
70
70
|
storage: new NodeStorage(),
|
|
71
|
+
autoPay: {
|
|
72
|
+
enabled: true,
|
|
73
|
+
maxAmountMinor: 20_000,
|
|
74
|
+
maxRetries: 1,
|
|
75
|
+
},
|
|
71
76
|
});
|
|
72
77
|
|
|
73
78
|
// Wallet auth
|
|
@@ -111,6 +116,11 @@ interface SDKConfig {
|
|
|
111
116
|
appId: string; // Required: identifies the app (e.g. 'dim', 'dim-admin')
|
|
112
117
|
baseUrl?: string; // Default: 'http://localhost:3000'
|
|
113
118
|
storage: IStorage; // Required: Storage implementation
|
|
119
|
+
autoPay?: {
|
|
120
|
+
enabled?: boolean;
|
|
121
|
+
maxAmountMinor?: number;
|
|
122
|
+
maxRetries?: number;
|
|
123
|
+
};
|
|
114
124
|
httpClient?: IHttpClient; // Optional: injectable HTTP client for testing
|
|
115
125
|
wsTransport?: WsTransport; // Optional: injectable WS transport
|
|
116
126
|
logger?: ILogger; // Optional: logger instance
|
|
@@ -127,6 +137,15 @@ The `appId` is:
|
|
|
127
137
|
- Included in the Socket.IO auth handshake for WebSocket connections
|
|
128
138
|
- Stored on user records (`signupAppId`, `lastLoginAppId`) and sessions
|
|
129
139
|
|
|
140
|
+
### Payment Required Handling
|
|
141
|
+
|
|
142
|
+
The SDK can automatically handle `402 Payment Required` challenges for endpoints that are payment-gated under abuse controls.
|
|
143
|
+
|
|
144
|
+
- Enable with `autoPay.enabled: true`
|
|
145
|
+
- Restrict exposure with `autoPay.maxAmountMinor` and conservative retry limits
|
|
146
|
+
- Provide a wallet signer (`sdk.wallet.setSigner(...)`) so the SDK can sign payment transactions
|
|
147
|
+
- If auto-pay is disabled or policy blocks a challenge, the SDK throws an error containing the payment challenge details
|
|
148
|
+
|
|
130
149
|
## Storage
|
|
131
150
|
|
|
132
151
|
The SDK requires a storage implementation to persist authentication tokens. Two implementations are provided:
|