Skip to content

Commit 124cdb3

Browse files
author
Lora Trifonova
committed
refactor: fix language issues
1 parent 1079482 commit 124cdb3

6 files changed

Lines changed: 45 additions & 45 deletions

File tree

src/client.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ import HTTP from "./http.js";
55
/**
66
* @class
77
* @param {Object} options
8-
* @param {string} options.projectUrl - MIRACL Trust Project URL that is used for communication with the MIRACL Trust API
8+
* @param {string} options.projectUrl - MIRACL Trust Project URL used for communication with the MIRACL Trust API
99
* @param {string} options.projectId - MIRACL Trust Project ID
10-
* @param {string} options.seed - Hex encoded random number generator seed
10+
* @param {string} options.seed - Hex-encoded random number generator seed
1111
* @param {string} options.deviceName - Name of the current device
1212
* @param {Object} options.userStorage - Storage for saving user data
1313
* @param {Object} options.oidc - Parameters for initializing an OIDC auth session
14-
* @param {string} options.oidc.client_id - OIDC client ID
14+
* @param {string} options.oidc.client_id - OIDC Client ID
1515
* @param {string} options.oidc.redirect_uri - OIDC redirect URI
1616
* @param {string} options.oidc.response_type - OIDC response type. Only 'code' is supported
1717
* @param {string} options.oidc.scope - OIDC scope. Must include 'openid'
1818
* @param {string} options.oidc.state - OIDC state
1919
* @param {bool} options.cors - Enable CORS requests if set to 'true'
20-
* @param {number} options.requestTimeout - Time before a HTTP request times out in miliseconds
21-
* @param {string} options.applicationInfo - Sets additional information that will be sent via X-MIRACL-CLIENT HTTP header
20+
* @param {number} options.requestTimeout - Time before an HTTP request times out in milliseconds
21+
* @param {string} options.applicationInfo - Set additional information that will be sent via X-MIRACL-CLIENT HTTP header
2222
*/
2323
export default function Client(options) {
2424
var self = this;
@@ -28,7 +28,7 @@ export default function Client(options) {
2828
}
2929

3030
if (!options.projectId) {
31-
throw new Error("Empty project ID");
31+
throw new Error("Empty Project ID");
3232
}
3333

3434
if (!options.userStorage) {
@@ -38,11 +38,11 @@ export default function Client(options) {
3838
if (!options.projectUrl) {
3939
options.projectUrl = "https://api.mpin.io";
4040
} else {
41-
// remove trailing slash from url, if there is one
41+
// Remove trailing slash from URL, if there is one
4242
options.projectUrl = options.projectUrl.replace(/\/$/, "");
4343
}
4444

45-
// Ensure that default PIN lenght is between 4 and 6
45+
// Ensure the default PIN length is between 4 and 6
4646
if (!options.defaultPinLength || options.defaultPinLength > 6 || options.defaultPinLength < 4) {
4747
options.defaultPinLength = 4;
4848
}
@@ -72,7 +72,7 @@ Client.prototype.options = {};
7272
Client.prototype.session = {};
7373

7474
/**
75-
* Set the access(session) ID
75+
* Set the access/session ID
7676
*
7777
* @param {string} accessId
7878
*/
@@ -81,7 +81,7 @@ Client.prototype.setAccessId = function (accessId) {
8181
};
8282

8383
/**
84-
* Make a request to start a new session and fetch the access(session) ID
84+
* Make a request to start a new session and fetch the access/session ID
8585
*
8686
* @param {string} userId - The unique identifier of the user that will be authenticating (not required)
8787
* @param {function(Error, Object)} callback
@@ -111,7 +111,7 @@ Client.prototype.fetchAccessId = function (userId, callback) {
111111
};
112112

113113
/**
114-
* Request for changes in status
114+
* Get session status
115115
*
116116
* @param {function(Error, Object)} callback
117117
*/
@@ -147,7 +147,7 @@ Client.prototype.sendPushNotificationForAuth = function (userId, callback) {
147147
reqData;
148148

149149
if (!userId) {
150-
return callback(new Error("Empty user ID"), null);
150+
return callback(new Error("Empty User ID"), null);
151151
}
152152

153153
reqData = {
@@ -174,17 +174,17 @@ Client.prototype.sendPushNotificationForAuth = function (userId, callback) {
174174
};
175175

176176
/**
177-
* Start the verification process for a specified user ID (must be email)
177+
* Start the verification process for a specified User ID (must be an email address)
178178
*
179-
* @param {string} userId - The email to start verification for
179+
* @param {string} userId - The email address for which to start verification
180180
* @param {function(Error, Object)} callback
181181
*/
182182
Client.prototype.sendVerificationEmail = function (userId, callback) {
183183
var self = this,
184184
reqData = {};
185185

186186
if (!userId) {
187-
return callback(new Error("Empty user ID"), null);
187+
return callback(new Error("Empty User ID"), null);
188188
}
189189

190190
reqData.url = self.options.projectUrl + "/verification/email";
@@ -229,7 +229,7 @@ Client.prototype.getActivationToken = function (verificationURI, callback) {
229229
params = self._parseUriParams(verificationURI);
230230

231231
if (!params["user_id"]) {
232-
return callback(new Error("Empty user ID"), null);
232+
return callback(new Error("Empty User ID"), null);
233233
}
234234

235235
if (!params["code"]) {
@@ -258,7 +258,7 @@ Client.prototype.getActivationToken = function (verificationURI, callback) {
258258
};
259259

260260
/**
261-
* Create an identity for the specified user ID
261+
* Create an identity for the specified User ID
262262
*
263263
* @param {string} userId - The unique identifier of the user
264264
* @param {string} activationToken - The code received from the verification process
@@ -270,7 +270,7 @@ Client.prototype.register = function (userId, activationToken, pinCallback, call
270270
keypair;
271271

272272
if (!userId) {
273-
return callback(new Error("Empty user ID"), null);
273+
return callback(new Error("Empty User ID"), null);
274274
}
275275

276276
if (!activationToken) {
@@ -407,7 +407,7 @@ Client.prototype._createIdentity = function (userId, userPin, identityData, sec1
407407
};
408408

409409
/**
410-
* Authenticate the user with the specified user ID
410+
* Authenticate the user with the specified User ID
411411
*
412412
* @param {string} userId - The unique identifier of the user
413413
* @param {string} userPin - The PIN associated with the userId
@@ -460,7 +460,7 @@ Client.prototype.authenticateWithNotificationPayload = function (payload, userPi
460460
};
461461

462462
/**
463-
* Fetch a registration (bootstrap) code for the specified user ID
463+
* Fetch a registration (bootstrap) code for the specified User ID
464464
*
465465
* @param {string} userId - The unique identifier of the user
466466
* @param {string} userPin - The PIN associated with the userId
@@ -505,7 +505,7 @@ Client.prototype._authentication = function (userId, userPin, scope, callback) {
505505
X = [];
506506

507507
if (!userId) {
508-
return callback(new Error("Empty user ID"), null);
508+
return callback(new Error("Empty User ID"), null);
509509
}
510510

511511
if (!self.users.exists(userId)) {
@@ -550,20 +550,20 @@ Client.prototype._authentication = function (userId, userPin, scope, callback) {
550550
};
551551

552552
/**
553-
* Make a request for pass one of the M-Pin protocol
553+
* Make a request for pass one of the M-PIN protocol
554554
*
555-
* This function assigns to the property X a random value. It assigns to
556-
* the property SEC the sum of the client secret and time permit. It also
555+
* This function assigns a random value to the property X. It assigns the sum of the client secret
556+
* and time permit to the property SEC. It also
557557
* calculates the values U and UT which are required for M-Pin authentication,
558558
* where U = X.(map_to_curve(MPIN_ID)) and UT = X.(map_to_curve(MPIN_ID) + map_to_curve(DATE|sha256(MPIN_ID))
559-
* UT is called the commitment. U is the required for finding the PIN error.
559+
* UT is called the commitment. U is required for finding the PIN error.
560560
*
561561
* Request data has the following structure:
562562
* {
563-
* mpin_id: mpinIdHex, // Hex encoded M-Pin ID
563+
* mpin_id: mpinIdHex, // Hex-encoded M-PIN ID
564564
* dtas: dtaList // Identifier of the DTAs used for this identity
565-
* UT: UT_hex, // Hex encoded UT
566-
* U: U_hex, // Hex encoded U
565+
* UT: UT_hex, // Hex-encoded UT
566+
* U: U_hex, // Hex-encoded U
567567
* publicKey: publicKey, // The public key used for DVS
568568
* scope: ['oidc'] // Scope of the authentication
569569
* }
@@ -597,11 +597,11 @@ Client.prototype._getPass1 = function (identityData, userPin, scope, X, SEC, cal
597597
*
598598
* This function uses the random value y from the server, property X
599599
* and the combined client secret and time permit to calculate
600-
* the value V which is sent to the M-Pin server.
600+
* the value V which is sent to the M-PIN server.
601601
*
602602
* Request data has the following structure:
603603
* {
604-
* mpin_id: mpinIdHex, // Hex encoded M-Pin ID
604+
* mpin_id: mpinIdHex, // Hex-encoded M-PIN ID
605605
* V: V_hex, // Value required by the server to authenticate user
606606
* WID: accessNumber // Number required for mobile authentication
607607
* }
@@ -697,7 +697,7 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback)
697697
identityData;
698698

699699
if (!userId) {
700-
return callback(new Error("Empty user ID"), null);
700+
return callback(new Error("Empty User ID"), null);
701701
}
702702

703703
if (!self.users.exists(userId)) {

src/crypto.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Crypto.prototype._crypto = function (curve) {
2828
// Change maximum PIN length to 6 digits
2929
CryptoContexts[curve].MPIN.MAXPIN = 1000000;
3030

31-
// Modify MPIN settings
31+
// Modify M-PIN settings
3232
CryptoContexts[curve].MPIN.PBLEN = 20;
3333
CryptoContexts[curve].MPIN.TRAP = 2000;
3434
}
@@ -53,7 +53,7 @@ Crypto.prototype.generateKeypair = function (curve) {
5353
/**
5454
* Add two points on the curve that are originally in hex format
5555
* This function is used to add client secret shares.
56-
* Returns a hex encoded sum of the shares
56+
* Returns a hex-encoded sum of the shares
5757
* @private
5858
*/
5959
Crypto.prototype.addShares = function (privateKeyHex, share1Hex, share2Hex, curve) {
@@ -82,11 +82,11 @@ Crypto.prototype.addShares = function (privateKeyHex, share1Hex, share2Hex, curv
8282
};
8383

8484
/**
85-
* Calculates the MPin Token
86-
* This function maps the M-Pin ID to a point on the curve,
87-
* multiplies this value by PIN and then subtractsit from
88-
* the client secret curve point to generate the M-Pin token.
89-
* Returns a hex encoded M-Pin Token
85+
* Calculates the M-PIN Token
86+
* This function maps the M-PIN ID to a point on the curve,
87+
* multiplies this value by PIN and then subtracts it from
88+
* the client secret curve point to generate the M-PIN token.
89+
* Returns a hex-encoded M-PIN Token
9090
* @private
9191
*/
9292
Crypto.prototype.extractPin = function (mpinId, publicKey, PIN, clientSecretHex, curve) {
@@ -191,7 +191,7 @@ Crypto.prototype.sign = function (curve, mpinId, publicKey, token, userPin, mess
191191
};
192192

193193
/**
194-
* Returns the public key bytes appended to the MPin ID bytes in hex encoding
194+
* Returns the public key bytes appended to the M-PIN ID bytes in hex encoding
195195
* @private
196196
*/
197197
Crypto.prototype._mpinIdWithPublicKey = function (mpinId, publicKey) {

src/users.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Users.prototype.updateLastUsed = function (userId) {
8787
};
8888

8989
/**
90-
* Check if an user with the specified user ID exists
90+
* Check if an user with the specified User ID exists
9191
* @param {string} userId - The ID of the user
9292
* @returns {boolean}
9393
*/

test/test-authentication.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ describe("Client _authentication", function () {
257257
it("should fail w/o userId", function (done) {
258258
client._authentication("", "", ["jwt"], function (err) {
259259
expect(err).to.exist;
260-
expect(err.message).to.equal("Empty user ID");
260+
expect(err.message).to.equal("Empty User ID");
261261
done();
262262
});
263263
});

test/test-dvs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("Client sign", function () {
1818
it("should fail w/o user ID", function (done) {
1919
client.sign("", "1234", "message", "timestamp", function (err, result) {
2020
expect(err).to.exist;
21-
expect(err.message).to.equal("Empty user ID");
21+
expect(err.message).to.equal("Empty User ID");
2222
expect(result).to.be.null;
2323
done();
2424
});

test/test-registration.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("Client sendVerificationEmail", function () {
1313
it("should fail w/o userId", function (done) {
1414
client.sendVerificationEmail("", function (err) {
1515
expect(err).to.exist;
16-
expect(err.message).to.equal("Empty user ID");
16+
expect(err.message).to.equal("Empty User ID");
1717
done();
1818
});
1919
});
@@ -63,7 +63,7 @@ describe("Client getActivationToken", function () {
6363
it("should fail w/o userId", function (done) {
6464
client.getActivationToken("http://example.com/verification/confirmation?code=test", function (err) {
6565
expect(err).to.exist;
66-
expect(err.message).to.equal("Empty user ID");
66+
expect(err.message).to.equal("Empty User ID");
6767
done();
6868
});
6969
});
@@ -316,7 +316,7 @@ describe("Client register", function () {
316316
it("should return error w/o userId", function () {
317317
client.register("", null, function () {}, function (err, data) {
318318
expect(err).to.exist;
319-
expect(err.message).to.equal("Empty user ID");
319+
expect(err.message).to.equal("Empty User ID");
320320
expect(data).to.be.null;
321321
});
322322
});

0 commit comments

Comments
 (0)