cdk-common 2.0.1040 → 2.0.1041
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +8 -2
- package/API.md +6 -0
- package/lib/main.js +1 -1
- package/lib/managed-policies.d.ts +2 -1
- package/lib/managed-policies.js +2 -1
- package/node_modules/@types/concat-stream/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/concat-stream/node_modules/@types/node/package.json +2 -7
- package/node_modules/@types/form-data/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/form-data/node_modules/@types/node/package.json +2 -7
- package/node_modules/call-bound/.eslintrc +13 -0
- package/node_modules/call-bound/.github/FUNDING.yml +12 -0
- package/node_modules/call-bound/.nycrc +9 -0
- package/node_modules/call-bound/CHANGELOG.md +25 -0
- package/node_modules/call-bound/LICENSE +21 -0
- package/node_modules/call-bound/README.md +53 -0
- package/node_modules/call-bound/index.d.ts +5 -0
- package/node_modules/call-bound/index.js +18 -0
- package/node_modules/call-bound/package.json +98 -0
- package/node_modules/call-bound/test/index.js +54 -0
- package/node_modules/call-bound/tsconfig.json +9 -0
- package/node_modules/es-object-atoms/.eslintrc +16 -0
- package/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
- package/node_modules/es-object-atoms/CHANGELOG.md +16 -0
- package/node_modules/es-object-atoms/LICENSE +21 -0
- package/node_modules/es-object-atoms/README.md +56 -0
- package/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
- package/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
- package/node_modules/es-object-atoms/ToObject.d.ts +3 -0
- package/node_modules/es-object-atoms/ToObject.js +10 -0
- package/node_modules/es-object-atoms/index.d.ts +3 -0
- package/node_modules/es-object-atoms/index.js +4 -0
- package/node_modules/es-object-atoms/package.json +79 -0
- package/node_modules/es-object-atoms/test/index.js +28 -0
- package/node_modules/es-object-atoms/tsconfig.json +6 -0
- package/node_modules/get-intrinsic/CHANGELOG.md +9 -0
- package/node_modules/get-intrinsic/index.js +16 -3
- package/node_modules/get-intrinsic/package.json +6 -4
- package/node_modules/math-intrinsics/.eslintrc +16 -0
- package/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
- package/node_modules/math-intrinsics/CHANGELOG.md +16 -0
- package/node_modules/math-intrinsics/LICENSE +21 -0
- package/node_modules/math-intrinsics/README.md +49 -0
- package/node_modules/math-intrinsics/abs.d.ts +1 -0
- package/node_modules/math-intrinsics/abs.js +4 -0
- package/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
- package/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
- package/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
- package/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
- package/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
- package/node_modules/math-intrinsics/constants/maxValue.js +5 -0
- package/node_modules/math-intrinsics/floor.d.ts +1 -0
- package/node_modules/math-intrinsics/floor.js +4 -0
- package/node_modules/math-intrinsics/isFinite.d.ts +3 -0
- package/node_modules/math-intrinsics/isFinite.js +12 -0
- package/node_modules/math-intrinsics/isInteger.d.ts +3 -0
- package/node_modules/math-intrinsics/isInteger.js +16 -0
- package/node_modules/math-intrinsics/isNaN.d.ts +1 -0
- package/node_modules/math-intrinsics/isNaN.js +6 -0
- package/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
- package/node_modules/math-intrinsics/isNegativeZero.js +6 -0
- package/node_modules/math-intrinsics/max.d.ts +1 -0
- package/node_modules/math-intrinsics/max.js +4 -0
- package/node_modules/math-intrinsics/min.d.ts +1 -0
- package/node_modules/math-intrinsics/min.js +4 -0
- package/node_modules/math-intrinsics/mod.d.ts +3 -0
- package/node_modules/math-intrinsics/mod.js +9 -0
- package/node_modules/math-intrinsics/package.json +85 -0
- package/node_modules/math-intrinsics/pow.d.ts +1 -0
- package/node_modules/math-intrinsics/pow.js +4 -0
- package/node_modules/math-intrinsics/sign.d.ts +3 -0
- package/node_modules/math-intrinsics/sign.js +11 -0
- package/node_modules/math-intrinsics/test/index.js +183 -0
- package/node_modules/math-intrinsics/tsconfig.json +3 -0
- package/node_modules/side-channel/.eslintrc +1 -0
- package/node_modules/side-channel/CHANGELOG.md +15 -0
- package/node_modules/side-channel/README.md +60 -1
- package/node_modules/side-channel/index.d.ts +9 -22
- package/node_modules/side-channel/index.js +20 -106
- package/node_modules/side-channel/package.json +20 -19
- package/node_modules/side-channel/test/index.js +76 -55
- package/node_modules/side-channel/tsconfig.json +2 -43
- package/node_modules/side-channel-list/.editorconfig +9 -0
- package/node_modules/side-channel-list/.eslintrc +11 -0
- package/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
- package/node_modules/side-channel-list/.nycrc +13 -0
- package/node_modules/side-channel-list/CHANGELOG.md +15 -0
- package/node_modules/side-channel-list/LICENSE +21 -0
- package/node_modules/side-channel-list/README.md +62 -0
- package/node_modules/side-channel-list/index.d.ts +13 -0
- package/node_modules/side-channel-list/index.js +113 -0
- package/node_modules/side-channel-list/list.d.ts +14 -0
- package/node_modules/side-channel-list/package.json +77 -0
- package/node_modules/side-channel-list/test/index.js +104 -0
- package/node_modules/side-channel-list/tsconfig.json +9 -0
- package/node_modules/side-channel-map/.editorconfig +9 -0
- package/node_modules/side-channel-map/.eslintrc +11 -0
- package/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
- package/node_modules/side-channel-map/.nycrc +13 -0
- package/node_modules/side-channel-map/CHANGELOG.md +22 -0
- package/node_modules/side-channel-map/LICENSE +21 -0
- package/node_modules/side-channel-map/README.md +62 -0
- package/node_modules/side-channel-map/index.d.ts +15 -0
- package/node_modules/side-channel-map/index.js +68 -0
- package/node_modules/side-channel-map/package.json +80 -0
- package/node_modules/side-channel-map/test/index.js +114 -0
- package/node_modules/side-channel-map/tsconfig.json +9 -0
- package/node_modules/side-channel-weakmap/.editorconfig +9 -0
- package/node_modules/side-channel-weakmap/.eslintrc +12 -0
- package/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
- package/node_modules/side-channel-weakmap/.nycrc +13 -0
- package/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
- package/node_modules/side-channel-weakmap/LICENSE +21 -0
- package/node_modules/side-channel-weakmap/README.md +62 -0
- package/node_modules/side-channel-weakmap/index.d.ts +15 -0
- package/node_modules/side-channel-weakmap/index.js +84 -0
- package/node_modules/side-channel-weakmap/package.json +87 -0
- package/node_modules/side-channel-weakmap/test/index.js +114 -0
- package/node_modules/side-channel-weakmap/tsconfig.json +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var test = require('tape');
|
|
4
|
+
var v = require('es-value-fixtures');
|
|
5
|
+
var forEach = require('for-each');
|
|
6
|
+
var inspect = require('object-inspect');
|
|
7
|
+
|
|
8
|
+
var abs = require('../abs');
|
|
9
|
+
var floor = require('../floor');
|
|
10
|
+
var isFinite = require('../isFinite');
|
|
11
|
+
var isInteger = require('../isInteger');
|
|
12
|
+
var isNaN = require('../isNaN');
|
|
13
|
+
var isNegativeZero = require('../isNegativeZero');
|
|
14
|
+
var max = require('../max');
|
|
15
|
+
var min = require('../min');
|
|
16
|
+
var mod = require('../mod');
|
|
17
|
+
var pow = require('../pow');
|
|
18
|
+
var sign = require('../sign');
|
|
19
|
+
|
|
20
|
+
var maxArrayLength = require('../constants/maxArrayLength');
|
|
21
|
+
var maxSafeInteger = require('../constants/maxSafeInteger');
|
|
22
|
+
var maxValue = require('../constants/maxValue');
|
|
23
|
+
|
|
24
|
+
test('abs', function (t) {
|
|
25
|
+
t.equal(abs(-1), 1, 'abs(-1) === 1');
|
|
26
|
+
t.equal(abs(+1), 1, 'abs(+1) === 1');
|
|
27
|
+
t.equal(abs(+0), +0, 'abs(+0) === +0');
|
|
28
|
+
t.equal(abs(-0), +0, 'abs(-0) === +0');
|
|
29
|
+
|
|
30
|
+
t.end();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('floor', function (t) {
|
|
34
|
+
t.equal(floor(-1.1), -2, 'floor(-1.1) === -2');
|
|
35
|
+
t.equal(floor(+1.1), 1, 'floor(+1.1) === 1');
|
|
36
|
+
t.equal(floor(+0), +0, 'floor(+0) === +0');
|
|
37
|
+
t.equal(floor(-0), -0, 'floor(-0) === -0');
|
|
38
|
+
t.equal(floor(-Infinity), -Infinity, 'floor(-Infinity) === -Infinity');
|
|
39
|
+
t.equal(floor(Number(Infinity)), Number(Infinity), 'floor(+Infinity) === +Infinity');
|
|
40
|
+
t.equal(floor(NaN), NaN, 'floor(NaN) === NaN');
|
|
41
|
+
t.equal(floor(0), +0, 'floor(0) === +0');
|
|
42
|
+
t.equal(floor(-0), -0, 'floor(-0) === -0');
|
|
43
|
+
t.equal(floor(1), 1, 'floor(1) === 1');
|
|
44
|
+
t.equal(floor(-1), -1, 'floor(-1) === -1');
|
|
45
|
+
t.equal(floor(1.1), 1, 'floor(1.1) === 1');
|
|
46
|
+
t.equal(floor(-1.1), -2, 'floor(-1.1) === -2');
|
|
47
|
+
t.equal(floor(maxValue), maxValue, 'floor(maxValue) === maxValue');
|
|
48
|
+
t.equal(floor(maxSafeInteger), maxSafeInteger, 'floor(maxSafeInteger) === maxSafeInteger');
|
|
49
|
+
|
|
50
|
+
t.end();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('isFinite', function (t) {
|
|
54
|
+
t.equal(isFinite(0), true, 'isFinite(+0) === true');
|
|
55
|
+
t.equal(isFinite(-0), true, 'isFinite(-0) === true');
|
|
56
|
+
t.equal(isFinite(1), true, 'isFinite(1) === true');
|
|
57
|
+
t.equal(isFinite(Infinity), false, 'isFinite(Infinity) === false');
|
|
58
|
+
t.equal(isFinite(-Infinity), false, 'isFinite(-Infinity) === false');
|
|
59
|
+
t.equal(isFinite(NaN), false, 'isFinite(NaN) === false');
|
|
60
|
+
|
|
61
|
+
forEach(v.nonNumbers, function (nonNumber) {
|
|
62
|
+
t.equal(isFinite(nonNumber), false, 'isFinite(' + inspect(nonNumber) + ') === false');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
t.end();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('isInteger', function (t) {
|
|
69
|
+
forEach([].concat(
|
|
70
|
+
// @ts-expect-error TS sucks with concat
|
|
71
|
+
v.nonNumbers,
|
|
72
|
+
v.nonIntegerNumbers
|
|
73
|
+
), function (nonInteger) {
|
|
74
|
+
t.equal(isInteger(nonInteger), false, 'isInteger(' + inspect(nonInteger) + ') === false');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
t.end();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('isNaN', function (t) {
|
|
81
|
+
forEach([].concat(
|
|
82
|
+
// @ts-expect-error TS sucks with concat
|
|
83
|
+
v.nonNumbers,
|
|
84
|
+
v.infinities,
|
|
85
|
+
v.zeroes,
|
|
86
|
+
v.integerNumbers
|
|
87
|
+
), function (nonNaN) {
|
|
88
|
+
t.equal(isNaN(nonNaN), false, 'isNaN(' + inspect(nonNaN) + ') === false');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
t.equal(isNaN(NaN), true, 'isNaN(NaN) === true');
|
|
92
|
+
|
|
93
|
+
t.end();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('isNegativeZero', function (t) {
|
|
97
|
+
t.equal(isNegativeZero(-0), true, 'isNegativeZero(-0) === true');
|
|
98
|
+
t.equal(isNegativeZero(+0), false, 'isNegativeZero(+0) === false');
|
|
99
|
+
t.equal(isNegativeZero(1), false, 'isNegativeZero(1) === false');
|
|
100
|
+
t.equal(isNegativeZero(-1), false, 'isNegativeZero(-1) === false');
|
|
101
|
+
t.equal(isNegativeZero(NaN), false, 'isNegativeZero(NaN) === false');
|
|
102
|
+
t.equal(isNegativeZero(Infinity), false, 'isNegativeZero(Infinity) === false');
|
|
103
|
+
t.equal(isNegativeZero(-Infinity), false, 'isNegativeZero(-Infinity) === false');
|
|
104
|
+
|
|
105
|
+
forEach(v.nonNumbers, function (nonNumber) {
|
|
106
|
+
t.equal(isNegativeZero(nonNumber), false, 'isNegativeZero(' + inspect(nonNumber) + ') === false');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
t.end();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('max', function (t) {
|
|
113
|
+
t.equal(max(1, 2), 2, 'max(1, 2) === 2');
|
|
114
|
+
t.equal(max(1, 2, 3), 3, 'max(1, 2, 3) === 3');
|
|
115
|
+
t.equal(max(1, 2, 3, 4), 4, 'max(1, 2, 3, 4) === 4');
|
|
116
|
+
t.equal(max(1, 2, 3, 4, 5), 5, 'max(1, 2, 3, 4, 5) === 5');
|
|
117
|
+
t.equal(max(1, 2, 3, 4, 5, 6), 6, 'max(1, 2, 3, 4, 5, 6) === 6');
|
|
118
|
+
t.equal(max(1, 2, 3, 4, 5, 6, 7), 7, 'max(1, 2, 3, 4, 5, 6, 7) === 7');
|
|
119
|
+
|
|
120
|
+
t.end();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('min', function (t) {
|
|
124
|
+
t.equal(min(1, 2), 1, 'min(1, 2) === 1');
|
|
125
|
+
t.equal(min(1, 2, 3), 1, 'min(1, 2, 3) === 1');
|
|
126
|
+
t.equal(min(1, 2, 3, 4), 1, 'min(1, 2, 3, 4) === 1');
|
|
127
|
+
t.equal(min(1, 2, 3, 4, 5), 1, 'min(1, 2, 3, 4, 5) === 1');
|
|
128
|
+
t.equal(min(1, 2, 3, 4, 5, 6), 1, 'min(1, 2, 3, 4, 5, 6) === 1');
|
|
129
|
+
|
|
130
|
+
t.end();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('mod', function (t) {
|
|
134
|
+
t.equal(mod(1, 2), 1, 'mod(1, 2) === 1');
|
|
135
|
+
t.equal(mod(2, 2), 0, 'mod(2, 2) === 0');
|
|
136
|
+
t.equal(mod(3, 2), 1, 'mod(3, 2) === 1');
|
|
137
|
+
t.equal(mod(4, 2), 0, 'mod(4, 2) === 0');
|
|
138
|
+
t.equal(mod(5, 2), 1, 'mod(5, 2) === 1');
|
|
139
|
+
t.equal(mod(6, 2), 0, 'mod(6, 2) === 0');
|
|
140
|
+
t.equal(mod(7, 2), 1, 'mod(7, 2) === 1');
|
|
141
|
+
t.equal(mod(8, 2), 0, 'mod(8, 2) === 0');
|
|
142
|
+
t.equal(mod(9, 2), 1, 'mod(9, 2) === 1');
|
|
143
|
+
t.equal(mod(10, 2), 0, 'mod(10, 2) === 0');
|
|
144
|
+
t.equal(mod(11, 2), 1, 'mod(11, 2) === 1');
|
|
145
|
+
|
|
146
|
+
t.end();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('pow', function (t) {
|
|
150
|
+
t.equal(pow(2, 2), 4, 'pow(2, 2) === 4');
|
|
151
|
+
t.equal(pow(2, 3), 8, 'pow(2, 3) === 8');
|
|
152
|
+
t.equal(pow(2, 4), 16, 'pow(2, 4) === 16');
|
|
153
|
+
t.equal(pow(2, 5), 32, 'pow(2, 5) === 32');
|
|
154
|
+
t.equal(pow(2, 6), 64, 'pow(2, 6) === 64');
|
|
155
|
+
t.equal(pow(2, 7), 128, 'pow(2, 7) === 128');
|
|
156
|
+
t.equal(pow(2, 8), 256, 'pow(2, 8) === 256');
|
|
157
|
+
t.equal(pow(2, 9), 512, 'pow(2, 9) === 512');
|
|
158
|
+
t.equal(pow(2, 10), 1024, 'pow(2, 10) === 1024');
|
|
159
|
+
|
|
160
|
+
t.end();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test('sign', function (t) {
|
|
164
|
+
t.equal(sign(-1), -1, 'sign(-1) === -1');
|
|
165
|
+
t.equal(sign(+1), +1, 'sign(+1) === +1');
|
|
166
|
+
t.equal(sign(+0), +0, 'sign(+0) === +0');
|
|
167
|
+
t.equal(sign(-0), -0, 'sign(-0) === -0');
|
|
168
|
+
t.equal(sign(NaN), NaN, 'sign(NaN) === NaN');
|
|
169
|
+
t.equal(sign(Infinity), +1, 'sign(Infinity) === +1');
|
|
170
|
+
t.equal(sign(-Infinity), -1, 'sign(-Infinity) === -1');
|
|
171
|
+
t.equal(sign(maxValue), +1, 'sign(maxValue) === +1');
|
|
172
|
+
t.equal(sign(maxSafeInteger), +1, 'sign(maxSafeInteger) === +1');
|
|
173
|
+
|
|
174
|
+
t.end();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('constants', function (t) {
|
|
178
|
+
t.equal(typeof maxArrayLength, 'number', 'typeof maxArrayLength === "number"');
|
|
179
|
+
t.equal(typeof maxSafeInteger, 'number', 'typeof maxSafeInteger === "number"');
|
|
180
|
+
t.equal(typeof maxValue, 'number', 'typeof maxValue === "number"');
|
|
181
|
+
|
|
182
|
+
t.end();
|
|
183
|
+
});
|
|
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [v1.1.0](https://github.com/ljharb/side-channel/compare/v1.0.6...v1.1.0) - 2024-12-11
|
|
9
|
+
|
|
10
|
+
### Commits
|
|
11
|
+
|
|
12
|
+
- [Refactor] extract implementations to `side-channel-weakmap`, `side-channel-map`, `side-channel-list` [`ada5955`](https://github.com/ljharb/side-channel/commit/ada595549a5c4c6c853756d598846b180941c6da)
|
|
13
|
+
- [New] add `channel.delete` [`c01d2d3`](https://github.com/ljharb/side-channel/commit/c01d2d3fd51dbb1ce6da72ad7916e61bd6172aad)
|
|
14
|
+
- [types] improve types [`0c54356`](https://github.com/ljharb/side-channel/commit/0c5435651417df41b8cc1a5f7cdce8bffae68cde)
|
|
15
|
+
- [readme] add content [`be24868`](https://github.com/ljharb/side-channel/commit/be248682ac294b0e22c883092c45985aa91c490a)
|
|
16
|
+
- [actions] split out node 10-20, and 20+ [`c4488e2`](https://github.com/ljharb/side-channel/commit/c4488e241ef3d49a19fe266ac830a2e644305911)
|
|
17
|
+
- [types] use shared tsconfig [`0e0d57c`](https://github.com/ljharb/side-channel/commit/0e0d57c2ff17c7b45c6cbd43ebcf553edc9e3adc)
|
|
18
|
+
- [Dev Deps] update `@ljharb/eslint-config`, `@ljharb/tsconfig`, `@types/get-intrinsic`, `@types/object-inspect`, `@types/tape`, `auto-changelog`, `tape` [`fb4f622`](https://github.com/ljharb/side-channel/commit/fb4f622e64a99a1e40b6e5cd7691674a9dc429e4)
|
|
19
|
+
- [Deps] update `call-bind`, `get-intrinsic`, `object-inspect` [`b78336b`](https://github.com/ljharb/side-channel/commit/b78336b886172d1b457d414ac9e28de8c5fecc78)
|
|
20
|
+
- [Tests] replace `aud` with `npm audit` [`ee3ab46`](https://github.com/ljharb/side-channel/commit/ee3ab4690d954311c35115651bcfd45edd205aa1)
|
|
21
|
+
- [Dev Deps] add missing peer dep [`c03e21a`](https://github.com/ljharb/side-channel/commit/c03e21a7def3b67cdc15ae22316884fefcb2f6a8)
|
|
22
|
+
|
|
8
23
|
## [v1.0.6](https://github.com/ljharb/side-channel/compare/v1.0.5...v1.0.6) - 2024-02-29
|
|
9
24
|
|
|
10
25
|
### Commits
|
|
@@ -1,2 +1,61 @@
|
|
|
1
|
-
# side-channel
|
|
1
|
+
# side-channel <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
|
+
|
|
2
10
|
Store information about any JS value in a side channel. Uses WeakMap if available.
|
|
11
|
+
|
|
12
|
+
Warning: in an environment that lacks `WeakMap`, this implementation will leak memory until you `delete` the `key`.
|
|
13
|
+
|
|
14
|
+
## Getting started
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install --save side-channel
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage/Examples
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
const assert = require('assert');
|
|
24
|
+
const getSideChannel = require('side-channel');
|
|
25
|
+
|
|
26
|
+
const channel = getSideChannel();
|
|
27
|
+
|
|
28
|
+
const key = {};
|
|
29
|
+
assert.equal(channel.has(key), false);
|
|
30
|
+
assert.throws(() => channel.assert(key), TypeError);
|
|
31
|
+
|
|
32
|
+
channel.set(key, 42);
|
|
33
|
+
|
|
34
|
+
channel.assert(key); // does not throw
|
|
35
|
+
assert.equal(channel.has(key), true);
|
|
36
|
+
assert.equal(channel.get(key), 42);
|
|
37
|
+
|
|
38
|
+
channel.delete(key);
|
|
39
|
+
assert.equal(channel.has(key), false);
|
|
40
|
+
assert.throws(() => channel.assert(key), TypeError);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Tests
|
|
44
|
+
|
|
45
|
+
Clone the repo, `npm install`, and run `npm test`
|
|
46
|
+
|
|
47
|
+
[package-url]: https://npmjs.org/package/side-channel
|
|
48
|
+
[npm-version-svg]: https://versionbadg.es/ljharb/side-channel.svg
|
|
49
|
+
[deps-svg]: https://david-dm.org/ljharb/side-channel.svg
|
|
50
|
+
[deps-url]: https://david-dm.org/ljharb/side-channel
|
|
51
|
+
[dev-deps-svg]: https://david-dm.org/ljharb/side-channel/dev-status.svg
|
|
52
|
+
[dev-deps-url]: https://david-dm.org/ljharb/side-channel#info=devDependencies
|
|
53
|
+
[npm-badge-png]: https://nodei.co/npm/side-channel.png?downloads=true&stars=true
|
|
54
|
+
[license-image]: https://img.shields.io/npm/l/side-channel.svg
|
|
55
|
+
[license-url]: LICENSE
|
|
56
|
+
[downloads-image]: https://img.shields.io/npm/dm/side-channel.svg
|
|
57
|
+
[downloads-url]: https://npm-stat.com/charts.html?package=side-channel
|
|
58
|
+
[codecov-image]: https://codecov.io/gh/ljharb/side-channel/branch/main/graphs/badge.svg
|
|
59
|
+
[codecov-url]: https://app.codecov.io/gh/ljharb/side-channel/
|
|
60
|
+
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/side-channel
|
|
61
|
+
[actions-url]: https://github.com/ljharb/side-channel/actions
|
|
@@ -1,27 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
key: Key;
|
|
5
|
-
next: ListNode<T>;
|
|
6
|
-
value: T;
|
|
7
|
-
};
|
|
8
|
-
type RootNode<T> = {
|
|
9
|
-
key: object;
|
|
10
|
-
next: null | ListNode<T>;
|
|
11
|
-
};
|
|
12
|
-
function listGetNode<T>(list: RootNode<T>, key: ListNode<T>['key']): ListNode<T> | void;
|
|
13
|
-
function listGet<T>(objects: RootNode<T>, key: ListNode<T>['key']): T | void;
|
|
14
|
-
function listSet<T>(objects: RootNode<T>, key: ListNode<T>['key'], value: T): void;
|
|
15
|
-
function listHas<T>(objects: RootNode<T>, key: ListNode<T>['key']): boolean;
|
|
1
|
+
import getSideChannelList from 'side-channel-list';
|
|
2
|
+
import getSideChannelMap from 'side-channel-map';
|
|
3
|
+
import getSideChannelWeakMap from 'side-channel-weakmap';
|
|
16
4
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
5
|
+
declare namespace getSideChannel {
|
|
6
|
+
type Channel<K, V> =
|
|
7
|
+
| getSideChannelList.Channel<K, V>
|
|
8
|
+
| ReturnType<Exclude<typeof getSideChannelMap<K, V>, false>>
|
|
9
|
+
| ReturnType<Exclude<typeof getSideChannelWeakMap<K, V>, false>>;
|
|
23
10
|
}
|
|
24
11
|
|
|
25
|
-
declare function getSideChannel(): getSideChannel.Channel
|
|
12
|
+
declare function getSideChannel<K, V>(): getSideChannel.Channel<K, V>;
|
|
26
13
|
|
|
27
14
|
export = getSideChannel;
|
|
@@ -1,129 +1,43 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var GetIntrinsic = require('get-intrinsic');
|
|
4
|
-
var callBound = require('call-bind/callBound');
|
|
5
|
-
var inspect = require('object-inspect');
|
|
6
|
-
|
|
7
3
|
var $TypeError = require('es-errors/type');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
var $weakMapSet = callBound('WeakMap.prototype.set', true);
|
|
13
|
-
var $weakMapHas = callBound('WeakMap.prototype.has', true);
|
|
14
|
-
var $mapGet = callBound('Map.prototype.get', true);
|
|
15
|
-
var $mapSet = callBound('Map.prototype.set', true);
|
|
16
|
-
var $mapHas = callBound('Map.prototype.has', true);
|
|
4
|
+
var inspect = require('object-inspect');
|
|
5
|
+
var getSideChannelList = require('side-channel-list');
|
|
6
|
+
var getSideChannelMap = require('side-channel-map');
|
|
7
|
+
var getSideChannelWeakMap = require('side-channel-weakmap');
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
* This function traverses the list returning the node corresponding to the given key.
|
|
20
|
-
*
|
|
21
|
-
* That node is also moved to the head of the list, so that if it's accessed again we don't need to traverse the whole list. By doing so, all the recently used nodes can be accessed relatively quickly.
|
|
22
|
-
*/
|
|
23
|
-
/** @type {import('.').listGetNode} */
|
|
24
|
-
var listGetNode = function (list, key) { // eslint-disable-line consistent-return
|
|
25
|
-
/** @type {typeof list | NonNullable<(typeof list)['next']>} */
|
|
26
|
-
var prev = list;
|
|
27
|
-
/** @type {(typeof list)['next']} */
|
|
28
|
-
var curr;
|
|
29
|
-
for (; (curr = prev.next) !== null; prev = curr) {
|
|
30
|
-
if (curr.key === key) {
|
|
31
|
-
prev.next = curr.next;
|
|
32
|
-
// eslint-disable-next-line no-extra-parens
|
|
33
|
-
curr.next = /** @type {NonNullable<typeof list.next>} */ (list.next);
|
|
34
|
-
list.next = curr; // eslint-disable-line no-param-reassign
|
|
35
|
-
return curr;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/** @type {import('.').listGet} */
|
|
41
|
-
var listGet = function (objects, key) {
|
|
42
|
-
var node = listGetNode(objects, key);
|
|
43
|
-
return node && node.value;
|
|
44
|
-
};
|
|
45
|
-
/** @type {import('.').listSet} */
|
|
46
|
-
var listSet = function (objects, key, value) {
|
|
47
|
-
var node = listGetNode(objects, key);
|
|
48
|
-
if (node) {
|
|
49
|
-
node.value = value;
|
|
50
|
-
} else {
|
|
51
|
-
// Prepend the new node to the beginning of the list
|
|
52
|
-
objects.next = /** @type {import('.').ListNode<typeof value>} */ ({ // eslint-disable-line no-param-reassign, no-extra-parens
|
|
53
|
-
key: key,
|
|
54
|
-
next: objects.next,
|
|
55
|
-
value: value
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
/** @type {import('.').listHas} */
|
|
60
|
-
var listHas = function (objects, key) {
|
|
61
|
-
return !!listGetNode(objects, key);
|
|
62
|
-
};
|
|
9
|
+
var makeChannel = getSideChannelWeakMap || getSideChannelMap || getSideChannelList;
|
|
63
10
|
|
|
64
11
|
/** @type {import('.')} */
|
|
65
12
|
module.exports = function getSideChannel() {
|
|
66
|
-
/** @
|
|
67
|
-
/** @type {Map<object, unknown>} */ var $m;
|
|
68
|
-
/** @type {import('.').RootNode<unknown>} */ var $o;
|
|
13
|
+
/** @typedef {ReturnType<typeof getSideChannel>} Channel */
|
|
69
14
|
|
|
70
|
-
/** @type {
|
|
15
|
+
/** @type {Channel | undefined} */ var $channelData;
|
|
16
|
+
|
|
17
|
+
/** @type {Channel} */
|
|
71
18
|
var channel = {
|
|
72
19
|
assert: function (key) {
|
|
73
20
|
if (!channel.has(key)) {
|
|
74
21
|
throw new $TypeError('Side channel does not contain ' + inspect(key));
|
|
75
22
|
}
|
|
76
23
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} else if ($Map) {
|
|
83
|
-
if ($m) {
|
|
84
|
-
return $mapGet($m, key);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
if ($o) { // eslint-disable-line no-lonely-if
|
|
88
|
-
return listGet($o, key);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
24
|
+
'delete': function (key) {
|
|
25
|
+
return !!$channelData && $channelData['delete'](key);
|
|
26
|
+
},
|
|
27
|
+
get: function (key) {
|
|
28
|
+
return $channelData && $channelData.get(key);
|
|
91
29
|
},
|
|
92
30
|
has: function (key) {
|
|
93
|
-
|
|
94
|
-
if ($wm) {
|
|
95
|
-
return $weakMapHas($wm, key);
|
|
96
|
-
}
|
|
97
|
-
} else if ($Map) {
|
|
98
|
-
if ($m) {
|
|
99
|
-
return $mapHas($m, key);
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
if ($o) { // eslint-disable-line no-lonely-if
|
|
103
|
-
return listHas($o, key);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return false;
|
|
31
|
+
return !!$channelData && $channelData.has(key);
|
|
107
32
|
},
|
|
108
33
|
set: function (key, value) {
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
$wm = new $WeakMap();
|
|
112
|
-
}
|
|
113
|
-
$weakMapSet($wm, key, value);
|
|
114
|
-
} else if ($Map) {
|
|
115
|
-
if (!$m) {
|
|
116
|
-
$m = new $Map();
|
|
117
|
-
}
|
|
118
|
-
$mapSet($m, key, value);
|
|
119
|
-
} else {
|
|
120
|
-
if (!$o) {
|
|
121
|
-
// Initialize the linked list as an empty node, so that we don't have to special-case handling of the first node: we can always refer to it as (previous node).next, instead of something like (list).head
|
|
122
|
-
$o = { key: {}, next: null };
|
|
123
|
-
}
|
|
124
|
-
listSet($o, key, value);
|
|
34
|
+
if (!$channelData) {
|
|
35
|
+
$channelData = makeChannel();
|
|
125
36
|
}
|
|
37
|
+
|
|
38
|
+
$channelData.set(key, value);
|
|
126
39
|
}
|
|
127
40
|
};
|
|
41
|
+
// @ts-expect-error TODO: figure out why this is erroring
|
|
128
42
|
return channel;
|
|
129
43
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "side-channel",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Store information about any JS value in a side channel. Uses WeakMap if available.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
7
|
-
"
|
|
8
|
-
".": "./
|
|
7
|
+
".": "./index.js",
|
|
8
|
+
"./package.json": "./package.json"
|
|
9
9
|
},
|
|
10
10
|
"types": "./index.d.ts",
|
|
11
11
|
"scripts": {
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"prepublish": "not-in-publish || npm run prepublishOnly",
|
|
15
15
|
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
|
|
16
16
|
"lint": "eslint --ext=js,mjs .",
|
|
17
|
-
"postlint": "tsc -p .",
|
|
17
|
+
"postlint": "tsc -p . && attw -P",
|
|
18
18
|
"pretest": "npm run lint",
|
|
19
19
|
"tests-only": "nyc tape 'test/**/*.js'",
|
|
20
20
|
"test": "npm run tests-only",
|
|
21
|
-
"posttest": "
|
|
21
|
+
"posttest": "npx npm@'>=10.2' audit --production",
|
|
22
22
|
"version": "auto-changelog && git add CHANGELOG.md",
|
|
23
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
24
|
},
|
|
@@ -42,29 +42,30 @@
|
|
|
42
42
|
"url": "https://github.com/ljharb/side-channel/issues"
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/ljharb/side-channel#readme",
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"es-errors": "^1.3.0",
|
|
47
|
+
"object-inspect": "^1.13.3",
|
|
48
|
+
"side-channel-list": "^1.0.0",
|
|
49
|
+
"side-channel-map": "^1.0.1",
|
|
50
|
+
"side-channel-weakmap": "^1.0.2"
|
|
51
|
+
},
|
|
45
52
|
"devDependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@types/object-inspect": "^1.
|
|
50
|
-
"@types/tape": "^5.6.
|
|
51
|
-
"
|
|
52
|
-
"auto-changelog": "^2.4.0",
|
|
53
|
+
"@arethetypeswrong/cli": "^0.17.1",
|
|
54
|
+
"@ljharb/eslint-config": "^21.1.1",
|
|
55
|
+
"@ljharb/tsconfig": "^0.2.2",
|
|
56
|
+
"@types/object-inspect": "^1.13.0",
|
|
57
|
+
"@types/tape": "^5.6.5",
|
|
58
|
+
"auto-changelog": "^2.5.0",
|
|
53
59
|
"eclint": "^2.8.1",
|
|
60
|
+
"encoding": "^0.1.13",
|
|
54
61
|
"eslint": "=8.8.0",
|
|
55
62
|
"in-publish": "^2.0.1",
|
|
56
63
|
"npmignore": "^0.3.1",
|
|
57
64
|
"nyc": "^10.3.2",
|
|
58
65
|
"safe-publish-latest": "^2.0.0",
|
|
59
|
-
"tape": "^5.
|
|
66
|
+
"tape": "^5.9.0",
|
|
60
67
|
"typescript": "next"
|
|
61
68
|
},
|
|
62
|
-
"dependencies": {
|
|
63
|
-
"call-bind": "^1.0.7",
|
|
64
|
-
"es-errors": "^1.3.0",
|
|
65
|
-
"get-intrinsic": "^1.2.4",
|
|
66
|
-
"object-inspect": "^1.13.1"
|
|
67
|
-
},
|
|
68
69
|
"auto-changelog": {
|
|
69
70
|
"output": "CHANGELOG.md",
|
|
70
71
|
"template": "keepachangelog",
|