Hoist up the biome config and use it for syn2mas
This commit is contained in:
@@ -4,7 +4,7 @@ root = true
|
|||||||
charset=utf-8
|
charset=utf-8
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
|
|
||||||
[*.{ts,tsx,js,cjs,mjs,css,json,graphql}]
|
[*.{ts,tsx,cts,mts,js,cjs,mjs,css,json,graphql}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|||||||
35
biome.json
Normal file
35
biome.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||||
|
"organizeImports": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"vcs": {
|
||||||
|
"enabled": true,
|
||||||
|
"clientKind": "git",
|
||||||
|
"useIgnoreFile": true
|
||||||
|
},
|
||||||
|
"files": {
|
||||||
|
"ignore": [
|
||||||
|
".devcontainer/**",
|
||||||
|
"docs/**",
|
||||||
|
"translations/**",
|
||||||
|
"policies/**",
|
||||||
|
"crates/**",
|
||||||
|
"frontend/src/gql/**",
|
||||||
|
"frontend/src/routeTree.gen.ts",
|
||||||
|
"**/coverage/**",
|
||||||
|
"**/dist/**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true,
|
||||||
|
"useEditorconfig": true,
|
||||||
|
"ignore": ["frontend/.storybook/locales.ts", "frontend/locales/*.json"]
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"enabled": true,
|
||||||
|
"rules": {
|
||||||
|
"recommended": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
||||||
"organizeImports": {
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
"files": {
|
|
||||||
"ignore": [
|
|
||||||
"**/dist/**",
|
|
||||||
"**/__generated__/**",
|
|
||||||
"**/coverage/**",
|
|
||||||
"src/gql/**",
|
|
||||||
"src/routeTree.gen.ts"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"formatter": {
|
|
||||||
"enabled": true,
|
|
||||||
"useEditorconfig": true,
|
|
||||||
"ignore": [".storybook/locales.ts", "locales/*.json"]
|
|
||||||
},
|
|
||||||
"linter": {
|
|
||||||
"enabled": true,
|
|
||||||
"rules": {
|
|
||||||
"recommended": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,27 +3,30 @@
|
|||||||
"readKey": "a7633943728394577700-c0f9f1df124fbdbe76b2c7dfcbfe574476d56509e0da6180e2a321dbbe056c40",
|
"readKey": "a7633943728394577700-c0f9f1df124fbdbe76b2c7dfcbfe574476d56509e0da6180e2a321dbbe056c40",
|
||||||
"upload": {
|
"upload": {
|
||||||
"type": "json",
|
"type": "json",
|
||||||
"files": [{
|
"files": [
|
||||||
"file": "file.json",
|
{
|
||||||
"pattern": "translations/en.json",
|
"file": "file.json",
|
||||||
"features": [
|
"pattern": "translations/en.json",
|
||||||
"arb_metadata",
|
"features": ["arb_metadata", "plural_object"]
|
||||||
"plural_object"
|
},
|
||||||
]
|
{
|
||||||
}, {
|
"file": "frontend.json",
|
||||||
"file": "frontend.json",
|
"pattern": "frontend/locales/en.json",
|
||||||
"pattern": "frontend/locales/en.json",
|
"features": ["plural_postfix_dd"]
|
||||||
"features": ["plural_postfix_dd"]
|
}
|
||||||
}]
|
]
|
||||||
},
|
},
|
||||||
"download": {
|
"download": {
|
||||||
"metadataFileTs": "frontend/.storybook/locales.ts",
|
"metadataFileTs": "frontend/.storybook/locales.ts",
|
||||||
"files": [{
|
"files": [
|
||||||
"conditions": "equals: ${file}, file.json",
|
{
|
||||||
"output": "translations/${lang}.json"
|
"conditions": "equals: ${file}, file.json",
|
||||||
}, {
|
"output": "translations/${lang}.json"
|
||||||
"conditions": "equals: ${file}, frontend.json",
|
},
|
||||||
"output": "frontend/locales/${lang}.json"
|
{
|
||||||
}]
|
"conditions": "equals: ${file}, frontend.json",
|
||||||
|
"output": "frontend/locales/${lang}.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
// Copyright 2024 New Vector Ltd.
|
|
||||||
// Copyright 2023, 2024 The Matrix.org Foundation C.I.C.
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
// Please see LICENSE in the repository root for full details.
|
|
||||||
|
|
||||||
const HEADER_TEMPLATE = `\
|
|
||||||
// Copyright %%CURRENT_YEAR%% New Vector Ltd.
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
// Please see LICENSE in the repository root for full details.
|
|
||||||
|
|
||||||
`;
|
|
||||||
|
|
||||||
/** @type {import('eslint').Linter.Config} */
|
|
||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
plugins: ["matrix-org"],
|
|
||||||
extends: [
|
|
||||||
"plugin:prettier/recommended",
|
|
||||||
"plugin:import/recommended",
|
|
||||||
"plugin:import/typescript",
|
|
||||||
"plugin:matrix-org/typescript",
|
|
||||||
],
|
|
||||||
env: {
|
|
||||||
browser: false,
|
|
||||||
node: true,
|
|
||||||
},
|
|
||||||
parser: "@typescript-eslint/parser",
|
|
||||||
parserOptions: {
|
|
||||||
project: "./tsconfig.eslint.json",
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
"matrix-org/require-copyright-header": ["error", HEADER_TEMPLATE],
|
|
||||||
"import/order": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"newlines-between": "always",
|
|
||||||
alphabetize: { order: "asc" },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"@typescript-eslint/no-floating-promises": "error",
|
|
||||||
"@typescript-eslint/no-misused-promises": "error",
|
|
||||||
"@typescript-eslint/promise-function-async": "error",
|
|
||||||
"@typescript-eslint/await-thenable": "error",
|
|
||||||
|
|
||||||
// False-positive because of id128 and log4js
|
|
||||||
"import/no-named-as-default-member": "off",
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
"import/parsers": {
|
|
||||||
"@typescript-eslint/parser": [".ts", ".mts"],
|
|
||||||
},
|
|
||||||
"import/resolver": {
|
|
||||||
typescript: true,
|
|
||||||
node: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ignorePatterns: ["dist"],
|
|
||||||
};
|
|
||||||
4706
tools/syn2mas/package-lock.json
generated
4706
tools/syn2mas/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -12,13 +12,7 @@
|
|||||||
"bin": {
|
"bin": {
|
||||||
"syn2mas": "dist/index.js"
|
"syn2mas": "dist/index.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": ["src", "dist", "package.json", "LICENSE", "README.md"],
|
||||||
"src",
|
|
||||||
"dist",
|
|
||||||
"package.json",
|
|
||||||
"LICENSE",
|
|
||||||
"README.md"
|
|
||||||
],
|
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -27,26 +21,16 @@
|
|||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"dev": "tsx src/index.ts",
|
"dev": "tsx src/index.ts",
|
||||||
"lint": "npm run lint:types && npm run lint:style",
|
"lint": "npm run lint:types && npm run lint:style",
|
||||||
"lint:style": "eslint . .eslintrc.cjs",
|
"lint:style": "biome check",
|
||||||
"lint:types": "tsc --noEmit",
|
"lint:types": "tsc --noEmit",
|
||||||
"start": "node dist/index.js"
|
"start": "node dist/index.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "^1.9.4",
|
||||||
"@tsconfig/node22": "^22.0.0",
|
"@tsconfig/node22": "^22.0.0",
|
||||||
"@tsconfig/strictest": "^2.0.2",
|
"@tsconfig/strictest": "^2.0.2",
|
||||||
"@types/command-line-args": "^5.2.2",
|
"@types/command-line-args": "^5.2.2",
|
||||||
"@types/node": "^22.0.0",
|
"@types/node": "^22.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
|
||||||
"@typescript-eslint/parser": "^7.3.1",
|
|
||||||
"eslint": "^8.52.0",
|
|
||||||
"eslint-config-google": "^0.14.0",
|
|
||||||
"eslint-config-prettier": "^9.0.0",
|
|
||||||
"eslint-import-resolver-typescript": "^3.6.1",
|
|
||||||
"eslint-plugin-import": "npm:eslint-plugin-i@^2.28.1",
|
|
||||||
"eslint-plugin-jest": "^27.9.0",
|
|
||||||
"eslint-plugin-matrix-org": "^1.2.1",
|
|
||||||
"eslint-plugin-prettier": "^5.0.0",
|
|
||||||
"eslint-plugin-unicorn": "^51.0.1",
|
|
||||||
"prettier": "^3.0.3",
|
"prettier": "^3.0.3",
|
||||||
"tsx": "^4.16.2",
|
"tsx": "^4.16.2",
|
||||||
"typescript": "^5.2.2"
|
"typescript": "^5.2.2"
|
||||||
|
|||||||
@@ -6,15 +6,15 @@
|
|||||||
|
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
|
|
||||||
import { Knex } from "knex";
|
import type { Knex } from "knex";
|
||||||
import log4js from "log4js";
|
import log4js from "log4js";
|
||||||
import { parse } from "ts-command-line-args";
|
import { parse } from "ts-command-line-args";
|
||||||
import yaml from "yaml";
|
import yaml from "yaml";
|
||||||
|
|
||||||
import { connectToSynapseDatabase } from "./db.mjs";
|
import { connectToSynapseDatabase } from "./db.mjs";
|
||||||
import {
|
import {
|
||||||
|
type SynapseOIDCProvider,
|
||||||
synapseConfig as synapseConfigSchema,
|
synapseConfig as synapseConfigSchema,
|
||||||
SynapseOIDCProvider,
|
|
||||||
} from "./schemas/synapse.mjs";
|
} from "./schemas/synapse.mjs";
|
||||||
import type { SAccessToken } from "./types/SAccessToken.d.ts";
|
import type { SAccessToken } from "./types/SAccessToken.d.ts";
|
||||||
import type { SRefreshToken } from "./types/SRefreshToken.d.ts";
|
import type { SRefreshToken } from "./types/SRefreshToken.d.ts";
|
||||||
|
|||||||
@@ -7,18 +7,18 @@
|
|||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import type { SecureContextOptions } from "node:tls";
|
import type { SecureContextOptions } from "node:tls";
|
||||||
|
|
||||||
import knex, { Knex } from "knex";
|
import knex, { type Knex } from "knex";
|
||||||
|
|
||||||
import {
|
import type {
|
||||||
MASConfig,
|
MASConfig,
|
||||||
DatabaseConfig as MASDatabaseConfig,
|
DatabaseConfig as MASDatabaseConfig,
|
||||||
URIDatabaseConfig as MASURIDatabaseConfig,
|
URIDatabaseConfig as MASURIDatabaseConfig,
|
||||||
} from "./schemas/mas.mjs";
|
} from "./schemas/mas.mjs";
|
||||||
import { SynapseConfig } from "./schemas/synapse.mjs";
|
import type { SynapseConfig } from "./schemas/synapse.mjs";
|
||||||
|
|
||||||
export async function connectToSynapseDatabase({
|
export async function connectToSynapseDatabase({
|
||||||
database,
|
database,
|
||||||
}: SynapseConfig): Promise<Knex<{}, unknown[]>> {
|
}: SynapseConfig): Promise<Knex> {
|
||||||
if (!database) {
|
if (!database) {
|
||||||
throw new Error("Synapse database not configured");
|
throw new Error("Synapse database not configured");
|
||||||
}
|
}
|
||||||
@@ -32,22 +32,22 @@ export async function connectToSynapseDatabase({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const connection: Knex.PgConnectionConfig = {};
|
const connection: Knex.PgConnectionConfig = {};
|
||||||
database.args.database && (connection.database = database.args.database);
|
if (database.args.database) connection.database = database.args.database;
|
||||||
database.args.dbname && (connection.database = database.args.dbname);
|
if (database.args.dbname) connection.database = database.args.dbname;
|
||||||
database.args.user && (connection.user = database.args.user);
|
if (database.args.user) connection.user = database.args.user;
|
||||||
database.args.password && (connection.password = database.args.password);
|
if (database.args.password) connection.password = database.args.password;
|
||||||
database.args.host && (connection.host = database.args.host);
|
if (database.args.host) connection.host = database.args.host;
|
||||||
typeof database.args.port === "number" &&
|
if (typeof database.args.port === "number")
|
||||||
(connection.port = database.args.port);
|
connection.port = database.args.port;
|
||||||
typeof database.args.port === "string" &&
|
if (typeof database.args.port === "string")
|
||||||
(connection.port = parseInt(database.args.port));
|
connection.port = Number.parseInt(database.args.port);
|
||||||
|
|
||||||
const ssl: SecureContextOptions = {};
|
const ssl: SecureContextOptions = {};
|
||||||
database.args.sslcert && (ssl.cert = await readFile(database.args.sslcert));
|
if (database.args.sslcert) ssl.cert = await readFile(database.args.sslcert);
|
||||||
database.args.sslrootcert &&
|
if (database.args.sslrootcert)
|
||||||
(ssl.ca = await readFile(database.args.sslrootcert));
|
ssl.ca = await readFile(database.args.sslrootcert);
|
||||||
database.args.sslkey && (ssl.key = await readFile(database.args.sslkey));
|
if (database.args.sslkey) ssl.key = await readFile(database.args.sslkey);
|
||||||
database.args.sslpassword && (ssl.passphrase = database.args.sslpassword);
|
if (database.args.sslpassword) ssl.passphrase = database.args.sslpassword;
|
||||||
|
|
||||||
if (Object.keys(ssl).length > 0) {
|
if (Object.keys(ssl).length > 0) {
|
||||||
connection.ssl = ssl;
|
connection.ssl = ssl;
|
||||||
@@ -62,21 +62,21 @@ export async function connectToSynapseDatabase({
|
|||||||
const isUriConfig = (
|
const isUriConfig = (
|
||||||
database: MASDatabaseConfig,
|
database: MASDatabaseConfig,
|
||||||
): database is MASURIDatabaseConfig =>
|
): database is MASURIDatabaseConfig =>
|
||||||
typeof (database as Record<string, unknown>)["uri"] === "string";
|
"uri" in database && typeof database.uri === "string";
|
||||||
|
|
||||||
export async function connectToMASDatabase({
|
export async function connectToMASDatabase({
|
||||||
database,
|
database,
|
||||||
}: MASConfig): Promise<Knex<{}, unknown[]>> {
|
}: MASConfig): Promise<Knex> {
|
||||||
const connection: Knex.PgConnectionConfig = {};
|
const connection: Knex.PgConnectionConfig = {};
|
||||||
const ssl: SecureContextOptions = {};
|
const ssl: SecureContextOptions = {};
|
||||||
if (isUriConfig(database)) {
|
if (isUriConfig(database)) {
|
||||||
connection.connectionString = database.uri;
|
connection.connectionString = database.uri;
|
||||||
} else {
|
} else {
|
||||||
database.database && (connection.database = database.database);
|
if (database.database) connection.database = database.database;
|
||||||
database.username && (connection.user = database.username);
|
if (database.username) connection.user = database.username;
|
||||||
database.password && (connection.password = database.password);
|
if (database.password) connection.password = database.password;
|
||||||
database.host && (connection.host = database.host);
|
if (database.host) connection.host = database.host;
|
||||||
database.port && (connection.port = database.port);
|
if (database.port) connection.port = database.port;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (database.ssl_ca) {
|
if (database.ssl_ca) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import log4js from "log4js";
|
import log4js from "log4js";
|
||||||
import { ArgumentConfig, parse } from "ts-command-line-args";
|
import { type ArgumentConfig, parse } from "ts-command-line-args";
|
||||||
|
|
||||||
import { advisor } from "./advisor.mjs";
|
import { advisor } from "./advisor.mjs";
|
||||||
import { migrate } from "./migrate.mjs";
|
import { migrate } from "./migrate.mjs";
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import log4js from "log4js";
|
|||||||
import { parse } from "ts-command-line-args";
|
import { parse } from "ts-command-line-args";
|
||||||
import yaml from "yaml";
|
import yaml from "yaml";
|
||||||
|
|
||||||
import { connectToSynapseDatabase, connectToMASDatabase } from "./db.mjs";
|
import { connectToMASDatabase, connectToSynapseDatabase } from "./db.mjs";
|
||||||
import { masConfig as masConfigSchema } from "./schemas/mas.mjs";
|
import { masConfig as masConfigSchema } from "./schemas/mas.mjs";
|
||||||
import { synapseConfig as synapseConfigSchema } from "./schemas/synapse.mjs";
|
import { synapseConfig as synapseConfigSchema } from "./schemas/synapse.mjs";
|
||||||
import type { MCompatAccessToken } from "./types/MCompatAccessToken.d.ts";
|
import type { MCompatAccessToken } from "./types/MCompatAccessToken.d.ts";
|
||||||
@@ -104,7 +104,7 @@ export async function migrate(): Promise<void> {
|
|||||||
let fatals = 0;
|
let fatals = 0;
|
||||||
function fatal(message: string): void {
|
function fatal(message: string): void {
|
||||||
log.fatal(message);
|
log.fatal(message);
|
||||||
warnings.forEach((w) => log.warn(w));
|
for (const w of warnings) log.warn(w);
|
||||||
if (!args.dryRun) {
|
if (!args.dryRun) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ export async function migrate(): Promise<void> {
|
|||||||
.from("users")
|
.from("users")
|
||||||
.first();
|
.first();
|
||||||
|
|
||||||
if (parseInt(`${existingMasUsers?.count ?? 0}`) > 0) {
|
if (Number.parseInt(`${existingMasUsers?.count ?? 0}`) > 0) {
|
||||||
fatal(
|
fatal(
|
||||||
`Found ${existingMasUsers?.count} existing users in MAS. Refusing to continue. Please clean MAS and try again.`,
|
`Found ${existingMasUsers?.count} existing users in MAS. Refusing to continue. Please clean MAS and try again.`,
|
||||||
);
|
);
|
||||||
@@ -204,14 +204,16 @@ export async function migrate(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// users => users
|
// users => users
|
||||||
const userCreatedAt = new Date(parseInt(`${user.creation_ts}`) * 1000);
|
const userCreatedAt = new Date(
|
||||||
|
Number.parseInt(`${user.creation_ts}`) * 1000,
|
||||||
|
);
|
||||||
const masUser = {
|
const masUser = {
|
||||||
user_id: makeUuid(userCreatedAt),
|
user_id: makeUuid(userCreatedAt),
|
||||||
username: localpart,
|
username: localpart,
|
||||||
created_at: userCreatedAt,
|
created_at: userCreatedAt,
|
||||||
locked_at: user.deactivated === 1 ? userCreatedAt : null,
|
locked_at: user.deactivated === 1 ? userCreatedAt : null,
|
||||||
};
|
};
|
||||||
executions.push(() => mas.insert(masUser!).into("users"));
|
executions.push(() => mas.insert(masUser).into("users"));
|
||||||
log.debug(`${stringifyAndRedact(user)} => ${stringifyAndRedact(masUser)}`);
|
log.debug(`${stringifyAndRedact(user)} => ${stringifyAndRedact(masUser)}`);
|
||||||
// users.password_hash => user_passwords
|
// users.password_hash => user_passwords
|
||||||
if (user.password_hash) {
|
if (user.password_hash) {
|
||||||
@@ -245,7 +247,9 @@ export async function migrate(): Promise<void> {
|
|||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const threePidCreatedAt = new Date(parseInt(`${threePid.added_at}`));
|
const threePidCreatedAt = new Date(
|
||||||
|
Number.parseInt(`${threePid.added_at}`),
|
||||||
|
);
|
||||||
const masUserEmail: MUserEmail = {
|
const masUserEmail: MUserEmail = {
|
||||||
user_email_id: makeUuid(threePidCreatedAt),
|
user_email_id: makeUuid(threePidCreatedAt),
|
||||||
user_id: masUser.user_id,
|
user_id: masUser.user_id,
|
||||||
@@ -255,7 +259,7 @@ export async function migrate(): Promise<void> {
|
|||||||
|
|
||||||
if (threePid.validated_at) {
|
if (threePid.validated_at) {
|
||||||
masUserEmail.confirmed_at = new Date(
|
masUserEmail.confirmed_at = new Date(
|
||||||
parseInt(`${threePid.validated_at}`),
|
Number.parseInt(`${threePid.validated_at}`),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,8 +279,8 @@ export async function migrate(): Promise<void> {
|
|||||||
);
|
);
|
||||||
executions.push(() =>
|
executions.push(() =>
|
||||||
mas("users")
|
mas("users")
|
||||||
.where({ user_id: masUser!.user_id })
|
.where({ user_id: masUser?.user_id })
|
||||||
.update({ primary_user_email_id: primaryEmail!.user_email_id }),
|
.update({ primary_user_email_id: primaryEmail?.user_email_id }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,12 +291,12 @@ export async function migrate(): Promise<void> {
|
|||||||
.where({ user_id: user.name });
|
.where({ user_id: user.name });
|
||||||
for (const externalId of synapseExternalIds) {
|
for (const externalId of synapseExternalIds) {
|
||||||
try {
|
try {
|
||||||
if (!upstreamProviders.has(externalId.auth_provider)) {
|
const provider = upstreamProviders.get(externalId.auth_provider);
|
||||||
|
if (!provider) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unknown upstream provider ${externalId.auth_provider}`,
|
`Unknown upstream provider ${externalId.auth_provider}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const provider = upstreamProviders.get(externalId.auth_provider)!;
|
|
||||||
const masUpstreamOauthLink: MUpstreamOauthLink = {
|
const masUpstreamOauthLink: MUpstreamOauthLink = {
|
||||||
upstream_oauth_link_id: makeUuid(userCreatedAt),
|
upstream_oauth_link_id: makeUuid(userCreatedAt),
|
||||||
user_id: masUser.user_id,
|
user_id: masUser.user_id,
|
||||||
@@ -333,7 +337,7 @@ export async function migrate(): Promise<void> {
|
|||||||
.whereNotNull("device_id");
|
.whereNotNull("device_id");
|
||||||
for (const accessToken of synapseAccessTokens) {
|
for (const accessToken of synapseAccessTokens) {
|
||||||
const tokenCreatedAt = accessToken.last_validated
|
const tokenCreatedAt = accessToken.last_validated
|
||||||
? new Date(parseInt(`${accessToken.last_validated}`))
|
? new Date(Number.parseInt(`${accessToken.last_validated}`))
|
||||||
: masUser.created_at;
|
: masUser.created_at;
|
||||||
const masCompatSession: MCompatSession = {
|
const masCompatSession: MCompatSession = {
|
||||||
compat_session_id: makeUuid(tokenCreatedAt),
|
compat_session_id: makeUuid(tokenCreatedAt),
|
||||||
@@ -462,7 +466,7 @@ export async function migrate(): Promise<void> {
|
|||||||
log.info(
|
log.info(
|
||||||
`Completed migration ${args.dryRun ? "dry-run " : ""}of ${synapseUsers} users with ${fatals} fatals and ${warnings.length} warnings:`,
|
`Completed migration ${args.dryRun ? "dry-run " : ""}of ${synapseUsers} users with ${fatals} fatals and ${warnings.length} warnings:`,
|
||||||
);
|
);
|
||||||
warnings.forEach((w) => log.warn(w));
|
for (const w of warnings) log.warn(w);
|
||||||
if (fatals > 0) {
|
if (fatals > 0) {
|
||||||
throw new Error(`Migration failed with ${fatals} fatals`);
|
throw new Error(`Migration failed with ${fatals} fatals`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { MCompatSession } from "./MCompatSession";
|
import type { MCompatSession } from "./MCompatSession";
|
||||||
|
|
||||||
import { UUID } from "./index";
|
import type { UUID } from "./index";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
+------------------------+--------------------------+-----------+
|
+------------------------+--------------------------+-----------+
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { MCompatAccessToken } from "./MCompatAccessToken";
|
import type { MCompatAccessToken } from "./MCompatAccessToken";
|
||||||
import { MCompatSession } from "./MCompatSession";
|
import type { MCompatSession } from "./MCompatSession";
|
||||||
|
|
||||||
import { UUID } from "./index";
|
import type { UUID } from "./index";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
+-------------------------+--------------------------+-----------+
|
+-------------------------+--------------------------+-----------+
|
||||||
|
|||||||
4
tools/syn2mas/src/types/MCompatSession.d.ts
vendored
4
tools/syn2mas/src/types/MCompatSession.d.ts
vendored
@@ -4,9 +4,9 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { MUser } from "./MUser";
|
import type { MUser } from "./MUser";
|
||||||
|
|
||||||
import { UUID } from "./index";
|
import type { UUID } from "./index";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
+-------------------+--------------------------+-----------+
|
+-------------------+--------------------------+-----------+
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { MUpstreamOauthProvider } from "./MUpstreamOauthProvider";
|
import type { MUpstreamOauthProvider } from "./MUpstreamOauthProvider";
|
||||||
import { MUser } from "./MUser";
|
import type { MUser } from "./MUser";
|
||||||
|
|
||||||
import { UUID } from "./index";
|
import type { UUID } from "./index";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
+----------------------------+--------------------------+-----------+
|
+----------------------------+--------------------------+-----------+
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { UUID } from "./index";
|
import type { UUID } from "./index";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
+----------------------------+--------------------------+-----------+
|
+----------------------------+--------------------------+-----------+
|
||||||
|
|||||||
4
tools/syn2mas/src/types/MUser.d.ts
vendored
4
tools/syn2mas/src/types/MUser.d.ts
vendored
@@ -4,9 +4,9 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { MUserEmail } from "./MUserEmail";
|
import type { MUserEmail } from "./MUserEmail";
|
||||||
|
|
||||||
import { UUID } from "./index";
|
import type { UUID } from "./index";
|
||||||
|
|
||||||
export interface MUser {
|
export interface MUser {
|
||||||
user_id: UUID<MUser>;
|
user_id: UUID<MUser>;
|
||||||
|
|||||||
4
tools/syn2mas/src/types/MUserEmail.d.ts
vendored
4
tools/syn2mas/src/types/MUserEmail.d.ts
vendored
@@ -4,9 +4,9 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { MUser } from "./MUser";
|
import type { MUser } from "./MUser";
|
||||||
|
|
||||||
import { UUID } from "./index";
|
import type { UUID } from "./index";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
+---------------+--------------------------+-----------+
|
+---------------+--------------------------+-----------+
|
||||||
|
|||||||
4
tools/syn2mas/src/types/MUserPassword.d.ts
vendored
4
tools/syn2mas/src/types/MUserPassword.d.ts
vendored
@@ -4,9 +4,9 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { MUser } from "./MUser";
|
import type { MUser } from "./MUser";
|
||||||
|
|
||||||
import { UUID } from "./index";
|
import type { UUID } from "./index";
|
||||||
|
|
||||||
export interface MUserPassword {
|
export interface MUserPassword {
|
||||||
user_password_id: UUID<MUserPassword>;
|
user_password_id: UUID<MUserPassword>;
|
||||||
|
|||||||
4
tools/syn2mas/src/types/SAccessToken.d.ts
vendored
4
tools/syn2mas/src/types/SAccessToken.d.ts
vendored
@@ -4,9 +4,9 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { SRefreshToken } from "./SRefreshToken";
|
import type { SRefreshToken } from "./SRefreshToken";
|
||||||
|
|
||||||
import { Id, SynapseUserId } from "./index";
|
import type { Id, SynapseUserId } from "./index";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CREATE TABLE access_tokens (
|
CREATE TABLE access_tokens (
|
||||||
|
|||||||
2
tools/syn2mas/src/types/SRefreshToken.d.ts
vendored
2
tools/syn2mas/src/types/SRefreshToken.d.ts
vendored
@@ -4,7 +4,7 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { Id, SynapseUserId } from "./index";
|
import type { Id, SynapseUserId } from "./index";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
);
|
);
|
||||||
|
|||||||
2
tools/syn2mas/src/types/SUser.d.ts
vendored
2
tools/syn2mas/src/types/SUser.d.ts
vendored
@@ -4,7 +4,7 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { SynapseUserId, UnixTimestamp } from "./index";
|
import type { SynapseUserId, UnixTimestamp } from "./index";
|
||||||
|
|
||||||
export interface SUser {
|
export interface SUser {
|
||||||
name: SynapseUserId; // '@test2:localhost:8008'
|
name: SynapseUserId; // '@test2:localhost:8008'
|
||||||
|
|||||||
2
tools/syn2mas/src/types/SUserExternalId.d.ts
vendored
2
tools/syn2mas/src/types/SUserExternalId.d.ts
vendored
@@ -4,7 +4,7 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { SynapseUserId } from "./index";
|
import type { SynapseUserId } from "./index";
|
||||||
|
|
||||||
export interface SUserExternalId {
|
export interface SUserExternalId {
|
||||||
auth_provider: string;
|
auth_provider: string;
|
||||||
|
|||||||
2
tools/syn2mas/src/types/SUserThreePid.d.ts
vendored
2
tools/syn2mas/src/types/SUserThreePid.d.ts
vendored
@@ -4,7 +4,7 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
// Please see LICENSE in the repository root for full details.
|
// Please see LICENSE in the repository root for full details.
|
||||||
|
|
||||||
import { SynapseUserId } from "./index";
|
import type { SynapseUserId } from "./index";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CREATE TABLE user_threepids (
|
CREATE TABLE user_threepids (
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"@tsconfig/strictest/tsconfig.json",
|
"@tsconfig/strictest/tsconfig.json",
|
||||||
"@tsconfig/node22/tsconfig.json",
|
"@tsconfig/node22/tsconfig.json"
|
||||||
],
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"allowJs": true,
|
"allowJs": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [".eslintrc.cjs", "src/**/*.mts", "src/**/*.ts"]
|
||||||
".eslintrc.cjs",
|
|
||||||
"src/**/*.mts",
|
|
||||||
"src/**/*.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declaration": false,
|
"declaration": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user