@mpgd/game-services 0.26.0 → 0.27.1
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/client.d.ts +2 -11
- package/dist/client.js +2 -25
- package/dist/microsoft-store-purchase.d.ts +9 -5
- package/dist/microsoft-store-purchase.js +175 -43
- package/dist/notifications/ait-functional-delivery.d.ts +25 -8
- package/dist/notifications/ait-functional-delivery.js +38 -17
- package/dist/notifications/client.d.ts +168 -0
- package/dist/notifications/client.js +432 -0
- package/dist/notifications/fcm.d.ts +15 -1
- package/dist/notifications/fcm.js +107 -5
- package/dist/notifications/service.d.ts +4 -1
- package/dist/notifications/service.js +221 -37
- package/dist/notifications/store-conformance.js +19 -0
- package/dist/notifications/store.d.ts +5 -1
- package/dist/notifications/store.js +1 -1
- package/dist/request-headers.d.ts +16 -0
- package/dist/request-headers.js +30 -0
- package/dist/runtime.d.ts +7 -0
- package/dist/runtime.js +9 -0
- package/package.json +9 -5
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request headers for game-services calls: static headers, then a resolver
|
|
3
|
+
* for rotating credentials, then per-request headers. Shared by the commerce
|
|
4
|
+
* client and the notifications client so a game gives both one resolver.
|
|
5
|
+
*/
|
|
6
|
+
export type GameServicesHeaderResolver = () => Readonly<Record<string, string>> | Promise<Readonly<Record<string, string>>>;
|
|
7
|
+
/** Credentials could not be resolved; no backend request was dispatched. */
|
|
8
|
+
export declare class GameServicesHeaderResolutionError extends Error {
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
/** Resolve rotating credentials once and preserve static → dynamic → request precedence. */
|
|
12
|
+
export declare function resolveGameServicesRequestHeaders(input: {
|
|
13
|
+
readonly headers?: Readonly<Record<string, string>> | undefined;
|
|
14
|
+
readonly getHeaders?: GameServicesHeaderResolver | undefined;
|
|
15
|
+
readonly requestHeaders?: Readonly<Record<string, string>> | undefined;
|
|
16
|
+
}): Promise<Readonly<Record<string, string>>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request headers for game-services calls: static headers, then a resolver
|
|
3
|
+
* for rotating credentials, then per-request headers. Shared by the commerce
|
|
4
|
+
* client and the notifications client so a game gives both one resolver.
|
|
5
|
+
*/
|
|
6
|
+
/** Credentials could not be resolved; no backend request was dispatched. */
|
|
7
|
+
export class GameServicesHeaderResolutionError extends Error {
|
|
8
|
+
constructor() {
|
|
9
|
+
super('Game Services request headers could not be resolved before dispatch.');
|
|
10
|
+
this.name = 'GameServicesHeaderResolutionError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Resolve rotating credentials once and preserve static → dynamic → request precedence. */
|
|
14
|
+
export async function resolveGameServicesRequestHeaders(input) {
|
|
15
|
+
let dynamicHeaders;
|
|
16
|
+
try {
|
|
17
|
+
dynamicHeaders = await input.getHeaders?.();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Resolver exceptions can contain credentials; expose a stable outcome.
|
|
21
|
+
throw new GameServicesHeaderResolutionError();
|
|
22
|
+
}
|
|
23
|
+
const merged = new Map();
|
|
24
|
+
for (const layer of [input.headers, dynamicHeaders, input.requestHeaders]) {
|
|
25
|
+
for (const [name, value] of Object.entries(layer ?? {})) {
|
|
26
|
+
merged.set(name.toLowerCase(), value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return Object.fromEntries(merged);
|
|
30
|
+
}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -54,4 +54,11 @@ export declare function createGameServicesRuntime(input: CreateGameServicesRunti
|
|
|
54
54
|
export declare function resolveGameServicesLedgerTarget(target: PlatformTarget | string): GameServicesLedgerTarget | null;
|
|
55
55
|
export declare function resolveGameServicesAuthorityMode(profile: string): GameServicesAuthorityMode;
|
|
56
56
|
export declare function resolveGameServicesTransport(transport: string | undefined): 'http' | 'orpc';
|
|
57
|
+
/**
|
|
58
|
+
* Whether a game-services URL may carry a session's credentials in a
|
|
59
|
+
* production build: an absolute https URL with no credentials and a public
|
|
60
|
+
* host, the rule the authoritative commerce backend follows. The
|
|
61
|
+
* notifications client's starter wiring uses it too.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isPublicGameServicesUrl(baseUrl: string): boolean;
|
|
57
64
|
export {};
|
package/dist/runtime.js
CHANGED
|
@@ -149,6 +149,15 @@ function normalizeBaseUrl(baseUrl) {
|
|
|
149
149
|
const normalized = baseUrl?.trim();
|
|
150
150
|
return normalized === undefined || normalized.length === 0 ? undefined : normalized;
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Whether a game-services URL may carry a session's credentials in a
|
|
154
|
+
* production build: an absolute https URL with no credentials and a public
|
|
155
|
+
* host, the rule the authoritative commerce backend follows. The
|
|
156
|
+
* notifications client's starter wiring uses it too.
|
|
157
|
+
*/
|
|
158
|
+
export function isPublicGameServicesUrl(baseUrl) {
|
|
159
|
+
return isPublicHttpsUrl(parseAbsoluteUrl(baseUrl.trim()));
|
|
160
|
+
}
|
|
152
161
|
function isPublicHttpsUrl(url) {
|
|
153
162
|
return url !== undefined
|
|
154
163
|
&& url.protocol === 'https:'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpgd/game-services",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "Client, contract, server, store, and test helpers for authoritative mpgd game services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -133,6 +133,10 @@
|
|
|
133
133
|
"types": "./dist/notifications/index.d.ts",
|
|
134
134
|
"default": "./dist/notifications/index.js"
|
|
135
135
|
},
|
|
136
|
+
"./notifications/client": {
|
|
137
|
+
"types": "./dist/notifications/client.d.ts",
|
|
138
|
+
"default": "./dist/notifications/client.js"
|
|
139
|
+
},
|
|
136
140
|
"./notifications/store-conformance": {
|
|
137
141
|
"types": "./dist/notifications/store-conformance.d.ts",
|
|
138
142
|
"default": "./dist/notifications/store-conformance.js"
|
|
@@ -215,9 +219,9 @@
|
|
|
215
219
|
"@orpc/client": "2.0.0-beta.14",
|
|
216
220
|
"@orpc/contract": "2.0.0-beta.14",
|
|
217
221
|
"@orpc/server": "2.0.0-beta.14",
|
|
218
|
-
"@mpgd/analytics": "0.4.
|
|
219
|
-
"@mpgd/
|
|
220
|
-
"@mpgd/
|
|
222
|
+
"@mpgd/analytics": "0.4.15",
|
|
223
|
+
"@mpgd/platform": "0.27.1",
|
|
224
|
+
"@mpgd/catalog": "0.10.6"
|
|
221
225
|
},
|
|
222
226
|
"peerDependencies": {
|
|
223
227
|
"@apple/app-store-server-library": "^3.1.0"
|
|
@@ -246,7 +250,7 @@
|
|
|
246
250
|
"fix": "ttsc fix",
|
|
247
251
|
"build": "cd ../.. && node tools/run-ttsx.mjs tools/package/build-packages.ts @mpgd/game-services",
|
|
248
252
|
"test:packed-transport": "pnpm build && node test/runtime-transport-package-import.mjs && node test/reward-evidence-import.mjs",
|
|
249
|
-
"test:unit": "cd ../.. && node tools/run-ttsx.mjs packages/game-services/src/client.test.ts && node tools/run-ttsx.mjs packages/game-services/src/client-progress.test.ts && node tools/run-ttsx.mjs packages/game-services/src/runtime.test.ts && node tools/run-ttsx.mjs packages/game-services/src/types.test.ts && node tools/run-ttsx.mjs packages/game-services/src/server.test.ts && node tools/run-ttsx.mjs packages/game-services/src/google-play-purchase.test.ts && node tools/run-ttsx.mjs packages/game-services/src/google-play-publisher-client.test.ts && node tools/run-ttsx.mjs packages/game-services/src/microsoft-store-purchase.test.ts && node tools/run-ttsx.mjs packages/game-services/src/microsoft-store-identity.test.ts && node tools/run-ttsx.mjs packages/game-services/src/platform-order.test.ts && node tools/run-ttsx.mjs packages/game-services/src/progress-link.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notification-delivery.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/service.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/service-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/scheduler.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/fcm.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/store-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/ait-functional-delivery.test.ts && node tools/run-ttsx.mjs packages/game-services/src/admob-ssv.test.ts && node tools/run-ttsx.mjs packages/game-services/src/app-store-verifier.test.ts && node tools/run-ttsx.mjs packages/game-services/src/apps-in-toss-evidence-verification-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/apps-in-toss-partner-api.test.ts && node tools/run-ttsx.mjs packages/game-services/src/verified-leaderboard.test.ts && node tools/run-ttsx.mjs packages/game-services/src/verified-leaderboard-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/verified-leaderboard-durability-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/verified-leaderboard-transport.test.ts && node tools/run-ttsx.mjs packages/game-services/src/guest-session.test.ts && node tools/run-ttsx.mjs packages/game-services/src/client-reward-evidence.test.ts && node tools/run-ttsx.mjs packages/game-services/src/ad-reward-verifier-registry.test.ts && node tools/run-ttsx.mjs packages/game-services/src/oneplay-reward.test.ts && node tools/run-ttsx.mjs packages/game-services/src/oneplay-purchase.test.ts && node tools/run-ttsx.mjs packages/game-services/src/commerce-registry-routing.test.ts && node tools/run-ttsx.mjs packages/game-services/src/commerce-registry-server.test.ts && node tools/run-ttsx.mjs packages/game-services/src/commerce-ledger-revocation.test.ts && node tools/run-ttsx.mjs packages/game-services/src/apps-in-toss-anonymous-auth.test.ts",
|
|
253
|
+
"test:unit": "cd ../.. && node tools/run-ttsx.mjs packages/game-services/src/client.test.ts && node tools/run-ttsx.mjs packages/game-services/src/client-progress.test.ts && node tools/run-ttsx.mjs packages/game-services/src/runtime.test.ts && node tools/run-ttsx.mjs packages/game-services/src/types.test.ts && node tools/run-ttsx.mjs packages/game-services/src/server.test.ts && node tools/run-ttsx.mjs packages/game-services/src/google-play-purchase.test.ts && node tools/run-ttsx.mjs packages/game-services/src/google-play-publisher-client.test.ts && node tools/run-ttsx.mjs packages/game-services/src/microsoft-store-purchase.test.ts && node tools/run-ttsx.mjs packages/game-services/src/microsoft-store-identity.test.ts && node tools/run-ttsx.mjs packages/game-services/src/platform-order.test.ts && node tools/run-ttsx.mjs packages/game-services/src/progress-link.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notification-delivery.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/service.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/service-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/client.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/client-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/scheduler.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/fcm.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/store-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/notifications/ait-functional-delivery.test.ts && node tools/run-ttsx.mjs packages/game-services/src/admob-ssv.test.ts && node tools/run-ttsx.mjs packages/game-services/src/app-store-verifier.test.ts && node tools/run-ttsx.mjs packages/game-services/src/apps-in-toss-evidence-verification-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/apps-in-toss-partner-api.test.ts && node tools/run-ttsx.mjs packages/game-services/src/verified-leaderboard.test.ts && node tools/run-ttsx.mjs packages/game-services/src/verified-leaderboard-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/verified-leaderboard-durability-conformance.test.ts && node tools/run-ttsx.mjs packages/game-services/src/verified-leaderboard-transport.test.ts && node tools/run-ttsx.mjs packages/game-services/src/guest-session.test.ts && node tools/run-ttsx.mjs packages/game-services/src/client-reward-evidence.test.ts && node tools/run-ttsx.mjs packages/game-services/src/ad-reward-verifier-registry.test.ts && node tools/run-ttsx.mjs packages/game-services/src/oneplay-reward.test.ts && node tools/run-ttsx.mjs packages/game-services/src/oneplay-purchase.test.ts && node tools/run-ttsx.mjs packages/game-services/src/commerce-registry-routing.test.ts && node tools/run-ttsx.mjs packages/game-services/src/commerce-registry-server.test.ts && node tools/run-ttsx.mjs packages/game-services/src/commerce-ledger-revocation.test.ts && node tools/run-ttsx.mjs packages/game-services/src/apps-in-toss-anonymous-auth.test.ts",
|
|
250
254
|
"test:recovery": "cd ../.. && node tools/run-ttsx.mjs packages/game-services/src/monetization-recovery.test.ts && node tools/run-ttsx.mjs packages/game-services/src/app-store-recovery.test.ts && node tools/run-ttsx.mjs packages/game-services/src/commerce-reconciler.test.ts && node tools/run-ttsx.mjs packages/game-services/src/commerce-reconciler-conformance.test.ts",
|
|
251
255
|
"test": "pnpm test:unit && pnpm test:app-store-server && pnpm test:recovery && pnpm test:packed-transport",
|
|
252
256
|
"test:app-store-server": "vitest run"
|