@makefully/adaptfully 5.0.3 → 5.0.5
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/lib/runtime/auth/social-auth.js +159 -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.5 — 2026-10-06
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **`social-auth`** Google login on Capacitor now passes `filterByAuthorizedAccounts: false` (Capgo/Family Link guidance) so Credential Manager does not stick to a stale authorized-account filter that surfaces `[16] Account reauth failed`.
|
|
10
|
+
|
|
11
|
+
## 5.0.4 — 2026-10-06
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **`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).
|
|
16
|
+
|
|
5
17
|
## 5.0.3 — 2026-10-05
|
|
6
18
|
|
|
7
19
|
### Changed
|
|
@@ -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,64 @@
|
|
|
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
|
+
// Android Capgo defaults / Family Link: never filter to "authorized"
|
|
307
|
+
// accounts only — that path commonly surfaces [16] Account reauth failed.
|
|
308
|
+
const options = provider === 'google'
|
|
309
|
+
? {
|
|
310
|
+
scopes: ['email', 'profile'],
|
|
311
|
+
filterByAuthorizedAccounts: false,
|
|
312
|
+
}
|
|
313
|
+
: {
|
|
314
|
+
scopes: ['email', 'name'],
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
console.info('[adaptfully social-auth] login starting', authContext({
|
|
213
318
|
provider,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
})
|
|
319
|
+
scopes: options.scopes,
|
|
320
|
+
filterByAuthorizedAccounts: options.filterByAuthorizedAccounts ?? null,
|
|
321
|
+
alreadyAuthenticated: this.authenticated,
|
|
322
|
+
}));
|
|
323
|
+
|
|
324
|
+
plugin.login({ provider, options })
|
|
220
325
|
.then((result) => {
|
|
221
|
-
|
|
222
|
-
|
|
326
|
+
const identity = mapLoginResult(result);
|
|
327
|
+
if (!this.#applyIdentity(identity)) {
|
|
328
|
+
const keys = result && typeof result === 'object'
|
|
329
|
+
? Object.keys(result)
|
|
330
|
+
: [];
|
|
331
|
+
console.warn(
|
|
332
|
+
'[adaptfully social-auth] login: could not map identity',
|
|
333
|
+
authContext({
|
|
334
|
+
provider,
|
|
335
|
+
resultKeys: keys,
|
|
336
|
+
hasResultResult: !!(result && result.result),
|
|
337
|
+
profileKeys: result?.result?.profile
|
|
338
|
+
? Object.keys(result.result.profile)
|
|
339
|
+
: (result?.profile ? Object.keys(result.profile) : []),
|
|
340
|
+
}),
|
|
341
|
+
);
|
|
342
|
+
} else {
|
|
343
|
+
console.info('[adaptfully social-auth] login ok', authContext({
|
|
344
|
+
provider,
|
|
345
|
+
hasEmail: !!identity.email,
|
|
346
|
+
idLength: String(identity.id || '').length,
|
|
347
|
+
}));
|
|
223
348
|
}
|
|
224
349
|
this.#complete(callback);
|
|
225
350
|
})
|
|
226
351
|
.catch((err) => {
|
|
227
|
-
console.error(
|
|
352
|
+
console.error(
|
|
353
|
+
'[adaptfully social-auth] login failed:',
|
|
354
|
+
formatAuthError(err),
|
|
355
|
+
authContext({ provider }),
|
|
356
|
+
);
|
|
228
357
|
this.user = null;
|
|
229
358
|
this.authenticated = false;
|
|
230
359
|
this.online = false;
|
|
@@ -264,8 +393,12 @@
|
|
|
264
393
|
this.#applyIdentity(identity);
|
|
265
394
|
this.#complete(callback);
|
|
266
395
|
return;
|
|
267
|
-
} catch {
|
|
268
|
-
|
|
396
|
+
} catch (err) {
|
|
397
|
+
console.warn(
|
|
398
|
+
'[adaptfully social-auth] autoLogin getAuthorizationCode failed:',
|
|
399
|
+
formatAuthError(err),
|
|
400
|
+
authContext({ provider, hasLastId: !!lastId }),
|
|
401
|
+
);
|
|
269
402
|
}
|
|
270
403
|
}
|
|
271
404
|
|
|
@@ -275,7 +408,11 @@
|
|
|
275
408
|
this.#complete(callback);
|
|
276
409
|
})
|
|
277
410
|
.catch((err) => {
|
|
278
|
-
console.warn(
|
|
411
|
+
console.warn(
|
|
412
|
+
'[adaptfully social-auth] autoLogin failed:',
|
|
413
|
+
formatAuthError(err),
|
|
414
|
+
authContext({ provider }),
|
|
415
|
+
);
|
|
279
416
|
this.#complete(callback);
|
|
280
417
|
});
|
|
281
418
|
}
|
|
@@ -301,7 +438,11 @@
|
|
|
301
438
|
plugin.logout({ provider })
|
|
302
439
|
.then(clear)
|
|
303
440
|
.catch((err) => {
|
|
304
|
-
console.warn(
|
|
441
|
+
console.warn(
|
|
442
|
+
'[adaptfully social-auth] logout failed:',
|
|
443
|
+
formatAuthError(err),
|
|
444
|
+
authContext({ provider }),
|
|
445
|
+
);
|
|
305
446
|
clear();
|
|
306
447
|
});
|
|
307
448
|
}
|