@notabene/javascript-sdk 2.12.0 → 2.13.0-next.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/README.md +6 -4
- package/dist/cjs/notabene.cjs +1 -1
- package/dist/cjs/notabene.d.ts +15 -2
- package/dist/cjs/package.json +1 -1
- package/dist/esm/notabene.d.ts +15 -2
- package/dist/esm/notabene.js +106 -105
- package/dist/esm/package.json +1 -1
- package/dist/notabene.d.ts +15 -2
- package/dist/notabene.js +106 -105
- package/docs/README.md +0 -4
- package/docs/_media/TransactionOptions.md +0 -4
- package/docs/types/interfaces/TransactionOptions.md +0 -4
- package/package.json +1 -1
- package/src/notabene.ts +2 -0
- package/src/types.ts +15 -2
- package/src/utils/arbitraries.ts +0 -1
package/README.md
CHANGED
|
@@ -206,6 +206,12 @@ To be notified of any validation errors use:
|
|
|
206
206
|
withdrawal.on('error',error => ...)
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
+
To be notified of any errors that won't require remounting the instance use:
|
|
210
|
+
|
|
211
|
+
```js
|
|
212
|
+
withdrawal.on('warning', error => ...)
|
|
213
|
+
```
|
|
214
|
+
|
|
209
215
|
To be notified when the component is Ready:
|
|
210
216
|
|
|
211
217
|
```js
|
|
@@ -344,7 +350,6 @@ const withdrawal = notabene.createWithdrawalAssist(
|
|
|
344
350
|
microTransfer: {
|
|
345
351
|
destination: '0x...',
|
|
346
352
|
amountSubunits: '12344',
|
|
347
|
-
timeout: 86440,
|
|
348
353
|
},
|
|
349
354
|
},
|
|
350
355
|
},
|
|
@@ -714,7 +719,6 @@ const options: TransactionOptions = {
|
|
|
714
719
|
microTransfer: {
|
|
715
720
|
destination: '0x...',
|
|
716
721
|
amountSubunits: '12344',
|
|
717
|
-
timeout: 86440,
|
|
718
722
|
},
|
|
719
723
|
fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self-declaration']
|
|
720
724
|
deminimis: {
|
|
@@ -786,7 +790,6 @@ withdrawal.update(
|
|
|
786
790
|
microTransfer: {
|
|
787
791
|
destination: '0x...',
|
|
788
792
|
amountSubunits: '12344',
|
|
789
|
-
timeout: 86440,
|
|
790
793
|
},
|
|
791
794
|
},
|
|
792
795
|
},
|
|
@@ -867,7 +870,6 @@ const options: TransactionOptions = {
|
|
|
867
870
|
microTransfer: {
|
|
868
871
|
destination: '0x...',
|
|
869
872
|
amountSubunits: '1234',
|
|
870
|
-
timeout: 86440, // Optional timeout in seconds, which is displayed to the user
|
|
871
873
|
},
|
|
872
874
|
fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self_declaration']
|
|
873
875
|
},
|
package/dist/cjs/notabene.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty;var D=(e,t,n)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var a=(e,t,n)=>D(e,typeof t!="symbol"?t+"":t,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var f=(e=>(e.PRIVATE="WALLET",e.VASP="VASP",e))(f||{}),w=(e=>(e.NATURAL="natural",e.LEGAL="legal",e.SELF="self",e))(w||{}),A=(e=>(e.EMPTY="empty",e.VERIFY="verify",e.PENDING="pending",e.VERIFIED="verified",e.BANNED="banned",e))(A||{}),v=(e=>(e.ALLOWED="allowed",e.PENDING="pending",e))(v||{}),g=(e=>(e.SMS="sms",e.EMAIL="email",e))(g||{}),I=(e=>(e.PENDING="pending",e.APPROVED="approved",e.FAILED="failed",e.EXPIRED="expired",e.MAX_ATTEMPTS_REACHED="max_attempts_reached",e.UNREACHABLE="unreachable",e))(I||{}),y=(e=>(e.COINBASE="coinbase",e))(y||{}),N=(e=>(e.ASSET="asset",e.DESTINATION="destination",e.COUNTERPARTY="counterparty",e.AGENT="agent",e))(N||{}),l=(e=>(e.COMPLETE="complete",e.RESIZE="resize",e.RESULT="result",e.READY="ready",e.INVALID="invalid",e.ERROR="error",e.CANCEL="cancel",e.WARNING="warning",e.INFO="info",e))(l||{}),b=(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))(b||{}),E=(e=>(e.UPDATE="update",e.REQUEST_RESPONSE="requestResponse",e))(E||{}),C=(e=>(e.PENDING="pending",e.FAILED="rejected",e.FLAGGED="flagged",e.VERIFIED="verified",e))(C||{}),L=(e=>(e.SelfDeclaration="self-declaration",e.SIWE="siwe",e.SIWX="siwx",e.SOL_SIWX="sol-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.XLM_ED25519="xlm-ed25519",e.CIP8="cip-8",e.COSMOS="cosmos-ecdsa",e.MicroTransfer="microtransfer",e.Screenshot="screenshot",e.Connect="connect",e.CONCORDIUM="concordium",e))(L||{});class S{constructor(){a(this,"listeners",new Map);a(this,"port");this.handleMessage=this.handleMessage.bind(this)}setPort(t){this.port=t,this.port.onmessage=this.handleMessage,this.port.start()}on(t,n){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(n),()=>this.off(t,n)}off(t,n){const r=this.listeners.get(t);r&&(r.delete(n),r.size===0&&this.listeners.delete(t))}handleMessage(t){const n=t.data;if(typeof n=="object"&&n!==null&&"type"in n){const r=n.type,s=this.listeners.get(r);s&&s.forEach(i=>i(n))}}send(t){this.port&&this.port.postMessage(t)}}class _{constructor(t,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=t,this._value=n,this._options=r,this.eventManager=new S,this.on(l.INVALID,s=>{s.type===l.INVALID&&(this._errors=s.errors,this._value=s.value)}),this.on(l.RESIZE,s=>{s.type===l.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 n=document.querySelector(t);if(!n)throw new Error(`parentID ${t} not found`);this.embed(n)}embed(t,n=!1){var r,s;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",t.appendChild(this.iframe),window.addEventListener("message",i=>{var o,c;i.source===((o=this.iframe)==null?void 0:o.contentWindow)&&((c=this.eventManager)==null||c.setPort(i.ports[0]))}),(s=(r=this.iframe)==null?void 0:r.contentWindow)==null||s.focus()}removeEmbed(){this.iframe&&this.iframe.remove()}send(t){this.eventManager.send(t)}on(t,n){return this.eventManager.on(t,n)}off(t,n){this.eventManager.off(t,n)}update(t,n){this._value=t,n&&(this._options=n),this.send({type:E.UPDATE,value:t,options:this._options})}completion(){return new Promise((t,n)=>{let r,s,i;function o(){r&&r(),s&&s(),i&&i()}r=this.on(l.COMPLETE,c=>{t(c.response),o()}),s=this.on(l.CANCEL,()=>{n(new Error("User cancelled")),o()}),i=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 t=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(()=>{t(),n()})}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 i;s.source===t&&(console.log("received message from popup",s.data),(i=this.eventManager)==null||i.setPort(s.ports[0]))});const n=this.on(l.CANCEL,()=>{t==null||t.close()}),r=this.on(l.COMPLETE,()=>{t==null||t.close()});return this.completion().finally(()=>{n(),r()})}}function x(e){return Object.entries(e).map(([t,n])=>{if(n==null)return;const r=encodeURIComponent(t),s=encodeURIComponent(typeof n=="object"?JSON.stringify(n):String(n));return`${r}=${s}`}).filter(t=>t!==void 0).join("&")}function M(e){const t=e.slice(1);return t?t.split("&").filter(Boolean).reduce((r,s)=>{const[i,o]=s.split("=");return i&&(r[decodeURIComponent(i)]=o?decodeURIComponent(o):""),r},{}):{}}async function p(e,t){const n=JSON.stringify(e),r=new TextEncoder,s=t?m(t):crypto.getRandomValues(new Uint8Array(32)),i=await crypto.subtle.importKey("raw",s,{name:"AES-GCM"},!1,["encrypt"]),o=crypto.getRandomValues(new Uint8Array(12)),c=await crypto.subtle.encrypt({name:"AES-GCM",iv:o},i,r.encode(n));return{ciphertext:`${u(o)}-${u(c)}`,key:u(s)}}async function O({ciphertext:e,key:t}){const[n,r]=e.split("-"),s=new Uint8Array(atob(t).split("").map(R=>R.charCodeAt(0))),i=m(n),o=m(r),c=await crypto.subtle.importKey("raw",s,{name:"AES-GCM"},!1,["decrypt"]),d=new TextDecoder,h=await crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(i)},c,o);return JSON.parse(d.decode(h))}function u(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return btoa(n)}function m(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}async function P(e){const t=await fetch(e.url,{method:"GET"});if(!t.ok)throw new Error(`Failed to get connection: ${await t.text()}`);const n=await t.json();if(!n.id||!n.metadata||!n.status||!n.sealed)throw new Error("Data missing from server response");const r={id:n.id,metadata:n.metadata,status:n.status};if(n.status==="closed")return r;const s=n.sealed[n.sealed.length-1],i=await O({ciphertext:s,key:e.key});return n.status==="completed"?{...r,result:i.result}:{...r,tx:i.tx}}class T{constructor(t){a(this,"endpoint");this.endpoint=t}async create(t,n){const r=await p(t),s={metadata:n,sealed:r.ciphertext},i=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok)throw new Error(`Failed to create connection: ${await i.text()}`);const o=await i.json();return{id:o.id,version:o.version,status:o.status,metadata:n,data:t,key:r.key}}async update(t,n,r,s,i){const o=await p(n,i),c={sealed:o.ciphertext,version:r,status:s},d=await fetch(`${this.endpoint}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok)throw new Error(`Failed to update connection: ${await d.text()}`);const h=await d.json();return{id:h.id,metadata:h.metadata,version:h.version,status:h.status,data:n,key:o.key}}async get(t,n){const r=await fetch(`${this.endpoint}/${t}`,{method:"GET"});if(!r.ok)throw new Error(`Failed to get connection: ${await r.text()}`);const s=await r.json(),i=s.sealed[s.sealed.length-1],o=await O({ciphertext:i,key:n});return{id:s.id,status:s.status,version:s.version,metadata:s.metadata,data:o,key:n}}async close(t){const n=await fetch(`${this.endpoint}/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`Failed to close connection: ${await n.text()}`)}}class k{constructor(t){a(this,"nodeUrl");a(this,"authToken");a(this,"uxUrl");a(this,"theme");a(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,n,r,s){const i=new URL(this.uxUrl);i.pathname=t;const o=x({authToken:this.authToken,value:n,configuration:r});return i.hash=o,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),s&&(s.callback&&i.searchParams.set("callback_url",s.callback),s.redirectUri&&i.searchParams.set("redirect_uri",s.redirectUri)),i.toString()}createComponent(t,n,r,s){return new _(this.componentUrl(t,n,r,s),n,r)}createWithdrawalAssist(t,n,r){return this.createComponent("withdrawal-assist",t,n,r)}createConnectWallet(t,n,r){return this.createComponent("connect",t,n,r)}createDepositRequest(t,n,r){return this.createComponent("deposit-request",t,n,r)}createDepositAssist(t,n,r){return this.createComponent("deposit-assist",t,n,r)}}exports.AgentType=f;exports.CMType=l;exports.CodeVerificationStatus=I;exports.ConnectionManager=T;exports.EmbeddedComponent=_;exports.ErrorIdentifierCode=b;exports.HMType=E;exports.IdentityVerificationMethod=g;exports.OAuthProvider=y;exports.PersonType=w;exports.ProofStatus=C;exports.ProofTypes=L;exports.Status=A;exports.VASPSearchControl=v;exports.ValidationSections=N;exports.decodeFragmentToObject=M;exports.default=k;exports.getRefreshResult=P;
|
|
1
|
+
"use strict";var O=Object.defineProperty;var S=(e,t,n)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var a=(e,t,n)=>S(e,typeof t!="symbol"?t+"":t,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var A=(e=>(e.PRIVATE="WALLET",e.VASP="VASP",e))(A||{}),f=(e=>(e.NATURAL="natural",e.LEGAL="legal",e.SELF="self",e))(f||{}),w=(e=>(e.EMPTY="empty",e.VERIFY="verify",e.PENDING="pending",e.VERIFIED="verified",e.BANNED="banned",e))(w||{}),L=(e=>(e.ALLOWED="allowed",e.PENDING="pending",e))(L||{}),N=(e=>(e.SMS="sms",e.EMAIL="email",e))(N||{}),v=(e=>(e.PENDING="pending",e.APPROVED="approved",e.FAILED="failed",e.EXPIRED="expired",e.MAX_ATTEMPTS_REACHED="max_attempts_reached",e.UNREACHABLE="unreachable",e))(v||{}),I=(e=>(e.COINBASE="coinbase",e))(I||{}),g=(e=>(e.ASSET="asset",e.DESTINATION="destination",e.COUNTERPARTY="counterparty",e.AGENT="agent",e))(g||{}),l=(e=>(e.COMPLETE="complete",e.RESIZE="resize",e.RESULT="result",e.READY="ready",e.INVALID="invalid",e.ERROR="error",e.CANCEL="cancel",e.WARNING="warning",e.INFO="info",e))(l||{}),_=(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))(_||{}),C=(e=>(e.WALLET_ADDRESS_NOT_CONNECTED="WALLET_ADDRESS_NOT_CONNECTED",e.WALLET_LOCKED="WALLET_LOCKED",e.WALLET_UNREACHABLE="WALLET_UNREACHABLE",e.JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE="JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE",e.IDV_UNAVAILABLE="IDV_UNAVAILABLE",e))(C||{}),m=(e=>(e.UPDATE="update",e.REQUEST_RESPONSE="requestResponse",e))(m||{}),y=(e=>(e.PENDING="pending",e.FAILED="rejected",e.FLAGGED="flagged",e.VERIFIED="verified",e))(y||{}),D=(e=>(e.SelfDeclaration="self-declaration",e.SIWE="siwe",e.SIWX="siwx",e.SOL_SIWX="sol-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.XLM_ED25519="xlm-ed25519",e.CIP8="cip-8",e.COSMOS="cosmos-ecdsa",e.MicroTransfer="microtransfer",e.Screenshot="screenshot",e.Connect="connect",e.CONCORDIUM="concordium",e))(D||{});class T{constructor(){a(this,"listeners",new Map);a(this,"port");this.handleMessage=this.handleMessage.bind(this)}setPort(t){this.port=t,this.port.onmessage=this.handleMessage,this.port.start()}on(t,n){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(n),()=>this.off(t,n)}off(t,n){const r=this.listeners.get(t);r&&(r.delete(n),r.size===0&&this.listeners.delete(t))}handleMessage(t){const n=t.data;if(typeof n=="object"&&n!==null&&"type"in n){const r=n.type,s=this.listeners.get(r);s&&s.forEach(o=>o(n))}}send(t){this.port&&this.port.postMessage(t)}}class R{constructor(t,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=t,this._value=n,this._options=r,this.eventManager=new T,this.on(l.INVALID,s=>{s.type===l.INVALID&&(this._errors=s.errors,this._value=s.value)}),this.on(l.RESIZE,s=>{s.type===l.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 n=document.querySelector(t);if(!n)throw new Error(`parentID ${t} not found`);this.embed(n)}embed(t,n=!1){var r,s;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",t.appendChild(this.iframe),window.addEventListener("message",o=>{var i,c;o.source===((i=this.iframe)==null?void 0:i.contentWindow)&&((c=this.eventManager)==null||c.setPort(o.ports[0]))}),(s=(r=this.iframe)==null?void 0:r.contentWindow)==null||s.focus()}removeEmbed(){this.iframe&&this.iframe.remove()}send(t){this.eventManager.send(t)}on(t,n){return this.eventManager.on(t,n)}off(t,n){this.eventManager.off(t,n)}update(t,n){this._value=t,n&&(this._options=n),this.send({type:m.UPDATE,value:t,options:this._options})}completion(){return new Promise((t,n)=>{let r,s,o;function i(){r&&r(),s&&s(),o&&o()}r=this.on(l.COMPLETE,c=>{t(c.response),i()}),s=this.on(l.CANCEL,()=>{n(new Error("User cancelled")),i()}),o=this.on("error",c=>{n(new Error(c.message)),i()})})}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(l.CANCEL,()=>{this.closeModal()}),n=this.on(l.COMPLETE,()=>{this.closeModal()});return this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion().finally(()=>{t(),n()})}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 o;s.source===t&&(console.log("received message from popup",s.data),(o=this.eventManager)==null||o.setPort(s.ports[0]))});const n=this.on(l.CANCEL,()=>{t==null||t.close()}),r=this.on(l.COMPLETE,()=>{t==null||t.close()});return this.completion().finally(()=>{n(),r()})}}function M(e){return Object.entries(e).map(([t,n])=>{if(n==null)return;const r=encodeURIComponent(t),s=encodeURIComponent(typeof n=="object"?JSON.stringify(n):String(n));return`${r}=${s}`}).filter(t=>t!==void 0).join("&")}function x(e){const t=e.slice(1);return t?t.split("&").filter(Boolean).reduce((r,s)=>{const[o,i]=s.split("=");return o&&(r[decodeURIComponent(o)]=i?decodeURIComponent(i):""),r},{}):{}}async function p(e,t){const n=JSON.stringify(e),r=new TextEncoder,s=t?E(t):crypto.getRandomValues(new Uint8Array(32)),o=await crypto.subtle.importKey("raw",s,{name:"AES-GCM"},!1,["encrypt"]),i=crypto.getRandomValues(new Uint8Array(12)),c=await crypto.subtle.encrypt({name:"AES-GCM",iv:i},o,r.encode(n));return{ciphertext:`${u(i)}-${u(c)}`,key:u(s)}}async function U({ciphertext:e,key:t}){const[n,r]=e.split("-"),s=new Uint8Array(atob(t).split("").map(b=>b.charCodeAt(0))),o=E(n),i=E(r),c=await crypto.subtle.importKey("raw",s,{name:"AES-GCM"},!1,["decrypt"]),h=new TextDecoder,d=await crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(o)},c,i);return JSON.parse(h.decode(d))}function u(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return btoa(n)}function E(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}async function P(e){const t=await fetch(e.url,{method:"GET"});if(!t.ok)throw new Error(`Failed to get connection: ${await t.text()}`);const n=await t.json();if(!n.id||!n.metadata||!n.status||!n.sealed)throw new Error("Data missing from server response");const r={id:n.id,metadata:n.metadata,status:n.status};if(n.status==="closed")return r;const s=n.sealed[n.sealed.length-1],o=await U({ciphertext:s,key:e.key});return n.status==="completed"?{...r,result:o.result}:{...r,tx:o.tx}}class B{constructor(t){a(this,"endpoint");this.endpoint=t}async create(t,n){const r=await p(t),s={metadata:n,sealed:r.ciphertext},o=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok)throw new Error(`Failed to create connection: ${await o.text()}`);const i=await o.json();return{id:i.id,version:i.version,status:i.status,metadata:n,data:t,key:r.key}}async update(t,n,r,s,o){const i=await p(n,o),c={sealed:i.ciphertext,version:r,status:s},h=await fetch(`${this.endpoint}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!h.ok)throw new Error(`Failed to update connection: ${await h.text()}`);const d=await h.json();return{id:d.id,metadata:d.metadata,version:d.version,status:d.status,data:n,key:i.key}}async get(t,n){const r=await fetch(`${this.endpoint}/${t}`,{method:"GET"});if(!r.ok)throw new Error(`Failed to get connection: ${await r.text()}`);const s=await r.json(),o=s.sealed[s.sealed.length-1],i=await U({ciphertext:o,key:n});return{id:s.id,status:s.status,version:s.version,metadata:s.metadata,data:i,key:n}}async close(t){const n=await fetch(`${this.endpoint}/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`Failed to close connection: ${await n.text()}`)}}class k{constructor(t){a(this,"nodeUrl");a(this,"authToken");a(this,"uxUrl");a(this,"theme");a(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,n,r,s){const o=new URL(this.uxUrl);o.pathname=t;const i=M({authToken:this.authToken,value:n,configuration:r});return o.hash=i,this.nodeUrl&&o.searchParams.set("nodeUrl",this.nodeUrl),this.theme&&o.searchParams.set("theme",JSON.stringify(this.theme)),this.locale&&o.searchParams.set("locale",this.locale),s&&(s.callback&&o.searchParams.set("callback_url",s.callback),s.redirectUri&&o.searchParams.set("redirect_uri",s.redirectUri)),o.toString()}createComponent(t,n,r,s){return new R(this.componentUrl(t,n,r,s),n,r)}createWithdrawalAssist(t,n,r){return this.createComponent("withdrawal-assist",t,n,r)}createConnectWallet(t,n,r){return this.createComponent("connect",t,n,r)}createDepositRequest(t,n,r){return this.createComponent("deposit-request",t,n,r)}createDepositAssist(t,n,r){return this.createComponent("deposit-assist",t,n,r)}}exports.AgentType=A;exports.CMType=l;exports.CodeVerificationStatus=v;exports.ConnectionManager=B;exports.EmbeddedComponent=R;exports.ErrorIdentifierCode=_;exports.HMType=m;exports.IdentityVerificationMethod=N;exports.OAuthProvider=I;exports.PersonType=f;exports.ProofStatus=y;exports.ProofTypes=D;exports.Status=w;exports.VASPSearchControl=L;exports.ValidationSections=g;exports.WarningIdentifierCode=C;exports.decodeFragmentToObject=x;exports.default=k;exports.getRefreshResult=P;
|
package/dist/cjs/notabene.d.ts
CHANGED
|
@@ -1308,7 +1308,7 @@ declare type Originator = {
|
|
|
1308
1308
|
* @public
|
|
1309
1309
|
*/
|
|
1310
1310
|
declare type OriginatorFields = {
|
|
1311
|
-
source?: Source;
|
|
1311
|
+
source?: Source | Source[];
|
|
1312
1312
|
};
|
|
1313
1313
|
|
|
1314
1314
|
/**
|
|
@@ -1690,7 +1690,6 @@ export declare interface TransactionOptions {
|
|
|
1690
1690
|
microTransfer?: {
|
|
1691
1691
|
destination: BlockchainAddress;
|
|
1692
1692
|
amountSubunits: string;
|
|
1693
|
-
timeout?: number;
|
|
1694
1693
|
};
|
|
1695
1694
|
fallbacks?: ProofTypes[];
|
|
1696
1695
|
deminimis?: ThresholdOptions;
|
|
@@ -1915,14 +1914,28 @@ export declare interface Wallet extends Agent {
|
|
|
1915
1914
|
* Represents a warning component message
|
|
1916
1915
|
* @param message - Warning message
|
|
1917
1916
|
* @param description - Description of the warning message
|
|
1917
|
+
* @param identifier - Identifier code of the warning message
|
|
1918
1918
|
* @public
|
|
1919
1919
|
*/
|
|
1920
1920
|
declare type Warning = {
|
|
1921
1921
|
type: CMType.WARNING;
|
|
1922
1922
|
message: string;
|
|
1923
1923
|
description?: string;
|
|
1924
|
+
identifier?: WarningIdentifierCode;
|
|
1924
1925
|
};
|
|
1925
1926
|
|
|
1927
|
+
/**
|
|
1928
|
+
* Identifier codes for warning messages
|
|
1929
|
+
* @public
|
|
1930
|
+
*/
|
|
1931
|
+
export declare enum WarningIdentifierCode {
|
|
1932
|
+
WALLET_ADDRESS_NOT_CONNECTED = "WALLET_ADDRESS_NOT_CONNECTED",
|
|
1933
|
+
WALLET_LOCKED = "WALLET_LOCKED",
|
|
1934
|
+
WALLET_UNREACHABLE = "WALLET_UNREACHABLE",
|
|
1935
|
+
JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE = "JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE",
|
|
1936
|
+
IDV_UNAVAILABLE = "IDV_UNAVAILABLE"
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1926
1939
|
/**
|
|
1927
1940
|
* An object representing a withdrawal transaction
|
|
1928
1941
|
* @public
|
package/dist/cjs/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.
|
|
13
|
+
"version": "2.13.0-next.1",
|
|
14
14
|
"source": "src/notabene.ts",
|
|
15
15
|
"main": "dist/cjs/notabene.cjs",
|
|
16
16
|
"module": "dist/esm/notabene.js",
|
package/dist/esm/notabene.d.ts
CHANGED
|
@@ -1308,7 +1308,7 @@ declare type Originator = {
|
|
|
1308
1308
|
* @public
|
|
1309
1309
|
*/
|
|
1310
1310
|
declare type OriginatorFields = {
|
|
1311
|
-
source?: Source;
|
|
1311
|
+
source?: Source | Source[];
|
|
1312
1312
|
};
|
|
1313
1313
|
|
|
1314
1314
|
/**
|
|
@@ -1690,7 +1690,6 @@ export declare interface TransactionOptions {
|
|
|
1690
1690
|
microTransfer?: {
|
|
1691
1691
|
destination: BlockchainAddress;
|
|
1692
1692
|
amountSubunits: string;
|
|
1693
|
-
timeout?: number;
|
|
1694
1693
|
};
|
|
1695
1694
|
fallbacks?: ProofTypes[];
|
|
1696
1695
|
deminimis?: ThresholdOptions;
|
|
@@ -1915,14 +1914,28 @@ export declare interface Wallet extends Agent {
|
|
|
1915
1914
|
* Represents a warning component message
|
|
1916
1915
|
* @param message - Warning message
|
|
1917
1916
|
* @param description - Description of the warning message
|
|
1917
|
+
* @param identifier - Identifier code of the warning message
|
|
1918
1918
|
* @public
|
|
1919
1919
|
*/
|
|
1920
1920
|
declare type Warning = {
|
|
1921
1921
|
type: CMType.WARNING;
|
|
1922
1922
|
message: string;
|
|
1923
1923
|
description?: string;
|
|
1924
|
+
identifier?: WarningIdentifierCode;
|
|
1924
1925
|
};
|
|
1925
1926
|
|
|
1927
|
+
/**
|
|
1928
|
+
* Identifier codes for warning messages
|
|
1929
|
+
* @public
|
|
1930
|
+
*/
|
|
1931
|
+
export declare enum WarningIdentifierCode {
|
|
1932
|
+
WALLET_ADDRESS_NOT_CONNECTED = "WALLET_ADDRESS_NOT_CONNECTED",
|
|
1933
|
+
WALLET_LOCKED = "WALLET_LOCKED",
|
|
1934
|
+
WALLET_UNREACHABLE = "WALLET_UNREACHABLE",
|
|
1935
|
+
JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE = "JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE",
|
|
1936
|
+
IDV_UNAVAILABLE = "IDV_UNAVAILABLE"
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1926
1939
|
/**
|
|
1927
1940
|
* An object representing a withdrawal transaction
|
|
1928
1941
|
* @public
|
package/dist/esm/notabene.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (e, t, n) =>
|
|
4
|
-
var
|
|
5
|
-
class
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var L = (e, t, n) => t in e ? f(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var o = (e, t, n) => L(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
var N = /* @__PURE__ */ ((e) => (e.PRIVATE = "WALLET", e.VASP = "VASP", e))(N || {}), v = /* @__PURE__ */ ((e) => (e.NATURAL = "natural", e.LEGAL = "legal", e.SELF = "self", e))(v || {}), I = /* @__PURE__ */ ((e) => (e.EMPTY = "empty", e.VERIFY = "verify", e.PENDING = "pending", e.VERIFIED = "verified", e.BANNED = "banned", e))(I || {}), _ = /* @__PURE__ */ ((e) => (e.ALLOWED = "allowed", e.PENDING = "pending", e))(_ || {}), g = /* @__PURE__ */ ((e) => (e.SMS = "sms", e.EMAIL = "email", e))(g || {}), D = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.APPROVED = "approved", e.FAILED = "failed", e.EXPIRED = "expired", e.MAX_ATTEMPTS_REACHED = "max_attempts_reached", e.UNREACHABLE = "unreachable", e))(D || {}), U = /* @__PURE__ */ ((e) => (e.COINBASE = "coinbase", e))(U || {}), R = /* @__PURE__ */ ((e) => (e.ASSET = "asset", e.DESTINATION = "destination", e.COUNTERPARTY = "counterparty", e.AGENT = "agent", e))(R || {}), l = /* @__PURE__ */ ((e) => (e.COMPLETE = "complete", e.RESIZE = "resize", e.RESULT = "result", e.READY = "ready", e.INVALID = "invalid", e.ERROR = "error", e.CANCEL = "cancel", e.WARNING = "warning", e.INFO = "info", e))(l || {}), C = /* @__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))(C || {}), O = /* @__PURE__ */ ((e) => (e.WALLET_ADDRESS_NOT_CONNECTED = "WALLET_ADDRESS_NOT_CONNECTED", e.WALLET_LOCKED = "WALLET_LOCKED", e.WALLET_UNREACHABLE = "WALLET_UNREACHABLE", e.JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE = "JURISDICTIONAL_REQUIREMENTS_UNAVAILABLE", e.IDV_UNAVAILABLE = "IDV_UNAVAILABLE", e))(O || {}), p = /* @__PURE__ */ ((e) => (e.UPDATE = "update", e.REQUEST_RESPONSE = "requestResponse", e))(p || {}), b = /* @__PURE__ */ ((e) => (e.PENDING = "pending", e.FAILED = "rejected", e.FLAGGED = "flagged", e.VERIFIED = "verified", e))(b || {}), y = /* @__PURE__ */ ((e) => (e.SelfDeclaration = "self-declaration", e.SIWE = "siwe", e.SIWX = "siwx", e.SOL_SIWX = "sol-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.XLM_ED25519 = "xlm-ed25519", e.CIP8 = "cip-8", e.COSMOS = "cosmos-ecdsa", e.MicroTransfer = "microtransfer", e.Screenshot = "screenshot", e.Connect = "connect", e.CONCORDIUM = "concordium", e))(y || {});
|
|
5
|
+
class x {
|
|
6
6
|
constructor() {
|
|
7
7
|
o(this, "listeners", /* @__PURE__ */ new Map());
|
|
8
8
|
o(this, "port");
|
|
@@ -42,8 +42,8 @@ class O {
|
|
|
42
42
|
* @param callback - The callback function to remove
|
|
43
43
|
*/
|
|
44
44
|
off(t, n) {
|
|
45
|
-
const
|
|
46
|
-
|
|
45
|
+
const s = this.listeners.get(t);
|
|
46
|
+
s && (s.delete(n), s.size === 0 && this.listeners.delete(t));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Internal message handler for processing received messages.
|
|
@@ -56,8 +56,8 @@ class O {
|
|
|
56
56
|
handleMessage(t) {
|
|
57
57
|
const n = t.data;
|
|
58
58
|
if (typeof n == "object" && n !== null && "type" in n) {
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
const s = n.type, r = this.listeners.get(s);
|
|
60
|
+
r && r.forEach((i) => i(n));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -68,13 +68,13 @@ class O {
|
|
|
68
68
|
this.port && this.port.postMessage(t);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
class
|
|
71
|
+
class S {
|
|
72
72
|
/**
|
|
73
73
|
* Creates an instance of EmbeddedComponent.
|
|
74
74
|
* @param url - The URL of the embedded component
|
|
75
75
|
* @param value - The initial transaction value
|
|
76
76
|
*/
|
|
77
|
-
constructor(t, n,
|
|
77
|
+
constructor(t, n, s) {
|
|
78
78
|
o(this, "_url");
|
|
79
79
|
o(this, "_value");
|
|
80
80
|
o(this, "_options");
|
|
@@ -82,10 +82,10 @@ class x {
|
|
|
82
82
|
o(this, "iframe");
|
|
83
83
|
o(this, "eventManager");
|
|
84
84
|
o(this, "modal");
|
|
85
|
-
this._url = t, this._value = n, this._options =
|
|
86
|
-
|
|
87
|
-
}), this.on(l.RESIZE, (
|
|
88
|
-
|
|
85
|
+
this._url = t, this._value = n, this._options = s, this.eventManager = new x(), this.on(l.INVALID, (r) => {
|
|
86
|
+
r.type === l.INVALID && (this._errors = r.errors, this._value = r.value);
|
|
87
|
+
}), this.on(l.RESIZE, (r) => {
|
|
88
|
+
r.type === l.RESIZE && this.iframe && (this.iframe.style.height = `${r.height}px`);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -129,11 +129,11 @@ class x {
|
|
|
129
129
|
* @param parent - The parent element to embed the component into
|
|
130
130
|
*/
|
|
131
131
|
embed(t, n = !1) {
|
|
132
|
-
var
|
|
132
|
+
var s, r;
|
|
133
133
|
this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (n ? "" : "&embedded=true"), this.iframe.allow = "web-share; clipboard-write; hid; bluetooth;", this.iframe.style.width = "100%", this.iframe.style.height = "0px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", this.iframe.scrolling = "no", t.appendChild(this.iframe), window.addEventListener("message", (i) => {
|
|
134
134
|
var a, c;
|
|
135
135
|
i.source === ((a = this.iframe) == null ? void 0 : a.contentWindow) && ((c = this.eventManager) == null || c.setPort(i.ports[0]));
|
|
136
|
-
}), (
|
|
136
|
+
}), (r = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || r.focus();
|
|
137
137
|
}
|
|
138
138
|
removeEmbed() {
|
|
139
139
|
this.iframe && this.iframe.remove();
|
|
@@ -174,13 +174,13 @@ class x {
|
|
|
174
174
|
*/
|
|
175
175
|
completion() {
|
|
176
176
|
return new Promise((t, n) => {
|
|
177
|
-
let
|
|
177
|
+
let s, r, i;
|
|
178
178
|
function a() {
|
|
179
|
-
|
|
179
|
+
s && s(), r && r(), i && i();
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
s = this.on(l.COMPLETE, (c) => {
|
|
182
182
|
t(c.response), a();
|
|
183
|
-
}),
|
|
183
|
+
}), r = this.on(l.CANCEL, () => {
|
|
184
184
|
n(new Error("User cancelled")), a();
|
|
185
185
|
}), i = this.on("error", (c) => {
|
|
186
186
|
n(new Error(c.message)), a();
|
|
@@ -223,63 +223,63 @@ class x {
|
|
|
223
223
|
"_blank",
|
|
224
224
|
"popup=true,width=600,height=600"
|
|
225
225
|
);
|
|
226
|
-
window.addEventListener("message", (
|
|
226
|
+
window.addEventListener("message", (r) => {
|
|
227
227
|
var i;
|
|
228
|
-
|
|
228
|
+
r.source === t && (console.log("received message from popup", r.data), (i = this.eventManager) == null || i.setPort(r.ports[0]));
|
|
229
229
|
});
|
|
230
230
|
const n = this.on(l.CANCEL, () => {
|
|
231
231
|
t == null || t.close();
|
|
232
|
-
}),
|
|
232
|
+
}), s = this.on(l.COMPLETE, () => {
|
|
233
233
|
t == null || t.close();
|
|
234
234
|
});
|
|
235
235
|
return this.completion().finally(() => {
|
|
236
|
-
n(),
|
|
236
|
+
n(), s();
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function T(e) {
|
|
241
241
|
return Object.entries(e).map(([t, n]) => {
|
|
242
242
|
if (n == null) return;
|
|
243
|
-
const
|
|
243
|
+
const s = encodeURIComponent(t), r = encodeURIComponent(
|
|
244
244
|
typeof n == "object" ? JSON.stringify(n) : String(n)
|
|
245
245
|
// Use String() to handle all primitive types
|
|
246
246
|
);
|
|
247
|
-
return `${
|
|
247
|
+
return `${s}=${r}`;
|
|
248
248
|
}).filter((t) => t !== void 0).join("&");
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function B(e) {
|
|
251
251
|
const t = e.slice(1);
|
|
252
252
|
return t ? t.split("&").filter(Boolean).reduce(
|
|
253
|
-
(
|
|
254
|
-
const [i, a] =
|
|
255
|
-
return i && (
|
|
253
|
+
(s, r) => {
|
|
254
|
+
const [i, a] = r.split("=");
|
|
255
|
+
return i && (s[decodeURIComponent(i)] = a ? decodeURIComponent(a) : ""), s;
|
|
256
256
|
},
|
|
257
257
|
{}
|
|
258
258
|
) : {};
|
|
259
259
|
}
|
|
260
|
-
async function
|
|
261
|
-
const n = JSON.stringify(e),
|
|
260
|
+
async function m(e, t) {
|
|
261
|
+
const n = JSON.stringify(e), s = new TextEncoder(), r = t ? u(t) : crypto.getRandomValues(new Uint8Array(32)), i = await crypto.subtle.importKey(
|
|
262
262
|
"raw",
|
|
263
|
-
|
|
263
|
+
r,
|
|
264
264
|
{ name: "AES-GCM" },
|
|
265
265
|
!1,
|
|
266
266
|
["encrypt"]
|
|
267
267
|
), a = crypto.getRandomValues(new Uint8Array(12)), c = await crypto.subtle.encrypt(
|
|
268
268
|
{ name: "AES-GCM", iv: a },
|
|
269
269
|
i,
|
|
270
|
-
|
|
270
|
+
s.encode(n)
|
|
271
271
|
);
|
|
272
272
|
return {
|
|
273
|
-
ciphertext: `${
|
|
274
|
-
key:
|
|
273
|
+
ciphertext: `${E(a)}-${E(c)}`,
|
|
274
|
+
key: E(r)
|
|
275
275
|
};
|
|
276
276
|
}
|
|
277
|
-
async function
|
|
278
|
-
const [n,
|
|
277
|
+
async function A({ ciphertext: e, key: t }) {
|
|
278
|
+
const [n, s] = e.split("-"), r = new Uint8Array(
|
|
279
279
|
atob(t).split("").map((w) => w.charCodeAt(0))
|
|
280
|
-
), i =
|
|
280
|
+
), i = u(n), a = u(s), c = await crypto.subtle.importKey(
|
|
281
281
|
"raw",
|
|
282
|
-
|
|
282
|
+
r,
|
|
283
283
|
{ name: "AES-GCM" },
|
|
284
284
|
!1,
|
|
285
285
|
["decrypt"]
|
|
@@ -290,20 +290,20 @@ async function f({ ciphertext: e, key: t }) {
|
|
|
290
290
|
);
|
|
291
291
|
return JSON.parse(h.decode(d));
|
|
292
292
|
}
|
|
293
|
-
function
|
|
293
|
+
function E(e) {
|
|
294
294
|
const t = new Uint8Array(e);
|
|
295
295
|
let n = "";
|
|
296
|
-
for (let
|
|
297
|
-
n += String.fromCharCode(t[
|
|
296
|
+
for (let s = 0; s < t.length; s++)
|
|
297
|
+
n += String.fromCharCode(t[s]);
|
|
298
298
|
return btoa(n);
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function u(e) {
|
|
301
301
|
const t = atob(e), n = new Uint8Array(t.length);
|
|
302
|
-
for (let
|
|
303
|
-
n[
|
|
302
|
+
for (let s = 0; s < t.length; s++)
|
|
303
|
+
n[s] = t.charCodeAt(s);
|
|
304
304
|
return n;
|
|
305
305
|
}
|
|
306
|
-
async function
|
|
306
|
+
async function k(e) {
|
|
307
307
|
const t = await fetch(e.url, {
|
|
308
308
|
method: "GET"
|
|
309
309
|
});
|
|
@@ -312,26 +312,26 @@ async function P(e) {
|
|
|
312
312
|
const n = await t.json();
|
|
313
313
|
if (!n.id || !n.metadata || !n.status || !n.sealed)
|
|
314
314
|
throw new Error("Data missing from server response");
|
|
315
|
-
const
|
|
315
|
+
const s = {
|
|
316
316
|
id: n.id,
|
|
317
317
|
metadata: n.metadata,
|
|
318
318
|
status: n.status
|
|
319
319
|
};
|
|
320
320
|
if (n.status === "closed")
|
|
321
|
-
return
|
|
322
|
-
const
|
|
323
|
-
ciphertext:
|
|
321
|
+
return s;
|
|
322
|
+
const r = n.sealed[n.sealed.length - 1], i = await A({
|
|
323
|
+
ciphertext: r,
|
|
324
324
|
key: e.key
|
|
325
325
|
});
|
|
326
326
|
return n.status === "completed" ? {
|
|
327
|
-
...
|
|
327
|
+
...s,
|
|
328
328
|
result: i.result
|
|
329
329
|
} : {
|
|
330
|
-
...
|
|
330
|
+
...s,
|
|
331
331
|
tx: i.tx
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
|
-
class
|
|
334
|
+
class P {
|
|
335
335
|
constructor(t) {
|
|
336
336
|
o(this, "endpoint");
|
|
337
337
|
this.endpoint = t;
|
|
@@ -344,15 +344,15 @@ class T {
|
|
|
344
344
|
* @returns Promise resolving to connection details including ID, version, and encryption key
|
|
345
345
|
*/
|
|
346
346
|
async create(t, n) {
|
|
347
|
-
const
|
|
347
|
+
const s = await m(t), r = {
|
|
348
348
|
metadata: n,
|
|
349
|
-
sealed:
|
|
349
|
+
sealed: s.ciphertext
|
|
350
350
|
}, i = await fetch(this.endpoint, {
|
|
351
351
|
method: "POST",
|
|
352
352
|
headers: {
|
|
353
353
|
"Content-Type": "application/json"
|
|
354
354
|
},
|
|
355
|
-
body: JSON.stringify(
|
|
355
|
+
body: JSON.stringify(r)
|
|
356
356
|
});
|
|
357
357
|
if (!i.ok)
|
|
358
358
|
throw new Error(`Failed to create connection: ${await i.text()}`);
|
|
@@ -363,7 +363,7 @@ class T {
|
|
|
363
363
|
status: a.status,
|
|
364
364
|
metadata: n,
|
|
365
365
|
data: t,
|
|
366
|
-
key:
|
|
366
|
+
key: s.key
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
369
|
/**
|
|
@@ -376,11 +376,11 @@ class T {
|
|
|
376
376
|
* @param key Current encryption key
|
|
377
377
|
* @returns Promise resolving to updated connection details including new encryption key
|
|
378
378
|
*/
|
|
379
|
-
async update(t, n,
|
|
380
|
-
const a = await
|
|
379
|
+
async update(t, n, s, r, i) {
|
|
380
|
+
const a = await m(n, i), c = {
|
|
381
381
|
sealed: a.ciphertext,
|
|
382
|
-
version:
|
|
383
|
-
status:
|
|
382
|
+
version: s,
|
|
383
|
+
status: r
|
|
384
384
|
}, h = await fetch(`${this.endpoint}/${t}`, {
|
|
385
385
|
method: "PATCH",
|
|
386
386
|
headers: {
|
|
@@ -408,20 +408,20 @@ class T {
|
|
|
408
408
|
* @returns Promise resolving to connection details including decrypted data
|
|
409
409
|
*/
|
|
410
410
|
async get(t, n) {
|
|
411
|
-
const
|
|
411
|
+
const s = await fetch(`${this.endpoint}/${t}`, {
|
|
412
412
|
method: "GET"
|
|
413
413
|
});
|
|
414
|
-
if (!
|
|
415
|
-
throw new Error(`Failed to get connection: ${await
|
|
416
|
-
const
|
|
414
|
+
if (!s.ok)
|
|
415
|
+
throw new Error(`Failed to get connection: ${await s.text()}`);
|
|
416
|
+
const r = await s.json(), i = r.sealed[r.sealed.length - 1], a = await A({
|
|
417
417
|
ciphertext: i,
|
|
418
418
|
key: n
|
|
419
419
|
});
|
|
420
420
|
return {
|
|
421
|
-
id:
|
|
422
|
-
status:
|
|
423
|
-
version:
|
|
424
|
-
metadata:
|
|
421
|
+
id: r.id,
|
|
422
|
+
status: r.status,
|
|
423
|
+
version: r.version,
|
|
424
|
+
metadata: r.metadata,
|
|
425
425
|
data: a,
|
|
426
426
|
key: n
|
|
427
427
|
};
|
|
@@ -439,7 +439,7 @@ class T {
|
|
|
439
439
|
throw new Error(`Failed to close connection: ${await n.text()}`);
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
class
|
|
442
|
+
class F {
|
|
443
443
|
/**
|
|
444
444
|
* Creates a new instance of the Notabene SDK
|
|
445
445
|
*
|
|
@@ -463,15 +463,15 @@ class B {
|
|
|
463
463
|
* @returns component URL
|
|
464
464
|
* @internal
|
|
465
465
|
*/
|
|
466
|
-
componentUrl(t, n,
|
|
466
|
+
componentUrl(t, n, s, r) {
|
|
467
467
|
const i = new URL(this.uxUrl);
|
|
468
468
|
i.pathname = t;
|
|
469
|
-
const a =
|
|
469
|
+
const a = T({
|
|
470
470
|
authToken: this.authToken,
|
|
471
471
|
value: n,
|
|
472
|
-
configuration:
|
|
472
|
+
configuration: s
|
|
473
473
|
});
|
|
474
|
-
return i.hash = a, 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),
|
|
474
|
+
return i.hash = a, 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();
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
477
477
|
* Creates a new embedded component
|
|
@@ -483,11 +483,11 @@ class B {
|
|
|
483
483
|
* @returns A new EmbeddedComponent instance
|
|
484
484
|
* @internal
|
|
485
485
|
*/
|
|
486
|
-
createComponent(t, n,
|
|
487
|
-
return new
|
|
488
|
-
this.componentUrl(t, n,
|
|
486
|
+
createComponent(t, n, s, r) {
|
|
487
|
+
return new S(
|
|
488
|
+
this.componentUrl(t, n, s, r),
|
|
489
489
|
n,
|
|
490
|
-
|
|
490
|
+
s
|
|
491
491
|
);
|
|
492
492
|
}
|
|
493
493
|
/**
|
|
@@ -498,12 +498,12 @@ class B {
|
|
|
498
498
|
* @param callbacks - Optional callback configuration
|
|
499
499
|
* @returns A new EmbeddedComponent instance for withdrawal assistance
|
|
500
500
|
*/
|
|
501
|
-
createWithdrawalAssist(t, n,
|
|
501
|
+
createWithdrawalAssist(t, n, s) {
|
|
502
502
|
return this.createComponent(
|
|
503
503
|
"withdrawal-assist",
|
|
504
504
|
t,
|
|
505
505
|
n,
|
|
506
|
-
|
|
506
|
+
s
|
|
507
507
|
);
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
@@ -515,12 +515,12 @@ class B {
|
|
|
515
515
|
* @returns A new EmbeddedComponent instance for connection
|
|
516
516
|
* @alpha
|
|
517
517
|
*/
|
|
518
|
-
createConnectWallet(t, n,
|
|
518
|
+
createConnectWallet(t, n, s) {
|
|
519
519
|
return this.createComponent(
|
|
520
520
|
"connect",
|
|
521
521
|
t,
|
|
522
522
|
n,
|
|
523
|
-
|
|
523
|
+
s
|
|
524
524
|
);
|
|
525
525
|
}
|
|
526
526
|
/**
|
|
@@ -532,12 +532,12 @@ class B {
|
|
|
532
532
|
* @returns A new EmbeddedComponent instance for deposit requests
|
|
533
533
|
* @public
|
|
534
534
|
*/
|
|
535
|
-
createDepositRequest(t, n,
|
|
535
|
+
createDepositRequest(t, n, s) {
|
|
536
536
|
return this.createComponent(
|
|
537
537
|
"deposit-request",
|
|
538
538
|
t,
|
|
539
539
|
n,
|
|
540
|
-
|
|
540
|
+
s
|
|
541
541
|
);
|
|
542
542
|
}
|
|
543
543
|
/**
|
|
@@ -549,32 +549,33 @@ class B {
|
|
|
549
549
|
* @returns A new EmbeddedComponent instance for deposit assistance
|
|
550
550
|
* @public
|
|
551
551
|
*/
|
|
552
|
-
createDepositAssist(t, n,
|
|
552
|
+
createDepositAssist(t, n, s) {
|
|
553
553
|
return this.createComponent(
|
|
554
554
|
"deposit-assist",
|
|
555
555
|
t,
|
|
556
556
|
n,
|
|
557
|
-
|
|
557
|
+
s
|
|
558
558
|
);
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
export {
|
|
562
|
-
|
|
562
|
+
N as AgentType,
|
|
563
563
|
l as CMType,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
564
|
+
D as CodeVerificationStatus,
|
|
565
|
+
P as ConnectionManager,
|
|
566
|
+
S as EmbeddedComponent,
|
|
567
|
+
C as ErrorIdentifierCode,
|
|
568
568
|
p as HMType,
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
B as
|
|
579
|
-
|
|
569
|
+
g as IdentityVerificationMethod,
|
|
570
|
+
U as OAuthProvider,
|
|
571
|
+
v as PersonType,
|
|
572
|
+
b as ProofStatus,
|
|
573
|
+
y as ProofTypes,
|
|
574
|
+
I as Status,
|
|
575
|
+
_ as VASPSearchControl,
|
|
576
|
+
R as ValidationSections,
|
|
577
|
+
O as WarningIdentifierCode,
|
|
578
|
+
B as decodeFragmentToObject,
|
|
579
|
+
F as default,
|
|
580
|
+
k as getRefreshResult
|
|
580
581
|
};
|