diff --git a/apps/account-deletion-website/app/utils.ts b/apps/account-deletion-website/app/utils.ts index 28dfdd378..ef32aa5be 100644 --- a/apps/account-deletion-website/app/utils.ts +++ b/apps/account-deletion-website/app/utils.ts @@ -1,8 +1,11 @@ +import {Schema} from '@effect/schema' import {ecdsa} from '@vexl-next/cryptography' import { PrivateKeyHolder, type PublicKeyPemBase64, } from '@vexl-next/cryptography/src/KeyHolder' +import {SemverStringE} from '@vexl-next/domain/src/utility/SmeverString.brand' +import {VersionCode} from '@vexl-next/domain/src/utility/VersionCode.brand' import { parseJson, safeParse, @@ -21,6 +24,12 @@ import type z from 'zod' const STORAGE_KEYPAIR_KEY = 'keypair' +const apiMeta = { + clientVersion: Schema.decodeSync(VersionCode)(0), + clientSemver: Schema.decodeSync(SemverStringE)('0.0.1'), + platform: 'WEB' as const, +} + export function saveKeypair(keypair: PrivateKeyHolder): void { sessionStorage.setItem(STORAGE_KEYPAIR_KEY, JSON.stringify(keypair)) } @@ -113,8 +122,7 @@ export function parseFormData( export function createUserPublicApi(): userApi.UserPublicApi { return userApi.publicApi({ url: getEnvPreset().userMs, - clientVersion: 130, - platform: 'WEB', + ...apiMeta, }) } @@ -128,14 +136,13 @@ export function createContactsPrivateApi({ signature: string }): contactsApi.ContactPrivateApi { return contactsApi.privateApi({ - clientVersion: 130, getUserSessionCredentials: () => ({ hash, publicKey, signature, }), - platform: 'WEB', url: getEnvPreset().contactMs, + ...apiMeta, }) } @@ -149,13 +156,12 @@ export function createUserPrivateApi({ signature: string }): userApi.UserPrivateApi { return userApi.privateApi({ - clientVersion: 130, getUserSessionCredentials: () => ({ hash, publicKey, signature, }), - platform: 'WEB', url: getEnvPreset().userMs, + ...apiMeta, }) } diff --git a/apps/account-deletion-website/package.json b/apps/account-deletion-website/package.json index ea55bc6fe..bbdfaa4a3 100644 --- a/apps/account-deletion-website/package.json +++ b/apps/account-deletion-website/package.json @@ -11,6 +11,7 @@ "typecheck": "tsc --noEmit" }, "dependencies": { + "@effect/schema": "^0.70.4", "@remix-run/css-bundle": "^2.8.1", "@remix-run/express": "^2.8.1", "@remix-run/node": "^2.8.1", @@ -26,6 +27,7 @@ "buffer": "^6.0.3", "cross-env": "^7.0.3", "crypto-browserify": "^3.12.0", + "effect": "^3.6.3", "events": "^3.3.0", "express": "^4.19.2", "fp-ts": "^2.13.1", diff --git a/apps/btc-exchange-rate-service/package.json b/apps/btc-exchange-rate-service/package.json index 1e6141c6a..f06035f31 100644 --- a/apps/btc-exchange-rate-service/package.json +++ b/apps/btc-exchange-rate-service/package.json @@ -21,13 +21,13 @@ ] }, "dependencies": { - "@effect/experimental": "^0.22.1", - "@effect/opentelemetry": "^0.35.1", - "@effect/platform": "^0.61.4", - "@effect/platform-node": "^0.56.4", - "@effect/schema": "^0.70.2", - "@effect/sql": "^0.8.3", - "@effect/sql-pg": "^0.8.3", + "@effect/experimental": "^0.22.6", + "@effect/opentelemetry": "^0.35.3", + "@effect/platform": "^0.61.8", + "@effect/platform-node": "^0.56.9", + "@effect/schema": "^0.70.4", + "@effect/sql": "^0.8.7", + "@effect/sql-pg": "^0.8.7", "@opentelemetry/exporter-trace-otlp-http": "^0.52.1", "@opentelemetry/sdk-trace-node": "^1.23.0", "@opentelemetry/sdk-trace-web": "^1.23.0", @@ -39,9 +39,9 @@ "@vexl-next/rest-api": "0.0.0", "@vexl-next/server-utils": "0.0.0", "dotenv": "^16.4.5", - "effect": "^3.6.1", - "effect-http": "^0.77.3", - "effect-http-node": "^0.17.6", + "effect": "^3.6.3", + "effect-http": "^0.77.4", + "effect-http-node": "^0.17.7", "fast-check": "^3.20.0", "ioredis": "^5.4.1", "node-fetch": "^3.3.2" diff --git a/apps/user-service/src/routes/login/domain.ts b/apps/user-service/src/routes/login/domain.ts index 4424fdfc6..d6d68d43f 100644 --- a/apps/user-service/src/routes/login/domain.ts +++ b/apps/user-service/src/routes/login/domain.ts @@ -1,8 +1,8 @@ import {Schema} from '@effect/schema' import {PublicKeyPemBase64E} from '@vexl-next/cryptography/src/KeyHolder/brands' import {CountryPrefixE} from '@vexl-next/domain/src/general/CountryPrefix.brand' +import {HashedPhoneNumberE} from '@vexl-next/domain/src/general/HashedPhoneNumber.brand' import {UnixMillisecondsE} from '@vexl-next/domain/src/utility/UnixMilliseconds.brand' -import {HmacHash} from '@vexl-next/generic-utils/src/effect-helpers/crypto' import { PhoneNumberVerificationId, VerificationChallenge, @@ -12,7 +12,7 @@ import {TwilioVerificationSid} from '../../utils/twilio' export const ChallengeVerificationState = Schema.Struct({ publicKey: PublicKeyPemBase64E, countryPrefix: CountryPrefixE, - phoneNumber: HmacHash, + phoneNumber: HashedPhoneNumberE, expiresAt: UnixMillisecondsE, challenge: VerificationChallenge, }) @@ -26,7 +26,7 @@ export const PhoneVerificationState = Schema.Union( id: PhoneNumberVerificationId, type: Schema.Literal('twilioSmsVerification'), sid: TwilioVerificationSid, - phoneNumber: HmacHash, + phoneNumber: HashedPhoneNumberE, countryPrefix: CountryPrefixE, expiresAt: UnixMillisecondsE, }), @@ -34,7 +34,7 @@ export const PhoneVerificationState = Schema.Union( id: PhoneNumberVerificationId, type: Schema.Literal('staticCodeVerification'), code: Schema.String, - phoneNumber: HmacHash, + phoneNumber: HashedPhoneNumberE, countryPrefix: CountryPrefixE, expiresAt: UnixMillisecondsE, }) diff --git a/packages/resources-utils/src/offers/utils/fetchContactsForOffer.ts b/packages/resources-utils/src/offers/utils/fetchContactsForOffer.ts index eecf39d3e..6a6e5ed48 100644 --- a/packages/resources-utils/src/offers/utils/fetchContactsForOffer.ts +++ b/packages/resources-utils/src/offers/utils/fetchContactsForOffer.ts @@ -1,6 +1,6 @@ import {type PublicKeyPemBase64} from '@vexl-next/cryptography/src/KeyHolder' import { - ConnectionLevel, + type ConnectionLevel, type IntendedConnectionLevel, } from '@vexl-next/domain/src/general/offers' import {type ContactPrivateApi} from '@vexl-next/rest-api/src/services/contact' diff --git a/packages/rest-api/src/services/location/index.ts b/packages/rest-api/src/services/location/index.ts index 88c1f2d11..b313d6422 100644 --- a/packages/rest-api/src/services/location/index.ts +++ b/packages/rest-api/src/services/location/index.ts @@ -1,5 +1,5 @@ -import {SemverString} from '@vexl-next/domain/src/utility/SmeverString.brand' -import {VersionCode} from '@vexl-next/domain/src/utility/VersionCode.brand' +import {type SemverString} from '@vexl-next/domain/src/utility/SmeverString.brand' +import {type VersionCode} from '@vexl-next/domain/src/utility/VersionCode.brand' import {type CreateAxiosDefaults, type GenericAbortSignal} from 'axios' import * as TE from 'fp-ts/TaskEither' import {pipe} from 'fp-ts/function' diff --git a/packages/rest-api/src/services/user/index.ts b/packages/rest-api/src/services/user/index.ts index f712a84f5..0a5b67b08 100644 --- a/packages/rest-api/src/services/user/index.ts +++ b/packages/rest-api/src/services/user/index.ts @@ -1,5 +1,5 @@ -import {SemverString} from '@vexl-next/domain/src/utility/SmeverString.brand' -import {VersionCode} from '@vexl-next/domain/src/utility/VersionCode.brand' +import {type SemverString} from '@vexl-next/domain/src/utility/SmeverString.brand' +import {type VersionCode} from '@vexl-next/domain/src/utility/VersionCode.brand' import {type CreateAxiosDefaults} from 'axios' import * as TE from 'fp-ts/TaskEither' import {pipe} from 'fp-ts/function' diff --git a/packages/rest-api/src/services/user/specification.ts b/packages/rest-api/src/services/user/specification.ts index 0c0ba565a..8ce10ca6d 100644 --- a/packages/rest-api/src/services/user/specification.ts +++ b/packages/rest-api/src/services/user/specification.ts @@ -1,11 +1,9 @@ import {Schema} from '@effect/schema' import {PublicKeyPemBase64E} from '@vexl-next/cryptography/src/KeyHolder/brands' import {E164PhoneNumberE} from '@vexl-next/domain/src/general/E164PhoneNumber.brand' +import {HashedPhoneNumberE} from '@vexl-next/domain/src/general/HashedPhoneNumber.brand' import {IsoDatetimeStringE} from '@vexl-next/domain/src/utility/IsoDatetimeString.brand' -import { - EcdsaSignature, - HmacHash, -} from '@vexl-next/generic-utils/src/effect-helpers/crypto' +import {EcdsaSignature} from '@vexl-next/generic-utils/src/effect-helpers/crypto' import {Api, ApiGroup} from 'effect-http' import {ServerSecurity} from '../../apiSecurity' import {SubmitFeedbackRequest} from '../feedback/specification' @@ -129,7 +127,7 @@ export class VerifyChallengeRequest extends Schema.Class export class VerifyChallengeResponse extends Schema.Class( 'VerifyChallengeResponse' )({ - hash: HmacHash, + hash: HashedPhoneNumberE, signature: EcdsaSignature, challengeVerified: Schema.Literal(true), }) {} diff --git a/packages/rest-api/tsconfig.json b/packages/rest-api/tsconfig.json index b1913fd60..36f4c3a76 100644 --- a/packages/rest-api/tsconfig.json +++ b/packages/rest-api/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "rootDir": "./src", + "rootDir": ".", "outDir": "./dist", "lib": ["ESNext"], "module": "ESNext", @@ -23,5 +23,5 @@ "noUncheckedIndexedAccess": true }, "exclude": ["./dist/**", "./tests/**", "node_modules"], - "include": ["./src"] + "include": ["./src", "./jest.config.ts"] } diff --git a/yarn.lock b/yarn.lock index 3a2c8f6a3..9de968b77 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4623,7 +4623,7 @@ __metadata: languageName: node linkType: hard -"@effect/experimental@npm:^0.22.1, @effect/experimental@npm:^0.22.6": +"@effect/experimental@npm:^0.22.6": version: 0.22.6 resolution: "@effect/experimental@npm:0.22.6" dependencies: @@ -4649,7 +4649,7 @@ __metadata: languageName: node linkType: hard -"@effect/opentelemetry@npm:^0.35.1, @effect/opentelemetry@npm:^0.35.3": +"@effect/opentelemetry@npm:^0.35.3": version: 0.35.3 resolution: "@effect/opentelemetry@npm:0.35.3" peerDependencies: @@ -4687,7 +4687,7 @@ __metadata: languageName: node linkType: hard -"@effect/platform-node@npm:^0.56.4, @effect/platform-node@npm:^0.56.9": +"@effect/platform-node@npm:^0.56.9": version: 0.56.9 resolution: "@effect/platform-node@npm:0.56.9" dependencies: @@ -4702,7 +4702,7 @@ __metadata: languageName: node linkType: hard -"@effect/platform@npm:^0.61.4, @effect/platform@npm:^0.61.8": +"@effect/platform@npm:^0.61.8": version: 0.61.8 resolution: "@effect/platform@npm:0.61.8" dependencies: @@ -4715,7 +4715,7 @@ __metadata: languageName: node linkType: hard -"@effect/schema@npm:^0.70.2, @effect/schema@npm:^0.70.4": +"@effect/schema@npm:^0.70.4": version: 0.70.4 resolution: "@effect/schema@npm:0.70.4" dependencies: @@ -4726,7 +4726,7 @@ __metadata: languageName: node linkType: hard -"@effect/sql-pg@npm:^0.8.3, @effect/sql-pg@npm:^0.8.7": +"@effect/sql-pg@npm:^0.8.7": version: 0.8.7 resolution: "@effect/sql-pg@npm:0.8.7" dependencies: @@ -4740,7 +4740,7 @@ __metadata: languageName: node linkType: hard -"@effect/sql@npm:^0.8.3, @effect/sql@npm:^0.8.7": +"@effect/sql@npm:^0.8.7": version: 0.8.7 resolution: "@effect/sql@npm:0.8.7" dependencies: @@ -12327,13 +12327,13 @@ __metadata: version: 0.0.0-use.local resolution: "@vexl-next/btc-exchange-rate-service@workspace:apps/btc-exchange-rate-service" dependencies: - "@effect/experimental": ^0.22.1 - "@effect/opentelemetry": ^0.35.1 - "@effect/platform": ^0.61.4 - "@effect/platform-node": ^0.56.4 - "@effect/schema": ^0.70.2 - "@effect/sql": ^0.8.3 - "@effect/sql-pg": ^0.8.3 + "@effect/experimental": ^0.22.6 + "@effect/opentelemetry": ^0.35.3 + "@effect/platform": ^0.61.8 + "@effect/platform-node": ^0.56.9 + "@effect/schema": ^0.70.4 + "@effect/sql": ^0.8.7 + "@effect/sql-pg": ^0.8.7 "@opentelemetry/exporter-trace-otlp-http": ^0.52.1 "@opentelemetry/sdk-trace-node": ^1.23.0 "@opentelemetry/sdk-trace-web": ^1.23.0 @@ -12351,9 +12351,9 @@ __metadata: "@vexl-next/server-utils": 0.0.0 "@vexl-next/tsconfig": 0.0.0 dotenv: ^16.4.5 - effect: ^3.6.1 - effect-http: ^0.77.3 - effect-http-node: ^0.17.6 + effect: ^3.6.3 + effect-http: ^0.77.4 + effect-http-node: ^0.17.7 esbuild: ^0.17.16 eslint: ^8.50.0 fast-check: ^3.20.0 @@ -13301,6 +13301,7 @@ __metadata: version: 0.0.0-use.local resolution: "account-deletion-website@workspace:apps/account-deletion-website" dependencies: + "@effect/schema": ^0.70.4 "@remix-run/css-bundle": ^2.8.1 "@remix-run/dev": ^2.8.1 "@remix-run/express": ^2.8.1 @@ -13325,6 +13326,7 @@ __metadata: buffer: ^6.0.3 cross-env: ^7.0.3 crypto-browserify: ^3.12.0 + effect: ^3.6.3 eslint: ^8.50.0 events: ^3.3.0 express: ^4.19.2 @@ -17133,7 +17135,7 @@ __metadata: languageName: node linkType: hard -"effect-http-node@npm:^0.17.6, effect-http-node@npm:^0.17.7": +"effect-http-node@npm:^0.17.7": version: 0.17.7 resolution: "effect-http-node@npm:0.17.7" dependencies: @@ -17148,7 +17150,7 @@ __metadata: languageName: node linkType: hard -"effect-http@npm:^0.77.3, effect-http@npm:^0.77.4": +"effect-http@npm:^0.77.4": version: 0.77.4 resolution: "effect-http@npm:0.77.4" peerDependencies: @@ -17159,7 +17161,7 @@ __metadata: languageName: node linkType: hard -"effect@npm:^3.6.1, effect@npm:^3.6.3": +"effect@npm:^3.6.3": version: 3.6.3 resolution: "effect@npm:3.6.3" checksum: 7d3498f5f4aab752a55d73ada475a38f8d18d4fa0a379673c25a14add2fab66a72ba88070a876ced7d4160366b0c9efb02c6cf6e761a8a0850e975927ea14164