@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.
@@ -2,8 +2,8 @@ import {
2
2
  bind_exports,
3
3
  poh_exports,
4
4
  user_exports
5
- } from "../../chunk-B2HVAJPQ.mjs";
6
- import "../../chunk-RYZFW6P6.mjs";
5
+ } from "../../chunk-ZP4OU66T.mjs";
6
+ import "../../chunk-OVZZIJZP.mjs";
7
7
  import "../../chunk-DPXMCLYK.mjs";
8
8
  import "../../chunk-J5LGTIGS.mjs";
9
9
  export {
@@ -1,4 +1,4 @@
1
- export { c as useCopyClipboard, d as useLayout, a as useMatchEvents, u as useUserInfo, b as useWallet } from '../index-fl6SNIZC.mjs';
1
+ export { c as useCopyClipboard, d as useLayout, a as useMatchEvents, u as useUserInfo, b as useWallet } from '../index-C1uG-2K1.mjs';
2
2
  import '../types.d-CLO_WLka.mjs';
3
3
  import 'react';
4
4
  import 'viem';
@@ -1,4 +1,4 @@
1
- export { c as useCopyClipboard, d as useLayout, a as useMatchEvents, u as useUserInfo, b as useWallet } from '../index-DoF5jRoi.js';
1
+ export { c as useCopyClipboard, d as useLayout, a as useMatchEvents, u as useUserInfo, b as useWallet } from '../index-Blx4Nrwm.js';
2
2
  import '../types.d-CLO_WLka.js';
3
3
  import 'react';
4
4
  import 'viem';
@@ -840,7 +840,8 @@ function useUserInfo() {
840
840
  setOverview,
841
841
  overview,
842
842
  address,
843
- endpoints
843
+ endpoints,
844
+ locale
844
845
  } = useLocalStore_default();
845
846
  const { events, login } = useMatch();
846
847
  const { open: SOLOpen } = useSOLModalStore();
@@ -1014,6 +1015,45 @@ function useUserInfo() {
1014
1015
  const bindCex = (type) => {
1015
1016
  return CEXBindOpen(type);
1016
1017
  };
1018
+ const getAuthInfo = async (method) => {
1019
+ const element_id = "auth_iframe";
1020
+ if (document.getElementById(element_id)) {
1021
+ document.getElementById(element_id).remove();
1022
+ }
1023
+ const iframe = document.createElement("iframe");
1024
+ iframe.id = element_id;
1025
+ iframe.src = `${endpoints.auth}auth?appid=${appid}&method=${method}&locale=${locale}&token=${encodeURIComponent(encodeBase64(token))}`;
1026
+ iframe.style.width = "100vw";
1027
+ iframe.style.height = "100vh";
1028
+ iframe.style.position = "fixed";
1029
+ iframe.style.top = "0";
1030
+ iframe.style.left = "0";
1031
+ iframe.style.zIndex = "9999";
1032
+ iframe.style.border = "none";
1033
+ iframe.allowTransparency = "true";
1034
+ document.body.appendChild(iframe);
1035
+ return new Promise((resolve, reject) => {
1036
+ const authMessageHandle = (event) => {
1037
+ if (endpoints.auth.includes(event.origin)) {
1038
+ const res = event.data;
1039
+ if (res.source == "match-auth") {
1040
+ window.removeEventListener("message", authMessageHandle);
1041
+ if (res.status == "success") {
1042
+ resolve({
1043
+ ...res.data,
1044
+ method: res.method,
1045
+ appid: res.appid
1046
+ });
1047
+ } else {
1048
+ reject(new Error(res.message));
1049
+ }
1050
+ iframe.remove();
1051
+ }
1052
+ }
1053
+ };
1054
+ window.addEventListener("message", authMessageHandle);
1055
+ });
1056
+ };
1017
1057
  return {
1018
1058
  loginByMethod,
1019
1059
  loginByTelegram,
@@ -1036,7 +1076,8 @@ function useUserInfo() {
1036
1076
  username: overview?.username || "",
1037
1077
  auth,
1038
1078
  login: loginMethod,
1039
- bind
1079
+ bind,
1080
+ getAuthInfo
1040
1081
  };
1041
1082
  }
1042
1083