Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions src/Hyperwallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,22 +559,22 @@ export default class Hyperwallet {
}

//--------------------------------------
// Client Token
// Authentication Token
//--------------------------------------

/**
* Get client token
* Get authentication token
*
* @param {string} userToken - The user token
* @param {api-callback} callback - The callback for this call
*
* @throws Will throw an error if userToken is not provided
*/
getClientToken(userToken, callback) {
getAuthenticationToken(userToken, callback) {
if (!userToken) {
throw new Error("userToken is required");
}
this.client.doPost(`users/${encodeURIComponent(userToken)}/client-token`, {}, {}, callback);
this.client.doPost(`users/${encodeURIComponent(userToken)}/authentication-token`, {}, {}, callback);
}

//--------------------------------------
Expand Down
18 changes: 9 additions & 9 deletions test/Hyperwallet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,11 @@ describe("Hyperwallet", () => {
});

//--------------------------------------
// Client Token
// Authentication Token
//--------------------------------------

/** @test {Hyperwallet#getClientToken} */
describe("getClientToken()", () => {
/** @test {Hyperwallet#getAuthenticationToken} */
describe("getAuthenticationToken()", () => {
let client;
let apiClientSpy;

Expand All @@ -781,19 +781,19 @@ describe("Hyperwallet", () => {
};
});

/** @test {Hyperwallet#getClientToken} */
/** @test {Hyperwallet#getAuthenticationToken} */
it("should throw error if userToken is missing", () => {
const callback = () => null;
expect(() => client.getClientToken(undefined, callback)).to.throw("userToken is required");
expect(() => client.getAuthenticationToken(undefined, callback)).to.throw("userToken is required");
});

/** @test {Hyperwallet#getClientToken} */
it("should do post call to client token endpoint", () => {
/** @test {Hyperwallet#getAuthenticationToken} */
it("should do post call to authentication token endpoint", () => {
const callback = () => null;
client.getClientToken("test-user-token", callback);
client.getAuthenticationToken("test-user-token", callback);

apiClientSpy.should.have.been.calledOnce();
apiClientSpy.should.have.been.calledWith("users/test-user-token/client-token", {}, {}, callback);
apiClientSpy.should.have.been.calledWith("users/test-user-token/authentication-token", {}, {}, callback);
});
});

Expand Down