@pnpm/registry-access.client 1100.1.7 → 1100.1.9
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 +14 -0
- package/package.json +3 -3
- package/lib/addUser.d.ts +0 -42
- package/lib/addUser.js +0 -54
- package/lib/index.d.ts +0 -2
- package/lib/setDistTag.d.ts +0 -18
- package/lib/setDistTag.js +0 -50
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @pnpm/registry-access.client
|
|
2
2
|
|
|
3
|
+
## 1100.1.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies:
|
|
8
|
+
- @pnpm/network.fetch@1100.1.7
|
|
9
|
+
|
|
10
|
+
## 1100.1.8
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies:
|
|
15
|
+
- @pnpm/network.fetch@1100.1.6
|
|
16
|
+
|
|
3
17
|
## 1100.1.7
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/registry-access.client",
|
|
3
|
-
"version": "1100.1.
|
|
3
|
+
"version": "1100.1.9",
|
|
4
4
|
"description": "Low-level helpers for npm-registry HTTP endpoints (PUT dist-tag, PUT user, etc.)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@pnpm/error": "1100.0.1",
|
|
31
|
-
"@pnpm/network.fetch": "1100.1.
|
|
31
|
+
"@pnpm/network.fetch": "1100.1.7",
|
|
32
32
|
"@pnpm/network.web-auth": "1101.2.0",
|
|
33
33
|
"@pnpm/npm-package-arg": "^2.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@pnpm/registry-access.client": "1100.1.
|
|
36
|
+
"@pnpm/registry-access.client": "1100.1.9"
|
|
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
package/lib/setDistTag.d.ts
DELETED
|
@@ -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
|