161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit ConnectivityKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport type { AsyncCallback, Callback } from './@ohos.base'; 2261847f8eSopenharmony_ci 2361847f8eSopenharmony_ci/** 2461847f8eSopenharmony_ci * Provides APIs for mobile applications to access different SEs in mobile devices, such as SIMs or embedded SEs. 2561847f8eSopenharmony_ci * See "Open Mobile API Specification". 2661847f8eSopenharmony_ci * 2761847f8eSopenharmony_ci * @namespace omapi 2861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 2961847f8eSopenharmony_ci * @since 10 3061847f8eSopenharmony_ci */ 3161847f8eSopenharmony_cideclare namespace omapi { 3261847f8eSopenharmony_ci /** 3361847f8eSopenharmony_ci * Establish a new connection that can be used to connect to all the SEs available in the system. 3461847f8eSopenharmony_ci * The connection process can be quite long, so it happens in an asynchronous way. It is usable only 3561847f8eSopenharmony_ci * if the specified callback is called or if isConnected() returns true. 3661847f8eSopenharmony_ci * 3761847f8eSopenharmony_ci * @param { 'serviceState' } type nfc serviceState 3861847f8eSopenharmony_ci * @param { Callback<ServiceState> } callback - The callback to return the service. 3961847f8eSopenharmony_ci * @returns { SEService } The new SEService instance. 4061847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 4161847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 4261847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 4361847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 4461847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 4561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 4661847f8eSopenharmony_ci * @since 10 4761847f8eSopenharmony_ci * @deprecated since 12 4861847f8eSopenharmony_ci * @useinstead omapi#createService 4961847f8eSopenharmony_ci */ 5061847f8eSopenharmony_ci function newSEService(type: 'serviceState', callback: Callback<ServiceState>): SEService; 5161847f8eSopenharmony_ci 5261847f8eSopenharmony_ci /** 5361847f8eSopenharmony_ci * Establish a new connection that can be used to connect to all the SEs available in the system. 5461847f8eSopenharmony_ci * The connection process can be quite long, so it happens in an asynchronous way. It is usable only 5561847f8eSopenharmony_ci * if isConnected() returns true. 5661847f8eSopenharmony_ci * 5761847f8eSopenharmony_ci * @returns { Promise<SEService> } Returns the created SEService instance. 5861847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 5961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 6061847f8eSopenharmony_ci * @since 12 6161847f8eSopenharmony_ci */ 6261847f8eSopenharmony_ci function createService(): Promise<SEService>; 6361847f8eSopenharmony_ci 6461847f8eSopenharmony_ci /** 6561847f8eSopenharmony_ci * SEService realizes the communication to available SEs on the device. 6661847f8eSopenharmony_ci * 6761847f8eSopenharmony_ci * @typedef SEService 6861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 6961847f8eSopenharmony_ci * @since 10 7061847f8eSopenharmony_ci */ 7161847f8eSopenharmony_ci export interface SEService { 7261847f8eSopenharmony_ci /** 7361847f8eSopenharmony_ci * Returns the list of available SE readers. There must be no duplicated objects in the returned list. 7461847f8eSopenharmony_ci * All available readers SHALL be listed even if no card is inserted. 7561847f8eSopenharmony_ci * 7661847f8eSopenharmony_ci * @returns { Reader[] } The list of available SE readers. 7761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 7861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 7961847f8eSopenharmony_ci * @since 10 8061847f8eSopenharmony_ci */ 8161847f8eSopenharmony_ci getReaders(): Reader[]; 8261847f8eSopenharmony_ci 8361847f8eSopenharmony_ci /** 8461847f8eSopenharmony_ci * Checks whether or not the service is connected. 8561847f8eSopenharmony_ci * 8661847f8eSopenharmony_ci * @returns { boolean } True if the service is connected. 8761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 8861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 8961847f8eSopenharmony_ci * @since 10 9061847f8eSopenharmony_ci */ 9161847f8eSopenharmony_ci isConnected(): boolean; 9261847f8eSopenharmony_ci 9361847f8eSopenharmony_ci /** 9461847f8eSopenharmony_ci * Releases all SE resources allocated by this SEService. As a result isConnected() will return false. 9561847f8eSopenharmony_ci * 9661847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 9761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 9861847f8eSopenharmony_ci * @since 10 9961847f8eSopenharmony_ci */ 10061847f8eSopenharmony_ci shutdown(): void; 10161847f8eSopenharmony_ci 10261847f8eSopenharmony_ci /** 10361847f8eSopenharmony_ci * Returns the version of the Open Mobile API Specification this implementation is based on. 10461847f8eSopenharmony_ci * 10561847f8eSopenharmony_ci * @returns { string } The Open Mobile API version (e.g. “3.3” for Open Mobile API Specification version 3.3). 10661847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 10761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 10861847f8eSopenharmony_ci * @since 10 10961847f8eSopenharmony_ci */ 11061847f8eSopenharmony_ci getVersion(): string; 11161847f8eSopenharmony_ci } 11261847f8eSopenharmony_ci 11361847f8eSopenharmony_ci /** 11461847f8eSopenharmony_ci * Reader represents the SE readers supported by this device. 11561847f8eSopenharmony_ci * 11661847f8eSopenharmony_ci * @typedef Reader 11761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 11861847f8eSopenharmony_ci * @since 10 11961847f8eSopenharmony_ci */ 12061847f8eSopenharmony_ci export interface Reader { 12161847f8eSopenharmony_ci /** 12261847f8eSopenharmony_ci * Returns the name of this reader. 12361847f8eSopenharmony_ci * If this reader is a SIM reader, then its name must be "SIM[slot]". 12461847f8eSopenharmony_ci * If the reader is an embedded SE reader, then its name must be "eSE[slot]". 12561847f8eSopenharmony_ci * 12661847f8eSopenharmony_ci * @returns { string } The reader name, as a String. 12761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 12861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 12961847f8eSopenharmony_ci * @since 10 13061847f8eSopenharmony_ci */ 13161847f8eSopenharmony_ci getName(): string; 13261847f8eSopenharmony_ci 13361847f8eSopenharmony_ci /** 13461847f8eSopenharmony_ci * Checks if a SE is present in this reader. 13561847f8eSopenharmony_ci * 13661847f8eSopenharmony_ci * @returns { boolean } True if the SE is present, false otherwise. 13761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 13861847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, service state exception. 13961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 14061847f8eSopenharmony_ci * @since 10 14161847f8eSopenharmony_ci */ 14261847f8eSopenharmony_ci isSecureElementPresent(): boolean; 14361847f8eSopenharmony_ci 14461847f8eSopenharmony_ci /** 14561847f8eSopenharmony_ci * Connects to a SE in this reader. 14661847f8eSopenharmony_ci * This method prepares (initializes) the SE for communication before the session object is returned. 14761847f8eSopenharmony_ci * There might be multiple sessions opened at the same time on the same reader. 14861847f8eSopenharmony_ci * 14961847f8eSopenharmony_ci * @returns { Session } A Session object to be used to create channels. 15061847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 15161847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, service state exception. 15261847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 15361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 15461847f8eSopenharmony_ci * @since 10 15561847f8eSopenharmony_ci */ 15661847f8eSopenharmony_ci openSession(): Session; 15761847f8eSopenharmony_ci 15861847f8eSopenharmony_ci /** 15961847f8eSopenharmony_ci * Close all the sessions opened on this reader. All the channels opened by all these sessions will be closed. 16061847f8eSopenharmony_ci * 16161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 16261847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, service state exception. 16361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 16461847f8eSopenharmony_ci * @since 10 16561847f8eSopenharmony_ci */ 16661847f8eSopenharmony_ci closeSessions(): void; 16761847f8eSopenharmony_ci } 16861847f8eSopenharmony_ci 16961847f8eSopenharmony_ci /** 17061847f8eSopenharmony_ci * Session represent a connection session to one of the SEs available on the device. These objects 17161847f8eSopenharmony_ci * can be used to get a communication channel with an applet in the SE. This channel can be the basic channel 17261847f8eSopenharmony_ci * or a logical channel. 17361847f8eSopenharmony_ci * 17461847f8eSopenharmony_ci * @typedef Session 17561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 17661847f8eSopenharmony_ci * @since 10 17761847f8eSopenharmony_ci */ 17861847f8eSopenharmony_ci export interface Session { 17961847f8eSopenharmony_ci /** 18061847f8eSopenharmony_ci * Get the reader that provides this session. 18161847f8eSopenharmony_ci * 18261847f8eSopenharmony_ci * @returns { Reader } The Reader object. 18361847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 18461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 18561847f8eSopenharmony_ci * @since 10 18661847f8eSopenharmony_ci */ 18761847f8eSopenharmony_ci getReader(): Reader; 18861847f8eSopenharmony_ci 18961847f8eSopenharmony_ci /** 19061847f8eSopenharmony_ci * Get the ATR of this SE. 19161847f8eSopenharmony_ci * A empty array SHALL be returned if the ATR for this SE is not available. 19261847f8eSopenharmony_ci * 19361847f8eSopenharmony_ci * @returns { number[] } The ATR as a number array or empty array. 19461847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 19561847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, service state exception. 19661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 19761847f8eSopenharmony_ci * @since 10 19861847f8eSopenharmony_ci */ 19961847f8eSopenharmony_ci getATR(): number[]; 20061847f8eSopenharmony_ci 20161847f8eSopenharmony_ci /** 20261847f8eSopenharmony_ci * Close the connection with the SE. This will close any channels opened by this application with this SE. 20361847f8eSopenharmony_ci * 20461847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 20561847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, service state exception. 20661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 20761847f8eSopenharmony_ci * @since 10 20861847f8eSopenharmony_ci */ 20961847f8eSopenharmony_ci close(): void; 21061847f8eSopenharmony_ci 21161847f8eSopenharmony_ci /** 21261847f8eSopenharmony_ci * Check if this session is closed. 21361847f8eSopenharmony_ci * 21461847f8eSopenharmony_ci * @returns { boolean } True if the session is closed, false otherwise. 21561847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 21661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 21761847f8eSopenharmony_ci * @since 10 21861847f8eSopenharmony_ci */ 21961847f8eSopenharmony_ci isClosed(): boolean; 22061847f8eSopenharmony_ci 22161847f8eSopenharmony_ci /** 22261847f8eSopenharmony_ci * Close any channels opened on this session. 22361847f8eSopenharmony_ci * 22461847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 22561847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, service state exception. 22661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 22761847f8eSopenharmony_ci * @since 10 22861847f8eSopenharmony_ci */ 22961847f8eSopenharmony_ci closeChannels(): void; 23061847f8eSopenharmony_ci 23161847f8eSopenharmony_ci /** 23261847f8eSopenharmony_ci * This method is provided to ease the development of mobile applications and for backward compatibility with 23361847f8eSopenharmony_ci * existing applications. This method is equivalent to openBasicChannel(aid, P2=0x00). 23461847f8eSopenharmony_ci * 23561847f8eSopenharmony_ci * @param { number[] } aid - The AID of the applet to be selected on this channel, as a byte array, 23661847f8eSopenharmony_ci * or Null if no applet is to be selected. 23761847f8eSopenharmony_ci * @returns { Promise<Channel> } An instance of channel if available. Null if the SE is unable to provide. 23861847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 23961847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 24061847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 24161847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 24261847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 24361847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, an attempt is made to use an SE session that has been closed. 24461847f8eSopenharmony_ci * @throws { BusinessError } 3300102 - NoSuchElementError, the AID on the SE is not available or cannot be selected. 24561847f8eSopenharmony_ci * @throws { BusinessError } 3300103 - SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. 24661847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 24761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 24861847f8eSopenharmony_ci * @since 10 24961847f8eSopenharmony_ci */ 25061847f8eSopenharmony_ci openBasicChannel(aid: number[]): Promise<Channel>; 25161847f8eSopenharmony_ci 25261847f8eSopenharmony_ci /** 25361847f8eSopenharmony_ci * This method is provided to ease the development of mobile applications and for backward compatibility with 25461847f8eSopenharmony_ci * existing applications. This method is equivalent to openBasicChannel(aid, P2=0x00). 25561847f8eSopenharmony_ci * 25661847f8eSopenharmony_ci * @param { number[] } aid - The AID of the applet to be selected on this channel, as a byte array, 25761847f8eSopenharmony_ci * or Null if no applet is to be selected. 25861847f8eSopenharmony_ci * @param { AsyncCallback<Channel> } callback - The callback to return the Channel object. Null if the SE is unable to provide. 25961847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 26061847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 26161847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 26261847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 26361847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 26461847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, an attempt is made to use an SE session that has been closed. 26561847f8eSopenharmony_ci * @throws { BusinessError } 3300102 - NoSuchElementError, the AID on the SE is not available or cannot be selected. 26661847f8eSopenharmony_ci * @throws { BusinessError } 3300103 - SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. 26761847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 26861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 26961847f8eSopenharmony_ci * @since 10 27061847f8eSopenharmony_ci */ 27161847f8eSopenharmony_ci openBasicChannel(aid: number[], callback: AsyncCallback<Channel>): void; 27261847f8eSopenharmony_ci 27361847f8eSopenharmony_ci /** 27461847f8eSopenharmony_ci * Get access to the basic channel, as defined in [ISO 7816-4] (the one that has number 0). The obtained object 27561847f8eSopenharmony_ci * is an instance of the channel class. 27661847f8eSopenharmony_ci * Once this channel has been opened by a device application, it is considered as ‘locked’ by this device 27761847f8eSopenharmony_ci * application, and other calls to this method SHALL return Null, until the channel is closed. 27861847f8eSopenharmony_ci * Some SE plug-ins, such as those handling UICC, may prevent the use of the Basic Channel. In these cases, 27961847f8eSopenharmony_ci * a Null value SHALL be returned. 28061847f8eSopenharmony_ci * P2 is normally 0x00. The device SHOULD allow any value for P2 and SHALL allow the following values: 28161847f8eSopenharmony_ci * 0x00, 0x04, 0x08, 0x0C (as defined in [ISO 7816-4]). 28261847f8eSopenharmony_ci * 28361847f8eSopenharmony_ci * @param { number[] } aid - The AID of the applet to be selected on this channel, as a byte array, 28461847f8eSopenharmony_ci * or Null if no applet is to be selected. 28561847f8eSopenharmony_ci * @param { number } p2 - The P2 parameter of the SELECT APDU executed on this channel. 28661847f8eSopenharmony_ci * @returns { Promise<Channel> } An instance of channel if available. Null if the SE is unable to provide. 28761847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 28861847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 28961847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 29061847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 29161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 29261847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, an attempt is made to use an SE session that has been closed. 29361847f8eSopenharmony_ci * @throws { BusinessError } 3300102 - NoSuchElementError, the AID on the SE is not available or cannot be selected. 29461847f8eSopenharmony_ci * @throws { BusinessError } 3300103 - SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. 29561847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 29661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 29761847f8eSopenharmony_ci * @since 10 29861847f8eSopenharmony_ci */ 29961847f8eSopenharmony_ci openBasicChannel(aid: number[], p2: number): Promise<Channel>; 30061847f8eSopenharmony_ci 30161847f8eSopenharmony_ci /** 30261847f8eSopenharmony_ci * Get access to the basic channel, as defined in [ISO 7816-4] (the one that has number 0). The obtained object 30361847f8eSopenharmony_ci * is an instance of the channel class. 30461847f8eSopenharmony_ci * Once this channel has been opened by a device application, it is considered as ‘locked’ by this device 30561847f8eSopenharmony_ci * application, and other calls to this method SHALL return Null, until the channel is closed. 30661847f8eSopenharmony_ci * Some SE plug-ins, such as those handling UICC, may prevent the use of the Basic Channel. In these cases, 30761847f8eSopenharmony_ci * a Null value SHALL be returned. 30861847f8eSopenharmony_ci * P2 is normally 0x00. The device SHOULD allow any value for P2 and SHALL allow the following values: 30961847f8eSopenharmony_ci * 0x00, 0x04, 0x08, 0x0C (as defined in [ISO 7816-4]). 31061847f8eSopenharmony_ci * 31161847f8eSopenharmony_ci * @param { number[] } aid - The AID of the applet to be selected on this channel, as a byte array, 31261847f8eSopenharmony_ci * or Null if no applet is to be selected. 31361847f8eSopenharmony_ci * @param { number } p2 - The P2 parameter of the SELECT APDU executed on this channel. 31461847f8eSopenharmony_ci * @param { AsyncCallback<Channel> } callback - The callback to return the Channel object. Null if the SE is unable to provide. 31561847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 31661847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 31761847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 31861847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 31961847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 32061847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, an attempt is made to use an SE session that has been closed. 32161847f8eSopenharmony_ci * @throws { BusinessError } 3300102 - NoSuchElementError, the AID on the SE is not available or cannot be selected. 32261847f8eSopenharmony_ci * @throws { BusinessError } 3300103 - SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. 32361847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 32461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 32561847f8eSopenharmony_ci * @since 10 32661847f8eSopenharmony_ci */ 32761847f8eSopenharmony_ci openBasicChannel(aid: number[], p2: number, callback: AsyncCallback<Channel>): void; 32861847f8eSopenharmony_ci 32961847f8eSopenharmony_ci /** 33061847f8eSopenharmony_ci * This method is provided to ease the development of mobile applications and for backward compatibility with 33161847f8eSopenharmony_ci * existing applications. This method is equivalent to openLogicalChannel(aid, P2=0x00). 33261847f8eSopenharmony_ci * 33361847f8eSopenharmony_ci * @param { number[] } aid - The AID of the applet to be selected on this channel, as a byte array. 33461847f8eSopenharmony_ci * @returns { Promise<Channel> } An instance of channel if available. Null if the SE is unable to provide. 33561847f8eSopenharmony_ci * A new logical channel or is unable to retrieve Access Control rules due to the lack of an available logical channel. 33661847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 33761847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 33861847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 33961847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 34061847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 34161847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, an attempt is made to use an SE session that has been closed. 34261847f8eSopenharmony_ci * @throws { BusinessError } 3300102 - NoSuchElementError, the AID on the SE is not available or cannot be selected or 34361847f8eSopenharmony_ci * a logical channel is already open to a non-multi-selectable applet. 34461847f8eSopenharmony_ci * @throws { BusinessError } 3300103 - SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. 34561847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 34661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 34761847f8eSopenharmony_ci * @since 10 34861847f8eSopenharmony_ci */ 34961847f8eSopenharmony_ci openLogicalChannel(aid: number[]): Promise<Channel>; 35061847f8eSopenharmony_ci 35161847f8eSopenharmony_ci /** 35261847f8eSopenharmony_ci * This method is provided to ease the development of mobile applications and for backward compatibility with 35361847f8eSopenharmony_ci * existing applications. This method is equivalent to openLogicalChannel(aid, P2=0x00). 35461847f8eSopenharmony_ci * 35561847f8eSopenharmony_ci * @param { number[] } aid - The AID of the applet to be selected on this channel, as a byte array. 35661847f8eSopenharmony_ci * @param { AsyncCallback<Channel> } callback - The callback to return the Channel object. Null if the SE is unable to provide. 35761847f8eSopenharmony_ci * A new logical channel or is unable to retrieve Access Control rules due to the lack of an available logical channel. 35861847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 35961847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 36061847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 36161847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 36261847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 36361847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, an attempt is made to use an SE session that has been closed. 36461847f8eSopenharmony_ci * @throws { BusinessError } 3300102 - NoSuchElementError, the AID on the SE is not available or cannot be selected or 36561847f8eSopenharmony_ci * a logical channel is already open to a non-multi-selectable applet. 36661847f8eSopenharmony_ci * @throws { BusinessError } 3300103 - SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. 36761847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 36861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 36961847f8eSopenharmony_ci * @since 10 37061847f8eSopenharmony_ci */ 37161847f8eSopenharmony_ci openLogicalChannel(aid: number[], callback: AsyncCallback<Channel>): void; 37261847f8eSopenharmony_ci 37361847f8eSopenharmony_ci /** 37461847f8eSopenharmony_ci * Open a logical channel with the SE, selecting the applet represented by the given AID (when the AID is not 37561847f8eSopenharmony_ci * Null and the length of the AID is not 0). 37661847f8eSopenharmony_ci * If the length of the AID is 0, the method will select the Issuer Security Domain of the SE by sending a SELECT 37761847f8eSopenharmony_ci * command with 0 length AID as defined in [GPCS]. 37861847f8eSopenharmony_ci * If the AID is Null, the method SHALL only send a MANAGE CHANNEL Open and SHALL NOT send a 37961847f8eSopenharmony_ci * SELECT command. In this case, the default applet associated to the logical channel will be selected by default. 38061847f8eSopenharmony_ci * P2 is normally 0x00. The device SHOULD allow any value for P2 and SHALL allow the following values: 38161847f8eSopenharmony_ci * 0x00, 0x04, 0x08, 0x0C (as defined in [ISO 7816-4]). 38261847f8eSopenharmony_ci * 38361847f8eSopenharmony_ci * @param { number[] } aid - The AID of the applet to be selected on this channel, as a byte array. 38461847f8eSopenharmony_ci * @param { number } p2 - The P2 parameter of the SELECT APDU executed on this channel. 38561847f8eSopenharmony_ci * @returns { Promise<Channel> } An instance of channel if available. Null if the SE is unable to provide. 38661847f8eSopenharmony_ci * A new logical channel or is unable to retrieve Access Control rules due to the lack of an available logical channel. 38761847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 38861847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 38961847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 39061847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 39161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 39261847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, an attempt is made to use an SE session that has been closed. 39361847f8eSopenharmony_ci * @throws { BusinessError } 3300102 - NoSuchElementError, the AID on the SE is not available or cannot be selected or 39461847f8eSopenharmony_ci * a logical channel is already open to a non-multi-selectable applet. 39561847f8eSopenharmony_ci * @throws { BusinessError } 3300103 - SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. 39661847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 39761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 39861847f8eSopenharmony_ci * @since 10 39961847f8eSopenharmony_ci */ 40061847f8eSopenharmony_ci openLogicalChannel(aid: number[], p2: number): Promise<Channel>; 40161847f8eSopenharmony_ci 40261847f8eSopenharmony_ci /** 40361847f8eSopenharmony_ci * Open a logical channel with the SE, selecting the applet represented by the given AID (when the AID is not 40461847f8eSopenharmony_ci * Null and the length of the AID is not 0). 40561847f8eSopenharmony_ci * If the length of the AID is 0, the method will select the Issuer Security Domain of the SE by sending a SELECT 40661847f8eSopenharmony_ci * command with 0 length AID as defined in [GPCS]. 40761847f8eSopenharmony_ci * If the AID is Null, the method SHALL only send a MANAGE CHANNEL Open and SHALL NOT send a 40861847f8eSopenharmony_ci * SELECT command. In this case, the default applet associated to the logical channel will be selected by default. 40961847f8eSopenharmony_ci * P2 is normally 0x00. The device SHOULD allow any value for P2 and SHALL allow the following values: 41061847f8eSopenharmony_ci * 0x00, 0x04, 0x08, 0x0C (as defined in [ISO 7816-4]). 41161847f8eSopenharmony_ci * 41261847f8eSopenharmony_ci * @param { number[] } aid - The AID of the applet to be selected on this channel, as a byte array. 41361847f8eSopenharmony_ci * @param { number } p2 - The P2 parameter of the SELECT APDU executed on this channel. 41461847f8eSopenharmony_ci * @param { AsyncCallback<Channel> } callback - The callback to return the instance of channel. Null if the SE is unable to provide. 41561847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 41661847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 41761847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 41861847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 41961847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 42061847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, an attempt is made to use an SE session that has been closed. 42161847f8eSopenharmony_ci * @throws { BusinessError } 3300102 - NoSuchElementError, the AID on the SE is not available or cannot be selected or 42261847f8eSopenharmony_ci * a logical channel is already open to a non-multi-selectable applet. 42361847f8eSopenharmony_ci * @throws { BusinessError } 3300103 - SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. 42461847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 42561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 42661847f8eSopenharmony_ci * @since 10 42761847f8eSopenharmony_ci */ 42861847f8eSopenharmony_ci openLogicalChannel(aid: number[], p2: number, callback: AsyncCallback<Channel>): void; 42961847f8eSopenharmony_ci } 43061847f8eSopenharmony_ci 43161847f8eSopenharmony_ci /** 43261847f8eSopenharmony_ci * Channel represents an [ISO 7816-4] channel opened to a SE. It can be either a logical channel or the basic channel. 43361847f8eSopenharmony_ci * 43461847f8eSopenharmony_ci * @typedef Channel 43561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 43661847f8eSopenharmony_ci * @since 10 43761847f8eSopenharmony_ci */ 43861847f8eSopenharmony_ci export interface Channel { 43961847f8eSopenharmony_ci /** 44061847f8eSopenharmony_ci * Get the session that has opened this channel. 44161847f8eSopenharmony_ci * 44261847f8eSopenharmony_ci * @returns { Session } The Session object this channel is bound to. 44361847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 44461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 44561847f8eSopenharmony_ci * @since 10 44661847f8eSopenharmony_ci */ 44761847f8eSopenharmony_ci getSession(): Session; 44861847f8eSopenharmony_ci 44961847f8eSopenharmony_ci /** 45061847f8eSopenharmony_ci * Closes this channel to the SE. 45161847f8eSopenharmony_ci * If the method is called when the channel is already closed, this method SHALL be ignored. 45261847f8eSopenharmony_ci * 45361847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 45461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 45561847f8eSopenharmony_ci * @since 10 45661847f8eSopenharmony_ci */ 45761847f8eSopenharmony_ci close(): void; 45861847f8eSopenharmony_ci 45961847f8eSopenharmony_ci /** 46061847f8eSopenharmony_ci * Checks whether this channel is the basic channel. 46161847f8eSopenharmony_ci * 46261847f8eSopenharmony_ci * @returns { boolean } True if this channel is a basic channel, false otherwise. 46361847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 46461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 46561847f8eSopenharmony_ci * @since 10 46661847f8eSopenharmony_ci */ 46761847f8eSopenharmony_ci isBasicChannel(): boolean; 46861847f8eSopenharmony_ci 46961847f8eSopenharmony_ci /** 47061847f8eSopenharmony_ci * Checks if this channel is closed. 47161847f8eSopenharmony_ci * 47261847f8eSopenharmony_ci * @returns { boolean } True if the channel is closed, false otherwise. 47361847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 47461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 47561847f8eSopenharmony_ci * @since 10 47661847f8eSopenharmony_ci */ 47761847f8eSopenharmony_ci isClosed(): boolean; 47861847f8eSopenharmony_ci 47961847f8eSopenharmony_ci /** 48061847f8eSopenharmony_ci * Returns the data as received from the application select command, including the status word received 48161847f8eSopenharmony_ci * at applet selection. 48261847f8eSopenharmony_ci * 48361847f8eSopenharmony_ci * @returns { number[] } The data as returned by the application select command inclusive of the status word. 48461847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 48561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 48661847f8eSopenharmony_ci * @since 10 48761847f8eSopenharmony_ci */ 48861847f8eSopenharmony_ci getSelectResponse(): number[]; 48961847f8eSopenharmony_ci 49061847f8eSopenharmony_ci /** 49161847f8eSopenharmony_ci * Transmit an APDU command (as per ISO/IEC 7816) to the SE. 49261847f8eSopenharmony_ci * 49361847f8eSopenharmony_ci * @param { number[] } command - The APDU command to be transmitted, as a byte array. 49461847f8eSopenharmony_ci * @returns { Promise<number[]> } The response received, as a byte array. 49561847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 49661847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 49761847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 49861847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 49961847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 50061847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, an attempt is made to use an SE session or channel that has been closed. 50161847f8eSopenharmony_ci * @throws { BusinessError } 3300103 - SecurityError, the command is filtered by the security policy. 50261847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 50361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 50461847f8eSopenharmony_ci * @since 10 50561847f8eSopenharmony_ci */ 50661847f8eSopenharmony_ci transmit(command: number[]): Promise<number[]>; 50761847f8eSopenharmony_ci 50861847f8eSopenharmony_ci /** 50961847f8eSopenharmony_ci * Transmit an APDU command (as per ISO/IEC 7816) to the SE. 51061847f8eSopenharmony_ci * 51161847f8eSopenharmony_ci * @param { number[] } command - The APDU command to be transmitted, as a byte array. 51261847f8eSopenharmony_ci * @param { AsyncCallback<number[]> } callback - The callback to return the response received, as a byte array. 51361847f8eSopenharmony_ci * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 51461847f8eSopenharmony_ci * <br> 1. Mandatory parameters are left unspecified. 51561847f8eSopenharmony_ci * <br> 2. Incorrect parameters types. 51661847f8eSopenharmony_ci * <br> 3. Parameter verification failed. 51761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 51861847f8eSopenharmony_ci * @throws { BusinessError } 3300101 - IllegalStateError, an attempt is made to use an SE session or channel that has been closed. 51961847f8eSopenharmony_ci * @throws { BusinessError } 3300103 - SecurityError, the command is filtered by the security policy. 52061847f8eSopenharmony_ci * @throws { BusinessError } 3300104 - IOError, there is a communication problem to the reader or the SE. 52161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 52261847f8eSopenharmony_ci * @since 10 52361847f8eSopenharmony_ci */ 52461847f8eSopenharmony_ci transmit(command: number[], callback: AsyncCallback<number[]>): void; 52561847f8eSopenharmony_ci } 52661847f8eSopenharmony_ci 52761847f8eSopenharmony_ci /** 52861847f8eSopenharmony_ci * Secure Element service state definition. 52961847f8eSopenharmony_ci * 53061847f8eSopenharmony_ci * @enum { number } 53161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 53261847f8eSopenharmony_ci * @since 10 53361847f8eSopenharmony_ci */ 53461847f8eSopenharmony_ci enum ServiceState { 53561847f8eSopenharmony_ci /** 53661847f8eSopenharmony_ci * Service is disconnected. 53761847f8eSopenharmony_ci * 53861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 53961847f8eSopenharmony_ci * @since 10 54061847f8eSopenharmony_ci */ 54161847f8eSopenharmony_ci DISCONNECTED = 0, 54261847f8eSopenharmony_ci 54361847f8eSopenharmony_ci /** 54461847f8eSopenharmony_ci * Service is connected. 54561847f8eSopenharmony_ci * 54661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.SecureElement 54761847f8eSopenharmony_ci * @since 10 54861847f8eSopenharmony_ci */ 54961847f8eSopenharmony_ci CONNECTED = 1 55061847f8eSopenharmony_ci } 55161847f8eSopenharmony_ci} 55261847f8eSopenharmony_ciexport default omapi;