Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/gitpod-db/src/one-time-secret-db.ts
2497 views
1
/**
2
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
export const OneTimeSecretDB = Symbol("OneTimeSecretDB");
8
9
export interface OneTimeSecretDB {
10
/**
11
* Register registers a secret for one-time retrieval until a certain time.
12
*
13
* @param secret value to provide once
14
* @param expirationTime until which the secret is available
15
* @returns the key using which the secret can be retrieved
16
*/
17
register(secret: string, expirationTime: Date): Promise<string>;
18
19
/**
20
* Get retrieves a secret and deletes it.
21
* A secret can be retrieved only once.
22
*
23
* @param key by which to retrieve the secret
24
* @returns the secret if available
25
*/
26
get(key: string): Promise<string | undefined>;
27
28
/**
29
* Remove deletes a previously registered one-time-secret.
30
*
31
* @param key of the secret to remove
32
*/
33
remove(key: string): Promise<void>;
34
35
/**
36
* Prune delets all expired one-time secretes.
37
*/
38
pruneExpired(): Promise<void>;
39
}
40
41