@zubari/sdk 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 +324 -0
- package/dist/SecureStorage-jO783AhC.d.mts +89 -0
- package/dist/SecureStorage-jO783AhC.d.ts +89 -0
- package/dist/SwapService-C0G8IXW2.d.mts +35 -0
- package/dist/SwapService-DZD0OJI_.d.ts +35 -0
- package/dist/WalletManager-DJjdq89b.d.mts +6106 -0
- package/dist/WalletManager-TiAdzqrn.d.ts +6106 -0
- package/dist/index-BLuxEdLp.d.mts +156 -0
- package/dist/index-BLuxEdLp.d.ts +156 -0
- package/dist/index-DO3T2HVe.d.ts +135 -0
- package/dist/index-fXVD8_D0.d.mts +135 -0
- package/dist/index.d.mts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +2411 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2386 -0
- package/dist/index.mjs.map +1 -0
- package/dist/protocols/index.d.mts +181 -0
- package/dist/protocols/index.d.ts +181 -0
- package/dist/protocols/index.js +415 -0
- package/dist/protocols/index.js.map +1 -0
- package/dist/protocols/index.mjs +410 -0
- package/dist/protocols/index.mjs.map +1 -0
- package/dist/react/index.d.mts +49 -0
- package/dist/react/index.d.ts +49 -0
- package/dist/react/index.js +1573 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +1570 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/services/index.d.mts +198 -0
- package/dist/services/index.d.ts +198 -0
- package/dist/services/index.js +554 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/index.mjs +547 -0
- package/dist/services/index.mjs.map +1 -0
- package/dist/storage/index.d.mts +57 -0
- package/dist/storage/index.d.ts +57 -0
- package/dist/storage/index.js +442 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/index.mjs +435 -0
- package/dist/storage/index.mjs.map +1 -0
- package/dist/wallet/index.d.mts +8 -0
- package/dist/wallet/index.d.ts +8 -0
- package/dist/wallet/index.js +1678 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/wallet/index.mjs +1674 -0
- package/dist/wallet/index.mjs.map +1 -0
- package/package.json +136 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Zubari
|
|
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,324 @@
|
|
|
1
|
+
# @zubari/sdk
|
|
2
|
+
|
|
3
|
+
Multi-chain self-custodial wallet SDK for the Web3 creator economy. Manage Bitcoin, Ethereum, TON, TRON, Solana, and Lightning (Spark) from a single BIP-39 seed phrase.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@zubari/sdk)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Multi-Chain Support**: Ethereum, Bitcoin, TON, TRON, Solana, and Lightning (Spark)
|
|
12
|
+
- **Single Seed Phrase**: Derive addresses for all chains from one BIP-39 mnemonic
|
|
13
|
+
- **Self-Custodial**: Your keys, your crypto - encrypted locally with AES-256-GCM
|
|
14
|
+
- **Creator Economy Protocols**: NFTs, Tips, Subscriptions, and Payouts
|
|
15
|
+
- **TypeScript First**: Full type safety with comprehensive type definitions
|
|
16
|
+
- **React Hooks**: Ready-to-use hooks for React applications
|
|
17
|
+
- **Tether WDK Integration**: Powered by Tether's Wallet Development Kit
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# npm
|
|
23
|
+
npm install @zubari/sdk
|
|
24
|
+
|
|
25
|
+
# yarn
|
|
26
|
+
yarn add @zubari/sdk
|
|
27
|
+
|
|
28
|
+
# pnpm
|
|
29
|
+
pnpm add @zubari/sdk
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### Create a New Wallet
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { WalletManager } from '@zubari/sdk';
|
|
38
|
+
|
|
39
|
+
// Initialize wallet manager
|
|
40
|
+
const wallet = new WalletManager({
|
|
41
|
+
network: 'testnet', // or 'mainnet'
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Create a new wallet with password protection
|
|
45
|
+
const { seed, address } = await wallet.createWallet('your-secure-password');
|
|
46
|
+
|
|
47
|
+
console.log('Seed phrase (SAVE THIS!):', seed);
|
|
48
|
+
console.log('Ethereum address:', address);
|
|
49
|
+
|
|
50
|
+
// Derive addresses for all supported chains
|
|
51
|
+
const addresses = await wallet.deriveAllAddressesWithWdk();
|
|
52
|
+
|
|
53
|
+
console.log('Multi-chain addresses:', addresses);
|
|
54
|
+
// {
|
|
55
|
+
// ethereum: '0x...',
|
|
56
|
+
// bitcoin: 'tb1q...',
|
|
57
|
+
// ton: 'UQ...',
|
|
58
|
+
// tron: 'T...',
|
|
59
|
+
// solana: '...',
|
|
60
|
+
// spark: 'sp1...'
|
|
61
|
+
// }
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Import Existing Wallet
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { WalletManager } from '@zubari/sdk';
|
|
68
|
+
|
|
69
|
+
const wallet = new WalletManager({ network: 'testnet' });
|
|
70
|
+
|
|
71
|
+
// Import from seed phrase
|
|
72
|
+
const { address } = await wallet.importWallet(
|
|
73
|
+
'your twelve word seed phrase goes here ...',
|
|
74
|
+
'your-secure-password'
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// Unlock and derive all addresses
|
|
78
|
+
await wallet.unlock('your-secure-password');
|
|
79
|
+
const addresses = await wallet.deriveAllAddressesWithWdk();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### React Hook Usage
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { useWalletManager } from '@zubari/sdk/react';
|
|
86
|
+
|
|
87
|
+
function WalletComponent() {
|
|
88
|
+
const {
|
|
89
|
+
state,
|
|
90
|
+
createWallet,
|
|
91
|
+
unlock,
|
|
92
|
+
lock,
|
|
93
|
+
deriveAllAddresses,
|
|
94
|
+
} = useWalletManager({ network: 'testnet' });
|
|
95
|
+
|
|
96
|
+
const handleCreate = async () => {
|
|
97
|
+
const { seed, address } = await createWallet('password123');
|
|
98
|
+
console.log('Created wallet:', address);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div>
|
|
103
|
+
<p>Status: {state.isLocked ? 'Locked' : 'Unlocked'}</p>
|
|
104
|
+
<p>Address: {state.address}</p>
|
|
105
|
+
<button onClick={handleCreate}>Create Wallet</button>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## API Reference
|
|
112
|
+
|
|
113
|
+
### WalletManager
|
|
114
|
+
|
|
115
|
+
The main class for wallet operations.
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { WalletManager } from '@zubari/sdk';
|
|
119
|
+
|
|
120
|
+
const wallet = new WalletManager({
|
|
121
|
+
network: 'testnet' | 'mainnet',
|
|
122
|
+
rpcUrl?: string, // Custom RPC URL
|
|
123
|
+
enabledChains?: string[], // Chains to enable
|
|
124
|
+
apiUrl?: string, // Backend API URL (optional)
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Methods
|
|
129
|
+
|
|
130
|
+
| Method | Description | Returns |
|
|
131
|
+
|--------|-------------|---------|
|
|
132
|
+
| `createWallet(password)` | Create new wallet with encrypted seed | `{ seed, address }` |
|
|
133
|
+
| `importWallet(seed, password)` | Import existing seed phrase | `{ address }` |
|
|
134
|
+
| `unlock(password)` | Unlock wallet | `{ address }` |
|
|
135
|
+
| `lock()` | Lock wallet (clear seed from memory) | `void` |
|
|
136
|
+
| `deleteWallet()` | Delete wallet from storage | `Promise<void>` |
|
|
137
|
+
| `deriveAllAddressesWithWdk()` | Derive real addresses using WDK | `MultiChainAddresses` |
|
|
138
|
+
| `deriveAllAddressesAsync()` | Derive with fallback strategies | `MultiChainAddresses` |
|
|
139
|
+
| `fetchBalance()` | Get ETH balance | `string` |
|
|
140
|
+
| `getState()` | Get wallet state | `WalletState` |
|
|
141
|
+
|
|
142
|
+
### ZubariWallet
|
|
143
|
+
|
|
144
|
+
High-level wallet class with multi-chain transaction support.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { ZubariWallet } from '@zubari/sdk';
|
|
148
|
+
|
|
149
|
+
const zubariWallet = new ZubariWallet({
|
|
150
|
+
seed: 'your seed phrase',
|
|
151
|
+
network: 'testnet',
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Send ETH
|
|
155
|
+
const tx = await zubariWallet.sendEth({
|
|
156
|
+
to: '0x...',
|
|
157
|
+
amount: '0.1',
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// Send Bitcoin
|
|
161
|
+
const btcTx = await zubariWallet.sendBitcoin({
|
|
162
|
+
to: 'tb1q...',
|
|
163
|
+
amount: '0.001',
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### WdkService
|
|
168
|
+
|
|
169
|
+
Native Tether WDK integration for address derivation.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { WdkService } from '@zubari/sdk/services';
|
|
173
|
+
|
|
174
|
+
const wdk = new WdkService({ network: 'testnet' });
|
|
175
|
+
|
|
176
|
+
// Generate seed phrase
|
|
177
|
+
const seed = await wdk.generateSeedPhrase();
|
|
178
|
+
|
|
179
|
+
// Initialize and derive addresses
|
|
180
|
+
await wdk.initialize(seed);
|
|
181
|
+
const addresses = await wdk.deriveAllAddresses();
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Protocols
|
|
185
|
+
|
|
186
|
+
Creator economy protocols for monetization.
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import {
|
|
190
|
+
ZubariNFTProtocol,
|
|
191
|
+
ZubariTipsProtocol,
|
|
192
|
+
ZubariSubscriptionProtocol,
|
|
193
|
+
ZubariPayoutsProtocol,
|
|
194
|
+
} from '@zubari/sdk/protocols';
|
|
195
|
+
|
|
196
|
+
// NFT Protocol - Lazy minting with EIP-712 signatures
|
|
197
|
+
const nft = new ZubariNFTProtocol(wallet, config);
|
|
198
|
+
const voucher = await nft.createLazyMintVoucher(metadata);
|
|
199
|
+
const mintedNFT = await nft.redeemVoucher(voucher);
|
|
200
|
+
|
|
201
|
+
// Tips Protocol - Send tips to creators
|
|
202
|
+
const tips = new ZubariTipsProtocol(wallet, config);
|
|
203
|
+
await tips.sendTip({ to: '0x...', amount: '1.0', token: 'ETH' });
|
|
204
|
+
|
|
205
|
+
// Subscription Protocol
|
|
206
|
+
const subs = new ZubariSubscriptionProtocol(wallet, config);
|
|
207
|
+
await subs.subscribe(planId);
|
|
208
|
+
|
|
209
|
+
// Payouts Protocol
|
|
210
|
+
const payouts = new ZubariPayoutsProtocol(wallet, config);
|
|
211
|
+
await payouts.claimEarnings();
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Storage
|
|
215
|
+
|
|
216
|
+
Secure storage adapters for different platforms.
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
import {
|
|
220
|
+
createSecureStorage,
|
|
221
|
+
WebEncryptedStorageAdapter,
|
|
222
|
+
MemoryStorageAdapter,
|
|
223
|
+
} from '@zubari/sdk/storage';
|
|
224
|
+
|
|
225
|
+
// Auto-detect platform (Web, React Native, Node.js)
|
|
226
|
+
const storage = createSecureStorage();
|
|
227
|
+
|
|
228
|
+
// Or use specific adapter
|
|
229
|
+
const webStorage = new WebEncryptedStorageAdapter('app-prefix');
|
|
230
|
+
await webStorage.initialize('encryption-password');
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Utilities
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
import {
|
|
237
|
+
formatAddress,
|
|
238
|
+
formatBalance,
|
|
239
|
+
isValidAddress,
|
|
240
|
+
normalizeAddress,
|
|
241
|
+
} from '@zubari/sdk';
|
|
242
|
+
|
|
243
|
+
formatAddress('0x1234...5678'); // '0x1234...5678'
|
|
244
|
+
formatBalance(1000000000000000000n); // '1.0000'
|
|
245
|
+
isValidAddress('0x...'); // true/false
|
|
246
|
+
normalizeAddress('0xABC...'); // '0xabc...'
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Supported Chains
|
|
250
|
+
|
|
251
|
+
| Chain | Derivation Path | Address Format | Testnet |
|
|
252
|
+
|-------|-----------------|----------------|---------|
|
|
253
|
+
| Ethereum | m/44'/60'/0'/0/0 | 0x... | Sepolia |
|
|
254
|
+
| Bitcoin | m/84'/0'/0'/0/0 | bc1q.../tb1q... | Testnet |
|
|
255
|
+
| TON | m/44'/607'/0' | UQ.../EQ... | Testnet |
|
|
256
|
+
| TRON | m/44'/195'/0'/0/0 | T... | Shasta |
|
|
257
|
+
| Solana | m/44'/501'/0'/0' | Base58 | Devnet |
|
|
258
|
+
| Spark | m/44'/998'/0'/0/0 | sp1... | Testnet |
|
|
259
|
+
|
|
260
|
+
## Security
|
|
261
|
+
|
|
262
|
+
- **AES-256-GCM** encryption for seed storage
|
|
263
|
+
- **PBKDF2** key derivation (100,000 iterations)
|
|
264
|
+
- Seeds cleared from memory on lock
|
|
265
|
+
- Platform-native secure storage (Keychain/Keystore)
|
|
266
|
+
- No private keys transmitted over network
|
|
267
|
+
|
|
268
|
+
## Requirements
|
|
269
|
+
|
|
270
|
+
- Node.js >= 18.0.0
|
|
271
|
+
- React >= 18.0.0 (for React hooks, optional)
|
|
272
|
+
|
|
273
|
+
## TypeScript Support
|
|
274
|
+
|
|
275
|
+
Full TypeScript support with exported types:
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
import type {
|
|
279
|
+
WalletState,
|
|
280
|
+
WalletManagerConfig,
|
|
281
|
+
NetworkType,
|
|
282
|
+
MultiChainAddresses,
|
|
283
|
+
NFTMetadata,
|
|
284
|
+
LazyMintVoucher,
|
|
285
|
+
TipData,
|
|
286
|
+
SubscriptionPlan,
|
|
287
|
+
SwapQuote,
|
|
288
|
+
} from '@zubari/sdk';
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Subpath Exports
|
|
292
|
+
|
|
293
|
+
Import specific modules for better tree-shaking:
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
// Core wallet only
|
|
297
|
+
import { WalletManager } from '@zubari/sdk/wallet';
|
|
298
|
+
|
|
299
|
+
// Protocols only
|
|
300
|
+
import { ZubariNFTProtocol } from '@zubari/sdk/protocols';
|
|
301
|
+
|
|
302
|
+
// Services only
|
|
303
|
+
import { WdkService } from '@zubari/sdk/services';
|
|
304
|
+
|
|
305
|
+
// Storage only
|
|
306
|
+
import { createSecureStorage } from '@zubari/sdk/storage';
|
|
307
|
+
|
|
308
|
+
// React hooks only
|
|
309
|
+
import { useWalletManager } from '@zubari/sdk/react';
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Contributing
|
|
313
|
+
|
|
314
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
315
|
+
|
|
316
|
+
## License
|
|
317
|
+
|
|
318
|
+
MIT - see [LICENSE](LICENSE) for details.
|
|
319
|
+
|
|
320
|
+
## Links
|
|
321
|
+
|
|
322
|
+
- [GitHub Repository](https://github.com/anthropics/zubari-wallet)
|
|
323
|
+
- [Documentation](https://docs.zubari.io)
|
|
324
|
+
- [Tether WDK](https://docs.wallet.tether.io)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secure Storage Interface
|
|
3
|
+
* Platform-agnostic interface for secure key storage
|
|
4
|
+
*/
|
|
5
|
+
interface SecureStorageAdapter {
|
|
6
|
+
/**
|
|
7
|
+
* Store a value securely
|
|
8
|
+
*/
|
|
9
|
+
setItem(key: string, value: string): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieve a value
|
|
12
|
+
*/
|
|
13
|
+
getItem(key: string): Promise<string | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Remove a value
|
|
16
|
+
*/
|
|
17
|
+
removeItem(key: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a key exists
|
|
20
|
+
*/
|
|
21
|
+
hasItem(key: string): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Clear all stored values
|
|
24
|
+
*/
|
|
25
|
+
clear(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* iOS Keychain Storage Adapter
|
|
29
|
+
* Uses react-native-keychain for iOS Keychain access
|
|
30
|
+
*/
|
|
31
|
+
declare class KeychainStorageAdapter implements SecureStorageAdapter {
|
|
32
|
+
private serviceName;
|
|
33
|
+
constructor(serviceName?: string);
|
|
34
|
+
setItem(key: string, value: string): Promise<void>;
|
|
35
|
+
getItem(key: string): Promise<string | null>;
|
|
36
|
+
removeItem(key: string): Promise<void>;
|
|
37
|
+
hasItem(key: string): Promise<boolean>;
|
|
38
|
+
clear(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Android Keystore Storage Adapter
|
|
42
|
+
* Uses Android Keystore for secure storage
|
|
43
|
+
*/
|
|
44
|
+
declare class KeystoreStorageAdapter implements SecureStorageAdapter {
|
|
45
|
+
private alias;
|
|
46
|
+
constructor(alias?: string);
|
|
47
|
+
setItem(key: string, value: string): Promise<void>;
|
|
48
|
+
getItem(key: string): Promise<string | null>;
|
|
49
|
+
removeItem(key: string): Promise<void>;
|
|
50
|
+
hasItem(key: string): Promise<boolean>;
|
|
51
|
+
clear(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Web Encrypted LocalStorage Adapter
|
|
55
|
+
* Uses Web Crypto API for encryption with localStorage
|
|
56
|
+
*/
|
|
57
|
+
declare class WebEncryptedStorageAdapter implements SecureStorageAdapter {
|
|
58
|
+
private encryptionKey;
|
|
59
|
+
private storagePrefix;
|
|
60
|
+
constructor(storagePrefix?: string);
|
|
61
|
+
/**
|
|
62
|
+
* Initialize with a password-derived key
|
|
63
|
+
*/
|
|
64
|
+
initialize(password: string): Promise<void>;
|
|
65
|
+
private getSalt;
|
|
66
|
+
setItem(key: string, value: string): Promise<void>;
|
|
67
|
+
getItem(key: string): Promise<string | null>;
|
|
68
|
+
removeItem(key: string): Promise<void>;
|
|
69
|
+
hasItem(key: string): Promise<boolean>;
|
|
70
|
+
clear(): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* In-Memory Storage Adapter (for testing)
|
|
74
|
+
*/
|
|
75
|
+
declare class MemoryStorageAdapter implements SecureStorageAdapter {
|
|
76
|
+
private storage;
|
|
77
|
+
setItem(key: string, value: string): Promise<void>;
|
|
78
|
+
getItem(key: string): Promise<string | null>;
|
|
79
|
+
removeItem(key: string): Promise<void>;
|
|
80
|
+
hasItem(key: string): Promise<boolean>;
|
|
81
|
+
clear(): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Secure Storage Factory
|
|
85
|
+
* Creates appropriate storage adapter based on platform
|
|
86
|
+
*/
|
|
87
|
+
declare function createSecureStorage(): SecureStorageAdapter;
|
|
88
|
+
|
|
89
|
+
export { KeychainStorageAdapter as K, MemoryStorageAdapter as M, type SecureStorageAdapter as S, WebEncryptedStorageAdapter as W, KeystoreStorageAdapter as a, createSecureStorage as c };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secure Storage Interface
|
|
3
|
+
* Platform-agnostic interface for secure key storage
|
|
4
|
+
*/
|
|
5
|
+
interface SecureStorageAdapter {
|
|
6
|
+
/**
|
|
7
|
+
* Store a value securely
|
|
8
|
+
*/
|
|
9
|
+
setItem(key: string, value: string): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieve a value
|
|
12
|
+
*/
|
|
13
|
+
getItem(key: string): Promise<string | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Remove a value
|
|
16
|
+
*/
|
|
17
|
+
removeItem(key: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a key exists
|
|
20
|
+
*/
|
|
21
|
+
hasItem(key: string): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Clear all stored values
|
|
24
|
+
*/
|
|
25
|
+
clear(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* iOS Keychain Storage Adapter
|
|
29
|
+
* Uses react-native-keychain for iOS Keychain access
|
|
30
|
+
*/
|
|
31
|
+
declare class KeychainStorageAdapter implements SecureStorageAdapter {
|
|
32
|
+
private serviceName;
|
|
33
|
+
constructor(serviceName?: string);
|
|
34
|
+
setItem(key: string, value: string): Promise<void>;
|
|
35
|
+
getItem(key: string): Promise<string | null>;
|
|
36
|
+
removeItem(key: string): Promise<void>;
|
|
37
|
+
hasItem(key: string): Promise<boolean>;
|
|
38
|
+
clear(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Android Keystore Storage Adapter
|
|
42
|
+
* Uses Android Keystore for secure storage
|
|
43
|
+
*/
|
|
44
|
+
declare class KeystoreStorageAdapter implements SecureStorageAdapter {
|
|
45
|
+
private alias;
|
|
46
|
+
constructor(alias?: string);
|
|
47
|
+
setItem(key: string, value: string): Promise<void>;
|
|
48
|
+
getItem(key: string): Promise<string | null>;
|
|
49
|
+
removeItem(key: string): Promise<void>;
|
|
50
|
+
hasItem(key: string): Promise<boolean>;
|
|
51
|
+
clear(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Web Encrypted LocalStorage Adapter
|
|
55
|
+
* Uses Web Crypto API for encryption with localStorage
|
|
56
|
+
*/
|
|
57
|
+
declare class WebEncryptedStorageAdapter implements SecureStorageAdapter {
|
|
58
|
+
private encryptionKey;
|
|
59
|
+
private storagePrefix;
|
|
60
|
+
constructor(storagePrefix?: string);
|
|
61
|
+
/**
|
|
62
|
+
* Initialize with a password-derived key
|
|
63
|
+
*/
|
|
64
|
+
initialize(password: string): Promise<void>;
|
|
65
|
+
private getSalt;
|
|
66
|
+
setItem(key: string, value: string): Promise<void>;
|
|
67
|
+
getItem(key: string): Promise<string | null>;
|
|
68
|
+
removeItem(key: string): Promise<void>;
|
|
69
|
+
hasItem(key: string): Promise<boolean>;
|
|
70
|
+
clear(): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* In-Memory Storage Adapter (for testing)
|
|
74
|
+
*/
|
|
75
|
+
declare class MemoryStorageAdapter implements SecureStorageAdapter {
|
|
76
|
+
private storage;
|
|
77
|
+
setItem(key: string, value: string): Promise<void>;
|
|
78
|
+
getItem(key: string): Promise<string | null>;
|
|
79
|
+
removeItem(key: string): Promise<void>;
|
|
80
|
+
hasItem(key: string): Promise<boolean>;
|
|
81
|
+
clear(): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Secure Storage Factory
|
|
85
|
+
* Creates appropriate storage adapter based on platform
|
|
86
|
+
*/
|
|
87
|
+
declare function createSecureStorage(): SecureStorageAdapter;
|
|
88
|
+
|
|
89
|
+
export { KeychainStorageAdapter as K, MemoryStorageAdapter as M, type SecureStorageAdapter as S, WebEncryptedStorageAdapter as W, KeystoreStorageAdapter as a, createSecureStorage as c };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { S as SwapQuote, T as TxResult } from './index-BLuxEdLp.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SwapService - DEX integration via Velora
|
|
5
|
+
*
|
|
6
|
+
* Handles token swaps with slippage protection,
|
|
7
|
+
* quote fetching, and earnings conversion.
|
|
8
|
+
*/
|
|
9
|
+
declare class SwapService {
|
|
10
|
+
private readonly _chainId;
|
|
11
|
+
private readonly isTestnet;
|
|
12
|
+
constructor(chainId: number, isTestnet?: boolean);
|
|
13
|
+
/**
|
|
14
|
+
* Get a swap quote
|
|
15
|
+
*/
|
|
16
|
+
getQuote(tokenIn: string, tokenOut: string, amountIn: bigint): Promise<SwapQuote>;
|
|
17
|
+
/**
|
|
18
|
+
* Execute a swap with slippage protection
|
|
19
|
+
*/
|
|
20
|
+
executeSwap(quote: SwapQuote, slippageToleranceBps?: number): Promise<TxResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Convert earnings to USDT, keeping some ETH for gas
|
|
23
|
+
*/
|
|
24
|
+
convertEarningsToStable(ethBalance: bigint, reserveForGas?: bigint): Promise<TxResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a swap route exists
|
|
27
|
+
*/
|
|
28
|
+
hasRoute(tokenIn: string, tokenOut: string): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Get supported tokens for swapping
|
|
31
|
+
*/
|
|
32
|
+
getSupportedTokens(): Promise<string[]>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { SwapService as S };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { S as SwapQuote, T as TxResult } from './index-BLuxEdLp.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SwapService - DEX integration via Velora
|
|
5
|
+
*
|
|
6
|
+
* Handles token swaps with slippage protection,
|
|
7
|
+
* quote fetching, and earnings conversion.
|
|
8
|
+
*/
|
|
9
|
+
declare class SwapService {
|
|
10
|
+
private readonly _chainId;
|
|
11
|
+
private readonly isTestnet;
|
|
12
|
+
constructor(chainId: number, isTestnet?: boolean);
|
|
13
|
+
/**
|
|
14
|
+
* Get a swap quote
|
|
15
|
+
*/
|
|
16
|
+
getQuote(tokenIn: string, tokenOut: string, amountIn: bigint): Promise<SwapQuote>;
|
|
17
|
+
/**
|
|
18
|
+
* Execute a swap with slippage protection
|
|
19
|
+
*/
|
|
20
|
+
executeSwap(quote: SwapQuote, slippageToleranceBps?: number): Promise<TxResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Convert earnings to USDT, keeping some ETH for gas
|
|
23
|
+
*/
|
|
24
|
+
convertEarningsToStable(ethBalance: bigint, reserveForGas?: bigint): Promise<TxResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a swap route exists
|
|
27
|
+
*/
|
|
28
|
+
hasRoute(tokenIn: string, tokenOut: string): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Get supported tokens for swapping
|
|
31
|
+
*/
|
|
32
|
+
getSupportedTokens(): Promise<string[]>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { SwapService as S };
|