@vltpkg/registry-client 0.0.0-0.1730724342581 → 0.0.0-10

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.
Files changed (67) hide show
  1. package/README.md +50 -53
  2. package/dist/esm/add-header.d.ts +1 -1
  3. package/dist/esm/add-header.d.ts.map +1 -1
  4. package/dist/esm/add-header.js +4 -1
  5. package/dist/esm/add-header.js.map +1 -1
  6. package/dist/esm/auth.d.ts +9 -0
  7. package/dist/esm/auth.d.ts.map +1 -0
  8. package/dist/esm/auth.js +39 -0
  9. package/dist/esm/auth.js.map +1 -0
  10. package/dist/esm/cache-entry.d.ts +59 -13
  11. package/dist/esm/cache-entry.d.ts.map +1 -1
  12. package/dist/esm/cache-entry.js +155 -54
  13. package/dist/esm/cache-entry.js.map +1 -1
  14. package/dist/esm/cache-revalidate.d.ts +2 -0
  15. package/dist/esm/cache-revalidate.d.ts.map +1 -0
  16. package/dist/esm/cache-revalidate.js +66 -0
  17. package/dist/esm/cache-revalidate.js.map +1 -0
  18. package/dist/esm/delete-header.d.ts +2 -0
  19. package/dist/esm/delete-header.d.ts.map +1 -0
  20. package/dist/esm/delete-header.js +32 -0
  21. package/dist/esm/delete-header.js.map +1 -0
  22. package/dist/esm/env.d.ts +0 -4
  23. package/dist/esm/env.d.ts.map +1 -1
  24. package/dist/esm/env.js +0 -3
  25. package/dist/esm/env.js.map +1 -1
  26. package/dist/esm/handle-304-response.d.ts +2 -2
  27. package/dist/esm/handle-304-response.d.ts.map +1 -1
  28. package/dist/esm/handle-304-response.js.map +1 -1
  29. package/dist/esm/index.d.ts +99 -8
  30. package/dist/esm/index.d.ts.map +1 -1
  31. package/dist/esm/index.js +265 -69
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/is-iterable.d.ts +2 -0
  34. package/dist/esm/is-iterable.d.ts.map +1 -0
  35. package/dist/esm/is-iterable.js +2 -0
  36. package/dist/esm/is-iterable.js.map +1 -0
  37. package/dist/esm/otplease.d.ts +4 -0
  38. package/dist/esm/otplease.d.ts.map +1 -0
  39. package/dist/esm/otplease.js +55 -0
  40. package/dist/esm/otplease.js.map +1 -0
  41. package/dist/esm/raw-header.d.ts +1 -1
  42. package/dist/esm/raw-header.d.ts.map +1 -1
  43. package/dist/esm/redirect.d.ts +2 -2
  44. package/dist/esm/redirect.d.ts.map +1 -1
  45. package/dist/esm/redirect.js +1 -0
  46. package/dist/esm/redirect.js.map +1 -1
  47. package/dist/esm/revalidate.d.ts +5 -0
  48. package/dist/esm/revalidate.d.ts.map +1 -0
  49. package/dist/esm/revalidate.js +49 -0
  50. package/dist/esm/revalidate.js.map +1 -0
  51. package/dist/esm/set-cache-headers.d.ts +2 -2
  52. package/dist/esm/set-cache-headers.d.ts.map +1 -1
  53. package/dist/esm/set-cache-headers.js +1 -1
  54. package/dist/esm/set-cache-headers.js.map +1 -1
  55. package/dist/esm/token-response.d.ts +5 -0
  56. package/dist/esm/token-response.d.ts.map +1 -0
  57. package/dist/esm/token-response.js +5 -0
  58. package/dist/esm/token-response.js.map +1 -0
  59. package/dist/esm/web-auth-challenge.d.ts +6 -0
  60. package/dist/esm/web-auth-challenge.d.ts.map +1 -0
  61. package/dist/esm/web-auth-challenge.js +7 -0
  62. package/dist/esm/web-auth-challenge.js.map +1 -0
  63. package/package.json +30 -21
  64. package/dist/esm/serdes.d.ts +0 -15
  65. package/dist/esm/serdes.d.ts.map +0 -1
  66. package/dist/esm/serdes.js +0 -19
  67. package/dist/esm/serdes.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ import type { Dispatcher } from 'undici';
2
+ import type { RegistryClient, RegistryClientRequestOptions } from './index.ts';
3
+ export declare const otplease: (client: RegistryClient, options: RegistryClientRequestOptions, response: Dispatcher.ResponseData) => Promise<RegistryClientRequestOptions | undefined>;
4
+ //# sourceMappingURL=otplease.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otplease.d.ts","sourceRoot":"","sources":["../../src/otplease.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EACV,cAAc,EACd,4BAA4B,EAC7B,MAAM,YAAY,CAAA;AASnB,eAAO,MAAM,QAAQ,WACX,cAAc,WACb,4BAA4B,YAC3B,UAAU,CAAC,YAAY,KAChC,OAAO,CAAC,4BAA4B,GAAG,SAAS,CAuDlD,CAAA"}
@@ -0,0 +1,55 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { isWebAuthChallenge } from "./web-auth-challenge.js";
3
+ import { urlOpen } from '@vltpkg/url-open';
4
+ import { createInterface } from 'node:readline/promises';
5
+ const otpChallengeNotice = /^Open ([^ ]+) to use your security key for authentication or enter OTP from your authenticator app/i;
6
+ export const otplease = async (client, options, response) => {
7
+ const waHeader = String(response.headers['www-authenticate'] ?? '');
8
+ const wwwAuth = new Set(waHeader ? waHeader.toLowerCase().split(/,\s*/) : []);
9
+ if (wwwAuth.has('ipaddress')) {
10
+ throw error('Authorization is not allowed from your ip address', {
11
+ response,
12
+ });
13
+ }
14
+ if (wwwAuth.has('otp')) {
15
+ // do a web auth opener to get otp token
16
+ const challenge = await response.body.json();
17
+ if (isWebAuthChallenge(challenge)) {
18
+ return {
19
+ ...options,
20
+ otp: (await client.webAuthOpener(challenge)).token,
21
+ };
22
+ }
23
+ else {
24
+ const { 'npm-notice': npmNotice } = response.headers;
25
+ if (npmNotice) {
26
+ const n = String(npmNotice);
27
+ const match = otpChallengeNotice.exec(n);
28
+ if (match) {
29
+ void urlOpen(match[1]);
30
+ const otp = await createInterface({
31
+ input: process.stdin,
32
+ output: process.stdout,
33
+ }).question(n);
34
+ return { ...options, otp };
35
+ }
36
+ }
37
+ throw error('Unrecognized OTP authentication challenge', {
38
+ response,
39
+ });
40
+ }
41
+ }
42
+ if (wwwAuth.size) {
43
+ throw error('Unknown authentication challenge', { response });
44
+ }
45
+ // see if the body is prompting for otp
46
+ const text = await response.body.text();
47
+ if (text.toLowerCase().includes('one-time pass')) {
48
+ const otp = await createInterface({
49
+ input: process.stdin,
50
+ output: process.stdout,
51
+ }).question(text);
52
+ return { ...options, otp };
53
+ }
54
+ };
55
+ //# sourceMappingURL=otplease.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otplease.js","sourceRoot":"","sources":["../../src/otplease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,MAAM,kBAAkB,GACtB,qGAAqG,CAAA;AAEvG,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,MAAsB,EACtB,OAAqC,EACrC,QAAiC,EACkB,EAAE;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAA;IACnE,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CACrD,CAAA;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,MAAM,KAAK,CAAC,mDAAmD,EAAE;YAC/D,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,wCAAwC;QACxC,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;QAC5C,IAAI,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,OAAO;gBACL,GAAG,OAAO;gBACV,GAAG,EAAE,CAAC,MAAM,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EAAE,GAAG,EAAE,CAAA;IAC5B,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { Dispatcher } from 'undici'\nimport type {\n RegistryClient,\n RegistryClientRequestOptions,\n} from './index.ts'\nimport { isWebAuthChallenge } from './web-auth-challenge.ts'\n\nimport { urlOpen } from '@vltpkg/url-open'\nimport { createInterface } from 'node:readline/promises'\n\nconst otpChallengeNotice =\n /^Open ([^ ]+) to use your security key for authentication or enter OTP from your authenticator app/i\n\nexport const otplease = async (\n client: RegistryClient,\n options: RegistryClientRequestOptions,\n response: Dispatcher.ResponseData,\n): Promise<RegistryClientRequestOptions | undefined> => {\n const waHeader = String(response.headers['www-authenticate'] ?? '')\n const wwwAuth = new Set(\n waHeader ? waHeader.toLowerCase().split(/,\\s*/) : [],\n )\n\n if (wwwAuth.has('ipaddress')) {\n throw error('Authorization is not allowed from your ip address', {\n response,\n })\n }\n\n if (wwwAuth.has('otp')) {\n // do a web auth opener to get otp token\n const challenge = await response.body.json()\n if (isWebAuthChallenge(challenge)) {\n return {\n ...options,\n otp: (await client.webAuthOpener(challenge)).token,\n }\n } else {\n const { 'npm-notice': npmNotice } = response.headers\n if (npmNotice) {\n const n = String(npmNotice)\n const match = otpChallengeNotice.exec(n) as\n | null\n | [string, string]\n if (match) {\n void urlOpen(match[1])\n const otp = await createInterface({\n input: process.stdin,\n output: process.stdout,\n }).question(n)\n return { ...options, otp }\n }\n }\n throw error('Unrecognized OTP authentication challenge', {\n response,\n })\n }\n }\n\n if (wwwAuth.size) {\n throw error('Unknown authentication challenge', { response })\n }\n\n // see if the body is prompting for otp\n const text = await response.body.text()\n if (text.toLowerCase().includes('one-time pass')) {\n const otp = await createInterface({\n input: process.stdin,\n output: process.stdout,\n }).question(text)\n return { ...options, otp }\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Give it a key, and it'll return the buffer of that header value
3
3
  */
4
- export declare const getRawHeader: (headers: Buffer[], k: string) => Buffer | undefined;
4
+ export declare const getRawHeader: (headers: Buffer[], k: string) => Buffer<ArrayBufferLike> | undefined;
5
5
  /**
6
6
  * Give it a key and value, and it'll overwrite or add the header entry
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"raw-header.d.ts","sourceRoot":"","sources":["../../src/raw-header.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY,YAAa,MAAM,EAAE,KAAK,MAAM,uBAYxD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,YACd,MAAM,EAAE,KACd,MAAM,KACN,MAAM,GAAG,MAAM,KACjB,MAAM,EAkBR,CAAA"}
1
+ {"version":3,"file":"raw-header.d.ts","sourceRoot":"","sources":["../../src/raw-header.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY,YAAa,MAAM,EAAE,KAAK,MAAM,wCAYxD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,YACd,MAAM,EAAE,KACd,MAAM,KACN,MAAM,GAAG,MAAM,KACjB,MAAM,EAkBR,CAAA"}
@@ -1,5 +1,5 @@
1
- import { type CacheEntry } from './cache-entry.js';
2
- import { type RegistryClientRequestOptions } from './index.js';
1
+ import type { CacheEntry } from './cache-entry.ts';
2
+ 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;
@@ -1 +1 @@
1
- {"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../../src/redirect.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,KAAK,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,MAAM,CAAA;CACnC,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,CAwCzC,CAAA"}
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,MAAM,CAAA;CACnC,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,CAyCzC,CAAA"}
@@ -40,6 +40,7 @@ export const redirect = (options, response, from) => {
40
40
  ...options,
41
41
  redirections,
42
42
  };
43
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- thats why we are deleting it
43
44
  delete nextOptions.path;
44
45
  redirections.add(String(nextURL));
45
46
  switch (response.statusCode) {
@@ -1 +1 @@
1
- {"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../src/redirect.ts"],"names":[],"mappings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V,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,WAAW,GAAiC;QAChD,GAAG,OAAO;QACV,YAAY;KACb,CAAA;IACD,OAAO,WAAW,CAAC,IAAI,CAAA;IACvB,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IACjC,QAAQ,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC5B,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,kCAAkC;YAClC,WAAW,CAAC,MAAM,GAAG,KAAK,CAAA;YAC1B,WAAW,CAAC,IAAI,GAAG,SAAS,CAAA;YAC5B,cAAc;QAChB,CAAC;QACD,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC,CAAC,mDAAmD;QAC7D,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC,CAAC,CAAC;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.js'\nimport { type RegistryClientRequestOptions } from './index.js'\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'): Buffer\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 = String(response.getHeader('location'))\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 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"]}
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,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;AAE1C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,OAAqC,EACrC,QAA0B,EAC1B,IAAS,EACiC,EAAE;IAC5C,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,EAAU,EAAE,eAAe,GAAG,EAAE,EAAE,GAC9D,OAAO,CAAA;IACT,IAAI,eAAe,IAAI,CAAC;QAA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// 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'): Buffer\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 = String(response.getHeader('location'))\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,5 @@
1
+ export declare const __CODE_SPLIT_SCRIPT_NAME: string;
2
+ export declare const main: (cache?: string, input?: NodeJS.ReadStream & {
3
+ fd: 0;
4
+ }) => Promise<void>;
5
+ //# sourceMappingURL=revalidate.d.ts.map
@@ -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;;mBAuCxC,CAAA"}
@@ -0,0 +1,49 @@
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
+ process.exit(1);
12
+ const reqs = await new Promise(res => {
13
+ const chunks = [];
14
+ let chunkLen = 0;
15
+ input.on('data', chunk => {
16
+ chunks.push(chunk);
17
+ chunkLen += chunk.length;
18
+ });
19
+ input.on('end', () => {
20
+ const reqs = Buffer.concat(chunks, chunkLen)
21
+ .toString()
22
+ .split('\0')
23
+ .filter(i => !!i && (i.startsWith('GET ') || i.startsWith('HEAD ')))
24
+ .map(i => i.startsWith('GET ') ?
25
+ ['GET', new URL(i.substring('GET '.length))]
26
+ : ['HEAD', new URL(i.substring('HEAD '.length))]);
27
+ res(reqs);
28
+ });
29
+ });
30
+ if (!reqs.length)
31
+ process.exit(1);
32
+ const rc = new RegistryClient({ cache });
33
+ await Promise.all(reqs.map(async ([method, url]) => {
34
+ await rc.request(url, {
35
+ method,
36
+ staleWhileRevalidate: false,
37
+ });
38
+ }));
39
+ };
40
+ const g = globalThis;
41
+ if (isMain(g.__VLT_INTERNAL_MAIN ?? process.argv[1])) {
42
+ process.title = 'vlt-cache-revalidate';
43
+ // When compiled there can be other leading args supplied by Deno
44
+ // so always use the last arg unless there are only two which means
45
+ // no path was supplied.
46
+ const cacheFolder = process.argv.length === 2 ? undefined : process.argv.at(-1);
47
+ void main(cacheFolder, process.stdin);
48
+ }
49
+ //# 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,KAAK,EAAE,KAAc,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE;IAClE,IAAI,CAAC,KAAK;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC3B,MAAM,IAAI,GAAG,MAAM,IAAI,OAAO,CAA0B,GAAG,CAAC,EAAE;QAC5D,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,IAAI,QAAQ,GAAG,CAAC,CAAA;QAChB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;YACvB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAClB,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAA;QAC1B,CAAC,CAAC,CAAA;QACF,KAAK,CAAC,EAAE,CA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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;IAE7D,KAAK,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;AACvC,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) process.exit(1)\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) process.exit(1)\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\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\n void main(cacheFolder, process.stdin)\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type CacheEntry } from './cache-entry.js';
2
- import { type RegistryClientRequestOptions } from './index.js';
1
+ import type { CacheEntry } from './cache-entry.ts';
2
+ import type { RegistryClientRequestOptions } from './index.ts';
3
3
  export declare const setCacheHeaders: (options: RegistryClientRequestOptions, entry?: CacheEntry) => void;
4
4
  //# sourceMappingURL=set-cache-headers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"set-cache-headers.d.ts","sourceRoot":"","sources":["../../src/set-cache-headers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,YAAY,CAAA;AAE9D,eAAO,MAAM,eAAe,YACjB,4BAA4B,UAC7B,UAAU,KACjB,IAqBF,CAAA"}
1
+ {"version":3,"file":"set-cache-headers.d.ts","sourceRoot":"","sources":["../../src/set-cache-headers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAA;AAE9D,eAAO,MAAM,eAAe,YACjB,4BAA4B,UAC7B,UAAU,KACjB,IAqBF,CAAA"}
@@ -1,6 +1,6 @@
1
1
  // Set the cache headers on a request options object
2
2
  // based on what we know from a CacheEntry
3
- import { addHeader } from './add-header.js';
3
+ import { addHeader } from "./add-header.js";
4
4
  export const setCacheHeaders = (options, entry) => {
5
5
  if (!entry)
6
6
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"set-cache-headers.js","sourceRoot":"","sources":["../../src/set-cache-headers.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,0CAA0C;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,OAAqC,EACrC,KAAkB,EACZ,EAAE;IACR,IAAI,CAAC,KAAK;QAAE,OAAM;IAClB,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAA;IAChD,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,OAAO,GAAG,SAAS,CACzB,OAAO,CAAC,OAAO,EACf,eAAe,EACf,IAAI,CACL,CAAA;IACH,CAAC;IAED,MAAM,IAAI,GACR,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE;QACnC,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAA;IAC9C,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,OAAO,GAAG,SAAS,CACzB,OAAO,CAAC,OAAO,EACf,mBAAmB,EACnB,IAAI,CACL,CAAA;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["// Set the cache headers on a request options object\n// based on what we know from a CacheEntry\n\nimport { addHeader } from './add-header.js'\nimport { type CacheEntry } from './cache-entry.js'\nimport { type RegistryClientRequestOptions } from './index.js'\n\nexport const setCacheHeaders = (\n options: RegistryClientRequestOptions,\n entry?: CacheEntry,\n): void => {\n if (!entry) return\n const etag = entry.getHeader('etag')?.toString()\n if (etag) {\n options.headers = addHeader(\n options.headers,\n 'if-none-match',\n etag,\n )\n }\n\n const date =\n entry.getHeader('date')?.toString() ??\n entry.getHeader('last-modified')?.toString()\n if (date) {\n options.headers = addHeader(\n options.headers,\n 'if-modified-since',\n date,\n )\n }\n}\n"]}
1
+ {"version":3,"file":"set-cache-headers.js","sourceRoot":"","sources":["../../src/set-cache-headers.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,0CAA0C;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,OAAqC,EACrC,KAAkB,EACZ,EAAE;IACR,IAAI,CAAC,KAAK;QAAE,OAAM;IAClB,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAA;IAChD,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,OAAO,GAAG,SAAS,CACzB,OAAO,CAAC,OAAO,EACf,eAAe,EACf,IAAI,CACL,CAAA;IACH,CAAC;IAED,MAAM,IAAI,GACR,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE;QACnC,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAA;IAC9C,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,OAAO,GAAG,SAAS,CACzB,OAAO,CAAC,OAAO,EACf,mBAAmB,EACnB,IAAI,CACL,CAAA;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["// Set the cache headers on a request options object\n// based on what we know from a CacheEntry\n\nimport { addHeader } from './add-header.ts'\nimport type { CacheEntry } from './cache-entry.ts'\nimport type { RegistryClientRequestOptions } from './index.ts'\n\nexport const setCacheHeaders = (\n options: RegistryClientRequestOptions,\n entry?: CacheEntry,\n): void => {\n if (!entry) return\n const etag = entry.getHeader('etag')?.toString()\n if (etag) {\n options.headers = addHeader(\n options.headers,\n 'if-none-match',\n etag,\n )\n }\n\n const date =\n entry.getHeader('date')?.toString() ??\n entry.getHeader('last-modified')?.toString()\n if (date) {\n options.headers = addHeader(\n options.headers,\n 'if-modified-since',\n date,\n )\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export type TokenResponse = {
2
+ token: string;
3
+ };
4
+ export declare const isTokenResponse: (b: unknown) => b is TokenResponse;
5
+ //# sourceMappingURL=token-response.d.ts.map
@@ -0,0 +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,eAAe,MAAO,OAAO,KAAG,CAAC,IAAI,aAIpB,CAAA"}
@@ -0,0 +1,5 @@
1
+ export const isTokenResponse = (b) => !!b &&
2
+ typeof b === 'object' &&
3
+ typeof b.token === 'string' &&
4
+ !!b.token;
5
+ //# sourceMappingURL=token-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-response.js","sourceRoot":"","sources":["../../src/token-response.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAU,EAAsB,EAAE,CAChE,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,QAAQ;IACrB,OAAQ,CAAmB,CAAC,KAAK,KAAK,QAAQ;IAC9C,CAAC,CAAE,CAAmB,CAAC,KAAK,CAAA","sourcesContent":["export type TokenResponse = {\n token: string\n}\n\nexport const isTokenResponse = (b: unknown): b is TokenResponse =>\n !!b &&\n typeof b === 'object' &&\n typeof (b as TokenResponse).token === 'string' &&\n !!(b as TokenResponse).token\n"]}
@@ -0,0 +1,6 @@
1
+ export type WebAuthChallenge = {
2
+ doneUrl: string;
3
+ loginUrl: string;
4
+ };
5
+ export declare const isWebAuthChallenge: (o: unknown) => o is WebAuthChallenge;
6
+ //# sourceMappingURL=web-auth-challenge.d.ts.map
@@ -0,0 +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,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,kBAAkB,MAC1B,OAAO,KACT,CAAC,IAAI,gBAM8C,CAAA"}
@@ -0,0 +1,7 @@
1
+ export const isWebAuthChallenge = (o) => !!o &&
2
+ typeof o === 'object' &&
3
+ !!o.doneUrl &&
4
+ !!o.loginUrl &&
5
+ typeof o.doneUrl === 'string' &&
6
+ typeof o.loginUrl === 'string';
7
+ //# sourceMappingURL=web-auth-challenge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-auth-challenge.js","sourceRoot":"","sources":["../../src/web-auth-challenge.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,CAAU,EACa,EAAE,CACzB,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,QAAQ;IACrB,CAAC,CAAE,CAAsB,CAAC,OAAO;IACjC,CAAC,CAAE,CAAsB,CAAC,QAAQ;IAClC,OAAQ,CAAsB,CAAC,OAAO,KAAK,QAAQ;IACnD,OAAQ,CAAsB,CAAC,QAAQ,KAAK,QAAQ,CAAA","sourcesContent":["export type WebAuthChallenge = {\n doneUrl: string\n loginUrl: string\n}\n\nexport const isWebAuthChallenge = (\n o: unknown,\n): o is WebAuthChallenge =>\n !!o &&\n typeof o === 'object' &&\n !!(o as WebAuthChallenge).doneUrl &&\n !!(o as WebAuthChallenge).loginUrl &&\n typeof (o as WebAuthChallenge).doneUrl === 'string' &&\n typeof (o as WebAuthChallenge).loginUrl === 'string'\n"]}
package/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "@vltpkg/registry-client",
3
3
  "description": "Fetch package artifacts and metadata from registries",
4
- "version": "0.0.0-0.1730724342581",
4
+ "version": "0.0.0-10",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/vltpkg/vltpkg.git",
8
+ "directory": "src/registry-client"
9
+ },
5
10
  "tshy": {
6
11
  "selfLink": false,
12
+ "liveDev": true,
7
13
  "dialects": [
8
14
  "esm"
9
15
  ],
@@ -14,29 +20,32 @@
14
20
  }
15
21
  },
16
22
  "dependencies": {
17
- "cache-control-parser": "^2.0.5",
18
- "package-json-from-dist": "^1.0.0",
19
- "undici": "^6.20.0",
20
- "@vltpkg/cache": "0.0.0-0.1730724342581",
21
- "@vltpkg/cache-unzip": "0.0.0-0.1730724342581",
22
- "@vltpkg/xdg": "0.0.0-0.1730724342581",
23
- "@vltpkg/types": "0.0.0-0.1730724342581",
24
- "@vltpkg/error-cause": "0.0.0-0.1730724342581"
23
+ "cache-control-parser": "^2.0.6",
24
+ "package-json-from-dist": "^1.0.1",
25
+ "undici": "^7.8.0",
26
+ "@vltpkg/cache": "0.0.0-10",
27
+ "@vltpkg/cache-unzip": "0.0.0-10",
28
+ "@vltpkg/error-cause": "0.0.0-10",
29
+ "@vltpkg/output": "0.0.0-10",
30
+ "@vltpkg/url-open": "0.0.0-10",
31
+ "@vltpkg/keychain": "0.0.0-10",
32
+ "@vltpkg/types": "0.0.0-10",
33
+ "@vltpkg/xdg": "0.0.0-10"
25
34
  },
26
35
  "devDependencies": {
27
- "@eslint/js": "^9.8.0",
28
- "@types/eslint__js": "^8.42.3",
29
- "@types/node": "^22.4.1",
30
- "eslint": "^9.8.0",
31
- "prettier": "^3.3.2",
32
- "tap": "^21.0.1",
36
+ "@eslint/js": "^9.25.0",
37
+ "@types/node": "^22.14.1",
38
+ "eslint": "^9.25.0",
39
+ "prettier": "^3.5.3",
40
+ "tap": "^21.1.0",
33
41
  "tshy": "^3.0.2",
34
- "typescript": "^5.5.4",
35
- "typescript-eslint": "^8.0.1"
42
+ "typedoc": "~0.27.6",
43
+ "typescript": "5.7.3",
44
+ "typescript-eslint": "^8.30.1"
36
45
  },
37
46
  "license": "BSD-2-Clause-Patent",
38
47
  "engines": {
39
- "node": "20 || >=22"
48
+ "node": ">=22"
40
49
  },
41
50
  "tap": {
42
51
  "extends": "../../tap-config.yaml"
@@ -67,9 +76,9 @@
67
76
  "format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
68
77
  "lint": "eslint . --fix",
69
78
  "lint:check": "eslint .",
70
- "presnap": "tshy",
71
79
  "snap": "tap",
72
- "pretest": "tshy",
73
- "test": "tap"
80
+ "test": "tap",
81
+ "posttest": "tsc --noEmit",
82
+ "typecheck": "tsc --noEmit"
74
83
  }
75
84
  }
@@ -1,15 +0,0 @@
1
- /**
2
- * This tiny module abstracts out the v8-specific serialization mechanism,
3
- * so that we can swap out based on platform.
4
- *
5
- * Bun, Deno, and Node all export serialize/deserialize from the `node:v8`
6
- * built-in module, but only Deno and Node are v8, Bun uses JSC's wire format.
7
- *
8
- * Any change to the serialization format is a semver-major change,
9
- * but not every major-version bump is a serialization change. So, this is
10
- * somewhat more conservative than necessary, but saves us having to track
11
- * which major versions changed the serialization wire format.
12
- */
13
- export declare const serializedHeader: string | undefined;
14
- export { deserialize, serialize } from 'node:v8';
15
- //# sourceMappingURL=serdes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serdes.d.ts","sourceRoot":"","sources":["../../src/serdes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,eAAO,MAAM,gBAAgB,oBAGhB,CAAA;AAEb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA"}
@@ -1,19 +0,0 @@
1
- /**
2
- * This tiny module abstracts out the v8-specific serialization mechanism,
3
- * so that we can swap out based on platform.
4
- *
5
- * Bun, Deno, and Node all export serialize/deserialize from the `node:v8`
6
- * built-in module, but only Deno and Node are v8, Bun uses JSC's wire format.
7
- *
8
- * Any change to the serialization format is a semver-major change,
9
- * but not every major-version bump is a serialization change. So, this is
10
- * somewhat more conservative than necessary, but saves us having to track
11
- * which major versions changed the serialization wire format.
12
- */
13
- import { engine } from './env.js';
14
- // these aren't used if we couldn't determine the engine type & version
15
- export const serializedHeader = engine ?
16
- `${engine.name}-serialize-${parseInt(engine.version.replace(/[^0-9]/g, ' ').trim(), 10)}`
17
- : undefined;
18
- export { deserialize, serialize } from 'node:v8';
19
- //# sourceMappingURL=serdes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serdes.js","sourceRoot":"","sources":["../../src/serdes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAC3B,MAAM,CAAC,CAAC;IACN,GAAG,MAAM,CAAC,IAAI,cAAc,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE;IAC3F,CAAC,CAAC,SAAS,CAAA;AAEb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA","sourcesContent":["/**\n * This tiny module abstracts out the v8-specific serialization mechanism,\n * so that we can swap out based on platform.\n *\n * Bun, Deno, and Node all export serialize/deserialize from the `node:v8`\n * built-in module, but only Deno and Node are v8, Bun uses JSC's wire format.\n *\n * Any change to the serialization format is a semver-major change,\n * but not every major-version bump is a serialization change. So, this is\n * somewhat more conservative than necessary, but saves us having to track\n * which major versions changed the serialization wire format.\n */\n\nimport { engine } from './env.js'\n\n// these aren't used if we couldn't determine the engine type & version\nexport const serializedHeader =\n engine ?\n `${engine.name}-serialize-${parseInt(engine.version.replace(/[^0-9]/g, ' ').trim(), 10)}`\n : undefined\n\nexport { deserialize, serialize } from 'node:v8'\n"]}