From 2b513104248db087a8205275d24e555407cd84a2 Mon Sep 17 00:00:00 2001 From: fuchao Date: Fri, 30 Sep 2022 10:31:57 +0800 Subject: [PATCH 1/2] Update dts of netmanager Signed-off-by: fuchao --- api/@ohos.net.connection.d.ts | 196 +++++++++++++++++++++++++++++- api/@ohos.net.ethernet.d.ts | 88 ++++++++++++++ api/@ohos.net.http.d.ts | 98 +++++++++++++++ api/@ohos.net.sharing.d.ts | 221 ++++++++++++++++++++++++++++++++++ api/@ohos.net.socket.d.ts | 188 ++++++++++++++++++++++++++++- 5 files changed, 788 insertions(+), 3 deletions(-) create mode 100644 api/@ohos.net.ethernet.d.ts create mode 100644 api/@ohos.net.sharing.d.ts diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index 84576eeee7..55d369dbf9 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -55,7 +55,6 @@ declare namespace connection { * @return Returns the {@link NetHandle} object; * returns {@code null} if the default network is not activated. * @permission ohos.permission.GET_NETWORK_INFO - * @since 9 */ function getDefaultNetSync(): NetHandle; @@ -219,6 +218,66 @@ declare namespace connection { */ NET_CAPABILITY_MMS = 0, + /** + * Indicates that the network can access the carrier's SUPL server. + * @since 9 + */ + NET_CAPABILITY_SUPL = 1, + + /** + * Indicates that the network can access the carrier's DUN or Tethering gateway. + * @since 9 + */ + NET_CAPABILITY_DUN = 2, + + /** + * Indicates that the network can access the FOTA server for remote device upgrade. + * @since 9 + */ + NET_CAPABILITY_FOTA = 3, + + /** + * Indicates that the network can access the IMS server. + * @since 9 + */ + NET_CAPABILITY_IMS = 4, + + /** + * Indicates that the network can access the carrier's CBS server. + * @since 9 + */ + NET_CAPABILITY_CBS = 5, + + /** + * Indicates that the network can be used for Wi-Fi Direct. + * @since 9 + */ + NET_CAPABILITY_WIFI_P2P = 6, + + /** + * Indicates that the network can access the carrier's Initial Attach server. + * @since 9 + */ + NET_CAPABILITY_IA = 7, + + /** + * Indicates that the network can access the carrier's RCS server. + * @since 9 + */ + NET_CAPABILITY_RCS = 8, + + /** + * Indicates that the network can access the carrier's XCAP server. + * @since 9 + */ + NET_CAPABILITY_XCAP = 9, + + /** + * Indicates that the network can access the carrier's IMS emergency call server. + * @since 9 + */ + NET_CAPABILITY_EIMS = 10, + /** * Indicates that the network traffic is not metered. */ @@ -229,6 +288,18 @@ declare namespace connection { */ NET_CAPABILITY_INTERNET = 12, + /** + * Indicates that the network is not restricted. + * @since 9 + */ + NET_CAPABILITY_NOT_RESTRICTED = 13, + + /** + * Indicates that the network is trusted. + * @since 9 + */ + NET_CAPABILITY_TRUSTED = 14, + /** * Indicates that the network does not use a VPN. */ @@ -238,6 +309,60 @@ declare namespace connection { * Indicates that the network is available. */ NET_CAPABILITY_VALIDATED = 16, + + /** + * Indicates that this network was found to have a captive portal in place last time it was + * probed. + * @since 9 + */ + NET_CAPABILITY_CAPTIVE_PORTAL = 17, + + /** + * Indicates that the network is unavailable during roaming. + * @since 9 + */ + NET_CAPABILITY_NOT_ROAMING = 18, + + /** + * Indicates that the network is available only for foreground applications. + * @since 9 + */ + NET_CAPABILITY_FOREGROUND = 19, + + /** + * Indicates that the network is not congested. + * @since 9 + */ + NET_CAPABILITY_NOT_CONGESTED = 20, + + /** + * Indicates that the network is not suspended. + * @since 9 + */ + NET_CAPABILITY_NOT_SUSPENDED = 21, + + /** + * Indicates that traffic that goes through this network is paid by oem. For example, + * this network can be used by system apps to upload telemetry data. + * + * @systemapi Hide this for inner system use. + * @since 9 + */ + NET_CAPABILITY_OEM_PAID = 22, + + /** + * Indicates that the network can access the Mission Critical server of the carrier. + * @since 9 + */ + NET_CAPABILITY_MCX = 23, + + /** + * Indicates that the network was tested to only provide partial connectivity. + * + * @systemapi Hide this for inner system use. + * @since 9 + */ + NET_CAPABILITY_PARTIAL_CONNECTIVITY = 24, } export enum NetBearType { @@ -251,21 +376,66 @@ declare namespace connection { */ BEARER_WIFI = 1, + /** + * Indicates that the network is based on a Bluetooth network. + * @since 9 + */ + BEARER_BLUETOOTH = 2, + /** * Indicates that the network is an Ethernet network. */ BEARER_ETHERNET = 3, + + /** + * Indicates that the network is a VPN. + * @since 9 + */ + BEARER_VPN = 4, + + /** + * Indicates that the network is a Wi-Fi Aware network. + * @since 9 + */ + BEARER_WIFI_AWARE = 5, + + /** + * Indicates that the network is a LoWPAN network. + * @since 9 + */ + BEARER_LOWPAN = 6 } export interface ConnectionProperties { interfaceName: string; + /** + * @since 9 + */ + isUsePrivateDns: boolean; + /** + * @since 9 + */ + privateDnsServerName: string; domains: string; + /** + * @since 9 + */ + httpProxy: HttpProxy; linkAddresses: Array; dnses: Array; routes: Array; mtu: number; } + /** + * @since 9 + */ + export interface HttpProxy { + host: string; + port: number; + parsedExclusionList: Array; + } + export interface RouteInfo { interface: string; destination: LinkAddress; @@ -284,6 +454,28 @@ declare namespace connection { family?: number; // IPv4 = 1; IPv6 = 2, default is IPv4 port?: number; // [0, 65535] } + + /** + * @since 9 + */ + export interface NetProxy { + type: ProxyType; + address: NetAddress; + } + + /** + * @since 9 + */ + export enum ProxyType { + /** + * Represents proxy for high level protocols such as HTTP or FTP. + */ + HTTP, + /** + * Represents a SOCKS (V4 or V5) proxy. + */ + SOCKS + } } -export default connection; +export default connection; \ No newline at end of file diff --git a/api/@ohos.net.ethernet.d.ts b/api/@ohos.net.ethernet.d.ts new file mode 100644 index 0000000000..24621e4b1f --- /dev/null +++ b/api/@ohos.net.ethernet.d.ts @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2022 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 {AsyncCallback, Callback} from "./basic"; + +/** + * Provides interfaces to manage ethernet. + * + * @since 9 + * @syscap SystemCapability.Communication.NetManager.Ethernet + */ +declare namespace ethernet { + /** + * Get the specified network interface information. + * + * @param iface Indicates the network interface name. + * @permission ohos.permission.GET_NETWORK_INFO + * @systemapi Hide this for inner system use. + */ + function getIfaceConfig(iface: string, callback: AsyncCallback): void; + function getIfaceConfig(iface: string): Promise; + + /** + * Set the specified network interface parameters. + * + * @param iface Indicates the network interface name of the network parameter. + * @param ic Indicates the ic. See {@link InterfaceConfiguration}. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @systemapi Hide this for inner system use. + */ + function setIfaceConfig(iface: string, ic: InterfaceConfiguration, callback: AsyncCallback): void; + function setIfaceConfig(iface: string, ic: InterfaceConfiguration): Promise; + + /** + * Check whether the specified network is active. + * + * @param iface Indicates the network interface name. + * @permission ohos.permission.GET_NETWORK_INFO + * @systemapi Hide this for inner system use. + */ + function isIfaceActive(iface: string, callback: AsyncCallback): void; + function isIfaceActive(iface: string): Promise; + + /** + * Gets the names of all active network interfaces. + * + * @permission ohos.permission.GET_NETWORK_INFO + * @systemapi Hide this for inner system use. + */ + function getAllActiveIfaces(callback: AsyncCallback>): void; + function getAllActiveIfaces(): Promise>; + + /** + * @systemapi Hide this for inner system use. + */ + export interface InterfaceConfiguration { + /*See {@link IPSetMode}*/ + mode: IPSetMode; + ipAddr: string; + route: string; + gateway: string; + netMask: string; + dnsServers: string; + domain: string; + } + + /** + * @systemapi Hide this for inner system use. + */ + export enum IPSetMode { + STATIC = 0, + DHCP = 1 + } +} + +export default ethernet; \ No newline at end of file diff --git a/api/@ohos.net.http.d.ts b/api/@ohos.net.http.d.ts index b6ecab57c1..8875689e43 100644 --- a/api/@ohos.net.http.d.ts +++ b/api/@ohos.net.http.d.ts @@ -14,6 +14,7 @@ */ import {AsyncCallback, Callback} from "./basic"; +import socket, {X509CertRawData} from './@ohos.net.socket' /** * Provides http related APIs. @@ -22,6 +23,9 @@ import {AsyncCallback, Callback} from "./basic"; * @syscap SystemCapability.Communication.NetStack */ declare namespace http { + type TLSSecureOptions = socket.TLSSecureOptions; + type X509CertRawData = socket.X509CertRawData; + /** * Creates an HTTP request task. */ @@ -37,6 +41,20 @@ declare namespace http { * extraData can be a string or an Object (API 6) or an ArrayBuffer(API 8). */ extraData?: string | Object | ArrayBuffer; + /** + * Data type to be returned. If this parameter is set, the system preferentially returns the specified type. + * + * @since 9 + */ + expectDataType?: HttpDataType; + /** + * @since 9 + */ + usingCache?: boolean; // default is true + /** + * @since 9 + */ + priority?: number; // [1, 1000], default is 1. /** * HTTP request header. */ @@ -49,6 +67,22 @@ declare namespace http { * Connection timeout interval. The default value is 60,000, in ms. */ connectTimeout?: number; // default is 60s. + /** + * @since 9 + */ + usingProtocol?: HttpProtocol; // default is automatically specified by the system. + /** + * For https. + * + * @since 9 + */ + secureOptions?: TLSSecureOptions; + /** + * For https. + * + * @since 9 + */ + checkServerIdentity?: (hostname: string, certs: Array) => Error | undefined; } export interface HttpRequest { @@ -154,11 +188,50 @@ declare namespace http { VERSION } + /** + * Supported protocols. + * + * @since 9 + */ + export enum HttpProtocol { + HTTP1_1, + HTTP2, + } + + /** + * Indicates the type of the returned data. + * + * @since 9 + */ + export enum HttpDataType { + /** + * The returned type is string. + */ + STRING, + /** + * The returned type is Object. + */ + OBJECT = 1, + /** + * The returned type is ArrayBuffer. + */ + ARRAY_BUFFER = 2, + } + export interface HttpResponse { /** * result can be a string (API 6) or an ArrayBuffer(API 8). Object is deprecated from API 8. + * If {@link HttpRequestOptions#expectDataType} is set, the system preferentially returns this parameter. */ result: string | Object | ArrayBuffer; + /** + * If the resultType is string, you can get result directly. + * If the resultType is Object, you can get result such as this: result['key']. + * If the resultType is ArrayBuffer, you can use ArrayBuffer to create the binary objects. + * + * @since 9 + */ + resultType: HttpDataType; /** * Server status code. */ @@ -172,6 +245,31 @@ declare namespace http { */ cookies: string; } + + /** + * Creates a default {@code HttpResponseCache} object to store the responses of HTTP access requests. + * + * @param cacheSize the size of cache, default is 10*1024*1024(10MB). + * @since 9 + */ + function createHttpResponseCache(cacheSize?: number): HttpResponseCache; + + /** + * @since 9 + */ + export interface HttpResponseCache { + /** + * Writes data in the cache to the file system so that all the cached data can be accessed in the next HTTP request. + */ + flush(callback: AsyncCallback): void; + flush(): Promise; + + /** + * Disables a cache and deletes the data in it. + */ + delete(callback: AsyncCallback): void; + delete(): Promise; + } } export default http; \ No newline at end of file diff --git a/api/@ohos.net.sharing.d.ts b/api/@ohos.net.sharing.d.ts new file mode 100644 index 0000000000..629b262bf7 --- /dev/null +++ b/api/@ohos.net.sharing.d.ts @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2022 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 {AsyncCallback, Callback} from "./basic"; +import {NetHandle} from "./@ohos.net.connection"; + +/** + * Provides network sharing related interfaces. + * + * @since 9 + * @syscap SystemCapability.Communication.NetManager.NetSharing + */ +declare namespace sharing { + /** + * Checks whether this device allows for network sharing. + * + * @param callback Returns {@code true} indicating network sharing is supported; returns {@code false} otherwise. + * @systemapi Hide this for inner system use. Only used for system app. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function isSharingSupported(callback: AsyncCallback): void; + function isSharingSupported(): Promise; + + /** + * Return the global network sharing state. + * + * @param callback Returns {@code true} indicating network sharing is running; returns {@code false} otherwise. + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function isSharing(callback: AsyncCallback): void; + function isSharing(): Promise; + + /** + * Start network sharing for given type. + * + * @param type Enumeration of shareable interface types. + * @param callback Returns the result. + * @systemapi Hide this for inner system use. Only used for system app. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function startSharing(type: SharingIfaceType, callback: AsyncCallback): void; + function startSharing(type: SharingIfaceType): Promise; + + /** + * Stop network sharing for given type. + * + * @param type Enumeration of shareable interface types. + * @param callback Returns the result. + * @systemapi Hide this for inner system use. Only used for system app. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function stopSharing(type: SharingIfaceType, callback: AsyncCallback): void; + function stopSharing(type: SharingIfaceType): Promise; + + /** + * Obtains the number of downlink data bytes of the sharing network interfaces. + * + * @param callback Returns the number of downlink data bytes of the sharing network interfaces. + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function getStatsRxBytes(callback: AsyncCallback): void; + function getStatsRxBytes(): Promise; + + /** + * Obtains the number of uplink data bytes of the sharing network interfaces. + * + * @param callback Returns the number of uplink data bytes of the sharing network interfaces. + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function getStatsTxBytes(callback: AsyncCallback): void; + function getStatsTxBytes(): Promise; + + /** + * Obtains the number of total data bytes of the sharing network interfaces. + * + * @param callback Returns the number of total data bytes of the sharing network interfaces. + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function getStatsTotalBytes(callback: AsyncCallback): void; + function getStatsTotalBytes(): Promise; + + /** + * Obtains the names of interfaces in each sharing state. + * + * @param state Is the network sharing state, include serving, can server and servering error states. + * @param callback Returns an array of interface names that meet this status. + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function getSharingIfaces(state: SharingIfaceState, callback: AsyncCallback>): void; + function getSharingIfaces(state: SharingIfaceState): Promise>; + + /** + * Obtains the network sharing state for given type. + * + * @param type Is the enumeration of shareable interface types. + * @param callback Returns {@code SharingIfaceState}. + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function getSharingState(type: SharingIfaceType, callback: AsyncCallback): void; + function getSharingState(type: SharingIfaceType): Promise; + + /** + * Get a list regular expression that defines any interface that can support network sharing. + * + * @param type Is the enumeration of shareable interface types. + * @param callback Returns an array of regular expression strings that define which interfaces + * are considered to support network sharing. + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function getSharableRegexes(type: SharingIfaceType, callback: AsyncCallback>): void; + function getSharableRegexes(type: SharingIfaceType): Promise>; + + /** + * Register a callback for the global network sharing state change. + * + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function on(type: 'sharingStateChange', callback: Callback): void; + + /** + * Unregister a callback for the global network sharing state change. + * + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function off(type: 'sharingStateChange', callback?: Callback): void; + + /** + * Register a callback for the interface network sharing state change. + * + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function on(type: 'interfaceSharingStateChange', callback: Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void; + + /** + * Unregister a callback for the interface network sharing state change. + * + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function off(type: 'interfaceSharingStateChange', callback?: Callback<{ type: SharingIfaceType, iface: string, state: SharingIfaceState }>): void; + + /** + * Register a callback for the sharing upstream network change. + * + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function on(type: 'sharingUpstreamChange', callback: Callback): void; + + /** + * Unregister a callback for the sharing upstream network change. + * + * @systemapi Hide this for inner system use. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + */ + function off(type: 'sharingUpstreamChange', callback?: Callback): void; + + /** + * @systemapi Hide this for inner system use. + */ + export enum SharingIfaceState { + /** + * Indicates the names of the NICs that are serving as network sharing. + */ + SHARING_NIC_SERVING = 1, + + /** + * Indicates the names of the NICs that can serve as network sharing. + */ + SHARING_NIC_CAN_SERVER = 2, + + /** + * Indicates the names of the NICs that serving error. + */ + SHARING_NIC_ERROR = 3 + } + + /** + * @systemapi Hide this for inner system use. + */ + export enum SharingIfaceType { + /** + * Network sharing type for Wi-Fi. + */ + SHARING_WIFI = 0, + + /** + * Network sharing type for USB. + */ + SHARING_USB = 1, + + /** + * Network sharing type for BLUETOOTH. + */ + SHARING_BLUETOOTH = 2 + } +} + +export default sharing; \ No newline at end of file diff --git a/api/@ohos.net.socket.d.ts b/api/@ohos.net.socket.d.ts index fb88669e14..e06b2e0777 100644 --- a/api/@ohos.net.socket.d.ts +++ b/api/@ohos.net.socket.d.ts @@ -15,6 +15,7 @@ import {AsyncCallback, Callback, ErrorCallback} from "./basic"; import connection from "./@ohos.net.connection"; +import cryptoFramework from "./@ohos.security.cryptoFramework"; /** * Provides TCP and UDP Socket APIs. @@ -24,6 +25,7 @@ import connection from "./@ohos.net.connection"; */ declare namespace socket { export import NetAddress = connection.NetAddress; + export type X509CertRawData = cryptoFramework.EncodingBlob; /** * Creates a UDPSocket object. @@ -35,6 +37,20 @@ declare namespace socket { */ function constructTCPSocketInstance(): TCPSocket; + /** + * Creates a TLSSocket object. + * + * @since 9 + */ + function constructTLSSocketInstance(): TLSSocket; + + /** + * Creates a Local Socket object. + * + * @since 10 + */ + function constructLocalSocketInstance(name: string, isServer?: boolean): LocalSocket; + export interface UDPSendOptions { /** * Data to send. @@ -219,7 +235,7 @@ declare namespace socket { /** * Socket linger. */ - socketLinger: {on: boolean, linger: number}; + socketLinger?: {on: boolean, linger: number}; } export interface TCPSocket { @@ -314,6 +330,176 @@ declare namespace socket { */ off(type: 'error', callback?: ErrorCallback): void; } + + /** + * @since 9 + */ + export interface TLSSocket extends TCPSocket { + + /** + * Returns an object representing a local certificate. + */ + getCertificate(callback: AsyncCallback): void; + getCertificate(): Promise; + + /** + * Returns an object representing the peer certificate. If the peer does not provide a certificate, + * an empty object will be returned. If the socket is destroyed, null is returned. + * If needChain is true, it contains the complete certificate chain. Otherwise, + * it only contains the peer's certificate. + */ + getRemoteCertificate(callback: AsyncCallback): void; + getRemoteCertificate(): Promise; + + /** + * Returns a string containing the negotiated SSL/TLS protocol version of the current connection. + * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned. + * Server sockets or disconnected client sockets will return a value of null. + */ + getProtocol(callback: AsyncCallback): void; + getProtocol(): Promise; + + /** + * Returns an object containing the negotiated cipher suite information. + * For example:{"name": "AES128-SHA256", "standardName": "TLS_RSA_WITH_AES_128_CBC_SHA256", "version": "TLSv1.2"} + */ + getCipherSuite(callback: AsyncCallback>): void; + getCipherSuite(): Promise>; + + /** + * The list of signature algorithms shared between the server and the client, in descending order of priority. + * @see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html + */ + getSignatureAlgorithms(callback: AsyncCallback>): void; + getSignatureAlgorithms(): Promise>; + + /** + * @permission ohos.permission.INTERNET + */ + connect(options: TLSConnectOptions, callback: AsyncCallback): void; + connect(options: TLSConnectOptions): Promise; + + /** + * Sends data over a TLSSocket connection. + * + * @param data Optional parameters {@link string}. + * @permission ohos.permission.INTERNET + */ + send(data: string, callback: AsyncCallback): void; + send(data: string): Promise; + } + + /** + * @since 9 + */ + export interface TLSSecureOptions { + ca: string | Array; + cert: string; + key: string; + passwd?: string; + protocols?: Protocol | Array; + /** + * default is false, use local cipher. + */ + useRemoteCipherPrefer?: boolean; + /** + * Supported signature algorithms. This list can contain summary algorithms(SHA256、MD5、etc)、 + * Public key algorithm(RSA-PSS、ECDSA、etc)、Combination of the two(For example 'RSA+SHA384') + * or TLS v1.3 Scheme name(For example rsa_pss_pss_sha512) + */ + signatureAlgorithms?: string; + + /** + * Crypto suite specification + */ + cipherSuite?: string; + /** + * Certificate Revocation List + */ + crl?: string | Array; + } + + /** + * @since 9 + */ + export interface TLSConnectOptions { + address: NetAddress; + secureOptions: TLSSecureOptions; + checkServerIdentity?: (hostname: string, cert: X509CertRawData) => Error | undefined; + /** + * Application layer protocol negotiation extension, supporting HTTP, HTTP/2 + */ + ALPNProtocols?: Array; + } + + /** + * @since 9 + */ + export enum Protocol { + TLSv12 = "TLSv1.2", + TLSv13 = "TLSv1.3", + } + + /** + * @since 10 + */ + export interface LocalSocket { + /** + * Accepts a connection request from the client. + */ + accept(callback: AsyncCallback): void; + accept(): Promise; + + /** + * Connects the client socket to a specified address for setting up a connection with the server. + */ + connect(callback: AsyncCallback): void; + connect(): Promise; + + /** + * Closes the socket after the server and client finish communicating with each other. + */ + close(callback: AsyncCallback): void; + close(): Promise; + + /** + * Sends data over a LocalSocket connection. + * + * @param data Data to send. + */ + send(data: string | ArrayBuffer, callback: AsyncCallback): void; + send(data: string | ArrayBuffer): Promise; + + /** + * Listens for message receiving events of the LocalSocket connection. + */ + on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; + + /** + * Cancels listening for message receiving events of the LocalSocket connection. + */ + off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; + + /** + * Listens for connection or close events of the LocalSocket connection. + */ + on(type: 'connect' | 'close', callback: Callback): void; + + /** + * Cancels listening for connection or close events of the LocalSocket connection. + */ + off(type: 'connect' | 'close', callback?: Callback): void; + + /** + * Listens for error events of the LocalSocket connection. + */ + on(type: 'error', callback: ErrorCallback): void; + + /** + * Cancels listening for error events of the LocalSocket connection. + */ + off(type: 'error', callback?: ErrorCallback): void; + } } export default socket; \ No newline at end of file -- Gitee From 173a0e74e39650993f297c4de833ff964a42c735 Mon Sep 17 00:00:00 2001 From: fuchao Date: Fri, 30 Sep 2022 19:53:13 +0800 Subject: [PATCH 2/2] Update dts Signed-off-by: fuchao --- api/@ohos.net.connection.d.ts | 23 +------------ api/@ohos.net.http.d.ts | 6 ---- api/@ohos.net.socket.d.ts | 61 ----------------------------------- 3 files changed, 1 insertion(+), 89 deletions(-) diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index 55d369dbf9..6bb1aabb2c 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -55,6 +55,7 @@ declare namespace connection { * @return Returns the {@link NetHandle} object; * returns {@code null} if the default network is not activated. * @permission ohos.permission.GET_NETWORK_INFO + * @since 9 */ function getDefaultNetSync(): NetHandle; @@ -454,28 +455,6 @@ declare namespace connection { family?: number; // IPv4 = 1; IPv6 = 2, default is IPv4 port?: number; // [0, 65535] } - - /** - * @since 9 - */ - export interface NetProxy { - type: ProxyType; - address: NetAddress; - } - - /** - * @since 9 - */ - export enum ProxyType { - /** - * Represents proxy for high level protocols such as HTTP or FTP. - */ - HTTP, - /** - * Represents a SOCKS (V4 or V5) proxy. - */ - SOCKS - } } export default connection; \ No newline at end of file diff --git a/api/@ohos.net.http.d.ts b/api/@ohos.net.http.d.ts index 8875689e43..c1732e1aff 100644 --- a/api/@ohos.net.http.d.ts +++ b/api/@ohos.net.http.d.ts @@ -77,12 +77,6 @@ declare namespace http { * @since 9 */ secureOptions?: TLSSecureOptions; - /** - * For https. - * - * @since 9 - */ - checkServerIdentity?: (hostname: string, certs: Array) => Error | undefined; } export interface HttpRequest { diff --git a/api/@ohos.net.socket.d.ts b/api/@ohos.net.socket.d.ts index e06b2e0777..975374b6de 100644 --- a/api/@ohos.net.socket.d.ts +++ b/api/@ohos.net.socket.d.ts @@ -439,67 +439,6 @@ declare namespace socket { TLSv12 = "TLSv1.2", TLSv13 = "TLSv1.3", } - - /** - * @since 10 - */ - export interface LocalSocket { - /** - * Accepts a connection request from the client. - */ - accept(callback: AsyncCallback): void; - accept(): Promise; - - /** - * Connects the client socket to a specified address for setting up a connection with the server. - */ - connect(callback: AsyncCallback): void; - connect(): Promise; - - /** - * Closes the socket after the server and client finish communicating with each other. - */ - close(callback: AsyncCallback): void; - close(): Promise; - - /** - * Sends data over a LocalSocket connection. - * - * @param data Data to send. - */ - send(data: string | ArrayBuffer, callback: AsyncCallback): void; - send(data: string | ArrayBuffer): Promise; - - /** - * Listens for message receiving events of the LocalSocket connection. - */ - on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; - - /** - * Cancels listening for message receiving events of the LocalSocket connection. - */ - off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; - - /** - * Listens for connection or close events of the LocalSocket connection. - */ - on(type: 'connect' | 'close', callback: Callback): void; - - /** - * Cancels listening for connection or close events of the LocalSocket connection. - */ - off(type: 'connect' | 'close', callback?: Callback): void; - - /** - * Listens for error events of the LocalSocket connection. - */ - on(type: 'error', callback: ErrorCallback): void; - - /** - * Cancels listening for error events of the LocalSocket connection. - */ - off(type: 'error', callback?: ErrorCallback): void; - } } export default socket; \ No newline at end of file -- Gitee