@zerodev/wallet-core 0.0.1-alpha.3
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 +272 -0
- package/dist/_cjs/actions/auth/authenticateWithEmail.js +17 -0
- package/dist/_cjs/actions/auth/authenticateWithEmail.js.map +1 -0
- package/dist/_cjs/actions/auth/authenticateWithOAuth.js +17 -0
- package/dist/_cjs/actions/auth/authenticateWithOAuth.js.map +1 -0
- package/dist/_cjs/actions/auth/getWhoami.js +15 -0
- package/dist/_cjs/actions/auth/getWhoami.js.map +1 -0
- package/dist/_cjs/actions/auth/index.js +18 -0
- package/dist/_cjs/actions/auth/index.js.map +1 -0
- package/dist/_cjs/actions/auth/loginWithOTP.js +17 -0
- package/dist/_cjs/actions/auth/loginWithOTP.js.map +1 -0
- package/dist/_cjs/actions/auth/loginWithStamp.js +29 -0
- package/dist/_cjs/actions/auth/loginWithStamp.js.map +1 -0
- package/dist/_cjs/actions/auth/registerWithOTP.js +17 -0
- package/dist/_cjs/actions/auth/registerWithOTP.js.map +1 -0
- package/dist/_cjs/actions/auth/registerWithPasskey.js +17 -0
- package/dist/_cjs/actions/auth/registerWithPasskey.js.map +1 -0
- package/dist/_cjs/actions/index.js +15 -0
- package/dist/_cjs/actions/index.js.map +1 -0
- package/dist/_cjs/actions/wallet/getUserWallet.js +13 -0
- package/dist/_cjs/actions/wallet/getUserWallet.js.map +1 -0
- package/dist/_cjs/actions/wallet/index.js +10 -0
- package/dist/_cjs/actions/wallet/index.js.map +1 -0
- package/dist/_cjs/actions/wallet/signRawPayload.js +26 -0
- package/dist/_cjs/actions/wallet/signRawPayload.js.map +1 -0
- package/dist/_cjs/actions/wallet/signTransaction.js +25 -0
- package/dist/_cjs/actions/wallet/signTransaction.js.map +1 -0
- package/dist/_cjs/adapters/viem.js +89 -0
- package/dist/_cjs/adapters/viem.js.map +1 -0
- package/dist/_cjs/client/createClient.js +45 -0
- package/dist/_cjs/client/createClient.js.map +1 -0
- package/dist/_cjs/client/decorators/client.js +21 -0
- package/dist/_cjs/client/decorators/client.js.map +1 -0
- package/dist/_cjs/client/index.js +9 -0
- package/dist/_cjs/client/index.js.map +1 -0
- package/dist/_cjs/client/transports/createTransport.js +29 -0
- package/dist/_cjs/client/transports/createTransport.js.map +1 -0
- package/dist/_cjs/client/transports/rest.js +86 -0
- package/dist/_cjs/client/transports/rest.js.map +1 -0
- package/dist/_cjs/client/types.js +3 -0
- package/dist/_cjs/client/types.js.map +1 -0
- package/dist/_cjs/constants.js +9 -0
- package/dist/_cjs/constants.js.map +1 -0
- package/dist/_cjs/core/createZeroDevWallet.js +330 -0
- package/dist/_cjs/core/createZeroDevWallet.js.map +1 -0
- package/dist/_cjs/errors/request.js +61 -0
- package/dist/_cjs/errors/request.js.map +1 -0
- package/dist/_cjs/index.js +31 -0
- package/dist/_cjs/index.js.map +1 -0
- package/dist/_cjs/package.json +1 -0
- package/dist/_cjs/polyfills/window.js +26 -0
- package/dist/_cjs/polyfills/window.js.map +1 -0
- package/dist/_cjs/stampers/iframeStamper.js +32 -0
- package/dist/_cjs/stampers/iframeStamper.js.map +1 -0
- package/dist/_cjs/stampers/index.js +10 -0
- package/dist/_cjs/stampers/index.js.map +1 -0
- package/dist/_cjs/stampers/indexedDbStamper.js +23 -0
- package/dist/_cjs/stampers/indexedDbStamper.js.map +1 -0
- package/dist/_cjs/stampers/types.js +3 -0
- package/dist/_cjs/stampers/types.js.map +1 -0
- package/dist/_cjs/stampers/webauthnStamper.js +17 -0
- package/dist/_cjs/stampers/webauthnStamper.js.map +1 -0
- package/dist/_cjs/storage/adapters.js +18 -0
- package/dist/_cjs/storage/adapters.js.map +1 -0
- package/dist/_cjs/storage/manager.js +108 -0
- package/dist/_cjs/storage/manager.js.map +1 -0
- package/dist/_cjs/types/session.js +9 -0
- package/dist/_cjs/types/session.js.map +1 -0
- package/dist/_cjs/utils/exportWallet.js +70 -0
- package/dist/_cjs/utils/exportWallet.js.map +1 -0
- package/dist/_cjs/utils/utils.js +75 -0
- package/dist/_cjs/utils/utils.js.map +1 -0
- package/dist/_esm/actions/auth/authenticateWithEmail.js +18 -0
- package/dist/_esm/actions/auth/authenticateWithEmail.js.map +1 -0
- package/dist/_esm/actions/auth/authenticateWithOAuth.js +31 -0
- package/dist/_esm/actions/auth/authenticateWithOAuth.js.map +1 -0
- package/dist/_esm/actions/auth/getWhoami.js +28 -0
- package/dist/_esm/actions/auth/getWhoami.js.map +1 -0
- package/dist/_esm/actions/auth/index.js +8 -0
- package/dist/_esm/actions/auth/index.js.map +1 -0
- package/dist/_esm/actions/auth/loginWithOTP.js +36 -0
- package/dist/_esm/actions/auth/loginWithOTP.js.map +1 -0
- package/dist/_esm/actions/auth/loginWithStamp.js +42 -0
- package/dist/_esm/actions/auth/loginWithStamp.js.map +1 -0
- package/dist/_esm/actions/auth/registerWithOTP.js +36 -0
- package/dist/_esm/actions/auth/registerWithOTP.js.map +1 -0
- package/dist/_esm/actions/auth/registerWithPasskey.js +36 -0
- package/dist/_esm/actions/auth/registerWithPasskey.js.map +1 -0
- package/dist/_esm/actions/index.js +5 -0
- package/dist/_esm/actions/index.js.map +1 -0
- package/dist/_esm/actions/wallet/getUserWallet.js +26 -0
- package/dist/_esm/actions/wallet/getUserWallet.js.map +1 -0
- package/dist/_esm/actions/wallet/index.js +4 -0
- package/dist/_esm/actions/wallet/index.js.map +1 -0
- package/dist/_esm/actions/wallet/signRawPayload.js +41 -0
- package/dist/_esm/actions/wallet/signRawPayload.js.map +1 -0
- package/dist/_esm/actions/wallet/signTransaction.js +40 -0
- package/dist/_esm/actions/wallet/signTransaction.js.map +1 -0
- package/dist/_esm/adapters/viem.js +91 -0
- package/dist/_esm/adapters/viem.js.map +1 -0
- package/dist/_esm/client/createClient.js +56 -0
- package/dist/_esm/client/createClient.js.map +1 -0
- package/dist/_esm/client/decorators/client.js +42 -0
- package/dist/_esm/client/decorators/client.js.map +1 -0
- package/dist/_esm/client/index.js +3 -0
- package/dist/_esm/client/index.js.map +1 -0
- package/dist/_esm/client/transports/createTransport.js +31 -0
- package/dist/_esm/client/transports/createTransport.js.map +1 -0
- package/dist/_esm/client/transports/rest.js +85 -0
- package/dist/_esm/client/transports/rest.js.map +1 -0
- package/dist/_esm/client/types.js +2 -0
- package/dist/_esm/client/types.js.map +1 -0
- package/dist/_esm/constants.js +6 -0
- package/dist/_esm/constants.js.map +1 -0
- package/dist/_esm/core/createZeroDevWallet.js +332 -0
- package/dist/_esm/core/createZeroDevWallet.js.map +1 -0
- package/dist/_esm/errors/request.js +60 -0
- package/dist/_esm/errors/request.js.map +1 -0
- package/dist/_esm/index.js +20 -0
- package/dist/_esm/index.js.map +1 -0
- package/dist/_esm/package.json +1 -0
- package/dist/_esm/polyfills/window.js +24 -0
- package/dist/_esm/polyfills/window.js.map +1 -0
- package/dist/_esm/stampers/iframeStamper.js +29 -0
- package/dist/_esm/stampers/iframeStamper.js.map +1 -0
- package/dist/_esm/stampers/index.js +4 -0
- package/dist/_esm/stampers/index.js.map +1 -0
- package/dist/_esm/stampers/indexedDbStamper.js +20 -0
- package/dist/_esm/stampers/indexedDbStamper.js.map +1 -0
- package/dist/_esm/stampers/types.js +2 -0
- package/dist/_esm/stampers/types.js.map +1 -0
- package/dist/_esm/stampers/webauthnStamper.js +15 -0
- package/dist/_esm/stampers/webauthnStamper.js.map +1 -0
- package/dist/_esm/storage/adapters.js +15 -0
- package/dist/_esm/storage/adapters.js.map +1 -0
- package/dist/_esm/storage/manager.js +118 -0
- package/dist/_esm/storage/manager.js.map +1 -0
- package/dist/_esm/types/session.js +6 -0
- package/dist/_esm/types/session.js.map +1 -0
- package/dist/_esm/utils/exportWallet.js +98 -0
- package/dist/_esm/utils/exportWallet.js.map +1 -0
- package/dist/_esm/utils/utils.js +105 -0
- package/dist/_esm/utils/utils.js.map +1 -0
- package/dist/_types/actions/auth/authenticateWithEmail.d.ts +33 -0
- package/dist/_types/actions/auth/authenticateWithEmail.d.ts.map +1 -0
- package/dist/_types/actions/auth/authenticateWithOAuth.d.ts +40 -0
- package/dist/_types/actions/auth/authenticateWithOAuth.d.ts.map +1 -0
- package/dist/_types/actions/auth/getWhoami.d.ts +35 -0
- package/dist/_types/actions/auth/getWhoami.d.ts.map +1 -0
- package/dist/_types/actions/auth/index.d.ts +8 -0
- package/dist/_types/actions/auth/index.d.ts.map +1 -0
- package/dist/_types/actions/auth/loginWithOTP.d.ts +41 -0
- package/dist/_types/actions/auth/loginWithOTP.d.ts.map +1 -0
- package/dist/_types/actions/auth/loginWithStamp.d.ts +35 -0
- package/dist/_types/actions/auth/loginWithStamp.d.ts.map +1 -0
- package/dist/_types/actions/auth/registerWithOTP.d.ts +52 -0
- package/dist/_types/actions/auth/registerWithOTP.d.ts.map +1 -0
- package/dist/_types/actions/auth/registerWithPasskey.d.ts +53 -0
- package/dist/_types/actions/auth/registerWithPasskey.d.ts.map +1 -0
- package/dist/_types/actions/index.d.ts +3 -0
- package/dist/_types/actions/index.d.ts.map +1 -0
- package/dist/_types/actions/wallet/getUserWallet.d.ts +32 -0
- package/dist/_types/actions/wallet/getUserWallet.d.ts.map +1 -0
- package/dist/_types/actions/wallet/index.d.ts +4 -0
- package/dist/_types/actions/wallet/index.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signRawPayload.d.ts +37 -0
- package/dist/_types/actions/wallet/signRawPayload.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signTransaction.d.ts +33 -0
- package/dist/_types/actions/wallet/signTransaction.d.ts.map +1 -0
- package/dist/_types/adapters/viem.d.ts +9 -0
- package/dist/_types/adapters/viem.d.ts.map +1 -0
- package/dist/_types/client/createClient.d.ts +18 -0
- package/dist/_types/client/createClient.d.ts.map +1 -0
- package/dist/_types/client/decorators/client.d.ts +73 -0
- package/dist/_types/client/decorators/client.d.ts.map +1 -0
- package/dist/_types/client/index.d.ts +4 -0
- package/dist/_types/client/index.d.ts.map +1 -0
- package/dist/_types/client/transports/createTransport.d.ts +17 -0
- package/dist/_types/client/transports/createTransport.d.ts.map +1 -0
- package/dist/_types/client/transports/rest.d.ts +30 -0
- package/dist/_types/client/transports/rest.d.ts.map +1 -0
- package/dist/_types/client/types.d.ts +60 -0
- package/dist/_types/client/types.d.ts.map +1 -0
- package/dist/_types/constants.d.ts +6 -0
- package/dist/_types/constants.d.ts.map +1 -0
- package/dist/_types/core/createZeroDevWallet.d.ts +55 -0
- package/dist/_types/core/createZeroDevWallet.d.ts.map +1 -0
- package/dist/_types/errors/request.d.ts +12 -0
- package/dist/_types/errors/request.d.ts.map +1 -0
- package/dist/_types/index.d.ts +17 -0
- package/dist/_types/index.d.ts.map +1 -0
- package/dist/_types/polyfills/window.d.ts +15 -0
- package/dist/_types/polyfills/window.d.ts.map +1 -0
- package/dist/_types/stampers/iframeStamper.d.ts +7 -0
- package/dist/_types/stampers/iframeStamper.d.ts.map +1 -0
- package/dist/_types/stampers/index.d.ts +5 -0
- package/dist/_types/stampers/index.d.ts.map +1 -0
- package/dist/_types/stampers/indexedDbStamper.d.ts +3 -0
- package/dist/_types/stampers/indexedDbStamper.d.ts.map +1 -0
- package/dist/_types/stampers/types.d.ts +23 -0
- package/dist/_types/stampers/types.d.ts.map +1 -0
- package/dist/_types/stampers/webauthnStamper.d.ts +5 -0
- package/dist/_types/stampers/webauthnStamper.d.ts.map +1 -0
- package/dist/_types/storage/adapters.d.ts +3 -0
- package/dist/_types/storage/adapters.d.ts.map +1 -0
- package/dist/_types/storage/manager.d.ts +19 -0
- package/dist/_types/storage/manager.d.ts.map +1 -0
- package/dist/_types/types/session.d.ts +17 -0
- package/dist/_types/types/session.d.ts.map +1 -0
- package/dist/_types/utils/exportWallet.d.ts +44 -0
- package/dist/_types/utils/exportWallet.d.ts.map +1 -0
- package/dist/_types/utils/utils.d.ts +52 -0
- package/dist/_types/utils/utils.d.ts.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +73 -0
- package/src/actions/auth/authenticateWithEmail.ts +52 -0
- package/src/actions/auth/authenticateWithOAuth.ts +58 -0
- package/src/actions/auth/getWhoami.ts +51 -0
- package/src/actions/auth/index.ts +40 -0
- package/src/actions/auth/loginWithOTP.ts +60 -0
- package/src/actions/auth/loginWithStamp.ts +68 -0
- package/src/actions/auth/registerWithOTP.ts +71 -0
- package/src/actions/auth/registerWithPasskey.ts +72 -0
- package/src/actions/index.ts +36 -0
- package/src/actions/wallet/getUserWallet.ts +46 -0
- package/src/actions/wallet/index.ts +17 -0
- package/src/actions/wallet/signRawPayload.ts +71 -0
- package/src/actions/wallet/signTransaction.ts +60 -0
- package/src/adapters/viem.ts +158 -0
- package/src/client/createClient.ts +95 -0
- package/src/client/decorators/client.ts +152 -0
- package/src/client/index.ts +12 -0
- package/src/client/transports/createTransport.ts +52 -0
- package/src/client/transports/rest.ts +121 -0
- package/src/client/types.ts +66 -0
- package/src/constants.ts +5 -0
- package/src/core/createZeroDevWallet.ts +477 -0
- package/src/errors/request.ts +36 -0
- package/src/index.ts +75 -0
- package/src/polyfills/window.ts +24 -0
- package/src/stampers/iframeStamper.ts +35 -0
- package/src/stampers/index.ts +8 -0
- package/src/stampers/indexedDbStamper.ts +22 -0
- package/src/stampers/types.ts +28 -0
- package/src/stampers/webauthnStamper.ts +21 -0
- package/src/storage/adapters.ts +20 -0
- package/src/storage/manager.ts +170 -0
- package/src/types/session.ts +18 -0
- package/src/utils/exportWallet.ts +124 -0
- package/src/utils/utils.ts +136 -0
package/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# @zerodev/wallet-core
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for managing wallet signing keys with Turnkey's non-custodial infrastructure.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Multiple authentication methods (Passkey, Email, OTP, OAuth)
|
|
8
|
+
- Non-custodial key management via Turnkey
|
|
9
|
+
- Automatic session refresh
|
|
10
|
+
- Multi-session support
|
|
11
|
+
- viem integration for Ethereum operations
|
|
12
|
+
- TypeScript with full type safety
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @zerodev/wallet-core
|
|
18
|
+
# or
|
|
19
|
+
yarn add @zerodev/wallet-core
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @zerodev/wallet-core
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { createZeroDevWallet } from '@zerodev/wallet-core';
|
|
28
|
+
|
|
29
|
+
// 1. Initialize the SDK
|
|
30
|
+
const wallet = await createZeroDevWallet({
|
|
31
|
+
projectId: 'your-project-id',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// 2. Authenticate with passkey
|
|
35
|
+
await wallet.auth({
|
|
36
|
+
type: 'passkey',
|
|
37
|
+
email: 'user@example.com',
|
|
38
|
+
mode: 'register' // or 'login' for existing users
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// 3. Get wallet account (viem LocalAccount)
|
|
42
|
+
const account = await wallet.toAccount();
|
|
43
|
+
console.log('Wallet address:', account.address);
|
|
44
|
+
|
|
45
|
+
// 4. Sign a message
|
|
46
|
+
const signature = await account.signMessage({
|
|
47
|
+
message: 'Hello World'
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// 5. Send a transaction
|
|
51
|
+
import { createWalletClient, http } from 'viem';
|
|
52
|
+
import { sepolia } from 'viem/chains';
|
|
53
|
+
|
|
54
|
+
const walletClient = createWalletClient({
|
|
55
|
+
account,
|
|
56
|
+
chain: sepolia,
|
|
57
|
+
transport: http()
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const hash = await walletClient.sendTransaction({
|
|
61
|
+
to: '0x...',
|
|
62
|
+
value: parseEther('0.001')
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Authentication Methods
|
|
67
|
+
|
|
68
|
+
### Passkey (WebAuthn)
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// Register new passkey
|
|
72
|
+
await wallet.auth({
|
|
73
|
+
type: 'passkey',
|
|
74
|
+
email: 'user@example.com',
|
|
75
|
+
mode: 'register'
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Login with existing passkey
|
|
79
|
+
await wallet.auth({
|
|
80
|
+
type: 'passkey',
|
|
81
|
+
email: 'user@example.com',
|
|
82
|
+
mode: 'login'
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Email Magic Link
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// Send magic link
|
|
90
|
+
await wallet.auth({
|
|
91
|
+
type: "otp",
|
|
92
|
+
mode: "sendOtp",
|
|
93
|
+
email: "user@example.com",
|
|
94
|
+
contact: { type: "email", contact: email },
|
|
95
|
+
emailCustomization: {
|
|
96
|
+
magicLinkTemplate: 'https://yourapp.com/verify?otp=%s'
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// After user clicks link, parse otp from url params
|
|
101
|
+
await wallet.auth({
|
|
102
|
+
type: "otp",
|
|
103
|
+
mode: "verifyOtp",
|
|
104
|
+
otpId,
|
|
105
|
+
otpCode: otp, // OTP from magic link url
|
|
106
|
+
subOrganizationId,
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Email OTP
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Step 1: Send OTP code
|
|
114
|
+
const data = await wallet.auth({
|
|
115
|
+
type: 'otp',
|
|
116
|
+
mode: 'sendOtp',
|
|
117
|
+
email: 'user@example.com',
|
|
118
|
+
contact: { type: 'email', contact: 'user@example.com' }
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Step 2: Verify OTP code
|
|
122
|
+
await wallet.auth({
|
|
123
|
+
type: 'otp',
|
|
124
|
+
mode: 'verifyOtp',
|
|
125
|
+
otpId: data.otpId,
|
|
126
|
+
otpCode: '123456',
|
|
127
|
+
subOrganizationId: data.subOrganizationId
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### OAuth (Google)
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
// After getting credential from Google OAuth
|
|
135
|
+
await wallet.auth({
|
|
136
|
+
type: 'oauth',
|
|
137
|
+
provider: 'google',
|
|
138
|
+
credential: googleCredential // JWT from Google
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Session Management
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
// Get active session
|
|
146
|
+
const session = await wallet.getSession();
|
|
147
|
+
console.log('Session expires:', new Date(session.expiry));
|
|
148
|
+
|
|
149
|
+
// Refresh session (extends expiry)
|
|
150
|
+
const newSession = await wallet.refreshSession();
|
|
151
|
+
|
|
152
|
+
// Get all sessions
|
|
153
|
+
const allSessions = await wallet.getAllSessions();
|
|
154
|
+
|
|
155
|
+
// Switch to different session
|
|
156
|
+
await wallet.switchSession(sessionId);
|
|
157
|
+
|
|
158
|
+
// Clear specific session
|
|
159
|
+
await wallet.clearSession(sessionId);
|
|
160
|
+
|
|
161
|
+
// Logout (clear all sessions)
|
|
162
|
+
await wallet.logout();
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Configuration Options
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
interface ZeroDevWalletConfig {
|
|
169
|
+
projectId: string; // Required: Your project ID
|
|
170
|
+
organizationId?: string; // Turnkey organization ID
|
|
171
|
+
proxyBaseUrl?: string; // KMS backend URL
|
|
172
|
+
iframeUrl?: string; // Turnkey iframe URL (default: auth.turnkey.com)
|
|
173
|
+
iframeContainer?: HTMLElement; // Custom iframe container
|
|
174
|
+
iframeElementId?: string; // Custom iframe element ID
|
|
175
|
+
sessionStorage?: StorageAdapter; // Custom storage (default: localStorage)
|
|
176
|
+
rpId?: string; // WebAuthn RP ID (default: window.location.hostname)
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Custom Storage
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { createZeroDevWallet, type StorageAdapter } from '@zerodev/wallet-core';
|
|
184
|
+
|
|
185
|
+
// Implement custom storage (e.g., IndexedDB, AsyncStorage)
|
|
186
|
+
const customStorage: StorageAdapter = {
|
|
187
|
+
getItem: async (key: string) => {
|
|
188
|
+
// Your implementation
|
|
189
|
+
return value;
|
|
190
|
+
},
|
|
191
|
+
setItem: async (key: string, value: string) => {
|
|
192
|
+
// Your implementation
|
|
193
|
+
},
|
|
194
|
+
removeItem: async (key: string) => {
|
|
195
|
+
// Your implementation
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const wallet = await createZeroDevWallet({
|
|
200
|
+
projectId: 'your-project-id',
|
|
201
|
+
sessionStorage: customStorage
|
|
202
|
+
});
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Export Wallet
|
|
206
|
+
|
|
207
|
+
Export your wallet's seed phrase using Turnkey's secure iframe:
|
|
208
|
+
|
|
209
|
+
**Setup:** Add a container element to your HTML:
|
|
210
|
+
```html
|
|
211
|
+
<div id="export-container"></div>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Usage:**
|
|
215
|
+
```typescript
|
|
216
|
+
import { createIframeStamper } from '@zerodev/wallet-core';
|
|
217
|
+
|
|
218
|
+
// 1. Create export iframe stamper
|
|
219
|
+
// IMPORTANT: Container element must exist in DOM first!
|
|
220
|
+
const exportIframeStamper = await createIframeStamper({
|
|
221
|
+
iframeUrl: 'https://export.turnkey.com',
|
|
222
|
+
iframeContainer: document.getElementById('export-container'),
|
|
223
|
+
iframeElementId: 'export-iframe'
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// 2. Initialize iframe and get target public key
|
|
227
|
+
const targetPublicKey = await exportIframeStamper.init();
|
|
228
|
+
|
|
229
|
+
// 3. Get encrypted export bundle from SDK
|
|
230
|
+
const { exportBundle, organizationId } = await wallet.exportWallet(targetPublicKey);
|
|
231
|
+
|
|
232
|
+
// 4. Inject into iframe to display seed phrase
|
|
233
|
+
await exportIframeStamper.injectWalletExportBundle(exportBundle, organizationId);
|
|
234
|
+
|
|
235
|
+
// The seed phrase is now visible in the 'export-container' div
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Note:** The SDK handles Turnkey API calls. The iframe handles secure decryption and display. The seed phrase never touches your JavaScript code.
|
|
239
|
+
|
|
240
|
+
## TypeScript Types
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import type {
|
|
244
|
+
ZeroDevWalletSDK,
|
|
245
|
+
ZeroDevWalletConfig,
|
|
246
|
+
ZeroDevWalletSession,
|
|
247
|
+
AuthParams,
|
|
248
|
+
StamperType,
|
|
249
|
+
ExportWalletParameters,
|
|
250
|
+
ExportWalletReturnType
|
|
251
|
+
} from '@zerodev/wallet-core';
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## React Integration
|
|
255
|
+
|
|
256
|
+
For React apps, see the demo implementation at [zerodev-wallet-demo](https://github.com/zerodevapp/zerodev-signer-demo).
|
|
257
|
+
|
|
258
|
+
Key patterns:
|
|
259
|
+
- Use React Context for SDK instance
|
|
260
|
+
- Handle session state with useState/useEffect
|
|
261
|
+
- Auto-refresh sessions in background
|
|
262
|
+
- Session expiry warnings
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
MIT
|
|
267
|
+
|
|
268
|
+
## Links
|
|
269
|
+
|
|
270
|
+
- [ZeroDev](https://zerodev.app)
|
|
271
|
+
- [Turnkey](https://turnkey.com)
|
|
272
|
+
- [GitHub](https://github.com/zerodevapp/doorway-kms-sdk)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authenticateWithEmail = authenticateWithEmail;
|
|
4
|
+
async function authenticateWithEmail(client, params) {
|
|
5
|
+
const { email, projectId, targetPublicKey, emailCustomization } = params;
|
|
6
|
+
return await client.request({
|
|
7
|
+
path: `${projectId}/auth/email-magic`,
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: {
|
|
10
|
+
email,
|
|
11
|
+
emailCustomization,
|
|
12
|
+
targetPublicKey,
|
|
13
|
+
projectId,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=authenticateWithEmail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticateWithEmail.js","sourceRoot":"","sources":["../../../../src/actions/auth/authenticateWithEmail.ts"],"names":[],"mappings":";;AAmCA,sDAgBC;AAhBM,KAAK,UAAU,qBAAqB,CACzC,MAAc,EACd,MAAuC;IAEvC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAA;IAExE,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,GAAG,SAAS,mBAAmB;QACrC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,KAAK;YACL,kBAAkB;YAClB,eAAe;YACf,SAAS;SACV;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authenticateWithOAuth = authenticateWithOAuth;
|
|
4
|
+
async function authenticateWithOAuth(client, params) {
|
|
5
|
+
const { oidcToken, provider, projectId, targetPublicKey } = params;
|
|
6
|
+
return await client.request({
|
|
7
|
+
path: `${projectId}/auth/oauth`,
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: {
|
|
10
|
+
oidcToken,
|
|
11
|
+
provider,
|
|
12
|
+
targetPublicKey,
|
|
13
|
+
projectId,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=authenticateWithOAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticateWithOAuth.js","sourceRoot":"","sources":["../../../../src/actions/auth/authenticateWithOAuth.ts"],"names":[],"mappings":";;AAyCA,sDAgBC;AAhBM,KAAK,UAAU,qBAAqB,CACzC,MAAc,EACd,MAAuC;IAEvC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,MAAM,CAAA;IAElE,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,GAAG,SAAS,aAAa;QAC/B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,SAAS;YACT,QAAQ;YACR,eAAe;YACf,SAAS;SACV;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWhoami = getWhoami;
|
|
4
|
+
async function getWhoami(client, params) {
|
|
5
|
+
const { organizationId, projectId } = params;
|
|
6
|
+
return await client.request({
|
|
7
|
+
path: `${projectId}/whoami`,
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: {
|
|
10
|
+
organizationId,
|
|
11
|
+
},
|
|
12
|
+
stamp: true,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=getWhoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWhoami.js","sourceRoot":"","sources":["../../../../src/actions/auth/getWhoami.ts"],"names":[],"mappings":";;AAoCA,8BAcC;AAdM,KAAK,UAAU,SAAS,CAC7B,MAAc,EACd,MAA2B;IAE3B,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,MAAM,CAAA;IAE5C,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,GAAG,SAAS,SAAS;QAC3B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,cAAc;SACf;QACD,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerWithPasskey = exports.registerWithOTP = exports.loginWithStamp = exports.loginWithOTP = exports.getWhoami = exports.authenticateWithOAuth = exports.authenticateWithEmail = void 0;
|
|
4
|
+
var authenticateWithEmail_js_1 = require("./authenticateWithEmail.js");
|
|
5
|
+
Object.defineProperty(exports, "authenticateWithEmail", { enumerable: true, get: function () { return authenticateWithEmail_js_1.authenticateWithEmail; } });
|
|
6
|
+
var authenticateWithOAuth_js_1 = require("./authenticateWithOAuth.js");
|
|
7
|
+
Object.defineProperty(exports, "authenticateWithOAuth", { enumerable: true, get: function () { return authenticateWithOAuth_js_1.authenticateWithOAuth; } });
|
|
8
|
+
var getWhoami_js_1 = require("./getWhoami.js");
|
|
9
|
+
Object.defineProperty(exports, "getWhoami", { enumerable: true, get: function () { return getWhoami_js_1.getWhoami; } });
|
|
10
|
+
var loginWithOTP_js_1 = require("./loginWithOTP.js");
|
|
11
|
+
Object.defineProperty(exports, "loginWithOTP", { enumerable: true, get: function () { return loginWithOTP_js_1.loginWithOTP; } });
|
|
12
|
+
var loginWithStamp_js_1 = require("./loginWithStamp.js");
|
|
13
|
+
Object.defineProperty(exports, "loginWithStamp", { enumerable: true, get: function () { return loginWithStamp_js_1.loginWithStamp; } });
|
|
14
|
+
var registerWithOTP_js_1 = require("./registerWithOTP.js");
|
|
15
|
+
Object.defineProperty(exports, "registerWithOTP", { enumerable: true, get: function () { return registerWithOTP_js_1.registerWithOTP; } });
|
|
16
|
+
var registerWithPasskey_js_1 = require("./registerWithPasskey.js");
|
|
17
|
+
Object.defineProperty(exports, "registerWithPasskey", { enumerable: true, get: function () { return registerWithPasskey_js_1.registerWithPasskey; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/actions/auth/index.ts"],"names":[],"mappings":";;;AAAA,uEAKmC;AAFjC,iIAAA,qBAAqB,OAAA;AAIvB,uEAImC;AADjC,iIAAA,qBAAqB,OAAA;AAGvB,+CAIuB;AADrB,yGAAA,SAAS,OAAA;AAEX,qDAI0B;AADxB,+GAAA,YAAY,OAAA;AAEd,yDAI4B;AAD1B,mHAAA,cAAc,OAAA;AAGhB,2DAK6B;AAD3B,qHAAA,eAAe,OAAA;AAEjB,mEAIiC;AAD/B,6HAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loginWithOTP = loginWithOTP;
|
|
4
|
+
async function loginWithOTP(client, params) {
|
|
5
|
+
const { otpId, otpCode, subOrganizationId, encodedPublicKey, projectId } = params;
|
|
6
|
+
return await client.request({
|
|
7
|
+
path: `${projectId}/auth/login/otp`,
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: {
|
|
10
|
+
otpId,
|
|
11
|
+
otpCode,
|
|
12
|
+
subOrganizationId,
|
|
13
|
+
encodedPublicKey,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=loginWithOTP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loginWithOTP.js","sourceRoot":"","sources":["../../../../src/actions/auth/loginWithOTP.ts"],"names":[],"mappings":";;AA0CA,oCAiBC;AAjBM,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,MAA8B;IAE9B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,GACtE,MAAM,CAAA;IAER,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,GAAG,SAAS,iBAAiB;QACnC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,KAAK;YACL,OAAO;YACP,iBAAiB;YACjB,gBAAgB;SACjB;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loginWithStamp = loginWithStamp;
|
|
4
|
+
async function loginWithStamp(client, params) {
|
|
5
|
+
const { projectId, targetPublicKey, organizationId } = params;
|
|
6
|
+
const timestampMs = Date.now();
|
|
7
|
+
const timestampMsString = timestampMs.toString();
|
|
8
|
+
const timestampIso = new Date(timestampMs).toISOString();
|
|
9
|
+
const stampPayload = `${JSON.stringify({
|
|
10
|
+
organizationId,
|
|
11
|
+
parameters: {
|
|
12
|
+
publicKey: targetPublicKey,
|
|
13
|
+
},
|
|
14
|
+
timestampMs: timestampMsString,
|
|
15
|
+
type: 'ACTIVITY_TYPE_STAMP_LOGIN',
|
|
16
|
+
})}\n`;
|
|
17
|
+
const stamp = await client.stamper.stamp(stampPayload);
|
|
18
|
+
return client.request({
|
|
19
|
+
path: `${projectId}/auth/login/passkey`,
|
|
20
|
+
method: 'POST',
|
|
21
|
+
body: {
|
|
22
|
+
subOrganizationId: organizationId,
|
|
23
|
+
targetPublicKey,
|
|
24
|
+
timestamp: timestampIso,
|
|
25
|
+
stamp,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=loginWithStamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loginWithStamp.js","sourceRoot":"","sources":["../../../../src/actions/auth/loginWithStamp.ts"],"names":[],"mappings":";;AAqCA,wCA8BC;AA9BM,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,MAAgC;IAEhC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,MAAM,CAAA;IAE7D,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAC9B,MAAM,iBAAiB,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAA;IAChD,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,CAAA;IAExD,MAAM,YAAY,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QACrC,cAAc;QACd,UAAU,EAAE;YACV,SAAS,EAAE,eAAe;SAC3B;QACD,WAAW,EAAE,iBAAiB;QAC9B,IAAI,EAAE,2BAA2B;KAClC,CAAC,IAAI,CAAA;IACN,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IAEtD,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,IAAI,EAAE,GAAG,SAAS,qBAAqB;QACvC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,iBAAiB,EAAE,cAAc;YACjC,eAAe;YACf,SAAS,EAAE,YAAY;YACvB,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerWithOTP = registerWithOTP;
|
|
4
|
+
async function registerWithOTP(client, params) {
|
|
5
|
+
const { email, contact, projectId, emailCustomization } = params;
|
|
6
|
+
return await client.request({
|
|
7
|
+
path: `${projectId}/auth/register/otp`,
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: {
|
|
10
|
+
email,
|
|
11
|
+
contact,
|
|
12
|
+
projectId,
|
|
13
|
+
emailCustomization,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=registerWithOTP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerWithOTP.js","sourceRoot":"","sources":["../../../../src/actions/auth/registerWithOTP.ts"],"names":[],"mappings":";;AAsDA,0CAgBC;AAhBM,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,MAAiC;IAEjC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAA;IAEhE,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,GAAG,SAAS,oBAAoB;QACtC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,KAAK;YACL,OAAO;YACP,SAAS;YACT,kBAAkB;SACnB;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerWithPasskey = registerWithPasskey;
|
|
4
|
+
async function registerWithPasskey(client, params) {
|
|
5
|
+
const { email, projectId, challenge, attestation, encodedPublicKey } = params;
|
|
6
|
+
return client.request({
|
|
7
|
+
path: `${projectId}/auth/register/passkey`,
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: {
|
|
10
|
+
email,
|
|
11
|
+
attestation,
|
|
12
|
+
challenge,
|
|
13
|
+
encodedPublicKey,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=registerWithPasskey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerWithPasskey.js","sourceRoot":"","sources":["../../../../src/actions/auth/registerWithPasskey.ts"],"names":[],"mappings":";;AAuDA,kDAgBC;AAhBM,KAAK,UAAU,mBAAmB,CACvC,MAAc,EACd,MAAqC;IAErC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAA;IAE7E,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,IAAI,EAAE,GAAG,SAAS,wBAAwB;QAC1C,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,KAAK;YACL,WAAW;YACX,SAAS;YACT,gBAAgB;SACjB;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signTransaction = exports.signRawPayload = exports.getUserWallet = exports.registerWithPasskey = exports.registerWithOTP = exports.loginWithOTP = exports.getWhoami = exports.authenticateWithOAuth = exports.authenticateWithEmail = void 0;
|
|
4
|
+
var index_js_1 = require("./auth/index.js");
|
|
5
|
+
Object.defineProperty(exports, "authenticateWithEmail", { enumerable: true, get: function () { return index_js_1.authenticateWithEmail; } });
|
|
6
|
+
Object.defineProperty(exports, "authenticateWithOAuth", { enumerable: true, get: function () { return index_js_1.authenticateWithOAuth; } });
|
|
7
|
+
Object.defineProperty(exports, "getWhoami", { enumerable: true, get: function () { return index_js_1.getWhoami; } });
|
|
8
|
+
Object.defineProperty(exports, "loginWithOTP", { enumerable: true, get: function () { return index_js_1.loginWithOTP; } });
|
|
9
|
+
Object.defineProperty(exports, "registerWithOTP", { enumerable: true, get: function () { return index_js_1.registerWithOTP; } });
|
|
10
|
+
Object.defineProperty(exports, "registerWithPasskey", { enumerable: true, get: function () { return index_js_1.registerWithPasskey; } });
|
|
11
|
+
var index_js_2 = require("./wallet/index.js");
|
|
12
|
+
Object.defineProperty(exports, "getUserWallet", { enumerable: true, get: function () { return index_js_2.getUserWallet; } });
|
|
13
|
+
Object.defineProperty(exports, "signRawPayload", { enumerable: true, get: function () { return index_js_2.signRawPayload; } });
|
|
14
|
+
Object.defineProperty(exports, "signTransaction", { enumerable: true, get: function () { return index_js_2.signTransaction; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/actions/index.ts"],"names":[],"mappings":";;;AACA,4CAqBwB;AAhBtB,iHAAA,qBAAqB,OAAA;AACrB,iHAAA,qBAAqB,OAAA;AAIrB,qGAAA,SAAS,OAAA;AAGT,wGAAA,YAAY,OAAA;AAMZ,2GAAA,eAAe,OAAA;AACf,+GAAA,mBAAmB,OAAA;AAIrB,8CAU0B;AAPxB,yGAAA,aAAa,OAAA;AAKb,0GAAA,cAAc,OAAA;AACd,2GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserWallet = getUserWallet;
|
|
4
|
+
async function getUserWallet(client, params) {
|
|
5
|
+
const { organizationId, projectId } = params;
|
|
6
|
+
return await client.request({
|
|
7
|
+
path: `${projectId}/user-wallet`,
|
|
8
|
+
body: {
|
|
9
|
+
organizationId,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=getUserWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserWallet.js","sourceRoot":"","sources":["../../../../src/actions/wallet/getUserWallet.ts"],"names":[],"mappings":";;AAiCA,sCAYC;AAZM,KAAK,UAAU,aAAa,CACjC,MAAc,EACd,MAA+B;IAE/B,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,MAAM,CAAA;IAE5C,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,GAAG,SAAS,cAAc;QAChC,IAAI,EAAE;YACJ,cAAc;SACf;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signTransaction = exports.signRawPayload = exports.getUserWallet = void 0;
|
|
4
|
+
var getUserWallet_js_1 = require("./getUserWallet.js");
|
|
5
|
+
Object.defineProperty(exports, "getUserWallet", { enumerable: true, get: function () { return getUserWallet_js_1.getUserWallet; } });
|
|
6
|
+
var signRawPayload_js_1 = require("./signRawPayload.js");
|
|
7
|
+
Object.defineProperty(exports, "signRawPayload", { enumerable: true, get: function () { return signRawPayload_js_1.signRawPayload; } });
|
|
8
|
+
var signTransaction_js_1 = require("./signTransaction.js");
|
|
9
|
+
Object.defineProperty(exports, "signTransaction", { enumerable: true, get: function () { return signTransaction_js_1.signTransaction; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/actions/wallet/index.ts"],"names":[],"mappings":";;;AAAA,uDAI2B;AADzB,iHAAA,aAAa,OAAA;AAGf,yDAI4B;AAD1B,mHAAA,cAAc,OAAA;AAGhB,2DAI6B;AAD3B,qHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signRawPayload = signRawPayload;
|
|
4
|
+
async function signRawPayload(client, params) {
|
|
5
|
+
const { organizationId, projectId, address, payload, encoding = 'PAYLOAD_ENCODING_HEXADECIMAL', hashFunction = 'HASH_FUNCTION_NO_OP', } = params;
|
|
6
|
+
const { signature } = await client.request({
|
|
7
|
+
path: `${projectId}/sign/raw-payload`,
|
|
8
|
+
body: {
|
|
9
|
+
body: {
|
|
10
|
+
type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',
|
|
11
|
+
timestampMs: Date.now().toString(),
|
|
12
|
+
organizationId,
|
|
13
|
+
parameters: {
|
|
14
|
+
signWith: address,
|
|
15
|
+
payload,
|
|
16
|
+
encoding,
|
|
17
|
+
hashFunction,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
apiUrl: 'https://api.turnkey.com/public/v1/submit/sign_raw_payload',
|
|
21
|
+
},
|
|
22
|
+
stamp: true,
|
|
23
|
+
});
|
|
24
|
+
return signature;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=signRawPayload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signRawPayload.js","sourceRoot":"","sources":["../../../../src/actions/wallet/signRawPayload.ts"],"names":[],"mappings":";;AAsCA,wCAgCC;AAhCM,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,MAAgC;IAEhC,MAAM,EACJ,cAAc,EACd,SAAS,EACT,OAAO,EACP,OAAO,EACP,QAAQ,GAAG,8BAA8B,EACzC,YAAY,GAAG,qBAAqB,GACrC,GAAG,MAAM,CAAA;IAEV,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACzC,IAAI,EAAE,GAAG,SAAS,mBAAmB;QACrC,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,IAAI,EAAE,mCAAmC;gBACzC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;gBAClC,cAAc;gBACd,UAAU,EAAE;oBACV,QAAQ,EAAE,OAAO;oBACjB,OAAO;oBACP,QAAQ;oBACR,YAAY;iBACb;aACF;YACD,MAAM,EAAE,2DAA2D;SACpE;QACD,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IACF,OAAO,SAAgB,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signTransaction = signTransaction;
|
|
4
|
+
async function signTransaction(client, params) {
|
|
5
|
+
const { organizationId, projectId, address, unsignedTransaction } = params;
|
|
6
|
+
const { signature } = await client.request({
|
|
7
|
+
path: `${projectId}/sign/transaction`,
|
|
8
|
+
body: {
|
|
9
|
+
body: {
|
|
10
|
+
type: 'ACTIVITY_TYPE_SIGN_TRANSACTION_V2',
|
|
11
|
+
timestampMs: Date.now().toString(),
|
|
12
|
+
organizationId,
|
|
13
|
+
parameters: {
|
|
14
|
+
signWith: address,
|
|
15
|
+
type: 'TRANSACTION_TYPE_ETHEREUM',
|
|
16
|
+
unsignedTransaction,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
apiUrl: 'https://api.turnkey.com/public/v1/submit/sign_transaction',
|
|
20
|
+
},
|
|
21
|
+
stamp: true,
|
|
22
|
+
});
|
|
23
|
+
return `0x${signature}`;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=signTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signTransaction.js","sourceRoot":"","sources":["../../../../src/actions/wallet/signTransaction.ts"],"names":[],"mappings":";;AAkCA,0CAyBC;AAzBM,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,MAAiC;IAEjC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAAA;IAE1E,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACzC,IAAI,EAAE,GAAG,SAAS,mBAAmB;QACrC,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,IAAI,EAAE,mCAAmC;gBACzC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;gBAClC,cAAc;gBACd,UAAU,EAAE;oBACV,QAAQ,EAAE,OAAO;oBACjB,IAAI,EAAE,2BAA2B;oBACjC,mBAAmB;iBACpB;aACF;YACD,MAAM,EAAE,2DAA2D;SACpE;QACD,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,OAAO,KAAK,SAAS,EAAS,CAAA;AAChC,CAAC"}
|