@mpgd/capacitor-play-billing 0.1.7 → 0.1.8
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/provider.d.ts +9 -2
- package/dist/provider.js +12 -14
- package/package.json +6 -6
package/dist/provider.d.ts
CHANGED
|
@@ -75,5 +75,12 @@ export declare function recoverOwnedPlayPurchases(input: {
|
|
|
75
75
|
readonly now?: () => string;
|
|
76
76
|
}): Promise<readonly RecoveredPlayPurchase[]>;
|
|
77
77
|
export declare function createCapacitorPlayBillingProvider(options: PlayBillingProviderOptions): CapacitorPlayBillingProvider;
|
|
78
|
-
/**
|
|
79
|
-
|
|
78
|
+
/**
|
|
79
|
+
* The server's token transaction ID, computed by the one shared helper so the
|
|
80
|
+
* plugin and `@mpgd/game-services` can never drift.
|
|
81
|
+
*
|
|
82
|
+
* @deprecated Use `createGooglePlayTokenPurchaseKey` from `@mpgd/platform/commerce`;
|
|
83
|
+
* this alias is the same function (same key, same `TypeError` for an invalid
|
|
84
|
+
* token) and will be removed in the next major version.
|
|
85
|
+
*/
|
|
86
|
+
export declare const createGooglePlayTokenTransactionId: (purchaseToken: string) => Promise<string>;
|
package/dist/provider.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Capacitor } from '@capacitor/core';
|
|
2
|
+
import { createGooglePlayTokenPurchaseKey } from '@mpgd/platform/commerce';
|
|
2
3
|
import { CapacitorPlayBilling } from './plugin.js';
|
|
3
4
|
const googlePlayProductPurchaseEvidenceSchema = 'google-play.product-purchase.v2';
|
|
4
5
|
class PlayPurchaseIntegrityError extends Error {
|
|
@@ -38,7 +39,7 @@ export async function recoverOwnedPlayPurchases(input) {
|
|
|
38
39
|
playerId: input.playerId,
|
|
39
40
|
productId,
|
|
40
41
|
platformTransactionId: result.transactionId,
|
|
41
|
-
idempotencyKey: await
|
|
42
|
+
idempotencyKey: await createGooglePlayTokenPurchaseKey(token),
|
|
42
43
|
purchasedAt: purchasedAt ?? input.now?.() ?? new Date().toISOString(),
|
|
43
44
|
evidence: result.evidence,
|
|
44
45
|
});
|
|
@@ -268,7 +269,7 @@ async function convertPurchase(purchase) {
|
|
|
268
269
|
return { status: 'pending', entitlementIds: [], evidence };
|
|
269
270
|
}
|
|
270
271
|
const transactionId = purchase.orderId?.trim()
|
|
271
|
-
|| await
|
|
272
|
+
|| await createGooglePlayTokenPurchaseKey(purchase.purchaseToken);
|
|
272
273
|
return {
|
|
273
274
|
status: 'completed',
|
|
274
275
|
transactionId,
|
|
@@ -276,18 +277,15 @@ async function convertPurchase(purchase) {
|
|
|
276
277
|
evidence,
|
|
277
278
|
};
|
|
278
279
|
}
|
|
279
|
-
/**
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const digest = new Uint8Array(await subtle.digest('SHA-256', new TextEncoder().encode(purchaseToken)));
|
|
289
|
-
return `play-token-sha256:${[...digest].map((value) => value.toString(16).padStart(2, '0')).join('')}`;
|
|
290
|
-
}
|
|
280
|
+
/**
|
|
281
|
+
* The server's token transaction ID, computed by the one shared helper so the
|
|
282
|
+
* plugin and `@mpgd/game-services` can never drift.
|
|
283
|
+
*
|
|
284
|
+
* @deprecated Use `createGooglePlayTokenPurchaseKey` from `@mpgd/platform/commerce`;
|
|
285
|
+
* this alias is the same function (same key, same `TypeError` for an invalid
|
|
286
|
+
* token) and will be removed in the next major version.
|
|
287
|
+
*/
|
|
288
|
+
export const createGooglePlayTokenTransactionId = createGooglePlayTokenPurchaseKey;
|
|
291
289
|
function success(id, data) {
|
|
292
290
|
return { id, ok: true, data };
|
|
293
291
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpgd/capacitor-play-billing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Opt-in Android Google Play Billing purchase collector for mpgd Capacitor games.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@capacitor/core": "^8.5.1",
|
|
41
|
-
"@mpgd/bridge": "^0.
|
|
42
|
-
"@mpgd/platform": "^0.
|
|
41
|
+
"@mpgd/bridge": "^0.12.0",
|
|
42
|
+
"@mpgd/platform": "^0.19.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@capacitor/core": "8.5.2",
|
|
46
46
|
"ttsc": "0.30.4",
|
|
47
47
|
"typescript": "7.0.2",
|
|
48
|
-
"@mpgd/
|
|
49
|
-
"@mpgd/
|
|
50
|
-
"@mpgd/platform": "0.
|
|
48
|
+
"@mpgd/game-services": "0.20.0",
|
|
49
|
+
"@mpgd/bridge": "0.12.0",
|
|
50
|
+
"@mpgd/platform": "0.19.0"
|
|
51
51
|
},
|
|
52
52
|
"main": "./dist/index.js",
|
|
53
53
|
"types": "./dist/index.d.ts",
|