@notabene/javascript-sdk 2.0.0 → 2.0.2

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 (117) hide show
  1. package/README.md +64 -58
  2. package/dist/notabene.cjs +1 -1
  3. package/dist/notabene.js +1 -1
  4. package/docs/README.md +656 -0
  5. package/docs/_media/LICENSE.md +21 -0
  6. package/docs/_media/TransactionOptions.md +93 -0
  7. package/docs/_media/locales.ts +48 -0
  8. package/docs/ivms/types/README.md +46 -0
  9. package/docs/ivms/types/enumerations/PayloadVersionCode.md +33 -0
  10. package/docs/ivms/types/interfaces/PayloadMetadata.md +34 -0
  11. package/docs/ivms/types/type-aliases/Address.md +114 -0
  12. package/docs/ivms/types/type-aliases/AddressTypeCode.md +16 -0
  13. package/docs/ivms/types/type-aliases/Beneficiary.md +30 -0
  14. package/docs/ivms/types/type-aliases/BeneficiaryVASP.md +24 -0
  15. package/docs/ivms/types/type-aliases/DateAndPlaceOfBirth.md +30 -0
  16. package/docs/ivms/types/type-aliases/ISOCountryCode.md +22 -0
  17. package/docs/ivms/types/type-aliases/ISODate.md +23 -0
  18. package/docs/ivms/types/type-aliases/IVMS101.md +41 -0
  19. package/docs/ivms/types/type-aliases/IntermediaryVASP.md +30 -0
  20. package/docs/ivms/types/type-aliases/LegalPerson.md +48 -0
  21. package/docs/ivms/types/type-aliases/LegalPersonName.md +36 -0
  22. package/docs/ivms/types/type-aliases/LegalPersonNameID.md +30 -0
  23. package/docs/ivms/types/type-aliases/LegalPersonNameTypeCode.md +16 -0
  24. package/docs/ivms/types/type-aliases/LocalLegalPersonNameID.md +30 -0
  25. package/docs/ivms/types/type-aliases/LocalNaturalPersonNameID.md +36 -0
  26. package/docs/ivms/types/type-aliases/NationalIdentification.md +42 -0
  27. package/docs/ivms/types/type-aliases/NationalIdentifierTypeCode.md +16 -0
  28. package/docs/ivms/types/type-aliases/NaturalPerson.md +54 -0
  29. package/docs/ivms/types/type-aliases/NaturalPersonName.md +36 -0
  30. package/docs/ivms/types/type-aliases/NaturalPersonNameID.md +36 -0
  31. package/docs/ivms/types/type-aliases/NaturalPersonNameTypeCode.md +16 -0
  32. package/docs/ivms/types/type-aliases/OriginatingVASP.md +24 -0
  33. package/docs/ivms/types/type-aliases/Originator.md +30 -0
  34. package/docs/ivms/types/type-aliases/Person.md +30 -0
  35. package/docs/ivms/types/type-aliases/TransferPath.md +24 -0
  36. package/docs/ivms/types/type-aliases/TransliterationMethodCode.md +16 -0
  37. package/docs/modules.md +11 -0
  38. package/docs/notabene/README.md +368 -0
  39. package/docs/notabene/classes/EmbeddedComponent.md +347 -0
  40. package/docs/notabene/classes/default.md +221 -0
  41. package/docs/notabene/functions/decodeFragmentToObject.md +27 -0
  42. package/docs/notabene/interfaces/NotabeneConfig.md +69 -0
  43. package/docs/notabene/type-aliases/MessageCallback.md +31 -0
  44. package/docs/types/README.md +154 -0
  45. package/docs/types/enumerations/AgentType.md +29 -0
  46. package/docs/types/enumerations/CMType.md +90 -0
  47. package/docs/types/enumerations/HMType.md +35 -0
  48. package/docs/types/enumerations/PersonType.md +55 -0
  49. package/docs/types/enumerations/ProofStatus.md +57 -0
  50. package/docs/types/enumerations/ProofTypes.md +148 -0
  51. package/docs/types/enumerations/Status.md +59 -0
  52. package/docs/types/enumerations/ValidationSections.md +59 -0
  53. package/docs/types/interfaces/Agent.md +74 -0
  54. package/docs/types/interfaces/CallbackOptions.md +29 -0
  55. package/docs/types/interfaces/ComponentRequest.md +50 -0
  56. package/docs/types/interfaces/ComponentResponse.md +71 -0
  57. package/docs/types/interfaces/ConnectionRecord.md +111 -0
  58. package/docs/types/interfaces/ConnectionRequest.md +51 -0
  59. package/docs/types/interfaces/Counterparty.md +135 -0
  60. package/docs/types/interfaces/DeclarationProof.md +89 -0
  61. package/docs/types/interfaces/Deposit.md +147 -0
  62. package/docs/types/interfaces/DepositRequest.md +111 -0
  63. package/docs/types/interfaces/DepositRequestOptions.md +19 -0
  64. package/docs/types/interfaces/LegalPerson.md +202 -0
  65. package/docs/types/interfaces/MicroTransferProof.md +119 -0
  66. package/docs/types/interfaces/NaturalPerson.md +201 -0
  67. package/docs/types/interfaces/OwnershipProof.md +77 -0
  68. package/docs/types/interfaces/ScreenshotProof.md +79 -0
  69. package/docs/types/interfaces/SignatureProof.md +115 -0
  70. package/docs/types/interfaces/ThresholdOptions.md +47 -0
  71. package/docs/types/interfaces/Transaction.md +136 -0
  72. package/docs/types/interfaces/TransactionOptions.md +93 -0
  73. package/docs/types/interfaces/TransactionResponse.md +130 -0
  74. package/docs/types/interfaces/VASP.md +127 -0
  75. package/docs/types/interfaces/Wallet.md +117 -0
  76. package/docs/types/interfaces/Withdrawal.md +147 -0
  77. package/docs/types/type-aliases/BlockchainAddress.md +36 -0
  78. package/docs/types/type-aliases/CAIP10.md +39 -0
  79. package/docs/types/type-aliases/CAIP19.md +40 -0
  80. package/docs/types/type-aliases/CAIP2.md +39 -0
  81. package/docs/types/type-aliases/CAIP220.md +15 -0
  82. package/docs/types/type-aliases/Cancel.md +23 -0
  83. package/docs/types/type-aliases/Completed.md +35 -0
  84. package/docs/types/type-aliases/ComponentMessage.md +41 -0
  85. package/docs/types/type-aliases/ConnectionOptions.md +15 -0
  86. package/docs/types/type-aliases/CryptoCredential.md +15 -0
  87. package/docs/types/type-aliases/DID.md +15 -0
  88. package/docs/types/type-aliases/DTI.md +38 -0
  89. package/docs/types/type-aliases/Destination.md +15 -0
  90. package/docs/types/type-aliases/Error.md +29 -0
  91. package/docs/types/type-aliases/FieldOptions.md +15 -0
  92. package/docs/types/type-aliases/FieldTypes.md +25 -0
  93. package/docs/types/type-aliases/HostMessage.md +37 -0
  94. package/docs/types/type-aliases/ISOCurrency.md +15 -0
  95. package/docs/types/type-aliases/InvalidValue.md +45 -0
  96. package/docs/types/type-aliases/LEI.md +15 -0
  97. package/docs/types/type-aliases/LegalPersonFieldName.md +13 -0
  98. package/docs/types/type-aliases/LegalPersonFields.md +15 -0
  99. package/docs/types/type-aliases/NaturalPersonFieldName.md +15 -0
  100. package/docs/types/type-aliases/NaturalPersonFields.md +15 -0
  101. package/docs/types/type-aliases/NotabeneAsset.md +36 -0
  102. package/docs/types/type-aliases/Ready.md +21 -0
  103. package/docs/types/type-aliases/ResizeRequest.md +27 -0
  104. package/docs/types/type-aliases/Source.md +15 -0
  105. package/docs/types/type-aliases/Theme.md +33 -0
  106. package/docs/types/type-aliases/TransactionAsset.md +15 -0
  107. package/docs/types/type-aliases/TravelAddress.md +37 -0
  108. package/docs/types/type-aliases/URI.md +15 -0
  109. package/docs/types/type-aliases/UUID.md +27 -0
  110. package/docs/types/type-aliases/UpdateValue.md +54 -0
  111. package/docs/types/type-aliases/V1Asset.md +36 -0
  112. package/docs/types/type-aliases/V1Transaction.md +49 -0
  113. package/docs/types/type-aliases/VASPOptions.md +25 -0
  114. package/docs/types/type-aliases/ValidationError.md +25 -0
  115. package/package.json +6 -4
  116. package/src/components/EmbeddedComponent.ts +2 -2
  117. package/src/locales.ts +2 -1
package/README.md CHANGED
@@ -81,14 +81,14 @@ import Notabene from '@notabene/javascript-sdk';
81
81
  // 1. Create Notabene instance
82
82
  const notabene = new Notabene({
83
83
  nodeUrl: 'https://api.notabene.id',
84
- authToken: 'YOUR_CUSTOMER_TOKEN'
84
+ authToken: 'YOUR_CUSTOMER_TOKEN',
85
85
  });
86
86
 
87
87
  // 2. Create and mount withdrawal component
88
88
  const withdrawal = notabene.createWithdrawalAssist({
89
89
  asset: 'ETH',
90
90
  destination: '0x1234...',
91
- amountDecimal: 1.0
91
+ amountDecimal: 1.0,
92
92
  });
93
93
  withdrawal.mount('#nb-withdrawal');
94
94
 
@@ -207,7 +207,6 @@ try {
207
207
  }
208
208
  ```
209
209
 
210
-
211
210
  ### Linked Component
212
211
 
213
212
  In some cases, in particular institutional or mobile apps you may prefer to link your customers to the component through an email or redirect the user to it in a mobile app.
@@ -231,7 +230,6 @@ The two parameters that should be configured are:
231
230
 
232
231
  **Note** for data privacy reasons the callback will be coming from your users web browser and not from our infrastructure, so no static IP is currently possible. Instead please check the `authToken` provided with the request.
233
232
 
234
-
235
233
  ## Components
236
234
 
237
235
  ## Assisted Withdrawal
@@ -246,7 +244,7 @@ const withdrawal = notabene.createWithdrawalAssist({
246
244
  assetPrice: {
247
245
  currency: 'USD', // ISO currency code
248
246
  price: 1700.12, // Asset price
249
- }
247
+ },
250
248
  });
251
249
  ```
252
250
 
@@ -264,23 +262,26 @@ If any of the required parameters are missing the component will just show the N
264
262
  Include configuration Options as a second optional parameter:
265
263
 
266
264
  ```js
267
- const withdrawal = notabene.createWithdrawalAssist({
268
- asset: 'ETH',
269
- destination: '0x...',
270
- amountDecimal: 1.23,
271
- assetPrice: {
272
- currency: 'USD', // ISO currency code
273
- price: 1700.12, // Asset price
274
- }
275
- }, {
276
- proofs: {
277
- microTransfer: {
278
- destination: '0x...',
279
- amountSubunits: '12344',
280
- timeout: 86440,
281
- }
282
- }
283
- });
265
+ const withdrawal = notabene.createWithdrawalAssist(
266
+ {
267
+ asset: 'ETH',
268
+ destination: '0x...',
269
+ amountDecimal: 1.23,
270
+ assetPrice: {
271
+ currency: 'USD', // ISO currency code
272
+ price: 1700.12, // Asset price
273
+ },
274
+ },
275
+ {
276
+ proofs: {
277
+ microTransfer: {
278
+ destination: '0x...',
279
+ amountSubunits: '12344',
280
+ timeout: 86440,
281
+ },
282
+ },
283
+ },
284
+ );
284
285
  ```
285
286
 
286
287
  See [Transaction Options](#transaction-options)
@@ -291,10 +292,10 @@ The Connect Wallet component helps you collect and verify the address of your us
291
292
 
292
293
  ```js
293
294
  const connect = notabene.createConnectWallet({
294
- asset: 'ETH'
295
+ asset: 'ETH',
295
296
  });
296
297
 
297
- const { proof, txCreate } = await connect.openModal()
298
+ const { proof, txCreate } = await connect.openModal();
298
299
  ```
299
300
 
300
301
  ### Parameters
@@ -306,17 +307,20 @@ const { proof, txCreate } = await connect.openModal()
306
307
  Include configuration Options as a second optional parameter:
307
308
 
308
309
  ```js
309
- const connect = notabene.createConnectWallet({
310
+ const connect = notabene.createConnectWallet(
311
+ {
310
312
  asset: 'ETH',
311
- }, {
312
- proofs: {
313
- microTransfer: {
314
- destination: '0x...',
315
- amountSubunits: '12344',
316
- timeout: 86440,
317
- }
318
- }
319
- });
313
+ },
314
+ {
315
+ proofs: {
316
+ microTransfer: {
317
+ destination: '0x...',
318
+ amountSubunits: '12344',
319
+ timeout: 86440,
320
+ },
321
+ },
322
+ },
323
+ );
320
324
  ```
321
325
 
322
326
  ## Deposit Request
@@ -329,8 +333,8 @@ const withdrawal = notabene.createDepositRequest({
329
333
  destination: '0x...',
330
334
  amountDecimal: 1.23,
331
335
  customer: {
332
- name: "John Smith"
333
- }
336
+ name: 'John Smith',
337
+ },
334
338
  });
335
339
  ```
336
340
 
@@ -389,7 +393,6 @@ assetPrice: {
389
393
  };
390
394
  ```
391
395
 
392
-
393
396
  ## Configuration
394
397
 
395
398
  ### Transaction Options
@@ -416,8 +419,8 @@ const options: TransactionOptions = {
416
419
  deminimis: {
417
420
  threshold: 1000,
418
421
  currency: 'EUR',
419
- proofTypes: [ProofTypes.SelfDeclaration]
420
- }
422
+ proofTypes: [ProofTypes.SelfDeclaration],
423
+ },
421
424
  },
422
425
  allowedAgentTypes: [AgentType.PRIVATE, AgentType.VASP], // js ['WALLET','VASP']
423
426
  allowedCounterpartyTypes: [
@@ -451,7 +454,7 @@ const options: TransactionOptions = {
451
454
  addUnknown: true, // Allow users to add a missing VASP - Defaults to false
452
455
  onlyActive: true, // Only list active VASPs - Default false
453
456
  },
454
- hide: [ValidationSections.ASSET, ValidationSections.DESTINATION] // Don't show specific sections of component
457
+ hide: [ValidationSections.ASSET, ValidationSections.DESTINATION], // Don't show specific sections of component
455
458
  },
456
459
  };
457
460
  const withdrawal = notabene.createWithdrawalAssist(tx, options);
@@ -460,19 +463,22 @@ const withdrawal = notabene.createWithdrawalAssist(tx, options);
460
463
  The options can additionally be updated dynamically with the `update()` function.
461
464
 
462
465
  ```js
463
- withdrawal.update({
464
- asset: 'ETH',
465
- destination: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
466
- amountDecimal: 1.12,
467
- }, {
468
- proofs: {
469
- microTransfer: {
470
- destination: '0x...',
471
- amountSubunits: '12344',
472
- timeout: 86440,
473
- }
474
- }
475
- });
466
+ withdrawal.update(
467
+ {
468
+ asset: 'ETH',
469
+ destination: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
470
+ amountDecimal: 1.12,
471
+ },
472
+ {
473
+ proofs: {
474
+ microTransfer: {
475
+ destination: '0x...',
476
+ amountSubunits: '12344',
477
+ timeout: 86440,
478
+ },
479
+ },
480
+ },
481
+ );
476
482
  ```
477
483
 
478
484
  ### Common use cases
@@ -623,12 +629,12 @@ const options: TransactionOptions = {
623
629
 
624
630
  #### Field reference
625
631
 
626
- | Field name | Natural | Legal | IVMS101 | description |
627
- | ------------------------ | ------- | ----- | ------- | --------------------------------------------- |
632
+ | Field name | Natural | Legal | IVMS101 | description |
633
+ | ------------------------ | ------- | ----- | ------- | --------------------------------------------- |
628
634
  | `name` | ✅ | ✅ | 🟩 | Full name |
629
- | `email` | 🟩 | 🟩 | -- | Email (for your internal purposes) |
630
- | `website` | -- | ✅ | -- | Business Website (for your internal purposes) |
631
- | `phone` | 🟩 | 🟩 | -- | Mobile Phone (for your internal purposes) |
635
+ | `email` | 🟩 | 🟩 | -- | Email (for your internal purposes) |
636
+ | `website` | -- | ✅ | -- | Business Website (for your internal purposes) |
637
+ | `phone` | 🟩 | 🟩 | -- | Mobile Phone (for your internal purposes) |
632
638
  | `geographicAddress` | 🟩 | 🟩 | 🟩 | Residencial or business address |
633
639
  | `nationalIdentification` | 🟩 | 🟩 | 🟩 | National Identification number |
634
640
  | `dateOfBirth` | 🟩 | -- | 🟩 | Date of birth |
package/dist/notabene.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var I=(e,t,r)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var o=(e,t,r)=>I(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||{}),f=(e=>(e.ASSET="asset",e.DESTINATION="destination",e.COUNTERPARTY="counterparty",e.AGENT="agent",e))(f||{}),h=(e=>(e.COMPLETE="complete",e.RESIZE="resize",e.RESULT="result",e.READY="ready",e.INVALID="invalid",e.ERROR="error",e.CANCEL="cancel",e))(h||{}),l=(e=>(e.UPDATE="update",e.REQUEST_RESPONSE="requestResponse",e))(l||{}),E=(e=>(e.PENDING="pending",e.FAILED="rejected",e.FLAGGED="flagged",e.VERIFIED="verified",e))(E||{}),p=(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.BIP137_XPUB="xpub",e.ED25519="ed25519",e.MicroTransfer="microtransfer",e.Screenshot="screenshot",e.Connect="connect",e))(p||{});class w{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 v{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 w,this.on(h.INVALID,s=>{s.type===h.INVALID&&(this._errors=s.errors,this._value=s.value)}),this.on(h.RESIZE,s=>{s.type===h.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",this.iframe.style.width="100%",this.iframe.style.height="100px",this.iframe.style.border="none",this.iframe.style.overflow="hidden",t.appendChild(this.iframe),window.addEventListener("message",n=>{var a,d;n.source===((a=this.iframe)==null?void 0:a.contentWindow)&&((d=this.eventManager)==null||d.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:l.UPDATE,value:t,options:this._options})}completion(){return new Promise((t,r)=>{let i,s;function n(){i&&i(),s&&s()}i=this.on(h.COMPLETE,a=>{t(a.response),n()}),s=this.on("error",a=>{r(new Error(a.message)),n()})})}openModal(){return 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),this.on(h.CANCEL,()=>{this.closeModal()}),this.on(h.COMPLETE,()=>{this.closeModal()}),this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion()}closeModal(){var t;this.modal&&((t=this.modal)==null||t.close(),this.modal.remove(),this.modal=void 0)}}function b(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 U(e){const t=e.slice(1);return t?t.split("&").filter(Boolean).reduce((i,s)=>{const[n,a]=s.split("=");return n&&(i[decodeURIComponent(n)]=a?decodeURIComponent(a):""),i},{}):{}}class R{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 a=b({authToken:this.authToken,value:r,configuration:i});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),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 v(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)}}exports.AgentType=c;exports.CMType=h;exports.EmbeddedComponent=v;exports.HMType=l;exports.PersonType=m;exports.ProofStatus=E;exports.ProofTypes=p;exports.Status=u;exports.ValidationSections=f;exports.decodeFragmentToObject=U;exports.default=R;
1
+ "use strict";var g=Object.defineProperty;var I=(e,t,r)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var o=(e,t,r)=>I(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||{}),f=(e=>(e.ASSET="asset",e.DESTINATION="destination",e.COUNTERPARTY="counterparty",e.AGENT="agent",e))(f||{}),h=(e=>(e.COMPLETE="complete",e.RESIZE="resize",e.RESULT="result",e.READY="ready",e.INVALID="invalid",e.ERROR="error",e.CANCEL="cancel",e))(h||{}),l=(e=>(e.UPDATE="update",e.REQUEST_RESPONSE="requestResponse",e))(l||{}),E=(e=>(e.PENDING="pending",e.FAILED="rejected",e.FLAGGED="flagged",e.VERIFIED="verified",e))(E||{}),p=(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.BIP137_XPUB="xpub",e.ED25519="ed25519",e.MicroTransfer="microtransfer",e.Screenshot="screenshot",e.Connect="connect",e))(p||{});class w{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 v{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 w,this.on(h.INVALID,s=>{s.type===h.INVALID&&(this._errors=s.errors,this._value=s.value)}),this.on(h.RESIZE,s=>{s.type===h.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",this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.overflow="hidden",this.iframe.scrolling="no",t.appendChild(this.iframe),window.addEventListener("message",n=>{var a,d;n.source===((a=this.iframe)==null?void 0:a.contentWindow)&&((d=this.eventManager)==null||d.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:l.UPDATE,value:t,options:this._options})}completion(){return new Promise((t,r)=>{let i,s;function n(){i&&i(),s&&s()}i=this.on(h.COMPLETE,a=>{t(a.response),n()}),s=this.on("error",a=>{r(new Error(a.message)),n()})})}openModal(){return 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),this.on(h.CANCEL,()=>{this.closeModal()}),this.on(h.COMPLETE,()=>{this.closeModal()}),this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion()}closeModal(){var t;this.modal&&((t=this.modal)==null||t.close(),this.modal.remove(),this.modal=void 0)}}function b(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 U(e){const t=e.slice(1);return t?t.split("&").filter(Boolean).reduce((i,s)=>{const[n,a]=s.split("=");return n&&(i[decodeURIComponent(n)]=a?decodeURIComponent(a):""),i},{}):{}}class R{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 a=b({authToken:this.authToken,value:r,configuration:i});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),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 v(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)}}exports.AgentType=c;exports.CMType=h;exports.EmbeddedComponent=v;exports.HMType=l;exports.PersonType=m;exports.ProofStatus=E;exports.ProofTypes=p;exports.Status=u;exports.ValidationSections=f;exports.decodeFragmentToObject=U;exports.default=R;
package/dist/notabene.js CHANGED
@@ -130,7 +130,7 @@ class w {
130
130
  */
131
131
  embed(t, r = !1) {
132
132
  var i, s;
133
- this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (r ? "" : "&embedded=true"), this.iframe.allow = "web-share", this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", t.appendChild(this.iframe), window.addEventListener("message", (n) => {
133
+ this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (r ? "" : "&embedded=true"), this.iframe.allow = "web-share; clipboard-write", this.iframe.style.width = "100%", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", this.iframe.scrolling = "no", t.appendChild(this.iframe), window.addEventListener("message", (n) => {
134
134
  var a, l;
135
135
  n.source === ((a = this.iframe) == null ? void 0 : a.contentWindow) && ((l = this.eventManager) == null || l.setPort(n.ports[0]));
136
136
  }), (s = (i = this.iframe) == null ? void 0 : i.contentWindow) == null || s.focus();