(feat): better connection management, utility functions & tests
This commit is contained in:
parent
b8889812c5
commit
822dfea577
14 changed files with 448 additions and 39 deletions
19
README.md
19
README.md
|
|
@ -1,8 +1,8 @@
|
|||
# TypeScript TAuth SDK
|
||||
|
||||
TypeScript SDK for TAuth-based login and transport session bootstrap.
|
||||
TypeScript SDK for TAuth-based login and explicit transport session management.
|
||||
|
||||
This SDK starts a local HTTP callback server, verifies a challenge, and opens an authenticated TTP transport client per `userId:sessionId`.
|
||||
This SDK starts a local HTTP callback server, verifies a challenge, and gives you explicit control over TTP connections per `userId:sessionId`.
|
||||
|
||||
## Requirements
|
||||
|
||||
|
|
@ -43,6 +43,11 @@ const client = new TAuthClient({
|
|||
identifier: "your-app-identifier",
|
||||
privateKey: "<APP_PRIVATE_KEY_BASE64>",
|
||||
publicKey: "<APP_PUBLIC_KEY_BASE64>",
|
||||
saveSession: async (userId, sessionId) => {
|
||||
// You must persist the session id yourself (for example in a database).
|
||||
// Treat the session id like a password!
|
||||
console.log("Save session", { userId, sessionId });
|
||||
},
|
||||
redirectUrl: "http://localhost:7878/callback",
|
||||
appData: z.object({
|
||||
my: z.string(),
|
||||
|
|
@ -56,9 +61,15 @@ const client = new TAuthClient({
|
|||
});
|
||||
```
|
||||
|
||||
## Endpoints exposed by the SDK
|
||||
## Auth endpoints exposed by the SDK
|
||||
|
||||
- `GET /auth`: Redirects user to TAuth frontend
|
||||
- `GET /callback`: Handles challenge flow and session bootstrap
|
||||
- `GET /callback`: Handles challenge flow and invokes your `saveSession(userId, sessionId)` callback
|
||||
|
||||
## Connection management
|
||||
|
||||
- Use `client.createTTP(userId, sessionId, omikronUrl)` when you want a persistent/manual TTP connection.
|
||||
- Use `client.loadData(userId, sessionId)` for loading user specific application data.
|
||||
- Use `client.saveData(userId, sessionId)` for saving user specific application data.
|
||||
|
||||
These endpoints need to be exposed behind some kind of http proxy to apply ssl
|
||||
|
|
|
|||
Loading…
Reference in a new issue