@arcblock/did-connect-react 3.4.8 → 3.4.9
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,10 +1,10 @@
|
|
|
1
|
-
import { useBrowser as
|
|
2
|
-
import { useRequest as
|
|
3
|
-
import
|
|
1
|
+
import { useBrowser as C } from "@arcblock/react-hooks";
|
|
2
|
+
import { useRequest as T, useCreation as p } from "ahooks";
|
|
3
|
+
import n from "lodash/isNil";
|
|
4
4
|
import { LOGIN_PROVIDER as s } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
-
import { getFederatedEnabled as
|
|
6
|
-
import { useState as
|
|
7
|
-
const
|
|
5
|
+
import { getFederatedEnabled as y, getMaster as D, getBlockletData as I } from "@arcblock/ux/lib/Util/federated";
|
|
6
|
+
import { useState as R } from "react";
|
|
7
|
+
const S = async ({ sourceAppPid: d }) => {
|
|
8
8
|
const t = globalThis?.blocklet;
|
|
9
9
|
if (!t)
|
|
10
10
|
return {
|
|
@@ -18,49 +18,52 @@ const B = async ({ sourceAppPid: d }) => {
|
|
|
18
18
|
enabled: !0
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
},
|
|
24
|
-
const t = await
|
|
25
|
-
return Object.entries(t).map(([e, o]) => ({ ...o, provider: e })).filter((e) => e.enabled).sort((e, o) => !
|
|
21
|
+
const l = y(t), e = D(t);
|
|
22
|
+
return l && e?.appPid && d === e?.appPid ? (await I(e.appUrl))?.settings?.authentication || {} : t?.settings?.authentication || {};
|
|
23
|
+
}, B = async ({ sourceAppPid: d } = {}) => {
|
|
24
|
+
const t = await S({ sourceAppPid: d });
|
|
25
|
+
return Object.entries(t).map(([e, o]) => ({ ...o, provider: e })).filter((e) => e.enabled).sort((e, o) => !n(e?.order) && !n(o?.order) ? e.order - o.order : n(e?.order) ? 1 : -1);
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function Y({
|
|
28
28
|
allowWallet: d = !0,
|
|
29
29
|
passkeyBehavior: t = "none",
|
|
30
|
-
action:
|
|
30
|
+
action: l,
|
|
31
31
|
sourceAppPid: e,
|
|
32
32
|
mode: o = "dialog",
|
|
33
|
-
blocklet:
|
|
33
|
+
blocklet: P = globalThis.blocklet,
|
|
34
34
|
isSmallView: L = !1,
|
|
35
|
-
lastLoginMethod:
|
|
35
|
+
lastLoginMethod: a = ""
|
|
36
36
|
}) {
|
|
37
|
-
const [
|
|
37
|
+
const [m, g] = R(!1), w = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], E = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], c = C(), { data: v = [] } = T(
|
|
38
38
|
async () => {
|
|
39
39
|
g(!0);
|
|
40
|
-
const
|
|
41
|
-
return g(!1),
|
|
40
|
+
const i = await B({ sourceAppPid: e });
|
|
41
|
+
return g(!1), i;
|
|
42
42
|
},
|
|
43
43
|
{ refreshDeps: [e] }
|
|
44
|
-
), f = p(() =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
), f = p(() => {
|
|
45
|
+
const i = globalThis?.blocklet?.DID_CONNECT_ENABLED_PROVIDERS?.split(",") || [];
|
|
46
|
+
return v.filter((r) => i.length > 0 && !i.includes(r.provider) ? !1 : r.provider === s.WALLET ? d : r.provider === s.PASSKEY ? t !== "none" && !c.wallet && !c.arcSphere : r.provider === s.EMAIL ? E.includes(l) && (P?.settings?.notification?.email?.enabled ?? !1) : !(r.type === "oauth" && !w.includes(l))).sort((r, u) => {
|
|
47
|
+
if (a) {
|
|
48
|
+
const h = r.provider === a, b = u.provider === a;
|
|
49
|
+
if (h && !b)
|
|
50
|
+
return -1;
|
|
51
|
+
if (!h && b)
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
return !n(r?.order) && !n(u?.order) ? r.order - u.order : n(r?.order) ? n(u?.order) ? 0 : 1 : -1;
|
|
55
|
+
});
|
|
56
|
+
}, [v, a]), A = p(() => {
|
|
57
|
+
const i = o === "drawer" || L && c.mobile.any;
|
|
58
|
+
return globalThis?.blocklet ? !!(f.find((r) => r.provider === s.WALLET)?.showQrcode !== !0 || i) : !!i;
|
|
56
59
|
}, [o, L, f]);
|
|
57
60
|
return {
|
|
58
61
|
hideChooseList: p(() => !1),
|
|
59
62
|
hideQRCode: A,
|
|
60
63
|
providerList: f,
|
|
61
|
-
loadingProviderList:
|
|
64
|
+
loadingProviderList: m
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
export {
|
|
65
|
-
|
|
68
|
+
Y as default
|
|
66
69
|
};
|
package/lib/package.json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/did-connect-react",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.9",
|
|
4
4
|
"description": "Client side library to work with DID Connect by ArcBlock.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@arcblock/bridge": "3.4.
|
|
36
|
-
"@arcblock/did": "^1.28.
|
|
37
|
-
"@arcblock/icons": "3.4.
|
|
38
|
-
"@arcblock/react-hooks": "3.4.
|
|
39
|
-
"@arcblock/ws": "^1.28.
|
|
35
|
+
"@arcblock/bridge": "3.4.9",
|
|
36
|
+
"@arcblock/did": "^1.28.6",
|
|
37
|
+
"@arcblock/icons": "3.4.9",
|
|
38
|
+
"@arcblock/react-hooks": "3.4.9",
|
|
39
|
+
"@arcblock/ws": "^1.28.6",
|
|
40
40
|
"@blocklet/constant": "^1.17.7",
|
|
41
41
|
"@fontsource/lexend": "^5.2.9",
|
|
42
42
|
"@iconify-icons/logos": "^1.2.36",
|
|
43
43
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
44
44
|
"@iconify/react": "^5.2.1",
|
|
45
|
-
"@ocap/util": "^1.28.
|
|
45
|
+
"@ocap/util": "^1.28.6",
|
|
46
46
|
"@simplewebauthn/browser": "^13.1.0",
|
|
47
47
|
"ahooks": "^3.8.5",
|
|
48
48
|
"axios": "^1.10.0",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
86
86
|
"jest": "^29.7.0"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "e01324f3084f688f514eed2b5fb8d1c4b3e4247e"
|
|
89
89
|
}
|
|
@@ -74,8 +74,14 @@ export default function useProviderList({
|
|
|
74
74
|
);
|
|
75
75
|
|
|
76
76
|
const showedLoginProviderList = useCreation(() => {
|
|
77
|
+
const allowedProviders = globalThis?.blocklet?.DID_CONNECT_ENABLED_PROVIDERS?.split(',') || [];
|
|
77
78
|
const result = loginProviderList
|
|
78
79
|
.filter((item) => {
|
|
80
|
+
if (allowedProviders.length > 0) {
|
|
81
|
+
if (!allowedProviders.includes(item.provider)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
79
85
|
if (item.provider === LOGIN_PROVIDER.WALLET) {
|
|
80
86
|
return allowWallet;
|
|
81
87
|
}
|