@matchain/matchid-sdk-react 0.1.12 → 0.1.13
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.
- package/dist/index.d.mts +21 -9
- package/dist/index.d.ts +21 -9
- package/dist/index.js +90 -89
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -89
- package/dist/index.mjs.map +1 -1
- package/example/src/App.tsx +16 -12
- package/example/src/pages/User.tsx +13 -0
- package/example/src/pages/Wallet.tsx +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -6,7 +6,12 @@ import * as _tanstack_react_query from '@tanstack/react-query';
|
|
|
6
6
|
import { UseQueryOptions } from '@tanstack/react-query/src/types';
|
|
7
7
|
|
|
8
8
|
type LoginMethodType = 'wallet' | 'email' | 'google' | 'X' | 'telegram'
|
|
9
|
-
type
|
|
9
|
+
type IEnvConfigType = {
|
|
10
|
+
endpoints: {
|
|
11
|
+
back: string;
|
|
12
|
+
auth: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
10
15
|
type IMatchEvents = {
|
|
11
16
|
onLogin?: (data: {
|
|
12
17
|
mid?: string;
|
|
@@ -134,25 +139,20 @@ type PohZkpassParams = {
|
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
type MatchContextType = {
|
|
137
|
-
env: IEnvName;
|
|
138
142
|
appid: string;
|
|
139
|
-
endpoints: {
|
|
140
|
-
login: string;
|
|
141
|
-
back: string;
|
|
142
|
-
};
|
|
143
143
|
events?: IMatchEvents;
|
|
144
144
|
login: (data: {
|
|
145
145
|
mid: string;
|
|
146
146
|
token: string;
|
|
147
147
|
}) => Promise<void>;
|
|
148
148
|
theme: "light" | "dark";
|
|
149
|
-
}
|
|
149
|
+
} & Partial<IEnvConfigType>;
|
|
150
150
|
declare const MatchProvider: React$1.FC<{
|
|
151
151
|
children: ReactNode;
|
|
152
152
|
appid: string;
|
|
153
|
-
env?: IEnvName;
|
|
154
153
|
events?: IMatchEvents;
|
|
155
154
|
theme?: "light" | "dark";
|
|
155
|
+
endpoints?: IEnvConfigType['endpoints'];
|
|
156
156
|
}>;
|
|
157
157
|
declare const useMatch: () => MatchContextType;
|
|
158
158
|
|
|
@@ -227,6 +227,7 @@ declare function useUserInfo(): {
|
|
|
227
227
|
bindWallet: () => Promise<void>;
|
|
228
228
|
bindTelegram: () => Promise<void>;
|
|
229
229
|
username: string;
|
|
230
|
+
auth: () => Promise<any>;
|
|
230
231
|
};
|
|
231
232
|
|
|
232
233
|
declare function useMatchEvents(handlers: IMatchEvents): void;
|
|
@@ -281,6 +282,10 @@ declare const unBindWalletApi: ({ address }: {
|
|
|
281
282
|
address: string;
|
|
282
283
|
}) => Promise<MyResponseType<any>>;
|
|
283
284
|
declare const verifyPohApi: ({ taskId, schemaId, publicFields, allocatorAddress, publicFieldsHash, allocatorSignature, uHash, validatorAddress, validatorSignature }: PohZkpassParams) => Promise<MyResponseType<any>>;
|
|
285
|
+
declare const chooseIdentityApi: ({ identity }: {
|
|
286
|
+
identity: string;
|
|
287
|
+
}) => Promise<MyResponseType<any>>;
|
|
288
|
+
declare const mintPassportNftApi: () => Promise<MyResponseType<any>>;
|
|
284
289
|
|
|
285
290
|
declare function useBindList(options?: Omit<UseQueryOptions<BindItemType[]>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<BindItemType[], Error>;
|
|
286
291
|
declare function useBindInfo(options?: Omit<UseQueryOptions<BindInfoType>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<BindInfoType, Error>;
|
|
@@ -302,10 +307,17 @@ declare namespace poh {
|
|
|
302
307
|
export { poh_usePohList as usePohList, poh_verifyPohApi as verifyPohApi };
|
|
303
308
|
}
|
|
304
309
|
|
|
310
|
+
declare const user_chooseIdentityApi: typeof chooseIdentityApi;
|
|
311
|
+
declare const user_mintPassportNftApi: typeof mintPassportNftApi;
|
|
312
|
+
declare namespace user {
|
|
313
|
+
export { user_chooseIdentityApi as chooseIdentityApi, user_mintPassportNftApi as mintPassportNftApi };
|
|
314
|
+
}
|
|
315
|
+
|
|
305
316
|
declare const index$1_bind: typeof bind;
|
|
306
317
|
declare const index$1_poh: typeof poh;
|
|
318
|
+
declare const index$1_user: typeof user;
|
|
307
319
|
declare namespace index$1 {
|
|
308
|
-
export { index$1_bind as bind, index$1_poh as poh };
|
|
320
|
+
export { index$1_bind as bind, index$1_poh as poh, index$1_user as user };
|
|
309
321
|
}
|
|
310
322
|
|
|
311
323
|
declare const matchMain: {
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,12 @@ import * as _tanstack_react_query from '@tanstack/react-query';
|
|
|
6
6
|
import { UseQueryOptions } from '@tanstack/react-query/src/types';
|
|
7
7
|
|
|
8
8
|
type LoginMethodType = 'wallet' | 'email' | 'google' | 'X' | 'telegram'
|
|
9
|
-
type
|
|
9
|
+
type IEnvConfigType = {
|
|
10
|
+
endpoints: {
|
|
11
|
+
back: string;
|
|
12
|
+
auth: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
10
15
|
type IMatchEvents = {
|
|
11
16
|
onLogin?: (data: {
|
|
12
17
|
mid?: string;
|
|
@@ -134,25 +139,20 @@ type PohZkpassParams = {
|
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
type MatchContextType = {
|
|
137
|
-
env: IEnvName;
|
|
138
142
|
appid: string;
|
|
139
|
-
endpoints: {
|
|
140
|
-
login: string;
|
|
141
|
-
back: string;
|
|
142
|
-
};
|
|
143
143
|
events?: IMatchEvents;
|
|
144
144
|
login: (data: {
|
|
145
145
|
mid: string;
|
|
146
146
|
token: string;
|
|
147
147
|
}) => Promise<void>;
|
|
148
148
|
theme: "light" | "dark";
|
|
149
|
-
}
|
|
149
|
+
} & Partial<IEnvConfigType>;
|
|
150
150
|
declare const MatchProvider: React$1.FC<{
|
|
151
151
|
children: ReactNode;
|
|
152
152
|
appid: string;
|
|
153
|
-
env?: IEnvName;
|
|
154
153
|
events?: IMatchEvents;
|
|
155
154
|
theme?: "light" | "dark";
|
|
155
|
+
endpoints?: IEnvConfigType['endpoints'];
|
|
156
156
|
}>;
|
|
157
157
|
declare const useMatch: () => MatchContextType;
|
|
158
158
|
|
|
@@ -227,6 +227,7 @@ declare function useUserInfo(): {
|
|
|
227
227
|
bindWallet: () => Promise<void>;
|
|
228
228
|
bindTelegram: () => Promise<void>;
|
|
229
229
|
username: string;
|
|
230
|
+
auth: () => Promise<any>;
|
|
230
231
|
};
|
|
231
232
|
|
|
232
233
|
declare function useMatchEvents(handlers: IMatchEvents): void;
|
|
@@ -281,6 +282,10 @@ declare const unBindWalletApi: ({ address }: {
|
|
|
281
282
|
address: string;
|
|
282
283
|
}) => Promise<MyResponseType<any>>;
|
|
283
284
|
declare const verifyPohApi: ({ taskId, schemaId, publicFields, allocatorAddress, publicFieldsHash, allocatorSignature, uHash, validatorAddress, validatorSignature }: PohZkpassParams) => Promise<MyResponseType<any>>;
|
|
285
|
+
declare const chooseIdentityApi: ({ identity }: {
|
|
286
|
+
identity: string;
|
|
287
|
+
}) => Promise<MyResponseType<any>>;
|
|
288
|
+
declare const mintPassportNftApi: () => Promise<MyResponseType<any>>;
|
|
284
289
|
|
|
285
290
|
declare function useBindList(options?: Omit<UseQueryOptions<BindItemType[]>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<BindItemType[], Error>;
|
|
286
291
|
declare function useBindInfo(options?: Omit<UseQueryOptions<BindInfoType>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<BindInfoType, Error>;
|
|
@@ -302,10 +307,17 @@ declare namespace poh {
|
|
|
302
307
|
export { poh_usePohList as usePohList, poh_verifyPohApi as verifyPohApi };
|
|
303
308
|
}
|
|
304
309
|
|
|
310
|
+
declare const user_chooseIdentityApi: typeof chooseIdentityApi;
|
|
311
|
+
declare const user_mintPassportNftApi: typeof mintPassportNftApi;
|
|
312
|
+
declare namespace user {
|
|
313
|
+
export { user_chooseIdentityApi as chooseIdentityApi, user_mintPassportNftApi as mintPassportNftApi };
|
|
314
|
+
}
|
|
315
|
+
|
|
305
316
|
declare const index$1_bind: typeof bind;
|
|
306
317
|
declare const index$1_poh: typeof poh;
|
|
318
|
+
declare const index$1_user: typeof user;
|
|
307
319
|
declare namespace index$1 {
|
|
308
|
-
export { index$1_bind as bind, index$1_poh as poh };
|
|
320
|
+
export { index$1_bind as bind, index$1_poh as poh, index$1_user as user };
|
|
309
321
|
}
|
|
310
322
|
|
|
311
323
|
declare const matchMain: {
|
package/dist/index.js
CHANGED
|
@@ -521,7 +521,6 @@ var persistedState = (0, import_middleware.persist)(
|
|
|
521
521
|
appid: "",
|
|
522
522
|
token: "",
|
|
523
523
|
did: "",
|
|
524
|
-
env: "main",
|
|
525
524
|
mid: "",
|
|
526
525
|
overview: null,
|
|
527
526
|
theme: "light",
|
|
@@ -531,13 +530,17 @@ var persistedState = (0, import_middleware.persist)(
|
|
|
531
530
|
did: overview.did,
|
|
532
531
|
mid: overview.mid
|
|
533
532
|
}),
|
|
534
|
-
|
|
533
|
+
endpoints: {
|
|
534
|
+
back: "https://api.matchid.ai/",
|
|
535
|
+
auth: "https://auth.matchid.ai/"
|
|
536
|
+
},
|
|
535
537
|
setDid: (did) => set({ did }),
|
|
536
538
|
setToken: (token) => set({ token }),
|
|
537
539
|
setAppid: (appid) => set({ appid }),
|
|
538
540
|
setMid: (mid) => set({ mid }),
|
|
539
541
|
logout: () => set({ token: "", did: "", mid: "", address: "", overview: null }),
|
|
540
542
|
setTheme: (theme) => set({ theme }),
|
|
543
|
+
setEndpoints: (endpoints) => set({ endpoints }),
|
|
541
544
|
address: "",
|
|
542
545
|
setAddress: (address) => set({ address })
|
|
543
546
|
}),
|
|
@@ -553,57 +556,28 @@ var import_react2 = require("react");
|
|
|
553
556
|
// src/api/request.ts
|
|
554
557
|
var import_axios = __toESM(require("axios"));
|
|
555
558
|
|
|
556
|
-
// src/config/env/main.ts
|
|
557
|
-
var main_default = {
|
|
558
|
-
endpoints: {
|
|
559
|
-
back: "https://api.matchid.ai/api/v1/",
|
|
560
|
-
login: "https://auth.matchid.ai/"
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
// src/config/env/dev.ts
|
|
565
|
-
var dev_default = {
|
|
566
|
-
endpoints: {
|
|
567
|
-
back: "https://mid-test-api.matchain.io/mid/api/v1/",
|
|
568
|
-
login: "https://calm-hare-roughly.ngrok-free.app/"
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
// src/config/env/test.ts
|
|
573
|
-
var test_default = {
|
|
574
|
-
endpoints: {
|
|
575
|
-
back: "https://mid-test-api.matchain.io/mid/api/v1/",
|
|
576
|
-
login: "https://mid-sso-test.vercel.app/"
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
|
|
580
559
|
// src/config/env/index.ts
|
|
581
560
|
var env_default = {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
561
|
+
endpoints: {
|
|
562
|
+
back: "https://api.matchid.ai/",
|
|
563
|
+
auth: "https://auth.matchid.ai/"
|
|
564
|
+
}
|
|
585
565
|
};
|
|
586
566
|
|
|
587
567
|
// src/store/index.ts
|
|
588
|
-
var
|
|
568
|
+
var getEndpoints = () => {
|
|
589
569
|
try {
|
|
590
570
|
const store = localStore.getState();
|
|
591
|
-
const env = store?.
|
|
571
|
+
const env = store?.endpoints;
|
|
592
572
|
if (env) {
|
|
593
573
|
return env;
|
|
594
574
|
} else {
|
|
595
|
-
return
|
|
575
|
+
return env_default.endpoints;
|
|
596
576
|
}
|
|
597
577
|
} catch (e) {
|
|
598
|
-
return
|
|
578
|
+
return env_default.endpoints;
|
|
599
579
|
}
|
|
600
580
|
};
|
|
601
|
-
var getEnvConfig = () => {
|
|
602
|
-
return env_default[getEnv()];
|
|
603
|
-
};
|
|
604
|
-
var getEndpoints = () => {
|
|
605
|
-
return getEnvConfig().endpoints;
|
|
606
|
-
};
|
|
607
581
|
var getAppid = () => {
|
|
608
582
|
try {
|
|
609
583
|
const store = localStore.getState();
|
|
@@ -691,72 +665,72 @@ var request_default = request;
|
|
|
691
665
|
// src/api/index.ts
|
|
692
666
|
var getEmailCodeApi = (email) => {
|
|
693
667
|
return request_default({
|
|
694
|
-
url: `/email/code`,
|
|
668
|
+
url: `/api/v1/email/code`,
|
|
695
669
|
method: "POST",
|
|
696
670
|
data: { email }
|
|
697
671
|
});
|
|
698
672
|
};
|
|
699
673
|
var verifyEmailCodeApi = ({ email, verification_key, verification_code }) => {
|
|
700
674
|
return request_default({
|
|
701
|
-
url: `/user/email/login`,
|
|
675
|
+
url: `/api/v1/user/email/login`,
|
|
702
676
|
method: "POST",
|
|
703
677
|
data: { email, verification_key, verification_code }
|
|
704
678
|
});
|
|
705
679
|
};
|
|
706
680
|
var getOverviewInfoApi = () => {
|
|
707
681
|
return request_default({
|
|
708
|
-
url: `/user/overview`,
|
|
682
|
+
url: `/api/v1/user/overview`,
|
|
709
683
|
method: "GET"
|
|
710
684
|
});
|
|
711
685
|
};
|
|
712
686
|
var toLogoutApi = () => {
|
|
713
687
|
return request_default({
|
|
714
|
-
url: `/user/logout`,
|
|
688
|
+
url: `/api/v1/user/logout`,
|
|
715
689
|
method: "POST"
|
|
716
690
|
});
|
|
717
691
|
};
|
|
718
692
|
var setUserNameApi = (data) => {
|
|
719
693
|
return request_default({
|
|
720
|
-
url: `/user/name`,
|
|
694
|
+
url: `/api/v1/user/name`,
|
|
721
695
|
method: "POSt",
|
|
722
696
|
data
|
|
723
697
|
});
|
|
724
698
|
};
|
|
725
699
|
var getBindListApi = () => {
|
|
726
700
|
return request_default({
|
|
727
|
-
url: `/bind/list`,
|
|
701
|
+
url: `/api/v1/bind/list`,
|
|
728
702
|
method: "GET"
|
|
729
703
|
});
|
|
730
704
|
};
|
|
731
705
|
var getPohListApi = () => {
|
|
732
706
|
return request_default({
|
|
733
|
-
url: `/poh/list`,
|
|
707
|
+
url: `/api/v1/poh/list`,
|
|
734
708
|
method: "GET"
|
|
735
709
|
});
|
|
736
710
|
};
|
|
737
711
|
var getBindInfoApi = () => {
|
|
738
712
|
return request_default({
|
|
739
|
-
url: `/bind`,
|
|
713
|
+
url: `/api/v1/bind`,
|
|
740
714
|
method: "GET"
|
|
741
715
|
});
|
|
742
716
|
};
|
|
743
717
|
var bindCexApi = ({ cex, api_key, api_secret }) => {
|
|
744
718
|
return request_default({
|
|
745
|
-
url: `/cex/subscribe`,
|
|
719
|
+
url: `/api/v1/cex/subscribe`,
|
|
746
720
|
method: "POST",
|
|
747
721
|
data: { cex, api_key, api_secret }
|
|
748
722
|
});
|
|
749
723
|
};
|
|
750
724
|
var unBindApi = ({ type }) => {
|
|
751
725
|
return request_default({
|
|
752
|
-
url: `/unbind`,
|
|
726
|
+
url: `/api/v1/unbind`,
|
|
753
727
|
method: "POST",
|
|
754
728
|
data: { type }
|
|
755
729
|
});
|
|
756
730
|
};
|
|
757
731
|
var unBindWalletApi = ({ address }) => {
|
|
758
732
|
return request_default({
|
|
759
|
-
url: `/wallet/unbind`,
|
|
733
|
+
url: `/api/v1/wallet/unbind`,
|
|
760
734
|
method: "POST",
|
|
761
735
|
data: { address }
|
|
762
736
|
});
|
|
@@ -773,7 +747,7 @@ var verifyPohApi = ({
|
|
|
773
747
|
validatorSignature
|
|
774
748
|
}) => {
|
|
775
749
|
return request_default({
|
|
776
|
-
url: `/poh/zkpass`,
|
|
750
|
+
url: `/api/v1/poh/zkpass`,
|
|
777
751
|
method: "POST",
|
|
778
752
|
data: {
|
|
779
753
|
taskId,
|
|
@@ -788,6 +762,25 @@ var verifyPohApi = ({
|
|
|
788
762
|
}
|
|
789
763
|
});
|
|
790
764
|
};
|
|
765
|
+
var chooseIdentityApi = ({ identity }) => {
|
|
766
|
+
return request_default({
|
|
767
|
+
url: `/api/v1/user/choose/identity`,
|
|
768
|
+
method: "POST",
|
|
769
|
+
data: { identity }
|
|
770
|
+
});
|
|
771
|
+
};
|
|
772
|
+
var mintPassportNftApi = () => {
|
|
773
|
+
return request_default({
|
|
774
|
+
url: `/api/v1/mint/passport/nft`,
|
|
775
|
+
method: "POST"
|
|
776
|
+
});
|
|
777
|
+
};
|
|
778
|
+
var getAuthInfoApi = () => {
|
|
779
|
+
return request_default({
|
|
780
|
+
url: `/api/v1/user/auth`,
|
|
781
|
+
method: "GET"
|
|
782
|
+
});
|
|
783
|
+
};
|
|
791
784
|
|
|
792
785
|
// src/hooks/eventManager.ts
|
|
793
786
|
var EventManager = class {
|
|
@@ -846,16 +839,13 @@ function useUserInfo() {
|
|
|
846
839
|
token,
|
|
847
840
|
mid,
|
|
848
841
|
did,
|
|
849
|
-
env,
|
|
850
842
|
logout: logoutStore,
|
|
851
843
|
setOverview,
|
|
852
844
|
overview,
|
|
853
|
-
address
|
|
845
|
+
address,
|
|
846
|
+
endpoints
|
|
854
847
|
} = useLocalStore_default();
|
|
855
848
|
const { events, login } = useMatch();
|
|
856
|
-
const endpoints = (0, import_react2.useMemo)(() => {
|
|
857
|
-
return getEndpoints();
|
|
858
|
-
}, [env]);
|
|
859
849
|
const isLogin = (0, import_react2.useMemo)(() => !!token, [token]);
|
|
860
850
|
const logout = async () => {
|
|
861
851
|
try {
|
|
@@ -868,7 +858,7 @@ function useUserInfo() {
|
|
|
868
858
|
eventManager_default.emit("onLogout");
|
|
869
859
|
};
|
|
870
860
|
const loginByMethod = (method) => {
|
|
871
|
-
const link = `${endpoints.back}auth/${method}?appid=${appid}&provider=${method}&redirect=${encodeURIComponent(endpoints.
|
|
861
|
+
const link = `${endpoints.back}auth/${method}?appid=${appid}&provider=${method}&redirect=${encodeURIComponent(endpoints.auth + "login/" + method)}&authorization=${(/* @__PURE__ */ new Date()).getTime()}`;
|
|
872
862
|
matchlog_default.log("link", link);
|
|
873
863
|
const authWindow = window.open(
|
|
874
864
|
link,
|
|
@@ -919,7 +909,7 @@ function useUserInfo() {
|
|
|
919
909
|
};
|
|
920
910
|
const loginByWallet = () => {
|
|
921
911
|
const authWindow = window.open(
|
|
922
|
-
`${endpoints.
|
|
912
|
+
`${endpoints.auth}login/wallet?appid=${appid}`,
|
|
923
913
|
// Replace with the actual authorization URL
|
|
924
914
|
"_blank"
|
|
925
915
|
// 'width=800,height=600'
|
|
@@ -927,7 +917,7 @@ function useUserInfo() {
|
|
|
927
917
|
};
|
|
928
918
|
const loginByTelegram = () => {
|
|
929
919
|
const authWindow = window.open(
|
|
930
|
-
`${endpoints.
|
|
920
|
+
`${endpoints.auth}login/telegram?appid=${appid}`,
|
|
931
921
|
// Replace with the actual authorization URL
|
|
932
922
|
"authWindow",
|
|
933
923
|
"width=800,height=600"
|
|
@@ -944,7 +934,7 @@ function useUserInfo() {
|
|
|
944
934
|
throw new Error("You must login first");
|
|
945
935
|
}
|
|
946
936
|
const authWindow = window.open(
|
|
947
|
-
`${endpoints.
|
|
937
|
+
`${endpoints.auth}bind/wallet?appid=${appid}&st=` + encodeURIComponent(encodeBase64(token)),
|
|
948
938
|
// Replace with the actual authorization URL
|
|
949
939
|
"_blank"
|
|
950
940
|
);
|
|
@@ -954,12 +944,19 @@ function useUserInfo() {
|
|
|
954
944
|
throw new Error("You must login first");
|
|
955
945
|
}
|
|
956
946
|
const authWindow = window.open(
|
|
957
|
-
`${endpoints.
|
|
947
|
+
`${endpoints.auth}bind/telegram?appid=${appid}&st=` + encodeURIComponent(encodeBase64(token)),
|
|
958
948
|
// Replace with the actual authorization URL
|
|
959
949
|
"authWindow",
|
|
960
950
|
"width=800,height=600"
|
|
961
951
|
);
|
|
962
952
|
};
|
|
953
|
+
const auth = async () => {
|
|
954
|
+
const res = await getAuthInfoApi();
|
|
955
|
+
if (isSuccess(res)) {
|
|
956
|
+
return res.data;
|
|
957
|
+
}
|
|
958
|
+
throw new Error(res.message);
|
|
959
|
+
};
|
|
963
960
|
return {
|
|
964
961
|
loginByTelegram,
|
|
965
962
|
loginByTwitter,
|
|
@@ -977,7 +974,8 @@ function useUserInfo() {
|
|
|
977
974
|
overview,
|
|
978
975
|
bindWallet,
|
|
979
976
|
bindTelegram,
|
|
980
|
-
username: overview?.username || ""
|
|
977
|
+
username: overview?.username || "",
|
|
978
|
+
auth
|
|
981
979
|
};
|
|
982
980
|
}
|
|
983
981
|
|
|
@@ -1338,7 +1336,7 @@ var AppClientId2 = "react-sdk-" + getVersion();
|
|
|
1338
1336
|
function useWalletInit({
|
|
1339
1337
|
refreshOverview
|
|
1340
1338
|
}) {
|
|
1341
|
-
const {
|
|
1339
|
+
const { endpoints } = useLocalStore_default();
|
|
1342
1340
|
const getWalletIframe = () => {
|
|
1343
1341
|
return document.getElementById("match-wallet");
|
|
1344
1342
|
};
|
|
@@ -1346,17 +1344,15 @@ function useWalletInit({
|
|
|
1346
1344
|
const { appid, token, overview } = useLocalStore_default();
|
|
1347
1345
|
const { initWallet, generateWallet } = useWallet();
|
|
1348
1346
|
(0, import_react6.useEffect)(() => {
|
|
1349
|
-
if (
|
|
1347
|
+
if (endpoints.auth) {
|
|
1350
1348
|
if (!window.matchWalletMessageIdMap) {
|
|
1351
1349
|
window.matchWalletMessageIdMap = {};
|
|
1352
1350
|
}
|
|
1353
|
-
const config = env_default[env];
|
|
1354
|
-
const endpoints = config.endpoints;
|
|
1355
1351
|
const existingIframe = getWalletIframe();
|
|
1356
1352
|
if (!existingIframe) {
|
|
1357
1353
|
const iframe = document.createElement("iframe");
|
|
1358
1354
|
iframe.id = "match-wallet";
|
|
1359
|
-
iframe.src = endpoints.
|
|
1355
|
+
iframe.src = endpoints.auth + "wallet";
|
|
1360
1356
|
iframe.style.display = "none";
|
|
1361
1357
|
iframe.style.width = "0";
|
|
1362
1358
|
iframe.style.height = "0";
|
|
@@ -1370,8 +1366,8 @@ function useWalletInit({
|
|
|
1370
1366
|
source: "matchid"
|
|
1371
1367
|
};
|
|
1372
1368
|
if (document.getElementById("match-wallet")) {
|
|
1373
|
-
matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.
|
|
1374
|
-
getWalletIframe()?.contentWindow?.postMessage(message, endpoints.
|
|
1369
|
+
matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.auth);
|
|
1370
|
+
getWalletIframe()?.contentWindow?.postMessage(message, endpoints.auth);
|
|
1375
1371
|
return messageId;
|
|
1376
1372
|
}
|
|
1377
1373
|
console.error("not found iframe");
|
|
@@ -1398,16 +1394,16 @@ function useWalletInit({
|
|
|
1398
1394
|
});
|
|
1399
1395
|
};
|
|
1400
1396
|
} else {
|
|
1401
|
-
if (existingIframe.src !== endpoints.
|
|
1397
|
+
if (existingIframe.src !== endpoints.auth + "wallet") {
|
|
1402
1398
|
setWalletInited(false);
|
|
1403
|
-
existingIframe.src = endpoints.
|
|
1399
|
+
existingIframe.src = endpoints.auth + "wallet";
|
|
1404
1400
|
}
|
|
1405
1401
|
}
|
|
1406
1402
|
}
|
|
1407
|
-
}, [
|
|
1403
|
+
}, [endpoints.auth]);
|
|
1408
1404
|
(0, import_react6.useEffect)(() => {
|
|
1409
1405
|
const messageHandle = async (e) => {
|
|
1410
|
-
if (e.origin !==
|
|
1406
|
+
if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
|
|
1411
1407
|
return;
|
|
1412
1408
|
}
|
|
1413
1409
|
const res = e.data;
|
|
@@ -1473,12 +1469,12 @@ var import_react7 = require("react");
|
|
|
1473
1469
|
function useInit({
|
|
1474
1470
|
theme,
|
|
1475
1471
|
appid,
|
|
1476
|
-
|
|
1477
|
-
|
|
1472
|
+
events,
|
|
1473
|
+
endpoints
|
|
1478
1474
|
}) {
|
|
1479
1475
|
const {
|
|
1480
1476
|
setAppid,
|
|
1481
|
-
|
|
1477
|
+
setEndpoints,
|
|
1482
1478
|
setToken,
|
|
1483
1479
|
setMid,
|
|
1484
1480
|
token,
|
|
@@ -1488,8 +1484,7 @@ function useInit({
|
|
|
1488
1484
|
const overviewLoadingRef = (0, import_react7.useRef)(false);
|
|
1489
1485
|
const searchParams = new URLSearchParams(window.location.search);
|
|
1490
1486
|
const matchToken = searchParams.get("matchToken");
|
|
1491
|
-
const
|
|
1492
|
-
const endpoints = config.endpoints;
|
|
1487
|
+
const realEndpoints = endpoints || env_default.endpoints;
|
|
1493
1488
|
(0, import_react7.useEffect)(() => {
|
|
1494
1489
|
setTheme(theme);
|
|
1495
1490
|
}, [theme]);
|
|
@@ -1497,8 +1492,8 @@ function useInit({
|
|
|
1497
1492
|
setAppid(appid);
|
|
1498
1493
|
}, [appid]);
|
|
1499
1494
|
(0, import_react7.useEffect)(() => {
|
|
1500
|
-
|
|
1501
|
-
}, [
|
|
1495
|
+
setEndpoints(realEndpoints);
|
|
1496
|
+
}, [realEndpoints]);
|
|
1502
1497
|
(0, import_react7.useEffect)(() => {
|
|
1503
1498
|
if (matchToken) {
|
|
1504
1499
|
const tokenData = JSON.parse(atob(matchToken));
|
|
@@ -1571,8 +1566,7 @@ function useInit({
|
|
|
1571
1566
|
return {
|
|
1572
1567
|
loadOverview,
|
|
1573
1568
|
login,
|
|
1574
|
-
|
|
1575
|
-
endpoints
|
|
1569
|
+
endpoints: realEndpoints
|
|
1576
1570
|
};
|
|
1577
1571
|
}
|
|
1578
1572
|
|
|
@@ -1581,12 +1575,12 @@ var import_react_query = require("@tanstack/react-query");
|
|
|
1581
1575
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1582
1576
|
var queryClient = new import_react_query.QueryClient();
|
|
1583
1577
|
var MatchContext = (0, import_react8.createContext)(void 0);
|
|
1584
|
-
var MatchProvider = ({ children, appid,
|
|
1585
|
-
const { loadOverview, login,
|
|
1578
|
+
var MatchProvider = ({ children, appid, events, theme = "light", endpoints }) => {
|
|
1579
|
+
const { loadOverview, login, endpoints: realEndPoints } = useInit({
|
|
1586
1580
|
theme,
|
|
1587
1581
|
appid,
|
|
1588
|
-
|
|
1589
|
-
|
|
1582
|
+
events,
|
|
1583
|
+
endpoints
|
|
1590
1584
|
});
|
|
1591
1585
|
useWalletInit({
|
|
1592
1586
|
refreshOverview: loadOverview
|
|
@@ -1596,8 +1590,7 @@ var MatchProvider = ({ children, appid, env = "main", events, theme = "light" })
|
|
|
1596
1590
|
{
|
|
1597
1591
|
value: {
|
|
1598
1592
|
appid,
|
|
1599
|
-
|
|
1600
|
-
endpoints,
|
|
1593
|
+
endpoints: realEndPoints,
|
|
1601
1594
|
events,
|
|
1602
1595
|
login,
|
|
1603
1596
|
theme
|
|
@@ -2080,7 +2073,8 @@ function UsernameModal({
|
|
|
2080
2073
|
var api_exports = {};
|
|
2081
2074
|
__export(api_exports, {
|
|
2082
2075
|
bind: () => bind_exports,
|
|
2083
|
-
poh: () => poh_exports
|
|
2076
|
+
poh: () => poh_exports,
|
|
2077
|
+
user: () => user_exports
|
|
2084
2078
|
});
|
|
2085
2079
|
|
|
2086
2080
|
// src/hooks/api/bind.ts
|
|
@@ -2138,6 +2132,13 @@ function usePohList(options) {
|
|
|
2138
2132
|
});
|
|
2139
2133
|
}
|
|
2140
2134
|
|
|
2135
|
+
// src/hooks/api/user.ts
|
|
2136
|
+
var user_exports = {};
|
|
2137
|
+
__export(user_exports, {
|
|
2138
|
+
chooseIdentityApi: () => chooseIdentityApi,
|
|
2139
|
+
mintPassportNftApi: () => mintPassportNftApi
|
|
2140
|
+
});
|
|
2141
|
+
|
|
2141
2142
|
// src/config/chains/index.ts
|
|
2142
2143
|
var chains_exports = {};
|
|
2143
2144
|
__export(chains_exports, {
|