Skip to content

Commit 9bd5744

Browse files
committed
Avoid loops and errors
1 parent ec76b05 commit 9bd5744

7 files changed

Lines changed: 23 additions & 19 deletions

File tree

docs/hds-lib.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/hds-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/tests-browser.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21012,16 +21012,17 @@ class AppClientAccount extends Application {
2101221012
const collectorClient = this.cache.collectorClientsMap[collectorClientKey];
2101321013
logger.debug('AppClient:handleIncomingRequest found existing', { collectorClient });
2101421014
if (collectorClient.requesterApiEndpoint !== apiEndpoint) {
21015-
console.log('⚠️⚠️⚠️⚠️ RESET! Found existing collectorClient with a different apiEndpoint', { actual: collectorClient.requesterApiEndpoint, incoming: apiEndpoint });
21016-
// throw new HDSLibError('Found existing collectorClient with a different apiEndpoint', { actual: collectorClient.requesterApiEndpoint, incoming: apiEndpoint });
21015+
// console.log('⚠️⚠️⚠️⚠️ RESET! Found existing collectorClient with a different apiEndpoint', { actual: collectorClient.requesterApiEndpoint, incoming: apiEndpoint });
21016+
throw new HDSLibError('Found existing collectorClient with a different apiEndpoint', { actual: collectorClient.requesterApiEndpoint, incoming: apiEndpoint });
2101721017
// we might consider reseting() in the future;
21018-
return await collectorClient.reset(apiEndpoint, incomingEventId, accessInfo);
21018+
// return await collectorClient.reset(apiEndpoint, incomingEventId, accessInfo);
2101921019
}
2102021020
if (incomingEventId && collectorClient.requesterEventId !== incomingEventId) {
21021-
// throw new HDSLibError('Found existing collectorClient with a different eventId', { actual: collectorClient.requesterEventId, incoming: incomingEventId });
21022-
console.log('⚠️⚠️⚠️⚠️ RESET! Found existing collectorClient with a different eventId', { actual: collectorClient.requesterEventId, incoming: incomingEventId });
21021+
throw new HDSLibError('Found existing collectorClient with a different eventId', { actual: collectorClient.requesterEventId, incoming: incomingEventId });
21022+
// console.log('⚠️⚠️⚠️⚠️ RESET! Found existing collectorClient with a different eventId', { actual: collectorClient.requesterEventId, incoming: incomingEventId });
2102321023
// we might consider reseting() in the future;
21024-
return await collectorClient.reset(apiEndpoint, incomingEventId, accessInfo);
21024+
// return await collectorClient.reset(apiEndpoint, incomingEventId, accessInfo);
21025+
// return null;
2102521026
}
2102621027
return collectorClient;
2102721028
}
@@ -21739,9 +21740,10 @@ class Collector {
2173921740
/**
2174021741
* @private
2174121742
* @param {CollectorInvite} invite
21743+
* @param {boolean} alreadyChecked // to avoid loops
2174221744
* @returns {CollectorInvite}
2174321745
*/
21744-
async revokeInvite (invite) {
21746+
async revokeInvite (invite, alreadyChecked = false) {
2174521747
// Invalidate Invite APIEndpoint(s)
2174621748
if (invite.status === 'active') { // invalidate eventual authorization granted
2174721749
const accessInfo = await invite.checkAndGetAccessInfo(true);
@@ -22235,7 +22237,7 @@ class CollectorInvite {
2223522237
} catch (e) {
2223622238
this.#accessInfo = null;
2223722239
if (e.response?.body?.error?.id === 'invalid-access-token') {
22238-
await this.revoke();
22240+
await this.collector.revokeInvite(this, true);
2223922241
return null;
2224022242
}
2224122243
throw e;

docs/tests-browser.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/appTemplates/AppClientAccount.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ class AppClientAccount extends Application {
4242
const collectorClient = this.cache.collectorClientsMap[collectorClientKey];
4343
logger.debug('AppClient:handleIncomingRequest found existing', { collectorClient });
4444
if (collectorClient.requesterApiEndpoint !== apiEndpoint) {
45-
console.log('⚠️⚠️⚠️⚠️ RESET! Found existing collectorClient with a different apiEndpoint', { actual: collectorClient.requesterApiEndpoint, incoming: apiEndpoint });
46-
// throw new HDSLibError('Found existing collectorClient with a different apiEndpoint', { actual: collectorClient.requesterApiEndpoint, incoming: apiEndpoint });
45+
// console.log('⚠️⚠️⚠️⚠️ RESET! Found existing collectorClient with a different apiEndpoint', { actual: collectorClient.requesterApiEndpoint, incoming: apiEndpoint });
46+
throw new HDSLibError('Found existing collectorClient with a different apiEndpoint', { actual: collectorClient.requesterApiEndpoint, incoming: apiEndpoint });
4747
// we might consider reseting() in the future;
48-
return await collectorClient.reset(apiEndpoint, incomingEventId, accessInfo);
48+
// return await collectorClient.reset(apiEndpoint, incomingEventId, accessInfo);
4949
}
5050
if (incomingEventId && collectorClient.requesterEventId !== incomingEventId) {
51-
// throw new HDSLibError('Found existing collectorClient with a different eventId', { actual: collectorClient.requesterEventId, incoming: incomingEventId });
52-
console.log('⚠️⚠️⚠️⚠️ RESET! Found existing collectorClient with a different eventId', { actual: collectorClient.requesterEventId, incoming: incomingEventId });
51+
throw new HDSLibError('Found existing collectorClient with a different eventId', { actual: collectorClient.requesterEventId, incoming: incomingEventId });
52+
// console.log('⚠️⚠️⚠️⚠️ RESET! Found existing collectorClient with a different eventId', { actual: collectorClient.requesterEventId, incoming: incomingEventId });
5353
// we might consider reseting() in the future;
54-
return await collectorClient.reset(apiEndpoint, incomingEventId, accessInfo);
54+
// return await collectorClient.reset(apiEndpoint, incomingEventId, accessInfo);
55+
// return null;
5556
}
5657
return collectorClient;
5758
}

src/appTemplates/Collector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,10 @@ class Collector {
320320
/**
321321
* @private
322322
* @param {CollectorInvite} invite
323+
* @param {boolean} alreadyChecked // to avoid loops
323324
* @returns {CollectorInvite}
324325
*/
325-
async revokeInvite (invite) {
326+
async revokeInvite (invite, alreadyChecked = false) {
326327
// Invalidate Invite APIEndpoint(s)
327328
if (invite.status === 'active') { // invalidate eventual authorization granted
328329
const accessInfo = await invite.checkAndGetAccessInfo(true);

src/appTemplates/CollectorInvite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class CollectorInvite {
6969
} catch (e) {
7070
this.#accessInfo = null;
7171
if (e.response?.body?.error?.id === 'invalid-access-token') {
72-
await this.revoke();
72+
await this.collector.revokeInvite(this, true);
7373
return null;
7474
}
7575
throw e;

0 commit comments

Comments
 (0)