diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0ce40f73f52..dbbad43dcc4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -409,7 +409,7 @@ jobs: DOCKER_CLI_HINTS: false - name: Configure /etc/hosts run: | - sudo echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts + sudo echo "127.0.0.1 huly.local" | sudo tee -a /etc/hosts - name: Prepare server run: | cd ./qms-tests @@ -479,7 +479,7 @@ jobs: DOCKER_CLI_HINTS: false - name: Configure /etc/hosts run: | - sudo echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts + sudo echo "127.0.0.1 huly.local" | sudo tee -a /etc/hosts - name: Prepare server run: | cd ./ws-tests diff --git a/.vscode/launch.json b/.vscode/launch.json index d3ee3247746..d78c98e888d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -35,12 +35,12 @@ "args": ["src/__start.ts"], "env": { // "FULLTEXT_URL": "http://localhost:4700", - "FULLTEXT_URL": "http://host.docker.internal:4702", + "FULLTEXT_URL": "http://huly.local:4702", // "MONGO_URL": "mongodb://localhost:27017", // "DB_URL": "mongodb://localhost:27017", // "DB_URL": "postgresql://postgres:example@localhost:5432", - "DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable", - "GREEN_URL": "http://host.docker.internal:6767?token=secret", + "DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable", + "GREEN_URL": "http://huly.local:6767?token=secret", "SERVER_PORT": "3332", "APM_SERVER_URL2": "http://localhost:8200", "METRICS_CONSOLE": "false", @@ -60,7 +60,7 @@ "ELASTIC_INDEX_NAME": "local_storage_index", "UPLOAD_URL": "/files", "AI_BOT_URL": "http://localhost:4010", - "STATS_URL": "http://host.docker.internal:4900" + "STATS_URL": "http://huly.local:4900" }, "runtimeArgs": ["--nolazy", "-r", "ts-node/register"], "runtimeVersion": "20", @@ -79,8 +79,8 @@ "FULLTEXT_URL": "http://localhost:4710", // "DB_URL": "mongodb://localhost:27018", // "DB_URL": "postgresql://postgres:example@localhost:5432", - "DB_URL": "postgresql://root@host.docker.internal:26258/defaultdb?sslmode=disable", - // "GREEN_URL": "http://host.docker.internal:6767?token=secret", + "DB_URL": "postgresql://root@huly.local:26258/defaultdb?sslmode=disable", + // "GREEN_URL": "http://huly.local:6767?token=secret", "SERVER_PORT": "3335", "METRICS_CONSOLE": "false", "METRICS_FILE": "${workspaceRoot}/metrics.txt", // Show metrics in console evert 30 seconds., @@ -92,7 +92,7 @@ "ACCOUNTS_URL": "http://localhost:3003", "MODEL_JSON": "${workspaceRoot}/models/all/bundle/model.json", "MODEL_VERSION": "0.7.1", - "STATS_URL": "http://host.docker.internal:4901" + "STATS_URL": "http://huly.local:4901" }, "runtimeArgs": ["--nolazy", "-r", "ts-node/register"], "runtimeVersion": "20", @@ -113,13 +113,13 @@ "FULLTEXT_DB_URL": "http://localhost:9200", // "DB_URL": "mongodb://localhost:27017", // "DB_URL": "postgresql://postgres:example@localhost:5432", - "DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable", + "DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable", "STORAGE_CONFIG": "minio|localhost?accessKey=minioadmin&secretKey=minioadmin", "SERVER_SECRET": "secret", "REKONI_URL": "http://localhost:4004", "MODEL_JSON": "${workspaceRoot}/models/all/bundle/model.json", "ELASTIC_INDEX_NAME": "local_storage_index", - "STATS_URL":"http://host.docker.internal:4900", + "STATS_URL":"http://huly.local:4900", "ACCOUNTS_URL": "http://localhost:3000", }, "runtimeArgs": ["--nolazy", "-r", "ts-node/register"], @@ -138,14 +138,14 @@ "env": { "MONGO_URL": "mongodb://localhost:27017", "DB_URL": "mongodb://localhost:27017", - // "DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable", + // "DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable", "SERVER_SECRET": "secret", "REGION_INFO":"|Mongo;cockroach|CockroachDB", - "TRANSACTOR_URL": "ws://host.docker.internal:3333,ws://host.docker.internal:3332;;cockroach", + "TRANSACTOR_URL": "ws://huly.local:3333,ws://huly.local:3332;;cockroach", "ACCOUNTS_URL": "http://localhost:3000", "ACCOUNT_PORT": "3000", "FRONT_URL": "http://localhost:8080", - "STATS_URL": "http://host.docker.internal:4900", + "STATS_URL": "http://huly.local:4900", "SES_URL": "", // "DB_NS": "account-2", // "WS_LIVENESS_DAYS": "1", @@ -172,11 +172,11 @@ // "DB_URL": "postgresql://postgres:example@localhost:5432", "SERVER_SECRET": "secret", "REGION_INFO":"|Mongo;pg|Postgres;cockroach|CockroachDB", - "TRANSACTOR_URL": "ws://host.docker.internal:3334;;,ws://host.docker.internal:3335;;europe", + "TRANSACTOR_URL": "ws://huly.local:3334;;,ws://huly.local:3335;;europe", "ACCOUNTS_URL": "http://localhost:3003", "ACCOUNT_PORT": "3003", "FRONT_URL": "http://localhost:8083", - "STATS_URL": "http://host.docker.internal:4901", + "STATS_URL": "http://huly.local:4901", "SES_URL": "", // "DB_NS": "account-2", // "WS_LIVENESS_DAYS": "1", @@ -216,7 +216,7 @@ "env": { "DB_URL": "mongodb://localhost:27017", // "DB_URL": "postgresql://postgres:example@localhost:5432", - // "DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable", + // "DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable", "REGION": "", "SERVER_SECRET": "secret", @@ -249,8 +249,8 @@ "env": { // "DB_URL": "mongodb://localhost:27017", // "DB_URL": "postgresql://postgres:example@localhost:5432", - "DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable", - "FULLTEXT_URL": "http://host.docker.internal:4702", + "DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable", + "FULLTEXT_URL": "http://huly.local:4702", "REGION": "cockroach", "SERVER_SECRET": "secret", "TRANSACTOR_URL": "ws://localhost:3332", @@ -415,7 +415,7 @@ "ACCOUNT_DB_URL": "mongodb://localhost:27017", // "ACCOUNT_DB_URL": "postgresql://postgres:example@localhost:5433", // "DB_URL": "postgresql://postgres:example@localhost:5433", - "DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable", + "DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable", "MONGO_URL": "mongodb://localhost:27017", "TELEGRAM_DATABASE": "telegram-service", "REKONI_URL": "http://localhost:4004", @@ -514,7 +514,7 @@ "PLATFORM_OPERATION_LOGGING": "true", "FRONT_URL": "http://localhost:8080", "PORT": "3500", - "STATS_URL": "http://host.docker.internal:4900" + "STATS_URL": "http://huly.local:4900" }, "runtimeArgs": ["--nolazy", "-r", "ts-node/register"], "sourceMaps": true, diff --git a/README.md b/README.md index 3f50824cf1e..6335127895b 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ This project offers a convenient method to host Huly using `docker`, designed fo - [Table of Content](#table-of-content) - [Pre-requisites](#pre-requisites) - [Verification](#verification) + - [Fast start](#fast-start) + - [Branches \& Contributing](#branches--contributing) - [Installation](#installation) - [Build and run](#build-and-run) - [Run in development mode](#run-in-development-mode) @@ -149,10 +151,10 @@ sh ./scripts/create-workspace.sh Add the following line to your /etc/hosts file ```plain -127.0.0.1 host.docker.internal +127.0.0.1 huly.local ``` -Accessing the URL will lead you to the app in development mode. +Accessing the URL will lead you to the app in development mode. Limitations: diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index b4c2c57fbf6..48d4de2acd4 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1330,6 +1330,9 @@ importers: '@types/compression': specifier: ~1.7.2 version: 1.7.5 + '@types/cookies': + specifier: ^0.9.0 + version: 0.9.0 '@types/cors': specifier: ^2.8.12 version: 2.8.17 @@ -1534,6 +1537,9 @@ importers: compression-webpack-plugin: specifier: ^10.0.0 version: 10.0.0(webpack@5.97.1) + cookies: + specifier: ^0.9.1 + version: 0.9.1 copy-webpack-plugin: specifier: ^11.0.0 version: 11.0.0(webpack@5.97.1) @@ -3955,7 +3961,7 @@ packages: version: 0.0.0 '@rush-temp/account-service@file:projects/account-service.tgz': - resolution: {integrity: sha512-SBWP6HBOnzpJC3MIOlYbttcjYw1HoD9VpbLpUS3zRwEL2slU6c0W/hEBU0/rzh3KkLb6bScKssS5utlSx5RrNw==, tarball: file:projects/account-service.tgz} + resolution: {integrity: sha512-ViPfMFYJ6+K9NPAIyV9v6+v6BRtdPCSiU4iTXCdZsoPgpag3nFxhE5PC3ahzS2wJ0TbCX+5UdaUX/UE3ySL4OA==, tarball: file:projects/account-service.tgz} version: 0.0.0 '@rush-temp/account@file:projects/account.tgz': @@ -16067,6 +16073,7 @@ snapshots: '@rush-temp/account-service@file:projects/account-service.tgz(@babel/core@7.23.9)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.23.9))(gcp-metadata@5.3.0(encoding@0.1.13))(snappy@7.2.2)(socks@2.8.3)': dependencies: '@koa/cors': 5.0.0 + '@types/cookies': 0.9.0 '@types/jest': 29.5.12 '@types/koa': 2.15.0 '@types/koa-bodyparser': 4.3.12 @@ -16075,6 +16082,7 @@ snapshots: '@types/node': 20.11.19 '@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.56.0)(typescript@5.3.3))(eslint@8.56.0)(typescript@5.3.3) '@typescript-eslint/parser': 6.21.0(eslint@8.56.0)(typescript@5.3.3) + cookies: 0.9.1 cross-env: 7.0.3 esbuild: 0.24.2 eslint: 8.56.0 diff --git a/desktop/.env-dev b/desktop/.env-dev index 037febc7837..936dd726fda 100644 --- a/desktop/.env-dev +++ b/desktop/.env-dev @@ -1,2 +1,2 @@ -FRONT_URL=http://localhost:8087 +FRONT_URL=http://huly.local:8087 CONFIG_URL=config.json diff --git a/desktop/src/main/start.ts b/desktop/src/main/start.ts index fee9be59bcb..6c276e1aa6f 100644 --- a/desktop/src/main/start.ts +++ b/desktop/src/main/start.ts @@ -63,7 +63,7 @@ const serverChanged = oldFront !== FRONT_URL function readServerUrl (): string { if (isDev) { - return process.env.FRONT_URL ?? 'http://localhost:8087' + return process.env.FRONT_URL ?? 'http://huly.local:8087' } return ((settings as any).get('server', process.env.FRONT_URL) as string) ?? 'https://huly.app' diff --git a/desktop/src/ui/index.ts b/desktop/src/ui/index.ts index 2658d01ea9e..499a86d5f53 100644 --- a/desktop/src/ui/index.ts +++ b/desktop/src/ui/index.ts @@ -1,24 +1,21 @@ -import login, { loginId } from '@hcengineering/login' -import { getEmbeddedLabel, getMetadata, setMetadata } from '@hcengineering/platform' -import presentation, { closeClient, MessageBox, setDownloadProgress } from '@hcengineering/presentation' +import { loginId } from '@hcengineering/login' +import { getEmbeddedLabel, getMetadata } from '@hcengineering/platform' +import presentation, { MessageBox, setDownloadProgress } from '@hcengineering/presentation' import settings, { settingId } from '@hcengineering/setting' import { closePanel, closePopup, createApp, - fetchMetadataLocalStorage, - getCurrentLocation, getCurrentResolvedLocation, navigate, parseLocation, pushRootBarProgressComponent, removeRootBarComponent, - setMetadataLocalStorage, showPopup } from '@hcengineering/ui' import { notificationId } from '@hcengineering/notification' -import { workbenchId } from '@hcengineering/workbench' +import { workbenchId, logOut } from '@hcengineering/workbench' import { isOwnerOrMaintainer } from '@hcengineering/core' import { configurePlatform } from './platform' @@ -58,18 +55,7 @@ window.addEventListener('DOMContentLoaded', () => { }) ipcMain.on('logout', () => { - const tokens = fetchMetadataLocalStorage(login.metadata.LoginTokensV2) - if (tokens !== null) { - const loc = getCurrentLocation() - // eslint-disable-next-line @typescript-eslint/no-dynamic-delete - delete tokens[loc.path[1]] - setMetadataLocalStorage(login.metadata.LoginTokensV2, tokens) - } - setMetadata(presentation.metadata.Token, null) - setMetadataLocalStorage(login.metadata.LastToken, null) - setMetadataLocalStorage(login.metadata.LoginEndpoint, null) - setMetadataLocalStorage(login.metadata.LoginAccount, null) - void closeClient().then(() => { + void logOut().then(() => { navigate({ path: [loginId] }) }) }) diff --git a/dev/branding.json b/dev/branding.json index b35a6042a52..44b2d6d91ed 100644 --- a/dev/branding.json +++ b/dev/branding.json @@ -1,12 +1,12 @@ { - "localhost:8080": { + "huly.local:8080": { "key": "huly-dev", "title": "Huly", "protocol": "http", "language": "en", "lastNameFirst": "true" }, - "localhost:8087": { + "huly.local:8087": { "key": "huly", "title": "Huly", "protocol": "http", @@ -20,13 +20,13 @@ "language": "en", "lastNameFirst": "true" }, - "localhost:8081": { + "huly.local:8081": { "key": "tracex-dev", "title": "TraceX", "protocol": "http", "language": "en" }, - "localhost:8088": { + "huly.local:8088": { "key": "tracex", "title": "TraceX", "protocol": "http", diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index 99a9ceab8e8..99ca8cf30a3 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -3,7 +3,7 @@ services: image: 'mongo:7-jammy' container_name: mongodb extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' healthcheck: test: echo "try { db.currentOp().ok } catch (err) { }" | mongosh --port 27017 --quiet interval: 5s @@ -61,7 +61,7 @@ services: account: image: hardcoreeng/account extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' links: - mongodb - minio @@ -74,29 +74,29 @@ services: - ACCOUNT_PORT=3000 - SERVER_SECRET=secret - ADMIN_EMAILS=admin - - STATS_URL=http://host.docker.internal:4900 - # - DB_URL=postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable + - STATS_URL=http://huly.local:4900 + # - DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable - DB_URL=${MONGO_URL} # - DB_NS=account-2 # Pass only one region to disallow selection for new workspaces.Ø - REGION_INFO=|Mongo;cockroach|CockroachDB # - REGION_INFO=cockroach|CockroachDB - - TRANSACTOR_URL=ws://host.docker.internal:3333,ws://host.docker.internal:3332;;cockroach, + - TRANSACTOR_URL=ws://huly.local:3333,ws://huly.local:3332;;cockroach, - SES_URL= - STORAGE_CONFIG=${STORAGE_CONFIG} - - FRONT_URL=http://host.docker.internal:8087 + - FRONT_URL=http://huly.local:8087 - RESERVED_DB_NAMES=telegram,gmail,github - MODEL_ENABLED=* - LAST_NAME_FIRST=true # - WS_LIVENESS_DAYS=1 - - ACCOUNTS_URL=http://host.docker.internal:3000 + - ACCOUNTS_URL=http://huly.local:3000 - BRANDING_PATH=/var/cfg/branding.json # - DISABLE_SIGNUP=true restart: unless-stopped stats: image: hardcoreeng/stats extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' ports: - 4900:4900 environment: @@ -106,7 +106,7 @@ services: workspace: image: hardcoreeng/workspace extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' links: - mongodb - minio @@ -117,12 +117,12 @@ services: - WS_OPERATION=all+backup - SERVER_SECRET=secret - DB_URL=${MONGO_URL} - - STATS_URL=http://host.docker.internal:4900 + - STATS_URL=http://huly.local:4900 - SES_URL= - STORAGE_CONFIG=${STORAGE_CONFIG} - RESERVED_DB_NAMES=telegram,gmail,github - MODEL_ENABLED=* - - ACCOUNTS_URL=http://host.docker.internal:3000 + - ACCOUNTS_URL=http://huly.local:3000 - BRANDING_PATH=/var/cfg/branding.json # - PARALLEL=2 - BACKUP_STORAGE=${BACKUP_STORAGE_CONFIG} @@ -132,7 +132,7 @@ services: workspace_cockroach: image: hardcoreeng/workspace extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' links: - cockroach - minio @@ -142,14 +142,14 @@ services: environment: - WS_OPERATION=all+backup - SERVER_SECRET=secret - - DB_URL=postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable - - STATS_URL=http://host.docker.internal:4900 + - DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable + - STATS_URL=http://huly.local:4900 - SES_URL= - REGION=cockroach - STORAGE_CONFIG=${STORAGE_CONFIG} - RESERVED_DB_NAMES=telegram,gmail,github - MODEL_ENABLED=* - - ACCOUNTS_URL=http://host.docker.internal:3000 + - ACCOUNTS_URL=http://huly.local:3000 - BRANDING_PATH=/var/cfg/branding.json # - PARALLEL=2 - BACKUP_STORAGE=${BACKUP_STORAGE_CONFIG} @@ -159,7 +159,7 @@ services: collaborator: image: hardcoreeng/collaborator extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' links: - mongodb - minio @@ -170,14 +170,14 @@ services: environment: - COLLABORATOR_PORT=3078 - SECRET=secret - - ACCOUNTS_URL=http://host.docker.internal:3000 + - ACCOUNTS_URL=http://huly.local:3000 - STORAGE_CONFIG=${STORAGE_CONFIG} - - STATS_URL=http://host.docker.internal:4900 + - STATS_URL=http://huly.local:4900 restart: unless-stopped front: image: hardcoreeng/front extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' links: - mongodb - minio @@ -191,28 +191,28 @@ services: environment: - SERVER_PORT=8080 - SERVER_SECRET=secret - - ACCOUNTS_URL=http://host.docker.internal:3000 - - STATS_URL=http://host.docker.internal:4900 + - ACCOUNTS_URL=http://huly.local:3000 + - STATS_URL=http://huly.local:4900 - UPLOAD_URL=/files - - GMAIL_URL=http://host.docker.internal:8088 - - CALENDAR_URL=http://host.docker.internal:8095 - - TELEGRAM_URL=http://host.docker.internal:8086 - - REKONI_URL=http://host.docker.internal:4004 - - COLLABORATOR_URL=ws://host.docker.internal:3078 + - GMAIL_URL=http://huly.local:8088 + - CALENDAR_URL=http://huly.local:8095 + - TELEGRAM_URL=http://huly.local:8086 + - REKONI_URL=http://huly.local:4004 + - COLLABORATOR_URL=ws://huly.local:3078 - STORAGE_CONFIG=${STORAGE_CONFIG} - - GITHUB_URL=http://host.docker.internal:3500 - - PRINT_URL=http://host.docker.internal:4005 - - SIGN_URL=http://host.docker.internal:4006 - - ANALYTICS_COLLECTOR_URL=http://host.docker.internal:4017 + - GITHUB_URL=http://huly.local:3500 + - PRINT_URL=http://huly.local:4005 + - SIGN_URL=http://huly.local:4006 + - ANALYTICS_COLLECTOR_URL=http://huly.local:4017 - DESKTOP_UPDATES_URL=https://dist.huly.io - DESKTOP_UPDATES_CHANNEL=dev - - BRANDING_URL=http://host.docker.internal:8087/branding.json + - BRANDING_URL=http://huly.local:8087/branding.json # - DISABLE_SIGNUP=true restart: unless-stopped transactor: image: hardcoreeng/transactor extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' links: - mongodb - minio @@ -230,8 +230,8 @@ services: - SERVER_PORT=3333 - SERVER_SECRET=secret - ENABLE_COMPRESSION=false - - STATS_URL=http://host.docker.internal:4900 - - FULLTEXT_URL=http://host.docker.internal:4700 + - STATS_URL=http://huly.local:4900 + - FULLTEXT_URL=http://huly.local:4700 # - DB_URL=postgresql://postgres:example@postgres:5432 - DB_URL=${MONGO_URL} - MONGO_URL=${MONGO_URL} @@ -239,18 +239,18 @@ services: - METRICS_CONSOLE=false - METRICS_FILE=metrics.txt - STORAGE_CONFIG=${STORAGE_CONFIG} - - FRONT_URL=http://host.docker.internal:8087 + - FRONT_URL=http://huly.local:8087 # - APM_SERVER_URL=http://apm-server:8200 - SES_URL='' - - ACCOUNTS_URL=http://host.docker.internal:3000 + - ACCOUNTS_URL=http://huly.local:3000 - LAST_NAME_FIRST=true - BRANDING_PATH=/var/cfg/branding.json - - AI_BOT_URL=http://host.docker.internal:4010 + - AI_BOT_URL=http://huly.local:4010 restart: unless-stopped transactor_cockroach: image: hardcoreeng/transactor extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' links: - cockroach - minio @@ -268,24 +268,24 @@ services: - SERVER_PORT=3332 - SERVER_SECRET=secret - ENABLE_COMPRESSION=false - - FULLTEXT_URL=http://host.docker.internal:4702 - - STATS_URL=http://host.docker.internal:4900 - - DB_URL=postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable + - FULLTEXT_URL=http://huly.local:4702 + - STATS_URL=http://huly.local:4900 + - DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable - METRICS_CONSOLE=false - METRICS_FILE=metrics.txt - STORAGE_CONFIG=${STORAGE_CONFIG} - - FRONT_URL=http://host.docker.internal:8087 + - FRONT_URL=http://huly.local:8087 # - APM_SERVER_URL=http://apm-server:8200 - SES_URL='' - - ACCOUNTS_URL=http://host.docker.internal:3000 + - ACCOUNTS_URL=http://huly.local:3000 - LAST_NAME_FIRST=true - BRANDING_PATH=/var/cfg/branding.json - - AI_BOT_URL=http://host.docker.internal:4010 + - AI_BOT_URL=http://huly.local:4010 restart: unless-stopped green: image: hardcoreeng/green extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' links: - cockroach - stats @@ -294,8 +294,8 @@ services: environment: - PORT=6767 - AUTH_TOKEN=secret - - STATS_URL=http://host.docker.internal:4900 - - DB_URL=postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable + - STATS_URL=http://huly.local:4900 + - DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable restart: unless-stopped rekoni: image: hardcoreeng/rekoni-service @@ -305,7 +305,7 @@ services: fulltext: image: hardcoreeng/fulltext extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' restart: unless-stopped links: - elastic @@ -315,16 +315,16 @@ services: environment: - SERVER_SECRET=secret - DB_URL=${MONGO_URL} - - FULLTEXT_DB_URL=http://host.docker.internal:9200 + - FULLTEXT_DB_URL=http://huly.local:9200 - ELASTIC_INDEX_NAME=local_storage_index - STORAGE_CONFIG=${STORAGE_CONFIG} - - STATS_URL=http://host.docker.internal:4900 - - REKONI_URL=http://host.docker.internal:4004 - - ACCOUNTS_URL=http://host.docker.internal:3000 + - STATS_URL=http://huly.local:4900 + - REKONI_URL=http://huly.local:4004 + - ACCOUNTS_URL=http://huly.local:3000 fulltext_cockroach: image: hardcoreeng/fulltext extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' restart: unless-stopped links: - elastic @@ -334,29 +334,29 @@ services: environment: - PORT=4702 - SERVER_SECRET=secret - - DB_URL=postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable - - FULLTEXT_DB_URL=http://host.docker.internal:9200 + - DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable + - FULLTEXT_DB_URL=http://huly.local:9200 - ELASTIC_INDEX_NAME=local_storage_index - STORAGE_CONFIG=${STORAGE_CONFIG} - - STATS_URL=http://host.docker.internal:4900 - - REKONI_URL=http://host.docker.internal:4004 - - ACCOUNTS_URL=http://host.docker.internal:3000 + - STATS_URL=http://huly.local:4900 + - REKONI_URL=http://huly.local:4004 + - ACCOUNTS_URL=http://huly.local:3000 print: image: hardcoreeng/print extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' restart: unless-stopped ports: - 4005:4005 environment: - SECRET=secret - STORAGE_CONFIG=${STORAGE_CONFIG} - - STATS_URL=http://host.docker.internal:4900 - - ACCOUNTS_URL=http://host.docker.internal:3000 + - STATS_URL=http://huly.local:4900 + - ACCOUNTS_URL=http://huly.local:3000 sign: image: hardcoreeng/sign extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' restart: unless-stopped ports: - 4006:4006 @@ -367,16 +367,16 @@ services: - SECRET=secret - MINIO_ENDPOINT=minio - MINIO_ACCESS_KEY=minioadmin - - ACCOUNTS_URL=http://host.docker.internal:3000 + - ACCOUNTS_URL=http://huly.local:3000 - MINIO_SECRET_KEY=minioadmin - CERTIFICATE_PATH=/var/cfg/certificate.p12 - SERVICE_ID=sign-service - BRANDING_PATH=/var/cfg/branding.json - - STATS_URL=http://host.docker.internal:4900 + - STATS_URL=http://huly.local:4900 # analytics: # image: hardcoreeng/analytics-collector # extra_hosts: -# - 'host.docker.internal:host-gateway' +# - 'huly.local:host-gateway' # restart: unless-stopped # ports: # - 4017:4017 @@ -386,32 +386,32 @@ services: # - MONGO_URL=${MONGO_URL} # - 'MONGO_OPTIONS={"appName":"analytics","maxPoolSize":1}' # - SERVICE_ID=analytics-collector-service -# - ACCOUNTS_URL=http://host.docker.internal:3000 -# - STATS_URL=http://host.docker.internal:4900 +# - ACCOUNTS_URL=http://huly.local:3000 +# - STATS_URL=http://huly.local:4900 aiBot: image: hardcoreeng/ai-bot ports: - 4010:4010 extra_hosts: - - 'host.docker.internal:host-gateway' + - 'huly.local:host-gateway' restart: unless-stopped environment: - SERVER_SECRET=secret - MONGO_URL=${MONGO_URL} - - ACCOUNTS_URL=http://host.docker.internal:3000 + - ACCOUNTS_URL=http://huly.local:3000 - STORAGE_CONFIG=${STORAGE_CONFIG} - FIRST_NAME=Jolie - LAST_NAME=AI - PASSWORD=password - AVATAR_PATH=./avatar.png - AVATAR_CONTENT_TYPE=.png - - STATS_URL=http://host.docker.internal:4900 -# - LOVE_ENDPOINT=http://host.docker.internal:8096 + - STATS_URL=http://huly.local:4900 +# - LOVE_ENDPOINT=http://huly.local:8096 # - OPENAI_API_KEY=token # telegram-bot: # image: hardcoreeng/telegram-bot # extra_hosts: -# - "host.docker.internal:host-gateway" +# - "huly.local:host-gateway" # restart: unless-stopped # environment: # - PORT=4020 @@ -420,9 +420,9 @@ services: # - MONGO_DB=telegram-bot # - SECRET=secret # - DOMAIN=domain -# - ACCOUNTS_URL=http://host.docker.internal:3000 +# - ACCOUNTS_URL=http://huly.local:3000 # - SERVICE_ID=telegram-bot-service -# - STATS_URL=http://host.docker.internal:4900 +# - STATS_URL=http://huly.local:4900 volumes: db: dbpg: diff --git a/dev/local-mongo/docker-compose.yaml b/dev/local-mongo/docker-compose.yaml index 22b38fdf095..5576d357c23 100644 --- a/dev/local-mongo/docker-compose.yaml +++ b/dev/local-mongo/docker-compose.yaml @@ -40,7 +40,7 @@ services: environment: - ACCOUNT_PORT=3000 - SERVER_SECRET=secret - - MONGO_URL=mongodb://host.docker.internal:27017?compressors=snappy + - MONGO_URL=mongodb://huly.local:27017?compressors=snappy - TRANSACTOR_URL=ws://transactor:3333;ws://localhost:3333 - SES_URL= - STORAGE_CONFIG=${STORAGE_CONFIG} @@ -65,7 +65,7 @@ services: - SECRET=secret - ACCOUNTS_URL=http://account:3000 - UPLOAD_URL=/files - - MONGO_URL=mongodb://host.docker.internal:27017?compressors=snappy + - MONGO_URL=mongodb://huly.local:27017?compressors=snappy - 'MONGO_OPTIONS={"appName":"collaborator","maxPoolSize":2}' - STORAGE_CONFIG=${STORAGE_CONFIG} restart: unless-stopped @@ -83,7 +83,7 @@ services: - UV_THREADPOOL_SIZE=10 - SERVER_PORT=8080 - SERVER_SECRET=secret - - MONGO_URL=mongodb://host.docker.internal:27017?compressors=snappy + - MONGO_URL=mongodb://huly.local:27017?compressors=snappy - 'MONGO_OPTIONS={"appName":"front","maxPoolSize":1}' - ACCOUNTS_URL=http://localhost:3000 - UPLOAD_URL=/files @@ -120,7 +120,7 @@ services: - SERVER_PORT=3333 - SERVER_SECRET=secret - ENABLE_COMPRESSION=true - - MONGO_URL=mongodb://host.docker.internal:27017?compressors=snappy + - MONGO_URL=mongodb://huly.local:27017?compressors=snappy - 'MONGO_OPTIONS={"appName": "transactor", "maxPoolSize": 10}' - METRICS_CONSOLE=false - METRICS_FILE=metrics.txt @@ -151,7 +151,7 @@ services: - 4005:4005 environment: - SECRET=secret - - MONGO_URL=mongodb://host.docker.internal:27017?compressors=snappy + - MONGO_URL=mongodb://huly.local:27017?compressors=snappy - 'MONGO_OPTIONS={"appName":"print","maxPoolSize":1}' - STORAGE_CONFIG=${STORAGE_CONFIG} deploy: @@ -168,7 +168,7 @@ services: - ../../services/sign/pod-sign/debug/branding.json:/var/cfg/branding.json environment: - SECRET=secret - - MONGO_URL=mongodb://host.docker.internal:27017 + - MONGO_URL=mongodb://huly.local:27017 - 'MONGO_OPTIONS={"appName":"sign","maxPoolSize":1}' - MINIO_ENDPOINT=minio - MINIO_ACCESS_KEY=minioadmin @@ -189,7 +189,7 @@ services: # environment: # - SECRET=secret # - PORT=4007 -# - MONGO_URL=mongodb://host.docker.internal:27017 +# - MONGO_URL=mongodb://huly.local:27017 # - 'MONGO_OPTIONS={"appName":"analytics","maxPoolSize":1}' # - SERVICE_ID=analytics-collector-service # - ACCOUNTS_URL=http://account:3000 @@ -202,7 +202,7 @@ services: restart: unless-stopped environment: - SERVER_SECRET=secret - - MONGO_URL=mongodb://host.docker.internal:27017 + - MONGO_URL=mongodb://huly.local:27017 - ACCOUNTS_URL=http://account:3000 - FIRST_NAME=Jolie - LAST_NAME=AI @@ -219,7 +219,7 @@ services: # environment: # - PORT=4020 # - BOT_TOKEN=token -# - MONGO_URL=mongodb://host.docker.internal:27017 +# - MONGO_URL=mongodb://huly.local:27017 # - MONGO_DB=telegram-bot # - SECRET=secret # - DOMAIN=domain diff --git a/dev/prod/public/branding.json b/dev/prod/public/branding.json index 1efd403c584..caccda656fb 100644 --- a/dev/prod/public/branding.json +++ b/dev/prod/public/branding.json @@ -1,5 +1,5 @@ { - "localhost:8080": { + "huly.local:8080": { "title": "Huly", "languages": "en,ru,pt,es,zh,fr,de", "defaultLanguage": "en", @@ -28,7 +28,7 @@ } ] }, - "localhost:8087": { + "huly.local:8087": { "title": "Huly", "languages": "en,ru,pt,es,zh,fr,de", "defaultLanguage": "en", @@ -57,7 +57,7 @@ } ] }, - "localhost:8081": { + "huly.local:8081": { "title": "TraceX", "languages": "en", "defaultLanguage": "en", @@ -97,7 +97,7 @@ } ] }, - "localhost:8088": { + "huly.local:8088": { "title": "TraceX", "languages": "en", "defaultLanguage": "en", diff --git a/dev/scripts/debug_account.sh b/dev/scripts/debug_account.sh index 0581bdf2481..8809d4bbd80 100755 --- a/dev/scripts/debug_account.sh +++ b/dev/scripts/debug_account.sh @@ -9,14 +9,14 @@ echo "Running account on port: ${port}" #MONGO_URL=mongodb://localhost:27017, export DB_URL="mongodb://localhost:27018" # DB_URL=postgresql://postgres:example@localhost:5432, -# DB_URL=postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable, +# DB_URL=postgresql://root@huly.local:26257/defaultdb?sslmode=disable, export SERVER_SECRET="secret" export REGION_INFO="|America;europe|" export TRANSACTOR_URL="ws://transactor:3334;ws://localhost:3334,ws://transactor-europe:3335;ws://localhost:3335;europe," export ACCOUNTS_URL="http://localhost:${port}" export ACCOUNT_PORT=${port} export FRONT_URL="http://localhost:8080" -export STATS_URL="http://host.docker.internal:4900" +export STATS_URL="http://huly.local:4900" export SES_URL= export MINIO_ACCESS_KEY="minioadmin" export MINIO_SECRET_KEY="minioadmin" diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index 358d39be101..7d532d0da7d 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -279,7 +279,11 @@ export function devTool ( throw new Error(`Workspace ${workspace} not found`) } - await assignWorkspace(toolCtx, db, null, getToolToken(), email, ws.uuid, AccountRole.User) + await assignWorkspace(toolCtx, db, null, getToolToken(), { + email, + workspaceUuid: ws.uuid, + role: AccountRole.User + }) } catch (err: any) { console.error(err) } @@ -341,16 +345,12 @@ export function devTool ( undefined, true ) - await updateWorkspaceInfo( - measureCtx, - db, - brandingObj, - getToolToken(), - res.workspaceUuid, - 'create-done', + await updateWorkspaceInfo(measureCtx, db, brandingObj, getToolToken(), { + workspaceUuid: res.workspaceUuid, + event: 'create-done', version, - 100 - ) + progress: 100 + }) console.log('create-workspace done') }) @@ -372,7 +372,7 @@ export function devTool ( throw new Error(`Workspace ${workspace} not found`) } - await assignWorkspace(toolCtx, db, null, getToolToken(), email, ws.uuid, role) + await assignWorkspace(toolCtx, db, null, getToolToken(), { email, workspaceUuid: ws.uuid, role }) }) }) @@ -423,7 +423,12 @@ export function devTool ( true ) - await updateWorkspaceInfo(measureCtx, db, null, getToolToken(), info.uuid, 'upgrade-done', version, 100) + await updateWorkspaceInfo(measureCtx, db, null, getToolToken(), { + workspaceUuid: info.uuid, + event: 'upgrade-done', + version, + progress: 100 + }) console.log(metricsToString(measureCtx.metrics, 'upgrade', 60)) console.log('upgrade-workspace done') diff --git a/packages/account-client/src/client.ts b/packages/account-client/src/client.ts index dfc8e64f339..089e33001b6 100644 --- a/packages/account-client/src/client.ts +++ b/packages/account-client/src/client.ts @@ -107,6 +107,9 @@ export interface AccountClient { assignWorkspace: (email: string, workspaceUuid: string, role: AccountRole) => Promise updateBackupInfo: (info: BackupStatus) => Promise updateWorkspaceRoleBySocialId: (socialKey: string, targetRole: AccountRole) => Promise + + setCookie: () => Promise + deleteCookie: () => Promise } /** @public */ @@ -120,10 +123,12 @@ export function getClient (accountsUrl?: string, token?: string): AccountClient interface Request { method: string - params: any[] + params: Record } class AccountClientImpl implements AccountClient { + private readonly request: RequestInit + constructor ( private readonly url: string, private readonly token?: string @@ -131,6 +136,18 @@ class AccountClientImpl implements AccountClient { if (url === '') { throw new Error('Accounts url not specified') } + + this.request = { + keepalive: true, + headers: { + ...(this.token === undefined + ? {} + : { + Authorization: 'Bearer ' + this.token + }) + }, + credentials: 'include' + } } async getProviders (): Promise { @@ -143,16 +160,12 @@ class AccountClientImpl implements AccountClient { private async rpc(request: Request): Promise { const response = await fetch(this.url, { - method: 'POST', - keepalive: true, + ...this.request, headers: { - ...(this.token === undefined - ? {} - : { - Authorization: 'Bearer ' + this.token - }), + ...this.request.headers, 'Content-Type': 'application/json' }, + method: 'POST', body: JSON.stringify(request) }) @@ -183,7 +196,7 @@ class AccountClientImpl implements AccountClient { async getUserWorkspaces (): Promise { const request = { method: 'getUserWorkspaces' as const, - params: [] + params: {} } return (await this.rpc(request)).map((ws) => this.flattenStatus(ws)) @@ -196,7 +209,7 @@ class AccountClientImpl implements AccountClient { ): Promise { const request = { method: 'selectWorkspace' as const, - params: [workspaceUrl, kind, externalRegions] + params: { workspaceUrl, kind, externalRegions } } return await this.rpc(request) @@ -205,7 +218,7 @@ class AccountClientImpl implements AccountClient { async validateOtp (email: string, code: string): Promise { const request = { method: 'validateOtp' as const, - params: [email, code] + params: { email, code } } return await this.rpc(request) @@ -214,7 +227,7 @@ class AccountClientImpl implements AccountClient { async loginOtp (email: string): Promise { const request = { method: 'loginOtp' as const, - params: [email] + params: { email } } return await this.rpc(request) @@ -223,7 +236,7 @@ class AccountClientImpl implements AccountClient { async getLoginInfoByToken (): Promise { const request = { method: 'getLoginInfoByToken' as const, - params: [] + params: {} } return await this.rpc(request) @@ -232,7 +245,7 @@ class AccountClientImpl implements AccountClient { async restorePassword (password: string): Promise { const request = { method: 'restorePassword' as const, - params: [password] + params: { password } } return await this.rpc(request) @@ -241,7 +254,7 @@ class AccountClientImpl implements AccountClient { async confirm (): Promise { const request = { method: 'confirm' as const, - params: [] + params: {} } return await this.rpc(request) @@ -250,7 +263,7 @@ class AccountClientImpl implements AccountClient { async requestPasswordReset (email: string): Promise { const request = { method: 'requestPasswordReset' as const, - params: [email] + params: { email } } await this.rpc(request) @@ -259,7 +272,7 @@ class AccountClientImpl implements AccountClient { async sendInvite (email: string, role: AccountRole): Promise { const request = { method: 'sendInvite' as const, - params: [email, role] + params: { email, role } } await this.rpc(request) @@ -277,7 +290,7 @@ class AccountClientImpl implements AccountClient { async leaveWorkspace (account: string): Promise { const request = { method: 'leaveWorkspace' as const, - params: [account] + params: { account } } return await this.rpc(request) @@ -286,7 +299,7 @@ class AccountClientImpl implements AccountClient { async changeUsername (first: string, last: string): Promise { const request = { method: 'changeUsername' as const, - params: [first, last] + params: { first, last } } await this.rpc(request) @@ -295,7 +308,7 @@ class AccountClientImpl implements AccountClient { async changePassword (oldPassword: string, newPassword: string): Promise { const request = { method: 'changePassword' as const, - params: [oldPassword, newPassword] + params: { oldPassword, newPassword } } await this.rpc(request) @@ -310,7 +323,7 @@ class AccountClientImpl implements AccountClient { ): Promise { const request = { method: 'signUpJoin' as const, - params: [email, password, first, last, inviteId] + params: { email, password, first, last, inviteId } } return await this.rpc(request) @@ -319,7 +332,7 @@ class AccountClientImpl implements AccountClient { async join (email: string, password: string, inviteId: string): Promise { const request = { method: 'join' as const, - params: [email, password, inviteId] + params: { email, password, inviteId } } return await this.rpc(request) @@ -334,7 +347,7 @@ class AccountClientImpl implements AccountClient { ): Promise { const request = { method: 'createInviteLink' as const, - params: [exp, emailMask, limit, role, personId] + params: { exp, emailMask, limit, role, personId } } return await this.rpc(request) @@ -343,7 +356,7 @@ class AccountClientImpl implements AccountClient { async checkJoin (inviteId: string): Promise { const request = { method: 'checkJoin' as const, - params: [inviteId] + params: { inviteId } } return await this.rpc(request) @@ -352,7 +365,7 @@ class AccountClientImpl implements AccountClient { async getWorkspaceInfo (updateLastVisit: boolean = false): Promise { const request = { method: 'getWorkspaceInfo' as const, - params: updateLastVisit ? [true] : [] + params: updateLastVisit ? { updateLastVisit: true } : {} } return this.flattenStatus(await this.rpc(request)) @@ -361,34 +374,34 @@ class AccountClientImpl implements AccountClient { async getRegionInfo (): Promise { const request = { method: 'getRegionInfo' as const, - params: [] + params: {} } return await this.rpc(request) } - async createWorkspace (name: string, region?: string): Promise { + async createWorkspace (workspaceName: string, region?: string): Promise { const request = { method: 'createWorkspace' as const, - params: [name, region] + params: { workspaceName, region } } return await this.rpc(request) } - async signUpOtp (email: string, first: string, last: string): Promise { + async signUpOtp (email: string, firstName: string, lastName: string): Promise { const request = { method: 'signUpOtp' as const, - params: [email, first, last] + params: { email, firstName, lastName } } return await this.rpc(request) } - async signUp (email: string, password: string, first: string, last: string): Promise { + async signUp (email: string, password: string, firstName: string, lastName: string): Promise { const request = { method: 'signUp' as const, - params: [email, password, first, last] + params: { email, password, firstName, lastName } } return await this.rpc(request) @@ -397,7 +410,7 @@ class AccountClientImpl implements AccountClient { async login (email: string, password: string): Promise { const request = { method: 'login' as const, - params: [email, password] + params: { email, password } } return await this.rpc(request) @@ -406,7 +419,7 @@ class AccountClientImpl implements AccountClient { async getPerson (): Promise { const request = { method: 'getPerson' as const, - params: [] + params: {} } return await this.rpc(request) @@ -415,7 +428,7 @@ class AccountClientImpl implements AccountClient { async getPersonInfo (account: PersonUuid): Promise { const request = { method: 'getPersonInfo' as const, - params: [account] + params: { account } } return await this.rpc(request) @@ -424,7 +437,7 @@ class AccountClientImpl implements AccountClient { async getSocialIds (): Promise { const request = { method: 'getSocialIds' as const, - params: [] + params: {} } return await this.rpc(request) @@ -433,7 +446,7 @@ class AccountClientImpl implements AccountClient { async workerHandshake (region: string, version: Data, operation: WorkspaceOperation): Promise { const request = { method: 'workerHandshake' as const, - params: [region, version, operation] + params: { region, version, operation } } await this.rpc(request) @@ -446,7 +459,7 @@ class AccountClientImpl implements AccountClient { ): Promise { const request = { method: 'getPendingWorkspace' as const, - params: [region, version, operation] + params: { region, version, operation } } const result = await this.rpc(request) @@ -458,7 +471,7 @@ class AccountClientImpl implements AccountClient { } async updateWorkspaceInfo ( - wsUuid: string, + workspaceUuid: string, event: string, version: Data, progress: number, @@ -466,7 +479,7 @@ class AccountClientImpl implements AccountClient { ): Promise { const request = { method: 'updateWorkspaceInfo' as const, - params: [wsUuid, event, version, progress, message] + params: { workspaceUuid, event, version, progress, message } } await this.rpc(request) @@ -475,16 +488,16 @@ class AccountClientImpl implements AccountClient { async getWorkspaceMembers (): Promise { const request = { method: 'getWorkspaceMembers' as const, - params: [] + params: {} } return await this.rpc(request) } - async updateWorkspaceRole (account: string, role: AccountRole): Promise { + async updateWorkspaceRole (targetAccount: string, targetRole: AccountRole): Promise { const request = { method: 'updateWorkspaceRole' as const, - params: [account, role] + params: { targetAccount, targetRole } } await this.rpc(request) @@ -493,7 +506,7 @@ class AccountClientImpl implements AccountClient { async updateWorkspaceName (name: string): Promise { const request = { method: 'updateWorkspaceName' as const, - params: [name] + params: { name } } await this.rpc(request) @@ -502,7 +515,7 @@ class AccountClientImpl implements AccountClient { async deleteWorkspace (): Promise { const request = { method: 'deleteWorkspace' as const, - params: [] + params: {} } await this.rpc(request) @@ -511,7 +524,7 @@ class AccountClientImpl implements AccountClient { async findPerson (socialString: string): Promise { const request = { method: 'findPerson' as const, - params: [socialString] + params: { socialString } } return await this.rpc(request) @@ -520,7 +533,7 @@ class AccountClientImpl implements AccountClient { async listWorkspaces (region?: string | null, mode: WorkspaceMode | null = null): Promise { const request = { method: 'listWorkspaces' as const, - params: [region, mode] + params: { region, mode } } return ((await this.rpc(request)) ?? []).map((ws) => this.flattenStatus(ws)) @@ -533,16 +546,16 @@ class AccountClientImpl implements AccountClient { ): Promise { const request = { method: 'performWorkspaceOperation' as const, - params: [workspaceId, event, ...params] + params: { workspaceId, event, params } } return await this.rpc(request) } - async updateBackupInfo (info: BackupStatus): Promise { + async updateBackupInfo (backupInfo: BackupStatus): Promise { const request = { method: 'updateBackupInfo' as const, - params: [info] + params: { backupInfo } } await this.rpc(request) @@ -551,7 +564,7 @@ class AccountClientImpl implements AccountClient { async assignWorkspace (email: string, workspaceUuid: string, role: AccountRole): Promise { const request = { method: 'assignWorkspace' as const, - params: [email, workspaceUuid, role] + params: { email, workspaceUuid, role } } await this.rpc(request) @@ -560,11 +573,35 @@ class AccountClientImpl implements AccountClient { async updateWorkspaceRoleBySocialId (socialKey: string, targetRole: AccountRole): Promise { const request = { method: 'updateWorkspaceRoleBySocialId' as const, - params: [socialKey, targetRole] + params: { socialKey, targetRole } } await this.rpc(request) } + + async setCookie (): Promise { + const url = concatLink(this.url, '/cookie') + const response = await fetch(url, { ...this.request, method: 'PUT' }) + + if (!response.ok) { + const result = await response.json() + if (result.error != null) { + throw new PlatformError(result.error) + } + } + } + + async deleteCookie (): Promise { + const url = concatLink(this.url, '/cookie') + const response = await fetch(url, { ...this.request, method: 'DELETE' }) + + if (!response.ok) { + const result = await response.json() + if (result.error != null) { + throw new PlatformError(result.error) + } + } + } } async function retry (retries: number, op: () => Promise, delay: number = 100): Promise { diff --git a/plugins/guest-resources/src/connect.ts b/plugins/guest-resources/src/connect.ts index a6a099f126c..ffad8416a5e 100644 --- a/plugins/guest-resources/src/connect.ts +++ b/plugins/guest-resources/src/connect.ts @@ -15,20 +15,14 @@ import { setCurrentEmployee, type Employee } from '@hcengineering/contact' import login, { loginId } from '@hcengineering/login' import { getMetadata, getResource, setMetadata } from '@hcengineering/platform' import presentation, { - closeClient, loadServerConfig, refreshClient, setClient, setPresentationCookie, upgradeDownloadProgress } from '@hcengineering/presentation' -import { - desktopPlatform, - fetchMetadataLocalStorage, - getCurrentLocation, - navigate, - setMetadataLocalStorage -} from '@hcengineering/ui' +import { desktopPlatform, getCurrentLocation, navigate } from '@hcengineering/ui' +import { logOut } from '@hcengineering/workbench' import { writable, get } from 'svelte/store' export const versionError = writable(undefined) @@ -48,7 +42,6 @@ export async function connect (title: string): Promise { }) return } - setMetadata(presentation.metadata.Token, token) const selectWorkspace = await getResource(login.function.SelectWorkspace) const workspaceLoginInfo = (await selectWorkspace(wsUrl, token))[1] @@ -57,10 +50,8 @@ export async function connect (title: string): Promise { `Error selecting workspace ${wsUrl}. There might be something wrong with the token. Please try to log in again.` ) // something went wrong with selecting workspace with the selected token - clearMetadata(wsUrl) - navigate({ - path: [loginId] - }) + await logOut() + navigate({ path: [loginId] }) return } @@ -126,10 +117,11 @@ export async function connect (title: string): Promise { location.reload() }, onUnauthorized: () => { - clearMetadata(wsUrl) - navigate({ - path: [loginId], - query: {} + void logOut().then(() => { + navigate({ + path: [loginId], + query: {} + }) }) }, // We need to refresh all active live queries and clear old queries. @@ -240,22 +232,3 @@ export async function connect (title: string): Promise { return _client } - -function clearMetadata (ws: string): void { - const tokens = fetchMetadataLocalStorage(login.metadata.LoginTokensV2) - if (tokens !== null) { - const loc = getCurrentLocation() - // eslint-disable-next-line - delete tokens[loc.path[1]] - setMetadataLocalStorage(login.metadata.LoginTokensV2, tokens) - } - const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) - if (currentWorkspace !== undefined) { - setPresentationCookie('', currentWorkspace) - } - - setMetadata(presentation.metadata.Token, null) - setMetadataLocalStorage(login.metadata.LastToken, null) - setMetadataLocalStorage(login.metadata.LoginAccount, null) - void closeClient() -} diff --git a/plugins/guest-resources/src/utils.ts b/plugins/guest-resources/src/utils.ts index 7c98303d1ce..30e15b4653b 100644 --- a/plugins/guest-resources/src/utils.ts +++ b/plugins/guest-resources/src/utils.ts @@ -1,9 +1,9 @@ import client from '@hcengineering/client' -import { type Doc } from '@hcengineering/core' +import { type Doc, AccountRole } from '@hcengineering/core' import login from '@hcengineering/login' -import { getMetadata, getResource, setMetadata } from '@hcengineering/platform' +import { getMetadata, getResource } from '@hcengineering/platform' import presentation from '@hcengineering/presentation' -import { fetchMetadataLocalStorage, getCurrentLocation, navigate } from '@hcengineering/ui' +import { getCurrentLocation, navigate } from '@hcengineering/ui' import view from '@hcengineering/view' import { getObjectLinkFragment } from '@hcengineering/view-resources' import { workbenchId } from '@hcengineering/workbench' @@ -11,10 +11,15 @@ import { workbenchId } from '@hcengineering/workbench' export async function checkAccess (doc: Doc): Promise { const loc = getCurrentLocation() const ws = loc.path[1] - const tokens: Record = fetchMetadataLocalStorage(login.metadata.LoginTokensV2) ?? {} - const token = tokens[ws] + + const selectWorkspace = await getResource(login.function.SelectWorkspace) + const wsLoginInfo = (await selectWorkspace(ws, null))[1] + if (wsLoginInfo === undefined || wsLoginInfo.role === AccountRole.DocGuest) return + + const token = wsLoginInfo.token const endpoint = getMetadata(presentation.metadata.Endpoint) if (token === undefined || endpoint === undefined) return + const clientFactory = await getResource(client.function.GetClient) const _client = await clientFactory(token, endpoint) @@ -28,7 +33,7 @@ export async function checkAccess (doc: Doc): Promise { loc.path[0] = workbenchId loc.path[1] = ws // We have access, let's set correct tokens and redirect) - setMetadata(presentation.metadata.Token, token) + // setMetadata(presentation.metadata.Token, token) navigate(loc) } } diff --git a/plugins/login-resources/src/actions.ts b/plugins/login-resources/src/actions.ts index 7dbb32e473c..36905f800e3 100644 --- a/plugins/login-resources/src/actions.ts +++ b/plugins/login-resources/src/actions.ts @@ -1,7 +1,6 @@ import { goTo } from './utils' import login from './plugin' import { type BottomAction } from '.' -import { setMetadataLocalStorage } from '@hcengineering/ui' import { setMetadata } from '@hcengineering/platform' import presentation from '@hcengineering/presentation' @@ -20,7 +19,6 @@ export const loginAction: BottomAction = { page: 'login', func: () => { setMetadata(presentation.metadata.Token, null) - setMetadataLocalStorage(login.metadata.LastToken, null) goTo('login', true) } } diff --git a/plugins/login-resources/src/components/Auth.svelte b/plugins/login-resources/src/components/Auth.svelte index d191e14bf27..25d589a0043 100644 --- a/plugins/login-resources/src/components/Auth.svelte +++ b/plugins/login-resources/src/components/Auth.svelte @@ -1,24 +1,21 @@