@laiye_packages/uci 1.0.7 → 1.0.9

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.
@@ -3,7 +3,33 @@ export type LYAction = 'none' | 'create' | 'read' | 'update' | 'delete' | 'execu
3
3
  export declare class LYAppPermission extends LYObject {
4
4
  private _app_name;
5
5
  private _codes;
6
- constructor(app_name: string, codes: Record<string, LYAction[]>);
6
+ /**
7
+ * 当前 app 声明的所有权限编码
8
+ * 用于判断某个权限编码是否在当前环境中被配置
9
+ * 如果不在 allCodes 中,表示该权限编码没有权限控制,应该直接返回 true
10
+ */
11
+ private _allCodes;
12
+ constructor(app_name: string, codes: Record<string, LYAction[]>, allCodes: string[]);
7
13
  get app_name(): string;
14
+ /**
15
+ * 获取用户拥有的权限编码列表
16
+ */
17
+ get codes(): string[];
18
+ /**
19
+ * 获取 app 声明的所有权限编码
20
+ */
21
+ get allCodes(): string[];
22
+ /**
23
+ * 设置 app 声明的所有权限编码
24
+ */
25
+ setAllCodes(codes: string[]): void;
8
26
  getActions(code: string): LYAction[];
27
+ /**
28
+ * 检查用户是否有指定的权限编码
29
+ * @param code - 权限编码
30
+ * @returns 是否有权限
31
+ * - 如果 code 不在 app 声明的 allCodes 中,返回 true(没有权限控制)
32
+ * - 如果 code 在 allCodes 中,检查用户是否拥有该权限
33
+ */
34
+ hasPermission(code: string): boolean;
9
35
  }
@@ -1,6 +1,14 @@
1
1
  import { LYObject } from '../object';
2
2
  import { type LYAction, LYAppPermission } from '../permission';
3
- type LYSessionType = 'web' | 'direct' | 'gateway' | 'redirect';
3
+ type LYSessionType = 'web' | 'direct' | 'gateway' | 'redirect' | 'app';
4
+ /**
5
+ * 获取指定 app 的所有权限编码的回调类型
6
+ */
7
+ export type LYAllCodesProvider = (appName: string) => string[];
8
+ /**
9
+ * Session 创建后的回调类型
10
+ */
11
+ export type LYSessionCreatedCallback = () => Promise<void>;
4
12
  export declare class LYSession extends LYObject {
5
13
  private static _session?;
6
14
  private _type;
@@ -20,6 +28,24 @@ export declare class LYSession extends LYObject {
20
28
  private _email;
21
29
  private _phone;
22
30
  private _country_code;
31
+ /**
32
+ * 获取指定 app 的所有权限编码的回调
33
+ */
34
+ private static _allCodesProvider?;
35
+ /**
36
+ * Session 创建后的回调
37
+ */
38
+ private static _onSessionCreated?;
39
+ /**
40
+ * 设置获取所有权限编码的回调
41
+ * @param provider 回调函数
42
+ */
43
+ static setAllCodesProvider(provider: LYAllCodesProvider): void;
44
+ /**
45
+ * 设置 Session 创建后的回调
46
+ * @param callback 回调函数
47
+ */
48
+ static setOnSessionCreated(callback: LYSessionCreatedCallback): void;
23
49
  static get(): LYSession | undefined;
24
50
  static create(type: LYSessionType, authentication_name: string, id: string, token: string, user_id: string, user_name: string, expires_in: number, permissions: Record<string, Record<string, LYAction[]>>, is_first_login?: boolean, display_name?: string, email?: string, phone?: string, country_code?: string): LYSession;
25
51
  static clear(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laiye_packages/uci",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "description": "A comprehensive utility library for frontend applications with HTTP client, storage, i18n, crypto, logger, and OpenTelemetry support",
6
6
  "exports": {
@@ -63,12 +63,12 @@
63
63
  "downloadjs": "^1.4.7",
64
64
  "events": "^3.3.0",
65
65
  "gm-crypto": "^0.1.12",
66
- "i18next": "^25.0.1",
66
+ "i18next": "25.8.0",
67
67
  "idb": "^8.0.2",
68
68
  "js-sha256": "^0.11.1",
69
69
  "lodash": "^4.17.21",
70
70
  "qs": "^6.14.0",
71
- "sm-crypto": "^0.3.13"
71
+ "sm-crypto": "0.3.13"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@rslib/core": "^0.13.3",