@arcblock/did-connect-react 3.4.13 → 3.4.15

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.
@@ -1,46 +1,44 @@
1
- import { jsx as a } from "react/jsx-runtime";
1
+ import { jsx as l } from "react/jsx-runtime";
2
2
  import e from "prop-types";
3
- import { useRef as l, useImperativeHandle as d } from "react";
3
+ import { useRef as d, useImperativeHandle as S } from "react";
4
4
  import { useMemoizedFn as y } from "ahooks";
5
- import { LOGIN_PROVIDER as P } from "@arcblock/ux/lib/Util/constant";
6
- import A from "../../../Passkey/actions.js";
7
- import { getAppId as I } from "../../../utils.js";
8
- import { useStateContext as R } from "../../contexts/state.js";
9
- function x({ ref: p = null, onSuccess: i, tokenState: o, behavior: n = "none", ...c }) {
10
- const { extraParams: r, lastLoginMethod: t } = R(), s = l(null), m = y(
11
- (f) => i(
12
- {
13
- ...f,
14
- encrypted: !1
15
- },
16
- (u) => u,
17
- {
18
- sourceAppPid: r?.sourceAppPid,
19
- connected_app: I(o.appInfo, o.memberAppInfo)
20
- }
21
- )
22
- );
23
- return d(p, () => ({
5
+ import { LAST_USED_LOGIN_METHOD as A, LOGIN_PROVIDER as p } from "@arcblock/ux/lib/Util/constant";
6
+ import I from "../../../Passkey/actions.js";
7
+ import { getAppId as P } from "../../../utils.js";
8
+ import { useStateContext as L } from "../../contexts/state.js";
9
+ function R({ ref: i = null, onSuccess: c, tokenState: o, behavior: n = "none", ...m }) {
10
+ const { extraParams: t, lastLoginMethod: r } = L(), s = d(null), a = y((u) => (localStorage.setItem(A, p.PASSKEY), c(
11
+ {
12
+ ...u,
13
+ encrypted: !1
14
+ },
15
+ (f) => f,
16
+ {
17
+ sourceAppPid: t?.sourceAppPid,
18
+ connected_app: P(o.appInfo, o.memberAppInfo)
19
+ }
20
+ )));
21
+ return S(i, () => ({
24
22
  connect: s.current.click
25
- })), n === "none" ? null : /* @__PURE__ */ a(
26
- A,
23
+ })), n === "none" ? null : /* @__PURE__ */ l(
24
+ I,
27
25
  {
28
- ...c,
26
+ ...m,
29
27
  ref: s,
30
- isLatest: t && t === P.PASSKEY,
28
+ isLatest: r && r === p.PASSKEY,
31
29
  action: o.action,
32
30
  behavior: n,
33
- onSuccess: m,
34
- extraParams: r
31
+ onSuccess: a,
32
+ extraParams: t
35
33
  }
36
34
  );
37
35
  }
38
- x.propTypes = {
36
+ R.propTypes = {
39
37
  onSuccess: e.func.isRequired,
40
38
  tokenState: e.object.isRequired,
41
39
  behavior: e.oneOf(["none", "both", "only-existing", "only-new"]),
42
40
  ref: e.any
43
41
  };
44
42
  export {
45
- x as default
43
+ R as default
46
44
  };
@@ -1,16 +1,16 @@
1
1
  import { jsx as p } from "react/jsx-runtime";
2
2
  import o from "prop-types";
3
- import { CircularProgress as _ } from "@mui/material";
4
- import { useReactive as w, useMemoizedFn as I, useCreation as f } from "ahooks";
5
- import { detectWalletExtension as C, openWebWallet as E } from "@arcblock/ux/lib/Util";
6
- import { mergeSx as O } from "@arcblock/ux/lib/Util/style";
3
+ import { CircularProgress as O } from "@mui/material";
4
+ import { useReactive as R, useMemoizedFn as I, useCreation as a } from "ahooks";
5
+ import { detectWalletExtension as w, openWebWallet as A } from "@arcblock/ux/lib/Util";
6
+ import { mergeSx as C } from "@arcblock/ux/lib/Util/style";
7
7
  import P from "lodash/noop";
8
- import v from "lodash/omit";
9
- import { useImperativeHandle as A } from "react";
8
+ import T from "lodash/omit";
9
+ import { useImperativeHandle as v } from "react";
10
10
  import y from "@arcblock/ux/lib/DIDConnect/provider-icon";
11
- import { LOGIN_PROVIDER_ICON_SIZE as a, LOGIN_PROVIDER as T } from "@arcblock/ux/lib/Util/constant";
12
- import N from "./login-method-item.js";
13
- import { useStateContext as U } from "../../contexts/state.js";
11
+ import { WALLET_LOGIN_METHOD as N, LOGIN_PROVIDER_ICON_SIZE as f, LOGIN_PROVIDER as M } from "@arcblock/ux/lib/Util/constant";
12
+ import U from "./login-method-item.js";
13
+ import { useStateContext as G } from "../../contexts/state.js";
14
14
  import { EXT_DOWNLOAD_URL as g } from "../../../constant.js";
15
15
  import j from "../../hooks/auth-url.js";
16
16
  function q({
@@ -18,54 +18,56 @@ function q({
18
18
  tokenState: r,
19
19
  locale: D = "en",
20
20
  webWalletUrl: b,
21
- onClick: h = P,
22
- disableSwitchApp: W = !1,
21
+ onClick: W = P,
22
+ disableSwitchApp: h = !1,
23
23
  autoConnect: t = !0,
24
24
  ...u
25
25
  }) {
26
- const { browserBrand: l } = U(), s = C(), n = w({
26
+ const { browserBrand: l, connectState: L } = G(), s = w(), n = R({
27
27
  loading: !1
28
- }), R = j({ disableSwitchApp: W, tokenState: r }), c = I(() => {
28
+ }), E = j({ disableSwitchApp: h, tokenState: r }), c = I(() => {
29
29
  if (!t)
30
30
  return;
31
- n.loading = !0, E({
31
+ n.loading = !0;
32
+ const e = A({
32
33
  webWalletUrl: b,
33
- url: R,
34
+ url: E,
34
35
  locale: D,
35
36
  appInfo: r.appInfo,
36
37
  memberAppInfo: r.memberAppInfo
37
- })?.type === "web" ? n.loading = !1 : setTimeout(() => {
38
+ });
39
+ L.walletMethod = N.WEB, e?.type === "web" ? n.loading = !1 : setTimeout(() => {
38
40
  n.loading = !1;
39
41
  }, 3e3);
40
42
  }), m = I((e) => {
41
- r.url && (h(e), e?.preventDefault(), c());
43
+ r.url && (W(e), e?.preventDefault(), c());
42
44
  });
43
- A(x, () => ({
45
+ v(x, () => ({
44
46
  connect: c
45
47
  }));
46
- const i = f(() => l === "edge" ? g.edge : l === "chrome" ? g.chrome : null, [l]), d = f(() => {
48
+ const i = a(() => l === "edge" ? g.edge : l === "chrome" ? g.chrome : null, [l]), d = a(() => {
47
49
  const e = {};
48
50
  return s || !t ? e.onClick = m : i && t ? (e.component = "a", e.href = i, e.target = "_blank", e.rel = "noopener") : e.onClick = m, r.url || (e.sx = {
49
51
  cursor: "not-allowed"
50
52
  }), e;
51
- }, [m, r.url]), L = f(() => t ? s || i ? "DID Wallet (Extension)" : "DID Wallet (Web)" : "DID Wallet", [s, i]);
53
+ }, [m, r.url]), _ = a(() => t ? s || i ? "DID Wallet (Extension)" : "DID Wallet (Web)" : "DID Wallet", [s, i]);
52
54
  return /* @__PURE__ */ p(
53
- N,
55
+ U,
54
56
  {
55
57
  ...u,
56
- sx: O(
58
+ sx: C(
57
59
  {
58
60
  textDecoration: "none"
59
61
  },
60
62
  u?.sx,
61
63
  d.sx
62
64
  ),
63
- title: L,
65
+ title: _,
64
66
  icon: n.loading || !r.url ? /* @__PURE__ */ p(
65
- _,
67
+ O,
66
68
  {
67
69
  color: "primary",
68
- size: a,
70
+ size: f,
69
71
  sx: {
70
72
  "& svg": {
71
73
  transform: "scale(0.75)"
@@ -76,14 +78,14 @@ function q({
76
78
  y,
77
79
  {
78
80
  sx: {
79
- width: a,
80
- height: a,
81
+ width: f,
82
+ height: f,
81
83
  transform: "scale(0.9)"
82
84
  },
83
- provider: T.DID_WALLET
85
+ provider: M.DID_WALLET
84
86
  }
85
87
  ),
86
- ...v(d, "sx")
88
+ ...T(d, "sx")
87
89
  }
88
90
  );
89
91
  }