@contrast/agent 4.4.1 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/bin/VERSION +1 -1
  2. package/bin/linux/contrast-service +0 -0
  3. package/bin/mac/contrast-service +0 -0
  4. package/bin/windows/contrast-service.exe +0 -0
  5. package/lib/assess/hapi/route-coverage.js +3 -3
  6. package/lib/assess/membrane/index.js +2 -8
  7. package/lib/assess/membrane/source-membrane.js +3 -4
  8. package/lib/assess/models/base-event.js +2 -2
  9. package/lib/assess/models/call-context.js +0 -3
  10. package/lib/assess/policy/propagators.json +20 -0
  11. package/lib/assess/policy/signatures.json +103 -0
  12. package/lib/assess/propagators/path/common.js +165 -36
  13. package/lib/assess/propagators/path/join.js +5 -1
  14. package/lib/assess/propagators/path/normalize.js +5 -1
  15. package/lib/assess/propagators/path/resolve.js +11 -2
  16. package/lib/assess/response-scanning/autocomplete-missing.js +0 -2
  17. package/lib/assess/response-scanning/parameter-pollution.js +0 -2
  18. package/lib/core/arch-components/dynamodb.js +1 -2
  19. package/lib/core/arch-components/dynamodbv3.js +44 -0
  20. package/lib/core/arch-components/index.js +1 -0
  21. package/lib/core/async-storage/hooks/bluebird.js +20 -0
  22. package/lib/core/config/options.js +3 -2
  23. package/lib/core/express/utils.js +1 -1
  24. package/lib/core/logger/debug-logger.js +15 -17
  25. package/lib/core/stacktrace.js +3 -4
  26. package/lib/feature-set.js +2 -1
  27. package/lib/hooks/encoding.js +1 -1
  28. package/lib/hooks/frameworks/base.js +8 -2
  29. package/lib/hooks/frameworks/http.js +23 -16
  30. package/lib/hooks/frameworks/http2.js +73 -0
  31. package/lib/hooks/frameworks/index.js +8 -3
  32. package/lib/hooks/http.js +112 -128
  33. package/lib/hooks/patcher.js +10 -12
  34. package/lib/hooks/require.js +16 -22
  35. package/lib/instrumentation.js +0 -3
  36. package/lib/protect/analysis/aho-corasick.js +13 -30
  37. package/lib/protect/rules/cmd-injection-command-backdoors/backdoor-detector.js +3 -3
  38. package/lib/protect/rules/signatures/reflected-xss/helpers/function-call.js +1 -1
  39. package/lib/protect/rules/xss/helpers/function-call.js +1 -1
  40. package/lib/util/clean-stack.js +1 -1
  41. package/lib/util/clean-string/brackets.js +3 -3
  42. package/lib/util/clean-string/concatenations.js +1 -1
  43. package/lib/util/clean-string/util.js +1 -2
  44. package/lib/util/ip-analyzer.js +1 -1
  45. package/lib/util/some.js +27 -0
  46. package/lib/util/xml-analyzer/external-entity-finder.js +1 -1
  47. package/package.json +14 -15
  48. package/lib/hooks/frameworks/https.js +0 -42
  49. package/node_modules/bindings/LICENSE.md +0 -22
  50. package/node_modules/bindings/README.md +0 -98
  51. package/node_modules/bindings/bindings.js +0 -221
  52. package/node_modules/bindings/package.json +0 -32
  53. package/node_modules/file-uri-to-path/.npmignore +0 -1
  54. package/node_modules/file-uri-to-path/.travis.yml +0 -30
  55. package/node_modules/file-uri-to-path/History.md +0 -21
  56. package/node_modules/file-uri-to-path/LICENSE +0 -20
  57. package/node_modules/file-uri-to-path/README.md +0 -74
  58. package/node_modules/file-uri-to-path/index.d.ts +0 -2
  59. package/node_modules/file-uri-to-path/index.js +0 -66
  60. package/node_modules/file-uri-to-path/package.json +0 -36
  61. package/node_modules/file-uri-to-path/test/test.js +0 -24
  62. package/node_modules/file-uri-to-path/test/tests.json +0 -13
  63. package/node_modules/glossy/LICENSE +0 -19
  64. package/node_modules/glossy/README.md +0 -129
  65. package/node_modules/glossy/index.js +0 -12
  66. package/node_modules/glossy/lib/glossy/parse.js +0 -520
  67. package/node_modules/glossy/lib/glossy/produce.js +0 -459
  68. package/node_modules/glossy/package.json +0 -47
  69. package/node_modules/glossy/test/decide.js +0 -7
  70. package/node_modules/glossy/test/decode_pri.js +0 -24
  71. package/node_modules/glossy/test/parse_3164.js +0 -104
  72. package/node_modules/glossy/test/parse_5424.js +0 -106
  73. package/node_modules/glossy/test/parse_5848.js +0 -40
  74. package/node_modules/glossy/test/parse_8601.js +0 -14
  75. package/node_modules/glossy/test/parse_rfc3339.js +0 -9
  76. package/node_modules/glossy/test/produce.js +0 -162
  77. package/node_modules/glossy/test/runner.js +0 -40
  78. package/node_modules/glossy/test/structure_data.js +0 -24
  79. package/node_modules/nan/CHANGELOG.md +0 -537
  80. package/node_modules/nan/LICENSE.md +0 -13
  81. package/node_modules/nan/README.md +0 -455
  82. package/node_modules/nan/doc/asyncworker.md +0 -146
  83. package/node_modules/nan/doc/buffers.md +0 -54
  84. package/node_modules/nan/doc/callback.md +0 -76
  85. package/node_modules/nan/doc/converters.md +0 -41
  86. package/node_modules/nan/doc/errors.md +0 -226
  87. package/node_modules/nan/doc/json.md +0 -62
  88. package/node_modules/nan/doc/maybe_types.md +0 -583
  89. package/node_modules/nan/doc/methods.md +0 -664
  90. package/node_modules/nan/doc/new.md +0 -147
  91. package/node_modules/nan/doc/node_misc.md +0 -123
  92. package/node_modules/nan/doc/object_wrappers.md +0 -263
  93. package/node_modules/nan/doc/persistent.md +0 -296
  94. package/node_modules/nan/doc/scopes.md +0 -73
  95. package/node_modules/nan/doc/script.md +0 -38
  96. package/node_modules/nan/doc/string_bytes.md +0 -62
  97. package/node_modules/nan/doc/v8_internals.md +0 -199
  98. package/node_modules/nan/doc/v8_misc.md +0 -85
  99. package/node_modules/nan/include_dirs.js +0 -1
  100. package/node_modules/nan/nan.h +0 -2898
  101. package/node_modules/nan/nan_callbacks.h +0 -88
  102. package/node_modules/nan/nan_callbacks_12_inl.h +0 -514
  103. package/node_modules/nan/nan_callbacks_pre_12_inl.h +0 -520
  104. package/node_modules/nan/nan_converters.h +0 -72
  105. package/node_modules/nan/nan_converters_43_inl.h +0 -68
  106. package/node_modules/nan/nan_converters_pre_43_inl.h +0 -42
  107. package/node_modules/nan/nan_define_own_property_helper.h +0 -29
  108. package/node_modules/nan/nan_implementation_12_inl.h +0 -430
  109. package/node_modules/nan/nan_implementation_pre_12_inl.h +0 -263
  110. package/node_modules/nan/nan_json.h +0 -166
  111. package/node_modules/nan/nan_maybe_43_inl.h +0 -356
  112. package/node_modules/nan/nan_maybe_pre_43_inl.h +0 -268
  113. package/node_modules/nan/nan_new.h +0 -340
  114. package/node_modules/nan/nan_object_wrap.h +0 -156
  115. package/node_modules/nan/nan_persistent_12_inl.h +0 -132
  116. package/node_modules/nan/nan_persistent_pre_12_inl.h +0 -242
  117. package/node_modules/nan/nan_private.h +0 -73
  118. package/node_modules/nan/nan_string_bytes.h +0 -305
  119. package/node_modules/nan/nan_typedarray_contents.h +0 -96
  120. package/node_modules/nan/nan_weak.h +0 -437
  121. package/node_modules/nan/package.json +0 -41
  122. package/node_modules/nan/tools/1to2.js +0 -412
  123. package/node_modules/nan/tools/README.md +0 -14
  124. package/node_modules/nan/tools/package.json +0 -19
  125. package/node_modules/unix-dgram/LICENSE +0 -13
  126. package/node_modules/unix-dgram/README.md +0 -107
  127. package/node_modules/unix-dgram/binding.gyp +0 -20
  128. package/node_modules/unix-dgram/build/Makefile +0 -324
  129. package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram/src/unix_dgram.o.d +0 -58
  130. package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram.node.d +0 -1
  131. package/node_modules/unix-dgram/build/Release/.deps/Release/unix_dgram.node.d +0 -1
  132. package/node_modules/unix-dgram/build/Release/obj.target/unix_dgram/src/unix_dgram.o +0 -0
  133. package/node_modules/unix-dgram/build/Release/obj.target/unix_dgram.node +0 -0
  134. package/node_modules/unix-dgram/build/Release/unix_dgram.node +0 -0
  135. package/node_modules/unix-dgram/build/binding.Makefile +0 -6
  136. package/node_modules/unix-dgram/build/config.gypi +0 -213
  137. package/node_modules/unix-dgram/build/unix_dgram.target.mk +0 -159
  138. package/node_modules/unix-dgram/lib/unix_dgram.js +0 -168
  139. package/node_modules/unix-dgram/package.json +0 -36
  140. package/node_modules/unix-dgram/src/unix_dgram.cc +0 -404
  141. package/node_modules/unix-dgram/src/win_dummy.cc +0 -7
  142. package/node_modules/unix-dgram/test/test-connect-callback.js +0 -68
  143. package/node_modules/unix-dgram/test/test-connect.js +0 -53
  144. package/node_modules/unix-dgram/test/test-dgram-unix.js +0 -58
  145. package/node_modules/unix-dgram/test/test-send-error.js +0 -26
  146. package/node_modules/winston-syslog/.eslintrc +0 -7
  147. package/node_modules/winston-syslog/.travis.yml +0 -14
  148. package/node_modules/winston-syslog/CHANGELOG.md +0 -9
  149. package/node_modules/winston-syslog/LICENSE +0 -20
  150. package/node_modules/winston-syslog/README.md +0 -135
  151. package/node_modules/winston-syslog/lib/utils.js +0 -26
  152. package/node_modules/winston-syslog/lib/winston-syslog.js +0 -385
  153. package/node_modules/winston-syslog/package.json +0 -56
  154. package/node_modules/winston-syslog/test/format-test.js +0 -122
  155. package/node_modules/winston-syslog/test/syslog-test.js +0 -95
  156. package/node_modules/winston-syslog/test/unix-connect-test.js +0 -133
@@ -1,340 +0,0 @@
1
- /*********************************************************************
2
- * NAN - Native Abstractions for Node.js
3
- *
4
- * Copyright (c) 2018 NAN contributors
5
- *
6
- * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
7
- ********************************************************************/
8
-
9
- #ifndef NAN_NEW_H_
10
- #define NAN_NEW_H_
11
-
12
- namespace imp { // scnr
13
-
14
- // TODO(agnat): Generalize
15
- template <typename T> v8::Local<T> To(v8::Local<v8::Integer> i);
16
-
17
- template <>
18
- inline
19
- v8::Local<v8::Integer>
20
- To<v8::Integer>(v8::Local<v8::Integer> i) {
21
- return Nan::To<v8::Integer>(i).ToLocalChecked();
22
- }
23
-
24
- template <>
25
- inline
26
- v8::Local<v8::Int32>
27
- To<v8::Int32>(v8::Local<v8::Integer> i) {
28
- return Nan::To<v8::Int32>(i).ToLocalChecked();
29
- }
30
-
31
- template <>
32
- inline
33
- v8::Local<v8::Uint32>
34
- To<v8::Uint32>(v8::Local<v8::Integer> i) {
35
- return Nan::To<v8::Uint32>(i).ToLocalChecked();
36
- }
37
-
38
- template <typename T> struct FactoryBase {
39
- typedef v8::Local<T> return_t;
40
- };
41
-
42
- template <typename T> struct MaybeFactoryBase {
43
- typedef MaybeLocal<T> return_t;
44
- };
45
-
46
- template <typename T> struct Factory;
47
-
48
- template <>
49
- struct Factory<v8::Array> : FactoryBase<v8::Array> {
50
- static inline return_t New();
51
- static inline return_t New(int length);
52
- };
53
-
54
- template <>
55
- struct Factory<v8::Boolean> : FactoryBase<v8::Boolean> {
56
- static inline return_t New(bool value);
57
- };
58
-
59
- template <>
60
- struct Factory<v8::BooleanObject> : FactoryBase<v8::BooleanObject> {
61
- static inline return_t New(bool value);
62
- };
63
-
64
- template <>
65
- struct Factory<v8::Context> : FactoryBase<v8::Context> {
66
- static inline
67
- return_t
68
- New( v8::ExtensionConfiguration* extensions = NULL
69
- , v8::Local<v8::ObjectTemplate> tmpl = v8::Local<v8::ObjectTemplate>()
70
- , v8::Local<v8::Value> obj = v8::Local<v8::Value>());
71
- };
72
-
73
- template <>
74
- struct Factory<v8::Date> : MaybeFactoryBase<v8::Date> {
75
- static inline return_t New(double value);
76
- };
77
-
78
- template <>
79
- struct Factory<v8::External> : FactoryBase<v8::External> {
80
- static inline return_t New(void *value);
81
- };
82
-
83
- template <>
84
- struct Factory<v8::Function> : FactoryBase<v8::Function> {
85
- static inline
86
- return_t
87
- New( FunctionCallback callback
88
- , v8::Local<v8::Value> data = v8::Local<v8::Value>());
89
- };
90
-
91
- template <>
92
- struct Factory<v8::FunctionTemplate> : FactoryBase<v8::FunctionTemplate> {
93
- static inline
94
- return_t
95
- New( FunctionCallback callback = NULL
96
- , v8::Local<v8::Value> data = v8::Local<v8::Value>()
97
- , v8::Local<v8::Signature> signature = v8::Local<v8::Signature>());
98
- };
99
-
100
- template <>
101
- struct Factory<v8::Number> : FactoryBase<v8::Number> {
102
- static inline return_t New(double value);
103
- };
104
-
105
- template <>
106
- struct Factory<v8::NumberObject> : FactoryBase<v8::NumberObject> {
107
- static inline return_t New(double value);
108
- };
109
-
110
- template <typename T>
111
- struct IntegerFactory : FactoryBase<T> {
112
- typedef typename FactoryBase<T>::return_t return_t;
113
- static inline return_t New(int32_t value);
114
- static inline return_t New(uint32_t value);
115
- };
116
-
117
- template <>
118
- struct Factory<v8::Integer> : IntegerFactory<v8::Integer> {};
119
-
120
- template <>
121
- struct Factory<v8::Int32> : IntegerFactory<v8::Int32> {};
122
-
123
- template <>
124
- struct Factory<v8::Uint32> : FactoryBase<v8::Uint32> {
125
- static inline return_t New(int32_t value);
126
- static inline return_t New(uint32_t value);
127
- };
128
-
129
- template <>
130
- struct Factory<v8::Object> : FactoryBase<v8::Object> {
131
- static inline return_t New();
132
- };
133
-
134
- template <>
135
- struct Factory<v8::ObjectTemplate> : FactoryBase<v8::ObjectTemplate> {
136
- static inline return_t New();
137
- };
138
-
139
- template <>
140
- struct Factory<v8::RegExp> : MaybeFactoryBase<v8::RegExp> {
141
- static inline return_t New(
142
- v8::Local<v8::String> pattern, v8::RegExp::Flags flags);
143
- };
144
-
145
- template <>
146
- struct Factory<v8::Script> : MaybeFactoryBase<v8::Script> {
147
- static inline return_t New( v8::Local<v8::String> source);
148
- static inline return_t New( v8::Local<v8::String> source
149
- , v8::ScriptOrigin const& origin);
150
- };
151
-
152
- template <>
153
- struct Factory<v8::Signature> : FactoryBase<v8::Signature> {
154
- typedef v8::Local<v8::FunctionTemplate> FTH;
155
- static inline return_t New(FTH receiver = FTH());
156
- };
157
-
158
- template <>
159
- struct Factory<v8::String> : MaybeFactoryBase<v8::String> {
160
- static inline return_t New();
161
- static inline return_t New(const char *value, int length = -1);
162
- static inline return_t New(const uint16_t *value, int length = -1);
163
- static inline return_t New(std::string const& value);
164
-
165
- static inline return_t New(v8::String::ExternalStringResource * value);
166
- static inline return_t New(ExternalOneByteStringResource * value);
167
- };
168
-
169
- template <>
170
- struct Factory<v8::StringObject> : FactoryBase<v8::StringObject> {
171
- static inline return_t New(v8::Local<v8::String> value);
172
- };
173
-
174
- } // end of namespace imp
175
-
176
- #if (NODE_MODULE_VERSION >= 12)
177
-
178
- namespace imp {
179
-
180
- template <>
181
- struct Factory<v8::UnboundScript> : MaybeFactoryBase<v8::UnboundScript> {
182
- static inline return_t New( v8::Local<v8::String> source);
183
- static inline return_t New( v8::Local<v8::String> source
184
- , v8::ScriptOrigin const& origin);
185
- };
186
-
187
- } // end of namespace imp
188
-
189
- # include "nan_implementation_12_inl.h"
190
-
191
- #else // NODE_MODULE_VERSION >= 12
192
-
193
- # include "nan_implementation_pre_12_inl.h"
194
-
195
- #endif
196
-
197
- //=== API ======================================================================
198
-
199
- template <typename T>
200
- typename imp::Factory<T>::return_t
201
- New() {
202
- return imp::Factory<T>::New();
203
- }
204
-
205
- template <typename T, typename A0>
206
- typename imp::Factory<T>::return_t
207
- New(A0 arg0) {
208
- return imp::Factory<T>::New(arg0);
209
- }
210
-
211
- template <typename T, typename A0, typename A1>
212
- typename imp::Factory<T>::return_t
213
- New(A0 arg0, A1 arg1) {
214
- return imp::Factory<T>::New(arg0, arg1);
215
- }
216
-
217
- template <typename T, typename A0, typename A1, typename A2>
218
- typename imp::Factory<T>::return_t
219
- New(A0 arg0, A1 arg1, A2 arg2) {
220
- return imp::Factory<T>::New(arg0, arg1, arg2);
221
- }
222
-
223
- template <typename T, typename A0, typename A1, typename A2, typename A3>
224
- typename imp::Factory<T>::return_t
225
- New(A0 arg0, A1 arg1, A2 arg2, A3 arg3) {
226
- return imp::Factory<T>::New(arg0, arg1, arg2, arg3);
227
- }
228
-
229
- // Note(agnat): When passing overloaded function pointers to template functions
230
- // as generic arguments the compiler needs help in picking the right overload.
231
- // These two functions handle New<Function> and New<FunctionTemplate> with
232
- // all argument variations.
233
-
234
- // v8::Function and v8::FunctionTemplate with one or two arguments
235
- template <typename T>
236
- typename imp::Factory<T>::return_t
237
- New( FunctionCallback callback
238
- , v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
239
- return imp::Factory<T>::New(callback, data);
240
- }
241
-
242
- // v8::Function and v8::FunctionTemplate with three arguments
243
- template <typename T, typename A2>
244
- typename imp::Factory<T>::return_t
245
- New( FunctionCallback callback
246
- , v8::Local<v8::Value> data = v8::Local<v8::Value>()
247
- , A2 a2 = A2()) {
248
- return imp::Factory<T>::New(callback, data, a2);
249
- }
250
-
251
- // Convenience
252
-
253
- #if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
254
- template <typename T> inline v8::Local<T> New(v8::Handle<T> h);
255
- #endif
256
-
257
- #if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
258
- template <typename T, typename M>
259
- inline v8::Local<T> New(v8::Persistent<T, M> const& p);
260
- #else
261
- template <typename T> inline v8::Local<T> New(v8::Persistent<T> const& p);
262
- #endif
263
- template <typename T, typename M>
264
- inline v8::Local<T> New(Persistent<T, M> const& p);
265
- template <typename T>
266
- inline v8::Local<T> New(Global<T> const& p);
267
-
268
- inline
269
- imp::Factory<v8::Boolean>::return_t
270
- New(bool value) {
271
- return New<v8::Boolean>(value);
272
- }
273
-
274
- inline
275
- imp::Factory<v8::Int32>::return_t
276
- New(int32_t value) {
277
- return New<v8::Int32>(value);
278
- }
279
-
280
- inline
281
- imp::Factory<v8::Uint32>::return_t
282
- New(uint32_t value) {
283
- return New<v8::Uint32>(value);
284
- }
285
-
286
- inline
287
- imp::Factory<v8::Number>::return_t
288
- New(double value) {
289
- return New<v8::Number>(value);
290
- }
291
-
292
- inline
293
- imp::Factory<v8::String>::return_t
294
- New(std::string const& value) { // NOLINT(build/include_what_you_use)
295
- return New<v8::String>(value);
296
- }
297
-
298
- inline
299
- imp::Factory<v8::String>::return_t
300
- New(const char * value, int length) {
301
- return New<v8::String>(value, length);
302
- }
303
-
304
- inline
305
- imp::Factory<v8::String>::return_t
306
- New(const uint16_t * value, int length) {
307
- return New<v8::String>(value, length);
308
- }
309
-
310
- inline
311
- imp::Factory<v8::String>::return_t
312
- New(const char * value) {
313
- return New<v8::String>(value);
314
- }
315
-
316
- inline
317
- imp::Factory<v8::String>::return_t
318
- New(const uint16_t * value) {
319
- return New<v8::String>(value);
320
- }
321
-
322
- inline
323
- imp::Factory<v8::String>::return_t
324
- New(v8::String::ExternalStringResource * value) {
325
- return New<v8::String>(value);
326
- }
327
-
328
- inline
329
- imp::Factory<v8::String>::return_t
330
- New(ExternalOneByteStringResource * value) {
331
- return New<v8::String>(value);
332
- }
333
-
334
- inline
335
- imp::Factory<v8::RegExp>::return_t
336
- New(v8::Local<v8::String> pattern, v8::RegExp::Flags flags) {
337
- return New<v8::RegExp>(pattern, flags);
338
- }
339
-
340
- #endif // NAN_NEW_H_
@@ -1,156 +0,0 @@
1
- /*********************************************************************
2
- * NAN - Native Abstractions for Node.js
3
- *
4
- * Copyright (c) 2018 NAN contributors
5
- *
6
- * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
7
- ********************************************************************/
8
-
9
- #ifndef NAN_OBJECT_WRAP_H_
10
- #define NAN_OBJECT_WRAP_H_
11
-
12
- class ObjectWrap {
13
- public:
14
- ObjectWrap() {
15
- refs_ = 0;
16
- }
17
-
18
-
19
- virtual ~ObjectWrap() {
20
- if (persistent().IsEmpty()) {
21
- return;
22
- }
23
-
24
- persistent().ClearWeak();
25
- persistent().Reset();
26
- }
27
-
28
-
29
- template <class T>
30
- static inline T* Unwrap(v8::Local<v8::Object> object) {
31
- assert(!object.IsEmpty());
32
- assert(object->InternalFieldCount() > 0);
33
- // Cast to ObjectWrap before casting to T. A direct cast from void
34
- // to T won't work right when T has more than one base class.
35
- void* ptr = GetInternalFieldPointer(object, 0);
36
- ObjectWrap* wrap = static_cast<ObjectWrap*>(ptr);
37
- return static_cast<T*>(wrap);
38
- }
39
-
40
-
41
- inline v8::Local<v8::Object> handle() const {
42
- return New(handle_);
43
- }
44
-
45
-
46
- inline Persistent<v8::Object>& persistent() {
47
- return handle_;
48
- }
49
-
50
-
51
- protected:
52
- inline void Wrap(v8::Local<v8::Object> object) {
53
- assert(persistent().IsEmpty());
54
- assert(object->InternalFieldCount() > 0);
55
- SetInternalFieldPointer(object, 0, this);
56
- persistent().Reset(object);
57
- MakeWeak();
58
- }
59
-
60
- #if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
61
- (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
62
-
63
- inline void MakeWeak() {
64
- persistent().v8::PersistentBase<v8::Object>::SetWeak(
65
- this, WeakCallback, v8::WeakCallbackType::kParameter);
66
- #if NODE_MAJOR_VERSION < 10
67
- // FIXME(bnoordhuis) Probably superfluous in older Node.js versions too.
68
- persistent().MarkIndependent();
69
- #endif
70
- }
71
-
72
- #elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
73
-
74
- inline void MakeWeak() {
75
- persistent().v8::PersistentBase<v8::Object>::SetWeak(this, WeakCallback);
76
- persistent().MarkIndependent();
77
- }
78
-
79
- #else
80
-
81
- inline void MakeWeak() {
82
- persistent().persistent.MakeWeak(this, WeakCallback);
83
- persistent().MarkIndependent();
84
- }
85
-
86
- #endif
87
-
88
- /* Ref() marks the object as being attached to an event loop.
89
- * Refed objects will not be garbage collected, even if
90
- * all references are lost.
91
- */
92
- virtual void Ref() {
93
- assert(!persistent().IsEmpty());
94
- persistent().ClearWeak();
95
- refs_++;
96
- }
97
-
98
- /* Unref() marks an object as detached from the event loop. This is its
99
- * default state. When an object with a "weak" reference changes from
100
- * attached to detached state it will be freed. Be careful not to access
101
- * the object after making this call as it might be gone!
102
- * (A "weak reference" means an object that only has a
103
- * persistent handle.)
104
- *
105
- * DO NOT CALL THIS FROM DESTRUCTOR
106
- */
107
- virtual void Unref() {
108
- assert(!persistent().IsEmpty());
109
- assert(!persistent().IsWeak());
110
- assert(refs_ > 0);
111
- if (--refs_ == 0)
112
- MakeWeak();
113
- }
114
-
115
- int refs_; // ro
116
-
117
- private:
118
- NAN_DISALLOW_ASSIGN_COPY_MOVE(ObjectWrap)
119
- #if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
120
- (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
121
-
122
- static void
123
- WeakCallback(v8::WeakCallbackInfo<ObjectWrap> const& info) {
124
- ObjectWrap* wrap = info.GetParameter();
125
- assert(wrap->refs_ == 0);
126
- wrap->handle_.Reset();
127
- delete wrap;
128
- }
129
-
130
- #elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
131
-
132
- static void
133
- WeakCallback(v8::WeakCallbackData<v8::Object, ObjectWrap> const& data) {
134
- ObjectWrap* wrap = data.GetParameter();
135
- assert(wrap->refs_ == 0);
136
- assert(wrap->handle_.IsNearDeath());
137
- wrap->handle_.Reset();
138
- delete wrap;
139
- }
140
-
141
- #else
142
-
143
- static void WeakCallback(v8::Persistent<v8::Value> value, void *data) {
144
- ObjectWrap *wrap = static_cast<ObjectWrap*>(data);
145
- assert(wrap->refs_ == 0);
146
- assert(wrap->handle_.IsNearDeath());
147
- wrap->handle_.Reset();
148
- delete wrap;
149
- }
150
-
151
- #endif
152
- Persistent<v8::Object> handle_;
153
- };
154
-
155
-
156
- #endif // NAN_OBJECT_WRAP_H_
@@ -1,132 +0,0 @@
1
- /*********************************************************************
2
- * NAN - Native Abstractions for Node.js
3
- *
4
- * Copyright (c) 2018 NAN contributors
5
- *
6
- * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
7
- ********************************************************************/
8
-
9
- #ifndef NAN_PERSISTENT_12_INL_H_
10
- #define NAN_PERSISTENT_12_INL_H_
11
-
12
- template<typename T, typename M> class Persistent :
13
- public v8::Persistent<T, M> {
14
- public:
15
- inline Persistent() : v8::Persistent<T, M>() {}
16
-
17
- template<typename S> inline Persistent(v8::Local<S> that) :
18
- v8::Persistent<T, M>(v8::Isolate::GetCurrent(), that) {}
19
-
20
- template<typename S, typename M2>
21
- inline
22
- Persistent(const v8::Persistent<S, M2> &that) : // NOLINT(runtime/explicit)
23
- v8::Persistent<T, M2>(v8::Isolate::GetCurrent(), that) {}
24
-
25
- inline void Reset() { v8::PersistentBase<T>::Reset(); }
26
-
27
- template <typename S>
28
- inline void Reset(const v8::Local<S> &other) {
29
- v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
30
- }
31
-
32
- template <typename S>
33
- inline void Reset(const v8::PersistentBase<S> &other) {
34
- v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
35
- }
36
-
37
- template<typename P>
38
- inline void SetWeak(
39
- P *parameter
40
- , typename WeakCallbackInfo<P>::Callback callback
41
- , WeakCallbackType type);
42
-
43
- private:
44
- inline T *operator*() const { return *PersistentBase<T>::persistent; }
45
-
46
- template<typename S, typename M2>
47
- inline void Copy(const Persistent<S, M2> &that) {
48
- TYPE_CHECK(T, S);
49
-
50
- this->Reset();
51
-
52
- if (!that.IsEmpty()) {
53
- this->Reset(that);
54
- M::Copy(that, this);
55
- }
56
- }
57
- };
58
-
59
- #if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
60
- (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
61
- template<typename T>
62
- class Global : public v8::Global<T> {
63
- public:
64
- inline Global() : v8::Global<T>() {}
65
-
66
- template<typename S> inline Global(v8::Local<S> that) :
67
- v8::Global<T>(v8::Isolate::GetCurrent(), that) {}
68
-
69
- template<typename S>
70
- inline
71
- Global(const v8::PersistentBase<S> &that) : // NOLINT(runtime/explicit)
72
- v8::Global<S>(v8::Isolate::GetCurrent(), that) {}
73
-
74
- inline void Reset() { v8::PersistentBase<T>::Reset(); }
75
-
76
- template <typename S>
77
- inline void Reset(const v8::Local<S> &other) {
78
- v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
79
- }
80
-
81
- template <typename S>
82
- inline void Reset(const v8::PersistentBase<S> &other) {
83
- v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
84
- }
85
-
86
- template<typename P>
87
- inline void SetWeak(
88
- P *parameter
89
- , typename WeakCallbackInfo<P>::Callback callback
90
- , WeakCallbackType type) {
91
- reinterpret_cast<Persistent<T>*>(this)->SetWeak(
92
- parameter, callback, type);
93
- }
94
- };
95
- #else
96
- template<typename T>
97
- class Global : public v8::UniquePersistent<T> {
98
- public:
99
- inline Global() : v8::UniquePersistent<T>() {}
100
-
101
- template<typename S> inline Global(v8::Local<S> that) :
102
- v8::UniquePersistent<T>(v8::Isolate::GetCurrent(), that) {}
103
-
104
- template<typename S>
105
- inline
106
- Global(const v8::PersistentBase<S> &that) : // NOLINT(runtime/explicit)
107
- v8::UniquePersistent<S>(v8::Isolate::GetCurrent(), that) {}
108
-
109
- inline void Reset() { v8::PersistentBase<T>::Reset(); }
110
-
111
- template <typename S>
112
- inline void Reset(const v8::Local<S> &other) {
113
- v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
114
- }
115
-
116
- template <typename S>
117
- inline void Reset(const v8::PersistentBase<S> &other) {
118
- v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
119
- }
120
-
121
- template<typename P>
122
- inline void SetWeak(
123
- P *parameter
124
- , typename WeakCallbackInfo<P>::Callback callback
125
- , WeakCallbackType type) {
126
- reinterpret_cast<Persistent<T>*>(this)->SetWeak(
127
- parameter, callback, type);
128
- }
129
- };
130
- #endif
131
-
132
- #endif // NAN_PERSISTENT_12_INL_H_