@fourt/sdk 1.0.0 → 1.1.1

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.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,26 @@ type EmailInitializeAuthParams = {
196
197
  redirectUrl: string;
197
198
  expirationSeconds?: number;
198
199
  };
199
- type EmailCompleteAuthWithBundleParams = {
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
+ id: string;
212
+ };
213
+ facebook?: {
214
+ id: string;
215
+ };
216
+ apple?: {
217
+ id: string;
218
+ };
219
+ };
204
220
  type WebSignerClientConstructorParams = SignerClientInheritedConstructorParams<{
205
221
  webauthn: {
206
222
  rpId: string;
@@ -209,18 +225,20 @@ type WebSignerClientConstructorParams = SignerClientInheritedConstructorParams<{
209
225
  iframeElementId?: string;
210
226
  iframeContainerId?: string;
211
227
  };
228
+ oauth?: OAuthConfiguration;
212
229
  }>;
213
230
  /**
214
231
  * A signer client for web applications.
215
232
  */
216
233
  declare class WebSignerClient extends SignerClient {
217
234
  private readonly _stampers;
235
+ readonly oauthConfiguration: WebSignerClientConstructorParams['oauth'];
218
236
  /**
219
237
  * Initializes a new instance of the `WebSignerClient` class.
220
238
  *
221
239
  * @param {WebSignerClientConstructorParams} params params for the constructor
222
240
  */
223
- constructor({ configuration, webauthn, iframe, }: WebSignerClientConstructorParams);
241
+ constructor({ configuration, webauthn, iframe, oauth, }: WebSignerClientConstructorParams);
224
242
  signRawMessage<Into extends string>(msg: string): Promise<Into>;
225
243
  logout(): Promise<void>;
226
244
  /**
@@ -240,6 +258,7 @@ declare class WebSignerClient extends SignerClient {
240
258
  * @param {EmailInitializeAuthParams} params Params needed for the initialization of the auth process
241
259
  */
242
260
  emailAuth(params: EmailInitializeAuthParams): Promise<void>;
261
+ getIframePublicKey(): Promise<string>;
243
262
  /**
244
263
  * Signs in a user with email.
245
264
  *
@@ -249,9 +268,9 @@ declare class WebSignerClient extends SignerClient {
249
268
  /**
250
269
  * Completes the authentication process with a credential bundle.
251
270
  *
252
- * @param {EmailCompleteAuthWithBundleParams} params params for the completion of the auth process
271
+ * @param {CompleteAuthWithBundleParams} params params for the completion of the auth process
253
272
  */
254
- completeAuthWithBundle({ bundle, subOrgId, }: EmailCompleteAuthWithBundleParams): Promise<void>;
273
+ completeAuthWithBundle({ bundle, subOrgId, sessionType, }: CompleteAuthWithBundleParams): Promise<void>;
255
274
  /**
256
275
  * Creates a passkey account using the webauthn stamper.
257
276
  *
@@ -274,56 +293,6 @@ declare class WebSignerClient extends SignerClient {
274
293
  private _initIframeStamper;
275
294
  }
276
295
 
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
296
  /**
328
297
  * A module for interacting with the Email authentication methods.
329
298
  * Available through the `auth.email` property on a `FourtWebSigner` instance.
@@ -341,10 +310,10 @@ declare class EmailModule {
341
310
  /**
342
311
  * Completes authentication with bundle after user receives the bundle and subOrgId as URL params.
343
312
  *
344
- * @param params {EmailCompleteAuthWithBundleParams} params received as URL params necessary to complete authentication process.
313
+ * @param params {CompleteAuthWithBundleParams} params received as URL params necessary to complete authentication process.
345
314
  * @returns {Promise<void>} promise that completes the authentication process.
346
315
  */
347
- complete(params: EmailCompleteAuthWithBundleParams): Promise<void>;
316
+ complete(params: Pick<CompleteAuthWithBundleParams, 'subOrgId' | 'bundle'>): Promise<void>;
348
317
  }
349
318
 
350
319
  /**
@@ -363,6 +332,48 @@ declare class PasskeysModule {
363
332
  signIn(params: WebauthnSignInParams): Promise<void>;
364
333
  }
365
334
 
335
+ declare class GoogleModule {
336
+ private readonly _webSignerClient;
337
+ constructor(_webSignerClient: WebSignerClient);
338
+ /**
339
+ *
340
+ * @returns
341
+ */
342
+ init(): Promise<string>;
343
+ }
344
+
345
+ declare class FacebookModule {
346
+ private readonly _webSignerClient;
347
+ constructor(_webSignerClient: WebSignerClient);
348
+ init(): Promise<string>;
349
+ }
350
+
351
+ declare class AppleModule {
352
+ private readonly _webSignerClient;
353
+ constructor(_webSignerClient: WebSignerClient);
354
+ /**
355
+ *
356
+ * @returns
357
+ */
358
+ init(): Promise<string>;
359
+ }
360
+
361
+ type CompleteParams = {
362
+ bundle: string;
363
+ subOrgId: string;
364
+ };
365
+ declare class OAuthModule {
366
+ private readonly _webSignerClient;
367
+ private readonly _googleModule;
368
+ private readonly _facebookModule;
369
+ private readonly _appleModule;
370
+ constructor(_webSignerClient: WebSignerClient);
371
+ get google(): GoogleModule;
372
+ get facebook(): FacebookModule;
373
+ get apple(): AppleModule;
374
+ complete({ bundle, subOrgId }: CompleteParams): Promise<void>;
375
+ }
376
+
366
377
  /**
367
378
  * A module for interacting with the authentication methods.
368
379
  * Available through the `auth` property on a `FourtWebSigner` instance.
@@ -371,6 +382,7 @@ declare class AuthModule {
371
382
  private readonly _webSignerClient;
372
383
  private readonly _passkeys;
373
384
  private readonly _email;
385
+ private readonly _oauth;
374
386
  /**
375
387
  * Initializes a new instance of the `AuthModule` class.
376
388
  *
@@ -385,6 +397,7 @@ declare class AuthModule {
385
397
  * A module for interacting with the Passkeys authentication methods.
386
398
  */
387
399
  get email(): EmailModule;
400
+ get oauth(): OAuthModule;
388
401
  }
389
402
 
390
403
  /**
@@ -413,9 +426,59 @@ declare class UserModule {
413
426
  logout(): Promise<void>;
414
427
  }
415
428
 
429
+ type CurrentUserToLightSmartAccountParams = {
430
+ owner: LocalAccount;
431
+ client: Client;
432
+ };
433
+ declare class ViemModule {
434
+ private readonly _signerClient;
435
+ constructor(_signerClient: SignerClient);
436
+ toLocalAccount(): Promise<LocalAccount>;
437
+ toSmartAccount({ client, owner, }: CurrentUserToLightSmartAccountParams): ReturnType<typeof toLightSmartAccount<'0.7'>>;
438
+ getPaymasterClient(): Promise<{
439
+ account: undefined;
440
+ batch?: viem.ClientConfig["batch"] | undefined;
441
+ cacheTime: number;
442
+ ccipRead?: viem.ClientConfig["ccipRead"] | undefined;
443
+ chain: undefined;
444
+ key: string;
445
+ name: string;
446
+ pollingInterval: number;
447
+ request: viem.EIP1193RequestFn<viem.PaymasterRpcSchema>;
448
+ transport: viem.TransportConfig<"http", viem.EIP1193RequestFn> & {
449
+ fetchOptions?: viem.HttpTransportConfig["fetchOptions"] | undefined;
450
+ url?: string | undefined;
451
+ };
452
+ type: string;
453
+ uid: string;
454
+ getPaymasterData: (parameters: viem_account_abstraction.GetPaymasterDataParameters) => Promise<viem_account_abstraction.GetPaymasterDataReturnType>;
455
+ getPaymasterStubData: (parameters: viem_account_abstraction.GetPaymasterStubDataParameters) => Promise<viem_account_abstraction.GetPaymasterStubDataReturnType>;
456
+ extend: <const client extends {
457
+ [x: string]: unknown;
458
+ account?: undefined;
459
+ batch?: undefined;
460
+ cacheTime?: undefined;
461
+ ccipRead?: undefined;
462
+ chain?: undefined;
463
+ key?: undefined;
464
+ name?: undefined;
465
+ pollingInterval?: undefined;
466
+ request?: undefined;
467
+ transport?: undefined;
468
+ type?: undefined;
469
+ uid?: undefined;
470
+ } & 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>;
471
+ }>;
472
+ signMessage(msg: SignableMessage): Promise<Hex>;
473
+ signTypedData<TTypedData extends TypedData | Record<string, unknown>, TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex>;
474
+ signTransaction<serializer extends SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]>(transaction: transaction, options?: {
475
+ serializer?: serializer | undefined;
476
+ } | undefined): Promise<IsNarrowable<TransactionSerialized<GetTransactionType<transaction>>, Hex> extends true ? TransactionSerialized<GetTransactionType<transaction>> : Hex>;
477
+ }
478
+
416
479
  type FourtWebSignerConstructorParams = {
417
480
  configuration: SignerClientConstructorParams['configuration'];
418
- auth: Pick<WebSignerClientConstructorParams, 'webauthn' | 'iframe'>;
481
+ auth: Pick<WebSignerClientConstructorParams, 'webauthn' | 'iframe' | 'oauth'>;
419
482
  };
420
483
  /**
421
484
  * A client for interacting with the Fourt Web Signer.
@@ -444,7 +507,7 @@ declare class FourtWebSigner {
444
507
  *
445
508
  * @param {FourtWebSignerConstructorParams} params the required parameters to initialize the client
446
509
  */
447
- constructor({ configuration, auth: { webauthn, iframe }, }: FourtWebSignerConstructorParams);
510
+ constructor({ configuration, auth: { webauthn, iframe, oauth }, }: FourtWebSignerConstructorParams);
448
511
  /**
449
512
  * A module for interacting with the Viem library.
450
513
  */