@laiye_packages/uci 1.0.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.
Files changed (56) hide show
  1. package/dist/app/base/index.d.ts +80 -0
  2. package/dist/app/index.d.ts +14 -0
  3. package/dist/app/organization/api/department.d.ts +44 -0
  4. package/dist/app/organization/api/license.d.ts +60 -0
  5. package/dist/app/organization/api/notification.d.ts +98 -0
  6. package/dist/app/organization/api/oem.d.ts +39 -0
  7. package/dist/app/organization/api/open_api.d.ts +78 -0
  8. package/dist/app/organization/api/permission.d.ts +71 -0
  9. package/dist/app/organization/api/session.d.ts +51 -0
  10. package/dist/app/organization/api/sso.d.ts +0 -0
  11. package/dist/app/organization/api/user.d.ts +95 -0
  12. package/dist/app/organization/api/verificationCodes.d.ts +27 -0
  13. package/dist/app/organization/app/index.d.ts +30 -0
  14. package/dist/app/organization/authorizer/base.d.ts +35 -0
  15. package/dist/app/organization/authorizer/direct.d.ts +11 -0
  16. package/dist/app/organization/authorizer/gateway.d.ts +5 -0
  17. package/dist/app/organization/authorizer/redirect.d.ts +18 -0
  18. package/dist/app/organization/authorizer/web.d.ts +25 -0
  19. package/dist/app/organization/index.d.ts +1 -0
  20. package/dist/app/tenant/api/configuration.d.ts +8 -0
  21. package/dist/app/tenant/api/session.d.ts +23 -0
  22. package/dist/app/tenant/api/tenant.d.ts +25 -0
  23. package/dist/app/tenant/api/user.d.ts +27 -0
  24. package/dist/app/tenant/app/index.d.ts +20 -0
  25. package/dist/app/tenant/authorizer/index.d.ts +13 -0
  26. package/dist/app/tenant/index.d.ts +1 -0
  27. package/dist/app/tenant/session/index.d.ts +57 -0
  28. package/dist/config/address.d.ts +5 -0
  29. package/dist/config/app.d.ts +5 -0
  30. package/dist/config/base.d.ts +15 -0
  31. package/dist/config/crypto.d.ts +5 -0
  32. package/dist/config/http.d.ts +14 -0
  33. package/dist/config/index.d.ts +12 -0
  34. package/dist/constants/index.d.ts +1 -0
  35. package/dist/crypto/base.d.ts +14 -0
  36. package/dist/crypto/gm.d.ts +3 -0
  37. package/dist/crypto/index.d.ts +144 -0
  38. package/dist/crypto/sm.d.ts +17 -0
  39. package/dist/env/index.d.ts +76 -0
  40. package/dist/error/index.d.ts +16 -0
  41. package/dist/http/base.d.ts +52 -0
  42. package/dist/http/error.d.ts +34 -0
  43. package/dist/http/index.d.ts +170 -0
  44. package/dist/http/trace.d.ts +1 -0
  45. package/dist/i18n/index.d.ts +50 -0
  46. package/dist/index.d.ts +14 -0
  47. package/dist/index.js +12194 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/logger/index.d.ts +75 -0
  50. package/dist/object/index.d.ts +57 -0
  51. package/dist/observable/index.d.ts +14 -0
  52. package/dist/observable/serializeable.d.ts +86 -0
  53. package/dist/permission/index.d.ts +9 -0
  54. package/dist/session/index.d.ts +74 -0
  55. package/dist/storage/index.d.ts +98 -0
  56. package/package.json +87 -0
@@ -0,0 +1,30 @@
1
+ import { LYBaseTenantApp } from '../../base';
2
+ import { LYSessionApi } from '../api/session';
3
+ import type { SSOConfig } from '../api/session';
4
+ import { LYUserApi } from '../api/user';
5
+ import type { LYBaseAuthorizer } from '../authorizer/base';
6
+ import { LYLicenseApi } from '../api/license';
7
+ import { LYCrypto } from '../../../crypto';
8
+ import { LYOEMApi } from '../api/oem';
9
+ import { LYVerificationCodesApi } from '../api/verificationCodes';
10
+ declare class LYOrganizationApp extends LYBaseTenantApp {
11
+ static _instance?: LYOrganizationApp;
12
+ private _sessionApi;
13
+ private _userApi;
14
+ private _licenseApi;
15
+ private _authorizers;
16
+ private _oemApi;
17
+ private _verificationCodesApi;
18
+ constructor(name: string, version: string, description: string);
19
+ static get instance(): LYOrganizationApp;
20
+ get sessionApi(): LYSessionApi;
21
+ get userApi(): LYUserApi;
22
+ get oemApi(): LYOEMApi;
23
+ get licenseApi(): LYLicenseApi;
24
+ get crypto(): LYCrypto;
25
+ get verificationCodesApi(): LYVerificationCodesApi;
26
+ protected doLoad(): Promise<void>;
27
+ private mergeOEM;
28
+ getAuthorizer<T extends LYBaseAuthorizer = LYBaseAuthorizer>(name?: string): T;
29
+ }
30
+ export { LYOrganizationApp, SSOConfig };
@@ -0,0 +1,35 @@
1
+ import { LYObject, type LYEvents } from '../../../object';
2
+ import { LYBaseApp } from '../../base';
3
+ import { SSOConfig } from '../api/session';
4
+ export declare const ORGANIZATION_APP_NAME = "organization";
5
+ export type LYAuthorizerStatus = 'signed-in' | 'signed-out';
6
+ type LYAuthorizerEvents = {
7
+ 'status-change': (status: LYAuthorizerStatus) => void;
8
+ };
9
+ export interface LYSigninArgs {
10
+ redirect_uri: string;
11
+ sso_config?: SSOConfig;
12
+ }
13
+ export interface LYSignoutArgs {
14
+ redirect_uri?: string;
15
+ }
16
+ export interface ILYAuthorizer<TSigninArgs extends LYSigninArgs = LYSigninArgs, TSignoutArgs extends LYSignoutArgs = LYSignoutArgs> {
17
+ on: LYEvents<LYAuthorizerEvents>['on'];
18
+ off: LYEvents<LYAuthorizerEvents>['on'];
19
+ once: LYEvents<LYAuthorizerEvents>['on'];
20
+ emit: LYEvents<LYAuthorizerEvents>['emit'];
21
+ signin: (args: TSigninArgs) => Promise<void>;
22
+ signout: (args: TSignoutArgs) => Promise<void>;
23
+ }
24
+ export declare abstract class LYBaseAuthorizer<TSigninArgs extends LYSigninArgs = LYSigninArgs, TSignoutArgs extends LYSignoutArgs = LYSignoutArgs> extends LYObject implements ILYAuthorizer<TSigninArgs, TSignoutArgs> {
25
+ private _app;
26
+ private _name;
27
+ constructor(app: LYBaseApp, name: string);
28
+ get app(): LYBaseApp;
29
+ get name(): string;
30
+ signin(args: TSigninArgs): Promise<void>;
31
+ signout(args: TSignoutArgs): Promise<void>;
32
+ protected abstract _signin(args: TSigninArgs): Promise<void>;
33
+ protected abstract _signout(args: TSignoutArgs): Promise<void>;
34
+ }
35
+ export {};
@@ -0,0 +1,11 @@
1
+ import { LYBaseAuthorizer, type LYSigninArgs, type LYSignoutArgs } from './base';
2
+ interface LYDirectSigninArgs extends LYSigninArgs {
3
+ authentication_name: string;
4
+ user_name: string;
5
+ password: string;
6
+ }
7
+ export declare class LYDirectAuthorizer extends LYBaseAuthorizer {
8
+ _signin(args: LYDirectSigninArgs): Promise<void>;
9
+ _signout(args: LYSignoutArgs): Promise<void>;
10
+ }
11
+ export {};
@@ -0,0 +1,5 @@
1
+ import { LYBaseAuthorizer, type LYSigninArgs, type LYSignoutArgs } from './base';
2
+ export declare class LYGatewayAuthorizer extends LYBaseAuthorizer {
3
+ _signin(args: LYSigninArgs): Promise<void>;
4
+ _signout(args: LYSignoutArgs): Promise<void>;
5
+ }
@@ -0,0 +1,18 @@
1
+ import { LYBaseAuthorizer, type LYSigninArgs, LYSignoutArgs } from './base';
2
+ export interface LYRedirectSessionPostRequest {
3
+ authentication_name: string;
4
+ query_params: {
5
+ code: string;
6
+ code_verifier: string;
7
+ redirect_uri: string;
8
+ state: string;
9
+ };
10
+ }
11
+ export declare class LYRedirectAuthorizer extends LYBaseAuthorizer {
12
+ _signin(args: LYSigninArgs): Promise<void>;
13
+ signin(args: LYSigninArgs): Promise<void>;
14
+ private _jumpToSSO;
15
+ private _getQueryParams;
16
+ signout(args?: LYSignoutArgs): Promise<void>;
17
+ _signout(): Promise<void>;
18
+ }
@@ -0,0 +1,25 @@
1
+ import type { LYBaseApp } from '../../base';
2
+ import { LYBaseAuthorizer, type LYSigninArgs, type LYSignoutArgs } from './base';
3
+ import type { LYSessionApi } from '../api/session';
4
+ export interface LYWebSigninArgs extends LYSigninArgs {
5
+ name?: string;
6
+ password?: string;
7
+ email?: string;
8
+ phone?: string;
9
+ country_code?: string;
10
+ account_type?: "email" | "phone";
11
+ verification_code?: string;
12
+ verification_code_id?: string;
13
+ }
14
+ export interface LYWebSignoutArgs extends LYSignoutArgs {
15
+ }
16
+ export declare class LYWebAuthorizer extends LYBaseAuthorizer<LYWebSigninArgs, LYWebSignoutArgs> {
17
+ private _sessionApi;
18
+ constructor(app: LYBaseApp, name: string, sessionApi: LYSessionApi);
19
+ _signin(args: LYWebSigninArgs): Promise<void>;
20
+ _signout(args: LYWebSignoutArgs): Promise<void>;
21
+ /**
22
+ * 刷新session
23
+ */
24
+ private _refreshSession;
25
+ }
@@ -0,0 +1 @@
1
+ export * from './app';
@@ -0,0 +1,8 @@
1
+ import type { LYAppHttpClient } from '../../../http';
2
+ export declare class LYConfigurationApi {
3
+ private _httpClient;
4
+ constructor(httpClient: LYAppHttpClient);
5
+ get_meta(): Promise<Record<string, any>>;
6
+ get(): Promise<Record<string, any>>;
7
+ set(value: Record<string, any>): Promise<number>;
8
+ }
@@ -0,0 +1,23 @@
1
+ import type { LYAppHttpClient, LYBaseResponse } from '../../../http';
2
+ interface LYSessionResponse extends LYBaseResponse {
3
+ id: string;
4
+ access_token: string;
5
+ token_type: string;
6
+ user_id: string;
7
+ user_name: string;
8
+ expires_in: number;
9
+ claims: Record<string, any>;
10
+ }
11
+ interface LYSessionPostRequest {
12
+ name: string;
13
+ password: string;
14
+ }
15
+ export declare class LYSessionApi {
16
+ private _httpClient;
17
+ constructor(httpClient: LYAppHttpClient);
18
+ get(id: string): Promise<LYSessionResponse>;
19
+ create(session: LYSessionPostRequest): Promise<LYSessionResponse>;
20
+ update(id: string): Promise<LYSessionResponse>;
21
+ delete(id: string): Promise<number>;
22
+ }
23
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { LYAppHttpClient, LYBaseResponse } from '../../../http';
2
+ interface LYTenantResponse extends LYBaseResponse {
3
+ id: string;
4
+ name: string;
5
+ description: string;
6
+ }
7
+ interface LYTenantPostRequest {
8
+ name: string;
9
+ description?: string;
10
+ admin_name: string;
11
+ admin_password: string;
12
+ }
13
+ interface LYTenantPatchRequest {
14
+ description?: string;
15
+ }
16
+ export declare class LYTenantApi {
17
+ private _httpClient;
18
+ constructor(httpClient: LYAppHttpClient);
19
+ query(): Promise<LYTenantResponse[]>;
20
+ get(name: string): Promise<LYTenantResponse>;
21
+ create(tenant: LYTenantPostRequest): Promise<string>;
22
+ update(name: string, tenant: LYTenantPatchRequest): Promise<number>;
23
+ delete(name: string): Promise<number>;
24
+ }
25
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { LYAppHttpClient, LYBaseResponse, LYListResponse } from '../../../http';
2
+ interface LYUserResponse extends LYBaseResponse {
3
+ id: string;
4
+ name: string;
5
+ description: string;
6
+ }
7
+ interface LYUserListResponse extends LYListResponse<LYUserResponse> {
8
+ }
9
+ interface LYUserPostRequest {
10
+ name: string;
11
+ password: string;
12
+ description?: string;
13
+ }
14
+ interface LYUserPatchRequest {
15
+ password?: string;
16
+ description?: string;
17
+ }
18
+ export declare class LYUserApi {
19
+ private _httpClient;
20
+ constructor(httpClient: LYAppHttpClient);
21
+ query(): Promise<LYUserListResponse>;
22
+ get(name: string): Promise<LYUserResponse>;
23
+ create(user: LYUserPostRequest): Promise<string>;
24
+ update(name: string, user: LYUserPatchRequest): Promise<number>;
25
+ delete(name: string): Promise<number>;
26
+ }
27
+ export {};
@@ -0,0 +1,20 @@
1
+ import { LYBaseApp } from '../../base';
2
+ import { LYTenantApi } from '../api/tenant';
3
+ import { LYUserApi } from '../api/user';
4
+ import { LYConfigurationApi } from '../api/configuration';
5
+ import { LYTenantAuthorizer } from '../authorizer';
6
+ declare class LYTenantApp extends LYBaseApp {
7
+ static _instance?: LYTenantApp;
8
+ private _tenantApi;
9
+ private _userApi;
10
+ private _configuration;
11
+ private _authorizer;
12
+ constructor(name: string, version: string, description: string);
13
+ static get instance(): LYTenantApp;
14
+ get tenantApi(): LYTenantApi;
15
+ get userApi(): LYUserApi;
16
+ get configuration(): LYConfigurationApi;
17
+ get authorizer(): LYTenantAuthorizer;
18
+ protected doLoad(): Promise<void>;
19
+ }
20
+ export { LYTenantApp };
@@ -0,0 +1,13 @@
1
+ import { LYObject } from '../../../object';
2
+ import type { LYAppHttpClient } from '../../../http';
3
+ export declare class LYTenantAuthorizer extends LYObject {
4
+ private _sessionApi;
5
+ constructor(httpClient: LYAppHttpClient);
6
+ signin(userName: string, password: string): Promise<void>;
7
+ signout(): Promise<void>;
8
+ update(): Promise<void>;
9
+ /**
10
+ * 刷新session
11
+ */
12
+ private _refreshSession;
13
+ }
@@ -0,0 +1 @@
1
+ export * from './app';
@@ -0,0 +1,57 @@
1
+ import { LYObject } from '../../../object';
2
+ export declare class LYTenantSession extends LYObject {
3
+ private static _session?;
4
+ private _id;
5
+ private _token;
6
+ private _user_id;
7
+ private _user_name;
8
+ private _expires_in;
9
+ private _claims;
10
+ private _created_at;
11
+ private static _refreshCallback?;
12
+ private static _refreshTimer?;
13
+ private static readonly _CHECK_INTERVAL;
14
+ static get(): LYTenantSession | undefined;
15
+ static create(id: string, token: string, user_id: string, user_name: string, expires_in: number, claims: Record<string, any>): LYTenantSession;
16
+ static clear(): void;
17
+ constructor(id: string, token: string, user_id: string, user_name: string, expires_in: number, claims: Record<string, any>, created_at: number);
18
+ get id(): string;
19
+ get token(): string;
20
+ get user_id(): string;
21
+ get user_name(): string;
22
+ get expires_in(): number;
23
+ get claims(): Record<string, any>;
24
+ get created_at(): number;
25
+ /**
26
+ * 检查session是否已过期
27
+ */
28
+ isExpired(): boolean;
29
+ /**
30
+ * 检查session是否即将过期(在过期前15秒)
31
+ */
32
+ isNearExpiration(): boolean;
33
+ /**
34
+ * 设置刷新回调函数
35
+ */
36
+ static setRefreshCallback(callback: (session: LYTenantSession) => Promise<void>): void;
37
+ /**
38
+ * 获取有效的session,如果过期则尝试刷新
39
+ */
40
+ static getValid(): Promise<LYTenantSession | undefined>;
41
+ /**
42
+ * 更新session信息
43
+ */
44
+ static update(id: string, token: string, user_id: string, user_name: string, expires_in: number, claims: Record<string, any>): void;
45
+ /**
46
+ * 启动定时器监控session过期
47
+ */
48
+ private static _startRefreshTimer;
49
+ /**
50
+ * 停止定时器
51
+ */
52
+ private static _stopRefreshTimer;
53
+ /**
54
+ * 检查并刷新session
55
+ */
56
+ private static _checkAndRefreshSession;
57
+ }
@@ -0,0 +1,5 @@
1
+ import { LYBaseConfigModel } from './base';
2
+ export declare class LYAddressConfig extends LYBaseConfigModel {
3
+ tenantLoginUrl: string;
4
+ organizationLoginUrl: string;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { LYBaseConfigModel } from './base';
2
+ export declare class LYAppConfig extends LYBaseConfigModel {
3
+ name: string;
4
+ version: string;
5
+ }
@@ -0,0 +1,15 @@
1
+ import { LYObject } from '../object';
2
+ export declare function model<T extends typeof LYBaseConfigModel>(modelType: T): (target: any, key: string) => void;
3
+ export declare function array<T extends typeof LYBaseConfigModel>(modelType: T): (target: any, key: string) => void;
4
+ export declare function object<T extends typeof LYBaseConfigModel>(modelType: T): (target: any, key: string) => void;
5
+ export declare class LYBaseConfigModel {
6
+ clone(): this;
7
+ load(config: Record<string, any>): void;
8
+ }
9
+ export declare class LYBaseConfig extends LYObject {
10
+ static load<T extends typeof LYBaseConfig>(this: T, config_url: string): Promise<InstanceType<T>>;
11
+ static get<T extends typeof LYBaseConfig>(this: T): InstanceType<T>;
12
+ private _load_from_url;
13
+ private _load_from_element;
14
+ load(config_url: string): Promise<void>;
15
+ }
@@ -0,0 +1,5 @@
1
+ import { LYBaseConfigModel } from './base';
2
+ export type LYCryptoType = 'default' | 'sm' | 'gm';
3
+ export declare class LYCryptoConfig extends LYBaseConfigModel {
4
+ type: LYCryptoType;
5
+ }
@@ -0,0 +1,14 @@
1
+ import { LYBaseConfigModel } from './base';
2
+ export declare class LYRetryWaitExponential extends LYBaseConfigModel {
3
+ multiplier: number;
4
+ min: number;
5
+ max: number;
6
+ }
7
+ export declare class LYHttpRetryConfig extends LYBaseConfigModel {
8
+ timeoutPerRetry: number;
9
+ stopAfterDelay: number;
10
+ waitExponential: LYRetryWaitExponential;
11
+ }
12
+ export declare class LYHttpConfig extends LYBaseConfigModel {
13
+ retry: LYHttpRetryConfig;
14
+ }
@@ -0,0 +1,12 @@
1
+ import { LYBaseConfig } from './base';
2
+ import { LYHttpConfig } from './http';
3
+ import { LYCryptoConfig } from './crypto';
4
+ import { LYAppConfig } from './app';
5
+ import { LYAddressConfig } from './address';
6
+ export declare class LYConfig extends LYBaseConfig {
7
+ http: LYHttpConfig;
8
+ crypto: LYCryptoConfig;
9
+ apps: LYAppConfig[];
10
+ address: LYAddressConfig;
11
+ host_patterns: string[];
12
+ }
@@ -0,0 +1 @@
1
+ export declare const FRAMEWORK_NAME = "uci";
@@ -0,0 +1,14 @@
1
+ import { LYCryptoType } from "../config/crypto";
2
+ export declare abstract class LYBaseCrypto {
3
+ abstract getSymmetricBlockSize(iv: Uint8Array, key: Uint8Array): number;
4
+ abstract getAsymmetricBlockSize(publicKey: Uint8Array): number;
5
+ abstract encryptSymmetric(data: Uint8Array, iv: Uint8Array, key: Uint8Array): Uint8Array;
6
+ abstract decryptSymmetric(data: Uint8Array, iv: Uint8Array, key: Uint8Array): Uint8Array;
7
+ abstract signature(data: Uint8Array, privateKey: Uint8Array): string;
8
+ abstract verify(data: Uint8Array, publicKey: Uint8Array, signature: string): boolean;
9
+ abstract encryptAsymmetric(data: Uint8Array, publicKey: Uint8Array): Uint8Array;
10
+ abstract decryptAsymmetric(data: Uint8Array, privateKey: Uint8Array): Uint8Array;
11
+ abstract hash(data: Uint8Array, key?: Uint8Array): Uint8Array;
12
+ }
13
+ export declare function registerCryptoImpl(name: LYCryptoType): <T extends new () => LYBaseCrypto>(impl: T) => T;
14
+ export declare const cryptoImpl: Record<LYCryptoType, new () => LYBaseCrypto | undefined>;
@@ -0,0 +1,3 @@
1
+ import { LYSMCrypto } from "./sm";
2
+ export declare class LYGMCrypto extends LYSMCrypto {
3
+ }
@@ -0,0 +1,144 @@
1
+ import { LYObject } from "../object";
2
+ import { LYBaseCrypto } from "./base";
3
+ import "./sm";
4
+ import "./gm";
5
+ export declare class LYCrypto extends LYObject {
6
+ private _impl?;
7
+ private _encryptPublicKey?;
8
+ private _decryptPrivateKey?;
9
+ private _signaturePrivateKey?;
10
+ private _verifyPublicKey?;
11
+ private _ivGetter;
12
+ private _keyGetter;
13
+ constructor();
14
+ get impl(): LYBaseCrypto;
15
+ private _createImpl;
16
+ private _getCryptoConfig;
17
+ private _uint8ArrayToHex;
18
+ private _hexToUint8Array;
19
+ private _stringToUint8Array;
20
+ private _uint8ArrayToString;
21
+ private _base64ToUint8Array;
22
+ private _uint8ArrayToBase64;
23
+ private _getIvAndKey;
24
+ private _getKey;
25
+ private _getEncryptPublicKey;
26
+ private _getDecryptPrivateKey;
27
+ private _getSignaturePrivateKey;
28
+ private _getVerifyPublicKey;
29
+ /**
30
+ * 将数据流分成指定大小的块
31
+ */
32
+ private _makeSize;
33
+ /**
34
+ * 设置对称加密的IV和密钥获取函数
35
+ */
36
+ setSymmetricKeyGetter(ivGetter: () => Uint8Array, keyGetter: () => Uint8Array): void;
37
+ /**
38
+ * 设置非对称加密公钥
39
+ */
40
+ setEncryptPublicKey(publicKey: Uint8Array | string): void;
41
+ /**
42
+ * 设置非对称解密私钥
43
+ */
44
+ setDecryptPrivateKey(privateKey: Uint8Array | string): void;
45
+ /**
46
+ * 设置签名私钥
47
+ */
48
+ setSignaturePrivateKey(privateKey: Uint8Array | string): void;
49
+ /**
50
+ * 设置验证公钥
51
+ */
52
+ setVerifyPublicKey(publicKey: Uint8Array | string): void;
53
+ /**
54
+ * 对称加密 - 字节数组
55
+ */
56
+ encryptSymmetric(data: Uint8Array, iv?: Uint8Array | string, key?: Uint8Array | string): Uint8Array;
57
+ /**
58
+ * 对称加密 - 字符串
59
+ */
60
+ encryptSymmetric(data: string, iv?: Uint8Array | string, key?: Uint8Array | string): string;
61
+ /**
62
+ * 对称加密 - 流式数据
63
+ */
64
+ encryptSymmetric(data: AsyncIterable<Uint8Array>, iv?: Uint8Array | string, key?: Uint8Array | string): AsyncIterable<Uint8Array>;
65
+ private _encryptSymmetricBytes;
66
+ private _encryptSymmetricStr;
67
+ private _encryptSymmetricStream;
68
+ /**
69
+ * 对称解密 - 字节数组
70
+ */
71
+ decryptSymmetric(data: Uint8Array, iv?: Uint8Array | string, key?: Uint8Array | string): Uint8Array;
72
+ /**
73
+ * 对称解密 - 字符串
74
+ */
75
+ decryptSymmetric(data: string, iv?: Uint8Array | string, key?: Uint8Array | string): string;
76
+ /**
77
+ * 对称解密 - 流式数据
78
+ */
79
+ decryptSymmetric(data: AsyncIterable<Uint8Array>, iv?: Uint8Array | string, key?: Uint8Array | string): AsyncIterable<Uint8Array>;
80
+ private _decryptSymmetricBytes;
81
+ private _decryptSymmetricStr;
82
+ private _decryptSymmetricStream;
83
+ /**
84
+ * 非对称加密 - 字节数组
85
+ */
86
+ encryptAsymmetric(data: Uint8Array, publicKey?: Uint8Array | string): Uint8Array;
87
+ /**
88
+ * 非对称加密 - 字符串
89
+ */
90
+ encryptAsymmetric(data: string, publicKey?: Uint8Array | string): string;
91
+ /**
92
+ * 非对称加密 - 流式数据
93
+ */
94
+ encryptAsymmetric(data: AsyncIterable<Uint8Array>, publicKey?: Uint8Array | string): AsyncIterable<Uint8Array>;
95
+ private _encryptAsymmetricBytes;
96
+ private _encryptAsymmetricStr;
97
+ private _encryptAsymmetricStream;
98
+ /**
99
+ * 非对称解密 - 字节数组
100
+ */
101
+ decryptAsymmetric(data: Uint8Array, privateKey?: Uint8Array | string): Uint8Array;
102
+ /**
103
+ * 非对称解密 - 字符串
104
+ */
105
+ decryptAsymmetric(data: string, privateKey?: Uint8Array | string): string;
106
+ /**
107
+ * 非对称解密 - 流式数据
108
+ */
109
+ decryptAsymmetric(data: AsyncIterable<Uint8Array>, privateKey?: Uint8Array | string): AsyncIterable<Uint8Array>;
110
+ private _decryptAsymmetricBytes;
111
+ private _decryptAsymmetricStr;
112
+ private _decryptAsymmetricStream;
113
+ /**
114
+ * 签名 - 字节数组
115
+ */
116
+ signature(data: Uint8Array, privateKey?: Uint8Array | string): string;
117
+ /**
118
+ * 签名 - 字符串
119
+ */
120
+ signature(data: string, privateKey?: Uint8Array | string): string;
121
+ private _signatureBytes;
122
+ private _signatureStr;
123
+ /**
124
+ * 验证签名 - 字节数组
125
+ */
126
+ verify(data: Uint8Array, signature: string, publicKey?: Uint8Array | string): boolean;
127
+ /**
128
+ * 验证签名 - 字符串
129
+ */
130
+ verify(data: string, signature: string, publicKey?: Uint8Array | string): boolean;
131
+ private _verifyBytes;
132
+ private _verifyStr;
133
+ /**
134
+ * 哈希 - 字节数组
135
+ */
136
+ hash(data: Uint8Array, key?: Uint8Array | string, iterations?: number): Uint8Array;
137
+ /**
138
+ * 哈希 - 字符串
139
+ */
140
+ hash(data: string, key?: Uint8Array | string, iterations?: number): string;
141
+ private _hashBytes;
142
+ private _hashStr;
143
+ }
144
+ export declare const crypto: LYCrypto;
@@ -0,0 +1,17 @@
1
+ import { LYBaseCrypto } from "./base";
2
+ export declare class LYSMCrypto extends LYBaseCrypto {
3
+ private _paddingIv;
4
+ private _uint8ArrayToHex;
5
+ private _hexToUint8Array;
6
+ private _validateKey;
7
+ private _validatePublicKey;
8
+ getSymmetricBlockSize(iv: Uint8Array, key: Uint8Array): number;
9
+ getAsymmetricBlockSize(publicKey: Uint8Array): number;
10
+ encryptSymmetric(data: Uint8Array, iv: Uint8Array, key: Uint8Array): Uint8Array;
11
+ decryptSymmetric(data: Uint8Array, iv: Uint8Array, key: Uint8Array): Uint8Array;
12
+ signature(data: Uint8Array, privateKey: Uint8Array): string;
13
+ verify(data: Uint8Array, publicKey: Uint8Array, signature: string): boolean;
14
+ encryptAsymmetric(data: Uint8Array, publicKey: Uint8Array): Uint8Array;
15
+ decryptAsymmetric(data: Uint8Array, privateKey: Uint8Array): Uint8Array;
16
+ hash(data: Uint8Array, key?: Uint8Array): Uint8Array;
17
+ }
@@ -0,0 +1,76 @@
1
+ import type { ILYEvents, LYEvents } from '../object';
2
+ import { LYObject } from '../object';
3
+ type LYEnvEvents = {
4
+ change(key: string): void;
5
+ };
6
+ export declare const REMOTE_ENTRY = "remoteComponentEntry.js";
7
+ export declare const REMOTE_MODULE = "Index";
8
+ export interface ILYEnv extends ILYEvents<LYEnvEvents> {
9
+ get(key: string, def?: unknown): unknown;
10
+ set(key: string, value: unknown): void;
11
+ has(key: string): boolean;
12
+ on: LYEvents<LYEnvEvents>['on'];
13
+ off: LYEvents<LYEnvEvents>['on'];
14
+ once: LYEvents<LYEnvEvents>['on'];
15
+ addListener: LYEvents<LYEnvEvents>['on'];
16
+ removeListener: LYEvents<LYEnvEvents>['on'];
17
+ emit: LYEvents<LYEnvEvents>['emit'];
18
+ readonly version: string;
19
+ readonly buildVersion: string;
20
+ readonly isOem: boolean;
21
+ readonly brand: string;
22
+ readonly product: string;
23
+ readonly embedProduct: string;
24
+ readonly baseUrl: string;
25
+ readonly isRemote: boolean;
26
+ readonly isIframe: boolean;
27
+ readonly isElectron: boolean;
28
+ readonly supportLanguages: string[];
29
+ [key: string]: any;
30
+ }
31
+ export declare class LYEnv extends LYObject implements ILYEnv {
32
+ on: LYEvents<LYEnvEvents>['on'];
33
+ off: LYEvents<LYEnvEvents>['on'];
34
+ once: LYEvents<LYEnvEvents>['on'];
35
+ addListener: LYEvents<LYEnvEvents>['on'];
36
+ removeListener: LYEvents<LYEnvEvents>['on'];
37
+ emit: LYEvents<LYEnvEvents>['emit'];
38
+ [key: string]: any;
39
+ private _isOem;
40
+ private _brand;
41
+ private _baseUrl;
42
+ private _version;
43
+ private _buildVersion;
44
+ private _product;
45
+ private _embedProduct;
46
+ private _isRemote;
47
+ private _supportLanguages;
48
+ constructor(product: string);
49
+ static getInstance<T extends LYObject>(product: string): T;
50
+ set(key: string, value: unknown): void;
51
+ get(key: string, def?: unknown): unknown;
52
+ has(key: string): boolean;
53
+ get version(): string;
54
+ set version(value: string);
55
+ get buildVersion(): string;
56
+ set buildVersion(value: string);
57
+ get isOem(): boolean;
58
+ set isOem(value: boolean);
59
+ get brand(): string;
60
+ set brand(value: string);
61
+ get product(): string;
62
+ set product(value: string);
63
+ get embedProduct(): string;
64
+ set embedProduct(value: string);
65
+ get baseUrl(): string;
66
+ set baseUrl(value: string);
67
+ get isRemote(): boolean;
68
+ set isRemote(value: boolean);
69
+ get isIframe(): boolean;
70
+ get isElectron(): boolean;
71
+ get supportLanguages(): string[];
72
+ set supportLanguages(value: string[]);
73
+ }
74
+ export declare const isIframe: boolean;
75
+ export declare const isElectron: boolean;
76
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * LY系列错误基类
3
+ */
4
+ export declare class LYError extends Error {
5
+ private _details?;
6
+ protected _code: string;
7
+ constructor(message: string, code?: string, details?: any);
8
+ get code(): string;
9
+ get details(): any;
10
+ }
11
+ /**
12
+ * 加密相关错误类
13
+ */
14
+ export declare class LYCryptoError extends LYError {
15
+ constructor(message: string, code?: string, details?: any);
16
+ }