Files
standardnotes-server/packages/auth/src/Domain/Api/ApiVersion.ts
Karol Sójko 1a57c247b2 chore: release latest changes (#1056)
* chore: release latest changes

* update yarn lockfile

* remove stale files

* fix ci env

* remove mysql command overwrite

* remove mysql overwrite from example

* fix cookie cooldown in memory
2024-06-18 09:29:24 +02:00

38 lines
1.0 KiB
TypeScript

import { Result, ValueObject } from '@standardnotes/domain-core'
import { ApiVersionProps } from './ApiVersionProps'
export class ApiVersion extends ValueObject<ApiVersionProps> {
static readonly VERSIONS = {
v20161215: '20161215',
v20190520: '20190520',
v20200115: '20200115',
v20240226: '20240226',
}
get value(): string {
return this.props.value
}
private constructor(props: ApiVersionProps) {
super(props)
}
static create(version: string): Result<ApiVersion> {
const isValidVersion = Object.values(this.VERSIONS).includes(version)
if (!isValidVersion) {
return Result.fail(`Invalid api version: ${version}`)
} else {
return Result.ok(new ApiVersion({ value: version }))
}
}
isSupportedForRegistration(): boolean {
return [ApiVersion.VERSIONS.v20200115, ApiVersion.VERSIONS.v20240226].includes(this.props.value)
}
isSupportedForRecoverySignIn(): boolean {
return [ApiVersion.VERSIONS.v20200115, ApiVersion.VERSIONS.v20240226].includes(this.props.value)
}
}