@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.
@@ -3873,7 +3873,8 @@ function useUserInfo() {
3873
3873
  setOverview,
3874
3874
  overview,
3875
3875
  address,
3876
- endpoints
3876
+ endpoints,
3877
+ locale
3877
3878
  } = useLocalStore_default();
3878
3879
  const { events, login } = useMatch();
3879
3880
  const { open: SOLOpen } = useSOLModalStore();
@@ -4047,6 +4048,46 @@ function useUserInfo() {
4047
4048
  const bindCex = (type) => {
4048
4049
  return CEXBindOpen(type);
4049
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
+ did
4080
+ });
4081
+ } else {
4082
+ reject(new Error(res.message));
4083
+ }
4084
+ iframe.remove();
4085
+ }
4086
+ }
4087
+ };
4088
+ window.addEventListener("message", authMessageHandle);
4089
+ });
4090
+ };
4050
4091
  return {
4051
4092
  loginByMethod,
4052
4093
  loginByTelegram,
@@ -4069,7 +4110,8 @@ function useUserInfo() {
4069
4110
  username: overview?.username || "",
4070
4111
  auth,
4071
4112
  login: loginMethod,
4072
- bind
4113
+ bind,
4114
+ getAuthInfo
4073
4115
  };
4074
4116
  }
4075
4117
 
@@ -4152,4 +4194,4 @@ export {
4152
4194
  MatchProvider,
4153
4195
  useMatch
4154
4196
  };
4155
- //# sourceMappingURL=chunk-RYZFW6P6.mjs.map
4197
+ //# sourceMappingURL=chunk-SBOIXOAW.mjs.map