@getpara/core-sdk 0.1.0 → 0.2.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/cjs/ParaCore.js +247 -158
- package/dist/cjs/definitions.js +1 -3
- package/dist/cjs/external/userManagementClient.js +16 -1
- package/dist/cjs/types/events.js +17 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/esm/ParaCore.js +250 -161
- package/dist/esm/definitions.js +0 -2
- package/dist/esm/external/userManagementClient.js +14 -0
- package/dist/esm/types/events.js +14 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/types/ParaCore.d.ts +218 -157
- package/dist/types/definitions.d.ts +0 -2
- package/dist/types/external/userManagementClient.d.ts +1 -0
- package/dist/types/types/events.d.ts +47 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/params.d.ts +34 -0
- package/package.json +3 -3
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Client, { AuthMethod, AuthType, BackupKitEmailProps, CurrentWalletIds, EmailTheme, PartnerEntity, WalletEntity, WalletType, WalletScheme, WalletParams, OAuthMethod, OnRampPurchaseCreateParams, OnRampPurchase, TPregenIdentifierType, PregenIds, BiometricLocationHint, TelegramAuthResponse, VerifyTelegramRes, Auth } from '@getpara/user-management-client';
|
|
2
2
|
import type { pki as pkiType } from 'node-forge';
|
|
3
3
|
import { Ctx, Environment, WalletFilters, WalletTypeProp } from './definitions.js';
|
|
4
|
-
import { Theme, FullSignatureRes, EmbeddedWalletType, ExternalWalletType, ExternalWalletInfo } from './types/index.js';
|
|
4
|
+
import { Theme, FullSignatureRes, EmbeddedWalletType, ExternalWalletType, ExternalWalletInfo, GetWebAuthUrlForLoginParams, AccountSetupResp, LoginResp } from './types/index.js';
|
|
5
5
|
import { PlatformUtils } from './PlatformUtils.js';
|
|
6
6
|
import { CountryCallingCode } from 'libphonenumber-js';
|
|
7
7
|
export declare function entityToWallet(w: WalletEntity): Omit<Wallet, 'signer'>;
|
|
@@ -169,12 +169,12 @@ export declare abstract class ParaCore {
|
|
|
169
169
|
#private;
|
|
170
170
|
static version?: string;
|
|
171
171
|
ctx: Ctx;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
email?: string;
|
|
173
|
+
phone?: string;
|
|
174
|
+
countryCode?: CountryCallingCode;
|
|
175
|
+
farcasterUsername?: string;
|
|
176
176
|
telegramUserId?: string;
|
|
177
|
-
|
|
177
|
+
userId?: string;
|
|
178
178
|
private sessionCookie?;
|
|
179
179
|
private isAwaitingAccountCreation;
|
|
180
180
|
private isAwaitingLogin;
|
|
@@ -469,72 +469,75 @@ export declare abstract class ParaCore {
|
|
|
469
469
|
private getShortUrl;
|
|
470
470
|
shortenLoginLink(link: string): Promise<string>;
|
|
471
471
|
/**
|
|
472
|
-
* Generates a URL
|
|
473
|
-
*
|
|
474
|
-
* @
|
|
475
|
-
* @param loginEncryptionPublicKey - public key to use for encrypting the login encryption key
|
|
476
|
-
* @param partnerId - id of the partner to get the portal URL for
|
|
477
|
-
* @param newDeviceSessionId - id of the session to use for web auth for a new device
|
|
478
|
-
* @param newDeviceEncryptionKey - public key to use for encrypting the login encryption key for a new device
|
|
479
|
-
* @returns - web auth url
|
|
472
|
+
* Generates a URL for registering a new WebAuth passkey.
|
|
473
|
+
* @param {GetWebAuthUrlForLoginParams} opts the options object
|
|
474
|
+
* @returns - the URL for creating a new passkey
|
|
480
475
|
*/
|
|
481
|
-
getWebAuthURLForLogin(
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}): Promise<string>;
|
|
476
|
+
getWebAuthURLForLogin(opts: GetWebAuthUrlForLoginParams): Promise<string>;
|
|
477
|
+
/**
|
|
478
|
+
* Generates a URL for registering a new user password.
|
|
479
|
+
* @param {GetWebAuthUrlForLoginParams} opts the options object
|
|
480
|
+
* @returns - the URL for creating a new password
|
|
481
|
+
*/
|
|
482
|
+
getPasswordURLForLogin(opts: GetWebAuthUrlForLoginParams): Promise<string>;
|
|
489
483
|
/**
|
|
490
|
-
* Generates a URL
|
|
491
|
-
*
|
|
492
|
-
* @param sessionId - id of the session to use for web auth
|
|
493
|
-
* @param loginEncryptionPublicKey - public key to use for encrypting the login encryption key
|
|
494
|
-
* @param partnerId - id of the partner to get the portal URL for
|
|
495
|
-
* @param newDeviceSessionId - id of the session to use for web auth for a new device
|
|
496
|
-
* @param newDeviceEncryptionKey - public key to use for encrypting the login encryption key for a new device
|
|
484
|
+
* Generates a URL for registering a new WebAuth passkey for a phone number.
|
|
485
|
+
* @param {Omit<GetWebAuthUrlForLoginParams, 'authType'>} opts the options object
|
|
497
486
|
* @returns - web auth url
|
|
498
487
|
*/
|
|
499
|
-
getWebAuthURLForLoginForPhone(
|
|
500
|
-
sessionId: string;
|
|
501
|
-
loginEncryptionPublicKey: string;
|
|
502
|
-
}): Promise<string>;
|
|
488
|
+
getWebAuthURLForLoginForPhone(opts: Omit<GetWebAuthUrlForLoginParams, 'authType'>): Promise<string>;
|
|
503
489
|
/**
|
|
504
490
|
* Gets the private key for the given wallet.
|
|
505
|
-
* @param
|
|
506
|
-
* @returns - private key string.
|
|
491
|
+
* @param {string } [walletId] id of the wallet to get the private key for. Will default to the first wallet if not provided.
|
|
492
|
+
* @returns - the private key string.
|
|
507
493
|
*/
|
|
508
494
|
protected getPrivateKey(walletId?: string): Promise<string>;
|
|
509
495
|
/**
|
|
510
496
|
* Fetches the wallets associated with the user.
|
|
511
|
-
* @returns
|
|
497
|
+
* @returns {WalletEntity[]} wallets that were fetched.
|
|
512
498
|
*/
|
|
513
499
|
fetchWallets(): Promise<WalletEntity[]>;
|
|
514
500
|
private populateWalletAddresses;
|
|
515
501
|
private populatePregenWalletAddresses;
|
|
516
502
|
/**
|
|
517
|
-
* Checks if a user exists.
|
|
518
|
-
* @
|
|
503
|
+
* Checks if a user exists for an email address.
|
|
504
|
+
* @param {Object} opts the options object
|
|
505
|
+
* @param {string} opts.email the email to check.
|
|
506
|
+
* @returns true if user exists, false otherwise.
|
|
519
507
|
*/
|
|
520
|
-
checkIfUserExists(email
|
|
508
|
+
checkIfUserExists({ email }: {
|
|
509
|
+
email: string;
|
|
510
|
+
}): Promise<boolean>;
|
|
521
511
|
/**
|
|
522
|
-
* Checks if a user exists
|
|
523
|
-
* @
|
|
512
|
+
* Checks if a user exists for a phone number.
|
|
513
|
+
* @param {Object} opts the options object
|
|
514
|
+
* @param {string} opts.phone - phone number to check.
|
|
515
|
+
* @param {string} opts.countryCode - the country code.
|
|
516
|
+
* @returns true if user exists, false otherwise.
|
|
517
|
+
*/
|
|
518
|
+
checkIfUserExistsByPhone({ phone, countryCode }: {
|
|
519
|
+
phone: string;
|
|
520
|
+
countryCode: string;
|
|
521
|
+
}): Promise<boolean>;
|
|
522
|
+
/**
|
|
523
|
+
* Creates a new user.
|
|
524
|
+
* @param {Object} opts the options object
|
|
525
|
+
* @param {string} opts.email the email to use.
|
|
524
526
|
*/
|
|
525
|
-
checkIfUserExistsByPhone(phone: string, countryCode: CountryCallingCode): Promise<boolean>;
|
|
526
527
|
createUser({ email }: Auth<'email'>): Promise<void>;
|
|
527
528
|
/**
|
|
528
529
|
* Creates a new user with a phone number.
|
|
529
|
-
* @param
|
|
530
|
-
* @param
|
|
530
|
+
* @param {Object} opts the options object
|
|
531
|
+
* @param {string} opts.phone - the phone number to use for creating the user.
|
|
532
|
+
* @param {string} opts.countryCode - the country code to use for creating the user.
|
|
531
533
|
*/
|
|
532
534
|
createUserByPhone({ phone, countryCode }: Auth<'phone'>): Promise<void>;
|
|
533
535
|
/**
|
|
534
536
|
* Logs in or creates a new user using an external wallet address.
|
|
535
|
-
* @param
|
|
536
|
-
* @param
|
|
537
|
-
* @param
|
|
537
|
+
* @param {Object} opts the options object
|
|
538
|
+
* @param {string} opts.address the external wallet address to use for identification.
|
|
539
|
+
* @param {WalletType} opts.type type of external wallet to use for identification.
|
|
540
|
+
* @param {string} opts.provider the name of the provider for the external wallet.
|
|
538
541
|
*/
|
|
539
542
|
externalWalletLogin(wallet: ExternalWalletInfo): Promise<void>;
|
|
540
543
|
/**
|
|
@@ -543,16 +546,22 @@ export declare abstract class ParaCore {
|
|
|
543
546
|
protected isUsingExternalWallet(): boolean;
|
|
544
547
|
/**
|
|
545
548
|
* Passes the email code obtained from the user for verification.
|
|
546
|
-
* @param
|
|
547
|
-
* @
|
|
549
|
+
* @param {Object} opts the options object
|
|
550
|
+
* @param {string} verificationCode the six-digit code to check
|
|
551
|
+
* @returns {string} the web auth url for creating a new credential
|
|
548
552
|
*/
|
|
549
|
-
verifyEmail(verificationCode
|
|
553
|
+
verifyEmail({ verificationCode }: {
|
|
554
|
+
verificationCode: string;
|
|
555
|
+
}): Promise<string>;
|
|
550
556
|
/**
|
|
551
557
|
* Passes the phone code obtained from the user for verification.
|
|
552
|
-
* @param
|
|
553
|
-
* @
|
|
558
|
+
* @param {Object} opts the options object
|
|
559
|
+
* @param {string} verificationCode the six-digit code to check
|
|
560
|
+
* @returns {string} the web auth url for creating a new credential
|
|
554
561
|
*/
|
|
555
|
-
verifyPhone(verificationCode
|
|
562
|
+
verifyPhone({ verificationCode }: {
|
|
563
|
+
verificationCode: string;
|
|
564
|
+
}): Promise<string>;
|
|
556
565
|
/**
|
|
557
566
|
* Validates the response received from an attempted Telegram login for authenticity, then
|
|
558
567
|
* creates or retrieves the corresponding Para user and prepares the Para instance to sign in with that user.
|
|
@@ -562,11 +571,15 @@ export declare abstract class ParaCore {
|
|
|
562
571
|
verifyTelegram(authObject: TelegramAuthResponse): Promise<VerifyTelegramRes>;
|
|
563
572
|
/**
|
|
564
573
|
* Performs 2FA verification.
|
|
565
|
-
* @param
|
|
566
|
-
* @param
|
|
567
|
-
* @
|
|
574
|
+
* @param {Object} opts the options object
|
|
575
|
+
* @param {string} opts.email the email to use for performing a 2FA verification.
|
|
576
|
+
* @param {string} opts.verificationCode the verification code to received via 2FA.
|
|
577
|
+
* @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
|
|
568
578
|
*/
|
|
569
|
-
verify2FA(email
|
|
579
|
+
verify2FA({ email, verificationCode }: {
|
|
580
|
+
email: string;
|
|
581
|
+
verificationCode: string;
|
|
582
|
+
}): Promise<{
|
|
570
583
|
initiatedAt?: Date;
|
|
571
584
|
status?: RecoveryStatus;
|
|
572
585
|
userId: string;
|
|
@@ -574,45 +587,84 @@ export declare abstract class ParaCore {
|
|
|
574
587
|
}>;
|
|
575
588
|
/**
|
|
576
589
|
* Performs 2FA verification.
|
|
577
|
-
* @param
|
|
578
|
-
* @param
|
|
579
|
-
* @
|
|
580
|
-
|
|
581
|
-
|
|
590
|
+
* @param {Object} opts the options object
|
|
591
|
+
* @param {string} opts.phone the phone number
|
|
592
|
+
* @param {string} opts.countryCode - the country code
|
|
593
|
+
* @param {string} opts.verificationCode - verification code to received via 2FA.
|
|
594
|
+
* @returns {Object} `{ address, initiatedAt, status, userId, walletId }`
|
|
595
|
+
*/
|
|
596
|
+
verify2FAForPhone({ phone, countryCode, verificationCode, }: {
|
|
597
|
+
phone: string;
|
|
598
|
+
countryCode: string;
|
|
599
|
+
verificationCode: string;
|
|
600
|
+
}): Promise<{
|
|
582
601
|
initiatedAt?: Date;
|
|
583
602
|
status?: RecoveryStatus;
|
|
584
603
|
userId: string;
|
|
585
604
|
wallets: Pick<Wallet, 'address' | 'id'>[];
|
|
586
605
|
}>;
|
|
587
606
|
/**
|
|
588
|
-
* Sets up
|
|
589
|
-
* @returns uri - uri to use for setting up 2FA
|
|
607
|
+
* Sets up two-factor authentication for the current user.
|
|
608
|
+
* @returns {string} uri - uri to use for setting up 2FA
|
|
590
609
|
* */
|
|
591
610
|
setup2FA(): Promise<{
|
|
592
611
|
uri?: string;
|
|
593
612
|
}>;
|
|
594
613
|
/**
|
|
595
614
|
* Enables 2FA.
|
|
596
|
-
* @param
|
|
615
|
+
* @param {Object} opts the options object
|
|
616
|
+
* @param {string} opts.verificationCode - the verification code received via 2FA.
|
|
597
617
|
*/
|
|
598
|
-
enable2FA(verificationCode
|
|
618
|
+
enable2FA({ verificationCode }: {
|
|
619
|
+
verificationCode: string;
|
|
620
|
+
}): Promise<void>;
|
|
599
621
|
/**
|
|
600
622
|
* Determines if 2FA has been set up.
|
|
601
|
-
* @returns { isSetup } - true if 2FA is setup, false otherwise
|
|
623
|
+
* @returns {Object} `{ isSetup: boolean }` - true if 2FA is setup, false otherwise
|
|
602
624
|
*/
|
|
603
625
|
check2FAStatus(): Promise<{
|
|
604
626
|
isSetup: boolean;
|
|
605
627
|
}>;
|
|
628
|
+
/**
|
|
629
|
+
* Resend a verification email for the current user.
|
|
630
|
+
*/
|
|
606
631
|
resendVerificationCode(): Promise<void>;
|
|
632
|
+
/**
|
|
633
|
+
* Resend a verification SMS for the current user.
|
|
634
|
+
*/
|
|
607
635
|
resendVerificationCodeByPhone(): Promise<void>;
|
|
636
|
+
/**
|
|
637
|
+
* Returns a URL for setting up a new WebAuth passkey.
|
|
638
|
+
* @param {Object} opts the options object
|
|
639
|
+
* @param {string} opts.authType - the auth type to use
|
|
640
|
+
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
641
|
+
* @returns {string} the URL
|
|
642
|
+
*/
|
|
608
643
|
getSetUpBiometricsURL({ authType, isForNewDevice, }?: Pick<PortalUrlOptions, 'authType' | 'isForNewDevice'>): Promise<string>;
|
|
644
|
+
/**
|
|
645
|
+
* Returns a URL for setting up a new WebAuth passkey for a phone number.
|
|
646
|
+
* @param {Object} opts the options object
|
|
647
|
+
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
648
|
+
* @returns {string} the URL
|
|
649
|
+
*/
|
|
609
650
|
getSetUpBiometricsURLForPhone({ isForNewDevice, }?: Pick<PortalUrlOptions, 'isForNewDevice'>): Promise<string>;
|
|
651
|
+
/**
|
|
652
|
+
* Returns a URL for setting up a new password.
|
|
653
|
+
* @param {Object} opts the options object
|
|
654
|
+
* @param {string} opts.authType - the auth type to use
|
|
655
|
+
* @param {boolean} opts.isForNewDevice whether the passkey is for a new device of an existing user
|
|
656
|
+
* @param {Theme} [opts.theme] the portal theme to use in place of the partner's default
|
|
657
|
+
* @returns {string} the URL
|
|
658
|
+
*/
|
|
610
659
|
getSetupPasswordURL({ authType, isForNewDevice, theme, }?: Pick<PortalUrlOptions, 'authType' | 'isForNewDevice' | 'theme'>): Promise<string>;
|
|
660
|
+
/**
|
|
661
|
+
* Checks if the current session is active.
|
|
662
|
+
* @returns `true` if active, `false` otherwise
|
|
663
|
+
*/
|
|
611
664
|
isSessionActive(): Promise<boolean>;
|
|
612
665
|
/**
|
|
613
666
|
* Checks if a session is active and a wallet exists.
|
|
614
|
-
*
|
|
615
|
-
* @returns true if session is active and a wallet exists.
|
|
667
|
+
* @returns `true` if active, `false` otherwise
|
|
616
668
|
**/
|
|
617
669
|
isFullyLoggedIn(): Promise<boolean>;
|
|
618
670
|
protected supportedAuthMethods(auth: Auth): Promise<Set<AuthMethod>>;
|
|
@@ -624,9 +676,10 @@ export declare abstract class ParaCore {
|
|
|
624
676
|
private setAuth;
|
|
625
677
|
/**
|
|
626
678
|
* Initiates a login.
|
|
627
|
-
* @param
|
|
628
|
-
* @param
|
|
629
|
-
* @
|
|
679
|
+
* @param {Object} opts the options object
|
|
680
|
+
* @param {String} opts.email - the email to login with
|
|
681
|
+
* @param {boolean} opts.useShortURL - whether to shorten the link
|
|
682
|
+
* @returns - the WebAuth URL for logging in
|
|
630
683
|
**/
|
|
631
684
|
initiateUserLogin({ useShortUrl, ...auth }: Auth & {
|
|
632
685
|
useShortUrl?: boolean;
|
|
@@ -639,10 +692,11 @@ export declare abstract class ParaCore {
|
|
|
639
692
|
initiateUserLoginV2(auth: Auth): Promise<Set<AuthMethod>>;
|
|
640
693
|
/**
|
|
641
694
|
* Initiates a login.
|
|
642
|
-
* @param
|
|
643
|
-
* @param
|
|
644
|
-
* @param
|
|
645
|
-
* @
|
|
695
|
+
* @param opts the options object
|
|
696
|
+
* @param opts.phone the phone number
|
|
697
|
+
* @param opts.countryCode the country code
|
|
698
|
+
* @param opts.useShortURL - whether to shorten the link
|
|
699
|
+
* @returns - the WebAuth URL for logging in
|
|
646
700
|
**/
|
|
647
701
|
initiateUserLoginForPhone({ useShortUrl, ...auth }: Auth<'phone'> & {
|
|
648
702
|
useShortUrl?: boolean;
|
|
@@ -651,23 +705,17 @@ export declare abstract class ParaCore {
|
|
|
651
705
|
* Waits for the session to be active.
|
|
652
706
|
**/
|
|
653
707
|
waitForAccountCreation(): Promise<boolean>;
|
|
654
|
-
waitForPasskeyAndCreateWallet(): Promise<
|
|
655
|
-
walletIds: CurrentWalletIds;
|
|
656
|
-
recoverySecret?: string;
|
|
657
|
-
}>;
|
|
708
|
+
waitForPasskeyAndCreateWallet(): Promise<AccountSetupResp>;
|
|
658
709
|
/**
|
|
659
710
|
* Initiates a Farcaster login attempt and return the URI for the user to connect.
|
|
660
711
|
* You can create a QR code with this URI that works with Farcaster's mobile app.
|
|
661
|
-
*
|
|
662
|
-
* @return {string}
|
|
712
|
+
* @return {string} the Farcaster connect URI
|
|
663
713
|
*/
|
|
664
714
|
getFarcasterConnectURL(): Promise<string>;
|
|
665
715
|
/**
|
|
666
716
|
* Awaits the response from a user's attempt to log in with Farcaster.
|
|
667
717
|
* If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
|
|
668
|
-
*
|
|
669
|
-
* @param {Object} opts the options object.
|
|
670
|
-
* @return {Object} the user's information and whether the user already exists.
|
|
718
|
+
* @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
|
|
671
719
|
*/
|
|
672
720
|
waitForFarcasterStatus(): Promise<{
|
|
673
721
|
userExists: boolean;
|
|
@@ -677,17 +725,20 @@ export declare abstract class ParaCore {
|
|
|
677
725
|
/**
|
|
678
726
|
* Generates a URL for the user to log in with OAuth using a desire method.
|
|
679
727
|
*
|
|
680
|
-
* @param {
|
|
728
|
+
* @param {Object} opts the options object
|
|
729
|
+
* @param {OAuthMethod} opts.method the third-party service to use for OAuth.
|
|
681
730
|
* @returns {string} the URL for the user to log in with OAuth.
|
|
682
731
|
*/
|
|
683
|
-
getOAuthURL(
|
|
732
|
+
getOAuthURL({ method }: {
|
|
733
|
+
method: OAuthMethod;
|
|
734
|
+
}): Promise<string>;
|
|
684
735
|
/**
|
|
685
736
|
* Awaits the response from a user's attempt to log in with OAuth.
|
|
686
737
|
* If successful, this returns the user's email address and indicates whether the user already exists.
|
|
687
738
|
*
|
|
688
739
|
* @param {Object} opts the options object.
|
|
689
740
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
690
|
-
* @return {Object}
|
|
741
|
+
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
691
742
|
*/
|
|
692
743
|
waitForOAuth({ popupWindow }?: {
|
|
693
744
|
popupWindow?: Window;
|
|
@@ -702,24 +753,19 @@ export declare abstract class ParaCore {
|
|
|
702
753
|
* @param {Object} opts the options object
|
|
703
754
|
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
704
755
|
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
705
|
-
* @returns {
|
|
756
|
+
* @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
|
|
706
757
|
**/
|
|
707
758
|
waitForLoginAndSetup({ popupWindow, skipSessionRefresh, }?: {
|
|
708
759
|
popupWindow?: Window;
|
|
709
760
|
skipSessionRefresh?: boolean;
|
|
710
|
-
}): Promise<
|
|
711
|
-
isComplete: boolean;
|
|
712
|
-
isError?: boolean;
|
|
713
|
-
needsWallet?: boolean;
|
|
714
|
-
partnerId?: string;
|
|
715
|
-
}>;
|
|
761
|
+
}): Promise<LoginResp>;
|
|
716
762
|
/**
|
|
717
763
|
* Updates the session with the user management server, possibly
|
|
718
764
|
* opening a popup to refresh the session.
|
|
719
765
|
*
|
|
720
766
|
* @param {Object} opts the options object.
|
|
721
767
|
* @param {boolean} [shouldOpenPopup] - if `true`, the running device will open a popup to reauthenticate the user.
|
|
722
|
-
* @returns
|
|
768
|
+
* @returns a URL for the user to reauthenticate.
|
|
723
769
|
**/
|
|
724
770
|
refreshSession({ shouldOpenPopup }?: {
|
|
725
771
|
shouldOpenPopup?: boolean;
|
|
@@ -737,8 +783,8 @@ export declare abstract class ParaCore {
|
|
|
737
783
|
}>;
|
|
738
784
|
/**
|
|
739
785
|
* Get transmission shares associated with session.
|
|
740
|
-
*
|
|
741
|
-
* @param isForNewDevice - true if this device is registering.
|
|
786
|
+
* @param {Object} opts the options object.
|
|
787
|
+
* @param {boolean} opts.isForNewDevice - true if this device is registering.
|
|
742
788
|
* @returns - transmission keyshares.
|
|
743
789
|
**/
|
|
744
790
|
protected getTransmissionKeyShares({ isForNewDevice }?: {
|
|
@@ -746,8 +792,9 @@ export declare abstract class ParaCore {
|
|
|
746
792
|
}): Promise<any>;
|
|
747
793
|
/**
|
|
748
794
|
* Call this method after login to perform setup.
|
|
749
|
-
*
|
|
750
|
-
* @param temporaryShares
|
|
795
|
+
* @param {Object} opts the options object.
|
|
796
|
+
* @param {any[]} opts.temporaryShares optional temporary shares to use for decryption.
|
|
797
|
+
* @param {boolean} [opts.skipSessionRefresh] - whether or not to skip refreshing the session.
|
|
751
798
|
**/
|
|
752
799
|
setupAfterLogin({ temporaryShares, skipSessionRefresh, }?: {
|
|
753
800
|
temporaryShares?: any[];
|
|
@@ -755,12 +802,12 @@ export declare abstract class ParaCore {
|
|
|
755
802
|
}): Promise<void>;
|
|
756
803
|
/**
|
|
757
804
|
* Distributes a new wallet recovery share.
|
|
758
|
-
*
|
|
759
|
-
* @param walletId
|
|
760
|
-
* @param userShare
|
|
761
|
-
* @param skipBiometricShareCreation
|
|
762
|
-
* @param forceRefreshRecovery
|
|
763
|
-
* @returns
|
|
805
|
+
* @param {Object} opts the options object.
|
|
806
|
+
* @param {string} opts.walletId the wallet to distribute the recovery share for.
|
|
807
|
+
* @param {string} opts.userShare optional user share generate the recovery share from. Defaults to the signer from the passed in walletId
|
|
808
|
+
* @param {boolean} opts.skipBiometricShareCreation whether or not to skip biometric share creation. Used when regenerating recovery shares.
|
|
809
|
+
* @param {boolean} opts.forceRefreshRecovery whether or not to force recovery secret regeneration. Used when regenerating recovery shares.
|
|
810
|
+
* @returns {string} the recovery share.
|
|
764
811
|
**/
|
|
765
812
|
distributeNewWalletShare({ walletId, userShare, skipBiometricShareCreation, forceRefresh, }: {
|
|
766
813
|
walletId: string;
|
|
@@ -840,10 +887,10 @@ export declare abstract class ParaCore {
|
|
|
840
887
|
}>;
|
|
841
888
|
/**
|
|
842
889
|
* Creates a new wallet.
|
|
843
|
-
*
|
|
844
|
-
* @param
|
|
845
|
-
* @param
|
|
846
|
-
* @returns [wallet, recoveryShare]
|
|
890
|
+
* @param {Object} opts the options object.
|
|
891
|
+
* @param {WalletType} opts.type the type of wallet to create.
|
|
892
|
+
* @param {boolean} opts.skipDistribute - if true, recovery share will not be distributed.
|
|
893
|
+
* @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
|
|
847
894
|
**/
|
|
848
895
|
createWallet({ type: _type, skipDistribute, }?: {
|
|
849
896
|
type?: WalletType;
|
|
@@ -858,7 +905,7 @@ export declare abstract class ParaCore {
|
|
|
858
905
|
* @param {WalletType} [opts.type] the type of wallet to create. Defaults to the first non-optional type in the instance's `supportedWalletTypes` array.
|
|
859
906
|
* @returns {Wallet} the created wallet.
|
|
860
907
|
**/
|
|
861
|
-
|
|
908
|
+
createPregenWallet(opts: {
|
|
862
909
|
type: WalletType;
|
|
863
910
|
pregenIdentifier: string;
|
|
864
911
|
pregenIdentifierType: TPregenIdentifierType;
|
|
@@ -867,11 +914,11 @@ export declare abstract class ParaCore {
|
|
|
867
914
|
* Creates new pregenerated wallets for each desired type.
|
|
868
915
|
* If no types are provided, this method will create one for each of the non-optional types
|
|
869
916
|
* specified in the instance's `supportedWalletTypes` array that are not already present.
|
|
870
|
-
*
|
|
871
|
-
* @param {string} pregenIdentifier the identifier to associate each wallet with.
|
|
872
|
-
* @param {TPregenIdentifierType} pregenIdentifierType - either `'EMAIL'` or `'PHONE'`.
|
|
873
|
-
* @param {WalletType[]} [types] the wallet types to create. Defaults to any types the instance supports that are not already present.
|
|
874
|
-
* @returns an array containing the created wallets.
|
|
917
|
+
* @param {Object} opts the options object.
|
|
918
|
+
* @param {string} opts.pregenIdentifier the identifier to associate each wallet with.
|
|
919
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType - either `'EMAIL'` or `'PHONE'`.
|
|
920
|
+
* @param {WalletType[]} [opts.types] the wallet types to create. Defaults to any types the instance supports that are not already present.
|
|
921
|
+
* @returns {Wallet[]} an array containing the created wallets.
|
|
875
922
|
**/
|
|
876
923
|
createPregenWalletPerType({ types, pregenIdentifier, pregenIdentifierType, }: {
|
|
877
924
|
pregenIdentifier: string;
|
|
@@ -881,17 +928,21 @@ export declare abstract class ParaCore {
|
|
|
881
928
|
/**
|
|
882
929
|
* Claims a pregenerated wallet.
|
|
883
930
|
*
|
|
884
|
-
* @param
|
|
885
|
-
* @param
|
|
886
|
-
* @
|
|
931
|
+
* @param {Object} opts the options object.
|
|
932
|
+
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
933
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the identifier of the user claiming the wallet
|
|
934
|
+
* @returns {[Wallet, string | null]} `[wallet, recoveryShare]` - the wallet object and the new recovery share.
|
|
887
935
|
**/
|
|
888
|
-
claimPregenWallets(pregenIdentifier
|
|
936
|
+
claimPregenWallets({ pregenIdentifier, pregenIdentifierType, }?: {
|
|
937
|
+
pregenIdentifier?: string;
|
|
938
|
+
pregenIdentifierType?: TPregenIdentifierType;
|
|
939
|
+
}): Promise<string | undefined>;
|
|
889
940
|
/**
|
|
890
|
-
* Updates a
|
|
891
|
-
*
|
|
892
|
-
* @param
|
|
893
|
-
* @param
|
|
894
|
-
* @
|
|
941
|
+
* Updates the identifier for a pregen wallet.
|
|
942
|
+
* @param {Object} opts the options object.
|
|
943
|
+
* @param {string} opts.walletId the pregen wallet ID
|
|
944
|
+
* @param {string} opts.newPregenIdentifier the new identtifier
|
|
945
|
+
* @param {TPregenIdentifierType} opts.newPregenIdentifierType: the new identifier type
|
|
895
946
|
**/
|
|
896
947
|
updatePregenWalletIdentifier({ walletId, newPregenIdentifier, newPregenIdentifierType, }: {
|
|
897
948
|
walletId: string;
|
|
@@ -899,22 +950,22 @@ export declare abstract class ParaCore {
|
|
|
899
950
|
newPregenIdentifierType: TPregenIdentifierType;
|
|
900
951
|
}): Promise<void>;
|
|
901
952
|
/**
|
|
902
|
-
* Checks if
|
|
903
|
-
*
|
|
904
|
-
* @param pregenIdentifier string the identifier of the user claiming the wallet
|
|
905
|
-
* @param pregenIdentifierType type of the string of the identifier of the user claiming the wallet
|
|
906
|
-
* @returns
|
|
953
|
+
* Checks if a pregen Wallet exists for the given identifier with the current partner.
|
|
954
|
+
* @param {Object} opts the options object.
|
|
955
|
+
* @param {string} opts.pregenIdentifier string the identifier of the user claiming the wallet
|
|
956
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType type of the string of the identifier of the user claiming the wallet
|
|
957
|
+
* @returns {boolean} whether the pregen wallet exists
|
|
907
958
|
**/
|
|
908
959
|
hasPregenWallet({ pregenIdentifier, pregenIdentifierType, }: {
|
|
909
960
|
pregenIdentifier: string;
|
|
910
961
|
pregenIdentifierType: TPregenIdentifierType;
|
|
911
962
|
}): Promise<boolean>;
|
|
912
963
|
/**
|
|
913
|
-
* Get pregen wallets for the identifier
|
|
914
|
-
*
|
|
915
|
-
* @param {string} pregenIdentifier - the identifier of the user claiming the wallet
|
|
916
|
-
* @param {TPregenIdentifierType} pregenIdentifierType - type of the identifier of the user claiming the wallet
|
|
917
|
-
* @returns {Promise<WalletEntity[]>}
|
|
964
|
+
* Get pregen wallets for the given identifier.
|
|
965
|
+
* @param {Object} opts the options object.
|
|
966
|
+
* @param {string} opts.pregenIdentifier - the identifier of the user claiming the wallet
|
|
967
|
+
* @param {TPregenIdentifierType} opts.pregenIdentifierType - type of the identifier of the user claiming the wallet
|
|
968
|
+
* @returns {Promise<WalletEntity[]>} the array of found wallets
|
|
918
969
|
**/
|
|
919
970
|
getPregenWallets({ pregenIdentifier, pregenIdentifierType, }?: {
|
|
920
971
|
pregenIdentifier?: string;
|
|
@@ -922,28 +973,27 @@ export declare abstract class ParaCore {
|
|
|
922
973
|
}): Promise<WalletEntity[]>;
|
|
923
974
|
private encodeWalletBase64;
|
|
924
975
|
/**
|
|
925
|
-
*
|
|
926
|
-
*
|
|
927
|
-
* @returns string base64 encoded wallet
|
|
976
|
+
* Encodes the current wallets encoded in Base 64.
|
|
977
|
+
* @returns {string} the encoded wallet string
|
|
928
978
|
**/
|
|
929
979
|
getUserShare(): string | null;
|
|
930
980
|
/**
|
|
931
|
-
* Sets
|
|
932
|
-
*
|
|
933
|
-
* @param base64Wallet
|
|
934
|
-
* @returns Promise<void>
|
|
981
|
+
* Sets the current wallets from a Base 64 string.
|
|
982
|
+
* @param {string} base64Wallet the encoded wallet string
|
|
935
983
|
**/
|
|
936
984
|
setUserShare(base64Wallets: string | null): Promise<void>;
|
|
937
985
|
private getTransactionReviewUrl;
|
|
938
986
|
private getOnRampTransactionUrl;
|
|
939
987
|
/**
|
|
940
|
-
* Signs a message.
|
|
988
|
+
* Signs a message using one of the current wallets.
|
|
941
989
|
*
|
|
942
990
|
* If you want to sign the keccak256 hash of a message, hash the
|
|
943
991
|
* message first and then pass in the base64 encoded hash.
|
|
944
|
-
* @param
|
|
945
|
-
* @param
|
|
946
|
-
* @param
|
|
992
|
+
* @param {Object} opts the options object.
|
|
993
|
+
* @param {string} opts.walletId the id of the wallet to sign with.
|
|
994
|
+
* @param {string} opts.messageBase64 the base64 encoding of exact message that should be signed
|
|
995
|
+
* @param {number} [opts.timeout] optional timeout in milliseconds. If not present, defaults to 30 seconds.
|
|
996
|
+
* @param {string} [opts.cosmosSignDocBase64] the Cosmos `SignDoc` in base64, if applicable
|
|
947
997
|
**/
|
|
948
998
|
signMessage({ walletId, messageBase64, timeoutMs, cosmosSignDocBase64, }: {
|
|
949
999
|
walletId: string;
|
|
@@ -954,9 +1004,11 @@ export declare abstract class ParaCore {
|
|
|
954
1004
|
private signMessageInner;
|
|
955
1005
|
/**
|
|
956
1006
|
* Signs a transaction.
|
|
957
|
-
* @param
|
|
958
|
-
* @param
|
|
959
|
-
* @param
|
|
1007
|
+
* @param {Object} opts the options object.
|
|
1008
|
+
* @param {string} opts.walletId the id of the wallet to sign with.
|
|
1009
|
+
* @param {string} opts.rlpEncodedTxBase64 the transaction to sign, in RLP base64 encoding
|
|
1010
|
+
* @param {string} [opts.chainId] the EVM chain id of the chain the transaction is being sent on, if applicable
|
|
1011
|
+
* @param {number} [opts.timeoutMs] the amount of time to wait for the user to sign the transaction, in milliseconds
|
|
960
1012
|
**/
|
|
961
1013
|
signTransaction({ walletId, rlpEncodedTxBase64, chainId, timeoutMs, }: {
|
|
962
1014
|
walletId: string;
|
|
@@ -965,6 +1017,7 @@ export declare abstract class ParaCore {
|
|
|
965
1017
|
timeoutMs?: number;
|
|
966
1018
|
}): Promise<FullSignatureRes>;
|
|
967
1019
|
/**
|
|
1020
|
+
* @deprecated
|
|
968
1021
|
* Sends a transaction.
|
|
969
1022
|
* @param walletId - id of the wallet to send the transaction from.
|
|
970
1023
|
* @param rlpEncodedTxBase64 - rlp encoded tx as base64 string
|
|
@@ -978,11 +1031,11 @@ export declare abstract class ParaCore {
|
|
|
978
1031
|
protected isProviderModalDisabled(): boolean;
|
|
979
1032
|
/**
|
|
980
1033
|
* Starts a on-ramp or off-ramp transaction and returns the Para Portal link for the user to finalize and complete it.
|
|
981
|
-
* @param {Object}
|
|
982
|
-
* @param {OnRampPurchaseCreateParams}
|
|
983
|
-
* @param {boolean}
|
|
984
|
-
* @param {string}
|
|
985
|
-
* @param {string}
|
|
1034
|
+
* @param {Object} opts the options object
|
|
1035
|
+
* @param {OnRampPurchaseCreateParams} opts.params the transaction settings.
|
|
1036
|
+
* @param {boolean} opts.shouldOpenPopup if `true`, a popup window with the link will be opened.
|
|
1037
|
+
* @param {string} opts.walletId the wallet ID to use for the transaction, where funds will be sent or withdrawn.
|
|
1038
|
+
* @param {string} opts.externalWalletAddress the external wallet address to send funds to or withdraw funds from, if using an external wallet.
|
|
986
1039
|
**/
|
|
987
1040
|
initiateOnRampTransaction(options: WalletParams & {
|
|
988
1041
|
params: OnRampPurchaseCreateParams;
|
|
@@ -992,10 +1045,18 @@ export declare abstract class ParaCore {
|
|
|
992
1045
|
portalUrl: string;
|
|
993
1046
|
}>;
|
|
994
1047
|
/**
|
|
995
|
-
* Returns true if session was successfully kept alive, false otherwise.
|
|
1048
|
+
* Returns `true` if session was successfully kept alive, `false` otherwise.
|
|
996
1049
|
**/
|
|
997
1050
|
keepSessionAlive(): Promise<boolean>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Serialize the current session for import by another Para instance.
|
|
1053
|
+
* @returns {string} the serialized session
|
|
1054
|
+
*/
|
|
998
1055
|
exportSession(): string;
|
|
1056
|
+
/**
|
|
1057
|
+
* Imports a session serialized by another Para instance.
|
|
1058
|
+
* @param {string} serializedInstanceBase64 the serialized session
|
|
1059
|
+
*/
|
|
999
1060
|
importSession(serializedInstanceBase64: string): Promise<void>;
|
|
1000
1061
|
protected exitAccountCreation(): void;
|
|
1001
1062
|
protected exitLogin(): void;
|
|
@@ -1004,8 +1065,8 @@ export declare abstract class ParaCore {
|
|
|
1004
1065
|
protected exitLoops(): void;
|
|
1005
1066
|
/**
|
|
1006
1067
|
* Logs the user out.
|
|
1007
|
-
*
|
|
1008
|
-
* @param
|
|
1068
|
+
* @param {Object} opts the options object.
|
|
1069
|
+
* @param {boolean} opts.clearPregenWallets if `true`, will remove all pregen wallets from storage
|
|
1009
1070
|
**/
|
|
1010
1071
|
logout({ clearPregenWallets }?: {
|
|
1011
1072
|
clearPregenWallets?: boolean;
|