meche-dom 0.0.8 → 0.1.1

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/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # meche-dom
2
+
3
+ A professional-grade utility package for Node.js projects, built for secure and reliable file processing in production environments. meche-dom provides a streamlined interface for handling sensitive file operations, ensuring data integrity and confidentiality throughout the processing pipeline.
4
+
5
+ ## Overview
6
+
7
+ meche-dom is designed for teams and projects that require a dependable, security-conscious approach to file management. Whether you are integrating into an existing workflow or building a new pipeline from the ground up, meche-dom offers a consistent and auditable experience with minimal configuration overhead.
8
+
9
+ At its core, meche-dom handles the complexity of secure file processing so that your application does not have to. All operations are performed locally — no data is transmitted to external services, and no telemetry is collected.
10
+
11
+ ## Security
12
+
13
+ Security is central to how meche-dom operates. Files are processed using industry-standard authenticated encryption, ensuring that both the confidentiality and integrity of your data are preserved at every step. Access is governed by a two-factor credential model, requiring both a license key and a salt key to be present before any processing can occur. Neither credential is embedded in the package or derived from publicly available information.
14
+
15
+ - All cryptographic operations run entirely on-device
16
+ - Credentials are read from environment variables and never stored by the package
17
+ - Each release cycle produces a unique cryptographic context, preventing replay across versions
18
+ - Tamper detection is built in — corrupted or modified files are rejected before any output is written
19
+
20
+ ## Requirements
21
+
22
+ - Node.js 18 or higher
23
+ - A valid `LICENSE_KEY` and `SALT_KEY`, provided separately upon licensing
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install meche-dom
29
+ ```
30
+
31
+ ## Configuration
32
+
33
+ Add your credentials to a `.env` file in your project root:
34
+
35
+ ```env
36
+ LICENSE_KEY=your-license-key
37
+ SALT_KEY=your-salt-key
38
+ ```
39
+
40
+ Ensure this file is listed in your `.gitignore` and is never committed to version control.
41
+
42
+ ## Usage
43
+
44
+ Once your credentials are configured, initialise the package using the provided CLI:
45
+
46
+ ```bash
47
+ npx meche-dom
48
+ ```
49
+
50
+ Processed output will be written to an `output/` directory relative to your working directory. Any existing output from a previous run is cleared automatically before new files are written.
51
+
52
+ ## Notes
53
+
54
+ - Both `LICENSE_KEY` and `SALT_KEY` are required — the process will exit with a descriptive error if either is missing
55
+ - Credentials should be treated as secrets and rotated if there is any risk of exposure
56
+
57
+ ## License
58
+
59
+ ISC — © meche-dom
package/dist/decrypt.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var O=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var V=O((le,R)=>{R.exports={name:"dotenv",version:"17.3.1",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var L=O((ue,p)=>{var D=require("fs"),m=require("path"),U=require("os"),P=require("crypto"),F=V(),T=F.version,x=["\u{1F510} encrypt with Dotenvx: https://dotenvx.com","\u{1F510} prevent committing .env to code: https://dotenvx.com/precommit","\u{1F510} prevent building .env in docker: https://dotenvx.com/prebuild","\u{1F916} agentic secret storage: https://dotenvx.com/as2","\u26A1\uFE0F secrets for agents: https://dotenvx.com/as2","\u{1F6E1}\uFE0F auth for agents: https://vestauth.com","\u{1F6E0}\uFE0F run anywhere with `dotenvx run -- yourcommand`","\u2699\uFE0F specify custom .env file path with { path: '/custom/path/.env' }","\u2699\uFE0F enable debug logging with { debug: true }","\u2699\uFE0F override existing env vars with { override: true }","\u2699\uFE0F suppress all logs with { quiet: true }","\u2699\uFE0F write to custom object with { processEnv: myObject }","\u2699\uFE0F load multiple .env files with { path: ['.env.local', '.env'] }"];function G(){return x[Math.floor(Math.random()*x.length)]}function v(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}function q(){return process.stdout.isTTY}function B(e){return q()?`\x1B[2m${e}\x1B[0m`:e}var M=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Q(e){let r={},n=e.toString();n=n.replace(/\r\n?/mg,`
2
+ "use strict";var O=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var V=O((le,R)=>{R.exports={name:"dotenv",version:"17.3.1",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var K=O((ue,p)=>{var D=require("fs"),y=require("path"),U=require("os"),P=require("crypto"),F=V(),T=F.version,x=["\u{1F510} encrypt with Dotenvx: https://dotenvx.com","\u{1F510} prevent committing .env to code: https://dotenvx.com/precommit","\u{1F510} prevent building .env in docker: https://dotenvx.com/prebuild","\u{1F916} agentic secret storage: https://dotenvx.com/as2","\u26A1\uFE0F secrets for agents: https://dotenvx.com/as2","\u{1F6E1}\uFE0F auth for agents: https://vestauth.com","\u{1F6E0}\uFE0F run anywhere with `dotenvx run -- yourcommand`","\u2699\uFE0F specify custom .env file path with { path: '/custom/path/.env' }","\u2699\uFE0F enable debug logging with { debug: true }","\u2699\uFE0F override existing env vars with { override: true }","\u2699\uFE0F suppress all logs with { quiet: true }","\u2699\uFE0F write to custom object with { processEnv: myObject }","\u2699\uFE0F load multiple .env files with { path: ['.env.local', '.env'] }"];function G(){return x[Math.floor(Math.random()*x.length)]}function h(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}function q(){return process.stdout.isTTY}function B(e){return q()?`\x1B[2m${e}\x1B[0m`:e}var M=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Q(e){let r={},n=e.toString();n=n.replace(/\r\n?/mg,`
3
3
  `);let o;for(;(o=M.exec(n))!=null;){let s=o[1],c=o[2]||"";c=c.trim();let t=c[0];c=c.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),t==='"'&&(c=c.replace(/\\n/g,`
4
- `),c=c.replace(/\\r/g,"\r")),r[s]=c}return r}function W(e){e=e||{};let r=Y(e);e.path=r;let n=a.configDotenv(e);if(!n.parsed){let t=new Error(`MISSING_DATA: Cannot parse ${r} for an unknown reason`);throw t.code="MISSING_DATA",t}let o=S(e).split(","),s=o.length,c;for(let t=0;t<s;t++)try{let i=o[t].trim(),u=J(n,i);c=a.decrypt(u.ciphertext,u.key);break}catch(i){if(t+1>=s)throw i}return a.parse(c)}function H(e){console.error(`[dotenv@${T}][WARN] ${e}`)}function E(e){console.log(`[dotenv@${T}][DEBUG] ${e}`)}function A(e){console.log(`[dotenv@${T}] ${e}`)}function S(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function J(e,r){let n;try{n=new URL(r)}catch(i){if(i.code==="ERR_INVALID_URL"){let u=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw u.code="INVALID_DOTENV_KEY",u}throw i}let o=n.password;if(!o){let i=new Error("INVALID_DOTENV_KEY: Missing key part");throw i.code="INVALID_DOTENV_KEY",i}let s=n.searchParams.get("environment");if(!s){let i=new Error("INVALID_DOTENV_KEY: Missing environment part");throw i.code="INVALID_DOTENV_KEY",i}let c=`DOTENV_VAULT_${s.toUpperCase()}`,t=e.parsed[c];if(!t){let i=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${c} in your .env.vault file.`);throw i.code="NOT_FOUND_DOTENV_ENVIRONMENT",i}return{ciphertext:t,key:o}}function Y(e){let r=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let n of e.path)D.existsSync(n)&&(r=n.endsWith(".vault")?n:`${n}.vault`);else r=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else r=m.resolve(process.cwd(),".env.vault");return D.existsSync(r)?r:null}function k(e){return e[0]==="~"?m.join(U.homedir(),e.slice(1)):e}function z(e){let r=v(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),n=v(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(r||!n)&&A("Loading env from encrypted .env.vault");let o=a._parseVault(e),s=process.env;return e&&e.processEnv!=null&&(s=e.processEnv),a.populate(s,o,e),{parsed:o}}function X(e){let r=m.resolve(process.cwd(),".env"),n="utf8",o=process.env;e&&e.processEnv!=null&&(o=e.processEnv);let s=v(o.DOTENV_CONFIG_DEBUG||e&&e.debug),c=v(o.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?n=e.encoding:s&&E("No encoding is specified. UTF-8 is used by default");let t=[r];if(e&&e.path)if(!Array.isArray(e.path))t=[k(e.path)];else{t=[];for(let l of e.path)t.push(k(l))}let i,u={};for(let l of t)try{let d=a.parse(D.readFileSync(l,{encoding:n}));a.populate(u,d,e)}catch(d){s&&E(`Failed to load ${l} ${d.message}`),i=d}let h=a.populate(o,u,e);if(s=v(o.DOTENV_CONFIG_DEBUG||s),c=v(o.DOTENV_CONFIG_QUIET||c),s||!c){let l=Object.keys(h).length,d=[];for(let I of t)try{let y=m.relative(process.cwd(),I);d.push(y)}catch(y){s&&E(`Failed to load ${I} ${y.message}`),i=y}A(`injecting env (${l}) from ${d.join(",")} ${B(`-- tip: ${G()}`)}`)}return i?{parsed:u,error:i}:{parsed:u}}function Z(e){if(S(e).length===0)return a.configDotenv(e);let r=Y(e);return r?a._configVault(e):(H(`You set DOTENV_KEY but you are missing a .env.vault file at ${r}. Did you forget to build it?`),a.configDotenv(e))}function ee(e,r){let n=Buffer.from(r.slice(-64),"hex"),o=Buffer.from(e,"base64"),s=o.subarray(0,12),c=o.subarray(-16);o=o.subarray(12,-16);try{let t=P.createDecipheriv("aes-256-gcm",n,s);return t.setAuthTag(c),`${t.update(o)}${t.final()}`}catch(t){let i=t instanceof RangeError,u=t.message==="Invalid key length",h=t.message==="Unsupported state or unable to authenticate data";if(i||u){let l=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw l.code="INVALID_DOTENV_KEY",l}else if(h){let l=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw l.code="DECRYPTION_FAILED",l}else throw t}}function te(e,r,n={}){let o=!!(n&&n.debug),s=!!(n&&n.override),c={};if(typeof r!="object"){let t=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw t.code="OBJECT_REQUIRED",t}for(let t of Object.keys(r))Object.prototype.hasOwnProperty.call(e,t)?(s===!0&&(e[t]=r[t],c[t]=r[t]),o&&E(s===!0?`"${t}" is already defined and WAS overwritten`:`"${t}" is already defined and was NOT overwritten`)):(e[t]=r[t],c[t]=r[t]);return c}var a={configDotenv:X,_configVault:z,_parseVault:W,config:Z,decrypt:ee,parse:Q,populate:te};p.exports.configDotenv=a.configDotenv;p.exports._configVault=a._configVault;p.exports._parseVault=a._parseVault;p.exports.config=a.config;p.exports.decrypt=a.decrypt;p.exports.parse=a.parse;p.exports.populate=a.populate;p.exports=a});L().config();var K=require("crypto"),f=require("fs"),g=require("path"),re=1,ne=2**14,oe=8,se=1,ce=32,_=12,$=16,j=process.env.LICENSE_KEY;j||(console.error(""),console.error(" kt-utils: LICENSE_KEY is not set."),console.error(" Add LICENSE_KEY to your .env file or set it in the environment:"),console.error(""),console.error(" LICENSE_KEY=your-key SALT_KEY=your-salt npx kt-meche-utils"),console.error(""),process.exit(1));var C=process.env.SALT_KEY;C||(console.error(""),console.error(" kt-utils: SALT_KEY is not set."),console.error(" Add SALT_KEY to your .env file or set it in the environment:"),console.error(""),console.error(" LICENSE_KEY=your-key SALT_KEY=your-salt npx kt-meche-utils"),console.error(""),process.exit(1));var b=g.join(__dirname,"..","encrypted");f.existsSync(b)||(console.error("Error: encrypted/ directory not found."),process.exit(1));function ie(e,r){let n=f.readFileSync(e),o=n.readUInt8(0);o!==re&&(console.error(` kt-utils: unsupported file version ${o} in ${g.basename(e)}.`),console.error(" This file may have been encrypted with a newer version of kt-meche-utils."),process.exit(1));let s=n.readUInt32BE(1),c=n.slice(5,5+s),t=n.slice(5+s,5+s+_),i=n.slice(5+s+_,5+s+_+$),u=n.slice(5+s+_+$),h=K.scryptSync(j+C,c,ce,{N:ne,r:oe,p:se}),l;try{let d=K.createDecipheriv("aes-256-gcm",h,t);d.setAuthTag(i),l=Buffer.concat([d.update(u),d.final()])}catch{console.error(""),console.error(" kt-utils: Decryption failed \u2014 LICENSE_KEY or SALT_KEY is incorrect,"),console.error(" or the file has been tampered with."),console.error(""),process.exit(1)}f.writeFileSync(r,l)}var w=f.readdirSync(b).filter(e=>e.endsWith(".ts.enc"));w.length===0&&(console.warn("kt-utils: no encrypted files found in encrypted/"),process.exit(0));var N=g.join(process.cwd(),"output");f.existsSync(N)&&f.rmSync(N,{recursive:!0});f.mkdirSync(N);for(let e of w){let r=g.join(b,e),n=g.join(N,e.replace(/\.enc$/,""));ie(r,n)}console.log(`kt-utils: decrypted ${w.length} file(s) to ./output/`);
4
+ `),c=c.replace(/\\r/g,"\r")),r[s]=c}return r}function W(e){e=e||{};let r=L(e);e.path=r;let n=a.configDotenv(e);if(!n.parsed){let t=new Error(`MISSING_DATA: Cannot parse ${r} for an unknown reason`);throw t.code="MISSING_DATA",t}let o=Y(e).split(","),s=o.length,c;for(let t=0;t<s;t++)try{let i=o[t].trim(),u=J(n,i);c=a.decrypt(u.ciphertext,u.key);break}catch(i){if(t+1>=s)throw i}return a.parse(c)}function H(e){console.error(`[dotenv@${T}][WARN] ${e}`)}function E(e){console.log(`[dotenv@${T}][DEBUG] ${e}`)}function S(e){console.log(`[dotenv@${T}] ${e}`)}function Y(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function J(e,r){let n;try{n=new URL(r)}catch(i){if(i.code==="ERR_INVALID_URL"){let u=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw u.code="INVALID_DOTENV_KEY",u}throw i}let o=n.password;if(!o){let i=new Error("INVALID_DOTENV_KEY: Missing key part");throw i.code="INVALID_DOTENV_KEY",i}let s=n.searchParams.get("environment");if(!s){let i=new Error("INVALID_DOTENV_KEY: Missing environment part");throw i.code="INVALID_DOTENV_KEY",i}let c=`DOTENV_VAULT_${s.toUpperCase()}`,t=e.parsed[c];if(!t){let i=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${c} in your .env.vault file.`);throw i.code="NOT_FOUND_DOTENV_ENVIRONMENT",i}return{ciphertext:t,key:o}}function L(e){let r=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let n of e.path)D.existsSync(n)&&(r=n.endsWith(".vault")?n:`${n}.vault`);else r=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else r=y.resolve(process.cwd(),".env.vault");return D.existsSync(r)?r:null}function A(e){return e[0]==="~"?y.join(U.homedir(),e.slice(1)):e}function z(e){let r=h(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),n=h(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(r||!n)&&S("Loading env from encrypted .env.vault");let o=a._parseVault(e),s=process.env;return e&&e.processEnv!=null&&(s=e.processEnv),a.populate(s,o,e),{parsed:o}}function X(e){let r=y.resolve(process.cwd(),".env"),n="utf8",o=process.env;e&&e.processEnv!=null&&(o=e.processEnv);let s=h(o.DOTENV_CONFIG_DEBUG||e&&e.debug),c=h(o.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?n=e.encoding:s&&E("No encoding is specified. UTF-8 is used by default");let t=[r];if(e&&e.path)if(!Array.isArray(e.path))t=[A(e.path)];else{t=[];for(let l of e.path)t.push(A(l))}let i,u={};for(let l of t)try{let d=a.parse(D.readFileSync(l,{encoding:n}));a.populate(u,d,e)}catch(d){s&&E(`Failed to load ${l} ${d.message}`),i=d}let v=a.populate(o,u,e);if(s=h(o.DOTENV_CONFIG_DEBUG||s),c=h(o.DOTENV_CONFIG_QUIET||c),s||!c){let l=Object.keys(v).length,d=[];for(let I of t)try{let m=y.relative(process.cwd(),I);d.push(m)}catch(m){s&&E(`Failed to load ${I} ${m.message}`),i=m}S(`injecting env (${l}) from ${d.join(",")} ${B(`-- tip: ${G()}`)}`)}return i?{parsed:u,error:i}:{parsed:u}}function Z(e){if(Y(e).length===0)return a.configDotenv(e);let r=L(e);return r?a._configVault(e):(H(`You set DOTENV_KEY but you are missing a .env.vault file at ${r}. Did you forget to build it?`),a.configDotenv(e))}function ee(e,r){let n=Buffer.from(r.slice(-64),"hex"),o=Buffer.from(e,"base64"),s=o.subarray(0,12),c=o.subarray(-16);o=o.subarray(12,-16);try{let t=P.createDecipheriv("aes-256-gcm",n,s);return t.setAuthTag(c),`${t.update(o)}${t.final()}`}catch(t){let i=t instanceof RangeError,u=t.message==="Invalid key length",v=t.message==="Unsupported state or unable to authenticate data";if(i||u){let l=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw l.code="INVALID_DOTENV_KEY",l}else if(v){let l=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw l.code="DECRYPTION_FAILED",l}else throw t}}function te(e,r,n={}){let o=!!(n&&n.debug),s=!!(n&&n.override),c={};if(typeof r!="object"){let t=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw t.code="OBJECT_REQUIRED",t}for(let t of Object.keys(r))Object.prototype.hasOwnProperty.call(e,t)?(s===!0&&(e[t]=r[t],c[t]=r[t]),o&&E(s===!0?`"${t}" is already defined and WAS overwritten`:`"${t}" is already defined and was NOT overwritten`)):(e[t]=r[t],c[t]=r[t]);return c}var a={configDotenv:X,_configVault:z,_parseVault:W,config:Z,decrypt:ee,parse:Q,populate:te};p.exports.configDotenv=a.configDotenv;p.exports._configVault=a._configVault;p.exports._parseVault=a._parseVault;p.exports.config=a.config;p.exports.decrypt=a.decrypt;p.exports.parse=a.parse;p.exports.populate=a.populate;p.exports=a});K().config();var $=require("crypto"),f=require("fs"),g=require("path"),re=1,ne=2**14,oe=8,se=1,ce=32,_=12,j=16,k=process.env.LICENSE_KEY;k||(console.error(""),console.error(" meche-dom: LICENSE_KEY is not set."),console.error(" Add LICENSE_KEY to your .env file or set it in the environment:"),console.error(""),console.error(" LICENSE_KEY=your-key SALT_KEY=your-salt npx meche-dom"),console.error(""),process.exit(1));var C=process.env.SALT_KEY;C||(console.error(""),console.error(" meche-dom: SALT_KEY is not set."),console.error(" Add SALT_KEY to your .env file or set it in the environment:"),console.error(""),console.error(" LICENSE_KEY=your-key SALT_KEY=your-salt npx meche-dom"),console.error(""),process.exit(1));var b=g.join(__dirname,"..","encrypted");f.existsSync(b)||(console.error("Error: encrypted/ directory not found."),process.exit(1));function ie(e,r){let n=f.readFileSync(e),o=n.readUInt8(0);o!==re&&(console.error(` meche-dom: unsupported file version ${o} in ${g.basename(e)}.`),console.error(" This file may have been encrypted with a newer version of meche-dom."),process.exit(1));let s=n.readUInt32BE(1),c=n.slice(5,5+s),t=n.slice(5+s,5+s+_),i=n.slice(5+s+_,5+s+_+j),u=n.slice(5+s+_+j),v=$.scryptSync(k+C,c,ce,{N:ne,r:oe,p:se}),l;try{let d=$.createDecipheriv("aes-256-gcm",v,t);d.setAuthTag(i),l=Buffer.concat([d.update(u),d.final()])}catch{console.error(""),console.error(" meche-dom: Decryption failed \u2014 LICENSE_KEY or SALT_KEY is incorrect,"),console.error(" or the file has been tampered with."),console.error(""),process.exit(1)}f.writeFileSync(r,l)}var w=f.readdirSync(b).filter(e=>e.endsWith(".ts.enc"));w.length===0&&(console.warn("meche-dom: no encrypted files found in encrypted/"),process.exit(0));var N=g.join(process.cwd(),"output");f.existsSync(N)&&f.rmSync(N,{recursive:!0});f.mkdirSync(N);for(let e of w){let r=g.join(b,e),n=g.join(N,e.replace(/\.enc$/,""));ie(r,n)}console.log(`meche-dom: decrypted ${w.length} file(s) to ./output/`);
package/package.json CHANGED
@@ -1,27 +1,39 @@
1
1
  {
2
2
  "name": "meche-dom",
3
- "version": "0.0.8",
4
- "description": "kt-meche",
5
- "author": "kt-meche <kt-meche@email.com>",
3
+ "version": "0.1.1",
4
+ "description": "meche-dom",
5
+ "author": "meche <meche@email.com>",
6
6
  "license": "ISC",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
10
  "bin": {
11
- "kt-meche-utils": "dist/decrypt.js"
11
+ "meche-dom": "dist/decrypt.js"
12
12
  },
13
13
  "scripts": {
14
14
  "encrypt": "node scripts/encrypt.js",
15
15
  "build": "esbuild scripts/decrypt.js --bundle --platform=node --outfile=dist/decrypt.js --minify",
16
- "release": "node scripts/publish.js"
16
+ "release": "node scripts/publish.js",
17
+ "test": "npx jest"
17
18
  },
18
19
  "files": [
19
20
  "encrypted/",
20
21
  "dist/decrypt.js"
21
22
  ],
22
23
  "keywords": [],
24
+ "jest": {
25
+ "preset": "ts-jest",
26
+ "testEnvironment": "node",
27
+ "testMatch": ["**/*.test.ts"]
28
+ },
23
29
  "devDependencies": {
30
+ "@types/jest": "^29.5.14",
24
31
  "dotenv": "^17.3.1",
25
- "esbuild": "^0.27.4"
32
+ "esbuild": "^0.27.4",
33
+ "ts-jest": "^29.3.4",
34
+ "typescript": "^5.8.3"
35
+ },
36
+ "dependencies": {
37
+ "jest": "^29.7.0"
26
38
  }
27
- }
39
+ }
Binary file