@notabene/javascript-sdk 2.0.0-next.15 → 2.0.0-next.16
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 +8 -4
- package/dist/notabene.cjs +1 -1
- package/dist/notabene.js +6 -7
- package/package.json +1 -1
- package/src/components/EmbeddedComponent.ts +3 -3
- package/src/components/__tests__/EmbeddedComponent.test.ts +1 -1
- package/src/locales.ts +47 -0
- package/src/utils/MessageEventManager.ts +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ This library is the JavaScript SDK for loading the Notabene UX components in the
|
|
|
36
36
|
- [Common use cases](#common-use-cases)
|
|
37
37
|
- [Configuring ownership proofs](#configuring-ownership-proofs)
|
|
38
38
|
- [Counterparty Field Properties](#counterparty-field-properties)
|
|
39
|
+
- [Locales](#locales)
|
|
39
40
|
- [License](#license)
|
|
40
41
|
|
|
41
42
|
## Installation
|
|
@@ -51,13 +52,13 @@ Or installing the library:
|
|
|
51
52
|
Using Yarn:
|
|
52
53
|
|
|
53
54
|
```bash
|
|
54
|
-
yarn add @notabene/javascript-sdk
|
|
55
|
+
yarn add @notabene/javascript-sdk@next
|
|
55
56
|
```
|
|
56
57
|
|
|
57
58
|
Using NPM:
|
|
58
59
|
|
|
59
60
|
```bash
|
|
60
|
-
npm install @notabene/javascript-sdk
|
|
61
|
+
npm install @notabene/javascript-sdk@next
|
|
61
62
|
```
|
|
62
63
|
|
|
63
64
|
If you installed the library into your project, you can import it into your project:
|
|
@@ -80,9 +81,9 @@ Create a new Notabene instance:
|
|
|
80
81
|
|
|
81
82
|
```js
|
|
82
83
|
const notabene = new Notabene({
|
|
83
|
-
nodeUrl: 'https://api.notabene.id',
|
|
84
|
+
nodeUrl: 'https://api.notabene.id', // use `https://api.notabene.dev` for testing
|
|
84
85
|
authToken: '{CUSTOMER_TOKEN}',
|
|
85
|
-
locale: 'de' // default locale
|
|
86
|
+
locale: 'de' // default locale = `en`
|
|
86
87
|
});
|
|
87
88
|
```
|
|
88
89
|
|
|
@@ -481,6 +482,9 @@ const options: TransactionOptions = {
|
|
|
481
482
|
| `lei` | -- | ✅ | ✅ | ✅ | LEI (Legal Entity Identifier) |
|
|
482
483
|
| `countryOfRegistration` | -- | 🟩 | ✅ | 🟩 | Country of Registration |
|
|
483
484
|
|
|
485
|
+
## Locales
|
|
486
|
+
|
|
487
|
+
See [locales](src/locales.ts) for the list of supported locales.
|
|
484
488
|
|
|
485
489
|
## [License](LICENSE.md)
|
|
486
490
|
|
package/dist/notabene.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var E=Object.defineProperty;var g=(t,e,s)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>g(t,typeof e!="symbol"?e+"":e,s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var d=(t=>(t.PRIVATE="WALLET",t.VASP="VASP",t))(d||{}),c=(t=>(t.NATURAL="natural",t.LEGAL="legal",t.SELF="self",t))(c||{}),m=(t=>(t.EMPTY="empty",t.VERIFY="verify",t.PENDING="pending",t.VERIFIED="verified",t.BANNED="banned",t))(m||{}),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||{}),u=(t=>(t.UPDATE="update",t.REQUEST_RESPONSE="requestResponse",t))(u||{}),f=(t=>(t.PENDING="pending",t.FAILED="rejected",t.FLAGGED="flagged",t.VERIFIED="verified",t))(f||{}),p=(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||{});class v{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){
|
|
1
|
+
"use strict";var E=Object.defineProperty;var g=(t,e,s)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e,s)=>g(t,typeof e!="symbol"?e+"":e,s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var d=(t=>(t.PRIVATE="WALLET",t.VASP="VASP",t))(d||{}),c=(t=>(t.NATURAL="natural",t.LEGAL="legal",t.SELF="self",t))(c||{}),m=(t=>(t.EMPTY="empty",t.VERIFY="verify",t.PENDING="pending",t.VERIFIED="verified",t.BANNED="banned",t))(m||{}),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||{}),u=(t=>(t.UPDATE="update",t.REQUEST_RESPONSE="requestResponse",t))(u||{}),f=(t=>(t.PENDING="pending",t.FAILED="rejected",t.FLAGGED="flagged",t.VERIFIED="verified",t))(f||{}),p=(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||{});class v{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 I{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 v,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,s=!1){var r,i;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 l,h;n.source===((l=this.iframe)==null?void 0:l.contentWindow)&&((h=this.eventManager)==null||h.setPort(n.ports[0]))}),(i=(r=this.iframe)==null?void 0:r.contentWindow)==null||i.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:u.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,!0),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&&((e=this.modal)==null||e.close(),this.modal.remove(),this.modal=void 0)}}function U(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 l=U({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 I(this.componentUrl(e,s,r,i),s)}createWithdrawalAssist(e,s,r){return this.createComponent("withdrawal-assist",e,s,r)}createWalletAssist(e,s,r){return this.createComponent("wallet-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=d;exports.CMType=a;exports.PersonType=c;exports.ProofStatus=f;exports.ProofTypes=p;exports.Status=m;exports.default=w;
|
package/dist/notabene.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var c = Object.defineProperty;
|
|
2
2
|
var m = (t, e, s) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
|
3
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 || {}),
|
|
4
|
+
var u = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(u || {}), E = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(E || {}), f = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(f || {}), 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 || {}), 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.PersonalSignEIP712 = "eip-712", t.PersonalSignBIP137 = "bip-137", t.PersonalSignXPUB = "xpub", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t))(g || {});
|
|
5
5
|
class v {
|
|
6
6
|
constructor() {
|
|
7
7
|
o(this, "listeners", /* @__PURE__ */ new Map());
|
|
@@ -19,7 +19,6 @@ class v {
|
|
|
19
19
|
r && (r.delete(s), r.size === 0 && this.listeners.delete(e));
|
|
20
20
|
}
|
|
21
21
|
handleMessage(e) {
|
|
22
|
-
console.log("received message", e.data);
|
|
23
22
|
const s = e.data;
|
|
24
23
|
if (typeof s == "object" && s !== null && "type" in s) {
|
|
25
24
|
const r = s.type, i = this.listeners.get(r);
|
|
@@ -89,9 +88,9 @@ class I {
|
|
|
89
88
|
*/
|
|
90
89
|
embed(e, s = !1) {
|
|
91
90
|
var r, i;
|
|
92
|
-
|
|
91
|
+
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) => {
|
|
93
92
|
var l, h;
|
|
94
|
-
n.source === ((l = this.iframe) == null ? void 0 : l.contentWindow) && (
|
|
93
|
+
n.source === ((l = this.iframe) == null ? void 0 : l.contentWindow) && ((h = this.eventManager) == null || h.setPort(n.ports[0]));
|
|
95
94
|
}), (i = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || i.focus();
|
|
96
95
|
}
|
|
97
96
|
/**
|
|
@@ -157,7 +156,7 @@ class I {
|
|
|
157
156
|
*/
|
|
158
157
|
closeModal() {
|
|
159
158
|
var e;
|
|
160
|
-
this.modal && (
|
|
159
|
+
this.modal && ((e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
162
|
function U(t) {
|
|
@@ -307,9 +306,9 @@ class L {
|
|
|
307
306
|
export {
|
|
308
307
|
u as AgentType,
|
|
309
308
|
a as CMType,
|
|
310
|
-
|
|
309
|
+
E as PersonType,
|
|
311
310
|
p as ProofStatus,
|
|
312
311
|
g as ProofTypes,
|
|
313
|
-
|
|
312
|
+
f as Status,
|
|
314
313
|
L as default
|
|
315
314
|
};
|
package/package.json
CHANGED
|
@@ -92,7 +92,7 @@ export default class EmbeddedComponent<V, R> {
|
|
|
92
92
|
*/
|
|
93
93
|
|
|
94
94
|
embed(parent: Element, modal: boolean = false) {
|
|
95
|
-
console.log(this.url);
|
|
95
|
+
// console.log(this.url);
|
|
96
96
|
this.iframe = document.createElement('iframe');
|
|
97
97
|
this.iframe.src = this.url + (!modal ? '&embedded=true' : '');
|
|
98
98
|
this.iframe.allow = 'web-share';
|
|
@@ -108,7 +108,7 @@ export default class EmbeddedComponent<V, R> {
|
|
|
108
108
|
if (event.source !== this.iframe?.contentWindow) {
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
console.log('received message from iframe', event.data);
|
|
111
|
+
// console.log('received message from iframe', event.data);
|
|
112
112
|
this.eventManager?.setPort(event.ports[0]);
|
|
113
113
|
});
|
|
114
114
|
|
|
@@ -210,7 +210,7 @@ export default class EmbeddedComponent<V, R> {
|
|
|
210
210
|
|
|
211
211
|
closeModal(): void {
|
|
212
212
|
if (this.modal) {
|
|
213
|
-
console.log('closeModal');
|
|
213
|
+
// console.log('closeModal');
|
|
214
214
|
this.modal?.close();
|
|
215
215
|
this.modal.remove();
|
|
216
216
|
this.modal = undefined;
|
|
@@ -78,7 +78,7 @@ describe('EmbeddedComponent', () => {
|
|
|
78
78
|
TransactionResponse<Withdrawal>
|
|
79
79
|
>(url, value);
|
|
80
80
|
component.mount(parentId);
|
|
81
|
-
expect(iframe?.src).toBe(url);
|
|
81
|
+
expect(iframe?.src).toBe(url + '&embedded=true');
|
|
82
82
|
expect(parentElement.appendChild).toHaveBeenCalledWith(iframe);
|
|
83
83
|
});
|
|
84
84
|
|
package/src/locales.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const languages = {
|
|
2
|
+
ar: 'العربية (Arabic)',
|
|
3
|
+
bg: 'български (Bulgarian)',
|
|
4
|
+
ca: 'Català (Catalan)',
|
|
5
|
+
cs: 'Čeština (Czech)',
|
|
6
|
+
da: 'Dansk (Danish)',
|
|
7
|
+
de: 'Deutsch (German)',
|
|
8
|
+
el: 'Ελληνικά (Greek)',
|
|
9
|
+
en: 'English (English)',
|
|
10
|
+
es: 'Español (Spanish)',
|
|
11
|
+
et: 'Eesti (Estonian)',
|
|
12
|
+
fa: 'فارسی (Persian)',
|
|
13
|
+
fi: 'Suomi (Finnish)',
|
|
14
|
+
fr: 'Français (French)',
|
|
15
|
+
he: 'עברית (Hebrew)',
|
|
16
|
+
hr: 'Hrvatski (Croatian)',
|
|
17
|
+
hu: 'Magyar (Hungarian)',
|
|
18
|
+
hy: 'Հայերեն (Armenian)',
|
|
19
|
+
id: 'Bahasa Indonesia (Indonesian)',
|
|
20
|
+
is: 'Íslenska (Icelandic)',
|
|
21
|
+
it: 'Italiano (Italian)',
|
|
22
|
+
ja: '日本語 (Japanese)',
|
|
23
|
+
ka: 'ქართული (Georgian)',
|
|
24
|
+
ko: '한국어 (Korean)',
|
|
25
|
+
lt: 'Lietuvių (Lithuanian)',
|
|
26
|
+
lv: 'Latviešu (Latvian)',
|
|
27
|
+
mn: 'Монгол (Mongolian)',
|
|
28
|
+
ms: 'Bahasa Melayu (Malay)',
|
|
29
|
+
mt: 'Malti (Maltese)',
|
|
30
|
+
nl: 'Nederlands (Dutch)',
|
|
31
|
+
no: 'Norsk (Norwegian)',
|
|
32
|
+
pl: 'Polski (Polish)',
|
|
33
|
+
pt: 'Português (Portuguese)',
|
|
34
|
+
ro: 'Română (Romanian)',
|
|
35
|
+
ru: 'Русский (Russian)',
|
|
36
|
+
sk: 'Slovenčina (Slovak)',
|
|
37
|
+
sl: 'Slovenščina (Slovenian)',
|
|
38
|
+
sr: 'Српски (Serbian)',
|
|
39
|
+
sv: 'Svenska (Swedish)',
|
|
40
|
+
sw: 'Kiswahili (Swahili)',
|
|
41
|
+
th: 'ไทย (Thai)',
|
|
42
|
+
tl: 'Tagalog (Tagalog)',
|
|
43
|
+
tr: 'Türkçe (Turkish)',
|
|
44
|
+
uk: 'Українська (Ukrainian)',
|
|
45
|
+
vi: 'Tiếng Việt (Vietnamese)',
|
|
46
|
+
zh: '中文 (Chinese)',
|
|
47
|
+
};
|
|
@@ -34,7 +34,7 @@ export class MessageEventManager {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
private handleMessage(event: MessageEvent): void {
|
|
37
|
-
console.log('received message', event.data);
|
|
37
|
+
// console.log('received message', event.data);
|
|
38
38
|
const message = event.data;
|
|
39
39
|
if (typeof message === 'object' && message !== null && 'type' in message) {
|
|
40
40
|
const messageType = message.type as string;
|