envis-node 0.0.2 → 0.0.3

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,56 @@
1
+ # envis-node
2
+
3
+ -----
4
+
5
+ ## Table of Contents
6
+
7
+ - [Overview](#overview)
8
+ - [Installation](#installation)
9
+ - [Usage](#usage)
10
+ - [License](#license)
11
+ - [Contact](#contact)
12
+
13
+ ## Overview
14
+ Envisible is a simple, secure secret management platform. The SDK allows users to integrate their secrets (configured [on our web dashboard](https://envisible.netlify.app)) directly into their Node.js code.
15
+
16
+ ## Installation
17
+
18
+ ```console
19
+ cd node-sdk
20
+ npm install
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ 1. Sign up for an Envisible account on the dashboard.
26
+ 2. Install the SDK and authenticate when prompted (the SDK will open a secure browser window).
27
+ 3. Read and manage secrets from any Node.js runtime:
28
+
29
+ ### Fetching a secret
30
+
31
+ ```javascript
32
+ const envis = require("envis-node");
33
+
34
+ async function main() {
35
+ const secret = await envis.get("project_id", "secret_name");
36
+ console.log(secret);
37
+ }
38
+
39
+ main();
40
+ ```
41
+
42
+ ### Logging out
43
+
44
+ ```javascript
45
+ const envis = require("envis-node");
46
+
47
+ envis.logout();
48
+ ```
49
+
50
+ ## License
51
+
52
+ `envis-node` is released under a private source-available license: you can use the SDK to integrate with [our web dashboard](https://envisible.netlify.app), but the backend platform remains proprietary.
53
+
54
+ ## Contact
55
+ - [Website](https://envisible.netlify.app)
56
+ - [Email](mailto:contact@uarham.me)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "envis-node",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Secure, simple secret management",
5
5
  "keywords": [
6
6
  "secret",
@@ -10,6 +10,10 @@
10
10
  ],
11
11
  "license": "ISC",
12
12
  "author": "Umair Arham",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/umairx25/Envisible-Clients"
16
+ },
13
17
  "type": "commonjs",
14
18
  "main": "src/index.js",
15
19
  "scripts": {
package/src/main.js CHANGED
@@ -33,21 +33,13 @@ async function get(projectId, secretName) {
33
33
  throw new Error("Both project id and secret name are required.");
34
34
  }
35
35
 
36
- const ciToken = process.env.ENVIS_CI_TOKEN;
37
- let session = null;
38
- if (!ciToken) {
39
- await ensureSession();
40
- session = await loadSession();
41
- }
36
+ await ensureSession();
37
+ const session = await loadSession();
42
38
 
43
39
  const headers = {
40
+ Authorization: `Bearer ${session.access_token}`,
44
41
  "Content-Type": "application/json",
45
42
  };
46
- if (ciToken) {
47
- headers["X-CI-Token"] = ciToken;
48
- } else {
49
- headers.Authorization = `Bearer ${session.access_token}`;
50
- }
51
43
 
52
44
  const url = `${BASE_URL}/v1/projects/${encodeURIComponent(
53
45
  projectId
package/src/session.js CHANGED
@@ -11,76 +11,6 @@ const REQUIRED_SESSION_KEYS = ["access_token", "refresh_token"];
11
11
  const WAIT_TIME = 120; // seconds
12
12
  const POLL_DELAY_SECONDS = 5;
13
13
 
14
- function findDotEnv(startDir) {
15
- let current = startDir;
16
- while (current && current !== path.dirname(current)) {
17
- const candidate = path.join(current, ".env");
18
- if (fs.existsSync(candidate)) {
19
- return candidate;
20
- }
21
- current = path.dirname(current);
22
- }
23
- const fallback = path.join(startDir, ".env");
24
- return fs.existsSync(fallback) ? fallback : null;
25
- }
26
-
27
- function parseDotEnvLine(line) {
28
- const trimmed = line.trim();
29
- if (!trimmed || trimmed.startsWith("#")) {
30
- return null;
31
- }
32
- const normalized = trimmed.startsWith("export ")
33
- ? trimmed.slice(7).trim()
34
- : trimmed;
35
- const splitIndex = normalized.indexOf("=");
36
- if (splitIndex <= 0) {
37
- return null;
38
- }
39
- const key = normalized.slice(0, splitIndex).trim();
40
- let value = normalized.slice(splitIndex + 1).trim();
41
- if (
42
- (value.startsWith('"') && value.endsWith('"')) ||
43
- (value.startsWith("'") && value.endsWith("'"))
44
- ) {
45
- value = value.slice(1, -1);
46
- }
47
- value = value.replace(/\\n/g, "\n");
48
- return { key, value };
49
- }
50
-
51
- function loadDotEnv() {
52
- const envPath = findDotEnv(process.cwd());
53
- if (!envPath) {
54
- return;
55
- }
56
- let raw;
57
- try {
58
- raw = fs.readFileSync(envPath, "utf-8");
59
- } catch {
60
- return;
61
- }
62
- raw.split(/\r?\n/).forEach((line) => {
63
- const parsed = parseDotEnvLine(line);
64
- if (!parsed || process.env[parsed.key] !== undefined) {
65
- return;
66
- }
67
- process.env[parsed.key] = parsed.value;
68
- });
69
- }
70
-
71
- function isHeadless() {
72
- if (process.env.ENVIS_CI_TOKEN) {
73
- return true;
74
- }
75
- try {
76
- return !(process.stdin.isTTY && process.stdout.isTTY);
77
- } catch {
78
- return true;
79
- }
80
- }
81
-
82
- loadDotEnv();
83
-
84
14
  function printc(text, color = "white") {
85
15
  const colorFn = chalk[color];
86
16
  if (typeof colorFn === "function") {
@@ -100,7 +30,7 @@ function getEnvUrl(varName, fallback) {
100
30
 
101
31
  const BASE_URL = getEnvUrl(
102
32
  "ENVIS_API_URL",
103
- "https://envis.onrender.com"
33
+ "https://envis-api-518186320084.us-east4.run.app"
104
34
  );
105
35
 
106
36
  const FRONTEND_URL = getEnvUrl(
@@ -276,12 +206,6 @@ async function ensureSession() {
276
206
  return;
277
207
  }
278
208
 
279
- if (isHeadless()) {
280
- throw new Error(
281
- "No cached session and headless environment detected. Set ENVIS_CI_TOKEN or run `envis login` on a machine with a browser."
282
- );
283
- }
284
-
285
209
  const { waitForAuth } = require("./auth");
286
210
  let openBrowser;
287
211
  try {