@getpara/core-sdk 2.0.0-alpha.20 → 2.0.0-alpha.21

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.
@@ -46,8 +46,21 @@ const PARA_CORE_METHODS = [
46
46
  "signTransaction",
47
47
  "initiateOnRampTransaction",
48
48
  "getWalletBalance",
49
- "issueJwt"
49
+ "issueJwt",
50
+ "getLinkedAccounts",
51
+ "accountLinkInProgress"
52
+ ];
53
+ const PARA_INTERNAL_METHODS = [
54
+ "linkAccount",
55
+ "unlinkAccount",
56
+ "verifyEmailOrPhoneLink",
57
+ "verifyOAuthLink",
58
+ "verifyFarcasterLink",
59
+ "verifyTelegramLink",
60
+ "verifyExternalWalletLink",
61
+ "accountLinkInProgress"
50
62
  ];
51
63
  export {
52
- PARA_CORE_METHODS
64
+ PARA_CORE_METHODS,
65
+ PARA_INTERNAL_METHODS
53
66
  };
@@ -1,4 +1,5 @@
1
1
  import "../chunk-7B52C2XE.js";
2
+ export * from "./auth.js";
2
3
  export * from "./config.js";
3
4
  export * from "./coreApi.js";
4
5
  export * from "./wallet.js";
@@ -1,6 +1,6 @@
1
- import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata } from '@getpara/user-management-client';
1
+ import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams, SupportedAccountLinks } from '@getpara/user-management-client';
2
2
  import type { pki as pkiType } from 'node-forge';
3
- import { Ctx, Environment, Theme, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType } from './types/index.js';
3
+ import { Ctx, Environment, Theme, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse } from './types/index.js';
4
4
  import { PlatformUtils } from './PlatformUtils.js';
5
5
  export declare abstract class ParaCore implements CoreInterface {
6
6
  #private;
@@ -15,6 +15,7 @@ export declare abstract class ParaCore implements CoreInterface {
15
15
  get externalWalletWithParaAuth(): Wallet | undefined;
16
16
  get externalWalletConnectionType(): ExternalWalletConnectionType;
17
17
  userId?: string;
18
+ accountLinkInProgress: AccountLinkInProgress | undefined;
18
19
  private sessionCookie?;
19
20
  private isAwaitingAccountCreation;
20
21
  private isAwaitingLogin;
@@ -124,6 +125,7 @@ export declare abstract class ParaCore implements CoreInterface {
124
125
  get isNoWalletConfig(): boolean;
125
126
  get supportedWalletTypes(): SupportedWalletTypes;
126
127
  get cosmosPrefix(): string | undefined;
128
+ get supportedAccountLinks(): SupportedAccountLinks;
127
129
  get isWalletTypeEnabled(): Partial<Record<TWalletType, boolean>>;
128
130
  private platformUtils;
129
131
  private localStorageGetItem;
@@ -234,7 +236,7 @@ export declare abstract class ParaCore implements CoreInterface {
234
236
  * @param externalAddress - External wallet address to set.
235
237
  * @param externalType - Type of external wallet to set.
236
238
  */
237
- setExternalWallet({ address, type, provider, addressBech32, withFullParaAuth, isConnectionOnly, withVerification, }: ExternalWalletInfo): Promise<void>;
239
+ setExternalWallet({ address, type, provider, providerId, addressBech32, withFullParaAuth, isConnectionOnly, withVerification, }: ExternalWalletInfo): Promise<void>;
238
240
  /**
239
241
  * Sets the user id associated with the `ParaCore` instance.
240
242
  * @param userId - User id to set.
@@ -305,7 +307,7 @@ export declare abstract class ParaCore implements CoreInterface {
305
307
  */
306
308
  findWalletByAddress(address: string, filter?: WalletFilters | undefined): any;
307
309
  findWallet(idOrAddress?: string, overrideType?: TWalletType, filter?: WalletFilters): Omit<Wallet, 'signer'> | undefined;
308
- get availableWallets(): Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'isExternal'>[];
310
+ get availableWallets(): Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'isExternal' | 'externalProviderId'>[];
309
311
  /**
310
312
  * Retrieves all usable wallets with the provided type (`'EVM' | 'COSMOS' | 'SOLANA'`)
311
313
  * @param {string} type the wallet type to filter by.
@@ -345,13 +347,15 @@ export declare abstract class ParaCore implements CoreInterface {
345
347
  */
346
348
  loginExternalWallet({ externalWallet, ...urlOptions }: CoreMethodParams<'loginExternalWallet'>): CoreMethodResponse<'loginExternalWallet'>;
347
349
  verifyExternalWallet({ externalWallet, signedMessage, cosmosPublicKeyHex, cosmosSigner, ...urlOptions }: CoreMethodParams<'verifyExternalWallet'>): CoreMethodResponse<'verifyExternalWallet'>;
348
- /**
349
- * Validates the response received from an attempted Telegram login for authenticity, then
350
- * creates or retrieves the corresponding Para user and prepares the Para instance to sign in with that user.
351
- * @param authResponse - the response JSON object received from the Telegram widget.
352
- * @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
353
- */
354
- verifyTelegram({ telegramAuthResponse, ...urlOptions }: CoreMethodParams<'verifyTelegram'>): CoreMethodResponse<'verifyTelegram'>;
350
+ protected verifyExternalWalletLink(opts: InternalMethodParams<'verifyExternalWalletLink'>): InternalMethodResponse<'verifyExternalWalletLink'>;
351
+ protected verifyTelegramProcess(opts: CoreMethodParams<'verifyTelegram'> & {
352
+ isLinkAccount: false;
353
+ }): CoreMethodResponse<'verifyTelegram'>;
354
+ protected verifyTelegramProcess(opts: InternalMethodParams<'verifyTelegramLink'> & {
355
+ isLinkAccount: true;
356
+ }): InternalMethodResponse<'verifyTelegramLink'>;
357
+ verifyTelegram(opts: CoreMethodParams<'verifyTelegram'>): CoreMethodResponse<'verifyTelegram'>;
358
+ protected verifyTelegramLink(opts: InternalMethodParams<'verifyTelegramLink'>): InternalMethodResponse<'verifyTelegramLink'>;
355
359
  /**
356
360
  * Performs 2FA verification.
357
361
  * @param {Object} opts the options object
@@ -374,7 +378,7 @@ export declare abstract class ParaCore implements CoreInterface {
374
378
  /**
375
379
  * Resend a verification email for the current user.
376
380
  */
377
- resendVerificationCode(): CoreMethodResponse<'resendVerificationCode'>;
381
+ resendVerificationCode({ type: reason, }: CoreMethodParams<'resendVerificationCode'>): CoreMethodResponse<'resendVerificationCode'>;
378
382
  /**
379
383
  * Checks if the current session is active.
380
384
  * @returns `true` if active, `false` otherwise
@@ -406,30 +410,23 @@ export declare abstract class ParaCore implements CoreInterface {
406
410
  getFarcasterConnectUri({ appScheme }?: {
407
411
  appScheme?: string;
408
412
  }): CoreMethodResponse<'getFarcasterConnectUri'>;
409
- /**
410
- * Awaits the response from a user's attempt to log in with Farcaster.
411
- * If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
412
- * @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
413
- */
414
- verifyFarcaster({ isCanceled, onConnectUri, onCancel, onPoll, ...urlOptions }: CoreMethodParams<'verifyFarcaster'>): CoreMethodResponse<'verifyFarcaster'>;
415
- /**
416
- * Generates a URL for the user to log in with OAuth using a desire method.
417
- *
418
- * @param {Object} opts the options object
419
- * @param {TOAuthMethod} opts.method the third-party service to use for OAuth.
420
- * @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
421
- * @returns {string} the URL for the user to log in with OAuth.
422
- */
423
- getOAuthUrl({ method, deeplinkUrl, ...params }: CoreMethodParams<'getOAuthUrl'>): CoreMethodResponse<'getOAuthUrl'>;
424
- /**
425
- * Awaits the response from a user's attempt to log in with OAuth.
426
- * If successful, this returns the user's email address and indicates whether the user already exists.
427
- *
428
- * @param {Object} opts the options object.
429
- * @param {Window} [opts.popupWindow] the popup window being used for login.
430
- * @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
431
- */
432
- verifyOAuth({ method, deeplinkUrl, isCanceled, onCancel, onPoll, onOAuthUrl, ...urlOptions }: CoreMethodParams<'verifyOAuth'>): CoreMethodResponse<'verifyOAuth'>;
413
+ protected verifyFarcasterProcess(opts: CoreMethodParams<'verifyFarcaster'> & {
414
+ isLinkAccount: false;
415
+ }): CoreMethodResponse<'verifyFarcaster'>;
416
+ protected verifyFarcasterProcess(opts: InternalMethodParams<'verifyFarcasterLink'> & {
417
+ isLinkAccount: true;
418
+ }): InternalMethodResponse<'verifyFarcasterLink'>;
419
+ verifyFarcaster(opts: CoreMethodParams<'verifyFarcaster'>): CoreMethodResponse<'verifyFarcaster'>;
420
+ protected verifyFarcasterLink(opts: InternalMethodParams<'verifyFarcasterLink'>): InternalMethodResponse<'verifyFarcasterLink'>;
421
+ getOAuthUrl(opts: CoreMethodParams<'getOAuthUrl'>): CoreMethodResponse<'getOAuthUrl'>;
422
+ protected verifyOAuthProcess(_: InternalMethodParams<'verifyOAuthLink'> & {
423
+ isLinkAccount: true;
424
+ }): InternalMethodResponse<'verifyOAuthLink'>;
425
+ protected verifyOAuthProcess(_: CoreMethodParams<'verifyOAuth'> & {
426
+ isLinkAccount: false;
427
+ }): CoreMethodResponse<'verifyOAuth'>;
428
+ verifyOAuth(opts: CoreMethodParams<'verifyOAuth'>): CoreMethodResponse<'verifyOAuth'>;
429
+ protected verifyOAuthLink(opts: InternalMethodParams<'verifyOAuthLink'>): InternalMethodResponse<'verifyOAuthLink'>;
433
430
  /**
434
431
  * Waits for the session to be active and sets up the user.
435
432
  *
@@ -654,8 +651,6 @@ export declare abstract class ParaCore implements CoreInterface {
654
651
  logout({ clearPregenWallets }?: {
655
652
  clearPregenWallets?: boolean;
656
653
  }): Promise<void>;
657
- /** @deprecated */
658
- protected getSupportedCreateAuthMethods(): Promise<Set<AuthMethod>>;
659
654
  /**
660
655
  * Converts to a string, removing sensitive data when logging this class.
661
656
  *
@@ -677,4 +672,11 @@ export declare abstract class ParaCore implements CoreInterface {
677
672
  protected getLoginUrl({ authMethod, shorten, portalTheme, sessionId, }: LoginUrlParams): Promise<string>;
678
673
  signUpOrLogIn({ auth, ...urlOptions }: CoreMethodParams<'signUpOrLogIn'>): CoreMethodResponse<'signUpOrLogIn'>;
679
674
  verifyNewAccount({ verificationCode, ...urlOptions }: CoreMethodParams<'verifyNewAccount'>): CoreMethodResponse<'verifyNewAccount'>;
675
+ getLinkedAccounts(): CoreMethodResponse<'getLinkedAccounts'>;
676
+ protected linkAccount(opts: InternalMethodParams<'linkAccount'>): InternalMethodResponse<'linkAccount'>;
677
+ protected unlinkAccount({ linkedAccountId, }: InternalMethodParams<'unlinkAccount'>): InternalMethodResponse<'unlinkAccount'>;
678
+ protected verifyLink({ accountLinkInProgress, ...opts }?: {
679
+ accountLinkInProgress?: AccountLinkInProgress;
680
+ } & Partial<Pick<VerifyLinkParams, 'verificationCode' | 'telegramAuthResponse'> & VerifyExternalWalletParams>): Promise<LinkedAccounts>;
681
+ protected verifyEmailOrPhoneLink({ verificationCode, }: InternalMethodParams<'verifyEmailOrPhoneLink'>): InternalMethodResponse<'verifyEmailOrPhoneLink'>;
680
682
  }
@@ -18,3 +18,4 @@ export declare const POLLING_INTERVAL_MS = 2000;
18
18
  export declare const SHORT_POLLING_INTERVAL_MS = 1000;
19
19
  export declare const POLLING_TIMEOUT_MS = 300000;
20
20
  export declare const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
21
+ export declare const ACCOUNT_LINK_CONFLICT = "Account already linked";
@@ -1,6 +1,6 @@
1
1
  import { ParaCore } from './ParaCore.js';
2
- export { type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, AuthMethod, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAllowedAssets, type OnRampPurchase, OAuthMethod, type TOAuthMethod, type SupportedWalletTypes, type TPregenIdentifierType, type PregenIds, type PregenAuth, NON_ED25519, PREGEN_IDENTIFIER_TYPES, WALLET_TYPES, WALLET_SCHEMES, OAUTH_METHODS, } from '@getpara/user-management-client';
3
- export { OnRampMethod, PopupType, PregenIdentifierType, RecoveryStatus, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type ProviderAssetInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type OnRampAssetInfo, type Theme, type Wallet, type GetWalletBalanceParams, } from './types/index.js';
2
+ export { type Auth, type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, type VerifiedAuth, AuthMethod, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAllowedAssets, type OnRampPurchase, OAuthMethod, type TOAuthMethod, type TLinkedAccountType, type SupportedAccountLinks, type SupportedWalletTypes, type TPregenIdentifierType, type PregenIds, type LinkedAccount, type LinkedAccounts, type TExternalWallet, type ExternalWalletInfo, type PregenAuth, type Setup2faResponse, type TelegramAuthResponse, type VerifyExternalWalletParams, NON_ED25519, PREGEN_IDENTIFIER_TYPES, WALLET_TYPES, WALLET_SCHEMES, OAUTH_METHODS, LINKED_ACCOUNT_TYPES, EXTERNAL_WALLET_TYPES, EVM_WALLETS, SOLANA_WALLETS, COSMOS_WALLETS, } from '@getpara/user-management-client';
3
+ export { OnRampMethod, PopupType, PregenIdentifierType, RecoveryStatus, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type ProviderAssetInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type OnRampAssetInfo, type Theme, type Wallet, type GetWalletBalanceParams, type AccountLinkInProgress, AccountLinkError, type InternalInterface, } from './types/index.js';
4
4
  export * from './types/coreApi.js';
5
5
  export * from './types/events.js';
6
6
  export * from './types/config.js';
@@ -0,0 +1,16 @@
1
+ import { ExternalWalletInfo, TLinkedAccountType } from '@getpara/user-management-client';
2
+ export type AccountLinkInProgress = {
3
+ id: string;
4
+ type: TLinkedAccountType;
5
+ identifier?: string;
6
+ isComplete: boolean;
7
+ externalWallet?: ExternalWalletInfo & {
8
+ signatureVerificationMessage: string;
9
+ };
10
+ };
11
+ export declare enum AccountLinkError {
12
+ NotAuthenticated = "No user is currently authenticated",
13
+ Conflict = "Account already linked",
14
+ Canceled = "Account linking was canceled",
15
+ Unknown = "An unknown error occurred"
16
+ }
@@ -1,24 +1,48 @@
1
- import { BackupKitEmailProps, CurrentWalletIds, ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, PregenAuth, Setup2faResponse, TelegramAuthResponse, VerifiedAuth, VerifyExternalWalletParams, WalletEntity, WalletParams, TWalletType, IssueJwtParams, IssueJwtResponse } from '@getpara/user-management-client';
2
- import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, WithCustomTheme, WithUseShortUrls, Verify2faResponse, AuthStateSignup, AuthStateVerifyOrLogin, OAuthUrlParams, StorageType, PollParams, CoreAuthInfo, GetWalletBalanceParams, GetWalletBalanceResponse } from './methods.js';
1
+ import { BackupKitEmailProps, CurrentWalletIds, ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, PregenAuth, Setup2faResponse, VerifiedAuth, VerifyExternalWalletParams, WalletEntity, WalletParams, TWalletType, IssueJwtParams, IssueJwtResponse, TLinkedAccountType, LinkedAccounts } from '@getpara/user-management-client';
2
+ import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, WithCustomTheme, WithUseShortUrls, Verify2faResponse, AuthStateSignup, AuthStateVerifyOrLogin, OAuthUrlParams, StorageType, PollParams, CoreAuthInfo, GetWalletBalanceParams, GetWalletBalanceResponse, FarcasterParams, TelegramParams, OAuthParams } from './methods.js';
3
3
  import { ParaCore } from '../ParaCore.js';
4
4
  import { FullSignatureRes, Wallet } from './wallet.js';
5
- export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt"];
5
+ import { AccountLinkInProgress } from './auth.js';
6
+ export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress"];
7
+ export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress"];
6
8
  export type CoreMethodName = (typeof PARA_CORE_METHODS)[number];
7
9
  export type CoreMethodParams<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
8
10
  params: infer P;
9
11
  } ? P : never;
12
+ export type CoreMethodIsGetter<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
13
+ isGetter: true;
14
+ } ? true : false;
10
15
  export type CoreMethodResponse<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
11
16
  response: infer R;
12
17
  } ? CoreMethods[method] extends {
13
18
  sync: true;
14
19
  } ? R : Promise<R> : void;
15
- export type CoreMethod<method extends CoreMethodName & keyof CoreMethods> = CoreMethodParams<method> extends void | never ? () => CoreMethodResponse<method> : (_?: CoreMethodParams<method>) => CoreMethodResponse<method>;
20
+ export type CoreMethod<method extends CoreMethodName & keyof CoreMethods> = CoreMethodIsGetter<method> extends true ? Awaited<CoreMethodResponse<method>> : CoreMethodParams<method> extends void | never ? () => CoreMethodResponse<method> : (_?: CoreMethodParams<method>) => CoreMethodResponse<method>;
16
21
  export type CoreAction<method extends CoreMethodName & keyof CoreMethods> = CoreMethodParams<method> extends void | never ? (_?: ParaCore) => CoreMethodResponse<method> : (_?: ParaCore, __?: CoreMethodParams<method>) => CoreMethodResponse<method>;
22
+ export type InternalMethodName = (typeof PARA_INTERNAL_METHODS)[number];
23
+ export type InternalMethodParams<method extends InternalMethodName & keyof InternalMethods> = InternalMethods[method] extends {
24
+ params: infer P;
25
+ } ? P : never;
26
+ export type InternalMethodIsGetter<method extends InternalMethodName & keyof InternalMethods> = InternalMethods[method] extends {
27
+ isGetter: true;
28
+ } ? true : false;
29
+ export type InternalMethodResponse<method extends InternalMethodName & keyof InternalMethods> = InternalMethods[method] extends {
30
+ response: infer R;
31
+ } ? InternalMethods[method] extends {
32
+ sync: true;
33
+ } ? R : Promise<R> : void;
34
+ export type InternalMethod<method extends InternalMethodName & keyof InternalMethods> = InternalMethodIsGetter<method> extends true ? Awaited<InternalMethodResponse<method>> : InternalMethodParams<method> extends void | never ? () => InternalMethodResponse<method> : (_?: InternalMethodParams<method>) => InternalMethodResponse<method>;
35
+ export type InternalAction<method extends InternalMethodName & keyof InternalMethods> = InternalMethodParams<method> extends void | never ? (_?: ParaCore) => InternalMethodResponse<method> : (_?: ParaCore, __?: InternalMethodParams<method>) => InternalMethodResponse<method>;
17
36
  export type CoreMethods = Record<CoreMethodName, {
18
37
  params?: unknown;
19
38
  response?: unknown;
20
39
  sync?: true;
21
40
  }> & {
41
+ accountLinkInProgress: {
42
+ params: never;
43
+ response: AccountLinkInProgress;
44
+ isGetter: true;
45
+ };
22
46
  getAuthInfo: {
23
47
  params: void;
24
48
  response: CoreAuthInfo | undefined;
@@ -98,17 +122,7 @@ export type CoreMethods = Record<CoreMethodName, {
98
122
  response: string;
99
123
  };
100
124
  verifyOAuth: {
101
- params: AuthStateBaseParams & OAuthUrlParams & PollParams & {
102
- /**
103
- * A function returning a boolean, indicating whether the OAuth process should be cancelled.
104
- */
105
- isCanceled?: () => boolean;
106
- /**
107
- * A callback function that will be invoked with the OAuth URL when it is available.
108
- * For example, you can use this to open the URL in a new window or tab.
109
- */
110
- onOAuthUrl?: (url: string) => void;
111
- };
125
+ params: AuthStateBaseParams & OAuthParams;
112
126
  response: OAuthResponse;
113
127
  };
114
128
  getFarcasterConnectUri: {
@@ -116,26 +130,11 @@ export type CoreMethods = Record<CoreMethodName, {
116
130
  response: string;
117
131
  };
118
132
  verifyFarcaster: {
119
- params: AuthStateBaseParams & PollParams & {
120
- /**
121
- * A function returning a boolean, indicating whether the Farcaster login process should be cancelled.
122
- */
123
- isCanceled?: () => boolean;
124
- /**
125
- * A callback function that will be invoked with the Farcaster Connect URI when it is available.
126
- * You will need to display the URI as a QR code.
127
- */
128
- onConnectUri?: (uri: string) => void;
129
- };
133
+ params: AuthStateBaseParams & FarcasterParams;
130
134
  response: OAuthResponse;
131
135
  };
132
136
  verifyTelegram: {
133
- params: AuthStateBaseParams & {
134
- /**
135
- * The response received from the Telegram login bot.
136
- */
137
- telegramAuthResponse: TelegramAuthResponse;
138
- };
137
+ params: AuthStateBaseParams & TelegramParams;
139
138
  response: OAuthResponse;
140
139
  };
141
140
  loginExternalWallet: {
@@ -152,7 +151,9 @@ export type CoreMethods = Record<CoreMethodName, {
152
151
  response: AuthStateSignup;
153
152
  };
154
153
  resendVerificationCode: {
155
- params: void;
154
+ params: {
155
+ type?: 'SIGNUP' | 'LINK_ACCOUNT';
156
+ } | undefined;
156
157
  response: void;
157
158
  };
158
159
  logout: {
@@ -473,7 +474,54 @@ export type CoreMethods = Record<CoreMethodName, {
473
474
  params: IssueJwtParams;
474
475
  response: IssueJwtResponse;
475
476
  };
477
+ getLinkedAccounts: {
478
+ params: void;
479
+ response: LinkedAccounts;
480
+ };
481
+ };
482
+ export type InternalMethods = {
483
+ linkAccount: {
484
+ params: {
485
+ auth: VerifiedAuth;
486
+ } | {
487
+ externalWallet: ExternalWalletInfo;
488
+ } | {
489
+ type: TLinkedAccountType | 'X';
490
+ };
491
+ response: AccountLinkInProgress;
492
+ };
493
+ unlinkAccount: {
494
+ params: {
495
+ linkedAccountId: string;
496
+ };
497
+ response: LinkedAccounts;
498
+ };
499
+ verifyEmailOrPhoneLink: {
500
+ params: {
501
+ verificationCode?: string;
502
+ };
503
+ response: LinkedAccounts;
504
+ };
505
+ verifyOAuthLink: {
506
+ params: OAuthParams;
507
+ response: LinkedAccounts;
508
+ };
509
+ verifyFarcasterLink: {
510
+ params: FarcasterParams;
511
+ response: LinkedAccounts;
512
+ };
513
+ verifyTelegramLink: {
514
+ params: TelegramParams;
515
+ response: LinkedAccounts;
516
+ };
517
+ verifyExternalWalletLink: {
518
+ params: Omit<VerifyExternalWalletParams, 'externalWallet'>;
519
+ response: LinkedAccounts;
520
+ };
476
521
  };
477
522
  export type CoreInterface = {
478
- [key in keyof CoreMethods]: CoreMethod<key>;
523
+ [key in keyof CoreMethods]: Partial<CoreMethod<key>>;
524
+ };
525
+ export type InternalInterface = {
526
+ [key in keyof InternalMethods]: Partial<InternalMethod<key>>;
479
527
  };
@@ -1,3 +1,4 @@
1
+ export * from './auth.js';
1
2
  export * from './config.js';
2
3
  export * from './coreApi.js';
3
4
  export * from './wallet.js';
@@ -1,4 +1,4 @@
1
- import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup, AuthMethod, ServerAuthStateVerify, VerifiedAuth, AuthExtras, TOAuthMethod, TWalletType } from '@getpara/user-management-client';
1
+ import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup, AuthMethod, ServerAuthStateVerify, VerifiedAuth, AuthExtras, TOAuthMethod, TWalletType, TelegramAuthResponse } from '@getpara/user-management-client';
2
2
  import { Theme } from './theme.js';
3
3
  import { RecoveryStatus } from './recovery.js';
4
4
  import { Wallet } from './wallet.js';
@@ -14,7 +14,7 @@ export type VerifyExternalWalletV1 = {
14
14
  cosmosPublicKeyHex?: string;
15
15
  cosmosSigner?: string;
16
16
  };
17
- export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp';
17
+ export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin';
18
18
  export type PortalUrlOptions = {
19
19
  params?: Record<string, string | undefined | null>;
20
20
  isForNewDevice?: boolean;
@@ -66,6 +66,23 @@ export type PollParams = {
66
66
  */
67
67
  onCancel?: () => void;
68
68
  };
69
+ export type FarcasterParams = PollParams & {
70
+ /**
71
+ * A function returning a boolean, indicating whether the Farcaster login process should be cancelled.
72
+ */
73
+ isCanceled?: () => boolean;
74
+ /**
75
+ * A callback function that will be invoked with the Farcaster Connect URI when it is available.
76
+ * You will need to display the URI as a QR code.
77
+ */
78
+ onConnectUri?: (uri: string) => void;
79
+ };
80
+ export type TelegramParams = {
81
+ /**
82
+ * The response received from the Telegram login bot.
83
+ */
84
+ telegramAuthResponse: TelegramAuthResponse;
85
+ };
69
86
  export type LoginUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & {
70
87
  sessionId?: string;
71
88
  };
@@ -85,6 +102,17 @@ export type OAuthUrlParams = {
85
102
  */
86
103
  deeplinkUrl?: string;
87
104
  };
105
+ export type OAuthParams = OAuthUrlParams & PollParams & {
106
+ /**
107
+ * A function returning a boolean, indicating whether the OAuth process should be cancelled.
108
+ */
109
+ isCanceled?: () => boolean;
110
+ /**
111
+ * A callback function that will be invoked with the OAuth URL when it is available.
112
+ * For example, you can use this to open the URL in a new window or tab.
113
+ */
114
+ onOAuthUrl?: (url: string) => void;
115
+ };
88
116
  export type AuthStateBaseParams = WithCustomTheme & WithUseShortUrls;
89
117
  export type AuthStateVerify = ServerAuthStateVerify;
90
118
  export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & WithIsPasskeySupported & {
@@ -1,4 +1,4 @@
1
- import { EmbeddedWalletType, ExternalWalletType, PartnerEntity, TPregenIdentifierType, TWalletScheme } from '@getpara/user-management-client';
1
+ import { EmbeddedWalletType, ExternalWalletType, PartnerEntity, TExternalWallet, TPregenIdentifierType, TWalletScheme } from '@getpara/user-management-client';
2
2
  export interface Wallet {
3
3
  createdAt?: string;
4
4
  id: string;
@@ -20,6 +20,7 @@ export interface Wallet {
20
20
  lastUsedPartnerId?: string;
21
21
  isExternal?: boolean;
22
22
  isExternalWithParaAuth?: boolean;
23
+ externalProviderId?: TExternalWallet;
23
24
  isExternalWithVerification?: boolean;
24
25
  isExternalConnectionOnly?: boolean;
25
26
  ensName?: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.20",
3
+ "version": "2.0.0-alpha.21",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "@celo/utils": "^8.0.2",
11
11
  "@cosmjs/encoding": "^0.32.4",
12
12
  "@ethereumjs/util": "^9.1.0",
13
- "@getpara/user-management-client": "2.0.0-alpha.20",
13
+ "@getpara/user-management-client": "2.0.0-alpha.21",
14
14
  "@noble/hashes": "^1.5.0",
15
15
  "base64url": "^3.0.1",
16
16
  "libphonenumber-js": "1.11.2",
@@ -41,5 +41,5 @@
41
41
  "require": "./dist/cjs/index.js"
42
42
  }
43
43
  },
44
- "gitHead": "4c8d918b9fc387476968bfc08524fe1a8b6ec83b"
44
+ "gitHead": "03daa3537312bc52e0640225c8abdbf8047c15da"
45
45
  }