@nodesecure/rc 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 NodeSecure
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # rc
2
+ ![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/NodeSecure/rc/master/package.json&query=$.version&label=Version)
3
+ [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/NodeSecure/rc/commit-activity)
4
+ [![Security Responsible Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/nodejs/security-wg/blob/master/processes/responsible_disclosure_template.md
5
+ )
6
+ [![mit](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/NodeSecure/rc/blob/master/LICENSE)
7
+
8
+ NodeSecure runtime configuration.
9
+
10
+ ## Requirements
11
+ - [Node.js](https://nodejs.org/en/) v16 or higher
12
+
13
+ ## Getting Started
14
+
15
+ This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).
16
+
17
+ ```bash
18
+ $ npm i @nodesecure/rc
19
+ # or
20
+ $ yarn add @nodesecure/rc
21
+ ```
22
+
23
+ ## Usage example
24
+
25
+ Read:
26
+
27
+ ```ts
28
+ import * as RC from "@nodesecure/rc";
29
+
30
+ const configurationPayload = (
31
+ await RC.read(void 0, { createIfDoesNotExist: true })
32
+ ).unwrap();
33
+ console.log(configurationPayload);
34
+ ```
35
+
36
+ Write:
37
+ ```ts
38
+ import assert from "node:assert/strict";
39
+ import * as RC from "@nodesecure/rc";
40
+
41
+ const writeOpts: RC.writeOptions = {
42
+ payload: { version: "2.0.0" },
43
+ partialUpdate: true
44
+ };
45
+
46
+ const result = (
47
+ await RC.write(void 0, writeOpts)
48
+ ).unwrap();
49
+ assert.strictEqual(result, void 0);
50
+ ```
51
+
52
+ > 👀 .read and .write return Rust like [Result](https://doc.rust-lang.org/std/result/) object. Under the hood we use [ts-results](https://github.com/vultix/ts-results) to achieve this.
53
+
54
+ ## API
55
+
56
+ > If `undefined` the location will be assigned to `process.cwd()`.
57
+
58
+ ### read(location?: string, options?: readOptions): Promise< Result< RC, NodeJS.ErrnoException > >
59
+
60
+ ```ts
61
+ interface createReadOptions {
62
+ /**
63
+ * If enabled the file will be created if it does not exist on the disk.
64
+ *
65
+ * @default false
66
+ */
67
+ createIfDoesNotExist?: boolean;
68
+ /**
69
+ * RC Generation mode. This option allows to generate a more or less complete configuration for some NodeSecure tools.
70
+ *
71
+ * @default `minimal`
72
+ */
73
+ createMode?: RCGenerationMode | RCGenerationMode[];
74
+ }
75
+
76
+ export type readOptions = RequireAtLeastOne<createReadOptions, "createIfDoesNotExist" | "createMode">;
77
+ ```
78
+
79
+ The `createIfDoesNotExist` argument can be ignored if `createMode` is provided.
80
+
81
+ ```ts
82
+ import * as RC from "@nodesecure/rc";
83
+
84
+ const configurationPayload = (
85
+ await RC.read(void 0, { createMode: "ci" })
86
+ ).unwrap();
87
+ console.log(configurationPayload);
88
+ ```
89
+
90
+ ### write(location?: string, options: writeOptions): Promise< Result< void, NodeJS.ErrnoException > >
91
+
92
+ By default the write API will overwrite the current payload with the provided one. When the `partialUpdate` option is enabled it will merge the new properties with the existing one.
93
+
94
+ ```ts
95
+ /**
96
+ * Overwrite the complete payload. partialUpdate property is mandatory.
97
+ */
98
+ export interface writeCompletePayload {
99
+ payload: RC;
100
+ partialUpdate?: false;
101
+ }
102
+
103
+ /**
104
+ * Partially update the payload. This implies not to rewrite the content of the file when enabled.
105
+ **/
106
+ export interface writePartialPayload {
107
+ payload: Partial<RC>;
108
+ partialUpdate: true;
109
+ }
110
+
111
+ export type writeOptions = writeCompletePayload | writePartialPayload;
112
+ ```
113
+
114
+ ### CONSTANTS
115
+
116
+ ```ts
117
+ import assert from "node:assert/strict";
118
+ import * as RC from "@nodesecure/rc";
119
+
120
+ assert.strictEqual(RC.CONSTANTS.CONFIGURATION_NAME, ".nodesecurerc");
121
+ ```
122
+
123
+ ### Generation Mode
124
+
125
+ We provide by default a configuration generation that we consider `minimal`. On the contrary, a `complete` value will indicate the generation with all possible default keys.
126
+
127
+ ```ts
128
+ export type RCGenerationMode = "minimal" | "ci" | "complete";
129
+ ```
130
+
131
+ However, depending on the NodeSecure tool you are working on, it can be interesting to generate a configuration with some property sets specific to your needs.
132
+
133
+ Note that you can combine several modes:
134
+
135
+ ```ts
136
+ import * as RC from "@nodesecure/rc";
137
+
138
+ await RC.read(void 0, { createMode: ["ci", "scanner"] })
139
+ ```
140
+
141
+ ## JSON Schema
142
+
143
+ The runtime configuration is validated with a JSON Schema: `./src/schema/nodesecurerc.json`.
144
+
145
+ It can be retrieved by API if required:
146
+ ```ts
147
+ import * as RC from "@nodesecure/rc";
148
+
149
+ console.log(RC.JSONSchema);
150
+ ```
151
+
152
+ ## Contributors ✨
153
+
154
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
155
+ [![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
156
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
157
+
158
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
159
+
160
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
161
+ <!-- prettier-ignore-start -->
162
+ <!-- markdownlint-disable -->
163
+
164
+ <!-- markdownlint-restore -->
165
+ <!-- prettier-ignore-end -->
166
+
167
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
168
+
169
+ ## License
170
+ MIT
@@ -0,0 +1 @@
1
+ export declare const CONFIGURATION_NAME = ".nodesecurerc";
@@ -0,0 +1,2 @@
1
+ export const CONFIGURATION_NAME = ".nodesecurerc";
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC"}
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" />
2
+ import { Result } from "ts-results";
3
+ import { RequireAtLeastOne } from "type-fest";
4
+ import { RC, RCGenerationMode } from "../rc.js";
5
+ interface createReadOptions {
6
+ /**
7
+ * If enabled the file will be created if it does not exist on the disk.
8
+ *
9
+ * @default false
10
+ */
11
+ createIfDoesNotExist?: boolean;
12
+ /**
13
+ * RC Generation mode. This option allows to generate a more or less complete configuration for some NodeSecure tools.
14
+ *
15
+ * @default `minimal`
16
+ */
17
+ createMode?: RCGenerationMode | RCGenerationMode[];
18
+ }
19
+ export declare type readOptions = RequireAtLeastOne<createReadOptions, "createIfDoesNotExist" | "createMode">;
20
+ export declare function read(location?: string, options?: readOptions): Promise<Result<RC, NodeJS.ErrnoException>>;
21
+ export {};
@@ -0,0 +1,32 @@
1
+ // Import Node.js Dependencies
2
+ import path from "node:path";
3
+ import { once } from "node:events";
4
+ // Import Third-party Dependencies
5
+ import Config from "@slimio/config";
6
+ import TR from "ts-results";
7
+ // Import Internal Dependencies
8
+ import { JSONSchema, generateDefaultRC } from "../rc.js";
9
+ import * as CONSTANTS from "../constants.js";
10
+ // CONSTANTS
11
+ const { Ok, Err } = TR;
12
+ export async function read(location = process.cwd(), options = Object.create(null)) {
13
+ try {
14
+ const { createIfDoesNotExist = Boolean(options.createMode), createMode } = options;
15
+ const cfgPath = path.join(location, CONSTANTS.CONFIGURATION_NAME);
16
+ const cfg = new Config(cfgPath, {
17
+ defaultSchema: JSONSchema,
18
+ createOnNoEntry: createIfDoesNotExist
19
+ });
20
+ await cfg.read(createIfDoesNotExist ? generateDefaultRC(createMode) : void 0);
21
+ if (createIfDoesNotExist) {
22
+ await once(cfg, "configWritten");
23
+ }
24
+ const result = cfg.payload;
25
+ await cfg.close();
26
+ return new Ok(result);
27
+ }
28
+ catch (error) {
29
+ return new Err(error);
30
+ }
31
+ }
32
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/functions/read.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,kCAAkC;AAClC,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAc,MAAM,YAAY,CAAC;AAGxC,+BAA+B;AAC/B,OAAO,EAAM,UAAU,EAAE,iBAAiB,EAAoB,MAAM,UAAU,CAAC;AAC/E,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAE7C,YAAY;AACZ,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAmBvB,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,EACxB,UAAuB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IAE1C,IAAI;QACF,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAEnF,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;QAClE,MAAM,GAAG,GAAG,IAAI,MAAM,CAAK,OAAO,EAAE;YAClC,aAAa,EAAE,UAAU;YACzB,eAAe,EAAE,oBAAoB;SACtC,CAAC,CAAC;QAEH,MAAM,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9E,IAAI,oBAAoB,EAAE;YACxB,MAAM,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;SAClC;QACD,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;QAE3B,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;QAElB,OAAO,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;KACvB;IACD,OAAO,KAAK,EAAE;QACZ,OAAO,IAAI,GAAG,CAAC,KAA8B,CAAC,CAAC;KAChD;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ /// <reference types="node" />
2
+ import { Result } from "ts-results";
3
+ import { RC } from "../rc.js";
4
+ /**
5
+ * Overwrite the complete payload. partialUpdate property is mandatory.
6
+ */
7
+ export interface writeCompletePayload {
8
+ payload: RC;
9
+ partialUpdate?: false;
10
+ }
11
+ /**
12
+ * Partially update the payload. This implies not to rewrite the content of the file when enabled.
13
+ **/
14
+ export interface writePartialPayload {
15
+ payload: Partial<RC>;
16
+ partialUpdate: true;
17
+ }
18
+ export declare type writeOptions = writeCompletePayload | writePartialPayload;
19
+ export declare function write(location: string | undefined, options: writeOptions): Promise<Result<void, NodeJS.ErrnoException>>;
@@ -0,0 +1,28 @@
1
+ // Import Node.js Dependencies
2
+ import path from "path";
3
+ // Import Third-party Dependencies
4
+ import Config from "@slimio/config";
5
+ import TR from "ts-results";
6
+ // Import Internal Dependencies
7
+ import { JSONSchema } from "../rc.js";
8
+ import * as CONSTANTS from "../constants.js";
9
+ // CONSTANTS
10
+ const { Ok, Err } = TR;
11
+ export async function write(location = process.cwd(), options) {
12
+ try {
13
+ const { payload, partialUpdate = false } = options;
14
+ const cfgPath = path.join(location, CONSTANTS.CONFIGURATION_NAME);
15
+ const cfg = new Config(cfgPath, {
16
+ defaultSchema: JSONSchema
17
+ });
18
+ await cfg.read();
19
+ const newPayloadValue = partialUpdate ? Object.assign(cfg.payload, payload) : payload;
20
+ cfg.payload = newPayloadValue;
21
+ await cfg.close();
22
+ return new Ok(void 0);
23
+ }
24
+ catch (error) {
25
+ return new Err(error);
26
+ }
27
+ }
28
+ //# sourceMappingURL=write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/functions/write.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,kCAAkC;AAClC,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAc,MAAM,YAAY,CAAC;AAExC,+BAA+B;AAC/B,OAAO,EAAM,UAAU,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAE7C,YAAY;AACZ,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAoBvB,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,EACxB,OAAqB;IAErB,IAAI;QACF,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;QAEnD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;QAClE,MAAM,GAAG,GAAG,IAAI,MAAM,CAAK,OAAO,EAAE;YAClC,aAAa,EAAE,UAAU;SAC1B,CAAC,CAAC;QACH,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,MAAM,eAAe,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAa,CAAC;QAC5F,GAAG,CAAC,OAAO,GAAG,eAAe,CAAC;QAE9B,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;QAElB,OAAO,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;KACvB;IACD,OAAO,KAAK,EAAE;QACZ,OAAO,IAAI,GAAG,CAAC,KAA8B,CAAC,CAAC;KAChD;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./functions/read.js";
2
+ export * from "./functions/write.js";
3
+ export * as CONSTANTS from "./constants.js";
4
+ export { RC, JSONSchema } from "./rc.js";
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./functions/read.js";
2
+ export * from "./functions/write.js";
3
+ export * as CONSTANTS from "./constants.js";
4
+ export { JSONSchema } from "./rc.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAM,UAAU,EAAE,MAAM,SAAS,CAAC"}
package/dist/rc.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ import i18n from "@nodesecure/i18n";
2
+ import * as vuln from "@nodesecure/vuln";
3
+ import * as jsxray from "@nodesecure/js-x-ray";
4
+ export declare const JSONSchema: any;
5
+ export interface RC {
6
+ /** version of the rc package used to generate the nodesecurerc file */
7
+ version: string;
8
+ /**
9
+ * Language to use for i18n (translation in NodeSecure tools).
10
+ * @see https://developer.mozilla.org/en-US/docs/Glossary/I18N
11
+ * @see https://github.com/NodeSecure/i18n
12
+ *
13
+ * @default `english`
14
+ */
15
+ i18n?: i18n.languages;
16
+ /**
17
+ * Vulnerability strategy to use. Can be disabled by using `none` as value.
18
+ * @see https://github.com/NodeSecure/vuln#available-strategy
19
+ *
20
+ * @default `npm`
21
+ */
22
+ strategy?: vuln.Strategy.Kind;
23
+ /** NodeSecure ci Object configuration */
24
+ ci?: CiConfiguration;
25
+ }
26
+ /**
27
+ * Configuration dedicated for NodeSecure CI (or nsci)
28
+ * @see https://github.com/NodeSecure/ci
29
+ * @see https://github.com/NodeSecure/ci-action
30
+ */
31
+ export interface CiConfiguration {
32
+ /**
33
+ * List of enabled reporters
34
+ * @see https://github.com/NodeSecure/ci#reporters
35
+ */
36
+ reporters?: ("console" | "html")[];
37
+ vulnerabilities?: {
38
+ severity?: "medium" | "high" | "critical" | "all";
39
+ };
40
+ /**
41
+ * JS-X-Ray warnings configuration
42
+ * @see https://github.com/NodeSecure/js-x-ray#warnings-legends-v20
43
+ */
44
+ warnings?: CiWarnings | Record<jsxray.kindWithValue | "unsafe-import", CiWarnings>;
45
+ }
46
+ export declare type CiWarnings = "off" | "error" | "warning";
47
+ export declare function generateCIConfiguration(): {
48
+ ci: CiConfiguration;
49
+ };
50
+ export declare type RCGenerationMode = "minimal" | "ci" | "complete";
51
+ /**
52
+ * @example
53
+ * generateDefaultRC("complete");
54
+ * generateDefaultRC(["ci", "scanner"]); // minimal + ci + scanner
55
+ */
56
+ export declare function generateDefaultRC(mode?: RCGenerationMode | RCGenerationMode[]): RC;
package/dist/rc.js ADDED
@@ -0,0 +1,30 @@
1
+ // Import Internal Dependencies
2
+ import { readJSONSync } from "./utils/index.js";
3
+ // CONSTANTS
4
+ export const JSONSchema = readJSONSync("./schema/nodesecurerc.json", import.meta.url);
5
+ export function generateCIConfiguration() {
6
+ const ci = {
7
+ reporters: ["console"],
8
+ vulnerabilities: {
9
+ severity: "medium"
10
+ },
11
+ warnings: "error"
12
+ };
13
+ return { ci };
14
+ }
15
+ /**
16
+ * @example
17
+ * generateDefaultRC("complete");
18
+ * generateDefaultRC(["ci", "scanner"]); // minimal + ci + scanner
19
+ */
20
+ export function generateDefaultRC(mode = "minimal") {
21
+ const modes = new Set(typeof mode === "string" ? [mode] : mode);
22
+ const minimalRC = {
23
+ version: "1.0.0",
24
+ i18n: "english",
25
+ strategy: "npm"
26
+ };
27
+ const complete = modes.has("complete");
28
+ return Object.assign(minimalRC, complete || modes.has("ci") ? generateCIConfiguration() : {});
29
+ }
30
+ //# sourceMappingURL=rc.js.map
package/dist/rc.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rc.js","sourceRoot":"","sources":["../src/rc.ts"],"names":[],"mappings":"AAKA,+BAA+B;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,YAAY;AACZ,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC,4BAA4B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AA8CtF,MAAM,UAAU,uBAAuB;IACrC,MAAM,EAAE,GAAoB;QAC1B,SAAS,EAAE,CAAC,SAAS,CAAC;QACtB,eAAe,EAAE;YACf,QAAQ,EAAE,QAAQ;SACnB;QACD,QAAQ,EAAE,OAAO;KAClB,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,CAAC;AAChB,CAAC;AAID;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA8C,SAAS;IACvF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEhE,MAAM,SAAS,GAAG;QAChB,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,SAAkB;QACxB,QAAQ,EAAE,KAAc;KACzB,CAAC;IACF,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAEvC,OAAO,MAAM,CAAC,MAAM,CAClB,SAAS,EACT,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,CAC7D,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./readJSON.js";
@@ -0,0 +1,2 @@
1
+ export * from "./readJSON.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function readJSONSync(path: string, base?: string | URL): any;
@@ -0,0 +1,7 @@
1
+ // Import Node.js Dependencies
2
+ import { readFileSync } from "node:fs";
3
+ export function readJSONSync(path, base) {
4
+ const buf = readFileSync(typeof base === "string" ? new URL(path, base) : path);
5
+ return JSON.parse(buf.toString());
6
+ }
7
+ //# sourceMappingURL=readJSON.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readJSON.js","sourceRoot":"","sources":["../../src/utils/readJSON.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,IAAmB;IAC5D,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEhF,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;AACpC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@nodesecure/rc",
3
+ "version": "1.0.0",
4
+ "description": "NodeSecure runtime configuration",
5
+ "exports": "./dist/index.js",
6
+ "type": "module",
7
+ "types": "./dist/index.d.ts",
8
+ "engines": {
9
+ "node": ">=16"
10
+ },
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "prepublishOnly": "npm run build",
14
+ "test": "mocha --parallel && npm run test:tsd",
15
+ "test:tsd": "npm run build && tsd",
16
+ "coverage": "c8 -r html npm test",
17
+ "lint": "cross-env eslint src/*.ts"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/NodeSecure/rc.git"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "keywords": [
27
+ "rc",
28
+ "config",
29
+ "configuration"
30
+ ],
31
+ "author": "GENTILHOMME Thomas <gentilhomme.thomas@gmail.com>",
32
+ "license": "MIT",
33
+ "bugs": {
34
+ "url": "https://github.com/NodeSecure/rc/issues"
35
+ },
36
+ "homepage": "https://github.com/NodeSecure/rc#readme",
37
+ "devDependencies": {
38
+ "@nodesecure/eslint-config": "^1.3.1",
39
+ "@types/chai": "^4.3.0",
40
+ "@types/mocha": "^9.1.0",
41
+ "@types/node": "^17.0.13",
42
+ "@types/zen-observable": "^0.8.3",
43
+ "ajv": "^8.9.0",
44
+ "c8": "^7.11.0",
45
+ "chai": "^4.3.6",
46
+ "eslint": "^8.7.0",
47
+ "mocha": "^9.2.0",
48
+ "tape": "^5.5.0",
49
+ "ts-node": "^10.4.0",
50
+ "tsd": "^0.19.1",
51
+ "typescript": "^4.5.5"
52
+ },
53
+ "dependencies": {
54
+ "@nodesecure/i18n": "^1.2.1",
55
+ "@nodesecure/js-x-ray": "^4.2.1",
56
+ "@nodesecure/vuln": "^1.5.0",
57
+ "@slimio/config": "^1.0.1",
58
+ "ts-results": "^3.3.0",
59
+ "type-fest": "^2.11.0"
60
+ },
61
+ "tsd": {
62
+ "directory": "test/types",
63
+ "compilerOptions": {
64
+ "esModuleInterop": true
65
+ }
66
+ }
67
+ }