@testerpaykit/expo 2.1.0 → 2.1.2
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 +19 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +81 -12
- package/dist/index.mjs +81 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@testerpaykit/expo` are documented here.
|
|
4
4
|
|
|
5
|
+
## 2.1.2 — 2026-11-09
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **A report could get lost, or wait for the next launch, after the session start
|
|
9
|
+
failed once.** Offline or a server error at launch left the SDK without a
|
|
10
|
+
session, and nothing tried again. Online the server then refused the report for
|
|
11
|
+
its empty session id, and the report was gone; a queued one stayed queued until
|
|
12
|
+
the next launch. A report now opens the session itself and stays queued while
|
|
13
|
+
none can start. Confirming a number starts the session and sends what waited.
|
|
14
|
+
|
|
15
|
+
## 2.1.1 — 2026-11-09
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- With `syncSessions: false` a launch sends nothing at all until the first
|
|
19
|
+
report: no sign-in and no profile check. Signing in marked the tester as
|
|
20
|
+
active on every start, so "no tracking" was not quite true. A person approved
|
|
21
|
+
on an earlier launch still signs in at launch and sees the widget; confirming
|
|
22
|
+
a number signs in when it starts.
|
|
23
|
+
|
|
5
24
|
## 2.1.0 — 2026-11-09
|
|
6
25
|
|
|
7
26
|
### Added
|
package/dist/index.d.mts
CHANGED
|
@@ -766,6 +766,9 @@ declare class TpkExpo {
|
|
|
766
766
|
private readonly submittedCrashes;
|
|
767
767
|
private crashFlush;
|
|
768
768
|
private accessValue;
|
|
769
|
+
/** `syncSessions: false`: nothing reaches the server until a report does. */
|
|
770
|
+
private quietUntilReport;
|
|
771
|
+
private signingIn;
|
|
769
772
|
private handleValue;
|
|
770
773
|
/** Bumped by a tester-gate 403: a check that started before it must
|
|
771
774
|
* not bring a stale "ready" back. */
|
|
@@ -845,6 +848,26 @@ declare class TpkExpo {
|
|
|
845
848
|
revalidate?: boolean;
|
|
846
849
|
}): Promise<'verified' | 'required' | 'awaitingApproval' | 'unknown'>;
|
|
847
850
|
private loginRecovery;
|
|
851
|
+
/** The attempt at launch is over. Until then a report must not start a second one. */
|
|
852
|
+
private launchSessionSettled;
|
|
853
|
+
private sessionStart;
|
|
854
|
+
/**
|
|
855
|
+
* A report needs a session, and the one attempt at launch can fail (offline,
|
|
856
|
+
* a server error). Concurrent callers share one start; a failure leaves the
|
|
857
|
+
* id empty and the next report or flush tries again. Never rejects.
|
|
858
|
+
*/
|
|
859
|
+
private ensureSession;
|
|
860
|
+
/**
|
|
861
|
+
* The payload with a session id. The server refuses an empty one for good,
|
|
862
|
+
* so this rejects while no session can start and the report stays queued.
|
|
863
|
+
*/
|
|
864
|
+
private withSession;
|
|
865
|
+
/**
|
|
866
|
+
* Signs in for the first report when `syncSessions: false` left that open,
|
|
867
|
+
* or just ends the quiet with a stored login. Concurrent callers share one
|
|
868
|
+
* sign-in; a failure is retried by the next one.
|
|
869
|
+
*/
|
|
870
|
+
private signInForReport;
|
|
848
871
|
/**
|
|
849
872
|
* Drop a login the server no longer accepts, with its session and phone
|
|
850
873
|
* state, and log in anonymously again, like a first start. Concurrent
|
package/dist/index.d.ts
CHANGED
|
@@ -766,6 +766,9 @@ declare class TpkExpo {
|
|
|
766
766
|
private readonly submittedCrashes;
|
|
767
767
|
private crashFlush;
|
|
768
768
|
private accessValue;
|
|
769
|
+
/** `syncSessions: false`: nothing reaches the server until a report does. */
|
|
770
|
+
private quietUntilReport;
|
|
771
|
+
private signingIn;
|
|
769
772
|
private handleValue;
|
|
770
773
|
/** Bumped by a tester-gate 403: a check that started before it must
|
|
771
774
|
* not bring a stale "ready" back. */
|
|
@@ -845,6 +848,26 @@ declare class TpkExpo {
|
|
|
845
848
|
revalidate?: boolean;
|
|
846
849
|
}): Promise<'verified' | 'required' | 'awaitingApproval' | 'unknown'>;
|
|
847
850
|
private loginRecovery;
|
|
851
|
+
/** The attempt at launch is over. Until then a report must not start a second one. */
|
|
852
|
+
private launchSessionSettled;
|
|
853
|
+
private sessionStart;
|
|
854
|
+
/**
|
|
855
|
+
* A report needs a session, and the one attempt at launch can fail (offline,
|
|
856
|
+
* a server error). Concurrent callers share one start; a failure leaves the
|
|
857
|
+
* id empty and the next report or flush tries again. Never rejects.
|
|
858
|
+
*/
|
|
859
|
+
private ensureSession;
|
|
860
|
+
/**
|
|
861
|
+
* The payload with a session id. The server refuses an empty one for good,
|
|
862
|
+
* so this rejects while no session can start and the report stays queued.
|
|
863
|
+
*/
|
|
864
|
+
private withSession;
|
|
865
|
+
/**
|
|
866
|
+
* Signs in for the first report when `syncSessions: false` left that open,
|
|
867
|
+
* or just ends the quiet with a stored login. Concurrent callers share one
|
|
868
|
+
* sign-in; a failure is retried by the next one.
|
|
869
|
+
*/
|
|
870
|
+
private signInForReport;
|
|
848
871
|
/**
|
|
849
872
|
* Drop a login the server no longer accepts, with its session and phone
|
|
850
873
|
* state, and log in anonymously again, like a first start. Concurrent
|
package/dist/index.js
CHANGED
|
@@ -1335,7 +1335,7 @@ function findAssignmentForTask(tasks, key) {
|
|
|
1335
1335
|
}
|
|
1336
1336
|
|
|
1337
1337
|
// package.json
|
|
1338
|
-
var version = "2.1.
|
|
1338
|
+
var version = "2.1.2";
|
|
1339
1339
|
|
|
1340
1340
|
// src/version.ts
|
|
1341
1341
|
var SDK_VERSION = `@testerpaykit/expo/${version}`;
|
|
@@ -1540,6 +1540,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
1540
1540
|
this.crashFlush = Promise.resolve();
|
|
1541
1541
|
// ── Access (who sees the widget) ──
|
|
1542
1542
|
this.accessValue = "hidden";
|
|
1543
|
+
/** `syncSessions: false`: nothing reaches the server until a report does. */
|
|
1544
|
+
this.quietUntilReport = false;
|
|
1545
|
+
this.signingIn = null;
|
|
1543
1546
|
this.handleValue = null;
|
|
1544
1547
|
/** Bumped by a tester-gate 403: a check that started before it must
|
|
1545
1548
|
* not bring a stale "ready" back. */
|
|
@@ -1549,6 +1552,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
1549
1552
|
/** Active server session id. Updated by init or rotate. Used to route telemetry. */
|
|
1550
1553
|
this.sessionId = "";
|
|
1551
1554
|
this.loginRecovery = null;
|
|
1555
|
+
/** The attempt at launch is over. Until then a report must not start a second one. */
|
|
1556
|
+
this.launchSessionSettled = false;
|
|
1557
|
+
this.sessionStart = null;
|
|
1552
1558
|
this._ready = ready;
|
|
1553
1559
|
}
|
|
1554
1560
|
/**
|
|
@@ -1593,6 +1599,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1593
1599
|
let tester;
|
|
1594
1600
|
let authReady;
|
|
1595
1601
|
let hasCachedAuth = false;
|
|
1602
|
+
const signInLater = config.syncSessions === false && (await storage.get(STORAGE_KEY_PHONE))?.approved !== true;
|
|
1596
1603
|
const acquireFreshAuth = async () => {
|
|
1597
1604
|
try {
|
|
1598
1605
|
const fresh = await api.loginAnonymous(config.projectId, config.testerCode);
|
|
@@ -1608,7 +1615,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1608
1615
|
authReady = Promise.resolve();
|
|
1609
1616
|
} else {
|
|
1610
1617
|
tester = { id: "", projectId: config.projectId, code: config.testerCode };
|
|
1611
|
-
authReady = acquireFreshAuth();
|
|
1618
|
+
authReady = signInLater ? Promise.resolve() : acquireFreshAuth();
|
|
1612
1619
|
}
|
|
1613
1620
|
let sessionId = "";
|
|
1614
1621
|
let sessionReady;
|
|
@@ -1659,8 +1666,10 @@ var TpkExpo = class _TpkExpo {
|
|
|
1659
1666
|
);
|
|
1660
1667
|
instance.tester = tester;
|
|
1661
1668
|
instance.sessionId = sessionId;
|
|
1669
|
+
instance.quietUntilReport = signInLater;
|
|
1662
1670
|
sessionReady.then(() => {
|
|
1663
|
-
instance.sessionId = sessionId;
|
|
1671
|
+
if (!instance.sessionId) instance.sessionId = sessionId;
|
|
1672
|
+
instance.launchSessionSettled = true;
|
|
1664
1673
|
});
|
|
1665
1674
|
api.onTesterGate = () => instance.onTesterGate();
|
|
1666
1675
|
await instance.accessFromCache();
|
|
@@ -1712,7 +1721,8 @@ var TpkExpo = class _TpkExpo {
|
|
|
1712
1721
|
const payload = await this.buildPayload(input);
|
|
1713
1722
|
const idempotencyKey = uuidv4();
|
|
1714
1723
|
try {
|
|
1715
|
-
|
|
1724
|
+
await this.signInForReport();
|
|
1725
|
+
const response = await this.api.submitBugReport(await this.withSession(payload), {
|
|
1716
1726
|
idempotencyKey
|
|
1717
1727
|
});
|
|
1718
1728
|
this.breadcrumbs.record({
|
|
@@ -1855,6 +1865,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1855
1865
|
const cached2 = await this.storage.get(STORAGE_KEY_PHONE);
|
|
1856
1866
|
const cachedOk = cached2?.approved === true;
|
|
1857
1867
|
if (cachedOk && !options.revalidate) return "verified";
|
|
1868
|
+
await this.signInForReport();
|
|
1858
1869
|
let status;
|
|
1859
1870
|
try {
|
|
1860
1871
|
let profile;
|
|
@@ -1882,6 +1893,58 @@ var TpkExpo = class _TpkExpo {
|
|
|
1882
1893
|
}
|
|
1883
1894
|
return status;
|
|
1884
1895
|
}
|
|
1896
|
+
/**
|
|
1897
|
+
* A report needs a session, and the one attempt at launch can fail (offline,
|
|
1898
|
+
* a server error). Concurrent callers share one start; a failure leaves the
|
|
1899
|
+
* id empty and the next report or flush tries again. Never rejects.
|
|
1900
|
+
*/
|
|
1901
|
+
ensureSession() {
|
|
1902
|
+
if (this.sessionId || !this.launchSessionSettled) return Promise.resolve();
|
|
1903
|
+
this.sessionStart ?? (this.sessionStart = (async () => {
|
|
1904
|
+
try {
|
|
1905
|
+
this.sessionId = await startServerSession(this.api, this.tester.projectId);
|
|
1906
|
+
await persistSession(this.storage, this.sessionId, this.config.projectId, this.config.testerCode);
|
|
1907
|
+
} catch (e) {
|
|
1908
|
+
if (isUnauthorized(e)) await this.recoverDeadLogin();
|
|
1909
|
+
} finally {
|
|
1910
|
+
this.sessionStart = null;
|
|
1911
|
+
}
|
|
1912
|
+
})());
|
|
1913
|
+
return this.sessionStart;
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* The payload with a session id. The server refuses an empty one for good,
|
|
1917
|
+
* so this rejects while no session can start and the report stays queued.
|
|
1918
|
+
*/
|
|
1919
|
+
async withSession(payload) {
|
|
1920
|
+
if (payload.sessionId) return payload;
|
|
1921
|
+
await this.ensureSession();
|
|
1922
|
+
if (!this.sessionId) throw new Error("no session yet");
|
|
1923
|
+
return { ...payload, sessionId: this.sessionId };
|
|
1924
|
+
}
|
|
1925
|
+
/**
|
|
1926
|
+
* Signs in for the first report when `syncSessions: false` left that open,
|
|
1927
|
+
* or just ends the quiet with a stored login. Concurrent callers share one
|
|
1928
|
+
* sign-in; a failure is retried by the next one.
|
|
1929
|
+
*/
|
|
1930
|
+
signInForReport() {
|
|
1931
|
+
if (!this.quietUntilReport) return Promise.resolve();
|
|
1932
|
+
this.signingIn ?? (this.signingIn = (async () => {
|
|
1933
|
+
try {
|
|
1934
|
+
if (!this.tester.id) {
|
|
1935
|
+
const fresh = await this.api.loginAnonymous(this.config.projectId, this.config.testerCode);
|
|
1936
|
+
await this.storage.set(STORAGE_KEY_AUTH, fresh);
|
|
1937
|
+
this.tester = fresh.tester;
|
|
1938
|
+
}
|
|
1939
|
+
this.quietUntilReport = false;
|
|
1940
|
+
void this.refreshAccess().catch(() => void 0);
|
|
1941
|
+
} catch {
|
|
1942
|
+
} finally {
|
|
1943
|
+
this.signingIn = null;
|
|
1944
|
+
}
|
|
1945
|
+
})());
|
|
1946
|
+
return this.signingIn;
|
|
1947
|
+
}
|
|
1885
1948
|
/**
|
|
1886
1949
|
* Drop a login the server no longer accepts, with its session and phone
|
|
1887
1950
|
* state, and log in anonymously again, like a first start. Concurrent
|
|
@@ -1933,6 +1996,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1933
1996
|
* `revalidate: false` answers from the cache when there is one.
|
|
1934
1997
|
*/
|
|
1935
1998
|
async refreshAccess(options = {}) {
|
|
1999
|
+
if (this.quietUntilReport) return this.accessValue;
|
|
1936
2000
|
const generation = this.accessGeneration;
|
|
1937
2001
|
let status;
|
|
1938
2002
|
try {
|
|
@@ -2006,6 +2070,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
2006
2070
|
*/
|
|
2007
2071
|
async startPhone(phone) {
|
|
2008
2072
|
try {
|
|
2073
|
+
await this.signInForReport();
|
|
2009
2074
|
const r = await this.api.startPhoneVerification(phone);
|
|
2010
2075
|
return { ok: true, verificationId: r.verificationId, devCode: r.devCode };
|
|
2011
2076
|
} catch (e) {
|
|
@@ -2044,6 +2109,10 @@ var TpkExpo = class _TpkExpo {
|
|
|
2044
2109
|
approved: true
|
|
2045
2110
|
});
|
|
2046
2111
|
}
|
|
2112
|
+
if (approved !== false) {
|
|
2113
|
+
await this.ensureSession();
|
|
2114
|
+
await this.flushQueue().catch(() => void 0);
|
|
2115
|
+
}
|
|
2047
2116
|
return { ok: true, handle: r.handle, awaitingApproval: approved === false };
|
|
2048
2117
|
} catch (e) {
|
|
2049
2118
|
const status = extractStatus2(e);
|
|
@@ -2137,12 +2206,10 @@ var TpkExpo = class _TpkExpo {
|
|
|
2137
2206
|
/** Flush the offline retry queue immediately. */
|
|
2138
2207
|
async flushQueue() {
|
|
2139
2208
|
return this.queue.flush({
|
|
2140
|
-
submit: (payload, options) => {
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
}
|
|
2145
|
-
return this.api.submitBugReport(payload, options);
|
|
2209
|
+
submit: async (payload, options) => {
|
|
2210
|
+
const ready = await this.withSession(payload);
|
|
2211
|
+
await this.signInForReport();
|
|
2212
|
+
return this.api.submitBugReport(ready, options);
|
|
2146
2213
|
}
|
|
2147
2214
|
});
|
|
2148
2215
|
}
|
|
@@ -2152,6 +2219,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
2152
2219
|
*/
|
|
2153
2220
|
async attachToBugReport(bugReportId, attachment) {
|
|
2154
2221
|
try {
|
|
2222
|
+
await this.signInForReport();
|
|
2155
2223
|
return await this.api.attachToBugReport(bugReportId, attachment);
|
|
2156
2224
|
} catch (e) {
|
|
2157
2225
|
const status = extractStatus2(e);
|
|
@@ -2173,7 +2241,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
2173
2241
|
/** Flush queued attachment uploads immediately. */
|
|
2174
2242
|
async flushAttachmentQueue() {
|
|
2175
2243
|
return this.attachmentQueue.flush({
|
|
2176
|
-
attach: (bugReportId, attachment) => this.api.attachToBugReport(bugReportId, attachment)
|
|
2244
|
+
attach: (bugReportId, attachment) => this.signInForReport().then(() => this.api.attachToBugReport(bugReportId, attachment))
|
|
2177
2245
|
});
|
|
2178
2246
|
}
|
|
2179
2247
|
/** Cached crashes available for post-crash review or retry. */
|
|
@@ -2423,8 +2491,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
2423
2491
|
title: truncate(info.message, 200),
|
|
2424
2492
|
description: composeCrashDescription(info)
|
|
2425
2493
|
});
|
|
2494
|
+
await this.signInForReport();
|
|
2426
2495
|
await this.api.submitBugReport(
|
|
2427
|
-
{ ...payload, automatic: true },
|
|
2496
|
+
{ ...await this.withSession(payload), automatic: true },
|
|
2428
2497
|
{ idempotencyKey: crashId }
|
|
2429
2498
|
);
|
|
2430
2499
|
this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
|
package/dist/index.mjs
CHANGED
|
@@ -1069,7 +1069,7 @@ function findAssignmentForTask(tasks, key) {
|
|
|
1069
1069
|
}
|
|
1070
1070
|
|
|
1071
1071
|
// package.json
|
|
1072
|
-
var version = "2.1.
|
|
1072
|
+
var version = "2.1.2";
|
|
1073
1073
|
|
|
1074
1074
|
// src/version.ts
|
|
1075
1075
|
var SDK_VERSION = `@testerpaykit/expo/${version}`;
|
|
@@ -1274,6 +1274,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
1274
1274
|
this.crashFlush = Promise.resolve();
|
|
1275
1275
|
// ── Access (who sees the widget) ──
|
|
1276
1276
|
this.accessValue = "hidden";
|
|
1277
|
+
/** `syncSessions: false`: nothing reaches the server until a report does. */
|
|
1278
|
+
this.quietUntilReport = false;
|
|
1279
|
+
this.signingIn = null;
|
|
1277
1280
|
this.handleValue = null;
|
|
1278
1281
|
/** Bumped by a tester-gate 403: a check that started before it must
|
|
1279
1282
|
* not bring a stale "ready" back. */
|
|
@@ -1283,6 +1286,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
1283
1286
|
/** Active server session id. Updated by init or rotate. Used to route telemetry. */
|
|
1284
1287
|
this.sessionId = "";
|
|
1285
1288
|
this.loginRecovery = null;
|
|
1289
|
+
/** The attempt at launch is over. Until then a report must not start a second one. */
|
|
1290
|
+
this.launchSessionSettled = false;
|
|
1291
|
+
this.sessionStart = null;
|
|
1286
1292
|
this._ready = ready;
|
|
1287
1293
|
}
|
|
1288
1294
|
/**
|
|
@@ -1327,6 +1333,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1327
1333
|
let tester;
|
|
1328
1334
|
let authReady;
|
|
1329
1335
|
let hasCachedAuth = false;
|
|
1336
|
+
const signInLater = config.syncSessions === false && (await storage.get(STORAGE_KEY_PHONE))?.approved !== true;
|
|
1330
1337
|
const acquireFreshAuth = async () => {
|
|
1331
1338
|
try {
|
|
1332
1339
|
const fresh = await api.loginAnonymous(config.projectId, config.testerCode);
|
|
@@ -1342,7 +1349,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1342
1349
|
authReady = Promise.resolve();
|
|
1343
1350
|
} else {
|
|
1344
1351
|
tester = { id: "", projectId: config.projectId, code: config.testerCode };
|
|
1345
|
-
authReady = acquireFreshAuth();
|
|
1352
|
+
authReady = signInLater ? Promise.resolve() : acquireFreshAuth();
|
|
1346
1353
|
}
|
|
1347
1354
|
let sessionId = "";
|
|
1348
1355
|
let sessionReady;
|
|
@@ -1393,8 +1400,10 @@ var TpkExpo = class _TpkExpo {
|
|
|
1393
1400
|
);
|
|
1394
1401
|
instance.tester = tester;
|
|
1395
1402
|
instance.sessionId = sessionId;
|
|
1403
|
+
instance.quietUntilReport = signInLater;
|
|
1396
1404
|
sessionReady.then(() => {
|
|
1397
|
-
instance.sessionId = sessionId;
|
|
1405
|
+
if (!instance.sessionId) instance.sessionId = sessionId;
|
|
1406
|
+
instance.launchSessionSettled = true;
|
|
1398
1407
|
});
|
|
1399
1408
|
api.onTesterGate = () => instance.onTesterGate();
|
|
1400
1409
|
await instance.accessFromCache();
|
|
@@ -1446,7 +1455,8 @@ var TpkExpo = class _TpkExpo {
|
|
|
1446
1455
|
const payload = await this.buildPayload(input);
|
|
1447
1456
|
const idempotencyKey = uuidv4();
|
|
1448
1457
|
try {
|
|
1449
|
-
|
|
1458
|
+
await this.signInForReport();
|
|
1459
|
+
const response = await this.api.submitBugReport(await this.withSession(payload), {
|
|
1450
1460
|
idempotencyKey
|
|
1451
1461
|
});
|
|
1452
1462
|
this.breadcrumbs.record({
|
|
@@ -1589,6 +1599,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1589
1599
|
const cached2 = await this.storage.get(STORAGE_KEY_PHONE);
|
|
1590
1600
|
const cachedOk = cached2?.approved === true;
|
|
1591
1601
|
if (cachedOk && !options.revalidate) return "verified";
|
|
1602
|
+
await this.signInForReport();
|
|
1592
1603
|
let status;
|
|
1593
1604
|
try {
|
|
1594
1605
|
let profile;
|
|
@@ -1616,6 +1627,58 @@ var TpkExpo = class _TpkExpo {
|
|
|
1616
1627
|
}
|
|
1617
1628
|
return status;
|
|
1618
1629
|
}
|
|
1630
|
+
/**
|
|
1631
|
+
* A report needs a session, and the one attempt at launch can fail (offline,
|
|
1632
|
+
* a server error). Concurrent callers share one start; a failure leaves the
|
|
1633
|
+
* id empty and the next report or flush tries again. Never rejects.
|
|
1634
|
+
*/
|
|
1635
|
+
ensureSession() {
|
|
1636
|
+
if (this.sessionId || !this.launchSessionSettled) return Promise.resolve();
|
|
1637
|
+
this.sessionStart ?? (this.sessionStart = (async () => {
|
|
1638
|
+
try {
|
|
1639
|
+
this.sessionId = await startServerSession(this.api, this.tester.projectId);
|
|
1640
|
+
await persistSession(this.storage, this.sessionId, this.config.projectId, this.config.testerCode);
|
|
1641
|
+
} catch (e) {
|
|
1642
|
+
if (isUnauthorized(e)) await this.recoverDeadLogin();
|
|
1643
|
+
} finally {
|
|
1644
|
+
this.sessionStart = null;
|
|
1645
|
+
}
|
|
1646
|
+
})());
|
|
1647
|
+
return this.sessionStart;
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* The payload with a session id. The server refuses an empty one for good,
|
|
1651
|
+
* so this rejects while no session can start and the report stays queued.
|
|
1652
|
+
*/
|
|
1653
|
+
async withSession(payload) {
|
|
1654
|
+
if (payload.sessionId) return payload;
|
|
1655
|
+
await this.ensureSession();
|
|
1656
|
+
if (!this.sessionId) throw new Error("no session yet");
|
|
1657
|
+
return { ...payload, sessionId: this.sessionId };
|
|
1658
|
+
}
|
|
1659
|
+
/**
|
|
1660
|
+
* Signs in for the first report when `syncSessions: false` left that open,
|
|
1661
|
+
* or just ends the quiet with a stored login. Concurrent callers share one
|
|
1662
|
+
* sign-in; a failure is retried by the next one.
|
|
1663
|
+
*/
|
|
1664
|
+
signInForReport() {
|
|
1665
|
+
if (!this.quietUntilReport) return Promise.resolve();
|
|
1666
|
+
this.signingIn ?? (this.signingIn = (async () => {
|
|
1667
|
+
try {
|
|
1668
|
+
if (!this.tester.id) {
|
|
1669
|
+
const fresh = await this.api.loginAnonymous(this.config.projectId, this.config.testerCode);
|
|
1670
|
+
await this.storage.set(STORAGE_KEY_AUTH, fresh);
|
|
1671
|
+
this.tester = fresh.tester;
|
|
1672
|
+
}
|
|
1673
|
+
this.quietUntilReport = false;
|
|
1674
|
+
void this.refreshAccess().catch(() => void 0);
|
|
1675
|
+
} catch {
|
|
1676
|
+
} finally {
|
|
1677
|
+
this.signingIn = null;
|
|
1678
|
+
}
|
|
1679
|
+
})());
|
|
1680
|
+
return this.signingIn;
|
|
1681
|
+
}
|
|
1619
1682
|
/**
|
|
1620
1683
|
* Drop a login the server no longer accepts, with its session and phone
|
|
1621
1684
|
* state, and log in anonymously again, like a first start. Concurrent
|
|
@@ -1667,6 +1730,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1667
1730
|
* `revalidate: false` answers from the cache when there is one.
|
|
1668
1731
|
*/
|
|
1669
1732
|
async refreshAccess(options = {}) {
|
|
1733
|
+
if (this.quietUntilReport) return this.accessValue;
|
|
1670
1734
|
const generation = this.accessGeneration;
|
|
1671
1735
|
let status;
|
|
1672
1736
|
try {
|
|
@@ -1740,6 +1804,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1740
1804
|
*/
|
|
1741
1805
|
async startPhone(phone) {
|
|
1742
1806
|
try {
|
|
1807
|
+
await this.signInForReport();
|
|
1743
1808
|
const r = await this.api.startPhoneVerification(phone);
|
|
1744
1809
|
return { ok: true, verificationId: r.verificationId, devCode: r.devCode };
|
|
1745
1810
|
} catch (e) {
|
|
@@ -1778,6 +1843,10 @@ var TpkExpo = class _TpkExpo {
|
|
|
1778
1843
|
approved: true
|
|
1779
1844
|
});
|
|
1780
1845
|
}
|
|
1846
|
+
if (approved !== false) {
|
|
1847
|
+
await this.ensureSession();
|
|
1848
|
+
await this.flushQueue().catch(() => void 0);
|
|
1849
|
+
}
|
|
1781
1850
|
return { ok: true, handle: r.handle, awaitingApproval: approved === false };
|
|
1782
1851
|
} catch (e) {
|
|
1783
1852
|
const status = extractStatus2(e);
|
|
@@ -1871,12 +1940,10 @@ var TpkExpo = class _TpkExpo {
|
|
|
1871
1940
|
/** Flush the offline retry queue immediately. */
|
|
1872
1941
|
async flushQueue() {
|
|
1873
1942
|
return this.queue.flush({
|
|
1874
|
-
submit: (payload, options) => {
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
}
|
|
1879
|
-
return this.api.submitBugReport(payload, options);
|
|
1943
|
+
submit: async (payload, options) => {
|
|
1944
|
+
const ready = await this.withSession(payload);
|
|
1945
|
+
await this.signInForReport();
|
|
1946
|
+
return this.api.submitBugReport(ready, options);
|
|
1880
1947
|
}
|
|
1881
1948
|
});
|
|
1882
1949
|
}
|
|
@@ -1886,6 +1953,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1886
1953
|
*/
|
|
1887
1954
|
async attachToBugReport(bugReportId, attachment) {
|
|
1888
1955
|
try {
|
|
1956
|
+
await this.signInForReport();
|
|
1889
1957
|
return await this.api.attachToBugReport(bugReportId, attachment);
|
|
1890
1958
|
} catch (e) {
|
|
1891
1959
|
const status = extractStatus2(e);
|
|
@@ -1907,7 +1975,7 @@ var TpkExpo = class _TpkExpo {
|
|
|
1907
1975
|
/** Flush queued attachment uploads immediately. */
|
|
1908
1976
|
async flushAttachmentQueue() {
|
|
1909
1977
|
return this.attachmentQueue.flush({
|
|
1910
|
-
attach: (bugReportId, attachment) => this.api.attachToBugReport(bugReportId, attachment)
|
|
1978
|
+
attach: (bugReportId, attachment) => this.signInForReport().then(() => this.api.attachToBugReport(bugReportId, attachment))
|
|
1911
1979
|
});
|
|
1912
1980
|
}
|
|
1913
1981
|
/** Cached crashes available for post-crash review or retry. */
|
|
@@ -2157,8 +2225,9 @@ var TpkExpo = class _TpkExpo {
|
|
|
2157
2225
|
title: truncate(info.message, 200),
|
|
2158
2226
|
description: composeCrashDescription(info)
|
|
2159
2227
|
});
|
|
2228
|
+
await this.signInForReport();
|
|
2160
2229
|
await this.api.submitBugReport(
|
|
2161
|
-
{ ...payload, automatic: true },
|
|
2230
|
+
{ ...await this.withSession(payload), automatic: true },
|
|
2162
2231
|
{ idempotencyKey: crashId }
|
|
2163
2232
|
);
|
|
2164
2233
|
this.breadcrumbs.record({ action: "tpk", target: "crash_submitted" });
|
package/package.json
CHANGED