@lumiapassport/core 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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Lumia
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,112 @@
1
+ # @lumiapassport/core
2
+
3
+ Framework-agnostic core SDK for Lumia Passport smart accounts.
4
+
5
+ ## Features
6
+
7
+ - ✅ **Zero React dependencies** - Works in Node.js, browser, and edge functions
8
+ - ✅ **TypeScript-first** - Full type safety
9
+ - ✅ **Modular** - Import only what you need
10
+ - ✅ **Storage abstraction** - Works with localStorage, Redis, memory, or custom storage
11
+ - ✅ **Account Abstraction** - Full ERC-4337 support
12
+ - ✅ **MPC/TSS** - Secure key management
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @lumiapassport/core viem
18
+ # or
19
+ pnpm add @lumiapassport/core viem
20
+ # or
21
+ yarn add @lumiapassport/core viem
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Backend (Node.js)
27
+
28
+ ```typescript
29
+ import { createLumiaPassportCore, MemoryStorage } from '@lumiapassport/core';
30
+
31
+ const core = createLumiaPassportCore({
32
+ tssUrl: process.env.LUMIA_TSS_URL,
33
+ bundlerUrl: process.env.LUMIA_BUNDLER_URL,
34
+ chainId: 2030232745,
35
+ tokenStorage: new MemoryStorage(),
36
+ keyshareStorage: new MemoryStorage(),
37
+ });
38
+
39
+ // Create server wallet
40
+ const account = await core.account.createAccountSession({
41
+ mpcUserId: 'server-wallet-001',
42
+ usePaymaster: true,
43
+ });
44
+
45
+ // Send transaction
46
+ const hash = await core.account.sendUserOperation(
47
+ account,
48
+ '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
49
+ '1000000000000000000' // 1 ETH in wei
50
+ );
51
+ ```
52
+
53
+ ### Frontend (Browser)
54
+
55
+ ```typescript
56
+ import { createLumiaPassportCore, LocalStorageAdapter } from '@lumiapassport/core';
57
+
58
+ const core = createLumiaPassportCore({
59
+ tssUrl: import.meta.env.VITE_LUMIA_TSS_URL,
60
+ bundlerUrl: import.meta.env.VITE_LUMIA_BUNDLER_URL,
61
+ tokenStorage: new LocalStorageAdapter(),
62
+ keyshareStorage: new LocalStorageAdapter(),
63
+ });
64
+
65
+ // Prepare UserOperation
66
+ const signedOp = await core.bundler.prepareUserOperation(params);
67
+
68
+ // Send to backend
69
+ await fetch('/api/submit', {
70
+ method: 'POST',
71
+ body: JSON.stringify({ userOp: signedOp }),
72
+ });
73
+ ```
74
+
75
+ ### JWT Verification
76
+
77
+ ```typescript
78
+ import { createLumiaPassportCore } from '@lumiapassport/core';
79
+
80
+ const core = createLumiaPassportCore({ tssUrl: process.env.LUMIA_TSS_URL });
81
+
82
+ // Verify token
83
+ const verification = await core.auth.verifyToken(token);
84
+
85
+ if (verification.valid) {
86
+ console.log('User ID:', verification.userId);
87
+ }
88
+ ```
89
+
90
+ ## API
91
+
92
+ ### Modules
93
+
94
+ - **bundler** - UserOperation management
95
+ - **auth** - JWT token management and verification
96
+ - **clients** - HTTP clients and account management
97
+ - **mpc** - MPC/TSS operations
98
+ - **utils** - Helper utilities
99
+
100
+ ### Storage Adapters
101
+
102
+ - `MemoryStorage` - In-memory storage (server)
103
+ - `LocalStorageAdapter` - Browser localStorage
104
+ - Custom adapters via `TokenStorage` interface
105
+
106
+ ## Examples
107
+
108
+ See [USAGE_EXAMPLES.md](../../USAGE_EXAMPLES.md) for comprehensive examples.
109
+
110
+ ## License
111
+
112
+ MIT