@onesub/server 0.12.0 → 0.13.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.
@@ -58,6 +58,19 @@ export declare function decodeAppleNotification(payload: AppleNotificationPayloa
58
58
  willRenew: boolean;
59
59
  /** May be null for non-subscription notifications (consumable refund). */
60
60
  expiresAt: string | null;
61
+ /**
62
+ * UUID the app set via setAppAccountToken at purchase time. For onesub this
63
+ * maps directly to userId. Present for both PURCHASED and FAMILY_SHARED
64
+ * ownership types when the host linked a user account at checkout time.
65
+ * Null when not set (sandbox, or host didn't call setAppAccountToken).
66
+ */
67
+ appAccountToken: string | null;
68
+ /**
69
+ * 'PURCHASED' — the user bought this directly.
70
+ * 'FAMILY_SHARED' — a family member of the purchaser. The originalTransactionId
71
+ * and appAccountToken belong to the family member, not the purchaser.
72
+ */
73
+ inAppOwnershipType: string | null;
61
74
  } | null>;
62
75
  /** Test-only: clear the Apple JWT cache. Not exported. */
63
76
  declare function clearAppleJwtCacheForTests(): void;
@@ -98,5 +111,68 @@ export declare function sendAppleConsumptionResponse(transactionId: string, body
98
111
  export declare function fetchAppleSubscriptionStatus(originalTransactionId: string, config: AppleConfig, options?: {
99
112
  sandbox?: boolean;
100
113
  }): Promise<SubscriptionInfo | null>;
114
+ /**
115
+ * Decoded lightweight transaction record from transaction history.
116
+ */
117
+ export interface AppleTransactionRecord {
118
+ originalTransactionId: string;
119
+ transactionId: string;
120
+ productId: string;
121
+ type: string;
122
+ purchasedAt: string;
123
+ expiresAt: string | null;
124
+ appAccountToken: string | null;
125
+ inAppOwnershipType: string | null;
126
+ revocationDate: string | null;
127
+ }
128
+ /**
129
+ * Fetch all transactions for an originalTransactionId from the App Store
130
+ * Transaction History API (GET /inApps/v2/history/{originalTransactionId}).
131
+ *
132
+ * Paginates automatically until `hasMore` is false. Returns all decoded
133
+ * transaction records, oldest-first (Apple's default sort).
134
+ *
135
+ * Returns null when API credentials are missing or the call fails.
136
+ */
137
+ export declare function fetchAppleTransactionHistory(originalTransactionId: string, config: AppleConfig, options?: {
138
+ sandbox?: boolean;
139
+ }): Promise<AppleTransactionRecord[] | null>;
140
+ /**
141
+ * Input for signing an Apple Promotional Offer payload.
142
+ * https://developer.apple.com/documentation/storekit/generating-a-signature-for-promotional-offers
143
+ */
144
+ export interface AppleOfferSignatureInput {
145
+ /** App Bundle ID (e.g. com.example.app) */
146
+ bundleId: string;
147
+ /** The product ID of the subscription being offered */
148
+ productId: string;
149
+ /** The promotional offer ID defined in App Store Connect */
150
+ offerId: string;
151
+ /** A unique UUID generated per request (the nonce) */
152
+ applicationUsername: string;
153
+ }
154
+ /**
155
+ * Result returned to the client so StoreKit can verify the offer.
156
+ */
157
+ export interface AppleOfferSignatureResult {
158
+ keyId: string;
159
+ nonce: string;
160
+ timestamp: number;
161
+ signature: string;
162
+ }
163
+ /**
164
+ * Sign an Apple Promotional Offer payload with ES256 (ECDSA P-256).
165
+ *
166
+ * The message to sign is:
167
+ * appBundleId + '⁣' + keyIdentifier + '⁣' + productIdentifier + '⁣'
168
+ * + offerIdentifier + '⁣' + applicationUsername + '⁣'
169
+ * + nonce (lowercase) + '⁣' + timestamp (ms, string)
170
+ *
171
+ * Requires `config.offerKeyId` and `config.offerPrivateKey` (PEM ES256 key from
172
+ * App Store Connect → Subscriptions → Promotional Offers → Keys).
173
+ *
174
+ * Throws if the required keys are not configured.
175
+ */
176
+ export declare function signApplePromotionalOffer(input: AppleOfferSignatureInput, config: AppleConfig): Promise<AppleOfferSignatureResult>;
101
177
  export {};
102
178
  //# 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,EACV,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAWxB,KAAK,WAAW,GAAG,WAAW,CAAC,kBAAkB,CAAC,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B,CAAC,CAoCpC"}
@@ -20,6 +20,20 @@ declare const GOOGLE_NOTIFICATION_TYPE: {
20
20
  readonly SUBSCRIPTION_EXPIRED: 13;
21
21
  };
22
22
  type GoogleNotificationType = (typeof GOOGLE_NOTIFICATION_TYPE)[keyof typeof GOOGLE_NOTIFICATION_TYPE];
23
+ /**
24
+ * Decoded Google RTDN oneTimeProductNotification — sent when a consumable or
25
+ * non-consumable product is purchased or canceled before acknowledgment.
26
+ *
27
+ * https://developer.android.com/google/play/billing/rtdn-reference#one-time
28
+ */
29
+ export interface GoogleOneTimeProductNotification {
30
+ /** 1 = PURCHASED, 2 = CANCELED (user canceled before purchase completed) */
31
+ notificationType: 1 | 2;
32
+ purchaseToken: string;
33
+ /** Product SKU / productId */
34
+ sku: string;
35
+ packageName: string;
36
+ }
23
37
  /**
24
38
  * Acknowledge a Google Play subscription purchase.
25
39
  * Google auto-refunds purchases that are not acknowledged within 3 days.
@@ -110,6 +124,17 @@ export interface GoogleVoidedNotification {
110
124
  * Returns null when the payload is a different notification kind.
111
125
  */
112
126
  export declare function decodeGoogleVoidedNotification(payload: GoogleNotificationPayload): GoogleVoidedNotification | null;
127
+ /**
128
+ * Decode a Google RTDN oneTimeProductNotification, if the payload is one.
129
+ * Returns null when the payload is a different notification kind.
130
+ *
131
+ * Note: the notification does NOT carry userId context. For PURCHASED, the
132
+ * receipt must be acknowledged via acknowledgeGoogleProduct to prevent the
133
+ * 3-day auto-refund window. The userId is only known after the client calls
134
+ * POST /onesub/purchase/validate, which is the authoritative record-creation
135
+ * path. The webhook handler therefore acknowledges without creating a record.
136
+ */
137
+ export declare function decodeGoogleOneTimeProductNotification(payload: GoogleNotificationPayload): GoogleOneTimeProductNotification | null;
113
138
  /**
114
139
  * Determine if a Google RTDN notification type represents an active subscription
115
140
  * inside the paid window (excludes grace period — that's a separate state now).
@@ -1 +1 @@
1
- {"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA,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B,+BAA+B,CAAC,gBAAgB,EAAE,sBAAsB,GAAG,OAAO,CAEjG;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,gBAAgB,EAAE,sBAAsB,GAAG,OAAO,CAE5F;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,gBAAgB,EAAE,sBAAsB,GAAG,OAAO,CAE5F;AAED;;;GAGG;AACH,wBAAgB,wCAAwC,CAAC,gBAAgB,EAAE,sBAAsB,GAAG,OAAO,CAE1G"}
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/routes/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,EAGV,kBAAkB,EAKnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,kBAAkB,EAC1B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,iBAAiB,EACxB,YAAY,CAAC,EAAE,YAAY,GAC1B,MAAM,GAAG,IAAI,CAiQf"}
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/routes/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,EAGV,kBAAkB,EAKnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKxD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,kBAAkB,EAC1B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,iBAAiB,EACxB,YAAY,CAAC,EAAE,YAAY,GAC1B,MAAM,GAAG,IAAI,CA2Sf"}
@@ -0,0 +1,21 @@
1
+ import { Router } from 'express';
2
+ import type { OneSubServerConfig } from '@onesub/shared';
3
+ /**
4
+ * POST /onesub/apple/offer-signature
5
+ *
6
+ * Sign an Apple Promotional Offer payload server-side.
7
+ * Requires config.apple.offerKeyId and config.apple.offerPrivateKey.
8
+ *
9
+ * Authentication: if config.adminSecret is set, the request must carry
10
+ * `X-Onesub-Offer-Secret: <adminSecret>` (same value). Hosts that mount
11
+ * onesub without adminSecret are responsible for securing this endpoint
12
+ * themselves (e.g. behind their own auth middleware).
13
+ *
14
+ * Body: { productId, offerId, applicationUsername }
15
+ * Response: { keyId, nonce, timestamp, signature }
16
+ *
17
+ * The client passes these four values to StoreKit's
18
+ * Product.SubscriptionOffer.Signature to redeem the offer.
19
+ */
20
+ export declare function createAppleOfferRouter(config: OneSubServerConfig): Router | null;
21
+ //# sourceMappingURL=apple-offer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apple-offer.d.ts","sourceRoot":"","sources":["../../src/routes/apple-offer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAazD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,GAAG,IAAI,CA+ChF"}
@@ -0,0 +1,6 @@
1
+ import type { Request, Response } from 'express';
2
+ import type { OneSubServerConfig } from '@onesub/shared';
3
+ import type { SubscriptionStore, PurchaseStore } from '../store.js';
4
+ import type { WebhookEventStore } from '../webhook-events.js';
5
+ export declare function handleAppleWebhook(req: Request, res: Response, config: OneSubServerConfig, store: SubscriptionStore, purchaseStore: PurchaseStore, webhookEventStore?: WebhookEventStore): Promise<void>;
6
+ //# sourceMappingURL=webhook-apple.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-apple.d.ts","sourceRoot":"","sources":["../../src/routes/webhook-apple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AASpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAsB9D,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,iBAAiB,EACxB,aAAa,EAAE,aAAa,EAC5B,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,IAAI,CAAC,CAwJf"}
@@ -0,0 +1,7 @@
1
+ import type { Request, Response } from 'express';
2
+ import type { OneSubServerConfig } from '@onesub/shared';
3
+ import type { SubscriptionStore, PurchaseStore } from '../store.js';
4
+ import type { WebhookEventStore } from '../webhook-events.js';
5
+ export declare function verifyGooglePushToken(req: Request, expectedAudience: string): Promise<boolean>;
6
+ export declare function handleGoogleWebhook(req: Request, res: Response, config: OneSubServerConfig, store: SubscriptionStore, purchaseStore: PurchaseStore, webhookEventStore?: WebhookEventStore): Promise<void>;
7
+ //# sourceMappingURL=webhook-google.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-google.d.ts","sourceRoot":"","sources":["../../src/routes/webhook-google.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAA6B,kBAAkB,EAAoB,MAAM,gBAAgB,CAAC;AAEtG,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAiBpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAW9D,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAWpG;AAED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,iBAAiB,EACxB,aAAa,EAAE,aAAa,EAC5B,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,IAAI,CAAC,CAmLf"}
@@ -5,23 +5,10 @@ import type { WebhookEventStore } from '../webhook-events.js';
5
5
  /**
6
6
  * Retry / durability semantics.
7
7
  *
8
- * Both Apple (App Store Server Notifications V2) and Google (Pub/Sub RTDN)
9
- * retry on any non-2xx response:
10
- * - Apple: up to 5 retries over ~3 days, exponential backoff.
11
- * - Google: per-Pub/Sub-subscription retry policy (default: retries until
12
- * the message is ack'd or the retention window expires, up to 7 days).
13
- *
14
- * This router uses that built-in retry instead of a local dead-letter queue:
15
- *
16
- * 4xx — the payload is unusable (missing signedPayload, bad signature,
17
- * package mismatch). Return 4xx so the sender does NOT retry, since
18
- * the same request would fail again.
19
- * 5xx — a transient failure on our side (DB down, network to Play API).
20
- * Return 5xx so Apple / Google retry the notification for us.
21
- * 2xx — processed, or intentionally ignored (e.g. test notification).
22
- *
23
- * If you need an explicit DLQ, wrap `store.save()` with your own error
24
- * handler before passing the store to `createOneSubMiddleware()`.
8
+ * Both Apple and Google retry on any non-2xx response.
9
+ * 4xx payload is unusable; do NOT retry.
10
+ * 5xx transient failure; source will retry.
11
+ * 2xx processed or intentionally ignored.
25
12
  */
26
13
  export declare function createWebhookRouter(config: OneSubServerConfig, store: SubscriptionStore, purchaseStore: PurchaseStore, webhookEventStore?: WebhookEventStore): Router;
27
14
  //# sourceMappingURL=webhook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/routes/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,EAGV,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAqBpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAiG9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,iBAAiB,EACxB,aAAa,EAAE,aAAa,EAC5B,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,MAAM,CAmZR"}
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/routes/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,iBAAiB,EACxB,aAAa,EAAE,aAAa,EAC5B,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,MAAM,CAYR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onesub/server",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Server-side receipt validation middleware for react-native-iap. Apple StoreKit 2 + Google Play Billing. One line.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "license": "MIT",
55
55
  "dependencies": {
56
- "@onesub/shared": "0.7.5",
56
+ "@onesub/shared": "0.8.0",
57
57
  "jose": "^6.2.2",
58
58
  "zod": "^4.3.6"
59
59
  },