Spaces:
Paused
Paused
Upload folder using huggingface_hub (part 17)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/side-channel-map/CHANGELOG.md +22 -0
- node_modules/side-channel-map/LICENSE +21 -0
- node_modules/side-channel-map/README.md +62 -0
- node_modules/side-channel-map/index.d.ts +15 -0
- node_modules/side-channel-map/index.js +68 -0
- node_modules/side-channel-map/package.json +80 -0
- node_modules/side-channel-map/test/index.js +114 -0
- node_modules/side-channel-map/tsconfig.json +9 -0
- node_modules/side-channel-weakmap/.editorconfig +9 -0
- node_modules/side-channel-weakmap/.eslintrc +12 -0
- node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
- node_modules/side-channel-weakmap/.nycrc +13 -0
- node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
- node_modules/side-channel-weakmap/LICENSE +21 -0
- node_modules/side-channel-weakmap/README.md +62 -0
- node_modules/side-channel-weakmap/index.d.ts +15 -0
- node_modules/side-channel-weakmap/index.js +84 -0
- node_modules/side-channel-weakmap/package.json +87 -0
- node_modules/side-channel-weakmap/test/index.js +114 -0
- node_modules/side-channel-weakmap/tsconfig.json +9 -0
- node_modules/siginfo/.travis.yml +13 -0
- node_modules/siginfo/LICENSE +13 -0
- node_modules/siginfo/README.md +47 -0
- node_modules/siginfo/index.js +20 -0
- node_modules/siginfo/package.json +32 -0
- node_modules/siginfo/test.js +16 -0
- node_modules/signal-exit/LICENSE.txt +16 -0
- node_modules/signal-exit/README.md +74 -0
- node_modules/signal-exit/package.json +106 -0
- node_modules/simple-concat/.travis.yml +3 -0
- node_modules/simple-concat/LICENSE +20 -0
- node_modules/simple-concat/README.md +44 -0
- node_modules/simple-concat/index.js +15 -0
- node_modules/simple-concat/package.json +47 -0
- node_modules/simple-concat/test/basic.js +41 -0
- node_modules/simple-get/.github/dependabot.yml +15 -0
- node_modules/simple-get/.github/workflows/ci.yml +23 -0
- node_modules/simple-get/LICENSE +20 -0
- node_modules/simple-get/README.md +333 -0
- node_modules/simple-get/index.js +108 -0
- node_modules/simple-get/package.json +67 -0
- node_modules/simple-update-notifier/LICENSE +21 -0
- node_modules/simple-update-notifier/README.md +82 -0
- node_modules/simple-update-notifier/build/index.d.ts +13 -0
- node_modules/simple-update-notifier/build/index.js +210 -0
- node_modules/simple-update-notifier/package.json +100 -0
- node_modules/simple-update-notifier/src/borderedText.ts +12 -0
- node_modules/simple-update-notifier/src/cache.spec.ts +17 -0
- node_modules/simple-update-notifier/src/cache.ts +44 -0
- node_modules/simple-update-notifier/src/getDistVersion.spec.ts +35 -0
node_modules/side-channel-map/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
|
| 3 |
+
All notable changes to this project will be documented in this file.
|
| 4 |
+
|
| 5 |
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
| 6 |
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
| 7 |
+
|
| 8 |
+
## [v1.0.1](https://github.com/ljharb/side-channel-map/compare/v1.0.0...v1.0.1) - 2024-12-10
|
| 9 |
+
|
| 10 |
+
### Commits
|
| 11 |
+
|
| 12 |
+
- [Deps] update `call-bound` [`6d05aaa`](https://github.com/ljharb/side-channel-map/commit/6d05aaa4ce5f2be4e7825df433d650696f0ba40f)
|
| 13 |
+
- [types] fix generics ordering [`11c0184`](https://github.com/ljharb/side-channel-map/commit/11c0184132ac11fdc16857e12682e148e5e9ee74)
|
| 14 |
+
|
| 15 |
+
## v1.0.0 - 2024-12-10
|
| 16 |
+
|
| 17 |
+
### Commits
|
| 18 |
+
|
| 19 |
+
- Initial implementation, tests, readme, types [`ad877b4`](https://github.com/ljharb/side-channel-map/commit/ad877b42926d46d63fff76a2bd01d2b4a01959a9)
|
| 20 |
+
- Initial commit [`28f8879`](https://github.com/ljharb/side-channel-map/commit/28f8879c512abe8fcf9b6a4dc7754a0287e5eba4)
|
| 21 |
+
- npm init [`2c9604e`](https://github.com/ljharb/side-channel-map/commit/2c9604e5aa40223e425ea7cea78f8a07697504bd)
|
| 22 |
+
- Only apps should have lockfiles [`5e7ba9c`](https://github.com/ljharb/side-channel-map/commit/5e7ba9cffe3ef42095815adc8ac1255b49bbadf5)
|
node_modules/side-channel-map/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2024 Jordan Harband
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
node_modules/side-channel-map/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# side-channel-map <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
| 2 |
+
|
| 3 |
+
[![github actions][actions-image]][actions-url]
|
| 4 |
+
[![coverage][codecov-image]][codecov-url]
|
| 5 |
+
[![License][license-image]][license-url]
|
| 6 |
+
[![Downloads][downloads-image]][downloads-url]
|
| 7 |
+
|
| 8 |
+
[![npm badge][npm-badge-png]][package-url]
|
| 9 |
+
|
| 10 |
+
Store information about any JS value in a side channel, using a Map.
|
| 11 |
+
|
| 12 |
+
Warning: if the `key` is an object, this implementation will leak memory until you `delete` it.
|
| 13 |
+
Use [`side-channel`](https://npmjs.com/side-channel) for the best available strategy.
|
| 14 |
+
|
| 15 |
+
## Getting started
|
| 16 |
+
|
| 17 |
+
```sh
|
| 18 |
+
npm install --save side-channel-map
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
## Usage/Examples
|
| 22 |
+
|
| 23 |
+
```js
|
| 24 |
+
const assert = require('assert');
|
| 25 |
+
const getSideChannelMap = require('side-channel-map');
|
| 26 |
+
|
| 27 |
+
const channel = getSideChannelMap();
|
| 28 |
+
|
| 29 |
+
const key = {};
|
| 30 |
+
assert.equal(channel.has(key), false);
|
| 31 |
+
assert.throws(() => channel.assert(key), TypeError);
|
| 32 |
+
|
| 33 |
+
channel.set(key, 42);
|
| 34 |
+
|
| 35 |
+
channel.assert(key); // does not throw
|
| 36 |
+
assert.equal(channel.has(key), true);
|
| 37 |
+
assert.equal(channel.get(key), 42);
|
| 38 |
+
|
| 39 |
+
channel.delete(key);
|
| 40 |
+
assert.equal(channel.has(key), false);
|
| 41 |
+
assert.throws(() => channel.assert(key), TypeError);
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
## Tests
|
| 45 |
+
|
| 46 |
+
Clone the repo, `npm install`, and run `npm test`
|
| 47 |
+
|
| 48 |
+
[package-url]: https://npmjs.org/package/side-channel-map
|
| 49 |
+
[npm-version-svg]: https://versionbadg.es/ljharb/side-channel-map.svg
|
| 50 |
+
[deps-svg]: https://david-dm.org/ljharb/side-channel-map.svg
|
| 51 |
+
[deps-url]: https://david-dm.org/ljharb/side-channel-map
|
| 52 |
+
[dev-deps-svg]: https://david-dm.org/ljharb/side-channel-map/dev-status.svg
|
| 53 |
+
[dev-deps-url]: https://david-dm.org/ljharb/side-channel-map#info=devDependencies
|
| 54 |
+
[npm-badge-png]: https://nodei.co/npm/side-channel-map.png?downloads=true&stars=true
|
| 55 |
+
[license-image]: https://img.shields.io/npm/l/side-channel-map.svg
|
| 56 |
+
[license-url]: LICENSE
|
| 57 |
+
[downloads-image]: https://img.shields.io/npm/dm/side-channel-map.svg
|
| 58 |
+
[downloads-url]: https://npm-stat.com/charts.html?package=side-channel-map
|
| 59 |
+
[codecov-image]: https://codecov.io/gh/ljharb/side-channel-map/branch/main/graphs/badge.svg
|
| 60 |
+
[codecov-url]: https://app.codecov.io/gh/ljharb/side-channel-map/
|
| 61 |
+
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/side-channel-map
|
| 62 |
+
[actions-url]: https://github.com/ljharb/side-channel-map/actions
|
node_modules/side-channel-map/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare namespace getSideChannelMap {
|
| 2 |
+
type Channel<K, V> = {
|
| 3 |
+
assert: (key: K) => void;
|
| 4 |
+
has: (key: K) => boolean;
|
| 5 |
+
get: (key: K) => V | undefined;
|
| 6 |
+
set: (key: K, value: V) => void;
|
| 7 |
+
delete: (key: K) => boolean;
|
| 8 |
+
};
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
declare function getSideChannelMap<K, V>(): getSideChannelMap.Channel<K, V>;
|
| 12 |
+
|
| 13 |
+
declare const x: false | typeof getSideChannelMap;
|
| 14 |
+
|
| 15 |
+
export = x;
|
node_modules/side-channel-map/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var GetIntrinsic = require('get-intrinsic');
|
| 4 |
+
var callBound = require('call-bound');
|
| 5 |
+
var inspect = require('object-inspect');
|
| 6 |
+
|
| 7 |
+
var $TypeError = require('es-errors/type');
|
| 8 |
+
var $Map = GetIntrinsic('%Map%', true);
|
| 9 |
+
|
| 10 |
+
/** @type {<K, V>(thisArg: Map<K, V>, key: K) => V} */
|
| 11 |
+
var $mapGet = callBound('Map.prototype.get', true);
|
| 12 |
+
/** @type {<K, V>(thisArg: Map<K, V>, key: K, value: V) => void} */
|
| 13 |
+
var $mapSet = callBound('Map.prototype.set', true);
|
| 14 |
+
/** @type {<K, V>(thisArg: Map<K, V>, key: K) => boolean} */
|
| 15 |
+
var $mapHas = callBound('Map.prototype.has', true);
|
| 16 |
+
/** @type {<K, V>(thisArg: Map<K, V>, key: K) => boolean} */
|
| 17 |
+
var $mapDelete = callBound('Map.prototype.delete', true);
|
| 18 |
+
/** @type {<K, V>(thisArg: Map<K, V>) => number} */
|
| 19 |
+
var $mapSize = callBound('Map.prototype.size', true);
|
| 20 |
+
|
| 21 |
+
/** @type {import('.')} */
|
| 22 |
+
module.exports = !!$Map && /** @type {Exclude<import('.'), false>} */ function getSideChannelMap() {
|
| 23 |
+
/** @typedef {ReturnType<typeof getSideChannelMap>} Channel */
|
| 24 |
+
/** @typedef {Parameters<Channel['get']>[0]} K */
|
| 25 |
+
/** @typedef {Parameters<Channel['set']>[1]} V */
|
| 26 |
+
|
| 27 |
+
/** @type {Map<K, V> | undefined} */ var $m;
|
| 28 |
+
|
| 29 |
+
/** @type {Channel} */
|
| 30 |
+
var channel = {
|
| 31 |
+
assert: function (key) {
|
| 32 |
+
if (!channel.has(key)) {
|
| 33 |
+
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
| 34 |
+
}
|
| 35 |
+
},
|
| 36 |
+
'delete': function (key) {
|
| 37 |
+
if ($m) {
|
| 38 |
+
var result = $mapDelete($m, key);
|
| 39 |
+
if ($mapSize($m) === 0) {
|
| 40 |
+
$m = void undefined;
|
| 41 |
+
}
|
| 42 |
+
return result;
|
| 43 |
+
}
|
| 44 |
+
return false;
|
| 45 |
+
},
|
| 46 |
+
get: function (key) { // eslint-disable-line consistent-return
|
| 47 |
+
if ($m) {
|
| 48 |
+
return $mapGet($m, key);
|
| 49 |
+
}
|
| 50 |
+
},
|
| 51 |
+
has: function (key) {
|
| 52 |
+
if ($m) {
|
| 53 |
+
return $mapHas($m, key);
|
| 54 |
+
}
|
| 55 |
+
return false;
|
| 56 |
+
},
|
| 57 |
+
set: function (key, value) {
|
| 58 |
+
if (!$m) {
|
| 59 |
+
// @ts-expect-error TS can't handle narrowing a variable inside a closure
|
| 60 |
+
$m = new $Map();
|
| 61 |
+
}
|
| 62 |
+
$mapSet($m, key, value);
|
| 63 |
+
}
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
// @ts-expect-error TODO: figure out why TS is erroring here
|
| 67 |
+
return channel;
|
| 68 |
+
};
|
node_modules/side-channel-map/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "side-channel-map",
|
| 3 |
+
"version": "1.0.1",
|
| 4 |
+
"description": "Store information about any JS value in a side channel, using a Map",
|
| 5 |
+
"main": "index.js",
|
| 6 |
+
"exports": {
|
| 7 |
+
".": "./index.js",
|
| 8 |
+
"./package.json": "./package.json"
|
| 9 |
+
},
|
| 10 |
+
"types": "./index.d.ts",
|
| 11 |
+
"scripts": {
|
| 12 |
+
"prepack": "npmignore --auto --commentLines=autogenerated",
|
| 13 |
+
"prepublishOnly": "safe-publish-latest",
|
| 14 |
+
"prepublish": "not-in-publish || npm run prepublishOnly",
|
| 15 |
+
"prelint": "evalmd README.md && eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
|
| 16 |
+
"lint": "eslint --ext=js,mjs .",
|
| 17 |
+
"postlint": "tsc -p . && attw -P",
|
| 18 |
+
"pretest": "npm run lint",
|
| 19 |
+
"tests-only": "nyc tape 'test/**/*.js'",
|
| 20 |
+
"test": "npm run tests-only",
|
| 21 |
+
"posttest": "npx npm@'>= 10.2' audit --production",
|
| 22 |
+
"version": "auto-changelog && git add CHANGELOG.md",
|
| 23 |
+
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
| 24 |
+
},
|
| 25 |
+
"repository": {
|
| 26 |
+
"type": "git",
|
| 27 |
+
"url": "git+https://github.com/ljharb/side-channel-map.git"
|
| 28 |
+
},
|
| 29 |
+
"keywords": [],
|
| 30 |
+
"author": "Jordan Harband <ljharb@gmail.com>",
|
| 31 |
+
"funding": {
|
| 32 |
+
"url": "https://github.com/sponsors/ljharb"
|
| 33 |
+
},
|
| 34 |
+
"license": "MIT",
|
| 35 |
+
"bugs": {
|
| 36 |
+
"url": "https://github.com/ljharb/side-channel-map/issues"
|
| 37 |
+
},
|
| 38 |
+
"homepage": "https://github.com/ljharb/side-channel-map#readme",
|
| 39 |
+
"dependencies": {
|
| 40 |
+
"call-bound": "^1.0.2",
|
| 41 |
+
"es-errors": "^1.3.0",
|
| 42 |
+
"get-intrinsic": "^1.2.5",
|
| 43 |
+
"object-inspect": "^1.13.3"
|
| 44 |
+
},
|
| 45 |
+
"devDependencies": {
|
| 46 |
+
"@arethetypeswrong/cli": "^0.17.1",
|
| 47 |
+
"@ljharb/eslint-config": "^21.1.1",
|
| 48 |
+
"@ljharb/tsconfig": "^0.2.2",
|
| 49 |
+
"@types/get-intrinsic": "^1.2.3",
|
| 50 |
+
"@types/object-inspect": "^1.13.0",
|
| 51 |
+
"@types/tape": "^5.6.5",
|
| 52 |
+
"auto-changelog": "^2.5.0",
|
| 53 |
+
"eclint": "^2.8.1",
|
| 54 |
+
"encoding": "^0.1.13",
|
| 55 |
+
"eslint": "=8.8.0",
|
| 56 |
+
"evalmd": "^0.0.19",
|
| 57 |
+
"in-publish": "^2.0.1",
|
| 58 |
+
"npmignore": "^0.3.1",
|
| 59 |
+
"nyc": "^10.3.2",
|
| 60 |
+
"safe-publish-latest": "^2.0.0",
|
| 61 |
+
"tape": "^5.9.0",
|
| 62 |
+
"typescript": "next"
|
| 63 |
+
},
|
| 64 |
+
"auto-changelog": {
|
| 65 |
+
"output": "CHANGELOG.md",
|
| 66 |
+
"template": "keepachangelog",
|
| 67 |
+
"unreleased": false,
|
| 68 |
+
"commitLimit": false,
|
| 69 |
+
"backfillLimit": false,
|
| 70 |
+
"hideCredit": true
|
| 71 |
+
},
|
| 72 |
+
"publishConfig": {
|
| 73 |
+
"ignore": [
|
| 74 |
+
".github/workflows"
|
| 75 |
+
]
|
| 76 |
+
},
|
| 77 |
+
"engines": {
|
| 78 |
+
"node": ">= 0.4"
|
| 79 |
+
}
|
| 80 |
+
}
|
node_modules/side-channel-map/test/index.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var test = require('tape');
|
| 4 |
+
|
| 5 |
+
var getSideChannelMap = require('../');
|
| 6 |
+
|
| 7 |
+
test('getSideChannelMap', { skip: typeof Map !== 'function' }, function (t) {
|
| 8 |
+
var getSideChannel = getSideChannelMap || function () {
|
| 9 |
+
throw new EvalError('should never happen');
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
t.test('export', function (st) {
|
| 13 |
+
st.equal(typeof getSideChannel, 'function', 'is a function');
|
| 14 |
+
|
| 15 |
+
st.equal(getSideChannel.length, 0, 'takes no arguments');
|
| 16 |
+
|
| 17 |
+
var channel = getSideChannel();
|
| 18 |
+
st.ok(channel, 'is truthy');
|
| 19 |
+
st.equal(typeof channel, 'object', 'is an object');
|
| 20 |
+
st.end();
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
t.test('assert', function (st) {
|
| 24 |
+
var channel = getSideChannel();
|
| 25 |
+
st['throws'](
|
| 26 |
+
function () { channel.assert({}); },
|
| 27 |
+
TypeError,
|
| 28 |
+
'nonexistent value throws'
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
var o = {};
|
| 32 |
+
channel.set(o, 'data');
|
| 33 |
+
st.doesNotThrow(function () { channel.assert(o); }, 'existent value noops');
|
| 34 |
+
|
| 35 |
+
st.end();
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
t.test('has', function (st) {
|
| 39 |
+
var channel = getSideChannel();
|
| 40 |
+
/** @type {unknown[]} */ var o = [];
|
| 41 |
+
|
| 42 |
+
st.equal(channel.has(o), false, 'nonexistent value yields false');
|
| 43 |
+
|
| 44 |
+
channel.set(o, 'foo');
|
| 45 |
+
st.equal(channel.has(o), true, 'existent value yields true');
|
| 46 |
+
|
| 47 |
+
st.equal(channel.has('abc'), false, 'non object value non existent yields false');
|
| 48 |
+
|
| 49 |
+
channel.set('abc', 'foo');
|
| 50 |
+
st.equal(channel.has('abc'), true, 'non object value that exists yields true');
|
| 51 |
+
|
| 52 |
+
st.end();
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
t.test('get', function (st) {
|
| 56 |
+
var channel = getSideChannel();
|
| 57 |
+
var o = {};
|
| 58 |
+
st.equal(channel.get(o), undefined, 'nonexistent value yields undefined');
|
| 59 |
+
|
| 60 |
+
var data = {};
|
| 61 |
+
channel.set(o, data);
|
| 62 |
+
st.equal(channel.get(o), data, '"get" yields data set by "set"');
|
| 63 |
+
|
| 64 |
+
st.end();
|
| 65 |
+
});
|
| 66 |
+
|
| 67 |
+
t.test('set', function (st) {
|
| 68 |
+
var channel = getSideChannel();
|
| 69 |
+
var o = function () {};
|
| 70 |
+
st.equal(channel.get(o), undefined, 'value not set');
|
| 71 |
+
|
| 72 |
+
channel.set(o, 42);
|
| 73 |
+
st.equal(channel.get(o), 42, 'value was set');
|
| 74 |
+
|
| 75 |
+
channel.set(o, Infinity);
|
| 76 |
+
st.equal(channel.get(o), Infinity, 'value was set again');
|
| 77 |
+
|
| 78 |
+
var o2 = {};
|
| 79 |
+
channel.set(o2, 17);
|
| 80 |
+
st.equal(channel.get(o), Infinity, 'o is not modified');
|
| 81 |
+
st.equal(channel.get(o2), 17, 'o2 is set');
|
| 82 |
+
|
| 83 |
+
channel.set(o, 14);
|
| 84 |
+
st.equal(channel.get(o), 14, 'o is modified');
|
| 85 |
+
st.equal(channel.get(o2), 17, 'o2 is not modified');
|
| 86 |
+
|
| 87 |
+
st.end();
|
| 88 |
+
});
|
| 89 |
+
|
| 90 |
+
t.test('delete', function (st) {
|
| 91 |
+
var channel = getSideChannel();
|
| 92 |
+
var o = {};
|
| 93 |
+
st.equal(channel['delete']({}), false, 'nonexistent value yields false');
|
| 94 |
+
|
| 95 |
+
channel.set(o, 42);
|
| 96 |
+
st.equal(channel.has(o), true, 'value is set');
|
| 97 |
+
|
| 98 |
+
st.equal(channel['delete']({}), false, 'nonexistent value still yields false');
|
| 99 |
+
|
| 100 |
+
st.equal(channel['delete'](o), true, 'deleted value yields true');
|
| 101 |
+
|
| 102 |
+
st.equal(channel.has(o), false, 'value is no longer set');
|
| 103 |
+
|
| 104 |
+
st.end();
|
| 105 |
+
});
|
| 106 |
+
|
| 107 |
+
t.end();
|
| 108 |
+
});
|
| 109 |
+
|
| 110 |
+
test('getSideChannelMap, no Maps', { skip: typeof Map === 'function' }, function (t) {
|
| 111 |
+
t.equal(getSideChannelMap, false, 'is false');
|
| 112 |
+
|
| 113 |
+
t.end();
|
| 114 |
+
});
|
node_modules/side-channel-map/tsconfig.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"extends": "@ljharb/tsconfig",
|
| 3 |
+
"compilerOptions": {
|
| 4 |
+
"target": "es2021",
|
| 5 |
+
},
|
| 6 |
+
"exclude": [
|
| 7 |
+
"coverage",
|
| 8 |
+
],
|
| 9 |
+
}
|
node_modules/side-channel-weakmap/.editorconfig
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
root = true
|
| 2 |
+
|
| 3 |
+
[*]
|
| 4 |
+
charset = utf-8
|
| 5 |
+
end_of_line = lf
|
| 6 |
+
insert_final_newline = true
|
| 7 |
+
indent_style = tab
|
| 8 |
+
indent_size = 2
|
| 9 |
+
trim_trailing_whitespace = true
|
node_modules/side-channel-weakmap/.eslintrc
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"root": true,
|
| 3 |
+
|
| 4 |
+
"extends": "@ljharb",
|
| 5 |
+
|
| 6 |
+
"rules": {
|
| 7 |
+
"id-length": 0,
|
| 8 |
+
"max-lines-per-function": 0,
|
| 9 |
+
"multiline-comment-style": 1,
|
| 10 |
+
"new-cap": [2, { "capIsNewExceptions": ["GetIntrinsic"] }],
|
| 11 |
+
},
|
| 12 |
+
}
|
node_modules/side-channel-weakmap/.github/FUNDING.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# These are supported funding model platforms
|
| 2 |
+
|
| 3 |
+
github: [ljharb]
|
| 4 |
+
patreon: # Replace with a single Patreon username
|
| 5 |
+
open_collective: # Replace with a single Open Collective username
|
| 6 |
+
ko_fi: # Replace with a single Ko-fi username
|
| 7 |
+
tidelift: npm/side-channel-weakmap
|
| 8 |
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
| 9 |
+
liberapay: # Replace with a single Liberapay username
|
| 10 |
+
issuehunt: # Replace with a single IssueHunt username
|
| 11 |
+
otechie: # Replace with a single Otechie username
|
| 12 |
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
node_modules/side-channel-weakmap/.nycrc
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"all": true,
|
| 3 |
+
"check-coverage": false,
|
| 4 |
+
"reporter": ["text-summary", "text", "html", "json"],
|
| 5 |
+
"lines": 86,
|
| 6 |
+
"statements": 85.93,
|
| 7 |
+
"functions": 82.43,
|
| 8 |
+
"branches": 76.06,
|
| 9 |
+
"exclude": [
|
| 10 |
+
"coverage",
|
| 11 |
+
"test"
|
| 12 |
+
]
|
| 13 |
+
}
|
node_modules/side-channel-weakmap/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
|
| 3 |
+
All notable changes to this project will be documented in this file.
|
| 4 |
+
|
| 5 |
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
| 6 |
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
| 7 |
+
|
| 8 |
+
## [v1.0.2](https://github.com/ljharb/side-channel-weakmap/compare/v1.0.1...v1.0.2) - 2024-12-10
|
| 9 |
+
|
| 10 |
+
### Commits
|
| 11 |
+
|
| 12 |
+
- [types] fix generics ordering [`1b62e94`](https://github.com/ljharb/side-channel-weakmap/commit/1b62e94a2ad6ed30b640ba73c4a2535836c67289)
|
| 13 |
+
|
| 14 |
+
## [v1.0.1](https://github.com/ljharb/side-channel-weakmap/compare/v1.0.0...v1.0.1) - 2024-12-10
|
| 15 |
+
|
| 16 |
+
### Commits
|
| 17 |
+
|
| 18 |
+
- [types] fix generics ordering [`08a4a5d`](https://github.com/ljharb/side-channel-weakmap/commit/08a4a5dbffedc3ebc79f1aaaf5a3dd6d2196dc1b)
|
| 19 |
+
- [Deps] update `side-channel-map` [`b53fe44`](https://github.com/ljharb/side-channel-weakmap/commit/b53fe447dfdd3a9aebedfd015b384eac17fce916)
|
| 20 |
+
|
| 21 |
+
## v1.0.0 - 2024-12-10
|
| 22 |
+
|
| 23 |
+
### Commits
|
| 24 |
+
|
| 25 |
+
- Initial implementation, tests, readme, types [`53c0fa4`](https://github.com/ljharb/side-channel-weakmap/commit/53c0fa4788435a006f58b9d7b43cb65989ecee49)
|
| 26 |
+
- Initial commit [`a157947`](https://github.com/ljharb/side-channel-weakmap/commit/a157947f26fcaf2c4a941d3a044e76bf67343532)
|
| 27 |
+
- npm init [`54dfc55`](https://github.com/ljharb/side-channel-weakmap/commit/54dfc55bafb16265910d5aad4e743c43aee5bbbb)
|
| 28 |
+
- Only apps should have lockfiles [`0ddd6c7`](https://github.com/ljharb/side-channel-weakmap/commit/0ddd6c7b07fe8ee04d67b2e9f7255af7ce62c07d)
|
node_modules/side-channel-weakmap/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2019 Jordan Harband
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
node_modules/side-channel-weakmap/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# side-channel-weakmap <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
| 2 |
+
|
| 3 |
+
[![github actions][actions-image]][actions-url]
|
| 4 |
+
[![coverage][codecov-image]][codecov-url]
|
| 5 |
+
[![License][license-image]][license-url]
|
| 6 |
+
[![Downloads][downloads-image]][downloads-url]
|
| 7 |
+
|
| 8 |
+
[![npm badge][npm-badge-png]][package-url]
|
| 9 |
+
|
| 10 |
+
Store information about any JS value in a side channel. Uses WeakMap if available.
|
| 11 |
+
|
| 12 |
+
Warning: this implementation will leak memory until you `delete` the `key`.
|
| 13 |
+
Use [`side-channel`](https://npmjs.com/side-channel) for the best available strategy.
|
| 14 |
+
|
| 15 |
+
## Getting started
|
| 16 |
+
|
| 17 |
+
```sh
|
| 18 |
+
npm install --save side-channel-weakmap
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
## Usage/Examples
|
| 22 |
+
|
| 23 |
+
```js
|
| 24 |
+
const assert = require('assert');
|
| 25 |
+
const getSideChannelList = require('side-channel-weakmap');
|
| 26 |
+
|
| 27 |
+
const channel = getSideChannelList();
|
| 28 |
+
|
| 29 |
+
const key = {};
|
| 30 |
+
assert.equal(channel.has(key), false);
|
| 31 |
+
assert.throws(() => channel.assert(key), TypeError);
|
| 32 |
+
|
| 33 |
+
channel.set(key, 42);
|
| 34 |
+
|
| 35 |
+
channel.assert(key); // does not throw
|
| 36 |
+
assert.equal(channel.has(key), true);
|
| 37 |
+
assert.equal(channel.get(key), 42);
|
| 38 |
+
|
| 39 |
+
channel.delete(key);
|
| 40 |
+
assert.equal(channel.has(key), false);
|
| 41 |
+
assert.throws(() => channel.assert(key), TypeError);
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
## Tests
|
| 45 |
+
|
| 46 |
+
Clone the repo, `npm install`, and run `npm test`
|
| 47 |
+
|
| 48 |
+
[package-url]: https://npmjs.org/package/side-channel-weakmap
|
| 49 |
+
[npm-version-svg]: https://versionbadg.es/ljharb/side-channel-weakmap.svg
|
| 50 |
+
[deps-svg]: https://david-dm.org/ljharb/side-channel-weakmap.svg
|
| 51 |
+
[deps-url]: https://david-dm.org/ljharb/side-channel-weakmap
|
| 52 |
+
[dev-deps-svg]: https://david-dm.org/ljharb/side-channel-weakmap/dev-status.svg
|
| 53 |
+
[dev-deps-url]: https://david-dm.org/ljharb/side-channel-weakmap#info=devDependencies
|
| 54 |
+
[npm-badge-png]: https://nodei.co/npm/side-channel-weakmap.png?downloads=true&stars=true
|
| 55 |
+
[license-image]: https://img.shields.io/npm/l/side-channel-weakmap.svg
|
| 56 |
+
[license-url]: LICENSE
|
| 57 |
+
[downloads-image]: https://img.shields.io/npm/dm/side-channel-weakmap.svg
|
| 58 |
+
[downloads-url]: https://npm-stat.com/charts.html?package=side-channel-weakmap
|
| 59 |
+
[codecov-image]: https://codecov.io/gh/ljharb/side-channel-weakmap/branch/main/graphs/badge.svg
|
| 60 |
+
[codecov-url]: https://app.codecov.io/gh/ljharb/side-channel-weakmap/
|
| 61 |
+
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/side-channel-weakmap
|
| 62 |
+
[actions-url]: https://github.com/ljharb/side-channel-weakmap/actions
|
node_modules/side-channel-weakmap/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare namespace getSideChannelWeakMap {
|
| 2 |
+
type Channel<K, V> = {
|
| 3 |
+
assert: (key: K) => void;
|
| 4 |
+
has: (key: K) => boolean;
|
| 5 |
+
get: (key: K) => V | undefined;
|
| 6 |
+
set: (key: K, value: V) => void;
|
| 7 |
+
delete: (key: K) => boolean;
|
| 8 |
+
}
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
declare function getSideChannelWeakMap<K, V>(): getSideChannelWeakMap.Channel<K, V>;
|
| 12 |
+
|
| 13 |
+
declare const x: false | typeof getSideChannelWeakMap;
|
| 14 |
+
|
| 15 |
+
export = x;
|
node_modules/side-channel-weakmap/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var GetIntrinsic = require('get-intrinsic');
|
| 4 |
+
var callBound = require('call-bound');
|
| 5 |
+
var inspect = require('object-inspect');
|
| 6 |
+
var getSideChannelMap = require('side-channel-map');
|
| 7 |
+
|
| 8 |
+
var $TypeError = require('es-errors/type');
|
| 9 |
+
var $WeakMap = GetIntrinsic('%WeakMap%', true);
|
| 10 |
+
|
| 11 |
+
/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => V} */
|
| 12 |
+
var $weakMapGet = callBound('WeakMap.prototype.get', true);
|
| 13 |
+
/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K, value: V) => void} */
|
| 14 |
+
var $weakMapSet = callBound('WeakMap.prototype.set', true);
|
| 15 |
+
/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean} */
|
| 16 |
+
var $weakMapHas = callBound('WeakMap.prototype.has', true);
|
| 17 |
+
/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean} */
|
| 18 |
+
var $weakMapDelete = callBound('WeakMap.prototype.delete', true);
|
| 19 |
+
|
| 20 |
+
/** @type {import('.')} */
|
| 21 |
+
module.exports = $WeakMap
|
| 22 |
+
? /** @type {Exclude<import('.'), false>} */ function getSideChannelWeakMap() {
|
| 23 |
+
/** @typedef {ReturnType<typeof getSideChannelWeakMap>} Channel */
|
| 24 |
+
/** @typedef {Parameters<Channel['get']>[0]} K */
|
| 25 |
+
/** @typedef {Parameters<Channel['set']>[1]} V */
|
| 26 |
+
|
| 27 |
+
/** @type {WeakMap<K & object, V> | undefined} */ var $wm;
|
| 28 |
+
/** @type {Channel | undefined} */ var $m;
|
| 29 |
+
|
| 30 |
+
/** @type {Channel} */
|
| 31 |
+
var channel = {
|
| 32 |
+
assert: function (key) {
|
| 33 |
+
if (!channel.has(key)) {
|
| 34 |
+
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
| 35 |
+
}
|
| 36 |
+
},
|
| 37 |
+
'delete': function (key) {
|
| 38 |
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
| 39 |
+
if ($wm) {
|
| 40 |
+
return $weakMapDelete($wm, key);
|
| 41 |
+
}
|
| 42 |
+
} else if (getSideChannelMap) {
|
| 43 |
+
if ($m) {
|
| 44 |
+
return $m['delete'](key);
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
return false;
|
| 48 |
+
},
|
| 49 |
+
get: function (key) {
|
| 50 |
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
| 51 |
+
if ($wm) {
|
| 52 |
+
return $weakMapGet($wm, key);
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
return $m && $m.get(key);
|
| 56 |
+
},
|
| 57 |
+
has: function (key) {
|
| 58 |
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
| 59 |
+
if ($wm) {
|
| 60 |
+
return $weakMapHas($wm, key);
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
return !!$m && $m.has(key);
|
| 64 |
+
},
|
| 65 |
+
set: function (key, value) {
|
| 66 |
+
if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
| 67 |
+
if (!$wm) {
|
| 68 |
+
$wm = new $WeakMap();
|
| 69 |
+
}
|
| 70 |
+
$weakMapSet($wm, key, value);
|
| 71 |
+
} else if (getSideChannelMap) {
|
| 72 |
+
if (!$m) {
|
| 73 |
+
$m = getSideChannelMap();
|
| 74 |
+
}
|
| 75 |
+
// eslint-disable-next-line no-extra-parens
|
| 76 |
+
/** @type {NonNullable<typeof $m>} */ ($m).set(key, value);
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
};
|
| 80 |
+
|
| 81 |
+
// @ts-expect-error TODO: figure out why this is erroring
|
| 82 |
+
return channel;
|
| 83 |
+
}
|
| 84 |
+
: getSideChannelMap;
|
node_modules/side-channel-weakmap/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "side-channel-weakmap",
|
| 3 |
+
"version": "1.0.2",
|
| 4 |
+
"description": "Store information about any JS value in a side channel. Uses WeakMap if available.",
|
| 5 |
+
"main": "index.js",
|
| 6 |
+
"exports": {
|
| 7 |
+
".": "./index.js",
|
| 8 |
+
"./package.json": "./package.json"
|
| 9 |
+
},
|
| 10 |
+
"types": "./index.d.ts",
|
| 11 |
+
"scripts": {
|
| 12 |
+
"prepack": "npmignore --auto --commentLines=autogenerated",
|
| 13 |
+
"prepublishOnly": "safe-publish-latest",
|
| 14 |
+
"prepublish": "not-in-publish || npm run prepublishOnly",
|
| 15 |
+
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
|
| 16 |
+
"lint": "eslint --ext=js,mjs .",
|
| 17 |
+
"postlint": "tsc -p . && attw -P",
|
| 18 |
+
"pretest": "npm run lint",
|
| 19 |
+
"tests-only": "nyc tape 'test/**/*.js'",
|
| 20 |
+
"test": "npm run tests-only",
|
| 21 |
+
"posttest": "npx npm@'>=10.2' audit --production",
|
| 22 |
+
"version": "auto-changelog && git add CHANGELOG.md",
|
| 23 |
+
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
| 24 |
+
},
|
| 25 |
+
"repository": {
|
| 26 |
+
"type": "git",
|
| 27 |
+
"url": "git+https://github.com/ljharb/side-channel-weakmap.git"
|
| 28 |
+
},
|
| 29 |
+
"keywords": [
|
| 30 |
+
"weakmap",
|
| 31 |
+
"map",
|
| 32 |
+
"side",
|
| 33 |
+
"channel",
|
| 34 |
+
"metadata"
|
| 35 |
+
],
|
| 36 |
+
"author": "Jordan Harband <ljharb@gmail.com>",
|
| 37 |
+
"funding": {
|
| 38 |
+
"url": "https://github.com/sponsors/ljharb"
|
| 39 |
+
},
|
| 40 |
+
"license": "MIT",
|
| 41 |
+
"bugs": {
|
| 42 |
+
"url": "https://github.com/ljharb/side-channel-weakmap/issues"
|
| 43 |
+
},
|
| 44 |
+
"homepage": "https://github.com/ljharb/side-channel-weakmap#readme",
|
| 45 |
+
"dependencies": {
|
| 46 |
+
"call-bound": "^1.0.2",
|
| 47 |
+
"es-errors": "^1.3.0",
|
| 48 |
+
"get-intrinsic": "^1.2.5",
|
| 49 |
+
"object-inspect": "^1.13.3",
|
| 50 |
+
"side-channel-map": "^1.0.1"
|
| 51 |
+
},
|
| 52 |
+
"devDependencies": {
|
| 53 |
+
"@arethetypeswrong/cli": "^0.17.1",
|
| 54 |
+
"@ljharb/eslint-config": "^21.1.1",
|
| 55 |
+
"@ljharb/tsconfig": "^0.2.2",
|
| 56 |
+
"@types/call-bind": "^1.0.5",
|
| 57 |
+
"@types/get-intrinsic": "^1.2.3",
|
| 58 |
+
"@types/object-inspect": "^1.13.0",
|
| 59 |
+
"@types/tape": "^5.6.5",
|
| 60 |
+
"auto-changelog": "^2.5.0",
|
| 61 |
+
"eclint": "^2.8.1",
|
| 62 |
+
"encoding": "^0.1.13",
|
| 63 |
+
"eslint": "=8.8.0",
|
| 64 |
+
"in-publish": "^2.0.1",
|
| 65 |
+
"npmignore": "^0.3.1",
|
| 66 |
+
"nyc": "^10.3.2",
|
| 67 |
+
"safe-publish-latest": "^2.0.0",
|
| 68 |
+
"tape": "^5.9.0",
|
| 69 |
+
"typescript": "next"
|
| 70 |
+
},
|
| 71 |
+
"auto-changelog": {
|
| 72 |
+
"output": "CHANGELOG.md",
|
| 73 |
+
"template": "keepachangelog",
|
| 74 |
+
"unreleased": false,
|
| 75 |
+
"commitLimit": false,
|
| 76 |
+
"backfillLimit": false,
|
| 77 |
+
"hideCredit": true
|
| 78 |
+
},
|
| 79 |
+
"publishConfig": {
|
| 80 |
+
"ignore": [
|
| 81 |
+
".github/workflows"
|
| 82 |
+
]
|
| 83 |
+
},
|
| 84 |
+
"engines": {
|
| 85 |
+
"node": ">= 0.4"
|
| 86 |
+
}
|
| 87 |
+
}
|
node_modules/side-channel-weakmap/test/index.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var test = require('tape');
|
| 4 |
+
|
| 5 |
+
var getSideChannelWeakMap = require('../');
|
| 6 |
+
|
| 7 |
+
test('getSideChannelMap', { skip: typeof WeakMap !== 'function' && typeof Map !== 'function' }, function (t) {
|
| 8 |
+
var getSideChannel = getSideChannelWeakMap || function () {
|
| 9 |
+
throw new EvalError('should never happen');
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
t.test('export', function (st) {
|
| 13 |
+
st.equal(typeof getSideChannel, 'function', 'is a function');
|
| 14 |
+
|
| 15 |
+
st.equal(getSideChannel.length, 0, 'takes no arguments');
|
| 16 |
+
|
| 17 |
+
var channel = getSideChannel();
|
| 18 |
+
st.ok(channel, 'is truthy');
|
| 19 |
+
st.equal(typeof channel, 'object', 'is an object');
|
| 20 |
+
st.end();
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
t.test('assert', function (st) {
|
| 24 |
+
var channel = getSideChannel();
|
| 25 |
+
st['throws'](
|
| 26 |
+
function () { channel.assert({}); },
|
| 27 |
+
TypeError,
|
| 28 |
+
'nonexistent value throws'
|
| 29 |
+
);
|
| 30 |
+
|
| 31 |
+
var o = {};
|
| 32 |
+
channel.set(o, 'data');
|
| 33 |
+
st.doesNotThrow(function () { channel.assert(o); }, 'existent value noops');
|
| 34 |
+
|
| 35 |
+
st.end();
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
t.test('has', function (st) {
|
| 39 |
+
var channel = getSideChannel();
|
| 40 |
+
/** @type {unknown[]} */ var o = [];
|
| 41 |
+
|
| 42 |
+
st.equal(channel.has(o), false, 'nonexistent value yields false');
|
| 43 |
+
|
| 44 |
+
channel.set(o, 'foo');
|
| 45 |
+
st.equal(channel.has(o), true, 'existent value yields true');
|
| 46 |
+
|
| 47 |
+
st.equal(channel.has('abc'), false, 'non object value non existent yields false');
|
| 48 |
+
|
| 49 |
+
channel.set('abc', 'foo');
|
| 50 |
+
st.equal(channel.has('abc'), true, 'non object value that exists yields true');
|
| 51 |
+
|
| 52 |
+
st.end();
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
t.test('get', function (st) {
|
| 56 |
+
var channel = getSideChannel();
|
| 57 |
+
var o = {};
|
| 58 |
+
st.equal(channel.get(o), undefined, 'nonexistent value yields undefined');
|
| 59 |
+
|
| 60 |
+
var data = {};
|
| 61 |
+
channel.set(o, data);
|
| 62 |
+
st.equal(channel.get(o), data, '"get" yields data set by "set"');
|
| 63 |
+
|
| 64 |
+
st.end();
|
| 65 |
+
});
|
| 66 |
+
|
| 67 |
+
t.test('set', function (st) {
|
| 68 |
+
var channel = getSideChannel();
|
| 69 |
+
var o = function () {};
|
| 70 |
+
st.equal(channel.get(o), undefined, 'value not set');
|
| 71 |
+
|
| 72 |
+
channel.set(o, 42);
|
| 73 |
+
st.equal(channel.get(o), 42, 'value was set');
|
| 74 |
+
|
| 75 |
+
channel.set(o, Infinity);
|
| 76 |
+
st.equal(channel.get(o), Infinity, 'value was set again');
|
| 77 |
+
|
| 78 |
+
var o2 = {};
|
| 79 |
+
channel.set(o2, 17);
|
| 80 |
+
st.equal(channel.get(o), Infinity, 'o is not modified');
|
| 81 |
+
st.equal(channel.get(o2), 17, 'o2 is set');
|
| 82 |
+
|
| 83 |
+
channel.set(o, 14);
|
| 84 |
+
st.equal(channel.get(o), 14, 'o is modified');
|
| 85 |
+
st.equal(channel.get(o2), 17, 'o2 is not modified');
|
| 86 |
+
|
| 87 |
+
st.end();
|
| 88 |
+
});
|
| 89 |
+
|
| 90 |
+
t.test('delete', function (st) {
|
| 91 |
+
var channel = getSideChannel();
|
| 92 |
+
var o = {};
|
| 93 |
+
st.equal(channel['delete']({}), false, 'nonexistent value yields false');
|
| 94 |
+
|
| 95 |
+
channel.set(o, 42);
|
| 96 |
+
st.equal(channel.has(o), true, 'value is set');
|
| 97 |
+
|
| 98 |
+
st.equal(channel['delete']({}), false, 'nonexistent value still yields false');
|
| 99 |
+
|
| 100 |
+
st.equal(channel['delete'](o), true, 'deleted value yields true');
|
| 101 |
+
|
| 102 |
+
st.equal(channel.has(o), false, 'value is no longer set');
|
| 103 |
+
|
| 104 |
+
st.end();
|
| 105 |
+
});
|
| 106 |
+
|
| 107 |
+
t.end();
|
| 108 |
+
});
|
| 109 |
+
|
| 110 |
+
test('getSideChannelMap, no WeakMaps and/or Maps', { skip: typeof WeakMap === 'function' || typeof Map === 'function' }, function (t) {
|
| 111 |
+
t.equal(getSideChannelWeakMap, false, 'is false');
|
| 112 |
+
|
| 113 |
+
t.end();
|
| 114 |
+
});
|
node_modules/side-channel-weakmap/tsconfig.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"extends": "@ljharb/tsconfig",
|
| 3 |
+
"compilerOptions": {
|
| 4 |
+
"target": "es2021",
|
| 5 |
+
},
|
| 6 |
+
"exclude": [
|
| 7 |
+
"coverage",
|
| 8 |
+
],
|
| 9 |
+
}
|
node_modules/siginfo/.travis.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
notifications:
|
| 2 |
+
email: false
|
| 3 |
+
language: node_js
|
| 4 |
+
node_js:
|
| 5 |
+
- node
|
| 6 |
+
deploy:
|
| 7 |
+
provider: npm
|
| 8 |
+
email:
|
| 9 |
+
secure: Y10Dvn9UbfpZPbulnl/e7dsiN/1xr06h7k6nJZyxRzr9Hh0UUFPism6k5CFaSegyPIF7sODNBQz4lvXIi2NwcvTLQruw5ehXW0NJ/G7x1TU94pzzhVJ31KBlRWzjKdvVTDsDzFxe5wKWxagPUTkieiIN9CWTQjafByNs3zbK8HL7cmu4Nc42JquVGbtpGgLs7Js+tY+WVB1dMQ4SfqpFgWjm2h05uyXCWHLK5amEAZJLP755lOVgMzw/jQGRg7J4vX4+eRE0r/g0v09x9FUU3ROEmJvqYa14CmGESRhSUyRlv4pnMIs/aK8ZDD8ia3eoTSvMJv8mzdvpkvKzWV1HSZFUX3QZVgWJEmeoF6XP+mdkWu5gnZVlOIBc8NANcS60Dr8QwF470xpPxsyAyf2o9UzX8Xy2qO8XNY/TykGO4soCfOEuVNdw5F9hHEldMHY8p9Z8EJSCn/xfM//LEvxRKREYsMqFtsnwUsv+qiAkHPSHXWQo6HYp+/xDchv63NxtjGHdPs9VpUFr1F8CxZjdis2HZfOnx51W0JIwNYlXNxeqC3WjRUqvRp2NknS982lRHCkHtZfHijGvMm7kj3QL+Ufc7pIfEGnMAKKiNv9kOryjQc29046pRZww9lWjrhoCeEPRhFbkgFV7Mo3bvOExstsSdRnOTlogCe4NviKOwfE=
|
| 10 |
+
api_key:
|
| 11 |
+
secure: cAmf8extX/sPl+sxC/6sWTmaiSGrXQY9C/lLg9c76Qn12MLysxDYgCRXfl8Az3RIbRuajq0SbyWXeDa/4wZc1PazuUGjZG82na+kuEDg8m5z0gLiJlhp60C0nj3WMJaRBRsOha1Jbs59eU3XNy+H0U5VczHrdw6v2yCHTlauhT/NYiPXMyKmTIJPB/X7gryFuXVhCPNdRBp3rPicbt0d68J+vWv9KNpjA1WB0WDUSl5rMUQbjjsRF2/DKj9WxXjmci+ac+/pCN3rQxgYZ0Ot5o5/RcWucc21ZdFgsLo8dq5YZDl/EQf/pPmkhquiiLRhiTyCBbEw1sDzYHTbTJThrukrZALg0on7XvxbXSQrxgc/IMJ/RT0PoGLEqyAZUSzGa6HPVlHUBt4LB3zgrswGmGUVkZmbiag0foIFeCKlydwEyBYfnFdRddxF6n3irft1l1NJ1HKNxKLnKvyt8iaOlGteXOOfLXzU17DgMgwTsZsvFmtFQcs6yolLHW9RnRTLf56+x/kJZ4kVJjHuyb/98pS4F7etJ2SpZqt1cVUFd/AYtnxL3jKiUhJLNL8hNUIH3eSpMfZUOUxGv1OWuwgyEhSONkITF2VPn4yuyxS23Ewq4LLj/u/9sPlLaGSN4Avaw21gi6L+M9x620sTZHYtNLniVMTAu6aPiM32zPreK2I=
|
| 12 |
+
on:
|
| 13 |
+
tags: true
|
node_modules/siginfo/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2017, Emil Bay <github@tixz.dk>
|
| 2 |
+
|
| 3 |
+
Permission to use, copy, modify, and/or distribute this software for any
|
| 4 |
+
purpose with or without fee is hereby granted, provided that the above
|
| 5 |
+
copyright notice and this permission notice appear in all copies.
|
| 6 |
+
|
| 7 |
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 8 |
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 9 |
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 10 |
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 11 |
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 12 |
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
| 13 |
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
node_modules/siginfo/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# `siginfo`
|
| 2 |
+
|
| 3 |
+
[](https://travis-ci.org/eemilbayes/siginfo)
|
| 4 |
+
|
| 5 |
+
> Utility module to print pretty messages on SIGINFO/SIGUSR1
|
| 6 |
+
|
| 7 |
+
`SIGINFO` on BSD / macOS and `SIGUSR1` on Linux, usually triggered by
|
| 8 |
+
`Ctrl + T`, are by convention used to print information about
|
| 9 |
+
a long running process internal state. Eg. `dd` will tell you how many blocks it
|
| 10 |
+
has written and at what speed, while `xz` will tell you progress, compression
|
| 11 |
+
ratio and estimated time remaining.
|
| 12 |
+
|
| 13 |
+
This module wraps both signals, checks if the process is connected to TTY and
|
| 14 |
+
lets you do whatever you want.
|
| 15 |
+
|
| 16 |
+
## Usage
|
| 17 |
+
|
| 18 |
+
```js
|
| 19 |
+
var siginfo = require('siginfo')
|
| 20 |
+
var pkg = require('./package.json')
|
| 21 |
+
|
| 22 |
+
siginfo(function () {
|
| 23 |
+
console.dir({
|
| 24 |
+
version: pkg.version,
|
| 25 |
+
uptime: process.uptime()
|
| 26 |
+
})
|
| 27 |
+
})
|
| 28 |
+
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
## API
|
| 32 |
+
|
| 33 |
+
### `var removeListener = siginfo(queryFn, [force])`
|
| 34 |
+
|
| 35 |
+
`queryFn` can be used for whatever you want (logging, sending a UDP message, etc.).
|
| 36 |
+
Setting `force = true` will attach the event handlers whether a TTY is present
|
| 37 |
+
or not.
|
| 38 |
+
|
| 39 |
+
## Install
|
| 40 |
+
|
| 41 |
+
```sh
|
| 42 |
+
npm install siginfo
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## License
|
| 46 |
+
|
| 47 |
+
[ISC](LICENSE)
|
node_modules/siginfo/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module.exports = function (query, force) {
|
| 2 |
+
var isAttached = false
|
| 3 |
+
if (process.stderr.isTTY || force === true) {
|
| 4 |
+
isAttached = true
|
| 5 |
+
process.on('SIGINFO', onsiginfo)
|
| 6 |
+
process.on('SIGUSR1', onsiginfo)
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
return function () {
|
| 10 |
+
if (isAttached === true) {
|
| 11 |
+
process.removeListener('SIGINFO', onsiginfo)
|
| 12 |
+
process.removeListener('SIGUSR1', onsiginfo)
|
| 13 |
+
isAttached = false
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function onsiginfo () {
|
| 18 |
+
query()
|
| 19 |
+
}
|
| 20 |
+
}
|
node_modules/siginfo/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "siginfo",
|
| 3 |
+
"version": "2.0.0",
|
| 4 |
+
"description": "Utility module to print pretty messages on SIGINFO/SIGUSR1",
|
| 5 |
+
"main": "index.js",
|
| 6 |
+
"dependencies": {},
|
| 7 |
+
"devDependencies": {
|
| 8 |
+
"standard": "^14.3.4"
|
| 9 |
+
},
|
| 10 |
+
"scripts": {
|
| 11 |
+
"test": "standard"
|
| 12 |
+
},
|
| 13 |
+
"repository": {
|
| 14 |
+
"type": "git",
|
| 15 |
+
"url": "git+https://github.com/emilbayes/siginfo.git"
|
| 16 |
+
},
|
| 17 |
+
"keywords": [
|
| 18 |
+
"siginfo",
|
| 19 |
+
"sigusr1",
|
| 20 |
+
"ctrl",
|
| 21 |
+
"t",
|
| 22 |
+
"info",
|
| 23 |
+
"progress",
|
| 24 |
+
"inspect"
|
| 25 |
+
],
|
| 26 |
+
"author": "Emil Bay <github@tixz.dk>",
|
| 27 |
+
"license": "ISC",
|
| 28 |
+
"bugs": {
|
| 29 |
+
"url": "https://github.com/emilbayes/siginfo/issues"
|
| 30 |
+
},
|
| 31 |
+
"homepage": "https://github.com/emilbayes/siginfo#readme"
|
| 32 |
+
}
|
node_modules/siginfo/test.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var siginfo = require('.')
|
| 2 |
+
var pkg = require('./package.json')
|
| 3 |
+
|
| 4 |
+
var stop = siginfo(function () {
|
| 5 |
+
console.dir({
|
| 6 |
+
version: pkg.version,
|
| 7 |
+
uptime: process.uptime()
|
| 8 |
+
})
|
| 9 |
+
})
|
| 10 |
+
|
| 11 |
+
process.stdout.resume()
|
| 12 |
+
|
| 13 |
+
setTimeout(function () {
|
| 14 |
+
stop()
|
| 15 |
+
process.exit(0)
|
| 16 |
+
}, 2000)
|
node_modules/signal-exit/LICENSE.txt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The ISC License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2015-2023 Benjamin Coe, Isaac Z. Schlueter, and Contributors
|
| 4 |
+
|
| 5 |
+
Permission to use, copy, modify, and/or distribute this software
|
| 6 |
+
for any purpose with or without fee is hereby granted, provided
|
| 7 |
+
that the above copyright notice and this permission notice
|
| 8 |
+
appear in all copies.
|
| 9 |
+
|
| 10 |
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 11 |
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
| 12 |
+
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
|
| 13 |
+
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
| 14 |
+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 15 |
+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
| 16 |
+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
node_modules/signal-exit/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# signal-exit
|
| 2 |
+
|
| 3 |
+
When you want to fire an event no matter how a process exits:
|
| 4 |
+
|
| 5 |
+
- reaching the end of execution.
|
| 6 |
+
- explicitly having `process.exit(code)` called.
|
| 7 |
+
- having `process.kill(pid, sig)` called.
|
| 8 |
+
- receiving a fatal signal from outside the process
|
| 9 |
+
|
| 10 |
+
Use `signal-exit`.
|
| 11 |
+
|
| 12 |
+
```js
|
| 13 |
+
// Hybrid module, either works
|
| 14 |
+
import { onExit } from 'signal-exit'
|
| 15 |
+
// or:
|
| 16 |
+
// const { onExit } = require('signal-exit')
|
| 17 |
+
|
| 18 |
+
onExit((code, signal) => {
|
| 19 |
+
console.log('process exited!', code, signal)
|
| 20 |
+
})
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
## API
|
| 24 |
+
|
| 25 |
+
`remove = onExit((code, signal) => {}, options)`
|
| 26 |
+
|
| 27 |
+
The return value of the function is a function that will remove
|
| 28 |
+
the handler.
|
| 29 |
+
|
| 30 |
+
Note that the function _only_ fires for signals if the signal
|
| 31 |
+
would cause the process to exit. That is, there are no other
|
| 32 |
+
listeners, and it is a fatal signal.
|
| 33 |
+
|
| 34 |
+
If the global `process` object is not suitable for this purpose
|
| 35 |
+
(ie, it's unset, or doesn't have an `emit` method, etc.) then the
|
| 36 |
+
`onExit` function is a no-op that returns a no-op `remove` method.
|
| 37 |
+
|
| 38 |
+
### Options
|
| 39 |
+
|
| 40 |
+
- `alwaysLast`: Run this handler after any other signal or exit
|
| 41 |
+
handlers. This causes `process.emit` to be monkeypatched.
|
| 42 |
+
|
| 43 |
+
### Capturing Signal Exits
|
| 44 |
+
|
| 45 |
+
If the handler returns an exact boolean `true`, and the exit is a
|
| 46 |
+
due to signal, then the signal will be considered handled, and
|
| 47 |
+
will _not_ trigger a synthetic `process.kill(process.pid,
|
| 48 |
+
signal)` after firing the `onExit` handlers.
|
| 49 |
+
|
| 50 |
+
In this case, it your responsibility as the caller to exit with a
|
| 51 |
+
signal (for example, by calling `process.kill()`) if you wish to
|
| 52 |
+
preserve the same exit status that would otherwise have occurred.
|
| 53 |
+
If you do not, then the process will likely exit gracefully with
|
| 54 |
+
status 0 at some point, assuming that no other terminating signal
|
| 55 |
+
or other exit trigger occurs.
|
| 56 |
+
|
| 57 |
+
Prior to calling handlers, the `onExit` machinery is unloaded, so
|
| 58 |
+
any subsequent exits or signals will not be handled, even if the
|
| 59 |
+
signal is captured and the exit is thus prevented.
|
| 60 |
+
|
| 61 |
+
Note that numeric code exits may indicate that the process is
|
| 62 |
+
already committed to exiting, for example due to a fatal
|
| 63 |
+
exception or unhandled promise rejection, and so there is no way to
|
| 64 |
+
prevent it safely.
|
| 65 |
+
|
| 66 |
+
### Browser Fallback
|
| 67 |
+
|
| 68 |
+
The `'signal-exit/browser'` module is the same fallback shim that
|
| 69 |
+
just doesn't do anything, but presents the same function
|
| 70 |
+
interface.
|
| 71 |
+
|
| 72 |
+
Patches welcome to add something that hooks onto
|
| 73 |
+
`window.onbeforeunload` or similar, but it might just not be a
|
| 74 |
+
thing that makes sense there.
|
node_modules/signal-exit/package.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "signal-exit",
|
| 3 |
+
"version": "4.1.0",
|
| 4 |
+
"description": "when you want to fire an event no matter how a process exits.",
|
| 5 |
+
"main": "./dist/cjs/index.js",
|
| 6 |
+
"module": "./dist/mjs/index.js",
|
| 7 |
+
"browser": "./dist/mjs/browser.js",
|
| 8 |
+
"types": "./dist/mjs/index.d.ts",
|
| 9 |
+
"exports": {
|
| 10 |
+
".": {
|
| 11 |
+
"import": {
|
| 12 |
+
"types": "./dist/mjs/index.d.ts",
|
| 13 |
+
"default": "./dist/mjs/index.js"
|
| 14 |
+
},
|
| 15 |
+
"require": {
|
| 16 |
+
"types": "./dist/cjs/index.d.ts",
|
| 17 |
+
"default": "./dist/cjs/index.js"
|
| 18 |
+
}
|
| 19 |
+
},
|
| 20 |
+
"./signals": {
|
| 21 |
+
"import": {
|
| 22 |
+
"types": "./dist/mjs/signals.d.ts",
|
| 23 |
+
"default": "./dist/mjs/signals.js"
|
| 24 |
+
},
|
| 25 |
+
"require": {
|
| 26 |
+
"types": "./dist/cjs/signals.d.ts",
|
| 27 |
+
"default": "./dist/cjs/signals.js"
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"./browser": {
|
| 31 |
+
"import": {
|
| 32 |
+
"types": "./dist/mjs/browser.d.ts",
|
| 33 |
+
"default": "./dist/mjs/browser.js"
|
| 34 |
+
},
|
| 35 |
+
"require": {
|
| 36 |
+
"types": "./dist/cjs/browser.d.ts",
|
| 37 |
+
"default": "./dist/cjs/browser.js"
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
},
|
| 41 |
+
"files": [
|
| 42 |
+
"dist"
|
| 43 |
+
],
|
| 44 |
+
"engines": {
|
| 45 |
+
"node": ">=14"
|
| 46 |
+
},
|
| 47 |
+
"repository": {
|
| 48 |
+
"type": "git",
|
| 49 |
+
"url": "https://github.com/tapjs/signal-exit.git"
|
| 50 |
+
},
|
| 51 |
+
"keywords": [
|
| 52 |
+
"signal",
|
| 53 |
+
"exit"
|
| 54 |
+
],
|
| 55 |
+
"author": "Ben Coe <ben@npmjs.com>",
|
| 56 |
+
"license": "ISC",
|
| 57 |
+
"devDependencies": {
|
| 58 |
+
"@types/cross-spawn": "^6.0.2",
|
| 59 |
+
"@types/node": "^18.15.11",
|
| 60 |
+
"@types/signal-exit": "^3.0.1",
|
| 61 |
+
"@types/tap": "^15.0.8",
|
| 62 |
+
"c8": "^7.13.0",
|
| 63 |
+
"prettier": "^2.8.6",
|
| 64 |
+
"tap": "^16.3.4",
|
| 65 |
+
"ts-node": "^10.9.1",
|
| 66 |
+
"typedoc": "^0.23.28",
|
| 67 |
+
"typescript": "^5.0.2"
|
| 68 |
+
},
|
| 69 |
+
"scripts": {
|
| 70 |
+
"preversion": "npm test",
|
| 71 |
+
"postversion": "npm publish",
|
| 72 |
+
"prepublishOnly": "git push origin --follow-tags",
|
| 73 |
+
"preprepare": "rm -rf dist",
|
| 74 |
+
"prepare": "tsc -p tsconfig.json && tsc -p tsconfig-esm.json && bash ./scripts/fixup.sh",
|
| 75 |
+
"pretest": "npm run prepare",
|
| 76 |
+
"presnap": "npm run prepare",
|
| 77 |
+
"test": "c8 tap",
|
| 78 |
+
"snap": "c8 tap",
|
| 79 |
+
"format": "prettier --write . --loglevel warn",
|
| 80 |
+
"typedoc": "typedoc --tsconfig tsconfig-esm.json ./src/*.ts"
|
| 81 |
+
},
|
| 82 |
+
"prettier": {
|
| 83 |
+
"semi": false,
|
| 84 |
+
"printWidth": 75,
|
| 85 |
+
"tabWidth": 2,
|
| 86 |
+
"useTabs": false,
|
| 87 |
+
"singleQuote": true,
|
| 88 |
+
"jsxSingleQuote": false,
|
| 89 |
+
"bracketSameLine": true,
|
| 90 |
+
"arrowParens": "avoid",
|
| 91 |
+
"endOfLine": "lf"
|
| 92 |
+
},
|
| 93 |
+
"tap": {
|
| 94 |
+
"coverage": false,
|
| 95 |
+
"jobs": 1,
|
| 96 |
+
"node-arg": [
|
| 97 |
+
"--no-warnings",
|
| 98 |
+
"--loader",
|
| 99 |
+
"ts-node/esm"
|
| 100 |
+
],
|
| 101 |
+
"ts": false
|
| 102 |
+
},
|
| 103 |
+
"funding": {
|
| 104 |
+
"url": "https://github.com/sponsors/isaacs"
|
| 105 |
+
}
|
| 106 |
+
}
|
node_modules/simple-concat/.travis.yml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
language: node_js
|
| 2 |
+
node_js:
|
| 3 |
+
- lts/*
|
node_modules/simple-concat/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) Feross Aboukhadijeh
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
| 6 |
+
this software and associated documentation files (the "Software"), to deal in
|
| 7 |
+
the Software without restriction, including without limitation the rights to
|
| 8 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 9 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
| 10 |
+
subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
| 17 |
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
| 18 |
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
| 19 |
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 20 |
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
node_modules/simple-concat/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# simple-concat [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
| 2 |
+
|
| 3 |
+
[travis-image]: https://img.shields.io/travis/feross/simple-concat/master.svg
|
| 4 |
+
[travis-url]: https://travis-ci.org/feross/simple-concat
|
| 5 |
+
[npm-image]: https://img.shields.io/npm/v/simple-concat.svg
|
| 6 |
+
[npm-url]: https://npmjs.org/package/simple-concat
|
| 7 |
+
[downloads-image]: https://img.shields.io/npm/dm/simple-concat.svg
|
| 8 |
+
[downloads-url]: https://npmjs.org/package/simple-concat
|
| 9 |
+
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
| 10 |
+
[standard-url]: https://standardjs.com
|
| 11 |
+
|
| 12 |
+
### Super-minimalist version of [`concat-stream`](https://github.com/maxogden/concat-stream). Less than 15 lines!
|
| 13 |
+
|
| 14 |
+
## install
|
| 15 |
+
|
| 16 |
+
```
|
| 17 |
+
npm install simple-concat
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
## usage
|
| 21 |
+
|
| 22 |
+
This example is longer than the implementation.
|
| 23 |
+
|
| 24 |
+
```js
|
| 25 |
+
var s = new stream.PassThrough()
|
| 26 |
+
concat(s, function (err, buf) {
|
| 27 |
+
if (err) throw err
|
| 28 |
+
console.error(buf)
|
| 29 |
+
})
|
| 30 |
+
s.write('abc')
|
| 31 |
+
setTimeout(function () {
|
| 32 |
+
s.write('123')
|
| 33 |
+
}, 10)
|
| 34 |
+
setTimeout(function () {
|
| 35 |
+
s.write('456')
|
| 36 |
+
}, 20)
|
| 37 |
+
setTimeout(function () {
|
| 38 |
+
s.end('789')
|
| 39 |
+
}, 30)
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
## license
|
| 43 |
+
|
| 44 |
+
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
|
node_modules/simple-concat/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*! simple-concat. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
| 2 |
+
module.exports = function (stream, cb) {
|
| 3 |
+
var chunks = []
|
| 4 |
+
stream.on('data', function (chunk) {
|
| 5 |
+
chunks.push(chunk)
|
| 6 |
+
})
|
| 7 |
+
stream.once('end', function () {
|
| 8 |
+
if (cb) cb(null, Buffer.concat(chunks))
|
| 9 |
+
cb = null
|
| 10 |
+
})
|
| 11 |
+
stream.once('error', function (err) {
|
| 12 |
+
if (cb) cb(err)
|
| 13 |
+
cb = null
|
| 14 |
+
})
|
| 15 |
+
}
|
node_modules/simple-concat/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "simple-concat",
|
| 3 |
+
"description": "Super-minimalist version of `concat-stream`. Less than 15 lines!",
|
| 4 |
+
"version": "1.0.1",
|
| 5 |
+
"author": {
|
| 6 |
+
"name": "Feross Aboukhadijeh",
|
| 7 |
+
"email": "feross@feross.org",
|
| 8 |
+
"url": "https://feross.org"
|
| 9 |
+
},
|
| 10 |
+
"bugs": {
|
| 11 |
+
"url": "https://github.com/feross/simple-concat/issues"
|
| 12 |
+
},
|
| 13 |
+
"dependencies": {},
|
| 14 |
+
"devDependencies": {
|
| 15 |
+
"standard": "*",
|
| 16 |
+
"tape": "^5.0.1"
|
| 17 |
+
},
|
| 18 |
+
"homepage": "https://github.com/feross/simple-concat",
|
| 19 |
+
"keywords": [
|
| 20 |
+
"concat",
|
| 21 |
+
"concat-stream",
|
| 22 |
+
"concat stream"
|
| 23 |
+
],
|
| 24 |
+
"license": "MIT",
|
| 25 |
+
"main": "index.js",
|
| 26 |
+
"repository": {
|
| 27 |
+
"type": "git",
|
| 28 |
+
"url": "git://github.com/feross/simple-concat.git"
|
| 29 |
+
},
|
| 30 |
+
"scripts": {
|
| 31 |
+
"test": "standard && tape test/*.js"
|
| 32 |
+
},
|
| 33 |
+
"funding": [
|
| 34 |
+
{
|
| 35 |
+
"type": "github",
|
| 36 |
+
"url": "https://github.com/sponsors/feross"
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"type": "patreon",
|
| 40 |
+
"url": "https://www.patreon.com/feross"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"type": "consulting",
|
| 44 |
+
"url": "https://feross.org/support"
|
| 45 |
+
}
|
| 46 |
+
]
|
| 47 |
+
}
|
node_modules/simple-concat/test/basic.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var concat = require('../')
|
| 2 |
+
var stream = require('stream')
|
| 3 |
+
var test = require('tape')
|
| 4 |
+
|
| 5 |
+
test('basic', function (t) {
|
| 6 |
+
t.plan(2)
|
| 7 |
+
var s = new stream.PassThrough()
|
| 8 |
+
concat(s, function (err, buf) {
|
| 9 |
+
t.error(err)
|
| 10 |
+
t.deepEqual(buf, Buffer.from('abc123456789'))
|
| 11 |
+
})
|
| 12 |
+
s.write('abc')
|
| 13 |
+
setTimeout(function () {
|
| 14 |
+
s.write('123')
|
| 15 |
+
}, 10)
|
| 16 |
+
setTimeout(function () {
|
| 17 |
+
s.write('456')
|
| 18 |
+
}, 20)
|
| 19 |
+
setTimeout(function () {
|
| 20 |
+
s.end('789')
|
| 21 |
+
}, 30)
|
| 22 |
+
})
|
| 23 |
+
|
| 24 |
+
test('error', function (t) {
|
| 25 |
+
t.plan(2)
|
| 26 |
+
var s = new stream.PassThrough()
|
| 27 |
+
concat(s, function (err, buf) {
|
| 28 |
+
t.ok(err, 'got expected error')
|
| 29 |
+
t.ok(!buf)
|
| 30 |
+
})
|
| 31 |
+
s.write('abc')
|
| 32 |
+
setTimeout(function () {
|
| 33 |
+
s.write('123')
|
| 34 |
+
}, 10)
|
| 35 |
+
setTimeout(function () {
|
| 36 |
+
s.write('456')
|
| 37 |
+
}, 20)
|
| 38 |
+
setTimeout(function () {
|
| 39 |
+
s.emit('error', new Error('error'))
|
| 40 |
+
}, 30)
|
| 41 |
+
})
|
node_modules/simple-get/.github/dependabot.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: 2
|
| 2 |
+
updates:
|
| 3 |
+
- package-ecosystem: npm
|
| 4 |
+
directory: /
|
| 5 |
+
schedule:
|
| 6 |
+
interval: daily
|
| 7 |
+
labels:
|
| 8 |
+
- dependency
|
| 9 |
+
versioning-strategy: increase-if-necessary
|
| 10 |
+
- package-ecosystem: github-actions
|
| 11 |
+
directory: /
|
| 12 |
+
schedule:
|
| 13 |
+
interval: daily
|
| 14 |
+
labels:
|
| 15 |
+
- dependency
|
node_modules/simple-get/.github/workflows/ci.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: ci
|
| 2 |
+
'on':
|
| 3 |
+
- push
|
| 4 |
+
- pull_request
|
| 5 |
+
jobs:
|
| 6 |
+
test:
|
| 7 |
+
name: Node ${{ matrix.node }} / ${{ matrix.os }}
|
| 8 |
+
runs-on: ${{ matrix.os }}
|
| 9 |
+
strategy:
|
| 10 |
+
fail-fast: false
|
| 11 |
+
matrix:
|
| 12 |
+
os:
|
| 13 |
+
- ubuntu-latest
|
| 14 |
+
node:
|
| 15 |
+
- '14'
|
| 16 |
+
steps:
|
| 17 |
+
- uses: actions/checkout@v2
|
| 18 |
+
- uses: actions/setup-node@v2
|
| 19 |
+
with:
|
| 20 |
+
node-version: ${{ matrix.node }}
|
| 21 |
+
- run: npm install
|
| 22 |
+
- run: npm run build --if-present
|
| 23 |
+
- run: npm test
|
node_modules/simple-get/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) Feross Aboukhadijeh
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
| 6 |
+
this software and associated documentation files (the "Software"), to deal in
|
| 7 |
+
the Software without restriction, including without limitation the rights to
|
| 8 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
| 9 |
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
| 10 |
+
subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
| 17 |
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
| 18 |
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
| 19 |
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
| 20 |
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
node_modules/simple-get/README.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# simple-get [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
| 2 |
+
|
| 3 |
+
[ci-image]: https://img.shields.io/github/workflow/status/feross/simple-get/ci/master
|
| 4 |
+
[ci-url]: https://github.com/feross/simple-get/actions
|
| 5 |
+
[npm-image]: https://img.shields.io/npm/v/simple-get.svg
|
| 6 |
+
[npm-url]: https://npmjs.org/package/simple-get
|
| 7 |
+
[downloads-image]: https://img.shields.io/npm/dm/simple-get.svg
|
| 8 |
+
[downloads-url]: https://npmjs.org/package/simple-get
|
| 9 |
+
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
| 10 |
+
[standard-url]: https://standardjs.com
|
| 11 |
+
|
| 12 |
+
### Simplest way to make http get requests
|
| 13 |
+
|
| 14 |
+
## features
|
| 15 |
+
|
| 16 |
+
This module is the lightest possible wrapper on top of node.js `http`, but supporting these essential features:
|
| 17 |
+
|
| 18 |
+
- follows redirects
|
| 19 |
+
- automatically handles gzip/deflate responses
|
| 20 |
+
- supports HTTPS
|
| 21 |
+
- supports specifying a timeout
|
| 22 |
+
- supports convenience `url` key so there's no need to use `url.parse` on the url when specifying options
|
| 23 |
+
- composes well with npm packages for features like cookies, proxies, form data, & OAuth
|
| 24 |
+
|
| 25 |
+
All this in < 100 lines of code.
|
| 26 |
+
|
| 27 |
+
## install
|
| 28 |
+
|
| 29 |
+
```
|
| 30 |
+
npm install simple-get
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
## usage
|
| 34 |
+
|
| 35 |
+
Note, all these examples also work in the browser with [browserify](http://browserify.org/).
|
| 36 |
+
|
| 37 |
+
### simple GET request
|
| 38 |
+
|
| 39 |
+
Doesn't get easier than this:
|
| 40 |
+
|
| 41 |
+
```js
|
| 42 |
+
const get = require('simple-get')
|
| 43 |
+
|
| 44 |
+
get('http://example.com', function (err, res) {
|
| 45 |
+
if (err) throw err
|
| 46 |
+
console.log(res.statusCode) // 200
|
| 47 |
+
res.pipe(process.stdout) // `res` is a stream
|
| 48 |
+
})
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
### even simpler GET request
|
| 52 |
+
|
| 53 |
+
If you just want the data, and don't want to deal with streams:
|
| 54 |
+
|
| 55 |
+
```js
|
| 56 |
+
const get = require('simple-get')
|
| 57 |
+
|
| 58 |
+
get.concat('http://example.com', function (err, res, data) {
|
| 59 |
+
if (err) throw err
|
| 60 |
+
console.log(res.statusCode) // 200
|
| 61 |
+
console.log(data) // Buffer('this is the server response')
|
| 62 |
+
})
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
### POST, PUT, PATCH, HEAD, DELETE support
|
| 66 |
+
|
| 67 |
+
For `POST`, call `get.post` or use option `{ method: 'POST' }`.
|
| 68 |
+
|
| 69 |
+
```js
|
| 70 |
+
const get = require('simple-get')
|
| 71 |
+
|
| 72 |
+
const opts = {
|
| 73 |
+
url: 'http://example.com',
|
| 74 |
+
body: 'this is the POST body'
|
| 75 |
+
}
|
| 76 |
+
get.post(opts, function (err, res) {
|
| 77 |
+
if (err) throw err
|
| 78 |
+
res.pipe(process.stdout) // `res` is a stream
|
| 79 |
+
})
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
#### A more complex example:
|
| 83 |
+
|
| 84 |
+
```js
|
| 85 |
+
const get = require('simple-get')
|
| 86 |
+
|
| 87 |
+
get({
|
| 88 |
+
url: 'http://example.com',
|
| 89 |
+
method: 'POST',
|
| 90 |
+
body: 'this is the POST body',
|
| 91 |
+
|
| 92 |
+
// simple-get accepts all options that node.js `http` accepts
|
| 93 |
+
// See: http://nodejs.org/api/http.html#http_http_request_options_callback
|
| 94 |
+
headers: {
|
| 95 |
+
'user-agent': 'my cool app'
|
| 96 |
+
}
|
| 97 |
+
}, function (err, res) {
|
| 98 |
+
if (err) throw err
|
| 99 |
+
|
| 100 |
+
// All properties/methods from http.IncomingResponse are available,
|
| 101 |
+
// even if a gunzip/inflate transform stream was returned.
|
| 102 |
+
// See: http://nodejs.org/api/http.html#http_http_incomingmessage
|
| 103 |
+
res.setTimeout(10000)
|
| 104 |
+
console.log(res.headers)
|
| 105 |
+
|
| 106 |
+
res.on('data', function (chunk) {
|
| 107 |
+
// `chunk` is the decoded response, after it's been gunzipped or inflated
|
| 108 |
+
// (if applicable)
|
| 109 |
+
console.log('got a chunk of the response: ' + chunk)
|
| 110 |
+
}))
|
| 111 |
+
|
| 112 |
+
})
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
### JSON
|
| 116 |
+
|
| 117 |
+
You can serialize/deserialize request and response with JSON:
|
| 118 |
+
|
| 119 |
+
```js
|
| 120 |
+
const get = require('simple-get')
|
| 121 |
+
|
| 122 |
+
const opts = {
|
| 123 |
+
method: 'POST',
|
| 124 |
+
url: 'http://example.com',
|
| 125 |
+
body: {
|
| 126 |
+
key: 'value'
|
| 127 |
+
},
|
| 128 |
+
json: true
|
| 129 |
+
}
|
| 130 |
+
get.concat(opts, function (err, res, data) {
|
| 131 |
+
if (err) throw err
|
| 132 |
+
console.log(data.key) // `data` is an object
|
| 133 |
+
})
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
### Timeout
|
| 137 |
+
|
| 138 |
+
You can set a timeout (in milliseconds) on the request with the `timeout` option.
|
| 139 |
+
If the request takes longer than `timeout` to complete, then the entire request
|
| 140 |
+
will fail with an `Error`.
|
| 141 |
+
|
| 142 |
+
```js
|
| 143 |
+
const get = require('simple-get')
|
| 144 |
+
|
| 145 |
+
const opts = {
|
| 146 |
+
url: 'http://example.com',
|
| 147 |
+
timeout: 2000 // 2 second timeout
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
get(opts, function (err, res) {})
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
### One Quick Tip
|
| 154 |
+
|
| 155 |
+
It's a good idea to set the `'user-agent'` header so the provider can more easily
|
| 156 |
+
see how their resource is used.
|
| 157 |
+
|
| 158 |
+
```js
|
| 159 |
+
const get = require('simple-get')
|
| 160 |
+
const pkg = require('./package.json')
|
| 161 |
+
|
| 162 |
+
get('http://example.com', {
|
| 163 |
+
headers: {
|
| 164 |
+
'user-agent': `my-module/${pkg.version} (https://github.com/username/my-module)`
|
| 165 |
+
}
|
| 166 |
+
})
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
### Proxies
|
| 170 |
+
|
| 171 |
+
You can use the [`tunnel`](https://github.com/koichik/node-tunnel) module with the
|
| 172 |
+
`agent` option to work with proxies:
|
| 173 |
+
|
| 174 |
+
```js
|
| 175 |
+
const get = require('simple-get')
|
| 176 |
+
const tunnel = require('tunnel')
|
| 177 |
+
|
| 178 |
+
const opts = {
|
| 179 |
+
url: 'http://example.com',
|
| 180 |
+
agent: tunnel.httpOverHttp({
|
| 181 |
+
proxy: {
|
| 182 |
+
host: 'localhost'
|
| 183 |
+
}
|
| 184 |
+
})
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
get(opts, function (err, res) {})
|
| 188 |
+
```
|
| 189 |
+
|
| 190 |
+
### Cookies
|
| 191 |
+
|
| 192 |
+
You can use the [`cookie`](https://github.com/jshttp/cookie) module to include
|
| 193 |
+
cookies in a request:
|
| 194 |
+
|
| 195 |
+
```js
|
| 196 |
+
const get = require('simple-get')
|
| 197 |
+
const cookie = require('cookie')
|
| 198 |
+
|
| 199 |
+
const opts = {
|
| 200 |
+
url: 'http://example.com',
|
| 201 |
+
headers: {
|
| 202 |
+
cookie: cookie.serialize('foo', 'bar')
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
get(opts, function (err, res) {})
|
| 207 |
+
```
|
| 208 |
+
|
| 209 |
+
### Form data
|
| 210 |
+
|
| 211 |
+
You can use the [`form-data`](https://github.com/form-data/form-data) module to
|
| 212 |
+
create POST request with form data:
|
| 213 |
+
|
| 214 |
+
```js
|
| 215 |
+
const fs = require('fs')
|
| 216 |
+
const get = require('simple-get')
|
| 217 |
+
const FormData = require('form-data')
|
| 218 |
+
const form = new FormData()
|
| 219 |
+
|
| 220 |
+
form.append('my_file', fs.createReadStream('/foo/bar.jpg'))
|
| 221 |
+
|
| 222 |
+
const opts = {
|
| 223 |
+
url: 'http://example.com',
|
| 224 |
+
body: form
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
get.post(opts, function (err, res) {})
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
#### Or, include `application/x-www-form-urlencoded` form data manually:
|
| 231 |
+
|
| 232 |
+
```js
|
| 233 |
+
const get = require('simple-get')
|
| 234 |
+
|
| 235 |
+
const opts = {
|
| 236 |
+
url: 'http://example.com',
|
| 237 |
+
form: {
|
| 238 |
+
key: 'value'
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
get.post(opts, function (err, res) {})
|
| 242 |
+
```
|
| 243 |
+
|
| 244 |
+
### Specifically disallowing redirects
|
| 245 |
+
|
| 246 |
+
```js
|
| 247 |
+
const get = require('simple-get')
|
| 248 |
+
|
| 249 |
+
const opts = {
|
| 250 |
+
url: 'http://example.com/will-redirect-elsewhere',
|
| 251 |
+
followRedirects: false
|
| 252 |
+
}
|
| 253 |
+
// res.statusCode will be 301, no error thrown
|
| 254 |
+
get(opts, function (err, res) {})
|
| 255 |
+
```
|
| 256 |
+
|
| 257 |
+
### Basic Auth
|
| 258 |
+
|
| 259 |
+
```js
|
| 260 |
+
const user = 'someuser'
|
| 261 |
+
const pass = 'pa$$word'
|
| 262 |
+
const encodedAuth = Buffer.from(`${user}:${pass}`).toString('base64')
|
| 263 |
+
|
| 264 |
+
get('http://example.com', {
|
| 265 |
+
headers: {
|
| 266 |
+
authorization: `Basic ${encodedAuth}`
|
| 267 |
+
}
|
| 268 |
+
})
|
| 269 |
+
```
|
| 270 |
+
|
| 271 |
+
### OAuth
|
| 272 |
+
|
| 273 |
+
You can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) module to create
|
| 274 |
+
a signed OAuth request:
|
| 275 |
+
|
| 276 |
+
```js
|
| 277 |
+
const get = require('simple-get')
|
| 278 |
+
const crypto = require('crypto')
|
| 279 |
+
const OAuth = require('oauth-1.0a')
|
| 280 |
+
|
| 281 |
+
const oauth = OAuth({
|
| 282 |
+
consumer: {
|
| 283 |
+
key: process.env.CONSUMER_KEY,
|
| 284 |
+
secret: process.env.CONSUMER_SECRET
|
| 285 |
+
},
|
| 286 |
+
signature_method: 'HMAC-SHA1',
|
| 287 |
+
hash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64')
|
| 288 |
+
})
|
| 289 |
+
|
| 290 |
+
const token = {
|
| 291 |
+
key: process.env.ACCESS_TOKEN,
|
| 292 |
+
secret: process.env.ACCESS_TOKEN_SECRET
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
const url = 'https://api.twitter.com/1.1/statuses/home_timeline.json'
|
| 296 |
+
|
| 297 |
+
const opts = {
|
| 298 |
+
url: url,
|
| 299 |
+
headers: oauth.toHeader(oauth.authorize({url, method: 'GET'}, token)),
|
| 300 |
+
json: true
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
get(opts, function (err, res) {})
|
| 304 |
+
```
|
| 305 |
+
|
| 306 |
+
### Throttle requests
|
| 307 |
+
|
| 308 |
+
You can use [limiter](https://github.com/jhurliman/node-rate-limiter) to throttle requests. This is useful when calling an API that is rate limited.
|
| 309 |
+
|
| 310 |
+
```js
|
| 311 |
+
const simpleGet = require('simple-get')
|
| 312 |
+
const RateLimiter = require('limiter').RateLimiter
|
| 313 |
+
const limiter = new RateLimiter(1, 'second')
|
| 314 |
+
|
| 315 |
+
const get = (opts, cb) => limiter.removeTokens(1, () => simpleGet(opts, cb))
|
| 316 |
+
get.concat = (opts, cb) => limiter.removeTokens(1, () => simpleGet.concat(opts, cb))
|
| 317 |
+
|
| 318 |
+
var opts = {
|
| 319 |
+
url: 'http://example.com'
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
get.concat(opts, processResult)
|
| 323 |
+
get.concat(opts, processResult)
|
| 324 |
+
|
| 325 |
+
function processResult (err, res, data) {
|
| 326 |
+
if (err) throw err
|
| 327 |
+
console.log(data.toString())
|
| 328 |
+
}
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
## license
|
| 332 |
+
|
| 333 |
+
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
|
node_modules/simple-get/index.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*! simple-get. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
| 2 |
+
module.exports = simpleGet
|
| 3 |
+
|
| 4 |
+
const concat = require('simple-concat')
|
| 5 |
+
const decompressResponse = require('decompress-response') // excluded from browser build
|
| 6 |
+
const http = require('http')
|
| 7 |
+
const https = require('https')
|
| 8 |
+
const once = require('once')
|
| 9 |
+
const querystring = require('querystring')
|
| 10 |
+
const url = require('url')
|
| 11 |
+
|
| 12 |
+
const isStream = o => o !== null && typeof o === 'object' && typeof o.pipe === 'function'
|
| 13 |
+
|
| 14 |
+
function simpleGet (opts, cb) {
|
| 15 |
+
opts = Object.assign({ maxRedirects: 10 }, typeof opts === 'string' ? { url: opts } : opts)
|
| 16 |
+
cb = once(cb)
|
| 17 |
+
|
| 18 |
+
if (opts.url) {
|
| 19 |
+
const { hostname, port, protocol, auth, path } = url.parse(opts.url) // eslint-disable-line node/no-deprecated-api
|
| 20 |
+
delete opts.url
|
| 21 |
+
if (!hostname && !port && !protocol && !auth) opts.path = path // Relative redirect
|
| 22 |
+
else Object.assign(opts, { hostname, port, protocol, auth, path }) // Absolute redirect
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
const headers = { 'accept-encoding': 'gzip, deflate' }
|
| 26 |
+
if (opts.headers) Object.keys(opts.headers).forEach(k => (headers[k.toLowerCase()] = opts.headers[k]))
|
| 27 |
+
opts.headers = headers
|
| 28 |
+
|
| 29 |
+
let body
|
| 30 |
+
if (opts.body) {
|
| 31 |
+
body = opts.json && !isStream(opts.body) ? JSON.stringify(opts.body) : opts.body
|
| 32 |
+
} else if (opts.form) {
|
| 33 |
+
body = typeof opts.form === 'string' ? opts.form : querystring.stringify(opts.form)
|
| 34 |
+
opts.headers['content-type'] = 'application/x-www-form-urlencoded'
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
if (body) {
|
| 38 |
+
if (!opts.method) opts.method = 'POST'
|
| 39 |
+
if (!isStream(body)) opts.headers['content-length'] = Buffer.byteLength(body)
|
| 40 |
+
if (opts.json && !opts.form) opts.headers['content-type'] = 'application/json'
|
| 41 |
+
}
|
| 42 |
+
delete opts.body; delete opts.form
|
| 43 |
+
|
| 44 |
+
if (opts.json) opts.headers.accept = 'application/json'
|
| 45 |
+
if (opts.method) opts.method = opts.method.toUpperCase()
|
| 46 |
+
|
| 47 |
+
const originalHost = opts.hostname // hostname before potential redirect
|
| 48 |
+
const protocol = opts.protocol === 'https:' ? https : http // Support http/https urls
|
| 49 |
+
const req = protocol.request(opts, res => {
|
| 50 |
+
if (opts.followRedirects !== false && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
| 51 |
+
opts.url = res.headers.location // Follow 3xx redirects
|
| 52 |
+
delete opts.headers.host // Discard `host` header on redirect (see #32)
|
| 53 |
+
res.resume() // Discard response
|
| 54 |
+
|
| 55 |
+
const redirectHost = url.parse(opts.url).hostname // eslint-disable-line node/no-deprecated-api
|
| 56 |
+
// If redirected host is different than original host, drop headers to prevent cookie leak (#73)
|
| 57 |
+
if (redirectHost !== null && redirectHost !== originalHost) {
|
| 58 |
+
delete opts.headers.cookie
|
| 59 |
+
delete opts.headers.authorization
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
if (opts.method === 'POST' && [301, 302].includes(res.statusCode)) {
|
| 63 |
+
opts.method = 'GET' // On 301/302 redirect, change POST to GET (see #35)
|
| 64 |
+
delete opts.headers['content-length']; delete opts.headers['content-type']
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
if (opts.maxRedirects-- === 0) return cb(new Error('too many redirects'))
|
| 68 |
+
else return simpleGet(opts, cb)
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
const tryUnzip = typeof decompressResponse === 'function' && opts.method !== 'HEAD'
|
| 72 |
+
cb(null, tryUnzip ? decompressResponse(res) : res)
|
| 73 |
+
})
|
| 74 |
+
req.on('timeout', () => {
|
| 75 |
+
req.abort()
|
| 76 |
+
cb(new Error('Request timed out'))
|
| 77 |
+
})
|
| 78 |
+
req.on('error', cb)
|
| 79 |
+
|
| 80 |
+
if (isStream(body)) body.on('error', cb).pipe(req)
|
| 81 |
+
else req.end(body)
|
| 82 |
+
|
| 83 |
+
return req
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
simpleGet.concat = (opts, cb) => {
|
| 87 |
+
return simpleGet(opts, (err, res) => {
|
| 88 |
+
if (err) return cb(err)
|
| 89 |
+
concat(res, (err, data) => {
|
| 90 |
+
if (err) return cb(err)
|
| 91 |
+
if (opts.json) {
|
| 92 |
+
try {
|
| 93 |
+
data = JSON.parse(data.toString())
|
| 94 |
+
} catch (err) {
|
| 95 |
+
return cb(err, res, data)
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
cb(null, res, data)
|
| 99 |
+
})
|
| 100 |
+
})
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
;['get', 'post', 'put', 'patch', 'head', 'delete'].forEach(method => {
|
| 104 |
+
simpleGet[method] = (opts, cb) => {
|
| 105 |
+
if (typeof opts === 'string') opts = { url: opts }
|
| 106 |
+
return simpleGet(Object.assign({ method: method.toUpperCase() }, opts), cb)
|
| 107 |
+
}
|
| 108 |
+
})
|
node_modules/simple-get/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "simple-get",
|
| 3 |
+
"description": "Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines.",
|
| 4 |
+
"version": "4.0.1",
|
| 5 |
+
"author": {
|
| 6 |
+
"name": "Feross Aboukhadijeh",
|
| 7 |
+
"email": "feross@feross.org",
|
| 8 |
+
"url": "https://feross.org"
|
| 9 |
+
},
|
| 10 |
+
"browser": {
|
| 11 |
+
"decompress-response": false
|
| 12 |
+
},
|
| 13 |
+
"bugs": {
|
| 14 |
+
"url": "https://github.com/feross/simple-get/issues"
|
| 15 |
+
},
|
| 16 |
+
"dependencies": {
|
| 17 |
+
"decompress-response": "^6.0.0",
|
| 18 |
+
"once": "^1.3.1",
|
| 19 |
+
"simple-concat": "^1.0.0"
|
| 20 |
+
},
|
| 21 |
+
"devDependencies": {
|
| 22 |
+
"self-signed-https": "^1.0.5",
|
| 23 |
+
"standard": "*",
|
| 24 |
+
"string-to-stream": "^3.0.0",
|
| 25 |
+
"tape": "^5.0.0"
|
| 26 |
+
},
|
| 27 |
+
"homepage": "https://github.com/feross/simple-get",
|
| 28 |
+
"keywords": [
|
| 29 |
+
"request",
|
| 30 |
+
"http",
|
| 31 |
+
"GET",
|
| 32 |
+
"get request",
|
| 33 |
+
"http.get",
|
| 34 |
+
"redirects",
|
| 35 |
+
"follow redirects",
|
| 36 |
+
"gzip",
|
| 37 |
+
"deflate",
|
| 38 |
+
"https",
|
| 39 |
+
"http-https",
|
| 40 |
+
"stream",
|
| 41 |
+
"simple request",
|
| 42 |
+
"simple get"
|
| 43 |
+
],
|
| 44 |
+
"license": "MIT",
|
| 45 |
+
"main": "index.js",
|
| 46 |
+
"repository": {
|
| 47 |
+
"type": "git",
|
| 48 |
+
"url": "git://github.com/feross/simple-get.git"
|
| 49 |
+
},
|
| 50 |
+
"scripts": {
|
| 51 |
+
"test": "standard && tape test/*.js"
|
| 52 |
+
},
|
| 53 |
+
"funding": [
|
| 54 |
+
{
|
| 55 |
+
"type": "github",
|
| 56 |
+
"url": "https://github.com/sponsors/feross"
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"type": "patreon",
|
| 60 |
+
"url": "https://www.patreon.com/feross"
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"type": "consulting",
|
| 64 |
+
"url": "https://feross.org/support"
|
| 65 |
+
}
|
| 66 |
+
]
|
| 67 |
+
}
|
node_modules/simple-update-notifier/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2022 Alex Brazier
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
node_modules/simple-update-notifier/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# simple-update-notifier [](https://github.com/alexbrazier/simple-update-notifier/stargazers)
|
| 2 |
+
|
| 3 |
+
[](https://github.com/alexbrazier/simple-update-notifier/actions)
|
| 4 |
+
[](https://www.npmjs.com/package/simple-update-notifier?activeTab=dependencies)
|
| 5 |
+
[](https://www.npmjs.com/package/simple-update-notifier)
|
| 6 |
+
[](https://bundlephobia.com/result?p=simple-update-notifier)
|
| 7 |
+
[](https://www.npmjs.com/package/simple-update-notifier)
|
| 8 |
+
[](./LICENSE)
|
| 9 |
+
|
| 10 |
+
Simple update notifier to check for npm updates for cli applications.
|
| 11 |
+
|
| 12 |
+
<img src="./.github/demo.png" alt="Demo in terminal showing an update is required">
|
| 13 |
+
|
| 14 |
+
Checks for updates for an npm module and outputs to the command line if there is one available. The result is cached for the specified time so it doesn't check every time the app runs.
|
| 15 |
+
|
| 16 |
+
## Install
|
| 17 |
+
|
| 18 |
+
```bash
|
| 19 |
+
npm install simple-update-notifier
|
| 20 |
+
OR
|
| 21 |
+
yarn add simple-update-notifier
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## Usage
|
| 25 |
+
|
| 26 |
+
```js
|
| 27 |
+
import updateNotifier from 'simple-update-notifier';
|
| 28 |
+
import packageJson from './package.json' assert { type: 'json' };
|
| 29 |
+
|
| 30 |
+
updateNotifier({ pkg: packageJson });
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
### Options
|
| 34 |
+
|
| 35 |
+
#### pkg
|
| 36 |
+
|
| 37 |
+
Type: `object`
|
| 38 |
+
|
| 39 |
+
##### name
|
| 40 |
+
|
| 41 |
+
_Required_\
|
| 42 |
+
Type: `string`
|
| 43 |
+
|
| 44 |
+
##### version
|
| 45 |
+
|
| 46 |
+
_Required_\
|
| 47 |
+
Type: `string`
|
| 48 |
+
|
| 49 |
+
#### updateCheckInterval
|
| 50 |
+
|
| 51 |
+
Type: `number`\
|
| 52 |
+
Default: `1000 * 60 * 60 * 24` _(1 day)_
|
| 53 |
+
|
| 54 |
+
How often to check for updates.
|
| 55 |
+
|
| 56 |
+
#### shouldNotifyInNpmScript
|
| 57 |
+
|
| 58 |
+
Type: `boolean`\
|
| 59 |
+
Default: `false`
|
| 60 |
+
|
| 61 |
+
Allows notification to be shown when running as an npm script.
|
| 62 |
+
|
| 63 |
+
#### distTag
|
| 64 |
+
|
| 65 |
+
Type: `string`\
|
| 66 |
+
Default: `'latest'`
|
| 67 |
+
|
| 68 |
+
Which [dist-tag](https://docs.npmjs.com/adding-dist-tags-to-packages) to use to find the latest version.
|
| 69 |
+
|
| 70 |
+
#### alwaysRun
|
| 71 |
+
|
| 72 |
+
Type: `boolean`\
|
| 73 |
+
Default: `false`
|
| 74 |
+
|
| 75 |
+
When set, `updateCheckInterval` will not be respected and a check for an update will always be performed.
|
| 76 |
+
|
| 77 |
+
#### debug
|
| 78 |
+
|
| 79 |
+
Type: `boolean`\
|
| 80 |
+
Default: `false`
|
| 81 |
+
|
| 82 |
+
When set, logs explaining the decision will be output to `stderr` whenever the module opts to not print an update notification
|
node_modules/simple-update-notifier/build/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
interface IUpdate {
|
| 2 |
+
pkg: {
|
| 3 |
+
name: string;
|
| 4 |
+
version: string;
|
| 5 |
+
};
|
| 6 |
+
updateCheckInterval?: number;
|
| 7 |
+
shouldNotifyInNpmScript?: boolean;
|
| 8 |
+
distTag?: string;
|
| 9 |
+
alwaysRun?: boolean;
|
| 10 |
+
debug?: boolean;
|
| 11 |
+
}
|
| 12 |
+
declare const simpleUpdateNotifier: (args: IUpdate) => Promise<void>;
|
| 13 |
+
export { simpleUpdateNotifier as default };
|
node_modules/simple-update-notifier/build/index.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var process$1 = require('process');
|
| 4 |
+
var semver = require('semver');
|
| 5 |
+
var os = require('os');
|
| 6 |
+
var path = require('path');
|
| 7 |
+
var fs = require('fs');
|
| 8 |
+
var https = require('https');
|
| 9 |
+
|
| 10 |
+
/******************************************************************************
|
| 11 |
+
Copyright (c) Microsoft Corporation.
|
| 12 |
+
|
| 13 |
+
Permission to use, copy, modify, and/or distribute this software for any
|
| 14 |
+
purpose with or without fee is hereby granted.
|
| 15 |
+
|
| 16 |
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
| 17 |
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
| 18 |
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
| 19 |
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
| 20 |
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
| 21 |
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
| 22 |
+
PERFORMANCE OF THIS SOFTWARE.
|
| 23 |
+
***************************************************************************** */
|
| 24 |
+
/* global Reflect, Promise */
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
function __awaiter(thisArg, _arguments, P, generator) {
|
| 28 |
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
| 29 |
+
return new (P || (P = Promise))(function (resolve, reject) {
|
| 30 |
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
| 31 |
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
| 32 |
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
| 33 |
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
| 34 |
+
});
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function __generator(thisArg, body) {
|
| 38 |
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
| 39 |
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
| 40 |
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
| 41 |
+
function step(op) {
|
| 42 |
+
if (f) throw new TypeError("Generator is already executing.");
|
| 43 |
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
| 44 |
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
| 45 |
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
| 46 |
+
switch (op[0]) {
|
| 47 |
+
case 0: case 1: t = op; break;
|
| 48 |
+
case 4: _.label++; return { value: op[1], done: false };
|
| 49 |
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
| 50 |
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
| 51 |
+
default:
|
| 52 |
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
| 53 |
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
| 54 |
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
| 55 |
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
| 56 |
+
if (t[2]) _.ops.pop();
|
| 57 |
+
_.trys.pop(); continue;
|
| 58 |
+
}
|
| 59 |
+
op = body.call(thisArg, _);
|
| 60 |
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
| 61 |
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
var packageJson = process$1.env.npm_package_json;
|
| 66 |
+
var userAgent = process$1.env.npm_config_user_agent;
|
| 67 |
+
var isNpm6 = Boolean(userAgent && userAgent.startsWith('npm'));
|
| 68 |
+
var isNpm7 = Boolean(packageJson && packageJson.endsWith('package.json'));
|
| 69 |
+
var isNpm = isNpm6 || isNpm7;
|
| 70 |
+
var isYarn = Boolean(userAgent && userAgent.startsWith('yarn'));
|
| 71 |
+
var isNpmOrYarn = isNpm || isYarn;
|
| 72 |
+
|
| 73 |
+
var homeDirectory = os.homedir();
|
| 74 |
+
var configDir = process.env.XDG_CONFIG_HOME ||
|
| 75 |
+
path.join(homeDirectory, '.config', 'simple-update-notifier');
|
| 76 |
+
var getConfigFile = function (packageName) {
|
| 77 |
+
return path.join(configDir, "".concat(packageName.replace('@', '').replace('/', '__'), ".json"));
|
| 78 |
+
};
|
| 79 |
+
var createConfigDir = function () {
|
| 80 |
+
if (!fs.existsSync(configDir)) {
|
| 81 |
+
fs.mkdirSync(configDir, { recursive: true });
|
| 82 |
+
}
|
| 83 |
+
};
|
| 84 |
+
var getLastUpdate = function (packageName) {
|
| 85 |
+
var configFile = getConfigFile(packageName);
|
| 86 |
+
try {
|
| 87 |
+
if (!fs.existsSync(configFile)) {
|
| 88 |
+
return undefined;
|
| 89 |
+
}
|
| 90 |
+
var file = JSON.parse(fs.readFileSync(configFile, 'utf8'));
|
| 91 |
+
return file.lastUpdateCheck;
|
| 92 |
+
}
|
| 93 |
+
catch (_a) {
|
| 94 |
+
return undefined;
|
| 95 |
+
}
|
| 96 |
+
};
|
| 97 |
+
var saveLastUpdate = function (packageName) {
|
| 98 |
+
var configFile = getConfigFile(packageName);
|
| 99 |
+
fs.writeFileSync(configFile, JSON.stringify({ lastUpdateCheck: new Date().getTime() }));
|
| 100 |
+
};
|
| 101 |
+
|
| 102 |
+
var getDistVersion = function (packageName, distTag) { return __awaiter(void 0, void 0, void 0, function () {
|
| 103 |
+
var url;
|
| 104 |
+
return __generator(this, function (_a) {
|
| 105 |
+
url = "https://registry.npmjs.org/-/package/".concat(packageName, "/dist-tags");
|
| 106 |
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
| 107 |
+
https
|
| 108 |
+
.get(url, function (res) {
|
| 109 |
+
var body = '';
|
| 110 |
+
res.on('data', function (chunk) { return (body += chunk); });
|
| 111 |
+
res.on('end', function () {
|
| 112 |
+
try {
|
| 113 |
+
var json = JSON.parse(body);
|
| 114 |
+
var version = json[distTag];
|
| 115 |
+
if (!version) {
|
| 116 |
+
reject(new Error('Error getting version'));
|
| 117 |
+
}
|
| 118 |
+
resolve(version);
|
| 119 |
+
}
|
| 120 |
+
catch (_a) {
|
| 121 |
+
reject(new Error('Could not parse version response'));
|
| 122 |
+
}
|
| 123 |
+
});
|
| 124 |
+
})
|
| 125 |
+
.on('error', function (err) { return reject(err); });
|
| 126 |
+
})];
|
| 127 |
+
});
|
| 128 |
+
}); };
|
| 129 |
+
|
| 130 |
+
var hasNewVersion = function (_a) {
|
| 131 |
+
var pkg = _a.pkg, _b = _a.updateCheckInterval, updateCheckInterval = _b === void 0 ? 1000 * 60 * 60 * 24 : _b, _c = _a.distTag, distTag = _c === void 0 ? 'latest' : _c, alwaysRun = _a.alwaysRun, debug = _a.debug;
|
| 132 |
+
return __awaiter(void 0, void 0, void 0, function () {
|
| 133 |
+
var lastUpdateCheck, latestVersion;
|
| 134 |
+
return __generator(this, function (_d) {
|
| 135 |
+
switch (_d.label) {
|
| 136 |
+
case 0:
|
| 137 |
+
createConfigDir();
|
| 138 |
+
lastUpdateCheck = getLastUpdate(pkg.name);
|
| 139 |
+
if (!(alwaysRun ||
|
| 140 |
+
!lastUpdateCheck ||
|
| 141 |
+
lastUpdateCheck < new Date().getTime() - updateCheckInterval)) return [3 /*break*/, 2];
|
| 142 |
+
return [4 /*yield*/, getDistVersion(pkg.name, distTag)];
|
| 143 |
+
case 1:
|
| 144 |
+
latestVersion = _d.sent();
|
| 145 |
+
saveLastUpdate(pkg.name);
|
| 146 |
+
if (semver.gt(latestVersion, pkg.version)) {
|
| 147 |
+
return [2 /*return*/, latestVersion];
|
| 148 |
+
}
|
| 149 |
+
else if (debug) {
|
| 150 |
+
console.error("Latest version (".concat(latestVersion, ") not newer than current version (").concat(pkg.version, ")"));
|
| 151 |
+
}
|
| 152 |
+
return [3 /*break*/, 3];
|
| 153 |
+
case 2:
|
| 154 |
+
if (debug) {
|
| 155 |
+
console.error("Too recent to check for a new update. simpleUpdateNotifier() interval set to ".concat(updateCheckInterval, "ms but only ").concat(new Date().getTime() - lastUpdateCheck, "ms since last check."));
|
| 156 |
+
}
|
| 157 |
+
_d.label = 3;
|
| 158 |
+
case 3: return [2 /*return*/, false];
|
| 159 |
+
}
|
| 160 |
+
});
|
| 161 |
+
});
|
| 162 |
+
};
|
| 163 |
+
|
| 164 |
+
var borderedText = function (text) {
|
| 165 |
+
var lines = text.split('\n');
|
| 166 |
+
var width = Math.max.apply(Math, lines.map(function (l) { return l.length; }));
|
| 167 |
+
var res = ["\u250C".concat('─'.repeat(width + 2), "\u2510")];
|
| 168 |
+
for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
|
| 169 |
+
var line = lines_1[_i];
|
| 170 |
+
res.push("\u2502 ".concat(line.padEnd(width), " \u2502"));
|
| 171 |
+
}
|
| 172 |
+
res.push("\u2514".concat('─'.repeat(width + 2), "\u2518"));
|
| 173 |
+
return res.join('\n');
|
| 174 |
+
};
|
| 175 |
+
|
| 176 |
+
var simpleUpdateNotifier = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
| 177 |
+
var latestVersion, err_1;
|
| 178 |
+
return __generator(this, function (_a) {
|
| 179 |
+
switch (_a.label) {
|
| 180 |
+
case 0:
|
| 181 |
+
if (!args.alwaysRun &&
|
| 182 |
+
(!process.stdout.isTTY || (isNpmOrYarn && !args.shouldNotifyInNpmScript))) {
|
| 183 |
+
if (args.debug) {
|
| 184 |
+
console.error('Opting out of running simpleUpdateNotifier()');
|
| 185 |
+
}
|
| 186 |
+
return [2 /*return*/];
|
| 187 |
+
}
|
| 188 |
+
_a.label = 1;
|
| 189 |
+
case 1:
|
| 190 |
+
_a.trys.push([1, 3, , 4]);
|
| 191 |
+
return [4 /*yield*/, hasNewVersion(args)];
|
| 192 |
+
case 2:
|
| 193 |
+
latestVersion = _a.sent();
|
| 194 |
+
if (latestVersion) {
|
| 195 |
+
console.error(borderedText("New version of ".concat(args.pkg.name, " available!\nCurrent Version: ").concat(args.pkg.version, "\nLatest Version: ").concat(latestVersion)));
|
| 196 |
+
}
|
| 197 |
+
return [3 /*break*/, 4];
|
| 198 |
+
case 3:
|
| 199 |
+
err_1 = _a.sent();
|
| 200 |
+
// Catch any network errors or cache writing errors so module doesn't cause a crash
|
| 201 |
+
if (args.debug && err_1 instanceof Error) {
|
| 202 |
+
console.error('Unexpected error in simpleUpdateNotifier():', err_1);
|
| 203 |
+
}
|
| 204 |
+
return [3 /*break*/, 4];
|
| 205 |
+
case 4: return [2 /*return*/];
|
| 206 |
+
}
|
| 207 |
+
});
|
| 208 |
+
}); };
|
| 209 |
+
|
| 210 |
+
module.exports = simpleUpdateNotifier;
|
node_modules/simple-update-notifier/package.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "simple-update-notifier",
|
| 3 |
+
"version": "2.0.0",
|
| 4 |
+
"description": "Simple update notifier to check for npm updates for cli applications",
|
| 5 |
+
"main": "build/index.js",
|
| 6 |
+
"types": "build/index.d.ts",
|
| 7 |
+
"repository": {
|
| 8 |
+
"type": "git",
|
| 9 |
+
"url": "https://github.com/alexbrazier/simple-update-notifier.git"
|
| 10 |
+
},
|
| 11 |
+
"homepage": "https://github.com/alexbrazier/simple-update-notifier.git",
|
| 12 |
+
"author": "alexbrazier",
|
| 13 |
+
"license": "MIT",
|
| 14 |
+
"engines": {
|
| 15 |
+
"node": ">=10"
|
| 16 |
+
},
|
| 17 |
+
"scripts": {
|
| 18 |
+
"test": "jest src --noStackTrace",
|
| 19 |
+
"build": "rollup -c rollup.config.js --bundleConfigAsCjs",
|
| 20 |
+
"prettier:check": "prettier --check src/**/*.ts",
|
| 21 |
+
"prettier": "prettier --write src/**/*.ts",
|
| 22 |
+
"eslint": "eslint src/**/*.ts",
|
| 23 |
+
"lint": "yarn prettier:check && yarn eslint",
|
| 24 |
+
"prepare": "yarn lint && yarn build",
|
| 25 |
+
"release": "release-it"
|
| 26 |
+
},
|
| 27 |
+
"dependencies": {
|
| 28 |
+
"semver": "^7.5.3"
|
| 29 |
+
},
|
| 30 |
+
"devDependencies": {
|
| 31 |
+
"@babel/preset-env": "^7.22.5",
|
| 32 |
+
"@babel/preset-typescript": "^7.22.5",
|
| 33 |
+
"@release-it/conventional-changelog": "^5.1.1",
|
| 34 |
+
"@types/jest": "^29.5.2",
|
| 35 |
+
"@types/node": "^20.3.1",
|
| 36 |
+
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
| 37 |
+
"@typescript-eslint/parser": "^5.60.0",
|
| 38 |
+
"eslint": "^8.43.0",
|
| 39 |
+
"eslint-config-prettier": "^8.8.0",
|
| 40 |
+
"eslint-plugin-prettier": "^4.0.0",
|
| 41 |
+
"jest": "^29.5.0",
|
| 42 |
+
"prettier": "^2.8.8",
|
| 43 |
+
"release-it": "^15.11.0",
|
| 44 |
+
"rollup": "^3.25.2",
|
| 45 |
+
"rollup-plugin-ts": "^3.2.0",
|
| 46 |
+
"typescript": "^5.1.3"
|
| 47 |
+
},
|
| 48 |
+
"resolutions": {
|
| 49 |
+
"semver": "^7.5.3"
|
| 50 |
+
},
|
| 51 |
+
"publishConfig": {
|
| 52 |
+
"registry": "https://registry.npmjs.org/"
|
| 53 |
+
},
|
| 54 |
+
"files": [
|
| 55 |
+
"build",
|
| 56 |
+
"src"
|
| 57 |
+
],
|
| 58 |
+
"release-it": {
|
| 59 |
+
"git": {
|
| 60 |
+
"commitMessage": "chore: release ${version}",
|
| 61 |
+
"tagName": "v${version}"
|
| 62 |
+
},
|
| 63 |
+
"npm": {
|
| 64 |
+
"publish": true
|
| 65 |
+
},
|
| 66 |
+
"github": {
|
| 67 |
+
"release": true
|
| 68 |
+
},
|
| 69 |
+
"plugins": {
|
| 70 |
+
"@release-it/conventional-changelog": {
|
| 71 |
+
"preset": "angular",
|
| 72 |
+
"infile": "CHANGELOG.md"
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
},
|
| 76 |
+
"eslintConfig": {
|
| 77 |
+
"plugins": [
|
| 78 |
+
"@typescript-eslint",
|
| 79 |
+
"prettier"
|
| 80 |
+
],
|
| 81 |
+
"extends": [
|
| 82 |
+
"prettier",
|
| 83 |
+
"eslint:recommended",
|
| 84 |
+
"plugin:@typescript-eslint/recommended"
|
| 85 |
+
],
|
| 86 |
+
"parser": "@typescript-eslint/parser",
|
| 87 |
+
"rules": {
|
| 88 |
+
"prettier/prettier": [
|
| 89 |
+
"error",
|
| 90 |
+
{
|
| 91 |
+
"quoteProps": "consistent",
|
| 92 |
+
"singleQuote": true,
|
| 93 |
+
"tabWidth": 2,
|
| 94 |
+
"trailingComma": "es5",
|
| 95 |
+
"useTabs": false
|
| 96 |
+
}
|
| 97 |
+
]
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
}
|
node_modules/simple-update-notifier/src/borderedText.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const borderedText = (text: string) => {
|
| 2 |
+
const lines = text.split('\n');
|
| 3 |
+
const width = Math.max(...lines.map((l) => l.length));
|
| 4 |
+
const res = [`┌${'─'.repeat(width + 2)}┐`];
|
| 5 |
+
for (const line of lines) {
|
| 6 |
+
res.push(`│ ${line.padEnd(width)} │`);
|
| 7 |
+
}
|
| 8 |
+
res.push(`└${'─'.repeat(width + 2)}┘`);
|
| 9 |
+
return res.join('\n');
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
export default borderedText;
|
node_modules/simple-update-notifier/src/cache.spec.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { createConfigDir, getLastUpdate, saveLastUpdate } from './cache';
|
| 2 |
+
|
| 3 |
+
createConfigDir();
|
| 4 |
+
|
| 5 |
+
jest.useFakeTimers().setSystemTime(new Date('2022-01-01'));
|
| 6 |
+
|
| 7 |
+
const fakeTime = new Date('2022-01-01').getTime();
|
| 8 |
+
|
| 9 |
+
test('can save update then get the update details', () => {
|
| 10 |
+
saveLastUpdate('test');
|
| 11 |
+
expect(getLastUpdate('test')).toBe(fakeTime);
|
| 12 |
+
});
|
| 13 |
+
|
| 14 |
+
test('prefixed module can save update then get the update details', () => {
|
| 15 |
+
saveLastUpdate('@alexbrazier/test');
|
| 16 |
+
expect(getLastUpdate('@alexbrazier/test')).toBe(fakeTime);
|
| 17 |
+
});
|
node_modules/simple-update-notifier/src/cache.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os from 'os';
|
| 2 |
+
import path from 'path';
|
| 3 |
+
import fs from 'fs';
|
| 4 |
+
|
| 5 |
+
const homeDirectory = os.homedir();
|
| 6 |
+
const configDir =
|
| 7 |
+
process.env.XDG_CONFIG_HOME ||
|
| 8 |
+
path.join(homeDirectory, '.config', 'simple-update-notifier');
|
| 9 |
+
|
| 10 |
+
const getConfigFile = (packageName: string) => {
|
| 11 |
+
return path.join(
|
| 12 |
+
configDir,
|
| 13 |
+
`${packageName.replace('@', '').replace('/', '__')}.json`
|
| 14 |
+
);
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
export const createConfigDir = () => {
|
| 18 |
+
if (!fs.existsSync(configDir)) {
|
| 19 |
+
fs.mkdirSync(configDir, { recursive: true });
|
| 20 |
+
}
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
export const getLastUpdate = (packageName: string) => {
|
| 24 |
+
const configFile = getConfigFile(packageName);
|
| 25 |
+
|
| 26 |
+
try {
|
| 27 |
+
if (!fs.existsSync(configFile)) {
|
| 28 |
+
return undefined;
|
| 29 |
+
}
|
| 30 |
+
const file = JSON.parse(fs.readFileSync(configFile, 'utf8'));
|
| 31 |
+
return file.lastUpdateCheck as number;
|
| 32 |
+
} catch {
|
| 33 |
+
return undefined;
|
| 34 |
+
}
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
export const saveLastUpdate = (packageName: string) => {
|
| 38 |
+
const configFile = getConfigFile(packageName);
|
| 39 |
+
|
| 40 |
+
fs.writeFileSync(
|
| 41 |
+
configFile,
|
| 42 |
+
JSON.stringify({ lastUpdateCheck: new Date().getTime() })
|
| 43 |
+
);
|
| 44 |
+
};
|
node_modules/simple-update-notifier/src/getDistVersion.spec.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Stream from 'stream';
|
| 2 |
+
import https from 'https';
|
| 3 |
+
import getDistVersion from './getDistVersion';
|
| 4 |
+
|
| 5 |
+
jest.mock('https', () => ({
|
| 6 |
+
get: jest.fn(),
|
| 7 |
+
}));
|
| 8 |
+
|
| 9 |
+
test('Valid response returns version', async () => {
|
| 10 |
+
const st = new Stream();
|
| 11 |
+
(https.get as jest.Mock).mockImplementation((url, cb) => {
|
| 12 |
+
cb(st);
|
| 13 |
+
|
| 14 |
+
st.emit('data', '{"latest":"1.0.0"}');
|
| 15 |
+
st.emit('end');
|
| 16 |
+
});
|
| 17 |
+
|
| 18 |
+
const version = await getDistVersion('test', 'latest');
|
| 19 |
+
|
| 20 |
+
expect(version).toEqual('1.0.0');
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
test('Invalid response throws error', async () => {
|
| 24 |
+
const st = new Stream();
|
| 25 |
+
(https.get as jest.Mock).mockImplementation((url, cb) => {
|
| 26 |
+
cb(st);
|
| 27 |
+
|
| 28 |
+
st.emit('data', 'some invalid json');
|
| 29 |
+
st.emit('end');
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
+
expect(getDistVersion('test', 'latest')).rejects.toThrow(
|
| 33 |
+
'Could not parse version response'
|
| 34 |
+
);
|
| 35 |
+
});
|