@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
package/README.md CHANGED
@@ -638,6 +638,36 @@ const options: TransactionOptions = {
638
638
  };
639
639
  ```
640
640
 
641
+ ### Configuring National Identifier Type
642
+
643
+ The National Identifier Type is a dropdown that allows the developer configure the types of national identifiers they are supporting.
644
+
645
+ ```ts
646
+ const options: TransactionOptions = {
647
+ fields: {
648
+ naturalPerson: {
649
+ name: {optional: false},
650
+ nationalIdentification: {
651
+ optional: true, // allow optional national identification
652
+ nationalIdentifierType: {
653
+ values: ['ARNU', 'CCPT', 'RAID', 'DRLC', 'TXID', 'SOCS'], // default values
654
+ },
655
+ },
656
+ },
657
+ legalPerson: {
658
+ name: true,
659
+ lei: {optional: true},
660
+ nationalIdentification: {
661
+ optional: false, // require national identification
662
+ nationalIdentifierType: {
663
+ values: ['RAID', 'TXID', 'MISC'], // default values
664
+ },
665
+ },
666
+ },
667
+ },
668
+ };
669
+ ```
670
+
641
671
  ### Configuring ownership proofs
642
672
 
643
673
  By default components support message signing proofs.
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var A=(e,t,r)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var o=(e,t,r)=>A(e,typeof t!="symbol"?t+"":t,r);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var c=(e=>(e.PRIVATE="WALLET",e.VASP="VASP",e))(c||{}),m=(e=>(e.NATURAL="natural",e.LEGAL="legal",e.SELF="self",e))(m||{}),u=(e=>(e.EMPTY="empty",e.VERIFY="verify",e.PENDING="pending",e.VERIFIED="verified",e.BANNED="banned",e))(u||{}),E=(e=>(e.ALLOWED="allowed",e.PENDING="pending",e))(E||{}),p=(e=>(e.ASSET="asset",e.DESTINATION="destination",e.COUNTERPARTY="counterparty",e.AGENT="agent",e))(p||{}),a=(e=>(e.COMPLETE="complete",e.RESIZE="resize",e.RESULT="result",e.READY="ready",e.INVALID="invalid",e.ERROR="error",e.CANCEL="cancel",e))(a||{}),f=(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))(f||{}),d=(e=>(e.UPDATE="update",e.REQUEST_RESPONSE="requestResponse",e))(d||{}),v=(e=>(e.PENDING="pending",e.FAILED="rejected",e.FLAGGED="flagged",e.VERIFIED="verified",e))(v||{}),I=(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))(I||{});class N{constructor(){o(this,"listeners",new Map);o(this,"port");this.handleMessage=this.handleMessage.bind(this)}setPort(t){this.port=t,this.port.onmessage=this.handleMessage,this.port.start()}on(t,r){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(r),()=>this.off(t,r)}off(t,r){const i=this.listeners.get(t);i&&(i.delete(r),i.size===0&&this.listeners.delete(t))}handleMessage(t){const r=t.data;if(typeof r=="object"&&r!==null&&"type"in r){const i=r.type,s=this.listeners.get(i);s&&s.forEach(n=>n(r))}}send(t){this.port&&this.port.postMessage(t)}}class g{constructor(t,r,i){o(this,"_url");o(this,"_value");o(this,"_options");o(this,"_errors",[]);o(this,"iframe");o(this,"eventManager");o(this,"modal");this._url=t,this._value=r,this._options=i,this.eventManager=new N,this.on(a.INVALID,s=>{s.type===a.INVALID&&(this._errors=s.errors,this._value=s.value)}),this.on(a.RESIZE,s=>{s.type===a.RESIZE&&this.iframe&&(this.iframe.style.height=`${s.height}px`)})}get url(){return this._url}get value(){return this._value}get options(){return this._options}get errors(){return this._errors}open(){document.location.href=this.url}mount(t){const r=document.querySelector(t);if(!r)throw new Error(`parentID ${t} not found`);this.embed(r)}embed(t,r=!1){var i,s;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=>{var l,h;n.source===((l=this.iframe)==null?void 0:l.contentWindow)&&((h=this.eventManager)==null||h.setPort(n.ports[0]))}),(s=(i=this.iframe)==null?void 0:i.contentWindow)==null||s.focus()}removeEmbed(){this.iframe&&this.iframe.remove()}send(t){this.eventManager.send(t)}on(t,r){return this.eventManager.on(t,r)}off(t,r){this.eventManager.off(t,r)}update(t,r){this._value=t,r&&(this._options=r),this.send({type:d.UPDATE,value:t,options:this._options})}completion(){return new Promise((t,r)=>{let i,s,n;function l(){i&&i(),s&&s(),n&&n()}i=this.on(a.COMPLETE,h=>{t(h.response),l()}),s=this.on(a.CANCEL,()=>{r(new Error("User cancelled")),l()}),n=this.on("error",h=>{r(new Error(h.message)),l()})})}async openModal(){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);const t=this.on(a.CANCEL,()=>{this.closeModal()}),r=this.on(a.COMPLETE,()=>{this.closeModal()});return this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion().finally(()=>{t(),r()})}closeModal(){var t;this.modal&&((t=this.modal)==null||t.close(),this.modal.remove(),this.modal=void 0)}async popup(){const t=window.open(this.url,"_blank","popup=true,width=600,height=600");window.addEventListener("message",s=>{var n;s.source===t&&(console.log("received message from popup",s.data),(n=this.eventManager)==null||n.setPort(s.ports[0]))});const r=this.on(a.CANCEL,()=>{t==null||t.close()}),i=this.on(a.COMPLETE,()=>{t==null||t.close()});return this.completion().finally(()=>{r(),i()})}}function _(e){return Object.entries(e).map(([t,r])=>{if(r==null)return;const i=encodeURIComponent(t),s=encodeURIComponent(typeof r=="object"?JSON.stringify(r):String(r));return`${i}=${s}`}).filter(t=>t!==void 0).join("&")}function w(e){const t=e.slice(1);return t?t.split("&").filter(Boolean).reduce((i,s)=>{const[n,l]=s.split("=");return n&&(i[decodeURIComponent(n)]=l?decodeURIComponent(l):""),i},{}):{}}class C{constructor(t){o(this,"nodeUrl");o(this,"authToken");o(this,"uxUrl");o(this,"theme");o(this,"locale");this.uxUrl=t.uxUrl||"https://connect.notabene.id",this.nodeUrl=t.nodeUrl,this.authToken=t.authToken,this.theme=t.theme,this.locale=t.locale}componentUrl(t,r,i,s){const n=new URL(this.uxUrl);n.pathname=t;const l=_({authToken:this.authToken,value:r,configuration:i});return n.hash=l,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),s&&(s.callback&&n.searchParams.set("callback_url",s.callback),s.redirectUri&&n.searchParams.set("redirect_uri",s.redirectUri)),n.toString()}createComponent(t,r,i,s){return new g(this.componentUrl(t,r,i,s),r,i)}createWithdrawalAssist(t,r,i){return this.createComponent("withdrawal-assist",t,r,i)}createConnectWallet(t,r,i){return this.createComponent("connect",t,r,i)}createDepositRequest(t,r,i){return this.createComponent("deposit-request",t,r,i)}createDepositAssist(t,r,i){return this.createComponent("deposit-assist",t,r,i)}}exports.AgentType=c;exports.CMType=a;exports.EmbeddedComponent=g;exports.ErrorIdentifierCode=f;exports.HMType=d;exports.PersonType=m;exports.ProofStatus=v;exports.ProofTypes=I;exports.Status=u;exports.VASPSearchControl=E;exports.ValidationSections=p;exports.decodeFragmentToObject=w;exports.default=C;
1
+ "use strict";var N=Object.defineProperty;var U=(t,e,n)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var a=(t,e,n)=>U(t,typeof e!="symbol"?e+"":e,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var p=(t=>(t.PRIVATE="WALLET",t.VASP="VASP",t))(p||{}),E=(t=>(t.NATURAL="natural",t.LEGAL="legal",t.SELF="self",t))(E||{}),f=(t=>(t.EMPTY="empty",t.VERIFY="verify",t.PENDING="pending",t.VERIFIED="verified",t.BANNED="banned",t))(f||{}),w=(t=>(t.ALLOWED="allowed",t.PENDING="pending",t))(w||{}),v=(t=>(t.ASSET="asset",t.DESTINATION="destination",t.COUNTERPARTY="counterparty",t.AGENT="agent",t))(v||{}),l=(t=>(t.COMPLETE="complete",t.RESIZE="resize",t.RESULT="result",t.READY="ready",t.INVALID="invalid",t.ERROR="error",t.CANCEL="cancel",t))(l||{}),g=(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))(g||{}),d=(t=>(t.UPDATE="update",t.REQUEST_RESPONSE="requestResponse",t))(d||{}),y=(t=>(t.PENDING="pending",t.FAILED="rejected",t.FLAGGED="flagged",t.VERIFIED="verified",t))(y||{}),A=(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))(A||{});class _{constructor(){a(this,"listeners",new Map);a(this,"port");this.handleMessage=this.handleMessage.bind(this)}setPort(e){this.port=e,this.port.onmessage=this.handleMessage,this.port.start()}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>this.off(e,n)}off(e,n){const r=this.listeners.get(e);r&&(r.delete(n),r.size===0&&this.listeners.delete(e))}handleMessage(e){const n=e.data;if(typeof n=="object"&&n!==null&&"type"in n){const r=n.type,i=this.listeners.get(r);i&&i.forEach(s=>s(n))}}send(e){this.port&&this.port.postMessage(e)}}class C{constructor(e,n,r){a(this,"_url");a(this,"_value");a(this,"_options");a(this,"_errors",[]);a(this,"iframe");a(this,"eventManager");a(this,"modal");this._url=e,this._value=n,this._options=r,this.eventManager=new _,this.on(l.INVALID,i=>{i.type===l.INVALID&&(this._errors=i.errors,this._value=i.value)}),this.on(l.RESIZE,i=>{i.type===l.RESIZE&&this.iframe&&(this.iframe.style.height=`${i.height}px`)})}get url(){return this._url}get value(){return this._value}get options(){return this._options}get errors(){return this._errors}open(){document.location.href=this.url}mount(e){const n=document.querySelector(e);if(!n)throw new Error(`parentID ${e} not found`);this.embed(n)}embed(e,n=!1){var r,i;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=>{var o,c;s.source===((o=this.iframe)==null?void 0:o.contentWindow)&&((c=this.eventManager)==null||c.setPort(s.ports[0]))}),(i=(r=this.iframe)==null?void 0:r.contentWindow)==null||i.focus()}removeEmbed(){this.iframe&&this.iframe.remove()}send(e){this.eventManager.send(e)}on(e,n){return this.eventManager.on(e,n)}off(e,n){this.eventManager.off(e,n)}update(e,n){this._value=e,n&&(this._options=n),this.send({type:d.UPDATE,value:e,options:this._options})}completion(){return new Promise((e,n)=>{let r,i,s;function o(){r&&r(),i&&i(),s&&s()}r=this.on(l.COMPLETE,c=>{e(c.response),o()}),i=this.on(l.CANCEL,()=>{n(new Error("User cancelled")),o()}),s=this.on("error",c=>{n(new Error(c.message)),o()})})}async openModal(){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);const e=this.on(l.CANCEL,()=>{this.closeModal()}),n=this.on(l.COMPLETE,()=>{this.closeModal()});return this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion().finally(()=>{e(),n()})}closeModal(){var e;this.modal&&((e=this.modal)==null||e.close(),this.modal.remove(),this.modal=void 0)}async popup(){const e=window.open(this.url,"_blank","popup=true,width=600,height=600");window.addEventListener("message",i=>{var s;i.source===e&&(console.log("received message from popup",i.data),(s=this.eventManager)==null||s.setPort(i.ports[0]))});const n=this.on(l.CANCEL,()=>{e==null||e.close()}),r=this.on(l.COMPLETE,()=>{e==null||e.close()});return this.completion().finally(()=>{n(),r()})}}function S(t){return Object.entries(t).map(([e,n])=>{if(n==null)return;const r=encodeURIComponent(e),i=encodeURIComponent(typeof n=="object"?JSON.stringify(n):String(n));return`${r}=${i}`}).filter(e=>e!==void 0).join("&")}function O(t){const e=t.slice(1);return e?e.split("&").filter(Boolean).reduce((r,i)=>{const[s,o]=i.split("=");return s&&(r[decodeURIComponent(s)]=o?decodeURIComponent(o):""),r},{}):{}}async function u(t){const e=JSON.stringify(t),n=new TextEncoder,r=crypto.getRandomValues(new Uint8Array(32)),i=await crypto.subtle.importKey("raw",r,{name:"AES-GCM"},!1,["encrypt"]),s=crypto.getRandomValues(new Uint8Array(12)),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:s},i,n.encode(e));return{ciphertext:`${h(s)}-${h(o)}`,key:h(r)}}async function M({ciphertext:t,key:e}){const[n,r]=t.split("-"),i=new Uint8Array(atob(e).split("").map(L=>L.charCodeAt(0))),s=m(n),o=m(r),c=await crypto.subtle.importKey("raw",i,{name:"AES-GCM"},!1,["decrypt"]),b=new TextDecoder,I=await crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(s)},c,o);return JSON.parse(b.decode(I))}function h(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++)n+=String.fromCharCode(e[r]);return btoa(n)}function m(t){const e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}class R{constructor(e){a(this,"endpoint");this.endpoint=e}async create(e,n){const r=await u(e),i={metadata:n,sealed:r.ciphertext},s=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok)throw new Error(`Failed to create connection: ${await s.text()}`);const o=await s.json();return{id:o.id,version:o.version,metadata:n,data:e,key:r.key}}async update(e,n,r){const i=await u(n),s={sealed:i.ciphertext,version:r},o=await fetch(`${this.endpoint}/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok)throw new Error(`Failed to update connection: ${await o.text()}`);const c=await o.json();return{id:c.id,metadata:c.metadata,version:c.version,data:n,key:i.key}}async get(e,n){const r=await fetch(`${this.endpoint}/${e}`,{method:"GET"});if(!r.ok)throw new Error(`Failed to get connection: ${await r.text()}`);const i=await r.json(),s=i.sealed[i.sealed.length-1],o=await M({ciphertext:s,key:n});return{id:i.id,version:i.version,metadata:i.metadata,data:o,key:n}}async close(e){const n=await fetch(`${this.endpoint}/${e}`,{method:"DELETE"});if(!n.ok)throw new Error(`Failed to close connection: ${await n.text()}`)}}class D{constructor(e){a(this,"nodeUrl");a(this,"authToken");a(this,"uxUrl");a(this,"theme");a(this,"locale");this.uxUrl=e.uxUrl||"https://connect.notabene.id",this.nodeUrl=e.nodeUrl,this.authToken=e.authToken,this.theme=e.theme,this.locale=e.locale}componentUrl(e,n,r,i){const s=new URL(this.uxUrl);s.pathname=e;const o=S({authToken:this.authToken,value:n,configuration:r});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()}createComponent(e,n,r,i){return new C(this.componentUrl(e,n,r,i),n,r)}createWithdrawalAssist(e,n,r){return this.createComponent("withdrawal-assist",e,n,r)}createConnectWallet(e,n,r){return this.createComponent("connect",e,n,r)}createDepositRequest(e,n,r){return this.createComponent("deposit-request",e,n,r)}createDepositAssist(e,n,r){return this.createComponent("deposit-assist",e,n,r)}}exports.AgentType=p;exports.CMType=l;exports.ConnectionManager=R;exports.EmbeddedComponent=C;exports.ErrorIdentifierCode=g;exports.HMType=d;exports.PersonType=E;exports.ProofStatus=y;exports.ProofTypes=A;exports.Status=f;exports.VASPSearchControl=w;exports.ValidationSections=v;exports.decodeFragmentToObject=O;exports.default=D;
@@ -290,6 +290,53 @@ export declare interface ComponentResponse {
290
290
  errors: ValidationError[];
291
291
  }
292
292
 
293
+ export declare interface ConnectionData<T extends ComponentRequest> {
294
+ tx: T;
295
+ authToken?: string;
296
+ txOptions?: TransactionOptions;
297
+ }
298
+
299
+ /**
300
+ * Manages encrypted connections using Cloudflare Durable Objects
301
+ */
302
+ export declare class ConnectionManager {
303
+ private endpoint;
304
+ constructor(endpoint: string);
305
+ /**
306
+ * Creates a new encrypted connection
307
+ * @param data The component request data to encrypt and store
308
+ * @param participants Array of participant identifiers
309
+ * @returns Promise resolving to connection details including ID, version, and encryption key
310
+ */
311
+ create<T extends ComponentRequest>(data: ConnectionData<T>, metadata: ConnectionMetadata): Promise<ConnectionResponse<T>>;
312
+ /**
313
+ * Updates an existing connection with new encrypted data
314
+ * @param id Connection ID
315
+ * @param data New data to encrypt and store
316
+ * @param version Current version number
317
+ * @returns Promise resolving to updated connection details including new encryption key
318
+ */
319
+ update<T extends ComponentRequest>(id: UUID, data: ConnectionData<T>, version: number): Promise<ConnectionResponse<T>>;
320
+ /**
321
+ * Retrieves and decrypts connection data
322
+ * @param id Connection ID
323
+ * @param key Encryption key from previous create/update operation
324
+ * @returns Promise resolving to connection details including decrypted data
325
+ */
326
+ get<T extends ComponentRequest>(id: UUID, key: string): Promise<ConnectionResponse<T>>;
327
+ /**
328
+ * Closes a connection
329
+ * @param id Connection ID
330
+ */
331
+ close(id: UUID): Promise<void>;
332
+ }
333
+
334
+ export declare interface ConnectionMetadata {
335
+ nodeUrl?: string;
336
+ participants: string[];
337
+ transactionType: TransactionType;
338
+ }
339
+
293
340
  /**
294
341
  * An object representing options for a Connection Request
295
342
  * @public
@@ -304,6 +351,14 @@ export declare interface ConnectionRequest extends ComponentRequest {
304
351
  asset: TransactionAsset;
305
352
  }
306
353
 
354
+ export declare interface ConnectionResponse<T extends ComponentRequest> {
355
+ id: UUID;
356
+ version: number;
357
+ metadata: ConnectionMetadata;
358
+ data: ConnectionData<T>;
359
+ key: string;
360
+ }
361
+
307
362
  /**
308
363
  * The counterparty of a transaction.
309
364
  * @public
@@ -728,12 +783,21 @@ declare type LegalPerson_2 = {
728
783
  export declare type LegalPersonFieldName = 'name' | 'lei' | 'website' | 'email' | 'phone' | 'geographicAddress' | 'nationalIdentification' | 'countryOfRegistration';
729
784
 
730
785
  /**
731
- * Field properties by field name
786
+ * Field properties for legal person fields
732
787
  * @public
733
788
  */
734
- export declare type LegalPersonFields = {
735
- [name in LegalPersonFieldName]?: FieldOptions;
736
- };
789
+ export declare type LegalPersonFields = Partial<{
790
+ name: FieldOptions;
791
+ lei: FieldOptions;
792
+ website: FieldOptions;
793
+ email: FieldOptions;
794
+ phone: FieldOptions;
795
+ geographicAddress: FieldOptions;
796
+ nationalIdentification: FieldOptions & {
797
+ nationalIdentifierType: NationalIdentifierTypeFieldOptions;
798
+ };
799
+ countryOfRegistration: FieldOptions;
800
+ }>;
737
801
 
738
802
  /**
739
803
  * Legal Person Name
@@ -845,6 +909,14 @@ export declare type NationalIdentification = {
845
909
  */
846
910
  declare type NationalIdentifierTypeCode = 'ARNU' | 'CCPT' | 'RAID' | 'DRLC' | 'FIIN' | 'TXID' | 'SOCS' | 'IDCD' | 'LEIX' | 'MISC';
847
911
 
912
+ /**
913
+ * Field properties for national identifier type selection
914
+ * @public
915
+ */
916
+ declare type NationalIdentifierTypeFieldOptions = {
917
+ values?: NationalIdentifierTypeCode[];
918
+ };
919
+
848
920
  /**
849
921
  * Interface representing a natural person (individual) involved in a transaction
850
922
  *
@@ -899,12 +971,22 @@ declare type NaturalPerson_2 = {
899
971
  export declare type NaturalPersonFieldName = 'name' | 'website' | 'email' | 'phone' | 'geographicAddress' | 'nationalIdentification' | 'dateOfBirth' | 'placeOfBirth' | 'countryOfResidence';
900
972
 
901
973
  /**
902
- * Field properties by field name for Natural persons
974
+ * Field properties for natural person fields
903
975
  * @public
904
976
  */
905
- export declare type NaturalPersonFields = {
906
- [name in NaturalPersonFieldName]?: FieldOptions;
907
- };
977
+ export declare type NaturalPersonFields = Partial<{
978
+ name: FieldOptions;
979
+ website: FieldOptions;
980
+ email: FieldOptions;
981
+ phone: FieldOptions;
982
+ geographicAddress: FieldOptions;
983
+ nationalIdentification: FieldOptions & {
984
+ nationalIdentifierType: NationalIdentifierTypeFieldOptions;
985
+ };
986
+ dateOfBirth: FieldOptions;
987
+ placeOfBirth: FieldOptions;
988
+ countryOfResidence: FieldOptions;
989
+ }>;
908
990
 
909
991
  /**
910
992
  * Natural Person Name
@@ -1458,6 +1540,8 @@ export declare interface TransactionResponse<V> extends ComponentResponse {
1458
1540
  txUpdate?: V1Transaction;
1459
1541
  }
1460
1542
 
1543
+ export declare type TransactionType = 'withdraw' | 'deposit';
1544
+
1461
1545
  /**
1462
1546
  * Transfer Path
1463
1547
  * Represents the path of intermediary VASPs in a transfer
@@ -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",
@@ -290,6 +290,53 @@ export declare interface ComponentResponse {
290
290
  errors: ValidationError[];
291
291
  }
292
292
 
293
+ export declare interface ConnectionData<T extends ComponentRequest> {
294
+ tx: T;
295
+ authToken?: string;
296
+ txOptions?: TransactionOptions;
297
+ }
298
+
299
+ /**
300
+ * Manages encrypted connections using Cloudflare Durable Objects
301
+ */
302
+ export declare class ConnectionManager {
303
+ private endpoint;
304
+ constructor(endpoint: string);
305
+ /**
306
+ * Creates a new encrypted connection
307
+ * @param data The component request data to encrypt and store
308
+ * @param participants Array of participant identifiers
309
+ * @returns Promise resolving to connection details including ID, version, and encryption key
310
+ */
311
+ create<T extends ComponentRequest>(data: ConnectionData<T>, metadata: ConnectionMetadata): Promise<ConnectionResponse<T>>;
312
+ /**
313
+ * Updates an existing connection with new encrypted data
314
+ * @param id Connection ID
315
+ * @param data New data to encrypt and store
316
+ * @param version Current version number
317
+ * @returns Promise resolving to updated connection details including new encryption key
318
+ */
319
+ update<T extends ComponentRequest>(id: UUID, data: ConnectionData<T>, version: number): Promise<ConnectionResponse<T>>;
320
+ /**
321
+ * Retrieves and decrypts connection data
322
+ * @param id Connection ID
323
+ * @param key Encryption key from previous create/update operation
324
+ * @returns Promise resolving to connection details including decrypted data
325
+ */
326
+ get<T extends ComponentRequest>(id: UUID, key: string): Promise<ConnectionResponse<T>>;
327
+ /**
328
+ * Closes a connection
329
+ * @param id Connection ID
330
+ */
331
+ close(id: UUID): Promise<void>;
332
+ }
333
+
334
+ export declare interface ConnectionMetadata {
335
+ nodeUrl?: string;
336
+ participants: string[];
337
+ transactionType: TransactionType;
338
+ }
339
+
293
340
  /**
294
341
  * An object representing options for a Connection Request
295
342
  * @public
@@ -304,6 +351,14 @@ export declare interface ConnectionRequest extends ComponentRequest {
304
351
  asset: TransactionAsset;
305
352
  }
306
353
 
354
+ export declare interface ConnectionResponse<T extends ComponentRequest> {
355
+ id: UUID;
356
+ version: number;
357
+ metadata: ConnectionMetadata;
358
+ data: ConnectionData<T>;
359
+ key: string;
360
+ }
361
+
307
362
  /**
308
363
  * The counterparty of a transaction.
309
364
  * @public
@@ -728,12 +783,21 @@ declare type LegalPerson_2 = {
728
783
  export declare type LegalPersonFieldName = 'name' | 'lei' | 'website' | 'email' | 'phone' | 'geographicAddress' | 'nationalIdentification' | 'countryOfRegistration';
729
784
 
730
785
  /**
731
- * Field properties by field name
786
+ * Field properties for legal person fields
732
787
  * @public
733
788
  */
734
- export declare type LegalPersonFields = {
735
- [name in LegalPersonFieldName]?: FieldOptions;
736
- };
789
+ export declare type LegalPersonFields = Partial<{
790
+ name: FieldOptions;
791
+ lei: FieldOptions;
792
+ website: FieldOptions;
793
+ email: FieldOptions;
794
+ phone: FieldOptions;
795
+ geographicAddress: FieldOptions;
796
+ nationalIdentification: FieldOptions & {
797
+ nationalIdentifierType: NationalIdentifierTypeFieldOptions;
798
+ };
799
+ countryOfRegistration: FieldOptions;
800
+ }>;
737
801
 
738
802
  /**
739
803
  * Legal Person Name
@@ -845,6 +909,14 @@ export declare type NationalIdentification = {
845
909
  */
846
910
  declare type NationalIdentifierTypeCode = 'ARNU' | 'CCPT' | 'RAID' | 'DRLC' | 'FIIN' | 'TXID' | 'SOCS' | 'IDCD' | 'LEIX' | 'MISC';
847
911
 
912
+ /**
913
+ * Field properties for national identifier type selection
914
+ * @public
915
+ */
916
+ declare type NationalIdentifierTypeFieldOptions = {
917
+ values?: NationalIdentifierTypeCode[];
918
+ };
919
+
848
920
  /**
849
921
  * Interface representing a natural person (individual) involved in a transaction
850
922
  *
@@ -899,12 +971,22 @@ declare type NaturalPerson_2 = {
899
971
  export declare type NaturalPersonFieldName = 'name' | 'website' | 'email' | 'phone' | 'geographicAddress' | 'nationalIdentification' | 'dateOfBirth' | 'placeOfBirth' | 'countryOfResidence';
900
972
 
901
973
  /**
902
- * Field properties by field name for Natural persons
974
+ * Field properties for natural person fields
903
975
  * @public
904
976
  */
905
- export declare type NaturalPersonFields = {
906
- [name in NaturalPersonFieldName]?: FieldOptions;
907
- };
977
+ export declare type NaturalPersonFields = Partial<{
978
+ name: FieldOptions;
979
+ website: FieldOptions;
980
+ email: FieldOptions;
981
+ phone: FieldOptions;
982
+ geographicAddress: FieldOptions;
983
+ nationalIdentification: FieldOptions & {
984
+ nationalIdentifierType: NationalIdentifierTypeFieldOptions;
985
+ };
986
+ dateOfBirth: FieldOptions;
987
+ placeOfBirth: FieldOptions;
988
+ countryOfResidence: FieldOptions;
989
+ }>;
908
990
 
909
991
  /**
910
992
  * Natural Person Name
@@ -1458,6 +1540,8 @@ export declare interface TransactionResponse<V> extends ComponentResponse {
1458
1540
  txUpdate?: V1Transaction;
1459
1541
  }
1460
1542
 
1543
+ export declare type TransactionType = 'withdraw' | 'deposit';
1544
+
1461
1545
  /**
1462
1546
  * Transfer Path
1463
1547
  * Represents the path of intermediary VASPs in a transfer