diff --git a/README.md b/README.md index d275efe83f4f69d319ba0c40b3cbec4ac364e9db..a7e61fe1517ed8ff4f07e9dd9c9de1755f355f83 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## 效果预览 | 数字盾预览 | |-----------------------------------------------| -| | +| | ## 使用说明 ### 数字盾服务签名申请 @@ -33,8 +33,6 @@ ``` ├──entry/src/main/ets/ -│ ├──Common -│ │ └──TrustedServiceOption.ets // 可信服务配置 │ ├──entryability │ │ └──EntryAbility.ets // Ability的生命周期回调内容 │ ├──entrybackupability @@ -44,10 +42,11 @@ │ ├──pages │ │ ├──Index.ets // Navigation导航入口界面 │ │ ├──MainPage.ets // 数字盾信息主界面 -│ │ ├──PageOne.ets // 密码类型选择界面 -│ │ └──PageTwo.ets // 交易信息界面 -│ └──Utils // 工具 -│ └──AssetUtils.ets // 关键资产存储服务工具 +│ │ ├──PasswordSelectionPage.ets // 密码类型选择界面 +│ │ └──TradingPage.ets // 交易信息界面 +│ └──utils // 工具 +│ ├──AssetUtils.ets // 关键资产存储服务工具 +│ └──TrustedServiceOption.ets // 可信服务配置 ├──resource └──module.json5 @@ -68,7 +67,7 @@ 3. User Authentication Kit (用户认证服务) ## 约束与限制 -1. 本示例仅支持标准系统上运行,支持设备:phone。 +1. 本示例仅支持标准系统上运行,支持设备:手机。 2. HarmonyOS系统:HarmonyOS 6.0 Beta3及以上。 3. DevEco Studio版本:DevEco Studio 6.0 Beta3及以上。 4. HarmonyOS SDK版本:HarmonyOS 6.0 Bete3 SDK及以上。 diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 508880af8c33aa838016d1cd4b2c68be2f447540..3456b0ec297a28f516dfec075eb57a378362a221 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,12 +1,30 @@ -import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; const DOMAIN = 0x0000; export default class EntryAbility extends UIAbility { - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + onCreate(): void { + try{ + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (error) { + hilog.error(DOMAIN, 'testTag', '%{public}s', 'setColorMode Error'); + } hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); } diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index 54ae78a400756b59284e9717b81d98617d98ddd3..56fcf224e07114f043cf12f813993a6e398423a5 100644 --- a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,3 +1,17 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ import { hilog } from '@kit.PerformanceAnalysisKit'; import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; diff --git a/entry/src/main/ets/model/TrustedAuthentication.ets b/entry/src/main/ets/model/TrustedAuthentication.ets index 8e3f03d5621179d133217523ff345ea7183d9633..30fcb2c0ef37ab189f3633e7b3ee2d9ac326b98e 100644 --- a/entry/src/main/ets/model/TrustedAuthentication.ets +++ b/entry/src/main/ets/model/TrustedAuthentication.ets @@ -1,10 +1,25 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ import { resourceManager } from '@kit.LocalizationKit'; import { huks } from '@kit.UniversalKeystoreKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { userAuth } from '@kit.UserAuthenticationKit'; import { trustedAuthentication } from '@kit.DeviceSecurityKit'; import { util } from '@kit.ArkTS'; -import AssetUtils from '../Utils/AssetUtils'; +import AssetUtils from '../utils/AssetUtils'; +import { hilog } from '@kit.PerformanceAnalysisKit'; const TUI_PIN_SET = 1 const TUI_PIN_MODIFY = 2 @@ -15,11 +30,9 @@ const TUI_BIND_FACE = 7 const TUI_BIND_FINGERPRINT = 8 const TUI_PIN_SET_MIX = 9 const TUI_PIN_MODIFY_MIX = 10 -let keyAlias = 'test_sign_key_alias'; +const DOMAIN = 0x0000 +const KEY_ALIAS = 'test_sign_key_alias'; let handle: number; -let challenge: Uint8Array; -let signature: Uint8Array; -let authTokenData: Uint8Array; class throwObject { isThrow: boolean = false @@ -83,22 +96,22 @@ function GetEccSignProperties(): Array { } async function publicGenKeyFunc(keyAlias: string, huksOptions: huks.HuksOptions): Promise { - console.info(`enter promise generatekeyItem`); + hilog.info(DOMAIN, 'testTag', `enter promise generatekeyItem`); let throwObject: throwObject = { isThrow: false }; try { await generateKeyItem(keyAlias, huksOptions, throwObject) .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + hilog.info(DOMAIN, 'testTag', `promise: generateKeyItem success, data = ${JSON.stringify(data)}`); }) .catch((error: Error) => { if (throwObject.isThrow) { throw (error as Error); } else { - console.error(`promise: generateKeyItem failed, ` + JSON.stringify(error)); + hilog.error(DOMAIN, 'testTag', `promise: generateKeyItem failed, ` + JSON.stringify(error)); } }); } catch (error) { - console.error(`promise: generateKeyItem input arg invlaid ` + JSON.stringify(error)) + hilog.error(DOMAIN, 'testTag', `promise: generateKeyItem input arg invlaid ` + JSON.stringify(error)); } }; @@ -108,15 +121,15 @@ async function SignFinish(handle: number, authToken: Uint8Array, plaintext: stri properties: signProperties, inData: stringToUint8Array(plaintext) } - console.log("====inData====" + options.inData); - console.error("AAA finish 开始" + handle, options, authToken); + hilog.info(DOMAIN, 'testTag', '====inData====' + options.inData); + hilog.info(DOMAIN, 'testTag', 'AAA finish Start' + handle, options, authToken); try { let data = await huks.finishSession(handle, options, authToken); let signature = data.outData as Uint8Array; - console.log('Sign Finish Success! Result: ' + JSON.stringify(data)); + hilog.info(DOMAIN, 'testTag', 'Sign Finish Success! Result: ' + JSON.stringify(data)); return signature } catch (error) { - console.error('Sign Finish Exception ' + JSON.stringify(error)); + hilog.error(DOMAIN, 'testTag', 'Sign Finish Exception ' + JSON.stringify(error)); throw new Error('Sign Finish Exception ' + (error as BusinessError).message); } } @@ -136,7 +149,7 @@ function stringToUint8Array(str: string): Uint8Array { async function Verify(indata: string, signature: Uint8Array): Promise { let indataArray = stringToUint8Array(indata) - console.log('indata size = ' + indataArray.length + ' signature size = ' + signature.length); + hilog.info(DOMAIN, 'testTag', 'indata size = ' + indataArray.length + ' signature size = ' + signature.length); let appendInfo = signature.subarray(0, 41); let newSignature = signature.subarray(41); @@ -148,35 +161,33 @@ async function Verify(indata: string, signature: Uint8Array): Promise { properties: verifyProperties, inData: signature } - await huks.initSession(keyAlias, options).then((data) => { + await huks.initSession(KEY_ALIAS, options).then((data) => { handle = data.handle; - console.log('Verify Init Success! Result: ' + JSON.stringify(data)) + hilog.info(DOMAIN, 'testTag', 'Verify Init Success! Result: ' + JSON.stringify(data)); }).catch((err: Error) => { - console.error('Init err: ' + JSON.stringify(err)); + hilog.error(DOMAIN, 'testTag', 'Init err: ' + JSON.stringify(err)); }) - - console.log('Verify Update Begin' + JSON.stringify(options) + 'handel' + JSON.stringify(handle)); + hilog.info(DOMAIN, 'testTag', 'Verify Update Begin' + JSON.stringify(options) + 'handle' + JSON.stringify(handle)); options.inData = newIndata; await huks.updateSession(handle, options).then(() => { - console.log('Verify Update Begin(infunction)' + JSON.stringify(options.inData)); + hilog.info(DOMAIN, 'testTag', 'Verify Update Begin(inFunction)' + JSON.stringify(options.inData)); }).catch((err: Error) => { - console.log('Verify update err: ' + JSON.stringify(err)); + hilog.error(DOMAIN, 'testTag', 'Verify update err: ' + JSON.stringify(err)); }) - - console.log('Verify Finish Begin' + JSON.stringify(options)); - console.log('Verify Finish SIG' + JSON.stringify(signature)); + hilog.info(DOMAIN, 'testTag', 'Verify Finish Begin' + JSON.stringify(options)); + hilog.info(DOMAIN, 'testTag', 'Verify Finish SIG' + JSON.stringify(signature)); options.inData = newSignature; await huks.finishSession(handle, options).then(() => { - console.log('Verify Finisht Success! Result:' + JSON.stringify(options.inData)); + hilog.info(DOMAIN, 'testTag', 'Verify Finish Success! Result:' + JSON.stringify(options.inData)); }).catch((err: Error) => { - console.log('Verify finish err: ' + JSON.stringify(err)); + hilog.error(DOMAIN, 'testTag', 'Verify finish err: ' + JSON.stringify(err)); }); }; class TrustedAuth { bigIntToUint8Array(value: bigint): Uint8Array { if (value < 0n) { - throw new Error("only non-negative bigint values are supported"); + throw new Error('only non-negative bigint values are supported'); } if (value === 0n) { @@ -209,9 +220,9 @@ class TrustedAuth { let credentialID = appendInfo.subarray(8, 40); let checkHash = appendInfo.subarray(40, 41); let authType = appendInfo.subarray(4, 8); - console.log('credentialId', credentialID); - console.log('checkHash', checkHash); - console.log('authType', authType); + hilog.info(DOMAIN, 'testTag', 'credentialId', credentialID); + hilog.info(DOMAIN, 'testTag', 'checkHash', checkHash); + hilog.info(DOMAIN, 'testTag', 'authType', authType); await AssetUtils.AddDataToAssetStore(credentialID, 'face_credentialID', 'face_credential_label'); } @@ -222,11 +233,11 @@ class TrustedAuth { const fileData: Uint8Array = await resourceMgr.getRawFileContent('startIcon.png'); const firstTenElementsView = fileData.subarray(0, 20); - console.log('image size is ', fileData.buffer.byteLength); - console.log('image subarray is ', firstTenElementsView); + hilog.info(DOMAIN, 'testTag', 'image size is ', fileData.buffer.byteLength); + hilog.info(DOMAIN, 'testTag', 'image subarray is ', firstTenElementsView); return fileData.buffer; } catch (error) { - console.error('Failed to load image:', error); + hilog.error(DOMAIN, 'testTag', 'Failed to load image:', error); throw new Error('Unable to import image:' + (error as BusinessError).message); } } @@ -238,14 +249,14 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: '数字盾密码验证' + title: $r('app.string.ShieldPwVerification') } const result = await trustedAuthentication.trustedAuthentication(challenge, credentialID, label); - console.log('数字盾密码认证:', result.authToken.length, result.authToken); + hilog.info(DOMAIN, 'testTag', 'DigitalShield password verification success:', result.authToken.length, result.authToken); return result; } catch (error) { - console.error('数字盾密码认证:', error); - throw new Error('数字盾密码认证失败:' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'DigitalShield password verification failed:', error); + throw new Error('DigitalShield password verification failed:' + (error as BusinessError).message); } } @@ -260,16 +271,16 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: '开通数字盾' + title: $r('app.string.OpenShield') } const authInfo = await trustedAuthentication.enableTrustedAuthentication(challenge, passwordInfo, label); let assetLabel = assetName + 'label'; await AssetUtils.AddDataToAssetStore(this.bigIntToUint8Array(authInfo.authID), assetName, assetLabel); - console.log('开通数字盾成功:', authInfo.authID, authInfo.authToken.length, authInfo.authToken); + hilog.info(DOMAIN, 'testTag', 'Open Shield Success:', authInfo.authID, authInfo.authToken.length, authInfo.authToken); return authInfo; } catch (error) { - console.error('开通数字盾失败:', error); - throw new Error('开通数字盾失败:' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'Open Shield Fail:', error); + throw new Error('Open Shield Fail:' + (error as BusinessError).message); } } @@ -284,16 +295,16 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: '开通数字盾' + title: $r('app.string.OpenShield') } const authInfo = await trustedAuthentication.enableTrustedAuthentication(challenge, passwordInfo, label); let assetLabel = assetName + 'label'; await AssetUtils.AddDataToAssetStore(this.bigIntToUint8Array(authInfo.authID), assetName, assetLabel); - console.log('开通数字盾成功:', authInfo.authID, authInfo.authToken.length, authInfo.authToken); + hilog.info(DOMAIN, 'testTag', 'Open Shield Success:', authInfo.authID, authInfo.authToken.length, authInfo.authToken); return authInfo; } catch (error) { - console.error('开通数字盾失败:', error); - throw new Error('开通数字盾失败:' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'Open Shield Fail:', error); + throw new Error('Open Shield Fail:' + (error as BusinessError).message); } } @@ -310,15 +321,15 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: '修改金融盾' + title: $r('app.string.ModifyShield') } const authInfo = await trustedAuthentication.modifyTrustedAuthenticationPwd(challenge, passwordInfo, credentialID, label); - console.log('修改数字盾成功:', authInfo.authToken); + hilog.info(DOMAIN, 'testTag', 'Modify Shield Success:', authInfo.authToken); return authInfo; } catch (error) { - console.error('密码修改失败:', error); - throw new Error('密码修改失败:' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'Modify Shield Fail:', error); + throw new Error('Modify Shield Fail:' + (error as BusinessError).message); } } @@ -335,15 +346,15 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: '修改金融盾' + title: $r('app.string.ModifyShield') } const authInfo = await trustedAuthentication.modifyTrustedAuthenticationPwd(challenge, passwordInfo, credentialID, label); - console.log('修改数字盾成功:', authInfo.authToken); + hilog.info(DOMAIN, 'testTag', 'Modify Shield Success:', authInfo.authToken); return authInfo; } catch (error) { - console.error('密码修改失败:', error); - throw new Error('密码修改失败:' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'Modify Shield Fail:', error); + throw new Error('Modify Shield Fail:' + (error as BusinessError).message); } } @@ -354,18 +365,18 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const label: trustedAuthentication.TUILable = { image: buffer, - title: '关闭金融盾' + title: $r('app.string.CloseShield') } const authInfo = await trustedAuthentication.disableTrustedAuthentication(challenge, true, credentialID, label); AssetUtils.DeleteDataFromAssetStore('pin_label1'); AssetUtils.DeleteDataFromAssetStore('credentialID'); AssetUtils.DeleteDataFromAssetStore('face_credentialID'); AssetUtils.DeleteDataFromAssetStore('finger_credentialID'); - console.log('关闭数字盾成功:', authInfo.authToken); + hilog.info(DOMAIN, 'testTag', 'Close Shield Success:', authInfo.authToken); return authInfo; } catch (error) { - console.error('关闭数字盾失败:', error); - throw new Error('关闭数字盾失败:' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'Close Shield Fail:', error); + throw new Error('Close Shield Fail:' + (error as BusinessError).message); } } @@ -376,68 +387,70 @@ class TrustedAuth { let emptyBuffer = new ArrayBuffer(0); const label: trustedAuthentication.TUILable = { image: emptyBuffer, - title: "" + title: '' } const authInfo = await trustedAuthentication.disableTrustedAuthentication(challenge, false, credentialID, label); AssetUtils.DeleteDataFromAssetStore('pin_label1'); AssetUtils.DeleteDataFromAssetStore('credentialID'); AssetUtils.DeleteDataFromAssetStore('face_credentialID'); AssetUtils.DeleteDataFromAssetStore('finger+credentialID'); - console.log('关闭数字盾成功:', authInfo.authToken); + hilog.info(DOMAIN, 'testTag', 'Close Shield Success:', authInfo.authToken); return authInfo.authToken; } catch (error) { - console.error('关闭数字盾失败:', error); - throw new Error('关闭数字盾失败:' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'Close Shield Fail:', error); + throw new Error('Close Shield Fail:' + (error as BusinessError).message); } } async FaceAuthContent(challenge: Uint8Array, assetName: string): Promise { try { let enrolledState = userAuth.getEnrolledState(userAuth.UserAuthType.FACE); - console.info(`get current enrolled state success enrolledState = ${JSON.stringify(enrolledState)}`); + hilog.info(DOMAIN, 'testTag', + `get current enrolled state success enrolledState = ${JSON.stringify(enrolledState)}`); let resArray: Uint8Array = await AssetUtils.QueryDataFromAssetStore(assetName); let credentialID: bigint = this.uint8ArrayToBigInt(resArray); const buffer: ArrayBuffer = await this.ImportImage(); const reqParams: trustedAuthentication.AuthReqParams = { reqType: trustedAuthentication.AuthType.AUTH_TYPE_FACE, - authContent: ["challenge:123456|0", "用户:张家龙|1", "账号:123456|1", "交易金额: 10000000|2", - "交易时间:2025-0605|2"] + authContent: ['challenge:123456|0', '用户:张家龙|1', '账号:123456|1', '交易金额: 10000000|2', + '交易时间:2025-0605|2'] } const label: trustedAuthentication.TUILable = { image: buffer, - title: '人脸交易认证' + title: $r('app.string.FaceVerification') } const result = await trustedAuthentication.procContentAuthentication(challenge, credentialID, reqParams, label); - console.log('人脸交易认证:', result.authToken); + hilog.info(DOMAIN, 'testTag', 'Face Verification Success:', result.authToken); return result; } catch (error) { - console.error('人脸交易认证失败:', error); - throw new Error('人脸交易认证失败:' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'Face Verification Fail:', error); + throw new Error('Face Verification Fail:' + (error as BusinessError).message); } } async FingerPrintAuthContent(challenge: Uint8Array, assetName: string): Promise { try { let enrolledState = userAuth.getEnrolledState(userAuth.UserAuthType.FINGERPRINT); - console.info(`get current enrolled state success enrolledState = ${JSON.stringify(enrolledState)}`); + hilog.info(DOMAIN, 'testTag', + `get current enrolled state success enrolledState = ${JSON.stringify(enrolledState)}`); let resArray: Uint8Array = await AssetUtils.QueryDataFromAssetStore(assetName); let credentialID: bigint = this.uint8ArrayToBigInt(resArray); const buffer: ArrayBuffer = await this.ImportImage(); const reqParams: trustedAuthentication.AuthReqParams = { reqType: trustedAuthentication.AuthType.AUTH_TYPE_FINGERPRINT, - authContent: ["challenge:123456|0", "用户:张家龙|1", "账号:123456|1", "交易金额: 10000000|2", - "交易时间:2025-0605|2"] + authContent: ['challenge:123456|0', '用户:张家龙|1', '账号:123456|1', '交易金额: 10000000|2', + '交易时间:2025-0605|2'] } const label: trustedAuthentication.TUILable = { image: buffer, - title: '指纹交易认证' + title: $r('app.string.FingerprintVerification') } const result = await trustedAuthentication.procContentAuthentication(challenge, credentialID, reqParams, label); - console.log('指纹交易认证:', result.authToken); + hilog.info(DOMAIN, 'testTag', 'Fingerprint Verification Success:', result.authToken); return result; } catch (error) { - console.error('指纹交易认证失败:', error); - throw new Error('指纹交易认证失败:' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'Fingerprint Verification Fail:', error); + throw new Error('Fingerprint Verification Fail:' + (error as BusinessError).message); } } @@ -448,19 +461,19 @@ class TrustedAuth { const buffer: ArrayBuffer = await this.ImportImage(); const reqParams: trustedAuthentication.AuthReqParams = { reqType: trustedAuthentication.AuthType.AUTH_TYPE_TUI_PIN, - authContent: ["challenge:123456|0", "用户:张家龙|1", "账号:123456|1", "交易金额: 10000000|2", - "交易时间:2025-0605|2"] + authContent: ['challenge:123456|0', '用户:张家龙|1', '账号:123456|1', '交易金额: 10000000|2', + '交易时间:2025-0605|2'] } const label: trustedAuthentication.TUILable = { image: buffer, - title: '密码交易认证' + title: $r('app.string.PINVerification') } const result = await trustedAuthentication.procContentAuthentication(challenge, credentialID, reqParams, label); - console.log('密码交易认证:', result.authToken); + hilog.info(DOMAIN, 'testTag', 'Pin Verification Success:', result.authToken); return result; } catch (error) { - console.error('密码交易认证失败:', error); - throw new Error('密码交易认证失败:' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'Pin Verification Fail:', error); + throw new Error('Pin Verification Fail:' + (error as BusinessError).message); } } @@ -495,7 +508,7 @@ class TrustedAuth { properties: properties, inData: new Uint8Array(new Array()) } - await publicGenKeyFunc(keyAlias, huksOptions); + await publicGenKeyFunc(KEY_ALIAS, huksOptions); }; async SignInit(): Promise { @@ -505,10 +518,10 @@ class TrustedAuth { inData: new Uint8Array } - let result = await huks.initSession(keyAlias, options); - handle = result.handle; - challenge = result.challenge as Uint8Array - console.error('initSession complete' + handle + '----' + challenge); + let result = await huks.initSession(KEY_ALIAS, options); + let handle = result.handle; + let challenge = result.challenge as Uint8Array + hilog.info(DOMAIN, 'testTag', 'initSession complete' + handle + '----' + challenge); return result; } @@ -517,22 +530,21 @@ class TrustedAuth { let resArray: Uint8Array = await AssetUtils.QueryDataFromAssetStore(assetName); let credentialID: bigint = this.uint8ArrayToBigInt(resArray); await trustedAuthentication.disableTrustedBioAuthentication(credentialID, authType); - console.log('解绑成功'); + hilog.info(DOMAIN, 'testTag', 'unBound success'); } catch (error) { - console.error('解绑失败', JSON.stringify(error)); - throw new Error('解绑失败' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'unBound fail', JSON.stringify(error)); + throw new Error('unBound fail' + (error as BusinessError).message); } } async HuksSignAndVerify(session: huks.HuksSessionHandle, authToken: Uint8Array): Promise { - let inputdata = "challenge:123456|0\n用户:张家龙|1\n账号:123456|1\n交易金额: 10000000|2\n交易时间:2025-0605|2"; + let inputdata = 'challenge:123456|0\n用户:张家龙|1\n账号:123456|1\n交易金额: 10000000|2\n交易时间:2025-0605|2'; try { let signature = await SignFinish(session.handle, authToken, inputdata); - - console.log('IAM auth on success'); + hilog.info(DOMAIN, 'testTag', 'IAM auth on success'); } catch (error) { - console.error('IAM auth catch error', JSON.stringify(error)); - throw new Error('拉起IAM控件失败' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'IAM auth catch error', JSON.stringify(error)); + throw new Error('pull up IAM Fail' + (error as BusinessError).message); } } @@ -541,41 +553,41 @@ class TrustedAuth { let challenge: Uint8Array = session.challenge as Uint8Array; let tempAuthToken: trustedAuthentication.AuthToken; if (authType === TUI_PIN_SET) { - console.log('============创建密码============'); + hilog.info(DOMAIN, 'testTag', '============createPW============'); tempAuthToken = await this.SetPwd(challenge, label); } else if (authType === TUI_PIN_MODIFY) { - console.log('============修改密码============'); + hilog.info(DOMAIN, 'testTag', '============modifyPW============'); tempAuthToken = await this.ModifyPwd(challenge, label); } else if (authType === TUI_PIN_DISABLE) { - console.log('============关闭数字盾============'); + hilog.info(DOMAIN, 'testTag', '============closeShield============'); tempAuthToken = await this.DisablePwd(challenge, label); } else if (authType === TUI_PIN_SET_MIX) { - console.log('============创建密码============'); + hilog.info(DOMAIN, 'testTag', '============createPW============'); tempAuthToken = await this.SetPwdMix(challenge, label); } else if (authType === TUI_PIN_MODIFY_MIX) { - console.log('============修改密码============'); + hilog.info(DOMAIN, 'testTag', '============modifyPW============'); tempAuthToken = await this.ModifyPwdMix(challenge, label); } else { - console.log('============开始密码交易认证============'); + hilog.info(DOMAIN, 'testTag', '============startPINVerification============'); tempAuthToken = await this.ContentVerifyByPwd(challenge, label); } const TuiAuthToken: trustedAuthentication.AuthToken = tempAuthToken; let authToken = TuiAuthToken.authToken; let inputdata = - "challenge:123456|0\n用户:张家龙|1\n账号:123456|1\n交易金额: 10000000|2\n交易时间:2025-0605|2"; + 'challenge:123456|0\n用户:张家龙|1\n账号:123456|1\n交易金额: 10000000|2\n交易时间:2025-0605|2'; try { SignFinish(session.handle, authToken, inputdata).then((data) => { - signature = data as Uint8Array; + let signature = data as Uint8Array; Verify(inputdata, signature); }); - console.log('HUKS -> IAM auth on success'); + hilog.info(DOMAIN, 'testTag', 'HUKS -> IAM auth on success'); } catch (error) { - console.error('HUKS -> IAM auth error', JSON.stringify(error)); - throw new Error('拉起IAM控件失败' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'HUKS -> IAM auth error', JSON.stringify(error)); + throw new Error('pull up IAM Fail' + (error as BusinessError).message); } } - async UserAuthBeforeSign(indata: string, session: huks.HuksSessionHandle, authType: number): Promise { + async UserAuthBeforeSign(session: huks.HuksSessionHandle, authType: number): Promise { let authTypeList: number[] = new Array(); if (authType === TUI_BIND_FACE || authType === TUI_CONTENT_FACE_VERIFY) { authTypeList[0] = userAuth.UserAuthType.FACE; @@ -591,23 +603,23 @@ class TrustedAuth { title: ' ' }; try { - console.log('auth start'); + hilog.info(DOMAIN, 'testTag', 'auth start'); const userAuthInstance = userAuth.getUserAuthInstance(authParam, widgetParam); - console.log('auth success'); + hilog.info(DOMAIN, 'testTag', 'auth success'); - return new Promise((resolve, reject) => { + return new Promise((resolve) => { userAuthInstance.on('result', { onResult(result) { - authTokenData = result.token; - console.log('auth result authTokenData', authTokenData); + let authTokenData = result.token; + hilog.info(DOMAIN, 'testTag', 'auth result authTokenData', authTokenData); resolve(authTokenData); } }); userAuthInstance.start(); }); } catch (error) { - console.error('HUKS -> IAM auth error', JSON.stringify(error)); - throw new Error('拉起IAM控件失败' + (error as BusinessError).message); + hilog.error(DOMAIN, 'testTag', 'HUKS -> IAM auth error', JSON.stringify(error)); + throw new Error('pull up IAM Fail' + (error as BusinessError).message); } } @@ -620,18 +632,21 @@ class TrustedAuth { if (authType === TUI_BIND_FACE) { try { let enrolledState = userAuth.getEnrolledState(userAuth.UserAuthType.FACE); - console.info(`get current face enrolled state success enrolledState = ${JSON.stringify(enrolledState)}`); + hilog.info(DOMAIN, 'testTag', + `get current face enrolled state success enrolledState = ${JSON.stringify(enrolledState)}`); } catch (error) { - console.error(`get current face enrolled state failed, error = ${JSON.stringify(error)}`); + hilog.error(DOMAIN, 'testTag', `get current face enrolled state failed, error = ${JSON.stringify(error)}`); throw new Error('bind' + (error as BusinessError).message); } tempAuthToken = await this.PwdVerify(challenge, assetName); } else if (authType === TUI_BIND_FINGERPRINT) { try { let enrolledState = userAuth.getEnrolledState(userAuth.UserAuthType.FINGERPRINT); - console.info(`get current fingerprint enrolled state success enrolledState = ${JSON.stringify(enrolledState)}`); + hilog.info(DOMAIN, 'testTag', + `get current fingerprint enrolled state success enrolledState = ${JSON.stringify(enrolledState)}`); } catch (error) { - console.error(`get current fingerprint enrolled state failed, error = ${JSON.stringify(error)}`); + hilog.error(DOMAIN, 'testTag', + `get current fingerprint enrolled state failed, error = ${JSON.stringify(error)}`); throw new Error('bind' + (error as BusinessError).message); } tempAuthToken = await this.PwdVerify(challenge, assetName); @@ -645,7 +660,7 @@ class TrustedAuth { return tempAuthToken.authToken; } catch (error) { const err: BusinessError = error as BusinessError; - console.error(`get TUI Authtoken failed. Code is ${err?.code}, message is ${err?.message}`); + hilog.error(DOMAIN, 'testTag', `get TUI Authtoken failed. Code is ${err?.code}, message is ${err?.message}`); throw new Error((err as BusinessError).message); } } diff --git a/entry/src/main/ets/pages/MainPage.ets b/entry/src/main/ets/pages/MainPage.ets index b2f1946ece0384841717fe5f7fedfd1f4a406f72..1dfc6566fbdb512e627bb1e6dcc5673d080a256c 100644 --- a/entry/src/main/ets/pages/MainPage.ets +++ b/entry/src/main/ets/pages/MainPage.ets @@ -13,23 +13,24 @@ * limitations under the License. */ -import { trustedAppService } from '@kit.DeviceSecurityKit'; import { trustedAuthentication } from '@kit.DeviceSecurityKit'; import TrustedAuth from '../model/TrustedAuthentication'; -import createOptions from '../Common/TrustedServiceOption'; import { BusinessError } from '@kit.BasicServicesKit'; import { cryptoFramework } from '@kit.CryptoArchitectureKit'; import { userAuth } from '@kit.UserAuthenticationKit'; import { PromptAction } from '@kit.ArkUI'; -import AssetUtils from '../Utils/AssetUtils'; +import AssetUtils from '../utils/AssetUtils'; +import { hilog } from '@kit.PerformanceAnalysisKit'; const TUI_PIN_DISABLE = 3 const TUI_BIND_FACE = 7 const TUI_BIND_FINGERPRINT = 8 +const DOMAIN = 0x0000 +const NOT_ENROLLED_ERROR = 12500010 @Builder -export function MainPageBuilder(name: string, param: Object) { +export function MainPageBuilder() { MainPage() } @@ -46,16 +47,6 @@ export struct MainPage { uiContext: UIContext = this.getUIContext(); promptAction: PromptAction = this.uiContext.getPromptAction(); - async createAttestKey(): Promise { - trustedAppService.createAttestKey(createOptions) - .then(() => { - this.message += '\n\n 创建证明密钥成功'; - }) - .catch((err: BusinessError) => { - this.message += '\n\n 创建证明密钥失败: ' + err.message; - }); - } - async aboutToAppear(): Promise { const bytes = [0x00, 0x00, 0x00, 0x80, 0x80, 0xd2, 0x41, 0x40]; const buffer = new ArrayBuffer(bytes.length); @@ -75,13 +66,13 @@ export struct MainPage { if(this.hasFingerprintAbility){ try { userAuth.getAvailableStatus(userAuth.UserAuthType.FINGERPRINT, userAuth.AuthTrustLevel.ATL3); - console.info('current auth trust level supported'); + hilog.info(DOMAIN, 'testTag', 'current auth trust level supported'); } catch (error) { const err: BusinessError = error as BusinessError; - if(error.code === 12500010){ - console.error(`Authentication bio is not enrolled. Code is ${err?.code}, message is ${err?.message}`) + if(error.code === NOT_ENROLLED_ERROR){ + hilog.error(DOMAIN, 'testTag', `Authentication bio is not enrolled. Code is ${err?.code}, message is ${err?.message}`); }else{ - console.error(`current auth trust level not supported. Code is ${err?.code}, message is ${err?.message}`) + hilog.error(DOMAIN, 'testTag', `current auth trust level not supported. Code is ${err?.code}, message is ${err?.message}`); this.hasFingerprintAbility = false; this.bioState--; } @@ -90,13 +81,13 @@ export struct MainPage { if(this.hasFaceAbility){ try { userAuth.getAvailableStatus(userAuth.UserAuthType.FACE, userAuth.AuthTrustLevel.ATL4); - console.info('current auth trust level supported'); + hilog.info(DOMAIN, 'testTag', 'current auth trust level supported'); } catch (error) { const err: BusinessError = error as BusinessError; - if(error.code === 12500010){ - console.error(`Authentication bio is not enrolled. Code is ${err?.code}, message is ${err?.message}`) + if(error.code === NOT_ENROLLED_ERROR){ + hilog.error(DOMAIN, 'testTag', `Authentication bio is not enrolled. Code is ${err?.code}, message is ${err?.message}`); }else{ - console.error(`current auth trust level not supported. Code is ${err?.code}, message is ${err?.message}`) + hilog.error(DOMAIN, 'testTag', `current auth trust level not supported. Code is ${err?.code}, message is ${err?.message}`); this.hasFaceAbility = false; this.bioState--; } @@ -109,7 +100,7 @@ export struct MainPage { Scroll() { Column() { Column() { - Text('身份认证设置') + Text($r('app.string.IDSetting')) .width('100%') .fontSize(500) .fontSize(14) @@ -123,21 +114,21 @@ export struct MainPage { }) Row() { - Text('数字盾').textAlign(TextAlign.Start).margin({ left: 12 }) + Text($r('app.string.DigitalShield')).textAlign(TextAlign.Start).margin({ left: 12 }) Blank() if (this.hasShield) { - Button('修改密码') + Button($r('app.string.ModifyPassword')) .buttonStyle(ButtonStyleMode.NORMAL) .margin({ top: 14, bottom: 14, right: 12 }) .onClick(async () => { - this.pageInfos.pushPath({name: "PageOne"}) + this.pageInfos.pushPath({name: 'PasswordSelectionPage'}) }); } else { - Button(' 开通 ') + Button($r('app.string.OpenWord')) .buttonStyle(ButtonStyleMode.NORMAL) .margin({ top: 14, bottom: 14, right: 12 }) .onClick(() => { - this.pageInfos.pushPath({ name: "PageOne" }) + this.pageInfos.pushPath({ name: 'PasswordSelectionPage' }) }) } } @@ -152,7 +143,7 @@ export struct MainPage { if (this.hasShield) { Column() { - Text('关闭数字盾') + Text($r('app.string.CloseShield')) .width('100%') .fontSize(500) .fontSize(14) @@ -167,25 +158,25 @@ export struct MainPage { Column() { Row() { - Text('需认证关闭数字盾').textAlign(TextAlign.Start).margin({ left: 12 }) + Text($r('app.string.CloseShieldWithVerification')).textAlign(TextAlign.Start).margin({ left: 12 }) Blank() - Button('关闭') + Button($r('app.string.CloseWord')) .buttonStyle(ButtonStyleMode.NORMAL) .margin({ top: 14, bottom: 14, right: 12 }) .onClick(async () => { this.message = ''; try { let session = await TrustedAuth.SignInit(); - console.info("签名初始化完成"); - let indata: string = "aaabbb"; - await TrustedAuth.UserAuthTUIPINBeforeSign(indata, session, TUI_PIN_DISABLE, "pin_label1"); - this.message += `关闭数字盾成功`; + hilog.info(DOMAIN, 'testTag', 'Finish Signature Initialization'); + let indata: string = 'aaabbb'; + await TrustedAuth.UserAuthTUIPINBeforeSign(indata, session, TUI_PIN_DISABLE, 'pin_label1'); + this.message += $r('app.string.CloseShieldSuccess'); this.hasShield = false; this.fingerprintBind = false; this.faceBind = false; } catch (error) { - console.error('n关闭数字盾失败:', error); - this.message += `\n\n关闭数字盾失败: ${error}`; + hilog.error(DOMAIN, 'testTag', 'Close Shield Fail:', error); + this.message += $r('app.string.CloseShieldFail') + `: ${error}`; } this.promptAction.openToast({ message: this.message, @@ -198,9 +189,9 @@ export struct MainPage { Divider().width('93%') Row() { - Text('无需认证关闭数字盾').textAlign(TextAlign.Start).margin({ left: 12 }) + Text($r('app.string.CloseShieldWithoutVerification')).textAlign(TextAlign.Start).margin({ left: 12 }) Blank() - Button('关闭') + Button($r('app.string.CloseWord')) .buttonStyle(ButtonStyleMode.NORMAL) .margin({ top: 14, bottom: 14, right: 12 }) .onClick(async () => { @@ -209,15 +200,15 @@ export struct MainPage { const rand = cryptoFramework.createRandom(); const len: number = 32; const challenge: Uint8Array = rand?.generateRandomSync(len)?.data; - const authToken = await TrustedAuth.disablePwdWithoutAuth(challenge, "pin_label1"); - console.log('关闭数字盾成功:', authToken); - this.message += `关闭数字盾成功`; + const authToken = await TrustedAuth.disablePwdWithoutAuth(challenge, 'pin_label1'); + hilog.info(DOMAIN, 'testTag', 'Close Shield Success:', authToken); + this.message += $r('app.string.CloseShieldSuccess'); this.hasShield = false; this.fingerprintBind = false; this.faceBind = false; } catch (error) { - console.error('n关闭数字盾失败:', error); - this.message += `\n\n关闭数字盾失败: ${error}`; + hilog.error(DOMAIN, 'testTag', 'Close Shield Fail:', error); + this.message += $r('app.string.CloseShieldFail')+ `: ${error}`; } this.promptAction.openToast({ message: this.message, @@ -239,7 +230,7 @@ export struct MainPage { if(this.bioState != 0){ Column() { - Text('生物特征认证方式') + Text($r('app.string.BioFeatureVerification')) .width('100%') .fontSize(500) .fontSize(14) @@ -257,35 +248,34 @@ export struct MainPage { if(this.hasFingerprintAbility){ if (!this.fingerprintBind) { Row() { - Text('指纹识别').textAlign(TextAlign.Start).margin({ left: 12 }) + Text($r('app.string.Fingerprint')).textAlign(TextAlign.Start).margin({ left: 12 }) Blank() - Button('绑定') + Button($r('app.string.Bind')) .buttonStyle(ButtonStyleMode.NORMAL) .margin({ top: 14, bottom: 14, right: 12 }) .onClick(async () => { this.message = ''; try { let session = await TrustedAuth.SignInit(); - console.info("签名初始化完成"); - let indata: string = "aaabbb"; + hilog.info(DOMAIN, 'testTag', 'Finish Signature Initialization'); const tuiAuthToken: Uint8Array = await TrustedAuth.GetTUIAuthTokenBeforeBioVerify(session, TUI_BIND_FINGERPRINT, - "pin_label1"); + 'pin_label1'); let bioAuthToken: Uint8Array = - await TrustedAuth.UserAuthBeforeSign(indata, session, TUI_BIND_FINGERPRINT); + await TrustedAuth.UserAuthBeforeSign(session, TUI_BIND_FINGERPRINT); let operType = trustedAuthentication.OperateType.OPERATE_TYPE_BIOMETRIC_AUTH; let resignAuthToken = await trustedAuthentication.getBiometricAuthToken(operType, tuiAuthToken, bioAuthToken); - let inputdata = "challenge:123456|0\n用户:张家龙|1\n账号:123456|1\n交易金额:1000000000|2"; + let inputdata = 'challenge:123456|0\n用户:张家龙|1\n账号:123456|1\n交易金额:1000000000|2'; await TrustedAuth.bindFaceID(session.handle, resignAuthToken.authToken, inputdata) - this.message += `指纹绑定成功`; + this.message += $r('app.string.BindFingerprintSuccess'); this.fingerprintBind = true; } catch (error) { - console.error('n指纹绑定失败:', error); + hilog.error(DOMAIN, 'testTag', 'Bind Fingerprint Fail:', error); if(error.message === 'Authentication template has not been enrolled.'){ - this.message += `\n\n指纹绑定失败:请前往系统界面绑定生物信息` + this.message += $r('app.string.BindFingerprintFailWithNotification') }else{ - this.message += `\n\n指纹绑定失败: ${error}`; + this.message += $r('app.string.BindFingerprintFail')+ `: ${error}`; } } this.promptAction.openToast({ @@ -298,22 +288,22 @@ export struct MainPage { .height(56) } else { Row() { - Text('指纹识别--已绑定').textAlign(TextAlign.Start).margin({ left: 12 }) + Text( $r('app.string.FingerprintBound')).textAlign(TextAlign.Start).margin({ left: 12 }) Blank() - Button('解绑') + Button($r('app.string.UnBound')) .buttonStyle(ButtonStyleMode.NORMAL) .margin({ top: 14, bottom: 14, right: 12 }) .onClick(async () => { this.message = ''; try { let authType = trustedAuthentication.AuthType.AUTH_TYPE_FINGERPRINT; - await TrustedAuth.disableTrustedBioAuthentication("pin_label1", authType); - this.message += `解绑指纹成功`; + await TrustedAuth.disableTrustedBioAuthentication('pin_label1', authType); + this.message += $r('app.string.UnBoundFingerprintSuccess'); this.fingerprintBind = false; } catch (error) { // 捕获错误并处理 - console.error('解绑指纹失败:', error); - this.message += `\n\n解绑指纹失败: ${error}`; + hilog.error(DOMAIN, 'testTag', 'UnBound Fingerprint Fail:', error); + this.message += $r('app.string.UnBoundFingerprintFail')+`: ${error}`; } this.promptAction.openToast({ message: this.message, @@ -330,34 +320,33 @@ export struct MainPage { if(this.hasFaceAbility){ if (!this.faceBind) { Row() { - Text('人脸识别').textAlign(TextAlign.Start).margin({ left: 12 }) + Text($r('app.string.Face')).textAlign(TextAlign.Start).margin({ left: 12 }) Blank() - Button('绑定') + Button($r('app.string.Bind')) .buttonStyle(ButtonStyleMode.NORMAL) .margin({ top: 14, bottom: 14, right: 12 }) .onClick(async () => { this.message = ''; try { let session = await TrustedAuth.SignInit(); - console.info("签名初始化完成"); - let indata: string = "aaabbb"; + hilog.info(DOMAIN, 'testTag', 'Finish Signature Initialization'); const tuiAuthToken: Uint8Array = - await TrustedAuth.GetTUIAuthTokenBeforeBioVerify(session, TUI_BIND_FACE, "pin_label1"); + await TrustedAuth.GetTUIAuthTokenBeforeBioVerify(session, TUI_BIND_FACE, 'pin_label1'); let bioAuthToken: Uint8Array = - await TrustedAuth.UserAuthBeforeSign(indata, session, TUI_BIND_FACE); + await TrustedAuth.UserAuthBeforeSign(session, TUI_BIND_FACE); let operType = trustedAuthentication.OperateType.OPERATE_TYPE_BIOMETRIC_AUTH; let resignAuthToken = await trustedAuthentication.getBiometricAuthToken(operType, tuiAuthToken, bioAuthToken); - let inputdata = "challenge:123456|0\n用户:张家龙|1\n账号:123456|1\n交易金额:1000000000|2"; + let inputdata = 'challenge:123456|0\n用户:张家龙|1\n账号:123456|1\n交易金额:1000000000|2'; await TrustedAuth.bindFaceID(session.handle, resignAuthToken.authToken, inputdata) - this.message += `人脸绑定成功`; + this.message += $r('app.string.BindFaceSuccess'); this.faceBind = true; } catch (error) { - console.error('n人脸绑定失败:', error); + hilog.error(DOMAIN, 'testTag', 'Bind Face Fail:', error); if(error.message === 'Authentication template has not been enrolled.'){ - this.message += `\n\n人脸绑定失败:请前往系统界面绑定生物信息` + this.message += $r('app.string.BindFaceFailWithNotification') }else{ - this.message += `\n\n人脸绑定失败: ${error}`; + this.message += $r('app.string.BindFaceFail')+ ` : ${error}`; } } this.promptAction.openToast({ @@ -369,22 +358,22 @@ export struct MainPage { .height(56) } else { Row() { - Text('人脸识别--已绑定').textAlign(TextAlign.Start).margin({ left: 12 }) + Text($r('app.string.FaceBound')).textAlign(TextAlign.Start).margin({ left: 12 }) Blank() - Button('解绑') + Button($r('app.string.UnBound')) .buttonStyle(ButtonStyleMode.NORMAL) .margin({ top: 14, bottom: 14, right: 12 }) .onClick(async () => { this.message = ''; try { let authType = trustedAuthentication.AuthType.AUTH_TYPE_FACE; - await TrustedAuth.disableTrustedBioAuthentication("pin_label1", authType); - this.message += `解绑人脸成功`; + await TrustedAuth.disableTrustedBioAuthentication('pin_label1', authType); + this.message += $r('app.string.UnBoundFaceSuccess'); this.faceBind = false; } catch (error) { // 捕获错误并处理 - console.error('检查失败:', error); - this.message += `\n\n解绑人脸失败: ${error}`; + hilog.error(DOMAIN, 'testTag', 'UnBound Face Fail:', error); + this.message += $r('app.string.UnBoundFaceFail')+`: ${error}`; } this.promptAction.openToast({ message: this.message, @@ -412,11 +401,11 @@ export struct MainPage { .constraintSize({minHeight:'100%'}) .width('100%') }.height('calc(100% - 56vp)') - Button('去转账').width('calc(100% - 32vp)').onClick(() => { - this.pageInfos.pushPath({ name: "PageTwo" }) + Button($r('app.string.Trade')).width('calc(100% - 32vp)').onClick(() => { + this.pageInfos.pushPath({ name: 'TradingPage' }) }).margin({ bottom: 16 }) } - .title('金融数字盾') + .title($r('app.string.FinDigitalShield')) .hideBackButton(true) .backgroundColor('#F1F3F5') .width('100%') diff --git a/entry/src/main/ets/pages/PageOne.ets b/entry/src/main/ets/pages/PasswordSelectionPage.ets similarity index 59% rename from entry/src/main/ets/pages/PageOne.ets rename to entry/src/main/ets/pages/PasswordSelectionPage.ets index 20327fbf477f6684a93f6dcea90a8f02d17c8708..5ff9689a18ab719142dbdb4d1551baed45d053d3 100644 --- a/entry/src/main/ets/pages/PageOne.ets +++ b/entry/src/main/ets/pages/PasswordSelectionPage.ets @@ -1,19 +1,34 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ import TrustedAuth from '../model/TrustedAuthentication'; import { PromptAction } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; const TUI_PIN_SET = 1 const TUI_PIN_MODIFY = 2 const TUI_PIN_SET_MIX = 9 const TUI_PIN_MODIFY_MIX = 10 - +const DOMAIN = 0x0000 @Builder -export function PageOneBuilder(name: string, param: Object) { - PageOne() +export function PasswordSelectionPageBuilder() { + PasswordSelectionPage() } @Component -export struct PageOne { +export struct PasswordSelectionPage { @State onlyNum: boolean = true; @State message: string = ''; @State type: number = 0; @@ -26,7 +41,7 @@ export struct PageOne { NavDestination() { Column() { Column() { - Text('请设定数字盾的验证方式') + Text($r('app.string.PlzSetVerificationWay')) .width('100%') .fontSize(500) .fontSize(14) @@ -41,7 +56,7 @@ export struct PageOne { Row() { Checkbox().margin({ left: 18 }).select(this.onlyNum!!) - Text('数字密码').textAlign(TextAlign.Start).margin({ left: 8 }) + Text($r('app.string.PureNumber')).textAlign(TextAlign.Start).margin({ left: 8 }) } .width('calc(100% - 32vp)') .height(56) @@ -57,7 +72,7 @@ export struct PageOne { Checkbox().margin({ left: 18 }).select(!this.onlyNum).onClick(() => { this.onlyNum = !this.onlyNum }) - Text('数字+英文组合密码').textAlign(TextAlign.Start).margin({ left: 8 }) + Text($r('app.string.NumberPlusAlphabet')).textAlign(TextAlign.Start).margin({ left: 8 }) } .width('calc(100% - 32vp)') .height(56) @@ -70,7 +85,7 @@ export struct PageOne { Blank() if(this.hasShield){ - Button('立即修改').width('calc(100% - 32vp)').onClick(async () => { + Button($r('app.string.ModifyWord')).width('calc(100% - 32vp)').onClick(async () => { this.message = ''; if (this.onlyNum) { this.type = TUI_PIN_MODIFY; @@ -79,17 +94,17 @@ export struct PageOne { } try { await TrustedAuth.TestGenKeyForTuiPinSign(); - console.log('生成密钥成功'); + hilog.info(DOMAIN, 'testTag', 'Generate Key Success'); let session = await TrustedAuth.SignInit(); - console.info("签名初始化完成"); - let indata: string = "aaabbb"; + hilog.info(DOMAIN, 'testTag', 'Signature Initialization success'); + let indata: string = 'aaabbb'; await TrustedAuth.UserAuthTUIPINBeforeSign(indata, session, this.type, 'pin_label1'); - this.message += `修改数字盾密码成功`; + this.message += $r('app.string.ModifyPwSuccess'); this.hasShield = true; } catch (error) { - // 捕获错误并处理 - console.error('检查失败:', error); - this.message += `修改数字盾密码失败: ${error}`; + // catch error + hilog.error(DOMAIN, 'testTag', 'Modify Pw Fail:', error); + this.message += $r('app.string.ModifyPwFail')+`: ${error}`; } this.promptAction.openToast({ message: this.message, @@ -99,7 +114,7 @@ export struct PageOne { }).margin({ bottom: 16 }) } else{ - Button('立即开通').width('calc(100% - 32vp)').onClick(async () => { + Button($r('app.string.OpenWord')).width('calc(100% - 32vp)').onClick(async () => { this.message = ''; if (this.onlyNum) { this.type = TUI_PIN_SET; @@ -108,17 +123,17 @@ export struct PageOne { } try { await TrustedAuth.TestGenKeyForTuiPinSign(); - console.log('生成密钥成功'); + hilog.info(DOMAIN, 'testTag', 'GenerateKeySuccess'); let session = await TrustedAuth.SignInit(); - console.info("签名初始化完成"); - let indata: string = "aaabbb"; + hilog.info(DOMAIN, 'testTag', 'Signature Initialization success'); + let indata: string = 'aaabbb'; await TrustedAuth.UserAuthTUIPINBeforeSign(indata, session, this.type, 'pin_label1'); - this.message += `开通数字盾成功`; + this.message += $r('app.string.OpenShieldSuccess'); this.hasShield = true; } catch (error) { - // 捕获错误并处理 - console.error('检查失败:', error); - this.message += `\n\n开通数字盾失败: ${error}`; + // catch error + hilog.error(DOMAIN, 'testTag', 'OpenShield Fail:', error); + this.message += $r('app.string.OpenShieldFail')+`: ${error}`; } this.promptAction.openToast({ message: this.message, @@ -129,7 +144,7 @@ export struct PageOne { } }.width('100%').height('100%') } - .title('数字盾') + .title($r('app.string.DigitalShield')) .backgroundColor('#F1F3F5') } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/PageTwo.ets b/entry/src/main/ets/pages/TradingPage.ets similarity index 55% rename from entry/src/main/ets/pages/PageTwo.ets rename to entry/src/main/ets/pages/TradingPage.ets index 2a74cc9edf112e11e878c0969748fa113a15d56d..1b0ce109627b4f607b63b135ef87e42cffd475b4 100644 --- a/entry/src/main/ets/pages/PageTwo.ets +++ b/entry/src/main/ets/pages/TradingPage.ets @@ -1,18 +1,34 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ import TrustedAuth from '../model/TrustedAuthentication'; -import { PromptAction } from "@kit.ArkUI"; +import { PromptAction } from '@kit.ArkUI'; import { trustedAuthentication } from '@kit.DeviceSecurityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; const TUI_CONTENT_PWD_VERIFY = 4 const TUI_CONTENT_FACE_VERIFY = 5 const TUI_CONTENT_FINGERPRINT_VERIFY = 6 +const DOMAIN = 0x0000 @Builder -export function PageTwoBuilder(name: string, param: Object) { - PageTwo() +export function TradingPageBuilder() { + TradingPage() } @Builder -export function BindSheetBuilder(name: string, param: Object) { +export function BindSheetBuilder() { BindSheetTemp() } @@ -29,17 +45,17 @@ export struct BindSheetTemp { build() { Column({ space: 12 }) { - Button('密码交易认证').width('calc(100% - 32vp)').buttonStyle(ButtonStyleMode.NORMAL).onClick(async () => { + Button($r('app.string.PINVerification')).width('calc(100% - 32vp)').buttonStyle(ButtonStyleMode.NORMAL).onClick(async () => { this.message = ''; try { let session = await TrustedAuth.SignInit(); - console.info("签名初始化完成"); + hilog.info(DOMAIN, 'testTag', 'Signature Initialization success'); let indata: string = this.receiver + '/' + this.receiveAccount + '/' + this.tradingAmount; - await TrustedAuth.UserAuthTUIPINBeforeSign(indata, session, TUI_CONTENT_PWD_VERIFY, "pin_label1"); - this.message += `密码交易认证成功`; + await TrustedAuth.UserAuthTUIPINBeforeSign(indata, session, TUI_CONTENT_PWD_VERIFY, 'pin_label1'); + this.message += $r('app.string.PINVerificationSuccess'); } catch (error) { - console.error('n密码交易认证失败:', error); - this.message += `\n\n密码交易认证失败: ${error}`; + hilog.error(DOMAIN, 'testTag', 'PIN Verification Fail:', error); + this.message += $r('app.string.PINVerificationFail')+ `: ${error}`; } this.promptAction.openToast({ message: this.message, @@ -47,28 +63,27 @@ export struct BindSheetTemp { }) }); if (this.fingerprintBind) { - Button('指纹交易认证').width('calc(100% - 32vp)').buttonStyle(ButtonStyleMode.NORMAL).onClick(async () => { + Button($r('app.string.FingerprintVerification')).width('calc(100% - 32vp)').buttonStyle(ButtonStyleMode.NORMAL).onClick(async () => { this.message = ''; try { let session = await TrustedAuth.SignInit(); - console.info("签名初始化完成"); - let indata: string = "aaabbb"; + hilog.info(DOMAIN, 'testTag', 'Signature Initialization success'); const tuiAuthToken: Uint8Array = - await TrustedAuth.GetTUIAuthTokenBeforeBioVerify(session, TUI_CONTENT_FINGERPRINT_VERIFY, "pin_label1"); + await TrustedAuth.GetTUIAuthTokenBeforeBioVerify(session, TUI_CONTENT_FINGERPRINT_VERIFY, 'pin_label1'); let bioAuthToken: Uint8Array = - await TrustedAuth.UserAuthBeforeSign(indata, session, TUI_CONTENT_FINGERPRINT_VERIFY); + await TrustedAuth.UserAuthBeforeSign(session, TUI_CONTENT_FINGERPRINT_VERIFY); let operType = trustedAuthentication.OperateType.OPERATE_TYPE_CONTENT_AUTH; let resignAuthToken = await trustedAuthentication.getBiometricAuthToken(operType, tuiAuthToken, bioAuthToken); await TrustedAuth.HuksSignAndVerify(session, resignAuthToken.authToken) - this.message += `指纹交易认证成功`; + this.message += $r('app.string.FingerprintVerificationSuccess'); } catch (error) { - console.error('n指纹交易认证失败:', error); + hilog.error(DOMAIN, 'testTag', 'Fingerprint Verification Fail:', error); if(error.code === 1019100019){ - this.message += `指纹交易认证失败:请用数字盾的指纹进行认证,多次失败请返回上一页解绑后重新绑定`; + this.message += $r('app.string.FingerprintVerificationFailWithNotification'); } else{ - this.message += `\n\n指纹交易认证失败: ${error}`; + this.message += $r('app.string.FingerprintVerificationFail')+ `: ${error}`; } } this.promptAction.openToast({ @@ -78,28 +93,27 @@ export struct BindSheetTemp { }); } if (this.faceBind) { - Button('人脸交易认证').width('calc(100% - 32vp)').buttonStyle(ButtonStyleMode.NORMAL).onClick(async () => { + Button($r('app.string.FaceVerification')).width('calc(100% - 32vp)').buttonStyle(ButtonStyleMode.NORMAL).onClick(async () => { this.message = ''; try { let session = await TrustedAuth.SignInit(); - console.info("签名初始化完成"); - let indata: string = "aaabbb"; + hilog.info(DOMAIN, 'testTag', 'Signature Initialization success'); const tuiAuthToken: Uint8Array = - await TrustedAuth.GetTUIAuthTokenBeforeBioVerify(session, TUI_CONTENT_FACE_VERIFY, "pin_label1"); + await TrustedAuth.GetTUIAuthTokenBeforeBioVerify(session, TUI_CONTENT_FACE_VERIFY, 'pin_label1'); let bioAuthToken: Uint8Array = - await TrustedAuth.UserAuthBeforeSign(indata, session, TUI_CONTENT_FACE_VERIFY); + await TrustedAuth.UserAuthBeforeSign(session, TUI_CONTENT_FACE_VERIFY); let operType = trustedAuthentication.OperateType.OPERATE_TYPE_CONTENT_AUTH; let resignAuthToken = await trustedAuthentication.getBiometricAuthToken(operType, tuiAuthToken, bioAuthToken); await TrustedAuth.HuksSignAndVerify(session, resignAuthToken.authToken) - this.message += `人脸交易认证成功`; + this.message += $r('app.string.FaceVerificationSuccess'); } catch (error) { - console.error('n人脸交易认证失败:', error); + hilog.error(DOMAIN, 'testTag', 'Face Verification Fail:', error); if(error.code === 1019100019){ - this.message += `人脸交易认证失败:请确认认证信息是否正确,多次失败请返回上一页解绑后重新绑定`; + this.message += $r('app.string.FaceVerificationFailWithNotification'); } else{ - this.message += `\n\n人脸交易认证失败: ${error}`; + this.message += $r('app.string.FaceVerificationFail')+ `: ${error}`; } } this.promptAction.openToast({ @@ -113,14 +127,14 @@ export struct BindSheetTemp { } @Component -export struct PageTwo { +export struct TradingPage { @State onlyNum: boolean = true; @Provide receiver: string = ''; @Provide receiveAccount: string = ''; @Provide tradingAmount: string = ''; @State bindSheetShow: boolean = false; pageInfos: NavPathStack = new NavPathStack(); - sheetTitleOption: SheetTitleOptions = { title: '选择认证方式' } + sheetTitleOption: SheetTitleOptions = { title: $r('app.string.ChooseVerificationMethod') } sheetOption: SheetOptions = { height: SheetSize.FIT_CONTENT, title: this.sheetTitleOption } build() { @@ -129,8 +143,8 @@ export struct PageTwo { Column() { Blank().height(4) Row() { - Text('收款人').width('20%').fontSize(14).textAlign(TextAlign.Start).margin({ left: 12 }) - TextArea({ placeholder: '张某某', text: this.receiver }) + Text($r('app.string.Recipient')).width('20%').fontSize(14).textAlign(TextAlign.Start).margin({ left: 12 }) + TextArea({ placeholder: $r('app.string.MRZhang'), text: this.receiver }) .width('75%') .fontSize(16) .backgroundColor(Color.White) @@ -138,7 +152,7 @@ export struct PageTwo { Divider().width('93%') Row() { - Text('收款账号').width('20%').fontSize(14).textAlign(TextAlign.Start).margin({ left: 12 }) + Text($r('app.string.AccountNumber')).width('20%').fontSize(14).textAlign(TextAlign.Start).margin({ left: 12 }) TextArea({ placeholder: '6666 1234 **** **** 888', text: this.receiveAccount }) .width('75%') .fontSize(16) @@ -147,7 +161,7 @@ export struct PageTwo { Divider().width('93%') Row() { - Text('交易金额').width('20%').fontSize(14).textAlign(TextAlign.Start).margin({ left: 12 }) + Text($r('app.string.TradingAmount')).width('20%').fontSize(14).textAlign(TextAlign.Start).margin({ left: 12 }) TextArea({ placeholder: '0.0', text: this.tradingAmount }) .width('75%') .fontSize(16) @@ -166,14 +180,14 @@ export struct PageTwo { bottom: 24 }) - Button('下一步').width('calc(100% - 32vp)') + Button($r('app.string.NextWord')).width('calc(100% - 32vp)') .onClick(() => { this.bindSheetShow = true; }) - .bindSheet(this.bindSheetShow!!, BindSheetBuilder('', ''), this.sheetOption); + .bindSheet(this.bindSheetShow!!, BindSheetBuilder(), this.sheetOption); } } - .title('银行卡转账') + .title($r('app.string.TransactionWord')) .backgroundColor('#F1F3F5') } } \ No newline at end of file diff --git a/entry/src/main/ets/Utils/AssetUtils.ets b/entry/src/main/ets/utils/AssetUtils.ets similarity index 54% rename from entry/src/main/ets/Utils/AssetUtils.ets rename to entry/src/main/ets/utils/AssetUtils.ets index 2e7417d41f3376429228c09535c44c840c5d60ea..1e525d5a4579167c4d06bc7f0ae58a6ec07785cc 100644 --- a/entry/src/main/ets/Utils/AssetUtils.ets +++ b/entry/src/main/ets/utils/AssetUtils.ets @@ -1,6 +1,23 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ import { util } from '@kit.ArkTS'; import { asset } from '@kit.AssetStoreKit'; import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const DOMAIN = 0x0000 class AssetUtils { hasShield: boolean = false; @@ -15,39 +32,39 @@ class AssetUtils { query.set(asset.Tag.ALIAS, this.stringToArray(name)); try { asset.remove(query).then(() => { - console.info(`Asset removed successfully`); + hilog.info(DOMAIN, 'testTag', 'Asset removed successfully'); }).catch((err: BusinessError) => { - console.error(`Failed to remove Asset. Code is ${err.code}, message is ${err.message}`); + hilog.error(DOMAIN, 'testTag', `Failed to remove Asset. Code is ${err.code}, message is ${err.message}`); }); } catch (error) { let err = error as BusinessError; - console.error(`Failed to remove Asset. Code is ${err.code}, message is ${err.message}`); + hilog.error(DOMAIN, 'testTag', `Failed to remove Asset. Code is ${err.code}, message is ${err.message}`); } } AddDataToAssetStore(data: Uint8Array, name: string, label: string): void { let attr: asset.AssetMap = new Map(); - console.info('secret input', data); + hilog.info(DOMAIN, 'testTag', 'secret input', data); attr.set(asset.Tag.SECRET, data); attr.set(asset.Tag.ALIAS, this.stringToArray(name)); attr.set(asset.Tag.ACCESSIBILITY, asset.Accessibility.DEVICE_FIRST_UNLOCKED); attr.set(asset.Tag.DATA_LABEL_NORMAL_1, this.stringToArray(label)); try { asset.add(attr).then(() => { - console.info('Asset Added successfully'); + hilog.info(DOMAIN, 'testTag', 'Asset Added successfully'); }).catch((err: BusinessError) => { - console.error(`Failed to add Asset. Code is ${err.code}, message is ${err.message}`); + hilog.error(DOMAIN, 'testTag', `Failed to add Asset. Code is ${err.code}, message is ${err.message}`); if (err.code === 24000003) { this.UpdateDataToAssetStore(data, name, label); } }); } catch (error) { let err = error as BusinessError; - console.error(`Failed to add Asset. Code is ${err.code}, message is ${err.message}`); + hilog.error(DOMAIN, 'testTag', `Failed to add Asset. Code is ${err.code}, message is ${err.message}`); } } - async UpdateDataToAssetStore(newData: Uint8Array, name: string, label: string): Promise { + UpdateDataToAssetStore(newData: Uint8Array, name: string, label: string): void { let query: asset.AssetMap = new Map(); query.set(asset.Tag.ALIAS, this.stringToArray(name)); let attrsToUpdate: asset.AssetMap = new Map(); @@ -55,13 +72,13 @@ class AssetUtils { attrsToUpdate.set(asset.Tag.DATA_LABEL_NORMAL_1, this.stringToArray(label)); try { asset.update(query, attrsToUpdate).then(() => { - console.info('Asset updated successfully'); + hilog.info(DOMAIN, 'testTag', 'Asset updated successfully'); }).catch((err: BusinessError) => { - console.error(`Failed to update Asset. Code is ${err.code}, message is ${err.message}`); + hilog.error(DOMAIN, 'testTag', `Failed to update Asset. Code is ${err.code}, message is ${err.message}`); }); } catch (error) { let err = error as BusinessError; - console.error(`Failed to update Asset. Code is ${err.code}, message is ${err.message}`); + hilog.error(DOMAIN, 'testTag', `Failed to update Asset. Code is ${err.code}, message is ${err.message}`); } } @@ -70,20 +87,20 @@ class AssetUtils { query.set(asset.Tag.ALIAS, this.stringToArray(name)); query.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL); let emptyArray = new Uint8Array(0); - console.info('Asset query begin'); + hilog.info(DOMAIN, 'testTag', 'Asset query begin'); try { - console.info('Asset query begin in try'); + hilog.info(DOMAIN, 'testTag', 'Asset query begin in try'); let res: Array = await asset.query(query); for (let i = 0; i < res.length; i++) { - console.info('Asset query begin in loop'); + hilog.info(DOMAIN, 'testTag', 'Asset query begin in loop'); let secret: Uint8Array = res[i].get(asset.Tag.SECRET) as Uint8Array; - console.info('secret output', secret); + hilog.info(DOMAIN, 'testTag', 'secret output', secret); return secret; } - console.info('Asset query begin again'); + hilog.info(DOMAIN, 'testTag', 'Asset query begin again'); } catch (error) { let err = error as BusinessError; - console.error(`Failed to query Asset. Code is ${err.code}, message is ${err.message}`); + hilog.error(DOMAIN, 'testTag', `Failed to query Asset. Code is ${err.code}, message is ${err.message}`); return emptyArray; } return emptyArray; diff --git a/entry/src/main/ets/Common/TrustedServiceOption.ets b/entry/src/main/ets/utils/TrustedServiceOption.ets similarity index 100% rename from entry/src/main/ets/Common/TrustedServiceOption.ets rename to entry/src/main/ets/utils/TrustedServiceOption.ets diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 8fb7a77d0f178aa4da49dc5ff7c47314e9d113ef..cc9f5b7f8efd715ea9a3175798acc77c7951c039 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -14,7 +14,246 @@ }, { "name": "reason", - "value": "申请必要权限" + "value": "Apply Necessary Rights" + }, + { + "name": "IDSetting", + "value": "Setting" + }, + { + "name": "DigitalShield", + "value": "Digital Shield" + }, + { + "name": "ModifyPassword", + "value": "Modify Password" + }, + { + "name": "OpenWord", + "value": "Enable" + }, + { + "name": "CloseShield", + "value": "Unable shield" + }, + { + "name": "CloseShieldWithVerification", + "value": "Unable shield with verification" + }, + { + "name": "CloseWord", + "value": "Unable" + }, + { + "name": "FinishSignatureInitialization", + "value": "Signature initialization finish" + }, + { + "name": "CloseShieldSuccess", + "value": "Unable shield success" + }, + { + "name": "CloseShieldFail", + "value": "Unable shield fail" + }, + { + "name": "CloseShieldWithoutVerification", + "value": "Unable shield without Verification" + }, + { + "name": "BioFeatureVerification", + "value": "Bio verification method" + }, + { + "name": "Fingerprint", + "value": "Fingerprint" + }, + { + "name": "Bind", + "value": "Bind" + }, + { + "name": "BindFingerprintSuccess", + "value": "Bind fingerprint success" + }, + { + "name": "BindFingerprintFail", + "value": "Bind fingerprint fail" + }, + { + "name": "BindFingerprintFailWithNotification", + "value": "Bind fingerprint fail:please bind bio feature in system setting" + }, + { + "name": "FingerprintBound", + "value": "Fingerprint--Bound" + }, + { + "name": "UnBound", + "value": "Unbound" + }, + { + "name": "UnBoundFingerprintSuccess", + "value": "Unbound fingerprint success" + }, + { + "name": "UnBoundFingerprintFail", + "value": "Unbound fingerprint fail" + }, + { + "name": "Face", + "value": "Face" + }, + { + "name": "BindFaceSuccess", + "value": "Bind face success" + }, + { + "name": "BindFaceFail", + "value": "Bind face fail" + }, + { + "name": "BindFaceFailWithNotification", + "value": "Bind face fail:please bind bio feature in system setting" + }, + { + "name": "FaceBound", + "value": "Face--Bound" + }, + { + "name": "UnBoundFaceSuccess", + "value": "Unbound face success" + }, + { + "name": "UnBoundFaceFail", + "value": "Unbound face fail" + }, + { + "name": "Trade", + "value": "Transfer" + }, + { + "name": "FinDigitalShield", + "value": "Financial Digital Shield" + }, + { + "name": "PlzSetVerificationWay", + "value": "Verification method setting" + }, + { + "name": "PureNumber", + "value": "Pure Number" + }, + { + "name": "NumberPlusAlphabet", + "value": "Number + Alphabet" + }, + { + "name": "ModifyWord", + "value": "Modify" + }, + { + "name": "GenerateKeySuccess", + "value": "Generate key success" + }, + { + "name": "ModifyPwSuccess", + "value": "Modify password success" + }, + { + "name": "ModifyPwFail", + "value": "Modify password fail" + }, + { + "name": "OpenShieldSuccess", + "value": "Enable Shield Success" + }, + { + "name": "OpenShieldFail", + "value": "Enable Shield Fail" + }, + { + "name": "ChooseVerificationMethod", + "value": "Choose verification method" + }, + { + "name": "Recipient", + "value": "Recipient" + }, + { + "name": "MRZhang", + "value": "Mr.Zhang" + }, + { + "name": "AccountNumber", + "value": "Target account number" + }, + { + "name": "TradingAmount", + "value": "Transaction amount" + }, + { + "name": "NextWord", + "value": "Next" + }, + { + "name": "TransactionWord", + "value": "Transaction" + }, + { + "name": "ShieldPwVerification", + "value": "Shield PIN verification" + }, + { + "name": "OpenShield", + "value": "Enable Shield" + }, + { + "name": "ModifyShield", + "value": "Modify Shield" + }, + { + "name": "FaceVerification", + "value": "Face Verification" + }, + { + "name": "FingerprintVerification", + "value": "Fingerprint Verification" + }, + { + "name": "PINVerification", + "value": "Pin Verification" + }, + { + "name": "PINVerificationSuccess", + "value": "PIN verification success" + }, + { + "name": "PINVerificationFail", + "value": "PIN verification fail" + }, + { + "name": "FingerprintVerificationSuccess", + "value": "Fingerprint verification success" + }, + { + "name": "FingerprintVerificationFail", + "value": "Fingerprint verification fail" + },{ + "name": "FingerprintVerificationFailWithNotification", + "value": "Fingerprint verification fail:please use the bound fingerprint,unbound after mutiple trys" + }, + { + "name": "FaceVerificationSuccess", + "value": "Face verification success" + }, + { + "name": "FaceVerificationFail", + "value": "Face verification fail" + }, + { + "name": "FaceVerificationFailWithNotification", + "value": "Face verification fail:please check the bound info,unbound after mutiple trys" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/router_map.json b/entry/src/main/resources/base/profile/router_map.json index 868d93f6c4fb497531c56d6d443d22346058596e..05daf5b3f9ef582f1f6d31b45b5a093516d419f3 100644 --- a/entry/src/main/resources/base/profile/router_map.json +++ b/entry/src/main/resources/base/profile/router_map.json @@ -9,19 +9,19 @@ } }, { - "name": "PageOne", - "pageSourceFile": "src/main/ets/pages/PageOne.ets", - "buildFunction": "PageOneBuilder", + "name": "PasswordSelectionPage", + "pageSourceFile": "src/main/ets/pages/PasswordSelectionPage.ets", + "buildFunction": "PasswordSelectionPageBuilder", "data": { - "description": "this is pageOne" + "description": "this is PasswordSelectionPage" } }, { - "name": "PageTwo", - "pageSourceFile": "src/main/ets/pages/PageTwo.ets", - "buildFunction": "PageTwoBuilder", + "name": "TradingPage", + "pageSourceFile": "src/main/ets/pages/TradingPage.ets", + "buildFunction": "TradingPageBuilder", "data": { - "description": "this is pageTwo" + "description": "this is TradingPage" } } ] diff --git a/entry/src/main/resources/en_US/element/color.json b/entry/src/main/resources/en_US/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/entry/src/main/resources/en_US/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/float.json b/entry/src/main/resources/en_US/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..a0a93dd91fd48f08f3a9532c76e9b26e68d4c034 --- /dev/null +++ b/entry/src/main/resources/en_US/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..cc9f5b7f8efd715ea9a3175798acc77c7951c039 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,259 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "TestDigitalShield" + }, + { + "name": "reason", + "value": "Apply Necessary Rights" + }, + { + "name": "IDSetting", + "value": "Setting" + }, + { + "name": "DigitalShield", + "value": "Digital Shield" + }, + { + "name": "ModifyPassword", + "value": "Modify Password" + }, + { + "name": "OpenWord", + "value": "Enable" + }, + { + "name": "CloseShield", + "value": "Unable shield" + }, + { + "name": "CloseShieldWithVerification", + "value": "Unable shield with verification" + }, + { + "name": "CloseWord", + "value": "Unable" + }, + { + "name": "FinishSignatureInitialization", + "value": "Signature initialization finish" + }, + { + "name": "CloseShieldSuccess", + "value": "Unable shield success" + }, + { + "name": "CloseShieldFail", + "value": "Unable shield fail" + }, + { + "name": "CloseShieldWithoutVerification", + "value": "Unable shield without Verification" + }, + { + "name": "BioFeatureVerification", + "value": "Bio verification method" + }, + { + "name": "Fingerprint", + "value": "Fingerprint" + }, + { + "name": "Bind", + "value": "Bind" + }, + { + "name": "BindFingerprintSuccess", + "value": "Bind fingerprint success" + }, + { + "name": "BindFingerprintFail", + "value": "Bind fingerprint fail" + }, + { + "name": "BindFingerprintFailWithNotification", + "value": "Bind fingerprint fail:please bind bio feature in system setting" + }, + { + "name": "FingerprintBound", + "value": "Fingerprint--Bound" + }, + { + "name": "UnBound", + "value": "Unbound" + }, + { + "name": "UnBoundFingerprintSuccess", + "value": "Unbound fingerprint success" + }, + { + "name": "UnBoundFingerprintFail", + "value": "Unbound fingerprint fail" + }, + { + "name": "Face", + "value": "Face" + }, + { + "name": "BindFaceSuccess", + "value": "Bind face success" + }, + { + "name": "BindFaceFail", + "value": "Bind face fail" + }, + { + "name": "BindFaceFailWithNotification", + "value": "Bind face fail:please bind bio feature in system setting" + }, + { + "name": "FaceBound", + "value": "Face--Bound" + }, + { + "name": "UnBoundFaceSuccess", + "value": "Unbound face success" + }, + { + "name": "UnBoundFaceFail", + "value": "Unbound face fail" + }, + { + "name": "Trade", + "value": "Transfer" + }, + { + "name": "FinDigitalShield", + "value": "Financial Digital Shield" + }, + { + "name": "PlzSetVerificationWay", + "value": "Verification method setting" + }, + { + "name": "PureNumber", + "value": "Pure Number" + }, + { + "name": "NumberPlusAlphabet", + "value": "Number + Alphabet" + }, + { + "name": "ModifyWord", + "value": "Modify" + }, + { + "name": "GenerateKeySuccess", + "value": "Generate key success" + }, + { + "name": "ModifyPwSuccess", + "value": "Modify password success" + }, + { + "name": "ModifyPwFail", + "value": "Modify password fail" + }, + { + "name": "OpenShieldSuccess", + "value": "Enable Shield Success" + }, + { + "name": "OpenShieldFail", + "value": "Enable Shield Fail" + }, + { + "name": "ChooseVerificationMethod", + "value": "Choose verification method" + }, + { + "name": "Recipient", + "value": "Recipient" + }, + { + "name": "MRZhang", + "value": "Mr.Zhang" + }, + { + "name": "AccountNumber", + "value": "Target account number" + }, + { + "name": "TradingAmount", + "value": "Transaction amount" + }, + { + "name": "NextWord", + "value": "Next" + }, + { + "name": "TransactionWord", + "value": "Transaction" + }, + { + "name": "ShieldPwVerification", + "value": "Shield PIN verification" + }, + { + "name": "OpenShield", + "value": "Enable Shield" + }, + { + "name": "ModifyShield", + "value": "Modify Shield" + }, + { + "name": "FaceVerification", + "value": "Face Verification" + }, + { + "name": "FingerprintVerification", + "value": "Fingerprint Verification" + }, + { + "name": "PINVerification", + "value": "Pin Verification" + }, + { + "name": "PINVerificationSuccess", + "value": "PIN verification success" + }, + { + "name": "PINVerificationFail", + "value": "PIN verification fail" + }, + { + "name": "FingerprintVerificationSuccess", + "value": "Fingerprint verification success" + }, + { + "name": "FingerprintVerificationFail", + "value": "Fingerprint verification fail" + },{ + "name": "FingerprintVerificationFailWithNotification", + "value": "Fingerprint verification fail:please use the bound fingerprint,unbound after mutiple trys" + }, + { + "name": "FaceVerificationSuccess", + "value": "Face verification success" + }, + { + "name": "FaceVerificationFail", + "value": "Face verification fail" + }, + { + "name": "FaceVerificationFailWithNotification", + "value": "Face verification fail:please check the bound info,unbound after mutiple trys" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/color.json b/entry/src/main/resources/zh_CN/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/float.json b/entry/src/main/resources/zh_CN/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..a0a93dd91fd48f08f3a9532c76e9b26e68d4c034 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1fb6260672a6d6754660f19fcbc1c63a28b6a8d0 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,259 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "TestDigitalShield" + }, + { + "name": "reason", + "value": "申请必要权限" + }, + { + "name": "IDSetting", + "value": "身份认证设置" + }, + { + "name": "DigitalShield", + "value": "数字盾" + }, + { + "name": "ModifyPassword", + "value": "修改密码" + }, + { + "name": "OpenWord", + "value": "立即开通" + }, + { + "name": "CloseShield", + "value": "关闭数字盾" + }, + { + "name": "CloseShieldWithVerification", + "value": "需认证关闭数字盾" + }, + { + "name": "CloseWord", + "value": "关闭" + }, + { + "name": "FinishSignatureInitialization", + "value": "签名初始化完成" + }, + { + "name": "CloseShieldSuccess", + "value": "关闭数字盾成功" + }, + { + "name": "CloseShieldFail", + "value": "关闭数字盾失败" + }, + { + "name": "CloseShieldWithoutVerification", + "value": "无需认证关闭数字盾" + }, + { + "name": "BioFeatureVerification", + "value": "生物特征认证方式" + }, + { + "name": "Fingerprint", + "value": "指纹识别" + }, + { + "name": "Bind", + "value": "绑定" + }, + { + "name": "BindFingerprintSuccess", + "value": "指纹绑定成功" + }, + { + "name": "BindFingerprintFail", + "value": "指纹绑定失败" + }, + { + "name": "BindFingerprintFailWithNotification", + "value": "指纹绑定失败:请前往系统界面绑定生物信息" + }, + { + "name": "FingerprintBound", + "value": "指纹识别--已绑定" + }, + { + "name": "UnBound", + "value": "解绑" + }, + { + "name": "UnBoundFingerprintSuccess", + "value": "解绑指纹成功" + }, + { + "name": "UnBoundFingerprintFail", + "value": "解绑指纹失败" + }, + { + "name": "Face", + "value": "人脸识别" + }, + { + "name": "BindFaceSuccess", + "value": "人脸绑定成功" + }, + { + "name": "BindFaceFail", + "value": "人脸绑定失败" + }, + { + "name": "BindFaceFailWithNotification", + "value": "人脸绑定失败:请前往系统界面绑定生物信息" + }, + { + "name": "FaceBound", + "value": "人脸识别--已绑定" + }, + { + "name": "UnBoundFaceSuccess", + "value": "解绑人脸成功" + }, + { + "name": "UnBoundFaceFail", + "value": "解绑人脸失败" + }, + { + "name": "Trade", + "value": "去转账" + }, + { + "name": "FinDigitalShield", + "value": "金融数字盾" + }, + { + "name": "PlzSetVerificationWay", + "value": "请设定数字盾的验证方式" + }, + { + "name": "PureNumber", + "value": "数字密码" + }, + { + "name": "NumberPlusAlphabet", + "value": "数字+英文组合密码" + }, + { + "name": "ModifyWord", + "value": "立即修改" + }, + { + "name": "GenerateKeySuccess", + "value": "生成密钥成功" + }, + { + "name": "ModifyPwSuccess", + "value": "修改数字盾密码成功" + }, + { + "name": "ModifyPwFail", + "value": "修改数字盾密码失败" + }, + { + "name": "OpenShieldSuccess", + "value": "开通数字盾成功" + }, + { + "name": "OpenShieldFail", + "value": "开通数字盾失败" + }, + { + "name": "ChooseVerificationMethod", + "value": "选择认证方式" + }, + { + "name": "Recipient", + "value": "收款人" + }, + { + "name": "MRZhang", + "value": "张某某" + }, + { + "name": "AccountNumber", + "value": "收款账号" + }, + { + "name": "TradingAmount", + "value": "交易金额" + }, + { + "name": "NextWord", + "value": "下一步" + }, + { + "name": "TransactionWord", + "value": "银行卡转账" + }, + { + "name": "ShieldPwVerification", + "value": "数字盾密码验证" + }, + { + "name": "OpenShield", + "value": "开通数字盾" + }, + { + "name": "ModifyShield", + "value": "修改金融盾" + }, + { + "name": "FaceVerification", + "value": "人脸交易认证" + }, + { + "name": "FingerprintVerification", + "value": "指纹交易认证" + }, + { + "name": "PINVerification", + "value": "密码交易认证" + }, + { + "name": "PINVerificationSuccess", + "value": "密码交易认证成功" + }, + { + "name": "PINVerificationFail", + "value": "密码交易认证失败" + }, + { + "name": "FingerprintVerificationSuccess", + "value": "指纹交易认证成功" + }, + { + "name": "FingerprintVerificationFail", + "value": "指纹交易认证失败" + },{ + "name": "FingerprintVerificationFailWithNotification", + "value": "指纹交易认证失败:请用数字盾的指纹进行认证,多次失败请返回上一页解绑后重新绑定," + }, + { + "name": "FaceVerificationSuccess", + "value": "人脸交易认证成功" + }, + { + "name": "FaceVerificationFail", + "value": "人脸交易认证失败" + }, + { + "name": "FaceVerificationFailWithNotification", + "value": "人脸交易认证失败:请确认认证信息是否正确,多次失败请返回上一页解绑后重新绑定" + } + ] +} \ No newline at end of file diff --git a/screenshots/index.jpg b/screenshots/index.jpg deleted file mode 100644 index d430df5f20855c5b6849efb792cdb4ad92093833..0000000000000000000000000000000000000000 Binary files a/screenshots/index.jpg and /dev/null differ diff --git a/screenshots/index.png b/screenshots/index.png new file mode 100644 index 0000000000000000000000000000000000000000..af6be326a0025d3c0c0fba9d8221bfd8b558aafb Binary files /dev/null and b/screenshots/index.png differ