@moon-x/react-native-sdk 0.26.0 → 0.28.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 +9 -3
- package/dist/ethereum.js +227 -51
- package/dist/ethereum.mjs +228 -43
- package/dist/index.d.mts +33 -3
- package/dist/index.d.ts +33 -3
- package/dist/index.js +790 -294
- package/dist/index.mjs +726 -221
- package/dist/solana.js +227 -51
- package/dist/solana.mjs +228 -43
- package/dist/tron.js +227 -51
- package/dist/tron.mjs +228 -43
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -390,20 +390,26 @@ Both methods use the configured `relyingPartyOrigin` when they need a passkey as
|
|
|
390
390
|
|
|
391
391
|
`MoonXProvider` shows a built-in prompt for the emailed code, so no wiring is needed. It draws nothing until a call needs a code, reprompts after a wrong code (up to five attempts on the same email), and closes when the code expires. Rejections to handle: `presence_otp_cancelled` (the user closed it) and `presence_otp_expired`.
|
|
392
392
|
|
|
393
|
-
|
|
393
|
+
It looks like the web SDK's prompt: a bottom sheet on phones with six code cells. It submits as soon as the sixth digit is typed, pasted or autofilled. It follows the device's light or dark setting and language (English, German, Spanish, French, Italian or Portuguese, otherwise English).
|
|
394
|
+
|
|
395
|
+
Pin the mode or language, restyle it or reword it through `config.presenceOtpPrompt`. `colors` and `copy` overrides apply on top of the light or dark defaults and the chosen language:
|
|
394
396
|
|
|
395
397
|
```tsx
|
|
396
398
|
<MoonXProvider
|
|
397
399
|
publishableKey="moon_pk_..."
|
|
398
400
|
config={{
|
|
399
401
|
presenceOtpPrompt: {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
+
displayMode: "dark", // "light" | "dark" | "auto" (default)
|
|
403
|
+
language: "es", // default: the device's
|
|
404
|
+
copy: { title: "Revisa tu correo", hint: "¿No llegó? Revisa la carpeta de spam." },
|
|
405
|
+
colors: { accent: "#7c3aed", accentText: "#ffffff" },
|
|
402
406
|
},
|
|
403
407
|
}}
|
|
404
408
|
>
|
|
405
409
|
```
|
|
406
410
|
|
|
411
|
+
`colors` keys: `background`, `surface`, `border`, `text`, `mutedText`, `accent`, `accentText`, `error`, `errorSurface` and `backdrop`. `copy` keys: `title`, `description`, `hint` (none by default), `verify`, `verifying`, `cancel`, `close`, `invalidCode`, `incompleteCode` and `codeLabel`.
|
|
412
|
+
|
|
407
413
|
To use your own UI everywhere, set `presenceOtpPrompt: false` and register a provider with `registerPresenceOtpCodeProvider`, exported from `@moon-x/react-native-sdk`. The provider receives a `PresenceOtpCodeRequest` and returns a promise for the entered code. Reject the promise when the user cancels. Call the returned cleanup function when the provider is no longer needed.
|
|
408
414
|
|
|
409
415
|
`registerPasskey` and `addPasskey` also accept `requestOtpCode`, to collect the code in the screen that started enrollment. It has the same signature and takes precedence over both the built-in prompt and a registered provider. Other operations that need a code, such as exporting a key or removing a passkey, always use the built-in prompt or the registered provider:
|
package/dist/ethereum.js
CHANGED
|
@@ -48,11 +48,11 @@ var import_ethereum = require("@moon-x/core/react/ethereum");
|
|
|
48
48
|
|
|
49
49
|
// src/hooks/use-export-key.ts
|
|
50
50
|
var import_sdk11 = require("@moon-x/core/sdk");
|
|
51
|
-
var
|
|
51
|
+
var import_utils7 = require("@moon-x/core/utils");
|
|
52
52
|
|
|
53
53
|
// src/provider.tsx
|
|
54
|
-
var
|
|
55
|
-
var
|
|
54
|
+
var import_react3 = require("react");
|
|
55
|
+
var import_react_native3 = require("react-native");
|
|
56
56
|
var import_react_native_webview = require("react-native-webview");
|
|
57
57
|
|
|
58
58
|
// src/sdk/create-sdk-instance.ts
|
|
@@ -161,100 +161,276 @@ var import_sdk7 = require("@moon-x/core/sdk");
|
|
|
161
161
|
var import_sdk8 = require("@moon-x/core/sdk");
|
|
162
162
|
|
|
163
163
|
// src/provider.tsx
|
|
164
|
-
var
|
|
164
|
+
var import_utils6 = require("@moon-x/core/utils");
|
|
165
165
|
|
|
166
166
|
// src/components/presence-otp-prompt.tsx
|
|
167
|
+
var import_react2 = __toESM(require("react"));
|
|
168
|
+
var import_react_native2 = require("react-native");
|
|
169
|
+
var import_sdk9 = require("@moon-x/core/sdk");
|
|
170
|
+
|
|
171
|
+
// src/components/use-reduce-motion.ts
|
|
167
172
|
var import_react = require("react");
|
|
168
173
|
var import_react_native = require("react-native");
|
|
169
|
-
|
|
174
|
+
|
|
175
|
+
// src/components/presence-otp-strings.ts
|
|
176
|
+
var import_utils3 = require("@moon-x/core/utils");
|
|
177
|
+
|
|
178
|
+
// src/components/presence-otp-prompt.tsx
|
|
170
179
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
171
|
-
var styles =
|
|
180
|
+
var styles = import_react_native2.StyleSheet.create({
|
|
172
181
|
backdrop: {
|
|
173
|
-
flex: 1
|
|
182
|
+
flex: 1
|
|
183
|
+
},
|
|
184
|
+
backdropSheet: {
|
|
185
|
+
justifyContent: "flex-end"
|
|
186
|
+
},
|
|
187
|
+
backdropCentered: {
|
|
174
188
|
alignItems: "center",
|
|
175
189
|
justifyContent: "center",
|
|
176
|
-
padding: 16
|
|
177
|
-
backgroundColor: "rgba(0, 0, 0, 0.45)"
|
|
190
|
+
padding: 16
|
|
178
191
|
},
|
|
179
192
|
card: {
|
|
180
193
|
width: "100%",
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
194
|
+
maxHeight: "100%",
|
|
195
|
+
overflow: "hidden"
|
|
196
|
+
},
|
|
197
|
+
sheet: {
|
|
198
|
+
borderTopLeftRadius: 24,
|
|
199
|
+
borderTopRightRadius: 24,
|
|
200
|
+
borderTopWidth: 1
|
|
201
|
+
},
|
|
202
|
+
centered: {
|
|
203
|
+
maxWidth: 400,
|
|
204
|
+
borderRadius: 24,
|
|
205
|
+
borderWidth: 1
|
|
206
|
+
},
|
|
207
|
+
header: {
|
|
208
|
+
flexDirection: "row",
|
|
209
|
+
justifyContent: "flex-end",
|
|
210
|
+
alignItems: "center",
|
|
211
|
+
height: 56,
|
|
212
|
+
paddingHorizontal: 16
|
|
213
|
+
},
|
|
214
|
+
iconButton: {
|
|
215
|
+
width: 32,
|
|
216
|
+
height: 32,
|
|
217
|
+
borderRadius: 8,
|
|
218
|
+
alignItems: "center",
|
|
219
|
+
justifyContent: "center"
|
|
220
|
+
},
|
|
221
|
+
content: {
|
|
222
|
+
paddingHorizontal: 24,
|
|
223
|
+
// Clear of the home indicator when the keyboard is down.
|
|
224
|
+
paddingBottom: 32
|
|
225
|
+
},
|
|
226
|
+
body: {
|
|
227
|
+
gap: 16
|
|
228
|
+
},
|
|
229
|
+
hero: {
|
|
230
|
+
alignItems: "center",
|
|
231
|
+
gap: 16,
|
|
232
|
+
paddingTop: 8
|
|
233
|
+
},
|
|
234
|
+
iconDisc: {
|
|
235
|
+
width: 64,
|
|
236
|
+
height: 64,
|
|
237
|
+
borderRadius: 32,
|
|
238
|
+
alignItems: "center",
|
|
239
|
+
justifyContent: "center"
|
|
240
|
+
},
|
|
241
|
+
heroText: {
|
|
242
|
+
width: "100%",
|
|
243
|
+
gap: 4
|
|
184
244
|
},
|
|
185
245
|
title: {
|
|
186
246
|
fontSize: 20,
|
|
187
|
-
|
|
247
|
+
lineHeight: 24,
|
|
248
|
+
fontWeight: "500",
|
|
249
|
+
letterSpacing: -0.4,
|
|
250
|
+
textAlign: "center"
|
|
188
251
|
},
|
|
189
|
-
|
|
252
|
+
description: {
|
|
190
253
|
fontSize: 14,
|
|
191
|
-
|
|
254
|
+
lineHeight: 20,
|
|
255
|
+
textAlign: "center"
|
|
192
256
|
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
257
|
+
cells: {
|
|
258
|
+
flexDirection: "row",
|
|
259
|
+
alignItems: "center",
|
|
260
|
+
justifyContent: "center",
|
|
261
|
+
gap: 8
|
|
262
|
+
},
|
|
263
|
+
cellsCompact: {
|
|
264
|
+
gap: 6
|
|
265
|
+
},
|
|
266
|
+
cellsBusy: {
|
|
267
|
+
opacity: 0.6
|
|
268
|
+
},
|
|
269
|
+
cell: {
|
|
270
|
+
width: 44,
|
|
271
|
+
height: 52,
|
|
272
|
+
borderWidth: 1,
|
|
197
273
|
borderRadius: 12,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
274
|
+
alignItems: "center",
|
|
275
|
+
justifyContent: "center"
|
|
276
|
+
},
|
|
277
|
+
cellCompact: {
|
|
278
|
+
width: 38,
|
|
279
|
+
height: 48
|
|
280
|
+
},
|
|
281
|
+
cellText: {
|
|
282
|
+
fontSize: 18,
|
|
283
|
+
fontWeight: "500",
|
|
284
|
+
fontVariant: ["tabular-nums"]
|
|
285
|
+
},
|
|
286
|
+
caret: {
|
|
287
|
+
width: 1.5,
|
|
288
|
+
height: 20,
|
|
289
|
+
borderRadius: 1
|
|
290
|
+
},
|
|
291
|
+
separator: {
|
|
292
|
+
width: 4,
|
|
293
|
+
height: 4,
|
|
294
|
+
borderRadius: 2,
|
|
295
|
+
marginHorizontal: 4,
|
|
296
|
+
opacity: 0.6
|
|
297
|
+
},
|
|
298
|
+
codeInput: {
|
|
299
|
+
position: "absolute",
|
|
300
|
+
top: 0,
|
|
301
|
+
right: 0,
|
|
302
|
+
bottom: 0,
|
|
303
|
+
left: 0,
|
|
304
|
+
// Not 0: iOS stops delivering touches to a view that is fully transparent.
|
|
305
|
+
opacity: 0.015,
|
|
306
|
+
color: "transparent",
|
|
307
|
+
backgroundColor: "transparent",
|
|
308
|
+
borderWidth: 0
|
|
202
309
|
},
|
|
203
310
|
error: {
|
|
204
|
-
|
|
205
|
-
|
|
311
|
+
flexDirection: "row",
|
|
312
|
+
alignItems: "center",
|
|
313
|
+
justifyContent: "center",
|
|
314
|
+
gap: 4
|
|
206
315
|
},
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
316
|
+
errorText: {
|
|
317
|
+
flexShrink: 1,
|
|
318
|
+
fontSize: 12,
|
|
319
|
+
fontWeight: "500",
|
|
320
|
+
textAlign: "center"
|
|
212
321
|
},
|
|
213
|
-
|
|
214
|
-
|
|
322
|
+
actions: {
|
|
323
|
+
gap: 8,
|
|
324
|
+
paddingTop: 24
|
|
215
325
|
},
|
|
216
|
-
|
|
326
|
+
button: {
|
|
327
|
+
flexDirection: "row",
|
|
328
|
+
alignItems: "center",
|
|
329
|
+
justifyContent: "center",
|
|
330
|
+
gap: 8,
|
|
331
|
+
height: 48,
|
|
332
|
+
paddingHorizontal: 20,
|
|
333
|
+
borderRadius: 999
|
|
334
|
+
},
|
|
335
|
+
buttonText: {
|
|
217
336
|
fontSize: 16,
|
|
218
|
-
fontWeight: "
|
|
337
|
+
fontWeight: "500"
|
|
219
338
|
},
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
alignItems: "center"
|
|
339
|
+
pressed: {
|
|
340
|
+
opacity: 0.88,
|
|
341
|
+
transform: [{ scale: 0.985 }]
|
|
224
342
|
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
fontWeight: "500"
|
|
343
|
+
disabled: {
|
|
344
|
+
opacity: 0.5
|
|
228
345
|
},
|
|
229
346
|
hint: {
|
|
230
347
|
fontSize: 12,
|
|
231
|
-
|
|
348
|
+
lineHeight: 16,
|
|
232
349
|
textAlign: "center"
|
|
350
|
+
},
|
|
351
|
+
closeIcon: {
|
|
352
|
+
width: 16,
|
|
353
|
+
height: 16,
|
|
354
|
+
alignItems: "center",
|
|
355
|
+
justifyContent: "center"
|
|
356
|
+
},
|
|
357
|
+
closeBar: {
|
|
358
|
+
position: "absolute",
|
|
359
|
+
width: 12,
|
|
360
|
+
height: 1.5,
|
|
361
|
+
borderRadius: 1
|
|
362
|
+
},
|
|
363
|
+
mailIcon: {
|
|
364
|
+
width: 28,
|
|
365
|
+
height: 28
|
|
366
|
+
},
|
|
367
|
+
mailBody: {
|
|
368
|
+
position: "absolute",
|
|
369
|
+
top: 5,
|
|
370
|
+
left: 2,
|
|
371
|
+
width: 24,
|
|
372
|
+
height: 18,
|
|
373
|
+
borderWidth: 2,
|
|
374
|
+
borderRadius: 3
|
|
375
|
+
},
|
|
376
|
+
mailFlap: {
|
|
377
|
+
position: "absolute",
|
|
378
|
+
top: 10.6,
|
|
379
|
+
width: 13,
|
|
380
|
+
height: 2,
|
|
381
|
+
borderRadius: 1
|
|
382
|
+
},
|
|
383
|
+
mailFlapLeft: {
|
|
384
|
+
left: 2,
|
|
385
|
+
transform: [{ rotate: "29.8deg" }]
|
|
386
|
+
},
|
|
387
|
+
mailFlapRight: {
|
|
388
|
+
left: 13,
|
|
389
|
+
transform: [{ rotate: "-29.8deg" }]
|
|
390
|
+
},
|
|
391
|
+
alertIcon: {
|
|
392
|
+
width: 14,
|
|
393
|
+
height: 14,
|
|
394
|
+
borderRadius: 7,
|
|
395
|
+
borderWidth: 1.25,
|
|
396
|
+
alignItems: "center",
|
|
397
|
+
justifyContent: "center",
|
|
398
|
+
gap: 1
|
|
399
|
+
},
|
|
400
|
+
alertStem: {
|
|
401
|
+
width: 1.5,
|
|
402
|
+
height: 4,
|
|
403
|
+
borderRadius: 1
|
|
404
|
+
},
|
|
405
|
+
alertDot: {
|
|
406
|
+
width: 1.5,
|
|
407
|
+
height: 1.5,
|
|
408
|
+
borderRadius: 1
|
|
233
409
|
}
|
|
234
410
|
});
|
|
235
411
|
|
|
236
412
|
// src/transport/webview-bridge.ts
|
|
237
|
-
var
|
|
413
|
+
var import_utils4 = require("@moon-x/core/utils");
|
|
238
414
|
|
|
239
415
|
// src/provider.tsx
|
|
240
|
-
var
|
|
416
|
+
var import_react4 = require("@moon-x/core/react");
|
|
241
417
|
var import_lib2 = require("@moon-x/core/lib");
|
|
242
418
|
|
|
243
419
|
// src/session-resume.ts
|
|
244
420
|
var import_sdk10 = require("@moon-x/core/sdk");
|
|
245
|
-
var
|
|
421
|
+
var import_utils5 = require("@moon-x/core/utils");
|
|
246
422
|
|
|
247
423
|
// src/provider.tsx
|
|
248
424
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
249
|
-
var MoonXContext = (0,
|
|
425
|
+
var MoonXContext = (0, import_react3.createContext)(null);
|
|
250
426
|
var useMoonXContext = () => {
|
|
251
|
-
const ctx = (0,
|
|
427
|
+
const ctx = (0, import_react3.useContext)(MoonXContext);
|
|
252
428
|
if (!ctx) {
|
|
253
429
|
throw new Error("useMoonX must be used within a MoonXProvider");
|
|
254
430
|
}
|
|
255
431
|
return ctx;
|
|
256
432
|
};
|
|
257
|
-
var styles2 =
|
|
433
|
+
var styles2 = import_react_native3.StyleSheet.create({
|
|
258
434
|
backdrop: {
|
|
259
435
|
position: "absolute",
|
|
260
436
|
top: 0,
|
|
@@ -304,7 +480,7 @@ var styles2 = import_react_native2.StyleSheet.create({
|
|
|
304
480
|
paddingBottom: 12,
|
|
305
481
|
paddingHorizontal: 16,
|
|
306
482
|
backgroundColor: "#0a0a0a",
|
|
307
|
-
borderBottomWidth:
|
|
483
|
+
borderBottomWidth: import_react_native3.StyleSheet.hairlineWidth,
|
|
308
484
|
borderBottomColor: "#222"
|
|
309
485
|
},
|
|
310
486
|
// Empty flex spacer keeps the close button right-aligned without
|
|
@@ -369,8 +545,8 @@ var useExportKey = () => {
|
|
|
369
545
|
title: "Export key",
|
|
370
546
|
flowPath: `/export-key?${params.toString()}#${secrets.toString()}`,
|
|
371
547
|
onMount: ({ bridge, setResult }) => bridge.register(
|
|
372
|
-
|
|
373
|
-
|
|
548
|
+
import_utils7.PostMessageType.WALLET,
|
|
549
|
+
import_utils7.PostMessageMethod.EXPORT_KEY_RESULT,
|
|
374
550
|
(result) => {
|
|
375
551
|
setResult(parseExportKeyResult(result));
|
|
376
552
|
}
|