@chainrails/sdk 0.1.0 → 0.2.1
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 +152 -0
- package/dist/chainrails-sdk.es.js +239 -239
- package/dist/chainrails-sdk.es.mjs +239 -239
- package/dist/chainrails-sdk.umd.js +2 -2
- package/dist/src/Auth/index.d.ts +5 -2
- package/dist/src/Auth/index.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,10 +8,69 @@ A TypeScript SDK for interacting with the Chainrails API - enabling seamless cro
|
|
|
8
8
|
- 🌉 **Bridge Routing** - Find optimal routes and pricing across multiple bridge protocols
|
|
9
9
|
- 💰 **Quote Management** - Get real-time quotes from various bridge providers
|
|
10
10
|
- 📋 **Intent Management** - Create and manage cross-chain transfer intents
|
|
11
|
+
- 🔐 **Session Authentication** - Secure session-based auth for modal payment flows (NEW in v0.1.0)
|
|
11
12
|
- ⛓️ **Chain Support** - Support for 11+ blockchain networks including Ethereum, Arbitrum, Base, Starknet, and more
|
|
12
13
|
- 🔐 **Secure** - API key-based authentication with automatic header injection
|
|
13
14
|
- 📦 **Tree-shakeable** - Built with ES modules for optimal bundle sizes
|
|
14
15
|
|
|
16
|
+
## What's New in v0.1.0 (January 2026)
|
|
17
|
+
|
|
18
|
+
### New: Session Token Authentication Module
|
|
19
|
+
|
|
20
|
+
The `Auth` module provides secure session-based authentication for modal payment flows:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
const session = await crapi.auth.getSessionToken({
|
|
24
|
+
recipient: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
|
|
25
|
+
destinationChain: "ARBITRUM_MAINNET",
|
|
26
|
+
token: "USDC",
|
|
27
|
+
amount: "100"
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// Returns: { sessionToken, sessionId, expiresAt }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Use Cases:**
|
|
34
|
+
- Iframe-based payment modal initialization
|
|
35
|
+
- Client-side session management with automatic expiration
|
|
36
|
+
- Secure token propagation to frontend applications
|
|
37
|
+
|
|
38
|
+
### Enhanced Intent APIs
|
|
39
|
+
|
|
40
|
+
New session-aware methods for managing intents within modal context:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// Create intent for session (simplified parameters)
|
|
44
|
+
const intent = await crapi.intents.createForSession({
|
|
45
|
+
/* minimal parameters */
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// Get intents associated with a session
|
|
49
|
+
const sessionIntents = await crapi.intents.getForSession("0x...")
|
|
50
|
+
|
|
51
|
+
// Get intent by contract address
|
|
52
|
+
const intent = await crapi.intents.getForAddress("0x...")
|
|
53
|
+
|
|
54
|
+
// Trigger processing within session context
|
|
55
|
+
const result = await crapi.intents.triggerProcessingForSession("0x...")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Session-Based Quote Queries
|
|
59
|
+
|
|
60
|
+
Retrieve quotes within a payment session context:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
const quotes = await crapi.quotes.getAllForSession({
|
|
64
|
+
// session-specific parameters
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Breaking Changes
|
|
69
|
+
|
|
70
|
+
- **Intent Creation**: Use `createForSession()` for modal flows instead of `create()`
|
|
71
|
+
- **Response Types**: Quote responses now have enhanced types for session context
|
|
72
|
+
- **Authentication**: Session token required for iframe communication
|
|
73
|
+
|
|
15
74
|
## Installation
|
|
16
75
|
|
|
17
76
|
```bash
|
|
@@ -65,6 +124,45 @@ Supported chains include:
|
|
|
65
124
|
|
|
66
125
|
## API Reference
|
|
67
126
|
|
|
127
|
+
### Auth Module (New in v0.1.0)
|
|
128
|
+
|
|
129
|
+
Manage session-based authentication for modal payment flows.
|
|
130
|
+
|
|
131
|
+
#### Get Session Token
|
|
132
|
+
|
|
133
|
+
Creates a secure session token for iframe-based payment modal initialization.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const session = await crapi.auth.getSessionToken({
|
|
137
|
+
recipient: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
|
|
138
|
+
destinationChain: "ARBITRUM_MAINNET",
|
|
139
|
+
token: "USDC",
|
|
140
|
+
amount: "100"
|
|
141
|
+
})
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Parameters:**
|
|
145
|
+
- `recipient` (required): Recipient wallet address on destination chain
|
|
146
|
+
- `destinationChain` (required): Destination blockchain network
|
|
147
|
+
- `token` (required): Token symbol (e.g., "USDC", "ETH")
|
|
148
|
+
- `amount` (required): Transfer amount (string or number)
|
|
149
|
+
|
|
150
|
+
**Response:**
|
|
151
|
+
```typescript
|
|
152
|
+
interface getSessionTokenOutput {
|
|
153
|
+
sessionToken: string // JWT token for iframe communication
|
|
154
|
+
sessionId: string // Unique session identifier
|
|
155
|
+
expiresAt: string // ISO 8601 expiration timestamp
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Use Cases:**
|
|
160
|
+
- Initialize payment modal with secure authentication
|
|
161
|
+
- Manage session lifecycle with automatic expiration
|
|
162
|
+
- Propagate credentials to iframe securely via postMessage
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
68
166
|
### Intents Module
|
|
69
167
|
|
|
70
168
|
Manage cross-chain transfer intents.
|
|
@@ -183,6 +281,48 @@ const updated = await crapi.intents.update("123", {
|
|
|
183
281
|
|
|
184
282
|
**Status values:** `"PENDING"`, `"FUNDED"`, `"INITIATED"`, `"COMPLETED"`, `"EXPIRED"`
|
|
185
283
|
|
|
284
|
+
#### Create Intent for Session (New in v0.1.0)
|
|
285
|
+
|
|
286
|
+
Creates an intent specifically for modal-based payment flows with simplified parameters.
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
const intent = await crapi.intents.createForSession({
|
|
290
|
+
// Simplified parameters for session context
|
|
291
|
+
// See API documentation for complete parameter list
|
|
292
|
+
})
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Use Case:** Use this method when creating intents within a modal payment session context instead of `create()`.
|
|
296
|
+
|
|
297
|
+
#### Get Intents for Session (New in v0.1.0)
|
|
298
|
+
|
|
299
|
+
Retrieves all intents associated with a specific session.
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
const sessionIntents = await crapi.intents.getForSession("0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb")
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Parameters:**
|
|
306
|
+
- `address` (required): Session address identifier
|
|
307
|
+
|
|
308
|
+
#### Trigger Processing for Session (New in v0.1.0)
|
|
309
|
+
|
|
310
|
+
Triggers payment processing for an intent within a modal session context.
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
const result = await crapi.intents.triggerProcessingForSession("0x4E60e01263E750eD9D087157e19D2480Fd86A900")
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Parameters:**
|
|
317
|
+
- `intentAddress` (required): Contract address of the intent
|
|
318
|
+
|
|
319
|
+
**Response:**
|
|
320
|
+
```typescript
|
|
321
|
+
interface triggerProcessingOutput {
|
|
322
|
+
// Processing status and receipt information
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
186
326
|
---
|
|
187
327
|
|
|
188
328
|
### Router Module
|
|
@@ -335,6 +475,18 @@ const multiSourceQuotes = await crapi.quotes.getAll({
|
|
|
335
475
|
- `tokenOut` (required): Output token address
|
|
336
476
|
- `recipient` (optional): Recipient address
|
|
337
477
|
|
|
478
|
+
#### Get Quotes for Session (New in v0.1.0)
|
|
479
|
+
|
|
480
|
+
Retrieves all available bridge quotes within a payment session context.
|
|
481
|
+
|
|
482
|
+
```typescript
|
|
483
|
+
const sessionQuotes = await crapi.quotes.getAllForSession({
|
|
484
|
+
// session-specific parameters
|
|
485
|
+
})
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
**Use Case:** Use this method to get quotes when operating within a modal session context. Returns quotes in the same format as `getBestAcrossBridges()` for consistency.
|
|
489
|
+
|
|
338
490
|
---
|
|
339
491
|
|
|
340
492
|
### Chains Module
|