mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 14:39:28 -07:00
Replace strings with enums
This commit is contained in:
parent
09677602cc
commit
a47c88ca36
2 changed files with 10 additions and 8 deletions
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue