@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.
@@ -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-U5KWO2YJ.mjs";
6
+ import "../../chunk-SBOIXOAW.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-D7bNSBwl.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-BrdP6eg5.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,46 @@ 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
+ did
1047
+ });
1048
+ } else {
1049
+ reject(new Error(res.message));
1050
+ }
1051
+ iframe.remove();
1052
+ }
1053
+ }
1054
+ };
1055
+ window.addEventListener("message", authMessageHandle);
1056
+ });
1057
+ };
1017
1058
  return {
1018
1059
  loginByMethod,
1019
1060
  loginByTelegram,
@@ -1036,7 +1077,8 @@ function useUserInfo() {
1036
1077
  username: overview?.username || "",
1037
1078
  auth,
1038
1079
  login: loginMethod,
1039
- bind
1080
+ bind,
1081
+ getAuthInfo
1040
1082
  };
1041
1083
  }
1042
1084