0
0

fix(misskey-js): type fixes related to signup and signin (#14679)

This commit is contained in:
zyoshoka 2024-10-03 18:33:56 +09:00 committed by GitHub
parent 2c1a7470d3
commit 2a4ab0e187
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 73 additions and 20 deletions

View File

@ -118,6 +118,7 @@ export class ApiServerService {
'hcaptcha-response'?: string; 'hcaptcha-response'?: string;
'g-recaptcha-response'?: string; 'g-recaptcha-response'?: string;
'turnstile-response'?: string; 'turnstile-response'?: string;
'm-captcha-response'?: string;
} }
}>('/signup', (request, reply) => this.signupApiService.signup(request, reply)); }>('/signup', (request, reply) => this.signupApiService.signup(request, reply));
@ -126,17 +127,18 @@ export class ApiServerService {
username: string; username: string;
password: string; password: string;
token?: string; token?: string;
signature?: string; credential?: AuthenticationResponseJSON;
authenticatorData?: string; 'hcaptcha-response'?: string;
clientDataJSON?: string; 'g-recaptcha-response'?: string;
credentialId?: string; 'turnstile-response'?: string;
challengeId?: string; 'm-captcha-response'?: string;
}; };
}>('/signin', (request, reply) => this.signinApiService.signin(request, reply)); }>('/signin', (request, reply) => this.signinApiService.signin(request, reply));
fastify.post<{ fastify.post<{
Body: { Body: {
credential?: AuthenticationResponseJSON; credential?: AuthenticationResponseJSON;
context?: string;
}; };
}>('/signin-with-passkey', (request, reply) => this.signinWithPasskeyApiService.signin(request, reply)); }>('/signin-with-passkey', (request, reply) => this.signinWithPasskeyApiService.signin(request, reply));

View File

@ -76,7 +76,6 @@ import { computed, defineAsyncComponent, ref } from 'vue';
import { toUnicode } from 'punycode/'; import { toUnicode } from 'punycode/';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { supported as webAuthnSupported, get as webAuthnRequest, parseRequestOptionsFromJSON } from '@github/webauthn-json/browser-ponyfill'; 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 { query, extractDomain } from '@@/js/url.js';
import { host as configHost } from '@@/js/config.js'; import { host as configHost } from '@@/js/config.js';
import MkDivider from './MkDivider.vue'; import MkDivider from './MkDivider.vue';
@ -188,7 +187,7 @@ function onPasskeyLogin(): void {
signing.value = true; signing.value = true;
if (webAuthnSupported()) { if (webAuthnSupported()) {
misskeyApi('signin-with-passkey', {}) misskeyApi('signin-with-passkey', {})
.then((res: SigninWithPasskeyResponse) => { .then(res => {
totpLogin.value = false; totpLogin.value = false;
signing.value = false; signing.value = false;
queryingKey.value = true; queryingKey.value = true;
@ -219,7 +218,7 @@ async function queryPasskey(): Promise<void> {
credential: credential.toJSON(), credential: credential.toJSON(),
context: passkey_context.value, context: passkey_context.value,
}); });
}).then((res: SigninWithPasskeyResponse) => { }).then(res => {
emit('login', res.signinResponse); emit('login', res.signinResponse);
return onLogin(res.signinResponse); return onLogin(res.signinResponse);
}); });

View File

@ -4,7 +4,9 @@
```ts ```ts
import type { AuthenticationResponseJSON } from '@simplewebauthn/types';
import { EventEmitter } from 'eventemitter3'; 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 // 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<Endpoints_2, {
}; };
'signin-with-passkey': { 'signin-with-passkey': {
req: SigninWithPasskeyRequest; req: SigninWithPasskeyRequest;
res: SigninWithPasskeyResponse; res: {
$switch: {
$cases: [
[
{
context: string;
},
SigninWithPasskeyResponse
]
];
$default: SigninWithPasskeyInitResponse;
};
};
}; };
'admin/roles/create': { 'admin/roles/create': {
req: Overwrite<AdminRolesCreateRequest, { req: Overwrite<AdminRolesCreateRequest, {
@ -1196,6 +1210,7 @@ declare namespace entities {
SignupPendingResponse, SignupPendingResponse,
SigninRequest, SigninRequest,
SigninWithPasskeyRequest, SigninWithPasskeyRequest,
SigninWithPasskeyInitResponse,
SigninWithPasskeyResponse, SigninWithPasskeyResponse,
SigninResponse, SigninResponse,
PartialRolePolicyOverride, PartialRolePolicyOverride,
@ -3027,6 +3042,11 @@ type SigninRequest = {
username: string; username: string;
password: string; password: string;
token?: string; token?: string;
credential?: AuthenticationResponseJSON;
'hcaptcha-response'?: string | null;
'g-recaptcha-response'?: string | null;
'turnstile-response'?: string | null;
'm-captcha-response'?: string | null;
}; };
// @public (undocumented) // @public (undocumented)
@ -3035,17 +3055,21 @@ type SigninResponse = {
i: string; i: string;
}; };
// @public (undocumented)
type SigninWithPasskeyInitResponse = {
option: PublicKeyCredentialRequestOptionsJSON;
context: string;
};
// @public (undocumented) // @public (undocumented)
type SigninWithPasskeyRequest = { type SigninWithPasskeyRequest = {
credential?: object; credential?: AuthenticationResponseJSON;
context?: string; context?: string;
}; };
// @public (undocumented) // @public (undocumented)
type SigninWithPasskeyResponse = { type SigninWithPasskeyResponse = {
option?: object; signinResponse: SigninResponse;
context?: string;
signinResponse?: SigninResponse;
}; };
// @public (undocumented) // @public (undocumented)
@ -3069,6 +3093,7 @@ type SignupRequest = {
'hcaptcha-response'?: string | null; 'hcaptcha-response'?: string | null;
'g-recaptcha-response'?: string | null; 'g-recaptcha-response'?: string | null;
'turnstile-response'?: string | null; 'turnstile-response'?: string | null;
'm-captcha-response'?: string | null;
}; };
// @public (undocumented) // @public (undocumented)
@ -3346,7 +3371,7 @@ type UsersUpdateMemoRequest = operations['users___update-memo']['requestBody']['
// Warnings were encountered during analysis: // Warnings were encountered during analysis:
// //
// src/entities.ts:49:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts // src/entities.ts:50:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:220:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:220:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:230:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:230:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts

View File

@ -57,6 +57,7 @@
"built" "built"
], ],
"dependencies": { "dependencies": {
"@simplewebauthn/types": "10.0.0",
"eventemitter3": "5.0.1", "eventemitter3": "5.0.1",
"reconnecting-websocket": "4.4.0" "reconnecting-websocket": "4.4.0"
} }

View File

@ -5,6 +5,7 @@ import {
PartialRolePolicyOverride, PartialRolePolicyOverride,
SigninRequest, SigninRequest,
SigninResponse, SigninResponse,
SigninWithPasskeyInitResponse,
SigninWithPasskeyRequest, SigninWithPasskeyRequest,
SigninWithPasskeyResponse, SigninWithPasskeyResponse,
SignupPendingRequest, SignupPendingRequest,
@ -86,8 +87,20 @@ export type Endpoints = Overwrite<
}, },
'signin-with-passkey': { 'signin-with-passkey': {
req: SigninWithPasskeyRequest; req: SigninWithPasskeyRequest;
res: SigninWithPasskeyResponse; res: {
} $switch: {
$cases: [
[
{
context: string;
},
SigninWithPasskeyResponse,
],
];
$default: SigninWithPasskeyInitResponse;
},
},
},
'admin/roles/create': { 'admin/roles/create': {
req: Overwrite<AdminRolesCreateRequest, { policies: PartialRolePolicyOverride }>; req: Overwrite<AdminRolesCreateRequest, { policies: PartialRolePolicyOverride }>;
res: AdminRolesCreateResponse; res: AdminRolesCreateResponse;

View File

@ -10,6 +10,7 @@ import {
User, User,
UserDetailedNotMe, UserDetailedNotMe,
} from './autogen/models.js'; } from './autogen/models.js';
import type { AuthenticationResponseJSON, PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
export * from './autogen/entities.js'; export * from './autogen/entities.js';
export * from './autogen/models.js'; export * from './autogen/models.js';
@ -250,6 +251,7 @@ export type SignupRequest = {
'hcaptcha-response'?: string | null; 'hcaptcha-response'?: string | null;
'g-recaptcha-response'?: string | null; 'g-recaptcha-response'?: string | null;
'turnstile-response'?: string | null; 'turnstile-response'?: string | null;
'm-captcha-response'?: string | null;
} }
export type SignupResponse = MeDetailed & { export type SignupResponse = MeDetailed & {
@ -269,17 +271,25 @@ export type SigninRequest = {
username: string; username: string;
password: string; password: string;
token?: 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 = { export type SigninWithPasskeyRequest = {
credential?: object; credential?: AuthenticationResponseJSON;
context?: string; context?: string;
}; };
export type SigninWithPasskeyInitResponse = {
option: PublicKeyCredentialRequestOptionsJSON;
context: string;
};
export type SigninWithPasskeyResponse = { export type SigninWithPasskeyResponse = {
option?: object; signinResponse: SigninResponse;
context?: string;
signinResponse?: SigninResponse;
}; };
export type SigninResponse = { export type SigninResponse = {

View File

@ -1289,6 +1289,9 @@ importers:
packages/misskey-js: packages/misskey-js:
dependencies: dependencies:
'@simplewebauthn/types':
specifier: 10.0.0
version: 10.0.0
eventemitter3: eventemitter3:
specifier: 5.0.1 specifier: 5.0.1
version: 5.0.1 version: 5.0.1