npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cordova-ohos/cordova-plugin-whitelist

v1.3.6

Published

Cordova White List Plugin

Readme

cordova-plugin-whitelist

zh-CN en

本项目基于 [email protected] 开发,本文档重点阐述其在 OpenHarmony(OHOS)系统中的具体应用。

简介

cordova-plugin-whitelist 是 Cordova 官方核心插件,用于控制应用对外部资源的访问权限,包括网络请求、外部应用跳转和 WebView 导航。它通过白名单机制有效防范跨站请求伪造(CSRF)、恶意 URL 跳转等安全风险,是保障 Cordova 应用安全性的关键组件。

重要提示: 该插件在 Cordova 10.0 开始,已在 Android 和 iOS 中废弃,插件已失效,因此该插件也在 OHOS 系统中功能失效,但保留插件接口,主要兼容老版本的 Android 或 iOS 项目移植使用,如果您是新项目,无需安装该插件。

支持平台

  • Android:API 19 及以上(Android 4.4+)

  • iOS:10.0 及以上

  • OHOS:5.0+

下载安装

从 npm 安装(推荐)

# 安装 hcordova
npm install -g hcordova

# 全平台安装插件
hcordova plugin add cordova-plugin-whitelist

# 指定 OHOS 平台
hcordova plugin add cordova-plugin-whitelist --platform ohos

# 安装指定版本(OHOS 平台)
hcordova plugin add [email protected] --platform ohos

从 GitCode 仓库安装

# 仅安装到 OHOS 平台(开发版)
hcordova plugin add https://gitcode.com/CPF-Cordova/cordova-plugin-whitelist.git --platform ohos

# 指定标签/分支安装
hcordova plugin add https://gitcode.com/CPF-Cordova/cordova-plugin-whitelist.git@develop --platform ohos

离线安装(本地包)

适用于无网络环境,先下载插件包到本地,再执行离线安装:

# 下载插件包到本地(示例路径:~/Downloads/cordova-plugin-whitelist)
# 执行离线安装
hcordova plugin add ~/Downloads/cordova-plugin-whitelist --platform ohos

安装后验证

安装完成后,可通过以下命令验证插件是否成功添加到项目中:

# 查看已安装的插件列表,若包含本插件 ID 则表示插件已成功安装
hcordova plugin list

卸载

# Cordova CLI 全平台卸载
hcordova plugin remove cordova-plugin-whitelist 

# 指定平台卸载
hcordova plugin remove cordova-plugin-whitelist --platform ohos

约束与限制

兼容性

支持:

| 项目 | 版本/信息 | |-----|--------| | SDK | API12+ | | IDE | DevEco Studio: 5.0+ | | ROM | 5.1+ | | Emulator | OpenHarmony 6.0+ |

在以下版本中已测试通过:

| 项目 | 版本/信息 | |-----|--------| | @cordova-ohos/ohos | 14.0.1-ohos-14.0.1 | | SDK | 5.0.0(12) | | IDE | DevEco Studio: 6.0.13.200 | | ROM | 5.1.0.120 SP3 | | Emulator | OpenHarmony 6.0.1(21) |

使用示例

1. 网络请求白名单配置示例

控制应用所有网络资源加载,支持通配符、协议限制和子域名匹配,配置在项目根目录的 config.xml 中。

<!-- 推荐配置 -->
<access origin="*" />

<!-- 允许访问指定域名 -->
<access origin="https://api.example.com" />

<!-- 允许访问指定域名及其所有子域名 -->
<access origin="https://*.example.com" />

<!-- 允许访问所有 HTTPS/WSS 安全域名(推荐) -->
<access origin="https://*" />

<!-- 允许访问指定端口(需完整指定协议+域名+端口) -->
<access origin="https://api.example.com:8443" />

2. 导航白名单配置示例

控制 WebView 可直接导航的 URL,未配置的 URL 会触发系统浏览器打开(或被拦截),配置在项目根目录的 config.xml 中。

<!-- 推荐配置 -->
<allow-navigation href="*" />

<!-- 允许导航到应用主域名下所有路径 -->
<allow-navigation href="https://app.example.com/*" />

<!-- 允许导航到子域名 -->
<allow-navigation href="https://*.app.example.com" />

使用说明

核心功能说明

插件通过三类白名单规则实现精细化权限控制,所有配置均在项目根目录的 config.xml 中完成

| 白名单类型 | 控制范围 | 配置标签 | 适用平台 | |---|---|---|---| | 网络请求白名单 | 控制应用发起的 XMLHttpRequest、WebSocket、图片/脚本/字体等资源加载请求 | | 所有支持平台 | | 导航白名单 | 控制应用内 WebView 可直接导航到的外部 URL(不跳转外部浏览器) | | 所有支持平台 |

详细配置说明

1. 网络请求白名单( 标签)

控制应用所有网络资源加载,支持通配符、协议限制和子域名匹配,具体配置示例见「使用示例」章节。

2. 导航白名单( 标签)

控制 WebView 可直接导航的 URL,未配置的 URL 会触发系统浏览器打开(或被拦截),具体配置示例见「使用示例」章节。

目录结构

cordova-plugin-whitelist             # [根目录] 网络白名单安全策略插件项目根目录
├── src                              # [源码目录] 存放原生平台代码
│   └── main                         # [主目录] 主代码目录
│       └── cpp                      # [C++ 目录] C++ 原生代码目录
│           └── Whitelist            # [C++ 模块] 白名单功能 C++ 模块文件夹
│               ├── Whitelist.h      # [C++ 声明] 白名单规则匹配逻辑的头文件
│               ├── WhitelistPlugin.cpp # [C++ 实现] 插件主逻辑,负责读取配置并拦截网络请求
│               └── WhitelistPlugin.h   # [C++ 声明] 插件接口的头文件
├── .gitignore                       # [配置] Git 版本控制忽略文件配置
├── LICENSE                          # [文本] 开源许可证文件
├── OAT.xml                          # [配置] 门禁配置文件
├── package.json                     # [配置] npm 包描述文件,包含插件版本、依赖等信息
├── plugin.xml                       # [配置] Cordova 插件核心配置文件,定义插件 ID、文件映射等
└── README.md                        # [文档] 项目说明文档,介绍如何安装和使用白名单插件

贡献代码

使用过程中发现任何问题都可以提 Issue ,当然也非常欢迎发 PR 共建。

许可证

本插件基于 Apache License 2.0 开源,详见 LICENSE 文件。

官方资源