redac---n 0.0.0-stage → 0.0.2
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 +323 -2
- package/THIRD_PARTY_NOTICES.md +59 -0
- package/dist/aho.d.ts +25 -0
- package/dist/aho.js +116 -0
- package/dist/base64.d.ts +10 -0
- package/dist/base64.js +29 -0
- package/dist/bip39-data.d.ts +2 -0
- package/dist/bip39-data.js +2 -0
- package/dist/cache.d.ts +14 -0
- package/dist/cache.js +40 -0
- package/dist/calls.d.ts +64 -0
- package/dist/calls.js +269 -0
- package/dist/charlm-data.d.ts +2 -0
- package/dist/charlm-data.js +3 -0
- package/dist/charlm.d.ts +7 -0
- package/dist/charlm.js +65 -0
- package/dist/checksums.d.ts +10 -0
- package/dist/checksums.js +98 -0
- package/dist/commands.d.ts +72 -0
- package/dist/commands.js +787 -0
- package/dist/context.d.ts +98 -0
- package/dist/context.js +469 -0
- package/dist/encoded.d.ts +11 -0
- package/dist/encoded.js +336 -0
- package/dist/environment.d.ts +10 -0
- package/dist/environment.js +62 -0
- package/dist/formats-data.d.ts +2 -0
- package/dist/formats-data.js +405 -0
- package/dist/formats.d.ts +5 -0
- package/dist/formats.js +470 -0
- package/dist/hmac.d.ts +3 -0
- package/dist/hmac.js +87 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.js +488 -0
- package/dist/json.d.ts +82 -0
- package/dist/json.js +392 -0
- package/dist/known.d.ts +34 -0
- package/dist/known.js +340 -0
- package/dist/lines.d.ts +28 -0
- package/dist/lines.js +69 -0
- package/dist/lookup.d.ts +5 -0
- package/dist/lookup.js +7 -0
- package/dist/model-data.d.ts +3 -0
- package/dist/model-data.js +4 -0
- package/dist/model.d.ts +2 -0
- package/dist/model.js +19 -0
- package/dist/named.d.ts +20 -0
- package/dist/named.js +3257 -0
- package/dist/names.d.ts +106 -0
- package/dist/names.js +1517 -0
- package/dist/normalize.d.ts +25 -0
- package/dist/normalize.js +529 -0
- package/dist/pem.d.ts +32 -0
- package/dist/pem.js +269 -0
- package/dist/policy.d.ts +3 -0
- package/dist/policy.js +470 -0
- package/dist/public.d.ts +44 -0
- package/dist/public.js +362 -0
- package/dist/publickeys.d.ts +41 -0
- package/dist/publickeys.js +232 -0
- package/dist/random.d.ts +29 -0
- package/dist/random.js +165 -0
- package/dist/repeats.d.ts +21 -0
- package/dist/repeats.js +80 -0
- package/dist/rules.d.ts +42 -0
- package/dist/rules.js +58 -0
- package/dist/runs.d.ts +10 -0
- package/dist/runs.js +36 -0
- package/dist/secretfile.d.ts +52 -0
- package/dist/secretfile.js +722 -0
- package/dist/shell.d.ts +127 -0
- package/dist/shell.js +703 -0
- package/dist/spans.d.ts +61 -0
- package/dist/spans.js +287 -0
- package/dist/sql.d.ts +20 -0
- package/dist/sql.js +66 -0
- package/dist/stream.d.ts +46 -0
- package/dist/stream.js +150 -0
- package/dist/structure.d.ts +24 -0
- package/dist/structure.js +1625 -0
- package/dist/syntax.d.ts +156 -0
- package/dist/syntax.js +446 -0
- package/dist/transcript.d.ts +30 -0
- package/dist/transcript.js +713 -0
- package/dist/types.d.ts +81 -0
- package/dist/types.js +1 -0
- package/dist/unnamed.d.ts +59 -0
- package/dist/unnamed.js +939 -0
- package/dist/urls.d.ts +70 -0
- package/dist/urls.js +303 -0
- package/dist/values.d.ts +178 -0
- package/dist/values.js +1621 -0
- package/dist/yaml.d.ts +40 -0
- package/dist/yaml.js +174 -0
- package/docs/creddata.svg +318 -0
- package/docs/guessing.md +139 -0
- package/docs/holdout.svg +85 -0
- package/docs/layers.md +80 -0
- package/docs/models.svg +81 -0
- package/docs/real-text.svg +112 -0
- package/package.json +57 -5
package/dist/shell.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export interface ShellWord {
|
|
2
|
+
/** The word with its quotes and escapes removed. */
|
|
3
|
+
text: string;
|
|
4
|
+
/** Where it was written: its start and end, and what is there (offset added). */
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
raw: string;
|
|
8
|
+
/** Whether any of it was quoted. */
|
|
9
|
+
quoted: boolean;
|
|
10
|
+
/** Whether its last part sat in single quotes (`'…'`, `$'…'`), where a shell expands nothing: `'$mIWy…'` is a literal. */
|
|
11
|
+
literalEnd: boolean;
|
|
12
|
+
/** Where each character of `text` was written (offset added): a value's span is read off it, never searched for. */
|
|
13
|
+
map: number[];
|
|
14
|
+
/** Where each character's source ends (offset added): an escape, `\x63` in `$'…'`, is several characters of the line. */
|
|
15
|
+
ends: number[];
|
|
16
|
+
/** Where the commands its substitutions run are written (offset added): `$(…)`, backticks, `<(…)`, `>(…)`. */
|
|
17
|
+
substitutions: {
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
}[];
|
|
21
|
+
}
|
|
22
|
+
export interface ShellRedirect {
|
|
23
|
+
/** The operator, without its file descriptor: `>`, `>>`, `>|`, `&>`, `&>>`, `<`, `<>`, `>&`, `<&`, `<<`, `<<-`, `<<<`. */
|
|
24
|
+
op: string;
|
|
25
|
+
/** The file descriptor written before it, if one was: `2` of `2>/dev/null`. */
|
|
26
|
+
fd?: number;
|
|
27
|
+
/** Its target: a file, a descriptor (`2>&1`'s `1`), a heredoc's delimiter, a here-string. */
|
|
28
|
+
target?: ShellWord;
|
|
29
|
+
/** Where the redirection is written, its target included (offset added). */
|
|
30
|
+
start: number;
|
|
31
|
+
end: number;
|
|
32
|
+
}
|
|
33
|
+
export interface Heredoc {
|
|
34
|
+
/** The delimiter, unquoted, and whether it was quoted (`<<'EOF'`, `<<\EOF`: the body isn't expanded). */
|
|
35
|
+
delimiter: string;
|
|
36
|
+
quoted: boolean;
|
|
37
|
+
/** `<<-`: the body's and the terminator's leading tabs are stripped. */
|
|
38
|
+
strip: boolean;
|
|
39
|
+
/** The body: the lines after the command's line, up to the delimiter's line, or the end (offset added). */
|
|
40
|
+
start: number;
|
|
41
|
+
end: number;
|
|
42
|
+
terminated: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** A compound command around simple ones: its redirections and the operator after it apply to all of them. */
|
|
45
|
+
export interface ShellGroup {
|
|
46
|
+
kind: string;
|
|
47
|
+
redirects: ShellRedirect[];
|
|
48
|
+
}
|
|
49
|
+
type ShellOperator = "|" | "|&" | "||" | "&&" | ";" | "&" | "\n" | "";
|
|
50
|
+
export interface ShellCommand {
|
|
51
|
+
/** The command as written, and where it starts and ends (offset added). */
|
|
52
|
+
text: string;
|
|
53
|
+
start: number;
|
|
54
|
+
end: number;
|
|
55
|
+
/** Its words, redirections aside. */
|
|
56
|
+
words: ShellWord[];
|
|
57
|
+
redirects: ShellRedirect[];
|
|
58
|
+
heredocs: Heredoc[];
|
|
59
|
+
/** The groups it is inside, innermost first. */
|
|
60
|
+
groups: ShellGroup[];
|
|
61
|
+
/** The operator after it, or after the group it ends: `|` and `|&` pipe its output into the next command. */
|
|
62
|
+
then: ShellOperator;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Where each short line of a text starts, by its content (and by its content without leading tabs): a heredoc's
|
|
66
|
+
* terminator is then a lookup, so many heredoc lines in a text cost each body once.
|
|
67
|
+
*/
|
|
68
|
+
export declare class LineIndex {
|
|
69
|
+
private readonly exact;
|
|
70
|
+
private readonly stripped;
|
|
71
|
+
constructor(text: string);
|
|
72
|
+
/** The first line at or after `from` that is `line` (with `strip`, after its leading tabs), or -1. */
|
|
73
|
+
next(line: string, strip: boolean, from: number): number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The commands of a command line (or several: a line break ends a command), read from `at` to the end of `text`. With
|
|
77
|
+
* `oneLine`, through the logical line at `at` (continued by `\`-newlines, and by a quote that closes within a few lines)
|
|
78
|
+
* and its heredocs' bodies, as out of other text. With `backslash` false a backslash is a character like any other, as
|
|
79
|
+
* on Windows (`.\.env`, `\\srv\share`). A `lines` index of `text` finds heredocs' terminators by lookup.
|
|
80
|
+
*/
|
|
81
|
+
export declare function shellCommands(text: string, offset?: number, { backslash, oneLine, at, lines, }?: {
|
|
82
|
+
backslash?: boolean;
|
|
83
|
+
oneLine?: boolean;
|
|
84
|
+
at?: number;
|
|
85
|
+
lines?: LineIndex;
|
|
86
|
+
}): ShellCommand[];
|
|
87
|
+
/** The shell word written at `at`, read to its line's end at most: `'it'\''s'` is one word, `it's`. */
|
|
88
|
+
export declare function shellWordAt(text: string, at: number): ShellWord;
|
|
89
|
+
/** The words of a command line, redirections aside (see shellCommands). */
|
|
90
|
+
export declare function shellWords(command: string, offset?: number, { backslash }?: {
|
|
91
|
+
backslash?: boolean | undefined;
|
|
92
|
+
}): ShellWord[];
|
|
93
|
+
/** A command's redirections and those of the groups it is inside. */
|
|
94
|
+
export declare function allRedirects(c: ShellCommand): ShellRedirect[];
|
|
95
|
+
/**
|
|
96
|
+
* Whether a redirection sends the command's standard output to a file: `>`, `>>`, `>|`, `&>`, `&>>`, and `>&` onto a
|
|
97
|
+
* file (`>& out`; `>&2` and `2>&1` copy a descriptor), with no descriptor written before it or standard output's
|
|
98
|
+
* (`1> out`, `1>& out`; `2> out` sends another's).
|
|
99
|
+
*/
|
|
100
|
+
export declare function redirectsStdout(r: ShellRedirect): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Where `text.slice(from)` of a word was written: the characters themselves when they were written together, or,
|
|
103
|
+
* when quotes or escapes sit among them (`'Xk9'"mQ2"`, `'a'\''b'`, `a\ b`), the whole stretch with the quotes around it,
|
|
104
|
+
* so what replaces it leaves the line's quoting whole.
|
|
105
|
+
*/
|
|
106
|
+
export declare function wordSpan(word: ShellWord, from?: number): {
|
|
107
|
+
start: number;
|
|
108
|
+
end: number;
|
|
109
|
+
};
|
|
110
|
+
/** The command line an argument vector stands for, each word quoted as a shell needs it: `["bash", "-lc", "cat .env"]` → `bash -lc 'cat .env'`. */
|
|
111
|
+
export declare function shellLine(argv: string[]): string;
|
|
112
|
+
/**
|
|
113
|
+
* A terminal prompt at the start of a line, before a command: a shell's `$ `, `user@host:~$ `, PowerShell's
|
|
114
|
+
* `PS C:\> `, a notebook's `In [3]: !` or a cell's bare `!` before a command. Group 1 is the command.
|
|
115
|
+
*/
|
|
116
|
+
export declare const PROMPT: RegExp;
|
|
117
|
+
/** Whether a word names a wrapper, a command that runs the command after it. */
|
|
118
|
+
export declare function isWrapper(word: string): boolean;
|
|
119
|
+
/** A program's name without its directory and Windows' `.exe`: `/usr/bin/grep` → `grep`, `.\\steamcmd.exe` → `steamcmd`. */
|
|
120
|
+
export declare function programName(word: ShellWord | undefined): string;
|
|
121
|
+
/**
|
|
122
|
+
* A simple command's words from the program it runs: past assignments (`FOO=1`), reserved words (`!`, `then`, `do`)
|
|
123
|
+
* and wrappers with their options and operands (`sudo -iu app`, `env -i`, `timeout 5`, `nice -n 10`, `xargs -I{}`).
|
|
124
|
+
* A wrapper that runs nothing (`env -0`, `sudo -l`) is the program itself.
|
|
125
|
+
*/
|
|
126
|
+
export declare function simpleCommand(words: ShellWord[]): ShellWord[];
|
|
127
|
+
export {};
|