mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
Finally done bugfixing for now for alias & PIN authrecall
This commit is contained in:
parent
e75854b73e
commit
0eb32c0e2d
15
sea.js
15
sea.js
@ -506,23 +506,26 @@
|
||||
const props = args || parseProps(await seaRead(remember, pub, true))
|
||||
let { pin, alias: aLias } = props
|
||||
|
||||
return (!pin && alias === aLias)
|
||||
const data = (!pin && alias === aLias)
|
||||
// No PIN, let's try short-term proof if for matching alias
|
||||
? await checkRememberData(props)
|
||||
// Got PIN so get IndexedDB secret if signature is ok
|
||||
: await checkRememberData(await readAndDecrypt(await seaIndexedDb.get(alias, 'auth'), pub, pin))
|
||||
pin = pin || data.pin
|
||||
delete data.pin
|
||||
return { pin, data }
|
||||
}
|
||||
// got pub, try auth with pin & alias :: or unwrap Storage data...
|
||||
const args = await readStorageData(pin && { pin, alias })
|
||||
const { proof } = args || {}
|
||||
const { data, pin: newPin } = await readStorageData(pin && { pin, alias })
|
||||
const { proof } = data || {}
|
||||
|
||||
if (!proof) {
|
||||
if (!args) {
|
||||
if (!data) {
|
||||
err = 'No valid authentication session found!'
|
||||
return
|
||||
}
|
||||
try { // Wipes IndexedDB silently
|
||||
await updatestorage()(args)
|
||||
await updatestorage()(data)
|
||||
} catch (e) {} //eslint-disable-line no-empty
|
||||
err = 'Expired session!'
|
||||
return
|
||||
@ -539,7 +542,7 @@
|
||||
const { epub } = at.put
|
||||
// Success! we've found our private data!
|
||||
err = null
|
||||
return { proof, at, pin, key: { pub, priv, epriv, epub } }
|
||||
return { proof, at, pin: newPin, key: { pub, priv, epriv, epub } }
|
||||
} catch (e) {
|
||||
err = 'Failed to decrypt private key!'
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user