@wireapp/core 20.4.0 → 20.5.2

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,44 @@
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
+ ## [20.5.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.5.1...@wireapp/core@20.5.2) (2022-01-10)
7
+
8
+ **Note:** Version bump only for package @wireapp/core
9
+
10
+
11
+
12
+
13
+
14
+ ## [20.5.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.5.0...@wireapp/core@20.5.1) (2022-01-10)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **core:** Return domain when uploading a v4 asset ([#4207](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4207)) ([70a7bbe](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/70a7bbe5ac4ab17cd6f3672a770c37a806f616ff))
20
+
21
+
22
+
23
+
24
+
25
+ # [20.5.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.4.1...@wireapp/core@20.5.0) (2022-01-10)
26
+
27
+
28
+ ### Features
29
+
30
+ * **core:** Add method to download v4 assets ([#4206](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4206)) ([41ab95a](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/41ab95ab1d70e2f5bee4e0b4f7d81f058a381792))
31
+
32
+
33
+
34
+
35
+
36
+ ## [20.4.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.4.0...@wireapp/core@20.4.1) (2022-01-06)
37
+
38
+ **Note:** Version bump only for package @wireapp/core
39
+
40
+
41
+
42
+
43
+
6
44
  # [20.4.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.3.0...@wireapp/core@20.4.0) (2021-12-17)
7
45
 
8
46
 
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": "16.2.0",
8
+ "@wireapp/api-client": "16.5.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": "20.4.0",
73
- "gitHead": "402569ffffefe2ee4319454e04219374685d70dd"
72
+ "version": "20.5.2",
73
+ "gitHead": "e59fc8e3bd10c74dea805e59a53e1abb1f2e861f"
74
74
  }
@@ -3,9 +3,44 @@ import type { APIClient } from '@wireapp/api-client';
3
3
  import type { AssetOptions } from '@wireapp/api-client/src/asset';
4
4
  import type { ProgressCallback, RequestCancelable } from '@wireapp/api-client/src/http';
5
5
  import type { EncryptedAssetUploaded } from '../cryptography/';
6
+ export interface AssetDataV4 {
7
+ assetKey: string;
8
+ assetToken: string;
9
+ assetDomain: string;
10
+ forceCaching: boolean;
11
+ version: 4;
12
+ }
13
+ export interface AssetDataV3 {
14
+ assetKey: string;
15
+ assetToken: string;
16
+ forceCaching: boolean;
17
+ version: 3;
18
+ }
19
+ export interface AssetDataV2 {
20
+ assetId: string;
21
+ conversationId: string;
22
+ forceCaching: boolean;
23
+ version: 2;
24
+ }
25
+ export interface AssetDataV1 {
26
+ assetId: string;
27
+ conversationId: string;
28
+ forceCaching: boolean;
29
+ version: 1;
30
+ }
31
+ export declare type AssetUrlData = AssetDataV1 | AssetDataV2 | AssetDataV3 | AssetDataV4;
6
32
  export declare class AssetService {
7
33
  private readonly apiClient;
8
34
  constructor(apiClient: APIClient);
35
+ /**
36
+ * Will download an asset on the server.
37
+ * Will route the request to the right endpoint depending on the asset version
38
+ *
39
+ * @param assetData The versioned asset data
40
+ * @param progressCallback?
41
+ * @return Resolves when the asset has been uploaded
42
+ */
43
+ downloadAsset(assetData: AssetUrlData, progressCallback?: ProgressCallback): RequestCancelable<import("@wireapp/api-client/src/asset").AssetResponse>;
9
44
  /**
10
45
  * Uploads a raw asset to the backend without encrypting it
11
46
  *
@@ -24,6 +24,27 @@ class AssetService {
24
24
  constructor(apiClient) {
25
25
  this.apiClient = apiClient;
26
26
  }
27
+ /**
28
+ * Will download an asset on the server.
29
+ * Will route the request to the right endpoint depending on the asset version
30
+ *
31
+ * @param assetData The versioned asset data
32
+ * @param progressCallback?
33
+ * @return Resolves when the asset has been uploaded
34
+ */
35
+ downloadAsset(assetData, progressCallback) {
36
+ const { forceCaching } = assetData;
37
+ switch (assetData.version) {
38
+ case 1:
39
+ return this.apiClient.asset.api.getAssetV1(assetData.assetId, assetData.conversationId, forceCaching, progressCallback);
40
+ case 2:
41
+ return this.apiClient.asset.api.getAssetV2(assetData.assetId, assetData.conversationId, forceCaching, progressCallback);
42
+ case 3:
43
+ return this.apiClient.asset.api.getAssetV3(assetData.assetKey, assetData.assetToken, forceCaching, progressCallback);
44
+ case 4:
45
+ return this.apiClient.asset.api.getAssetV4(assetData.assetKey, assetData.assetToken, assetData.assetDomain, forceCaching, progressCallback);
46
+ }
47
+ }
27
48
  /**
28
49
  * Uploads a raw asset to the backend without encrypting it
29
50
  *
@@ -51,9 +72,10 @@ class AssetService {
51
72
  });
52
73
  const request = this.uploadRawAsset(cipherText, options, progressCallback);
53
74
  return Object.assign(Object.assign({}, request), { response: request.response.then(response => {
54
- const { key, token } = response;
75
+ const { key, token, domain } = response;
55
76
  return {
56
77
  cipherText,
78
+ domain,
57
79
  key,
58
80
  keyBytes,
59
81
  sha256,
@@ -628,7 +628,7 @@ class ConversationService {
628
628
  return this.apiClient.conversation.api.getConversationsByIds(conversationIds);
629
629
  }
630
630
  async getAsset({ assetId, assetToken, otrKey, sha256 }) {
631
- const request = await this.apiClient.asset.api.getAssetV3(assetId, assetToken);
631
+ const request = this.apiClient.asset.api.getAssetV3(assetId, assetToken);
632
632
  const encryptedBuffer = (await request.response).buffer;
633
633
  return (0, AssetCryptography_1.decryptAsset)({
634
634
  cipherText: Buffer.from(encryptedBuffer),
@@ -7,5 +7,6 @@ export interface EncryptedAsset {
7
7
  }
8
8
  export interface EncryptedAssetUploaded extends EncryptedAsset {
9
9
  key: string;
10
+ domain?: string;
10
11
  token: string;
11
12
  }