1.0.30 • Published 1 year ago
srun4k-webauthn v1.0.30
srun4k-webauthn
vue 环境
引入
yarn add srun4k-webauthn
# or
npm i srun4k-webauthn
使用
import { srunWebAuthn } from 'srun4k-webauthn'
...
const auth = new srunWebAuthn({
serverApi: 'https://127.0.0.1:80', // 后台请求地址
requestConf: {
webauthnStatus: { // 查询是否注册webauthn API
api: '/webauthnStatus'
},
registerBegin: { // 开始注册 API
api: '/registerBegin'
},
registerFinish: { // 执行注册 API
api: '/registerFinish',
params: {} // 个性化参数
},
loginBegin: { // 开始登陆 API
api: '/loginBegin'
},
loginFinish: { // 执行登陆 API
api: '/loginFinish',
params: {} // 个性化参数
}
},
getHeader: 'token', // 需要从login接口获取响应头就传,不用就不传
})
/** webauthn认证
username: 用户名
*/
auth.login(username, async (res: any) => {
if (res) {
// 成功回调
}
})
/** 新增设备
username: 用户名
*/
auth.register(username, async (res: any) => {
if (res) {
// 成功回调
}
})
非vue环境
引入
<script src="../src/window.js"></script>
使用
const auth = new srunWebAuthn({
serverApi: 'https://127.0.0.1:80', // 后台请求地址
requestConf: {
webauthnStatus: { // 查询是否注册webauthn API
api: '/webauthnStatus'
},
registerBegin: { // 开始注册 API
api: '/registerBegin'
},
registerFinish: { // 执行注册 API
api: '/registerFinish',
params: {}
},
loginBegin: { // 开始登陆 API
api: '/loginBegin'
},
loginFinish: { // 执行登陆 API
api: '/loginFinish',
params: {}
}
},
getHeader: 'token', // 需要从login接口获取响应头就传,不用就不传
})
/**
username: 用户名
*/
auth.login({
username: this.user.user,
// 成功回调
func: async (res: any) => {
if (res) {
const auth = res.token;
await this.store.saveLoginMethod('authn');
await this.user_store.saveAuth(auth);
await this.user_store.saveUser(this.user.user);
this.$router.push('/apps');
}
},
// 错误回调
err: (err: any, flag: string) => {
if (flag === 'register') {
this.$q.dialog({
title: '注册失败',
message: '请检查当前网络环境'
})
}
}
})
1.0.26
1 year ago
1.0.25
1 year ago
1.0.24
1 year ago
1.0.23
1 year ago
1.0.29
1 year ago
1.0.28
1 year ago
1.0.27
1 year ago
1.0.30
1 year ago
1.0.22
1 year ago
1.0.21
1 year ago
1.0.20
1 year ago
1.0.19
1 year ago
1.0.14
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago