stableflow-ai-sdk 1.0.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 ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 StableFlow AI
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.
22
+
package/README.md ADDED
@@ -0,0 +1,228 @@
1
+ # StableFlow AI SDK - TypeScript
2
+
3
+ A powerful TypeScript SDK for seamless cross-chain token swaps. Built with type safety in mind, this SDK enables developers to easily integrate cross-chain swapping functionality into their applications with minimal setup.
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js >= 16
8
+ - npm / yarn / pnpm
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ # Using npm
14
+ npm install stableflow-ai-sdk
15
+
16
+ # Using yarn
17
+ yarn add stableflow-ai-sdk
18
+
19
+ # Using pnpm
20
+ pnpm add stableflow-ai-sdk
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```typescript
26
+ import { OpenAPI, QuoteRequest, SFA } from 'stableflow-ai-sdk';
27
+
28
+ // Initialize the API client
29
+ OpenAPI.BASE = 'https://api.stableflow.ai';
30
+
31
+ // Configure your JSON Web Token (JWT) - required for most endpoints
32
+ OpenAPI.TOKEN = "your-JSON-Web-Token";
33
+
34
+ // Create a quote request
35
+ const quoteRequest: QuoteRequest = {
36
+ dry: true, // set to true for testing / false to get `depositAddress` and execute swap
37
+ swapType: QuoteRequest.swapType.EXACT_INPUT,
38
+ slippageTolerance: 100, // 1%
39
+ originAsset: 'nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near', // USDC on Arbitrum
40
+ depositType: QuoteRequest.depositType.ORIGIN_CHAIN,
41
+ destinationAsset: 'nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near', // USDC on Solana
42
+ amount: '1000000', // 1 USDC (in smallest units)
43
+ refundTo: '0x2527D02599Ba641c19FEa793cD0F167589a0f10D', // Valid Arbitrum address
44
+ refundType: QuoteRequest.refundType.ORIGIN_CHAIN,
45
+ recipient: '13QkxhNMrTPxoCkRdYdJ65tFuwXPhL5gLS2Z5Nr6gjRK', // Valid Solana Address
46
+ recipientType: QuoteRequest.recipientType.DESTINATION_CHAIN,
47
+ deadline: "2025-08-06T14:15:22Z"
48
+ };
49
+
50
+ // Get quote
51
+ const quote = await SFA.getQuote(quoteRequest);
52
+ ```
53
+
54
+ ## API Methods
55
+
56
+ ### Get Quote
57
+
58
+ ```typescript
59
+ const quote = await SFA.getQuote(quoteRequest);
60
+ ```
61
+
62
+ ### Get Execution Status
63
+
64
+ ```typescript
65
+ const status = await SFA.getExecutionStatus(depositAddress);
66
+ ```
67
+
68
+ ### Submit Deposit Transaction
69
+
70
+ ```typescript
71
+ const result = await SFA.submitDepositTx({
72
+ txHash: '0x...',
73
+ depositAddress: '0x...'
74
+ });
75
+ ```
76
+
77
+ ### Get Supported Tokens
78
+
79
+ ```typescript
80
+ const tokens = await SFA.getTokens();
81
+ ```
82
+
83
+ ## Authentication
84
+
85
+ The StableFlow AI API requires JWT authentication for most endpoints.
86
+
87
+ ### Static Token (Required)
88
+
89
+ ```typescript
90
+ // Set a static JWT - required for authenticated endpoints
91
+ OpenAPI.TOKEN = 'your-JSON-Web-Token';
92
+ ```
93
+
94
+ ### Dynamic Token Provider (for token refresh)
95
+
96
+ ```typescript
97
+ // Set a function that returns a fresh token when needed
98
+ OpenAPI.TOKEN = async () => {
99
+ // Get a fresh token from your authentication system
100
+ return 'FRESH_JWT';
101
+ };
102
+ ```
103
+
104
+ ### Protected Endpoints
105
+
106
+ The following endpoints require JWT authentication:
107
+ - `SFA.getQuote()`
108
+ - `SFA.submitDepositTx()`
109
+ - `SFA.getExecutionStatus()`
110
+
111
+ ## Error Handling
112
+
113
+ The SDK throws typed errors that you can catch and handle:
114
+
115
+ ```typescript
116
+ try {
117
+ const quote = await SFA.getQuote(quoteRequest);
118
+ } catch (error) {
119
+ if (error instanceof ApiError && error.status === 401) {
120
+ // Handle authentication errors
121
+ console.error('Authentication failed: JWT is missing or invalid');
122
+ } else if (error instanceof ApiError && error.status === 400) {
123
+ // Handle bad request
124
+ console.error('Invalid request:', error.body);
125
+ } else {
126
+ // Handle other errors
127
+ console.error('Error:', error);
128
+ }
129
+ }
130
+ ```
131
+
132
+ ## Type Definitions
133
+
134
+ The SDK provides full TypeScript type definitions, including:
135
+
136
+ - `QuoteRequest` - Parameters for requesting a quote
137
+ - `QuoteResponse` - Quote response data
138
+ - `GetExecutionStatusResponse` - Execution status response
139
+ - `SubmitDepositTxRequest` - Submit deposit transaction request
140
+ - `SubmitDepositTxResponse` - Submit deposit transaction response
141
+ - `TokenResponse` - Token information
142
+
143
+ ## Examples
144
+
145
+ ### 🌐 Web Application Demo (NEW!)
146
+
147
+ **Try our interactive web app with real wallet connection:**
148
+
149
+ ```bash
150
+ cd examples/web-demo
151
+ npm install
152
+ npm run dev
153
+ ```
154
+
155
+ Features:
156
+ - 🔗 **Wallet Connection** - Connect MetaMask or compatible wallets
157
+ - 🎨 **Modern UI** - Beautiful dark theme with gradients
158
+ - 💱 **21+ Networks** - Ethereum, Arbitrum, Solana, Base, and more
159
+ - 💎 **110+ Tokens** - USDT, USDC, ETH, and many others
160
+ - 💰 **Real-Time Quotes** - Get accurate fee and time estimates
161
+ - 🚀 **Execute Transactions** - Bridge tokens across chains
162
+ - 📊 **Transaction History** - Track your bridging activity
163
+
164
+ **Tech Stack**: TypeScript, Vite, ethers.js, StableFlow SDK
165
+
166
+ See [examples/web-demo/README.md](examples/web-demo/README.md) for full documentation.
167
+
168
+ ### 💻 Command Line Demo
169
+
170
+ Interactive CLI tool for testing SDK functionality:
171
+
172
+ ```bash
173
+ cd examples
174
+ npm install
175
+ export STABLEFLOW_JWT_TOKEN='your-jwt-token'
176
+ npm run demo
177
+ ```
178
+
179
+ See [examples/BRIDGE_DEMO_GUIDE.md](examples/BRIDGE_DEMO_GUIDE.md) for detailed instructions.
180
+
181
+ ### Other Examples
182
+
183
+ Check the `examples` directory for more examples:
184
+
185
+ ```bash
186
+ cd examples
187
+ npm install
188
+ npm start
189
+ ```
190
+
191
+ ## Development
192
+
193
+ Developer commands:
194
+
195
+ ```bash
196
+ # Install dependencies
197
+ npm install
198
+
199
+ # Build the SDK
200
+ npm run build
201
+
202
+ # Clean build artifacts
203
+ npm run clean
204
+
205
+ # Watch mode for development
206
+ npm run dev
207
+ ```
208
+
209
+ ## License
210
+
211
+ MIT
212
+
213
+ ## Support
214
+
215
+ For issues or support:
216
+
217
+ - Open an issue on GitHub
218
+ - Check the documentation
219
+ - Contact our support team
220
+
221
+ ## Changelog
222
+
223
+ ### v1.0.0
224
+ - Initial release
225
+ - Support for cross-chain token swaps
226
+ - JWT authentication support
227
+ - Full TypeScript type definitions
228
+