Giter Club home page Giter Club logo

app-info-parser's Introduction

app-info-parser

app-info-parser is a parser for parsing .ipa or .apk files. It will return the information with json from AndroidManifest.xml or Info.plist.

Support

  • Node ✅

  • Browser

    Chrome Firefox Safari Opera IE
    latest ✅ latest ✅ latest ✅ latest ✅
  • npx

Installation

npm install app-info-parser
# or yarn
yarn add app-info-parser

Getting started

NPX Use

You can use app-info-parser by npx, if you don't want to install it. Run this command in your terminal:

npx app-info-parser -f <file-path> -o <output-path>
argument type description
-f string The path of file that you want to parse.
-o string The output path that you want to save the parse result. Default is "./result.json"

NPM Use

const AppInfoParser = require('app-info-parser')
const parser = new AppInfoParser('../packages/test.apk') // or xxx.ipa
parser.parse().then(result => {
  console.log('app info ----> ', result)
  console.log('icon base64 ----> ', result.icon)
}).catch(err => {
  console.log('err ----> ', err)
})

CDN Use

<input type="file" name="file" id="file" onchange="fileSelect()">
<script src="//unpkg.com/browse/app-info-parser/dist/app-info-parser.min.js"></script>
<script>
function fileSelect () {
  const files = document.getElementById('file').files
  const parser = new window.AppInfoParser(files[0])
  parser.parse().then(result => {
    console.log('app info ----> ', result)
    console.log('icon base64 ----> ', result.icon)
  }).catch(err => {
    console.log('err ----> ', err)
  })
}
</script>

Demand loading

You can use demand loading, when you only need one parser.

ApkParser

const ApkParser = require('app-info-parser/src/apk')
const parser = new ApkParser('../packages/test.apk')
parser.parse().then(result => {
  console.log('app info ----> ', result)
  console.log('icon base64 ----> ', result.icon)
}).catch(err => {
  console.log('err ----> ', err)
})

IpaParser

const IpaParser = require('app-info-parser/src/ipa')
const parser = new IpaParser('../packages/test.ipa')
parser.parse().then(result => {
  console.log('app info ----> ', result)
  console.log('icon base64 ----> ', result.icon)
}).catch(err => {
  console.log('err ----> ', err)
})

API Referrer

AppInfoParser | ApkParser | IpaParser

  • constructor(file)
    • file Blob or File in browser, Path in Node
  • parse: () => Promise<Object> A function return a promise, which resolving the parse result

Buy Me A Coffee

Open source is not easy, you can buy me a coffee. Note your name or github id so I can add you to the donation list.

Wechat Pay

Ali Pay

Donation List

❤️ Thanks these guys for donations. Contact me with email, if you had donated but not on the list.

Donors Amount Time
*明 ¥100 2023-03-29 10:16
*明 ¥100 2021-06-17 17:29
=*= ¥6.66 2021-05-24 15:12
*学 ¥6.66 2021-01-08 15:32
y*n ¥6.66 2020-08-26 12:10
*明 ¥100 2020-08-25 11:35
*肖 ¥6.66 2020-07-31 19:54
O*s ¥1 2020-05-26 16:01
**豪 ¥6.66 2020-03-05 20:14
*大 ¥6.66 2020-02-25 16:55
*风 ¥1 2020-01-03 15:36
黄灰红 ¥1 2019-12-10 17:53
zona.zhou ¥1 2019-10-20 23:18
*。 ¥66 2019-10-20 22:45

License

MIT

Resources

FAQ

Build/Parse error with vite?

See this issue of vite, vite is not going support node global builtins and node specific api's on the client. Some of app-info-parser's deps didn't support browser env, most of them without maintain, so it can't be resolved.

Just use app-info-parser by CDN using(import by script element), don't use it with module import in vite.

app-info-parser's People

Contributors

chenquincy avatar cliqiang avatar imquincychen avatar michalskr avatar pecasha avatar sunnylqm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

app-info-parser's Issues

Module not found: Error: Can't resolve 'fs'

Describe the bug
react项目 客户端引入报错
ERROR in ./node_modules/bplist-parser/bplistParser.js
Module not found: Error: Can't resolve 'fs'

解决办法
package.json中入口文件找不到
image

修改之后解决问题,还请修复以下这个问题哦
"browser": "./dist/app-info-parser.js",

请发布dist目录到npm并更新browser配置

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. ...
  2. ...

Expected behavior
A clear and concise description of what you expected to happen.

Node or Browser version (please complete the following information):

  • Browser [e.g. chrome72.0.3626.121]
  • Node [e.g. v8.9.4]

Package links for testing(downloadable links of the package, which making this issue)

描述 bug
请简明扼要的描述你所遇到的bug

复现
请描述复现该bug的步骤:

  1. ...
  2. ...

预期表现
请简明扼要的描述你所期望得到的效果

请填写您的Node或浏览器版本:

  • Browser [如:chrome72.0.3626.121]
  • Node [如:v8.9.4]

请提供测试用的安装包下载链接:

parseBplist is not a function

err ----> TypeError: parseBplist is not a function
at IpaParser._parsePlist (ipa.js?228c:108)
at eval (ipa.js?228c:73)

打开源码发现这个函数有问题。。。

image

image

解析APK图标时得到一个XML。附带一个临时解决方案

测试APK:知乎 v5.8.1

下载APK:https://github.com/LEORChn/ContentDelivery/releases/download/temp/zhihu_5.8.1.apk
(如果没有特殊需要,在一段时间后会清除。)

浏览器:Chrome 43

new AppInfoParser(file).parse().then(function(e){
  console.log(e.icon);
  // 预期表现:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimH...
  // 实际表现:data:image/png;base64,AwAIAMgAAAABABwAZAAAAAMAAAAAAAAAAAEAACgAAA...
});

临时解决方案 in dist/app-info-parser.js

code with lines tag

// is it png?
if((apkInfo.icon || '').contains(';base64,iVBORw0K')){
  // yes it is png
  resolve(apkInfo);
}else{
  // no it is not png but maybe xml
  var xml = new BinaryXmlParser(iconBuffer).parse();
  if(xml.nodeName == 'bitmap'){
    // xml.attributes[0].typedValue.value = 'resourceId:0x7f0d0002'
    var iconRef = xml.attributes[0].typedValue.value.split(':')[1].toUpperCase().replace('0X', '@');
    _this2.getEntry(resourceMap[iconRef][0]).then(function (iconBuffer) {
      apkInfo.icon = getBase64FromBuffer(iconBuffer);
      resolve(apkInfo);
    });
  }else{
    // exception... but when? i dont know.
    resolve(apkInfo);
  }
}

The new version doesn't work

I have installed the new version and tring to use it on a browser (Chrome) and I see this error in the console:

Uncaught ReferenceError: regeneratorRuntime is not defined

Browser version (74.0.3729.131):

  • Browser [chrome latest on windows]

额外的日志输出

执行 parser.parse()时,输出字符串 what,位于安装包的 src/ipa.js:74,版本 0.3.8

希望能去掉,多出来的字符串会影响shell的eval处理

versionName 出现乱码,但aapt解压是正常

Describe the bug
解析部分 apk 的versionName 乱码 (VersionName of the parsing part of the APK is messy code)

image

但是我用 aapt dump badging 命令解析是正常的 (But I use the aapt dump badging command, it works fine)

image

我尝试 debug 源码,可能是binary.js的问题?(I had try to debug the source, maybe a problem with binary.js?)

Expected behavior
Work expected.

请填写您的Node或浏览器版本:

  • chrome
  • Node 14.5

请提供测试用的安装包下载链接:

获取解析后信息里面的文件名为数组

获取解析后信息里面的文件名为数组,现在查出来是['apple','苹果','xxx']无法知道哪个语言是如何对应的,能否区分对应一下语言,得到{‘zh_CN’:'苹果','en_US':'apple'}

Parser resources.arsc error: RangeError: Illegal offset: 0 <= 50372 (+2) <= 50372

直接使用文件路径解析报错

const AppInfoParser = require("app-info-parser"); const parser = new AppInfoParser("./packages/dbb.apk"); // or xxx.ipa parser .parse() .then(result => { console.log("app info ----> ", result); console.log("icon base64 ----> ", result.icon); }) .catch(err => { console.log("err ----> ", err); });

报错信息:
main.vue?5faf:137 Uncaught Error: Param error: [file] must be an instance of Blob or File in browser.

我用其他apk解析插件同样的路径是可以解析的,是我的写法有问题么

AXML uint8 array 第一个为 0 导致解析失败

描述 bug
解析某些 apk 时发生错误,"Error: Parse AndroidManifest.xml error"

复现
工作原因无法提供 apk

预期表现
解析成功,拿到包名和应用名

请填写您的Node或浏览器版本:

  • [chrome 91.0.4472.114]

原因:
出错的包的 AXML 读取的 buffer 中的 chunkType 是 0,导致 chunkType 的校验未通过。
但是使用后端的反编译工具可以解析(用的应该就是 apktool)

v0.3.0

app-info-parser/src/index.js:1:478)
ReferenceError: window is not defined

我们在使用的过程中,发现ipa的包里面的icon各种情况都有

所以我加了一个东西,取出所有的ICON,然后比较大小,找到一个最大的ICON图片

function findIpaInfoIcons (info) {
  var icons = [];
  if (info.CFBundleIconFile) {
	  console.log(info.CFBundleIconFile)
	  icons = icons.concat(info.CFBundleIconFile);
  } 

  if (
    info.CFBundleIcons &&
    info.CFBundleIcons.CFBundlePrimaryIcon &&
    info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles &&
    info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles.length
  ) {
    icons = icons.concat(info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles);
  } 

  if (info.CFBundleIconFiles && info.CFBundleIconFiles.length) {
    icons = icons.concat(info.CFBundleIconFiles);
  }

  if (icons.length < 1)
  {
	  if (
		  info['CFBundleIcons~ipad'] && 
		  info['CFBundleIcons~ipad'].CFBundlePrimaryIcon && 
		  info['CFBundleIcons~ipad'].CFBundlePrimaryIcon.CFBundleIconFiles && 
		  info['CFBundleIcons~ipad'].CFBundlePrimaryIcon.CFBundleIconFiles.length
	   )  {
	      icons = icons.concat(info['CFBundleIcons~ipad'].CFBundlePrimaryIcon.CFBundleIconFiles);
	   }
  }

  if (icons.length < 1)
  {
	  icons = icons.concat('.app/Icon.png');
  }

  return icons;

}

vue-cli3 打包部署后报错

描述 bug
vue-cli3 打包部署到服务器后报错 s.inherits is not a function

复现
请描述复现该bug的步骤:

  1. vue-cli3 打包命令 vue-cli-service build --mode test
    将包部署到服务器后, 访问该页面报错 s.inherits is not a function

请填写您的Node或浏览器版本:

  • Browser 版本 90.0.4430.85(正式版本) (64 位)
  • Node v12.13.1

import 引入报错

错误信息如下:
ERROR in ./node_modules/bplist-parser/bplistParser.js
Module not found: Error: Can't resolve 'fs' in 'E:\dev\youdu_back_end\node_modules\bplist-parser'
ERROR in ./node_modules/app-info-parser/src/zip.js
Module not found: Error: Can't resolve 'path' in 'E:\dev\youdu_back_end\node_modules\app-info-parser\src'
ERROR in ./node_modules/streamifier/lib/index.js
Module not found: Error: Can't resolve 'stream' in 'E:\dev\youdu_back_end\node_modules\streamifier\lib'
ERROR in ./node_modules/cgbi-to-png/index.js
Module not found: Error: Can't resolve 'zlib' in 'E:\dev\youdu_back_end\node_modules\cgbi-to-png'

image

解析ipa文件报错

TypeError: parseBplist is not a function
at IpaParser._parsePlist (ipa.js:105)
at ipa.js:70

1. 通过npm引入

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. ...
  2. ...

Expected behavior
A clear and concise description of what you expected to happen.

Node or Browser version (please complete the following information):

  • Browser [e.g. chrome72.0.3626.121]
  • Node [e.g. v8.9.4]

Package links for testing(downloadable links of the package, which making this issue)

描述 bug
请简明扼要的描述你所遇到的bug

复现
请描述复现该bug的步骤:

  1. ...
  2. ...

预期表现
请简明扼要的描述你所期望得到的效果

请填写您的Node或浏览器版本:

  • Browser [如:chrome72.0.3626.121]
  • Node [如:v8.9.4]

请提供测试用的安装包下载链接:

安装包icon文件名为unicode编码时报错: Cannot read property 'toString' of undefined

描述 bug
安装包icon文件名为unicode编码时解析安装包不成功,报错信息:

err ---->  TypeError: Cannot read property 'toString' of undefined
    at getBase64FromBuffer (/Users/quincy.chen/workspace/app-info-parser/lib/utils.js:143:44)
    at ApkParser.parse (/Users/quincy.chen/workspace/app-info-parser/lib/apk.js:30:22)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

复现
请描述复现该bug的步骤:
解析文件名为unicode编码的安装包

预期表现
正常解析

请提供测试用的安装包下载链接:

部分IPA文件无法正常解析图标

描述 bug
请简明扼要的描述你所遇到的bug
部分IPA文件无法正常解析图标

复现
请描述复现该bug的步骤:

  1. 安装包图标也正常, 但是无法解析出应用包内图标
  2. 测试在解析ipa文件时出现

预期表现
请简明扼要的描述你所期望得到的效果

请填写您的Node或浏览器版本:
Google Chrome 已是最新版本
版本 80.0.3987.132(正式版本) (64 位)

请提供测试用的安装包下载链接:
测试安装包地址 https://gf-lyres.oss-cn-beijing.aliyuncs.com/test_tubiao.ipa

IPA 包 解析失败

用 你提供的地址,上传一个包,提示 解析出错:Error: inflating: invalid stored block lengths

no such file or directory

AppInfoParser 的构造方法中这样写不合理吧。。
this.file = fs.readFileSync(path.join(__dirname, filename));
/Users/xxxxx/demo/static/aaa.apk 传进去,就成这了
/Users/xxxxx/demo/node_modules/app-info-parser/src/Users/xxxxx/demo/static/aaa.apk

apk解析没有取到应用名 label为null

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. ...
  2. ...

Expected behavior
A clear and concise description of what you expected to happen.

Node or Browser version (please complete the following information):

  • Browser [e.g. chrome72.0.3626.121]
  • Node [e.g. v8.9.4]

Package links for testing(downloadable links of the package, which making this issue)

描述 bug
请简明扼要的描述你所遇到的bug

复现
请描述复现该bug的步骤:

  1. ...
  2. ...

预期表现
请简明扼要的描述你所期望得到的效果

请填写您的Node或浏览器版本:

  • Browser [如:chrome72.0.3626.121]
  • Node [如:v8.9.4]

请提供测试用的安装包下载链接:

Cannot find module 'commander'

Describe the bug
Cannot find module 'commander'

To Reproduce
Steps to reproduce the behavior:

  1. npx app-info-parser -f some-app.apk
  2. or npm i -g app-info-parser && app-info-parser -f some-app.apk

Expected behavior
Work expected.

C:\Users\Liu.D.H\Documents\WeChat Files\iman405904\FileStorage\File\2021-06>npx app-info-parser -f com.cdvcloud.qicaiyun_305.apk
npm notice
npm notice New minor version of npm available! 7.10.0 -> 7.16.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.16.0
npm notice Run npm install -g [email protected] to update!
npm notice
Need to install the following packages:
  app-info-parser
Ok to proceed? (y)
node:internal/modules/cjs/loader:943
  throw err;
  ^

Error: Cannot find module 'commander'
Require stack:
- C:\Users\Liu.D.H\AppData\Local\npm-cache\_npx\5d235a1832a4f7be\node_modules\app-info-parser\bin\index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at Function.Module._load (node:internal/modules/cjs/loader:773:27)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (C:\Users\Liu.D.H\AppData\Local\npm-cache\_npx\5d235a1832a4f7be\node_modules\app-info-parser\bin\index.js:3:21)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Function.Module._load (node:internal/modules/cjs/loader:828:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Liu.D.H\\AppData\\Local\\npm-cache\\_npx\\5d235a1832a4f7be\\node_modules\\app-info-parser\\bin\\index.js'
  ]
}

C:\Users\Liu.D.H\Documents\WeChat Files\iman405904\FileStorage\File\2021-06>npm install app-info-parser -g

added 22 packages, and audited 23 packages in 6s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

C:\Users\Liu.D.H\Documents\WeChat Files\iman405904\FileStorage\File\2021-06> app-info-parser -f com.cdvcloud.qicaiyun_305.apk
node:internal/modules/cjs/loader:943
  throw err;
  ^

Error: Cannot find module 'commander'
Require stack:
- C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\app-info-parser\bin\index.js
�[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:940:15)�[39m
�[90m    at Function.Module._load (node:internal/modules/cjs/loader:773:27)�[39m
�[90m    at Module.require (node:internal/modules/cjs/loader:1012:19)�[39m
�[90m    at require (node:internal/modules/cjs/helpers:93:18)�[39m
    at Object.<anonymous> (C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\�[4mapp-info-parser�[24m\bin\index.js:3:21)
�[90m    at Module._compile (node:internal/modules/cjs/loader:1108:14)�[39m
�[90m    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)�[39m
�[90m    at Module.load (node:internal/modules/cjs/loader:988:32)�[39m
�[90m    at Function.Module._load (node:internal/modules/cjs/loader:828:14)�[39m
�[90m    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)�[39m {
  code: �[32m'MODULE_NOT_FOUND'�[39m,
  requireStack: [
    �[32m'C:\\Users\\Liu.D.H\\AppData\\Roaming\\npm\\node_modules\\app-info-parser\\bin\\index.js'�[39m
  ]
}

C:\Users\Liu.D.H\Documents\WeChat Files\iman405904\FileStorage\File\2021-06>

I found 'commander' dependence is a dev dependence, maybe this is the problem.

解析其他文件格式(比如txt)转换为apk文件,代码报错,但没反映在catch中

最近项目需要做 apk 上传,前端解析相关信息显示 (包名,图标,版本)。为了尽可能的保证功能正常,按照以往的惯例上传了一个由 txt 文件改后缀为 apk 的文件,结果 js 代码报错了。报错信息如下:

image

建议把这个错误信息放到 catch 中。

此外,在获取 app 名称时,result.application.label 的值有的是数组,有的是字符串,不统一,期望能统一。

希望上面的问题能得到修复。

vue项目中通过npm引入报错

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. ...
  2. ...

Expected behavior
A clear and concise description of what you expected to happen.

Node or Browser version (please complete the following information):

  • Browser [e.g. chrome72.0.3626.121]
  • Node [e.g. v8.9.4]

Package links for testing(downloadable links of the package, which making this issue)

描述 bug
请简明扼要的描述你所遇到的bug

复现
请描述复现该bug的步骤:

  1. 通过npm引入
import AppInfoParser from 'app-info-parser'
 const parser = new AppInfoParser('https://res.12317wan.com/mailiang/cyad/cyqlb_981.apk')
        parser
            .parse()
            .then(result => {
                console.log('app info ----> ', result)
            })
            .catch(err => {
                console.log('err ----> ', err)
            })Ï

报错

vue.esm.js:628 [Vue warn]: Error in created hook: "Error: Param error: [file] must be an instance of Blob or File in browser."

通过链接是可以正常解析的
预期表现
预期可以解析apk包

请填写您的Node或浏览器版本:

  • Browser [如:chrome81.0.4044.138(正式版本]
  • Node [如:v10.15.3]

请提供测试用的安装包下载链接:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.