Skip to content

Commit

Permalink
Merge pull request #120 from aoberoi/bug-117
Browse files Browse the repository at this point in the history
replace use of reserved word pacakge, fixes #117
  • Loading branch information
aoberoi committed Apr 22, 2016
2 parents a07359e + f508de5 commit 815a04e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var util = require('util'),
request = requestRoot,
_ = require('lodash'),
to_json = require('xmljson').to_json,
package = require('../package.json'),
pkg = require('../package.json'),
defaultConfig = {
apiKey: null,
apiSecret: null,
Expand Down Expand Up @@ -37,7 +37,7 @@ Client.prototype.createSession = function(opts, cb) {
url: this.c.apiUrl + this.c.endpoints.createSession,
form: opts,
headers: {
'User-Agent': 'OpenTok-Node-SDK/' + package.version,
'User-Agent': 'OpenTok-Node-SDK/' + pkg.version,
'X-TB-PARTNER-AUTH': this.c.apiKey+':'+this.c.apiSecret
}
}, function(err, resp, body) {
Expand Down
3 changes: 1 addition & 2 deletions lib/opentok.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var net = require('net'),
Client = require('./client'),
Session = require('./session'),
archiving = require('./archiving'),
package = require('../package.json'),
errors = require('./errors');

// Internal Constants
Expand Down Expand Up @@ -299,7 +298,7 @@ var OpenTok = function(apiKey, apiSecret, env) {
* OpenTok Media Router</a> provides the following benefits:
*
* <li><code>archiveMode</code> (String) &mdash;
* Whether the session is automatically archived (<code>"always"</code>) or not
* Whether the session is automatically archived (<code>"always"</code>) or not
* (<code>"manual"</code>). By default, the setting is <code>"manual"</code>, and you must call the
* <code>StartArchive()</code> method of the OpenTok object to start archiving. To archive the
* session (either automatically or not), you must set the <code>mediaMode</code> parameter to
Expand Down
22 changes: 11 additions & 11 deletions test/opentok-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var expect = require('chai').expect,
// Subject
var OpenTok = require('../lib/opentok.js'),
Session = require('../lib/session.js'),
package = require('../package.json');
pkg = require('../package.json');

// Fixtures
var apiKey = '123456',
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('OpenTok', function() {
it('sends its requests to the set apiUrl', function(done) {
var scope = nock(apiUrl)
.matchHeader('x-tb-partner-auth', apiKey+':'+apiSecret)
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+package.version))
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+pkg.version))
.post('/session/create', "archiveMode=manual&p2p.preference=enabled")
.reply(200, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sessions><Session><session_id>SESSIONID</session_id><partner_id>123456</partner_id><create_dt>Wed Mar 19 23:35:24 PDT 2014</create_dt></Session></sessions>", { server: 'nginx',
date: 'Thu, 20 Mar 2014 06:35:24 GMT',
Expand Down Expand Up @@ -171,7 +171,7 @@ describe('OpenTok', function() {
it('creates a new session', function(done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-tb-partner-auth', apiKey+':'+apiSecret)
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+package.version))
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+pkg.version))
.post('/session/create', "archiveMode=manual&p2p.preference=enabled")
.reply(200, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sessions><Session><session_id>SESSIONID</session_id><partner_id>123456</partner_id><create_dt>Wed Mar 19 23:35:24 PDT 2014</create_dt></Session></sessions>", { server: 'nginx',
date: 'Thu, 20 Mar 2014 06:35:24 GMT',
Expand All @@ -194,7 +194,7 @@ describe('OpenTok', function() {
it('creates a media routed session', function(done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-tb-partner-auth', apiKey+':'+apiSecret)
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+package.version))
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+pkg.version))
.post('/session/create', "archiveMode=manual&p2p.preference=disabled")
.reply(200, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sessions><Session><session_id>SESSIONID</session_id><partner_id>123456</partner_id><create_dt>Thu Mar 20 07:02:45 PDT 2014</create_dt></Session></sessions>", { server: 'nginx',
date: 'Thu, 20 Mar 2014 14:02:45 GMT',
Expand All @@ -216,7 +216,7 @@ describe('OpenTok', function() {
it('creates a media relayed session even if the media mode is invalid', function(done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-tb-partner-auth', apiKey+':'+apiSecret)
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+package.version))
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+pkg.version))
.post('/session/create', "archiveMode=manual&p2p.preference=enabled")
.reply(200, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sessions><Session><session_id>SESSIONID</session_id><partner_id>123456</partner_id><create_dt>Thu Mar 20 07:02:45 PDT 2014</create_dt></Session></sessions>", { server: 'nginx',
date: 'Thu, 20 Mar 2014 14:02:45 GMT',
Expand All @@ -238,7 +238,7 @@ describe('OpenTok', function() {
it('creates a session with manual archive mode', function(done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-tb-partner-auth', apiKey+':'+apiSecret)
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+package.version))
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+pkg.version))
.post('/session/create', "archiveMode=manual&p2p.preference=disabled")
.reply(200, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sessions><Session><session_id>SESSIONID</session_id><partner_id>123456</partner_id><create_dt>Thu Mar 20 07:02:45 PDT 2014</create_dt></Session></sessions>", { server: 'nginx',
date: 'Thu, 20 Mar 2014 14:02:45 GMT',
Expand All @@ -260,7 +260,7 @@ describe('OpenTok', function() {
it('creates a session with always archive mode', function(done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-tb-partner-auth', apiKey+':'+apiSecret)
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+package.version))
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+pkg.version))
.post('/session/create', "archiveMode=always&p2p.preference=disabled")
.reply(200, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sessions><Session><session_id>SESSIONID</session_id><partner_id>123456</partner_id><create_dt>Thu Mar 20 07:02:45 PDT 2014</create_dt></Session></sessions>", { server: 'nginx',
date: 'Thu, 20 Mar 2014 14:02:45 GMT',
Expand All @@ -282,7 +282,7 @@ describe('OpenTok', function() {
it('creates a session with manual archive mode even if the archive mode is invalid', function(done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-tb-partner-auth', apiKey+':'+apiSecret)
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+package.version))
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+pkg.version))
.post('/session/create', "archiveMode=manual&p2p.preference=disabled")
.reply(200, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sessions><Session><session_id>SESSIONID</session_id><partner_id>123456</partner_id><create_dt>Thu Mar 20 07:02:45 PDT 2014</create_dt></Session></sessions>", { server: 'nginx',
date: 'Thu, 20 Mar 2014 14:02:45 GMT',
Expand All @@ -304,7 +304,7 @@ describe('OpenTok', function() {
it('adds a location hint to the created session', function(done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-tb-partner-auth', apiKey+':'+apiSecret)
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+package.version))
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+pkg.version))
.post('/session/create', "location=12.34.56.78&archiveMode=manual&p2p.preference=enabled")
.reply(200, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sessions><Session><session_id>SESSIONID</session_id><partner_id>123456</partner_id><create_dt>Thu Mar 20 07:17:22 PDT 2014</create_dt></Session></sessions>", { server: 'nginx',
date: 'Thu, 20 Mar 2014 14:17:22 GMT',
Expand Down Expand Up @@ -348,7 +348,7 @@ describe('OpenTok', function() {
it('complains when a server error takes place', function(done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-tb-partner-auth', apiKey+':'+apiSecret)
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+package.version))
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+pkg.version))
.post('/session/create', "archiveMode=manual&p2p.preference=enabled")
.reply(503, "", { server: 'nginx',
date: 'Thu, 20 Mar 2014 06:35:24 GMT',
Expand All @@ -368,7 +368,7 @@ describe('OpenTok', function() {
it('returns a Session that can generate a token', function(done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-tb-partner-auth', apiKey+':'+apiSecret)
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+package.version))
.matchHeader('user-agent', new RegExp("OpenTok-Node-SDK\/"+pkg.version))
.post('/session/create', "archiveMode=manual&p2p.preference=enabled")
.reply(200, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><sessions><Session><session_id>"+sessionId+"</session_id><partner_id>123456</partner_id><create_dt>Wed Mar 19 23:35:24 PDT 2014</create_dt></Session></sessions>", { server: 'nginx',
date: 'Thu, 20 Mar 2014 06:35:24 GMT',
Expand Down

0 comments on commit 815a04e

Please sign in to comment.