Comparing version 3.5.45 to 3.5.47
{ | ||
"name": "pubnub", | ||
"preferGlobal": false, | ||
"version": "3.5.45", | ||
"version": "3.5.47", | ||
"author": "PubNub <stephen@pubnub.com>", | ||
@@ -6,0 +6,0 @@ "description": "Publish & Subscribe Real-time Messaging with PubNub", |
175
pubnub.js
@@ -1,2 +0,2 @@ | ||
// Version: 3.5.45 | ||
// Version: 3.5.47 | ||
var NOW = 1 | ||
@@ -53,4 +53,4 @@ , READY = false | ||
(typeof value != 'undefined' && | ||
value != null && encode_param(value).length > 0 | ||
) && params.push(key + "=" + encode_param(value)); | ||
value != null && encode(value).length > 0 | ||
) && params.push(key + "=" + encode(value)); | ||
} ); | ||
@@ -163,19 +163,6 @@ | ||
* ====== | ||
* var encoded_path = encode('path'); | ||
* var encoded_data = encode('path'); | ||
*/ | ||
function encode_base( path, chars ) { | ||
return map( (''+path||"").split(''), function(chr) { | ||
return chars.indexOf(chr) < 0 ? chr : | ||
"%"+chr.charCodeAt(0).toString(16).toUpperCase() | ||
} ).join(''); | ||
} | ||
function encode(path) { return encodeURIComponent(path) } | ||
function encode( path, chars ) { | ||
return encode_base( path, chars || '?/%&# ' ); | ||
} | ||
function encode_param(value) { | ||
return encode_base( value, '?/%&# ' ); | ||
} | ||
/** | ||
@@ -206,4 +193,4 @@ * Generate Subscription Channel List | ||
, NOLEAVE = setup['noleave'] || 0 | ||
, PUBLISH_KEY = setup['publish_key'] || '' | ||
, SUBSCRIBE_KEY = setup['subscribe_key'] || '' | ||
, PUBLISH_KEY = setup['publish_key'] || 'demo' | ||
, SUBSCRIBE_KEY = setup['subscribe_key'] || 'demo' | ||
, AUTH_KEY = setup['auth_key'] || '' | ||
@@ -232,3 +219,3 @@ , SECRET_KEY = setup['secret_key'] || '' | ||
, db = setup['db'] || {'get': function(){}, 'set': function(){}} | ||
, UUID = setup['uuid'] || ( db && db['get'](SUBSCRIBE_KEY+'uuid') || ''); | ||
, UUID = setup['uuid'] || ( db && db['get'](SUBSCRIBE_KEY+'uuid') || ''); | ||
@@ -345,3 +332,3 @@ function publish(next) { | ||
var callback = callback || args['callback'] || function(){} | ||
, auth_key = args['auth_key'] || AUTH_KEY | ||
, auth_key = args['auth_key'] || AUTH_KEY | ||
, source = args['source'] | ||
@@ -457,11 +444,11 @@ , destination = args['destination'] | ||
data : { 'uuid' : UUID, 'auth' : auth_key }, | ||
fail : function(response){err(response);publish(1)}, | ||
success : function(response) { | ||
if (typeof response == 'object' && response['error']) { | ||
if (typeof response == 'object' && response['error']) | ||
err(response); | ||
} else { | ||
callback(response); | ||
} | ||
else | ||
callback(response) | ||
publish(1); | ||
}, | ||
fail : function(response){err(response);publish(1)} | ||
} | ||
}); | ||
@@ -496,3 +483,2 @@ | ||
// Reset Connection if Count Less | ||
//if (each_channel() < 2) | ||
CONNECT(); | ||
@@ -718,2 +704,5 @@ }, | ||
/* | ||
PUBNUB.here_now({ channel : 'my_chat', callback : fun }); | ||
*/ | ||
'here_now' : function( args, callback ) { | ||
@@ -752,2 +741,14 @@ var callback = args['callback'] || callback | ||
}, | ||
/* | ||
PUBNUB.grant({ | ||
channel : 'my_chat', | ||
callback : fun, | ||
error : fun, | ||
ttl : 60, // Seconds | ||
read : true, | ||
write : true, | ||
auth_key : '3y8uiajdklytowsj' | ||
}); | ||
*/ | ||
'grant' : function( args, callback ) { | ||
@@ -763,6 +764,2 @@ var callback = args['callback'] || callback | ||
function replaceAll(find, replace, str) { | ||
return str.replace(new RegExp(find, 'g'), replace); | ||
} | ||
// Make sure we have a Channel | ||
@@ -772,20 +769,25 @@ if (!channel) return error('Missing Channel'); | ||
if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key'); | ||
if (!PUBLISH_KEY) return error('Missing Publish Key'); | ||
if (!SECRET_KEY) return error('Missing Secret Key'); | ||
if (!PUBLISH_KEY) return error('Missing Publish Key'); | ||
if (!SECRET_KEY) return error('Missing Secret Key'); | ||
if (jsonp != '0') { data['callback'] = jsonp; } | ||
var timestamp = Math.floor(new Date().getTime() / 1000); | ||
var sign_input = SUBSCRIBE_KEY + "\n" + PUBLISH_KEY + "\n" | ||
var timestamp = Math.floor(new Date().getTime() / 1000) | ||
, sign_input = SUBSCRIBE_KEY + "\n" + PUBLISH_KEY + "\n" | ||
+ "grant" + "\n" | ||
+ (((auth_key && encodeURIComponent(auth_key).length > 0)?"auth=" + encodeURIComponent(auth_key) + "&":"")) | ||
+ "channel=" + encodeURIComponent(channel) + "&" + "pnsdk=" + encodeURIComponent(PNSDK) + "&" | ||
+ "r=" + r + "&" + "timestamp=" + encodeURIComponent(timestamp) | ||
+ (( | ||
(auth_key && encode(auth_key).length > 0) ? | ||
"auth=" + encode(auth_key) + "&" : | ||
"" | ||
)) | ||
+ "channel=" + encode(channel) + "&" | ||
+ "pnsdk=" + encode(PNSDK) + "&" | ||
+ "r=" + r + "&" | ||
+ "timestamp=" + encode(timestamp) | ||
+ ((ttl > -1)?"&" + "ttl=" + ttl:"") | ||
+ "&" + "w=" + w; | ||
var signature = hmac_SHA256( sign_input, SECRET_KEY ); | ||
+ "&" + "w=" + w | ||
, signature = hmac_SHA256( sign_input, SECRET_KEY ); | ||
signature = replaceAll("\\+","-",signature); | ||
signature = replaceAll("\\/","_",signature); | ||
signature = signature.replace( /\+/g, "-" ); | ||
signature = signature.replace( /\//g, "_" ); | ||
@@ -796,7 +798,7 @@ var data = { | ||
'signature' : signature, | ||
'channel' : encodeURIComponent(channel), | ||
'channel' : encode(channel), | ||
'timestamp' : timestamp | ||
}; | ||
if (ttl > -1) data['ttl'] = ttl | ||
if (auth_key) data['auth'] = encodeURIComponent(auth_key); | ||
if (auth_key) data['auth'] = encode(auth_key); | ||
@@ -814,2 +816,13 @@ xdr({ | ||
}, | ||
/* | ||
PUBNUB.audit({ | ||
channel : 'my_chat', | ||
callback : fun, | ||
error : fun, | ||
read : true, | ||
write : true, | ||
auth_key : '3y8uiajdklytowsj' | ||
}); | ||
*/ | ||
'audit' : function( args, callback ) { | ||
@@ -819,39 +832,33 @@ var callback = args['callback'] || callback | ||
, channel = args['channel'] | ||
, jsonp = jsonp_cb() | ||
, ttl = args['ttl'] || -1 | ||
, auth_key = args['auth_key']; | ||
, auth_key = args['auth_key'] | ||
, jsonp = jsonp_cb(); | ||
function replaceAll(find, replace, str) { | ||
return str.replace(new RegExp(find, 'g'), replace); | ||
} | ||
// Make sure we have a Channel | ||
if (!callback) return error('Missing Callback'); | ||
if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key'); | ||
if (!PUBLISH_KEY) return error('Missing Publish Key'); | ||
if (!SECRET_KEY) return error('Missing Secret Key'); | ||
if (!PUBLISH_KEY) return error('Missing Publish Key'); | ||
if (!SECRET_KEY) return error('Missing Secret Key'); | ||
if (jsonp != '0') { data['callback'] = jsonp; } | ||
var timestamp = Math.floor(new Date().getTime() / 1000); | ||
var timestamp = Math.floor(new Date().getTime() / 1000) | ||
, sign_input = SUBSCRIBE_KEY + "\n" | ||
+ PUBLISH_KEY + "\n" | ||
+ "audit" + "\n"; | ||
var sign_input = SUBSCRIBE_KEY + "\n" + PUBLISH_KEY + "\n" + "audit" + "\n"; | ||
if (auth_key) sign_input += ("auth=" + encode(auth_key) + "&"); | ||
if (channel) sign_input += ("channel=" + encode(channel) + "&") ; | ||
if (auth_key) sign_input += ("auth=" + encodeURIComponent(auth_key) + "&"); | ||
if (channel) sign_input += ("channel=" + encodeURIComponent(channel) + "&") ; | ||
sign_input += "pnsdk=" + encode(PNSDK) + "&" + "timestamp=" + timestamp; | ||
sign_input += "pnsdk=" + encodeURIComponent(PNSDK) + "&" + "timestamp=" + timestamp; | ||
var signature = hmac_SHA256( sign_input, SECRET_KEY ); | ||
signature = replaceAll("\\+","-",signature); | ||
signature = replaceAll("\\/","_",signature); | ||
signature = signature.replace( /\+/g, "-" ); | ||
signature = signature.replace( /\//g, "_" ); | ||
var data = { | ||
'signature' : signature, | ||
'timestamp' : timestamp | ||
}; | ||
if (channel) data['channel'] = encodeURIComponent(channel) | ||
if (auth_key) data['auth'] = encodeURIComponent(auth_key) | ||
var data = { 'signature' : signature, 'timestamp' : timestamp }; | ||
if (channel) data['channel'] = encode(channel) | ||
if (auth_key) data['auth'] = encode(auth_key) | ||
xdr({ | ||
@@ -868,9 +875,17 @@ callback : jsonp, | ||
}, | ||
/* | ||
PUBNUB.revoke({ | ||
channel : 'my_chat', | ||
callback : fun, | ||
error : fun, | ||
auth_key : '3y8uiajdklytowsj' | ||
}); | ||
*/ | ||
'revoke' : function( args, callback ) { | ||
args['read'] = false; | ||
args['read'] = false; | ||
args['write'] = false; | ||
SELF['grant'](args,callback); | ||
SELF['grant']( args, callback ); | ||
}, | ||
// Expose PUBNUB Functions | ||
@@ -893,3 +908,5 @@ 'xdr' : xdr, | ||
function _poll_online() { | ||
_is_online() || _reset_offline(1 , {"error" : "Offline. Please check your network settings. "}); | ||
_is_online() || _reset_offline( 1, { | ||
"error" : "Offline. Please check your network settings. " | ||
}); | ||
timeout( _poll_online, SECOND ); | ||
@@ -901,3 +918,6 @@ } | ||
detect_time_detla( function(){}, success ); | ||
success || _reset_offline(1, {"error" : "Heartbeat failed to connect to Pubnub Servers. Please check your network settings."}); | ||
success || _reset_offline( 1, { | ||
"error" : "Heartbeat failed to connect to Pubnub Servers." + | ||
"Please check your network settings." | ||
}); | ||
timeout( _poll_online2, KEEPALIVE ); | ||
@@ -932,8 +952,5 @@ }); | ||
if (!time) return; | ||
var ptime = time / 10000 | ||
, latency = (rnow() - stime) / 2; | ||
TIME_DRIFT = rnow() - (ptime + latency); | ||
cb && cb(TIME_DRIFT); | ||
@@ -985,3 +1002,3 @@ } | ||
, SECOND = 1000 | ||
, PNSDK = 'PubNub-JS-' + 'Nodejs' + '/' + '3.5.45' | ||
, PNSDK = 'PubNub-JS-' + 'Nodejs' + '/' + '3.5.47' | ||
, crypto = require('crypto') | ||
@@ -988,0 +1005,0 @@ , XORIGN = 1; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
154545
2666