@makefully/adaptfully 5.0.2 → 5.0.4
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/lib/node/packagers/web.js +3 -1
- package/lib/runtime/analytics/_helpers.js +1 -0
- package/lib/runtime/auth/social-auth.js +153 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 5.0.4 — 2026-10-06
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **`social-auth`** logs richer Capgo/Android login diagnostics: structured error dumps when the bridge returns an empty-message `Error`, plus safe context (platform, provider, masked `webClientId`, plugin presence, result keys on identity-map failures).
|
|
10
|
+
|
|
11
|
+
## 5.0.3 — 2026-10-05
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **Web packager** writes `game-config.js` (and injects the script) for **web** and **pwa** as well as **uwp**, so `window.gameConfig.version` / platform are stamped on every web-family route — matching electron and capacitor. HTTP analytics can then populate batch `appVersion` without a per-game `analyticsAppVersion` override.
|
|
16
|
+
|
|
5
17
|
## 5.0.2 — 2026-10-05
|
|
6
18
|
|
|
7
19
|
### Fixed
|
package/README.md
CHANGED
|
@@ -178,7 +178,7 @@ Each platform entry may set a **`packager`** (`web`, `electron`, or `capacitor`)
|
|
|
178
178
|
|
|
179
179
|
| Packager | Prebuild adds |
|
|
180
180
|
|----------|---------------|
|
|
181
|
-
| `web` | `game-config.js` for
|
|
181
|
+
| `web` | `game-config.js` for **web / uwp / pwa** platform prebuilds (version + platform for analytics) |
|
|
182
182
|
| `electron` | `main.js` (Electron shell); `preload.js` when **`steam-auth`** is registered |
|
|
183
183
|
| `capacitor` | `game-config.js`, Capacitor CSP/viewport; `social-login-config.js` when **`social-auth`** is registered |
|
|
184
184
|
|
|
@@ -8,6 +8,8 @@ export class WebPackager extends Packager {
|
|
|
8
8
|
static defaultPlatforms = ['web', 'uwp', 'pwa'];
|
|
9
9
|
|
|
10
10
|
needsGameConfig() {
|
|
11
|
-
|
|
11
|
+
// Stamp version/platform for all web-family routes (web, uwp, pwa) so
|
|
12
|
+
// analytics resolveAppVersion() matches electron/capacitor builds.
|
|
13
|
+
return true;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* analyticsEnabled — when false, track is a no-op (default true when endpoint set)
|
|
10
10
|
* analyticsPlatform — optional override; else window.gameConfig.platform
|
|
11
11
|
* analyticsAppVersion — optional override; else window.gameConfig.version / config.appVersion
|
|
12
|
+
* (web/uwp/pwa/electron/capacitor prebuilds all write game-config.js)
|
|
12
13
|
*/
|
|
13
14
|
(function registerAnalyticsHelpers(ns) {
|
|
14
15
|
const OPT_OUT_KEY = 'adaptfully_analytics_opt_out';
|
|
@@ -27,6 +27,81 @@
|
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
function capacitorPlatform() {
|
|
31
|
+
try {
|
|
32
|
+
return window.Capacitor?.getPlatform?.() || 'unknown';
|
|
33
|
+
} catch {
|
|
34
|
+
return 'unknown';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Capgo / Android bridge often rejects with an empty-message Error. */
|
|
39
|
+
function formatAuthError(err) {
|
|
40
|
+
if (err == null) {
|
|
41
|
+
return { message: 'unknown error' };
|
|
42
|
+
}
|
|
43
|
+
if (typeof err === 'string') {
|
|
44
|
+
return { message: err };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const message = err.message
|
|
48
|
+
|| err.errorMessage
|
|
49
|
+
|| err.error_description
|
|
50
|
+
|| (typeof err.error === 'string' ? err.error : '')
|
|
51
|
+
|| '';
|
|
52
|
+
const out = {
|
|
53
|
+
message: message || '(empty message)',
|
|
54
|
+
name: err.name || undefined,
|
|
55
|
+
code: err.code ?? err.errorCode ?? err.statusCode ?? undefined,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
if (err.data != null) {
|
|
59
|
+
out.data = err.data;
|
|
60
|
+
}
|
|
61
|
+
if (err.error != null && typeof err.error === 'object') {
|
|
62
|
+
out.nested = formatAuthError(err.error);
|
|
63
|
+
}
|
|
64
|
+
if (err.stack) {
|
|
65
|
+
out.stack = String(err.stack).split('\n').slice(0, 6).join('\n');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Empty / generic "Error" from the Android bridge — dump own props.
|
|
69
|
+
if (!message || message === 'Error' || message === '[object Object]') {
|
|
70
|
+
try {
|
|
71
|
+
out.raw = JSON.stringify(err, Object.getOwnPropertyNames(Object(err)));
|
|
72
|
+
} catch {
|
|
73
|
+
out.raw = String(err);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function maskClientId(id) {
|
|
81
|
+
const value = String(id || '');
|
|
82
|
+
if (!value) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
if (value.length <= 12) {
|
|
86
|
+
return `${value.slice(0, 4)}…`;
|
|
87
|
+
}
|
|
88
|
+
return `${value.slice(0, 8)}…${value.slice(-6)}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function authContext(extra = {}) {
|
|
92
|
+
const config = readSocialLoginConfig();
|
|
93
|
+
return {
|
|
94
|
+
platform: capacitorPlatform(),
|
|
95
|
+
defaultProvider: config.defaultProvider || null,
|
|
96
|
+
providers: config.providers || null,
|
|
97
|
+
googleWebClientId: maskClientId(config.google?.webClientId),
|
|
98
|
+
appleClientIdConfigured: !!(config.apple?.clientId || window.gameConfig?.packageName),
|
|
99
|
+
hasCapacitor: !!window.Capacitor,
|
|
100
|
+
hasSocialLoginPlugin: !!resolveSocialLoginPlugin(),
|
|
101
|
+
...extra,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
30
105
|
function mapLoginResult(result) {
|
|
31
106
|
const resultResult = result?.result ?? result;
|
|
32
107
|
const profile = resultResult?.profile
|
|
@@ -173,7 +248,10 @@
|
|
|
173
248
|
const plugin = resolveSocialLoginPlugin();
|
|
174
249
|
if (!plugin) {
|
|
175
250
|
if (Date.now() - started >= timeoutMs) {
|
|
176
|
-
console.warn(
|
|
251
|
+
console.warn(
|
|
252
|
+
'[adaptfully social-auth] Capgo SocialLogin plugin not available',
|
|
253
|
+
authContext({ waitedMs: Date.now() - started }),
|
|
254
|
+
);
|
|
177
255
|
this.online = false;
|
|
178
256
|
done({ error: 'SocialLogin plugin not available' });
|
|
179
257
|
return;
|
|
@@ -185,12 +263,26 @@
|
|
|
185
263
|
this.#plugin = plugin;
|
|
186
264
|
this.#provider = this.#resolveDefaultProvider();
|
|
187
265
|
|
|
266
|
+
const initOptions = this.#buildInitializeOptions();
|
|
267
|
+
console.info('[adaptfully social-auth] initializing', authContext({
|
|
268
|
+
provider: this.#provider,
|
|
269
|
+
googleMode: initOptions.google?.mode || null,
|
|
270
|
+
googleWebClientIdPresent: !!initOptions.google?.webClientId,
|
|
271
|
+
}));
|
|
272
|
+
|
|
188
273
|
try {
|
|
189
|
-
await plugin.initialize(
|
|
274
|
+
await plugin.initialize(initOptions);
|
|
190
275
|
this.online = true;
|
|
276
|
+
console.info('[adaptfully social-auth] initialize ok', authContext({
|
|
277
|
+
provider: this.#provider,
|
|
278
|
+
}));
|
|
191
279
|
done();
|
|
192
280
|
} catch (err) {
|
|
193
|
-
console.error(
|
|
281
|
+
console.error(
|
|
282
|
+
'[adaptfully social-auth] initialize failed:',
|
|
283
|
+
formatAuthError(err),
|
|
284
|
+
authContext({ provider: this.#provider }),
|
|
285
|
+
);
|
|
194
286
|
this.online = false;
|
|
195
287
|
done({ error: err?.message || 'SocialLogin initialize failed' });
|
|
196
288
|
}
|
|
@@ -204,27 +296,58 @@
|
|
|
204
296
|
const provider = this.#provider ?? this.#resolveDefaultProvider();
|
|
205
297
|
|
|
206
298
|
if (!plugin) {
|
|
207
|
-
console.warn('[adaptfully social-auth] login: plugin missing'
|
|
299
|
+
console.warn('[adaptfully social-auth] login: plugin missing', authContext({
|
|
300
|
+
provider,
|
|
301
|
+
}));
|
|
208
302
|
this.#complete(callback);
|
|
209
303
|
return;
|
|
210
304
|
}
|
|
211
305
|
|
|
212
|
-
|
|
306
|
+
const options = {
|
|
307
|
+
scopes: provider === 'google'
|
|
308
|
+
? ['email', 'profile']
|
|
309
|
+
: ['email', 'name'],
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
console.info('[adaptfully social-auth] login starting', authContext({
|
|
213
313
|
provider,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
})
|
|
314
|
+
scopes: options.scopes,
|
|
315
|
+
alreadyAuthenticated: this.authenticated,
|
|
316
|
+
}));
|
|
317
|
+
|
|
318
|
+
plugin.login({ provider, options })
|
|
220
319
|
.then((result) => {
|
|
221
|
-
|
|
222
|
-
|
|
320
|
+
const identity = mapLoginResult(result);
|
|
321
|
+
if (!this.#applyIdentity(identity)) {
|
|
322
|
+
const keys = result && typeof result === 'object'
|
|
323
|
+
? Object.keys(result)
|
|
324
|
+
: [];
|
|
325
|
+
console.warn(
|
|
326
|
+
'[adaptfully social-auth] login: could not map identity',
|
|
327
|
+
authContext({
|
|
328
|
+
provider,
|
|
329
|
+
resultKeys: keys,
|
|
330
|
+
hasResultResult: !!(result && result.result),
|
|
331
|
+
profileKeys: result?.result?.profile
|
|
332
|
+
? Object.keys(result.result.profile)
|
|
333
|
+
: (result?.profile ? Object.keys(result.profile) : []),
|
|
334
|
+
}),
|
|
335
|
+
);
|
|
336
|
+
} else {
|
|
337
|
+
console.info('[adaptfully social-auth] login ok', authContext({
|
|
338
|
+
provider,
|
|
339
|
+
hasEmail: !!identity.email,
|
|
340
|
+
idLength: String(identity.id || '').length,
|
|
341
|
+
}));
|
|
223
342
|
}
|
|
224
343
|
this.#complete(callback);
|
|
225
344
|
})
|
|
226
345
|
.catch((err) => {
|
|
227
|
-
console.error(
|
|
346
|
+
console.error(
|
|
347
|
+
'[adaptfully social-auth] login failed:',
|
|
348
|
+
formatAuthError(err),
|
|
349
|
+
authContext({ provider }),
|
|
350
|
+
);
|
|
228
351
|
this.user = null;
|
|
229
352
|
this.authenticated = false;
|
|
230
353
|
this.online = false;
|
|
@@ -264,8 +387,12 @@
|
|
|
264
387
|
this.#applyIdentity(identity);
|
|
265
388
|
this.#complete(callback);
|
|
266
389
|
return;
|
|
267
|
-
} catch {
|
|
268
|
-
|
|
390
|
+
} catch (err) {
|
|
391
|
+
console.warn(
|
|
392
|
+
'[adaptfully social-auth] autoLogin getAuthorizationCode failed:',
|
|
393
|
+
formatAuthError(err),
|
|
394
|
+
authContext({ provider, hasLastId: !!lastId }),
|
|
395
|
+
);
|
|
269
396
|
}
|
|
270
397
|
}
|
|
271
398
|
|
|
@@ -275,7 +402,11 @@
|
|
|
275
402
|
this.#complete(callback);
|
|
276
403
|
})
|
|
277
404
|
.catch((err) => {
|
|
278
|
-
console.warn(
|
|
405
|
+
console.warn(
|
|
406
|
+
'[adaptfully social-auth] autoLogin failed:',
|
|
407
|
+
formatAuthError(err),
|
|
408
|
+
authContext({ provider }),
|
|
409
|
+
);
|
|
279
410
|
this.#complete(callback);
|
|
280
411
|
});
|
|
281
412
|
}
|
|
@@ -301,7 +432,11 @@
|
|
|
301
432
|
plugin.logout({ provider })
|
|
302
433
|
.then(clear)
|
|
303
434
|
.catch((err) => {
|
|
304
|
-
console.warn(
|
|
435
|
+
console.warn(
|
|
436
|
+
'[adaptfully social-auth] logout failed:',
|
|
437
|
+
formatAuthError(err),
|
|
438
|
+
authContext({ provider }),
|
|
439
|
+
);
|
|
305
440
|
clear();
|
|
306
441
|
});
|
|
307
442
|
}
|