GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: add KeyObjectHandle::HasInstance · nodejs/node@92fdb24

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • crypto
      • crypto_keys.cc
      • crypto_keys.h
    • env_properties.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/crypto/crypto_keys.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_keys.cc
+28-25Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -889,33 +889,36 @@ size_t KeyObjectData::GetSymmetricKeySize() const {
889889
return symmetric_key_.size();
890890
}
891891

892+
bool KeyObjectHandle::HasInstance(Environment* env, Local<Value> value) {
893+
Local<FunctionTemplate> t = env->crypto_key_object_handle_constructor();
894+
return !t.IsEmpty() && t->HasInstance(value);
895+
}
896+
892897
v8::Local<v8::Function> KeyObjectHandle::Initialize(Environment* env) {
893-
Local<Function> templ = env->crypto_key_object_handle_constructor();
894-
if (!templ.IsEmpty()) {
895-
return templ;
898+
Local<FunctionTemplate> templ = env->crypto_key_object_handle_constructor();
899+
if (templ.IsEmpty()) {
900+
Isolate* isolate = env->isolate();
901+
templ = NewFunctionTemplate(isolate, New);
902+
templ->InstanceTemplate()->SetInternalFieldCount(
903+
KeyObjectHandle::kInternalFieldCount);
904+
templ->Inherit(BaseObject::GetConstructorTemplate(env));
905+
906+
SetProtoMethod(isolate, templ, "init", Init);
907+
SetProtoMethodNoSideEffect(
908+
isolate, templ, "getSymmetricKeySize", GetSymmetricKeySize);
909+
SetProtoMethodNoSideEffect(
910+
isolate, templ, "getAsymmetricKeyType", GetAsymmetricKeyType);
911+
SetProtoMethod(isolate, templ, "export", Export);
912+
SetProtoMethod(isolate, templ, "exportJwk", ExportJWK);
913+
SetProtoMethod(isolate, templ, "initECRaw", InitECRaw);
914+
SetProtoMethod(isolate, templ, "initEDRaw", InitEDRaw);
915+
SetProtoMethod(isolate, templ, "initJwk", InitJWK);
916+
SetProtoMethod(isolate, templ, "keyDetail", GetKeyDetail);
917+
SetProtoMethod(isolate, templ, "equals", Equals);
918+
919+
env->set_crypto_key_object_handle_constructor(templ);
896920
}
897-
Isolate* isolate = env->isolate();
898-
Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New);
899-
t->InstanceTemplate()->SetInternalFieldCount(
900-
KeyObjectHandle::kInternalFieldCount);
901-
t->Inherit(BaseObject::GetConstructorTemplate(env));
902-
903-
SetProtoMethod(isolate, t, "init", Init);
904-
SetProtoMethodNoSideEffect(
905-
isolate, t, "getSymmetricKeySize", GetSymmetricKeySize);
906-
SetProtoMethodNoSideEffect(
907-
isolate, t, "getAsymmetricKeyType", GetAsymmetricKeyType);
908-
SetProtoMethod(isolate, t, "export", Export);
909-
SetProtoMethod(isolate, t, "exportJwk", ExportJWK);
910-
SetProtoMethod(isolate, t, "initECRaw", InitECRaw);
911-
SetProtoMethod(isolate, t, "initEDRaw", InitEDRaw);
912-
SetProtoMethod(isolate, t, "initJwk", InitJWK);
913-
SetProtoMethod(isolate, t, "keyDetail", GetKeyDetail);
914-
SetProtoMethod(isolate, t, "equals", Equals);
915-
916-
auto function = t->GetFunction(env->context()).ToLocalChecked();
917-
env->set_crypto_key_object_handle_constructor(function);
918-
return function;
921+
return templ->GetFunction(env->context()).ToLocalChecked();
919922
}
920923

921924
void KeyObjectHandle::RegisterExternalReferences(
Collapse file

‎src/crypto/crypto_keys.h‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_keys.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class KeyObjectData : public MemoryRetainer {
163163

164164
class KeyObjectHandle : public BaseObject {
165165
public:
166+
static bool HasInstance(Environment* env, v8::Local<v8::Value> value);
166167
static v8::Local<v8::Function> Initialize(Environment* env);
167168
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
168169

Collapse file

‎src/env_properties.h‎

Copy file name to clipboardExpand all lines: src/env_properties.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@
334334
V(contextify_global_template, v8::ObjectTemplate) \
335335
V(contextify_wrapper_template, v8::ObjectTemplate) \
336336
V(compiled_fn_entry_template, v8::ObjectTemplate) \
337+
V(crypto_key_object_handle_constructor, v8::FunctionTemplate) \
337338
V(env_proxy_template, v8::ObjectTemplate) \
338339
V(env_proxy_ctor_template, v8::FunctionTemplate) \
339340
V(dir_instance_template, v8::ObjectTemplate) \
@@ -376,7 +377,6 @@
376377
V(async_hooks_promise_resolve_function, v8::Function) \
377378
V(buffer_prototype_object, v8::Object) \
378379
V(crypto_key_object_constructor, v8::Function) \
379-
V(crypto_key_object_handle_constructor, v8::Function) \
380380
V(crypto_key_object_private_constructor, v8::Function) \
381381
V(crypto_key_object_public_constructor, v8::Function) \
382382
V(crypto_key_object_secret_constructor, v8::Function) \

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.