Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@notabene/javascript-sdk
Advanced tools
This library is the JavaScript SDK for loading the widget on a frontend.
There are two options for loading the Notabene SDK:
<script id="notabene" async src="https://unpkg.com/@notabene/javascript-sdk@latest/dist/es/index.js"></script>
Or installing the library:
yarn add @notabene/javascript-sdk
Create a new Notabene instance:
const notabene = new Notabene({
vaspDID: 'did:ethr:0x94c38fd29ef36f5cb2f7bc771f9d5bd9f7d05f27',
widget: 'https://beta-widget.notabene.id',
container: '#container',
authToken: '{CUSTOMER_TOKEN}',
onValidStateChange: (isValid) => {
// Use this value to determine if the transaction is ready to be created.
console.log('is transaction valid', isValid);
},
onError: (err) => {
// If any errors are encountered, they will be passed to this function
alert(err.message);
},
});
Then render the widget:
// Use this method when you need to collect missing information from the sender about the recipient (normal withdrawal)
notabene.renderWithdrawalWidget();
// Use this method when you need to collect missing information from the recipient about the sender (for transactions created via notification)
notabene.renderPostDepositWidget();
// @deprecated Same as renderWithdrawalWidget
notabene.renderWidget();
To update the widget as users enter transaction details:
notabene.setTransaction({
transactionAsset: 'ETH',
beneficiaryAccountNumber: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
transactionAmount: '2000000000',
});
Once the widget determines the transaction is valid, it will call the onValidStateChange
callback, to access the transaction details:
const currentTransactionInfo = notabene.tx;
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).
The container of the widget must be in the DOM before calling destroyWidget
or renderPostDepositWidget | renderWithdrawalWidget | renderWidget (@deprecated)
.
If you need to close and re-render the widget, call the destroyWidget
method like so:
// Will remove the widget
notabene.destroyWidget();
// Will re-render the widget
// Same applies to notabene.renderPostDepositWidget() or notabene.renderWidget() - renderWidget is deprecated
notabene.renderWithdrawalWidget();
Calling the renderWithdrawalWidget | renderPostDepositWidget | renderWidget (@deprecated)
methods without destroying it first will not work.
Functionality
transactionTypeAllowed
: ALL
| VASP_2_VASP_ONLY
| SELF_TRANSACTION_ONLY
For limiting the type of transaction destinations you can pass.
ALL
: All transaction destinations are allowed. (DEFAULT)
VASP_2_VASP_ONLY
: Only transaction destinations that are VASPs are allowed.
SELF_TRANSACTION_ONLY
: Only transaction destinations that the originator owns are allowed.
nonCustodialDeclarationType
: SIGNATURE
| DECLARATION
For deciding which ownership proof type you want to use.
SIGNATURE
: The ownership proof will be signed by the originator using a wallet. (DEFAULT)
DECLARATION
: The ownership proof will be declared by the originator using a checkbox.
Pass the variables in the configuration
const notabene = new Notabene({
vaspDID: 'did:ethr:0x94c38fd29ef36f5cb2f7bc771f9d5bd9f7d05f27',
widget: 'https://beta-widget.notabene.id',
container: '#container',
authToken: '{CUSTOMER_TOKEN}'
allowedTransactionTypes: 'VASP_2_VASP_ONLY',
nonCustodialDeclarationType: 'DECLARATION',
});
Theme
Pass a theme
object when creating an instance
Here you can pass configuration which will customize the styles of the widget to meet your brand needs, all values are optional.
{
primaryColor: '#fff',
secondaryColor: '#fff',
primaryFontColor: '#fff',
secondaryFontColor: '#fff',
backgroundColor: '#fff',
fontFamily: Arial,
logo: {LOGO_URL},
mode: 'dark', // default: 'light'
}
To get a list of supported fonts, visit https://fonts.google.com/
Dictionary
Pass a dictionary
object mapping in text in the widget to your own language, for example:
To replace Loading...
with Cargando...
{
'Loading...': 'Cargando...',
}
Beneficiary Details
You can require specific beneficiary fields that are not required by your jurisdiction.
Field options:
beneficiaryName
- Recipient NamebeneficiaryGeographicAddress
- Recipient AddressbeneficiaryNationalIdentification
- Recipient National IdentificationbeneficiaryDateAndPlaceOfBirth
- Recipient Date and Place of BirthbeneficiaryDetails: [
'benficiaryName',
'beneficiaryGeographicAddress',
'beneficiaryNationalIdentification',
'beneficiaryDateAndPlaceOfBirth',
];
Finally you pass the configuration to a Notabene instance:
const notabene = new Notabene({
widget: 'https://beta-widget.notabene.id',
container: '#container',
authToken: '{CUSTOMER_TOKEN}'
theme: {THEME},
dictionary: {DICTIONARY},
beneficiaryDetails: {BENEFICIARY_DETAILS},
});
BSD 3-Clause © Notabene Inc.
FAQs
JavaScript SDK for Notabene
The npm package @notabene/javascript-sdk receives a total of 1,677 weekly downloads. As such, @notabene/javascript-sdk popularity was classified as popular.
We found that @notabene/javascript-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.