Skip to content

Commit 675bb17

Browse files
committed
improve code quality
1 parent 78cd040 commit 675bb17

File tree

5 files changed

+97
-8
lines changed

5 files changed

+97
-8
lines changed

const.ts

+46-1
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,67 @@
1+
/**
2+
* Size (in bytes) of salt block in encryption content-coding header.
3+
*/
14
export const SALT_LENGTH = 16;
5+
/**
6+
* Size (in bytes) of record size block in encryption content-coding header.
7+
*/
28
export const RS_LENGTH = 4;
9+
10+
/**
11+
* Size (in bytes) of idlen block in encryption content-coding header.
12+
*/
313
export const IDLEN_LENGTH = 1;
14+
15+
/**
16+
* Size (in bytes) of content-encryption key.
17+
*/
418
export const KEY_LENGTH = 16;
519

20+
/**
21+
* Size of authentication tag block in encryption content-coding header.
22+
*/
623
export const TAG_LENGTH = 16;
24+
25+
/**
26+
* Size of a nonce.
27+
*/
728
export const NONCE_LENGTH = 12;
829

30+
/**
31+
* Minimum size of an encryption content-coding header.
32+
*/
933
export const HEADER_LENGTH_MIN = SALT_LENGTH + RS_LENGTH + IDLEN_LENGTH;
1034

35+
/**
36+
* Default size of a record.
37+
*/
1138
export const DEFAULT_RECORD_SIZE = 1024 * 64;
39+
/**
40+
* Minimum size of a record.
41+
*/
1242
export const RECORD_SIZE_MIN = 18;
43+
/**
44+
* Maximum size of a record.
45+
*/
1346
export const RECORD_SIZE_MAX = 2 ** 36 - 31;
1447

15-
export const encoder: TextEncoder = new TextEncoder();
48+
const encoder: TextEncoder = new TextEncoder();
49+
50+
/**
51+
* Content-encryption key info as in https://www.rfc-editor.org/rfc/rfc8188#section-2.2
52+
*/
1653
export const CEK_INFO: Uint8Array = encoder.encode(
1754
"Content-Encoding: aes128gcm\0",
1855
);
56+
57+
/**
58+
* Nonce info as in https://www.rfc-editor.org/rfc/rfc8188#section-2.3
59+
*/
1960
export const NONCE_INFO: Uint8Array = encoder.encode(
2061
"Content-Encoding: nonce\0",
2162
);
63+
/**
64+
* Uint8Array of size 1 containing a single byte of value 1.
65+
* This is mostly used for concatenation with others Uint8Array.
66+
*/
2267
export const ONE_BYTE: Uint8Array = encoder.encode("\x01");

deno.json

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
],
3131
"indentWidth": 2
3232
},
33+
"publish": {
34+
"include": [
35+
"*.ts"
36+
],
37+
"exclude": [
38+
"*_test.ts"
39+
]
40+
},
3341
"imports": {
3442
"@deno/dnt": "jsr:@deno/[email protected]",
3543
"@std/encoding": "jsr:@std/[email protected]",

deno.lock

+38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ece_crypto.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
NONCE_LENGTH,
77
ONE_BYTE,
88
} from "./const.ts";
9-
import { bytes, encodeBase64Url } from "./deps.ts";
9+
import { bytes } from "./deps.ts";
1010

1111
export interface ECECryptoOptions {
1212
header?: Header | HeaderOptions;

mod.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
export { decrypt, encrypt, WithPaddingRecordIterable } from "./ece.ts";
2-
export { Header } from "./header.ts";
3-
export type { HeaderOptions } from "./header.ts";
4-
export { Salt } from "./salt.ts";
5-
export { ECECrypto } from "./ece_crypto.ts";
6-
export type { ECECryptoOptions } from "./ece_crypto.ts";
1+
export * from "./ece.ts";
2+
export * from "./header.ts";
3+
export * from "./salt.ts";
4+
export * from "./ece_crypto.ts";
75
export * from "./const.ts";

0 commit comments

Comments
 (0)