@jscrypto/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/blocks.d.ts +9 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +34 -0
- package/dist/blocks.js.map +1 -0
- package/dist/bytes.d.ts +5 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +36 -0
- package/dist/bytes.js.map +1 -0
- package/dist/component.d.ts +67 -0
- package/dist/component.d.ts.map +1 -0
- package/dist/component.js +2 -0
- package/dist/component.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.cjs +590 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +552 -0
- package/dist/index.mjs.map +7 -0
- package/dist/jscrypto-core.iife.js +576 -0
- package/dist/jscrypto-core.iife.js.map +7 -0
- package/dist/jscrypto-core.iife.min.js +7 -0
- package/dist/jscrypto-core.iife.min.js.map +7 -0
- package/dist/jscrypto-core.umd.js +587 -0
- package/dist/jscrypto-core.umd.js.map +7 -0
- package/dist/jscrypto-core.umd.min.js +18 -0
- package/dist/jscrypto-core.umd.min.js.map +7 -0
- package/dist/passphrase.d.ts +31 -0
- package/dist/passphrase.d.ts.map +1 -0
- package/dist/passphrase.js +222 -0
- package/dist/passphrase.js.map +1 -0
- package/dist/registry.d.ts +28 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +73 -0
- package/dist/registry.js.map +1 -0
- package/dist/transform.d.ts +13 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +133 -0
- package/dist/transform.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chen, Yi-Cyuan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @jscrypto/core
|
|
2
|
+
|
|
3
|
+
Core registry, component contracts, transform helpers, byte helpers, and shared errors for `@jscrypto` packages.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @jscrypto/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createRegistry } from '@jscrypto/core';
|
|
15
|
+
import { aes, cbc, pkcs7 } from '@jscrypto/classic';
|
|
16
|
+
|
|
17
|
+
const registry = createRegistry()
|
|
18
|
+
.use(aes)
|
|
19
|
+
.use(cbc)
|
|
20
|
+
.use(pkcs7);
|
|
21
|
+
|
|
22
|
+
const cipher = registry.createCipher({
|
|
23
|
+
cipher: 'AES',
|
|
24
|
+
mode: 'CBC',
|
|
25
|
+
padding: 'Pkcs7',
|
|
26
|
+
key,
|
|
27
|
+
iv,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const ciphertext = cipher.encrypt(plaintext);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## What It Provides
|
|
34
|
+
|
|
35
|
+
- `createRegistry`: component registry with cipher facade and passphrase facade creation.
|
|
36
|
+
- Component contracts: cipher, mode, padding, KDF, format, and preset types.
|
|
37
|
+
- Transform contract: `process(input)` plus `finalize(input?)` for streaming.
|
|
38
|
+
- Byte helpers: `concatBytes`, `equalBytes`, `xorBytes`, and byte assertions.
|
|
39
|
+
- Block helpers: block-size, IV, and padding assertions.
|
|
40
|
+
- Errors: `CryptoError`, `DuplicateComponentError`, and `MissingComponentError`.
|
|
41
|
+
|
|
42
|
+
`@jscrypto/core` does not include concrete cryptographic algorithms. Use `@jscrypto/classic` or custom components for actual ciphers, modes, paddings, KDFs, and formats.
|
package/dist/blocks.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface BlockSizeOptions {
|
|
2
|
+
readonly max?: number;
|
|
3
|
+
}
|
|
4
|
+
export declare function assertBlockSize(blockSize: number, options?: BlockSizeOptions): void;
|
|
5
|
+
export declare function assertBlockMultiple(input: Uint8Array, blockSize: number, label: string): void;
|
|
6
|
+
export declare function assertPaddedInput(input: Uint8Array, blockSize: number, label: string, options?: BlockSizeOptions): void;
|
|
7
|
+
export declare function assertIv(blockSize: number, iv: Uint8Array | undefined, modeName: string): asserts iv is Uint8Array;
|
|
8
|
+
export declare function getBlockPaddingLength(inputLength: number, blockSize: number): number;
|
|
9
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,IAAI,CAQvF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAK7F;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,IAAI,CAK3H;AAED,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,IAAI,UAAU,CAOlH;AAED,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGpF"}
|
package/dist/blocks.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export function assertBlockSize(blockSize, options = {}) {
|
|
2
|
+
const { max } = options;
|
|
3
|
+
if (!Number.isInteger(blockSize) || blockSize <= 0) {
|
|
4
|
+
throw new RangeError('blockSize must be a positive integer.');
|
|
5
|
+
}
|
|
6
|
+
if (max !== undefined && blockSize > max) {
|
|
7
|
+
throw new RangeError(`blockSize must be an integer between 1 and ${max}.`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function assertBlockMultiple(input, blockSize, label) {
|
|
11
|
+
assertBlockSize(blockSize);
|
|
12
|
+
if (input.length % blockSize !== 0) {
|
|
13
|
+
throw new Error(`${label} input length must be a multiple of the block size.`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function assertPaddedInput(input, blockSize, label, options = {}) {
|
|
17
|
+
assertBlockSize(blockSize, options);
|
|
18
|
+
if (input.length === 0 || input.length % blockSize !== 0) {
|
|
19
|
+
throw new Error(`Invalid ${label} padded data.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function assertIv(blockSize, iv, modeName) {
|
|
23
|
+
if (!iv) {
|
|
24
|
+
throw new Error(`${modeName} mode requires an IV.`);
|
|
25
|
+
}
|
|
26
|
+
if (iv.length !== blockSize) {
|
|
27
|
+
throw new Error(`${modeName} IV length must match the cipher block size.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function getBlockPaddingLength(inputLength, blockSize) {
|
|
31
|
+
const remainder = inputLength % blockSize;
|
|
32
|
+
return remainder === 0 ? blockSize : blockSize - remainder;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,UAA4B,EAAE;IAC/E,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,UAAU,CAAC,uCAAuC,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,GAAG,KAAK,SAAS,IAAI,SAAS,GAAG,GAAG,EAAE,CAAC;QACzC,MAAM,IAAI,UAAU,CAAC,8CAA8C,GAAG,GAAG,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAiB,EAAE,SAAiB,EAAE,KAAa;IACrF,eAAe,CAAC,SAAS,CAAC,CAAC;IAC3B,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qDAAqD,CAAC,CAAC;IACjF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAiB,EAAE,SAAiB,EAAE,KAAa,EAAE,UAA4B,EAAE;IACnH,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,WAAW,KAAK,eAAe,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,SAAiB,EAAE,EAA0B,EAAE,QAAgB;IACtF,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,uBAAuB,CAAC,CAAC;IACtD,CAAC;IACD,IAAI,EAAE,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,8CAA8C,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,WAAmB,EAAE,SAAiB;IAC1E,MAAM,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;IAC1C,OAAO,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,GAAG,SAAS,CAAC;AAC7D,CAAC"}
|
package/dist/bytes.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function concatBytes(...chunks: readonly Uint8Array[]): Uint8Array;
|
|
2
|
+
export declare function equalBytes(a: Uint8Array, b: Uint8Array): boolean;
|
|
3
|
+
export declare function xorBytes(a: Uint8Array, b: Uint8Array): Uint8Array;
|
|
4
|
+
export declare function assertBytes(value: unknown, name: string): asserts value is Uint8Array;
|
|
5
|
+
//# sourceMappingURL=bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../src/bytes.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,MAAM,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAWxE;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAUhE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAUjE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAIrF"}
|
package/dist/bytes.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function concatBytes(...chunks) {
|
|
2
|
+
const length = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
3
|
+
const output = new Uint8Array(length);
|
|
4
|
+
let offset = 0;
|
|
5
|
+
for (const chunk of chunks) {
|
|
6
|
+
output.set(chunk, offset);
|
|
7
|
+
offset += chunk.length;
|
|
8
|
+
}
|
|
9
|
+
return output;
|
|
10
|
+
}
|
|
11
|
+
export function equalBytes(a, b) {
|
|
12
|
+
if (a.length !== b.length) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
let diff = 0;
|
|
16
|
+
for (let i = 0; i < a.length; i++) {
|
|
17
|
+
diff |= a[i] ^ b[i];
|
|
18
|
+
}
|
|
19
|
+
return diff === 0;
|
|
20
|
+
}
|
|
21
|
+
export function xorBytes(a, b) {
|
|
22
|
+
if (a.length !== b.length) {
|
|
23
|
+
throw new Error('XOR inputs must have the same length.');
|
|
24
|
+
}
|
|
25
|
+
const output = new Uint8Array(a.length);
|
|
26
|
+
for (let i = 0; i < a.length; i++) {
|
|
27
|
+
output[i] = a[i] ^ b[i];
|
|
28
|
+
}
|
|
29
|
+
return output;
|
|
30
|
+
}
|
|
31
|
+
export function assertBytes(value, name) {
|
|
32
|
+
if (!(value instanceof Uint8Array)) {
|
|
33
|
+
throw new TypeError(`${name} must be a Uint8Array.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../src/bytes.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,GAAG,MAA6B;IAC1D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACpE,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAa,EAAE,CAAa;IACrD,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAa,EAAE,CAAa;IACnD,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc,EAAE,IAAY;IACtD,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,wBAAwB,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type ComponentKind = 'cipher' | 'mode' | 'padding' | 'kdf' | 'format' | 'preset';
|
|
2
|
+
export interface Component<Kind extends ComponentKind = ComponentKind, Name extends string = string> {
|
|
3
|
+
readonly kind: Kind;
|
|
4
|
+
readonly name: Name;
|
|
5
|
+
}
|
|
6
|
+
export type CipherComponent<Name extends string = string> = BlockCipherComponent<Name> | StreamCipherComponent<Name>;
|
|
7
|
+
export interface BlockCipherComponent<Name extends string = string> extends Component<'cipher', Name> {
|
|
8
|
+
readonly type: 'block';
|
|
9
|
+
readonly blockSize: number;
|
|
10
|
+
readonly keySizes: readonly number[];
|
|
11
|
+
create(key: Uint8Array): BlockCipher;
|
|
12
|
+
}
|
|
13
|
+
export interface StreamCipherComponent<Name extends string = string> extends Component<'cipher', Name> {
|
|
14
|
+
readonly type: 'stream';
|
|
15
|
+
readonly keySizes?: readonly number[];
|
|
16
|
+
createEncryptor(params: StreamCipherTransformParams): Transform;
|
|
17
|
+
createDecryptor(params: StreamCipherTransformParams): Transform;
|
|
18
|
+
}
|
|
19
|
+
export interface BlockCipher {
|
|
20
|
+
readonly blockSize: number;
|
|
21
|
+
encryptBlock(block: Uint8Array): Uint8Array;
|
|
22
|
+
decryptBlock(block: Uint8Array): Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
export interface ModeComponent<Name extends string = string> extends Component<'mode', Name> {
|
|
25
|
+
readonly requiresPadding?: boolean;
|
|
26
|
+
readonly requiredBlockSize?: number;
|
|
27
|
+
readonly aead?: boolean;
|
|
28
|
+
createEncryptor(params: BlockModeTransformParams): Transform;
|
|
29
|
+
createDecryptor(params: BlockModeTransformParams): Transform;
|
|
30
|
+
}
|
|
31
|
+
export interface BlockModeTransformParams {
|
|
32
|
+
cipher: BlockCipher;
|
|
33
|
+
iv?: Uint8Array;
|
|
34
|
+
}
|
|
35
|
+
export interface StreamCipherTransformParams {
|
|
36
|
+
key: Uint8Array;
|
|
37
|
+
options?: unknown;
|
|
38
|
+
}
|
|
39
|
+
export interface Transform {
|
|
40
|
+
process(input: Uint8Array): Uint8Array;
|
|
41
|
+
finalize(input?: Uint8Array): Uint8Array;
|
|
42
|
+
}
|
|
43
|
+
export interface PaddingComponent<Name extends string = string> extends Component<'padding', Name> {
|
|
44
|
+
pad(input: Uint8Array, blockSize: number): Uint8Array;
|
|
45
|
+
unpad(input: Uint8Array, blockSize: number): Uint8Array;
|
|
46
|
+
}
|
|
47
|
+
export interface KdfComponent<Name extends string = string> extends Component<'kdf', Name> {
|
|
48
|
+
derive(params: unknown): Uint8Array | Promise<Uint8Array>;
|
|
49
|
+
}
|
|
50
|
+
export interface FormatComponent<Name extends string = string> extends Component<'format', Name> {
|
|
51
|
+
readonly mediaType?: string;
|
|
52
|
+
stringify(params: FormatStringifyParams): Uint8Array;
|
|
53
|
+
parse(input: Uint8Array): FormatParseResult;
|
|
54
|
+
}
|
|
55
|
+
export interface FormatStringifyParams {
|
|
56
|
+
ciphertext: Uint8Array;
|
|
57
|
+
salt?: Uint8Array;
|
|
58
|
+
}
|
|
59
|
+
export interface FormatParseResult {
|
|
60
|
+
ciphertext: Uint8Array;
|
|
61
|
+
salt?: Uint8Array;
|
|
62
|
+
}
|
|
63
|
+
export interface PresetComponent<Name extends string = string> extends Component<'preset', Name> {
|
|
64
|
+
components(): Iterable<AnyComponent>;
|
|
65
|
+
}
|
|
66
|
+
export type AnyComponent = CipherComponent | ModeComponent | PaddingComponent | KdfComponent | FormatComponent | PresetComponent;
|
|
67
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAExF,MAAM,WAAW,SAAS,CACxB,IAAI,SAAS,aAAa,GAAG,aAAa,EAC1C,IAAI,SAAS,MAAM,GAAG,MAAM;IAE5B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AAED,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IACpD,oBAAoB,CAAC,IAAI,CAAC,GAC1B,qBAAqB,CAAC,IAAI,CAAC,CAAC;AAEhC,MAAM,WAAW,oBAAoB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC;IACnG,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EA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e,GACf,aAAa,GACb,gBAAgB,GAChB,YAAY,GACZ,eAAe,GACf,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":""}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class CryptoError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class DuplicateComponentError extends CryptoError {
|
|
5
|
+
constructor(kind: string, name: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class MissingComponentError extends CryptoError {
|
|
8
|
+
constructor(kind: string, name: string);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,uBAAwB,SAAQ,WAAW;gBAC1C,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAGvC;AAED,qBAAa,qBAAsB,SAAQ,WAAW;gBACxC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAGvC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class CryptoError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = new.target.name;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export class DuplicateComponentError extends CryptoError {
|
|
8
|
+
constructor(kind, name) {
|
|
9
|
+
super(`Component already registered: ${kind}:${name}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class MissingComponentError extends CryptoError {
|
|
13
|
+
constructor(kind, name) {
|
|
14
|
+
super(`Component not found: ${kind}:${name}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,WAAW;IACtD,YAAY,IAAY,EAAE,IAAY;QACpC,KAAK,CAAC,iCAAiC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IACpD,YAAY,IAAY,EAAE,IAAY;QACpC,KAAK,CAAC,wBAAwB,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;CACF"}
|