@mpgd/game-services 0.28.1 → 0.30.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/README.md +18 -3
- package/dist/account-deletion.d.ts +306 -0
- package/dist/account-deletion.js +491 -0
- package/dist/app-store-recovery.d.ts +6 -0
- package/dist/app-store-recovery.js +26 -16
- package/dist/app-store-server-notifications.d.ts +158 -0
- package/dist/app-store-server-notifications.js +270 -0
- package/dist/app-store-server.d.ts +8 -0
- package/dist/app-store-server.js +135 -37
- package/dist/app-store-verifier.d.ts +34 -0
- package/dist/app-store-verifier.js +161 -31
- package/dist/commerce-ledger.d.ts +55 -0
- package/dist/commerce-ledger.js +198 -0
- package/dist/commerce-reconciler.js +47 -7
- package/dist/evidence-verification.d.ts +19 -0
- package/dist/google-play-publisher-client.d.ts +2 -1
- package/dist/google-play-publisher-client.js +80 -0
- package/dist/google-play-purchase.d.ts +7 -0
- package/dist/google-play-purchase.js +32 -7
- package/dist/google-play-store-server.d.ts +160 -0
- package/dist/google-play-store-server.js +297 -0
- package/dist/guest-session.d.ts +112 -2
- package/dist/guest-session.js +196 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/notifications/delivery-provider.d.ts +7 -0
- package/dist/notifications/fcm.d.ts +30 -3
- package/dist/notifications/fcm.js +72 -13
- package/dist/notifications/service.js +33 -5
- package/dist/notifications/store-conformance.js +7 -1
- package/dist/notifications/store.d.ts +9 -0
- package/dist/notifications/store.js +41 -0
- package/dist/operation-results.d.ts +7 -0
- package/dist/purchase-sharing.d.ts +41 -0
- package/dist/purchase-sharing.js +37 -0
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.js +13 -0
- package/dist/server.d.ts +60 -1
- package/dist/server.js +536 -42
- package/dist/types.d.ts +30 -0
- package/dist/types.js +22 -0
- package/dist/verified-leaderboard.d.ts +13 -0
- package/dist/verified-leaderboard.js +31 -0
- package/package.json +17 -5
package/dist/server.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { type AnalyticsSink } from '@mpgd/analytics';
|
|
|
2
2
|
import { type AdPlacements, type ProductCatalog } from '@mpgd/catalog';
|
|
3
3
|
import { type GameServicesBackendApi, type GameServicesBackendTransport, type GameServicesBackendTransportRequest, type GameServicesBackendTransportResponse } from './client.js';
|
|
4
4
|
import { type CommerceEvidenceRegistry } from './commerce-evidence-registry.js';
|
|
5
|
+
import { type PlayerDataErasureInput, type PlayerDataErasureResult } from './account-deletion.js';
|
|
5
6
|
import { type GameServicesHealthResponse } from './contract.js';
|
|
6
7
|
import { type GameServicesEvidenceVerifier, type GameServicesPurchaseGrantFinalizer } from './evidence-verification.js';
|
|
7
|
-
import { type ClaimAdRewardRequest, type ClaimAdRewardResponse, type EntitlementLedgerGrant, type EntitlementLedgerResult, type EntitlementLedgerRevocation, type EntitlementRevocationTransaction, type GameServicesAdRewardTarget, type GameServicesStoreTarget, type LeaderboardScoreTransaction, type ProductGrantTransaction, type PurchaseLedgerStatusRequest, type RecordLeaderboardScoreRequest, type RecordLeaderboardScoreResponse, type VerifyPurchaseRequest, type VerifyPurchaseResponse } from './types.js';
|
|
8
|
+
import { type ClaimAdRewardRequest, type ClaimAdRewardResponse, type EntitlementLedgerGrant, type EntitlementLedgerNote, type EntitlementLedgerResult, type EntitlementLedgerRevocation, type EntitlementRevocationTransaction, type GameServicesAdRewardTarget, type GameServicesStoreTarget, type LeaderboardScoreTransaction, type ProductGrantTransaction, type PurchaseLedgerStatusRequest, type RecordLeaderboardScoreRequest, type RecordLeaderboardScoreResponse, type VerifyPurchaseRequest, type VerifyPurchaseResponse } from './types.js';
|
|
9
|
+
import { type PurchaseRestoreSharingPolicy } from './purchase-sharing.js';
|
|
8
10
|
export { gameServicesRequestLimits, GameServicesRequestValidationError } from './validation.js';
|
|
9
11
|
export { listActiveEntitlementTransactions, readPurchaseLedgerStatuses, revokeEntitlementGrant, RevocationKeyConflictError, type RevokeEntitlementGrantResult, } from './commerce-ledger.js';
|
|
10
12
|
type CorsHeaders = Record<string, string>;
|
|
@@ -33,6 +35,15 @@ export interface CreateGameServicesBackendInput {
|
|
|
33
35
|
*/
|
|
34
36
|
readonly commerceEvidenceRegistry?: CommerceEvidenceRegistry;
|
|
35
37
|
/**
|
|
38
|
+
* How a restored non-consumable that the store binds to another player is
|
|
39
|
+
* answered (RFC "Restore sharing"). `{ mode: 'share' }` grants the
|
|
40
|
+
* restoring player its own entitlement while earlier holders keep theirs,
|
|
41
|
+
* up to `maxHolders` (5) players per purchase. Defaults to
|
|
42
|
+
* `{ mode: 'refuse' }`, which keeps answering the binding mismatch; the
|
|
43
|
+
* reference Worker shares by default (`GAME_SERVICES_RESTORE_SHARING`).
|
|
44
|
+
*/
|
|
45
|
+
readonly restoreSharing?: PurchaseRestoreSharingPolicy;
|
|
46
|
+
/**
|
|
36
47
|
* Receives unexpected (non-validation) failures such as store errors before the
|
|
37
48
|
* transport answers with the generic `INTERNAL_ERROR` code. Defaults to `console.error`.
|
|
38
49
|
* The hook is diagnostics only: if it throws or returns a rejecting promise, the failure
|
|
@@ -87,11 +98,42 @@ export interface GameServicesStore {
|
|
|
87
98
|
findEntitlementRevocations?(input: {
|
|
88
99
|
readonly ledgerEntryIds: readonly string[];
|
|
89
100
|
}): Promise<readonly EntitlementRevocationTransaction[]>;
|
|
101
|
+
/**
|
|
102
|
+
* The grants of `source` whose `evidenceVerificationId` starts with
|
|
103
|
+
* `prefix` (at most `limit`), any order: restore sharing lists a purchase's
|
|
104
|
+
* shared grants with it in one indexed read (RFC "Restore sharing").
|
|
105
|
+
* Optional: without it the shares are read slot by slot.
|
|
106
|
+
*/
|
|
107
|
+
findEntitlementTransactionsByEvidencePrefix?(input: {
|
|
108
|
+
readonly source: EntitlementLedgerGrant['source'];
|
|
109
|
+
readonly prefix: string;
|
|
110
|
+
readonly limit: number;
|
|
111
|
+
}): Promise<readonly ProductGrantTransaction[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Keeps a ledger note (a store event that grants nothing), once per
|
|
114
|
+
* `noteId`: a replay answers `alreadyRecorded: true` and keeps the first.
|
|
115
|
+
* Optional: a store without it still answers the event, with a log only.
|
|
116
|
+
*/
|
|
117
|
+
recordEntitlementNote?(input: EntitlementLedgerNote): Promise<{
|
|
118
|
+
readonly alreadyRecorded: boolean;
|
|
119
|
+
}>;
|
|
120
|
+
/** The notes about the given grants, oldest first. */
|
|
121
|
+
findEntitlementNotes?(input: {
|
|
122
|
+
readonly ledgerEntryIds: readonly string[];
|
|
123
|
+
}): Promise<readonly EntitlementLedgerNote[]>;
|
|
90
124
|
recordLeaderboardScore(input: RecordLeaderboardScoreRequest, options?: {
|
|
91
125
|
readonly recordedAt?: string;
|
|
92
126
|
}): Promise<RecordLeaderboardScoreResponse>;
|
|
93
127
|
getLeaderboardTransaction(ledgerEntryId: string): Promise<LeaderboardScoreTransaction | undefined>;
|
|
94
128
|
listLeaderboardTransactions(): Promise<readonly LeaderboardScoreTransaction[]>;
|
|
129
|
+
/**
|
|
130
|
+
* Account deletion (`./account-deletion`): deletes the player's grants,
|
|
131
|
+
* revocations, notes, and scores, except purchase grants and what reverses
|
|
132
|
+
* or annotates them, which are kept detached from the player (new ids,
|
|
133
|
+
* `retainedPlayerId`, no `playerId` payload key). Idempotent. Optional: the
|
|
134
|
+
* Worker's D1 deployment erases its tables in one batch instead.
|
|
135
|
+
*/
|
|
136
|
+
erasePlayerData?(input: PlayerDataErasureInput): Promise<PlayerDataErasureResult>;
|
|
95
137
|
}
|
|
96
138
|
export interface EntitlementPlatformEvidenceIdentity {
|
|
97
139
|
readonly source: Extract<EntitlementLedgerGrant['source'], 'purchase' | 'ad_reward'>;
|
|
@@ -122,6 +164,7 @@ export declare class InMemoryGameServicesStore implements GameServicesStore {
|
|
|
122
164
|
private readonly revocationsByKey;
|
|
123
165
|
private readonly revocationsByGrant;
|
|
124
166
|
private readonly revocationsByEvidence;
|
|
167
|
+
private readonly notesById;
|
|
125
168
|
private readonly leaderboardTransactionsByRun;
|
|
126
169
|
private readonly leaderboardTransactionsById;
|
|
127
170
|
recordEntitlementGrant(input: EntitlementLedgerGrant): Promise<EntitlementLedgerResult>;
|
|
@@ -134,6 +177,11 @@ export declare class InMemoryGameServicesStore implements GameServicesStore {
|
|
|
134
177
|
readonly source: EntitlementLedgerGrant['source'];
|
|
135
178
|
readonly evidenceVerificationId: string;
|
|
136
179
|
}): Promise<ProductGrantTransaction | undefined>;
|
|
180
|
+
findEntitlementTransactionsByEvidencePrefix(input: {
|
|
181
|
+
readonly source: EntitlementLedgerGrant['source'];
|
|
182
|
+
readonly prefix: string;
|
|
183
|
+
readonly limit: number;
|
|
184
|
+
}): Promise<readonly ProductGrantTransaction[]>;
|
|
137
185
|
findEntitlementTransactionByPlatformEvidence(input: EntitlementPlatformEvidenceIdentity): Promise<ProductGrantTransaction | undefined>;
|
|
138
186
|
getEntitlementTransaction(ledgerEntryId: string): Promise<ProductGrantTransaction | undefined>;
|
|
139
187
|
listEntitlementTransactions(): Promise<readonly ProductGrantTransaction[]>;
|
|
@@ -142,11 +190,22 @@ export declare class InMemoryGameServicesStore implements GameServicesStore {
|
|
|
142
190
|
findEntitlementRevocations(input: {
|
|
143
191
|
readonly ledgerEntryIds: readonly string[];
|
|
144
192
|
}): Promise<readonly EntitlementRevocationTransaction[]>;
|
|
193
|
+
recordEntitlementNote(input: EntitlementLedgerNote): Promise<{
|
|
194
|
+
readonly alreadyRecorded: boolean;
|
|
195
|
+
}>;
|
|
196
|
+
findEntitlementNotes(input: {
|
|
197
|
+
readonly ledgerEntryIds: readonly string[];
|
|
198
|
+
}): Promise<readonly EntitlementLedgerNote[]>;
|
|
145
199
|
recordLeaderboardScore(input: RecordLeaderboardScoreRequest, options?: {
|
|
146
200
|
readonly recordedAt?: string;
|
|
147
201
|
}): Promise<RecordLeaderboardScoreResponse>;
|
|
148
202
|
getLeaderboardTransaction(ledgerEntryId: string): Promise<LeaderboardScoreTransaction | undefined>;
|
|
149
203
|
listLeaderboardTransactions(): Promise<readonly LeaderboardScoreTransaction[]>;
|
|
204
|
+
erasePlayerData(input: PlayerDataErasureInput): Promise<PlayerDataErasureResult>;
|
|
205
|
+
private rememberEntitlementRevocation;
|
|
206
|
+
private forgetEntitlementRevocation;
|
|
207
|
+
private forgetEntitlementTransaction;
|
|
208
|
+
private rememberEntitlementTransaction;
|
|
150
209
|
private rankFor;
|
|
151
210
|
private sortedLeaderboardTransactions;
|
|
152
211
|
}
|