@vltpkg/registry-client 0.0.0-17 → 0.0.0-18

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.
@@ -1 +1 @@
1
- {"version":3,"file":"otplease.d.ts","sourceRoot":"","sources":["../../src/otplease.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EACV,cAAc,EACd,4BAA4B,EAC7B,MAAM,YAAY,CAAA;AAWnB,eAAO,MAAM,QAAQ,WACX,cAAc,WACb,4BAA4B,YAC3B,UAAU,CAAC,YAAY,KAChC,OAAO,CAAC,4BAA4B,GAAG,SAAS,CAuDlD,CAAA"}
1
+ {"version":3,"file":"otplease.d.ts","sourceRoot":"","sources":["../../src/otplease.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EACV,cAAc,EACd,4BAA4B,EAC7B,MAAM,YAAY,CAAA;AAqBnB,eAAO,MAAM,QAAQ,WACX,cAAc,WACb,4BAA4B,YAC3B,UAAU,CAAC,YAAY,KAChC,OAAO,CAAC,4BAA4B,GAAG,SAAS,CAuDlD,CAAA"}
@@ -4,6 +4,15 @@ import { urlOpen } from '@vltpkg/url-open';
4
4
  import { createInterface } from 'node:readline/promises';
5
5
  // eslint-disable-next-line no-console
6
6
  const log = (msg) => console.error(msg);
7
+ const question = async (text) => {
8
+ const rl = createInterface({
9
+ input: process.stdin,
10
+ output: process.stdout,
11
+ });
12
+ const answer = await rl.question(text);
13
+ rl.close();
14
+ return answer;
15
+ };
7
16
  const otpChallengeNotice = /^Open ([^ ]+) to use your security key for authentication or enter OTP from your authenticator app/i;
8
17
  export const otplease = async (client, options, response) => {
9
18
  const waHeader = String(response.headers['www-authenticate'] ?? '');
@@ -15,7 +24,7 @@ export const otplease = async (client, options, response) => {
15
24
  }
16
25
  if (wwwAuth.has('otp')) {
17
26
  // do a web auth opener to get otp token
18
- const challenge = getWebAuthChallenge(await response.body.json());
27
+ const challenge = getWebAuthChallenge(await response.body.json().catch(() => null));
19
28
  if (challenge) {
20
29
  return {
21
30
  ...options,
@@ -29,11 +38,10 @@ export const otplease = async (client, options, response) => {
29
38
  if (match?.[1]) {
30
39
  await urlOpen(match[1]);
31
40
  log(notice);
32
- const otp = await createInterface({
33
- input: process.stdin,
34
- output: process.stdout,
35
- }).question('OTP: ');
36
- return { ...options, otp };
41
+ return {
42
+ ...options,
43
+ otp: await question('OTP: '),
44
+ };
37
45
  }
38
46
  }
39
47
  throw error('Unrecognized OTP authentication challenge', {
@@ -44,13 +52,12 @@ export const otplease = async (client, options, response) => {
44
52
  throw error('Unknown authentication challenge', { response });
45
53
  }
46
54
  // see if the body is prompting for otp
47
- const text = await response.body.text();
55
+ const text = await response.body.text().catch(() => '');
48
56
  if (text.toLowerCase().includes('one-time pass')) {
49
- const otp = await createInterface({
50
- input: process.stdin,
51
- output: process.stdout,
52
- }).question(text);
53
- return { ...options, otp };
57
+ return {
58
+ ...options,
59
+ otp: await question(text),
60
+ };
54
61
  }
55
62
  };
56
63
  //# sourceMappingURL=otplease.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"otplease.js","sourceRoot":"","sources":["../../src/otplease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,sCAAsC;AACtC,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAE/C,MAAM,kBAAkB,GACtB,qGAAqG,CAAA;AAEvG,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B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KAAK;oBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;gBACpB,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,CAAA;YAC5B,CAAC;QACH,CAAC;QAED,MAAM,KAAK,CAAC,2CAA2C,EAAE;YACvD,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,KAAK,CAAC,kCAAkC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC/D,CAAC;IAED,uCAAuC;IACvC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IACvC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QACjD,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC;YAChC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACjB,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,CAAA;IAC5B,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { Dispatcher } from 'undici'\nimport type {\n RegistryClient,\n RegistryClientRequestOptions,\n} from './index.ts'\nimport { getWebAuthChallenge } from './web-auth-challenge.ts'\nimport { urlOpen } from '@vltpkg/url-open'\nimport { createInterface } from 'node:readline/promises'\n\n// eslint-disable-next-line no-console\nconst log = (msg: string) => console.error(msg)\n\nconst otpChallengeNotice =\n /^Open ([^ ]+) to use your security key for authentication or enter OTP from your authenticator app/i\n\nexport const otplease = async (\n client: RegistryClient,\n options: RegistryClientRequestOptions,\n response: Dispatcher.ResponseData,\n): Promise<RegistryClientRequestOptions | undefined> => {\n const waHeader = String(response.headers['www-authenticate'] ?? '')\n const wwwAuth = new Set(\n waHeader ? waHeader.toLowerCase().split(/,\\s*/) : [],\n )\n\n if (wwwAuth.has('ipaddress')) {\n throw error('Authorization is not allowed from your ip address', {\n response,\n })\n }\n\n if (wwwAuth.has('otp')) {\n // do a web auth opener to get otp token\n const challenge = getWebAuthChallenge(await response.body.json())\n if (challenge) {\n return {\n ...options,\n otp: (await client.webAuthOpener(challenge)).token,\n }\n }\n\n const { 'npm-notice': npmNotice } = response.headers\n if (npmNotice) {\n const notice = String(npmNotice)\n const match = otpChallengeNotice.exec(notice)\n if (match?.[1]) {\n await urlOpen(match[1])\n log(notice)\n const otp = await createInterface({\n input: process.stdin,\n output: process.stdout,\n }).question('OTP: ')\n return { ...options, otp }\n }\n }\n\n throw error('Unrecognized OTP authentication challenge', {\n response,\n })\n }\n\n if (wwwAuth.size) {\n throw error('Unknown authentication challenge', { response })\n }\n\n // see if the body is prompting for otp\n const text = await response.body.text()\n if (text.toLowerCase().includes('one-time pass')) {\n const otp = await createInterface({\n input: process.stdin,\n output: process.stdout,\n }).question(text)\n return { ...options, otp }\n }\n}\n"]}
1
+ {"version":3,"file":"otplease.js","sourceRoot":"","sources":["../../src/otplease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,sCAAsC;AACtC,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAE/C,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAY,EAAmB,EAAE;IACvD,MAAM,EAAE,GAAG,eAAe,CAAC;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;K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C,CAAA;YAChC,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC7C,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACf,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;gBACvB,GAAG,CAAC,MAAM,CAAC,CAAA;gBACX,OAAO;oBACL,GAAG,OAAO;oBACV,GAAG,EAAE,MAAM,QAAQ,CAAC,OAAO,CAAC;iBAC7B,CAAA;YACH,CAAC;QACH,CAAC;QAED,MAAM,KAAK,CAAC,2CAA2C,EAAE;YACvD,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,KAAK,CAAC,kCAAkC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC/D,CAAC;IAED,uCAAuC;IACvC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;IACvD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QACjD,OAAO;YACL,GAAG,OAAO;YACV,GAAG,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC;SAC1B,CAAA;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { Dispatcher } from 'undici'\nimport type {\n RegistryClient,\n RegistryClientRequestOptions,\n} from './index.ts'\nimport { getWebAuthChallenge } from './web-auth-challenge.ts'\nimport { urlOpen } from '@vltpkg/url-open'\nimport { createInterface } from 'node:readline/promises'\n\n// eslint-disable-next-line no-console\nconst log = (msg: string) => console.error(msg)\n\nconst question = async (text: string): Promise<string> => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n })\n const answer = await rl.question(text)\n rl.close()\n return answer\n}\n\nconst otpChallengeNotice =\n /^Open ([^ ]+) to use your security key for authentication or enter OTP from your authenticator app/i\n\nexport const otplease = async (\n client: RegistryClient,\n options: RegistryClientRequestOptions,\n response: Dispatcher.ResponseData,\n): Promise<RegistryClientRequestOptions | undefined> => {\n const waHeader = String(response.headers['www-authenticate'] ?? '')\n const wwwAuth = new Set(\n waHeader ? waHeader.toLowerCase().split(/,\\s*/) : [],\n )\n\n if (wwwAuth.has('ipaddress')) {\n throw error('Authorization is not allowed from your ip address', {\n response,\n })\n }\n\n if (wwwAuth.has('otp')) {\n // do a web auth opener to get otp token\n const challenge = getWebAuthChallenge(\n await response.body.json().catch(() => null),\n )\n if (challenge) {\n return {\n ...options,\n otp: (await client.webAuthOpener(challenge)).token,\n }\n }\n\n const { 'npm-notice': npmNotice } = response.headers\n if (npmNotice) {\n const notice = String(npmNotice)\n const match = otpChallengeNotice.exec(notice)\n if (match?.[1]) {\n await urlOpen(match[1])\n log(notice)\n return {\n ...options,\n otp: await question('OTP: '),\n }\n }\n }\n\n throw error('Unrecognized OTP authentication challenge', {\n response,\n })\n }\n\n if (wwwAuth.size) {\n throw error('Unknown authentication challenge', { response })\n }\n\n // see if the body is prompting for otp\n const text = await response.body.text().catch(() => '')\n if (text.toLowerCase().includes('one-time pass')) {\n return {\n ...options,\n otp: await question(text),\n }\n }\n}\n"]}
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": "0.0.0-17",
4
+ "version": "0.0.0-18",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -23,14 +23,14 @@
23
23
  "cache-control-parser": "^2.0.6",
24
24
  "package-json-from-dist": "^1.0.1",
25
25
  "undici": "^7.10.0",
26
- "@vltpkg/cache": "0.0.0-17",
27
- "@vltpkg/cache-unzip": "0.0.0-17",
28
- "@vltpkg/error-cause": "0.0.0-17",
29
- "@vltpkg/keychain": "0.0.0-17",
30
- "@vltpkg/output": "0.0.0-17",
31
- "@vltpkg/types": "0.0.0-17",
32
- "@vltpkg/xdg": "0.0.0-17",
33
- "@vltpkg/url-open": "0.0.0-17"
26
+ "@vltpkg/cache": "0.0.0-18",
27
+ "@vltpkg/error-cause": "0.0.0-18",
28
+ "@vltpkg/cache-unzip": "0.0.0-18",
29
+ "@vltpkg/output": "0.0.0-18",
30
+ "@vltpkg/types": "0.0.0-18",
31
+ "@vltpkg/url-open": "0.0.0-18",
32
+ "@vltpkg/keychain": "0.0.0-18",
33
+ "@vltpkg/xdg": "0.0.0-18"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@eslint/js": "^9.28.0",