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 "JSPublicKeyCredentialRequestOptions.h" |
26 | |
27 | #include "JSAuthenticationExtensionsClientInputs.h" |
28 | #include "JSDOMConvertBufferSource.h" |
29 | #include "JSDOMConvertEnumeration.h" |
30 | #include "JSDOMConvertNumbers.h" |
31 | #include "JSDOMConvertSequences.h" |
32 | #include "JSDOMConvertStrings.h" |
33 | #include "JSDOMConvertUnion.h" |
34 | #include "JSPublicKeyCredentialDescriptor.h" |
35 | #include "JSUserVerificationRequirement.h" |
36 | #include <JavaScriptCore/JSArray.h> |
37 | #include <JavaScriptCore/JSCInlines.h> |
38 | #include <wtf/Variant.h> |
39 | |
40 | |
41 | namespace WebCore { |
42 | using namespace JSC; |
43 | |
44 | #if ENABLE(WEB_AUTHN) |
45 | |
46 | template<> PublicKeyCredentialRequestOptions convertDictionary<PublicKeyCredentialRequestOptions>(ExecState& state, JSValue value) |
47 | { |
48 | VM& vm = state.vm(); |
49 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
50 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
51 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
52 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
53 | throwTypeError(&state, throwScope); |
54 | return { }; |
55 | } |
56 | PublicKeyCredentialRequestOptions result; |
57 | JSValue allowCredentialsValue; |
58 | if (isNullOrUndefined) |
59 | allowCredentialsValue = jsUndefined(); |
60 | else { |
61 | allowCredentialsValue = object->get(&state, Identifier::fromString(&state, "allowCredentials" )); |
62 | RETURN_IF_EXCEPTION(throwScope, { }); |
63 | } |
64 | if (!allowCredentialsValue.isUndefined()) { |
65 | result.allowCredentials = convert<IDLSequence<IDLDictionary<PublicKeyCredentialDescriptor>>>(state, allowCredentialsValue); |
66 | RETURN_IF_EXCEPTION(throwScope, { }); |
67 | } else |
68 | result.allowCredentials = Converter<IDLSequence<IDLDictionary<PublicKeyCredentialDescriptor>>>::ReturnType{ }; |
69 | JSValue challengeValue; |
70 | if (isNullOrUndefined) |
71 | challengeValue = jsUndefined(); |
72 | else { |
73 | challengeValue = object->get(&state, Identifier::fromString(&state, "challenge" )); |
74 | RETURN_IF_EXCEPTION(throwScope, { }); |
75 | } |
76 | if (!challengeValue.isUndefined()) { |
77 | result.challenge = convert<IDLUnion<IDLArrayBufferView, IDLArrayBuffer>>(state, challengeValue); |
78 | RETURN_IF_EXCEPTION(throwScope, { }); |
79 | } else { |
80 | throwRequiredMemberTypeError(state, throwScope, "challenge" , "PublicKeyCredentialRequestOptions" , "(ArrayBufferView or ArrayBuffer)" ); |
81 | return { }; |
82 | } |
83 | JSValue extensionsValue; |
84 | if (isNullOrUndefined) |
85 | extensionsValue = jsUndefined(); |
86 | else { |
87 | extensionsValue = object->get(&state, Identifier::fromString(&state, "extensions" )); |
88 | RETURN_IF_EXCEPTION(throwScope, { }); |
89 | } |
90 | if (!extensionsValue.isUndefined()) { |
91 | result.extensions = convert<IDLDictionary<AuthenticationExtensionsClientInputs>>(state, extensionsValue); |
92 | RETURN_IF_EXCEPTION(throwScope, { }); |
93 | } |
94 | JSValue rpIdValue; |
95 | if (isNullOrUndefined) |
96 | rpIdValue = jsUndefined(); |
97 | else { |
98 | rpIdValue = object->get(&state, Identifier::fromString(&state, "rpId" )); |
99 | RETURN_IF_EXCEPTION(throwScope, { }); |
100 | } |
101 | if (!rpIdValue.isUndefined()) { |
102 | result.rpId = convert<IDLUSVString>(state, rpIdValue); |
103 | RETURN_IF_EXCEPTION(throwScope, { }); |
104 | } |
105 | JSValue timeoutValue; |
106 | if (isNullOrUndefined) |
107 | timeoutValue = jsUndefined(); |
108 | else { |
109 | timeoutValue = object->get(&state, Identifier::fromString(&state, "timeout" )); |
110 | RETURN_IF_EXCEPTION(throwScope, { }); |
111 | } |
112 | if (!timeoutValue.isUndefined()) { |
113 | result.timeout = convert<IDLUnsignedLong>(state, timeoutValue); |
114 | RETURN_IF_EXCEPTION(throwScope, { }); |
115 | } |
116 | JSValue userVerificationValue; |
117 | if (isNullOrUndefined) |
118 | userVerificationValue = jsUndefined(); |
119 | else { |
120 | userVerificationValue = object->get(&state, Identifier::fromString(&state, "userVerification" )); |
121 | RETURN_IF_EXCEPTION(throwScope, { }); |
122 | } |
123 | if (!userVerificationValue.isUndefined()) { |
124 | result.userVerification = convert<IDLEnumeration<UserVerificationRequirement>>(state, userVerificationValue); |
125 | RETURN_IF_EXCEPTION(throwScope, { }); |
126 | } else |
127 | result.userVerification = UserVerificationRequirement::Preferred; |
128 | return result; |
129 | } |
130 | |
131 | #endif |
132 | |
133 | } // namespace WebCore |
134 | |
135 | #endif // ENABLE(WEB_AUTHN) |
136 | |