@matchain/matchid-sdk-react 0.1.40-alpha.9 → 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.
@@ -2355,7 +2355,9 @@ function WalletContent2({
2355
2355
  setVisible: async (v) => {
2356
2356
  console.log("setVisible", v);
2357
2357
  if (v) {
2358
- await tonConnectUI.disconnect();
2358
+ if (wallet) {
2359
+ await tonConnectUI.disconnect();
2360
+ }
2359
2361
  setStatus("");
2360
2362
  statusRef.current = "";
2361
2363
  open();
@@ -3871,7 +3873,8 @@ function useUserInfo() {
3871
3873
  setOverview,
3872
3874
  overview,
3873
3875
  address,
3874
- endpoints
3876
+ endpoints,
3877
+ locale
3875
3878
  } = useLocalStore_default();
3876
3879
  const { events, login } = useMatch();
3877
3880
  const { open: SOLOpen } = useSOLModalStore();
@@ -4045,6 +4048,45 @@ function useUserInfo() {
4045
4048
  const bindCex = (type) => {
4046
4049
  return CEXBindOpen(type);
4047
4050
  };
4051
+ const getAuthInfo = async (method) => {
4052
+ const element_id = "auth_iframe";
4053
+ if (document.getElementById(element_id)) {
4054
+ document.getElementById(element_id).remove();
4055
+ }
4056
+ const iframe = document.createElement("iframe");
4057
+ iframe.id = element_id;
4058
+ iframe.src = `${endpoints.auth}auth?appid=${appid}&method=${method}&locale=${locale}&token=${encodeURIComponent(encodeBase64(token))}`;
4059
+ iframe.style.width = "100vw";
4060
+ iframe.style.height = "100vh";
4061
+ iframe.style.position = "fixed";
4062
+ iframe.style.top = "0";
4063
+ iframe.style.left = "0";
4064
+ iframe.style.zIndex = "9999";
4065
+ iframe.style.border = "none";
4066
+ iframe.allowTransparency = "true";
4067
+ document.body.appendChild(iframe);
4068
+ return new Promise((resolve, reject) => {
4069
+ const authMessageHandle = (event) => {
4070
+ if (endpoints.auth.includes(event.origin)) {
4071
+ const res = event.data;
4072
+ if (res.source == "match-auth") {
4073
+ window.removeEventListener("message", authMessageHandle);
4074
+ if (res.status == "success") {
4075
+ resolve({
4076
+ ...res.data,
4077
+ method: res.method,
4078
+ appid: res.appid
4079
+ });
4080
+ } else {
4081
+ reject(new Error(res.message));
4082
+ }
4083
+ iframe.remove();
4084
+ }
4085
+ }
4086
+ };
4087
+ window.addEventListener("message", authMessageHandle);
4088
+ });
4089
+ };
4048
4090
  return {
4049
4091
  loginByMethod,
4050
4092
  loginByTelegram,
@@ -4067,7 +4109,8 @@ function useUserInfo() {
4067
4109
  username: overview?.username || "",
4068
4110
  auth,
4069
4111
  login: loginMethod,
4070
- bind
4112
+ bind,
4113
+ getAuthInfo
4071
4114
  };
4072
4115
  }
4073
4116
 
@@ -4150,4 +4193,4 @@ export {
4150
4193
  MatchProvider,
4151
4194
  useMatch
4152
4195
  };
4153
- //# sourceMappingURL=chunk-PPKUHUE3.mjs.map
4196
+ //# sourceMappingURL=chunk-OVZZIJZP.mjs.map