@matchain/matchid-sdk-react 0.1.41 → 0.1.42-alpha.1
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-SBOIXOAW.mjs} +45 -3
- package/dist/chunk-SBOIXOAW.mjs.map +1 -0
- package/dist/{chunk-B2HVAJPQ.mjs → chunk-U5KWO2YJ.mjs} +2 -2
- package/dist/components/index.js +44 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/hooks/api/index.js +44 -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 +44 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/{index-DoF5jRoi.d.ts → index-BrdP6eg5.d.ts} +18 -0
- package/dist/{index-fl6SNIZC.d.mts → index-D7bNSBwl.d.mts} +18 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +44 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- 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-U5KWO2YJ.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,46 @@ 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
|
+
did
|
|
993
|
+
});
|
|
994
|
+
} else {
|
|
995
|
+
reject(new Error(res.message));
|
|
996
|
+
}
|
|
997
|
+
iframe.remove();
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
window.addEventListener("message", authMessageHandle);
|
|
1002
|
+
});
|
|
1003
|
+
};
|
|
963
1004
|
return {
|
|
964
1005
|
loginByMethod,
|
|
965
1006
|
loginByTelegram,
|
|
@@ -982,7 +1023,8 @@ function useUserInfo() {
|
|
|
982
1023
|
username: overview?.username || "",
|
|
983
1024
|
auth,
|
|
984
1025
|
login: loginMethod,
|
|
985
|
-
bind
|
|
1026
|
+
bind,
|
|
1027
|
+
getAuthInfo
|
|
986
1028
|
};
|
|
987
1029
|
}
|
|
988
1030
|
|