create-disposabl-app 0.17.3 → 0.17.5
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 +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/default/packages/disposabl-kit/PAYMENTS.md +1 -1
- package/dist/templates/default/packages/disposabl-kit/server/billing.ts +4 -1
- package/dist/templates/default/packages/disposabl-kit/server/revenuecat-contract.ts +7 -1
- package/dist/templates/default/packages/tests/billing.test.ts +18 -0
- package/dist/templates/default/packages/tests/native-billing.test.ts +2 -1
- package/dist/templates/default/packages/tests/revenuecat-inbox.test.ts +124 -1
- package/package.json +1 -1
package/dist/disposabl.js
CHANGED
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.
|
|
1566
|
+
var version = "0.17.5";
|
|
1567
1567
|
|
|
1568
1568
|
// ../cli/telemetry.ts
|
|
1569
1569
|
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
@@ -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
|
|
|
@@ -67,7 +67,10 @@ export async function billingRequest(
|
|
|
67
67
|
},
|
|
68
68
|
body: JSON.stringify(body),
|
|
69
69
|
});
|
|
70
|
-
|
|
70
|
+
// Autumn may accept a write for deferred processing with a success-shaped
|
|
71
|
+
// 202 body. It is not a definitive result; callers must retain unknown holds.
|
|
72
|
+
if (!response.ok || response.status === 202)
|
|
73
|
+
throw new Error("Billing is temporarily unavailable.");
|
|
71
74
|
const result: unknown = await response.json();
|
|
72
75
|
if (!result || typeof result !== "object" || Array.isArray(result))
|
|
73
76
|
throw new Error("Billing is temporarily unavailable.");
|
|
@@ -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;
|
|
@@ -182,4 +182,22 @@ describe("billing boundary", () => {
|
|
|
182
182
|
/Billing is temporarily unavailable/,
|
|
183
183
|
);
|
|
184
184
|
});
|
|
185
|
+
test("accepted responses cannot establish a final billing result", async () => {
|
|
186
|
+
for (const method of [
|
|
187
|
+
"balances.check",
|
|
188
|
+
"balances.update",
|
|
189
|
+
"balances.create",
|
|
190
|
+
]) {
|
|
191
|
+
let requests = 0;
|
|
192
|
+
const mock = (async () => {
|
|
193
|
+
requests++;
|
|
194
|
+
return Response.json({ success: true, allowed: true }, { status: 202 });
|
|
195
|
+
}) as typeof fetch;
|
|
196
|
+
await assert.rejects(
|
|
197
|
+
billingRequest("test-key", method, {}, mock),
|
|
198
|
+
/Billing is temporarily unavailable/,
|
|
199
|
+
);
|
|
200
|
+
assert.equal(requests, 1);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
185
203
|
});
|
|
@@ -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: "
|
|
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: "
|
|
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 = {
|