
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@startupjs/2fa
Advanced tools
Сomponent of two-factor authentication
yarn add @startupjs/2fa
In server/index.js
add next strings:
import { init2fa } from '@startupjs/2fa/server'
import app from '../app.json'
In startupjsServer
function add:
init2fa(ee, { appName: app.name })
import { createSecret, getSecret, QRSecret, CheckToken } from '@startupjs/2fa'
export default function MyComponent() {
const [secret, setSecret] = useState({})
async function onCreateSecret () {
const secret = await createSecret()
setSecret(secret)
}
async function onGetSecret () {
try {
const secret = await getSecret()
secret && setSecret(secret)
} catch (err) {
console.log('err: ', err)
}
}
return (
<View style={styles.root}>
<View style={styles.row}>
<Button
style={styles.button}
title="Create secret"
onPress={onCreateSecret}
/>
<Button
style={styles.button}
title="Get created secret"
onPress={onGetSecret}
/>
</View>
{secret.QRDataURL && <QRSecret style={styles.qr} />}
{secret.QRDataURL && <CheckToken onSuccess={() => alert('Right code')} onDismiss={() => alert('Wrong code')} />}
</View>
)
}
const styles = StyleSheet.create({
root: {
flex: 1,
alignItems: 'center'
},
row: {
minWidth: 320,
flexDirection: 'row',
justifyContent: 'space-around'
},
qr: {
width: 100,
height: 100
}
})
createSecret
- returns a Promise
which creates a request to create a Secret
(if secret exists it will be replaced by new secret) and returns the result:
{ base32, QRDataURL }
here:
base32
- your Secret codeQRDataURL
- QR code that you can use like imagecheckToken(token)
- return true
if token is valid and false
otherwise
getSecret
- return already created secret (if secret does not exist there will throw error) in format like in createSecret
.
You can use this component for show QR code of existing secret. If secret does not exist there will show nothing.
Simple token validation. There are props:
style
- styles of root componentlabel
- input labelonSuccess
- valid token callbackonDismiss
- invalid token callbackFAQs
Two factor authentication module
The npm package @startupjs/2fa receives a total of 3 weekly downloads. As such, @startupjs/2fa popularity was classified as not popular.
We found that @startupjs/2fa demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.