@vltpkg/registry-client 1.0.0-rc.33 → 1.0.0-rc.34
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/dist/otplease.js +12 -2
- package/package.json +9 -9
package/dist/otplease.js
CHANGED
|
@@ -2,6 +2,7 @@ import { error } from '@vltpkg/error-cause';
|
|
|
2
2
|
import { getWebAuthChallenge } from "./web-auth-challenge.js";
|
|
3
3
|
import { urlOpen } from '@vltpkg/url-open';
|
|
4
4
|
import { createInterface } from 'node:readline/promises';
|
|
5
|
+
import { gunzipSync } from 'node:zlib';
|
|
5
6
|
// eslint-disable-next-line no-console
|
|
6
7
|
const log = (msg) => console.error(msg);
|
|
7
8
|
const question = async (text) => {
|
|
@@ -14,6 +15,13 @@ const question = async (text) => {
|
|
|
14
15
|
return answer;
|
|
15
16
|
};
|
|
16
17
|
const otpChallengeNotice = /^Open ([^ ]+) to use your security key for authentication or enter OTP from your authenticator app/i;
|
|
18
|
+
const responseBodyText = async (response) => {
|
|
19
|
+
const contentEncoding = String(response.headers['content-encoding'] ?? '');
|
|
20
|
+
if (/\bgzip\b/i.test(contentEncoding)) {
|
|
21
|
+
return gunzipSync(await response.body.arrayBuffer()).toString();
|
|
22
|
+
}
|
|
23
|
+
return await response.body.text();
|
|
24
|
+
};
|
|
17
25
|
export const otplease = async (client, options, response) => {
|
|
18
26
|
const waHeader = String(response.headers['www-authenticate'] ?? '');
|
|
19
27
|
const wwwAuth = new Set(waHeader ? waHeader.toLowerCase().split(/,\s*/) : []);
|
|
@@ -24,7 +32,9 @@ export const otplease = async (client, options, response) => {
|
|
|
24
32
|
}
|
|
25
33
|
if (wwwAuth.has('otp')) {
|
|
26
34
|
// do a web auth opener to get otp token
|
|
27
|
-
const challenge = getWebAuthChallenge(await response
|
|
35
|
+
const challenge = getWebAuthChallenge(await responseBodyText(response)
|
|
36
|
+
.then(text => JSON.parse(text))
|
|
37
|
+
.catch(() => null));
|
|
28
38
|
if (challenge) {
|
|
29
39
|
return {
|
|
30
40
|
retry: {
|
|
@@ -61,7 +71,7 @@ export const otplease = async (client, options, response) => {
|
|
|
61
71
|
// Consume the body to check if it's prompting for OTP.
|
|
62
72
|
// We must return the consumed text so the caller doesn't try to
|
|
63
73
|
// re-read from the already-drained stream.
|
|
64
|
-
const text = await response
|
|
74
|
+
const text = await responseBodyText(response).catch(() => '');
|
|
65
75
|
if (text.toLowerCase().includes('one-time pass')) {
|
|
66
76
|
return {
|
|
67
77
|
retry: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/registry-client",
|
|
3
3
|
"description": "Fetch package artifacts and metadata from registries",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.34",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"url": "http://vlt.sh"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@vltpkg/cache": "1.0.0-rc.
|
|
17
|
-
"@vltpkg/cache-unzip": "1.0.0-rc.
|
|
18
|
-
"@vltpkg/error-cause": "1.0.0-rc.
|
|
19
|
-
"@vltpkg/keychain": "1.0.0-rc.
|
|
20
|
-
"@vltpkg/output": "1.0.0-rc.
|
|
21
|
-
"@vltpkg/types": "1.0.0-rc.
|
|
22
|
-
"@vltpkg/url-open": "1.0.0-rc.
|
|
23
|
-
"@vltpkg/xdg": "1.0.0-rc.
|
|
16
|
+
"@vltpkg/cache": "1.0.0-rc.34",
|
|
17
|
+
"@vltpkg/cache-unzip": "1.0.0-rc.34",
|
|
18
|
+
"@vltpkg/error-cause": "1.0.0-rc.34",
|
|
19
|
+
"@vltpkg/keychain": "1.0.0-rc.34",
|
|
20
|
+
"@vltpkg/output": "1.0.0-rc.34",
|
|
21
|
+
"@vltpkg/types": "1.0.0-rc.34",
|
|
22
|
+
"@vltpkg/url-open": "1.0.0-rc.34",
|
|
23
|
+
"@vltpkg/xdg": "1.0.0-rc.34",
|
|
24
24
|
"cache-control-parser": "^2.0.6",
|
|
25
25
|
"package-json-from-dist": "^1.0.1",
|
|
26
26
|
"undici": "^7.16.0"
|