@getpara/react-sdk-lite 2.0.0-dev.5 → 2.0.0-dev.6

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.
Files changed (39) hide show
  1. package/dist/modal/ParaModal.js +2 -1
  2. package/dist/modal/components/Account/Account.js +3 -3
  3. package/dist/modal/components/Account/AccountProfileLink.js +3 -3
  4. package/dist/modal/components/AddFunds/AddFunds.js +5 -7
  5. package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.d.ts +1 -0
  6. package/dist/modal/components/{AwaitingIFrameStep/AwaitingIFrameStep.js → AwaitingAccountStep/AwaitingAccountStep.js} +2 -2
  7. package/dist/modal/components/Body/Body.js +4 -4
  8. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +20 -1
  9. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +6 -3
  10. package/dist/modal/components/Header/hooks/useStepTitle.js +1 -1
  11. package/dist/modal/components/OAuth/FarcasterLink.d.ts +2 -0
  12. package/dist/modal/components/OAuth/FarcasterLink.js +30 -0
  13. package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -3
  14. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +47 -26
  15. package/dist/modal/components/OAuth/OAuth.js +2 -2
  16. package/dist/modal/components/OAuth/TelegramOAuthStep.js +2 -1
  17. package/dist/modal/constants/constants.js +1 -1
  18. package/dist/modal/hooks/useFarcasterLogin.d.ts +9 -0
  19. package/dist/modal/hooks/useFarcasterLogin.js +70 -0
  20. package/dist/modal/hooks/useTelegramLogin.d.ts +4 -3
  21. package/dist/modal/hooks/useTelegramLogin.js +11 -3
  22. package/dist/modal/stores/modal/useModalStore.js +2 -1
  23. package/dist/modal/utils/steps.d.ts +6 -3
  24. package/dist/modal/utils/steps.js +14 -8
  25. package/dist/provider/ParaProviderMin.js +3 -3
  26. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +3 -3
  27. package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +6 -3
  28. package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +3 -3
  29. package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +9 -6
  30. package/dist/provider/providers/AuthProvider.d.ts +4 -3
  31. package/dist/provider/providers/AuthProvider.js +102 -50
  32. package/dist/provider/providers/ExternalWalletProvider.d.ts +2 -0
  33. package/dist/provider/providers/ExternalWalletProvider.js +23 -4
  34. package/dist/provider/stores/useStore.js +2 -1
  35. package/dist/provider/types/provider.d.ts +1 -1
  36. package/dist/provider/utils/paraConfigTypeGuards.d.ts +1 -1
  37. package/dist/provider/utils/paraConfigTypeGuards.js +1 -1
  38. package/package.json +8 -8
  39. package/dist/modal/components/AwaitingIFrameStep/AwaitingIFrameStep.d.ts +0 -1
@@ -67,7 +67,7 @@ const ParaProviderMin = forwardRef(({ children, paraClientConfig, callbacks, con
67
67
  useEffect(() => {
68
68
  var _a, _b;
69
69
  if (includeWalletVerification !== (externalWalletConfig == null ? void 0 : externalWalletConfig.includeWalletVerification)) {
70
- if ((externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) || (isConfigType(paraClientConfig) ? (_a = paraClientConfig.opts) == null ? void 0 : _a.externalWalletConnectionOnly : paraClientConfig.externalWalletConnectionOnly)) {
70
+ if ((externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) || (isParaWeb(paraClientConfig) ? paraClientConfig.externalWalletConnectionOnly : (_a = paraClientConfig.opts) == null ? void 0 : _a.externalWalletConnectionOnly)) {
71
71
  console.warn("includeWalletVerification has no effect when using connection only external wallets");
72
72
  setIncludeWalletVerification(false);
73
73
  } else {
@@ -84,7 +84,7 @@ const ParaProviderMin = forwardRef(({ children, paraClientConfig, callbacks, con
84
84
  useEffect(() => {
85
85
  var _a, _b;
86
86
  if (externalWalletsWithFullAuth !== (externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets)) {
87
- if ((externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) || (isConfigType(paraClientConfig) ? (_a = paraClientConfig.opts) == null ? void 0 : _a.externalWalletConnectionOnly : paraClientConfig.externalWalletConnectionOnly)) {
87
+ if ((externalWalletConfig == null ? void 0 : externalWalletConfig.connectionOnly) || (isParaWeb(paraClientConfig) ? paraClientConfig.externalWalletConnectionOnly : (_a = paraClientConfig.opts) == null ? void 0 : _a.externalWalletConnectionOnly)) {
88
88
  console.warn("createLinkedEmbeddedForExternalWallets has no effect when using connection only external wallets");
89
89
  setExternalWalletsWithFullAuth([]);
90
90
  } else {
@@ -98,7 +98,7 @@ const ParaProviderMin = forwardRef(({ children, paraClientConfig, callbacks, con
98
98
  if (!isConfigType(paraClientConfig) && !isParaWeb(paraClientConfig)) {
99
99
  throw new Error("Invalid Para config");
100
100
  }
101
- const newClient = isConfigType(paraClientConfig) ? new ParaWeb(paraClientConfig.env, paraClientConfig.apiKey, paraClientConfig.opts) : paraClientConfig;
101
+ const newClient = isParaWeb(paraClientConfig) ? paraClientConfig : new ParaWeb(paraClientConfig.env, paraClientConfig.apiKey, paraClientConfig.opts);
102
102
  if (newClient.isReady) {
103
103
  setIsClientReady(true);
104
104
  } else {
@@ -16,7 +16,7 @@ export declare const SIGN_UP_LOG_IN_KEY = "SIGN_UP_LOG_IN";
16
16
  */
17
17
  export declare const useSignUpOrLogIn: () => {
18
18
  status: "error" | "idle" | "pending" | "success";
19
- data: Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/user-management-client").ServerAuthStateVerify> | undefined;
19
+ data: Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/web-sdk").AuthStateVerify> | undefined;
20
20
  isSuccess: boolean;
21
21
  variables: {
22
22
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
@@ -33,12 +33,12 @@ export declare const useSignUpOrLogIn: () => {
33
33
  failureReason: Error | null;
34
34
  isPaused: boolean;
35
35
  submittedAt: number;
36
- signUpOrLogIn: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/user-management-client").ServerAuthStateVerify>, Error, {
36
+ signUpOrLogIn: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/web-sdk").AuthStateVerify>, Error, {
37
37
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
38
38
  useShortUrls?: boolean | undefined;
39
39
  auth: import("@getpara/web-sdk").VerifiedAuth;
40
40
  }, unknown>;
41
- signUpOrLogInAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/user-management-client").ServerAuthStateVerify>, Error, {
41
+ signUpOrLogInAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/web-sdk").AuthStateLogin | import("@getpara/web-sdk").AuthStateVerify>, Error, {
42
42
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
43
43
  useShortUrls?: boolean | undefined;
44
44
  auth: import("@getpara/web-sdk").VerifiedAuth;
@@ -16,7 +16,7 @@ export declare const VERIFY_FARCASTER_KEY = "VERIFY_FARCASTER";
16
16
  */
17
17
  export declare const useVerifyFarcaster: () => {
18
18
  status: "error" | "idle" | "pending" | "success";
19
- data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin> | undefined;
19
+ data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
20
20
  isSuccess: boolean;
21
21
  variables: void | {
22
22
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
@@ -25,6 +25,7 @@ export declare const useVerifyFarcaster: () => {
25
25
  onCancel?: (() => void) | undefined;
26
26
  isCanceled?: (() => boolean) | undefined;
27
27
  onConnectUri?: ((uri: string) => void) | undefined;
28
+ serverAuthState?: import("@getpara/user-management-client").VerifyThirdPartyAuth | undefined;
28
29
  } | undefined;
29
30
  error: Error | null;
30
31
  isError: boolean;
@@ -36,20 +37,22 @@ export declare const useVerifyFarcaster: () => {
36
37
  failureReason: Error | null;
37
38
  isPaused: boolean;
38
39
  submittedAt: number;
39
- verifyFarcaster: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, void | {
40
+ verifyFarcaster: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, void | {
40
41
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
41
42
  useShortUrls?: boolean | undefined;
42
43
  onPoll?: (() => void) | undefined;
43
44
  onCancel?: (() => void) | undefined;
44
45
  isCanceled?: (() => boolean) | undefined;
45
46
  onConnectUri?: ((uri: string) => void) | undefined;
47
+ serverAuthState?: import("@getpara/user-management-client").VerifyThirdPartyAuth | undefined;
46
48
  }, unknown>;
47
- verifyFarcasterAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, void | {
49
+ verifyFarcasterAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, void | {
48
50
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
49
51
  useShortUrls?: boolean | undefined;
50
52
  onPoll?: (() => void) | undefined;
51
53
  onCancel?: (() => void) | undefined;
52
54
  isCanceled?: (() => boolean) | undefined;
53
55
  onConnectUri?: ((uri: string) => void) | undefined;
56
+ serverAuthState?: import("@getpara/user-management-client").VerifyThirdPartyAuth | undefined;
54
57
  }, unknown>;
55
58
  };
@@ -16,7 +16,7 @@ export declare const VERIFY_OAUTH_KEY = "VERIFY_OAUTH";
16
16
  */
17
17
  export declare const useVerifyOAuth: () => {
18
18
  status: "error" | "idle" | "pending" | "success";
19
- data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin> | undefined;
19
+ data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
20
20
  isSuccess: boolean;
21
21
  variables: {
22
22
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
@@ -39,7 +39,7 @@ export declare const useVerifyOAuth: () => {
39
39
  failureReason: Error | null;
40
40
  isPaused: boolean;
41
41
  submittedAt: number;
42
- verifyOAuth: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, {
42
+ verifyOAuth: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
43
43
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
44
44
  useShortUrls?: boolean | undefined;
45
45
  method: Exclude<import("@getpara/web-sdk").TOAuthMethod, "TELEGRAM" | "FARCASTER">;
@@ -50,7 +50,7 @@ export declare const useVerifyOAuth: () => {
50
50
  onOAuthUrl?: ((url: string) => void) | undefined;
51
51
  onOAuthPopup?: ((popup: Window) => void) | undefined;
52
52
  }, unknown>;
53
- verifyOAuthAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, {
53
+ verifyOAuthAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
54
54
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
55
55
  useShortUrls?: boolean | undefined;
56
56
  method: Exclude<import("@getpara/web-sdk").TOAuthMethod, "TELEGRAM" | "FARCASTER">;
@@ -16,12 +16,13 @@ export declare const VERIFY_TELEGRAM_KEY = "VERIFY_TELEGRAM";
16
16
  */
17
17
  export declare const useVerifyTelegram: () => {
18
18
  status: "error" | "idle" | "pending" | "success";
19
- data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin> | undefined;
19
+ data: Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone> | undefined;
20
20
  isSuccess: boolean;
21
21
  variables: {
22
22
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
23
23
  useShortUrls?: boolean | undefined;
24
- telegramAuthResponse: import("@getpara/web-sdk").TelegramAuthResponse;
24
+ telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
25
+ serverAuthState?: import("@getpara/user-management-client").VerifyThirdPartyAuth | undefined;
25
26
  } | undefined;
26
27
  error: Error | null;
27
28
  isError: boolean;
@@ -33,14 +34,16 @@ export declare const useVerifyTelegram: () => {
33
34
  failureReason: Error | null;
34
35
  isPaused: boolean;
35
36
  submittedAt: number;
36
- verifyTelegram: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, {
37
+ verifyTelegram: import("@tanstack/react-query").UseMutateFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
37
38
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
38
39
  useShortUrls?: boolean | undefined;
39
- telegramAuthResponse: import("@getpara/web-sdk").TelegramAuthResponse;
40
+ telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
41
+ serverAuthState?: import("@getpara/user-management-client").VerifyThirdPartyAuth | undefined;
40
42
  }, unknown>;
41
- verifyTelegramAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLogin>, Error, {
43
+ verifyTelegramAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Compute<import("@getpara/core-sdk/dist/types/types/methods.js").AuthStateSignupOrLoginOrDone>, Error, {
42
44
  portalTheme?: import("@getpara/web-sdk").Theme | undefined;
43
45
  useShortUrls?: boolean | undefined;
44
- telegramAuthResponse: import("@getpara/web-sdk").TelegramAuthResponse;
46
+ telegramAuthResponse?: import("@getpara/web-sdk").TelegramAuthResponse | undefined;
47
+ serverAuthState?: import("@getpara/user-management-client").VerifyThirdPartyAuth | undefined;
45
48
  }, unknown>;
46
49
  };
@@ -2,7 +2,7 @@ import { BiometricHints } from '@getpara/react-common';
2
2
  import { PropsWithChildren } from 'react';
3
3
  import { AuthMethod, CoreMethodParams, AuthState, AuthStateSignup, AuthStateLogin } from '@getpara/web-sdk';
4
4
  import { ParaModalProps } from '../../modal/types/modalProps.js';
5
- import { TelegramAuthResponse, VerifiedAuth } from '@getpara/user-management-client';
5
+ import { VerifiedAuth, VerifyThirdPartyAuth } from '@getpara/user-management-client';
6
6
  import { MutationStatus } from '@tanstack/react-query';
7
7
  type Value = {
8
8
  signUpOrLogIn: (_: VerifiedAuth) => void;
@@ -11,9 +11,10 @@ type Value = {
11
11
  verifyNewAccountStatus: MutationStatus;
12
12
  verifyNewAccountError: Error | null;
13
13
  verifyOAuth: (_: CoreMethodParams<'verifyOAuth'>['method']) => void;
14
- verifyFarcaster: () => void;
15
- verifyTelegram: (_: TelegramAuthResponse) => void;
14
+ verifyFarcaster: (_?: VerifyThirdPartyAuth) => void;
15
+ verifyTelegram: (_: VerifyThirdPartyAuth) => void;
16
16
  verifyTelegramStatus: MutationStatus;
17
+ verifyFarcasterStatus: MutationStatus;
17
18
  onNewAuthState: (_: AuthState) => void;
18
19
  presentSignupUi: (_: AuthMethod, __: AuthStateSignup) => void;
19
20
  presentLoginUi: (_: AuthMethod, __: AuthStateLogin) => void;
@@ -51,6 +51,7 @@ const AuthContext = createContext({
51
51
  verifyTelegram: () => {
52
52
  },
53
53
  verifyTelegramStatus: "idle",
54
+ verifyFarcasterStatus: "idle",
54
55
  onNewAuthState: () => {
55
56
  },
56
57
  isSetup2faPending: false,
@@ -103,7 +104,7 @@ function AuthProvider({
103
104
  error: verifyNewAccountError
104
105
  } = useVerifyNewAccount();
105
106
  const { verifyOAuth: mutateVerifyOAuth } = useVerifyOAuth();
106
- const { verifyFarcaster: mutateVerifyFarcaster } = useVerifyFarcaster();
107
+ const { verifyFarcaster: mutateVerifyFarcaster, status: verifyFarcasterStatus } = useVerifyFarcaster();
107
108
  const { verifyTelegram: mutateVerifyTelegram, status: verifyTelegramStatus } = useVerifyTelegram();
108
109
  const { waitForLogin: mutateWaitForLogin } = useWaitForLogin();
109
110
  const { waitForSignup: mutateWaitForSignup } = useWaitForSignup();
@@ -135,13 +136,13 @@ function AuthProvider({
135
136
  setAuthStepRoute();
136
137
  setIFrameUrl();
137
138
  setIsIFrameReady(false);
138
- setStep(ModalStep.AWAITING_IFRAME);
139
+ setStep(ModalStep.AWAITING_ACCOUNT);
139
140
  }
140
141
  window.removeEventListener("message", handleMessage);
141
142
  }
142
143
  });
143
144
  };
144
- const signup = () => {
145
+ const pollSignup = () => {
145
146
  if (typeof window !== "undefined") {
146
147
  refs.poll.current = {
147
148
  action: "signup",
@@ -152,10 +153,11 @@ function AuthProvider({
152
153
  ModalStep.BIOMETRIC_CREATION,
153
154
  ModalStep.AWAITING_BIOMETRIC_CREATION,
154
155
  ModalStep.PASSWORD_CREATION,
155
- ModalStep.AWAITING_IFRAME,
156
+ ModalStep.AWAITING_ACCOUNT,
156
157
  ModalStep.VERIFICATIONS,
157
158
  ModalStep.AWAITING_OAUTH,
158
- ModalStep.EXTERNAL_WALLET_VERIFICATION
159
+ ModalStep.EXTERNAL_WALLET_VERIFICATION,
160
+ ModalStep.OTP
159
161
  ]),
160
162
  onPoll: () => {
161
163
  goBackIfPopupClosedOnSteps([ModalStep.AWAITING_BIOMETRIC_CREATION]);
@@ -173,7 +175,7 @@ function AuthProvider({
173
175
  }
174
176
  },
175
177
  onError: () => {
176
- if (refs.currentStep.current && [ModalStep.AWAITING_BIOMETRIC_CREATION, ModalStep.PASSWORD_CREATION, ModalStep.AWAITING_IFRAME].includes(
178
+ if (refs.currentStep.current && [ModalStep.AWAITING_BIOMETRIC_CREATION, ModalStep.PASSWORD_CREATION, ModalStep.AWAITING_ACCOUNT].includes(
177
179
  refs.currentStep.current
178
180
  )) {
179
181
  goBack();
@@ -229,6 +231,23 @@ function AuthProvider({
229
231
  },
230
232
  [isIFrameReady]
231
233
  );
234
+ const presentVerifyUi = useCallback(
235
+ (method, authState) => {
236
+ switch (method) {
237
+ case AuthMethod.SLO:
238
+ setupListener();
239
+ if (isIFrameReady) {
240
+ setStep(ModalStep.OTP);
241
+ } else {
242
+ setIFrameUrl(authState.loginUrl);
243
+ setIsIFrameReady(false);
244
+ setAuthStepRoute(ModalStep.OTP);
245
+ }
246
+ break;
247
+ }
248
+ },
249
+ [isIFrameReady]
250
+ );
232
251
  const login = (authState) => {
233
252
  if (authState.isWalletSelectionNeeded || authState.passkeyUrl) {
234
253
  setStep(ModalStep.BIOMETRIC_LOGIN);
@@ -238,47 +257,54 @@ function AuthProvider({
238
257
  setIsIFrameReady(false);
239
258
  setStep(ModalStep.EMBEDDED_PASSWORD_LOGIN);
240
259
  }
241
- refs.poll.current = {
242
- action: "login",
243
- timeout: window == null ? void 0 : window.setTimeout(() => __async(this, null, function* () {
244
- mutateWaitForLogin(
245
- {
246
- isCanceled: () => cancelIfExitedSteps([
247
- ModalStep.BIOMETRIC_LOGIN,
248
- ModalStep.EMBEDDED_PASSWORD_LOGIN,
249
- ModalStep.AWAITING_BIOMETRIC_LOGIN,
250
- ModalStep.AWAITING_PASSWORD_LOGIN,
251
- ModalStep.AWAITING_IFRAME
252
- ]),
253
- onPoll: () => {
254
- goBackIfPopupClosedOnSteps([
260
+ pollLogin();
261
+ };
262
+ const pollLogin = () => {
263
+ if (typeof window !== "undefined") {
264
+ refs.poll.current = {
265
+ action: "login",
266
+ timeout: window == null ? void 0 : window.setTimeout(() => __async(this, null, function* () {
267
+ mutateWaitForLogin(
268
+ {
269
+ isCanceled: () => cancelIfExitedSteps([
270
+ ModalStep.BIOMETRIC_LOGIN,
271
+ ModalStep.EMBEDDED_PASSWORD_LOGIN,
255
272
  ModalStep.AWAITING_BIOMETRIC_LOGIN,
256
273
  ModalStep.AWAITING_PASSWORD_LOGIN,
257
- ModalStep.EMBEDDED_PASSWORD_LOGIN
258
- ]);
259
- }
260
- },
261
- {
262
- onSuccess: ({ needsWallet }) => {
263
- if (needsWallet && !para.isNoWalletConfig) {
264
- createWallets();
265
- } else {
266
- onLoginComplete({
267
- on2faSetupOrError: () => setStep(ModalStep.LOGIN_DONE),
268
- on2faNotSetup: () => setStep(ModalStep.SETUP_2FA)
269
- });
274
+ ModalStep.AWAITING_ACCOUNT,
275
+ ModalStep.OTP
276
+ ]),
277
+ onPoll: () => {
278
+ goBackIfPopupClosedOnSteps([
279
+ ModalStep.AWAITING_BIOMETRIC_LOGIN,
280
+ ModalStep.AWAITING_PASSWORD_LOGIN,
281
+ ModalStep.EMBEDDED_PASSWORD_LOGIN,
282
+ ModalStep.OTP
283
+ ]);
270
284
  }
271
285
  },
272
- onSettled: () => {
273
- var _a;
274
- window == null ? void 0 : window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
275
- refs.poll.current = null;
276
- refs.popupWindow.current = null;
286
+ {
287
+ onSuccess: ({ needsWallet }) => {
288
+ if (needsWallet && !para.isNoWalletConfig) {
289
+ createWallets();
290
+ } else {
291
+ onLoginComplete({
292
+ on2faSetupOrError: () => setStep(ModalStep.LOGIN_DONE),
293
+ on2faNotSetup: () => setStep(ModalStep.SETUP_2FA)
294
+ });
295
+ }
296
+ },
297
+ onSettled: () => {
298
+ var _a;
299
+ window == null ? void 0 : window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
300
+ refs.poll.current = null;
301
+ refs.popupWindow.current = null;
302
+ }
277
303
  }
278
- }
279
- );
280
- }), DEFAULTS.LOGGIN_POLLING_DELAY_MS)
281
- };
304
+ );
305
+ }), DEFAULTS.LOGGIN_POLLING_DELAY_MS)
306
+ };
307
+ }
282
308
  };
283
309
  const presentLoginUi = useCallback(
284
310
  (method, authState) => {
@@ -313,7 +339,20 @@ function AuthProvider({
313
339
  if (isExternalWallet(authState.auth) && authState.signatureVerificationMessage) {
314
340
  setStep(ModalStep.EXTERNAL_WALLET_VERIFICATION);
315
341
  } else {
316
- setStep(ModalStep.VERIFICATIONS);
342
+ if (authState.nextStage === "login") {
343
+ setFlow("login");
344
+ pollLogin();
345
+ } else {
346
+ setFlow("signup");
347
+ pollSignup();
348
+ }
349
+ if (authState.loginUrl) {
350
+ setIFrameUrl(authState.loginUrl);
351
+ setIsIFrameReady(false);
352
+ presentVerifyUi(AuthMethod.SLO, authState);
353
+ } else {
354
+ setStep(ModalStep.VERIFICATIONS);
355
+ }
317
356
  }
318
357
  break;
319
358
  case "login":
@@ -330,7 +369,7 @@ function AuthProvider({
330
369
  setIFrameUrl(authState.passwordUrl || authState.pinUrl);
331
370
  setIsIFrameReady(false);
332
371
  }
333
- signup();
372
+ pollSignup();
334
373
  if (isPasswordOrPINOnly) {
335
374
  presentSignupUi(isPassword ? AuthMethod.PASSWORD : AuthMethod.PIN, authState);
336
375
  } else {
@@ -338,6 +377,16 @@ function AuthProvider({
338
377
  }
339
378
  }
340
379
  break;
380
+ case "done":
381
+ if (authState.isNewUser) {
382
+ pollSignup();
383
+ setFlow("signup");
384
+ } else {
385
+ pollLogin();
386
+ setFlow("login");
387
+ }
388
+ setStep(ModalStep.AWAITING_ACCOUNT);
389
+ break;
341
390
  }
342
391
  });
343
392
  const signUpOrLogIn = (auth) => __async(this, null, function* () {
@@ -381,7 +430,7 @@ function AuthProvider({
381
430
  }
382
431
  );
383
432
  });
384
- const verifyFarcaster = () => __async(this, null, function* () {
433
+ const verifyFarcaster = (serverAuthState) => __async(this, null, function* () {
385
434
  setStep(ModalStep.FARCASTER_OAUTH);
386
435
  mutateVerifyFarcaster(
387
436
  {
@@ -390,7 +439,8 @@ function AuthProvider({
390
439
  setFarcasterConnectUri(connectUri);
391
440
  routeMobileExternalWallet(connectUri);
392
441
  },
393
- useShortUrls: true
442
+ useShortUrls: true,
443
+ serverAuthState
394
444
  },
395
445
  {
396
446
  onSuccess: onNewAuthState,
@@ -402,10 +452,10 @@ function AuthProvider({
402
452
  }
403
453
  );
404
454
  });
405
- const verifyTelegram = (telegramAuthResponse) => __async(this, null, function* () {
455
+ const verifyTelegram = (serverAuthState) => __async(this, null, function* () {
406
456
  mutateVerifyTelegram(
407
457
  {
408
- telegramAuthResponse,
458
+ serverAuthState,
409
459
  useShortUrls: true
410
460
  },
411
461
  {
@@ -511,7 +561,8 @@ function AuthProvider({
511
561
  createGuestWallets,
512
562
  isCreateGuestWalletsPending,
513
563
  logout,
514
- biometricHints: biometricHints || void 0
564
+ biometricHints: biometricHints || void 0,
565
+ verifyFarcasterStatus
515
566
  }),
516
567
  [
517
568
  presentSignupUi,
@@ -531,7 +582,8 @@ function AuthProvider({
531
582
  createGuestWallets,
532
583
  isCreateGuestWalletsPending,
533
584
  logout,
534
- biometricHints
585
+ biometricHints,
586
+ verifyFarcasterStatus
535
587
  ]
536
588
  );
537
589
  useEffect(() => {
@@ -34,6 +34,7 @@ export declare const defaultExternalWallet: {
34
34
  requestInfo: (_: string) => Promise<ExternalWalletInfo>;
35
35
  disconnectBase: (_: string, __: TWalletType) => Promise<void>;
36
36
  connectFarcasterMiniApp: () => Promise<void>;
37
+ verificationStage: undefined;
37
38
  };
38
39
  type Value = Omit<ExternalWalletContextType<CosmosSignResult>, 'disconnect' | 'signVerificationMessage' | 'requestInfo' | 'disconnectBase'> & ChainManagement<string, void> & BalanceManagement & {
39
40
  wallet?: CommonWallet;
@@ -55,6 +56,7 @@ type Value = Omit<ExternalWalletContextType<CosmosSignResult>, 'disconnect' | 's
55
56
  requestInfo: (_: string, __: TWalletType) => Promise<ExternalWalletInfo>;
56
57
  disconnectBase: (_: string, __: TWalletType) => Promise<void>;
57
58
  connectFarcasterMiniApp: () => Promise<void>;
59
+ verificationStage?: 'verifying' | 'switchingChain';
58
60
  };
59
61
  export declare const ExternalWalletContext: import("react").Context<Value>;
60
62
  export declare function ExternalWalletProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
@@ -47,7 +47,8 @@ const defaultExternalWallet = {
47
47
  getWalletBalance: () => Promise.resolve(void 0),
48
48
  requestInfo: (_) => Promise.resolve({}),
49
49
  disconnectBase: (_, __) => Promise.resolve(),
50
- connectFarcasterMiniApp: () => Promise.resolve()
50
+ connectFarcasterMiniApp: () => Promise.resolve(),
51
+ verificationStage: void 0
51
52
  };
52
53
  const ExternalWalletContext = createContext(defaultExternalWallet);
53
54
  function ExternalWalletProvider({ children }) {
@@ -76,7 +77,8 @@ function ExternalWalletProvider({ children }) {
76
77
  getWalletBalance: evmGetWalletBalance,
77
78
  requestInfo: evmRequestInfo,
78
79
  disconnectBase: evmDisconnectBase,
79
- farcasterStatus: evmFarcasterStatus
80
+ farcasterStatus: evmFarcasterStatus,
81
+ verificationStage: evmVerificationStage
80
82
  } = useContext(evmContext);
81
83
  const {
82
84
  wallets: solanaWallets,
@@ -187,6 +189,18 @@ function ExternalWalletProvider({ children }) {
187
189
  }
188
190
  }
189
191
  }, [cosmosChains, evmChains, selectedExternalWallet]);
192
+ const verificationStage = useMemo(() => {
193
+ var _a;
194
+ const walletType = (_a = Object.values(para.externalWallets || {})[0]) == null ? void 0 : _a.type;
195
+ switch (walletType) {
196
+ case "EVM": {
197
+ return evmVerificationStage;
198
+ }
199
+ default: {
200
+ return "verifying";
201
+ }
202
+ }
203
+ }, [selectedExternalWallet, evmVerificationStage]);
190
204
  const switchChain = useCallback(
191
205
  (chainId2) => __async(this, null, function* () {
192
206
  var _a;
@@ -245,6 +259,7 @@ function ExternalWalletProvider({ children }) {
245
259
  const { address, signature, error, cosmosPublicKeyHex, cosmosSigner, addressBech32 } = yield cosmosSignVerificationMessage();
246
260
  if (error) {
247
261
  setExternalWalletError([error]);
262
+ return;
248
263
  } else if (signature && address) {
249
264
  verifyExternalWalletParams = {
250
265
  externalWallet: __spreadValues({
@@ -265,6 +280,7 @@ function ExternalWalletProvider({ children }) {
265
280
  const { signature, error, address } = yield evmSignVerificationMessage();
266
281
  if (error) {
267
282
  setExternalWalletError([error]);
283
+ return;
268
284
  } else if (signature && address) {
269
285
  verifyExternalWalletParams = {
270
286
  externalWallet: __spreadValues({
@@ -282,6 +298,7 @@ function ExternalWalletProvider({ children }) {
282
298
  const { signature, error, address } = yield solanaSignVerificationMessage();
283
299
  if (error) {
284
300
  setExternalWalletError([error]);
301
+ return;
285
302
  } else if (signature && address) {
286
303
  verifyExternalWalletParams = {
287
304
  externalWallet: __spreadValues({
@@ -585,7 +602,8 @@ function ExternalWalletProvider({ children }) {
585
602
  getWalletBalance,
586
603
  requestInfo,
587
604
  disconnectBase,
588
- connectFarcasterMiniApp
605
+ connectFarcasterMiniApp,
606
+ verificationStage
589
607
  }),
590
608
  [
591
609
  wallets,
@@ -608,7 +626,8 @@ function ExternalWalletProvider({ children }) {
608
626
  getWalletBalance,
609
627
  requestInfo,
610
628
  disconnectBase,
611
- connectFarcasterMiniApp
629
+ connectFarcasterMiniApp,
630
+ verificationStage
612
631
  ]
613
632
  ),
614
633
  children
@@ -12,12 +12,13 @@ import {
12
12
  } from "./slices/index.js";
13
13
  import { createJSONStorage, persist } from "zustand/middleware";
14
14
  import { createConfigSlice } from "./slices/config.js";
15
+ import { PARA_STORAGE_PREFIX } from "@getpara/core-sdk";
15
16
  const vanillaStore = createStore()(
16
17
  persist(
17
18
  (...a) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, createClientSlice(...a)), createModalSlice(...a)), createWalletSlice(...a)), createExternalWalletsSlice(...a)), createConfigSlice(...a)), createAnalyticsSlice(...a)),
18
19
  {
19
20
  version: 1,
20
- name: "@PARA/provider-state",
21
+ name: `${PARA_STORAGE_PREFIX}provider-state`,
21
22
  storage: createJSONStorage(() => localStorage),
22
23
  partialize: (state) => ({
23
24
  selectedWalletId: state.selectedWalletId,
@@ -138,7 +138,7 @@ export interface ParaProviderProps<chains extends readonly [Chain, ...Chain[]],
138
138
  /**
139
139
  * Environment for your Para instance.
140
140
  */
141
- env: Environment;
141
+ env?: Environment;
142
142
  /**
143
143
  * API key for you Para instance.
144
144
  *
@@ -1,7 +1,7 @@
1
1
  import ParaWeb, { ConstructorOpts, Environment } from '@getpara/web-sdk';
2
2
  export declare function isConfigType(obj: any): obj is {
3
- env: Environment;
4
3
  apiKey: string;
4
+ env: Environment | undefined;
5
5
  opts?: ConstructorOpts;
6
6
  };
7
7
  export declare function isParaWeb(obj: any): obj is ParaWeb;
@@ -2,7 +2,7 @@
2
2
  import "../../chunk-MMUBH76A.js";
3
3
  import ParaWeb from "@getpara/web-sdk";
4
4
  function isConfigType(obj) {
5
- return !!obj && typeof obj === "object" && "env" in obj && "apiKey" in obj;
5
+ return !!obj && typeof obj === "object" && "apiKey" in obj;
6
6
  }
7
7
  function isParaWeb(obj) {
8
8
  return obj instanceof ParaWeb;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk-lite",
3
- "version": "2.0.0-dev.5",
3
+ "version": "2.0.0-dev.6",
4
4
  "bin": {
5
5
  "setup-para": "dist/cli/cli.mjs"
6
6
  },
7
7
  "dependencies": {
8
- "@getpara/react-common": "2.0.0-alpha.43",
9
- "@getpara/react-components": "2.0.0-alpha.43",
10
- "@getpara/web-sdk": "2.0.0-alpha.43",
8
+ "@getpara/react-common": "2.0.0-dev.6",
9
+ "@getpara/react-components": "2.0.0-dev.6",
10
+ "@getpara/web-sdk": "2.0.0-dev.6",
11
11
  "date-fns": "^3.6.0",
12
12
  "framer-motion": "^11.3.31",
13
13
  "libphonenumber-js": "^1.11.7",
@@ -16,9 +16,9 @@
16
16
  "zustand-sync-tabs": "^0.2.2"
17
17
  },
18
18
  "devDependencies": {
19
- "@getpara/cosmos-wallet-connectors": "2.0.0-alpha.43",
20
- "@getpara/evm-wallet-connectors": "2.0.0-alpha.43",
21
- "@getpara/solana-wallet-connectors": "2.0.0-alpha.43",
19
+ "@getpara/cosmos-wallet-connectors": "2.0.0-dev.6",
20
+ "@getpara/evm-wallet-connectors": "2.0.0-dev.6",
21
+ "@getpara/solana-wallet-connectors": "2.0.0-dev.6",
22
22
  "@tanstack/react-query": "^5.74.0",
23
23
  "@testing-library/dom": "^10.4.0",
24
24
  "@testing-library/react": "^16.3.0",
@@ -38,7 +38,7 @@
38
38
  "package.json",
39
39
  "styles.css"
40
40
  ],
41
- "gitHead": "e6e791d4e4f9afd94f2093d6045d686b85e5a682",
41
+ "gitHead": "c2125e37c73a19f11978031f5aa2eab39b978c56",
42
42
  "main": "dist/index.js",
43
43
  "peerDependencies": {
44
44
  "@tanstack/react-query": ">=5.0.0",
@@ -1 +0,0 @@
1
- export declare const AwaitingIFrameStep: () => import("react/jsx-runtime").JSX.Element;