@capgo/cli 1.5.0 → 1.6.0
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.
- package/.cz.toml +1 -1
- package/CHANGELOG.md +12 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/bin/decode.ts +6 -6
- package/src/bin/types_supabase.ts +207 -0
- package/src/bin/upload.ts +3 -0
package/.cz.toml
CHANGED
package/CHANGELOG.md
CHANGED
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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304);o.checkAppExistsAndHasPermission=(e,o,n)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:i}=yield e.rpc("exist_app",{appid:o,apikey:n});t&&!i||r.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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)&&r.program.error(`Version ${o}@${s} is used in a channel, unlink it first ${(0,i.formatError)(p)}`)}))},386:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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)&&r.program.error(`Version ${o} @${a} is used in a device override, unlink it first ${(0,i.formatError)(s)}`)}))},191:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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&&r.program.error(`Something went wrong when trying to delete ${n} @${s} ${(0,i.formatError)(t)} `)}))},340:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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&&r.program.error(`App ${o}@${a} not found in database '${(0,i.formatError)(t)}'`)})),o.deleteSpecificVersion=(e,n,r,i)=>t(void 0,void 0,void 0,(function*(){const t=yield(0,o.getVersionData)(e,n,r,i);yield(0,a.checkVersionNotUsedInChannel)(e,n,r,t,i),yield(0,s.checkVersionNotUsedInDeviceOverride)(e,n,t,i),yield(0,p.deleteFromStorage)(e,r,n,t,i),yield(0,o.deleteAppVersion)(e,n,r,i)})),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&&r.program.error(`App ${o} not found in database ${(0,i.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||r.program.error(`Version ${o}@${a} doesn't exist ${(0,i.formatError)(s)}`),t}))},870:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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 f=o.apikey||(0,d.findSavedKey)(),g=yield(0,d.getConfig)(),v=(0,d.useLogSnag)();e=e||(null===(n=null==g?void 0:g.app)||void 0===n?void 0:n.appId),l=l||(null===(t=null==g?void 0:g.app)||void 0===t?void 0:t.appName)||"Unknown",u=u||"resources/icon.png",f||r.program.error("Missing API key, you need to provide a API key to add your app"),e&&l||r.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)(f),m=yield(0,d.verifyUser)(y,f,["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:w}=yield y.rpc("exist_app",{appid:e,apikey:f});(_||w)&&r.program.error(`App already exists ${(0,d.formatError)(w)}`);const k=`icon_${(0,i.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(k,h,{contentType:b});o&&r.program.error(`Could not add app ${(0,d.formatError)(o)}`);const{data:n}=yield y.storage.from(`images/${m}/${e}`).getPublicUrl(k);$=(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&&r.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&&r.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.cleanupApp=void 0;const i=n(304),a=r(n(505)),s=r(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:r,keep:s=4}=o,u=o.force||!1,f=yield(0,p.getConfig)();e=e||(null===(n=null==f?void 0:f.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");const g=`${a.default.inc(r,"major")}`;console.log(`Querying available versions in Capgo between ${r} and ${g}`);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,r,g).reverse();console.log(`Active versions in Capgo between ${r} and ${g}: ${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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.decodeZip=void 0;const i=n(304),a=n(147),s=r(n(339)),p=n(880);o.decodeZip=(e,o)=>t(void 0,void 0,void 0,(function*(){(0,a.existsSync)(e)||i.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||i.program.error(`Public Key not found at the path ${p.baseKey} or in ${n.app.extConfigFilePath}`);const r="string"==typeof o.key?o.key:p.baseKey;let d=Buffer.from(t.plugins.CapacitorUpdater.privateKey||"","base64").toString("utf8");(0,a.existsSync)(r)||t.plugins.CapacitorUpdater.privateKey?(0,a.existsSync)(r)&&(d=(0,a.readFileSync)(r).toString()):i.program.error(`Cannot find public key ${r}`);const c=(0,a.readFileSync)(e),l=new s.default(d).decrypt(c);(0,a.writeFileSync)(`${e}decoded.zip`,l)}))},0:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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,i.findSavedKey)(),p=yield(0,i.getConfig)(),d=(0,i.useLogSnag)();e=e||(null===(n=null==p?void 0:p.app)||void 0===n?void 0:n.appId),s||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 c=(0,i.createSupabaseClient)(s),l=yield(0,i.verifyUser)(c,s),{data:u,error:f}=yield c.rpc("exist_app",{appid:e,apikey:s});if(u&&!f||r.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:g,error:v}=yield c.from("app_versions").select().eq("app_id",e).eq("user_id",l);if(v&&r.program.error(`App ${e} not found in database ${(0,i.formatError)(v)} `),g&&g.length){const o=g.map((o=>`${l}/${e}/versions/${o.bucket_id} `)),{error:n}=yield c.storage.from("apps").remove(o);n&&r.program.error(`Cannot delete stored version for app ${e} from storage ${(0,i.formatError)(n)} `)}const{error:y}=yield c.from("app_versions").delete().eq("app_id",e).eq("user_id",l);y&&r.program.error(`Cannot delete version for app ${e} from database ${(0,i.formatError)(y)} `);const{error:m}=yield c.from("apps").delete().eq("app_id",e).eq("user_id",l);m&&r.program.error(`Cannot delete from database ${(0,i.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 r=n(304),i=n(157),a=n(870),s=n(218),p=n(0),d=n(331),c=n(510),l=t(n(598)),u=n(621),f=n(272),g=n(600);r.program.description("Manage packages and bundle versions in capgo Cloud").version(l.default.version),r.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"),r.program.command("login [apikey]").alias("l").description("Save apikey to your machine or folder").action(u.login).option("--local","Only save in local folder"),r.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 signing key").option("--no-key","ignore signing key and send clear update").option("-b, --bundle <bundle>","bundle version number of the file to upload"),r.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"),r.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"),r.program.command("list [appid]").alias("ls").description("List versions in capgo Cloud").action(f.listApp).option("-a, --apikey <apikey>","apikey to link to your account"),r.program.command("cleanup [appid]").alias("c").description("Cleanup versions in capgo Cloud").action(g.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"),r.program.command("key").alias("k").description("Generate signing key for your account or app").action(s.createKey).option("-f, --force","force genrate a new one"),r.program.command("decode [zipPath]").alias("dec").description("Decode a signed zip update").action(i.decodeZip).option("--key <key>","custom path for signing key"),r.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.createKey=void 0;const i=n(304),a=n(147),s=r(n(339)),p=n(778),d=n(880);o.createKey=e=>t(void 0,void 0,void 0,(function*(){(0,a.existsSync)(".git")||i.program.error("To use local you should be in a git repository");const o=new s.default({b:512}).generateKeyPair(),n=o.exportKey("public"),t=o.exportKey("private"),r=Buffer.from(t).toString("base64");(0,a.existsSync)(d.baseKey)&&!e.force&&i.program.error("Private Key already exists, use --force to overwrite"),(0,a.writeFileSync)(d.baseKey,t),(0,a.existsSync)(d.baseKeyPub)&&!e.force&&i.program.error("Public Key already exists, use --force to overwrite"),(0,a.writeFileSync)(d.baseKeyPub,n);const c=yield(0,d.getConfig)(),{extConfig:l}=c.app;l&&(l.plugins||(l.plugins={}),l.plugins.CapacitorUpdater||(l.plugins.CapacitorUpdater={}),l.plugins.CapacitorUpdater.privateKey=r,(0,p.writeConfig)(l,c.app.extConfigFilePath)),console.log(`public key saved into ${d.baseKeyPub} file in local directory\n`),console.log("This key will be use to sign your zip archive sent to Capgo,\nthan make them unreadable by Capgo and not modifiable by anyone\n"),console.log(`private key saved into ${d.baseKey} file in local directory\n`),console.log(`It's recommended to don't git ${d.baseKeyPub} and ${d.baseKey} files\n`),console.log(`private key saved into ${c.app.extConfigFilePath} file in local directory`),console.log("your app will decode the zip archive with this key\n")}))},272:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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,i.findSavedKey)(),p=yield(0,i.getConfig)();e=e||(null===(n=null==p?void 0:p.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"),console.log("Querying available versions in Capgo");const d=(0,i.createSupabaseClient)(t),c=yield(0,i.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,i.getHumanDate)(e)}`)}))}))},621:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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,i.existsSync)(".git")||r.program.error("To use local you should be in a git repository"),(0,i.writeFileSync)(".capgo",`${e}\n`),(0,i.appendFileSync)(".gitignore",".capgo\n");else{const o=(0,a.homedir)();(0,i.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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:f,channel:g,state:v}=o,y=o.apikey||(0,i.findSavedKey)(),m=yield(0,i.getConfig)(),h=(0,i.useLogSnag)();e=e||(null===(n=null==m?void 0:m.app)||void 0===n?void 0:n.appId),y||r.program.error("Missing API key, you need to provide a API key to add your app"),e||r.program.error("Missing argument, you need to provide a appid, or be in a capacitor project"),p&&s&&r.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===f&&r.program.error("Missing argument, you need to provide a option to set");try{const o=(0,i.createSupabaseClient)(y),n=yield(0,i.verifyUser)(o,y,["write","all"]);yield(0,i.checkPlanValid)(o,n);const b={created_by:n,app_id:e,name:g},_=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:i}=yield o.from("app_versions").select().eq("app_id",e).eq("name",_).eq("user_id",n).eq("deleted",!1);!i&&t&&t.length||r.program.error(`Cannot find version ${_}`),console.log(`Set ${e} channel: ${g} to @${s}`),b.version=t[0].id}void 0!==v&&("public"!==v&&"private"!==v||console.log(`Set ${e} channel: ${g} to public or private is deprecated, use default or normal instead`),console.log(`Set ${e} channel: ${g} to ${"public"===v||"default"===v?"default":"normal"}`),b.public="public"===v||"default"===v),void 0!==d&&(console.log(`Set ${e} channel: ${g} to ${d?"allow":"disallow"} downgrade`),b.disableAutoUpdateUnderNative=!d),void 0!==c&&(console.log(`Set ${e} channel: ${g} to ${c?"allow":"disallow"} upgrade`),b.disableAutoUpdateToMajor=!c),void 0!==l&&(console.log(`Set ${e} channel: ${g} to ${l?"allow":"disallow"} ios update`),b.ios=!!l),void 0!==u&&(console.log(`Set ${e} channel: ${g} to ${u?"allow":"disallow"} android update`),b.android=!!u),void 0!==f&&(console.log(`Set ${e} channel: ${g} to ${f?"allow":"disallow"} self assign to this channel`),b.allow_device_self_set=!!f);try{const{error:e}=yield(0,i.updateOrCreateChannel)(o,b,y);e&&r.program.error(`Cannot set channel ${(0,i.formatError)(e)}`)}catch(e){r.program.error(`Cannot set channel ${(0,i.formatError)(e)}`)}h.publish({channel:"app",event:"Set app",icon:"✅",tags:{"user-id":n,"app-id":e},notify:!1}).catch()}catch(e){r.program.error(`Unknow error ${(0,i.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.uploadVersion=void 0;const i=r(n(844)),a=n(304),s=n(113),p=r(n(295)),d=n(147),c=r(n(339)),l=n(906),u=n(880);o.uploadVersion=(e,o)=>t(void 0,void 0,void 0,(function*(){var n,t,r,f;let{bundle:g,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 w=yield(0,u.getConfig)();e=e||(null===(n=null==w?void 0:w.app)||void 0===n?void 0:n.appId),g=g||(null===(r=null===(t=null==w?void 0:w.app)||void 0===t?void 0:t.package)||void 0===r?void 0:r.version),u.regexSemver.test(g)||a.program.error(`Your bundle name ${g}, is not valid it should follow semver convention : https://semver.org/`),v=v||(null===(f=null==w?void 0:w.app)||void 0===f?void 0:f.webDir),b||a.program.error("Missing API key, you need to provide a API key to add your app"),e&&g&&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}@${g} started from path "${v}" to Capgo cloud`);const k=(0,u.createSupabaseClient)(b),$=yield(0,u.verifyUser)(k,b,["write","all","upload"]);yield(0,u.checkPlanValid)(k,$,!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 k.rpc("exist_app_versions",{apikey:b,name_version:g,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 k.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:K}=yield k.rpc("exist_app",{appid:e,apikey:b});I&&!K||(x.stop(),a.program.error(`Cannot find app ${e} in your account \n${(0,u.formatError)(K)}`)),C.increment();const{data:M,error:j}=yield k.rpc("exist_app_versions",{appid:e,apikey:b,name_version:g});(M||j)&&a.program.error(`Version already exists ${(0,u.formatError)(j)}`),C.increment();const U=(0,s.randomUUID)();let E="";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 i.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);n=new c.default(o.toString()).encrypt(n)}E=yield(0,l.checksum)(n,"crc32");const t=Math.floor(n.byteLength/1024/1024),r=`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 k.storage.from(r).upload(U,n,{contentType:"application/zip"});s&&(x.stop(),a.program.error(`Cannot upload ${(0,u.formatError)(s)}`))}C.increment();const{data:D,error:V}=yield(0,u.updateOrCreateVersion)(k,{bucket_id:m?void 0:U,user_id:$,name:g,app_id:e,external_url:m,checksum:E},b);if(V&&(x.stop(),a.program.error(`Cannot add bundle ${(0,u.formatError)(V)}`)),C.increment(),D&&D.length){const{error:o}=yield(0,u.updateOrCreateChannel)(k,{name:y,app_id:e,created_by:$,version:D[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 O=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/${O}`),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/${O}/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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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())}))},r=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 i=n(778),a=n(304),s=n(885),p=r(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,r)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:i}=yield e.rpc("is_allowed_capgkey",{apikey:n,keymode:r});t&&!i||a.program.error(`Invalid API key or insufficient permissions ${(0,o.formatError)(i)}`)})),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,r=!0)=>t(void 0,void 0,void 0,(function*(){const t=yield(0,o.isGoodPlan)(e,n),i=yield(0,o.isPaying)(e,n),s=yield(0,o.isTrial)(e,n);i&&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&&r&&!i&&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,i.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:r}=yield e.rpc("exist_app_versions",{appid:o.app_id,name_version:o.name,apikey:n});return t&&!r?(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:r}=yield e.rpc("exist_channel",{appid:o.app_id,name_channel:o.name,apikey:n});return t&&!r?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,r=["all"])=>t(void 0,void 0,void 0,(function*(){yield(0,o.checkKey)(e,n,r);const{data:t,error:i}=yield e.rpc("get_user_id",{apikey:n}),s=t?t.toString():"";return s&&!i||a.program.error(`Cannot verify user ${(0,o.formatError)(i)}`),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.5.0","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 r=o[t];if(void 0!==r)return r.exports;var i=o[t]={exports:{}};return e[t].call(i.exports,i,i.exports,n),i.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304);o.checkAppExistsAndHasPermission=(e,o,n)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:i}=yield e.rpc("exist_app",{appid:o,apikey:n});t&&!i||r.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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)&&r.program.error(`Version ${o}@${s} is used in a channel, unlink it first ${(0,i.formatError)(p)}`)}))},386:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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)&&r.program.error(`Version ${o} @${a} is used in a device override, unlink it first ${(0,i.formatError)(s)}`)}))},191:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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&&r.program.error(`Something went wrong when trying to delete ${n} @${s} ${(0,i.formatError)(t)} `)}))},340:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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&&r.program.error(`App ${o}@${a} not found in database '${(0,i.formatError)(t)}'`)})),o.deleteSpecificVersion=(e,n,r,i)=>t(void 0,void 0,void 0,(function*(){const t=yield(0,o.getVersionData)(e,n,r,i);yield(0,a.checkVersionNotUsedInChannel)(e,n,r,t,i),yield(0,s.checkVersionNotUsedInDeviceOverride)(e,n,t,i),yield(0,p.deleteFromStorage)(e,r,n,t,i),yield(0,o.deleteAppVersion)(e,n,r,i)})),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&&r.program.error(`App ${o} not found in database ${(0,i.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||r.program.error(`Version ${o}@${a} doesn't exist ${(0,i.formatError)(s)}`),t}))},870:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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 f=o.apikey||(0,d.findSavedKey)(),g=yield(0,d.getConfig)(),v=(0,d.useLogSnag)();e=e||(null===(n=null==g?void 0:g.app)||void 0===n?void 0:n.appId),l=l||(null===(t=null==g?void 0:g.app)||void 0===t?void 0:t.appName)||"Unknown",u=u||"resources/icon.png",f||r.program.error("Missing API key, you need to provide a API key to add your app"),e&&l||r.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)(f),m=yield(0,d.verifyUser)(y,f,["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:w}=yield y.rpc("exist_app",{appid:e,apikey:f});(_||w)&&r.program.error(`App already exists ${(0,d.formatError)(w)}`);const k=`icon_${(0,i.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(k,h,{contentType:b});o&&r.program.error(`Could not add app ${(0,d.formatError)(o)}`);const{data:n}=yield y.storage.from(`images/${m}/${e}`).getPublicUrl(k);$=(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&&r.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&&r.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.cleanupApp=void 0;const i=n(304),a=r(n(505)),s=r(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:r,keep:s=4}=o,u=o.force||!1,f=yield(0,p.getConfig)();e=e||(null===(n=null==f?void 0:f.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");const g=`${a.default.inc(r,"major")}`;console.log(`Querying available versions in Capgo between ${r} and ${g}`);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,r,g).reverse();console.log(`Active versions in Capgo between ${r} and ${g}: ${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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.decodeZip=void 0;const i=n(304),a=n(147),s=r(n(339)),p=n(880);o.decodeZip=(e,o)=>t(void 0,void 0,void 0,(function*(){(0,a.existsSync)(e)||i.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||i.program.error(`Private Key not found at the path ${p.baseKey} or in ${n.app.extConfigFilePath}`);const r="string"==typeof o.key?o.key:p.baseKey;let d=Buffer.from(t.plugins.CapacitorUpdater.privateKey||"","base64").toString("utf8");(0,a.existsSync)(r)||t.plugins.CapacitorUpdater.privateKey?(0,a.existsSync)(r)&&(d=(0,a.readFileSync)(r).toString()):i.program.error(`Cannot find public key ${r}`);const c=(0,a.readFileSync)(e),l=new s.default(d).decrypt(c);(0,a.writeFileSync)(`${e}decoded.zip`,l)}))},0:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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,i.findSavedKey)(),p=yield(0,i.getConfig)(),d=(0,i.useLogSnag)();e=e||(null===(n=null==p?void 0:p.app)||void 0===n?void 0:n.appId),s||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 c=(0,i.createSupabaseClient)(s),l=yield(0,i.verifyUser)(c,s),{data:u,error:f}=yield c.rpc("exist_app",{appid:e,apikey:s});if(u&&!f||r.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:g,error:v}=yield c.from("app_versions").select().eq("app_id",e).eq("user_id",l);if(v&&r.program.error(`App ${e} not found in database ${(0,i.formatError)(v)} `),g&&g.length){const o=g.map((o=>`${l}/${e}/versions/${o.bucket_id} `)),{error:n}=yield c.storage.from("apps").remove(o);n&&r.program.error(`Cannot delete stored version for app ${e} from storage ${(0,i.formatError)(n)} `)}const{error:y}=yield c.from("app_versions").delete().eq("app_id",e).eq("user_id",l);y&&r.program.error(`Cannot delete version for app ${e} from database ${(0,i.formatError)(y)} `);const{error:m}=yield c.from("apps").delete().eq("app_id",e).eq("user_id",l);m&&r.program.error(`Cannot delete from database ${(0,i.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 r=n(304),i=n(157),a=n(870),s=n(218),p=n(0),d=n(331),c=n(510),l=t(n(598)),u=n(621),f=n(272),g=n(600);r.program.description("Manage packages and bundle versions in capgo Cloud").version(l.default.version),r.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"),r.program.command("login [apikey]").alias("l").description("Save apikey to your machine or folder").action(u.login).option("--local","Only save in local folder"),r.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 signing key").option("--no-key","ignore signing key and send clear update").option("-b, --bundle <bundle>","bundle version number of the file to upload"),r.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"),r.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"),r.program.command("list [appid]").alias("ls").description("List versions in capgo Cloud").action(f.listApp).option("-a, --apikey <apikey>","apikey to link to your account"),r.program.command("cleanup [appid]").alias("c").description("Cleanup versions in capgo Cloud").action(g.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"),r.program.command("key").alias("k").description("Generate signing key for your account or app").action(s.createKey).option("-f, --force","force genrate a new one"),r.program.command("decode [zipPath]").alias("dec").description("Decode a signed zip update").action(i.decodeZip).option("--key <key>","custom path for signing key"),r.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.createKey=void 0;const i=n(304),a=n(147),s=r(n(339)),p=n(778),d=n(880);o.createKey=e=>t(void 0,void 0,void 0,(function*(){(0,a.existsSync)(".git")||i.program.error("To use local you should be in a git repository");const o=new s.default({b:512}).generateKeyPair(),n=o.exportKey("public"),t=o.exportKey("private"),r=Buffer.from(t).toString("base64");(0,a.existsSync)(d.baseKey)&&!e.force&&i.program.error("Private Key already exists, use --force to overwrite"),(0,a.writeFileSync)(d.baseKey,t),(0,a.existsSync)(d.baseKeyPub)&&!e.force&&i.program.error("Public Key already exists, use --force to overwrite"),(0,a.writeFileSync)(d.baseKeyPub,n);const c=yield(0,d.getConfig)(),{extConfig:l}=c.app;l&&(l.plugins||(l.plugins={}),l.plugins.CapacitorUpdater||(l.plugins.CapacitorUpdater={}),l.plugins.CapacitorUpdater.privateKey=r,(0,p.writeConfig)(l,c.app.extConfigFilePath)),console.log(`public key saved into ${d.baseKeyPub} file in local directory\n`),console.log("This key will be use to sign your zip archive sent to Capgo,\nthan make them unreadable by Capgo and not modifiable by anyone\n"),console.log(`private key saved into ${d.baseKey} file in local directory\n`),console.log(`It's recommended to don't git ${d.baseKeyPub} and ${d.baseKey} files\n`),console.log(`private key saved into ${c.app.extConfigFilePath} file in local directory`),console.log("your app will decode the zip archive with this key\n")}))},272:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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,i.findSavedKey)(),p=yield(0,i.getConfig)();e=e||(null===(n=null==p?void 0:p.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"),console.log("Querying available versions in Capgo");const d=(0,i.createSupabaseClient)(t),c=yield(0,i.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,i.getHumanDate)(e)}`)}))}))},621:function(e,o,n){var t=this&&this.__awaiter||function(e,o,n,t){return new(n||(n=Promise))((function(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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,i.existsSync)(".git")||r.program.error("To use local you should be in a git repository"),(0,i.writeFileSync)(".capgo",`${e}\n`),(0,i.appendFileSync)(".gitignore",".capgo\n");else{const o=(0,a.homedir)();(0,i.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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 r=n(304),i=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:f,channel:g,state:v}=o,y=o.apikey||(0,i.findSavedKey)(),m=yield(0,i.getConfig)(),h=(0,i.useLogSnag)();e=e||(null===(n=null==m?void 0:m.app)||void 0===n?void 0:n.appId),y||r.program.error("Missing API key, you need to provide a API key to add your app"),e||r.program.error("Missing argument, you need to provide a appid, or be in a capacitor project"),p&&s&&r.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===f&&r.program.error("Missing argument, you need to provide a option to set");try{const o=(0,i.createSupabaseClient)(y),n=yield(0,i.verifyUser)(o,y,["write","all"]);yield(0,i.checkPlanValid)(o,n);const b={created_by:n,app_id:e,name:g},_=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:i}=yield o.from("app_versions").select().eq("app_id",e).eq("name",_).eq("user_id",n).eq("deleted",!1);!i&&t&&t.length||r.program.error(`Cannot find version ${_}`),console.log(`Set ${e} channel: ${g} to @${s}`),b.version=t[0].id}void 0!==v&&("public"!==v&&"private"!==v||console.log(`Set ${e} channel: ${g} to public or private is deprecated, use default or normal instead`),console.log(`Set ${e} channel: ${g} to ${"public"===v||"default"===v?"default":"normal"}`),b.public="public"===v||"default"===v),void 0!==d&&(console.log(`Set ${e} channel: ${g} to ${d?"allow":"disallow"} downgrade`),b.disableAutoUpdateUnderNative=!d),void 0!==c&&(console.log(`Set ${e} channel: ${g} to ${c?"allow":"disallow"} upgrade`),b.disableAutoUpdateToMajor=!c),void 0!==l&&(console.log(`Set ${e} channel: ${g} to ${l?"allow":"disallow"} ios update`),b.ios=!!l),void 0!==u&&(console.log(`Set ${e} channel: ${g} to ${u?"allow":"disallow"} android update`),b.android=!!u),void 0!==f&&(console.log(`Set ${e} channel: ${g} to ${f?"allow":"disallow"} self assign to this channel`),b.allow_device_self_set=!!f);try{const{error:e}=yield(0,i.updateOrCreateChannel)(o,b,y);e&&r.program.error(`Cannot set channel ${(0,i.formatError)(e)}`)}catch(e){r.program.error(`Cannot set channel ${(0,i.formatError)(e)}`)}h.publish({channel:"app",event:"Set app",icon:"✅",tags:{"user-id":n,"app-id":e},notify:!1}).catch()}catch(e){r.program.error(`Unknow error ${(0,i.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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.uploadVersion=void 0;const i=r(n(844)),a=n(304),s=n(113),p=r(n(295)),d=n(147),c=r(n(339)),l=n(906),u=n(880);o.uploadVersion=(e,o)=>t(void 0,void 0,void 0,(function*(){var n,t,r,f;let{bundle:g,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 w=yield(0,u.getConfig)();e=e||(null===(n=null==w?void 0:w.app)||void 0===n?void 0:n.appId),g=g||(null===(r=null===(t=null==w?void 0:w.app)||void 0===t?void 0:t.package)||void 0===r?void 0:r.version),u.regexSemver.test(g)||a.program.error(`Your bundle name ${g}, is not valid it should follow semver convention : https://semver.org/`),v=v||(null===(f=null==w?void 0:w.app)||void 0===f?void 0:f.webDir),b||a.program.error("Missing API key, you need to provide a API key to add your app"),e&&g&&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}@${g} started from path "${v}" to Capgo cloud`);const k=(0,u.createSupabaseClient)(b),$=yield(0,u.verifyUser)(k,b,["write","all","upload"]);yield(0,u.checkPlanValid)(k,$,!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 k.rpc("exist_app_versions",{apikey:b,name_version:g,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 k.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:K}=yield k.rpc("exist_app",{appid:e,apikey:b});I&&!K||(x.stop(),a.program.error(`Cannot find app ${e} in your account \n${(0,u.formatError)(K)}`)),C.increment();const{data:M,error:j}=yield k.rpc("exist_app_versions",{appid:e,apikey:b,name_version:g});(M||j)&&a.program.error(`Version already exists ${(0,u.formatError)(j)}`),C.increment();const U=(0,s.randomUUID)();let E=!1,D="";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 i.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);n=new c.default(o.toString()).encrypt(n),E=!0}D=yield(0,l.checksum)(n,"crc32");const t=Math.floor(n.byteLength/1024/1024),r=`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 k.storage.from(r).upload(U,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)(k,{bucket_id:m?void 0:U,user_id:$,name:g,app_id:e,encrypted:E,external_url:m,checksum:D},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)(k,{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(r,i){function a(e){try{p(t.next(e))}catch(e){i(e)}}function s(e){try{p(t.throw(e))}catch(e){i(e)}}function p(e){var o;e.done?r(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())}))},r=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 i=n(778),a=n(304),s=n(885),p=r(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,r)=>t(void 0,void 0,void 0,(function*(){const{data:t,error:i}=yield e.rpc("is_allowed_capgkey",{apikey:n,keymode:r});t&&!i||a.program.error(`Invalid API key or insufficient permissions ${(0,o.formatError)(i)}`)})),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,r=!0)=>t(void 0,void 0,void 0,(function*(){const t=yield(0,o.isGoodPlan)(e,n),i=yield(0,o.isPaying)(e,n),s=yield(0,o.isTrial)(e,n);i&&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&&r&&!i&&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,i.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:r}=yield e.rpc("exist_app_versions",{appid:o.app_id,name_version:o.name,apikey:n});return t&&!r?(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:r}=yield e.rpc("exist_channel",{appid:o.app_id,name_channel:o.name,apikey:n});return t&&!r?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,r=["all"])=>t(void 0,void 0,void 0,(function*(){yield(0,o.checkKey)(e,n,r);const{data:t,error:i}=yield e.rpc("get_user_id",{apikey:n}),s=t?t.toString():"";return s&&!i||a.program.error(`Cannot verify user ${(0,o.formatError)(i)}`),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.0","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 r=o[t];if(void 0!==r)return r.exports;var i=o[t]={exports:{}};return e[t].call(i.exports,i,i.exports,n),i.exports}(731)})();
|
package/package.json
CHANGED
package/src/bin/decode.ts
CHANGED
|
@@ -18,18 +18,18 @@ export const decodeZip = async (zipPath: string, options: Options) => {
|
|
|
18
18
|
const { extConfig } = config.app;
|
|
19
19
|
|
|
20
20
|
if (!options.key && !existsSync(baseKey) && !extConfig.plugins.CapacitorUpdater.privateKey) {
|
|
21
|
-
program.error(`
|
|
21
|
+
program.error(`Private Key not found at the path ${baseKey} or in ${config.app.extConfigFilePath}`);
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const privateKey = typeof options.key === 'string' ? options.key : baseKey
|
|
24
24
|
// check if publicKey exist
|
|
25
25
|
|
|
26
26
|
let keyString = Buffer.from(extConfig.plugins.CapacitorUpdater.privateKey || "", 'base64').toString('utf8');
|
|
27
27
|
|
|
28
|
-
if (!existsSync(
|
|
29
|
-
program.error(`Cannot find public key ${
|
|
30
|
-
} else if (existsSync(
|
|
28
|
+
if (!existsSync(privateKey) && !extConfig.plugins.CapacitorUpdater.privateKey) {
|
|
29
|
+
program.error(`Cannot find public key ${privateKey}`)
|
|
30
|
+
} else if (existsSync(privateKey)) {
|
|
31
31
|
// open with fs publicKey path
|
|
32
|
-
const keyFile = readFileSync(
|
|
32
|
+
const keyFile = readFileSync(privateKey)
|
|
33
33
|
keyString = keyFile.toString()
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -1497,6 +1497,111 @@ export interface paths {
|
|
|
1497
1497
|
};
|
|
1498
1498
|
};
|
|
1499
1499
|
};
|
|
1500
|
+
"/notifications": {
|
|
1501
|
+
get: {
|
|
1502
|
+
parameters: {
|
|
1503
|
+
query: {
|
|
1504
|
+
id?: parameters["rowFilter.notifications.id"];
|
|
1505
|
+
created_at?: parameters["rowFilter.notifications.created_at"];
|
|
1506
|
+
updated_at?: parameters["rowFilter.notifications.updated_at"];
|
|
1507
|
+
user_id?: parameters["rowFilter.notifications.user_id"];
|
|
1508
|
+
last_send_at?: parameters["rowFilter.notifications.last_send_at"];
|
|
1509
|
+
total_send?: parameters["rowFilter.notifications.total_send"];
|
|
1510
|
+
cron?: parameters["rowFilter.notifications.cron"];
|
|
1511
|
+
/** Filtering Columns */
|
|
1512
|
+
select?: parameters["select"];
|
|
1513
|
+
/** Ordering */
|
|
1514
|
+
order?: parameters["order"];
|
|
1515
|
+
/** Limiting and Pagination */
|
|
1516
|
+
offset?: parameters["offset"];
|
|
1517
|
+
/** Limiting and Pagination */
|
|
1518
|
+
limit?: parameters["limit"];
|
|
1519
|
+
};
|
|
1520
|
+
header: {
|
|
1521
|
+
/** Limiting and Pagination */
|
|
1522
|
+
Range?: parameters["range"];
|
|
1523
|
+
/** Limiting and Pagination */
|
|
1524
|
+
"Range-Unit"?: parameters["rangeUnit"];
|
|
1525
|
+
/** Preference */
|
|
1526
|
+
Prefer?: parameters["preferCount"];
|
|
1527
|
+
};
|
|
1528
|
+
};
|
|
1529
|
+
responses: {
|
|
1530
|
+
/** OK */
|
|
1531
|
+
200: {
|
|
1532
|
+
schema: definitions["notifications"][];
|
|
1533
|
+
};
|
|
1534
|
+
/** Partial Content */
|
|
1535
|
+
206: unknown;
|
|
1536
|
+
};
|
|
1537
|
+
};
|
|
1538
|
+
post: {
|
|
1539
|
+
parameters: {
|
|
1540
|
+
body: {
|
|
1541
|
+
/** notifications */
|
|
1542
|
+
notifications?: definitions["notifications"];
|
|
1543
|
+
};
|
|
1544
|
+
query: {
|
|
1545
|
+
/** Filtering Columns */
|
|
1546
|
+
select?: parameters["select"];
|
|
1547
|
+
};
|
|
1548
|
+
header: {
|
|
1549
|
+
/** Preference */
|
|
1550
|
+
Prefer?: parameters["preferReturn"];
|
|
1551
|
+
};
|
|
1552
|
+
};
|
|
1553
|
+
responses: {
|
|
1554
|
+
/** Created */
|
|
1555
|
+
201: unknown;
|
|
1556
|
+
};
|
|
1557
|
+
};
|
|
1558
|
+
delete: {
|
|
1559
|
+
parameters: {
|
|
1560
|
+
query: {
|
|
1561
|
+
id?: parameters["rowFilter.notifications.id"];
|
|
1562
|
+
created_at?: parameters["rowFilter.notifications.created_at"];
|
|
1563
|
+
updated_at?: parameters["rowFilter.notifications.updated_at"];
|
|
1564
|
+
user_id?: parameters["rowFilter.notifications.user_id"];
|
|
1565
|
+
last_send_at?: parameters["rowFilter.notifications.last_send_at"];
|
|
1566
|
+
total_send?: parameters["rowFilter.notifications.total_send"];
|
|
1567
|
+
cron?: parameters["rowFilter.notifications.cron"];
|
|
1568
|
+
};
|
|
1569
|
+
header: {
|
|
1570
|
+
/** Preference */
|
|
1571
|
+
Prefer?: parameters["preferReturn"];
|
|
1572
|
+
};
|
|
1573
|
+
};
|
|
1574
|
+
responses: {
|
|
1575
|
+
/** No Content */
|
|
1576
|
+
204: never;
|
|
1577
|
+
};
|
|
1578
|
+
};
|
|
1579
|
+
patch: {
|
|
1580
|
+
parameters: {
|
|
1581
|
+
query: {
|
|
1582
|
+
id?: parameters["rowFilter.notifications.id"];
|
|
1583
|
+
created_at?: parameters["rowFilter.notifications.created_at"];
|
|
1584
|
+
updated_at?: parameters["rowFilter.notifications.updated_at"];
|
|
1585
|
+
user_id?: parameters["rowFilter.notifications.user_id"];
|
|
1586
|
+
last_send_at?: parameters["rowFilter.notifications.last_send_at"];
|
|
1587
|
+
total_send?: parameters["rowFilter.notifications.total_send"];
|
|
1588
|
+
cron?: parameters["rowFilter.notifications.cron"];
|
|
1589
|
+
};
|
|
1590
|
+
body: {
|
|
1591
|
+
/** notifications */
|
|
1592
|
+
notifications?: definitions["notifications"];
|
|
1593
|
+
};
|
|
1594
|
+
header: {
|
|
1595
|
+
/** Preference */
|
|
1596
|
+
Prefer?: parameters["preferReturn"];
|
|
1597
|
+
};
|
|
1598
|
+
};
|
|
1599
|
+
responses: {
|
|
1600
|
+
/** No Content */
|
|
1601
|
+
204: never;
|
|
1602
|
+
};
|
|
1603
|
+
};
|
|
1604
|
+
};
|
|
1500
1605
|
"/channel_users": {
|
|
1501
1606
|
get: {
|
|
1502
1607
|
parameters: {
|
|
@@ -2180,6 +2285,7 @@ export interface paths {
|
|
|
2180
2285
|
deleted?: parameters["rowFilter.app_versions.deleted"];
|
|
2181
2286
|
external_url?: parameters["rowFilter.app_versions.external_url"];
|
|
2182
2287
|
checksum?: parameters["rowFilter.app_versions.checksum"];
|
|
2288
|
+
encrypted?: parameters["rowFilter.app_versions.encrypted"];
|
|
2183
2289
|
/** Filtering Columns */
|
|
2184
2290
|
select?: parameters["select"];
|
|
2185
2291
|
/** Ordering */
|
|
@@ -2240,6 +2346,7 @@ export interface paths {
|
|
|
2240
2346
|
deleted?: parameters["rowFilter.app_versions.deleted"];
|
|
2241
2347
|
external_url?: parameters["rowFilter.app_versions.external_url"];
|
|
2242
2348
|
checksum?: parameters["rowFilter.app_versions.checksum"];
|
|
2349
|
+
encrypted?: parameters["rowFilter.app_versions.encrypted"];
|
|
2243
2350
|
};
|
|
2244
2351
|
header: {
|
|
2245
2352
|
/** Preference */
|
|
@@ -2264,6 +2371,7 @@ export interface paths {
|
|
|
2264
2371
|
deleted?: parameters["rowFilter.app_versions.deleted"];
|
|
2265
2372
|
external_url?: parameters["rowFilter.app_versions.external_url"];
|
|
2266
2373
|
checksum?: parameters["rowFilter.app_versions.checksum"];
|
|
2374
|
+
encrypted?: parameters["rowFilter.app_versions.encrypted"];
|
|
2267
2375
|
};
|
|
2268
2376
|
body: {
|
|
2269
2377
|
/** app_versions */
|
|
@@ -2586,6 +2694,26 @@ export interface paths {
|
|
|
2586
2694
|
};
|
|
2587
2695
|
};
|
|
2588
2696
|
};
|
|
2697
|
+
"/rpc/get_current_plan_max": {
|
|
2698
|
+
post: {
|
|
2699
|
+
parameters: {
|
|
2700
|
+
body: {
|
|
2701
|
+
args: {
|
|
2702
|
+
/** Format: uuid */
|
|
2703
|
+
userid: string;
|
|
2704
|
+
};
|
|
2705
|
+
};
|
|
2706
|
+
header: {
|
|
2707
|
+
/** Preference */
|
|
2708
|
+
Prefer?: parameters["preferParams"];
|
|
2709
|
+
};
|
|
2710
|
+
};
|
|
2711
|
+
responses: {
|
|
2712
|
+
/** OK */
|
|
2713
|
+
200: unknown;
|
|
2714
|
+
};
|
|
2715
|
+
};
|
|
2716
|
+
};
|
|
2589
2717
|
"/rpc/find_fit_plan": {
|
|
2590
2718
|
post: {
|
|
2591
2719
|
parameters: {
|
|
@@ -2892,6 +3020,26 @@ export interface paths {
|
|
|
2892
3020
|
};
|
|
2893
3021
|
};
|
|
2894
3022
|
};
|
|
3023
|
+
"/rpc/get_max_plan": {
|
|
3024
|
+
post: {
|
|
3025
|
+
parameters: {
|
|
3026
|
+
body: {
|
|
3027
|
+
args: {
|
|
3028
|
+
/** Format: uuid */
|
|
3029
|
+
userid: string;
|
|
3030
|
+
};
|
|
3031
|
+
};
|
|
3032
|
+
header: {
|
|
3033
|
+
/** Preference */
|
|
3034
|
+
Prefer?: parameters["preferParams"];
|
|
3035
|
+
};
|
|
3036
|
+
};
|
|
3037
|
+
responses: {
|
|
3038
|
+
/** OK */
|
|
3039
|
+
200: unknown;
|
|
3040
|
+
};
|
|
3041
|
+
};
|
|
3042
|
+
};
|
|
2895
3043
|
"/rpc/get_max_stats": {
|
|
2896
3044
|
post: {
|
|
2897
3045
|
parameters: {
|
|
@@ -3627,6 +3775,42 @@ export interface definitions {
|
|
|
3627
3775
|
*/
|
|
3628
3776
|
customer_id?: string;
|
|
3629
3777
|
};
|
|
3778
|
+
notifications: {
|
|
3779
|
+
/**
|
|
3780
|
+
* Format: character varying
|
|
3781
|
+
* @description Note:
|
|
3782
|
+
* This is a Primary Key.<pk/>
|
|
3783
|
+
*/
|
|
3784
|
+
id: string;
|
|
3785
|
+
/**
|
|
3786
|
+
* Format: timestamp with time zone
|
|
3787
|
+
* @default now()
|
|
3788
|
+
*/
|
|
3789
|
+
created_at?: string;
|
|
3790
|
+
/**
|
|
3791
|
+
* Format: timestamp with time zone
|
|
3792
|
+
* @default now()
|
|
3793
|
+
*/
|
|
3794
|
+
updated_at?: string;
|
|
3795
|
+
/**
|
|
3796
|
+
* Format: uuid
|
|
3797
|
+
* @description Note:
|
|
3798
|
+
* This is a Foreign Key to `users.id`.<fk table='users' column='id'/>
|
|
3799
|
+
*/
|
|
3800
|
+
user_id: string;
|
|
3801
|
+
/**
|
|
3802
|
+
* Format: timestamp with time zone
|
|
3803
|
+
* @default now()
|
|
3804
|
+
*/
|
|
3805
|
+
last_send_at: string;
|
|
3806
|
+
/** Format: bigint */
|
|
3807
|
+
total_send: number;
|
|
3808
|
+
/**
|
|
3809
|
+
* Format: character varying
|
|
3810
|
+
* @default * * * * *
|
|
3811
|
+
*/
|
|
3812
|
+
cron: string;
|
|
3813
|
+
};
|
|
3630
3814
|
channel_users: {
|
|
3631
3815
|
/**
|
|
3632
3816
|
* Format: bigint
|
|
@@ -3928,6 +4112,11 @@ export interface definitions {
|
|
|
3928
4112
|
external_url?: string;
|
|
3929
4113
|
/** Format: character varying */
|
|
3930
4114
|
checksum?: string;
|
|
4115
|
+
/**
|
|
4116
|
+
* Format: boolean
|
|
4117
|
+
* @default false
|
|
4118
|
+
*/
|
|
4119
|
+
encrypted: boolean;
|
|
3931
4120
|
};
|
|
3932
4121
|
}
|
|
3933
4122
|
|
|
@@ -4252,6 +4441,22 @@ export interface parameters {
|
|
|
4252
4441
|
"rowFilter.users.legalAccepted": string;
|
|
4253
4442
|
/** Format: character varying */
|
|
4254
4443
|
"rowFilter.users.customer_id": string;
|
|
4444
|
+
/** @description notifications */
|
|
4445
|
+
"body.notifications": definitions["notifications"];
|
|
4446
|
+
/** Format: character varying */
|
|
4447
|
+
"rowFilter.notifications.id": string;
|
|
4448
|
+
/** Format: timestamp with time zone */
|
|
4449
|
+
"rowFilter.notifications.created_at": string;
|
|
4450
|
+
/** Format: timestamp with time zone */
|
|
4451
|
+
"rowFilter.notifications.updated_at": string;
|
|
4452
|
+
/** Format: uuid */
|
|
4453
|
+
"rowFilter.notifications.user_id": string;
|
|
4454
|
+
/** Format: timestamp with time zone */
|
|
4455
|
+
"rowFilter.notifications.last_send_at": string;
|
|
4456
|
+
/** Format: bigint */
|
|
4457
|
+
"rowFilter.notifications.total_send": string;
|
|
4458
|
+
/** Format: character varying */
|
|
4459
|
+
"rowFilter.notifications.cron": string;
|
|
4255
4460
|
/** @description channel_users */
|
|
4256
4461
|
"body.channel_users": definitions["channel_users"];
|
|
4257
4462
|
/** Format: bigint */
|
|
@@ -4396,6 +4601,8 @@ export interface parameters {
|
|
|
4396
4601
|
"rowFilter.app_versions.external_url": string;
|
|
4397
4602
|
/** Format: character varying */
|
|
4398
4603
|
"rowFilter.app_versions.checksum": string;
|
|
4604
|
+
/** Format: boolean */
|
|
4605
|
+
"rowFilter.app_versions.encrypted": string;
|
|
4399
4606
|
}
|
|
4400
4607
|
|
|
4401
4608
|
export interface operations { }
|
package/src/bin/upload.ts
CHANGED
|
@@ -93,6 +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
97
|
let checksum = ''
|
|
97
98
|
if (!external) {
|
|
98
99
|
const zip = new AdmZip();
|
|
@@ -108,6 +109,7 @@ export const uploadVersion = async (appid: string, options: Options) => {
|
|
|
108
109
|
const keyFile = readFileSync(publicKey)
|
|
109
110
|
const nodeRsa = new NodeRSA(keyFile.toString())
|
|
110
111
|
zipped = nodeRsa.encrypt(zipped)
|
|
112
|
+
encrypted = true;
|
|
111
113
|
}
|
|
112
114
|
checksum = await getChecksum(zipped, 'crc32');
|
|
113
115
|
const mbSize = Math.floor(zipped.byteLength / 1024 / 1024);
|
|
@@ -146,6 +148,7 @@ export const uploadVersion = async (appid: string, options: Options) => {
|
|
|
146
148
|
user_id: userId,
|
|
147
149
|
name: bundle,
|
|
148
150
|
app_id: appid,
|
|
151
|
+
encrypted,
|
|
149
152
|
external_url: external,
|
|
150
153
|
checksum,
|
|
151
154
|
}, apikey)
|