(feat): update createTTP function
This commit is contained in:
parent
cc7472b61c
commit
80dc94ba55
6 changed files with 948 additions and 36 deletions
15
dist/index.js
vendored
15
dist/index.js
vendored
|
|
@ -76,7 +76,8 @@ export class TAuthClient {
|
|||
if ((await this.solveChallenge(userId, originalChallenge)) ===
|
||||
potentialChallenge) {
|
||||
await this.saveSession(userId, potentialSessionId);
|
||||
return new Response(htmlSuccessPage || (await readFile("./index.html")), {
|
||||
return new Response(htmlSuccessPage ||
|
||||
(await readFile(new URL("./index.html", import.meta.url), "utf8")), {
|
||||
headers: {
|
||||
"Content-Type": "text/html",
|
||||
},
|
||||
|
|
@ -126,15 +127,13 @@ export class TAuthClient {
|
|||
}
|
||||
createTTP(userId, sessionId, omikronUrl) {
|
||||
console.log(`[tauth] Creating TTP client for user ${userId} with session ${sessionId} at ${omikronUrl}`);
|
||||
this.clientMap.set(`${userId}:${sessionId}`, createTransportClient(this.schema, {
|
||||
const client = createTransportClient(this.schema, {
|
||||
url: omikronUrl,
|
||||
onReadyStateChange: (stateIndex) => {
|
||||
const state = getFriendlyReadyState(stateIndex);
|
||||
console.log(state);
|
||||
if (state === "OPEN") {
|
||||
this.clientMap
|
||||
.get(`${userId}:${sessionId}`)
|
||||
?.send("identification", {
|
||||
this.clientMap.get(`${userId}:${sessionId}`)?.send("identification", {
|
||||
app_identifier: this.identifier,
|
||||
app_session_id: sessionId,
|
||||
app_public_key: this.publicKey,
|
||||
|
|
@ -142,8 +141,10 @@ export class TAuthClient {
|
|||
});
|
||||
}
|
||||
},
|
||||
}));
|
||||
this.clientMap.get(`${userId}:${sessionId}`)?.connect();
|
||||
});
|
||||
this.clientMap.set(`${userId}:${sessionId}`, client);
|
||||
client.connect();
|
||||
return Promise.resolve(client);
|
||||
}
|
||||
async loadData(userId, sessionId) {
|
||||
const connection = await this.createTemporaryTTPConnection(userId, sessionId);
|
||||
|
|
|
|||
Loading…
Reference in a new issue