gitpod/components/gitpod-db/src/auth-provider-entry-db.ts
Alex Tugarev f27efb7716 [server] fix infinite init loop of dynamic providers
... which is caused by casing mismatch.
2022-04-12 19:46:25 +05:30

29 lines
1.0 KiB
TypeScript

/**
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/
import { AuthProviderEntry as AuthProviderEntry } from "@gitpod/gitpod-protocol";
import { createHash } from "crypto";
export const AuthProviderEntryDB = Symbol("AuthProviderEntryDB");
export interface AuthProviderEntryDB {
storeAuthProvider(ap: AuthProviderEntry, updateOAuthRevision: boolean): Promise<AuthProviderEntry>;
delete(ap: AuthProviderEntry): Promise<void>;
findAll(exceptOAuthRevisions?: string[]): Promise<AuthProviderEntry[]>;
/**
* `host`s contained in the result array are expected to be lower case.
*/
findAllHosts(): Promise<string[]>;
findByHost(host: string): Promise<AuthProviderEntry | undefined>;
findByUserId(userId: string): Promise<AuthProviderEntry[]>;
}
export function hashOAuth(oauth: AuthProviderEntry["oauth"]): string {
return createHash("sha256").update(JSON.stringify(oauth)).digest("hex");
}