@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.
@@ -16,7 +16,7 @@ import {
16
16
  TONModal,
17
17
  TRONModal,
18
18
  UsernameModal
19
- } from "../chunk-RYZFW6P6.mjs";
19
+ } from "../chunk-OVZZIJZP.mjs";
20
20
  import "../chunk-DPXMCLYK.mjs";
21
21
  import "../chunk-J5LGTIGS.mjs";
22
22
  export {
@@ -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