@protobase/cli 0.94.27 → 0.94.28
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/dist/cli/package.js
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/mobile/android-backup.ts
|
|
2
|
+
const rootTag = "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\">";
|
|
3
|
+
const backupLine = " android:allowBackup=\"true\"\n";
|
|
4
|
+
/** Where the data extraction rules go, relative to the `android` folder. */
|
|
5
|
+
const dataExtractionRulesPath = [
|
|
6
|
+
"app",
|
|
7
|
+
"src",
|
|
8
|
+
"main",
|
|
9
|
+
"res",
|
|
10
|
+
"xml",
|
|
11
|
+
"data_extraction_rules.xml"
|
|
12
|
+
];
|
|
13
|
+
const excludeAll = [
|
|
14
|
+
"root",
|
|
15
|
+
"file",
|
|
16
|
+
"database",
|
|
17
|
+
"sharedpref",
|
|
18
|
+
"external",
|
|
19
|
+
"device_root",
|
|
20
|
+
"device_file",
|
|
21
|
+
"device_database",
|
|
22
|
+
"device_sharedpref"
|
|
23
|
+
].map((domain) => ` <exclude domain="${domain}" path="."/>\n`).join("");
|
|
24
|
+
/**
|
|
25
|
+
* The data extraction rules: on Android 12 and later, nothing goes into a cloud backup or a device-to-device transfer,
|
|
26
|
+
* so a signed-in session never moves to another phone. Every domain is named, as `root` is not documented to cover the others.
|
|
27
|
+
*/
|
|
28
|
+
const dataExtractionRules = `<?xml version="1.0" encoding="utf-8"?>
|
|
29
|
+
<!-- Nothing of the app's carries over to another phone: it starts there as a fresh install. -->
|
|
30
|
+
<data-extraction-rules>
|
|
31
|
+
<cloud-backup>
|
|
32
|
+
${excludeAll} </cloud-backup>
|
|
33
|
+
<device-transfer>
|
|
34
|
+
${excludeAll} </device-transfer>
|
|
35
|
+
</data-extraction-rules>
|
|
36
|
+
`;
|
|
37
|
+
/**
|
|
38
|
+
* Capacitor's AndroidManifest.xml opting out of backup and device transfer: `allowBackup="false"` for Android 11 and
|
|
39
|
+
* earlier and cloud backup, the data extraction rules for Android 12 and later, and `tools:replace` so a plugin's
|
|
40
|
+
* manifest cannot turn either back on in the merge. Throws on any other manifest rather than leave backup on.
|
|
41
|
+
*/
|
|
42
|
+
const withoutBackup = (manifest) => {
|
|
43
|
+
if (manifest.split(rootTag).length !== 2 || manifest.split(backupLine).length !== 2 || /dataExtractionRules|fullBackupContent|xmlns:tools/.test(manifest)) throw new Error("AndroidManifest.xml is not Capacitor's template: it needs its one root tag and android:allowBackup=\"true\" line, and no backup rules");
|
|
44
|
+
return manifest.replace(rootTag, `${rootTag.slice(0, -1)} xmlns:tools="http://schemas.android.com/tools">`).replace(backupLine, " android:allowBackup=\"false\"\n android:dataExtractionRules=\"@xml/data_extraction_rules\"\n tools:replace=\"android:allowBackup,android:dataExtractionRules\"\n");
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { dataExtractionRules, dataExtractionRulesPath, withoutBackup };
|
|
@@ -20,10 +20,13 @@ const apiUrl = (given, issuer, platform) => {
|
|
|
20
20
|
if (url.protocol === "http:" && !httpHosts[platform].includes(url.hostname)) throw new Error(`${what} uses plain http to ${url.hostname}: plain http is only for a server on this machine (${httpHosts[platform].join(", ")}); any other server needs https`);
|
|
21
21
|
return url;
|
|
22
22
|
};
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* What the app must allow to reach `url`: plain http, and on Android mixed content for plain http to the emulator's
|
|
25
|
+
* host, which is not loopback, so the https page could not call it otherwise.
|
|
26
|
+
*/
|
|
24
27
|
const httpAllowances = (url) => ({
|
|
25
28
|
cleartext: url.protocol === "http:",
|
|
26
|
-
mixedContent: url.hostname === "10.0.2.2"
|
|
29
|
+
mixedContent: url.protocol === "http:" && url.hostname === "10.0.2.2"
|
|
27
30
|
});
|
|
28
31
|
/** The port `adb reverse` forwards for an Android app calling `url` on this machine, `undefined` for any other. */
|
|
29
32
|
const forwardedPort = (url, platform) => {
|
package/dist/mobile/generate.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import { dataExtractionRules, dataExtractionRulesPath, withoutBackup } from "./android-backup.js";
|
|
1
2
|
import { copyGoogleServices } from "./google-services.js";
|
|
2
3
|
import { withLocalNetworking } from "./info-plist.js";
|
|
3
4
|
import { setUpIosPush } from "./ios-push.js";
|
|
4
5
|
import { withProtobaseIcon } from "./native-icon.js";
|
|
5
6
|
import path from "node:path";
|
|
6
|
-
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
7
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
7
8
|
//#region src/mobile/generate.ts
|
|
8
9
|
const infoPlist = (ws) => path.join(ws, "ios", "App", "App", "Info.plist");
|
|
10
|
+
const androidManifest = (ws) => path.join(ws, "android", "app", "src", "main", "AndroidManifest.xml");
|
|
9
11
|
/**
|
|
10
12
|
* Generates the platform's native project in the workspace from its capacitor.config.json and app files, replacing
|
|
11
13
|
* the last one: it is never edited by hand. Its home-screen icon is Protobase's, an Android app with push gets the
|
|
12
14
|
* project's google-services.json from `googleServicesFrom`, an iOS app with push its entitlement in `apnsEnvironment` and
|
|
13
|
-
* the token forwarding, and an iOS app calling the API over plain http may reach local addresses.
|
|
15
|
+
* the token forwarding, and an iOS app calling the API over plain http may reach local addresses. Android apps opt out
|
|
16
|
+
* of backup and device transfer, so nothing carries over to another phone.
|
|
14
17
|
*/
|
|
15
18
|
const generatePlatform = async (ws, platform, { cleartext, googleServicesFrom, apnsEnvironment }, cap) => {
|
|
16
19
|
await rm(path.join(ws, platform), {
|
|
@@ -19,9 +22,16 @@ const generatePlatform = async (ws, platform, { cleartext, googleServicesFrom, a
|
|
|
19
22
|
});
|
|
20
23
|
await cap(["add", platform]);
|
|
21
24
|
await withProtobaseIcon(ws, platform);
|
|
22
|
-
if (platform === "android"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
if (platform === "android") {
|
|
26
|
+
if (googleServicesFrom !== void 0) await copyGoogleServices(googleServicesFrom, ws);
|
|
27
|
+
await writeFile(androidManifest(ws), withoutBackup(await readFile(androidManifest(ws), "utf8")));
|
|
28
|
+
const rules = path.join(ws, "android", ...dataExtractionRulesPath);
|
|
29
|
+
await mkdir(path.dirname(rules), { recursive: true });
|
|
30
|
+
await writeFile(rules, dataExtractionRules);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (apnsEnvironment !== void 0) await setUpIosPush(ws, apnsEnvironment);
|
|
34
|
+
if (!cleartext) return;
|
|
25
35
|
await writeFile(infoPlist(ws), withLocalNetworking(await readFile(infoPlist(ws), "utf8")));
|
|
26
36
|
};
|
|
27
37
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.94.
|
|
3
|
+
"version": "0.94.28",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@better-auth/core": "^1.7.12",
|
|
45
45
|
"@hono/node-server": "^2.1.3",
|
|
46
|
-
"@protobase/config": "0.94.
|
|
47
|
-
"@protobase/layout": "0.94.
|
|
48
|
-
"@protobase/query": "0.94.
|
|
49
|
-
"@protobase/schema": "0.94.
|
|
50
|
-
"@protobase/server": "0.94.
|
|
51
|
-
"@protobase/ui": "0.94.
|
|
52
|
-
"@protobase/workflows": "0.94.
|
|
46
|
+
"@protobase/config": "0.94.28",
|
|
47
|
+
"@protobase/layout": "0.94.28",
|
|
48
|
+
"@protobase/query": "0.94.28",
|
|
49
|
+
"@protobase/schema": "0.94.28",
|
|
50
|
+
"@protobase/server": "0.94.28",
|
|
51
|
+
"@protobase/ui": "0.94.28",
|
|
52
|
+
"@protobase/workflows": "0.94.28",
|
|
53
53
|
"@react-email/render": "^2.1.0",
|
|
54
54
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
55
55
|
"@sentry/vite-plugin": "^11.10.0",
|
|
@@ -111,6 +111,7 @@ makes a signed release binary: an `.aab` to upload to Google Play, an `.ipa` to
|
|
|
111
111
|
- A release calls its server over https, at `--api` or the app's `url`: plain http, `localhost` and `10.0.2.2` are refused.
|
|
112
112
|
- `--app-version` is the version the stores show, one to three numbers such as `1.2.3`. `--build-number` is a whole number that must rise with every upload, such as your CI's run number.
|
|
113
113
|
- Extra plugins run at build time with access to your signing key, so add only plugins you trust.
|
|
114
|
+
- Android apps built by `protobase mobile run` and `protobase mobile build` opt out of Android's backup and device-to-device transfer, so no working session sits in a cloud backup or on another phone. On a new phone, or after restoring a backup, the app starts as a fresh install: your users sign in again, and unsent drafts are gone. <gap>An iOS app restored from a backup or moved to a new iPhone cannot start as a fresh install because opting the iOS app out of backup is not implemented.</gap>
|
|
114
115
|
|
|
115
116
|
**Android.** Make an upload key once, outside the project, and never commit it:
|
|
116
117
|
|