cilantro-sdk 0.0.4 → 0.0.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 CHANGED
@@ -83,6 +83,73 @@ configure({ apiKey: 'your-api-key' });
83
83
  const result = await sendSOL('wallet-id', { ... });
84
84
  ```
85
85
 
86
+ ## Helpers Module (Device Keys & Signer Management)
87
+
88
+ The SDK includes a comprehensive helpers module for device key management and signer operations with automatic caching. This simplifies working with email/phone signers and eliminates manual key management.
89
+
90
+ ### Quick Example
91
+
92
+ ```typescript
93
+ import {
94
+ createEmailSignerHelper,
95
+ getEmailSignerKeypair,
96
+ createLocalStorageAdapter
97
+ } from 'cilantro-sdk/helpers';
98
+
99
+ // Create storage for device keys
100
+ const storage = createLocalStorageAdapter();
101
+
102
+ // Create email signer (device key generated automatically)
103
+ const signer = await createEmailSignerHelper('wallet-id', {
104
+ email: 'user@example.com',
105
+ deviceKeyManager: storage
106
+ });
107
+
108
+ // Get keypair (automatically cached)
109
+ const keypair = await getEmailSignerKeypair(
110
+ 'wallet-id',
111
+ signer.signerId,
112
+ { deviceKeyManager: storage }
113
+ );
114
+ ```
115
+
116
+ ### Key Features
117
+
118
+ - ✅ **Unified API** - Single interface for all key and signer operations
119
+ - ✅ **Automatic Caching** - Keypair derivation is cached to avoid redundant operations
120
+ - ✅ **Cross-Platform** - Works in browser and Node.js
121
+ - ✅ **Storage Adapters** - localStorage, filesystem, or memory storage
122
+ - ✅ **Type-Safe** - Full TypeScript support
123
+ - ✅ **Functional** - No classes, pure functions
124
+
125
+ ### Available Helpers
126
+
127
+ **Device Key Management:**
128
+ - `getDevicePublicKey()` - Get or create device key with caching
129
+ - `generateDeviceKeyPair()` - Generate new device key pair
130
+ - `rotateDeviceKey()` - Rotate device keys
131
+ - `clearDeviceKeyCache()` - Clear cache
132
+
133
+ **Email Signer Helpers:**
134
+ - `createEmailSignerHelper()` - Create email signer with auto key management
135
+ - `getEmailSignerKeypair()` - Get keypair with caching
136
+ - `signWithEmailSigner()` - Sign messages
137
+ - `clearEmailSignerCache()` - Clear cache
138
+
139
+ **Phone Signer Helpers:**
140
+ - `createPhoneSignerHelper()` - Create phone signer with auto key management
141
+ - `getPhoneSignerKeypair()` - Get keypair with caching
142
+ - `signWithPhoneSigner()` - Sign messages
143
+ - `clearPhoneSignerCache()` - Clear cache
144
+
145
+ **Storage Adapters:**
146
+ - `createLocalStorageAdapter()` - Browser localStorage
147
+ - `createFileSystemAdapter(path)` - Node.js filesystem
148
+ - `createMemoryAdapter()` - In-memory (temporary)
149
+ - `getDefaultStorageAdapter()` - Auto-detect environment
150
+
151
+ For complete documentation, see [HELPERS_README.md](./HELPERS_README.md).
152
+
86
153
  ## Configuration
87
154
 
88
155
  ### SDK Configuration Functions