Authorize

Pull up MYKEY for authentication binding. See the class definition for the parameters: AuthorizeRequest and MYKEYWalletCallback

For better security, dapp can set CallBackUrl for server-side verification.

MYKEY will post the signed data to CallBackUrl which provided by dapp, server-side of DApp should verify the signature, dapp server should query the user's ReserveKey from MYKEY SmartContract data to verify the signature, see detail in KEYS in MYKEY.

The format of the data post to CallBackUrl:

{
    "protocol":"",  // protocol name,Use init method, protocol name is 'MYKEY', use initSimple to init, protocol name is 'MYKEYSimple'
    "version":"",   // Version,1.0
    "dapp_key":"",  // DAPP_KEY assigned by MYKEY,contact MYKEY team to apply. In simple mode, it is null
    "uuID":"",      // user id,dapp passed it in init method;In simple mode, it is device id
    "sign":"",      // eos signature, sign data:timestamp + account + uuID + ref
    "ref":"",       // ref, mykey
    "timestamp":"", // UNIX timestamp, accurate to second
    "account":"",    // eos account name
    "chain": ""      // value could be ANY, EOS, ETH,or not pass this param
}

Verify signature:

MYKEY will return mykeyUID and mykeyUIDSignature fields. mykeyUID is the unique identifier for users in MYKEY.

// generate unsigned data
let message = hex(timestamp + account + uuID + ref)
let unsignedData =  "\x19Ethereum Signed Message:\n" + message.length + message

// generate unsigned data for mykeyUID
let messageForMykeyUID = timestamp + account + uuID + ref + mykeyUID
let unsignedDataForMykeyUID =  "\x19Ethereum Signed Message:\n" + messageForMykeyUID.length + messageForMykeyUID

Response format:

Sample:

Last updated

Was this helpful?