@notabene/javascript-sdk 2.18.0 → 2.19.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/src/types.ts CHANGED
@@ -978,6 +978,25 @@ export interface AgentSections {
978
978
  fallback?: SectionOption[];
979
979
  }
980
980
 
981
+ /**
982
+ * Configuration for the terms and conditions consent checkbox.
983
+ *
984
+ * @remarks
985
+ * - `undefined` or `true`: show default T&C (current behavior)
986
+ * - `false`: hide T&C entirely
987
+ * - `{ label?, description? }`: show with custom text (translations are the customer's responsibility)
988
+ *
989
+ * @public
990
+ */
991
+ export type ConsentConfig =
992
+ | boolean
993
+ | {
994
+ /** Custom label text. Replaces the default "Accept terms and conditions". */
995
+ label?: string;
996
+ /** Custom description text. Replaces the default sharing-info description. */
997
+ description?: string;
998
+ };
999
+
981
1000
  /**
982
1001
  * Configuration options for Transaction components
983
1002
  * @public
@@ -1005,12 +1024,8 @@ export interface TransactionOptions {
1005
1024
  vasps?: VASPOptions;
1006
1025
  hide?: ValidationSections[]; // You can hide a specific section of the component by listing it here
1007
1026
  counterpartyAssist?: CounterpartyAssistConfig;
1008
- /**
1009
- * Configuration for the contact support button.
1010
- * Enablement is controlled via `agentSections` — include `'contact-support'`
1011
- * in `main` or `fallback` to show the button.
1012
- */
1013
- contactSupport?: ContactSupportConfig;
1027
+ contactSupport?: ContactSupportConfig; // Requires 'contact-support' in agentSections
1028
+ consent?: ConsentConfig; // Defaults to true
1014
1029
  autoSubmit?: boolean; // Defaults to false
1015
1030
  }
1016
1031
  /**
@@ -38,6 +38,8 @@ export class MessageEventManager<T, O> {
38
38
  */
39
39
 
40
40
  setPort(port: MessagePort): void {
41
+ if (!port) return;
42
+ this.port?.close();
41
43
  this.port = port;
42
44
  this.port.onmessage = this.handleMessage;
43
45
  this.port.start();
@@ -24,6 +24,14 @@ describe('MessageEventManager', () => {
24
24
  });
25
25
 
26
26
  describe('setPort', () => {
27
+ it('should ignore undefined port', () => {
28
+ expect(() =>
29
+ messageEventManager.setPort(undefined as unknown as MessagePort),
30
+ ).not.toThrow();
31
+ });
32
+ });
33
+
34
+ describe('setPort with valid port', () => {
27
35
  beforeEach(() => {
28
36
  messageEventManager.setPort(mockPort);
29
37
  });