create-disposabl-app 0.17.5 → 0.18.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/README.md +4 -0
- package/dist/disposabl.js +43 -10
- package/dist/index.js +64 -18
- package/dist/templates/default/apps/mobile/README.md +40 -0
- package/dist/templates/default/apps/mobile/app.config.js +46 -2
- package/dist/templates/default/apps/mobile/package.json +7 -1
- package/dist/templates/default/apps/mobile/plugins/with-android-signing.js +23 -1
- package/dist/templates/default/apps/mobile/scripts/fresh-android.mjs +24 -0
- package/dist/templates/default/apps/mobile/scripts/play-aab.mjs +176 -0
- package/dist/templates/default/apps/mobile/scripts/verify-play-aab.mjs +77 -0
- package/dist/templates/default/bun.lock +12 -3
- package/dist/templates/default/bunfig.toml +1 -0
- package/dist/templates/default/package.json +6 -2
- package/dist/templates/default/packages/backend/convex/files/guard.ts +2 -0
- package/dist/templates/default/packages/backend/convex/http.ts +11 -1
- package/dist/templates/default/packages/backend/convex/schema.ts +10 -0
- package/dist/templates/default/packages/backend/convex/telemetry.ts +12 -16
- package/dist/templates/default/packages/cli/build.ts +4 -0
- package/dist/templates/default/packages/cli/package.json +2 -1
- package/dist/templates/default/packages/cli/telemetry.ts +40 -3
- package/dist/templates/default/packages/disposabl-kit/PAYMENTS.md +2 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/account-deletion.tsx +111 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/consent-identity.tsx +50 -0
- package/dist/templates/default/packages/disposabl-kit/client/components/legal-page.tsx +12 -1
- package/dist/templates/default/packages/disposabl-kit/client/lib/telemetry-lease.ts +200 -0
- package/dist/templates/default/packages/disposabl-kit/client/lib/telemetry.ts +8 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/consent.tsx +23 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/legal/delete-account.tsx +6 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/legal/support.tsx +33 -0
- package/dist/templates/default/packages/disposabl-kit/client/routes/pricing.tsx +13 -0
- package/dist/templates/default/packages/disposabl-kit/client/routes/route.tsx +19 -2
- package/dist/templates/default/packages/disposabl-kit/client/vite.config.ts +1 -0
- package/dist/templates/default/packages/disposabl-kit/legal/README.md +1 -1
- package/dist/templates/default/packages/disposabl-kit/legal/config.ts +32 -4
- package/dist/templates/default/packages/disposabl-kit/legal/index.ts +2 -2
- package/dist/templates/default/packages/disposabl-kit/legal/publisher.ts +6 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/account-billing.tsx +13 -9
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/paywall.ts +28 -4
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/policy.ts +31 -14
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/web-checkout.ts +45 -34
- package/dist/templates/default/packages/disposabl-kit/mobile/components/settings-links.tsx +14 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/expo-plugin.cjs +3 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/index.ts +4 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/layout.tsx +55 -8
- package/dist/templates/default/packages/disposabl-kit/server/billing-functions.ts +147 -124
- package/dist/templates/default/packages/disposabl-kit/server/billing-handoff.ts +113 -95
- package/dist/templates/default/packages/disposabl-kit/server/files-functions.ts +70 -54
- package/dist/templates/default/packages/disposabl-kit/server/http.ts +49 -21
- package/dist/templates/default/packages/disposabl-kit/server/lib/platform-spec.ts +25 -1
- package/dist/templates/default/packages/disposabl-kit/server/lib/telemetry.ts +375 -69
- package/dist/templates/default/packages/disposabl-kit/server/release/clients.mjs +28 -1
- package/dist/templates/default/packages/disposabl-kit/server/release/verify-metadata.mjs +64 -0
- package/dist/templates/default/packages/sdk/README.md +2 -0
- package/dist/templates/default/packages/sdk/build.ts +8 -0
- package/dist/templates/default/packages/sdk/package.json +3 -2
- package/dist/templates/default/packages/sdk/src/analytics.ts +7 -2
- package/dist/templates/default/packages/skill/SKILL.md +4 -2
- package/dist/templates/default/packages/skill/references/store-submissions.md +25 -0
- package/dist/templates/default/packages/tests/README.md +28 -1
- package/dist/templates/default/packages/tests/account-deletion-ui.test.ts +21 -0
- package/dist/templates/default/packages/tests/auth-email-setup.test.ts +45 -0
- package/dist/templates/default/packages/tests/components/account-deletion.test.mjs +82 -0
- package/dist/templates/default/packages/tests/components/consent-identity.test.mjs +175 -0
- package/dist/templates/default/packages/tests/components/mobile-deletion-link.test.mjs +40 -0
- package/dist/templates/default/packages/tests/components/mobile-theme.test.mjs +56 -3
- package/dist/templates/default/packages/tests/components/pricing-identity.test.mjs +113 -0
- package/dist/templates/default/packages/tests/components/support-page.test.mjs +36 -0
- package/dist/templates/default/packages/tests/consent-identity.test.ts +13 -0
- package/dist/templates/default/packages/tests/desktop-macos-release.test.ts +153 -145
- package/dist/templates/default/packages/tests/flows/legal.e2e.ts +40 -3
- package/dist/templates/default/packages/tests/helpers/auth-email-setup/probe.test.mjs +44 -0
- package/dist/templates/default/packages/tests/helpers/mobile-simulator/preflight.py +80 -0
- package/dist/templates/default/packages/tests/helpers/mobile-simulator/test_preflight.py +57 -0
- package/dist/templates/default/packages/tests/mobile-android-e2e-network.test.ts +81 -1
- package/dist/templates/default/packages/tests/mobile-android-signing.test.ts +52 -0
- package/dist/templates/default/packages/tests/mobile-deletion-link.test.ts +21 -0
- package/dist/templates/default/packages/tests/mobile-ios-reachability-pin.test.ts +84 -0
- package/dist/templates/default/packages/tests/mobile-simulator-preflight.test.ts +16 -0
- package/dist/templates/default/packages/tests/native-billing.test.ts +288 -0
- package/dist/templates/default/packages/tests/pricing-identity.test.ts +13 -0
- package/dist/templates/default/packages/tests/sdk-analytics.test.ts +28 -2
- package/dist/templates/default/packages/tests/support-page.test.ts +13 -0
- package/dist/templates/default/packages/tests/telemetry.test.ts +389 -18
- package/dist/templates/default/packages/tests/ui-telemetry-lease.test.ts +346 -0
- package/dist/templates/default/patches/convex-mcp-account-erasure-alpha7.patch +466 -0
- package/dist/templates/default/vendor/README.md +61 -1
- package/dist/templates/default/vendor/convex-auth-040d8e36-disposabl.1.patch +890 -0
- package/dist/templates/default/vendor/convex-auth-040d8e36-disposabl.1.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-040d8e36-disposabl.2.patch +1060 -0
- package/dist/templates/default/vendor/convex-auth-040d8e36-disposabl.2.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.4.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.5.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.6.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.7.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-437831bd-disposabl.8.tgz +0 -0
- package/dist/templates/default/vendor/convex-auth-core-erasure-disposabl.6.patch +115 -0
- package/dist/templates/default/vendor/convex-auth-identity-cutoff-disposabl.7.patch +442 -0
- package/dist/templates/default/vendor/convex-auth-identity-erasure-disposabl.8.md +11 -0
- package/dist/templates/default/vendor/convex-auth-identity-erasure-disposabl.8.patch +78 -0
- package/dist/templates/default/vendor/convex-auth-marker-disposabl.4.patch +169 -0
- package/dist/templates/default/vendor/convex-auth-marker-password-disposabl.5.patch +126 -0
- package/dist/verify-metadata.mjs +64 -0
- package/package.json +3 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { test } from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
+
import project from "../../disposabl.json";
|
|
4
5
|
|
|
6
|
+
const selectedFeatures: readonly string[] = project.features;
|
|
5
7
|
const require = createRequire(import.meta.url);
|
|
6
8
|
const configure = require("../../apps/mobile/app.config.js");
|
|
7
9
|
const network = require("../../apps/mobile/plugins/with-e2e-network.js");
|
|
@@ -9,6 +11,9 @@ const keys = [
|
|
|
9
11
|
"EXPO_PUBLIC_E2E",
|
|
10
12
|
"E2E_ANDROID_LOOPBACK",
|
|
11
13
|
"EXPO_PUBLIC_CONVEX_URL",
|
|
14
|
+
"EXPO_PUBLIC_CONVEX_SITE_URL",
|
|
15
|
+
"CONVEX_URL",
|
|
16
|
+
"CONVEX_SITE_URL",
|
|
12
17
|
"E2E_ANDROID_APP_ID",
|
|
13
18
|
"E2E_ANDROID_SCHEME",
|
|
14
19
|
"DISPOSABL_MOBILE_CHANNEL",
|
|
@@ -75,7 +80,14 @@ test("E2E loopback configuration has isolated identity, scheme, updates and netw
|
|
|
75
80
|
config.android.package,
|
|
76
81
|
"app.disposabl.androidround10.preview",
|
|
77
82
|
);
|
|
78
|
-
assert.
|
|
83
|
+
assert.equal(config.scheme[0], "disposabl-androidround10-preview");
|
|
84
|
+
if (selectedFeatures.includes("payments")) {
|
|
85
|
+
assert.equal(config.scheme.length, 2);
|
|
86
|
+
assert.match(
|
|
87
|
+
config.scheme[1],
|
|
88
|
+
/^disposabl-billing-[a-f0-9]{12}-development$/,
|
|
89
|
+
);
|
|
90
|
+
} else assert.equal(config.scheme.length, 1);
|
|
79
91
|
assert.equal(config.updates.enabled, false);
|
|
80
92
|
assert.ok(config.plugins.includes("./plugins/with-e2e-network.js"));
|
|
81
93
|
assert.equal(
|
|
@@ -110,3 +122,71 @@ test("E2E without loopback opt-in does not add cleartext policy", () => {
|
|
|
110
122
|
);
|
|
111
123
|
});
|
|
112
124
|
});
|
|
125
|
+
|
|
126
|
+
test("Android bundle inputs include every public RevenueCat purchase setting", async () => {
|
|
127
|
+
const { readFile } = await import("node:fs/promises");
|
|
128
|
+
const { resolve } = await import("node:path");
|
|
129
|
+
const plugin = await readFile(
|
|
130
|
+
resolve(import.meta.dirname, "../disposabl-kit/mobile/expo-plugin.cjs"),
|
|
131
|
+
"utf8",
|
|
132
|
+
);
|
|
133
|
+
for (const name of [
|
|
134
|
+
"EXPO_PUBLIC_REVENUECAT_ANDROID_API_KEY",
|
|
135
|
+
"EXPO_PUBLIC_REVENUECAT_ANDROID_MONTHLY_PRODUCT",
|
|
136
|
+
"EXPO_PUBLIC_REVENUECAT_ANDROID_APP_ID",
|
|
137
|
+
"EXPO_PUBLIC_REVENUECAT_ANDROID_TOPUP_PRODUCT",
|
|
138
|
+
"EXPO_PUBLIC_REVENUECAT_OFFERING_ID",
|
|
139
|
+
])
|
|
140
|
+
assert.match(
|
|
141
|
+
plugin,
|
|
142
|
+
new RegExp(`inputs\\.property\\([^\\n]*System\\.getenv\\("${name}"\\)`),
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("isolated payment builds keep their billing return scheme", async () => {
|
|
147
|
+
const { copyFile, mkdir, mkdtemp, writeFile } =
|
|
148
|
+
await import("node:fs/promises");
|
|
149
|
+
const { join, resolve } = await import("node:path");
|
|
150
|
+
const { tmpdir } = await import("node:os");
|
|
151
|
+
const root = await mkdtemp(join(tmpdir(), "mobile-billing-config-"));
|
|
152
|
+
await mkdir(join(root, "apps/mobile"), { recursive: true });
|
|
153
|
+
await copyFile(
|
|
154
|
+
resolve(import.meta.dirname, "../../apps/mobile/app.config.js"),
|
|
155
|
+
join(root, "apps/mobile/app.config.cjs"),
|
|
156
|
+
);
|
|
157
|
+
await writeFile(
|
|
158
|
+
join(root, "package.json"),
|
|
159
|
+
JSON.stringify({ name: "synthetic" }),
|
|
160
|
+
);
|
|
161
|
+
const isolated = require(join(root, "apps/mobile/app.config.cjs"));
|
|
162
|
+
for (const enabled of [false, true]) {
|
|
163
|
+
await writeFile(
|
|
164
|
+
join(root, "disposabl.json"),
|
|
165
|
+
JSON.stringify({
|
|
166
|
+
features: enabled ? ["authentication", "payments"] : ["authentication"],
|
|
167
|
+
}),
|
|
168
|
+
);
|
|
169
|
+
withEnv(
|
|
170
|
+
{
|
|
171
|
+
EXPO_PUBLIC_E2E: "true",
|
|
172
|
+
E2E_ANDROID_SCHEME: "isolated-test",
|
|
173
|
+
DISPOSABL_MOBILE_CHANNEL: "preview",
|
|
174
|
+
},
|
|
175
|
+
() => {
|
|
176
|
+
const result = isolated({ config: {} });
|
|
177
|
+
assert.equal(result.scheme[0], "isolated-test");
|
|
178
|
+
assert.equal(result.updates.enabled, false);
|
|
179
|
+
if (enabled) {
|
|
180
|
+
assert.match(
|
|
181
|
+
result.scheme[1],
|
|
182
|
+
/^disposabl-billing-[a-f0-9]{12}-preview$/,
|
|
183
|
+
);
|
|
184
|
+
assert.equal(result.extra.billingReturnChannel, "preview");
|
|
185
|
+
} else {
|
|
186
|
+
assert.equal(result.scheme.length, 1);
|
|
187
|
+
assert.equal(result.extra?.billingReturnChannel, undefined);
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const withSigning = require("../../apps/mobile/plugins/with-android-signing.js");
|
|
7
|
+
|
|
8
|
+
async function generate(contents = "android {}", twice = false) {
|
|
9
|
+
let config = withSigning({});
|
|
10
|
+
if (twice) config = withSigning(config);
|
|
11
|
+
const result = await config.mods.android.appBuildGradle({
|
|
12
|
+
...config,
|
|
13
|
+
modResults: { language: "groovy", contents },
|
|
14
|
+
modRequest: {},
|
|
15
|
+
});
|
|
16
|
+
return result.modResults.contents as string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
test("production signing remains designated and fails closed without embedding inputs", async () => {
|
|
20
|
+
const previous = process.env.ANDROID_KEYSTORE_PATH;
|
|
21
|
+
try {
|
|
22
|
+
delete process.env.ANDROID_KEYSTORE_PATH;
|
|
23
|
+
const withoutPath = await generate();
|
|
24
|
+
process.env.ANDROID_KEYSTORE_PATH = "synthetic-private-path-marker";
|
|
25
|
+
const withPath = await generate();
|
|
26
|
+
assert.equal(withoutPath, withPath);
|
|
27
|
+
assert.doesNotMatch(withPath, /synthetic-private-path-marker/);
|
|
28
|
+
assert.match(withPath, /if \(storePath\) storeFile file\(storePath\)/);
|
|
29
|
+
assert.match(
|
|
30
|
+
withPath,
|
|
31
|
+
/buildTypes\.release\.signingConfig = signingConfigs\.disposablRelease/,
|
|
32
|
+
);
|
|
33
|
+
assert.match(withPath, /required\.any \{ !System\.getenv\(it\) \}/);
|
|
34
|
+
assert.match(withPath, /selector\(\)\.withBuildType\("release"\)/);
|
|
35
|
+
assert.match(withPath, /releaseVariants\.contains\(task\.variantName\)/);
|
|
36
|
+
} finally {
|
|
37
|
+
if (previous === undefined) delete process.env.ANDROID_KEYSTORE_PATH;
|
|
38
|
+
else process.env.ANDROID_KEYSTORE_PATH = previous;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("preview keeps Expo signing and plugin application is idempotent", async () => {
|
|
43
|
+
const result = await generate("android {}", true);
|
|
44
|
+
assert.match(
|
|
45
|
+
result,
|
|
46
|
+
/if \(System\.getenv\("DISPOSABL_ANDROID_CHANNEL"\) == "production"\)/,
|
|
47
|
+
);
|
|
48
|
+
assert.equal(
|
|
49
|
+
result.split("// Disposabl production APK signing.").length - 1,
|
|
50
|
+
1,
|
|
51
|
+
);
|
|
52
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
test("mobile settings link to deletion when authentication is enabled", () => {
|
|
7
|
+
for (const disabled of ["true", "false"]) {
|
|
8
|
+
const result = spawnSync(
|
|
9
|
+
process.execPath,
|
|
10
|
+
[
|
|
11
|
+
"test",
|
|
12
|
+
join(import.meta.dirname, "components/mobile-deletion-link.test.mjs"),
|
|
13
|
+
],
|
|
14
|
+
{
|
|
15
|
+
encoding: "utf8",
|
|
16
|
+
env: { ...process.env, TEST_AUTH_DISABLED: disabled },
|
|
17
|
+
},
|
|
18
|
+
);
|
|
19
|
+
assert.equal(result.status, 0, result.stdout + result.stderr);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const configure = require("../../apps/mobile/app.config.js");
|
|
7
|
+
const mobile = require("../../apps/mobile/package.json");
|
|
8
|
+
|
|
9
|
+
function isolatedConfig(config: object) {
|
|
10
|
+
const keys = [
|
|
11
|
+
"CONVEX_URL",
|
|
12
|
+
"CONVEX_SITE_URL",
|
|
13
|
+
"EXPO_PUBLIC_CONVEX_URL",
|
|
14
|
+
"EXPO_PUBLIC_CONVEX_SITE_URL",
|
|
15
|
+
];
|
|
16
|
+
const saved = keys.map((key) => process.env[key]);
|
|
17
|
+
try {
|
|
18
|
+
for (const key of keys) delete process.env[key];
|
|
19
|
+
return configure(config);
|
|
20
|
+
} finally {
|
|
21
|
+
for (const [index, key] of keys.entries()) {
|
|
22
|
+
if (saved[index] === undefined) delete process.env[key];
|
|
23
|
+
else process.env[key] = saved[index];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
test("iOS build properties constrain the Expo Updates reachability pod", () => {
|
|
29
|
+
const config = isolatedConfig({ config: { plugins: ["existing-plugin"] } });
|
|
30
|
+
const properties = config.plugins.filter(
|
|
31
|
+
(plugin: unknown) =>
|
|
32
|
+
Array.isArray(plugin) && plugin[0] === "expo-build-properties",
|
|
33
|
+
);
|
|
34
|
+
assert.deepEqual(properties, [
|
|
35
|
+
[
|
|
36
|
+
"expo-build-properties",
|
|
37
|
+
{
|
|
38
|
+
ios: { extraPods: [{ name: "ReachabilitySwift", version: "5.2.3" }] },
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
]);
|
|
42
|
+
assert.ok(config.plugins.includes("existing-plugin"));
|
|
43
|
+
assert.ok(config.plugins.includes("./plugins/with-android-signing.js"));
|
|
44
|
+
assert.equal(mobile.dependencies["expo-build-properties"], "~58.0.11");
|
|
45
|
+
assert.ok(mobile.expo.autolinking.ios.buildFromSource.includes("expo-image"));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("iOS pod pin preserves existing build properties in one plugin", () => {
|
|
49
|
+
const config = isolatedConfig({
|
|
50
|
+
config: {
|
|
51
|
+
plugins: [
|
|
52
|
+
"expo-build-properties",
|
|
53
|
+
[
|
|
54
|
+
"expo-build-properties",
|
|
55
|
+
{
|
|
56
|
+
ios: {
|
|
57
|
+
deploymentTarget: "16.0",
|
|
58
|
+
extraPods: [
|
|
59
|
+
{ name: "CustomPod", version: "1.2.3" },
|
|
60
|
+
{ name: "ReachabilitySwift", version: "5.2.4" },
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
android: { minSdkVersion: 28 },
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
const properties = config.plugins.filter(
|
|
70
|
+
(plugin: unknown) =>
|
|
71
|
+
Array.isArray(plugin) && plugin[0] === "expo-build-properties",
|
|
72
|
+
);
|
|
73
|
+
assert.equal(properties.length, 1);
|
|
74
|
+
assert.deepEqual(properties[0][1], {
|
|
75
|
+
android: { minSdkVersion: 28 },
|
|
76
|
+
ios: {
|
|
77
|
+
deploymentTarget: "16.0",
|
|
78
|
+
extraPods: [
|
|
79
|
+
{ name: "CustomPod", version: "1.2.3" },
|
|
80
|
+
{ name: "ReachabilitySwift", version: "5.2.3" },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
test("simulator preflight validates platform, entitlements and inputs", () => {
|
|
7
|
+
const directory = fileURLToPath(
|
|
8
|
+
new URL("./helpers/mobile-simulator", import.meta.url),
|
|
9
|
+
);
|
|
10
|
+
const result = spawnSync(
|
|
11
|
+
"python3",
|
|
12
|
+
["-m", "unittest", "discover", "-s", directory, "-p", "test_preflight.py"],
|
|
13
|
+
{ encoding: "utf8" },
|
|
14
|
+
);
|
|
15
|
+
assert.equal(result.status, 0, result.stderr);
|
|
16
|
+
});
|
|
@@ -557,3 +557,291 @@ test("web top-up preflight rechecks storefront, product, route and account indep
|
|
|
557
557
|
),
|
|
558
558
|
);
|
|
559
559
|
});
|
|
560
|
+
|
|
561
|
+
test("explicit monthly offering is consistent across readiness, paywall, and web preflight", async () => {
|
|
562
|
+
const { presentMonthlyPaywall, selectMonthlyOffering } =
|
|
563
|
+
await import("../disposabl-kit/mobile/billing/paywall");
|
|
564
|
+
const monthly = {
|
|
565
|
+
product: { identifier: "monthly", subscriptionPeriod: "P1M" },
|
|
566
|
+
};
|
|
567
|
+
const other = {
|
|
568
|
+
product: { identifier: "yearly", subscriptionPeriod: "P1Y" },
|
|
569
|
+
};
|
|
570
|
+
const good = { identifier: "safe", availablePackages: [monthly] };
|
|
571
|
+
const mixed = { identifier: "mixed", availablePackages: [monthly, other] };
|
|
572
|
+
const wrong = { identifier: "wrong", availablePackages: [other] };
|
|
573
|
+
const wrongPeriod = {
|
|
574
|
+
identifier: "period",
|
|
575
|
+
availablePackages: [
|
|
576
|
+
{ product: { identifier: "monthly", subscriptionPeriod: "P1Y" } },
|
|
577
|
+
],
|
|
578
|
+
};
|
|
579
|
+
const offerings = {
|
|
580
|
+
current: mixed,
|
|
581
|
+
all: { safe: good, mixed, wrong, period: wrongPeriod },
|
|
582
|
+
};
|
|
583
|
+
const snapshot = async () => ({
|
|
584
|
+
balance: 0,
|
|
585
|
+
hasMonthlyPlan: false,
|
|
586
|
+
nativeSubscriptionsEnabled: true,
|
|
587
|
+
monthlyCheckoutPending: false,
|
|
588
|
+
mobileWebCheckoutEnabled: true,
|
|
589
|
+
customerId: "alice",
|
|
590
|
+
});
|
|
591
|
+
let current = true;
|
|
592
|
+
const sdk = {
|
|
593
|
+
canMakePayments: async () => true,
|
|
594
|
+
getStorefront: async () => ({ countryCode: "USA" }),
|
|
595
|
+
getCustomerInfo: async () => ({ activeSubscriptions: [] }),
|
|
596
|
+
getOfferings: async () => offerings,
|
|
597
|
+
};
|
|
598
|
+
let shown: unknown;
|
|
599
|
+
const show = async (offering: unknown) => {
|
|
600
|
+
shown = offering;
|
|
601
|
+
return "cancelled" as const;
|
|
602
|
+
};
|
|
603
|
+
const paywall = (id?: string) =>
|
|
604
|
+
presentMonthlyPaywall(
|
|
605
|
+
sdk as never,
|
|
606
|
+
snapshot,
|
|
607
|
+
() => current,
|
|
608
|
+
"monthly",
|
|
609
|
+
show,
|
|
610
|
+
id,
|
|
611
|
+
);
|
|
612
|
+
const web = (id?: string) =>
|
|
613
|
+
preflightWebMonthly(
|
|
614
|
+
sdk as never,
|
|
615
|
+
"ios",
|
|
616
|
+
"monthly",
|
|
617
|
+
"alice",
|
|
618
|
+
snapshot,
|
|
619
|
+
() => current,
|
|
620
|
+
id,
|
|
621
|
+
);
|
|
622
|
+
for (const id of [undefined, "missing", "wrong", "period", "mixed"]) {
|
|
623
|
+
assert.equal(
|
|
624
|
+
selectMonthlyOffering(offerings as never, "monthly", id),
|
|
625
|
+
null,
|
|
626
|
+
);
|
|
627
|
+
await assert.rejects(paywall(id), /unavailable/);
|
|
628
|
+
await assert.rejects(web(id), /unavailable/);
|
|
629
|
+
}
|
|
630
|
+
assert.equal(
|
|
631
|
+
selectMonthlyOffering(offerings as never, "monthly", "safe"),
|
|
632
|
+
good as never,
|
|
633
|
+
);
|
|
634
|
+
await paywall("safe");
|
|
635
|
+
assert.equal(shown, good);
|
|
636
|
+
await web("safe");
|
|
637
|
+
const withCurrent = { ...offerings, current: good };
|
|
638
|
+
assert.equal(
|
|
639
|
+
selectMonthlyOffering(withCurrent as never, "monthly"),
|
|
640
|
+
good as never,
|
|
641
|
+
);
|
|
642
|
+
const defaultSdk = { ...sdk, getOfferings: async () => withCurrent };
|
|
643
|
+
await presentMonthlyPaywall(
|
|
644
|
+
defaultSdk as never,
|
|
645
|
+
snapshot,
|
|
646
|
+
() => current,
|
|
647
|
+
"monthly",
|
|
648
|
+
show,
|
|
649
|
+
);
|
|
650
|
+
await preflightWebMonthly(
|
|
651
|
+
defaultSdk as never,
|
|
652
|
+
"ios",
|
|
653
|
+
"monthly",
|
|
654
|
+
"alice",
|
|
655
|
+
snapshot,
|
|
656
|
+
() => current,
|
|
657
|
+
);
|
|
658
|
+
|
|
659
|
+
const delayed = deferred();
|
|
660
|
+
const started = deferred();
|
|
661
|
+
const changingSdk = {
|
|
662
|
+
...sdk,
|
|
663
|
+
getOfferings: async () => {
|
|
664
|
+
started.resolve();
|
|
665
|
+
await delayed.promise;
|
|
666
|
+
return offerings;
|
|
667
|
+
},
|
|
668
|
+
};
|
|
669
|
+
const pendingPaywall = presentMonthlyPaywall(
|
|
670
|
+
changingSdk as never,
|
|
671
|
+
snapshot,
|
|
672
|
+
() => current,
|
|
673
|
+
"monthly",
|
|
674
|
+
show,
|
|
675
|
+
"safe",
|
|
676
|
+
);
|
|
677
|
+
await started.promise;
|
|
678
|
+
current = false;
|
|
679
|
+
delayed.resolve();
|
|
680
|
+
await assert.rejects(pendingPaywall, /Account changed/);
|
|
681
|
+
current = true;
|
|
682
|
+
const delayedWeb = deferred();
|
|
683
|
+
const startedWeb = deferred();
|
|
684
|
+
const changingWebSdk = {
|
|
685
|
+
...sdk,
|
|
686
|
+
getOfferings: async () => {
|
|
687
|
+
startedWeb.resolve();
|
|
688
|
+
await delayedWeb.promise;
|
|
689
|
+
return offerings;
|
|
690
|
+
},
|
|
691
|
+
};
|
|
692
|
+
const pendingWeb = preflightWebMonthly(
|
|
693
|
+
changingWebSdk as never,
|
|
694
|
+
"ios",
|
|
695
|
+
"monthly",
|
|
696
|
+
"alice",
|
|
697
|
+
snapshot,
|
|
698
|
+
() => current,
|
|
699
|
+
"safe",
|
|
700
|
+
);
|
|
701
|
+
await startedWeb.promise;
|
|
702
|
+
current = false;
|
|
703
|
+
delayedWeb.resolve();
|
|
704
|
+
await assert.rejects(pendingWeb, /Account changed/);
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
test("web handoff rechecks the storefront and account after link creation", async () => {
|
|
708
|
+
const { guardedWebHandoff, preflightWebMonthly, preflightWebTopup } =
|
|
709
|
+
await import("../disposabl-kit/mobile/billing/policy");
|
|
710
|
+
let country: string | null = "USA";
|
|
711
|
+
let storefrontError = false;
|
|
712
|
+
let restricted = false;
|
|
713
|
+
let current = true;
|
|
714
|
+
let changeRegionDuringLookup = false;
|
|
715
|
+
const monthly = {
|
|
716
|
+
product: { identifier: "monthly", subscriptionPeriod: "P1M" },
|
|
717
|
+
};
|
|
718
|
+
const offering = { availablePackages: [monthly] };
|
|
719
|
+
const product = {
|
|
720
|
+
identifier: "coins",
|
|
721
|
+
productCategory: "NON_SUBSCRIPTION",
|
|
722
|
+
productType: "CONSUMABLE",
|
|
723
|
+
priceString: "$5",
|
|
724
|
+
};
|
|
725
|
+
const sdk = {
|
|
726
|
+
canMakePayments: async () => !restricted,
|
|
727
|
+
getStorefront: async () => {
|
|
728
|
+
if (storefrontError) throw new Error("unavailable");
|
|
729
|
+
return country === null ? null : { countryCode: country };
|
|
730
|
+
},
|
|
731
|
+
getCustomerInfo: async () => ({ activeSubscriptions: [] }),
|
|
732
|
+
getOfferings: async () => {
|
|
733
|
+
if (changeRegionDuringLookup) country = "CAN";
|
|
734
|
+
return { current: null, all: { dedicated: offering } };
|
|
735
|
+
},
|
|
736
|
+
getAppUserID: async () => "alice",
|
|
737
|
+
getProducts: async () => {
|
|
738
|
+
if (changeRegionDuringLookup) country = "CAN";
|
|
739
|
+
return [product];
|
|
740
|
+
},
|
|
741
|
+
PRODUCT_CATEGORY: { NON_SUBSCRIPTION: "NON_SUBSCRIPTION" },
|
|
742
|
+
};
|
|
743
|
+
const snapshot = async () => ({
|
|
744
|
+
balance: 0,
|
|
745
|
+
customerId: "alice",
|
|
746
|
+
hasMonthlyPlan: false,
|
|
747
|
+
monthlyCheckoutPending: false,
|
|
748
|
+
nativeSubscriptionsEnabled: true,
|
|
749
|
+
mobileWebCheckoutEnabled: true,
|
|
750
|
+
nativeTopupRoutes: [{ app: "apple", store: "APP_STORE", product: "coins" }],
|
|
751
|
+
});
|
|
752
|
+
for (const kind of ["monthly", "topup"]) {
|
|
753
|
+
const preflight = () =>
|
|
754
|
+
kind === "monthly"
|
|
755
|
+
? preflightWebMonthly(
|
|
756
|
+
sdk as never,
|
|
757
|
+
"ios",
|
|
758
|
+
"monthly",
|
|
759
|
+
"alice",
|
|
760
|
+
snapshot,
|
|
761
|
+
() => current,
|
|
762
|
+
"dedicated",
|
|
763
|
+
)
|
|
764
|
+
: preflightWebTopup(
|
|
765
|
+
sdk as never,
|
|
766
|
+
"ios",
|
|
767
|
+
"apple",
|
|
768
|
+
"coins",
|
|
769
|
+
"alice",
|
|
770
|
+
snapshot,
|
|
771
|
+
() => current,
|
|
772
|
+
);
|
|
773
|
+
let created = 0;
|
|
774
|
+
const create = async () => {
|
|
775
|
+
created++;
|
|
776
|
+
return "https://example.test/billing-login";
|
|
777
|
+
};
|
|
778
|
+
country = "USA";
|
|
779
|
+
current = true;
|
|
780
|
+
assert.equal(
|
|
781
|
+
await guardedWebHandoff(preflight, create, () => current),
|
|
782
|
+
"https://example.test/billing-login",
|
|
783
|
+
);
|
|
784
|
+
country = "CAN";
|
|
785
|
+
await assert.rejects(
|
|
786
|
+
guardedWebHandoff(preflight, create, () => current),
|
|
787
|
+
/unavailable/,
|
|
788
|
+
);
|
|
789
|
+
assert.equal(created, 1);
|
|
790
|
+
country = "USA";
|
|
791
|
+
await assert.rejects(
|
|
792
|
+
guardedWebHandoff(
|
|
793
|
+
preflight,
|
|
794
|
+
async () => {
|
|
795
|
+
country = "CAN";
|
|
796
|
+
return "link";
|
|
797
|
+
},
|
|
798
|
+
() => current,
|
|
799
|
+
),
|
|
800
|
+
/unavailable/,
|
|
801
|
+
);
|
|
802
|
+
for (const mode of ["unknown", "error", "restricted"]) {
|
|
803
|
+
country = "USA";
|
|
804
|
+
storefrontError = false;
|
|
805
|
+
restricted = false;
|
|
806
|
+
await assert.rejects(
|
|
807
|
+
guardedWebHandoff(
|
|
808
|
+
preflight,
|
|
809
|
+
async () => {
|
|
810
|
+
if (mode === "unknown") country = null;
|
|
811
|
+
if (mode === "error") storefrontError = true;
|
|
812
|
+
if (mode === "restricted") restricted = true;
|
|
813
|
+
return "link";
|
|
814
|
+
},
|
|
815
|
+
() => current,
|
|
816
|
+
),
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
country = "USA";
|
|
820
|
+
storefrontError = false;
|
|
821
|
+
restricted = false;
|
|
822
|
+
await assert.rejects(
|
|
823
|
+
guardedWebHandoff(
|
|
824
|
+
preflight,
|
|
825
|
+
async () => {
|
|
826
|
+
changeRegionDuringLookup = true;
|
|
827
|
+
return "link";
|
|
828
|
+
},
|
|
829
|
+
() => current,
|
|
830
|
+
),
|
|
831
|
+
/unavailable/,
|
|
832
|
+
);
|
|
833
|
+
changeRegionDuringLookup = false;
|
|
834
|
+
country = "USA";
|
|
835
|
+
await assert.rejects(
|
|
836
|
+
guardedWebHandoff(
|
|
837
|
+
preflight,
|
|
838
|
+
async () => {
|
|
839
|
+
current = false;
|
|
840
|
+
return "link";
|
|
841
|
+
},
|
|
842
|
+
() => current,
|
|
843
|
+
),
|
|
844
|
+
/Account changed/,
|
|
845
|
+
);
|
|
846
|
+
}
|
|
847
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
test("pricing shows only the current authenticated account", () => {
|
|
7
|
+
const result = spawnSync(
|
|
8
|
+
process.execPath,
|
|
9
|
+
["test", join(import.meta.dirname, "components/pricing-identity.test.mjs")],
|
|
10
|
+
{ encoding: "utf8", env: process.env },
|
|
11
|
+
);
|
|
12
|
+
assert.equal(result.status, 0, result.stdout + result.stderr);
|
|
13
|
+
});
|
|
@@ -5,11 +5,37 @@ import { createSdkAnalytics } from "../sdk/src/analytics";
|
|
|
5
5
|
const inheritedFlags = {
|
|
6
6
|
E2E_TELEMETRY_DISABLED: process.env.E2E_TELEMETRY_DISABLED,
|
|
7
7
|
DO_NOT_TRACK: process.env.DO_NOT_TRACK,
|
|
8
|
+
DISPOSABL_TELEMETRY_DISABLED: process.env.DISPOSABL_TELEMETRY_DISABLED,
|
|
9
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
10
|
+
BUN_ENV: process.env.BUN_ENV,
|
|
11
|
+
CI: process.env.CI,
|
|
8
12
|
};
|
|
9
13
|
beforeEach(() => {
|
|
10
14
|
// These tests use in-memory sinks only; each opt-out is exercised explicitly.
|
|
11
|
-
delete process.env
|
|
12
|
-
|
|
15
|
+
for (const key of Object.keys(inheritedFlags)) delete process.env[key];
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("runtime opt-out and local execution override an explicit production configuration", async () => {
|
|
19
|
+
const events: unknown[] = [];
|
|
20
|
+
const analytics = createSdkAnalytics({
|
|
21
|
+
environment: "production",
|
|
22
|
+
capture: (event) => {
|
|
23
|
+
events.push(event);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
for (const [key, value] of Object.entries({
|
|
27
|
+
NODE_ENV: "development",
|
|
28
|
+
BUN_ENV: "test",
|
|
29
|
+
CI: "true",
|
|
30
|
+
E2E_TELEMETRY_DISABLED: "1",
|
|
31
|
+
DISPOSABL_TELEMETRY_DISABLED: "1",
|
|
32
|
+
DO_NOT_TRACK: "true",
|
|
33
|
+
})) {
|
|
34
|
+
process.env[key] = value;
|
|
35
|
+
await analytics.track("appsList", async () => ({}));
|
|
36
|
+
delete process.env[key];
|
|
37
|
+
}
|
|
38
|
+
assert.deepEqual(events, []);
|
|
13
39
|
});
|
|
14
40
|
afterEach(() => {
|
|
15
41
|
for (const [key, value] of Object.entries(inheritedFlags)) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
test("support page shows the configured contact or an unconfigured state", () => {
|
|
7
|
+
const result = spawnSync(
|
|
8
|
+
process.execPath,
|
|
9
|
+
["test", join(import.meta.dirname, "components/support-page.test.mjs")],
|
|
10
|
+
{ encoding: "utf8" },
|
|
11
|
+
);
|
|
12
|
+
assert.equal(result.status, 0, result.stdout + result.stderr);
|
|
13
|
+
});
|