@hadoku/dev-vault 1.5.0 → 1.5.2

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/LICENSE +15 -0
  2. package/README.md +16 -1
  3. package/login.mjs +21 -3
  4. package/package.json +4 -2
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 WolffM
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -16,7 +16,22 @@ The shim used to live only inside the `hadoku_site` repo at
16
16
  clone `hadoku_site` as a sibling just to reach the vault. Publishing it removes
17
17
  that coupling: a child repo depends on a versioned package, not a sibling repo.
18
18
 
19
- ## Install (one-time, per machine)
19
+ ## Outside the fleet: `@hadoku/dev-vault`
20
+
21
+ The same package is published to the public npm registry as
22
+ `@hadoku/dev-vault`, so someone holding a service grant can use it with no
23
+ GitHub token and no clone of anything:
24
+
25
+ ```sh
26
+ npx @hadoku/dev-vault login # once a week: your own 7-day credential
27
+ npx @hadoku/dev-vault --check # what your .devvault.json can read
28
+ npx @hadoku/dev-vault -- <command>
29
+ ```
30
+
31
+ Everything below applies to it unchanged. It reaches the broker at
32
+ `https://hadoku.me/mgmt`; nothing else needs to be reachable.
33
+
34
+ ## Install inside the fleet (one-time, per machine)
20
35
 
21
36
  The package lives on GitHub Packages under the `@wolffm` scope. GitHub Packages
22
37
  requires auth even to read, so add to your `~/.npmrc`:
package/login.mjs CHANGED
@@ -21,8 +21,23 @@ import { mainCheckoutOf } from './key-file.mjs';
21
21
  export const EDGE = 'https://hadoku.me';
22
22
  const FILE = '.devvault.local.json';
23
23
  const POLL_MS = 3000;
24
+ // A request lives a day (edge DEVICE_TTL_S), so the approver can get to it
25
+ // later. Poll briskly while someone is likely approving right now, then slowly:
26
+ // a day at 3s would be ~29k requests for one abandoned login.
27
+ const BRISK_MS = 10 * 60 * 1000;
28
+ const SLOW_POLL_MS = 30_000;
24
29
  const DAY_MS = 24 * 60 * 60 * 1000;
25
30
 
31
+ /** 86_400_000 -> "24 hours", 600_000 -> "10 minutes". */
32
+ export function spell(ms) {
33
+ const min = Math.round(ms / 60_000);
34
+ if (min % 60 === 0) {
35
+ const h = min / 60;
36
+ return `${h} hour${h === 1 ? '' : 's'}`;
37
+ }
38
+ return `${min} minute${min === 1 ? '' : 's'}`;
39
+ }
40
+
26
41
  function runGit(cwd, args) {
27
42
  const r = spawnSync('git', args, { cwd, encoding: 'utf-8' });
28
43
  return r.status === 0 ? r.stdout.trim() : '';
@@ -94,9 +109,12 @@ export async function login({
94
109
  log(`[dev-vault] code ${userCode} · ${host}${repo ? ` · ${repo}` : ''}`);
95
110
  log('[dev-vault] waiting for approval…');
96
111
 
97
- const deadline = now() + (Number(expiresIn) || 600) * 1000;
112
+ const ttlMs = (Number(expiresIn) || 600) * 1000;
113
+ const startedAt = now();
114
+ const deadline = startedAt + ttlMs;
115
+ log(`[dev-vault] (the link stays valid for ${spell(ttlMs)}; leave this running)`);
98
116
  while (now() < deadline) {
99
- await sleep(POLL_MS);
117
+ await sleep(now() - startedAt < BRISK_MS ? POLL_MS : SLOW_POLL_MS);
100
118
  let polled;
101
119
  try {
102
120
  polled = await postJson(fetchImpl, `${base}/auth/service-access/device/poll`, {
@@ -129,6 +147,6 @@ export async function login({
129
147
  );
130
148
  return 0;
131
149
  }
132
- log('[dev-vault] login: nobody approved within 10 minutes. Run `dev-vault login` again.');
150
+ log(`[dev-vault] login: nobody approved within ${spell(ttlMs)}. Run \`dev-vault login\` again.`);
133
151
  return 1;
134
152
  }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/dev-vault",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
+ "gitHead": "9010a68c19d319334869bb549bc90acc1ee4d0ca",
4
5
  "description": "Local-dev vault-broker shim — fetches secrets from the hadoku mgmt-api broker and execs a child command with them in process.env. Works for any consuming repo (Node or non-Node).",
5
6
  "type": "module",
6
7
  "bin": {
@@ -12,7 +13,8 @@
12
13
  "key-file.mjs",
13
14
  "install-id.mjs",
14
15
  "login.mjs",
15
- "README.md"
16
+ "README.md",
17
+ "LICENSE"
16
18
  ],
17
19
  "repository": {
18
20
  "type": "git",