Skip to content

Commit

Permalink
Converting Uint8Array.from to new Uint8Array
Browse files Browse the repository at this point in the history
  • Loading branch information
kaxline authored and tasn committed Aug 8, 2021
1 parent a329037 commit a42c067
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/EncryptedModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class EncryptedRevision<CM extends CollectionItemCryptoManager> {

private calculateAdHash(cryptoManager: CM, additionalData: Uint8Array) {
const cryptoMac = cryptoManager.getCryptoMac();
cryptoMac.update(Uint8Array.from([(this.deleted) ? 1 : 0]));
cryptoMac.update(new Uint8Array([(this.deleted) ? 1 : 0]));
cryptoMac.updateWithLenPrefix(additionalData);

// We hash the chunks separately so that the server can (in the future) return just the hash instead of the full
Expand Down
4 changes: 2 additions & 2 deletions src/Etebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class Account {

const ret: AccountDataStored = {
version,
encryptedData: cryptoManager.encrypt(msgpackEncode(content), Uint8Array.from([version])),
encryptedData: cryptoManager.encrypt(msgpackEncode(content), new Uint8Array([version])),
};

return toBase64(msgpackEncode(ret));
Expand All @@ -243,7 +243,7 @@ export class Account {
const cryptoManager = new StorageCryptoManager(encryptionKey, accountDataStored.version);

const accountData = msgpackDecode(
cryptoManager.decrypt(accountDataStored.encryptedData, Uint8Array.from([accountDataStored.version]))
cryptoManager.decrypt(accountDataStored.encryptedData, new Uint8Array([accountDataStored.version]))
) as AccountData;

const ret = new this(cryptoManager.decrypt(accountData.key), accountData.version);
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function msgpackDecode(buffer: ArrayLike<number> | ArrayBuffer): unknown

export function numToUint8Array(num: number): Uint8Array {
// We are using little-endian because on most platforms it'll mean zero-conversion
return Uint8Array.from([
return new Uint8Array([
num & 255,
(num >> 8) & 255,
(num >> 16) & 255,
Expand Down

0 comments on commit a42c067

Please sign in to comment.