1# AppDomainNameVerify
2
3## Introduction
4
5AppDomainNameVerify is a part of the bundle management subsystem. It works with the BaseFramework part and ability framework to provide the App Linking$^1$ feature. The main functions of AppDomainNameVerify are as follows:
6
7- During application installation, AppDomainNameVerify communicates with the domain server associated with the application, verifies the mapping between the application and domain name, and saves the mapping.
8- When a link is clicked, AppDomainNameVerify filters the ability of the application associated with the domain name based on the saved mapping.
9
10> **NOTE**
11>
12> App Linking redirects users from different platform to your in-app content. Compared with Deep Link, App Linking is more secure and reliable and provides better user experience.
13
14### Architecture
15
16**Figure 1** Architecture of AppDomainNameVerify
17
18!["AppDomainNameVerify architecture"](figures/architecture_en.png)
19
20### Process
21
22#### Interaction with BundleManagerService
23
24* During application installation, BundleManagerService calls the domain name verification API of AppDomainNameVerify to obtain the asset configuration file of all HTTPS domain names declared in **module.json5**. It checks whether any field of the **apps** array in the asset configuration file matches the current application. If so, the verification is successful. Otherwise, the verification fails.
25* During application uninstall, BundleManagerService calls the deletion API of AppDomainNameVerify to delete the verification result of the application.
26* During application update, BundleManagerService calls the APIs of AppDomainNameVerify to delete the verification result of the application and then initiate a new round of verification.
27* When **startAbility()** is called to trigger an inter-application implicit redirection, BundleManagerService passes in the want (implicit redirection, with an HTTPS URI) and abilities and transfers them to AppDomainNameVerify. Based on the cached mappings between the applications matching the passed-in abilities and the URI domain name in the want, AppDomainNameVerify obtains the ability of the application that passes the verification and sends that ability to BundleManagerService for more accurate redirection.
28
29#### Periodic Update
30
31If the verification fails, AppDomainNameVerify automatically updates the verification result on a regular basis after the device is powered on.
32
33## Directory Structure
34
35```text
36/foundation/bundlemanager/app_domain_verify/
37├── etc                      # Process configuration files
38├── figures                  	# Architecture
39├── interfaces               # APIs provided for external systems
40│   └── inner_api            # Inner APIs
41├── profile                  # System service configuration files
42├── services                 # Feature implementation code
43├── test                     # Test code
44└──README.en.md              # Instructions for use
45```
46
47## Build
48
49In the root directory of the OpenHarmony source code, call the following command to compile **app_domain_verify** separately:
50
51```shell
52./build.sh --product-name rk3568 --ccache --build-target app_domain_verify
53```
54
55> **NOTE**
56> - --**product-name**: product name, for example, **Hi3516DV300** and **rk3568**.
57> - --**ccache**: cache used during the build.
58> - --**build-target**: part to build.
59
60## Inner API Development Guide
61
62### Available APIs
63
64#### app_domain_verify_mgr_client.h
65
66Import the following header file before API calling:
67
68```c++
69#include "app_domain_verify_mgr_client.h"
70```
71
72|API|Description|
73|---|---|
74|VerifyDomain(const std::string &appIdentifier, const std::string &bundleName, const std::string &fingerprint, const std::vector<SkillUri> &skillUris): void|Called by BundleManagerService to trigger application domain name verification during application installation and update.|
75|ClearDomainVerifyStatus(const std::string &appIdentifier, const std::string &bundleName): bool|Called by BundleManagerService to clear the application verification information during application uninstall. The return value indicates whether the clearance is successful.|
76|FilterAbilities(const OHOS::AAFwk::Want &want, const std::vector<OHOS::AppExecFwk::AbilityInfo> &originAbilityInfos, std::vector<OHOS::AppExecFwk::AbilityInfo> &filtedAbilityInfos): bool|Called by BundleManagerService to find, from **AbilityInfos**, the ability of the application that passes the verification based on the HTTPS domain name in the want, when **startAbility** is used for inter-application implicit redirection. The return value indicates whether the filtering is successful.|
77
78#### skill_uri.h
79
80**skill_uri** information structure
81
82|Name|Type|Description|
83|----|----|----|
84| scheme | std::string | Protocol name of the URI.       |
85| host | std::string | Host address of the URI.   |
86| port  | std::string | Port of the URI. |
87| path| std::string | Path of the URI. Set **path**, **pathStartWith**, or **pathRegex** as needed. |
88| pathStartWith| std::string |  Path of the URI. Set **path**, **pathStartWith**, or **pathRegex** as needed. |
89| pathRegex| std::string |  Path of the URI. Set **path**, **pathStartWith**, or **pathRegex** as needed. |
90| type| std::string | Data type that matches the want. The value complies with the Multipurpose Internet Mail Extensions (MIME) type specification. |
91
92### How to Develop
93
941. Add dependencies to bundle.json.
95
96   ```json
97   "deps": {
98     "components": [
99       "app_domain_verify"
100     ]
101   }
102   ```
103
1042. Add the dependency on the client module to the .gn file.
105
106   ```gn
107   external_deps = [
108     "app_domain_verify:app_domain_verify_mgr_client",
109     "app_domain_verify:app_domain_verify_common"
110   ]
111   ```
112
1133. Import the header file of the client to the header file.
114
115   ```c++
116   #include "app_domain_verify_mgr_client.h"
117   ```
118
1194. Call the APIs.
120
121   Call the APIs by referring to the description in [Available APIs](#available-apis) to verify the domain name.