diff --git a/src/claims.js b/src/claims.js index 5d897c6..5449ba9 100644 --- a/src/claims.js +++ b/src/claims.js @@ -61,16 +61,16 @@ const runVerificationJson = ( if (checkPath.length == 0) { switch (checkRelation) { default: - case 'contains': + case E.ClaimRelation.CONTAINS: re = new RegExp(checkClaim, 'gi') res.isVerified = re.test(proofData.replace(/\r?\n|\r|\\/g, '')) break - case 'equals': + case E.ClaimRelation.EQUALS: res.isVerified = proofData.replace(/\r?\n|\r|\\/g, '').toLowerCase() == checkClaim.toLowerCase() break - case 'oneOf': + case E.ClaimRelation.ONEOF: re = new RegExp(checkClaim, 'gi') res.isVerified = re.test(proofData.join('|')) break @@ -102,7 +102,7 @@ const runVerification = (proofData, spData) => { } switch (spData.proof.format) { - case 'json': + case E.ProofFormat.JSON: res = runVerificationJson( res, proofData, @@ -111,7 +111,7 @@ const runVerification = (proofData, spData) => { spData.claim.relation ) break - case 'text': + case E.ProofFormat.TEXT: re = new RegExp( utils .generateClaim(spData.claim.fingerprint, spData.claim.format) diff --git a/src/utils.js b/src/utils.js index 9283227..9e656cb 100644 --- a/src/utils.js +++ b/src/utils.js @@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +const E = require('./enums') + const generateProxyURL = (type, urlElements, opts) => { if (!opts || !opts.doipProxyHostname) { return null @@ -37,13 +39,13 @@ const generateProxyURL = (type, urlElements, opts) => { const generateClaim = (fingerprint, format) => { switch (format) { - case 'uri': + case E.ClaimFormat.URI: return `openpgp4fpr:${fingerprint}` break - case 'message': + case E.ClaimFormat.MESSAGE: return `[Verifying my OpenPGP key: openpgp4fpr:${fingerprint}]` break - case 'fingerprint': + case E.ClaimFormat.FINGERPRINT: return fingerprint break default: