@modootoday/envs 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/.agent/skills/env-value-store/SKILL.md +350 -0
- package/LICENSE +93 -0
- package/NOTICE +24 -0
- package/README.md +97 -0
- package/dist/chunk-47XO3SDE.js +4591 -0
- package/dist/chunk-STHFIZRP.js +1310 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +10 -0
- package/dist/config-DKLCgBZX.d.cts +116 -0
- package/dist/config-DKLCgBZX.d.ts +116 -0
- package/dist/config.cjs +940 -0
- package/dist/config.d.cts +5 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.js +10 -0
- package/dist/index.cjs +5915 -0
- package/dist/index.d.cts +418 -0
- package/dist/index.d.ts +418 -0
- package/dist/index.js +112 -0
- package/package.json +98 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key hierarchy. Values are sealed under a random DEK, and the DEK is wrapped
|
|
3
|
+
* once per way of getting it back: the KEK, and each recovery code. Losing one
|
|
4
|
+
* way costs nothing as long as another wrap survives.
|
|
5
|
+
*/
|
|
6
|
+
declare const DEK_BYTES = 32;
|
|
7
|
+
type WrapMethod = "kek" | "recovery";
|
|
8
|
+
interface DekWrap {
|
|
9
|
+
readonly wrapId: string;
|
|
10
|
+
readonly method: WrapMethod;
|
|
11
|
+
readonly salt: Uint8Array;
|
|
12
|
+
/** scrypt cost, stored so a future default cannot orphan an old wrap. */
|
|
13
|
+
readonly n: number;
|
|
14
|
+
readonly r: number;
|
|
15
|
+
readonly p: number;
|
|
16
|
+
readonly envelope: Uint8Array;
|
|
17
|
+
}
|
|
18
|
+
interface Keyring {
|
|
19
|
+
readonly dek: Uint8Array;
|
|
20
|
+
readonly wraps: readonly DekWrap[];
|
|
21
|
+
/** Shown once at creation. Never stored, never recoverable from the wraps. */
|
|
22
|
+
readonly recoveryCodes: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
declare class RecoveryCodeError extends Error {
|
|
25
|
+
constructor(message: string);
|
|
26
|
+
}
|
|
27
|
+
declare class KeyringLockedError extends Error {
|
|
28
|
+
readonly tried: number;
|
|
29
|
+
constructor(tried: number);
|
|
30
|
+
}
|
|
31
|
+
declare function formatRecoveryCode(raw: string): string;
|
|
32
|
+
declare function generateRecoveryCode(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Accepts what a person actually types: any case, any separators, and the
|
|
35
|
+
* letters Crockford treats as digits. A code rejected for a typo that the
|
|
36
|
+
* alphabet was designed to absorb is a lost catalog.
|
|
37
|
+
*/
|
|
38
|
+
declare function normaliseRecoveryCode(input: string): string;
|
|
39
|
+
interface CreateKeyringOptions {
|
|
40
|
+
readonly kek: Uint8Array;
|
|
41
|
+
/** How many recovery codes to mint. Zero means the KEK is the only way back. */
|
|
42
|
+
readonly recoveryCodes?: number;
|
|
43
|
+
/** Injectable so a test can assert on fixed material. */
|
|
44
|
+
readonly dek?: Uint8Array;
|
|
45
|
+
readonly newId?: () => string;
|
|
46
|
+
readonly newCode?: () => string;
|
|
47
|
+
}
|
|
48
|
+
declare function createKeyring(options: CreateKeyringOptions): Keyring;
|
|
49
|
+
type Unlock = {
|
|
50
|
+
readonly kek: Uint8Array;
|
|
51
|
+
} | {
|
|
52
|
+
readonly recoveryCode: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Tries every wrap of the matching method. A recovery code is checked against
|
|
56
|
+
* all of them because the holder cannot know which wrap is theirs.
|
|
57
|
+
*/
|
|
58
|
+
declare function unlockDek(wraps: readonly DekWrap[], unlock: Unlock): Uint8Array;
|
|
59
|
+
/** Same DEK, a new wrap: adds a way back without re-encrypting any value. */
|
|
60
|
+
declare function addWrap(dek: Uint8Array, unlock: Unlock, wrapId: string): DekWrap;
|
|
61
|
+
/** Constant-time comparison, for callers verifying a DEK round trip. */
|
|
62
|
+
declare function sameKey(a: Uint8Array, b: Uint8Array): boolean;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* config(), shaped like dotenv's and resolving a store rather than a file. Fully
|
|
66
|
+
* synchronous: this is a side-effect import, so nothing here may await.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
type OnConflict = "ignore" | "warn" | "throw";
|
|
70
|
+
/**
|
|
71
|
+
* Node's BufferEncoding, restated. The published declarations must not need an
|
|
72
|
+
* ambient global a consumer may not have loaded.
|
|
73
|
+
*/
|
|
74
|
+
type Encoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "utf-16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
|
|
75
|
+
type Layer = "process" | "project" | "global" | "file";
|
|
76
|
+
interface Provenance {
|
|
77
|
+
readonly key: string;
|
|
78
|
+
readonly layer: Layer;
|
|
79
|
+
/** Alias for a catalog source, absolute path for a file. */
|
|
80
|
+
readonly from: string;
|
|
81
|
+
}
|
|
82
|
+
interface ConfigOptions {
|
|
83
|
+
readonly path?: string | readonly string[];
|
|
84
|
+
readonly encoding?: Encoding;
|
|
85
|
+
readonly debug?: boolean;
|
|
86
|
+
readonly override?: boolean;
|
|
87
|
+
readonly quiet?: boolean;
|
|
88
|
+
readonly processEnv?: Record<string, string | undefined>;
|
|
89
|
+
/** Source aliases to load, in precedence order. */
|
|
90
|
+
readonly aliases?: readonly string[];
|
|
91
|
+
readonly onConflict?: OnConflict;
|
|
92
|
+
/** Read the machine-wide layer. CI should turn this off. */
|
|
93
|
+
readonly global?: boolean;
|
|
94
|
+
readonly unlock?: Unlock;
|
|
95
|
+
readonly cwd?: string;
|
|
96
|
+
readonly home?: string;
|
|
97
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
98
|
+
}
|
|
99
|
+
interface ConfigResult {
|
|
100
|
+
readonly parsed?: Record<string, string>;
|
|
101
|
+
readonly error?: Error;
|
|
102
|
+
/** Where each key came from. `doctor` prints this; values are never in it. */
|
|
103
|
+
readonly provenance?: readonly Provenance[];
|
|
104
|
+
}
|
|
105
|
+
declare class ConflictError extends Error {
|
|
106
|
+
readonly key: string;
|
|
107
|
+
readonly first: Provenance;
|
|
108
|
+
readonly second: Provenance;
|
|
109
|
+
constructor(key: string, first: Provenance, second: Provenance);
|
|
110
|
+
}
|
|
111
|
+
declare class KekMissingError extends Error {
|
|
112
|
+
constructor();
|
|
113
|
+
}
|
|
114
|
+
declare function config(options?: ConfigOptions): ConfigResult;
|
|
115
|
+
|
|
116
|
+
export { type ConfigResult as C, type DekWrap as D, type Encoding as E, KekMissingError as K, type Layer as L, type OnConflict as O, type Provenance as P, RecoveryCodeError as R, type Unlock as U, type WrapMethod as W, type ConfigOptions as a, ConflictError as b, type CreateKeyringOptions as c, DEK_BYTES as d, type Keyring as e, KeyringLockedError as f, addWrap as g, config as h, createKeyring as i, formatRecoveryCode as j, generateRecoveryCode as k, normaliseRecoveryCode as n, sameKey as s, unlockDek as u };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key hierarchy. Values are sealed under a random DEK, and the DEK is wrapped
|
|
3
|
+
* once per way of getting it back: the KEK, and each recovery code. Losing one
|
|
4
|
+
* way costs nothing as long as another wrap survives.
|
|
5
|
+
*/
|
|
6
|
+
declare const DEK_BYTES = 32;
|
|
7
|
+
type WrapMethod = "kek" | "recovery";
|
|
8
|
+
interface DekWrap {
|
|
9
|
+
readonly wrapId: string;
|
|
10
|
+
readonly method: WrapMethod;
|
|
11
|
+
readonly salt: Uint8Array;
|
|
12
|
+
/** scrypt cost, stored so a future default cannot orphan an old wrap. */
|
|
13
|
+
readonly n: number;
|
|
14
|
+
readonly r: number;
|
|
15
|
+
readonly p: number;
|
|
16
|
+
readonly envelope: Uint8Array;
|
|
17
|
+
}
|
|
18
|
+
interface Keyring {
|
|
19
|
+
readonly dek: Uint8Array;
|
|
20
|
+
readonly wraps: readonly DekWrap[];
|
|
21
|
+
/** Shown once at creation. Never stored, never recoverable from the wraps. */
|
|
22
|
+
readonly recoveryCodes: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
declare class RecoveryCodeError extends Error {
|
|
25
|
+
constructor(message: string);
|
|
26
|
+
}
|
|
27
|
+
declare class KeyringLockedError extends Error {
|
|
28
|
+
readonly tried: number;
|
|
29
|
+
constructor(tried: number);
|
|
30
|
+
}
|
|
31
|
+
declare function formatRecoveryCode(raw: string): string;
|
|
32
|
+
declare function generateRecoveryCode(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Accepts what a person actually types: any case, any separators, and the
|
|
35
|
+
* letters Crockford treats as digits. A code rejected for a typo that the
|
|
36
|
+
* alphabet was designed to absorb is a lost catalog.
|
|
37
|
+
*/
|
|
38
|
+
declare function normaliseRecoveryCode(input: string): string;
|
|
39
|
+
interface CreateKeyringOptions {
|
|
40
|
+
readonly kek: Uint8Array;
|
|
41
|
+
/** How many recovery codes to mint. Zero means the KEK is the only way back. */
|
|
42
|
+
readonly recoveryCodes?: number;
|
|
43
|
+
/** Injectable so a test can assert on fixed material. */
|
|
44
|
+
readonly dek?: Uint8Array;
|
|
45
|
+
readonly newId?: () => string;
|
|
46
|
+
readonly newCode?: () => string;
|
|
47
|
+
}
|
|
48
|
+
declare function createKeyring(options: CreateKeyringOptions): Keyring;
|
|
49
|
+
type Unlock = {
|
|
50
|
+
readonly kek: Uint8Array;
|
|
51
|
+
} | {
|
|
52
|
+
readonly recoveryCode: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Tries every wrap of the matching method. A recovery code is checked against
|
|
56
|
+
* all of them because the holder cannot know which wrap is theirs.
|
|
57
|
+
*/
|
|
58
|
+
declare function unlockDek(wraps: readonly DekWrap[], unlock: Unlock): Uint8Array;
|
|
59
|
+
/** Same DEK, a new wrap: adds a way back without re-encrypting any value. */
|
|
60
|
+
declare function addWrap(dek: Uint8Array, unlock: Unlock, wrapId: string): DekWrap;
|
|
61
|
+
/** Constant-time comparison, for callers verifying a DEK round trip. */
|
|
62
|
+
declare function sameKey(a: Uint8Array, b: Uint8Array): boolean;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* config(), shaped like dotenv's and resolving a store rather than a file. Fully
|
|
66
|
+
* synchronous: this is a side-effect import, so nothing here may await.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
type OnConflict = "ignore" | "warn" | "throw";
|
|
70
|
+
/**
|
|
71
|
+
* Node's BufferEncoding, restated. The published declarations must not need an
|
|
72
|
+
* ambient global a consumer may not have loaded.
|
|
73
|
+
*/
|
|
74
|
+
type Encoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "utf-16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
|
|
75
|
+
type Layer = "process" | "project" | "global" | "file";
|
|
76
|
+
interface Provenance {
|
|
77
|
+
readonly key: string;
|
|
78
|
+
readonly layer: Layer;
|
|
79
|
+
/** Alias for a catalog source, absolute path for a file. */
|
|
80
|
+
readonly from: string;
|
|
81
|
+
}
|
|
82
|
+
interface ConfigOptions {
|
|
83
|
+
readonly path?: string | readonly string[];
|
|
84
|
+
readonly encoding?: Encoding;
|
|
85
|
+
readonly debug?: boolean;
|
|
86
|
+
readonly override?: boolean;
|
|
87
|
+
readonly quiet?: boolean;
|
|
88
|
+
readonly processEnv?: Record<string, string | undefined>;
|
|
89
|
+
/** Source aliases to load, in precedence order. */
|
|
90
|
+
readonly aliases?: readonly string[];
|
|
91
|
+
readonly onConflict?: OnConflict;
|
|
92
|
+
/** Read the machine-wide layer. CI should turn this off. */
|
|
93
|
+
readonly global?: boolean;
|
|
94
|
+
readonly unlock?: Unlock;
|
|
95
|
+
readonly cwd?: string;
|
|
96
|
+
readonly home?: string;
|
|
97
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
98
|
+
}
|
|
99
|
+
interface ConfigResult {
|
|
100
|
+
readonly parsed?: Record<string, string>;
|
|
101
|
+
readonly error?: Error;
|
|
102
|
+
/** Where each key came from. `doctor` prints this; values are never in it. */
|
|
103
|
+
readonly provenance?: readonly Provenance[];
|
|
104
|
+
}
|
|
105
|
+
declare class ConflictError extends Error {
|
|
106
|
+
readonly key: string;
|
|
107
|
+
readonly first: Provenance;
|
|
108
|
+
readonly second: Provenance;
|
|
109
|
+
constructor(key: string, first: Provenance, second: Provenance);
|
|
110
|
+
}
|
|
111
|
+
declare class KekMissingError extends Error {
|
|
112
|
+
constructor();
|
|
113
|
+
}
|
|
114
|
+
declare function config(options?: ConfigOptions): ConfigResult;
|
|
115
|
+
|
|
116
|
+
export { type ConfigResult as C, type DekWrap as D, type Encoding as E, KekMissingError as K, type Layer as L, type OnConflict as O, type Provenance as P, RecoveryCodeError as R, type Unlock as U, type WrapMethod as W, type ConfigOptions as a, ConflictError as b, type CreateKeyringOptions as c, DEK_BYTES as d, type Keyring as e, KeyringLockedError as f, addWrap as g, config as h, createKeyring as i, formatRecoveryCode as j, generateRecoveryCode as k, normaliseRecoveryCode as n, sameKey as s, unlockDek as u };
|