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

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.
Files changed (64) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +281 -231
  3. package/dist/js/notabene.js +1 -0
  4. package/dist/notabene.cjs +1 -1
  5. package/dist/notabene.d.ts +1052 -209
  6. package/dist/notabene.js +275 -105
  7. package/dist/tsdoc-metadata.json +1 -1
  8. package/package.json +36 -26
  9. package/src/__tests__/notabene.test.ts +43 -0
  10. package/src/components/EmbeddedComponent.ts +141 -22
  11. package/src/components/__tests__/EmbeddedComponent.test.ts +73 -20
  12. package/src/ivms/types.ts +230 -152
  13. package/src/locales.ts +47 -0
  14. package/src/notabene.ts +243 -90
  15. package/src/types.ts +723 -144
  16. package/src/utils/MessageEventManager.ts +70 -12
  17. package/src/utils/__tests__/MessageEventManager.test.ts +13 -5
  18. package/src/utils/arbitraries.ts +9 -4
  19. package/.editorconfig +0 -10
  20. package/.gitlab-ci.yml +0 -85
  21. package/.husky/commit-msg +0 -4
  22. package/.husky/pre-commit +0 -4
  23. package/.husky/pre-push +0 -4
  24. package/.prettierrc +0 -4
  25. package/.releaserc.json +0 -16
  26. package/.vscode/extensions.json +0 -3
  27. package/.vscode/settings.json +0 -11
  28. package/.yarn/releases/yarn-berry.cjs +0 -925
  29. package/.yarnrc.yml +0 -3
  30. package/CODEOWNERS +0 -1
  31. package/api-extractor.json +0 -434
  32. package/eslint.config.js +0 -24
  33. package/etc/javascript-sdk.api.md +0 -363
  34. package/index.html +0 -137
  35. package/temp/javascript-sdk.api.json +0 -3509
  36. package/temp/javascript-sdk.api.md +0 -363
  37. package/ts-out/src/__tests__/notabene.test.d.ts +0 -1
  38. package/ts-out/src/__tests__/notabene.test.js +0 -88
  39. package/ts-out/src/arbitraries.d.ts +0 -4
  40. package/ts-out/src/arbitraries.js +0 -8
  41. package/ts-out/src/components/EmbeddedComponent.d.ts +0 -25
  42. package/ts-out/src/components/EmbeddedComponent.js +0 -87
  43. package/ts-out/src/components/__tests__/EmbeddedComponent.test.d.ts +0 -1
  44. package/ts-out/src/components/__tests__/EmbeddedComponent.test.js +0 -132
  45. package/ts-out/src/ivms/types.d.ts +0 -252
  46. package/ts-out/src/ivms/types.js +0 -1
  47. package/ts-out/src/notabene.d.ts +0 -35
  48. package/ts-out/src/notabene.js +0 -59
  49. package/ts-out/src/types.d.ts +0 -357
  50. package/ts-out/src/types.js +0 -85
  51. package/ts-out/src/utils/MessageEventManager.d.ts +0 -12
  52. package/ts-out/src/utils/MessageEventManager.js +0 -45
  53. package/ts-out/src/utils/__tests__/MessageEventManager.test.d.ts +0 -1
  54. package/ts-out/src/utils/__tests__/MessageEventManager.test.js +0 -73
  55. package/ts-out/src/utils/arbitraries.d.ts +0 -6
  56. package/ts-out/src/utils/arbitraries.js +0 -7
  57. package/ts-out/src/utils/caip.d.ts +0 -13
  58. package/ts-out/src/utils/caip.js +0 -15
  59. package/ts-out/src/utils/urls.d.ts +0 -1
  60. package/ts-out/src/utils/urls.js +0 -14
  61. package/ts-out/tsconfig.tsbuildinfo +0 -1
  62. package/tsconfig.json +0 -22
  63. package/tsconfig.tsbuildinfo +0 -1
  64. package/vite.config.js +0 -13
package/README.md CHANGED
@@ -5,12 +5,11 @@
5
5
 
6
6
  # JavaScript SDK
7
7
 
8
- [![pipeline status](https://gitlab.com/notabene/open-source/javascript-sdk/badges/master/pipeline.svg)](https://gitlab.com/notabene/open-source/javascript-sdk/-/commits/master)
9
- [![Latest Release](https://gitlab.com/notabene/open-source/javascript-sdk/-/badges/release.svg)](https://gitlab.com/notabene/open-source/javascript-sdk/-/releases)
8
+ [![pipeline status](https://gitlab.com/notabene/open-source/javascript-sdk/badges/v2/pipeline.svg)](https://gitlab.com/notabene/open-source/javascript-sdk/-/commits/v2)
10
9
 
11
10
  This library is the JavaScript SDK for loading the Notabene UX components in the front-end.
12
11
 
13
- [Documentation](https://devx.notabene.id/docs/widget-v2) •
12
+ [Documentation](https://devx.notabene.id/docs/embedded=ux)
14
13
  [Installation](#installation)
15
14
 
16
15
  </div>
@@ -27,17 +26,17 @@ This library is the JavaScript SDK for loading the Notabene UX components in the
27
26
  - [Asset specification](#asset-specification)
28
27
  - [Transaction amount specification](#transaction-amount-specification)
29
28
  - [Destination address](#destination-address)
30
- - [Error handling](#error-handling)
31
- - [Customization](#customization)
32
- - [Functionality](#functionality)
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
- - [Fields Properties](#fields-properties)
38
- - [Fallbacks](#fallbacks)
39
- - [Opt-In Features](#opt-in-features)
40
- - [Transaction Custom Asset Price](#transaction-custom-asset-price)
29
+ - [Destination address](#destination-address-1)
30
+ - [Connect Wallet](#connect-wallet)
31
+ - [Asset specification](#asset-specification-1)
32
+ - [Modal](#modal)
33
+ - [Linked Component](#linked-component-1)
34
+ - [Error handling](#error-handling)
35
+ - [Transaction Options](#transaction-options)
36
+ - [Common use cases](#common-use-cases)
37
+ - [Configuring ownership proofs](#configuring-ownership-proofs)
38
+ - [Counterparty Field Properties](#counterparty-field-properties)
39
+ - [Locales](#locales)
41
40
  - [License](#license)
42
41
 
43
42
  ## Installation
@@ -45,13 +44,27 @@ This library is the JavaScript SDK for loading the Notabene UX components in the
45
44
  There are two options for loading the Notabene SDK:
46
45
 
47
46
  ```bash
48
- <script id="notabene" async src="https://unpkg.com/@notabene/javascript-sdk@1.31.0/dist/es/index.js"></script>
47
+ <script id="notabene" async src="https://unpkg.com/@notabene/javascript-sdk@next/dist/notabene.js"></script>
49
48
  ```
50
49
 
51
50
  Or installing the library:
52
51
 
52
+ Using Yarn:
53
+
53
54
  ```bash
54
- yarn add @notabene/javascript-sdk
55
+ yarn add @notabene/javascript-sdk@next
56
+ ```
57
+
58
+ Using NPM:
59
+
60
+ ```bash
61
+ npm install @notabene/javascript-sdk@next
62
+ ```
63
+
64
+ If you installed the library into your project, you can import it into your project:
65
+
66
+ ```js
67
+ import Notabene from '@notabene/javascript-sdk';
55
68
  ```
56
69
 
57
70
  ## Usage
@@ -67,10 +80,10 @@ Use the [customer token endpoint](https://devx.notabene.id/docs/customertoken) w
67
80
  Create a new Notabene instance:
68
81
 
69
82
  ```js
70
-
71
83
  const notabene = new Notabene({
72
- nodeUrl: 'https://api.notabene.id',
73
- authToken: '{CUSTOMER_TOKEN}'
84
+ nodeUrl: 'https://api.notabene.id', // use `https://api.notabene.dev` for testing
85
+ authToken: '{CUSTOMER_TOKEN}',
86
+ locale: 'de', // default locale = `en`
74
87
  });
75
88
  ```
76
89
 
@@ -94,19 +107,20 @@ Instantiate the withdrawal element and mount it using the id from above
94
107
 
95
108
  ```js
96
109
  const withdrawal = notabene.createWithdrawalAssist(tx, options);
97
- withdrawal.mount("nb-withdrawal");
110
+ withdrawal.mount('nb-withdrawal');
98
111
  ```
99
112
 
100
113
  The simplest way to get the result is to use:
101
114
 
102
115
  ```js
103
116
  try {
104
- const {valid, ivms101} = await withdrawal.completion()
105
- if (valid) {
106
- // Submit result to your backend
107
- }
117
+ const { valid, value, txCreate, ivms101, proof } =
118
+ await withdrawal.completion();
119
+ if (valid) {
120
+ // Submit result to your backend
121
+ }
108
122
  } catch (e) {
109
- console.error(e)
123
+ console.error(e);
110
124
  }
111
125
  ```
112
126
 
@@ -118,14 +132,14 @@ To update the component as users enter transaction details:
118
132
  withdrawal.update({
119
133
  asset: 'ETH',
120
134
  destination: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
121
- amountDecimal: 1.12
135
+ amountDecimal: 1.12,
122
136
  });
123
137
  ```
124
138
 
125
139
  To be notified once the validation is completed so you can submit the withdrawal to your back end:
126
140
 
127
141
  ```js
128
- withdrawal.on('valid', {ivms101} => ...)
142
+ withdrawal.on('complete', { valid, value, txCreate, ivms101, proof } => ...)
129
143
  ```
130
144
 
131
145
  To be notified of any errors use:
@@ -172,7 +186,6 @@ The `asset` field the following types of assets specified:
172
186
  Use one of the following
173
187
 
174
188
  - `amountDecimal` A number specifying the amount in decimal format. Eg. `amountDecimal=1.1` would mean 1.1 of for example BTC or ETH.
175
- - `amountSubunits` A string specifying the amount in the native blockchain subunits eg Satoshi for Bitcoin or wei for Ethereum
176
189
 
177
190
  ### Destination address
178
191
 
@@ -183,279 +196,316 @@ Specify the beneficiary address as `destination` using one of the following form
183
196
  - [BIP-21](https://en.bitcoin.it/wiki/BIP_0021) Bitcoin URI
184
197
  - Native blockchain address
185
198
 
186
- ---
187
-
188
- ### Error handling
189
-
190
- If any error occurs, the `onError` function from the Notabene instance will be triggered. The `error` passed as argument contains a `data` property that has the following type `ErrorData`.
199
+ ### Destination address
191
200
 
192
- > ⚠️ **Note**: These errors are mainly used for debugging internal issues while implementing the widget. They are not meant to be shown directly to the end user.
201
+ The price of the asset is used to determine certain rules based on thresholds. We recommond you pass in your price like this:
193
202
 
194
- ```js
195
- type ErrorData = {
196
- title: string;
197
- detail: string;
198
- code: number;
199
- type: string;
203
+ ```ts
204
+ assetPrice: {
205
+ currency: 'USD', // ISO currency code
206
+ price: 1700.12, // Asset price
200
207
  };
201
-
202
- const notabene = new Notabene({
203
- ...,
204
- onError: (err) => {
205
- const errorData = err.data;
206
-
207
- // Do something
208
- },
209
- });
210
208
  ```
211
209
 
212
- **Notabene Internal Errors**
210
+ ## Connect Wallet
213
211
 
214
- Type | Code | Title | Detail
215
- -- | -- | -- | --
216
- `BAD_REQUEST` | `400` | `Bad Request` | `NotabeneBadRequest: ...`
217
- `TRANSACTION_INVALID` | `400` | `Transaction Invalid` | `NotabeneTransactionInvalid: ...`
218
- `TOKEN_INVALID` | `401` | `Token Invalid` | `NotabeneTokenInvalid: ...`
219
- `ASSET_NOT_SUPPORTED` | `404` | `Asset Not Supported` | `NotabeneAssetNotSupported: ...`
220
- `SERVICE_UNAVAILABLE` | `500` | `Service Unavailable` | `NotabeneServiceUnavailable: ...`
221
- `WALLET_CONNECTED_FAILED` | `500` | `Wallet Connection Failed` | `NotabeneWalletConnectionFailed: ...`
222
- `WALLET_NOT_SUPPORTED` | `501` | `Wallet Not Supported` | `NotabeneWalletNotSupported: ...`
212
+ The Connect Wallet component helps you collect and verify the address of your users self-hosted wallet in one go.
223
213
 
224
- ## Customization
214
+ ### Asset specification
225
215
 
226
- ### Functionality
216
+ The `asset` field the following types of assets specified:
227
217
 
228
- `transactionTypeAllowed`: `ALL` | `VASP_2_VASP_ONLY` | `FIRST_PARTY_ONLY`
218
+ - `notabene_asset` code passed as a`string`. See [Notabene Assets Service](https://devx.notabene.id/docs/coins-decimals#assets-service-api).
219
+ - [CAIP-19](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md_) is a chain agnostic format allows you to support the widest amount of assets and blockchains including NFTs.
220
+ - [DTI](https://www.iso.org/standard/80601.html) is the ISO Digital Token Identifier format. See [DTI registry](https://dtif.org/registry-search/) for supported tokens.
229
221
 
230
- For limiting the type of transaction destinations you can pass.
222
+ ### Modal
231
223
 
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.
224
+ Instantiate the modal and open it
235
225
 
236
- ---
226
+ ```js
227
+ const connect = notabene.createConnectWallet({ asset: 'ETH' }, options);
228
+ const { valid, value, txCreate, ivms101, proof } = await connect.openModal();
229
+ ```
237
230
 
238
- `nonCustodialDeclarationType`: `SIGNATURE` | `DECLARATION`
231
+ ### Linked Component
239
232
 
240
- For deciding which ownership proof type you want to use.
233
+ In some cases, in particular institutional or mobile apps you may prefer to link your customers to the component through an email or redirect the user to it in a mobile app.
241
234
 
242
- `SIGNATURE`: The ownership proof will be signed by the originator using a wallet. (DEFAULT)
243
- `DECLARATION`: The ownership proof will be declared by the originator using a checkbox.
235
+ ```js
236
+ const connect = notabene.createConnectWallet({asset:'ETH'}, options, {
237
+ callback: /// a serverside backend url
238
+ redirectUri: // URI of website or mobile app to redirect user to after completion
239
+ });
244
240
 
245
- ---
241
+ // NodeJS redirect. Link also works in an email.
242
+ res.redirect(withdrawal.url);
243
+ ```
246
244
 
247
- `counterpartyManualEntry`: `TRUE` | `FALSE`
245
+ Bear in mind that this is a full screen view for your users.
248
246
 
249
- For deciding if you would like to allow your customer to provide a manual counterparty vasp name in the counterparty field.
247
+ The two parameters that should be configured are:
250
248
 
251
- ### Pass the variables in the configuration
249
+ - `callback` - a URL for your serverside. On completion this will receive an HTTP POST with the result as a json body and the `authToken` as an `Authorization: Bearer` header.
250
+ - `redirectUri` - the user will be redirected here on completion. The result parameters will be json encoded in the URL fragment. You can use a mobile app schema to intercept these in your mobile app.
252
251
 
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
- ```
252
+ **Note** for data privacy reasons the callback will be coming from your users web browser and not from our infrastructure, so no static IP is currently possible. Instead please check the `authToken` provided with the request.
263
253
 
264
254
  ---
265
255
 
266
- ### Theme
256
+ ## Error handling
267
257
 
268
- Pass a `theme` object when creating an instance
258
+ If any error occurs, the `error` event is passed containing a message.
269
259
 
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
- }
260
+ ```ts
261
+ withdrawal.on('error', {message} => ...)
306
262
  ```
307
263
 
308
- To get a list of supported fonts, visit [https://fonts.google.com/](https://fonts.google.com/)
264
+ ## Transaction Options
309
265
 
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).
266
+ All components can be configured using an optional [TransactionOptions](./docs/interfaces/TransactionOptions.md) object.
311
267
 
312
- ---
268
+ The following shows the full set of options in typescript:
313
269
 
314
- ### Dictionary
270
+ ```ts
271
+ import Notabene, {
272
+ AgentType,
273
+ PersonType,
274
+ ProofTypes,
275
+ } from '@notabene/javascript-sdk';
315
276
 
316
- Pass a `dictionary` object mapping in text in the widget to your own language, for example:
277
+ const options: TransactionOptions = {
278
+ proofs: {
279
+ microTransfer: {
280
+ destination: '0x...',
281
+ amountSubunits: '12344',
282
+ timeout: 86440,
283
+ },
284
+ fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self_declaration']
285
+ },
286
+ allowedAgentTypes: [AgentType.PRIVATE, AgentType.VASP], // js ['WALLET','VASP']
287
+ allowedCounterpartyTypes: [
288
+ PersonType.LEGAL, // JS: 'legal'
289
+ PersonType.NATURAL, // JS: 'natural'
290
+ PersonType.SELF, // JS: 'self'
291
+ ],
292
+ fields: {
293
+ naturalPerson: {
294
+ name: true, // Default true
295
+ website: { optional: true },
296
+ email: true,
297
+ phone: true,
298
+ geographicAddress: false,
299
+ nationalIdentification: false,
300
+ dateOfBirth: false,
301
+ placeOfBirth: false,
302
+ countryOfResidence: true,
303
+ },
304
+ legalPerson: {
305
+ name: true, // Default true
306
+ lei: true, // Default true
307
+ website: { optional: true }, // Default true
308
+ email: true,
309
+ phone: true,
310
+ geographicAddress: false,
311
+ nationalIdentification: false,
312
+ countryOfRegistration: true,
313
+ },
314
+ vasps: {
315
+ addUnknown: true, // Allow users to add a missing VASP - Defaults to false
316
+ onlyActive: true, // Only list active VASPs - Default false
317
+ },
318
+ },
319
+ };
320
+ const withdrawal = notabene.createWithdrawalAssist(tx, options);
321
+ ```
317
322
 
318
- To replace `Loading...` with `Cargando...`
323
+ The options can additionally be updated dynamically with the `update()` function.
319
324
 
320
325
  ```js
321
- {
322
- 'Loading...': 'Cargando...',
323
- }
326
+ withdrawal.update({
327
+ asset: 'ETH',
328
+ destination: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
329
+ amountDecimal: 1.12,
330
+ }, {
331
+ proofs: {
332
+ microTransfer: {
333
+ destination: '0x...',
334
+ amountSubunits: '12344',
335
+ timeout: 86440,
336
+ }
337
+ }
338
+ });
324
339
  ```
325
340
 
326
- ###### The property name must be the same as the text in the widget, for it to be replaced
327
341
 
328
- ---
342
+ ### Common use cases
329
343
 
330
- ### Fields Properties
344
+ #### Only allow first party transactions
331
345
 
332
- Possible fields customization support:
346
+ ```ts
347
+ const firstParty: TransactionOptions = {
348
+ allowedCounterpartyTypes: [
349
+ PersonType.SELF, // JS: 'self'
350
+ ],
351
+ };
352
+ ```
333
353
 
334
- | field name | `forceDisplay` | `optional` | description |
335
- | ------------------------ | -------------- | ---------- | ------------------------------------------------------- |
336
- | `counterparty` | -- | ☑️ | Counterparty VASP or Wallet (destination or originator) |
337
- | `dateAndPlaceOfBirth` | ☑️ | -- | Recipient (or Sender) Date and Place of Birth |
338
- | `geographicAddress` | ☑️ | ☑️ | Recipient (or Sender) Address |
339
- | `firstName` | ☑️ | -- | Recipient (or Sender) First name |
340
- | `name` | ☑️ | -- | Recipient (or Sender) Last Name / Company Name |
341
- | `nationalIdentification` | ☑️ | --️ | Recipient (or Sender) National Identification |
342
- | `country` | ☑️ | ☑️ | Recipient (or Sender) Country of Residence (for natural person) / Country of Registration (for legal person) |
354
+ #### Only VASP to VASP transactions
343
355
 
344
- **Field Options**
356
+ ```ts
357
+ const vasp2vasp: TransactionOptions = {
358
+ allowedAgentTypes: [AgentType.VASP], // js ['VASP']
359
+ };
360
+ ```
345
361
 
346
- - **forceDisplay** - Force a field that is not required by your jurisdiction to be displayed - defaults to **false**
347
- - **optional** - Bypass the jurisdiction rules validation for that specific field - defaults to **false**
362
+ #### Only Self-hosted wallet transactions
348
363
 
349
- ```js
350
- {
351
- counterparty: {
352
- optional: true;
353
- },
354
- geographicAddress: {
355
- forceDisplay: true,
356
- optional: true;
357
- },
358
- }
364
+ ```ts
365
+ const options: TransactionOptions = {
366
+ allowedAgentTypes: [AgentType.PRIVATE], // js ['WALLET']
367
+ };
359
368
  ```
360
369
 
361
- ---
370
+ ### Configuring ownership proofs
362
371
 
363
- **_Beneficiary Details_ [DEPRECATED]**
372
+ By default components support message signing proofs.
364
373
 
365
- You can require specific beneficiary fields that are not required by your jurisdiction.
374
+ #### Supporting Micro Transactions (aka Satoshi tests)
366
375
 
367
- Possible fields:
376
+ You can support Micro Transfers (aka Satoshi tests) by adding a deposit address for the test.
368
377
 
369
- - `beneficiaryName` - Recipient Name
370
- - `beneficiaryGeographicAddress` - Recipient Address
371
- - `beneficiaryNationalIdentification` - Recipient National Identification
372
- - `beneficiaryDateAndPlaceOfBirth` - Recipient Date and Place of Birth
378
+ Your compliance team will have to determine how to handle and verify these transactions in the rules engine or individually.
373
379
 
374
- ```js
375
- beneficiaryDetails: [
376
- 'benficiaryName',
377
- 'beneficiaryGeographicAddress',
378
- 'beneficiaryNationalIdentification',
379
- 'beneficiaryDateAndPlaceOfBirth',
380
- ];
380
+ ```ts
381
+ const options: TransactionOptions = {
382
+ proofs: {
383
+ microTransfer: {
384
+ destination: '0x...',
385
+ amountSubunits: '1234',
386
+ timeout: 86440, // Optional timeout in seconds, which is displayed to the user
387
+ },
388
+ fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self_declaration']
389
+ },
390
+ };
381
391
  ```
382
392
 
383
- ---
384
-
385
- ### Fallbacks
393
+ Notabene does not currently verify these tests automatically as you likely already have the infrastructure to do so.
386
394
 
387
- Fallbacks are custom options provided when desired outcome is not achieved
395
+ You will receive a response back from the component containing a proof object. For MicroTransfers it will look like this:
388
396
 
389
- Possible options and actions:
397
+ ```ts
398
+ type MicroTransferProof {
399
+ type: ProofTypes.MicroTransfer;
400
+ status: ProofStatus.PENDING;
401
+ did: DID;
402
+ address: CAIP10; // CAIP10 account to be verified
403
+ txhash: string; // Transaction Hash to verify
404
+ chain: CAIP2; // CAIP2 identifier of blockchain
405
+ amountSubunits: string; // Amount in subunits eg (satoshi or wei) to be verified
406
+ }
407
+ ```
390
408
 
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
409
+ #### Fallback Proof Options
395
410
 
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
- ```
411
+ You may accept a few options if none of the other are available. We do not recommend them, as they do not provide sufficient proof. However many VASPs do allow them for now:
404
412
 
405
- ```js
406
- fallbacks: [{flow: "WALLET_NOT_SUPPORTED", action: "DECLARATION"}]
413
+ ```ts
414
+ const options: TransactionOptions = {
415
+ proofs: {
416
+ fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration], // js ['screenshot','self_declaration']
417
+ },
418
+ };
407
419
  ```
408
420
 
409
- ---
421
+ The two options are:
410
422
 
411
- Finally you pass the configuration to a Notabene instance:
423
+ - `screenshot` Where a user is requested to upload a screenshot of their wallet
424
+ - `self-declaration` Where a user self declares that they control the wallet address
412
425
 
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
- ```
426
+ ### Counterparty Field Properties
423
427
 
424
- ---
428
+ The fields requested from a customer about a counterparty can be configured with the fields object. You can configure required and optional fields individually for both natural and legal persons.
425
429
 
426
- ### Opt-In Features
430
+ We recommend working closely with your compliance team for this. Bearing in mind that different jurisdictions have different rules.
427
431
 
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
- });
432
+ Each field can be configured like this:
433
+
434
+ - `true` required field
435
+ - `false` don't show
436
+ - `{ optional: true }` show but don't require
437
+ - `{ transmit: true }` Include in beneficiary field of IVMS101 to be transmitted to counterparty
438
+
439
+ Eg:
440
+
441
+ ```ts
442
+ {
443
+ naturalPerson: {
444
+ website: { optional: true },
445
+ email: true,
446
+ phone: false,
447
+ }
448
+ }
437
449
  ```
438
450
 
439
- **Available Opt-In Features**
451
+ The above will always ask the user for the following for natural persons:
452
+
453
+ - `name` since it is on by default (you can disable it explicitly by setting it to `false`)
454
+ - `website` is show but is optional
455
+ - `email` is required
456
+
457
+ #### Full Example
458
+
459
+ ```ts
460
+ const options: TransactionOptions = {
461
+ fields: {
462
+ naturalPerson: {
463
+ name: true, // Default true
464
+ website: { optional: true },
465
+ email: true,
466
+ phone: true,
467
+ geographicAddress: false,
468
+ nationalIdentification: false,
469
+ dateOfBirth: {
470
+ transmit: true,
471
+ },
472
+ placeOfBirth: false,
473
+ countryOfResidence: true,
474
+ },
475
+ legalPerson: {
476
+ name: true, // Default true
477
+ lei: true, // Default true
478
+ website: { optional: true }, // Default true
479
+ email: true,
480
+ phone: true,
481
+ geographicAddress: false,
482
+ nationalIdentification: false,
483
+ countryOfRegistration: true,
484
+ },
485
+ },
486
+ };
487
+ ```
440
488
 
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.
489
+ #### Field reference
442
490
 
443
- ### Transaction Custom Asset Price
491
+ | Field name | Natural | Legal | IVMS101 | Transmitted | description |
492
+ | ------------------------ | ------- | ----- | ------- | ----------- | --------------------------------------------- |
493
+ | `name` | ✅ | ✅ | ✅ | ✅ | Full name |
494
+ | `email` | 🟩 | 🟩 | -- | -- | Email (for your internal purposes) |
495
+ | `website` | -- | ✅ | -- | -- | Business Website (for your internal purposes) |
496
+ | `phone` | 🟩 | 🟩 | -- | -- | Mobile Phone (for your internal purposes) |
497
+ | `geographicAddress` | 🟩 | 🟩 | ✅ | 🟩 | Residencial or business address |
498
+ | `nationalIdentification` | 🟩 | 🟩 | ✅ | 🟩 | National Identification number |
499
+ | `dateOfBirth` | 🟩 | -- | ✅ | 🟩 | Date of birth |
500
+ | `placeOfBirth` | 🟩 | -- | ✅ | 🟩 | Place of birth |
501
+ | `countryOfResidence` | 🟩 | -- | ✅ | 🟩 | Country of Residence |
502
+ | `lei` | -- | ✅ | ✅ | ✅ | LEI (Legal Entity Identifier) |
503
+ | `countryOfRegistration` | -- | 🟩 | ✅ | 🟩 | Country of Registration |
444
504
 
445
- To use your own asset price as fallback in case an asset is not supported by Notabene, you can provide a `customAssetPrice` object that will be used instead to render the widget with the correct jurisdiction requirements.
505
+ ## Locales
446
506
 
447
- ```js
448
- notabene.setTransaction({
449
- transactionAsset: 'ASSET_UNSUPPORTED_FROM_NOTABENE',
450
- beneficiaryAccountNumber: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
451
- transactionAmount: '2000000000',
452
- customAssetPrice: {
453
- priceUSD: 1700.12, // Asset price in USD
454
- decimals: 10 // Decimals used for the given transactionAmount
455
- };
456
- });
457
- ```
507
+ See [locales](src/locales.ts) for the list of supported locales.
458
508
 
459
509
  ## [License](LICENSE.md)
460
510
 
461
- BSD 3-Clause © Notabene Inc.
511
+ MIT © Notabene Inc.