diff --git a/packages/backend/src/server/api/ApiServerService.ts b/packages/backend/src/server/api/ApiServerService.ts index 709a04460..356e14568 100644 --- a/packages/backend/src/server/api/ApiServerService.ts +++ b/packages/backend/src/server/api/ApiServerService.ts @@ -118,6 +118,7 @@ export class ApiServerService { 'hcaptcha-response'?: string; 'g-recaptcha-response'?: string; 'turnstile-response'?: string; + 'm-captcha-response'?: string; } }>('/signup', (request, reply) => this.signupApiService.signup(request, reply)); @@ -126,17 +127,18 @@ export class ApiServerService { username: string; password: string; token?: string; - signature?: string; - authenticatorData?: string; - clientDataJSON?: string; - credentialId?: string; - challengeId?: string; + credential?: AuthenticationResponseJSON; + 'hcaptcha-response'?: string; + 'g-recaptcha-response'?: string; + 'turnstile-response'?: string; + 'm-captcha-response'?: string; }; }>('/signin', (request, reply) => this.signinApiService.signin(request, reply)); fastify.post<{ Body: { credential?: AuthenticationResponseJSON; + context?: string; }; }>('/signin-with-passkey', (request, reply) => this.signinWithPasskeyApiService.signin(request, reply)); diff --git a/packages/frontend/src/components/MkSignin.vue b/packages/frontend/src/components/MkSignin.vue index 8ebdac022..abbff8e1f 100644 --- a/packages/frontend/src/components/MkSignin.vue +++ b/packages/frontend/src/components/MkSignin.vue @@ -76,7 +76,6 @@ import { computed, defineAsyncComponent, ref } from 'vue'; import { toUnicode } from 'punycode/'; import * as Misskey from 'misskey-js'; import { supported as webAuthnSupported, get as webAuthnRequest, parseRequestOptionsFromJSON } from '@github/webauthn-json/browser-ponyfill'; -import { SigninWithPasskeyResponse } from 'misskey-js/entities.js'; import { query, extractDomain } from '@@/js/url.js'; import { host as configHost } from '@@/js/config.js'; import MkDivider from './MkDivider.vue'; @@ -188,7 +187,7 @@ function onPasskeyLogin(): void { signing.value = true; if (webAuthnSupported()) { misskeyApi('signin-with-passkey', {}) - .then((res: SigninWithPasskeyResponse) => { + .then(res => { totpLogin.value = false; signing.value = false; queryingKey.value = true; @@ -219,7 +218,7 @@ async function queryPasskey(): Promise { credential: credential.toJSON(), context: passkey_context.value, }); - }).then((res: SigninWithPasskeyResponse) => { + }).then(res => { emit('login', res.signinResponse); return onLogin(res.signinResponse); }); diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index a5f12b41f..5f4792eb7 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -4,7 +4,9 @@ ```ts +import type { AuthenticationResponseJSON } from '@simplewebauthn/types'; import { EventEmitter } from 'eventemitter3'; +import type { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types'; // Warning: (ae-forgotten-export) The symbol "components" needs to be exported by the entry point index.d.ts // @@ -1162,7 +1164,19 @@ export type Endpoints = Overwrite; res: AdminRolesCreateResponse; diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 64ed90cbb..36b7f5bca 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -10,6 +10,7 @@ import { User, UserDetailedNotMe, } from './autogen/models.js'; +import type { AuthenticationResponseJSON, PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types'; export * from './autogen/entities.js'; export * from './autogen/models.js'; @@ -250,6 +251,7 @@ export type SignupRequest = { 'hcaptcha-response'?: string | null; 'g-recaptcha-response'?: string | null; 'turnstile-response'?: string | null; + 'm-captcha-response'?: string | null; } export type SignupResponse = MeDetailed & { @@ -269,17 +271,25 @@ export type SigninRequest = { username: string; password: string; token?: string; + credential?: AuthenticationResponseJSON; + 'hcaptcha-response'?: string | null; + 'g-recaptcha-response'?: string | null; + 'turnstile-response'?: string | null; + 'm-captcha-response'?: string | null; }; export type SigninWithPasskeyRequest = { - credential?: object; + credential?: AuthenticationResponseJSON; context?: string; }; +export type SigninWithPasskeyInitResponse = { + option: PublicKeyCredentialRequestOptionsJSON; + context: string; +}; + export type SigninWithPasskeyResponse = { - option?: object; - context?: string; - signinResponse?: SigninResponse; + signinResponse: SigninResponse; }; export type SigninResponse = { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5d7febbcc..53d5dbbde 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1289,6 +1289,9 @@ importers: packages/misskey-js: dependencies: + '@simplewebauthn/types': + specifier: 10.0.0 + version: 10.0.0 eventemitter3: specifier: 5.0.1 version: 5.0.1