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 "JSPublicKeyCredentialDescriptor.h"
26
27#include "JSAuthenticatorTransport.h"
28#include "JSDOMConvertBufferSource.h"
29#include "JSDOMConvertEnumeration.h"
30#include "JSDOMConvertSequences.h"
31#include "JSDOMConvertUnion.h"
32#include "JSPublicKeyCredentialType.h"
33#include <JavaScriptCore/JSArray.h>
34#include <JavaScriptCore/JSCInlines.h>
35#include <wtf/Variant.h>
36
37
38namespace WebCore {
39using namespace JSC;
40
41#if ENABLE(WEB_AUTHN)
42
43template<> PublicKeyCredentialDescriptor convertDictionary<PublicKeyCredentialDescriptor>(ExecState& state, JSValue value)
44{
45 VM& vm = state.vm();
46 auto throwScope = DECLARE_THROW_SCOPE(vm);
47 bool isNullOrUndefined = value.isUndefinedOrNull();
48 auto* object = isNullOrUndefined ? nullptr : value.getObject();
49 if (UNLIKELY(!isNullOrUndefined && !object)) {
50 throwTypeError(&state, throwScope);
51 return { };
52 }
53 PublicKeyCredentialDescriptor result;
54 JSValue idValue;
55 if (isNullOrUndefined)
56 idValue = jsUndefined();
57 else {
58 idValue = object->get(&state, Identifier::fromString(&state, "id"));
59 RETURN_IF_EXCEPTION(throwScope, { });
60 }
61 if (!idValue.isUndefined()) {
62 result.id = convert<IDLUnion<IDLArrayBufferView, IDLArrayBuffer>>(state, idValue);
63 RETURN_IF_EXCEPTION(throwScope, { });
64 } else {
65 throwRequiredMemberTypeError(state, throwScope, "id", "PublicKeyCredentialDescriptor", "(ArrayBufferView or ArrayBuffer)");
66 return { };
67 }
68 JSValue transportsValue;
69 if (isNullOrUndefined)
70 transportsValue = jsUndefined();
71 else {
72 transportsValue = object->get(&state, Identifier::fromString(&state, "transports"));
73 RETURN_IF_EXCEPTION(throwScope, { });
74 }
75 if (!transportsValue.isUndefined()) {
76 result.transports = convert<IDLSequence<IDLEnumeration<AuthenticatorTransport>>>(state, transportsValue);
77 RETURN_IF_EXCEPTION(throwScope, { });
78 }
79 JSValue typeValue;
80 if (isNullOrUndefined)
81 typeValue = jsUndefined();
82 else {
83 typeValue = object->get(&state, Identifier::fromString(&state, "type"));
84 RETURN_IF_EXCEPTION(throwScope, { });
85 }
86 if (!typeValue.isUndefined()) {
87 result.type = convert<IDLEnumeration<PublicKeyCredentialType>>(state, typeValue);
88 RETURN_IF_EXCEPTION(throwScope, { });
89 } else {
90 throwRequiredMemberTypeError(state, throwScope, "type", "PublicKeyCredentialDescriptor", "PublicKeyCredentialType");
91 return { };
92 }
93 return result;
94}
95
96#endif
97
98} // namespace WebCore
99
100#endif // ENABLE(WEB_AUTHN)
101