@matchain/matchid-sdk-react 0.1.41 → 0.1.42-alpha.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/dist/{chunk-RYZFW6P6.mjs → chunk-OVZZIJZP.mjs} +44 -3
- package/dist/chunk-OVZZIJZP.mjs.map +1 -0
- package/dist/{chunk-B2HVAJPQ.mjs → chunk-ZP4OU66T.mjs} +2 -2
- package/dist/components/index.js +43 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/hooks/api/index.js +43 -2
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +2 -2
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +43 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/{index-DoF5jRoi.d.ts → index-Blx4Nrwm.d.ts} +18 -0
- package/dist/{index-fl6SNIZC.d.mts → index-C1uG-2K1.d.mts} +18 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +43 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/example/src/config/index.ts +19 -1
- package/example/src/pages/User.tsx +27 -3
- package/package.json +1 -1
- package/dist/chunk-RYZFW6P6.mjs.map +0 -1
- /package/dist/{chunk-B2HVAJPQ.mjs.map → chunk-ZP4OU66T.mjs.map} +0 -0
package/dist/hooks/api/index.js
CHANGED
|
@@ -786,7 +786,8 @@ function useUserInfo() {
|
|
|
786
786
|
setOverview,
|
|
787
787
|
overview,
|
|
788
788
|
address,
|
|
789
|
-
endpoints
|
|
789
|
+
endpoints,
|
|
790
|
+
locale
|
|
790
791
|
} = useLocalStore_default();
|
|
791
792
|
const { events, login } = useMatch();
|
|
792
793
|
const { open: SOLOpen } = useSOLModalStore();
|
|
@@ -960,6 +961,45 @@ function useUserInfo() {
|
|
|
960
961
|
const bindCex = (type) => {
|
|
961
962
|
return CEXBindOpen(type);
|
|
962
963
|
};
|
|
964
|
+
const getAuthInfo = async (method) => {
|
|
965
|
+
const element_id = "auth_iframe";
|
|
966
|
+
if (document.getElementById(element_id)) {
|
|
967
|
+
document.getElementById(element_id).remove();
|
|
968
|
+
}
|
|
969
|
+
const iframe = document.createElement("iframe");
|
|
970
|
+
iframe.id = element_id;
|
|
971
|
+
iframe.src = `${endpoints.auth}auth?appid=${appid}&method=${method}&locale=${locale}&token=${encodeURIComponent(encodeBase64(token))}`;
|
|
972
|
+
iframe.style.width = "100vw";
|
|
973
|
+
iframe.style.height = "100vh";
|
|
974
|
+
iframe.style.position = "fixed";
|
|
975
|
+
iframe.style.top = "0";
|
|
976
|
+
iframe.style.left = "0";
|
|
977
|
+
iframe.style.zIndex = "9999";
|
|
978
|
+
iframe.style.border = "none";
|
|
979
|
+
iframe.allowTransparency = "true";
|
|
980
|
+
document.body.appendChild(iframe);
|
|
981
|
+
return new Promise((resolve, reject) => {
|
|
982
|
+
const authMessageHandle = (event) => {
|
|
983
|
+
if (endpoints.auth.includes(event.origin)) {
|
|
984
|
+
const res = event.data;
|
|
985
|
+
if (res.source == "match-auth") {
|
|
986
|
+
window.removeEventListener("message", authMessageHandle);
|
|
987
|
+
if (res.status == "success") {
|
|
988
|
+
resolve({
|
|
989
|
+
...res.data,
|
|
990
|
+
method: res.method,
|
|
991
|
+
appid: res.appid
|
|
992
|
+
});
|
|
993
|
+
} else {
|
|
994
|
+
reject(new Error(res.message));
|
|
995
|
+
}
|
|
996
|
+
iframe.remove();
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
window.addEventListener("message", authMessageHandle);
|
|
1001
|
+
});
|
|
1002
|
+
};
|
|
963
1003
|
return {
|
|
964
1004
|
loginByMethod,
|
|
965
1005
|
loginByTelegram,
|
|
@@ -982,7 +1022,8 @@ function useUserInfo() {
|
|
|
982
1022
|
username: overview?.username || "",
|
|
983
1023
|
auth,
|
|
984
1024
|
login: loginMethod,
|
|
985
|
-
bind
|
|
1025
|
+
bind,
|
|
1026
|
+
getAuthInfo
|
|
986
1027
|
};
|
|
987
1028
|
}
|
|
988
1029
|
|