@vltpkg/registry-client 1.0.6 → 1.0.7
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/index.d.ts +8 -2
- package/dist/index.js +17 -3
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -131,12 +131,18 @@ export declare class RegistryClient {
|
|
|
131
131
|
*/
|
|
132
132
|
logout(registry: string): Promise<void>;
|
|
133
133
|
/**
|
|
134
|
-
* Log into the registry specified
|
|
134
|
+
* Log into the registry specified.
|
|
135
|
+
*
|
|
136
|
+
* When a list of registries is provided, the web login flow runs once
|
|
137
|
+
* against the first of them, and the token it returns is saved for all
|
|
138
|
+
* of them. This is for registries that share credentials -- like the
|
|
139
|
+
* ones under a single vlt.io account -- where opening the browser once
|
|
140
|
+
* per registry would just be asking for the same token again.
|
|
135
141
|
*
|
|
136
142
|
* Does not return the token or expose it, just saves to the auth keychain
|
|
137
143
|
* and returns void if it worked. Otherwise, error is raised.
|
|
138
144
|
*/
|
|
139
|
-
login(registry: string): Promise<void>;
|
|
145
|
+
login(registry: string | string[]): Promise<void>;
|
|
140
146
|
/**
|
|
141
147
|
* Given a {@link WebAuthChallenge}, open the `authUrl` in a browser and
|
|
142
148
|
* hang on the `doneUrl` until it returns a {@link TokenResponse} object.
|
package/dist/index.js
CHANGED
|
@@ -154,12 +154,23 @@ export class RegistryClient {
|
|
|
154
154
|
await deleteToken(registry, this.identity);
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
|
-
* Log into the registry specified
|
|
157
|
+
* Log into the registry specified.
|
|
158
|
+
*
|
|
159
|
+
* When a list of registries is provided, the web login flow runs once
|
|
160
|
+
* against the first of them, and the token it returns is saved for all
|
|
161
|
+
* of them. This is for registries that share credentials -- like the
|
|
162
|
+
* ones under a single vlt.io account -- where opening the browser once
|
|
163
|
+
* per registry would just be asking for the same token again.
|
|
158
164
|
*
|
|
159
165
|
* Does not return the token or expose it, just saves to the auth keychain
|
|
160
166
|
* and returns void if it worked. Otherwise, error is raised.
|
|
161
167
|
*/
|
|
162
168
|
async login(registry) {
|
|
169
|
+
const registries = Array.isArray(registry) ? registry : [registry];
|
|
170
|
+
const [first] = registries;
|
|
171
|
+
if (!first) {
|
|
172
|
+
throw error('No registry provided to log in against');
|
|
173
|
+
}
|
|
163
174
|
// - make POST to '/-/v1/login'
|
|
164
175
|
// - include a body of {} and npm-auth-type:web
|
|
165
176
|
// - get a {doneUrl, authUrl}
|
|
@@ -167,7 +178,7 @@ export class RegistryClient {
|
|
|
167
178
|
// - hang on the doneUrl until done
|
|
168
179
|
//
|
|
169
180
|
// if that fails: fall back to couchdb login
|
|
170
|
-
const webLoginURL = new URL('-/v1/login', registryBase(
|
|
181
|
+
const webLoginURL = new URL('-/v1/login', registryBase(first));
|
|
171
182
|
const response = await this.request(webLoginURL, {
|
|
172
183
|
method: 'POST',
|
|
173
184
|
useCache: false,
|
|
@@ -181,7 +192,10 @@ export class RegistryClient {
|
|
|
181
192
|
const challenge = getWebAuthChallenge(response.json());
|
|
182
193
|
if (challenge) {
|
|
183
194
|
const result = await this.webAuthOpener(challenge);
|
|
184
|
-
|
|
195
|
+
// sequential, because they all write to the same keychain file
|
|
196
|
+
for (const reg of registries) {
|
|
197
|
+
await setToken(reg, `Bearer ${result.token}`, this.identity);
|
|
198
|
+
}
|
|
185
199
|
return;
|
|
186
200
|
}
|
|
187
201
|
}
|
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.
|
|
4
|
+
"version": "1.0.7",
|
|
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.
|
|
17
|
-
"@vltpkg/cache-unzip": "1.0.
|
|
18
|
-
"@vltpkg/error-cause": "1.0.
|
|
19
|
-
"@vltpkg/keychain": "1.0.
|
|
20
|
-
"@vltpkg/output": "1.0.
|
|
21
|
-
"@vltpkg/types": "1.0.
|
|
22
|
-
"@vltpkg/url-open": "1.0.
|
|
23
|
-
"@vltpkg/xdg": "1.0.
|
|
16
|
+
"@vltpkg/cache": "1.0.7",
|
|
17
|
+
"@vltpkg/cache-unzip": "1.0.7",
|
|
18
|
+
"@vltpkg/error-cause": "1.0.7",
|
|
19
|
+
"@vltpkg/keychain": "1.0.7",
|
|
20
|
+
"@vltpkg/output": "1.0.7",
|
|
21
|
+
"@vltpkg/types": "1.0.7",
|
|
22
|
+
"@vltpkg/url-open": "1.0.7",
|
|
23
|
+
"@vltpkg/xdg": "1.0.7",
|
|
24
24
|
"cache-control-parser": "^2.0.6",
|
|
25
25
|
"package-json-from-dist": "^1.0.1",
|
|
26
26
|
"undici": "^7.16.0"
|