eh-api-client
Advanced tools
Comparing version 0.30.5 to 0.31.0
@@ -93,4 +93,4 @@ var | ||
*/ | ||
Factory.prototype.getRawClient = function() { | ||
var client = new this.Client(this.apiURL); | ||
Factory.prototype.getRawClient = function(options) { | ||
var client = new this.Client(this.apiURL, options); | ||
client._factory = this; | ||
@@ -97,0 +97,0 @@ return client; |
@@ -60,4 +60,11 @@ var | ||
options = options || {}; | ||
if(options.internalAuth) { | ||
options.auth = { | ||
type: "Internal", | ||
credentials: options.internalAuth | ||
}; | ||
delete options.internalAuth; | ||
} | ||
this._options = options; | ||
this.internalAuth = options.internalAuth; | ||
this.auth = options.auth; | ||
this.apiURL = apiURL; | ||
@@ -140,4 +147,4 @@ this.requestId = null; | ||
} | ||
if(this.internalAuth) { | ||
reqParams.headers.Authorization = "Internal " + this.internalAuth; | ||
if(this.auth) { | ||
reqParams.headers.Authorization = this.auth.type + " " + this.auth.credentials; | ||
} | ||
@@ -144,0 +151,0 @@ if(this.requestId) { |
{ | ||
"name": "eh-api-client", | ||
"version": "0.30.5", | ||
"version": "0.31.0", | ||
"description": "Node.js rest client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -57,3 +57,6 @@ var | ||
client.sessionId.should.equal(context.sessionId); | ||
client.internalAuth.should.equal(context.userId + ":" + context.remoteAppCode); | ||
client.auth.should.eql({ | ||
type: "Internal", | ||
credentials: context.userId + ":" + context.remoteAppCode | ||
}); | ||
}); | ||
@@ -78,2 +81,17 @@ }); | ||
describe("getRawClient", function() { | ||
it("should pass options to Client", function() { | ||
var client = f.getRawClient({ | ||
auth: { | ||
type: "Session", | ||
credentials: "sss:app" | ||
} | ||
}); | ||
client.auth.should.eql({ | ||
type: "Session", | ||
credentials: "sss:app" | ||
}); | ||
}); | ||
}); | ||
describe("Internal Auth Client test", function() { | ||
@@ -84,3 +102,6 @@ var noteGlobalId = ehGuid.gen(); | ||
var c = f.getClient(undefined, "web"); | ||
c.internalAuth.should.equal("0:web"); | ||
c.auth.should.eql({ | ||
type: "Internal", | ||
credentials: "0:web" | ||
}); | ||
}); | ||
@@ -90,3 +111,6 @@ | ||
var c = f.getClient(null, "web"); | ||
c.internalAuth.should.equal("0:web"); | ||
c.auth.should.eql({ | ||
type: "Internal", | ||
credentials: "0:web" | ||
}); | ||
}); | ||
@@ -93,0 +117,0 @@ |
78666
1888