misskey/packages/misskey-js/src/entities.ts

293 lines
6.8 KiB
TypeScript
Raw Normal View History

import { ModerationLogPayloads } from './consts.js';
import {
Announcement,
EmojiDetailed,
MeDetailed,
Note,
Page,
Role,
RolePolicies,
User,
UserDetailedNotMe,
} from './autogen/models.js';
2024-01-20 04:57:03 +00:00
export * from './autogen/entities.js';
export * from './autogen/models.js';
export type ID = string;
export type DateString = string;
type NonNullableRecord<T> = {
[P in keyof T]-?: NonNullable<T[P]>;
};
type AllNullRecord<T> = {
[P in keyof T]: null;
};
export type PureRenote =
Omit<Note, 'renote' | 'renoteId' | 'reply' | 'replyId' | 'text' | 'cw' | 'files' | 'fileIds' | 'poll'>
& AllNullRecord<Pick<Note, 'reply' | 'replyId' | 'text' | 'cw' | 'poll'>>
& { files: []; fileIds: []; }
& NonNullableRecord<Pick<Note, 'renote' | 'renoteId'>>;
export type PageEvent = {
pageId: Page['id'];
event: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var: any;
userId: User['id'];
user: User;
};
export type ModerationLog = {
id: ID;
createdAt: DateString;
userId: User['id'];
user: UserDetailedNotMe | null;
} & ({
type: 'updateServerSettings';
info: ModerationLogPayloads['updateServerSettings'];
} | {
type: 'suspend';
info: ModerationLogPayloads['suspend'];
} | {
type: 'unsuspend';
info: ModerationLogPayloads['unsuspend'];
} | {
type: 'updateUserNote';
info: ModerationLogPayloads['updateUserNote'];
} | {
type: 'addCustomEmoji';
info: ModerationLogPayloads['addCustomEmoji'];
2023-09-24 01:57:24 +00:00
} | {
type: 'updateCustomEmoji';
info: ModerationLogPayloads['updateCustomEmoji'];
} | {
type: 'deleteCustomEmoji';
info: ModerationLogPayloads['deleteCustomEmoji'];
} | {
type: 'assignRole';
info: ModerationLogPayloads['assignRole'];
} | {
type: 'unassignRole';
info: ModerationLogPayloads['unassignRole'];
2023-09-25 01:29:12 +00:00
} | {
type: 'createRole';
info: ModerationLogPayloads['createRole'];
} | {
type: 'updateRole';
info: ModerationLogPayloads['updateRole'];
} | {
type: 'deleteRole';
info: ModerationLogPayloads['deleteRole'];
} | {
type: 'clearQueue';
info: ModerationLogPayloads['clearQueue'];
} | {
type: 'promoteQueue';
info: ModerationLogPayloads['promoteQueue'];
2023-09-24 01:46:09 +00:00
} | {
type: 'deleteDriveFile';
info: ModerationLogPayloads['deleteDriveFile'];
} | {
type: 'deleteNote';
info: ModerationLogPayloads['deleteNote'];
} | {
type: 'createGlobalAnnouncement';
info: ModerationLogPayloads['createGlobalAnnouncement'];
} | {
type: 'createUserAnnouncement';
info: ModerationLogPayloads['createUserAnnouncement'];
} | {
type: 'updateGlobalAnnouncement';
info: ModerationLogPayloads['updateGlobalAnnouncement'];
} | {
type: 'updateUserAnnouncement';
info: ModerationLogPayloads['updateUserAnnouncement'];
} | {
type: 'deleteGlobalAnnouncement';
info: ModerationLogPayloads['deleteGlobalAnnouncement'];
} | {
type: 'deleteUserAnnouncement';
info: ModerationLogPayloads['deleteUserAnnouncement'];
2023-09-23 11:50:02 +00:00
} | {
type: 'resetPassword';
info: ModerationLogPayloads['resetPassword'];
} | {
type: 'suspendRemoteInstance';
info: ModerationLogPayloads['suspendRemoteInstance'];
} | {
type: 'unsuspendRemoteInstance';
info: ModerationLogPayloads['unsuspendRemoteInstance'];
} | {
type: 'updateRemoteInstanceNote';
info: ModerationLogPayloads['updateRemoteInstanceNote'];
2023-09-24 06:40:38 +00:00
} | {
type: 'markSensitiveDriveFile';
info: ModerationLogPayloads['markSensitiveDriveFile'];
} | {
type: 'unmarkSensitiveDriveFile';
info: ModerationLogPayloads['unmarkSensitiveDriveFile'];
2023-09-28 01:02:05 +00:00
} | {
type: 'createInvitation';
info: ModerationLogPayloads['createInvitation'];
2023-09-29 06:01:13 +00:00
} | {
type: 'createAd';
info: ModerationLogPayloads['createAd'];
} | {
type: 'updateAd';
info: ModerationLogPayloads['updateAd'];
} | {
type: 'deleteAd';
info: ModerationLogPayloads['deleteAd'];
} | {
type: 'createAvatarDecoration';
info: ModerationLogPayloads['createAvatarDecoration'];
} | {
type: 'updateAvatarDecoration';
info: ModerationLogPayloads['updateAvatarDecoration'];
} | {
type: 'deleteAvatarDecoration';
info: ModerationLogPayloads['deleteAvatarDecoration'];
} | {
type: 'resolveAbuseReport';
info: ModerationLogPayloads['resolveAbuseReport'];
2023-11-19 01:18:57 +00:00
} | {
type: 'unsetUserAvatar';
info: ModerationLogPayloads['unsetUserAvatar'];
} | {
type: 'unsetUserBanner';
info: ModerationLogPayloads['unsetUserBanner'];
2023-11-19 01:18:57 +00:00
} | {
type: 'createSystemWebhook';
info: ModerationLogPayloads['createSystemWebhook'];
} | {
type: 'updateSystemWebhook';
info: ModerationLogPayloads['updateSystemWebhook'];
} | {
type: 'deleteSystemWebhook';
info: ModerationLogPayloads['deleteSystemWebhook'];
} | {
type: 'createAbuseReportNotificationRecipient';
info: ModerationLogPayloads['createAbuseReportNotificationRecipient'];
} | {
type: 'updateAbuseReportNotificationRecipient';
info: ModerationLogPayloads['updateAbuseReportNotificationRecipient'];
} | {
type: 'deleteAbuseReportNotificationRecipient';
info: ModerationLogPayloads['deleteAbuseReportNotificationRecipient'];
} | {
type: 'deleteAccount';
info: ModerationLogPayloads['deleteAccount'];
} | {
type: 'deletePage';
info: ModerationLogPayloads['deletePage'];
} | {
type: 'deleteFlash';
info: ModerationLogPayloads['deleteFlash'];
} | {
type: 'deleteGalleryPost';
info: ModerationLogPayloads['deleteGalleryPost'];
});
export type ServerStats = {
cpu: number;
mem: {
used: number;
active: number;
};
net: {
rx: number;
tx: number;
};
fs: {
r: number;
w: number;
}
};
export type ServerStatsLog = ServerStats[];
export type QueueStats = {
deliver: {
activeSincePrevTick: number;
active: number;
waiting: number;
delayed: number;
};
inbox: {
activeSincePrevTick: number;
active: number;
waiting: number;
delayed: number;
};
};
export type QueueStatsLog = QueueStats[];
export type EmojiAdded = {
emoji: EmojiDetailed
};
export type EmojiUpdated = {
emojis: EmojiDetailed[]
};
export type EmojiDeleted = {
emojis: EmojiDetailed[]
};
export type AnnouncementCreated = {
announcement: Announcement;
};
export type SignupRequest = {
username: string;
password: string;
host?: string;
invitationCode?: string;
emailAddress?: string;
'hcaptcha-response'?: string | null;
'g-recaptcha-response'?: string | null;
'turnstile-response'?: string | null;
}
export type SignupResponse = MeDetailed & {
token: string;
}
export type SignupPendingRequest = {
code: string;
};
export type SignupPendingResponse = {
id: User['id'],
i: string,
};
export type SigninRequest = {
username: string;
password: string;
token?: string;
};
Add Sign in with passkey Button (#14577) * Sign in with passkey (PoC) * 💄 Added "Login with Passkey" Button * refactor: Improve error response when WebAuthn challenge fails * signinResponse should be placed under the SigninWithPasskeyResponse object. * Frontend fix * Fix: Rate limiting key for passkey signin Use specific rate limiting key: 'signin-with-passkey' for passkey sign-in API to avoid collisions with signin rate-limit. * Refactor: enhance Passkey sign-in flow and error handling - Increased the rate limit for Passkey sign-in attempts to accommodate the two API calls needed per sign-in. - Improved error messages and handling in both the `WebAuthnService` and the `SigninWithPasskeyApiService`, providing more context and better usability. - Updated error messages to provide more specific and helpful details to the user. These changes aim to enhance the Passkey sign-in experience by providing more robust error handling, improving security by limiting API calls, and delivering a more user-friendly interface. * Refactor: Streamline 2FA flow and remove redundant Passkey button. - Separate the flow of 1FA and 2FA. - Remove duplicate passkey buttons * Fix: Add error messages to MkSignin * chore: Hide passkey button if the entered user does not use passkey login * Update CHANGELOG.md * Refactor: Rename functions and Add comments * Update locales/ja-JP.yml Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> * Fix: Update translation - update index.d.ts - update ko-KR.yml, en-US.yml - Fix: Reflect Changed i18n key on MkSignin --------- Co-authored-by: Squarecat-meow <kw7551@gmail.com> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
2024-09-25 23:25:33 +00:00
export type SigninWithPasskeyRequest = {
credential?: object;
context?: string;
};
export type SigninWithPasskeyResponse = {
option?: object;
context?: string;
signinResponse?: SigninResponse;
};
export type SigninResponse = {
id: User['id'],
i: string,
};
type Values<T extends Record<PropertyKey, unknown>> = T[keyof T];
export type PartialRolePolicyOverride = Partial<{[k in keyof RolePolicies]: Omit<Values<Role['policies']>, 'value'> & { value: RolePolicies[k] }}>;