@capgo/cli 1.6.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,20 +4,32 @@ on:
4
4
  push:
5
5
  branches:
6
6
  - main
7
+ - development
7
8
 
8
9
  jobs:
9
10
  bump-version:
10
- if: "!startsWith(github.event.head_commit.message, 'bump:')"
11
+ if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
11
12
  runs-on: ubuntu-latest
12
- name: "Bump version and create changelog with commitizen"
13
+ name: "Bump version and create changelog with standard version"
13
14
  steps:
14
15
  - name: Check out
15
16
  uses: actions/checkout@v3
16
17
  with:
17
18
  fetch-depth: 0
18
- token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
19
- - name: Create bump and changelog
20
- uses: commitizen-tools/commitizen-action@0.15.1
21
- with:
22
- github_token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
23
- branch: 'main'
19
+ token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
20
+ - name: Git config
21
+ run: |
22
+ git config --local user.name "github-actions[bot]"
23
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
24
+ - name: Create bump and changelog main
25
+ if: github.ref == 'refs/heads/main'
26
+ run: npx standard-version
27
+ - name: Create bump and changelog development
28
+ if: github.ref != 'refs/heads/main'
29
+ run: npx standard-version --prerelease alpha
30
+ - name: Push to origin
31
+ run: |
32
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
33
+ remote_repo="https://${GITHUB_ACTOR}:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
34
+ git pull $remote_repo $CURRENT_BRANCH
35
+ git push $remote_repo HEAD:$CURRENT_BRANCH --follow-tags --tags
package/CHANGELOG.md CHANGED
@@ -1,3 +1,175 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [2.0.1](https://github.com/Cap-go/capgo-cli/compare/v2.0.0...v2.0.1) (2022-11-24)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * encode use AES to encode the file ([8f6524e](https://github.com/Cap-go/capgo-cli/commit/8f6524e05708f6cbf708a5c11c59f7aefac66823))
11
+
12
+ ## 2.0.0 (2022-11-24)
13
+
14
+
15
+ ### ⚠ BREAKING CHANGES
16
+
17
+ * rename version in bundle to remove arg conflict
18
+
19
+ ### Features
20
+
21
+ * add --version ([66a8601](https://github.com/Cap-go/capgo-cli/commit/66a86017cb43be03845682029cec7013aa5b01bf))
22
+ * add add feature ([322e340](https://github.com/Cap-go/capgo-cli/commit/322e34069ff5af9d6b61a9928888656b27de121a))
23
+ * add all channel option in set method ([20eac06](https://github.com/Cap-go/capgo-cli/commit/20eac0697cc6afd0cf922a123eeb249c95d7ad3e))
24
+ * add channel system ([f11b86a](https://github.com/Cap-go/capgo-cli/commit/f11b86a35489cdb9f345d1dff282c7f470f8dfcf))
25
+ * add checksum upload ([e266f01](https://github.com/Cap-go/capgo-cli/commit/e266f0169a64fbe8e66a4d95dbfadb5171ccc0ea))
26
+ * add delete app method ([d7d211c](https://github.com/Cap-go/capgo-cli/commit/d7d211c568409690e4dba37b36df7c0f377b32f2))
27
+ * add encrypted bool to app_version ([db424a0](https://github.com/Cap-go/capgo-cli/commit/db424a005c5af87b3176f93ec00ec2a623e3a126))
28
+ * Add force option to cleanup command [#26](https://github.com/Cap-go/capgo-cli/issues/26) ([6a011d1](https://github.com/Cap-go/capgo-cli/commit/6a011d181e7cb87cb2d7aa64bf060c455c1e7802))
29
+ * add front lock if not paying ([224c879](https://github.com/Cap-go/capgo-cli/commit/224c8792d6c6b24494d476c3eb37244038712f4d))
30
+ * add hard limit of big app, max 30mb ([146fde8](https://github.com/Cap-go/capgo-cli/commit/146fde86809fe9305126b9b12c51cdd584f9eb22))
31
+ * add is_trial alert ([e7264f9](https://github.com/Cap-go/capgo-cli/commit/e7264f9141e386822df5b479b06ecf16b05f5081))
32
+ * add key gen method and decode ([6d3f9c4](https://github.com/Cap-go/capgo-cli/commit/6d3f9c47fa6d42f4ff725dc306ff6654a0424256))
33
+ * add latest option to restore the old behavior ([55c03bc](https://github.com/Cap-go/capgo-cli/commit/55c03bc46f25bf50d0d450d8ebecac740fa322c3))
34
+ * add login system ([ace1ec5](https://github.com/Cap-go/capgo-cli/commit/ace1ec5fb92867da2154f2c1c2eaba880cf2bd01))
35
+ * add logsnag ([c467070](https://github.com/Cap-go/capgo-cli/commit/c46707078c43f8a6f08812ef4eb686729cfc8088))
36
+ * allow decode from base64 privateKey ([4b79567](https://github.com/Cap-go/capgo-cli/commit/4b795670f4521797064456a030dbe0e75f4a6343))
37
+ * allow external url for upload ([03041a3](https://github.com/Cap-go/capgo-cli/commit/03041a3df460b075437a998baaf7d760d6a0cecc))
38
+ * allow format switch ([ccb9c67](https://github.com/Cap-go/capgo-cli/commit/ccb9c67a8274ce71c62915dbeec7c00640477092))
39
+ * allow set chanel state ([bdc67e8](https://github.com/Cap-go/capgo-cli/commit/bdc67e8ef347d98641b5fe165efb4947ba263568))
40
+ * convert to supabase edge functions ([9d59ed1](https://github.com/Cap-go/capgo-cli/commit/9d59ed1fee9dbf9cd3837aef76b4a30b537823f5))
41
+ * make upload work ([5d4950b](https://github.com/Cap-go/capgo-cli/commit/5d4950b4363d7944bb8d60e6926931b4d9fedb0c))
42
+ * remove upload limit ([0c80652](https://github.com/Cap-go/capgo-cli/commit/0c8065209978dbdf68fcee7c0518459a7a78467e))
43
+ * rename version in bundle to remove arg conflict ([1a7d477](https://github.com/Cap-go/capgo-cli/commit/1a7d47736a2497a27422c4ac99e6499eab5c5361))
44
+ * update package and allow delete only one version ([8c0ad83](https://github.com/Cap-go/capgo-cli/commit/8c0ad83e59f0f9381b257fbffca2317ca6c7cf67))
45
+ * use supbase function instead of netlify to handle timeout ([14a19de](https://github.com/Cap-go/capgo-cli/commit/14a19def0a525c07978daed002c3018a4981df8a))
46
+
47
+
48
+ ### Bug Fixes
49
+
50
+ * add back limit in upload ([06619dd](https://github.com/Cap-go/capgo-cli/commit/06619dd1f857b86669fcff30efd7fbdd2116be63))
51
+ * add check if version exist ([a78baef](https://github.com/Cap-go/capgo-cli/commit/a78baef12398b6da43b8a963dae6c511c1c8a0f8))
52
+ * add default path for icon ([e8b74ea](https://github.com/Cap-go/capgo-cli/commit/e8b74ea74e63b9ef00c2028727a891e49cacd79b))
53
+ * add method ([1ad83f9](https://github.com/Cap-go/capgo-cli/commit/1ad83f9fab95165c60cfd5c4ad838f273587f9e2))
54
+ * addcheck exist_app_versions in upload ([5185336](https://github.com/Cap-go/capgo-cli/commit/51853366bc8f6c1bda0b05cf3d973c664262e552))
55
+ * better clean privatekey ([18ba3b9](https://github.com/Cap-go/capgo-cli/commit/18ba3b9397d3020ca052bc04fb9d783d68705630))
56
+ * better error throw ([f7c3e67](https://github.com/Cap-go/capgo-cli/commit/f7c3e67cc17a0d30714bd46338c6fdb5a3346d50))
57
+ * better loggin ([43a5883](https://github.com/Cap-go/capgo-cli/commit/43a5883d6d9d400ca96dd5c0526b127492a617ca))
58
+ * better logs for set ([831f1ec](https://github.com/Cap-go/capgo-cli/commit/831f1ec03ac6d7f2c9c035e1c3166bff933da578))
59
+ * build and add auto retry ([2189b2e](https://github.com/Cap-go/capgo-cli/commit/2189b2eddb68bc23279805ff817dc8975a287284))
60
+ * build issue + update deps ([8dc45fc](https://github.com/Cap-go/capgo-cli/commit/8dc45fc542f135ea26612c51bc2a5b079b34866b))
61
+ * bundle option ([ec6a6c2](https://github.com/Cap-go/capgo-cli/commit/ec6a6c264d9ae9cd424a4f73a97c90983d7f1924))
62
+ * check if version exist ([13750ab](https://github.com/Cap-go/capgo-cli/commit/13750ab63a19cfe18fca2ee176f8e9dd8b75d62a))
63
+ * CLI command descriptions ([5b1cecb](https://github.com/Cap-go/capgo-cli/commit/5b1cecbb9874ef3cb3636dcaec7ab3e2cbd04845))
64
+ * CLI log ([84af3e9](https://github.com/Cap-go/capgo-cli/commit/84af3e90a1068c4437f6dbf14c075ccd253dd498))
65
+ * CLI messages ([ba4d705](https://github.com/Cap-go/capgo-cli/commit/ba4d7050c326f4598988fc389e0fc2480d14c0d9))
66
+ * cli throw error when upload fail ([a132e35](https://github.com/Cap-go/capgo-cli/commit/a132e3547dc1088d39484784e3914db5c6924bf0))
67
+ * code norm + add keep option ([211b98a](https://github.com/Cap-go/capgo-cli/commit/211b98a3220cbc8b979b584a3f72e2dd99ca3683))
68
+ * delete logs ([709ef29](https://github.com/Cap-go/capgo-cli/commit/709ef29518893f6e952c192cd54eb0ea47a62447))
69
+ * delete message ([40e5c41](https://github.com/Cap-go/capgo-cli/commit/40e5c418aeeed7750fd421822dc0c678c2773e52))
70
+ * delete wrong log ([1f6c6e1](https://github.com/Cap-go/capgo-cli/commit/1f6c6e1c1a590b09db945d1636168205b4ac9ca9))
71
+ * dep issue ([098fdb6](https://github.com/Cap-go/capgo-cli/commit/098fdb65d4b982f1d0b0c08b6b9342c2db2fd2a7))
72
+ * dep issue ([9b71530](https://github.com/Cap-go/capgo-cli/commit/9b715303fad617e22e50a854329449d2d9b9455f))
73
+ * deploy new version builded ([82a0d9a](https://github.com/Cap-go/capgo-cli/commit/82a0d9a6517e0a53864683edf8696938751f5458))
74
+ * deploy to npm ([d1ca9a0](https://github.com/Cap-go/capgo-cli/commit/d1ca9a011e4fa879c6ef3434f5cef8510702ce06))
75
+ * description ([bcc7a49](https://github.com/Cap-go/capgo-cli/commit/bcc7a492d352eb60938e74318d9d36176afb0995))
76
+ * disable upload non semver ([520c560](https://github.com/Cap-go/capgo-cli/commit/520c56010d40aad90aab7bb295c57b9cc8f6b2bb))
77
+ * doc + require option ([5c1e56c](https://github.com/Cap-go/capgo-cli/commit/5c1e56cfd7f94bea9e5c6f719f848ad3ba64000d))
78
+ * doc of cli ([46604aa](https://github.com/Cap-go/capgo-cli/commit/46604aad34b6d9fea83f9a80870208d1abe60f6c))
79
+ * ensure bundle option recognized ([0c5e883](https://github.com/Cap-go/capgo-cli/commit/0c5e883adf19d5329fec5eb4058fb14b47da95eb))
80
+ * error formating + better import ([7932504](https://github.com/Cap-go/capgo-cli/commit/79325040f9a17c57615605ff98b7c4dffbce3376))
81
+ * error mb limit ([884d65b](https://github.com/Cap-go/capgo-cli/commit/884d65babf7485dac5ad1d63ca8a1abf3e3ecb77))
82
+ * error message ([936e8d2](https://github.com/Cap-go/capgo-cli/commit/936e8d28875c8f0273d083388458298b9d4b1586))
83
+ * error message system ([adffd04](https://github.com/Cap-go/capgo-cli/commit/adffd0425af339fb413175853bf6c1469827af54))
84
+ * external typo ([205ea01](https://github.com/Cap-go/capgo-cli/commit/205ea015207dc5424c69a0277f79af2f41bdf6e4))
85
+ * for delete allow only all ([91c726c](https://github.com/Cap-go/capgo-cli/commit/91c726c4d02a39e21773976aab5ed646de6db9ed))
86
+ * format upload ([7a17dbd](https://github.com/Cap-go/capgo-cli/commit/7a17dbdc7157617aaffd11a878421f3d8bd76383))
87
+ * host for prod ([2efb61e](https://github.com/Cap-go/capgo-cli/commit/2efb61ee91c09380c4aea25526ba94c46271f4ab))
88
+ * host to service ([fa7ad5e](https://github.com/Cap-go/capgo-cli/commit/fa7ad5eb7038f50104bfd56b6503cfc2473d679c))
89
+ * install command ([dd80520](https://github.com/Cap-go/capgo-cli/commit/dd80520f3f3cff6a7dcfdf276064112e77669e8a))
90
+ * issue for app less than 1mb ([bae4d80](https://github.com/Cap-go/capgo-cli/commit/bae4d80ae398c912a0aa6a2497377e10ba386092))
91
+ * issue in npm listing ([c36a60c](https://github.com/Cap-go/capgo-cli/commit/c36a60ce9b2b5b3c60320df584c58174a459d524))
92
+ * issue upload and set channel ([5a3d0e8](https://github.com/Cap-go/capgo-cli/commit/5a3d0e83ddd23c2432ce11af111c0f806cd74f19))
93
+ * issue warning for upload ([4741be8](https://github.com/Cap-go/capgo-cli/commit/4741be8dc294653d0a084fa9e08cdddf2b92a40c))
94
+ * issue with add and typo in text ([f450da5](https://github.com/Cap-go/capgo-cli/commit/f450da543b56f0182085e14ac5ff96c5e3aebe2e))
95
+ * Keep is only removing the first version, not the given option. [#25](https://github.com/Cap-go/capgo-cli/issues/25) ([8b1dc24](https://github.com/Cap-go/capgo-cli/commit/8b1dc2420cb85e011788da04889e4d3c289674c5)), closes [#26](https://github.com/Cap-go/capgo-cli/issues/26)
96
+ * key generation ([4811f52](https://github.com/Cap-go/capgo-cli/commit/4811f524d1b3d2cd8d9bf53e6e8c5f41f1136554))
97
+ * keywords npm ([9e9b2ac](https://github.com/Cap-go/capgo-cli/commit/9e9b2ac81dd3aed5688d5cdb32976e3c3e9977b3))
98
+ * latest version ([e331d93](https://github.com/Cap-go/capgo-cli/commit/e331d930e40fb767e630960aceafe69d2602956b))
99
+ * lint + do set ([3046aac](https://github.com/Cap-go/capgo-cli/commit/3046aacd52b28c04d66aa2805e07183eeb2559e5))
100
+ * lint issue ([1a815b1](https://github.com/Cap-go/capgo-cli/commit/1a815b171a8f2ccf5250e6386d7cf4b4fe15b745))
101
+ * lint issue ([08f8fbd](https://github.com/Cap-go/capgo-cli/commit/08f8fbd217c1b09b4b21a2a35c1329c01b1584c8))
102
+ * lint issue ([6c4b0da](https://github.com/Cap-go/capgo-cli/commit/6c4b0da11c519ca09d6c2b5b455a895a5075c8c3))
103
+ * lock file ([c4d94ef](https://github.com/Cap-go/capgo-cli/commit/c4d94ef046aa8c63c7acf3e4ee671b35b602e826))
104
+ * logsnag ([efb5003](https://github.com/Cap-go/capgo-cli/commit/efb5003a783ef3b5097d45311eac7c3585f9fd65))
105
+ * make channel optional ([4ebdda6](https://github.com/Cap-go/capgo-cli/commit/4ebdda6ac8f81b41e72bfbd1449aa2eaabdd42ff))
106
+ * make key function use less deps + make config simpler ([3a52dc3](https://github.com/Cap-go/capgo-cli/commit/3a52dc3fc9174ffa40f45302145ccf500f692a1d))
107
+ * message for delete version ([750949c](https://github.com/Cap-go/capgo-cli/commit/750949c2a693ed93b6957247e92480021fcac25a))
108
+ * message order ([e97d794](https://github.com/Cap-go/capgo-cli/commit/e97d794f7183daad41e488d447e5150e647d52f7))
109
+ * migrate to new npm namespace ([2ce438d](https://github.com/Cap-go/capgo-cli/commit/2ce438d60dde9b300757f7c67df2f1576029aa66))
110
+ * mobile app url ([2388532](https://github.com/Cap-go/capgo-cli/commit/238853254d88fed9301615c465fe010c4ce399df))
111
+ * name function ([8a16a2b](https://github.com/Cap-go/capgo-cli/commit/8a16a2b039e4378b17922b698edbb08f9fa937da))
112
+ * naming in doc and cli ([f000926](https://github.com/Cap-go/capgo-cli/commit/f00092615b50d7de196d5cfa7702040b79b1638c))
113
+ * npm listing ([d24f901](https://github.com/Cap-go/capgo-cli/commit/d24f901a01b1339be43e5ef7632565faf049e417))
114
+ * pack version for deploy ([1611bfc](https://github.com/Cap-go/capgo-cli/commit/1611bfcfdd95ac5372a39b7dcd2773108e58749b))
115
+ * path ([a7e5d4b](https://github.com/Cap-go/capgo-cli/commit/a7e5d4b85667367df1e5279bdcf301b7f2da794d))
116
+ * pnpm build ([a979e04](https://github.com/Cap-go/capgo-cli/commit/a979e0465b3db72d7fe1bb916ac49818a7a4a693))
117
+ * pnpm version ([0ee7b63](https://github.com/Cap-go/capgo-cli/commit/0ee7b63c96de9438ee0e38774d0deec9f015c3d5))
118
+ * publish right version ([4c40102](https://github.com/Cap-go/capgo-cli/commit/4c40102fcbc2cf032121daa36078b00ca9107891))
119
+ * put all env var in same file ([ab78f0c](https://github.com/Cap-go/capgo-cli/commit/ab78f0c3da6222c6e66d97e26128c21d71c237f9))
120
+ * readme ([2d47be8](https://github.com/Cap-go/capgo-cli/commit/2d47be84887f7aecd53285cb1ea21ef54ba28226))
121
+ * readme add keep option ([0d1a5fa](https://github.com/Cap-go/capgo-cli/commit/0d1a5fadd84ddabbb67e3b2a7cc7b70ca370b7e2))
122
+ * redirection usage ([ba28c25](https://github.com/Cap-go/capgo-cli/commit/ba28c25c3ad2efe676d877f5e95f1f73fd500d02))
123
+ * remove all --apikey usage ([39606c7](https://github.com/Cap-go/capgo-cli/commit/39606c70a910293f2ca2832b4db5800f216c879a))
124
+ * remove debug comments ([9687003](https://github.com/Cap-go/capgo-cli/commit/96870037b981b1e80d4b0ecc397670e707dd0464))
125
+ * remove dup code + fix list display ([5f32edf](https://github.com/Cap-go/capgo-cli/commit/5f32edf6065e597946563382102e6d2b07000a08))
126
+ * remove install ([bcc5d24](https://github.com/Cap-go/capgo-cli/commit/bcc5d24a36adac44e128adcd0b94cd2167aae4d9))
127
+ * remove old deps ([6d19dda](https://github.com/Cap-go/capgo-cli/commit/6d19dda81c25f961d1750223c61375be99634a86))
128
+ * remove production option and use only channel ([881474e](https://github.com/Cap-go/capgo-cli/commit/881474ee86ea7736e51cbf39f4e590bcdc8c786e))
129
+ * remove useless ([512f293](https://github.com/Cap-go/capgo-cli/commit/512f2939e2663060e8c26fcd3c59af6f62453ea9))
130
+ * remove useless comment ([c02eb3f](https://github.com/Cap-go/capgo-cli/commit/c02eb3f84bf29ea0fe1cb7dc75d2b4c16bab0195))
131
+ * remove useless import ([c27bfa2](https://github.com/Cap-go/capgo-cli/commit/c27bfa2cc2992b39fba1f4c48a1f4ed4a1ba68a1))
132
+ * remove useless key for now ([ecd5ef6](https://github.com/Cap-go/capgo-cli/commit/ecd5ef614a2a2ad642153e8aa782236513e0a71c))
133
+ * remove version from mendatory field in set ([0317608](https://github.com/Cap-go/capgo-cli/commit/03176089e098d4c7f9be301def41fb95059776b0))
134
+ * rename var to privateKey in decode ([5d3a74d](https://github.com/Cap-go/capgo-cli/commit/5d3a74d9ccba4c88957b448f0c1b7dabcf1d3bca))
135
+ * replace all console.error by program exit ([75ed825](https://github.com/Cap-go/capgo-cli/commit/75ed825f16501a5b601cd54c5c9bc8c99de26b1f))
136
+ * return app versions ordered by id ([4924f39](https://github.com/Cap-go/capgo-cli/commit/4924f39ded74348966d0f5bb2ead65eb5af66a77))
137
+ * revert to old upload logic ([cf409b2](https://github.com/Cap-go/capgo-cli/commit/cf409b23de676e70906499a5d2152748c517df16))
138
+ * right issue in cli ([6ec7c47](https://github.com/Cap-go/capgo-cli/commit/6ec7c4766312cb386a2fe33f06080a4bb743a2e4))
139
+ * semver issue use official regex ([15f57e6](https://github.com/Cap-go/capgo-cli/commit/15f57e631d38fedad2d0d3a8a977f170411665ec))
140
+ * stats add automatic unknown and builtin version ([fab503b](https://github.com/Cap-go/capgo-cli/commit/fab503bf15c8e8884111c7bf6aa0006742902a65))
141
+ * supa config ([d540d69](https://github.com/Cap-go/capgo-cli/commit/d540d6996b81b43f11295e2980c731842164e615))
142
+ * test other error log ([dfc0e00](https://github.com/Cap-go/capgo-cli/commit/dfc0e004f5e4c8c84c8f4d62d6a18325925d1772))
143
+ * tigger CI ([856e137](https://github.com/Cap-go/capgo-cli/commit/856e137cea02a7c3e9dd6159fef2c00d4003dac6))
144
+ * types ([8bf51d8](https://github.com/Cap-go/capgo-cli/commit/8bf51d87015d5e59ae6fa8c782f78d12a6fb8993))
145
+ * types ([4f9b00f](https://github.com/Cap-go/capgo-cli/commit/4f9b00ff2d1baac0361f818e6350d267ad9d799d))
146
+ * typing issues ([3715a6e](https://github.com/Cap-go/capgo-cli/commit/3715a6ed7f09fccc47779f9fc6ea5473def32e54))
147
+ * typo ([4628ffa](https://github.com/Cap-go/capgo-cli/commit/4628ffa188ff431a8e0577f9360d9f6af57a9381))
148
+ * typo ([304d531](https://github.com/Cap-go/capgo-cli/commit/304d53140240aace26f9d651a89dbbebc76de3b9))
149
+ * update to new is_good_plan + use is_paying ([d0e5c2a](https://github.com/Cap-go/capgo-cli/commit/d0e5c2ae26800f0b21cdb444338c12cfa8380039))
150
+ * upgrade cli-progress from 3.11.0 to 3.11.2 ([a846fed](https://github.com/Cap-go/capgo-cli/commit/a846fed7da4ffe35cfdfc6a10a4e8eae89cbb27d))
151
+ * upgrade commander from 9.2.0 to 9.4.1 ([6c9e36f](https://github.com/Cap-go/capgo-cli/commit/6c9e36f82da1959edb934580b71ee78f9463decf))
152
+ * upload ([443da66](https://github.com/Cap-go/capgo-cli/commit/443da66c82da5c6e4044c5aa9254dffce101581d))
153
+ * upload ([9273f35](https://github.com/Cap-go/capgo-cli/commit/9273f35c77b992afc7aab441da1b12d3cf3e9215))
154
+ * upload allow channel ([8233e0f](https://github.com/Cap-go/capgo-cli/commit/8233e0ffaa42e0de6a5675a543ecc13d570f5811))
155
+ * upload for folder bigger than 6 mb ([001715a](https://github.com/Cap-go/capgo-cli/commit/001715a8ea51060a84b3a213b4aa424143bced65))
156
+ * upload in new supabase method ([940be30](https://github.com/Cap-go/capgo-cli/commit/940be3063d6b6d9a0475b48a436d4c60ae4489a6))
157
+ * upload issue ([4223612](https://github.com/Cap-go/capgo-cli/commit/422361211797e2111e08e4a43afe1de1b43e7871))
158
+ * upload issue ([d5afbcd](https://github.com/Cap-go/capgo-cli/commit/d5afbcd6ed6ba639522b6369dcfed98eb2b2901f))
159
+ * upload multipart on new supabase function ([46f4c94](https://github.com/Cap-go/capgo-cli/commit/46f4c94383a53e8dc8b1b2d69eb581e7597526bc))
160
+ * upload use base64 to have more portable ([d0d0042](https://github.com/Cap-go/capgo-cli/commit/d0d00420c9f82ac7f522c5e945c80297de29266b))
161
+ * upload without key ([af58b69](https://github.com/Cap-go/capgo-cli/commit/af58b69b1a283206319a80b1ca4da4c9e29604d9))
162
+ * url use new one ([620a5f1](https://github.com/Cap-go/capgo-cli/commit/620a5f153693142de1d787c407be532473cb64fa))
163
+ * usage instructions ([f6ddbd0](https://github.com/Cap-go/capgo-cli/commit/f6ddbd01ea6d777ec3c105daae2aaade4621dc26))
164
+ * use appId as identifier ([287e2d7](https://github.com/Cap-go/capgo-cli/commit/287e2d7acb9c02d07cc7ddb2f947d0024ea24f84))
165
+ * use back binary ([5f4d4f9](https://github.com/Cap-go/capgo-cli/commit/5f4d4f965c4254549ea33eba5983bb764eb64fa3))
166
+ * use hostWeb instead of hardcoded ([edc6aee](https://github.com/Cap-go/capgo-cli/commit/edc6aeed199e169427342f8b4fb5401adaa79dc3))
167
+ * use latest webpack cli ([2d2afda](https://github.com/Cap-go/capgo-cli/commit/2d2afdaac78ae44d7cbc634a9e2157185dcde71a))
168
+ * use standar-version instead of cz ([90b6372](https://github.com/Cap-go/capgo-cli/commit/90b63728777904c63f7f00e1b1ec0c46fbe32b0b))
169
+ * use the prod env ([1f976ac](https://github.com/Cap-go/capgo-cli/commit/1f976ac18fcb6d197a7c6e5b3c24f0d5fdf035d7))
170
+ * validation issue semver ([c2368d5](https://github.com/Cap-go/capgo-cli/commit/c2368d53ce1736ccdd689a957f86796a3d1c71e7))
171
+ * version number ([f26da67](https://github.com/Cap-go/capgo-cli/commit/f26da67684b800d460fe74d2fd711ec4487e5c9f))
172
+
1
173
  ## 1.6.2 (2022-11-24)
2
174
 
3
175
  ### Fix
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- (()=>{"use strict";var e={577:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.checkAppExistsAndHasPermission=void 0;const i=n(304);o.checkAppExistsAndHasPermission=(e,o,n)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:r}=yield e.rpc("exist_app",{appid:o,apikey:n});t&&!r||i.program.error("No permission for this app")}))},978:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.checkVersionNotUsedInChannel=void 0;const i=n(304),r=n(880);o.checkVersionNotUsedInChannel=(e,o,n,a,s)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:p}=yield e.from("channels").select().eq("app_id",o).eq("created_by",n).eq("version",a.id);(t&&t.length||p)&&i.program.error(`Version ${o}@${s} is used in a channel, unlink it first ${(0,r.formatError)(p)}`)}))},386:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.checkVersionNotUsedInDeviceOverride=void 0;const i=n(304),r=n(880);o.checkVersionNotUsedInDeviceOverride=(e,o,n,a)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:s}=yield e.from("devices_override").select().eq("app_id",o).eq("version",n.id);(t&&t.length||s)&&i.program.error(`Version ${o} @${a} is used in a device override, unlink it first ${(0,r.formatError)(s)}`)}))},191:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.deleteFromStorage=void 0;const i=n(304),r=n(880);o.deleteFromStorage=(e,o,n,a,s)=>t(void 0,void 0,void 0,(function*(){const{error:t}=yield e.storage.from("apps").remove([`${o}/${n}/versions/${a.bucket_id} `]);t&&i.program.error(`Something went wrong when trying to delete ${n} @${s} ${(0,r.formatError)(t)} `)}))},340:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.getVersionData=o.getActiveAppVersions=o.deleteSpecificVersion=o.deleteAppVersion=void 0;const i=n(304),r=n(880),a=n(978),s=n(386),p=n(191);o.deleteAppVersion=(e,o,n,a)=>t(void 0,void 0,void 0,(function*(){const{error:t}=yield e.from("app_versions").update({deleted:!0}).eq("app_id",o).eq("user_id",n).eq("name",a);t&&i.program.error(`App ${o}@${a} not found in database '${(0,r.formatError)(t)}'`)})),o.deleteSpecificVersion=(e,n,i,r)=>t(void 0,void 0,void 0,(function*(){const t=yield(0,o.getVersionData)(e,n,i,r);yield(0,a.checkVersionNotUsedInChannel)(e,n,i,t,r),yield(0,s.checkVersionNotUsedInDeviceOverride)(e,n,t,r),yield(0,p.deleteFromStorage)(e,i,n,t,r),yield(0,o.deleteAppVersion)(e,n,i,r)})),o.getActiveAppVersions=(e,o,n)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:a}=yield e.from("app_versions").select().eq("app_id",o).eq("user_id",n).eq("deleted",!1).order("id");return a&&i.program.error(`App ${o} not found in database ${(0,r.formatError)(a)} `),t})),o.getVersionData=(e,o,n,a)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:s}=yield e.from("app_versions").select().eq("app_id",o).eq("user_id",n).eq("name",a).eq("deleted",!1).single();return t&&!s||i.program.error(`Version ${o}@${a} doesn't exist ${(0,r.formatError)(s)}`),t}))},870:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.addApp=void 0;const i=n(304),r=n(113),a=n(147),s=n(470),p=n(11),d=n(880),c="assets/icon.png";o.addApp=(e,o)=>t(void 0,void 0,void 0,(function*(){var n,t;let{name:l,icon:u}=o;const g=o.apikey||(0,d.findSavedKey)(),f=yield(0,d.getConfig)(),v=(0,d.useLogSnag)();e=e||(null===(n=null==f?void 0:f.app)||void 0===n?void 0:n.appId),l=l||(null===(t=null==f?void 0:f.app)||void 0===t?void 0:t.appName)||"Unknown",u=u||"resources/icon.png",g||i.program.error("Missing API key, you need to provide a API key to add your app"),e&&l||i.program.error("Missing argument, you need to provide a appid and a name, or be in a capacitor project"),console.log(`Add ${e} to Capgo`);const y=(0,d.createSupabaseClient)(g),m=yield(0,d.verifyUser)(y,g,["write","all"]);let h,b;yield(0,d.checkPlanValid)(y,m),console.log("Adding..."),u&&(0,s.existsSync)(u)?(h=(0,a.readFileSync)(u),b=(0,p.getType)(u)||"image/png",console.warn(`Found app icon ${u}`)):(0,s.existsSync)(c)?(h=(0,a.readFileSync)(c),b=(0,p.getType)(c)||"image/png",console.warn(`Found app icon ${c}`)):console.warn(`Cannot find app icon in any of the following locations: ${u}, ${c}`);const{data:_,error:k}=yield y.rpc("exist_app",{appid:e,apikey:g});(_||k)&&i.program.error(`App already exists ${(0,d.formatError)(k)}`);const w=`icon_${(0,r.randomUUID)()}`;let $="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(h&&b){const{error:o}=yield y.storage.from(`images/${m}/${e}`).upload(w,h,{contentType:b});o&&i.program.error(`Could not add app ${(0,d.formatError)(o)}`);const{data:n}=yield y.storage.from(`images/${m}/${e}`).getPublicUrl(w);$=(null==n?void 0:n.publicURL)||$}const{error:x}=yield y.from("apps").insert({icon_url:$,user_id:m,name:l,app_id:e},{returning:"minimal"});x&&i.program.error(`Could not add app ${(0,d.formatError)(x)}`);const{error:C}=yield y.from("app_versions").insert([{user_id:m,deleted:!0,name:"unknown",app_id:e},{user_id:m,deleted:!0,name:"builtin",app_id:e}],{returning:"minimal"});C&&i.program.error(`Could not add app ${(0,d.formatError)(C)}`),v.publish({channel:"app",event:"App Added",icon:"🎉",tags:{"user-id":m,"app-id":e},notify:!1}).catch(),console.log("App added to server, you can upload a bundle now")}))},600:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.cleanupApp=void 0;const r=n(304),a=i(n(505)),s=i(n(616)),p=n(880),d=n(340),c=n(577),l=(0,s.default)();o.cleanupApp=(e,o)=>t(void 0,void 0,void 0,(function*(){var n;const t=o.apikey||(0,p.findSavedKey)(),{bundle:i,keep:s=4}=o,u=o.force||!1,g=yield(0,p.getConfig)();e=e||(null===(n=null==g?void 0:g.app)||void 0===n?void 0:n.appId),t||r.program.error("Missing API key, you need to provide an API key to delete your app"),e||r.program.error("Missing argument, you need to provide a appid, or be in a capacitor project");const f=`${a.default.inc(i,"major")}`;console.log(`Querying available versions in Capgo between ${i} and ${f}`);const v=(0,p.createSupabaseClient)(t),y=yield(0,p.verifyUser)(v,t);yield(0,c.checkAppExistsAndHasPermission)(v,e,t);const m=yield(0,d.getActiveAppVersions)(v,e,y);if(console.log(`Total active versions in Capgo: ${null==m?void 0:m.length}`),0===(null==m?void 0:m.length))return;const h=((e,o,n)=>{const t=[];return null==e||e.forEach((e=>{a.default.gte(e.name,o)&&a.default.lt(e.name,`${n}`)&&t.push(e)})),t})(m,i,f).reverse();console.log(`Active versions in Capgo between ${i} and ${f}: ${null==h?void 0:h.length}`);const b=h.slice(0,s),_=h.slice(s);if(b.forEach((e=>{console.log(`${e.name} created on ${(0,p.getHumanDate)(e)} will be kept`)})),b.length&&console.log("==================================================="),0!==_.length){if(_.forEach((e=>{console.log(`${e.name} created on ${(0,p.getHumanDate)(e)} will be removed`)})),!u&&"yes"!==l("Do you want to continue removing the versions specified? Type yes to confirm"))return void console.log("Not confirmed, aborting removal...");console.log("You have confirmed removal, removing versions now"),((e,o,n,t)=>{null==e||e.forEach((e=>{console.log(`Removing ${e.name} created on ${(0,p.getHumanDate)(e)}`),(0,d.deleteSpecificVersion)(o,n,t,e.name)}))})(_,v,e,y)}else console.log("Nothing to be removed, aborting removal...")}))},157:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.decodeZip=void 0;const r=n(304),a=n(147),s=i(n(339)),p=n(880);o.decodeZip=(e,o)=>t(void 0,void 0,void 0,(function*(){(0,a.existsSync)(e)||r.program.error(`Zip not found at the path ${e}`);const n=yield(0,p.getConfig)(),{extConfig:t}=n.app;o.key||(0,a.existsSync)(p.baseKey)||t.plugins.CapacitorUpdater.privateKey||r.program.error(`Private Key not found at the path ${p.baseKey} or in ${n.app.extConfigFilePath}`);const i="string"==typeof o.key?o.key:p.baseKey;let d=Buffer.from(t.plugins.CapacitorUpdater.privateKey||"","base64").toString("utf8");(0,a.existsSync)(i)||t.plugins.CapacitorUpdater.privateKey?(0,a.existsSync)(i)&&(d=(0,a.readFileSync)(i).toString()):r.program.error(`Cannot find public key ${i}`);const c=(0,a.readFileSync)(e),l=new s.default(d);l.isPublic()&&r.program.error("Cannot use public key to decode, please use private key");const u=l.decrypt(c);(0,a.writeFileSync)(`${e}decoded.zip`,u)}))},0:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.deleteApp=void 0;const i=n(304),r=n(880),a=n(340);o.deleteApp=(e,o)=>t(void 0,void 0,void 0,(function*(){var n;const{bundle:t}=o,s=o.apikey||(0,r.findSavedKey)(),p=yield(0,r.getConfig)(),d=(0,r.useLogSnag)();e=e||(null===(n=null==p?void 0:p.app)||void 0===n?void 0:n.appId),s||i.program.error("Missing API key, you need to provide an API key to delete your app"),e||i.program.error("Missing argument, you need to provide a appid, or be in a capacitor project");const c=(0,r.createSupabaseClient)(s),l=yield(0,r.verifyUser)(c,s),{data:u,error:g}=yield c.rpc("exist_app",{appid:e,apikey:s});if(u&&!g||i.program.error("No permission to delete"),t)return console.log(`Delete ${e}@${t} from Capgo`),yield(0,a.deleteSpecificVersion)(c,e,l,t),void console.log(`${e}@${t} deleted from server`);console.log(`Delete ${e} from Capgo`);const{data:f,error:v}=yield c.from("app_versions").select().eq("app_id",e).eq("user_id",l);if(v&&i.program.error(`App ${e} not found in database ${(0,r.formatError)(v)} `),f&&f.length){const o=f.map((o=>`${l}/${e}/versions/${o.bucket_id} `)),{error:n}=yield c.storage.from("apps").remove(o);n&&i.program.error(`Cannot delete stored version for app ${e} from storage ${(0,r.formatError)(n)} `)}const{error:y}=yield c.from("app_versions").delete().eq("app_id",e).eq("user_id",l);y&&i.program.error(`Cannot delete version for app ${e} from database ${(0,r.formatError)(y)} `);const{error:m}=yield c.from("apps").delete().eq("app_id",e).eq("user_id",l);m&&i.program.error(`Cannot delete from database ${(0,r.formatError)(m)} `),d.publish({channel:"app",event:"App Deleted",icon:"😱",tags:{"user-id":l,"app-id":e},notify:!1}).catch(),console.log(`${e} deleted from server`)}))},731:function(e,o,n){var t=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0});const i=n(304),r=n(157),a=n(870),s=n(218),p=n(0),d=n(331),c=n(510),l=t(n(598)),u=n(621),g=n(272),f=n(600);i.program.description("Manage packages and bundle versions in capgo Cloud").version(l.default.version),i.program.command("add [appid]").alias("a").description("Add a new app to capgo Cloud").action(a.addApp).option("-n, --name <name>","app name").option("-i, --icon <icon>","app icon path").option("-a, --apikey <apikey>","apikey to link to your account"),i.program.command("login [apikey]").alias("l").description("Save apikey to your machine or folder").action(u.login).option("--local","Only save in local folder"),i.program.command("upload [appid]").alias("u").description("Upload a new bundle to capgo Cloud").action(c.uploadVersion).option("-a, --apikey <apikey>","apikey to link to your account").option("-p, --path <path>","path of the file to upload").option("-c, --channel <channel>","channel to link to").option("-e, --external <url>","link to external url intead of upload to capgo cloud").option("-f, --format <base64|hex|binary|utf8>","choose the upload format default base64").option("--key <key>","custom path for public signing key").option("--keyData <keyData>","base64 public signing key").option("--no-key","ignore signing key and send clear update").option("-b, --bundle <bundle>","bundle version number of the file to upload"),i.program.command("set [appid]").alias("s").description("Modify a channel configuration").action(d.setChannel).requiredOption("-c, --channel <channel>","channel to link to").option("-a, --apikey <apikey>","apikey to link to your account").option("-b, --bundle <bundle>","bundle version number of the file to set").option("-s, --state <state>","set the state of the channel, default or normal").option("--downgrade","Allow to downgrade to version under native one").option("--latest","get the latest version key in the package.json to set it to the channel").option("--no-downgrade","Disable downgrade to version under native one").option("--upgrade","Allow to upgrade to version above native one").option("--no-upgrade","Disable upgrade to version above native one").option("--ios","Allow sending update to ios devices").option("--no-ios","Disable sending update to ios devices").option("--android","Allow sending update to android devices").option("--no-android","Disable sending update to android devices").option("--self-assign","Allow to device to self assign to this channel").option("--no-self-assign","Disable devices to self assign to this channel"),i.program.command("delete [appid]").alias("d").description("Delete an app from capgo Cloud").action(p.deleteApp).option("-a, --apikey <apikey>","apikey to link to your account").option("-b, --bundle <bundle>","bundle version number of the app to delete"),i.program.command("list [appid]").alias("ls").description("List versions in capgo Cloud").action(g.listApp).option("-a, --apikey <apikey>","apikey to link to your account"),i.program.command("cleanup [appid]").alias("c").description("Cleanup versions in capgo Cloud").action(f.cleanupApp).requiredOption("-b, --bundle <bundle>","bundle version number of the app to delete").option("-a, --apikey <apikey>","apikey to link to your account").option("-k, --keep <keep>","number of version to keep").option("-f, --force","force removal"),i.program.command("key [option]").description("Save base64 signing key in capacitor config, usefull for CI").action(s.manageKey).option("-f, --force","force generate a new one"),i.program.command("decode [zipPath]").alias("dec").description("Decode a signed zip update").action(r.decodeZip).option("--key <key>","custom path for private signing key").option("--keyData <keyData>","base64 private signing key"),i.program.parse(process.argv)},218:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.manageKey=void 0;const r=n(304),a=n(147),s=i(n(339)),p=n(778),d=n(880);o.manageKey=(e,o)=>t(void 0,void 0,void 0,(function*(){"create"===e?(e=>{t(void 0,void 0,void 0,(function*(){(0,a.existsSync)(".git")||r.program.error("To use local you should be in a git repository");const o=new s.default({b:512}).generateKeyPair(),n=o.exportKey("pkcs8-public-pem"),t=o.exportKey("pkcs8-private-pem").replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\s/g,"").replace(/\n/g,"");(0,a.existsSync)(d.baseKeyPub)&&!e.force&&r.program.error("Public Key already exists, use --force to overwrite"),(0,a.writeFileSync)(d.baseKeyPub,n);const i=yield(0,d.getConfig)(),{extConfig:c}=i.app;c&&(c.plugins||(c.plugins={}),c.plugins.CapacitorUpdater||(c.plugins.CapacitorUpdater={}),c.plugins.CapacitorUpdater.privateKey=t,(0,p.writeConfig)(c,i.app.extConfigFilePath)),console.log("Your RSA key has been generated using node-rsa with this settings:\n\n- encryptionScheme — 'pkcs1_oaep'.\n- signingScheme — 'pkcs8-sha256'.\n- bits — 2048.\n- exp — 65537.\n"),console.log(`public key saved into ${d.baseKeyPub} file in local directory\n`),console.log("This key will be use to encode your zipped bundle before sending it to Capgo,\nthan make them unreadable by Capgo and unmodifiable by anyone\n"),console.log(`Private key saved into ${i.app.extConfigFilePath} file in local directory`),console.log("Your app will decode with this key the zipped bundle\n")}))})(o):r.program.error("You should provide a valid option (create or save)")}))},272:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.listApp=void 0;const i=n(304),r=n(880),a=n(577),s=n(340);o.listApp=(e,o)=>t(void 0,void 0,void 0,(function*(){var n;const t=o.apikey||(0,r.findSavedKey)(),p=yield(0,r.getConfig)();e=e||(null===(n=null==p?void 0:p.app)||void 0===n?void 0:n.appId),t||i.program.error("Missing API key, you need to provide an API key to delete your app"),e||i.program.error("Missing argument, you need to provide a appid, or be in a capacitor project"),console.log("Querying available versions in Capgo");const d=(0,r.createSupabaseClient)(t),c=yield(0,r.verifyUser)(d,t);yield(0,a.checkAppExistsAndHasPermission)(d,e,t);const l=yield(0,s.getActiveAppVersions)(d,e,c);console.log(`Active versions in Capgo: ${null==l?void 0:l.length}`),null==l||l.forEach((e=>{console.log(`${e.name} created on ${(0,r.getHumanDate)(e)}`)}))}))},621:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.login=void 0;const i=n(304),r=n(147),a=n(37),s=n(880);o.login=(e,o)=>t(void 0,void 0,void 0,(function*(){const{local:n}=o,t=(0,s.useLogSnag)();if(n)(0,r.existsSync)(".git")||i.program.error("To use local you should be in a git repository"),(0,r.writeFileSync)(".capgo",`${e}\n`),(0,r.appendFileSync)(".gitignore",".capgo\n");else{const o=(0,a.homedir)();(0,r.writeFileSync)(`${o}/.capgo`,`${e}\n`)}const p=(0,s.createSupabaseClient)(e),d=yield(0,s.verifyUser)(p,e,["write","all","upload"]);t.publish({channel:"user-login",event:"User CLI login",icon:"✅",tags:{"user-id":d},notify:!1}).catch(),console.log(`login saved into .capgo file in ${n?"local":"home"} directory`)}))},331:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.setChannel=void 0;const i=n(304),r=n(880);o.setChannel=(e,o)=>t(void 0,void 0,void 0,(function*(){var n,t,a;const{bundle:s,latest:p,downgrade:d,upgrade:c,ios:l,android:u,selfAssign:g,channel:f,state:v}=o,y=o.apikey||(0,r.findSavedKey)(),m=yield(0,r.getConfig)(),h=(0,r.useLogSnag)();e=e||(null===(n=null==m?void 0:m.app)||void 0===n?void 0:n.appId),y||i.program.error("Missing API key, you need to provide a API key to add your app"),e||i.program.error("Missing argument, you need to provide a appid, or be in a capacitor project"),p&&s&&i.program.error("Cannot set latest and bundle at the same time"),void 0===s&&void 0===v&&void 0===p&&void 0===d&&void 0===c&&void 0===l&&void 0===u&&void 0===g&&i.program.error("Missing argument, you need to provide a option to set");try{const o=(0,r.createSupabaseClient)(y),n=yield(0,r.verifyUser)(o,y,["write","all"]);yield(0,r.checkPlanValid)(o,n);const b={created_by:n,app_id:e,name:f},_=p?null===(a=null===(t=null==m?void 0:m.app)||void 0===t?void 0:t.package)||void 0===a?void 0:a.version:s;if(_){const{data:t,error:r}=yield o.from("app_versions").select().eq("app_id",e).eq("name",_).eq("user_id",n).eq("deleted",!1);!r&&t&&t.length||i.program.error(`Cannot find version ${_}`),console.log(`Set ${e} channel: ${f} to @${s}`),b.version=t[0].id}void 0!==v&&("public"!==v&&"private"!==v||console.log(`Set ${e} channel: ${f} to public or private is deprecated, use default or normal instead`),console.log(`Set ${e} channel: ${f} to ${"public"===v||"default"===v?"default":"normal"}`),b.public="public"===v||"default"===v),void 0!==d&&(console.log(`Set ${e} channel: ${f} to ${d?"allow":"disallow"} downgrade`),b.disableAutoUpdateUnderNative=!d),void 0!==c&&(console.log(`Set ${e} channel: ${f} to ${c?"allow":"disallow"} upgrade`),b.disableAutoUpdateToMajor=!c),void 0!==l&&(console.log(`Set ${e} channel: ${f} to ${l?"allow":"disallow"} ios update`),b.ios=!!l),void 0!==u&&(console.log(`Set ${e} channel: ${f} to ${u?"allow":"disallow"} android update`),b.android=!!u),void 0!==g&&(console.log(`Set ${e} channel: ${f} to ${g?"allow":"disallow"} self assign to this channel`),b.allow_device_self_set=!!g);try{const{error:e}=yield(0,r.updateOrCreateChannel)(o,b,y);e&&i.program.error(`Cannot set channel ${(0,r.formatError)(e)}`)}catch(e){i.program.error(`Cannot set channel ${(0,r.formatError)(e)}`)}h.publish({channel:"app",event:"Set app",icon:"✅",tags:{"user-id":n,"app-id":e},notify:!1}).catch()}catch(e){i.program.error(`Unknow error ${(0,r.formatError)(e)}`)}console.log("Done ✅")}))},510:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.uploadVersion=void 0;const r=i(n(844)),a=n(304),s=n(113),p=i(n(295)),d=n(147),c=i(n(339)),l=n(906),u=n(880);o.uploadVersion=(e,o)=>t(void 0,void 0,void 0,(function*(){var n,t,i,g;let{bundle:f,path:v,channel:y}=o;const{external:m,key:h=!1}=o,b=o.apikey||(0,u.findSavedKey)(),_=(0,u.useLogSnag)();y=y||"dev";const k=yield(0,u.getConfig)();e=e||(null===(n=null==k?void 0:k.app)||void 0===n?void 0:n.appId),f=f||(null===(i=null===(t=null==k?void 0:k.app)||void 0===t?void 0:t.package)||void 0===i?void 0:i.version),u.regexSemver.test(f)||a.program.error(`Your bundle name ${f}, is not valid it should follow semver convention : https://semver.org/`),v=v||(null===(g=null==k?void 0:k.app)||void 0===g?void 0:g.webDir),b||a.program.error("Missing API key, you need to provide a API key to add your app"),e&&f&&v||a.program.error("Missing argument, you need to provide a appid and a bundle and a path, or be in a capacitor project"),console.log(`Upload ${e}@${f} started from path "${v}" to Capgo cloud`);const w=(0,u.createSupabaseClient)(b),$=yield(0,u.verifyUser)(w,b,["write","all","upload"]);yield(0,u.checkPlanValid)(w,$,!1);const x=new p.default.MultiBar({clearOnComplete:!1,hideCursor:!0},p.default.Presets.shades_grey),C=x.create(7,0,{format:"Uploading: [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} Part"},p.default.Presets.shades_grey);C.start(7,0,{speed:"N/A"});const{data:A,error:S}=yield w.rpc("exist_app_versions",{apikey:b,name_version:f,appid:e});(A||S)&&(x.stop(),a.program.error(`This app bundle already exist or was deleted, you cannot re-upload it ${(0,u.formatError)(S)}`)),C.increment();const{data:P,error:q}=yield w.rpc("is_trial",{userid:$}).single();(P&&P>0||q)&&x.log(`WARNING !!\nTrial expires in ${P} days, upgrade here: ${u.hostWeb}/dashboard/settings/plans\n`),C.increment();const{data:I,error:E}=yield w.rpc("exist_app",{appid:e,apikey:b});I&&!E||(x.stop(),a.program.error(`Cannot find app ${e} in your account \n${(0,u.formatError)(E)}`)),C.increment();const{data:D,error:M}=yield w.rpc("exist_app_versions",{appid:e,apikey:b,name_version:f});(D||M)&&a.program.error(`Version already exists ${(0,u.formatError)(M)}`),C.increment();const j=(0,s.randomUUID)();let U=!1,K="";if(m)m&&!m.startsWith("https://")&&(x.stop(),a.program.error(`External link should should start with "https://" current is "${m}"`));else{const o=new r.default;o.addLocalFolder(v);let n=o.toBuffer();if(h||(0,d.existsSync)(u.baseKeyPub)){const e="string"==typeof h?h:u.baseKeyPub;(0,d.existsSync)(e)||a.program.error(`Cannot find public key ${e}`);const o=(0,d.readFileSync)(e),t=new c.default(o.toString());t.isPrivate()&&a.program.error("Cannot use private key to encode, please use public key"),n=t.encrypt(n),U=!0}K=yield(0,l.checksum)(n,"crc32");const t=Math.floor(n.byteLength/1024/1024),i=`apps/${$}/${e}/versions`;C.increment(),t>20&&(x.log(`WARNING !!\nThe app size is ${t} Mb, this may take a while to download for users\n`),_.publish({channel:"app-error",event:"App Too Large",icon:"🚛",tags:{"user-id":$,"app-id":e},notify:!1}).catch());const{error:s}=yield w.storage.from(i).upload(j,n,{contentType:"application/zip"});s&&(x.stop(),a.program.error(`Cannot upload ${(0,u.formatError)(s)}`))}C.increment();const{data:V,error:O}=yield(0,u.updateOrCreateVersion)(w,{bucket_id:m?void 0:j,user_id:$,name:f,app_id:e,encrypted:U,external_url:m,checksum:K},b);if(O&&(x.stop(),a.program.error(`Cannot add bundle ${(0,u.formatError)(O)}`)),C.increment(),V&&V.length){const{error:o}=yield(0,u.updateOrCreateChannel)(w,{name:y,app_id:e,created_by:$,version:V[0].id},b);o&&x.log("Cannot set bundle with upload key, use key with more rights for that\n")}else x.log("Cannot set bundle with upload key, use key with more rights for that\n");x.stop();const N=e.replace(/\./g,"--");console.log("App uploaded to server"),console.log(`Try it in mobile app: ${u.host}/app_mobile`),console.log(`Or set the channel ${y} as public here: ${u.hostWeb}/app/package/${N}`),console.log("To use with live update in your own app"),console.log(`You can link specific device to this bundle to make user try it first, here: ${u.hostWeb}/app/p/${N}/devices`),_.publish({channel:"app",event:"App Uploaded",icon:"⏫",tags:{"user-id":$,"app-id":e},notify:!1}).catch()}))},880:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.getHumanDate=o.verifyUser=o.useLogSnag=o.updateOrCreateChannel=o.updateOrCreateVersion=o.getConfig=o.formatError=o.findSavedKey=o.checkPlanValid=o.isTrial=o.isPaying=o.isGoodPlan=o.checkKey=o.regexSemver=o.createSupabaseClient=o.supaAnon=o.hostSupa=o.hostWeb=o.host=o.baseKeyPub=o.baseKey=void 0;const r=n(778),a=n(304),s=n(885),p=i(n(867)),d=n(147),c=n(37),l=n(133);o.baseKey=".capgo_key",o.baseKeyPub=`${o.baseKey}.pub`,o.host="https://capgo.app",o.hostWeb="https://web.capgo.app",o.hostSupa="https://xvwzpoazmxkqosrdewyv.supabase.co",o.supaAnon="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYzNzgwNTAwOSwiZXhwIjoxOTUzMzgxMDA5fQ.8tgID1d4jodPwuo_fz4KHN4o1XKB9fnqyt0_GaJSj-w",o.createSupabaseClient=e=>(0,s.createClient)(o.hostSupa,o.supaAnon,{headers:{capgkey:e}}),o.regexSemver=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,o.checkKey=(e,n,i)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:r}=yield e.rpc("is_allowed_capgkey",{apikey:n,keymode:i});t&&!r||a.program.error(`Invalid API key or insufficient permissions ${(0,o.formatError)(r)}`)})),o.isGoodPlan=(e,o)=>t(void 0,void 0,void 0,(function*(){const{data:n,error:t}=yield e.rpc("is_good_plan_v2",{userid:o}).single();if(t)throw t;return n||!1})),o.isPaying=(e,o)=>t(void 0,void 0,void 0,(function*(){const{data:n,error:t}=yield e.rpc("is_paying",{userid:o}).single();if(t)throw t;return n||!1})),o.isTrial=(e,o)=>t(void 0,void 0,void 0,(function*(){const{data:n,error:t}=yield e.rpc("is_trial",{userid:o}).single();if(t)throw t;return n||0})),o.checkPlanValid=(e,n,i=!0)=>t(void 0,void 0,void 0,(function*(){const t=yield(0,o.isGoodPlan)(e,n),r=yield(0,o.isPaying)(e,n),s=yield(0,o.isTrial)(e,n);r&&t||!(s<0)||a.program.error(`You need to upgrade your plan to continue to use capgo.\n Upgrade here: ${o.hostWeb}/dashboard/settings/plans\n`),s>0&&i&&!r&&console.log(`WARNING !!\nTrial expires in ${s} days, upgrade here: ${o.hostWeb}/dashboard/settings/plans\n`)})),o.findSavedKey=()=>{let e=`${(0,c.homedir)()}/.capgo`;return(0,d.existsSync)(e)?(0,d.readFileSync)(e,"utf8").trim():(e=".capgo",(0,d.existsSync)(e)?(0,d.readFileSync)(e,"utf8").trim():null)},o.formatError=e=>e?`\n${p.default.render(e)}`:"",o.getConfig=()=>t(void 0,void 0,void 0,(function*(){let e;try{e=yield(0,r.loadConfig)()}catch(e){a.program.error("No capacitor config file found, run `cap init` first")}return e})),o.updateOrCreateVersion=(e,o,n)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:i}=yield e.rpc("exist_app_versions",{appid:o.app_id,name_version:o.name,apikey:n});return t&&!i?(o.deleted=!1,e.from("app_versions").update(o).eq("app_id",o.app_id).eq("name",o.name)):e.from("app_versions").insert(o)})),o.updateOrCreateChannel=(e,o,n)=>t(void 0,void 0,void 0,(function*(){if(!o.app_id||!o.name||!o.created_by)return console.error("missing app_id, name, or created_by"),Promise.reject(new Error("missing app_id, name, or created_by"));const{data:t,error:i}=yield e.rpc("exist_channel",{appid:o.app_id,name_channel:o.name,apikey:n});return t&&!i?e.from("channels").update(o,{returning:"minimal"}).eq("app_id",o.app_id).eq("name",o.name).eq("created_by",o.created_by):e.from("channels").insert(o,{returning:"minimal"})})),o.useLogSnag=()=>new l.LogSnag({token:"c124f5e9d0ce5bdd14bbb48f815d5583",project:"capgo"}),o.verifyUser=(e,n,i=["all"])=>t(void 0,void 0,void 0,(function*(){yield(0,o.checkKey)(e,n,i);const{data:t,error:r}=yield e.rpc("get_user_id",{apikey:n}),s=t?t.toString():"";return s&&!r||a.program.error(`Cannot verify user ${(0,o.formatError)(r)}`),s})),o.getHumanDate=e=>new Date(e.created_at||"").toLocaleString()},778:e=>{e.exports=require("@capacitor/cli/dist/config")},885:e=>{e.exports=require("@supabase/supabase-js")},906:e=>{e.exports=require("@tomasklaen/checksum")},844:e=>{e.exports=require("adm-zip")},295:e=>{e.exports=require("cli-progress")},304:e=>{e.exports=require("commander")},470:e=>{e.exports=require("fs-extra")},133:e=>{e.exports=require("logsnag")},11:e=>{e.exports=require("mime")},339:e=>{e.exports=require("node-rsa")},867:e=>{e.exports=require("prettyjson")},616:e=>{e.exports=require("prompt-sync")},505:e=>{e.exports=require("semver/preload")},113:e=>{e.exports=require("crypto")},147:e=>{e.exports=require("fs")},37:e=>{e.exports=require("os")},598:e=>{e.exports=JSON.parse('{"name":"@capgo/cli","version":"1.6.2","description":"A CLI to upload to capgo servers","main":"dist/index.js","bin":{"capgo":"dist/index.js"},"repository":{"type":"git","url":"git+https://github.com/Cap-go/capgo-cli.git"},"bugs":{"url":"https://github.com/Cap-go/capgo-cli/issues"},"keywords":["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli"],"scripts":{"dev":"set NODE_ENV=development && npx webpack --config webpack.config.js","no-debug":"node dist/index.js","build":"npx webpack --config webpack.config.js","dev-build":"SUPA_DB=development npx webpack --config webpack.config.js","pack":"pkg","test_rls":"ts-node ./test/test_headers_rls.ts","lint":"eslint . --ext .ts --fix"},"author":"github.com/riderx","license":"Apache 2.0","dependencies":{"@capacitor/cli":"4.5.0","@supabase/supabase-js":"^1.35.7","@tomasklaen/checksum":"^1.1.0","adm-zip":"^0.5.9","cli-progress":"3.11.2","commander":"9.4.1","fs-extra":"10.1.0","logsnag":"^0.1.5","mime":"^3.0.0","node-rsa":"^1.1.1","prettyjson":"^1.2.5","prompt-sync":"^4.2.0","semver":"^7.3.8"},"devDependencies":{"@types/adm-zip":"0.5.0","@types/cli-progress":"^3.11.0","@types/fs-extra":"^9.0.13","@types/mime":"^3.0.1","@types/node":"^18.11.9","@types/node-rsa":"^1.1.1","@types/prettyjson":"^0.0.30","@types/prompt-sync":"^4.2.0","@types/semver":"^7.3.13","@typescript-eslint/eslint-plugin":"5.44.0","@typescript-eslint/parser":"5.44.0","eslint":"8.28.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^8.5.0","eslint-import-resolver-typescript":"3.5.2","eslint-plugin-import":"2.26.0","eslint-plugin-prettier":"^4.2.1","git-format-staged":"3.0.0","husky":"^8.0.2","nodemon":"2.0.20","pkg":"5.8.0","prettier":"2.7.1","ts-loader":"^9.4.1","ts-node":"^10.9.1","tsconfig-paths":"4.1.0","typescript":"4.9.3","webpack":"5.75.0","webpack-cli":"^5.0.0","webpack-node-externals":"^3.0.0"}}')}},o={};!function n(t){var i=o[t];if(void 0!==i)return i.exports;var r=o[t]={exports:{}};return e[t].call(r.exports,r,r.exports,n),r.exports}(731)})();
2
+ (()=>{"use strict";var e={577:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.checkAppExistsAndHasPermission=void 0;const i=n(304);o.checkAppExistsAndHasPermission=(e,o,n)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:r}=yield e.rpc("exist_app",{appid:o,apikey:n});t&&!r||i.program.error("No permission for this app")}))},978:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.checkVersionNotUsedInChannel=void 0;const i=n(304),r=n(880);o.checkVersionNotUsedInChannel=(e,o,n,a,s)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:p}=yield e.from("channels").select().eq("app_id",o).eq("created_by",n).eq("version",a.id);(t&&t.length||p)&&i.program.error(`Version ${o}@${s} is used in a channel, unlink it first ${(0,r.formatError)(p)}`)}))},386:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.checkVersionNotUsedInDeviceOverride=void 0;const i=n(304),r=n(880);o.checkVersionNotUsedInDeviceOverride=(e,o,n,a)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:s}=yield e.from("devices_override").select().eq("app_id",o).eq("version",n.id);(t&&t.length||s)&&i.program.error(`Version ${o} @${a} is used in a device override, unlink it first ${(0,r.formatError)(s)}`)}))},191:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.deleteFromStorage=void 0;const i=n(304),r=n(880);o.deleteFromStorage=(e,o,n,a,s)=>t(void 0,void 0,void 0,(function*(){const{error:t}=yield e.storage.from("apps").remove([`${o}/${n}/versions/${a.bucket_id} `]);t&&i.program.error(`Something went wrong when trying to delete ${n} @${s} ${(0,r.formatError)(t)} `)}))},340:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.getVersionData=o.getActiveAppVersions=o.deleteSpecificVersion=o.deleteAppVersion=void 0;const i=n(304),r=n(880),a=n(978),s=n(386),p=n(191);o.deleteAppVersion=(e,o,n,a)=>t(void 0,void 0,void 0,(function*(){const{error:t}=yield e.from("app_versions").update({deleted:!0}).eq("app_id",o).eq("user_id",n).eq("name",a);t&&i.program.error(`App ${o}@${a} not found in database '${(0,r.formatError)(t)}'`)})),o.deleteSpecificVersion=(e,n,i,r)=>t(void 0,void 0,void 0,(function*(){const t=yield(0,o.getVersionData)(e,n,i,r);yield(0,a.checkVersionNotUsedInChannel)(e,n,i,t,r),yield(0,s.checkVersionNotUsedInDeviceOverride)(e,n,t,r),yield(0,p.deleteFromStorage)(e,i,n,t,r),yield(0,o.deleteAppVersion)(e,n,i,r)})),o.getActiveAppVersions=(e,o,n)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:a}=yield e.from("app_versions").select().eq("app_id",o).eq("user_id",n).eq("deleted",!1).order("id");return a&&i.program.error(`App ${o} not found in database ${(0,r.formatError)(a)} `),t})),o.getVersionData=(e,o,n,a)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:s}=yield e.from("app_versions").select().eq("app_id",o).eq("user_id",n).eq("name",a).eq("deleted",!1).single();return t&&!s||i.program.error(`Version ${o}@${a} doesn't exist ${(0,r.formatError)(s)}`),t}))},870:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.addApp=void 0;const i=n(304),r=n(113),a=n(147),s=n(470),p=n(11),d=n(880),c="assets/icon.png";o.addApp=(e,o)=>t(void 0,void 0,void 0,(function*(){var n,t;let{name:l,icon:u}=o;const g=o.apikey||(0,d.findSavedKey)(),f=yield(0,d.getConfig)(),v=(0,d.useLogSnag)();e=e||(null===(n=null==f?void 0:f.app)||void 0===n?void 0:n.appId),l=l||(null===(t=null==f?void 0:f.app)||void 0===t?void 0:t.appName)||"Unknown",u=u||"resources/icon.png",g||i.program.error("Missing API key, you need to provide a API key to add your app"),e&&l||i.program.error("Missing argument, you need to provide a appid and a name, or be in a capacitor project"),console.log(`Add ${e} to Capgo`);const y=(0,d.createSupabaseClient)(g),m=yield(0,d.verifyUser)(y,g,["write","all"]);let h,b;yield(0,d.checkPlanValid)(y,m),console.log("Adding..."),u&&(0,s.existsSync)(u)?(h=(0,a.readFileSync)(u),b=(0,p.getType)(u)||"image/png",console.warn(`Found app icon ${u}`)):(0,s.existsSync)(c)?(h=(0,a.readFileSync)(c),b=(0,p.getType)(c)||"image/png",console.warn(`Found app icon ${c}`)):console.warn(`Cannot find app icon in any of the following locations: ${u}, ${c}`);const{data:_,error:k}=yield y.rpc("exist_app",{appid:e,apikey:g});(_||k)&&i.program.error(`App already exists ${(0,d.formatError)(k)}`);const w=`icon_${(0,r.randomUUID)()}`;let $="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(h&&b){const{error:o}=yield y.storage.from(`images/${m}/${e}`).upload(w,h,{contentType:b});o&&i.program.error(`Could not add app ${(0,d.formatError)(o)}`);const{data:n}=yield y.storage.from(`images/${m}/${e}`).getPublicUrl(w);$=(null==n?void 0:n.publicURL)||$}const{error:x}=yield y.from("apps").insert({icon_url:$,user_id:m,name:l,app_id:e},{returning:"minimal"});x&&i.program.error(`Could not add app ${(0,d.formatError)(x)}`);const{error:C}=yield y.from("app_versions").insert([{user_id:m,deleted:!0,name:"unknown",app_id:e},{user_id:m,deleted:!0,name:"builtin",app_id:e}],{returning:"minimal"});C&&i.program.error(`Could not add app ${(0,d.formatError)(C)}`),v.publish({channel:"app",event:"App Added",icon:"🎉",tags:{"user-id":m,"app-id":e},notify:!1}).catch(),console.log("App added to server, you can upload a bundle now")}))},600:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.cleanupApp=void 0;const r=n(304),a=i(n(505)),s=i(n(616)),p=n(880),d=n(340),c=n(577),l=(0,s.default)();o.cleanupApp=(e,o)=>t(void 0,void 0,void 0,(function*(){var n;const t=o.apikey||(0,p.findSavedKey)(),{bundle:i,keep:s=4}=o,u=o.force||!1,g=yield(0,p.getConfig)();e=e||(null===(n=null==g?void 0:g.app)||void 0===n?void 0:n.appId),t||r.program.error("Missing API key, you need to provide an API key to delete your app"),e||r.program.error("Missing argument, you need to provide a appid, or be in a capacitor project");const f=`${a.default.inc(i,"major")}`;console.log(`Querying available versions in Capgo between ${i} and ${f}`);const v=(0,p.createSupabaseClient)(t),y=yield(0,p.verifyUser)(v,t);yield(0,c.checkAppExistsAndHasPermission)(v,e,t);const m=yield(0,d.getActiveAppVersions)(v,e,y);if(console.log(`Total active versions in Capgo: ${null==m?void 0:m.length}`),0===(null==m?void 0:m.length))return;const h=((e,o,n)=>{const t=[];return null==e||e.forEach((e=>{a.default.gte(e.name,o)&&a.default.lt(e.name,`${n}`)&&t.push(e)})),t})(m,i,f).reverse();console.log(`Active versions in Capgo between ${i} and ${f}: ${null==h?void 0:h.length}`);const b=h.slice(0,s),_=h.slice(s);if(b.forEach((e=>{console.log(`${e.name} created on ${(0,p.getHumanDate)(e)} will be kept`)})),b.length&&console.log("==================================================="),0!==_.length){if(_.forEach((e=>{console.log(`${e.name} created on ${(0,p.getHumanDate)(e)} will be removed`)})),!u&&"yes"!==l("Do you want to continue removing the versions specified? Type yes to confirm"))return void console.log("Not confirmed, aborting removal...");console.log("You have confirmed removal, removing versions now"),((e,o,n,t)=>{null==e||e.forEach((e=>{console.log(`Removing ${e.name} created on ${(0,p.getHumanDate)(e)}`),(0,d.deleteSpecificVersion)(o,n,t,e.name)}))})(_,v,e,y)}else console.log("Nothing to be removed, aborting removal...")}))},157:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.decodeZip=void 0;const r=n(304),a=n(147),s=i(n(339)),p=i(n(837)),d=n(880);o.decodeZip=(e,o,n)=>t(void 0,void 0,void 0,(function*(){(0,a.existsSync)(e)||r.program.error(`Zip not found at the path ${e}`);const t=yield(0,d.getConfig)(),{extConfig:i}=t.app;n.key||(0,a.existsSync)(d.baseKey)||i.plugins.CapacitorUpdater.privateKey||r.program.error(`Private Key not found at the path ${d.baseKey} or in ${t.app.extConfigFilePath}`);const c="string"==typeof n.key?n.key:d.baseKey;let l=i.plugins.CapacitorUpdater.privateKey;(0,a.existsSync)(c)||i.plugins.CapacitorUpdater.privateKey?(0,a.existsSync)(c)&&(l=(0,a.readFileSync)(c).toString()):r.program.error(`Cannot find public key ${c}`);const u=(0,a.readFileSync)(e),g=new s.default(l,"pkcs8-private-pem");g.isPublic()&&r.program.error("Cannot use public key to decode, please use private key");const f=g.decrypt(o,"base64");console.log("Session Key",f);const v=p.default.decrypt(u.toString(),f).toString();(0,a.writeFileSync)(`${e}decoded.zip`,v)}))},0:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.deleteApp=void 0;const i=n(304),r=n(880),a=n(340);o.deleteApp=(e,o)=>t(void 0,void 0,void 0,(function*(){var n;const{bundle:t}=o,s=o.apikey||(0,r.findSavedKey)(),p=yield(0,r.getConfig)(),d=(0,r.useLogSnag)();e=e||(null===(n=null==p?void 0:p.app)||void 0===n?void 0:n.appId),s||i.program.error("Missing API key, you need to provide an API key to delete your app"),e||i.program.error("Missing argument, you need to provide a appid, or be in a capacitor project");const c=(0,r.createSupabaseClient)(s),l=yield(0,r.verifyUser)(c,s),{data:u,error:g}=yield c.rpc("exist_app",{appid:e,apikey:s});if(u&&!g||i.program.error("No permission to delete"),t)return console.log(`Delete ${e}@${t} from Capgo`),yield(0,a.deleteSpecificVersion)(c,e,l,t),void console.log(`${e}@${t} deleted from server`);console.log(`Delete ${e} from Capgo`);const{data:f,error:v}=yield c.from("app_versions").select().eq("app_id",e).eq("user_id",l);if(v&&i.program.error(`App ${e} not found in database ${(0,r.formatError)(v)} `),f&&f.length){const o=f.map((o=>`${l}/${e}/versions/${o.bucket_id} `)),{error:n}=yield c.storage.from("apps").remove(o);n&&i.program.error(`Cannot delete stored version for app ${e} from storage ${(0,r.formatError)(n)} `)}const{error:y}=yield c.from("app_versions").delete().eq("app_id",e).eq("user_id",l);y&&i.program.error(`Cannot delete version for app ${e} from database ${(0,r.formatError)(y)} `);const{error:m}=yield c.from("apps").delete().eq("app_id",e).eq("user_id",l);m&&i.program.error(`Cannot delete from database ${(0,r.formatError)(m)} `),d.publish({channel:"app",event:"App Deleted",icon:"😱",tags:{"user-id":l,"app-id":e},notify:!1}).catch(),console.log(`${e} deleted from server`)}))},731:function(e,o,n){var t=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0});const i=n(304),r=n(157),a=n(870),s=n(218),p=n(0),d=n(331),c=n(510),l=t(n(598)),u=n(621),g=n(272),f=n(600);i.program.description("Manage packages and bundle versions in capgo Cloud").version(l.default.version),i.program.command("add [appid]").alias("a").description("Add a new app to capgo Cloud").action(a.addApp).option("-n, --name <name>","app name").option("-i, --icon <icon>","app icon path").option("-a, --apikey <apikey>","apikey to link to your account"),i.program.command("login [apikey]").alias("l").description("Save apikey to your machine or folder").action(u.login).option("--local","Only save in local folder"),i.program.command("upload [appid]").alias("u").description("Upload a new bundle to capgo Cloud").action(c.uploadVersion).option("-a, --apikey <apikey>","apikey to link to your account").option("-p, --path <path>","path of the file to upload").option("-c, --channel <channel>","channel to link to").option("-e, --external <url>","link to external url intead of upload to capgo cloud").option("-f, --format <base64|hex|binary|utf8>","choose the upload format default base64").option("--key <key>","custom path for public signing key").option("--keyData <keyData>","base64 public signing key").option("--no-key","ignore signing key and send clear update").option("-b, --bundle <bundle>","bundle version number of the file to upload"),i.program.command("set [appid]").alias("s").description("Modify a channel configuration").action(d.setChannel).requiredOption("-c, --channel <channel>","channel to link to").option("-a, --apikey <apikey>","apikey to link to your account").option("-b, --bundle <bundle>","bundle version number of the file to set").option("-s, --state <state>","set the state of the channel, default or normal").option("--downgrade","Allow to downgrade to version under native one").option("--latest","get the latest version key in the package.json to set it to the channel").option("--no-downgrade","Disable downgrade to version under native one").option("--upgrade","Allow to upgrade to version above native one").option("--no-upgrade","Disable upgrade to version above native one").option("--ios","Allow sending update to ios devices").option("--no-ios","Disable sending update to ios devices").option("--android","Allow sending update to android devices").option("--no-android","Disable sending update to android devices").option("--self-assign","Allow to device to self assign to this channel").option("--no-self-assign","Disable devices to self assign to this channel"),i.program.command("delete [appid]").alias("d").description("Delete an app from capgo Cloud").action(p.deleteApp).option("-a, --apikey <apikey>","apikey to link to your account").option("-b, --bundle <bundle>","bundle version number of the app to delete"),i.program.command("list [appid]").alias("ls").description("List versions in capgo Cloud").action(g.listApp).option("-a, --apikey <apikey>","apikey to link to your account"),i.program.command("cleanup [appid]").alias("c").description("Cleanup versions in capgo Cloud").action(f.cleanupApp).requiredOption("-b, --bundle <bundle>","bundle version number of the app to delete").option("-a, --apikey <apikey>","apikey to link to your account").option("-k, --keep <keep>","number of version to keep").option("-f, --force","force removal"),i.program.command("key [option]").description("Save base64 signing key in capacitor config, usefull for CI").action(s.manageKey).option("-f, --force","force generate a new one"),i.program.command("decode [zipPath] [sessionKey]").alias("dec").description("Decode a signed zip update").action(r.decodeZip).option("--key <key>","custom path for private signing key").option("--keyData <keyData>","base64 private signing key"),i.program.parse(process.argv)},218:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.manageKey=void 0;const r=n(304),a=n(147),s=i(n(339)),p=n(778),d=n(880);o.manageKey=(e,o)=>t(void 0,void 0,void 0,(function*(){"create"===e?(e=>{t(void 0,void 0,void 0,(function*(){(0,a.existsSync)(".git")||r.program.error("To use local you should be in a git repository");const o=new s.default({b:512}).generateKeyPair(),n=o.exportKey("pkcs8-public-pem"),t=o.exportKey("pkcs8-private-pem").replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\s/g,"").replace(/\n/g,"");(0,a.existsSync)(d.baseKeyPub)&&!e.force&&r.program.error("Public Key already exists, use --force to overwrite"),(0,a.writeFileSync)(d.baseKeyPub,n);const i=yield(0,d.getConfig)(),{extConfig:c}=i.app;c&&(c.plugins||(c.plugins={}),c.plugins.CapacitorUpdater||(c.plugins.CapacitorUpdater={}),c.plugins.CapacitorUpdater.privateKey=t,(0,p.writeConfig)(c,i.app.extConfigFilePath)),console.log("Your RSA key has been generated using node-rsa with this settings:\n\n- encryptionScheme — 'pkcs1_oaep'.\n- signingScheme — 'pkcs8-sha256'.\n- bits — 2048.\n- exp — 65537.\n"),console.log(`public key saved into ${d.baseKeyPub} file in local directory\n`),console.log("This key will be use to encode your zipped bundle before sending it to Capgo,\nthan make them unreadable by Capgo and unmodifiable by anyone\n"),console.log(`Private key saved into ${i.app.extConfigFilePath} file in local directory`),console.log("Your app will decode with this key the zipped bundle\n")}))})(o):r.program.error("You should provide a valid option (create or save)")}))},272:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.listApp=void 0;const i=n(304),r=n(880),a=n(577),s=n(340);o.listApp=(e,o)=>t(void 0,void 0,void 0,(function*(){var n;const t=o.apikey||(0,r.findSavedKey)(),p=yield(0,r.getConfig)();e=e||(null===(n=null==p?void 0:p.app)||void 0===n?void 0:n.appId),t||i.program.error("Missing API key, you need to provide an API key to delete your app"),e||i.program.error("Missing argument, you need to provide a appid, or be in a capacitor project"),console.log("Querying available versions in Capgo");const d=(0,r.createSupabaseClient)(t),c=yield(0,r.verifyUser)(d,t);yield(0,a.checkAppExistsAndHasPermission)(d,e,t);const l=yield(0,s.getActiveAppVersions)(d,e,c);console.log(`Active versions in Capgo: ${null==l?void 0:l.length}`),null==l||l.forEach((e=>{console.log(`${e.name} created on ${(0,r.getHumanDate)(e)}`)}))}))},621:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.login=void 0;const i=n(304),r=n(147),a=n(37),s=n(880);o.login=(e,o)=>t(void 0,void 0,void 0,(function*(){const{local:n}=o,t=(0,s.useLogSnag)();if(n)(0,r.existsSync)(".git")||i.program.error("To use local you should be in a git repository"),(0,r.writeFileSync)(".capgo",`${e}\n`),(0,r.appendFileSync)(".gitignore",".capgo\n");else{const o=(0,a.homedir)();(0,r.writeFileSync)(`${o}/.capgo`,`${e}\n`)}const p=(0,s.createSupabaseClient)(e),d=yield(0,s.verifyUser)(p,e,["write","all","upload"]);t.publish({channel:"user-login",event:"User CLI login",icon:"✅",tags:{"user-id":d},notify:!1}).catch(),console.log(`login saved into .capgo file in ${n?"local":"home"} directory`)}))},331:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))};Object.defineProperty(o,"__esModule",{value:!0}),o.setChannel=void 0;const i=n(304),r=n(880);o.setChannel=(e,o)=>t(void 0,void 0,void 0,(function*(){var n,t,a;const{bundle:s,latest:p,downgrade:d,upgrade:c,ios:l,android:u,selfAssign:g,channel:f,state:v}=o,y=o.apikey||(0,r.findSavedKey)(),m=yield(0,r.getConfig)(),h=(0,r.useLogSnag)();e=e||(null===(n=null==m?void 0:m.app)||void 0===n?void 0:n.appId),y||i.program.error("Missing API key, you need to provide a API key to add your app"),e||i.program.error("Missing argument, you need to provide a appid, or be in a capacitor project"),p&&s&&i.program.error("Cannot set latest and bundle at the same time"),void 0===s&&void 0===v&&void 0===p&&void 0===d&&void 0===c&&void 0===l&&void 0===u&&void 0===g&&i.program.error("Missing argument, you need to provide a option to set");try{const o=(0,r.createSupabaseClient)(y),n=yield(0,r.verifyUser)(o,y,["write","all"]);yield(0,r.checkPlanValid)(o,n);const b={created_by:n,app_id:e,name:f},_=p?null===(a=null===(t=null==m?void 0:m.app)||void 0===t?void 0:t.package)||void 0===a?void 0:a.version:s;if(_){const{data:t,error:r}=yield o.from("app_versions").select().eq("app_id",e).eq("name",_).eq("user_id",n).eq("deleted",!1);!r&&t&&t.length||i.program.error(`Cannot find version ${_}`),console.log(`Set ${e} channel: ${f} to @${s}`),b.version=t[0].id}void 0!==v&&("public"!==v&&"private"!==v||console.log(`Set ${e} channel: ${f} to public or private is deprecated, use default or normal instead`),console.log(`Set ${e} channel: ${f} to ${"public"===v||"default"===v?"default":"normal"}`),b.public="public"===v||"default"===v),void 0!==d&&(console.log(`Set ${e} channel: ${f} to ${d?"allow":"disallow"} downgrade`),b.disableAutoUpdateUnderNative=!d),void 0!==c&&(console.log(`Set ${e} channel: ${f} to ${c?"allow":"disallow"} upgrade`),b.disableAutoUpdateToMajor=!c),void 0!==l&&(console.log(`Set ${e} channel: ${f} to ${l?"allow":"disallow"} ios update`),b.ios=!!l),void 0!==u&&(console.log(`Set ${e} channel: ${f} to ${u?"allow":"disallow"} android update`),b.android=!!u),void 0!==g&&(console.log(`Set ${e} channel: ${f} to ${g?"allow":"disallow"} self assign to this channel`),b.allow_device_self_set=!!g);try{const{error:e}=yield(0,r.updateOrCreateChannel)(o,b,y);e&&i.program.error(`Cannot set channel ${(0,r.formatError)(e)}`)}catch(e){i.program.error(`Cannot set channel ${(0,r.formatError)(e)}`)}h.publish({channel:"app",event:"Set app",icon:"✅",tags:{"user-id":n,"app-id":e},notify:!1}).catch()}catch(e){i.program.error(`Unknow error ${(0,r.formatError)(e)}`)}console.log("Done ✅")}))},510:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.uploadVersion=void 0;const r=i(n(844)),a=n(304),s=n(113),p=i(n(837)),d=i(n(295)),c=n(147),l=i(n(339)),u=n(906),g=n(880);o.uploadVersion=(e,o)=>t(void 0,void 0,void 0,(function*(){var n,t,i,f;let{bundle:v,path:y,channel:m}=o;const{external:h,key:b=!1}=o,_=o.apikey||(0,g.findSavedKey)(),k=(0,g.useLogSnag)();m=m||"dev";const w=yield(0,g.getConfig)();e=e||(null===(n=null==w?void 0:w.app)||void 0===n?void 0:n.appId),v=v||(null===(i=null===(t=null==w?void 0:w.app)||void 0===t?void 0:t.package)||void 0===i?void 0:i.version),g.regexSemver.test(v)||a.program.error(`Your bundle name ${v}, is not valid it should follow semver convention : https://semver.org/`),y=y||(null===(f=null==w?void 0:w.app)||void 0===f?void 0:f.webDir),_||a.program.error("Missing API key, you need to provide a API key to add your app"),e&&v&&y||a.program.error("Missing argument, you need to provide a appid and a bundle and a path, or be in a capacitor project"),console.log(`Upload ${e}@${v} started from path "${y}" to Capgo cloud`);const $=(0,g.createSupabaseClient)(_),x=yield(0,g.verifyUser)($,_,["write","all","upload"]);yield(0,g.checkPlanValid)($,x,!1);const C=new d.default.MultiBar({clearOnComplete:!1,hideCursor:!0},d.default.Presets.shades_grey),S=C.create(7,0,{format:"Uploading: [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} Part"},d.default.Presets.shades_grey);S.start(7,0,{speed:"N/A"});const{data:A,error:P}=yield $.rpc("exist_app_versions",{apikey:_,name_version:v,appid:e});(A||P)&&(C.stop(),a.program.error(`This app bundle already exist or was deleted, you cannot re-upload it ${(0,g.formatError)(P)}`)),S.increment();const{data:q,error:I}=yield $.rpc("is_trial",{userid:x}).single();(q&&q>0||I)&&C.log(`WARNING !!\nTrial expires in ${q} days, upgrade here: ${g.hostWeb}/dashboard/settings/plans\n`),S.increment();const{data:j,error:E}=yield $.rpc("exist_app",{appid:e,apikey:_});j&&!E||(C.stop(),a.program.error(`Cannot find app ${e} in your account \n${(0,g.formatError)(E)}`)),S.increment();const{data:D,error:M}=yield $.rpc("exist_app_versions",{appid:e,apikey:_,name_version:v});(D||M)&&a.program.error(`Version already exists ${(0,g.formatError)(M)}`),S.increment();const K=(0,s.randomUUID)();let U,V="";if(h)h&&!h.startsWith("https://")&&(C.stop(),a.program.error(`External link should should start with "https://" current is "${h}"`));else{const o=new r.default;o.addLocalFolder(y);let n=o.toBuffer();if(b||(0,c.existsSync)(g.baseKeyPub)){const e="string"==typeof b?b:g.baseKeyPub;(0,c.existsSync)(e)||a.program.error(`Cannot find public key ${e}`);const o=(0,c.readFileSync)(e),t=new l.default(o.toString());t.isPrivate()&&a.program.error("Cannot use private key to encode, please use public key");const i=p.default.encrypt(n.toString(),(0,s.randomUUID)());U=t.encrypt(i.key.toString(),"base64"),console.log("Session Key",i.key.toString()),n=Buffer.from(i.ciphertext.toString(),"base64")}V=yield(0,u.checksum)(n,"crc32");const t=Math.floor(n.byteLength/1024/1024),i=`apps/${x}/${e}/versions`;S.increment(),t>20&&(C.log(`WARNING !!\nThe app size is ${t} Mb, this may take a while to download for users\n`),k.publish({channel:"app-error",event:"App Too Large",icon:"🚛",tags:{"user-id":x,"app-id":e},notify:!1}).catch());const{error:d}=yield $.storage.from(i).upload(K,n,{contentType:"application/zip"});d&&(C.stop(),a.program.error(`Cannot upload ${(0,g.formatError)(d)}`))}S.increment();const{data:O,error:N}=yield(0,g.updateOrCreateVersion)($,{bucket_id:h?void 0:K,user_id:x,name:v,app_id:e,session_key:U,external_url:h,checksum:V},_);if(N&&(C.stop(),a.program.error(`Cannot add bundle ${(0,g.formatError)(N)}`)),S.increment(),O&&O.length){const{error:o}=yield(0,g.updateOrCreateChannel)($,{name:m,app_id:e,created_by:x,version:O[0].id},_);o&&C.log("Cannot set bundle with upload key, use key with more rights for that\n")}else C.log("Cannot set bundle with upload key, use key with more rights for that\n");C.stop();const z=e.replace(/\./g,"--");console.log("App uploaded to server"),console.log(`Try it in mobile app: ${g.host}/app_mobile`),console.log(`Or set the channel ${m} as public here: ${g.hostWeb}/app/package/${z}`),console.log("To use with live update in your own app"),console.log(`You can link specific device to this bundle to make user try it first, here: ${g.hostWeb}/app/p/${z}/devices`),k.publish({channel:"app",event:"App Uploaded",icon:"⏫",tags:{"user-id":x,"app-id":e},notify:!1}).catch()}))},880:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(i,r){function a(e){try{p(t.next(e))}catch(e){r(e)}}function s(e){try{p(t.throw(e))}catch(e){r(e)}}function p(e){var o;e.done?i(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(a,s)}p((t=t.apply(e,o||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.getHumanDate=o.verifyUser=o.useLogSnag=o.updateOrCreateChannel=o.updateOrCreateVersion=o.getConfig=o.formatError=o.findSavedKey=o.checkPlanValid=o.isTrial=o.isPaying=o.isGoodPlan=o.checkKey=o.regexSemver=o.createSupabaseClient=o.supaAnon=o.hostSupa=o.hostWeb=o.host=o.baseKeyPub=o.baseKey=void 0;const r=n(778),a=n(304),s=n(885),p=i(n(867)),d=n(147),c=n(37),l=n(133);o.baseKey=".capgo_key",o.baseKeyPub=`${o.baseKey}.pub`,o.host="https://capgo.app",o.hostWeb="https://web.capgo.app",o.hostSupa="https://xvwzpoazmxkqosrdewyv.supabase.co",o.supaAnon="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYzNzgwNTAwOSwiZXhwIjoxOTUzMzgxMDA5fQ.8tgID1d4jodPwuo_fz4KHN4o1XKB9fnqyt0_GaJSj-w",o.createSupabaseClient=e=>(0,s.createClient)(o.hostSupa,o.supaAnon,{headers:{capgkey:e}}),o.regexSemver=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,o.checkKey=(e,n,i)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:r}=yield e.rpc("is_allowed_capgkey",{apikey:n,keymode:i});t&&!r||a.program.error(`Invalid API key or insufficient permissions ${(0,o.formatError)(r)}`)})),o.isGoodPlan=(e,o)=>t(void 0,void 0,void 0,(function*(){const{data:n,error:t}=yield e.rpc("is_good_plan_v2",{userid:o}).single();if(t)throw t;return n||!1})),o.isPaying=(e,o)=>t(void 0,void 0,void 0,(function*(){const{data:n,error:t}=yield e.rpc("is_paying",{userid:o}).single();if(t)throw t;return n||!1})),o.isTrial=(e,o)=>t(void 0,void 0,void 0,(function*(){const{data:n,error:t}=yield e.rpc("is_trial",{userid:o}).single();if(t)throw t;return n||0})),o.checkPlanValid=(e,n,i=!0)=>t(void 0,void 0,void 0,(function*(){const t=yield(0,o.isGoodPlan)(e,n),r=yield(0,o.isPaying)(e,n),s=yield(0,o.isTrial)(e,n);r&&t||!(s<0)||a.program.error(`You need to upgrade your plan to continue to use capgo.\n Upgrade here: ${o.hostWeb}/dashboard/settings/plans\n`),s>0&&i&&!r&&console.log(`WARNING !!\nTrial expires in ${s} days, upgrade here: ${o.hostWeb}/dashboard/settings/plans\n`)})),o.findSavedKey=()=>{let e=`${(0,c.homedir)()}/.capgo`;return(0,d.existsSync)(e)?(0,d.readFileSync)(e,"utf8").trim():(e=".capgo",(0,d.existsSync)(e)?(0,d.readFileSync)(e,"utf8").trim():null)},o.formatError=e=>e?`\n${p.default.render(e)}`:"",o.getConfig=()=>t(void 0,void 0,void 0,(function*(){let e;try{e=yield(0,r.loadConfig)()}catch(e){a.program.error("No capacitor config file found, run `cap init` first")}return e})),o.updateOrCreateVersion=(e,o,n)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:i}=yield e.rpc("exist_app_versions",{appid:o.app_id,name_version:o.name,apikey:n});return t&&!i?(o.deleted=!1,e.from("app_versions").update(o).eq("app_id",o.app_id).eq("name",o.name)):e.from("app_versions").insert(o)})),o.updateOrCreateChannel=(e,o,n)=>t(void 0,void 0,void 0,(function*(){if(!o.app_id||!o.name||!o.created_by)return console.error("missing app_id, name, or created_by"),Promise.reject(new Error("missing app_id, name, or created_by"));const{data:t,error:i}=yield e.rpc("exist_channel",{appid:o.app_id,name_channel:o.name,apikey:n});return t&&!i?e.from("channels").update(o,{returning:"minimal"}).eq("app_id",o.app_id).eq("name",o.name).eq("created_by",o.created_by):e.from("channels").insert(o,{returning:"minimal"})})),o.useLogSnag=()=>new l.LogSnag({token:"c124f5e9d0ce5bdd14bbb48f815d5583",project:"capgo"}),o.verifyUser=(e,n,i=["all"])=>t(void 0,void 0,void 0,(function*(){yield(0,o.checkKey)(e,n,i);const{data:t,error:r}=yield e.rpc("get_user_id",{apikey:n}),s=t?t.toString():"";return s&&!r||a.program.error(`Cannot verify user ${(0,o.formatError)(r)}`),s})),o.getHumanDate=e=>new Date(e.created_at||"").toLocaleString()},778:e=>{e.exports=require("@capacitor/cli/dist/config")},885:e=>{e.exports=require("@supabase/supabase-js")},906:e=>{e.exports=require("@tomasklaen/checksum")},844:e=>{e.exports=require("adm-zip")},295:e=>{e.exports=require("cli-progress")},304:e=>{e.exports=require("commander")},837:e=>{e.exports=require("crypto-js/aes")},470:e=>{e.exports=require("fs-extra")},133:e=>{e.exports=require("logsnag")},11:e=>{e.exports=require("mime")},339:e=>{e.exports=require("node-rsa")},867:e=>{e.exports=require("prettyjson")},616:e=>{e.exports=require("prompt-sync")},505:e=>{e.exports=require("semver/preload")},113:e=>{e.exports=require("crypto")},147:e=>{e.exports=require("fs")},37:e=>{e.exports=require("os")},598:e=>{e.exports=JSON.parse('{"name":"@capgo/cli","version":"2.0.1","description":"A CLI to upload to capgo servers","main":"dist/index.js","bin":{"capgo":"dist/index.js"},"repository":{"type":"git","url":"git+https://github.com/Cap-go/capgo-cli.git"},"bugs":{"url":"https://github.com/Cap-go/capgo-cli/issues"},"keywords":["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli"],"scripts":{"dev":"set NODE_ENV=development && npx webpack --config webpack.config.js","no-debug":"node dist/index.js","build":"npx webpack --config webpack.config.js","dev-build":"SUPA_DB=development npx webpack --config webpack.config.js","pack":"pkg","test_rls":"ts-node ./test/test_headers_rls.ts","lint":"eslint . --ext .ts --fix"},"author":"github.com/riderx","license":"Apache 2.0","dependencies":{"@capacitor/cli":"4.5.0","@supabase/supabase-js":"^1.35.7","@tomasklaen/checksum":"^1.1.0","adm-zip":"^0.5.9","cli-progress":"3.11.2","commander":"9.4.1","crypto-js":"^4.1.1","fs-extra":"10.1.0","logsnag":"^0.1.5","mime":"^3.0.0","node-rsa":"^1.1.1","prettyjson":"^1.2.5","prompt-sync":"^4.2.0","semver":"^7.3.8"},"devDependencies":{"@types/adm-zip":"0.5.0","@types/cli-progress":"^3.11.0","@types/crypto-js":"^4.1.1","@types/fs-extra":"^9.0.13","@types/mime":"^3.0.1","@types/node":"^18.11.9","@types/node-rsa":"^1.1.1","@types/prettyjson":"^0.0.30","@types/prompt-sync":"^4.2.0","@types/semver":"^7.3.13","@typescript-eslint/eslint-plugin":"5.44.0","@typescript-eslint/parser":"5.44.0","eslint":"8.28.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^8.5.0","eslint-import-resolver-typescript":"3.5.2","eslint-plugin-import":"2.26.0","eslint-plugin-prettier":"^4.2.1","git-format-staged":"3.0.0","husky":"^8.0.2","nodemon":"2.0.20","pkg":"5.8.0","prettier":"2.7.1","ts-loader":"^9.4.1","ts-node":"^10.9.1","tsconfig-paths":"4.1.0","typescript":"4.9.3","webpack":"5.75.0","webpack-cli":"^5.0.0","webpack-node-externals":"^3.0.0"}}')}},o={};!function n(t){var i=o[t];if(void 0!==i)return i.exports;var r=o[t]={exports:{}};return e[t].call(r.exports,r,r.exports,n),r.exports}(731)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
- "version": "1.6.2",
3
+ "version": "2.0.1",
4
4
  "description": "A CLI to upload to capgo servers",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -42,6 +42,7 @@
42
42
  "adm-zip": "^0.5.9",
43
43
  "cli-progress": "3.11.2",
44
44
  "commander": "9.4.1",
45
+ "crypto-js": "^4.1.1",
45
46
  "fs-extra": "10.1.0",
46
47
  "logsnag": "^0.1.5",
47
48
  "mime": "^3.0.0",
@@ -53,6 +54,7 @@
53
54
  "devDependencies": {
54
55
  "@types/adm-zip": "0.5.0",
55
56
  "@types/cli-progress": "^3.11.0",
57
+ "@types/crypto-js": "^4.1.1",
56
58
  "@types/fs-extra": "^9.0.13",
57
59
  "@types/mime": "^3.0.1",
58
60
  "@types/node": "^18.11.9",
@@ -81,4 +83,4 @@
81
83
  "webpack-cli": "^5.0.0",
82
84
  "webpack-node-externals": "^3.0.0"
83
85
  }
84
- }
86
+ }
package/src/bin/decode.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  import { program } from 'commander'
2
2
  import { existsSync, readFileSync, writeFileSync } from 'fs'
3
3
  import NodeRSA from 'node-rsa'
4
+ import aes from 'crypto-js/aes';
4
5
  import { baseKey, getConfig } from './utils';
5
6
 
6
7
  interface Options {
7
8
  key?: boolean | string
8
9
  }
9
10
 
10
- export const decodeZip = async (zipPath: string, options: Options) => {
11
+ export const decodeZip = async (zipPath: string, sessionKey: string, options: Options) => {
11
12
  // write in file .capgo the apikey in home directory
12
13
 
13
14
  if (!existsSync(zipPath)) {
@@ -23,7 +24,7 @@ export const decodeZip = async (zipPath: string, options: Options) => {
23
24
  const privateKey = typeof options.key === 'string' ? options.key : baseKey
24
25
  // check if publicKey exist
25
26
 
26
- let keyString = Buffer.from(extConfig.plugins.CapacitorUpdater.privateKey || "", 'base64').toString('utf8');
27
+ let keyString = extConfig.plugins.CapacitorUpdater.privateKey;
27
28
 
28
29
  if (!existsSync(privateKey) && !extConfig.plugins.CapacitorUpdater.privateKey) {
29
30
  program.error(`Cannot find public key ${privateKey}`)
@@ -34,11 +35,14 @@ export const decodeZip = async (zipPath: string, options: Options) => {
34
35
  }
35
36
 
36
37
  const zipFile = readFileSync(zipPath)
37
- const nodeRsa = new NodeRSA(keyString)
38
+ const nodeRsa = new NodeRSA(keyString, 'pkcs8-private-pem');
38
39
  if (nodeRsa.isPublic()) {
39
40
  program.error(`Cannot use public key to decode, please use private key`)
40
41
  }
41
- const decodedZip = nodeRsa.decrypt(zipFile)
42
+ const decodedSessionKey = nodeRsa.decrypt(sessionKey, 'base64')
43
+ console.log('Session Key', decodedSessionKey)
44
+ const decodedZip = aes.decrypt(zipFile.toString(), decodedSessionKey).toString()
45
+
42
46
  // write decodedZip in a file
43
47
  writeFileSync(`${zipPath}decoded.zip`, decodedZip)
44
48
  }
package/src/bin/index.ts CHANGED
@@ -99,7 +99,7 @@ program
99
99
 
100
100
 
101
101
  program
102
- .command('decode [zipPath]')
102
+ .command('decode [zipPath] [sessionKey]')
103
103
  .alias('dec')
104
104
  .description('Decode a signed zip update')
105
105
  .action(decodeZip)
@@ -2285,7 +2285,7 @@ export interface paths {
2285
2285
  deleted?: parameters["rowFilter.app_versions.deleted"];
2286
2286
  external_url?: parameters["rowFilter.app_versions.external_url"];
2287
2287
  checksum?: parameters["rowFilter.app_versions.checksum"];
2288
- encrypted?: parameters["rowFilter.app_versions.encrypted"];
2288
+ session_key?: parameters["rowFilter.app_versions.session_key"];
2289
2289
  /** Filtering Columns */
2290
2290
  select?: parameters["select"];
2291
2291
  /** Ordering */
@@ -2346,7 +2346,7 @@ export interface paths {
2346
2346
  deleted?: parameters["rowFilter.app_versions.deleted"];
2347
2347
  external_url?: parameters["rowFilter.app_versions.external_url"];
2348
2348
  checksum?: parameters["rowFilter.app_versions.checksum"];
2349
- encrypted?: parameters["rowFilter.app_versions.encrypted"];
2349
+ session_key?: parameters["rowFilter.app_versions.session_key"];
2350
2350
  };
2351
2351
  header: {
2352
2352
  /** Preference */
@@ -2371,7 +2371,7 @@ export interface paths {
2371
2371
  deleted?: parameters["rowFilter.app_versions.deleted"];
2372
2372
  external_url?: parameters["rowFilter.app_versions.external_url"];
2373
2373
  checksum?: parameters["rowFilter.app_versions.checksum"];
2374
- encrypted?: parameters["rowFilter.app_versions.encrypted"];
2374
+ session_key?: parameters["rowFilter.app_versions.session_key"];
2375
2375
  };
2376
2376
  body: {
2377
2377
  /** app_versions */
@@ -4112,11 +4112,8 @@ export interface definitions {
4112
4112
  external_url?: string;
4113
4113
  /** Format: character varying */
4114
4114
  checksum?: string;
4115
- /**
4116
- * Format: boolean
4117
- * @default false
4118
- */
4119
- encrypted: boolean;
4115
+ /** Format: character varying */
4116
+ session_key?: string;
4120
4117
  };
4121
4118
  }
4122
4119
 
@@ -4601,8 +4598,8 @@ export interface parameters {
4601
4598
  "rowFilter.app_versions.external_url": string;
4602
4599
  /** Format: character varying */
4603
4600
  "rowFilter.app_versions.checksum": string;
4604
- /** Format: boolean */
4605
- "rowFilter.app_versions.encrypted": string;
4601
+ /** Format: character varying */
4602
+ "rowFilter.app_versions.session_key": string;
4606
4603
  }
4607
4604
 
4608
4605
  export interface operations { }
package/src/bin/upload.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import AdmZip from 'adm-zip';
2
2
  import { program } from 'commander';
3
3
  import { randomUUID } from 'crypto';
4
+ import aes from 'crypto-js/aes';
4
5
  import cliProgress from 'cli-progress';
5
6
  import { existsSync, readFileSync } from 'fs';
6
- // import EncryptRsa from 'encrypt-rsa'
7
7
  import NodeRSA from 'node-rsa'
8
8
  import { checksum as getChecksum } from '@tomasklaen/checksum';
9
9
  import {
@@ -93,7 +93,7 @@ export const uploadVersion = async (appid: string, options: Options) => {
93
93
  }
94
94
  b1.increment();
95
95
  const fileName = randomUUID()
96
- let encrypted = false;
96
+ let sessionKey;
97
97
  let checksum = ''
98
98
  if (!external) {
99
99
  const zip = new AdmZip();
@@ -112,8 +112,14 @@ export const uploadVersion = async (appid: string, options: Options) => {
112
112
  if (nodeRsa.isPrivate()) {
113
113
  program.error(`Cannot use private key to encode, please use public key`)
114
114
  }
115
- zipped = nodeRsa.encrypt(zipped)
116
- encrypted = true;
115
+ // encrypt zip with key
116
+ const encrypted = aes.encrypt(zipped.toString(), randomUUID())
117
+ // encrypt session key with public key
118
+ sessionKey = nodeRsa.encrypt(encrypted.key.toString(), 'base64')
119
+ console.log('Session Key', encrypted.key.toString())
120
+
121
+ // encrypted to buffer
122
+ zipped = Buffer.from(encrypted.ciphertext.toString(), 'base64')
117
123
  }
118
124
  checksum = await getChecksum(zipped, 'crc32');
119
125
  const mbSize = Math.floor(zipped.byteLength / 1024 / 1024);
@@ -152,7 +158,7 @@ export const uploadVersion = async (appid: string, options: Options) => {
152
158
  user_id: userId,
153
159
  name: bundle,
154
160
  app_id: appid,
155
- encrypted,
161
+ session_key: sessionKey,
156
162
  external_url: external,
157
163
  checksum,
158
164
  }, apikey)
package/.cz.toml DELETED
@@ -1,8 +0,0 @@
1
- [tool.commitizen]
2
- name = "cz_conventional_commits"
3
- tag_format = "$major.$minor.$patch$prerelease"
4
- version = "1.6.2"
5
- version_files = [
6
- "package.json:version",
7
- ".cz.toml"
8
- ]