@fourt/sdk 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index-Cy_WMhHm.d.cts +19 -0
- package/dist/index-Cy_WMhHm.d.ts +19 -0
- package/dist/index.cjs +246 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +186 -9
- package/dist/index.d.ts +186 -9
- package/dist/index.js +252 -11
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.cts +1 -13
- package/dist/types/index.d.ts +1 -13
- package/package.json +9 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { getWebAuthnAttestation, TSignedRequest, TurnkeyClient } from '@turnkey/http';
|
|
2
|
-
import { User } from './
|
|
3
|
-
import
|
|
2
|
+
import { U as User, A as AtLeastOne } from './index-Cy_WMhHm.cjs';
|
|
3
|
+
import * as viem_account_abstraction from 'viem/account-abstraction';
|
|
4
|
+
import * as viem from 'viem';
|
|
5
|
+
import { LocalAccount, Client, SignableMessage, Hex, TypedData, TypedDataDefinition, SerializeTransactionFn, TransactionSerializable, IsNarrowable, TransactionSerialized, GetTransactionType } from 'viem';
|
|
4
6
|
import { toLightSmartAccount } from 'permissionless/accounts';
|
|
5
7
|
|
|
8
|
+
declare enum SessionType {
|
|
9
|
+
Email = "email",
|
|
10
|
+
Passkeys = "passkeys"
|
|
11
|
+
}
|
|
6
12
|
/**
|
|
7
13
|
* A store for the session state.
|
|
8
14
|
*/
|
|
@@ -12,6 +18,18 @@ declare class SessionStore {
|
|
|
12
18
|
* Initializes a new instance of the `SessionStore` class by creating a new `zustand`store with the initial state.
|
|
13
19
|
*/
|
|
14
20
|
constructor();
|
|
21
|
+
/**
|
|
22
|
+
* Gets the type from the session state.
|
|
23
|
+
*
|
|
24
|
+
* @returns {SessionType | undefined} the type.
|
|
25
|
+
*/
|
|
26
|
+
get type(): SessionType | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Sets the type in the session state.
|
|
29
|
+
*
|
|
30
|
+
* @param {SessionType} type the type to set.
|
|
31
|
+
*/
|
|
32
|
+
set type(type: SessionType);
|
|
15
33
|
/**
|
|
16
34
|
* Gets the token from the session state.
|
|
17
35
|
*
|
|
@@ -24,6 +42,18 @@ declare class SessionStore {
|
|
|
24
42
|
* @param {string} token the token to set.
|
|
25
43
|
*/
|
|
26
44
|
set token(token: string);
|
|
45
|
+
/**
|
|
46
|
+
* Gets the bundle from the session state.
|
|
47
|
+
*
|
|
48
|
+
* @returns {string | undefined} the bundle.
|
|
49
|
+
*/
|
|
50
|
+
get bundle(): string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Sets the bundle in the session state.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} bundle the bundle to set.
|
|
55
|
+
*/
|
|
56
|
+
set bundle(bundle: string);
|
|
27
57
|
/**
|
|
28
58
|
* Gets the user from the session state.
|
|
29
59
|
*
|
|
@@ -40,6 +70,14 @@ declare class SessionStore {
|
|
|
40
70
|
* Clears the user from the session state.
|
|
41
71
|
*/
|
|
42
72
|
clearUser(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Clears the bundle from the session state.
|
|
75
|
+
*/
|
|
76
|
+
clearBundle(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Clears the type from the session state.
|
|
79
|
+
*/
|
|
80
|
+
clearType(): void;
|
|
43
81
|
/**
|
|
44
82
|
* Clears the token from the session state.
|
|
45
83
|
*/
|
|
@@ -60,12 +98,30 @@ type AuthenticationServiceResponse<Route extends AuthenticationServiceRoutes> =
|
|
|
60
98
|
}>['Response'];
|
|
61
99
|
type AuthenticationServiceEndpoints = [
|
|
62
100
|
{
|
|
63
|
-
Route: '/v1/
|
|
101
|
+
Route: '/v1/email-auth';
|
|
64
102
|
Body: {
|
|
103
|
+
email: string;
|
|
104
|
+
targetPublicKey: string;
|
|
105
|
+
redirectUrl: string;
|
|
106
|
+
expirationSeconds?: number;
|
|
107
|
+
};
|
|
108
|
+
Response: {
|
|
109
|
+
subOrgId: string;
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
Route: '/v1/signup';
|
|
114
|
+
Body: AtLeastOne<{
|
|
65
115
|
passkey: {
|
|
66
116
|
challenge: string;
|
|
67
117
|
attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;
|
|
68
118
|
};
|
|
119
|
+
iframe: {
|
|
120
|
+
targetPublicKey: string;
|
|
121
|
+
redirectUrl: string;
|
|
122
|
+
expirationSeconds?: number;
|
|
123
|
+
};
|
|
124
|
+
}> & {
|
|
69
125
|
email: string;
|
|
70
126
|
};
|
|
71
127
|
Response: {
|
|
@@ -106,6 +162,7 @@ type AuthenticationServiceEndpoints = [
|
|
|
106
162
|
type SignerClientConfiguration = {
|
|
107
163
|
apiKey: string;
|
|
108
164
|
apiUrl?: string;
|
|
165
|
+
paymasterRpcUrl?: string;
|
|
109
166
|
};
|
|
110
167
|
type SignerClientConstructorParams = {
|
|
111
168
|
stamper: TurnkeyClient['stamper'];
|
|
@@ -114,11 +171,12 @@ type SignerClientConstructorParams = {
|
|
|
114
171
|
type SignerClientInheritedConstructorParams<Extended extends Record<string, unknown>> = Pick<SignerClientConstructorParams, 'configuration'> & Extended;
|
|
115
172
|
declare abstract class SignerClient {
|
|
116
173
|
protected readonly _turnkeyClient: TurnkeyClient;
|
|
117
|
-
protected readonly _configuration: Required<
|
|
174
|
+
protected readonly _configuration: Required<SignerClientConstructorParams['configuration']>;
|
|
118
175
|
protected readonly _sessionStore: SessionStore;
|
|
119
176
|
private _user?;
|
|
120
|
-
constructor({ stamper, configuration: { apiUrl, ...requiredConfiguration }, }: SignerClientConstructorParams);
|
|
177
|
+
constructor({ stamper, configuration: { apiUrl, paymasterRpcUrl, ...requiredConfiguration }, }: SignerClientConstructorParams);
|
|
121
178
|
logout(): void;
|
|
179
|
+
get configuration(): Required<SignerClientConfiguration>;
|
|
122
180
|
get user(): User | undefined;
|
|
123
181
|
protected set user(value: User | undefined);
|
|
124
182
|
protected set stamper(stamper: TurnkeyClient['stamper']);
|
|
@@ -133,10 +191,24 @@ declare abstract class SignerClient {
|
|
|
133
191
|
type WebauthnSignInParams = {
|
|
134
192
|
email: string;
|
|
135
193
|
};
|
|
194
|
+
type EmailInitializeAuthParams = {
|
|
195
|
+
email: string;
|
|
196
|
+
redirectUrl: string;
|
|
197
|
+
expirationSeconds?: number;
|
|
198
|
+
};
|
|
199
|
+
type EmailCompleteAuthWithBundleParams = {
|
|
200
|
+
bundle: string;
|
|
201
|
+
subOrgId: string;
|
|
202
|
+
isNewUser?: boolean;
|
|
203
|
+
};
|
|
136
204
|
type WebSignerClientConstructorParams = SignerClientInheritedConstructorParams<{
|
|
137
205
|
webauthn: {
|
|
138
206
|
rpId: string;
|
|
139
207
|
};
|
|
208
|
+
iframe?: {
|
|
209
|
+
iframeElementId?: string;
|
|
210
|
+
iframeContainerId?: string;
|
|
211
|
+
};
|
|
140
212
|
}>;
|
|
141
213
|
/**
|
|
142
214
|
* A signer client for web applications.
|
|
@@ -148,15 +220,58 @@ declare class WebSignerClient extends SignerClient {
|
|
|
148
220
|
*
|
|
149
221
|
* @param {WebSignerClientConstructorParams} params params for the constructor
|
|
150
222
|
*/
|
|
151
|
-
constructor({ configuration, webauthn }: WebSignerClientConstructorParams);
|
|
223
|
+
constructor({ configuration, webauthn, iframe, }: WebSignerClientConstructorParams);
|
|
224
|
+
signRawMessage<Into extends string>(msg: string): Promise<Into>;
|
|
225
|
+
logout(): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Checks for an existing session and if exists, updates the stamper accordingly.
|
|
228
|
+
*
|
|
229
|
+
*/
|
|
230
|
+
private updateStamper;
|
|
152
231
|
/**
|
|
153
232
|
* Signs in a user with webauthn.
|
|
154
233
|
*
|
|
155
234
|
* @param {WebauthnSignInParams} params params for the sign in
|
|
156
235
|
*/
|
|
157
236
|
webauthnSignIn({ email }: WebauthnSignInParams): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Handle auth user process with email.
|
|
239
|
+
*
|
|
240
|
+
* @param {EmailInitializeAuthParams} params Params needed for the initialization of the auth process
|
|
241
|
+
*/
|
|
242
|
+
emailAuth(params: EmailInitializeAuthParams): Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Signs in a user with email.
|
|
245
|
+
*
|
|
246
|
+
* @param {EmailInitializeAuthParams} params params for the sign in
|
|
247
|
+
*/
|
|
248
|
+
private _signInWithEmail;
|
|
249
|
+
/**
|
|
250
|
+
* Completes the authentication process with a credential bundle.
|
|
251
|
+
*
|
|
252
|
+
* @param {EmailCompleteAuthWithBundleParams} params params for the completion of the auth process
|
|
253
|
+
*/
|
|
254
|
+
completeAuthWithBundle({ bundle, subOrgId, }: EmailCompleteAuthWithBundleParams): Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* Creates a passkey account using the webauthn stamper.
|
|
257
|
+
*
|
|
258
|
+
* @param {Extract<CreateAccountParams, { method: 'webauthn' }>} params params for the creation of the account
|
|
259
|
+
*/
|
|
260
|
+
private _createWebauthnAccount;
|
|
261
|
+
/**
|
|
262
|
+
* Creates an email account using the iframe stamper.
|
|
263
|
+
*
|
|
264
|
+
* @param {Extract<CreateAccountParams, { method: 'email' }>} params params for the creation of the account
|
|
265
|
+
*/
|
|
266
|
+
private _createEmailAccount;
|
|
267
|
+
/**
|
|
268
|
+
* Handle the account creation process.
|
|
269
|
+
*
|
|
270
|
+
* @param {CreateAccountParams} params params to create an account
|
|
271
|
+
*/
|
|
158
272
|
private _createAccount;
|
|
159
273
|
private _webauthnGenerateAttestation;
|
|
274
|
+
private _initIframeStamper;
|
|
160
275
|
}
|
|
161
276
|
|
|
162
277
|
type CurrentUserToLightSmartAccountParams = {
|
|
@@ -168,6 +283,40 @@ declare class ViemModule {
|
|
|
168
283
|
constructor(_signerClient: SignerClient);
|
|
169
284
|
toLocalAccount(): Promise<LocalAccount>;
|
|
170
285
|
toSmartAccount({ client, owner, }: CurrentUserToLightSmartAccountParams): ReturnType<typeof toLightSmartAccount<'0.7'>>;
|
|
286
|
+
getPaymasterClient(): Promise<{
|
|
287
|
+
account: undefined;
|
|
288
|
+
batch?: viem.ClientConfig["batch"] | undefined;
|
|
289
|
+
cacheTime: number;
|
|
290
|
+
ccipRead?: viem.ClientConfig["ccipRead"] | undefined;
|
|
291
|
+
chain: undefined;
|
|
292
|
+
key: string;
|
|
293
|
+
name: string;
|
|
294
|
+
pollingInterval: number;
|
|
295
|
+
request: viem.EIP1193RequestFn<viem.PaymasterRpcSchema>;
|
|
296
|
+
transport: viem.TransportConfig<"http", viem.EIP1193RequestFn> & {
|
|
297
|
+
fetchOptions?: viem.HttpTransportConfig["fetchOptions"] | undefined;
|
|
298
|
+
url?: string | undefined;
|
|
299
|
+
};
|
|
300
|
+
type: string;
|
|
301
|
+
uid: string;
|
|
302
|
+
getPaymasterData: (parameters: viem_account_abstraction.GetPaymasterDataParameters) => Promise<viem_account_abstraction.GetPaymasterDataReturnType>;
|
|
303
|
+
getPaymasterStubData: (parameters: viem_account_abstraction.GetPaymasterStubDataParameters) => Promise<viem_account_abstraction.GetPaymasterStubDataReturnType>;
|
|
304
|
+
extend: <const client extends {
|
|
305
|
+
[x: string]: unknown;
|
|
306
|
+
account?: undefined;
|
|
307
|
+
batch?: undefined;
|
|
308
|
+
cacheTime?: undefined;
|
|
309
|
+
ccipRead?: undefined;
|
|
310
|
+
chain?: undefined;
|
|
311
|
+
key?: undefined;
|
|
312
|
+
name?: undefined;
|
|
313
|
+
pollingInterval?: undefined;
|
|
314
|
+
request?: undefined;
|
|
315
|
+
transport?: undefined;
|
|
316
|
+
type?: undefined;
|
|
317
|
+
uid?: undefined;
|
|
318
|
+
} & viem.ExactPartial<Pick<viem.PublicActions<viem.HttpTransport, undefined, undefined>, "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getChainId" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "prepareTransactionRequest" | "readContract" | "sendRawTransaction" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<viem.WalletActions<undefined, undefined>, "sendTransaction" | "writeContract">>>(fn: (client: Client<viem.HttpTransport, undefined, undefined, viem.PaymasterRpcSchema, viem_account_abstraction.PaymasterActions>) => client) => Client<viem.HttpTransport, undefined, undefined, viem.PaymasterRpcSchema, { [K in keyof client]: client[K]; } & viem_account_abstraction.PaymasterActions>;
|
|
319
|
+
}>;
|
|
171
320
|
signMessage(msg: SignableMessage): Promise<Hex>;
|
|
172
321
|
signTypedData<TTypedData extends TypedData | Record<string, unknown>, TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex>;
|
|
173
322
|
signTransaction<serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]>(transaction: transaction, options?: {
|
|
@@ -175,6 +324,29 @@ declare class ViemModule {
|
|
|
175
324
|
} | undefined): Promise<IsNarrowable<TransactionSerialized<GetTransactionType<transaction>>, Hex> extends true ? TransactionSerialized<GetTransactionType<transaction>> : Hex>;
|
|
176
325
|
}
|
|
177
326
|
|
|
327
|
+
/**
|
|
328
|
+
* A module for interacting with the Email authentication methods.
|
|
329
|
+
* Available through the `auth.email` property on a `FourtWebSigner` instance.
|
|
330
|
+
*/
|
|
331
|
+
declare class EmailModule {
|
|
332
|
+
private readonly _webSignerClient;
|
|
333
|
+
constructor(_webSignerClient: WebSignerClient);
|
|
334
|
+
/**
|
|
335
|
+
* Initialize user authentication process using email.
|
|
336
|
+
*
|
|
337
|
+
* @param params {EmailInitializeAuthParams} params to initialize the user authentication process.
|
|
338
|
+
* @returns {Promise<void>} promise that resolves to the result of the authentication process.
|
|
339
|
+
*/
|
|
340
|
+
initialize(params: EmailInitializeAuthParams): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Completes authentication with bundle after user receives the bundle and subOrgId as URL params.
|
|
343
|
+
*
|
|
344
|
+
* @param params {EmailCompleteAuthWithBundleParams} params received as URL params necessary to complete authentication process.
|
|
345
|
+
* @returns {Promise<void>} promise that completes the authentication process.
|
|
346
|
+
*/
|
|
347
|
+
complete(params: EmailCompleteAuthWithBundleParams): Promise<void>;
|
|
348
|
+
}
|
|
349
|
+
|
|
178
350
|
/**
|
|
179
351
|
* A module for interacting with the Passkeys authentication methods.
|
|
180
352
|
* Available through the `auth.passkeys` property on a `FourtWebSigner` instance.
|
|
@@ -198,6 +370,7 @@ declare class PasskeysModule {
|
|
|
198
370
|
declare class AuthModule {
|
|
199
371
|
private readonly _webSignerClient;
|
|
200
372
|
private readonly _passkeys;
|
|
373
|
+
private readonly _email;
|
|
201
374
|
/**
|
|
202
375
|
* Initializes a new instance of the `AuthModule` class.
|
|
203
376
|
*
|
|
@@ -208,6 +381,10 @@ declare class AuthModule {
|
|
|
208
381
|
* A module for interacting with the Passkeys authentication methods.
|
|
209
382
|
*/
|
|
210
383
|
get passkeys(): PasskeysModule;
|
|
384
|
+
/**
|
|
385
|
+
* A module for interacting with the Passkeys authentication methods.
|
|
386
|
+
*/
|
|
387
|
+
get email(): EmailModule;
|
|
211
388
|
}
|
|
212
389
|
|
|
213
390
|
/**
|
|
@@ -233,12 +410,12 @@ declare class UserModule {
|
|
|
233
410
|
*
|
|
234
411
|
* @returns {void}
|
|
235
412
|
*/
|
|
236
|
-
logout(): void
|
|
413
|
+
logout(): Promise<void>;
|
|
237
414
|
}
|
|
238
415
|
|
|
239
416
|
type FourtWebSignerConstructorParams = {
|
|
240
417
|
configuration: SignerClientConstructorParams['configuration'];
|
|
241
|
-
auth: Pick<WebSignerClientConstructorParams, 'webauthn'>;
|
|
418
|
+
auth: Pick<WebSignerClientConstructorParams, 'webauthn' | 'iframe'>;
|
|
242
419
|
};
|
|
243
420
|
/**
|
|
244
421
|
* A client for interacting with the Fourt Web Signer.
|
|
@@ -267,7 +444,7 @@ declare class FourtWebSigner {
|
|
|
267
444
|
*
|
|
268
445
|
* @param {FourtWebSignerConstructorParams} params the required parameters to initialize the client
|
|
269
446
|
*/
|
|
270
|
-
constructor({ configuration, auth: { webauthn }, }: FourtWebSignerConstructorParams);
|
|
447
|
+
constructor({ configuration, auth: { webauthn, iframe }, }: FourtWebSignerConstructorParams);
|
|
271
448
|
/**
|
|
272
449
|
* A module for interacting with the Viem library.
|
|
273
450
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { getWebAuthnAttestation, TSignedRequest, TurnkeyClient } from '@turnkey/http';
|
|
2
|
-
import { User } from './
|
|
3
|
-
import
|
|
2
|
+
import { U as User, A as AtLeastOne } from './index-Cy_WMhHm.js';
|
|
3
|
+
import * as viem_account_abstraction from 'viem/account-abstraction';
|
|
4
|
+
import * as viem from 'viem';
|
|
5
|
+
import { LocalAccount, Client, SignableMessage, Hex, TypedData, TypedDataDefinition, SerializeTransactionFn, TransactionSerializable, IsNarrowable, TransactionSerialized, GetTransactionType } from 'viem';
|
|
4
6
|
import { toLightSmartAccount } from 'permissionless/accounts';
|
|
5
7
|
|
|
8
|
+
declare enum SessionType {
|
|
9
|
+
Email = "email",
|
|
10
|
+
Passkeys = "passkeys"
|
|
11
|
+
}
|
|
6
12
|
/**
|
|
7
13
|
* A store for the session state.
|
|
8
14
|
*/
|
|
@@ -12,6 +18,18 @@ declare class SessionStore {
|
|
|
12
18
|
* Initializes a new instance of the `SessionStore` class by creating a new `zustand`store with the initial state.
|
|
13
19
|
*/
|
|
14
20
|
constructor();
|
|
21
|
+
/**
|
|
22
|
+
* Gets the type from the session state.
|
|
23
|
+
*
|
|
24
|
+
* @returns {SessionType | undefined} the type.
|
|
25
|
+
*/
|
|
26
|
+
get type(): SessionType | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Sets the type in the session state.
|
|
29
|
+
*
|
|
30
|
+
* @param {SessionType} type the type to set.
|
|
31
|
+
*/
|
|
32
|
+
set type(type: SessionType);
|
|
15
33
|
/**
|
|
16
34
|
* Gets the token from the session state.
|
|
17
35
|
*
|
|
@@ -24,6 +42,18 @@ declare class SessionStore {
|
|
|
24
42
|
* @param {string} token the token to set.
|
|
25
43
|
*/
|
|
26
44
|
set token(token: string);
|
|
45
|
+
/**
|
|
46
|
+
* Gets the bundle from the session state.
|
|
47
|
+
*
|
|
48
|
+
* @returns {string | undefined} the bundle.
|
|
49
|
+
*/
|
|
50
|
+
get bundle(): string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Sets the bundle in the session state.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} bundle the bundle to set.
|
|
55
|
+
*/
|
|
56
|
+
set bundle(bundle: string);
|
|
27
57
|
/**
|
|
28
58
|
* Gets the user from the session state.
|
|
29
59
|
*
|
|
@@ -40,6 +70,14 @@ declare class SessionStore {
|
|
|
40
70
|
* Clears the user from the session state.
|
|
41
71
|
*/
|
|
42
72
|
clearUser(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Clears the bundle from the session state.
|
|
75
|
+
*/
|
|
76
|
+
clearBundle(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Clears the type from the session state.
|
|
79
|
+
*/
|
|
80
|
+
clearType(): void;
|
|
43
81
|
/**
|
|
44
82
|
* Clears the token from the session state.
|
|
45
83
|
*/
|
|
@@ -60,12 +98,30 @@ type AuthenticationServiceResponse<Route extends AuthenticationServiceRoutes> =
|
|
|
60
98
|
}>['Response'];
|
|
61
99
|
type AuthenticationServiceEndpoints = [
|
|
62
100
|
{
|
|
63
|
-
Route: '/v1/
|
|
101
|
+
Route: '/v1/email-auth';
|
|
64
102
|
Body: {
|
|
103
|
+
email: string;
|
|
104
|
+
targetPublicKey: string;
|
|
105
|
+
redirectUrl: string;
|
|
106
|
+
expirationSeconds?: number;
|
|
107
|
+
};
|
|
108
|
+
Response: {
|
|
109
|
+
subOrgId: string;
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
Route: '/v1/signup';
|
|
114
|
+
Body: AtLeastOne<{
|
|
65
115
|
passkey: {
|
|
66
116
|
challenge: string;
|
|
67
117
|
attestation: Awaited<ReturnType<typeof getWebAuthnAttestation>>;
|
|
68
118
|
};
|
|
119
|
+
iframe: {
|
|
120
|
+
targetPublicKey: string;
|
|
121
|
+
redirectUrl: string;
|
|
122
|
+
expirationSeconds?: number;
|
|
123
|
+
};
|
|
124
|
+
}> & {
|
|
69
125
|
email: string;
|
|
70
126
|
};
|
|
71
127
|
Response: {
|
|
@@ -106,6 +162,7 @@ type AuthenticationServiceEndpoints = [
|
|
|
106
162
|
type SignerClientConfiguration = {
|
|
107
163
|
apiKey: string;
|
|
108
164
|
apiUrl?: string;
|
|
165
|
+
paymasterRpcUrl?: string;
|
|
109
166
|
};
|
|
110
167
|
type SignerClientConstructorParams = {
|
|
111
168
|
stamper: TurnkeyClient['stamper'];
|
|
@@ -114,11 +171,12 @@ type SignerClientConstructorParams = {
|
|
|
114
171
|
type SignerClientInheritedConstructorParams<Extended extends Record<string, unknown>> = Pick<SignerClientConstructorParams, 'configuration'> & Extended;
|
|
115
172
|
declare abstract class SignerClient {
|
|
116
173
|
protected readonly _turnkeyClient: TurnkeyClient;
|
|
117
|
-
protected readonly _configuration: Required<
|
|
174
|
+
protected readonly _configuration: Required<SignerClientConstructorParams['configuration']>;
|
|
118
175
|
protected readonly _sessionStore: SessionStore;
|
|
119
176
|
private _user?;
|
|
120
|
-
constructor({ stamper, configuration: { apiUrl, ...requiredConfiguration }, }: SignerClientConstructorParams);
|
|
177
|
+
constructor({ stamper, configuration: { apiUrl, paymasterRpcUrl, ...requiredConfiguration }, }: SignerClientConstructorParams);
|
|
121
178
|
logout(): void;
|
|
179
|
+
get configuration(): Required<SignerClientConfiguration>;
|
|
122
180
|
get user(): User | undefined;
|
|
123
181
|
protected set user(value: User | undefined);
|
|
124
182
|
protected set stamper(stamper: TurnkeyClient['stamper']);
|
|
@@ -133,10 +191,24 @@ declare abstract class SignerClient {
|
|
|
133
191
|
type WebauthnSignInParams = {
|
|
134
192
|
email: string;
|
|
135
193
|
};
|
|
194
|
+
type EmailInitializeAuthParams = {
|
|
195
|
+
email: string;
|
|
196
|
+
redirectUrl: string;
|
|
197
|
+
expirationSeconds?: number;
|
|
198
|
+
};
|
|
199
|
+
type EmailCompleteAuthWithBundleParams = {
|
|
200
|
+
bundle: string;
|
|
201
|
+
subOrgId: string;
|
|
202
|
+
isNewUser?: boolean;
|
|
203
|
+
};
|
|
136
204
|
type WebSignerClientConstructorParams = SignerClientInheritedConstructorParams<{
|
|
137
205
|
webauthn: {
|
|
138
206
|
rpId: string;
|
|
139
207
|
};
|
|
208
|
+
iframe?: {
|
|
209
|
+
iframeElementId?: string;
|
|
210
|
+
iframeContainerId?: string;
|
|
211
|
+
};
|
|
140
212
|
}>;
|
|
141
213
|
/**
|
|
142
214
|
* A signer client for web applications.
|
|
@@ -148,15 +220,58 @@ declare class WebSignerClient extends SignerClient {
|
|
|
148
220
|
*
|
|
149
221
|
* @param {WebSignerClientConstructorParams} params params for the constructor
|
|
150
222
|
*/
|
|
151
|
-
constructor({ configuration, webauthn }: WebSignerClientConstructorParams);
|
|
223
|
+
constructor({ configuration, webauthn, iframe, }: WebSignerClientConstructorParams);
|
|
224
|
+
signRawMessage<Into extends string>(msg: string): Promise<Into>;
|
|
225
|
+
logout(): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Checks for an existing session and if exists, updates the stamper accordingly.
|
|
228
|
+
*
|
|
229
|
+
*/
|
|
230
|
+
private updateStamper;
|
|
152
231
|
/**
|
|
153
232
|
* Signs in a user with webauthn.
|
|
154
233
|
*
|
|
155
234
|
* @param {WebauthnSignInParams} params params for the sign in
|
|
156
235
|
*/
|
|
157
236
|
webauthnSignIn({ email }: WebauthnSignInParams): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Handle auth user process with email.
|
|
239
|
+
*
|
|
240
|
+
* @param {EmailInitializeAuthParams} params Params needed for the initialization of the auth process
|
|
241
|
+
*/
|
|
242
|
+
emailAuth(params: EmailInitializeAuthParams): Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Signs in a user with email.
|
|
245
|
+
*
|
|
246
|
+
* @param {EmailInitializeAuthParams} params params for the sign in
|
|
247
|
+
*/
|
|
248
|
+
private _signInWithEmail;
|
|
249
|
+
/**
|
|
250
|
+
* Completes the authentication process with a credential bundle.
|
|
251
|
+
*
|
|
252
|
+
* @param {EmailCompleteAuthWithBundleParams} params params for the completion of the auth process
|
|
253
|
+
*/
|
|
254
|
+
completeAuthWithBundle({ bundle, subOrgId, }: EmailCompleteAuthWithBundleParams): Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* Creates a passkey account using the webauthn stamper.
|
|
257
|
+
*
|
|
258
|
+
* @param {Extract<CreateAccountParams, { method: 'webauthn' }>} params params for the creation of the account
|
|
259
|
+
*/
|
|
260
|
+
private _createWebauthnAccount;
|
|
261
|
+
/**
|
|
262
|
+
* Creates an email account using the iframe stamper.
|
|
263
|
+
*
|
|
264
|
+
* @param {Extract<CreateAccountParams, { method: 'email' }>} params params for the creation of the account
|
|
265
|
+
*/
|
|
266
|
+
private _createEmailAccount;
|
|
267
|
+
/**
|
|
268
|
+
* Handle the account creation process.
|
|
269
|
+
*
|
|
270
|
+
* @param {CreateAccountParams} params params to create an account
|
|
271
|
+
*/
|
|
158
272
|
private _createAccount;
|
|
159
273
|
private _webauthnGenerateAttestation;
|
|
274
|
+
private _initIframeStamper;
|
|
160
275
|
}
|
|
161
276
|
|
|
162
277
|
type CurrentUserToLightSmartAccountParams = {
|
|
@@ -168,6 +283,40 @@ declare class ViemModule {
|
|
|
168
283
|
constructor(_signerClient: SignerClient);
|
|
169
284
|
toLocalAccount(): Promise<LocalAccount>;
|
|
170
285
|
toSmartAccount({ client, owner, }: CurrentUserToLightSmartAccountParams): ReturnType<typeof toLightSmartAccount<'0.7'>>;
|
|
286
|
+
getPaymasterClient(): Promise<{
|
|
287
|
+
account: undefined;
|
|
288
|
+
batch?: viem.ClientConfig["batch"] | undefined;
|
|
289
|
+
cacheTime: number;
|
|
290
|
+
ccipRead?: viem.ClientConfig["ccipRead"] | undefined;
|
|
291
|
+
chain: undefined;
|
|
292
|
+
key: string;
|
|
293
|
+
name: string;
|
|
294
|
+
pollingInterval: number;
|
|
295
|
+
request: viem.EIP1193RequestFn<viem.PaymasterRpcSchema>;
|
|
296
|
+
transport: viem.TransportConfig<"http", viem.EIP1193RequestFn> & {
|
|
297
|
+
fetchOptions?: viem.HttpTransportConfig["fetchOptions"] | undefined;
|
|
298
|
+
url?: string | undefined;
|
|
299
|
+
};
|
|
300
|
+
type: string;
|
|
301
|
+
uid: string;
|
|
302
|
+
getPaymasterData: (parameters: viem_account_abstraction.GetPaymasterDataParameters) => Promise<viem_account_abstraction.GetPaymasterDataReturnType>;
|
|
303
|
+
getPaymasterStubData: (parameters: viem_account_abstraction.GetPaymasterStubDataParameters) => Promise<viem_account_abstraction.GetPaymasterStubDataReturnType>;
|
|
304
|
+
extend: <const client extends {
|
|
305
|
+
[x: string]: unknown;
|
|
306
|
+
account?: undefined;
|
|
307
|
+
batch?: undefined;
|
|
308
|
+
cacheTime?: undefined;
|
|
309
|
+
ccipRead?: undefined;
|
|
310
|
+
chain?: undefined;
|
|
311
|
+
key?: undefined;
|
|
312
|
+
name?: undefined;
|
|
313
|
+
pollingInterval?: undefined;
|
|
314
|
+
request?: undefined;
|
|
315
|
+
transport?: undefined;
|
|
316
|
+
type?: undefined;
|
|
317
|
+
uid?: undefined;
|
|
318
|
+
} & viem.ExactPartial<Pick<viem.PublicActions<viem.HttpTransport, undefined, undefined>, "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getChainId" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "prepareTransactionRequest" | "readContract" | "sendRawTransaction" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<viem.WalletActions<undefined, undefined>, "sendTransaction" | "writeContract">>>(fn: (client: Client<viem.HttpTransport, undefined, undefined, viem.PaymasterRpcSchema, viem_account_abstraction.PaymasterActions>) => client) => Client<viem.HttpTransport, undefined, undefined, viem.PaymasterRpcSchema, { [K in keyof client]: client[K]; } & viem_account_abstraction.PaymasterActions>;
|
|
319
|
+
}>;
|
|
171
320
|
signMessage(msg: SignableMessage): Promise<Hex>;
|
|
172
321
|
signTypedData<TTypedData extends TypedData | Record<string, unknown>, TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex>;
|
|
173
322
|
signTransaction<serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]>(transaction: transaction, options?: {
|
|
@@ -175,6 +324,29 @@ declare class ViemModule {
|
|
|
175
324
|
} | undefined): Promise<IsNarrowable<TransactionSerialized<GetTransactionType<transaction>>, Hex> extends true ? TransactionSerialized<GetTransactionType<transaction>> : Hex>;
|
|
176
325
|
}
|
|
177
326
|
|
|
327
|
+
/**
|
|
328
|
+
* A module for interacting with the Email authentication methods.
|
|
329
|
+
* Available through the `auth.email` property on a `FourtWebSigner` instance.
|
|
330
|
+
*/
|
|
331
|
+
declare class EmailModule {
|
|
332
|
+
private readonly _webSignerClient;
|
|
333
|
+
constructor(_webSignerClient: WebSignerClient);
|
|
334
|
+
/**
|
|
335
|
+
* Initialize user authentication process using email.
|
|
336
|
+
*
|
|
337
|
+
* @param params {EmailInitializeAuthParams} params to initialize the user authentication process.
|
|
338
|
+
* @returns {Promise<void>} promise that resolves to the result of the authentication process.
|
|
339
|
+
*/
|
|
340
|
+
initialize(params: EmailInitializeAuthParams): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Completes authentication with bundle after user receives the bundle and subOrgId as URL params.
|
|
343
|
+
*
|
|
344
|
+
* @param params {EmailCompleteAuthWithBundleParams} params received as URL params necessary to complete authentication process.
|
|
345
|
+
* @returns {Promise<void>} promise that completes the authentication process.
|
|
346
|
+
*/
|
|
347
|
+
complete(params: EmailCompleteAuthWithBundleParams): Promise<void>;
|
|
348
|
+
}
|
|
349
|
+
|
|
178
350
|
/**
|
|
179
351
|
* A module for interacting with the Passkeys authentication methods.
|
|
180
352
|
* Available through the `auth.passkeys` property on a `FourtWebSigner` instance.
|
|
@@ -198,6 +370,7 @@ declare class PasskeysModule {
|
|
|
198
370
|
declare class AuthModule {
|
|
199
371
|
private readonly _webSignerClient;
|
|
200
372
|
private readonly _passkeys;
|
|
373
|
+
private readonly _email;
|
|
201
374
|
/**
|
|
202
375
|
* Initializes a new instance of the `AuthModule` class.
|
|
203
376
|
*
|
|
@@ -208,6 +381,10 @@ declare class AuthModule {
|
|
|
208
381
|
* A module for interacting with the Passkeys authentication methods.
|
|
209
382
|
*/
|
|
210
383
|
get passkeys(): PasskeysModule;
|
|
384
|
+
/**
|
|
385
|
+
* A module for interacting with the Passkeys authentication methods.
|
|
386
|
+
*/
|
|
387
|
+
get email(): EmailModule;
|
|
211
388
|
}
|
|
212
389
|
|
|
213
390
|
/**
|
|
@@ -233,12 +410,12 @@ declare class UserModule {
|
|
|
233
410
|
*
|
|
234
411
|
* @returns {void}
|
|
235
412
|
*/
|
|
236
|
-
logout(): void
|
|
413
|
+
logout(): Promise<void>;
|
|
237
414
|
}
|
|
238
415
|
|
|
239
416
|
type FourtWebSignerConstructorParams = {
|
|
240
417
|
configuration: SignerClientConstructorParams['configuration'];
|
|
241
|
-
auth: Pick<WebSignerClientConstructorParams, 'webauthn'>;
|
|
418
|
+
auth: Pick<WebSignerClientConstructorParams, 'webauthn' | 'iframe'>;
|
|
242
419
|
};
|
|
243
420
|
/**
|
|
244
421
|
* A client for interacting with the Fourt Web Signer.
|
|
@@ -267,7 +444,7 @@ declare class FourtWebSigner {
|
|
|
267
444
|
*
|
|
268
445
|
* @param {FourtWebSignerConstructorParams} params the required parameters to initialize the client
|
|
269
446
|
*/
|
|
270
|
-
constructor({ configuration, auth: { webauthn }, }: FourtWebSignerConstructorParams);
|
|
447
|
+
constructor({ configuration, auth: { webauthn, iframe }, }: FourtWebSignerConstructorParams);
|
|
271
448
|
/**
|
|
272
449
|
* A module for interacting with the Viem library.
|
|
273
450
|
*/
|