@coffre/core 0.1.13 → 0.1.15
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/dist/dotenv.d.ts +2 -0
- package/dist/dotenv.js +5 -4
- package/dist/vault.d.ts +6 -3
- package/package.json +2 -2
- package/src/dotenv.ts +4 -3
- package/src/vault.ts +6 -3
package/dist/dotenv.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export declare function parseDotenv(input: string): ParseResult;
|
|
|
35
35
|
* escapes the parser knows (`\\`, `\"`, `\n`, `\r`).
|
|
36
36
|
*/
|
|
37
37
|
export declare function formatDotenv(entries: Iterable<readonly [key: string, value: string]>): string;
|
|
38
|
+
/** Reject names and values that cannot be passed intact in an environment. */
|
|
39
|
+
export declare function assertEnvironmentEntry(key: string, value: string): void;
|
|
38
40
|
/**
|
|
39
41
|
* Write entries as POSIX shell `export` statements, for
|
|
40
42
|
* `eval "$(coffre export … --format shell)"`. Single quotes are the only
|
package/dist/dotenv.js
CHANGED
|
@@ -156,12 +156,13 @@ const PLAIN_VALUE = /^[A-Za-z0-9_./:@+,=%?-]*$/;
|
|
|
156
156
|
function formatDotenv(entries) {
|
|
157
157
|
let out = "";
|
|
158
158
|
for (const [key, value] of entries) {
|
|
159
|
-
|
|
159
|
+
assertEnvironmentEntry(key, value);
|
|
160
160
|
out += `${key}=${quoteDotenv(value)}\n`;
|
|
161
161
|
}
|
|
162
162
|
return out;
|
|
163
163
|
}
|
|
164
|
-
|
|
164
|
+
/** Reject names and values that cannot be passed intact in an environment. */
|
|
165
|
+
function assertEnvironmentEntry(key, value) {
|
|
165
166
|
if (!KEY_RE.test(key)) throw new Error(`${JSON.stringify(key)} is not a valid variable name`);
|
|
166
167
|
if (value.includes("\0")) throw new Error(`${key} contains a NUL byte`);
|
|
167
168
|
}
|
|
@@ -185,10 +186,10 @@ function quoteDotenv(value) {
|
|
|
185
186
|
function formatShellExports(entries) {
|
|
186
187
|
let out = "";
|
|
187
188
|
for (const [key, value] of entries) {
|
|
188
|
-
|
|
189
|
+
assertEnvironmentEntry(key, value);
|
|
189
190
|
out += `export ${key}='${value.replaceAll("'", "'\\''")}'\n`;
|
|
190
191
|
}
|
|
191
192
|
return out;
|
|
192
193
|
}
|
|
193
194
|
//#endregion
|
|
194
|
-
export { formatDotenv, formatShellExports, parseDotenv };
|
|
195
|
+
export { assertEnvironmentEntry, formatDotenv, formatShellExports, parseDotenv };
|
package/dist/vault.d.ts
CHANGED
|
@@ -141,9 +141,12 @@ export interface Vault {
|
|
|
141
141
|
}>>;
|
|
142
142
|
/**
|
|
143
143
|
* Sign the log up to its last entry, in an `audit.checkpoint` entry of
|
|
144
|
-
* the vault's, if the
|
|
145
|
-
*
|
|
146
|
-
*
|
|
144
|
+
* the vault's, if the chain recomputes, the vault's entries by their MACs,
|
|
145
|
+
* and the prefix the last checkpoint signed is still there. The first
|
|
146
|
+
* checkpoint of each hour recomputes from the first entry; the others
|
|
147
|
+
* resume from the prefix the last one signed, which the vault recomputed
|
|
148
|
+
* itself, while it still has every entry and ends at the hash it signed.
|
|
149
|
+
* The vault reads the log itself: it takes nobody's word
|
|
147
150
|
* for where it ends, or for what came before. It checks every
|
|
148
151
|
* member's row too, as `access` would, and logs a `vault.tampered` for
|
|
149
152
|
* each one changed around it: lists read rows without asking the vault.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffre/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "What coffre's packages share: roles, envelopes, identity, the audit chain and the vault's contract.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@types/node": "26.1.1",
|
|
70
70
|
"tsdown": "0.23.0",
|
|
71
71
|
"typescript": "5.9.3",
|
|
72
|
-
"@coffre/conformance": "0.1.
|
|
72
|
+
"@coffre/conformance": "0.1.15"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "tsdown",
|
package/src/dotenv.ts
CHANGED
|
@@ -199,13 +199,14 @@ const PLAIN_VALUE = /^[A-Za-z0-9_./:@+,=%?-]*$/;
|
|
|
199
199
|
export function formatDotenv(entries: Iterable<readonly [key: string, value: string]>): string {
|
|
200
200
|
let out = '';
|
|
201
201
|
for (const [key, value] of entries) {
|
|
202
|
-
|
|
202
|
+
assertEnvironmentEntry(key, value);
|
|
203
203
|
out += `${key}=${quoteDotenv(value)}\n`;
|
|
204
204
|
}
|
|
205
205
|
return out;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
/** Reject names and values that cannot be passed intact in an environment. */
|
|
209
|
+
export function assertEnvironmentEntry(key: string, value: string): void {
|
|
209
210
|
if (!KEY_RE.test(key)) throw new Error(`${JSON.stringify(key)} is not a valid variable name`);
|
|
210
211
|
if (value.includes('\u0000')) throw new Error(`${key} contains a NUL byte`);
|
|
211
212
|
}
|
|
@@ -235,7 +236,7 @@ function quoteDotenv(value: string): string {
|
|
|
235
236
|
export function formatShellExports(entries: Iterable<readonly [key: string, value: string]>): string {
|
|
236
237
|
let out = '';
|
|
237
238
|
for (const [key, value] of entries) {
|
|
238
|
-
|
|
239
|
+
assertEnvironmentEntry(key, value);
|
|
239
240
|
out += `export ${key}='${value.replaceAll("'", "'\\''")}'\n`;
|
|
240
241
|
}
|
|
241
242
|
return out;
|
package/src/vault.ts
CHANGED
|
@@ -55,9 +55,12 @@ export interface Vault {
|
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Sign the log up to its last entry, in an `audit.checkpoint` entry of
|
|
58
|
-
* the vault's, if the
|
|
59
|
-
*
|
|
60
|
-
*
|
|
58
|
+
* the vault's, if the chain recomputes, the vault's entries by their MACs,
|
|
59
|
+
* and the prefix the last checkpoint signed is still there. The first
|
|
60
|
+
* checkpoint of each hour recomputes from the first entry; the others
|
|
61
|
+
* resume from the prefix the last one signed, which the vault recomputed
|
|
62
|
+
* itself, while it still has every entry and ends at the hash it signed.
|
|
63
|
+
* The vault reads the log itself: it takes nobody's word
|
|
61
64
|
* for where it ends, or for what came before. It checks every
|
|
62
65
|
* member's row too, as `access` would, and logs a `vault.tampered` for
|
|
63
66
|
* each one changed around it: lists read rows without asking the vault.
|