UNPKG

aladinnetwork-blockstack

Version:

The Aladin Javascript library for authentication, identity, and storage.

70 lines 2.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * * @ignore */ function containsValidProofStatement(searchText, name = null) { if (!name) { return false; } searchText = searchText.toLowerCase(); if (name.split('.').length < 2) { throw new Error('Please provide the fully qualified Aladin name.'); } let username = null; // support legacy Aladin ID proofs if (name.endsWith('.id')) { username = name.split('.id')[0]; } const verificationStyles = username != null ? [ `verifying myself: my bitcoin username is +${username}`, `verifying myself: my bitcoin username is ${username}`, `verifying myself: my openname is ${username}`, `verifying that +${username} is my bitcoin username`, `verifying that ${username} is my bitcoin username`, `verifying that ${username} is my openname`, `verifying that +${username} is my openname`, `verifying i am +${username} on my passcard`, `verifying that +${username} is my blockchain id`, `verifying that "${name}" is my aladin id`, `verifying that ${name} is my aladin id`, `verifying that &quot;${name}&quot; is my aladin id` ] : [ `verifying that "${name}" is my aladin id`, `verifying that ${name} is my aladin id`, `verifying that &quot;${name}&quot; is my aladin id` ]; for (let i = 0; i < verificationStyles.length; i++) { const verificationStyle = verificationStyles[i]; if (searchText.includes(verificationStyle)) { return true; } } if (username != null && searchText.includes('verifymyonename') && searchText.includes(`+${username}`)) { return true; } return false; } exports.containsValidProofStatement = containsValidProofStatement; /** * * @ignore */ function containsValidAddressProofStatement(proofStatement, address) { proofStatement = proofStatement.split(address)[0].toLowerCase() + address; const verificationStyles = [ `verifying my aladin id is secured with the address ${address}` ]; for (let i = 0; i < verificationStyles.length; i++) { const verificationStyle = verificationStyles[i]; if (proofStatement.includes(verificationStyle)) { return true; } } return false; } exports.containsValidAddressProofStatement = containsValidAddressProofStatement; //# sourceMappingURL=serviceUtils.js.map