• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "napi_account_iam_constant.h"
17 
18 #include "account_log_wrapper.h"
19 #include "napi_account_iam_common.h"
20 
21 namespace OHOS {
22 namespace AccountJsKit {
23 using namespace OHOS::AccountSA;
24 
AuthTypeConstructor(napi_env env)25 napi_value AuthTypeConstructor(napi_env env)
26 {
27     napi_value authType = nullptr;
28     napi_value pin = nullptr;
29     napi_value face = nullptr;
30     napi_value fingerPrint = nullptr;
31     napi_value recoveryKey = nullptr;
32     napi_value privatePin  = nullptr;
33     napi_value domain = nullptr;
34     NAPI_CALL(env, napi_create_object(env, &authType));
35     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthType::PIN), &pin));
36     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthType::FACE), &face));
37     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthType::FINGERPRINT), &fingerPrint));
38     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthType::RECOVERY_KEY), &recoveryKey));
39     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthType::PRIVATE_PIN), &privatePin));
40     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(IAMAuthType::DOMAIN), &domain));
41     NAPI_CALL(env, napi_set_named_property(env, authType, "PIN", pin));
42     NAPI_CALL(env, napi_set_named_property(env, authType, "FACE", face));
43     NAPI_CALL(env, napi_set_named_property(env, authType, "FINGERPRINT", fingerPrint));
44     NAPI_CALL(env, napi_set_named_property(env, authType, "RECOVERY_KEY", recoveryKey));
45     NAPI_CALL(env, napi_set_named_property(env, authType, "PRIVATE_PIN", privatePin));
46     NAPI_CALL(env, napi_set_named_property(env, authType, "DOMAIN", domain));
47     return authType;
48 }
49 
AuthSubTypeConstructor(napi_env env)50 napi_value AuthSubTypeConstructor(napi_env env)
51 {
52     napi_value authSubType = nullptr;
53     napi_value pinSix = nullptr;
54     napi_value pinNumber = nullptr;
55     napi_value pinMixed = nullptr;
56     napi_value pinFour = nullptr;
57     napi_value pinPattern = nullptr;
58     napi_value face2d = nullptr;
59     napi_value face3d = nullptr;
60     napi_value fingerprintCapacitive = nullptr;
61     napi_value fingerprintOptical = nullptr;
62     napi_value fingerprintUltrasonic = nullptr;
63     napi_value pinQuestion  = nullptr;
64     napi_value domainMixed = nullptr;
65     NAPI_CALL(env, napi_create_object(env, &authSubType));
66     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(PinSubType::PIN_SIX), &pinSix));
67     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(PinSubType::PIN_NUMBER), &pinNumber));
68     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(PinSubType::PIN_MIXED), &pinMixed));
69     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(PinSubType::PIN_FOUR), &pinFour));
70     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(PinSubType::PIN_PATTERN), &pinPattern));
71     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(FACE_2D), &face2d));
72     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(FACE_3D), &face3d));
73     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(FINGERPRINT_CAPACITIVE), &fingerprintCapacitive));
74     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(FINGERPRINT_OPTICAL), &fingerprintOptical));
75     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(FINGERPRINT_ULTRASONIC), &fingerprintUltrasonic));
76     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(PinSubType::PIN_QUESTION), &pinQuestion));
77     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(IAMAuthSubType::DOMAIN_MIXED), &domainMixed));
78     NAPI_CALL(env, napi_set_named_property(env, authSubType, "PIN_SIX", pinSix));
79     NAPI_CALL(env, napi_set_named_property(env, authSubType, "PIN_NUMBER", pinNumber));
80     NAPI_CALL(env, napi_set_named_property(env, authSubType, "PIN_MIXED", pinMixed));
81     NAPI_CALL(env, napi_set_named_property(env, authSubType, "PIN_FOUR", pinFour));
82     NAPI_CALL(env, napi_set_named_property(env, authSubType, "PIN_PATTERN", pinPattern));
83     NAPI_CALL(env, napi_set_named_property(env, authSubType, "FACE_2D", face2d));
84     NAPI_CALL(env, napi_set_named_property(env, authSubType, "FACE_3D", face3d));
85     NAPI_CALL(env, napi_set_named_property(env, authSubType, "FINGERPRINT_CAPACITIVE", fingerprintCapacitive));
86     NAPI_CALL(env, napi_set_named_property(env, authSubType, "FINGERPRINT_OPTICAL", fingerprintOptical));
87     NAPI_CALL(env, napi_set_named_property(env, authSubType, "FINGERPRINT_ULTRASONIC", fingerprintUltrasonic));
88     NAPI_CALL(env, napi_set_named_property(env, authSubType, "PIN_QUESTION", pinQuestion));
89     NAPI_CALL(env, napi_set_named_property(env, authSubType, "DOMAIN_MIXED", domainMixed));
90     return authSubType;
91 }
92 
AuthTrustLevelConstructor(napi_env env)93 napi_value AuthTrustLevelConstructor(napi_env env)
94 {
95     napi_value authTrustLevel = nullptr;
96     napi_value atl1 = nullptr;
97     napi_value atl2 = nullptr;
98     napi_value atl3 = nullptr;
99     napi_value atl4 = nullptr;
100     NAPI_CALL(env, napi_create_object(env, &authTrustLevel));
101     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthTrustLevel::ATL1), &atl1));
102     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthTrustLevel::ATL2), &atl2));
103     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthTrustLevel::ATL3), &atl3));
104     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthTrustLevel::ATL4), &atl4));
105     NAPI_CALL(env, napi_set_named_property(env, authTrustLevel, "ATL1", atl1));
106     NAPI_CALL(env, napi_set_named_property(env, authTrustLevel, "ATL2", atl2));
107     NAPI_CALL(env, napi_set_named_property(env, authTrustLevel, "ATL3", atl3));
108     NAPI_CALL(env, napi_set_named_property(env, authTrustLevel, "ATL4", atl4));
109     return authTrustLevel;
110 }
111 
GetPropertyTypeConstructor(napi_env env)112 napi_value GetPropertyTypeConstructor(napi_env env)
113 {
114     napi_value getPropertyType = nullptr;
115     napi_value authSubType = nullptr;
116     napi_value remainTimes = nullptr;
117     napi_value freezingTime = nullptr;
118     napi_value enrollmentProgress = nullptr;
119     napi_value sensorInfo = nullptr;
120     napi_value nextPhaseFreezingTime = nullptr;
121     NAPI_CALL(env, napi_create_object(env, &getPropertyType));
122     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(GetPropertyType::AUTH_SUB_TYPE), &authSubType));
123     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(GetPropertyType::REMAIN_TIMES), &remainTimes));
124     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(GetPropertyType::FREEZING_TIME), &freezingTime));
125     NAPI_CALL(env,
126         napi_create_int32(env, static_cast<int32_t>(GetPropertyType::ENROLLMENT_PROGRESS), &enrollmentProgress));
127     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(GetPropertyType::SENSOR_INFO), &sensorInfo));
128     NAPI_CALL(env, napi_create_int32(
129         env, static_cast<int32_t>(GetPropertyType::NEXT_PHASE_FREEZING_TIME), &nextPhaseFreezingTime));
130     NAPI_CALL(env, napi_set_named_property(env, getPropertyType, "AUTH_SUB_TYPE", authSubType));
131     NAPI_CALL(env, napi_set_named_property(env, getPropertyType, "REMAIN_TIMES", remainTimes));
132     NAPI_CALL(env, napi_set_named_property(env, getPropertyType, "FREEZING_TIME", freezingTime));
133     NAPI_CALL(env, napi_set_named_property(env, getPropertyType, "ENROLLMENT_PROGRESS", enrollmentProgress));
134     NAPI_CALL(env, napi_set_named_property(env, getPropertyType, "SENSOR_INFO", sensorInfo));
135     NAPI_CALL(env, napi_set_named_property(env, getPropertyType, "NEXT_PHASE_FREEZING_TIME", nextPhaseFreezingTime));
136     napi_value credentialLength = nullptr;
137     NAPI_CALL(env, napi_create_int32(
138         env, static_cast<int32_t>(GetPropertyType::CREDENTIAL_LENGTH), &credentialLength));
139     NAPI_CALL(env, napi_set_named_property(env, getPropertyType, "CREDENTIAL_LENGTH", credentialLength));
140     return getPropertyType;
141 }
142 
SetPropertyTypeConstructor(napi_env env)143 napi_value SetPropertyTypeConstructor(napi_env env)
144 {
145     napi_value setPropertyType = nullptr;
146     napi_value initAlgorithm = nullptr;
147     NAPI_CALL(env, napi_create_object(env, &setPropertyType));
148     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(SetPropertyType::INIT_ALGORITHM), &initAlgorithm));
149     NAPI_CALL(env, napi_set_named_property(env, setPropertyType, "INIT_ALGORITHM", initAlgorithm));
150     return setPropertyType;
151 }
152 
AuthMethodConstructor(napi_env env)153 napi_value AuthMethodConstructor(napi_env env)
154 {
155     napi_value authMethod = nullptr;
156     napi_value pinOnly = nullptr;
157     napi_value faceOnly = nullptr;
158     NAPI_CALL(env, napi_create_object(env, &authMethod));
159     NAPI_CALL(env, napi_create_int32(env, AuthMethod::PIN_ONLY, &pinOnly));
160     NAPI_CALL(env, napi_create_int32(env, AuthMethod::FACE_ONLY, &faceOnly));
161     NAPI_CALL(env, napi_set_named_property(env, authMethod, "PIN_ONLY", pinOnly));
162     NAPI_CALL(env, napi_set_named_property(env, authMethod, "FACE_ONLY", faceOnly));
163     return authMethod;
164 }
165 
ModuleConstructor(napi_env env)166 napi_value ModuleConstructor(napi_env env)
167 {
168     napi_value module = nullptr;
169     napi_value faceAuth = nullptr;
170     NAPI_CALL(env, napi_create_object(env, &module));
171     NAPI_CALL(env, napi_create_int32(env, Module::FACE_AUTH, &faceAuth));
172     NAPI_CALL(env, napi_set_named_property(env, module, "FACE_AUTH", faceAuth));
173     return module;
174 }
175 
ResultCodeConstructor(napi_env env)176 napi_value ResultCodeConstructor(napi_env env)
177 {
178     napi_value resultCode = nullptr;
179     napi_value success = nullptr;
180     napi_value fail = nullptr;
181     napi_value generalError = nullptr;
182     napi_value canceled = nullptr;
183     napi_value timeout = nullptr;
184     napi_value typeNotSupport = nullptr;
185     napi_value trustLevelNotSupport = nullptr;
186     napi_value busy = nullptr;
187     napi_value invalidParameters = nullptr;
188     napi_value locked = nullptr;
189     napi_value notEnrolled = nullptr;
190     NAPI_CALL(env, napi_create_object(env, &resultCode));
191     NAPI_CALL(env, napi_create_int32(env, ResultCode::SUCCESS, &success));
192     NAPI_CALL(env, napi_create_int32(env, ResultCode::FAIL, &fail));
193     NAPI_CALL(env, napi_create_int32(env, ResultCode::GENERAL_ERROR, &generalError));
194     NAPI_CALL(env, napi_create_int32(env, ResultCode::CANCELED, &canceled));
195     NAPI_CALL(env, napi_create_int32(env, ResultCode::TIMEOUT, &timeout));
196     NAPI_CALL(env, napi_create_int32(env, ResultCode::TYPE_NOT_SUPPORT, &typeNotSupport));
197     NAPI_CALL(env, napi_create_int32(env, ResultCode::TRUST_LEVEL_NOT_SUPPORT, &trustLevelNotSupport));
198     NAPI_CALL(env, napi_create_int32(env, ResultCode::BUSY, &busy));
199     NAPI_CALL(env, napi_create_int32(env, ResultCode::INVALID_PARAMETERS, &invalidParameters));
200     NAPI_CALL(env, napi_create_int32(env, ResultCode::LOCKED, &locked));
201     NAPI_CALL(env, napi_create_int32(env, ResultCode::NOT_ENROLLED, &notEnrolled));
202     NAPI_CALL(env, napi_set_named_property(env, resultCode, "SUCCESS", success));
203     NAPI_CALL(env, napi_set_named_property(env, resultCode, "FAIL", fail));
204     NAPI_CALL(env, napi_set_named_property(env, resultCode, "GENERAL_ERROR", generalError));
205     NAPI_CALL(env, napi_set_named_property(env, resultCode, "CANCELED", canceled));
206     NAPI_CALL(env, napi_set_named_property(env, resultCode, "TIMEOUT", timeout));
207     NAPI_CALL(env, napi_set_named_property(env, resultCode, "TYPE_NOT_SUPPORT", typeNotSupport));
208     NAPI_CALL(env, napi_set_named_property(env, resultCode, "TRUST_LEVEL_NOT_SUPPORT", trustLevelNotSupport));
209     NAPI_CALL(env, napi_set_named_property(env, resultCode, "BUSY", busy));
210     NAPI_CALL(env, napi_set_named_property(env, resultCode, "INVALID_PARAMETERS", invalidParameters));
211     NAPI_CALL(env, napi_set_named_property(env, resultCode, "LOCKED", locked));
212     NAPI_CALL(env, napi_set_named_property(env, resultCode, "NOT_ENROLLED", notEnrolled));
213     return resultCode;
214 }
215 
FaceTipsCodeConstructor(napi_env env)216 napi_value FaceTipsCodeConstructor(napi_env env)
217 {
218     napi_value faceTipsCode = nullptr;
219     napi_value faceAuthTipTooBright = nullptr;
220     napi_value faceAuthTipTooDark = nullptr;
221     napi_value faceAuthTipTooClose = nullptr;
222     napi_value faceAuthTipTooFar = nullptr;
223     napi_value faceAuthTipTooHigh = nullptr;
224     napi_value faceAuthTipTooLow = nullptr;
225     napi_value faceAuthTipTooRight = nullptr;
226     napi_value faceAuthTipTooLeft = nullptr;
227     napi_value faceAuthTipTooMuchMotion = nullptr;
228     napi_value faceAuthTipPoorGaze = nullptr;
229     napi_value faceAuthTipNotDetected = nullptr;
230     NAPI_CALL(env, napi_create_object(env, &faceTipsCode));
231     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_TOO_BRIGHT, &faceAuthTipTooBright));
232     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_TOO_DARK, &faceAuthTipTooDark));
233     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_TOO_CLOSE, &faceAuthTipTooClose));
234     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_TOO_FAR, &faceAuthTipTooFar));
235     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_TOO_HIGH, &faceAuthTipTooHigh));
236     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_TOO_LOW, &faceAuthTipTooLow));
237     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_TOO_RIGHT, &faceAuthTipTooRight));
238     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_TOO_LEFT, &faceAuthTipTooLeft));
239     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_TOO_MUCH_MOTION, &faceAuthTipTooMuchMotion));
240     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_POOR_GAZE, &faceAuthTipPoorGaze));
241     NAPI_CALL(env, napi_create_int32(env, FaceTipsCode::FACE_AUTH_TIP_NOT_DETECTED, &faceAuthTipNotDetected));
242     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode, "FACE_AUTH_TIP_TOO_BRIGHT", faceAuthTipTooBright));
243     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode, "FACE_AUTH_TIP_TOO_DARK", faceAuthTipTooDark));
244     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode, "FACE_AUTH_TIP_TOO_CLOSE", faceAuthTipTooClose));
245     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode, "FACE_AUTH_TIP_TOO_FAR", faceAuthTipTooFar));
246     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode, "FACE_AUTH_TIP_TOO_HIGH", faceAuthTipTooHigh));
247     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode, "FACE_AUTH_TIP_TOO_LOW", faceAuthTipTooLow));
248     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode, "FACE_AUTH_TIP_TOO_RIGHT", faceAuthTipTooRight));
249     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode, "FACE_AUTH_TIP_TOO_LEFT", faceAuthTipTooLeft));
250     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode,
251         "FACE_AUTH_TIP_TOO_MUCH_MOTION", faceAuthTipTooMuchMotion));
252     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode, "FACE_AUTH_TIP_POOR_GAZE", faceAuthTipPoorGaze));
253     NAPI_CALL(env, napi_set_named_property(env, faceTipsCode, "FACE_AUTH_TIP_NOT_DETECTED", faceAuthTipNotDetected));
254     return faceTipsCode;
255 }
256 
FingerprintTipsConstructorForInnerkits(napi_env env)257 napi_value FingerprintTipsConstructorForInnerkits(napi_env env)
258 {
259     napi_value fingerprintTips = nullptr;
260     napi_value fingerprintTipGood = nullptr;
261     napi_value fingerprintTipImagerDirty = nullptr;
262     napi_value fingerprintTipInsufficient = nullptr;
263     napi_value fingerprintTipPartial = nullptr;
264     napi_value fingerprintTipTooFast = nullptr;
265     napi_value fingerprintTipTooSlow = nullptr;
266     napi_value fingerprintTipFingerDown = nullptr;
267     napi_value fingerprintTipFingerUp = nullptr;
268     NAPI_CALL(env, napi_create_object(env, &fingerprintTips));
269     NAPI_CALL(env, napi_create_int32(env, FingerprintTips::FINGERPRINT_AUTH_TIP_GOOD, &fingerprintTipGood));
270     NAPI_CALL(env, napi_create_int32(env, FingerprintTips::FINGERPRINT_AUTH_TIP_IMAGER_DIRTY,
271         &fingerprintTipImagerDirty));
272     NAPI_CALL(env, napi_create_int32(env, FingerprintTips::FINGERPRINT_AUTH_TIP_INSUFFICIENT,
273         &fingerprintTipInsufficient));
274     NAPI_CALL(env, napi_create_int32(env, FingerprintTips::FINGERPRINT_AUTH_TIP_PARTIAL, &fingerprintTipPartial));
275     NAPI_CALL(env, napi_create_int32(env, FingerprintTips::FINGERPRINT_AUTH_TIP_TOO_FAST, &fingerprintTipTooFast));
276     NAPI_CALL(env, napi_create_int32(env, FingerprintTips::FINGERPRINT_AUTH_TIP_TOO_SLOW, &fingerprintTipTooSlow));
277     NAPI_CALL(env, napi_create_int32(env, FingerprintTips::FINGERPRINT_TIP_FINGER_DOWN, &fingerprintTipFingerDown));
278     NAPI_CALL(env, napi_create_int32(env, FingerprintTips::FINGERPRINT_TIP_FINGER_UP, &fingerprintTipFingerUp));
279     NAPI_CALL(env,
280         napi_set_named_property(env, fingerprintTips, "FINGERPRINT_TIP_GOOD", fingerprintTipGood));
281     NAPI_CALL(env,
282         napi_set_named_property(env, fingerprintTips, "FINGERPRINT_TIP_IMAGER_DIRTY", fingerprintTipImagerDirty));
283     NAPI_CALL(env,
284         napi_set_named_property(env, fingerprintTips, "FINGERPRINT_TIP_INSUFFICIENT", fingerprintTipInsufficient));
285     NAPI_CALL(env,
286         napi_set_named_property(env, fingerprintTips, "FINGERPRINT_TIP_PARTIAL", fingerprintTipPartial));
287     NAPI_CALL(env,
288         napi_set_named_property(env, fingerprintTips, "FINGERPRINT_TIP_TOO_FAST", fingerprintTipTooFast));
289     NAPI_CALL(env,
290         napi_set_named_property(env, fingerprintTips, "FINGERPRINT_TIP_TOO_SLOW", fingerprintTipTooSlow));
291     NAPI_CALL(env,
292         napi_set_named_property(env, fingerprintTips, "FINGERPRINT_TIP_FINGER_DOWN", fingerprintTipFingerDown));
293     NAPI_CALL(env,
294         napi_set_named_property(env, fingerprintTips, "FINGERPRINT_TIP_FINGER_UP", fingerprintTipFingerUp));
295     return fingerprintTips;
296 }
297 
AuthIntentConstructorForInnerkits(napi_env env)298 napi_value AuthIntentConstructorForInnerkits(napi_env env)
299 {
300     napi_value authIntent = nullptr;
301     napi_value unlock = nullptr;
302     napi_value silent_auth = nullptr;
303     napi_value question_auth = nullptr;
304     napi_value abandoned_pin_auth = nullptr;
305     NAPI_CALL(env, napi_create_object(env, &authIntent));
306     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthIntent::UNLOCK), &unlock));
307     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthIntent::SILENT_AUTH), &silent_auth));
308     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthIntent::QUESTION_AUTH), &question_auth));
309     NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(AuthIntent::ABANDONED_PIN_AUTH), &abandoned_pin_auth));
310     NAPI_CALL(env, napi_set_named_property(env, authIntent, "UNLOCK", unlock));
311     NAPI_CALL(env, napi_set_named_property(env, authIntent, "SILENT_AUTH", silent_auth));
312     NAPI_CALL(env, napi_set_named_property(env, authIntent, "QUESTION_AUTH", question_auth));
313     NAPI_CALL(env, napi_set_named_property(env, authIntent, "ABANDONED_PIN_AUTH", abandoned_pin_auth));
314     return authIntent;
315 }
316 
Init(napi_env env,napi_value exports)317 napi_value NapiAccountIAMConstant::Init(napi_env env, napi_value exports)
318 {
319     napi_property_descriptor descriptors[] = {
320         DECLARE_NAPI_PROPERTY("AuthType", AuthTypeConstructor(env)),
321         DECLARE_NAPI_PROPERTY("AuthSubType", AuthSubTypeConstructor(env)),
322         DECLARE_NAPI_PROPERTY("AuthTrustLevel", AuthTrustLevelConstructor(env)),
323         DECLARE_NAPI_PROPERTY("GetPropertyType", GetPropertyTypeConstructor(env)),
324         DECLARE_NAPI_PROPERTY("SetPropertyType", SetPropertyTypeConstructor(env)),
325         DECLARE_NAPI_PROPERTY("AuthMethod", AuthMethodConstructor(env)),
326         DECLARE_NAPI_PROPERTY("Module", ModuleConstructor(env)),
327         DECLARE_NAPI_PROPERTY("ResultCode", ResultCodeConstructor(env)),
328         DECLARE_NAPI_PROPERTY("FaceTipsCode", FaceTipsCodeConstructor(env)),
329         DECLARE_NAPI_PROPERTY("FingerprintTips", FingerprintTipsConstructorForInnerkits(env)),
330         DECLARE_NAPI_PROPERTY("AuthIntent", AuthIntentConstructorForInnerkits(env)),
331     };
332     napi_define_properties(env, exports, sizeof(descriptors) / sizeof(napi_property_descriptor), descriptors);
333     return exports;
334 }
335 }  // namespace AccountJsKit
336 }  // namespace OHOS
337