l3wi / mam.client.js

Masked Authentication Messaging wrapper for Javascript (Browser and Node)
GNU General Public License v3.0
15 stars 51 forks source link

A bug on Mam.fetch function #18

Closed yehia67 closed 4 years ago

yehia67 commented 5 years ago

I call an async funtcion to fetch restricted mama message

const root = 'DOGDHTBWAKNZEVF9RPFPMLPNUZFUNHOCVESK9HFXRCJKATXBCPXKNYHHSQW9XCWRAM9JDPFWEBDUBZHRO' //root address
await FetchMamRestricted.execute(root)

no output will appear.But if I write

await FetchMamRestricted.execute('DOGDHTBWAKNZEVF9RPFPMLPNUZFUNHOCVESK9HFXRCJKATXBCPXKNYHHSQW9XCWRAM9JDPFWEBDUBZHRO') //root address It work!! Could anyone tell me how I could make it work using 'root' variable? Thanks in advance.

I know JavaScript language doesn't behave this way. What I think about the problem is the FetchMamRestricted.execute('DOGDHTBWAKNZEVF9RPFPMLPNUZFUNHOCVESK9HFXRCJKATXBCPXKNYHHSQW9XCWRAM9JDPFWEBDUBZHRO') content is:

const execute = async (_root) => {
  // Callback used to pass data + returns next_root
  console.log("inside function root is",_root) // outptut 'something'
  const resp = await Mam.fetch(_root, mamType, mamSecret, logData)
}

I think the function Mam.fetch(_root, mamType, mamSecret, logData) have a bug(it's a build in function) on checking the first parameter using something like '==' not '==='.So it won't work unless I parse the string between '' to the parameter.

yehia67 commented 5 years ago

I asked the question on stalkoverflow: https://stackoverflow.com/questions/58100720/what-is-the-difference-between-string-constant-and-string-between-quotes-a
the full source code : https://github.com/yehia67/javascript-iota-workshop/blob/master/code/Send%20ID/fetchID.js