@notabene/javascript-sdk 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/notabene.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var I=(t,e,r)=>e in t?w(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var o=(t,e,r)=>I(t,typeof e!="symbol"?e+"":e,r);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var c=(t=>(t.PRIVATE="WALLET",t.VASP="VASP",t))(c||{}),m=(t=>(t.NATURAL="natural",t.LEGAL="legal",t.SELF="self",t))(m||{}),u=(t=>(t.EMPTY="empty",t.VERIFY="verify",t.PENDING="pending",t.VERIFIED="verified",t.BANNED="banned",t))(u||{}),E=(t=>(t.ALLOWED="allowed",t.PENDING="pending",t))(E||{}),f=(t=>(t.ASSET="asset",t.DESTINATION="destination",t.COUNTERPARTY="counterparty",t.AGENT="agent",t))(f||{}),a=(t=>(t.COMPLETE="complete",t.RESIZE="resize",t.RESULT="result",t.READY="ready",t.INVALID="invalid",t.ERROR="error",t.CANCEL="cancel",t))(a||{}),d=(t=>(t.UPDATE="update",t.REQUEST_RESPONSE="requestResponse",t))(d||{}),p=(t=>(t.PENDING="pending",t.FAILED="rejected",t.FLAGGED="flagged",t.VERIFIED="verified",t))(p||{}),v=(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.MicroTransfer="microtransfer",t.Screenshot="screenshot",t.Connect="connect",t))(v||{});class b{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,r){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(r),()=>this.off(e,r)}off(e,r){const i=this.listeners.get(e);i&&(i.delete(r),i.size===0&&this.listeners.delete(e))}handleMessage(e){const r=e.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(e){this.port&&this.port.postMessage(e)}}class g{constructor(e,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=e,this._value=r,this._options=i,this.eventManager=new b,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(e){const r=document.querySelector(e);if(!r)throw new Error(`parentID ${e} not found`);this.embed(r)}embed(e,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",e.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(e){this.eventManager.send(e)}on(e,r){return this.eventManager.on(e,r)}off(e,r){this.eventManager.off(e,r)}update(e,r){this._value=e,r&&(this._options=r),this.send({type:d.UPDATE,value:e,options:this._options})}completion(){return new Promise((e,r)=>{let i,s,n;function l(){i&&i(),s&&s(),n&&n()}i=this.on(a.COMPLETE,h=>{e(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 e=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(()=>{e(),r()})}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",s=>{var n;s.source===e&&(console.log("received message from popup",s.data),(n=this.eventManager)==null||n.setPort(s.ports[0]))});const r=this.on(a.CANCEL,()=>{e==null||e.close()}),i=this.on(a.COMPLETE,()=>{e==null||e.close()});return this.completion().finally(()=>{r(),i()})}}function C(t){return Object.entries(t).map(([e,r])=>{if(r==null)return;const i=encodeURIComponent(e),s=encodeURIComponent(typeof r=="object"?JSON.stringify(r):String(r));return`${i}=${s}`}).filter(e=>e!==void 0).join("&")}function A(t){const e=t.slice(1);return e?e.split("&").filter(Boolean).reduce((i,s)=>{const[n,l]=s.split("=");return n&&(i[decodeURIComponent(n)]=l?decodeURIComponent(l):""),i},{}):{}}class U{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,r,i,s){const n=new URL(this.uxUrl);n.pathname=e;const l=C({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(e,r,i,s){return new g(this.componentUrl(e,r,i,s),r,i)}createWithdrawalAssist(e,r,i){return this.createComponent("withdrawal-assist",e,r,i)}createConnectWallet(e,r,i){return this.createComponent("connect",e,r,i)}createDepositRequest(e,r,i){return this.createComponent("deposit-request",e,r,i)}createDepositAssist(e,r,i){return this.createComponent("deposit-assist",e,r,i)}}exports.AgentType=c;exports.CMType=a;exports.EmbeddedComponent=g;exports.HMType=d;exports.PersonType=m;exports.ProofStatus=p;exports.ProofTypes=v;exports.Status=u;exports.VASPSearchControl=E;exports.ValidationSections=f;exports.decodeFragmentToObject=A;exports.default=U;
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.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 s=this.listeners.get(t);s&&(s.delete(r),s.size===0&&this.listeners.delete(t))}handleMessage(t){const r=t.data;if(typeof r=="object"&&r!==null&&"type"in r){const s=r.type,i=this.listeners.get(s);i&&i.forEach(n=>n(r))}}send(t){this.port&&this.port.postMessage(t)}}class g{constructor(t,r,s){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=s,this.eventManager=new N,this.on(a.INVALID,i=>{i.type===a.INVALID&&(this._errors=i.errors,this._value=i.value)}),this.on(a.RESIZE,i=>{i.type===a.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(t){const r=document.querySelector(t);if(!r)throw new Error(`parentID ${t} not found`);this.embed(r)}embed(t,r=!1){var s,i;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]))}),(i=(s=this.iframe)==null?void 0:s.contentWindow)==null||i.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 s,i,n;function l(){s&&s(),i&&i(),n&&n()}s=this.on(a.COMPLETE,h=>{t(h.response),l()}),i=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",i=>{var n;i.source===t&&(console.log("received message from popup",i.data),(n=this.eventManager)==null||n.setPort(i.ports[0]))});const r=this.on(a.CANCEL,()=>{t==null||t.close()}),s=this.on(a.COMPLETE,()=>{t==null||t.close()});return this.completion().finally(()=>{r(),s()})}}function w(e){return Object.entries(e).map(([t,r])=>{if(r==null)return;const s=encodeURIComponent(t),i=encodeURIComponent(typeof r=="object"?JSON.stringify(r):String(r));return`${s}=${i}`}).filter(t=>t!==void 0).join("&")}function _(e){const t=e.slice(1);return t?t.split("&").filter(Boolean).reduce((s,i)=>{const[n,l]=i.split("=");return n&&(s[decodeURIComponent(n)]=l?decodeURIComponent(l):""),s},{}):{}}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,s,i){const n=new URL(this.uxUrl);n.pathname=t;const l=w({authToken:this.authToken,value:r,configuration:s});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(t,r,s,i){return new g(this.componentUrl(t,r,s,i),r,s)}createWithdrawalAssist(t,r,s){return this.createComponent("withdrawal-assist",t,r,s)}createConnectWallet(t,r,s){return this.createComponent("connect",t,r,s)}createDepositRequest(t,r,s){return this.createComponent("deposit-request",t,r,s)}createDepositAssist(t,r,s){return this.createComponent("deposit-assist",t,r,s)}}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=_;exports.default=C;
package/dist/notabene.js CHANGED
@@ -1,8 +1,8 @@
1
1
  var c = Object.defineProperty;
2
- var m = (t, e, r) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var o = (t, e, r) => m(t, typeof e != "symbol" ? e + "" : e, r);
4
- var u = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(u || {}), E = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(E || {}), f = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(f || {}), p = /* @__PURE__ */ ((t) => (t.ALLOWED = "allowed", t.PENDING = "pending", t))(p || {}), v = /* @__PURE__ */ ((t) => (t.ASSET = "asset", t.DESTINATION = "destination", t.COUNTERPARTY = "counterparty", t.AGENT = "agent", t))(v || {}), h = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.ERROR = "error", t.CANCEL = "cancel", t))(h || {}), d = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(d || {}), g = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(g || {}), w = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.SIWE = "siwe", t.SIWX = "siwx", t.EIP191 = "eip-191", t.EIP712 = "eip-712", t.EIP1271 = "eip-1271", t.BIP137 = "bip-137", t.BIP322 = "bip-322", t.BIP137_XPUB = "xpub", t.TIP191 = "tip-191", t.ED25519 = "ed25519", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t.Connect = "connect", t))(w || {});
5
- class I {
2
+ var m = (e, t, r) => t in e ? c(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var o = (e, t, r) => m(e, typeof t != "symbol" ? t + "" : t, r);
4
+ var u = /* @__PURE__ */ ((e) => (e.PRIVATE = "WALLET", e.VASP = "VASP", e))(u || {}), E = /* @__PURE__ */ ((e) => (e.NATURAL = "natural", e.LEGAL = "legal", e.SELF = "self", e))(E || {}), f = /* @__PURE__ */ ((e) => (e.EMPTY = "empty", e.VERIFY = "verify", e.PENDING = "pending", e.VERIFIED = "verified", e.BANNED = "banned", e))(f || {}), p = /* @__PURE__ */ ((e) => (e.ALLOWED = "allowed", e.PENDING = "pending", e))(p || {}), v = /* @__PURE__ */ ((e) => (e.ASSET = "asset", e.DESTINATION = "destination", e.COUNTERPARTY = "counterparty", e.AGENT = "agent", e))(v || {}), h = /* @__PURE__ */ ((e) => (e.COMPLETE = "complete", e.RESIZE = "resize", e.RESULT = "result", e.READY = "ready", e.INVALID = "invalid", e.ERROR = "error", e.CANCEL = "cancel", e))(h || {}), I = /* @__PURE__ */ ((e) => (e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.WALLET_CONNECTION_FAILED = "WALLET_CONNECTION_FAILED", e.WALLET_NOT_SUPPORTED = "WALLET_NOT_SUPPORTED", e.TOKEN_INVALID = "TOKEN_INVALID", e))(I || {}), d = /* @__PURE__ */ ((e) => (e.UPDATE = "update", e.REQUEST_RESPONSE = "requestResponse", e))(d || {}), L = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.FAILED = "rejected", e.FLAGGED = "flagged", e.VERIFIED = "verified", e))(L || {}), g = /* @__PURE__ */ ((e) => (e.SelfDeclaration = "self-declaration", e.SIWE = "siwe", e.SIWX = "siwx", e.EIP191 = "eip-191", e.EIP712 = "eip-712", e.EIP1271 = "eip-1271", e.BIP137 = "bip-137", e.BIP322 = "bip-322", e.BIP137_XPUB = "xpub", e.TIP191 = "tip-191", e.ED25519 = "ed25519", e.MicroTransfer = "microtransfer", e.Screenshot = "screenshot", e.Connect = "connect", e))(g || {});
5
+ class A {
6
6
  constructor() {
7
7
  o(this, "listeners", /* @__PURE__ */ new Map());
8
8
  o(this, "port");
@@ -16,8 +16,8 @@ class I {
16
16
  *
17
17
  * @param port - The MessagePort instance to use for communication
18
18
  */
19
- setPort(e) {
20
- this.port = e, this.port.onmessage = this.handleMessage, this.port.start();
19
+ setPort(t) {
20
+ this.port = t, this.port.onmessage = this.handleMessage, this.port.start();
21
21
  }
22
22
  /**
23
23
  * Registers a callback for a specific message type.
@@ -29,8 +29,8 @@ class I {
29
29
  * @param callback - The callback function to execute when matching messages are received
30
30
 
31
31
  */
32
- on(e, r) {
33
- return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(r), () => this.off(e, r);
32
+ on(t, r) {
33
+ return this.listeners.has(t) || this.listeners.set(t, /* @__PURE__ */ new Set()), this.listeners.get(t).add(r), () => this.off(t, r);
34
34
  }
35
35
  /**
36
36
  * Removes a callback for a specific message type.
@@ -41,9 +41,9 @@ class I {
41
41
  * @param messageType - The type of message to remove listener from
42
42
  * @param callback - The callback function to remove
43
43
  */
44
- off(e, r) {
45
- const i = this.listeners.get(e);
46
- i && (i.delete(r), i.size === 0 && this.listeners.delete(e));
44
+ off(t, r) {
45
+ const s = this.listeners.get(t);
46
+ s && (s.delete(r), s.size === 0 && this.listeners.delete(t));
47
47
  }
48
48
  /**
49
49
  * Internal message handler for processing received messages.
@@ -53,28 +53,28 @@ class I {
53
53
  *
54
54
  * @param event - The message event containing the component message
55
55
  */
56
- handleMessage(e) {
57
- const r = e.data;
56
+ handleMessage(t) {
57
+ const r = t.data;
58
58
  if (typeof r == "object" && r !== null && "type" in r) {
59
- const i = r.type, s = this.listeners.get(i);
60
- s && s.forEach((n) => n(r));
59
+ const s = r.type, i = this.listeners.get(s);
60
+ i && i.forEach((n) => n(r));
61
61
  }
62
62
  }
63
63
  /**
64
64
  * Sends a message through the message port
65
65
  * @param message The host message to send
66
66
  */
67
- send(e) {
68
- this.port && this.port.postMessage(e);
67
+ send(t) {
68
+ this.port && this.port.postMessage(t);
69
69
  }
70
70
  }
71
- class C {
71
+ class N {
72
72
  /**
73
73
  * Creates an instance of EmbeddedComponent.
74
74
  * @param url - The URL of the embedded component
75
75
  * @param value - The initial transaction value
76
76
  */
77
- constructor(e, r, i) {
77
+ constructor(t, r, s) {
78
78
  o(this, "_url");
79
79
  o(this, "_value");
80
80
  o(this, "_options");
@@ -82,10 +82,10 @@ class C {
82
82
  o(this, "iframe");
83
83
  o(this, "eventManager");
84
84
  o(this, "modal");
85
- this._url = e, this._value = r, this._options = i, this.eventManager = new I(), this.on(h.INVALID, (s) => {
86
- s.type === h.INVALID && (this._errors = s.errors, this._value = s.value);
87
- }), this.on(h.RESIZE, (s) => {
88
- s.type === h.RESIZE && this.iframe && (this.iframe.style.height = `${s.height}px`);
85
+ this._url = t, this._value = r, this._options = s, this.eventManager = new A(), this.on(h.INVALID, (i) => {
86
+ i.type === h.INVALID && (this._errors = i.errors, this._value = i.value);
87
+ }), this.on(h.RESIZE, (i) => {
88
+ i.type === h.RESIZE && this.iframe && (this.iframe.style.height = `${i.height}px`);
89
89
  });
90
90
  }
91
91
  /**
@@ -119,21 +119,21 @@ class C {
119
119
  * @param parentId - The ID of the parent element
120
120
  * @throws Will throw an error if the parent element is not found
121
121
  */
122
- mount(e) {
123
- const r = document.querySelector(e);
124
- if (!r) throw new Error(`parentID ${e} not found`);
122
+ mount(t) {
123
+ const r = document.querySelector(t);
124
+ if (!r) throw new Error(`parentID ${t} not found`);
125
125
  this.embed(r);
126
126
  }
127
127
  /**
128
128
  * Embeds the component into a parent element
129
129
  * @param parent - The parent element to embed the component into
130
130
  */
131
- embed(e, r = !1) {
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; 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", (n) => {
131
+ embed(t, r = !1) {
132
+ var s, i;
133
+ this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (r ? "" : "&embedded=true"), this.iframe.allow = "web-share; clipboard-write; hid; bluetooth;", this.iframe.style.width = "100%", this.iframe.style.height = "0px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", this.iframe.scrolling = "no", t.appendChild(this.iframe), window.addEventListener("message", (n) => {
134
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
- }), (s = (i = this.iframe) == null ? void 0 : i.contentWindow) == null || s.focus();
136
+ }), (i = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || i.focus();
137
137
  }
138
138
  removeEmbed() {
139
139
  this.iframe && this.iframe.remove();
@@ -142,45 +142,45 @@ class C {
142
142
  * Sends a message to the embedded component
143
143
  * @param message - The message to send
144
144
  */
145
- send(e) {
146
- this.eventManager.send(e);
145
+ send(t) {
146
+ this.eventManager.send(t);
147
147
  }
148
148
  /**
149
149
  * Adds an event listener for a specific message type
150
150
  * @param messageType - The type of message to listen for
151
151
  * @param callback - The callback function to execute when the message is received
152
152
  */
153
- on(e, r) {
154
- return this.eventManager.on(e, r);
153
+ on(t, r) {
154
+ return this.eventManager.on(t, r);
155
155
  }
156
156
  /**
157
157
  * Removes an event listener for a specific message type
158
158
  * @param messageType - The type of message to stop listening for
159
159
  * @param callback - The callback function to remove
160
160
  */
161
- off(e, r) {
162
- this.eventManager.off(e, r);
161
+ off(t, r) {
162
+ this.eventManager.off(t, r);
163
163
  }
164
164
  /**
165
165
  * Updates the transaction value and sends an update message to the component
166
166
  * @param value - The new transaction value
167
167
  */
168
- update(e, r) {
169
- this._value = e, r && (this._options = r), this.send({ type: d.UPDATE, value: e, options: this._options });
168
+ update(t, r) {
169
+ this._value = t, r && (this._options = r), this.send({ type: d.UPDATE, value: t, options: this._options });
170
170
  }
171
171
  /**
172
172
  * Waits for the component to complete and returns the transaction response
173
173
  * @returns A promise that resolves with the transaction response
174
174
  */
175
175
  completion() {
176
- return new Promise((e, r) => {
177
- let i, s, n;
176
+ return new Promise((t, r) => {
177
+ let s, i, n;
178
178
  function a() {
179
- i && i(), s && s(), n && n();
179
+ s && s(), i && i(), n && n();
180
180
  }
181
- i = this.on(h.COMPLETE, (l) => {
182
- e(l.response), a();
183
- }), s = this.on(h.CANCEL, () => {
181
+ s = this.on(h.COMPLETE, (l) => {
182
+ t(l.response), a();
183
+ }), i = this.on(h.CANCEL, () => {
184
184
  r(new Error("User cancelled")), a();
185
185
  }), n = this.on("error", (l) => {
186
186
  r(new Error(l.message)), a();
@@ -192,7 +192,7 @@ class C {
192
192
  */
193
193
  async openModal() {
194
194
  this.modal && this.closeModal(), this.modal = document.createElement("dialog"), this.modal.style.border = "none", this.modal.style.backgroundColor = "white", this.modal.style.maxWidth = "100vw", this.modal.style.maxHeight = "100vh", this.modal.style.width = "600px", this.modal.style.height = "600px", document.body.appendChild(this.modal), this.embed(this.modal, !0);
195
- const e = this.on(h.CANCEL, () => {
195
+ const t = this.on(h.CANCEL, () => {
196
196
  this.closeModal();
197
197
  }), r = this.on(h.COMPLETE, () => {
198
198
  this.closeModal();
@@ -200,7 +200,7 @@ class C {
200
200
  return this.modal.showModal(), this.modal.addEventListener("click", () => {
201
201
  this.closeModal();
202
202
  }), this.completion().finally(() => {
203
- e(), r();
203
+ t(), r();
204
204
  });
205
205
  }
206
206
  /**
@@ -208,8 +208,8 @@ class C {
208
208
  *
209
209
  */
210
210
  closeModal() {
211
- var e;
212
- this.modal && ((e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
211
+ var t;
212
+ this.modal && ((t = this.modal) == null || t.close(), this.modal.remove(), this.modal = void 0);
213
213
  }
214
214
  /**
215
215
  * Opens the component in a popup window. This may be needed to support many self-hosted wallets
@@ -218,58 +218,58 @@ class C {
218
218
  * @see [Cross-Origin-Opener-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy)
219
219
  */
220
220
  async popup() {
221
- const e = window.open(
221
+ const t = window.open(
222
222
  this.url,
223
223
  "_blank",
224
224
  "popup=true,width=600,height=600"
225
225
  );
226
- window.addEventListener("message", (s) => {
226
+ window.addEventListener("message", (i) => {
227
227
  var n;
228
- s.source === e && (console.log("received message from popup", s.data), (n = this.eventManager) == null || n.setPort(s.ports[0]));
228
+ i.source === t && (console.log("received message from popup", i.data), (n = this.eventManager) == null || n.setPort(i.ports[0]));
229
229
  });
230
230
  const r = this.on(h.CANCEL, () => {
231
- e == null || e.close();
232
- }), i = this.on(h.COMPLETE, () => {
233
- e == null || e.close();
231
+ t == null || t.close();
232
+ }), s = this.on(h.COMPLETE, () => {
233
+ t == null || t.close();
234
234
  });
235
235
  return this.completion().finally(() => {
236
- r(), i();
236
+ r(), s();
237
237
  });
238
238
  }
239
239
  }
240
- function U(t) {
241
- return Object.entries(t).map(([e, r]) => {
240
+ function w(e) {
241
+ return Object.entries(e).map(([t, r]) => {
242
242
  if (r == null) return;
243
- const i = encodeURIComponent(e), s = encodeURIComponent(
243
+ const s = encodeURIComponent(t), i = encodeURIComponent(
244
244
  typeof r == "object" ? JSON.stringify(r) : String(r)
245
245
  // Use String() to handle all primitive types
246
246
  );
247
- return `${i}=${s}`;
248
- }).filter((e) => e !== void 0).join("&");
247
+ return `${s}=${i}`;
248
+ }).filter((t) => t !== void 0).join("&");
249
249
  }
250
- function L(t) {
251
- const e = t.slice(1);
252
- return e ? e.split("&").filter(Boolean).reduce(
253
- (i, s) => {
254
- const [n, a] = s.split("=");
255
- return n && (i[decodeURIComponent(n)] = a ? decodeURIComponent(a) : ""), i;
250
+ function U(e) {
251
+ const t = e.slice(1);
252
+ return t ? t.split("&").filter(Boolean).reduce(
253
+ (s, i) => {
254
+ const [n, a] = i.split("=");
255
+ return n && (s[decodeURIComponent(n)] = a ? decodeURIComponent(a) : ""), s;
256
256
  },
257
257
  {}
258
258
  ) : {};
259
259
  }
260
- class A {
260
+ class C {
261
261
  /**
262
262
  * Creates a new instance of the Notabene SDK
263
263
  *
264
264
  * @param config - Configuration options for the Notabene SDK
265
265
  */
266
- constructor(e) {
266
+ constructor(t) {
267
267
  o(this, "nodeUrl");
268
268
  o(this, "authToken");
269
269
  o(this, "uxUrl");
270
270
  o(this, "theme");
271
271
  o(this, "locale");
272
- this.uxUrl = e.uxUrl || "https://connect.notabene.id", this.nodeUrl = e.nodeUrl, this.authToken = e.authToken, this.theme = e.theme, this.locale = e.locale;
272
+ this.uxUrl = t.uxUrl || "https://connect.notabene.id", this.nodeUrl = t.nodeUrl, this.authToken = t.authToken, this.theme = t.theme, this.locale = t.locale;
273
273
  }
274
274
  /**
275
275
  * Generates a URL for a Notabene component
@@ -281,15 +281,15 @@ class A {
281
281
  * @returns component URL
282
282
  * @internal
283
283
  */
284
- componentUrl(e, r, i, s) {
284
+ componentUrl(t, r, s, i) {
285
285
  const n = new URL(this.uxUrl);
286
- n.pathname = e;
287
- const a = U({
286
+ n.pathname = t;
287
+ const a = w({
288
288
  authToken: this.authToken,
289
289
  value: r,
290
- configuration: i
290
+ configuration: s
291
291
  });
292
- return n.hash = a, this.nodeUrl && n.searchParams.set("nodeUrl", this.nodeUrl), this.theme && n.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && n.searchParams.set("locale", this.locale), s && (s.callback && n.searchParams.set("callback_url", s.callback), s.redirectUri && n.searchParams.set("redirect_uri", s.redirectUri)), n.toString();
292
+ return n.hash = a, this.nodeUrl && n.searchParams.set("nodeUrl", this.nodeUrl), this.theme && n.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && n.searchParams.set("locale", this.locale), i && (i.callback && n.searchParams.set("callback_url", i.callback), i.redirectUri && n.searchParams.set("redirect_uri", i.redirectUri)), n.toString();
293
293
  }
294
294
  /**
295
295
  * Creates a new embedded component
@@ -301,11 +301,11 @@ class A {
301
301
  * @returns A new EmbeddedComponent instance
302
302
  * @internal
303
303
  */
304
- createComponent(e, r, i, s) {
305
- return new C(
306
- this.componentUrl(e, r, i, s),
304
+ createComponent(t, r, s, i) {
305
+ return new N(
306
+ this.componentUrl(t, r, s, i),
307
307
  r,
308
- i
308
+ s
309
309
  );
310
310
  }
311
311
  /**
@@ -316,12 +316,12 @@ class A {
316
316
  * @param callbacks - Optional callback configuration
317
317
  * @returns A new EmbeddedComponent instance for withdrawal assistance
318
318
  */
319
- createWithdrawalAssist(e, r, i) {
319
+ createWithdrawalAssist(t, r, s) {
320
320
  return this.createComponent(
321
321
  "withdrawal-assist",
322
- e,
322
+ t,
323
323
  r,
324
- i
324
+ s
325
325
  );
326
326
  }
327
327
  /**
@@ -333,12 +333,12 @@ class A {
333
333
  * @returns A new EmbeddedComponent instance for connection
334
334
  * @alpha
335
335
  */
336
- createConnectWallet(e, r, i) {
336
+ createConnectWallet(t, r, s) {
337
337
  return this.createComponent(
338
338
  "connect",
339
- e,
339
+ t,
340
340
  r,
341
- i
341
+ s
342
342
  );
343
343
  }
344
344
  /**
@@ -350,12 +350,12 @@ class A {
350
350
  * @returns A new EmbeddedComponent instance for deposit requests
351
351
  * @public
352
352
  */
353
- createDepositRequest(e, r, i) {
353
+ createDepositRequest(t, r, s) {
354
354
  return this.createComponent(
355
355
  "deposit-request",
356
- e,
356
+ t,
357
357
  r,
358
- i
358
+ s
359
359
  );
360
360
  }
361
361
  /**
@@ -367,26 +367,27 @@ class A {
367
367
  * @returns A new EmbeddedComponent instance for deposit assistance
368
368
  * @public
369
369
  */
370
- createDepositAssist(e, r, i) {
370
+ createDepositAssist(t, r, s) {
371
371
  return this.createComponent(
372
372
  "deposit-assist",
373
- e,
373
+ t,
374
374
  r,
375
- i
375
+ s
376
376
  );
377
377
  }
378
378
  }
379
379
  export {
380
380
  u as AgentType,
381
381
  h as CMType,
382
- C as EmbeddedComponent,
382
+ N as EmbeddedComponent,
383
+ I as ErrorIdentifierCode,
383
384
  d as HMType,
384
385
  E as PersonType,
385
- g as ProofStatus,
386
- w as ProofTypes,
386
+ L as ProofStatus,
387
+ g as ProofTypes,
387
388
  f as Status,
388
389
  p as VASPSearchControl,
389
390
  v as ValidationSections,
390
- L as decodeFragmentToObject,
391
- A as default
391
+ U as decodeFragmentToObject,
392
+ C as default
392
393
  };
package/package.json CHANGED
@@ -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.5.0",
13
+ "version": "2.5.1",
14
14
  "source": "src/notabene.ts",
15
15
  "main": "dist/notabene.js",
16
16
  "types": "dist/notabene.d.ts",
package/src/notabene.ts CHANGED
@@ -22,7 +22,6 @@ import type {
22
22
  DID,
23
23
  DTI,
24
24
  Error,
25
- ErrorIdentifierCode,
26
25
  FieldTypes,
27
26
  HostMessage,
28
27
  InvalidValue,
@@ -56,6 +55,7 @@ import type {
56
55
  import {
57
56
  AgentType,
58
57
  CMType,
58
+ ErrorIdentifierCode,
59
59
  HMType,
60
60
  PersonType,
61
61
  ProofStatus,
@@ -72,6 +72,7 @@ export {
72
72
  AgentType,
73
73
  CMType,
74
74
  decodeFragmentToObject,
75
+ ErrorIdentifierCode,
75
76
  HMType,
76
77
  PersonType,
77
78
  ProofStatus,
@@ -101,7 +102,6 @@ export type {
101
102
  DID,
102
103
  DTI,
103
104
  Error,
104
- ErrorIdentifierCode,
105
105
  FieldTypes,
106
106
  HostMessage,
107
107
  InvalidValue,