@laiye_packages/uci 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,9 +2,9 @@ import { openDB } from "idb";
2
2
  import events, { EventEmitter } from "events";
3
3
  import axios from "axios";
4
4
  import { cloneDeep } from "lodash";
5
+ import { sm2, sm3, sm4 } from "sm-crypto";
5
6
  import i18next from "i18next";
6
7
  import js_sha256 from "js-sha256";
7
- import { sm2, sm3, sm4 } from "sm-crypto";
8
8
  import qs from "qs";
9
9
  import downloadjs from "downloadjs";
10
10
  var __webpack_modules__ = {
@@ -9959,1271 +9959,1221 @@ LYSession = session_ts_decorate([
9959
9959
  String
9960
9960
  ])
9961
9961
  ], LYSession);
9962
- function i18n_ts_decorate(decorators, target, key, desc) {
9962
+ class LYBaseCrypto {
9963
+ }
9964
+ function registerCryptoImpl(name1) {
9965
+ return function(impl) {
9966
+ if (cryptoImpl[name1]) throw new Error(`Crypto implementation for ${name1} already registered`);
9967
+ cryptoImpl[name1] = impl;
9968
+ return impl;
9969
+ };
9970
+ }
9971
+ const cryptoImpl = {
9972
+ default: void 0,
9973
+ sm: void 0,
9974
+ gm: void 0
9975
+ };
9976
+ function sm_ts_decorate(decorators, target, key, desc) {
9963
9977
  var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9964
9978
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
9965
9979
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9966
9980
  return c > 3 && r && Object.defineProperty(target, key, r), r;
9967
9981
  }
9968
- function i18n_ts_metadata(k, v) {
9969
- if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
9970
- }
9971
- var i18n_LYLangEnum = /*#__PURE__*/ function(LYLangEnum) {
9972
- LYLangEnum["zh-CN"] = "简体中文";
9973
- LYLangEnum["en-US"] = "English";
9974
- return LYLangEnum;
9975
- }({});
9976
- const i18n_langKeys = Object.keys(i18n_LYLangEnum);
9977
- const languages = {};
9978
- const LANG_KEY = 'lang';
9979
- class LYi18n extends LYObject {
9980
- constructor(namespace){
9981
- super();
9982
- this._namespace = namespace || 'LY.';
9982
+ class LYSMCrypto extends LYBaseCrypto {
9983
+ _paddingIv(iv) {
9984
+ if (iv.length < 16) {
9985
+ const padded = new Uint8Array(16);
9986
+ padded.set(iv);
9987
+ return padded;
9988
+ }
9989
+ return iv.slice(0, 16);
9983
9990
  }
9984
- get t() {
9985
- return (rest, options)=>{
9986
- if (!rest) return "<Null>";
9987
- if (rest.includes(':')) return rest.startsWith(`${this.namespace}:`) ? i18next.t(rest, options) : i18next.t(`${this.namespace}.${rest}`, options);
9988
- return i18next.t(`${this.namespace}:${rest}`, options);
9989
- };
9991
+ _uint8ArrayToHex(array) {
9992
+ return Array.from(array).map((b)=>b.toString(16).padStart(2, '0')).join('');
9990
9993
  }
9991
- get lang() {
9992
- return this._lang || this.resolveLanguage();
9994
+ _hexToUint8Array(hex) {
9995
+ if (hex.length % 2 !== 0) throw new LYCryptoError('Invalid hex string length');
9996
+ const result = new Uint8Array(hex.length / 2);
9997
+ for(let i = 0; i < hex.length; i += 2)result[i / 2] = parseInt(hex.substring(i, i + 2), 16);
9998
+ return result;
9993
9999
  }
9994
- get languages() {
9995
- return languages;
10000
+ _validateKey(key, expectedLength, keyType) {
10001
+ if (key.length !== expectedLength) throw new LYCryptoError(`Invalid ${keyType} key length: expected ${expectedLength}, got ${key.length}`);
9996
10002
  }
9997
- get namespace() {
9998
- return this._namespace;
10003
+ _validatePublicKey(key) {
10004
+ if (64 !== key.length && 65 !== key.length) throw new LYCryptoError(`Invalid SM2 public key length: expected 64 or 65, got ${key.length}`);
9999
10005
  }
10000
- async initialize() {
10001
- if (!this._lang) this._lang = this.resolveLanguage();
10002
- i18next.on('languageChanged', (lang)=>{
10003
- if (this._lang !== lang) {
10004
- this._lang = lang;
10005
- this.emit('lang-changed', lang);
10006
- }
10007
- });
10008
- if (i18next.isInitialized) return;
10009
- const defaultVariables = {};
10010
- const env = LYEnv.getInstance(this._namespace);
10011
- for(const key in env)defaultVariables['$' + key] = env[key];
10012
- await i18next.init({
10013
- fallbackLng: 'zh-CN',
10014
- lng: this._lang,
10015
- defaultNS: this.namespace,
10016
- returnObjects: true,
10017
- interpolation: {
10018
- escapeValue: false,
10019
- defaultVariables
10020
- }
10021
- });
10022
- await this.changeLanguage(this._lang);
10006
+ getSymmetricBlockSize(iv, key) {
10007
+ return 16;
10023
10008
  }
10024
- fallbackLng(lang) {
10025
- if (lang.includes('en')) return 'en-US';
10026
- return 'zh-CN';
10009
+ getAsymmetricBlockSize(publicKey) {
10010
+ return 16;
10027
10011
  }
10028
- resolveLanguage() {
10029
- const langKeys = Object.keys(this.languages);
10030
- if (1 === langKeys.length) return this.fallbackLng(langKeys[0]);
10031
- const searchParams = new URLSearchParams(location.search);
10032
- let lang = searchParams.get(LANG_KEY);
10033
- if (lang) {
10034
- lang = this.fallbackLng(lang);
10035
- return lang;
10012
+ encryptSymmetric(data, iv, key) {
10013
+ try {
10014
+ this._validateKey(key, 16, 'SM4');
10015
+ const paddedIv = this._paddingIv(iv);
10016
+ const keyHex = this._uint8ArrayToHex(key);
10017
+ const ivHex = this._uint8ArrayToHex(paddedIv);
10018
+ const dataHex = this._uint8ArrayToHex(data);
10019
+ const encrypted = sm4.encrypt(dataHex, keyHex, {
10020
+ iv: ivHex,
10021
+ mode: 'cbc',
10022
+ padding: 'pkcs#7'
10023
+ });
10024
+ if (!encrypted) throw new LYCryptoError('SM4 encryption failed');
10025
+ return this._hexToUint8Array(encrypted);
10026
+ } catch (error) {
10027
+ if (error instanceof LYCryptoError) throw error;
10028
+ throw new LYCryptoError(`SM4 encryption error: ${error instanceof Error ? error.message : String(error)}`);
10036
10029
  }
10037
- if (!sharedLocalStorage.getSync(LANG_KEY)) {
10038
- lang = this.fallbackLng(navigator.language);
10039
- return lang;
10030
+ }
10031
+ decryptSymmetric(data, iv, key) {
10032
+ try {
10033
+ this._validateKey(key, 16, 'SM4');
10034
+ const paddedIv = this._paddingIv(iv);
10035
+ const keyHex = this._uint8ArrayToHex(key);
10036
+ const ivHex = this._uint8ArrayToHex(paddedIv);
10037
+ const dataHex = this._uint8ArrayToHex(data);
10038
+ const decrypted = sm4.decrypt(dataHex, keyHex, {
10039
+ iv: ivHex,
10040
+ mode: 'cbc',
10041
+ padding: 'pkcs#7'
10042
+ });
10043
+ if (!decrypted) throw new LYCryptoError('SM4 decryption failed');
10044
+ return this._hexToUint8Array(decrypted);
10045
+ } catch (error) {
10046
+ if (error instanceof LYCryptoError) throw error;
10047
+ throw new LYCryptoError(`SM4 decryption error: ${error instanceof Error ? error.message : String(error)}`);
10040
10048
  }
10041
- lang = sharedLocalStorage.getSync(LANG_KEY) || 'zh-CN';
10042
- return lang;
10043
10049
  }
10044
- async loadResource(urlOrJson, lang, namespace) {
10045
- if ('string' == typeof urlOrJson) {
10046
- const res = await this.getUrlResource(urlOrJson);
10047
- if (!res) return;
10048
- urlOrJson = res;
10050
+ signature(data, privateKey) {
10051
+ try {
10052
+ this._validateKey(privateKey, 32, 'SM2 private');
10053
+ const dataHex = this._uint8ArrayToHex(data);
10054
+ const privateKeyHex = this._uint8ArrayToHex(privateKey);
10055
+ const signature = sm2.doSignature(dataHex, privateKeyHex);
10056
+ if (!signature) throw new LYCryptoError('SM2 signature failed');
10057
+ return signature;
10058
+ } catch (error) {
10059
+ if (error instanceof LYCryptoError) throw error;
10060
+ throw new LYCryptoError(`SM2 signature error: ${error instanceof Error ? error.message : String(error)}`);
10049
10061
  }
10050
- if (!urlOrJson) return;
10051
- lang = lang || this._lang;
10052
- namespace = namespace ? `${this.namespace}.${namespace}` : this.namespace;
10053
- i18next.addResourceBundle(lang, namespace, urlOrJson);
10054
10062
  }
10055
- async getUrlResource(resourceUrl) {
10063
+ verify(data, publicKey, signature) {
10056
10064
  try {
10057
- const res = await axios.get(resourceUrl);
10058
- return res.data;
10065
+ this._validatePublicKey(publicKey);
10066
+ const dataHex = this._uint8ArrayToHex(data);
10067
+ const publicKeyHex = this._uint8ArrayToHex(publicKey);
10068
+ return sm2.doVerifySignature(dataHex, signature, publicKeyHex);
10059
10069
  } catch (error) {
10060
- this.logger.error("loadUrlResource error");
10061
- this.logger.error(error);
10070
+ if (error instanceof LYCryptoError) throw error;
10071
+ throw new LYCryptoError(`SM2 verify error: ${error instanceof Error ? error.message : String(error)}`);
10062
10072
  }
10063
10073
  }
10064
- async changeLanguage(lang) {
10065
- this.logger.info(`changeLanguage lang to ${lang}`);
10066
- this._lang = lang;
10067
- i18next.isInitialized && await i18next.changeLanguage(lang);
10068
- sharedLocalStorage.setSync(LANG_KEY, lang);
10069
- const url = new URL(window.location.href);
10070
- url.searchParams.delete(LANG_KEY);
10071
- window.history.replaceState(null, '', url);
10072
- i18next.isInitialized && this.emit('lang-changed', lang);
10074
+ encryptAsymmetric(data, publicKey) {
10075
+ try {
10076
+ this._validatePublicKey(publicKey);
10077
+ const dataHex = this._uint8ArrayToHex(data);
10078
+ const publicKeyHex = this._uint8ArrayToHex(publicKey);
10079
+ const encrypted = sm2.doEncrypt(dataHex, publicKeyHex);
10080
+ if (!encrypted) throw new LYCryptoError('SM2 encryption failed');
10081
+ return this._hexToUint8Array(encrypted);
10082
+ } catch (error) {
10083
+ if (error instanceof LYCryptoError) throw error;
10084
+ throw new LYCryptoError(`SM2 encryption error: ${error instanceof Error ? error.message : String(error)}`);
10085
+ }
10073
10086
  }
10074
- getResource(key, lang) {
10075
- lang = lang || this._lang;
10076
- let index = key.indexOf(':');
10077
- key = index <= 0 ? `${this.namespace}:${key}` : key.startsWith(`${this.namespace}:`) ? key : `${this.namespace}.${key}`;
10078
- index = key.indexOf(':');
10079
- const ns = key.substring(0, index);
10080
- const keys = key.substring(index + 1);
10081
- if (!ns || !keys) return {};
10082
- const res = i18next.getResourceBundle(lang, ns);
10083
- if (!res) return {};
10084
- const resource = keys.split('.').reduce((result, key)=>result[key], res);
10085
- if (!resource && keys === this.namespace) return res;
10086
- return resource;
10087
+ decryptAsymmetric(data, privateKey) {
10088
+ try {
10089
+ this._validateKey(privateKey, 32, 'SM2 private');
10090
+ const dataHex = this._uint8ArrayToHex(data);
10091
+ const privateKeyHex = this._uint8ArrayToHex(privateKey);
10092
+ const decrypted = sm2.doDecrypt(dataHex, privateKeyHex);
10093
+ if (!decrypted) throw new LYCryptoError('SM2 decryption failed');
10094
+ return this._hexToUint8Array(decrypted);
10095
+ } catch (error) {
10096
+ if (error instanceof LYCryptoError) throw error;
10097
+ throw new LYCryptoError(`SM2 decryption error: ${error instanceof Error ? error.message : String(error)}`);
10098
+ }
10099
+ }
10100
+ hash(data, key) {
10101
+ try {
10102
+ if (key) {
10103
+ const hmacResult = sm3(data, {
10104
+ key,
10105
+ mode: 'hmac'
10106
+ });
10107
+ if (!hmacResult) throw new LYCryptoError('SM3 HMAC failed');
10108
+ return this._hexToUint8Array(hmacResult);
10109
+ }
10110
+ {
10111
+ const hashResult = sm3(data);
10112
+ if (!hashResult) throw new LYCryptoError('SM3 hash failed');
10113
+ return this._hexToUint8Array(hashResult);
10114
+ }
10115
+ } catch (error) {
10116
+ if (error instanceof LYCryptoError) throw error;
10117
+ throw new LYCryptoError(`SM3 hash error: ${error instanceof Error ? error.message : String(error)}`);
10118
+ }
10087
10119
  }
10088
10120
  }
10089
- LYi18n = i18n_ts_decorate([
10090
- register('LYi18n'),
10091
- i18n_ts_metadata("design:type", Function),
10092
- i18n_ts_metadata("design:paramtypes", [
10093
- String
10094
- ])
10095
- ], LYi18n);
10096
- function app_base_ts_decorate(decorators, target, key, desc) {
10121
+ LYSMCrypto = sm_ts_decorate([
10122
+ registerCryptoImpl("sm")
10123
+ ], LYSMCrypto);
10124
+ function gm_ts_decorate(decorators, target, key, desc) {
10097
10125
  var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10098
10126
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10099
10127
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10100
10128
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10101
10129
  }
10102
- function base_ts_metadata(k, v) {
10103
- if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
10130
+ class LYGMCrypto extends LYSMCrypto {
10104
10131
  }
10105
- const CONFIG_URL = "/uci/system_info";
10106
- const TENANT_APP_NAME = 'tenant';
10107
- const ORGANIZATION_APP_NAME = 'organization';
10108
- (0, runtime.init)({
10109
- name: 'uci',
10110
- remotes: []
10111
- });
10112
- class LYDefaultAppProvider extends LYObject {
10113
- provideI18nResourcePath(app, lang) {
10114
- const { i18n } = app;
10115
- return `${app.env.baseUrl}/i18n/assets/${lang || i18n.lang}/`;
10116
- }
10117
- async provideI18nResource(app) {
10118
- const { i18n } = app;
10119
- const result = {};
10120
- for (const key of i18n_langKeys){
10121
- const lang = key;
10122
- const resource = await i18n.getUrlResource(`${app.env.baseUrl}/i18n/locale/${lang}.json`);
10123
- result[lang] = resource;
10124
- }
10125
- return result;
10126
- }
10132
+ LYGMCrypto = gm_ts_decorate([
10133
+ registerCryptoImpl("gm")
10134
+ ], LYGMCrypto);
10135
+ function crypto_ts_decorate(decorators, target, key, desc) {
10136
+ var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10137
+ if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10138
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10139
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10127
10140
  }
10128
- LYDefaultAppProvider = app_base_ts_decorate([
10129
- register('LYDefaultAppProvider')
10130
- ], LYDefaultAppProvider);
10131
- class base_LYBaseApp extends LYObject {
10132
- static{
10133
- this._apps = {};
10134
- }
10135
- static{
10136
- this._initLock = false;
10137
- }
10138
- static get apps() {
10139
- return base_LYBaseApp._apps;
10141
+ function crypto_ts_metadata(k, v) {
10142
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
10143
+ }
10144
+ const LENGTH_SIZE = 2;
10145
+ class LYCrypto extends LYObject {
10146
+ constructor(){
10147
+ super();
10148
+ this._ivGetter = ()=>new Uint8Array(16);
10149
+ this._keyGetter = ()=>new Uint8Array(16);
10140
10150
  }
10141
- static getAppClassName(appName) {
10142
- const camelCase = appName.replace(/_([a-z])/g, (_, letter)=>letter.toUpperCase());
10143
- return `LY${camelCase.charAt(0).toUpperCase() + camelCase.slice(1)}App`;
10151
+ get impl() {
10152
+ if (!this._impl) this._createImpl();
10153
+ if (!this._impl) throw new LYCryptoError('Crypto implementation not available');
10154
+ return this._impl;
10144
10155
  }
10145
- static async init(config_url = CONFIG_URL) {
10146
- if (this._initLock) throw new LYError('Application initialization in progress');
10147
- this._initLock = true;
10156
+ _createImpl() {
10148
10157
  try {
10149
- if (0 === Object.keys(base_LYBaseApp._apps).length) {
10150
- const config = await LYConfig.load(config_url);
10151
- for (const app of config.apps)if (app.name === TENANT_APP_NAME) {
10152
- const Constructor = LYObject.getClass('LYTenantApp');
10153
- base_LYBaseApp._apps[app.name] = new Constructor(app.name, app.version, '');
10154
- } else if (app.name === ORGANIZATION_APP_NAME) {
10155
- const Constructor = LYObject.getClass('LYOrganizationApp');
10156
- base_LYBaseApp._apps[app.name] = new Constructor(app.name, app.version, '');
10157
- } else {
10158
- const specificAppClassName = this.getAppClassName(app.name);
10159
- let Constructor;
10160
- try {
10161
- Constructor = LYObject.getClass(specificAppClassName);
10162
- } catch {
10163
- Constructor = LYObject.getClass('LYApp');
10164
- }
10165
- base_LYBaseApp._apps[app.name] = new Constructor(app.name, app.version, '');
10166
- }
10167
- }
10168
- } finally{
10169
- this._initLock = false;
10158
+ const config = this._getCryptoConfig();
10159
+ const implClass = cryptoImpl[config.type];
10160
+ if (!implClass) throw new LYCryptoError(`Crypto implementation ${config.type} not found`);
10161
+ this._impl = new implClass();
10162
+ } catch (error) {
10163
+ throw new LYCryptoError(`Failed to create crypto implementation: ${error instanceof Error ? error.message : String(error)}`);
10170
10164
  }
10171
10165
  }
10172
- static getAll() {
10173
- return this._apps;
10166
+ _getCryptoConfig() {
10167
+ const config = new LYCryptoConfig();
10168
+ config.type = 'sm';
10169
+ return config;
10174
10170
  }
10175
- static get(name1) {
10176
- return this._apps[name1];
10171
+ _uint8ArrayToHex(array) {
10172
+ return Array.from(array).map((b)=>b.toString(16).padStart(2, '0')).join('');
10177
10173
  }
10178
- static setHeaderProvider(headerProvider) {
10179
- base_LYBaseApp._headerProvider = headerProvider;
10174
+ _hexToUint8Array(hex) {
10175
+ if (hex.length % 2 !== 0) throw new LYCryptoError('Invalid hex string length');
10176
+ const result = new Uint8Array(hex.length / 2);
10177
+ for(let i = 0; i < hex.length; i += 2)result[i / 2] = parseInt(hex.substring(i, i + 2), 16);
10178
+ return result;
10180
10179
  }
10181
- static getHeaderProvider() {
10182
- return base_LYBaseApp._headerProvider;
10180
+ _stringToUint8Array(str) {
10181
+ return new TextEncoder().encode(str);
10183
10182
  }
10184
- constructor(name1, version, description){
10185
- super(), this._isLoaded = false;
10186
- this._name = name1;
10187
- this._version = version;
10188
- this._description = description;
10189
- this._i18n = new LYi18n(name1);
10190
- const prefix = `${this._name}.`;
10191
- this._localStore = new LYLocalStorage(prefix);
10192
- this._sessionStore = new LYSessionStorage(prefix);
10193
- this._cloudStore = new LYCloudStorage(prefix);
10194
- this._env = new LYEnv(this._name);
10195
- this._env.baseUrl = this.getBaseUrl();
10196
- this._httpClient = this._createHttpClient();
10183
+ _uint8ArrayToString(array) {
10184
+ return new TextDecoder().decode(array);
10197
10185
  }
10198
- get location() {
10199
- return this._name;
10186
+ _base64ToUint8Array(base64) {
10187
+ const binaryString = atob(base64);
10188
+ const bytes = new Uint8Array(binaryString.length);
10189
+ for(let i = 0; i < binaryString.length; i++)bytes[i] = binaryString.charCodeAt(i);
10190
+ return bytes;
10200
10191
  }
10201
- get name() {
10202
- return this._name;
10192
+ _uint8ArrayToBase64(array) {
10193
+ let binaryString = '';
10194
+ array.forEach((byte)=>{
10195
+ binaryString += String.fromCharCode(byte);
10196
+ });
10197
+ return btoa(binaryString);
10203
10198
  }
10204
- get tenantName() {
10205
- return this._tenantName;
10199
+ _getIvAndKey(iv, key) {
10200
+ const actualIv = iv ? 'string' == typeof iv ? this._hexToUint8Array(iv) : iv : this._ivGetter();
10201
+ const actualKey = key ? 'string' == typeof key ? this._hexToUint8Array(key) : key : this._keyGetter();
10202
+ return [
10203
+ actualIv,
10204
+ actualKey
10205
+ ];
10206
10206
  }
10207
- get version() {
10208
- return this._version;
10207
+ _getKey(key, defaultKey) {
10208
+ if (key) return 'string' == typeof key ? this._hexToUint8Array(key) : key;
10209
+ if (defaultKey) return defaultKey;
10210
+ throw new LYCryptoError('Key not provided and no default key available');
10209
10211
  }
10210
- get description() {
10211
- return this._description;
10212
+ _getEncryptPublicKey(publicKey) {
10213
+ const key = this._getKey(publicKey, this._encryptPublicKey);
10214
+ return key;
10212
10215
  }
10213
- get httpClient() {
10214
- return this._httpClient;
10216
+ _getDecryptPrivateKey(privateKey) {
10217
+ const key = this._getKey(privateKey, this._decryptPrivateKey);
10218
+ return key;
10215
10219
  }
10216
- get permission() {
10217
- const session = LYSession.get();
10218
- if (!session) throw new Error('session not found');
10219
- return session.permissions[this._name];
10220
+ _getSignaturePrivateKey(privateKey) {
10221
+ const key = this._getKey(privateKey, this._signaturePrivateKey);
10222
+ return key;
10220
10223
  }
10221
- get provider() {
10222
- return this._provider || new LYDefaultAppProvider();
10224
+ _getVerifyPublicKey(publicKey) {
10225
+ const key = this._getKey(publicKey, this._verifyPublicKey);
10226
+ return key;
10223
10227
  }
10224
- get i18n() {
10225
- return this._i18n;
10228
+ async *_makeSize(data, size) {
10229
+ let buffer = new Uint8Array(0);
10230
+ for await (const chunk of data){
10231
+ const newBuffer = new Uint8Array(buffer.length + chunk.length);
10232
+ newBuffer.set(buffer);
10233
+ newBuffer.set(chunk, buffer.length);
10234
+ buffer = newBuffer;
10235
+ while(buffer.length >= size){
10236
+ yield buffer.slice(0, size);
10237
+ buffer = buffer.slice(size);
10238
+ }
10239
+ }
10240
+ if (buffer.length > 0) yield buffer;
10226
10241
  }
10227
- get localStore() {
10228
- return this._localStore;
10242
+ setSymmetricKeyGetter(ivGetter, keyGetter) {
10243
+ this._ivGetter = ivGetter;
10244
+ this._keyGetter = keyGetter;
10229
10245
  }
10230
- get sessionStore() {
10231
- return this._sessionStore;
10246
+ setEncryptPublicKey(publicKey) {
10247
+ this._encryptPublicKey = 'string' == typeof publicKey ? this._hexToUint8Array(publicKey) : publicKey;
10232
10248
  }
10233
- get cloudStore() {
10234
- return this._cloudStore;
10249
+ setDecryptPrivateKey(privateKey) {
10250
+ this._decryptPrivateKey = 'string' == typeof privateKey ? this._hexToUint8Array(privateKey) : privateKey;
10235
10251
  }
10236
- get isLoaded() {
10237
- return this._isLoaded;
10252
+ setSignaturePrivateKey(privateKey) {
10253
+ this._signaturePrivateKey = 'string' == typeof privateKey ? this._hexToUint8Array(privateKey) : privateKey;
10238
10254
  }
10239
- get env() {
10240
- return this._env;
10255
+ setVerifyPublicKey(publicKey) {
10256
+ this._verifyPublicKey = 'string' == typeof publicKey ? this._hexToUint8Array(publicKey) : publicKey;
10241
10257
  }
10242
- _createHttpClient() {
10243
- return new http_LYAppHttpClient(this._name, {
10244
- get headers () {
10245
- return base_LYBaseApp.getHeaderProvider().headers;
10246
- }
10247
- });
10258
+ encryptSymmetric(data, iv, key) {
10259
+ if ('string' == typeof data) return this._encryptSymmetricStr(data, iv, key);
10260
+ if (ArrayBuffer.isView(data)) return this._encryptSymmetricBytes(data, iv, key);
10261
+ return this._encryptSymmetricStream(data, iv, key);
10248
10262
  }
10249
- async load() {
10250
- if (this._isLoaded) return;
10251
- this.logger.info(`start run ${this._name} app`);
10252
- await this.doLoad();
10253
- this._isLoaded = true;
10254
- this.logger.info(`run ${this._name} app completed`);
10263
+ _encryptSymmetricBytes(data, iv, key) {
10264
+ if (!data || 0 === data.length) return new Uint8Array(data);
10265
+ const [actualIv, actualKey] = this._getIvAndKey(iv, key);
10266
+ return this.impl.encryptSymmetric(data, actualIv, actualKey);
10255
10267
  }
10256
- getBaseUrl() {
10257
- const config = LYConfig.get();
10258
- const url = new URL(window.location.href);
10259
- let baseUrl = "";
10260
- for (const pattern of config.host_patterns){
10261
- if (!pattern.includes("{tenant_name}") && pattern.startsWith(url.origin)) {
10262
- const parts = url.pathname.split('/');
10263
- const index = parts.findIndex((part)=>'view' === part);
10264
- let tenantName = parts[index + 2];
10265
- if (!tenantName) throw new Error('tenantName not found');
10266
- baseUrl = `${pattern}/view/${this.name}/${tenantName}`;
10267
- this._tenantName = tenantName;
10268
- return baseUrl;
10268
+ _encryptSymmetricStr(data, iv, key) {
10269
+ const dataBytes = this._stringToUint8Array(data);
10270
+ const result = this._encryptSymmetricBytes(dataBytes, iv, key);
10271
+ return this._uint8ArrayToBase64(result);
10272
+ }
10273
+ async *_encryptSymmetricStream(data, iv, key) {
10274
+ const [actualIv, actualKey] = this._getIvAndKey(iv, key);
10275
+ const blockSize = this.impl.getSymmetricBlockSize(actualIv, actualKey);
10276
+ for await (const chunk of this._makeSize(data, blockSize)){
10277
+ if (!chunk || 0 === chunk.length) {
10278
+ yield chunk;
10279
+ continue;
10269
10280
  }
10270
- let filterhost = pattern.replace(/\./g, "\\.").replace("{tenant_name}", "([a-zA-Z0-9_\\-]+)");
10271
- const reg = new RegExp(`^${filterhost}(?::\\d+)?(?:/.*)?$`);
10272
- const matched = url.toString().match(reg);
10273
- if (matched && matched[1]) {
10274
- const tenantName = matched[1];
10275
- const host = pattern.replace("{tenant_name}", tenantName);
10276
- baseUrl = `${host}/view/${this.name}`;
10277
- this._tenantName = tenantName;
10278
- return baseUrl;
10279
- }
10280
- }
10281
- try {
10282
- baseUrl = `${window.origin}/view/${this.name}/laiye`;
10283
- this._tenantName = "laiye";
10284
- return baseUrl;
10285
- } catch (error) {
10286
- console.error('Error getting base URL:', error);
10281
+ const buffer = this.impl.encryptSymmetric(chunk, actualIv, actualKey);
10282
+ const lengthBytes = new Uint8Array(LENGTH_SIZE);
10283
+ const view = new DataView(lengthBytes.buffer);
10284
+ view.setUint16(0, buffer.length, false);
10285
+ yield lengthBytes;
10286
+ yield buffer;
10287
10287
  }
10288
- return window.origin;
10289
10288
  }
10290
- async doLoad() {
10291
- await this.initI18n();
10289
+ decryptSymmetric(data, iv, key) {
10290
+ if ('string' == typeof data) return this._decryptSymmetricStr(data, iv, key);
10291
+ if (ArrayBuffer.isView(data)) return this._decryptSymmetricBytes(data, iv, key);
10292
+ return this._decryptSymmetricStream(data, iv, key);
10292
10293
  }
10293
- async initI18n() {
10294
- try {
10295
- const resources = await this.provider.provideI18nResource(this);
10296
- await this._i18n.initialize();
10297
- for(const key in resources)this._i18n.loadResource(resources[key] || {}, key);
10298
- } catch (error) {
10299
- this.logger.error('initI18n error');
10300
- this.logger.error(error);
10301
- }
10294
+ _decryptSymmetricBytes(data, iv, key) {
10295
+ if (!data || 0 === data.length) return new Uint8Array(data);
10296
+ const [actualIv, actualKey] = this._getIvAndKey(iv, key);
10297
+ return this.impl.decryptSymmetric(data, actualIv, actualKey);
10302
10298
  }
10303
- getI18nResourceUrl(relativeUrl, lang) {
10304
- const baseUrl = this.provider.provideI18nResourcePath(this, lang) || '';
10305
- try {
10306
- const url = new URL(relativeUrl, baseUrl);
10307
- return url.toString();
10308
- } catch (error) {
10309
- return `${baseUrl}/${relativeUrl}`;
10299
+ _decryptSymmetricStr(data, iv, key) {
10300
+ const dataBytes = this._base64ToUint8Array(data);
10301
+ const result = this._decryptSymmetricBytes(dataBytes, iv, key);
10302
+ return this._uint8ArrayToString(result);
10303
+ }
10304
+ async *_decryptSymmetricStream(data, iv, key) {
10305
+ const [actualIv, actualKey] = this._getIvAndKey(iv, key);
10306
+ let buffer = new Uint8Array(0);
10307
+ let size = -1;
10308
+ for await (const chunk of data){
10309
+ const newBuffer = new Uint8Array(buffer.length + chunk.length);
10310
+ newBuffer.set(buffer);
10311
+ newBuffer.set(chunk, buffer.length);
10312
+ buffer = newBuffer;
10313
+ while(true){
10314
+ if (size <= 0 && buffer.length < LENGTH_SIZE) break;
10315
+ if (size <= 0) {
10316
+ const view = new DataView(buffer.buffer, buffer.byteOffset);
10317
+ size = view.getUint16(0, false);
10318
+ buffer = buffer.slice(LENGTH_SIZE);
10319
+ }
10320
+ if (buffer.length < size) break;
10321
+ const encryptedChunk = buffer.slice(0, size);
10322
+ yield this.impl.decryptSymmetric(encryptedChunk, actualIv, actualKey);
10323
+ buffer = buffer.slice(size);
10324
+ size = -1;
10325
+ }
10310
10326
  }
10327
+ if (buffer.length > 0) yield this.impl.decryptSymmetric(buffer, actualIv, actualKey);
10311
10328
  }
10312
- async getComponent(componentName) {
10313
- if (this._remoteComponents) return this._remoteComponents[componentName];
10314
- await this.loadRemoteComponents();
10315
- return this._remoteComponents[componentName];
10329
+ encryptAsymmetric(data, publicKey) {
10330
+ if ('string' == typeof data) return this._encryptAsymmetricStr(data, publicKey);
10331
+ if (data instanceof Uint8Array) return this._encryptAsymmetricBytes(data, publicKey);
10332
+ return this._encryptAsymmetricStream(data, publicKey);
10316
10333
  }
10317
- async loadRemoteComponents() {
10318
- const isLoaded = this._isLoadingComponent;
10319
- while(this._isLoadingComponent)await wait();
10320
- if (isLoaded) return this._remoteComponents;
10321
- this._isLoadingComponent = true;
10334
+ _encryptAsymmetricBytes(data, publicKey) {
10335
+ if (!data || 0 === data.length) return new Uint8Array(0);
10336
+ const key = this._getEncryptPublicKey(publicKey);
10337
+ return this.impl.encryptAsymmetric(data, key);
10338
+ }
10339
+ _encryptAsymmetricStr(data, publicKey) {
10340
+ if (!data) return '';
10341
+ const dataBytes = this._stringToUint8Array(data);
10342
+ const result = this._encryptAsymmetricBytes(dataBytes, publicKey);
10343
+ return this._uint8ArrayToBase64(result);
10344
+ }
10345
+ async *_encryptAsymmetricStream(data, publicKey) {
10322
10346
  try {
10323
- (0, runtime.registerRemotes)([
10324
- {
10325
- name: this.name,
10326
- entry: `${this.env.baseUrl}/mf-manifest.json`
10347
+ const key = this._getEncryptPublicKey(publicKey);
10348
+ for await (const chunk of data){
10349
+ if (!chunk || 0 === chunk.length) {
10350
+ yield new Uint8Array(0);
10351
+ continue;
10327
10352
  }
10328
- ]);
10329
- const remoteModule = await (0, runtime.loadRemote)(`${this.name}/Index`);
10330
- this._remoteComponents = await remoteModule.default(this);
10353
+ yield this.impl.encryptAsymmetric(chunk, key);
10354
+ }
10331
10355
  } catch (error) {
10332
- this._remoteComponents = {};
10333
- this.logger.error("loadRemoteComponents error:", error);
10334
- } finally{
10335
- this._isLoadingComponent = false;
10356
+ throw new LYCryptoError(`Stream asymmetric encryption failed: ${error instanceof Error ? error.message : String(error)}`);
10336
10357
  }
10337
- return this._remoteComponents;
10338
10358
  }
10339
- }
10340
- base_LYBaseApp = app_base_ts_decorate([
10341
- register('LYBaseApp'),
10342
- base_ts_metadata("design:type", Function),
10343
- base_ts_metadata("design:paramtypes", [
10344
- String,
10345
- String,
10346
- String
10347
- ])
10348
- ], base_LYBaseApp);
10349
- class LYBaseTenantApp extends base_LYBaseApp {
10350
- _createHttpClient() {
10351
- const lang = this._i18n.lang;
10352
- return new LYTenantHttpClient(this.name, {
10353
- get headers () {
10354
- const session = LYSession.get();
10355
- if (!session) return;
10356
- return {
10357
- Authorization: `Bearer ${session.token}`,
10358
- 'Accept-Language': lang
10359
- };
10360
- }
10361
- });
10359
+ decryptAsymmetric(data, privateKey) {
10360
+ if ('string' == typeof data) return this._decryptAsymmetricStr(data, privateKey);
10361
+ if (data instanceof Uint8Array) return this._decryptAsymmetricBytes(data, privateKey);
10362
+ return this._decryptAsymmetricStream(data, privateKey);
10362
10363
  }
10363
- }
10364
- LYBaseTenantApp = app_base_ts_decorate([
10365
- register('LYBaseTenantApp')
10366
- ], LYBaseTenantApp);
10367
- class session_LYSessionApi {
10368
- constructor(httpClient){
10369
- this._httpClient = httpClient;
10364
+ _decryptAsymmetricBytes(data, privateKey) {
10365
+ if (!data || 0 === data.length) return new Uint8Array(0);
10366
+ const key = this._getDecryptPrivateKey(privateKey);
10367
+ return this.impl.decryptAsymmetric(data, key);
10370
10368
  }
10371
- async create(request) {
10372
- if (!request.name) request = {
10373
- ...request,
10374
- name: ""
10375
- };
10376
- const result = await this._httpClient.post("/session", request);
10377
- return result.data;
10369
+ _decryptAsymmetricStr(data, privateKey) {
10370
+ if (!data) return '';
10371
+ const dataBytes = this._base64ToUint8Array(data);
10372
+ const result = this._decryptAsymmetricBytes(dataBytes, privateKey);
10373
+ return this._uint8ArrayToString(result);
10378
10374
  }
10379
- async update(id) {
10380
- const response = await this._httpClient.post(`/session/patch/${id}`);
10381
- return response.data;
10375
+ async *_decryptAsymmetricStream(data, privateKey) {
10376
+ try {
10377
+ const key = this._getDecryptPrivateKey(privateKey);
10378
+ for await (const chunk of data){
10379
+ if (!chunk || 0 === chunk.length) {
10380
+ yield new Uint8Array(0);
10381
+ continue;
10382
+ }
10383
+ yield this.impl.decryptAsymmetric(chunk, key);
10384
+ }
10385
+ } catch (error) {
10386
+ throw new LYCryptoError(`Stream asymmetric decryption failed: ${error instanceof Error ? error.message : String(error)}`);
10387
+ }
10382
10388
  }
10383
- async delete(id) {
10384
- const response = await this._httpClient.post(`/session/delete/${id}`);
10385
- return response.data.count;
10389
+ signature(data, privateKey) {
10390
+ if ('string' == typeof data) return this._signatureStr(data, privateKey);
10391
+ return this._signatureBytes(data, privateKey);
10386
10392
  }
10387
- async getLoginWays() {
10388
- const response = await this._httpClient.get("/loginways");
10389
- return response.data;
10393
+ _signatureBytes(data, privateKey) {
10394
+ if (!data || 0 === data.length) return '';
10395
+ const key = this._getSignaturePrivateKey(privateKey);
10396
+ return this.impl.signature(data, key);
10390
10397
  }
10391
- }
10392
- class LYUserApi {
10393
- constructor(httpClient){
10394
- this._httpClient = httpClient;
10398
+ _signatureStr(data, privateKey) {
10399
+ if (!data) return '';
10400
+ const dataBytes = this._stringToUint8Array(data);
10401
+ return this._signatureBytes(dataBytes, privateKey);
10395
10402
  }
10396
- async query(params) {
10397
- const response = await this._httpClient.get('/user', params);
10398
- return response.data;
10403
+ verify(data, signature, publicKey) {
10404
+ if ('string' == typeof data) return this._verifyStr(data, signature, publicKey);
10405
+ return this._verifyBytes(data, signature, publicKey);
10399
10406
  }
10400
- async get(name1) {
10401
- const response = await this._httpClient.get(`/user/${name1}`);
10402
- return response.data;
10407
+ _verifyBytes(data, signature, publicKey) {
10408
+ if (!data || 0 === data.length || !signature) return false;
10409
+ const key = this._getVerifyPublicKey(publicKey);
10410
+ return this.impl.verify(data, key, signature);
10403
10411
  }
10404
- async add(user) {
10405
- const response = await this._httpClient.post("/user", {
10406
- ...user,
10407
- password: user.password
10408
- });
10409
- return response.data.id;
10412
+ _verifyStr(data, signature, publicKey) {
10413
+ if (!data || !signature) return false;
10414
+ const dataBytes = this._stringToUint8Array(data);
10415
+ return this._verifyBytes(dataBytes, signature, publicKey);
10410
10416
  }
10411
- async update(name1, user) {
10412
- const response = await this._httpClient.post(`/user/patch/${name1}`, {
10413
- ...user,
10414
- password: user.password
10415
- });
10416
- return response.data.count;
10417
+ hash(data, key, iterations) {
10418
+ if ('string' == typeof data) return this._hashStr(data, key, iterations);
10419
+ return this._hashBytes(data, key, iterations);
10417
10420
  }
10418
- async remove(name1) {
10419
- const response = await this._httpClient.post(`/user/delete/${name1}`);
10420
- return response.data.count;
10421
+ _hashBytes(data, key, iterations = 1) {
10422
+ if (!data || 0 === data.length) return new Uint8Array(0);
10423
+ const actualKey = key ? 'string' == typeof key ? this._hexToUint8Array(key) : key : void 0;
10424
+ let result = new Uint8Array(data);
10425
+ for(let i = 0; i < iterations; i++)result = new Uint8Array(this.impl.hash(result, actualKey));
10426
+ return result;
10421
10427
  }
10422
- async accountCheck(request) {
10423
- const response = await this._httpClient.post("/user/account-check", {
10424
- ...request
10425
- });
10426
- return response.data.exists;
10427
- }
10428
- async register(request) {
10429
- const response = await this._httpClient.post("/user/registration", {
10430
- ...request
10431
- });
10432
- return response.data;
10433
- }
10434
- async userNameCheck(name1) {
10435
- const response = await this._httpClient.get(`/user/username-check/${name1}`);
10436
- return response.data.available;
10437
- }
10438
- async changePassword(currentPassword, newPassword) {
10439
- const response = await this._httpClient.post("/user/password/change", {
10440
- current_password: currentPassword,
10441
- new_password: newPassword
10442
- });
10443
- return response.data;
10444
- }
10445
- async resetPassword(request) {
10446
- const response = await this._httpClient.post("/user/password", {
10447
- ...request
10448
- });
10449
- return response.data;
10450
- }
10451
- }
10452
- const base_ORGANIZATION_APP_NAME = 'organization';
10453
- class LYBaseAuthorizer extends LYObject {
10454
- constructor(app, name1){
10455
- super();
10456
- this._app = app;
10457
- this._name = name1;
10458
- }
10459
- get app() {
10460
- return this._app;
10461
- }
10462
- get name() {
10463
- return this._name;
10464
- }
10465
- async signin(args) {
10466
- await this._signin(args);
10467
- this.emit('status-change', 'signed-in');
10468
- if (args.redirect_uri) setTimeout(()=>{
10469
- window.location.href = args.redirect_uri;
10470
- }, 0);
10471
- }
10472
- async signout(args) {
10473
- await this._signout(args);
10474
- this.emit('status-change', 'signed-out');
10475
- setTimeout(()=>{
10476
- const baseUrl = new URL(this.app.env.baseUrl);
10477
- baseUrl.searchParams.set('returnUrl', encodeURIComponent(args.redirect_uri || window.location.href));
10478
- window.location.href = baseUrl.toString();
10479
- }, 0);
10428
+ _hashStr(data, key, iterations = 1) {
10429
+ if (!data) return '';
10430
+ const dataBytes = this._stringToUint8Array(data);
10431
+ const result = this._hashBytes(dataBytes, key, iterations);
10432
+ return this._uint8ArrayToBase64(result);
10480
10433
  }
10481
10434
  }
10482
- function web_ts_decorate(decorators, target, key, desc) {
10435
+ LYCrypto = crypto_ts_decorate([
10436
+ register('LYCrypto'),
10437
+ crypto_ts_metadata("design:type", Function),
10438
+ crypto_ts_metadata("design:paramtypes", [])
10439
+ ], LYCrypto);
10440
+ const crypto_crypto = new LYCrypto();
10441
+ function i18n_ts_decorate(decorators, target, key, desc) {
10483
10442
  var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10484
10443
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10485
10444
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10486
10445
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10487
10446
  }
10488
- function web_ts_metadata(k, v) {
10447
+ function i18n_ts_metadata(k, v) {
10489
10448
  if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
10490
10449
  }
10491
- class LYWebAuthorizer extends LYBaseAuthorizer {
10492
- constructor(app, name1, sessionApi){
10493
- super(app, name1);
10494
- this._sessionApi = sessionApi;
10495
- LYSession.setRefreshCallback(this._refreshSession.bind(this));
10450
+ var i18n_LYLangEnum = /*#__PURE__*/ function(LYLangEnum) {
10451
+ LYLangEnum["zh-CN"] = "简体中文";
10452
+ LYLangEnum["en-US"] = "English";
10453
+ return LYLangEnum;
10454
+ }({});
10455
+ const i18n_langKeys = Object.keys(i18n_LYLangEnum);
10456
+ const languages = {};
10457
+ const LANG_KEY = 'lang';
10458
+ class LYi18n extends LYObject {
10459
+ constructor(namespace){
10460
+ super();
10461
+ this._namespace = namespace || 'LY.';
10496
10462
  }
10497
- async _signin(args) {
10498
- const response = await this._sessionApi.create({
10499
- name: args.name,
10500
- password: args.password,
10501
- email: args.email,
10502
- phone: args.phone,
10503
- country_code: args.country_code,
10504
- account_type: args.account_type,
10505
- verification_code: args.verification_code,
10506
- verification_code_id: args.verification_code_id
10463
+ get t() {
10464
+ return (rest, options)=>{
10465
+ if (!rest) return "<Null>";
10466
+ if (rest.includes(':')) return rest.startsWith(`${this.namespace}:`) ? i18next.t(rest, options) : i18next.t(`${this.namespace}.${rest}`, options);
10467
+ return i18next.t(`${this.namespace}:${rest}`, options);
10468
+ };
10469
+ }
10470
+ get lang() {
10471
+ return this._lang || this.resolveLanguage();
10472
+ }
10473
+ get languages() {
10474
+ return languages;
10475
+ }
10476
+ get namespace() {
10477
+ return this._namespace;
10478
+ }
10479
+ async initialize() {
10480
+ if (!this._lang) this._lang = this.resolveLanguage();
10481
+ i18next.on('languageChanged', (lang)=>{
10482
+ if (this._lang !== lang) {
10483
+ this._lang = lang;
10484
+ this.emit('lang-changed', lang);
10485
+ }
10507
10486
  });
10508
- LYSession.create('web', '', response.id, response.access_token, response.user_id, response.user_name, response.expires_in, response.permission_codes, response.is_first_login, response.display_name, response.email, response.phone, response.country_code);
10487
+ if (i18next.isInitialized) return;
10488
+ const defaultVariables = {};
10489
+ const env = LYEnv.getInstance(this._namespace);
10490
+ for(const key in env)defaultVariables['$' + key] = env[key];
10491
+ await i18next.init({
10492
+ fallbackLng: 'zh-CN',
10493
+ lng: this._lang,
10494
+ defaultNS: this.namespace,
10495
+ returnObjects: true,
10496
+ interpolation: {
10497
+ escapeValue: false,
10498
+ defaultVariables
10499
+ }
10500
+ });
10501
+ await this.changeLanguage(this._lang);
10509
10502
  }
10510
- async _signout(args) {
10511
- const session = LYSession.get();
10512
- if (!session) throw new Error('Session not found');
10513
- const count = await this._sessionApi.delete(session.id);
10514
- if (0 === count) throw new Error('Session not found');
10515
- LYSession.clear();
10503
+ fallbackLng(lang) {
10504
+ if (lang.includes('en')) return 'en-US';
10505
+ return 'zh-CN';
10516
10506
  }
10517
- async _refreshSession(session) {
10518
- const response = await this._sessionApi.update(session.id);
10519
- LYSession.update(response.id, response.access_token, response.user_id, response.user_name, response.expires_in, response.permission_codes);
10507
+ resolveLanguage() {
10508
+ const langKeys = Object.keys(this.languages);
10509
+ if (1 === langKeys.length) return this.fallbackLng(langKeys[0]);
10510
+ const searchParams = new URLSearchParams(location.search);
10511
+ let lang = searchParams.get(LANG_KEY);
10512
+ if (lang) {
10513
+ lang = this.fallbackLng(lang);
10514
+ return lang;
10515
+ }
10516
+ if (!sharedLocalStorage.getSync(LANG_KEY)) {
10517
+ lang = this.fallbackLng(navigator.language);
10518
+ return lang;
10519
+ }
10520
+ lang = sharedLocalStorage.getSync(LANG_KEY) || 'zh-CN';
10521
+ return lang;
10522
+ }
10523
+ async loadResource(urlOrJson, lang, namespace) {
10524
+ if ('string' == typeof urlOrJson) {
10525
+ const res = await this.getUrlResource(urlOrJson);
10526
+ if (!res) return;
10527
+ urlOrJson = res;
10528
+ }
10529
+ if (!urlOrJson) return;
10530
+ lang = lang || this._lang;
10531
+ namespace = namespace ? `${this.namespace}.${namespace}` : this.namespace;
10532
+ i18next.addResourceBundle(lang, namespace, urlOrJson);
10533
+ }
10534
+ async getUrlResource(resourceUrl) {
10535
+ try {
10536
+ const res = await axios.get(resourceUrl);
10537
+ return res.data;
10538
+ } catch (error) {
10539
+ this.logger.error("loadUrlResource error");
10540
+ this.logger.error(error);
10541
+ }
10542
+ }
10543
+ async changeLanguage(lang) {
10544
+ this.logger.info(`changeLanguage lang to ${lang}`);
10545
+ this._lang = lang;
10546
+ i18next.isInitialized && await i18next.changeLanguage(lang);
10547
+ sharedLocalStorage.setSync(LANG_KEY, lang);
10548
+ const url = new URL(window.location.href);
10549
+ url.searchParams.delete(LANG_KEY);
10550
+ window.history.replaceState(null, '', url);
10551
+ i18next.isInitialized && this.emit('lang-changed', lang);
10552
+ }
10553
+ getResource(key, lang) {
10554
+ lang = lang || this._lang;
10555
+ let index = key.indexOf(':');
10556
+ key = index <= 0 ? `${this.namespace}:${key}` : key.startsWith(`${this.namespace}:`) ? key : `${this.namespace}.${key}`;
10557
+ index = key.indexOf(':');
10558
+ const ns = key.substring(0, index);
10559
+ const keys = key.substring(index + 1);
10560
+ if (!ns || !keys) return {};
10561
+ const res = i18next.getResourceBundle(lang, ns);
10562
+ if (!res) return {};
10563
+ const resource = keys.split('.').reduce((result, key)=>result[key], res);
10564
+ if (!resource && keys === this.namespace) return res;
10565
+ return resource;
10520
10566
  }
10521
10567
  }
10522
- LYWebAuthorizer = web_ts_decorate([
10523
- register('LYWebAuthorizer'),
10524
- web_ts_metadata("design:type", Function),
10525
- web_ts_metadata("design:paramtypes", [
10526
- "undefined" == typeof LYBaseApp ? Object : LYBaseApp,
10527
- String,
10528
- "undefined" == typeof LYSessionApi ? Object : LYSessionApi
10568
+ LYi18n = i18n_ts_decorate([
10569
+ register('LYi18n'),
10570
+ i18n_ts_metadata("design:type", Function),
10571
+ i18n_ts_metadata("design:paramtypes", [
10572
+ String
10529
10573
  ])
10530
- ], LYWebAuthorizer);
10531
- function gateway_ts_decorate(decorators, target, key, desc) {
10574
+ ], LYi18n);
10575
+ function app_base_ts_decorate(decorators, target, key, desc) {
10532
10576
  var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10533
10577
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10534
10578
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10535
10579
  return c > 3 && r && Object.defineProperty(target, key, r), r;
10536
10580
  }
10537
- class LYGatewayAuthorizer extends LYBaseAuthorizer {
10538
- async _signin(args) {
10539
- const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
10540
- const response = await app.httpClient.post('sso/gateway/session');
10541
- LYSession.create('gateway', '', response.id, response.access_token, response.user_id, response.user_name, response.expires_in, response.permission_codes);
10581
+ function base_ts_metadata(k, v) {
10582
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
10583
+ }
10584
+ const CONFIG_URL = "/uci/system_info";
10585
+ const TENANT_APP_NAME = 'tenant';
10586
+ const ORGANIZATION_APP_NAME = 'organization';
10587
+ (0, runtime.init)({
10588
+ name: 'uci',
10589
+ remotes: []
10590
+ });
10591
+ class LYDefaultAppProvider extends LYObject {
10592
+ provideI18nResourcePath(app, lang) {
10593
+ const { i18n } = app;
10594
+ return `${app.env.baseUrl}/i18n/assets/${lang || i18n.lang}/`;
10542
10595
  }
10543
- async _signout(args) {
10544
- const session = LYSession.get();
10545
- if (!session) throw new Error('Session not found');
10546
- const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
10547
- const response = await app.httpClient.post(`sso/gateway/session/delete/${session.id}`);
10548
- if (0 === response.count) throw new Error('Session not found');
10549
- LYSession.clear();
10596
+ async provideI18nResource(app) {
10597
+ const { i18n } = app;
10598
+ const result = {};
10599
+ for (const key of i18n_langKeys){
10600
+ const lang = key;
10601
+ const resource = await i18n.getUrlResource(`${app.env.baseUrl}/i18n/locale/${lang}.json`);
10602
+ result[lang] = resource;
10603
+ }
10604
+ return result;
10550
10605
  }
10551
10606
  }
10552
- LYGatewayAuthorizer = gateway_ts_decorate([
10553
- register('LYGatewayAuthorizer')
10554
- ], LYGatewayAuthorizer);
10555
- function direct_ts_decorate(decorators, target, key, desc) {
10556
- var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10557
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10558
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10559
- return c > 3 && r && Object.defineProperty(target, key, r), r;
10560
- }
10561
- class LYDirectAuthorizer extends LYBaseAuthorizer {
10562
- async _signin(args) {
10563
- const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
10564
- const response = await app.httpClient.post('sso/direct/session', {
10565
- authentication_name: args.authentication_name,
10566
- user_name: args.user_name,
10567
- password: args.password
10568
- });
10569
- LYSession.create('direct', args.authentication_name, response.id, response.access_token, response.user_id, response.user_name, response.expires_in, response.permission_codes);
10570
- }
10571
- async _signout(args) {
10572
- const session = LYSession.get();
10573
- if (!session) throw new Error('Session not found');
10574
- const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
10575
- const response = await app.httpClient.post(`sso/direct/session/delete/${session.id}`, {
10576
- authentication_name: session.authentication_name
10577
- });
10578
- if (0 === response.count) throw new Error('Session not found');
10579
- LYSession.clear();
10607
+ LYDefaultAppProvider = app_base_ts_decorate([
10608
+ register('LYDefaultAppProvider')
10609
+ ], LYDefaultAppProvider);
10610
+ class base_LYBaseApp extends LYObject {
10611
+ static{
10612
+ this._apps = {};
10580
10613
  }
10581
- }
10582
- LYDirectAuthorizer = direct_ts_decorate([
10583
- register('LYDirectAuthorizer')
10584
- ], LYDirectAuthorizer);
10585
- function redirect_ts_decorate(decorators, target, key, desc) {
10586
- var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10587
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10588
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10589
- return c > 3 && r && Object.defineProperty(target, key, r), r;
10590
- }
10591
- const REDIRECT_STORAGE_KEY = 'sso_redirect_info';
10592
- const REDIRECT_STORAGE_EXPIRES_IN = 600000;
10593
- class PKCEUtils {
10594
- static generateCodeVerifier() {
10595
- const array = new Uint8Array(32);
10596
- crypto.getRandomValues(array);
10597
- return btoa(String.fromCharCode.apply(null, Array.from(array))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
10614
+ static{
10615
+ this._initLock = false;
10598
10616
  }
10599
- static async generateCodeChallenge(codeVerifier) {
10600
- const encoder = new TextEncoder();
10601
- const data = encoder.encode(codeVerifier);
10602
- let digest;
10603
- digest = crypto.subtle ? await crypto.subtle.digest('SHA-256', data) : js_sha256.sha256.arrayBuffer(data);
10604
- return btoa(String.fromCharCode.apply(null, Array.from(new Uint8Array(digest)))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
10617
+ static get apps() {
10618
+ return base_LYBaseApp._apps;
10605
10619
  }
10606
- static generateState() {
10607
- const array = new Uint8Array(16);
10608
- crypto.getRandomValues(array);
10609
- return btoa(String.fromCharCode.apply(null, Array.from(array))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
10620
+ static getAppClassName(appName) {
10621
+ const camelCase = appName.replace(/_([a-z])/g, (_, letter)=>letter.toUpperCase());
10622
+ return `LY${camelCase.charAt(0).toUpperCase() + camelCase.slice(1)}App`;
10610
10623
  }
10611
- }
10612
- class LYRedirectAuthorizer extends LYBaseAuthorizer {
10613
- async _signin(args) {
10614
- const redirectInfo = sharedLocalStorage.getSync(REDIRECT_STORAGE_KEY);
10615
- if (redirectInfo) if (redirectInfo.expires_at < new Date()) sharedLocalStorage.removeSync(REDIRECT_STORAGE_KEY);
10616
- else {
10617
- const queryParams = this._getQueryParams();
10618
- const code = queryParams.code;
10619
- const state = queryParams.state;
10620
- const locale = queryParams.ui_locales;
10621
- if (code && state) {
10622
- if (state !== redirectInfo.state) throw new Error('Invalid state parameter');
10623
- const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
10624
- if (locale) await app.i18n.changeLanguage(locale);
10625
- try {
10626
- const response = await app.httpClient.post('sso/redirect/session', {
10627
- authentication_name: redirectInfo.authentication_name,
10628
- query_params: {
10629
- code: code,
10630
- code_verifier: redirectInfo.code_verifier,
10631
- redirect_uri: redirectInfo.redirect_uri,
10632
- state: redirectInfo.state
10633
- }
10634
- });
10635
- if (!response || !response.data.access_token) throw new Error('Invalid SSO response: missing access token');
10636
- 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);
10637
- this.emit('status-change', 'signed-in');
10638
- sharedLocalStorage.removeSync(REDIRECT_STORAGE_KEY);
10639
- setTimeout(()=>{
10640
- window.location.href = redirectInfo.redirect_uri;
10641
- }, 0);
10642
- return;
10643
- } catch (error) {
10644
- console.error('SSO login failed:', error);
10645
- sharedLocalStorage.removeSync(REDIRECT_STORAGE_KEY);
10624
+ static async init(config_url = CONFIG_URL) {
10625
+ if (this._initLock) throw new LYError('Application initialization in progress');
10626
+ this._initLock = true;
10627
+ try {
10628
+ if (0 === Object.keys(base_LYBaseApp._apps).length) {
10629
+ const config = await LYConfig.load(config_url);
10630
+ for (const app of config.apps)if (app.name === TENANT_APP_NAME) {
10631
+ const Constructor = LYObject.getClass('LYTenantApp');
10632
+ base_LYBaseApp._apps[app.name] = new Constructor(app.name, app.version, '');
10633
+ } else if (app.name === ORGANIZATION_APP_NAME) {
10634
+ const Constructor = LYObject.getClass('LYOrganizationApp');
10635
+ base_LYBaseApp._apps[app.name] = new Constructor(app.name, app.version, '');
10636
+ } else {
10637
+ const specificAppClassName = this.getAppClassName(app.name);
10638
+ let Constructor;
10639
+ try {
10640
+ Constructor = LYObject.getClass(specificAppClassName);
10641
+ } catch {
10642
+ Constructor = LYObject.getClass('LYApp');
10643
+ }
10644
+ base_LYBaseApp._apps[app.name] = new Constructor(app.name, app.version, '');
10646
10645
  }
10647
10646
  }
10647
+ } finally{
10648
+ this._initLock = false;
10648
10649
  }
10649
- if (args.sso_config) await this._jumpToSSO(args.sso_config, args.redirect_uri);
10650
- else throw new Error('SSO configuration not provided');
10651
10650
  }
10652
- signin(args) {
10653
- return this._signin(args);
10651
+ static getAll() {
10652
+ return this._apps;
10654
10653
  }
10655
- async _jumpToSSO(ssoConfig, redirectUri) {
10656
- const codeVerifier = PKCEUtils.generateCodeVerifier();
10657
- const codeChallenge = await PKCEUtils.generateCodeChallenge(codeVerifier);
10658
- const state = PKCEUtils.generateState();
10659
- const ssoUrl = new URL(ssoConfig.auth_url);
10660
- ssoUrl.searchParams.set('code_challenge', codeChallenge);
10661
- ssoUrl.searchParams.set('code_challenge_method', 'S256');
10662
- ssoUrl.searchParams.set('state', state);
10663
- sharedLocalStorage.setSync(REDIRECT_STORAGE_KEY, {
10664
- authentication_name: ssoConfig.name,
10665
- redirect_uri: redirectUri,
10666
- expires_at: new Date(Date.now() + REDIRECT_STORAGE_EXPIRES_IN),
10667
- code_verifier: codeVerifier,
10668
- state: state,
10669
- sso_config: ssoConfig
10670
- });
10671
- setTimeout(()=>{
10672
- window.location.href = ssoUrl.toString();
10673
- }, 0);
10654
+ static get(name1) {
10655
+ return this._apps[name1];
10674
10656
  }
10675
- _getQueryParams() {
10676
- const params = {};
10677
- const urlParams = new URLSearchParams(window.location.search);
10678
- urlParams.forEach((value, key)=>{
10679
- params[key] = value;
10680
- });
10681
- return params;
10657
+ static setHeaderProvider(headerProvider) {
10658
+ base_LYBaseApp._headerProvider = headerProvider;
10682
10659
  }
10683
- async signout(args) {
10684
- await this._signout();
10660
+ static getHeaderProvider() {
10661
+ return base_LYBaseApp._headerProvider;
10685
10662
  }
10686
- async _signout() {
10687
- const session = LYSession.get();
10688
- if (!session) throw new Error('Session not found');
10689
- const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
10690
- const response = await app.httpClient.post(`sso/redirect/session/delete/${session.id}`, {
10691
- authentication_name: session.authentication_name
10692
- });
10693
- if (0 === response.data.count) throw new Error('Session not found');
10694
- LYSession.clear();
10695
- if (response.data.logout_url) {
10696
- this.emit('status-change', 'signed-out');
10697
- window.location.href = response.data.logout_url;
10698
- }
10663
+ constructor(name1, version, description){
10664
+ super(), this._isLoaded = false;
10665
+ this._name = name1;
10666
+ this._version = version;
10667
+ this._description = description;
10668
+ this._i18n = new LYi18n(name1);
10669
+ const prefix = `${this._name}.`;
10670
+ this._localStore = new LYLocalStorage(prefix);
10671
+ this._sessionStore = new LYSessionStorage(prefix);
10672
+ this._cloudStore = new LYCloudStorage(prefix);
10673
+ this._env = new LYEnv(this._name);
10674
+ this._httpClient = this._createHttpClient();
10699
10675
  }
10700
- }
10701
- LYRedirectAuthorizer = redirect_ts_decorate([
10702
- register('LYRedirectAuthorizer')
10703
- ], LYRedirectAuthorizer);
10704
- class LYLicenseApi {
10705
- constructor(httpClient){
10706
- this._httpClient = httpClient;
10676
+ get location() {
10677
+ return this._name;
10707
10678
  }
10708
- async queryFiles() {
10709
- const response = await this._httpClient.get("/license/file");
10710
- return response.data;
10679
+ get name() {
10680
+ return this._name;
10711
10681
  }
10712
- async getFileContent(id) {
10713
- const response = await this._httpClient.get(`/license/file/content/${id}`);
10714
- return response.data;
10682
+ get tenantName() {
10683
+ return this._tenantName;
10715
10684
  }
10716
- async add(license) {
10717
- const response = await this._httpClient.post("/license", license);
10718
- return response.data.id;
10685
+ get version() {
10686
+ return this._version;
10719
10687
  }
10720
- async getAll() {
10721
- const response = await this._httpClient.get("/license");
10722
- return response.data;
10688
+ get description() {
10689
+ return this._description;
10723
10690
  }
10724
- async get(id) {
10725
- const response = await this._httpClient.get(`/license/${id}`);
10726
- return response.data;
10691
+ get httpClient() {
10692
+ return this._httpClient;
10727
10693
  }
10728
- async remove(id) {
10729
- const response = await this._httpClient.post(`/license/delete/${id}`);
10730
- return response.data.count;
10694
+ get permission() {
10695
+ const session = LYSession.get();
10696
+ if (!session) throw new Error('session not found');
10697
+ return session.permissions[this._name];
10731
10698
  }
10732
- async getTokens() {
10733
- const response = await this._httpClient.get("/license/token");
10734
- return response.data;
10699
+ get provider() {
10700
+ return this._provider || new LYDefaultAppProvider();
10735
10701
  }
10736
- async getToken(id) {
10737
- const response = await this._httpClient.get(`/license/token/${id}`);
10738
- return response.data;
10702
+ get i18n() {
10703
+ return this._i18n;
10739
10704
  }
10740
- async getLogs(licenseId, tokenId) {
10741
- const response = await this._httpClient.get("/license/log", {
10742
- license_id: licenseId,
10743
- token_id: tokenId
10744
- });
10745
- return response.data;
10705
+ get localStore() {
10706
+ return this._localStore;
10746
10707
  }
10747
- }
10748
- class LYBaseCrypto {
10749
- }
10750
- function registerCryptoImpl(name1) {
10751
- return function(impl) {
10752
- if (cryptoImpl[name1]) throw new Error(`Crypto implementation for ${name1} already registered`);
10753
- cryptoImpl[name1] = impl;
10754
- return impl;
10755
- };
10756
- }
10757
- const cryptoImpl = {
10758
- default: void 0,
10759
- sm: void 0,
10760
- gm: void 0
10761
- };
10762
- function sm_ts_decorate(decorators, target, key, desc) {
10763
- var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10764
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10765
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10766
- return c > 3 && r && Object.defineProperty(target, key, r), r;
10767
- }
10768
- class LYSMCrypto extends LYBaseCrypto {
10769
- _paddingIv(iv) {
10770
- if (iv.length < 16) {
10771
- const padded = new Uint8Array(16);
10772
- padded.set(iv);
10773
- return padded;
10774
- }
10775
- return iv.slice(0, 16);
10776
- }
10777
- _uint8ArrayToHex(array) {
10778
- return Array.from(array).map((b)=>b.toString(16).padStart(2, '0')).join('');
10779
- }
10780
- _hexToUint8Array(hex) {
10781
- if (hex.length % 2 !== 0) throw new LYCryptoError('Invalid hex string length');
10782
- const result = new Uint8Array(hex.length / 2);
10783
- for(let i = 0; i < hex.length; i += 2)result[i / 2] = parseInt(hex.substring(i, i + 2), 16);
10784
- return result;
10708
+ get sessionStore() {
10709
+ return this._sessionStore;
10785
10710
  }
10786
- _validateKey(key, expectedLength, keyType) {
10787
- if (key.length !== expectedLength) throw new LYCryptoError(`Invalid ${keyType} key length: expected ${expectedLength}, got ${key.length}`);
10711
+ get cloudStore() {
10712
+ return this._cloudStore;
10788
10713
  }
10789
- _validatePublicKey(key) {
10790
- if (64 !== key.length && 65 !== key.length) throw new LYCryptoError(`Invalid SM2 public key length: expected 64 or 65, got ${key.length}`);
10714
+ get isLoaded() {
10715
+ return this._isLoaded;
10791
10716
  }
10792
- getSymmetricBlockSize(iv, key) {
10793
- return 16;
10717
+ get env() {
10718
+ return this._env;
10794
10719
  }
10795
- getAsymmetricBlockSize(publicKey) {
10796
- return 16;
10720
+ get crypto() {
10721
+ return crypto_crypto;
10797
10722
  }
10798
- encryptSymmetric(data, iv, key) {
10799
- try {
10800
- this._validateKey(key, 16, 'SM4');
10801
- const paddedIv = this._paddingIv(iv);
10802
- const keyHex = this._uint8ArrayToHex(key);
10803
- const ivHex = this._uint8ArrayToHex(paddedIv);
10804
- const dataHex = this._uint8ArrayToHex(data);
10805
- const encrypted = sm4.encrypt(dataHex, keyHex, {
10806
- iv: ivHex,
10807
- mode: 'cbc',
10808
- padding: 'pkcs#7'
10809
- });
10810
- if (!encrypted) throw new LYCryptoError('SM4 encryption failed');
10811
- return this._hexToUint8Array(encrypted);
10812
- } catch (error) {
10813
- if (error instanceof LYCryptoError) throw error;
10814
- throw new LYCryptoError(`SM4 encryption error: ${error instanceof Error ? error.message : String(error)}`);
10815
- }
10723
+ _createHttpClient() {
10724
+ return new http_LYAppHttpClient(this._name, {
10725
+ get headers () {
10726
+ return base_LYBaseApp.getHeaderProvider().headers;
10727
+ }
10728
+ });
10816
10729
  }
10817
- decryptSymmetric(data, iv, key) {
10818
- try {
10819
- this._validateKey(key, 16, 'SM4');
10820
- const paddedIv = this._paddingIv(iv);
10821
- const keyHex = this._uint8ArrayToHex(key);
10822
- const ivHex = this._uint8ArrayToHex(paddedIv);
10823
- const dataHex = this._uint8ArrayToHex(data);
10824
- const decrypted = sm4.decrypt(dataHex, keyHex, {
10825
- iv: ivHex,
10826
- mode: 'cbc',
10827
- padding: 'pkcs#7'
10828
- });
10829
- if (!decrypted) throw new LYCryptoError('SM4 decryption failed');
10830
- return this._hexToUint8Array(decrypted);
10831
- } catch (error) {
10832
- if (error instanceof LYCryptoError) throw error;
10833
- throw new LYCryptoError(`SM4 decryption error: ${error instanceof Error ? error.message : String(error)}`);
10834
- }
10730
+ async load() {
10731
+ if (this._isLoaded) return;
10732
+ this.logger.info(`start run ${this._name} app`);
10733
+ await this.doLoad();
10734
+ this._isLoaded = true;
10735
+ this.logger.info(`run ${this._name} app completed`);
10835
10736
  }
10836
- signature(data, privateKey) {
10837
- try {
10838
- this._validateKey(privateKey, 32, 'SM2 private');
10839
- const dataHex = this._uint8ArrayToHex(data);
10840
- const privateKeyHex = this._uint8ArrayToHex(privateKey);
10841
- const signature = sm2.doSignature(dataHex, privateKeyHex);
10842
- if (!signature) throw new LYCryptoError('SM2 signature failed');
10843
- return signature;
10844
- } catch (error) {
10845
- if (error instanceof LYCryptoError) throw error;
10846
- throw new LYCryptoError(`SM2 signature error: ${error instanceof Error ? error.message : String(error)}`);
10847
- }
10737
+ async doLoad() {
10738
+ await this.initI18n();
10848
10739
  }
10849
- verify(data, publicKey, signature) {
10740
+ async initI18n() {
10850
10741
  try {
10851
- this._validatePublicKey(publicKey);
10852
- const dataHex = this._uint8ArrayToHex(data);
10853
- const publicKeyHex = this._uint8ArrayToHex(publicKey);
10854
- return sm2.doVerifySignature(dataHex, signature, publicKeyHex);
10742
+ const resources = await this.provider.provideI18nResource(this);
10743
+ await this._i18n.initialize();
10744
+ for(const key in resources)this._i18n.loadResource(resources[key] || {}, key);
10855
10745
  } catch (error) {
10856
- if (error instanceof LYCryptoError) throw error;
10857
- throw new LYCryptoError(`SM2 verify error: ${error instanceof Error ? error.message : String(error)}`);
10746
+ this.logger.error('initI18n error');
10747
+ this.logger.error(error);
10858
10748
  }
10859
10749
  }
10860
- encryptAsymmetric(data, publicKey) {
10750
+ getI18nResourceUrl(relativeUrl, lang) {
10751
+ const baseUrl = this.provider.provideI18nResourcePath(this, lang) || '';
10861
10752
  try {
10862
- this._validatePublicKey(publicKey);
10863
- const dataHex = this._uint8ArrayToHex(data);
10864
- const publicKeyHex = this._uint8ArrayToHex(publicKey);
10865
- const encrypted = sm2.doEncrypt(dataHex, publicKeyHex);
10866
- if (!encrypted) throw new LYCryptoError('SM2 encryption failed');
10867
- return this._hexToUint8Array(encrypted);
10753
+ const url = new URL(relativeUrl, baseUrl);
10754
+ return url.toString();
10868
10755
  } catch (error) {
10869
- if (error instanceof LYCryptoError) throw error;
10870
- throw new LYCryptoError(`SM2 encryption error: ${error instanceof Error ? error.message : String(error)}`);
10756
+ return `${baseUrl}/${relativeUrl}`;
10871
10757
  }
10872
10758
  }
10873
- decryptAsymmetric(data, privateKey) {
10874
- try {
10875
- this._validateKey(privateKey, 32, 'SM2 private');
10876
- const dataHex = this._uint8ArrayToHex(data);
10877
- const privateKeyHex = this._uint8ArrayToHex(privateKey);
10878
- const decrypted = sm2.doDecrypt(dataHex, privateKeyHex);
10879
- if (!decrypted) throw new LYCryptoError('SM2 decryption failed');
10880
- return this._hexToUint8Array(decrypted);
10881
- } catch (error) {
10882
- if (error instanceof LYCryptoError) throw error;
10883
- throw new LYCryptoError(`SM2 decryption error: ${error instanceof Error ? error.message : String(error)}`);
10884
- }
10759
+ async getComponent(componentName) {
10760
+ if (this._remoteComponents) return this._remoteComponents[componentName];
10761
+ await this.loadRemoteComponents();
10762
+ return this._remoteComponents[componentName];
10885
10763
  }
10886
- hash(data, key) {
10764
+ async loadRemoteComponents() {
10765
+ const isLoaded = this._isLoadingComponent;
10766
+ while(this._isLoadingComponent)await wait();
10767
+ if (isLoaded) return this._remoteComponents;
10768
+ this._isLoadingComponent = true;
10887
10769
  try {
10888
- if (key) {
10889
- const hmacResult = sm3(data, {
10890
- key,
10891
- mode: 'hmac'
10892
- });
10893
- if (!hmacResult) throw new LYCryptoError('SM3 HMAC failed');
10894
- return this._hexToUint8Array(hmacResult);
10895
- }
10896
- {
10897
- const hashResult = sm3(data);
10898
- if (!hashResult) throw new LYCryptoError('SM3 hash failed');
10899
- return this._hexToUint8Array(hashResult);
10900
- }
10770
+ (0, runtime.registerRemotes)([
10771
+ {
10772
+ name: this.name,
10773
+ entry: `${this.env.baseUrl}/mf-manifest.json`
10774
+ }
10775
+ ]);
10776
+ const remoteModule = await (0, runtime.loadRemote)(`${this.name}/Index`);
10777
+ this._remoteComponents = await remoteModule.default(this);
10901
10778
  } catch (error) {
10902
- if (error instanceof LYCryptoError) throw error;
10903
- throw new LYCryptoError(`SM3 hash error: ${error instanceof Error ? error.message : String(error)}`);
10779
+ this._remoteComponents = {};
10780
+ this.logger.error("loadRemoteComponents error:", error);
10781
+ } finally{
10782
+ this._isLoadingComponent = false;
10904
10783
  }
10784
+ return this._remoteComponents;
10905
10785
  }
10906
10786
  }
10907
- LYSMCrypto = sm_ts_decorate([
10908
- registerCryptoImpl("sm")
10909
- ], LYSMCrypto);
10910
- function gm_ts_decorate(decorators, target, key, desc) {
10911
- var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10912
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10913
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10914
- return c > 3 && r && Object.defineProperty(target, key, r), r;
10915
- }
10916
- class LYGMCrypto extends LYSMCrypto {
10917
- }
10918
- LYGMCrypto = gm_ts_decorate([
10919
- registerCryptoImpl("gm")
10920
- ], LYGMCrypto);
10921
- function crypto_ts_decorate(decorators, target, key, desc) {
10922
- var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10923
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10924
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10925
- return c > 3 && r && Object.defineProperty(target, key, r), r;
10926
- }
10927
- function crypto_ts_metadata(k, v) {
10928
- if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
10929
- }
10930
- const LENGTH_SIZE = 2;
10931
- class LYCrypto extends LYObject {
10932
- constructor(){
10933
- super();
10934
- this._ivGetter = ()=>new Uint8Array(16);
10935
- this._keyGetter = ()=>new Uint8Array(16);
10936
- }
10937
- get impl() {
10938
- if (!this._impl) this._createImpl();
10939
- if (!this._impl) throw new LYCryptoError('Crypto implementation not available');
10940
- return this._impl;
10787
+ base_LYBaseApp = app_base_ts_decorate([
10788
+ register('LYBaseApp'),
10789
+ base_ts_metadata("design:type", Function),
10790
+ base_ts_metadata("design:paramtypes", [
10791
+ String,
10792
+ String,
10793
+ String
10794
+ ])
10795
+ ], base_LYBaseApp);
10796
+ class session_LYSessionApi {
10797
+ constructor(httpClient){
10798
+ this._httpClient = httpClient;
10941
10799
  }
10942
- _createImpl() {
10943
- try {
10944
- const config = this._getCryptoConfig();
10945
- const implClass = cryptoImpl[config.type];
10946
- if (!implClass) throw new LYCryptoError(`Crypto implementation ${config.type} not found`);
10947
- this._impl = new implClass();
10948
- } catch (error) {
10949
- throw new LYCryptoError(`Failed to create crypto implementation: ${error instanceof Error ? error.message : String(error)}`);
10950
- }
10800
+ async create(request) {
10801
+ if (!request.name) request = {
10802
+ ...request,
10803
+ name: ""
10804
+ };
10805
+ const result = await this._httpClient.post("/session", request);
10806
+ return result.data;
10951
10807
  }
10952
- _getCryptoConfig() {
10953
- const config = new LYCryptoConfig();
10954
- config.type = 'sm';
10955
- return config;
10808
+ async update(id) {
10809
+ const response = await this._httpClient.post(`/session/patch/${id}`);
10810
+ return response.data;
10956
10811
  }
10957
- _uint8ArrayToHex(array) {
10958
- return Array.from(array).map((b)=>b.toString(16).padStart(2, '0')).join('');
10812
+ async delete(id) {
10813
+ const response = await this._httpClient.post(`/session/delete/${id}`);
10814
+ return response.data.count;
10959
10815
  }
10960
- _hexToUint8Array(hex) {
10961
- if (hex.length % 2 !== 0) throw new LYCryptoError('Invalid hex string length');
10962
- const result = new Uint8Array(hex.length / 2);
10963
- for(let i = 0; i < hex.length; i += 2)result[i / 2] = parseInt(hex.substring(i, i + 2), 16);
10964
- return result;
10816
+ async getLoginWays() {
10817
+ const response = await this._httpClient.get("/loginways");
10818
+ return response.data;
10965
10819
  }
10966
- _stringToUint8Array(str) {
10967
- return new TextEncoder().encode(str);
10820
+ }
10821
+ class LYUserApi {
10822
+ constructor(httpClient){
10823
+ this._httpClient = httpClient;
10968
10824
  }
10969
- _uint8ArrayToString(array) {
10970
- return new TextDecoder().decode(array);
10825
+ async query(params) {
10826
+ const response = await this._httpClient.get('/user', params);
10827
+ return response.data;
10971
10828
  }
10972
- _base64ToUint8Array(base64) {
10973
- const binaryString = atob(base64);
10974
- const bytes = new Uint8Array(binaryString.length);
10975
- for(let i = 0; i < binaryString.length; i++)bytes[i] = binaryString.charCodeAt(i);
10976
- return bytes;
10829
+ async get(name1) {
10830
+ const response = await this._httpClient.get(`/user/${name1}`);
10831
+ return response.data;
10977
10832
  }
10978
- _uint8ArrayToBase64(array) {
10979
- let binaryString = '';
10980
- array.forEach((byte)=>{
10981
- binaryString += String.fromCharCode(byte);
10833
+ async add(user) {
10834
+ const response = await this._httpClient.post("/user", {
10835
+ ...user,
10836
+ password: user.password
10982
10837
  });
10983
- return btoa(binaryString);
10838
+ return response.data.id;
10984
10839
  }
10985
- _getIvAndKey(iv, key) {
10986
- const actualIv = iv ? 'string' == typeof iv ? this._hexToUint8Array(iv) : iv : this._ivGetter();
10987
- const actualKey = key ? 'string' == typeof key ? this._hexToUint8Array(key) : key : this._keyGetter();
10988
- return [
10989
- actualIv,
10990
- actualKey
10991
- ];
10840
+ async update(name1, user) {
10841
+ const response = await this._httpClient.post(`/user/patch/${name1}`, {
10842
+ ...user,
10843
+ password: user.password
10844
+ });
10845
+ return response.data.count;
10992
10846
  }
10993
- _getKey(key, defaultKey) {
10994
- if (key) return 'string' == typeof key ? this._hexToUint8Array(key) : key;
10995
- if (defaultKey) return defaultKey;
10996
- throw new LYCryptoError('Key not provided and no default key available');
10847
+ async remove(name1) {
10848
+ const response = await this._httpClient.post(`/user/delete/${name1}`);
10849
+ return response.data.count;
10997
10850
  }
10998
- _getEncryptPublicKey(publicKey) {
10999
- const key = this._getKey(publicKey, this._encryptPublicKey);
11000
- return key;
10851
+ async accountCheck(request) {
10852
+ const response = await this._httpClient.post("/user/account-check", {
10853
+ ...request
10854
+ });
10855
+ return response.data.exists;
11001
10856
  }
11002
- _getDecryptPrivateKey(privateKey) {
11003
- const key = this._getKey(privateKey, this._decryptPrivateKey);
11004
- return key;
10857
+ async register(request) {
10858
+ const response = await this._httpClient.post("/user/registration", {
10859
+ ...request
10860
+ });
10861
+ return response.data;
11005
10862
  }
11006
- _getSignaturePrivateKey(privateKey) {
11007
- const key = this._getKey(privateKey, this._signaturePrivateKey);
11008
- return key;
10863
+ async userNameCheck(name1) {
10864
+ const response = await this._httpClient.get(`/user/username-check/${name1}`);
10865
+ return response.data.available;
11009
10866
  }
11010
- _getVerifyPublicKey(publicKey) {
11011
- const key = this._getKey(publicKey, this._verifyPublicKey);
11012
- return key;
10867
+ async changePassword(currentPassword, newPassword) {
10868
+ const response = await this._httpClient.post("/user/password/change", {
10869
+ current_password: currentPassword,
10870
+ new_password: newPassword
10871
+ });
10872
+ return response.data;
11013
10873
  }
11014
- async *_makeSize(data, size) {
11015
- let buffer = new Uint8Array(0);
11016
- for await (const chunk of data){
11017
- const newBuffer = new Uint8Array(buffer.length + chunk.length);
11018
- newBuffer.set(buffer);
11019
- newBuffer.set(chunk, buffer.length);
11020
- buffer = newBuffer;
11021
- while(buffer.length >= size){
11022
- yield buffer.slice(0, size);
11023
- buffer = buffer.slice(size);
11024
- }
11025
- }
11026
- if (buffer.length > 0) yield buffer;
10874
+ async resetPassword(request) {
10875
+ const response = await this._httpClient.post("/user/password", {
10876
+ ...request
10877
+ });
10878
+ return response.data;
11027
10879
  }
11028
- setSymmetricKeyGetter(ivGetter, keyGetter) {
11029
- this._ivGetter = ivGetter;
11030
- this._keyGetter = keyGetter;
10880
+ }
10881
+ const base_ORGANIZATION_APP_NAME = 'organization';
10882
+ class LYBaseAuthorizer extends LYObject {
10883
+ constructor(app, name1){
10884
+ super();
10885
+ this._app = app;
10886
+ this._name = name1;
11031
10887
  }
11032
- setEncryptPublicKey(publicKey) {
11033
- this._encryptPublicKey = 'string' == typeof publicKey ? this._hexToUint8Array(publicKey) : publicKey;
10888
+ get app() {
10889
+ return this._app;
11034
10890
  }
11035
- setDecryptPrivateKey(privateKey) {
11036
- this._decryptPrivateKey = 'string' == typeof privateKey ? this._hexToUint8Array(privateKey) : privateKey;
10891
+ get name() {
10892
+ return this._name;
11037
10893
  }
11038
- setSignaturePrivateKey(privateKey) {
11039
- this._signaturePrivateKey = 'string' == typeof privateKey ? this._hexToUint8Array(privateKey) : privateKey;
10894
+ async signin(args) {
10895
+ await this._signin(args);
10896
+ this.emit('status-change', 'signed-in');
10897
+ if (args.redirect_uri) setTimeout(()=>{
10898
+ window.location.href = args.redirect_uri;
10899
+ }, 0);
11040
10900
  }
11041
- setVerifyPublicKey(publicKey) {
11042
- this._verifyPublicKey = 'string' == typeof publicKey ? this._hexToUint8Array(publicKey) : publicKey;
10901
+ async signout(args) {
10902
+ await this._signout(args);
10903
+ this.emit('status-change', 'signed-out');
10904
+ setTimeout(()=>{
10905
+ const baseUrl = new URL(this.app.env.baseUrl);
10906
+ baseUrl.searchParams.set('returnUrl', encodeURIComponent(args.redirect_uri || window.location.href));
10907
+ window.location.href = baseUrl.toString();
10908
+ }, 0);
11043
10909
  }
11044
- encryptSymmetric(data, iv, key) {
11045
- if ('string' == typeof data) return this._encryptSymmetricStr(data, iv, key);
11046
- if (ArrayBuffer.isView(data)) return this._encryptSymmetricBytes(data, iv, key);
11047
- return this._encryptSymmetricStream(data, iv, key);
10910
+ }
10911
+ function web_ts_decorate(decorators, target, key, desc) {
10912
+ var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10913
+ if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10914
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10915
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10916
+ }
10917
+ function web_ts_metadata(k, v) {
10918
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
10919
+ }
10920
+ class LYWebAuthorizer extends LYBaseAuthorizer {
10921
+ constructor(app, name1, sessionApi){
10922
+ super(app, name1);
10923
+ this._sessionApi = sessionApi;
10924
+ LYSession.setRefreshCallback(this._refreshSession.bind(this));
11048
10925
  }
11049
- _encryptSymmetricBytes(data, iv, key) {
11050
- if (!data || 0 === data.length) return new Uint8Array(data);
11051
- const [actualIv, actualKey] = this._getIvAndKey(iv, key);
11052
- return this.impl.encryptSymmetric(data, actualIv, actualKey);
10926
+ async _signin(args) {
10927
+ const response = await this._sessionApi.create({
10928
+ name: args.name,
10929
+ password: args.password,
10930
+ email: args.email,
10931
+ phone: args.phone,
10932
+ country_code: args.country_code,
10933
+ account_type: args.account_type,
10934
+ verification_code: args.verification_code,
10935
+ verification_code_id: args.verification_code_id
10936
+ });
10937
+ LYSession.create('web', '', response.id, response.access_token, response.user_id, response.user_name, response.expires_in, response.permission_codes, response.is_first_login, response.display_name, response.email, response.phone, response.country_code);
11053
10938
  }
11054
- _encryptSymmetricStr(data, iv, key) {
11055
- const dataBytes = this._stringToUint8Array(data);
11056
- const result = this._encryptSymmetricBytes(dataBytes, iv, key);
11057
- return this._uint8ArrayToBase64(result);
10939
+ async _signout(args) {
10940
+ const session = LYSession.get();
10941
+ if (!session) throw new Error('Session not found');
10942
+ const count = await this._sessionApi.delete(session.id);
10943
+ if (0 === count) throw new Error('Session not found');
10944
+ LYSession.clear();
11058
10945
  }
11059
- async *_encryptSymmetricStream(data, iv, key) {
11060
- const [actualIv, actualKey] = this._getIvAndKey(iv, key);
11061
- const blockSize = this.impl.getSymmetricBlockSize(actualIv, actualKey);
11062
- for await (const chunk of this._makeSize(data, blockSize)){
11063
- if (!chunk || 0 === chunk.length) {
11064
- yield chunk;
11065
- continue;
11066
- }
11067
- const buffer = this.impl.encryptSymmetric(chunk, actualIv, actualKey);
11068
- const lengthBytes = new Uint8Array(LENGTH_SIZE);
11069
- const view = new DataView(lengthBytes.buffer);
11070
- view.setUint16(0, buffer.length, false);
11071
- yield lengthBytes;
11072
- yield buffer;
11073
- }
10946
+ async _refreshSession(session) {
10947
+ const response = await this._sessionApi.update(session.id);
10948
+ LYSession.update(response.id, response.access_token, response.user_id, response.user_name, response.expires_in, response.permission_codes);
11074
10949
  }
11075
- decryptSymmetric(data, iv, key) {
11076
- if ('string' == typeof data) return this._decryptSymmetricStr(data, iv, key);
11077
- if (ArrayBuffer.isView(data)) return this._decryptSymmetricBytes(data, iv, key);
11078
- return this._decryptSymmetricStream(data, iv, key);
10950
+ }
10951
+ LYWebAuthorizer = web_ts_decorate([
10952
+ register('LYWebAuthorizer'),
10953
+ web_ts_metadata("design:type", Function),
10954
+ web_ts_metadata("design:paramtypes", [
10955
+ "undefined" == typeof LYBaseApp ? Object : LYBaseApp,
10956
+ String,
10957
+ "undefined" == typeof LYSessionApi ? Object : LYSessionApi
10958
+ ])
10959
+ ], LYWebAuthorizer);
10960
+ function gateway_ts_decorate(decorators, target, key, desc) {
10961
+ var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10962
+ if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10963
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10964
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10965
+ }
10966
+ class LYGatewayAuthorizer extends LYBaseAuthorizer {
10967
+ async _signin(args) {
10968
+ const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
10969
+ const response = await app.httpClient.post('sso/gateway/session');
10970
+ LYSession.create('gateway', '', response.id, response.access_token, response.user_id, response.user_name, response.expires_in, response.permission_codes);
11079
10971
  }
11080
- _decryptSymmetricBytes(data, iv, key) {
11081
- if (!data || 0 === data.length) return new Uint8Array(data);
11082
- const [actualIv, actualKey] = this._getIvAndKey(iv, key);
11083
- return this.impl.decryptSymmetric(data, actualIv, actualKey);
10972
+ async _signout(args) {
10973
+ const session = LYSession.get();
10974
+ if (!session) throw new Error('Session not found');
10975
+ const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
10976
+ const response = await app.httpClient.post(`sso/gateway/session/delete/${session.id}`);
10977
+ if (0 === response.count) throw new Error('Session not found');
10978
+ LYSession.clear();
11084
10979
  }
11085
- _decryptSymmetricStr(data, iv, key) {
11086
- const dataBytes = this._base64ToUint8Array(data);
11087
- const result = this._decryptSymmetricBytes(dataBytes, iv, key);
11088
- return this._uint8ArrayToString(result);
10980
+ }
10981
+ LYGatewayAuthorizer = gateway_ts_decorate([
10982
+ register('LYGatewayAuthorizer')
10983
+ ], LYGatewayAuthorizer);
10984
+ function direct_ts_decorate(decorators, target, key, desc) {
10985
+ var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10986
+ if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10987
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10988
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10989
+ }
10990
+ class LYDirectAuthorizer extends LYBaseAuthorizer {
10991
+ async _signin(args) {
10992
+ const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
10993
+ const response = await app.httpClient.post('sso/direct/session', {
10994
+ authentication_name: args.authentication_name,
10995
+ user_name: args.user_name,
10996
+ password: args.password
10997
+ });
10998
+ LYSession.create('direct', args.authentication_name, response.id, response.access_token, response.user_id, response.user_name, response.expires_in, response.permission_codes);
11089
10999
  }
11090
- async *_decryptSymmetricStream(data, iv, key) {
11091
- const [actualIv, actualKey] = this._getIvAndKey(iv, key);
11092
- let buffer = new Uint8Array(0);
11093
- let size = -1;
11094
- for await (const chunk of data){
11095
- const newBuffer = new Uint8Array(buffer.length + chunk.length);
11096
- newBuffer.set(buffer);
11097
- newBuffer.set(chunk, buffer.length);
11098
- buffer = newBuffer;
11099
- while(true){
11100
- if (size <= 0 && buffer.length < LENGTH_SIZE) break;
11101
- if (size <= 0) {
11102
- const view = new DataView(buffer.buffer, buffer.byteOffset);
11103
- size = view.getUint16(0, false);
11104
- buffer = buffer.slice(LENGTH_SIZE);
11000
+ async _signout(args) {
11001
+ const session = LYSession.get();
11002
+ if (!session) throw new Error('Session not found');
11003
+ const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
11004
+ const response = await app.httpClient.post(`sso/direct/session/delete/${session.id}`, {
11005
+ authentication_name: session.authentication_name
11006
+ });
11007
+ if (0 === response.count) throw new Error('Session not found');
11008
+ LYSession.clear();
11009
+ }
11010
+ }
11011
+ LYDirectAuthorizer = direct_ts_decorate([
11012
+ register('LYDirectAuthorizer')
11013
+ ], LYDirectAuthorizer);
11014
+ function redirect_ts_decorate(decorators, target, key, desc) {
11015
+ var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11016
+ if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
11017
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11018
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11019
+ }
11020
+ const REDIRECT_STORAGE_KEY = 'sso_redirect_info';
11021
+ const REDIRECT_STORAGE_EXPIRES_IN = 600000;
11022
+ class PKCEUtils {
11023
+ static generateCodeVerifier() {
11024
+ const array = new Uint8Array(32);
11025
+ crypto.getRandomValues(array);
11026
+ return btoa(String.fromCharCode.apply(null, Array.from(array))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
11027
+ }
11028
+ static async generateCodeChallenge(codeVerifier) {
11029
+ const encoder = new TextEncoder();
11030
+ const data = encoder.encode(codeVerifier);
11031
+ let digest;
11032
+ digest = crypto.subtle ? await crypto.subtle.digest('SHA-256', data) : js_sha256.sha256.arrayBuffer(data);
11033
+ return btoa(String.fromCharCode.apply(null, Array.from(new Uint8Array(digest)))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
11034
+ }
11035
+ static generateState() {
11036
+ const array = new Uint8Array(16);
11037
+ crypto.getRandomValues(array);
11038
+ return btoa(String.fromCharCode.apply(null, Array.from(array))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
11039
+ }
11040
+ }
11041
+ class LYRedirectAuthorizer extends LYBaseAuthorizer {
11042
+ async _signin(args) {
11043
+ const redirectInfo = sharedLocalStorage.getSync(REDIRECT_STORAGE_KEY);
11044
+ if (redirectInfo) if (redirectInfo.expires_at < new Date()) sharedLocalStorage.removeSync(REDIRECT_STORAGE_KEY);
11045
+ else {
11046
+ const queryParams = this._getQueryParams();
11047
+ const code = queryParams.code;
11048
+ const state = queryParams.state;
11049
+ const locale = queryParams.ui_locales;
11050
+ if (code && state) {
11051
+ if (state !== redirectInfo.state) throw new Error('Invalid state parameter');
11052
+ const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
11053
+ if (locale) await app.i18n.changeLanguage(locale);
11054
+ try {
11055
+ const response = await app.httpClient.post('sso/redirect/session', {
11056
+ authentication_name: redirectInfo.authentication_name,
11057
+ query_params: {
11058
+ code: code,
11059
+ code_verifier: redirectInfo.code_verifier,
11060
+ redirect_uri: redirectInfo.redirect_uri,
11061
+ state: redirectInfo.state
11062
+ }
11063
+ });
11064
+ if (!response || !response.data.access_token) throw new Error('Invalid SSO response: missing access token');
11065
+ 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);
11066
+ this.emit('status-change', 'signed-in');
11067
+ sharedLocalStorage.removeSync(REDIRECT_STORAGE_KEY);
11068
+ setTimeout(()=>{
11069
+ window.location.href = redirectInfo.redirect_uri;
11070
+ }, 0);
11071
+ return;
11072
+ } catch (error) {
11073
+ console.error('SSO login failed:', error);
11074
+ sharedLocalStorage.removeSync(REDIRECT_STORAGE_KEY);
11105
11075
  }
11106
- if (buffer.length < size) break;
11107
- const encryptedChunk = buffer.slice(0, size);
11108
- yield this.impl.decryptSymmetric(encryptedChunk, actualIv, actualKey);
11109
- buffer = buffer.slice(size);
11110
- size = -1;
11111
11076
  }
11112
11077
  }
11113
- if (buffer.length > 0) yield this.impl.decryptSymmetric(buffer, actualIv, actualKey);
11114
- }
11115
- encryptAsymmetric(data, publicKey) {
11116
- if ('string' == typeof data) return this._encryptAsymmetricStr(data, publicKey);
11117
- if (data instanceof Uint8Array) return this._encryptAsymmetricBytes(data, publicKey);
11118
- return this._encryptAsymmetricStream(data, publicKey);
11119
- }
11120
- _encryptAsymmetricBytes(data, publicKey) {
11121
- if (!data || 0 === data.length) return new Uint8Array(0);
11122
- const key = this._getEncryptPublicKey(publicKey);
11123
- return this.impl.encryptAsymmetric(data, key);
11124
- }
11125
- _encryptAsymmetricStr(data, publicKey) {
11126
- if (!data) return '';
11127
- const dataBytes = this._stringToUint8Array(data);
11128
- const result = this._encryptAsymmetricBytes(dataBytes, publicKey);
11129
- return this._uint8ArrayToBase64(result);
11078
+ if (args.sso_config) await this._jumpToSSO(args.sso_config, args.redirect_uri);
11079
+ else throw new Error('SSO configuration not provided');
11130
11080
  }
11131
- async *_encryptAsymmetricStream(data, publicKey) {
11132
- try {
11133
- const key = this._getEncryptPublicKey(publicKey);
11134
- for await (const chunk of data){
11135
- if (!chunk || 0 === chunk.length) {
11136
- yield new Uint8Array(0);
11137
- continue;
11138
- }
11139
- yield this.impl.encryptAsymmetric(chunk, key);
11140
- }
11141
- } catch (error) {
11142
- throw new LYCryptoError(`Stream asymmetric encryption failed: ${error instanceof Error ? error.message : String(error)}`);
11143
- }
11081
+ signin(args) {
11082
+ return this._signin(args);
11144
11083
  }
11145
- decryptAsymmetric(data, privateKey) {
11146
- if ('string' == typeof data) return this._decryptAsymmetricStr(data, privateKey);
11147
- if (data instanceof Uint8Array) return this._decryptAsymmetricBytes(data, privateKey);
11148
- return this._decryptAsymmetricStream(data, privateKey);
11084
+ async _jumpToSSO(ssoConfig, redirectUri) {
11085
+ const codeVerifier = PKCEUtils.generateCodeVerifier();
11086
+ const codeChallenge = await PKCEUtils.generateCodeChallenge(codeVerifier);
11087
+ const state = PKCEUtils.generateState();
11088
+ const ssoUrl = new URL(ssoConfig.auth_url);
11089
+ ssoUrl.searchParams.set('code_challenge', codeChallenge);
11090
+ ssoUrl.searchParams.set('code_challenge_method', 'S256');
11091
+ ssoUrl.searchParams.set('state', state);
11092
+ sharedLocalStorage.setSync(REDIRECT_STORAGE_KEY, {
11093
+ authentication_name: ssoConfig.name,
11094
+ redirect_uri: redirectUri,
11095
+ expires_at: new Date(Date.now() + REDIRECT_STORAGE_EXPIRES_IN),
11096
+ code_verifier: codeVerifier,
11097
+ state: state,
11098
+ sso_config: ssoConfig
11099
+ });
11100
+ setTimeout(()=>{
11101
+ window.location.href = ssoUrl.toString();
11102
+ }, 0);
11149
11103
  }
11150
- _decryptAsymmetricBytes(data, privateKey) {
11151
- if (!data || 0 === data.length) return new Uint8Array(0);
11152
- const key = this._getDecryptPrivateKey(privateKey);
11153
- return this.impl.decryptAsymmetric(data, key);
11104
+ _getQueryParams() {
11105
+ const params = {};
11106
+ const urlParams = new URLSearchParams(window.location.search);
11107
+ urlParams.forEach((value, key)=>{
11108
+ params[key] = value;
11109
+ });
11110
+ return params;
11154
11111
  }
11155
- _decryptAsymmetricStr(data, privateKey) {
11156
- if (!data) return '';
11157
- const dataBytes = this._base64ToUint8Array(data);
11158
- const result = this._decryptAsymmetricBytes(dataBytes, privateKey);
11159
- return this._uint8ArrayToString(result);
11112
+ async signout(args) {
11113
+ await this._signout();
11160
11114
  }
11161
- async *_decryptAsymmetricStream(data, privateKey) {
11162
- try {
11163
- const key = this._getDecryptPrivateKey(privateKey);
11164
- for await (const chunk of data){
11165
- if (!chunk || 0 === chunk.length) {
11166
- yield new Uint8Array(0);
11167
- continue;
11168
- }
11169
- yield this.impl.decryptAsymmetric(chunk, key);
11170
- }
11171
- } catch (error) {
11172
- throw new LYCryptoError(`Stream asymmetric decryption failed: ${error instanceof Error ? error.message : String(error)}`);
11115
+ async _signout() {
11116
+ const session = LYSession.get();
11117
+ if (!session) throw new Error('Session not found');
11118
+ const app = base_LYBaseApp.get(base_ORGANIZATION_APP_NAME);
11119
+ const response = await app.httpClient.post(`sso/redirect/session/delete/${session.id}`, {
11120
+ authentication_name: session.authentication_name
11121
+ });
11122
+ if (0 === response.data.count) throw new Error('Session not found');
11123
+ LYSession.clear();
11124
+ if (response.data.logout_url) {
11125
+ this.emit('status-change', 'signed-out');
11126
+ window.location.href = response.data.logout_url;
11173
11127
  }
11174
11128
  }
11175
- signature(data, privateKey) {
11176
- if ('string' == typeof data) return this._signatureStr(data, privateKey);
11177
- return this._signatureBytes(data, privateKey);
11129
+ }
11130
+ LYRedirectAuthorizer = redirect_ts_decorate([
11131
+ register('LYRedirectAuthorizer')
11132
+ ], LYRedirectAuthorizer);
11133
+ class LYLicenseApi {
11134
+ constructor(httpClient){
11135
+ this._httpClient = httpClient;
11178
11136
  }
11179
- _signatureBytes(data, privateKey) {
11180
- if (!data || 0 === data.length) return '';
11181
- const key = this._getSignaturePrivateKey(privateKey);
11182
- return this.impl.signature(data, key);
11137
+ async queryFiles() {
11138
+ const response = await this._httpClient.get("/license/file");
11139
+ return response.data;
11183
11140
  }
11184
- _signatureStr(data, privateKey) {
11185
- if (!data) return '';
11186
- const dataBytes = this._stringToUint8Array(data);
11187
- return this._signatureBytes(dataBytes, privateKey);
11141
+ async getFileContent(id) {
11142
+ const response = await this._httpClient.get(`/license/file/content/${id}`);
11143
+ return response.data;
11188
11144
  }
11189
- verify(data, signature, publicKey) {
11190
- if ('string' == typeof data) return this._verifyStr(data, signature, publicKey);
11191
- return this._verifyBytes(data, signature, publicKey);
11145
+ async add(license) {
11146
+ const response = await this._httpClient.post("/license", license);
11147
+ return response.data.id;
11192
11148
  }
11193
- _verifyBytes(data, signature, publicKey) {
11194
- if (!data || 0 === data.length || !signature) return false;
11195
- const key = this._getVerifyPublicKey(publicKey);
11196
- return this.impl.verify(data, key, signature);
11149
+ async getAll() {
11150
+ const response = await this._httpClient.get("/license");
11151
+ return response.data;
11197
11152
  }
11198
- _verifyStr(data, signature, publicKey) {
11199
- if (!data || !signature) return false;
11200
- const dataBytes = this._stringToUint8Array(data);
11201
- return this._verifyBytes(dataBytes, signature, publicKey);
11153
+ async get(id) {
11154
+ const response = await this._httpClient.get(`/license/${id}`);
11155
+ return response.data;
11202
11156
  }
11203
- hash(data, key, iterations) {
11204
- if ('string' == typeof data) return this._hashStr(data, key, iterations);
11205
- return this._hashBytes(data, key, iterations);
11157
+ async remove(id) {
11158
+ const response = await this._httpClient.post(`/license/delete/${id}`);
11159
+ return response.data.count;
11206
11160
  }
11207
- _hashBytes(data, key, iterations = 1) {
11208
- if (!data || 0 === data.length) return new Uint8Array(0);
11209
- const actualKey = key ? 'string' == typeof key ? this._hexToUint8Array(key) : key : void 0;
11210
- let result = new Uint8Array(data);
11211
- for(let i = 0; i < iterations; i++)result = new Uint8Array(this.impl.hash(result, actualKey));
11212
- return result;
11161
+ async getTokens() {
11162
+ const response = await this._httpClient.get("/license/token");
11163
+ return response.data;
11213
11164
  }
11214
- _hashStr(data, key, iterations = 1) {
11215
- if (!data) return '';
11216
- const dataBytes = this._stringToUint8Array(data);
11217
- const result = this._hashBytes(dataBytes, key, iterations);
11218
- return this._uint8ArrayToBase64(result);
11165
+ async getToken(id) {
11166
+ const response = await this._httpClient.get(`/license/token/${id}`);
11167
+ return response.data;
11168
+ }
11169
+ async getLogs(licenseId, tokenId) {
11170
+ const response = await this._httpClient.get("/license/log", {
11171
+ license_id: licenseId,
11172
+ token_id: tokenId
11173
+ });
11174
+ return response.data;
11219
11175
  }
11220
11176
  }
11221
- LYCrypto = crypto_ts_decorate([
11222
- register('LYCrypto'),
11223
- crypto_ts_metadata("design:type", Function),
11224
- crypto_ts_metadata("design:paramtypes", [])
11225
- ], LYCrypto);
11226
- const crypto_crypto = new LYCrypto();
11227
11177
  class LYOEMApi {
11228
11178
  constructor(httpClient){
11229
11179
  this._httpClient = httpClient;
@@ -11297,9 +11247,10 @@ function app_ts_decorate(decorators, target, key, desc) {
11297
11247
  function app_ts_metadata(k, v) {
11298
11248
  if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
11299
11249
  }
11300
- class LYOrganizationApp extends LYBaseTenantApp {
11250
+ class LYOrganizationApp extends base_LYBaseApp {
11301
11251
  constructor(name1, version, description){
11302
11252
  super(name1, version, description);
11253
+ this.env.baseUrl = this.getBaseUrl();
11303
11254
  LYOrganizationApp._instance = this;
11304
11255
  this._sessionApi = new session_LYSessionApi(this.httpClient);
11305
11256
  this._userApi = new LYUserApi(this.httpClient);
@@ -11317,6 +11268,19 @@ class LYOrganizationApp extends LYBaseTenantApp {
11317
11268
  if (!LYOrganizationApp._instance) throw new Error('LYOrganizationApp not initialized');
11318
11269
  return LYOrganizationApp._instance;
11319
11270
  }
11271
+ _createHttpClient() {
11272
+ const lang = this._i18n.lang;
11273
+ return new LYOrganizationHttpClient(this.name, {
11274
+ get headers () {
11275
+ const session = LYSession.get();
11276
+ if (!session) return;
11277
+ return {
11278
+ Authorization: `Bearer ${session.token}`,
11279
+ 'Accept-Language': lang
11280
+ };
11281
+ }
11282
+ });
11283
+ }
11320
11284
  get sessionApi() {
11321
11285
  return this._sessionApi;
11322
11286
  }
@@ -11329,9 +11293,6 @@ class LYOrganizationApp extends LYBaseTenantApp {
11329
11293
  get licenseApi() {
11330
11294
  return this._licenseApi;
11331
11295
  }
11332
- get crypto() {
11333
- return crypto_crypto;
11334
- }
11335
11296
  get verificationCodesApi() {
11336
11297
  return this._verificationCodesApi;
11337
11298
  }
@@ -11354,6 +11315,50 @@ class LYOrganizationApp extends LYBaseTenantApp {
11354
11315
  if (!this._authorizers[type]) throw new Error(`Authorizer ${type} not found`);
11355
11316
  return this._authorizers[type];
11356
11317
  }
11318
+ getBaseUrl() {
11319
+ const config = LYConfig.get();
11320
+ const url = new URL(window.location.href);
11321
+ let baseUrl = "";
11322
+ for (const pattern of config.host_patterns){
11323
+ if (!pattern.includes("{tenant_name}") && pattern.startsWith(url.origin)) {
11324
+ const parts = url.pathname.split('/');
11325
+ const index = parts.findIndex((part)=>'view' === part);
11326
+ let tenantName = parts[index + 2];
11327
+ if (!tenantName) throw new Error('tenantName not found');
11328
+ baseUrl = `${pattern}/view/${this.name}/${tenantName}`;
11329
+ this._tenantName = tenantName;
11330
+ return baseUrl;
11331
+ }
11332
+ let filterhost = pattern.replace(/\./g, "\\.").replace("{tenant_name}", "([a-zA-Z0-9_\\-]+)");
11333
+ const reg = new RegExp(`^${filterhost}(?::\\d+)?(?:/.*)?$`);
11334
+ const matched = url.toString().match(reg);
11335
+ if (matched && matched[1]) {
11336
+ const tenantName = matched[1];
11337
+ const host = pattern.replace("{tenant_name}", tenantName);
11338
+ baseUrl = `${host}/view/${this.name}`;
11339
+ this._tenantName = tenantName;
11340
+ return baseUrl;
11341
+ }
11342
+ }
11343
+ try {
11344
+ if ('development' === process.env.NODE_ENV) {
11345
+ baseUrl = `${window.origin}/view/${this.name}/laiye`;
11346
+ this._tenantName = "laiye";
11347
+ return baseUrl;
11348
+ }
11349
+ const parts = url.pathname.split('/');
11350
+ const index = parts.findIndex((part)=>'view' === part);
11351
+ if (-1 === index) throw new Error('view not found in URL');
11352
+ let tenantName = parts[index + 2];
11353
+ if (!tenantName) throw new Error('tenantName not found');
11354
+ baseUrl = `${window.origin}/view/${this.name}/${tenantName}`;
11355
+ this._tenantName = tenantName;
11356
+ return baseUrl;
11357
+ } catch (error) {
11358
+ console.error('Error getting base URL:', error);
11359
+ }
11360
+ return window.origin;
11361
+ }
11357
11362
  }
11358
11363
  LYOrganizationApp = app_ts_decorate([
11359
11364
  register('LYOrganizationApp'),
@@ -11716,6 +11721,19 @@ class LYTenantApp extends base_LYBaseApp {
11716
11721
  this._authorizer = new LYTenantAuthorizer(this.httpClient);
11717
11722
  LYTenantApp._instance = this;
11718
11723
  }
11724
+ _createHttpClient() {
11725
+ const lang = this._i18n.lang;
11726
+ return new http_LYAppHttpClient(this.name, {
11727
+ get headers () {
11728
+ const session = LYTenantSession.get();
11729
+ if (!session) return;
11730
+ return {
11731
+ Authorization: `Bearer ${session.token}`,
11732
+ 'Accept-Language': lang
11733
+ };
11734
+ }
11735
+ });
11736
+ }
11719
11737
  static get instance() {
11720
11738
  if (!LYTenantApp._instance) throw new Error('LYTenantApp not initialized');
11721
11739
  return LYTenantApp._instance;
@@ -11745,24 +11763,13 @@ LYTenantApp = tenant_app_ts_decorate([
11745
11763
  String
11746
11764
  ])
11747
11765
  ], LYTenantApp);
11748
- base_LYBaseApp.setHeaderProvider({
11749
- get headers () {
11750
- const lang = LYTenantApp.instance.i18n.lang;
11751
- const session = LYTenantSession.get();
11752
- if (!session) return;
11753
- return {
11754
- Authorization: `Bearer ${session.token}`,
11755
- 'Accept-Language': lang
11756
- };
11757
- }
11758
- });
11759
11766
  function src_app_ts_decorate(decorators, target, key, desc) {
11760
11767
  var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11761
11768
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
11762
11769
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11763
11770
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11764
11771
  }
11765
- class LYApp extends LYBaseTenantApp {
11772
+ class LYApp extends base_LYBaseApp {
11766
11773
  }
11767
11774
  LYApp = src_app_ts_decorate([
11768
11775
  register('LYApp')
@@ -12165,7 +12172,7 @@ http_LYAppHttpClient = src_http_ts_decorate([
12165
12172
  "undefined" == typeof IHeaderProvider ? Object : IHeaderProvider
12166
12173
  ])
12167
12174
  ], http_LYAppHttpClient);
12168
- class LYTenantHttpClient extends http_LYAppHttpClient {
12175
+ class LYOrganizationHttpClient extends http_LYAppHttpClient {
12169
12176
  static getTenantName() {
12170
12177
  const url = window.location.pathname;
12171
12178
  const parts = url.split('/');
@@ -12175,15 +12182,15 @@ class LYTenantHttpClient extends http_LYAppHttpClient {
12175
12182
  }
12176
12183
  _getUrl(url) {
12177
12184
  url = super._getUrl(url);
12178
- const tenantName = LYTenantHttpClient.getTenantName() || 'laiye';
12185
+ const tenantName = LYOrganizationHttpClient.getTenantName();
12179
12186
  if (tenantName) url = url.startsWith('/') ? `${tenantName}${url}` : `${tenantName}/${url}`;
12180
12187
  return url;
12181
12188
  }
12182
12189
  }
12183
- LYTenantHttpClient = src_http_ts_decorate([
12184
- register('LYTenantHttpClient')
12185
- ], LYTenantHttpClient);
12190
+ LYOrganizationHttpClient = src_http_ts_decorate([
12191
+ register('LOrganizationHttpClient')
12192
+ ], LYOrganizationHttpClient);
12186
12193
  var __webpack_exports__FRAMEWORK_NAME = "uci";
12187
- export { LANG_KEY, LYApp, http_LYAppHttpClient as LYAppHttpClient, LYAppPermission, base_LYBaseApp as LYBaseApp, LYCloudStorage, LYConfig, LYCrypto, LYCryptoError, LYDefaultLogFormatter, LYDirectAuthorizer, LYEnv, LYError, LYGatewayAuthorizer, LYIndexedDBLogStorage, i18n_LYLangEnum as LYLangEnum, LYLocalStorage, logger_LYLogLevel as LYLogLevel, LYLogger, LYObject, LYObservable, LYOrganizationApp, LYOwnerObservable, LYRedirectAuthorizer, LYSession, LYSessionStorage, LYTenantApp, LYTenantAuthorizer, LYTenantHttpClient, LYTenantSession, LYWebAuthorizer, LYi18n, ORGANIZATION_APP_NAME, REMOTE_ENTRY, REMOTE_MODULE, TENANT_APP_NAME, crypto_crypto as crypto, isElectron, isIframe, i18n_langKeys as langKeys, languages, logger, observable_observe as observe, register, setCloudStorageImpl, setFormatter, setPrintToConsole, setStorage, sharedCloudStorage, sharedLocalStorage, wait, __webpack_exports__FRAMEWORK_NAME as FRAMEWORK_NAME };
12194
+ export { LANG_KEY, LYApp, http_LYAppHttpClient as LYAppHttpClient, LYAppPermission, base_LYBaseApp as LYBaseApp, LYCloudStorage, LYConfig, LYCrypto, LYCryptoError, LYDefaultLogFormatter, LYDirectAuthorizer, LYEnv, LYError, LYGatewayAuthorizer, LYIndexedDBLogStorage, i18n_LYLangEnum as LYLangEnum, LYLocalStorage, logger_LYLogLevel as LYLogLevel, LYLogger, LYObject, LYObservable, LYOrganizationApp, LYOrganizationHttpClient, LYOwnerObservable, LYRedirectAuthorizer, LYSession, LYSessionStorage, LYTenantApp, LYTenantAuthorizer, LYTenantSession, LYWebAuthorizer, LYi18n, ORGANIZATION_APP_NAME, REMOTE_ENTRY, REMOTE_MODULE, TENANT_APP_NAME, crypto_crypto as crypto, isElectron, isIframe, i18n_langKeys as langKeys, languages, logger, observable_observe as observe, register, setCloudStorageImpl, setFormatter, setPrintToConsole, setStorage, sharedCloudStorage, sharedLocalStorage, wait, __webpack_exports__FRAMEWORK_NAME as FRAMEWORK_NAME };
12188
12195
 
12189
12196
  //# sourceMappingURL=index.js.map