@contrast/agent 4.5.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/VERSION +1 -1
- package/bin/linux/contrast-service +0 -0
- package/bin/mac/contrast-service +0 -0
- package/bin/windows/contrast-service.exe +0 -0
- package/lib/assess/membrane/source-membrane.js +4 -18
- package/lib/assess/policy/propagators.json +11 -21
- package/lib/assess/policy/rules.json +5 -0
- package/lib/assess/policy/signatures.json +15 -0
- package/lib/assess/propagators/dustjs/escape-html.js +22 -0
- package/lib/assess/propagators/dustjs/escape-js.js +22 -0
- package/lib/assess/propagators/encode-uri/encode-uri-component.js +22 -0
- package/lib/assess/propagators/encode-uri/encode-uri.js +22 -0
- package/lib/assess/propagators/index.js +0 -2
- package/lib/assess/propagators/joi/values.js +26 -11
- package/lib/assess/propagators/mustache/escape.js +22 -0
- package/lib/assess/propagators/path/common.js +155 -46
- package/lib/assess/propagators/path/join.js +5 -1
- package/lib/assess/propagators/path/normalize.js +1 -2
- package/lib/assess/propagators/path/resolve.js +11 -2
- package/lib/assess/propagators/template-escape.js +84 -0
- package/lib/assess/propagators/templates.js +2 -3
- package/lib/assess/sinks/dustjs-linkedin-xss.js +131 -0
- package/lib/core/arch-components/dynamodb.js +1 -2
- package/lib/core/arch-components/dynamodbv3.js +44 -0
- package/lib/core/arch-components/index.js +1 -0
- package/lib/core/arch-components/rethinkdb.js +53 -0
- package/lib/core/async-storage/hooks/bluebird.js +20 -0
- package/lib/core/config/options.js +2 -1
- package/lib/core/stacktrace.js +3 -4
- package/lib/feature-set.js +2 -1
- package/lib/hooks/frameworks/base.js +8 -2
- package/lib/hooks/frameworks/http.js +23 -16
- package/lib/hooks/frameworks/http2.js +73 -0
- package/lib/hooks/frameworks/index.js +8 -3
- package/lib/hooks/http.js +112 -128
- package/lib/hooks/patcher.js +69 -48
- package/lib/hooks/require.js +16 -22
- package/lib/instrumentation.js +0 -3
- package/lib/protect/rules/cmd-injection-command-backdoors/backdoor-detector.js +3 -3
- package/lib/protect/rules/signatures/reflected-xss/helpers/function-call.js +1 -1
- package/lib/protect/rules/xss/helpers/function-call.js +1 -1
- package/lib/util/clean-stack.js +1 -1
- package/lib/util/clean-string/brackets.js +3 -3
- package/lib/util/ip-analyzer.js +1 -1
- package/lib/util/some.js +27 -0
- package/lib/util/source-map.js +1 -1
- package/lib/util/xml-analyzer/external-entity-finder.js +1 -1
- package/package.json +14 -16
- package/lib/hooks/frameworks/https.js +0 -42
- package/node_modules/bindings/LICENSE.md +0 -22
- package/node_modules/bindings/README.md +0 -98
- package/node_modules/bindings/bindings.js +0 -221
- package/node_modules/bindings/package.json +0 -32
- package/node_modules/file-uri-to-path/.npmignore +0 -1
- package/node_modules/file-uri-to-path/.travis.yml +0 -30
- package/node_modules/file-uri-to-path/History.md +0 -21
- package/node_modules/file-uri-to-path/LICENSE +0 -20
- package/node_modules/file-uri-to-path/README.md +0 -74
- package/node_modules/file-uri-to-path/index.d.ts +0 -2
- package/node_modules/file-uri-to-path/index.js +0 -66
- package/node_modules/file-uri-to-path/package.json +0 -36
- package/node_modules/file-uri-to-path/test/test.js +0 -24
- package/node_modules/file-uri-to-path/test/tests.json +0 -13
- package/node_modules/glossy/LICENSE +0 -19
- package/node_modules/glossy/README.md +0 -129
- package/node_modules/glossy/index.js +0 -12
- package/node_modules/glossy/lib/glossy/parse.js +0 -520
- package/node_modules/glossy/lib/glossy/produce.js +0 -459
- package/node_modules/glossy/package.json +0 -47
- package/node_modules/glossy/test/decide.js +0 -7
- package/node_modules/glossy/test/decode_pri.js +0 -24
- package/node_modules/glossy/test/parse_3164.js +0 -104
- package/node_modules/glossy/test/parse_5424.js +0 -106
- package/node_modules/glossy/test/parse_5848.js +0 -40
- package/node_modules/glossy/test/parse_8601.js +0 -14
- package/node_modules/glossy/test/parse_rfc3339.js +0 -9
- package/node_modules/glossy/test/produce.js +0 -162
- package/node_modules/glossy/test/runner.js +0 -40
- package/node_modules/glossy/test/structure_data.js +0 -24
- package/node_modules/nan/CHANGELOG.md +0 -537
- package/node_modules/nan/LICENSE.md +0 -13
- package/node_modules/nan/README.md +0 -455
- package/node_modules/nan/doc/asyncworker.md +0 -146
- package/node_modules/nan/doc/buffers.md +0 -54
- package/node_modules/nan/doc/callback.md +0 -76
- package/node_modules/nan/doc/converters.md +0 -41
- package/node_modules/nan/doc/errors.md +0 -226
- package/node_modules/nan/doc/json.md +0 -62
- package/node_modules/nan/doc/maybe_types.md +0 -583
- package/node_modules/nan/doc/methods.md +0 -664
- package/node_modules/nan/doc/new.md +0 -147
- package/node_modules/nan/doc/node_misc.md +0 -123
- package/node_modules/nan/doc/object_wrappers.md +0 -263
- package/node_modules/nan/doc/persistent.md +0 -296
- package/node_modules/nan/doc/scopes.md +0 -73
- package/node_modules/nan/doc/script.md +0 -38
- package/node_modules/nan/doc/string_bytes.md +0 -62
- package/node_modules/nan/doc/v8_internals.md +0 -199
- package/node_modules/nan/doc/v8_misc.md +0 -85
- package/node_modules/nan/include_dirs.js +0 -1
- package/node_modules/nan/nan.h +0 -2898
- package/node_modules/nan/nan_callbacks.h +0 -88
- package/node_modules/nan/nan_callbacks_12_inl.h +0 -514
- package/node_modules/nan/nan_callbacks_pre_12_inl.h +0 -520
- package/node_modules/nan/nan_converters.h +0 -72
- package/node_modules/nan/nan_converters_43_inl.h +0 -68
- package/node_modules/nan/nan_converters_pre_43_inl.h +0 -42
- package/node_modules/nan/nan_define_own_property_helper.h +0 -29
- package/node_modules/nan/nan_implementation_12_inl.h +0 -430
- package/node_modules/nan/nan_implementation_pre_12_inl.h +0 -263
- package/node_modules/nan/nan_json.h +0 -166
- package/node_modules/nan/nan_maybe_43_inl.h +0 -356
- package/node_modules/nan/nan_maybe_pre_43_inl.h +0 -268
- package/node_modules/nan/nan_new.h +0 -340
- package/node_modules/nan/nan_object_wrap.h +0 -156
- package/node_modules/nan/nan_persistent_12_inl.h +0 -132
- package/node_modules/nan/nan_persistent_pre_12_inl.h +0 -242
- package/node_modules/nan/nan_private.h +0 -73
- package/node_modules/nan/nan_string_bytes.h +0 -305
- package/node_modules/nan/nan_typedarray_contents.h +0 -96
- package/node_modules/nan/nan_weak.h +0 -437
- package/node_modules/nan/package.json +0 -41
- package/node_modules/nan/tools/1to2.js +0 -412
- package/node_modules/nan/tools/README.md +0 -14
- package/node_modules/nan/tools/package.json +0 -19
- package/node_modules/unix-dgram/LICENSE +0 -13
- package/node_modules/unix-dgram/README.md +0 -107
- package/node_modules/unix-dgram/binding.gyp +0 -20
- package/node_modules/unix-dgram/build/Makefile +0 -324
- package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram/src/unix_dgram.o.d +0 -58
- package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram.node.d +0 -1
- package/node_modules/unix-dgram/build/Release/.deps/Release/unix_dgram.node.d +0 -1
- package/node_modules/unix-dgram/build/Release/obj.target/unix_dgram/src/unix_dgram.o +0 -0
- package/node_modules/unix-dgram/build/Release/obj.target/unix_dgram.node +0 -0
- package/node_modules/unix-dgram/build/Release/unix_dgram.node +0 -0
- package/node_modules/unix-dgram/build/binding.Makefile +0 -6
- package/node_modules/unix-dgram/build/config.gypi +0 -213
- package/node_modules/unix-dgram/build/unix_dgram.target.mk +0 -159
- package/node_modules/unix-dgram/lib/unix_dgram.js +0 -168
- package/node_modules/unix-dgram/package.json +0 -36
- package/node_modules/unix-dgram/src/unix_dgram.cc +0 -404
- package/node_modules/unix-dgram/src/win_dummy.cc +0 -7
- package/node_modules/unix-dgram/test/test-connect-callback.js +0 -68
- package/node_modules/unix-dgram/test/test-connect.js +0 -53
- package/node_modules/unix-dgram/test/test-dgram-unix.js +0 -58
- package/node_modules/unix-dgram/test/test-send-error.js +0 -26
- package/node_modules/winston-syslog/.eslintrc +0 -7
- package/node_modules/winston-syslog/.travis.yml +0 -14
- package/node_modules/winston-syslog/CHANGELOG.md +0 -9
- package/node_modules/winston-syslog/LICENSE +0 -20
- package/node_modules/winston-syslog/README.md +0 -135
- package/node_modules/winston-syslog/lib/utils.js +0 -26
- package/node_modules/winston-syslog/lib/winston-syslog.js +0 -385
- package/node_modules/winston-syslog/package.json +0 -56
- package/node_modules/winston-syslog/test/format-test.js +0 -122
- package/node_modules/winston-syslog/test/syslog-test.js +0 -95
- package/node_modules/winston-syslog/test/unix-connect-test.js +0 -133
|
@@ -1,242 +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_PRE_12_INL_H_
|
|
10
|
-
#define NAN_PERSISTENT_PRE_12_INL_H_
|
|
11
|
-
|
|
12
|
-
template<typename T>
|
|
13
|
-
class PersistentBase {
|
|
14
|
-
v8::Persistent<T> persistent;
|
|
15
|
-
template<typename U>
|
|
16
|
-
friend v8::Local<U> New(const PersistentBase<U> &p);
|
|
17
|
-
template<typename U, typename M>
|
|
18
|
-
friend v8::Local<U> New(const Persistent<U, M> &p);
|
|
19
|
-
template<typename U>
|
|
20
|
-
friend v8::Local<U> New(const Global<U> &p);
|
|
21
|
-
template<typename S> friend class ReturnValue;
|
|
22
|
-
|
|
23
|
-
public:
|
|
24
|
-
inline PersistentBase() :
|
|
25
|
-
persistent() {}
|
|
26
|
-
|
|
27
|
-
inline void Reset() {
|
|
28
|
-
persistent.Dispose();
|
|
29
|
-
persistent.Clear();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
template<typename S>
|
|
33
|
-
inline void Reset(const v8::Local<S> &other) {
|
|
34
|
-
TYPE_CHECK(T, S);
|
|
35
|
-
|
|
36
|
-
if (!persistent.IsEmpty()) {
|
|
37
|
-
persistent.Dispose();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (other.IsEmpty()) {
|
|
41
|
-
persistent.Clear();
|
|
42
|
-
} else {
|
|
43
|
-
persistent = v8::Persistent<T>::New(other);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
template<typename S>
|
|
48
|
-
inline void Reset(const PersistentBase<S> &other) {
|
|
49
|
-
TYPE_CHECK(T, S);
|
|
50
|
-
|
|
51
|
-
if (!persistent.IsEmpty()) {
|
|
52
|
-
persistent.Dispose();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (other.IsEmpty()) {
|
|
56
|
-
persistent.Clear();
|
|
57
|
-
} else {
|
|
58
|
-
persistent = v8::Persistent<T>::New(other.persistent);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
inline bool IsEmpty() const { return persistent.IsEmpty(); }
|
|
63
|
-
|
|
64
|
-
inline void Empty() { persistent.Clear(); }
|
|
65
|
-
|
|
66
|
-
template<typename S>
|
|
67
|
-
inline bool operator==(const PersistentBase<S> &that) const {
|
|
68
|
-
return this->persistent == that.persistent;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
template<typename S>
|
|
72
|
-
inline bool operator==(const v8::Local<S> &that) const {
|
|
73
|
-
return this->persistent == that;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
template<typename S>
|
|
77
|
-
inline bool operator!=(const PersistentBase<S> &that) const {
|
|
78
|
-
return !operator==(that);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
template<typename S>
|
|
82
|
-
inline bool operator!=(const v8::Local<S> &that) const {
|
|
83
|
-
return !operator==(that);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
template<typename P>
|
|
87
|
-
inline void SetWeak(
|
|
88
|
-
P *parameter
|
|
89
|
-
, typename WeakCallbackInfo<P>::Callback callback
|
|
90
|
-
, WeakCallbackType type);
|
|
91
|
-
|
|
92
|
-
inline void ClearWeak() { persistent.ClearWeak(); }
|
|
93
|
-
|
|
94
|
-
inline void MarkIndependent() { persistent.MarkIndependent(); }
|
|
95
|
-
|
|
96
|
-
inline bool IsIndependent() const { return persistent.IsIndependent(); }
|
|
97
|
-
|
|
98
|
-
inline bool IsNearDeath() const { return persistent.IsNearDeath(); }
|
|
99
|
-
|
|
100
|
-
inline bool IsWeak() const { return persistent.IsWeak(); }
|
|
101
|
-
|
|
102
|
-
private:
|
|
103
|
-
inline explicit PersistentBase(v8::Persistent<T> that) :
|
|
104
|
-
persistent(that) { }
|
|
105
|
-
inline explicit PersistentBase(T *val) : persistent(val) {}
|
|
106
|
-
template<typename S, typename M> friend class Persistent;
|
|
107
|
-
template<typename S> friend class Global;
|
|
108
|
-
friend class ObjectWrap;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
template<typename T>
|
|
112
|
-
class NonCopyablePersistentTraits {
|
|
113
|
-
public:
|
|
114
|
-
typedef Persistent<T, NonCopyablePersistentTraits<T> >
|
|
115
|
-
NonCopyablePersistent;
|
|
116
|
-
static const bool kResetInDestructor = false;
|
|
117
|
-
template<typename S, typename M>
|
|
118
|
-
inline static void Copy(const Persistent<S, M> &source,
|
|
119
|
-
NonCopyablePersistent *dest) {
|
|
120
|
-
Uncompilable<v8::Object>();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
template<typename O> inline static void Uncompilable() {
|
|
124
|
-
TYPE_CHECK(O, v8::Primitive);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
template<typename T>
|
|
129
|
-
struct CopyablePersistentTraits {
|
|
130
|
-
typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
|
|
131
|
-
static const bool kResetInDestructor = true;
|
|
132
|
-
template<typename S, typename M>
|
|
133
|
-
static inline void Copy(const Persistent<S, M> &source,
|
|
134
|
-
CopyablePersistent *dest) {}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
template<typename T, typename M> class Persistent :
|
|
138
|
-
public PersistentBase<T> {
|
|
139
|
-
public:
|
|
140
|
-
inline Persistent() {}
|
|
141
|
-
|
|
142
|
-
template<typename S> inline Persistent(v8::Handle<S> that)
|
|
143
|
-
: PersistentBase<T>(v8::Persistent<T>::New(that)) {
|
|
144
|
-
TYPE_CHECK(T, S);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
inline Persistent(const Persistent &that) : PersistentBase<T>() {
|
|
148
|
-
Copy(that);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
template<typename S, typename M2>
|
|
152
|
-
inline Persistent(const Persistent<S, M2> &that) :
|
|
153
|
-
PersistentBase<T>() {
|
|
154
|
-
Copy(that);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
inline Persistent &operator=(const Persistent &that) {
|
|
158
|
-
Copy(that);
|
|
159
|
-
return *this;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
template <class S, class M2>
|
|
163
|
-
inline Persistent &operator=(const Persistent<S, M2> &that) {
|
|
164
|
-
Copy(that);
|
|
165
|
-
return *this;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
inline ~Persistent() {
|
|
169
|
-
if (M::kResetInDestructor) this->Reset();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private:
|
|
173
|
-
inline T *operator*() const { return *PersistentBase<T>::persistent; }
|
|
174
|
-
|
|
175
|
-
template<typename S, typename M2>
|
|
176
|
-
inline void Copy(const Persistent<S, M2> &that) {
|
|
177
|
-
TYPE_CHECK(T, S);
|
|
178
|
-
|
|
179
|
-
this->Reset();
|
|
180
|
-
|
|
181
|
-
if (!that.IsEmpty()) {
|
|
182
|
-
this->persistent = v8::Persistent<T>::New(that.persistent);
|
|
183
|
-
M::Copy(that, this);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
template<typename T>
|
|
189
|
-
class Global : public PersistentBase<T> {
|
|
190
|
-
struct RValue {
|
|
191
|
-
inline explicit RValue(Global* obj) : object(obj) {}
|
|
192
|
-
Global* object;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
public:
|
|
196
|
-
inline Global() : PersistentBase<T>(0) { }
|
|
197
|
-
|
|
198
|
-
template <typename S>
|
|
199
|
-
inline Global(v8::Local<S> that) // NOLINT(runtime/explicit)
|
|
200
|
-
: PersistentBase<T>(v8::Persistent<T>::New(that)) {
|
|
201
|
-
TYPE_CHECK(T, S);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
template <typename S>
|
|
205
|
-
inline Global(const PersistentBase<S> &that) // NOLINT(runtime/explicit)
|
|
206
|
-
: PersistentBase<T>(that) {
|
|
207
|
-
TYPE_CHECK(T, S);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Move constructor.
|
|
211
|
-
*/
|
|
212
|
-
inline Global(RValue rvalue) // NOLINT(runtime/explicit)
|
|
213
|
-
: PersistentBase<T>(rvalue.object->persistent) {
|
|
214
|
-
rvalue.object->Reset();
|
|
215
|
-
}
|
|
216
|
-
inline ~Global() { this->Reset(); }
|
|
217
|
-
/**
|
|
218
|
-
* Move via assignment.
|
|
219
|
-
*/
|
|
220
|
-
template<typename S>
|
|
221
|
-
inline Global &operator=(Global<S> rhs) {
|
|
222
|
-
TYPE_CHECK(T, S);
|
|
223
|
-
this->Reset(rhs.persistent);
|
|
224
|
-
rhs.Reset();
|
|
225
|
-
return *this;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Cast operator for moves.
|
|
229
|
-
*/
|
|
230
|
-
inline operator RValue() { return RValue(this); }
|
|
231
|
-
/**
|
|
232
|
-
* Pass allows returning uniques from functions, etc.
|
|
233
|
-
*/
|
|
234
|
-
Global Pass() { return Global(RValue(this)); }
|
|
235
|
-
|
|
236
|
-
private:
|
|
237
|
-
Global(Global &);
|
|
238
|
-
void operator=(Global &);
|
|
239
|
-
template<typename S> friend class ReturnValue;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
#endif // NAN_PERSISTENT_PRE_12_INL_H_
|
|
@@ -1,73 +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_PRIVATE_H_
|
|
10
|
-
#define NAN_PRIVATE_H_
|
|
11
|
-
|
|
12
|
-
inline Maybe<bool>
|
|
13
|
-
HasPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key) {
|
|
14
|
-
HandleScope scope;
|
|
15
|
-
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
|
16
|
-
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
|
17
|
-
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
18
|
-
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
|
19
|
-
return object->HasPrivate(context, private_key);
|
|
20
|
-
#else
|
|
21
|
-
return Just(!object->GetHiddenValue(key).IsEmpty());
|
|
22
|
-
#endif
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
inline MaybeLocal<v8::Value>
|
|
26
|
-
GetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key) {
|
|
27
|
-
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
|
28
|
-
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
|
29
|
-
v8::EscapableHandleScope scope(isolate);
|
|
30
|
-
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
31
|
-
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
|
32
|
-
v8::MaybeLocal<v8::Value> v = object->GetPrivate(context, private_key);
|
|
33
|
-
return scope.Escape(v.ToLocalChecked());
|
|
34
|
-
#else
|
|
35
|
-
EscapableHandleScope scope;
|
|
36
|
-
v8::Local<v8::Value> v = object->GetHiddenValue(key);
|
|
37
|
-
if (v.IsEmpty()) {
|
|
38
|
-
v = Undefined();
|
|
39
|
-
}
|
|
40
|
-
return scope.Escape(v);
|
|
41
|
-
#endif
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
inline Maybe<bool> SetPrivate(
|
|
45
|
-
v8::Local<v8::Object> object,
|
|
46
|
-
v8::Local<v8::String> key,
|
|
47
|
-
v8::Local<v8::Value> value) {
|
|
48
|
-
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
|
49
|
-
HandleScope scope;
|
|
50
|
-
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
|
51
|
-
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
52
|
-
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
|
53
|
-
return object->SetPrivate(context, private_key, value);
|
|
54
|
-
#else
|
|
55
|
-
return Just(object->SetHiddenValue(key, value));
|
|
56
|
-
#endif
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
inline Maybe<bool> DeletePrivate(
|
|
60
|
-
v8::Local<v8::Object> object,
|
|
61
|
-
v8::Local<v8::String> key) {
|
|
62
|
-
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
|
63
|
-
HandleScope scope;
|
|
64
|
-
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
|
65
|
-
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
|
66
|
-
return object->DeletePrivate(isolate->GetCurrentContext(), private_key);
|
|
67
|
-
#else
|
|
68
|
-
return Just(object->DeleteHiddenValue(key));
|
|
69
|
-
#endif
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
#endif // NAN_PRIVATE_H_
|
|
73
|
-
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
// Copyright Joyent, Inc. and other Node contributors.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
4
|
-
// copy of this software and associated documentation files (the
|
|
5
|
-
// "Software"), to deal in the Software without restriction, including
|
|
6
|
-
// without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
-
// persons to whom the Software is furnished to do so, subject to the
|
|
9
|
-
// following conditions:
|
|
10
|
-
//
|
|
11
|
-
// The above copyright notice and this permission notice shall be included
|
|
12
|
-
// in all copies or substantial portions of the Software.
|
|
13
|
-
//
|
|
14
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
17
|
-
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
19
|
-
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
20
|
-
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
-
|
|
22
|
-
#ifndef NAN_STRING_BYTES_H_
|
|
23
|
-
#define NAN_STRING_BYTES_H_
|
|
24
|
-
|
|
25
|
-
// Decodes a v8::Local<v8::String> or Buffer to a raw char*
|
|
26
|
-
|
|
27
|
-
namespace imp {
|
|
28
|
-
|
|
29
|
-
using v8::Local;
|
|
30
|
-
using v8::Object;
|
|
31
|
-
using v8::String;
|
|
32
|
-
using v8::Value;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//// Base 64 ////
|
|
36
|
-
|
|
37
|
-
#define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//// HEX ////
|
|
42
|
-
|
|
43
|
-
static bool contains_non_ascii_slow(const char* buf, size_t len) {
|
|
44
|
-
for (size_t i = 0; i < len; ++i) {
|
|
45
|
-
if (buf[i] & 0x80) return true;
|
|
46
|
-
}
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
static bool contains_non_ascii(const char* src, size_t len) {
|
|
52
|
-
if (len < 16) {
|
|
53
|
-
return contains_non_ascii_slow(src, len);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const unsigned bytes_per_word = sizeof(void*);
|
|
57
|
-
const unsigned align_mask = bytes_per_word - 1;
|
|
58
|
-
const unsigned unaligned = reinterpret_cast<uintptr_t>(src) & align_mask;
|
|
59
|
-
|
|
60
|
-
if (unaligned > 0) {
|
|
61
|
-
const unsigned n = bytes_per_word - unaligned;
|
|
62
|
-
if (contains_non_ascii_slow(src, n)) return true;
|
|
63
|
-
src += n;
|
|
64
|
-
len -= n;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
#if defined(__x86_64__) || defined(_WIN64)
|
|
69
|
-
const uintptr_t mask = 0x8080808080808080ll;
|
|
70
|
-
#else
|
|
71
|
-
const uintptr_t mask = 0x80808080l;
|
|
72
|
-
#endif
|
|
73
|
-
|
|
74
|
-
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
|
|
75
|
-
|
|
76
|
-
for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
|
|
77
|
-
if (srcw[i] & mask) return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const unsigned remainder = len & align_mask;
|
|
81
|
-
if (remainder > 0) {
|
|
82
|
-
const size_t offset = len - remainder;
|
|
83
|
-
if (contains_non_ascii_slow(src + offset, remainder)) return true;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
static void force_ascii_slow(const char* src, char* dst, size_t len) {
|
|
91
|
-
for (size_t i = 0; i < len; ++i) {
|
|
92
|
-
dst[i] = src[i] & 0x7f;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
static void force_ascii(const char* src, char* dst, size_t len) {
|
|
98
|
-
if (len < 16) {
|
|
99
|
-
force_ascii_slow(src, dst, len);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const unsigned bytes_per_word = sizeof(void*);
|
|
104
|
-
const unsigned align_mask = bytes_per_word - 1;
|
|
105
|
-
const unsigned src_unalign = reinterpret_cast<uintptr_t>(src) & align_mask;
|
|
106
|
-
const unsigned dst_unalign = reinterpret_cast<uintptr_t>(dst) & align_mask;
|
|
107
|
-
|
|
108
|
-
if (src_unalign > 0) {
|
|
109
|
-
if (src_unalign == dst_unalign) {
|
|
110
|
-
const unsigned unalign = bytes_per_word - src_unalign;
|
|
111
|
-
force_ascii_slow(src, dst, unalign);
|
|
112
|
-
src += unalign;
|
|
113
|
-
dst += unalign;
|
|
114
|
-
len -= src_unalign;
|
|
115
|
-
} else {
|
|
116
|
-
force_ascii_slow(src, dst, len);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
#if defined(__x86_64__) || defined(_WIN64)
|
|
122
|
-
const uintptr_t mask = ~0x8080808080808080ll;
|
|
123
|
-
#else
|
|
124
|
-
const uintptr_t mask = ~0x80808080l;
|
|
125
|
-
#endif
|
|
126
|
-
|
|
127
|
-
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
|
|
128
|
-
uintptr_t* dstw = reinterpret_cast<uintptr_t*>(dst);
|
|
129
|
-
|
|
130
|
-
for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
|
|
131
|
-
dstw[i] = srcw[i] & mask;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const unsigned remainder = len & align_mask;
|
|
135
|
-
if (remainder > 0) {
|
|
136
|
-
const size_t offset = len - remainder;
|
|
137
|
-
force_ascii_slow(src + offset, dst + offset, remainder);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
static size_t base64_encode(const char* src,
|
|
143
|
-
size_t slen,
|
|
144
|
-
char* dst,
|
|
145
|
-
size_t dlen) {
|
|
146
|
-
// We know how much we'll write, just make sure that there's space.
|
|
147
|
-
assert(dlen >= base64_encoded_size(slen) &&
|
|
148
|
-
"not enough space provided for base64 encode");
|
|
149
|
-
|
|
150
|
-
dlen = base64_encoded_size(slen);
|
|
151
|
-
|
|
152
|
-
unsigned a;
|
|
153
|
-
unsigned b;
|
|
154
|
-
unsigned c;
|
|
155
|
-
unsigned i;
|
|
156
|
-
unsigned k;
|
|
157
|
-
unsigned n;
|
|
158
|
-
|
|
159
|
-
static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
160
|
-
"abcdefghijklmnopqrstuvwxyz"
|
|
161
|
-
"0123456789+/";
|
|
162
|
-
|
|
163
|
-
i = 0;
|
|
164
|
-
k = 0;
|
|
165
|
-
n = slen / 3 * 3;
|
|
166
|
-
|
|
167
|
-
while (i < n) {
|
|
168
|
-
a = src[i + 0] & 0xff;
|
|
169
|
-
b = src[i + 1] & 0xff;
|
|
170
|
-
c = src[i + 2] & 0xff;
|
|
171
|
-
|
|
172
|
-
dst[k + 0] = table[a >> 2];
|
|
173
|
-
dst[k + 1] = table[((a & 3) << 4) | (b >> 4)];
|
|
174
|
-
dst[k + 2] = table[((b & 0x0f) << 2) | (c >> 6)];
|
|
175
|
-
dst[k + 3] = table[c & 0x3f];
|
|
176
|
-
|
|
177
|
-
i += 3;
|
|
178
|
-
k += 4;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (n != slen) {
|
|
182
|
-
switch (slen - n) {
|
|
183
|
-
case 1:
|
|
184
|
-
a = src[i + 0] & 0xff;
|
|
185
|
-
dst[k + 0] = table[a >> 2];
|
|
186
|
-
dst[k + 1] = table[(a & 3) << 4];
|
|
187
|
-
dst[k + 2] = '=';
|
|
188
|
-
dst[k + 3] = '=';
|
|
189
|
-
break;
|
|
190
|
-
|
|
191
|
-
case 2:
|
|
192
|
-
a = src[i + 0] & 0xff;
|
|
193
|
-
b = src[i + 1] & 0xff;
|
|
194
|
-
dst[k + 0] = table[a >> 2];
|
|
195
|
-
dst[k + 1] = table[((a & 3) << 4) | (b >> 4)];
|
|
196
|
-
dst[k + 2] = table[(b & 0x0f) << 2];
|
|
197
|
-
dst[k + 3] = '=';
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return dlen;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) {
|
|
207
|
-
// We know how much we'll write, just make sure that there's space.
|
|
208
|
-
assert(dlen >= slen * 2 &&
|
|
209
|
-
"not enough space provided for hex encode");
|
|
210
|
-
|
|
211
|
-
dlen = slen * 2;
|
|
212
|
-
for (uint32_t i = 0, k = 0; k < dlen; i += 1, k += 2) {
|
|
213
|
-
static const char hex[] = "0123456789abcdef";
|
|
214
|
-
uint8_t val = static_cast<uint8_t>(src[i]);
|
|
215
|
-
dst[k + 0] = hex[val >> 4];
|
|
216
|
-
dst[k + 1] = hex[val & 15];
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return dlen;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
static Local<Value> Encode(const char* buf,
|
|
225
|
-
size_t buflen,
|
|
226
|
-
enum Encoding encoding) {
|
|
227
|
-
assert(buflen <= node::Buffer::kMaxLength);
|
|
228
|
-
if (!buflen && encoding != BUFFER)
|
|
229
|
-
return New("").ToLocalChecked();
|
|
230
|
-
|
|
231
|
-
Local<String> val;
|
|
232
|
-
switch (encoding) {
|
|
233
|
-
case BUFFER:
|
|
234
|
-
return CopyBuffer(buf, buflen).ToLocalChecked();
|
|
235
|
-
|
|
236
|
-
case ASCII:
|
|
237
|
-
if (contains_non_ascii(buf, buflen)) {
|
|
238
|
-
char* out = new char[buflen];
|
|
239
|
-
force_ascii(buf, out, buflen);
|
|
240
|
-
val = New<String>(out, buflen).ToLocalChecked();
|
|
241
|
-
delete[] out;
|
|
242
|
-
} else {
|
|
243
|
-
val = New<String>(buf, buflen).ToLocalChecked();
|
|
244
|
-
}
|
|
245
|
-
break;
|
|
246
|
-
|
|
247
|
-
case UTF8:
|
|
248
|
-
val = New<String>(buf, buflen).ToLocalChecked();
|
|
249
|
-
break;
|
|
250
|
-
|
|
251
|
-
case BINARY: {
|
|
252
|
-
// TODO(isaacs) use ExternalTwoByteString?
|
|
253
|
-
const unsigned char *cbuf = reinterpret_cast<const unsigned char*>(buf);
|
|
254
|
-
uint16_t * twobytebuf = new uint16_t[buflen];
|
|
255
|
-
for (size_t i = 0; i < buflen; i++) {
|
|
256
|
-
// XXX is the following line platform independent?
|
|
257
|
-
twobytebuf[i] = cbuf[i];
|
|
258
|
-
}
|
|
259
|
-
val = New<String>(twobytebuf, buflen).ToLocalChecked();
|
|
260
|
-
delete[] twobytebuf;
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
case BASE64: {
|
|
265
|
-
size_t dlen = base64_encoded_size(buflen);
|
|
266
|
-
char* dst = new char[dlen];
|
|
267
|
-
|
|
268
|
-
size_t written = base64_encode(buf, buflen, dst, dlen);
|
|
269
|
-
assert(written == dlen);
|
|
270
|
-
|
|
271
|
-
val = New<String>(dst, dlen).ToLocalChecked();
|
|
272
|
-
delete[] dst;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
case UCS2: {
|
|
277
|
-
const uint16_t* data = reinterpret_cast<const uint16_t*>(buf);
|
|
278
|
-
val = New<String>(data, buflen / 2).ToLocalChecked();
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
case HEX: {
|
|
283
|
-
size_t dlen = buflen * 2;
|
|
284
|
-
char* dst = new char[dlen];
|
|
285
|
-
size_t written = hex_encode(buf, buflen, dst, dlen);
|
|
286
|
-
assert(written == dlen);
|
|
287
|
-
|
|
288
|
-
val = New<String>(dst, dlen).ToLocalChecked();
|
|
289
|
-
delete[] dst;
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
default:
|
|
294
|
-
assert(0 && "unknown encoding");
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return val;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
#undef base64_encoded_size
|
|
302
|
-
|
|
303
|
-
} // end of namespace imp
|
|
304
|
-
|
|
305
|
-
#endif // NAN_STRING_BYTES_H_
|
|
@@ -1,96 +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_TYPEDARRAY_CONTENTS_H_
|
|
10
|
-
#define NAN_TYPEDARRAY_CONTENTS_H_
|
|
11
|
-
|
|
12
|
-
template<typename T>
|
|
13
|
-
class TypedArrayContents {
|
|
14
|
-
public:
|
|
15
|
-
inline explicit TypedArrayContents(v8::Local<v8::Value> from) :
|
|
16
|
-
length_(0), data_(NULL) {
|
|
17
|
-
HandleScope scope;
|
|
18
|
-
|
|
19
|
-
size_t length = 0;
|
|
20
|
-
void* data = NULL;
|
|
21
|
-
|
|
22
|
-
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
|
23
|
-
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
|
24
|
-
|
|
25
|
-
if (from->IsArrayBufferView()) {
|
|
26
|
-
v8::Local<v8::ArrayBufferView> array =
|
|
27
|
-
v8::Local<v8::ArrayBufferView>::Cast(from);
|
|
28
|
-
|
|
29
|
-
const size_t byte_length = array->ByteLength();
|
|
30
|
-
const ptrdiff_t byte_offset = array->ByteOffset();
|
|
31
|
-
v8::Local<v8::ArrayBuffer> buffer = array->Buffer();
|
|
32
|
-
|
|
33
|
-
length = byte_length / sizeof(T);
|
|
34
|
-
// Actually it's 7.9 here but this would lead to ABI issues with Node.js 13
|
|
35
|
-
// using 7.8 till 13.2.0.
|
|
36
|
-
#if (V8_MAJOR_VERSION >= 8)
|
|
37
|
-
data = static_cast<char*>(buffer->GetBackingStore()->Data()) + byte_offset;
|
|
38
|
-
#else
|
|
39
|
-
data = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
|
|
40
|
-
#endif
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
#else
|
|
44
|
-
|
|
45
|
-
if (from->IsObject() && !from->IsNull()) {
|
|
46
|
-
v8::Local<v8::Object> array = v8::Local<v8::Object>::Cast(from);
|
|
47
|
-
|
|
48
|
-
MaybeLocal<v8::Value> buffer = Get(array,
|
|
49
|
-
New<v8::String>("buffer").ToLocalChecked());
|
|
50
|
-
MaybeLocal<v8::Value> byte_length = Get(array,
|
|
51
|
-
New<v8::String>("byteLength").ToLocalChecked());
|
|
52
|
-
MaybeLocal<v8::Value> byte_offset = Get(array,
|
|
53
|
-
New<v8::String>("byteOffset").ToLocalChecked());
|
|
54
|
-
|
|
55
|
-
if (!buffer.IsEmpty() &&
|
|
56
|
-
!byte_length.IsEmpty() && byte_length.ToLocalChecked()->IsUint32() &&
|
|
57
|
-
!byte_offset.IsEmpty() && byte_offset.ToLocalChecked()->IsUint32()) {
|
|
58
|
-
data = array->GetIndexedPropertiesExternalArrayData();
|
|
59
|
-
if(data) {
|
|
60
|
-
length = byte_length.ToLocalChecked()->Uint32Value() / sizeof(T);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
#endif
|
|
66
|
-
|
|
67
|
-
#if defined(_MSC_VER) && _MSC_VER >= 1900 || __cplusplus >= 201103L
|
|
68
|
-
assert(reinterpret_cast<uintptr_t>(data) % alignof (T) == 0);
|
|
69
|
-
#elif defined(_MSC_VER) && _MSC_VER >= 1600 || defined(__GNUC__)
|
|
70
|
-
assert(reinterpret_cast<uintptr_t>(data) % __alignof(T) == 0);
|
|
71
|
-
#else
|
|
72
|
-
assert(reinterpret_cast<uintptr_t>(data) % sizeof (T) == 0);
|
|
73
|
-
#endif
|
|
74
|
-
|
|
75
|
-
length_ = length;
|
|
76
|
-
data_ = static_cast<T*>(data);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
inline size_t length() const { return length_; }
|
|
80
|
-
inline T* operator*() { return data_; }
|
|
81
|
-
inline const T* operator*() const { return data_; }
|
|
82
|
-
|
|
83
|
-
private:
|
|
84
|
-
NAN_DISALLOW_ASSIGN_COPY_MOVE(TypedArrayContents)
|
|
85
|
-
|
|
86
|
-
//Disable heap allocation
|
|
87
|
-
void *operator new(size_t size);
|
|
88
|
-
void operator delete(void *, size_t) {
|
|
89
|
-
abort();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
size_t length_;
|
|
93
|
-
T* data_;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
#endif // NAN_TYPEDARRAY_CONTENTS_H_
|