localStorage Management

saveKey(sid)

This method saves the contents of the identity payload in the localStorage.

keyExist()

This method checks if a key exists in the localStorage and returns its public address.

const scrypta = window.ScryptaCore
let address = await scrypta.keyExist()

readKey(password, key = '')

This method allows to decrypt the identity payload saved in the localStorage (by default). It is also possible to pass a payload in the key parameter and decrypt the specified key. If the password is wrong, the method returns false. If the password is correct it returns the whole payload in the clear.

const scrypta = window.ScryptaCore
let payload = "LLLjx7yV4nhUzSapBAHogb5BdgUR6VCB3o:d287884b4af9e3e844da643646cb17e364cffc018f3704dfe5db1e04429b6a26986c0151a1008403209e6087ba3eaf75c79544ea93437053f60eb527dabba4acee76fad8e9821c4ce3e5cc54e04b0baa100476fb6010a9c426f8372bc9a4f67297244737f9631e02655fff1f10d04fce8f22743b623f024144f1efc7bc91cc3604e8a87a8f080cde7ef140c9f2c1b93d6d5fe275293cc33e8adae78a63ce63e84250fa59e75fb016cb2f4b3871ed32e0e182b56ec4f6578065f782e961606b3e"
let password = 'AStrongPassword'
let id = await scrypta.readKey(password, payload)
/*
{
"pub":"LLLjx7yV4nhUzSapBAHogb5BdgUR6VCB3o",
"api_secret":"33239857dbe3d37fd35b807578a0132b",
"key":"03097163386854cde5801aec574948e15b9e24c79da65414d4e5588e7140846165",
"prv":"SnvpeER7kdeMFGRimBzV5EJfX2ZfxmAQwin1qAHD2kXb8XRF983g",
"walletstore":"LLLjx7yV4nhUzSapBAHogb5BdgUR6VCB3o:d287884b4af9e3e844da643646cb17e364cffc018f3704dfe5db1e04429b6a26986c0151a1008403209e6087ba3eaf75c79544ea93437053f60eb527dabba4acee76fad8e9821c4ce3e5cc54e04b0baa100476fb6010a9c426f8372bc9a4f67297244737f9631e02655fff1f10d04fce8f22743b623f024144f1efc7bc91cc3604e8a87a8f080cde7ef140c9f2c1b93d6d5fe275293cc33e8adae78a63ce63e84250fa59e75fb016cb2f4b3871ed32e0e182b56ec4f6578065f782e961606b3e"
}
*/

forgetKey()

It deletes the key from the localStorage.

Attention, this operation is irreversible and no confirmation from the library is required. Use the necessary precautions so that the key is not destroyed forever.