| 1 | /* |
| 2 | This file is part of the WebKit open source project. |
| 3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public License |
| 16 | along with this library; see the file COPYING.LIB. If not, write to |
| 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | |
| 23 | #if ENABLE(WEB_AUTHN) |
| 24 | |
| 25 | #include "JSCredentialsContainer.h" |
| 26 | |
| 27 | #include "JSBasicCredential.h" |
| 28 | #include "JSCredentialCreationOptions.h" |
| 29 | #include "JSCredentialRequestOptions.h" |
| 30 | #include "JSDOMBinding.h" |
| 31 | #include "JSDOMConstructorNotConstructable.h" |
| 32 | #include "JSDOMConvertDictionary.h" |
| 33 | #include "JSDOMConvertInterface.h" |
| 34 | #include "JSDOMExceptionHandling.h" |
| 35 | #include "JSDOMOperation.h" |
| 36 | #include "JSDOMOperationReturningPromise.h" |
| 37 | #include "JSDOMWrapperCache.h" |
| 38 | #include "ScriptExecutionContext.h" |
| 39 | #include <JavaScriptCore/FunctionPrototype.h> |
| 40 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 41 | #include <JavaScriptCore/JSCInlines.h> |
| 42 | #include <wtf/GetPtr.h> |
| 43 | #include <wtf/PointerPreparations.h> |
| 44 | #include <wtf/URL.h> |
| 45 | |
| 46 | |
| 47 | namespace WebCore { |
| 48 | using namespace JSC; |
| 49 | |
| 50 | // Functions |
| 51 | |
| 52 | JSC::EncodedJSValue JSC_HOST_CALL jsCredentialsContainerPrototypeFunctionGet(JSC::ExecState*); |
| 53 | JSC::EncodedJSValue JSC_HOST_CALL jsCredentialsContainerPrototypeFunctionStore(JSC::ExecState*); |
| 54 | JSC::EncodedJSValue JSC_HOST_CALL jsCredentialsContainerPrototypeFunctionCreate(JSC::ExecState*); |
| 55 | JSC::EncodedJSValue JSC_HOST_CALL jsCredentialsContainerPrototypeFunctionPreventSilentAccess(JSC::ExecState*); |
| 56 | |
| 57 | // Attributes |
| 58 | |
| 59 | JSC::EncodedJSValue jsCredentialsContainerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 60 | bool setJSCredentialsContainerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 61 | |
| 62 | class JSCredentialsContainerPrototype : public JSC::JSNonFinalObject { |
| 63 | public: |
| 64 | using Base = JSC::JSNonFinalObject; |
| 65 | static JSCredentialsContainerPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 66 | { |
| 67 | JSCredentialsContainerPrototype* ptr = new (NotNull, JSC::allocateCell<JSCredentialsContainerPrototype>(vm.heap)) JSCredentialsContainerPrototype(vm, globalObject, structure); |
| 68 | ptr->finishCreation(vm); |
| 69 | return ptr; |
| 70 | } |
| 71 | |
| 72 | DECLARE_INFO; |
| 73 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 74 | { |
| 75 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 76 | } |
| 77 | |
| 78 | private: |
| 79 | JSCredentialsContainerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 80 | : JSC::JSNonFinalObject(vm, structure) |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | void finishCreation(JSC::VM&); |
| 85 | }; |
| 86 | |
| 87 | using JSCredentialsContainerConstructor = JSDOMConstructorNotConstructable<JSCredentialsContainer>; |
| 88 | |
| 89 | template<> JSValue JSCredentialsContainerConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 90 | { |
| 91 | UNUSED_PARAM(vm); |
| 92 | return globalObject.functionPrototype(); |
| 93 | } |
| 94 | |
| 95 | template<> void JSCredentialsContainerConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 96 | { |
| 97 | putDirect(vm, vm.propertyNames->prototype, JSCredentialsContainer::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 98 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CredentialsContainer"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 99 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 100 | } |
| 101 | |
| 102 | template<> const ClassInfo JSCredentialsContainerConstructor::s_info = { "CredentialsContainer" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCredentialsContainerConstructor) }; |
| 103 | |
| 104 | /* Hash table for prototype */ |
| 105 | |
| 106 | static const HashTableValue JSCredentialsContainerPrototypeTableValues[] = |
| 107 | { |
| 108 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCredentialsContainerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCredentialsContainerConstructor) } }, |
| 109 | { "get" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCredentialsContainerPrototypeFunctionGet), (intptr_t) (0) } }, |
| 110 | { "store" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCredentialsContainerPrototypeFunctionStore), (intptr_t) (1) } }, |
| 111 | { "create" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCredentialsContainerPrototypeFunctionCreate), (intptr_t) (0) } }, |
| 112 | { "preventSilentAccess" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCredentialsContainerPrototypeFunctionPreventSilentAccess), (intptr_t) (0) } }, |
| 113 | }; |
| 114 | |
| 115 | const ClassInfo JSCredentialsContainerPrototype::s_info = { "CredentialsContainerPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCredentialsContainerPrototype) }; |
| 116 | |
| 117 | void JSCredentialsContainerPrototype::finishCreation(VM& vm) |
| 118 | { |
| 119 | Base::finishCreation(vm); |
| 120 | reifyStaticProperties(vm, JSCredentialsContainer::info(), JSCredentialsContainerPrototypeTableValues, *this); |
| 121 | } |
| 122 | |
| 123 | const ClassInfo JSCredentialsContainer::s_info = { "CredentialsContainer" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCredentialsContainer) }; |
| 124 | |
| 125 | JSCredentialsContainer::JSCredentialsContainer(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CredentialsContainer>&& impl) |
| 126 | : JSDOMWrapper<CredentialsContainer>(structure, globalObject, WTFMove(impl)) |
| 127 | { |
| 128 | } |
| 129 | |
| 130 | void JSCredentialsContainer::finishCreation(VM& vm) |
| 131 | { |
| 132 | Base::finishCreation(vm); |
| 133 | ASSERT(inherits(vm, info())); |
| 134 | |
| 135 | } |
| 136 | |
| 137 | JSObject* JSCredentialsContainer::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 138 | { |
| 139 | return JSCredentialsContainerPrototype::create(vm, &globalObject, JSCredentialsContainerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 140 | } |
| 141 | |
| 142 | JSObject* JSCredentialsContainer::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 143 | { |
| 144 | return getDOMPrototype<JSCredentialsContainer>(vm, globalObject); |
| 145 | } |
| 146 | |
| 147 | JSValue JSCredentialsContainer::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 148 | { |
| 149 | return getDOMConstructor<JSCredentialsContainerConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 150 | } |
| 151 | |
| 152 | void JSCredentialsContainer::destroy(JSC::JSCell* cell) |
| 153 | { |
| 154 | JSCredentialsContainer* thisObject = static_cast<JSCredentialsContainer*>(cell); |
| 155 | thisObject->JSCredentialsContainer::~JSCredentialsContainer(); |
| 156 | } |
| 157 | |
| 158 | template<> inline JSCredentialsContainer* IDLOperation<JSCredentialsContainer>::cast(ExecState& state) |
| 159 | { |
| 160 | return jsDynamicCast<JSCredentialsContainer*>(state.vm(), state.thisValue()); |
| 161 | } |
| 162 | |
| 163 | EncodedJSValue jsCredentialsContainerConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 164 | { |
| 165 | VM& vm = state->vm(); |
| 166 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 167 | auto* prototype = jsDynamicCast<JSCredentialsContainerPrototype*>(vm, JSValue::decode(thisValue)); |
| 168 | if (UNLIKELY(!prototype)) |
| 169 | return throwVMTypeError(state, throwScope); |
| 170 | return JSValue::encode(JSCredentialsContainer::getConstructor(state->vm(), prototype->globalObject())); |
| 171 | } |
| 172 | |
| 173 | bool setJSCredentialsContainerConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 174 | { |
| 175 | VM& vm = state->vm(); |
| 176 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 177 | auto* prototype = jsDynamicCast<JSCredentialsContainerPrototype*>(vm, JSValue::decode(thisValue)); |
| 178 | if (UNLIKELY(!prototype)) { |
| 179 | throwVMTypeError(state, throwScope); |
| 180 | return false; |
| 181 | } |
| 182 | // Shadowing a built-in constructor |
| 183 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 184 | } |
| 185 | |
| 186 | static inline JSC::EncodedJSValue jsCredentialsContainerPrototypeFunctionGetBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSCredentialsContainer>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 187 | { |
| 188 | UNUSED_PARAM(state); |
| 189 | UNUSED_PARAM(throwScope); |
| 190 | auto& impl = castedThis->wrapped(); |
| 191 | auto options = convert<IDLDictionary<CredentialRequestOptions>>(*state, state->argument(0)); |
| 192 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 193 | impl.get(WTFMove(options), WTFMove(promise)); |
| 194 | return JSValue::encode(jsUndefined()); |
| 195 | } |
| 196 | |
| 197 | EncodedJSValue JSC_HOST_CALL jsCredentialsContainerPrototypeFunctionGet(ExecState* state) |
| 198 | { |
| 199 | return IDLOperationReturningPromise<JSCredentialsContainer>::call<jsCredentialsContainerPrototypeFunctionGetBody, PromiseExecutionScope::WindowOrWorker>(*state, "get" ); |
| 200 | } |
| 201 | |
| 202 | static inline JSC::EncodedJSValue jsCredentialsContainerPrototypeFunctionStoreBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSCredentialsContainer>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 203 | { |
| 204 | UNUSED_PARAM(state); |
| 205 | UNUSED_PARAM(throwScope); |
| 206 | auto& impl = castedThis->wrapped(); |
| 207 | if (UNLIKELY(state->argumentCount() < 1)) |
| 208 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 209 | auto credential = convert<IDLInterface<BasicCredential>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "credential" , "CredentialsContainer" , "store" , "BasicCredential" ); }); |
| 210 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 211 | impl.store(*credential, WTFMove(promise)); |
| 212 | return JSValue::encode(jsUndefined()); |
| 213 | } |
| 214 | |
| 215 | EncodedJSValue JSC_HOST_CALL jsCredentialsContainerPrototypeFunctionStore(ExecState* state) |
| 216 | { |
| 217 | return IDLOperationReturningPromise<JSCredentialsContainer>::call<jsCredentialsContainerPrototypeFunctionStoreBody, PromiseExecutionScope::WindowOrWorker>(*state, "store" ); |
| 218 | } |
| 219 | |
| 220 | static inline JSC::EncodedJSValue jsCredentialsContainerPrototypeFunctionCreateBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSCredentialsContainer>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 221 | { |
| 222 | UNUSED_PARAM(state); |
| 223 | UNUSED_PARAM(throwScope); |
| 224 | auto& impl = castedThis->wrapped(); |
| 225 | auto options = convert<IDLDictionary<CredentialCreationOptions>>(*state, state->argument(0)); |
| 226 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 227 | impl.isCreate(WTFMove(options), WTFMove(promise)); |
| 228 | return JSValue::encode(jsUndefined()); |
| 229 | } |
| 230 | |
| 231 | EncodedJSValue JSC_HOST_CALL jsCredentialsContainerPrototypeFunctionCreate(ExecState* state) |
| 232 | { |
| 233 | return IDLOperationReturningPromise<JSCredentialsContainer>::call<jsCredentialsContainerPrototypeFunctionCreateBody, PromiseExecutionScope::WindowOrWorker>(*state, "create" ); |
| 234 | } |
| 235 | |
| 236 | static inline JSC::EncodedJSValue jsCredentialsContainerPrototypeFunctionPreventSilentAccessBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSCredentialsContainer>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 237 | { |
| 238 | UNUSED_PARAM(state); |
| 239 | UNUSED_PARAM(throwScope); |
| 240 | auto& impl = castedThis->wrapped(); |
| 241 | impl.preventSilentAccess(WTFMove(promise)); |
| 242 | return JSValue::encode(jsUndefined()); |
| 243 | } |
| 244 | |
| 245 | EncodedJSValue JSC_HOST_CALL jsCredentialsContainerPrototypeFunctionPreventSilentAccess(ExecState* state) |
| 246 | { |
| 247 | return IDLOperationReturningPromise<JSCredentialsContainer>::call<jsCredentialsContainerPrototypeFunctionPreventSilentAccessBody, PromiseExecutionScope::WindowOrWorker>(*state, "preventSilentAccess" ); |
| 248 | } |
| 249 | |
| 250 | void JSCredentialsContainer::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 251 | { |
| 252 | auto* thisObject = jsCast<JSCredentialsContainer*>(cell); |
| 253 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 254 | if (thisObject->scriptExecutionContext()) |
| 255 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 256 | Base::heapSnapshot(cell, builder); |
| 257 | } |
| 258 | |
| 259 | bool JSCredentialsContainerOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 260 | { |
| 261 | UNUSED_PARAM(handle); |
| 262 | UNUSED_PARAM(visitor); |
| 263 | UNUSED_PARAM(reason); |
| 264 | return false; |
| 265 | } |
| 266 | |
| 267 | void JSCredentialsContainerOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 268 | { |
| 269 | auto* jsCredentialsContainer = static_cast<JSCredentialsContainer*>(handle.slot()->asCell()); |
| 270 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 271 | uncacheWrapper(world, &jsCredentialsContainer->wrapped(), jsCredentialsContainer); |
| 272 | } |
| 273 | |
| 274 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<CredentialsContainer>&& impl) |
| 275 | { |
| 276 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 277 | // attribute. You should remove that attribute. If the class has subclasses |
| 278 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 279 | // attribute to CredentialsContainer. |
| 280 | static_assert(!std::is_polymorphic<CredentialsContainer>::value, "CredentialsContainer is polymorphic but the IDL claims it is not" ); |
| 281 | return createWrapper<CredentialsContainer>(globalObject, WTFMove(impl)); |
| 282 | } |
| 283 | |
| 284 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, CredentialsContainer& impl) |
| 285 | { |
| 286 | return wrap(state, globalObject, impl); |
| 287 | } |
| 288 | |
| 289 | CredentialsContainer* JSCredentialsContainer::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 290 | { |
| 291 | if (auto* wrapper = jsDynamicCast<JSCredentialsContainer*>(vm, value)) |
| 292 | return &wrapper->wrapped(); |
| 293 | return nullptr; |
| 294 | } |
| 295 | |
| 296 | } |
| 297 | |
| 298 | #endif // ENABLE(WEB_AUTHN) |
| 299 | |