@notabene/javascript-sdk 2.8.0-next.4 → 2.8.0-next.6

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.
Files changed (134) hide show
  1. package/README.md +30 -0
  2. package/dist/cjs/notabene.cjs +1 -1
  3. package/dist/cjs/notabene.d.ts +92 -8
  4. package/dist/cjs/package.json +1 -1
  5. package/dist/esm/notabene.d.ts +92 -8
  6. package/dist/esm/notabene.js +282 -137
  7. package/dist/esm/package.json +1 -1
  8. package/dist/notabene.d.ts +92 -8
  9. package/dist/notabene.js +282 -137
  10. package/docs/README.md +30 -0
  11. package/docs/_media/TransactionOptions.md +6 -6
  12. package/docs/ivms/types/enumerations/PayloadVersionCode.md +2 -2
  13. package/docs/ivms/types/interfaces/PayloadMetadata.md +2 -2
  14. package/docs/ivms/types/type-aliases/Address.md +1 -1
  15. package/docs/ivms/types/type-aliases/AddressTypeCode.md +1 -1
  16. package/docs/ivms/types/type-aliases/Beneficiary.md +1 -1
  17. package/docs/ivms/types/type-aliases/BeneficiaryVASP.md +1 -1
  18. package/docs/ivms/types/type-aliases/DateAndPlaceOfBirth.md +1 -1
  19. package/docs/ivms/types/type-aliases/ISOCountryCode.md +1 -1
  20. package/docs/ivms/types/type-aliases/ISODate.md +1 -1
  21. package/docs/ivms/types/type-aliases/IVMS101.md +1 -1
  22. package/docs/ivms/types/type-aliases/IntermediaryVASP.md +1 -1
  23. package/docs/ivms/types/type-aliases/LegalPerson.md +1 -1
  24. package/docs/ivms/types/type-aliases/LegalPersonName.md +1 -1
  25. package/docs/ivms/types/type-aliases/LegalPersonNameID.md +1 -1
  26. package/docs/ivms/types/type-aliases/LegalPersonNameTypeCode.md +1 -1
  27. package/docs/ivms/types/type-aliases/LocalLegalPersonNameID.md +1 -1
  28. package/docs/ivms/types/type-aliases/LocalNaturalPersonNameID.md +1 -1
  29. package/docs/ivms/types/type-aliases/NationalIdentification.md +1 -1
  30. package/docs/ivms/types/type-aliases/NationalIdentifierTypeCode.md +1 -1
  31. package/docs/ivms/types/type-aliases/NaturalPerson.md +1 -1
  32. package/docs/ivms/types/type-aliases/NaturalPersonName.md +1 -1
  33. package/docs/ivms/types/type-aliases/NaturalPersonNameID.md +1 -1
  34. package/docs/ivms/types/type-aliases/NaturalPersonNameTypeCode.md +1 -1
  35. package/docs/ivms/types/type-aliases/OriginatingVASP.md +1 -1
  36. package/docs/ivms/types/type-aliases/Originator.md +1 -1
  37. package/docs/ivms/types/type-aliases/Person.md +1 -1
  38. package/docs/ivms/types/type-aliases/TransferPath.md +1 -1
  39. package/docs/ivms/types/type-aliases/TransliterationMethodCode.md +1 -1
  40. package/docs/notabene/README.md +5 -0
  41. package/docs/notabene/classes/ConnectionManager.md +165 -0
  42. package/docs/notabene/classes/EmbeddedComponent.md +17 -17
  43. package/docs/notabene/classes/default.md +7 -7
  44. package/docs/notabene/functions/decodeFragmentToObject.md +1 -1
  45. package/docs/notabene/interfaces/ConnectionData.md +41 -0
  46. package/docs/notabene/interfaces/ConnectionMetadata.md +37 -0
  47. package/docs/notabene/interfaces/ConnectionResponse.md +61 -0
  48. package/docs/notabene/interfaces/NotabeneConfig.md +5 -5
  49. package/docs/notabene/type-aliases/MessageCallback.md +1 -1
  50. package/docs/notabene/type-aliases/TransactionType.md +13 -0
  51. package/docs/types/README.md +1 -0
  52. package/docs/types/enumerations/AgentType.md +2 -2
  53. package/docs/types/enumerations/CMType.md +7 -7
  54. package/docs/types/enumerations/ErrorIdentifierCode.md +4 -4
  55. package/docs/types/enumerations/HMType.md +2 -2
  56. package/docs/types/enumerations/PersonType.md +3 -3
  57. package/docs/types/enumerations/ProofStatus.md +4 -4
  58. package/docs/types/enumerations/ProofTypes.md +16 -16
  59. package/docs/types/enumerations/Status.md +5 -5
  60. package/docs/types/enumerations/VASPSearchControl.md +2 -2
  61. package/docs/types/enumerations/ValidationSections.md +4 -4
  62. package/docs/types/interfaces/Agent.md +6 -6
  63. package/docs/types/interfaces/CallbackOptions.md +2 -2
  64. package/docs/types/interfaces/ComponentRequest.md +2 -2
  65. package/docs/types/interfaces/ComponentResponse.md +4 -4
  66. package/docs/types/interfaces/ConnectionRecord.md +7 -7
  67. package/docs/types/interfaces/ConnectionRequest.md +3 -3
  68. package/docs/types/interfaces/Counterparty.md +10 -10
  69. package/docs/types/interfaces/DeclarationProof.md +6 -6
  70. package/docs/types/interfaces/Deposit.md +11 -11
  71. package/docs/types/interfaces/DepositRequest.md +7 -7
  72. package/docs/types/interfaces/DepositRequestOptions.md +1 -1
  73. package/docs/types/interfaces/DepositTransaction.md +9 -9
  74. package/docs/types/interfaces/LegalPerson.md +13 -13
  75. package/docs/types/interfaces/MicroTransferProof.md +9 -9
  76. package/docs/types/interfaces/NaturalPerson.md +13 -13
  77. package/docs/types/interfaces/OwnershipProof.md +4 -4
  78. package/docs/types/interfaces/RefreshSource.md +2 -2
  79. package/docs/types/interfaces/Refreshable.md +1 -1
  80. package/docs/types/interfaces/ScreenshotProof.md +5 -5
  81. package/docs/types/interfaces/SignatureProof.md +9 -9
  82. package/docs/types/interfaces/ThresholdOptions.md +3 -3
  83. package/docs/types/interfaces/Transaction.md +8 -8
  84. package/docs/types/interfaces/TransactionOptions.md +6 -6
  85. package/docs/types/interfaces/TransactionResponse.md +9 -9
  86. package/docs/types/interfaces/VASP.md +9 -9
  87. package/docs/types/interfaces/Wallet.md +8 -8
  88. package/docs/types/interfaces/Withdrawal.md +10 -10
  89. package/docs/types/type-aliases/BlockchainAddress.md +1 -1
  90. package/docs/types/type-aliases/CAIP10.md +1 -1
  91. package/docs/types/type-aliases/CAIP19.md +1 -1
  92. package/docs/types/type-aliases/CAIP2.md +1 -1
  93. package/docs/types/type-aliases/CAIP220.md +1 -1
  94. package/docs/types/type-aliases/Cancel.md +1 -1
  95. package/docs/types/type-aliases/Completed.md +1 -1
  96. package/docs/types/type-aliases/ComponentMessage.md +1 -1
  97. package/docs/types/type-aliases/ConnectionOptions.md +1 -1
  98. package/docs/types/type-aliases/CryptoCredential.md +1 -1
  99. package/docs/types/type-aliases/DID.md +1 -1
  100. package/docs/types/type-aliases/DTI.md +1 -1
  101. package/docs/types/type-aliases/Destination.md +1 -1
  102. package/docs/types/type-aliases/Error.md +1 -1
  103. package/docs/types/type-aliases/FieldOptions.md +1 -1
  104. package/docs/types/type-aliases/FieldTypes.md +1 -1
  105. package/docs/types/type-aliases/HostMessage.md +1 -1
  106. package/docs/types/type-aliases/ISOCurrency.md +1 -1
  107. package/docs/types/type-aliases/InvalidValue.md +1 -1
  108. package/docs/types/type-aliases/LEI.md +1 -1
  109. package/docs/types/type-aliases/LegalPersonFieldName.md +1 -1
  110. package/docs/types/type-aliases/LegalPersonFields.md +3 -3
  111. package/docs/types/type-aliases/NationalIdentifierTypeFieldOptions.md +21 -0
  112. package/docs/types/type-aliases/NaturalPersonFieldName.md +1 -1
  113. package/docs/types/type-aliases/NaturalPersonFields.md +3 -3
  114. package/docs/types/type-aliases/NotabeneAsset.md +1 -1
  115. package/docs/types/type-aliases/Ready.md +1 -1
  116. package/docs/types/type-aliases/ResizeRequest.md +1 -1
  117. package/docs/types/type-aliases/Source.md +1 -1
  118. package/docs/types/type-aliases/Theme.md +1 -1
  119. package/docs/types/type-aliases/TransactionAsset.md +1 -1
  120. package/docs/types/type-aliases/TravelAddress.md +1 -1
  121. package/docs/types/type-aliases/URI.md +1 -1
  122. package/docs/types/type-aliases/UUID.md +1 -1
  123. package/docs/types/type-aliases/UpdateValue.md +1 -1
  124. package/docs/types/type-aliases/V1Asset.md +1 -1
  125. package/docs/types/type-aliases/V1Transaction.md +1 -1
  126. package/docs/types/type-aliases/VASPOptions.md +1 -1
  127. package/docs/types/type-aliases/ValidationError.md +1 -1
  128. package/package.json +1 -1
  129. package/src/notabene.ts +7 -0
  130. package/src/types.ts +35 -7
  131. package/src/utils/__tests__/connections.test.ts +284 -0
  132. package/src/utils/__tests__/encryption.test.ts +79 -0
  133. package/src/utils/connections.ts +174 -0
  134. package/src/utils/encryption.ts +111 -0
@@ -1,11 +1,11 @@
1
- var c = Object.defineProperty;
2
- var m = (e, t, r) => t in e ? c(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var o = (e, t, r) => m(e, typeof t != "symbol" ? t + "" : t, r);
4
- var u = /* @__PURE__ */ ((e) => (e.PRIVATE = "WALLET", e.VASP = "VASP", e))(u || {}), E = /* @__PURE__ */ ((e) => (e.NATURAL = "natural", e.LEGAL = "legal", e.SELF = "self", e))(E || {}), p = /* @__PURE__ */ ((e) => (e.EMPTY = "empty", e.VERIFY = "verify", e.PENDING = "pending", e.VERIFIED = "verified", e.BANNED = "banned", e))(p || {}), f = /* @__PURE__ */ ((e) => (e.ALLOWED = "allowed", e.PENDING = "pending", e))(f || {}), v = /* @__PURE__ */ ((e) => (e.ASSET = "asset", e.DESTINATION = "destination", e.COUNTERPARTY = "counterparty", e.AGENT = "agent", e))(v || {}), h = /* @__PURE__ */ ((e) => (e.COMPLETE = "complete", e.RESIZE = "resize", e.RESULT = "result", e.READY = "ready", e.INVALID = "invalid", e.ERROR = "error", e.CANCEL = "cancel", e))(h || {}), I = /* @__PURE__ */ ((e) => (e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.WALLET_CONNECTION_FAILED = "WALLET_CONNECTION_FAILED", e.WALLET_NOT_SUPPORTED = "WALLET_NOT_SUPPORTED", e.TOKEN_INVALID = "TOKEN_INVALID", e))(I || {}), d = /* @__PURE__ */ ((e) => (e.UPDATE = "update", e.REQUEST_RESPONSE = "requestResponse", e))(d || {}), L = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.FAILED = "rejected", e.FLAGGED = "flagged", e.VERIFIED = "verified", e))(L || {}), g = /* @__PURE__ */ ((e) => (e.SelfDeclaration = "self-declaration", e.SIWE = "siwe", e.SIWX = "siwx", e.EIP191 = "eip-191", e.EIP712 = "eip-712", e.EIP1271 = "eip-1271", e.BIP137 = "bip-137", e.BIP322 = "bip-322", e.BIP137_XPUB = "xpub", e.TIP191 = "tip-191", e.ED25519 = "ed25519", e.XRP_ED25519 = "xrp-ed25519", e.CIP8 = "cip-8", e.MicroTransfer = "microtransfer", e.Screenshot = "screenshot", e.Connect = "connect", e))(g || {});
5
- class A {
1
+ var w = Object.defineProperty;
2
+ var v = (t, e, n) => e in t ? w(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var a = (t, e, n) => v(t, typeof e != "symbol" ? e + "" : e, n);
4
+ var A = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(A || {}), g = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(g || {}), y = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(y || {}), I = /* @__PURE__ */ ((t) => (t.ALLOWED = "allowed", t.PENDING = "pending", t))(I || {}), C = /* @__PURE__ */ ((t) => (t.ASSET = "asset", t.DESTINATION = "destination", t.COUNTERPARTY = "counterparty", t.AGENT = "agent", t))(C || {}), l = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.ERROR = "error", t.CANCEL = "cancel", t))(l || {}), L = /* @__PURE__ */ ((t) => (t.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", t.WALLET_CONNECTION_FAILED = "WALLET_CONNECTION_FAILED", t.WALLET_NOT_SUPPORTED = "WALLET_NOT_SUPPORTED", t.TOKEN_INVALID = "TOKEN_INVALID", t))(L || {}), u = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(u || {}), b = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(b || {}), N = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.SIWE = "siwe", t.SIWX = "siwx", t.EIP191 = "eip-191", t.EIP712 = "eip-712", t.EIP1271 = "eip-1271", t.BIP137 = "bip-137", t.BIP322 = "bip-322", t.BIP137_XPUB = "xpub", t.TIP191 = "tip-191", t.ED25519 = "ed25519", t.XRP_ED25519 = "xrp-ed25519", t.CIP8 = "cip-8", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t.Connect = "connect", t))(N || {});
5
+ class U {
6
6
  constructor() {
7
- o(this, "listeners", /* @__PURE__ */ new Map());
8
- o(this, "port");
7
+ a(this, "listeners", /* @__PURE__ */ new Map());
8
+ a(this, "port");
9
9
  this.handleMessage = this.handleMessage.bind(this);
10
10
  }
11
11
  /**
@@ -16,8 +16,8 @@ class A {
16
16
  *
17
17
  * @param port - The MessagePort instance to use for communication
18
18
  */
19
- setPort(t) {
20
- this.port = t, this.port.onmessage = this.handleMessage, this.port.start();
19
+ setPort(e) {
20
+ this.port = e, this.port.onmessage = this.handleMessage, this.port.start();
21
21
  }
22
22
  /**
23
23
  * Registers a callback for a specific message type.
@@ -29,8 +29,8 @@ class A {
29
29
  * @param callback - The callback function to execute when matching messages are received
30
30
 
31
31
  */
32
- on(t, r) {
33
- return this.listeners.has(t) || this.listeners.set(t, /* @__PURE__ */ new Set()), this.listeners.get(t).add(r), () => this.off(t, r);
32
+ on(e, n) {
33
+ return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(n), () => this.off(e, n);
34
34
  }
35
35
  /**
36
36
  * Removes a callback for a specific message type.
@@ -41,9 +41,9 @@ class A {
41
41
  * @param messageType - The type of message to remove listener from
42
42
  * @param callback - The callback function to remove
43
43
  */
44
- off(t, r) {
45
- const s = this.listeners.get(t);
46
- s && (s.delete(r), s.size === 0 && this.listeners.delete(t));
44
+ off(e, n) {
45
+ const r = this.listeners.get(e);
46
+ r && (r.delete(n), r.size === 0 && this.listeners.delete(e));
47
47
  }
48
48
  /**
49
49
  * Internal message handler for processing received messages.
@@ -53,39 +53,39 @@ class A {
53
53
  *
54
54
  * @param event - The message event containing the component message
55
55
  */
56
- handleMessage(t) {
57
- const r = t.data;
58
- if (typeof r == "object" && r !== null && "type" in r) {
59
- const s = r.type, i = this.listeners.get(s);
60
- i && i.forEach((n) => n(r));
56
+ handleMessage(e) {
57
+ const n = e.data;
58
+ if (typeof n == "object" && n !== null && "type" in n) {
59
+ const r = n.type, i = this.listeners.get(r);
60
+ i && i.forEach((s) => s(n));
61
61
  }
62
62
  }
63
63
  /**
64
64
  * Sends a message through the message port
65
65
  * @param message The host message to send
66
66
  */
67
- send(t) {
68
- this.port && this.port.postMessage(t);
67
+ send(e) {
68
+ this.port && this.port.postMessage(e);
69
69
  }
70
70
  }
71
- class N {
71
+ class _ {
72
72
  /**
73
73
  * Creates an instance of EmbeddedComponent.
74
74
  * @param url - The URL of the embedded component
75
75
  * @param value - The initial transaction value
76
76
  */
77
- constructor(t, r, s) {
78
- o(this, "_url");
79
- o(this, "_value");
80
- o(this, "_options");
81
- o(this, "_errors", []);
82
- o(this, "iframe");
83
- o(this, "eventManager");
84
- o(this, "modal");
85
- this._url = t, this._value = r, this._options = s, this.eventManager = new A(), this.on(h.INVALID, (i) => {
86
- i.type === h.INVALID && (this._errors = i.errors, this._value = i.value);
87
- }), this.on(h.RESIZE, (i) => {
88
- i.type === h.RESIZE && this.iframe && (this.iframe.style.height = `${i.height}px`);
77
+ constructor(e, n, r) {
78
+ a(this, "_url");
79
+ a(this, "_value");
80
+ a(this, "_options");
81
+ a(this, "_errors", []);
82
+ a(this, "iframe");
83
+ a(this, "eventManager");
84
+ a(this, "modal");
85
+ this._url = e, this._value = n, this._options = r, this.eventManager = new U(), this.on(l.INVALID, (i) => {
86
+ i.type === l.INVALID && (this._errors = i.errors, this._value = i.value);
87
+ }), this.on(l.RESIZE, (i) => {
88
+ i.type === l.RESIZE && this.iframe && (this.iframe.style.height = `${i.height}px`);
89
89
  });
90
90
  }
91
91
  /**
@@ -119,21 +119,21 @@ class N {
119
119
  * @param parentId - The ID of the parent element
120
120
  * @throws Will throw an error if the parent element is not found
121
121
  */
122
- mount(t) {
123
- const r = document.querySelector(t);
124
- if (!r) throw new Error(`parentID ${t} not found`);
125
- this.embed(r);
122
+ mount(e) {
123
+ const n = document.querySelector(e);
124
+ if (!n) throw new Error(`parentID ${e} not found`);
125
+ this.embed(n);
126
126
  }
127
127
  /**
128
128
  * Embeds the component into a parent element
129
129
  * @param parent - The parent element to embed the component into
130
130
  */
131
- embed(t, r = !1) {
132
- var s, i;
133
- this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (r ? "" : "&embedded=true"), this.iframe.allow = "web-share; clipboard-write; hid; bluetooth;", this.iframe.style.width = "100%", this.iframe.style.height = "0px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", this.iframe.scrolling = "no", t.appendChild(this.iframe), window.addEventListener("message", (n) => {
134
- var a, l;
135
- n.source === ((a = this.iframe) == null ? void 0 : a.contentWindow) && ((l = this.eventManager) == null || l.setPort(n.ports[0]));
136
- }), (i = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || i.focus();
131
+ embed(e, n = !1) {
132
+ var r, i;
133
+ this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (n ? "" : "&embedded=true"), this.iframe.allow = "web-share; clipboard-write; hid; bluetooth;", this.iframe.style.width = "100%", this.iframe.style.height = "0px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", this.iframe.scrolling = "no", e.appendChild(this.iframe), window.addEventListener("message", (s) => {
134
+ var o, c;
135
+ s.source === ((o = this.iframe) == null ? void 0 : o.contentWindow) && ((c = this.eventManager) == null || c.setPort(s.ports[0]));
136
+ }), (i = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || i.focus();
137
137
  }
138
138
  removeEmbed() {
139
139
  this.iframe && this.iframe.remove();
@@ -142,48 +142,48 @@ class N {
142
142
  * Sends a message to the embedded component
143
143
  * @param message - The message to send
144
144
  */
145
- send(t) {
146
- this.eventManager.send(t);
145
+ send(e) {
146
+ this.eventManager.send(e);
147
147
  }
148
148
  /**
149
149
  * Adds an event listener for a specific message type
150
150
  * @param messageType - The type of message to listen for
151
151
  * @param callback - The callback function to execute when the message is received
152
152
  */
153
- on(t, r) {
154
- return this.eventManager.on(t, r);
153
+ on(e, n) {
154
+ return this.eventManager.on(e, n);
155
155
  }
156
156
  /**
157
157
  * Removes an event listener for a specific message type
158
158
  * @param messageType - The type of message to stop listening for
159
159
  * @param callback - The callback function to remove
160
160
  */
161
- off(t, r) {
162
- this.eventManager.off(t, r);
161
+ off(e, n) {
162
+ this.eventManager.off(e, n);
163
163
  }
164
164
  /**
165
165
  * Updates the transaction value and sends an update message to the component
166
166
  * @param value - The new transaction value
167
167
  */
168
- update(t, r) {
169
- this._value = t, r && (this._options = r), this.send({ type: d.UPDATE, value: t, options: this._options });
168
+ update(e, n) {
169
+ this._value = e, n && (this._options = n), this.send({ type: u.UPDATE, value: e, options: this._options });
170
170
  }
171
171
  /**
172
172
  * Waits for the component to complete and returns the transaction response
173
173
  * @returns A promise that resolves with the transaction response
174
174
  */
175
175
  completion() {
176
- return new Promise((t, r) => {
177
- let s, i, n;
178
- function a() {
179
- s && s(), i && i(), n && n();
176
+ return new Promise((e, n) => {
177
+ let r, i, s;
178
+ function o() {
179
+ r && r(), i && i(), s && s();
180
180
  }
181
- s = this.on(h.COMPLETE, (l) => {
182
- t(l.response), a();
183
- }), i = this.on(h.CANCEL, () => {
184
- r(new Error("User cancelled")), a();
185
- }), n = this.on("error", (l) => {
186
- r(new Error(l.message)), a();
181
+ r = this.on(l.COMPLETE, (c) => {
182
+ e(c.response), o();
183
+ }), i = this.on(l.CANCEL, () => {
184
+ n(new Error("User cancelled")), o();
185
+ }), s = this.on("error", (c) => {
186
+ n(new Error(c.message)), o();
187
187
  });
188
188
  });
189
189
  }
@@ -192,15 +192,15 @@ class N {
192
192
  */
193
193
  async openModal() {
194
194
  this.modal && this.closeModal(), this.modal = document.createElement("dialog"), this.modal.style.border = "none", this.modal.style.backgroundColor = "white", this.modal.style.maxWidth = "100vw", this.modal.style.maxHeight = "100vh", this.modal.style.width = "600px", this.modal.style.height = "600px", document.body.appendChild(this.modal), this.embed(this.modal, !0);
195
- const t = this.on(h.CANCEL, () => {
195
+ const e = this.on(l.CANCEL, () => {
196
196
  this.closeModal();
197
- }), r = this.on(h.COMPLETE, () => {
197
+ }), n = this.on(l.COMPLETE, () => {
198
198
  this.closeModal();
199
199
  });
200
200
  return this.modal.showModal(), this.modal.addEventListener("click", () => {
201
201
  this.closeModal();
202
202
  }), this.completion().finally(() => {
203
- t(), r();
203
+ e(), n();
204
204
  });
205
205
  }
206
206
  /**
@@ -208,8 +208,8 @@ class N {
208
208
  *
209
209
  */
210
210
  closeModal() {
211
- var t;
212
- this.modal && ((t = this.modal) == null || t.close(), this.modal.remove(), this.modal = void 0);
211
+ var e;
212
+ this.modal && ((e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
213
213
  }
214
214
  /**
215
215
  * Opens the component in a popup window. This may be needed to support many self-hosted wallets
@@ -218,58 +218,202 @@ class N {
218
218
  * @see [Cross-Origin-Opener-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy)
219
219
  */
220
220
  async popup() {
221
- const t = window.open(
221
+ const e = window.open(
222
222
  this.url,
223
223
  "_blank",
224
224
  "popup=true,width=600,height=600"
225
225
  );
226
226
  window.addEventListener("message", (i) => {
227
- var n;
228
- i.source === t && (console.log("received message from popup", i.data), (n = this.eventManager) == null || n.setPort(i.ports[0]));
227
+ var s;
228
+ i.source === e && (console.log("received message from popup", i.data), (s = this.eventManager) == null || s.setPort(i.ports[0]));
229
229
  });
230
- const r = this.on(h.CANCEL, () => {
231
- t == null || t.close();
232
- }), s = this.on(h.COMPLETE, () => {
233
- t == null || t.close();
230
+ const n = this.on(l.CANCEL, () => {
231
+ e == null || e.close();
232
+ }), r = this.on(l.COMPLETE, () => {
233
+ e == null || e.close();
234
234
  });
235
235
  return this.completion().finally(() => {
236
- r(), s();
236
+ n(), r();
237
237
  });
238
238
  }
239
239
  }
240
- function w(e) {
241
- return Object.entries(e).map(([t, r]) => {
242
- if (r == null) return;
243
- const s = encodeURIComponent(t), i = encodeURIComponent(
244
- typeof r == "object" ? JSON.stringify(r) : String(r)
240
+ function R(t) {
241
+ return Object.entries(t).map(([e, n]) => {
242
+ if (n == null) return;
243
+ const r = encodeURIComponent(e), i = encodeURIComponent(
244
+ typeof n == "object" ? JSON.stringify(n) : String(n)
245
245
  // Use String() to handle all primitive types
246
246
  );
247
- return `${s}=${i}`;
248
- }).filter((t) => t !== void 0).join("&");
247
+ return `${r}=${i}`;
248
+ }).filter((e) => e !== void 0).join("&");
249
249
  }
250
- function C(e) {
251
- const t = e.slice(1);
252
- return t ? t.split("&").filter(Boolean).reduce(
253
- (s, i) => {
254
- const [n, a] = i.split("=");
255
- return n && (s[decodeURIComponent(n)] = a ? decodeURIComponent(a) : ""), s;
250
+ function O(t) {
251
+ const e = t.slice(1);
252
+ return e ? e.split("&").filter(Boolean).reduce(
253
+ (r, i) => {
254
+ const [s, o] = i.split("=");
255
+ return s && (r[decodeURIComponent(s)] = o ? decodeURIComponent(o) : ""), r;
256
256
  },
257
257
  {}
258
258
  ) : {};
259
259
  }
260
- class U {
260
+ async function d(t) {
261
+ const e = JSON.stringify(t), n = new TextEncoder(), r = crypto.getRandomValues(new Uint8Array(32)), i = await crypto.subtle.importKey(
262
+ "raw",
263
+ r,
264
+ { name: "AES-GCM" },
265
+ !1,
266
+ ["encrypt"]
267
+ ), s = crypto.getRandomValues(new Uint8Array(12)), o = await crypto.subtle.encrypt(
268
+ { name: "AES-GCM", iv: s },
269
+ i,
270
+ n.encode(e)
271
+ );
272
+ return {
273
+ ciphertext: `${h(s)}-${h(o)}`,
274
+ key: h(r)
275
+ };
276
+ }
277
+ async function x({ ciphertext: t, key: e }) {
278
+ const [n, r] = t.split("-"), i = new Uint8Array(
279
+ atob(e).split("").map((f) => f.charCodeAt(0))
280
+ ), s = m(n), o = m(r), c = await crypto.subtle.importKey(
281
+ "raw",
282
+ i,
283
+ { name: "AES-GCM" },
284
+ !1,
285
+ ["decrypt"]
286
+ ), p = new TextDecoder(), E = await crypto.subtle.decrypt(
287
+ { name: "AES-GCM", iv: new Uint8Array(s) },
288
+ c,
289
+ o
290
+ );
291
+ return JSON.parse(p.decode(E));
292
+ }
293
+ function h(t) {
294
+ const e = new Uint8Array(t);
295
+ let n = "";
296
+ for (let r = 0; r < e.length; r++)
297
+ n += String.fromCharCode(e[r]);
298
+ return btoa(n);
299
+ }
300
+ function m(t) {
301
+ const e = atob(t), n = new Uint8Array(e.length);
302
+ for (let r = 0; r < e.length; r++)
303
+ n[r] = e.charCodeAt(r);
304
+ return n;
305
+ }
306
+ class M {
307
+ constructor(e) {
308
+ a(this, "endpoint");
309
+ this.endpoint = e;
310
+ }
311
+ /**
312
+ * Creates a new encrypted connection
313
+ * @param data The component request data to encrypt and store
314
+ * @param participants Array of participant identifiers
315
+ * @returns Promise resolving to connection details including ID, version, and encryption key
316
+ */
317
+ async create(e, n) {
318
+ const r = await d(e), i = {
319
+ metadata: n,
320
+ sealed: r.ciphertext
321
+ }, s = await fetch(this.endpoint, {
322
+ method: "POST",
323
+ headers: {
324
+ "Content-Type": "application/json"
325
+ },
326
+ body: JSON.stringify(i)
327
+ });
328
+ if (!s.ok)
329
+ throw new Error(`Failed to create connection: ${await s.text()}`);
330
+ const o = await s.json();
331
+ return {
332
+ id: o.id,
333
+ version: o.version,
334
+ metadata: n,
335
+ data: e,
336
+ key: r.key
337
+ };
338
+ }
339
+ /**
340
+ * Updates an existing connection with new encrypted data
341
+ * @param id Connection ID
342
+ * @param data New data to encrypt and store
343
+ * @param version Current version number
344
+ * @returns Promise resolving to updated connection details including new encryption key
345
+ */
346
+ async update(e, n, r) {
347
+ const i = await d(n), s = {
348
+ sealed: i.ciphertext,
349
+ version: r
350
+ }, o = await fetch(`${this.endpoint}/${e}`, {
351
+ method: "PATCH",
352
+ headers: {
353
+ "Content-Type": "application/json"
354
+ },
355
+ body: JSON.stringify(s)
356
+ });
357
+ if (!o.ok)
358
+ throw new Error(`Failed to update connection: ${await o.text()}`);
359
+ const c = await o.json();
360
+ return {
361
+ id: c.id,
362
+ metadata: c.metadata,
363
+ version: c.version,
364
+ data: n,
365
+ key: i.key
366
+ };
367
+ }
368
+ /**
369
+ * Retrieves and decrypts connection data
370
+ * @param id Connection ID
371
+ * @param key Encryption key from previous create/update operation
372
+ * @returns Promise resolving to connection details including decrypted data
373
+ */
374
+ async get(e, n) {
375
+ const r = await fetch(`${this.endpoint}/${e}`, {
376
+ method: "GET"
377
+ });
378
+ if (!r.ok)
379
+ throw new Error(`Failed to get connection: ${await r.text()}`);
380
+ const i = await r.json(), s = i.sealed[i.sealed.length - 1], o = await x({
381
+ ciphertext: s,
382
+ key: n
383
+ });
384
+ return {
385
+ id: i.id,
386
+ version: i.version,
387
+ metadata: i.metadata,
388
+ data: o,
389
+ key: n
390
+ };
391
+ }
392
+ /**
393
+ * Closes a connection
394
+ * @param id Connection ID
395
+ */
396
+ async close(e) {
397
+ const n = await fetch(`${this.endpoint}/${e}`, {
398
+ method: "DELETE"
399
+ });
400
+ if (!n.ok)
401
+ throw new Error(`Failed to close connection: ${await n.text()}`);
402
+ }
403
+ }
404
+ class S {
261
405
  /**
262
406
  * Creates a new instance of the Notabene SDK
263
407
  *
264
408
  * @param config - Configuration options for the Notabene SDK
265
409
  */
266
- constructor(t) {
267
- o(this, "nodeUrl");
268
- o(this, "authToken");
269
- o(this, "uxUrl");
270
- o(this, "theme");
271
- o(this, "locale");
272
- this.uxUrl = t.uxUrl || "https://connect.notabene.id", this.nodeUrl = t.nodeUrl, this.authToken = t.authToken, this.theme = t.theme, this.locale = t.locale;
410
+ constructor(e) {
411
+ a(this, "nodeUrl");
412
+ a(this, "authToken");
413
+ a(this, "uxUrl");
414
+ a(this, "theme");
415
+ a(this, "locale");
416
+ this.uxUrl = e.uxUrl || "https://connect.notabene.id", this.nodeUrl = e.nodeUrl, this.authToken = e.authToken, this.theme = e.theme, this.locale = e.locale;
273
417
  }
274
418
  /**
275
419
  * Generates a URL for a Notabene component
@@ -281,15 +425,15 @@ class U {
281
425
  * @returns component URL
282
426
  * @internal
283
427
  */
284
- componentUrl(t, r, s, i) {
285
- const n = new URL(this.uxUrl);
286
- n.pathname = t;
287
- const a = w({
428
+ componentUrl(e, n, r, i) {
429
+ const s = new URL(this.uxUrl);
430
+ s.pathname = e;
431
+ const o = R({
288
432
  authToken: this.authToken,
289
- value: r,
290
- configuration: s
433
+ value: n,
434
+ configuration: r
291
435
  });
292
- return n.hash = a, this.nodeUrl && n.searchParams.set("nodeUrl", this.nodeUrl), this.theme && n.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && n.searchParams.set("locale", this.locale), i && (i.callback && n.searchParams.set("callback_url", i.callback), i.redirectUri && n.searchParams.set("redirect_uri", i.redirectUri)), n.toString();
436
+ return s.hash = o, this.nodeUrl && s.searchParams.set("nodeUrl", this.nodeUrl), this.theme && s.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && s.searchParams.set("locale", this.locale), i && (i.callback && s.searchParams.set("callback_url", i.callback), i.redirectUri && s.searchParams.set("redirect_uri", i.redirectUri)), s.toString();
293
437
  }
294
438
  /**
295
439
  * Creates a new embedded component
@@ -301,11 +445,11 @@ class U {
301
445
  * @returns A new EmbeddedComponent instance
302
446
  * @internal
303
447
  */
304
- createComponent(t, r, s, i) {
305
- return new N(
306
- this.componentUrl(t, r, s, i),
307
- r,
308
- s
448
+ createComponent(e, n, r, i) {
449
+ return new _(
450
+ this.componentUrl(e, n, r, i),
451
+ n,
452
+ r
309
453
  );
310
454
  }
311
455
  /**
@@ -316,12 +460,12 @@ class U {
316
460
  * @param callbacks - Optional callback configuration
317
461
  * @returns A new EmbeddedComponent instance for withdrawal assistance
318
462
  */
319
- createWithdrawalAssist(t, r, s) {
463
+ createWithdrawalAssist(e, n, r) {
320
464
  return this.createComponent(
321
465
  "withdrawal-assist",
322
- t,
323
- r,
324
- s
466
+ e,
467
+ n,
468
+ r
325
469
  );
326
470
  }
327
471
  /**
@@ -333,12 +477,12 @@ class U {
333
477
  * @returns A new EmbeddedComponent instance for connection
334
478
  * @alpha
335
479
  */
336
- createConnectWallet(t, r, s) {
480
+ createConnectWallet(e, n, r) {
337
481
  return this.createComponent(
338
482
  "connect",
339
- t,
340
- r,
341
- s
483
+ e,
484
+ n,
485
+ r
342
486
  );
343
487
  }
344
488
  /**
@@ -350,12 +494,12 @@ class U {
350
494
  * @returns A new EmbeddedComponent instance for deposit requests
351
495
  * @public
352
496
  */
353
- createDepositRequest(t, r, s) {
497
+ createDepositRequest(e, n, r) {
354
498
  return this.createComponent(
355
499
  "deposit-request",
356
- t,
357
- r,
358
- s
500
+ e,
501
+ n,
502
+ r
359
503
  );
360
504
  }
361
505
  /**
@@ -367,27 +511,28 @@ class U {
367
511
  * @returns A new EmbeddedComponent instance for deposit assistance
368
512
  * @public
369
513
  */
370
- createDepositAssist(t, r, s) {
514
+ createDepositAssist(e, n, r) {
371
515
  return this.createComponent(
372
516
  "deposit-assist",
373
- t,
374
- r,
375
- s
517
+ e,
518
+ n,
519
+ r
376
520
  );
377
521
  }
378
522
  }
379
523
  export {
380
- u as AgentType,
381
- h as CMType,
382
- N as EmbeddedComponent,
383
- I as ErrorIdentifierCode,
384
- d as HMType,
385
- E as PersonType,
386
- L as ProofStatus,
387
- g as ProofTypes,
388
- p as Status,
389
- f as VASPSearchControl,
390
- v as ValidationSections,
391
- C as decodeFragmentToObject,
392
- U as default
524
+ A as AgentType,
525
+ l as CMType,
526
+ M as ConnectionManager,
527
+ _ as EmbeddedComponent,
528
+ L as ErrorIdentifierCode,
529
+ u as HMType,
530
+ g as PersonType,
531
+ b as ProofStatus,
532
+ N as ProofTypes,
533
+ y as Status,
534
+ I as VASPSearchControl,
535
+ C as ValidationSections,
536
+ O as decodeFragmentToObject,
537
+ S as default
393
538
  };
@@ -10,7 +10,7 @@
10
10
  "author": "Notabene <developers@notabene.id>",
11
11
  "license": "MIT",
12
12
  "packageManager": "yarn@4.5.1",
13
- "version": "2.8.0-next.4",
13
+ "version": "2.8.0-next.6",
14
14
  "source": "src/notabene.ts",
15
15
  "main": "dist/cjs/notabene.cjs",
16
16
  "module": "dist/esm/notabene.js",