@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 +319 -261
- package/dist/notabene.cjs +1 -0
- package/dist/notabene.d.ts +1136 -0
- package/dist/notabene.js +296 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/package.json +45 -62
- package/src/__tests__/notabene.test.ts +159 -0
- package/src/arbitraries.ts +13 -0
- package/src/components/EmbeddedComponent.ts +217 -0
- package/src/components/__tests__/EmbeddedComponent.test.ts +188 -0
- package/src/ivms/types.ts +232 -152
- package/src/notabene.ts +264 -284
- package/src/types.ts +609 -78
- package/src/utils/MessageEventManager.ts +54 -0
- package/src/utils/__tests__/MessageEventManager.test.ts +95 -0
- package/src/utils/arbitraries.ts +26 -0
- package/src/utils/caip.ts +16 -0
- package/src/utils/urls.ts +15 -0
- package/.editorconfig +0 -10
- package/.envrc.template +0 -1
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -13
- package/.gitlab-ci.yml +0 -74
- package/.husky/commit-msg +0 -4
- package/.husky/pre-commit +0 -4
- package/.husky/pre-push +0 -4
- package/.nvmrc +0 -1
- package/.prettierrc +0 -4
- package/.releaserc.json +0 -16
- package/.tool-versions +0 -3
- package/.vscode/extensions.json +0 -7
- package/.vscode/settings.json +0 -11
- package/CODEOWNERS +0 -1
- package/dist/es/index.js +0 -1
- package/dist/lib/index.js +0 -376
- package/jest.config.js +0 -5
- package/public/index.html +0 -93
- package/public/js/.gitkeep +0 -0
- package/src/lib/index.ts +0 -2
- package/src/module/index.ts +0 -10
- package/src/zoidComponentProps.ts +0 -81
- package/tsconfig.json +0 -18
package/README.md
CHANGED
|
@@ -5,37 +5,45 @@
|
|
|
5
5
|
|
|
6
6
|
# JavaScript SDK
|
|
7
7
|
|
|
8
|
-
[](https://gitlab.com/notabene/open-source/javascript-sdk/-/releases)
|
|
8
|
+
[](https://gitlab.com/notabene/open-source/javascript-sdk/-/commits/v2)
|
|
10
9
|
|
|
11
|
-
This library is the JavaScript SDK for loading the
|
|
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/
|
|
12
|
+
[Documentation](https://devx.notabene.id/docs/embedded=ux)
|
|
14
13
|
[Installation](#installation)
|
|
15
14
|
|
|
16
15
|
</div>
|
|
17
16
|
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
|
|
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
|
-
- [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- [
|
|
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@
|
|
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
|
-
|
|
62
|
-
widget: 'https://beta-widget.notabene.id',
|
|
63
|
-
container: '#container',
|
|
70
|
+
nodeUrl: 'https://api.notabene.id',
|
|
64
71
|
authToken: '{CUSTOMER_TOKEN}',
|
|
65
|
-
|
|
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
|
-
|
|
76
|
+
Use the same `nodeUrl` that you use to interact with the Notabene API.
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
83
|
-
|
|
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
|
-
|
|
92
|
+
Instantiate the withdrawal element and mount it using the id from above
|
|
87
93
|
|
|
88
94
|
```js
|
|
89
|
-
notabene.
|
|
90
|
-
|
|
91
|
-
beneficiaryAccountNumber: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
|
|
92
|
-
transactionAmount: '2000000000',
|
|
93
|
-
});
|
|
95
|
+
const withdrawal = notabene.createWithdrawalAssist(tx, options);
|
|
96
|
+
withdrawal.mount("nb-withdrawal");
|
|
94
97
|
```
|
|
95
98
|
|
|
96
|
-
|
|
99
|
+
The simplest way to get the result is to use:
|
|
97
100
|
|
|
98
101
|
```js
|
|
99
|
-
|
|
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
|
-
|
|
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
|
-
|
|
116
|
+
```js
|
|
117
|
+
withdrawal.update({
|
|
118
|
+
asset: 'ETH',
|
|
119
|
+
destination: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
|
|
120
|
+
amountDecimal: 1.12
|
|
121
|
+
});
|
|
122
|
+
```
|
|
122
123
|
|
|
123
|
-
|
|
124
|
+
To be notified once the validation is completed so you can submit the withdrawal to your back end:
|
|
124
125
|
|
|
125
|
-
|
|
126
|
+
```js
|
|
127
|
+
withdrawal.on('complete', {valid, txCreate } => ...)
|
|
128
|
+
```
|
|
126
129
|
|
|
127
|
-
|
|
130
|
+
To be notified of any errors use:
|
|
128
131
|
|
|
129
132
|
```js
|
|
130
|
-
|
|
131
|
-
notabene.destroyWidget();
|
|
132
|
-
// Will re-render the widget
|
|
133
|
-
notabene.renderWidget();
|
|
133
|
+
withdrawal.on('error',error => ...)
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
|
|
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
|
-
|
|
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
|
-
|
|
146
|
+
// NodeJS redirect. Link also works in an email.
|
|
147
|
+
res.redirect(withdrawal.url);
|
|
148
|
+
```
|
|
143
149
|
|
|
144
|
-
|
|
150
|
+
Bear in mind that this is a full screen view for your users.
|
|
145
151
|
|
|
146
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
+
## Transaction parameters
|
|
165
160
|
|
|
166
|
-
|
|
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
|
-
|
|
163
|
+
The `asset` field the following types of assets specified:
|
|
177
164
|
|
|
178
|
-
|
|
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
|
-
|
|
169
|
+
### Transaction amount specification
|
|
181
170
|
|
|
182
|
-
|
|
171
|
+
Use one of the following
|
|
183
172
|
|
|
184
|
-
`
|
|
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
|
-
|
|
177
|
+
Specify the beneficiary address as `destination` using one of the following formats:
|
|
191
178
|
|
|
192
|
-
|
|
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
|
-
|
|
195
|
-
`DECLARATION`: The ownership proof will be declared by the originator using a checkbox.
|
|
184
|
+
### Destination address
|
|
196
185
|
|
|
197
|
-
|
|
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
|
-
```
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
197
|
+
The Connect Wallet component helps you collect and verify the address of your users self-hosted wallet in one go.
|
|
213
198
|
|
|
214
|
-
|
|
199
|
+
### Asset specification
|
|
215
200
|
|
|
216
|
-
|
|
201
|
+
The `asset` field the following types of assets specified:
|
|
217
202
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
208
|
+
### Modal
|
|
257
209
|
|
|
258
|
-
|
|
210
|
+
Instantiate the modal and open it
|
|
259
211
|
|
|
260
|
-
|
|
212
|
+
```js
|
|
213
|
+
const connect = notabene.createConnectWallet({asset:'ETH'}, options);
|
|
214
|
+
const {valid, ivms101, proof } = await connect.openModal();
|
|
215
|
+
```
|
|
261
216
|
|
|
262
|
-
|
|
217
|
+
### Linked Component
|
|
263
218
|
|
|
264
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
242
|
+
## Error handling
|
|
243
|
+
|
|
244
|
+
If any error occurs, the `error` event is passed containing a message.
|
|
277
245
|
|
|
278
|
-
|
|
246
|
+
```ts
|
|
247
|
+
withdrawal.on('error', {message} => ...)
|
|
248
|
+
```
|
|
279
249
|
|
|
280
|
-
|
|
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
|
-
|
|
252
|
+
All components can be configured using an optional [TransactionOptions](./docs/interfaces/TransactionOptions.md) object.
|
|
291
253
|
|
|
292
|
-
|
|
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
|
-
```
|
|
296
|
-
{
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
-
|
|
300
|
+
#### Only allow first party transactions
|
|
301
|
+
|
|
302
|
+
```ts
|
|
303
|
+
const firstParty: TransactionOptions = {
|
|
304
|
+
allowedCounterpartyTypes: [
|
|
305
|
+
PersonType.SELF,
|
|
306
|
+
],
|
|
307
|
+
};
|
|
308
|
+
```
|
|
310
309
|
|
|
311
|
-
|
|
310
|
+
#### Only VASP to VASP transactions
|
|
312
311
|
|
|
313
|
-
|
|
312
|
+
```ts
|
|
313
|
+
const vasp2vasp: TransactionOptions = {
|
|
314
|
+
allowedAgentTypes: [AgentType.VASP],
|
|
315
|
+
};
|
|
316
|
+
```
|
|
314
317
|
|
|
315
|
-
|
|
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
|
-
```
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
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
|
-
|
|
331
|
+
#### Supporting Micro Transactions (aka Satoshi tests)
|
|
336
332
|
|
|
337
|
-
|
|
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
|
-
|
|
351
|
-
|
|
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
|
-
|
|
349
|
+
Notabene does not currently verify these tests automatically as you likely already have the infrastructure to do so.
|
|
356
350
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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
|
-
|
|
365
|
+
#### Fallback Proof Options
|
|
370
366
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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
|
-
|
|
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
|
-
|
|
381
|
+
### Counterparty Field Properties
|
|
385
382
|
|
|
386
|
-
|
|
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
|
-
|
|
385
|
+
We recommend working closely with your compliance team for this. Bearing in mind that different jurisdictions have different rules.
|
|
389
386
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
-
|
|
462
|
+
MIT © Notabene Inc.
|