@laiye_packages/uci 1.0.9 → 1.1.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.
|
@@ -10,6 +10,8 @@ export interface LYUserQueryParams extends LYRangeQueryParams {
|
|
|
10
10
|
/** 用户唯一名称,英文和数字组合 */
|
|
11
11
|
name?: string;
|
|
12
12
|
display_name?: string;
|
|
13
|
+
/** 用户来源 */
|
|
14
|
+
utm_source?: string;
|
|
13
15
|
/** 角色ID */
|
|
14
16
|
role_id?: string;
|
|
15
17
|
/** 邮箱,仅精确匹配 */
|
|
@@ -171,6 +173,8 @@ interface LYRegisterRequest {
|
|
|
171
173
|
password: string;
|
|
172
174
|
/** 显示名称 */
|
|
173
175
|
display_name: string;
|
|
176
|
+
/** 用户来源 */
|
|
177
|
+
utm_source?: string;
|
|
174
178
|
}
|
|
175
179
|
/**
|
|
176
180
|
* 密码重置请求
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { LYBaseAuthorizer, type LYSigninArgs, LYSignoutArgs } from './base';
|
|
2
|
+
interface LYQueryParams {
|
|
3
|
+
code: string;
|
|
4
|
+
code_verifier: string;
|
|
5
|
+
redirect_uri: string;
|
|
6
|
+
state: string;
|
|
7
|
+
utm_source?: string;
|
|
8
|
+
}
|
|
2
9
|
export interface LYRedirectSessionPostRequest {
|
|
3
10
|
authentication_name: string;
|
|
4
|
-
query_params:
|
|
5
|
-
code: string;
|
|
6
|
-
code_verifier: string;
|
|
7
|
-
redirect_uri: string;
|
|
8
|
-
state: string;
|
|
9
|
-
};
|
|
11
|
+
query_params: LYQueryParams;
|
|
10
12
|
}
|
|
11
13
|
export declare class LYRedirectAuthorizer extends LYBaseAuthorizer {
|
|
12
14
|
_signin(args: LYSigninArgs): Promise<void>;
|
|
@@ -16,3 +18,4 @@ export declare class LYRedirectAuthorizer extends LYBaseAuthorizer {
|
|
|
16
18
|
signout(args?: LYSignoutArgs): Promise<void>;
|
|
17
19
|
_signout(): Promise<void>;
|
|
18
20
|
}
|
|
21
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -9745,12 +9745,6 @@ class LYSession extends LYObject {
|
|
|
9745
9745
|
static{
|
|
9746
9746
|
this._CHECK_INTERVAL = 10000;
|
|
9747
9747
|
}
|
|
9748
|
-
static setAllCodesProvider(provider) {
|
|
9749
|
-
LYSession._allCodesProvider = provider;
|
|
9750
|
-
}
|
|
9751
|
-
static setOnSessionCreated(callback) {
|
|
9752
|
-
LYSession._onSessionCreated = callback;
|
|
9753
|
-
}
|
|
9754
9748
|
static get() {
|
|
9755
9749
|
if (!LYSession._session) {
|
|
9756
9750
|
const session = sharedLocalStorage.getSync(SESSION_KEY);
|
|
@@ -9782,9 +9776,6 @@ class LYSession extends LYObject {
|
|
|
9782
9776
|
country_code: country_code || ''
|
|
9783
9777
|
});
|
|
9784
9778
|
LYSession._startRefreshTimer();
|
|
9785
|
-
if (LYSession._onSessionCreated) LYSession._onSessionCreated().catch((err)=>{
|
|
9786
|
-
console.error('Session created callback error:', err);
|
|
9787
|
-
});
|
|
9788
9779
|
return LYSession._session;
|
|
9789
9780
|
}
|
|
9790
9781
|
static clear() {
|
|
@@ -9808,8 +9799,7 @@ class LYSession extends LYObject {
|
|
|
9808
9799
|
this._phone = phone || '';
|
|
9809
9800
|
this._country_code = country_code || '';
|
|
9810
9801
|
this._permissions = Object.entries(permissions || {}).reduce((acc, [app_name, codes])=>{
|
|
9811
|
-
|
|
9812
|
-
acc[app_name] = new LYAppPermission(app_name, codes, allCodes);
|
|
9802
|
+
acc[app_name] = new LYAppPermission(app_name, codes, []);
|
|
9813
9803
|
return acc;
|
|
9814
9804
|
}, {});
|
|
9815
9805
|
}
|
|
@@ -9903,8 +9893,7 @@ class LYSession extends LYObject {
|
|
|
9903
9893
|
if (void 0 !== phone) LYSession._session._phone = phone;
|
|
9904
9894
|
if (void 0 !== country_code) LYSession._session._country_code = country_code;
|
|
9905
9895
|
LYSession._session._permissions = Object.entries(permissions || {}).reduce((acc, [app_name, codes])=>{
|
|
9906
|
-
|
|
9907
|
-
acc[app_name] = new LYAppPermission(app_name, codes, allCodes);
|
|
9896
|
+
acc[app_name] = new LYAppPermission(app_name, codes, []);
|
|
9908
9897
|
return acc;
|
|
9909
9898
|
}, {});
|
|
9910
9899
|
sharedLocalStorage.setSync(SESSION_KEY, {
|
|
@@ -11644,20 +11633,23 @@ class LYRedirectAuthorizer extends LYBaseAuthorizer {
|
|
|
11644
11633
|
const queryParams = this._getQueryParams();
|
|
11645
11634
|
const code = queryParams.code;
|
|
11646
11635
|
const state = queryParams.state;
|
|
11636
|
+
const utm_source = queryParams.utm_source;
|
|
11647
11637
|
const locale = queryParams.ui_locales;
|
|
11648
11638
|
if (code && state) {
|
|
11649
11639
|
if (state !== redirectInfo.state) throw new Error('Invalid state parameter');
|
|
11650
11640
|
const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
|
|
11651
11641
|
if (locale) await app.i18n.changeLanguage(locale);
|
|
11652
11642
|
try {
|
|
11643
|
+
const params = {
|
|
11644
|
+
code: code,
|
|
11645
|
+
state: state,
|
|
11646
|
+
code_verifier: redirectInfo.code_verifier,
|
|
11647
|
+
redirect_uri: redirectInfo.redirect_uri
|
|
11648
|
+
};
|
|
11649
|
+
if (utm_source) params.utm_source = utm_source;
|
|
11653
11650
|
const response = await app.httpClient.post('sso/redirect/session', {
|
|
11654
11651
|
authentication_name: redirectInfo.authentication_name,
|
|
11655
|
-
query_params:
|
|
11656
|
-
code: code,
|
|
11657
|
-
code_verifier: redirectInfo.code_verifier,
|
|
11658
|
-
redirect_uri: redirectInfo.redirect_uri,
|
|
11659
|
-
state: redirectInfo.state
|
|
11660
|
-
}
|
|
11652
|
+
query_params: params
|
|
11661
11653
|
});
|
|
11662
11654
|
if (!response || !response.data.access_token) throw new Error('Invalid SSO response: missing access token');
|
|
11663
11655
|
LYSession.create('redirect', redirectInfo.authentication_name, response.data.id, response.data.access_token, response.data.user_id, response.data.user_name, response.data.expires_in, response.data.permission_codes, response.data.is_first_login, response.data.display_name, response.data.email, response.data.phone, response.data.country_code);
|
|
@@ -12032,10 +12024,6 @@ class LYOrganizationApp extends LYBaseOrganizationApp {
|
|
|
12032
12024
|
}
|
|
12033
12025
|
async doLoad() {
|
|
12034
12026
|
await super.doLoad();
|
|
12035
|
-
LYSession.setAllCodesProvider((appName)=>this.getAllPermissionCodes(appName));
|
|
12036
|
-
LYSession.setOnSessionCreated(async ()=>{
|
|
12037
|
-
await this.loadPermissionMeta();
|
|
12038
|
-
});
|
|
12039
12027
|
}
|
|
12040
12028
|
async loadPermissionMeta() {
|
|
12041
12029
|
try {
|