stellar-expert / albedo

Security-centric, developer-friendly, easy-to-use delegated signer and keystore for Stellar Network
https://albedo.link
MIT License
64 stars 14 forks source link

tx intent flow broken for Safari #30

Closed kalepail closed 3 years ago

kalepail commented 3 years ago

Getting this error trying to use the intent flow for a tx intent. Works fine in Chrome.

Screen Shot 2020-10-02 at 9 31 59 PM
kalepail commented 3 years ago
{
  "message": "Unhandled error occurred. If this error persists, please contact Albedo support.",
  "code": -1
}
orbitlens commented 3 years ago

We tested on both Mac and iOS with default values from the playground and everything seems to work well. Could you please try to sign a tx in the implicit mode using the playground UI and let me know if you spot any other problems.

Also, please check the network when you are calling the intent. Session granted for the "testnet" won't be valid for "public" network.

kalepail commented 3 years ago

Works fine in the playground. Definitely using the correct network, again works fine on Chrome.

Here's the xdr I'm trying to sign.

AAAAAgAAAABxVBxhMby8zkB3+nXlT1B3bZZVVPACgoyltPaeduz5zAAAASwADeyAAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAABAAAAALPF/AGs1yfqdWWMZk1JKn4K7GXxgtLfw7sIi2atRTuzAAAAAQAAAABxVBxhMby8zkB3+nXlT1B3bZZVVPACgoyltPaeduz5zAAAAAAAAAAAlQL5AAAAAAAAAAAGAAAAAlNRMDAwMQAAAAAAAAAAAABlNnoKbiDR//fMdiS32OpAvBmrJ0C+ioHjsPxq/he1VwAAAAAAAAABAAAAAQAAAABlNnoKbiDR//fMdiS32OpAvBmrJ0C+ioHjsPxq/he1VwAAAAEAAAAAcVQcYTG8vM5Ad/p15U9Qd22WVVTwAoKMpbT2nnbs+cwAAAACU1EwMDAxAAAAAAAAAAAAAGU2egpuINH/98x2JLfY6kC8GasnQL6KgeOw/Gr+F7VXAAAAAAAAAAEAAAAAAAAAAv4XtVcAAABA/Xk0t7kKfmMNBPXoQrPy90jCC4TzaxVijNy+30vj3nF7ae7cqv7117eM3CZJUXTIje01ifGqCyFnXoJxB7AJAa1FO7MAAABAb9rVjTpTAFk2NmesLJhd6b0yKnzqdaZsFBRqJ5+fOXjZ3ewzcMSrYikertxUobDTyQ5g1DmJr8G2phPeXeinAg==
kalepail commented 3 years ago

fwiw That XDR works and signs perfectly on the playground. Must be a cross origin popup thing?

kalepail commented 3 years ago
async claimPrize(e, key) {
  e.preventDefault()

  if (!this.user.name)
    this.user.name = prompt(`In order to run a compliant competition we need your full name`)

  if (!this.user.name)
    return

  this.error = false
  this.loading = {[`claim-${key}`]: true}

  let albedoSessionPuk = loFirst(
    loMap(loMap(loFilter(loKeys(sessionStorage),
        (key) => loStartsWith(key, 'albedo_session_')
      ), (key) => JSON.parse(sessionStorage.getItem(key))
    ), ({pubkey}) => pubkey)
  )

  if (!albedoSessionPuk) albedoSessionPuk = await albedo.implicitFlow({
    intents: 'tx',
    network: 'testnet'
  }).then(({pubkey}) => pubkey)

  fetch(`${baseUrl}/prize/submit`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${this.session}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      key,
      name: this.user.name,
      puk: albedoSessionPuk,
    })
  })
  .then(handleResponse)
  .then(({xdr}) => {
    console.log(albedoSessionPuk)
    console.log(xdr)

    return albedo.tx({
      xdr,
      pubkey: albedoSessionPuk,
      network: 'testnet',
    })
  })
  .then(({signed_envelope_xdr}) =>
    fetch(`${baseUrl}/prize/submit`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${this.session}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        key,
        name: this.user.name,
        puk: albedoSessionPuk,
        innerTx: signed_envelope_xdr,
      })
    })
  )
  .then(handleResponse)
  .then(async () => {
    // TODO: Due to latency we need to save the claim status client side
    // await this.updateSession()

    this.success = {...this.success, [`claim-${key}`]: true}
  })
  .catch((err) => {
    this.error = err

    if (err.code === 1)
      sessionStorage.removeItem(`albedo_session_${albedoSessionPuk}`)
  })
  .finally(() => this.loading = {...this.loading, [`claim-${key}`]: false})
}
0001jb commented 3 years ago

Hi, I have a similar issue where I am using an iPhone to transfer XLM to a Bitstamp account and the transaction never gets validated. Is there anyone who could help me here? Thanks in advance.

orbitlens commented 3 years ago

@0001jb answered here.