diff --git a/.github/workflows/cargo-build.yml b/.github/workflows/cargo-build.yml index 1409c18e..db2592ee 100644 --- a/.github/workflows/cargo-build.yml +++ b/.github/workflows/cargo-build.yml @@ -52,7 +52,7 @@ jobs: id: build-cargo-cache uses: MasterworksIO/action-local-cache@1.0.0 with: - path: ./target + path: ./target/ key: build-cargo-target - name: Cargo Build diff --git a/.github/workflows/cargo-integration-tests.yml b/.github/workflows/cargo-integration-tests.yml index bc87f0f7..c8098134 100644 --- a/.github/workflows/cargo-integration-tests.yml +++ b/.github/workflows/cargo-integration-tests.yml @@ -53,7 +53,7 @@ jobs: id: integration-tests-cargo-cache uses: MasterworksIO/action-local-cache@1.0.0 with: - path: ./target + path: ./target/ key: integration-tests-cargo-target - name: Cargo Integration Tests diff --git a/.github/workflows/cargo-unit-tests.yml b/.github/workflows/cargo-unit-tests.yml index d73f46ba..b742a080 100644 --- a/.github/workflows/cargo-unit-tests.yml +++ b/.github/workflows/cargo-unit-tests.yml @@ -37,7 +37,7 @@ jobs: # needs: skip_check # if: needs.skip_check.outputs.should_skip != 'true' - runs-on: ubuntu-latest + runs-on: self-hosted-unit-tests steps: @@ -54,7 +54,7 @@ jobs: id: unit-tests-cargo-cache uses: MasterworksIO/action-local-cache@1.0.0 with: - path: ./target + path: ./target/ key: unit-tests-cargo-target - name: Cargo Unit Tests diff --git a/.github/workflows/front-admin-build.yml b/.github/workflows/front-admin-build.yml index 0d03aae1..60d24046 100644 --- a/.github/workflows/front-admin-build.yml +++ b/.github/workflows/front-admin-build.yml @@ -17,18 +17,19 @@ on: jobs: - skip_check: - runs-on: ubuntu-latest - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@v5 + # skip_check: + # runs-on: ubuntu-latest + # outputs: + # should_skip: ${{ steps.skip_check.outputs.should_skip }} + # steps: + # - id: skip_check + # uses: fkirc/skip-duplicate-actions@v5 + front-admin-build: - needs: skip_check - if: needs.skip_check.outputs.should_skip != 'true' + # needs: skip_check + # if: needs.skip_check.outputs.should_skip != 'true' defaults: run: diff --git a/.github/workflows/front-admin-typecheck.yml b/.github/workflows/front-admin-typecheck.yml index 367dbd5a..e4c05eaa 100644 --- a/.github/workflows/front-admin-typecheck.yml +++ b/.github/workflows/front-admin-typecheck.yml @@ -17,18 +17,18 @@ on: jobs: - skip_check: - runs-on: ubuntu-latest - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@v5 + # skip_check: + # runs-on: ubuntu-latest + # outputs: + # should_skip: ${{ steps.skip_check.outputs.should_skip }} + # steps: + # - id: skip_check + # uses: fkirc/skip-duplicate-actions@v5 front-admin-typecheck: - needs: skip_check - if: needs.skip_check.outputs.should_skip != 'true' + # needs: skip_check + # if: needs.skip_check.outputs.should_skip != 'true' runs-on: ubuntu-latest diff --git a/.github/workflows/front-server-build.yml b/.github/workflows/front-server-build.yml index 2421e70e..253cdaa3 100644 --- a/.github/workflows/front-server-build.yml +++ b/.github/workflows/front-server-build.yml @@ -17,18 +17,18 @@ on: jobs: - skip_check: - runs-on: ubuntu-latest - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@v5 + # skip_check: + # runs-on: ubuntu-latest + # outputs: + # should_skip: ${{ steps.skip_check.outputs.should_skip }} + # steps: + # - id: skip_check + # uses: fkirc/skip-duplicate-actions@v5 front-server-build: - needs: skip_check - if: needs.skip_check.outputs.should_skip != 'true' + # needs: skip_check + # if: needs.skip_check.outputs.should_skip != 'true' defaults: run: diff --git a/.github/workflows/front-server-unit-tests.yml b/.github/workflows/front-server-unit-tests.yml index 2b8ab889..3486ff3a 100644 --- a/.github/workflows/front-server-unit-tests.yml +++ b/.github/workflows/front-server-unit-tests.yml @@ -17,18 +17,18 @@ on: jobs: - skip_check: - runs-on: ubuntu-latest - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@v5 + # skip_check: + # runs-on: ubuntu-latest + # outputs: + # should_skip: ${{ steps.skip_check.outputs.should_skip }} + # steps: + # - id: skip_check + # uses: fkirc/skip-duplicate-actions@v5 front-server-unit-tests: - needs: skip_check - if: needs.skip_check.outputs.should_skip != 'true' + # needs: skip_check + # if: needs.skip_check.outputs.should_skip != 'true' runs-on: ubuntu-latest diff --git a/.github/workflows/front-studio-build.yml b/.github/workflows/front-studio-build.yml index 027206a9..37489d47 100644 --- a/.github/workflows/front-studio-build.yml +++ b/.github/workflows/front-studio-build.yml @@ -17,19 +17,19 @@ on: jobs: - skip_check: - runs-on: ubuntu-latest - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@v5 + # skip_check: + # runs-on: ubuntu-latest + # outputs: + # should_skip: ${{ steps.skip_check.outputs.should_skip }} + # steps: + # - id: skip_check + # uses: fkirc/skip-duplicate-actions@v5 front-studio-build: - needs: skip_check - if: needs.skip_check.outputs.should_skip != 'true' + # needs: skip_check + # if: needs.skip_check.outputs.should_skip != 'true' defaults: run: diff --git a/.github/workflows/front-studio-typecheck.yml b/.github/workflows/front-studio-typecheck.yml index f7d7407b..dd6f37b4 100644 --- a/.github/workflows/front-studio-typecheck.yml +++ b/.github/workflows/front-studio-typecheck.yml @@ -17,19 +17,19 @@ on: jobs: - skip_check: - runs-on: ubuntu-latest - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@v5 + # skip_check: + # runs-on: ubuntu-latest + # outputs: + # should_skip: ${{ steps.skip_check.outputs.should_skip }} + # steps: + # - id: skip_check + # uses: fkirc/skip-duplicate-actions@v5 front-studio-typecheck: - needs: skip_check - if: needs.skip_check.outputs.should_skip != 'true' + # needs: skip_check + # if: needs.skip_check.outputs.should_skip != 'true' runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 162bb3d6..06f6f6ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: id: release-cargo-cache uses: MasterworksIO/action-local-cache@1.0.0 with: - path: ./target + path: ./target/ key: release-cargo-target - name: Use Node.js ${{ matrix.node-version }} diff --git a/.gitignore b/.gitignore index 17ae7f35..7679a156 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ .env openstream.toml openstream-2.toml +openstream-front.toml +openstream-front-2.toml node_modules/ /release.tar.gz /release-tmp \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index c226b261..e0043a44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -639,6 +639,10 @@ dependencies = [ [[package]] name = "constants" version = "0.1.0" +dependencies = [ + "macros", + "static_init", +] [[package]] name = "convert_case" @@ -1009,6 +1013,7 @@ dependencies = [ "bytes", "chrono", "const-str", + "constants", "crypt", "deepsize", "derive_more", @@ -1026,6 +1031,7 @@ dependencies = [ "mongodb", "once_cell", "parking_lot 0.12.1", + "paste", "prex", "rand 0.8.5", "random-string", @@ -1041,6 +1047,7 @@ dependencies = [ "tokio", "ts-rs", "uid", + "url", "user-agent", "validate", "validify", @@ -1431,9 +1438,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -2017,6 +2024,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "1.9.2" @@ -2501,6 +2518,12 @@ name = "macros" version = "0.1.0" dependencies = [ "macros-build", + "once_cell", + "parking_lot 0.12.1", + "paste", + "serde", + "serde_json", + "static_init", ] [[package]] @@ -2908,9 +2931,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" dependencies = [ "parking_lot_core 0.9.5", ] @@ -3109,6 +3132,7 @@ checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" name = "payments" version = "0.1.0" dependencies = [ + "constants", "reqwest", "serde", "serde_json", @@ -3128,9 +3152,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "phf" @@ -3357,6 +3381,7 @@ version = "0.1.0" dependencies = [ "async-trait", "bytes", + "constants", "futures 0.3.25", "http-auth-basic", "hyper", @@ -3424,6 +3449,7 @@ dependencies = [ "api", "async-stream", "bytes", + "constants", "db", "dotenv", "ffmpeg", @@ -4089,9 +4115,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" dependencies = [ "serde_derive", ] @@ -4125,9 +4151,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", @@ -5291,9 +5317,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-id" @@ -5384,12 +5410,12 @@ dependencies = [ [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", - "idna 0.3.0", + "idna 0.4.0", "percent-encoding", ] @@ -5397,6 +5423,7 @@ dependencies = [ name = "user-agent" version = "0.1.0" dependencies = [ + "deepsize", "prex", "serde", "static_init", @@ -5424,7 +5451,8 @@ dependencies = [ name = "validate" version = "0.1.0" dependencies = [ - "lazy-regex", + "once_cell", + "regex_static", "thiserror", ] diff --git a/defs/UserPublicAccount.ts b/defs/UserPublicAccount.ts index e23af58f..1987d203 100644 --- a/defs/UserPublicAccount.ts +++ b/defs/UserPublicAccount.ts @@ -6,6 +6,7 @@ import type { Metadata } from "./db/Metadata"; export type UserPublicAccount = { _id: string; plan_id: string; + payment_method_id: string | null; name: string; limits: AccountLimits; created_at: DateTime; diff --git a/defs/analytics/Analytics.ts b/defs/analytics/Analytics.ts index 775da524..80338d09 100644 --- a/defs/analytics/Analytics.ts +++ b/defs/analytics/Analytics.ts @@ -23,4 +23,5 @@ export type Analytics = { by_os: Array>; by_country: Array>; by_station: Array>; + by_domain: Array>; }; diff --git a/defs/api/InvitationAccount.ts b/defs/api/InvitationAccount.ts new file mode 100644 index 00000000..627aeaf5 --- /dev/null +++ b/defs/api/InvitationAccount.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type InvitationAccount = { _id: string; name: string }; diff --git a/defs/api/InvitationAdminSender.ts b/defs/api/InvitationAdminSender.ts new file mode 100644 index 00000000..375b00f4 --- /dev/null +++ b/defs/api/InvitationAdminSender.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type InvitationAdminSender = { + _id: string; + first_name: string; + last_name: string; +}; diff --git a/defs/api/InvitationReceiver.ts b/defs/api/InvitationReceiver.ts new file mode 100644 index 00000000..c5579c8e --- /dev/null +++ b/defs/api/InvitationReceiver.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type InvitationReceiver = { + _id: string; + email: string; + first_name: string; + last_name: string; +}; diff --git a/defs/api/InvitationUserSender.ts b/defs/api/InvitationUserSender.ts new file mode 100644 index 00000000..2083c341 --- /dev/null +++ b/defs/api/InvitationUserSender.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type InvitationUserSender = { + _id: string; + first_name: string; + last_name: string; + email: string; +}; diff --git a/defs/api/PublicInvitation.ts b/defs/api/PublicInvitation.ts new file mode 100644 index 00000000..1a7f4cf8 --- /dev/null +++ b/defs/api/PublicInvitation.ts @@ -0,0 +1,23 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AccountInvitationState } from "../db/AccountInvitationState"; +import type { DateTime } from "../DateTime"; +import type { InvitationAccount } from "./InvitationAccount"; +import type { InvitationAdminSender } from "./InvitationAdminSender"; +import type { InvitationReceiver } from "./InvitationReceiver"; +import type { InvitationUserSender } from "./InvitationUserSender"; + +export type PublicInvitation = { + id: string; + user_sender_id: string | null; + admin_sender_id: string | null; + account_id: string; + receiver_email: string; + created_at: DateTime; + deleted_at: DateTime | null; + is_expired: boolean; + expires_at: DateTime; + account: InvitationAccount | null; + user_sender: InvitationUserSender | null; + admin_sender: InvitationAdminSender | null; + receiver: InvitationReceiver | null; +} & AccountInvitationState; diff --git a/defs/api/accounts/POST/Payload.ts b/defs/api/accounts/POST/Payload.ts index 3bd0e703..33774c2f 100644 --- a/defs/api/accounts/POST/Payload.ts +++ b/defs/api/accounts/POST/Payload.ts @@ -7,4 +7,5 @@ export type Payload = { user_id?: string; user_metadata?: Metadata; system_metadata?: Metadata; + payment_method_id: string; }; diff --git a/defs/api/accounts/[account]/GET/Output.ts b/defs/api/accounts/[account]/GET/Output.ts index ff6aabf9..29d51555 100644 --- a/defs/api/accounts/[account]/GET/Output.ts +++ b/defs/api/accounts/[account]/GET/Output.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { PublicAccount } from "../../../../PublicAccount"; -export type Output = { account: PublicAccount }; +export type Output = { is_owner: boolean; account: PublicAccount }; diff --git a/defs/api/accounts/[account]/members/[member]/DELETE/Output.ts b/defs/api/accounts/[account]/members/[member]/DELETE/Output.ts new file mode 100644 index 00000000..26622e8a --- /dev/null +++ b/defs/api/accounts/[account]/members/[member]/DELETE/Output.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { EmptyStruct } from "../../../../../../EmptyStruct"; + +export type Output = EmptyStruct; diff --git a/defs/api/accounts/[account]/members/[member]/set-role/POST/AccessKind.ts b/defs/api/accounts/[account]/members/[member]/set-role/POST/AccessKind.ts new file mode 100644 index 00000000..8352b104 --- /dev/null +++ b/defs/api/accounts/[account]/members/[member]/set-role/POST/AccessKind.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type AccessKind = "owner" | "staff"; diff --git a/defs/api/accounts/[account]/members/[member]/set-role/POST/Output.ts b/defs/api/accounts/[account]/members/[member]/set-role/POST/Output.ts new file mode 100644 index 00000000..fe3ccd5b --- /dev/null +++ b/defs/api/accounts/[account]/members/[member]/set-role/POST/Output.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { EmptyStruct } from "../../../../../../../EmptyStruct"; + +export type Output = EmptyStruct; diff --git a/defs/api/accounts/[account]/members/[member]/set-role/POST/Payload.ts b/defs/api/accounts/[account]/members/[member]/set-role/POST/Payload.ts new file mode 100644 index 00000000..8e69f53b --- /dev/null +++ b/defs/api/accounts/[account]/members/[member]/set-role/POST/Payload.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AccessKind } from "./AccessKind"; + +export type Payload = { role: AccessKind }; diff --git a/defs/api/analytics/GET/CountryCodeOrZZ.ts b/defs/api/analytics/GET/CountryCodeOrZZ.ts new file mode 100644 index 00000000..3e594c3f --- /dev/null +++ b/defs/api/analytics/GET/CountryCodeOrZZ.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CountryCode } from "../../../CountryCode"; +import type { ZZ } from "./ZZ"; + +export type CountryCodeOrZZ = ZZ | CountryCode; diff --git a/defs/api/analytics/GET/Query.ts b/defs/api/analytics/GET/Query.ts index 5802a45e..8c1707d7 100644 --- a/defs/api/analytics/GET/Query.ts +++ b/defs/api/analytics/GET/Query.ts @@ -1,7 +1,12 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CountryCodeOrZZ } from "./CountryCodeOrZZ"; export type Query = { since: /** time::DateTime */ string; until: /** time::DateTime */ string; stations: string[] | undefined; + browser: string | null; + os: string | null; + domain: string | null; + country_code: CountryCodeOrZZ | null; }; diff --git a/defs/api/analytics/GET/ZZ.ts b/defs/api/analytics/GET/ZZ.ts new file mode 100644 index 00000000..24bfdb6e --- /dev/null +++ b/defs/api/analytics/GET/ZZ.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ZZ = "ZZ"; diff --git a/defs/api/invitations/GET/Output.ts b/defs/api/invitations/GET/Output.ts new file mode 100644 index 00000000..10cc544b --- /dev/null +++ b/defs/api/invitations/GET/Output.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Paged } from "../../../Paged"; +import type { PublicInvitation } from "../../PublicInvitation"; + +export type Output = Paged; diff --git a/defs/api/invitations/GET/Query.ts b/defs/api/invitations/GET/Query.ts new file mode 100644 index 00000000..523836e4 --- /dev/null +++ b/defs/api/invitations/GET/Query.ts @@ -0,0 +1,10 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Query = { + skip?: number; + limit?: number; + user_sender_id?: string; + admin_sender_id?: string; + receiver_email?: string; + account_id?: string; +}; diff --git a/defs/api/invitations/POST/Output.ts b/defs/api/invitations/POST/Output.ts new file mode 100644 index 00000000..9dc11b68 --- /dev/null +++ b/defs/api/invitations/POST/Output.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PublicInvitation } from "../../PublicInvitation"; + +export type Output = { invitation: PublicInvitation }; diff --git a/defs/api/invitations/POST/Payload.ts b/defs/api/invitations/POST/Payload.ts new file mode 100644 index 00000000..be48d463 --- /dev/null +++ b/defs/api/invitations/POST/Payload.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Payload = { account_id: string; email: string }; diff --git a/defs/api/invitations/[invitation]/DELETE/Output.ts b/defs/api/invitations/[invitation]/DELETE/Output.ts new file mode 100644 index 00000000..711ba65b --- /dev/null +++ b/defs/api/invitations/[invitation]/DELETE/Output.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { EmptyStruct } from "../../../../EmptyStruct"; + +export type Output = EmptyStruct; diff --git a/defs/api/invitations/[invitation]/GET/Output.ts b/defs/api/invitations/[invitation]/GET/Output.ts new file mode 100644 index 00000000..448d6af7 --- /dev/null +++ b/defs/api/invitations/[invitation]/GET/Output.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PublicInvitation } from "../../../PublicInvitation"; + +export type Output = { invitation: PublicInvitation }; diff --git a/defs/api/invitations/accept/POST/Output.ts b/defs/api/invitations/accept/POST/Output.ts new file mode 100644 index 00000000..3555e01c --- /dev/null +++ b/defs/api/invitations/accept/POST/Output.ts @@ -0,0 +1,12 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Output = + | { result: "ok" } + | { result: "not-found" } + | { result: "expired" } + | { result: "already-accepted" } + | { result: "already-rejected" } + | { result: "already-in-account" } + | { result: "account-deleted" } + | { result: "account-not-found" } + | { result: "email-exists" }; diff --git a/defs/api/invitations/accept/POST/Payload.ts b/defs/api/invitations/accept/POST/Payload.ts new file mode 100644 index 00000000..7b9b7aa5 --- /dev/null +++ b/defs/api/invitations/accept/POST/Payload.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { UnauthenticatedAcceptPayloadData } from "./UnauthenticatedAcceptPayloadData"; + +export type Payload = UnauthenticatedAcceptPayloadData | { + invitation_id: string; +}; diff --git a/defs/api/invitations/accept/POST/UnauthenticatedAcceptPayloadData.ts b/defs/api/invitations/accept/POST/UnauthenticatedAcceptPayloadData.ts new file mode 100644 index 00000000..599424a4 --- /dev/null +++ b/defs/api/invitations/accept/POST/UnauthenticatedAcceptPayloadData.ts @@ -0,0 +1,9 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type UnauthenticatedAcceptPayloadData = { + token: string; + first_name: string; + last_name: string; + phone: string | null; + password: string; +}; diff --git a/defs/api/invitations/get-by-token/[token]/GET/Output.ts b/defs/api/invitations/get-by-token/[token]/GET/Output.ts new file mode 100644 index 00000000..81e25a78 --- /dev/null +++ b/defs/api/invitations/get-by-token/[token]/GET/Output.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PublicInvitation } from "../../../../PublicInvitation"; + +export type Output = ({ kind: "ok" } & { invitation: PublicInvitation }) | { + kind: "not-found"; +}; diff --git a/defs/api/invitations/reject/POST/Output.ts b/defs/api/invitations/reject/POST/Output.ts new file mode 100644 index 00000000..104bed8a --- /dev/null +++ b/defs/api/invitations/reject/POST/Output.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Output = + | { result: "ok" } + | { result: "not-found" } + | { result: "expired" } + | { result: "already-accepted" } + | { result: "already-rejected" }; diff --git a/defs/api/invitations/reject/POST/Payload.ts b/defs/api/invitations/reject/POST/Payload.ts new file mode 100644 index 00000000..d6fd7c51 --- /dev/null +++ b/defs/api/invitations/reject/POST/Payload.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Payload = { token: string } | { invitation_id: string }; diff --git a/defs/api/payment-methods/GET/Output.ts b/defs/api/payment-methods/GET/Output.ts new file mode 100644 index 00000000..4c5e8886 --- /dev/null +++ b/defs/api/payment-methods/GET/Output.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Paged } from "../../../Paged"; +import type { PublicPaymentMethod } from "../../../PublicPaymentMethod"; + +export type Output = Paged; diff --git a/defs/api/payment-methods/GET/Query.ts b/defs/api/payment-methods/GET/Query.ts new file mode 100644 index 00000000..c536016e --- /dev/null +++ b/defs/api/payment-methods/GET/Query.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Query = { skip?: number; limit?: number; user_id?: string }; diff --git a/defs/api/payment-methods/POST/Output.ts b/defs/api/payment-methods/POST/Output.ts new file mode 100644 index 00000000..bbf96566 --- /dev/null +++ b/defs/api/payment-methods/POST/Output.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PublicPaymentMethod } from "../../../PublicPaymentMethod"; + +export type Output = { payment_method: PublicPaymentMethod }; diff --git a/defs/api/payment-methods/POST/Payload.ts b/defs/api/payment-methods/POST/Payload.ts new file mode 100644 index 00000000..f424b704 --- /dev/null +++ b/defs/api/payment-methods/POST/Payload.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Payload = { user_id?: string; nonce: string; device_data: string }; diff --git a/defs/api/payment-methods/[payment-method]/GET/Output.ts b/defs/api/payment-methods/[payment-method]/GET/Output.ts new file mode 100644 index 00000000..743485ff --- /dev/null +++ b/defs/api/payment-methods/[payment-method]/GET/Output.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PublicPaymentMethod } from "../../../../PublicPaymentMethod"; + +export type Output = { payment_method: PublicPaymentMethod }; diff --git a/defs/constants.ts b/defs/constants.ts new file mode 100644 index 00000000..9ea16918 --- /dev/null +++ b/defs/constants.ts @@ -0,0 +1,44 @@ +/// This file is auto generated from its Rust definition, do not edit manually + + +export const ACCESS_TOKEN_HEADER = "x-access-token"; + +export const ACCESS_TOKEN_NOT_USED_AUTOREMOVE_SECS = 604800; + +export const ACCOUNT_INVITATION_VALIDITY_SECS = 604800; + +export const API_IP_LIMIT = 60; + +export const API_IP_LIMIT_DURATION_SECS = 60; + +export const AUDIO_FILE_BYTERATE = 16000; + +export const AUDIO_FILE_CHUNK_SIZE = 256000; + +export const EMAIL_VERIFICATION_CODE_LEN = 6; + +export const EMAIL_VERIFICATION_VALIDITY_SECS = 3600; + +export const FORWARD_IP_HEADER = "x-openstream-forwarded-ip"; + +export const PAYMENTS_ACCESS_TOKEN_HEADER = "x-access-token"; + +export const PLAYLIST_NO_LISTENERS_SHUTDOWN_DELAY_SECS = 10; + +export const REAL_IP_HEADER = "x-real-ip"; + +export const RELAY_NO_LISTENERS_SHUTDOWN_DELAY_SECS = 10; + +export const STREAM_BURST_LENGTH = 8; + +export const STREAM_CHANNEL_CAPACITY = 5; + +export const STREAM_CHUNK_SIZE = 16000; + +export const STREAM_IP_CONNECTIONS_LIMIT = 8; + +export const STREAM_KBITRATE = 128; + +export const TOKEN_USER_RECOVERY_VALIDITY_SECS = 3600; + +export const TRANSFER_SAVE_INTERVAL_MILLIS = 5000; \ No newline at end of file diff --git a/defs/db/Account.ts b/defs/db/Account.ts index c92cf6a5..dc61704a 100644 --- a/defs/db/Account.ts +++ b/defs/db/Account.ts @@ -6,6 +6,7 @@ import type { Metadata } from "./Metadata"; export type Account = { _id: string; plan_id: string; + payment_method_id: string | null; name: string; limits: AccountLimits; created_at: DateTime; diff --git a/defs/db/AccountInvitationState.ts b/defs/db/AccountInvitationState.ts new file mode 100644 index 00000000..e713c4d1 --- /dev/null +++ b/defs/db/AccountInvitationState.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DateTime } from "../DateTime"; + +export type AccountInvitationState = + | { state: "pending" } + | ({ state: "accepted" } & { used_at: DateTime }) + | ({ state: "rejected" } & { used_at: DateTime }); diff --git a/defs/db/RelaySessionBase.ts b/defs/db/RelaySession.ts similarity index 93% rename from defs/db/RelaySessionBase.ts rename to defs/db/RelaySession.ts index f6dafc54..fd861035 100644 --- a/defs/db/RelaySessionBase.ts +++ b/defs/db/RelaySession.ts @@ -2,7 +2,7 @@ import type { DateTime } from "../DateTime"; import type { RelaySessionState } from "./RelaySessionState"; -export type RelaySessionBase = { +export type RelaySession = { _id: string; station_id: string; deployment_id: string; diff --git a/defs/db/SentEmailKind.ts b/defs/db/SentEmailKind.ts index 024688de..656ee364 100644 --- a/defs/db/SentEmailKind.ts +++ b/defs/db/SentEmailKind.ts @@ -6,4 +6,12 @@ export type SentEmailKind = { } | { kind: "email-verification-code"; data: { email: string; code_id: string }; +} | { + kind: "account-invitation"; + data: { + receiver_email: string; + invitation_id: string; + user_sender_id: string | null; + admin_sender_id: string | null; + }; }; diff --git a/defs/db/StreamConnectionLite.ts b/defs/db/StreamConnectionLite.ts index 88ccbfc2..dc5a782b 100644 --- a/defs/db/StreamConnectionLite.ts +++ b/defs/db/StreamConnectionLite.ts @@ -11,6 +11,7 @@ export type StreamConnectionLite = { du: number | null; by: number | null; br: string | null; + do: string | null; os: string | null; ca: DateTime; }; diff --git a/defs/db/TokenUserEmailConfirmation.ts b/defs/db/TokenUserEmailConfirmation.ts deleted file mode 100644 index d17b87a5..00000000 --- a/defs/db/TokenUserEmailConfirmation.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { DateTime } from "../DateTime"; - -export type TokenUserEmailConfirmation = { - _id: string; - hash: string; - user_id: string; - email: string; - accepted_at: DateTime | null; - created_at: DateTime; -}; diff --git a/defs/error/PublicErrorCode.ts b/defs/error/PublicErrorCode.ts index 6692a740..d5ff7cd5 100644 --- a/defs/error/PublicErrorCode.ts +++ b/defs/error/PublicErrorCode.ts @@ -15,6 +15,7 @@ export type PublicErrorCode = | "TOKEN_STATION_NOT_FOUND" | "TOKEN_ADMIN_NOT_FOUND" | "TOKEN_OUT_OF_SCOPE" + | "TOKEN_USER_ACCOUNT_NOT_OWNER" | "STATION_NOT_FOUND" | "ADMIN_NOT_FOUND" | "USER_NOT_FOUND" @@ -22,6 +23,8 @@ export type PublicErrorCode = | "AUDIO_FILE_NOT_FOUND" | "DEVICE_NOT_FOUND" | "PLAN_NOT_FOUND" + | "PAYMENT_METHOD_NOT_FOUND" + | "INVITATION_NOT_FOUND" | "QUERY_STRING_INVALID" | "PAYLOAD_IO" | "PAYLOAD_JSON" diff --git a/front/admin/package-lock.json b/front/admin/package-lock.json index e51f8c94..709963ca 100644 --- a/front/admin/package-lock.json +++ b/front/admin/package-lock.json @@ -11,7 +11,7 @@ "@mdi/js": "^7.0.96", "@playwright/test": "1.25.0", "@sveltejs/adapter-node": "^1.1.4", - "@sveltejs/kit": "^1.15.0", + "@sveltejs/kit": "^1.20.2", "@types/color": "^3.0.3", "@types/cookie": "^0.5.1", "@typescript-eslint/eslint-plugin": "^5.27.0", @@ -25,7 +25,7 @@ "kleur": "^4.1.5", "prettier": "^2.6.2", "prettier-plugin-svelte": "^2.7.0", - "svelte": "^3.46.0", + "svelte": "^3.59.1", "svelte-check": "^2.7.1", "svelte-preprocess": "^4.10.6", "ts-patch": "^2.1.0", @@ -682,25 +682,25 @@ } }, "node_modules/@sveltejs/kit": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.15.2.tgz", - "integrity": "sha512-rLNxZrjbrlPf8AWW8GAU4L/Vvu17e9v8EYl7pUip7x72lTft7RcxeP3z7tsrHpMSBBxC9o4XdKzFvz1vMZyXZw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.20.2.tgz", + "integrity": "sha512-MtR1i+HtmYWcRgtubw1GQqT/+CWXL/z24PegE0xYAdObbhdr7YtEfmoe705D/JZMtMmoPXrmSk4W0MfL5A3lYw==", "dev": true, "hasInstallScript": true, "dependencies": { - "@sveltejs/vite-plugin-svelte": "^2.0.0", + "@sveltejs/vite-plugin-svelte": "^2.4.1", "@types/cookie": "^0.5.1", "cookie": "^0.5.0", - "devalue": "^4.3.0", + "devalue": "^4.3.1", "esm-env": "^1.0.0", "kleur": "^4.1.5", "magic-string": "^0.30.0", "mime": "^3.0.0", "sade": "^1.8.1", - "set-cookie-parser": "^2.5.1", + "set-cookie-parser": "^2.6.0", "sirv": "^2.0.2", "tiny-glob": "^0.2.9", - "undici": "5.20.0" + "undici": "~5.22.0" }, "bin": { "svelte-kit": "svelte-kit.js" @@ -709,7 +709,7 @@ "node": "^16.14 || >=18" }, "peerDependencies": { - "svelte": "^3.54.0", + "svelte": "^3.54.0 || ^4.0.0-next.0", "vite": "^4.0.0" } }, @@ -726,11 +726,12 @@ } }, "node_modules/@sveltejs/vite-plugin-svelte": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.0.4.tgz", - "integrity": "sha512-pjqhW00KwK2uzDGEr+yJBwut+D+4XfJO/+bHHdHzPRXn9+1Jeq5JcFHyrUiYaXgHtyhX0RsllCTm4ssAx4ZY7Q==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.4.1.tgz", + "integrity": "sha512-bNNKvoRY89ptY7udeBSCmTdCVwkjmMcZ0j/z9J5MuedT8jPjq0zrknAo/jF1sToAza4NVaAgR9AkZoD9oJJmnA==", "dev": true, "dependencies": { + "@sveltejs/vite-plugin-svelte-inspector": "^1.0.2", "debug": "^4.3.4", "deepmerge": "^4.3.1", "kleur": "^4.1.5", @@ -742,7 +743,24 @@ "node": "^14.18.0 || >= 16" }, "peerDependencies": { - "svelte": "^3.54.0", + "svelte": "^3.54.0 || ^4.0.0-next.0", + "vite": "^4.0.0" + } + }, + "node_modules/@sveltejs/vite-plugin-svelte-inspector": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-1.0.2.tgz", + "integrity": "sha512-Cy1dUMcYCnDVV/hPLXa43YZJ2jGKVW5rA0xuNL9dlmYhT0yoS1g7+FOFSRlgk0BXKk/Oc7grs+8BVA5Iz2fr8A==", + "dev": true, + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": "^14.18.0 || >= 16" + }, + "peerDependencies": { + "@sveltejs/vite-plugin-svelte": "^2.2.0", + "svelte": "^3.54.0 || ^4.0.0-next.0", "vite": "^4.0.0" } }, @@ -1466,9 +1484,9 @@ } }, "node_modules/devalue": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/devalue/-/devalue-4.3.0.tgz", - "integrity": "sha512-n94yQo4LI3w7erwf84mhRUkUJfhLoCZiLyoOZ/QFsDbcWNZePrLwbQpvZBUG2TNxwV3VjCKPxkiiQA6pe3TrTA==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-4.3.2.tgz", + "integrity": "sha512-KqFl6pOgOW+Y6wJgu80rHpo2/3H07vr8ntR9rkkFIRETewbf5GaYYcakYfiKz89K+sLsuPkQIZaXDMjUObZwWg==", "dev": true }, "node_modules/dir-glob": { @@ -3415,9 +3433,9 @@ } }, "node_modules/svelte": { - "version": "3.58.0", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.58.0.tgz", - "integrity": "sha512-brIBNNB76mXFmU/Kerm4wFnkskBbluBDCjx/8TcpYRb298Yh2dztS2kQ6bhtjMcvUhd5ynClfwpz5h2gnzdQ1A==", + "version": "3.59.1", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.59.1.tgz", + "integrity": "sha512-pKj8fEBmqf6mq3/NfrB9SLtcJcUvjYSWyePlfCqN9gujLB25RitWK8PvFzlwim6hD/We35KbPlRteuA6rnPGcQ==", "dev": true, "engines": { "node": ">= 8" @@ -3446,15 +3464,15 @@ } }, "node_modules/svelte-hmr": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/svelte-hmr/-/svelte-hmr-0.15.1.tgz", - "integrity": "sha512-BiKB4RZ8YSwRKCNVdNxK/GfY+r4Kjgp9jCLEy0DuqAKfmQtpL38cQK3afdpjw4sqSs4PLi3jIPJIFp259NkZtA==", + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/svelte-hmr/-/svelte-hmr-0.15.2.tgz", + "integrity": "sha512-q/bAruCvFLwvNbeE1x3n37TYFb3mTBJ6TrCq6p2CoFbSTNhDE9oAtEfpy+wmc9So8AG0Tja+X0/mJzX9tSfvIg==", "dev": true, "engines": { "node": "^12.20 || ^14.13.1 || >= 16" }, "peerDependencies": { - "svelte": ">=3.19.0" + "svelte": "^3.19.0 || ^4.0.0-next.0" } }, "node_modules/svelte-preprocess": { @@ -3701,15 +3719,15 @@ } }, "node_modules/undici": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz", - "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==", + "version": "5.22.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.22.1.tgz", + "integrity": "sha512-Ji2IJhFXZY0x/0tVBXeQwgPlLWw13GVzpsWPQ3rV50IFMMof2I55PZZxtm4P6iNq+L5znYN9nSTAq0ZyE6lSJw==", "dev": true, "dependencies": { "busboy": "^1.6.0" }, "engines": { - "node": ">=12.18" + "node": ">=14.0" } }, "node_modules/uri-js": { @@ -4251,24 +4269,24 @@ } }, "@sveltejs/kit": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.15.2.tgz", - "integrity": "sha512-rLNxZrjbrlPf8AWW8GAU4L/Vvu17e9v8EYl7pUip7x72lTft7RcxeP3z7tsrHpMSBBxC9o4XdKzFvz1vMZyXZw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.20.2.tgz", + "integrity": "sha512-MtR1i+HtmYWcRgtubw1GQqT/+CWXL/z24PegE0xYAdObbhdr7YtEfmoe705D/JZMtMmoPXrmSk4W0MfL5A3lYw==", "dev": true, "requires": { - "@sveltejs/vite-plugin-svelte": "^2.0.0", + "@sveltejs/vite-plugin-svelte": "^2.4.1", "@types/cookie": "^0.5.1", "cookie": "^0.5.0", - "devalue": "^4.3.0", + "devalue": "^4.3.1", "esm-env": "^1.0.0", "kleur": "^4.1.5", "magic-string": "^0.30.0", "mime": "^3.0.0", "sade": "^1.8.1", - "set-cookie-parser": "^2.5.1", + "set-cookie-parser": "^2.6.0", "sirv": "^2.0.2", "tiny-glob": "^0.2.9", - "undici": "5.20.0" + "undici": "~5.22.0" }, "dependencies": { "magic-string": { @@ -4283,11 +4301,12 @@ } }, "@sveltejs/vite-plugin-svelte": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.0.4.tgz", - "integrity": "sha512-pjqhW00KwK2uzDGEr+yJBwut+D+4XfJO/+bHHdHzPRXn9+1Jeq5JcFHyrUiYaXgHtyhX0RsllCTm4ssAx4ZY7Q==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.4.1.tgz", + "integrity": "sha512-bNNKvoRY89ptY7udeBSCmTdCVwkjmMcZ0j/z9J5MuedT8jPjq0zrknAo/jF1sToAza4NVaAgR9AkZoD9oJJmnA==", "dev": true, "requires": { + "@sveltejs/vite-plugin-svelte-inspector": "^1.0.2", "debug": "^4.3.4", "deepmerge": "^4.3.1", "kleur": "^4.1.5", @@ -4307,6 +4326,15 @@ } } }, + "@sveltejs/vite-plugin-svelte-inspector": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-1.0.2.tgz", + "integrity": "sha512-Cy1dUMcYCnDVV/hPLXa43YZJ2jGKVW5rA0xuNL9dlmYhT0yoS1g7+FOFSRlgk0BXKk/Oc7grs+8BVA5Iz2fr8A==", + "dev": true, + "requires": { + "debug": "^4.3.4" + } + }, "@types/color": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/color/-/color-3.0.3.tgz", @@ -4793,9 +4821,9 @@ "dev": true }, "devalue": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/devalue/-/devalue-4.3.0.tgz", - "integrity": "sha512-n94yQo4LI3w7erwf84mhRUkUJfhLoCZiLyoOZ/QFsDbcWNZePrLwbQpvZBUG2TNxwV3VjCKPxkiiQA6pe3TrTA==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-4.3.2.tgz", + "integrity": "sha512-KqFl6pOgOW+Y6wJgu80rHpo2/3H07vr8ntR9rkkFIRETewbf5GaYYcakYfiKz89K+sLsuPkQIZaXDMjUObZwWg==", "dev": true }, "dir-glob": { @@ -6200,9 +6228,9 @@ "dev": true }, "svelte": { - "version": "3.58.0", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.58.0.tgz", - "integrity": "sha512-brIBNNB76mXFmU/Kerm4wFnkskBbluBDCjx/8TcpYRb298Yh2dztS2kQ6bhtjMcvUhd5ynClfwpz5h2gnzdQ1A==", + "version": "3.59.1", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.59.1.tgz", + "integrity": "sha512-pKj8fEBmqf6mq3/NfrB9SLtcJcUvjYSWyePlfCqN9gujLB25RitWK8PvFzlwim6hD/We35KbPlRteuA6rnPGcQ==", "dev": true }, "svelte-check": { @@ -6222,9 +6250,9 @@ } }, "svelte-hmr": { - "version": "0.15.1", - "resolved": "https://registry.npmjs.org/svelte-hmr/-/svelte-hmr-0.15.1.tgz", - "integrity": "sha512-BiKB4RZ8YSwRKCNVdNxK/GfY+r4Kjgp9jCLEy0DuqAKfmQtpL38cQK3afdpjw4sqSs4PLi3jIPJIFp259NkZtA==", + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/svelte-hmr/-/svelte-hmr-0.15.2.tgz", + "integrity": "sha512-q/bAruCvFLwvNbeE1x3n37TYFb3mTBJ6TrCq6p2CoFbSTNhDE9oAtEfpy+wmc9So8AG0Tja+X0/mJzX9tSfvIg==", "dev": true, "requires": {} }, @@ -6384,9 +6412,9 @@ "dev": true }, "undici": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.20.0.tgz", - "integrity": "sha512-J3j60dYzuo6Eevbawwp1sdg16k5Tf768bxYK4TUJRH7cBM4kFCbf3mOnM/0E3vQYXvpxITbbWmBafaDbxLDz3g==", + "version": "5.22.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.22.1.tgz", + "integrity": "sha512-Ji2IJhFXZY0x/0tVBXeQwgPlLWw13GVzpsWPQ3rV50IFMMof2I55PZZxtm4P6iNq+L5znYN9nSTAq0ZyE6lSJw==", "dev": true, "requires": { "busboy": "^1.6.0" diff --git a/front/admin/package.json b/front/admin/package.json index a7542623..14ee9a65 100644 --- a/front/admin/package.json +++ b/front/admin/package.json @@ -18,7 +18,7 @@ "@mdi/js": "^7.0.96", "@playwright/test": "1.25.0", "@sveltejs/adapter-node": "^1.1.4", - "@sveltejs/kit": "^1.15.0", + "@sveltejs/kit": "^1.20.2", "@types/color": "^3.0.3", "@types/cookie": "^0.5.1", "@typescript-eslint/eslint-plugin": "^5.27.0", @@ -32,7 +32,7 @@ "kleur": "^4.1.5", "prettier": "^2.6.2", "prettier-plugin-svelte": "^2.7.0", - "svelte": "^3.46.0", + "svelte": "^3.59.1", "svelte-check": "^2.7.1", "svelte-preprocess": "^4.10.6", "ts-patch": "^2.1.0", diff --git a/front/admin/src/hooks.server.ts b/front/admin/src/hooks.server.ts index f926898a..b5397b91 100644 --- a/front/admin/src/hooks.server.ts +++ b/front/admin/src/hooks.server.ts @@ -1,6 +1,6 @@ import type { Handle, HandleFetch } from "@sveltejs/kit"; import { env } from "./env.server"; -import { FORWARD_IP_HEADER, PROTOCOL_HEADER, X_REAL_IP } from "$server/constants"; +import { FORWARD_IP_HEADER, PROTOCOL_HEADER, REAL_IP_HEADER } from "$server/constants"; import { server_logger } from "$lib/logger.server"; export const handle: Handle = async ({ event, resolve }) => { @@ -11,8 +11,8 @@ export const handle: Handle = async ({ event, resolve }) => { const start = Date.now(); - const ip = event.request.headers.get(X_REAL_IP); - if(ip == null) server_logger.warn(`handle: received request without ${X_REAL_IP} header: ${event.request.url}`); + const ip = event.request.headers.get(REAL_IP_HEADER); + if(ip == null) server_logger.warn(`handle: received request without ${REAL_IP_HEADER} header: ${event.request.url}`); event.locals.ip = ip || "0.0.0.0"; let proto_header = event.request.headers.get(PROTOCOL_HEADER); diff --git a/front/admin/src/lib/components/Dashboard/TopUser.svelte b/front/admin/src/lib/components/Dashboard/TopUser.svelte index 3b5b3bb7..3c8e8fea 100644 --- a/front/admin/src/lib/components/Dashboard/TopUser.svelte +++ b/front/admin/src/lib/components/Dashboard/TopUser.svelte @@ -14,7 +14,7 @@ const sign_out = action(async () => { await _post("/api/auth/admin/logout", {}); goto("/", { invalidateAll: true }) - invalidate_siblings(); + invalidate_siblings() }) let menu_open = false; diff --git a/front/admin/src/lib/components/SimpleLogo.svelte b/front/admin/src/lib/components/SimpleLogo.svelte index ebdb9b28..a5959665 100644 --- a/front/admin/src/lib/components/SimpleLogo.svelte +++ b/front/admin/src/lib/components/SimpleLogo.svelte @@ -31,10 +31,10 @@ } - diff --git a/front/admin/src/routes/(online)/(app)/plans/[plan]/+page.svelte b/front/admin/src/routes/(online)/(app)/plans/[plan]/+page.svelte index 6335e9f5..9f525f79 100644 --- a/front/admin/src/routes/(online)/(app)/plans/[plan]/+page.svelte +++ b/front/admin/src/routes/(online)/(app)/plans/[plan]/+page.svelte @@ -77,7 +77,7 @@ let delete_open = false; const del = action(async () => { await _delete(`/api/plans/${data.plan._id}`); - goto("/plans", { invalidateAll: true }); + goto("/plans", { invalidateAll: true }) invalidate_siblings(); }) diff --git a/front/admin/src/routes/(online)/(login)/login/+page.svelte b/front/admin/src/routes/(online)/(login)/login/+page.svelte index 7587c926..f59df294 100644 --- a/front/admin/src/routes/(online)/(login)/login/+page.svelte +++ b/front/admin/src/routes/(online)/(login)/login/+page.svelte @@ -17,7 +17,7 @@ const login = action(async () => { const payload: Omit = { email, password }; await _post("/api/auth/admin/login", payload); - const target = decodeURIComponent(location.hash.replace(/^#/, "")) || "/"; + const target = location.hash.replace(/^#/, "") || "/"; goto(target, { invalidateAll: true }); invalidate_siblings(); }) @@ -45,7 +45,7 @@ + {/each} + + {/if} + + + +{#if to_reject_item != null} + (to_reject_item = null)} + > +
+
+ {$locale.pages['me/invitations'].dialogs.reject.message} +
+
+ + + +
+
+
+{/if} \ No newline at end of file diff --git a/front/app/src/routes/(root)/(online)/(app)/me/invitations/+page.ts b/front/app/src/routes/(root)/(online)/(app)/me/invitations/+page.ts new file mode 100644 index 00000000..28aa472a --- /dev/null +++ b/front/app/src/routes/(root)/(online)/(app)/me/invitations/+page.ts @@ -0,0 +1,13 @@ +import { load_get } from "$lib/load"; + +export const load = (async ({ fetch, url, depends }) => { + + depends("resource:invitations"); + depends("api:invitations"); + + // TODO: implement pagination + const invitations = await load_get(`/api/invitations?limit=10000`, { fetch, url }); + + return { invitations } + +}) satisfies import("./$types").PageLoad; \ No newline at end of file diff --git a/front/app/src/routes/(root)/(online)/(login)/email-invitations/[token]/+page.svelte b/front/app/src/routes/(root)/(online)/(login)/email-invitations/[token]/+page.svelte new file mode 100644 index 00000000..7975a166 --- /dev/null +++ b/front/app/src/routes/(root)/(online)/(login)/email-invitations/[token]/+page.svelte @@ -0,0 +1,325 @@ + + + + + + {title} + + + +
+

{title}

+ + {#if invitation_description_html} +
+ {@html invitation_description_html} +
+ {/if} + + {#if + data.result.kind === "ok" && + !data.result.invitation.is_expired && + data.result.invitation.state === "pending" + } + {#if data.result.invitation.receiver != null} +
+ {:else} +
+
+ {@html $locale.pages.email_invitation.form.pre_message_html} +
+ + + + + + + + + + +
+ {/if} + + {:else} +
+
+ {error_message} +
+
+ {/if} +
+ diff --git a/front/app/src/routes/(root)/(online)/(login)/email-invitations/[token]/+page.ts b/front/app/src/routes/(root)/(online)/(login)/email-invitations/[token]/+page.ts new file mode 100644 index 00000000..de9bd250 --- /dev/null +++ b/front/app/src/routes/(root)/(online)/(login)/email-invitations/[token]/+page.ts @@ -0,0 +1,25 @@ +import { load_get } from '$lib/load.js'; +import { redirect } from '@sveltejs/kit'; + +export const load = (async ({ depends, url, fetch, params, parent }) => { + + depends("resource:invitations"); + depends("api:invitations"); + + const { token } = params; + const result = await load_get(`/api/invitations/get-by-token/${token}`, { fetch, url }, { redirectToLoginOnAuthErrors: false }); + const { maybe_user } = await parent(); + + // if the user receiver of the invitation is already logged in + // we send him directly to the logged-in version of this page + if(result.kind === "ok") { + if(result.invitation.receiver && maybe_user) { + if(result.invitation.receiver._id === maybe_user._id) { + throw redirect(302, "/me/invitations"); + } + } + } + + return { result, token } + +}) satisfies import("./$types").PageLoad; \ No newline at end of file diff --git a/front/app/src/routes/(root)/(online)/(login)/login/+page.svelte b/front/app/src/routes/(root)/(online)/(login)/login/+page.svelte index d62a08e9..0c13deb4 100644 --- a/front/app/src/routes/(root)/(online)/(login)/login/+page.svelte +++ b/front/app/src/routes/(root)/(online)/(login)/login/+page.svelte @@ -12,15 +12,18 @@ import { locale } from "$lib/locale"; import { invalidate_siblings } from "$lib/invalidate"; - let email = ""; + import { page } from "$app/stores"; + + let email = $page.url.searchParams.get("email")?.trim() || ""; let password = ""; const login = action(async () => { const payload: Omit = { email, password }; await _post("/api/auth/user/login", payload); - const target = decodeURIComponent(location.hash.replace(/^#/, "")) || "/"; - goto(target, { invalidateAll: true }); - invalidate_siblings(); + const target = location.hash.replace(/^#/, "") || "/"; + goto(target, { invalidateAll: true }).then(() => { + invalidate_siblings(); + }); }) @@ -46,7 +49,7 @@