(fix): better explentations
This commit is contained in:
parent
a8fabbf0a0
commit
0e87a9df8b
4 changed files with 20 additions and 3 deletions
|
|
@ -39,8 +39,7 @@ import z from "zod";
|
||||||
import { TAuthClient } from "@tensamin/tauth-sdk";
|
import { TAuthClient } from "@tensamin/tauth-sdk";
|
||||||
|
|
||||||
const client = new TAuthClient({
|
const client = new TAuthClient({
|
||||||
frontendUrl: "http://localhost:3000",
|
identifier: "my.cool.app",
|
||||||
identifier: "your-app-identifier",
|
|
||||||
privateKey: "<APP_PRIVATE_KEY_BASE64>",
|
privateKey: "<APP_PRIVATE_KEY_BASE64>",
|
||||||
publicKey: "<APP_PUBLIC_KEY_BASE64>",
|
publicKey: "<APP_PUBLIC_KEY_BASE64>",
|
||||||
saveSession: async (userId, sessionId) => {
|
saveSession: async (userId, sessionId) => {
|
||||||
|
|
@ -48,7 +47,7 @@ const client = new TAuthClient({
|
||||||
// Treat the session id like a password!
|
// Treat the session id like a password!
|
||||||
console.log("Save session", { userId, sessionId });
|
console.log("Save session", { userId, sessionId });
|
||||||
},
|
},
|
||||||
redirectUrl: "http://localhost:7878/callback",
|
redirectUrl: "https://my.cool.app/callback", // This should be a public link proxying http://localhost:7878/callback
|
||||||
appData: z.object({
|
appData: z.object({
|
||||||
my: z.string(),
|
my: z.string(),
|
||||||
cool: z.string(),
|
cool: z.string(),
|
||||||
|
|
|
||||||
6
dist/index.d.ts
vendored
6
dist/index.d.ts
vendored
|
|
@ -2,7 +2,13 @@ import { type TransportClient, READY_STATE } from "@tensamin/ttp-core";
|
||||||
import { createSchema } from "./schema";
|
import { createSchema } from "./schema";
|
||||||
import type { z, ZodObject } from "zod";
|
import type { z, ZodObject } from "zod";
|
||||||
/**
|
/**
|
||||||
|
* @param identifier Your app's domain.
|
||||||
* @param redirectUrl The URL should point to the TAuth HTTP Server at http://hostname:port/callback
|
* @param redirectUrl The URL should point to the TAuth HTTP Server at http://hostname:port/callback
|
||||||
|
* @param frontendUrl The URL of the frontend the user interacts with. Only used in development.
|
||||||
|
* @param appData A Zod schema defining the shape of the app data you want to load/save for each user.
|
||||||
|
* @param saveSession A function that saves the session ID for a given user ID. This is called after a successful authentication.
|
||||||
|
* @param httpServer Optional configuration for the TAuth HTTP Server. Defaults to { port: 7878, hostname: "localhost" }.
|
||||||
|
* @param htmlSuccessPage Optional HTML string or path to an HTML file to be served upon successful authentication.
|
||||||
*/
|
*/
|
||||||
export declare class TAuthClient {
|
export declare class TAuthClient {
|
||||||
frontendUrl: string;
|
frontendUrl: string;
|
||||||
|
|
|
||||||
6
dist/index.js
vendored
6
dist/index.js
vendored
|
|
@ -6,7 +6,13 @@ import { get } from "./user";
|
||||||
import { decrypt, encrypt, getSharedSecret } from "./crypto";
|
import { decrypt, encrypt, getSharedSecret } from "./crypto";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
/**
|
/**
|
||||||
|
* @param identifier Your app's domain.
|
||||||
* @param redirectUrl The URL should point to the TAuth HTTP Server at http://hostname:port/callback
|
* @param redirectUrl The URL should point to the TAuth HTTP Server at http://hostname:port/callback
|
||||||
|
* @param frontendUrl The URL of the frontend the user interacts with. Only used in development.
|
||||||
|
* @param appData A Zod schema defining the shape of the app data you want to load/save for each user.
|
||||||
|
* @param saveSession A function that saves the session ID for a given user ID. This is called after a successful authentication.
|
||||||
|
* @param httpServer Optional configuration for the TAuth HTTP Server. Defaults to { port: 7878, hostname: "localhost" }.
|
||||||
|
* @param htmlSuccessPage Optional HTML string or path to an HTML file to be served upon successful authentication.
|
||||||
*/
|
*/
|
||||||
export class TAuthClient {
|
export class TAuthClient {
|
||||||
frontendUrl;
|
frontendUrl;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,13 @@ import { decrypt, encrypt, getSharedSecret } from "./crypto";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param identifier Your app's domain.
|
||||||
* @param redirectUrl The URL should point to the TAuth HTTP Server at http://hostname:port/callback
|
* @param redirectUrl The URL should point to the TAuth HTTP Server at http://hostname:port/callback
|
||||||
|
* @param frontendUrl The URL of the frontend the user interacts with. Only used in development.
|
||||||
|
* @param appData A Zod schema defining the shape of the app data you want to load/save for each user.
|
||||||
|
* @param saveSession A function that saves the session ID for a given user ID. This is called after a successful authentication.
|
||||||
|
* @param httpServer Optional configuration for the TAuth HTTP Server. Defaults to { port: 7878, hostname: "localhost" }.
|
||||||
|
* @param htmlSuccessPage Optional HTML string or path to an HTML file to be served upon successful authentication.
|
||||||
*/
|
*/
|
||||||
export class TAuthClient {
|
export class TAuthClient {
|
||||||
frontendUrl: string;
|
frontendUrl: string;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue