@vltpkg/registry-client 1.0.0-rc.2 → 1.0.0-rc.23
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/package.json +36 -48
- package/dist/esm/add-header.d.ts +0 -2
- package/dist/esm/add-header.d.ts.map +0 -1
- package/dist/esm/add-header.js +0 -27
- package/dist/esm/add-header.js.map +0 -1
- package/dist/esm/auth.d.ts +0 -9
- package/dist/esm/auth.d.ts.map +0 -1
- package/dist/esm/auth.js +0 -39
- package/dist/esm/auth.js.map +0 -1
- package/dist/esm/cache-entry.d.ts +0 -141
- package/dist/esm/cache-entry.d.ts.map +0 -1
- package/dist/esm/cache-entry.js +0 -518
- package/dist/esm/cache-entry.js.map +0 -1
- package/dist/esm/cache-revalidate.d.ts +0 -2
- package/dist/esm/cache-revalidate.d.ts.map +0 -1
- package/dist/esm/cache-revalidate.js +0 -66
- package/dist/esm/cache-revalidate.js.map +0 -1
- package/dist/esm/delete-header.d.ts +0 -2
- package/dist/esm/delete-header.d.ts.map +0 -1
- package/dist/esm/delete-header.js +0 -32
- package/dist/esm/delete-header.js.map +0 -1
- package/dist/esm/env.d.ts +0 -7
- package/dist/esm/env.d.ts.map +0 -1
- package/dist/esm/env.js +0 -13
- package/dist/esm/env.js.map +0 -1
- package/dist/esm/get-header.d.ts +0 -2
- package/dist/esm/get-header.d.ts.map +0 -1
- package/dist/esm/get-header.js +0 -37
- package/dist/esm/get-header.js.map +0 -1
- package/dist/esm/handle-304-response.d.ts +0 -4
- package/dist/esm/handle-304-response.d.ts.map +0 -1
- package/dist/esm/handle-304-response.js +0 -10
- package/dist/esm/handle-304-response.js.map +0 -1
- package/dist/esm/index.d.ts +0 -144
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -325
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/is-cacheable.d.ts +0 -5
- package/dist/esm/is-cacheable.d.ts.map +0 -1
- package/dist/esm/is-cacheable.js +0 -10
- package/dist/esm/is-cacheable.js.map +0 -1
- package/dist/esm/is-iterable.d.ts +0 -2
- package/dist/esm/is-iterable.d.ts.map +0 -1
- package/dist/esm/is-iterable.js +0 -2
- package/dist/esm/is-iterable.js.map +0 -1
- package/dist/esm/otplease.d.ts +0 -4
- package/dist/esm/otplease.d.ts.map +0 -1
- package/dist/esm/otplease.js +0 -63
- package/dist/esm/otplease.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/raw-header.d.ts +0 -9
- package/dist/esm/raw-header.d.ts.map +0 -1
- package/dist/esm/raw-header.js +0 -36
- package/dist/esm/raw-header.js.map +0 -1
- package/dist/esm/redirect.d.ts +0 -23
- package/dist/esm/redirect.d.ts.map +0 -1
- package/dist/esm/redirect.js +0 -65
- package/dist/esm/redirect.js.map +0 -1
- package/dist/esm/revalidate.d.ts +0 -5
- package/dist/esm/revalidate.d.ts.map +0 -1
- package/dist/esm/revalidate.js +0 -55
- package/dist/esm/revalidate.js.map +0 -1
- package/dist/esm/set-cache-headers.d.ts +0 -4
- package/dist/esm/set-cache-headers.d.ts.map +0 -1
- package/dist/esm/set-cache-headers.js +0 -17
- package/dist/esm/set-cache-headers.js.map +0 -1
- package/dist/esm/set-raw-header.d.ts +0 -6
- package/dist/esm/set-raw-header.d.ts.map +0 -1
- package/dist/esm/set-raw-header.js +0 -22
- package/dist/esm/set-raw-header.js.map +0 -1
- package/dist/esm/string-encoding.d.ts +0 -9
- package/dist/esm/string-encoding.d.ts.map +0 -1
- package/dist/esm/string-encoding.js +0 -25
- package/dist/esm/string-encoding.js.map +0 -1
- package/dist/esm/token-response.d.ts +0 -5
- package/dist/esm/token-response.d.ts.map +0 -1
- package/dist/esm/token-response.js +0 -8
- package/dist/esm/token-response.js.map +0 -1
- package/dist/esm/web-auth-challenge.d.ts +0 -6
- package/dist/esm/web-auth-challenge.d.ts.map +0 -1
- package/dist/esm/web-auth-challenge.js +0 -14
- package/dist/esm/web-auth-challenge.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,86 +1,74 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/registry-client",
|
|
3
3
|
"description": "Fetch package artifacts and metadata from registries",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.23",
|
|
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":
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"liveDev": true,
|
|
14
|
-
"dialects": [
|
|
15
|
-
"esm"
|
|
16
|
-
],
|
|
17
|
-
"exports": {
|
|
18
|
-
"./package.json": "./package.json",
|
|
19
|
-
".": "./src/index.ts",
|
|
20
|
-
"./cache-entry": "./src/cache-entry.ts"
|
|
21
|
-
}
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "vlt technology inc.",
|
|
12
|
+
"email": "support@vlt.sh"
|
|
22
13
|
},
|
|
23
14
|
"dependencies": {
|
|
15
|
+
"@vltpkg/cache": "1.0.0-rc.23",
|
|
16
|
+
"@vltpkg/cache-unzip": "1.0.0-rc.23",
|
|
17
|
+
"@vltpkg/error-cause": "1.0.0-rc.23",
|
|
18
|
+
"@vltpkg/keychain": "1.0.0-rc.23",
|
|
19
|
+
"@vltpkg/output": "1.0.0-rc.23",
|
|
20
|
+
"@vltpkg/types": "1.0.0-rc.23",
|
|
21
|
+
"@vltpkg/url-open": "1.0.0-rc.23",
|
|
22
|
+
"@vltpkg/xdg": "1.0.0-rc.23",
|
|
24
23
|
"cache-control-parser": "^2.0.6",
|
|
25
24
|
"package-json-from-dist": "^1.0.1",
|
|
26
|
-
"undici": "^7.
|
|
27
|
-
"@vltpkg/cache": "1.0.0-rc.2",
|
|
28
|
-
"@vltpkg/keychain": "1.0.0-rc.2",
|
|
29
|
-
"@vltpkg/cache-unzip": "1.0.0-rc.2",
|
|
30
|
-
"@vltpkg/error-cause": "1.0.0-rc.2",
|
|
31
|
-
"@vltpkg/types": "1.0.0-rc.2",
|
|
32
|
-
"@vltpkg/output": "1.0.0-rc.2",
|
|
33
|
-
"@vltpkg/xdg": "1.0.0-rc.2",
|
|
34
|
-
"@vltpkg/url-open": "1.0.0-rc.2"
|
|
25
|
+
"undici": "^7.16.0"
|
|
35
26
|
},
|
|
36
27
|
"devDependencies": {
|
|
37
|
-
"@eslint/js": "^9.
|
|
38
|
-
"@types/node": "^22.
|
|
39
|
-
"eslint": "^9.
|
|
40
|
-
"prettier": "^3.
|
|
41
|
-
"tap": "^21.
|
|
42
|
-
"tshy": "^3.0.2",
|
|
28
|
+
"@eslint/js": "^9.39.1",
|
|
29
|
+
"@types/node": "^22.19.2",
|
|
30
|
+
"eslint": "^9.39.1",
|
|
31
|
+
"prettier": "^3.7.4",
|
|
32
|
+
"tap": "^21.5.0",
|
|
43
33
|
"typedoc": "~0.27.9",
|
|
44
34
|
"typescript": "5.7.3",
|
|
45
|
-
"typescript-eslint": "^8.
|
|
35
|
+
"typescript-eslint": "^8.49.0"
|
|
46
36
|
},
|
|
47
37
|
"license": "BSD-2-Clause-Patent",
|
|
48
38
|
"engines": {
|
|
49
|
-
"node": ">=22"
|
|
39
|
+
"node": ">=22.22.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
43
|
+
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
44
|
+
"lint": "eslint . --fix",
|
|
45
|
+
"lint:check": "eslint .",
|
|
46
|
+
"prepack": "tsc -p tsconfig.publish.json && ../../scripts/update-dist-exports.ts",
|
|
47
|
+
"snap": "tap",
|
|
48
|
+
"test": "tap",
|
|
49
|
+
"posttest": "tsc --noEmit",
|
|
50
|
+
"typecheck": "tsc --noEmit"
|
|
50
51
|
},
|
|
51
52
|
"tap": {
|
|
52
53
|
"extends": "../../tap-config.yaml"
|
|
53
54
|
},
|
|
54
55
|
"prettier": "../../.prettierrc.js",
|
|
55
|
-
"module": "./dist/
|
|
56
|
+
"module": "./dist/index.js",
|
|
56
57
|
"type": "module",
|
|
57
58
|
"exports": {
|
|
58
59
|
"./package.json": "./package.json",
|
|
59
60
|
".": {
|
|
60
61
|
"import": {
|
|
61
|
-
"
|
|
62
|
-
"default": "./dist/esm/index.js"
|
|
62
|
+
"default": "./dist/index.js"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"./cache-entry": {
|
|
66
66
|
"import": {
|
|
67
|
-
"
|
|
68
|
-
"default": "./dist/esm/cache-entry.js"
|
|
67
|
+
"default": "./dist/cache-entry.js"
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
},
|
|
72
71
|
"files": [
|
|
73
72
|
"dist"
|
|
74
|
-
]
|
|
75
|
-
|
|
76
|
-
"format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
77
|
-
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
78
|
-
"lint": "eslint . --fix",
|
|
79
|
-
"lint:check": "eslint .",
|
|
80
|
-
"snap": "tap",
|
|
81
|
-
"test": "tap",
|
|
82
|
-
"posttest": "tsc --noEmit",
|
|
83
|
-
"tshy": "tshy",
|
|
84
|
-
"typecheck": "tsc --noEmit"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
73
|
+
]
|
|
74
|
+
}
|
package/dist/esm/add-header.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const addHeader: <H extends [string, string[] | string][] | Iterable<[string, string[] | string | undefined]> | Record<string, string[] | string | undefined> | string[]>(headers: H | null | undefined, key: string, value?: string) => H;
|
|
2
|
-
//# sourceMappingURL=add-header.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add-header.d.ts","sourceRoot":"","sources":["../../src/add-header.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,GACpB,CAAC,SACG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,GAC7B,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,GACjD,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC,GAC7C,MAAM,EAAE,WAEH,CAAC,GAAG,IAAI,GAAG,SAAS,OACxB,MAAM,UACH,MAAM,KACb,CAkBF,CAAA"}
|
package/dist/esm/add-header.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { deleteHeader } from "./delete-header.js";
|
|
2
|
-
import { isIterable } from "./is-iterable.js";
|
|
3
|
-
// this does some rude things with types, but not much way around it,
|
|
4
|
-
// since the opts.headers type is so loosey goosey to begin with.
|
|
5
|
-
export const addHeader = (headers, key, value) => {
|
|
6
|
-
if (!value)
|
|
7
|
-
return deleteHeader(headers, key);
|
|
8
|
-
if (!headers)
|
|
9
|
-
return { [key]: value };
|
|
10
|
-
if (Array.isArray(headers)) {
|
|
11
|
-
if (!headers.length)
|
|
12
|
-
return [[key, value]];
|
|
13
|
-
if (Array.isArray(headers[0]))
|
|
14
|
-
headers.push([key, value]);
|
|
15
|
-
else
|
|
16
|
-
headers.push(key, value);
|
|
17
|
-
return headers;
|
|
18
|
-
}
|
|
19
|
-
else if (isIterable(headers)) {
|
|
20
|
-
return [...headers, [key, value]];
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
headers[key] = value;
|
|
24
|
-
return headers;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=add-header.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add-header.js","sourceRoot":"","sources":["../../src/add-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,qEAAqE;AACrE,iEAAiE;AACjE,MAAM,CAAC,MAAM,SAAS,GAAG,CAOvB,OAA6B,EAC7B,GAAW,EACX,KAAc,EACX,EAAE;IACL,IAAI,CAAC,KAAK;QAAE,OAAO,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAE7C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAO,CAAA;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAiB,CAAA;QAC1D,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC1B,OAA8B,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;;YAC9C,OAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC3C,OAAO,OAAO,CAAA;IAChB,CAAC;SAAM,IACL,UAAU,CAA0C,OAAO,CAAC,EAC5D,CAAC;QACD,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,CAAiB,CAAA;IACnD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACpB,OAAO,OAAO,CAAA;IAChB,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { deleteHeader } from './delete-header.ts'\nimport { isIterable } from './is-iterable.ts'\n\n// this does some rude things with types, but not much way around it,\n// since the opts.headers type is so loosey goosey to begin with.\nexport const addHeader = <\n H extends\n | [string, string[] | string][]\n | Iterable<[string, string[] | string | undefined]>\n | Record<string, string[] | string | undefined>\n | string[],\n>(\n headers: H | null | undefined,\n key: string,\n value?: string,\n): H => {\n if (!value) return deleteHeader(headers, key)\n\n if (!headers) return { [key]: value } as H\n if (Array.isArray(headers)) {\n if (!headers.length) return [[key, value]] as unknown as H\n if (Array.isArray(headers[0]))\n (headers as [string, string][]).push([key, value])\n else (headers as string[]).push(key, value)\n return headers\n } else if (\n isIterable<[string, string[] | string | undefined]>(headers)\n ) {\n return [...headers, [key, value]] as unknown as H\n } else {\n headers[key] = value\n return headers\n }\n}\n"]}
|
package/dist/esm/auth.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Keychain } from '@vltpkg/keychain';
|
|
2
|
-
export type Token = `Bearer ${string}` | `Basic ${string}`;
|
|
3
|
-
export declare const keychains: Map<string, Keychain<Token>>;
|
|
4
|
-
export declare const getKC: (identity: string) => Keychain<Token>;
|
|
5
|
-
export declare const isToken: (t: any) => t is Token;
|
|
6
|
-
export declare const deleteToken: (registry: string, identity: string) => Promise<void>;
|
|
7
|
-
export declare const setToken: (registry: string, token: Token, identity: string) => Promise<void>;
|
|
8
|
-
export declare const getToken: (registry: string, identity: string) => Promise<Token | undefined>;
|
|
9
|
-
//# sourceMappingURL=auth.d.ts.map
|
package/dist/esm/auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,MAAM,MAAM,KAAK,GAAG,UAAU,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,CAAA;AAG1D,eAAO,MAAM,SAAS,8BAAqC,CAAA;AAE3D,eAAO,MAAM,KAAK,aAAc,MAAM,oBAOrC,CAAA;AAED,eAAO,MAAM,OAAO,MAAO,GAAG,KAAG,CAAC,IAAI,KAEe,CAAA;AAErD,eAAO,MAAM,WAAW,aACZ,MAAM,YACN,MAAM,KACf,OAAO,CAAC,IAAI,CAKd,CAAA;AAED,eAAO,MAAM,QAAQ,aACT,MAAM,SACT,KAAK,YACF,MAAM,KACf,OAAO,CAAC,IAAI,CAGd,CAAA;AAED,eAAO,MAAM,QAAQ,aACT,MAAM,YACN,MAAM,KACf,OAAO,CAAC,KAAK,GAAG,SAAS,CAc3B,CAAA"}
|
package/dist/esm/auth.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Keychain } from '@vltpkg/keychain';
|
|
2
|
-
// just exported for testing
|
|
3
|
-
export const keychains = new Map();
|
|
4
|
-
export const getKC = (identity) => {
|
|
5
|
-
const kc = keychains.get(identity);
|
|
6
|
-
if (kc)
|
|
7
|
-
return kc;
|
|
8
|
-
const i = identity ? `vlt/auth/${identity}` : 'vlt/auth';
|
|
9
|
-
const nkc = new Keychain(i);
|
|
10
|
-
keychains.set(identity, nkc);
|
|
11
|
-
return nkc;
|
|
12
|
-
};
|
|
13
|
-
export const isToken = (t) => typeof t === 'string' &&
|
|
14
|
-
(t.startsWith('Bearer ') || t.startsWith('Basic '));
|
|
15
|
-
export const deleteToken = async (registry, identity) => {
|
|
16
|
-
const kc = getKC(identity);
|
|
17
|
-
await kc.load();
|
|
18
|
-
kc.delete(new URL(registry).origin);
|
|
19
|
-
await kc.save();
|
|
20
|
-
};
|
|
21
|
-
export const setToken = async (registry, token, identity) => {
|
|
22
|
-
const kc = getKC(identity);
|
|
23
|
-
return kc.set(new URL(registry).origin, token);
|
|
24
|
-
};
|
|
25
|
-
export const getToken = async (registry, identity) => {
|
|
26
|
-
const kc = getKC(identity);
|
|
27
|
-
registry = new URL(registry).origin;
|
|
28
|
-
const envReg = process.env.VLT_REGISTRY;
|
|
29
|
-
if (envReg && registry === new URL(envReg).origin) {
|
|
30
|
-
const envTok = process.env.VLT_TOKEN;
|
|
31
|
-
if (envTok)
|
|
32
|
-
return `Bearer ${envTok}`;
|
|
33
|
-
}
|
|
34
|
-
const tok = process.env[`VLT_TOKEN_${registry.replace(/[^a-zA-Z0-9]+/g, '_')}`];
|
|
35
|
-
if (tok)
|
|
36
|
-
return `Bearer ${tok}`;
|
|
37
|
-
return kc.get(registry);
|
|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;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,QAAgB,EAChB,KAAY,EACZ,QAAgB,EACD,EAAE;IACjB,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC1B,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAChD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,QAAgB,EAChB,QAAgB,EACY,EAAE;IAC9B,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC1B,QAAQ,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAA;IACvC,IAAI,MAAM,IAAI,QAAQ,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAA;QACpC,IAAI,MAAM;YAAE,OAAO,UAAU,MAAM,EAAE,CAAA;IACvC,CAAC;IACD,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CACT,aAAa,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,EAAE,CACvD,CAAA;IACH,IAAI,GAAG;QAAE,OAAO,UAAU,GAAG,EAAE,CAAA;IAC/B,OAAO,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACzB,CAAC,CAAA","sourcesContent":["import { Keychain } from '@vltpkg/keychain'\n\nexport type Token = `Bearer ${string}` | `Basic ${string}`\n\n// just exported for testing\nexport const keychains = new Map<string, Keychain<Token>>()\n\nexport const getKC = (identity: string) => {\n const kc = keychains.get(identity)\n if (kc) return kc\n const i = identity ? `vlt/auth/${identity}` : 'vlt/auth'\n const nkc = new Keychain<Token>(i)\n keychains.set(identity, nkc)\n return nkc\n}\n\nexport const isToken = (t: any): t is Token =>\n typeof t === 'string' &&\n (t.startsWith('Bearer ') || t.startsWith('Basic '))\n\nexport const deleteToken = async (\n registry: string,\n identity: string,\n): Promise<void> => {\n const kc = getKC(identity)\n await kc.load()\n kc.delete(new URL(registry).origin)\n await kc.save()\n}\n\nexport const setToken = async (\n registry: string,\n token: Token,\n identity: string,\n): Promise<void> => {\n const kc = getKC(identity)\n return kc.set(new URL(registry).origin, token)\n}\n\nexport const getToken = async (\n registry: string,\n identity: string,\n): Promise<Token | undefined> => {\n const kc = getKC(identity)\n registry = new URL(registry).origin\n const envReg = process.env.VLT_REGISTRY\n if (envReg && registry === new URL(envReg).origin) {\n const envTok = process.env.VLT_TOKEN\n if (envTok) return `Bearer ${envTok}`\n }\n const tok =\n process.env[\n `VLT_TOKEN_${registry.replace(/[^a-zA-Z0-9]+/g, '_')}`\n ]\n if (tok) return `Bearer ${tok}`\n return kc.get(registry)\n}\n"]}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import type { ErrorCauseOptions } from '@vltpkg/error-cause';
|
|
2
|
-
import type { Integrity, JSONField } from '@vltpkg/types';
|
|
3
|
-
import ccp from 'cache-control-parser';
|
|
4
|
-
import type { InspectOptions } from 'node:util';
|
|
5
|
-
export type JSONObj = Record<string, JSONField>;
|
|
6
|
-
declare const kCustomInspect: unique symbol;
|
|
7
|
-
export type CacheEntryOptions = {
|
|
8
|
-
/**
|
|
9
|
-
* An optional body to use.
|
|
10
|
-
*
|
|
11
|
-
* This is used when decoding a cache entry from a buffer, and the body
|
|
12
|
-
* is already in a ArrayBuffer we can use. When this option is
|
|
13
|
-
* provided the `addBody` method should not be used.
|
|
14
|
-
*/
|
|
15
|
-
body?: Uint8Array;
|
|
16
|
-
/**
|
|
17
|
-
* An optional content length of the body to use, if undefined the
|
|
18
|
-
* content-length header will be used.
|
|
19
|
-
*/
|
|
20
|
-
contentLength?: number;
|
|
21
|
-
/**
|
|
22
|
-
* The expected integrity value for this response body
|
|
23
|
-
*/
|
|
24
|
-
integrity?: Integrity;
|
|
25
|
-
/**
|
|
26
|
-
* Whether to trust the integrity, or calculate the actual value.
|
|
27
|
-
*
|
|
28
|
-
* This indicates that we just accept whatever the integrity is as the actual
|
|
29
|
-
* integrity for saving back to the cache, because it's coming directly from
|
|
30
|
-
* the registry that we fetched a packument from, and is an initial gzipped
|
|
31
|
-
* artifact request.
|
|
32
|
-
*/
|
|
33
|
-
trustIntegrity?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* If the server does not serve a `stale-while-revalidate` value in the
|
|
36
|
-
* `cache-control` header, then this multiplier is applied to the `max-age`
|
|
37
|
-
* or `s-maxage` values.
|
|
38
|
-
*
|
|
39
|
-
* By default, this is `60`, so for example a response that is cacheable for
|
|
40
|
-
* 5 minutes will allow a stale response while revalidating for up to 5
|
|
41
|
-
* hours.
|
|
42
|
-
*
|
|
43
|
-
* If the server *does* provide a `stale-while-revalidate` value, then that
|
|
44
|
-
* is always used.
|
|
45
|
-
*
|
|
46
|
-
* Set to 0 to prevent any `stale-while-revalidate` behavior unless
|
|
47
|
-
* explicitly allowed by the server's `cache-control` header.
|
|
48
|
-
*/
|
|
49
|
-
'stale-while-revalidate-factor'?: number;
|
|
50
|
-
};
|
|
51
|
-
export declare class CacheEntry {
|
|
52
|
-
#private;
|
|
53
|
-
constructor(statusCode: number, headers: Uint8Array[], { body, integrity, trustIntegrity, 'stale-while-revalidate-factor': staleWhileRevalidateFactor, contentLength, }?: CacheEntryOptions);
|
|
54
|
-
toJSON(): {
|
|
55
|
-
[k: string]: string | number | boolean | [string, string][] | Date | ccp.CacheControl | undefined;
|
|
56
|
-
};
|
|
57
|
-
[kCustomInspect](depth: number, options: InspectOptions): string;
|
|
58
|
-
get date(): Date | undefined;
|
|
59
|
-
get maxAge(): number;
|
|
60
|
-
get cacheControl(): ccp.CacheControl;
|
|
61
|
-
get staleWhileRevalidate(): boolean;
|
|
62
|
-
get contentType(): string;
|
|
63
|
-
get valid(): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Add contents to the entry body.
|
|
66
|
-
*/
|
|
67
|
-
addBody(b: Uint8Array): void;
|
|
68
|
-
get statusCode(): number;
|
|
69
|
-
get headers(): Uint8Array[];
|
|
70
|
-
/**
|
|
71
|
-
* Returns the body as a single Uint8Array, concatenating parts if needed.
|
|
72
|
-
*/
|
|
73
|
-
get _body(): Uint8Array;
|
|
74
|
-
/**
|
|
75
|
-
* Check that the sri integrity string that was provided to the ctor
|
|
76
|
-
* matches the body that we actually received. This should only be called
|
|
77
|
-
* AFTER the entire body has been completely downloaded.
|
|
78
|
-
*
|
|
79
|
-
* This method **will throw** if the integrity values do not match.
|
|
80
|
-
*
|
|
81
|
-
* Note that this will *usually* not be true if the value is coming out of
|
|
82
|
-
* the cache, because the cache entries are un-gzipped in place. It should
|
|
83
|
-
* _only_ be called for artifacts that come from an actual http response.
|
|
84
|
-
*
|
|
85
|
-
* Returns true if anything was actually verified.
|
|
86
|
-
*/
|
|
87
|
-
checkIntegrity(context?: ErrorCauseOptions): this is CacheEntry & {
|
|
88
|
-
integrity: Integrity;
|
|
89
|
-
};
|
|
90
|
-
get integrityActual(): Integrity;
|
|
91
|
-
set integrityActual(i: Integrity);
|
|
92
|
-
set integrity(i: Integrity | undefined);
|
|
93
|
-
get integrity(): Integrity | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* Give it a key, and it'll return the buffer of that header value
|
|
96
|
-
*/
|
|
97
|
-
getHeader(h: string): Uint8Array | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* Give it a key, and it'll return the decoded string of that header value
|
|
100
|
-
*/
|
|
101
|
-
getHeaderString(h: string): string | undefined;
|
|
102
|
-
/**
|
|
103
|
-
* Set a header to a specific value
|
|
104
|
-
*/
|
|
105
|
-
setHeader(h: string, value: Uint8Array | string): void;
|
|
106
|
-
/**
|
|
107
|
-
* Return the body of the entry as a Buffer
|
|
108
|
-
*/
|
|
109
|
-
buffer(): Buffer;
|
|
110
|
-
get body(): Uint8Array | Record<string, any>;
|
|
111
|
-
get isJSON(): boolean;
|
|
112
|
-
get isGzip(): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Un-gzip encode the body.
|
|
115
|
-
* Returns true if it was previously gzip (so something was done), otherwise
|
|
116
|
-
* returns false.
|
|
117
|
-
*/
|
|
118
|
-
unzip(): boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Return the body of the entry as utf8 text
|
|
121
|
-
* Automatically unzips if the content is gzip encoded
|
|
122
|
-
*/
|
|
123
|
-
text(): string;
|
|
124
|
-
/**
|
|
125
|
-
* Parse the entry body as JSON and return the result
|
|
126
|
-
*/
|
|
127
|
-
json(): JSONObj;
|
|
128
|
-
/**
|
|
129
|
-
* Pass the contents of a @vltpkg/cache.Cache object as a buffer,
|
|
130
|
-
* and this static method will decode it into a CacheEntry representing
|
|
131
|
-
* the cached response.
|
|
132
|
-
*/
|
|
133
|
-
static decode(buffer: Uint8Array): CacheEntry;
|
|
134
|
-
static isGzipEntry(buffer: Uint8Array): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Encode the entry as a single Buffer for writing to the cache
|
|
137
|
-
*/
|
|
138
|
-
encode(): Buffer;
|
|
139
|
-
}
|
|
140
|
-
export {};
|
|
141
|
-
//# sourceMappingURL=cache-entry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache-entry.d.ts","sourceRoot":"","sources":["../../src/cache-entry.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzD,OAAO,GAAG,MAAM,sBAAsB,CAAA;AAEtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAS/C,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAA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