bot/src/linkedRoles.ts
openaliro/openaliro
Module

linkedRoles.ts

@file Orchestrates the Linked Roles flow across the three plain browser…

bot/src/linkedRoles.ts1 documented symbols

Overview

@file Orchestrates the Linked Roles flow across the three plain browser routes (/linked-role, /discord-oauth-callback, /github-oauth-callback) that src/index.ts registers alongside — but structurally separate from — the signed interactions endpoint. These are ordinary redirects a browser follows, not Discord interactions: no Ed25519 signature is involved or expected, which is also why they live on their own routes rather than folded into POST /. Each exported function takes the incoming request's own URL and derives both OAuth redirect URIs from its origin, so no separate "base URL" secret is needed — the Worker always knows where it is being reached at. Metadata is only ever pushed once, right after both OAuth legs complete. There is no scheduled refresh: re-running /linked-role is how a contributor updates their badge later (a periodic full refresh across every linked user is a natural follow-up, not built here, since it would mean spending every linked user's share of GitHub's search rate limit on every sweep tick whether or not anything about them changed).

depends on discordOAuth.ts env.ts githubOAuth.ts oauthLinks.ts oauthState.ts roleConnection.ts  ·  used by index.ts

API

Fasync function pushMetadataNow(env: Env, discordUserId: string, githubLogin: string, correlationId: string): Promise<boolean>

bot/src/linkedRoles.ts:181

Computes and pushes the five metadata fields with the access token the Discord leg parked, then scrubs it. Returns whether the push itself succeeded — the GitHub link is already saved by this point regardless.

called by handleGithubCallback  ·  calls computeRegistryMetadata, countMergedPullRequests, decryptedAccessToken, getLink, markMetadataPushed, pushRoleConnection, scrubLinkSecrets, stringifyMetadata
Undocumented (6)

htmlPage, errorPage, callbackUrl, startLinkedRole, handleDiscordCallback, handleGithubCallback