@pnpm/registry-access.client 1100.1.6 → 1100.1.8

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/CHANGELOG.md ADDED
@@ -0,0 +1,78 @@
1
+ # @pnpm/registry-access.client
2
+
3
+ ## 1100.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @pnpm/network.fetch@1100.1.6
9
+
10
+ ## 1100.1.7
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies:
15
+ - @pnpm/network.fetch@1100.1.5
16
+
17
+ ## 1100.1.6
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [1e81761]
22
+ - @pnpm/network.web-auth@1101.2.0
23
+
24
+ ## 1100.1.5
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [05b95ab]
29
+ - Updated dependencies [852d537]
30
+ - @pnpm/network.fetch@1100.1.4
31
+ - @pnpm/error@1100.0.1
32
+ - @pnpm/network.web-auth@1101.1.2
33
+
34
+ ## 1100.1.4
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies [a31faa7]
39
+ - @pnpm/network.fetch@1100.1.3
40
+ - @pnpm/network.web-auth@1101.1.1
41
+
42
+ ## 1100.1.3
43
+
44
+ ### Patch Changes
45
+
46
+ - @pnpm/network.fetch@1100.1.2
47
+
48
+ ## 1100.1.2
49
+
50
+ ### Patch Changes
51
+
52
+ - @pnpm/network.fetch@1100.1.1
53
+
54
+ ## 1100.1.1
55
+
56
+ ### Patch Changes
57
+
58
+ - Updated dependencies [60a1eec]
59
+ - @pnpm/network.fetch@1100.1.0
60
+
61
+ ## 1100.1.0
62
+
63
+ ### Minor Changes
64
+
65
+ - b1fa2d5: Fix `pnpm dist-tag add` and `pnpm dist-tag rm` against npmjs.org failing without `--otp` with `[ERR_PNPM_UNAUTHORIZED] You must be logged in to set dist-tag … "You must provide a one-time pass. Upgrade your client to npm@latest in order to use 2FA."`. pnpm now sends `npm-auth-type: web` on dist-tag writes and surfaces the resulting OTP challenge through the existing browser-based 2FA flow (the same `withOtpHandling` helper used by `pnpm publish`), so the browser opens, the user authenticates, and the dist-tag is set on retry. `--otp=<code>` continues to work via the classic flow.
66
+
67
+ ### Patch Changes
68
+
69
+ - Updated dependencies [b1fa2d5]
70
+ - Updated dependencies [2cadfb5]
71
+ - @pnpm/network.fetch@1100.0.8
72
+ - @pnpm/network.web-auth@1101.1.0
73
+
74
+ ## 1100.0.1
75
+
76
+ ### Patch Changes
77
+
78
+ - @pnpm/network.fetch@1100.0.7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/registry-access.client",
3
- "version": "1100.1.6",
3
+ "version": "1100.1.8",
4
4
  "description": "Low-level helpers for npm-registry HTTP endpoints (PUT dist-tag, PUT user, etc.)",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -27,13 +27,13 @@
27
27
  "!*.map"
28
28
  ],
29
29
  "dependencies": {
30
- "@pnpm/npm-package-arg": "^2.0.0",
31
- "@pnpm/network.web-auth": "1101.2.0",
32
30
  "@pnpm/error": "1100.0.1",
33
- "@pnpm/network.fetch": "1100.1.4"
31
+ "@pnpm/network.fetch": "1100.1.6",
32
+ "@pnpm/network.web-auth": "1101.2.0",
33
+ "@pnpm/npm-package-arg": "^2.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@pnpm/registry-access.client": "1100.1.6"
36
+ "@pnpm/registry-access.client": "1100.1.8"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=22.13"
package/lib/addUser.d.ts DELETED
@@ -1,42 +0,0 @@
1
- export interface AddUserResponse {
2
- ok: boolean;
3
- status: number;
4
- text: () => Promise<string>;
5
- json: () => Promise<unknown>;
6
- headers: {
7
- get: (name: string) => string | null;
8
- };
9
- }
10
- export interface AddUserFetch {
11
- (url: string, init: {
12
- method: 'PUT';
13
- headers: Record<string, string>;
14
- body: string;
15
- }): Promise<AddUserResponse>;
16
- }
17
- export interface AddUserOptions {
18
- username: string;
19
- password: string;
20
- email: string;
21
- registryUrl: string;
22
- fetch: AddUserFetch;
23
- otp?: string;
24
- }
25
- export interface AddUserResult {
26
- token: string;
27
- }
28
- export declare class AddUserHttpError extends Error {
29
- readonly status: number;
30
- readonly responseText: string;
31
- readonly responseJson: unknown | undefined;
32
- readonly responseHeaders: {
33
- get: (name: string) => string | null;
34
- };
35
- constructor(status: number, responseText: string, responseHeaders: {
36
- get: (name: string) => string | null;
37
- });
38
- }
39
- export declare class AddUserNoTokenError extends Error {
40
- constructor();
41
- }
42
- export declare function addUser(opts: AddUserOptions): Promise<AddUserResult>;
package/lib/addUser.js DELETED
@@ -1,54 +0,0 @@
1
- export class AddUserHttpError extends Error {
2
- status;
3
- responseText;
4
- responseJson;
5
- responseHeaders;
6
- constructor(status, responseText, responseHeaders) {
7
- super(`addUser failed (HTTP ${status}): ${responseText}`);
8
- this.name = 'AddUserHttpError';
9
- this.status = status;
10
- this.responseText = responseText;
11
- this.responseHeaders = responseHeaders;
12
- try {
13
- this.responseJson = JSON.parse(responseText);
14
- }
15
- catch {
16
- this.responseJson = undefined;
17
- }
18
- }
19
- }
20
- export class AddUserNoTokenError extends Error {
21
- constructor() {
22
- super('The registry returned a successful response but no token');
23
- this.name = 'AddUserNoTokenError';
24
- }
25
- }
26
- export async function addUser(opts) {
27
- const url = new URL(`-/user/org.couchdb.user:${encodeURIComponent(opts.username)}`, opts.registryUrl).href;
28
- const response = await opts.fetch(url, {
29
- method: 'PUT',
30
- headers: {
31
- 'content-type': 'application/json',
32
- accept: 'application/json',
33
- 'npm-auth-type': 'web',
34
- ...(opts.otp != null ? { 'npm-otp': opts.otp } : {}),
35
- },
36
- body: JSON.stringify({
37
- _id: `org.couchdb.user:${opts.username}`,
38
- name: opts.username,
39
- password: opts.password,
40
- email: opts.email,
41
- type: 'user',
42
- }),
43
- });
44
- if (!response.ok) {
45
- const text = await response.text();
46
- throw new AddUserHttpError(response.status, text, response.headers);
47
- }
48
- const body = await response.json();
49
- if (!body?.token) {
50
- throw new AddUserNoTokenError();
51
- }
52
- return { token: body.token };
53
- }
54
- //# sourceMappingURL=addUser.js.map
package/lib/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './addUser.js';
2
- export * from './setDistTag.js';
@@ -1,18 +0,0 @@
1
- import type { FetchFromRegistry } from '@pnpm/network.fetch';
2
- export type AuthType = 'web' | 'legacy';
3
- export interface SetDistTagOptions {
4
- packageName: string;
5
- version: string;
6
- distTag: string;
7
- registryUrl: string;
8
- fetchFromRegistry: FetchFromRegistry;
9
- authHeader?: string;
10
- /** Mirrors npm CLI's `auth-type` flat option: `'web'` (default) opts into the
11
- * web-OTP challenge, `'legacy'` is set automatically when the user passes
12
- * `--otp` so a classic 6-digit code can be sent. */
13
- authType?: AuthType;
14
- /** OTP token to send as `npm-otp`. May be a classic 6-digit code (legacy) or
15
- * the 64-character token returned by the web flow. */
16
- otp?: string;
17
- }
18
- export declare function setDistTag(opts: SetDistTagOptions): Promise<void>;
package/lib/setDistTag.js DELETED
@@ -1,50 +0,0 @@
1
- import { PnpmError } from '@pnpm/error';
2
- import { SyntheticOtpError } from '@pnpm/network.web-auth';
3
- import npa from '@pnpm/npm-package-arg';
4
- export async function setDistTag(opts) {
5
- const encodedName = npa(opts.packageName).escapedName;
6
- const url = new URL(`-/package/${encodedName}/dist-tags/${encodeURIComponent(opts.distTag)}`, opts.registryUrl).href;
7
- const response = await opts.fetchFromRegistry(url, {
8
- authHeaderValue: opts.authHeader,
9
- method: 'PUT',
10
- headers: {
11
- 'content-type': 'application/json',
12
- 'npm-auth-type': opts.authType ?? 'web',
13
- ...(opts.otp ? { 'npm-otp': opts.otp } : {}),
14
- },
15
- body: JSON.stringify(opts.version),
16
- });
17
- if (response.ok)
18
- return;
19
- const body = await response.text();
20
- if (response.status === 401) {
21
- throw parseAuthError(body, opts.distTag);
22
- }
23
- const action = `set dist-tag "${opts.distTag}" on`;
24
- if (response.status === 403) {
25
- throw new PnpmError('FORBIDDEN', `You do not have permission to ${action} this package. ${body}`);
26
- }
27
- throw new PnpmError('REGISTRY_ERROR', `Failed to ${action} package: ${response.status} ${response.statusText}. ${body}`);
28
- }
29
- function parseAuthError(body, distTag) {
30
- const parsed = tryParseJson(body);
31
- if (parsed != null && typeof parsed === 'object' && 'authUrl' in parsed && 'doneUrl' in parsed) {
32
- return new SyntheticOtpError({
33
- authUrl: typeof parsed.authUrl === 'string' ? parsed.authUrl : undefined,
34
- doneUrl: typeof parsed.doneUrl === 'string' ? parsed.doneUrl : undefined,
35
- });
36
- }
37
- if (/one-time pass/i.test(body)) {
38
- return new SyntheticOtpError(undefined);
39
- }
40
- return new PnpmError('UNAUTHORIZED', `You must be logged in to set dist-tag "${distTag}" on packages. ${body}`);
41
- }
42
- function tryParseJson(body) {
43
- try {
44
- return JSON.parse(body);
45
- }
46
- catch {
47
- return undefined;
48
- }
49
- }
50
- //# sourceMappingURL=setDistTag.js.map