@onesub/server 0.7.3 → 0.9.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/dist/__tests__/apple-status-api.test.d.ts +14 -0
- package/dist/__tests__/apple-status-api.test.d.ts.map +1 -0
- package/dist/__tests__/apple-status-api.test.js +345 -0
- package/dist/__tests__/apple-status-api.test.js.map +1 -0
- package/dist/__tests__/fetch-hardening.test.d.ts +7 -0
- package/dist/__tests__/fetch-hardening.test.d.ts.map +1 -0
- package/dist/__tests__/fetch-hardening.test.js +192 -0
- package/dist/__tests__/fetch-hardening.test.js.map +1 -0
- package/dist/__tests__/google-paused.test.d.ts +10 -0
- package/dist/__tests__/google-paused.test.d.ts.map +1 -0
- package/dist/__tests__/google-paused.test.js +126 -0
- package/dist/__tests__/google-paused.test.js.map +1 -0
- package/dist/__tests__/google-price-change.test.d.ts +6 -0
- package/dist/__tests__/google-price-change.test.d.ts.map +1 -0
- package/dist/__tests__/google-price-change.test.js +186 -0
- package/dist/__tests__/google-price-change.test.js.map +1 -0
- package/dist/__tests__/google-subscriptions-v2.test.d.ts +13 -0
- package/dist/__tests__/google-subscriptions-v2.test.d.ts.map +1 -0
- package/dist/__tests__/google-subscriptions-v2.test.js +206 -0
- package/dist/__tests__/google-subscriptions-v2.test.js.map +1 -0
- package/dist/__tests__/lifecycle-states.test.d.ts +12 -0
- package/dist/__tests__/lifecycle-states.test.d.ts.map +1 -0
- package/dist/__tests__/lifecycle-states.test.js +423 -0
- package/dist/__tests__/lifecycle-states.test.js.map +1 -0
- package/dist/__tests__/linked-purchase-token.test.d.ts +9 -0
- package/dist/__tests__/linked-purchase-token.test.d.ts.map +1 -0
- package/dist/__tests__/linked-purchase-token.test.js +227 -0
- package/dist/__tests__/linked-purchase-token.test.js.map +1 -0
- package/dist/__tests__/paused-auto-resume.test.d.ts +7 -0
- package/dist/__tests__/paused-auto-resume.test.d.ts.map +1 -0
- package/dist/__tests__/paused-auto-resume.test.js +162 -0
- package/dist/__tests__/paused-auto-resume.test.js.map +1 -0
- package/dist/__tests__/providers.test.js +69 -9
- package/dist/__tests__/providers.test.js.map +1 -1
- package/dist/__tests__/refund-policy.test.d.ts +11 -0
- package/dist/__tests__/refund-policy.test.d.ts.map +1 -0
- package/dist/__tests__/refund-policy.test.js +317 -0
- package/dist/__tests__/refund-policy.test.js.map +1 -0
- package/dist/__tests__/schema.test.js +4 -0
- package/dist/__tests__/schema.test.js.map +1 -1
- package/dist/__tests__/store.test.js +17 -0
- package/dist/__tests__/store.test.js.map +1 -1
- package/dist/__tests__/test-utils.d.ts +20 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -0
- package/dist/__tests__/test-utils.js +30 -0
- package/dist/__tests__/test-utils.js.map +1 -0
- package/dist/__tests__/webhook-refund.test.d.ts +13 -0
- package/dist/__tests__/webhook-refund.test.d.ts.map +1 -0
- package/dist/__tests__/webhook-refund.test.js +313 -0
- package/dist/__tests__/webhook-refund.test.js.map +1 -0
- package/dist/http.d.ts +17 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +36 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/apple.d.ts +50 -2
- package/dist/providers/apple.d.ts.map +1 -1
- package/dist/providers/apple.js +235 -2
- package/dist/providers/apple.js.map +1 -1
- package/dist/providers/google.d.ts +71 -6
- package/dist/providers/google.d.ts.map +1 -1
- package/dist/providers/google.js +211 -36
- package/dist/providers/google.js.map +1 -1
- package/dist/routes/purchase.d.ts.map +1 -1
- package/dist/routes/purchase.js +15 -6
- package/dist/routes/purchase.js.map +1 -1
- package/dist/routes/status.d.ts.map +1 -1
- package/dist/routes/status.js +14 -1
- package/dist/routes/status.js.map +1 -1
- package/dist/routes/validate.d.ts.map +1 -1
- package/dist/routes/validate.js +7 -1
- package/dist/routes/validate.js.map +1 -1
- package/dist/routes/webhook.d.ts +2 -2
- package/dist/routes/webhook.d.ts.map +1 -1
- package/dist/routes/webhook.js +219 -27
- package/dist/routes/webhook.js.map +1 -1
- package/dist/store.d.ts +9 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +12 -0
- package/dist/store.js.map +1 -1
- package/dist/stores/postgres.d.ts +1 -0
- package/dist/stores/postgres.d.ts.map +1 -1
- package/dist/stores/postgres.js +14 -2
- package/dist/stores/postgres.js.map +1 -1
- package/dist/stores/schema.d.ts.map +1 -1
- package/dist/stores/schema.js +7 -0
- package/dist/stores/schema.js.map +1 -1
- package/package.json +2 -2
- package/sql/schema.sql +7 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refund / voided-purchase webhook tests.
|
|
3
|
+
*
|
|
4
|
+
* Covers:
|
|
5
|
+
* - Apple webhook REFUND for IAP (Consumable / Non-Consumable) →
|
|
6
|
+
* PurchaseStore row removed, SubscriptionStore untouched.
|
|
7
|
+
* - Apple webhook REFUND for subscriptions still updates SubscriptionStore.
|
|
8
|
+
* - Google voidedPurchaseNotification productType=2 → IAP row removed.
|
|
9
|
+
* - Google voidedPurchaseNotification productType=1 → subscription canceled.
|
|
10
|
+
* - decodeGoogleVoidedNotification recognises voided payload, ignores other kinds.
|
|
11
|
+
*/
|
|
12
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
13
|
+
import express from 'express';
|
|
14
|
+
import { SUBSCRIPTION_STATUS } from '@onesub/shared';
|
|
15
|
+
import { createWebhookRouter } from '../routes/webhook.js';
|
|
16
|
+
import { InMemorySubscriptionStore, InMemoryPurchaseStore } from '../store.js';
|
|
17
|
+
import { decodeGoogleVoidedNotification } from '../providers/google.js';
|
|
18
|
+
// ── helpers ─────────────────────────────────────────────────────────────────
|
|
19
|
+
function makeJws(payload) {
|
|
20
|
+
const header = Buffer.from(JSON.stringify({ alg: 'ES256' })).toString('base64url');
|
|
21
|
+
const body = Buffer.from(JSON.stringify(payload)).toString('base64url');
|
|
22
|
+
return `${header}.${body}.fakesig`;
|
|
23
|
+
}
|
|
24
|
+
function appleConfig() {
|
|
25
|
+
return {
|
|
26
|
+
apple: { bundleId: 'com.example.app', skipJwsVerification: true },
|
|
27
|
+
database: { url: '' },
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function googleConfig() {
|
|
31
|
+
return {
|
|
32
|
+
google: { packageName: 'com.example.app' },
|
|
33
|
+
database: { url: '' },
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function buildServer(config, store, purchaseStore) {
|
|
37
|
+
const app = express();
|
|
38
|
+
app.use(express.json());
|
|
39
|
+
app.use(createWebhookRouter(config, store, purchaseStore));
|
|
40
|
+
return {
|
|
41
|
+
async request(path, body) {
|
|
42
|
+
// Use Node http directly for a lightweight test server.
|
|
43
|
+
const server = app.listen(0);
|
|
44
|
+
const address = server.address();
|
|
45
|
+
const port = typeof address === 'object' && address ? address.port : 0;
|
|
46
|
+
try {
|
|
47
|
+
const resp = await fetch(`http://127.0.0.1:${port}${path}`, {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
headers: { 'Content-Type': 'application/json' },
|
|
50
|
+
body: JSON.stringify(body),
|
|
51
|
+
});
|
|
52
|
+
const text = await resp.text();
|
|
53
|
+
let parsed = text;
|
|
54
|
+
try {
|
|
55
|
+
parsed = JSON.parse(text);
|
|
56
|
+
}
|
|
57
|
+
catch { /* keep as text */ }
|
|
58
|
+
return { status: resp.status, body: parsed };
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const samplePurchase = (overrides) => ({
|
|
67
|
+
userId: 'user_1',
|
|
68
|
+
productId: 'credits_100',
|
|
69
|
+
platform: 'apple',
|
|
70
|
+
type: 'consumable',
|
|
71
|
+
transactionId: 'txn_apple_consumable_001',
|
|
72
|
+
purchasedAt: '2026-01-01T00:00:00.000Z',
|
|
73
|
+
quantity: 1,
|
|
74
|
+
...overrides,
|
|
75
|
+
});
|
|
76
|
+
const sampleSub = (overrides) => ({
|
|
77
|
+
userId: 'user_sub',
|
|
78
|
+
productId: 'pro_monthly',
|
|
79
|
+
platform: 'google',
|
|
80
|
+
status: 'active',
|
|
81
|
+
expiresAt: '2027-01-01T00:00:00.000Z',
|
|
82
|
+
originalTransactionId: 'token_google_sub_xyz',
|
|
83
|
+
purchasedAt: '2026-01-01T00:00:00.000Z',
|
|
84
|
+
willRenew: true,
|
|
85
|
+
...overrides,
|
|
86
|
+
});
|
|
87
|
+
// ── Apple webhook: IAP REFUND ───────────────────────────────────────────────
|
|
88
|
+
describe('Apple webhook — IAP REFUND', () => {
|
|
89
|
+
let store;
|
|
90
|
+
let purchaseStore;
|
|
91
|
+
let server;
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
store = new InMemorySubscriptionStore();
|
|
94
|
+
purchaseStore = new InMemoryPurchaseStore();
|
|
95
|
+
server = buildServer(appleConfig(), store, purchaseStore);
|
|
96
|
+
});
|
|
97
|
+
it('removes the consumable purchase row on REFUND', async () => {
|
|
98
|
+
await purchaseStore.savePurchase(samplePurchase({ transactionId: 'txn_consumable_a' }));
|
|
99
|
+
const signedTransactionInfo = makeJws({
|
|
100
|
+
bundleId: 'com.example.app',
|
|
101
|
+
type: 'Consumable',
|
|
102
|
+
productId: 'credits_100',
|
|
103
|
+
transactionId: 'txn_consumable_a',
|
|
104
|
+
originalTransactionId: 'orig_consumable_a',
|
|
105
|
+
purchaseDate: Date.now(),
|
|
106
|
+
});
|
|
107
|
+
const signedRenewalInfo = makeJws({});
|
|
108
|
+
const signedPayload = makeJws({
|
|
109
|
+
notificationType: 'REFUND',
|
|
110
|
+
data: { signedTransactionInfo, signedRenewalInfo },
|
|
111
|
+
});
|
|
112
|
+
const resp = await server.request('/onesub/webhook/apple', { signedPayload });
|
|
113
|
+
expect(resp.status).toBe(200);
|
|
114
|
+
expect(await purchaseStore.getPurchaseByTransactionId('txn_consumable_a')).toBeNull();
|
|
115
|
+
});
|
|
116
|
+
it('removes the non-consumable purchase row on REVOKE', async () => {
|
|
117
|
+
await purchaseStore.savePurchase(samplePurchase({
|
|
118
|
+
transactionId: 'txn_nc_a',
|
|
119
|
+
type: 'non_consumable',
|
|
120
|
+
productId: 'premium_unlock',
|
|
121
|
+
}));
|
|
122
|
+
const signedTransactionInfo = makeJws({
|
|
123
|
+
bundleId: 'com.example.app',
|
|
124
|
+
type: 'Non-Consumable',
|
|
125
|
+
productId: 'premium_unlock',
|
|
126
|
+
transactionId: 'txn_nc_a',
|
|
127
|
+
originalTransactionId: 'txn_nc_a',
|
|
128
|
+
purchaseDate: Date.now(),
|
|
129
|
+
});
|
|
130
|
+
const signedPayload = makeJws({
|
|
131
|
+
notificationType: 'REVOKE',
|
|
132
|
+
data: { signedTransactionInfo, signedRenewalInfo: makeJws({}) },
|
|
133
|
+
});
|
|
134
|
+
const resp = await server.request('/onesub/webhook/apple', { signedPayload });
|
|
135
|
+
expect(resp.status).toBe(200);
|
|
136
|
+
expect(await purchaseStore.getPurchaseByTransactionId('txn_nc_a')).toBeNull();
|
|
137
|
+
});
|
|
138
|
+
it('does not touch the SubscriptionStore on IAP REFUND', async () => {
|
|
139
|
+
await store.save(sampleSub({ originalTransactionId: 'orig_sub_untouched' }));
|
|
140
|
+
await purchaseStore.savePurchase(samplePurchase({ transactionId: 'iap_only' }));
|
|
141
|
+
const signedTransactionInfo = makeJws({
|
|
142
|
+
bundleId: 'com.example.app',
|
|
143
|
+
type: 'Consumable',
|
|
144
|
+
productId: 'credits_100',
|
|
145
|
+
transactionId: 'iap_only',
|
|
146
|
+
originalTransactionId: 'iap_only',
|
|
147
|
+
purchaseDate: Date.now(),
|
|
148
|
+
});
|
|
149
|
+
const signedPayload = makeJws({
|
|
150
|
+
notificationType: 'REFUND',
|
|
151
|
+
data: { signedTransactionInfo, signedRenewalInfo: makeJws({}) },
|
|
152
|
+
});
|
|
153
|
+
await server.request('/onesub/webhook/apple', { signedPayload });
|
|
154
|
+
expect(await store.getByTransactionId('orig_sub_untouched')).not.toBeNull();
|
|
155
|
+
});
|
|
156
|
+
it('still routes subscription REFUND through the SubscriptionStore', async () => {
|
|
157
|
+
await store.save(sampleSub({
|
|
158
|
+
platform: 'apple',
|
|
159
|
+
originalTransactionId: 'orig_sub_apple',
|
|
160
|
+
status: 'active',
|
|
161
|
+
}));
|
|
162
|
+
const signedTransactionInfo = makeJws({
|
|
163
|
+
bundleId: 'com.example.app',
|
|
164
|
+
type: 'Auto-Renewable Subscription',
|
|
165
|
+
productId: 'pro_monthly',
|
|
166
|
+
transactionId: 'tx_sub_apple_1',
|
|
167
|
+
originalTransactionId: 'orig_sub_apple',
|
|
168
|
+
purchaseDate: Date.now(),
|
|
169
|
+
expiresDate: Date.now() + 86400000,
|
|
170
|
+
});
|
|
171
|
+
const signedPayload = makeJws({
|
|
172
|
+
notificationType: 'REFUND',
|
|
173
|
+
data: { signedTransactionInfo, signedRenewalInfo: makeJws({}) },
|
|
174
|
+
});
|
|
175
|
+
const resp = await server.request('/onesub/webhook/apple', { signedPayload });
|
|
176
|
+
expect(resp.status).toBe(200);
|
|
177
|
+
const updated = await store.getByTransactionId('orig_sub_apple');
|
|
178
|
+
expect(updated?.status).toBe(SUBSCRIPTION_STATUS.CANCELED);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
// ── Google webhook: voidedPurchaseNotification ──────────────────────────────
|
|
182
|
+
function makeVoidedPushBody(notification) {
|
|
183
|
+
const json = JSON.stringify({
|
|
184
|
+
version: '1.0',
|
|
185
|
+
eventTimeMillis: String(Date.now()),
|
|
186
|
+
...notification,
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
message: {
|
|
190
|
+
data: Buffer.from(json, 'utf-8').toString('base64'),
|
|
191
|
+
messageId: '1',
|
|
192
|
+
},
|
|
193
|
+
subscription: 'projects/x/subscriptions/y',
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
describe('Google webhook — voidedPurchaseNotification', () => {
|
|
197
|
+
let store;
|
|
198
|
+
let purchaseStore;
|
|
199
|
+
let server;
|
|
200
|
+
beforeEach(() => {
|
|
201
|
+
store = new InMemorySubscriptionStore();
|
|
202
|
+
purchaseStore = new InMemoryPurchaseStore();
|
|
203
|
+
server = buildServer(googleConfig(), store, purchaseStore);
|
|
204
|
+
});
|
|
205
|
+
it('removes IAP row when productType=2 (one-time product refund)', async () => {
|
|
206
|
+
await purchaseStore.savePurchase(samplePurchase({
|
|
207
|
+
platform: 'google',
|
|
208
|
+
transactionId: 'GPA.refunded_order',
|
|
209
|
+
}));
|
|
210
|
+
const resp = await server.request('/onesub/webhook/google', makeVoidedPushBody({
|
|
211
|
+
packageName: 'com.example.app',
|
|
212
|
+
voidedPurchaseNotification: {
|
|
213
|
+
purchaseToken: 'tok_x',
|
|
214
|
+
orderId: 'GPA.refunded_order',
|
|
215
|
+
productType: 2,
|
|
216
|
+
refundType: 1,
|
|
217
|
+
},
|
|
218
|
+
}));
|
|
219
|
+
expect(resp.status).toBe(200);
|
|
220
|
+
expect(await purchaseStore.getPurchaseByTransactionId('GPA.refunded_order')).toBeNull();
|
|
221
|
+
});
|
|
222
|
+
it('cancels subscription when productType=1', async () => {
|
|
223
|
+
await store.save(sampleSub({ originalTransactionId: 'tok_sub' }));
|
|
224
|
+
const resp = await server.request('/onesub/webhook/google', makeVoidedPushBody({
|
|
225
|
+
packageName: 'com.example.app',
|
|
226
|
+
voidedPurchaseNotification: {
|
|
227
|
+
purchaseToken: 'tok_sub',
|
|
228
|
+
orderId: 'GPA.sub_order',
|
|
229
|
+
productType: 1,
|
|
230
|
+
refundType: 1,
|
|
231
|
+
},
|
|
232
|
+
}));
|
|
233
|
+
expect(resp.status).toBe(200);
|
|
234
|
+
const updated = await store.getByTransactionId('tok_sub');
|
|
235
|
+
expect(updated?.status).toBe(SUBSCRIPTION_STATUS.CANCELED);
|
|
236
|
+
});
|
|
237
|
+
it('rejects voided notification when packageName mismatches', async () => {
|
|
238
|
+
const resp = await server.request('/onesub/webhook/google', makeVoidedPushBody({
|
|
239
|
+
packageName: 'com.attacker.app',
|
|
240
|
+
voidedPurchaseNotification: {
|
|
241
|
+
purchaseToken: 'tok',
|
|
242
|
+
orderId: 'GPA.x',
|
|
243
|
+
productType: 2,
|
|
244
|
+
refundType: 1,
|
|
245
|
+
},
|
|
246
|
+
}));
|
|
247
|
+
expect(resp.status).toBe(400);
|
|
248
|
+
});
|
|
249
|
+
it('acknowledges with 200 even when the orderId is unknown', async () => {
|
|
250
|
+
// Idempotent ack semantics — Google retries until 2xx; we don't want loops
|
|
251
|
+
// when the row was already removed.
|
|
252
|
+
const resp = await server.request('/onesub/webhook/google', makeVoidedPushBody({
|
|
253
|
+
packageName: 'com.example.app',
|
|
254
|
+
voidedPurchaseNotification: {
|
|
255
|
+
purchaseToken: 'tok',
|
|
256
|
+
orderId: 'GPA.unknown',
|
|
257
|
+
productType: 2,
|
|
258
|
+
refundType: 1,
|
|
259
|
+
},
|
|
260
|
+
}));
|
|
261
|
+
expect(resp.status).toBe(200);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
// ── decodeGoogleVoidedNotification unit ─────────────────────────────────────
|
|
265
|
+
describe('decodeGoogleVoidedNotification', () => {
|
|
266
|
+
it('returns null for subscription notifications', () => {
|
|
267
|
+
const json = JSON.stringify({
|
|
268
|
+
packageName: 'com.example.app',
|
|
269
|
+
eventTimeMillis: '0',
|
|
270
|
+
subscriptionNotification: {
|
|
271
|
+
version: '1.0',
|
|
272
|
+
notificationType: 4,
|
|
273
|
+
purchaseToken: 't',
|
|
274
|
+
subscriptionId: 'p',
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
const result = decodeGoogleVoidedNotification({
|
|
278
|
+
message: { data: Buffer.from(json).toString('base64'), messageId: '1' },
|
|
279
|
+
subscription: 's',
|
|
280
|
+
});
|
|
281
|
+
expect(result).toBeNull();
|
|
282
|
+
});
|
|
283
|
+
it('extracts voided payload fields', () => {
|
|
284
|
+
const json = JSON.stringify({
|
|
285
|
+
packageName: 'com.example.app',
|
|
286
|
+
eventTimeMillis: '0',
|
|
287
|
+
voidedPurchaseNotification: {
|
|
288
|
+
purchaseToken: 'tok123',
|
|
289
|
+
orderId: 'GPA.xyz',
|
|
290
|
+
productType: 2,
|
|
291
|
+
refundType: 1,
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
const result = decodeGoogleVoidedNotification({
|
|
295
|
+
message: { data: Buffer.from(json).toString('base64'), messageId: '1' },
|
|
296
|
+
subscription: 's',
|
|
297
|
+
});
|
|
298
|
+
expect(result).toEqual({
|
|
299
|
+
purchaseToken: 'tok123',
|
|
300
|
+
orderId: 'GPA.xyz',
|
|
301
|
+
productType: 2,
|
|
302
|
+
refundType: 1,
|
|
303
|
+
packageName: 'com.example.app',
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
it('returns null for malformed base64', () => {
|
|
307
|
+
expect(decodeGoogleVoidedNotification({
|
|
308
|
+
message: { data: '!!!not-base64!!!', messageId: '1' },
|
|
309
|
+
subscription: 's',
|
|
310
|
+
})).toBeNull();
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
//# sourceMappingURL=webhook-refund.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-refund.test.js","sourceRoot":"","sources":["../../src/__tests__/webhook-refund.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,M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C,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,8BAA8B,CAAC;YACpC,OAAO,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,GAAG,EAAE;YACrD,YAAY,EAAE,GAAG;SAClB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound HTTP helpers shared by Apple/Google providers.
|
|
3
|
+
*
|
|
4
|
+
* Why timeouts: Node's global fetch has no default timeout. If the upstream
|
|
5
|
+
* (Apple App Store Server API, Google Play Developer API, Google OAuth) hangs,
|
|
6
|
+
* webhook handlers and validate routes hang with it — Apple/Google retry on
|
|
7
|
+
* their side, so a hung outbound call cascades into request pile-up here.
|
|
8
|
+
*/
|
|
9
|
+
/** Default timeout for outbound API calls (10s). */
|
|
10
|
+
export declare const DEFAULT_FETCH_TIMEOUT_MS = 10000;
|
|
11
|
+
/**
|
|
12
|
+
* fetch with an `AbortController`-based timeout. Throws an `AbortError`-like
|
|
13
|
+
* Error when the timer fires. Caller is expected to catch and decide
|
|
14
|
+
* (return null, log, propagate as 5xx, etc.).
|
|
15
|
+
*/
|
|
16
|
+
export declare function fetchWithTimeout(input: RequestInfo | URL, init?: RequestInit, timeoutMs?: number): Promise<Response>;
|
|
17
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oDAAoD;AACpD,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,EAClB,SAAS,SAA2B,GACnC,OAAO,CAAC,QAAQ,CAAC,CAkBnB"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound HTTP helpers shared by Apple/Google providers.
|
|
3
|
+
*
|
|
4
|
+
* Why timeouts: Node's global fetch has no default timeout. If the upstream
|
|
5
|
+
* (Apple App Store Server API, Google Play Developer API, Google OAuth) hangs,
|
|
6
|
+
* webhook handlers and validate routes hang with it — Apple/Google retry on
|
|
7
|
+
* their side, so a hung outbound call cascades into request pile-up here.
|
|
8
|
+
*/
|
|
9
|
+
/** Default timeout for outbound API calls (10s). */
|
|
10
|
+
export const DEFAULT_FETCH_TIMEOUT_MS = 10_000;
|
|
11
|
+
/**
|
|
12
|
+
* fetch with an `AbortController`-based timeout. Throws an `AbortError`-like
|
|
13
|
+
* Error when the timer fires. Caller is expected to catch and decide
|
|
14
|
+
* (return null, log, propagate as 5xx, etc.).
|
|
15
|
+
*/
|
|
16
|
+
export async function fetchWithTimeout(input, init, timeoutMs = DEFAULT_FETCH_TIMEOUT_MS) {
|
|
17
|
+
const controller = new AbortController();
|
|
18
|
+
// Allow caller-provided signal to compose with our timeout.
|
|
19
|
+
const callerSignal = init?.signal;
|
|
20
|
+
if (callerSignal) {
|
|
21
|
+
if (callerSignal.aborted)
|
|
22
|
+
controller.abort(callerSignal.reason);
|
|
23
|
+
else
|
|
24
|
+
callerSignal.addEventListener('abort', () => controller.abort(callerSignal.reason), { once: true });
|
|
25
|
+
}
|
|
26
|
+
const timer = setTimeout(() => {
|
|
27
|
+
controller.abort(new Error(`[onesub] fetch timed out after ${timeoutMs}ms`));
|
|
28
|
+
}, timeoutMs);
|
|
29
|
+
try {
|
|
30
|
+
return await fetch(input, { ...init, signal: controller.signal });
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAE/C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAwB,EACxB,IAAkB,EAClB,SAAS,GAAG,wBAAwB;IAEpC,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,4DAA4D;IAC5D,MAAM,YAAY,GAAG,IAAI,EAAE,MAAM,CAAC;IAClC,IAAI,YAAY,EAAE,CAAC;QACjB,IAAI,YAAY,CAAC,OAAO;YAAE,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;;YAC3D,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3G,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAC5B,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,kCAAkC,SAAS,IAAI,CAAC,CAAC,CAAC;IAC/E,CAAC,EAAE,SAAS,CAAC,CAAC;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IACpE,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare function createOneSubServer(config: OneSubMiddlewareConfig): Retu
|
|
|
47
47
|
export { InMemorySubscriptionStore, InMemoryPurchaseStore } from './store.js';
|
|
48
48
|
export type { SubscriptionStore, PurchaseStore } from './store.js';
|
|
49
49
|
export { PostgresSubscriptionStore, PostgresPurchaseStore } from './stores/postgres.js';
|
|
50
|
-
export { validateAppleReceipt } from './providers/apple.js';
|
|
50
|
+
export { validateAppleReceipt, fetchAppleSubscriptionStatus } from './providers/apple.js';
|
|
51
51
|
export { validateGoogleReceipt } from './providers/google.js';
|
|
52
52
|
export { setLogger, log } from './logger.js';
|
|
53
53
|
export default createOneSubMiddleware;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAQnE;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE;;;OAGG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CA+B7E;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAW7F;AAGD,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC9E,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAQnE;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE;;;OAGG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CA+B7E;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAW7F;AAGD,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC9E,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGxF,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAI9D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAG7C,eAAe,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ export function createOneSubMiddleware(config) {
|
|
|
40
40
|
router.use(express.json({ limit: '50kb' }));
|
|
41
41
|
router.use(createValidateRouter(config, store));
|
|
42
42
|
router.use(createStatusRouter(store));
|
|
43
|
-
router.use(createWebhookRouter(config, store));
|
|
43
|
+
router.use(createWebhookRouter(config, store, purchaseStore));
|
|
44
44
|
router.use(createPurchaseRouter(config, purchaseStore));
|
|
45
45
|
// Admin routes — only mounted when config.adminSecret is set
|
|
46
46
|
const adminRouter = createAdminRouter(config, purchaseStore);
|
|
@@ -69,7 +69,7 @@ export function createOneSubServer(config) {
|
|
|
69
69
|
export { InMemorySubscriptionStore, InMemoryPurchaseStore } from './store.js';
|
|
70
70
|
export { PostgresSubscriptionStore, PostgresPurchaseStore } from './stores/postgres.js';
|
|
71
71
|
// Provider functions for direct (non-HTTP) usage
|
|
72
|
-
export { validateAppleReceipt } from './providers/apple.js';
|
|
72
|
+
export { validateAppleReceipt, fetchAppleSubscriptionStatus } from './providers/apple.js';
|
|
73
73
|
export { validateGoogleReceipt } from './providers/google.js';
|
|
74
74
|
// Logger plumbing — expose so non-middleware callers (direct provider use)
|
|
75
75
|
// can still redirect logs.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAmBxC;;;;;;;;;;;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,EAAE,GAAG,EAAE;QAC3C,OAAO,CAAC,GAAG,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SubscriptionInfo, AppleNotificationPayload, OneSubServerConfig } from '@onesub/shared';
|
|
1
|
+
import type { SubscriptionInfo, AppleNotificationPayload, AppleConsumptionRequest, OneSubServerConfig } from '@onesub/shared';
|
|
2
2
|
type AppleConfig = NonNullable<OneSubServerConfig['apple']>;
|
|
3
3
|
/**
|
|
4
4
|
* Decode and verify a StoreKit 2 signed transaction JWS.
|
|
@@ -46,9 +46,57 @@ export declare function validateAppleConsumableReceipt(signedTransaction: string
|
|
|
46
46
|
*/
|
|
47
47
|
export declare function decodeAppleNotification(payload: AppleNotificationPayload, skipJwsVerification?: boolean): Promise<{
|
|
48
48
|
originalTransactionId: string;
|
|
49
|
+
/** Per-transaction id (different from originalTransactionId for consumables / re-purchases). */
|
|
50
|
+
transactionId: string | null;
|
|
51
|
+
/** 'Auto-Renewable Subscription' | 'Consumable' | 'Non-Consumable' | 'Non-Renewing Subscription' */
|
|
52
|
+
type: string | null;
|
|
53
|
+
productId: string | null;
|
|
54
|
+
bundleId: string | null;
|
|
55
|
+
/** 'Production' | 'Sandbox' — drives which Apple API host to call back. */
|
|
56
|
+
environment: 'Production' | 'Sandbox';
|
|
49
57
|
status: SubscriptionInfo['status'];
|
|
50
58
|
willRenew: boolean;
|
|
51
|
-
|
|
59
|
+
/** May be null for non-subscription notifications (consumable refund). */
|
|
60
|
+
expiresAt: string | null;
|
|
52
61
|
} | null>;
|
|
62
|
+
/** Test-only: clear the module-level Apple JWT cache. Not exported. */
|
|
63
|
+
declare function clearAppleJwtCacheForTests(): void;
|
|
64
|
+
export declare const __testing: {
|
|
65
|
+
clearAppleJwtCacheForTests: typeof clearAppleJwtCacheForTests;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* PUT a ConsumptionRequest to Apple's
|
|
69
|
+
* /inApps/v1/transactions/consumption/{transactionId} endpoint.
|
|
70
|
+
*
|
|
71
|
+
* Apple sends CONSUMPTION_REQUEST notifications when a customer asks for a
|
|
72
|
+
* refund on a consumable. Without a response Apple has no usage signal and
|
|
73
|
+
* tends to grant the refund. This call provides the data Apple uses to weigh
|
|
74
|
+
* the refund decision.
|
|
75
|
+
*
|
|
76
|
+
* Fire-and-forget: failures are logged, never thrown — the webhook should
|
|
77
|
+
* still 200 to Apple even if our outbound call fails.
|
|
78
|
+
*/
|
|
79
|
+
export declare function sendAppleConsumptionResponse(transactionId: string, body: AppleConsumptionRequest, config: AppleConfig, options?: {
|
|
80
|
+
sandbox?: boolean;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Fetch the current state of a subscription directly from Apple's App Store
|
|
84
|
+
* Server API — the canonical source of truth when webhooks have been missed,
|
|
85
|
+
* delivered out of order, or the local store has no record at all.
|
|
86
|
+
*
|
|
87
|
+
* GET /inApps/v1/subscriptions/{originalTransactionId}
|
|
88
|
+
* https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses
|
|
89
|
+
*
|
|
90
|
+
* Returns null on:
|
|
91
|
+
* - Missing API credentials (issuerId/keyId/privateKey)
|
|
92
|
+
* - Network or auth failure
|
|
93
|
+
* - Empty response (transaction not found)
|
|
94
|
+
*
|
|
95
|
+
* Hosts can call this directly (e.g. from a reconciliation cron) or it runs
|
|
96
|
+
* automatically as the unknown-transaction fallback inside the Apple webhook.
|
|
97
|
+
*/
|
|
98
|
+
export declare function fetchAppleSubscriptionStatus(originalTransactionId: string, config: AppleConfig, options?: {
|
|
99
|
+
sandbox?: boolean;
|
|
100
|
+
}): Promise<SubscriptionInfo | null>;
|
|
53
101
|
export {};
|
|
54
102
|
//# sourceMappingURL=apple.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apple.d.ts","sourceRoot":"","sources":["../../src/providers/apple.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"apple.d.ts","sourceRoot":"","sources":["../../src/providers/apple.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAUxB,KAAK,WAAW,GAAG,WAAW,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AA2F5D;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,gBAAgB,UAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAuBpF;AAsBD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAoDlC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAsB,8BAA8B,CAClD,iBAAiB,EAAE,MAAM,EACzB,MAAM,EAAE,WAAW,EACnB,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAgFpC;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,wBAAwB,EACjC,mBAAmB,UAAQ,GAC1B,OAAO,CAAC;IACT,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gGAAgG;IAChG,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,oGAAoG;IACpG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAA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