Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge upstream (2024.5.0-host.3d) #22

Merged
merged 7 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion locales/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ const primaries = {
const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '');

export function build() {
const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(new URL(`${c}.yml`, import.meta.url), 'utf-8'))) || {}, a), {});
const metaUrl = import.meta.url;
const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(new URL(`${c}.yml`, metaUrl), 'utf-8'))) || {}, a), {});

// 空文字列が入ることがあり、フォールバックが動作しなくなるのでプロパティごと消す
const removeEmpty = (obj) => {
Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@
"cleanall": "pnpm clean-all"
},
"resolutions": {
"@tensorflow/tfjs-core": "4.21.0",
"@tensorflow/tfjs-core": "4.22.0",
"chokidar": "4.0.1",
"cookie": "1.0.1",
"cookie-signature": "1.2.1",
"debug": "4.3.7",
"esbuild": "0.24.0",
"lodash": "4.17.21",
"sharp": "0.33.5"
"sharp": "0.33.5",
"web-streams-polyfill": "4.0.0"
},
"dependencies": {
"cssnano": "7.0.6",
Expand All @@ -61,7 +65,7 @@
"typescript": "5.6.3"
},
"devDependencies": {
"@types/node": "22.7.7",
"@types/node": "22.7.8",
"@typescript-eslint/eslint-plugin": "7.10.0",
"@typescript-eslint/parser": "7.10.0",
"cross-env": "7.0.3",
Expand All @@ -71,6 +75,6 @@
"start-server-and-test": "2.0.8"
},
"optionalDependencies": {
"@tensorflow/tfjs-core": "4.21.0"
"@tensorflow/tfjs-core": "4.22.0"
}
}
88 changes: 43 additions & 45 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,18 @@
"generate-api-json": "pnpm build && node ./scripts/generate_api_json.js"
},
"optionalDependencies": {
"@swc/core-android-arm64": "1.3.11",
"@swc/core-darwin-arm64": "1.5.7",
"@swc/core-darwin-x64": "1.5.7",
"@swc/core-freebsd-x64": "1.3.11",
"@swc/core-linux-arm-gnueabihf": "1.5.7",
"@swc/core-linux-arm64-gnu": "1.5.7",
"@swc/core-linux-arm64-musl": "1.5.7",
"@swc/core-linux-x64-gnu": "1.5.7",
"@swc/core-linux-x64-musl": "1.5.7",
"@swc/core-win32-arm64-msvc": "1.5.7",
"@swc/core-win32-ia32-msvc": "1.5.7",
"@swc/core-win32-x64-msvc": "1.5.7",
"@tensorflow/tfjs": "4.21.0",
"@tensorflow/tfjs-node": "4.21.0",
"@swc/core-darwin-arm64": "1.7.39",
"@swc/core-darwin-x64": "1.7.39",
"@swc/core-linux-arm-gnueabihf": "1.7.39",
"@swc/core-linux-arm64-gnu": "1.7.39",
"@swc/core-linux-arm64-musl": "1.7.39",
"@swc/core-linux-x64-gnu": "1.7.39",
"@swc/core-linux-x64-musl": "1.7.39",
"@swc/core-win32-arm64-msvc": "1.7.39",
"@swc/core-win32-ia32-msvc": "1.7.39",
"@swc/core-win32-x64-msvc": "1.7.39",
"@tensorflow/tfjs": "4.22.0",
"@tensorflow/tfjs-node": "4.22.0",
"bufferutil": "4.0.8",
"slacc-android-arm-eabi": "0.0.10",
"slacc-android-arm64": "0.0.10",
Expand All @@ -66,43 +64,43 @@
},
"dependencies": {
"@authenio/samlify-node-xmllint": "2.0.0",
"@aws-sdk/client-s3": "3.675.0",
"@aws-sdk/lib-storage": "3.675.0",
"@bull-board/api": "5.23.0",
"@bull-board/fastify": "5.23.0",
"@bull-board/ui": "5.23.0",
"@aws-sdk/client-s3": "3.676.0",
"@aws-sdk/lib-storage": "3.676.0",
"@bull-board/api": "6.2.4",
"@bull-board/fastify": "6.2.4",
"@bull-board/ui": "6.2.4",
"@discordapp/twemoji": "15.1.0",
"@elastic/elasticsearch": "8.15.1",
"@fastify/accepts": "4.3.0",
"@fastify/cookie": "9.4.0",
"@fastify/cors": "9.0.1",
"@fastify/express": "3.0.0",
"@fastify/formbody": "7.4.0",
"@fastify/http-proxy": "9.5.0",
"@fastify/multipart": "8.3.0",
"@fastify/static": "7.0.4",
"@fastify/view": "9.1.0",
"@fastify/accepts": "5.0.1",
"@fastify/cookie": "11.0.1",
"@fastify/cors": "10.0.1",
"@fastify/express": "4.0.1",
"@fastify/formbody": "8.0.1",
"@fastify/http-proxy": "10.0.1",
"@fastify/multipart": "9.0.1",
"@fastify/static": "8.0.2",
"@fastify/view": "10.0.1",
"@misskey-dev/sharp-read-bmp": "1.2.0",
"@misskey-dev/summaly": "5.1.0",
"@napi-rs/canvas": "0.1.58",
"@nestjs/common": "10.4.5",
"@nestjs/core": "10.4.5",
"@nestjs/testing": "10.4.5",
"@peertube/http-signature": "1.7.0",
"@simplewebauthn/server": "10.0.1",
"@simplewebauthn/server": "11.0.0",
"@sinonjs/fake-timers": "11.3.1",
"@smithy/node-http-handler": "3.2.4",
"@swc/cli": "0.3.12",
"@swc/core": "1.5.7",
"@smithy/node-http-handler": "3.2.5",
"@swc/cli": "0.4.0",
"@swc/core": "1.7.39",
"@twemoji/parser": "15.1.1",
"accepts": "1.3.8",
"ajv": "8.17.1",
"archiver": "7.0.1",
"async-mutex": "0.5.0",
"bcryptjs": "2.4.3",
"blurhash": "2.0.5",
"body-parser": "1.20.2",
"bullmq": "5.21.1",
"body-parser": "1.20.3",
"bullmq": "5.21.2",
"cacheable-lookup": "7.0.0",
"cbor": "9.0.2",
"chalk": "5.3.0",
Expand All @@ -113,11 +111,11 @@
"content-disposition": "0.5.4",
"date-fns": "4.1.0",
"deep-email-validator": "0.1.21",
"fastify": "4.28.1",
"fastify-http-errors-enhanced": "5.0.4",
"fastify-raw-body": "4.3.0",
"fastify": "5.0.0",
"fastify-http-errors-enhanced": "6.0.0",
"fastify-raw-body": "5.0.0",
"feed": "4.2.2",
"file-type": "19.4.0",
"file-type": "19.6.0",
"fluent-ffmpeg": "2.1.3",
"form-data": "4.0.1",
"got": "14.4.3",
Expand All @@ -126,7 +124,7 @@
"htmlescape": "1.1.1",
"http-link-header": "1.1.3",
"ioredis": "5.4.1",
"ip-cidr": "3.1.0",
"ip-cidr": "4.0.2",
"ipaddr.js": "2.2.0",
"is-svg": "5.1.0",
"jose": "5.9.6",
Expand All @@ -135,7 +133,7 @@
"json5": "2.2.3",
"jsonld": "8.3.2",
"jsrsasign": "11.1.0",
"meilisearch": "0.41.0",
"meilisearch": "0.44.1",
"mfm-js": "0.24.0",
"microformats-parser": "2.0.2",
"mime-types": "2.1.35",
Expand All @@ -153,7 +151,7 @@
"oauth2orize-pkce": "0.1.2",
"os-utils": "0.0.14",
"otpauth": "9.3.4",
"parse5": "7.1.2",
"parse5": "7.2.0",
"pg": "8.13.0",
"pino": "9.5.0",
"pino-pretty": "11.3.0",
Expand All @@ -172,7 +170,7 @@
"rss-parser": "3.13.0",
"rxjs": "7.8.1",
"samlify": "2.8.11",
"sanitize-html": "2.13.0",
"sanitize-html": "2.13.1",
"secure-json-parse": "2.7.0",
"sharp": "0.33.5",
"slacc": "0.0.10",
Expand All @@ -197,7 +195,7 @@
"@jest/globals": "29.7.0",
"@misskey-dev/eslint-plugin": "1.0.0",
"@nestjs/platform-express": "10.4.5",
"@simplewebauthn/types": "10.0.0",
"@simplewebauthn/types": "11.0.0",
"@swc/jest": "0.2.36",
"@types/accepts": "1.3.7",
"@types/archiver": "6.0.2",
Expand All @@ -215,7 +213,7 @@
"@types/jsrsasign": "10.5.14",
"@types/mime-types": "2.1.4",
"@types/ms": "0.7.34",
"@types/node": "22.7.7",
"@types/node": "22.7.8",
"@types/node-forge": "1.3.11",
"@types/nodemailer": "6.4.16",
"@types/oauth": "0.9.6",
Expand All @@ -235,7 +233,7 @@
"@types/tinycolor2": "1.4.6",
"@types/tmp": "0.2.6",
"@types/vary": "1.1.3",
"@types/web-push": "3.6.3",
"@types/web-push": "3.6.4",
"@types/ws": "8.5.12",
"@typescript-eslint/eslint-plugin": "7.10.0",
"@typescript-eslint/parser": "7.10.0",
Expand Down
18 changes: 9 additions & 9 deletions packages/backend/src/core/WebAuthnService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export class WebAuthnService {

@bindThis
public async verifyRegistration(userId: MiUser['id'], response: RegistrationResponseJSON): Promise<{
credentialID: string;
credentialPublicKey: Uint8Array;
id: string;
publicKey: Uint8Array;
attestationObject: Uint8Array;
fmt: AttestationFormat;
counter: number;
Expand Down Expand Up @@ -139,15 +139,15 @@ export class WebAuthnService {
const { registrationInfo } = verification;

return {
credentialID: registrationInfo.credentialID,
credentialPublicKey: registrationInfo.credentialPublicKey,
id: registrationInfo.credential.id,
publicKey: registrationInfo.credential.publicKey,
attestationObject: registrationInfo.attestationObject,
fmt: registrationInfo.fmt,
counter: registrationInfo.counter,
counter: registrationInfo.credential.counter,
userVerified: registrationInfo.userVerified,
credentialDeviceType: registrationInfo.credentialDeviceType,
credentialBackedUp: registrationInfo.credentialBackedUp,
transports: response.response.transports,
transports: registrationInfo.credential.transports,
};
}

Expand Down Expand Up @@ -228,9 +228,9 @@ export class WebAuthnService {
expectedChallenge: challenge,
expectedOrigin: relyingParty.origin,
expectedRPID: relyingParty.rpId,
authenticator: {
credentialID: key.id,
credentialPublicKey: Buffer.from(key.publicKey, 'base64url'),
credential: {
id: key.id,
publicKey: Buffer.from(key.publicKey, 'base64url'),
counter: key.counter,
transports: key.transports ? key.transports as AuthenticatorTransportFuture[] : undefined,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/misc/fastify-hook-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { onRequestHookHandler } from 'fastify';
export const handleRequestRedirectToOmitSearch: onRequestHookHandler = (request, reply, done) => {
const index = request.url.indexOf('?');
if (~index) {
reply.redirect(301, request.url.slice(0, index));
reply.redirect(request.url.slice(0, index), 301);
}
done();
};
18 changes: 12 additions & 6 deletions packages/backend/src/server/FileServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class FileServerService {
.catch(err => this.errorHandler(request, reply, err));
});
fastify.get<{ Params: { key: string; } }>('/files/:key/*', async (request, reply) => {
return await reply.redirect(301, `${this.config.url}/files/${request.params.key}`);
return reply.redirect(`${this.config.url}/files/${request.params.key}`, 301);
});
done();
});
Expand Down Expand Up @@ -147,12 +147,12 @@ export class FileServerService {
url.searchParams.set('static', '1');

file.cleanup();
return await reply.redirect(301, url.toString());
return await reply.redirect(url.toString(), 301);
} else if (file.mime.startsWith('video/')) {
const externalThumbnail = this.videoProcessingService.getExternalVideoThumbnailUrl(file.url);
if (externalThumbnail) {
file.cleanup();
return await reply.redirect(301, externalThumbnail);
return await reply.redirect(externalThumbnail, 301);
}

image = await this.videoProcessingService.generateVideoThumbnail(file.path);
Expand All @@ -167,7 +167,7 @@ export class FileServerService {
url.searchParams.set('url', file.url);

file.cleanup();
return await reply.redirect(301, url.toString());
return await reply.redirect(url.toString(), 301);
}
}

Expand Down Expand Up @@ -313,12 +313,18 @@ export class FileServerService {
url.searchParams.append(key, value);
}

return await reply.redirect(
301,
return reply.redirect(
url.toString(),
301,
);
}

if (!request.headers['user-agent']) {
throw new StatusError('User-Agent is required', 400, 'User-Agent is required');
} else if (request.headers['user-agent'].toLowerCase().indexOf('misskey/') !== -1) {
throw new StatusError('Refusing to proxy a request from another proxy', 403, 'Proxy is recursive');
}

// Create temp file
const file = await this.getStreamAndTypeFromUrl(url);
if (file === '404') {
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/server/ServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class ServerService implements OnApplicationShutdown {

if (emoji == null) {
if ('fallback' in request.query) {
return await reply.redirect('/static-assets/emoji-unknown.png');
return reply.redirect('/static-assets/emoji-unknown.png');
} else {
reply.code(404);
return;
Expand All @@ -179,9 +179,9 @@ export class ServerService implements OnApplicationShutdown {
if ('static' in request.query) url.searchParams.set('static', '1');
}

return await reply.redirect(
301,
return reply.redirect(
url.toString(),
301,
);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/server/api/endpoints/i/2fa/key-done.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
}

const keyInfo = await this.webAuthnService.verifyRegistration(me.id, ps.credential);
const keyId = keyInfo.credentialID;
const keyId = keyInfo.id;

await this.userSecurityKeysRepository.insert({
id: keyId,
userId: me.id,
name: ps.name,
publicKey: Buffer.from(keyInfo.credentialPublicKey).toString('base64url'),
publicKey: Buffer.from(keyInfo.publicKey).toString('base64url'),
counter: keyInfo.counter,
credentialDeviceType: keyInfo.credentialDeviceType,
credentialBackedUp: keyInfo.credentialBackedUp,
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/server/api/openapi/gen-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ export function genOpenapiSpec(config: Config, includeSelfRef = false) {

spec.paths['/' + endpoint.name] = {
...(endpoint.meta.allowGet ? {
get: info,
get: {
...info,
operationId: info.operationId + '_get',
},
} : {}),
post: info,
};
Expand Down
Loading
Loading