@lacrous/omnicloud 0.2.16 → 0.2.17
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/dist/index.cjs +25 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/server/index.js +33 -7
- package/server/prisma/migrations/5_upload_request_fingerprint/migration.sql +3 -0
- package/server/prisma/schema.prisma +43 -42
package/dist/index.cjs
CHANGED
|
@@ -1477,6 +1477,20 @@ function sanitizeFileName(name) {
|
|
|
1477
1477
|
return cleaned.slice(0, 255);
|
|
1478
1478
|
}
|
|
1479
1479
|
|
|
1480
|
+
// ../core/src/utils/request-fingerprint.ts
|
|
1481
|
+
var import_node_crypto4 = require("crypto");
|
|
1482
|
+
function uploadRequestFingerprint(input) {
|
|
1483
|
+
const contentHash = input.spooled?.sha256 ?? sha256Hex(input.data ?? Buffer.alloc(0));
|
|
1484
|
+
const canonical = JSON.stringify({
|
|
1485
|
+
name: sanitizeFileName(input.name),
|
|
1486
|
+
folderId: input.folderId ?? null,
|
|
1487
|
+
replaceFileId: input.replaceFileId ?? null,
|
|
1488
|
+
contentHash,
|
|
1489
|
+
size: input.spooled?.size ?? input.data?.byteLength ?? 0
|
|
1490
|
+
});
|
|
1491
|
+
return (0, import_node_crypto4.createHash)("sha256").update(canonical).digest("hex");
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1480
1494
|
// ../core/src/services/file-service.ts
|
|
1481
1495
|
var FileService = class {
|
|
1482
1496
|
constructor(files, folders, engineFor, activity = noopActivityRecorder, operations = null, log = null) {
|
|
@@ -1515,7 +1529,13 @@ var FileService = class {
|
|
|
1515
1529
|
if (!isValidOperationId(operationId)) {
|
|
1516
1530
|
throw new ValidationError("Invalid upload operation id");
|
|
1517
1531
|
}
|
|
1532
|
+
const fingerprint = uploadRequestFingerprint(input);
|
|
1518
1533
|
let op = await operations.findByOperationId(userId, operationId);
|
|
1534
|
+
if (op?.requestFingerprint && op.requestFingerprint !== fingerprint) {
|
|
1535
|
+
throw new ConflictError(
|
|
1536
|
+
"This upload key was already used for a different file. Use a new key for a new upload."
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1519
1539
|
if (op?.status === "COMPLETED" && op.fileId) {
|
|
1520
1540
|
return this.get(userId, op.fileId);
|
|
1521
1541
|
}
|
|
@@ -1524,7 +1544,7 @@ var FileService = class {
|
|
|
1524
1544
|
}
|
|
1525
1545
|
if (!op) {
|
|
1526
1546
|
try {
|
|
1527
|
-
op = await operations.create({ userId, operationId });
|
|
1547
|
+
op = await operations.create({ userId, operationId, requestFingerprint: fingerprint });
|
|
1528
1548
|
} catch (error) {
|
|
1529
1549
|
if (!(error instanceof OperationAlreadyExistsError)) throw error;
|
|
1530
1550
|
const outcome = await this.followWinner(userId, input, operationId, operations);
|
|
@@ -2634,7 +2654,7 @@ var RecentService = class {
|
|
|
2634
2654
|
};
|
|
2635
2655
|
|
|
2636
2656
|
// ../core/src/utils/spool.ts
|
|
2637
|
-
var
|
|
2657
|
+
var import_node_crypto5 = require("crypto");
|
|
2638
2658
|
var import_node_fs = require("fs");
|
|
2639
2659
|
var import_promises = require("fs/promises");
|
|
2640
2660
|
var import_node_os = require("os");
|
|
@@ -2643,7 +2663,7 @@ var import_node_stream2 = require("stream");
|
|
|
2643
2663
|
var import_promises2 = require("stream/promises");
|
|
2644
2664
|
|
|
2645
2665
|
// ../core/src/utils/secret-box.ts
|
|
2646
|
-
var
|
|
2666
|
+
var import_node_crypto6 = require("crypto");
|
|
2647
2667
|
|
|
2648
2668
|
// ../telegram/src/client.ts
|
|
2649
2669
|
var import_telegram = require("telegram");
|
|
@@ -3228,7 +3248,7 @@ var TelegramStorageProvider = class {
|
|
|
3228
3248
|
};
|
|
3229
3249
|
|
|
3230
3250
|
// ../telegram/src/connection.ts
|
|
3231
|
-
var
|
|
3251
|
+
var import_node_crypto7 = require("crypto");
|
|
3232
3252
|
var import_telegram3 = require("telegram");
|
|
3233
3253
|
var import_Password = require("telegram/Password.js");
|
|
3234
3254
|
var TELEGRAM_PROVIDER = "telegram";
|
|
@@ -3310,7 +3330,7 @@ var TelegramConnectionService = class {
|
|
|
3310
3330
|
needsPassword: false,
|
|
3311
3331
|
failure: null
|
|
3312
3332
|
};
|
|
3313
|
-
const flowId = (0,
|
|
3333
|
+
const flowId = (0, import_node_crypto7.randomUUID)();
|
|
3314
3334
|
const token = await this.exportQrToken(client);
|
|
3315
3335
|
this.qrFlows.set(flowId, flow);
|
|
3316
3336
|
this.watchQrApproval(flowId, flow);
|