Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.compress = function(input, compressionOptions) {
return pako.deflateRaw(input, {
level : compressionOptions.level || -1 // default compression
});
};
exports.uncompress = function(input) {
sendLogs: function (data) {
if(!connection.emuc.focusMucJid)
return false;
var deflate = true;
var content = JSON.stringify(data);
if (deflate) {
content = String.fromCharCode.apply(null, Pako.deflateRaw(content));
}
content = Base64.encode(content);
// XEP-0337-ish
var message = $msg({to: connection.emuc.focusMucJid, type: 'normal'});
message.c('log', { xmlns: 'urn:xmpp:eventlog',
id: 'PeerConnectionStats'});
message.c('message').t(content).up();
if (deflate) {
message.c('tag', {name: "deflated", value: "true"}).up();
}
message.up();
connection.send(message);
return true;
},
// Gets the logs from strophe.jingle.
encode(data, encode, deflate, base64) {
let result = data;
if (encode) {
try {
result = encodeURIComponent(result);
} catch (e) {
console.error(e);
return;
}
}
if (deflate && result.length > 0) {
try {
result = this.bytesToString(pako.deflateRaw(result));
} catch (e) {
console.error(e);
return;
}
}
if (base64) {
try {
result = btoa(result);
} catch (e) {
console.error(e);
return;
}
}
return result;
},
encode: function encode(data, _encode, deflate, base64) {
if (_encode) {
try {
data = encodeURIComponent(data);
} catch (e) {
console.error(e);
return;
}
}
if (deflate && data.length > 0) {
try {
data = this.bytesToString(pako.deflateRaw(data));
} catch (e) {
console.error(e);
return;
}
}
if (base64) {
try {
data = btoa(data);
} catch (e) {
console.error(e);
return;
}
}
return data;
function cipher({ session, string, compress, rsaKey })
{
if (rsaKey === undefined)
{
rsaKey = session.cleAES;
}
string = forge.util.encodeUtf8('' + string);
//let original = string;
if (compress && !session.disableCompress)
{
string = new forge.util.ByteBuffer(string).toHex();
string = pako.deflateRaw(string, {
level: 6,
to: 'string'
})
}
let key = forge.md.md5.create().update(rsaKey.bytes()).digest();
let iv = session.ivAES.length() ? forge.md.md5.create().update(session.ivAES.bytes()).digest() : new forge.util.ByteBuffer();
let cipher = forge.cipher.createCipher('AES-CBC', key);
cipher.start({
iv: iv
});
cipher.update(new forge.util.ByteBuffer(string));
return cipher.finish() && cipher.output.toHex();
/*let result = cipher.finish() && cipher.output.toHex();
function toUrlKey(code: string) {
return btoa(deflateRaw(code, {to: 'string'}))
.replace(/=*$/, '')
.replace(/\//g, '_')
.replace(/\+/g, '.');
}
fn: () => pako.deflateRaw(source, { chunkSize, level }),
})
exports.compress = function(input) {
return pako.deflateRaw(input);
};
exports.uncompress = function(input) {
var deflate = bodec.Binary === Buffer ? function (data) {
if (bodec.Binary === Buffer) {
return new Buffer(pako.deflateRaw(new Uint8Array(data)));
}
} : pako.deflateRaw;