From d6dbc18a8588079234003b3975e0bbe846bc61d1 Mon Sep 17 00:00:00 2001 From: qq_46377042 <1251776175@qq.com> Date: Thu, 11 Dec 2025 20:18:32 +0800 Subject: [PATCH 1/2] docs: translate react-native-secure-key-store.md to English --- en/react-native-secure-key-store.md | 83 ++++++++++++++------------ zh-cn/react-native-secure-key-store.md | 24 ++++---- 2 files changed, 59 insertions(+), 48 deletions(-) diff --git a/en/react-native-secure-key-store.md b/en/react-native-secure-key-store.md index 57e2d832f..aeebb89fb 100644 --- a/en/react-native-secure-key-store.md +++ b/en/react-native-secure-key-store.md @@ -16,15 +16,15 @@ ## Installation and Usage -Please check the release information of the third-party library for the matching version information: +Please go to the Releases page of the third-party library to check the matching version information: -| Library Version | Release Information | Supported RN Version | -| ---------- | ------------------------------------------------------------ | ---------- | -| 2.0.11 | [@react-native-ohos/react-native-secure-key-store Releases](https://github.com/react-native-oh-library/react-native-secure-key-store/releases) | 0.72, 0.77 | +| Library Version | Release Info | Supported RN Version | +| --------------- | ------------------------------------------------------------ | -------------------- | +| 2.0.11 | [@react-native-ohos/react-native-secure-key-store Releases](https://github.com/react-native-oh-library/react-native-secure-key-store/releases) | 0.72, 0.77 | -For older versions not published to npm, please refer to the [Installation Guide](/en/tgz-usage.md) to install the tgz package. +For older versions not published to npm, please refer to the [installation guide](/zh-cn/tgz-usage.md) to install the tgz package. -Go to the project directory and execute the following instruction: +Enter the project directory and run the following command: @@ -44,7 +44,7 @@ yarn add @react-native-ohos/react-native-secure-key-store The following code shows the basic usage scenarios of this library: -> [!WARNING] The library name imported remains unchanged. +> [!WARNING] The library name imported remains unchanged when using. ```ts import React, { useState } from "react"; @@ -187,18 +187,23 @@ const styles = StyleSheet.create({ }); export default AppDemo; - ``` -## Using Codegen -Version >= @react-native-ohos/react-native-secure-key-store@2.0.11, which has been adapted to codegen-lib to generate bridge code. -This library has been adapted to Codegen. Before using it, you need to actively execute the generation of third-party library bridge code. For details, please refer to the Codegen Usage Documentation. +## Use Codegen + +Version >= @react-native-ohos/react-native-secure-key-store@2.0.11 has been adapted to codegen-lib to generate bridge code. + +This library has been adapted to `Codegen`, so you need to actively execute the generation of third-party library bridge code before use. For details, please refer to [Codegen Usage Document](/zh-cn/codegen.md). ## Link + +Version >= @react-native-ohos/react-native-background-fetch@4.2.6 supports Autolink, so manual configuration is not required (content that still needs manual configuration is marked at the corresponding title). Currently, only the 72 framework is supported. Autolink framework guide document: https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md + This step is a guide for manually configuring native dependencies. -First, you need to open the HarmonyOS project harmony in the project using DevEco Studio. -### Add overrides field to oh-package.json in the project root directory +First, you need to use DevEco Studio to open the HarmonyOS project `harmony` in the project. + +### 1. Add overrides field to `oh-package.json` in the project root directory ```json { @@ -210,6 +215,8 @@ First, you need to open the HarmonyOS project harmony in the project using DevEc } ``` +### 2. Introduce Native Code + There are currently two methods: Import via har package (this method will be deprecated after the IDE improves related functions, and it is the preferred method currently); @@ -228,23 +235,22 @@ Open the entry/oh-package.json5 file and append the following dependencies: } ``` -Click the sync button at the top right corner. +Click the `sync` button in the upper right corner. -Or run this command in the terminal: +Or run in the terminal: ```bash cd entry ohpm install ``` -Method 2: Link the source code directly - -> [!TIP] For direct source code linking, refer to [Direct Source Code Linking Instructions](/zh-cn/link-source-code.md) +Method 2: Link source code directly +> [!TIP] If you need to use direct source code linking, please refer to [Direct Source Code Linking Description](/zh-cn/link-source-code.md) -### 4.Configure CMakeLists and import turbo_log +### 3. Configure CMakeLists and Introduce RTNSecureKeyStorePackage -open entry/src/main/cpp/CMakeLists.txt,add: +open entry/src/main/cpp/CMakeLists.txt, add: ```diff include(FetchContent) @@ -288,10 +294,9 @@ target_link_libraries(rnoh_app PUBLIC rnoh) target_link_libraries(rnoh_app PUBLIC rnoh_gesture_handler) + target_link_libraries(rnoh_app PUBLIC rnoh_secure_key_store) # RNOH_END: manual_package_linking_2 - ``` -打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: +Open `entry/src/main/cpp/PackageProvider.cpp`, add: ```diff #include "RNOH/PackageProvider.h" @@ -310,12 +315,12 @@ std::vector> PackageProvider::getPackages(Package::Cont } ``` -### 5.在 ArkTs 侧引入 RNSecureKeyStorePackage +### 4. Introduce RNSecureKeyStorePackage on ArkTs side -open `entry/src/main/ets/RNPackagesFactory.ts`,add: +Open `entry/src/main/ets/RNPackagesFactory.ts`, add: ```diff - ... +... + import { RNSecureKeyStorePackage } from "@react-native-ohos/react-native-secure-key-store/ts"; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { @@ -326,29 +331,29 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 6.Run +### 5. Run -Click the sync button in the upper right corner. - -Alternatively, execute the following command in the terminal: +Click the `sync` button in the upper right corner. +Or run in the terminal: ```bash cd entry ohpm install ``` -Then compile and run the project. +Then compile and run. ## Constraints ### Compatibility -To use this library, you need to use the correct React-Native and RNOH versions. In addition, you need to use the matching DevEco Studio and the phone ROM. +To use this library, you need to use the correct React-Native and RNOH versions. In addition, you need to use the matching DevEco Studio and phone ROM. + +This document is verified based on the following versions: -PThe content of this document has been verified based on the following versions: -1. RNOH:0.72.90; SDK:HarmonyOS NEXT Developer DB3; IDE: DevEco Studio: 5.0.5.220; ROM:NEXT.0.0.105; -2. RNOH:0.77.18; SDK:HarmonyOS 6.0.0 Release; IDE: DevEco Studio 6.0.0.858; ROM:6.0.0.112; +1. RNOH: 0.72.90; SDK: HarmonyOS NEXT Developer DB3; IDE: DevEco Studio: 5.0.5.220; ROM: NEXT.0.0.105; +2. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112; ## Technical Implementation @@ -357,18 +362,19 @@ PThe content of this document has been verified based on the following versions The HarmonyOS version uses the following technologies to implement secure storage: 1. **HUKS (HarmonyOS Universal KeyStore)** + - Uses AES-256-GCM encryption algorithm - Keys are stored in a system-level secure area - Provides hardware-level security protection - 2. **Preferences** + - Used to store encrypted data - Data is stored in JSON format (including cipherText, iv, authTag) ### Encryption Process ``` -Raw Data → AES-256-GCM Encryption → Base64 Encoding → Preferences Storage +Original Data → AES-256-GCM Encryption → Base64 Encoding → Preferences Storage ``` ## API @@ -380,6 +386,7 @@ Raw Data → AES-256-GCM Encryption → Base64 Encoding → Preferences Storage | RNSecureKeyStore.remove | Removes the key-value pair. | function | yes | iOS/Android | yes | ```typescript + ``` ## Platform Differences @@ -391,7 +398,7 @@ Raw Data → AES-256-GCM Encryption → Base64 Encoding → Preferences Storage | accessible Option | ❌ Ignored | ✅ Fully Supported | ❌ Ignored | | setResetOnAppUninstallTo | ❌ Ignored | ✅ Supported | ❌ Ignored | - ## License -This project is licensed under [The MIT License (MIT)](https://github.com/ovr/react-native-secure-key-store/blob/master/LICENSE). +This project is based on [The MIT License (MIT)](https://github.com/ovr/react-native-secure-key-store/blob/master/LICENSE), please freely enjoy and participate in open source. + diff --git a/zh-cn/react-native-secure-key-store.md b/zh-cn/react-native-secure-key-store.md index b69c3ca55..5dce5edfe 100644 --- a/zh-cn/react-native-secure-key-store.md +++ b/zh-cn/react-native-secure-key-store.md @@ -15,6 +15,7 @@ > [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-secure-key-store) ## 安装与使用 + 请到三方库的 Releases 发布地址查看配套的版本信息: | 三方库版本 | 发布信息 | 支持RN版本 | @@ -186,16 +187,18 @@ const styles = StyleSheet.create({ }); export default AppDemo; - ``` + ## 使用 Codegen -Version >= @react-native-ohos/react-native-secure-key-store@2.0.11, 已适配codegen-lib生成桥接代码。 +Version >= @react-native-ohos/react-native-secure-key-store@2.011,已适配codegen-lib生成桥接代码。 本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 ## Link +Version >= @react-native-ohos/react-native-background-fetch@4.2.6,已支持 Autolink,无需手动配置(仍需手动配置的内容已在对应标题处标记),目前只支持72框架。 Autolink框架指导文档:https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md + 此步骤为手动配置原生依赖项的指导。 首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony` @@ -245,8 +248,7 @@ ohpm install > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) - -### 4.配置 CMakeLists 和引入 RTNSecureKeyStorePackage +### 3.配置 CMakeLists 和引入 RTNSecureKeyStorePackage open entry/src/main/cpp/CMakeLists.txt,add: @@ -292,7 +294,6 @@ target_link_libraries(rnoh_app PUBLIC rnoh) target_link_libraries(rnoh_app PUBLIC rnoh_gesture_handler) + target_link_libraries(rnoh_app PUBLIC rnoh_secure_key_store) # RNOH_END: manual_package_linking_2 - ``` 打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: @@ -314,12 +315,12 @@ std::vector> PackageProvider::getPackages(Package::Cont } ``` -### 5.在 ArkTs 侧引入 RNSecureKeyStorePackage +### 4.在 ArkTs 侧引入 RNSecureKeyStorePackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff - ... +... + import { RNSecureKeyStorePackage } from "@react-native-ohos/react-native-secure-key-store/ts"; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { @@ -330,7 +331,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 6.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -350,6 +351,7 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 本文档内容基于以下版本验证通过: + 1. RNOH:0.72.90; SDK:HarmonyOS NEXT Developer DB3; IDE: DevEco Studio: 5.0.5.220; ROM:NEXT.0.0.105; 2. RNOH:0.77.18; SDK:HarmonyOS 6.0.0 Release; IDE: DevEco Studio 6.0.0.858; ROM:6.0.0.112; @@ -360,11 +362,12 @@ ohpm install HarmonyOS 版本使用以下技术实现安全存储: 1. **HUKS (HarmonyOS Universal KeyStore)** + - 使用 AES-256-GCM 加密算法 - 密钥存储在系统级安全区域 - 提供硬件级别的安全保护 - 2. **Preferences** + - 用于存储加密后的数据 - 数据以 JSON 格式存储(包含 cipherText, iv, authTag) @@ -375,6 +378,7 @@ HarmonyOS 版本使用以下技术实现安全存储: ``` ## API + | Name | Description | Type | Required | Platform | HarmonyOS Support | | ----------------------- | -------------------------------------------- | -------- | -------- | ----------- | ----------------- | | RNSecureKeyStore.set | Securely stores the key-value pair. | function | yes | iOS/Android | yes | @@ -382,6 +386,7 @@ HarmonyOS 版本使用以下技术实现安全存储: | RNSecureKeyStore.remove | Removes the key-value pair. | function | yes | iOS/Android | yes | ```typescript + ``` ## 平台差异 @@ -393,7 +398,6 @@ HarmonyOS 版本使用以下技术实现安全存储: | accessible 选项 | ❌ 忽略 | ✅ 完整支持 | ❌ 忽略 | | setResetOnAppUninstallTo | ❌ 忽略 | ✅ 支持 | ❌ 忽略 | - ## 开源协议 本项目基于 [The MIT License (MIT)](https://github.com/ovr/react-native-secure-key-store/blob/master/LICENSE) ,请自由地享受和参与开源。 -- Gitee From c0fa084e0dea080879f6e237f733957e82f407c8 Mon Sep 17 00:00:00 2001 From: qq_46377042 <1251776175@qq.com> Date: Fri, 12 Dec 2025 13:48:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20translate=20react-native-secure-key?= =?UTF-8?q?-store.md=20=E5=AE=8C=E5=96=84=E6=8C=87=E5=AF=BC=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- en/react-native-secure-key-store.md | 5 +++-- zh-cn/react-native-secure-key-store.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/en/react-native-secure-key-store.md b/en/react-native-secure-key-store.md index aeebb89fb..0cc212ad1 100644 --- a/en/react-native-secure-key-store.md +++ b/en/react-native-secure-key-store.md @@ -20,7 +20,8 @@ Please go to the Releases page of the third-party library to check the matching | Library Version | Release Info | Supported RN Version | | --------------- | ------------------------------------------------------------ | -------------------- | -| 2.0.11 | [@react-native-ohos/react-native-secure-key-store Releases](https://github.com/react-native-oh-library/react-native-secure-key-store/releases) | 0.72, 0.77 | +| 2.0.11 | [@react-native-ohos/react-native-secure-key-store Releases](https://github.com/react-native-oh-library/react-native-secure-key-store/releases/2.0.11-rc.1) | 0.72 | +| 2.1.0 | [@react-native-ohos/react-native-secure-key-store Releases](https://github.com/react-native-oh-library/react-native-secure-key-store/releases/2.1.0-rc.1) | 0.77 | For older versions not published to npm, please refer to the [installation guide](/zh-cn/tgz-usage.md) to install the tgz package. @@ -197,7 +198,7 @@ This library has been adapted to `Codegen`, so you need to actively execute the ## Link -Version >= @react-native-ohos/react-native-background-fetch@4.2.6 supports Autolink, so manual configuration is not required (content that still needs manual configuration is marked at the corresponding title). Currently, only the 72 framework is supported. Autolink framework guide document: https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md +Version >= @react-native-ohos/react-native-secure-key-store supports Autolink, so manual configuration is not required (content that still needs manual configuration is marked at the corresponding title). Currently, Autolink framework guide document: https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md This step is a guide for manually configuring native dependencies. diff --git a/zh-cn/react-native-secure-key-store.md b/zh-cn/react-native-secure-key-store.md index 5dce5edfe..75b1c6a05 100644 --- a/zh-cn/react-native-secure-key-store.md +++ b/zh-cn/react-native-secure-key-store.md @@ -20,7 +20,8 @@ | 三方库版本 | 发布信息 | 支持RN版本 | | ---------- | ------------------------------------------------------------ | ---------- | -| 2.0.11 | [@react-native-ohos/react-native-secure-key-store Releases](https://github.com/react-native-oh-library/react-native-secure-key-store/releases) | 0.72,0.77 | +| 2.0.11 | [@react-native-ohos/react-native-secure-key-store Releases](https://github.com/react-native-oh-library/react-native-secure-key-store/releases/2.0.11-rc.1) | 0.72 | +| 2.1.0 | [@react-native-ohos/react-native-secure-key-store Releases](https://github.com/react-native-oh-library/react-native-secure-key-store/releases/2.1.0-rc.1) | 0.77 | 对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 @@ -197,7 +198,7 @@ Version >= @react-native-ohos/react-native-secure-key-store@2.011,已适配cod ## Link -Version >= @react-native-ohos/react-native-background-fetch@4.2.6,已支持 Autolink,无需手动配置(仍需手动配置的内容已在对应标题处标记),目前只支持72框架。 Autolink框架指导文档:https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md +Version >= @react-native-ohos/react-native-secure-key-store,已支持 Autolink,无需手动配置(仍需手动配置的内容已在对应标题处标记)。 Autolink框架指导文档:https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md 此步骤为手动配置原生依赖项的指导。 -- Gitee