Add StreamPixels managed auth seams
This commit is contained in:
parent
5ef94bb725
commit
f22db66d64
15 changed files with 589 additions and 26 deletions
97
src/app.ts
97
src/app.ts
|
|
@ -1,4 +1,4 @@
|
|||
import { randomUUID } from "node:crypto";
|
||||
import { randomUUID, timingSafeEqual } from "node:crypto";
|
||||
import cors from "@fastify/cors";
|
||||
import Fastify, { type FastifyInstance } from "fastify";
|
||||
import { deliverBackendHandoff, type BackendHandoffPayload } from "./backend-handoff.js";
|
||||
|
|
@ -229,6 +229,21 @@ function normalizeEntitlementPolicy(value: OAuthStartRequest["entitlementPolicy"
|
|||
throw new Error("Invalid entitlement policy definition.");
|
||||
}
|
||||
|
||||
function getSharedSecret(request: { headers: Record<string, string | string[] | undefined> }): string | undefined {
|
||||
const header = request.headers["x-heimdall-app-secret"];
|
||||
return Array.isArray(header) ? header[0] : header;
|
||||
}
|
||||
|
||||
function secretMatches(expected: string | undefined, provided: string | undefined): boolean {
|
||||
if (!expected || !provided) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const expectedBuffer = Buffer.from(expected);
|
||||
const providedBuffer = Buffer.from(provided);
|
||||
return expectedBuffer.length === providedBuffer.length && timingSafeEqual(expectedBuffer, providedBuffer);
|
||||
}
|
||||
|
||||
function acceptsBackendPolicy(appSlug: AppSlug, handoff: OAuthHandoff): boolean {
|
||||
if (handoff.kind !== "backend_callback") {
|
||||
return false;
|
||||
|
|
@ -525,6 +540,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
appSlug: statePayload.app_slug,
|
||||
mode: statePayload.mode,
|
||||
returnTo: statePayload.return_to,
|
||||
connection: statePayload.connection,
|
||||
error: "provider_error",
|
||||
errorDescription: request.query.error_description ?? request.query.error,
|
||||
});
|
||||
|
|
@ -569,6 +585,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
appSlug: statePayload.app_slug,
|
||||
mode: statePayload.mode,
|
||||
returnTo: statePayload.return_to,
|
||||
connection: statePayload.connection,
|
||||
error: "missing_code",
|
||||
});
|
||||
}
|
||||
|
|
@ -603,6 +620,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
redirectUri: callbackUrl,
|
||||
});
|
||||
const identity = await runtime.resolveIdentity({
|
||||
config,
|
||||
accessToken: tokenSet.accessToken,
|
||||
});
|
||||
const nowIso = new Date().toISOString();
|
||||
|
|
@ -730,6 +748,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
account: accountSummary,
|
||||
entitlements: entitlementEvaluation,
|
||||
returnTo: statePayload.return_to,
|
||||
connection: statePayload.connection,
|
||||
...issued,
|
||||
};
|
||||
if (handoff.kind === "backend_callback") {
|
||||
|
|
@ -743,6 +762,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
appSlug: statePayload.app_slug,
|
||||
mode: statePayload.mode,
|
||||
returnTo: statePayload.return_to,
|
||||
connection: statePayload.connection,
|
||||
account: accountSummary,
|
||||
entitlements: entitlementEvaluation,
|
||||
...issued,
|
||||
|
|
@ -757,6 +777,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
provider: request.params.provider,
|
||||
mode: statePayload.mode,
|
||||
attemptId: handoff.attemptId,
|
||||
connection: statePayload.connection,
|
||||
callbackUrl: handoff.callbackUrl,
|
||||
},
|
||||
createdAt: nowIso,
|
||||
|
|
@ -868,6 +889,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
appSlug: statePayload.app_slug,
|
||||
mode: statePayload.mode,
|
||||
returnTo: statePayload.return_to,
|
||||
connection: statePayload.connection,
|
||||
error: "oauth_callback_failed",
|
||||
errorDescription: message,
|
||||
});
|
||||
|
|
@ -1009,5 +1031,78 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
}
|
||||
);
|
||||
|
||||
app.post<{
|
||||
Params: { appSlug: AppSlug };
|
||||
Body: { accountId: string; provider: Provider };
|
||||
}>(
|
||||
"/v1/apps/:appSlug/managed-credentials/resolve",
|
||||
{
|
||||
schema: {
|
||||
params: {
|
||||
type: "object",
|
||||
required: ["appSlug"],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
appSlug: { type: "string", enum: [...appSlugs] },
|
||||
},
|
||||
},
|
||||
body: {
|
||||
type: "object",
|
||||
required: ["accountId", "provider"],
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
accountId: { type: "string", minLength: 1 },
|
||||
provider: { type: "string", enum: [...providers] },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
async (request, reply) => {
|
||||
const profile = getAppProfile(request.params.appSlug);
|
||||
const providedSecret = getSharedSecret(request);
|
||||
|
||||
if (!secretMatches(config.appSharedSecrets[profile.slug], providedSecret)) {
|
||||
reply.code(401);
|
||||
return { error: "app_auth_required" };
|
||||
}
|
||||
|
||||
if (!profile.managedConnectionProviders.includes(request.body.provider)) {
|
||||
reply.code(400);
|
||||
return {
|
||||
error: "provider_not_managed_for_app",
|
||||
provider: request.body.provider,
|
||||
appSlug: profile.slug,
|
||||
};
|
||||
}
|
||||
|
||||
const linkedIdentity = await store.findStoredLinkedIdentityForAccount(request.body.accountId, request.body.provider);
|
||||
if (!linkedIdentity?.accessTokenEncrypted) {
|
||||
reply.code(404);
|
||||
return { error: "managed_credential_not_found" };
|
||||
}
|
||||
|
||||
const response: {
|
||||
accountId: string;
|
||||
provider: Provider;
|
||||
providerUserId: string;
|
||||
accessToken: string;
|
||||
tokenExpiresAt?: string;
|
||||
scopes: string[];
|
||||
} = {
|
||||
accountId: linkedIdentity.accountId,
|
||||
provider: linkedIdentity.provider,
|
||||
providerUserId: linkedIdentity.providerUserId,
|
||||
accessToken: tokenCustody.decrypt(linkedIdentity.accessTokenEncrypted),
|
||||
scopes: linkedIdentity.scopes,
|
||||
};
|
||||
|
||||
if (linkedIdentity.tokenExpiresAt) {
|
||||
response.tokenExpiresAt = linkedIdentity.tokenExpiresAt;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { type IssuedAccessClaimResult } from "./claims.js";
|
||||
import { type AppSlug, type OAuthMode, type Provider } from "./contracts.js";
|
||||
import { type AppSlug, type OAuthConnectionBinding, type OAuthMode, type Provider } from "./contracts.js";
|
||||
import { type EntitlementEvaluation } from "./oauth.js";
|
||||
|
||||
interface AccountSummary {
|
||||
|
|
@ -16,6 +16,7 @@ interface BackendHandoffBase {
|
|||
provider: Provider;
|
||||
appSlug: AppSlug;
|
||||
returnTo: string;
|
||||
connection: OAuthConnectionBinding | null;
|
||||
}
|
||||
|
||||
export interface BackendHandoffSuccessPayload extends BackendHandoffBase, IssuedAccessClaimResult {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { providers, type Provider } from "./contracts.js";
|
||||
import { appSlugs, providers, type AppSlug, type Provider } from "./contracts.js";
|
||||
|
||||
export interface ProviderClientConfig {
|
||||
clientId?: string;
|
||||
|
|
@ -25,6 +25,7 @@ export interface HeimdallConfig {
|
|||
bootstrapSigningPrivateKeyOnMissing: boolean;
|
||||
signingKeyId?: string;
|
||||
tokenEncryptionKeyBase64?: string;
|
||||
appSharedSecrets: Partial<Record<AppSlug, string>>;
|
||||
storage: StorageConfig;
|
||||
providers: Record<Provider, ProviderClientConfig>;
|
||||
}
|
||||
|
|
@ -86,6 +87,14 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): HeimdallConfig
|
|||
const providersConfig = Object.fromEntries(
|
||||
providers.map((provider) => [provider, readProviderConfig(env, provider)])
|
||||
) as Record<Provider, ProviderClientConfig>;
|
||||
const appSharedSecrets = Object.fromEntries(
|
||||
appSlugs
|
||||
.map((appSlug) => {
|
||||
const envKey = `GC_ACCESS_APP_${appSlug.toUpperCase()}_SHARED_SECRET`;
|
||||
return [appSlug, env[envKey] ?? env.GC_ACCESS_APP_SHARED_SECRET];
|
||||
})
|
||||
.filter(([, value]) => Boolean(value))
|
||||
) as Partial<Record<AppSlug, string>>;
|
||||
|
||||
const config: HeimdallConfig = {
|
||||
serviceName: "heimdall",
|
||||
|
|
@ -97,6 +106,7 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): HeimdallConfig
|
|||
stateTtlSeconds: readInt(env.GC_ACCESS_STATE_TTL_SECONDS, 600),
|
||||
completionTtlSeconds: readInt(env.GC_ACCESS_COMPLETION_TTL_SECONDS, 300),
|
||||
bootstrapSigningPrivateKeyOnMissing: readBoolean(env.GC_ACCESS_SIGNING_PRIVATE_KEY_BOOTSTRAP, false),
|
||||
appSharedSecrets,
|
||||
storage: {
|
||||
backend: storageBackend,
|
||||
applySchemaOnStartup: readBoolean(env.GC_ACCESS_APPLY_SCHEMA_ON_STARTUP, true),
|
||||
|
|
|
|||
265
src/oauth.ts
265
src/oauth.ts
|
|
@ -46,7 +46,7 @@ export interface OAuthProviderRuntime {
|
|||
code: string;
|
||||
redirectUri: string;
|
||||
}): Promise<OAuthTokenSet>;
|
||||
resolveIdentity(options: { accessToken: string }): Promise<ResolvedIdentity>;
|
||||
resolveIdentity(options: { config: HeimdallConfig; accessToken: string }): Promise<ResolvedIdentity>;
|
||||
evaluateEntitlements(options: {
|
||||
config: HeimdallConfig;
|
||||
callback: OAuthCallbackContext;
|
||||
|
|
@ -173,6 +173,111 @@ async function exchangePatreonAuthorizationCode(options: {
|
|||
return tokenSet;
|
||||
}
|
||||
|
||||
async function exchangeTwitchAuthorizationCode(options: {
|
||||
config: HeimdallConfig;
|
||||
code: string;
|
||||
redirectUri: string;
|
||||
}): Promise<OAuthTokenSet> {
|
||||
const providerConfig = options.config.providers.twitch;
|
||||
if (!providerConfig.clientId || !providerConfig.clientSecret) {
|
||||
throw new Error("Twitch OAuth is not fully configured.");
|
||||
}
|
||||
|
||||
const tokenResponse = await fetchJson<{
|
||||
access_token: string;
|
||||
refresh_token?: string;
|
||||
token_type: string;
|
||||
expires_in?: number;
|
||||
scope?: string;
|
||||
}>(
|
||||
"https://id.twitch.tv/oauth2/token",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
client_id: providerConfig.clientId,
|
||||
client_secret: providerConfig.clientSecret,
|
||||
code: options.code,
|
||||
grant_type: "authorization_code",
|
||||
redirect_uri: options.redirectUri,
|
||||
}),
|
||||
},
|
||||
"Twitch token exchange failed"
|
||||
);
|
||||
|
||||
const tokenSet: OAuthTokenSet = {
|
||||
accessToken: tokenResponse.access_token,
|
||||
tokenType: tokenResponse.token_type,
|
||||
scope: tokenResponse.scope?.split(/\s+/).filter(Boolean) ?? [],
|
||||
raw: tokenResponse as unknown as Record<string, unknown>,
|
||||
};
|
||||
|
||||
if (tokenResponse.refresh_token) {
|
||||
tokenSet.refreshToken = tokenResponse.refresh_token;
|
||||
}
|
||||
|
||||
if (tokenResponse.expires_in) {
|
||||
tokenSet.expiresAt = new Date(Date.now() + tokenResponse.expires_in * 1000).toISOString();
|
||||
}
|
||||
|
||||
return tokenSet;
|
||||
}
|
||||
|
||||
async function exchangeYouTubeAuthorizationCode(options: {
|
||||
config: HeimdallConfig;
|
||||
code: string;
|
||||
redirectUri: string;
|
||||
}): Promise<OAuthTokenSet> {
|
||||
const providerConfig = options.config.providers.youtube;
|
||||
if (!providerConfig.clientId || !providerConfig.clientSecret) {
|
||||
throw new Error("YouTube OAuth is not fully configured.");
|
||||
}
|
||||
|
||||
const tokenResponse = await fetchJson<{
|
||||
access_token: string;
|
||||
refresh_token?: string;
|
||||
token_type: string;
|
||||
expires_in?: number;
|
||||
scope?: string;
|
||||
id_token?: string;
|
||||
}>(
|
||||
"https://oauth2.googleapis.com/token",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
client_id: providerConfig.clientId,
|
||||
client_secret: providerConfig.clientSecret,
|
||||
code: options.code,
|
||||
grant_type: "authorization_code",
|
||||
redirect_uri: options.redirectUri,
|
||||
}),
|
||||
},
|
||||
"YouTube token exchange failed"
|
||||
);
|
||||
|
||||
const tokenSet: OAuthTokenSet = {
|
||||
accessToken: tokenResponse.access_token,
|
||||
tokenType: tokenResponse.token_type,
|
||||
scope: tokenResponse.scope?.split(/\s+/).filter(Boolean) ?? [],
|
||||
raw: tokenResponse as unknown as Record<string, unknown>,
|
||||
};
|
||||
|
||||
if (tokenResponse.refresh_token) {
|
||||
tokenSet.refreshToken = tokenResponse.refresh_token;
|
||||
}
|
||||
|
||||
if (tokenResponse.expires_in) {
|
||||
tokenSet.expiresAt = new Date(Date.now() + tokenResponse.expires_in * 1000).toISOString();
|
||||
}
|
||||
|
||||
return tokenSet;
|
||||
}
|
||||
|
||||
async function resolveDiscordIdentity(options: { accessToken: string }): Promise<ResolvedIdentity> {
|
||||
const user = await fetchJson<{
|
||||
id: string;
|
||||
|
|
@ -288,6 +393,144 @@ async function resolvePatreonIdentity(options: { accessToken: string }): Promise
|
|||
return identity;
|
||||
}
|
||||
|
||||
async function resolveTwitchIdentity(options: {
|
||||
config: HeimdallConfig;
|
||||
accessToken: string;
|
||||
}): Promise<ResolvedIdentity> {
|
||||
const providerConfig = options.config.providers.twitch;
|
||||
const payload = await fetchJson<{
|
||||
data?: Array<{
|
||||
id: string;
|
||||
login?: string;
|
||||
display_name?: string;
|
||||
profile_image_url?: string;
|
||||
email?: string;
|
||||
}>;
|
||||
}>(
|
||||
"https://api.twitch.tv/helix/users",
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${options.accessToken}`,
|
||||
"Client-Id": providerConfig.clientId ?? "",
|
||||
},
|
||||
},
|
||||
"Twitch identity lookup failed"
|
||||
);
|
||||
const user = payload.data?.[0];
|
||||
|
||||
if (!user?.id) {
|
||||
throw new Error("Twitch identity response did not include a user id.");
|
||||
}
|
||||
|
||||
const identity: ResolvedIdentity = {
|
||||
provider: "twitch",
|
||||
providerUserId: user.id,
|
||||
profile: user as unknown as Record<string, unknown>,
|
||||
};
|
||||
|
||||
if (user.login) {
|
||||
identity.username = user.login;
|
||||
}
|
||||
|
||||
if (user.display_name) {
|
||||
identity.displayName = user.display_name;
|
||||
}
|
||||
|
||||
if (user.email) {
|
||||
identity.primaryEmail = user.email;
|
||||
}
|
||||
|
||||
if (user.profile_image_url) {
|
||||
identity.avatarUrl = user.profile_image_url;
|
||||
}
|
||||
|
||||
return identity;
|
||||
}
|
||||
|
||||
async function resolveYouTubeIdentity(options: { accessToken: string }): Promise<ResolvedIdentity> {
|
||||
const channelUrl = new URL("https://www.googleapis.com/youtube/v3/channels");
|
||||
channelUrl.searchParams.set("part", "snippet");
|
||||
channelUrl.searchParams.set("mine", "true");
|
||||
const channelResponse = await fetch(channelUrl, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${options.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (channelResponse.ok) {
|
||||
const payload = (await channelResponse.json()) as {
|
||||
items?: Array<{
|
||||
id: string;
|
||||
snippet?: {
|
||||
title?: string;
|
||||
customUrl?: string;
|
||||
thumbnails?: {
|
||||
default?: { url?: string };
|
||||
medium?: { url?: string };
|
||||
high?: { url?: string };
|
||||
};
|
||||
};
|
||||
}>;
|
||||
};
|
||||
const channel = payload.items?.[0];
|
||||
|
||||
if (channel?.id) {
|
||||
const identity: ResolvedIdentity = {
|
||||
provider: "youtube",
|
||||
providerUserId: channel.id,
|
||||
username: channel.snippet?.customUrl ?? channel.snippet?.title ?? channel.id,
|
||||
displayName: channel.snippet?.title ?? channel.id,
|
||||
profile: channel as unknown as Record<string, unknown>,
|
||||
};
|
||||
const avatarUrl =
|
||||
channel.snippet?.thumbnails?.high?.url ??
|
||||
channel.snippet?.thumbnails?.medium?.url ??
|
||||
channel.snippet?.thumbnails?.default?.url;
|
||||
if (avatarUrl) {
|
||||
identity.avatarUrl = avatarUrl;
|
||||
}
|
||||
return identity;
|
||||
}
|
||||
}
|
||||
|
||||
const userInfo = await fetchJson<{
|
||||
sub?: string;
|
||||
name?: string;
|
||||
picture?: string;
|
||||
email?: string;
|
||||
}>(
|
||||
"https://openidconnect.googleapis.com/v1/userinfo",
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${options.accessToken}`,
|
||||
},
|
||||
},
|
||||
"Google identity lookup failed"
|
||||
);
|
||||
|
||||
if (!userInfo.sub) {
|
||||
throw new Error("Google identity response did not include a subject.");
|
||||
}
|
||||
|
||||
const identity: ResolvedIdentity = {
|
||||
provider: "youtube",
|
||||
providerUserId: userInfo.sub,
|
||||
username: userInfo.email ?? userInfo.name ?? userInfo.sub,
|
||||
displayName: userInfo.name ?? userInfo.email ?? userInfo.sub,
|
||||
profile: userInfo as unknown as Record<string, unknown>,
|
||||
};
|
||||
|
||||
if (userInfo.email) {
|
||||
identity.primaryEmail = userInfo.email;
|
||||
}
|
||||
|
||||
if (userInfo.picture) {
|
||||
identity.avatarUrl = userInfo.picture;
|
||||
}
|
||||
|
||||
return identity;
|
||||
}
|
||||
|
||||
async function evaluateDiscordEntitlements(options: {
|
||||
config: HeimdallConfig;
|
||||
callback: OAuthCallbackContext;
|
||||
|
|
@ -519,6 +762,22 @@ const patreonRuntime: OAuthProviderRuntime = {
|
|||
evaluateEntitlements: evaluatePatreonEntitlements,
|
||||
};
|
||||
|
||||
const twitchRuntime: OAuthProviderRuntime = {
|
||||
exchangeAuthorizationCode: exchangeTwitchAuthorizationCode,
|
||||
resolveIdentity: resolveTwitchIdentity,
|
||||
async evaluateEntitlements() {
|
||||
return { facts: [], snapshots: [] };
|
||||
},
|
||||
};
|
||||
|
||||
const youtubeRuntime: OAuthProviderRuntime = {
|
||||
exchangeAuthorizationCode: exchangeYouTubeAuthorizationCode,
|
||||
resolveIdentity: resolveYouTubeIdentity,
|
||||
async evaluateEntitlements() {
|
||||
return { facts: [], snapshots: [] };
|
||||
},
|
||||
};
|
||||
|
||||
const notImplementedRuntime: OAuthProviderRuntime = {
|
||||
async exchangeAuthorizationCode() {
|
||||
throw new Error("Provider callback exchange is not implemented yet.");
|
||||
|
|
@ -538,7 +797,7 @@ export function createOAuthRuntimeRegistry(): OAuthRuntimeRegistry {
|
|||
discord: discordRuntime,
|
||||
patreon: patreonRuntime,
|
||||
github: notImplementedRuntime,
|
||||
twitch: notImplementedRuntime,
|
||||
youtube: notImplementedRuntime,
|
||||
twitch: twitchRuntime,
|
||||
youtube: youtubeRuntime,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,16 @@ export class InMemoryStore implements HeimdallStore {
|
|||
return null;
|
||||
}
|
||||
|
||||
async findStoredLinkedIdentityForAccount(accountId: string, provider: Provider): Promise<StoredLinkedIdentity | null> {
|
||||
for (const linkedIdentity of this.linkedIdentities.values()) {
|
||||
if (linkedIdentity.accountId === accountId && linkedIdentity.provider === provider) {
|
||||
return clone(linkedIdentity);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
async upsertLinkedIdentity(input: UpsertLinkedIdentityInput): Promise<StoredLinkedIdentity> {
|
||||
const existing = [...this.linkedIdentities.values()].find(
|
||||
(identity) => identity.provider === input.provider && identity.providerUserId === input.providerUserId
|
||||
|
|
|
|||
|
|
@ -289,6 +289,22 @@ export class PostgresStore implements HeimdallStore {
|
|||
return result.rowCount ? mapLinkedIdentityRow(expectRow(result.rows[0], "findStoredLinkedIdentity")) : null;
|
||||
}
|
||||
|
||||
async findStoredLinkedIdentityForAccount(accountId: string, provider: Provider): Promise<StoredLinkedIdentity | null> {
|
||||
const result = await this.pool.query<LinkedIdentityRow>(
|
||||
`
|
||||
SELECT *
|
||||
FROM linked_identities
|
||||
WHERE account_id = $1
|
||||
AND provider = $2
|
||||
ORDER BY updated_at DESC
|
||||
LIMIT 1
|
||||
`,
|
||||
[accountId, provider]
|
||||
);
|
||||
|
||||
return result.rowCount ? mapLinkedIdentityRow(expectRow(result.rows[0], "findStoredLinkedIdentityForAccount")) : null;
|
||||
}
|
||||
|
||||
async upsertLinkedIdentity(input: UpsertLinkedIdentityInput): Promise<StoredLinkedIdentity> {
|
||||
const id = input.id ?? randomUUID();
|
||||
const result = await this.pool.query<LinkedIdentityRow>(
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ export interface HeimdallStore {
|
|||
touchAccount(accountId: string, at: string, updates?: { displayName?: string; primaryEmail?: string }): Promise<void>;
|
||||
findAccountByLinkedIdentity(provider: Provider, providerUserId: string): Promise<StoredAccount | null>;
|
||||
findStoredLinkedIdentity(provider: Provider, providerUserId: string): Promise<StoredLinkedIdentity | null>;
|
||||
findStoredLinkedIdentityForAccount(accountId: string, provider: Provider): Promise<StoredLinkedIdentity | null>;
|
||||
upsertLinkedIdentity(input: UpsertLinkedIdentityInput): Promise<StoredLinkedIdentity>;
|
||||
listLinkedIdentitiesForAccount(accountId: string): Promise<LinkedIdentityInput[]>;
|
||||
createCapabilityGrant(input: CreateCapabilityGrantInput): Promise<StoredCapabilityGrant>;
|
||||
|
|
|
|||
Loading…
Reference in a new issue