Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7dabfd3
ref: decoupling cryptor module
mohitpubnub Sep 11, 2023
77d6a96
cryptoModule
mohitpubnub Sep 19, 2023
3382595
lint
mohitpubnub Sep 19, 2023
da1cce6
rever cryptors in config
mohitpubnub Sep 19, 2023
41fbba9
lint fixes
mohitpubnub Sep 19, 2023
4adeadb
Merge branch 'master' into CLEN-1545
mohitpubnub Sep 19, 2023
cad96a7
CryptoModule for web and node
mohitpubnub Sep 25, 2023
28b5777
step definitions for contract tests
mohitpubnub Sep 25, 2023
5d43f19
lib files
mohitpubnub Sep 25, 2023
243056b
fix:es-lint
mohitpubnub Sep 25, 2023
36afc90
let vs const
mohitpubnub Sep 25, 2023
9d43d8d
and some more ts not wanting me to specific about trivials
mohitpubnub Sep 25, 2023
3e1d47f
access modfiers
mohitpubnub Sep 25, 2023
efaea51
refactor-1
mohitpubnub Sep 26, 2023
a3f5930
lint, cleanup test
mohitpubnub Sep 26, 2023
7be4f39
refactor - 2
mohitpubnub Sep 26, 2023
3e9c721
code cleanup in stream encryption with new cryptor
mohitpubnub Sep 26, 2023
6718489
fix: lint issue.
mohitpubnub Sep 26, 2023
230af91
refactor: eliminate ts-ignores by defining file reated types
mohitpubnub Sep 26, 2023
3c041ba
* integration of crypto module * refactoring cryptoModule
mohitpubnub Oct 5, 2023
720b9ef
lib and dist
mohitpubnub Oct 5, 2023
44fc0fd
support for setCipherKey
mohitpubnub Oct 5, 2023
ee976bf
fix: setCipherKey()
mohitpubnub Oct 5, 2023
929191d
lib and dist files
mohitpubnub Oct 5, 2023
7cef59d
fix: staticIV support
mohitpubnub Oct 5, 2023
f88042f
lib and dist
mohitpubnub Oct 5, 2023
8c57c01
refactor: cryptoModule, * added support for PubNub.CryptoModule factory
mohitpubnub Oct 9, 2023
34ac252
fix: types
mohitpubnub Oct 9, 2023
7839164
dist and libs
mohitpubnub Oct 9, 2023
cd913be
fix: test- customEncrypt function
mohitpubnub Oct 9, 2023
ed97050
fix: legacy crypto init, tests
mohitpubnub Oct 9, 2023
acaacad
refactor: typecheck on incoming data for aescbc cryptor
mohitpubnub Oct 9, 2023
992c8fe
code cleanup, * fix: broken file cryptography operations on web
mohitpubnub Oct 12, 2023
c17fca3
lib and dist directories
mohitpubnub Oct 12, 2023
915d355
refactor: crypto initialiser apis default value initialisation
mohitpubnub Oct 15, 2023
11351ec
LICENSE
mohitpubnub Oct 16, 2023
e007216
reverted last commit 11351ec
mohitpubnub Oct 16, 2023
0a8a4a6
update LICENSE
mohitpubnub Oct 16, 2023
c8d347a
PubNub SDK v7.4.0 release.
pubnub-release-bot Oct 16, 2023
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
34 changes: 25 additions & 9 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -12481,6 +12481,14 @@
tmp.set(new Uint8Array(ab2), ab1.byteLength);
return tmp.buffer;
}
function ab2hex(ab) {
return __spreadArray([], __read(new Uint8Array(ab)), false).map(function (x) { return x.toString(16).padStart(2, '0'); }).join('');
}
function hex2ab(hex) {
return new Uint8Array(hex.match(/[\da-f]{2}/gi).map(function (h) {
return parseInt(h, 16);
}));
}
var WebCryptography = /** @class */ (function () {
function WebCryptography() {
}
Expand Down Expand Up @@ -12580,11 +12588,11 @@
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
bKey = Buffer.from(key);
bKey = WebCryptography.encoder.encode(key);
return [4 /*yield*/, crypto.subtle.digest('SHA-256', bKey.buffer)];
case 1:
abHash = _a.sent();
abKey = Buffer.from(Buffer.from(abHash).toString('hex').slice(0, 32), 'utf8').buffer;
abKey = hex2ab(ab2hex(abHash).slice(0, 32)).buffer;
return [2 /*return*/, crypto.subtle.importKey('raw', abKey, 'AES-CBC', true, ['encrypt', 'decrypt'])];
}
});
Expand All @@ -12607,10 +12615,16 @@
};
WebCryptography.prototype.decryptArrayBuffer = function (key, ciphertext) {
return __awaiter(this, void 0, void 0, function () {
var abIv;
var abIv, data;
return __generator(this, function (_a) {
abIv = ciphertext.slice(0, 16);
return [2 /*return*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, ciphertext.slice(16))];
switch (_a.label) {
case 0:
abIv = ciphertext.slice(0, 16);
return [4 /*yield*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, ciphertext.slice(16))];
case 1:
data = _a.sent();
return [2 /*return*/, data];
}
});
});
};
Expand All @@ -12621,12 +12635,12 @@
switch (_a.label) {
case 0:
abIv = crypto.getRandomValues(new Uint8Array(16));
abPlaintext = Buffer.from(plaintext).buffer;
abPlaintext = WebCryptography.encoder.encode(plaintext).buffer;
return [4 /*yield*/, crypto.subtle.encrypt({ name: 'AES-CBC', iv: abIv }, key, abPlaintext)];
case 1:
abPayload = _a.sent();
ciphertext = concatArrayBuffer(abIv.buffer, abPayload);
return [2 /*return*/, Buffer.from(ciphertext).toString('utf8')];
return [2 /*return*/, WebCryptography.decoder.decode(ciphertext)];
}
});
});
Expand All @@ -12637,18 +12651,20 @@
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
abCiphertext = Buffer.from(ciphertext);
abCiphertext = WebCryptography.encoder.encode(ciphertext).buffer;
abIv = abCiphertext.slice(0, 16);
abPayload = abCiphertext.slice(16);
return [4 /*yield*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, abPayload)];
case 1:
abPlaintext = _a.sent();
return [2 /*return*/, Buffer.from(abPlaintext).toString('utf8')];
return [2 /*return*/, WebCryptography.decoder.decode(abPlaintext)];
}
});
});
};
WebCryptography.IV_LENGTH = 16;
WebCryptography.encoder = new TextEncoder();
WebCryptography.decoder = new TextDecoder();
return WebCryptography;
}());

Expand Down
4 changes: 2 additions & 2 deletions dist/web/pubnub.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/crypto/modules/NodeCryptoModule/ICryptor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
2 changes: 2 additions & 0 deletions lib/crypto/modules/NodeCryptoModule/ILegacyCryptor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
Loading