@redacto.io/consent-sdk-js 1.0.0-beta.0 → 1.0.0-beta.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/redacto.global.js +2 -2
- package/dist/redacto.global.js.map +1 -1
- package/dist/redacto.js +31 -7
- package/dist/redacto.mjs +31 -7
- package/package.json +1 -1
package/dist/redacto.js
CHANGED
|
@@ -4447,6 +4447,7 @@ var InlineController = class {
|
|
|
4447
4447
|
this.hasSubmitted = false;
|
|
4448
4448
|
this.hasCheckedLedgerConsent = false;
|
|
4449
4449
|
this.unsubscribe = null;
|
|
4450
|
+
this.abortController = null;
|
|
4450
4451
|
this.options = options;
|
|
4451
4452
|
this.store = new Store({
|
|
4452
4453
|
content: null,
|
|
@@ -4464,6 +4465,7 @@ var InlineController = class {
|
|
|
4464
4465
|
this.mediaQuery = createMediaQuery("(max-width: 768px)");
|
|
4465
4466
|
}
|
|
4466
4467
|
async init() {
|
|
4468
|
+
this.abortController = new AbortController();
|
|
4467
4469
|
if (typeof this.options.target === "string") {
|
|
4468
4470
|
this.targetEl = document.querySelector(this.options.target);
|
|
4469
4471
|
if (!this.targetEl) {
|
|
@@ -4486,8 +4488,9 @@ var InlineController = class {
|
|
|
4486
4488
|
await this.fetchNotice();
|
|
4487
4489
|
}
|
|
4488
4490
|
destroy() {
|
|
4489
|
-
var _a;
|
|
4490
|
-
(_a = this.
|
|
4491
|
+
var _a, _b;
|
|
4492
|
+
(_a = this.abortController) == null ? void 0 : _a.abort();
|
|
4493
|
+
(_b = this.unsubscribe) == null ? void 0 : _b.call(this);
|
|
4491
4494
|
this.mediaQuery.destroy();
|
|
4492
4495
|
this.store.destroy();
|
|
4493
4496
|
if (this.hostEl && this.hostEl.parentNode) {
|
|
@@ -4507,6 +4510,12 @@ var InlineController = class {
|
|
|
4507
4510
|
this.tryAutoSubmit();
|
|
4508
4511
|
}
|
|
4509
4512
|
// ─── Private ───
|
|
4513
|
+
// destroy() aborts the controller, so an aborted signal is the marker that
|
|
4514
|
+
// teardown has happened and async continuations must not touch the host.
|
|
4515
|
+
isDestroyed() {
|
|
4516
|
+
var _a;
|
|
4517
|
+
return Boolean((_a = this.abortController) == null ? void 0 : _a.signal.aborted);
|
|
4518
|
+
}
|
|
4510
4519
|
async fetchNotice() {
|
|
4511
4520
|
var _a, _b, _c, _d;
|
|
4512
4521
|
this.store.setState({ isLoading: true, fetchError: null });
|
|
@@ -4519,6 +4528,9 @@ var InlineController = class {
|
|
|
4519
4528
|
language: this.options.language,
|
|
4520
4529
|
specific_uuid: this.options.applicationId
|
|
4521
4530
|
});
|
|
4531
|
+
if (this.isDestroyed()) {
|
|
4532
|
+
return;
|
|
4533
|
+
}
|
|
4522
4534
|
const activeConfig = data.detail.active_config;
|
|
4523
4535
|
const initialCollapsed = {};
|
|
4524
4536
|
const initialPurposes = {};
|
|
@@ -4540,6 +4552,9 @@ var InlineController = class {
|
|
|
4540
4552
|
selectedDataElements: initialElements
|
|
4541
4553
|
});
|
|
4542
4554
|
} catch (err) {
|
|
4555
|
+
if (this.isDestroyed()) {
|
|
4556
|
+
return;
|
|
4557
|
+
}
|
|
4543
4558
|
const error = err;
|
|
4544
4559
|
if (error.status === 409) {
|
|
4545
4560
|
this.store.setState({ hasAlreadyConsented: true, isLoading: false });
|
|
@@ -4558,7 +4573,7 @@ var InlineController = class {
|
|
|
4558
4573
|
// (the 409 path governs) and for the magic-link applicationId flow. Any
|
|
4559
4574
|
// failure returns null and falls through to the normal flow.
|
|
4560
4575
|
async checkLedgerConsent() {
|
|
4561
|
-
var _a, _b;
|
|
4576
|
+
var _a, _b, _c;
|
|
4562
4577
|
if (!this.shouldCheckLedgerConsent()) return;
|
|
4563
4578
|
this.hasCheckedLedgerConsent = true;
|
|
4564
4579
|
this.store.setState({ isCheckingConsent: true });
|
|
@@ -4568,15 +4583,21 @@ var InlineController = class {
|
|
|
4568
4583
|
ledgerBaseUrl: this.options.ledgerBaseUrl,
|
|
4569
4584
|
organisationUuid: this.options.org_uuid,
|
|
4570
4585
|
workspaceUuid: this.options.workspace_uuid,
|
|
4571
|
-
noticeUuid: this.options.notice_uuid
|
|
4586
|
+
noticeUuid: this.options.notice_uuid,
|
|
4587
|
+
signal: (_a = this.abortController) == null ? void 0 : _a.signal
|
|
4572
4588
|
});
|
|
4589
|
+
if (this.isDestroyed()) {
|
|
4590
|
+
return;
|
|
4591
|
+
}
|
|
4573
4592
|
if (status && isNoticeFullyConsented(status)) {
|
|
4574
4593
|
this.store.setState({ hasAlreadyConsented: true });
|
|
4575
|
-
(
|
|
4594
|
+
(_c = (_b = this.options).onAccept) == null ? void 0 : _c.call(_b);
|
|
4576
4595
|
}
|
|
4577
4596
|
} finally {
|
|
4578
|
-
this.
|
|
4579
|
-
|
|
4597
|
+
if (!this.isDestroyed()) {
|
|
4598
|
+
this.store.setState({ isCheckingConsent: false });
|
|
4599
|
+
this.tryAutoSubmit();
|
|
4600
|
+
}
|
|
4580
4601
|
}
|
|
4581
4602
|
}
|
|
4582
4603
|
handleStateChange(state, prevState) {
|
|
@@ -4798,6 +4819,9 @@ var InlineController = class {
|
|
|
4798
4819
|
}
|
|
4799
4820
|
async tryAutoSubmit() {
|
|
4800
4821
|
var _a, _b;
|
|
4822
|
+
if (this.isDestroyed()) {
|
|
4823
|
+
return;
|
|
4824
|
+
}
|
|
4801
4825
|
const state = this.store.getState();
|
|
4802
4826
|
const accessToken = this.options.accessToken;
|
|
4803
4827
|
if (accessToken && state.content && this.areAllRequiredElementsChecked() && !state.isSubmitting && !state.isCheckingConsent && !state.hasAlreadyConsented && !this.hasSubmitted) {
|
package/dist/redacto.mjs
CHANGED
|
@@ -4417,6 +4417,7 @@ var InlineController = class {
|
|
|
4417
4417
|
this.hasSubmitted = false;
|
|
4418
4418
|
this.hasCheckedLedgerConsent = false;
|
|
4419
4419
|
this.unsubscribe = null;
|
|
4420
|
+
this.abortController = null;
|
|
4420
4421
|
this.options = options;
|
|
4421
4422
|
this.store = new Store({
|
|
4422
4423
|
content: null,
|
|
@@ -4434,6 +4435,7 @@ var InlineController = class {
|
|
|
4434
4435
|
this.mediaQuery = createMediaQuery("(max-width: 768px)");
|
|
4435
4436
|
}
|
|
4436
4437
|
async init() {
|
|
4438
|
+
this.abortController = new AbortController();
|
|
4437
4439
|
if (typeof this.options.target === "string") {
|
|
4438
4440
|
this.targetEl = document.querySelector(this.options.target);
|
|
4439
4441
|
if (!this.targetEl) {
|
|
@@ -4456,8 +4458,9 @@ var InlineController = class {
|
|
|
4456
4458
|
await this.fetchNotice();
|
|
4457
4459
|
}
|
|
4458
4460
|
destroy() {
|
|
4459
|
-
var _a;
|
|
4460
|
-
(_a = this.
|
|
4461
|
+
var _a, _b;
|
|
4462
|
+
(_a = this.abortController) == null ? void 0 : _a.abort();
|
|
4463
|
+
(_b = this.unsubscribe) == null ? void 0 : _b.call(this);
|
|
4461
4464
|
this.mediaQuery.destroy();
|
|
4462
4465
|
this.store.destroy();
|
|
4463
4466
|
if (this.hostEl && this.hostEl.parentNode) {
|
|
@@ -4477,6 +4480,12 @@ var InlineController = class {
|
|
|
4477
4480
|
this.tryAutoSubmit();
|
|
4478
4481
|
}
|
|
4479
4482
|
// ─── Private ───
|
|
4483
|
+
// destroy() aborts the controller, so an aborted signal is the marker that
|
|
4484
|
+
// teardown has happened and async continuations must not touch the host.
|
|
4485
|
+
isDestroyed() {
|
|
4486
|
+
var _a;
|
|
4487
|
+
return Boolean((_a = this.abortController) == null ? void 0 : _a.signal.aborted);
|
|
4488
|
+
}
|
|
4480
4489
|
async fetchNotice() {
|
|
4481
4490
|
var _a, _b, _c, _d;
|
|
4482
4491
|
this.store.setState({ isLoading: true, fetchError: null });
|
|
@@ -4489,6 +4498,9 @@ var InlineController = class {
|
|
|
4489
4498
|
language: this.options.language,
|
|
4490
4499
|
specific_uuid: this.options.applicationId
|
|
4491
4500
|
});
|
|
4501
|
+
if (this.isDestroyed()) {
|
|
4502
|
+
return;
|
|
4503
|
+
}
|
|
4492
4504
|
const activeConfig = data.detail.active_config;
|
|
4493
4505
|
const initialCollapsed = {};
|
|
4494
4506
|
const initialPurposes = {};
|
|
@@ -4510,6 +4522,9 @@ var InlineController = class {
|
|
|
4510
4522
|
selectedDataElements: initialElements
|
|
4511
4523
|
});
|
|
4512
4524
|
} catch (err) {
|
|
4525
|
+
if (this.isDestroyed()) {
|
|
4526
|
+
return;
|
|
4527
|
+
}
|
|
4513
4528
|
const error = err;
|
|
4514
4529
|
if (error.status === 409) {
|
|
4515
4530
|
this.store.setState({ hasAlreadyConsented: true, isLoading: false });
|
|
@@ -4528,7 +4543,7 @@ var InlineController = class {
|
|
|
4528
4543
|
// (the 409 path governs) and for the magic-link applicationId flow. Any
|
|
4529
4544
|
// failure returns null and falls through to the normal flow.
|
|
4530
4545
|
async checkLedgerConsent() {
|
|
4531
|
-
var _a, _b;
|
|
4546
|
+
var _a, _b, _c;
|
|
4532
4547
|
if (!this.shouldCheckLedgerConsent()) return;
|
|
4533
4548
|
this.hasCheckedLedgerConsent = true;
|
|
4534
4549
|
this.store.setState({ isCheckingConsent: true });
|
|
@@ -4538,15 +4553,21 @@ var InlineController = class {
|
|
|
4538
4553
|
ledgerBaseUrl: this.options.ledgerBaseUrl,
|
|
4539
4554
|
organisationUuid: this.options.org_uuid,
|
|
4540
4555
|
workspaceUuid: this.options.workspace_uuid,
|
|
4541
|
-
noticeUuid: this.options.notice_uuid
|
|
4556
|
+
noticeUuid: this.options.notice_uuid,
|
|
4557
|
+
signal: (_a = this.abortController) == null ? void 0 : _a.signal
|
|
4542
4558
|
});
|
|
4559
|
+
if (this.isDestroyed()) {
|
|
4560
|
+
return;
|
|
4561
|
+
}
|
|
4543
4562
|
if (status && isNoticeFullyConsented(status)) {
|
|
4544
4563
|
this.store.setState({ hasAlreadyConsented: true });
|
|
4545
|
-
(
|
|
4564
|
+
(_c = (_b = this.options).onAccept) == null ? void 0 : _c.call(_b);
|
|
4546
4565
|
}
|
|
4547
4566
|
} finally {
|
|
4548
|
-
this.
|
|
4549
|
-
|
|
4567
|
+
if (!this.isDestroyed()) {
|
|
4568
|
+
this.store.setState({ isCheckingConsent: false });
|
|
4569
|
+
this.tryAutoSubmit();
|
|
4570
|
+
}
|
|
4550
4571
|
}
|
|
4551
4572
|
}
|
|
4552
4573
|
handleStateChange(state, prevState) {
|
|
@@ -4768,6 +4789,9 @@ var InlineController = class {
|
|
|
4768
4789
|
}
|
|
4769
4790
|
async tryAutoSubmit() {
|
|
4770
4791
|
var _a, _b;
|
|
4792
|
+
if (this.isDestroyed()) {
|
|
4793
|
+
return;
|
|
4794
|
+
}
|
|
4771
4795
|
const state = this.store.getState();
|
|
4772
4796
|
const accessToken = this.options.accessToken;
|
|
4773
4797
|
if (accessToken && state.content && this.areAllRequiredElementsChecked() && !state.isSubmitting && !state.isCheckingConsent && !state.hasAlreadyConsented && !this.hasSubmitted) {
|