# All files / src index.js

33.33% Statements 3/9
28.57% Branches 2/7
50% Functions 1/2
33.33% Lines 3/9

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

    1x

    1x

    1x

     /* @flow */

    import queryString from 'query-string'

    // TODO: Putting in here so it executes ASAP. There is probably a better place to put this.
    // Note: This prototype is designed to work as a drop-in-replacement (non-breaking upgrade)
    // for apps using blockstack.js. That requires doing this hacky global & immediate detection.
    // A more proper approach would require developers to call an additional blockstack.js method
    // for invoking this detection method.
    (function protocolEchoReplyDetection() {
      // Check that the `window` APIs exist
      Eif (typeof window !== 'object' || !window.location || !window.localStorage) {
        // Exit detection function - we are not running in a browser environment.
        return
      }
      // Check if the location query string contains a protocol-echo reply.
      // If so, this page was only re-opened to signal back the originating
      // tab that the protocol handler is installed.
      const queryDict = queryString.parse(window.location.search)
      if (queryDict.echoReply) {
        // Use localStorage to notify originated tab that protocol handler is available and working.
        const echoReplyKey = `echo-reply-${queryDict.echoReply}`
        // Set the echo-reply result in localStorage for the other window to see.
        window.localStorage.setItem(echoReplyKey, 'success')
        // Redirect back to the localhost auth url, as opposed to another protocol launch.
        // This will re-use the same tab rather than creating another useless one.
        window.setTimeout(() => {
          window.location = decodeURIComponent(queryDict.authContinuation)
        }, 10)
      }
    }())

    export * from './auth'
    export * from './profiles'
    export * from './storage'

    export {
      makeDIDFromAddress, makeDIDFromPublicKey, getDIDType, getAddressFromDID
    } from './dids'

    export {
      getEntropy, makeECPrivateKey, publicKeyToAddress, getPublicKeyFromPrivate
    } from './keys'

    export {
      nextYear, nextMonth, nextHour, makeUUID4, updateQueryStringParameter,
      isLaterVersion, isSameOriginAbsoluteUrl, hexStringToECPair, ecPairToHexString,
      ecPairToAddress
    } from './utils'

    export {
      transactions, safety, TransactionSigner,
      PubkeyHashSigner, addUTXOsToFund, estimateTXBytes
    } from './operations'

    export { BlockstackWallet, IdentityKeyPair } from './wallet'

    export { network } from './network'

    export { decodeToken } from 'jsontokens'

    export { config } from './config'

    export { encryptMnemonic, decryptMnemonic } from './encryption'

    export { UserSession }  from './auth/userSession'