@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.
@@ -9,7 +9,7 @@ import {
9
9
  unBindWalletApi,
10
10
  useUserInfo,
11
11
  verifyPohApi
12
- } from "./chunk-RYZFW6P6.mjs";
12
+ } from "./chunk-SBOIXOAW.mjs";
13
13
  import {
14
14
  __export
15
15
  } from "./chunk-J5LGTIGS.mjs";
@@ -90,4 +90,4 @@ export {
90
90
  user_exports,
91
91
  api_exports
92
92
  };
93
- //# sourceMappingURL=chunk-B2HVAJPQ.mjs.map
93
+ //# sourceMappingURL=chunk-U5KWO2YJ.mjs.map
@@ -1973,7 +1973,8 @@ function useUserInfo() {
1973
1973
  setOverview,
1974
1974
  overview,
1975
1975
  address,
1976
- endpoints
1976
+ endpoints,
1977
+ locale
1977
1978
  } = useLocalStore_default();
1978
1979
  const { events, login } = useMatch();
1979
1980
  const { open: SOLOpen } = useSOLModalStore();
@@ -2147,6 +2148,46 @@ function useUserInfo() {
2147
2148
  const bindCex = (type) => {
2148
2149
  return CEXBindOpen(type);
2149
2150
  };
2151
+ const getAuthInfo = async (method) => {
2152
+ const element_id = "auth_iframe";
2153
+ if (document.getElementById(element_id)) {
2154
+ document.getElementById(element_id).remove();
2155
+ }
2156
+ const iframe = document.createElement("iframe");
2157
+ iframe.id = element_id;
2158
+ iframe.src = `${endpoints.auth}auth?appid=${appid}&method=${method}&locale=${locale}&token=${encodeURIComponent(encodeBase64(token))}`;
2159
+ iframe.style.width = "100vw";
2160
+ iframe.style.height = "100vh";
2161
+ iframe.style.position = "fixed";
2162
+ iframe.style.top = "0";
2163
+ iframe.style.left = "0";
2164
+ iframe.style.zIndex = "9999";
2165
+ iframe.style.border = "none";
2166
+ iframe.allowTransparency = "true";
2167
+ document.body.appendChild(iframe);
2168
+ return new Promise((resolve, reject) => {
2169
+ const authMessageHandle = (event) => {
2170
+ if (endpoints.auth.includes(event.origin)) {
2171
+ const res = event.data;
2172
+ if (res.source == "match-auth") {
2173
+ window.removeEventListener("message", authMessageHandle);
2174
+ if (res.status == "success") {
2175
+ resolve({
2176
+ ...res.data,
2177
+ method: res.method,
2178
+ appid: res.appid,
2179
+ did
2180
+ });
2181
+ } else {
2182
+ reject(new Error(res.message));
2183
+ }
2184
+ iframe.remove();
2185
+ }
2186
+ }
2187
+ };
2188
+ window.addEventListener("message", authMessageHandle);
2189
+ });
2190
+ };
2150
2191
  return {
2151
2192
  loginByMethod,
2152
2193
  loginByTelegram,
@@ -2169,7 +2210,8 @@ function useUserInfo() {
2169
2210
  username: overview?.username || "",
2170
2211
  auth,
2171
2212
  login: loginMethod,
2172
- bind
2213
+ bind,
2214
+ getAuthInfo
2173
2215
  };
2174
2216
  }
2175
2217