1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import measure from '@ohos.measure'; 17import window from '@ohos.window'; 18import ability from '@ohos.ability.ability'; 19import account_osAccount from '@ohos.account.osAccount'; 20import emitter from '@ohos.events.emitter'; 21import dlpPermission from '@ohos.dlpPermission'; 22import bundleManager from '@ohos.bundle.bundleManager'; 23import fs from '@ohos.file.fs'; 24import zlib from '@ohos.zlib'; 25import util from '@ohos.util'; 26import fileUri from '@ohos.file.fileuri'; 27import { BusinessError, Callback } from '@ohos.base' 28import Want from '@ohos.app.ability.Want'; 29import common from '@ohos.app.ability.common'; 30import connection from '@ohos.net.connection'; 31import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; 32import Constants from '../common/constant'; 33import GlobalContext from './GlobalContext'; 34import hiSysEvent from '@ohos.hiSysEvent'; 35import { HiLog } from '../common/HiLog'; 36import { systemDateTime } from '@kit.BasicServicesKit'; 37 38const TAG = 'Utils'; 39const HEAD_LENGTH_IN_BYTE = 28; 40const HEAD_LENGTH_IN_U32 = 7; 41const CERT_OFFSET = 5; 42const CERT_SIZE = 6; 43 44const NET_CAPABILITY_INTERNET: number = 12; 45const NET_CAPABILITY_VALIDATED: number = 16; 46const NET_CAPABILITY_CHECKING_CONNECTIVITY: number = 31; 47const TIME_OUT_SECONDS: number = 3; 48const SLEEP_MILLISECONDS: number = 200; 49 50const DAY_TO_MILLISECOND: number = 1000 * 60 * 60 * 24; 51const MINUTE_TO_MILLISECOND: number = 1000 * 60; 52const SECOND_TO_MILLISECOND: number = 1000; 53 54const enum UnitType { 55 DAY_UNIT = 1, 56 MINUTE_UNIT = 2, 57 SECOND_UNIT = 3, 58} 59 60const UNIT_MAP = new Map<number, number>([ 61 [UnitType.DAY_UNIT, DAY_TO_MILLISECOND], 62 [UnitType.MINUTE_UNIT, MINUTE_TO_MILLISECOND], 63 [UnitType.SECOND_UNIT, SECOND_TO_MILLISECOND], 64]); 65 66class ChangeOption { 67 public offset: number = 0 68 public length: number = 0 69} 70let defaultDlpProperty: dlpPermission.DLPProperty = { 71 ownerAccount: '', 72 ownerAccountType: dlpPermission.AccountType.DOMAIN_ACCOUNT, 73 authUserList: [], 74 contactAccount: '', 75 offlineAccess: true, 76 ownerAccountID: '', 77 everyoneAccessList: [] 78} 79 80let defaultDlpFile: dlpPermission.DLPFile = { 81 dlpProperty: defaultDlpProperty, 82 recoverDLPFile: async () => {}, 83 closeDLPFile: async () => {}, 84 addDLPLinkFile: async () => {}, 85 stopFuseLink: async () => {}, 86 resumeFuseLink: async () => {}, 87 replaceDLPLinkFile: async () => {}, 88 deleteDLPLinkFile: async () => {} 89}; 90 91interface AuthAccount { 92 authAccount: string; 93 textContent?: string; 94} 95 96interface PermissionType { 97 value: Resource; 98 data: string; 99 index: number; 100} 101 102interface DLPInfo { 103 name: string; 104 versionCode: string; 105} 106 107function getFileUriByPath(filePath: string): string { 108 try { 109 let uri = fileUri.getUriFromPath(filePath); 110 return uri; 111 } catch (err) { 112 HiLog.info(TAG, `getUriFromPath error: ${JSON.stringify(err)}`); 113 return ''; 114 } 115} 116 117function getFileFd(uri: string, mode?: number): number { 118 mode = mode || fs.OpenMode.READ_ONLY; 119 try { 120 let file = fs.openSync(uri, mode); 121 HiLog.info(TAG, `open: ${uri}, as: ${file.fd}`); 122 return file.fd; 123 } catch (err) { 124 HiLog.info(TAG, `openSync error: ${JSON.stringify(err)}`); 125 return -1; 126 } 127} 128 129async function getOsAccountInfo(): Promise<account_osAccount.OsAccountInfo> { 130 let accountMgr = account_osAccount.getAccountManager(); 131 return await accountMgr.queryOsAccount(); 132} 133 134function checkDomainAccountInfo(accountInfo: account_osAccount.OsAccountInfo): number { 135 AppStorage.setOrCreate('hiAccountType', dlpPermission.AccountType.DOMAIN_ACCOUNT); 136 if (accountInfo.domainInfo.accountName === '' && 137 accountInfo.domainInfo.accountId === '') { 138 AppStorage.setOrCreate('hiAccountStatus', 0); 139 return Constants.ERR_JS_APP_NO_ACCOUNT_ERROR; 140 } 141 if (!accountInfo.domainInfo.isAuthenticated) { 142 AppStorage.setOrCreate('hiAccountStatus', 0); 143 return Constants.ERR_JS_APP_SYSTEM_IS_AUTHENTICATED; 144 } 145 AppStorage.setOrCreate('hiAccountStatus', 1); 146 return Constants.ERR_JS_APP_ACCOUNT_INFO; 147} 148 149async function getUserId(): Promise<number> { 150 let accountMgr = account_osAccount.getAccountManager(); 151 return await accountMgr.getOsAccountLocalId(); 152} 153 154function getAuthPerm(accountName: string, dlpProperty: dlpPermission.DLPProperty): dlpPermission.DLPFileAccess { 155 let perm: dlpPermission.DLPFileAccess = dlpPermission.DLPFileAccess.NO_PERMISSION; 156 if (accountName === dlpProperty.ownerAccount) { 157 return dlpPermission.DLPFileAccess.FULL_CONTROL; 158 } 159 if ((dlpProperty.everyoneAccessList !== undefined) && (dlpProperty.everyoneAccessList.length > 0)) { 160 perm = Math.max(...dlpProperty.everyoneAccessList); 161 } 162 let authUserList = dlpProperty.authUserList ?? []; 163 for (let i = 0; i < authUserList.length; ++i) { 164 let authUser = authUserList[i]; 165 if (authUser.authAccount === accountName) { 166 return authUser.dlpFileAccess; 167 } 168 } 169 return perm; 170} 171 172function terminateSelfWithResult(resultCode: number, result: string): void { 173 let abilityResult: ability.AbilityResult = { 174 resultCode: resultCode, 175 want: { 176 parameters: { 177 result: result 178 } 179 } 180 }; 181 (getContext() as common.UIAbilityContext).terminateSelfWithResult(abilityResult); 182} 183 184function judgeIsSandBox(want: Want) { 185 return new Promise<boolean>(async resolve => { 186 let callerToken: number = want.parameters?.['ohos.aafwk.param.callerToken'] as number; 187 let callerBundleName: string = want.parameters?.['ohos.aafwk.param.callerBundleName'] as string; 188 let applicationInfo = await bundleManager.getApplicationInfo( 189 callerBundleName, bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT); 190 if (callerToken === applicationInfo.accessTokenId) { 191 resolve(false); 192 } 193 resolve(true); 194 }) 195} 196 197let removeDuplicate = (arr: AuthAccount[], arg: string) => { 198 let map: Map<string, AuthAccount> = new Map(); 199 for (let item of arr) { 200 if (!map.has(item.authAccount)) { 201 map.set(item.authAccount, item); 202 } 203 } 204 return Array.from<AuthAccount>(map.values()); 205} 206 207 208let calculate = (newValue: Area, allNames: AuthAccount[]) => { 209 let editLength = allNames.length; 210 let screenWidth = Number(newValue['width']); 211 let nameChange = Constants.ENCRYPTION_STAFF_WIDTH_NAME; 212 let rowNamesLen = Math.floor(screenWidth / (nameChange + Constants.ENCRYPTION_ADD_STAFF_MARGIN_RIGHT)); 213 let showNamesArr = editLength > Constants.ENCRYPTION_DOUBLED_NUMBER * rowNamesLen 214 ? allNames.slice(0, 2 * rowNamesLen - 1) 215 : allNames.slice(0, 2 * rowNamesLen); 216 let hideNamesNum = editLength - showNamesArr.length > 0 217 ? String(editLength - showNamesArr.length) 218 : '0'; 219 return { 220 'rowNamesLen': rowNamesLen, 221 'showNamesArr': showNamesArr, 222 'hideNamesNum': hideNamesNum 223 } as Record<string, number | AuthAccount[] | string> 224} 225 226let toggleShow = (allNames: AuthAccount[], showNamesArr: AuthAccount[], editFlag: boolean, rowNamesLen: number) => { 227 if (showNamesArr.length < allNames.length) { 228 let showFlag = !editFlag; 229 let showNamesArr = allNames; 230 return { 231 'showNamesArr': showNamesArr, 232 'showFlag': showFlag 233 } as Record<string, AuthAccount[] | boolean>; 234 } else { 235 let showFlag = !editFlag; 236 let showNamesArr = allNames.length > Constants.ENCRYPTION_DOUBLED_NUMBER * rowNamesLen 237 ? allNames.slice(0, Constants.ENCRYPTION_DOUBLED_NUMBER * rowNamesLen - 1) 238 : allNames.slice(0, Constants.ENCRYPTION_DOUBLED_NUMBER * rowNamesLen); 239 return { 240 'showNamesArr': showNamesArr, 241 'showFlag': showFlag 242 } as Record<string, AuthAccount[] | boolean>; 243 } 244} 245 246function directionStatus(func: Callback<number>) { 247 let innerEvent: emitter.InnerEvent = { 248 eventId: Constants.ENCRYPTION_EMIT_DIRECTION_STATUS 249 }; 250 emitter.on(innerEvent, (eventData: emitter.EventData) => { 251 func(eventData.data?.direction); 252 }); 253} 254 255function getAppId(bundleName: string) { 256 return new Promise<string>(async (resolve, reject) => { 257 let bundleFlags: number = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; 258 let userId = await getUserId(); 259 try { 260 let data = await bundleManager.getBundleInfo(bundleName, bundleFlags, userId); 261 if (data.signatureInfo.appId) { 262 resolve(data.signatureInfo.appId); 263 return; 264 } 265 reject(); 266 } catch (err) { 267 HiLog.error(TAG, `get appId failed: ${JSON.stringify(err)}`); 268 reject(); 269 } 270 }) 271} 272 273function getTime() { 274 let permanent: boolean | undefined = AppStorage.get('permanent'); 275 if (permanent) { 276 return $r('app.string.permanently'); 277 } 278 let dateTime: number | undefined = AppStorage.get('validity'); 279 if (dateTime !== undefined) { 280 let date = new Date(dateTime); 281 let year = date.getFullYear(); 282 let month = date.getMonth() + 1; 283 let day = date.getDate(); 284 let hour = date.getHours(); 285 let minute = date.getMinutes(); 286 return `${year}/${month}/${day} ${hour}:${minute}`; 287 } else { 288 return ''; 289 } 290} 291 292async function getFileSizeByUri(uri: string): Promise<number> { 293 let inFile: fs.File | undefined; 294 try { 295 inFile = await fs.open(uri, fs.OpenMode.READ_ONLY); 296 let stat = await fs.stat(inFile.fd); 297 HiLog.info(TAG, `get file info succeed, the size of file is: ${stat.size}`); 298 return stat.size; 299 } catch (err) { 300 HiLog.error(TAG, `open: ${uri}, failed: ${JSON.stringify(err)}`); 301 HiLog.info(TAG, `get file info failed with error message: ${JSON.stringify(err)}`); 302 return -1; 303 } finally { 304 if (inFile) { 305 fs.closeSync(inFile); 306 } 307 } 308} 309 310function getDLPInfo() { 311 return new Promise<DLPInfo>(async (resolve, reject) => { 312 let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 313 try { 314 bundleManager.getBundleInfoForSelf(bundleFlags, (err, data) => { 315 if (err) { 316 HiLog.error(TAG, `getBundleInfoForSelf failed. Cause: ${JSON.stringify(err)}`); 317 reject({name: '', versionCode: ''}); 318 } else { 319 resolve({name: data.name, versionCode: data.versionCode.toString()}); 320 } 321 }); 322 } catch (err) { 323 HiLog.error(TAG, `getBundleInfoForSelf failed. Cause: ${JSON.stringify(err)}`); 324 reject({name: '', versionCode: ''}); 325 } 326 }) 327} 328 329function sendDlpManagerAccountLogin(errorCode: number) { 330 let event: hiSysEvent.SysEventInfo = { 331 domain: 'DLP_UE', 332 name: 'DLP_MANAGER_ACCOUNT_LOGIN', 333 eventType: hiSysEvent?.EventType?.BEHAVIOR, 334 params: { 335 'PNAMEID': AppStorage.get('hiPNameId') ?? '', 336 'PVERSIONID': AppStorage.get('hiPVersionId') ?? '', 337 'ACCOUNT_TYPE': AppStorage.get('hiAccountType') ?? '', 338 'ACCOUNT_STATUS': AppStorage.get('hiAccountStatus') ?? -1, 339 'LOGIN_FAIL_CODE': errorCode ?? -1, 340 'PKG_NAME': AppStorage.get('hiPkgName') ?? '', 341 } as Record<string, number> 342 }; 343 344 try { 345 hiSysEvent.write(event); 346 } catch (err) { 347 HiLog.error(TAG, `sendDlpManagerAccountLogin failed`); 348 } 349} 350 351function sendDlpManagerFileConfiguration() { 352 let event: hiSysEvent.SysEventInfo = { 353 domain: 'DLP_UE', 354 name: 'DLP_MANAGER_FILE_CONFIGURATION', 355 eventType: hiSysEvent?.EventType?.BEHAVIOR, 356 params: { 357 'PNAMEID': AppStorage.get('hiPNameId') ?? '', 358 'PVERSIONID': AppStorage.get('hiPVersionId') ?? '', 359 'OPERATION': AppStorage.get('hiOperation') ?? '', 360 'READ_SCOPE': AppStorage.get('hiReadScope') ?? '', 361 'WRITE_SCOPE': AppStorage.get('hiWriteScope') ?? '', 362 'ADVANCED_SETTINGS': AppStorage.get('hiAdvancedSettings') ?? false, 363 'STORE_PATH': AppStorage.get('hiStorePath') ?? false, 364 'ACCOUNT_VERIFY_SUCC': AppStorage.get('hiAccountVerifySucc') ?? -1, 365 'ACCOUNT_VERIFY_FAIL': AppStorage.get('hiAccountVerifyFail') ?? -1, 366 'VALID_DATE': AppStorage.get('hiValidDate') ?? false, 367 } as Record<string, number> 368 }; 369 370 try { 371 hiSysEvent.write(event); 372 } catch (err) { 373 HiLog.error(TAG, `sendDlpManagerFileConfiguration failed`); 374 } 375} 376 377function sendDlpFileCreateProperties(accountType: number) { 378 let event: hiSysEvent.SysEventInfo = { 379 domain: 'DLP_UE', 380 name: 'DLP_FILE_CREATE_EVENT', 381 eventType: hiSysEvent?.EventType?.BEHAVIOR, 382 params: { 383 'ACCOUNT_TYPE': accountType, 384 'PNAMEID': AppStorage.get('hiPNameId') ?? '', 385 'PVERSIONID': AppStorage.get('hiPVersionId') ?? '', 386 'CODE': AppStorage.get('hiCode') ?? -1, 387 'FILE_SIZE': AppStorage.get('hiFileSize') ?? -1, 388 'FILE_TYPE': AppStorage.get('hiFileType') ?? '', 389 'POLICY_SIZE_ENC': AppStorage.get('hiPolicySizeEnc') ?? -1, 390 'PKG_NAME': AppStorage.get('hiPkgName') ?? '', 391 } as Record<string, number> 392 }; 393 394 try { 395 hiSysEvent.write(event); 396 } catch (err) { 397 HiLog.error(TAG, `sendDlpFileCreateProperties failed`); 398 } 399} 400 401function sendDlpFileOpenProperties() { 402 let event: hiSysEvent.SysEventInfo = { 403 domain: 'DLP_UE', 404 name: 'DLP_FILE_OPEN_EVENT', 405 eventType: hiSysEvent?.EventType?.BEHAVIOR, 406 params: { 407 'PNAMEID': AppStorage.get('hiPNameId') ?? '', 408 'PVERSIONID': AppStorage.get('hiPVersionId') ?? '', 409 'CODE': AppStorage.get('hiCode') ?? -1, 410 'SANDBOX_PKGNAME': AppStorage.get('hiSandboxPkgName') ?? '', 411 'SANDBOX_INDEX': AppStorage.get('hiSandboxIndex') ?? -1, 412 'ACCOUNT_TYPE': AppStorage.get('hiAccountType') ?? '', 413 'FILE_SIZE': AppStorage.get('hiFileSize') ?? -1, 414 'POLICY_SIZE_ENC': AppStorage.get('hiPolicySizeEnc') ?? -1, 415 } as Record<string, number> 416 }; 417 418 try { 419 hiSysEvent.write(event); 420 } catch (err) { 421 HiLog.error(TAG, `sendDlpFileOpenProperties failed`); 422 } 423} 424 425function isValidPath(path: string): Boolean { 426 if (path.indexOf('/./') !== -1 || path.indexOf('/../') !== -1) { 427 return false; 428 } 429 return true; 430} 431 432function getAccountType( 433 context: common.ServiceExtensionContext | common.UIExtensionContext, fd: number): Promise<number> { 434 return new Promise(async (resolve, reject) => { 435 let z = new ArrayBuffer(HEAD_LENGTH_IN_BYTE); 436 let option: ChangeOption = { offset: 0, length: HEAD_LENGTH_IN_BYTE }; 437 let num = fs.readSync(fd, z, option); 438 let buf = new Uint32Array(z, 0, HEAD_LENGTH_IN_U32); 439 if (buf && buf[0] === Constants.DLP_ZIP_MAGIC) { 440 let random = String(Math.random()).substring(Constants.RAND_START, Constants.RAND_END); 441 let filePath = context.filesDir + '/saveAs' + random; 442 let dirPath = context.filesDir + '/saveAsUnzip' + random; 443 let fileName = dirPath + '/dlp_cert'; 444 let ff: fs.File | undefined; 445 try { 446 fs.readSync(fd, z, option); 447 ff = await fs.open(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); 448 await fs.copyFile(fd, ff.fd); 449 await fs.mkdir(dirPath); 450 await zlib.decompressFile(filePath, dirPath); 451 let dlpInfo = fs.readTextSync(fileName); 452 let infoArray = dlpInfo.split('accountType'); 453 let type = infoArray[1].slice(Constants.TYPE_START, Constants.TYPE_END); 454 GlobalContext.store('accountType', Number(type)); 455 resolve(Number(type)); 456 } catch (err) { 457 HiLog.error(TAG, `decompressFile: ${JSON.stringify(err)}`); 458 reject(); 459 } finally { 460 closeFile(ff); 461 deleteFile(filePath); 462 removeDir(dirPath); 463 } 464 } else { 465 let cert = new ArrayBuffer(buf[CERT_SIZE]); 466 option = { offset: buf[CERT_OFFSET], length: buf[CERT_SIZE] }; 467 num = fs.readSync(fd, cert, option); 468 try { 469 let textDecoder: util.TextDecoder = util.TextDecoder.create('utf-8'); 470 let fdString: string = textDecoder.decodeWithStream(new Uint8Array(cert), { stream: false }); 471 let infoArray = fdString.split('accountType'); 472 let type = infoArray[1].slice(Constants.TYPE_START, Constants.TYPE_END); 473 GlobalContext.store('accountType', Number(type)); 474 resolve(Number(type)); 475 } catch (err) { 476 HiLog.error(TAG, `getStringFromFd error: ${JSON.stringify(err)}`); 477 reject(); 478 } 479 } 480 }) 481} 482 483function closeFile(file: fs.File | undefined) { 484 try { 485 if (file) { 486 fs.closeSync(file); 487 } 488 } catch (err) { 489 HiLog.error(TAG, `closeSync: ${JSON.stringify(err)}`); 490 } 491} 492 493function deleteFile(file: string) { 494 try { 495 let res = fs.accessSync(file); 496 if (res) { 497 fs.unlinkSync(file); 498 } 499 } catch (err) { 500 HiLog.error(TAG, `deleteFile: ${JSON.stringify(err)}`); 501 } 502} 503 504function removeDir(file: string) { 505 try { 506 let res = fs.accessSync(file); 507 if (res) { 508 fs.rmdirSync(file); 509 } 510 } catch (err) { 511 HiLog.error(TAG, `rmdirSync: ${JSON.stringify(err)}`); 512 } 513} 514 515function getCurrentTime(isNano: boolean = false): number { 516 return systemDateTime.getTime(isNano); 517} 518 519function isExpire(timestamp: number, diff: number, unit: number): boolean { 520 if (isNaN(timestamp) || diff <= 0) { 521 return true; 522 } 523 let multipleMill = UNIT_MAP.get(unit); 524 if (!multipleMill) { 525 HiLog.error(TAG, 'Invalid unit'); 526 return false; 527 } 528 529 let currentTime = getCurrentTime(); 530 const diffMilliSecond = Number(currentTime) - Number(timestamp); 531 const compareDiffSec = diff * multipleMill; 532 return diffMilliSecond > compareDiffSec; 533} 534 535async function sleep(milliSeconds: number): Promise<void> { 536 return new Promise<void>(resolve => setTimeout(resolve, milliSeconds)); 537} 538 539async function getConnectionStatus(exactly: boolean = true): Promise<boolean> { 540 HiLog.info(TAG, `Enter getConnectionStatus, exactly mode: ${exactly}}`); 541 try { 542 const startTime = getCurrentTime(); 543 let net: connection.NetHandle = await connection.getDefaultNet(); 544 let capabilities: connection.NetCapabilities = await connection.getNetCapabilities(net); 545 HiLog.info(TAG, `Succeeded to get net capabilities, ${JSON.stringify(capabilities)}`); 546 let networkCap = capabilities.networkCap; 547 while (exactly && networkCap?.includes(NET_CAPABILITY_CHECKING_CONNECTIVITY)) { 548 HiLog.info(TAG, `Checking connectivity...`); 549 if (isExpire(startTime, TIME_OUT_SECONDS, UnitType.SECOND_UNIT)) { 550 HiLog.error(TAG, `Network connection check failed.`); 551 return false; 552 } 553 await sleep(SLEEP_MILLISECONDS); 554 net = await connection.getDefaultNet(); 555 capabilities = await connection.getNetCapabilities(net); 556 networkCap = capabilities.networkCap; 557 } 558 559 let internetExists = networkCap?.includes(NET_CAPABILITY_INTERNET); 560 let validatedExists = networkCap?.includes(NET_CAPABILITY_VALIDATED); 561 if (internetExists && validatedExists) { 562 HiLog.debug(TAG, 'Net connection is valid.'); 563 return true; 564 } else { 565 HiLog.error(TAG, 'Net connection is invalid.'); 566 } 567 } catch (error) { 568 HiLog.error(TAG, `GetConnectionStatus failed: ${JSON.stringify(error)}`); 569 } 570 return false; 571} 572 573function checkNetworkStatus(): Promise<void> { 574 return new Promise((resolve, reject) => { 575 let netHandle = connection.getDefaultNetSync(); 576 connection.getNetCapabilities(netHandle, (error: BusinessError, data: connection.NetCapabilities) => { 577 if (error) { 578 HiLog.error(TAG, `checkNetworkStatus failed: ${JSON.stringify(error)}`); 579 reject(); 580 return; 581 }; 582 HiLog.info(TAG, `network Succeeded to get data: ${JSON.stringify(data)}`); 583 const result = [connection.NetCap.NET_CAPABILITY_INTERNET, connection.NetCap.NET_CAPABILITY_VALIDATED] 584 .every(element => data.networkCap?.includes(element)); 585 if (result) { 586 resolve(); 587 return; 588 } 589 reject(); 590 }) 591 }) 592} 593 594export { 595 AuthAccount, 596 PermissionType, 597 getOsAccountInfo, 598 checkDomainAccountInfo, 599 getUserId, 600 getAuthPerm, 601 terminateSelfWithResult, 602 judgeIsSandBox, 603 getFileFd, 604 getFileUriByPath, 605 removeDuplicate, 606 calculate, 607 toggleShow, 608 directionStatus, 609 getAppId, 610 getTime, 611 getFileSizeByUri, 612 getDLPInfo, 613 sendDlpManagerAccountLogin, 614 sendDlpManagerFileConfiguration, 615 sendDlpFileCreateProperties, 616 sendDlpFileOpenProperties, 617 DLPInfo, 618 isValidPath, 619 defaultDlpFile, 620 getAccountType, 621 checkNetworkStatus, 622 getConnectionStatus 623}; 624