@notabene/javascript-sdk 2.0.0-next.6 → 2.0.0-next.7
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 +3 -178
- package/dist/notabene.cjs +1 -1
- package/dist/notabene.d.ts +56 -16
- package/dist/notabene.js +27 -29
- package/package.json +1 -1
- package/src/__tests__/notabene.test.ts +28 -0
- package/src/ivms/types.ts +69 -28
- package/src/notabene.ts +5 -5
- package/src/utils/MessageEventManager.ts +2 -3
- package/src/utils/arbitraries.ts +5 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
This library is the JavaScript SDK for loading the Notabene UX components in the front-end.
|
|
12
12
|
|
|
13
|
-
[Documentation](https://devx.notabene.id/docs/
|
|
13
|
+
[Documentation](https://devx.notabene.id/docs/embedded=ux)
|
|
14
14
|
[Installation](#installation)
|
|
15
15
|
|
|
16
16
|
</div>
|
|
@@ -31,12 +31,7 @@ This library is the JavaScript SDK for loading the Notabene UX components in the
|
|
|
31
31
|
- [Customization](#customization)
|
|
32
32
|
- [Functionality](#functionality)
|
|
33
33
|
- [Pass the variables in the configuration](#pass-the-variables-in-the-configuration)
|
|
34
|
-
- [Theme](#theme)
|
|
35
|
-
- [Dictionary](#dictionary)
|
|
36
|
-
- [The property name must be the same as the text in the widget, for it to be replaced](#the-property-name-must-be-the-same-as-the-text-in-the-widget-for-it-to-be-replaced)
|
|
37
34
|
- [Fields Properties](#fields-properties)
|
|
38
|
-
- [Fallbacks](#fallbacks)
|
|
39
|
-
- [Opt-In Features](#opt-in-features)
|
|
40
35
|
- [Transaction Custom Asset Price](#transaction-custom-asset-price)
|
|
41
36
|
- [License](#license)
|
|
42
37
|
|
|
@@ -70,7 +65,8 @@ Create a new Notabene instance:
|
|
|
70
65
|
|
|
71
66
|
const notabene = new Notabene({
|
|
72
67
|
nodeUrl: 'https://api.notabene.id',
|
|
73
|
-
authToken: '{CUSTOMER_TOKEN}'
|
|
68
|
+
authToken: '{CUSTOMER_TOKEN}',
|
|
69
|
+
locale: 'de' // default locale
|
|
74
70
|
});
|
|
75
71
|
```
|
|
76
72
|
|
|
@@ -223,18 +219,6 @@ Type | Code | Title | Detail
|
|
|
223
219
|
|
|
224
220
|
## Customization
|
|
225
221
|
|
|
226
|
-
### Functionality
|
|
227
|
-
|
|
228
|
-
`transactionTypeAllowed`: `ALL` | `VASP_2_VASP_ONLY` | `FIRST_PARTY_ONLY`
|
|
229
|
-
|
|
230
|
-
For limiting the type of transaction destinations you can pass.
|
|
231
|
-
|
|
232
|
-
`ALL`: All transaction destinations are allowed. (DEFAULT)
|
|
233
|
-
`VASP_2_VASP_ONLY`: Only transaction destinations that are VASPs are allowed.
|
|
234
|
-
`FIRST_PARTY_ONLY`: Only transaction destinations that the originator owns are allowed.
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
222
|
`nonCustodialDeclarationType`: `SIGNATURE` | `DECLARATION`
|
|
239
223
|
|
|
240
224
|
For deciding which ownership proof type you want to use.
|
|
@@ -248,83 +232,6 @@ For deciding which ownership proof type you want to use.
|
|
|
248
232
|
|
|
249
233
|
For deciding if you would like to allow your customer to provide a manual counterparty vasp name in the counterparty field.
|
|
250
234
|
|
|
251
|
-
### Pass the variables in the configuration
|
|
252
|
-
|
|
253
|
-
```js
|
|
254
|
-
const notabene = new Notabene({
|
|
255
|
-
vaspDID: 'did:ethr:0x94c38fd29ef36f5cb2f7bc771f9d5bd9f7d05f27',
|
|
256
|
-
widget: 'https://beta-widget.notabene.id',
|
|
257
|
-
container: '#container',
|
|
258
|
-
authToken: '{CUSTOMER_TOKEN}'
|
|
259
|
-
allowedTransactionTypes: 'VASP_2_VASP_ONLY',
|
|
260
|
-
nonCustodialDeclarationType: 'DECLARATION',
|
|
261
|
-
});
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
---
|
|
265
|
-
|
|
266
|
-
### Theme
|
|
267
|
-
|
|
268
|
-
Pass a `theme` object when creating an instance
|
|
269
|
-
|
|
270
|
-
Here you can pass configuration which will customize the styles of the widget to meet your brand needs, all values are optional.
|
|
271
|
-
|
|
272
|
-
```js
|
|
273
|
-
{
|
|
274
|
-
primaryColor: '#fff',
|
|
275
|
-
secondaryColor: '#fff',
|
|
276
|
-
primaryFontColor: '#fff',
|
|
277
|
-
secondaryFontColor: '#fff',
|
|
278
|
-
backgroundColor: '#fff',
|
|
279
|
-
fontFamily: Arial,
|
|
280
|
-
logo: {LOGO_URL},
|
|
281
|
-
mode: 'dark', // default: 'light'
|
|
282
|
-
|
|
283
|
-
// If you are using the Signature flow, here is the full list of custom theme that can be applied to the WalletConnect Modal.
|
|
284
|
-
'--w3m-font-family',
|
|
285
|
-
'--w3m-font-feature-settings',
|
|
286
|
-
'--w3m-overlay-background-color',
|
|
287
|
-
'--w3m-overlay-backdrop-filter',
|
|
288
|
-
'--w3m-z-index',
|
|
289
|
-
'--w3m-accent-color',
|
|
290
|
-
'--w3m-accent-fill-color',
|
|
291
|
-
'--w3m-background-color',
|
|
292
|
-
'--w3m-background-image-url',
|
|
293
|
-
'--w3m-logo-image-url',
|
|
294
|
-
'--w3m-background-border-radius',
|
|
295
|
-
'--w3m-container-border-radius',
|
|
296
|
-
'--w3m-wallet-icon-border-radius',
|
|
297
|
-
'--w3m-wallet-icon-large-border-radius',
|
|
298
|
-
'--w3m-wallet-icon-small-border-radius',
|
|
299
|
-
'--w3m-input-border-radius',
|
|
300
|
-
'--w3m-notification-border-radius',
|
|
301
|
-
'--w3m-button-border-radius',
|
|
302
|
-
'--w3m-secondary-button-border-radius',
|
|
303
|
-
'--w3m-icon-button-border-radius',
|
|
304
|
-
'--w3m-button-hover-highlight-border-radius',
|
|
305
|
-
}
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
To get a list of supported fonts, visit [https://fonts.google.com/](https://fonts.google.com/)
|
|
309
|
-
|
|
310
|
-
To get more details about the WalletConnect theme variables, visit [General style variables](https://docs.walletconnect.com/2.0/web/web3modal/react/wagmi/theming#general-style-variables).
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
### Dictionary
|
|
315
|
-
|
|
316
|
-
Pass a `dictionary` object mapping in text in the widget to your own language, for example:
|
|
317
|
-
|
|
318
|
-
To replace `Loading...` with `Cargando...`
|
|
319
|
-
|
|
320
|
-
```js
|
|
321
|
-
{
|
|
322
|
-
'Loading...': 'Cargando...',
|
|
323
|
-
}
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
###### The property name must be the same as the text in the widget, for it to be replaced
|
|
327
|
-
|
|
328
235
|
---
|
|
329
236
|
|
|
330
237
|
### Fields Properties
|
|
@@ -333,10 +240,8 @@ Possible fields customization support:
|
|
|
333
240
|
|
|
334
241
|
| field name | `forceDisplay` | `optional` | description |
|
|
335
242
|
| ------------------------ | -------------- | ---------- | ------------------------------------------------------- |
|
|
336
|
-
| `counterparty` | -- | ☑️ | Counterparty VASP or Wallet (destination or originator) |
|
|
337
243
|
| `dateAndPlaceOfBirth` | ☑️ | -- | Recipient (or Sender) Date and Place of Birth |
|
|
338
244
|
| `geographicAddress` | ☑️ | ☑️ | Recipient (or Sender) Address |
|
|
339
|
-
| `firstName` | ☑️ | -- | Recipient (or Sender) First name |
|
|
340
245
|
| `name` | ☑️ | -- | Recipient (or Sender) Last Name / Company Name |
|
|
341
246
|
| `nationalIdentification` | ☑️ | --️ | Recipient (or Sender) National Identification |
|
|
342
247
|
| `country` | ☑️ | ☑️ | Recipient (or Sender) Country of Residence (for natural person) / Country of Registration (for legal person) |
|
|
@@ -358,87 +263,7 @@ Possible fields customization support:
|
|
|
358
263
|
}
|
|
359
264
|
```
|
|
360
265
|
|
|
361
|
-
---
|
|
362
|
-
|
|
363
|
-
**_Beneficiary Details_ [DEPRECATED]**
|
|
364
|
-
|
|
365
|
-
You can require specific beneficiary fields that are not required by your jurisdiction.
|
|
366
|
-
|
|
367
|
-
Possible fields:
|
|
368
|
-
|
|
369
|
-
- `beneficiaryName` - Recipient Name
|
|
370
|
-
- `beneficiaryGeographicAddress` - Recipient Address
|
|
371
|
-
- `beneficiaryNationalIdentification` - Recipient National Identification
|
|
372
|
-
- `beneficiaryDateAndPlaceOfBirth` - Recipient Date and Place of Birth
|
|
373
|
-
|
|
374
|
-
```js
|
|
375
|
-
beneficiaryDetails: [
|
|
376
|
-
'benficiaryName',
|
|
377
|
-
'beneficiaryGeographicAddress',
|
|
378
|
-
'beneficiaryNationalIdentification',
|
|
379
|
-
'beneficiaryDateAndPlaceOfBirth',
|
|
380
|
-
];
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
---
|
|
384
|
-
|
|
385
|
-
### Fallbacks
|
|
386
|
-
|
|
387
|
-
Fallbacks are custom options provided when desired outcome is not achieved
|
|
388
|
-
|
|
389
|
-
Possible options and actions:
|
|
390
|
-
|
|
391
|
-
- `WALLET_NOT_SUPPORTED` - Performs one of the following options when wallet is not supported
|
|
392
|
-
- `DECLARATION` - Falls back to the self declaration flow
|
|
393
|
-
- `REJECT` - Rejects the transaction and throws an error
|
|
394
|
-
- The error that will be thrown here will have the following structure
|
|
395
|
-
|
|
396
|
-
```js
|
|
397
|
-
{
|
|
398
|
-
"type": "WALLET_NOT_SUPPORTED",
|
|
399
|
-
"title": "Wallet Not Supported",
|
|
400
|
-
"status": 501,
|
|
401
|
-
"detail": "We don't support the wallet for the provided asset"
|
|
402
|
-
}
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
```js
|
|
406
|
-
fallbacks: [{flow: "WALLET_NOT_SUPPORTED", action: "DECLARATION"}]
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
---
|
|
410
|
-
|
|
411
|
-
Finally you pass the configuration to a Notabene instance:
|
|
412
|
-
|
|
413
|
-
```js
|
|
414
|
-
const notabene = new Notabene({
|
|
415
|
-
widget: 'https://beta-widget.notabene.id',
|
|
416
|
-
container: '#container',
|
|
417
|
-
authToken: '{CUSTOMER_TOKEN}'
|
|
418
|
-
theme: {THEME},
|
|
419
|
-
dictionary: {DICTIONARY},
|
|
420
|
-
fallbacks: [{flow: "WALLET_NOT_SUPPORTED", action: "DECLARATION"}]
|
|
421
|
-
});
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
---
|
|
425
|
-
|
|
426
|
-
### Opt-In Features
|
|
427
|
-
|
|
428
|
-
```js
|
|
429
|
-
const notabene = new Notabene({
|
|
430
|
-
widget: 'https://beta-widget.notabene.id',
|
|
431
|
-
container: '#container',
|
|
432
|
-
authToken: '{CUSTOMER_TOKEN}'
|
|
433
|
-
theme: {THEME},
|
|
434
|
-
dictionary: {DICTIONARY},
|
|
435
|
-
optInFeatures: ['REUSE_ADDRESS_OWNERSHIP_PROOF']
|
|
436
|
-
});
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
**Available Opt-In Features**
|
|
440
266
|
|
|
441
|
-
- `REUSE_ADDRESS_OWNERSHIP_PROOF`: For a given unique customer (identified by the `customerRef` from the customer token used) + unique wallet address, the widget would not ask for data collection if the customer previously verified the address ownership in a previous first party self-hosted transfer.
|
|
442
267
|
|
|
443
268
|
### Transaction Custom Asset Price
|
|
444
269
|
|
package/dist/notabene.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var u=(s,e,t)=>e in s?d(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var o=(s,e,t)=>u(s,typeof e!="symbol"?e+"":e,t);var h=(s=>(s.COMPLETE="complete",s.RESIZE="resize",s.RESULT="result",s.READY="ready",s.INVALID="invalid",s.MODAL="openModal",s.ERROR="error",s.CLOSE="closeModal",s.CANCEL="cancel",s))(h||{}),c=(s=>(s.UPDATE="update",s.REQUEST_RESPONSE="requestResponse",s))(c||{});class m{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,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){const r=this.listeners.get(e);r&&(r.delete(t),r.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 r=t.type,n=this.listeners.get(r);n&&n.forEach(i=>i(t))}}send(e){this.port&&this.port.postMessage(e)}}class f{constructor(e,t){o(this,"_url");o(this,"_value");o(this,"_errors",[]);o(this,"iframe");o(this,"eventManager");o(this,"ready",!1);this._url=e,this._value=t,this.eventManager=new m,this.on(h.INVALID,r=>{r.type===h.INVALID&&(this._errors=r.errors,this._value=r.value)}),this.on(h.RESIZE,r=>{r.type===h.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){var r,n;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",window.addEventListener("message",i=>{var a,l;i.source===((a=this.iframe)==null?void 0:a.contentWindow)&&(console.log("received message from iframe",i.data),(l=this.eventManager)==null||l.setPort(i.ports[0]),this.ready=!0)});const t=document.querySelector(e);if(!t)throw new Error(`parentID ${e} not found`);t.appendChild(this.iframe),(n=(r=this.iframe)==null?void 0:r.contentWindow)==null||n.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:c.UPDATE,value:e})}completion(){return new Promise((e,t)=>{this.on(h.COMPLETE,r=>{e(r.response)}),this.on("error",r=>{t(new Error(r.message))})})}}function p(s){return Object.entries(s).map(([e,t])=>{if(!(e&&t))return;const r=encodeURIComponent(e),n=encodeURIComponent(typeof t=="object"?JSON.stringify(t):t);return`${r}=${n}`}).filter(e=>!!e).join("&")}class E{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,t,r,n){const i=new URL(this.uxUrl);i.pathname=e;const a=p({authToken:this.authToken,value:t,configuration:r});return i.hash=a,this.nodeUrl&&i.searchParams.set("nodeUrl",this.nodeUrl),this.theme&&i.searchParams.set("theme",JSON.stringify(this.theme)),this.locale&&i.searchParams.set("locale",this.locale),n&&(n.callback&&i.searchParams.set("callback_url",n.callback),n.redirectUri&&i.searchParams.set("redirect_uri",n.redirectUri)),i.toString()}createComponent(e,t,r,n){return new f(this.componentUrl(e,t,r,n),t)}createWithdrawalAssist(e,t,r){return this.createComponent("withdrawal-assist",e,t,r)}decodeFragmentToObject(e){return e.slice(1).split("&").reduce((r,n)=>{const[i,a]=n.split("=");return r[decodeURIComponent(i)]=decodeURIComponent(a),r},{})}}module.exports=E;
|
package/dist/notabene.d.ts
CHANGED
|
@@ -3,22 +3,38 @@
|
|
|
3
3
|
* Address
|
|
4
4
|
*/
|
|
5
5
|
declare type Address = {
|
|
6
|
-
|
|
6
|
+
/** Identifies the nature of the address. */
|
|
7
|
+
addressType: AddressTypeCode;
|
|
8
|
+
/** Identification of a division of a large organisation or building. */
|
|
7
9
|
department?: string;
|
|
10
|
+
/** Identification of a sub-division of a large organisation or building. */
|
|
8
11
|
subDepartment?: string;
|
|
12
|
+
/** Name of a street or thoroughfare. */
|
|
9
13
|
streetName?: string;
|
|
14
|
+
/** Number that identifies the position of a building on a street. */
|
|
10
15
|
buildingNumber?: string;
|
|
16
|
+
/** Name of the building or house. */
|
|
11
17
|
buildingName?: string;
|
|
18
|
+
/** Floor or storey within a building. */
|
|
12
19
|
floor?: string;
|
|
20
|
+
/** Numbered box in a post office. */
|
|
13
21
|
postBox?: string;
|
|
22
|
+
/** Building room number. */
|
|
14
23
|
room?: string;
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
/** Identifier consisting of a group of letters and/or numbers that is added to a postal address to assist the sorting of mail. */
|
|
25
|
+
postcode?: string;
|
|
26
|
+
/** Name of a built-up area, with defined boundaries, and a local government. */
|
|
27
|
+
townName: string;
|
|
28
|
+
/** Specific location name within the town. */
|
|
17
29
|
townLocationName?: string;
|
|
30
|
+
/** Identifies a subdivision within a country subdivision. */
|
|
18
31
|
districtName?: string;
|
|
32
|
+
/** Identifies a subdivision of a country such as state, region, province. */
|
|
19
33
|
countrySubDivision?: string;
|
|
34
|
+
/** Information that locates and identifies a specific address, presented in free format text. */
|
|
20
35
|
addressLine?: string[];
|
|
21
|
-
|
|
36
|
+
/** Nation with its own government. */
|
|
37
|
+
country: string;
|
|
22
38
|
};
|
|
23
39
|
|
|
24
40
|
/**
|
|
@@ -243,10 +259,15 @@ export declare type IVMS101 = {
|
|
|
243
259
|
* LegalPerson
|
|
244
260
|
*/
|
|
245
261
|
declare type LegalPerson = {
|
|
246
|
-
name
|
|
262
|
+
/** The name of the legal person. */
|
|
263
|
+
name: LegalPersonName;
|
|
264
|
+
/** The address of the legal person. */
|
|
247
265
|
geographicAddress?: Address[];
|
|
266
|
+
/** A distinct identifier that uniquely identifies the person to the institution in context. */
|
|
248
267
|
customerNumber?: string;
|
|
268
|
+
/** A distinct identifier used by governments to uniquely identify a legal person. */
|
|
249
269
|
nationalIdentification?: NationalIdentification;
|
|
270
|
+
/** The country in which the legal person is registered. */
|
|
250
271
|
countryOfRegistration?: string;
|
|
251
272
|
};
|
|
252
273
|
|
|
@@ -255,7 +276,7 @@ declare type LegalPerson = {
|
|
|
255
276
|
* LegalPersonName
|
|
256
277
|
*/
|
|
257
278
|
declare type LegalPersonName = {
|
|
258
|
-
nameIdentifier
|
|
279
|
+
nameIdentifier: LegalPersonNameID[];
|
|
259
280
|
localNameIdentifier?: LocalLegalPersonNameID[];
|
|
260
281
|
phoneticNameIdentifier?: LocalLegalPersonNameID[];
|
|
261
282
|
};
|
|
@@ -265,8 +286,10 @@ declare type LegalPersonName = {
|
|
|
265
286
|
* LegalPersonNameID
|
|
266
287
|
*/
|
|
267
288
|
declare type LegalPersonNameID = {
|
|
268
|
-
|
|
269
|
-
|
|
289
|
+
/** Name by which the legal person is known. */
|
|
290
|
+
legalPersonName: string;
|
|
291
|
+
/** The nature of the name specified. */
|
|
292
|
+
legalPersonNameIdentifierType: LegalPersonNameTypeCode;
|
|
270
293
|
};
|
|
271
294
|
|
|
272
295
|
/**
|
|
@@ -350,11 +373,17 @@ declare type NationalIdentifierTypeCode = 'ARNU' | 'CCPT' | 'RAID' | 'DRLC' | 'F
|
|
|
350
373
|
* NaturalPerson
|
|
351
374
|
*/
|
|
352
375
|
declare type NaturalPerson = {
|
|
353
|
-
|
|
376
|
+
/** The distinct words used as identification for an individual. */
|
|
377
|
+
name: NaturalPersonName;
|
|
378
|
+
/** The particulars of a location at which a person may be communicated with. */
|
|
354
379
|
geographicAddress?: Address[];
|
|
380
|
+
/** A distinct identifier used by governments to uniquely identify a natural person. */
|
|
355
381
|
nationalIdentification?: NationalIdentification;
|
|
382
|
+
/** A distinct identifier that uniquely identifies the person to the institution in context. */
|
|
356
383
|
customerIdentification?: string;
|
|
384
|
+
/** Date and place of birth of a person. */
|
|
357
385
|
dateAndPlaceOfBirth?: DateAndPlaceOfBirth;
|
|
386
|
+
/** Country in which a person resides (the place of a person's home). */
|
|
358
387
|
countryOfResidence?: string;
|
|
359
388
|
};
|
|
360
389
|
|
|
@@ -400,7 +429,7 @@ declare class Notabene {
|
|
|
400
429
|
private authToken?;
|
|
401
430
|
private uxUrl;
|
|
402
431
|
private theme?;
|
|
403
|
-
private
|
|
432
|
+
private locale?;
|
|
404
433
|
constructor(config: NotabeneConfig);
|
|
405
434
|
componentUrl(path: string, value: Partial<Transaction>, configuration?: any, callbacks?: CallbackOptions): string;
|
|
406
435
|
createComponent(path: string, value: Partial<Transaction>, options?: any, callbacks?: CallbackOptions): EmbeddedComponent;
|
|
@@ -422,9 +451,7 @@ export declare interface NotabeneConfig {
|
|
|
422
451
|
authToken?: string;
|
|
423
452
|
uxUrl?: string;
|
|
424
453
|
theme?: Theme;
|
|
425
|
-
|
|
426
|
-
[key: string]: string;
|
|
427
|
-
};
|
|
454
|
+
locale?: string;
|
|
428
455
|
}
|
|
429
456
|
|
|
430
457
|
/**
|
|
@@ -459,9 +486,22 @@ export declare interface OwnershipProof {
|
|
|
459
486
|
* 6.7
|
|
460
487
|
* Data describing the contents of the payload.
|
|
461
488
|
*/
|
|
462
|
-
declare
|
|
463
|
-
|
|
464
|
-
|
|
489
|
+
declare interface PayloadMetadata {
|
|
490
|
+
/** The method used to map from a national system of writing to Latin script. */
|
|
491
|
+
transliterationMethod?: TransliterationMethodCode[];
|
|
492
|
+
/** The version of IVMS 101 to which the payload complies. */
|
|
493
|
+
payloadVersion: PayloadVersionCode;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* The version of IVMS 101 to which the payload complies.
|
|
498
|
+
*/
|
|
499
|
+
declare enum PayloadVersionCode {
|
|
500
|
+
/** Published May 2020 */
|
|
501
|
+
V101 = "101",
|
|
502
|
+
/** Published August 2023 */
|
|
503
|
+
V101_2023 = "101.2023"
|
|
504
|
+
}
|
|
465
505
|
|
|
466
506
|
/**
|
|
467
507
|
* 5.2.1
|
package/dist/notabene.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var u = (s, e, t) => e in s ?
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var u = (s, e, t) => e in s ? d(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
3
|
var o = (s, e, t) => u(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var h = /* @__PURE__ */ ((s) => (s.COMPLETE = "complete", s.RESIZE = "resize", s.RESULT = "result", s.READY = "ready", s.INVALID = "invalid", s.MODAL = "openModal", s.ERROR = "error", s.CLOSE = "closeModal", s.CANCEL = "cancel", s))(h || {}), c = /* @__PURE__ */ ((s) => (s.UPDATE = "update", s.REQUEST_RESPONSE = "requestResponse", s))(c || {});
|
|
5
|
-
class
|
|
5
|
+
class m {
|
|
6
6
|
constructor() {
|
|
7
7
|
o(this, "listeners", /* @__PURE__ */ new Map());
|
|
8
8
|
o(this, "port");
|
|
@@ -22,18 +22,16 @@ class f {
|
|
|
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 r = t.type,
|
|
26
|
-
|
|
25
|
+
const r = t.type, n = this.listeners.get(r);
|
|
26
|
+
n && n.forEach((i) => i(t));
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
// Method to send messages through the port
|
|
30
30
|
send(e) {
|
|
31
|
-
|
|
32
|
-
throw new Error("No port set");
|
|
33
|
-
this.port.postMessage(e);
|
|
31
|
+
this.port && this.port.postMessage(e);
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
class
|
|
34
|
+
class f {
|
|
37
35
|
constructor(e, t) {
|
|
38
36
|
o(this, "_url");
|
|
39
37
|
o(this, "_value");
|
|
@@ -41,7 +39,7 @@ class m {
|
|
|
41
39
|
o(this, "iframe");
|
|
42
40
|
o(this, "eventManager");
|
|
43
41
|
o(this, "ready", !1);
|
|
44
|
-
this._url = e, this._value = t, this.eventManager = new
|
|
42
|
+
this._url = e, this._value = t, this.eventManager = new m(), this.on(h.INVALID, (r) => {
|
|
45
43
|
r.type === h.INVALID && (this._errors = r.errors, this._value = r.value);
|
|
46
44
|
}), this.on(h.RESIZE, (r) => {
|
|
47
45
|
r.type === h.RESIZE && this.iframe && (this.iframe.style.height = `${r.height}px`);
|
|
@@ -60,14 +58,14 @@ class m {
|
|
|
60
58
|
document.location.href = this.url;
|
|
61
59
|
}
|
|
62
60
|
mount(e) {
|
|
63
|
-
var r,
|
|
64
|
-
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", window.addEventListener("message", (
|
|
65
|
-
var a,
|
|
66
|
-
|
|
61
|
+
var r, n;
|
|
62
|
+
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", window.addEventListener("message", (i) => {
|
|
63
|
+
var a, l;
|
|
64
|
+
i.source === ((a = this.iframe) == null ? void 0 : a.contentWindow) && (console.log("received message from iframe", i.data), (l = this.eventManager) == null || l.setPort(i.ports[0]), this.ready = !0);
|
|
67
65
|
});
|
|
68
66
|
const t = document.querySelector(e);
|
|
69
67
|
if (!t) throw new Error(`parentID ${e} not found`);
|
|
70
|
-
t.appendChild(this.iframe), (
|
|
68
|
+
t.appendChild(this.iframe), (n = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || n.focus();
|
|
71
69
|
}
|
|
72
70
|
send(e) {
|
|
73
71
|
this.eventManager.send(e);
|
|
@@ -94,10 +92,10 @@ class m {
|
|
|
94
92
|
function p(s) {
|
|
95
93
|
return Object.entries(s).map(([e, t]) => {
|
|
96
94
|
if (!(e && t)) return;
|
|
97
|
-
const r = encodeURIComponent(e),
|
|
95
|
+
const r = encodeURIComponent(e), n = encodeURIComponent(
|
|
98
96
|
typeof t == "object" ? JSON.stringify(t) : t
|
|
99
97
|
);
|
|
100
|
-
return `${r}=${
|
|
98
|
+
return `${r}=${n}`;
|
|
101
99
|
}).filter((e) => !!e).join("&");
|
|
102
100
|
}
|
|
103
101
|
class g {
|
|
@@ -106,22 +104,22 @@ class g {
|
|
|
106
104
|
o(this, "authToken");
|
|
107
105
|
o(this, "uxUrl");
|
|
108
106
|
o(this, "theme");
|
|
109
|
-
o(this, "
|
|
110
|
-
this.uxUrl = e.uxUrl || "https://connect.notabene.id", this.nodeUrl = e.nodeUrl, this.authToken = e.authToken, this.theme = e.theme, this.
|
|
107
|
+
o(this, "locale");
|
|
108
|
+
this.uxUrl = e.uxUrl || "https://connect.notabene.id", this.nodeUrl = e.nodeUrl, this.authToken = e.authToken, this.theme = e.theme, this.locale = e.locale;
|
|
111
109
|
}
|
|
112
|
-
componentUrl(e, t, r,
|
|
113
|
-
const
|
|
114
|
-
|
|
110
|
+
componentUrl(e, t, r, n) {
|
|
111
|
+
const i = new URL(this.uxUrl);
|
|
112
|
+
i.pathname = e;
|
|
115
113
|
const a = p({
|
|
116
114
|
authToken: this.authToken,
|
|
117
115
|
value: t,
|
|
118
116
|
configuration: r
|
|
119
117
|
});
|
|
120
|
-
return
|
|
118
|
+
return i.hash = a, this.nodeUrl && i.searchParams.set("nodeUrl", this.nodeUrl), this.theme && i.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && i.searchParams.set("locale", this.locale), n && (n.callback && i.searchParams.set("callback_url", n.callback), n.redirectUri && i.searchParams.set("redirect_uri", n.redirectUri)), i.toString();
|
|
121
119
|
}
|
|
122
|
-
createComponent(e, t, r,
|
|
123
|
-
return new
|
|
124
|
-
this.componentUrl(e, t, r,
|
|
120
|
+
createComponent(e, t, r, n) {
|
|
121
|
+
return new f(
|
|
122
|
+
this.componentUrl(e, t, r, n),
|
|
125
123
|
t
|
|
126
124
|
);
|
|
127
125
|
}
|
|
@@ -130,9 +128,9 @@ class g {
|
|
|
130
128
|
}
|
|
131
129
|
decodeFragmentToObject(e) {
|
|
132
130
|
return e.slice(1).split("&").reduce(
|
|
133
|
-
(r,
|
|
134
|
-
const [
|
|
135
|
-
return r[decodeURIComponent(
|
|
131
|
+
(r, n) => {
|
|
132
|
+
const [i, a] = n.split("=");
|
|
133
|
+
return r[decodeURIComponent(i)] = decodeURIComponent(a), r;
|
|
136
134
|
},
|
|
137
135
|
{}
|
|
138
136
|
);
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { fc, test } from '@fast-check/vitest';
|
|
|
2
2
|
import { describe } from 'vitest';
|
|
3
3
|
import { abitraryCallbackOptions, arbitraryComponent } from '../arbitraries';
|
|
4
4
|
import Notabene from '../notabene';
|
|
5
|
+
import { arbitraryLocale } from '../utils/arbitraries';
|
|
5
6
|
|
|
6
7
|
describe('Notabene', () => {
|
|
7
8
|
describe('defaults', () => {
|
|
@@ -28,6 +29,33 @@ describe('Notabene', () => {
|
|
|
28
29
|
);
|
|
29
30
|
});
|
|
30
31
|
|
|
32
|
+
describe('locale', () => {
|
|
33
|
+
test.prop([
|
|
34
|
+
fc.string({ minLength: 3 }),
|
|
35
|
+
fc.webUrl(),
|
|
36
|
+
arbitraryComponent(),
|
|
37
|
+
fc.object(),
|
|
38
|
+
arbitraryLocale(),
|
|
39
|
+
])(
|
|
40
|
+
'Should set the correct values',
|
|
41
|
+
(authToken, nodeUrl, component, value, locale) => {
|
|
42
|
+
const notabene = new Notabene({
|
|
43
|
+
nodeUrl,
|
|
44
|
+
authToken,
|
|
45
|
+
locale,
|
|
46
|
+
});
|
|
47
|
+
const url = new URL(notabene.componentUrl(component, value));
|
|
48
|
+
return (
|
|
49
|
+
url.hash ===
|
|
50
|
+
`#authToken=${encodeURIComponent(authToken)}&value=${encodeURIComponent(JSON.stringify(value))}` &&
|
|
51
|
+
url.searchParams.get('nodeUrl') === nodeUrl &&
|
|
52
|
+
url.searchParams.get('locale') === locale &&
|
|
53
|
+
url.pathname === `/${component}`
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
31
59
|
describe('minimal', () => {
|
|
32
60
|
test.prop([arbitraryComponent(), fc.object()])(
|
|
33
61
|
'Should set the correct values',
|
package/src/ivms/types.ts
CHANGED
|
@@ -120,22 +120,38 @@ export type DateAndPlaceOfBirth = {
|
|
|
120
120
|
* Address
|
|
121
121
|
*/
|
|
122
122
|
export type Address = {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
123
|
+
/** Identifies the nature of the address. */
|
|
124
|
+
addressType: AddressTypeCode;
|
|
125
|
+
/** Identification of a division of a large organisation or building. */
|
|
126
|
+
department?: string;
|
|
127
|
+
/** Identification of a sub-division of a large organisation or building. */
|
|
128
|
+
subDepartment?: string;
|
|
129
|
+
/** Name of a street or thoroughfare. */
|
|
130
|
+
streetName?: string;
|
|
131
|
+
/** Number that identifies the position of a building on a street. */
|
|
132
|
+
buildingNumber?: string;
|
|
133
|
+
/** Name of the building or house. */
|
|
134
|
+
buildingName?: string;
|
|
135
|
+
/** Floor or storey within a building. */
|
|
136
|
+
floor?: string;
|
|
137
|
+
/** Numbered box in a post office. */
|
|
138
|
+
postBox?: string;
|
|
139
|
+
/** Building room number. */
|
|
140
|
+
room?: string;
|
|
141
|
+
/** Identifier consisting of a group of letters and/or numbers that is added to a postal address to assist the sorting of mail. */
|
|
142
|
+
postcode?: string;
|
|
143
|
+
/** Name of a built-up area, with defined boundaries, and a local government. */
|
|
144
|
+
townName: string;
|
|
145
|
+
/** Specific location name within the town. */
|
|
146
|
+
townLocationName?: string;
|
|
147
|
+
/** Identifies a subdivision within a country subdivision. */
|
|
148
|
+
districtName?: string;
|
|
149
|
+
/** Identifies a subdivision of a country such as state, region, province. */
|
|
150
|
+
countrySubDivision?: string;
|
|
151
|
+
/** Information that locates and identifies a specific address, presented in free format text. */
|
|
152
|
+
addressLine?: string[];
|
|
153
|
+
/** Nation with its own government. */
|
|
154
|
+
country: string;
|
|
139
155
|
};
|
|
140
156
|
|
|
141
157
|
/**
|
|
@@ -173,12 +189,18 @@ export type NaturalPersonName = {
|
|
|
173
189
|
* NaturalPerson
|
|
174
190
|
*/
|
|
175
191
|
export type NaturalPerson = {
|
|
176
|
-
|
|
192
|
+
/** The distinct words used as identification for an individual. */
|
|
193
|
+
name: NaturalPersonName;
|
|
194
|
+
/** The particulars of a location at which a person may be communicated with. */
|
|
177
195
|
geographicAddress?: Address[];
|
|
196
|
+
/** A distinct identifier used by governments to uniquely identify a natural person. */
|
|
178
197
|
nationalIdentification?: NationalIdentification;
|
|
179
|
-
|
|
198
|
+
/** A distinct identifier that uniquely identifies the person to the institution in context. */
|
|
199
|
+
customerIdentification?: string;
|
|
200
|
+
/** Date and place of birth of a person. */
|
|
180
201
|
dateAndPlaceOfBirth?: DateAndPlaceOfBirth;
|
|
181
|
-
|
|
202
|
+
/** Country in which a person resides (the place of a person's home). */
|
|
203
|
+
countryOfResidence?: string;
|
|
182
204
|
};
|
|
183
205
|
|
|
184
206
|
/**
|
|
@@ -195,8 +217,10 @@ export type LocalLegalPersonNameID = {
|
|
|
195
217
|
* LegalPersonNameID
|
|
196
218
|
*/
|
|
197
219
|
export type LegalPersonNameID = {
|
|
198
|
-
|
|
199
|
-
|
|
220
|
+
/** Name by which the legal person is known. */
|
|
221
|
+
legalPersonName: string;
|
|
222
|
+
/** The nature of the name specified. */
|
|
223
|
+
legalPersonNameIdentifierType: LegalPersonNameTypeCode;
|
|
200
224
|
};
|
|
201
225
|
|
|
202
226
|
/**
|
|
@@ -204,7 +228,7 @@ export type LegalPersonNameID = {
|
|
|
204
228
|
* LegalPersonName
|
|
205
229
|
*/
|
|
206
230
|
export type LegalPersonName = {
|
|
207
|
-
nameIdentifier
|
|
231
|
+
nameIdentifier: LegalPersonNameID[];
|
|
208
232
|
localNameIdentifier?: LocalLegalPersonNameID[];
|
|
209
233
|
phoneticNameIdentifier?: LocalLegalPersonNameID[];
|
|
210
234
|
};
|
|
@@ -214,11 +238,16 @@ export type LegalPersonName = {
|
|
|
214
238
|
* LegalPerson
|
|
215
239
|
*/
|
|
216
240
|
export type LegalPerson = {
|
|
217
|
-
name
|
|
241
|
+
/** The name of the legal person. */
|
|
242
|
+
name: LegalPersonName;
|
|
243
|
+
/** The address of the legal person. */
|
|
218
244
|
geographicAddress?: Address[];
|
|
219
|
-
|
|
245
|
+
/** A distinct identifier that uniquely identifies the person to the institution in context. */
|
|
246
|
+
customerNumber?: string;
|
|
247
|
+
/** A distinct identifier used by governments to uniquely identify a legal person. */
|
|
220
248
|
nationalIdentification?: NationalIdentification;
|
|
221
|
-
|
|
249
|
+
/** The country in which the legal person is registered. */
|
|
250
|
+
countryOfRegistration?: string;
|
|
222
251
|
};
|
|
223
252
|
|
|
224
253
|
/**
|
|
@@ -285,9 +314,21 @@ export type TransferPath = {
|
|
|
285
314
|
* 6.7
|
|
286
315
|
* Data describing the contents of the payload.
|
|
287
316
|
*/
|
|
288
|
-
export
|
|
289
|
-
|
|
290
|
-
|
|
317
|
+
export interface PayloadMetadata {
|
|
318
|
+
/** The method used to map from a national system of writing to Latin script. */
|
|
319
|
+
transliterationMethod?: TransliterationMethodCode[];
|
|
320
|
+
/** The version of IVMS 101 to which the payload complies. */
|
|
321
|
+
payloadVersion: PayloadVersionCode;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* The version of IVMS 101 to which the payload complies.
|
|
325
|
+
*/
|
|
326
|
+
export enum PayloadVersionCode {
|
|
327
|
+
/** Published May 2020 */
|
|
328
|
+
V101 = '101',
|
|
329
|
+
/** Published August 2023 */
|
|
330
|
+
V101_2023 = '101.2023',
|
|
331
|
+
}
|
|
291
332
|
|
|
292
333
|
/**
|
|
293
334
|
* IVMS101 definition
|
package/src/notabene.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface NotabeneConfig {
|
|
|
66
66
|
authToken?: string;
|
|
67
67
|
uxUrl?: string;
|
|
68
68
|
theme?: Theme;
|
|
69
|
-
|
|
69
|
+
locale?: string;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -80,14 +80,14 @@ export default class Notabene {
|
|
|
80
80
|
private authToken?: string;
|
|
81
81
|
private uxUrl: string;
|
|
82
82
|
private theme?: Theme;
|
|
83
|
-
private
|
|
83
|
+
private locale?: string;
|
|
84
84
|
|
|
85
85
|
constructor(config: NotabeneConfig) {
|
|
86
86
|
this.uxUrl = config.uxUrl || 'https://connect.notabene.id';
|
|
87
87
|
this.nodeUrl = config.nodeUrl;
|
|
88
88
|
this.authToken = config.authToken;
|
|
89
89
|
this.theme = config.theme;
|
|
90
|
-
this.
|
|
90
|
+
this.locale = config.locale;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
public componentUrl(
|
|
@@ -110,8 +110,8 @@ export default class Notabene {
|
|
|
110
110
|
if (this.theme) {
|
|
111
111
|
url.searchParams.set('theme', JSON.stringify(this.theme));
|
|
112
112
|
}
|
|
113
|
-
if (this.
|
|
114
|
-
url.searchParams.set('
|
|
113
|
+
if (this.locale) {
|
|
114
|
+
url.searchParams.set('locale', this.locale);
|
|
115
115
|
}
|
|
116
116
|
if (callbacks) {
|
|
117
117
|
if (callbacks.callback)
|
|
@@ -47,9 +47,8 @@ export class MessageEventManager {
|
|
|
47
47
|
|
|
48
48
|
// Method to send messages through the port
|
|
49
49
|
send(message: HostMessage): void {
|
|
50
|
-
if (
|
|
51
|
-
|
|
50
|
+
if (this.port) {
|
|
51
|
+
this.port.postMessage(message);
|
|
52
52
|
}
|
|
53
|
-
this.port.postMessage(message);
|
|
54
53
|
}
|
|
55
54
|
}
|
package/src/utils/arbitraries.ts
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
CAIP2_MATCHER,
|
|
8
8
|
} from './caip';
|
|
9
9
|
|
|
10
|
+
const LOCALE = new RegExp(/^[a-z]{2}(-[A-Z]{2})?$/);
|
|
11
|
+
|
|
10
12
|
// Arbitraries
|
|
11
13
|
export const arbitraryCAIP10 = (): fc.Arbitrary<CAIP10> =>
|
|
12
14
|
fc.stringMatching(CAIP10_MATCHER) as fc.Arbitrary<CAIP10>;
|
|
@@ -19,3 +21,6 @@ export const arbitraryCAIP19 = (): fc.Arbitrary<CAIP19> =>
|
|
|
19
21
|
|
|
20
22
|
export const arbitraryCAIP220 = (): fc.Arbitrary<CAIP220> =>
|
|
21
23
|
fc.stringMatching(CAIP220_MATCHER) as fc.Arbitrary<CAIP220>;
|
|
24
|
+
|
|
25
|
+
export const arbitraryLocale = (): fc.Arbitrary<string> =>
|
|
26
|
+
fc.stringMatching(LOCALE) as fc.Arbitrary<string>;
|