{"name":"pac-resolver","version":"9.0.0","keywords":["pac","file","proxy","resolve","dns"],"author":{"url":"http://n8.io/","name":"Nathan Rajlich","email":"nathan@tootallnate.net"},"license":"MIT","_id":"pac-resolver@9.0.0","maintainers":[{"name":"tootallnate","email":"nathan@tootallnate.net"}],"homepage":"https://github.com/TooTallNate/proxy-agents#readme","bugs":{"url":"https://github.com/TooTallNate/proxy-agents/issues"},"dist":{"shasum":"b24daf47b6f414a7c3d1ad0c1a76a95276dcc956","tarball":"http://registry-npm.ywwl.com/pac-resolver/download/pac-resolver-9.0.0.tgz","fileCount":63,"integrity":"sha512-7vnhwZvvnXgqOFy7sXt6yJh2KASD5xqW9SYt4yGsbTNNUDoF5ryL84itpoERN7a2dF6AXJsIiXwcZchazLS/vw==","signatures":[{"sig":"MEQCIB25aGu3EF6NwZwUyBypklh9aPa3JSybllbo0hFxvi67AiAQIyBcEvN5AW9wU2AK9BS0xFSXZTtQr+I8lITGP972Sg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/pac-resolver@9.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":56277,"size":16676,"noattachment":false,"key":"/pac-resolver/-/pac-resolver-9.0.0.tgz"},"type":"module","_from":"file:pac-resolver-9.0.0.tgz","engines":{"node":">= 20"},"exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"scripts":{"lint":"eslint . --ext .ts","pack":"node ../../scripts/pack.mjs","test":"vitest","build":"tsc"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:106b6536-4d79-4c36-a281-d768b2f5bdb5"}},"_resolved":"/tmp/6dc75333973a9f7d1d00340808600db4/pac-resolver-9.0.0.tgz","_integrity":"sha512-7vnhwZvvnXgqOFy7sXt6yJh2KASD5xqW9SYt4yGsbTNNUDoF5ryL84itpoERN7a2dF6AXJsIiXwcZchazLS/vw==","repository":{"url":"git+https://github.com/TooTallNate/proxy-agents.git","type":"git","directory":"packages/pac-resolver"},"_npmVersion":"11.12.1","description":"Generates an asynchronous resolver function from a PAC file","directories":{},"_nodeVersion":"20.20.1","dependencies":{"netmask":"^2.0.2","degenerator":"7.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsconfig":"0.0.0","typescript":"^5.1.6","@types/node":"^22.13.0","quickjs-wasi":"^0.0.1","@types/netmask":"^1.0.30"},"peerDependencies":{"quickjs-wasi":"^0.0.1"},"_npmOperationalInternal":{"tmp":"tmp/pac-resolver_9.0.0_1775026675372_0.9405938479336169","host":"s3://npm-registry-packages-npm-production"},"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":1775026675507,"_cnpm_publish_time":1775026675507,"dist-tags":{"latest":"9.0.2"}}