diff --git a/api/@ohos.net.vpn.d.ts b/api/@ohos.net.vpn.d.ts index 13af99c3c853897e23b62c94c0fe4fcfa44e6578..e33d963554f0197a6d622afd9dcf704658d41b0c 100644 --- a/api/@ohos.net.vpn.d.ts +++ b/api/@ohos.net.vpn.d.ts @@ -82,6 +82,23 @@ declare namespace vpn { */ function on(type: 'connect', callback: Callback): void; + /** + * Subscribes to vpn connect state changes. + * @permission ohos.permission.MANAGE_VPN + * @param { 'connectMulti' } type - Indicates multi vpn connect state changes. + * @param { Callback } callback - The callback of the multi vpn connect state. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + function on(type: 'connectMulti', callback: Callback): void; + /** * Unsubscribes from vpn connect state changes. * @permission ohos.permission.MANAGE_VPN @@ -99,6 +116,23 @@ declare namespace vpn { */ function off(type: 'connect', callback?: Callback): void; + /** + * Unsubscribes from vpn connect state changes. + * @permission ohos.permission.MANAGE_VPN + * @param { 'connectMulti' } type - Indicates multi vpn connect state changes. + * @param { Callback } callback - The callback of the multi vpn connect state. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + function off(type: 'connectMulti', callback?: Callback): void; + /** * Add a system VPN network configuration. * @permission ohos.permission.MANAGE_VPN @@ -178,6 +212,20 @@ declare namespace vpn { */ function getConnectedSysVpnConfig(): Promise; + /** + * Get the connected VPN App Info. + * @permission ohos.permission.MANAGE_VPN + * @returns { Promise> } The promise returned by the connected VPN App Info. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + function getConnectedVpnAppInfo(): Promise>; + /** * Defines a VPN connection. * @interface VpnConnection @@ -301,6 +349,14 @@ declare namespace vpn { * @since 10 */ export interface VpnConfig { + /** + * The uuid for the VPN network. + * @type {?string} + * @syscap SystemCapability.Communication.NetManager.Vpn + * @since 20 + */ + vpnId?: string; + /** * The array of addresses for VPN interface. * @type {Array} @@ -410,15 +466,6 @@ declare namespace vpn { * @since 12 */ export interface SysVpnConfig extends VpnConfig { - /** - * The uuid for the VPN network. - * @type {?string} - * @syscap SystemCapability.Communication.NetManager.Vpn - * @systemapi Hide this for inner system use. - * @since 12 - */ - vpnId?: string; - /** * The name for the VPN network. * @type {?string} @@ -482,6 +529,33 @@ declare namespace vpn { * @since 12 */ forwardingRoutes?: string; + + /** + * The array of addresses for remote server. + * @type {?Array} + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + remoteAddresses?: Array; + + /** + * The p12 cert password for the ipsec VPN network. + * @type {?string} + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + pkcs12Password?: string; + + /** + * The p12 cert data for the ipsec VPN network. + * @type {?Uint8Array} + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + pkcs12FileData?: Uint8Array; } /** @@ -961,7 +1035,15 @@ declare namespace vpn { * @systemapi Hide this for inner system use. * @since 12 */ - OPENVPN = 9 + OPENVPN = 9, + + /** + * The type for the l2tp network. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @systemapi Hide this for inner system use. + * @since 20 + */ + L2TP = 10 } } export default vpn; diff --git a/api/@ohos.net.vpnExtension.d.ts b/api/@ohos.net.vpnExtension.d.ts index 6b13b033f746e5b95df6bcc04f556f0fada9f683..4684d51314033ed5d05d675aba004668dbfc0c98 100644 --- a/api/@ohos.net.vpnExtension.d.ts +++ b/api/@ohos.net.vpnExtension.d.ts @@ -175,6 +175,17 @@ declare namespace vpnExtension { * @since 11 */ create(config: VpnConfig): Promise; + + /** + * generate vpn id. + * + * @returns { Promise } The promise returns vpn id. + * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @since 20 + */ + generateVpnId(): Promise; /** * Protect a socket from VPN connections. After protecting, data sent through this socket will go directly to the @@ -203,6 +214,19 @@ declare namespace vpnExtension { * @since 11 */ destroy(): Promise; + + /** + * Destroy the VPN network. + * + * @param { string } vpnId - vpn id. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200002 - Operation failed. Cannot connect to service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Vpn + * @since 20 + */ + destroy(vpnId: string): Promise; } /**