{"name":"pac-resolver","version":"9.0.1","type":"module","description":"Generates an asynchronous resolver function from a PAC file","exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"dependencies":{"netmask":"^2.0.2","degenerator":"7.0.1"},"devDependencies":{"@types/netmask":"^1.0.30","@types/node":"^22.13.0","quickjs-wasi":"^2.2.0","typescript":"^5.1.6","tsconfig":"0.0.0"},"peerDependencies":{"quickjs-wasi":"^2.2.0"},"repository":{"type":"git","url":"git+https://github.com/TooTallNate/proxy-agents.git","directory":"packages/pac-resolver"},"engines":{"node":">= 20"},"keywords":["pac","file","proxy","resolve","dns"],"author":{"name":"Nathan Rajlich","email":"nathan@tootallnate.net","url":"http://n8.io/"},"license":"MIT","scripts":{"build":"tsc","test":"vitest","lint":"eslint . --ext .ts","pack":"node ../../scripts/pack.mjs"},"_id":"pac-resolver@9.0.1","bugs":{"url":"https://github.com/TooTallNate/proxy-agents/issues"},"homepage":"https://github.com/TooTallNate/proxy-agents#readme","_integrity":"sha512-lJbS008tmkj08VhoM8Hzuv/VE5tK9MS0OIQ/7+s0lIF+BYhiQWFYzkSpML7lXs9iBu2jfmzBTLzhe9n6BX+dYw==","_resolved":"/tmp/b6d23bc1f4bcf9ccc7bbace1b1939ae2/pac-resolver-9.0.1.tgz","_from":"file:pac-resolver-9.0.1.tgz","_nodeVersion":"20.20.2","_npmVersion":"11.12.1","dist":{"integrity":"sha512-lJbS008tmkj08VhoM8Hzuv/VE5tK9MS0OIQ/7+s0lIF+BYhiQWFYzkSpML7lXs9iBu2jfmzBTLzhe9n6BX+dYw==","shasum":"a90b1518e4e832b3fcb197ada974d6f6ceaa7f8a","tarball":"http://registry-npm.ywwl.com/pac-resolver/download/pac-resolver-9.0.1.tgz","fileCount":63,"unpackedSize":56277,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/pac-resolver@9.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFAY/uMJQ8IGSFS6nuYqwCuNjB45R7ukmyP8MZsziMNwAiEAr32i2yKSA2A9MJAVwVJZy9Uxvqt5Z6+XlaA5pRHEI9I="}],"size":16677,"noattachment":false,"key":"/pac-resolver/-/pac-resolver-9.0.1.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:106b6536-4d79-4c36-a281-d768b2f5bdb5"}},"directories":{},"maintainers":[{"name":"tootallnate","email":"nathan@tootallnate.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pac-resolver_9.0.1_1775457667698_0.06444970547300288"},"_hasShrinkwrap":false,"readme":"pac-resolver\n============\n### Generates an asynchronous resolver function from a [PAC file][pac-wikipedia]\n\n\nThis module accepts a JavaScript String of code, which is meant to be a\n[PAC proxy file][pac-wikipedia], and returns a generated asynchronous\n`FindProxyForURL()` function.\n\nExample\n-------\n\nGiven the PAC proxy file named `proxy.pac`:\n\n```js\nfunction FindProxyForURL(url, host) {\n  if (isInNet(myIpAddress(), \"10.1.10.0\", \"255.255.255.0\")) {\n    return \"PROXY 1.2.3.4:8080\";\n  } else {\n    return \"DIRECT\";\n  }\n}\n```\n\nYou can consume this PAC file with `pac-resolver` like so:\n\n```ts\nimport { readFileSync } from 'fs';\nimport { createPacResolver } from 'pac-resolver';\n\nconst FindProxyForURL = createPacResolver(readFileSync('proxy.pac'));\n\nconst res = await FindProxyForURL('http://foo.com/');\nconsole.log(res);\n// \"DIRECT\"\n```\n\n\nAPI\n---\n\n### pac(qjs: QuickJSWASMModule, pacFileContents: string | Buffer, options?: PacResolverOptions) → Function\n\nReturns an asynchronous `FindProxyForURL()` function based off of the given JS\nstring `pacFileContents` PAC proxy file. An optional `options` object may be\npassed in which respects the following options:\n\n * `filename` - String - the filename to use in error stack traces. Defaults to `proxy.pac`.\n * `sandbox` - Object - a map of functions to include in the sandbox of the\n JavaScript environment where the JS code will be executed. i.e. if you wanted to\n include the common `alert` function you could pass `alert: console.log`. For\n async functions, you must set the `async = true` property on the function\n instance, and the JS code will be able to invoke the function as if it were\n synchronous.\n\n The `qjs` parameter is a QuickJS module instance as returned from `getQuickJS()` from the `quickjs-emscripten` module.\n\n[pac-file-docs]: https://web.archive.org/web/20070602031929/http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html\n[pac-wikipedia]: http://wikipedia.org/wiki/Proxy_auto-config\n","publish_time":1775457667822,"_cnpm_publish_time":1775457667822,"dist-tags":{"latest":"9.0.2"}}