@moon-x/react-native-sdk 0.11.0 → 0.12.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/README.md +5 -7
- package/dist/index.d.mts +28 -5
- package/dist/index.d.ts +28 -5
- package/dist/index.js +75 -29
- package/dist/index.mjs +63 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -319,17 +319,15 @@ your app's package name + signing-cert SHA-256 fingerprint.
|
|
|
319
319
|
#### 1. Publish `assetlinks.json` at the rpId apex
|
|
320
320
|
|
|
321
321
|
If `passkeyDomains` is `myapp.com`, host at
|
|
322
|
-
`https://myapp.com/.well-known/assetlinks.json`.
|
|
323
|
-
|
|
324
|
-
|
|
322
|
+
`https://myapp.com/.well-known/assetlinks.json`. Passkeys need the
|
|
323
|
+
`delegate_permission/common.get_login_creds` relation. Add
|
|
324
|
+
`delegate_permission/common.handle_all_urls` separately only if the app also
|
|
325
|
+
uses Android App Links:
|
|
325
326
|
|
|
326
327
|
```json
|
|
327
328
|
[
|
|
328
329
|
{
|
|
329
|
-
"relation": [
|
|
330
|
-
"delegate_permission/common.handle_all_urls",
|
|
331
|
-
"delegate_permission/common.get_login_creds"
|
|
332
|
-
],
|
|
330
|
+
"relation": ["delegate_permission/common.get_login_creds"],
|
|
333
331
|
"target": {
|
|
334
332
|
"namespace": "android_app",
|
|
335
333
|
"package_name": "com.example.myapp",
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { RelyingPartyOriginInput } from '@moon-x/core/sdk';
|
|
|
3
3
|
import { PostMessageType, PostMessageMethod } from '@moon-x/core/utils';
|
|
4
4
|
export { PostMessageMethod, PostMessageType } from '@moon-x/core/utils';
|
|
5
5
|
import * as _moon_x_core_types from '@moon-x/core/types';
|
|
6
|
-
import { PublicWallet, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult } from '@moon-x/core/types';
|
|
6
|
+
import { PublicWallet, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult, AppConfigResponse } from '@moon-x/core/types';
|
|
7
7
|
export { Chain, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, ListEphemeralSignersResult, Network, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, PublicWallet, RevokeEphemeralSignerParams, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, WalletConnectConfig } from '@moon-x/core/types';
|
|
8
8
|
export { UseEphemeralSignerResult, useAddPasskey, useCreateWallet, useEphemeralSigner, useImportKey, useLoginWithEmail, useLogout, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets } from '@moon-x/core/react';
|
|
9
9
|
|
|
@@ -78,16 +78,16 @@ interface RNAuthSDK {
|
|
|
78
78
|
success: boolean;
|
|
79
79
|
message: string;
|
|
80
80
|
}>;
|
|
81
|
-
createWallet: (walletType: "solana" | "ethereum", options?: {
|
|
81
|
+
createWallet: (walletType: "solana" | "ethereum" | "tron", options?: {
|
|
82
82
|
createAdditional?: boolean;
|
|
83
83
|
walletIndex?: number;
|
|
84
84
|
}) => Promise<{
|
|
85
85
|
wallet: PublicWallet;
|
|
86
86
|
}>;
|
|
87
|
-
importKey: (walletType: "solana" | "ethereum", key: string) => Promise<{
|
|
87
|
+
importKey: (walletType: "solana" | "ethereum" | "tron", key: string) => Promise<{
|
|
88
88
|
wallet: PublicWallet;
|
|
89
89
|
}>;
|
|
90
|
-
getWallets: (walletType: "solana" | "ethereum") => Promise<{
|
|
90
|
+
getWallets: (walletType: "solana" | "ethereum" | "tron") => Promise<{
|
|
91
91
|
wallets: any[];
|
|
92
92
|
walletType: string;
|
|
93
93
|
}>;
|
|
@@ -211,6 +211,29 @@ interface MoonXContextValue {
|
|
|
211
211
|
declare const MoonXProvider: React.FC<MoonXProviderProps>;
|
|
212
212
|
declare const useMoonXContext: () => MoonXContextValue;
|
|
213
213
|
|
|
214
|
+
interface UseAppConfigReturn {
|
|
215
|
+
appConfig: AppConfigResponse | null;
|
|
216
|
+
isLoading: boolean;
|
|
217
|
+
error: string | null;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Fetch the per-app config (`sdk_settings`, terms/privacy URLs, logo,
|
|
221
|
+
* ...) over the WebView bridge and return the whole `AppConfigResponse`
|
|
222
|
+
* alongside `{ isLoading, error }`.
|
|
223
|
+
*
|
|
224
|
+
* Deliberately mirrors the web SDK's `useAppConfig`
|
|
225
|
+
* (`@moon-x/react-sdk`'s `internal/use-app-config.ts`) return shape so
|
|
226
|
+
* app code that gates login methods on `sdk_settings` or renders a
|
|
227
|
+
* terms-acceptance footer moves between web and RN with a 1-line import
|
|
228
|
+
* swap — same philosophy as `useMoonX`. We return the full response
|
|
229
|
+
* rather than destructuring convenience fields for exactly that reason.
|
|
230
|
+
*
|
|
231
|
+
* `publishableKey` is optional (unlike web, where the consumer always
|
|
232
|
+
* threads it): the RN provider already holds the key, so we default to
|
|
233
|
+
* `sdk.publishableKey`. Pass it only to override.
|
|
234
|
+
*/
|
|
235
|
+
declare const useAppConfig: (publishableKey?: string) => UseAppConfigReturn;
|
|
236
|
+
|
|
214
237
|
type State$1 = {
|
|
215
238
|
status: "idle";
|
|
216
239
|
} | {
|
|
@@ -283,4 +306,4 @@ declare const useLoginWithOAuth: (params?: {
|
|
|
283
306
|
*/
|
|
284
307
|
declare const useMoonX: () => RNAuthSDK;
|
|
285
308
|
|
|
286
|
-
export { type MoonXConfig, MoonXProvider, type MoonXProviderProps, type RNAuthSDK, useAttachOAuth, useDetachOAuth, useExportKey, useLoginWithOAuth, useMoonX, useMoonXContext };
|
|
309
|
+
export { type MoonXConfig, MoonXProvider, type MoonXProviderProps, type RNAuthSDK, useAppConfig, useAttachOAuth, useDetachOAuth, useExportKey, useLoginWithOAuth, useMoonX, useMoonXContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { RelyingPartyOriginInput } from '@moon-x/core/sdk';
|
|
|
3
3
|
import { PostMessageType, PostMessageMethod } from '@moon-x/core/utils';
|
|
4
4
|
export { PostMessageMethod, PostMessageType } from '@moon-x/core/utils';
|
|
5
5
|
import * as _moon_x_core_types from '@moon-x/core/types';
|
|
6
|
-
import { PublicWallet, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult } from '@moon-x/core/types';
|
|
6
|
+
import { PublicWallet, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult, AppConfigResponse } from '@moon-x/core/types';
|
|
7
7
|
export { Chain, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, ListEphemeralSignersResult, Network, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, PublicWallet, RevokeEphemeralSignerParams, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, WalletConnectConfig } from '@moon-x/core/types';
|
|
8
8
|
export { UseEphemeralSignerResult, useAddPasskey, useCreateWallet, useEphemeralSigner, useImportKey, useLoginWithEmail, useLogout, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets } from '@moon-x/core/react';
|
|
9
9
|
|
|
@@ -78,16 +78,16 @@ interface RNAuthSDK {
|
|
|
78
78
|
success: boolean;
|
|
79
79
|
message: string;
|
|
80
80
|
}>;
|
|
81
|
-
createWallet: (walletType: "solana" | "ethereum", options?: {
|
|
81
|
+
createWallet: (walletType: "solana" | "ethereum" | "tron", options?: {
|
|
82
82
|
createAdditional?: boolean;
|
|
83
83
|
walletIndex?: number;
|
|
84
84
|
}) => Promise<{
|
|
85
85
|
wallet: PublicWallet;
|
|
86
86
|
}>;
|
|
87
|
-
importKey: (walletType: "solana" | "ethereum", key: string) => Promise<{
|
|
87
|
+
importKey: (walletType: "solana" | "ethereum" | "tron", key: string) => Promise<{
|
|
88
88
|
wallet: PublicWallet;
|
|
89
89
|
}>;
|
|
90
|
-
getWallets: (walletType: "solana" | "ethereum") => Promise<{
|
|
90
|
+
getWallets: (walletType: "solana" | "ethereum" | "tron") => Promise<{
|
|
91
91
|
wallets: any[];
|
|
92
92
|
walletType: string;
|
|
93
93
|
}>;
|
|
@@ -211,6 +211,29 @@ interface MoonXContextValue {
|
|
|
211
211
|
declare const MoonXProvider: React.FC<MoonXProviderProps>;
|
|
212
212
|
declare const useMoonXContext: () => MoonXContextValue;
|
|
213
213
|
|
|
214
|
+
interface UseAppConfigReturn {
|
|
215
|
+
appConfig: AppConfigResponse | null;
|
|
216
|
+
isLoading: boolean;
|
|
217
|
+
error: string | null;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Fetch the per-app config (`sdk_settings`, terms/privacy URLs, logo,
|
|
221
|
+
* ...) over the WebView bridge and return the whole `AppConfigResponse`
|
|
222
|
+
* alongside `{ isLoading, error }`.
|
|
223
|
+
*
|
|
224
|
+
* Deliberately mirrors the web SDK's `useAppConfig`
|
|
225
|
+
* (`@moon-x/react-sdk`'s `internal/use-app-config.ts`) return shape so
|
|
226
|
+
* app code that gates login methods on `sdk_settings` or renders a
|
|
227
|
+
* terms-acceptance footer moves between web and RN with a 1-line import
|
|
228
|
+
* swap — same philosophy as `useMoonX`. We return the full response
|
|
229
|
+
* rather than destructuring convenience fields for exactly that reason.
|
|
230
|
+
*
|
|
231
|
+
* `publishableKey` is optional (unlike web, where the consumer always
|
|
232
|
+
* threads it): the RN provider already holds the key, so we default to
|
|
233
|
+
* `sdk.publishableKey`. Pass it only to override.
|
|
234
|
+
*/
|
|
235
|
+
declare const useAppConfig: (publishableKey?: string) => UseAppConfigReturn;
|
|
236
|
+
|
|
214
237
|
type State$1 = {
|
|
215
238
|
status: "idle";
|
|
216
239
|
} | {
|
|
@@ -283,4 +306,4 @@ declare const useLoginWithOAuth: (params?: {
|
|
|
283
306
|
*/
|
|
284
307
|
declare const useMoonX: () => RNAuthSDK;
|
|
285
308
|
|
|
286
|
-
export { type MoonXConfig, MoonXProvider, type MoonXProviderProps, type RNAuthSDK, useAttachOAuth, useDetachOAuth, useExportKey, useLoginWithOAuth, useMoonX, useMoonXContext };
|
|
309
|
+
export { type MoonXConfig, MoonXProvider, type MoonXProviderProps, type RNAuthSDK, useAppConfig, useAttachOAuth, useDetachOAuth, useExportKey, useLoginWithOAuth, useMoonX, useMoonXContext };
|
package/dist/index.js
CHANGED
|
@@ -31,25 +31,26 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
MoonXProvider: () => MoonXProvider,
|
|
34
|
-
PostMessageMethod: () =>
|
|
35
|
-
PostMessageType: () =>
|
|
36
|
-
useAddPasskey: () =>
|
|
34
|
+
PostMessageMethod: () => import_utils9.PostMessageMethod,
|
|
35
|
+
PostMessageType: () => import_utils9.PostMessageType,
|
|
36
|
+
useAddPasskey: () => import_react6.useAddPasskey,
|
|
37
|
+
useAppConfig: () => useAppConfig,
|
|
37
38
|
useAttachOAuth: () => useAttachOAuth,
|
|
38
|
-
useCreateWallet: () =>
|
|
39
|
+
useCreateWallet: () => import_react6.useCreateWallet,
|
|
39
40
|
useDetachOAuth: () => useDetachOAuth,
|
|
40
|
-
useEphemeralSigner: () =>
|
|
41
|
+
useEphemeralSigner: () => import_react6.useEphemeralSigner,
|
|
41
42
|
useExportKey: () => useExportKey,
|
|
42
|
-
useImportKey: () =>
|
|
43
|
-
useLoginWithEmail: () =>
|
|
43
|
+
useImportKey: () => import_react6.useImportKey,
|
|
44
|
+
useLoginWithEmail: () => import_react6.useLoginWithEmail,
|
|
44
45
|
useLoginWithOAuth: () => useLoginWithOAuth,
|
|
45
|
-
useLogout: () =>
|
|
46
|
+
useLogout: () => import_react6.useLogout,
|
|
46
47
|
useMoonX: () => useMoonX,
|
|
47
48
|
useMoonXContext: () => useMoonXContext,
|
|
48
|
-
usePasskeyStatus: () =>
|
|
49
|
-
useRegisterPasskey: () =>
|
|
50
|
-
useRemovePasskey: () =>
|
|
51
|
-
useUser: () =>
|
|
52
|
-
useWallets: () =>
|
|
49
|
+
usePasskeyStatus: () => import_react6.usePasskeyStatus,
|
|
50
|
+
useRegisterPasskey: () => import_react6.useRegisterPasskey,
|
|
51
|
+
useRemovePasskey: () => import_react6.useRemovePasskey,
|
|
52
|
+
useUser: () => import_react6.useUser,
|
|
53
|
+
useWallets: () => import_react6.useWallets
|
|
53
54
|
});
|
|
54
55
|
module.exports = __toCommonJS(index_exports);
|
|
55
56
|
|
|
@@ -929,11 +930,55 @@ var styles = import_react_native.StyleSheet.create({
|
|
|
929
930
|
});
|
|
930
931
|
|
|
931
932
|
// src/hooks/index.ts
|
|
932
|
-
var
|
|
933
|
+
var import_react6 = require("@moon-x/core/react");
|
|
933
934
|
|
|
934
|
-
// src/hooks/use-
|
|
935
|
+
// src/hooks/use-app-config.ts
|
|
935
936
|
var import_utils5 = require("@moon-x/core/utils");
|
|
936
937
|
var import_react3 = require("react");
|
|
938
|
+
var useAppConfig = (publishableKey) => {
|
|
939
|
+
const { sdk, _bridge } = useMoonXContext();
|
|
940
|
+
const resolvedKey = publishableKey ?? sdk.publishableKey;
|
|
941
|
+
const ready = sdk.ready;
|
|
942
|
+
const [appConfig, setAppConfig] = (0, import_react3.useState)(null);
|
|
943
|
+
const [isLoading, setIsLoading] = (0, import_react3.useState)(true);
|
|
944
|
+
const [error, setError] = (0, import_react3.useState)(null);
|
|
945
|
+
(0, import_react3.useEffect)(() => {
|
|
946
|
+
if (!resolvedKey) {
|
|
947
|
+
setIsLoading(false);
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
if (!ready) {
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
let cancelled = false;
|
|
954
|
+
const fetchAppConfig = async () => {
|
|
955
|
+
setIsLoading(true);
|
|
956
|
+
setError(null);
|
|
957
|
+
setAppConfig(null);
|
|
958
|
+
try {
|
|
959
|
+
const config = await _bridge.send(import_utils5.PostMessageType.AUTH, import_utils5.PostMessageMethod.GET_APP_CONFIG, {
|
|
960
|
+
publishableKey: resolvedKey
|
|
961
|
+
});
|
|
962
|
+
if (!cancelled) setAppConfig(config);
|
|
963
|
+
} catch (err) {
|
|
964
|
+
if (!cancelled) {
|
|
965
|
+
setError(err instanceof Error ? err.message : "Unknown error");
|
|
966
|
+
}
|
|
967
|
+
} finally {
|
|
968
|
+
if (!cancelled) setIsLoading(false);
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
fetchAppConfig();
|
|
972
|
+
return () => {
|
|
973
|
+
cancelled = true;
|
|
974
|
+
};
|
|
975
|
+
}, [resolvedKey, ready, _bridge]);
|
|
976
|
+
return { appConfig, isLoading, error };
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
// src/hooks/use-attach-oauth.ts
|
|
980
|
+
var import_utils6 = require("@moon-x/core/utils");
|
|
981
|
+
var import_react4 = require("react");
|
|
937
982
|
|
|
938
983
|
// src/lib/oauth-deep-link.ts
|
|
939
984
|
var openOAuthFlow = async ({
|
|
@@ -974,7 +1019,7 @@ var parseOAuthRedirect = async (redirectUrl) => {
|
|
|
974
1019
|
// src/hooks/use-attach-oauth.ts
|
|
975
1020
|
var useAttachOAuth = (params) => {
|
|
976
1021
|
const { sdk, _bridge, _oauthRedirectUri } = useMoonXContext();
|
|
977
|
-
const [state, setState] = (0,
|
|
1022
|
+
const [state, setState] = (0, import_react4.useState)({ status: "idle" });
|
|
978
1023
|
return {
|
|
979
1024
|
state,
|
|
980
1025
|
attachOAuth: async (provider) => {
|
|
@@ -983,8 +1028,8 @@ var useAttachOAuth = (params) => {
|
|
|
983
1028
|
const redirectUri = params?.redirectUri || _oauthRedirectUri;
|
|
984
1029
|
if (!redirectUri) throw new Error("oauth_redirect_uri_missing");
|
|
985
1030
|
const startResult = await _bridge.send(
|
|
986
|
-
|
|
987
|
-
|
|
1031
|
+
import_utils6.PostMessageType.AUTH,
|
|
1032
|
+
import_utils6.PostMessageMethod.START_OAUTH,
|
|
988
1033
|
{
|
|
989
1034
|
publishableKey: sdk.publishableKey,
|
|
990
1035
|
provider,
|
|
@@ -1004,8 +1049,8 @@ var useAttachOAuth = (params) => {
|
|
|
1004
1049
|
if (parsed.error) throw new Error(parsed.error);
|
|
1005
1050
|
setState({ status: "verifying" });
|
|
1006
1051
|
await _bridge.send(
|
|
1007
|
-
|
|
1008
|
-
|
|
1052
|
+
import_utils6.PostMessageType.AUTH,
|
|
1053
|
+
import_utils6.PostMessageMethod.ATTACH_OAUTH,
|
|
1009
1054
|
{
|
|
1010
1055
|
publishableKey: sdk.publishableKey,
|
|
1011
1056
|
provider,
|
|
@@ -1026,14 +1071,14 @@ var useAttachOAuth = (params) => {
|
|
|
1026
1071
|
};
|
|
1027
1072
|
|
|
1028
1073
|
// src/hooks/use-detach-oauth.ts
|
|
1029
|
-
var
|
|
1074
|
+
var import_utils7 = require("@moon-x/core/utils");
|
|
1030
1075
|
var useDetachOAuth = () => {
|
|
1031
1076
|
const { sdk, _bridge } = useMoonXContext();
|
|
1032
1077
|
return {
|
|
1033
1078
|
detachOAuth: async (idpUserId) => {
|
|
1034
1079
|
await _bridge.send(
|
|
1035
|
-
|
|
1036
|
-
|
|
1080
|
+
import_utils7.PostMessageType.AUTH,
|
|
1081
|
+
import_utils7.PostMessageMethod.DETACH_OAUTH,
|
|
1037
1082
|
{ publishableKey: sdk.publishableKey, idpUserId }
|
|
1038
1083
|
);
|
|
1039
1084
|
}
|
|
@@ -1078,11 +1123,11 @@ var useExportKey = () => {
|
|
|
1078
1123
|
};
|
|
1079
1124
|
|
|
1080
1125
|
// src/hooks/use-login-with-oauth.ts
|
|
1081
|
-
var
|
|
1082
|
-
var
|
|
1126
|
+
var import_utils8 = require("@moon-x/core/utils");
|
|
1127
|
+
var import_react5 = require("react");
|
|
1083
1128
|
var useLoginWithOAuth = (params) => {
|
|
1084
1129
|
const { sdk, _bridge, _oauthRedirectUri } = useMoonXContext();
|
|
1085
|
-
const [state, setState] = (0,
|
|
1130
|
+
const [state, setState] = (0, import_react5.useState)({ status: "idle" });
|
|
1086
1131
|
return {
|
|
1087
1132
|
state,
|
|
1088
1133
|
loginWithOAuth: async (provider) => {
|
|
@@ -1093,8 +1138,8 @@ var useLoginWithOAuth = (params) => {
|
|
|
1093
1138
|
throw new Error("oauth_redirect_uri_missing");
|
|
1094
1139
|
}
|
|
1095
1140
|
const startResult = await _bridge.send(
|
|
1096
|
-
|
|
1097
|
-
|
|
1141
|
+
import_utils8.PostMessageType.AUTH,
|
|
1142
|
+
import_utils8.PostMessageMethod.START_OAUTH,
|
|
1098
1143
|
{
|
|
1099
1144
|
publishableKey: sdk.publishableKey,
|
|
1100
1145
|
provider,
|
|
@@ -1136,13 +1181,14 @@ var useLoginWithOAuth = (params) => {
|
|
|
1136
1181
|
var useMoonX = () => useMoonXContext().sdk;
|
|
1137
1182
|
|
|
1138
1183
|
// src/index.ts
|
|
1139
|
-
var
|
|
1184
|
+
var import_utils9 = require("@moon-x/core/utils");
|
|
1140
1185
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1141
1186
|
0 && (module.exports = {
|
|
1142
1187
|
MoonXProvider,
|
|
1143
1188
|
PostMessageMethod,
|
|
1144
1189
|
PostMessageType,
|
|
1145
1190
|
useAddPasskey,
|
|
1191
|
+
useAppConfig,
|
|
1146
1192
|
useAttachOAuth,
|
|
1147
1193
|
useCreateWallet,
|
|
1148
1194
|
useDetachOAuth,
|
package/dist/index.mjs
CHANGED
|
@@ -917,9 +917,53 @@ import {
|
|
|
917
917
|
useWallets
|
|
918
918
|
} from "@moon-x/core/react";
|
|
919
919
|
|
|
920
|
-
// src/hooks/use-
|
|
920
|
+
// src/hooks/use-app-config.ts
|
|
921
921
|
import { PostMessageMethod as PostMessageMethod4, PostMessageType as PostMessageType4 } from "@moon-x/core/utils";
|
|
922
|
-
import { useState as useState2 } from "react";
|
|
922
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
923
|
+
var useAppConfig = (publishableKey) => {
|
|
924
|
+
const { sdk, _bridge } = useMoonXContext();
|
|
925
|
+
const resolvedKey = publishableKey ?? sdk.publishableKey;
|
|
926
|
+
const ready = sdk.ready;
|
|
927
|
+
const [appConfig, setAppConfig] = useState2(null);
|
|
928
|
+
const [isLoading, setIsLoading] = useState2(true);
|
|
929
|
+
const [error, setError] = useState2(null);
|
|
930
|
+
useEffect2(() => {
|
|
931
|
+
if (!resolvedKey) {
|
|
932
|
+
setIsLoading(false);
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
if (!ready) {
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
let cancelled = false;
|
|
939
|
+
const fetchAppConfig = async () => {
|
|
940
|
+
setIsLoading(true);
|
|
941
|
+
setError(null);
|
|
942
|
+
setAppConfig(null);
|
|
943
|
+
try {
|
|
944
|
+
const config = await _bridge.send(PostMessageType4.AUTH, PostMessageMethod4.GET_APP_CONFIG, {
|
|
945
|
+
publishableKey: resolvedKey
|
|
946
|
+
});
|
|
947
|
+
if (!cancelled) setAppConfig(config);
|
|
948
|
+
} catch (err) {
|
|
949
|
+
if (!cancelled) {
|
|
950
|
+
setError(err instanceof Error ? err.message : "Unknown error");
|
|
951
|
+
}
|
|
952
|
+
} finally {
|
|
953
|
+
if (!cancelled) setIsLoading(false);
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
fetchAppConfig();
|
|
957
|
+
return () => {
|
|
958
|
+
cancelled = true;
|
|
959
|
+
};
|
|
960
|
+
}, [resolvedKey, ready, _bridge]);
|
|
961
|
+
return { appConfig, isLoading, error };
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
// src/hooks/use-attach-oauth.ts
|
|
965
|
+
import { PostMessageMethod as PostMessageMethod5, PostMessageType as PostMessageType5 } from "@moon-x/core/utils";
|
|
966
|
+
import { useState as useState3 } from "react";
|
|
923
967
|
|
|
924
968
|
// src/lib/oauth-deep-link.ts
|
|
925
969
|
var openOAuthFlow = async ({
|
|
@@ -960,7 +1004,7 @@ var parseOAuthRedirect = async (redirectUrl) => {
|
|
|
960
1004
|
// src/hooks/use-attach-oauth.ts
|
|
961
1005
|
var useAttachOAuth = (params) => {
|
|
962
1006
|
const { sdk, _bridge, _oauthRedirectUri } = useMoonXContext();
|
|
963
|
-
const [state, setState] =
|
|
1007
|
+
const [state, setState] = useState3({ status: "idle" });
|
|
964
1008
|
return {
|
|
965
1009
|
state,
|
|
966
1010
|
attachOAuth: async (provider) => {
|
|
@@ -969,8 +1013,8 @@ var useAttachOAuth = (params) => {
|
|
|
969
1013
|
const redirectUri = params?.redirectUri || _oauthRedirectUri;
|
|
970
1014
|
if (!redirectUri) throw new Error("oauth_redirect_uri_missing");
|
|
971
1015
|
const startResult = await _bridge.send(
|
|
972
|
-
|
|
973
|
-
|
|
1016
|
+
PostMessageType5.AUTH,
|
|
1017
|
+
PostMessageMethod5.START_OAUTH,
|
|
974
1018
|
{
|
|
975
1019
|
publishableKey: sdk.publishableKey,
|
|
976
1020
|
provider,
|
|
@@ -990,8 +1034,8 @@ var useAttachOAuth = (params) => {
|
|
|
990
1034
|
if (parsed.error) throw new Error(parsed.error);
|
|
991
1035
|
setState({ status: "verifying" });
|
|
992
1036
|
await _bridge.send(
|
|
993
|
-
|
|
994
|
-
|
|
1037
|
+
PostMessageType5.AUTH,
|
|
1038
|
+
PostMessageMethod5.ATTACH_OAUTH,
|
|
995
1039
|
{
|
|
996
1040
|
publishableKey: sdk.publishableKey,
|
|
997
1041
|
provider,
|
|
@@ -1012,14 +1056,14 @@ var useAttachOAuth = (params) => {
|
|
|
1012
1056
|
};
|
|
1013
1057
|
|
|
1014
1058
|
// src/hooks/use-detach-oauth.ts
|
|
1015
|
-
import { PostMessageMethod as
|
|
1059
|
+
import { PostMessageMethod as PostMessageMethod6, PostMessageType as PostMessageType6 } from "@moon-x/core/utils";
|
|
1016
1060
|
var useDetachOAuth = () => {
|
|
1017
1061
|
const { sdk, _bridge } = useMoonXContext();
|
|
1018
1062
|
return {
|
|
1019
1063
|
detachOAuth: async (idpUserId) => {
|
|
1020
1064
|
await _bridge.send(
|
|
1021
|
-
|
|
1022
|
-
|
|
1065
|
+
PostMessageType6.AUTH,
|
|
1066
|
+
PostMessageMethod6.DETACH_OAUTH,
|
|
1023
1067
|
{ publishableKey: sdk.publishableKey, idpUserId }
|
|
1024
1068
|
);
|
|
1025
1069
|
}
|
|
@@ -1064,11 +1108,11 @@ var useExportKey = () => {
|
|
|
1064
1108
|
};
|
|
1065
1109
|
|
|
1066
1110
|
// src/hooks/use-login-with-oauth.ts
|
|
1067
|
-
import { PostMessageMethod as
|
|
1068
|
-
import { useState as
|
|
1111
|
+
import { PostMessageMethod as PostMessageMethod7, PostMessageType as PostMessageType7 } from "@moon-x/core/utils";
|
|
1112
|
+
import { useState as useState4 } from "react";
|
|
1069
1113
|
var useLoginWithOAuth = (params) => {
|
|
1070
1114
|
const { sdk, _bridge, _oauthRedirectUri } = useMoonXContext();
|
|
1071
|
-
const [state, setState] =
|
|
1115
|
+
const [state, setState] = useState4({ status: "idle" });
|
|
1072
1116
|
return {
|
|
1073
1117
|
state,
|
|
1074
1118
|
loginWithOAuth: async (provider) => {
|
|
@@ -1079,8 +1123,8 @@ var useLoginWithOAuth = (params) => {
|
|
|
1079
1123
|
throw new Error("oauth_redirect_uri_missing");
|
|
1080
1124
|
}
|
|
1081
1125
|
const startResult = await _bridge.send(
|
|
1082
|
-
|
|
1083
|
-
|
|
1126
|
+
PostMessageType7.AUTH,
|
|
1127
|
+
PostMessageMethod7.START_OAUTH,
|
|
1084
1128
|
{
|
|
1085
1129
|
publishableKey: sdk.publishableKey,
|
|
1086
1130
|
provider,
|
|
@@ -1122,12 +1166,13 @@ var useLoginWithOAuth = (params) => {
|
|
|
1122
1166
|
var useMoonX = () => useMoonXContext().sdk;
|
|
1123
1167
|
|
|
1124
1168
|
// src/index.ts
|
|
1125
|
-
import { PostMessageMethod as
|
|
1169
|
+
import { PostMessageMethod as PostMessageMethod8, PostMessageType as PostMessageType8 } from "@moon-x/core/utils";
|
|
1126
1170
|
export {
|
|
1127
1171
|
MoonXProvider,
|
|
1128
|
-
|
|
1129
|
-
|
|
1172
|
+
PostMessageMethod8 as PostMessageMethod,
|
|
1173
|
+
PostMessageType8 as PostMessageType,
|
|
1130
1174
|
useAddPasskey,
|
|
1175
|
+
useAppConfig,
|
|
1131
1176
|
useAttachOAuth,
|
|
1132
1177
|
useCreateWallet,
|
|
1133
1178
|
useDetachOAuth,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moon-x/react-native-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "MoonX React Native SDK — WebView-backed transport, react-native-passkeys, AsyncStorage. Mobile parity with @moon-x/react-sdk + @moon-x/core-sdk.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"typescript": "5.9.3"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@moon-x/core": "0.
|
|
52
|
+
"@moon-x/core": "0.14.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@expo/config-plugins": ">=10.0.0",
|