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

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
@@ -258,6 +258,7 @@ const options: TransactionOptions = {
258
258
  proofs: {
259
259
  microTransfer: {
260
260
  destination: '0x...',
261
+ amountSubunits: '12344',
261
262
  timeout: 86440,
262
263
  },
263
264
  fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration],
@@ -339,6 +340,7 @@ const options: TransactionOptions = {
339
340
  proofs: {
340
341
  microTransfer: {
341
342
  destination: '0x...',
343
+ amountSubunits: '1234',
342
344
  timeout: 86440, // Optional timeout in seconds, which is displayed to the user
343
345
  },
344
346
  fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration],
package/dist/notabene.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var c=(r,e,t)=>e in r?d(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e,t)=>c(r,typeof e!="symbol"?e+"":e,t);var a=(r=>(r.COMPLETE="complete",r.RESIZE="resize",r.RESULT="result",r.READY="ready",r.INVALID="invalid",r.MODAL="openModal",r.ERROR="error",r.CLOSE="closeModal",r.CANCEL="cancel",r))(a||{}),l=(r=>(r.UPDATE="update",r.REQUEST_RESPONSE="requestResponse",r))(l||{});class m{constructor(){n(this,"listeners",new Map);n(this,"port");this.handleMessage=this.handleMessage.bind(this)}setPort(e){this.port=e,this.port.onmessage=this.handleMessage,this.port.start()}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){const s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e))}handleMessage(e){console.log("received message",e.data);const t=e.data;if(typeof t=="object"&&t!==null&&"type"in t){const s=t.type,o=this.listeners.get(s);o&&o.forEach(i=>i(t))}}send(e){this.port&&this.port.postMessage(e)}}class u{constructor(e,t){n(this,"_url");n(this,"_value");n(this,"_errors",[]);n(this,"iframe");n(this,"eventManager");n(this,"modal");this._url=e,this._value=t,this.eventManager=new m,this.on(a.INVALID,s=>{s.type===a.INVALID&&(this._errors=s.errors,this._value=s.value)}),this.on(a.RESIZE,s=>{s.type===a.RESIZE&&this.iframe&&(this.iframe.style.height=`${s.height}px`)})}get url(){return this._url}get value(){return this._value}get errors(){return this._errors}open(){document.location.href=this.url}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`parentID ${e} not found`);this.embed(t)}embed(e){var t,s;this.iframe=document.createElement("iframe"),this.iframe.src=this.url,this.iframe.style.width="100%",this.iframe.style.height="100px",this.iframe.style.border="none",this.iframe.style.overflow="hidden",this.iframe.setAttribute("allowtransparency","true"),this.iframe.style.backgroundColor="transparent",e.appendChild(this.iframe),window.addEventListener("message",o=>{var i,h;o.source===((i=this.iframe)==null?void 0:i.contentWindow)&&(console.log("received message from iframe",o.data),(h=this.eventManager)==null||h.setPort(o.ports[0]))}),(s=(t=this.iframe)==null?void 0:t.contentWindow)==null||s.focus()}send(e){this.eventManager.send(e)}on(e,t){this.eventManager.on(e,t)}off(e,t){this.eventManager.off(e,t)}update(e){this._value=e,this.send({type:l.UPDATE,value:e})}completion(){return new Promise((e,t)=>{this.on(a.COMPLETE,s=>{e(s.response)}),this.on("error",s=>{t(new Error(s.message))})})}openModal(){return this.modal&&this.closeModal(),this.modal=document.createElement("dialog"),this.modal.style.border="none",this.modal.style.backgroundColor="transparent",this.modal.style.maxWidth="100vw",this.modal.style.maxHeight="100vh",this.modal.style.width="600px",this.modal.style.height="800px",document.body.appendChild(this.modal),this.embed(this.modal),this.on(a.CANCEL,()=>{this.closeModal()}),this.on(a.CLOSE,()=>{this.closeModal()}),this.on(a.COMPLETE,()=>{this.closeModal()}),this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion()}closeModal(){var e;this.modal&&(console.log("closeModal"),(e=this.modal)==null||e.close(),this.modal.remove(),this.modal=void 0)}}function p(r){return Object.entries(r).map(([e,t])=>{if(!(e&&t))return;const s=encodeURIComponent(e),o=encodeURIComponent(typeof t=="object"?JSON.stringify(t):t);return`${s}=${o}`}).filter(e=>!!e).join("&")}class f{constructor(e){n(this,"nodeUrl");n(this,"authToken");n(this,"uxUrl");n(this,"theme");n(this,"locale");this.uxUrl=e.uxUrl||"https://connect.notabene.id",this.nodeUrl=e.nodeUrl,this.authToken=e.authToken,this.theme=e.theme,this.locale=e.locale}componentUrl(e,t,s,o){const i=new URL(this.uxUrl);i.pathname=e;const h=p({authToken:this.authToken,value:t,configuration:s});return i.hash=h,this.nodeUrl&&i.searchParams.set("nodeUrl",this.nodeUrl),this.theme&&i.searchParams.set("theme",JSON.stringify(this.theme)),this.locale&&i.searchParams.set("locale",this.locale),o&&(o.callback&&i.searchParams.set("callback_url",o.callback),o.redirectUri&&i.searchParams.set("redirect_uri",o.redirectUri)),i.toString()}createComponent(e,t,s,o){return new u(this.componentUrl(e,t,s,o),t)}createWithdrawalAssist(e,t,s){return this.createComponent("withdrawal-assist",e,t,s)}createDepositAssist(e,t,s){return this.createComponent("deposit-assist",e,t,s)}createConnectWallet(e,t,s){return this.createComponent("connect",e,t,s)}createDepositRequest(e,t,s){return this.createComponent("deposit-request",e,t,s)}decodeFragmentToObject(e){return e.slice(1).split("&").reduce((s,o)=>{const[i,h]=o.split("=");return s[decodeURIComponent(i)]=decodeURIComponent(h),s},{})}}module.exports=f;
1
+ "use strict";var d=Object.defineProperty;var c=(o,e,t)=>e in o?d(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var n=(o,e,t)=>c(o,typeof e!="symbol"?e+"":e,t);var a=(o=>(o.COMPLETE="complete",o.RESIZE="resize",o.RESULT="result",o.READY="ready",o.INVALID="invalid",o.MODAL="openModal",o.ERROR="error",o.CLOSE="closeModal",o.CANCEL="cancel",o))(a||{}),l=(o=>(o.UPDATE="update",o.REQUEST_RESPONSE="requestResponse",o))(l||{});class m{constructor(){n(this,"listeners",new Map);n(this,"port");this.handleMessage=this.handleMessage.bind(this)}setPort(e){this.port=e,this.port.onmessage=this.handleMessage,this.port.start()}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){const s=this.listeners.get(e);s&&(s.delete(t),s.size===0&&this.listeners.delete(e))}handleMessage(e){console.log("received message",e.data);const t=e.data;if(typeof t=="object"&&t!==null&&"type"in t){const s=t.type,r=this.listeners.get(s);r&&r.forEach(i=>i(t))}}send(e){this.port&&this.port.postMessage(e)}}class u{constructor(e,t){n(this,"_url");n(this,"_value");n(this,"_errors",[]);n(this,"iframe");n(this,"eventManager");n(this,"modal");this._url=e,this._value=t,this.eventManager=new m,this.on(a.INVALID,s=>{s.type===a.INVALID&&(this._errors=s.errors,this._value=s.value)}),this.on(a.RESIZE,s=>{s.type===a.RESIZE&&this.iframe&&(this.iframe.style.height=`${s.height}px`)})}get url(){return this._url}get value(){return this._value}get errors(){return this._errors}open(){document.location.href=this.url}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`parentID ${e} not found`);this.embed(t)}embed(e){var t,s;this.iframe=document.createElement("iframe"),this.iframe.src=this.url,this.iframe.allow="web-share",this.iframe.style.width="100%",this.iframe.style.height="100px",this.iframe.style.border="none",this.iframe.style.overflow="hidden",e.appendChild(this.iframe),window.addEventListener("message",r=>{var i,h;r.source===((i=this.iframe)==null?void 0:i.contentWindow)&&(console.log("received message from iframe",r.data),(h=this.eventManager)==null||h.setPort(r.ports[0]))}),(s=(t=this.iframe)==null?void 0:t.contentWindow)==null||s.focus()}send(e){this.eventManager.send(e)}on(e,t){this.eventManager.on(e,t)}off(e,t){this.eventManager.off(e,t)}update(e){this._value=e,this.send({type:l.UPDATE,value:e})}completion(){return new Promise((e,t)=>{this.on(a.COMPLETE,s=>{e(s.response)}),this.on("error",s=>{t(new Error(s.message))})})}openModal(){return this.modal&&this.closeModal(),this.modal=document.createElement("dialog"),this.modal.style.border="none",this.modal.style.backgroundColor="transparent",this.modal.style.maxWidth="100vw",this.modal.style.maxHeight="100vh",this.modal.style.width="600px",this.modal.style.height="800px",document.body.appendChild(this.modal),this.embed(this.modal),this.on(a.CANCEL,()=>{this.closeModal()}),this.on(a.CLOSE,()=>{this.closeModal()}),this.on(a.COMPLETE,()=>{this.closeModal()}),this.modal.showModal(),this.modal.addEventListener("click",()=>{this.closeModal()}),this.completion()}closeModal(){var e;this.modal&&(console.log("closeModal"),(e=this.modal)==null||e.close(),this.modal.remove(),this.modal=void 0)}}function f(o){return Object.entries(o).map(([e,t])=>{if(!(e&&t))return;const s=encodeURIComponent(e),r=encodeURIComponent(typeof t=="object"?JSON.stringify(t):t);return`${s}=${r}`}).filter(e=>!!e).join("&")}class p{constructor(e){n(this,"nodeUrl");n(this,"authToken");n(this,"uxUrl");n(this,"theme");n(this,"locale");this.uxUrl=e.uxUrl||"https://connect.notabene.id",this.nodeUrl=e.nodeUrl,this.authToken=e.authToken,this.theme=e.theme,this.locale=e.locale}componentUrl(e,t,s,r){const i=new URL(this.uxUrl);i.pathname=e;const h=f({authToken:this.authToken,value:t,configuration:s});return i.hash=h,this.nodeUrl&&i.searchParams.set("nodeUrl",this.nodeUrl),this.theme&&i.searchParams.set("theme",JSON.stringify(this.theme)),this.locale&&i.searchParams.set("locale",this.locale),r&&(r.callback&&i.searchParams.set("callback_url",r.callback),r.redirectUri&&i.searchParams.set("redirect_uri",r.redirectUri)),i.toString()}createComponent(e,t,s,r){return new u(this.componentUrl(e,t,s,r),t)}createWithdrawalAssist(e,t,s){return this.createComponent("withdrawal-assist",e,t,s)}createDepositAssist(e,t,s){return this.createComponent("deposit-assist",e,t,s)}createConnectWallet(e,t,s){return this.createComponent("connect",e,t,s)}createDepositRequest(e,t,s){return this.createComponent("deposit-request",e,t,s)}decodeFragmentToObject(e){return e.slice(1).split("&").reduce((s,r)=>{const[i,h]=r.split("=");return s[decodeURIComponent(i)]=decodeURIComponent(h),s},{})}}module.exports=p;
@@ -276,7 +276,9 @@ export declare interface DepositRequest extends DepositRequestFields, Transactio
276
276
  * @public
277
277
  */
278
278
  declare type DepositRequestFields = {
279
- destinations: destination[];
279
+ destination: BlockchainAddress | CAIP10;
280
+ travelAddress?: TravelAddress;
281
+ cryptoCredential?: CryptoCredential;
280
282
  };
281
283
 
282
284
  /**
@@ -1014,6 +1016,7 @@ export declare interface TransactionOptions {
1014
1016
  proofs?: {
1015
1017
  microTransfer?: {
1016
1018
  destination: BlockchainAddress;
1019
+ amountSubunits: string;
1017
1020
  timeout?: number;
1018
1021
  };
1019
1022
  fallbacks?: ProofTypes[];
@@ -1021,6 +1024,7 @@ export declare interface TransactionOptions {
1021
1024
  allowedAgentTypes?: AgentType[];
1022
1025
  allowedCounterpartyTypes?: PersonType[];
1023
1026
  fields?: FieldTypes;
1027
+ vasps?: VASPOptions;
1024
1028
  }
1025
1029
 
1026
1030
  /**
@@ -1117,6 +1121,11 @@ export declare interface VASP extends Agent {
1117
1121
  countryOfRegistration?: ISOCountryCode;
1118
1122
  }
1119
1123
 
1124
+ declare type VASPOptions = {
1125
+ addUnknown?: boolean;
1126
+ onlyActive?: boolean;
1127
+ };
1128
+
1120
1129
  /**
1121
1130
  * A wallet agent acting on behalf of the counterparty
1122
1131
  * @public
package/dist/notabene.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var d = Object.defineProperty;
2
- var c = (r, e, t) => e in r ? d(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var n = (r, e, t) => c(r, typeof e != "symbol" ? e + "" : e, t);
4
- var a = /* @__PURE__ */ ((r) => (r.COMPLETE = "complete", r.RESIZE = "resize", r.RESULT = "result", r.READY = "ready", r.INVALID = "invalid", r.MODAL = "openModal", r.ERROR = "error", r.CLOSE = "closeModal", r.CANCEL = "cancel", r))(a || {}), l = /* @__PURE__ */ ((r) => (r.UPDATE = "update", r.REQUEST_RESPONSE = "requestResponse", r))(l || {});
2
+ var c = (o, e, t) => e in o ? d(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var n = (o, e, t) => c(o, typeof e != "symbol" ? e + "" : e, t);
4
+ var a = /* @__PURE__ */ ((o) => (o.COMPLETE = "complete", o.RESIZE = "resize", o.RESULT = "result", o.READY = "ready", o.INVALID = "invalid", o.MODAL = "openModal", o.ERROR = "error", o.CLOSE = "closeModal", o.CANCEL = "cancel", o))(a || {}), l = /* @__PURE__ */ ((o) => (o.UPDATE = "update", o.REQUEST_RESPONSE = "requestResponse", o))(l || {});
5
5
  class m {
6
6
  constructor() {
7
7
  n(this, "listeners", /* @__PURE__ */ new Map());
@@ -22,8 +22,8 @@ class m {
22
22
  console.log("received message", e.data);
23
23
  const t = e.data;
24
24
  if (typeof t == "object" && t !== null && "type" in t) {
25
- const s = t.type, o = this.listeners.get(s);
26
- o && o.forEach((i) => i(t));
25
+ const s = t.type, r = this.listeners.get(s);
26
+ r && r.forEach((i) => i(t));
27
27
  }
28
28
  }
29
29
  // Method to send messages through the port
@@ -89,9 +89,9 @@ class u {
89
89
  */
90
90
  embed(e) {
91
91
  var t, s;
92
- this.iframe = document.createElement("iframe"), this.iframe.src = this.url, this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", this.iframe.setAttribute("allowtransparency", "true"), this.iframe.style.backgroundColor = "transparent", e.appendChild(this.iframe), window.addEventListener("message", (o) => {
92
+ this.iframe = document.createElement("iframe"), this.iframe.src = this.url, this.iframe.allow = "web-share", this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", e.appendChild(this.iframe), window.addEventListener("message", (r) => {
93
93
  var i, h;
94
- o.source === ((i = this.iframe) == null ? void 0 : i.contentWindow) && (console.log("received message from iframe", o.data), (h = this.eventManager) == null || h.setPort(o.ports[0]));
94
+ r.source === ((i = this.iframe) == null ? void 0 : i.contentWindow) && (console.log("received message from iframe", r.data), (h = this.eventManager) == null || h.setPort(r.ports[0]));
95
95
  }), (s = (t = this.iframe) == null ? void 0 : t.contentWindow) == null || s.focus();
96
96
  }
97
97
  /**
@@ -160,13 +160,13 @@ class u {
160
160
  this.modal && (console.log("closeModal"), (e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
161
161
  }
162
162
  }
163
- function f(r) {
164
- return Object.entries(r).map(([e, t]) => {
163
+ function f(o) {
164
+ return Object.entries(o).map(([e, t]) => {
165
165
  if (!(e && t)) return;
166
- const s = encodeURIComponent(e), o = encodeURIComponent(
166
+ const s = encodeURIComponent(e), r = encodeURIComponent(
167
167
  typeof t == "object" ? JSON.stringify(t) : t
168
168
  );
169
- return `${s}=${o}`;
169
+ return `${s}=${r}`;
170
170
  }).filter((e) => !!e).join("&");
171
171
  }
172
172
  class E {
@@ -193,7 +193,7 @@ class E {
193
193
  * @returns component URL
194
194
  * @internal
195
195
  */
196
- componentUrl(e, t, s, o) {
196
+ componentUrl(e, t, s, r) {
197
197
  const i = new URL(this.uxUrl);
198
198
  i.pathname = e;
199
199
  const h = f({
@@ -201,7 +201,7 @@ class E {
201
201
  value: t,
202
202
  configuration: s
203
203
  });
204
- return i.hash = h, this.nodeUrl && i.searchParams.set("nodeUrl", this.nodeUrl), this.theme && i.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && i.searchParams.set("locale", this.locale), o && (o.callback && i.searchParams.set("callback_url", o.callback), o.redirectUri && i.searchParams.set("redirect_uri", o.redirectUri)), i.toString();
204
+ return i.hash = h, this.nodeUrl && i.searchParams.set("nodeUrl", this.nodeUrl), this.theme && i.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && i.searchParams.set("locale", this.locale), r && (r.callback && i.searchParams.set("callback_url", r.callback), r.redirectUri && i.searchParams.set("redirect_uri", r.redirectUri)), i.toString();
205
205
  }
206
206
  /**
207
207
  * Creates a new embedded component
@@ -213,9 +213,9 @@ class E {
213
213
  * @returns A new EmbeddedComponent instance
214
214
  * @internal
215
215
  */
216
- createComponent(e, t, s, o) {
216
+ createComponent(e, t, s, r) {
217
217
  return new u(
218
- this.componentUrl(e, t, s, o),
218
+ this.componentUrl(e, t, s, r),
219
219
  t
220
220
  );
221
221
  }
@@ -283,8 +283,8 @@ class E {
283
283
  */
284
284
  decodeFragmentToObject(e) {
285
285
  return e.slice(1).split("&").reduce(
286
- (s, o) => {
287
- const [i, h] = o.split("=");
286
+ (s, r) => {
287
+ const [i, h] = r.split("=");
288
288
  return s[decodeURIComponent(i)] = decodeURIComponent(h), s;
289
289
  },
290
290
  {}
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.11",
12
+ "version": "2.0.0-next.13",
13
13
  "source": "src/notabene.ts",
14
14
  "main": "dist/notabene.js",
15
15
  "types": "dist/notabene.d.ts",
@@ -94,12 +94,13 @@ export default class EmbeddedComponent<V, R> {
94
94
  embed(parent: Element) {
95
95
  this.iframe = document.createElement('iframe');
96
96
  this.iframe.src = this.url;
97
+ this.iframe.allow = 'web-share';
97
98
  this.iframe.style.width = '100%';
98
99
  this.iframe.style.height = '100px';
99
100
  this.iframe.style.border = 'none';
100
101
  this.iframe.style.overflow = 'hidden';
101
- this.iframe.setAttribute('allowtransparency', 'true');
102
- this.iframe.style.backgroundColor = 'transparent';
102
+ // this.iframe.setAttribute('allowtransparency', 'true');
103
+ // this.iframe.style.backgroundColor = 'transparent';
103
104
  parent.appendChild(this.iframe);
104
105
 
105
106
  window.addEventListener('message', (event: MessageEvent) => {
package/src/types.ts CHANGED
@@ -296,7 +296,9 @@ type BeneficiaryFields = {
296
296
  * @public
297
297
  */
298
298
  type DepositRequestFields = {
299
- destinations: Destination[];
299
+ destination: BlockchainAddress | CAIP10;
300
+ travelAddress?: TravelAddress;
301
+ cryptoCredential?: CryptoCredential;
300
302
  };
301
303
 
302
304
  type RequestID = UUID;
@@ -432,6 +434,11 @@ export type FieldTypes = {
432
434
  naturalPerson?: NaturalPersonFields;
433
435
  legalPerson?: LegalPersonFields;
434
436
  };
437
+
438
+ export type VASPOptions = {
439
+ addUnknown?: boolean;
440
+ onlyActive?: boolean;
441
+ };
435
442
  /**
436
443
  * Configuration options for Transaction components
437
444
  * @public
@@ -440,6 +447,7 @@ export interface TransactionOptions {
440
447
  proofs?: {
441
448
  microTransfer?: {
442
449
  destination: BlockchainAddress;
450
+ amountSubunits: string;
443
451
  timeout?: number; // Time to verify in seconds
444
452
  };
445
453
  fallbacks?: ProofTypes[];
@@ -447,6 +455,7 @@ export interface TransactionOptions {
447
455
  allowedAgentTypes?: AgentType[]; // Defaults to All
448
456
  allowedCounterpartyTypes?: PersonType[]; // Defaults to All
449
457
  fields?: FieldTypes;
458
+ vasps?: VASPOptions;
450
459
  }
451
460
 
452
461
  /**