kidscipher 0.5.0 → 0.7.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.
@@ -2,6 +2,13 @@ import { CipherOptions } from '../core/cipher-options/CipherOptions';
2
2
  export type CipherConfigurationsRecord = Record<string, any>;
3
3
  declare abstract class Cipher {
4
4
  abstract encodeToken(token: string, configuration?: CipherConfigurationsRecord): string;
5
+ /**
6
+ * Tokenize input using a dictionary of valid tokens.
7
+ * Longest tokens win.
8
+ */
9
+ protected tokenize(input: string, tokens: string[]): string[];
10
+ abstract getEncodeTokens(): string[];
11
+ abstract getDecodeTokens(): string[];
5
12
  encode(input: string, configuration?: CipherConfigurationsRecord, opts?: CipherOptions): string;
6
13
  abstract decodeToken(token: string, configuration?: CipherConfigurationsRecord): string;
7
14
  decode(input: string, configuration?: CipherConfigurationsRecord, opts?: CipherOptions): string;
@@ -0,0 +1,16 @@
1
+ export declare const MORSE_CODE_ALPHABETS: {
2
+ intl: Record<string, string>;
3
+ cs: {
4
+ CH: string;
5
+ };
6
+ de: {
7
+ Ä: string;
8
+ Ö: string;
9
+ Ü: string;
10
+ ß: string;
11
+ };
12
+ es: {
13
+ Ñ: string;
14
+ };
15
+ };
16
+ export type MorseCodeAlphabetKey = keyof typeof MORSE_CODE_ALPHABETS;
@@ -1,16 +1,34 @@
1
1
  import SubstitutionCipher from '../substitution/SubstitutionCipher';
2
2
  import { CipherOptions } from '../../core/cipher-options/CipherOptions';
3
3
  import { CipherConfigurationsRecord } from '../Cipher';
4
- export type MorseCodeCipherOptions = CipherConfigurationsRecord | {
5
- dotDashMapping?: {
6
- dot?: string;
7
- dash?: string;
8
- };
4
+ import { MorseCodeAlphabetKey } from './MorseCodeAlphabet';
5
+ type DotDashMapping = {
6
+ dot: string;
7
+ dash: string;
8
+ };
9
+ type MorseCodeCipherProps = {
10
+ alphabetVariant?: MorseCodeAlphabetKey;
11
+ dotDashMapping?: Partial<DotDashMapping>;
9
12
  };
10
13
  declare class MorseCodeCipher extends SubstitutionCipher {
11
- static MORSE_CODE_MAP: Record<string, string>;
12
- constructor();
13
- encode(input: string, configuration?: MorseCodeCipherOptions, opts?: CipherOptions): string;
14
- decode(input: string, configuration?: MorseCodeCipherOptions, opts?: CipherOptions): string;
14
+ private readonly dotDashMapping;
15
+ static readonly ALPHABETS: {
16
+ intl: Record<string, string>;
17
+ cs: {
18
+ CH: string;
19
+ };
20
+ de: {
21
+ Ä: string;
22
+ Ö: string;
23
+ Ü: string;
24
+ ß: string;
25
+ };
26
+ es: {
27
+ Ñ: string;
28
+ };
29
+ };
30
+ constructor({ alphabetVariant, dotDashMapping, }?: MorseCodeCipherProps);
31
+ encode(input: string, configuration?: CipherConfigurationsRecord, opts?: CipherOptions): string;
32
+ decode(input: string, configuration?: CipherConfigurationsRecord, opts?: CipherOptions): string;
15
33
  }
16
34
  export default MorseCodeCipher;
@@ -0,0 +1,11 @@
1
+ import SubstitutionCipher from '../substitution/SubstitutionCipher';
2
+ import { CipherOptions } from '../../core/cipher-options/CipherOptions';
3
+ import { CipherConfigurationsRecord } from '../Cipher';
4
+ export type LetterNumberCipherOptions = CipherConfigurationsRecord;
5
+ declare class LetterNumberCipher extends SubstitutionCipher {
6
+ static readonly ALPHABET: Record<string, string>;
7
+ constructor();
8
+ encode(input: string, configuration?: LetterNumberCipherOptions, opts?: CipherOptions): string;
9
+ decode(input: string, configuration?: LetterNumberCipherOptions, opts?: CipherOptions): string;
10
+ }
11
+ export default LetterNumberCipher;
@@ -1,6 +1,5 @@
1
1
  import ShiftCipher from './ShiftCipher';
2
2
  declare class ShiftAlphabetCipher extends ShiftCipher {
3
- static DEFAULT_ALPHABET: string[];
4
- constructor();
3
+ constructor(shift?: number);
5
4
  }
6
5
  export default ShiftAlphabetCipher;
@@ -1,17 +1,12 @@
1
1
  import { CipherOptions } from '../../core/cipher-options/CipherOptions';
2
- import Cipher, { CipherConfigurationsRecord } from '../Cipher';
3
- export type ShiftCipherOptions = CipherConfigurationsRecord | {
4
- shift: number;
5
- outputAsIndex?: boolean;
6
- inputAsIndex?: boolean;
7
- };
8
- declare class ShiftCipher extends Cipher {
2
+ import { CipherConfigurationsRecord } from '../Cipher';
3
+ import SubstitutionCipher from '../substitution/SubstitutionCipher';
4
+ declare class ShiftCipher extends SubstitutionCipher {
9
5
  private alphabet;
10
- constructor(alphabet: string[]);
11
- encodeToken(token: string, configuration: ShiftCipherOptions): string;
12
- decodeToken(token: string, configuration: ShiftCipherOptions): string;
13
- getAllTokenIndexes(token: string, shift: number): number[];
14
- encode(input: string, configuration?: ShiftCipherOptions, opts?: CipherOptions): string;
15
- decode(input: string, configuration?: ShiftCipherOptions, opts?: CipherOptions): string;
6
+ private inputMode;
7
+ private outputMode;
8
+ constructor(alphabet: string[], shift: number, inputMode?: 'letter' | 'index', outputMode?: 'letter' | 'index');
9
+ encode(input: string, configuration?: CipherConfigurationsRecord, opts?: CipherOptions): string;
10
+ decode(input: string, configuration?: CipherConfigurationsRecord, opts?: CipherOptions): string;
16
11
  }
17
12
  export default ShiftCipher;
@@ -4,6 +4,6 @@ declare class ShiftRotorABCDCipher extends ShiftRotorCipher {
4
4
  static REPEAT_ALPHABET: string[];
5
5
  private static generateRepeatRotorAlphabet;
6
6
  static ROTOR_ALPHABETS: string[][];
7
- constructor();
7
+ constructor(shifts: number[]);
8
8
  }
9
9
  export default ShiftRotorABCDCipher;
@@ -1,18 +1,9 @@
1
1
  import { CipherOptions } from '../../core/cipher-options/CipherOptions';
2
- import Cipher, { CipherConfigurationsRecord } from '../Cipher';
3
- import ShiftCipher from './ShiftCipher';
4
- export type ShiftRotorCipherOptions = CipherConfigurationsRecord | {
5
- shifts: number[];
6
- outputAsIndex?: boolean;
7
- inputAsIndex?: boolean;
8
- };
9
- declare class ShiftRotorCipher extends Cipher {
10
- baseAlphabet: ShiftCipher;
11
- rotors: ShiftCipher[];
12
- constructor(baseAlphabet: ShiftCipher, rotors: ShiftCipher[]);
13
- encodeToken(token: string, configuration: ShiftRotorCipherOptions): string;
14
- decodeToken(token: string, configuration: ShiftRotorCipherOptions): string;
15
- encode(input: string, configuration?: ShiftRotorCipherOptions, opts?: CipherOptions): string;
16
- decode(input: string, configuration?: ShiftRotorCipherOptions, opts?: CipherOptions): string;
2
+ import { CipherConfigurationsRecord } from '../Cipher';
3
+ import SubstitutionCipher from '../substitution/SubstitutionCipher';
4
+ declare class ShiftRotorCipher extends SubstitutionCipher {
5
+ constructor(baseAlphabet: string[], rotors: string[][], shifts: number[]);
6
+ encode(input: string, configuration?: CipherConfigurationsRecord, opts?: CipherOptions): string;
7
+ decode(input: string, configuration?: CipherConfigurationsRecord, opts?: CipherOptions): string;
17
8
  }
18
9
  export default ShiftRotorCipher;
@@ -2,7 +2,11 @@ import Cipher from '../Cipher';
2
2
  declare class SubstitutionCipher extends Cipher {
3
3
  protected encodeMap: Record<string, string>;
4
4
  protected decodeMap: Record<string, string>;
5
+ protected encodeTokens: string[];
6
+ protected decodeTokens: string[];
5
7
  constructor(encodeMap: Record<string, string>);
8
+ getEncodeTokens(): string[];
9
+ getDecodeTokens(): string[];
6
10
  encodeToken(token: string): string;
7
11
  decodeToken(token: string): string;
8
12
  }
@@ -4,7 +4,11 @@ declare class SubstitutionCyclicCipher extends Cipher {
4
4
  protected encodeMap: Record<string, string[]>;
5
5
  protected decodeMap: Record<string, string>;
6
6
  protected counters: Record<string, number>;
7
+ protected encodeTokens: string[];
8
+ protected decodeTokens: string[];
7
9
  constructor(encodeMap: Record<string, string | string[]>);
10
+ getEncodeTokens(): string[];
11
+ getDecodeTokens(): string[];
8
12
  resetCounters: () => void;
9
13
  encodeToken(token: string): string;
10
14
  encode(input: string, configuration?: CipherConfigurationsRecord, opts?: CipherOptions): string;
@@ -0,0 +1,47 @@
1
+ export declare const ALPHABET_CZ: {
2
+ readonly A: "A";
3
+ readonly Á: "Á";
4
+ readonly B: "B";
5
+ readonly C: "C";
6
+ readonly Č: "Č";
7
+ readonly D: "D";
8
+ readonly Ď: "Ď";
9
+ readonly E: "E";
10
+ readonly É: "É";
11
+ readonly Ě: "Ě";
12
+ readonly F: "F";
13
+ readonly G: "G";
14
+ readonly H: "H";
15
+ readonly CH: "CH";
16
+ readonly I: "I";
17
+ readonly Í: "Í";
18
+ readonly J: "J";
19
+ readonly K: "K";
20
+ readonly L: "L";
21
+ readonly M: "M";
22
+ readonly N: "N";
23
+ readonly Ň: "Ň";
24
+ readonly O: "O";
25
+ readonly Ó: "Ó";
26
+ readonly P: "P";
27
+ readonly Q: "Q";
28
+ readonly R: "R";
29
+ readonly Ř: "Ř";
30
+ readonly S: "S";
31
+ readonly Š: "Š";
32
+ readonly T: "T";
33
+ readonly Ť: "Ť";
34
+ readonly U: "U";
35
+ readonly Ú: "Ú";
36
+ readonly Ů: "Ů";
37
+ readonly V: "V";
38
+ readonly W: "W";
39
+ readonly X: "X";
40
+ readonly Y: "Y";
41
+ readonly Ý: "Ý";
42
+ readonly Z: "Z";
43
+ readonly Ž: "Ž";
44
+ };
45
+ export type AlphabetCz = (typeof ALPHABET_CZ)[keyof typeof ALPHABET_CZ];
46
+ export declare const ALPHABET_CZ_ARRAY: AlphabetCz[];
47
+ export declare const ALPHABET_CZ_NO_PUNCTUATION_ARRAY: AlphabetCz[];
@@ -0,0 +1,30 @@
1
+ export declare const ALPHABET_EN: {
2
+ readonly A: "A";
3
+ readonly B: "B";
4
+ readonly C: "C";
5
+ readonly D: "D";
6
+ readonly E: "E";
7
+ readonly F: "F";
8
+ readonly G: "G";
9
+ readonly H: "H";
10
+ readonly I: "I";
11
+ readonly J: "J";
12
+ readonly K: "K";
13
+ readonly L: "L";
14
+ readonly M: "M";
15
+ readonly N: "N";
16
+ readonly O: "O";
17
+ readonly P: "P";
18
+ readonly Q: "Q";
19
+ readonly R: "R";
20
+ readonly S: "S";
21
+ readonly T: "T";
22
+ readonly U: "U";
23
+ readonly V: "V";
24
+ readonly W: "W";
25
+ readonly X: "X";
26
+ readonly Y: "Y";
27
+ readonly Z: "Z";
28
+ };
29
+ export type AlphabetEn = (typeof ALPHABET_EN)[keyof typeof ALPHABET_EN];
30
+ export declare const ALPHABET_EN_ARRAY: AlphabetEn[];
@@ -0,0 +1,14 @@
1
+ export declare const ALPHABET_NUMBERS: {
2
+ '0': string;
3
+ '1': string;
4
+ '2': string;
5
+ '3': string;
6
+ '4': string;
7
+ '5': string;
8
+ '6': string;
9
+ '7': string;
10
+ '8': string;
11
+ '9': string;
12
+ };
13
+ export type AlphabetNumber = (typeof ALPHABET_NUMBERS)[keyof typeof ALPHABET_NUMBERS];
14
+ export declare const ALPHABET_NUMBERS_ARRAY: AlphabetNumber[];
@@ -1,2 +1,5 @@
1
1
  import './fonts/Kidscipher.css';
2
+ import './fonts/Kidscipher.ttf';
3
+ import './fonts/Kidscipher.woff';
4
+ import './fonts/Kidscipher.woff2';
2
5
  export { KidscipherGlyphs } from './fonts/KidscipherGlyphs';
@@ -15,3 +15,4 @@ export { default as ShiftRotorABCDCipher } from './cipher/shift/ShiftRotorABCDCi
15
15
  export { default as Substitution2DCipher } from './cipher/substitution/Substitution2DCipher';
16
16
  export { default as TableKeyFiveToFiveCipher } from './cipher/table/TableKeyFiveToFiveCipher';
17
17
  export { default as ChessCipher } from './cipher/table/ChessCipher';
18
+ export { default as LetterNumberCipher } from './cipher/number/LetterNumberCipher';
package/package.json CHANGED
@@ -1,19 +1,26 @@
1
1
  {
2
2
  "name": "kidscipher",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/fandau1/kidscipher",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/fandau1/kidscipher.git"
9
+ },
6
10
  "type": "module",
7
11
  "types": "dist/types/index.d.ts",
8
12
  "exports": {
9
13
  ".": {
10
14
  "import": "./dist/index.esm.js",
11
- "require": "./dist/index.cjs.js"
15
+ "require": "./dist/index.cjs.js",
16
+ "types": "./dist/types/index.d.ts"
12
17
  },
13
18
  "./font": {
14
19
  "import": "./dist/font.esm.js",
15
- "require": "./dist/font.cjs.js"
20
+ "require": "./dist/font.cjs.js",
21
+ "types": "./dist/types/font.d.ts"
16
22
  },
23
+ "./assets/*": "./dist/assets/*",
17
24
  "./kidscipher.css": "./dist/kidscipher.css"
18
25
  },
19
26
  "scripts": {