@onyx-p/imlib-web 2.3.7 → 2.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.js +50 -53
- package/index.umd.js +50 -53
- package/package.json +1 -1
- package/types/types.d.ts +12 -7
package/index.esm.js
CHANGED
@@ -7648,7 +7648,7 @@ function requireCryptoJs () {
|
|
7648
7648
|
}
|
7649
7649
|
|
7650
7650
|
var cryptoJsExports = requireCryptoJs();
|
7651
|
-
var CryptoJS
|
7651
|
+
var CryptoJS = /*@__PURE__*/getDefaultExportFromCjs(cryptoJsExports);
|
7652
7652
|
|
7653
7653
|
function getType(value) {
|
7654
7654
|
return Object.prototype.toString.call(value).slice(8, -1);
|
@@ -7735,8 +7735,8 @@ const throttle = (fn, delay = 200) => {
|
|
7735
7735
|
};
|
7736
7736
|
};
|
7737
7737
|
|
7738
|
-
const AesKey = CryptoJS
|
7739
|
-
const AesIv = CryptoJS
|
7738
|
+
const AesKey = CryptoJS.enc.Utf8.parse('skdjhfgc9829kslf');
|
7739
|
+
const AesIv = CryptoJS.enc.Utf8.parse('qwdkshjf9838jsdf');
|
7740
7740
|
const isElectron = () => {
|
7741
7741
|
return typeof process !== 'undefined' && typeof process.versions !== 'undefined' && !!process.versions.electron;
|
7742
7742
|
};
|
@@ -7795,12 +7795,12 @@ const SecureStorageService = {
|
|
7795
7795
|
return null;
|
7796
7796
|
}
|
7797
7797
|
if (isDef(value)) {
|
7798
|
-
const encryptedHexStr = CryptoJS
|
7799
|
-
const srcs = CryptoJS
|
7800
|
-
const decrypt = CryptoJS
|
7798
|
+
const encryptedHexStr = CryptoJS.enc.Hex.parse(value);
|
7799
|
+
const srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
|
7800
|
+
const decrypt = CryptoJS.AES.decrypt(srcs, AesKey, {
|
7801
7801
|
iv: AesIv
|
7802
7802
|
});
|
7803
|
-
value = decrypt.toString(CryptoJS
|
7803
|
+
value = decrypt.toString(CryptoJS.enc.Utf8);
|
7804
7804
|
}
|
7805
7805
|
if (!isDef(value)) {
|
7806
7806
|
return value;
|
@@ -7817,7 +7817,7 @@ const SecureStorageService = {
|
|
7817
7817
|
this.remove(key);
|
7818
7818
|
return;
|
7819
7819
|
}
|
7820
|
-
const encryptedData = CryptoJS
|
7820
|
+
const encryptedData = CryptoJS.AES.encrypt(JSON.stringify(value), AesKey, {
|
7821
7821
|
iv: AesIv
|
7822
7822
|
});
|
7823
7823
|
const encrytedStr = encryptedData.ciphertext.toString();
|
@@ -19554,18 +19554,18 @@ const aes256Encrypt = (message, secretKey) => {
|
|
19554
19554
|
if (!notEmptyString(message)) {
|
19555
19555
|
return '';
|
19556
19556
|
}
|
19557
|
-
const encryptedData = CryptoJS
|
19558
|
-
iv: isDef(secretKey.iv) ? CryptoJS
|
19557
|
+
const encryptedData = CryptoJS.AES.encrypt(message, CryptoJS.enc.Utf8.parse(secretKey.key), {
|
19558
|
+
iv: isDef(secretKey.iv) ? CryptoJS.enc.Utf8.parse(secretKey.iv) : undefined
|
19559
19559
|
});
|
19560
19560
|
return Array.from(wordToUInt8Array(encryptedData.ciphertext.words)).map(byte => byte.toString(16).padStart(2, '0')).join('');
|
19561
19561
|
};
|
19562
19562
|
const aes256Decrypt = (cipherHex, secretKey) => {
|
19563
19563
|
const cipherData = new Uint8Array(cipherHex.match(/.{1,2}/g)?.map(byte => parseInt(byte, 16)) || []);
|
19564
19564
|
const srcs = window.btoa(String.fromCharCode(...cipherData));
|
19565
|
-
const decrypt = CryptoJS
|
19566
|
-
iv: isDef(secretKey.iv) ? CryptoJS
|
19565
|
+
const decrypt = CryptoJS.AES.decrypt(srcs, CryptoJS.enc.Utf8.parse(secretKey.key), {
|
19566
|
+
iv: isDef(secretKey.iv) ? CryptoJS.enc.Utf8.parse(secretKey.iv) : undefined
|
19567
19567
|
});
|
19568
|
-
return decrypt.toString(CryptoJS
|
19568
|
+
return decrypt.toString(CryptoJS.enc.Utf8);
|
19569
19569
|
};
|
19570
19570
|
const wordToUInt8Array = wordArray => {
|
19571
19571
|
const array = [];
|
@@ -20744,14 +20744,14 @@ class MessageCache {
|
|
20744
20744
|
}
|
20745
20745
|
generateEncryptKey(appKey, userId) {
|
20746
20746
|
const saltedInput = `${this.SALT_PREFIX}${appKey}_${userId}${this.SALT_SUFFIX}`;
|
20747
|
-
const keyMaterial = CryptoJS
|
20747
|
+
const keyMaterial = CryptoJS.SHA256(saltedInput).toString();
|
20748
20748
|
const iv = keyMaterial.substring(0, 16);
|
20749
20749
|
const key = keyMaterial.substring(16, 48);
|
20750
|
-
const additionalSalt = CryptoJS
|
20751
|
-
const finalKey = CryptoJS
|
20750
|
+
const additionalSalt = CryptoJS.SHA256(`${iv}:${this.SALT_PREFIX}:${userId}:${appKey}`).toString().substring(0, 8);
|
20751
|
+
const finalKey = CryptoJS.PBKDF2(key, additionalSalt, {
|
20752
20752
|
keySize: 256 / 32,
|
20753
20753
|
iterations: 1000,
|
20754
|
-
hasher: CryptoJS
|
20754
|
+
hasher: CryptoJS.algo.SHA256
|
20755
20755
|
}).toString();
|
20756
20756
|
this.encryptKey = {
|
20757
20757
|
key: finalKey.substring(0, 32),
|
@@ -28942,34 +28942,40 @@ async function createSendFunction(fileType, conversation, msgBody, hooks, sendOp
|
|
28942
28942
|
}
|
28943
28943
|
message1.content.user = msgBody.user;
|
28944
28944
|
message1.content.extra = msgBody.extra;
|
28945
|
-
const
|
28946
|
-
|
28947
|
-
files
|
28948
|
-
|
28949
|
-
|
28950
|
-
|
28951
|
-
|
28952
|
-
|
28953
|
-
|
28954
|
-
|
28955
|
-
|
28956
|
-
|
28957
|
-
|
28958
|
-
|
28959
|
-
|
28960
|
-
|
28961
|
-
|
28962
|
-
|
28963
|
-
|
28964
|
-
|
28965
|
-
|
28945
|
+
const uploader = imConfig.getUploader();
|
28946
|
+
try {
|
28947
|
+
const prepareResult = await uploader.prepare(files);
|
28948
|
+
return internal_sendMessage(conversation, message1, sendOptions, {
|
28949
|
+
uploadItems: prepareResult,
|
28950
|
+
task: (message2, uploadItems) => {
|
28951
|
+
return new Promise(resolve => {
|
28952
|
+
uploader.upload(uploadItems, {
|
28953
|
+
onProgress: progress => hooks?.onProgress?.(progress),
|
28954
|
+
onError: () => {
|
28955
|
+
resolve({
|
28956
|
+
finished: false,
|
28957
|
+
message: message2
|
28958
|
+
});
|
28959
|
+
},
|
28960
|
+
onCompleted: result => {
|
28961
|
+
message2.content = mediaMessageCreator.updateMessageRemoteUrlProperty(message2.content, result);
|
28962
|
+
resolve({
|
28963
|
+
finished: true,
|
28964
|
+
message: hooks?.onComplete?.(result) ?? message2
|
28965
|
+
});
|
28966
|
+
}
|
28967
|
+
});
|
28966
28968
|
});
|
28967
|
-
}
|
28968
|
-
}
|
28969
|
-
})
|
28969
|
+
}
|
28970
|
+
});
|
28971
|
+
} catch (error) {
|
28972
|
+
return {
|
28973
|
+
code: ErrorCode.UPLOAD_FILE_FAILED
|
28974
|
+
};
|
28975
|
+
}
|
28970
28976
|
}
|
28971
28977
|
async function internal_sendMessage(conversation, message, options, uploadOptions) {
|
28972
|
-
const checkResult = await beforeSend(conversation, message, options, uploadOptions);
|
28978
|
+
const checkResult = await beforeSend(conversation, message, options, uploadOptions?.uploadItems);
|
28973
28979
|
if (checkResult.code !== ErrorCode.SUCCESS || !checkResult.message || !checkResult.sentArgs) {
|
28974
28980
|
return {
|
28975
28981
|
code: checkResult.code
|
@@ -28984,7 +28990,7 @@ async function internal_sendMessage(conversation, message, options, uploadOption
|
|
28984
28990
|
sentArgs
|
28985
28991
|
} = checkResult;
|
28986
28992
|
if (isDef(uploadOptions)) {
|
28987
|
-
const uploadResult = await uploadOptions.task(sentMessage, uploadOptions.
|
28993
|
+
const uploadResult = await uploadOptions.task(sentMessage, uploadOptions.uploadItems);
|
28988
28994
|
sentMessage = uploadResult.message;
|
28989
28995
|
if (!uploadResult.finished) {
|
28990
28996
|
const receivedMessage = transSentAttrs2IReceivedMessage(checkResult.message, checkResult.sentArgs, SentStatus.FAILED);
|
@@ -29116,15 +29122,6 @@ async function saveSentMessage(receivedMessage, options) {
|
|
29116
29122
|
logger.error('saveSentMessage -> ', error);
|
29117
29123
|
}
|
29118
29124
|
}
|
29119
|
-
function generateEncryptKey() {
|
29120
|
-
const data = new Uint8Array(16);
|
29121
|
-
for (let i = 0; i < 16; i++) {
|
29122
|
-
data[i] = 65 + Math.floor(Math.random() * 26);
|
29123
|
-
}
|
29124
|
-
const key = String.fromCharCode(...data);
|
29125
|
-
const md5Hash = CryptoJS.MD5(key).toString();
|
29126
|
-
return md5Hash;
|
29127
|
-
}
|
29128
29125
|
|
29129
29126
|
class IMClient extends EventEmitter {
|
29130
29127
|
options;
|
@@ -30342,7 +30339,7 @@ const login = config => {
|
|
30342
30339
|
return webSocketServer.request(0x30011011, {
|
30343
30340
|
langCode: config.langCode,
|
30344
30341
|
phoneNum: config.phone,
|
30345
|
-
password: CryptoJS
|
30342
|
+
password: CryptoJS.SHA256(config.password).toString(),
|
30346
30343
|
deviceType: 7,
|
30347
30344
|
imei: '59bc678b-fe6d-4e67-87c6-b0692205134b',
|
30348
30345
|
brand: 'Chrome',
|
package/index.umd.js
CHANGED
@@ -7654,7 +7654,7 @@
|
|
7654
7654
|
}
|
7655
7655
|
|
7656
7656
|
var cryptoJsExports = requireCryptoJs();
|
7657
|
-
var CryptoJS
|
7657
|
+
var CryptoJS = /*@__PURE__*/getDefaultExportFromCjs(cryptoJsExports);
|
7658
7658
|
|
7659
7659
|
function getType(value) {
|
7660
7660
|
return Object.prototype.toString.call(value).slice(8, -1);
|
@@ -7741,8 +7741,8 @@
|
|
7741
7741
|
};
|
7742
7742
|
};
|
7743
7743
|
|
7744
|
-
const AesKey = CryptoJS
|
7745
|
-
const AesIv = CryptoJS
|
7744
|
+
const AesKey = CryptoJS.enc.Utf8.parse('skdjhfgc9829kslf');
|
7745
|
+
const AesIv = CryptoJS.enc.Utf8.parse('qwdkshjf9838jsdf');
|
7746
7746
|
const isElectron = () => {
|
7747
7747
|
return typeof process !== 'undefined' && typeof process.versions !== 'undefined' && !!process.versions.electron;
|
7748
7748
|
};
|
@@ -7801,12 +7801,12 @@
|
|
7801
7801
|
return null;
|
7802
7802
|
}
|
7803
7803
|
if (isDef(value)) {
|
7804
|
-
const encryptedHexStr = CryptoJS
|
7805
|
-
const srcs = CryptoJS
|
7806
|
-
const decrypt = CryptoJS
|
7804
|
+
const encryptedHexStr = CryptoJS.enc.Hex.parse(value);
|
7805
|
+
const srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
|
7806
|
+
const decrypt = CryptoJS.AES.decrypt(srcs, AesKey, {
|
7807
7807
|
iv: AesIv
|
7808
7808
|
});
|
7809
|
-
value = decrypt.toString(CryptoJS
|
7809
|
+
value = decrypt.toString(CryptoJS.enc.Utf8);
|
7810
7810
|
}
|
7811
7811
|
if (!isDef(value)) {
|
7812
7812
|
return value;
|
@@ -7823,7 +7823,7 @@
|
|
7823
7823
|
this.remove(key);
|
7824
7824
|
return;
|
7825
7825
|
}
|
7826
|
-
const encryptedData = CryptoJS
|
7826
|
+
const encryptedData = CryptoJS.AES.encrypt(JSON.stringify(value), AesKey, {
|
7827
7827
|
iv: AesIv
|
7828
7828
|
});
|
7829
7829
|
const encrytedStr = encryptedData.ciphertext.toString();
|
@@ -19560,18 +19560,18 @@
|
|
19560
19560
|
if (!notEmptyString(message)) {
|
19561
19561
|
return '';
|
19562
19562
|
}
|
19563
|
-
const encryptedData = CryptoJS
|
19564
|
-
iv: isDef(secretKey.iv) ? CryptoJS
|
19563
|
+
const encryptedData = CryptoJS.AES.encrypt(message, CryptoJS.enc.Utf8.parse(secretKey.key), {
|
19564
|
+
iv: isDef(secretKey.iv) ? CryptoJS.enc.Utf8.parse(secretKey.iv) : undefined
|
19565
19565
|
});
|
19566
19566
|
return Array.from(wordToUInt8Array(encryptedData.ciphertext.words)).map(byte => byte.toString(16).padStart(2, '0')).join('');
|
19567
19567
|
};
|
19568
19568
|
const aes256Decrypt = (cipherHex, secretKey) => {
|
19569
19569
|
const cipherData = new Uint8Array(cipherHex.match(/.{1,2}/g)?.map(byte => parseInt(byte, 16)) || []);
|
19570
19570
|
const srcs = window.btoa(String.fromCharCode(...cipherData));
|
19571
|
-
const decrypt = CryptoJS
|
19572
|
-
iv: isDef(secretKey.iv) ? CryptoJS
|
19571
|
+
const decrypt = CryptoJS.AES.decrypt(srcs, CryptoJS.enc.Utf8.parse(secretKey.key), {
|
19572
|
+
iv: isDef(secretKey.iv) ? CryptoJS.enc.Utf8.parse(secretKey.iv) : undefined
|
19573
19573
|
});
|
19574
|
-
return decrypt.toString(CryptoJS
|
19574
|
+
return decrypt.toString(CryptoJS.enc.Utf8);
|
19575
19575
|
};
|
19576
19576
|
const wordToUInt8Array = wordArray => {
|
19577
19577
|
const array = [];
|
@@ -20750,14 +20750,14 @@
|
|
20750
20750
|
}
|
20751
20751
|
generateEncryptKey(appKey, userId) {
|
20752
20752
|
const saltedInput = `${this.SALT_PREFIX}${appKey}_${userId}${this.SALT_SUFFIX}`;
|
20753
|
-
const keyMaterial = CryptoJS
|
20753
|
+
const keyMaterial = CryptoJS.SHA256(saltedInput).toString();
|
20754
20754
|
const iv = keyMaterial.substring(0, 16);
|
20755
20755
|
const key = keyMaterial.substring(16, 48);
|
20756
|
-
const additionalSalt = CryptoJS
|
20757
|
-
const finalKey = CryptoJS
|
20756
|
+
const additionalSalt = CryptoJS.SHA256(`${iv}:${this.SALT_PREFIX}:${userId}:${appKey}`).toString().substring(0, 8);
|
20757
|
+
const finalKey = CryptoJS.PBKDF2(key, additionalSalt, {
|
20758
20758
|
keySize: 256 / 32,
|
20759
20759
|
iterations: 1000,
|
20760
|
-
hasher: CryptoJS
|
20760
|
+
hasher: CryptoJS.algo.SHA256
|
20761
20761
|
}).toString();
|
20762
20762
|
this.encryptKey = {
|
20763
20763
|
key: finalKey.substring(0, 32),
|
@@ -28948,34 +28948,40 @@
|
|
28948
28948
|
}
|
28949
28949
|
message1.content.user = msgBody.user;
|
28950
28950
|
message1.content.extra = msgBody.extra;
|
28951
|
-
const
|
28952
|
-
|
28953
|
-
files
|
28954
|
-
|
28955
|
-
|
28956
|
-
|
28957
|
-
|
28958
|
-
|
28959
|
-
|
28960
|
-
|
28961
|
-
|
28962
|
-
|
28963
|
-
|
28964
|
-
|
28965
|
-
|
28966
|
-
|
28967
|
-
|
28968
|
-
|
28969
|
-
|
28970
|
-
|
28971
|
-
|
28951
|
+
const uploader = imConfig.getUploader();
|
28952
|
+
try {
|
28953
|
+
const prepareResult = await uploader.prepare(files);
|
28954
|
+
return internal_sendMessage(conversation, message1, sendOptions, {
|
28955
|
+
uploadItems: prepareResult,
|
28956
|
+
task: (message2, uploadItems) => {
|
28957
|
+
return new Promise(resolve => {
|
28958
|
+
uploader.upload(uploadItems, {
|
28959
|
+
onProgress: progress => hooks?.onProgress?.(progress),
|
28960
|
+
onError: () => {
|
28961
|
+
resolve({
|
28962
|
+
finished: false,
|
28963
|
+
message: message2
|
28964
|
+
});
|
28965
|
+
},
|
28966
|
+
onCompleted: result => {
|
28967
|
+
message2.content = mediaMessageCreator.updateMessageRemoteUrlProperty(message2.content, result);
|
28968
|
+
resolve({
|
28969
|
+
finished: true,
|
28970
|
+
message: hooks?.onComplete?.(result) ?? message2
|
28971
|
+
});
|
28972
|
+
}
|
28973
|
+
});
|
28972
28974
|
});
|
28973
|
-
}
|
28974
|
-
}
|
28975
|
-
})
|
28975
|
+
}
|
28976
|
+
});
|
28977
|
+
} catch (error) {
|
28978
|
+
return {
|
28979
|
+
code: exports.ErrorCode.UPLOAD_FILE_FAILED
|
28980
|
+
};
|
28981
|
+
}
|
28976
28982
|
}
|
28977
28983
|
async function internal_sendMessage(conversation, message, options, uploadOptions) {
|
28978
|
-
const checkResult = await beforeSend(conversation, message, options, uploadOptions);
|
28984
|
+
const checkResult = await beforeSend(conversation, message, options, uploadOptions?.uploadItems);
|
28979
28985
|
if (checkResult.code !== exports.ErrorCode.SUCCESS || !checkResult.message || !checkResult.sentArgs) {
|
28980
28986
|
return {
|
28981
28987
|
code: checkResult.code
|
@@ -28990,7 +28996,7 @@
|
|
28990
28996
|
sentArgs
|
28991
28997
|
} = checkResult;
|
28992
28998
|
if (isDef(uploadOptions)) {
|
28993
|
-
const uploadResult = await uploadOptions.task(sentMessage, uploadOptions.
|
28999
|
+
const uploadResult = await uploadOptions.task(sentMessage, uploadOptions.uploadItems);
|
28994
29000
|
sentMessage = uploadResult.message;
|
28995
29001
|
if (!uploadResult.finished) {
|
28996
29002
|
const receivedMessage = transSentAttrs2IReceivedMessage(checkResult.message, checkResult.sentArgs, exports.SentStatus.FAILED);
|
@@ -29122,15 +29128,6 @@
|
|
29122
29128
|
logger.error('saveSentMessage -> ', error);
|
29123
29129
|
}
|
29124
29130
|
}
|
29125
|
-
function generateEncryptKey() {
|
29126
|
-
const data = new Uint8Array(16);
|
29127
|
-
for (let i = 0; i < 16; i++) {
|
29128
|
-
data[i] = 65 + Math.floor(Math.random() * 26);
|
29129
|
-
}
|
29130
|
-
const key = String.fromCharCode(...data);
|
29131
|
-
const md5Hash = CryptoJS.MD5(key).toString();
|
29132
|
-
return md5Hash;
|
29133
|
-
}
|
29134
29131
|
|
29135
29132
|
class IMClient extends EventEmitter {
|
29136
29133
|
options;
|
@@ -30348,7 +30345,7 @@
|
|
30348
30345
|
return webSocketServer.request(0x30011011, {
|
30349
30346
|
langCode: config.langCode,
|
30350
30347
|
phoneNum: config.phone,
|
30351
|
-
password: CryptoJS
|
30348
|
+
password: CryptoJS.SHA256(config.password).toString(),
|
30352
30349
|
deviceType: 7,
|
30353
30350
|
imei: '59bc678b-fe6d-4e67-87c6-b0692205134b',
|
30354
30351
|
brand: 'Chrome',
|
package/package.json
CHANGED
package/types/types.d.ts
CHANGED
@@ -130,10 +130,6 @@ export type IPushConfig = {
|
|
130
130
|
*/
|
131
131
|
pushData?: string;
|
132
132
|
};
|
133
|
-
export interface IUploadMessageParams {
|
134
|
-
files: Blob[];
|
135
|
-
encryptKey: string;
|
136
|
-
}
|
137
133
|
/**
|
138
134
|
* 发送消息时的可选项信息
|
139
135
|
*/
|
@@ -170,11 +166,19 @@ export interface IUploadHooks {
|
|
170
166
|
/**
|
171
167
|
* 文件上传完成回调,可通过修改返回值以修改待发布的消息内容,如实现自定义消息
|
172
168
|
*/
|
173
|
-
onComplete?: (
|
169
|
+
onComplete?: (result: IUploadCompletedResult) => void | BaseMessage;
|
170
|
+
}
|
171
|
+
export interface IUploadMessageParams {
|
172
|
+
items: {
|
173
|
+
url: string;
|
174
|
+
file: Blob;
|
175
|
+
}[];
|
176
|
+
encryptKey: string;
|
174
177
|
}
|
178
|
+
export type IUploadPrepareResult = IUploadMessageParams;
|
175
179
|
export type IUploadCompletedResult = {
|
176
180
|
urls: string[];
|
177
|
-
encryptedKey
|
181
|
+
encryptedKey: string;
|
178
182
|
};
|
179
183
|
export type IUploadCallback = {
|
180
184
|
onProgress?: (progress: number) => void;
|
@@ -182,8 +186,9 @@ export type IUploadCallback = {
|
|
182
186
|
onError?: (reason: string) => void;
|
183
187
|
};
|
184
188
|
export interface IUploader {
|
185
|
-
upload(
|
189
|
+
upload(params: IUploadMessageParams, callback: IUploadCallback): void;
|
186
190
|
cancel(): void;
|
191
|
+
prepare(files: Blob[]): Promise<IUploadPrepareResult>;
|
187
192
|
}
|
188
193
|
/**
|
189
194
|
* 文件消息配置
|