Skip to content

Commit

Permalink
more info in external_tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanfeenstra committed Apr 8, 2021
1 parent 4c0ade1 commit f78fa52
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
12 changes: 9 additions & 3 deletions dist/src/controllers/auth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/src/controllers/auth.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion dist/src/utils/tribes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/src/utils/tribes.js.map

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import * as meme from "../utils/meme";
import { success, failure } from "../utils/res";
import * as tribes from "../utils/tribes";

interface MeInfo {
memeToken: string
tribesToken: string
photoUrl: string
alias: string
routeHint: string
contactKey: string
}

export async function requestExternalTokens(req, res) {
if (!req.owner) return failure(res, "no owner");
const pubkey = req.owner.publicKey;
Expand All @@ -11,9 +20,15 @@ export async function requestExternalTokens(req, res) {
if(!memeToken || !tribesToken) {
return failure(res, 'failed to generate token')
}
success(res, {
memeToken, tribesToken
})
const result:MeInfo = {
memeToken,
tribesToken,
alias: req.owner.alias,
photoUrl: req.owner.photoUrl,
routeHint: req.owner.routeHint,
contactKey: req.owner.contactKey,
}
success(res, result)
} catch (e) {
failure(res, e);
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/tribes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async function initializeClient(pubkey, host, onMessage): Promise<mqtt.Client> {
let connected = false
async function reconnect() {
const pwd = await genSignedTimestamp(pubkey);
if (!connected) return
const url = mqttURL(host);
const cl = mqtt.connect(url, {
username: pubkey,
Expand Down Expand Up @@ -90,7 +91,7 @@ async function initializeClient(pubkey, host, onMessage): Promise<mqtt.Client> {
if(!connected) {
reconnect();
}
await sleep(3000 + Math.round(Math.random()*10000))
await sleep(5000 + Math.round(Math.random()*8000))
}
});
}
Expand Down

0 comments on commit f78fa52

Please sign in to comment.