@getpara/react-core 3.25.0 → 3.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/mutations.d.ts +1 -0
- package/dist/mutations.js +2 -0
- package/dist/provider/ParaProviderCore.d.ts +7 -1
- package/dist/provider/ParaProviderCore.js +20 -8
- package/dist/provider/actions/index.d.ts +2 -1
- package/dist/provider/actions/index.js +2 -0
- package/dist/provider/hooks/mutations/index.d.ts +1 -0
- package/dist/provider/hooks/mutations/index.js +3 -0
- package/dist/provider/hooks/mutations/useSigningDelegation.d.ts +80 -0
- package/dist/provider/hooks/mutations/useSigningDelegation.js +39 -0
- package/dist/provider/hooks/queries/useParaStatus.d.ts +3 -1
- package/dist/provider/hooks/queries/useParaStatus.js +3 -2
- package/dist/provider/utils/clientConfigEquality.d.ts +22 -0
- package/dist/provider/utils/clientConfigEquality.js +26 -0
- package/package.json +19 -19
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export { useIssueJwt } from './provider/hooks/mutations/useIssueJwt.js';
|
|
|
30
30
|
export { useResendVerificationCode } from './provider/hooks/mutations/useResendVerificationCode.js';
|
|
31
31
|
export { useExportPrivateKey, EXPORT_PRIVATE_KEY_KEY } from './provider/hooks/mutations/useExportPrivateKey.js';
|
|
32
32
|
export { useRequestFaucet, REQUEST_FAUCET_KEY } from './provider/hooks/mutations/useRequestFaucet.js';
|
|
33
|
+
export { useSigningDelegation, REQUEST_SIGNING_DELEGATION_KEY } from './provider/hooks/mutations/useSigningDelegation.js';
|
|
33
34
|
export { useAuthenticateWithEmailOrPhone } from './provider/hooks/mutations/useAuthenticateWithEmailOrPhone.js';
|
|
34
35
|
export { useAuthenticateWithOAuth } from './provider/hooks/mutations/useAuthenticateWithOAuth.js';
|
|
35
36
|
export { useAuthenticateWithCustomOAuth } from './provider/hooks/mutations/useAuthenticateWithCustomOAuth.js';
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ import { useIssueJwt } from "./provider/hooks/mutations/useIssueJwt.js";
|
|
|
28
28
|
import { useResendVerificationCode } from "./provider/hooks/mutations/useResendVerificationCode.js";
|
|
29
29
|
import { useExportPrivateKey, EXPORT_PRIVATE_KEY_KEY } from "./provider/hooks/mutations/useExportPrivateKey.js";
|
|
30
30
|
import { useRequestFaucet, REQUEST_FAUCET_KEY } from "./provider/hooks/mutations/useRequestFaucet.js";
|
|
31
|
+
import { useSigningDelegation, REQUEST_SIGNING_DELEGATION_KEY } from "./provider/hooks/mutations/useSigningDelegation.js";
|
|
31
32
|
import { useAuthenticateWithEmailOrPhone } from "./provider/hooks/mutations/useAuthenticateWithEmailOrPhone.js";
|
|
32
33
|
import { useAuthenticateWithOAuth } from "./provider/hooks/mutations/useAuthenticateWithOAuth.js";
|
|
33
34
|
import { useAuthenticateWithCustomOAuth } from "./provider/hooks/mutations/useAuthenticateWithCustomOAuth.js";
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
ChainId,
|
|
47
48
|
EXPORT_PRIVATE_KEY_KEY,
|
|
48
49
|
REQUEST_FAUCET_KEY,
|
|
50
|
+
REQUEST_SIGNING_DELEGATION_KEY,
|
|
49
51
|
useAccount,
|
|
50
52
|
useAuthenticateWithCustomOAuth,
|
|
51
53
|
useAuthenticateWithEmailOrPhone,
|
|
@@ -74,6 +76,7 @@ export {
|
|
|
74
76
|
useSignMessage,
|
|
75
77
|
useSignTransaction,
|
|
76
78
|
useSignUpOrLogIn,
|
|
79
|
+
useSigningDelegation,
|
|
77
80
|
useUpdatePregenWalletIdentifier,
|
|
78
81
|
useVerify2fa,
|
|
79
82
|
useVerifyExternalWallet,
|
package/dist/mutations.d.ts
CHANGED
|
@@ -31,4 +31,5 @@ export { useWaitForSignup } from './provider/hooks/mutations/useWaitForSignup.js
|
|
|
31
31
|
export { useWaitForWalletCreation } from './provider/hooks/mutations/useWaitForWalletCreation.js';
|
|
32
32
|
export { useExportPrivateKey } from './provider/hooks/mutations/useExportPrivateKey.js';
|
|
33
33
|
export { useRequestFaucet } from './provider/hooks/mutations/useRequestFaucet.js';
|
|
34
|
+
export { useSigningDelegation } from './provider/hooks/mutations/useSigningDelegation.js';
|
|
34
35
|
export * from './provider/hooks/permissions/mutations.js';
|
package/dist/mutations.js
CHANGED
|
@@ -31,6 +31,7 @@ import { useWaitForSignup } from "./provider/hooks/mutations/useWaitForSignup.js
|
|
|
31
31
|
import { useWaitForWalletCreation } from "./provider/hooks/mutations/useWaitForWalletCreation.js";
|
|
32
32
|
import { useExportPrivateKey } from "./provider/hooks/mutations/useExportPrivateKey.js";
|
|
33
33
|
import { useRequestFaucet } from "./provider/hooks/mutations/useRequestFaucet.js";
|
|
34
|
+
import { useSigningDelegation } from "./provider/hooks/mutations/useSigningDelegation.js";
|
|
34
35
|
export * from "./provider/hooks/permissions/mutations.js";
|
|
35
36
|
export {
|
|
36
37
|
useAuthenticateWithCustomOAuth,
|
|
@@ -56,6 +57,7 @@ export {
|
|
|
56
57
|
useSignMessage,
|
|
57
58
|
useSignTransaction,
|
|
58
59
|
useSignUpOrLogIn,
|
|
60
|
+
useSigningDelegation,
|
|
59
61
|
useUpdatePregenWalletIdentifier,
|
|
60
62
|
useVerify2fa,
|
|
61
63
|
useVerifyExternalWallet,
|
|
@@ -72,6 +72,12 @@ export interface ParaProviderBaseProps<TClient extends ParaCore = ParaCore, TCon
|
|
|
72
72
|
* When omitted, nothing is rendered until ready.
|
|
73
73
|
*/
|
|
74
74
|
fallback?: React.ReactNode;
|
|
75
|
+
/**
|
|
76
|
+
* Content to render instead of `fallback` when SDK setup fails before the SDK becomes ready
|
|
77
|
+
* (for example, the API key is rejected). Pass a function to render from the setup error.
|
|
78
|
+
* When omitted, `fallback` keeps rendering for a rejected key.
|
|
79
|
+
*/
|
|
80
|
+
errorFallback?: React.ReactNode | ((error: Error) => React.ReactNode);
|
|
75
81
|
}
|
|
76
82
|
/** @internal Props for ParaProviderCore. Consumers should not use this directly. */
|
|
77
83
|
export interface ParaProviderCoreProps<TClient extends ParaCore = ParaCore> extends Omit<ParaProviderBaseProps<TClient>, 'paraClientConfig'> {
|
|
@@ -92,4 +98,4 @@ export interface ParaProviderCoreProps<TClient extends ParaCore = ParaCore> exte
|
|
|
92
98
|
* a `createClient` factory. Platform SDKs wrap this and add platform-specific
|
|
93
99
|
* providers on top.
|
|
94
100
|
*/
|
|
95
|
-
export declare function ParaProviderCore<TClient extends ParaCore = ParaCore>({ children, paraClientConfig: paraClientInput, config, callbacks, configureClient, storageAdapter, store: externalStore, waitForReady, fallback, }: ParaProviderCoreProps<TClient>): import("react/jsx-runtime").JSX.Element;
|
|
101
|
+
export declare function ParaProviderCore<TClient extends ParaCore = ParaCore>({ children, paraClientConfig: paraClientInput, config, callbacks, configureClient, storageAdapter, store: externalStore, waitForReady, fallback, errorFallback, }: ParaProviderCoreProps<TClient>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
|
|
|
3
3
|
import { onParaEvent, ParaEvent } from "@getpara/core-sdk";
|
|
4
4
|
import { CoreStoreContext, useCoreStore } from "./stores/CoreStoreContext.js";
|
|
5
5
|
import { createCoreStore } from "./stores/createCoreStore.js";
|
|
6
|
+
import { isSameClientConfig } from "./utils/clientConfigEquality.js";
|
|
6
7
|
const EVENT_TO_CALLBACK = {
|
|
7
8
|
[ParaEvent.LOGIN_EVENT]: "onLogin",
|
|
8
9
|
[ParaEvent.LOGOUT_EVENT]: "onLogout",
|
|
@@ -17,7 +18,12 @@ const DEFAULT_PROVIDER_CONFIG = {};
|
|
|
17
18
|
function isClientConfig(v) {
|
|
18
19
|
return typeof v === "object" && v !== null && "createClient" in v;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
function isSameClientInput(prev, next) {
|
|
22
|
+
if (prev === next) return true;
|
|
23
|
+
if (!prev || !isClientConfig(prev) || !isClientConfig(next)) return false;
|
|
24
|
+
return isSameClientConfig(prev, next);
|
|
25
|
+
}
|
|
26
|
+
const ParaProviderCoreInner = ({ children, paraClientConfig: paraClient, config, callbacks, waitForReady, fallback, errorFallback }) => {
|
|
21
27
|
var _a, _b, _c, _d;
|
|
22
28
|
const unsubRef = useRef(null);
|
|
23
29
|
const setClient = useCoreStore((state) => state.setClient);
|
|
@@ -55,16 +61,16 @@ const ParaProviderCoreInner = ({ children, paraClientConfig: paraClient, config,
|
|
|
55
61
|
if (((_a2 = initRef.current) == null ? void 0 : _a2.client) !== client) {
|
|
56
62
|
initRef.current = { client, promise: client.init() };
|
|
57
63
|
}
|
|
58
|
-
|
|
64
|
+
const subscribe = () => {
|
|
59
65
|
if (cancelled) return;
|
|
60
|
-
|
|
66
|
+
unsubRef.current = client.onStatePhaseChange((snapshot) => {
|
|
61
67
|
setParaState(snapshot);
|
|
62
68
|
});
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
};
|
|
70
|
+
void initRef.current.promise.then(subscribe).catch((error) => {
|
|
65
71
|
if (cancelled) return;
|
|
66
|
-
setParaState(client.getCurrentState());
|
|
67
72
|
console.error(error);
|
|
73
|
+
subscribe();
|
|
68
74
|
});
|
|
69
75
|
return () => {
|
|
70
76
|
var _a3;
|
|
@@ -91,6 +97,10 @@ const ParaProviderCoreInner = ({ children, paraClientConfig: paraClient, config,
|
|
|
91
97
|
return /* @__PURE__ */ jsx(Fragment, { children: fallback != null ? fallback : null });
|
|
92
98
|
}
|
|
93
99
|
if (waitForReady && !isReady) {
|
|
100
|
+
const setupError = paraState == null ? void 0 : paraState.error;
|
|
101
|
+
if (setupError && errorFallback !== void 0) {
|
|
102
|
+
return /* @__PURE__ */ jsx(Fragment, { children: typeof errorFallback === "function" ? errorFallback(setupError) : errorFallback });
|
|
103
|
+
}
|
|
94
104
|
return /* @__PURE__ */ jsx(Fragment, { children: fallback != null ? fallback : null });
|
|
95
105
|
}
|
|
96
106
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
@@ -104,7 +114,8 @@ function ParaProviderCore({
|
|
|
104
114
|
storageAdapter,
|
|
105
115
|
store: externalStore,
|
|
106
116
|
waitForReady = true,
|
|
107
|
-
fallback
|
|
117
|
+
fallback,
|
|
118
|
+
errorFallback
|
|
108
119
|
}) {
|
|
109
120
|
const store = useMemo(
|
|
110
121
|
() => externalStore != null ? externalStore : createCoreStore({ storage: storageAdapter }),
|
|
@@ -117,7 +128,7 @@ function ParaProviderCore({
|
|
|
117
128
|
configureClientRef.current = configureClient;
|
|
118
129
|
useEffect(() => {
|
|
119
130
|
var _a, _b;
|
|
120
|
-
if (((_a = clientResolutionRef.current) == null ? void 0 : _a.input
|
|
131
|
+
if (!isSameClientInput((_a = clientResolutionRef.current) == null ? void 0 : _a.input, paraClientInput)) {
|
|
121
132
|
const client2 = isClientConfig(paraClientInput) ? paraClientInput.createClient(paraClientInput.apiKey, paraClientInput.env, paraClientInput.opts) : paraClientInput;
|
|
122
133
|
clientResolutionRef.current = { input: paraClientInput, client: client2 };
|
|
123
134
|
}
|
|
@@ -139,6 +150,7 @@ function ParaProviderCore({
|
|
|
139
150
|
callbacks,
|
|
140
151
|
waitForReady,
|
|
141
152
|
fallback,
|
|
153
|
+
errorFallback,
|
|
142
154
|
children
|
|
143
155
|
}
|
|
144
156
|
) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type ParaCore from '@getpara/core-sdk';
|
|
2
|
-
import type { SignUpOrLogInParams, SignUpOrLogInResponse, WaitForLoginParams, WaitForLoginResponse, WaitForSignupParams, WaitForWalletCreationParams, WaitForWalletCreationResponse, VerifyOAuthProcessParams, OAuthResponse, VerifyFarcasterParams, VerifyTelegramParams, LoginExternalWalletParams, LoginExternalWalletResponse, VerifyExternalWalletParams, VerifyExternalWalletResponse, Setup2faResponse, Enable2faParams, Verify2faParams, Verify2faResponse, TwoFactorEnrollResponse, VerifyMfaParams, EnrollMfaParams, VerifyMfaResult, LogoutParams, ResendVerificationCodeParams, ResendVerificationCodeResponse, CreateWalletParams, CreateWalletResponse, CreateWalletPerTypeParams, CreateWalletPerTypeResponse, CreatePregenWalletParams, CreatePregenWalletResponse, CreatePregenWalletPerTypeParams, CreatePregenWalletPerTypeResponse, ClaimPregenWalletsParams, ClaimPregenWalletsResponse, HasPregenWalletParams, UpdatePregenWalletIdentifierParams, CreateGuestWalletsResponse, SignMessageParams, SignTransactionParams, FullSignatureRes, GetWalletBalanceParams, IssueJwtParams, IssueJwtResponse, GetLinkedAccountsParams, GetLinkedAccountsResponse, GetAuthFactorsResponse, AddAuthFactorParams, AddAuthFactorResponse, AddOAuthFactorParams, AddOAuthFactorResponse, AddExternalWalletFactorParams, AddExternalWalletFactorResponse, ContinueAuthFactorLinkParams, ContinueAuthFactorLinkResponse, UnlinkAuthFactorParams, AddCredentialParams, ExportPrivateKeyParams, ExportPrivateKeyResponse, RequestFaucetParams, RequestFaucetResponse, AuthenticateWithEmailOrPhoneParams, AuthenticateWithEmailOrPhoneResponse, AuthenticateWithOAuthParams, AuthenticateWithOAuthResponse, AuthenticateWithCustomOAuthParams, AuthenticateWithCustomOAuthResponse } from '@getpara/core-sdk';
|
|
2
|
+
import type { SignUpOrLogInParams, SignUpOrLogInResponse, WaitForLoginParams, WaitForLoginResponse, WaitForSignupParams, WaitForWalletCreationParams, WaitForWalletCreationResponse, VerifyOAuthProcessParams, OAuthResponse, VerifyFarcasterParams, VerifyTelegramParams, LoginExternalWalletParams, LoginExternalWalletResponse, VerifyExternalWalletParams, VerifyExternalWalletResponse, Setup2faResponse, Enable2faParams, Verify2faParams, Verify2faResponse, TwoFactorEnrollResponse, VerifyMfaParams, EnrollMfaParams, VerifyMfaResult, LogoutParams, ResendVerificationCodeParams, ResendVerificationCodeResponse, CreateWalletParams, CreateWalletResponse, CreateWalletPerTypeParams, CreateWalletPerTypeResponse, CreatePregenWalletParams, CreatePregenWalletResponse, CreatePregenWalletPerTypeParams, CreatePregenWalletPerTypeResponse, ClaimPregenWalletsParams, ClaimPregenWalletsResponse, HasPregenWalletParams, UpdatePregenWalletIdentifierParams, CreateGuestWalletsResponse, SignMessageParams, SignTransactionParams, FullSignatureRes, GetWalletBalanceParams, IssueJwtParams, IssueJwtResponse, GetLinkedAccountsParams, GetLinkedAccountsResponse, GetAuthFactorsResponse, AddAuthFactorParams, AddAuthFactorResponse, AddOAuthFactorParams, AddOAuthFactorResponse, AddExternalWalletFactorParams, AddExternalWalletFactorResponse, ContinueAuthFactorLinkParams, ContinueAuthFactorLinkResponse, UnlinkAuthFactorParams, AddCredentialParams, ExportPrivateKeyParams, ExportPrivateKeyResponse, RequestFaucetParams, RequestFaucetResponse, AuthenticateWithEmailOrPhoneParams, AuthenticateWithEmailOrPhoneResponse, AuthenticateWithOAuthParams, AuthenticateWithOAuthResponse, AuthenticateWithCustomOAuthParams, AuthenticateWithCustomOAuthResponse, RequestSigningDelegationParams, SigningDelegationConsentOutcome } from '@getpara/core-sdk';
|
|
3
3
|
export { generateCoreAction, type CoreAction } from './utils.js';
|
|
4
4
|
export { getEmbeddedAccount, type EmbeddedAccount } from './getEmbeddedAccount.js';
|
|
5
5
|
export { getWallet } from './getWallet.js';
|
|
@@ -42,6 +42,7 @@ export declare const continueAuthFactorLink: (para?: ParaCore, args?: ContinueAu
|
|
|
42
42
|
export declare const unlinkAuthFactor: (para?: ParaCore, args?: UnlinkAuthFactorParams) => Promise<GetAuthFactorsResponse>;
|
|
43
43
|
export declare const addCredential: (para?: ParaCore, args?: AddCredentialParams) => Promise<string>;
|
|
44
44
|
export declare const exportPrivateKey: (para?: ParaCore, args?: ExportPrivateKeyParams) => Promise<ExportPrivateKeyResponse>;
|
|
45
|
+
export declare const requestSigningDelegation: (para?: ParaCore, args?: RequestSigningDelegationParams) => Promise<SigningDelegationConsentOutcome>;
|
|
45
46
|
export declare const requestFaucet: (para?: ParaCore, args?: RequestFaucetParams) => Promise<RequestFaucetResponse>;
|
|
46
47
|
export declare const authenticateWithEmailOrPhone: (para?: ParaCore, args?: AuthenticateWithEmailOrPhoneParams) => Promise<AuthenticateWithEmailOrPhoneResponse>;
|
|
47
48
|
export declare const authenticateWithOAuth: (para?: ParaCore, args?: AuthenticateWithOAuthParams) => Promise<AuthenticateWithOAuthResponse>;
|
|
@@ -41,6 +41,7 @@ const continueAuthFactorLink = generateCoreAction("continueAuthFactorLink");
|
|
|
41
41
|
const unlinkAuthFactor = generateCoreAction("unlinkAuthFactor");
|
|
42
42
|
const addCredential = generateCoreAction("addCredential");
|
|
43
43
|
const exportPrivateKey = generateCoreAction("exportPrivateKey");
|
|
44
|
+
const requestSigningDelegation = generateCoreAction("requestSigningDelegation");
|
|
44
45
|
const requestFaucet = generateCoreAction("requestFaucet");
|
|
45
46
|
const authenticateWithEmailOrPhone = generateCoreAction("authenticateWithEmailOrPhone");
|
|
46
47
|
const authenticateWithOAuth = generateCoreAction("authenticateWithOAuth");
|
|
@@ -76,6 +77,7 @@ export {
|
|
|
76
77
|
loginExternalWallet,
|
|
77
78
|
logout,
|
|
78
79
|
requestFaucet,
|
|
80
|
+
requestSigningDelegation,
|
|
79
81
|
resendVerificationCode,
|
|
80
82
|
setup2fa,
|
|
81
83
|
signMessage,
|
|
@@ -21,6 +21,7 @@ export { useIssueJwt, ISSUE_JWT_KEY } from './useIssueJwt.js';
|
|
|
21
21
|
export { useResendVerificationCode, RESEND_VERIFICATION_CODE_KEY } from './useResendVerificationCode.js';
|
|
22
22
|
export { useExportPrivateKey, EXPORT_PRIVATE_KEY_KEY } from './useExportPrivateKey.js';
|
|
23
23
|
export { useRequestFaucet, REQUEST_FAUCET_KEY } from './useRequestFaucet.js';
|
|
24
|
+
export { useSigningDelegation, REQUEST_SIGNING_DELEGATION_KEY } from './useSigningDelegation.js';
|
|
24
25
|
export { useAuthenticateWithEmailOrPhone, AUTHENTICATE_EMAIL_OR_PHONE_KEY } from './useAuthenticateWithEmailOrPhone.js';
|
|
25
26
|
export { useAuthenticateWithOAuth, AUTHENTICATE_OAUTH_KEY } from './useAuthenticateWithOAuth.js';
|
|
26
27
|
export { useAuthenticateWithCustomOAuth, AUTHENTICATE_CUSTOM_OAUTH_KEY } from './useAuthenticateWithCustomOAuth.js';
|
|
@@ -21,6 +21,7 @@ import { useIssueJwt, ISSUE_JWT_KEY } from "./useIssueJwt.js";
|
|
|
21
21
|
import { useResendVerificationCode, RESEND_VERIFICATION_CODE_KEY } from "./useResendVerificationCode.js";
|
|
22
22
|
import { useExportPrivateKey, EXPORT_PRIVATE_KEY_KEY } from "./useExportPrivateKey.js";
|
|
23
23
|
import { useRequestFaucet, REQUEST_FAUCET_KEY } from "./useRequestFaucet.js";
|
|
24
|
+
import { useSigningDelegation, REQUEST_SIGNING_DELEGATION_KEY } from "./useSigningDelegation.js";
|
|
24
25
|
import { useAuthenticateWithEmailOrPhone, AUTHENTICATE_EMAIL_OR_PHONE_KEY } from "./useAuthenticateWithEmailOrPhone.js";
|
|
25
26
|
import { useAuthenticateWithOAuth, AUTHENTICATE_OAUTH_KEY } from "./useAuthenticateWithOAuth.js";
|
|
26
27
|
import { useAuthenticateWithCustomOAuth, AUTHENTICATE_CUSTOM_OAUTH_KEY } from "./useAuthenticateWithCustomOAuth.js";
|
|
@@ -52,6 +53,7 @@ export {
|
|
|
52
53
|
LOGIN_EXTERNAL_WALLET_KEY,
|
|
53
54
|
LOGOUT_KEY,
|
|
54
55
|
REQUEST_FAUCET_KEY,
|
|
56
|
+
REQUEST_SIGNING_DELEGATION_KEY,
|
|
55
57
|
RESEND_VERIFICATION_CODE_KEY,
|
|
56
58
|
SETUP_2FA_KEY,
|
|
57
59
|
SIGN_MESSAGE_KEY,
|
|
@@ -91,6 +93,7 @@ export {
|
|
|
91
93
|
useSignMessage,
|
|
92
94
|
useSignTransaction,
|
|
93
95
|
useSignUpOrLogIn,
|
|
96
|
+
useSigningDelegation,
|
|
94
97
|
useUpdatePregenWalletIdentifier,
|
|
95
98
|
useVerify2fa,
|
|
96
99
|
useVerifyExternalWallet,
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { RequestSigningDelegationParams, SigningDelegationConsentOutcome } from '@getpara/core-sdk';
|
|
2
|
+
export declare const REQUEST_SIGNING_DELEGATION_KEY = "REQUEST_SIGNING_DELEGATION";
|
|
3
|
+
/** Opens Para Portal and resolves when the user grants or declines signing delegation. */
|
|
4
|
+
export declare const useSigningDelegation: () => {
|
|
5
|
+
data: undefined;
|
|
6
|
+
variables: undefined;
|
|
7
|
+
error: null;
|
|
8
|
+
isError: false;
|
|
9
|
+
isIdle: true;
|
|
10
|
+
isPending: false;
|
|
11
|
+
isSuccess: false;
|
|
12
|
+
status: "idle";
|
|
13
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
14
|
+
reset: () => void;
|
|
15
|
+
context: unknown;
|
|
16
|
+
failureCount: number;
|
|
17
|
+
failureReason: Error;
|
|
18
|
+
isPaused: boolean;
|
|
19
|
+
submittedAt: number;
|
|
20
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
21
|
+
requestSigningDelegation: import("@tanstack/react-query").UseMutateFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
22
|
+
requestSigningDelegationAsync: import("@tanstack/react-query").UseMutateAsyncFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
23
|
+
} | {
|
|
24
|
+
data: undefined;
|
|
25
|
+
variables: RequestSigningDelegationParams;
|
|
26
|
+
error: null;
|
|
27
|
+
isError: false;
|
|
28
|
+
isIdle: false;
|
|
29
|
+
isPending: true;
|
|
30
|
+
isSuccess: false;
|
|
31
|
+
status: "pending";
|
|
32
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
33
|
+
reset: () => void;
|
|
34
|
+
context: unknown;
|
|
35
|
+
failureCount: number;
|
|
36
|
+
failureReason: Error;
|
|
37
|
+
isPaused: boolean;
|
|
38
|
+
submittedAt: number;
|
|
39
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
40
|
+
requestSigningDelegation: import("@tanstack/react-query").UseMutateFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
41
|
+
requestSigningDelegationAsync: import("@tanstack/react-query").UseMutateAsyncFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
42
|
+
} | {
|
|
43
|
+
data: undefined;
|
|
44
|
+
error: Error;
|
|
45
|
+
variables: RequestSigningDelegationParams;
|
|
46
|
+
isError: true;
|
|
47
|
+
isIdle: false;
|
|
48
|
+
isPending: false;
|
|
49
|
+
isSuccess: false;
|
|
50
|
+
status: "error";
|
|
51
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
52
|
+
reset: () => void;
|
|
53
|
+
context: unknown;
|
|
54
|
+
failureCount: number;
|
|
55
|
+
failureReason: Error;
|
|
56
|
+
isPaused: boolean;
|
|
57
|
+
submittedAt: number;
|
|
58
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
59
|
+
requestSigningDelegation: import("@tanstack/react-query").UseMutateFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
60
|
+
requestSigningDelegationAsync: import("@tanstack/react-query").UseMutateAsyncFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
61
|
+
} | {
|
|
62
|
+
data: SigningDelegationConsentOutcome;
|
|
63
|
+
error: null;
|
|
64
|
+
variables: RequestSigningDelegationParams;
|
|
65
|
+
isError: false;
|
|
66
|
+
isIdle: false;
|
|
67
|
+
isPending: false;
|
|
68
|
+
isSuccess: true;
|
|
69
|
+
status: "success";
|
|
70
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
71
|
+
reset: () => void;
|
|
72
|
+
context: unknown;
|
|
73
|
+
failureCount: number;
|
|
74
|
+
failureReason: Error;
|
|
75
|
+
isPaused: boolean;
|
|
76
|
+
submittedAt: number;
|
|
77
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
78
|
+
requestSigningDelegation: import("@tanstack/react-query").UseMutateFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
79
|
+
requestSigningDelegationAsync: import("@tanstack/react-query").UseMutateAsyncFunction<SigningDelegationConsentOutcome, Error, RequestSigningDelegationParams, unknown>;
|
|
80
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { useMutation } from "@tanstack/react-query";
|
|
22
|
+
import { requestSigningDelegation } from "../../actions/index.js";
|
|
23
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
24
|
+
import { useClient } from "../utils/index.js";
|
|
25
|
+
const REQUEST_SIGNING_DELEGATION_KEY = "REQUEST_SIGNING_DELEGATION";
|
|
26
|
+
const useSigningDelegation = () => {
|
|
27
|
+
const para = useClient();
|
|
28
|
+
const mutation = useMutation({
|
|
29
|
+
mutationKey: [REQUEST_SIGNING_DELEGATION_KEY],
|
|
30
|
+
mutationFn: (args) => __async(null, null, function* () {
|
|
31
|
+
return requestSigningDelegation(para, args);
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
return renameMutations(mutation, "requestSigningDelegation");
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
REQUEST_SIGNING_DELEGATION_KEY,
|
|
38
|
+
useSigningDelegation
|
|
39
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export type ParaStatusBase = {
|
|
2
2
|
/** Whether the Para client's first-time setup is complete. */
|
|
3
3
|
isReady: boolean;
|
|
4
|
+
/** The most recent SDK state error (e.g. a failed setup step), or `null`. */
|
|
5
|
+
error: Error | null;
|
|
4
6
|
};
|
|
5
7
|
/**
|
|
6
8
|
* Factory that creates a `useParaStatus` hook. Accepts an optional enhancer
|
|
@@ -10,6 +12,6 @@ export type ParaStatusBase = {
|
|
|
10
12
|
export declare function createParaStatusHook<TExtra extends Record<string, unknown> = Record<string, never>>(useExtra?: () => TExtra): () => ParaStatusBase & TExtra;
|
|
11
13
|
/**
|
|
12
14
|
* Platform-agnostic hook for reading the Para SDK's current status.
|
|
13
|
-
* Returns `{ isReady }`. Web extends this with `isFarcasterMiniApp` etc.
|
|
15
|
+
* Returns `{ isReady, error }`. Web extends this with `isFarcasterMiniApp` etc.
|
|
14
16
|
*/
|
|
15
17
|
export declare const useParaStatus: () => ParaStatusBase & Record<string, never>;
|
|
@@ -17,11 +17,12 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
import { useCoreStore } from "../../stores/CoreStoreContext.js";
|
|
18
18
|
function createParaStatusHook(useExtra) {
|
|
19
19
|
return function useParaStatus2() {
|
|
20
|
-
var _a, _b;
|
|
20
|
+
var _a, _b, _c;
|
|
21
21
|
const paraState = useCoreStore((state) => state.paraState);
|
|
22
22
|
const extra = (_a = useExtra == null ? void 0 : useExtra()) != null ? _a : {};
|
|
23
23
|
return __spreadValues({
|
|
24
|
-
isReady: (_b = paraState == null ? void 0 : paraState.isReady) != null ? _b : false
|
|
24
|
+
isReady: (_b = paraState == null ? void 0 : paraState.isReady) != null ? _b : false,
|
|
25
|
+
error: (_c = paraState == null ? void 0 : paraState.error) != null ? _c : null
|
|
25
26
|
}, extra);
|
|
26
27
|
};
|
|
27
28
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural equality for client constructor options. Plain objects and arrays compare by contents;
|
|
3
|
+
* everything else (functions, class instances, storage adapters) compares by reference, so a changed
|
|
4
|
+
* adapter or callback still counts as a different config.
|
|
5
|
+
*/
|
|
6
|
+
export declare function areClientOptsEqual(a: unknown, b: unknown, depth?: number): boolean;
|
|
7
|
+
interface ClientConfigLike {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
env?: unknown;
|
|
10
|
+
opts?: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Whether a new `paraClientConfig` should keep the existing client.
|
|
14
|
+
*
|
|
15
|
+
* Partners commonly pass an inline object (`paraClientConfig={{ apiKey, env }}`), which is a fresh
|
|
16
|
+
* reference on every parent render. Keying the client on object identity rebuilt the ParaWeb client on
|
|
17
|
+
* each such render. When that happened mid-login, the in-progress flow was stranded on the discarded
|
|
18
|
+
* client and the auth modal went blank (ENG-7553). Configs are compared by value instead; the platform
|
|
19
|
+
* factory (`createClient`) is ignored because wrappers recreate it alongside the config.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isSameClientConfig(prev: ClientConfigLike, next: ClientConfigLike): boolean;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const MAX_DEPTH = 8;
|
|
2
|
+
function isPlainObject(value) {
|
|
3
|
+
if (typeof value !== "object" || value === null) return false;
|
|
4
|
+
const proto = Object.getPrototypeOf(value);
|
|
5
|
+
return proto === Object.prototype || proto === null;
|
|
6
|
+
}
|
|
7
|
+
function areClientOptsEqual(a, b, depth = 0) {
|
|
8
|
+
if (Object.is(a, b)) return true;
|
|
9
|
+
if (depth > MAX_DEPTH) return false;
|
|
10
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
11
|
+
return a.length === b.length && a.every((item, i) => areClientOptsEqual(item, b[i], depth + 1));
|
|
12
|
+
}
|
|
13
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
14
|
+
const aKeys = Object.keys(a);
|
|
15
|
+
if (aKeys.length !== Object.keys(b).length) return false;
|
|
16
|
+
return aKeys.every((key) => Object.prototype.hasOwnProperty.call(b, key) && areClientOptsEqual(a[key], b[key], depth + 1));
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
function isSameClientConfig(prev, next) {
|
|
21
|
+
return prev.apiKey === next.apiKey && prev.env === next.env && areClientOptsEqual(prev.opts, next.opts);
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
areClientOptsEqual,
|
|
25
|
+
isSameClientConfig
|
|
26
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.26.0",
|
|
4
4
|
"description": "Platform-agnostic ParaProvider, hooks, and store for Para SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -168,29 +168,29 @@
|
|
|
168
168
|
"typecheck": "tsc --noEmit"
|
|
169
169
|
},
|
|
170
170
|
"dependencies": {
|
|
171
|
-
"@getpara/core-sdk": "3.
|
|
171
|
+
"@getpara/core-sdk": "3.26.0",
|
|
172
172
|
"zustand": "^5.0.0"
|
|
173
173
|
},
|
|
174
174
|
"devDependencies": {
|
|
175
175
|
"@cosmjs/amino": "^0.32.4",
|
|
176
176
|
"@cosmjs/proto-signing": "^0.32.4",
|
|
177
177
|
"@cosmjs/stargate": "^0.32.4",
|
|
178
|
-
"@getpara/aa-alchemy": "3.
|
|
179
|
-
"@getpara/aa-biconomy": "3.
|
|
180
|
-
"@getpara/aa-cdp": "3.
|
|
181
|
-
"@getpara/aa-gelato": "3.
|
|
182
|
-
"@getpara/aa-pimlico": "3.
|
|
183
|
-
"@getpara/aa-porto": "3.
|
|
184
|
-
"@getpara/aa-rhinestone": "3.
|
|
185
|
-
"@getpara/aa-safe": "3.
|
|
186
|
-
"@getpara/aa-thirdweb": "3.
|
|
187
|
-
"@getpara/aa-zerodev": "3.
|
|
188
|
-
"@getpara/cosmjs-v0-integration": "3.
|
|
189
|
-
"@getpara/ethers-v6-integration": "3.
|
|
190
|
-
"@getpara/solana-signers-v2-integration": "3.
|
|
191
|
-
"@getpara/stellar-sdk-v14-integration": "3.
|
|
192
|
-
"@getpara/sui-sdk-integration": "3.
|
|
193
|
-
"@getpara/viem-v2-integration": "3.
|
|
178
|
+
"@getpara/aa-alchemy": "3.26.0",
|
|
179
|
+
"@getpara/aa-biconomy": "3.26.0",
|
|
180
|
+
"@getpara/aa-cdp": "3.26.0",
|
|
181
|
+
"@getpara/aa-gelato": "3.26.0",
|
|
182
|
+
"@getpara/aa-pimlico": "3.26.0",
|
|
183
|
+
"@getpara/aa-porto": "3.26.0",
|
|
184
|
+
"@getpara/aa-rhinestone": "3.26.0",
|
|
185
|
+
"@getpara/aa-safe": "3.26.0",
|
|
186
|
+
"@getpara/aa-thirdweb": "3.26.0",
|
|
187
|
+
"@getpara/aa-zerodev": "3.26.0",
|
|
188
|
+
"@getpara/cosmjs-v0-integration": "3.26.0",
|
|
189
|
+
"@getpara/ethers-v6-integration": "3.26.0",
|
|
190
|
+
"@getpara/solana-signers-v2-integration": "3.26.0",
|
|
191
|
+
"@getpara/stellar-sdk-v14-integration": "3.26.0",
|
|
192
|
+
"@getpara/sui-sdk-integration": "3.26.0",
|
|
193
|
+
"@getpara/viem-v2-integration": "3.26.0",
|
|
194
194
|
"@mysten/sui": "^2.0.0",
|
|
195
195
|
"@solana/keys": "^2.2.1",
|
|
196
196
|
"@solana/signers": "^2.0.0",
|
|
@@ -308,5 +308,5 @@
|
|
|
308
308
|
"@getpara/aa-*"
|
|
309
309
|
]
|
|
310
310
|
},
|
|
311
|
-
"gitHead": "
|
|
311
|
+
"gitHead": "3da03ae598e47dddcad44773264bcba424537e9d"
|
|
312
312
|
}
|