@dotsec/core 5.0.0-beta.04208ad

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.
Files changed (4) hide show
  1. package/README.md +60 -0
  2. package/index.d.ts +28 -0
  3. package/index.js +48 -0
  4. package/package.json +43 -0
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @dotsec/core
2
+
3
+ Native Node.js bindings for [dotsec](https://github.com/jpwesselink/dotsec-rs) — parse, validate, and format `.env` files with directive support.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @dotsec/core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import { parse, validate, toJson, format } from '@dotsec/core';
15
+
16
+ // Parse .env content into structured entries
17
+ const entries = parse(`
18
+ # @encrypt
19
+ DB_URL="postgres://localhost"
20
+ DEBUG=true
21
+ `);
22
+ // [
23
+ // { key: "DB_URL", value: "postgres://localhost", quoteType: "Double", directives: [{ name: "encrypt" }] },
24
+ // { key: "DEBUG", value: "true", quoteType: "None", directives: [] }
25
+ // ]
26
+
27
+ // Validate directives and values
28
+ const errors = validate('# @bogus\nFOO="bar"\n');
29
+ // [{ key: "FOO", message: "unknown directive @bogus..." }]
30
+
31
+ // Convert to JSON
32
+ const json = toJson('FOO=bar\nPORT=3000\n');
33
+ // '[{"FOO":"bar"},{"PORT":"3000"}]'
34
+
35
+ // Roundtrip format
36
+ const formatted = format('FOO=bar\n');
37
+ // 'FOO=bar\n'
38
+ ```
39
+
40
+ ## Supported directives
41
+
42
+ - `@encrypt` / `@plaintext` — mark variables for encryption
43
+ - `@default-encrypt` / `@default-plaintext` — file-level defaults
44
+ - `@type=string|number|boolean|enum("a","b")` — value type validation
45
+ - `@push=aws-ssm|aws-secrets-manager` — push targets with options
46
+ - `@provider`, `@key-id`, `@region` — file-level encryption config
47
+
48
+ See the [full documentation](https://jpwesselink.github.io/dotsec-rs/beta/guide/directives.html) for details.
49
+
50
+ ## Platforms
51
+
52
+ Pre-built binaries are available for:
53
+
54
+ - macOS (ARM64, x64)
55
+ - Linux (ARM64, x64, glibc)
56
+ - Windows (ARM64, x64)
57
+
58
+ ## License
59
+
60
+ MIT — [github.com/jpwesselink/dotsec-rs](https://github.com/jpwesselink/dotsec-rs)
package/index.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ export interface DirectiveItem {
2
+ name: string;
3
+ value: string | null;
4
+ }
5
+
6
+ export interface ParsedEntry {
7
+ key: string;
8
+ value: string;
9
+ quoteType: string;
10
+ directives: DirectiveItem[];
11
+ }
12
+
13
+ export interface ParsedValidationError {
14
+ key: string;
15
+ message: string;
16
+ }
17
+
18
+ /** Parse a .env file string and return entries with their directives. */
19
+ export declare function parse(source: string): ParsedEntry[];
20
+
21
+ /** Validate entries from a .env file string. Returns a list of validation errors. */
22
+ export declare function validate(source: string): ParsedValidationError[];
23
+
24
+ /** Convert a .env file string to JSON. */
25
+ export declare function toJson(source: string): string;
26
+
27
+ /** Roundtrip: parse a .env file string and serialize it back. */
28
+ export declare function format(source: string): string;
package/index.js ADDED
@@ -0,0 +1,48 @@
1
+ import { createRequire } from "node:module";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const require = createRequire(import.meta.url);
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+
8
+ const PLATFORMS = {
9
+ "darwin-arm64": "@dotsec/core-darwin-arm64",
10
+ "darwin-x64": "@dotsec/core-darwin-x64",
11
+ "linux-x64": "@dotsec/core-linux-x64-gnu",
12
+ "linux-arm64": "@dotsec/core-linux-arm64-gnu",
13
+ "win32-x64": "@dotsec/core-win32-x64-msvc",
14
+ "win32-arm64": "@dotsec/core-win32-arm64-msvc",
15
+ };
16
+
17
+ const key = `${process.platform}-${process.arch}`;
18
+ const pkg = PLATFORMS[key];
19
+
20
+ if (!pkg) {
21
+ throw new Error(
22
+ `@dotsec/core: unsupported platform ${process.platform}-${process.arch}\n` +
23
+ `Supported: ${Object.keys(PLATFORMS).join(", ")}`
24
+ );
25
+ }
26
+
27
+ let nativeModule;
28
+ try {
29
+ nativeModule = require(pkg);
30
+ } catch {
31
+ try {
32
+ const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
33
+ nativeModule = require(path.join(pkgDir, "dotsec-core.node"));
34
+ } catch {
35
+ try {
36
+ nativeModule = require(path.join(__dirname, "dotsec-core.node"));
37
+ } catch {
38
+ throw new Error(
39
+ `@dotsec/core: could not load native module "${pkg}"\n\n` +
40
+ `This usually means the optional dependency was not installed.\n` +
41
+ `Try reinstalling with: npm install @dotsec/core`
42
+ );
43
+ }
44
+ }
45
+ }
46
+
47
+ export const { parse, validate, toJson, format } = nativeModule;
48
+ export default nativeModule;
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@dotsec/core",
3
+ "version": "5.0.0-beta.04208ad",
4
+ "description": "Native Node.js bindings for dotsec — parse, validate, and format .env files",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "types": "index.d.ts",
8
+ "napi": {
9
+ "binaryName": "dotsec-core",
10
+ "targets": [
11
+ "x86_64-apple-darwin",
12
+ "aarch64-apple-darwin",
13
+ "x86_64-unknown-linux-gnu",
14
+ "aarch64-unknown-linux-gnu",
15
+ "x86_64-pc-windows-msvc",
16
+ "aarch64-pc-windows-msvc"
17
+ ]
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts",
22
+ "README.md"
23
+ ],
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/jpwesselink/dotsec-rs"
27
+ },
28
+ "optionalDependencies": {
29
+ "@dotsec/core-darwin-arm64": "5.0.0-beta.04208ad",
30
+ "@dotsec/core-darwin-x64": "5.0.0-beta.04208ad",
31
+ "@dotsec/core-linux-x64-gnu": "5.0.0-beta.04208ad",
32
+ "@dotsec/core-linux-arm64-gnu": "5.0.0-beta.04208ad",
33
+ "@dotsec/core-win32-x64-msvc": "5.0.0-beta.04208ad",
34
+ "@dotsec/core-win32-arm64-msvc": "5.0.0-beta.04208ad"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "license": "MIT",
40
+ "engines": {
41
+ "node": ">=16.0.0"
42
+ }
43
+ }