mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
29 lines
1.0 KiB
TypeScript
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");
|
|
}
|