@moon-x/react-native-sdk 0.20.2 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/ethereum.js +5 -2
- package/dist/ethereum.mjs +5 -2
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -2
- package/dist/index.mjs +5 -2
- package/dist/solana.js +5 -2
- package/dist/solana.mjs +5 -2
- package/dist/tron.js +5 -2
- package/dist/tron.mjs +5 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -231,6 +231,27 @@ the backend's 64-token ceremony limit.
|
|
|
231
231
|
|
|
232
232
|
### Wallets
|
|
233
233
|
|
|
234
|
+
`useMoonX().createWallet(chain)` always creates a new wallet, including concurrent
|
|
235
|
+
calls. `useMoonX().findOrCreateWallet(chain)` returns the first existing wallet
|
|
236
|
+
for that chain, or creates one if none exists. Both return `{ wallet }`. For
|
|
237
|
+
Bitcoin, pass `{ addressType }` to find or create a wallet of that type (`p2tr` by
|
|
238
|
+
default). `findOrCreateWallet()` rejects with `wallets_unavailable` rather than
|
|
239
|
+
creating a wallet when the existing list can't be read.
|
|
240
|
+
|
|
241
|
+
Only `findOrCreateWallet()` shares concurrent requests. Sharing requires the same
|
|
242
|
+
transport, publishable key, login, and chain (and address type for Bitcoin).
|
|
243
|
+
Separate devices and SDK transports can still race. A routine access-token
|
|
244
|
+
refresh does not interrupt the operation; the helper rejects with
|
|
245
|
+
`session_changed` only if a different login replaces the session while it runs. If a different login replaces the session during creation, the wallet can
|
|
246
|
+
already exist on the earlier login when the call rejects. After `session_changed`,
|
|
247
|
+
confirm the intended account before you retry with `findOrCreateWallet()`, not
|
|
248
|
+
`createWallet()`. The retry searches the current account before it creates a wallet.
|
|
249
|
+
If the new login is the same account, the retry finds the wallet that the first
|
|
250
|
+
call created.
|
|
251
|
+
|
|
252
|
+
The generic `useCreateWallet()` hook also returns both methods. Existing
|
|
253
|
+
`createWallet()` callers need no new option.
|
|
254
|
+
|
|
234
255
|
| Hook | What it does |
|
|
235
256
|
|---|---|
|
|
236
257
|
| `useWallets(walletType)` | Generic chain-aware list hook for Ethereum, Solana, or Tron. Chain subpaths provide pinned `useWallets()` variants. |
|
package/dist/ethereum.js
CHANGED
|
@@ -276,15 +276,18 @@ var useExportKey = () => {
|
|
|
276
276
|
scopes: import_sdk9.SCOPES_EXPORT_KEY
|
|
277
277
|
});
|
|
278
278
|
const keyshareReadToken = tokens.keyshare_read?.token ?? "";
|
|
279
|
+
const keyExportToken = tokens.key_export?.token ?? "";
|
|
279
280
|
const params = new URLSearchParams({
|
|
280
281
|
publishableKey: sdk.publishableKey,
|
|
281
282
|
wallet_id: wallet.id ?? "",
|
|
282
|
-
wallet_type: wallet.wallet_type ?? ""
|
|
283
|
+
wallet_type: wallet.wallet_type ?? "",
|
|
284
|
+
...!userHandleB64url && !credentialIdB64url ? { kms_eligible: "true" } : {}
|
|
283
285
|
});
|
|
284
286
|
const secrets = new URLSearchParams({
|
|
285
287
|
user_handle_b64url: userHandleB64url,
|
|
286
288
|
credential_id_b64url: credentialIdB64url,
|
|
287
|
-
keyshare_read_token: keyshareReadToken
|
|
289
|
+
keyshare_read_token: keyshareReadToken,
|
|
290
|
+
key_export_token: keyExportToken
|
|
288
291
|
});
|
|
289
292
|
return await _runSensitiveFlow({
|
|
290
293
|
title: "Export key",
|
package/dist/ethereum.mjs
CHANGED
|
@@ -287,15 +287,18 @@ var useExportKey = () => {
|
|
|
287
287
|
scopes: SCOPES_EXPORT_KEY
|
|
288
288
|
});
|
|
289
289
|
const keyshareReadToken = tokens.keyshare_read?.token ?? "";
|
|
290
|
+
const keyExportToken = tokens.key_export?.token ?? "";
|
|
290
291
|
const params = new URLSearchParams({
|
|
291
292
|
publishableKey: sdk.publishableKey,
|
|
292
293
|
wallet_id: wallet.id ?? "",
|
|
293
|
-
wallet_type: wallet.wallet_type ?? ""
|
|
294
|
+
wallet_type: wallet.wallet_type ?? "",
|
|
295
|
+
...!userHandleB64url && !credentialIdB64url ? { kms_eligible: "true" } : {}
|
|
294
296
|
});
|
|
295
297
|
const secrets = new URLSearchParams({
|
|
296
298
|
user_handle_b64url: userHandleB64url,
|
|
297
299
|
credential_id_b64url: credentialIdB64url,
|
|
298
|
-
keyshare_read_token: keyshareReadToken
|
|
300
|
+
keyshare_read_token: keyshareReadToken,
|
|
301
|
+
key_export_token: keyExportToken
|
|
299
302
|
});
|
|
300
303
|
return await _runSensitiveFlow({
|
|
301
304
|
title: "Export key",
|
package/dist/index.d.mts
CHANGED
|
@@ -118,6 +118,12 @@ interface RNAuthSDK {
|
|
|
118
118
|
}) => Promise<{
|
|
119
119
|
wallet: PublicWallet;
|
|
120
120
|
}>;
|
|
121
|
+
/** Return an existing wallet or create one. Concurrent calls share work within the same transport and session. */
|
|
122
|
+
findOrCreateWallet: (walletType: "solana" | "ethereum" | "tron" | "bitcoin", options?: {
|
|
123
|
+
addressType?: "p2tr" | "p2wpkh" | "p2pkh";
|
|
124
|
+
}) => Promise<{
|
|
125
|
+
wallet: PublicWallet;
|
|
126
|
+
}>;
|
|
121
127
|
importKey: (walletType: "solana" | "ethereum" | "tron" | "bitcoin", source: string | WalletImportSource, options?: {
|
|
122
128
|
addressType?: "p2tr" | "p2wpkh" | "p2pkh";
|
|
123
129
|
}) => Promise<{
|
package/dist/index.d.ts
CHANGED
|
@@ -118,6 +118,12 @@ interface RNAuthSDK {
|
|
|
118
118
|
}) => Promise<{
|
|
119
119
|
wallet: PublicWallet;
|
|
120
120
|
}>;
|
|
121
|
+
/** Return an existing wallet or create one. Concurrent calls share work within the same transport and session. */
|
|
122
|
+
findOrCreateWallet: (walletType: "solana" | "ethereum" | "tron" | "bitcoin", options?: {
|
|
123
|
+
addressType?: "p2tr" | "p2wpkh" | "p2pkh";
|
|
124
|
+
}) => Promise<{
|
|
125
|
+
wallet: PublicWallet;
|
|
126
|
+
}>;
|
|
121
127
|
importKey: (walletType: "solana" | "ethereum" | "tron" | "bitcoin", source: string | WalletImportSource, options?: {
|
|
122
128
|
addressType?: "p2tr" | "p2wpkh" | "p2pkh";
|
|
123
129
|
}) => Promise<{
|
package/dist/index.js
CHANGED
|
@@ -1515,15 +1515,18 @@ var useExportKey = () => {
|
|
|
1515
1515
|
scopes: import_sdk9.SCOPES_EXPORT_KEY
|
|
1516
1516
|
});
|
|
1517
1517
|
const keyshareReadToken = tokens.keyshare_read?.token ?? "";
|
|
1518
|
+
const keyExportToken = tokens.key_export?.token ?? "";
|
|
1518
1519
|
const params = new URLSearchParams({
|
|
1519
1520
|
publishableKey: sdk.publishableKey,
|
|
1520
1521
|
wallet_id: wallet.id ?? "",
|
|
1521
|
-
wallet_type: wallet.wallet_type ?? ""
|
|
1522
|
+
wallet_type: wallet.wallet_type ?? "",
|
|
1523
|
+
...!userHandleB64url && !credentialIdB64url ? { kms_eligible: "true" } : {}
|
|
1522
1524
|
});
|
|
1523
1525
|
const secrets = new URLSearchParams({
|
|
1524
1526
|
user_handle_b64url: userHandleB64url,
|
|
1525
1527
|
credential_id_b64url: credentialIdB64url,
|
|
1526
|
-
keyshare_read_token: keyshareReadToken
|
|
1528
|
+
keyshare_read_token: keyshareReadToken,
|
|
1529
|
+
key_export_token: keyExportToken
|
|
1527
1530
|
});
|
|
1528
1531
|
return await _runSensitiveFlow({
|
|
1529
1532
|
title: "Export key",
|
package/dist/index.mjs
CHANGED
|
@@ -1506,15 +1506,18 @@ var useExportKey = () => {
|
|
|
1506
1506
|
scopes: SCOPES_EXPORT_KEY
|
|
1507
1507
|
});
|
|
1508
1508
|
const keyshareReadToken = tokens.keyshare_read?.token ?? "";
|
|
1509
|
+
const keyExportToken = tokens.key_export?.token ?? "";
|
|
1509
1510
|
const params = new URLSearchParams({
|
|
1510
1511
|
publishableKey: sdk.publishableKey,
|
|
1511
1512
|
wallet_id: wallet.id ?? "",
|
|
1512
|
-
wallet_type: wallet.wallet_type ?? ""
|
|
1513
|
+
wallet_type: wallet.wallet_type ?? "",
|
|
1514
|
+
...!userHandleB64url && !credentialIdB64url ? { kms_eligible: "true" } : {}
|
|
1513
1515
|
});
|
|
1514
1516
|
const secrets = new URLSearchParams({
|
|
1515
1517
|
user_handle_b64url: userHandleB64url,
|
|
1516
1518
|
credential_id_b64url: credentialIdB64url,
|
|
1517
|
-
keyshare_read_token: keyshareReadToken
|
|
1519
|
+
keyshare_read_token: keyshareReadToken,
|
|
1520
|
+
key_export_token: keyExportToken
|
|
1518
1521
|
});
|
|
1519
1522
|
return await _runSensitiveFlow({
|
|
1520
1523
|
title: "Export key",
|
package/dist/solana.js
CHANGED
|
@@ -274,15 +274,18 @@ var useExportKey = () => {
|
|
|
274
274
|
scopes: import_sdk9.SCOPES_EXPORT_KEY
|
|
275
275
|
});
|
|
276
276
|
const keyshareReadToken = tokens.keyshare_read?.token ?? "";
|
|
277
|
+
const keyExportToken = tokens.key_export?.token ?? "";
|
|
277
278
|
const params = new URLSearchParams({
|
|
278
279
|
publishableKey: sdk.publishableKey,
|
|
279
280
|
wallet_id: wallet.id ?? "",
|
|
280
|
-
wallet_type: wallet.wallet_type ?? ""
|
|
281
|
+
wallet_type: wallet.wallet_type ?? "",
|
|
282
|
+
...!userHandleB64url && !credentialIdB64url ? { kms_eligible: "true" } : {}
|
|
281
283
|
});
|
|
282
284
|
const secrets = new URLSearchParams({
|
|
283
285
|
user_handle_b64url: userHandleB64url,
|
|
284
286
|
credential_id_b64url: credentialIdB64url,
|
|
285
|
-
keyshare_read_token: keyshareReadToken
|
|
287
|
+
keyshare_read_token: keyshareReadToken,
|
|
288
|
+
key_export_token: keyExportToken
|
|
286
289
|
});
|
|
287
290
|
return await _runSensitiveFlow({
|
|
288
291
|
title: "Export key",
|
package/dist/solana.mjs
CHANGED
|
@@ -285,15 +285,18 @@ var useExportKey = () => {
|
|
|
285
285
|
scopes: SCOPES_EXPORT_KEY
|
|
286
286
|
});
|
|
287
287
|
const keyshareReadToken = tokens.keyshare_read?.token ?? "";
|
|
288
|
+
const keyExportToken = tokens.key_export?.token ?? "";
|
|
288
289
|
const params = new URLSearchParams({
|
|
289
290
|
publishableKey: sdk.publishableKey,
|
|
290
291
|
wallet_id: wallet.id ?? "",
|
|
291
|
-
wallet_type: wallet.wallet_type ?? ""
|
|
292
|
+
wallet_type: wallet.wallet_type ?? "",
|
|
293
|
+
...!userHandleB64url && !credentialIdB64url ? { kms_eligible: "true" } : {}
|
|
292
294
|
});
|
|
293
295
|
const secrets = new URLSearchParams({
|
|
294
296
|
user_handle_b64url: userHandleB64url,
|
|
295
297
|
credential_id_b64url: credentialIdB64url,
|
|
296
|
-
keyshare_read_token: keyshareReadToken
|
|
298
|
+
keyshare_read_token: keyshareReadToken,
|
|
299
|
+
key_export_token: keyExportToken
|
|
297
300
|
});
|
|
298
301
|
return await _runSensitiveFlow({
|
|
299
302
|
title: "Export key",
|
package/dist/tron.js
CHANGED
|
@@ -273,15 +273,18 @@ var useExportKey = () => {
|
|
|
273
273
|
scopes: import_sdk9.SCOPES_EXPORT_KEY
|
|
274
274
|
});
|
|
275
275
|
const keyshareReadToken = tokens.keyshare_read?.token ?? "";
|
|
276
|
+
const keyExportToken = tokens.key_export?.token ?? "";
|
|
276
277
|
const params = new URLSearchParams({
|
|
277
278
|
publishableKey: sdk.publishableKey,
|
|
278
279
|
wallet_id: wallet.id ?? "",
|
|
279
|
-
wallet_type: wallet.wallet_type ?? ""
|
|
280
|
+
wallet_type: wallet.wallet_type ?? "",
|
|
281
|
+
...!userHandleB64url && !credentialIdB64url ? { kms_eligible: "true" } : {}
|
|
280
282
|
});
|
|
281
283
|
const secrets = new URLSearchParams({
|
|
282
284
|
user_handle_b64url: userHandleB64url,
|
|
283
285
|
credential_id_b64url: credentialIdB64url,
|
|
284
|
-
keyshare_read_token: keyshareReadToken
|
|
286
|
+
keyshare_read_token: keyshareReadToken,
|
|
287
|
+
key_export_token: keyExportToken
|
|
285
288
|
});
|
|
286
289
|
return await _runSensitiveFlow({
|
|
287
290
|
title: "Export key",
|
package/dist/tron.mjs
CHANGED
|
@@ -284,15 +284,18 @@ var useExportKey = () => {
|
|
|
284
284
|
scopes: SCOPES_EXPORT_KEY
|
|
285
285
|
});
|
|
286
286
|
const keyshareReadToken = tokens.keyshare_read?.token ?? "";
|
|
287
|
+
const keyExportToken = tokens.key_export?.token ?? "";
|
|
287
288
|
const params = new URLSearchParams({
|
|
288
289
|
publishableKey: sdk.publishableKey,
|
|
289
290
|
wallet_id: wallet.id ?? "",
|
|
290
|
-
wallet_type: wallet.wallet_type ?? ""
|
|
291
|
+
wallet_type: wallet.wallet_type ?? "",
|
|
292
|
+
...!userHandleB64url && !credentialIdB64url ? { kms_eligible: "true" } : {}
|
|
291
293
|
});
|
|
292
294
|
const secrets = new URLSearchParams({
|
|
293
295
|
user_handle_b64url: userHandleB64url,
|
|
294
296
|
credential_id_b64url: credentialIdB64url,
|
|
295
|
-
keyshare_read_token: keyshareReadToken
|
|
297
|
+
keyshare_read_token: keyshareReadToken,
|
|
298
|
+
key_export_token: keyExportToken
|
|
296
299
|
});
|
|
297
300
|
return await _runSensitiveFlow({
|
|
298
301
|
title: "Export key",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moon-x/react-native-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "Headless MoonX React Native SDK with WebView-backed transport, native passkeys, and app-owned UI.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vitest": "4.1.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@moon-x/core": "0.
|
|
65
|
+
"@moon-x/core": "0.28.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@expo/config-plugins": ">=10.0.0",
|
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
"dev": "tsup --watch",
|
|
96
96
|
"test": "vitest run",
|
|
97
97
|
"test:watch": "vitest",
|
|
98
|
+
"parity:export": "vitest run --config parity/vitest.config.ts",
|
|
98
99
|
"type-check": "tsc --noEmit",
|
|
99
100
|
"clean": "rm -rf dist .turbo node_modules"
|
|
100
101
|
}
|