@arcblock/did-connect-react 3.5.2 → 4.0.0-beta.2

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.
Files changed (171) hide show
  1. package/dist/ConnectContext.d.ts +13 -0
  2. package/dist/ConnectContext.d.ts.map +1 -0
  3. package/dist/ConnectContext.js +14 -0
  4. package/dist/ConnectContext.js.map +1 -0
  5. package/dist/ConnectProvider.d.ts +11 -0
  6. package/dist/ConnectProvider.d.ts.map +1 -0
  7. package/dist/ConnectProvider.js +23 -0
  8. package/dist/ConnectProvider.js.map +1 -0
  9. package/dist/compat/SessionProvider.d.ts +22 -0
  10. package/dist/compat/SessionProvider.d.ts.map +1 -0
  11. package/dist/compat/SessionProvider.js +17 -0
  12. package/dist/compat/SessionProvider.js.map +1 -0
  13. package/dist/compat/index.d.ts +4 -0
  14. package/dist/compat/index.d.ts.map +1 -0
  15. package/dist/compat/index.js +3 -0
  16. package/dist/compat/index.js.map +1 -0
  17. package/dist/compat/useSessionContext.d.ts +14 -0
  18. package/dist/compat/useSessionContext.d.ts.map +1 -0
  19. package/dist/compat/useSessionContext.js +20 -0
  20. package/dist/compat/useSessionContext.js.map +1 -0
  21. package/dist/components/LoginPage.d.ts +15 -0
  22. package/dist/components/LoginPage.d.ts.map +1 -0
  23. package/dist/components/LoginPage.js +33 -0
  24. package/dist/components/LoginPage.js.map +1 -0
  25. package/dist/components/UserAvatar.d.ts +19 -0
  26. package/dist/components/UserAvatar.d.ts.map +1 -0
  27. package/dist/components/UserAvatar.js +45 -0
  28. package/dist/components/UserAvatar.js.map +1 -0
  29. package/dist/hooks/index.d.ts +11 -0
  30. package/dist/hooks/index.d.ts.map +1 -0
  31. package/dist/hooks/index.js +6 -0
  32. package/dist/hooks/index.js.map +1 -0
  33. package/dist/hooks/useConnect.d.ts +15 -0
  34. package/dist/hooks/useConnect.d.ts.map +1 -0
  35. package/dist/hooks/useConnect.js +19 -0
  36. package/dist/hooks/useConnect.js.map +1 -0
  37. package/dist/hooks/useEmail.d.ts +11 -0
  38. package/dist/hooks/useEmail.d.ts.map +1 -0
  39. package/dist/hooks/useEmail.js +47 -0
  40. package/dist/hooks/useEmail.js.map +1 -0
  41. package/dist/hooks/useOAuth.d.ts +12 -0
  42. package/dist/hooks/useOAuth.d.ts.map +1 -0
  43. package/dist/hooks/useOAuth.js +75 -0
  44. package/dist/hooks/useOAuth.js.map +1 -0
  45. package/dist/hooks/usePasskey.d.ts +14 -0
  46. package/dist/hooks/usePasskey.d.ts.map +1 -0
  47. package/dist/hooks/usePasskey.js +35 -0
  48. package/dist/hooks/usePasskey.js.map +1 -0
  49. package/dist/hooks/useSession.d.ts +12 -0
  50. package/dist/hooks/useSession.d.ts.map +1 -0
  51. package/dist/hooks/useSession.js +30 -0
  52. package/dist/hooks/useSession.js.map +1 -0
  53. package/dist/index.d.ts +13 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +11 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/internals/blocklet-config.d.ts +22 -0
  58. package/dist/internals/blocklet-config.d.ts.map +1 -0
  59. package/dist/internals/blocklet-config.js +26 -0
  60. package/dist/internals/blocklet-config.js.map +1 -0
  61. package/dist/internals/local-storage-adapter.d.ts +12 -0
  62. package/dist/internals/local-storage-adapter.d.ts.map +1 -0
  63. package/dist/internals/local-storage-adapter.js +32 -0
  64. package/dist/internals/local-storage-adapter.js.map +1 -0
  65. package/dist/internals/use-sync-state.d.ts +18 -0
  66. package/dist/internals/use-sync-state.d.ts.map +1 -0
  67. package/dist/internals/use-sync-state.js +38 -0
  68. package/dist/internals/use-sync-state.js.map +1 -0
  69. package/package.json +33 -79
  70. package/LICENSE +0 -13
  71. package/README.md +0 -134
  72. package/dist/standalone/did-connect-react.css +0 -1
  73. package/dist/standalone/index.js +0 -136774
  74. package/lib/Address/index.js +0 -4
  75. package/lib/Avatar/index.js +0 -4
  76. package/lib/Button/index.js +0 -17
  77. package/lib/Connect/assets/locale.js +0 -147
  78. package/lib/Connect/assets/login-bg.png +0 -0
  79. package/lib/Connect/assets/login-slogan.js +0 -9
  80. package/lib/Connect/components/action-button.js +0 -26
  81. package/lib/Connect/components/app-tips.js +0 -132
  82. package/lib/Connect/components/auto-height.js +0 -31
  83. package/lib/Connect/components/back-button.js +0 -25
  84. package/lib/Connect/components/connect-status.js +0 -263
  85. package/lib/Connect/components/did-connect-title.js +0 -127
  86. package/lib/Connect/components/download-tips.js +0 -52
  87. package/lib/Connect/components/loading.js +0 -26
  88. package/lib/Connect/components/login-item/connect-choose-list.js +0 -257
  89. package/lib/Connect/components/login-item/connect-provider-list.js +0 -345
  90. package/lib/Connect/components/login-item/login-method-item.js +0 -147
  91. package/lib/Connect/components/login-item/mobile-login-item.js +0 -116
  92. package/lib/Connect/components/login-item/passkey-login-item.js +0 -44
  93. package/lib/Connect/components/login-item/wallet-login-options.js +0 -114
  94. package/lib/Connect/components/login-item/web-login-item.js +0 -104
  95. package/lib/Connect/components/mask-overlay.js +0 -34
  96. package/lib/Connect/components/refresh-overlay.js +0 -57
  97. package/lib/Connect/components/switch-app.js +0 -70
  98. package/lib/Connect/connect.js +0 -505
  99. package/lib/Connect/contexts/state.js +0 -156
  100. package/lib/Connect/fallback-connect.js +0 -53
  101. package/lib/Connect/fullpage.js +0 -5
  102. package/lib/Connect/hooks/auth-url.js +0 -23
  103. package/lib/Connect/hooks/method-list.js +0 -46
  104. package/lib/Connect/hooks/page-show.js +0 -17
  105. package/lib/Connect/hooks/provider-list.js +0 -69
  106. package/lib/Connect/hooks/security.js +0 -27
  107. package/lib/Connect/hooks/token.js +0 -296
  108. package/lib/Connect/hooks/use-apps.js +0 -19
  109. package/lib/Connect/hooks/use-quick-connect.js +0 -86
  110. package/lib/Connect/index.js +0 -16
  111. package/lib/Connect/landing-page.js +0 -5
  112. package/lib/Connect/plugins/email/index.js +0 -65
  113. package/lib/Connect/plugins/email/list-item.js +0 -31
  114. package/lib/Connect/plugins/email/placeholder.js +0 -284
  115. package/lib/Connect/plugins/index.js +0 -4
  116. package/lib/Connect/use-connect.js +0 -164
  117. package/lib/Connect/with-blocklet.js +0 -15
  118. package/lib/Connect/with-bridge-call.js +0 -108
  119. package/lib/Federated/context.js +0 -61
  120. package/lib/Federated/index.js +0 -7
  121. package/lib/Logo/index.js +0 -4
  122. package/lib/OAuth/bind-conflict-alert.js +0 -29
  123. package/lib/OAuth/context.js +0 -277
  124. package/lib/OAuth/guest.svg.js +0 -5
  125. package/lib/OAuth/index.js +0 -7
  126. package/lib/OAuth/passport-switcher.js +0 -5
  127. package/lib/Passkey/actions.js +0 -170
  128. package/lib/Passkey/constants.js +0 -4
  129. package/lib/Passkey/context.js +0 -281
  130. package/lib/Passkey/dialog.js +0 -280
  131. package/lib/Passkey/icon.js +0 -13
  132. package/lib/Passkey/index.js +0 -9
  133. package/lib/Service/index.js +0 -62
  134. package/lib/Session/assets/did-spaces-guide-cover.svg.js +0 -111
  135. package/lib/Session/assets/did-spaces-guide-icon.svg.js +0 -9
  136. package/lib/Session/context.js +0 -5
  137. package/lib/Session/did-spaces-guide.js +0 -136
  138. package/lib/Session/handler.js +0 -55
  139. package/lib/Session/hooks/use-federated.js +0 -64
  140. package/lib/Session/hooks/use-mobile.js +0 -8
  141. package/lib/Session/hooks/use-protected-routes.js +0 -11
  142. package/lib/Session/hooks/use-session-token.js +0 -181
  143. package/lib/Session/hooks/use-verify.js +0 -45
  144. package/lib/Session/index.js +0 -941
  145. package/lib/Session/libs/constants.js +0 -18
  146. package/lib/Session/libs/did-spaces.js +0 -10
  147. package/lib/Session/libs/federated.js +0 -42
  148. package/lib/Session/libs/index.js +0 -15
  149. package/lib/Session/libs/locales.js +0 -161
  150. package/lib/Session/libs/login-mobile.js +0 -55
  151. package/lib/Session/window-focus-aware.js +0 -17
  152. package/lib/SessionManager/index.js +0 -4
  153. package/lib/Storage/engine/cookie.js +0 -22
  154. package/lib/Storage/engine/local-storage.js +0 -37
  155. package/lib/Storage/index.js +0 -23
  156. package/lib/User/index.js +0 -6
  157. package/lib/User/use-did.js +0 -59
  158. package/lib/User/wrap-did.js +0 -13
  159. package/lib/WebWalletSWKeeper/index.js +0 -5
  160. package/lib/components/PassportSwitcher.js +0 -128
  161. package/lib/constant.js +0 -23
  162. package/lib/error.js +0 -8
  163. package/lib/hooks/use-locale.js +0 -7
  164. package/lib/index.js +0 -111
  165. package/lib/locales/en.js +0 -17
  166. package/lib/locales/index.js +0 -10
  167. package/lib/locales/zh.js +0 -17
  168. package/lib/node_modules/@blocklet/js-sdk/dist/index.js +0 -512
  169. package/lib/packages/did-connect/package.json.js +0 -7
  170. package/lib/types.d.ts +0 -355
  171. package/lib/utils.js +0 -225
@@ -1,147 +0,0 @@
1
- import { jsxs as i, jsx as e, Fragment as u } from "react/jsx-runtime";
2
- import { useTheme as b, Box as t, Tooltip as _, Typography as a } from "@mui/material";
3
- import { Icon as p } from "@iconify/react";
4
- import { isValidElement as I } from "react";
5
- import o from "prop-types";
6
- import S from "lodash/noop";
7
- import { mergeSx as d } from "@arcblock/ux/lib/Util/style";
8
- import { LOGIN_PROVIDER_ICON_SIZE as f } from "@arcblock/ux/lib/Util/constant";
9
- import N from "@iconify-icons/material-symbols/arrow-right-alt-rounded";
10
- function R({
11
- isLatest: r = !1,
12
- title: l,
13
- description: s = null,
14
- icon: n,
15
- iconScale: h = 0.95,
16
- slotProps: g = {},
17
- mode: x = "normal",
18
- t: y = S,
19
- ...c
20
- }) {
21
- const m = b();
22
- return /* @__PURE__ */ i(
23
- t,
24
- {
25
- ...c,
26
- className: "arc-login-item",
27
- sx: d(
28
- {
29
- position: "relative",
30
- display: "flex",
31
- alignItems: "center",
32
- gap: 1,
33
- cursor: "pointer",
34
- p: 1.2,
35
- borderRadius: 1,
36
- backgroundColor: r ? "grey.100" : "grey.50",
37
- border: r ? "1px solid" : "none",
38
- borderColor: r ? "grey.100" : "transparent",
39
- textDecoration: "none",
40
- transition: "background-color 0.5s",
41
- "&:hover, &:active, &.did-connect__choose-item__active": {
42
- backgroundColor: "grey.100"
43
- },
44
- "& .other-item-icon": {
45
- opacity: "0",
46
- transform: "translateX(-100%)",
47
- transition: "transform 0.2s ease, opacity 0.1s ease"
48
- },
49
- "&:hover": {
50
- "& .other-item-icon": {
51
- display: "inline-block",
52
- transform: "translateX(0)",
53
- opacity: "1"
54
- }
55
- }
56
- },
57
- c?.sx
58
- ),
59
- children: [
60
- /* @__PURE__ */ e(_, { title: l, children: /* @__PURE__ */ e(
61
- t,
62
- {
63
- className: "arc-login-item__icon",
64
- sx: d(
65
- {
66
- display: "flex",
67
- justifyContent: "center",
68
- alignItems: "center",
69
- color: "text.primary"
70
- },
71
- g?.icon?.sx
72
- ),
73
- children: I(n) ? n : /* @__PURE__ */ e(
74
- t,
75
- {
76
- component: p,
77
- icon: n,
78
- sx: {
79
- transform: `scale(${h})`,
80
- width: f,
81
- height: f
82
- }
83
- }
84
- )
85
- }
86
- ) }),
87
- x === "normal" ? /* @__PURE__ */ i(u, { children: [
88
- /* @__PURE__ */ i(t, { className: "arc-login-item__body", sx: { display: "flex", flexDirection: "column", flex: 1 }, children: [
89
- /* @__PURE__ */ e(
90
- a,
91
- {
92
- sx: {
93
- fontSize: 14,
94
- fontWeight: "500",
95
- color: "text.primary",
96
- whiteSpace: "nowrap"
97
- },
98
- children: l
99
- }
100
- ),
101
- s ? /* @__PURE__ */ e(
102
- a,
103
- {
104
- sx: {
105
- color: "text.secondary",
106
- fontSize: 12,
107
- lineHeight: 1
108
- },
109
- children: s
110
- }
111
- ) : null
112
- ] }),
113
- r ? /* @__PURE__ */ e(
114
- a,
115
- {
116
- component: "span",
117
- className: "latest-badge",
118
- style: { color: m.palette.text.secondary, fontSize: 11 },
119
- children: y("lastUsed")
120
- }
121
- ) : /* @__PURE__ */ e(
122
- p,
123
- {
124
- className: "other-item-icon",
125
- icon: N,
126
- fontSize: "1.3rem",
127
- color: m.palette.primary.main
128
- }
129
- )
130
- ] }) : null
131
- ]
132
- }
133
- );
134
- }
135
- R.propTypes = {
136
- title: o.string.isRequired,
137
- description: o.string,
138
- icon: o.any.isRequired,
139
- iconScale: o.number,
140
- slotProps: o.object,
141
- mode: o.oneOf(["mini", "simple", "normal"]),
142
- isLatest: o.bool,
143
- t: o.func
144
- };
145
- export {
146
- R as default
147
- };
@@ -1,116 +0,0 @@
1
- import { jsx as p } from "react/jsx-runtime";
2
- import n from "prop-types";
3
- import { CircularProgress as _ } from "@mui/material";
4
- import { useReactive as v, useCreation as N, useMemoizedFn as l } from "ahooks";
5
- import W from "@arcblock/bridge";
6
- import { useBrowser as q } from "@arcblock/react-hooks";
7
- import B from "lodash/noop";
8
- import { useImperativeHandle as F } from "react";
9
- import { mergeSx as G } from "@arcblock/ux/lib/Util/style";
10
- import j from "@arcblock/ux/lib/DIDConnect/provider-icon";
11
- import { WALLET_LOGIN_METHOD as f, LOGIN_PROVIDER_ICON_SIZE as d, LOGIN_PROVIDER as z } from "@arcblock/ux/lib/Util/constant";
12
- import { useStateContext as H } from "../../contexts/state.js";
13
- import J from "./login-method-item.js";
14
- import { logger as L } from "../../../utils.js";
15
- import K from "../../hooks/auth-url.js";
16
- function V({
17
- isTablet: C = !1,
18
- ref: A = null,
19
- tokenState: e,
20
- locale: P,
21
- tokenKey: y,
22
- onClick: R = B,
23
- disableSwitchApp: O = !1,
24
- ...h
25
- }) {
26
- const a = v({
27
- loading: !1
28
- }), { isWalletWebview: u, connectState: c } = H(), x = "DID Wallet", m = q(), I = new URL(window.location.href), E = K({ disableSwitchApp: O, tokenState: e }), g = N(() => {
29
- if (!e.url)
30
- return "";
31
- I.searchParams.set("tokenKey", e.token);
32
- const o = new URL(E);
33
- m.wallet || (o.searchParams.set("callback", encodeURIComponent(I)), o.searchParams.set("callback_delay", 1500)), o.searchParams.set("locale", P);
34
- const w = new TextEncoder(), U = o.href.length;
35
- let r = "", s = "";
36
- try {
37
- if (e.appInfo) {
38
- const i = w.encode(JSON.stringify(e.appInfo));
39
- r = btoa(String.fromCharCode(...i));
40
- }
41
- if (e.memberAppInfo) {
42
- const i = w.encode(JSON.stringify(e.memberAppInfo));
43
- s = btoa(String.fromCharCode(...i));
44
- }
45
- if (U + 8 + r.length + 14 + s.length > 2e3)
46
- throw L.warn("URL too long, drop appInfo & memberAppInfo", { appInfo: r, memberAppInfo: s }), new Error("URL too long");
47
- s ? r && (o.searchParams.set("appInfo", r), o.searchParams.set("memberAppInfo", s)) : r && o.searchParams.set("appInfo", r);
48
- } catch (i) {
49
- L.warn("Failed to convert appInfo & memberAppInfo", i);
50
- }
51
- return o.href.replace(/^https?:\/\//, "abt://");
52
- }, [y, e.token, e.appInfo, e.memberAppInfo, e.url]), M = l(() => {
53
- a.loading = !0, setTimeout(() => {
54
- W.call("authAction", { action: "auth", deepLink: g });
55
- }, 600), setTimeout(() => {
56
- a.loading = !1;
57
- }, 2e3);
58
- }), T = l(() => {
59
- e.checking = !0, e.status = "scanned";
60
- }), t = {};
61
- !u && m.mobile.any && (t.component = "a", t.href = g), e.url || (t.sx = {
62
- cursor: "not-allowed"
63
- });
64
- const b = l((o) => {
65
- e.url && (u ? (c.walletMethod = f.MOBILE, M()) : m.mobile.any || C ? (c.walletMethod = f.MOBILE, T()) : (c.walletMethod = f.SCAN, o()));
66
- }), D = l(() => {
67
- b(R);
68
- });
69
- return F(A, () => ({
70
- connect: b
71
- })), /* @__PURE__ */ p(
72
- J,
73
- {
74
- ...h,
75
- ...t,
76
- sx: G(h?.sx, t?.sx),
77
- title: x,
78
- icon: a.loading || !e.url ? /* @__PURE__ */ p(
79
- _,
80
- {
81
- color: "primary",
82
- size: d,
83
- sx: {
84
- "& svg": {
85
- transform: "scale(0.75)"
86
- }
87
- }
88
- }
89
- ) : /* @__PURE__ */ p(
90
- j,
91
- {
92
- provider: z.DID_WALLET,
93
- sx: {
94
- width: d,
95
- height: d,
96
- transform: "scale(0.9)"
97
- }
98
- }
99
- ),
100
- iconScale: 1,
101
- onClick: D
102
- }
103
- );
104
- }
105
- V.propTypes = {
106
- tokenState: n.object.isRequired,
107
- tokenKey: n.string.isRequired,
108
- locale: n.string.isRequired,
109
- onClick: n.func,
110
- disableSwitchApp: n.bool,
111
- ref: n.any,
112
- isTablet: n.bool
113
- };
114
- export {
115
- V as default
116
- };
@@ -1,44 +0,0 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import e from "prop-types";
3
- import { useRef as d, useImperativeHandle as S } from "react";
4
- import { useMemoizedFn as y } from "ahooks";
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, () => ({
22
- connect: s.current.click
23
- })), n === "none" ? null : /* @__PURE__ */ l(
24
- I,
25
- {
26
- ...m,
27
- ref: s,
28
- isLatest: r && r === p.PASSKEY,
29
- action: o.action,
30
- behavior: n,
31
- onSuccess: a,
32
- extraParams: t
33
- }
34
- );
35
- }
36
- R.propTypes = {
37
- onSuccess: e.func.isRequired,
38
- tokenState: e.object.isRequired,
39
- behavior: e.oneOf(["none", "both", "only-existing", "only-new"]),
40
- ref: e.any
41
- };
42
- export {
43
- R as default
44
- };
@@ -1,114 +0,0 @@
1
- import { jsxs as f, Fragment as p, jsx as e } from "react/jsx-runtime";
2
- import o from "prop-types";
3
- import { Box as i, Divider as q } from "@mui/material";
4
- import { LOGIN_PROVIDER as u } from "@arcblock/ux/lib/Util/constant";
5
- import { checkSameProtocol as T, getWebWalletUrl as j } from "@arcblock/ux/lib/Util/wallet";
6
- import { detectWalletExtension as v } from "@arcblock/ux/lib/Util";
7
- import { useCreation as I } from "ahooks";
8
- import { useBrowser as P } from "@arcblock/react-hooks";
9
- import A from "./mobile-login-item.js";
10
- import B from "./web-login-item.js";
11
- import E from "../back-button.js";
12
- import { useStateContext as O } from "../../contexts/state.js";
13
- function S({
14
- qrcode: g,
15
- tokenState: r,
16
- webWalletUrl: n = j(),
17
- size: l = "small",
18
- disableSwitchApp: s = !1,
19
- tokenKey: x,
20
- walletLoginRef: b = null,
21
- webLoginRef: h = null,
22
- onMobileLoginClick: L,
23
- onWebLoginClick: C,
24
- onBack: a
25
- }) {
26
- const { t: c, locale: R } = O(), w = P(), k = T(n), m = v(), d = I(() => {
27
- const t = navigator.userAgent.toLowerCase(), y = /ipad/.test(t) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1, W = /android/.test(t) && !/mobile/.test(t);
28
- return !!(y || W);
29
- }, []);
30
- return /* @__PURE__ */ f(p, { children: [
31
- g,
32
- /* @__PURE__ */ f(i, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 1.5 }, children: [
33
- /* @__PURE__ */ e(i, { sx: { width: "100%" }, children: /* @__PURE__ */ e(
34
- q,
35
- {
36
- orientation: "horizontal",
37
- sx: {
38
- fontSize: 12,
39
- color: "text.hint",
40
- "&::before, &::after": {
41
- borderColor: "divider"
42
- }
43
- },
44
- children: "or"
45
- }
46
- ) }),
47
- /* @__PURE__ */ e(
48
- i,
49
- {
50
- sx: {
51
- width: "100%",
52
- ".arc-login-item": {
53
- width: "100%",
54
- justifyContent: "center",
55
- "& > .arc-login-item__body": {
56
- flex: "unset"
57
- },
58
- "& > .other-item-icon": {
59
- display: "none !important"
60
- }
61
- }
62
- },
63
- children: d ? /* @__PURE__ */ e(
64
- A,
65
- {
66
- t: c,
67
- ref: b,
68
- tokenState: r,
69
- isTablet: d,
70
- sx: [l === "small" ? { p: 1 } : { p: 2 }],
71
- locale: R,
72
- tokenKey: x,
73
- disableSwitchApp: s,
74
- onClick: L
75
- },
76
- u.WALLET
77
- ) : (
78
- // eslint-disable-next-line react/jsx-no-useless-fragment
79
- /* @__PURE__ */ e(p, { children: (k || m) && (!w.mobile.any || m) ? /* @__PURE__ */ e(
80
- B,
81
- {
82
- t: c,
83
- ref: h,
84
- tokenState: r,
85
- webWalletUrl: n,
86
- sx: [l === "small" ? { p: 1 } : { p: 2 }],
87
- disableSwitchApp: s,
88
- onClick: C
89
- },
90
- u.WALLET
91
- ) : null })
92
- )
93
- }
94
- ),
95
- a && /* @__PURE__ */ e(E, { variant: "text", onClick: a })
96
- ] })
97
- ] });
98
- }
99
- S.propTypes = {
100
- qrcode: o.node.isRequired,
101
- tokenState: o.object.isRequired,
102
- webWalletUrl: o.string,
103
- size: o.oneOf(["small", "normal", "large"]),
104
- disableSwitchApp: o.bool,
105
- tokenKey: o.string.isRequired,
106
- walletLoginRef: o.object,
107
- webLoginRef: o.object,
108
- onMobileLoginClick: o.func.isRequired,
109
- onWebLoginClick: o.func.isRequired,
110
- onBack: o.func.isRequired
111
- };
112
- export {
113
- S as default
114
- };
@@ -1,104 +0,0 @@
1
- import { jsx as p } from "react/jsx-runtime";
2
- import o from "prop-types";
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
- import P from "lodash/noop";
8
- import T from "lodash/omit";
9
- import { useImperativeHandle as v } from "react";
10
- import y from "@arcblock/ux/lib/DIDConnect/provider-icon";
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
- import { EXT_DOWNLOAD_URL as g } from "../../../constant.js";
15
- import j from "../../hooks/auth-url.js";
16
- function q({
17
- ref: x = null,
18
- tokenState: r,
19
- locale: D = "en",
20
- webWalletUrl: b,
21
- onClick: W = P,
22
- disableSwitchApp: h = !1,
23
- autoConnect: t = !0,
24
- ...u
25
- }) {
26
- const { browserBrand: l, connectState: L } = G(), s = w(), n = R({
27
- loading: !1
28
- }), E = j({ disableSwitchApp: h, tokenState: r }), c = I(() => {
29
- if (!t)
30
- return;
31
- n.loading = !0;
32
- const e = A({
33
- webWalletUrl: b,
34
- url: E,
35
- locale: D,
36
- appInfo: r.appInfo,
37
- memberAppInfo: r.memberAppInfo
38
- });
39
- L.walletMethod = N.WEB, e?.type === "web" ? n.loading = !1 : setTimeout(() => {
40
- n.loading = !1;
41
- }, 3e3);
42
- }), m = I((e) => {
43
- r.url && (W(e), e?.preventDefault(), c());
44
- });
45
- v(x, () => ({
46
- connect: c
47
- }));
48
- const i = a(() => l === "edge" ? g.edge : l === "chrome" ? g.chrome : null, [l]), d = a(() => {
49
- const e = {};
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 = {
51
- cursor: "not-allowed"
52
- }), e;
53
- }, [m, r.url]), _ = a(() => t ? s || i ? "DID Wallet (Extension)" : "DID Wallet (Web)" : "DID Wallet", [s, i]);
54
- return /* @__PURE__ */ p(
55
- U,
56
- {
57
- ...u,
58
- sx: C(
59
- {
60
- textDecoration: "none"
61
- },
62
- u?.sx,
63
- d.sx
64
- ),
65
- title: _,
66
- icon: n.loading || !r.url ? /* @__PURE__ */ p(
67
- O,
68
- {
69
- color: "primary",
70
- size: f,
71
- sx: {
72
- "& svg": {
73
- transform: "scale(0.75)"
74
- }
75
- }
76
- }
77
- ) : /* @__PURE__ */ p(
78
- y,
79
- {
80
- sx: {
81
- width: f,
82
- height: f,
83
- transform: "scale(0.9)"
84
- },
85
- provider: M.DID_WALLET
86
- }
87
- ),
88
- ...T(d, "sx")
89
- }
90
- );
91
- }
92
- q.propTypes = {
93
- tokenState: o.object.isRequired,
94
- locale: o.string,
95
- webWalletUrl: o.string.isRequired,
96
- onClick: o.func,
97
- disableSwitchApp: o.bool,
98
- autoConnect: o.bool,
99
- // 点击后是否自动连接,默认true
100
- ref: o.any
101
- };
102
- export {
103
- q as default
104
- };
@@ -1,34 +0,0 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import p from "prop-types";
3
- import { Box as i, alpha as a } from "@mui/material";
4
- import { mergeSx as l } from "@arcblock/ux/lib/Util/style";
5
- function n({ children: r, ...o }) {
6
- return /* @__PURE__ */ e(
7
- i,
8
- {
9
- ...o,
10
- sx: l(
11
- {
12
- position: "absolute",
13
- top: 0,
14
- bottom: 0,
15
- left: 0,
16
- right: 0,
17
- display: "flex",
18
- justifyContent: "center",
19
- alignItems: "center",
20
- backgroundColor: ({ palette: t }) => a(t.background.default, 0.75),
21
- backdropFilter: "blur(3px)"
22
- },
23
- o?.sx
24
- ),
25
- children: r
26
- }
27
- );
28
- }
29
- n.propTypes = {
30
- children: p.any.isRequired
31
- };
32
- export {
33
- n as default
34
- };
@@ -1,57 +0,0 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import i from "prop-types";
3
- import { useTheme as a, Box as r } from "@mui/material";
4
- import { Icon as c } from "@iconify/react";
5
- import f from "@iconify-icons/material-symbols/refresh-rounded";
6
- function l({ onRefresh: n, ...e }) {
7
- const { palette: t } = a();
8
- return /* @__PURE__ */ o(
9
- r,
10
- {
11
- ...e,
12
- onClick: (s) => {
13
- s.stopPropagation(), n();
14
- },
15
- sx: {
16
- position: "absolute",
17
- top: 0,
18
- bottom: 0,
19
- left: 0,
20
- right: 0,
21
- display: "flex",
22
- justifyContent: "center",
23
- alignItems: "center",
24
- backgroundColor: "rgba(255, 255, 255, 0.75)",
25
- cursor: "pointer",
26
- ...e.sx
27
- },
28
- children: /* @__PURE__ */ o(
29
- r,
30
- {
31
- sx: {
32
- backgroundColor: "secondary.main",
33
- borderRadius: "100%",
34
- fontSize: 0
35
- },
36
- children: /* @__PURE__ */ o(
37
- c,
38
- {
39
- icon: f,
40
- fontSize: 52,
41
- style: {
42
- transform: "scale(0.7)",
43
- color: t.secondary.contrastText
44
- }
45
- }
46
- )
47
- }
48
- )
49
- }
50
- );
51
- }
52
- l.propTypes = {
53
- onRefresh: i.func.isRequired
54
- };
55
- export {
56
- l as default
57
- };
@@ -1,70 +0,0 @@
1
- import { jsxs as u, Fragment as f, jsx as r } from "react/jsx-runtime";
2
- import { useRef as m } from "react";
3
- import { Box as x, Menu as l, MenuItem as d } from "@mui/material";
4
- import { useReactive as h } from "ahooks";
5
- import { mergeSx as P } from "@arcblock/ux/lib/Util/style";
6
- import t from "prop-types";
7
- import { AppInfoItem as A } from "@arcblock/ux/lib/DIDConnect";
8
- import { useStateContext as y } from "../contexts/state.js";
9
- function S({ sx: s = {}, children: i }) {
10
- const { appInfoList: p, extraParams: c, connectState: a } = y(), n = m(null), e = h({
11
- open: !1
12
- });
13
- return p.length <= 1 ? null : /* @__PURE__ */ u(f, { children: [
14
- /* @__PURE__ */ r(
15
- x,
16
- {
17
- component: "span",
18
- ref: n,
19
- sx: P(
20
- {
21
- color: "text.secondary",
22
- cursor: "pointer"
23
- },
24
- s
25
- ),
26
- onClick: () => {
27
- e.open = !0;
28
- },
29
- children: i
30
- }
31
- ),
32
- /* @__PURE__ */ r(
33
- l,
34
- {
35
- anchorEl: n.current,
36
- open: e.open,
37
- onClose: () => {
38
- e.open = !1;
39
- },
40
- slotProps: {
41
- paper: {
42
- variant: "outlined",
43
- sx: {
44
- border: 0,
45
- boxShadow: ({ palette: o }) => `0px 4px 8px 0px ${o.grey[100]}, 0px 0px 0px 1px ${o.grey[100]}`,
46
- borderRadius: 1
47
- }
48
- }
49
- },
50
- children: p.map((o) => /* @__PURE__ */ r(
51
- d,
52
- {
53
- onClick: () => {
54
- e.open = !1, a.sourceAppPid = o.sourceAppPid;
55
- },
56
- children: /* @__PURE__ */ r(A, { appInfo: o, active: o.sourceAppPid === c?.sourceAppPid })
57
- },
58
- o.appPid
59
- ))
60
- }
61
- )
62
- ] });
63
- }
64
- S.propTypes = {
65
- sx: t.object,
66
- children: t.any.isRequired
67
- };
68
- export {
69
- S as default
70
- };