kunkun/packages/api/src/version.ts
Huakun Shen da8e37c4a1
Some checks failed
CI / build-test (macos-14) (push) Has been cancelled
CI / build-test (ubuntu-24.04) (push) Has been cancelled
CI / build-test (windows-latest) (push) Has been cancelled
Security with cryptography (#32)
* Add some experiment code for crypto crate

* feat: add crypto crate with ssl, rsa, ed25519 for https, encryption, signing

* Implement aes encryption helper in crypto crate

* ci: add dep for CI rust test (protobuf)

* fix: try to fix window CI with next

* fix: CI

* ci: add dep for ubuntu

* ci: fix

* fix: openssl lib path in CI

* fix: CI

* update applications-rs, disable some tests

* fix: CI

* feat: add file transfer grpc proto and server setup

* CI: try to fix CI

* fix: missing proto in build.rs

* ci: add cargo build before cargo test

* fix: grpc file descriptor

* ci: fix CI by removing a redundant main.rs

* fix: disable local windows test in applications-rs which fails CI

* ci: run CI rust test only on ubuntu, windows is failing. will be handled in another PR

* fix: vue template

* fix: allow unused variable

* fix: remove node:buffer type from api shell.ts to avoid frontend build error

* try to fix test in create-kunkun

* upgrade api to 0.0.44, remove node:buffer

* upgrade next template to 15

* feat: turn the default server into a https server

* feat: make SSL certificate loadable from env

* feat: add conditional SSL cert

in debug mode, use local default cert, in production generate new self-signed cert every time app starts

* chore: add vscode debug config

* feat: add server public key

* feat: setup sqlite db encryption

* fix: settings hotkey

* chore: add .gitkeep

* ci: add node-fetch to dep for api package
2024-11-24 00:45:36 -05:00

36 lines
1.2 KiB
TypeScript

import { clean, gte, parse, satisfies, sort } from "semver"
import * as v from "valibot"
export const breakingChangesVersionCheckpoints = [
{ version: "0.0.1", changelog: "" },
{ version: "0.0.12-beta.0", changelog: "" },
{ version: "0.0.12-beta.1", changelog: "" },
{
version: "0.0.17",
changelog: "New Custom UI loading method, remove base url config requirement."
},
{
version: "0.0.34",
changelog: "Replace comlink with kkrpc, extensions using comlink won't work anymore."
}
]
const checkpointVersions = breakingChangesVersionCheckpoints.map((c) => c.version)
const sortedCheckpointVersions = sort(checkpointVersions)
export const version = "0.0.44"
export function isVersionBetween(v: string, start: string, end: string) {
const vCleaned = clean(v)
const startCleaned = clean(start)
const endCleaned = clean(end)
return satisfies(vCleaned!, `${startCleaned} - ${endCleaned}`)
}
/**
* Check if a given version is compatible with this API version
* Basically, this checks if the version is greater than or equal to the last checkpoint version
* @param version
*/
export function isCompatible(version: string) {
return gte(version, v.parse(v.string(), sortedCheckpointVersions.at(-1)))
}