Initial commit. Started laying down the foundations.

This commit is contained in:
2026-10-26 11:22:16 +01:00
commit 1fb7936be9
12 changed files with 6249 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.idea
node_modules
dist
src/generated

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# Chatenium SDK (For API v3)
**WIP, not much to see here yet**

3865
openapi.yaml Normal file

File diff suppressed because it is too large Load Diff

7
openapitools.json Normal file
View File

@@ -0,0 +1,7 @@
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "7.26.0"
}
}

2263
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

33
package.json Normal file
View File

@@ -0,0 +1,33 @@
{
"name": "chatenium-sdk-typescript",
"version": "1.0.0",
"description": "A TypeScript SDK for interacting with Chatenium API",
"main": "index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.js"
}
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"generate": "npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g typescript-axios -o ./src/generated --skip-validate-spec --global-property apiDocs=false,modelDocs=false",
"build": "tsc",
"prepare": "npm run build"
},
"repository": {
"type": "git",
"url": "https://git.chatenium.hu/chatenium/SDK-TypeScript"
},
"author": "Noel",
"license": "GPL-3.0-or-later",
"dependencies": {
"@openapitools/openapi-generator-cli": "^2.42.0"
},
"devDependencies": {
"@types/node": "^26.6.5",
"typescript": "^7.0.2"
}
}

17
src/index.ts Normal file
View File

@@ -0,0 +1,17 @@
import {AuthApi, Configuration} from "./generated";
import {DatabaseAPI} from "./storage/database";
import {KeyringAPI} from "./storage/keyring";
import {KeyValueAPI} from "./storage/keyvalue";
import {AuthApiExtended} from "./services/auth";
export class ChateniumClient {
public auth: AuthApiExtended;
constructor(config: { baseUrl: string, storage: {database: DatabaseAPI, keyring: KeyringAPI, keyValue: KeyValueAPI} }) {
const apiConfig = new Configuration({
basePath: config.baseUrl+"/v3"
})
this.auth = new AuthApiExtended(apiConfig);
}
}

24
src/services/auth.ts Normal file
View File

@@ -0,0 +1,24 @@
import {AuthApi, Challenge, ChallengeDataOverride} from "../generated";
export class AuthChallenge {
private challenge?: Challenge;
constructor(private authApi: AuthApi) {}
/**
* Starts a new challenge for the provided endpoint
* @param action Each authenticated endpoint in v3/auth or v3/account has its own action name (Example: passwordless registration: AUTH:PLE)
* @param userId If the provided action points to an endpoint that modifies an existing user, provide it. For registration, don't.
* @param override For registration or account info changes, this provides the (new) user data
*/
async start(action: string, userId?: string, override?: ChallengeDataOverride): Promise<Challenge> {
const resp = await this.authApi.registerChallenge({
actionName: action,
override: override,
userId: userId,
})
this.challenge = resp.data;
return resp.data;
}
}

6
src/storage/database.ts Normal file
View File

@@ -0,0 +1,6 @@
export interface DatabaseAPI {
set(collection: string, key: string, value: any): void;
get(collection: string, key: string): Promise<string>;
delete(collection: string, key: string): void;
flush(): void;
}

6
src/storage/keyring.ts Normal file
View File

@@ -0,0 +1,6 @@
export interface KeyringAPI {
set(key: string, value: any): void;
get(key: string): Promise<string>;
getAll(): Promise<string[]>;
delete(key: string): void;
}

6
src/storage/keyvalue.ts Normal file
View File

@@ -0,0 +1,6 @@
export interface KeyValueAPI {
set(key: string, value: any): void;
get(key: string): Promise<string>;
delete(key: string): void;
flush(): void;
}

16
tsconfig.json Normal file
View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"]
}