Skip to content

Commit

Permalink
dist/lib
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpubnub committed Nov 8, 2023
1 parent 2586deb commit d52a9e0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
40 changes: 29 additions & 11 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -13136,9 +13136,11 @@
case 0:
if (this.defaultCryptor.identifier === CryptorHeader.LEGACY_IDENTIFIER)
return [2 /*return*/, this.defaultCryptor.encryptFile(file, File)];
fileData = this.getFileData(file.data);
return [4 /*yield*/, this.defaultCryptor.encryptFileData(fileData)];
return [4 /*yield*/, this.getFileData(file.data)];
case 1:
fileData = _a.sent();
return [4 /*yield*/, this.defaultCryptor.encryptFileData(fileData)];
case 2:
encrypted = _a.sent();
return [2 /*return*/, File.create({
name: file.name,
Expand All @@ -13163,7 +13165,9 @@
if ((cryptor === null || cryptor === void 0 ? void 0 : cryptor.identifier) === CryptoModule.LEGACY_IDENTIFIER) {
return [2 /*return*/, cryptor.decryptFile(file, File)];
}
fileData = this.getFileData(data);
return [4 /*yield*/, this.getFileData(data)];
case 2:
fileData = _d.sent();
metadata = fileData.slice(header.length - header.metadataLength, header.length);
_b = (_a = File).create;
_c = {
Expand All @@ -13173,7 +13177,7 @@
data: data.slice(header.length),
metadata: metadata,
})];
case 2: return [2 /*return*/, _b.apply(_a, [(_c.data = _d.sent(),
case 3: return [2 /*return*/, _b.apply(_a, [(_c.data = _d.sent(),
_c)])];
}
});
Expand Down Expand Up @@ -13215,13 +13219,27 @@
return headerData.buffer;
};
CryptoModule.prototype.getFileData = function (input) {
if (input instanceof ArrayBuffer) {
return input;
}
if (typeof input === 'string') {
return CryptoModule.encoder.encode(input);
}
throw new Error('Cannot decrypt/encrypt file. In browsers file decryption supports only string or ArrayBuffer');
return __awaiter(this, void 0, void 0, function () {
var fileData;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(input instanceof Blob)) return [3 /*break*/, 2];
return [4 /*yield*/, input.arrayBuffer()];
case 1:
fileData = _a.sent();
return [2 /*return*/, fileData];
case 2:
if (input instanceof ArrayBuffer) {
return [2 /*return*/, input];
}
if (typeof input === 'string') {
return [2 /*return*/, CryptoModule.encoder.encode(input)];
}
throw new Error('Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob');
}
});
});
};
CryptoModule.LEGACY_IDENTIFIER = '';
CryptoModule.encoder = new TextEncoder();
Expand Down
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

0 comments on commit d52a9e0

Please sign in to comment.