Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@internxt/inxt-js",
"author": "Internxt <hello@internxt.com>",
"version": "3.2.1",
"version": "3.2.2",
"description": "",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
9 changes: 3 additions & 6 deletions src/lib/core/download/downloadV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { getStream } from '../../../services/request';
import { GenerateFileKey, sha256 } from '../../utils/crypto';
import { Events as ProgressEvents, HashStream, ProgressNotifier } from '../../utils/streams';
import { DownloadProgressCallback } from '.';
import Errors from './errors';
import { ChunkSizeTransform } from '../../utils/streams/Chunker';
import { AppDetails } from '@internxt/sdk/dist/shared';

Expand Down Expand Up @@ -60,7 +59,7 @@ export function downloadFileV2(

const decryptFileStep: DecryptFileFunction = async (algorithm, key, iv, fileSize) => {
if (algorithm !== ALGORITHMS.AES256CTR.type) {
throw Errors.downloadUnknownAlgorithmError;
throw new Error(`Invalid algorithm: ${algorithm}.`);
}

const decipher = createDecipheriv('aes-256-ctr', key as Buffer, iv as Buffer);
Expand Down Expand Up @@ -88,7 +87,7 @@ export function downloadFileV2(
const expectedHash = fileEncryptedSlice.hash;

if (calculatedHash !== expectedHash) {
throw Errors.downloadHashMismatchError;
throw new Error(`Hash mismatch. Expected: ${expectedHash}. Got: ${calculatedHash}.`);
}
}

Expand All @@ -101,9 +100,7 @@ export function downloadFileV2(
mnemonic,
network,
{
validateMnemonic: (mnemonic) => {
return validateMnemonic(mnemonic);
},
validateMnemonic,
algorithm: ALGORITHMS.AES256CTR,
randomBytes,
generateFileKey: (mnemonic, bucketId, index) => {
Expand Down
39 changes: 0 additions & 39 deletions src/lib/core/download/errors.ts

This file was deleted.

5 changes: 2 additions & 3 deletions src/lib/core/upload/uploadV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { ALGORITHMS, Crypto, Network } from '@internxt/sdk/dist/network';

import { GenerateFileKey, sha256 } from '../../utils/crypto';
import { Events as ProgressEvents, HashStream, ProgressNotifier } from '../../utils/streams';
import Errors from '../download/errors';
import { UploadProgressCallback } from '.';
import { logger } from '../../utils/logger';
import { uploadParts } from './multipart';
Expand Down Expand Up @@ -67,7 +66,7 @@ async function uploadFileV2(
logger.debug('Encrypting file using %s (key %s, iv %s)...', algorithm, key.toString('hex'), iv.toString('hex'));

if (algorithm !== ALGORITHMS.AES256CTR.type) {
throw Errors.uploadUnknownAlgorithmError;
throw new Error(`Invalid algorithm: ${algorithm}.`);
}

cipher = createCipheriv('aes-256-ctr', key as Buffer, iv as Buffer);
Expand Down Expand Up @@ -118,7 +117,7 @@ async function uploadFileMultipart(
logger.debug('Encrypting file using %s (key %s, iv %s)...', algorithm, key.toString('hex'), iv.toString('hex'));

if (algorithm !== ALGORITHMS.AES256CTR.type) {
throw Errors.uploadUnknownAlgorithmError;
throw new Error(`Invalid algorithm: ${algorithm}.`);
}

cipher = createCipheriv('aes-256-ctr', key as Buffer, iv as Buffer);
Expand Down
Loading