nfx-ui 0.32.0 → 0.34.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.
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/dist/enums/auth.d.ts +1 -1
- package/dist/enums/auth.d.ts.map +1 -1
- package/dist/enums/auth.js +1 -1
- package/dist/enums/auth.js.map +1 -1
- package/dist/hooks/auth.d.ts +6 -1
- package/dist/hooks/auth.d.ts.map +1 -1
- package/dist/hooks/auth.js +69 -66
- package/dist/hooks/auth.js.map +1 -1
- package/dist/providers/DataProvider/index.d.ts.map +1 -1
- package/dist/providers/DataProvider/index.js +63 -41
- package/dist/providers/DataProvider/index.js.map +1 -1
- package/package.json +1 -1
- package/src/enums/auth.ts +1 -1
- package/src/hooks/auth.ts +14 -4
- package/src/providers/DataProvider/index.tsx +39 -6
package/README.en.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[中文](README.md)
|
|
4
4
|
|
|
5
|
-
Shared React library for NebulaForgeX (theme, i18n, hooks). **Not** a standalone site. Hosts: Identity,
|
|
5
|
+
Shared React library for NebulaForgeX (theme, i18n, hooks). **Not** a standalone site. Hosts: Identity, Edge, News, Storages, Documentation.
|
|
6
6
|
|
|
7
|
-
Exports and host wiring: [NFX-Documentation chapter 7](https://github.com/NebulaForgeX/NFX-Documentation/blob/main/books/en/chapter-07-nfx-ui.md). Current **0.
|
|
7
|
+
Exports and host wiring: [NFX-Documentation chapter 7](https://github.com/NebulaForgeX/NFX-Documentation/blob/main/books/en/chapter-07-nfx-ui.md). Current **0.34.0**; hosts pin exactly `"nfx-ui": "0.34.0"`. No `file:` dual path.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install
|
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.en.md)
|
|
4
4
|
|
|
5
|
-
NebulaForgeX 共享 React 库(主题、i18n、hooks)。**不是**独立站点。宿主:Identity、
|
|
5
|
+
NebulaForgeX 共享 React 库(主题、i18n、hooks)。**不是**独立站点。宿主:Identity、Edge、News、Storages、Documentation。
|
|
6
6
|
|
|
7
|
-
接入与真实导出:[NFX-Documentation 第七章](https://github.com/NebulaForgeX/NFX-Documentation/blob/main/books/zh/chapter-07-nfx-ui.md)。当前 **0.
|
|
7
|
+
接入与真实导出:[NFX-Documentation 第七章](https://github.com/NebulaForgeX/NFX-Documentation/blob/main/books/zh/chapter-07-nfx-ui.md)。当前 **0.34.0**,宿主精确钉 `"nfx-ui": "0.34.0"`。不要 `file:` 双路径。
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install
|
package/dist/enums/auth.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare enum AuthSignupPlatformEnum {
|
|
|
32
32
|
NFXIDENTITY = "nfxidentity",
|
|
33
33
|
NFXNEWS = "nfxnews",
|
|
34
34
|
NFXSTORAGES = "nfxstorages",
|
|
35
|
-
|
|
35
|
+
NFXEDGE = "nfxedge"
|
|
36
36
|
}
|
|
37
37
|
export declare const DEFAULT_AUTH_SIGNUP_PLATFORM = AuthSignupPlatformEnum.NFXIDENTITY;
|
|
38
38
|
export declare const AUTH_SIGNUP_PLATFORM_VALUES: AuthSignupPlatformEnum[];
|
package/dist/enums/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/enums/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,OAAO,CAEzE;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,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2BACmB,CAAC;AAE7E,oBAAY,wBAAwB;IAClC,QAAQ,aAAa;CACtB;AACD,eAAO,MAAM,8BAA8B,oCAAoC,CAAC;AAChF,eAAO,MAAM,6BAA6B,qCAA0C,CAAC;AACrF,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,CAAC,MAAM,CAAC,6BACqB,CAAC;AAEjF,oBAAY,aAAa;IACvB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB"}
|
package/dist/enums/auth.js
CHANGED
|
@@ -13,7 +13,7 @@ var i = /* @__PURE__ */ function(e) {
|
|
|
13
13
|
}({}), l = "forger", u = Object.values(c), d = (e) => t(e, u, l), f = /* @__PURE__ */ function(e) {
|
|
14
14
|
return e.AUDITOR = "auditor", e.ADMINISTRATOR = "administrator", e.OWNER = "owner", e;
|
|
15
15
|
}({}), p = "administrator", m = Object.values(f), h = (e) => t(e, m, p), g = m.filter((e) => e !== "owner"), _ = /* @__PURE__ */ function(e) {
|
|
16
|
-
return e.NFXIDENTITY = "nfxidentity", e.NFXNEWS = "nfxnews", e.NFXSTORAGES = "nfxstorages", e.
|
|
16
|
+
return e.NFXIDENTITY = "nfxidentity", e.NFXNEWS = "nfxnews", e.NFXSTORAGES = "nfxstorages", e.NFXEDGE = "nfxedge", e;
|
|
17
17
|
}({}), v = "nfxidentity", y = Object.values(_), b = (e) => t(e, y, v), x = /* @__PURE__ */ function(e) {
|
|
18
18
|
return e.PASSWORD = "password", e;
|
|
19
19
|
}({}), S = "password", C = Object.values(x), w = (e) => t(e, C, S), T = /* @__PURE__ */ function(e) {
|
package/dist/enums/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":[],"sources":["../../src/enums/auth.ts"],"sourcesContent":["/**\n * Auth 枚举,镜像 Identity 后端。\n * ProfileKindEnum 与 JWT profile_scope 共用 wire 值 \"community\" | \"authority\"。\n * forger 是 community 档上的角色(AuthForgerRoleEnum),不是 kind。\n * 角色不在 JWT;能力门控按纯成员判定(hasRole / hasAnyRole)。\n */\n\nimport type { Nilable } from \"nfx-ui/types\";\n\nimport { safeArray, safeEnum } from \"nfx-ui/utils/safe\";\n\nexport function hasRole<T>(role: T, roles: Nilable<readonly T[]>): boolean {\n return safeArray(roles).includes(role);\n}\n\nexport function hasAnyRole<T>(roles: Nilable<readonly T[]>, ...candidates: T[]): boolean {\n return candidates.some((role) => hasRole(role, roles));\n}\n\n/** 与后端 ProfileKind / profile_scope 一致(\"community\" | \"authority\")。forger 是 community 档上的角色,不是 kind。 */\nexport enum ProfileKindEnum {\n COMMUNITY = \"community\",\n AUTHORITY = \"authority\",\n}\n\nexport const DEFAULT_PROFILE_KIND = ProfileKindEnum.COMMUNITY;\nexport const PROFILE_KIND_VALUES = Object.values(ProfileKindEnum);\nexport const ProfileKind = (value: Nilable<string>) => safeEnum(value, PROFILE_KIND_VALUES, DEFAULT_PROFILE_KIND);\n\n/** 普通档 forger_roles。 */\nexport enum AuthForgerRoleEnum {\n FORGER = \"forger\",\n}\nexport const DEFAULT_AUTH_FORGER_ROLE = AuthForgerRoleEnum.FORGER;\nexport const AUTH_FORGER_ROLE_VALUES = Object.values(AuthForgerRoleEnum);\nexport const AuthForgerRole = (value: Nilable<string>) => safeEnum(value, AUTH_FORGER_ROLE_VALUES, DEFAULT_AUTH_FORGER_ROLE);\n\n/** 管理档 authority_roles。角色不是包含关系。 */\nexport enum AuthAuthorityRoleEnum {\n AUDITOR = \"auditor\",\n ADMINISTRATOR = \"administrator\",\n OWNER = \"owner\",\n}\n\nexport const DEFAULT_AUTH_AUTHORITY_ROLE = AuthAuthorityRoleEnum.ADMINISTRATOR;\nexport const AUTH_AUTHORITY_ROLE_VALUES = Object.values(AuthAuthorityRoleEnum);\nexport const AuthAuthorityRole = (value: Nilable<string>) =>\n safeEnum(value, AUTH_AUTHORITY_ROLE_VALUES, DEFAULT_AUTH_AUTHORITY_ROLE);\n\n/** 可通过 UI/API 分配的权限角色(owner 仅允许数据库手动变更)。 */\nexport const UI_ASSIGNABLE_AUTH_AUTHORITY_ROLES = AUTH_AUTHORITY_ROLE_VALUES.filter(\n (role): role is Exclude<AuthAuthorityRoleEnum, AuthAuthorityRoleEnum.OWNER> => role !== AuthAuthorityRoleEnum.OWNER,\n);\n\nexport type ProfileRole = AuthForgerRoleEnum | AuthAuthorityRoleEnum;\n\nexport enum AuthSignupPlatformEnum {\n NFXIDENTITY = \"nfxidentity\",\n NFXNEWS = \"nfxnews\",\n NFXSTORAGES = \"nfxstorages\",\n
|
|
1
|
+
{"version":3,"file":"auth.js","names":[],"sources":["../../src/enums/auth.ts"],"sourcesContent":["/**\n * Auth 枚举,镜像 Identity 后端。\n * ProfileKindEnum 与 JWT profile_scope 共用 wire 值 \"community\" | \"authority\"。\n * forger 是 community 档上的角色(AuthForgerRoleEnum),不是 kind。\n * 角色不在 JWT;能力门控按纯成员判定(hasRole / hasAnyRole)。\n */\n\nimport type { Nilable } from \"nfx-ui/types\";\n\nimport { safeArray, safeEnum } from \"nfx-ui/utils/safe\";\n\nexport function hasRole<T>(role: T, roles: Nilable<readonly T[]>): boolean {\n return safeArray(roles).includes(role);\n}\n\nexport function hasAnyRole<T>(roles: Nilable<readonly T[]>, ...candidates: T[]): boolean {\n return candidates.some((role) => hasRole(role, roles));\n}\n\n/** 与后端 ProfileKind / profile_scope 一致(\"community\" | \"authority\")。forger 是 community 档上的角色,不是 kind。 */\nexport enum ProfileKindEnum {\n COMMUNITY = \"community\",\n AUTHORITY = \"authority\",\n}\n\nexport const DEFAULT_PROFILE_KIND = ProfileKindEnum.COMMUNITY;\nexport const PROFILE_KIND_VALUES = Object.values(ProfileKindEnum);\nexport const ProfileKind = (value: Nilable<string>) => safeEnum(value, PROFILE_KIND_VALUES, DEFAULT_PROFILE_KIND);\n\n/** 普通档 forger_roles。 */\nexport enum AuthForgerRoleEnum {\n FORGER = \"forger\",\n}\nexport const DEFAULT_AUTH_FORGER_ROLE = AuthForgerRoleEnum.FORGER;\nexport const AUTH_FORGER_ROLE_VALUES = Object.values(AuthForgerRoleEnum);\nexport const AuthForgerRole = (value: Nilable<string>) => safeEnum(value, AUTH_FORGER_ROLE_VALUES, DEFAULT_AUTH_FORGER_ROLE);\n\n/** 管理档 authority_roles。角色不是包含关系。 */\nexport enum AuthAuthorityRoleEnum {\n AUDITOR = \"auditor\",\n ADMINISTRATOR = \"administrator\",\n OWNER = \"owner\",\n}\n\nexport const DEFAULT_AUTH_AUTHORITY_ROLE = AuthAuthorityRoleEnum.ADMINISTRATOR;\nexport const AUTH_AUTHORITY_ROLE_VALUES = Object.values(AuthAuthorityRoleEnum);\nexport const AuthAuthorityRole = (value: Nilable<string>) =>\n safeEnum(value, AUTH_AUTHORITY_ROLE_VALUES, DEFAULT_AUTH_AUTHORITY_ROLE);\n\n/** 可通过 UI/API 分配的权限角色(owner 仅允许数据库手动变更)。 */\nexport const UI_ASSIGNABLE_AUTH_AUTHORITY_ROLES = AUTH_AUTHORITY_ROLE_VALUES.filter(\n (role): role is Exclude<AuthAuthorityRoleEnum, AuthAuthorityRoleEnum.OWNER> => role !== AuthAuthorityRoleEnum.OWNER,\n);\n\nexport type ProfileRole = AuthForgerRoleEnum | AuthAuthorityRoleEnum;\n\nexport enum AuthSignupPlatformEnum {\n NFXIDENTITY = \"nfxidentity\",\n NFXNEWS = \"nfxnews\",\n NFXSTORAGES = \"nfxstorages\",\n NFXEDGE = \"nfxedge\",\n}\nexport const DEFAULT_AUTH_SIGNUP_PLATFORM = AuthSignupPlatformEnum.NFXIDENTITY;\nexport const AUTH_SIGNUP_PLATFORM_VALUES = Object.values(AuthSignupPlatformEnum);\nexport const AuthSignupPlatform = (value: Nilable<string>) =>\n safeEnum(value, AUTH_SIGNUP_PLATFORM_VALUES, DEFAULT_AUTH_SIGNUP_PLATFORM);\n\nexport enum AuthIdentityProviderEnum {\n PASSWORD = \"password\",\n}\nexport const DEFAULT_AUTH_IDENTITY_PROVIDER = AuthIdentityProviderEnum.PASSWORD;\nexport const AUTH_IDENTITY_PROVIDER_VALUES = Object.values(AuthIdentityProviderEnum);\nexport const AuthIdentityProvider = (value: Nilable<string>) =>\n safeEnum(value, AUTH_IDENTITY_PROVIDER_VALUES, DEFAULT_AUTH_IDENTITY_PROVIDER);\n\nexport enum AssetKindEnum {\n IMAGES = \"images\",\n FILES = \"files\",\n VIDEOS = \"videos\",\n AUDIOS = \"audios\",\n}\n"],"mappings":";;AAWA,SAAgB,EAAW,GAAS,GAAuC;CACzE,OAAO,EAAU,CAAK,CAAC,CAAC,SAAS,CAAI;AACvC;AAEA,SAAgB,EAAc,GAA8B,GAAG,GAA0B;CACvF,OAAO,EAAW,MAAM,MAAS,EAAQ,GAAM,CAAK,CAAC;AACvD;AAGA,IAAY,IAAL,yBAAA,GAAA;QACL,EAAA,YAAA,aACA,EAAA,YAAA;AACF,EAAA,CAAA,CAAA,GAEa,IAAA,aACA,IAAsB,OAAO,OAAO,CAAe,GACnD,KAAe,MAA2B,EAAS,GAAO,GAAqB,CAAoB,GAGpG,IAAL,yBAAA,GAAA;QACL,EAAA,SAAA;AACF,EAAA,CAAA,CAAA,GACa,IAAA,UACA,IAA0B,OAAO,OAAO,CAAkB,GAC1D,KAAkB,MAA2B,EAAS,GAAO,GAAyB,CAAwB,GAG/G,IAAL,yBAAA,GAAA;QACL,EAAA,UAAA,WACA,EAAA,gBAAA,iBACA,EAAA,QAAA;AACF,EAAA,CAAA,CAAA,GAEa,IAAA,iBACA,IAA6B,OAAO,OAAO,CAAqB,GAChE,KAAqB,MAChC,EAAS,GAAO,GAA4B,CAA2B,GAG5D,IAAqC,EAA2B,QAC1E,MAA8E,MAAA,OACjF,GAIY,IAAL,yBAAA,GAAA;QACL,EAAA,cAAA,eACA,EAAA,UAAA,WACA,EAAA,cAAA,eACA,EAAA,UAAA;AACF,EAAA,CAAA,CAAA,GACa,IAAA,eACA,IAA8B,OAAO,OAAO,CAAsB,GAClE,KAAsB,MACjC,EAAS,GAAO,GAA6B,CAA4B,GAE/D,IAAL,yBAAA,GAAA;QACL,EAAA,WAAA;AACF,EAAA,CAAA,CAAA,GACa,IAAA,YACA,IAAgC,OAAO,OAAO,CAAwB,GACtE,KAAwB,MACnC,EAAS,GAAO,GAA+B,CAA8B,GAEnE,IAAL,yBAAA,GAAA;QACL,EAAA,SAAA,UACA,EAAA,QAAA,SACA,EAAA,SAAA,UACA,EAAA,SAAA;AACF,EAAA,CAAA,CAAA"}
|
package/dist/hooks/auth.d.ts
CHANGED
|
@@ -24,7 +24,12 @@ export declare const useLoginWithPhone: () => import('@tanstack/react-query').Us
|
|
|
24
24
|
password: string;
|
|
25
25
|
rememberMe: boolean;
|
|
26
26
|
}, unknown>;
|
|
27
|
-
export
|
|
27
|
+
export type SelectProfileOptions = {
|
|
28
|
+
/** 与 token、档案同一次提交里执行(例如跳到该档案的首页)。Runs in the same commit as the token and profile. */
|
|
29
|
+
onCommit?: () => void;
|
|
30
|
+
};
|
|
31
|
+
/** 两步登录第二步:切换当前 profile,重新签发 token。kind 决定后端分派到社区/权限档。 */
|
|
32
|
+
export declare const useSelectProfile: (options?: SelectProfileOptions) => import('@tanstack/react-query').UseMutationResult<Login.Response.SelectProfile, AxiosError<unknown, any, any>, {
|
|
28
33
|
profileId: string;
|
|
29
34
|
kind: Login.ProfileKind;
|
|
30
35
|
}, unknown>;
|
package/dist/hooks/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/hooks/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/hooks/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;A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C,OAAO,CAAC,2BAA2B,CAAC,gBAAgB,CAAC;WAUjJ,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC"}
|
package/dist/hooks/auth.js
CHANGED
|
@@ -13,8 +13,9 @@ import { pickProfile as k } from "../utils/domain/account.js";
|
|
|
13
13
|
import { useEffect as A } from "react";
|
|
14
14
|
import { useTranslation as j } from "react-i18next";
|
|
15
15
|
import { useMutation as M } from "@tanstack/react-query";
|
|
16
|
+
import { flushSync as N } from "react-dom";
|
|
16
17
|
//#region src/hooks/auth.ts
|
|
17
|
-
function
|
|
18
|
+
function P() {
|
|
18
19
|
let e = m((e) => e.currentAccountId), t = m((e) => e.currentProfileId), n = m((e) => e.isAuthValid), r = m((e) => e.currentProfileKind);
|
|
19
20
|
return {
|
|
20
21
|
aID: e,
|
|
@@ -24,14 +25,14 @@ function N() {
|
|
|
24
25
|
profileScope: r
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function F(e, t) {
|
|
28
29
|
A(() => {
|
|
29
30
|
e && a.getState().isAuthValid && c(a.getState().currentProfileId) && (_.emit(v.LOGOUT, t), s());
|
|
30
31
|
}, [e, t]);
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
let e = y(), { aID: t, pID: n, isAuthValid: r, kind: i } =
|
|
34
|
-
return
|
|
33
|
+
function I() {
|
|
34
|
+
let e = y(), { aID: t, pID: n, isAuthValid: r, kind: i } = P(), a = O(({ kind: t }) => e.GetCurrentFullAccountInformationWithProfile(t), x(t, n), { kind: i }, { enabled: r && c(n) });
|
|
35
|
+
return F(a.isError, t), {
|
|
35
36
|
kind: i,
|
|
36
37
|
data: a.data,
|
|
37
38
|
profile: k(i, a.data),
|
|
@@ -40,7 +41,7 @@ function F() {
|
|
|
40
41
|
refetch: a.refetch
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
var
|
|
44
|
+
var L = () => {
|
|
44
45
|
let e = y(), { t } = j("hooks", { keyPrefix: "account" });
|
|
45
46
|
return M({
|
|
46
47
|
mutationFn: (t) => e.SendVerificationCode(t),
|
|
@@ -51,7 +52,7 @@ var I = () => {
|
|
|
51
52
|
D.showError(g(e, "[useSendVerificationCode] error"));
|
|
52
53
|
}
|
|
53
54
|
});
|
|
54
|
-
},
|
|
55
|
+
}, R = () => {
|
|
55
56
|
let e = y();
|
|
56
57
|
return M({
|
|
57
58
|
mutationFn: async ({ rememberMe: t, ...n }) => {
|
|
@@ -71,7 +72,7 @@ var I = () => {
|
|
|
71
72
|
D.showError(g(e, "[useSignup] error"));
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
|
-
},
|
|
75
|
+
}, z = () => {
|
|
75
76
|
let e = y();
|
|
76
77
|
return M({
|
|
77
78
|
mutationFn: async ({ rememberMe: t, ...n }) => e.LoginWithEmail({
|
|
@@ -88,7 +89,7 @@ var I = () => {
|
|
|
88
89
|
D.showError(g(e, "[useLogin] error"));
|
|
89
90
|
}
|
|
90
91
|
});
|
|
91
|
-
},
|
|
92
|
+
}, B = () => {
|
|
92
93
|
let e = y();
|
|
93
94
|
return M({
|
|
94
95
|
mutationFn: async ({ rememberMe: t, ...n }) => e.LoginWithPhone({
|
|
@@ -105,26 +106,28 @@ var I = () => {
|
|
|
105
106
|
D.showError(g(e, "[useLoginWithPhone] error"));
|
|
106
107
|
}
|
|
107
108
|
});
|
|
108
|
-
},
|
|
109
|
-
let
|
|
109
|
+
}, V = (e) => {
|
|
110
|
+
let n = y();
|
|
110
111
|
return M({
|
|
111
|
-
mutationFn: async ({ profileId:
|
|
112
|
-
profileId:
|
|
113
|
-
kind:
|
|
112
|
+
mutationFn: async ({ profileId: e, kind: t }) => n.SelectProfile({
|
|
113
|
+
profileId: e,
|
|
114
|
+
kind: t,
|
|
114
115
|
deviceId: await h()
|
|
115
116
|
}),
|
|
116
|
-
onSuccess: (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
onSuccess: (n, r) => {
|
|
118
|
+
n?.accessToken && (N(() => {
|
|
119
|
+
p({
|
|
120
|
+
accessToken: n.accessToken,
|
|
121
|
+
refreshToken: t(n.refreshToken)
|
|
122
|
+
}), d(r.kind), n.profileId && u(n.profileId), e?.onCommit?.();
|
|
123
|
+
}), _.emit(v.LOGIN_SUCCESS, n.accountId));
|
|
121
124
|
},
|
|
122
125
|
onError: (e) => {
|
|
123
126
|
D.showError(g(e, "[useSelectProfile] error"));
|
|
124
127
|
}
|
|
125
128
|
});
|
|
126
|
-
},
|
|
127
|
-
let n = y(), { kind: r } =
|
|
129
|
+
}, H = (t) => {
|
|
130
|
+
let n = y(), { kind: r } = P(), i = e(t?.silent, !1), { t: o } = j("pages.User.Profile.Edit");
|
|
128
131
|
return M({
|
|
129
132
|
mutationFn: (e) => n.PatchProfile(r, e),
|
|
130
133
|
onSuccess: () => {
|
|
@@ -139,8 +142,8 @@ var I = () => {
|
|
|
139
142
|
i || D.showError(g(e, "[usePatchProfile] error"));
|
|
140
143
|
}
|
|
141
144
|
});
|
|
142
|
-
},
|
|
143
|
-
let e = y(), { kind: t } =
|
|
145
|
+
}, U = () => {
|
|
146
|
+
let e = y(), { kind: t } = P(), { t: n } = j("hooks", { keyPrefix: "account" });
|
|
144
147
|
return M({
|
|
145
148
|
mutationFn: (n) => e.PatchProfileSettings(t, n),
|
|
146
149
|
onSuccess: () => {
|
|
@@ -151,21 +154,21 @@ var I = () => {
|
|
|
151
154
|
D.showError(g(e, "[useUpdateProfileSettings] error"));
|
|
152
155
|
}
|
|
153
156
|
});
|
|
154
|
-
},
|
|
155
|
-
let e = y(), { kind: t } =
|
|
157
|
+
}, W = () => {
|
|
158
|
+
let e = y(), { kind: t } = P();
|
|
156
159
|
return M({
|
|
157
160
|
mutationFn: (n) => e.UpdatePreference(t, n),
|
|
158
161
|
onError: (e) => {
|
|
159
162
|
D.showError(g(e, "[useUpdatePreference] error"));
|
|
160
163
|
}
|
|
161
164
|
});
|
|
162
|
-
},
|
|
163
|
-
let t = y(), { aID: n, isAuthValid: r } =
|
|
165
|
+
}, G = (e) => {
|
|
166
|
+
let t = y(), { aID: n, isAuthValid: r } = P();
|
|
164
167
|
return O(() => t.ListProfiles(e, {
|
|
165
168
|
limit: 50,
|
|
166
169
|
offset: 0
|
|
167
170
|
}), ee(n, e), void 0, { enabled: r && !!n });
|
|
168
|
-
},
|
|
171
|
+
}, K = () => {
|
|
169
172
|
let e = y();
|
|
170
173
|
return M({
|
|
171
174
|
mutationFn: (t) => e.CreateForgerProfile(t),
|
|
@@ -180,7 +183,7 @@ var I = () => {
|
|
|
180
183
|
D.showError(g(e, "[useCreateForgerProfile] error"));
|
|
181
184
|
}
|
|
182
185
|
});
|
|
183
|
-
},
|
|
186
|
+
}, q = () => {
|
|
184
187
|
let e = y();
|
|
185
188
|
return M({
|
|
186
189
|
mutationFn: (t) => e.CreateAuthorityProfile(t),
|
|
@@ -195,7 +198,7 @@ var I = () => {
|
|
|
195
198
|
D.showError(g(e, "[useCreateAuthorityProfile] error"));
|
|
196
199
|
}
|
|
197
200
|
});
|
|
198
|
-
},
|
|
201
|
+
}, J = () => {
|
|
199
202
|
let e = y();
|
|
200
203
|
return M({
|
|
201
204
|
mutationFn: ({ kind: t, profileId: n }) => e.DeleteProfile(t, n),
|
|
@@ -210,8 +213,8 @@ var I = () => {
|
|
|
210
213
|
D.showError(g(e, "[useDeleteProfile] error"));
|
|
211
214
|
}
|
|
212
215
|
});
|
|
213
|
-
},
|
|
214
|
-
let e = y(), { kind: t } =
|
|
216
|
+
}, te = () => {
|
|
217
|
+
let e = y(), { kind: t } = P();
|
|
215
218
|
return M({
|
|
216
219
|
mutationFn: (n) => e.ConfirmProfileAvatar(t, n),
|
|
217
220
|
onSuccess: () => {
|
|
@@ -222,8 +225,8 @@ var I = () => {
|
|
|
222
225
|
D.showError(g(e, "[useConfirmProfileAvatar] error"));
|
|
223
226
|
}
|
|
224
227
|
});
|
|
225
|
-
},
|
|
226
|
-
let e = y(), { kind: t } =
|
|
228
|
+
}, Y = () => {
|
|
229
|
+
let e = y(), { kind: t } = P(), { t: n } = j("hooks", { keyPrefix: "account" });
|
|
227
230
|
return M({
|
|
228
231
|
mutationFn: () => e.ClearProfileAvatar(t),
|
|
229
232
|
onSuccess: () => {
|
|
@@ -234,19 +237,19 @@ var I = () => {
|
|
|
234
237
|
D.showError(g(e, "[useClearProfileAvatar] error"));
|
|
235
238
|
}
|
|
236
239
|
});
|
|
237
|
-
},
|
|
238
|
-
let e = y(), { aID: t, isAuthValid: n } =
|
|
240
|
+
}, X = () => {
|
|
241
|
+
let e = y(), { aID: t, isAuthValid: n } = P();
|
|
239
242
|
return O(() => e.ListEmails({
|
|
240
243
|
limit: 50,
|
|
241
244
|
offset: 0
|
|
242
245
|
}), b(t), void 0, { enabled: n && !!t });
|
|
243
|
-
},
|
|
244
|
-
let e = y(), { aID: t, isAuthValid: n } =
|
|
246
|
+
}, Z = () => {
|
|
247
|
+
let e = y(), { aID: t, isAuthValid: n } = P();
|
|
245
248
|
return O(() => e.ListPhones({
|
|
246
249
|
limit: 50,
|
|
247
250
|
offset: 0
|
|
248
251
|
}), w(t), void 0, { enabled: n && !!t });
|
|
249
|
-
},
|
|
252
|
+
}, Q = () => {
|
|
250
253
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
251
254
|
return M({
|
|
252
255
|
mutationFn: (t) => e.CreateEmail(t),
|
|
@@ -257,7 +260,7 @@ var I = () => {
|
|
|
257
260
|
D.showError(g(e, "[useCreateEmail] error"));
|
|
258
261
|
}
|
|
259
262
|
});
|
|
260
|
-
},
|
|
263
|
+
}, ne = () => {
|
|
261
264
|
let e = y(), { t } = j("hooks", { keyPrefix: "account" });
|
|
262
265
|
return M({
|
|
263
266
|
mutationFn: ({ emailId: t, lang: n }) => e.SendEmailVerificationCode(t, { lang: n }),
|
|
@@ -268,7 +271,7 @@ var I = () => {
|
|
|
268
271
|
D.showError(g(e, "[useSendEmailVerificationCode] error"));
|
|
269
272
|
}
|
|
270
273
|
});
|
|
271
|
-
},
|
|
274
|
+
}, re = () => {
|
|
272
275
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
273
276
|
return M({
|
|
274
277
|
mutationFn: ({ emailId: t, verificationCode: n }) => e.VerifyEmail(t, { verificationCode: n }),
|
|
@@ -279,7 +282,7 @@ var I = () => {
|
|
|
279
282
|
D.showError(g(e, "[useVerifyEmail] error"));
|
|
280
283
|
}
|
|
281
284
|
});
|
|
282
|
-
},
|
|
285
|
+
}, ie = () => {
|
|
283
286
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
284
287
|
return M({
|
|
285
288
|
mutationFn: ({ emailId: t, email: n }) => e.UpdateEmail(t, { email: n }),
|
|
@@ -290,7 +293,7 @@ var I = () => {
|
|
|
290
293
|
D.showError(g(e, "[useUpdateEmail] error"));
|
|
291
294
|
}
|
|
292
295
|
});
|
|
293
|
-
},
|
|
296
|
+
}, ae = () => {
|
|
294
297
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
295
298
|
return M({
|
|
296
299
|
mutationFn: (t) => e.SetPrimaryEmail(t),
|
|
@@ -301,7 +304,7 @@ var I = () => {
|
|
|
301
304
|
D.showError(g(e, "[useSetPrimaryEmail] error"));
|
|
302
305
|
}
|
|
303
306
|
});
|
|
304
|
-
},
|
|
307
|
+
}, oe = () => {
|
|
305
308
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
306
309
|
return M({
|
|
307
310
|
mutationFn: (t) => e.DeleteEmail(t),
|
|
@@ -312,7 +315,7 @@ var I = () => {
|
|
|
312
315
|
D.showError(g(e, "[useDeleteEmail] error"));
|
|
313
316
|
}
|
|
314
317
|
});
|
|
315
|
-
},
|
|
318
|
+
}, se = () => {
|
|
316
319
|
let e = y(), { t } = j("hooks", { keyPrefix: "account" });
|
|
317
320
|
return M({
|
|
318
321
|
mutationFn: (t = {}) => e.SendChangePasswordVerificationCode(t),
|
|
@@ -323,7 +326,7 @@ var I = () => {
|
|
|
323
326
|
D.showError(g(e, "[useSendChangePasswordVerificationCode] error"));
|
|
324
327
|
}
|
|
325
328
|
});
|
|
326
|
-
},
|
|
329
|
+
}, ce = () => {
|
|
327
330
|
let e = y(), { t } = j("hooks", { keyPrefix: "account" });
|
|
328
331
|
return M({
|
|
329
332
|
mutationFn: (t) => e.ChangePassword(t),
|
|
@@ -334,8 +337,8 @@ var I = () => {
|
|
|
334
337
|
D.showError(g(e, "[useChangePassword] error"));
|
|
335
338
|
}
|
|
336
339
|
});
|
|
337
|
-
},
|
|
338
|
-
let e = y(), { kind: t } =
|
|
340
|
+
}, le = () => {
|
|
341
|
+
let e = y(), { kind: t } = P();
|
|
339
342
|
return M({
|
|
340
343
|
mutationFn: (n) => e.ConfirmProfileBackgrounds(t, n),
|
|
341
344
|
onSuccess: () => {
|
|
@@ -346,7 +349,7 @@ var I = () => {
|
|
|
346
349
|
D.showError(g(e, "[useConfirmProfileBackgrounds] error"));
|
|
347
350
|
}
|
|
348
351
|
});
|
|
349
|
-
},
|
|
352
|
+
}, ue = () => {
|
|
350
353
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
351
354
|
return M({
|
|
352
355
|
mutationFn: (t) => e.CreatePhone(t),
|
|
@@ -357,7 +360,7 @@ var I = () => {
|
|
|
357
360
|
D.showError(g(e, "[useCreatePhone] error"));
|
|
358
361
|
}
|
|
359
362
|
});
|
|
360
|
-
},
|
|
363
|
+
}, de = () => {
|
|
361
364
|
let e = y(), { t } = j("hooks", { keyPrefix: "account" });
|
|
362
365
|
return M({
|
|
363
366
|
mutationFn: (t) => e.SendPhoneVerificationCode(t),
|
|
@@ -368,7 +371,7 @@ var I = () => {
|
|
|
368
371
|
D.showError(g(e, "[useSendPhoneVerificationCode] error"));
|
|
369
372
|
}
|
|
370
373
|
});
|
|
371
|
-
},
|
|
374
|
+
}, fe = () => {
|
|
372
375
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
373
376
|
return M({
|
|
374
377
|
mutationFn: ({ phoneId: t, verificationCode: n }) => e.VerifyPhone(t, { verificationCode: n }),
|
|
@@ -379,7 +382,7 @@ var I = () => {
|
|
|
379
382
|
D.showError(g(e, "[useVerifyPhone] error"));
|
|
380
383
|
}
|
|
381
384
|
});
|
|
382
|
-
},
|
|
385
|
+
}, pe = () => {
|
|
383
386
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
384
387
|
return M({
|
|
385
388
|
mutationFn: ({ phoneId: t, phone: n }) => e.UpdatePhone(t, { phone: n }),
|
|
@@ -390,7 +393,7 @@ var I = () => {
|
|
|
390
393
|
D.showError(g(e, "[useUpdatePhone] error"));
|
|
391
394
|
}
|
|
392
395
|
});
|
|
393
|
-
},
|
|
396
|
+
}, $ = () => {
|
|
394
397
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
395
398
|
return M({
|
|
396
399
|
mutationFn: (t) => e.SetPrimaryPhone(t),
|
|
@@ -401,7 +404,7 @@ var I = () => {
|
|
|
401
404
|
D.showError(g(e, "[useSetPrimaryPhone] error"));
|
|
402
405
|
}
|
|
403
406
|
});
|
|
404
|
-
},
|
|
407
|
+
}, me = () => {
|
|
405
408
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
406
409
|
return M({
|
|
407
410
|
mutationFn: (t) => e.DeletePhone(t),
|
|
@@ -412,38 +415,38 @@ var I = () => {
|
|
|
412
415
|
D.showError(g(e, "[useDeletePhone] error"));
|
|
413
416
|
}
|
|
414
417
|
});
|
|
415
|
-
},
|
|
416
|
-
let t = y(), { aID: n, isAuthValid: r } =
|
|
418
|
+
}, he = (e) => {
|
|
419
|
+
let t = y(), { aID: n, isAuthValid: r } = P(), a = e.trim();
|
|
417
420
|
return O(({ query: e }) => t.SearchForgerProfiles({
|
|
418
421
|
query: e,
|
|
419
422
|
limit: 50,
|
|
420
423
|
offset: 0
|
|
421
424
|
}), T(n, i.COMMUNITY, a), { query: a }, { enabled: r && !!n && a.length > 0 });
|
|
422
|
-
},
|
|
423
|
-
let t = y(), { aID: n, isAuthValid: r } =
|
|
425
|
+
}, ge = (e) => {
|
|
426
|
+
let t = y(), { aID: n, isAuthValid: r } = P(), a = e.trim();
|
|
424
427
|
return O(({ query: e }) => t.SearchAuthorityProfiles({
|
|
425
428
|
query: e,
|
|
426
429
|
limit: 50,
|
|
427
430
|
offset: 0
|
|
428
431
|
}), T(n, i.AUTHORITY, a), { query: a }, { enabled: r && !!n && a.length > 0 });
|
|
429
|
-
},
|
|
430
|
-
let t = y(), { isAuthValid: n } =
|
|
432
|
+
}, _e = (e) => {
|
|
433
|
+
let t = y(), { isAuthValid: n } = P();
|
|
431
434
|
return O(() => t.GetPublicProfileCard(e), E(e), void 0, { enabled: n && !!e });
|
|
432
|
-
},
|
|
433
|
-
let t = y(), { aID: n, isAuthValid: r } =
|
|
435
|
+
}, ve = (e = "") => {
|
|
436
|
+
let t = y(), { aID: n, isAuthValid: r } = P(), i = e.trim();
|
|
434
437
|
return O(({ query: e }) => t.ListOwnerForgerProfiles({
|
|
435
438
|
limit: 50,
|
|
436
439
|
offset: 0,
|
|
437
440
|
query: e || void 0
|
|
438
441
|
}), [...C(n), i], { query: i }, { enabled: r && !!n });
|
|
439
|
-
},
|
|
440
|
-
let t = y(), { aID: n, isAuthValid: r } =
|
|
442
|
+
}, ye = (e = "") => {
|
|
443
|
+
let t = y(), { aID: n, isAuthValid: r } = P(), i = e.trim();
|
|
441
444
|
return O(({ query: e }) => t.ListOwnerAuthorityProfiles({
|
|
442
445
|
limit: 50,
|
|
443
446
|
offset: 0,
|
|
444
447
|
query: e || void 0
|
|
445
448
|
}), [...S(n), i], { query: i }, { enabled: r && !!n });
|
|
446
|
-
},
|
|
449
|
+
}, be = () => {
|
|
447
450
|
let e = y(), t = a.getState().currentAccountId, { t: n } = j("hooks", { keyPrefix: "account" });
|
|
448
451
|
return M({
|
|
449
452
|
mutationFn: ({ profileId: t, authorityRoles: n }) => e.UpdateAuthorityProfileRoles(t, { authorityRoles: n }),
|
|
@@ -456,6 +459,6 @@ var I = () => {
|
|
|
456
459
|
});
|
|
457
460
|
};
|
|
458
461
|
//#endregion
|
|
459
|
-
export { r as AuthSignupPlatformEnum, a as AuthStore, n as LanguageEnum, c as hasSelectedProfile,
|
|
462
|
+
export { r as AuthSignupPlatformEnum, a as AuthStore, n as LanguageEnum, c as hasSelectedProfile, P as useAuthQueryScope, m as useAuthStore, ce as useChangePassword, Y as useClearProfileAvatar, te as useConfirmProfileAvatar, le as useConfirmProfileBackgrounds, q as useCreateAuthorityProfile, Q as useCreateEmail, K as useCreateForgerProfile, ue as useCreatePhone, I as useCurrentProfile, oe as useDeleteEmail, me as useDeletePhone, J as useDeleteProfile, _e as useGetPublicProfileCard, X as useListEmails, ye as useListOwnerAuthorityProfiles, ve as useListOwnerForgerProfiles, Z as useListPhones, G as useListProfiles, z as useLoginWithEmail, B as useLoginWithPhone, H as usePatchProfile, ge as useSearchAuthorityProfiles, he as useSearchForgerProfiles, V as useSelectProfile, se as useSendChangePasswordVerificationCode, ne as useSendEmailVerificationCode, de as useSendPhoneVerificationCode, L as useSendVerificationCode, ae as useSetPrimaryEmail, $ as useSetPrimaryPhone, R as useSignupWithEmail, be as useUpdateAuthorityProfileRoles, ie as useUpdateEmail, pe as useUpdatePhone, W as useUpdatePreference, U as useUpdateProfileSettings, re as useVerifyEmail, fe as useVerifyPhone };
|
|
460
463
|
|
|
461
464
|
//# sourceMappingURL=auth.js.map
|
package/dist/hooks/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":[],"sources":["../../src/hooks/auth.ts"],"sourcesContent":["/**\n * Auth hooks — 组件勿直接调 apis/auth\n */\nimport type { AxiosError } from \"axios\";\nimport type { CurrentProfileResult, Login, Profile, Signup } from \"nfx-ui/types\";\n\nimport { useEffect } from \"react\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useAuthRepository } from \"nfx-ui/apis/repositories\";\nimport { AUTH_EMAILS, AUTH_ME, AUTH_OWNER_AUTHORITIES, AUTH_OWNER_FORGERS, AUTH_PHONES, AUTH_PROFILE_SEARCH, AUTH_PROFILES, AUTH_PUBLIC_CARD } from \"nfx-ui/constants\";\nimport { AuthSignupPlatformEnum, LanguageEnum, ProfileKindEnum } from \"nfx-ui/enums\";\nimport { authEventEmitter, authEvents } from \"nfx-ui/events/auth\";\nimport { systemEventEmitter } from \"nfx-ui/events/system\";\nimport {\n AuthStore,\n clearAuth,\n EMPTY_PROFILE_ID,\n hasSelectedProfile,\n setCurrentAccountId,\n setCurrentProfileId,\n setCurrentProfileKind,\n setIsAuthValid,\n setTokens,\n useAuthStore,\n} from \"nfx-ui/stores/auth\";\nimport { ensureDeviceIdStorage } from \"nfx-ui/stores/system\";\nimport { getApiErrorMessage } from \"nfx-ui/utils/apiError\";\nimport { pickProfile } from \"nfx-ui/utils/domain/account\";\nimport { useUnifiedQuery } from \"nfx-ui/utils/factory\";\nimport { safeOr, safeStringable } from \"nfx-ui/utils/safe\";\nimport { useTranslation } from \"react-i18next\";\n\nexport function useAuthQueryScope() {\n const aID = useAuthStore((s) => s.currentAccountId);\n const pID = useAuthStore((s) => s.currentProfileId);\n const isAuthValid = useAuthStore((s) => s.isAuthValid);\n const kind = useAuthStore((s) => s.currentProfileKind);\n return { aID, pID, isAuthValid, kind, profileScope: kind };\n}\n\nfunction useLogoutOnAuthError(isError: boolean, aID: string) {\n useEffect(() => {\n if (!isError || !AuthStore.getState().isAuthValid) return;\n if (!hasSelectedProfile(AuthStore.getState().currentProfileId)) return;\n authEventEmitter.emit(authEvents.LOGOUT, aID);\n clearAuth();\n }, [isError, aID]);\n}\n\nexport function useCurrentProfile(): CurrentProfileResult {\n const auth = useAuthRepository();\n const { aID, pID, isAuthValid, kind } = useAuthQueryScope();\n const result = useUnifiedQuery(\n ({ kind }: { kind: ProfileKindEnum }) => auth.GetCurrentFullAccountInformationWithProfile(kind),\n AUTH_ME(aID, pID),\n { kind },\n { enabled: isAuthValid && hasSelectedProfile(pID) },\n );\n useLogoutOnAuthError(result.isError, aID);\n return {\n kind,\n data: result.data,\n profile: pickProfile(kind, result.data),\n isLoading: result.isLoading,\n isError: result.isError,\n refetch: result.refetch,\n } as CurrentProfileResult;\n}\n\nexport const useSendVerificationCode = () => {\n const auth = useAuthRepository();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (params: Signup.Request.SendVerificationCode) => auth.SendVerificationCode(params),\n onSuccess: () => {\n systemEventEmitter.showSuccess(t(\"sendVerificationCodeSuccess\", { defaultValue: \"Code sent\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSendVerificationCode] error\"));\n },\n });\n};\n\nexport const useSignupWithEmail = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: async ({\n rememberMe,\n ...params\n }: {\n rememberMe: boolean;\n } & Omit<Signup.Request.SignupWithEmail, \"deviceId\">): Promise<Signup.Response.SignupWithEmail> => {\n const deviceId = await ensureDeviceIdStorage();\n return auth.SignupWithEmail({\n ...params,\n deviceId,\n });\n },\n onSuccess: (result, variables) => {\n if (!result?.accessToken) return;\n setTokens(\n {\n accessToken: result.accessToken,\n refreshToken: safeStringable(result.refreshToken),\n },\n { rememberMe: variables.rememberMe },\n );\n setIsAuthValid(true);\n if (result.accountId) setCurrentAccountId(result.accountId);\n if (result.profileId) {\n setCurrentProfileId(result.profileId);\n setCurrentProfileKind(ProfileKindEnum.COMMUNITY);\n authEventEmitter.emit(authEvents.LOGIN_SUCCESS, result.accountId);\n } else {\n setCurrentProfileId(EMPTY_PROFILE_ID);\n }\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSignup] error\"));\n },\n });\n};\n\nexport const useLoginWithEmail = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: async ({ rememberMe, ...params }: { email: string; password: string; rememberMe: boolean }) =>\n auth.LoginWithEmail({\n ...params,\n deviceId: await ensureDeviceIdStorage(),\n }),\n onSuccess: (result, variables) => {\n if (!result?.accessToken) return;\n setCurrentProfileId(EMPTY_PROFILE_ID);\n setTokens(\n {\n accessToken: result.accessToken,\n refreshToken: safeStringable(result.refreshToken),\n },\n { rememberMe: variables.rememberMe },\n );\n setIsAuthValid(true);\n if (result.accountId) setCurrentAccountId(result.accountId);\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useLogin] error\"));\n },\n });\n};\n\nexport const useLoginWithPhone = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: async ({ rememberMe, ...params }: { phone: string; password: string; rememberMe: boolean }) =>\n auth.LoginWithPhone({\n ...params,\n deviceId: await ensureDeviceIdStorage(),\n }),\n onSuccess: (result, variables) => {\n if (!result?.accessToken) return;\n setCurrentProfileId(EMPTY_PROFILE_ID);\n setTokens(\n {\n accessToken: result.accessToken,\n refreshToken: safeStringable(result.refreshToken),\n },\n { rememberMe: variables.rememberMe },\n );\n setIsAuthValid(true);\n if (result.accountId) setCurrentAccountId(result.accountId);\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useLoginWithPhone] error\"));\n },\n });\n};\n\nexport const useSelectProfile = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: async ({ profileId, kind }: { profileId: string; kind: Login.ProfileKind }) =>\n auth.SelectProfile({\n profileId,\n kind,\n deviceId: await ensureDeviceIdStorage(),\n }),\n onSuccess: (result, variables) => {\n if (result?.accessToken) {\n setTokens({\n accessToken: result.accessToken,\n refreshToken: safeStringable(result.refreshToken),\n });\n setCurrentProfileKind(variables.kind);\n if (result.profileId) setCurrentProfileId(result.profileId);\n authEventEmitter.emit(authEvents.LOGIN_SUCCESS, result.accountId);\n }\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSelectProfile] error\"));\n },\n });\n};\n\nexport const usePatchProfile = (options?: { silent?: boolean }) => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n const silent = safeOr(options?.silent, false);\n const { t } = useTranslation(\"pages.User.Profile.Edit\");\n return useMutation({\n mutationFn: (body: Profile.Request.PatchProfile) => auth.PatchProfile(kind, body),\n onSuccess: () => {\n if (!silent) systemEventEmitter.showSuccess(t(\"saveSuccess\", { defaultValue: \"Saved\" }));\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.invalidateProfiles({ aID, kind });\n },\n onError: (error: AxiosError) => {\n if (!silent) systemEventEmitter.showError(getApiErrorMessage(error, \"[usePatchProfile] error\"));\n },\n });\n};\n\nexport const useUpdateProfileSettings = () => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (body: Profile.Request.PatchProfileSettings) => auth.PatchProfileSettings(kind, body),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, aID);\n systemEventEmitter.showSuccess(t(\"updateSettingsSuccess\", { defaultValue: \"Settings updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useUpdateProfileSettings] error\"));\n },\n });\n};\n\nexport const useUpdatePreference = () => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n return useMutation({\n mutationFn: (preference: string) => auth.UpdatePreference(kind, preference),\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useUpdatePreference] error\"));\n },\n });\n};\n\nexport const useListProfiles = <K extends ProfileKindEnum>(kind: K) => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n return useUnifiedQuery(\n () => auth.ListProfiles(kind, { limit: 50, offset: 0 }),\n AUTH_PROFILES(aID, kind),\n undefined,\n { enabled: isAuthValid && Boolean(aID) },\n );\n};\n\nexport const useCreateForgerProfile = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: (body: Login.Request.CreateForgerProfile) => auth.CreateForgerProfile(body),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.invalidateProfiles({ aID, kind: ProfileKindEnum.COMMUNITY });\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useCreateForgerProfile] error\"));\n },\n });\n};\n\nexport const useCreateAuthorityProfile = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: (body: Login.Request.CreateAuthorityProfile) => auth.CreateAuthorityProfile(body),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.invalidateProfiles({ aID, kind: ProfileKindEnum.AUTHORITY });\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useCreateAuthorityProfile] error\"));\n },\n });\n};\n\nexport const useDeleteProfile = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: ({ kind, profileId }: { kind: ProfileKindEnum; profileId: string }) => auth.DeleteProfile(kind, profileId),\n onSuccess: (_void, variables) => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.invalidateProfiles({ aID, kind: variables.kind });\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useDeleteProfile] error\"));\n },\n });\n};\n\nexport const useConfirmProfileAvatar = () => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n return useMutation({\n mutationFn: (body: Profile.Request.ConfirmProfileAvatar) => auth.ConfirmProfileAvatar(kind, body),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, aID);\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useConfirmProfileAvatar] error\"));\n },\n });\n};\n\nexport const useClearProfileAvatar = () => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: () => auth.ClearProfileAvatar(kind),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, aID);\n systemEventEmitter.showSuccess(t(\"clearAvatarSuccess\", { defaultValue: \"Avatar removed.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useClearProfileAvatar] error\"));\n },\n });\n};\n\nexport const useListEmails = () => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n return useUnifiedQuery(() => auth.ListEmails({ limit: 50, offset: 0 }), AUTH_EMAILS(aID), undefined, {\n enabled: isAuthValid && Boolean(aID),\n });\n};\n\nexport const useListPhones = () => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n return useUnifiedQuery(() => auth.ListPhones({ limit: 50, offset: 0 }), AUTH_PHONES(aID), undefined, {\n enabled: isAuthValid && Boolean(aID),\n });\n};\n\nexport const useCreateEmail = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (body: Login.Request.CreateEmail) => auth.CreateEmail(body),\n onSuccess: () => {\n authEventEmitter.invalidateEmails(accountId);\n systemEventEmitter.showSuccess(t(\"createEmailSuccess\", { defaultValue: \"Email added.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useCreateEmail] error\"));\n },\n });\n};\n\nexport const useSendEmailVerificationCode = () => {\n const auth = useAuthRepository();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ emailId, lang }: { emailId: string; lang?: LanguageEnum }) => auth.SendEmailVerificationCode(emailId, { lang }),\n onSuccess: () => {\n systemEventEmitter.showSuccess(t(\"sendVerificationCodeSuccess\", { defaultValue: \"Code sent\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSendEmailVerificationCode] error\"));\n },\n });\n};\n\nexport const useVerifyEmail = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ emailId, verificationCode }: { emailId: string; verificationCode: string }) =>\n auth.VerifyEmail(emailId, { verificationCode }),\n onSuccess: () => {\n authEventEmitter.invalidateEmails(accountId);\n systemEventEmitter.showSuccess(t(\"verifyEmailSuccess\", { defaultValue: \"Email verified.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useVerifyEmail] error\"));\n },\n });\n};\n\nexport const useUpdateEmail = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ emailId, email }: { emailId: string; email: string }) => auth.UpdateEmail(emailId, { email }),\n onSuccess: () => {\n authEventEmitter.invalidateEmails(accountId);\n systemEventEmitter.showSuccess(t(\"updateEmailSuccess\", { defaultValue: \"Email updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useUpdateEmail] error\"));\n },\n });\n};\n\nexport const useSetPrimaryEmail = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (emailId: string) => auth.SetPrimaryEmail(emailId),\n onSuccess: () => {\n authEventEmitter.invalidateEmails(accountId);\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, accountId);\n systemEventEmitter.showSuccess(t(\"setPrimaryEmailSuccess\", { defaultValue: \"Primary email updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSetPrimaryEmail] error\"));\n },\n });\n};\n\nexport const useDeleteEmail = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (emailId: string) => auth.DeleteEmail(emailId),\n onSuccess: () => {\n authEventEmitter.invalidateEmails(accountId);\n systemEventEmitter.showSuccess(t(\"deleteEmailSuccess\", { defaultValue: \"Email removed.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useDeleteEmail] error\"));\n },\n });\n};\n\nexport const useSendChangePasswordVerificationCode = () => {\n const auth = useAuthRepository();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (body: Login.Request.SendChangePasswordVerificationCode = {}) => auth.SendChangePasswordVerificationCode(body),\n onSuccess: () => {\n systemEventEmitter.showSuccess(t(\"sendVerificationCodeSuccess\", { defaultValue: \"Code sent\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSendChangePasswordVerificationCode] error\"));\n },\n });\n};\n\nexport const useChangePassword = () => {\n const auth = useAuthRepository();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (body: Login.Request.ChangePassword) => auth.ChangePassword(body),\n onSuccess: () => {\n systemEventEmitter.showSuccess(t(\"changePasswordSuccess\", { defaultValue: \"Password updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useChangePassword] error\"));\n },\n });\n};\n\nexport const useConfirmProfileBackgrounds = () => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n return useMutation({\n mutationFn: (body: Profile.Request.ConfirmProfileBackgrounds) => auth.ConfirmProfileBackgrounds(kind, body),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, aID);\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useConfirmProfileBackgrounds] error\"));\n },\n });\n};\n\nexport const useCreatePhone = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (body: Login.Request.CreatePhone) => auth.CreatePhone(body),\n onSuccess: () => {\n authEventEmitter.invalidatePhones(accountId);\n systemEventEmitter.showSuccess(t(\"createPhoneSuccess\", { defaultValue: \"Phone added.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useCreatePhone] error\"));\n },\n });\n};\n\nexport const useSendPhoneVerificationCode = () => {\n const auth = useAuthRepository();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (phoneId: string) => auth.SendPhoneVerificationCode(phoneId),\n onSuccess: () => {\n systemEventEmitter.showSuccess(t(\"sendVerificationCodeSuccess\", { defaultValue: \"Code sent\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSendPhoneVerificationCode] error\"));\n },\n });\n};\n\nexport const useVerifyPhone = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ phoneId, verificationCode }: { phoneId: string; verificationCode: string }) =>\n auth.VerifyPhone(phoneId, { verificationCode }),\n onSuccess: () => {\n authEventEmitter.invalidatePhones(accountId);\n systemEventEmitter.showSuccess(t(\"verifyPhoneSuccess\", { defaultValue: \"Phone verified.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useVerifyPhone] error\"));\n },\n });\n};\n\nexport const useUpdatePhone = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ phoneId, phone }: { phoneId: string; phone: string }) => auth.UpdatePhone(phoneId, { phone }),\n onSuccess: () => {\n authEventEmitter.invalidatePhones(accountId);\n systemEventEmitter.showSuccess(t(\"updatePhoneSuccess\", { defaultValue: \"Phone updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useUpdatePhone] error\"));\n },\n });\n};\n\nexport const useSetPrimaryPhone = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (phoneId: string) => auth.SetPrimaryPhone(phoneId),\n onSuccess: () => {\n authEventEmitter.invalidatePhones(accountId);\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, accountId);\n systemEventEmitter.showSuccess(t(\"setPrimaryPhoneSuccess\", { defaultValue: \"Primary phone updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSetPrimaryPhone] error\"));\n },\n });\n};\n\nexport const useDeletePhone = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (phoneId: string) => auth.DeletePhone(phoneId),\n onSuccess: () => {\n authEventEmitter.invalidatePhones(accountId);\n systemEventEmitter.showSuccess(t(\"deletePhoneSuccess\", { defaultValue: \"Phone removed.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useDeletePhone] error\"));\n },\n });\n};\n\nexport const useSearchForgerProfiles = (query: string) => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n const trimmed = query.trim();\n return useUnifiedQuery(\n ({ query: q }) => auth.SearchForgerProfiles({ query: q, limit: 50, offset: 0 }),\n AUTH_PROFILE_SEARCH(aID, ProfileKindEnum.COMMUNITY, trimmed),\n { query: trimmed },\n { enabled: isAuthValid && Boolean(aID) && trimmed.length > 0 },\n );\n};\n\nexport const useSearchAuthorityProfiles = (query: string) => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n const trimmed = query.trim();\n return useUnifiedQuery(\n ({ query: q }) => auth.SearchAuthorityProfiles({ query: q, limit: 50, offset: 0 }),\n AUTH_PROFILE_SEARCH(aID, ProfileKindEnum.AUTHORITY, trimmed),\n { query: trimmed },\n { enabled: isAuthValid && Boolean(aID) && trimmed.length > 0 },\n );\n};\n\nexport const useGetPublicProfileCard = (profileId: string) => {\n const auth = useAuthRepository();\n const { isAuthValid } = useAuthQueryScope();\n return useUnifiedQuery(\n () => auth.GetPublicProfileCard(profileId),\n AUTH_PUBLIC_CARD(profileId),\n undefined,\n { enabled: isAuthValid && Boolean(profileId) },\n );\n};\n\nexport const useListOwnerForgerProfiles = (query = \"\") => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n const trimmed = query.trim();\n return useUnifiedQuery(\n ({ query: q }) => auth.ListOwnerForgerProfiles({ limit: 50, offset: 0, query: q || undefined }),\n [...AUTH_OWNER_FORGERS(aID), trimmed],\n { query: trimmed },\n { enabled: isAuthValid && Boolean(aID) },\n );\n};\n\nexport const useListOwnerAuthorityProfiles = (query = \"\") => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n const trimmed = query.trim();\n return useUnifiedQuery(\n ({ query: q }) => auth.ListOwnerAuthorityProfiles({ limit: 50, offset: 0, query: q || undefined }),\n [...AUTH_OWNER_AUTHORITIES(aID), trimmed],\n { query: trimmed },\n { enabled: isAuthValid && Boolean(aID) },\n );\n};\n\nexport const useUpdateAuthorityProfileRoles = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ profileId, authorityRoles }: { profileId: string; authorityRoles: Profile.Request.UpdateAuthorityProfileRoles[\"authorityRoles\"] }) =>\n auth.UpdateAuthorityProfileRoles(profileId, { authorityRoles }),\n onSuccess: () => {\n authEventEmitter.invalidateOwner(accountId);\n systemEventEmitter.showSuccess(t(\"updateRolesSuccess\", { defaultValue: \"Roles updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useUpdateAuthorityProfileRoles] error\"));\n },\n });\n};\n\nexport { hasSelectedProfile, AuthStore, useAuthStore };\nexport { LanguageEnum, AuthSignupPlatformEnum };\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,SAAgB,IAAoB;CAClC,IAAM,IAAM,GAAc,MAAM,EAAE,gBAAgB,GAC5C,IAAM,GAAc,MAAM,EAAE,gBAAgB,GAC5C,IAAc,GAAc,MAAM,EAAE,WAAW,GAC/C,IAAO,GAAc,MAAM,EAAE,kBAAkB;CACrD,OAAO;EAAE;EAAK;EAAK;EAAa;EAAM,cAAc;CAAK;AAC3D;AAEA,SAAS,EAAqB,GAAkB,GAAa;CAC3D,QAAgB;EACV,AAAC,KAAY,EAAU,SAAS,CAAC,CAAC,eACjC,EAAmB,EAAU,SAAS,CAAC,CAAC,gBAAgB,MAC7D,EAAiB,KAAK,EAAW,QAAQ,CAAG,GAC5C,EAAU;CACZ,GAAG,CAAC,GAAS,CAAG,CAAC;AACnB;AAEA,SAAgB,IAA0C;CACxD,IAAM,IAAO,EAAkB,GACzB,EAAE,QAAK,QAAK,gBAAa,YAAS,EAAkB,GACpD,IAAS,GACZ,EAAE,cAAsC,EAAK,4CAA4C,CAAI,GAC9F,E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,IAAY,EAAU,SAAS,CAAC,CAAC,kBACjC,EAAE,SAAM,EAAe,SAAS,EAAE,WAAW,UAAU,CAAC;CAC9D,OAAO,EAAY;EACjB,aAAa,EAAE,cAAW,wBACxB,EAAK,4BAA4B,GAAW,EAAE,kBAAe,CAAC;EAChE,iBAAiB;GAEf,AADA,EAAiB,gBAAgB,CAAS,GAC1C,EAAmB,YAAY,EAAE,sBAAsB,EAAE,cAAc,iBAAiB,CAAC,CAAC;EAC5F;EACA,UAAU,MAAsB;GAC9B,EAAmB,UAAU,EAAmB,GAAO,wCAAwC,CAAC;EAClG;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"auth.js","names":[],"sources":["../../src/hooks/auth.ts"],"sourcesContent":["/**\n * Auth hooks — 组件勿直接调 apis/auth\n */\nimport type { AxiosError } from \"axios\";\nimport type { CurrentProfileResult, Login, Profile, Signup } from \"nfx-ui/types\";\n\nimport { useEffect } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useAuthRepository } from \"nfx-ui/apis/repositories\";\nimport { AUTH_EMAILS, AUTH_ME, AUTH_OWNER_AUTHORITIES, AUTH_OWNER_FORGERS, AUTH_PHONES, AUTH_PROFILE_SEARCH, AUTH_PROFILES, AUTH_PUBLIC_CARD } from \"nfx-ui/constants\";\nimport { AuthSignupPlatformEnum, LanguageEnum, ProfileKindEnum } from \"nfx-ui/enums\";\nimport { authEventEmitter, authEvents } from \"nfx-ui/events/auth\";\nimport { systemEventEmitter } from \"nfx-ui/events/system\";\nimport {\n AuthStore,\n clearAuth,\n EMPTY_PROFILE_ID,\n hasSelectedProfile,\n setCurrentAccountId,\n setCurrentProfileId,\n setCurrentProfileKind,\n setIsAuthValid,\n setTokens,\n useAuthStore,\n} from \"nfx-ui/stores/auth\";\nimport { ensureDeviceIdStorage } from \"nfx-ui/stores/system\";\nimport { getApiErrorMessage } from \"nfx-ui/utils/apiError\";\nimport { pickProfile } from \"nfx-ui/utils/domain/account\";\nimport { useUnifiedQuery } from \"nfx-ui/utils/factory\";\nimport { safeOr, safeStringable } from \"nfx-ui/utils/safe\";\nimport { useTranslation } from \"react-i18next\";\n\nexport function useAuthQueryScope() {\n const aID = useAuthStore((s) => s.currentAccountId);\n const pID = useAuthStore((s) => s.currentProfileId);\n const isAuthValid = useAuthStore((s) => s.isAuthValid);\n const kind = useAuthStore((s) => s.currentProfileKind);\n return { aID, pID, isAuthValid, kind, profileScope: kind };\n}\n\nfunction useLogoutOnAuthError(isError: boolean, aID: string) {\n useEffect(() => {\n if (!isError || !AuthStore.getState().isAuthValid) return;\n if (!hasSelectedProfile(AuthStore.getState().currentProfileId)) return;\n authEventEmitter.emit(authEvents.LOGOUT, aID);\n clearAuth();\n }, [isError, aID]);\n}\n\nexport function useCurrentProfile(): CurrentProfileResult {\n const auth = useAuthRepository();\n const { aID, pID, isAuthValid, kind } = useAuthQueryScope();\n const result = useUnifiedQuery(\n ({ kind }: { kind: ProfileKindEnum }) => auth.GetCurrentFullAccountInformationWithProfile(kind),\n AUTH_ME(aID, pID),\n { kind },\n { enabled: isAuthValid && hasSelectedProfile(pID) },\n );\n useLogoutOnAuthError(result.isError, aID);\n return {\n kind,\n data: result.data,\n profile: pickProfile(kind, result.data),\n isLoading: result.isLoading,\n isError: result.isError,\n refetch: result.refetch,\n } as CurrentProfileResult;\n}\n\nexport const useSendVerificationCode = () => {\n const auth = useAuthRepository();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (params: Signup.Request.SendVerificationCode) => auth.SendVerificationCode(params),\n onSuccess: () => {\n systemEventEmitter.showSuccess(t(\"sendVerificationCodeSuccess\", { defaultValue: \"Code sent\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSendVerificationCode] error\"));\n },\n });\n};\n\nexport const useSignupWithEmail = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: async ({\n rememberMe,\n ...params\n }: {\n rememberMe: boolean;\n } & Omit<Signup.Request.SignupWithEmail, \"deviceId\">): Promise<Signup.Response.SignupWithEmail> => {\n const deviceId = await ensureDeviceIdStorage();\n return auth.SignupWithEmail({\n ...params,\n deviceId,\n });\n },\n onSuccess: (result, variables) => {\n if (!result?.accessToken) return;\n setTokens(\n {\n accessToken: result.accessToken,\n refreshToken: safeStringable(result.refreshToken),\n },\n { rememberMe: variables.rememberMe },\n );\n setIsAuthValid(true);\n if (result.accountId) setCurrentAccountId(result.accountId);\n if (result.profileId) {\n setCurrentProfileId(result.profileId);\n setCurrentProfileKind(ProfileKindEnum.COMMUNITY);\n authEventEmitter.emit(authEvents.LOGIN_SUCCESS, result.accountId);\n } else {\n setCurrentProfileId(EMPTY_PROFILE_ID);\n }\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSignup] error\"));\n },\n });\n};\n\nexport const useLoginWithEmail = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: async ({ rememberMe, ...params }: { email: string; password: string; rememberMe: boolean }) =>\n auth.LoginWithEmail({\n ...params,\n deviceId: await ensureDeviceIdStorage(),\n }),\n onSuccess: (result, variables) => {\n if (!result?.accessToken) return;\n setCurrentProfileId(EMPTY_PROFILE_ID);\n setTokens(\n {\n accessToken: result.accessToken,\n refreshToken: safeStringable(result.refreshToken),\n },\n { rememberMe: variables.rememberMe },\n );\n setIsAuthValid(true);\n if (result.accountId) setCurrentAccountId(result.accountId);\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useLogin] error\"));\n },\n });\n};\n\nexport const useLoginWithPhone = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: async ({ rememberMe, ...params }: { phone: string; password: string; rememberMe: boolean }) =>\n auth.LoginWithPhone({\n ...params,\n deviceId: await ensureDeviceIdStorage(),\n }),\n onSuccess: (result, variables) => {\n if (!result?.accessToken) return;\n setCurrentProfileId(EMPTY_PROFILE_ID);\n setTokens(\n {\n accessToken: result.accessToken,\n refreshToken: safeStringable(result.refreshToken),\n },\n { rememberMe: variables.rememberMe },\n );\n setIsAuthValid(true);\n if (result.accountId) setCurrentAccountId(result.accountId);\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useLoginWithPhone] error\"));\n },\n });\n};\n\nexport type SelectProfileOptions = {\n /** 与 token、档案同一次提交里执行(例如跳到该档案的首页)。Runs in the same commit as the token and profile. */\n onCommit?: () => void;\n};\n\n/** 两步登录第二步:切换当前 profile,重新签发 token。kind 决定后端分派到社区/权限档。 */\nexport const useSelectProfile = (options?: SelectProfileOptions) => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: async ({ profileId, kind }: { profileId: string; kind: Login.ProfileKind }) =>\n auth.SelectProfile({\n profileId,\n kind,\n deviceId: await ensureDeviceIdStorage(),\n }),\n onSuccess: (result, variables) => {\n if (!result?.accessToken) return;\n // 同一次提交写入新 token 和档案,旧角色的请求在重拉前先停用。\n flushSync(() => {\n setTokens({\n accessToken: result.accessToken,\n refreshToken: safeStringable(result.refreshToken),\n });\n setCurrentProfileKind(variables.kind);\n if (result.profileId) setCurrentProfileId(result.profileId);\n options?.onCommit?.();\n });\n authEventEmitter.emit(authEvents.LOGIN_SUCCESS, result.accountId);\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSelectProfile] error\"));\n },\n });\n};\n\nexport const usePatchProfile = (options?: { silent?: boolean }) => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n const silent = safeOr(options?.silent, false);\n const { t } = useTranslation(\"pages.User.Profile.Edit\");\n return useMutation({\n mutationFn: (body: Profile.Request.PatchProfile) => auth.PatchProfile(kind, body),\n onSuccess: () => {\n if (!silent) systemEventEmitter.showSuccess(t(\"saveSuccess\", { defaultValue: \"Saved\" }));\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.invalidateProfiles({ aID, kind });\n },\n onError: (error: AxiosError) => {\n if (!silent) systemEventEmitter.showError(getApiErrorMessage(error, \"[usePatchProfile] error\"));\n },\n });\n};\n\nexport const useUpdateProfileSettings = () => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (body: Profile.Request.PatchProfileSettings) => auth.PatchProfileSettings(kind, body),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, aID);\n systemEventEmitter.showSuccess(t(\"updateSettingsSuccess\", { defaultValue: \"Settings updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useUpdateProfileSettings] error\"));\n },\n });\n};\n\nexport const useUpdatePreference = () => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n return useMutation({\n mutationFn: (preference: string) => auth.UpdatePreference(kind, preference),\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useUpdatePreference] error\"));\n },\n });\n};\n\nexport const useListProfiles = <K extends ProfileKindEnum>(kind: K) => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n return useUnifiedQuery(\n () => auth.ListProfiles(kind, { limit: 50, offset: 0 }),\n AUTH_PROFILES(aID, kind),\n undefined,\n { enabled: isAuthValid && Boolean(aID) },\n );\n};\n\nexport const useCreateForgerProfile = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: (body: Login.Request.CreateForgerProfile) => auth.CreateForgerProfile(body),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.invalidateProfiles({ aID, kind: ProfileKindEnum.COMMUNITY });\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useCreateForgerProfile] error\"));\n },\n });\n};\n\nexport const useCreateAuthorityProfile = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: (body: Login.Request.CreateAuthorityProfile) => auth.CreateAuthorityProfile(body),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.invalidateProfiles({ aID, kind: ProfileKindEnum.AUTHORITY });\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useCreateAuthorityProfile] error\"));\n },\n });\n};\n\nexport const useDeleteProfile = () => {\n const auth = useAuthRepository();\n return useMutation({\n mutationFn: ({ kind, profileId }: { kind: ProfileKindEnum; profileId: string }) => auth.DeleteProfile(kind, profileId),\n onSuccess: (_void, variables) => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.invalidateProfiles({ aID, kind: variables.kind });\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useDeleteProfile] error\"));\n },\n });\n};\n\nexport const useConfirmProfileAvatar = () => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n return useMutation({\n mutationFn: (body: Profile.Request.ConfirmProfileAvatar) => auth.ConfirmProfileAvatar(kind, body),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, aID);\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useConfirmProfileAvatar] error\"));\n },\n });\n};\n\nexport const useClearProfileAvatar = () => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: () => auth.ClearProfileAvatar(kind),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, aID);\n systemEventEmitter.showSuccess(t(\"clearAvatarSuccess\", { defaultValue: \"Avatar removed.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useClearProfileAvatar] error\"));\n },\n });\n};\n\nexport const useListEmails = () => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n return useUnifiedQuery(() => auth.ListEmails({ limit: 50, offset: 0 }), AUTH_EMAILS(aID), undefined, {\n enabled: isAuthValid && Boolean(aID),\n });\n};\n\nexport const useListPhones = () => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n return useUnifiedQuery(() => auth.ListPhones({ limit: 50, offset: 0 }), AUTH_PHONES(aID), undefined, {\n enabled: isAuthValid && Boolean(aID),\n });\n};\n\nexport const useCreateEmail = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (body: Login.Request.CreateEmail) => auth.CreateEmail(body),\n onSuccess: () => {\n authEventEmitter.invalidateEmails(accountId);\n systemEventEmitter.showSuccess(t(\"createEmailSuccess\", { defaultValue: \"Email added.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useCreateEmail] error\"));\n },\n });\n};\n\nexport const useSendEmailVerificationCode = () => {\n const auth = useAuthRepository();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ emailId, lang }: { emailId: string; lang?: LanguageEnum }) => auth.SendEmailVerificationCode(emailId, { lang }),\n onSuccess: () => {\n systemEventEmitter.showSuccess(t(\"sendVerificationCodeSuccess\", { defaultValue: \"Code sent\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSendEmailVerificationCode] error\"));\n },\n });\n};\n\nexport const useVerifyEmail = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ emailId, verificationCode }: { emailId: string; verificationCode: string }) =>\n auth.VerifyEmail(emailId, { verificationCode }),\n onSuccess: () => {\n authEventEmitter.invalidateEmails(accountId);\n systemEventEmitter.showSuccess(t(\"verifyEmailSuccess\", { defaultValue: \"Email verified.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useVerifyEmail] error\"));\n },\n });\n};\n\nexport const useUpdateEmail = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ emailId, email }: { emailId: string; email: string }) => auth.UpdateEmail(emailId, { email }),\n onSuccess: () => {\n authEventEmitter.invalidateEmails(accountId);\n systemEventEmitter.showSuccess(t(\"updateEmailSuccess\", { defaultValue: \"Email updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useUpdateEmail] error\"));\n },\n });\n};\n\nexport const useSetPrimaryEmail = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (emailId: string) => auth.SetPrimaryEmail(emailId),\n onSuccess: () => {\n authEventEmitter.invalidateEmails(accountId);\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, accountId);\n systemEventEmitter.showSuccess(t(\"setPrimaryEmailSuccess\", { defaultValue: \"Primary email updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSetPrimaryEmail] error\"));\n },\n });\n};\n\nexport const useDeleteEmail = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (emailId: string) => auth.DeleteEmail(emailId),\n onSuccess: () => {\n authEventEmitter.invalidateEmails(accountId);\n systemEventEmitter.showSuccess(t(\"deleteEmailSuccess\", { defaultValue: \"Email removed.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useDeleteEmail] error\"));\n },\n });\n};\n\nexport const useSendChangePasswordVerificationCode = () => {\n const auth = useAuthRepository();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (body: Login.Request.SendChangePasswordVerificationCode = {}) => auth.SendChangePasswordVerificationCode(body),\n onSuccess: () => {\n systemEventEmitter.showSuccess(t(\"sendVerificationCodeSuccess\", { defaultValue: \"Code sent\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSendChangePasswordVerificationCode] error\"));\n },\n });\n};\n\nexport const useChangePassword = () => {\n const auth = useAuthRepository();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (body: Login.Request.ChangePassword) => auth.ChangePassword(body),\n onSuccess: () => {\n systemEventEmitter.showSuccess(t(\"changePasswordSuccess\", { defaultValue: \"Password updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useChangePassword] error\"));\n },\n });\n};\n\nexport const useConfirmProfileBackgrounds = () => {\n const auth = useAuthRepository();\n const { kind } = useAuthQueryScope();\n return useMutation({\n mutationFn: (body: Profile.Request.ConfirmProfileBackgrounds) => auth.ConfirmProfileBackgrounds(kind, body),\n onSuccess: () => {\n const aID = AuthStore.getState().currentAccountId;\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, aID);\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useConfirmProfileBackgrounds] error\"));\n },\n });\n};\n\nexport const useCreatePhone = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (body: Login.Request.CreatePhone) => auth.CreatePhone(body),\n onSuccess: () => {\n authEventEmitter.invalidatePhones(accountId);\n systemEventEmitter.showSuccess(t(\"createPhoneSuccess\", { defaultValue: \"Phone added.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useCreatePhone] error\"));\n },\n });\n};\n\nexport const useSendPhoneVerificationCode = () => {\n const auth = useAuthRepository();\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (phoneId: string) => auth.SendPhoneVerificationCode(phoneId),\n onSuccess: () => {\n systemEventEmitter.showSuccess(t(\"sendVerificationCodeSuccess\", { defaultValue: \"Code sent\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSendPhoneVerificationCode] error\"));\n },\n });\n};\n\nexport const useVerifyPhone = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ phoneId, verificationCode }: { phoneId: string; verificationCode: string }) =>\n auth.VerifyPhone(phoneId, { verificationCode }),\n onSuccess: () => {\n authEventEmitter.invalidatePhones(accountId);\n systemEventEmitter.showSuccess(t(\"verifyPhoneSuccess\", { defaultValue: \"Phone verified.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useVerifyPhone] error\"));\n },\n });\n};\n\nexport const useUpdatePhone = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ phoneId, phone }: { phoneId: string; phone: string }) => auth.UpdatePhone(phoneId, { phone }),\n onSuccess: () => {\n authEventEmitter.invalidatePhones(accountId);\n systemEventEmitter.showSuccess(t(\"updatePhoneSuccess\", { defaultValue: \"Phone updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useUpdatePhone] error\"));\n },\n });\n};\n\nexport const useSetPrimaryPhone = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (phoneId: string) => auth.SetPrimaryPhone(phoneId),\n onSuccess: () => {\n authEventEmitter.invalidatePhones(accountId);\n authEventEmitter.emit(authEvents.UPDATE_ACCOUNT_SUCCESS, accountId);\n systemEventEmitter.showSuccess(t(\"setPrimaryPhoneSuccess\", { defaultValue: \"Primary phone updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useSetPrimaryPhone] error\"));\n },\n });\n};\n\nexport const useDeletePhone = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: (phoneId: string) => auth.DeletePhone(phoneId),\n onSuccess: () => {\n authEventEmitter.invalidatePhones(accountId);\n systemEventEmitter.showSuccess(t(\"deletePhoneSuccess\", { defaultValue: \"Phone removed.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useDeletePhone] error\"));\n },\n });\n};\n\nexport const useSearchForgerProfiles = (query: string) => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n const trimmed = query.trim();\n return useUnifiedQuery(\n ({ query: q }) => auth.SearchForgerProfiles({ query: q, limit: 50, offset: 0 }),\n AUTH_PROFILE_SEARCH(aID, ProfileKindEnum.COMMUNITY, trimmed),\n { query: trimmed },\n { enabled: isAuthValid && Boolean(aID) && trimmed.length > 0 },\n );\n};\n\nexport const useSearchAuthorityProfiles = (query: string) => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n const trimmed = query.trim();\n return useUnifiedQuery(\n ({ query: q }) => auth.SearchAuthorityProfiles({ query: q, limit: 50, offset: 0 }),\n AUTH_PROFILE_SEARCH(aID, ProfileKindEnum.AUTHORITY, trimmed),\n { query: trimmed },\n { enabled: isAuthValid && Boolean(aID) && trimmed.length > 0 },\n );\n};\n\nexport const useGetPublicProfileCard = (profileId: string) => {\n const auth = useAuthRepository();\n const { isAuthValid } = useAuthQueryScope();\n return useUnifiedQuery(\n () => auth.GetPublicProfileCard(profileId),\n AUTH_PUBLIC_CARD(profileId),\n undefined,\n { enabled: isAuthValid && Boolean(profileId) },\n );\n};\n\nexport const useListOwnerForgerProfiles = (query = \"\") => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n const trimmed = query.trim();\n return useUnifiedQuery(\n ({ query: q }) => auth.ListOwnerForgerProfiles({ limit: 50, offset: 0, query: q || undefined }),\n [...AUTH_OWNER_FORGERS(aID), trimmed],\n { query: trimmed },\n { enabled: isAuthValid && Boolean(aID) },\n );\n};\n\nexport const useListOwnerAuthorityProfiles = (query = \"\") => {\n const auth = useAuthRepository();\n const { aID, isAuthValid } = useAuthQueryScope();\n const trimmed = query.trim();\n return useUnifiedQuery(\n ({ query: q }) => auth.ListOwnerAuthorityProfiles({ limit: 50, offset: 0, query: q || undefined }),\n [...AUTH_OWNER_AUTHORITIES(aID), trimmed],\n { query: trimmed },\n { enabled: isAuthValid && Boolean(aID) },\n );\n};\n\nexport const useUpdateAuthorityProfileRoles = () => {\n const auth = useAuthRepository();\n const accountId = AuthStore.getState().currentAccountId;\n const { t } = useTranslation(\"hooks\", { keyPrefix: \"account\" });\n return useMutation({\n mutationFn: ({ profileId, authorityRoles }: { profileId: string; authorityRoles: Profile.Request.UpdateAuthorityProfileRoles[\"authorityRoles\"] }) =>\n auth.UpdateAuthorityProfileRoles(profileId, { authorityRoles }),\n onSuccess: () => {\n authEventEmitter.invalidateOwner(accountId);\n systemEventEmitter.showSuccess(t(\"updateRolesSuccess\", { defaultValue: \"Roles updated.\" }));\n },\n onError: (error: AxiosError) => {\n systemEventEmitter.showError(getApiErrorMessage(error, \"[useUpdateAuthorityProfileRoles] error\"));\n },\n });\n};\n\nexport { hasSelectedProfile, AuthStore, useAuthStore };\nexport { LanguageEnum,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AK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/DataProvider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAkBvC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAyED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,iBAAiB,+BAUzE"}
|
|
@@ -1,64 +1,86 @@
|
|
|
1
1
|
import { setIdentityRepositories as e } from "../../apis/activeIdentityRepositories.js";
|
|
2
|
-
import { AuthStore as t, hasSelectedProfile as n, subscribeAuthStorageSync as r } from "../../stores/auth.js";
|
|
3
|
-
import { parseServerPreference as
|
|
4
|
-
import { scheduleAccessTokenRefresh as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
2
|
+
import { AuthStore as t, hasSelectedProfile as n, subscribeAuthStorageSync as r, useAuthStore as i } from "../../stores/auth.js";
|
|
3
|
+
import { parseServerPreference as a, toServerPreference as o } from "../../stores/preference.js";
|
|
4
|
+
import { clearScheduledTokenRefresh as s, scheduleAccessTokenRefresh as c } from "../../apis/authRefresh.js";
|
|
5
|
+
import { authEventEmitter as l, authEvents as u } from "../../events/auth.js";
|
|
6
|
+
import { ApiAuthRepository as d } from "../../apis/repositories/AuthRepository.js";
|
|
7
|
+
import { ApiAssetRepository as f } from "../../apis/repositories/AssetRepository.js";
|
|
8
|
+
import { IdentityRepositoriesContext as p, useAuthRepository as m } from "../../apis/repositories/context.js";
|
|
9
|
+
import { useAuthQueryScope as h, useCurrentProfile as g } from "../../hooks/auth.js";
|
|
10
|
+
import { configurePreferenceSync as _, useApplyPreferenceOnLoad as v } from "../../hooks/preference.js";
|
|
11
|
+
import { useEffect as y, useMemo as b } from "react";
|
|
12
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
12
13
|
//#region src/providers/DataProvider/index.tsx
|
|
13
|
-
var
|
|
14
|
-
auth: new
|
|
15
|
-
asset: new
|
|
14
|
+
var C = {
|
|
15
|
+
auth: new d(),
|
|
16
|
+
asset: new f()
|
|
16
17
|
};
|
|
17
|
-
e(
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
18
|
+
e(C);
|
|
19
|
+
function w() {
|
|
20
|
+
let { refetch: e } = g(), a = i((e) => e.isAuthValid), o = i((e) => e.accessToken), d = i((e) => e.currentProfileId);
|
|
21
|
+
return y(() => {
|
|
22
|
+
if (!a || !o) {
|
|
23
|
+
s();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return c(o), () => s();
|
|
27
|
+
}, [a, o]), y(() => r(() => {
|
|
28
|
+
let { accessToken: e, isAuthValid: n } = t.getState();
|
|
29
|
+
if (!n || !e) {
|
|
30
|
+
s();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
c(e);
|
|
34
|
+
}), []), y(() => {
|
|
35
|
+
a && n(d) && e();
|
|
36
|
+
}, [
|
|
37
|
+
a,
|
|
38
|
+
d,
|
|
39
|
+
e
|
|
40
|
+
]), y(() => {
|
|
41
|
+
let t = async () => {
|
|
42
|
+
await e();
|
|
43
|
+
};
|
|
44
|
+
return l.on(u.LOGIN_SUCCESS, t), () => {
|
|
45
|
+
l.off(u.LOGIN_SUCCESS, t);
|
|
46
|
+
};
|
|
47
|
+
}, [e]), null;
|
|
26
48
|
}
|
|
27
|
-
function
|
|
28
|
-
let e =
|
|
29
|
-
|
|
30
|
-
if (!r || !n(
|
|
31
|
-
|
|
49
|
+
function T() {
|
|
50
|
+
let e = m(), { kind: t, isAuthValid: r, pID: i } = h(), { profile: s } = g();
|
|
51
|
+
y(() => {
|
|
52
|
+
if (!r || !n(i)) {
|
|
53
|
+
_(void 0);
|
|
32
54
|
return;
|
|
33
55
|
}
|
|
34
|
-
return
|
|
35
|
-
e.UpdatePreference(t, JSON.stringify(
|
|
36
|
-
}), () =>
|
|
56
|
+
return _((n) => {
|
|
57
|
+
e.UpdatePreference(t, JSON.stringify(o(n)));
|
|
58
|
+
}), () => _(void 0);
|
|
37
59
|
}, [
|
|
38
60
|
e,
|
|
39
61
|
t,
|
|
40
62
|
r,
|
|
41
|
-
|
|
63
|
+
i
|
|
42
64
|
]);
|
|
43
|
-
let c =
|
|
44
|
-
return
|
|
45
|
-
isAuthValid: r && n(
|
|
46
|
-
applyKey:
|
|
65
|
+
let c = b(() => s?.preference ? a(s.preference) : null, [s?.preference]);
|
|
66
|
+
return v({
|
|
67
|
+
isAuthValid: r && n(i),
|
|
68
|
+
applyKey: i,
|
|
47
69
|
serverPreference: c
|
|
48
70
|
}), null;
|
|
49
71
|
}
|
|
50
|
-
function
|
|
51
|
-
let r = n ??
|
|
52
|
-
return e(r), /* @__PURE__ */
|
|
72
|
+
function E({ children: t, repositories: n }) {
|
|
73
|
+
let r = n ?? C;
|
|
74
|
+
return e(r), /* @__PURE__ */ S(p.Provider, {
|
|
53
75
|
value: r,
|
|
54
76
|
children: [
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ x(w, {}),
|
|
78
|
+
/* @__PURE__ */ x(T, {}),
|
|
57
79
|
t
|
|
58
80
|
]
|
|
59
81
|
});
|
|
60
82
|
}
|
|
61
83
|
//#endregion
|
|
62
|
-
export {
|
|
84
|
+
export { E as DataProvider };
|
|
63
85
|
|
|
64
86
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/providers/DataProvider/index.tsx"],"sourcesContent":["import type { IdentityRepositories } from \"nfx-ui/apis\";\nimport type { ReactNode } from \"react\";\n\nimport { useEffect, useMemo } from \"react\";\nimport { ApiAssetRepository, ApiAuthRepository, IdentityRepositoriesContext, setIdentityRepositories, useAuthRepository } from \"nfx-ui/apis\";\nimport { scheduleAccessTokenRefresh } from \"nfx-ui/apis/authRefresh\";\nimport { useAuthQueryScope, useCurrentProfile } from \"nfx-ui/hooks/auth\";\nimport { configurePreferenceSync, useApplyPreferenceOnLoad } from \"nfx-ui/hooks/preference\";\nimport { AuthStore, hasSelectedProfile, subscribeAuthStorageSync } from \"nfx-ui/stores/auth\";\nimport { parseServerPreference, toServerPreference } from \"nfx-ui/stores/preference\";\n\nconst defaultIdentityRepositories: IdentityRepositories = {\n auth: new ApiAuthRepository(),\n asset: new ApiAssetRepository(),\n};\n\nsetIdentityRepositories(defaultIdentityRepositories);\n\nexport interface DataProviderProps {\n children: ReactNode;\n repositories?: IdentityRepositories;\n}\n\nfunction AuthSessionBootstrap() {\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/providers/DataProvider/index.tsx"],"sourcesContent":["import type { IdentityRepositories } from \"nfx-ui/apis\";\nimport type { ReactNode } from \"react\";\n\nimport { useEffect, useMemo } from \"react\";\nimport { ApiAssetRepository, ApiAuthRepository, IdentityRepositoriesContext, setIdentityRepositories, useAuthRepository } from \"nfx-ui/apis\";\nimport { clearScheduledTokenRefresh, scheduleAccessTokenRefresh } from \"nfx-ui/apis/authRefresh\";\nimport { authEventEmitter, authEvents } from \"nfx-ui/events/auth\";\nimport { useAuthQueryScope, useCurrentProfile } from \"nfx-ui/hooks/auth\";\nimport { configurePreferenceSync, useApplyPreferenceOnLoad } from \"nfx-ui/hooks/preference\";\nimport { AuthStore, hasSelectedProfile, subscribeAuthStorageSync, useAuthStore } from \"nfx-ui/stores/auth\";\nimport { parseServerPreference, toServerPreference } from \"nfx-ui/stores/preference\";\n\nconst defaultIdentityRepositories: IdentityRepositories = {\n auth: new ApiAuthRepository(),\n asset: new ApiAssetRepository(),\n};\n\nsetIdentityRepositories(defaultIdentityRepositories);\n\nexport interface DataProviderProps {\n children: ReactNode;\n repositories?: IdentityRepositories;\n}\n\nfunction AuthSessionBootstrap() {\n const { refetch } = useCurrentProfile();\n const isAuthValid = useAuthStore((s) => s.isAuthValid);\n const accessToken = useAuthStore((s) => s.accessToken);\n const profileId = useAuthStore((s) => s.currentProfileId);\n\n useEffect(() => {\n if (!isAuthValid || !accessToken) {\n clearScheduledTokenRefresh();\n return;\n }\n scheduleAccessTokenRefresh(accessToken);\n return () => clearScheduledTokenRefresh();\n }, [isAuthValid, accessToken]);\n\n useEffect(() => {\n return subscribeAuthStorageSync(() => {\n const { accessToken: nextAccessToken, isAuthValid: nextValid } = AuthStore.getState();\n if (!nextValid || !nextAccessToken) {\n clearScheduledTokenRefresh();\n return;\n }\n scheduleAccessTokenRefresh(nextAccessToken);\n });\n }, []);\n\n useEffect(() => {\n if (!isAuthValid || !hasSelectedProfile(profileId)) return;\n void refetch();\n }, [isAuthValid, profileId, refetch]);\n\n useEffect(() => {\n const onLoginSuccess = async () => {\n await refetch();\n };\n authEventEmitter.on(authEvents.LOGIN_SUCCESS, onLoginSuccess);\n return () => {\n authEventEmitter.off(authEvents.LOGIN_SUCCESS, onLoginSuccess);\n };\n }, [refetch]);\n\n return null;\n}\n\nfunction AuthPreferenceSync() {\n const auth = useAuthRepository();\n const { kind, isAuthValid, pID } = useAuthQueryScope();\n const { profile } = useCurrentProfile();\n\n useEffect(() => {\n if (!isAuthValid || !hasSelectedProfile(pID)) {\n configurePreferenceSync(undefined);\n return;\n }\n configurePreferenceSync((state) => {\n void auth.UpdatePreference(kind, JSON.stringify(toServerPreference(state)));\n });\n return () => configurePreferenceSync(undefined);\n }, [auth, kind, isAuthValid, pID]);\n\n const serverPreference = useMemo(() => (profile?.preference ? parseServerPreference(profile.preference) : null), [profile?.preference]);\n\n useApplyPreferenceOnLoad({\n isAuthValid: isAuthValid && hasSelectedProfile(pID),\n applyKey: pID,\n serverPreference,\n });\n\n return null;\n}\n\nexport function DataProvider({ children, repositories }: DataProviderProps) {\n const value = repositories ?? defaultIdentityRepositories;\n setIdentityRepositories(value);\n return (\n <IdentityRepositoriesContext.Provider value={value}>\n <AuthSessionBootstrap />\n <AuthPreferenceSync />\n {children}\n </IdentityRepositoriesContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAM,IAAoD;CACxD,MAAM,IAAI,EAAkB;CAC5B,OAAO,IAAI,EAAmB;AAChC;AAEA,EAAwB,CAA2B;AAOnD,SAAS,IAAuB;CAC9B,IAAM,EAAE,eAAY,EAAkB,GAChC,IAAc,GAAc,MAAM,EAAE,WAAW,GAC/C,IAAc,GAAc,MAAM,EAAE,WAAW,GAC/C,IAAY,GAAc,MAAM,EAAE,gBAAgB;CAqCxD,OAnCA,QAAgB;EACd,IAAI,CAAC,KAAe,CAAC,GAAa;GAChC,EAA2B;GAC3B;EACF;EAEA,OADA,EAA2B,CAAW,SACzB,EAA2B;CAC1C,GAAG,CAAC,GAAa,CAAW,CAAC,GAE7B,QACS,QAA+B;EACpC,IAAM,EAAE,aAAa,GAAiB,aAAa,MAAc,EAAU,SAAS;EACpF,IAAI,CAAC,KAAa,CAAC,GAAiB;GAClC,EAA2B;GAC3B;EACF;EACA,EAA2B,CAAe;CAC5C,CAAC,GACA,CAAC,CAAC,GAEL,QAAgB;EACV,AAAC,KAAgB,EAAmB,CAAS,KACjD,EAAa;CACf,GAAG;EAAC;EAAa;EAAW;CAAO,CAAC,GAEpC,QAAgB;EACd,IAAM,IAAiB,YAAY;GACjC,MAAM,EAAQ;EAChB;EAEA,OADA,EAAiB,GAAG,EAAW,eAAe,CAAc,SAC/C;GACX,EAAiB,IAAI,EAAW,eAAe,CAAc;EAC/D;CACF,GAAG,CAAC,CAAO,CAAC,GAEL;AACT;AAEA,SAAS,IAAqB;CAC5B,IAAM,IAAO,EAAkB,GACzB,EAAE,SAAM,gBAAa,WAAQ,EAAkB,GAC/C,EAAE,eAAY,EAAkB;CAEtC,QAAgB;EACd,IAAI,CAAC,KAAe,CAAC,EAAmB,CAAG,GAAG;GAC5C,EAAwB,KAAA,CAAS;GACjC;EACF;EAIA,OAHA,GAAyB,MAAU;GACjC,EAAU,iBAAiB,GAAM,KAAK,UAAU,EAAmB,CAAK,CAAC,CAAC;EAC5E,CAAC,SACY,EAAwB,KAAA,CAAS;CAChD,GAAG;EAAC;EAAM;EAAM;EAAa;CAAG,CAAC;CAEjC,IAAM,IAAmB,QAAe,GAAS,aAAa,EAAsB,EAAQ,UAAU,IAAI,MAAO,CAAC,GAAS,UAAU,CAAC;CAQtI,OANA,EAAyB;EACvB,aAAa,KAAe,EAAmB,CAAG;EAClD,UAAU;EACV;CACF,CAAC,GAEM;AACT;AAEA,SAAgB,EAAa,EAAE,aAAU,mBAAmC;CAC1E,IAAM,IAAQ,KAAgB;CAE9B,OADA,EAAwB,CAAK,GAE3B,kBAAC,EAA4B,UAA7B;EAA6C;EAA7C,UAAA;GACE,kBAAC,GAAD,CAAuB,CAAA;GACvB,kBAAC,GAAD,CAAqB,CAAA;GACpB;EACmC;;AAE1C"}
|
package/package.json
CHANGED
package/src/enums/auth.ts
CHANGED
|
@@ -58,7 +58,7 @@ export enum AuthSignupPlatformEnum {
|
|
|
58
58
|
NFXIDENTITY = "nfxidentity",
|
|
59
59
|
NFXNEWS = "nfxnews",
|
|
60
60
|
NFXSTORAGES = "nfxstorages",
|
|
61
|
-
|
|
61
|
+
NFXEDGE = "nfxedge",
|
|
62
62
|
}
|
|
63
63
|
export const DEFAULT_AUTH_SIGNUP_PLATFORM = AuthSignupPlatformEnum.NFXIDENTITY;
|
|
64
64
|
export const AUTH_SIGNUP_PLATFORM_VALUES = Object.values(AuthSignupPlatformEnum);
|
package/src/hooks/auth.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { AxiosError } from "axios";
|
|
|
5
5
|
import type { CurrentProfileResult, Login, Profile, Signup } from "nfx-ui/types";
|
|
6
6
|
|
|
7
7
|
import { useEffect } from "react";
|
|
8
|
+
import { flushSync } from "react-dom";
|
|
8
9
|
import { useMutation } from "@tanstack/react-query";
|
|
9
10
|
import { useAuthRepository } from "nfx-ui/apis/repositories";
|
|
10
11
|
import { AUTH_EMAILS, AUTH_ME, AUTH_OWNER_AUTHORITIES, AUTH_OWNER_FORGERS, AUTH_PHONES, AUTH_PROFILE_SEARCH, AUTH_PROFILES, AUTH_PUBLIC_CARD } from "nfx-ui/constants";
|
|
@@ -175,7 +176,13 @@ export const useLoginWithPhone = () => {
|
|
|
175
176
|
});
|
|
176
177
|
};
|
|
177
178
|
|
|
178
|
-
export
|
|
179
|
+
export type SelectProfileOptions = {
|
|
180
|
+
/** 与 token、档案同一次提交里执行(例如跳到该档案的首页)。Runs in the same commit as the token and profile. */
|
|
181
|
+
onCommit?: () => void;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/** 两步登录第二步:切换当前 profile,重新签发 token。kind 决定后端分派到社区/权限档。 */
|
|
185
|
+
export const useSelectProfile = (options?: SelectProfileOptions) => {
|
|
179
186
|
const auth = useAuthRepository();
|
|
180
187
|
return useMutation({
|
|
181
188
|
mutationFn: async ({ profileId, kind }: { profileId: string; kind: Login.ProfileKind }) =>
|
|
@@ -185,15 +192,18 @@ export const useSelectProfile = () => {
|
|
|
185
192
|
deviceId: await ensureDeviceIdStorage(),
|
|
186
193
|
}),
|
|
187
194
|
onSuccess: (result, variables) => {
|
|
188
|
-
if (result?.accessToken)
|
|
195
|
+
if (!result?.accessToken) return;
|
|
196
|
+
// 同一次提交写入新 token 和档案,旧角色的请求在重拉前先停用。
|
|
197
|
+
flushSync(() => {
|
|
189
198
|
setTokens({
|
|
190
199
|
accessToken: result.accessToken,
|
|
191
200
|
refreshToken: safeStringable(result.refreshToken),
|
|
192
201
|
});
|
|
193
202
|
setCurrentProfileKind(variables.kind);
|
|
194
203
|
if (result.profileId) setCurrentProfileId(result.profileId);
|
|
195
|
-
|
|
196
|
-
}
|
|
204
|
+
options?.onCommit?.();
|
|
205
|
+
});
|
|
206
|
+
authEventEmitter.emit(authEvents.LOGIN_SUCCESS, result.accountId);
|
|
197
207
|
},
|
|
198
208
|
onError: (error: AxiosError) => {
|
|
199
209
|
systemEventEmitter.showError(getApiErrorMessage(error, "[useSelectProfile] error"));
|
|
@@ -3,10 +3,11 @@ import type { ReactNode } from "react";
|
|
|
3
3
|
|
|
4
4
|
import { useEffect, useMemo } from "react";
|
|
5
5
|
import { ApiAssetRepository, ApiAuthRepository, IdentityRepositoriesContext, setIdentityRepositories, useAuthRepository } from "nfx-ui/apis";
|
|
6
|
-
import { scheduleAccessTokenRefresh } from "nfx-ui/apis/authRefresh";
|
|
6
|
+
import { clearScheduledTokenRefresh, scheduleAccessTokenRefresh } from "nfx-ui/apis/authRefresh";
|
|
7
|
+
import { authEventEmitter, authEvents } from "nfx-ui/events/auth";
|
|
7
8
|
import { useAuthQueryScope, useCurrentProfile } from "nfx-ui/hooks/auth";
|
|
8
9
|
import { configurePreferenceSync, useApplyPreferenceOnLoad } from "nfx-ui/hooks/preference";
|
|
9
|
-
import { AuthStore, hasSelectedProfile, subscribeAuthStorageSync } from "nfx-ui/stores/auth";
|
|
10
|
+
import { AuthStore, hasSelectedProfile, subscribeAuthStorageSync, useAuthStore } from "nfx-ui/stores/auth";
|
|
10
11
|
import { parseServerPreference, toServerPreference } from "nfx-ui/stores/preference";
|
|
11
12
|
|
|
12
13
|
const defaultIdentityRepositories: IdentityRepositories = {
|
|
@@ -22,14 +23,46 @@ export interface DataProviderProps {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
function AuthSessionBootstrap() {
|
|
26
|
+
const { refetch } = useCurrentProfile();
|
|
27
|
+
const isAuthValid = useAuthStore((s) => s.isAuthValid);
|
|
28
|
+
const accessToken = useAuthStore((s) => s.accessToken);
|
|
29
|
+
const profileId = useAuthStore((s) => s.currentProfileId);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!isAuthValid || !accessToken) {
|
|
33
|
+
clearScheduledTokenRefresh();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
scheduleAccessTokenRefresh(accessToken);
|
|
37
|
+
return () => clearScheduledTokenRefresh();
|
|
38
|
+
}, [isAuthValid, accessToken]);
|
|
39
|
+
|
|
25
40
|
useEffect(() => {
|
|
26
|
-
const accessToken = AuthStore.getState().accessToken;
|
|
27
|
-
if (accessToken) scheduleAccessTokenRefresh(accessToken);
|
|
28
41
|
return subscribeAuthStorageSync(() => {
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
42
|
+
const { accessToken: nextAccessToken, isAuthValid: nextValid } = AuthStore.getState();
|
|
43
|
+
if (!nextValid || !nextAccessToken) {
|
|
44
|
+
clearScheduledTokenRefresh();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
scheduleAccessTokenRefresh(nextAccessToken);
|
|
31
48
|
});
|
|
32
49
|
}, []);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!isAuthValid || !hasSelectedProfile(profileId)) return;
|
|
53
|
+
void refetch();
|
|
54
|
+
}, [isAuthValid, profileId, refetch]);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const onLoginSuccess = async () => {
|
|
58
|
+
await refetch();
|
|
59
|
+
};
|
|
60
|
+
authEventEmitter.on(authEvents.LOGIN_SUCCESS, onLoginSuccess);
|
|
61
|
+
return () => {
|
|
62
|
+
authEventEmitter.off(authEvents.LOGIN_SUCCESS, onLoginSuccess);
|
|
63
|
+
};
|
|
64
|
+
}, [refetch]);
|
|
65
|
+
|
|
33
66
|
return null;
|
|
34
67
|
}
|
|
35
68
|
|