@fourt/sdk 1.0.0 → 1.1.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/dist/index.cjs +281 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -60
- package/dist/index.d.ts +97 -60
- package/dist/index.js +271 -192
- package/dist/index.js.map +1 -1
- package/package.json +10 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getWebAuthnAttestation, TSignedRequest, TurnkeyClient } from '@turnkey/http';
|
|
2
1
|
import { U as User, A as AtLeastOne } from './index-Cy_WMhHm.js';
|
|
2
|
+
import { getWebAuthnAttestation, TSignedRequest, TurnkeyClient } from '@turnkey/http';
|
|
3
3
|
import * as viem_account_abstraction from 'viem/account-abstraction';
|
|
4
4
|
import * as viem from 'viem';
|
|
5
5
|
import { LocalAccount, Client, SignableMessage, Hex, TypedData, TypedDataDefinition, SerializeTransactionFn, TransactionSerializable, IsNarrowable, TransactionSerialized, GetTransactionType } from 'viem';
|
|
@@ -7,7 +7,8 @@ import { toLightSmartAccount } from 'permissionless/accounts';
|
|
|
7
7
|
|
|
8
8
|
declare enum SessionType {
|
|
9
9
|
Email = "email",
|
|
10
|
-
Passkeys = "passkeys"
|
|
10
|
+
Passkeys = "passkeys",
|
|
11
|
+
OAuth = "oauth"
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* A store for the session state.
|
|
@@ -196,11 +197,20 @@ type EmailInitializeAuthParams = {
|
|
|
196
197
|
redirectUrl: string;
|
|
197
198
|
expirationSeconds?: number;
|
|
198
199
|
};
|
|
199
|
-
type
|
|
200
|
+
type CompleteAuthWithBundleParams = {
|
|
200
201
|
bundle: string;
|
|
201
202
|
subOrgId: string;
|
|
203
|
+
sessionType: SessionType;
|
|
202
204
|
isNewUser?: boolean;
|
|
203
205
|
};
|
|
206
|
+
type OAuthConfiguration = {
|
|
207
|
+
common: {
|
|
208
|
+
redirectUrl: string;
|
|
209
|
+
};
|
|
210
|
+
google?: {
|
|
211
|
+
clientId: string;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
204
214
|
type WebSignerClientConstructorParams = SignerClientInheritedConstructorParams<{
|
|
205
215
|
webauthn: {
|
|
206
216
|
rpId: string;
|
|
@@ -209,18 +219,20 @@ type WebSignerClientConstructorParams = SignerClientInheritedConstructorParams<{
|
|
|
209
219
|
iframeElementId?: string;
|
|
210
220
|
iframeContainerId?: string;
|
|
211
221
|
};
|
|
222
|
+
oauth?: OAuthConfiguration;
|
|
212
223
|
}>;
|
|
213
224
|
/**
|
|
214
225
|
* A signer client for web applications.
|
|
215
226
|
*/
|
|
216
227
|
declare class WebSignerClient extends SignerClient {
|
|
217
228
|
private readonly _stampers;
|
|
229
|
+
readonly oauthConfiguration: WebSignerClientConstructorParams['oauth'];
|
|
218
230
|
/**
|
|
219
231
|
* Initializes a new instance of the `WebSignerClient` class.
|
|
220
232
|
*
|
|
221
233
|
* @param {WebSignerClientConstructorParams} params params for the constructor
|
|
222
234
|
*/
|
|
223
|
-
constructor({ configuration, webauthn, iframe, }: WebSignerClientConstructorParams);
|
|
235
|
+
constructor({ configuration, webauthn, iframe, oauth, }: WebSignerClientConstructorParams);
|
|
224
236
|
signRawMessage<Into extends string>(msg: string): Promise<Into>;
|
|
225
237
|
logout(): Promise<void>;
|
|
226
238
|
/**
|
|
@@ -240,6 +252,7 @@ declare class WebSignerClient extends SignerClient {
|
|
|
240
252
|
* @param {EmailInitializeAuthParams} params Params needed for the initialization of the auth process
|
|
241
253
|
*/
|
|
242
254
|
emailAuth(params: EmailInitializeAuthParams): Promise<void>;
|
|
255
|
+
getIframePublicKey(): Promise<string>;
|
|
243
256
|
/**
|
|
244
257
|
* Signs in a user with email.
|
|
245
258
|
*
|
|
@@ -249,9 +262,9 @@ declare class WebSignerClient extends SignerClient {
|
|
|
249
262
|
/**
|
|
250
263
|
* Completes the authentication process with a credential bundle.
|
|
251
264
|
*
|
|
252
|
-
* @param {
|
|
265
|
+
* @param {CompleteAuthWithBundleParams} params params for the completion of the auth process
|
|
253
266
|
*/
|
|
254
|
-
completeAuthWithBundle({ bundle, subOrgId, }:
|
|
267
|
+
completeAuthWithBundle({ bundle, subOrgId, sessionType, }: CompleteAuthWithBundleParams): Promise<void>;
|
|
255
268
|
/**
|
|
256
269
|
* Creates a passkey account using the webauthn stamper.
|
|
257
270
|
*
|
|
@@ -274,56 +287,6 @@ declare class WebSignerClient extends SignerClient {
|
|
|
274
287
|
private _initIframeStamper;
|
|
275
288
|
}
|
|
276
289
|
|
|
277
|
-
type CurrentUserToLightSmartAccountParams = {
|
|
278
|
-
owner: LocalAccount;
|
|
279
|
-
client: Client;
|
|
280
|
-
};
|
|
281
|
-
declare class ViemModule {
|
|
282
|
-
private readonly _signerClient;
|
|
283
|
-
constructor(_signerClient: SignerClient);
|
|
284
|
-
toLocalAccount(): Promise<LocalAccount>;
|
|
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
|
-
}>;
|
|
320
|
-
signMessage(msg: SignableMessage): Promise<Hex>;
|
|
321
|
-
signTypedData<TTypedData extends TypedData | Record<string, unknown>, TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex>;
|
|
322
|
-
signTransaction<serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]>(transaction: transaction, options?: {
|
|
323
|
-
serializer?: serializer | undefined;
|
|
324
|
-
} | undefined): Promise<IsNarrowable<TransactionSerialized<GetTransactionType<transaction>>, Hex> extends true ? TransactionSerialized<GetTransactionType<transaction>> : Hex>;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
290
|
/**
|
|
328
291
|
* A module for interacting with the Email authentication methods.
|
|
329
292
|
* Available through the `auth.email` property on a `FourtWebSigner` instance.
|
|
@@ -341,10 +304,10 @@ declare class EmailModule {
|
|
|
341
304
|
/**
|
|
342
305
|
* Completes authentication with bundle after user receives the bundle and subOrgId as URL params.
|
|
343
306
|
*
|
|
344
|
-
* @param params {
|
|
307
|
+
* @param params {CompleteAuthWithBundleParams} params received as URL params necessary to complete authentication process.
|
|
345
308
|
* @returns {Promise<void>} promise that completes the authentication process.
|
|
346
309
|
*/
|
|
347
|
-
complete(params:
|
|
310
|
+
complete(params: Pick<CompleteAuthWithBundleParams, 'subOrgId' | 'bundle'>): Promise<void>;
|
|
348
311
|
}
|
|
349
312
|
|
|
350
313
|
/**
|
|
@@ -363,6 +326,28 @@ declare class PasskeysModule {
|
|
|
363
326
|
signIn(params: WebauthnSignInParams): Promise<void>;
|
|
364
327
|
}
|
|
365
328
|
|
|
329
|
+
declare class GoogleModule {
|
|
330
|
+
private readonly _webSignerClient;
|
|
331
|
+
constructor(_webSignerClient: WebSignerClient);
|
|
332
|
+
/**
|
|
333
|
+
*
|
|
334
|
+
* @returns
|
|
335
|
+
*/
|
|
336
|
+
init(): Promise<string>;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
type CompleteParams = {
|
|
340
|
+
bundle: string;
|
|
341
|
+
subOrgId: string;
|
|
342
|
+
};
|
|
343
|
+
declare class OAuthModule {
|
|
344
|
+
private readonly _webSignerClient;
|
|
345
|
+
private readonly _googleModule;
|
|
346
|
+
constructor(_webSignerClient: WebSignerClient);
|
|
347
|
+
get google(): GoogleModule;
|
|
348
|
+
complete({ bundle, subOrgId }: CompleteParams): Promise<void>;
|
|
349
|
+
}
|
|
350
|
+
|
|
366
351
|
/**
|
|
367
352
|
* A module for interacting with the authentication methods.
|
|
368
353
|
* Available through the `auth` property on a `FourtWebSigner` instance.
|
|
@@ -371,6 +356,7 @@ declare class AuthModule {
|
|
|
371
356
|
private readonly _webSignerClient;
|
|
372
357
|
private readonly _passkeys;
|
|
373
358
|
private readonly _email;
|
|
359
|
+
private readonly _oauth;
|
|
374
360
|
/**
|
|
375
361
|
* Initializes a new instance of the `AuthModule` class.
|
|
376
362
|
*
|
|
@@ -385,6 +371,7 @@ declare class AuthModule {
|
|
|
385
371
|
* A module for interacting with the Passkeys authentication methods.
|
|
386
372
|
*/
|
|
387
373
|
get email(): EmailModule;
|
|
374
|
+
get oauth(): OAuthModule;
|
|
388
375
|
}
|
|
389
376
|
|
|
390
377
|
/**
|
|
@@ -413,9 +400,59 @@ declare class UserModule {
|
|
|
413
400
|
logout(): Promise<void>;
|
|
414
401
|
}
|
|
415
402
|
|
|
403
|
+
type CurrentUserToLightSmartAccountParams = {
|
|
404
|
+
owner: LocalAccount;
|
|
405
|
+
client: Client;
|
|
406
|
+
};
|
|
407
|
+
declare class ViemModule {
|
|
408
|
+
private readonly _signerClient;
|
|
409
|
+
constructor(_signerClient: SignerClient);
|
|
410
|
+
toLocalAccount(): Promise<LocalAccount>;
|
|
411
|
+
toSmartAccount({ client, owner, }: CurrentUserToLightSmartAccountParams): ReturnType<typeof toLightSmartAccount<'0.7'>>;
|
|
412
|
+
getPaymasterClient(): Promise<{
|
|
413
|
+
account: undefined;
|
|
414
|
+
batch?: viem.ClientConfig["batch"] | undefined;
|
|
415
|
+
cacheTime: number;
|
|
416
|
+
ccipRead?: viem.ClientConfig["ccipRead"] | undefined;
|
|
417
|
+
chain: undefined;
|
|
418
|
+
key: string;
|
|
419
|
+
name: string;
|
|
420
|
+
pollingInterval: number;
|
|
421
|
+
request: viem.EIP1193RequestFn<viem.PaymasterRpcSchema>;
|
|
422
|
+
transport: viem.TransportConfig<"http", viem.EIP1193RequestFn> & {
|
|
423
|
+
fetchOptions?: viem.HttpTransportConfig["fetchOptions"] | undefined;
|
|
424
|
+
url?: string | undefined;
|
|
425
|
+
};
|
|
426
|
+
type: string;
|
|
427
|
+
uid: string;
|
|
428
|
+
getPaymasterData: (parameters: viem_account_abstraction.GetPaymasterDataParameters) => Promise<viem_account_abstraction.GetPaymasterDataReturnType>;
|
|
429
|
+
getPaymasterStubData: (parameters: viem_account_abstraction.GetPaymasterStubDataParameters) => Promise<viem_account_abstraction.GetPaymasterStubDataReturnType>;
|
|
430
|
+
extend: <const client extends {
|
|
431
|
+
[x: string]: unknown;
|
|
432
|
+
account?: undefined;
|
|
433
|
+
batch?: undefined;
|
|
434
|
+
cacheTime?: undefined;
|
|
435
|
+
ccipRead?: undefined;
|
|
436
|
+
chain?: undefined;
|
|
437
|
+
key?: undefined;
|
|
438
|
+
name?: undefined;
|
|
439
|
+
pollingInterval?: undefined;
|
|
440
|
+
request?: undefined;
|
|
441
|
+
transport?: undefined;
|
|
442
|
+
type?: undefined;
|
|
443
|
+
uid?: undefined;
|
|
444
|
+
} & 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>;
|
|
445
|
+
}>;
|
|
446
|
+
signMessage(msg: SignableMessage): Promise<Hex>;
|
|
447
|
+
signTypedData<TTypedData extends TypedData | Record<string, unknown>, TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex>;
|
|
448
|
+
signTransaction<serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]>(transaction: transaction, options?: {
|
|
449
|
+
serializer?: serializer | undefined;
|
|
450
|
+
} | undefined): Promise<IsNarrowable<TransactionSerialized<GetTransactionType<transaction>>, Hex> extends true ? TransactionSerialized<GetTransactionType<transaction>> : Hex>;
|
|
451
|
+
}
|
|
452
|
+
|
|
416
453
|
type FourtWebSignerConstructorParams = {
|
|
417
454
|
configuration: SignerClientConstructorParams['configuration'];
|
|
418
|
-
auth: Pick<WebSignerClientConstructorParams, 'webauthn' | 'iframe'>;
|
|
455
|
+
auth: Pick<WebSignerClientConstructorParams, 'webauthn' | 'iframe' | 'oauth'>;
|
|
419
456
|
};
|
|
420
457
|
/**
|
|
421
458
|
* A client for interacting with the Fourt Web Signer.
|
|
@@ -444,7 +481,7 @@ declare class FourtWebSigner {
|
|
|
444
481
|
*
|
|
445
482
|
* @param {FourtWebSignerConstructorParams} params the required parameters to initialize the client
|
|
446
483
|
*/
|
|
447
|
-
constructor({ configuration, auth: { webauthn, iframe }, }: FourtWebSignerConstructorParams);
|
|
484
|
+
constructor({ configuration, auth: { webauthn, iframe, oauth }, }: FourtWebSignerConstructorParams);
|
|
448
485
|
/**
|
|
449
486
|
* A module for interacting with the Viem library.
|
|
450
487
|
*/
|