@zerodev/wallet-core 0.0.1-alpha.14 → 0.0.1-alpha.16
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/dist/_cjs/actions/auth/{getUserEmail.js → getAuthenticators.js} +6 -6
- package/dist/_cjs/actions/auth/getAuthenticators.js.map +1 -0
- package/dist/_cjs/actions/auth/index.js +3 -3
- package/dist/_cjs/actions/auth/index.js.map +1 -1
- package/dist/_cjs/actions/index.js +6 -3
- package/dist/_cjs/actions/index.js.map +1 -1
- package/dist/_cjs/actions/wallet/index.js +9 -3
- package/dist/_cjs/actions/wallet/index.js.map +1 -1
- package/dist/_cjs/actions/wallet/sign7702Authorization.js +16 -0
- package/dist/_cjs/actions/wallet/sign7702Authorization.js.map +1 -0
- package/dist/_cjs/actions/wallet/signMessage.js +17 -0
- package/dist/_cjs/actions/wallet/signMessage.js.map +1 -0
- package/dist/_cjs/actions/wallet/signTransaction.js +9 -18
- package/dist/_cjs/actions/wallet/signTransaction.js.map +1 -1
- package/dist/_cjs/actions/wallet/signTypedDataV4.js +17 -0
- package/dist/_cjs/actions/wallet/signTypedDataV4.js.map +1 -0
- package/dist/_cjs/actions/wallet/signUserOperation.js +17 -0
- package/dist/_cjs/actions/wallet/signUserOperation.js.map +1 -0
- package/dist/_cjs/actions/wallet/signingUtils.js +64 -0
- package/dist/_cjs/actions/wallet/signingUtils.js.map +1 -0
- package/dist/_cjs/adapters/viem.js +57 -24
- package/dist/_cjs/adapters/viem.js.map +1 -1
- package/dist/_cjs/client/decorators/client.js +6 -4
- package/dist/_cjs/client/decorators/client.js.map +1 -1
- package/dist/_cjs/index.js +6 -2
- package/dist/_cjs/index.js.map +1 -1
- package/dist/_esm/actions/auth/getAuthenticators.js +36 -0
- package/dist/_esm/actions/auth/getAuthenticators.js.map +1 -0
- package/dist/_esm/actions/auth/index.js +1 -1
- package/dist/_esm/actions/auth/index.js.map +1 -1
- package/dist/_esm/actions/index.js +2 -2
- package/dist/_esm/actions/index.js.map +1 -1
- package/dist/_esm/actions/wallet/index.js +4 -1
- package/dist/_esm/actions/wallet/index.js.map +1 -1
- package/dist/_esm/actions/wallet/sign7702Authorization.js +13 -0
- package/dist/_esm/actions/wallet/sign7702Authorization.js.map +1 -0
- package/dist/_esm/actions/wallet/signMessage.js +14 -0
- package/dist/_esm/actions/wallet/signMessage.js.map +1 -0
- package/dist/_esm/actions/wallet/signTransaction.js +9 -36
- package/dist/_esm/actions/wallet/signTransaction.js.map +1 -1
- package/dist/_esm/actions/wallet/signTypedDataV4.js +14 -0
- package/dist/_esm/actions/wallet/signTypedDataV4.js.map +1 -0
- package/dist/_esm/actions/wallet/signUserOperation.js +14 -0
- package/dist/_esm/actions/wallet/signUserOperation.js.map +1 -0
- package/dist/_esm/actions/wallet/signingUtils.js +69 -0
- package/dist/_esm/actions/wallet/signingUtils.js.map +1 -0
- package/dist/_esm/adapters/viem.js +60 -27
- package/dist/_esm/adapters/viem.js.map +1 -1
- package/dist/_esm/client/decorators/client.js +6 -4
- package/dist/_esm/client/decorators/client.js.map +1 -1
- package/dist/_esm/index.js +2 -2
- package/dist/_esm/index.js.map +1 -1
- package/dist/_types/actions/auth/getAuthenticators.d.ts +65 -0
- package/dist/_types/actions/auth/getAuthenticators.d.ts.map +1 -0
- package/dist/_types/actions/auth/index.d.ts +1 -1
- package/dist/_types/actions/auth/index.d.ts.map +1 -1
- package/dist/_types/actions/index.d.ts +2 -2
- package/dist/_types/actions/index.d.ts.map +1 -1
- package/dist/_types/actions/wallet/index.d.ts +4 -1
- package/dist/_types/actions/wallet/index.d.ts.map +1 -1
- package/dist/_types/actions/wallet/sign7702Authorization.d.ts +19 -0
- package/dist/_types/actions/wallet/sign7702Authorization.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signMessage.d.ts +19 -0
- package/dist/_types/actions/wallet/signMessage.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signTransaction.d.ts +1 -19
- package/dist/_types/actions/wallet/signTransaction.d.ts.map +1 -1
- package/dist/_types/actions/wallet/signTypedDataV4.d.ts +21 -0
- package/dist/_types/actions/wallet/signTypedDataV4.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signUserOperation.d.ts +21 -0
- package/dist/_types/actions/wallet/signUserOperation.d.ts.map +1 -0
- package/dist/_types/actions/wallet/signingUtils.d.ts +32 -0
- package/dist/_types/actions/wallet/signingUtils.d.ts.map +1 -0
- package/dist/_types/adapters/viem.d.ts.map +1 -1
- package/dist/_types/client/decorators/client.d.ts +18 -6
- package/dist/_types/client/decorators/client.d.ts.map +1 -1
- package/dist/_types/index.d.ts +2 -2
- package/dist/_types/index.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/actions/auth/getAuthenticators.ts +89 -0
- package/src/actions/auth/index.ts +9 -5
- package/src/actions/index.ts +19 -6
- package/src/actions/wallet/index.ts +22 -4
- package/src/actions/wallet/sign7702Authorization.ts +48 -0
- package/src/actions/wallet/signMessage.ts +47 -0
- package/src/actions/wallet/signTransaction.ts +19 -38
- package/src/actions/wallet/signTypedDataV4.ts +52 -0
- package/src/actions/wallet/signUserOperation.ts +56 -0
- package/src/actions/wallet/signingUtils.ts +110 -0
- package/src/adapters/viem.ts +71 -39
- package/src/client/decorators/client.ts +49 -19
- package/src/index.ts +19 -3
- package/dist/_cjs/actions/auth/getUserEmail.js.map +0 -1
- package/dist/_cjs/actions/wallet/signRawPayload.js +0 -27
- package/dist/_cjs/actions/wallet/signRawPayload.js.map +0 -1
- package/dist/_esm/actions/auth/getUserEmail.js +0 -33
- package/dist/_esm/actions/auth/getUserEmail.js.map +0 -1
- package/dist/_esm/actions/wallet/signRawPayload.js +0 -42
- package/dist/_esm/actions/wallet/signRawPayload.js.map +0 -1
- package/dist/_types/actions/auth/getUserEmail.d.ts +0 -32
- package/dist/_types/actions/auth/getUserEmail.d.ts.map +0 -1
- package/dist/_types/actions/wallet/signRawPayload.d.ts +0 -39
- package/dist/_types/actions/wallet/signRawPayload.d.ts.map +0 -1
- package/src/actions/auth/getUserEmail.ts +0 -52
- package/src/actions/wallet/signRawPayload.ts +0 -75
package/src/adapters/viem.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
bytesToHex,
|
|
3
|
+
concat,
|
|
4
|
+
getTypesForEIP712Domain,
|
|
2
5
|
type Hex,
|
|
3
|
-
|
|
6
|
+
hashTypedData,
|
|
4
7
|
type LocalAccount,
|
|
8
|
+
numberToHex,
|
|
5
9
|
parseSignature,
|
|
6
|
-
parseTransaction,
|
|
7
10
|
type SerializeTransactionFn,
|
|
8
11
|
type SignableMessage,
|
|
9
12
|
serializeTransaction,
|
|
10
13
|
serializeTypedData,
|
|
11
14
|
type TransactionSerializable,
|
|
15
|
+
toRlp,
|
|
12
16
|
zeroAddress,
|
|
13
17
|
} from 'viem'
|
|
14
18
|
import type {
|
|
@@ -17,7 +21,6 @@ import type {
|
|
|
17
21
|
} from 'viem/accounts'
|
|
18
22
|
import { toAccount } from 'viem/accounts'
|
|
19
23
|
import { hashAuthorization } from 'viem/utils'
|
|
20
|
-
import type { signRawPayload } from '../actions/index.js'
|
|
21
24
|
import type { ZeroDevWalletClient } from '../client/index.js'
|
|
22
25
|
|
|
23
26
|
export interface ToViemAccountParams {
|
|
@@ -44,21 +47,6 @@ export async function toViemAccount(
|
|
|
44
47
|
} catch {
|
|
45
48
|
address = zeroAddress
|
|
46
49
|
}
|
|
47
|
-
const signRawPayloadInternal = async (
|
|
48
|
-
payload: string,
|
|
49
|
-
encoding: Parameters<
|
|
50
|
-
typeof signRawPayload
|
|
51
|
-
>[1]['encoding'] = 'PAYLOAD_ENCODING_HEXADECIMAL',
|
|
52
|
-
) => {
|
|
53
|
-
return await client.signRawPayload({
|
|
54
|
-
organizationId,
|
|
55
|
-
projectId,
|
|
56
|
-
token: await getToken(),
|
|
57
|
-
address,
|
|
58
|
-
payload,
|
|
59
|
-
encoding,
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
50
|
|
|
63
51
|
// Modified from: https://github.com/tkhq/sdk/blob/4e439bf2973ea13b51d981d7c24a4841d4e5fd5f/packages/viem/src/index.ts#L419-L461
|
|
64
52
|
const signTransactionInternal = async <
|
|
@@ -84,27 +72,37 @@ export async function toViemAccount(
|
|
|
84
72
|
unsignedTransaction: nonHexPrefixedSerializedTx,
|
|
85
73
|
})
|
|
86
74
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const { r, s, v } = parseTransaction(signature)
|
|
90
|
-
|
|
91
|
-
// Recombine with the original transaction
|
|
92
|
-
return serializeTransaction(transaction, {
|
|
93
|
-
r: r!,
|
|
94
|
-
s: s!,
|
|
95
|
-
v: v!,
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return signature
|
|
75
|
+
const { r, s, v, yParity } = parseSignature(signature)
|
|
76
|
+
return serializeTransaction(transaction, { r, s, v, yParity })
|
|
100
77
|
}
|
|
101
78
|
|
|
102
79
|
return toAccount({
|
|
103
80
|
address,
|
|
104
81
|
|
|
105
82
|
async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {
|
|
106
|
-
|
|
107
|
-
|
|
83
|
+
if (typeof message === 'string') {
|
|
84
|
+
return client.signMessage({
|
|
85
|
+
organizationId,
|
|
86
|
+
projectId,
|
|
87
|
+
token: await getToken(),
|
|
88
|
+
address,
|
|
89
|
+
message,
|
|
90
|
+
encoding: 'utf8',
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
// Raw message (Hex or ByteArray)
|
|
94
|
+
const raw =
|
|
95
|
+
typeof message.raw === 'string'
|
|
96
|
+
? message.raw.replace(/^0x/, '')
|
|
97
|
+
: bytesToHex(message.raw).slice(2)
|
|
98
|
+
return client.signMessage({
|
|
99
|
+
organizationId,
|
|
100
|
+
projectId,
|
|
101
|
+
token: await getToken(),
|
|
102
|
+
address,
|
|
103
|
+
message: raw,
|
|
104
|
+
encoding: 'hex',
|
|
105
|
+
})
|
|
108
106
|
},
|
|
109
107
|
|
|
110
108
|
signTransaction: async <
|
|
@@ -123,11 +121,28 @@ export async function toViemAccount(
|
|
|
123
121
|
return signTransactionInternal(transaction, serializer)
|
|
124
122
|
},
|
|
125
123
|
signTypedData: async (typedData) => {
|
|
126
|
-
const serializedTypedData = serializeTypedData(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
const serializedTypedData = serializeTypedData({
|
|
125
|
+
...typedData,
|
|
126
|
+
types: {
|
|
127
|
+
...typedData.types,
|
|
128
|
+
EIP712Domain: getTypesForEIP712Domain({
|
|
129
|
+
domain: typedData.domain as Parameters<
|
|
130
|
+
typeof getTypesForEIP712Domain
|
|
131
|
+
>[0]['domain'],
|
|
132
|
+
}),
|
|
133
|
+
},
|
|
134
|
+
} as Parameters<typeof serializeTypedData>[0])
|
|
135
|
+
return client.signTypedDataV4({
|
|
136
|
+
organizationId,
|
|
137
|
+
projectId,
|
|
138
|
+
token: await getToken(),
|
|
139
|
+
address,
|
|
140
|
+
unsignedTypedDataV4: serializedTypedData,
|
|
141
|
+
encoding: 'utf8',
|
|
142
|
+
typedDataHash: hashTypedData(
|
|
143
|
+
typedData as Parameters<typeof hashTypedData>[0],
|
|
144
|
+
).slice(2),
|
|
145
|
+
})
|
|
131
146
|
},
|
|
132
147
|
|
|
133
148
|
async signAuthorization(
|
|
@@ -146,7 +161,24 @@ export async function toViemAccount(
|
|
|
146
161
|
nonce,
|
|
147
162
|
})
|
|
148
163
|
|
|
149
|
-
|
|
164
|
+
// Serialize EIP-7702 authorization: 0x05 || RLP([chainId, address, nonce])
|
|
165
|
+
const unsignedTransaction = concat([
|
|
166
|
+
'0x05',
|
|
167
|
+
toRlp([
|
|
168
|
+
chainId ? numberToHex(chainId) : '0x',
|
|
169
|
+
authAddress,
|
|
170
|
+
nonce ? numberToHex(nonce) : '0x',
|
|
171
|
+
]),
|
|
172
|
+
]).slice(2)
|
|
173
|
+
|
|
174
|
+
const signature = await client.sign7702Authorization({
|
|
175
|
+
organizationId,
|
|
176
|
+
projectId,
|
|
177
|
+
token: await getToken(),
|
|
178
|
+
address,
|
|
179
|
+
unsignedTransaction,
|
|
180
|
+
hashedAuthorization: hashedAuthorization.slice(2),
|
|
181
|
+
})
|
|
150
182
|
|
|
151
183
|
const parsedSignature = parseSignature(signature)
|
|
152
184
|
|
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
type AuthenticateWithOAuthReturnType,
|
|
11
11
|
authenticateWithEmail,
|
|
12
12
|
authenticateWithOAuth,
|
|
13
|
+
type GetAuthenticatorsParameters,
|
|
14
|
+
type GetAuthenticatorsReturnType,
|
|
13
15
|
type GetAuthProxyConfigIdReturnType,
|
|
14
|
-
type GetUserEmailParameters,
|
|
15
|
-
type GetUserEmailReturnType,
|
|
16
16
|
type GetUserWalletParameters,
|
|
17
17
|
type GetUserWalletReturnType,
|
|
18
18
|
type GetWhoamiParameters,
|
|
19
19
|
type GetWhoamiReturnType,
|
|
20
|
+
getAuthenticators,
|
|
20
21
|
getAuthProxyConfigId,
|
|
21
|
-
getUserEmail,
|
|
22
22
|
getUserWallet,
|
|
23
23
|
getWhoami,
|
|
24
24
|
type LoginWithOTPParameters,
|
|
@@ -30,15 +30,22 @@ import {
|
|
|
30
30
|
type RegisterWithPasskeyReturnType,
|
|
31
31
|
registerWithOTP,
|
|
32
32
|
registerWithPasskey,
|
|
33
|
-
type
|
|
34
|
-
type
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import {
|
|
33
|
+
type Sign7702AuthorizationParameters,
|
|
34
|
+
type Sign7702AuthorizationReturnType,
|
|
35
|
+
type SignMessageParameters,
|
|
36
|
+
type SignMessageReturnType,
|
|
38
37
|
type SignTransactionParameters,
|
|
39
38
|
type SignTransactionReturnType,
|
|
39
|
+
type SignTypedDataV4Parameters,
|
|
40
|
+
type SignTypedDataV4ReturnType,
|
|
41
|
+
type SignUserOperationParameters,
|
|
42
|
+
type SignUserOperationReturnType,
|
|
43
|
+
sign7702Authorization,
|
|
44
|
+
signMessage,
|
|
40
45
|
signTransaction,
|
|
41
|
-
|
|
46
|
+
signTypedDataV4,
|
|
47
|
+
signUserOperation,
|
|
48
|
+
} from '../../actions/index.js'
|
|
42
49
|
import type { Client } from '../types.js'
|
|
43
50
|
|
|
44
51
|
/**
|
|
@@ -66,11 +73,12 @@ export type ZeroDevWalletActions = {
|
|
|
66
73
|
getWhoami: (params: GetWhoamiParameters) => Promise<GetWhoamiReturnType>
|
|
67
74
|
|
|
68
75
|
/**
|
|
69
|
-
*
|
|
76
|
+
* Fetches all authenticators (oauths, passkeys, emailContacts, apiKeys)
|
|
77
|
+
* for the authenticated user within the given project/sub-organization
|
|
70
78
|
*/
|
|
71
|
-
|
|
72
|
-
params:
|
|
73
|
-
) => Promise<
|
|
79
|
+
getAuthenticators: (
|
|
80
|
+
params: GetAuthenticatorsParameters,
|
|
81
|
+
) => Promise<GetAuthenticatorsReturnType>
|
|
74
82
|
|
|
75
83
|
// Wallet actions
|
|
76
84
|
/**
|
|
@@ -81,11 +89,9 @@ export type ZeroDevWalletActions = {
|
|
|
81
89
|
) => Promise<GetUserWalletReturnType>
|
|
82
90
|
|
|
83
91
|
/**
|
|
84
|
-
* Signs a
|
|
92
|
+
* Signs a message with the user's wallet
|
|
85
93
|
*/
|
|
86
|
-
|
|
87
|
-
params: SignRawPayloadParameters,
|
|
88
|
-
) => Promise<SignRawPayloadReturnType>
|
|
94
|
+
signMessage: (params: SignMessageParameters) => Promise<SignMessageReturnType>
|
|
89
95
|
|
|
90
96
|
/**
|
|
91
97
|
* Signs a transaction with the user's wallet
|
|
@@ -94,6 +100,27 @@ export type ZeroDevWalletActions = {
|
|
|
94
100
|
params: SignTransactionParameters,
|
|
95
101
|
) => Promise<SignTransactionReturnType>
|
|
96
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Signs EIP-712 typed data with the user's wallet
|
|
105
|
+
*/
|
|
106
|
+
signTypedDataV4: (
|
|
107
|
+
params: SignTypedDataV4Parameters,
|
|
108
|
+
) => Promise<SignTypedDataV4ReturnType>
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Signs a user operation with the user's wallet
|
|
112
|
+
*/
|
|
113
|
+
signUserOperation: (
|
|
114
|
+
params: SignUserOperationParameters,
|
|
115
|
+
) => Promise<SignUserOperationReturnType>
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Signs an EIP-7702 authorization with the user's wallet
|
|
119
|
+
*/
|
|
120
|
+
sign7702Authorization: (
|
|
121
|
+
params: Sign7702AuthorizationParameters,
|
|
122
|
+
) => Promise<Sign7702AuthorizationReturnType>
|
|
123
|
+
|
|
97
124
|
/**
|
|
98
125
|
* Registers a passkey with the user's wallet
|
|
99
126
|
*/
|
|
@@ -156,12 +183,15 @@ export function zeroDevWalletActions(client: Client): ZeroDevWalletActions {
|
|
|
156
183
|
authenticateWithEmail: (params) => authenticateWithEmail(client, params),
|
|
157
184
|
authenticateWithOAuth: (params) => authenticateWithOAuth(client, params),
|
|
158
185
|
getWhoami: (params) => getWhoami(client, params),
|
|
159
|
-
|
|
186
|
+
getAuthenticators: (params) => getAuthenticators(client, params),
|
|
160
187
|
|
|
161
188
|
// Wallet actions
|
|
162
189
|
getUserWallet: (params) => getUserWallet(client, params),
|
|
163
|
-
|
|
190
|
+
signMessage: (params) => signMessage(client, params),
|
|
164
191
|
signTransaction: (params) => signTransaction(client, params),
|
|
192
|
+
signTypedDataV4: (params) => signTypedDataV4(client, params),
|
|
193
|
+
signUserOperation: (params) => signUserOperation(client, params),
|
|
194
|
+
sign7702Authorization: (params) => sign7702Authorization(client, params),
|
|
165
195
|
registerWithPasskey: (params) => registerWithPasskey(client, params),
|
|
166
196
|
loginWithStamp: (params) => loginWithStamp(client, params),
|
|
167
197
|
registerWithOTP: (params) => registerWithOTP(client, params),
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export type {
|
|
2
2
|
// Auth types
|
|
3
|
+
ApiKeyAuthenticator,
|
|
3
4
|
AuthenticateWithEmailParameters,
|
|
4
5
|
AuthenticateWithEmailReturnType,
|
|
5
6
|
AuthenticateWithOAuthParameters,
|
|
6
7
|
AuthenticateWithOAuthReturnType,
|
|
8
|
+
EmailContact,
|
|
7
9
|
EmailCustomization,
|
|
10
|
+
GetAuthenticatorsParameters,
|
|
11
|
+
GetAuthenticatorsReturnType,
|
|
8
12
|
// Wallet types
|
|
9
13
|
GetUserWalletParameters,
|
|
10
14
|
GetUserWalletReturnType,
|
|
@@ -12,13 +16,21 @@ export type {
|
|
|
12
16
|
GetWhoamiReturnType,
|
|
13
17
|
LoginWithOTPParameters,
|
|
14
18
|
LoginWithOTPReturnType,
|
|
19
|
+
OAuthAuthenticator,
|
|
15
20
|
OtpContact,
|
|
21
|
+
PasskeyAuthenticator,
|
|
16
22
|
RegisterWithOTPParameters,
|
|
17
23
|
RegisterWithOTPReturnType,
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
Sign7702AuthorizationParameters,
|
|
25
|
+
Sign7702AuthorizationReturnType,
|
|
26
|
+
SignMessageParameters,
|
|
27
|
+
SignMessageReturnType,
|
|
20
28
|
SignTransactionParameters,
|
|
21
29
|
SignTransactionReturnType,
|
|
30
|
+
SignTypedDataV4Parameters,
|
|
31
|
+
SignTypedDataV4ReturnType,
|
|
32
|
+
SignUserOperationParameters,
|
|
33
|
+
SignUserOperationReturnType,
|
|
22
34
|
} from './actions/index.js'
|
|
23
35
|
|
|
24
36
|
// Actions
|
|
@@ -26,13 +38,17 @@ export {
|
|
|
26
38
|
// Auth actions
|
|
27
39
|
authenticateWithEmail,
|
|
28
40
|
authenticateWithOAuth,
|
|
41
|
+
getAuthenticators,
|
|
29
42
|
// Wallet actions
|
|
30
43
|
getUserWallet,
|
|
31
44
|
getWhoami,
|
|
32
45
|
loginWithOTP,
|
|
33
46
|
registerWithOTP,
|
|
34
|
-
|
|
47
|
+
sign7702Authorization,
|
|
48
|
+
signMessage,
|
|
35
49
|
signTransaction,
|
|
50
|
+
signTypedDataV4,
|
|
51
|
+
signUserOperation,
|
|
36
52
|
} from './actions/index.js'
|
|
37
53
|
export type { ToViemAccountParams } from './adapters/viem.js'
|
|
38
54
|
// Adapters
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getUserEmail.js","sourceRoot":"","sources":["../../../../src/actions/auth/getUserEmail.ts"],"names":[],"mappings":";;AAiCA,oCAkBC;AAlBM,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,MAA8B;IAE9B,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IAEnD,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,GAAG,SAAS,aAAa;QAC/B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,cAAc;SACf;QACD,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC;QACD,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,SAAS;KACxB,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.signRawPayload = signRawPayload;
|
|
4
|
-
async function signRawPayload(client, params) {
|
|
5
|
-
const { organizationId, projectId, token, 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
|
-
type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',
|
|
10
|
-
timestampMs: Date.now().toString(),
|
|
11
|
-
organizationId,
|
|
12
|
-
parameters: {
|
|
13
|
-
signWith: address,
|
|
14
|
-
payload,
|
|
15
|
-
encoding,
|
|
16
|
-
hashFunction,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
headers: {
|
|
20
|
-
Authorization: `Bearer ${token}`,
|
|
21
|
-
},
|
|
22
|
-
stamp: true,
|
|
23
|
-
stampPostion: 'headers',
|
|
24
|
-
});
|
|
25
|
-
return signature;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=signRawPayload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signRawPayload.js","sourceRoot":"","sources":["../../../../src/actions/wallet/signRawPayload.ts"],"names":[],"mappings":";;AAwCA,wCAkCC;AAlCM,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,MAAgC;IAEhC,MAAM,EACJ,cAAc,EACd,SAAS,EACT,KAAK,EACL,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,mCAAmC;YACzC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;YAClC,cAAc;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE,OAAO;gBACjB,OAAO;gBACP,QAAQ;gBACR,YAAY;aACb;SACF;QACD,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC;QACD,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,SAAS;KACxB,CAAC,CAAA;IACF,OAAO,SAAgB,CAAA;AACzB,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the user's email address
|
|
3
|
-
*
|
|
4
|
-
* @param client - The ZeroDev Wallet client
|
|
5
|
-
* @param params - The parameters for the user email request
|
|
6
|
-
* @returns The user's email address
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* const userEmail = await getUserEmail(client, {
|
|
11
|
-
* organizationId: 'org_123',
|
|
12
|
-
* projectId: 'proj_456',
|
|
13
|
-
* token: 'session_token_abc',
|
|
14
|
-
* });
|
|
15
|
-
* console.log(userEmail.email); // 'user@example.com'
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export async function getUserEmail(client, params) {
|
|
19
|
-
const { organizationId, projectId, token } = params;
|
|
20
|
-
return await client.request({
|
|
21
|
-
path: `${projectId}/user-email`,
|
|
22
|
-
method: 'POST',
|
|
23
|
-
body: {
|
|
24
|
-
organizationId,
|
|
25
|
-
},
|
|
26
|
-
headers: {
|
|
27
|
-
Authorization: `Bearer ${token}`,
|
|
28
|
-
},
|
|
29
|
-
stamp: true,
|
|
30
|
-
stampPostion: 'headers',
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=getUserEmail.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getUserEmail.js","sourceRoot":"","sources":["../../../../src/actions/auth/getUserEmail.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,MAA8B;IAE9B,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IAEnD,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,GAAG,SAAS,aAAa;QAC/B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,cAAc;SACf;QACD,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC;QACD,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,SAAS;KACxB,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signs a raw payload with the user's wallet
|
|
3
|
-
*
|
|
4
|
-
* @param client - The ZeroDev Wallet client
|
|
5
|
-
* @param params - The parameters for signing
|
|
6
|
-
* @returns The signature
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* const result = await signRawPayload(client, {
|
|
11
|
-
* organizationId: 'org_123',
|
|
12
|
-
* projectId: 'proj_456',
|
|
13
|
-
* address: '0x123...',
|
|
14
|
-
* payload: 'abc123...',
|
|
15
|
-
* });
|
|
16
|
-
* console.log(result.signature); // '0x...'
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export async function signRawPayload(client, params) {
|
|
20
|
-
const { organizationId, projectId, token, address, payload, encoding = 'PAYLOAD_ENCODING_HEXADECIMAL', hashFunction = 'HASH_FUNCTION_NO_OP', } = params;
|
|
21
|
-
const { signature } = await client.request({
|
|
22
|
-
path: `${projectId}/sign/raw-payload`,
|
|
23
|
-
body: {
|
|
24
|
-
type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',
|
|
25
|
-
timestampMs: Date.now().toString(),
|
|
26
|
-
organizationId,
|
|
27
|
-
parameters: {
|
|
28
|
-
signWith: address,
|
|
29
|
-
payload,
|
|
30
|
-
encoding,
|
|
31
|
-
hashFunction,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
headers: {
|
|
35
|
-
Authorization: `Bearer ${token}`,
|
|
36
|
-
},
|
|
37
|
-
stamp: true,
|
|
38
|
-
stampPostion: 'headers',
|
|
39
|
-
});
|
|
40
|
-
return signature;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=signRawPayload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signRawPayload.js","sourceRoot":"","sources":["../../../../src/actions/wallet/signRawPayload.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,MAAgC;IAEhC,MAAM,EACJ,cAAc,EACd,SAAS,EACT,KAAK,EACL,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,mCAAmC;YACzC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;YAClC,cAAc;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE,OAAO;gBACjB,OAAO;gBACP,QAAQ;gBACR,YAAY;aACb;SACF;QACD,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC;QACD,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,SAAS;KACxB,CAAC,CAAA;IACF,OAAO,SAAgB,CAAA;AACzB,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Client } from '../../client/types.js';
|
|
2
|
-
export type GetUserEmailParameters = {
|
|
3
|
-
/** The organization ID to query */
|
|
4
|
-
organizationId: string;
|
|
5
|
-
/** The project ID for the request */
|
|
6
|
-
projectId: string;
|
|
7
|
-
/** The session token for authorization */
|
|
8
|
-
token: string;
|
|
9
|
-
};
|
|
10
|
-
export type GetUserEmailReturnType = {
|
|
11
|
-
/** The user's email address */
|
|
12
|
-
email: string;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Gets the user's email address
|
|
16
|
-
*
|
|
17
|
-
* @param client - The ZeroDev Wallet client
|
|
18
|
-
* @param params - The parameters for the user email request
|
|
19
|
-
* @returns The user's email address
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* const userEmail = await getUserEmail(client, {
|
|
24
|
-
* organizationId: 'org_123',
|
|
25
|
-
* projectId: 'proj_456',
|
|
26
|
-
* token: 'session_token_abc',
|
|
27
|
-
* });
|
|
28
|
-
* console.log(userEmail.email); // 'user@example.com'
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare function getUserEmail(client: Client, params: GetUserEmailParameters): Promise<GetUserEmailReturnType>;
|
|
32
|
-
//# sourceMappingURL=getUserEmail.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getUserEmail.d.ts","sourceRoot":"","sources":["../../../../src/actions/auth/getUserEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,MAAM,MAAM,sBAAsB,GAAG;IACnC,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAA;IACtB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,sBAAsB,CAAC,CAejC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Hex } from 'viem';
|
|
2
|
-
import type { Client } from '../../client/types.js';
|
|
3
|
-
export type SignRawPayloadParameters = {
|
|
4
|
-
/** The organization ID */
|
|
5
|
-
organizationId: string;
|
|
6
|
-
/** The project ID for the request */
|
|
7
|
-
projectId: string;
|
|
8
|
-
/** The session token for authorization */
|
|
9
|
-
token: string;
|
|
10
|
-
/** The address to sign with */
|
|
11
|
-
address: Hex;
|
|
12
|
-
/** The payload hash to sign (without 0x prefix) */
|
|
13
|
-
payload: string;
|
|
14
|
-
/** The encoding type */
|
|
15
|
-
encoding?: 'PAYLOAD_ENCODING_HEXADECIMAL' | 'PAYLOAD_ENCODING_EIP712';
|
|
16
|
-
/** The hash function type */
|
|
17
|
-
hashFunction?: 'HASH_FUNCTION_NO_OP';
|
|
18
|
-
};
|
|
19
|
-
export type SignRawPayloadReturnType = Hex;
|
|
20
|
-
/**
|
|
21
|
-
* Signs a raw payload with the user's wallet
|
|
22
|
-
*
|
|
23
|
-
* @param client - The ZeroDev Wallet client
|
|
24
|
-
* @param params - The parameters for signing
|
|
25
|
-
* @returns The signature
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* const result = await signRawPayload(client, {
|
|
30
|
-
* organizationId: 'org_123',
|
|
31
|
-
* projectId: 'proj_456',
|
|
32
|
-
* address: '0x123...',
|
|
33
|
-
* payload: 'abc123...',
|
|
34
|
-
* });
|
|
35
|
-
* console.log(result.signature); // '0x...'
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function signRawPayload(client: Client, params: SignRawPayloadParameters): Promise<SignRawPayloadReturnType>;
|
|
39
|
-
//# sourceMappingURL=signRawPayload.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signRawPayload.d.ts","sourceRoot":"","sources":["../../../../src/actions/wallet/signRawPayload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,MAAM,MAAM,wBAAwB,GAAG;IACrC,0BAA0B;IAC1B,cAAc,EAAE,MAAM,CAAA;IACtB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B;IAC/B,OAAO,EAAE,GAAG,CAAA;IACZ,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAA;IACf,wBAAwB;IACxB,QAAQ,CAAC,EAAE,8BAA8B,GAAG,yBAAyB,CAAA;IACrE,6BAA6B;IAC7B,YAAY,CAAC,EAAE,qBAAqB,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAE1C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,wBAAwB,CAAC,CA+BnC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { Client } from '../../client/types.js'
|
|
2
|
-
|
|
3
|
-
export type GetUserEmailParameters = {
|
|
4
|
-
/** The organization ID to query */
|
|
5
|
-
organizationId: string
|
|
6
|
-
/** The project ID for the request */
|
|
7
|
-
projectId: string
|
|
8
|
-
/** The session token for authorization */
|
|
9
|
-
token: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type GetUserEmailReturnType = {
|
|
13
|
-
/** The user's email address */
|
|
14
|
-
email: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Gets the user's email address
|
|
19
|
-
*
|
|
20
|
-
* @param client - The ZeroDev Wallet client
|
|
21
|
-
* @param params - The parameters for the user email request
|
|
22
|
-
* @returns The user's email address
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* const userEmail = await getUserEmail(client, {
|
|
27
|
-
* organizationId: 'org_123',
|
|
28
|
-
* projectId: 'proj_456',
|
|
29
|
-
* token: 'session_token_abc',
|
|
30
|
-
* });
|
|
31
|
-
* console.log(userEmail.email); // 'user@example.com'
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export async function getUserEmail(
|
|
35
|
-
client: Client,
|
|
36
|
-
params: GetUserEmailParameters,
|
|
37
|
-
): Promise<GetUserEmailReturnType> {
|
|
38
|
-
const { organizationId, projectId, token } = params
|
|
39
|
-
|
|
40
|
-
return await client.request({
|
|
41
|
-
path: `${projectId}/user-email`,
|
|
42
|
-
method: 'POST',
|
|
43
|
-
body: {
|
|
44
|
-
organizationId,
|
|
45
|
-
},
|
|
46
|
-
headers: {
|
|
47
|
-
Authorization: `Bearer ${token}`,
|
|
48
|
-
},
|
|
49
|
-
stamp: true,
|
|
50
|
-
stampPostion: 'headers',
|
|
51
|
-
})
|
|
52
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { Hex } from 'viem'
|
|
2
|
-
import type { Client } from '../../client/types.js'
|
|
3
|
-
|
|
4
|
-
export type SignRawPayloadParameters = {
|
|
5
|
-
/** The organization ID */
|
|
6
|
-
organizationId: string
|
|
7
|
-
/** The project ID for the request */
|
|
8
|
-
projectId: string
|
|
9
|
-
/** The session token for authorization */
|
|
10
|
-
token: string
|
|
11
|
-
/** The address to sign with */
|
|
12
|
-
address: Hex
|
|
13
|
-
/** The payload hash to sign (without 0x prefix) */
|
|
14
|
-
payload: string
|
|
15
|
-
/** The encoding type */
|
|
16
|
-
encoding?: 'PAYLOAD_ENCODING_HEXADECIMAL' | 'PAYLOAD_ENCODING_EIP712'
|
|
17
|
-
/** The hash function type */
|
|
18
|
-
hashFunction?: 'HASH_FUNCTION_NO_OP'
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type SignRawPayloadReturnType = Hex
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Signs a raw payload with the user's wallet
|
|
25
|
-
*
|
|
26
|
-
* @param client - The ZeroDev Wallet client
|
|
27
|
-
* @param params - The parameters for signing
|
|
28
|
-
* @returns The signature
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* const result = await signRawPayload(client, {
|
|
33
|
-
* organizationId: 'org_123',
|
|
34
|
-
* projectId: 'proj_456',
|
|
35
|
-
* address: '0x123...',
|
|
36
|
-
* payload: 'abc123...',
|
|
37
|
-
* });
|
|
38
|
-
* console.log(result.signature); // '0x...'
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export async function signRawPayload(
|
|
42
|
-
client: Client,
|
|
43
|
-
params: SignRawPayloadParameters,
|
|
44
|
-
): Promise<SignRawPayloadReturnType> {
|
|
45
|
-
const {
|
|
46
|
-
organizationId,
|
|
47
|
-
projectId,
|
|
48
|
-
token,
|
|
49
|
-
address,
|
|
50
|
-
payload,
|
|
51
|
-
encoding = 'PAYLOAD_ENCODING_HEXADECIMAL',
|
|
52
|
-
hashFunction = 'HASH_FUNCTION_NO_OP',
|
|
53
|
-
} = params
|
|
54
|
-
|
|
55
|
-
const { signature } = await client.request({
|
|
56
|
-
path: `${projectId}/sign/raw-payload`,
|
|
57
|
-
body: {
|
|
58
|
-
type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',
|
|
59
|
-
timestampMs: Date.now().toString(),
|
|
60
|
-
organizationId,
|
|
61
|
-
parameters: {
|
|
62
|
-
signWith: address,
|
|
63
|
-
payload,
|
|
64
|
-
encoding,
|
|
65
|
-
hashFunction,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
headers: {
|
|
69
|
-
Authorization: `Bearer ${token}`,
|
|
70
|
-
},
|
|
71
|
-
stamp: true,
|
|
72
|
-
stampPostion: 'headers',
|
|
73
|
-
})
|
|
74
|
-
return signature as Hex
|
|
75
|
-
}
|