@account-kit/signer 4.0.0-alpha.1 → 4.0.0-alpha.11
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/base.js +8 -1
- package/dist/cjs/base.js.map +1 -1
- package/dist/cjs/client/base.d.ts +3 -2
- package/dist/cjs/client/base.js +13 -0
- package/dist/cjs/client/base.js.map +1 -1
- package/dist/cjs/client/index.js +2 -1
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/client/types.d.ts +4 -0
- package/dist/cjs/client/types.js.map +1 -1
- package/dist/cjs/index.d.ts +5 -4
- package/dist/cjs/index.js +9 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/signer.d.ts +5 -1
- package/dist/cjs/signer.js +5 -5
- package/dist/cjs/signer.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/base.js +8 -1
- package/dist/esm/base.js.map +1 -1
- package/dist/esm/client/base.d.ts +3 -2
- package/dist/esm/client/base.js +13 -0
- package/dist/esm/client/base.js.map +1 -1
- package/dist/esm/client/index.js +2 -1
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/types.d.ts +4 -0
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/index.d.ts +5 -4
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/signer.d.ts +5 -1
- package/dist/esm/signer.js +5 -5
- package/dist/esm/signer.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/base.d.ts +248 -14
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/client/base.d.ts +63 -7
- package/dist/types/client/base.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +158 -0
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +4 -0
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/signer.d.ts +26 -4
- package/dist/types/signer.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/base.ts +266 -18
- package/src/client/base.ts +74 -8
- package/src/client/index.ts +161 -2
- package/src/client/types.ts +5 -0
- package/src/index.ts +5 -6
- package/src/signer.ts +32 -6
- package/src/version.ts +1 -1
package/dist/types/base.d.ts
CHANGED
|
@@ -9,29 +9,83 @@ export interface BaseAlchemySignerParams<TClient extends BaseSignerClient> {
|
|
|
9
9
|
client: TClient;
|
|
10
10
|
sessionConfig?: Omit<SessionManagerParams, "client">;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Base abstract class for Alchemy Signer, providing authentication and session management for smart accounts.
|
|
14
|
+
* Implements the `SmartAccountAuthenticator` interface and handles various signer events.
|
|
15
|
+
*/
|
|
12
16
|
export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient> implements SmartAccountAuthenticator<AuthParams, User, TClient> {
|
|
13
17
|
signerType: string;
|
|
14
18
|
inner: TClient;
|
|
15
19
|
private sessionManager;
|
|
16
20
|
private store;
|
|
21
|
+
/**
|
|
22
|
+
* Initializes an instance with the provided client and session configuration.
|
|
23
|
+
* This function sets up the internal store, initializes the session manager,
|
|
24
|
+
* registers listeners and initializes the session manager to manage session state.
|
|
25
|
+
*
|
|
26
|
+
* @param {BaseAlchemySignerParams<TClient>} param0 Object containing the client and session configuration
|
|
27
|
+
* @param {TClient} param0.client The client instance to be used internally
|
|
28
|
+
* @param {SessionConfig} param0.sessionConfig Configuration for managing sessions
|
|
29
|
+
*/
|
|
17
30
|
constructor({ client, sessionConfig }: BaseAlchemySignerParams<TClient>);
|
|
18
31
|
/**
|
|
19
32
|
* Allows you to subscribe to events emitted by the signer
|
|
20
33
|
*
|
|
21
|
-
* @param event the event to subscribe to
|
|
22
|
-
* @param listener the function to run when the event is emitted
|
|
23
|
-
* @returns a function to remove the listener
|
|
34
|
+
* @param {AlchemySignerEvent} event the event to subscribe to
|
|
35
|
+
* @param {AlchemySignerEvents[AlchemySignerEvent]} listener the function to run when the event is emitted
|
|
36
|
+
* @returns {() => void} a function to remove the listener
|
|
24
37
|
*/
|
|
25
38
|
on: <E extends keyof AlchemySignerEvents>(event: E, listener: AlchemySignerEvents[E]) => () => void;
|
|
26
39
|
/**
|
|
27
40
|
* Authenticate a user with either an email or a passkey and create a session for that user
|
|
28
41
|
*
|
|
29
|
-
* @
|
|
30
|
-
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
45
|
+
*
|
|
46
|
+
* const signer = new AlchemyWebSigner({
|
|
47
|
+
* client: {
|
|
48
|
+
* connection: {
|
|
49
|
+
* rpcUrl: "/api/rpc",
|
|
50
|
+
* },
|
|
51
|
+
* iframeConfig: {
|
|
52
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
53
|
+
* },
|
|
54
|
+
* },
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* const result = await signer.authenticate({
|
|
58
|
+
* type: "email",
|
|
59
|
+
* email: "foo@mail.com",
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @param {AuthParams} params - undefined if passkey login, otherwise an object with email and bundle to resolve
|
|
64
|
+
* @returns {Promise<User>} the user that was authenticated
|
|
31
65
|
*/
|
|
32
66
|
authenticate: (params: AuthParams) => Promise<User>;
|
|
33
67
|
/**
|
|
34
|
-
*
|
|
68
|
+
* Clear a user session and log them out
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
73
|
+
*
|
|
74
|
+
* const signer = new AlchemyWebSigner({
|
|
75
|
+
* client: {
|
|
76
|
+
* connection: {
|
|
77
|
+
* rpcUrl: "/api/rpc",
|
|
78
|
+
* },
|
|
79
|
+
* iframeConfig: {
|
|
80
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
81
|
+
* },
|
|
82
|
+
* },
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* await signer.disconnect();
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @returns {Promise<void>} a promise that resolves when the user is logged out
|
|
35
89
|
*/
|
|
36
90
|
disconnect: () => Promise<void>;
|
|
37
91
|
/**
|
|
@@ -39,21 +93,146 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
39
93
|
* If a user has an ongoing session, it will use that session and
|
|
40
94
|
* try to authenticate
|
|
41
95
|
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
99
|
+
*
|
|
100
|
+
* const signer = new AlchemyWebSigner({
|
|
101
|
+
* client: {
|
|
102
|
+
* connection: {
|
|
103
|
+
* rpcUrl: "/api/rpc",
|
|
104
|
+
* },
|
|
105
|
+
* iframeConfig: {
|
|
106
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
107
|
+
* },
|
|
108
|
+
* },
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* // throws if not logged in
|
|
112
|
+
* const user = await signer.getAuthDetails();
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
42
115
|
* @throws if there is no user logged in
|
|
43
|
-
* @returns the current user
|
|
116
|
+
* @returns {Promise<User>} the current user
|
|
44
117
|
*/
|
|
45
118
|
getAuthDetails: () => Promise<User>;
|
|
119
|
+
/**
|
|
120
|
+
* Retrieves the address of the current user by calling the `whoami` method on `this.inner`.
|
|
121
|
+
*
|
|
122
|
+
* @returns {Promise<string>} A promise that resolves to the address of the current user.
|
|
123
|
+
*/
|
|
46
124
|
getAddress: () => Promise<`0x${string}`>;
|
|
125
|
+
/**
|
|
126
|
+
* Signs a raw message after hashing it.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
131
|
+
*
|
|
132
|
+
* const signer = new AlchemyWebSigner({
|
|
133
|
+
* client: {
|
|
134
|
+
* connection: {
|
|
135
|
+
* rpcUrl: "/api/rpc",
|
|
136
|
+
* },
|
|
137
|
+
* iframeConfig: {
|
|
138
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
139
|
+
* },
|
|
140
|
+
* },
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* const signature = await signer.signMessage("Hello, world!");
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @param {string} msg the message to be hashed and then signed
|
|
147
|
+
* @returns {Promise<string>} a promise that resolves to the signed message
|
|
148
|
+
*/
|
|
47
149
|
signMessage: (msg: SignableMessage) => Promise<`0x${string}`>;
|
|
150
|
+
/**
|
|
151
|
+
* Signs a typed message by first hashing it and then signing the hashed message using the `signRawMessage` method.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
156
|
+
*
|
|
157
|
+
* const signer = new AlchemyWebSigner({
|
|
158
|
+
* client: {
|
|
159
|
+
* connection: {
|
|
160
|
+
* rpcUrl: "/api/rpc",
|
|
161
|
+
* },
|
|
162
|
+
* iframeConfig: {
|
|
163
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
164
|
+
* },
|
|
165
|
+
* },
|
|
166
|
+
* });
|
|
167
|
+
*
|
|
168
|
+
* const signature = await signer.signTypedData({
|
|
169
|
+
* domain: {},
|
|
170
|
+
* types: {},
|
|
171
|
+
* primaryType: "",
|
|
172
|
+
* message: {},
|
|
173
|
+
* });
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters for the typed message to be hashed and signed
|
|
177
|
+
* @returns {Promise<any>} A promise that resolves to the signed message
|
|
178
|
+
*/
|
|
48
179
|
signTypedData: <const TTypedData extends TypedData | {
|
|
49
180
|
[key: string]: unknown;
|
|
50
181
|
}, TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
182
|
+
/**
|
|
183
|
+
* Serializes a transaction, signs it with a raw message, and then returns the serialized transaction with the signature.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
188
|
+
*
|
|
189
|
+
* const signer = new AlchemyWebSigner({
|
|
190
|
+
* client: {
|
|
191
|
+
* connection: {
|
|
192
|
+
* rpcUrl: "/api/rpc",
|
|
193
|
+
* },
|
|
194
|
+
* iframeConfig: {
|
|
195
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
196
|
+
* },
|
|
197
|
+
* },
|
|
198
|
+
* });
|
|
199
|
+
*
|
|
200
|
+
* const tx = await signer.signTransaction({
|
|
201
|
+
* to: "0x1234",
|
|
202
|
+
* value: "0x1234",
|
|
203
|
+
* data: "0x1234",
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @param {Transaction} tx the transaction to be serialized and signed
|
|
208
|
+
* @param {{serializer?: SerializeTransactionFn}} args options for serialization
|
|
209
|
+
* @param {() => Hex} [args.serializer] an optional serializer function. If not provided, the default `serializeTransaction` function will be used
|
|
210
|
+
* @returns {Promise<string>} a promise that resolves to the serialized transaction with the signature
|
|
211
|
+
*/
|
|
51
212
|
signTransaction: CustomSource["signTransaction"];
|
|
52
213
|
/**
|
|
53
214
|
* Unauthenticated call to look up a user's organizationId by email
|
|
54
215
|
*
|
|
55
|
-
* @
|
|
56
|
-
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
219
|
+
*
|
|
220
|
+
* const signer = new AlchemyWebSigner({
|
|
221
|
+
* client: {
|
|
222
|
+
* connection: {
|
|
223
|
+
* rpcUrl: "/api/rpc",
|
|
224
|
+
* },
|
|
225
|
+
* iframeConfig: {
|
|
226
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
227
|
+
* },
|
|
228
|
+
* },
|
|
229
|
+
* });
|
|
230
|
+
*
|
|
231
|
+
* const result = await signer.getUser("foo@mail.com");
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* @param {string} email the email to lookup
|
|
235
|
+
* @returns {Promise<{orgId: string}>} the organization id for the user if they exist
|
|
57
236
|
*/
|
|
58
237
|
getUser: (email: string) => Promise<{
|
|
59
238
|
orgId: string;
|
|
@@ -61,8 +240,26 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
61
240
|
/**
|
|
62
241
|
* Adds a passkey to the user's account
|
|
63
242
|
*
|
|
64
|
-
* @
|
|
65
|
-
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
246
|
+
*
|
|
247
|
+
* const signer = new AlchemyWebSigner({
|
|
248
|
+
* client: {
|
|
249
|
+
* connection: {
|
|
250
|
+
* rpcUrl: "/api/rpc",
|
|
251
|
+
* },
|
|
252
|
+
* iframeConfig: {
|
|
253
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
254
|
+
* },
|
|
255
|
+
* },
|
|
256
|
+
* });
|
|
257
|
+
*
|
|
258
|
+
* const result = await signer.addPasskey()
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* @param {CredentialCreationOptions | undefined} params optional parameters for the passkey creation
|
|
262
|
+
* @returns {Promise<string[]>} an array of the authenticator ids added to the user
|
|
66
263
|
*/
|
|
67
264
|
addPasskey: (params?: CredentialCreationOptions) => Promise<string[]>;
|
|
68
265
|
/**
|
|
@@ -70,16 +267,53 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
70
267
|
* If the user is authenticated with an Email, this will return a seed phrase
|
|
71
268
|
* If the user is authenticated with a Passkey, this will return a private key
|
|
72
269
|
*
|
|
73
|
-
* @
|
|
74
|
-
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
273
|
+
*
|
|
274
|
+
* const signer = new AlchemyWebSigner({
|
|
275
|
+
* client: {
|
|
276
|
+
* connection: {
|
|
277
|
+
* rpcUrl: "/api/rpc",
|
|
278
|
+
* },
|
|
279
|
+
* iframeConfig: {
|
|
280
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
281
|
+
* },
|
|
282
|
+
* },
|
|
283
|
+
* });
|
|
284
|
+
*
|
|
285
|
+
* // the params passed to this are different based on the specific signer
|
|
286
|
+
* const result = signer.exportWallet()
|
|
287
|
+
* ```
|
|
288
|
+
*
|
|
289
|
+
* @param {unknown} params export wallet parameters
|
|
290
|
+
* @returns {boolean} true if the wallet was exported successfully
|
|
75
291
|
*/
|
|
76
292
|
exportWallet: (params: Parameters<(typeof this.inner)["exportWallet"]>[0]) => Promise<boolean>;
|
|
77
293
|
/**
|
|
78
294
|
* This method lets you adapt your AlchemySigner to a viem LocalAccount, which
|
|
79
295
|
* will let you use the signer as an EOA directly.
|
|
80
296
|
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```ts
|
|
299
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
300
|
+
*
|
|
301
|
+
* const signer = new AlchemyWebSigner({
|
|
302
|
+
* client: {
|
|
303
|
+
* connection: {
|
|
304
|
+
* rpcUrl: "/api/rpc",
|
|
305
|
+
* },
|
|
306
|
+
* iframeConfig: {
|
|
307
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
308
|
+
* },
|
|
309
|
+
* },
|
|
310
|
+
* });
|
|
311
|
+
*
|
|
312
|
+
* const account = signer.toViemAccount();
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
81
315
|
* @throws if your signer is not authenticated
|
|
82
|
-
* @returns a LocalAccount object that can be used with viem's wallet client
|
|
316
|
+
* @returns {LocalAccount} a LocalAccount object that can be used with viem's wallet client
|
|
83
317
|
*/
|
|
84
318
|
toViemAccount: () => LocalAccount;
|
|
85
319
|
private authenticateWithEmail;
|
package/dist/types/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AAKd,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,uBAAuB,CAAC,OAAO,SAAS,gBAAgB;IACvE,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;CACtD;AAYD,8BAAsB,iBAAiB,CAAC,OAAO,SAAS,gBAAgB,CACtE,YAAW,yBAAyB,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC;IAE/D,UAAU,EAAE,MAAM,CAAoB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,cAAc,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CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KACvD,OAAO,CAAC,OAAO,CAAC,CAEnB;IAEF;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,aAAa,QAAO,YAAY,CAkB9B;IAEF,OAAO,CAAC,qBAAqB,CAkD3B;IAEF,OAAO,CAAC,uBAAuB,CAoC7B;IAEF,OAAO,CAAC,iBAAiB,CA0BvB;CACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ConnectionConfig } from "@aa-sdk/core";
|
|
2
|
-
import { TurnkeyClient } from "@turnkey/http";
|
|
2
|
+
import { TurnkeyClient, type TSignedRequest } from "@turnkey/http";
|
|
3
3
|
import EventEmitter from "eventemitter3";
|
|
4
4
|
import type { Hex } from "viem";
|
|
5
5
|
import type { AlchemySignerClientEvents, CreateAccountParams, EmailAuthParams, GetWebAuthnAttestationResult, SignerBody, SignerResponse, SignupResponse, User } from "./types.js";
|
|
@@ -31,7 +31,20 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
31
31
|
constructor(params: BaseSignerClientParams);
|
|
32
32
|
protected get user(): User | undefined;
|
|
33
33
|
protected set user(user: User | undefined);
|
|
34
|
+
/**
|
|
35
|
+
* Sets the stamper of the TurnkeyClient.
|
|
36
|
+
*
|
|
37
|
+
* @param {TurnkeyClient["stamper"]} stamper the stamper function to set for the TurnkeyClient
|
|
38
|
+
*/
|
|
34
39
|
protected setStamper(stamper: TurnkeyClient["stamper"]): void;
|
|
40
|
+
/**
|
|
41
|
+
* Exports wallet credentials based on the specified type, either as a SEED_PHRASE or PRIVATE_KEY.
|
|
42
|
+
*
|
|
43
|
+
* @param {object} params The parameters for exporting the wallet
|
|
44
|
+
* @param {ExportWalletStamper} params.exportStamper The stamper used for exporting the wallet
|
|
45
|
+
* @param {"SEED_PHRASE" | "PRIVATE_KEY"} params.exportAs Specifies the format for exporting the wallet, either as a SEED_PHRASE or PRIVATE_KEY
|
|
46
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the export is successful
|
|
47
|
+
*/
|
|
35
48
|
protected exportWalletInner(params: {
|
|
36
49
|
exportStamper: ExportWalletStamper;
|
|
37
50
|
exportAs: "SEED_PHRASE" | "PRIVATE_KEY";
|
|
@@ -53,13 +66,43 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
53
66
|
/**
|
|
54
67
|
* Listen to events emitted by the client
|
|
55
68
|
*
|
|
56
|
-
* @param event the event you want to listen to
|
|
57
|
-
* @param listener the callback function to execute when an event is fired
|
|
58
|
-
* @returns a function that will remove the listener when called
|
|
69
|
+
* @param {AlchemySignerClientEvent} event the event you want to listen to
|
|
70
|
+
* @param {AlchemySignerClientEvents[AlchemySignerClientEvent]} listener the callback function to execute when an event is fired
|
|
71
|
+
* @returns {() => void} a function that will remove the listener when called
|
|
59
72
|
*/
|
|
60
73
|
on: <E extends keyof AlchemySignerClientEvents>(event: E, listener: AlchemySignerClientEvents[E]) => () => EventEmitter<AlchemySignerClientEvents, any>;
|
|
74
|
+
/**
|
|
75
|
+
* Handles the creation of authenticators using WebAuthn attestation and the provided options. Requires the user to be authenticated.
|
|
76
|
+
*
|
|
77
|
+
* @param {CredentialCreationOptions} options The options used to create the WebAuthn attestation
|
|
78
|
+
* @returns {Promise<string[]>} A promise that resolves to an array of authenticator IDs
|
|
79
|
+
* @throws {NotAuthenticatedError} If the user is not authenticated
|
|
80
|
+
*/
|
|
61
81
|
addPasskey: (options: CredentialCreationOptions) => Promise<string[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the current user or fetches the user information if not already available.
|
|
84
|
+
*
|
|
85
|
+
* @param {string} [orgId] optional organization ID, defaults to the user's organization ID
|
|
86
|
+
* @returns {Promise<User>} A promise that resolves to the user object
|
|
87
|
+
* @throws {Error} if no organization ID is provided when there is no current user
|
|
88
|
+
*/
|
|
62
89
|
whoami: (orgId?: string | undefined) => Promise<User>;
|
|
90
|
+
/**
|
|
91
|
+
* Generates a stamped whoami request for the current user. This request can then be used to call /signer/v1/whoami to get the user information.
|
|
92
|
+
* This is useful if you want to get the user information in a different context like a server. You can pass the stamped request to the server
|
|
93
|
+
* and then call our API to get the user information. Using this stamp is the most trusted way to get the user information since a stamp can only
|
|
94
|
+
* belong to the user who created it.
|
|
95
|
+
*
|
|
96
|
+
* @returns {Promise<TSignedRequest>} a promise that resolves to the "whoami" information for the logged in user
|
|
97
|
+
* @throws {Error} if no organization ID is provided
|
|
98
|
+
*/
|
|
99
|
+
stampWhoami: () => Promise<TSignedRequest>;
|
|
100
|
+
/**
|
|
101
|
+
* Looks up information based on an email address.
|
|
102
|
+
*
|
|
103
|
+
* @param {string} email the email address to look up
|
|
104
|
+
* @returns {Promise<any>} the result of the lookup request
|
|
105
|
+
*/
|
|
63
106
|
lookupUserByEmail: (email: string) => Promise<{
|
|
64
107
|
orgId: string | null;
|
|
65
108
|
}>;
|
|
@@ -68,11 +111,24 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
68
111
|
* For SignMessage or SignTypedData, the caller should hash the message before calling this method and pass
|
|
69
112
|
* that result here.
|
|
70
113
|
*
|
|
71
|
-
* @param msg the hex representation of the bytes to sign
|
|
72
|
-
* @returns the signature over the raw hex
|
|
114
|
+
* @param {Hex} msg the hex representation of the bytes to sign
|
|
115
|
+
* @returns {Promise<Hex>} the signature over the raw hex
|
|
116
|
+
*/
|
|
117
|
+
signRawMessage: (msg: Hex) => Promise<Hex>;
|
|
118
|
+
/**
|
|
119
|
+
* Returns the current user or null if no user is set.
|
|
120
|
+
*
|
|
121
|
+
* @returns {User | null} the current user object or null if no user is available
|
|
73
122
|
*/
|
|
74
|
-
signRawMessage: (msg: Hex) => Promise<`0x${string}`>;
|
|
75
123
|
getUser: () => User | null;
|
|
124
|
+
/**
|
|
125
|
+
* Sends a POST request to the given signer route with the specified body and returns the response.
|
|
126
|
+
* Not intended to be used directly, use the specific methods instead on the client instead.
|
|
127
|
+
*
|
|
128
|
+
* @param {SignerRoutes} route The route to which the request should be sent
|
|
129
|
+
* @param {SignerBody<R>} body The request body containing the data to be sent
|
|
130
|
+
* @returns {Promise<SignerResponse<R>>} A promise that resolves to the response from the signer
|
|
131
|
+
*/
|
|
76
132
|
request: <R extends "/v1/signup" | "/v1/whoami" | "/v1/auth" | "/v1/lookup" | "/v1/sign-payload">(route: R, body: SignerBody<R>) => Promise<SignerResponse<R>>;
|
|
77
133
|
private exportAsSeedPhrase;
|
|
78
134
|
private exportAsPrivateKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/client/base.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/client/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAGhC,OAAO,KAAK,EAEV,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,4BAA4B,EAC5B,UAAU,EACV,cAAc,EAEd,cAAc,EACd,IAAI,EACL,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC,SAAS,CAAC,GAAG;IAC3D,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,qBAAqB,CAAC,MAAM,EAA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per;
|
|
123
123
|
iframeContainerId: string;
|
|
124
|
+
/**
|
|
125
|
+
* Initializes a new instance with the given parameters, setting up the connection, iframe configuration, and WebAuthn stamper.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
130
|
+
*
|
|
131
|
+
* const client = new AlchemySignerWebClient({
|
|
132
|
+
* connection: {
|
|
133
|
+
* apiKey: "your-api-key",
|
|
134
|
+
* },
|
|
135
|
+
* iframeConfig: {
|
|
136
|
+
* iframeContainerId: "signer-iframe-container",
|
|
137
|
+
* },
|
|
138
|
+
* });
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* @param {AlchemySignerClientParams} params the parameters required to initialize the client
|
|
142
|
+
* @param {ConnectionConfig} params.connection The connection details needed to connect to the service
|
|
143
|
+
* @param {{ iframeElementId?: string; iframeContainerId: string }} params.iframeConfig The configuration details for setting up the iframe stamper
|
|
144
|
+
* @param {string} params.rpId The relying party ID, defaulting to the current hostname if not provided
|
|
145
|
+
* @param {string} params.rootOrgId The root organization ID
|
|
146
|
+
*/
|
|
124
147
|
constructor(params: AlchemySignerClientParams);
|
|
148
|
+
/**
|
|
149
|
+
* Authenticates the user by either email or passkey account creation flow. Emits events during the process.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
154
|
+
*
|
|
155
|
+
* const client = new AlchemySignerWebClient({
|
|
156
|
+
* connection: {
|
|
157
|
+
* apiKey: "your-api-key",
|
|
158
|
+
* },
|
|
159
|
+
* iframeConfig: {
|
|
160
|
+
* iframeContainerId: "signer-iframe-container",
|
|
161
|
+
* },
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* const account = await client.createAccount({ type: "email", email: "you@mail.com" });
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @param {CreateAccountParams} params The parameters for creating an account, including the type (email or passkey) and additional details.
|
|
168
|
+
* @returns {Promise<SignupResponse>} A promise that resolves with the response object containing the account creation result.
|
|
169
|
+
*/
|
|
125
170
|
createAccount: (params: CreateAccountParams) => Promise<import("./types.js").SignupResponse>;
|
|
171
|
+
/**
|
|
172
|
+
* Begin authenticating a user with their email and an expiration time for the authentication request. Initializes the iframe stamper to get the target public key.
|
|
173
|
+
* This method sends an email to the user to complete their login
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
178
|
+
*
|
|
179
|
+
* const client = new AlchemySignerWebClient({
|
|
180
|
+
* connection: {
|
|
181
|
+
* apiKey: "your-api-key",
|
|
182
|
+
* },
|
|
183
|
+
* iframeConfig: {
|
|
184
|
+
* iframeContainerId: "signer-iframe-container",
|
|
185
|
+
* },
|
|
186
|
+
* });
|
|
187
|
+
*
|
|
188
|
+
* const account = await client.initEmailAuth({ email: "you@mail.com" });
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* @param {Omit<EmailAuthParams, "targetPublicKey">} params The parameters for email authentication, excluding the target public key
|
|
192
|
+
* @returns {Promise<any>} The response from the authentication request
|
|
193
|
+
*/
|
|
126
194
|
initEmailAuth: (params: Omit<EmailAuthParams, "targetPublicKey">) => Promise<{
|
|
127
195
|
orgId: string;
|
|
128
196
|
}>;
|
|
197
|
+
/**
|
|
198
|
+
* Completes email auth for the user by injecting a credential bundle and retrieving the user information based on the provided organization ID. Emits events during the process.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
203
|
+
*
|
|
204
|
+
* const client = new AlchemySignerWebClient({
|
|
205
|
+
* connection: {
|
|
206
|
+
* apiKey: "your-api-key",
|
|
207
|
+
* },
|
|
208
|
+
* iframeConfig: {
|
|
209
|
+
* iframeContainerId: "signer-iframe-container",
|
|
210
|
+
* },
|
|
211
|
+
* });
|
|
212
|
+
*
|
|
213
|
+
* const account = await client.completeEmailAuth({ orgId: "user-org-id", bundle: "bundle-from-email" });
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* @param {{ bundle: string; orgId: string }} config The configuration object for the authentication function containing the credential bundle to inject and the organization id associated with the user
|
|
217
|
+
* @returns {Promise<User>} A promise that resolves to the authenticated user information
|
|
218
|
+
*/
|
|
129
219
|
completeEmailAuth: ({ bundle, orgId, }: {
|
|
130
220
|
bundle: string;
|
|
131
221
|
orgId: string;
|
|
132
222
|
}) => Promise<User>;
|
|
223
|
+
/**
|
|
224
|
+
* Asynchronously handles the authentication process using WebAuthn Stamper. If a user is provided, sets the user and returns it. Otherwise, retrieves the current user and initializes the WebAuthn stamper.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
229
|
+
*
|
|
230
|
+
* const client = new AlchemySignerWebClient({
|
|
231
|
+
* connection: {
|
|
232
|
+
* apiKey: "your-api-key",
|
|
233
|
+
* },
|
|
234
|
+
* iframeConfig: {
|
|
235
|
+
* iframeContainerId: "signer-iframe-container",
|
|
236
|
+
* },
|
|
237
|
+
* });
|
|
238
|
+
*
|
|
239
|
+
* const account = await client.lookupUserWithPasskey();
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
242
|
+
* @param {User} [user] An optional user object to authenticate
|
|
243
|
+
* @returns {Promise<User>} A promise that resolves to the authenticated user object
|
|
244
|
+
*/
|
|
133
245
|
lookupUserWithPasskey: (user?: User | undefined) => Promise<User>;
|
|
246
|
+
/**
|
|
247
|
+
* Initiates the export of a wallet by creating an iframe stamper and calling the appropriate export function.
|
|
248
|
+
* The export can be based on a seed phrase or a private key.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
253
|
+
*
|
|
254
|
+
* const client = new AlchemySignerWebClient({
|
|
255
|
+
* connection: {
|
|
256
|
+
* apiKey: "your-api-key",
|
|
257
|
+
* },
|
|
258
|
+
* iframeConfig: {
|
|
259
|
+
* iframeContainerId: "signer-iframe-container",
|
|
260
|
+
* },
|
|
261
|
+
* });
|
|
262
|
+
*
|
|
263
|
+
* const account = await client.exportWallet({
|
|
264
|
+
* iframeContainerId: "export-iframe-container",
|
|
265
|
+
* });
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* @param {ExportWalletParams} config The parameters for exporting the wallet
|
|
269
|
+
* @param {string} config.iframeContainerId The ID of the container element that will hold the iframe stamper
|
|
270
|
+
* @param {string} [config.iframeElementId] Optional ID for the iframe element
|
|
271
|
+
* @returns {Promise<void>} A promise that resolves when the export process is complete
|
|
272
|
+
*/
|
|
134
273
|
exportWallet: ({ iframeContainerId, iframeElementId, }: ExportWalletParams) => Promise<boolean>;
|
|
274
|
+
/**
|
|
275
|
+
* Asynchronous function that clears the user and resets the iframe stamper.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* import { AlchemySignerWebClient } from "@account-kit/signer";
|
|
280
|
+
*
|
|
281
|
+
* const client = new AlchemySignerWebClient({
|
|
282
|
+
* connection: {
|
|
283
|
+
* apiKey: "your-api-key",
|
|
284
|
+
* },
|
|
285
|
+
* iframeConfig: {
|
|
286
|
+
* iframeContainerId: "signer-iframe-container",
|
|
287
|
+
* },
|
|
288
|
+
* });
|
|
289
|
+
*
|
|
290
|
+
* const account = await client.disconnect();
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
135
293
|
disconnect: () => Promise<void>;
|
|
136
294
|
private initIframeStamper;
|
|
137
295
|
private initWebauthnStamper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,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aAAa,CAAgB;IACrC,OAAO,CAAC,eAAe,CAAkB;IACzC,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;;;;;;;;;;;;;;;;;;;;;OAsBG;gBACS,MAAM,EAAE,yBAAyB;IAwB7C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,aAAa,WAAkB,mBAAmB,kDAwChD;IAEF;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACI,aAAa,WACV,KAAK,eAAe,EAAE,iBAAiB,CAAC;;OAYhD;IAEF;;;;;;;;;;;;;;;;;;;;;OAqBG;IACI,iBAAiB;gBAId,MAAM;eACP,MAAM;wBAeb;IAEF;;;;;;;;;;;;;;;;;;;;;OAqBG;IACI,qBAAqB,UAAgB,IAAI,GAAG,SAAS,mBAa1D;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACI,YAAY,4CAGhB,kBAAkB,sBAmBnB;IAEF;;;;;;;;;;;;;;;;;;OAkBG;IACI,UAAU,sBAGf;IAEF,OAAO,CAAC,iBAAiB,CAQvB;IAEF,OAAO,CAAC,mBAAmB,CAYzB;IAEF,SAAS,CAAC,sBAAsB,aACpB,iCAAiC,gBAC9B;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE;;;;;;;;;OAmDjC;CACH"}
|
|
@@ -20,6 +20,10 @@ export type CreateAccountParams = {
|
|
|
20
20
|
email: string;
|
|
21
21
|
expirationSeconds?: number;
|
|
22
22
|
redirectParams?: URLSearchParams;
|
|
23
|
+
} | {
|
|
24
|
+
type: "passkey";
|
|
25
|
+
email: string;
|
|
26
|
+
creationOpts?: CredentialCreationOptionOverrides;
|
|
23
27
|
} | {
|
|
24
28
|
type: "passkey";
|
|
25
29
|
username: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,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