@automattic/request-promise-native 1.1.0
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.
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/npmpublish.yml +23 -0
- package/.github/workflows/test.yml +30 -0
- package/LICENSE +15 -0
- package/README.md +82 -0
- package/errors.js +3 -0
- package/lib/rp.js +26 -0
- package/package.json +53 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# This workflow will publish this package to npm on each release created.
|
|
2
|
+
# NPM_TOKEN secret needs to be created via https://www.npmjs.com/settings/a8c/tokens/ (choose automation token) and stored in this repository.
|
|
3
|
+
#
|
|
4
|
+
# See https://docs.github.com/en/actions/guides/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
|
|
5
|
+
|
|
6
|
+
name: Publish to npm
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
release:
|
|
10
|
+
types: [created]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish-npm:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
node-version: "latest"
|
|
20
|
+
registry-url: https://registry.npmjs.org/
|
|
21
|
+
- run: npm publish --access public
|
|
22
|
+
env:
|
|
23
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Test with mocha
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "master" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "master" ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
# https://nodejs.org/en/about/previous-releases#release-schedule
|
|
16
|
+
# https://github.com/actions/setup-node?tab=readme-ov-file#supported-version-syntax
|
|
17
|
+
node-version: [18.x, 20.x, 22.x, 23.x]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
23
|
+
uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: ${{ matrix.node-version }}
|
|
26
|
+
|
|
27
|
+
- name: Build and test
|
|
28
|
+
run: |
|
|
29
|
+
npm ci
|
|
30
|
+
npm t
|
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Nicolai Kamenzky and contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Request-Promise-Native
|
|
2
|
+
======================
|
|
3
|
+
|
|
4
|
+
[](https://github.com/Automattic/request-promise-native/actions/workflows/test.yml)
|
|
5
|
+
|
|
6
|
+
# Deprecated!
|
|
7
|
+
|
|
8
|
+
As of Feb 11th 2020, [`request`](https://github.com/request/request) is fully deprecated. No new changes are expected to land. In fact, none have landed for some time. This package is also deprecated because it depends on `request`. We're only keeping the library's dependencies up to date.
|
|
9
|
+
|
|
10
|
+
Fyi, here is the [reasoning of `request`'s deprecation](https://github.com/request/request/issues/3142) and a [list of alternative libraries](https://github.com/request/request/issues/3143).
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
This package is similar to [`request-promise`](https://www.npmjs.com/package/request-promise) but uses native ES6+ promises.
|
|
15
|
+
|
|
16
|
+
Please refer to the [`request-promise` documentation](https://www.npmjs.com/package/request-promise). Everything applies to `request-promise-native` except the following:
|
|
17
|
+
- Instead of using Bluebird promises this library uses native ES6+ promises.
|
|
18
|
+
- Native ES6+ promises may have fewer features than Bluebird promises do. In particular, the `.finally(...)` method was not included until Node v10.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
This module is installed via npm:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
npm i --save "request-promise-native@npm:@automattic/request-promise-native@latest"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Migration from `request-promise` to `request-promise-native`
|
|
30
|
+
|
|
31
|
+
1. Go through the [migration instructions](https://github.com/request/request-promise#migration-from-v3-to-v4) to upgrade to `request-promise` v4.
|
|
32
|
+
2. Ensure that you don't use Bluebird-specific features on the promise returned by your request calls. In particular, you can't use `.finally(...)` anymore.
|
|
33
|
+
3. You are done.
|
|
34
|
+
|
|
35
|
+
## Contributing
|
|
36
|
+
|
|
37
|
+
To set up your development environment:
|
|
38
|
+
|
|
39
|
+
1. clone the repo to your desktop,
|
|
40
|
+
2. in the shell `cd` to the main folder,
|
|
41
|
+
3. hit `npm install`,
|
|
42
|
+
4. hit `npm install gulp -g` if you haven't installed gulp globally yet, and
|
|
43
|
+
5. run `gulp dev`. (Or run `node ./node_modules/.bin/gulp dev` if you don't want to install gulp globally.)
|
|
44
|
+
|
|
45
|
+
`gulp dev` watches all source files and if you save some changes it will lint the code and execute all tests. The test coverage report can be viewed from `./coverage/lcov-report/index.html`.
|
|
46
|
+
|
|
47
|
+
If you want to debug a test you should use `gulp test-without-coverage` to run all tests without obscuring the code by the test coverage instrumentation.
|
|
48
|
+
|
|
49
|
+
## Change History
|
|
50
|
+
|
|
51
|
+
- v1.0.9 (2020-07-21)
|
|
52
|
+
- Security fix: bumped `request-promise-core` which bumps `lodash` to `^4.17.19` following [this advisory](https://www.npmjs.com/advisories/1523).
|
|
53
|
+
- v1.0.8 (2019-11-03)
|
|
54
|
+
- Security fix: bumped `request-promise-core` which bumps `lodash` to `^4.17.15`. See [vulnerabilty reports](https://snyk.io/vuln/search?q=lodash&type=npm).
|
|
55
|
+
*(Thanks to @aw-davidson for reporting this in issue [#49](https://github.com/request/request-promise-native/issues/49).)*
|
|
56
|
+
- v1.0.7 (2019-02-14)
|
|
57
|
+
- Corrected mistakenly set `tough-cookie` version, now `^2.3.3`
|
|
58
|
+
*(Thanks to @evocateur for pointing this out.)*
|
|
59
|
+
- If you installed `request-promise-native@1.0.6` please make sure after the upgrade that `request` and `request-promise-native` use the same physical copy of `tough-cookie`.
|
|
60
|
+
- v1.0.6 (2019-02-14)
|
|
61
|
+
- Using stricter `tough-cookie@~2.3.3` to avoid installing `tough-cookie@3` which introduces breaking changes
|
|
62
|
+
*(Thanks to @jasonmit for pull request [#33](https://github.com/request/request-promise-native/pull/33/))*
|
|
63
|
+
- Security fix: bumped `lodash` to `^4.17.11`, see [vulnerabilty reports](https://snyk.io/vuln/search?q=lodash&type=npm)
|
|
64
|
+
- v1.0.5 (2017-09-22)
|
|
65
|
+
- Upgraded `tough-cookie` to a version without regex DoS vulnerability
|
|
66
|
+
*(Thanks to @sophieklm for [pull request #13](https://github.com/request/request-promise-native/pull/13))*
|
|
67
|
+
- v1.0.4 (2017-05-07)
|
|
68
|
+
- Fix that allows to use `tough-cookie` for [cookie creation](https://github.com/request/request-promise#include-a-cookie)
|
|
69
|
+
- v1.0.3 (2016-08-08)
|
|
70
|
+
- Renamed internally used package `@request/promise-core` to `request-promise-core` because there where [too](https://github.com/request/request-promise/issues/137) [many](https://github.com/request/request-promise/issues/141) issues with the scoped package name
|
|
71
|
+
- v1.0.2 (2016-07-18)
|
|
72
|
+
- Fix for using with module bundlers like Webpack and Browserify
|
|
73
|
+
- v1.0.1 (2016-07-17)
|
|
74
|
+
- Fixed `@request/promise-core` version for safer versioning
|
|
75
|
+
- v1.0.0 (2016-07-15)
|
|
76
|
+
- Initial version similar to [`request-promise`](https://www.npmjs.com/package/request-promise) v4
|
|
77
|
+
|
|
78
|
+
## License (ISC)
|
|
79
|
+
|
|
80
|
+
In case you never heard about the [ISC license](http://en.wikipedia.org/wiki/ISC_license) it is functionally equivalent to the MIT license.
|
|
81
|
+
|
|
82
|
+
See the [LICENSE file](LICENSE) for details.
|
package/errors.js
ADDED
package/lib/rp.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var configure = require('request-promise-core/configure/request2'),
|
|
4
|
+
stealthyRequire = require('stealthy-require');
|
|
5
|
+
|
|
6
|
+
// Load Request freshly - so that users can require an unaltered request instance!
|
|
7
|
+
var request = stealthyRequire(require.cache, function () {
|
|
8
|
+
return require('request');
|
|
9
|
+
},
|
|
10
|
+
function () {
|
|
11
|
+
require('tough-cookie');
|
|
12
|
+
}, module);
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
configure({
|
|
16
|
+
request: request,
|
|
17
|
+
PromiseImpl: Promise,
|
|
18
|
+
expose: [
|
|
19
|
+
'then',
|
|
20
|
+
'catch',
|
|
21
|
+
'promise'
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
module.exports = request;
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@automattic/request-promise-native",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "The simplified HTTP request client 'request' with Promise support. Powered by native ES6 promises.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"xhr",
|
|
7
|
+
"http",
|
|
8
|
+
"https",
|
|
9
|
+
"promise",
|
|
10
|
+
"request",
|
|
11
|
+
"then",
|
|
12
|
+
"thenable",
|
|
13
|
+
"native"
|
|
14
|
+
],
|
|
15
|
+
"main": "./lib/rp.js",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "mocha test/spec"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/request/request-promise-native.git"
|
|
22
|
+
},
|
|
23
|
+
"author": "Nicolai Kamenzky (https://github.com/analog-nico)",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/request/request-promise-native/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/request/request-promise-native#readme",
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18.x"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"request": "^2.88.2",
|
|
34
|
+
"request-promise-core": "1.1.4",
|
|
35
|
+
"stealthy-require": "^1.1.1",
|
|
36
|
+
"tough-cookie": "^5.1.0"
|
|
37
|
+
},
|
|
38
|
+
"overrides": {
|
|
39
|
+
"request": {
|
|
40
|
+
"tough-cookie": "^5.1.0",
|
|
41
|
+
"uuid": "^7.0.0"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"body-parser": "~1.20.3",
|
|
46
|
+
"chai": "^4.5.0",
|
|
47
|
+
"chalk": "~5.4.1",
|
|
48
|
+
"lodash": "~4.17.21",
|
|
49
|
+
"mocha": "^11.1.0",
|
|
50
|
+
"rimraf": "~6.0.1",
|
|
51
|
+
"run-sequence": "~2.2.1"
|
|
52
|
+
}
|
|
53
|
+
}
|