Path: blob/main/components/gitpod-db/src/one-time-secret-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*/56export const OneTimeSecretDB = Symbol("OneTimeSecretDB");78export interface OneTimeSecretDB {9/**10* Register registers a secret for one-time retrieval until a certain time.11*12* @param secret value to provide once13* @param expirationTime until which the secret is available14* @returns the key using which the secret can be retrieved15*/16register(secret: string, expirationTime: Date): Promise<string>;1718/**19* Get retrieves a secret and deletes it.20* A secret can be retrieved only once.21*22* @param key by which to retrieve the secret23* @returns the secret if available24*/25get(key: string): Promise<string | undefined>;2627/**28* Remove deletes a previously registered one-time-secret.29*30* @param key of the secret to remove31*/32remove(key: string): Promise<void>;3334/**35* Prune delets all expired one-time secretes.36*/37pruneExpired(): Promise<void>;38}394041