@@ -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 */
2323export 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 = {};
7272Client . 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 */
182182Client . 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 ) ) {
0 commit comments