@wireapp/core 18.0.0 → 19.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [19.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@18.0.0...@wireapp/core@19.0.0) (2021-12-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **core:** Ability to cancel asset uploading ([#4198](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4198)) ([e111f46](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/e111f46d06bf2ec22f2002c9a2954cdf0c9e8d09))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* **core:** Uploading an asset now return a structure that allow cancelling the upload. Thus instances of `await account.service.asset.uploadAsset(...)` must be replaced by
|
|
17
|
+
```
|
|
18
|
+
const {cancel, response} = await account.service.asset.uploadAsset(...);
|
|
19
|
+
cancel() // This is how you cancel the upload
|
|
20
|
+
await response// This will contain the uploaded asset once the upload is done
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
6
27
|
# [18.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@17.34.0...@wireapp/core@18.0.0) (2021-12-08)
|
|
7
28
|
|
|
8
29
|
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@types/long": "4.0.1",
|
|
7
7
|
"@types/node": "~14",
|
|
8
|
-
"@wireapp/api-client": "
|
|
8
|
+
"@wireapp/api-client": "16.0.0",
|
|
9
9
|
"@wireapp/cryptobox": "12.7.1",
|
|
10
10
|
"bazinga64": "5.10.0",
|
|
11
11
|
"hash.js": "1.1.7",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"test:project": "yarn dist && yarn test",
|
|
70
70
|
"test:node": "nyc jasmine --config=jasmine.json"
|
|
71
71
|
},
|
|
72
|
-
"version": "
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "19.0.0",
|
|
73
|
+
"gitHead": "e4c585ccf983ca2eb954b3c381dc1fb093192b3a"
|
|
74
74
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { APIClient } from '@wireapp/api-client';
|
|
2
3
|
import type { AssetOptions } from '@wireapp/api-client/src/asset';
|
|
3
|
-
import type {
|
|
4
|
+
import type { ProgressCallback, RequestCancelable } from '@wireapp/api-client/src/http';
|
|
4
5
|
import type { EncryptedAssetUploaded } from '../cryptography/';
|
|
5
6
|
export declare class AssetService {
|
|
6
7
|
private readonly apiClient;
|
|
7
8
|
constructor(apiClient: APIClient);
|
|
8
|
-
|
|
9
|
-
uploadImageAsset(image: ImageContent, options?: AssetOptions): Promise<EncryptedAssetUploaded>;
|
|
10
|
-
uploadFileAsset(file: FileContent, options?: AssetOptions): Promise<EncryptedAssetUploaded>;
|
|
9
|
+
uploadAsset(plainText: Buffer | Uint8Array, options?: AssetOptions, progressCallback?: ProgressCallback): Promise<RequestCancelable<EncryptedAssetUploaded>>;
|
|
11
10
|
}
|
|
@@ -24,27 +24,23 @@ class AssetService {
|
|
|
24
24
|
constructor(apiClient) {
|
|
25
25
|
this.apiClient = apiClient;
|
|
26
26
|
}
|
|
27
|
-
async
|
|
27
|
+
async uploadAsset(plainText, options, progressCallback) {
|
|
28
28
|
const { cipherText, keyBytes, sha256 } = await (0, AssetCryptography_1.encryptAsset)({
|
|
29
29
|
plainText,
|
|
30
30
|
algorithm: options === null || options === void 0 ? void 0 : options.algorithm,
|
|
31
31
|
hash: options === null || options === void 0 ? void 0 : options.hash,
|
|
32
32
|
});
|
|
33
|
-
const request =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return this.postAsset(image.data, options);
|
|
45
|
-
}
|
|
46
|
-
uploadFileAsset(file, options) {
|
|
47
|
-
return this.postAsset(file.data, options);
|
|
33
|
+
const request = this.apiClient.asset.api.postAsset(new Uint8Array(cipherText), options, progressCallback);
|
|
34
|
+
return Object.assign(Object.assign({}, request), { response: request.response.then(response => {
|
|
35
|
+
const { key, token } = response;
|
|
36
|
+
return {
|
|
37
|
+
cipherText,
|
|
38
|
+
key,
|
|
39
|
+
keyBytes,
|
|
40
|
+
sha256,
|
|
41
|
+
token,
|
|
42
|
+
};
|
|
43
|
+
}) });
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
exports.AssetService = AssetService;
|
|
@@ -40,7 +40,7 @@ class LinkPreviewService {
|
|
|
40
40
|
return preview;
|
|
41
41
|
}
|
|
42
42
|
const uploadedLinkPreview = preview;
|
|
43
|
-
const asset = await this.assetService.
|
|
43
|
+
const asset = await (await this.assetService.uploadAsset(linkPreview.image.data)).response;
|
|
44
44
|
uploadedLinkPreview.imageUploaded = {
|
|
45
45
|
asset,
|
|
46
46
|
image,
|