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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,37 +5,45 @@
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
- This library is the JavaScript SDK for loading the widget on a frontend.
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>
17
16
 
18
- - [Installation](#installation)
19
- - [Usage](#usage)
20
- - [Supported asset formats](#supported-asset-formats)
21
- - [Re-rendering](#re-rendering)
17
+ - [JavaScript SDK](#javascript-sdk)
18
+ - [Installation](#installation)
19
+ - [Usage](#usage)
20
+ - [Authentication](#authentication)
21
+ - [Assisted Withdrawal](#assisted-withdrawal)
22
+ - [Embedded Component](#embedded-component)
23
+ - [Dynamic updates](#dynamic-updates)
24
+ - [Linked Component](#linked-component)
25
+ - [Transaction parameters](#transaction-parameters)
26
+ - [Asset specification](#asset-specification)
27
+ - [Transaction amount specification](#transaction-amount-specification)
28
+ - [Destination address](#destination-address)
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)
22
34
  - [Error handling](#error-handling)
23
- - [Customization](#customization)
24
- - [Functionality](#functionality)
25
- - [Pass the variables in the configuration](#pass-the-variables-in-the-configuration)
26
- - [Theme](#theme)
27
- - [Dictionary](#dictionary)
28
- - [Fields Properties](#fields-properties)
29
- - [Fallbacks](#fallbacks)
30
- - [Transaction Custom Asset Price](#transaction-custom-asset-price)
31
- - [License](#license)
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
+ - [License](#license)
32
40
 
33
41
  ## Installation
34
42
 
35
43
  There are two options for loading the Notabene SDK:
36
44
 
37
45
  ```bash
38
- <script id="notabene" async src="https://unpkg.com/@notabene/javascript-sdk@1.31.0/dist/es/index.js"></script>
46
+ <script id="notabene" async src="https://unpkg.com/@notabene/javascript-sdk@next/dist/notabene.js"></script>
39
47
  ```
40
48
 
41
49
  Or installing the library:
@@ -57,348 +65,398 @@ Use the [customer token endpoint](https://devx.notabene.id/docs/customertoken) w
57
65
  Create a new Notabene instance:
58
66
 
59
67
  ```js
68
+
60
69
  const notabene = new Notabene({
61
- vaspDID: 'did:ethr:0x94c38fd29ef36f5cb2f7bc771f9d5bd9f7d05f27',
62
- widget: 'https://beta-widget.notabene.id',
63
- container: '#container',
70
+ nodeUrl: 'https://api.notabene.id',
64
71
  authToken: '{CUSTOMER_TOKEN}',
65
- onValidStateChange: (isValid) => {
66
- // Use this value to determine if the transaction is ready to be created.
67
- console.log('is transaction valid', isValid);
68
- },
69
- onError: (err) => {
70
- // If any errors are encountered, they will be passed to this function
71
- alert(err.message);
72
- },
72
+ locale: 'de' // default locale
73
73
  });
74
74
  ```
75
75
 
76
- Then render the widget:
76
+ Use the same `nodeUrl` that you use to interact with the Notabene API.
77
77
 
78
- ```js
79
- // Use this method when you need to collect missing information from the sender about the recipient (normal withdrawal)
80
- notabene.renderWidget('WITHDRAWAL');
78
+ ## Assisted Withdrawal
79
+
80
+ The Withdrawal Assist component helps you collect additional required information from your user during a standard crypto withdrawal process.
81
+
82
+ ### Embedded Component
81
83
 
82
- // Use this method when you need to collect missing information from the recipient about the sender (for transactions created via notification)
83
- notabene.renderWidget('POST_DEPOSIT');
84
+ This will let you embed the component into your existing withdrawal flow.
85
+
86
+ Create an html element to contain the component:
87
+
88
+ ```html
89
+ <div id="nb-withdrawal/>
84
90
  ```
85
91
 
86
- To update the widget as users enter transaction details:
92
+ Instantiate the withdrawal element and mount it using the id from above
87
93
 
88
94
  ```js
89
- notabene.setTransaction({
90
- transactionAsset: 'ETH',
91
- beneficiaryAccountNumber: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
92
- transactionAmount: '2000000000',
93
- });
95
+ const withdrawal = notabene.createWithdrawalAssist(tx, options);
96
+ withdrawal.mount("nb-withdrawal");
94
97
  ```
95
98
 
96
- Once the widget determines the transaction is valid, it will call the `onValidStateChange` callback, to access the transaction details:
99
+ The simplest way to get the result is to use:
97
100
 
98
101
  ```js
99
- const currentTransactionInfo = notabene.tx;
102
+ try {
103
+ const {valid, ivms101} = await withdrawal.completion()
104
+ if (valid) {
105
+ // Submit result to your backend
106
+ }
107
+ } catch (e) {
108
+ console.error(e)
109
+ }
100
110
  ```
101
111
 
102
- ### Supported asset formats
103
-
104
- - `USDC` the simple asset code passed as a `string`, in case different chain (polygon) -> `USDC-POLY`
105
- - `CAIP19` format
106
- ```js
107
- {
108
- caip19: 'eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; // for USDC
109
- }
110
- ```
111
- - `coingeckoId` and `network` format
112
- ```js
113
- {
114
- coingeckoId: "usd-coin",
115
- network: "ethereum"
116
- }
117
- ```
112
+ #### Dynamic updates
118
113
 
119
- ---
114
+ To update the component as users enter transaction details:
120
115
 
121
- ### Re-rendering
116
+ ```js
117
+ withdrawal.update({
118
+ asset: 'ETH',
119
+ destination: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
120
+ amountDecimal: 1.12
121
+ });
122
+ ```
122
123
 
123
- **WARNING:** this shouldn't be used often, if you need to change the transaction's initial fields call `setTransaction` again. (This should be used only for tearing down the component).
124
+ To be notified once the validation is completed so you can submit the withdrawal to your back end:
124
125
 
125
- The container of the widget must be in the DOM before calling `destroyWidget` or `renderWidget`.
126
+ ```js
127
+ withdrawal.on('complete', {valid, txCreate } => ...)
128
+ ```
126
129
 
127
- If you need to close and re-render the widget, call the `destroyWidget` method like so:
130
+ To be notified of any errors use:
128
131
 
129
132
  ```js
130
- // Will remove the widget
131
- notabene.destroyWidget();
132
- // Will re-render the widget
133
- notabene.renderWidget();
133
+ withdrawal.on('error',error => ...)
134
134
  ```
135
135
 
136
- Calling the `renderWidget` methods without destroying it first will not work.
136
+ ### Linked Component
137
137
 
138
- ---
138
+ 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.
139
139
 
140
- ### Error handling
140
+ ```js
141
+ const withdrawal = notabene.createWithdrawalAssist(tx, options, {
142
+ callback: /// a serverside backend url
143
+ redirectUri: // URI of website or mobile app to redirect user to after completion
144
+ });
141
145
 
142
- 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`.
146
+ // NodeJS redirect. Link also works in an email.
147
+ res.redirect(withdrawal.url);
148
+ ```
143
149
 
144
- > ⚠️ **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.
150
+ Bear in mind that this is a full screen view for your users.
145
151
 
146
- ```js
147
- type ErrorData = {
148
- title: string;
149
- detail: string;
150
- code: number;
151
- type: string;
152
- };
152
+ The two parameters that should be configured are:
153
153
 
154
- const notabene = new Notabene({
155
- ...,
156
- onError: (err) => {
157
- const errorData = err.data;
154
+ - `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.
155
+ - `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.
158
156
 
159
- // Do something
160
- },
161
- });
162
- ```
157
+ **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.
163
158
 
164
- **Notabene Internal Errors**
159
+ ## Transaction parameters
165
160
 
166
- Type | Code | Title | Detail
167
- -- | -- | -- | --
168
- `BAD_REQUEST` | `400` | `Bad Request` | `NotabeneBadRequest: ...`
169
- `TRANSACTION_INVALID` | `400` | `Transaction Invalid` | `NotabeneTransactionInvalid: ...`
170
- `TOKEN_INVALID` | `401` | `Token Invalid` | `NotabeneTokenInvalid: ...`
171
- `ASSET_NOT_SUPPORTED` | `404` | `Asset Not Supported` | `NotabeneAssetNotSupported: ...`
172
- `SERVICE_UNAVAILABLE` | `500` | `Service Unavailable` | `NotabeneServiceUnavailable: ...`
173
- `WALLET_CONNECTED_FAILED` | `500` | `Wallet Connection Failed` | `NotabeneWalletConnectionFailed: ...`
174
- `WALLET_NOT_SUPPORTED` | `501` | `Wallet Not Supported` | `NotabeneWalletNotSupported: ...`
161
+ ### Asset specification
175
162
 
176
- ## Customization
163
+ The `asset` field the following types of assets specified:
177
164
 
178
- ### Functionality
165
+ - `notabene_asset` code passed as a`string`. See [Notabene Assets Service](https://devx.notabene.id/docs/coins-decimals#assets-service-api).
166
+ - [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.
167
+ - [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.
179
168
 
180
- `transactionTypeAllowed`: `ALL` | `VASP_2_VASP_ONLY` | `SELF_TRANSACTION_ONLY`
169
+ ### Transaction amount specification
181
170
 
182
- For limiting the type of transaction destinations you can pass.
171
+ Use one of the following
183
172
 
184
- `ALL`: All transaction destinations are allowed. (DEFAULT)
185
- `VASP_2_VASP_ONLY`: Only transaction destinations that are VASPs are allowed.
186
- `SELF_TRANSACTION_ONLY`: Only transaction destinations that the originator owns are allowed.
173
+ - `amountDecimal` A number specifying the amount in decimal format. Eg. `amountDecimal=1.1` would mean 1.1 of for example BTC or ETH.
187
174
 
188
- ---
175
+ ### Destination address
189
176
 
190
- `nonCustodialDeclarationType`: `SIGNATURE` | `DECLARATION`
177
+ Specify the beneficiary address as `destination` using one of the following formats:
191
178
 
192
- For deciding which ownership proof type you want to use.
179
+ - [CAIP-10](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md_) is a chain agnostic format allows you to specify the specific blockchain and address
180
+ - [EIP-3770](https://eips.ethereum.org/EIPS/eip-3770) EVM URI
181
+ - [BIP-21](https://en.bitcoin.it/wiki/BIP_0021) Bitcoin URI
182
+ - Native blockchain address
193
183
 
194
- `SIGNATURE`: The ownership proof will be signed by the originator using a wallet. (DEFAULT)
195
- `DECLARATION`: The ownership proof will be declared by the originator using a checkbox.
184
+ ### Destination address
196
185
 
197
- ### Pass the variables in the configuration
186
+ The price of the asset is used to determine certain rules based on thresholds. We recommond you pass in your price like this:
198
187
 
199
- ```js
200
- const notabene = new Notabene({
201
- vaspDID: 'did:ethr:0x94c38fd29ef36f5cb2f7bc771f9d5bd9f7d05f27',
202
- widget: 'https://beta-widget.notabene.id',
203
- container: '#container',
204
- authToken: '{CUSTOMER_TOKEN}'
205
- allowedTransactionTypes: 'VASP_2_VASP_ONLY',
206
- nonCustodialDeclarationType: 'DECLARATION',
207
- });
188
+ ```ts
189
+ assetPrice: {
190
+ currency: 'USD', // ISO currency code
191
+ price: 1700.12, // Asset price
192
+ };
208
193
  ```
209
194
 
210
- ---
195
+ ## Connect Wallet
211
196
 
212
- ### Theme
197
+ The Connect Wallet component helps you collect and verify the address of your users self-hosted wallet in one go.
213
198
 
214
- Pass a `theme` object when creating an instance
199
+ ### Asset specification
215
200
 
216
- Here you can pass configuration which will customize the styles of the widget to meet your brand needs, all values are optional.
201
+ The `asset` field the following types of assets specified:
217
202
 
218
- ```js
219
- {
220
- primaryColor: '#fff',
221
- secondaryColor: '#fff',
222
- primaryFontColor: '#fff',
223
- secondaryFontColor: '#fff',
224
- backgroundColor: '#fff',
225
- fontFamily: Arial,
226
- logo: {LOGO_URL},
227
- mode: 'dark', // default: 'light'
228
-
229
- // If you are using the Signature flow, here is the full list of custom theme that can be applied to the WalletConnect Modal.
230
- '--w3m-font-family',
231
- '--w3m-font-feature-settings',
232
- '--w3m-overlay-background-color',
233
- '--w3m-overlay-backdrop-filter',
234
- '--w3m-z-index',
235
- '--w3m-accent-color',
236
- '--w3m-accent-fill-color',
237
- '--w3m-background-color',
238
- '--w3m-background-image-url',
239
- '--w3m-logo-image-url',
240
- '--w3m-background-border-radius',
241
- '--w3m-container-border-radius',
242
- '--w3m-wallet-icon-border-radius',
243
- '--w3m-wallet-icon-large-border-radius',
244
- '--w3m-wallet-icon-small-border-radius',
245
- '--w3m-input-border-radius',
246
- '--w3m-notification-border-radius',
247
- '--w3m-button-border-radius',
248
- '--w3m-secondary-button-border-radius',
249
- '--w3m-icon-button-border-radius',
250
- '--w3m-button-hover-highlight-border-radius',
251
- }
252
- ```
203
+ - `notabene_asset` code passed as a`string`. See [Notabene Assets Service](https://devx.notabene.id/docs/coins-decimals#assets-service-api).
204
+ - [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.
205
+ - [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.
253
206
 
254
- To get a list of supported fonts, visit [https://fonts.google.com/](https://fonts.google.com/)
255
207
 
256
- 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).
208
+ ### Modal
257
209
 
258
- ---
210
+ Instantiate the modal and open it
259
211
 
260
- ### Dictionary
212
+ ```js
213
+ const connect = notabene.createConnectWallet({asset:'ETH'}, options);
214
+ const {valid, ivms101, proof } = await connect.openModal();
215
+ ```
261
216
 
262
- Pass a `dictionary` object mapping in text in the widget to your own language, for example:
217
+ ### Linked Component
263
218
 
264
- To replace `Loading...` with `Cargando...`
219
+ 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.
265
220
 
266
221
  ```js
267
- {
268
- 'Loading...': 'Cargando...',
269
- }
222
+ const connect = notabene.createConnectWallet({asset:'ETH'}, options, {
223
+ callback: /// a serverside backend url
224
+ redirectUri: // URI of website or mobile app to redirect user to after completion
225
+ });
226
+
227
+ // NodeJS redirect. Link also works in an email.
228
+ res.redirect(withdrawal.url);
270
229
  ```
271
230
 
272
- ###### The property name must be the same as the text in the widget, for it to be replaced
231
+ Bear in mind that this is a full screen view for your users.
232
+
233
+ The two parameters that should be configured are:
234
+
235
+ - `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.
236
+ - `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.
237
+
238
+ **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.
273
239
 
274
240
  ---
275
241
 
276
- ### Fields Properties
242
+ ## Error handling
243
+
244
+ If any error occurs, the `error` event is passed containing a message.
277
245
 
278
- Possible fields customization support:
246
+ ```ts
247
+ withdrawal.on('error', {message} => ...)
248
+ ```
279
249
 
280
- | field name | `forceDisplay` | `optional` | description |
281
- | ------------------------ | -------------- | ---------- | ------------------------------------------------------- |
282
- | `counterparty` | -- | ☑️ | Counterparty VASP or Wallet (destination or originator) |
283
- | `dateAndPlaceOfBirth` | ☑️ | -- | Recipient (or Sender) Date and Place of Birth |
284
- | `geographicAddress` | ☑️ | ☑️ | Recipient (or Sender) Address |
285
- | `firstName` | ☑️ | -- | Recipient (or Sender) First name |
286
- | `name` | ☑️ | -- | Recipient (or Sender) Last Name / Company Name |
287
- | `nationalIdentification` | ☑️ | --️ | Recipient (or Sender) National Identification |
288
- | `country` | ☑️ | ☑️ | Recipient (or Sender) Country of Residence (for natural person) / Country of Registration (for legal person) |
250
+ ## Transaction Options
289
251
 
290
- **Field Options**
252
+ All components can be configured using an optional [TransactionOptions](./docs/interfaces/TransactionOptions.md) object.
291
253
 
292
- - **forceDisplay** - Force a field that is not required by your jurisdiction to be displayed - defaults to **false**
293
- - **optional** - Bypass the jurisdiction rules validation for that specific field - defaults to **false**
254
+ The following shows the full set of options in typescript:
294
255
 
295
- ```js
296
- {
297
- counterparty: {
298
- optional: true;
256
+ ```ts
257
+ const options: TransactionOptions = {
258
+ proofs: {
259
+ microTransfer: {
260
+ destination: '0x...',
261
+ timeout: 86440,
262
+ },
263
+ fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration],
299
264
  },
300
- geographicAddress: {
301
- forceDisplay: true,
302
- optional: true;
265
+ allowedAgentTypes: [AgentType.PRIVATE, AgentType.VASP],
266
+ allowedCounterpartyTypes: [
267
+ PersonType.LEGAL,
268
+ PersonType.NATURAL,
269
+ PersonType.SELF,
270
+ ],
271
+ fields: {
272
+ naturalPerson: {
273
+ name: true, // Default true
274
+ website: { optional: true },
275
+ email: true,
276
+ phone: true,
277
+ geographicAddress: false,
278
+ nationalIdentification: false,
279
+ dateOfBirth: false,
280
+ placeOfBirth: false,
281
+ countryOfResidence: true,
282
+ },
283
+ legalPerson: {
284
+ name: true, // Default true
285
+ lei: true, // Default true
286
+ website: { optional: true }, // Default true
287
+ email: true,
288
+ phone: true,
289
+ geographicAddress: false,
290
+ nationalIdentification: false,
291
+ countryOfRegistration: true,
292
+ },
303
293
  },
304
- }
294
+ };
295
+ const withdrawal = notabene.createWithdrawalAssist(tx, options);
305
296
  ```
306
297
 
307
- ---
298
+ ### Common use cases
308
299
 
309
- **_Beneficiary Details_ [DEPRECATED]**
300
+ #### Only allow first party transactions
301
+
302
+ ```ts
303
+ const firstParty: TransactionOptions = {
304
+ allowedCounterpartyTypes: [
305
+ PersonType.SELF,
306
+ ],
307
+ };
308
+ ```
310
309
 
311
- You can require specific beneficiary fields that are not required by your jurisdiction.
310
+ #### Only VASP to VASP transactions
312
311
 
313
- Possible fields:
312
+ ```ts
313
+ const vasp2vasp: TransactionOptions = {
314
+ allowedAgentTypes: [AgentType.VASP],
315
+ };
316
+ ```
314
317
 
315
- - `beneficiaryName` - Recipient Name
316
- - `beneficiaryGeographicAddress` - Recipient Address
317
- - `beneficiaryNationalIdentification` - Recipient National Identification
318
- - `beneficiaryDateAndPlaceOfBirth` - Recipient Date and Place of Birth
318
+ #### Only Self-hosted wallet transactions
319
319
 
320
- ```js
321
- beneficiaryDetails: [
322
- 'benficiaryName',
323
- 'beneficiaryGeographicAddress',
324
- 'beneficiaryNationalIdentification',
325
- 'beneficiaryDateAndPlaceOfBirth',
326
- ];
320
+ ```ts
321
+ const options: TransactionOptions = {
322
+ allowedAgentTypes: [AgentType.PRIVATE],
323
+ };
327
324
  ```
328
325
 
329
- ---
326
+ ### Configuring ownership proofs
330
327
 
331
- ### Fallbacks
328
+ By default components support message signing proofs.
332
329
 
333
- Fallbacks are custom options provided when desired outcome is not achieved
334
330
 
335
- Possible options and actions:
331
+ #### Supporting Micro Transactions (aka Satoshi tests)
336
332
 
337
- - `WALLET_NOT_SUPPORTED` - Performs one of the following options when wallet is not supported
338
- - `DECLARATION` - Falls back to the self declaration flow
339
- - `REJECT` - Rejects the transaction and throws an error
340
- - The error that will be thrown here will have the following structure
341
- ```js
342
- {
343
- "type": "WALLET_NOT_SUPPORTED",
344
- "title": "Wallet Not Supported",
345
- "status": 501,
346
- "detail": "We don't support the wallet for the provided asset"
347
- }
348
- ```
333
+ You can support Micro Transfers (aka Satoshi tests) by adding a deposit address for the test.
349
334
 
350
- ```js
351
- fallbacks: [{flow: "WALLET_NOT_SUPPORTED", action: "DECLARATION"}]
335
+ Your compliance team will have to determine how to handle and verify these transactions in the rules engine or individually.
336
+
337
+ ```ts
338
+ const options: TransactionOptions = {
339
+ proofs: {
340
+ microTransfer: {
341
+ destination: '0x...',
342
+ timeout: 86440, // Optional timeout in seconds, which is displayed to the user
343
+ },
344
+ fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration],
345
+ }
346
+ }
352
347
  ```
353
- ---
354
348
 
355
- Finally you pass the configuration to a Notabene instance:
349
+ Notabene does not currently verify these tests automatically as you likely already have the infrastructure to do so.
356
350
 
357
- ```js
358
- const notabene = new Notabene({
359
- widget: 'https://beta-widget.notabene.id',
360
- container: '#container',
361
- authToken: '{CUSTOMER_TOKEN}'
362
- theme: {THEME},
363
- dictionary: {DICTIONARY},
364
- fallbacks: [{flow: "WALLET_NOT_SUPPORTED", action: "DECLARATION"}]
365
- });
351
+ You will receive a response back from the component containing a proof object. For MicroTransfers it will look like this:
352
+
353
+ ```ts
354
+ type MicroTransferProof {
355
+ type: ProofTypes.MicroTransfer;
356
+ status: ProofStatus.PENDING;
357
+ did: DID;
358
+ address: CAIP10; // CAIP10 account to be verified
359
+ txhash: string; // Transaction Hash to verify
360
+ chain: CAIP2; // CAIP2 identifier of blockchain
361
+ amountSubunits: string; // Amount in subunits eg (satoshi or wei) to be verified
362
+ }
366
363
  ```
367
- ---
368
364
 
369
- ### Opt-In Features
365
+ #### Fallback Proof Options
370
366
 
371
- ```js
372
- const notabene = new Notabene({
373
- widget: 'https://beta-widget.notabene.id',
374
- container: '#container',
375
- authToken: '{CUSTOMER_TOKEN}'
376
- theme: {THEME},
377
- dictionary: {DICTIONARY},
378
- optInFeatures: ['REUSE_ADDRESS_OWNERSHIP_PROOF']
379
- });
367
+ 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:
368
+
369
+ ```ts
370
+ const options: TransactionOptions = {
371
+ proofs: {
372
+ fallbacks: [ProofTypes.Screenshot, ProofTypes.SelfDeclaration],
373
+ }
374
+ }
380
375
  ```
376
+ The two options are:
381
377
 
382
- **Available Opt-In Features**
378
+ - `screenshot` Where a user is requested to upload a screenshot of their wallet
379
+ - `self-declaration` Where a user self declares that they control the wallet address
383
380
 
384
- - `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.
381
+ ### Counterparty Field Properties
385
382
 
386
- ### Transaction Custom Asset Price
383
+ 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.
387
384
 
388
- 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.
385
+ We recommend working closely with your compliance team for this. Bearing in mind that different jurisdictions have different rules.
389
386
 
390
- ```js
391
- notabene.setTransaction({
392
- transactionAsset: 'ASSET_UNSUPPORTED_FROM_NOTABENE',
393
- beneficiaryAccountNumber: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
394
- transactionAmount: '2000000000',
395
- customAssetPrice: {
396
- priceUSD: 1700.12, // Asset price in USD
397
- decimals: 10 // Decimals used for the given transactionAmount
398
- };
399
- });
387
+ Each field can be configured like this:
388
+
389
+ - `true` required field
390
+ - `false` don't show
391
+ - `{ optional: true }` show but don't require
392
+ - `{ transmit: true }` Include in beneficiary field of IVMS101 to be transmitted to counterparty
393
+
394
+ Eg:
395
+ ```ts
396
+ {
397
+ naturalPerson: {
398
+ website: { optional: true },
399
+ email: true,
400
+ phone: false,
401
+ }
402
+ }
400
403
  ```
404
+ The above will always ask the user for the following for natural persons:
405
+
406
+ - `name` since it is on by default (you can disable it explicitly by setting it to `false`)
407
+ - `website` is show but is optional
408
+ - `email` is required
409
+
410
+
411
+ #### Full Example
412
+
413
+ ```ts
414
+ const options: TransactionOptions = {
415
+ fields: {
416
+ naturalPerson: {
417
+ name: true, // Default true
418
+ website: { optional: true },
419
+ email: true,
420
+ phone: true,
421
+ geographicAddress: false,
422
+ nationalIdentification: false,
423
+ dateOfBirth: {
424
+ transmit: true
425
+ },
426
+ placeOfBirth: false,
427
+ countryOfResidence: true,
428
+ },
429
+ legalPerson: {
430
+ name: true, // Default true
431
+ lei: true, // Default true
432
+ website: { optional: true }, // Default true
433
+ email: true,
434
+ phone: true,
435
+ geographicAddress: false,
436
+ nationalIdentification: false,
437
+ countryOfRegistration: true,
438
+ },
439
+ },
440
+ };
441
+ ```
442
+
443
+ #### Field reference
444
+
445
+ | Field name | Natural | Legal | IVMS101 | Transmitted | description |
446
+ |--------------------------|---------|-------|---------|-------------|-----------------------------------------------|
447
+ | `name` | ✅ | ✅ | ✅ | ✅ | Full name |
448
+ | `email` | 🟩 | 🟩 | -- | -- | Email (for your internal purposes) |
449
+ | `website` | -- | ✅ | -- | -- | Business Website (for your internal purposes) |
450
+ | `phone` | 🟩 | 🟩 | -- | -- | Mobile Phone (for your internal purposes) |
451
+ | `geographicAddress` | 🟩 | 🟩 | ✅ | 🟩 | Residencial or business address |
452
+ | `nationalIdentification` | 🟩 | 🟩 | ✅ | 🟩 | National Identification number |
453
+ | `dateOfBirth` | 🟩 | -- | ✅ | 🟩 | Date of birth |
454
+ | `placeOfBirth` | 🟩 | -- | ✅ | 🟩 | Place of birth |
455
+ | `countryOfResidence` | 🟩 | -- | ✅ | 🟩 | Country of Residence |
456
+ | `lei` | -- | ✅ | ✅ | ✅ | LEI (Legal Entity Identifier) |
457
+ | `countryOfRegistration` | -- | 🟩 | ✅ | 🟩 | Country of Registration |
458
+
401
459
 
402
460
  ## [License](LICENSE.md)
403
461
 
404
- BSD 3-Clause © Notabene Inc.
462
+ MIT © Notabene Inc.