bytifi 0.2.9 → 0.2.10
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/bin/bytifi.js +0 -8
- package/lib/crypto.js +4 -6
- package/lib/upload.js +0 -1
- package/package.json +1 -1
package/bin/bytifi.js
CHANGED
|
@@ -57,7 +57,6 @@ Options:
|
|
|
57
57
|
-q, --quiet Print only the share URL
|
|
58
58
|
--verbose Show API error details on stderr
|
|
59
59
|
--mime-type <type> Override detected MIME type
|
|
60
|
-
--compress Gzip-compress before encrypting (direct uploads only)
|
|
61
60
|
--concurrency <n> Parallel part workers, 1–16 (default: auto)
|
|
62
61
|
--base-url <url> API base URL (default: https://bytifi.com)
|
|
63
62
|
-h, --help Show this help
|
|
@@ -122,7 +121,6 @@ function parseUploadArgs(argv) {
|
|
|
122
121
|
quiet: false,
|
|
123
122
|
verbose: false,
|
|
124
123
|
mimeType: '',
|
|
125
|
-
compress: false,
|
|
126
124
|
concurrency: null,
|
|
127
125
|
baseUrl: 'https://bytifi.com',
|
|
128
126
|
help: false,
|
|
@@ -185,11 +183,6 @@ function parseUploadArgs(argv) {
|
|
|
185
183
|
continue
|
|
186
184
|
}
|
|
187
185
|
|
|
188
|
-
if (arg === '--compress') {
|
|
189
|
-
options.compress = true
|
|
190
|
-
continue
|
|
191
|
-
}
|
|
192
|
-
|
|
193
186
|
if (arg === '--concurrency') {
|
|
194
187
|
const raw = readFlagValue(argv, index, arg)
|
|
195
188
|
const concurrency = Number(raw)
|
|
@@ -433,7 +426,6 @@ async function runUpload(filePath, options) {
|
|
|
433
426
|
expiresInMinutes: options.expiresInMinutes,
|
|
434
427
|
deleteOnDownload: options.deleteOnDownload,
|
|
435
428
|
mimeType: options.mimeType || undefined,
|
|
436
|
-
compress: options.compress,
|
|
437
429
|
concurrency: options.concurrency ?? undefined,
|
|
438
430
|
signal: abort.signal,
|
|
439
431
|
onProgress: showProgress
|
package/lib/crypto.js
CHANGED
|
@@ -19,15 +19,15 @@ export function buildChunkIv(noncePrefix, chunkIndex) {
|
|
|
19
19
|
return iv
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function resolveCompressionMode(originalSize = 0
|
|
22
|
+
export function resolveCompressionMode(originalSize = 0) {
|
|
23
23
|
// Multipart uploads use fixed 32 MB encrypted parts on the server. Gzip can
|
|
24
24
|
// expand incompressible data (ISO, zip, etc.) past that limit and fail part
|
|
25
|
-
// validation, so only gzip-compress direct uploads
|
|
25
|
+
// validation, so only gzip-compress direct uploads.
|
|
26
26
|
if (originalSize > MULTIPART_THRESHOLD_BYTES) {
|
|
27
27
|
return 'none'
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
return
|
|
30
|
+
return 'gzip'
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export function usesChunkCompression(meta) {
|
|
@@ -107,12 +107,11 @@ export function createEncryptionContext({
|
|
|
107
107
|
tokenBytes = crypto.randomBytes(32),
|
|
108
108
|
noncePrefix = crypto.randomBytes(8),
|
|
109
109
|
plainChunkSize = PLAIN_CHUNK_SIZE,
|
|
110
|
-
compress = false,
|
|
111
110
|
}) {
|
|
112
111
|
if (tokenBytes.length !== 32) throw new Error('Encryption token must be 32 bytes.')
|
|
113
112
|
if (noncePrefix.length !== 8) throw new Error('Nonce prefix must be 8 bytes.')
|
|
114
113
|
|
|
115
|
-
const compression = resolveCompressionMode(originalSize
|
|
114
|
+
const compression = resolveCompressionMode(originalSize)
|
|
116
115
|
const { chunkCount, encryptedSize } = calculateEncryptedSize(originalSize, plainChunkSize)
|
|
117
116
|
const meta = buildClientEncryptionMeta({
|
|
118
117
|
plainChunkSize,
|
|
@@ -155,7 +154,6 @@ export async function resolveUploadFile(filePath, options = {}) {
|
|
|
155
154
|
originalSize: stat.size,
|
|
156
155
|
originalName,
|
|
157
156
|
mimeType,
|
|
158
|
-
compress: options.compress === true,
|
|
159
157
|
}),
|
|
160
158
|
}
|
|
161
159
|
}
|
package/lib/upload.js
CHANGED
|
@@ -369,7 +369,6 @@ export async function uploadFile(filePath, options) {
|
|
|
369
369
|
|
|
370
370
|
const { absolutePath, context } = await resolveUploadFile(filePath, {
|
|
371
371
|
mimeType: options.mimeType,
|
|
372
|
-
compress: options.compress === true,
|
|
373
372
|
})
|
|
374
373
|
|
|
375
374
|
if (context.originalSize <= MULTIPART_THRESHOLD_BYTES) {
|