@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.
@@ -16,7 +16,7 @@ import {
16
16
  TONModal,
17
17
  TRONModal,
18
18
  UsernameModal
19
- } from "../chunk-RYZFW6P6.mjs";
19
+ } from "../chunk-SBOIXOAW.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,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