mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: add KeyObjectHandle::HasInstance
In preparation for use by the QUIC implementation. PR-URL: https://github.com/nodejs/node/pull/45912 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
committed by
Node.js GitHub Bot
parent
a689c4dcb8
commit
c33c447b2a
@@ -889,33 +889,36 @@ size_t KeyObjectData::GetSymmetricKeySize() const {
|
||||
return symmetric_key_.size();
|
||||
}
|
||||
|
||||
bool KeyObjectHandle::HasInstance(Environment* env, Local<Value> value) {
|
||||
Local<FunctionTemplate> t = env->crypto_key_object_handle_constructor();
|
||||
return !t.IsEmpty() && t->HasInstance(value);
|
||||
}
|
||||
|
||||
v8::Local<v8::Function> KeyObjectHandle::Initialize(Environment* env) {
|
||||
Local<Function> templ = env->crypto_key_object_handle_constructor();
|
||||
if (!templ.IsEmpty()) {
|
||||
return templ;
|
||||
Local<FunctionTemplate> templ = env->crypto_key_object_handle_constructor();
|
||||
if (templ.IsEmpty()) {
|
||||
Isolate* isolate = env->isolate();
|
||||
templ = NewFunctionTemplate(isolate, New);
|
||||
templ->InstanceTemplate()->SetInternalFieldCount(
|
||||
KeyObjectHandle::kInternalFieldCount);
|
||||
templ->Inherit(BaseObject::GetConstructorTemplate(env));
|
||||
|
||||
SetProtoMethod(isolate, templ, "init", Init);
|
||||
SetProtoMethodNoSideEffect(
|
||||
isolate, templ, "getSymmetricKeySize", GetSymmetricKeySize);
|
||||
SetProtoMethodNoSideEffect(
|
||||
isolate, templ, "getAsymmetricKeyType", GetAsymmetricKeyType);
|
||||
SetProtoMethod(isolate, templ, "export", Export);
|
||||
SetProtoMethod(isolate, templ, "exportJwk", ExportJWK);
|
||||
SetProtoMethod(isolate, templ, "initECRaw", InitECRaw);
|
||||
SetProtoMethod(isolate, templ, "initEDRaw", InitEDRaw);
|
||||
SetProtoMethod(isolate, templ, "initJwk", InitJWK);
|
||||
SetProtoMethod(isolate, templ, "keyDetail", GetKeyDetail);
|
||||
SetProtoMethod(isolate, templ, "equals", Equals);
|
||||
|
||||
env->set_crypto_key_object_handle_constructor(templ);
|
||||
}
|
||||
Isolate* isolate = env->isolate();
|
||||
Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(
|
||||
KeyObjectHandle::kInternalFieldCount);
|
||||
t->Inherit(BaseObject::GetConstructorTemplate(env));
|
||||
|
||||
SetProtoMethod(isolate, t, "init", Init);
|
||||
SetProtoMethodNoSideEffect(
|
||||
isolate, t, "getSymmetricKeySize", GetSymmetricKeySize);
|
||||
SetProtoMethodNoSideEffect(
|
||||
isolate, t, "getAsymmetricKeyType", GetAsymmetricKeyType);
|
||||
SetProtoMethod(isolate, t, "export", Export);
|
||||
SetProtoMethod(isolate, t, "exportJwk", ExportJWK);
|
||||
SetProtoMethod(isolate, t, "initECRaw", InitECRaw);
|
||||
SetProtoMethod(isolate, t, "initEDRaw", InitEDRaw);
|
||||
SetProtoMethod(isolate, t, "initJwk", InitJWK);
|
||||
SetProtoMethod(isolate, t, "keyDetail", GetKeyDetail);
|
||||
SetProtoMethod(isolate, t, "equals", Equals);
|
||||
|
||||
auto function = t->GetFunction(env->context()).ToLocalChecked();
|
||||
env->set_crypto_key_object_handle_constructor(function);
|
||||
return function;
|
||||
return templ->GetFunction(env->context()).ToLocalChecked();
|
||||
}
|
||||
|
||||
void KeyObjectHandle::RegisterExternalReferences(
|
||||
|
||||
@@ -163,6 +163,7 @@ class KeyObjectData : public MemoryRetainer {
|
||||
|
||||
class KeyObjectHandle : public BaseObject {
|
||||
public:
|
||||
static bool HasInstance(Environment* env, v8::Local<v8::Value> value);
|
||||
static v8::Local<v8::Function> Initialize(Environment* env);
|
||||
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
||||
|
||||
|
||||
@@ -332,6 +332,7 @@
|
||||
V(contextify_global_template, v8::ObjectTemplate) \
|
||||
V(contextify_wrapper_template, v8::ObjectTemplate) \
|
||||
V(compiled_fn_entry_template, v8::ObjectTemplate) \
|
||||
V(crypto_key_object_handle_constructor, v8::FunctionTemplate) \
|
||||
V(env_proxy_template, v8::ObjectTemplate) \
|
||||
V(env_proxy_ctor_template, v8::FunctionTemplate) \
|
||||
V(dir_instance_template, v8::ObjectTemplate) \
|
||||
@@ -374,7 +375,6 @@
|
||||
V(async_hooks_promise_resolve_function, v8::Function) \
|
||||
V(buffer_prototype_object, v8::Object) \
|
||||
V(crypto_key_object_constructor, v8::Function) \
|
||||
V(crypto_key_object_handle_constructor, v8::Function) \
|
||||
V(crypto_key_object_private_constructor, v8::Function) \
|
||||
V(crypto_key_object_public_constructor, v8::Function) \
|
||||
V(crypto_key_object_secret_constructor, v8::Function) \
|
||||
|
||||
Reference in New Issue
Block a user