| 86 | } |
| 87 | |
| 88 | function emailCheck(email, key) { |
| 89 | email = email.toLowerCase(); |
| 90 | // escape email before using in regular expression |
| 91 | const emailEsc = email.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); |
| 92 | const emailRegex = new RegExp(`<${emailEsc}>`); |
| 93 | const userIds = key.getUserIDs(); |
| 94 | for (let i = 0; i < userIds.length; i++) { |
| 95 | const userId = userIds[i].toLowerCase(); |
| 96 | if (email === userId || emailRegex.test(userId)) { |
| 97 | return true; |
| 98 | } |
| 99 | } |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | function keyIdCheck(keyId, key) { |
| 104 | if (keyId.length === 16) { |