@wireapp/core 20.4.1 → 20.6.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,47 @@
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.6.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.5.2...@wireapp/core@20.6.0) (2022-01-10)
7
+
8
+
9
+ ### Features
10
+
11
+ * **core:** Add asset domain when sending asset message ([#4208](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4208)) ([51f7518](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/51f751834cf6480a47c9a5bf255b4b38d7228f77))
12
+
13
+
14
+
15
+
16
+
17
+ ## [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)
18
+
19
+ **Note:** Version bump only for package @wireapp/core
20
+
21
+
22
+
23
+
24
+
25
+ ## [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)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **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))
31
+
32
+
33
+
34
+
35
+
36
+ # [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)
37
+
38
+
39
+ ### Features
40
+
41
+ * **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))
42
+
43
+
44
+
45
+
46
+
6
47
  ## [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)
7
48
 
8
49
  **Note:** Version bump only for package @wireapp/core
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.3.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.1",
73
- "gitHead": "5f916a0ffeea53d3f3e9b99dcb0ef589b2f71b02"
72
+ "version": "20.6.0",
73
+ "gitHead": "a3ceb0c59844db867e2dbb5ca3949db809da024c"
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,
@@ -273,6 +273,7 @@ class ConversationService {
273
273
  assetToken: asset.token,
274
274
  otrKey: asset.keyBytes,
275
275
  sha256: asset.sha256,
276
+ assetDomain: asset.domain,
276
277
  });
277
278
  const assetMessage = protocol_messaging_1.Asset.create({
278
279
  expectsReadConfirmation,
@@ -628,7 +629,7 @@ class ConversationService {
628
629
  return this.apiClient.conversation.api.getConversationsByIds(conversationIds);
629
630
  }
630
631
  async getAsset({ assetId, assetToken, otrKey, sha256 }) {
631
- const request = await this.apiClient.asset.api.getAssetV3(assetId, assetToken);
632
+ const request = this.apiClient.asset.api.getAssetV3(assetId, assetToken);
632
633
  const encryptedBuffer = (await request.response).buffer;
633
634
  return (0, AssetCryptography_1.decryptAsset)({
634
635
  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
  }