mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-23 12:07:38 +00:00
fix: bitwarden passkey reigster error
This commit is contained in:
@@ -8,7 +8,9 @@ for (let i = 0; i < chars.length; i++) {
|
|||||||
|
|
||||||
const encode = function(arraybuffer) {
|
const encode = function(arraybuffer) {
|
||||||
const bytes = new Uint8Array(arraybuffer)
|
const bytes = new Uint8Array(arraybuffer)
|
||||||
let i; const len = bytes.length; let base64url = ''
|
let i
|
||||||
|
const len = bytes.length
|
||||||
|
let base64url = ''
|
||||||
|
|
||||||
for (i = 0; i < len; i += 3) {
|
for (i = 0; i < len; i += 3) {
|
||||||
base64url += chars[bytes[i] >> 2]
|
base64url += chars[bytes[i] >> 2]
|
||||||
@@ -17,7 +19,7 @@ const encode = function(arraybuffer) {
|
|||||||
base64url += chars[bytes[i + 2] & 63]
|
base64url += chars[bytes[i + 2] & 63]
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((len % 3) === 2) {
|
if (len % 3 === 2) {
|
||||||
base64url = base64url.substring(0, base64url.length - 1)
|
base64url = base64url.substring(0, base64url.length - 1)
|
||||||
} else if (len % 3 === 1) {
|
} else if (len % 3 === 1) {
|
||||||
base64url = base64url.substring(0, base64url.length - 2)
|
base64url = base64url.substring(0, base64url.length - 2)
|
||||||
@@ -28,8 +30,13 @@ const encode = function(arraybuffer) {
|
|||||||
|
|
||||||
const decode = function(base64string) {
|
const decode = function(base64string) {
|
||||||
const bufferLength = base64string.length * 0.75
|
const bufferLength = base64string.length * 0.75
|
||||||
const len = base64string.length; let i; let p = 0
|
const len = base64string.length
|
||||||
let encoded1; let encoded2; let encoded3; let encoded4
|
let i
|
||||||
|
let p = 0
|
||||||
|
let encoded1
|
||||||
|
let encoded2
|
||||||
|
let encoded3
|
||||||
|
let encoded4
|
||||||
|
|
||||||
const bytes = new Uint8Array(bufferLength)
|
const bytes = new Uint8Array(bufferLength)
|
||||||
|
|
||||||
@@ -47,15 +54,16 @@ const decode = function(base64string) {
|
|||||||
return bytes.buffer
|
return bytes.buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicKeyCredentialToJSON = (pubKeyCred) => {
|
const publicKeyCredentialToJSON = pubKeyCred => {
|
||||||
if (pubKeyCred instanceof Array) {
|
if (pubKeyCred instanceof Array) {
|
||||||
const arr = []
|
const arr = []
|
||||||
for (const i of pubKeyCred) { arr.push(publicKeyCredentialToJSON(i)) }
|
for (const i of pubKeyCred) {
|
||||||
|
arr.push(publicKeyCredentialToJSON(i))
|
||||||
|
}
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pubKeyCred instanceof ArrayBuffer) {
|
if (pubKeyCred instanceof ArrayBuffer || pubKeyCred instanceof Uint8Array) {
|
||||||
return encode(pubKeyCred)
|
return encode(pubKeyCred)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,8 +81,7 @@ const publicKeyCredentialToJSON = (pubKeyCred) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
'decode': decode,
|
decode: decode,
|
||||||
'encode': encode,
|
encode: encode,
|
||||||
'publicKeyCredentialToJSON': publicKeyCredentialToJSON
|
publicKeyCredentialToJSON: publicKeyCredentialToJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user