@hadoku/dev-vault 1.5.4 → 1.5.5
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/login.mjs +18 -2
- package/package.json +2 -2
package/login.mjs
CHANGED
|
@@ -73,10 +73,22 @@ async function postJson(fetchImpl, url, body) {
|
|
|
73
73
|
headers: { 'Content-Type': 'application/json' },
|
|
74
74
|
body: JSON.stringify(body),
|
|
75
75
|
});
|
|
76
|
-
const data = await res.json().catch(() =>
|
|
77
|
-
|
|
76
|
+
const data = await res.json().catch(() => null);
|
|
77
|
+
// Cloudflare's bot protection answers before hadoku.me sees the request:
|
|
78
|
+
// a 403 marked `cf-mitigated`, or one whose body is not our JSON. It
|
|
79
|
+
// refuses networks, not people (cloud VMs, Codespaces, some VPNs), so
|
|
80
|
+
// nothing about the person's grant or key is involved.
|
|
81
|
+
const blocked =
|
|
82
|
+
res.status === 403 && (res.headers?.get?.('cf-mitigated') != null || data === null);
|
|
83
|
+
return { status: res.status, data: data ?? {}, blocked };
|
|
78
84
|
}
|
|
79
85
|
|
|
86
|
+
const BLOCKED = [
|
|
87
|
+
'[dev-vault] login: Cloudflare refused this network before hadoku.me saw the request.',
|
|
88
|
+
'[dev-vault] Its bot protection blocks cloud servers, Codespaces and some VPNs.',
|
|
89
|
+
'[dev-vault] Run this from a home or office connection (or with the VPN off).',
|
|
90
|
+
];
|
|
91
|
+
|
|
80
92
|
/**
|
|
81
93
|
* Run the login. Resolves to the process exit code: 0 written, 1 refused,
|
|
82
94
|
* expired or unreachable.
|
|
@@ -99,6 +111,10 @@ export async function login({
|
|
|
99
111
|
log(`[dev-vault] login: cannot reach ${base}: ${err instanceof Error ? err.message : err}`);
|
|
100
112
|
return 1;
|
|
101
113
|
}
|
|
114
|
+
if (started.blocked) {
|
|
115
|
+
for (const line of BLOCKED) log(line);
|
|
116
|
+
return 1;
|
|
117
|
+
}
|
|
102
118
|
if (started.status !== 200) {
|
|
103
119
|
log(`[dev-vault] login: ${started.data.error ?? `HTTP ${started.status}`}`);
|
|
104
120
|
return 1;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/dev-vault",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "1.5.5",
|
|
4
|
+
"gitHead": "00833df2e386ce613a5126f985cdbe6c42e649c0",
|
|
5
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).",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|