@notabene/javascript-sdk 2.0.0-next.20 → 2.0.0-next.21

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
@@ -196,7 +196,7 @@ Specify the beneficiary address as `destination` using one of the following form
196
196
  - [BIP-21](https://en.bitcoin.it/wiki/BIP_0021) Bitcoin URI
197
197
  - Native blockchain address
198
198
 
199
- ### Destination address
199
+ ### Asset Price
200
200
 
201
201
  The price of the asset is used to determine certain rules based on thresholds. We recommond you pass in your price like this:
202
202
 
@@ -282,6 +282,11 @@ const options: TransactionOptions = {
282
282
  timeout: 86440,
283
283
  },
284
284
  fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self_declaration']
285
+ deminimis: {
286
+ threshold: 1000,
287
+ currency: 'EUR',
288
+ proofTypes: [ProofTypes.SelfDeclaration]
289
+ }
285
290
  },
286
291
  allowedAgentTypes: [AgentType.PRIVATE, AgentType.VASP], // js ['WALLET','VASP']
287
292
  allowedCounterpartyTypes: [
@@ -315,6 +320,7 @@ const options: TransactionOptions = {
315
320
  addUnknown: true, // Allow users to add a missing VASP - Defaults to false
316
321
  onlyActive: true, // Only list active VASPs - Default false
317
322
  },
323
+ hide: [ValidationSections.ASSET, ValidationSections.DESTINATION] // Don't show specific sections of component
318
324
  },
319
325
  };
320
326
  const withdrawal = notabene.createWithdrawalAssist(tx, options);
package/dist/notabene.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var v=(t,e,s)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>v(t,typeof e!="symbol"?e+"":e,s);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||{}),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||{}),l=(t=>(t.UPDATE="update",t.REQUEST_RESPONSE="requestResponse",t))(l||{}),p=(t=>(t.PENDING="pending",t.FAILED="rejected",t.FLAGGED="flagged",t.VERIFIED="verified",t))(p||{}),f=(t=>(t.SelfDeclaration="self-declaration",t.PersonalSignEIP191="eip-191",t.SIWE="siwe",t.PersonalSignEIP712="eip-712",t.PersonalSignBIP137="bip-137",t.PersonalSignXPUB="xpub",t.MicroTransfer="microtransfer",t.Screenshot="screenshot",t))(f||{});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,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){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 E{constructor(e,s,r){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=s,this._options=r,this.eventManager=new b,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(e){const s=document.querySelector(e);if(!s)throw new Error(`parentID ${e} not found`);this.embed(s)}embed(e,s=!1){var r,i;this.removeEmbed(),this.iframe=document.createElement("iframe"),this.iframe.src=this.url+(s?"":"&embedded=true"),this.iframe.allow="web-share",this.iframe.style.width="100%",this.iframe.style.height="100px",this.iframe.style.border="none",this.iframe.style.overflow="hidden",e.appendChild(this.iframe),window.addEventListener("message",n=>{var h,d;n.source===((h=this.iframe)==null?void 0:h.contentWindow)&&((d=this.eventManager)==null||d.setPort(n.ports[0]))}),(i=(r=this.iframe)==null?void 0:r.contentWindow)==null||i.focus()}removeEmbed(){this.iframe&&this.iframe.remove()}send(e){this.eventManager.send(e)}on(e,s){this.eventManager.on(e,s)}off(e,s){this.eventManager.off(e,s)}update(e,s){this._value=e,s&&(this._options=s),this.send({type:l.UPDATE,value:e,options:this._options})}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="white",this.modal.style.maxWidth="100vw",this.modal.style.maxHeight="100vh",this.modal.style.width="600px",this.modal.style.height="600px",document.body.appendChild(this.modal),this.embed(this.modal,!0),this.on(a.CANCEL,()=>{this.closeModal()}),this.on(a.COMPLETE,()=>{this.closeModal()}),this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion()}closeModal(){var e;this.modal&&((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 w{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 h=I({authToken:this.authToken,value:s,configuration:r});return n.hash=h,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 E(this.componentUrl(e,s,r,i),s,r)}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,h]=i.split("=");return r[decodeURIComponent(n)]=decodeURIComponent(h),r},{})}}exports.AgentType=c;exports.CMType=a;exports.EmbeddedComponent=E;exports.HMType=l;exports.PersonType=m;exports.ProofStatus=p;exports.ProofTypes=f;exports.Status=u;exports.default=w;
1
+ "use strict";var v=Object.defineProperty;var I=(t,e,s)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>I(t,typeof e!="symbol"?e+"":e,s);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.ASSET="asset",t.DESTINATION="destination",t.COUNTERPARTY="counterparty",t.AGENT="agent",t))(E||{}),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||{}),l=(t=>(t.UPDATE="update",t.REQUEST_RESPONSE="requestResponse",t))(l||{}),p=(t=>(t.PENDING="pending",t.FAILED="rejected",t.FLAGGED="flagged",t.VERIFIED="verified",t))(p||{}),f=(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.BIP137_XPUB="xpub",t.ED25519="ed25519",t.MicroTransfer="microtransfer",t.Screenshot="screenshot",t))(f||{});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,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){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 g{constructor(e,s,r){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=s,this._options=r,this.eventManager=new b,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(e){const s=document.querySelector(e);if(!s)throw new Error(`parentID ${e} not found`);this.embed(s)}embed(e,s=!1){var r,i;this.removeEmbed(),this.iframe=document.createElement("iframe"),this.iframe.src=this.url+(s?"":"&embedded=true"),this.iframe.allow="web-share",this.iframe.style.width="100%",this.iframe.style.height="100px",this.iframe.style.border="none",this.iframe.style.overflow="hidden",e.appendChild(this.iframe),window.addEventListener("message",n=>{var h,d;n.source===((h=this.iframe)==null?void 0:h.contentWindow)&&((d=this.eventManager)==null||d.setPort(n.ports[0]))}),(i=(r=this.iframe)==null?void 0:r.contentWindow)==null||i.focus()}removeEmbed(){this.iframe&&this.iframe.remove()}send(e){this.eventManager.send(e)}on(e,s){this.eventManager.on(e,s)}off(e,s){this.eventManager.off(e,s)}update(e,s){this._value=e,s&&(this._options=s),this.send({type:l.UPDATE,value:e,options:this._options})}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="white",this.modal.style.maxWidth="100vw",this.modal.style.maxHeight="100vh",this.modal.style.width="600px",this.modal.style.height="600px",document.body.appendChild(this.modal),this.embed(this.modal,!0),this.on(a.CANCEL,()=>{this.closeModal()}),this.on(a.COMPLETE,()=>{this.closeModal()}),this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion()}closeModal(){var e;this.modal&&((e=this.modal)==null||e.close(),this.modal.remove(),this.modal=void 0)}}function w(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 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,s,r,i){const n=new URL(this.uxUrl);n.pathname=e;const h=w({authToken:this.authToken,value:s,configuration:r});return n.hash=h,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 g(this.componentUrl(e,s,r,i),s,r)}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,h]=i.split("=");return r[decodeURIComponent(n)]=decodeURIComponent(h),r},{})}}exports.AgentType=c;exports.CMType=a;exports.EmbeddedComponent=g;exports.HMType=l;exports.PersonType=m;exports.ProofStatus=p;exports.ProofTypes=f;exports.Status=u;exports.ValidationSections=E;exports.default=U;
@@ -762,8 +762,9 @@ export declare type MessageCallback<T> = (message: ComponentMessage<T>) => void;
762
762
  */
763
763
  export declare interface MicroTransferProof extends OwnershipProof {
764
764
  type: ProofTypes.MicroTransfer;
765
- txhash: string;
765
+ proof: string;
766
766
  chain: CAIP2;
767
+ asset: CAIP19;
767
768
  destination: BlockchainAddress;
768
769
  amountSubunits: string;
769
770
  }
@@ -1171,11 +1172,11 @@ export declare enum ProofStatus {
1171
1172
  * @remarks
1172
1173
  * Supported proof types:
1173
1174
  * - SelfDeclaration: User self-declares ownership without cryptographic proof
1174
- * - PersonalSignEIP191: Ethereum personal signature following EIP-191 standard
1175
+ * - EIP191: Ethereum personal signature following EIP-191 standard
1175
1176
  * - SIWE: Sign-In with Ethereum message signature (EIP-4361)
1176
- * - PersonalSignEIP712: Ethereum typed data signature following EIP-712 standard
1177
- * - PersonalSignBIP137: Bitcoin message signature following BIP-137
1178
- * - PersonalSignXPUB: Extended public key signature for HD wallets
1177
+ * - EIP712: Ethereum typed data signature following EIP-712 standard
1178
+ * - BIP137: Bitcoin message signature following BIP-137
1179
+ * - XPUB: Extended public key signature for HD wallets
1179
1180
  * - MicroTransfer: Proof via small blockchain transaction
1180
1181
  * - Screenshot: Image proof of ownership/access
1181
1182
  *
@@ -1187,11 +1188,14 @@ export declare enum ProofStatus {
1187
1188
  */
1188
1189
  export declare enum ProofTypes {
1189
1190
  SelfDeclaration = "self-declaration",
1190
- PersonalSignEIP191 = "eip-191",
1191
1191
  SIWE = "siwe",
1192
- PersonalSignEIP712 = "eip-712",
1193
- PersonalSignBIP137 = "bip-137",
1194
- PersonalSignXPUB = "xpub",
1192
+ SIWX = "siwx",
1193
+ EIP191 = "eip-191",
1194
+ EIP712 = "eip-712",
1195
+ EIP1271 = "eip-1271",
1196
+ BIP137 = "bip-137",
1197
+ BIP137_XPUB = "xpub",
1198
+ ED25519 = "ed25519",
1195
1199
  MicroTransfer = "microtransfer",
1196
1200
  Screenshot = "screenshot"
1197
1201
  }
@@ -1242,7 +1246,7 @@ export declare interface ScreenshotProof extends OwnershipProof {
1242
1246
  * @public
1243
1247
  */
1244
1248
  export declare interface SignatureProof extends OwnershipProof {
1245
- type: ProofTypes.PersonalSignEIP191 | ProofTypes.PersonalSignEIP712 | ProofTypes.PersonalSignBIP137 | ProofTypes.SIWE | ProofTypes.PersonalSignXPUB;
1249
+ type: ProofTypes.EIP191 | ProofTypes.EIP712 | ProofTypes.EIP1271 | ProofTypes.BIP137 | ProofTypes.BIP137_XPUB | ProofTypes.ED25519 | ProofTypes.SIWX | ProofTypes.SIWE;
1246
1250
  proof: string;
1247
1251
  attestation: string;
1248
1252
  wallet_provider: string;
@@ -1277,6 +1281,23 @@ export declare type Theme = {
1277
1281
  logo: string;
1278
1282
  };
1279
1283
 
1284
+ /**
1285
+ * Specify what to do under the provided threshold.
1286
+ *
1287
+ * Eg. to allow self-declaration for all transactions under 1000 EUR
1288
+ *
1289
+ * Note to support threshold you MUST include the Asset Price in the Transaction
1290
+ *
1291
+ * @see {@link Transaction} Transaction object
1292
+ *
1293
+ * @public
1294
+ */
1295
+ export declare interface ThresholdOptions {
1296
+ threshold: number;
1297
+ currency: ISOCurrency;
1298
+ proofTypes?: ProofTypes[];
1299
+ }
1300
+
1280
1301
  /**
1281
1302
  * Core transaction interface representing a crypto asset transfer between parties
1282
1303
  *
@@ -1330,11 +1351,13 @@ export declare interface TransactionOptions {
1330
1351
  timeout?: number;
1331
1352
  };
1332
1353
  fallbacks?: ProofTypes[];
1354
+ deminimis?: ThresholdOptions;
1333
1355
  };
1334
1356
  allowedAgentTypes?: AgentType[];
1335
1357
  allowedCounterpartyTypes?: PersonType[];
1336
1358
  fields?: FieldTypes;
1337
1359
  vasps?: VASPOptions;
1360
+ hide?: ValidationSections[];
1338
1361
  }
1339
1362
 
1340
1363
  /**
@@ -1482,6 +1505,18 @@ export declare type ValidationError = {
1482
1505
  message: string;
1483
1506
  };
1484
1507
 
1508
+ /**
1509
+ * Sections in a WithdrawalAssist screen
1510
+ *
1511
+ * @alpha
1512
+ */
1513
+ export declare enum ValidationSections {
1514
+ ASSET = "asset",
1515
+ DESTINATION = "destination",
1516
+ COUNTERPARTY = "counterparty",
1517
+ AGENT = "agent"
1518
+ }
1519
+
1485
1520
  /**
1486
1521
  * A VASP agent acting on behalf of the counterparty
1487
1522
  * @public
package/dist/notabene.js CHANGED
@@ -1,8 +1,8 @@
1
1
  var c = Object.defineProperty;
2
- var m = (t, e, s) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
- var o = (t, e, s) => m(t, typeof e != "symbol" ? e + "" : e, s);
4
- var u = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(u || {}), f = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(f || {}), 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.ERROR = "error", t.CANCEL = "cancel", t))(a || {}), d = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(d || {}), p = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(p || {}), g = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.PersonalSignEIP191 = "eip-191", t.SIWE = "siwe", t.PersonalSignEIP712 = "eip-712", t.PersonalSignBIP137 = "bip-137", t.PersonalSignXPUB = "xpub", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t))(g || {});
5
- class v {
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 || {}), p = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(p || {}), f = /* @__PURE__ */ ((t) => (t.ASSET = "asset", t.DESTINATION = "destination", t.COUNTERPARTY = "counterparty", t.AGENT = "agent", t))(f || {}), a = /* @__PURE__ */ ((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 = /* @__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 || {}), v = /* @__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.BIP137_XPUB = "xpub", t.ED25519 = "ed25519", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t))(v || {});
5
+ class I {
6
6
  constructor() {
7
7
  o(this, "listeners", /* @__PURE__ */ new Map());
8
8
  o(this, "port");
@@ -28,8 +28,8 @@ class v {
28
28
  * @param messageType - The type of message to listen for
29
29
  * @param callback - The callback function to execute when matching messages are received
30
30
  */
31
- on(e, s) {
32
- this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(s);
31
+ on(e, r) {
32
+ this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(r);
33
33
  }
34
34
  /**
35
35
  * Removes a callback for a specific message type.
@@ -40,9 +40,9 @@ class v {
40
40
  * @param messageType - The type of message to remove listener from
41
41
  * @param callback - The callback function to remove
42
42
  */
43
- off(e, s) {
44
- const r = this.listeners.get(e);
45
- r && (r.delete(s), r.size === 0 && this.listeners.delete(e));
43
+ off(e, r) {
44
+ const s = this.listeners.get(e);
45
+ s && (s.delete(r), s.size === 0 && this.listeners.delete(e));
46
46
  }
47
47
  /**
48
48
  * Internal message handler for processing received messages.
@@ -53,10 +53,10 @@ class v {
53
53
  * @param event - The message event containing the component message
54
54
  */
55
55
  handleMessage(e) {
56
- const s = e.data;
57
- if (typeof s == "object" && s !== null && "type" in s) {
58
- const r = s.type, i = this.listeners.get(r);
59
- i && i.forEach((n) => n(s));
56
+ const r = e.data;
57
+ if (typeof r == "object" && r !== null && "type" in r) {
58
+ const s = r.type, i = this.listeners.get(s);
59
+ i && i.forEach((n) => n(r));
60
60
  }
61
61
  }
62
62
  /**
@@ -67,13 +67,13 @@ class v {
67
67
  this.port && this.port.postMessage(e);
68
68
  }
69
69
  }
70
- class I {
70
+ class w {
71
71
  /**
72
72
  * Creates an instance of EmbeddedComponent.
73
73
  * @param url - The URL of the embedded component
74
74
  * @param value - The initial transaction value
75
75
  */
76
- constructor(e, s, r) {
76
+ constructor(e, r, s) {
77
77
  o(this, "_url");
78
78
  o(this, "_value");
79
79
  o(this, "_options");
@@ -81,7 +81,7 @@ class I {
81
81
  o(this, "iframe");
82
82
  o(this, "eventManager");
83
83
  o(this, "modal");
84
- this._url = e, this._value = s, this._options = r, this.eventManager = new v(), this.on(a.INVALID, (i) => {
84
+ this._url = e, this._value = r, this._options = s, this.eventManager = new I(), this.on(a.INVALID, (i) => {
85
85
  i.type === a.INVALID && (this._errors = i.errors, this._value = i.value);
86
86
  }), this.on(a.RESIZE, (i) => {
87
87
  i.type === a.RESIZE && this.iframe && (this.iframe.style.height = `${i.height}px`);
@@ -119,20 +119,20 @@ class I {
119
119
  * @throws Will throw an error if the parent element is not found
120
120
  */
121
121
  mount(e) {
122
- const s = document.querySelector(e);
123
- if (!s) throw new Error(`parentID ${e} not found`);
124
- this.embed(s);
122
+ const r = document.querySelector(e);
123
+ if (!r) throw new Error(`parentID ${e} not found`);
124
+ this.embed(r);
125
125
  }
126
126
  /**
127
127
  * Embeds the component into a parent element
128
128
  * @param parent - The parent element to embed the component into
129
129
  */
130
- embed(e, s = !1) {
131
- var r, i;
132
- this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (s ? "" : "&embedded=true"), this.iframe.allow = "web-share", this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", e.appendChild(this.iframe), window.addEventListener("message", (n) => {
130
+ embed(e, r = !1) {
131
+ var s, i;
132
+ this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (r ? "" : "&embedded=true"), this.iframe.allow = "web-share", this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", e.appendChild(this.iframe), window.addEventListener("message", (n) => {
133
133
  var h, l;
134
134
  n.source === ((h = this.iframe) == null ? void 0 : h.contentWindow) && ((l = this.eventManager) == null || l.setPort(n.ports[0]));
135
- }), (i = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || i.focus();
135
+ }), (i = (s = this.iframe) == null ? void 0 : s.contentWindow) == null || i.focus();
136
136
  }
137
137
  removeEmbed() {
138
138
  this.iframe && this.iframe.remove();
@@ -149,34 +149,34 @@ class I {
149
149
  * @param messageType - The type of message to listen for
150
150
  * @param callback - The callback function to execute when the message is received
151
151
  */
152
- on(e, s) {
153
- this.eventManager.on(e, s);
152
+ on(e, r) {
153
+ this.eventManager.on(e, r);
154
154
  }
155
155
  /**
156
156
  * Removes an event listener for a specific message type
157
157
  * @param messageType - The type of message to stop listening for
158
158
  * @param callback - The callback function to remove
159
159
  */
160
- off(e, s) {
161
- this.eventManager.off(e, s);
160
+ off(e, r) {
161
+ this.eventManager.off(e, r);
162
162
  }
163
163
  /**
164
164
  * Updates the transaction value and sends an update message to the component
165
165
  * @param value - The new transaction value
166
166
  */
167
- update(e, s) {
168
- this._value = e, s && (this._options = s), this.send({ type: d.UPDATE, value: e, options: this._options });
167
+ update(e, r) {
168
+ this._value = e, r && (this._options = r), this.send({ type: d.UPDATE, value: e, options: this._options });
169
169
  }
170
170
  /**
171
171
  * Waits for the component to complete and returns the transaction response
172
172
  * @returns A promise that resolves with the transaction response
173
173
  */
174
174
  completion() {
175
- return new Promise((e, s) => {
176
- this.on(a.COMPLETE, (r) => {
177
- e(r.response);
178
- }), this.on("error", (r) => {
179
- s(new Error(r.message));
175
+ return new Promise((e, r) => {
176
+ this.on(a.COMPLETE, (s) => {
177
+ e(s.response);
178
+ }), this.on("error", (s) => {
179
+ r(new Error(s.message));
180
180
  });
181
181
  });
182
182
  }
@@ -201,13 +201,13 @@ class I {
201
201
  this.modal && ((e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
202
202
  }
203
203
  }
204
- function w(t) {
205
- return Object.entries(t).map(([e, s]) => {
206
- if (!(e && s)) return;
207
- const r = encodeURIComponent(e), i = encodeURIComponent(
208
- typeof s == "object" ? JSON.stringify(s) : s
204
+ function U(t) {
205
+ return Object.entries(t).map(([e, r]) => {
206
+ if (!(e && r)) return;
207
+ const s = encodeURIComponent(e), i = encodeURIComponent(
208
+ typeof r == "object" ? JSON.stringify(r) : r
209
209
  );
210
- return `${r}=${i}`;
210
+ return `${s}=${i}`;
211
211
  }).filter((e) => !!e).join("&");
212
212
  }
213
213
  class b {
@@ -234,13 +234,13 @@ class b {
234
234
  * @returns component URL
235
235
  * @internal
236
236
  */
237
- componentUrl(e, s, r, i) {
237
+ componentUrl(e, r, s, i) {
238
238
  const n = new URL(this.uxUrl);
239
239
  n.pathname = e;
240
- const h = w({
240
+ const h = U({
241
241
  authToken: this.authToken,
242
- value: s,
243
- configuration: r
242
+ value: r,
243
+ configuration: s
244
244
  });
245
245
  return n.hash = h, 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();
246
246
  }
@@ -254,11 +254,11 @@ class b {
254
254
  * @returns A new EmbeddedComponent instance
255
255
  * @internal
256
256
  */
257
- createComponent(e, s, r, i) {
258
- return new I(
259
- this.componentUrl(e, s, r, i),
260
- s,
261
- r
257
+ createComponent(e, r, s, i) {
258
+ return new w(
259
+ this.componentUrl(e, r, s, i),
260
+ r,
261
+ s
262
262
  );
263
263
  }
264
264
  /**
@@ -269,12 +269,12 @@ class b {
269
269
  * @param callbacks - Optional callback configuration
270
270
  * @returns A new EmbeddedComponent instance for withdrawal assistance
271
271
  */
272
- createWithdrawalAssist(e, s, r) {
272
+ createWithdrawalAssist(e, r, s) {
273
273
  return this.createComponent(
274
274
  "withdrawal-assist",
275
275
  e,
276
- s,
277
- r
276
+ r,
277
+ s
278
278
  );
279
279
  }
280
280
  /**
@@ -286,12 +286,12 @@ class b {
286
286
  * @returns A new EmbeddedComponent instance for deposit assistance
287
287
  * @alpha
288
288
  */
289
- createDepositAssist(e, s, r) {
289
+ createDepositAssist(e, r, s) {
290
290
  return this.createComponent(
291
291
  "deposit-assist",
292
292
  e,
293
- s,
294
- r
293
+ r,
294
+ s
295
295
  );
296
296
  }
297
297
  /**
@@ -303,12 +303,12 @@ class b {
303
303
  * @returns A new EmbeddedComponent instance for connection
304
304
  * @alpha
305
305
  */
306
- createConnectWallet(e, s, r) {
306
+ createConnectWallet(e, r, s) {
307
307
  return this.createComponent(
308
308
  "connect",
309
309
  e,
310
- s,
311
- r
310
+ r,
311
+ s
312
312
  );
313
313
  }
314
314
  /**
@@ -320,12 +320,12 @@ class b {
320
320
  * @returns A new EmbeddedComponent instance for deposit requests
321
321
  * @public
322
322
  */
323
- createDepositRequest(e, s, r) {
323
+ createDepositRequest(e, r, s) {
324
324
  return this.createComponent(
325
325
  "deposit-request",
326
326
  e,
327
- s,
328
- r
327
+ r,
328
+ s
329
329
  );
330
330
  }
331
331
  /**
@@ -336,9 +336,9 @@ class b {
336
336
  */
337
337
  decodeFragmentToObject(e) {
338
338
  return e.slice(1).split("&").reduce(
339
- (r, i) => {
339
+ (s, i) => {
340
340
  const [n, h] = i.split("=");
341
- return r[decodeURIComponent(n)] = decodeURIComponent(h), r;
341
+ return s[decodeURIComponent(n)] = decodeURIComponent(h), s;
342
342
  },
343
343
  {}
344
344
  );
@@ -347,11 +347,12 @@ class b {
347
347
  export {
348
348
  u as AgentType,
349
349
  a as CMType,
350
- I as EmbeddedComponent,
350
+ w as EmbeddedComponent,
351
351
  d as HMType,
352
- f as PersonType,
353
- p as ProofStatus,
354
- g as ProofTypes,
355
- E as Status,
352
+ E as PersonType,
353
+ g as ProofStatus,
354
+ v as ProofTypes,
355
+ p as Status,
356
+ f as ValidationSections,
356
357
  b as default
357
358
  };
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.20",
12
+ "version": "2.0.0-next.21",
13
13
  "source": "src/notabene.ts",
14
14
  "main": "dist/notabene.js",
15
15
  "types": "dist/notabene.d.ts",
package/src/notabene.ts CHANGED
@@ -36,6 +36,7 @@ import type {
36
36
  ScreenshotProof,
37
37
  SignatureProof,
38
38
  Theme,
39
+ ThresholdOptions,
39
40
  Transaction,
40
41
  TransactionAsset,
41
42
  TransactionOptions,
@@ -57,6 +58,7 @@ import {
57
58
  ProofStatus,
58
59
  ProofTypes,
59
60
  Status,
61
+ ValidationSections,
60
62
  } from './types';
61
63
  import { type MessageCallback } from './utils/MessageEventManager';
62
64
  import { encodeObjectToFragment } from './utils/urls';
@@ -102,6 +104,7 @@ export type {
102
104
  ScreenshotProof,
103
105
  SignatureProof,
104
106
  Theme,
107
+ ThresholdOptions,
105
108
  Transaction,
106
109
  TransactionAsset,
107
110
  TransactionOptions,
@@ -121,6 +124,7 @@ export {
121
124
  PersonType,
122
125
  Status,
123
126
  AgentType,
127
+ ValidationSections,
124
128
  };
125
129
 
126
130
  /**
package/src/types.ts CHANGED
@@ -687,6 +687,34 @@ export type VASPOptions = {
687
687
  onlyActive?: boolean;
688
688
  };
689
689
 
690
+ /**
691
+ * Sections in a WithdrawalAssist screen
692
+ *
693
+ * @alpha
694
+ */
695
+ export enum ValidationSections {
696
+ ASSET = 'asset',
697
+ DESTINATION = 'destination',
698
+ COUNTERPARTY = 'counterparty',
699
+ AGENT = 'agent',
700
+ }
701
+ /**
702
+ * Specify what to do under the provided threshold.
703
+ *
704
+ * Eg. to allow self-declaration for all transactions under 1000 EUR
705
+ *
706
+ * Note to support threshold you MUST include the Asset Price in the Transaction
707
+ *
708
+ * @see {@link Transaction} Transaction object
709
+ *
710
+ * @public
711
+ */
712
+
713
+ export interface ThresholdOptions {
714
+ threshold: number; // The threshold amount eg 1000
715
+ currency: ISOCurrency; // Currency of threshold
716
+ proofTypes?: ProofTypes[]; // If left empty no proof will be required under threshold
717
+ }
690
718
  /**
691
719
  * Configuration options for Transaction components
692
720
  * @public
@@ -699,11 +727,13 @@ export interface TransactionOptions {
699
727
  timeout?: number; // Time to verify in seconds
700
728
  };
701
729
  fallbacks?: ProofTypes[];
730
+ deminimis?: ThresholdOptions;
702
731
  };
703
732
  allowedAgentTypes?: AgentType[]; // Defaults to All
704
733
  allowedCounterpartyTypes?: PersonType[]; // Defaults to All
705
734
  fields?: FieldTypes;
706
735
  vasps?: VASPOptions;
736
+ hide?: ValidationSections[]; // You can hide a specific section of the component by listing it here
707
737
  }
708
738
 
709
739
  /**
@@ -911,11 +941,11 @@ export enum ProofStatus {
911
941
  * @remarks
912
942
  * Supported proof types:
913
943
  * - SelfDeclaration: User self-declares ownership without cryptographic proof
914
- * - PersonalSignEIP191: Ethereum personal signature following EIP-191 standard
944
+ * - EIP191: Ethereum personal signature following EIP-191 standard
915
945
  * - SIWE: Sign-In with Ethereum message signature (EIP-4361)
916
- * - PersonalSignEIP712: Ethereum typed data signature following EIP-712 standard
917
- * - PersonalSignBIP137: Bitcoin message signature following BIP-137
918
- * - PersonalSignXPUB: Extended public key signature for HD wallets
946
+ * - EIP712: Ethereum typed data signature following EIP-712 standard
947
+ * - BIP137: Bitcoin message signature following BIP-137
948
+ * - XPUB: Extended public key signature for HD wallets
919
949
  * - MicroTransfer: Proof via small blockchain transaction
920
950
  * - Screenshot: Image proof of ownership/access
921
951
  *
@@ -927,11 +957,14 @@ export enum ProofStatus {
927
957
  */
928
958
  export enum ProofTypes {
929
959
  SelfDeclaration = 'self-declaration',
930
- PersonalSignEIP191 = 'eip-191',
931
960
  SIWE = 'siwe',
932
- PersonalSignEIP712 = 'eip-712',
933
- PersonalSignBIP137 = 'bip-137',
934
- PersonalSignXPUB = 'xpub',
961
+ SIWX = 'siwx',
962
+ EIP191 = 'eip-191',
963
+ EIP712 = 'eip-712',
964
+ EIP1271 = 'eip-1271',
965
+ BIP137 = 'bip-137',
966
+ BIP137_XPUB = 'xpub',
967
+ ED25519 = 'ed25519',
935
968
  MicroTransfer = 'microtransfer',
936
969
  Screenshot = 'screenshot',
937
970
  }
@@ -983,11 +1016,15 @@ export interface OwnershipProof {
983
1016
  */
984
1017
  export interface SignatureProof extends OwnershipProof {
985
1018
  type:
986
- | ProofTypes.PersonalSignEIP191
987
- | ProofTypes.PersonalSignEIP712
988
- | ProofTypes.PersonalSignBIP137
989
- | ProofTypes.SIWE
990
- | ProofTypes.PersonalSignXPUB;
1019
+ | ProofTypes.EIP191
1020
+ | ProofTypes.EIP712
1021
+ | ProofTypes.EIP1271
1022
+ | ProofTypes.BIP137
1023
+ | ProofTypes.BIP137_XPUB
1024
+ | ProofTypes.ED25519
1025
+ | ProofTypes.SIWX
1026
+ | ProofTypes.SIWE;
1027
+
991
1028
  proof: string;
992
1029
  attestation: string;
993
1030
  wallet_provider: string;
@@ -1009,8 +1046,9 @@ export interface DeclarationProof extends OwnershipProof {
1009
1046
  */
1010
1047
  export interface MicroTransferProof extends OwnershipProof {
1011
1048
  type: ProofTypes.MicroTransfer;
1012
- txhash: string;
1049
+ proof: string;
1013
1050
  chain: CAIP2;
1051
+ asset: CAIP19;
1014
1052
  destination: BlockchainAddress;
1015
1053
  amountSubunits: string;
1016
1054
  }