@vltpkg/registry-client 1.0.0-rc.10 → 1.0.0-rc.11

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 (122) hide show
  1. package/dist/add-header.d.ts.map +1 -0
  2. package/dist/add-header.js.map +1 -0
  3. package/dist/auth.d.ts.map +1 -0
  4. package/dist/auth.js.map +1 -0
  5. package/dist/cache-entry.d.ts.map +1 -0
  6. package/dist/cache-entry.js.map +1 -0
  7. package/dist/cache-revalidate.d.ts.map +1 -0
  8. package/dist/cache-revalidate.js.map +1 -0
  9. package/dist/delete-header.d.ts.map +1 -0
  10. package/dist/delete-header.js.map +1 -0
  11. package/dist/env.d.ts.map +1 -0
  12. package/dist/env.js.map +1 -0
  13. package/dist/get-header.d.ts.map +1 -0
  14. package/dist/get-header.js.map +1 -0
  15. package/dist/handle-304-response.d.ts.map +1 -0
  16. package/dist/handle-304-response.js.map +1 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/is-cacheable.d.ts.map +1 -0
  20. package/dist/is-cacheable.js.map +1 -0
  21. package/dist/is-iterable.d.ts.map +1 -0
  22. package/dist/is-iterable.js.map +1 -0
  23. package/dist/otplease.d.ts.map +1 -0
  24. package/dist/otplease.js.map +1 -0
  25. package/dist/raw-header.d.ts.map +1 -0
  26. package/dist/raw-header.js.map +1 -0
  27. package/dist/redirect.d.ts.map +1 -0
  28. package/dist/redirect.js.map +1 -0
  29. package/dist/revalidate.d.ts.map +1 -0
  30. package/dist/revalidate.js.map +1 -0
  31. package/dist/set-cache-headers.d.ts.map +1 -0
  32. package/dist/set-cache-headers.js.map +1 -0
  33. package/dist/set-raw-header.d.ts.map +1 -0
  34. package/dist/set-raw-header.js.map +1 -0
  35. package/dist/string-encoding.d.ts.map +1 -0
  36. package/dist/string-encoding.js.map +1 -0
  37. package/dist/token-response.d.ts.map +1 -0
  38. package/dist/token-response.js.map +1 -0
  39. package/dist/web-auth-challenge.d.ts.map +1 -0
  40. package/dist/web-auth-challenge.js.map +1 -0
  41. package/package.json +12 -28
  42. package/dist/esm/add-header.d.ts.map +0 -1
  43. package/dist/esm/add-header.js.map +0 -1
  44. package/dist/esm/auth.d.ts.map +0 -1
  45. package/dist/esm/auth.js.map +0 -1
  46. package/dist/esm/cache-entry.d.ts.map +0 -1
  47. package/dist/esm/cache-entry.js.map +0 -1
  48. package/dist/esm/cache-revalidate.d.ts.map +0 -1
  49. package/dist/esm/cache-revalidate.js.map +0 -1
  50. package/dist/esm/delete-header.d.ts.map +0 -1
  51. package/dist/esm/delete-header.js.map +0 -1
  52. package/dist/esm/env.d.ts.map +0 -1
  53. package/dist/esm/env.js.map +0 -1
  54. package/dist/esm/get-header.d.ts.map +0 -1
  55. package/dist/esm/get-header.js.map +0 -1
  56. package/dist/esm/handle-304-response.d.ts.map +0 -1
  57. package/dist/esm/handle-304-response.js.map +0 -1
  58. package/dist/esm/index.d.ts.map +0 -1
  59. package/dist/esm/index.js.map +0 -1
  60. package/dist/esm/is-cacheable.d.ts.map +0 -1
  61. package/dist/esm/is-cacheable.js.map +0 -1
  62. package/dist/esm/is-iterable.d.ts.map +0 -1
  63. package/dist/esm/is-iterable.js.map +0 -1
  64. package/dist/esm/otplease.d.ts.map +0 -1
  65. package/dist/esm/otplease.js.map +0 -1
  66. package/dist/esm/package.json +0 -3
  67. package/dist/esm/raw-header.d.ts.map +0 -1
  68. package/dist/esm/raw-header.js.map +0 -1
  69. package/dist/esm/redirect.d.ts.map +0 -1
  70. package/dist/esm/redirect.js.map +0 -1
  71. package/dist/esm/revalidate.d.ts.map +0 -1
  72. package/dist/esm/revalidate.js.map +0 -1
  73. package/dist/esm/set-cache-headers.d.ts.map +0 -1
  74. package/dist/esm/set-cache-headers.js.map +0 -1
  75. package/dist/esm/set-raw-header.d.ts.map +0 -1
  76. package/dist/esm/set-raw-header.js.map +0 -1
  77. package/dist/esm/string-encoding.d.ts.map +0 -1
  78. package/dist/esm/string-encoding.js.map +0 -1
  79. package/dist/esm/token-response.d.ts.map +0 -1
  80. package/dist/esm/token-response.js.map +0 -1
  81. package/dist/esm/web-auth-challenge.d.ts.map +0 -1
  82. package/dist/esm/web-auth-challenge.js.map +0 -1
  83. /package/dist/{esm/add-header.d.ts → add-header.d.ts} +0 -0
  84. /package/dist/{esm/add-header.js → add-header.js} +0 -0
  85. /package/dist/{esm/auth.d.ts → auth.d.ts} +0 -0
  86. /package/dist/{esm/auth.js → auth.js} +0 -0
  87. /package/dist/{esm/cache-entry.d.ts → cache-entry.d.ts} +0 -0
  88. /package/dist/{esm/cache-entry.js → cache-entry.js} +0 -0
  89. /package/dist/{esm/cache-revalidate.d.ts → cache-revalidate.d.ts} +0 -0
  90. /package/dist/{esm/cache-revalidate.js → cache-revalidate.js} +0 -0
  91. /package/dist/{esm/delete-header.d.ts → delete-header.d.ts} +0 -0
  92. /package/dist/{esm/delete-header.js → delete-header.js} +0 -0
  93. /package/dist/{esm/env.d.ts → env.d.ts} +0 -0
  94. /package/dist/{esm/env.js → env.js} +0 -0
  95. /package/dist/{esm/get-header.d.ts → get-header.d.ts} +0 -0
  96. /package/dist/{esm/get-header.js → get-header.js} +0 -0
  97. /package/dist/{esm/handle-304-response.d.ts → handle-304-response.d.ts} +0 -0
  98. /package/dist/{esm/handle-304-response.js → handle-304-response.js} +0 -0
  99. /package/dist/{esm/index.d.ts → index.d.ts} +0 -0
  100. /package/dist/{esm/index.js → index.js} +0 -0
  101. /package/dist/{esm/is-cacheable.d.ts → is-cacheable.d.ts} +0 -0
  102. /package/dist/{esm/is-cacheable.js → is-cacheable.js} +0 -0
  103. /package/dist/{esm/is-iterable.d.ts → is-iterable.d.ts} +0 -0
  104. /package/dist/{esm/is-iterable.js → is-iterable.js} +0 -0
  105. /package/dist/{esm/otplease.d.ts → otplease.d.ts} +0 -0
  106. /package/dist/{esm/otplease.js → otplease.js} +0 -0
  107. /package/dist/{esm/raw-header.d.ts → raw-header.d.ts} +0 -0
  108. /package/dist/{esm/raw-header.js → raw-header.js} +0 -0
  109. /package/dist/{esm/redirect.d.ts → redirect.d.ts} +0 -0
  110. /package/dist/{esm/redirect.js → redirect.js} +0 -0
  111. /package/dist/{esm/revalidate.d.ts → revalidate.d.ts} +0 -0
  112. /package/dist/{esm/revalidate.js → revalidate.js} +0 -0
  113. /package/dist/{esm/set-cache-headers.d.ts → set-cache-headers.d.ts} +0 -0
  114. /package/dist/{esm/set-cache-headers.js → set-cache-headers.js} +0 -0
  115. /package/dist/{esm/set-raw-header.d.ts → set-raw-header.d.ts} +0 -0
  116. /package/dist/{esm/set-raw-header.js → set-raw-header.js} +0 -0
  117. /package/dist/{esm/string-encoding.d.ts → string-encoding.d.ts} +0 -0
  118. /package/dist/{esm/string-encoding.js → string-encoding.js} +0 -0
  119. /package/dist/{esm/token-response.d.ts → token-response.d.ts} +0 -0
  120. /package/dist/{esm/token-response.js → token-response.js} +0 -0
  121. /package/dist/{esm/web-auth-challenge.d.ts → web-auth-challenge.d.ts} +0 -0
  122. /package/dist/{esm/web-auth-challenge.js → web-auth-challenge.js} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache-entry.js","sourceRoot":"","sources":["../../src/cache-entry.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,4EAA4E;AAC5E,yDAAyD;AACzD,EAAE;AACF,sBAAsB;AACtB,EAAE;AACF,gBAAgB;AAChB,yBAAyB;AACzB,YAAY;AACZ,SAAS;AACT,EAAE;AACF,0EAA0E;AAC1E,+CAA+C;AAC/C,EAAE;AACF,8EAA8E;AAC9E,4DAA4D;AAC5D,EAAE;AACF,2EAA2E;AAC3E,eAAe;AAGf,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,GAAG,MAAM,sBAAsB,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO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ores Buffer objects, and it's convenient to have headers/body\n// together, so we have a simple data structure for this.\n//\n// The shape of it is:\n//\n// [head length]\n// <status code in ascii>\n// [headers]\n// [body]\n//\n// The [UInt32BE head length] is 4 bytes specifying the full length of the\n// status code plus all header keys and values.\n//\n// The [headers] section is key/value/key2/value2/... where each key and value\n// is a 4-byte Uint32BE length, followed by that many bytes.\n//\n// From there, the body can be of any indeterminate length, and is the rest\n// of the file.\n\nimport type { ErrorCauseOptions } from '@vltpkg/error-cause'\nimport { error } from '@vltpkg/error-cause'\nimport type { Integrity, JSONField } from '@vltpkg/types'\nimport ccp from 'cache-control-parser'\nimport { createHash } from 'node:crypto'\nimport type { InspectOptions } from 'node:util'\nimport { inspect } from 'node:util'\nimport { gunzipSync } from 'node:zlib'\nimport { getRawHeader, setRawHeader } from './raw-header.ts'\nimport {\n getDecodedValue,\n getEncondedValue,\n} from './string-encoding.ts'\n\nexport type JSONObj = Record<string, JSONField>\n\nconst readSize = (buf: Uint8Array, offset: number) => {\n const a = buf[offset]\n const b = buf[offset + 1]\n const c = buf[offset + 2]\n const d = buf[offset + 3]\n\n // not possible, we check the length\n /* c8 ignore start */\n if (\n a === undefined ||\n b === undefined ||\n c === undefined ||\n d === undefined\n ) {\n throw error('Invalid buffer, not long enough to readSize', {\n found: buf.length,\n })\n }\n /* c8 ignore stop */\n\n return (a << 24) | (b << 16) | (c << 8) | d\n}\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport type CacheEntryOptions = {\n /**\n * An optional body to use.\n *\n * This is used when decoding a cache entry from a buffer, and the body\n * is already in a ArrayBuffer we can use. When this option is\n * provided the `addBody` method should not be used.\n */\n body?: Uint8Array\n\n /**\n * An optional content length of the body to use, if undefined the\n * content-length header will be used.\n */\n contentLength?: number\n\n /**\n * The expected integrity value for this response body\n */\n integrity?: Integrity\n /**\n * Whether to trust the integrity, or calculate the actual value.\n *\n * This indicates that we just accept whatever the integrity is as the actual\n * integrity for saving back to the cache, because it's coming directly from\n * the registry that we fetched a packument from, and is an initial gzipped\n * artifact request.\n */\n trustIntegrity?: boolean\n\n /**\n * If the server does not serve a `stale-while-revalidate` value in the\n * `cache-control` header, then this multiplier is applied to the `max-age`\n * or `s-maxage` values.\n *\n * By default, this is `60`, so for example a response that is cacheable for\n * 5 minutes will allow a stale response while revalidating for up to 5\n * hours.\n *\n * If the server *does* provide a `stale-while-revalidate` value, then that\n * is always used.\n *\n * Set to 0 to prevent any `stale-while-revalidate` behavior unless\n * explicitly allowed by the server's `cache-control` header.\n */\n 'stale-while-revalidate-factor'?: number\n}\n\nexport class CacheEntry {\n #statusCode: number\n /** The raw headers as an array of buffers */\n #headers: Uint8Array[]\n /** The body buffer, used if the content length is known. */\n #body?: Uint8Array\n /**\n * If the content length is unknown we save the body in multiple parts\n * in order to only concatenate once at the end and save extra memory copies.\n */\n #bodyParts: Uint8Array[] = []\n /** Used to track the length of the body while reading chunks */\n #bodyLength = 0\n /** The total length of the body, if known */\n #contentLength?: number\n #integrity?: Integrity\n #integrityActual?: Integrity\n #json?: JSONObj\n #trustIntegrity\n #staleWhileRevalidateFactor\n\n constructor(\n statusCode: number,\n headers: Uint8Array[],\n {\n body,\n integrity,\n trustIntegrity = false,\n 'stale-while-revalidate-factor':\n staleWhileRevalidateFactor = 60,\n contentLength,\n }: CacheEntryOptions = {},\n ) {\n this.#headers = headers\n this.#statusCode = statusCode\n this.#trustIntegrity = trustIntegrity\n this.#staleWhileRevalidateFactor = staleWhileRevalidateFactor\n if (integrity) this.integrity = integrity\n\n // if content-legnth is known then we'll only allocate that much memory\n // and we'll avoid copying memory around when adding new chunks.\n if (contentLength != null && typeof contentLength === 'number') {\n this.#contentLength = contentLength\n }\n\n // if a body is provided then use that, in this case the `addBody`\n // method should no longer be used.\n if (body) {\n const buffer = new ArrayBuffer(body.byteLength)\n this.#body = new Uint8Array(buffer, 0, body.byteLength)\n this.#body.set(body, 0)\n this.#bodyLength = body.byteLength\n /* c8 ignore start */\n } else if (this.#contentLength) {\n const buffer = new ArrayBuffer(this.#contentLength)\n this.#body = new Uint8Array(buffer, 0, this.#contentLength)\n this.#bodyLength = 0\n }\n /* c8 ignore stop */\n }\n\n get #headersAsObject(): [string, string][] {\n const ret: [string, string][] = []\n for (let i = 0; i < this.#headers.length - 1; i += 2) {\n const key = getDecodedValue(this.#headers[i])\n const val = getDecodedValue(this.#headers[i + 1])\n ret.push([key, val])\n }\n return ret\n }\n\n toJSON() {\n const {\n statusCode,\n valid,\n staleWhileRevalidate,\n cacheControl,\n date,\n contentType,\n integrity,\n maxAge,\n isGzip,\n isJSON,\n } = this\n /* c8 ignore start */\n const age =\n date ?\n Math.floor((Date.now() - date.getTime()) / 1000)\n : undefined\n const expires =\n date ? new Date(date.getTime() + this.maxAge * 1000) : undefined\n /* c8 ignore end */\n return Object.fromEntries(\n Object.entries({\n statusCode,\n headers: this.#headersAsObject,\n contentType,\n integrity,\n date,\n expires,\n cacheControl,\n valid,\n staleWhileRevalidate,\n age,\n maxAge,\n isGzip,\n isJSON,\n }).filter(([_, v]) => v !== undefined),\n )\n }\n\n [kCustomInspect](depth: number, options: InspectOptions): string {\n const str = inspect(this.toJSON(), {\n depth,\n ...options,\n })\n return `@vltpkg/registry-client.CacheEntry ${str}`\n }\n\n #date?: Date\n get date(): Date | undefined {\n if (this.#date) return this.#date\n const dh = this.getHeaderString('date')\n if (dh) this.#date = new Date(dh)\n return this.#date\n }\n\n #maxAge?: number\n get maxAge(): number {\n if (this.#maxAge !== undefined) return this.#maxAge\n // see if the max-age has not yet been crossed\n // default to 5m if maxage is not set, as some registries\n // do not set a cache control header at all.\n const cc = this.cacheControl\n this.#maxAge = cc['max-age'] || cc['s-maxage'] || 300\n return this.#maxAge\n }\n\n #cacheControl?: ccp.CacheControl\n get cacheControl(): ccp.CacheControl {\n if (this.#cacheControl) return this.#cacheControl\n const cc = this.getHeaderString('cache-control')\n this.#cacheControl = cc ? ccp.parse(cc) : {}\n return this.#cacheControl\n }\n\n #staleWhileRevalidate?: boolean\n get staleWhileRevalidate(): boolean {\n if (this.#staleWhileRevalidate !== undefined)\n return this.#staleWhileRevalidate\n if (this.valid || !this.date) return true\n const swv =\n this.cacheControl['stale-while-revalidate'] ??\n this.maxAge * this.#staleWhileRevalidateFactor\n\n this.#staleWhileRevalidate =\n this.date.getTime() + swv * 1000 > Date.now()\n return this.#staleWhileRevalidate\n }\n\n #contentType?: string\n get contentType() {\n if (this.#contentType !== undefined) return this.#contentType\n this.#contentType = this.getHeaderString('content-type') ?? ''\n return this.#contentType\n }\n\n /**\n * `true` if the entry represents a cached response that is still\n * valid to use.\n */\n #valid?: boolean\n get valid(): boolean {\n if (this.#valid !== undefined) return this.#valid\n\n // immutable = never changes\n if (this.cacheControl.immutable) return (this.#valid = true)\n\n // some registries do text/json, some do application/json,\n // some do application/vnd.npm.install-v1+json\n // If it's NOT json, it's an immutable tarball\n const ct = this.contentType\n if (ct && !/\\bjson\\b/.test(ct)) return (this.#valid = true)\n\n // see if the max-age has not yet been crossed\n // default to 5m if maxage is not set, as some registries\n // do not set a cache control header at all.\n if (!this.date) return (this.#valid = false)\n this.#valid =\n this.date.getTime() + this.maxAge * 1000 > Date.now()\n return this.#valid\n }\n\n /**\n * Add contents to the entry body.\n */\n addBody(b: Uint8Array) {\n // when the content length is uknown we store each chunk in an array that\n // later on is concatenate into a single buffer, otherwise we just append\n // the new chunk of bytes to the already allocated buffer keeping track\n // of the current offset in the `this.#bodyLength` property.\n if (!this.#body) {\n this.#bodyParts.push(b)\n this.#bodyLength += b.byteLength\n } else {\n this.#body.set(b, this.#bodyLength)\n this.#bodyLength += b.byteLength\n }\n }\n\n get statusCode() {\n return this.#statusCode\n }\n get headers(): Uint8Array[] {\n return this.#headers\n }\n\n /**\n * Returns the body as a single Uint8Array, concatenating parts if needed.\n */\n get _body(): Uint8Array {\n // if the body is known we'll just use that\n if (this.#body) return this.#body\n // otherwise we concatenate the body parts into a single buffer\n const buffer = new ArrayBuffer(this.#bodyLength)\n const b = new Uint8Array(buffer, 0, this.#bodyLength)\n let off = 0\n for (const part of this.#bodyParts) {\n b.set(part, off)\n off += part.byteLength\n }\n return b\n }\n\n /**\n * Check that the sri integrity string that was provided to the ctor\n * matches the body that we actually received. This should only be called\n * AFTER the entire body has been completely downloaded.\n *\n * This method **will throw** if the integrity values do not match.\n *\n * Note that this will *usually* not be true if the value is coming out of\n * the cache, because the cache entries are un-gzipped in place. It should\n * _only_ be called for artifacts that come from an actual http response.\n *\n * Returns true if anything was actually verified.\n */\n checkIntegrity(\n context: ErrorCauseOptions = {},\n ): this is CacheEntry & { integrity: Integrity } {\n if (!this.#integrity) return false\n if (this.integrityActual !== this.#integrity) {\n throw error('Integrity check failure', {\n code: 'EINTEGRITY',\n response: this,\n wanted: this.#integrity,\n found: this.integrityActual,\n ...context,\n })\n }\n return true\n }\n\n get integrityActual(): Integrity {\n if (this.#integrityActual) return this.#integrityActual\n const hash = createHash('sha512')\n hash.update(this._body)\n const i: Integrity = `sha512-${hash.digest('base64')}`\n this.integrityActual = i\n return i\n }\n\n set integrityActual(i: Integrity) {\n this.#integrityActual = i\n this.setHeader('integrity', i)\n }\n\n set integrity(i: Integrity | undefined) {\n if (!this.#integrity && i) {\n this.#integrity = i\n if (this.#trustIntegrity) this.integrityActual = i\n }\n }\n get integrity() {\n return this.#integrity\n }\n\n /**\n * Give it a key, and it'll return the buffer of that header value\n */\n getHeader(h: string): Uint8Array | undefined {\n return getRawHeader(this.#headers, h)\n }\n\n /**\n * Give it a key, and it'll return the decoded string of that header value\n */\n getHeaderString(h: string): string | undefined {\n const value = getRawHeader(this.#headers, h)\n if (value) {\n return getDecodedValue(value)\n }\n }\n\n /**\n * Set a header to a specific value\n */\n setHeader(h: string, value: Uint8Array | string) {\n this.#headers = setRawHeader(this.#headers, h, value)\n }\n\n /**\n * Return the body of the entry as a Buffer\n */\n buffer(): Buffer {\n return Buffer.from(\n this._body.buffer,\n this._body.byteOffset,\n this._body.byteLength,\n )\n }\n\n // return the buffer if it's a tarball, or the parsed\n // JSON if it's not.\n get body(): Uint8Array | Record<string, any> {\n return this.isJSON ? this.json() : this.buffer()\n }\n\n #isJSON?: boolean\n get isJSON(): boolean {\n if (this.#isJSON !== undefined) return this.#isJSON\n const ct = this.getHeaderString('content-type')\n // if it says it's json, assume json\n if (ct) return (this.#isJSON = /\\bjson\\b/.test(ct))\n const text = this.text()\n // don't cache, because we might just not have it yet.\n if (!text) return false\n // all registry json starts with {, and no tarball ever can.\n this.#isJSON = text.startsWith('{')\n if (this.#isJSON) this.setHeader('content-type', 'text/json')\n return this.#isJSON\n }\n\n #isGzip?: boolean\n get isGzip(): boolean {\n if (this.#isGzip !== undefined) return this.#isGzip\n const ce = this.getHeaderString('content-encoding')\n if (ce && !/\\bgzip\\b/.test(ce)) return (this.#isGzip = false)\n const buf = this._body\n if (buf.length < 2) return false\n this.#isGzip = buf[0] === 0x1f && buf[1] === 0x8b\n if (this.#isGzip) {\n this.setHeader('content-encoding', 'gzip')\n } else {\n this.setHeader('content-encoding', 'identity')\n this.setHeader('content-length', String(this.#bodyLength))\n }\n return this.#isGzip\n }\n\n /**\n * Un-gzip encode the body.\n * Returns true if it was previously gzip (so something was done), otherwise\n * returns false.\n */\n unzip() {\n if (this.isGzip) {\n // we know that if we know it's gzip, that the body has been\n // flattened to a single buffer, so save the extra call.\n /* c8 ignore start */\n if (this._body.length === 0)\n throw error('Invalid buffer, cant unzip')\n /* c8 ignore stop */\n const b = gunzipSync(this._body)\n this.setHeader('content-encoding', 'identity')\n const u8 = new Uint8Array(b.buffer, b.byteOffset, b.byteLength)\n this.#body = u8\n this.#bodyLength = u8.byteLength\n this.#contentLength = u8.byteLength\n this.setHeader('content-length', String(this.#contentLength))\n this.#isGzip = false\n return true\n }\n return false\n }\n\n /**\n * Return the body of the entry as utf8 text\n * Automatically unzips if the content is gzip encoded\n */\n text() {\n this.unzip()\n return getDecodedValue(this._body)\n }\n\n /**\n * Parse the entry body as JSON and return the result\n */\n json(): JSONObj {\n if (this.#json !== undefined) return this.#json\n const text = this.text()\n const obj = JSON.parse(text || '{}') as JSONObj\n this.#json = obj\n return obj\n }\n\n /**\n * Pass the contents of a @vltpkg/cache.Cache object as a buffer,\n * and this static method will decode it into a CacheEntry representing\n * the cached response.\n */\n static decode(buffer: Uint8Array): CacheEntry {\n if (buffer.length < 4) {\n return emptyCacheEntry\n }\n const headSize = readSize(buffer, 0)\n if (buffer.length < headSize) {\n return emptyCacheEntry\n }\n const statusCode = Number(getDecodedValue(buffer.subarray(4, 7)))\n const headersBuffer = buffer.subarray(7, headSize)\n // walk through the headers array, building up the rawHeaders\n const headers: Uint8Array[] = []\n let i = 0\n let integrity: Integrity | undefined = undefined\n while (i < headersBuffer.length - 4) {\n const size = readSize(headersBuffer, i)\n const val = headersBuffer.subarray(i + 4, i + size)\n // if the last one was the key integrity, then this one is the value\n if (headers.length % 2 === 1) {\n const k = getDecodedValue(\n headers[headers.length - 1],\n ).toLowerCase()\n if (k === 'integrity')\n integrity = getDecodedValue(val) as Integrity\n }\n headers.push(val)\n i += size\n }\n const body = buffer.subarray(headSize)\n\n const c = new CacheEntry(\n statusCode,\n setRawHeader(\n headers,\n 'content-length',\n String(body.byteLength),\n ),\n {\n body,\n integrity,\n trustIntegrity: true,\n contentLength: body.byteLength,\n },\n )\n\n if (c.isJSON) {\n try {\n c.json()\n } catch {\n return emptyCacheEntry\n }\n }\n return c\n }\n\n static isGzipEntry(buffer: Uint8Array): boolean {\n if (buffer.length < 4) return false\n const headSize = readSize(buffer, 0)\n const gzipBytes = buffer.subarray(headSize, headSize + 2)\n return gzipBytes[0] === 0x1f && gzipBytes[1] === 0x8b\n }\n\n /**\n * Encode the entry as a single Buffer for writing to the cache\n */\n encode(): Buffer {\n if (this.isJSON) this.json()\n const statusStr = String(this.#statusCode)\n const statusBytes = getEncondedValue(statusStr)\n\n // compute headLength = 4 (length field itself) + statusBytes + Σ(4 + headerLen) for each header item\n let headLength = 4 + statusBytes.byteLength\n for (const h of this.#headers) headLength += 4 + h.byteLength\n\n // allocate and fill head length prefix (big-endian)\n const headLenBytes = new Uint8Array(4)\n headLenBytes[0] = (headLength >> 24) & 0xff\n headLenBytes[1] = (headLength >> 16) & 0xff\n headLenBytes[2] = (headLength >> 8) & 0xff\n headLenBytes[3] = headLength & 0xff\n\n // header chunks: [len, bytes] for each header item\n const headerChunks: Uint8Array[] = []\n for (const h of this.#headers) {\n const l = headLenBytes.byteLength + h.byteLength\n const lb = new Uint8Array(4)\n lb[0] = (l >> 24) & 0xff\n lb[1] = (l >> 16) & 0xff\n lb[2] = (l >> 8) & 0xff\n lb[3] = l & 0xff\n headerChunks.push(lb, h)\n }\n\n // total size\n const total =\n headLenBytes.byteLength +\n statusBytes.byteLength +\n headerChunks.reduce((n, b) => n + b.byteLength, 0) +\n this._body.byteLength\n\n // returns the concatenate buffer with all the pieces\n const outBuffer = new ArrayBuffer(total)\n const out = Buffer.from(outBuffer, 0, total)\n let off = 0\n out.set(headLenBytes, off)\n off += headLenBytes.byteLength\n out.set(statusBytes, off)\n off += statusBytes.byteLength\n for (const chunk of headerChunks) {\n out.set(chunk, off)\n off += chunk.byteLength\n }\n out.set(this._body, off)\n return out\n }\n}\n\nconst emptyCacheEntry = new CacheEntry(0, [], { contentLength: 0 })\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache-revalidate.d.ts","sourceRoot":"","sources":["../../src/cache-revalidate.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,QAAQ,SACb,MAAM,UACJ,MAAM,GAAG,KAAK,OACjB,MAAM,GAAG,GAAG,KAChB,IASF,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache-revalidate.js","sourceRoot":"","sources":["../../src/cache-revalidate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAEx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YACvD,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,IAAI,CACP,yBAAyB,EACzB,+BAA+B,CAChC,CAAA;YACH,CAAC;YACD,oBAAoB;YACpB,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAA;QAC3C,CAAC;QACD,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACvB,sDAAsD;QACtD,gDAAgD;QAChD,gDAAgD;QAChD,oBAAoB;QACpB,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAA;QAC1D,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE;YACzC,QAAQ;YACR,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC;YACnC,GAAG;SACJ,CAAC,CAAA;QACF,KAAK,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,CAAA;QAC9B,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAA;QAChB,wEAAwE;QACxE,+EAA+E;QAC/E,0EAA0E;QAC1E,oDAAoD;QACpD,gDAAgD;QAChD,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,EAAE,CAAA;QACd,CAAC;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { spawn } from 'node:child_process'\nimport { __CODE_SPLIT_SCRIPT_NAME } from './revalidate.ts'\nimport { pathToFileURL } from 'node:url'\n\nconst isDeno =\n (globalThis as typeof globalThis & { Deno?: any }).Deno != undefined\n\nlet didProcessBeforeExitHook = false\nconst registered = new Map<string, Set<string>>()\n\nexport const register = (\n path: string,\n method: 'HEAD' | 'GET',\n url: string | URL,\n): void => {\n const r = registered.get(path) ?? new Set<string>()\n const key = `${method} ${url}`\n r.add(key)\n registered.set(path, r)\n if (!didProcessBeforeExitHook) {\n didProcessBeforeExitHook = true\n process.on('beforeExit', handleBeforeExit)\n }\n}\n\nconst handleBeforeExit = () => {\n for (const [path, r] of registered) {\n /* c8 ignore next */\n if (!r.size) return\n const env = { ...process.env }\n const args = []\n /* c8 ignore start */\n // When compiled the script to be run is passed as an\n // environment variable and then routed by the main entry point\n if (process.env.__VLT_INTERNAL_COMPILED) {\n env.__VLT_INTERNAL_MAIN = pathToFileURL(\n __CODE_SPLIT_SCRIPT_NAME,\n ).toString()\n args.push(path)\n } else {\n // If we are running deno from source we need to add the\n // unstable flags we need. The '-A' flag does not need\n // to be passed in as Deno supplies that automatically.\n if (isDeno) {\n args.push(\n '--unstable-node-globals',\n '--unstable-bare-node-builtins',\n )\n }\n /* c8 ignore stop */\n args.push(__CODE_SPLIT_SCRIPT_NAME, path)\n }\n registered.delete(path)\n // Deno on Windows does not support detached processes\n // https://github.com/denoland/deno/issues/25867\n // TODO: figure out something better to do here?\n /* c8 ignore next */\n const detached = !(isDeno && process.platform === 'win32')\n const proc = spawn(process.execPath, args, {\n detached,\n stdio: ['pipe', 'ignore', 'ignore'],\n env,\n })\n for (const key of r) {\n proc.stdin.write(`${key}\\0`)\n }\n proc.stdin.end()\n // Another Deno oddity. Calling unref on a spawned process will kill the\n // process unless it is detached. https://github.com/denoland/deno/issues/21446\n // So in this case Deno on Windows will be slower to exit the main process\n // since it will wait for the child process to exit.\n // TODO: figure out something better to do here?\n if (detached) {\n proc.unref()\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"delete-header.d.ts","sourceRoot":"","sources":["../../src/delete-header.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GACvB,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,MA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C;QACH,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;SAAM,IACL,UAAU,CAA0C,OAAO,CAAC,EAC5D,CAAC;QACD,OAAO,YAAY,CAAC,CAAC,GAAG,OAAO,CAAiB,EAAE,GAAG,CAAC,CAAA;IACxD,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,CAAC,GAAG,CAAC,CAAA;QACnB,OAAO,OAAO,CAAA;IAChB,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { isIterable } from './is-iterable.ts'\n\nexport const deleteHeader = <\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): H => {\n if (!headers) return {} as H\n if (Array.isArray(headers)) {\n if (!headers.length) return headers\n if (Array.isArray(headers[0])) {\n const index = (headers as [string, string][]).findIndex(\n ([k]) => k.toLowerCase() === key.toLowerCase(),\n )\n if (index !== -1) headers.splice(index, 1)\n } else {\n const h = headers as string[]\n for (let i = 0; i < h.length; i += 2) {\n if (h[i]?.toLowerCase() === key.toLowerCase()) {\n headers.splice(i, 2)\n break\n }\n }\n }\n return headers\n } else if (\n isIterable<[string, string[] | string | undefined]>(headers)\n ) {\n return deleteHeader([...headers] as unknown as H, key)\n } else {\n delete headers[key]\n return headers\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM,SAAc,CAAA;AACjC,eAAO,MAAM,KAAK,SAAwB,CAAA;AAG1C,eAAO,MAAM,MAAM,SAA+C,CAAA;AAGlE,eAAO,MAAM,GAAG,oBAAwC,CAAA;AACxD,eAAO,MAAM,IAAI,oBAA0C,CAAA;AAC3D,eAAO,MAAM,IAAI,oBAA0C,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,cAAc,CAAA;AAE/B,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,UAGrB,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAA;AAE1D,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;AACjC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;AAC1C,kEAAkE;AAClE,gCAAgC;AAChC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAA;AAElE,4DAA4D;AAC5D,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;AACxD,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3D,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA","sourcesContent":["import proc from 'node:process'\n\nconst { Deno, Bun } = globalThis as typeof globalThis & {\n Deno: undefined | object\n Bun: undefined | object\n}\n\nconst isObj = (v: unknown) => typeof v === 'object' && !!v\n\nexport const isDeno = isObj(Deno)\nexport const isBun = !isDeno && isObj(Bun)\n// bun and deno also report 'node' in process.versions so its only\n// node if it is not bun or deno\nexport const isNode = !isDeno && !isBun && 'node' in proc.versions\n\n// All the runtimes put their versions into process.versions\nexport const bun = isBun ? proc.versions.bun : undefined\nexport const deno = isDeno ? proc.versions.deno : undefined\nexport const node = isNode ? proc.versions.node : undefined\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-header.d.ts","sourceRoot":"","sources":["../../src/get-header.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,YAEhB,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,GACR,IAAI,GACJ,SAAS,OACR,MAAM,KACV,MAAM,EAAE,GAAG,MAAM,GAAG,SA8BtB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-header.js","sourceRoot":"","sources":["../../src/get-header.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAI,CAAU,EAAoB,EAAE,CACrD,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAA;AAEtD,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,OAKa,EACb,GAAW,EACoB,EAAE;IACjC,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAA;IAC9B,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;IACvB,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,OAAO,SAAS,CAAA;QACrC,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9B,yBAAyB;YACzB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAGlB,EAAE,CAAC;gBACJ,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG;oBAAE,OAAO,CAAC,CAAA;YACvC,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACpC,sBAAsB;YACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3C,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,GAAG;oBAAE,OAAO,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;YAC9D,CAAC;QACH,CAAC;IACH,CAAC;SAAM,IACL,UAAU,CAA0C,OAAO,CAAC,EAC5D,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG;gBAAE,OAAO,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG;gBAAE,OAAO,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["const isIterable = <T>(o: unknown): o is Iterable<T> =>\n !!o && typeof o === 'object' && Symbol.iterator in o\n\nexport const getHeader = (\n headers:\n | Iterable<[string, string[] | string | undefined]>\n | Record<string, string[] | string | undefined>\n | string[]\n | null\n | undefined,\n key: string,\n): string[] | string | undefined => {\n if (!headers) return undefined\n key = key.toLowerCase()\n if (Array.isArray(headers)) {\n if (!headers.length) return undefined\n if (Array.isArray(headers[0])) {\n // [string,HeaderValue][]\n for (const [k, v] of headers as unknown as [\n string,\n string[] | string,\n ][]) {\n if (k.toLowerCase() === key) return v\n }\n } else if (headers.length % 2 === 0) {\n // [k, v, k2, v2, ...]\n for (let i = 0; i < headers.length; i += 2) {\n if (headers[i]?.toLowerCase() === key) return headers[i + 1]\n }\n }\n } else if (\n isIterable<[string, string[] | string | undefined]>(headers)\n ) {\n for (const [k, v] of headers) {\n if (k.toLowerCase() === key) return v\n }\n } else {\n for (const [k, v] of Object.entries(headers)) {\n if (k.toLowerCase() === key) return v\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"handle-304-response.d.ts","sourceRoot":"","sources":["../../src/handle-304-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,eAAO,MAAM,iBAAiB,SACtB,UAAU,CAAC,YAAY,UACrB,UAAU,KACjB,KAAK,IAAI,UASX,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"handle-304-response.js","sourceRoot":"","sources":["../../src/handle-304-response.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAA6B,EAC7B,KAAkB,EACG,EAAE;IACvB,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IAEnD,MAAM,CAAC,GACL,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IAC7D,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAC1B,2CAA2C;IAC3C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAA;IAClB,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import type { Dispatcher } from 'undici'\nimport type { CacheEntry } from './cache-entry.ts'\n\nexport const handle304Response = (\n resp: Dispatcher.ResponseData,\n entry?: CacheEntry,\n): entry is CacheEntry => {\n if (resp.statusCode !== 304 || !entry) return false\n\n const d =\n String(resp.headers.date ?? '') || new Date().toUTCString()\n entry.setHeader('date', d)\n // shouldn't have a body, but just in case.\n res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AAC,MAAM,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAA;YACtB,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;YAC7D,IAAI,WAAW,IAAI,OAAO,EAAE,CAAC;gBAC3B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;YACjD,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAiB,EAAE,EAAE,CAC7C,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CACtB,CAAA;QACD,OAAO,MAAM,IAAI,OAAO,CAAa,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;YAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import { Cache } from '@vltpkg/cache'\nimport { register as cacheUnzipRegister } from '@vltpkg/cache-unzip'\nimport { error } from '@vltpkg/error-cause'\nimport { asError } from '@vltpkg/types'\nimport { logRequest } from '@vltpkg/output'\nimport type { Integrity } from '@vltpkg/types'\nimport { urlOpen } from '@vltpkg/url-open'\nimport { XDG } from '@vltpkg/xdg'\nimport { dirname, resolve } from 'node:path'\nimport { setTimeout } from 'node:timers/promises'\nimport { loadPackageJson } from 'package-json-from-dist'\nimport type { Dispatcher } from 'undici'\nimport { Agent, RetryAgent } from 'undici'\nimport { addHeader } from './add-header.ts'\nimport type { Token } from './auth.ts'\nimport {\n deleteToken,\n getKC,\n getToken,\n isToken,\n keychains,\n setToken,\n} from './auth.ts'\nimport type { JSONObj } from './cache-entry.ts'\nimport { CacheEntry } from './cache-entry.ts'\nimport { register } from './cache-revalidate.ts'\nimport { bun, deno, node } from './env.ts'\nimport { handle304Response } from './handle-304-response.ts'\nimport { otplease } from './otplease.ts'\nimport { isRedirect, redirect } from './redirect.ts'\nimport { setCacheHeaders } from './set-cache-headers.ts'\nimport type { TokenResponse } from './token-response.ts'\nimport { getTokenResponse } from './token-response.ts'\nimport type { WebAuthChallenge } from './web-auth-challenge.ts'\nimport { getWebAuthChallenge } from './web-auth-challenge.ts'\nimport { getEncondedValue } from './string-encoding.ts'\nexport {\n CacheEntry,\n deleteToken,\n getKC,\n isToken,\n keychains,\n setToken,\n type JSONObj,\n type Token,\n type TokenResponse,\n type WebAuthChallenge,\n}\n\nexport type CacheableMethod = 'GET' | 'HEAD'\nexport const isCacheableMethod = (m: unknown): m is CacheableMethod =>\n m === 'GET' || m === 'HEAD'\n\nexport type RegistryClientOptions = {\n /**\n * Path on disk where the cache should be stored\n *\n * Defaults to the XDG cache folder for `vlt/registry-client`\n */\n cache?: string\n /**\n * Number of retries to perform when encountering network errors or\n * likely-transient errors from git hosts.\n */\n 'fetch-retries'?: number\n /** The exponential backoff factor to use when retrying git hosts */\n 'fetch-retry-factor'?: number\n /** Number of milliseconds before starting first retry */\n 'fetch-retry-mintimeout'?: number\n /** Maximum number of milliseconds between two retries */\n 'fetch-retry-maxtimeout'?: number\n\n /** the identity to use for storing auth tokens */\n identity?: string\n\n /**\n * If the server does not serve a `stale-while-revalidate` value in the\n * `cache-control` header, then this multiplier is applied to the `max-age`\n * or `s-maxage` values.\n *\n * By default, this is `60`, so for example a response that is cacheable for\n * 5 minutes will allow a stale response while revalidating for up to 5\n * hours.\n *\n * If the server *does* provide a `stale-while-revalidate` value, then that\n * is always used.\n *\n * Set to 0 to prevent any `stale-while-revalidate` behavior unless\n * explicitly allowed by the server's `cache-control` header.\n */\n 'stale-while-revalidate-factor'?: number\n}\n\nexport type RegistryClientRequestOptions = Omit<\n Dispatcher.RequestOptions,\n 'method' | 'path'\n> & {\n /**\n * `path` should not be set when using the RegistryClient.\n * It will be overwritten with the path on the URL being requested.\n * This only here for compliance with the DispatchOptions base type.\n * @deprecated\n */\n path?: string\n\n /**\n * Method is optional, defaults to 'GET'\n */\n method?: Dispatcher.DispatchOptions['method']\n /**\n * Provide an SRI string to verify integrity of the item being fetched.\n *\n * This is only relevant when it must make a request to the registry. Once in\n * the local disk cache, items are assumed to be trustworthy.\n */\n integrity?: Integrity\n\n /**\n * Set to true if the integrity should be trusted implicitly without\n * a recalculation, for example if it comes from a trusted registry that\n * also serves the tarball itself.\n */\n trustIntegrity?: boolean\n\n /**\n * Follow up to 10 redirections by default. Set this to 0 to just return\n * the 3xx response. If the max redirections are expired, and we still get\n * a redirection response, then fail the request. Redirection cycles are\n * always treated as an error.\n */\n maxRedirections?: number\n\n /**\n * the number of redirections that have already been seen. This is used\n * internally, and should always start at 0.\n * @internal\n */\n redirections?: Set<string>\n\n /**\n * Set to `false` to suppress ANY lookups from cache. This will also\n * prevent storing the result to the cache.\n */\n useCache?: false\n\n /**\n * Set to pass an `npm-otp` header on the request.\n *\n * This should not be set except by the RegistryClient itself, when\n * we receive a 401 response with an OTP challenge.\n * @internal\n */\n otp?: string\n\n /**\n * Set to false to explicitly prevent `stale-while-revalidate` behavior,\n * for use in revalidating while stale.\n * @internal\n */\n staleWhileRevalidate?: false\n}\n\nconst { version } = loadPackageJson(\n import.meta.filename,\n process.env.__VLT_INTERNAL_REGISTRY_CLIENT_PACKAGE_JSON,\n) as {\n version: string\n}\n\nconst nua =\n (globalThis.navigator as Navigator | undefined)?.userAgent ??\n (bun ? `Bun/${bun}`\n : deno ? `Deno/${deno}`\n : node ? `Node.js/${node}`\n : '(unknown platform)')\n\nexport const userAgent = `@vltpkg/registry-client/${version} ${nua}`\n\nconst agentOptions: Agent.Options = {\n bodyTimeout: 600_000,\n headersTimeout: 600_000,\n keepAliveMaxTimeout: 1_200_000,\n keepAliveTimeout: 600_000,\n keepAliveTimeoutThreshold: 30_000,\n connect: {\n timeout: 600_000,\n keepAlive: true,\n keepAliveInitialDelay: 30_000,\n sessionTimeout: 600,\n },\n connections: 128,\n pipelining: 10,\n}\n\nconst xdg = new XDG('vlt')\n\nexport class RegistryClient {\n agent: RetryAgent\n cache: Cache\n identity: string\n staleWhileRevalidateFactor: number\n\n constructor(options: RegistryClientOptions) {\n const {\n cache = xdg.cache(),\n 'fetch-retry-factor': timeoutFactor = 2,\n 'fetch-retry-mintimeout': minTimeout = 0,\n 'fetch-retry-maxtimeout': maxTimeout = 30_000,\n 'fetch-retries': maxRetries = 3,\n identity = '',\n 'stale-while-revalidate-factor':\n staleWhileRevalidateFactor = 576, // 48h for a 5min cache\n } = options\n this.identity = identity\n this.staleWhileRevalidateFactor = staleWhileRevalidateFactor\n const path = resolve(cache, 'registry-client')\n this.cache = new Cache({\n path,\n onDiskWrite(_path, key, data) {\n if (CacheEntry.isGzipEntry(data)) {\n cacheUnzipRegister(path, key)\n }\n },\n })\n const dispatch = new Agent(agentOptions)\n this.agent = new RetryAgent(dispatch, {\n maxRetries,\n timeoutFactor,\n minTimeout,\n maxTimeout,\n retryAfter: true,\n errorCodes: [\n 'ECONNREFUSED',\n 'ECONNRESET',\n 'EHOSTDOWN',\n 'ENETDOWN',\n 'ENETUNREACH',\n 'ENOTFOUND',\n 'EPIPE',\n 'UND_ERR_SOCKET',\n ],\n })\n }\n\n /**\n * Fetch the entire set of a paginated list of objects\n */\n async scroll<T>(\n url: URL | string,\n options: RegistryClientRequestOptions = {},\n seek?: (obj: T) => boolean,\n ): Promise<T[]> {\n const resp = await this.request(url, options)\n const { objects, urls } = resp.json() as {\n objects: T[]\n urls: { next?: string }\n }\n // if we have more, and haven't found our target, fetch more\n return urls.next && !(seek && objects.some(seek)) ?\n objects.concat(await this.scroll<T>(urls.next, options, seek))\n : objects\n }\n\n /**\n * find a given item in a paginated set\n */\n async seek<T>(\n url: URL | string,\n seek: (obj: T) => boolean,\n options: RegistryClientRequestOptions = {},\n ): Promise<T | undefined> {\n return (await this.scroll(url, options, seek)).find(seek)\n }\n\n /**\n * Log out from the registry specified, attempting to destroy the\n * token if the registry supports that endpoint.\n */\n async logout(registry: string) {\n // if we have no token for that registry, nothing to do\n const tok = await getToken(registry, this.identity)\n if (!tok) return\n\n const s = tok.replace(/^(Bearer|Basic) /i, '')\n\n const tokensUrl = new URL('-/npm/v1/tokens', registry)\n const record = await this.seek<{\n key: string\n token: string\n }>(tokensUrl, ({ token }) => s.startsWith(token), {\n useCache: false,\n }).catch(() => undefined)\n\n if (record) {\n const { key } = record\n await this.request(\n new URL(`-/npm/v1/tokens/token/${key}`, registry),\n { useCache: false, method: 'DELETE' },\n )\n }\n\n await deleteToken(registry, this.identity)\n }\n\n /**\n * Log into the registry specified\n *\n * Does not return the token or expose it, just saves to the auth keychain\n * and returns void if it worked. Otherwise, error is raised.\n */\n async login(registry: string) {\n // - make POST to '/-/v1/login'\n // - include a body of {} and npm-auth-type:web\n // - get a {doneUrl, authUrl}\n // - open the authUrl\n // - hang on the doneUrl until done\n //\n // if that fails: fall back to couchdb login\n const webLoginURL = new URL('-/v1/login', registry)\n const response = await this.request(webLoginURL, {\n method: 'POST',\n useCache: false,\n headers: {\n 'content-type': 'application/json',\n 'npm-auth-type': 'web',\n },\n body: '{}',\n })\n\n if (response.statusCode === 200) {\n const challenge = getWebAuthChallenge(response.json())\n if (challenge) {\n const result = await this.webAuthOpener(challenge)\n await setToken(\n registry,\n `Bearer ${result.token}`,\n this.identity,\n )\n return\n }\n }\n /* c8 ignore start */\n // TODO: fall back to username/password login, and/or couchdb PUT login\n throw error('Failed to perform web login', { response })\n }\n /* c8 ignore stop */\n\n /**\n * Given a {@link WebAuthChallenge}, open the `authUrl` in a browser and\n * hang on the `doneUrl` until it returns a {@link TokenResponse} object.\n */\n async webAuthOpener({ doneUrl, authUrl }: WebAuthChallenge) {\n const ac = new AbortController()\n const { signal } = ac\n /* c8 ignore start - race condition */\n const [result] = await Promise.all([\n this.#checkLogin(doneUrl, { signal }).then(result => {\n ac.abort()\n return result\n }),\n urlOpen(authUrl, { signal }).catch((er: unknown) => {\n if (asError(er).name === 'AbortError') return\n ac.abort()\n throw er\n }),\n ])\n /* c8 ignore stop */\n return result\n }\n\n async #checkLogin(\n url: URL | string,\n options: RegistryClientRequestOptions = {},\n ): Promise<TokenResponse> {\n const response = await this.request(url, {\n ...options,\n useCache: false,\n })\n const { signal } = options as { signal?: AbortSignal }\n if (response.statusCode === 202) {\n const rt = response.getHeaderString('retry-after')\n const retryAfter = rt ? Number(rt) : -1\n if (retryAfter > 0) {\n await setTimeout(retryAfter * 1000, null, { signal })\n }\n return await this.#checkLogin(url, options)\n }\n if (response.statusCode === 200) {\n const token = getTokenResponse(response.json())\n if (token) return token\n }\n throw error('Invalid response from web login endpoint', {\n response,\n })\n }\n\n async request(\n url: URL | string,\n options: RegistryClientRequestOptions = {},\n ): Promise<CacheEntry> {\n const u = typeof url === 'string' ? new URL(url) : url\n const {\n method = 'GET',\n integrity,\n redirections = new Set(),\n signal,\n otp = (process.env.VLT_OTP ?? '').trim(),\n staleWhileRevalidate = true,\n } = options\n let { trustIntegrity } = options\n\n const m = isCacheableMethod(method) ? method : undefined\n const { useCache = !!m } = options\n\n ;(signal as AbortSignal | null)?.throwIfAborted()\n\n // first, try to get from the cache before making any request.\n const { origin } = u\n const key = `${method !== 'GET' ? method + ' ' : ''}${u}`\n const buffer =\n useCache ?\n await this.cache.fetch(key, { context: { integrity } })\n : undefined\n\n const entry = buffer ? CacheEntry.decode(buffer) : undefined\n if (entry?.valid) {\n logRequest(url, 'cache')\n return entry\n }\n\n if (staleWhileRevalidate && entry?.staleWhileRevalidate && m) {\n // revalidate while returning the stale entry\n register(dirname(this.cache.path()), m, url)\n logRequest(url, 'stale')\n return entry\n }\n\n logRequest(url, 'start')\n\n // either no cache entry, or need to revalidate before use.\n setCacheHeaders(options, entry)\n\n redirections.add(String(url))\n\n Object.assign(options, {\n path: u.pathname.replace(/\\/+$/, '') + u.search,\n ...agentOptions,\n })\n\n options.origin = u.origin\n options.headers = addHeader(\n addHeader(\n options.headers,\n 'accept-encoding',\n 'gzip;q=1.0, identity;q=0.5',\n ),\n 'user-agent',\n userAgent,\n )\n if (otp) {\n options.headers = addHeader(options.headers, 'npm-otp', otp)\n }\n if (integrity) {\n options.headers = addHeader(\n options.headers,\n 'accept-integrity',\n integrity,\n )\n }\n options.method = options.method ?? 'GET'\n\n // will remove if we don't have a token.\n options.headers = addHeader(\n options.headers,\n 'authorization',\n await getToken(origin, this.identity),\n )\n\n let response: Dispatcher.ResponseData | null = null\n try {\n response = await this.agent.request(\n options as Dispatcher.RequestOptions,\n )\n /* c8 ignore start */\n } catch (er) {\n // Rethrow so we get a better stack trace\n throw error('Request failed', {\n code: 'EREQUEST',\n cause: er,\n url,\n method,\n })\n }\n /* c8 ignore stop */\n\n const result = await this.#handleResponse(\n u,\n options,\n response,\n entry,\n )\n\n if (result.getHeader('integrity')) {\n trustIntegrity = true\n }\n\n if (result.isGzip && !trustIntegrity) {\n result.checkIntegrity({ url })\n }\n if (useCache) {\n // Get the encoded buffer from the cache entry\n const buffer = result.encode()\n this.cache.set(\n key,\n Buffer.from(\n buffer.buffer,\n buffer.byteOffset,\n buffer.byteLength,\n ),\n {\n integrity: result.integrity,\n },\n )\n }\n return result\n }\n\n async #handleResponse(\n url: URL,\n options: RegistryClientRequestOptions,\n response: Dispatcher.ResponseData,\n entry?: CacheEntry,\n ): Promise<CacheEntry> {\n if (handle304Response(response, entry)) return entry\n\n if (response.statusCode === 401) {\n const repeatRequest = await otplease(this, options, response)\n if (repeatRequest) return await this.request(url, repeatRequest)\n }\n\n const h: Uint8Array[] = []\n for (const [key, value] of Object.entries(response.headers)) {\n /* c8 ignore start - theoretical */\n if (Array.isArray(value)) {\n h.push(\n getEncondedValue(key),\n getEncondedValue(value.join(', ')),\n )\n /* c8 ignore stop */\n } else if (typeof value === 'string') {\n h.push(getEncondedValue(key), getEncondedValue(value))\n }\n }\n\n const { integrity, trustIntegrity } = options\n const result = new CacheEntry(\n /* c8 ignore next - should always have a status code */\n response.statusCode || 200,\n h,\n {\n integrity,\n trustIntegrity,\n 'stale-while-revalidate-factor':\n this.staleWhileRevalidateFactor,\n contentLength:\n response.headers['content-length'] ?\n Number(response.headers['content-length'])\n : /* c8 ignore next */ undefined,\n },\n )\n\n if (isRedirect(result)) {\n response.body.resume()\n const [nextURL, nextOptions] = redirect(options, result, url)\n if (nextOptions && nextURL) {\n return await this.request(nextURL, nextOptions)\n }\n return result\n }\n\n response.body.on('data', (chunk: Uint8Array) =>\n result.addBody(chunk),\n )\n return await new Promise<CacheEntry>((res, rej) => {\n response.body.on('error', rej)\n response.body.on('end', () => res(result))\n })\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-cacheable.d.ts","sourceRoot":"","sources":["../../src/is-cacheable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW,eAAgB,MAAM,YAMrC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-cacheable.js","sourceRoot":"","sources":["../../src/is-cacheable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,UAAkB,EAAE,EAAE,CAChD,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK;IACxB,CAAC,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI;QACzB,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI;YAC3B,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI;gBAC3B,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI;oBAC3B,CAAC,CAAC,KAAK,CAAA","sourcesContent":["/**\n * Determine whether we're allowed to cache it, based on status code\n */\nexport const isCacheable = (statusCode: number) =>\n statusCode < 200 ? false\n : statusCode < 300 ? true\n : statusCode === 301 ? true\n : statusCode === 308 ? true\n : statusCode === 410 ? true\n : false\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-iterable.d.ts","sourceRoot":"","sources":["../../src/is-iterable.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,CAAC,KAAK,OAAO,KAAG,CAAC,IAAI,QAAQ,CAAC,CAAC,CACJ,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-iterable.js","sourceRoot":"","sources":["../../src/is-iterable.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAI,CAAU,EAAoB,EAAE,CAC5D,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAA","sourcesContent":["export const isIterable = <T>(o: unknown): o is Iterable<T> =>\n !!o && typeof o === 'object' && Symbol.iterator in o\n"]}
@@ -1 +0,0 @@
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;AAqBnB,eAAO,MAAM,QAAQ,WACX,cAAc,WACb,4BAA4B,YAC3B,UAAU,CAAC,YAAY,KAChC,OAAO,CAAC,4BAA4B,GAAG,SAAS,CAuDlD,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"otplease.js","sourceRoot":"","sources":["../../src/otplease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,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gBACL,GAAG,OAAO;gBACV,GAAG,EAAE,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK;aACnD,CAAA;QACH,CAAC;QAED,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAA;QACpD,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;YAChC,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC7C,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACf,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;gBACvB,GAAG,CAAC,MAAM,CAAC,CAAA;gBACX,OAAO;oBACL,GAAG,OAAO;oBACV,GAAG,EAAE,MAAM,QAAQ,CAAC,OAAO,CAAC;iBAC7B,CAAA;YACH,CAAC;QACH,CAAC;QAED,MAAM,KAAK,CAAC,2CAA2C,EAAE;YACvD,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,KAAK,CAAC,kCAAkC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC/D,CAAC;IAED,uCAAuC;IACvC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;IACvD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QACjD,OAAO;YACL,GAAG,OAAO;YACV,GAAG,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC;SAC1B,CAAA;IACH,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 { getWebAuthChallenge } from './web-auth-challenge.ts'\nimport { urlOpen } from '@vltpkg/url-open'\nimport { createInterface } from 'node:readline/promises'\n\n// eslint-disable-next-line no-console\nconst log = (msg: string) => console.error(msg)\n\nconst question = async (text: string): Promise<string> => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n })\n const answer = await rl.question(text)\n rl.close()\n return answer\n}\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 = getWebAuthChallenge(\n await response.body.json().catch(() => null),\n )\n if (challenge) {\n return {\n ...options,\n otp: (await client.webAuthOpener(challenge)).token,\n }\n }\n\n const { 'npm-notice': npmNotice } = response.headers\n if (npmNotice) {\n const notice = String(npmNotice)\n const match = otpChallengeNotice.exec(notice)\n if (match?.[1]) {\n await urlOpen(match[1])\n log(notice)\n return {\n ...options,\n otp: await question('OTP: '),\n }\n }\n }\n\n throw error('Unrecognized OTP authentication challenge', {\n response,\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().catch(() => '')\n if (text.toLowerCase().includes('one-time pass')) {\n return {\n ...options,\n otp: await question(text),\n }\n }\n}\n"]}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"raw-header.d.ts","sourceRoot":"","sources":["../../src/raw-header.ts"],"names":[],"mappings":"A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CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;QACvB,IACE,IAAI;YACJ,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;YACxB,eAAe,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,EACzC,CAAC;YACD,OAAO;gBACL,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;gBAC1B,MAAM;gBACN,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;aACxB,CAAA;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAClD,CAAC,CAAA","sourcesContent":["import {\n getDecodedValue,\n getEncondedValue,\n} from './string-encoding.ts'\n\n/**\n * Give it a key, and it'll return the value of that header as a Uint8Array\n */\nexport const getRawHeader = (\n headers: Uint8Array[],\n key: string,\n): Uint8Array | undefined => {\n const k = key.toLowerCase()\n for (let i = 0; i < headers.length; i += 2) {\n const name = headers[i]\n if (\n name &&\n name.length === key.length &&\n getDecodedValue(name).toLowerCase() === k\n ) {\n return headers[i + 1]\n }\n }\n}\n\n/**\n * Give it a key and value, and it'll overwrite or add the header entry\n */\nexport const setRawHeader = (\n headers: Uint8Array[],\n key: string,\n value: Uint8Array | string,\n): Uint8Array[] => {\n const k = key.toLowerCase()\n const encVal =\n typeof value === 'string' ? getEncondedValue(value) : value\n for (let i = 0; i < headers.length; i += 2) {\n const name = headers[i]\n if (\n name &&\n name.length === k.length &&\n getDecodedValue(name).toLowerCase() === k\n ) {\n return [\n ...headers.slice(0, i + 1),\n encVal,\n ...headers.slice(i + 2),\n ]\n }\n }\n return [...headers, getEncondedValue(k), encVal]\n}\n"]}
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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,I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,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.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"]}
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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,EAAE,CAAC;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IACD,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;YACv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,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"]}
@@ -1 +0,0 @@
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 +0,0 @@
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"]}
@@ -1 +0,0 @@
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 +0,0 @@
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"]}
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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"]}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes