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