SIWW
  • Sign-in with Wallet (SIWW)
  • Specifications
    • Abstract
    • Motivation
    • Open source libraries
    • Security considerations
  • Use Cases
    • NodeJS - Backend implementation
      • 1. Setup passport-wallet
      • 2. Connect to SIWW
      • 3. Manage your authentication token
      • 4. Add authentication routes
      • 5. Code the views
      • 6. Full sample app
      • 7. Debugging and Q&A
    • ReactJS - connect to backend
      • 1. Add a login route
      • 2. Redirect the route to your backend
    • JS - Native calls to SIWW libs
      • 1. Initialize SIWW client lib
      • 2. Connect to a Wallet
      • 3. Create a message
      • 4. Send a message
      • 5. React JS App
    • Authenticating as an end-user
      • 1. Have a wallet available
      • 2. Connecting and signing
Powered by GitBook
On this page
  1. Use Cases
  2. JS - Native calls to SIWW libs

3. Create a message

The async_createMessage function prepares a message ready for signing. If input params are incorrect, the function will fail, otherwise it will return a full message object, ready for consumption by the async_sendMessage API.

// Basic message required input params 
let objParam= {
    message: "A message for authenticating the user",
    version: "1.0",
    valid_for: 300, 
}

// Request the full message object ready to be signed by user
let objMsg = await this.siww.async_createMessage(_idWallet, objParam);

Note that a fully formed message object contains property/values as follows:

  • domain: string ; dns authority that is requesting the signing

  • address: string ; address performing the signing

  • message: string ; message statement that the user will sign

  • version: string ; version of the message

  • chain: string ; chain that is being queried

  • name: string ; name of wallet being queried

  • api: object ; specific wallet api for calling signMessage, or null if generic

  • issued_at: date ; when this message was created

  • valid_for: number ; how many seconds the message is valid (after issued_at)

  • nonce: number ; randomized number used to prevent replay attacks

Previous2. Connect to a WalletNext4. Send a message

Last updated 2 years ago