varlock 0.0.8 → 0.0.9
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/auto-load.js +5 -6
- package/dist/{chunk-SHQHITWV.js → chunk-2CM4YUFY.js} +49 -19
- package/dist/chunk-2CM4YUFY.js.map +1 -0
- package/dist/{chunk-BM3UAHAH.js → chunk-4CE75BSX.js} +5 -5
- package/dist/{chunk-BM3UAHAH.js.map → chunk-4CE75BSX.js.map} +1 -1
- package/dist/{chunk-H5PNRKYP.js → chunk-4WMY2EW3.js} +5 -5
- package/dist/{chunk-H5PNRKYP.js.map → chunk-4WMY2EW3.js.map} +1 -1
- package/dist/{chunk-7OHVYEDG.js → chunk-CYYLAV42.js} +3 -4
- package/dist/chunk-CYYLAV42.js.map +1 -0
- package/dist/{chunk-P74HB2II.js → chunk-ELJZUQX3.js} +4 -5
- package/dist/chunk-ELJZUQX3.js.map +1 -0
- package/dist/{chunk-5B7JZEDE.js → chunk-FLO6F7B6.js} +3 -4
- package/dist/chunk-FLO6F7B6.js.map +1 -0
- package/dist/{chunk-GYHC6Y7D.js → chunk-FYLMYWUF.js} +3 -3
- package/dist/{chunk-GYHC6Y7D.js.map → chunk-FYLMYWUF.js.map} +1 -1
- package/dist/{chunk-YK4SATSE.js → chunk-GWQT5VGW.js} +4 -4
- package/dist/{chunk-YK4SATSE.js.map → chunk-GWQT5VGW.js.map} +1 -1
- package/dist/{chunk-PQPGBNGV.js → chunk-KCX4NC7Q.js} +5 -5
- package/dist/{chunk-PQPGBNGV.js.map → chunk-KCX4NC7Q.js.map} +1 -1
- package/dist/{chunk-6FFRZOIK.js → chunk-LS6F7BSZ.js} +4 -4
- package/dist/{chunk-6FFRZOIK.js.map → chunk-LS6F7BSZ.js.map} +1 -1
- package/dist/{chunk-UFPWQAFZ.js → chunk-PB7RWVE6.js} +3 -3
- package/dist/chunk-PB7RWVE6.js.map +1 -0
- package/dist/chunk-WYJDUDC4.js +14 -0
- package/dist/{chunk-CQHOPN6M.js.map → chunk-WYJDUDC4.js.map} +1 -1
- package/dist/chunk-ZUG7BEY5.js +17 -0
- package/dist/chunk-ZUG7BEY5.js.map +1 -0
- package/dist/{chunk-Y2RFMQ5X.js → chunk-ZW2T4C6A.js} +83 -23
- package/dist/chunk-ZW2T4C6A.js.map +1 -0
- package/dist/cli/cli-executable.js +15 -15
- package/dist/cli/cli-executable.js.map +1 -1
- package/dist/dotenv-compat.js +5 -6
- package/dist/env-KH4bPru7.d.ts +356 -0
- package/dist/index.d.ts +14 -5
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/init.command-ZRQOE2OK.js +9 -0
- package/dist/{init.command-L4HF4372.js.map → init.command-ZRQOE2OK.js.map} +1 -1
- package/dist/load.command-YBN3BW6U.js +9 -0
- package/dist/{load.command-VHNPXTDI.js.map → load.command-YBN3BW6U.js.map} +1 -1
- package/dist/login.command-F5AWKZKA.js +8 -0
- package/dist/{login.command-OIQBNMNZ.js.map → login.command-F5AWKZKA.js.map} +1 -1
- package/dist/run.command-WWJ6ZE26.js +9 -0
- package/dist/{run.command-2OE432A5.js.map → run.command-WWJ6ZE26.js.map} +1 -1
- package/dist/runtime/env.d.ts +3 -1
- package/dist/runtime/env.js +1 -1
- package/dist/runtime/patch-console.js +2 -3
- package/dist/runtime/patch-response.js +2 -3
- package/dist/runtime/patch-server-response.js +2 -3
- package/dist/telemetry.command-IS2JLIZM.js +8 -0
- package/dist/{telemetry.command-MYQU7FPB.js.map → telemetry.command-IS2JLIZM.js.map} +1 -1
- package/package.json +1 -2
- package/dist/chunk-5B7JZEDE.js.map +0 -1
- package/dist/chunk-7OHVYEDG.js.map +0 -1
- package/dist/chunk-CQHOPN6M.js +0 -14
- package/dist/chunk-LZ45SLAI.js +0 -12
- package/dist/chunk-LZ45SLAI.js.map +0 -1
- package/dist/chunk-MPS3IXAW.js +0 -70
- package/dist/chunk-MPS3IXAW.js.map +0 -1
- package/dist/chunk-P74HB2II.js.map +0 -1
- package/dist/chunk-SHQHITWV.js.map +0 -1
- package/dist/chunk-UFPWQAFZ.js.map +0 -1
- package/dist/chunk-Y2RFMQ5X.js.map +0 -1
- package/dist/env-k8iRuXIH.d.ts +0 -42
- package/dist/init.command-L4HF4372.js +0 -9
- package/dist/load.command-VHNPXTDI.js +0 -9
- package/dist/login.command-OIQBNMNZ.js +0 -8
- package/dist/run.command-2OE432A5.js +0 -9
- package/dist/telemetry.command-MYQU7FPB.js +0 -8
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { ParsedEnvSpecDecorator, ParsedEnvSpecFile, ParsedEnvSpecStaticValue, ParsedEnvSpecFunctionCall } from '@env-spec/parser';
|
|
2
|
+
import { FallbackIfUnknown } from '@env-spec/utils/type-utils';
|
|
3
|
+
|
|
4
|
+
declare class VarlockError extends Error {
|
|
5
|
+
readonly more?: {
|
|
6
|
+
tip?: string | Array<string>;
|
|
7
|
+
err?: Error;
|
|
8
|
+
isWarning?: boolean;
|
|
9
|
+
/** machine-friendly error code if needed for anything else */
|
|
10
|
+
code?: string;
|
|
11
|
+
/** free-form additional metadata */
|
|
12
|
+
extraMetadata?: Record<string, any>;
|
|
13
|
+
} | undefined;
|
|
14
|
+
originalError?: Error;
|
|
15
|
+
get isUnexpected(): boolean;
|
|
16
|
+
get type(): string;
|
|
17
|
+
static defaultIcon: string;
|
|
18
|
+
icon: string;
|
|
19
|
+
_isWarning: boolean;
|
|
20
|
+
constructor(errOrMessage: string | Error, more?: {
|
|
21
|
+
tip?: string | Array<string>;
|
|
22
|
+
err?: Error;
|
|
23
|
+
isWarning?: boolean;
|
|
24
|
+
/** machine-friendly error code if needed for anything else */
|
|
25
|
+
code?: string;
|
|
26
|
+
/** free-form additional metadata */
|
|
27
|
+
extraMetadata?: Record<string, any>;
|
|
28
|
+
} | undefined);
|
|
29
|
+
get tip(): string | undefined;
|
|
30
|
+
get code(): string | undefined;
|
|
31
|
+
get extraMetadata(): Record<string, any> | undefined;
|
|
32
|
+
set isWarning(w: boolean);
|
|
33
|
+
get isWarning(): boolean;
|
|
34
|
+
toJSON(): {
|
|
35
|
+
isWarning?: true | undefined;
|
|
36
|
+
tip?: string | undefined;
|
|
37
|
+
icon: string;
|
|
38
|
+
type: string;
|
|
39
|
+
name: string;
|
|
40
|
+
message: string;
|
|
41
|
+
isUnexpected: boolean;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
declare class ConfigLoadError extends VarlockError {
|
|
45
|
+
readonly cleanedStack: Array<string>;
|
|
46
|
+
constructor(err: Error);
|
|
47
|
+
toJSON(): {
|
|
48
|
+
cleanedStack: string[];
|
|
49
|
+
isWarning?: true | undefined;
|
|
50
|
+
tip?: string | undefined;
|
|
51
|
+
icon: string;
|
|
52
|
+
type: string;
|
|
53
|
+
name: string;
|
|
54
|
+
message: string;
|
|
55
|
+
isUnexpected: boolean;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
declare class SchemaError extends VarlockError {
|
|
59
|
+
static defaultIcon: string;
|
|
60
|
+
}
|
|
61
|
+
declare class ValidationError extends VarlockError {
|
|
62
|
+
static defaultIcon: string;
|
|
63
|
+
}
|
|
64
|
+
declare class CoercionError extends VarlockError {
|
|
65
|
+
static defaultIcon: string;
|
|
66
|
+
}
|
|
67
|
+
declare class ResolutionError extends VarlockError {
|
|
68
|
+
static defaultIcon: string;
|
|
69
|
+
protected _retryable?: boolean;
|
|
70
|
+
set retryable(val: boolean);
|
|
71
|
+
get retryable(): boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type EnvGraphDataTypeDef<CoerceReturnType, ValidateInputType = FallbackIfUnknown<CoerceReturnType, string>> = {
|
|
75
|
+
/** this will be the name of the type, used to reference it when using it in a schema */
|
|
76
|
+
name: string;
|
|
77
|
+
/** optional description of the type itself */
|
|
78
|
+
typeDescription?: string;
|
|
79
|
+
/** icon see https://icones.js.org for available options
|
|
80
|
+
* @example mdi:aws
|
|
81
|
+
* */
|
|
82
|
+
icon?: string;
|
|
83
|
+
/** coerce function - should take in any value and return a value of the correct type if possible */
|
|
84
|
+
coerce?: (value: any) => CoerceReturnType | CoercionError | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* validate function - we can assume that coercion has already succeded, or this will not be called
|
|
87
|
+
* - if validation passes, should return true
|
|
88
|
+
* - if validation fails, should return a ValidationError or array of errors - or throw an error
|
|
89
|
+
* */
|
|
90
|
+
validate: (value: ValidateInputType) => (true | undefined | void | Error | Array<Error>);
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* holds a specific instance of a data type, along with specific settings which affect validation/coercion etc
|
|
94
|
+
*/
|
|
95
|
+
declare class EnvGraphDataType {
|
|
96
|
+
private def;
|
|
97
|
+
/** reference back to the factory function, which we can use like a constructor to check the type of the instance */
|
|
98
|
+
private factory;
|
|
99
|
+
constructor(def: EnvGraphDataTypeDef<any, any>,
|
|
100
|
+
/** reference back to the factory function, which we can use like a constructor to check the type of the instance */
|
|
101
|
+
factory: any);
|
|
102
|
+
get name(): string;
|
|
103
|
+
get icon(): string | undefined;
|
|
104
|
+
/** @internal */
|
|
105
|
+
get _rawDef(): EnvGraphDataTypeDef<any, any>;
|
|
106
|
+
coerce(val: any): any;
|
|
107
|
+
validate(val: any): true | void | Error | Error[];
|
|
108
|
+
}
|
|
109
|
+
declare function createEnvGraphDataType<TsType, InstanceSettingsArgs extends Array<any>>(dataTypeDef: EnvGraphDataTypeDef<TsType> | ((...args: InstanceSettingsArgs) => EnvGraphDataTypeDef<TsType>)): {
|
|
110
|
+
(...usageOpts: InstanceSettingsArgs): EnvGraphDataType;
|
|
111
|
+
_isEnvGraphDataTypeFactory: boolean;
|
|
112
|
+
dataTypeName: string;
|
|
113
|
+
};
|
|
114
|
+
type EnvGraphDataTypeFactory = ReturnType<typeof createEnvGraphDataType>;
|
|
115
|
+
|
|
116
|
+
declare const DATA_SOURCE_TYPES: Readonly<{
|
|
117
|
+
schema: {
|
|
118
|
+
fileSuffixes: string[];
|
|
119
|
+
precedence: number;
|
|
120
|
+
};
|
|
121
|
+
example: {
|
|
122
|
+
fileSuffixes: string[];
|
|
123
|
+
precedence: number;
|
|
124
|
+
};
|
|
125
|
+
defaults: {
|
|
126
|
+
fileSuffixes: string[];
|
|
127
|
+
precedence: number;
|
|
128
|
+
};
|
|
129
|
+
values: {
|
|
130
|
+
fileSuffixes: Array<string>;
|
|
131
|
+
precedence: number;
|
|
132
|
+
};
|
|
133
|
+
overrides: {
|
|
134
|
+
fileSuffixes: string[];
|
|
135
|
+
precedence: number;
|
|
136
|
+
};
|
|
137
|
+
}>;
|
|
138
|
+
type DataSourceType = keyof typeof DATA_SOURCE_TYPES;
|
|
139
|
+
declare abstract class EnvGraphDataSource {
|
|
140
|
+
static DATA_SOURCE_TYPES: Readonly<{
|
|
141
|
+
schema: {
|
|
142
|
+
fileSuffixes: string[];
|
|
143
|
+
precedence: number;
|
|
144
|
+
};
|
|
145
|
+
example: {
|
|
146
|
+
fileSuffixes: string[];
|
|
147
|
+
precedence: number;
|
|
148
|
+
};
|
|
149
|
+
defaults: {
|
|
150
|
+
fileSuffixes: string[];
|
|
151
|
+
precedence: number;
|
|
152
|
+
};
|
|
153
|
+
values: {
|
|
154
|
+
fileSuffixes: Array<string>;
|
|
155
|
+
precedence: number;
|
|
156
|
+
};
|
|
157
|
+
overrides: {
|
|
158
|
+
fileSuffixes: string[];
|
|
159
|
+
precedence: number;
|
|
160
|
+
};
|
|
161
|
+
}>;
|
|
162
|
+
graph?: EnvGraph;
|
|
163
|
+
abstract typeLabel: string;
|
|
164
|
+
type: DataSourceType;
|
|
165
|
+
applyForEnv?: string;
|
|
166
|
+
disabled?: boolean;
|
|
167
|
+
ignoreNewDefs: boolean;
|
|
168
|
+
abstract get label(): string;
|
|
169
|
+
/** an error encountered while loading/parsing the data source */
|
|
170
|
+
loadingError?: Error;
|
|
171
|
+
get isValid(): boolean;
|
|
172
|
+
configItemDefs: Record<string, ConfigItemDef>;
|
|
173
|
+
decorators: Record<string, ParsedEnvSpecDecorator>;
|
|
174
|
+
getStaticValues(): Record<string, string>;
|
|
175
|
+
}
|
|
176
|
+
declare class ProcessEnvDataSource extends EnvGraphDataSource {
|
|
177
|
+
type: "overrides";
|
|
178
|
+
typeLabel: string;
|
|
179
|
+
label: string;
|
|
180
|
+
ignoreNewDefs: boolean;
|
|
181
|
+
static processEnvValues: Record<string, string | undefined> | undefined;
|
|
182
|
+
constructor();
|
|
183
|
+
}
|
|
184
|
+
declare abstract class FileBasedDataSource extends EnvGraphDataSource {
|
|
185
|
+
isGitIgnored?: boolean;
|
|
186
|
+
fullPath: string;
|
|
187
|
+
fileName: string;
|
|
188
|
+
rawContents?: string;
|
|
189
|
+
get typeLabel(): string;
|
|
190
|
+
get label(): string;
|
|
191
|
+
static format: string;
|
|
192
|
+
static validFileExtensions: Array<string>;
|
|
193
|
+
get validFileExtensions(): string[];
|
|
194
|
+
constructor(fullPath: string, opts?: {
|
|
195
|
+
overrideContents?: string;
|
|
196
|
+
overrideGitIgnored?: boolean;
|
|
197
|
+
});
|
|
198
|
+
finishInit(): Promise<void>;
|
|
199
|
+
abstract _parseContents(): Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
declare class DotEnvFileDataSource extends FileBasedDataSource {
|
|
202
|
+
static format: string;
|
|
203
|
+
static validFileExtensions: never[];
|
|
204
|
+
parsedFile?: ParsedEnvSpecFile;
|
|
205
|
+
private convertParserValueToResolvers;
|
|
206
|
+
_parseContents(): Promise<void>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
type ResolvedValue = undefined | string | number | boolean | RegExp;
|
|
210
|
+
type ResolverFunctionArgs = Array<Resolver | Record<string, Resolver>>;
|
|
211
|
+
declare abstract class Resolver {
|
|
212
|
+
readonly fnArgs: ResolverFunctionArgs;
|
|
213
|
+
static fnName?: string;
|
|
214
|
+
constructor(fnArgs: ResolverFunctionArgs);
|
|
215
|
+
abstract label: string;
|
|
216
|
+
abstract icon: string;
|
|
217
|
+
inferredType?: string;
|
|
218
|
+
_schemaErrors: Array<SchemaError>;
|
|
219
|
+
private _depsObj;
|
|
220
|
+
get childResolvers(): Array<Resolver>;
|
|
221
|
+
get schemaErrors(): Array<SchemaError>;
|
|
222
|
+
get depsObj(): Record<string, boolean>;
|
|
223
|
+
get deps(): string[];
|
|
224
|
+
protected abstract _process(ctx?: any): Promise<void | (() => void)>;
|
|
225
|
+
private configItem?;
|
|
226
|
+
process(configItem: ConfigItem): Promise<void>;
|
|
227
|
+
protected addDep(key: string): void;
|
|
228
|
+
protected abstract _resolve(): Promise<ResolvedValue>;
|
|
229
|
+
resolve(): Promise<ResolvedValue>;
|
|
230
|
+
protected getDepValue(key: string): ResolvedValue;
|
|
231
|
+
}
|
|
232
|
+
type ResolverChildClass<ChildClass extends Resolver = Resolver> = ({
|
|
233
|
+
new (...args: Array<any>): ChildClass;
|
|
234
|
+
} & typeof Resolver);
|
|
235
|
+
|
|
236
|
+
type ConfigItemDef = {
|
|
237
|
+
description?: string;
|
|
238
|
+
resolver?: Resolver;
|
|
239
|
+
decorators?: Record<string, ParsedEnvSpecDecorator>;
|
|
240
|
+
};
|
|
241
|
+
type ConfigItemDefAndSource = {
|
|
242
|
+
itemDef: ConfigItemDef;
|
|
243
|
+
source: EnvGraphDataSource;
|
|
244
|
+
};
|
|
245
|
+
declare class ConfigItem {
|
|
246
|
+
#private;
|
|
247
|
+
constructor(_envGraph: EnvGraph, _key: string);
|
|
248
|
+
get envGraph(): EnvGraph;
|
|
249
|
+
get key(): string;
|
|
250
|
+
defs: Array<ConfigItemDefAndSource>;
|
|
251
|
+
addDef(itemDef: ConfigItemDef, source: EnvGraphDataSource): void;
|
|
252
|
+
get description(): string | undefined;
|
|
253
|
+
get icon(): string | undefined;
|
|
254
|
+
get docsLinks(): {
|
|
255
|
+
url: string;
|
|
256
|
+
description?: string;
|
|
257
|
+
}[];
|
|
258
|
+
get valueResolver(): Resolver | undefined;
|
|
259
|
+
getDecorator(decoratorName: string): ParsedEnvSpecDecorator | undefined;
|
|
260
|
+
getDecoratorValueRaw(decoratorName: string): ParsedEnvSpecStaticValue | ParsedEnvSpecFunctionCall | undefined;
|
|
261
|
+
getDecoratorValueString(decoratorName: string): string | undefined;
|
|
262
|
+
dataType?: EnvGraphDataType;
|
|
263
|
+
schemaErrors: Array<SchemaError>;
|
|
264
|
+
get resolverSchemaErrors(): SchemaError[];
|
|
265
|
+
process(): Promise<void>;
|
|
266
|
+
get isRequired(): any;
|
|
267
|
+
get isSensitive(): any;
|
|
268
|
+
get errors(): (SchemaError | ValidationError | CoercionError | ResolutionError)[];
|
|
269
|
+
get validationState(): 'warn' | 'error' | 'valid';
|
|
270
|
+
/** resolved value _before coercion_ */
|
|
271
|
+
resolvedRawValue?: ResolvedValue;
|
|
272
|
+
isResolved: boolean;
|
|
273
|
+
/** resolved value after coercion */
|
|
274
|
+
resolvedValue?: ResolvedValue;
|
|
275
|
+
isValidated: boolean;
|
|
276
|
+
resolutionError?: ResolutionError;
|
|
277
|
+
coercionError?: CoercionError;
|
|
278
|
+
validationErrors?: Array<ValidationError>;
|
|
279
|
+
get isCoerced(): boolean;
|
|
280
|
+
resolve(): Promise<void>;
|
|
281
|
+
get isValid(): boolean;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
type GraphNodeId = string;
|
|
285
|
+
type GraphAdjacencyList = Record<GraphNodeId, Array<GraphNodeId>>;
|
|
286
|
+
|
|
287
|
+
type SerializedEnvGraph = {
|
|
288
|
+
basePath?: string;
|
|
289
|
+
sources: Array<{
|
|
290
|
+
label: string;
|
|
291
|
+
enabled: boolean;
|
|
292
|
+
path?: string;
|
|
293
|
+
}>;
|
|
294
|
+
settings: {
|
|
295
|
+
redactLogs?: boolean;
|
|
296
|
+
preventLeaks?: boolean;
|
|
297
|
+
};
|
|
298
|
+
config: Record<string, {
|
|
299
|
+
value: any;
|
|
300
|
+
isSensitive: boolean;
|
|
301
|
+
}>;
|
|
302
|
+
};
|
|
303
|
+
/** container of the overall graph and current resolution attempt / values */
|
|
304
|
+
declare class EnvGraph {
|
|
305
|
+
basePath?: string;
|
|
306
|
+
/** array of data sources */
|
|
307
|
+
dataSources: Array<EnvGraphDataSource>;
|
|
308
|
+
finalOverridesDataSource?: EnvGraphDataSource;
|
|
309
|
+
/** config item key of env flag (toggles env-specific data sources enabled) */
|
|
310
|
+
envFlagKey?: string;
|
|
311
|
+
/** current value of the environment flag */
|
|
312
|
+
envFlagValue?: string;
|
|
313
|
+
configSchema: Record<string, ConfigItem>;
|
|
314
|
+
addDataSource(dataSource: EnvGraphDataSource): void;
|
|
315
|
+
get schemaDataSource(): EnvGraphDataSource | undefined;
|
|
316
|
+
get sortedDataSources(): EnvGraphDataSource[];
|
|
317
|
+
registeredResolverFunctions: Record<string, ResolverChildClass>;
|
|
318
|
+
registerResolver(resolverClass: ResolverChildClass): void;
|
|
319
|
+
dataTypesRegistry: Record<string, EnvGraphDataTypeFactory>;
|
|
320
|
+
registerDataType(factory: EnvGraphDataTypeFactory): void;
|
|
321
|
+
constructor();
|
|
322
|
+
finishLoad(): Promise<void>;
|
|
323
|
+
get graphAdjacencyList(): GraphAdjacencyList;
|
|
324
|
+
resolveEnvValues(): Promise<void>;
|
|
325
|
+
getResolvedEnvObject(): Record<string, any>;
|
|
326
|
+
getSerializedGraph(): SerializedEnvGraph;
|
|
327
|
+
get isInvalid(): boolean;
|
|
328
|
+
generateTypes(lang: string, outputPath: string): Promise<void>;
|
|
329
|
+
getRootDecoratorValue(decoratorName: string): any;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
declare function resetRedactionMap(graph: SerializedEnvGraph): void;
|
|
333
|
+
/**
|
|
334
|
+
* Redacts senstive config values from any string/array/object/etc
|
|
335
|
+
*
|
|
336
|
+
* NOTE - must be used only after varlock has loaded config
|
|
337
|
+
* */
|
|
338
|
+
declare function redactSensitiveConfig(o: any): any;
|
|
339
|
+
/**
|
|
340
|
+
* utility to unmask a secret/sensitive value when logging to the console
|
|
341
|
+
* currently this only works on a single secret, not objects or aggregated strings
|
|
342
|
+
* */
|
|
343
|
+
declare function revealSensitiveConfig(secretStr: string): string;
|
|
344
|
+
declare function scanForLeaks(toScan: string | ReadableStream | null, meta?: {
|
|
345
|
+
method?: string;
|
|
346
|
+
file?: string;
|
|
347
|
+
}): string | ReadableStream<any> | null;
|
|
348
|
+
declare const varlockSettings: Record<string, any>;
|
|
349
|
+
declare function initVarlockEnv(opts?: {
|
|
350
|
+
allowFail?: boolean;
|
|
351
|
+
}): void;
|
|
352
|
+
interface TypedEnvSchema {
|
|
353
|
+
}
|
|
354
|
+
declare const ENV: TypedEnvSchema;
|
|
355
|
+
|
|
356
|
+
export { ConfigLoadError as C, DotEnvFileDataSource as D, EnvGraph as E, ProcessEnvDataSource as P, ResolutionError as R, SchemaError as S, type TypedEnvSchema as T, ValidationError as V, CoercionError as a, type SerializedEnvGraph as b, ENV as c, redactSensitiveConfig as d, revealSensitiveConfig as e, initVarlockEnv as i, resetRedactionMap as r, scanForLeaks as s, varlockSettings as v };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { i as initVarlockEnv } from './env-
|
|
2
|
-
export {
|
|
3
|
-
import * as _env_spec_env_graph from '@env-spec/env-graph';
|
|
4
|
-
import { EnvGraph, DotEnvFileDataSource, ProcessEnvDataSource, loadEnvGraph, ConfigLoadError, SchemaError, ValidationError, CoercionError, ResolutionError } from '@env-spec/env-graph';
|
|
1
|
+
import { E as EnvGraph, D as DotEnvFileDataSource, P as ProcessEnvDataSource, C as ConfigLoadError, S as SchemaError, V as ValidationError, a as CoercionError, R as ResolutionError, i as initVarlockEnv } from './env-KH4bPru7.js';
|
|
2
|
+
export { c as ENV, b as SerializedEnvGraph } from './env-KH4bPru7.js';
|
|
5
3
|
export { patchGlobalConsole } from './runtime/patch-console.js';
|
|
6
4
|
export { patchGlobalServerResponse } from './runtime/patch-server-response.js';
|
|
7
5
|
export { patchGlobalResponse } from './runtime/patch-response.js';
|
|
6
|
+
import '@env-spec/parser';
|
|
7
|
+
import '@env-spec/utils/type-utils';
|
|
8
|
+
|
|
9
|
+
declare function loadEnvGraph(opts?: {
|
|
10
|
+
basePath?: string;
|
|
11
|
+
relativePaths?: Array<string>;
|
|
12
|
+
checkGitIgnored?: boolean;
|
|
13
|
+
excludeDirs?: Array<string>;
|
|
14
|
+
currentEnvFallback?: string;
|
|
15
|
+
afterInit?: (graph: EnvGraph) => Promise<void>;
|
|
16
|
+
}): Promise<EnvGraph>;
|
|
8
17
|
|
|
9
18
|
declare function checkForConfigErrors(envGraph: EnvGraph, opts?: {
|
|
10
19
|
showAll?: boolean;
|
|
@@ -12,7 +21,7 @@ declare function checkForConfigErrors(envGraph: EnvGraph, opts?: {
|
|
|
12
21
|
|
|
13
22
|
declare function loadVarlockEnvGraph(opts?: {
|
|
14
23
|
currentEnvFallback?: string;
|
|
15
|
-
}): Promise<
|
|
24
|
+
}): Promise<EnvGraph>;
|
|
16
25
|
|
|
17
26
|
declare function load(): Promise<void>;
|
|
18
27
|
declare function getBuildTimeReplacements(opts?: {
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { checkForConfigErrors } from './chunk-
|
|
2
|
-
import { loadVarlockEnvGraph
|
|
3
|
-
import { ResolutionError, CoercionError, ValidationError, SchemaError, ConfigLoadError, ProcessEnvDataSource, DotEnvFileDataSource, EnvGraph } from './chunk-
|
|
4
|
-
export { patchGlobalConsole } from './chunk-
|
|
5
|
-
export { patchGlobalResponse } from './chunk-
|
|
6
|
-
export { patchGlobalServerResponse } from './chunk-
|
|
7
|
-
import './chunk-
|
|
8
|
-
|
|
9
|
-
export { ENV } from './chunk-SHQHITWV.js';
|
|
1
|
+
import { checkForConfigErrors } from './chunk-PB7RWVE6.js';
|
|
2
|
+
import { loadVarlockEnvGraph } from './chunk-ZUG7BEY5.js';
|
|
3
|
+
import { ResolutionError, CoercionError, ValidationError, SchemaError, ConfigLoadError, loadEnvGraph, ProcessEnvDataSource, DotEnvFileDataSource, EnvGraph } from './chunk-ZW2T4C6A.js';
|
|
4
|
+
export { patchGlobalConsole } from './chunk-CYYLAV42.js';
|
|
5
|
+
export { patchGlobalResponse } from './chunk-ELJZUQX3.js';
|
|
6
|
+
export { patchGlobalServerResponse } from './chunk-FLO6F7B6.js';
|
|
7
|
+
import { initVarlockEnv } from './chunk-2CM4YUFY.js';
|
|
8
|
+
export { ENV } from './chunk-2CM4YUFY.js';
|
|
10
9
|
import './chunk-FGMXIEFA.js';
|
|
11
10
|
import { __name } from './chunk-XN24GZXQ.js';
|
|
12
11
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAkBA,eAAsB,IAAA,GAAO;AAE3B,EAAA,MAAM,QAAA,GAAW,MAAM,mBAAA,EAAoB;AAC3C,EAAA,MAAM,SAAS,gBAAA,EAAiB;AAChC,EAAA,oBAAA,CAAqB,QAAQ,CAAA;AAG7B,EAAA,OAAA,CAAQ,IAAI,aAAA,GAAgB,IAAA,CAAK,SAAA,CAAU,QAAA,CAAS,oBAAoB,CAAA;AACxE,EAAA,cAAA,EAAe;AAEjB;AAVsB,MAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AAaf,SAAS,yBAAyB,IAAA,EAGtC;AACD,EAAA,IAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,aAAA,SAAsB,EAAC;AACxC,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,OAAA,CAAQ,IAAI,aAAa,CAAA;AACpD,EAAA,MAAM,eAAe,EAAC;AACtB,EAAA,KAAA,MAAW,GAAA,IAAO,QAAQ,MAAA,EAAQ;AAChC,IAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAA;AACnC,IAAA,MAAM,WAAA,GAAc,CAAC,QAAA,CAAS,WAAA,IAAe,IAAA,EAAM,gBAAA;AACnD,IAAA,IAAI,CAAC,WAAA,EAAa;AAClB,IAAA,YAAA,CAAa,CAAA,EAAG,IAAA,EAAM,SAAA,IAAa,KAAK,IAAI,GAAG,CAAA,CAAE,CAAA,GAAI,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,MAAA,CAAO,GAAG,EAAE,KAAK,CAAA;AAAA,EAC/F;AACA,EAAA,OAAO,YAAA;AACT;AAdgB,MAAA,CAAA,wBAAA,EAAA,0BAAA,CAAA;AAiBT,IAAM,QAAA,GAAW;AAAA;AAAA,EAEtB,QAAA;AAAA,EACA,oBAAA;AAAA,EACA,oBAAA;AAAA;AAAA,EAGA,YAAA;AAAA;AAAA,EAGA,eAAA;AAAA,EACA,WAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA;AAAA,EAGA,mBAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["import { checkForConfigErrors } from './cli/helpers/error-checks';\nimport { loadVarlockEnvGraph } from './lib/load-graph';\nimport { initVarlockEnv } from './runtime/env';\n\n// Import env-graph components for internal API\nimport {\n EnvGraph,\n loadEnvGraph,\n DotEnvFileDataSource,\n ProcessEnvDataSource,\n ConfigLoadError,\n SchemaError,\n ValidationError,\n CoercionError,\n ResolutionError,\n type SerializedEnvGraph,\n} from '../env-graph';\n\nexport async function load() {\n // TODO: add some options\n const envGraph = await loadVarlockEnvGraph();\n await envGraph.resolveEnvValues();\n checkForConfigErrors(envGraph);\n\n // loadFromSerializedGraph(envGraph.getSerializedGraph());\n process.env.__VARLOCK_ENV = JSON.stringify(envGraph.getSerializedGraph());\n initVarlockEnv();\n // TODO: return resolved env and schema / meta info\n}\n\n\nexport function getBuildTimeReplacements(opts?: {\n objectKey?: string,\n includeSensitive?: boolean,\n}) {\n if (!process.env.__VARLOCK_ENV) return {};\n const envInfo = JSON.parse(process.env.__VARLOCK_ENV) as SerializedEnvGraph;\n const replacements = {} as Record<string, string>;\n for (const key in envInfo.config) {\n const itemInfo = envInfo.config[key];\n const replaceItem = !itemInfo.isSensitive || opts?.includeSensitive;\n if (!replaceItem) continue;\n replacements[`${opts?.objectKey || 'ENV'}.${key}`] = JSON.stringify(envInfo.config[key].value);\n }\n return replacements;\n}\n\n// Internal API for direct env graph manipulation\nexport const internal = {\n // Core classes\n EnvGraph,\n DotEnvFileDataSource,\n ProcessEnvDataSource,\n\n // Loader function\n loadEnvGraph,\n\n // Error classes\n ConfigLoadError,\n SchemaError,\n ValidationError,\n CoercionError,\n ResolutionError,\n\n // Varlock-specific utilities\n loadVarlockEnvGraph,\n checkForConfigErrors,\n initVarlockEnv,\n};\n\nexport { patchGlobalConsole } from './runtime/patch-console';\nexport { patchGlobalServerResponse } from './runtime/patch-server-response';\nexport { patchGlobalResponse } from './runtime/patch-response';\nexport { ENV } from './runtime/env';\nexport type { SerializedEnvGraph };\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { commandFn, commandSpec } from './chunk-4WMY2EW3.js';
|
|
2
|
+
import './chunk-FYLMYWUF.js';
|
|
3
|
+
import './chunk-33ROL4J5.js';
|
|
4
|
+
import './chunk-ZUG7BEY5.js';
|
|
5
|
+
import './chunk-ZW2T4C6A.js';
|
|
6
|
+
import './chunk-FGMXIEFA.js';
|
|
7
|
+
import './chunk-XN24GZXQ.js';
|
|
8
|
+
//# sourceMappingURL=init.command-ZRQOE2OK.js.map
|
|
9
|
+
//# sourceMappingURL=init.command-ZRQOE2OK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"init.command-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"init.command-ZRQOE2OK.js"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { commandFn, commandSpec } from './chunk-4CE75BSX.js';
|
|
2
|
+
import './chunk-33ROL4J5.js';
|
|
3
|
+
import './chunk-PB7RWVE6.js';
|
|
4
|
+
import './chunk-ZUG7BEY5.js';
|
|
5
|
+
import './chunk-ZW2T4C6A.js';
|
|
6
|
+
import './chunk-FGMXIEFA.js';
|
|
7
|
+
import './chunk-XN24GZXQ.js';
|
|
8
|
+
//# sourceMappingURL=load.command-YBN3BW6U.js.map
|
|
9
|
+
//# sourceMappingURL=load.command-YBN3BW6U.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"load.command-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"load.command-YBN3BW6U.js"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { commandFn, commandSpec } from './chunk-GWQT5VGW.js';
|
|
2
|
+
import './chunk-FYLMYWUF.js';
|
|
3
|
+
import './chunk-33ROL4J5.js';
|
|
4
|
+
import './chunk-ZW2T4C6A.js';
|
|
5
|
+
import './chunk-FGMXIEFA.js';
|
|
6
|
+
import './chunk-XN24GZXQ.js';
|
|
7
|
+
//# sourceMappingURL=login.command-F5AWKZKA.js.map
|
|
8
|
+
//# sourceMappingURL=login.command-F5AWKZKA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"login.command-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"login.command-F5AWKZKA.js"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { commandFn, commandSpec } from './chunk-KCX4NC7Q.js';
|
|
2
|
+
import './chunk-33ROL4J5.js';
|
|
3
|
+
import './chunk-PB7RWVE6.js';
|
|
4
|
+
import './chunk-ZUG7BEY5.js';
|
|
5
|
+
import './chunk-ZW2T4C6A.js';
|
|
6
|
+
import './chunk-FGMXIEFA.js';
|
|
7
|
+
import './chunk-XN24GZXQ.js';
|
|
8
|
+
//# sourceMappingURL=run.command-WWJ6ZE26.js.map
|
|
9
|
+
//# sourceMappingURL=run.command-WWJ6ZE26.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"run.command-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"run.command-WWJ6ZE26.js"}
|
package/dist/runtime/env.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { c as ENV, T as TypedEnvSchema, i as initVarlockEnv, d as redactSensitiveConfig, r as resetRedactionMap, e as revealSensitiveConfig, s as scanForLeaks, v as varlockSettings } from '../env-KH4bPru7.js';
|
|
2
|
+
import '@env-spec/parser';
|
|
3
|
+
import '@env-spec/utils/type-utils';
|
package/dist/runtime/env.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ENV, initVarlockEnv, redactSensitiveConfig, resetRedactionMap, revealSensitiveConfig, scanForLeaks, varlockSettings } from '../chunk-
|
|
1
|
+
export { ENV, initVarlockEnv, redactSensitiveConfig, resetRedactionMap, revealSensitiveConfig, scanForLeaks, varlockSettings } from '../chunk-2CM4YUFY.js';
|
|
2
2
|
import '../chunk-FGMXIEFA.js';
|
|
3
3
|
import '../chunk-XN24GZXQ.js';
|
|
4
4
|
//# sourceMappingURL=env.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { patchGlobalConsole, unpatchGlobalConsole } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-SHQHITWV.js';
|
|
1
|
+
export { patchGlobalConsole, unpatchGlobalConsole } from '../chunk-CYYLAV42.js';
|
|
2
|
+
import '../chunk-2CM4YUFY.js';
|
|
4
3
|
import '../chunk-FGMXIEFA.js';
|
|
5
4
|
import '../chunk-XN24GZXQ.js';
|
|
6
5
|
//# sourceMappingURL=patch-console.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { patchGlobalResponse } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-SHQHITWV.js';
|
|
1
|
+
export { patchGlobalResponse } from '../chunk-ELJZUQX3.js';
|
|
2
|
+
import '../chunk-2CM4YUFY.js';
|
|
4
3
|
import '../chunk-FGMXIEFA.js';
|
|
5
4
|
import '../chunk-XN24GZXQ.js';
|
|
6
5
|
//# sourceMappingURL=patch-response.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { patchGlobalServerResponse } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-SHQHITWV.js';
|
|
1
|
+
export { patchGlobalServerResponse } from '../chunk-FLO6F7B6.js';
|
|
2
|
+
import '../chunk-2CM4YUFY.js';
|
|
4
3
|
import '../chunk-FGMXIEFA.js';
|
|
5
4
|
import '../chunk-XN24GZXQ.js';
|
|
6
5
|
//# sourceMappingURL=patch-server-response.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { commandFn, commandSpec } from './chunk-LS6F7BSZ.js';
|
|
2
|
+
import './chunk-FYLMYWUF.js';
|
|
3
|
+
import './chunk-33ROL4J5.js';
|
|
4
|
+
import './chunk-ZW2T4C6A.js';
|
|
5
|
+
import './chunk-FGMXIEFA.js';
|
|
6
|
+
import './chunk-XN24GZXQ.js';
|
|
7
|
+
//# sourceMappingURL=telemetry.command-IS2JLIZM.js.map
|
|
8
|
+
//# sourceMappingURL=telemetry.command-IS2JLIZM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"telemetry.command-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"telemetry.command-IS2JLIZM.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "varlock",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -89,7 +89,6 @@
|
|
|
89
89
|
"outdent": "^0.8.0",
|
|
90
90
|
"tsup": "^8.5.0",
|
|
91
91
|
"vitest": "^3.2.4",
|
|
92
|
-
"@env-spec/env-graph": "0.0.0",
|
|
93
92
|
"@env-spec/utils": "0.0.0"
|
|
94
93
|
},
|
|
95
94
|
"scripts": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/patch-server-response.ts"],"names":[],"mappings":";;;;;;AAUA,IAAM,UAAA,GAAa,mBAAA;AACZ,SAAS,0BAA0B,IAAA,EAGvC;AACD,EAAA,KAAA,CAAM,6CAAmC,CAAA;AACzC,EAAA,IAAI,MAAA,CAAO,wBAAA,CAAyB,cAAA,CAAe,SAAA,EAAW,UAAU,CAAA,EAAG;AACzE,IAAA,KAAA,CAAM,mBAAmB,CAAA;AACzB,IAAA;AAAA,EACF;AACA,EAAA,IAAI,eAAA,CAAgB,iBAAiB,KAAA,EAAO;AAC1C,IAAA,KAAA,CAAM,wBAAwB,CAAA;AAC9B,IAAA;AAAA,EACF;AAEA,EAAA,MAAA,CAAO,eAAe,cAAA,CAAe,SAAA,EAAW,YAAY,EAAE,KAAA,EAAO,MAAM,CAAA;AAE3E,EAAA,MAAM,mBAAA,GAAsB,eAAe,SAAA,CAAU,KAAA;AAGrD,EAAA,cAAA,CAAe,SAAA,CAAU,KAAA,mBAAQ,MAAA,CAAA,SAAS,iCAAA,CAAA,GAAqC,IAAA,EAAM;AAInF,IAAA,MAAM,QAAA,GAAW,KAAK,CAAC,CAAA;AAIvB,IAAA,MAAM,cAAc,IAAA,CAAK,SAAA,CAAU,cAAc,CAAA,EAAG,UAAS,IAAK,EAAA;AAElE,IAAA,IAAI,UACF,WAAA,CAAY,UAAA,CAAW,OAAO,CAAA,IAC3B,WAAA,CAAY,WAAW,kBAAkB,CAAA;AAI9C,IAAA,MAAM,MAAA,GAAU,KAAa,GAAA,CAAI,GAAA;AAEjC,IAAA,IAAI,OAAA,IAAW,MAAA,IAAU,IAAA,EAAM,iBAAA,EAAmB,IAAA,CAAK,CAAC,OAAA,KAAY,OAAA,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,GAAW,KAAK,CAAC,CAAA;AAGvB,IAAA,IAAI,QAAA,IAAY,OAAO,QAAA,KAAa,QAAA,EAAU;AAE5C,MAAA,YAAA,CAAa,QAAA,EAAU,EAAE,MAAA,EAAQ,4BAAA,EAA8B,CAAA;AAAA,IACjE;AAEA,IAAA,OAAO,iBAAA,CAAkB,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA;AAAA,EAC3C,CAAA,EAX+B,0BAAA,CAAA;AAYjC;AAvIgB,MAAA,CAAA,yBAAA,EAAA,2BAAA,CAAA","file":"chunk-5B7JZEDE.js","sourcesContent":["/*\n This patches the global ServerResponse object to scan for secret leaks - currently used for next.js and remix\n*/\n\nimport zlib from 'node:zlib';\nimport { ServerResponse } from 'node:http';\nimport { redactSensitiveConfig, scanForLeaks, varlockSettings } from './env';\nimport { debug } from './lib/debug';\n\n// NOTE - previously was using a symbol but got weird because of multiple builds and contexts...\nconst patchedKey = '_patchedByVarlock';\nexport function patchGlobalServerResponse(opts?: {\n ignoreUrlPatterns?: Array<RegExp>,\n redactInsteadOfThrow?: boolean,\n}) {\n debug('⚡️ PATCHING global ServerResponse');\n if (Object.getOwnPropertyDescriptor(ServerResponse.prototype, patchedKey)) {\n debug('> already patched');\n return;\n }\n if (varlockSettings.preventLeaks === false) {\n debug('> disabled by settings');\n return;\n }\n\n Object.defineProperty(ServerResponse.prototype, patchedKey, { value: true });\n\n const serverResponseWrite = ServerResponse.prototype.write;\n\n // @ts-ignore\n ServerResponse.prototype.write = function varlockPatchedServerResponseWrite(...args) {\n // console.log('⚡️ patched ServerResponse.write');\n // TODO: do we want to filter out some requests here? maybe based on the file type?\n\n const rawChunk = args[0];\n\n // for now, we only scan rendered html... may need to change this though for server components?\n // so we bail if it looks like this response does not contain html\n const contentType = this.getHeader('content-type')?.toString() || '';\n // console.log('patched ServerResponse.write', contentType);\n let runScan = (\n contentType.startsWith('text/')\n || contentType.startsWith('application/json')\n // || contentType.startsWith('application/javascript')\n );\n\n const reqUrl = (this as any).req.url;\n // console.log('> scan ServerResponse.write', contentType, reqUrl);\n if (runScan && reqUrl && opts?.ignoreUrlPatterns?.some((pattern) => pattern.test(reqUrl))) {\n runScan = false;\n }\n\n // we want to run the scanner on text/html and text/x-component (server actions)\n // TODO: anything else?\n if (!runScan) {\n // @ts-ignore\n return serverResponseWrite.apply(this, args);\n }\n\n // have to deal with compressed data, which is awkward but possible\n const compressionType = this.getHeader('Content-Encoding');\n let chunkStr;\n let chunkType: 'string' | 'encoded' | 'gzip' | null = null;\n if (typeof rawChunk === 'string') {\n chunkType = 'string';\n chunkStr = rawChunk;\n } else if (!compressionType) {\n chunkType = 'encoded';\n const decoder = new TextDecoder();\n chunkStr = decoder.decode(rawChunk);\n } else if (compressionType === 'gzip') {\n chunkType = 'gzip';\n // first chunk of data contains only compression headers\n if (!(this as any)._zlibChunks) {\n // (this as any)._zlibHeadersChunk = rawChunk;\n (this as any)._zlibChunks = [rawChunk];\n } else {\n // TODO: figure out how we can unzip one chunk at a time instead of storing everything\n (this as any)._zlibChunks?.push(rawChunk);\n try {\n const unzippedChunk = zlib.unzipSync(Buffer.concat((this as any)._zlibChunks || []), {\n flush: zlib.constants.Z_SYNC_FLUSH,\n finishFlush: zlib.constants.Z_SYNC_FLUSH,\n });\n const fullUnzippedData = unzippedChunk.toString('utf-8');\n chunkStr = fullUnzippedData.substring((this as any)._lastChunkEndIndex || 0);\n (this as any)._lastChunkEndIndex = fullUnzippedData.length;\n } catch (err) {\n // console.log('error unzipping chunk', err);\n }\n }\n }\n // TODO: we may want to support other compression schemes? but currently only used in nextjs which is using gzip\n if (chunkStr) {\n // console.log('scanning!', chunkStr.substring(0, 1000));\n\n\n try {\n scanForLeaks(chunkStr, { method: 'patched ServerResponse.write', file: (this as any).req.url });\n } catch (err) {\n // console.log('found secret in chunk', chunkType, chunkStr);\n // console.log(this)\n if (opts?.redactInsteadOfThrow) {\n chunkStr = redactSensitiveConfig(chunkStr);\n if (chunkType === 'string') {\n args[0] = chunkStr;\n } else if (chunkType === 'encoded') {\n const encoder = new TextEncoder();\n args[0] = encoder.encode(chunkStr);\n } else if (chunkType === 'gzip') {\n // currently unable to scrub gzip chunks\n // this works sometimes, but othertimes causes decoding error\n // we'll need to pass through chunks from a new gzip stream, because we don't have access to the underlying one\n // args[0] = zlib.gzipSync(chunkStr, {\n // flush: zlib.constants.Z_SYNC_FLUSH,\n // finishFlush: zlib.constants.Z_SYNC_FLUSH,\n // });\n } else {\n throw new Error(`unable to scrub - unknown chunk type ${chunkType}`);\n }\n } else {\n throw err;\n }\n }\n }\n\n // @ts-ignore\n return serverResponseWrite.apply(this, args);\n };\n\n\n // calling `res.json()` in the api routes on pages router calls `res.end` without called `res.write`\n const serverResponseEnd = ServerResponse.prototype.end;\n // @ts-ignore\n ServerResponse.prototype.end = function patchedServerResponseEnd(...args) {\n // console.log('⚡️ patched ServerResponse.end');\n const endChunk = args[0];\n // console.log('patched ServerResponse.end', endChunk);\n // this just needs to work (so far) for nextjs sending json bodies, so does not need to handle all cases...\n if (endChunk && typeof endChunk === 'string') {\n // TODO: currently this throws the error and then things just hang... do we want to try to return an error type response instead?\n scanForLeaks(endChunk, { method: 'patched ServerResponse.end' });\n }\n // @ts-ignore\n return serverResponseEnd.apply(this, args);\n };\n}\n\n// ---\n// patchGlobalServerResponse();\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/patch-console.ts"],"names":[],"mappings":";;;;;AAWO,SAAS,kBAAA,GAAqB;AACnC,EAAA,KAAA,CAAM,8CAAoC,CAAA;AAC1C,EAAA,IAAK,OAAA,CAAQ,IAAY,iBAAA,EAAmB;AAC1C,IAAA,KAAA,CAAM,mBAAmB,CAAA;AACzB,IAAA;AAAA,EACF;AACA,EAAA,IAAI,eAAA,CAAgB,eAAe,KAAA,EAAO;AACxC,IAAA,KAAA,CAAM,wBAAwB,CAAA;AAC9B,IAAA;AAAA,EACF;AAQA,EAAA,MAAM,qBAAA,GAAwB,MAAA,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,CAAA,KAAM,CAAA,CAAE,WAAA,KAAgB,iBAAiB,CAAA;AAE9H,EAAA,UAAA,CAAW,OAAA,CAAQ,qBAAqB,CAAA,GAAK,UAAA,CAAmB,4BAAA;AAChE,EAAA,OAAQ,UAAA,CAAmB,4BAAA;AAC7B;AARgB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA","file":"chunk-7OHVYEDG.js","sourcesContent":["/* eslint-disable func-names, no-console, prefer-rest-params */\n\nimport { redactSensitiveConfig, varlockSettings } from './env';\nimport { debug } from './lib/debug';\n\n\n/**\n * patches global console methods to redact sensitive config\n *\n * NOTE - this may not be 100% foolproof depending on the platform\n * */\nexport function patchGlobalConsole() {\n debug('⚡️ PATCHING global console methods');\n if ((console.log as any)._varlockPatchedFn) {\n debug('> already patched');\n return;\n }\n if (varlockSettings.redactLogs === false) {\n debug('> disabled by settings');\n return;\n }\n\n // our method of patching involves replacing an internal node method which may not be called if console.log itself has also been patched\n // for example AWS lambdas patches this to write the logs to a file which then is pushed to the rest of their system\n\n // so first we'll just patch the internal method do deal with normal stdout/stderr logs -------------------------------------\n\n // we need the internal symbol name to access the internal method\n const kWriteToConsoleSymbol = Object.getOwnPropertySymbols(globalThis.console).find((s) => s.description === 'kWriteToConsole');\n\n // @ts-ignore\n (globalThis as any)._varlockOrigWriteToConsoleFn ||= globalThis.console[kWriteToConsoleSymbol];\n // @ts-ignore\n globalThis.console[kWriteToConsoleSymbol] = function () {\n (globalThis as any)._varlockOrigWriteToConsoleFn.apply(this, [\n arguments[0],\n redactSensitiveConfig(arguments[1]),\n arguments[2],\n ]);\n };\n\n // and now we'll wrap console.log (and the other methods) if it looks like they have been patched already ------------------\n // NOTE - this will not fully redact from everything since we can't safely reach deep into objects\n // ideally we would only turn this when the above method does not work, but it's not trivial to detect when it that is the case\n // so we'll turn it on all the time for now...\n\n for (const logMethodName of ['trace', 'debug', 'info', 'log', 'info', 'warn', 'error']) {\n // @ts-ignore\n const originalLogMethod = globalThis.console[logMethodName];\n\n const patchedFn = function () {\n // @ts-ignore\n originalLogMethod.apply(this, Array.from(arguments).map(redactSensitiveConfig));\n };\n patchedFn._varlockPatchedFn = true;\n\n // @ts-ignore\n globalThis.console[logMethodName] = patchedFn;\n }\n}\n\n/**\n * restore's original global console methods to stop redacting secrets\n *\n * (only needed during local development when switching settings on/off in a process that does not reload)\n * */\nexport function unpatchGlobalConsole() {\n // we'll only care about the normal case where console.log has NOT been patched by something else... (see above)\n if (!(globalThis as any)._varlockOrigWriteToConsoleFn) return;\n\n const kWriteToConsoleSymbol = Object.getOwnPropertySymbols(globalThis.console).find((s) => s.description === 'kWriteToConsole');\n // @ts-ignore\n globalThis.console[kWriteToConsoleSymbol] = (globalThis as any)._varlockOrigWriteToConsoleFn;\n delete (globalThis as any)._varlockOrigWriteToConsoleFn;\n}\n\n// ---\n\n// patchGlobalConsole();\n"]}
|
package/dist/chunk-CQHOPN6M.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { patchGlobalConsole } from './chunk-7OHVYEDG.js';
|
|
2
|
-
import { patchGlobalResponse } from './chunk-P74HB2II.js';
|
|
3
|
-
import { patchGlobalServerResponse } from './chunk-5B7JZEDE.js';
|
|
4
|
-
import { initVarlockEnv } from './chunk-SHQHITWV.js';
|
|
5
|
-
import { execSync } from 'child_process';
|
|
6
|
-
|
|
7
|
-
var execResult = execSync("varlock load --format json-full");
|
|
8
|
-
process.env.__VARLOCK_ENV = execResult.toString();
|
|
9
|
-
initVarlockEnv();
|
|
10
|
-
patchGlobalConsole();
|
|
11
|
-
patchGlobalServerResponse();
|
|
12
|
-
patchGlobalResponse();
|
|
13
|
-
//# sourceMappingURL=chunk-CQHOPN6M.js.map
|
|
14
|
-
//# sourceMappingURL=chunk-CQHOPN6M.js.map
|
package/dist/chunk-LZ45SLAI.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { __name } from './chunk-XN24GZXQ.js';
|
|
2
|
-
|
|
3
|
-
// src/runtime/lib/debug.ts
|
|
4
|
-
function debug(...args) {
|
|
5
|
-
if (!process.env.DEBUG_VARLOCK) return;
|
|
6
|
-
console.log(...args);
|
|
7
|
-
}
|
|
8
|
-
__name(debug, "debug");
|
|
9
|
-
|
|
10
|
-
export { debug };
|
|
11
|
-
//# sourceMappingURL=chunk-LZ45SLAI.js.map
|
|
12
|
-
//# sourceMappingURL=chunk-LZ45SLAI.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/lib/debug.ts"],"names":[],"mappings":";;;AACO,SAAS,SAAS,IAAA,EAAkB;AACzC,EAAA,IAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,aAAA,EAAe;AAChC,EAAA,OAAA,CAAQ,GAAA,CAAI,GAAG,IAAI,CAAA;AACrB;AAHgB,MAAA,CAAA,KAAA,EAAA,OAAA,CAAA","file":"chunk-LZ45SLAI.js","sourcesContent":["/* eslint-disable no-console */\nexport function debug(...args: Array<any>) {\n if (!process.env.DEBUG_VARLOCK) return;\n console.log(...args);\n}\n"]}
|