create-disposabl-app 0.17.4 → 0.17.6

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/disposabl.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // ../cli/auth.ts
4
4
  import { lock } from "proper-lockfile";
5
5
  // ../cli/package.json
6
- var version = "0.17.4";
6
+ var version = "0.17.6";
7
7
  var package_default = {
8
8
  name: "@disposabl/cli",
9
9
  version,
@@ -14,7 +14,7 @@ var package_default = {
14
14
  files: ["dist", "README.md"],
15
15
  engines: { node: ">=22.12.0" },
16
16
  publishConfig: { access: "public" },
17
- scripts: { build: "bun build.ts", typecheck: "bun check", lint: "bun check", release: "semantic-release" },
17
+ scripts: { build: "bun build.ts", typecheck: "bun check", lint: "bun check", release: "semantic-release", prepack: "node dist/verify-metadata.mjs" },
18
18
  dependencies: { "@modelcontextprotocol/sdk": "1.32.2", commander: "15.0.0", "proper-lockfile": "4.1.2" },
19
19
  devDependencies: { "@types/bun": "1.4.4", typescript: "~6.0.3", "@types/proper-lockfile": "4.1.4", "semantic-release": "25.0.9", "@semantic-release/exec": "7.1.0", "conventional-changelog-conventionalcommits": "9.3.1" },
20
20
  repository: { type: "git", url: "git+https://github.com/disposabl-dev/create-disposabl-app.git", directory: "packages/cli" }
package/dist/index.js CHANGED
@@ -1563,7 +1563,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
1563
1563
  import { Command, CommanderError } from "commander";
1564
1564
  import * as p2 from "@clack/prompts";
1565
1565
  // package.json
1566
- var version = "0.17.4";
1566
+ var version = "0.17.6";
1567
1567
 
1568
1568
  // ../cli/telemetry.ts
1569
1569
  var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
@@ -11,5 +11,9 @@ const result = await Bun.build({
11
11
  : telemetryBuildDefine("0.0.0-development", {}),
12
12
  });
13
13
  if (!result.success) throw new AggregateError(result.logs, "CLI build failed");
14
+ await Bun.write(
15
+ "dist/verify-metadata.mjs",
16
+ Bun.file("../disposabl-kit/server/release/verify-metadata.mjs"),
17
+ );
14
18
 
15
19
  export {};
@@ -21,7 +21,8 @@
21
21
  "build": "bun build.ts",
22
22
  "typecheck": "bun check",
23
23
  "lint": "bun check",
24
- "release": "semantic-release"
24
+ "release": "semantic-release",
25
+ "prepack": "node dist/verify-metadata.mjs"
25
26
  },
26
27
  "dependencies": {
27
28
  "@modelcontextprotocol/sdk": "1.32.2",
@@ -48,7 +48,7 @@ Web checkout and native purchasing reject an existing or scheduled monthly plan,
48
48
 
49
49
  Native consumable top-ups use a separately fetched store product and the opt-in custom RevenueCat inbox; this is not provider or release proof. The native button remains disabled until the backend route and the public app and product IDs match and the operator explicitly verifies the integration. Its ownership must be exclusive: keep this top-up product out of Autumn's managed RevenueCat mapping, while managed subscriptions remain separate. Never enable custom grants for a product already granted by a managed integration. The inbox accepts an explicit allowlist of store apps and products within one RevenueCat project and environment.
50
50
 
51
- With payments selected, custom processing is disabled unless `REVENUECAT_CONSUMABLE_OWNER=custom`, `REVENUECAT_WEBHOOK_AUTH`, `REVENUECAT_PROJECT_ID`, `REVENUECAT_ENVIRONMENT` (`SANDBOX` or `PRODUCTION`), `REVENUECAT_ROUTES`, and `AUTUMN_SECRET_KEY` are present. `REVENUECAT_ROUTES` is a JSON array such as `[{"app":"apple-app-id","store":"APP_STORE","product":"apple-topup"},{"app":"google-app-id","store":"PLAY_STORE","product":"google-topup"}]`. Each app ID must be unique. Invalid or ambiguous configuration disables the inbox. Configure a distinct authorization for each project and environment, sent as the complete Authorization header to `/revenuecat/webhook`. RevenueCat payloads do not normally include a project ID: the project association depends on that credential; authenticated app ID, store, environment and product select the allowlisted route. Transfer events without an environment are rejected for review. Use separate test and live deployments and secrets. Payments-off never processes a webhook or makes an Autumn request.
51
+ With payments selected, custom processing is disabled unless `REVENUECAT_CONSUMABLE_OWNER=custom`, `REVENUECAT_WEBHOOK_AUTH`, `REVENUECAT_PROJECT_ID`, `REVENUECAT_ENVIRONMENT` (`SANDBOX` or `PRODUCTION`), `REVENUECAT_ROUTES`, and `AUTUMN_SECRET_KEY` are present. `REVENUECAT_ROUTES` is a JSON array such as `[{"app":"apple-app-id","store":"APP_STORE","product":"apple-topup"},{"app":"google-app-id","store":"PLAY_STORE","product":"google-topup"}]`. Each app ID must be unique. The inbox requires an `am_sk_test_` Autumn key for `SANDBOX` and an `am_sk_live_` key for `PRODUCTION`; a mismatched or unrecognized key disables intake and dispatch. The prefix is an environment guard, not proof that the key belongs to the intended Autumn organization. Invalid or ambiguous configuration disables the inbox. Configure a distinct authorization for each project and environment, sent as the complete Authorization header to `/revenuecat/webhook`. RevenueCat payloads do not normally include a project ID: the project association depends on that credential; authenticated app ID, store, environment and product select the allowlisted route. Transfer events without an environment are rejected for review. Use separate test and live deployments and secrets. Payments-off never processes a webhook or makes an Autumn request.
52
52
 
53
53
  After completing the verification below, an operator may explicitly set `REVENUECAT_CONSUMABLE_INTEGRATION_VERIFIED=true` on the matching backend. Set `EXPO_PUBLIC_REVENUECAT_IOS_APP_ID`, `EXPO_PUBLIC_REVENUECAT_ANDROID_APP_ID`, `EXPO_PUBLIC_REVENUECAT_IOS_TOPUP_PRODUCT`, and `EXPO_PUBLIC_REVENUECAT_ANDROID_TOPUP_PRODUCT` to the exact route values for each build. The SDK fetches the localized store price and verifies the product identifier and non-subscription category. On iOS it requires StoreKit 2 to identify the product as consumable; StoreKit 1 cannot prove this. On Android the SDK may report an unknown specific product type, so the operator must independently verify its consumable configuration. Do not enable based on category alone. The monthly RevenueCat offering remains separate and contains only the monthly product.
54
54
 
@@ -3,6 +3,7 @@ import { readFileSync, writeFileSync, realpathSync } from "node:fs";
3
3
  import { basename, relative, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { analyzeCommits as conventional } from "@semantic-release/commit-analyzer";
6
+ import { verifyMetadata } from "./verify-metadata.mjs";
6
7
 
7
8
  const contract = "packages/backend/generated/openapi.json";
8
9
  const git = (cwd, ...args) =>
@@ -86,14 +87,40 @@ export async function analyzeCommits(_, context) {
86
87
  return release;
87
88
  }
88
89
 
90
+ // Use semantic-release's original repository URL, before it injects Git credentials.
91
+ export function publicRepositoryUrl(original) {
92
+ if (typeof original !== "string")
93
+ throw new Error("Missing original repository URL");
94
+ const scp = /^(?:[^@/]+@)?([^:/]+):(.+)$/.exec(original);
95
+ const input =
96
+ scp && !original.includes("://")
97
+ ? `https://${scp[1]}/${scp[2]}`
98
+ : original.replace(/^git\+/, "");
99
+ let url;
100
+ try {
101
+ url = new URL(input);
102
+ } catch {
103
+ throw new Error("Invalid repository URL");
104
+ }
105
+ if (!["http:", "https:", "ssh:"].includes(url.protocol))
106
+ throw new Error("Unsupported repository URL");
107
+ if (url.protocol === "ssh:") return `git+https://${url.host}${url.pathname}`;
108
+ url.username = "";
109
+ url.password = "";
110
+ url.search = "";
111
+ url.hash = "";
112
+ return `git+${url.href}`;
113
+ }
114
+
89
115
  // Generated apps acquire their own repository metadata at release time.
90
116
  export function verifyConditions(_, { cwd, options }) {
91
117
  const path = resolve(cwd, "package.json");
92
118
  const manifest = JSON.parse(readFileSync(path, "utf8"));
93
119
  manifest.repository = {
94
120
  type: "git",
95
- url: options.repositoryUrl,
121
+ url: publicRepositoryUrl(options.originalRepositoryURL),
96
122
  directory: `packages/${basename(cwd)}`,
97
123
  };
124
+ verifyMetadata(manifest);
98
125
  writeFileSync(path, JSON.stringify(manifest, null, 2) + "\n");
99
126
  }
@@ -0,0 +1,64 @@
1
+ import { readFileSync, realpathSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+
5
+ // Package metadata must never publish authenticated or signed URLs.
6
+ export function verifyMetadata(manifest) {
7
+ function inspect(value, field) {
8
+ if (typeof value === "string") {
9
+ const candidate = value
10
+ .trim()
11
+ .replace(/[\u0000-\u0020]/g, "")
12
+ .replace(/^git\+/i, "");
13
+ if (
14
+ /^[a-z][a-z\d+.-]*:/i.test(candidate) ||
15
+ /^[\\/]{2}/.test(candidate)
16
+ ) {
17
+ let url;
18
+ try {
19
+ url = new URL(
20
+ candidate,
21
+ /^[\\/]{2}/.test(candidate)
22
+ ? "https://metadata.invalid"
23
+ : undefined,
24
+ );
25
+ } catch {
26
+ throw new Error(`Invalid URL in package metadata: ${field}`);
27
+ }
28
+ if (url.username || url.password || url.search || url.hash)
29
+ throw new Error(`Unsafe URL in package metadata: ${field}`);
30
+ } else if (/^[^/]+@[^/]+:/.test(candidate)) {
31
+ throw new Error(`Unsafe URL in package metadata: ${field}`);
32
+ }
33
+ } else if (Array.isArray(value)) {
34
+ value.forEach((item) => inspect(item, field));
35
+ } else if (value && typeof value === "object") {
36
+ for (const item of Object.values(value)) inspect(item, field);
37
+ }
38
+ }
39
+ for (const field of [
40
+ "repository",
41
+ "homepage",
42
+ "bugs",
43
+ "funding",
44
+ "author",
45
+ "contributors",
46
+ "maintainers",
47
+ "publishConfig",
48
+ ])
49
+ inspect(manifest[field], field);
50
+ }
51
+
52
+ if (
53
+ process.argv[1] &&
54
+ import.meta.url === pathToFileURL(realpathSync(resolve(process.argv[1]))).href
55
+ )
56
+ try {
57
+ verifyMetadata(
58
+ JSON.parse(readFileSync(process.argv[2] ?? "package.json", "utf8")),
59
+ );
60
+ } catch (error) {
61
+ if (error instanceof SyntaxError)
62
+ throw new Error("Invalid package metadata JSON");
63
+ throw error;
64
+ }
@@ -78,7 +78,13 @@ export function revenueCatConfigs(
78
78
  !authorization ||
79
79
  !project ||
80
80
  !autumnKey ||
81
- (environment !== "SANDBOX" && environment !== "PRODUCTION")
81
+ (environment !== "SANDBOX" && environment !== "PRODUCTION") ||
82
+ !autumnKey.startsWith(
83
+ environment === "SANDBOX" ? "am_sk_test_" : "am_sk_live_",
84
+ ) ||
85
+ autumnKey.length <= "am_sk_test_".length ||
86
+ autumnKey.length > 4096 ||
87
+ /\s/.test(autumnKey)
82
88
  )
83
89
  return null;
84
90
  let routes: unknown;
@@ -0,0 +1,8 @@
1
+ await Bun.$`bun run generate`;
2
+ await Bun.$`tsc -p tsconfig.build.json`;
3
+ await Bun.write(
4
+ "dist/verify-metadata.mjs",
5
+ Bun.file("../disposabl-kit/server/release/verify-metadata.mjs"),
6
+ );
7
+
8
+ export {};
@@ -19,10 +19,11 @@
19
19
  },
20
20
  "scripts": {
21
21
  "generate": "openapi-ts && bun fmt src/generated",
22
- "build": "bun run generate && tsc -p tsconfig.build.json",
22
+ "build": "bun build.ts",
23
23
  "typecheck": "bun run generate && tsc --noEmit",
24
24
  "lint": "bun check",
25
- "release": "semantic-release"
25
+ "release": "semantic-release",
26
+ "prepack": "node dist/verify-metadata.mjs"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@hey-api/openapi-ts": "0.99.0",
@@ -391,7 +391,7 @@ test("native top-up fails closed and checks identity at purchase", async () => {
391
391
  REVENUECAT_CONSUMABLE_INTEGRATION_VERIFIED: "true",
392
392
  REVENUECAT_WEBHOOK_AUTH: "auth",
393
393
  REVENUECAT_PROJECT_ID: "project",
394
- AUTUMN_SECRET_KEY: "key",
394
+ AUTUMN_SECRET_KEY: "am_sk_test_fixture",
395
395
  REVENUECAT_ENVIRONMENT: "SANDBOX",
396
396
  REVENUECAT_ROUTES: JSON.stringify([
397
397
  { app: "apple", store: "APP_STORE", product: "coins" },
@@ -403,6 +403,7 @@ test("native top-up fails closed and checks identity at purchase", async () => {
403
403
  { REVENUECAT_CONSUMABLE_INTEGRATION_VERIFIED: "false" },
404
404
  { REVENUECAT_ROUTES: "[]" },
405
405
  { REVENUECAT_WEBHOOK_AUTH: "" },
406
+ { AUTUMN_SECRET_KEY: "am_sk_live_fixture" },
406
407
  ])
407
408
  assert.deepEqual(nativeTopupRoutes(true, { ...env, ...change }), []);
408
409
  const snapshot = {
@@ -19,6 +19,8 @@ import {
19
19
  webhookAuthorized,
20
20
  webhook,
21
21
  dispatchBalance,
22
+ dispatch,
23
+ routing,
22
24
  } from "../disposabl-kit/server/revenuecat-functions";
23
25
 
24
26
  import { creditQuantity } from "../disposabl-kit/payments/config";
@@ -127,7 +129,7 @@ describe("RevenueCat consumable inbox", () => {
127
129
  REVENUECAT_WEBHOOK_AUTH: "Bearer test",
128
130
  REVENUECAT_PROJECT_ID: "proj",
129
131
  REVENUECAT_ENVIRONMENT: "SANDBOX",
130
- AUTUMN_SECRET_KEY: "key",
132
+ AUTUMN_SECRET_KEY: "am_sk_test_fixture",
131
133
  REVENUECAT_ROUTES: JSON.stringify([
132
134
  { app: "app", store: "APP_STORE", product: "topup" },
133
135
  { app: "android", store: "PLAY_STORE", product: "coins" },
@@ -193,6 +195,127 @@ describe("RevenueCat consumable inbox", () => {
193
195
  null,
194
196
  );
195
197
  });
198
+ test("sandbox and production events require matching Autumn key environments", () => {
199
+ const env = {
200
+ REVENUECAT_CONSUMABLE_OWNER: "custom",
201
+ REVENUECAT_WEBHOOK_AUTH: "Bearer fixture",
202
+ REVENUECAT_PROJECT_ID: "project",
203
+ REVENUECAT_ROUTES: JSON.stringify([
204
+ { app: "ios", store: "APP_STORE", product: "topup" },
205
+ ]),
206
+ REVENUECAT_ENVIRONMENT: "SANDBOX",
207
+ AUTUMN_SECRET_KEY: "am_sk_test_fixture",
208
+ };
209
+ assert.equal(revenueCatConfigs(true, env)?.[0]?.environment, "SANDBOX");
210
+ assert.equal(
211
+ revenueCatConfigs(true, {
212
+ ...env,
213
+ AUTUMN_SECRET_KEY: "am_sk_live_fixture",
214
+ }),
215
+ null,
216
+ );
217
+ assert.equal(
218
+ revenueCatConfigs(true, { ...env, AUTUMN_SECRET_KEY: "unknown" }),
219
+ null,
220
+ );
221
+ assert.equal(
222
+ revenueCatConfigs(true, { ...env, AUTUMN_SECRET_KEY: "am_sk_test_" }),
223
+ null,
224
+ );
225
+ assert.equal(
226
+ revenueCatConfigs(true, {
227
+ ...env,
228
+ AUTUMN_SECRET_KEY: "am_sk_test_bad key",
229
+ }),
230
+ null,
231
+ );
232
+ const live = { ...env, REVENUECAT_ENVIRONMENT: "PRODUCTION" };
233
+ assert.equal(revenueCatConfigs(true, live), null);
234
+ assert.equal(
235
+ revenueCatConfigs(true, {
236
+ ...live,
237
+ AUTUMN_SECRET_KEY: "am_sk_live_fixture",
238
+ })?.[0]?.environment,
239
+ "PRODUCTION",
240
+ );
241
+ });
242
+ test(
243
+ "queued sandbox dispatch rechecks the current environment and key",
244
+ { skip: !paymentsEnabled },
245
+ async () => {
246
+ const f = fixture();
247
+ const id = await balanceId(event);
248
+ await call(receive, f.ctx, { event, balanceId: id });
249
+ assert.equal(f.tables.revenueCatPurchases![0].state, "queued");
250
+ const env = {
251
+ REVENUECAT_CONSUMABLE_OWNER: "custom",
252
+ REVENUECAT_WEBHOOK_AUTH: "Bearer fixture",
253
+ REVENUECAT_PROJECT_ID: "proj",
254
+ REVENUECAT_ENVIRONMENT: "SANDBOX",
255
+ REVENUECAT_ROUTES: JSON.stringify([
256
+ { app: "app", store: "APP_STORE", product: "topup" },
257
+ ]),
258
+ AUTUMN_SECRET_KEY: "am_sk_test_fixture",
259
+ };
260
+ const previous = Object.fromEntries(
261
+ Object.keys(env).map((key) => [key, process.env[key]]),
262
+ );
263
+ const originalFetch = globalThis.fetch;
264
+ let claims = 0;
265
+ let completions = 0;
266
+ let requests = 0;
267
+ const ctx = {
268
+ runQuery: async (ref: any, args: unknown) => {
269
+ assert.equal(ref[Symbol.for("functionName")], "revenuecat:routing");
270
+ return call(routing, f.ctx, args);
271
+ },
272
+ runMutation: async (ref: any, args: unknown) => {
273
+ const name = ref[Symbol.for("functionName")];
274
+ if (name === "revenuecat:claim") {
275
+ claims++;
276
+ return call(claim, f.ctx, args);
277
+ }
278
+ assert.equal(name, "revenuecat:complete");
279
+ completions++;
280
+ return call(complete, f.ctx, args);
281
+ },
282
+ };
283
+ try {
284
+ Object.assign(process.env, env);
285
+ globalThis.fetch = (async (url, init) => {
286
+ requests++;
287
+ assert.equal(url, "https://api.useautumn.com/v1/balances.create");
288
+ assert.equal(
289
+ new Headers(init?.headers).get("authorization"),
290
+ "Bearer am_sk_test_fixture",
291
+ );
292
+ assert.deepEqual(
293
+ JSON.parse(String(init?.body)),
294
+ balanceRequest(event.customer, id, "grant"),
295
+ );
296
+ return Response.json({ success: true });
297
+ }) as typeof fetch;
298
+ process.env.AUTUMN_SECRET_KEY = "am_sk_live_fixture";
299
+ await call(dispatch, ctx, { balanceId: id });
300
+ assert.deepEqual([claims, requests, completions], [0, 0, 0]);
301
+ assert.equal(f.tables.revenueCatPurchases![0].state, "queued");
302
+ process.env.REVENUECAT_ENVIRONMENT = "PRODUCTION";
303
+ await call(dispatch, ctx, { balanceId: id });
304
+ assert.deepEqual([claims, requests, completions], [0, 0, 0]);
305
+ assert.equal(f.tables.revenueCatPurchases![0].state, "queued");
306
+ Object.assign(process.env, env);
307
+ await call(dispatch, ctx, { balanceId: id });
308
+ assert.deepEqual([claims, requests, completions], [1, 1, 1]);
309
+ assert.equal(f.tables.revenueCatPurchases![0].state, "granted");
310
+ } finally {
311
+ globalThis.fetch = originalFetch;
312
+ for (const [key, value] of Object.entries(previous)) {
313
+ if (value === undefined) delete process.env[key];
314
+ else process.env[key] = value;
315
+ }
316
+ }
317
+ },
318
+ );
196
319
  test("transfer holds affect the other app in the same project and environment", async () => {
197
320
  const f = fixture();
198
321
  const android = {
@@ -0,0 +1,64 @@
1
+ import { readFileSync, realpathSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+
5
+ // Package metadata must never publish authenticated or signed URLs.
6
+ export function verifyMetadata(manifest) {
7
+ function inspect(value, field) {
8
+ if (typeof value === "string") {
9
+ const candidate = value
10
+ .trim()
11
+ .replace(/[\u0000-\u0020]/g, "")
12
+ .replace(/^git\+/i, "");
13
+ if (
14
+ /^[a-z][a-z\d+.-]*:/i.test(candidate) ||
15
+ /^[\\/]{2}/.test(candidate)
16
+ ) {
17
+ let url;
18
+ try {
19
+ url = new URL(
20
+ candidate,
21
+ /^[\\/]{2}/.test(candidate)
22
+ ? "https://metadata.invalid"
23
+ : undefined,
24
+ );
25
+ } catch {
26
+ throw new Error(`Invalid URL in package metadata: ${field}`);
27
+ }
28
+ if (url.username || url.password || url.search || url.hash)
29
+ throw new Error(`Unsafe URL in package metadata: ${field}`);
30
+ } else if (/^[^/]+@[^/]+:/.test(candidate)) {
31
+ throw new Error(`Unsafe URL in package metadata: ${field}`);
32
+ }
33
+ } else if (Array.isArray(value)) {
34
+ value.forEach((item) => inspect(item, field));
35
+ } else if (value && typeof value === "object") {
36
+ for (const item of Object.values(value)) inspect(item, field);
37
+ }
38
+ }
39
+ for (const field of [
40
+ "repository",
41
+ "homepage",
42
+ "bugs",
43
+ "funding",
44
+ "author",
45
+ "contributors",
46
+ "maintainers",
47
+ "publishConfig",
48
+ ])
49
+ inspect(manifest[field], field);
50
+ }
51
+
52
+ if (
53
+ process.argv[1] &&
54
+ import.meta.url === pathToFileURL(realpathSync(resolve(process.argv[1]))).href
55
+ )
56
+ try {
57
+ verifyMetadata(
58
+ JSON.parse(readFileSync(process.argv[2] ?? "package.json", "utf8")),
59
+ );
60
+ } catch (error) {
61
+ if (error instanceof SyntaxError)
62
+ throw new Error("Invalid package metadata JSON");
63
+ throw error;
64
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-disposabl-app",
3
- "version": "0.17.4",
3
+ "version": "0.17.6",
4
4
  "description": "Create a Disposabl app",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,7 +26,8 @@
26
26
  "typecheck": "bun check",
27
27
  "lint": "cd ../.. && eslint --config packages/create-disposabl-app/eslint.config.ts packages/create-disposabl-app reset.ts",
28
28
  "format": "bun fmt",
29
- "verify:starter": "bun ../tests/starter-ci.ts"
29
+ "verify:starter": "bun ../tests/starter-ci.ts",
30
+ "prepack": "node dist/verify-metadata.mjs"
30
31
  },
31
32
  "publishConfig": {
32
33
  "access": "public"