Skip to content

Commit

Permalink
Add setOrderId
Browse files Browse the repository at this point in the history
  • Loading branch information
sHesl committed Jul 17, 2018
1 parent 7e6acd6 commit cb450c0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ravelinjs",
"version": "0.0.5",
"version": "0.0.6",
"description": "Ravelin Browser Card Encryption Library.",
"main": "ravelin.js",
"scripts": {
Expand Down
22 changes: 17 additions & 5 deletions ravelin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
}(typeof self !== 'undefined' ? self : this, function () {

var version = '0.0.5';
var version = '0.0.6';

var RSAKey = (function(){
// prng4.js - uses Arcfour as a PRNG
Expand Down Expand Up @@ -956,24 +956,36 @@
}

/**
* Set the customerId submitted with requests. This is not required to tie
* together tracking.
* Set the customerId submitted with requests. This is used to associate device activity
* with a specific user.
*
* @param {String} customerId
*/
RavelinJS.prototype.setCustomerId = function() {
console.info('what?')
this._ravelin(['setCustomerId'].concat(Array.prototype.slice.call(arguments, 0)));
}

RavelinJS.prototype._ravelin = function() {
/**
* Set the orderId submitted with requests. This is used to associate session-activity
* with a specific user.
*
* @param {String} orderId
*/
RavelinJS.prototype.setOrderId = function() {
this._ravelin(['setOrderId'].concat(Array.prototype.slice.call(arguments, 0)));
}

RavelinJS.prototype._ravelin = function(args) {
if (typeof this.apiKey !== 'string') {
throw new Error("No tracking API key set. See RavelinJS.setPublicAPIKey");
}
if (!window.ravelin) {
// https://developer.ravelin.com/v2/#device-tracking.
(function(r,a,v,e,l,i,n){r[l]=r[l]||function(){(r[l].q=r[l].q||[]).push(arguments)};i=a.createElement(v);i.async=i.defer=1;i.src=e;a.body.appendChild(i)})(window, document, 'script', 'https://cdn.ravelin.net/js/rvn-beta.min.js', 'ravelin');
}
window.ravelin.apply(window, arguments)

window.ravelin.apply(window, args);
}
}

Expand Down
7 changes: 4 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('ravelinjs', function() {

it('validates no unknown attributes are present', function() {
ravelin.setRSAKey(dummyRSAKey);

const err = "RavelinJS validation: encrypt only allows properties pan, year, month, nameOnCard";
expect(() => ravelin.encrypt({pan: "4111 1111 1111 1111", month: 1, year: "18", "cvv": "123"})).to.throw(err);
});
Expand All @@ -60,7 +60,7 @@ describe('ravelinjs', function() {
c.cardCiphertext != "" && c.cardCiphertext.length > 10 &&
c.aesKeyCiphertext != "" && c.aesKeyCiphertext.length > 10 &&
c.algorithm == "RSA_WITH_AES_256_GCM" &&
c.ravelinjsVersion == "0.0.5"
c.ravelinjsVersion == "0.0.6"
);
}

Expand All @@ -83,4 +83,5 @@ describe('ravelinjs', function() {
})).to.satisfy(validCipher);
});
});
});

});

0 comments on commit cb450c0

Please sign in to comment.