From 234294d564f49b1926ebf4a74d418e419ea4da71 Mon Sep 17 00:00:00 2001
From: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com>
Date: Sat, 9 May 2020 08:20:22 +0900
Subject: [PATCH] =?UTF-8?q?WebAuthn=E3=81=A7=E3=83=AD=E3=82=B0=E3=82=A4?=
=?UTF-8?q?=E3=83=B3=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E3=81=AE=E3=82=92?=
=?UTF-8?q?=E4=BF=AE=E6=AD=A3=20(#6327)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Resolve #6319
---
locales/ja-JP.yml | 2 +-
src/client/components/signin.vue | 17 +++++--------
src/client/pages/my-settings/2fa.vue | 23 ++++++------------
src/client/scripts/2fa.ts | 36 ++++++++++++++++++++++++----
4 files changed, 46 insertions(+), 32 deletions(-)
diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index ce9b0dcd6b..5bc9784925 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -414,7 +414,7 @@ passwordMatched: "一致しました"
passwordNotMatched: "一致していません"
signinWith: "{x}でログイン"
signinFailed: "ログインできませんでした。ユーザー名とパスワードを確認してください。"
-tapSecurityKey: "セキュリティーキーにタッチ"
+tapSecurityKey: "セキュリティキーにタッチ"
or: "もしくは"
uiLanguage: "UIの表示言語"
groupInvited: "グループに招待されました"
diff --git a/src/client/components/signin.vue b/src/client/components/signin.vue
index b84b89a5c7..dc73ad8a0f 100755
--- a/src/client/components/signin.vue
+++ b/src/client/components/signin.vue
@@ -51,7 +51,7 @@ import MkButton from './ui/button.vue';
import MkInput from './ui/input.vue';
import i18n from '../i18n';
import { apiUrl, host } from '../config';
-import { hexifyAB } from '../scripts/2fa';
+import { byteify, hexify } from '../scripts/2fa';
export default Vue.extend({
i18n,
@@ -121,14 +121,9 @@ export default Vue.extend({
this.queryingKey = true;
return navigator.credentials.get({
publicKey: {
- challenge: Buffer.from(
- this.challengeData.challenge
- .replace(/\-/g, '+')
- .replace(/_/g, '/'),
- 'base64'
- ),
+ challenge: byteify(this.challengeData.challenge, 'base64'),
allowCredentials: this.challengeData.securityKeys.map(key => ({
- id: Buffer.from(key.id, 'hex'),
+ id: byteify(key.id, 'hex'),
type: 'public-key',
transports: ['usb', 'nfc', 'ble', 'internal']
})),
@@ -143,9 +138,9 @@ export default Vue.extend({
return this.$root.api('signin', {
username: this.username,
password: this.password,
- signature: hexifyAB(credential.response.signature),
- authenticatorData: hexifyAB(credential.response.authenticatorData),
- clientDataJSON: hexifyAB(credential.response.clientDataJSON),
+ signature: hexify(credential.response.signature),
+ authenticatorData: hexify(credential.response.authenticatorData),
+ clientDataJSON: hexify(credential.response.clientDataJSON),
credentialId: credential.id,
challengeId: this.challengeData.challengeId
});
diff --git a/src/client/pages/my-settings/2fa.vue b/src/client/pages/my-settings/2fa.vue
index 1d1e111dac..6ceca21fe6 100644
--- a/src/client/pages/my-settings/2fa.vue
+++ b/src/client/pages/my-settings/2fa.vue
@@ -22,12 +22,12 @@