# PostMessage API

You can still use Inkey without Algonaut.js, but you will have to send & receive messages back and forth between the iframe manually. It shouldn't take much time to write a small utility to communicate with the iframe in the language of your choice, assuming it implements the PostMessage API.

# Message format

const data = {
    source: 'ncc-inkey-client' || 'ncc-inkey-wallet',
    type: 'connect' // determines what the payload structure looks like
    payload: {},
    uuid: new Date(), // used to match responses w/ initial messages
    async: true // tells algonaut to wait for a response to its message to inkey
};

walletWindow.postMessage(data, 'https://inkey.app/');

# Full list of messages

# Connect to Inkey

const data = {
    source: 'ncc-inkey-client',
    uuid: new Date(),
    async: true,
    type: 'connect'
}
const data = {
    source: 'ncc-inkey-wallet',
    uuid: 123456789, // same id received above
    async: true,
    payload: {
        address: '<address of logged in user>'
    }
}

# Disconnect from Inkey

const data = {
    source: 'ncc-inkey-client',
    uuid: new Date(),
    async: true,
    type: 'disconnect'
}
const data = {
    source: 'ncc-inkey-wallet',
    uuid: 123456789, // same id received above
    async: true,
    type: 'disconnect',
    payload: {
        success: true
    }
}

# Request to Sign Transaction(s)

const data = {
    source: 'ncc-inkey-client',
    uuid: new Date(),
    async: true,
    type: 'sign-txns',
    payload: {
        // array of base64 encoded unsigned transactions
        txns: [txn1, txn2, txn3] 
    }
}
const data = {
    source: 'ncc-inkey-wallet',
    uuid: 123456789, // same id received above
    async: true,
    type: 'sign-txns',
    payload: {
        // array of base64-encoded signed transactions
        signedTxns: [txn1, txn2, txn3]
    }
}

# Hide Inkey

You should handle a hide message coming from Inkey by hiding the containing iframe. In Algonaut.js, we handle this by adding & removing a visible class. You can see that in action in the FrameBus.ts file.

That message looks like this:

const data = {
    source: 'ncc-inkey-wallet',
    type: 'hide'
}