Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TooTallNate/proxy-agents
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: https-proxy-agent@7.0.2
Choose a base ref
...
head repository: TooTallNate/proxy-agents
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: https-proxy-agent@7.0.3
Choose a head ref
  • 14 commits
  • 52 files changed
  • 9 contributors

Commits on Sep 8, 2023

  1. 1
    Copy the full SHA
    523b74c View commit details
  2. 1
    Copy the full SHA
    43a9689 View commit details

Commits on Sep 22, 2023

  1. Moved licenses to separate files (#251)

    tschlechtweg authored Sep 22, 2023
    1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5923589 View commit details

Commits on Sep 30, 2023

  1. Prettier

    TooTallNate committed Sep 30, 2023
    1
    Copy the full SHA
    aaebfa4 View commit details
  2. [data-uri-to-buffer] Refactor to return an ArrayBuffer instead of a…

    … Node.js `Buffer` (#252)
    
    Breaking change refactor to return an `ArrayBuffer` instead of a Node.js `Buffer`.
    
    This change is being made to make the package platform-agnostic, and work in web browsers or other non-Node.js environments without polyfills.
    
    For Node.js users of this package, you can get a Node.js `Buffer` instance from an `ArrayBuffer` like so:
    
    ```typescript
    const uri = 'data:,Hello%2C%20World!';
    const parsed = dataUriToBuffer(uri);
    const buffer = Buffer.from(parsed.buffer);
    // `buffer` is a Node.js Buffer
    ```
    TooTallNate authored Sep 30, 2023
    1
    Copy the full SHA
    52b458f View commit details
  3. 1
    Copy the full SHA
    b149ecc View commit details
  4. 1
    Copy the full SHA
    1d146e8 View commit details
  5. 1
    Copy the full SHA
    b133295 View commit details

Commits on Jan 8, 2024

  1. 1
    Copy the full SHA
    c3c405e View commit details
  2. Use native decoding of base64 in Node.js (#269)

    * Make decoding of base64 data URIs faster
    
    I saw in microsoft/vscode-js-debug#1911 that
    base64 decoding of a data URI was taking a bit of time.
    
    This PR feature-detects the presence of a global `Buffer` to use native
    decoding when running in Node.js, which is about 25x faster on a 10MB
    data URI than the JS implementation in the library.
    
    I have a bit of a hack in order to test both paths when running tests,
    happy to change it if desired :)
    
    * use conditional exports
    
    * fix test import
    
    * fix node test import, and set stringToBuffer encoding
    
    * Create few-adults-rhyme.md
    
    ---------
    
    Co-authored-by: Nathan Rajlich <n@n8.io>
    connor4312 and TooTallNate authored Jan 8, 2024
    1
    Copy the full SHA
    c881a18 View commit details

Commits on Feb 12, 2024

  1. [get-uri] Update fs-extra to v11 (#279)

    mehulkar authored Feb 12, 2024
    1
    Copy the full SHA
    c854e4c View commit details
  2. [proxy-agent] Allow asynchronous getProxyForUrl (#275)

    This allows users to use an asynchronous getProxyForUrl in case they need
    to do asynchronous operations to resolve the correct proxy URL.  This can
    be the case, for example, if using Electron.Session.resolveProxy(url).
    mook-as authored Feb 12, 2024
    1
    Copy the full SHA
    e7e0e56 View commit details
  3. [pac-resolver] Remove ip dependency (#281)

    viktor-urbanas-qatalog authored Feb 12, 2024
    1
    Copy the full SHA
    a954da3 View commit details
  4. Version Packages (#271)

    github-actions[bot] authored Feb 12, 2024
    1
    Copy the full SHA
    d4d3cd0 View commit details
Showing with 717 additions and 485 deletions.
  1. +16 −0 .eslintrc.js
  2. +22 −0 packages/agent-base/LICENSE
  3. +0 −26 packages/agent-base/README.md
  4. +29 −0 packages/data-uri-to-buffer/CHANGELOG.md
  5. +22 −0 packages/data-uri-to-buffer/LICENSE
  6. +25 −40 packages/data-uri-to-buffer/README.md
  7. +6 −2 packages/data-uri-to-buffer/package.json
  8. +69 −0 packages/data-uri-to-buffer/src/common.ts
  9. +48 −58 packages/data-uri-to-buffer/src/index.ts
  10. +28 −0 packages/data-uri-to-buffer/src/node.ts
  11. +77 −68 packages/data-uri-to-buffer/test/data-uri-to-buffer.test.ts
  12. +1 −0 packages/data-uri-to-buffer/tsconfig.json
  13. +22 −0 packages/degenerator/LICENSE
  14. +1 −28 packages/degenerator/README.md
  15. +4 −1 packages/degenerator/test/test.ts
  16. +15 −0 packages/get-uri/CHANGELOG.md
  17. +22 −0 packages/get-uri/LICENSE
  18. +0 −26 packages/get-uri/README.md
  19. +3 −3 packages/get-uri/package.json
  20. +3 −3 packages/get-uri/src/data.ts
  21. +6 −0 packages/http-proxy-agent/CHANGELOG.md
  22. +1 −4 packages/http-proxy-agent/LICENSE
  23. +1 −27 packages/http-proxy-agent/README.md
  24. +1 −1 packages/http-proxy-agent/package.json
  25. +2 −1 packages/http-proxy-agent/src/index.ts
  26. +6 −0 packages/https-proxy-agent/CHANGELOG.md
  27. +22 −0 packages/https-proxy-agent/LICENSE
  28. +0 −27 packages/https-proxy-agent/README.md
  29. +1 −1 packages/https-proxy-agent/package.json
  30. +6 −3 packages/https-proxy-agent/src/index.ts
  31. +22 −0 packages/pac-proxy-agent/LICENSE
  32. +0 −26 packages/pac-proxy-agent/README.md
  33. +1 −0 packages/pac-proxy-agent/test/test.ts
  34. +6 −0 packages/pac-resolver/CHANGELOG.md
  35. +22 −0 packages/pac-resolver/LICENSE
  36. +0 −27 packages/pac-resolver/README.md
  37. +1 −3 packages/pac-resolver/package.json
  38. +57 −0 packages/pac-resolver/src/ip.ts
  39. +1 −1 packages/pac-resolver/src/myIpAddress.ts
  40. +4 −1 packages/pac-resolver/test/test.ts
  41. +12 −0 packages/proxy-agent/CHANGELOG.md
  42. +22 −0 packages/proxy-agent/LICENSE
  43. +0 −28 packages/proxy-agent/README.md
  44. +3 −3 packages/proxy-agent/package.json
  45. +2 −2 packages/proxy-agent/src/index.ts
  46. +29 −0 packages/proxy-agent/test/test.ts
  47. +22 −0 packages/proxy/LICENSE
  48. +0 −27 packages/proxy/README.md
  49. +22 −0 packages/socks-proxy-agent/LICENSE
  50. +1 −27 packages/socks-proxy-agent/README.md
  51. +1 −0 packages/socks-proxy-agent/test/test.ts
  52. +30 −21 pnpm-lock.yaml
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -13,4 +13,20 @@ module.exports = {
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
overrides: [
{
files: ['packages/{pac-proxy,proxy,socks-proxy}-agent/**/*'],
rules: {
'no-restricted-globals': [
'error',
// https://github.com/TooTallNate/proxy-agents/pull/242
{
name: 'URL',
message:
'Use `URL` from the Node.js "url" module instead.',
},
],
},
},
],
};
22 changes: 22 additions & 0 deletions packages/agent-base/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 changes: 0 additions & 26 deletions packages/agent-base/README.md
Original file line number Diff line number Diff line change
@@ -62,32 +62,6 @@ http.get('http://nodejs.org/api/', { agent }, (res) => {
});
```

License
-------

(The MIT License)

Copyright (c) 2013 Nathan Rajlich &lt;nathan@tootallnate.net&gt;

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

[http-proxy-agent]: ../http-proxy-agent
[https-proxy-agent]: ../https-proxy-agent
[pac-proxy-agent]: ../pac-proxy-agent
29 changes: 29 additions & 0 deletions packages/data-uri-to-buffer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# data-uri-to-buffer

## 6.0.2

### Patch Changes

- c881a18: Use native Buffer decoding in Node.js

## 6.0.1

### Patch Changes

- 1d146e8: Ensure `<reference types="node" />` is not present in generated types

## 6.0.0

### Major Changes

- 52b458f: Refactor to return an `ArrayBuffer` instead of a Node.js `Buffer`.

This change is being made to make the package platform-agnostic, and work in web browsers or other non-Node.js environments without polyfills.

For Node.js users of this package, you can get a Node.js `Buffer` instance from an `ArrayBuffer` like so:

```typescript
const uri = 'data:,Hello%2C%20World!';
const parsed = dataUriToBuffer(uri);
const buffer = Buffer.from(parsed.buffer);
// `buffer` is a Node.js Buffer
```

## 5.0.1

### Patch Changes
22 changes: 22 additions & 0 deletions packages/data-uri-to-buffer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65 changes: 25 additions & 40 deletions packages/data-uri-to-buffer/README.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,61 @@
data-uri-to-buffer
==================
### Generate a Buffer instance from a [Data URI][rfc] string
### Create an ArrayBuffer instance from a [Data URI][rfc] string

This module accepts a ["data" URI][rfc] String of data, and returns a
node.js `Buffer` instance with the decoded data.
This module accepts a ["data" URI][rfc] String of data, and returns
an `ArrayBuffer` instance with the decoded data.

This module is intended to work on a large variety of JavaScript
runtimes, including Node.js and web browsers.

Example
-------

``` js
```typescript
import { dataUriToBuffer } from 'data-uri-to-buffer';

// plain-text data is supported
let uri = 'data:,Hello%2C%20World!';
let decoded = dataUriToBuffer(uri);
console.log(decoded.toString());
let parsed = dataUriToBuffer(uri);
console.log(new TextDecoder().decode(parsed.buffer));
// 'Hello, World!'

// base64-encoded data is supported
uri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D';
decoded = dataUriToBuffer(uri);
console.log(decoded.toString());
parsed = dataUriToBuffer(uri);
console.log(new TextDecoder().decode(parsed.buffer));
// 'Hello, World!'
```


API
---

### dataUriToBuffer(String uri) → Buffer
```typescript
export interface ParsedDataURI {
type: string;
typeFull: string;
charset: string;
buffer: ArrayBuffer;
}
```

### dataUriToBuffer(uri: string | URL) → ParsedDataURI

The `type` property on the Buffer instance gets set to the main type portion of
The `type` property gets set to the main type portion of
the "mediatype" portion of the "data" URI, or defaults to `"text/plain"` if not
specified.

The `typeFull` property on the Buffer instance gets set to the entire
The `typeFull` property gets set to the entire
"mediatype" portion of the "data" URI (including all parameters), or defaults
to `"text/plain;charset=US-ASCII"` if not specified.

The `charset` property on the Buffer instance gets set to the Charset portion of
The `charset` property gets set to the Charset portion of
the "mediatype" portion of the "data" URI, or defaults to `"US-ASCII"` if the
entire type is not specified, or defaults to `""` otherwise.

*Note*: If the only the main type is specified but not the charset, e.g.
*Note*: If only the main type is specified but not the charset, e.g.
`"data:text/plain,abc"`, the charset is set to the empty string. The spec only
defaults to US-ASCII as charset if the entire type is not specified.


License
-------

(The MIT License)

Copyright (c) 2014 Nathan Rajlich &lt;nathan@tootallnate.net&gt;

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

[rfc]: http://tools.ietf.org/html/rfc2397
8 changes: 6 additions & 2 deletions packages/data-uri-to-buffer/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "data-uri-to-buffer",
"version": "5.0.1",
"description": "Generate a Buffer instance from a Data URI string",
"version": "6.0.2",
"description": "Create an ArrayBuffer instance from a Data URI string",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"node": "./dist/node.js",
"default": "./dist/index.js"
},
"files": [
"dist"
],
69 changes: 69 additions & 0 deletions packages/data-uri-to-buffer/src/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
export interface ParsedDataURI {
type: string;
typeFull: string;
charset: string;
buffer: ArrayBuffer;
}

export interface IBufferConversions {
base64ToArrayBuffer(base64: string): ArrayBuffer;
stringToBuffer(str: string): ArrayBuffer;
}

/**
* Returns a `Buffer` instance from the given data URI `uri`.
*
* @param {String} uri Data URI to turn into a Buffer instance
*/
export const makeDataUriToBuffer = (convert: IBufferConversions) => (uri: string | URL): ParsedDataURI => {
uri = String(uri);

if (!/^data:/i.test(uri)) {
throw new TypeError(
'`uri` does not appear to be a Data URI (must begin with "data:")'
);
}

// strip newlines
uri = uri.replace(/\r?\n/g, '');

// split the URI up into the "metadata" and the "data" portions
const firstComma = uri.indexOf(',');
if (firstComma === -1 || firstComma <= 4) {
throw new TypeError('malformed data: URI');
}

// remove the "data:" scheme and parse the metadata
const meta = uri.substring(5, firstComma).split(';');

let charset = '';
let base64 = false;
const type = meta[0] || 'text/plain';
let typeFull = type;
for (let i = 1; i < meta.length; i++) {
if (meta[i] === 'base64') {
base64 = true;
} else if (meta[i]) {
typeFull += `;${meta[i]}`;
if (meta[i].indexOf('charset=') === 0) {
charset = meta[i].substring(8);
}
}
}
// defaults to US-ASCII only if type is not provided
if (!meta[0] && !charset.length) {
typeFull += ';charset=US-ASCII';
charset = 'US-ASCII';
}

// get the encoded data portion and decode URI-encoded chars
const data = unescape(uri.substring(firstComma + 1));
const buffer = base64 ? convert.base64ToArrayBuffer(data) : convert.stringToBuffer(data);

return {
type,
typeFull,
charset,
buffer,
};
}
Loading