@notabene/javascript-sdk 1.32.0 → 2.0.0-next.2
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/.gitlab-ci.yml +12 -1
- package/.husky/commit-msg +0 -0
- package/.husky/pre-commit +0 -0
- package/.husky/pre-push +1 -1
- package/.vscode/extensions.json +1 -5
- package/.vscode/settings.json +4 -4
- package/.yarn/releases/yarn-berry.cjs +925 -0
- package/.yarnrc.yml +3 -0
- package/CODEOWNERS +1 -1
- package/README.md +128 -70
- package/api-extractor.json +434 -0
- package/dist/notabene.cjs +1 -0
- package/dist/notabene.d.ts +678 -0
- package/dist/notabene.js +187 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/eslint.config.js +24 -0
- package/etc/javascript-sdk.api.md +363 -0
- package/index.html +137 -0
- package/package.json +27 -53
- package/src/__tests__/notabene.test.ts +116 -0
- package/src/arbitraries.ts +13 -0
- package/src/components/EmbeddedComponent.ts +110 -0
- package/src/components/__tests__/EmbeddedComponent.test.ts +160 -0
- package/src/ivms/types.ts +2 -0
- package/src/notabene.ts +173 -279
- package/src/types.ts +381 -49
- package/src/utils/MessageEventManager.ts +55 -0
- package/src/utils/__tests__/MessageEventManager.test.ts +95 -0
- package/src/utils/arbitraries.ts +21 -0
- package/src/utils/caip.ts +16 -0
- package/src/utils/urls.ts +15 -0
- package/temp/javascript-sdk.api.json +3509 -0
- package/temp/javascript-sdk.api.md +363 -0
- package/ts-out/src/__tests__/notabene.test.d.ts +1 -0
- package/ts-out/src/__tests__/notabene.test.js +88 -0
- package/ts-out/src/arbitraries.d.ts +4 -0
- package/ts-out/src/arbitraries.js +8 -0
- package/ts-out/src/components/EmbeddedComponent.d.ts +25 -0
- package/ts-out/src/components/EmbeddedComponent.js +87 -0
- package/ts-out/src/components/__tests__/EmbeddedComponent.test.d.ts +1 -0
- package/ts-out/src/components/__tests__/EmbeddedComponent.test.js +132 -0
- package/ts-out/src/ivms/types.d.ts +252 -0
- package/ts-out/src/ivms/types.js +1 -0
- package/ts-out/src/notabene.d.ts +35 -0
- package/ts-out/src/notabene.js +59 -0
- package/ts-out/src/types.d.ts +357 -0
- package/ts-out/src/types.js +85 -0
- package/ts-out/src/utils/MessageEventManager.d.ts +12 -0
- package/ts-out/src/utils/MessageEventManager.js +45 -0
- package/ts-out/src/utils/__tests__/MessageEventManager.test.d.ts +1 -0
- package/ts-out/src/utils/__tests__/MessageEventManager.test.js +73 -0
- package/ts-out/src/utils/arbitraries.d.ts +6 -0
- package/ts-out/src/utils/arbitraries.js +7 -0
- package/ts-out/src/utils/caip.d.ts +13 -0
- package/ts-out/src/utils/caip.js +15 -0
- package/ts-out/src/utils/urls.d.ts +1 -0
- package/ts-out/src/utils/urls.js +14 -0
- package/ts-out/tsconfig.tsbuildinfo +1 -0
- package/tsconfig.json +15 -11
- package/tsconfig.tsbuildinfo +1 -0
- package/vite.config.js +13 -0
- package/.envrc.template +0 -1
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -13
- package/.nvmrc +0 -1
- package/.tool-versions +0 -3
- package/dist/es/index.js +0 -1
- package/dist/lib/index.js +0 -366
- 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/.yarnrc.yml
ADDED
package/CODEOWNERS
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
* @ajunge @brunosimplicio @
|
|
1
|
+
* @ajunge @brunosimplicio @dw1284 @richardcrosby @david1250 @marieh_mai @timothy4915912 @graham9961840
|
package/README.md
CHANGED
|
@@ -8,27 +8,37 @@
|
|
|
8
8
|
[](https://gitlab.com/notabene/open-source/javascript-sdk/-/commits/master)
|
|
9
9
|
[](https://gitlab.com/notabene/open-source/javascript-sdk/-/releases)
|
|
10
10
|
|
|
11
|
-
This library is the JavaScript SDK for loading the
|
|
11
|
+
This library is the JavaScript SDK for loading the Notabene UX components in the front-end.
|
|
12
12
|
|
|
13
13
|
[Documentation](https://devx.notabene.id/docs/widget-v2) •
|
|
14
14
|
[Installation](#installation)
|
|
15
15
|
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- [
|
|
18
|
+
- [JavaScript SDK](#javascript-sdk)
|
|
19
|
+
- [Installation](#installation)
|
|
20
|
+
- [Usage](#usage)
|
|
21
|
+
- [Authentication](#authentication)
|
|
22
|
+
- [Assisted Withdrawal](#assisted-withdrawal)
|
|
23
|
+
- [Embedded Component](#embedded-component)
|
|
24
|
+
- [Dynamic updates](#dynamic-updates)
|
|
25
|
+
- [Linked Component](#linked-component)
|
|
26
|
+
- [Transaction parameters](#transaction-parameters)
|
|
27
|
+
- [Asset specification](#asset-specification)
|
|
28
|
+
- [Transaction amount specification](#transaction-amount-specification)
|
|
29
|
+
- [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)
|
|
41
|
+
- [License](#license)
|
|
32
42
|
|
|
33
43
|
## Installation
|
|
34
44
|
|
|
@@ -57,83 +67,121 @@ Use the [customer token endpoint](https://devx.notabene.id/docs/customertoken) w
|
|
|
57
67
|
Create a new Notabene instance:
|
|
58
68
|
|
|
59
69
|
```js
|
|
70
|
+
|
|
60
71
|
const notabene = new Notabene({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
container: '#container',
|
|
64
|
-
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
|
+
nodeUrl: 'https://api.notabene.id',
|
|
73
|
+
authToken: '{CUSTOMER_TOKEN}'
|
|
73
74
|
});
|
|
74
75
|
```
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
Use the same `nodeUrl` that you use to interact with the Notabene API.
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
## Assisted Withdrawal
|
|
80
|
+
|
|
81
|
+
The Withdrawal Assist component helps you collect additional required information from your user during a standard crypto withdrawal process.
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
### Embedded Component
|
|
84
|
+
|
|
85
|
+
This will let you embed the component into your existing withdrawal flow.
|
|
86
|
+
|
|
87
|
+
Create an html element to contain the component:
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<div id="nb-withdrawal/>
|
|
84
91
|
```
|
|
85
92
|
|
|
86
|
-
|
|
93
|
+
Instantiate the withdrawal element and mount it using the id from above
|
|
87
94
|
|
|
88
95
|
```js
|
|
89
|
-
notabene.
|
|
90
|
-
|
|
91
|
-
beneficiaryAccountNumber: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
|
|
92
|
-
transactionAmount: '2000000000',
|
|
93
|
-
});
|
|
96
|
+
const withdrawal = notabene.createWithdrawalAssist(tx, options);
|
|
97
|
+
withdrawal.mount("nb-withdrawal");
|
|
94
98
|
```
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
The simplest way to get the result is to use:
|
|
97
101
|
|
|
98
102
|
```js
|
|
99
|
-
|
|
103
|
+
try {
|
|
104
|
+
const {valid, ivms101} = await withdrawal.completion()
|
|
105
|
+
if (valid) {
|
|
106
|
+
// Submit result to your backend
|
|
107
|
+
}
|
|
108
|
+
} catch (e) {
|
|
109
|
+
console.error(e)
|
|
110
|
+
}
|
|
100
111
|
```
|
|
101
112
|
|
|
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
|
-
```
|
|
113
|
+
#### Dynamic updates
|
|
118
114
|
|
|
119
|
-
|
|
115
|
+
To update the component as users enter transaction details:
|
|
120
116
|
|
|
121
|
-
|
|
117
|
+
```js
|
|
118
|
+
withdrawal.update({
|
|
119
|
+
asset: 'ETH',
|
|
120
|
+
destination: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
|
|
121
|
+
amountDecimal: 1.12
|
|
122
|
+
});
|
|
123
|
+
```
|
|
122
124
|
|
|
123
|
-
|
|
125
|
+
To be notified once the validation is completed so you can submit the withdrawal to your back end:
|
|
124
126
|
|
|
125
|
-
|
|
127
|
+
```js
|
|
128
|
+
withdrawal.on('valid', {ivms101} => ...)
|
|
129
|
+
```
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
To be notified of any errors use:
|
|
128
132
|
|
|
129
133
|
```js
|
|
130
|
-
|
|
131
|
-
notabene.destroyWidget();
|
|
132
|
-
// Will re-render the widget
|
|
133
|
-
notabene.renderWidget();
|
|
134
|
+
withdrawal.on('error',error => ...)
|
|
134
135
|
```
|
|
135
136
|
|
|
136
|
-
|
|
137
|
+
### Linked Component
|
|
138
|
+
|
|
139
|
+
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.
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
const withdrawal = notabene.createWithdrawalAssist(tx, options, {
|
|
143
|
+
callback: /// a serverside backend url
|
|
144
|
+
redirectUri: // URI of website or mobile app to redirect user to after completion
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// NodeJS redirect. Link also works in an email.
|
|
148
|
+
res.redirect(withdrawal.url);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Bear in mind that this is a full screen view for your users.
|
|
152
|
+
|
|
153
|
+
The two parameters that should be configured are:
|
|
154
|
+
|
|
155
|
+
- `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.
|
|
156
|
+
- `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.
|
|
157
|
+
|
|
158
|
+
**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.
|
|
159
|
+
|
|
160
|
+
## Transaction parameters
|
|
161
|
+
|
|
162
|
+
### Asset specification
|
|
163
|
+
|
|
164
|
+
The `asset` field the following types of assets specified:
|
|
165
|
+
|
|
166
|
+
- `notabene_asset` code passed as a`string`. See [Notabene Assets Service](https://devx.notabene.id/docs/coins-decimals#assets-service-api).
|
|
167
|
+
- [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.
|
|
168
|
+
- [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.
|
|
169
|
+
|
|
170
|
+
### Transaction amount specification
|
|
171
|
+
|
|
172
|
+
Use one of the following
|
|
173
|
+
|
|
174
|
+
- `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
|
+
|
|
177
|
+
### Destination address
|
|
178
|
+
|
|
179
|
+
Specify the beneficiary address as `destination` using one of the following formats:
|
|
180
|
+
|
|
181
|
+
- [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
|
|
182
|
+
- [EIP-3770](https://eips.ethereum.org/EIPS/eip-3770) EVM URI
|
|
183
|
+
- [BIP-21](https://en.bitcoin.it/wiki/BIP_0021) Bitcoin URI
|
|
184
|
+
- Native blockchain address
|
|
137
185
|
|
|
138
186
|
---
|
|
139
187
|
|
|
@@ -177,13 +225,13 @@ Type | Code | Title | Detail
|
|
|
177
225
|
|
|
178
226
|
### Functionality
|
|
179
227
|
|
|
180
|
-
`transactionTypeAllowed`: `ALL` | `VASP_2_VASP_ONLY` | `
|
|
228
|
+
`transactionTypeAllowed`: `ALL` | `VASP_2_VASP_ONLY` | `FIRST_PARTY_ONLY`
|
|
181
229
|
|
|
182
230
|
For limiting the type of transaction destinations you can pass.
|
|
183
231
|
|
|
184
232
|
`ALL`: All transaction destinations are allowed. (DEFAULT)
|
|
185
233
|
`VASP_2_VASP_ONLY`: Only transaction destinations that are VASPs are allowed.
|
|
186
|
-
`
|
|
234
|
+
`FIRST_PARTY_ONLY`: Only transaction destinations that the originator owns are allowed.
|
|
187
235
|
|
|
188
236
|
---
|
|
189
237
|
|
|
@@ -194,6 +242,12 @@ For deciding which ownership proof type you want to use.
|
|
|
194
242
|
`SIGNATURE`: The ownership proof will be signed by the originator using a wallet. (DEFAULT)
|
|
195
243
|
`DECLARATION`: The ownership proof will be declared by the originator using a checkbox.
|
|
196
244
|
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
`counterpartyManualEntry`: `TRUE` | `FALSE`
|
|
248
|
+
|
|
249
|
+
For deciding if you would like to allow your customer to provide a manual counterparty vasp name in the counterparty field.
|
|
250
|
+
|
|
197
251
|
### Pass the variables in the configuration
|
|
198
252
|
|
|
199
253
|
```js
|
|
@@ -282,7 +336,8 @@ Possible fields customization support:
|
|
|
282
336
|
| `counterparty` | -- | ☑️ | Counterparty VASP or Wallet (destination or originator) |
|
|
283
337
|
| `dateAndPlaceOfBirth` | ☑️ | -- | Recipient (or Sender) Date and Place of Birth |
|
|
284
338
|
| `geographicAddress` | ☑️ | ☑️ | Recipient (or Sender) Address |
|
|
285
|
-
| `
|
|
339
|
+
| `firstName` | ☑️ | -- | Recipient (or Sender) First name |
|
|
340
|
+
| `name` | ☑️ | -- | Recipient (or Sender) Last Name / Company Name |
|
|
286
341
|
| `nationalIdentification` | ☑️ | --️ | Recipient (or Sender) National Identification |
|
|
287
342
|
| `country` | ☑️ | ☑️ | Recipient (or Sender) Country of Residence (for natural person) / Country of Registration (for legal person) |
|
|
288
343
|
|
|
@@ -337,6 +392,7 @@ Possible options and actions:
|
|
|
337
392
|
- `DECLARATION` - Falls back to the self declaration flow
|
|
338
393
|
- `REJECT` - Rejects the transaction and throws an error
|
|
339
394
|
- The error that will be thrown here will have the following structure
|
|
395
|
+
|
|
340
396
|
```js
|
|
341
397
|
{
|
|
342
398
|
"type": "WALLET_NOT_SUPPORTED",
|
|
@@ -349,6 +405,7 @@ Possible options and actions:
|
|
|
349
405
|
```js
|
|
350
406
|
fallbacks: [{flow: "WALLET_NOT_SUPPORTED", action: "DECLARATION"}]
|
|
351
407
|
```
|
|
408
|
+
|
|
352
409
|
---
|
|
353
410
|
|
|
354
411
|
Finally you pass the configuration to a Notabene instance:
|
|
@@ -363,6 +420,7 @@ const notabene = new Notabene({
|
|
|
363
420
|
fallbacks: [{flow: "WALLET_NOT_SUPPORTED", action: "DECLARATION"}]
|
|
364
421
|
});
|
|
365
422
|
```
|
|
423
|
+
|
|
366
424
|
---
|
|
367
425
|
|
|
368
426
|
### Opt-In Features
|