@vltpkg/registry-client 0.0.0-3 → 0.0.0-31
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/README.md +50 -53
- package/dist/esm/cache-entry.d.ts +84 -14
- package/dist/esm/cache-entry.d.ts.map +1 -1
- package/dist/esm/cache-entry.js +284 -90
- package/dist/esm/cache-entry.js.map +1 -1
- package/dist/esm/cache-revalidate.d.ts +2 -0
- package/dist/esm/cache-revalidate.d.ts.map +1 -0
- package/dist/esm/cache-revalidate.js +66 -0
- package/dist/esm/cache-revalidate.js.map +1 -0
- package/dist/esm/handle-304-response.js +1 -1
- package/dist/esm/handle-304-response.js.map +1 -1
- package/dist/esm/index.d.ts +40 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +100 -55
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/otplease.d.ts.map +1 -1
- package/dist/esm/otplease.js +33 -25
- package/dist/esm/otplease.js.map +1 -1
- package/dist/esm/raw-header.d.ts +3 -3
- package/dist/esm/raw-header.d.ts.map +1 -1
- package/dist/esm/raw-header.js +12 -11
- package/dist/esm/raw-header.js.map +1 -1
- package/dist/esm/redirect.d.ts +1 -1
- package/dist/esm/redirect.d.ts.map +1 -1
- package/dist/esm/redirect.js +5 -1
- package/dist/esm/redirect.js.map +1 -1
- package/dist/esm/revalidate.d.ts +5 -0
- package/dist/esm/revalidate.d.ts.map +1 -0
- package/dist/esm/revalidate.js +55 -0
- package/dist/esm/revalidate.js.map +1 -0
- package/dist/esm/set-raw-header.d.ts +1 -1
- package/dist/esm/set-raw-header.d.ts.map +1 -1
- package/dist/esm/set-raw-header.js +6 -4
- package/dist/esm/set-raw-header.js.map +1 -1
- package/dist/esm/string-encoding.d.ts +9 -0
- package/dist/esm/string-encoding.d.ts.map +1 -0
- package/dist/esm/string-encoding.js +25 -0
- package/dist/esm/string-encoding.js.map +1 -0
- package/dist/esm/token-response.d.ts +1 -1
- package/dist/esm/token-response.d.ts.map +1 -1
- package/dist/esm/token-response.js +5 -2
- package/dist/esm/token-response.js.map +1 -1
- package/dist/esm/web-auth-challenge.d.ts +2 -2
- package/dist/esm/web-auth-challenge.d.ts.map +1 -1
- package/dist/esm/web-auth-challenge.js +13 -6
- package/dist/esm/web-auth-challenge.js.map +1 -1
- package/package.json +20 -20
package/dist/esm/redirect.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { RegistryClientRequestOptions } from './index.ts';
|
|
|
3
3
|
export type RedirectStatus = 301 | 302 | 303 | 307 | 308;
|
|
4
4
|
export type RedirectResponse = CacheEntry & {
|
|
5
5
|
statusCode: RedirectStatus;
|
|
6
|
-
getHeader(key: 'location'):
|
|
6
|
+
getHeader(key: 'location'): Uint8Array | undefined;
|
|
7
7
|
};
|
|
8
8
|
export declare const isRedirect: (response: CacheEntry) => response is RedirectResponse;
|
|
9
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../../src/redirect.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAA;AAE9D,MAAM,MAAM,cAAc,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAIxD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG;IAC1C,UAAU,EAAE,cAAc,CAAA;IAC1B,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../../src/redirect.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAA;AAE9D,MAAM,MAAM,cAAc,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAIxD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG;IAC1C,UAAU,EAAE,cAAc,CAAA;IAC1B,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,GAAG,SAAS,CAAA;CACnD,CAAA;AAED,eAAO,MAAM,UAAU,aACX,UAAU,KACnB,QAAQ,IAAI,gBAE2B,CAAA;AAE1C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,YACV,4BAA4B,YAC3B,gBAAgB,QACpB,GAAG,KACR,EAAE,GAAG,CAAC,GAAG,EAAE,4BAA4B,CA6CzC,CAAA"}
|
package/dist/esm/redirect.js
CHANGED
|
@@ -27,7 +27,11 @@ export const redirect = (options, response, from) => {
|
|
|
27
27
|
url: from,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
const location =
|
|
30
|
+
const location = response.getHeaderString('location');
|
|
31
|
+
/* c8 ignore start */
|
|
32
|
+
if (!location)
|
|
33
|
+
throw error('Location header missing from redirect response');
|
|
34
|
+
/* c8 ignore stop */
|
|
31
35
|
const nextURL = new URL(location, from);
|
|
32
36
|
if (redirections.has(String(nextURL))) {
|
|
33
37
|
throw error('Redirection cycle detected', {
|
package/dist/esm/redirect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../src/redirect.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAEpE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAO3D,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,QAAoB,EACU,EAAE,CAChC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC;IACzC,CAAC,CAAC,QAAQ,CAAC,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YACT,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["// given a RegistryClientOptions object, and a redirection response,\n\nimport { error } from '@vltpkg/error-cause'\nimport type { CacheEntry } from './cache-entry.ts'\nimport type { RegistryClientRequestOptions } from './index.ts'\n\nexport type RedirectStatus = 301 | 302 | 303 | 307 | 308\n\nconst redirectStatuses = new Set([301, 302, 303, 307, 308])\n\nexport type RedirectResponse = CacheEntry & {\n statusCode: RedirectStatus\n getHeader(key: 'location'): Uint8Array | undefined\n}\n\nexport const isRedirect = (\n response: CacheEntry,\n): response is RedirectResponse =>\n redirectStatuses.has(response.statusCode) &&\n !!response.getHeader('location')?.length\n\n/**\n * If this response is allowed to follow the redirect (because max has not\n * been hit, and the new location has not been seen already), then return\n * the [url, options] to use for the subsequent request.\n *\n * Return [] if the response should be returned as-is.\n *\n * Throws an error if maxRedirections is hit or the redirections set already\n * contains the new location.\n *\n * Ensure that the response is in fact a redirection first, by calling\n * {@link isRedirect} on it.\n */\nexport const redirect = (\n options: RegistryClientRequestOptions,\n response: RedirectResponse,\n from: URL,\n): [] | [URL, RegistryClientRequestOptions] => {\n const { redirections = new Set<string>(), maxRedirections = 10 } =\n options\n if (maxRedirections <= 0) return []\n if (redirections.size >= maxRedirections) {\n throw error('Maximum redirections exceeded', {\n max: maxRedirections,\n found: [...redirections],\n url: from,\n })\n }\n const location = response.getHeaderString('location')\n /* c8 ignore start */\n if (!location)\n throw error('Location header missing from redirect response')\n /* c8 ignore stop */\n const nextURL = new URL(location, from)\n if (redirections.has(String(nextURL))) {\n throw error('Redirection cycle detected', {\n max: maxRedirections,\n found: [...redirections],\n url: from,\n })\n }\n const nextOptions: RegistryClientRequestOptions = {\n ...options,\n redirections,\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- thats why we are deleting it\n delete nextOptions.path\n redirections.add(String(nextURL))\n switch (response.statusCode) {\n case 303: {\n // drop body, change method to GET\n nextOptions.method = 'GET'\n nextOptions.body = undefined\n // fallthrough\n }\n case 301:\n case 302: // some user agents treat as 303, but they're wrong\n case 307:\n case 308: {\n return [nextURL, nextOptions]\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revalidate.d.ts","sourceRoot":"","sources":["../../src/revalidate.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,wBAAwB,QAAuB,CAAA;AAM5D,eAAO,MAAM,IAAI,WAAkB,MAAM;;sBA8CxC,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// This needs to live in the same workspace as the RegistryClient, because
|
|
2
|
+
// otherwise we have a cyclical dependency cycle of dependencies in a cycle,
|
|
3
|
+
// which is even more cyclical than this description describing it.
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { RegistryClient } from "./index.js";
|
|
6
|
+
export const __CODE_SPLIT_SCRIPT_NAME = import.meta.filename;
|
|
7
|
+
const isMain = (path) => path === __CODE_SPLIT_SCRIPT_NAME ||
|
|
8
|
+
path === pathToFileURL(__CODE_SPLIT_SCRIPT_NAME).toString();
|
|
9
|
+
export const main = async (cache, input = process.stdin) => {
|
|
10
|
+
if (!cache) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const reqs = await new Promise(res => {
|
|
14
|
+
const chunks = [];
|
|
15
|
+
let chunkLen = 0;
|
|
16
|
+
input.on('data', chunk => {
|
|
17
|
+
chunks.push(chunk);
|
|
18
|
+
chunkLen += chunk.length;
|
|
19
|
+
});
|
|
20
|
+
input.on('end', () => {
|
|
21
|
+
const reqs = Buffer.concat(chunks, chunkLen)
|
|
22
|
+
.toString()
|
|
23
|
+
.split('\0')
|
|
24
|
+
.filter(i => !!i && (i.startsWith('GET ') || i.startsWith('HEAD ')))
|
|
25
|
+
.map(i => i.startsWith('GET ') ?
|
|
26
|
+
['GET', new URL(i.substring('GET '.length))]
|
|
27
|
+
: ['HEAD', new URL(i.substring('HEAD '.length))]);
|
|
28
|
+
res(reqs);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
if (!reqs.length) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const rc = new RegistryClient({ cache });
|
|
35
|
+
await Promise.all(reqs.map(async ([method, url]) => {
|
|
36
|
+
await rc.request(url, {
|
|
37
|
+
method,
|
|
38
|
+
staleWhileRevalidate: false,
|
|
39
|
+
});
|
|
40
|
+
}));
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
43
|
+
const g = globalThis;
|
|
44
|
+
if (isMain(g.__VLT_INTERNAL_MAIN ?? process.argv[1])) {
|
|
45
|
+
process.title = 'vlt-cache-revalidate';
|
|
46
|
+
// When compiled there can be other leading args supplied by Deno
|
|
47
|
+
// so always use the last arg unless there are only two which means
|
|
48
|
+
// no path was supplied.
|
|
49
|
+
const cacheFolder = process.argv.length === 2 ? undefined : process.argv.at(-1);
|
|
50
|
+
const res = await main(cacheFolder, process.stdin);
|
|
51
|
+
if (!res) {
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=revalidate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revalidate.js","sourceRoot":"","sources":["../../src/revalidate.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,4EAA4E;AAC5E,mEAAmE;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAA;AAE5D,MAAM,MAAM,GAAG,CAAC,IAAa,EAAE,EAAE,CAC/B,IAAI,KAAK,wBAAwB;IACjC,IAAI,KAAK,aAAa,CAAC,wBAAwB,CAAC,CAAC,QAAQ,EAAE,CAAA;AAE7D,MAAM,CAAC,MAAM,IAAI,GAAG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,EAAE,CAAC;QACjB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,EAAE,GAAG,IAAI,cAAc,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IACxC,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAAE;QAC/B,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;YACpB,MAAM;YACN,oBAAoB,EAAE,KAAK;SAC5B,CAAC,CAAA;IACJ,CAAC,CAAC,CACH,CAAA;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,CAAC,GAAG,UAET,CAAA;AAED,IAAI,MAAM,CAAC,CAAC,CAAC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,OAAO,CAAC,KAAK,GAAG,sBAAsB,CAAA;IACtC,iEAAiE;IACjE,mEAAmE;IACnE,wBAAwB;IACxB,MAAM,WAAW,GACf,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAC7D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IAClD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC","sourcesContent":["// This needs to live in the same workspace as the RegistryClient, because\n// otherwise we have a cyclical dependency cycle of dependencies in a cycle,\n// which is even more cyclical than this description describing it.\nimport { pathToFileURL } from 'node:url'\nimport { RegistryClient } from './index.ts'\n\nexport const __CODE_SPLIT_SCRIPT_NAME = import.meta.filename\n\nconst isMain = (path?: string) =>\n path === __CODE_SPLIT_SCRIPT_NAME ||\n path === pathToFileURL(__CODE_SPLIT_SCRIPT_NAME).toString()\n\nexport const main = async (cache?: string, input = process.stdin) => {\n if (!cache) {\n return false\n }\n const reqs = await new Promise<['GET' | 'HEAD', URL][]>(res => {\n const chunks: Buffer[] = []\n let chunkLen = 0\n input.on('data', chunk => {\n chunks.push(chunk)\n chunkLen += chunk.length\n })\n input.on('end', () => {\n const reqs: ['GET' | 'HEAD', URL][] = Buffer.concat(\n chunks,\n chunkLen,\n )\n .toString()\n .split('\\0')\n .filter(\n i => !!i && (i.startsWith('GET ') || i.startsWith('HEAD ')),\n )\n .map(i =>\n i.startsWith('GET ') ?\n ['GET', new URL(i.substring('GET '.length))]\n : ['HEAD', new URL(i.substring('HEAD '.length))],\n )\n\n res(reqs)\n })\n })\n\n if (!reqs.length) {\n return false\n }\n\n const rc = new RegistryClient({ cache })\n await Promise.all(\n reqs.map(async ([method, url]) => {\n await rc.request(url, {\n method,\n staleWhileRevalidate: false,\n })\n }),\n )\n\n return true\n}\n\nconst g = globalThis as typeof globalThis & {\n __VLT_INTERNAL_MAIN?: string\n}\n\nif (isMain(g.__VLT_INTERNAL_MAIN ?? process.argv[1])) {\n process.title = 'vlt-cache-revalidate'\n // When compiled there can be other leading args supplied by Deno\n // so always use the last arg unless there are only two which means\n // no path was supplied.\n const cacheFolder =\n process.argv.length === 2 ? undefined : process.argv.at(-1)\n const res = await main(cacheFolder, process.stdin)\n if (!res) {\n process.exit(1)\n }\n}\n"]}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Given a rawHeaders array of [key, value, key2, value2, ...],
|
|
3
3
|
* overwrite the current value of a header, or if not found, append
|
|
4
4
|
*/
|
|
5
|
-
export declare const setRawHeader: (headers:
|
|
5
|
+
export declare const setRawHeader: (headers: Uint8Array[], key: string, value: Uint8Array | string) => Uint8Array[];
|
|
6
6
|
//# sourceMappingURL=set-raw-header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-raw-header.d.ts","sourceRoot":"","sources":["../../src/set-raw-header.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set-raw-header.d.ts","sourceRoot":"","sources":["../../src/set-raw-header.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,YAAY,YACd,UAAU,EAAE,OAChB,MAAM,SACJ,UAAU,GAAG,MAAM,KACzB,UAAU,EAiBZ,CAAA"}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
import { getDecodedValue, getEncondedValue, } from "./string-encoding.js";
|
|
1
2
|
/**
|
|
2
3
|
* Given a rawHeaders array of [key, value, key2, value2, ...],
|
|
3
4
|
* overwrite the current value of a header, or if not found, append
|
|
4
5
|
*/
|
|
5
6
|
export const setRawHeader = (headers, key, value) => {
|
|
6
7
|
key = key.toLowerCase();
|
|
7
|
-
const keyBuf =
|
|
8
|
-
const valBuf =
|
|
8
|
+
const keyBuf = getEncondedValue(key);
|
|
9
|
+
const valBuf = getEncondedValue(value);
|
|
9
10
|
for (let i = 0; i < headers.length; i += 2) {
|
|
10
11
|
const k = headers[i];
|
|
11
12
|
if (k &&
|
|
12
13
|
k.length === keyBuf.length &&
|
|
13
|
-
|
|
14
|
+
getDecodedValue(k).toLowerCase() === key) {
|
|
14
15
|
headers[i + 1] = valBuf;
|
|
15
|
-
return;
|
|
16
|
+
return headers;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
headers.push(keyBuf, valBuf);
|
|
20
|
+
return headers;
|
|
19
21
|
};
|
|
20
22
|
//# sourceMappingURL=set-raw-header.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-raw-header.js","sourceRoot":"","sources":["../../src/set-raw-header.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,
|
|
1
|
+
{"version":3,"file":"set-raw-header.js","sourceRoot":"","sources":["../../src/set-raw-header.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAE7B;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAAqB,EACrB,GAAW,EACX,KAA0B,EACZ,EAAE;IAChB,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;IACvB,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;IACpC,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;QACpB,IACE,CAAC;YACD,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;YAC1B,eAAe,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,EACxC,CAAC;YACD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAA;YACvB,OAAO,OAAO,CAAA;QAChB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import {\n getDecodedValue,\n getEncondedValue,\n} from './string-encoding.ts'\n\n/**\n * Given a rawHeaders array of [key, value, key2, value2, ...],\n * overwrite the current value of a header, or if not found, append\n */\nexport const setRawHeader = (\n headers: Uint8Array[],\n key: string,\n value: Uint8Array | string,\n): Uint8Array[] => {\n key = key.toLowerCase()\n const keyBuf = getEncondedValue(key)\n const valBuf = getEncondedValue(value)\n for (let i = 0; i < headers.length; i += 2) {\n const k = headers[i]\n if (\n k &&\n k.length === keyBuf.length &&\n getDecodedValue(k).toLowerCase() === key\n ) {\n headers[i + 1] = valBuf\n return headers\n }\n }\n headers.push(keyBuf, valBuf)\n return headers\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decodes a string from a Uint8Array
|
|
3
|
+
*/
|
|
4
|
+
export declare const getDecodedValue: (value: string | Uint8Array | undefined) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Encodes a string to a Uint8Array
|
|
7
|
+
*/
|
|
8
|
+
export declare const getEncondedValue: (value: Uint8Array | string | undefined) => Uint8Array;
|
|
9
|
+
//# sourceMappingURL=string-encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-encoding.d.ts","sourceRoot":"","sources":["../../src/string-encoding.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,eAAe,UACnB,MAAM,GAAG,UAAU,GAAG,SAAS,KACrC,MAKF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,UACpB,UAAU,GAAG,MAAM,GAAG,SAAS,KACrC,UAOF,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const decoder = new TextDecoder();
|
|
2
|
+
/**
|
|
3
|
+
* Decodes a string from a Uint8Array
|
|
4
|
+
*/
|
|
5
|
+
export const getDecodedValue = (value) => {
|
|
6
|
+
if (value == undefined)
|
|
7
|
+
return '';
|
|
8
|
+
if (typeof value === 'string')
|
|
9
|
+
return value;
|
|
10
|
+
const res = decoder.decode(value);
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Encodes a string to a Uint8Array
|
|
15
|
+
*/
|
|
16
|
+
export const getEncondedValue = (value) => {
|
|
17
|
+
if (value == undefined)
|
|
18
|
+
return new Uint8Array(0);
|
|
19
|
+
if (typeof value === 'string') {
|
|
20
|
+
const res = Buffer.from(value);
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=string-encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-encoding.js","sourceRoot":"","sources":["../../src/string-encoding.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AAEjC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAsC,EAC9B,EAAE;IACV,IAAI,KAAK,IAAI,SAAS;QAAE,OAAO,EAAE,CAAA;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACjC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAAsC,EAC1B,EAAE;IACd,IAAI,KAAK,IAAI,SAAS;QAAE,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;IAChD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC9B,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["const decoder = new TextDecoder()\n\n/**\n * Decodes a string from a Uint8Array\n */\nexport const getDecodedValue = (\n value: string | Uint8Array | undefined,\n): string => {\n if (value == undefined) return ''\n if (typeof value === 'string') return value\n const res = decoder.decode(value)\n return res\n}\n\n/**\n * Encodes a string to a Uint8Array\n */\nexport const getEncondedValue = (\n value: Uint8Array | string | undefined,\n): Uint8Array => {\n if (value == undefined) return new Uint8Array(0)\n if (typeof value === 'string') {\n const res = Buffer.from(value)\n return res\n }\n return value\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-response.d.ts","sourceRoot":"","sources":["../../src/token-response.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"token-response.d.ts","sourceRoot":"","sources":["../../src/token-response.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,gBAAgB,MACxB,OAAO,KACT,aAAa,GAAG,SASN,CAAA"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const getTokenResponse = (b) => (!!b &&
|
|
2
2
|
typeof b === 'object' &&
|
|
3
|
+
'token' in b &&
|
|
3
4
|
typeof b.token === 'string' &&
|
|
4
|
-
|
|
5
|
+
b.token) ?
|
|
6
|
+
{ token: b.token }
|
|
7
|
+
: undefined;
|
|
5
8
|
//# sourceMappingURL=token-response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-response.js","sourceRoot":"","sources":["../../src/token-response.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"token-response.js","sourceRoot":"","sources":["../../src/token-response.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,CAAU,EACiB,EAAE,CAC7B,CACE,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,QAAQ;IACrB,OAAO,IAAI,CAAC;IACZ,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ;IAC3B,CAAC,CAAC,KAAK,CACR,CAAC,CAAC;IACD,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE;IACpB,CAAC,CAAC,SAAS,CAAA","sourcesContent":["export type TokenResponse = {\n token: string\n}\n\nexport const getTokenResponse = (\n b: unknown,\n): TokenResponse | undefined =>\n (\n !!b &&\n typeof b === 'object' &&\n 'token' in b &&\n typeof b.token === 'string' &&\n b.token\n ) ?\n { token: b.token }\n : undefined\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type WebAuthChallenge = {
|
|
2
2
|
doneUrl: string;
|
|
3
|
-
|
|
3
|
+
authUrl: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const getWebAuthChallenge: (o: unknown) => WebAuthChallenge | undefined;
|
|
6
6
|
//# sourceMappingURL=web-auth-challenge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-auth-challenge.d.ts","sourceRoot":"","sources":["../../src/web-auth-challenge.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,
|
|
1
|
+
{"version":3,"file":"web-auth-challenge.d.ts","sourceRoot":"","sources":["../../src/web-auth-challenge.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,mBAAmB,MAC3B,OAAO,KACT,gBAAgB,GAAG,SAerB,CAAA"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export const getWebAuthChallenge = (o) => {
|
|
2
|
+
if (!!o &&
|
|
3
|
+
typeof o === 'object' &&
|
|
4
|
+
'doneUrl' in o &&
|
|
5
|
+
typeof o.doneUrl === 'string' &&
|
|
6
|
+
o.doneUrl) {
|
|
7
|
+
// Publishes use authUrl, but login uses loginUrl
|
|
8
|
+
const authUrl = 'authUrl' in o && typeof o.authUrl === 'string' ? o.authUrl
|
|
9
|
+
: 'loginUrl' in o && typeof o.loginUrl === 'string' ? o.loginUrl
|
|
10
|
+
: undefined;
|
|
11
|
+
return authUrl ? { doneUrl: o.doneUrl, authUrl } : undefined;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
7
14
|
//# sourceMappingURL=web-auth-challenge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-auth-challenge.js","sourceRoot":"","sources":["../../src/web-auth-challenge.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"web-auth-challenge.js","sourceRoot":"","sources":["../../src/web-auth-challenge.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,CAAU,EACoB,EAAE;IAChC,IACE,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,QAAQ;QACrB,SAAS,IAAI,CAAC;QACd,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ;QAC7B,CAAC,CAAC,OAAO,EACT,CAAC;QACD,iDAAiD;QACjD,MAAM,OAAO,GACX,SAAS,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;YAC3D,CAAC,CAAC,UAAU,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ;gBAChE,CAAC,CAAC,SAAS,CAAA;QACb,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;IAC9D,CAAC;AACH,CAAC,CAAA","sourcesContent":["export type WebAuthChallenge = {\n doneUrl: string\n authUrl: string\n}\n\nexport const getWebAuthChallenge = (\n o: unknown,\n): WebAuthChallenge | undefined => {\n if (\n !!o &&\n typeof o === 'object' &&\n 'doneUrl' in o &&\n typeof o.doneUrl === 'string' &&\n o.doneUrl\n ) {\n // Publishes use authUrl, but login uses loginUrl\n const authUrl =\n 'authUrl' in o && typeof o.authUrl === 'string' ? o.authUrl\n : 'loginUrl' in o && typeof o.loginUrl === 'string' ? o.loginUrl\n : undefined\n return authUrl ? { doneUrl: o.doneUrl, authUrl } : undefined\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/registry-client",
|
|
3
3
|
"description": "Fetch package artifacts and metadata from registries",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-31",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
8
8
|
"directory": "src/registry-client"
|
|
9
9
|
},
|
|
10
|
+
"author": "vlt technology inc. <support@vlt.sh> (http://vlt.sh)",
|
|
10
11
|
"tshy": {
|
|
11
12
|
"selfLink": false,
|
|
12
13
|
"liveDev": true,
|
|
@@ -20,30 +21,28 @@
|
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"cache-control-parser": "^2.0.
|
|
24
|
-
"package-json-from-dist": "^1.0.
|
|
25
|
-
"undici": "^
|
|
26
|
-
"@vltpkg/cache
|
|
27
|
-
"@vltpkg/cache": "0.0.0-
|
|
28
|
-
"@vltpkg/
|
|
29
|
-
"@vltpkg/
|
|
30
|
-
"@vltpkg/
|
|
31
|
-
"@vltpkg/url-open": "0.0.0-
|
|
32
|
-
"@vltpkg/
|
|
33
|
-
"@vltpkg/
|
|
34
|
-
"@vltpkg/xdg": "0.0.0-3"
|
|
24
|
+
"cache-control-parser": "^2.0.6",
|
|
25
|
+
"package-json-from-dist": "^1.0.1",
|
|
26
|
+
"undici": "^7.15.0",
|
|
27
|
+
"@vltpkg/cache": "0.0.0-31",
|
|
28
|
+
"@vltpkg/cache-unzip": "0.0.0-31",
|
|
29
|
+
"@vltpkg/keychain": "0.0.0-31",
|
|
30
|
+
"@vltpkg/types": "0.0.0-31",
|
|
31
|
+
"@vltpkg/error-cause": "0.0.0-31",
|
|
32
|
+
"@vltpkg/url-open": "0.0.0-31",
|
|
33
|
+
"@vltpkg/output": "0.0.0-31",
|
|
34
|
+
"@vltpkg/xdg": "0.0.0-31"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@eslint/js": "^9.
|
|
38
|
-
"@types/
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"prettier": "^3.4.2",
|
|
37
|
+
"@eslint/js": "^9.34.0",
|
|
38
|
+
"@types/node": "^22.17.2",
|
|
39
|
+
"eslint": "^9.34.0",
|
|
40
|
+
"prettier": "^3.6.2",
|
|
42
41
|
"tap": "^21.1.0",
|
|
43
42
|
"tshy": "^3.0.2",
|
|
44
|
-
"typedoc": "0.27.
|
|
43
|
+
"typedoc": "~0.27.9",
|
|
45
44
|
"typescript": "5.7.3",
|
|
46
|
-
"typescript-eslint": "^8.
|
|
45
|
+
"typescript-eslint": "^8.40.0"
|
|
47
46
|
},
|
|
48
47
|
"license": "BSD-2-Clause-Patent",
|
|
49
48
|
"engines": {
|
|
@@ -81,6 +80,7 @@
|
|
|
81
80
|
"snap": "tap",
|
|
82
81
|
"test": "tap",
|
|
83
82
|
"posttest": "tsc --noEmit",
|
|
83
|
+
"tshy": "tshy",
|
|
84
84
|
"typecheck": "tsc --noEmit"
|
|
85
85
|
}
|
|
86
86
|
}
|