create-disposabl-app 0.19.5 → 0.19.7
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/apps/desktop/forge.config.mts +7 -0
- package/dist/templates/default/apps/desktop/vite.main.config.mts +2 -3
- package/dist/templates/default/apps/desktop/website-config.ts +3 -0
- package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +2 -0
- package/dist/templates/default/packages/backend/convex/_generated/server.d.ts +1 -0
- package/dist/templates/default/packages/backend/convex/convex.config.ts +1 -0
- package/dist/templates/default/packages/backend/convex/revenuecat.ts +2 -0
- package/dist/templates/default/packages/disposabl-kit/PAYMENTS.md +7 -3
- package/dist/templates/default/packages/disposabl-kit/server/revenuecat-contract.ts +55 -0
- package/dist/templates/default/packages/disposabl-kit/server/revenuecat-functions.ts +134 -26
- package/dist/templates/default/packages/disposabl-kit/server/revenuecat-validator.ts +7 -0
- package/dist/templates/default/packages/tests/desktop-packaging.test.ts +80 -0
- package/dist/templates/default/packages/tests/revenuecat-inbox.test.ts +313 -0
- 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.19.
|
|
1566
|
+
var version = "0.19.7";
|
|
1567
1567
|
|
|
1568
1568
|
// ../cli/telemetry.ts
|
|
1569
1569
|
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
@@ -10,6 +10,8 @@ import { VitePlugin } from '@electron-forge/plugin-vite';
|
|
|
10
10
|
import { FusesPlugin } from '@electron-forge/plugin-fuses';
|
|
11
11
|
import { FuseV1Options, FuseVersion } from '@electron/fuses';
|
|
12
12
|
import { desktopAuthScheme } from '../../packages/disposabl-kit/lib/desktop-auth';
|
|
13
|
+
import { externalUrl } from './src/navigation';
|
|
14
|
+
import { configuredWebsite } from './website-config';
|
|
13
15
|
|
|
14
16
|
const executableName = manifest.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
15
17
|
const authScheme = desktopAuthScheme(
|
|
@@ -83,6 +85,11 @@ const config: ForgeConfig = {
|
|
|
83
85
|
rebuildConfig: {},
|
|
84
86
|
hooks: {
|
|
85
87
|
prePackage: async (_config, platform, arch) => {
|
|
88
|
+
const website = configuredWebsite();
|
|
89
|
+
if (website && (!website.startsWith('https://') || !externalUrl(website)))
|
|
90
|
+
throw new Error(
|
|
91
|
+
'Desktop packaging requires a valid HTTPS website without credentials. Set CONVEX_SITE_URL or VITE_CONVEX_SITE_URL, or leave both blank for the starter.',
|
|
92
|
+
);
|
|
86
93
|
const supported =
|
|
87
94
|
(platform === 'darwin' && arch === 'arm64') ||
|
|
88
95
|
((platform === 'win32' || platform === 'linux') && arch === 'x64');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
2
|
import manifest from './package.json' with { type: 'json' };
|
|
3
|
+
import { configuredWebsite } from './website-config';
|
|
3
4
|
|
|
4
5
|
export default defineConfig({
|
|
5
6
|
define: {
|
|
@@ -12,8 +13,6 @@ export default defineConfig({
|
|
|
12
13
|
DISPOSABL_UPDATE_CHANNEL: JSON.stringify(
|
|
13
14
|
process.env.DISPOSABL_DESKTOP_UPDATE_CHANNEL || 'production',
|
|
14
15
|
),
|
|
15
|
-
DISPOSABL_WEB_URL: JSON.stringify(
|
|
16
|
-
process.env.CONVEX_SITE_URL || process.env.VITE_CONVEX_SITE_URL || '',
|
|
17
|
-
),
|
|
16
|
+
DISPOSABL_WEB_URL: JSON.stringify(configuredWebsite()),
|
|
18
17
|
},
|
|
19
18
|
});
|
|
@@ -16,6 +16,7 @@ import type * as files_index from "../files/index.js";
|
|
|
16
16
|
import type * as files_internal from "../files/internal.js";
|
|
17
17
|
import type * as http from "../http.js";
|
|
18
18
|
import type * as mcp from "../mcp.js";
|
|
19
|
+
import type * as revenuecat from "../revenuecat.js";
|
|
19
20
|
import type * as telemetry from "../telemetry.js";
|
|
20
21
|
import type * as users_index from "../users/index.js";
|
|
21
22
|
import type * as users_internal from "../users/internal.js";
|
|
@@ -35,6 +36,7 @@ declare const fullApi: ApiFromModules<{
|
|
|
35
36
|
"files/internal": typeof files_internal;
|
|
36
37
|
http: typeof http;
|
|
37
38
|
mcp: typeof mcp;
|
|
39
|
+
revenuecat: typeof revenuecat;
|
|
38
40
|
telemetry: typeof telemetry;
|
|
39
41
|
"users/index": typeof users_index;
|
|
40
42
|
"users/internal": typeof users_internal;
|
|
@@ -32,6 +32,7 @@ type Env = {
|
|
|
32
32
|
readonly R2_BUCKET_NAME: string | undefined;
|
|
33
33
|
readonly R2_ACCESS_KEY_ID: string | undefined;
|
|
34
34
|
readonly R2_SECRET_ACCESS_KEY: string | undefined;
|
|
35
|
+
readonly REVENUECAT_MANAGED_MONTHLY_ROUTES: string | undefined;
|
|
35
36
|
readonly CONVEX_CLOUD_URL: string;
|
|
36
37
|
readonly CONVEX_SITE_URL: string;
|
|
37
38
|
readonly AUTH_EMAIL_ORIGIN: string | undefined;
|
|
@@ -25,6 +25,7 @@ const app = defineApp({
|
|
|
25
25
|
REVENUECAT_PROJECT_ID: v.optional(v.string()),
|
|
26
26
|
REVENUECAT_ENVIRONMENT: v.optional(v.string()),
|
|
27
27
|
REVENUECAT_ROUTES: v.optional(v.string()),
|
|
28
|
+
REVENUECAT_MANAGED_MONTHLY_ROUTES: v.optional(v.string()),
|
|
28
29
|
REVENUECAT_SYNC_ENABLED: v.optional(v.string()),
|
|
29
30
|
DISPOSABL_ENVIRONMENT: v.optional(v.string()),
|
|
30
31
|
POSTHOG_ENABLED: v.optional(v.string()),
|
|
@@ -52,13 +52,17 @@ Native consumable top-ups use a separately fetched store product and the opt-in
|
|
|
52
52
|
|
|
53
53
|
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.
|
|
54
54
|
|
|
55
|
+
Optionally set `REVENUECAT_MANAGED_MONTHLY_ROUTES` to a JSON array of `{ "app", "store", "product" }` tuples for managed monthly products, for example `[{"app":"apple-app-id","store":"APP_STORE","product":"apple-monthly"}]`. Each tuple must match an existing top-up app and store, have a different product, and be unique; at most 20 tuples are allowed. An absent or empty array adds no routes, while malformed or conflicting configuration disables the inbox. Authenticated, structurally valid `INITIAL_PURCHASE`, `RENEWAL`, and `CANCELLATION` events matching these tuples return 200 with `ignored` without persistence or grant. Unknown products and other event types on these monthly routes remain rejected. This allowlist does not configure or verify the managed provider mapping.
|
|
56
|
+
|
|
55
57
|
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.
|
|
56
58
|
|
|
57
|
-
The authenticated webhook checks app, environment, store, product, transaction and a known local user, then durably records delivery and transaction ownership. A stable balance ID excludes the customer, so an account switch cannot create a second grant. A scheduled worker atomically changes `queued` to `grant_unknown` before calling Autumn 2.6 `balances.create` with the configured top-up credit quantity. Only an explicit `{success:true}` response records a grant. A timeout, malformed response, provider error, or worker crash leaves `grant_unknown`: duplicate deliveries and action retries cannot issue another create. A separate paid transaction can proceed independently.
|
|
59
|
+
The authenticated webhook checks app, environment, store, product, transaction and a known local user, then durably records delivery and transaction ownership. A stable balance ID excludes the customer, so an account switch cannot create a second grant. A scheduled worker atomically changes `queued` to `grant_unknown` before calling Autumn 2.6 `balances.create` with the configured top-up credit quantity. Only an explicit `{success:true}` response records a grant. A timeout, malformed response, provider error, or worker crash leaves `grant_unknown`: duplicate deliveries and action retries cannot issue another create. A separate paid transaction can proceed independently. An HTTP 200 after persistence means accepted for processing, never credited.
|
|
60
|
+
|
|
61
|
+
A cancellation before dispatch creates a local tombstone; a later purchase cannot grant. Cancellation during a write is held until the result is known. After a grant, cancellation enters `refund_review` because the webhook alone does not prove the refund is full. An operator must establish the scope and spent-credit policy from provider records before calling private `revenuecat:confirmFullRefund` with a nonsecret evidence reference. It targets only that balance ID via `balances.update` with `remaining: 0`. An uncertain update is held as `refund_unknown`. Transfers and refund reversals require review; transfer notifications are stored separately and place affected customers on hold across both apps in the same project and environment. A transfer arriving after dispatch cannot cancel an in-flight provider request. Transfer holds remain active after an operator records a review; incomplete event identities are rejected. A release policy must first establish whether previously queued credits may be granted to the stored customer after each provider transfer, including account ownership and prior provider writes. No automatic restore, replay of an uncertain operation, or missed-webhook reconciliation is implied.
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
Operators can inspect private `revenuecat:inspect` by state and `revenuecat:inspectTransfers` and `revenuecat:inspectConflicts`. `revenuecat:confirmUnknown` records a provider-confirmed grant or refund with a nonsecret evidence reference, without issuing another write. An aggregate customer balance alone is not proof of an individual operation. There is no automatic reissue of a failed or uncertain dispatch. For an existing queued grant, `revenuecat:redispatchQueued` accepts the exact balance, route and customer, and schedules dispatch only if the customer exists and no active transfer holds remain. Dispatch rechecks current configuration and claim state, customer and holds; a later transfer can still block it. Unknown, refund and review states are not redispatched by this tool.
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
Private `revenuecat:recordTransferReview` records a `retain_hold` decision, a nonsecret provider evidence reference and review time against an exact transfer scope and its original from/to lists. Repeating the same decision is idempotent; conflicting evidence or scope is rejected. It does not release holds, resolve purchase states, transfer ownership, or move balances. The remaining policy question is what provider evidence and account-ownership conditions make every affected queued grant safe for its stored customer after a transfer; until that is defined and verified, keep the holds.
|
|
62
66
|
|
|
63
67
|
Autumn documents a caller-supplied `balance_id`, not its atomic uniqueness and retry semantics. This code does not claim exactly-once behavior across providers. Before enabling or offering the consumable, verify stable ID behavior and balance targeting, event ownership, concurrent delivery, response loss, crashes, refunds and partial refunds in isolated Apple and Google sandboxes; establish a documented provider reconciliation contract and a missed-webhook process. A successful local test or a callback does not prove a purchase or provider write. Native product IDs, pricing, RevenueCat offerings and both stores still need verification; do not set the verification flag until those checks pass. A store purchase remains pending until the authoritative Autumn balance updates; the app never grants credits locally.
|
|
64
68
|
|
|
@@ -8,6 +8,7 @@ export type RevenueCatConfig = {
|
|
|
8
8
|
product: string;
|
|
9
9
|
store: "APP_STORE" | "PLAY_STORE";
|
|
10
10
|
autumnKey: string;
|
|
11
|
+
managedMonthlyProducts?: string[];
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
export type PurchaseEvent = {
|
|
@@ -116,9 +117,63 @@ export function revenueCatConfigs(
|
|
|
116
117
|
return null;
|
|
117
118
|
result.push({ authorization, project, environment, autumnKey, ...route });
|
|
118
119
|
}
|
|
120
|
+
if (env.REVENUECAT_MANAGED_MONTHLY_ROUTES !== undefined) {
|
|
121
|
+
let monthly: unknown;
|
|
122
|
+
try {
|
|
123
|
+
monthly = JSON.parse(env.REVENUECAT_MANAGED_MONTHLY_ROUTES);
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
if (!Array.isArray(monthly) || monthly.length > 20) return null;
|
|
128
|
+
for (const route of monthly) {
|
|
129
|
+
if (
|
|
130
|
+
!route ||
|
|
131
|
+
typeof route !== "object" ||
|
|
132
|
+
Array.isArray(route) ||
|
|
133
|
+
Object.keys(route).sort().join(",") !== "app,product,store" ||
|
|
134
|
+
typeof route.product !== "string" ||
|
|
135
|
+
!route.product ||
|
|
136
|
+
route.product.trim() !== route.product ||
|
|
137
|
+
route.product.length > 256
|
|
138
|
+
)
|
|
139
|
+
return null;
|
|
140
|
+
const config = result.find(
|
|
141
|
+
(item) => item.app === route.app && item.store === route.store,
|
|
142
|
+
);
|
|
143
|
+
if (
|
|
144
|
+
!config ||
|
|
145
|
+
config.product === route.product ||
|
|
146
|
+
config.managedMonthlyProducts?.includes(route.product)
|
|
147
|
+
)
|
|
148
|
+
return null;
|
|
149
|
+
(config.managedMonthlyProducts ??= []).push(route.product);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
119
152
|
return result;
|
|
120
153
|
}
|
|
121
154
|
|
|
155
|
+
/** Managed monthly lifecycle events are acknowledged without entering the top-up inbox. */
|
|
156
|
+
export function isManagedMonthlyEvent(
|
|
157
|
+
payload: unknown,
|
|
158
|
+
configs: RevenueCatConfig[],
|
|
159
|
+
) {
|
|
160
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
161
|
+
return false;
|
|
162
|
+
const event = (payload as Record<string, unknown>).event;
|
|
163
|
+
if (!event || typeof event !== "object" || Array.isArray(event)) return false;
|
|
164
|
+
const e = event as Record<string, unknown>;
|
|
165
|
+
if (
|
|
166
|
+
!["INITIAL_PURCHASE", "RENEWAL", "CANCELLATION"].includes(e.type as string)
|
|
167
|
+
)
|
|
168
|
+
return false;
|
|
169
|
+
return configs.some((config) =>
|
|
170
|
+
config.managedMonthlyProducts?.some(
|
|
171
|
+
(product) =>
|
|
172
|
+
parseRevenueCatEvent(payload, { ...config, product }) !== null,
|
|
173
|
+
),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
122
177
|
export function selectRevenueCatRoute(
|
|
123
178
|
payload: unknown,
|
|
124
179
|
configs: RevenueCatConfig[],
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
balanceRequest,
|
|
13
13
|
parseRevenueCatEvent,
|
|
14
14
|
parseTransfer,
|
|
15
|
+
isManagedMonthlyEvent,
|
|
15
16
|
revenueCatConfigs,
|
|
16
17
|
selectRevenueCatRoute,
|
|
17
18
|
resolveRevenueCatRoute,
|
|
@@ -83,33 +84,41 @@ export async function webhookAuthorized(
|
|
|
83
84
|
return !!supplied && (await sameSecret(supplied, authorization));
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
export const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
87
|
+
export const createWebhook = (
|
|
88
|
+
enabled = paymentsEnabled,
|
|
89
|
+
environment: Record<string, string | undefined> = process.env,
|
|
90
|
+
) =>
|
|
91
|
+
httpActionGeneric(async (ctx, request) => {
|
|
92
|
+
const configs = revenueCatConfigs(enabled, environment);
|
|
93
|
+
if (!configs) return new Response("Unavailable", { status: 503 });
|
|
94
|
+
if (!(await webhookAuthorized(request, configs[0]!.authorization)))
|
|
95
|
+
return new Response("Unauthorized", { status: 401 });
|
|
96
|
+
let payload: unknown;
|
|
97
|
+
try {
|
|
98
|
+
payload = await request.json();
|
|
99
|
+
} catch {
|
|
100
|
+
return new Response("Invalid event", { status: 400 });
|
|
101
|
+
}
|
|
102
|
+
if (isManagedMonthlyEvent(payload, configs))
|
|
103
|
+
return Response.json({ status: "ignored" }, { status: 200 });
|
|
104
|
+
const config = selectRevenueCatRoute(payload, configs);
|
|
105
|
+
if (!config) return new Response("Invalid event", { status: 400 });
|
|
106
|
+
const transfer = parseTransfer(payload, config);
|
|
107
|
+
if (transfer) {
|
|
108
|
+
await ctx.runMutation(transferRef, transfer);
|
|
109
|
+
return Response.json({ status: "operator_review" }, { status: 200 });
|
|
110
|
+
}
|
|
111
|
+
const event = parseRevenueCatEvent(payload, config);
|
|
112
|
+
if (!event) return new Response("Invalid event", { status: 400 });
|
|
113
|
+
const result = await ctx.runMutation(receiveRef, {
|
|
114
|
+
event,
|
|
115
|
+
balanceId: await balanceId(event),
|
|
116
|
+
});
|
|
117
|
+
// Accepted means persisted, never a claim that the balance has changed.
|
|
118
|
+
return Response.json({ status: result }, { status: 200 });
|
|
109
119
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
120
|
+
|
|
121
|
+
export const webhook = createWebhook();
|
|
113
122
|
|
|
114
123
|
export const receiveTransfer = internalMutation({
|
|
115
124
|
args: {
|
|
@@ -173,6 +182,53 @@ export const inspectTransfers = internalQuery({
|
|
|
173
182
|
ctx.db.query("revenueCatTransfers").order("desc").take(100),
|
|
174
183
|
});
|
|
175
184
|
|
|
185
|
+
// Recording a review does not decide whether affected credits may be granted.
|
|
186
|
+
export const recordTransferReview = internalMutation({
|
|
187
|
+
args: {
|
|
188
|
+
project: v.string(),
|
|
189
|
+
app: v.string(),
|
|
190
|
+
environment: v.string(),
|
|
191
|
+
deliveryId: v.string(),
|
|
192
|
+
from: v.array(v.string()),
|
|
193
|
+
to: v.array(v.string()),
|
|
194
|
+
evidence: v.string(),
|
|
195
|
+
},
|
|
196
|
+
returns: v.boolean(),
|
|
197
|
+
handler: async (
|
|
198
|
+
ctx,
|
|
199
|
+
{ project, app, environment, deliveryId, from, to, evidence },
|
|
200
|
+
) => {
|
|
201
|
+
if (!evidence.trim() || evidence.length > 1000)
|
|
202
|
+
throw new Error("Provider evidence is required");
|
|
203
|
+
if (from.length > 20 || to.length > 20) return false;
|
|
204
|
+
const row = await ctx.db
|
|
205
|
+
.query("revenueCatTransfers")
|
|
206
|
+
.withIndex("by_delivery", (q) =>
|
|
207
|
+
q
|
|
208
|
+
.eq("project", project)
|
|
209
|
+
.eq("app", app)
|
|
210
|
+
.eq("environment", environment)
|
|
211
|
+
.eq("deliveryId", deliveryId),
|
|
212
|
+
)
|
|
213
|
+
.unique();
|
|
214
|
+
if (
|
|
215
|
+
!row ||
|
|
216
|
+
JSON.stringify(row.from) !== JSON.stringify(from) ||
|
|
217
|
+
JSON.stringify(row.to) !== JSON.stringify(to)
|
|
218
|
+
)
|
|
219
|
+
return false;
|
|
220
|
+
if (row.review) return row.review.evidence === evidence.trim();
|
|
221
|
+
await ctx.db.patch("revenueCatTransfers", row._id, {
|
|
222
|
+
review: {
|
|
223
|
+
decision: "retain_hold",
|
|
224
|
+
evidence: evidence.trim(),
|
|
225
|
+
reviewedAt: Date.now(),
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
return true;
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
|
|
176
232
|
export const inspectConflicts = internalQuery({
|
|
177
233
|
args: {},
|
|
178
234
|
returns: v.array(v.any()),
|
|
@@ -338,6 +394,10 @@ export const claim = internalMutation({
|
|
|
338
394
|
)
|
|
339
395
|
.take(1);
|
|
340
396
|
if (holds.length) return null;
|
|
397
|
+
if (row.state === "queued") {
|
|
398
|
+
const customerId = ctx.db.normalizeId("users", row.customer);
|
|
399
|
+
if (!customerId || !(await ctx.db.get("users", customerId))) return null;
|
|
400
|
+
}
|
|
341
401
|
const kind: "grant" | "refund" =
|
|
342
402
|
row.state === "queued" ? "grant" : "refund";
|
|
343
403
|
await ctx.db.patch("revenueCatPurchases", row._id, {
|
|
@@ -347,6 +407,54 @@ export const claim = internalMutation({
|
|
|
347
407
|
},
|
|
348
408
|
});
|
|
349
409
|
|
|
410
|
+
/** Schedule only a specifically identified queued grant; dispatch rechecks its route and claim. */
|
|
411
|
+
export const redispatchQueued = internalMutation({
|
|
412
|
+
args: {
|
|
413
|
+
balanceId: v.string(),
|
|
414
|
+
project: v.string(),
|
|
415
|
+
app: v.string(),
|
|
416
|
+
environment: v.string(),
|
|
417
|
+
store: v.string(),
|
|
418
|
+
product: v.string(),
|
|
419
|
+
customer: v.string(),
|
|
420
|
+
},
|
|
421
|
+
returns: v.boolean(),
|
|
422
|
+
handler: async (ctx, args) => {
|
|
423
|
+
const row = await ctx.db
|
|
424
|
+
.query("revenueCatPurchases")
|
|
425
|
+
.withIndex("by_balanceId", (q) => q.eq("balanceId", args.balanceId))
|
|
426
|
+
.unique();
|
|
427
|
+
if (
|
|
428
|
+
!row ||
|
|
429
|
+
row.project !== args.project ||
|
|
430
|
+
row.app !== args.app ||
|
|
431
|
+
row.environment !== args.environment ||
|
|
432
|
+
row.store !== args.store ||
|
|
433
|
+
row.product !== args.product ||
|
|
434
|
+
row.customer !== args.customer ||
|
|
435
|
+
row.state !== "queued" ||
|
|
436
|
+
row.refundPending ||
|
|
437
|
+
row.reviewPending
|
|
438
|
+
)
|
|
439
|
+
return false;
|
|
440
|
+
const customerId = ctx.db.normalizeId("users", row.customer);
|
|
441
|
+
if (!customerId || !(await ctx.db.get("users", customerId))) return false;
|
|
442
|
+
const holds = await ctx.db
|
|
443
|
+
.query("revenueCatTransferHolds")
|
|
444
|
+
.withIndex("by_customer_active", (q) =>
|
|
445
|
+
q
|
|
446
|
+
.eq("project", row.project)
|
|
447
|
+
.eq("environment", row.environment)
|
|
448
|
+
.eq("customer", row.customer)
|
|
449
|
+
.eq("active", true),
|
|
450
|
+
)
|
|
451
|
+
.take(1);
|
|
452
|
+
if (holds.length) return false;
|
|
453
|
+
await ctx.scheduler.runAfter(0, dispatchRef, { balanceId: args.balanceId });
|
|
454
|
+
return true;
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
|
|
350
458
|
export const complete = internalMutation({
|
|
351
459
|
args: {
|
|
352
460
|
balanceId: v.string(),
|
|
@@ -57,6 +57,13 @@ export const revenueCatTransfers = defineTable({
|
|
|
57
57
|
deliveryId: v.string(),
|
|
58
58
|
from: v.array(v.string()),
|
|
59
59
|
to: v.array(v.string()),
|
|
60
|
+
review: v.optional(
|
|
61
|
+
v.object({
|
|
62
|
+
decision: v.literal("retain_hold"),
|
|
63
|
+
evidence: v.string(),
|
|
64
|
+
reviewedAt: v.number(),
|
|
65
|
+
}),
|
|
66
|
+
),
|
|
60
67
|
}).index("by_delivery", ["project", "app", "environment", "deliveryId"]);
|
|
61
68
|
export const revenueCatTransferHolds = defineTable({
|
|
62
69
|
project: v.string(),
|
|
@@ -10,3 +10,83 @@ test("macOS disk image uses a bounded title without overriding artifact names",
|
|
|
10
10
|
assert.equal(maker.config.title, "Install");
|
|
11
11
|
assert.equal(maker.config.name, undefined);
|
|
12
12
|
});
|
|
13
|
+
|
|
14
|
+
test("packaging validates the website Vite embeds", async () => {
|
|
15
|
+
const previous = {
|
|
16
|
+
CONVEX_SITE_URL: process.env.CONVEX_SITE_URL,
|
|
17
|
+
VITE_CONVEX_SITE_URL: process.env.VITE_CONVEX_SITE_URL,
|
|
18
|
+
};
|
|
19
|
+
const cases = [
|
|
20
|
+
{ convex: "", vite: "", embedded: "", valid: true },
|
|
21
|
+
{
|
|
22
|
+
convex: "https://app.example/path",
|
|
23
|
+
vite: "",
|
|
24
|
+
embedded: "https://app.example/path",
|
|
25
|
+
valid: true,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
convex: "http://127.0.0.1:39876",
|
|
29
|
+
vite: "https://app.example",
|
|
30
|
+
embedded: "http://127.0.0.1:39876",
|
|
31
|
+
valid: false,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
convex: "",
|
|
35
|
+
vite: "https://app.example",
|
|
36
|
+
embedded: "https://app.example",
|
|
37
|
+
valid: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
convex: "https://app.example",
|
|
41
|
+
vite: "http://invalid.example",
|
|
42
|
+
embedded: "https://app.example",
|
|
43
|
+
valid: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
convex: "",
|
|
47
|
+
vite: "http://invalid.example",
|
|
48
|
+
embedded: "http://invalid.example",
|
|
49
|
+
valid: false,
|
|
50
|
+
},
|
|
51
|
+
{ convex: "https://", vite: "", embedded: "https://", valid: false },
|
|
52
|
+
{
|
|
53
|
+
convex: "https://user:pass@app.example",
|
|
54
|
+
vite: "",
|
|
55
|
+
embedded: "https://user:pass@app.example",
|
|
56
|
+
valid: false,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
convex: "HTTPS://app.example",
|
|
60
|
+
vite: "",
|
|
61
|
+
embedded: "HTTPS://app.example",
|
|
62
|
+
valid: false,
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
try {
|
|
66
|
+
for (const [index, item] of cases.entries()) {
|
|
67
|
+
process.env.CONVEX_SITE_URL = item.convex;
|
|
68
|
+
process.env.VITE_CONVEX_SITE_URL = item.vite;
|
|
69
|
+
const vite = await import(
|
|
70
|
+
`../../apps/desktop/vite.main.config.mts?case=${index}`
|
|
71
|
+
);
|
|
72
|
+
assert.equal(
|
|
73
|
+
JSON.parse(vite.default.define.DISPOSABL_WEB_URL),
|
|
74
|
+
item.embedded,
|
|
75
|
+
);
|
|
76
|
+
const hook = config.hooks!.prePackage!;
|
|
77
|
+
const check = () =>
|
|
78
|
+
hook(config as Parameters<typeof hook>[0], "darwin", "arm64");
|
|
79
|
+
if (item.valid) await assert.doesNotReject(check);
|
|
80
|
+
else
|
|
81
|
+
await assert.rejects(
|
|
82
|
+
check,
|
|
83
|
+
/Desktop packaging requires a valid HTTPS website/,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
} finally {
|
|
87
|
+
for (const [name, value] of Object.entries(previous)) {
|
|
88
|
+
if (value === undefined) delete process.env[name];
|
|
89
|
+
else process.env[name] = value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
@@ -16,6 +16,9 @@ import {
|
|
|
16
16
|
complete,
|
|
17
17
|
confirmFullRefund,
|
|
18
18
|
receiveTransfer,
|
|
19
|
+
recordTransferReview,
|
|
20
|
+
redispatchQueued,
|
|
21
|
+
createWebhook,
|
|
19
22
|
webhookAuthorized,
|
|
20
23
|
webhook,
|
|
21
24
|
dispatchBalance,
|
|
@@ -123,6 +126,137 @@ const scopedClaim = (balanceId: string) => ({
|
|
|
123
126
|
});
|
|
124
127
|
|
|
125
128
|
describe("RevenueCat consumable inbox", () => {
|
|
129
|
+
test("managed monthly events are acknowledged only for valid, disjoint configured routes", async () => {
|
|
130
|
+
const monthly = { app: "app", store: "APP_STORE", product: "monthly" };
|
|
131
|
+
const env = {
|
|
132
|
+
REVENUECAT_CONSUMABLE_OWNER: "custom",
|
|
133
|
+
REVENUECAT_WEBHOOK_AUTH: config.authorization,
|
|
134
|
+
REVENUECAT_PROJECT_ID: config.project,
|
|
135
|
+
REVENUECAT_ENVIRONMENT: config.environment,
|
|
136
|
+
AUTUMN_SECRET_KEY: "am_sk_test_synthetic",
|
|
137
|
+
REVENUECAT_ROUTES: JSON.stringify([
|
|
138
|
+
{ app: "app", store: "APP_STORE", product: "topup" },
|
|
139
|
+
]),
|
|
140
|
+
REVENUECAT_MANAGED_MONTHLY_ROUTES: JSON.stringify([monthly]),
|
|
141
|
+
};
|
|
142
|
+
const cancellation = {
|
|
143
|
+
id: "private-delivery",
|
|
144
|
+
type: "CANCELLATION",
|
|
145
|
+
app_id: "app",
|
|
146
|
+
environment: "SANDBOX",
|
|
147
|
+
store: "APP_STORE",
|
|
148
|
+
product_id: "monthly",
|
|
149
|
+
app_user_id: "private-user",
|
|
150
|
+
transaction_id: "private-transaction",
|
|
151
|
+
};
|
|
152
|
+
const request = (event: object, auth = config.authorization) =>
|
|
153
|
+
new Request("https://example.test", {
|
|
154
|
+
method: "POST",
|
|
155
|
+
headers: { authorization: auth },
|
|
156
|
+
body: JSON.stringify({ api_version: "1.0", event }),
|
|
157
|
+
});
|
|
158
|
+
const f = fixture();
|
|
159
|
+
let mutations = 0;
|
|
160
|
+
const ctx = {
|
|
161
|
+
runMutation: (_ref: unknown, args: unknown) => {
|
|
162
|
+
mutations++;
|
|
163
|
+
return call(receive, f.ctx, args);
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
const handler = createWebhook(true, env);
|
|
167
|
+
for (const type of ["CANCELLATION", "INITIAL_PURCHASE", "RENEWAL"]) {
|
|
168
|
+
const response = await call(
|
|
169
|
+
handler,
|
|
170
|
+
ctx,
|
|
171
|
+
request({ ...cancellation, type }),
|
|
172
|
+
);
|
|
173
|
+
assert.equal(response.status, 200);
|
|
174
|
+
assert.equal(await response.text(), '{"status":"ignored"}');
|
|
175
|
+
}
|
|
176
|
+
assert.equal(mutations, 0);
|
|
177
|
+
assert.equal(f.jobs.length, 0);
|
|
178
|
+
assert.ok(Object.values(f.tables).every((rows) => rows.length === 0));
|
|
179
|
+
for (const change of [
|
|
180
|
+
{ product_id: "unknown" },
|
|
181
|
+
{ app_id: "other" },
|
|
182
|
+
{ store: "PLAY_STORE" },
|
|
183
|
+
{ environment: "PRODUCTION" },
|
|
184
|
+
{ project_id: "other" },
|
|
185
|
+
{ id: "" },
|
|
186
|
+
{ transaction_id: "" },
|
|
187
|
+
{ app_user_id: "$RCAnonymousID:x" },
|
|
188
|
+
{ original_app_user_id: "other" },
|
|
189
|
+
{ type: "UNKNOWN" },
|
|
190
|
+
{ type: "NON_RENEWING_PURCHASE" },
|
|
191
|
+
]) {
|
|
192
|
+
const response = await call(
|
|
193
|
+
handler,
|
|
194
|
+
ctx,
|
|
195
|
+
request({ ...cancellation, ...change }),
|
|
196
|
+
);
|
|
197
|
+
assert.equal(response.status, 400);
|
|
198
|
+
assert.equal(await response.text(), "Invalid event");
|
|
199
|
+
}
|
|
200
|
+
assert.equal(
|
|
201
|
+
(await call(handler, ctx, request(cancellation, "Bearer wrong"))).status,
|
|
202
|
+
401,
|
|
203
|
+
);
|
|
204
|
+
assert.equal(
|
|
205
|
+
(await call(createWebhook(false, env), ctx, request(cancellation)))
|
|
206
|
+
.status,
|
|
207
|
+
503,
|
|
208
|
+
);
|
|
209
|
+
for (const routes of [
|
|
210
|
+
[{ ...monthly, product: "topup" }],
|
|
211
|
+
[monthly, monthly],
|
|
212
|
+
[{ ...monthly, store: "PLAY_STORE" }],
|
|
213
|
+
[{ ...monthly, app: "other" }],
|
|
214
|
+
[{ ...monthly, extra: true }],
|
|
215
|
+
]) {
|
|
216
|
+
assert.equal(
|
|
217
|
+
revenueCatConfigs(true, {
|
|
218
|
+
...env,
|
|
219
|
+
REVENUECAT_MANAGED_MONTHLY_ROUTES: JSON.stringify(routes),
|
|
220
|
+
}),
|
|
221
|
+
null,
|
|
222
|
+
);
|
|
223
|
+
assert.equal(
|
|
224
|
+
(
|
|
225
|
+
await call(
|
|
226
|
+
createWebhook(true, {
|
|
227
|
+
...env,
|
|
228
|
+
REVENUECAT_MANAGED_MONTHLY_ROUTES: JSON.stringify(routes),
|
|
229
|
+
}),
|
|
230
|
+
ctx,
|
|
231
|
+
request(cancellation),
|
|
232
|
+
)
|
|
233
|
+
).status,
|
|
234
|
+
503,
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
assert.equal(
|
|
238
|
+
revenueCatConfigs(true, {
|
|
239
|
+
...env,
|
|
240
|
+
REVENUECAT_MANAGED_MONTHLY_ROUTES: "bad",
|
|
241
|
+
}),
|
|
242
|
+
null,
|
|
243
|
+
);
|
|
244
|
+
const response = await call(
|
|
245
|
+
handler,
|
|
246
|
+
ctx,
|
|
247
|
+
request({
|
|
248
|
+
...cancellation,
|
|
249
|
+
product_id: "topup",
|
|
250
|
+
type: "NON_RENEWING_PURCHASE",
|
|
251
|
+
app_user_id: "user-1",
|
|
252
|
+
}),
|
|
253
|
+
);
|
|
254
|
+
assert.equal(response.status, 200);
|
|
255
|
+
assert.equal(mutations, 1);
|
|
256
|
+
assert.equal(f.tables.revenueCatPurchases!.length, 1);
|
|
257
|
+
assert.equal(f.tables.revenueCatDeliveries!.length, 1);
|
|
258
|
+
assert.equal(f.jobs.length, 1);
|
|
259
|
+
});
|
|
126
260
|
test("validated routes select both stores and reject ambiguous or removed configuration", () => {
|
|
127
261
|
const env = {
|
|
128
262
|
REVENUECAT_CONSUMABLE_OWNER: "custom",
|
|
@@ -396,6 +530,108 @@ describe("RevenueCat consumable inbox", () => {
|
|
|
396
530
|
assert.equal(response.status, 503);
|
|
397
531
|
},
|
|
398
532
|
);
|
|
533
|
+
test("webhook acknowledges durable purchases and transfer holds with HTTP 200", async () => {
|
|
534
|
+
const handler = createWebhook(true, {
|
|
535
|
+
REVENUECAT_CONSUMABLE_OWNER: "custom",
|
|
536
|
+
REVENUECAT_WEBHOOK_AUTH: config.authorization,
|
|
537
|
+
REVENUECAT_PROJECT_ID: config.project,
|
|
538
|
+
REVENUECAT_ENVIRONMENT: config.environment,
|
|
539
|
+
AUTUMN_SECRET_KEY: "am_sk_test_synthetic",
|
|
540
|
+
REVENUECAT_ROUTES: JSON.stringify([
|
|
541
|
+
{ app: config.app, store: config.store, product: config.product },
|
|
542
|
+
]),
|
|
543
|
+
});
|
|
544
|
+
const purchase = {
|
|
545
|
+
id: "delivery",
|
|
546
|
+
type: "NON_RENEWING_PURCHASE",
|
|
547
|
+
app_id: config.app,
|
|
548
|
+
environment: config.environment,
|
|
549
|
+
store: config.store,
|
|
550
|
+
product_id: config.product,
|
|
551
|
+
app_user_id: "user-1",
|
|
552
|
+
transaction_id: "transaction",
|
|
553
|
+
};
|
|
554
|
+
const request = (event: object) =>
|
|
555
|
+
new Request("https://example.test/revenuecat/webhook", {
|
|
556
|
+
method: "POST",
|
|
557
|
+
headers: { authorization: config.authorization },
|
|
558
|
+
body: JSON.stringify({ api_version: "1.0", event }),
|
|
559
|
+
});
|
|
560
|
+
for (const event of [
|
|
561
|
+
purchase,
|
|
562
|
+
{
|
|
563
|
+
...purchase,
|
|
564
|
+
type: "TRANSFER",
|
|
565
|
+
transferred_from: ["user-1"],
|
|
566
|
+
transferred_to: ["user-2"],
|
|
567
|
+
},
|
|
568
|
+
]) {
|
|
569
|
+
let enter!: () => void;
|
|
570
|
+
let persist!: (value: string) => void;
|
|
571
|
+
const entered = new Promise<void>((resolve) => {
|
|
572
|
+
enter = resolve;
|
|
573
|
+
});
|
|
574
|
+
const persisted = new Promise<string>((resolve) => {
|
|
575
|
+
persist = resolve;
|
|
576
|
+
});
|
|
577
|
+
let acknowledged = false;
|
|
578
|
+
const result = call(
|
|
579
|
+
handler,
|
|
580
|
+
{
|
|
581
|
+
runMutation: () => {
|
|
582
|
+
enter();
|
|
583
|
+
return persisted;
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
request(event),
|
|
587
|
+
).then((response: Response) => {
|
|
588
|
+
acknowledged = true;
|
|
589
|
+
return response;
|
|
590
|
+
});
|
|
591
|
+
await entered;
|
|
592
|
+
assert.equal(acknowledged, false);
|
|
593
|
+
persist("pending");
|
|
594
|
+
const response = await result;
|
|
595
|
+
assert.equal(response.status, 200);
|
|
596
|
+
assert.deepEqual(await response.json(), {
|
|
597
|
+
status: event.type === "TRANSFER" ? "operator_review" : "pending",
|
|
598
|
+
});
|
|
599
|
+
await assert.rejects(
|
|
600
|
+
call(
|
|
601
|
+
handler,
|
|
602
|
+
{
|
|
603
|
+
runMutation: async () => {
|
|
604
|
+
throw new Error("persistence failed");
|
|
605
|
+
},
|
|
606
|
+
},
|
|
607
|
+
request(event),
|
|
608
|
+
),
|
|
609
|
+
/persistence failed/,
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
const f = fixture();
|
|
613
|
+
const ctx = {
|
|
614
|
+
runMutation: (_ref: unknown, args: unknown) => call(receive, f.ctx, args),
|
|
615
|
+
};
|
|
616
|
+
assert.equal((await call(handler, ctx, request(purchase))).status, 200);
|
|
617
|
+
assert.equal((await call(handler, ctx, request(purchase))).status, 200);
|
|
618
|
+
assert.equal(f.tables.revenueCatPurchases!.length, 1);
|
|
619
|
+
assert.equal(f.tables.revenueCatDeliveries!.length, 1);
|
|
620
|
+
assert.equal(
|
|
621
|
+
(
|
|
622
|
+
await call(
|
|
623
|
+
handler,
|
|
624
|
+
ctx,
|
|
625
|
+
request({ ...purchase, environment: "PRODUCTION" }),
|
|
626
|
+
)
|
|
627
|
+
).status,
|
|
628
|
+
400,
|
|
629
|
+
);
|
|
630
|
+
assert.equal(
|
|
631
|
+
(await call(handler, ctx, new Request("https://example.test"))).status,
|
|
632
|
+
401,
|
|
633
|
+
);
|
|
634
|
+
});
|
|
399
635
|
test("webhook authorization requires the exact configured header", async () => {
|
|
400
636
|
assert.equal(
|
|
401
637
|
await webhookAuthorized(
|
|
@@ -451,6 +687,83 @@ describe("RevenueCat consumable inbox", () => {
|
|
|
451
687
|
"grant",
|
|
452
688
|
);
|
|
453
689
|
});
|
|
690
|
+
test("transfer review is scoped, idempotent and retains holds; redispatch is targeted", async () => {
|
|
691
|
+
const f = fixture();
|
|
692
|
+
const id = await balanceId(event);
|
|
693
|
+
await call(receive, f.ctx, { event, balanceId: id });
|
|
694
|
+
const transfer = {
|
|
695
|
+
project: "proj",
|
|
696
|
+
app: "app",
|
|
697
|
+
environment: "SANDBOX",
|
|
698
|
+
deliveryId: "transfer",
|
|
699
|
+
from: ["user-1"],
|
|
700
|
+
to: ["user-2"],
|
|
701
|
+
};
|
|
702
|
+
await call(receiveTransfer, f.ctx, transfer);
|
|
703
|
+
await call(receiveTransfer, f.ctx, { ...transfer, deliveryId: "second" });
|
|
704
|
+
const review = { ...transfer, evidence: " provider case 123 " };
|
|
705
|
+
assert.equal(
|
|
706
|
+
await call(recordTransferReview, f.ctx, { ...review, app: "wrong" }),
|
|
707
|
+
false,
|
|
708
|
+
);
|
|
709
|
+
assert.equal(
|
|
710
|
+
await call(recordTransferReview, f.ctx, { ...review, to: ["user-3"] }),
|
|
711
|
+
false,
|
|
712
|
+
);
|
|
713
|
+
await assert.rejects(
|
|
714
|
+
call(recordTransferReview, f.ctx, { ...review, evidence: " " }),
|
|
715
|
+
/Provider evidence/,
|
|
716
|
+
);
|
|
717
|
+
await assert.rejects(
|
|
718
|
+
call(recordTransferReview, f.ctx, {
|
|
719
|
+
...review,
|
|
720
|
+
evidence: "x".repeat(1001),
|
|
721
|
+
}),
|
|
722
|
+
/Provider evidence/,
|
|
723
|
+
);
|
|
724
|
+
assert.equal(await call(recordTransferReview, f.ctx, review), true);
|
|
725
|
+
const saved = f.tables.revenueCatTransfers![0].review;
|
|
726
|
+
assert.equal(saved.decision, "retain_hold");
|
|
727
|
+
assert.equal(saved.evidence, "provider case 123");
|
|
728
|
+
assert.equal(typeof saved.reviewedAt, "number");
|
|
729
|
+
assert.equal(await call(recordTransferReview, f.ctx, review), true);
|
|
730
|
+
assert.equal(
|
|
731
|
+
await call(recordTransferReview, f.ctx, {
|
|
732
|
+
...review,
|
|
733
|
+
evidence: "different",
|
|
734
|
+
}),
|
|
735
|
+
false,
|
|
736
|
+
);
|
|
737
|
+
assert.deepEqual(f.tables.revenueCatTransfers![0].review, saved);
|
|
738
|
+
await call(receiveTransfer, f.ctx, transfer);
|
|
739
|
+
assert.ok(f.tables.revenueCatTransferHolds!.every((hold) => hold.active));
|
|
740
|
+
const target = { ...scopedClaim(id), customer: event.customer };
|
|
741
|
+
const jobs = f.jobs.length;
|
|
742
|
+
assert.equal(await call(redispatchQueued, f.ctx, target), false);
|
|
743
|
+
assert.equal(await call(claim, f.ctx, scopedClaim(id)), null);
|
|
744
|
+
assert.equal(f.jobs.length, jobs);
|
|
745
|
+
// Simulate independently reconciled holds to exercise redispatch without defining a release policy.
|
|
746
|
+
f.tables.revenueCatTransferHolds!.forEach((hold) => {
|
|
747
|
+
hold.active = false;
|
|
748
|
+
});
|
|
749
|
+
assert.equal(
|
|
750
|
+
await call(redispatchQueued, f.ctx, { ...target, customer: "user-2" }),
|
|
751
|
+
false,
|
|
752
|
+
);
|
|
753
|
+
assert.equal(
|
|
754
|
+
await call(redispatchQueued, f.ctx, { ...target, product: "wrong" }),
|
|
755
|
+
false,
|
|
756
|
+
);
|
|
757
|
+
assert.equal(await call(redispatchQueued, f.ctx, target), true);
|
|
758
|
+
assert.equal(f.jobs.length, jobs + 1);
|
|
759
|
+
await call(receiveTransfer, f.ctx, { ...transfer, deliveryId: "third" });
|
|
760
|
+
assert.equal(await call(claim, f.ctx, scopedClaim(id)), null);
|
|
761
|
+
f.tables.revenueCatTransferHolds!.forEach((hold) => {
|
|
762
|
+
hold.active = false;
|
|
763
|
+
});
|
|
764
|
+
assert.equal((await call(claim, f.ctx, scopedClaim(id))).kind, "grant");
|
|
765
|
+
assert.equal(await call(redispatchQueued, f.ctx, target), false);
|
|
766
|
+
});
|
|
454
767
|
test("disabled and incomplete configuration cannot read or dispatch payments", () => {
|
|
455
768
|
assert.equal(revenueCatConfigs(false, {}), null);
|
|
456
769
|
assert.equal(
|