Skip to content

Commit bd4fad6

Browse files
authored
Add tsdoc (#107)
* Add tsdocs * More tsdoc fixes
1 parent 28eac09 commit bd4fad6

27 files changed

+485
-102
lines changed

schemaregistry/rest-error.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
/**
2+
* Represents a REST error.
3+
*/
14
export class RestError extends Error {
25
status: number;
36
errorCode: number;
47

8+
/**
9+
* Creates a new REST error.
10+
* @param message - The error message.
11+
* @param status - The HTTP status code.
12+
* @param errorCode - The error code.
13+
*/
514
constructor(message: string, status: number, errorCode: number) {
615
super(message + "; Error code: " + errorCode);
716
this.status = status;
817
this.errorCode = errorCode;
918
}
10-
}
19+
}

schemaregistry/rules/encryption/awskms/aws-driver.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export class AwsKmsDriver implements KmsDriver {
88
static ACCESS_KEY_ID = 'access.key.id'
99
static SECRET_ACCESS_KEY = 'secret.access.key'
1010

11+
/**
12+
* Register the AWS KMS driver with the KMS registry.
13+
*/
1114
static register(): void {
1215
registerKmsDriver(new AwsKmsDriver())
1316
}

schemaregistry/rules/encryption/azurekms/azure-driver.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export class AzureKmsDriver implements KmsDriver {
99
static CLIENT_ID = 'client.id'
1010
static CLIENT_SECRET = 'client.secret'
1111

12+
/**
13+
* Register the Azure KMS driver with the KMS registry.
14+
*/
1215
static register(): void {
1316
registerKmsDriver(new AzureKmsDriver())
1417
}

schemaregistry/rules/encryption/encrypt-executor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ export class FieldEncryptionExecutor extends FieldRuleExecutor {
6464
client: Client | null = null
6565
clock: Clock
6666

67+
/**
68+
* Register the field encryption executor with the rule registry.
69+
*/
6770
static register(): FieldEncryptionExecutor {
6871
return this.registerWithClock(new Clock())
6972
}

schemaregistry/rules/encryption/gcpkms/gcp-driver.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export class GcpKmsDriver implements KmsDriver {
1010
static PRIVATE_KEY_ID = "private.key.id";
1111
static PRIVATE_KEY= "private.key";
1212

13+
/**
14+
* Register the GCP KMS driver with the KMS registry.
15+
*/
1316
static register(): void {
1417
registerKmsDriver(new GcpKmsDriver())
1518
}

schemaregistry/rules/encryption/hcvault/hcvault-driver.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export class HcVaultDriver implements KmsDriver {
77
static TOKEN_ID = 'token.id'
88
static NAMESPACE = 'namespace'
99

10+
/**
11+
* Register the HashiCorp Vault driver with the KMS registry.
12+
*/
1013
static register(): void {
1114
registerKmsDriver(new HcVaultDriver())
1215
}

schemaregistry/rules/encryption/kms-registry.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import {SecurityException} from "./tink/exception/security_exception";
22

3+
/**
4+
* Key management service (KMS) driver.
5+
*/
36
export interface KmsDriver {
47
getKeyUrlPrefix(): string
58
newKmsClient(config: Map<string, string>, keyUrl: string): KmsClient
69
}
710

11+
/**
12+
* Key management service (KMS) client.
13+
*/
814
export interface KmsClient {
915
supported(keyUri: string): boolean
1016
encrypt(plaintext: Buffer): Promise<Buffer>
@@ -16,10 +22,18 @@ const kmsDrivers: KmsDriver[] = []
1622
const kmsClients: KmsClient[] = []
1723

1824

25+
/**
26+
* Register a KMS driver.
27+
* @param kmsDriver - the KMS driver to register
28+
*/
1929
export function registerKmsDriver(kmsDriver: KmsDriver): void {
2030
kmsDrivers.push(kmsDriver)
2131
}
2232

33+
/**
34+
* Get the KMS driver for the given key URL.
35+
* @param keyUrl - the key URL
36+
*/
2337
export function getKmsDriver(keyUrl: string): KmsDriver {
2438
for (let driver of kmsDrivers) {
2539
if (keyUrl.startsWith(driver.getKeyUrlPrefix())) {
@@ -29,10 +43,18 @@ export function getKmsDriver(keyUrl: string): KmsDriver {
2943
throw new SecurityException('no KMS driver found for key URL: ' + keyUrl)
3044
}
3145

46+
/**
47+
* Register a KMS client.
48+
* @param kmsClient - the KMS client to register
49+
*/
3250
export function registerKmsClient(kmsClient: KmsClient): void {
3351
kmsClients.push(kmsClient)
3452
}
3553

54+
/**
55+
* Get the KMS client for the given key URL.
56+
* @param keyUrl - the key URL
57+
*/
3658
export function getKmsClient(keyUrl: string): KmsClient | null {
3759
for (let client of kmsClients) {
3860
if (client.supported(keyUrl)) {
@@ -42,6 +64,9 @@ export function getKmsClient(keyUrl: string): KmsClient | null {
4264
return null
4365
}
4466

67+
/**
68+
* Clear the KMS clients.
69+
*/
4570
export function clearKmsClients(): void {
4671
kmsClients.length = 0
4772
}

schemaregistry/rules/encryption/localkms/local-driver.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export class LocalKmsDriver implements KmsDriver {
66
static PREFIX: string = 'local-kms://'
77
static SECRET: string = 'secret'
88

9+
/**
10+
* Register the local KMS driver with the KMS registry.
11+
*/
912
static register(): void {
1013
registerKmsDriver(new LocalKmsDriver())
1114
}

schemaregistry/rules/encryption/tink/aead.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/**
2-
* @license
32
* Copyright 2020 Google LLC
43
* SPDX-License-Identifier: Apache-2.0
54
*/
@@ -21,13 +20,13 @@ export abstract class Aead {
2120
* data. The resulting ciphertext allows for checking authenticity and
2221
* integrity of associated data, but does not guarantee its secrecy.
2322
*
24-
* @param plaintext the plaintext to be encrypted. It must be
23+
* @param plaintext - the plaintext to be encrypted. It must be
2524
* non-null, but can also be an empty (zero-length) byte array.
26-
* @param opt_associatedData optional associated data to be
25+
* @param opt_associatedData - optional associated data to be
2726
* authenticated, but not encrypted. A null value is equivalent to an
2827
* empty (zero-length) byte array. For successful decryption the same
2928
* associated data must be provided along with the ciphertext.
30-
* @return resulting ciphertext
29+
* @returns resulting ciphertext
3130
*
3231
*/
3332
abstract encrypt(plaintext: Uint8Array, opt_associatedData?: Uint8Array|null):
@@ -38,13 +37,13 @@ export abstract class Aead {
3837
* The decryption verifies the authenticity and integrity of the associated
3938
* data, but there are no guarantees wrt. secrecy of that data.
4039
*
41-
* @param ciphertext the ciphertext to be decrypted, must be
40+
* @param ciphertext - the ciphertext to be decrypted, must be
4241
* non-null.
43-
* @param opt_associatedData optional associated data to be
42+
* @param opt_associatedData - optional associated data to be
4443
* authenticated. A null value is equivalent to an empty (zero-length)
4544
* byte array. For successful decryption the same associated data must be
4645
* provided along with the ciphertext.
47-
* @return resulting plaintext
46+
* @returns resulting plaintext
4847
*/
4948
abstract decrypt(
5049
ciphertext: Uint8Array,

schemaregistry/rules/encryption/tink/aes_gcm.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/**
2-
* @license
32
* Copyright 2020 Google LLC
43
* SPDX-License-Identifier: Apache-2.0
54
*/
@@ -27,7 +26,6 @@ const TAG_SIZE_IN_BITS: number = 128;
2726
/**
2827
* Implementation of AES-GCM.
2928
*
30-
* @final
3129
*/
3230
export class AesGcm extends Aead {
3331
constructor(private readonly key: CryptoKey) {

0 commit comments

Comments
 (0)