# All files / src/profiles/services serviceUtils.ts

88.24% Statements 15/17
50% Branches 2/4
100% Functions 2/2
88.24% Lines 15/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78

    1x

    12x

    1x

    11x

    10x

    11x
    77x

    8x

    3x

    1x
    12x

    12x
    12x

    6x

    6x

     /**
     *
     * @ignore
     */
    export function containsValidProofStatement(searchText: string, name: string | null = null) {
      if (!name) {
        return false
      }

      searchText = searchText.toLowerCase()

      if (name.split('.').length < 2) {
        throw new Error('Please provide the fully qualified Blockstack name.')
      }

      let username = null

      // support legacy Blockstack 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 blockstack id`, // id
        `verifying that ${name} is my blockstack id`,
        `verifying that &quot;${name}&quot; is my blockstack id`
      ] : [ // only these formats are valid for non-.id tlds
        `verifying that "${name}" is my blockstack id`, // id
        `verifying that ${name} is my blockstack id`,
        `verifying that &quot;${name}&quot; is my blockstack 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
    }

    /**
     *
     * @ignore
     */
    export function containsValidAddressProofStatement(proofStatement: string, address: string) {
      proofStatement = proofStatement.split(address)[0].toLowerCase() + address

      const verificationStyles = [
        `verifying my blockstack 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
    }