mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
code refactor
This commit is contained in:
+4
-4
@@ -61,13 +61,13 @@ function registerCredential({ username, nickname }, userSecret) {
|
|||||||
|
|
||||||
const challenge = utils.generateRandomString();
|
const challenge = utils.generateRandomString();
|
||||||
const publicKeyCredentialCreationOptions = Object.assign({}, PUBLIC_KEY_CREDENTIAL_CREATION_OPTIONS_TEMPLATE, {
|
const publicKeyCredentialCreationOptions = Object.assign({}, PUBLIC_KEY_CREDENTIAL_CREATION_OPTIONS_TEMPLATE, {
|
||||||
challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)),
|
challenge: utils.stringToArrayBuffer(challenge),
|
||||||
rp: {
|
rp: {
|
||||||
name: window.location.hostname,
|
name: window.location.hostname,
|
||||||
id: window.location.hostname
|
id: window.location.hostname
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
id: Uint8Array.from(userSecret, c => c.charCodeAt(0)),
|
id: utils.stringToArrayBuffer(userSecret),
|
||||||
name: username,
|
name: username,
|
||||||
displayName: nickname
|
displayName: nickname
|
||||||
}
|
}
|
||||||
@@ -140,10 +140,10 @@ function verifyCredential(credentialId) {
|
|||||||
|
|
||||||
const challenge = utils.generateRandomString();
|
const challenge = utils.generateRandomString();
|
||||||
const publicKeyCredentialRequestOptions = Object.assign({}, PUBLIC_KEY_CREDENTIAL_REQUEST_OPTIONS_TEMPLATE, {
|
const publicKeyCredentialRequestOptions = Object.assign({}, PUBLIC_KEY_CREDENTIAL_REQUEST_OPTIONS_TEMPLATE, {
|
||||||
challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)),
|
challenge: utils.stringToArrayBuffer(challenge),
|
||||||
rpId: window.location.hostname
|
rpId: window.location.hostname
|
||||||
});
|
});
|
||||||
publicKeyCredentialRequestOptions.allowCredentials[0].id = Uint8Array.from(atob(credentialId), c=>c.charCodeAt(0)).buffer;
|
publicKeyCredentialRequestOptions.allowCredentials[0].id = utils.stringToArrayBuffer(atob(credentialId));
|
||||||
|
|
||||||
logger.debug('webauthn get options', publicKeyCredentialRequestOptions);
|
logger.debug('webauthn get options', publicKeyCredentialRequestOptions);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user