@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.
@@ -4,7 +4,7 @@ import {
4
4
  useMatchEvents,
5
5
  useUserInfo,
6
6
  useWallet
7
- } from "../chunk-RYZFW6P6.mjs";
7
+ } from "../chunk-SBOIXOAW.mjs";
8
8
  import "../chunk-DPXMCLYK.mjs";
9
9
  import "../chunk-J5LGTIGS.mjs";
10
10
  export {
@@ -2,6 +2,23 @@ import { i as ISocialLoginMethod, j as OverviewInfo, C as CEXType, k as LoginMet
2
2
  import * as viem from 'viem';
3
3
  import { SignableMessage, Hex, TransactionSerializable, Account } from 'viem';
4
4
 
5
+ declare const LOGIN_METHOD_MAP: {
6
+ email: string;
7
+ evm: string;
8
+ sol: string;
9
+ btc: string;
10
+ ton: string;
11
+ tron: string;
12
+ google: string;
13
+ facebook: string;
14
+ x: string;
15
+ telegram: string;
16
+ github: string;
17
+ discord: string;
18
+ linkedin: string;
19
+ youtube: string;
20
+ };
21
+
5
22
  declare function useUserInfo(): {
6
23
  loginByMethod: (method: ISocialLoginMethod) => Promise<Window | null>;
7
24
  loginByTelegram: () => Promise<Window | null>;
@@ -28,6 +45,7 @@ declare function useUserInfo(): {
28
45
  auth: () => Promise<any>;
29
46
  login: (method: LoginMethodType) => Promise<void | Window | null>;
30
47
  bind: (method: LoginMethodType) => Promise<void | Window | null>;
48
+ getAuthInfo: (method: keyof typeof LOGIN_METHOD_MAP) => Promise<unknown>;
31
49
  };
32
50
 
33
51
  declare function useMatchEvents(handlers: IMatchEvents): void;
@@ -2,6 +2,23 @@ import { i as ISocialLoginMethod, j as OverviewInfo, C as CEXType, k as LoginMet
2
2
  import * as viem from 'viem';
3
3
  import { SignableMessage, Hex, TransactionSerializable, Account } from 'viem';
4
4
 
5
+ declare const LOGIN_METHOD_MAP: {
6
+ email: string;
7
+ evm: string;
8
+ sol: string;
9
+ btc: string;
10
+ ton: string;
11
+ tron: string;
12
+ google: string;
13
+ facebook: string;
14
+ x: string;
15
+ telegram: string;
16
+ github: string;
17
+ discord: string;
18
+ linkedin: string;
19
+ youtube: string;
20
+ };
21
+
5
22
  declare function useUserInfo(): {
6
23
  loginByMethod: (method: ISocialLoginMethod) => Promise<Window | null>;
7
24
  loginByTelegram: () => Promise<Window | null>;
@@ -28,6 +45,7 @@ declare function useUserInfo(): {
28
45
  auth: () => Promise<any>;
29
46
  login: (method: LoginMethodType) => Promise<void | Window | null>;
30
47
  bind: (method: LoginMethodType) => Promise<void | Window | null>;
48
+ getAuthInfo: (method: keyof typeof LOGIN_METHOD_MAP) => Promise<unknown>;
31
49
  };
32
50
 
33
51
  declare function useMatchEvents(handlers: IMatchEvents): void;
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { I as IMatchEvents, a as IEnvConfigType, L as LocaleType } from './types.d-CLO_WLka.mjs';
3
3
  export { i as Components } from './index-COlsBC-b.mjs';
4
- export { i as Hooks } from './index-fl6SNIZC.mjs';
4
+ export { i as Hooks } from './index-D7bNSBwl.mjs';
5
5
  export { i as Api } from './index-C3KZYrtu.mjs';
6
6
  export { i as Chains } from './index-DXRGMAbv.mjs';
7
7
  import 'react/jsx-runtime';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { I as IMatchEvents, a as IEnvConfigType, L as LocaleType } from './types.d-CLO_WLka.js';
3
3
  export { i as Components } from './index-fS75Swm8.js';
4
- export { i as Hooks } from './index-DoF5jRoi.js';
4
+ export { i as Hooks } from './index-BrdP6eg5.js';
5
5
  export { i as Api } from './index-Dq9Swg8r.js';
6
6
  export { i as Chains } from './index-DXRGMAbv.js';
7
7
  import 'react/jsx-runtime';
package/dist/index.js CHANGED
@@ -1693,7 +1693,8 @@ function useUserInfo() {
1693
1693
  setOverview,
1694
1694
  overview,
1695
1695
  address,
1696
- endpoints
1696
+ endpoints,
1697
+ locale
1697
1698
  } = useLocalStore_default();
1698
1699
  const { events, login } = useMatch();
1699
1700
  const { open: SOLOpen } = useSOLModalStore();
@@ -1867,6 +1868,46 @@ function useUserInfo() {
1867
1868
  const bindCex = (type) => {
1868
1869
  return CEXBindOpen(type);
1869
1870
  };
1871
+ const getAuthInfo = async (method) => {
1872
+ const element_id = "auth_iframe";
1873
+ if (document.getElementById(element_id)) {
1874
+ document.getElementById(element_id).remove();
1875
+ }
1876
+ const iframe = document.createElement("iframe");
1877
+ iframe.id = element_id;
1878
+ iframe.src = `${endpoints.auth}auth?appid=${appid}&method=${method}&locale=${locale}&token=${encodeURIComponent(encodeBase64(token))}`;
1879
+ iframe.style.width = "100vw";
1880
+ iframe.style.height = "100vh";
1881
+ iframe.style.position = "fixed";
1882
+ iframe.style.top = "0";
1883
+ iframe.style.left = "0";
1884
+ iframe.style.zIndex = "9999";
1885
+ iframe.style.border = "none";
1886
+ iframe.allowTransparency = "true";
1887
+ document.body.appendChild(iframe);
1888
+ return new Promise((resolve, reject) => {
1889
+ const authMessageHandle = (event) => {
1890
+ if (endpoints.auth.includes(event.origin)) {
1891
+ const res = event.data;
1892
+ if (res.source == "match-auth") {
1893
+ window.removeEventListener("message", authMessageHandle);
1894
+ if (res.status == "success") {
1895
+ resolve({
1896
+ ...res.data,
1897
+ method: res.method,
1898
+ appid: res.appid,
1899
+ did
1900
+ });
1901
+ } else {
1902
+ reject(new Error(res.message));
1903
+ }
1904
+ iframe.remove();
1905
+ }
1906
+ }
1907
+ };
1908
+ window.addEventListener("message", authMessageHandle);
1909
+ });
1910
+ };
1870
1911
  return {
1871
1912
  loginByMethod,
1872
1913
  loginByTelegram,
@@ -1889,7 +1930,8 @@ function useUserInfo() {
1889
1930
  username: overview?.username || "",
1890
1931
  auth,
1891
1932
  login: loginMethod,
1892
- bind
1933
+ bind,
1934
+ getAuthInfo
1893
1935
  };
1894
1936
  }
1895
1937