@arcblock/did-connect-react 3.1.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/LICENSE +13 -0
- package/README.md +134 -0
- package/lib/Address/index.js +4 -0
- package/lib/Avatar/index.js +4 -0
- package/lib/Button/index.js +17 -0
- package/lib/Connect/assets/locale.js +143 -0
- package/lib/Connect/assets/login-bg.png +0 -0
- package/lib/Connect/assets/login-slogan.js +9 -0
- package/lib/Connect/components/action-button.js +26 -0
- package/lib/Connect/components/app-tips.js +132 -0
- package/lib/Connect/components/auto-height.js +31 -0
- package/lib/Connect/components/back-button.js +24 -0
- package/lib/Connect/components/connect-status.js +263 -0
- package/lib/Connect/components/did-connect-title.js +126 -0
- package/lib/Connect/components/download-tips.js +52 -0
- package/lib/Connect/components/loading.js +26 -0
- package/lib/Connect/components/login-item/connect-choose-list.js +249 -0
- package/lib/Connect/components/login-item/login-method-item.js +129 -0
- package/lib/Connect/components/login-item/mobile-login-item.js +114 -0
- package/lib/Connect/components/login-item/passkey-login-item.js +44 -0
- package/lib/Connect/components/login-item/web-login-item.js +97 -0
- package/lib/Connect/components/mask-overlay.js +34 -0
- package/lib/Connect/components/refresh-overlay.js +57 -0
- package/lib/Connect/components/switch-app.js +70 -0
- package/lib/Connect/contexts/state.js +142 -0
- package/lib/Connect/fullpage.js +5 -0
- package/lib/Connect/hooks/auth-url.js +23 -0
- package/lib/Connect/hooks/method-list.js +46 -0
- package/lib/Connect/hooks/page-show.js +17 -0
- package/lib/Connect/hooks/security.js +27 -0
- package/lib/Connect/hooks/token.js +305 -0
- package/lib/Connect/hooks/use-apps.js +19 -0
- package/lib/Connect/hooks/use-quick-connect.js +97 -0
- package/lib/Connect/index.js +498 -0
- package/lib/Connect/landing-page.js +5 -0
- package/lib/Connect/plugins/email/index.js +62 -0
- package/lib/Connect/plugins/email/list-item.js +28 -0
- package/lib/Connect/plugins/email/placeholder.js +283 -0
- package/lib/Connect/plugins/index.js +4 -0
- package/lib/Connect/use-connect.js +164 -0
- package/lib/Connect/with-blocklet.js +15 -0
- package/lib/Connect/with-bridge-call.js +108 -0
- package/lib/Federated/context.js +61 -0
- package/lib/Federated/index.js +7 -0
- package/lib/Logo/index.js +4 -0
- package/lib/OAuth/context.js +234 -0
- package/lib/OAuth/guest.svg.js +5 -0
- package/lib/OAuth/index.js +7 -0
- package/lib/OAuth/passport-switcher.js +114 -0
- package/lib/Passkey/actions.js +165 -0
- package/lib/Passkey/constants.js +4 -0
- package/lib/Passkey/context.js +266 -0
- package/lib/Passkey/dialog.js +277 -0
- package/lib/Passkey/icon.js +13 -0
- package/lib/Passkey/index.js +9 -0
- package/lib/Service/index.js +62 -0
- package/lib/Session/assets/did-spaces-guide-cover.svg.js +135 -0
- package/lib/Session/assets/did-spaces-guide-icon.svg.js +9 -0
- package/lib/Session/context.js +5 -0
- package/lib/Session/did-spaces-guide.js +136 -0
- package/lib/Session/hooks/use-federated.js +64 -0
- package/lib/Session/hooks/use-mobile.js +8 -0
- package/lib/Session/hooks/use-protected-routes.js +11 -0
- package/lib/Session/hooks/use-session-token.js +169 -0
- package/lib/Session/hooks/use-verify.js +45 -0
- package/lib/Session/index.js +896 -0
- package/lib/Session/libs/constants.js +15 -0
- package/lib/Session/libs/did-spaces.js +10 -0
- package/lib/Session/libs/federated.js +42 -0
- package/lib/Session/libs/index.js +15 -0
- package/lib/Session/libs/locales.js +161 -0
- package/lib/Session/libs/login-mobile.js +55 -0
- package/lib/Session/window-focus-aware.js +17 -0
- package/lib/SessionManager/index.js +4 -0
- package/lib/Storage/engine/cookie.js +21 -0
- package/lib/Storage/engine/local-storage.js +36 -0
- package/lib/Storage/index.js +23 -0
- package/lib/User/index.js +6 -0
- package/lib/User/use-did.js +59 -0
- package/lib/User/wrap-did.js +13 -0
- package/lib/WebWalletSWKeeper/index.js +5 -0
- package/lib/constant.js +22 -0
- package/lib/error.js +8 -0
- package/lib/hooks/use-locale.js +7 -0
- package/lib/index.js +33 -0
- package/lib/locales/en.js +17 -0
- package/lib/locales/index.js +10 -0
- package/lib/locales/zh.js +17 -0
- package/lib/package.json.js +7 -0
- package/lib/types.d.ts +355 -0
- package/lib/utils.js +214 -0
- package/package.json +84 -0
- package/src/Address/index.jsx +2 -0
- package/src/Avatar/index.jsx +2 -0
- package/src/Button/Button.stories.jsx +7 -0
- package/src/Button/index.jsx +21 -0
- package/src/Connect/Connect.stories.jsx +34 -0
- package/src/Connect/assets/locale.js +145 -0
- package/src/Connect/assets/login-bg.png +0 -0
- package/src/Connect/assets/login-slogan.js +7 -0
- package/src/Connect/components/action-button.jsx +22 -0
- package/src/Connect/components/app-tips.jsx +156 -0
- package/src/Connect/components/auto-height.jsx +38 -0
- package/src/Connect/components/back-button.jsx +23 -0
- package/src/Connect/components/connect-status.jsx +259 -0
- package/src/Connect/components/did-connect-title.jsx +106 -0
- package/src/Connect/components/download-tips.jsx +55 -0
- package/src/Connect/components/loading.jsx +25 -0
- package/src/Connect/components/login-item/connect-choose-list.jsx +304 -0
- package/src/Connect/components/login-item/login-method-item.jsx +118 -0
- package/src/Connect/components/login-item/mobile-login-item.jsx +179 -0
- package/src/Connect/components/login-item/passkey-login-item.jsx +52 -0
- package/src/Connect/components/login-item/web-login-item.jsx +149 -0
- package/src/Connect/components/mask-overlay.jsx +32 -0
- package/src/Connect/components/refresh-overlay.jsx +52 -0
- package/src/Connect/components/switch-app.jsx +69 -0
- package/src/Connect/contexts/state.jsx +219 -0
- package/src/Connect/fullpage.jsx +3 -0
- package/src/Connect/hooks/auth-url.js +31 -0
- package/src/Connect/hooks/method-list.js +121 -0
- package/src/Connect/hooks/page-show.js +24 -0
- package/src/Connect/hooks/security.js +40 -0
- package/src/Connect/hooks/token.js +639 -0
- package/src/Connect/hooks/use-apps.js +69 -0
- package/src/Connect/hooks/use-quick-connect.js +130 -0
- package/src/Connect/index.jsx +600 -0
- package/src/Connect/landing-page.jsx +3 -0
- package/src/Connect/plugins/email/index.jsx +82 -0
- package/src/Connect/plugins/email/list-item.jsx +31 -0
- package/src/Connect/plugins/email/placeholder.jsx +365 -0
- package/src/Connect/plugins/index.js +2 -0
- package/src/Connect/use-connect.jsx +321 -0
- package/src/Connect/with-blocklet.jsx +26 -0
- package/src/Connect/with-bridge-call.jsx +138 -0
- package/src/Federated/context.jsx +93 -0
- package/src/Federated/index.jsx +1 -0
- package/src/Logo/index.jsx +2 -0
- package/src/OAuth/context.jsx +346 -0
- package/src/OAuth/guest.svg +20 -0
- package/src/OAuth/index.jsx +1 -0
- package/src/OAuth/passport-switcher.jsx +133 -0
- package/src/Passkey/actions.jsx +212 -0
- package/src/Passkey/constants.js +2 -0
- package/src/Passkey/context.jsx +381 -0
- package/src/Passkey/dialog.jsx +391 -0
- package/src/Passkey/icon.jsx +10 -0
- package/src/Passkey/index.jsx +2 -0
- package/src/Service/index.jsx +96 -0
- package/src/Session/assets/did-spaces-guide-cover.svg +128 -0
- package/src/Session/assets/did-spaces-guide-icon.svg +7 -0
- package/src/Session/context.jsx +7 -0
- package/src/Session/did-spaces-guide.jsx +173 -0
- package/src/Session/hooks/use-federated.js +88 -0
- package/src/Session/hooks/use-mobile.jsx +6 -0
- package/src/Session/hooks/use-protected-routes.js +16 -0
- package/src/Session/hooks/use-session-token.js +365 -0
- package/src/Session/hooks/use-verify.jsx +76 -0
- package/src/Session/index.jsx +1687 -0
- package/src/Session/libs/constants.js +14 -0
- package/src/Session/libs/did-spaces.js +38 -0
- package/src/Session/libs/federated.js +79 -0
- package/src/Session/libs/index.js +5 -0
- package/src/Session/libs/locales.js +160 -0
- package/src/Session/libs/login-mobile.js +80 -0
- package/src/Session/window-focus-aware.jsx +28 -0
- package/src/SessionManager/index.jsx +2 -0
- package/src/Storage/engine/cookie.js +23 -0
- package/src/Storage/engine/local-storage.js +55 -0
- package/src/Storage/index.js +25 -0
- package/src/User/index.js +4 -0
- package/src/User/use-did.js +80 -0
- package/src/User/wrap-did.jsx +18 -0
- package/src/WebWalletSWKeeper/index.jsx +3 -0
- package/src/constant.js +26 -0
- package/src/error.js +6 -0
- package/src/hooks/use-locale.jsx +6 -0
- package/src/index.js +43 -0
- package/src/locales/en.jsx +15 -0
- package/src/locales/index.jsx +13 -0
- package/src/locales/zh.jsx +15 -0
- package/src/types.d.ts +355 -0
- package/src/utils.js +395 -0
- package/vite.config.mjs +29 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const S = {
|
|
2
|
+
LOGIN: Symbol("login"),
|
|
3
|
+
CANCEL_LOGIN: Symbol("cancelLogin"),
|
|
4
|
+
LOGOUT: Symbol("logout"),
|
|
5
|
+
SWITCH_PROFILE: Symbol("switchProfile"),
|
|
6
|
+
CANCEL_SWITCH_PROFILE: Symbol("cancelSwitchProfile"),
|
|
7
|
+
SWITCH_PASSPORT: Symbol("switchPassport"),
|
|
8
|
+
CANCEL_SWITCH_PASSPORT: Symbol("cancelSwitchPassport"),
|
|
9
|
+
BIND_WALLET: Symbol("bindWallet"),
|
|
10
|
+
CANCEL_BIND_WALLET: Symbol("cancelBindWallet"),
|
|
11
|
+
DID_SPACE_CONNECTED: Symbol("didSpaceConnected")
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
S as EVENTS
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DID_SPACES_BASE_URL as t, BLOCKLET_SERVICE_PATH_PREFIX as d } from "../../constant.js";
|
|
2
|
+
async function c(i) {
|
|
3
|
+
if (i?.didSpace?.endpoint || !window.blocklet || window.self !== window.top || window.location.origin === new URL(t).origin || window.location.href.includes(d))
|
|
4
|
+
return !1;
|
|
5
|
+
const { componentMountPoints: o } = window.blocklet, [, e] = window.blocklet.componentId.split("/");
|
|
6
|
+
return o.some((n) => n?.capabilities?.didSpace === "requiredOnConnect" && e === n.did);
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
c as didSpacesIsRequired
|
|
10
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { joinURL as o } from "ufo";
|
|
2
|
+
import { getMaster as l, getFederatedEnabled as p } from "@arcblock/ux/lib/Util/federated";
|
|
3
|
+
import { createAxios as g, sleep as w } from "../../utils.js";
|
|
4
|
+
import { BLOCKLET_SERVICE_PATH_PREFIX as i } from "../../constant.js";
|
|
5
|
+
const c = g();
|
|
6
|
+
async function y() {
|
|
7
|
+
const t = o(i, "/api/federated/loginMaster"), { data: r } = await c.post(t);
|
|
8
|
+
return r;
|
|
9
|
+
}
|
|
10
|
+
async function h({ mode: t, refreshToken: r = "", blocklet: a }) {
|
|
11
|
+
const s = l(a);
|
|
12
|
+
return new Promise((n) => {
|
|
13
|
+
if (!["login", "logout"].includes(t)) {
|
|
14
|
+
n();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const e = document.createElement("iframe");
|
|
18
|
+
e.style.display = "none", e.onload = async () => {
|
|
19
|
+
await w(500), document.body.removeChild(e), n();
|
|
20
|
+
}, e.src = o(
|
|
21
|
+
s.appUrl,
|
|
22
|
+
i,
|
|
23
|
+
`functional/federated?mode=${t}&refreshToken=${r}`
|
|
24
|
+
), document.body.appendChild(e);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async function C(t = {}, { fetchToken: r = !0, blocklet: a } = {}) {
|
|
28
|
+
if (!p())
|
|
29
|
+
return console.warn("Federated not enabled"), null;
|
|
30
|
+
let n, e;
|
|
31
|
+
r && ({ sessionToken: n, refreshToken: e } = await y());
|
|
32
|
+
const f = l(a), m = o(f.appUrl, i, "/api/federated/login"), d = { withCredentials: !0 };
|
|
33
|
+
n && (d.headers = {
|
|
34
|
+
Authorization: `Bearer ${n}`
|
|
35
|
+
});
|
|
36
|
+
const { data: u } = await c.post(m, t, d);
|
|
37
|
+
return e && await h({ mode: "login", refreshToken: e, blocklet: a }), u;
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
C as loginFederatedMaster,
|
|
41
|
+
h as mountFederatedIframe
|
|
42
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EVENTS as r } from "./constants.js";
|
|
2
|
+
import { didSpacesIsRequired as i } from "./did-spaces.js";
|
|
3
|
+
import { loginFederatedMaster as d, mountFederatedIframe as m } from "./federated.js";
|
|
4
|
+
import { translations as f } from "./locales.js";
|
|
5
|
+
import { checkEnableAutoLogin as s, getMobileVisitorId as l, login as x } from "./login-mobile.js";
|
|
6
|
+
export {
|
|
7
|
+
r as EVENTS,
|
|
8
|
+
s as checkEnableAutoLogin,
|
|
9
|
+
i as didSpacesIsRequired,
|
|
10
|
+
l as getMobileVisitorId,
|
|
11
|
+
x as login,
|
|
12
|
+
d as loginFederatedMaster,
|
|
13
|
+
m as mountFederatedIframe,
|
|
14
|
+
f as translations
|
|
15
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
login: {
|
|
3
|
+
en: {
|
|
4
|
+
title: "Connect",
|
|
5
|
+
scan: "Please use the following methods to complete the connection",
|
|
6
|
+
confirm: "Confirm connection in your DID Wallet",
|
|
7
|
+
success: "Successfully connected"
|
|
8
|
+
},
|
|
9
|
+
zh: {
|
|
10
|
+
title: "登录",
|
|
11
|
+
scan: "请使用下面的方式完成登录",
|
|
12
|
+
confirm: "在 DID Wallet 中确认连接",
|
|
13
|
+
success: "登录成功"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"switch-specified-did": {
|
|
17
|
+
en: {
|
|
18
|
+
title: "Switch Account",
|
|
19
|
+
scan: "You need switch DID to {did} to complete the following actions",
|
|
20
|
+
confirm: "Confirm switch in your DID Wallet",
|
|
21
|
+
success: "Successfully switched"
|
|
22
|
+
},
|
|
23
|
+
zh: {
|
|
24
|
+
title: "切换账号",
|
|
25
|
+
scan: "你需要切换账号至 {did} 才能完成后续的操作",
|
|
26
|
+
confirm: "在 DID Wallet 中确认切换",
|
|
27
|
+
success: "切换成功"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"switch-did": {
|
|
31
|
+
en: {
|
|
32
|
+
title: "Add Account",
|
|
33
|
+
scan: "Please use the following methods to add a new account",
|
|
34
|
+
confirm: "Confirm switch in your DID Wallet",
|
|
35
|
+
success: "Successfully added"
|
|
36
|
+
},
|
|
37
|
+
zh: {
|
|
38
|
+
title: "添加账号",
|
|
39
|
+
scan: "请使用下列方式添加新的账号",
|
|
40
|
+
confirm: "在 DID Wallet 中确认切换",
|
|
41
|
+
success: "添加成功"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"switch-profile": {
|
|
45
|
+
en: {
|
|
46
|
+
title: "Switch Profile",
|
|
47
|
+
scan: "Use DID Wallet to switch profile",
|
|
48
|
+
confirm: "Select profile in your DID Wallet",
|
|
49
|
+
success: "Profile updated"
|
|
50
|
+
},
|
|
51
|
+
zh: {
|
|
52
|
+
title: "切换个人信息",
|
|
53
|
+
scan: "请使用 DID Wallet 来切换个人信息",
|
|
54
|
+
confirm: "在 DID Wallet 中选择个人信息",
|
|
55
|
+
success: "个人信息已经更新"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"switch-passport": {
|
|
59
|
+
en: {
|
|
60
|
+
title: "Switch Passport",
|
|
61
|
+
scan: "Use DID Wallet to switch passport",
|
|
62
|
+
confirm: "Select passport in your DID Wallet",
|
|
63
|
+
success: "Passport and session updated"
|
|
64
|
+
},
|
|
65
|
+
zh: {
|
|
66
|
+
title: "切换通行证",
|
|
67
|
+
scan: "请使用 DID Wallet 来切换通行证",
|
|
68
|
+
confirm: "在 DID Wallet 中选择通行证",
|
|
69
|
+
success: "通行证和会话已经更新"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"connect-to-did-spaces-for-user": {
|
|
73
|
+
en: {
|
|
74
|
+
title: "Please authorize the application to connect to your DID Space",
|
|
75
|
+
scan: "Please use your DID wallet to complete this authorization",
|
|
76
|
+
confirm: "Select the DID Spaces NFT in your DID wallet",
|
|
77
|
+
success: "Connection successful"
|
|
78
|
+
},
|
|
79
|
+
zh: {
|
|
80
|
+
title: "请授权应用连接你的 DID Space",
|
|
81
|
+
scan: "请使用 DID Wallet 来完成授权",
|
|
82
|
+
confirm: "在 DID Wallet 中选择 DID Spaces NFT",
|
|
83
|
+
success: "连接成功"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"bind-wallet": {
|
|
87
|
+
en: {
|
|
88
|
+
title: "Connect DID Wallet for enhanced security",
|
|
89
|
+
scan: "Use DID Wallet to connect your account",
|
|
90
|
+
success: "Successfully connected"
|
|
91
|
+
},
|
|
92
|
+
zh: {
|
|
93
|
+
title: "连接 DID Wallet 获得更高的安全性",
|
|
94
|
+
scan: "请使用 DID Wallet 来连接您的账户",
|
|
95
|
+
success: "连接成功"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
exchangePassport: {
|
|
99
|
+
en: {
|
|
100
|
+
action: "Exchange Passport with NFT",
|
|
101
|
+
tooltip: "Exchange passport if you owns any required NFT"
|
|
102
|
+
},
|
|
103
|
+
zh: {
|
|
104
|
+
action: "兑换通行证",
|
|
105
|
+
tooltip: "通过出示你持有的特定 NFT 来获取通行证"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
lostPassport: {
|
|
109
|
+
en: {
|
|
110
|
+
action: "Lost Passport"
|
|
111
|
+
},
|
|
112
|
+
zh: {
|
|
113
|
+
action: "找回通行证"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
switchAccountDialog: {
|
|
117
|
+
en: {
|
|
118
|
+
confirm: "Switch",
|
|
119
|
+
title: "Switch Account",
|
|
120
|
+
description: "Please switch accounts to complete next action",
|
|
121
|
+
currentAccount: "Current account",
|
|
122
|
+
nextAccount: "Account to be switched"
|
|
123
|
+
},
|
|
124
|
+
zh: {
|
|
125
|
+
confirm: "切换",
|
|
126
|
+
title: "切换账号",
|
|
127
|
+
description: "请切换账号来完成后续的操作",
|
|
128
|
+
currentAccount: "当前登录的账户",
|
|
129
|
+
nextAccount: "即将切换的账户"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
verify: {
|
|
133
|
+
zh: {
|
|
134
|
+
title: "验证所有权",
|
|
135
|
+
verify: "验证",
|
|
136
|
+
reconnect: "换个应用",
|
|
137
|
+
scan: "使用以下方法证明所有权",
|
|
138
|
+
confirm: "请在钱包中确认签名,以允许服务器下载并解密备份",
|
|
139
|
+
success: "所有权验证成功,正在进行还原",
|
|
140
|
+
exists: "相同 DID 的应用已存在此节点上,没有继续恢复",
|
|
141
|
+
open: "访问此应用",
|
|
142
|
+
overwrite: "覆盖安装",
|
|
143
|
+
abort: "访问验证已终止"
|
|
144
|
+
},
|
|
145
|
+
en: {
|
|
146
|
+
title: "Verify Ownership",
|
|
147
|
+
verify: "Verify",
|
|
148
|
+
reconnect: "Try another blocklet",
|
|
149
|
+
scan: "Use the following methods to prove ownership",
|
|
150
|
+
confirm: "Sign delegation to allow server to download and decrypt the backup",
|
|
151
|
+
success: "Ownership verified, the restoring is in progress",
|
|
152
|
+
exists: "This blocklet already exists on this server and restore is aborted",
|
|
153
|
+
open: "Visit Blocklet",
|
|
154
|
+
overwrite: "Overwrite",
|
|
155
|
+
abort: "Access verification aborted"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
export {
|
|
160
|
+
e as translations
|
|
161
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getApps as f } from "@arcblock/ux/lib/Util/federated";
|
|
2
|
+
import { isUrl as h } from "@arcblock/ux/lib/Util";
|
|
3
|
+
import { withQuery as w, joinURL as n } from "ufo";
|
|
4
|
+
import c from "semver";
|
|
5
|
+
import p from "@arcblock/bridge";
|
|
6
|
+
import P from "path-to-regexp";
|
|
7
|
+
import { BLOCKLET_SERVICE_PATH_PREFIX as a } from "../../constant.js";
|
|
8
|
+
import { logger as L } from "../../utils.js";
|
|
9
|
+
const b = [
|
|
10
|
+
`${a}/connect`,
|
|
11
|
+
`${a}/login`,
|
|
12
|
+
`${a}/invite`,
|
|
13
|
+
`${a}/issue-passport`,
|
|
14
|
+
`${a}/oauth/*`
|
|
15
|
+
], y = b.map((t) => P(t, []));
|
|
16
|
+
async function S() {
|
|
17
|
+
const t = window?.blocklet || {}, o = window.location.pathname, { componentId: s, CHAIN_TYPE: l = "arcblock", appPid: m } = t;
|
|
18
|
+
if (y.some((e) => e.exec(o)))
|
|
19
|
+
return null;
|
|
20
|
+
const u = f();
|
|
21
|
+
try {
|
|
22
|
+
const g = new URLSearchParams(window.location.search).get("inviter") || localStorage.getItem("inviter"), d = w(n(window.location.origin, a, "/api/user/loginByWallet"), {
|
|
23
|
+
inviter: g
|
|
24
|
+
});
|
|
25
|
+
return await p.asyncCall("arcLogin", {
|
|
26
|
+
target: d,
|
|
27
|
+
chainType: l,
|
|
28
|
+
appPid: m,
|
|
29
|
+
componentId: s,
|
|
30
|
+
apps: u.map((r) => {
|
|
31
|
+
let i = r?.appLogo;
|
|
32
|
+
return h(i) || (i = n(r.appUrl, i)), {
|
|
33
|
+
appName: r.appName,
|
|
34
|
+
appPid: r.appPid,
|
|
35
|
+
appUrl: r.appUrl,
|
|
36
|
+
appLogo: i,
|
|
37
|
+
sourceAppPid: r.sourceAppPid
|
|
38
|
+
};
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return L.error("Failed login mobile", e), null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async function B() {
|
|
46
|
+
return await p.asyncCall("arcGetVisitorId");
|
|
47
|
+
}
|
|
48
|
+
function N({ platform: t, version: o } = {}) {
|
|
49
|
+
return !!(t === "ios" && o && c.gte(o, "4.15.6") || t === "android" && o && c.gte(o, "4.15.1"));
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
N as checkEnableAutoLogin,
|
|
53
|
+
B as getMobileVisitorId,
|
|
54
|
+
S as login
|
|
55
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect as o } from "react";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
import { useDebounceFn as r, useMemoizedFn as u } from "ahooks";
|
|
4
|
+
function s({ callback: i }) {
|
|
5
|
+
const e = r(i), n = u(() => {
|
|
6
|
+
document.hidden || e.run();
|
|
7
|
+
});
|
|
8
|
+
return o(() => (window.addEventListener("focus", e.run), document.addEventListener("visibilitychange", n), () => {
|
|
9
|
+
window.removeEventListener("focus", e.run), document.removeEventListener("visibilitychange", n);
|
|
10
|
+
}), []), null;
|
|
11
|
+
}
|
|
12
|
+
s.propTypes = {
|
|
13
|
+
callback: t.func.isRequired
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
s as default
|
|
17
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import o from "js-cookie";
|
|
2
|
+
import { getCookieOptions as t } from "@arcblock/ux/lib/Util";
|
|
3
|
+
class g {
|
|
4
|
+
constructor(e, s) {
|
|
5
|
+
this.storageKey = e, this.options = s || {};
|
|
6
|
+
}
|
|
7
|
+
setToken(e) {
|
|
8
|
+
return o.set(this.storageKey, e, {
|
|
9
|
+
...t(this.options)
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
getToken() {
|
|
13
|
+
return o.get(this.storageKey);
|
|
14
|
+
}
|
|
15
|
+
removeToken() {
|
|
16
|
+
return o.remove(this.storageKey, t(this.options));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
g as default
|
|
21
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import o from "jwt-decode";
|
|
2
|
+
class a {
|
|
3
|
+
constructor(e) {
|
|
4
|
+
this.storageKey = e;
|
|
5
|
+
}
|
|
6
|
+
setToken(e) {
|
|
7
|
+
if (!(typeof window > "u" || typeof window.localStorage > "u"))
|
|
8
|
+
return localStorage.setItem(this.storageKey, e);
|
|
9
|
+
}
|
|
10
|
+
getToken() {
|
|
11
|
+
if (typeof window > "u" || typeof window.localStorage > "u")
|
|
12
|
+
return;
|
|
13
|
+
const e = localStorage.getItem(this.storageKey);
|
|
14
|
+
let t, n;
|
|
15
|
+
try {
|
|
16
|
+
if ({ value: t, exp: n } = JSON.parse(e), n === void 0 || t === void 0)
|
|
17
|
+
return e;
|
|
18
|
+
} catch {
|
|
19
|
+
t = e;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
n = o(t).exp;
|
|
23
|
+
} catch {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (!((/* @__PURE__ */ new Date()).getTime() > n * 1e3))
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
removeToken() {
|
|
30
|
+
if (!(typeof window > "u" || typeof window.localStorage > "u"))
|
|
31
|
+
return localStorage.removeItem(this.storageKey);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
a as default
|
|
36
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import t from "./engine/cookie.js";
|
|
2
|
+
import i from "./engine/local-storage.js";
|
|
3
|
+
function s(o = "did.auth.token", n = "ls", r = {}) {
|
|
4
|
+
if (!o)
|
|
5
|
+
throw new Error("storageKey must be specified to create a storage");
|
|
6
|
+
let e = null;
|
|
7
|
+
if (n === "ls")
|
|
8
|
+
e = new i(o);
|
|
9
|
+
else if (n === "cookie")
|
|
10
|
+
e = new t(o, r);
|
|
11
|
+
else
|
|
12
|
+
throw new Error("storageEngine must be ls or cookie");
|
|
13
|
+
return {
|
|
14
|
+
getToken: e.getToken.bind(e),
|
|
15
|
+
setToken: e.setToken.bind(e),
|
|
16
|
+
removeToken: e.removeToken.bind(e),
|
|
17
|
+
engine: n,
|
|
18
|
+
key: o
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
s as default
|
|
23
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useState as f, useEffect as A } from "react";
|
|
2
|
+
function v(t) {
|
|
3
|
+
return t?.did;
|
|
4
|
+
}
|
|
5
|
+
function o(t) {
|
|
6
|
+
return t?.connectedAccounts || t?.extraConfigs?.connectedAccounts || [];
|
|
7
|
+
}
|
|
8
|
+
function w(t) {
|
|
9
|
+
return t?.sourceProvider || t?.extraConfigs?.sourceProvider || "wallet";
|
|
10
|
+
}
|
|
11
|
+
function D(t) {
|
|
12
|
+
return o(t).map((n) => n.provider);
|
|
13
|
+
}
|
|
14
|
+
function g(t) {
|
|
15
|
+
return o(t).map((e) => e.did);
|
|
16
|
+
}
|
|
17
|
+
function r(t) {
|
|
18
|
+
return o(t).find((e) => e.provider === "wallet");
|
|
19
|
+
}
|
|
20
|
+
function P(t) {
|
|
21
|
+
return r(t)?.did;
|
|
22
|
+
}
|
|
23
|
+
function m({ session: t }) {
|
|
24
|
+
const [c, n] = f({
|
|
25
|
+
did: "",
|
|
26
|
+
wallet: "",
|
|
27
|
+
walletDid: "",
|
|
28
|
+
permanentDid: "",
|
|
29
|
+
connectedDids: [],
|
|
30
|
+
connectedAccounts: [],
|
|
31
|
+
sourceProvider: "",
|
|
32
|
+
sourceProviders: []
|
|
33
|
+
});
|
|
34
|
+
return A(() => {
|
|
35
|
+
if (t?.user) {
|
|
36
|
+
const e = v(t.user), d = P(t.user), u = o(t.user), i = g(t.user), s = r(t.user), l = w(t.user), a = D(t.user);
|
|
37
|
+
n({
|
|
38
|
+
did: e,
|
|
39
|
+
wallet: s,
|
|
40
|
+
walletDid: d,
|
|
41
|
+
permanentDid: e,
|
|
42
|
+
connectedDids: i,
|
|
43
|
+
connectedAccounts: u,
|
|
44
|
+
sourceProvider: l,
|
|
45
|
+
sourceProviders: a
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}, [t?.user]), c;
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
m as default,
|
|
52
|
+
o as getConnectedAccounts,
|
|
53
|
+
g as getConnectedDids,
|
|
54
|
+
v as getPermanentDid,
|
|
55
|
+
w as getSourceProvider,
|
|
56
|
+
D as getSourceProviders,
|
|
57
|
+
r as getWallet,
|
|
58
|
+
P as getWalletDid
|
|
59
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import r from "prop-types";
|
|
2
|
+
import t from "./use-did.js";
|
|
3
|
+
function n({ session: i, children: e }) {
|
|
4
|
+
const o = t({ session: i });
|
|
5
|
+
return e instanceof Function ? e(o) : null;
|
|
6
|
+
}
|
|
7
|
+
n.propTypes = {
|
|
8
|
+
session: r.object.isRequired,
|
|
9
|
+
children: r.func.isRequired
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
n as default
|
|
13
|
+
};
|
package/lib/constant.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const _ = 300, o = 1800, n = "/.well-known/service", E = "login_token", c = "refresh_token", t = "/.well-known/service", e = "/api/did", s = "DID Connect", d = "__did-connect__", T = ["scanned", "succeed", "error", "busy"], A = {
|
|
2
|
+
chrome: "https://chromewebstore.google.com/detail/did-wallet/ibjflpbmadchofnbpppegdbnifdgincp",
|
|
3
|
+
edge: "https://microsoftedge.microsoft.com/addons/detail/did-wallet/hjgoblidjnnnamdkinbichnfbmghmafd"
|
|
4
|
+
}, i = 2 * 1e3, S = 6, I = "nf_lang", l = 1e3, D = window?.blocklet?.DID_SPACES_BASE_URL || "https://www.didspaces.com/app";
|
|
5
|
+
export {
|
|
6
|
+
e as API_DID_PREFIX,
|
|
7
|
+
n as BLOCKLET_SERVICE_PATH_PREFIX,
|
|
8
|
+
T as BUSY_STATUS,
|
|
9
|
+
l as CHECK_INTERVAL_TIME,
|
|
10
|
+
i as CHECK_STATUS_INTERVAL,
|
|
11
|
+
s as DEFAULT_NAME,
|
|
12
|
+
_ as DEFAULT_TIMEOUT,
|
|
13
|
+
o as DEFAULT_WINDOW_TIMEOUT,
|
|
14
|
+
d as DID_CONNECT_URL_PARAMS_NAME,
|
|
15
|
+
D as DID_SPACES_BASE_URL,
|
|
16
|
+
A as EXT_DOWNLOAD_URL,
|
|
17
|
+
I as LANG_COOKIE_NAME,
|
|
18
|
+
c as REFRESH_TOKEN_STORAGE_KEY,
|
|
19
|
+
t as RELAY_SOCKET_PREFIX,
|
|
20
|
+
E as SESSION_TOKEN_STORAGE_KEY,
|
|
21
|
+
S as VERIFY_CODE_LENGTH
|
|
22
|
+
};
|
package/lib/error.js
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { default as t } from "@arcblock/ux/lib/Address";
|
|
2
|
+
import { default as s } from "@arcblock/ux/lib/Avatar";
|
|
3
|
+
import { default as f } from "./Button/index.js";
|
|
4
|
+
import { default as d, default as m } from "./Connect/index.js";
|
|
5
|
+
import { default as n } from "@arcblock/ux/lib/DIDLogo";
|
|
6
|
+
import { OAuthConsumer as l, OAuthContext as i, OAuthProvider as A, useOAuth as P } from "./OAuth/context.js";
|
|
7
|
+
import { PasskeyConsumer as k, PasskeyContext as y, PasskeyProvider as h, usePasskey as O } from "./Passkey/context.js";
|
|
8
|
+
import { default as v } from "./Passkey/actions.js";
|
|
9
|
+
import { default as g } from "./Session/index.js";
|
|
10
|
+
import { default as B } from "@arcblock/ux/lib/SessionManager";
|
|
11
|
+
import { default as M } from "./User/use-did.js";
|
|
12
|
+
import { default as b } from "./User/wrap-did.js";
|
|
13
|
+
export {
|
|
14
|
+
t as Address,
|
|
15
|
+
s as Avatar,
|
|
16
|
+
f as Button,
|
|
17
|
+
d as Connect,
|
|
18
|
+
m as DidConnect,
|
|
19
|
+
n as Logo,
|
|
20
|
+
l as OAuthConsumer,
|
|
21
|
+
i as OAuthContext,
|
|
22
|
+
A as OAuthProvider,
|
|
23
|
+
v as PasskeyActions,
|
|
24
|
+
k as PasskeyConsumer,
|
|
25
|
+
y as PasskeyContext,
|
|
26
|
+
h as PasskeyProvider,
|
|
27
|
+
g as Session,
|
|
28
|
+
B as SessionManager,
|
|
29
|
+
b as WrapDid,
|
|
30
|
+
M as useDid,
|
|
31
|
+
P as useOAuth,
|
|
32
|
+
O as usePasskey
|
|
33
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import a from "flat";
|
|
2
|
+
const e = a({
|
|
3
|
+
didSpacesGuide: {
|
|
4
|
+
title: "Connect to DID Spaces",
|
|
5
|
+
description: "Your secure, private, and reliable decentralized digital storage space.",
|
|
6
|
+
feature: {
|
|
7
|
+
dataSecurity: "Data Security",
|
|
8
|
+
dataSharing: "Data Sharing",
|
|
9
|
+
dataSync: "Data Sync",
|
|
10
|
+
dataIntegration: "Data Integration"
|
|
11
|
+
},
|
|
12
|
+
connectNow: "Connect Now"
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
e as default
|
|
17
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import c from "./en.js";
|
|
2
|
+
import p from "./zh.js";
|
|
3
|
+
const n = { en: c, zh: p }, l = (r, o) => r.replace(/{(\w*)}/g, (e, t) => Object.prototype.hasOwnProperty.call(o, t) ? o[t] : "");
|
|
4
|
+
function m(r, o = "en", e = {}) {
|
|
5
|
+
const t = o in n ? o : "en";
|
|
6
|
+
return l(n[t][r], e) || r;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
m as t
|
|
10
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import t from "flat";
|
|
2
|
+
const e = t({
|
|
3
|
+
didSpacesGuide: {
|
|
4
|
+
title: "连接到 DID Spaces",
|
|
5
|
+
description: "您的安全、私密、可靠的分散式数字存储空间。",
|
|
6
|
+
feature: {
|
|
7
|
+
dataSecurity: "数据安全",
|
|
8
|
+
dataSharing: "数据共享",
|
|
9
|
+
dataSync: "数据同步",
|
|
10
|
+
dataIntegration: "数据集成"
|
|
11
|
+
},
|
|
12
|
+
connectNow: "立即连接"
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
e as default
|
|
17
|
+
};
|