@@ -5,9 +5,9 @@ const nodeCrypto = require('crypto');
55const base64url = require ( 'base64url' ) ;
66
77/**
8- * @class Crypto
8+ * @class JWE Crypto
99 *
10- * Constructor to create an instance of `Crypto `: provide encrypt/decrypt methods
10+ * Constructor to create an instance of `JweCrypto `: provide JWE encrypt/decrypt methods
1111 *
1212 * @param config encryption/decryption service configuration
1313 * @constructor
@@ -24,8 +24,13 @@ function JweCrypto(config) {
2424
2525 this . encryptedValueFieldName = config . encryptedValueFieldName ;
2626
27- this . encryptedKeyFieldName = config . encryptedKeyFieldName ;
28-
27+ /**
28+ * Perform data encryption
29+ *
30+ * @public
31+ * @param options {Object} parameters
32+ * @param options.data {string} json string to encrypt
33+ */
2934 this . encryptData = function ( options ) {
3035 const data = utils . jsonToString ( options . data ) ;
3136
@@ -67,6 +72,12 @@ function JweCrypto(config) {
6772 return { [ this . encryptedValueFieldName ] : encryptedData } ;
6873 } ;
6974
75+ /**
76+ * Perform data decryption
77+ *
78+ * @public
79+ * @param encryptedData encrypted data
80+ */
7081 this . decryptData = function ( encryptedData ) {
7182 if ( ! encryptedData || encryptedData . length <= 1 ) {
7283 throw new Error ( 'Input not valid' ) ;
@@ -158,6 +169,9 @@ function getPrivateKey(config) {
158169 return null ;
159170}
160171
172+ /**
173+ * @private
174+ */
161175function getPrivateKey12 ( p12Path , alias , password ) {
162176 const p12Content = fs . readFileSync ( p12Path , 'binary' ) ;
163177
@@ -192,6 +206,9 @@ function getPrivateKey12(p12Path, alias, password) {
192206 return forge . pki . privateKeyToPem ( keyObj . key ) ;
193207}
194208
209+ /**
210+ * @private
211+ */
195212function loadPrivateKey ( privateKeyPath ) {
196213 const privateKeyContent = fs . readFileSync ( privateKeyPath , 'binary' ) ;
197214
@@ -208,6 +225,9 @@ function loadPrivateKey(privateKeyPath) {
208225 return privateKey ;
209226}
210227
228+ /**
229+ * @private
230+ */
211231function getPrivateKeyPem ( pemPath ) {
212232 const pemContent = fs . readFileSync ( pemPath , 'binary' ) ;
213233
@@ -221,6 +241,9 @@ function getPrivateKeyPem(pemPath) {
221241 return privateKey ;
222242}
223243
244+ /**
245+ * @private
246+ */
224247function getPrivateKeyDer ( derPath ) {
225248 const derContent = fs . readFileSync ( derPath , 'binary' ) ;
226249
@@ -316,6 +339,9 @@ function isValidConfig(config) {
316339 validateRootMapping ( config ) ;
317340}
318341
342+ /**
343+ * @private
344+ */
319345function validateFingerprint ( config , contains ) {
320346 const propertiesFingerprint = [ "publicKeyFingerprintType" ] ;
321347 const propertiesOptionalFingerprint = [ "publicKeyFingerprint" ] ;
@@ -325,6 +351,9 @@ function validateFingerprint(config, contains) {
325351 }
326352}
327353
354+ /**
355+ * @private
356+ */
328357function validateRootMapping ( config ) {
329358 function multipleRoots ( elem ) {
330359 return elem . length !== 1 && elem . some ( ( item ) => {
0 commit comments