@notabene/javascript-sdk 2.0.0-next.13 → 2.0.0-next.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,10 +48,24 @@ There are two options for loading the Notabene SDK:
48
48
 
49
49
  Or installing the library:
50
50
 
51
+ Using Yarn:
52
+
51
53
  ```bash
52
54
  yarn add @notabene/javascript-sdk
53
55
  ```
54
56
 
57
+ Using NPM:
58
+
59
+ ```bash
60
+ npm install @notabene/javascript-sdk
61
+ ```
62
+
63
+ If you installed the library into your project, you can import it into your project:
64
+
65
+ ```js
66
+ import Notabene from '@notabene/javascript-sdk';
67
+ ```
68
+
55
69
  ## Usage
56
70
 
57
71
  ### Authentication
@@ -65,7 +79,6 @@ Use the [customer token endpoint](https://devx.notabene.id/docs/customertoken) w
65
79
  Create a new Notabene instance:
66
80
 
67
81
  ```js
68
-
69
82
  const notabene = new Notabene({
70
83
  nodeUrl: 'https://api.notabene.id',
71
84
  authToken: '{CUSTOMER_TOKEN}',
@@ -254,6 +267,12 @@ All components can be configured using an optional [TransactionOptions](./docs/i
254
267
  The following shows the full set of options in typescript:
255
268
 
256
269
  ```ts
270
+ import {
271
+ AgentType,
272
+ PersonType,
273
+ ProofTypes,
274
+ } from '@notabene/javascript-sdk/src/types';
275
+
257
276
  const options: TransactionOptions = {
258
277
  proofs: {
259
278
  microTransfer: {
@@ -261,13 +280,13 @@ const options: TransactionOptions = {
261
280
  amountSubunits: '12344',
262
281
  timeout: 86440,
263
282
  },
264
- fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration],
283
+ fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self_declaration']
265
284
  },
266
- allowedAgentTypes: [AgentType.PRIVATE, AgentType.VASP],
285
+ allowedAgentTypes: [AgentType.PRIVATE, AgentType.VASP], // js ['WALLET','VASP']
267
286
  allowedCounterpartyTypes: [
268
- PersonType.LEGAL,
269
- PersonType.NATURAL,
270
- PersonType.SELF,
287
+ PersonType.LEGAL, // JS: 'legal'
288
+ PersonType.NATURAL, // JS: 'natural'
289
+ PersonType.SELF, // JS: 'self'
271
290
  ],
272
291
  fields: {
273
292
  naturalPerson: {
@@ -291,6 +310,10 @@ const options: TransactionOptions = {
291
310
  nationalIdentification: false,
292
311
  countryOfRegistration: true,
293
312
  },
313
+ vasps: {
314
+ addUnknown: true, // Allow users to add a missing VASP - Defaults to false
315
+ onlyActive: true // Only list active VASPs - Default false
316
+ }
294
317
  },
295
318
  };
296
319
  const withdrawal = notabene.createWithdrawalAssist(tx, options);
@@ -303,7 +326,7 @@ const withdrawal = notabene.createWithdrawalAssist(tx, options);
303
326
  ```ts
304
327
  const firstParty: TransactionOptions = {
305
328
  allowedCounterpartyTypes: [
306
- PersonType.SELF,
329
+ PersonType.SELF, // JS: 'self'
307
330
  ],
308
331
  };
309
332
  ```
@@ -312,7 +335,7 @@ const firstParty: TransactionOptions = {
312
335
 
313
336
  ```ts
314
337
  const vasp2vasp: TransactionOptions = {
315
- allowedAgentTypes: [AgentType.VASP],
338
+ allowedAgentTypes: [AgentType.VASP], // js ['VASP']
316
339
  };
317
340
  ```
318
341
 
@@ -320,7 +343,7 @@ const vasp2vasp: TransactionOptions = {
320
343
 
321
344
  ```ts
322
345
  const options: TransactionOptions = {
323
- allowedAgentTypes: [AgentType.PRIVATE],
346
+ allowedAgentTypes: [AgentType.PRIVATE], // js ['WALLET']
324
347
  };
325
348
  ```
326
349
 
@@ -343,7 +366,7 @@ const options: TransactionOptions = {
343
366
  amountSubunits: '1234',
344
367
  timeout: 86440, // Optional timeout in seconds, which is displayed to the user
345
368
  },
346
- fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration],
369
+ fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self_declaration']
347
370
  }
348
371
  }
349
372
  ```
@@ -371,7 +394,7 @@ You may accept a few options if none of the other are available. We do not recom
371
394
  ```ts
372
395
  const options: TransactionOptions = {
373
396
  proofs: {
374
- fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration],
397
+ fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self_declaration']
375
398
  }
376
399
  }
377
400
  ```
package/dist/notabene.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var c=(o,e,t)=>e in o?d(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var n=(o,e,t)=>c(o,typeof e!="symbol"?e+"":e,t);var a=(o=>(o.COMPLETE="complete",o.RESIZE="resize",o.RESULT="result",o.READY="ready",o.INVALID="invalid",o.MODAL="openModal",o.ERROR="error",o.CLOSE="closeModal",o.CANCEL="cancel",o))(a||{}),l=(o=>(o.UPDATE="update",o.REQUEST_RESPONSE="requestResponse",o))(l||{});class m{constructor(){n(this,"listeners",new Map);n(this,"port");this.handleMessage=this.handleMessage.bind(this)}setPort(e){this.port=e,this.port.onmessage=this.handleMessage,this.port.start()}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){const s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e))}handleMessage(e){console.log("received message",e.data);const t=e.data;if(typeof t=="object"&&t!==null&&"type"in t){const s=t.type,r=this.listeners.get(s);r&&r.forEach(i=>i(t))}}send(e){this.port&&this.port.postMessage(e)}}class u{constructor(e,t){n(this,"_url");n(this,"_value");n(this,"_errors",[]);n(this,"iframe");n(this,"eventManager");n(this,"modal");this._url=e,this._value=t,this.eventManager=new m,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 errors(){return this._errors}open(){document.location.href=this.url}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`parentID ${e} not found`);this.embed(t)}embed(e){var t,s;this.iframe=document.createElement("iframe"),this.iframe.src=this.url,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",e.appendChild(this.iframe),window.addEventListener("message",r=>{var i,h;r.source===((i=this.iframe)==null?void 0:i.contentWindow)&&(console.log("received message from iframe",r.data),(h=this.eventManager)==null||h.setPort(r.ports[0]))}),(s=(t=this.iframe)==null?void 0:t.contentWindow)==null||s.focus()}send(e){this.eventManager.send(e)}on(e,t){this.eventManager.on(e,t)}off(e,t){this.eventManager.off(e,t)}update(e){this._value=e,this.send({type:l.UPDATE,value:e})}completion(){return new Promise((e,t)=>{this.on(a.COMPLETE,s=>{e(s.response)}),this.on("error",s=>{t(new Error(s.message))})})}openModal(){return this.modal&&this.closeModal(),this.modal=document.createElement("dialog"),this.modal.style.border="none",this.modal.style.backgroundColor="transparent",this.modal.style.maxWidth="100vw",this.modal.style.maxHeight="100vh",this.modal.style.width="600px",this.modal.style.height="800px",document.body.appendChild(this.modal),this.embed(this.modal),this.on(a.CANCEL,()=>{this.closeModal()}),this.on(a.CLOSE,()=>{this.closeModal()}),this.on(a.COMPLETE,()=>{this.closeModal()}),this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion()}closeModal(){var e;this.modal&&(console.log("closeModal"),(e=this.modal)==null||e.close(),this.modal.remove(),this.modal=void 0)}}function f(o){return Object.entries(o).map(([e,t])=>{if(!(e&&t))return;const s=encodeURIComponent(e),r=encodeURIComponent(typeof t=="object"?JSON.stringify(t):t);return`${s}=${r}`}).filter(e=>!!e).join("&")}class p{constructor(e){n(this,"nodeUrl");n(this,"authToken");n(this,"uxUrl");n(this,"theme");n(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,t,s,r){const i=new URL(this.uxUrl);i.pathname=e;const h=f({authToken:this.authToken,value:t,configuration:s});return i.hash=h,this.nodeUrl&&i.searchParams.set("nodeUrl",this.nodeUrl),this.theme&&i.searchParams.set("theme",JSON.stringify(this.theme)),this.locale&&i.searchParams.set("locale",this.locale),r&&(r.callback&&i.searchParams.set("callback_url",r.callback),r.redirectUri&&i.searchParams.set("redirect_uri",r.redirectUri)),i.toString()}createComponent(e,t,s,r){return new u(this.componentUrl(e,t,s,r),t)}createWithdrawalAssist(e,t,s){return this.createComponent("withdrawal-assist",e,t,s)}createDepositAssist(e,t,s){return this.createComponent("deposit-assist",e,t,s)}createConnectWallet(e,t,s){return this.createComponent("connect",e,t,s)}createDepositRequest(e,t,s){return this.createComponent("deposit-request",e,t,s)}decodeFragmentToObject(e){return e.slice(1).split("&").reduce((s,r)=>{const[i,h]=r.split("=");return s[decodeURIComponent(i)]=decodeURIComponent(h),s},{})}}module.exports=p;
1
+ "use strict";var p=Object.defineProperty;var E=(t,e,s)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>E(t,typeof e!="symbol"?e+"":e,s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var h=(t=>(t.PRIVATE="WALLET",t.VASP="VASP",t))(h||{}),d=(t=>(t.NATURAL="natural",t.LEGAL="legal",t.SELF="self",t))(d||{}),c=(t=>(t.EMPTY="empty",t.VERIFY="verify",t.PENDING="pending",t.VERIFIED="verified",t.BANNED="banned",t))(c||{}),a=(t=>(t.COMPLETE="complete",t.RESIZE="resize",t.RESULT="result",t.READY="ready",t.INVALID="invalid",t.MODAL="openModal",t.ERROR="error",t.CLOSE="closeModal",t.CANCEL="cancel",t))(a||{}),m=(t=>(t.UPDATE="update",t.REQUEST_RESPONSE="requestResponse",t))(m||{}),u=(t=>(t.PENDING="pending",t.FAILED="rejected",t.FLAGGED="flagged",t.VERIFIED="verified",t))(u||{}),f=(t=>(t.SelfDeclaration="self-declaration",t.PersonalSignEIP191="eip-191",t.PersonalSignEIP712="eip-712",t.PersonalSignBIP137="bip-137",t.PersonalSignXPUB="xpub",t.MicroTransfer="microtransfer",t.Screenshot="screenshot",t))(f||{});class g{constructor(){o(this,"listeners",new Map);o(this,"port");this.handleMessage=this.handleMessage.bind(this)}setPort(e){this.port=e,this.port.onmessage=this.handleMessage,this.port.start()}on(e,s){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(s)}off(e,s){const r=this.listeners.get(e);r&&(r.delete(s),r.size===0&&this.listeners.delete(e))}handleMessage(e){console.log("received message",e.data);const s=e.data;if(typeof s=="object"&&s!==null&&"type"in s){const r=s.type,i=this.listeners.get(r);i&&i.forEach(n=>n(s))}}send(e){this.port&&this.port.postMessage(e)}}class v{constructor(e,s){o(this,"_url");o(this,"_value");o(this,"_errors",[]);o(this,"iframe");o(this,"eventManager");o(this,"modal");this._url=e,this._value=s,this.eventManager=new g,this.on(a.INVALID,r=>{r.type===a.INVALID&&(this._errors=r.errors,this._value=r.value)}),this.on(a.RESIZE,r=>{r.type===a.RESIZE&&this.iframe&&(this.iframe.style.height=`${r.height}px`)})}get url(){return this._url}get value(){return this._value}get errors(){return this._errors}open(){document.location.href=this.url}mount(e){const s=document.querySelector(e);if(!s)throw new Error(`parentID ${e} not found`);this.embed(s)}embed(e){var s,r;this.iframe=document.createElement("iframe"),this.iframe.src=this.url,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",e.appendChild(this.iframe),window.addEventListener("message",i=>{var n,l;i.source===((n=this.iframe)==null?void 0:n.contentWindow)&&(console.log("received message from iframe",i.data),(l=this.eventManager)==null||l.setPort(i.ports[0]))}),(r=(s=this.iframe)==null?void 0:s.contentWindow)==null||r.focus()}send(e){this.eventManager.send(e)}on(e,s){this.eventManager.on(e,s)}off(e,s){this.eventManager.off(e,s)}update(e){this._value=e,this.send({type:m.UPDATE,value:e})}completion(){return new Promise((e,s)=>{this.on(a.COMPLETE,r=>{e(r.response)}),this.on("error",r=>{s(new Error(r.message))})})}openModal(){return this.modal&&this.closeModal(),this.modal=document.createElement("dialog"),this.modal.style.border="none",this.modal.style.backgroundColor="transparent",this.modal.style.maxWidth="100vw",this.modal.style.maxHeight="100vh",this.modal.style.width="600px",this.modal.style.height="800px",document.body.appendChild(this.modal),this.embed(this.modal),this.on(a.CANCEL,()=>{this.closeModal()}),this.on(a.CLOSE,()=>{this.closeModal()}),this.on(a.COMPLETE,()=>{this.closeModal()}),this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion()}closeModal(){var e;this.modal&&(console.log("closeModal"),(e=this.modal)==null||e.close(),this.modal.remove(),this.modal=void 0)}}function I(t){return Object.entries(t).map(([e,s])=>{if(!(e&&s))return;const r=encodeURIComponent(e),i=encodeURIComponent(typeof s=="object"?JSON.stringify(s):s);return`${r}=${i}`}).filter(e=>!!e).join("&")}class M{constructor(e){o(this,"nodeUrl");o(this,"authToken");o(this,"uxUrl");o(this,"theme");o(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,s,r,i){const n=new URL(this.uxUrl);n.pathname=e;const l=I({authToken:this.authToken,value:s,configuration:r});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),i&&(i.callback&&n.searchParams.set("callback_url",i.callback),i.redirectUri&&n.searchParams.set("redirect_uri",i.redirectUri)),n.toString()}createComponent(e,s,r,i){return new v(this.componentUrl(e,s,r,i),s)}createWithdrawalAssist(e,s,r){return this.createComponent("withdrawal-assist",e,s,r)}createDepositAssist(e,s,r){return this.createComponent("deposit-assist",e,s,r)}createConnectWallet(e,s,r){return this.createComponent("connect",e,s,r)}createDepositRequest(e,s,r){return this.createComponent("deposit-request",e,s,r)}decodeFragmentToObject(e){return e.slice(1).split("&").reduce((r,i)=>{const[n,l]=i.split("=");return r[decodeURIComponent(n)]=decodeURIComponent(l),r},{})}}exports.AgentType=h;exports.CMType=a;exports.PersonType=d;exports.ProofStatus=u;exports.ProofTypes=f;exports.Status=c;exports.default=M;
package/dist/notabene.js CHANGED
@@ -1,29 +1,29 @@
1
1
  var d = Object.defineProperty;
2
- var c = (o, e, t) => e in o ? d(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var n = (o, e, t) => c(o, typeof e != "symbol" ? e + "" : e, t);
4
- var a = /* @__PURE__ */ ((o) => (o.COMPLETE = "complete", o.RESIZE = "resize", o.RESULT = "result", o.READY = "ready", o.INVALID = "invalid", o.MODAL = "openModal", o.ERROR = "error", o.CLOSE = "closeModal", o.CANCEL = "cancel", o))(a || {}), l = /* @__PURE__ */ ((o) => (o.UPDATE = "update", o.REQUEST_RESPONSE = "requestResponse", o))(l || {});
5
- class m {
2
+ var c = (t, e, s) => e in t ? d(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var o = (t, e, s) => c(t, typeof e != "symbol" ? e + "" : e, s);
4
+ var m = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(m || {}), u = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(u || {}), E = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(E || {}), a = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.MODAL = "openModal", t.ERROR = "error", t.CLOSE = "closeModal", t.CANCEL = "cancel", t))(a || {}), h = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(h || {}), f = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(f || {}), p = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.PersonalSignEIP191 = "eip-191", t.PersonalSignEIP712 = "eip-712", t.PersonalSignBIP137 = "bip-137", t.PersonalSignXPUB = "xpub", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t))(p || {});
5
+ class g {
6
6
  constructor() {
7
- n(this, "listeners", /* @__PURE__ */ new Map());
8
- n(this, "port");
7
+ o(this, "listeners", /* @__PURE__ */ new Map());
8
+ o(this, "port");
9
9
  this.handleMessage = this.handleMessage.bind(this);
10
10
  }
11
11
  setPort(e) {
12
12
  this.port = e, this.port.onmessage = this.handleMessage, this.port.start();
13
13
  }
14
- on(e, t) {
15
- this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t);
14
+ on(e, s) {
15
+ this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(s);
16
16
  }
17
- off(e, t) {
18
- const s = this.listeners.get(e);
19
- s && (s.delete(t), s.size === 0 && this.listeners.delete(e));
17
+ off(e, s) {
18
+ const r = this.listeners.get(e);
19
+ r && (r.delete(s), r.size === 0 && this.listeners.delete(e));
20
20
  }
21
21
  handleMessage(e) {
22
22
  console.log("received message", e.data);
23
- const t = e.data;
24
- if (typeof t == "object" && t !== null && "type" in t) {
25
- const s = t.type, r = this.listeners.get(s);
26
- r && r.forEach((i) => i(t));
23
+ const s = e.data;
24
+ if (typeof s == "object" && s !== null && "type" in s) {
25
+ const r = s.type, i = this.listeners.get(r);
26
+ i && i.forEach((n) => n(s));
27
27
  }
28
28
  }
29
29
  // Method to send messages through the port
@@ -31,23 +31,23 @@ class m {
31
31
  this.port && this.port.postMessage(e);
32
32
  }
33
33
  }
34
- class u {
34
+ class v {
35
35
  /**
36
36
  * Creates an instance of EmbeddedComponent.
37
37
  * @param url - The URL of the embedded component
38
38
  * @param value - The initial transaction value
39
39
  */
40
- constructor(e, t) {
41
- n(this, "_url");
42
- n(this, "_value");
43
- n(this, "_errors", []);
44
- n(this, "iframe");
45
- n(this, "eventManager");
46
- n(this, "modal");
47
- this._url = e, this._value = t, this.eventManager = new m(), this.on(a.INVALID, (s) => {
48
- s.type === a.INVALID && (this._errors = s.errors, this._value = s.value);
49
- }), this.on(a.RESIZE, (s) => {
50
- s.type === a.RESIZE && this.iframe && (this.iframe.style.height = `${s.height}px`);
40
+ constructor(e, s) {
41
+ o(this, "_url");
42
+ o(this, "_value");
43
+ o(this, "_errors", []);
44
+ o(this, "iframe");
45
+ o(this, "eventManager");
46
+ o(this, "modal");
47
+ this._url = e, this._value = s, this.eventManager = new g(), this.on(a.INVALID, (r) => {
48
+ r.type === a.INVALID && (this._errors = r.errors, this._value = r.value);
49
+ }), this.on(a.RESIZE, (r) => {
50
+ r.type === a.RESIZE && this.iframe && (this.iframe.style.height = `${r.height}px`);
51
51
  });
52
52
  }
53
53
  /**
@@ -79,20 +79,20 @@ class u {
79
79
  * @throws Will throw an error if the parent element is not found
80
80
  */
81
81
  mount(e) {
82
- const t = document.querySelector(e);
83
- if (!t) throw new Error(`parentID ${e} not found`);
84
- this.embed(t);
82
+ const s = document.querySelector(e);
83
+ if (!s) throw new Error(`parentID ${e} not found`);
84
+ this.embed(s);
85
85
  }
86
86
  /**
87
87
  * Embeds the component into a parent element
88
88
  * @param parent - The parent element to embed the component into
89
89
  */
90
90
  embed(e) {
91
- var t, s;
92
- this.iframe = document.createElement("iframe"), this.iframe.src = this.url, 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", e.appendChild(this.iframe), window.addEventListener("message", (r) => {
93
- var i, h;
94
- r.source === ((i = this.iframe) == null ? void 0 : i.contentWindow) && (console.log("received message from iframe", r.data), (h = this.eventManager) == null || h.setPort(r.ports[0]));
95
- }), (s = (t = this.iframe) == null ? void 0 : t.contentWindow) == null || s.focus();
91
+ var s, r;
92
+ this.iframe = document.createElement("iframe"), this.iframe.src = this.url, 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", e.appendChild(this.iframe), window.addEventListener("message", (i) => {
93
+ var n, l;
94
+ i.source === ((n = this.iframe) == null ? void 0 : n.contentWindow) && (console.log("received message from iframe", i.data), (l = this.eventManager) == null || l.setPort(i.ports[0]));
95
+ }), (r = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || r.focus();
96
96
  }
97
97
  /**
98
98
  * Sends a message to the embedded component
@@ -106,34 +106,34 @@ class u {
106
106
  * @param messageType - The type of message to listen for
107
107
  * @param callback - The callback function to execute when the message is received
108
108
  */
109
- on(e, t) {
110
- this.eventManager.on(e, t);
109
+ on(e, s) {
110
+ this.eventManager.on(e, s);
111
111
  }
112
112
  /**
113
113
  * Removes an event listener for a specific message type
114
114
  * @param messageType - The type of message to stop listening for
115
115
  * @param callback - The callback function to remove
116
116
  */
117
- off(e, t) {
118
- this.eventManager.off(e, t);
117
+ off(e, s) {
118
+ this.eventManager.off(e, s);
119
119
  }
120
120
  /**
121
121
  * Updates the transaction value and sends an update message to the component
122
122
  * @param value - The new transaction value
123
123
  */
124
124
  update(e) {
125
- this._value = e, this.send({ type: l.UPDATE, value: e });
125
+ this._value = e, this.send({ type: h.UPDATE, value: e });
126
126
  }
127
127
  /**
128
128
  * Waits for the component to complete and returns the transaction response
129
129
  * @returns A promise that resolves with the transaction response
130
130
  */
131
131
  completion() {
132
- return new Promise((e, t) => {
133
- this.on(a.COMPLETE, (s) => {
134
- e(s.response);
135
- }), this.on("error", (s) => {
136
- t(new Error(s.message));
132
+ return new Promise((e, s) => {
133
+ this.on(a.COMPLETE, (r) => {
134
+ e(r.response);
135
+ }), this.on("error", (r) => {
136
+ s(new Error(r.message));
137
137
  });
138
138
  });
139
139
  }
@@ -160,27 +160,27 @@ class u {
160
160
  this.modal && (console.log("closeModal"), (e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
161
161
  }
162
162
  }
163
- function f(o) {
164
- return Object.entries(o).map(([e, t]) => {
165
- if (!(e && t)) return;
166
- const s = encodeURIComponent(e), r = encodeURIComponent(
167
- typeof t == "object" ? JSON.stringify(t) : t
163
+ function I(t) {
164
+ return Object.entries(t).map(([e, s]) => {
165
+ if (!(e && s)) return;
166
+ const r = encodeURIComponent(e), i = encodeURIComponent(
167
+ typeof s == "object" ? JSON.stringify(s) : s
168
168
  );
169
- return `${s}=${r}`;
169
+ return `${r}=${i}`;
170
170
  }).filter((e) => !!e).join("&");
171
171
  }
172
- class E {
172
+ class w {
173
173
  /**
174
174
  * Creates a new instance of the Notabene SDK
175
175
  *
176
176
  * @param config - Configuration options for the Notabene SDK
177
177
  */
178
178
  constructor(e) {
179
- n(this, "nodeUrl");
180
- n(this, "authToken");
181
- n(this, "uxUrl");
182
- n(this, "theme");
183
- n(this, "locale");
179
+ o(this, "nodeUrl");
180
+ o(this, "authToken");
181
+ o(this, "uxUrl");
182
+ o(this, "theme");
183
+ o(this, "locale");
184
184
  this.uxUrl = e.uxUrl || "https://connect.notabene.id", this.nodeUrl = e.nodeUrl, this.authToken = e.authToken, this.theme = e.theme, this.locale = e.locale;
185
185
  }
186
186
  /**
@@ -193,15 +193,15 @@ class E {
193
193
  * @returns component URL
194
194
  * @internal
195
195
  */
196
- componentUrl(e, t, s, r) {
197
- const i = new URL(this.uxUrl);
198
- i.pathname = e;
199
- const h = f({
196
+ componentUrl(e, s, r, i) {
197
+ const n = new URL(this.uxUrl);
198
+ n.pathname = e;
199
+ const l = I({
200
200
  authToken: this.authToken,
201
- value: t,
202
- configuration: s
201
+ value: s,
202
+ configuration: r
203
203
  });
204
- return i.hash = h, this.nodeUrl && i.searchParams.set("nodeUrl", this.nodeUrl), this.theme && i.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && i.searchParams.set("locale", this.locale), r && (r.callback && i.searchParams.set("callback_url", r.callback), r.redirectUri && i.searchParams.set("redirect_uri", r.redirectUri)), i.toString();
204
+ 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), i && (i.callback && n.searchParams.set("callback_url", i.callback), i.redirectUri && n.searchParams.set("redirect_uri", i.redirectUri)), n.toString();
205
205
  }
206
206
  /**
207
207
  * Creates a new embedded component
@@ -213,10 +213,10 @@ class E {
213
213
  * @returns A new EmbeddedComponent instance
214
214
  * @internal
215
215
  */
216
- createComponent(e, t, s, r) {
217
- return new u(
218
- this.componentUrl(e, t, s, r),
219
- t
216
+ createComponent(e, s, r, i) {
217
+ return new v(
218
+ this.componentUrl(e, s, r, i),
219
+ s
220
220
  );
221
221
  }
222
222
  /**
@@ -227,8 +227,8 @@ class E {
227
227
  * @param callbacks - Optional callback configuration
228
228
  * @returns A new EmbeddedComponent instance for withdrawal assistance
229
229
  */
230
- createWithdrawalAssist(e, t, s) {
231
- return this.createComponent("withdrawal-assist", e, t, s);
230
+ createWithdrawalAssist(e, s, r) {
231
+ return this.createComponent("withdrawal-assist", e, s, r);
232
232
  }
233
233
  /**
234
234
  * Creates a deposit assist component
@@ -239,12 +239,12 @@ class E {
239
239
  * @returns A new EmbeddedComponent instance for deposit assistance
240
240
  * @alpha
241
241
  */
242
- createDepositAssist(e, t, s) {
242
+ createDepositAssist(e, s, r) {
243
243
  return this.createComponent(
244
244
  "deposit-assist",
245
245
  e,
246
- t,
247
- s
246
+ s,
247
+ r
248
248
  );
249
249
  }
250
250
  /**
@@ -255,12 +255,12 @@ class E {
255
255
  * @param callbacks - Optional callback configuration
256
256
  * @returns A new EmbeddedComponent instance for connection
257
257
  */
258
- createConnectWallet(e, t, s) {
258
+ createConnectWallet(e, s, r) {
259
259
  return this.createComponent(
260
260
  "connect",
261
261
  e,
262
- t,
263
- s
262
+ s,
263
+ r
264
264
  );
265
265
  }
266
266
  /**
@@ -272,8 +272,8 @@ class E {
272
272
  * @returns A new EmbeddedComponent instance for deposit requests
273
273
  * @alpha
274
274
  */
275
- createDepositRequest(e, t, s) {
276
- return this.createComponent("deposit-request", e, t, s);
275
+ createDepositRequest(e, s, r) {
276
+ return this.createComponent("deposit-request", e, s, r);
277
277
  }
278
278
  /**
279
279
  * Decodes a URL fragment into an object
@@ -283,14 +283,20 @@ class E {
283
283
  */
284
284
  decodeFragmentToObject(e) {
285
285
  return e.slice(1).split("&").reduce(
286
- (s, r) => {
287
- const [i, h] = r.split("=");
288
- return s[decodeURIComponent(i)] = decodeURIComponent(h), s;
286
+ (r, i) => {
287
+ const [n, l] = i.split("=");
288
+ return r[decodeURIComponent(n)] = decodeURIComponent(l), r;
289
289
  },
290
290
  {}
291
291
  );
292
292
  }
293
293
  }
294
294
  export {
295
- E as default
295
+ m as AgentType,
296
+ a as CMType,
297
+ u as PersonType,
298
+ f as ProofStatus,
299
+ p as ProofTypes,
300
+ E as Status,
301
+ w as default
296
302
  };
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "author": "Notabene <developers@notabene.id>",
11
11
  "license": "MIT",
12
- "version": "2.0.0-next.13",
12
+ "version": "2.0.0-next.14",
13
13
  "source": "src/notabene.ts",
14
14
  "main": "dist/notabene.js",
15
15
  "types": "dist/notabene.d.ts",
package/src/notabene.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import EmbeddedComponent from './components/EmbeddedComponent';
2
2
  import type {
3
3
  Agent,
4
- AgentType,
5
4
  CallbackOptions,
6
5
  ComponentMessage,
7
6
  ConnectionRequest,
@@ -15,25 +14,28 @@ import type {
15
14
  IVMS101,
16
15
  MicroTransferProof,
17
16
  OwnershipProof,
18
- PersonType,
19
- ProofStatus,
20
- ProofTypes,
21
17
  ScreenshotProof,
22
18
  SignatureProof,
23
- Status,
24
19
  Theme,
25
20
  Transaction,
26
21
  TransactionAsset,
27
22
  TransactionOptions,
23
+ TransactionResponse,
28
24
  VASP,
29
25
  Wallet,
30
26
  Withdrawal,
31
27
  } from './types';
32
- import { CMType, TransactionResponse } from './types';
28
+ import {
29
+ AgentType,
30
+ CMType,
31
+ PersonType,
32
+ ProofStatus,
33
+ ProofTypes,
34
+ Status,
35
+ } from './types';
33
36
  import { encodeObjectToFragment } from './utils/urls';
34
37
 
35
38
  export type {
36
- CMType,
37
39
  ComponentMessage,
38
40
  EmbeddedComponent,
39
41
  ConnectionRequest,
@@ -53,19 +55,15 @@ export type {
53
55
  MicroTransferProof,
54
56
  DeclarationProof,
55
57
  Notabene,
56
- ProofStatus,
57
- ProofTypes,
58
58
  IVMS101,
59
- PersonType,
60
- Status,
61
59
  VASP,
62
60
  Wallet,
63
61
  Agent,
64
- AgentType,
65
62
  OwnershipProof,
66
63
  TransactionOptions,
67
64
  CallbackOptions,
68
65
  };
66
+ export { CMType, ProofStatus, ProofTypes, PersonType, Status, AgentType };
69
67
 
70
68
  /**
71
69
  * Configuration for the Notabene SDK