@mpgd/capacitor-storekit 0.2.1 → 0.2.3

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/README.md CHANGED
@@ -111,14 +111,19 @@ default) so the gateway serves the `commerce.v2.*` and v1 `commerce.*`
111
111
  bridge methods from it and exposes it as `gateway.commerceV2`.
112
112
 
113
113
  Finishing never grants. The v2 SDK finishes any transaction it is given a
114
- `ledgerEntryId` for: the commerce v2 reconciler is the gate, and it calls
115
- `finishTransaction` only after the backend ledger granted the purchase. The
116
- v1 `finishGrantedTransaction` allow-list guard is not reproduced; the real
117
- control stays server-side, in the verifier that checks the JWS before the
118
- ledger grant, and in the native plugin never granting anything on finish.
119
- The v1 recovery helpers (`recoverStoreKitPurchases`,
120
- `getRecoverableTransactions`, `finishGrantedTransaction`) are deprecated in
121
- favor of the single reconciler (RFC C1) and are removed in C4.
114
+ `ledgerEntryId` for: the commerce v2 reconciler
115
+ (`createCommerceReconciler` in `@mpgd/game-services`) is the gate, and it
116
+ calls `finishTransaction` only for a journal record in `granted` or
117
+ `finishing` that holds the ledger entry id the backend grant wrote
118
+ (`assertCommerceFinishAllowed`). The v1 `finishGrantedTransaction`
119
+ allow-list guard is not reproduced in the SDK: the journal revision the grant
120
+ wrote is the pairing, and the real control stays server-side, in the verifier
121
+ that checks the JWS before the ledger grant, and in the native plugin never
122
+ granting anything on finish. The v1 recovery helpers
123
+ (`recoverStoreKitPurchases`, `getRecoverableTransactions`,
124
+ `finishGrantedTransaction`) are deprecated in favor of that reconciler (RFC
125
+ C1) and are removed in C4; `src/commerce-reconciler-storekit-smoke.test.ts`
126
+ shows both paths reaching the same outcomes over the fake plugin.
122
127
 
123
128
  The conformance test runs every store vector whose profile the App Store
124
129
  supports against a fake plugin, directly and through the gateway bridge path,
@@ -126,6 +131,27 @@ and lists each skipped vector with its reason (host or server finish,
126
131
  quantity, server-push, an asynchronous store error event StoreKit never
127
132
  emits, and a pending transaction state StoreKit never reports).
128
133
 
134
+ ### Generated games
135
+
136
+ Games generated by `mpgd game create` (and the kit's private starter) ship
137
+ this wiring in `src/platform/buildGateways/capacitorIos.ts` (commerce v2 PR
138
+ C3): the service provider is registered for every catalog product whose
139
+ `platformProductIds.ios` names an App Store product id (subscriptions are
140
+ skipped), and `getAppAccountToken` is the reference binding in
141
+ `src/platform/commerceAccountBinding.ts`, a UUID (version 5 layout) over the
142
+ SHA-256 of `mpgd-commerce-account:<playerId>` for the authenticated player;
143
+ a guest session throws, so no sheet opens without a binding. The backend's
144
+ `resolveAppAccountToken` must derive the same UUID, or both are replaced
145
+ together.
146
+
147
+ `mpgd target init capacitor --providers storekit` installs this package into
148
+ the game-owned shell and the game at one exact version and lets `cap add` or
149
+ `cap sync` register its Swift package; on a game that still has the unwired
150
+ gateway of an earlier template it also writes the wiring above. A build
151
+ whose shell lacks the native plugin still runs: the plugin answers
152
+ Capacitor's `UNIMPLEMENTED`, which the SDK reports as
153
+ `configuration-required`, so no purchase sheet opens.
154
+
129
155
  ## v1 provider and recovery
130
156
 
131
157
  On startup, account restoration, and after a pending or uncertain checkout,
package/dist/store-sdk.js CHANGED
@@ -396,7 +396,10 @@ export function createCapacitorStoreKitStoreSdk(input) {
396
396
  }
397
397
  catch (error) {
398
398
  const code = isRecord(error) ? error.code : undefined;
399
- return code === 'STOREKIT_INVALID_PRODUCTS' || code === 'STOREKIT_PRODUCT_UNAVAILABLE'
399
+ // Capacitor's `UNIMPLEMENTED` means the native plugin is not installed in the shell.
400
+ return code === 'STOREKIT_INVALID_PRODUCTS'
401
+ || code === 'STOREKIT_PRODUCT_UNAVAILABLE'
402
+ || code === 'UNIMPLEMENTED'
400
403
  ? 'configuration-required'
401
404
  : 'temporarily-unavailable';
402
405
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpgd/capacitor-storekit",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Opt-in StoreKit 2 one-time purchase collector and commerce v2 provider for mpgd Capacitor games.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,18 +38,18 @@
38
38
  ],
39
39
  "peerDependencies": {
40
40
  "@capacitor/core": "^8.5.1",
41
- "@mpgd/adapter-capacitor": "^0.9.1",
42
- "@mpgd/bridge": "^0.12.2",
43
- "@mpgd/platform": "^0.21.0"
41
+ "@mpgd/adapter-capacitor": "^0.9.3",
42
+ "@mpgd/bridge": "^0.12.3",
43
+ "@mpgd/platform": "^0.22.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@capacitor/core": "8.5.2",
47
47
  "ttsc": "0.30.4",
48
48
  "typescript": "7.0.2",
49
- "@mpgd/adapter-capacitor": "0.9.1",
50
- "@mpgd/bridge": "0.12.2",
51
- "@mpgd/game-services": "0.21.1",
52
- "@mpgd/platform": "0.21.0"
49
+ "@mpgd/adapter-capacitor": "0.9.3",
50
+ "@mpgd/platform": "0.22.0",
51
+ "@mpgd/game-services": "0.23.0",
52
+ "@mpgd/bridge": "0.12.3"
53
53
  },
54
54
  "main": "./dist/index.js",
55
55
  "types": "./dist/index.d.ts",
@@ -59,6 +59,6 @@
59
59
  "scripts": {
60
60
  "check": "ttsc --noEmit",
61
61
  "lint": "ttsc --noEmit",
62
- "test": "cd ../.. && node tools/run-ttsx.mjs --project native-plugins/capacitor-storekit/tsconfig.json native-plugins/capacitor-storekit/src/provider.test.ts && node tools/run-ttsx.mjs --project native-plugins/capacitor-storekit/tsconfig.json native-plugins/capacitor-storekit/src/store-sdk.test.ts && node tools/run-ttsx.mjs --project native-plugins/capacitor-storekit/tsconfig.json native-plugins/capacitor-storekit/src/commerce-provider.test.ts && node tools/run-ttsx.mjs --project native-plugins/capacitor-storekit/tsconfig.json native-plugins/capacitor-storekit/src/commerce-provider.conformance.test.ts"
62
+ "test": "cd ../.. && node tools/run-ttsx.mjs --project native-plugins/capacitor-storekit/tsconfig.json native-plugins/capacitor-storekit/src/provider.test.ts && node tools/run-ttsx.mjs --project native-plugins/capacitor-storekit/tsconfig.json native-plugins/capacitor-storekit/src/store-sdk.test.ts && node tools/run-ttsx.mjs --project native-plugins/capacitor-storekit/tsconfig.json native-plugins/capacitor-storekit/src/commerce-provider.test.ts && node tools/run-ttsx.mjs --project native-plugins/capacitor-storekit/tsconfig.json native-plugins/capacitor-storekit/src/commerce-provider.conformance.test.ts && node tools/run-ttsx.mjs --project native-plugins/capacitor-storekit/tsconfig.json native-plugins/capacitor-storekit/src/commerce-reconciler-storekit-smoke.test.ts"
63
63
  }
64
64
  }