@wireapp/core 21.0.1 → 21.0.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,17 @@
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
+ ## [21.0.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@21.0.1...@wireapp/core@21.0.2) (2022-01-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **core:** Use Uint8Array in place of Buffer ([#4214](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4214)) ([d9c8692](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/d9c869291e60325411070b87f71d8803561bde49))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [21.0.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@21.0.0...@wireapp/core@21.0.1) (2022-01-18)
7
18
 
8
19
 
package/package.json CHANGED
@@ -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": "21.0.1",
73
- "gitHead": "eddd7ebcdc4868900cd7f80b1da391e124593ec1"
72
+ "version": "21.0.2",
73
+ "gitHead": "9838da9b1a1dcb702154c73c28a15e53fc35af9f"
74
74
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { APIClient } from '@wireapp/api-client';
3
2
  import { MessageSendingStatus, Conversation, DefaultConversationRoleName, MutedStatus, QualifiedUserClients, UserClients, ClientMismatch } from '@wireapp/api-client/src/conversation';
4
3
  import type { ConversationMemberLeaveEvent } from '@wireapp/api-client/src/event';
@@ -150,7 +149,7 @@ export declare class ConversationService {
150
149
  createConversation(name: string, otherUserIds?: string | string[]): Promise<Conversation>;
151
150
  getConversations(conversationId: string): Promise<Conversation>;
152
151
  getConversations(conversationIds?: string[]): Promise<Conversation[]>;
153
- getAsset({ assetId, assetToken, otrKey, sha256 }: RemoteData): Promise<Buffer>;
152
+ getAsset({ assetId, assetToken, otrKey, sha256 }: RemoteData): Promise<Uint8Array>;
154
153
  getUnencryptedAsset(assetId: string, assetToken?: string): Promise<ArrayBuffer>;
155
154
  addUser<T extends string | string[] | QualifiedId | QualifiedId[]>(conversationId: string, userIds: T): Promise<T>;
156
155
  removeUser(conversationId: string, userId: string): Promise<string>;
@@ -633,9 +633,9 @@ class ConversationService {
633
633
  const request = this.apiClient.asset.api.getAssetV3(assetId, assetToken);
634
634
  const encryptedBuffer = (await request.response).buffer;
635
635
  return (0, AssetCryptography_1.decryptAsset)({
636
- cipherText: Buffer.from(encryptedBuffer),
637
- keyBytes: Buffer.from(otrKey),
638
- sha256: Buffer.from(sha256),
636
+ cipherText: new Uint8Array(encryptedBuffer),
637
+ keyBytes: otrKey,
638
+ sha256: sha256,
639
639
  });
640
640
  }
641
641
  async getUnencryptedAsset(assetId, assetToken) {
@@ -1,9 +1,8 @@
1
- /// <reference types="node" />
2
1
  export interface EncryptedAsset {
3
- cipherText: Buffer;
4
- keyBytes: Buffer;
2
+ cipherText: Uint8Array;
3
+ keyBytes: Uint8Array;
5
4
  /** The SHA-256 sum of `cipherText` */
6
- sha256: Buffer;
5
+ sha256: Uint8Array;
7
6
  }
8
7
  export interface EncryptedAssetUploaded extends EncryptedAsset {
9
8
  key: string;
@@ -23,22 +23,22 @@ const cryptoLib = window.crypto;
23
23
  exports.crypto = {
24
24
  async digest(cipherText) {
25
25
  const checksum = await cryptoLib.subtle.digest('SHA-256', cipherText);
26
- return Buffer.from(checksum);
26
+ return new Uint8Array(checksum);
27
27
  },
28
28
  async decrypt(cipherText, keyBytes) {
29
29
  const key = await cryptoLib.subtle.importKey('raw', keyBytes, 'AES-CBC', false, ['decrypt']);
30
30
  const initializationVector = cipherText.slice(0, 16);
31
31
  const assetCipherText = cipherText.slice(16);
32
32
  const decipher = await cryptoLib.subtle.decrypt({ iv: initializationVector, name: 'AES-CBC' }, key, assetCipherText);
33
- return Buffer.from(decipher);
33
+ return new Uint8Array(decipher);
34
34
  },
35
35
  getRandomValues(size) {
36
- return Buffer.from(cryptoLib.getRandomValues(new Uint8Array(size)));
36
+ return cryptoLib.getRandomValues(new Uint8Array(size));
37
37
  },
38
38
  async encrypt(plainText, keyBytes, initializationVector) {
39
39
  const key = await cryptoLib.subtle.importKey('raw', keyBytes, 'AES-CBC', true, ['encrypt']);
40
40
  return {
41
- key: Buffer.from(await cryptoLib.subtle.exportKey('raw', key)),
41
+ key: new Uint8Array(await cryptoLib.subtle.exportKey('raw', key)),
42
42
  cipher: await cryptoLib.subtle.encrypt({ iv: initializationVector, name: 'AES-CBC' }, key, plainText),
43
43
  };
44
44
  },
@@ -1,9 +1,8 @@
1
- /// <reference types="node" />
2
1
  import { CipherOptions } from '@wireapp/api-client/src/asset';
3
2
  import type { EncryptedAsset } from './EncryptedAsset';
4
3
  interface EncryptOptions extends CipherOptions {
5
- plainText: Buffer | Uint8Array;
4
+ plainText: Uint8Array;
6
5
  }
7
- export declare const decryptAsset: ({ cipherText, keyBytes, sha256: referenceSha256, }: EncryptedAsset) => Promise<Buffer>;
6
+ export declare const decryptAsset: ({ cipherText, keyBytes, sha256: referenceSha256, }: EncryptedAsset) => Promise<Uint8Array>;
8
7
  export declare const encryptAsset: ({ plainText, algorithm }: EncryptOptions) => Promise<EncryptedAsset>;
9
8
  export {};
@@ -44,7 +44,7 @@ const encryptAsset = async ({ plainText, algorithm = 'AES-256-CBC' }) => {
44
44
  ivCipherText.set(new Uint8Array(cipher), initializationVector.byteLength);
45
45
  const sha256 = await crypto_node_1.crypto.digest(ivCipherText);
46
46
  return {
47
- cipherText: Buffer.from(ivCipherText.buffer),
47
+ cipherText: ivCipherText,
48
48
  keyBytes: key,
49
49
  sha256,
50
50
  };
@@ -1,10 +1,9 @@
1
- /// <reference types="node" />
2
1
  export interface Crypto {
3
- digest(cipherText: Buffer | Uint8Array): Promise<Buffer>;
4
- decrypt(cipherText: Buffer | Uint8Array, keyBytes: Buffer): Promise<Buffer>;
5
- getRandomValues(size: number): Buffer;
6
- encrypt(plainText: Buffer | Uint8Array, keyBytes: Buffer, initializationVector: Buffer, algorithm: string): Promise<{
7
- key: Buffer;
8
- cipher: Buffer;
2
+ digest(cipherText: Uint8Array): Promise<Uint8Array>;
3
+ decrypt(cipherText: Uint8Array, keyBytes: Uint8Array): Promise<Uint8Array>;
4
+ getRandomValues(size: number): Uint8Array;
5
+ encrypt(plainText: Uint8Array, keyBytes: Uint8Array, initializationVector: Uint8Array, algorithm: string): Promise<{
6
+ key: Uint8Array;
7
+ cipher: Uint8Array;
9
8
  }>;
10
9
  }