@metomic/alias-core
v0.3.0
Published
## What is this? Client-side (web) javascript library and UI elements that create a metomic alias for a given email.
Downloads
2
Maintainers
Keywords
Readme
alias-core
What is this?
Client-side (web) javascript library and UI elements that create a metomic alias for a given email.
When should I use it?
Probably only if you're writing a library that provides metomic alias functionality in your chosen framework.
For an example, see @metomic/alias-react
How do I use it?
You probably don't want to - there's likely a higher level library. But if you're sure:
importing
import {
Alias,
EncryptionOverlay,
AliasToggle
} from '@metomic/alias-core
constructing an alias (no ui)
Alias({ appId: 'zx123' }).secure("[email protected]")
.then( ... )
mutably binding to an input element
const run = Alias.dom.bindToInput(appId, purpose, inputElement, (state) => {
/* optional state-change callback here. Options:
state = { status: 'loading' }
state = { status: 'error', error: 'error' }
state = { status: 'complete', result: 'alias@metomic' }
state = { status: 'reset', result: 'original-email' }
*/
})
run(true) // performs securing action on input
run(false) // reverts securing action on input
manually managing entire flow
const overlay = Alias.dom.createOverlayController(inputEl)
const { doToggle } = createSecuringContext(appId, purpose, inputEl, function onStateChange(state){
// deal with states
overlay.setActive(state === 'loading')
})
doToggle(true) // triggers securing action on input
doToggle(false) // reverts securing action on input