@laiye_packages/uci 1.0.5 → 1.0.7
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/app/base/index.d.ts +5 -1
- package/dist/app/bill/api/admin.d.ts +41 -0
- package/dist/app/bill/api/types.d.ts +258 -0
- package/dist/app/bill/api/user.d.ts +18 -0
- package/dist/app/bill/app/index.d.ts +16 -0
- package/dist/app/bill/app/order.d.ts +70 -0
- package/dist/app/bill/index.d.ts +1 -0
- package/dist/app/index.d.ts +5 -3
- package/dist/app/organization/app/index.d.ts +2 -4
- package/dist/index.js +1002 -711
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,11 +2,11 @@ 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";
|
|
6
|
-
import i18next from "i18next";
|
|
7
|
-
import js_sha256 from "js-sha256";
|
|
8
5
|
import qs from "qs";
|
|
9
6
|
import downloadjs from "downloadjs";
|
|
7
|
+
import i18next from "i18next";
|
|
8
|
+
import { sm2, sm3, sm4 } from "sm-crypto";
|
|
9
|
+
import js_sha256 from "js-sha256";
|
|
10
10
|
var __webpack_modules__ = {
|
|
11
11
|
"../../node_modules/.pnpm/@module-federation+error-codes@0.8.12/node_modules/@module-federation/error-codes/dist/index.cjs.js": function(__unused_webpack_module, exports) {
|
|
12
12
|
const RUNTIME_001 = 'RUNTIME-001';
|
|
@@ -3624,7 +3624,7 @@ var __webpack_modules__ = {
|
|
|
3624
3624
|
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
3625
3625
|
});
|
|
3626
3626
|
},
|
|
3627
|
-
"../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.
|
|
3627
|
+
"../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.7.4_@swc+helpers@0.5.18__react-dom@18.3.1_r_cyx5r4amgprq4i67bngfcxvhom/node_modules/@module-federation/enhanced/dist/src/runtime.js": function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3628
3628
|
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3629
3629
|
if (void 0 === k2) k2 = k;
|
|
3630
3630
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -9703,7 +9703,6 @@ class LYAppHttpError extends LYBaseHttpError {
|
|
|
9703
9703
|
return this._code;
|
|
9704
9704
|
}
|
|
9705
9705
|
}
|
|
9706
|
-
var runtime = __webpack_require__("../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.5.8_@swc+helpers@0.5.18__react-dom@18.3.1_r_dcbcwp56l5mltx2br2csa6d5sy/node_modules/@module-federation/enhanced/dist/src/runtime.js");
|
|
9707
9706
|
class LYAppPermission extends LYObject {
|
|
9708
9707
|
constructor(app_name, codes){
|
|
9709
9708
|
super(), this._codes = {};
|
|
@@ -9959,173 +9958,723 @@ LYSession = session_ts_decorate([
|
|
|
9959
9958
|
String
|
|
9960
9959
|
])
|
|
9961
9960
|
], LYSession);
|
|
9962
|
-
|
|
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) {
|
|
9961
|
+
function http_base_ts_decorate(decorators, target, key, desc) {
|
|
9977
9962
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9978
9963
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
9979
9964
|
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;
|
|
9980
9965
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9981
9966
|
}
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
return Array.from(array).map((b)=>b.toString(16).padStart(2, '0')).join('');
|
|
9967
|
+
function base_ts_metadata(k, v) {
|
|
9968
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
9969
|
+
}
|
|
9970
|
+
class LYHttpClient extends LYObject {
|
|
9971
|
+
constructor(baseUrl){
|
|
9972
|
+
super();
|
|
9973
|
+
this._client = axios.create({
|
|
9974
|
+
baseURL: baseUrl
|
|
9975
|
+
});
|
|
9976
|
+
this._baseUrl = baseUrl || '';
|
|
9993
9977
|
}
|
|
9994
|
-
|
|
9995
|
-
|
|
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;
|
|
9978
|
+
get baseUrl() {
|
|
9979
|
+
return this._baseUrl;
|
|
9999
9980
|
}
|
|
10000
|
-
|
|
10001
|
-
|
|
9981
|
+
get key_converter() {
|
|
9982
|
+
return this._key_converter;
|
|
10002
9983
|
}
|
|
10003
|
-
|
|
10004
|
-
|
|
9984
|
+
set key_converter(converter) {
|
|
9985
|
+
this._key_converter = converter;
|
|
10005
9986
|
}
|
|
10006
|
-
|
|
10007
|
-
return
|
|
9987
|
+
_convert_request(data) {
|
|
9988
|
+
if (!this._key_converter) return data;
|
|
9989
|
+
const result = {};
|
|
9990
|
+
for(const key in data)result[this._key_converter.convert_request(key)] = data[key];
|
|
9991
|
+
return result;
|
|
10008
9992
|
}
|
|
10009
|
-
|
|
10010
|
-
return
|
|
9993
|
+
_convert_response(data) {
|
|
9994
|
+
if (!this._key_converter) return data;
|
|
9995
|
+
const result = {};
|
|
9996
|
+
for(const key in data)result[this._key_converter.convert_response(key)] = data[key];
|
|
9997
|
+
return result;
|
|
10011
9998
|
}
|
|
10012
|
-
|
|
9999
|
+
_get_headers() {}
|
|
10000
|
+
async _request(config) {
|
|
10001
|
+
const { method, data, params, ...rest } = config;
|
|
10002
|
+
let { data: requestData, params: requestParams } = config;
|
|
10003
|
+
if (requestData) requestData = this._convert_request(requestData);
|
|
10004
|
+
if (requestParams) requestParams = this._convert_request(requestParams);
|
|
10013
10005
|
try {
|
|
10014
|
-
this.
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10006
|
+
const response = await this._client.request({
|
|
10007
|
+
method,
|
|
10008
|
+
url: config.url,
|
|
10009
|
+
data: requestData,
|
|
10010
|
+
params: requestParams,
|
|
10011
|
+
...rest,
|
|
10012
|
+
paramsSerializer: (params)=>qs.stringify(params, {
|
|
10013
|
+
arrayFormat: 'repeat'
|
|
10014
|
+
}),
|
|
10015
|
+
headers: {
|
|
10016
|
+
...this._get_headers(),
|
|
10017
|
+
...config?.headers
|
|
10018
|
+
},
|
|
10019
|
+
onUploadProgress: (progressEvent)=>{
|
|
10020
|
+
if (config?.onUploadProgress) config.onUploadProgress(progressEvent.loaded / progressEvent.total);
|
|
10021
|
+
},
|
|
10022
|
+
onDownloadProgress: (progressEvent)=>{
|
|
10023
|
+
if (config?.onDownloadProgress) config.onDownloadProgress(progressEvent.loaded / progressEvent.total);
|
|
10024
|
+
}
|
|
10023
10025
|
});
|
|
10024
|
-
if (!
|
|
10025
|
-
return this.
|
|
10026
|
+
if (!response.headers['content-type'].includes('json')) return response;
|
|
10027
|
+
return this._convert_response(response.data);
|
|
10026
10028
|
} catch (error) {
|
|
10027
|
-
if (error
|
|
10028
|
-
|
|
10029
|
+
if (axios.isAxiosError(error)) {
|
|
10030
|
+
const url = error.config?.url || config.url;
|
|
10031
|
+
if (401 === error.status) try {
|
|
10032
|
+
LYSession.clear();
|
|
10033
|
+
} catch (error) {
|
|
10034
|
+
console.error(error);
|
|
10035
|
+
} finally{
|
|
10036
|
+
window.location.reload();
|
|
10037
|
+
}
|
|
10038
|
+
if (error.response) throw new LYHttpStatusError(error.response?.data?.detail || error.message, url, method, error, error.response.status);
|
|
10039
|
+
if (error.request) throw new LYNetworkError(error.message, url, method, error);
|
|
10040
|
+
throw new LYConfigError(error.message, url, method, error);
|
|
10041
|
+
}
|
|
10042
|
+
throw error;
|
|
10029
10043
|
}
|
|
10030
10044
|
}
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
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)}`);
|
|
10048
|
-
}
|
|
10045
|
+
async withRetry(fn) {
|
|
10046
|
+
let config = LYConfig.get().http.retry;
|
|
10047
|
+
config = fn(config.clone());
|
|
10048
|
+
Date.now();
|
|
10049
|
+
return this;
|
|
10049
10050
|
}
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
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)}`);
|
|
10061
|
-
}
|
|
10051
|
+
async get(url, query, config) {
|
|
10052
|
+
return this._request({
|
|
10053
|
+
method: 'GET',
|
|
10054
|
+
url,
|
|
10055
|
+
params: query,
|
|
10056
|
+
...config
|
|
10057
|
+
});
|
|
10062
10058
|
}
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
}
|
|
10070
|
-
if (error instanceof LYCryptoError) throw error;
|
|
10071
|
-
throw new LYCryptoError(`SM2 verify error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10072
|
-
}
|
|
10059
|
+
async post(url, data, config) {
|
|
10060
|
+
return this._request({
|
|
10061
|
+
method: 'POST',
|
|
10062
|
+
url,
|
|
10063
|
+
data: data,
|
|
10064
|
+
...config
|
|
10065
|
+
});
|
|
10073
10066
|
}
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
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
|
-
}
|
|
10067
|
+
async put(url, data, config) {
|
|
10068
|
+
return this._request({
|
|
10069
|
+
method: 'PUT',
|
|
10070
|
+
url,
|
|
10071
|
+
data: data,
|
|
10072
|
+
...config
|
|
10073
|
+
});
|
|
10086
10074
|
}
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
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
|
-
}
|
|
10075
|
+
async delete(url, query, config) {
|
|
10076
|
+
return this._request({
|
|
10077
|
+
method: 'DELETE',
|
|
10078
|
+
url,
|
|
10079
|
+
params: query,
|
|
10080
|
+
...config
|
|
10081
|
+
});
|
|
10099
10082
|
}
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
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
|
-
}
|
|
10083
|
+
async patch(url, data, config) {
|
|
10084
|
+
return this._request({
|
|
10085
|
+
method: 'PATCH',
|
|
10086
|
+
url,
|
|
10087
|
+
data: data,
|
|
10088
|
+
...config
|
|
10089
|
+
});
|
|
10119
10090
|
}
|
|
10120
10091
|
}
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10092
|
+
LYHttpClient = http_base_ts_decorate([
|
|
10093
|
+
register('LYHttpClient'),
|
|
10094
|
+
base_ts_metadata("design:type", Function),
|
|
10095
|
+
base_ts_metadata("design:paramtypes", [
|
|
10096
|
+
String
|
|
10097
|
+
])
|
|
10098
|
+
], LYHttpClient);
|
|
10099
|
+
function src_http_ts_decorate(decorators, target, key, desc) {
|
|
10100
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10101
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
10102
|
+
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;
|
|
10103
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10104
|
+
}
|
|
10105
|
+
function src_http_ts_metadata(k, v) {
|
|
10106
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
10107
|
+
}
|
|
10108
|
+
const ROUTE_PREFIX_WEB_API = 'web';
|
|
10109
|
+
class http_LYAppHttpClient extends LYHttpClient {
|
|
10110
|
+
constructor(app_name, headerProvider){
|
|
10111
|
+
super(`/${ROUTE_PREFIX_WEB_API}/${app_name}`);
|
|
10112
|
+
this._headerProvider = headerProvider;
|
|
10113
|
+
}
|
|
10114
|
+
_getUrl(url) {
|
|
10115
|
+
return url;
|
|
10116
|
+
}
|
|
10117
|
+
_get_headers() {
|
|
10118
|
+
return this._headerProvider.headers;
|
|
10119
|
+
}
|
|
10120
|
+
async _request(config) {
|
|
10121
|
+
const { method, data, ...rest } = config;
|
|
10122
|
+
let url = this._getUrl(config.url);
|
|
10123
|
+
if ('GET' !== method && 'POST' !== method) throw new LYError(`Method ${method} not allowed`);
|
|
10124
|
+
const response = await super._request({
|
|
10125
|
+
method,
|
|
10126
|
+
data,
|
|
10127
|
+
...rest,
|
|
10128
|
+
url
|
|
10129
|
+
});
|
|
10130
|
+
if (void 0 !== response.status) return response;
|
|
10131
|
+
const result = response;
|
|
10132
|
+
if ('not_exists' === result.code) return result;
|
|
10133
|
+
if ('success' !== result.code) {
|
|
10134
|
+
url = `${this.baseUrl}/${url}`;
|
|
10135
|
+
throw new LYAppHttpError(result.message, url, method, new Error(), result.code);
|
|
10136
|
+
}
|
|
10137
|
+
return result;
|
|
10138
|
+
}
|
|
10139
|
+
async uploadFile(params, config) {
|
|
10140
|
+
const formData = new FormData();
|
|
10141
|
+
if (params.id) formData.append('id', params.id);
|
|
10142
|
+
if (params.ref_id) formData.append('ref_id', params.ref_id);
|
|
10143
|
+
if (params.ref_type) formData.append('ref_type', params.ref_type);
|
|
10144
|
+
if (void 0 !== params.expire) formData.append('expire', String(params.expire));
|
|
10145
|
+
if (void 0 !== params.ignore_session) formData.append('ignore_session', String(params.ignore_session));
|
|
10146
|
+
if (params.extra) formData.append('extra', JSON.stringify(params.extra));
|
|
10147
|
+
formData.append('total_size', String(params.total_size || params.chunk?.size));
|
|
10148
|
+
if (void 0 !== params.encryption) formData.append('encryption', String(params.encryption));
|
|
10149
|
+
if (params.state) formData.append('state', JSON.stringify(params.state));
|
|
10150
|
+
if (params.level) formData.append('level', params.level);
|
|
10151
|
+
formData.append('chunk', params.chunk);
|
|
10152
|
+
const response = await this.post("/file", formData, {
|
|
10153
|
+
...config,
|
|
10154
|
+
headers: {
|
|
10155
|
+
'Content-Type': 'multipart/form-data',
|
|
10156
|
+
...config?.headers
|
|
10157
|
+
}
|
|
10158
|
+
});
|
|
10159
|
+
return response;
|
|
10160
|
+
}
|
|
10161
|
+
async uploadFileInChunks(params, config) {
|
|
10162
|
+
const file = params.chunk;
|
|
10163
|
+
const chunkSize = config?.chunkSize || 20971520;
|
|
10164
|
+
const startChunkIndex = config?.startChunkIndex || 0;
|
|
10165
|
+
const totalChunks = Math.ceil(file.size / chunkSize);
|
|
10166
|
+
let uploadedChunks = 0;
|
|
10167
|
+
let currentState = params.state;
|
|
10168
|
+
let fileId = params.id;
|
|
10169
|
+
for(let chunkIndex = startChunkIndex; chunkIndex < totalChunks; chunkIndex++){
|
|
10170
|
+
const start = chunkIndex * chunkSize;
|
|
10171
|
+
const end = Math.min(start + chunkSize, file.size);
|
|
10172
|
+
const chunk = file.slice(start, end);
|
|
10173
|
+
try {
|
|
10174
|
+
const uploadParams = {
|
|
10175
|
+
...params,
|
|
10176
|
+
chunk: new File([
|
|
10177
|
+
chunk
|
|
10178
|
+
], file.name, {
|
|
10179
|
+
type: file.type
|
|
10180
|
+
}),
|
|
10181
|
+
state: currentState,
|
|
10182
|
+
id: fileId,
|
|
10183
|
+
total_size: file.size
|
|
10184
|
+
};
|
|
10185
|
+
const response = await this.uploadFile(uploadParams, config);
|
|
10186
|
+
fileId = response.data?.id || fileId;
|
|
10187
|
+
currentState = response.data?.state || currentState;
|
|
10188
|
+
uploadedChunks++;
|
|
10189
|
+
const progress = uploadedChunks / (totalChunks - startChunkIndex) * 100;
|
|
10190
|
+
config?.onProgress?.(progress);
|
|
10191
|
+
} catch (error) {
|
|
10192
|
+
this.emit('upload_failed', {
|
|
10193
|
+
error,
|
|
10194
|
+
file,
|
|
10195
|
+
fileId,
|
|
10196
|
+
state: currentState,
|
|
10197
|
+
params,
|
|
10198
|
+
failedChunkIndex: chunkIndex,
|
|
10199
|
+
uploadedChunks
|
|
10200
|
+
});
|
|
10201
|
+
throw error;
|
|
10202
|
+
}
|
|
10203
|
+
}
|
|
10204
|
+
return {
|
|
10205
|
+
id: fileId,
|
|
10206
|
+
state: currentState
|
|
10207
|
+
};
|
|
10208
|
+
}
|
|
10209
|
+
async download(fileId, fileName, config) {
|
|
10210
|
+
config?.chunkSize;
|
|
10211
|
+
const resumeFromByte = config?.resumeFromByte || 0;
|
|
10212
|
+
const url = `${this.baseUrl}/${this._getUrl(`/file/${fileId}`)}`;
|
|
10213
|
+
const headers = {
|
|
10214
|
+
Accept: '*/*',
|
|
10215
|
+
...this._get_headers(),
|
|
10216
|
+
...config?.headers
|
|
10217
|
+
};
|
|
10218
|
+
const blob = new Blob();
|
|
10219
|
+
let reader;
|
|
10220
|
+
try {
|
|
10221
|
+
const downloadResponse = await fetch(url, {
|
|
10222
|
+
method: 'GET',
|
|
10223
|
+
headers: {
|
|
10224
|
+
...headers,
|
|
10225
|
+
...resumeFromByte > 0 && {
|
|
10226
|
+
Range: `bytes=${resumeFromByte}-`
|
|
10227
|
+
}
|
|
10228
|
+
},
|
|
10229
|
+
credentials: 'include'
|
|
10230
|
+
});
|
|
10231
|
+
if (!downloadResponse.ok) throw new Error(`Download request failed: ${downloadResponse.status} ${downloadResponse.statusText}`);
|
|
10232
|
+
reader = downloadResponse.body?.getReader();
|
|
10233
|
+
if (!reader) throw new Error('Response body is not readable');
|
|
10234
|
+
const contentLength = parseInt(downloadResponse.headers.get('content-length') || '0');
|
|
10235
|
+
const contentType = downloadResponse.headers.get('content-type') || 'application/octet-stream';
|
|
10236
|
+
const contentRange = downloadResponse.headers.get('content-range');
|
|
10237
|
+
const contentDisposition = downloadResponse.headers.get('content-disposition');
|
|
10238
|
+
let totalSize = contentLength;
|
|
10239
|
+
if (contentRange) {
|
|
10240
|
+
const match = contentRange.match(/bytes \d+-\d+\/(\d+)/);
|
|
10241
|
+
if (match) totalSize = parseInt(match[1]);
|
|
10242
|
+
}
|
|
10243
|
+
let finalFileName = fileName;
|
|
10244
|
+
if (!finalFileName && contentDisposition) {
|
|
10245
|
+
const utf8Match = contentDisposition.match(/filename\*=UTF-8''([^;]+)/);
|
|
10246
|
+
if (utf8Match) finalFileName = decodeURIComponent(utf8Match[1]);
|
|
10247
|
+
else {
|
|
10248
|
+
const filenameMatch = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
|
|
10249
|
+
if (filenameMatch && filenameMatch[1]) finalFileName = filenameMatch[1].replace(/['"]/g, '');
|
|
10250
|
+
}
|
|
10251
|
+
}
|
|
10252
|
+
const chunks = [];
|
|
10253
|
+
let totalLoaded = 0;
|
|
10254
|
+
let progress = 0;
|
|
10255
|
+
let blob;
|
|
10256
|
+
while(true){
|
|
10257
|
+
const { done, value } = await reader.read();
|
|
10258
|
+
if (done) break;
|
|
10259
|
+
chunks.push(value);
|
|
10260
|
+
totalLoaded += value.length;
|
|
10261
|
+
const newProgress = totalSize > 0 ? totalLoaded / totalSize * 100 : 0;
|
|
10262
|
+
if (newProgress !== progress) {
|
|
10263
|
+
progress = newProgress;
|
|
10264
|
+
config?.onProgress?.(progress);
|
|
10265
|
+
}
|
|
10266
|
+
}
|
|
10267
|
+
blob = new Blob(chunks, {
|
|
10268
|
+
type: contentType
|
|
10269
|
+
});
|
|
10270
|
+
return {
|
|
10271
|
+
blob,
|
|
10272
|
+
fileName: finalFileName,
|
|
10273
|
+
contentType,
|
|
10274
|
+
totalSize: totalSize || blob.size
|
|
10275
|
+
};
|
|
10276
|
+
} catch (error) {
|
|
10277
|
+
if (reader) reader.cancel();
|
|
10278
|
+
this.emit('download_failed', {
|
|
10279
|
+
error,
|
|
10280
|
+
fileId,
|
|
10281
|
+
fileName,
|
|
10282
|
+
blob
|
|
10283
|
+
});
|
|
10284
|
+
throw error;
|
|
10285
|
+
}
|
|
10286
|
+
}
|
|
10287
|
+
async downloadFile(fileId, fileName, config) {
|
|
10288
|
+
const result = await this.download(fileId, fileName, config);
|
|
10289
|
+
downloadjs(result.blob, result.fileName, result.contentType);
|
|
10290
|
+
}
|
|
10291
|
+
async *stream(url, config) {
|
|
10292
|
+
const { data, delimiter = '\n', headers: customHeaders } = config || {};
|
|
10293
|
+
const fullUrl = `${this.baseUrl}/${this._getUrl(url)}`;
|
|
10294
|
+
const headers = {
|
|
10295
|
+
...this._get_headers(),
|
|
10296
|
+
...customHeaders,
|
|
10297
|
+
Accept: 'text/event-stream',
|
|
10298
|
+
'Content-Type': 'application/json'
|
|
10299
|
+
};
|
|
10300
|
+
const abortController = new AbortController();
|
|
10301
|
+
if (config?.signal) config.signal.addEventListener('abort', ()=>{
|
|
10302
|
+
abortController.abort();
|
|
10303
|
+
});
|
|
10304
|
+
const requestOptions = {
|
|
10305
|
+
method: 'POST',
|
|
10306
|
+
headers,
|
|
10307
|
+
signal: abortController.signal,
|
|
10308
|
+
body: JSON.stringify(data)
|
|
10309
|
+
};
|
|
10310
|
+
try {
|
|
10311
|
+
const response = await fetch(fullUrl, requestOptions);
|
|
10312
|
+
if (!response.ok || !response.body) throw new Error(`SSE connection failed: ${response.status}`);
|
|
10313
|
+
const reader = response.body.getReader();
|
|
10314
|
+
const decoder = new TextDecoder();
|
|
10315
|
+
let buffer = '';
|
|
10316
|
+
try {
|
|
10317
|
+
while(true){
|
|
10318
|
+
const { value, done } = await reader.read();
|
|
10319
|
+
if (done) break;
|
|
10320
|
+
const chunk = decoder.decode(value, {
|
|
10321
|
+
stream: true
|
|
10322
|
+
});
|
|
10323
|
+
buffer += chunk;
|
|
10324
|
+
const parts = buffer.split(delimiter);
|
|
10325
|
+
buffer = parts.pop() ?? '';
|
|
10326
|
+
for (const part of parts){
|
|
10327
|
+
const trimmed = part.trim();
|
|
10328
|
+
if (0 !== trimmed.length) yield this.parseChunk(trimmed);
|
|
10329
|
+
}
|
|
10330
|
+
}
|
|
10331
|
+
if (buffer.trim()) yield this.parseChunk(buffer);
|
|
10332
|
+
} finally{
|
|
10333
|
+
reader.releaseLock();
|
|
10334
|
+
}
|
|
10335
|
+
} catch (error) {
|
|
10336
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
10337
|
+
throw new Error(errorMessage);
|
|
10338
|
+
}
|
|
10339
|
+
}
|
|
10340
|
+
parseChunk(text) {
|
|
10341
|
+
Uint8Array;
|
|
10342
|
+
try {
|
|
10343
|
+
return JSON.parse(text);
|
|
10344
|
+
} catch {
|
|
10345
|
+
return text;
|
|
10346
|
+
}
|
|
10347
|
+
}
|
|
10348
|
+
}
|
|
10349
|
+
http_LYAppHttpClient = src_http_ts_decorate([
|
|
10350
|
+
register('LYAppHttpClient'),
|
|
10351
|
+
src_http_ts_metadata("design:type", Function),
|
|
10352
|
+
src_http_ts_metadata("design:paramtypes", [
|
|
10353
|
+
String,
|
|
10354
|
+
"undefined" == typeof IHeaderProvider ? Object : IHeaderProvider
|
|
10355
|
+
])
|
|
10356
|
+
], http_LYAppHttpClient);
|
|
10357
|
+
class LYOrganizationHttpClient extends http_LYAppHttpClient {
|
|
10358
|
+
static getTenantName() {
|
|
10359
|
+
const url = window.location.pathname;
|
|
10360
|
+
const parts = url.split('/');
|
|
10361
|
+
const index = parts.findIndex((part)=>'view' === part);
|
|
10362
|
+
if (-1 === index || index + 1 >= parts.length) return '';
|
|
10363
|
+
return parts[index + 2];
|
|
10364
|
+
}
|
|
10365
|
+
_getUrl(url) {
|
|
10366
|
+
url = super._getUrl(url);
|
|
10367
|
+
let tenantName = LYOrganizationHttpClient.getTenantName();
|
|
10368
|
+
if ('development' === process.env.NODE_ENV) tenantName = "laiye";
|
|
10369
|
+
if (tenantName) url = url.startsWith('/') ? `${tenantName}${url}` : `${tenantName}/${url}`;
|
|
10370
|
+
return url;
|
|
10371
|
+
}
|
|
10372
|
+
}
|
|
10373
|
+
LYOrganizationHttpClient = src_http_ts_decorate([
|
|
10374
|
+
register('LOrganizationHttpClient')
|
|
10375
|
+
], LYOrganizationHttpClient);
|
|
10376
|
+
function i18n_ts_decorate(decorators, target, key, desc) {
|
|
10377
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10378
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
10379
|
+
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;
|
|
10380
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10381
|
+
}
|
|
10382
|
+
function i18n_ts_metadata(k, v) {
|
|
10383
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
10384
|
+
}
|
|
10385
|
+
var i18n_LYLangEnum = /*#__PURE__*/ function(LYLangEnum) {
|
|
10386
|
+
LYLangEnum["zh-CN"] = "简体中文";
|
|
10387
|
+
LYLangEnum["en-US"] = "English";
|
|
10388
|
+
return LYLangEnum;
|
|
10389
|
+
}({});
|
|
10390
|
+
const i18n_langKeys = Object.keys(i18n_LYLangEnum);
|
|
10391
|
+
const languages = {};
|
|
10392
|
+
const LANG_KEY = 'lang';
|
|
10393
|
+
class LYi18n extends LYObject {
|
|
10394
|
+
constructor(namespace){
|
|
10395
|
+
super();
|
|
10396
|
+
this._namespace = namespace || 'LY.';
|
|
10397
|
+
}
|
|
10398
|
+
get t() {
|
|
10399
|
+
return (rest, options)=>{
|
|
10400
|
+
if (!rest) return "<Null>";
|
|
10401
|
+
if (rest.includes(':')) return rest.startsWith(`${this.namespace}:`) ? i18next.t(rest, options) : i18next.t(`${this.namespace}.${rest}`, options);
|
|
10402
|
+
return i18next.t(`${this.namespace}:${rest}`, options);
|
|
10403
|
+
};
|
|
10404
|
+
}
|
|
10405
|
+
get lang() {
|
|
10406
|
+
return this._lang || this.resolveLanguage();
|
|
10407
|
+
}
|
|
10408
|
+
get languages() {
|
|
10409
|
+
return languages;
|
|
10410
|
+
}
|
|
10411
|
+
get namespace() {
|
|
10412
|
+
return this._namespace;
|
|
10413
|
+
}
|
|
10414
|
+
async initialize() {
|
|
10415
|
+
if (!this._lang) this._lang = this.resolveLanguage();
|
|
10416
|
+
i18next.on('languageChanged', (lang)=>{
|
|
10417
|
+
if (this._lang !== lang) {
|
|
10418
|
+
this._lang = lang;
|
|
10419
|
+
this.emit('lang-changed', lang);
|
|
10420
|
+
}
|
|
10421
|
+
});
|
|
10422
|
+
if (i18next.isInitialized) return;
|
|
10423
|
+
const defaultVariables = {};
|
|
10424
|
+
const env = LYEnv.getInstance(this._namespace);
|
|
10425
|
+
for(const key in env)defaultVariables['$' + key] = env[key];
|
|
10426
|
+
await i18next.init({
|
|
10427
|
+
fallbackLng: 'zh-CN',
|
|
10428
|
+
lng: this._lang,
|
|
10429
|
+
defaultNS: this.namespace,
|
|
10430
|
+
returnObjects: true,
|
|
10431
|
+
interpolation: {
|
|
10432
|
+
escapeValue: false,
|
|
10433
|
+
defaultVariables
|
|
10434
|
+
}
|
|
10435
|
+
});
|
|
10436
|
+
await this.changeLanguage(this._lang);
|
|
10437
|
+
}
|
|
10438
|
+
fallbackLng(lang) {
|
|
10439
|
+
if (lang.includes('en')) return 'en-US';
|
|
10440
|
+
return 'zh-CN';
|
|
10441
|
+
}
|
|
10442
|
+
resolveLanguage() {
|
|
10443
|
+
const langKeys = Object.keys(this.languages);
|
|
10444
|
+
if (1 === langKeys.length) return this.fallbackLng(langKeys[0]);
|
|
10445
|
+
const searchParams = new URLSearchParams(location.search);
|
|
10446
|
+
let lang = searchParams.get(LANG_KEY);
|
|
10447
|
+
if (lang) {
|
|
10448
|
+
lang = this.fallbackLng(lang);
|
|
10449
|
+
return lang;
|
|
10450
|
+
}
|
|
10451
|
+
if (!sharedLocalStorage.getSync(LANG_KEY)) {
|
|
10452
|
+
lang = this.fallbackLng(navigator.language);
|
|
10453
|
+
return lang;
|
|
10454
|
+
}
|
|
10455
|
+
lang = sharedLocalStorage.getSync(LANG_KEY) || 'zh-CN';
|
|
10456
|
+
return lang;
|
|
10457
|
+
}
|
|
10458
|
+
async loadResource(urlOrJson, lang, namespace) {
|
|
10459
|
+
if ('string' == typeof urlOrJson) {
|
|
10460
|
+
const res = await this.getUrlResource(urlOrJson);
|
|
10461
|
+
if (!res) return;
|
|
10462
|
+
urlOrJson = res;
|
|
10463
|
+
}
|
|
10464
|
+
if (!urlOrJson) return;
|
|
10465
|
+
lang = lang || this._lang;
|
|
10466
|
+
namespace = namespace ? `${this.namespace}.${namespace}` : this.namespace;
|
|
10467
|
+
i18next.addResourceBundle(lang, namespace, urlOrJson);
|
|
10468
|
+
}
|
|
10469
|
+
async getUrlResource(resourceUrl) {
|
|
10470
|
+
try {
|
|
10471
|
+
const res = await axios.get(`${resourceUrl}?v=${window.buildTime}`);
|
|
10472
|
+
return res.data;
|
|
10473
|
+
} catch (error) {
|
|
10474
|
+
this.logger.error("loadUrlResource error");
|
|
10475
|
+
this.logger.error(error);
|
|
10476
|
+
}
|
|
10477
|
+
}
|
|
10478
|
+
async changeLanguage(lang) {
|
|
10479
|
+
this.logger.info(`changeLanguage lang to ${lang}`);
|
|
10480
|
+
this._lang = lang;
|
|
10481
|
+
i18next.isInitialized && await i18next.changeLanguage(lang);
|
|
10482
|
+
sharedLocalStorage.setSync(LANG_KEY, lang);
|
|
10483
|
+
const url = new URL(window.location.href);
|
|
10484
|
+
url.searchParams.delete(LANG_KEY);
|
|
10485
|
+
window.history.replaceState(null, '', url);
|
|
10486
|
+
i18next.isInitialized && this.emit('lang-changed', lang);
|
|
10487
|
+
}
|
|
10488
|
+
getResource(key, lang) {
|
|
10489
|
+
lang = lang || this._lang;
|
|
10490
|
+
let index = key.indexOf(':');
|
|
10491
|
+
key = index <= 0 ? `${this.namespace}:${key}` : key.startsWith(`${this.namespace}:`) ? key : `${this.namespace}.${key}`;
|
|
10492
|
+
index = key.indexOf(':');
|
|
10493
|
+
const ns = key.substring(0, index);
|
|
10494
|
+
const keys = key.substring(index + 1);
|
|
10495
|
+
if (!ns || !keys) return {};
|
|
10496
|
+
const res = i18next.getResourceBundle(lang, ns);
|
|
10497
|
+
if (!res) return {};
|
|
10498
|
+
const resource = keys.split('.').reduce((result, key)=>result[key], res);
|
|
10499
|
+
if (!resource && keys === this.namespace) return res;
|
|
10500
|
+
return resource;
|
|
10501
|
+
}
|
|
10502
|
+
}
|
|
10503
|
+
LYi18n = i18n_ts_decorate([
|
|
10504
|
+
register('LYi18n'),
|
|
10505
|
+
i18n_ts_metadata("design:type", Function),
|
|
10506
|
+
i18n_ts_metadata("design:paramtypes", [
|
|
10507
|
+
String
|
|
10508
|
+
])
|
|
10509
|
+
], LYi18n);
|
|
10510
|
+
var runtime = __webpack_require__("../../node_modules/.pnpm/@module-federation+enhanced@0.8.12_@rspack+core@1.7.4_@swc+helpers@0.5.18__react-dom@18.3.1_r_cyx5r4amgprq4i67bngfcxvhom/node_modules/@module-federation/enhanced/dist/src/runtime.js");
|
|
10511
|
+
class LYBaseCrypto {
|
|
10512
|
+
}
|
|
10513
|
+
function registerCryptoImpl(name1) {
|
|
10514
|
+
return function(impl) {
|
|
10515
|
+
if (cryptoImpl[name1]) throw new Error(`Crypto implementation for ${name1} already registered`);
|
|
10516
|
+
cryptoImpl[name1] = impl;
|
|
10517
|
+
return impl;
|
|
10518
|
+
};
|
|
10519
|
+
}
|
|
10520
|
+
const cryptoImpl = {
|
|
10521
|
+
default: void 0,
|
|
10522
|
+
sm: void 0,
|
|
10523
|
+
gm: void 0
|
|
10524
|
+
};
|
|
10525
|
+
function sm_ts_decorate(decorators, target, key, desc) {
|
|
10526
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10527
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
10528
|
+
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;
|
|
10529
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10530
|
+
}
|
|
10531
|
+
class LYSMCrypto extends LYBaseCrypto {
|
|
10532
|
+
_paddingIv(iv) {
|
|
10533
|
+
if (iv.length < 16) {
|
|
10534
|
+
const padded = new Uint8Array(16);
|
|
10535
|
+
padded.set(iv);
|
|
10536
|
+
return padded;
|
|
10537
|
+
}
|
|
10538
|
+
return iv.slice(0, 16);
|
|
10539
|
+
}
|
|
10540
|
+
_uint8ArrayToHex(array) {
|
|
10541
|
+
return Array.from(array).map((b)=>b.toString(16).padStart(2, '0')).join('');
|
|
10542
|
+
}
|
|
10543
|
+
_hexToUint8Array(hex) {
|
|
10544
|
+
if (hex.length % 2 !== 0) throw new LYCryptoError('Invalid hex string length');
|
|
10545
|
+
const result = new Uint8Array(hex.length / 2);
|
|
10546
|
+
for(let i = 0; i < hex.length; i += 2)result[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
10547
|
+
return result;
|
|
10548
|
+
}
|
|
10549
|
+
_validateKey(key, expectedLength, keyType) {
|
|
10550
|
+
if (key.length !== expectedLength) throw new LYCryptoError(`Invalid ${keyType} key length: expected ${expectedLength}, got ${key.length}`);
|
|
10551
|
+
}
|
|
10552
|
+
_validatePublicKey(key) {
|
|
10553
|
+
if (64 !== key.length && 65 !== key.length) throw new LYCryptoError(`Invalid SM2 public key length: expected 64 or 65, got ${key.length}`);
|
|
10554
|
+
}
|
|
10555
|
+
getSymmetricBlockSize(iv, key) {
|
|
10556
|
+
return 16;
|
|
10557
|
+
}
|
|
10558
|
+
getAsymmetricBlockSize(publicKey) {
|
|
10559
|
+
return 16;
|
|
10560
|
+
}
|
|
10561
|
+
encryptSymmetric(data, iv, key) {
|
|
10562
|
+
try {
|
|
10563
|
+
this._validateKey(key, 16, 'SM4');
|
|
10564
|
+
const paddedIv = this._paddingIv(iv);
|
|
10565
|
+
const keyHex = this._uint8ArrayToHex(key);
|
|
10566
|
+
const ivHex = this._uint8ArrayToHex(paddedIv);
|
|
10567
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10568
|
+
const encrypted = sm4.encrypt(dataHex, keyHex, {
|
|
10569
|
+
iv: ivHex,
|
|
10570
|
+
mode: 'cbc',
|
|
10571
|
+
padding: 'pkcs#7'
|
|
10572
|
+
});
|
|
10573
|
+
if (!encrypted) throw new LYCryptoError('SM4 encryption failed');
|
|
10574
|
+
return this._hexToUint8Array(encrypted);
|
|
10575
|
+
} catch (error) {
|
|
10576
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10577
|
+
throw new LYCryptoError(`SM4 encryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10578
|
+
}
|
|
10579
|
+
}
|
|
10580
|
+
decryptSymmetric(data, iv, key) {
|
|
10581
|
+
try {
|
|
10582
|
+
this._validateKey(key, 16, 'SM4');
|
|
10583
|
+
const paddedIv = this._paddingIv(iv);
|
|
10584
|
+
const keyHex = this._uint8ArrayToHex(key);
|
|
10585
|
+
const ivHex = this._uint8ArrayToHex(paddedIv);
|
|
10586
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10587
|
+
const decrypted = sm4.decrypt(dataHex, keyHex, {
|
|
10588
|
+
iv: ivHex,
|
|
10589
|
+
mode: 'cbc',
|
|
10590
|
+
padding: 'pkcs#7'
|
|
10591
|
+
});
|
|
10592
|
+
if (!decrypted) throw new LYCryptoError('SM4 decryption failed');
|
|
10593
|
+
return this._hexToUint8Array(decrypted);
|
|
10594
|
+
} catch (error) {
|
|
10595
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10596
|
+
throw new LYCryptoError(`SM4 decryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10597
|
+
}
|
|
10598
|
+
}
|
|
10599
|
+
signature(data, privateKey) {
|
|
10600
|
+
try {
|
|
10601
|
+
this._validateKey(privateKey, 32, 'SM2 private');
|
|
10602
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10603
|
+
const privateKeyHex = this._uint8ArrayToHex(privateKey);
|
|
10604
|
+
const signature = sm2.doSignature(dataHex, privateKeyHex);
|
|
10605
|
+
if (!signature) throw new LYCryptoError('SM2 signature failed');
|
|
10606
|
+
return signature;
|
|
10607
|
+
} catch (error) {
|
|
10608
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10609
|
+
throw new LYCryptoError(`SM2 signature error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10610
|
+
}
|
|
10611
|
+
}
|
|
10612
|
+
verify(data, publicKey, signature) {
|
|
10613
|
+
try {
|
|
10614
|
+
this._validatePublicKey(publicKey);
|
|
10615
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10616
|
+
const publicKeyHex = this._uint8ArrayToHex(publicKey);
|
|
10617
|
+
return sm2.doVerifySignature(dataHex, signature, publicKeyHex);
|
|
10618
|
+
} catch (error) {
|
|
10619
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10620
|
+
throw new LYCryptoError(`SM2 verify error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10621
|
+
}
|
|
10622
|
+
}
|
|
10623
|
+
encryptAsymmetric(data, publicKey) {
|
|
10624
|
+
try {
|
|
10625
|
+
this._validatePublicKey(publicKey);
|
|
10626
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10627
|
+
const publicKeyHex = this._uint8ArrayToHex(publicKey);
|
|
10628
|
+
const encrypted = sm2.doEncrypt(dataHex, publicKeyHex);
|
|
10629
|
+
if (!encrypted) throw new LYCryptoError('SM2 encryption failed');
|
|
10630
|
+
return this._hexToUint8Array(encrypted);
|
|
10631
|
+
} catch (error) {
|
|
10632
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10633
|
+
throw new LYCryptoError(`SM2 encryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10634
|
+
}
|
|
10635
|
+
}
|
|
10636
|
+
decryptAsymmetric(data, privateKey) {
|
|
10637
|
+
try {
|
|
10638
|
+
this._validateKey(privateKey, 32, 'SM2 private');
|
|
10639
|
+
const dataHex = this._uint8ArrayToHex(data);
|
|
10640
|
+
const privateKeyHex = this._uint8ArrayToHex(privateKey);
|
|
10641
|
+
const decrypted = sm2.doDecrypt(dataHex, privateKeyHex);
|
|
10642
|
+
if (!decrypted) throw new LYCryptoError('SM2 decryption failed');
|
|
10643
|
+
return this._hexToUint8Array(decrypted);
|
|
10644
|
+
} catch (error) {
|
|
10645
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10646
|
+
throw new LYCryptoError(`SM2 decryption error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10647
|
+
}
|
|
10648
|
+
}
|
|
10649
|
+
hash(data, key) {
|
|
10650
|
+
try {
|
|
10651
|
+
if (key) {
|
|
10652
|
+
const hmacResult = sm3(data, {
|
|
10653
|
+
key,
|
|
10654
|
+
mode: 'hmac'
|
|
10655
|
+
});
|
|
10656
|
+
if (!hmacResult) throw new LYCryptoError('SM3 HMAC failed');
|
|
10657
|
+
return this._hexToUint8Array(hmacResult);
|
|
10658
|
+
}
|
|
10659
|
+
{
|
|
10660
|
+
const hashResult = sm3(data);
|
|
10661
|
+
if (!hashResult) throw new LYCryptoError('SM3 hash failed');
|
|
10662
|
+
return this._hexToUint8Array(hashResult);
|
|
10663
|
+
}
|
|
10664
|
+
} catch (error) {
|
|
10665
|
+
if (error instanceof LYCryptoError) throw error;
|
|
10666
|
+
throw new LYCryptoError(`SM3 hash error: ${error instanceof Error ? error.message : String(error)}`);
|
|
10667
|
+
}
|
|
10668
|
+
}
|
|
10669
|
+
}
|
|
10670
|
+
LYSMCrypto = sm_ts_decorate([
|
|
10671
|
+
registerCryptoImpl("sm")
|
|
10672
|
+
], LYSMCrypto);
|
|
10673
|
+
function gm_ts_decorate(decorators, target, key, desc) {
|
|
10674
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10675
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
10676
|
+
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;
|
|
10677
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10129
10678
|
}
|
|
10130
10679
|
class LYGMCrypto extends LYSMCrypto {
|
|
10131
10680
|
}
|
|
@@ -10414,176 +10963,43 @@ class LYCrypto extends LYObject {
|
|
|
10414
10963
|
const dataBytes = this._stringToUint8Array(data);
|
|
10415
10964
|
return this._verifyBytes(dataBytes, signature, publicKey);
|
|
10416
10965
|
}
|
|
10417
|
-
hash(data, key, iterations) {
|
|
10418
|
-
if ('string' == typeof data) return this._hashStr(data, key, iterations);
|
|
10419
|
-
return this._hashBytes(data, key, iterations);
|
|
10420
|
-
}
|
|
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;
|
|
10427
|
-
}
|
|
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);
|
|
10433
|
-
}
|
|
10434
|
-
}
|
|
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) {
|
|
10442
|
-
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10443
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
10445
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10446
|
-
}
|
|
10447
|
-
function i18n_ts_metadata(k, v) {
|
|
10448
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
10449
|
-
}
|
|
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.';
|
|
10462
|
-
}
|
|
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
|
-
}
|
|
10486
|
-
});
|
|
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);
|
|
10502
|
-
}
|
|
10503
|
-
fallbackLng(lang) {
|
|
10504
|
-
if (lang.includes('en')) return 'en-US';
|
|
10505
|
-
return 'zh-CN';
|
|
10506
|
-
}
|
|
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;
|
|
10966
|
+
hash(data, key, iterations) {
|
|
10967
|
+
if ('string' == typeof data) return this._hashStr(data, key, iterations);
|
|
10968
|
+
return this._hashBytes(data, key, iterations);
|
|
10969
|
+
}
|
|
10970
|
+
_hashBytes(data, key, iterations = 1) {
|
|
10971
|
+
if (!data || 0 === data.length) return new Uint8Array(0);
|
|
10972
|
+
const actualKey = key ? 'string' == typeof key ? this._hexToUint8Array(key) : key : void 0;
|
|
10973
|
+
let result = new Uint8Array(data);
|
|
10974
|
+
for(let i = 0; i < iterations; i++)result = new Uint8Array(this.impl.hash(result, actualKey));
|
|
10975
|
+
return result;
|
|
10976
|
+
}
|
|
10977
|
+
_hashStr(data, key, iterations = 1) {
|
|
10978
|
+
if (!data) return '';
|
|
10979
|
+
const dataBytes = this._stringToUint8Array(data);
|
|
10980
|
+
const result = this._hashBytes(dataBytes, key, iterations);
|
|
10981
|
+
return this._uint8ArrayToBase64(result);
|
|
10566
10982
|
}
|
|
10567
10983
|
}
|
|
10568
|
-
|
|
10569
|
-
register('
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
], LYi18n);
|
|
10984
|
+
LYCrypto = crypto_ts_decorate([
|
|
10985
|
+
register('LYCrypto'),
|
|
10986
|
+
crypto_ts_metadata("design:type", Function),
|
|
10987
|
+
crypto_ts_metadata("design:paramtypes", [])
|
|
10988
|
+
], LYCrypto);
|
|
10989
|
+
const crypto_crypto = new LYCrypto();
|
|
10575
10990
|
function app_base_ts_decorate(decorators, target, key, desc) {
|
|
10576
10991
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10577
10992
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
10578
10993
|
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;
|
|
10579
10994
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10580
10995
|
}
|
|
10581
|
-
function
|
|
10996
|
+
function app_base_ts_metadata(k, v) {
|
|
10582
10997
|
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
10583
10998
|
}
|
|
10584
10999
|
const CONFIG_URL = "/uci/system_info";
|
|
10585
11000
|
const TENANT_APP_NAME = 'tenant';
|
|
10586
11001
|
const ORGANIZATION_APP_NAME = 'organization';
|
|
11002
|
+
const BILL_APP_NAME = "billing";
|
|
10587
11003
|
(0, runtime.init)({
|
|
10588
11004
|
name: 'uci',
|
|
10589
11005
|
remotes: []
|
|
@@ -10633,6 +11049,9 @@ class base_LYBaseApp extends LYObject {
|
|
|
10633
11049
|
} else if (app.name === ORGANIZATION_APP_NAME) {
|
|
10634
11050
|
const Constructor = LYObject.getClass('LYOrganizationApp');
|
|
10635
11051
|
base_LYBaseApp._apps[app.name] = new Constructor(app.name, app.version, '');
|
|
11052
|
+
} else if (app.name === BILL_APP_NAME) {
|
|
11053
|
+
const Constructor = LYObject.getClass('LYBillApp');
|
|
11054
|
+
base_LYBaseApp._apps[app.name] = new Constructor(app.name, app.version, '');
|
|
10636
11055
|
} else {
|
|
10637
11056
|
const specificAppClassName = this.getAppClassName(app.name);
|
|
10638
11057
|
let Constructor;
|
|
@@ -10722,9 +11141,10 @@ class base_LYBaseApp extends LYObject {
|
|
|
10722
11141
|
return crypto_crypto;
|
|
10723
11142
|
}
|
|
10724
11143
|
_createHttpClient() {
|
|
10725
|
-
return new
|
|
11144
|
+
return new LYOrganizationHttpClient(this._name, {
|
|
10726
11145
|
get headers () {
|
|
10727
|
-
|
|
11146
|
+
const headers = base_LYBaseApp.getHeaderProvider()?.headers;
|
|
11147
|
+
return headers;
|
|
10728
11148
|
}
|
|
10729
11149
|
});
|
|
10730
11150
|
}
|
|
@@ -10831,13 +11251,31 @@ class base_LYBaseApp extends LYObject {
|
|
|
10831
11251
|
}
|
|
10832
11252
|
base_LYBaseApp = app_base_ts_decorate([
|
|
10833
11253
|
register('LYBaseApp'),
|
|
10834
|
-
|
|
10835
|
-
|
|
11254
|
+
app_base_ts_metadata("design:type", Function),
|
|
11255
|
+
app_base_ts_metadata("design:paramtypes", [
|
|
10836
11256
|
String,
|
|
10837
11257
|
String,
|
|
10838
11258
|
String
|
|
10839
11259
|
])
|
|
10840
11260
|
], base_LYBaseApp);
|
|
11261
|
+
class LYBaseOrganizationApp extends base_LYBaseApp {
|
|
11262
|
+
_createHttpClient() {
|
|
11263
|
+
const lang = this._i18n.lang;
|
|
11264
|
+
return new LYOrganizationHttpClient(this.name, {
|
|
11265
|
+
get headers () {
|
|
11266
|
+
const session = LYSession.get();
|
|
11267
|
+
if (!session) return;
|
|
11268
|
+
return {
|
|
11269
|
+
Authorization: `Bearer ${session.token}`,
|
|
11270
|
+
'Accept-Language': lang
|
|
11271
|
+
};
|
|
11272
|
+
}
|
|
11273
|
+
});
|
|
11274
|
+
}
|
|
11275
|
+
}
|
|
11276
|
+
LYBaseOrganizationApp = app_base_ts_decorate([
|
|
11277
|
+
register('LYBaseOrganizationApp')
|
|
11278
|
+
], LYBaseOrganizationApp);
|
|
10841
11279
|
class session_LYSessionApi {
|
|
10842
11280
|
constructor(httpClient){
|
|
10843
11281
|
this._httpClient = httpClient;
|
|
@@ -11292,7 +11730,7 @@ function app_ts_decorate(decorators, target, key, desc) {
|
|
|
11292
11730
|
function app_ts_metadata(k, v) {
|
|
11293
11731
|
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
11294
11732
|
}
|
|
11295
|
-
class LYOrganizationApp extends
|
|
11733
|
+
class LYOrganizationApp extends LYBaseOrganizationApp {
|
|
11296
11734
|
constructor(name1, version, description){
|
|
11297
11735
|
super(name1, version, description);
|
|
11298
11736
|
LYOrganizationApp._instance = this;
|
|
@@ -11312,19 +11750,6 @@ class LYOrganizationApp extends base_LYBaseApp {
|
|
|
11312
11750
|
if (!LYOrganizationApp._instance) throw new Error('LYOrganizationApp not initialized');
|
|
11313
11751
|
return LYOrganizationApp._instance;
|
|
11314
11752
|
}
|
|
11315
|
-
_createHttpClient() {
|
|
11316
|
-
const lang = this._i18n.lang;
|
|
11317
|
-
return new LYOrganizationHttpClient(this.name, {
|
|
11318
|
-
get headers () {
|
|
11319
|
-
const session = LYSession.get();
|
|
11320
|
-
if (!session) return;
|
|
11321
|
-
return {
|
|
11322
|
-
Authorization: `Bearer ${session.token}`,
|
|
11323
|
-
'Accept-Language': lang
|
|
11324
|
-
};
|
|
11325
|
-
}
|
|
11326
|
-
});
|
|
11327
|
-
}
|
|
11328
11753
|
get sessionApi() {
|
|
11329
11754
|
return this._sessionApi;
|
|
11330
11755
|
}
|
|
@@ -11766,434 +12191,300 @@ LYTenantApp = tenant_app_ts_decorate([
|
|
|
11766
12191
|
String
|
|
11767
12192
|
])
|
|
11768
12193
|
], LYTenantApp);
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11772
|
-
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;
|
|
11773
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11774
|
-
}
|
|
11775
|
-
class LYApp extends base_LYBaseApp {
|
|
11776
|
-
}
|
|
11777
|
-
LYApp = src_app_ts_decorate([
|
|
11778
|
-
register('LYApp')
|
|
11779
|
-
], LYApp);
|
|
11780
|
-
function http_base_ts_decorate(decorators, target, key, desc) {
|
|
11781
|
-
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11782
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
11783
|
-
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;
|
|
11784
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11785
|
-
}
|
|
11786
|
-
function http_base_ts_metadata(k, v) {
|
|
11787
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
11788
|
-
}
|
|
11789
|
-
class LYHttpClient extends LYObject {
|
|
11790
|
-
constructor(baseUrl){
|
|
11791
|
-
super();
|
|
11792
|
-
this._client = axios.create({
|
|
11793
|
-
baseURL: baseUrl
|
|
11794
|
-
});
|
|
11795
|
-
this._baseUrl = baseUrl || '';
|
|
12194
|
+
class LYAdminApi {
|
|
12195
|
+
constructor(httpClient){
|
|
12196
|
+
this._httpClient = httpClient;
|
|
11796
12197
|
}
|
|
11797
|
-
|
|
11798
|
-
|
|
12198
|
+
async getProducts(params) {
|
|
12199
|
+
const res = await this._httpClient.get('/admin/products', params);
|
|
12200
|
+
return res.data;
|
|
11799
12201
|
}
|
|
11800
|
-
|
|
11801
|
-
|
|
12202
|
+
async createProduct(product) {
|
|
12203
|
+
const res = await this._httpClient.post('/admin/products', product);
|
|
12204
|
+
return res.data;
|
|
11802
12205
|
}
|
|
11803
|
-
|
|
11804
|
-
this.
|
|
12206
|
+
async updateProduct(id, product) {
|
|
12207
|
+
const res = await this._httpClient.post(`/admin/products/patch/${id}`, product);
|
|
12208
|
+
return res.data;
|
|
11805
12209
|
}
|
|
11806
|
-
|
|
11807
|
-
|
|
11808
|
-
|
|
11809
|
-
for(const key in data)result[this._key_converter.convert_request(key)] = data[key];
|
|
11810
|
-
return result;
|
|
12210
|
+
async delProduct(id) {
|
|
12211
|
+
const res = await this._httpClient.post(`/admin/products/delete/${id}`);
|
|
12212
|
+
return res.data;
|
|
11811
12213
|
}
|
|
11812
|
-
|
|
11813
|
-
|
|
11814
|
-
|
|
11815
|
-
for(const key in data)result[this._key_converter.convert_response(key)] = data[key];
|
|
11816
|
-
return result;
|
|
12214
|
+
async query(id) {
|
|
12215
|
+
const res = await this._httpClient.get(`/admin/products/${id}`);
|
|
12216
|
+
return res.data;
|
|
11817
12217
|
}
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
let { data: requestData, params: requestParams } = config;
|
|
11822
|
-
if (requestData) requestData = this._convert_request(requestData);
|
|
11823
|
-
if (requestParams) requestParams = this._convert_request(requestParams);
|
|
11824
|
-
try {
|
|
11825
|
-
const response = await this._client.request({
|
|
11826
|
-
method,
|
|
11827
|
-
url: config.url,
|
|
11828
|
-
data: requestData,
|
|
11829
|
-
params: requestParams,
|
|
11830
|
-
...rest,
|
|
11831
|
-
paramsSerializer: (params)=>qs.stringify(params, {
|
|
11832
|
-
arrayFormat: 'repeat'
|
|
11833
|
-
}),
|
|
11834
|
-
headers: {
|
|
11835
|
-
...this._get_headers(),
|
|
11836
|
-
...config?.headers
|
|
11837
|
-
},
|
|
11838
|
-
onUploadProgress: (progressEvent)=>{
|
|
11839
|
-
if (config?.onUploadProgress) config.onUploadProgress(progressEvent.loaded / progressEvent.total);
|
|
11840
|
-
},
|
|
11841
|
-
onDownloadProgress: (progressEvent)=>{
|
|
11842
|
-
if (config?.onDownloadProgress) config.onDownloadProgress(progressEvent.loaded / progressEvent.total);
|
|
11843
|
-
}
|
|
11844
|
-
});
|
|
11845
|
-
if (!response.headers['content-type'].includes('json')) return response;
|
|
11846
|
-
return this._convert_response(response.data);
|
|
11847
|
-
} catch (error) {
|
|
11848
|
-
if (axios.isAxiosError(error)) {
|
|
11849
|
-
const url = error.config?.url || config.url;
|
|
11850
|
-
if (401 === error.status) try {
|
|
11851
|
-
const app = base_LYBaseApp.get(ORGANIZATION_APP_NAME);
|
|
11852
|
-
app.getAuthorizer().signout({
|
|
11853
|
-
redirect_uri: window.location.href
|
|
11854
|
-
});
|
|
11855
|
-
} catch (error) {
|
|
11856
|
-
console.error(error);
|
|
11857
|
-
window.location.reload();
|
|
11858
|
-
}
|
|
11859
|
-
if (error.response) throw new LYHttpStatusError(error.response?.data?.detail || error.message, url, method, error, error.response.status);
|
|
11860
|
-
if (error.request) throw new LYNetworkError(error.message, url, method, error);
|
|
11861
|
-
throw new LYConfigError(error.message, url, method, error);
|
|
11862
|
-
}
|
|
11863
|
-
throw error;
|
|
11864
|
-
}
|
|
12218
|
+
async getPrices(param) {
|
|
12219
|
+
const res = await this._httpClient.get('/admin/prices', param);
|
|
12220
|
+
return res.data;
|
|
11865
12221
|
}
|
|
11866
|
-
async
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
Date.now();
|
|
11870
|
-
return this;
|
|
12222
|
+
async createPrice(price) {
|
|
12223
|
+
const res = await this._httpClient.post('/admin/prices', price);
|
|
12224
|
+
return res.data;
|
|
11871
12225
|
}
|
|
11872
|
-
async
|
|
11873
|
-
|
|
11874
|
-
|
|
11875
|
-
url,
|
|
11876
|
-
params: query,
|
|
11877
|
-
...config
|
|
11878
|
-
});
|
|
12226
|
+
async updatePrice(id, price) {
|
|
12227
|
+
const res = await this._httpClient.post(`/admin/prices/patch/${id}`, price);
|
|
12228
|
+
return res.data;
|
|
11879
12229
|
}
|
|
11880
|
-
async
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
url,
|
|
11884
|
-
data: data,
|
|
11885
|
-
...config
|
|
11886
|
-
});
|
|
12230
|
+
async delPrice(id) {
|
|
12231
|
+
const res = await this._httpClient.post(`/admin/prices/delete/${id}`);
|
|
12232
|
+
return res.data;
|
|
11887
12233
|
}
|
|
11888
|
-
async
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
url,
|
|
11892
|
-
data: data,
|
|
11893
|
-
...config
|
|
11894
|
-
});
|
|
12234
|
+
async queryPrice(param) {
|
|
12235
|
+
const res = await this._httpClient.get('/admin/prices', param);
|
|
12236
|
+
return res.data;
|
|
11895
12237
|
}
|
|
11896
|
-
async
|
|
11897
|
-
|
|
11898
|
-
|
|
11899
|
-
url,
|
|
11900
|
-
params: query,
|
|
11901
|
-
...config
|
|
11902
|
-
});
|
|
12238
|
+
async getPlatforms(param) {
|
|
12239
|
+
const res = await this._httpClient.get('/admin/platforms', param);
|
|
12240
|
+
return res.data;
|
|
11903
12241
|
}
|
|
11904
|
-
async
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
12242
|
+
async createPlatform(platform) {
|
|
12243
|
+
const res = await this._httpClient.post('/admin/platforms', platform);
|
|
12244
|
+
return res.data;
|
|
12245
|
+
}
|
|
12246
|
+
async updatePlatform(id, platform) {
|
|
12247
|
+
const res = await this._httpClient.post(`/admin/platforms/patch/${id}`, platform);
|
|
12248
|
+
return res.data;
|
|
12249
|
+
}
|
|
12250
|
+
async delPlatform(id) {
|
|
12251
|
+
const res = await this._httpClient.post(`/admin/platforms/delete/${id}`);
|
|
12252
|
+
return res.data;
|
|
12253
|
+
}
|
|
12254
|
+
async queryPlatform(id) {
|
|
12255
|
+
const res = await this._httpClient.get(`/admin/platforms/${id}`);
|
|
12256
|
+
return res.data;
|
|
12257
|
+
}
|
|
12258
|
+
async getOrders(param) {
|
|
12259
|
+
const res = await this._httpClient.get('/admin/orders', param);
|
|
12260
|
+
return res.data;
|
|
12261
|
+
}
|
|
12262
|
+
async getOrderDetails(id) {
|
|
12263
|
+
const res = await this._httpClient.get(`/admin/orders/${id}`);
|
|
12264
|
+
return res.data;
|
|
11911
12265
|
}
|
|
11912
12266
|
}
|
|
11913
|
-
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
http_base_ts_metadata("design:paramtypes", [
|
|
11917
|
-
String
|
|
11918
|
-
])
|
|
11919
|
-
], LYHttpClient);
|
|
11920
|
-
function src_http_ts_decorate(decorators, target, key, desc) {
|
|
11921
|
-
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11922
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
11923
|
-
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;
|
|
11924
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11925
|
-
}
|
|
11926
|
-
function src_http_ts_metadata(k, v) {
|
|
11927
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
11928
|
-
}
|
|
11929
|
-
const ROUTE_PREFIX_WEB_API = 'web';
|
|
11930
|
-
class http_LYAppHttpClient extends LYHttpClient {
|
|
11931
|
-
constructor(app_name, headerProvider){
|
|
11932
|
-
super(`/${ROUTE_PREFIX_WEB_API}/${app_name}`);
|
|
11933
|
-
this._headerProvider = headerProvider;
|
|
12267
|
+
class api_user_LYUserApi {
|
|
12268
|
+
constructor(httpClient){
|
|
12269
|
+
this._httpClient = httpClient;
|
|
11934
12270
|
}
|
|
11935
|
-
|
|
11936
|
-
|
|
12271
|
+
async getProductsByApp(param) {
|
|
12272
|
+
const res = await this._httpClient.get('/products', param);
|
|
12273
|
+
return res.data;
|
|
11937
12274
|
}
|
|
11938
|
-
|
|
11939
|
-
|
|
12275
|
+
async getPlatformList() {
|
|
12276
|
+
const res = await this._httpClient.get('/platforms');
|
|
12277
|
+
return res.data;
|
|
11940
12278
|
}
|
|
11941
|
-
async
|
|
11942
|
-
const
|
|
11943
|
-
|
|
11944
|
-
if ('GET' !== method && 'POST' !== method) throw new LYError(`Method ${method} not allowed`);
|
|
11945
|
-
const response = await super._request({
|
|
11946
|
-
method,
|
|
11947
|
-
data,
|
|
11948
|
-
...rest,
|
|
11949
|
-
url
|
|
11950
|
-
});
|
|
11951
|
-
if (void 0 !== response.status) return response;
|
|
11952
|
-
const result = response;
|
|
11953
|
-
if ('not_exists' === result.code) return result;
|
|
11954
|
-
if ('success' !== result.code) {
|
|
11955
|
-
url = `${this.baseUrl}/${url}`;
|
|
11956
|
-
throw new LYAppHttpError(result.message, url, method, new Error(), result.code);
|
|
11957
|
-
}
|
|
11958
|
-
return result;
|
|
12279
|
+
async getOrderStatus(id) {
|
|
12280
|
+
const res = await this._httpClient.get(`/orders/status/${id}`);
|
|
12281
|
+
return res.data;
|
|
11959
12282
|
}
|
|
11960
|
-
async
|
|
11961
|
-
|
|
11962
|
-
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
|
|
11967
|
-
|
|
11968
|
-
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
|
|
11972
|
-
|
|
11973
|
-
const
|
|
11974
|
-
|
|
11975
|
-
|
|
11976
|
-
|
|
11977
|
-
|
|
11978
|
-
|
|
12283
|
+
async getOrders(params) {
|
|
12284
|
+
return this._httpClient.get('/orders', params);
|
|
12285
|
+
}
|
|
12286
|
+
async purchases(params) {
|
|
12287
|
+
const res = await this._httpClient.post('/purchases', params);
|
|
12288
|
+
return res.data;
|
|
12289
|
+
}
|
|
12290
|
+
async webhooks() {}
|
|
12291
|
+
async subscription(param) {
|
|
12292
|
+
const res = await this._httpClient.post("/subscriptions", param);
|
|
12293
|
+
return res.data;
|
|
12294
|
+
}
|
|
12295
|
+
async getSubscriptionByApp(param) {
|
|
12296
|
+
const res = await this._httpClient.get("/subscriptions/my", param);
|
|
12297
|
+
return res.data;
|
|
12298
|
+
}
|
|
12299
|
+
async cancelSubscription(param) {
|
|
12300
|
+
const res = await this._httpClient.post("/subscriptions/cancel", param);
|
|
12301
|
+
return res.data;
|
|
12302
|
+
}
|
|
12303
|
+
async releaseSchedule(id, param) {
|
|
12304
|
+
const res = await this._httpClient.post(`/subscriptions/schedule/delete/${id}`, param);
|
|
12305
|
+
return res.data;
|
|
12306
|
+
}
|
|
12307
|
+
async previewPurchase(id, price_id) {
|
|
12308
|
+
const res = await this._httpClient.get(`/subscriptions/preview/${id}`, {
|
|
12309
|
+
price_id
|
|
11979
12310
|
});
|
|
11980
|
-
return
|
|
12311
|
+
return res.data;
|
|
11981
12312
|
}
|
|
11982
|
-
async
|
|
11983
|
-
const
|
|
11984
|
-
|
|
11985
|
-
|
|
11986
|
-
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
|
|
11995
|
-
|
|
11996
|
-
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
|
|
12000
|
-
|
|
12001
|
-
|
|
12002
|
-
|
|
12003
|
-
|
|
12004
|
-
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
|
|
12009
|
-
|
|
12010
|
-
|
|
12011
|
-
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
|
|
12016
|
-
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12023
|
-
|
|
12313
|
+
async changeSubscription(id, param) {
|
|
12314
|
+
const res = await this._httpClient.post(`/subscriptions/${id}/patch`, param);
|
|
12315
|
+
return res.data;
|
|
12316
|
+
}
|
|
12317
|
+
}
|
|
12318
|
+
function order_ts_decorate(decorators, target, key, desc) {
|
|
12319
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12320
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
12321
|
+
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;
|
|
12322
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12323
|
+
}
|
|
12324
|
+
function order_ts_metadata(k, v) {
|
|
12325
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
12326
|
+
}
|
|
12327
|
+
class LYOrder extends LYObject {
|
|
12328
|
+
constructor(userApi){
|
|
12329
|
+
super(), this._status = 'pending', this._pollTimer = null, this._pollInterval = 2000, this._isPolling = false, this._data = null;
|
|
12330
|
+
this._userApi = userApi;
|
|
12331
|
+
}
|
|
12332
|
+
get id() {
|
|
12333
|
+
return this._data?.order_id;
|
|
12334
|
+
}
|
|
12335
|
+
get no() {
|
|
12336
|
+
return this._data?.order_no;
|
|
12337
|
+
}
|
|
12338
|
+
get productName() {
|
|
12339
|
+
return this._data?.product_name;
|
|
12340
|
+
}
|
|
12341
|
+
get priceName() {
|
|
12342
|
+
return this._data?.price_name;
|
|
12343
|
+
}
|
|
12344
|
+
get actualAmount() {
|
|
12345
|
+
return this._data?.actual_amount;
|
|
12346
|
+
}
|
|
12347
|
+
get currency() {
|
|
12348
|
+
return this._data.currency;
|
|
12349
|
+
}
|
|
12350
|
+
get platformName() {
|
|
12351
|
+
return this._data?.platform_name;
|
|
12352
|
+
}
|
|
12353
|
+
get paymentUrl() {
|
|
12354
|
+
return this._data?.payment_url;
|
|
12355
|
+
}
|
|
12356
|
+
get qrCodeUrl() {
|
|
12357
|
+
return this._data?.qr_code_url;
|
|
12358
|
+
}
|
|
12359
|
+
get paymentForm() {
|
|
12360
|
+
return this._data?.payment_form || null;
|
|
12361
|
+
}
|
|
12362
|
+
get expiresAt() {
|
|
12363
|
+
return this._data?.expires_at;
|
|
12364
|
+
}
|
|
12365
|
+
get status() {
|
|
12366
|
+
return this._status;
|
|
12367
|
+
}
|
|
12368
|
+
_updateStatus(newStatus) {
|
|
12369
|
+
if (this._status !== newStatus) {
|
|
12370
|
+
this._status = newStatus;
|
|
12371
|
+
this.emit('status', newStatus, this.id);
|
|
12024
12372
|
}
|
|
12025
|
-
return {
|
|
12026
|
-
id: fileId,
|
|
12027
|
-
state: currentState
|
|
12028
|
-
};
|
|
12029
12373
|
}
|
|
12030
|
-
async
|
|
12031
|
-
config?.chunkSize;
|
|
12032
|
-
const resumeFromByte = config?.resumeFromByte || 0;
|
|
12033
|
-
const url = `${this.baseUrl}/${this._getUrl(`/file/${fileId}`)}`;
|
|
12034
|
-
const headers = {
|
|
12035
|
-
Accept: '*/*',
|
|
12036
|
-
...this._get_headers(),
|
|
12037
|
-
...config?.headers
|
|
12038
|
-
};
|
|
12039
|
-
const blob = new Blob();
|
|
12040
|
-
let reader;
|
|
12374
|
+
async pay(params) {
|
|
12041
12375
|
try {
|
|
12042
|
-
const
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
Range: `bytes=${resumeFromByte}-`
|
|
12048
|
-
}
|
|
12049
|
-
},
|
|
12050
|
-
credentials: 'include'
|
|
12051
|
-
});
|
|
12052
|
-
if (!downloadResponse.ok) throw new Error(`Download request failed: ${downloadResponse.status} ${downloadResponse.statusText}`);
|
|
12053
|
-
reader = downloadResponse.body?.getReader();
|
|
12054
|
-
if (!reader) throw new Error('Response body is not readable');
|
|
12055
|
-
const contentLength = parseInt(downloadResponse.headers.get('content-length') || '0');
|
|
12056
|
-
const contentType = downloadResponse.headers.get('content-type') || 'application/octet-stream';
|
|
12057
|
-
const contentRange = downloadResponse.headers.get('content-range');
|
|
12058
|
-
const contentDisposition = downloadResponse.headers.get('content-disposition');
|
|
12059
|
-
let totalSize = contentLength;
|
|
12060
|
-
if (contentRange) {
|
|
12061
|
-
const match = contentRange.match(/bytes \d+-\d+\/(\d+)/);
|
|
12062
|
-
if (match) totalSize = parseInt(match[1]);
|
|
12063
|
-
}
|
|
12064
|
-
let finalFileName = fileName;
|
|
12065
|
-
if (!finalFileName && contentDisposition) {
|
|
12066
|
-
const utf8Match = contentDisposition.match(/filename\*=UTF-8''([^;]+)/);
|
|
12067
|
-
if (utf8Match) finalFileName = decodeURIComponent(utf8Match[1]);
|
|
12068
|
-
else {
|
|
12069
|
-
const filenameMatch = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
|
|
12070
|
-
if (filenameMatch && filenameMatch[1]) finalFileName = filenameMatch[1].replace(/['"]/g, '');
|
|
12071
|
-
}
|
|
12072
|
-
}
|
|
12073
|
-
const chunks = [];
|
|
12074
|
-
let totalLoaded = 0;
|
|
12075
|
-
let progress = 0;
|
|
12076
|
-
let blob;
|
|
12077
|
-
while(true){
|
|
12078
|
-
const { done, value } = await reader.read();
|
|
12079
|
-
if (done) break;
|
|
12080
|
-
chunks.push(value);
|
|
12081
|
-
totalLoaded += value.length;
|
|
12082
|
-
const newProgress = totalSize > 0 ? totalLoaded / totalSize * 100 : 0;
|
|
12083
|
-
if (newProgress !== progress) {
|
|
12084
|
-
progress = newProgress;
|
|
12085
|
-
config?.onProgress?.(progress);
|
|
12086
|
-
}
|
|
12087
|
-
}
|
|
12088
|
-
blob = new Blob(chunks, {
|
|
12089
|
-
type: contentType
|
|
12090
|
-
});
|
|
12091
|
-
return {
|
|
12092
|
-
blob,
|
|
12093
|
-
fileName: finalFileName,
|
|
12094
|
-
contentType,
|
|
12095
|
-
totalSize: totalSize || blob.size
|
|
12096
|
-
};
|
|
12376
|
+
const result = await this._userApi.purchases(params);
|
|
12377
|
+
this._data = result;
|
|
12378
|
+
this._updateStatus('pending');
|
|
12379
|
+
this._startPolling();
|
|
12380
|
+
return this._data;
|
|
12097
12381
|
} catch (error) {
|
|
12098
|
-
|
|
12099
|
-
this.emit('download_failed', {
|
|
12100
|
-
error,
|
|
12101
|
-
fileId,
|
|
12102
|
-
fileName,
|
|
12103
|
-
blob
|
|
12104
|
-
});
|
|
12382
|
+
this._updateStatus('failed');
|
|
12105
12383
|
throw error;
|
|
12106
12384
|
}
|
|
12107
12385
|
}
|
|
12108
|
-
|
|
12109
|
-
|
|
12110
|
-
|
|
12386
|
+
_startPolling() {
|
|
12387
|
+
if (this._isPolling) return;
|
|
12388
|
+
this._isPolling = true;
|
|
12389
|
+
this._doPoll();
|
|
12111
12390
|
}
|
|
12112
|
-
async
|
|
12113
|
-
const { data, delimiter = '\n', headers: customHeaders } = config || {};
|
|
12114
|
-
const fullUrl = `${this.baseUrl}/${this._getUrl(url)}`;
|
|
12115
|
-
const headers = {
|
|
12116
|
-
...this._get_headers(),
|
|
12117
|
-
...customHeaders,
|
|
12118
|
-
Accept: 'text/event-stream',
|
|
12119
|
-
'Content-Type': 'application/json'
|
|
12120
|
-
};
|
|
12121
|
-
const abortController = new AbortController();
|
|
12122
|
-
if (config?.signal) config.signal.addEventListener('abort', ()=>{
|
|
12123
|
-
abortController.abort();
|
|
12124
|
-
});
|
|
12125
|
-
const requestOptions = {
|
|
12126
|
-
method: 'POST',
|
|
12127
|
-
headers,
|
|
12128
|
-
signal: abortController.signal,
|
|
12129
|
-
body: JSON.stringify(data)
|
|
12130
|
-
};
|
|
12391
|
+
async _doPoll() {
|
|
12131
12392
|
try {
|
|
12132
|
-
const
|
|
12133
|
-
if (
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
try {
|
|
12138
|
-
while(true){
|
|
12139
|
-
const { value, done } = await reader.read();
|
|
12140
|
-
if (done) break;
|
|
12141
|
-
const chunk = decoder.decode(value, {
|
|
12142
|
-
stream: true
|
|
12143
|
-
});
|
|
12144
|
-
buffer += chunk;
|
|
12145
|
-
const parts = buffer.split(delimiter);
|
|
12146
|
-
buffer = parts.pop() ?? '';
|
|
12147
|
-
for (const part of parts){
|
|
12148
|
-
const trimmed = part.trim();
|
|
12149
|
-
if (0 !== trimmed.length) yield this.parseChunk(trimmed);
|
|
12150
|
-
}
|
|
12151
|
-
}
|
|
12152
|
-
if (buffer.trim()) yield this.parseChunk(buffer);
|
|
12153
|
-
} finally{
|
|
12154
|
-
reader.releaseLock();
|
|
12393
|
+
const orderStatus = await this._userApi.getOrderStatus(this.id);
|
|
12394
|
+
if ('pending' !== orderStatus.status) {
|
|
12395
|
+
this._stopPolling();
|
|
12396
|
+
this._updateStatus(orderStatus.status);
|
|
12397
|
+
return;
|
|
12155
12398
|
}
|
|
12399
|
+
this._pollTimer = setTimeout(()=>this._doPoll(), this._pollInterval);
|
|
12156
12400
|
} catch (error) {
|
|
12157
|
-
|
|
12158
|
-
|
|
12401
|
+
this.logger.error(`查询订单 ${this.id} 状态失败:`, error);
|
|
12402
|
+
this._stopPolling();
|
|
12403
|
+
this._updateStatus('failed');
|
|
12159
12404
|
}
|
|
12160
12405
|
}
|
|
12161
|
-
|
|
12162
|
-
|
|
12406
|
+
_stopPolling() {
|
|
12407
|
+
this._isPolling = false;
|
|
12408
|
+
if (this._pollTimer) {
|
|
12409
|
+
clearTimeout(this._pollTimer);
|
|
12410
|
+
this._pollTimer = null;
|
|
12411
|
+
}
|
|
12412
|
+
}
|
|
12413
|
+
destroy() {
|
|
12414
|
+
this._stopPolling();
|
|
12415
|
+
this.removeAllListeners();
|
|
12416
|
+
}
|
|
12417
|
+
async refresh() {
|
|
12163
12418
|
try {
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
return
|
|
12419
|
+
const orderStatus = await this._userApi.getOrderStatus(this.id);
|
|
12420
|
+
this._updateStatus(orderStatus.status);
|
|
12421
|
+
return this._status;
|
|
12422
|
+
} catch (error) {
|
|
12423
|
+
this.logger.error(`刷新订单 ${this.id} 状态失败:`, error);
|
|
12424
|
+
return this._status;
|
|
12167
12425
|
}
|
|
12168
12426
|
}
|
|
12169
12427
|
}
|
|
12170
|
-
|
|
12171
|
-
register('
|
|
12172
|
-
|
|
12173
|
-
|
|
12174
|
-
|
|
12175
|
-
"undefined" == typeof IHeaderProvider ? Object : IHeaderProvider
|
|
12428
|
+
LYOrder = order_ts_decorate([
|
|
12429
|
+
register('LYOrder'),
|
|
12430
|
+
order_ts_metadata("design:type", Function),
|
|
12431
|
+
order_ts_metadata("design:paramtypes", [
|
|
12432
|
+
void 0 === api_user_LYUserApi ? Object : api_user_LYUserApi
|
|
12176
12433
|
])
|
|
12177
|
-
],
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12434
|
+
], LYOrder);
|
|
12435
|
+
function bill_app_ts_decorate(decorators, target, key, desc) {
|
|
12436
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12437
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
12438
|
+
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;
|
|
12439
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12440
|
+
}
|
|
12441
|
+
function bill_app_ts_metadata(k, v) {
|
|
12442
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
12443
|
+
}
|
|
12444
|
+
class LYBillApp extends LYBaseOrganizationApp {
|
|
12445
|
+
constructor(name1, version, description){
|
|
12446
|
+
super(name1, version, description);
|
|
12447
|
+
LYBillApp._instance = this;
|
|
12448
|
+
this._userApi = new api_user_LYUserApi(this._httpClient);
|
|
12449
|
+
this._adminApi = new LYAdminApi(this._httpClient);
|
|
12185
12450
|
}
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
return
|
|
12451
|
+
get userApi() {
|
|
12452
|
+
return this._userApi;
|
|
12453
|
+
}
|
|
12454
|
+
get adminApi() {
|
|
12455
|
+
return this._adminApi;
|
|
12191
12456
|
}
|
|
12457
|
+
static get instance() {
|
|
12458
|
+
if (!LYBillApp._instance) throw new Error('LYBillApp not initialized');
|
|
12459
|
+
return LYBillApp._instance;
|
|
12460
|
+
}
|
|
12461
|
+
createOrder() {
|
|
12462
|
+
const order = new LYOrder(this._userApi);
|
|
12463
|
+
return order;
|
|
12464
|
+
}
|
|
12465
|
+
changeSubscription(id, param) {}
|
|
12192
12466
|
}
|
|
12193
|
-
|
|
12194
|
-
register('
|
|
12195
|
-
|
|
12467
|
+
LYBillApp = bill_app_ts_decorate([
|
|
12468
|
+
register('LYBillApp'),
|
|
12469
|
+
bill_app_ts_metadata("design:type", Function),
|
|
12470
|
+
bill_app_ts_metadata("design:paramtypes", [
|
|
12471
|
+
String,
|
|
12472
|
+
String,
|
|
12473
|
+
String
|
|
12474
|
+
])
|
|
12475
|
+
], LYBillApp);
|
|
12476
|
+
function src_app_ts_decorate(decorators, target, key, desc) {
|
|
12477
|
+
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12478
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
12479
|
+
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;
|
|
12480
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12481
|
+
}
|
|
12482
|
+
class LYApp extends LYBaseOrganizationApp {
|
|
12483
|
+
}
|
|
12484
|
+
LYApp = src_app_ts_decorate([
|
|
12485
|
+
register('LYApp')
|
|
12486
|
+
], LYApp);
|
|
12196
12487
|
var __webpack_exports__FRAMEWORK_NAME = "uci";
|
|
12197
|
-
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 };
|
|
12488
|
+
export { BILL_APP_NAME, LANG_KEY, LYApp, http_LYAppHttpClient as LYAppHttpClient, LYAppPermission, base_LYBaseApp as LYBaseApp, LYBillApp, LYCloudStorage, LYConfig, LYCrypto, LYCryptoError, LYDefaultLogFormatter, LYDirectAuthorizer, LYEnv, LYError, LYGatewayAuthorizer, LYIndexedDBLogStorage, i18n_LYLangEnum as LYLangEnum, LYLocalStorage, logger_LYLogLevel as LYLogLevel, LYLogger, LYObject, LYObservable, LYOrder, 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 };
|
|
12198
12489
|
|
|
12199
12490
|
//# sourceMappingURL=index.js.map
|