Path: blob/main/components/gitpod-db/src/auth-provider-entry-db.ts
2497 views
/**1* Copyright (c) 2020 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { AuthProviderEntry as AuthProviderEntry } from "@gitpod/gitpod-protocol";7import { createHash } from "crypto";89export const AuthProviderEntryDB = Symbol("AuthProviderEntryDB");1011export interface AuthProviderEntryDB {12storeAuthProvider(ap: AuthProviderEntry, updateOAuthRevision: boolean): Promise<AuthProviderEntry>;1314delete(ap: AuthProviderEntry): Promise<void>;1516findAll(exceptOAuthRevisions?: string[]): Promise<AuthProviderEntry[]>;17/**18* `host`s contained in the result array are expected to be lower case.19*/20findAllHosts(): Promise<string[]>;21findByHost(host: string): Promise<AuthProviderEntry | undefined>;22findById(id: string): Promise<AuthProviderEntry | undefined>;23findByUserId(userId: string): Promise<AuthProviderEntry[]>;24findByOrgId(organizationId: string): Promise<AuthProviderEntry[]>;25}2627export function hashOAuth(oauth: AuthProviderEntry["oauth"]): string {28return createHash("sha256").update(JSON.stringify(oauth)).digest("hex");29}303132