@notabene/javascript-sdk 2.17.0 → 2.18.0-next.3
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 +102 -0
- package/dist/cjs/notabene.cjs +5 -5
- package/dist/cjs/notabene.d.ts +51 -1
- package/dist/cjs/package.json +1 -1
- package/dist/esm/notabene.d.ts +51 -1
- package/dist/esm/notabene.js +480 -479
- package/dist/esm/package.json +1 -1
- package/dist/notabene.d.ts +51 -1
- package/dist/notabene.js +480 -479
- package/docs/README.md +34 -1
- package/package.json +2 -2
- package/src/notabene.ts +6 -0
- package/src/types.ts +54 -1
- package/src/utils/arbitraries.ts +30 -0
package/docs/README.md
CHANGED
|
@@ -73,6 +73,7 @@ This library is the JavaScript SDK for loading the Notabene UX components in the
|
|
|
73
73
|
- [Full Example](#full-example)
|
|
74
74
|
- [Field reference](#field-reference)
|
|
75
75
|
- [Configure Counterparty Assist](#counterparty-assist-configuration)
|
|
76
|
+
- [Consent / Terms & Conditions](#consent--terms--conditions)
|
|
76
77
|
- [Locales](#locales)
|
|
77
78
|
- [Theming](#theming)
|
|
78
79
|
- [License](#license)
|
|
@@ -767,7 +768,8 @@ const options: TransactionOptions = {
|
|
|
767
768
|
PersonType.NATURAL, // JS: 'natural'
|
|
768
769
|
PersonType.SELF, // JS: 'self'
|
|
769
770
|
],
|
|
770
|
-
}
|
|
771
|
+
},
|
|
772
|
+
consent: true, // true (default) | false (hide) | { label?: string, description?: string }
|
|
771
773
|
};
|
|
772
774
|
const withdrawal = notabene.createWithdrawalAssist(tx, options);
|
|
773
775
|
```
|
|
@@ -987,6 +989,37 @@ const options: TransactionOptions = {
|
|
|
987
989
|
| `lei` | -- | ✅ | 🟩 | LEI (Legal Entity Identifier) |
|
|
988
990
|
| `countryOfRegistration` | -- | 🟩 | 🟩 | Country of Registration |
|
|
989
991
|
|
|
992
|
+
### Consent / Terms & Conditions
|
|
993
|
+
|
|
994
|
+
By default, a consent checkbox is shown when the counterparty agent is a VASP. It asks the user to accept sharing personal information with the receiving/sending exchange. You can configure this behavior using the `consent` option.
|
|
995
|
+
|
|
996
|
+
- `undefined` or `true`: Show the default consent checkbox (default behavior)
|
|
997
|
+
- `false`: Hide the consent checkbox entirely
|
|
998
|
+
- `{ label?, description? }`: Show the checkbox with custom text
|
|
999
|
+
|
|
1000
|
+
#### Hiding the consent checkbox
|
|
1001
|
+
|
|
1002
|
+
```ts
|
|
1003
|
+
const options: TransactionOptions = {
|
|
1004
|
+
consent: false,
|
|
1005
|
+
};
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
When hidden, the consent requirement is skipped in validation — the component will complete without requiring the user to check the box.
|
|
1009
|
+
|
|
1010
|
+
#### Custom consent text
|
|
1011
|
+
|
|
1012
|
+
```ts
|
|
1013
|
+
const options: TransactionOptions = {
|
|
1014
|
+
consent: {
|
|
1015
|
+
label: 'I agree to the terms',
|
|
1016
|
+
description: 'By proceeding you agree to share your name and address with the counterparty.',
|
|
1017
|
+
},
|
|
1018
|
+
};
|
|
1019
|
+
```
|
|
1020
|
+
|
|
1021
|
+
Both `label` and `description` are optional — you can override one while keeping the default for the other. Translations are the customer's responsibility when providing custom text.
|
|
1022
|
+
|
|
990
1023
|
## Locales
|
|
991
1024
|
|
|
992
1025
|
See [locales](_media/locales.ts) for the list of supported locales.
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "Notabene <developers@notabene.id>",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"packageManager": "yarn@4.5.1",
|
|
13
|
-
"version": "2.
|
|
13
|
+
"version": "2.18.0-next.3",
|
|
14
14
|
"source": "src/notabene.ts",
|
|
15
15
|
"main": "dist/cjs/notabene.cjs",
|
|
16
16
|
"module": "dist/esm/notabene.js",
|
|
@@ -107,4 +107,4 @@
|
|
|
107
107
|
"@commitlint/config-conventional"
|
|
108
108
|
]
|
|
109
109
|
}
|
|
110
|
-
}
|
|
110
|
+
}
|
package/src/notabene.ts
CHANGED
|
@@ -14,6 +14,8 @@ import type {
|
|
|
14
14
|
ComponentResponse,
|
|
15
15
|
ConnectionOptions,
|
|
16
16
|
ConnectionRequest,
|
|
17
|
+
ConsentConfig,
|
|
18
|
+
ContactSupportConfig,
|
|
17
19
|
CosmosMetadata,
|
|
18
20
|
Counterparty,
|
|
19
21
|
CounterpartyAssistConfig,
|
|
@@ -74,6 +76,7 @@ import {
|
|
|
74
76
|
ErrorIdentifierCode,
|
|
75
77
|
HMType,
|
|
76
78
|
IdentityVerificationMethod,
|
|
79
|
+
InfoIdentifierCode,
|
|
77
80
|
PersonType,
|
|
78
81
|
ProofStatus,
|
|
79
82
|
ProofTypes,
|
|
@@ -117,6 +120,7 @@ export {
|
|
|
117
120
|
ErrorIdentifierCode,
|
|
118
121
|
HMType,
|
|
119
122
|
IdentityVerificationMethod,
|
|
123
|
+
InfoIdentifierCode,
|
|
120
124
|
PersonType,
|
|
121
125
|
ProofStatus,
|
|
122
126
|
ProofTypes,
|
|
@@ -140,6 +144,8 @@ export type {
|
|
|
140
144
|
ComponentResponse,
|
|
141
145
|
ConnectionOptions,
|
|
142
146
|
ConnectionRequest,
|
|
147
|
+
ConsentConfig,
|
|
148
|
+
ContactSupportConfig,
|
|
143
149
|
CosmosMetadata,
|
|
144
150
|
Counterparty,
|
|
145
151
|
CounterpartyAssistConfig,
|
package/src/types.ts
CHANGED
|
@@ -922,6 +922,7 @@ export interface ThresholdOptions {
|
|
|
922
922
|
* - `'signature'` — wallet connection for ownership proof via signature
|
|
923
923
|
* - `'manual-signing'` — ownership proof via manual message signing
|
|
924
924
|
* - `'add-vasp'` — manually add an unlisted exchange/VASP (hosted flow)
|
|
925
|
+
* - `'contact-support'` — show a contact support button
|
|
925
926
|
*
|
|
926
927
|
* Options are automatically filtered by flow (e.g. `add-vasp` is ignored in self-hosted).
|
|
927
928
|
* Including an option implicitly enables that capability.
|
|
@@ -934,7 +935,28 @@ export type SectionOption =
|
|
|
934
935
|
| 'microtransfer' // ProofTypes.MicroTransfer
|
|
935
936
|
| 'signature'
|
|
936
937
|
| 'manual-signing'
|
|
937
|
-
| 'add-vasp'
|
|
938
|
+
| 'add-vasp'
|
|
939
|
+
| 'contact-support';
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Configuration for the contact support action.
|
|
943
|
+
*
|
|
944
|
+
* @remarks
|
|
945
|
+
* Contact support is **enabled** by including `'contact-support'` in
|
|
946
|
+
* `agentSections.main` or `agentSections.fallback`. This object only
|
|
947
|
+
* configures the behaviour when the feature is enabled.
|
|
948
|
+
*
|
|
949
|
+
* - With `contactSupport: { supportUrl: "..." }` — clicking sends an info
|
|
950
|
+
* message to the host **and** attempts to open the URL as a fallback.
|
|
951
|
+
* - Without `contactSupport` — clicking only sends an info message; the
|
|
952
|
+
* host decides what to do.
|
|
953
|
+
*
|
|
954
|
+
* @public
|
|
955
|
+
*/
|
|
956
|
+
export interface ContactSupportConfig {
|
|
957
|
+
/** URL to open when the user clicks the support button */
|
|
958
|
+
supportUrl: string;
|
|
959
|
+
}
|
|
938
960
|
|
|
939
961
|
/**
|
|
940
962
|
* Explicit layout configuration for the agent selection step.
|
|
@@ -956,6 +978,25 @@ export interface AgentSections {
|
|
|
956
978
|
fallback?: SectionOption[];
|
|
957
979
|
}
|
|
958
980
|
|
|
981
|
+
/**
|
|
982
|
+
* Configuration for the terms and conditions consent checkbox.
|
|
983
|
+
*
|
|
984
|
+
* @remarks
|
|
985
|
+
* - `undefined` or `true`: show default T&C (current behavior)
|
|
986
|
+
* - `false`: hide T&C entirely
|
|
987
|
+
* - `{ label?, description? }`: show with custom text (translations are the customer's responsibility)
|
|
988
|
+
*
|
|
989
|
+
* @public
|
|
990
|
+
*/
|
|
991
|
+
export type ConsentConfig =
|
|
992
|
+
| boolean
|
|
993
|
+
| {
|
|
994
|
+
/** Custom label text. Replaces the default "Accept terms and conditions". */
|
|
995
|
+
label?: string;
|
|
996
|
+
/** Custom description text. Replaces the default sharing-info description. */
|
|
997
|
+
description?: string;
|
|
998
|
+
};
|
|
999
|
+
|
|
959
1000
|
/**
|
|
960
1001
|
* Configuration options for Transaction components
|
|
961
1002
|
* @public
|
|
@@ -983,6 +1024,8 @@ export interface TransactionOptions {
|
|
|
983
1024
|
vasps?: VASPOptions;
|
|
984
1025
|
hide?: ValidationSections[]; // You can hide a specific section of the component by listing it here
|
|
985
1026
|
counterpartyAssist?: CounterpartyAssistConfig;
|
|
1027
|
+
contactSupport?: ContactSupportConfig; // Requires 'contact-support' in agentSections
|
|
1028
|
+
consent?: ConsentConfig; // Defaults to true
|
|
986
1029
|
autoSubmit?: boolean; // Defaults to false
|
|
987
1030
|
}
|
|
988
1031
|
/**
|
|
@@ -1111,16 +1154,26 @@ export type Warning = {
|
|
|
1111
1154
|
identifier?: WarningIdentifierCode;
|
|
1112
1155
|
};
|
|
1113
1156
|
|
|
1157
|
+
/**
|
|
1158
|
+
* Identifier codes for info messages
|
|
1159
|
+
* @public
|
|
1160
|
+
*/
|
|
1161
|
+
export enum InfoIdentifierCode {
|
|
1162
|
+
CONTACT_SUPPORT = 'CONTACT_SUPPORT',
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1114
1165
|
/**
|
|
1115
1166
|
* Represents an info component message
|
|
1116
1167
|
* @param message - Info message
|
|
1117
1168
|
* @param description - Description of the info message
|
|
1169
|
+
* @param identifier - Identifier code of the info message
|
|
1118
1170
|
* @public
|
|
1119
1171
|
*/
|
|
1120
1172
|
export type Info = {
|
|
1121
1173
|
type: CMType.INFO;
|
|
1122
1174
|
message: string;
|
|
1123
1175
|
description?: string;
|
|
1176
|
+
identifier?: InfoIdentifierCode;
|
|
1124
1177
|
};
|
|
1125
1178
|
|
|
1126
1179
|
/**
|
package/src/utils/arbitraries.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fc from 'fast-check';
|
|
2
2
|
import type {
|
|
3
3
|
Agent,
|
|
4
|
+
AgentSections,
|
|
4
5
|
BlockchainAddress,
|
|
5
6
|
CAIP10,
|
|
6
7
|
CAIP19,
|
|
@@ -9,6 +10,7 @@ import type {
|
|
|
9
10
|
CallbackOptions,
|
|
10
11
|
ConnectionOptions,
|
|
11
12
|
ConnectionRequest,
|
|
13
|
+
ContactSupportConfig,
|
|
12
14
|
Counterparty,
|
|
13
15
|
CryptoCredential,
|
|
14
16
|
Deposit,
|
|
@@ -19,6 +21,7 @@ import type {
|
|
|
19
21
|
ISOCurrency,
|
|
20
22
|
ISODate,
|
|
21
23
|
NaturalPerson,
|
|
24
|
+
SectionOption,
|
|
22
25
|
ThresholdOptions,
|
|
23
26
|
TransactionAsset,
|
|
24
27
|
TransactionOptions,
|
|
@@ -236,9 +239,35 @@ export const arbitraryVASPOptions = (): fc.Arbitrary<VASPOptions> =>
|
|
|
236
239
|
}),
|
|
237
240
|
);
|
|
238
241
|
|
|
242
|
+
const SECTION_OPTIONS: SectionOption[] = [
|
|
243
|
+
'self-declaration',
|
|
244
|
+
'screenshot',
|
|
245
|
+
'microtransfer',
|
|
246
|
+
'signature',
|
|
247
|
+
'manual-signing',
|
|
248
|
+
'add-vasp',
|
|
249
|
+
'contact-support',
|
|
250
|
+
];
|
|
251
|
+
|
|
252
|
+
export const arbitrarySectionOption = (): fc.Arbitrary<SectionOption> =>
|
|
253
|
+
fc.constantFrom(...SECTION_OPTIONS);
|
|
254
|
+
|
|
255
|
+
export const arbitraryAgentSections = (): fc.Arbitrary<AgentSections> =>
|
|
256
|
+
fc.record({
|
|
257
|
+
main: fc.option(fc.array(arbitrarySectionOption())),
|
|
258
|
+
fallback: fc.option(fc.array(arbitrarySectionOption())),
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
export const arbitraryContactSupportConfig =
|
|
262
|
+
(): fc.Arbitrary<ContactSupportConfig> =>
|
|
263
|
+
fc.record({
|
|
264
|
+
supportUrl: fc.webUrl(),
|
|
265
|
+
});
|
|
266
|
+
|
|
239
267
|
export const arbitraryTransactionOptions =
|
|
240
268
|
(): fc.Arbitrary<TransactionOptions> =>
|
|
241
269
|
fc.record({
|
|
270
|
+
agentSections: fc.option(arbitraryAgentSections()),
|
|
242
271
|
proofs: fc.option(
|
|
243
272
|
fc.record({
|
|
244
273
|
microTransfer: fc.option(
|
|
@@ -265,6 +294,7 @@ export const arbitraryTransactionOptions =
|
|
|
265
294
|
hide: fc.option(
|
|
266
295
|
fc.array(fc.constantFrom(...Object.values(ValidationSections))),
|
|
267
296
|
),
|
|
297
|
+
contactSupport: fc.option(arbitraryContactSupportConfig()),
|
|
268
298
|
});
|
|
269
299
|
|
|
270
300
|
export const arbitraryDepositRequestOptions =
|