@notabene/javascript-sdk 1.14.2 → 1.15.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/.envrc.template +1 -0
- package/.tool-versions +3 -0
- package/README.md +14 -1
- package/dist/es/index.js +1 -1
- package/dist/lib/index.js +93 -142
- package/package.json +2 -1
- package/public/index.html +6 -5
- package/src/ivms/types.ts +302 -0
- package/src/lib/index.ts +1 -0
- package/src/module/index.ts +1 -0
- package/src/notabene.ts +11 -183
- package/src/types.ts +72 -0
- package/src/zoidComponentProps.ts +69 -0
- package/tsconfig.json +1 -0
package/src/notabene.ts
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
2
|
import { dom, node } from 'jsx-pragmatic';
|
|
3
|
+
import {
|
|
4
|
+
NonCustodialDeclarationType,
|
|
5
|
+
Theme,
|
|
6
|
+
Transaction,
|
|
7
|
+
TransactionTypeAllowed,
|
|
8
|
+
} from './types';
|
|
3
9
|
// @ts-ignore
|
|
4
10
|
import zoid, { destroy } from 'zoid';
|
|
5
|
-
|
|
6
|
-
export interface Theme {
|
|
7
|
-
primaryColor: string;
|
|
8
|
-
secondaryColor: string;
|
|
9
|
-
fontFamily: string;
|
|
10
|
-
logo: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export enum TransactionTypeAllowed {
|
|
14
|
-
ALL = 'ALL',
|
|
15
|
-
VASP_2_VASP_ONLY = 'VASP_2_VASP_ONLY',
|
|
16
|
-
SELF_TRANSACTION_ONLY = 'SELF_TRANSACTION_ONLY',
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export enum NonCustodialDeclarationType {
|
|
20
|
-
SIGNATURE = 'SIGNATURE',
|
|
21
|
-
DECLARATION = 'DECLARATION',
|
|
22
|
-
SIGNATURE_OR_DECLARATION = 'SIGNATURE_OR_DECLARATION',
|
|
23
|
-
}
|
|
11
|
+
import { popupProps, widgetProps } from './zoidComponentProps';
|
|
24
12
|
|
|
25
13
|
interface NotabeneConfig {
|
|
26
14
|
widget: string;
|
|
@@ -36,34 +24,6 @@ interface NotabeneConfig {
|
|
|
36
24
|
beneficiaryDetails?: string[];
|
|
37
25
|
}
|
|
38
26
|
|
|
39
|
-
export interface OwnershipProofInput {
|
|
40
|
-
type?: string | null;
|
|
41
|
-
proof?: string | null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface TransactionBlockchainInfo {
|
|
45
|
-
destination?: string | null;
|
|
46
|
-
}
|
|
47
|
-
interface Transaction {
|
|
48
|
-
transactionAsset: string;
|
|
49
|
-
transactionAmount: string;
|
|
50
|
-
beneficiaryAccountNumber: string;
|
|
51
|
-
originatorVASPdid?: string;
|
|
52
|
-
originatorDid?: string;
|
|
53
|
-
transactionBlockchainInfo?: TransactionBlockchainInfo;
|
|
54
|
-
beneficiaryVASPname?: string;
|
|
55
|
-
beneficiaryName?: string;
|
|
56
|
-
beneficiaryGeographicAddress?: string;
|
|
57
|
-
beneficiaryNationalIdentification?: string;
|
|
58
|
-
beneficiaryDateAndPlaceOfBirth?: string;
|
|
59
|
-
beneficiaryDid?: string;
|
|
60
|
-
isNonCustodial?: boolean;
|
|
61
|
-
originatorEqualsBeneficiary?: boolean;
|
|
62
|
-
beneficiaryProof?: OwnershipProofInput;
|
|
63
|
-
isValid?: boolean;
|
|
64
|
-
errors?: string[];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
27
|
export default class Notabene {
|
|
68
28
|
private widget: zoid.ZoidComponent;
|
|
69
29
|
private popup: zoid.ZoidComponent;
|
|
@@ -77,10 +37,8 @@ export default class Notabene {
|
|
|
77
37
|
constructor(config: NotabeneConfig) {
|
|
78
38
|
this.config = config;
|
|
79
39
|
this.config.nonCustodialDeclarationType =
|
|
80
|
-
config.nonCustodialDeclarationType ||
|
|
81
|
-
|
|
82
|
-
this.config.transactionTypeAllowed =
|
|
83
|
-
config.transactionTypeAllowed || TransactionTypeAllowed.ALL;
|
|
40
|
+
config.nonCustodialDeclarationType || 'SIGNATURE';
|
|
41
|
+
this.config.transactionTypeAllowed = config.transactionTypeAllowed || 'ALL';
|
|
84
42
|
this.widgetRendered = false;
|
|
85
43
|
this.shouldBeDestroyed = false;
|
|
86
44
|
this.popupRendered = false;
|
|
@@ -131,34 +89,6 @@ export default class Notabene {
|
|
|
131
89
|
}
|
|
132
90
|
|
|
133
91
|
public setTransaction(tx: Transaction) {
|
|
134
|
-
const validProperties = [
|
|
135
|
-
'transactionAsset',
|
|
136
|
-
'transactionAmount',
|
|
137
|
-
'beneficiaryAccountNumber',
|
|
138
|
-
'beneficiaryAccountNumber',
|
|
139
|
-
'originatorVASPdid',
|
|
140
|
-
'originatorDid',
|
|
141
|
-
'transactionBlockchainInfo',
|
|
142
|
-
'beneficiaryVASPname',
|
|
143
|
-
'beneficiaryVASPdid',
|
|
144
|
-
'beneficiaryName',
|
|
145
|
-
'beneficiaryGeographicAddress',
|
|
146
|
-
'beneficiaryNationalIdentification',
|
|
147
|
-
'beneficiaryDateAndPlaceOfBirth',
|
|
148
|
-
'beneficiaryDid',
|
|
149
|
-
'isNonCustodial',
|
|
150
|
-
'originatorEqualsBeneficiary',
|
|
151
|
-
'beneficiaryProof',
|
|
152
|
-
'isValid',
|
|
153
|
-
'errors',
|
|
154
|
-
];
|
|
155
|
-
if (tx) {
|
|
156
|
-
Object.keys(tx).forEach((key) => {
|
|
157
|
-
if (!validProperties.includes(key)) {
|
|
158
|
-
throw new Error(`Notabene: Invalid transaction property ${key}`);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
92
|
this.tx = tx;
|
|
163
93
|
if (this.widgetRendered) {
|
|
164
94
|
this.widget.updateProps({
|
|
@@ -215,56 +145,7 @@ export default class Notabene {
|
|
|
215
145
|
width: '100%',
|
|
216
146
|
height: '280px',
|
|
217
147
|
},
|
|
218
|
-
props:
|
|
219
|
-
vaspDID: {
|
|
220
|
-
type: 'string',
|
|
221
|
-
required: true,
|
|
222
|
-
},
|
|
223
|
-
transaction: {
|
|
224
|
-
type: 'object',
|
|
225
|
-
required: false,
|
|
226
|
-
},
|
|
227
|
-
onRequireAdditionalInformation: {
|
|
228
|
-
type: 'function',
|
|
229
|
-
required: true,
|
|
230
|
-
},
|
|
231
|
-
onValidStateChange: {
|
|
232
|
-
type: 'function',
|
|
233
|
-
required: true,
|
|
234
|
-
},
|
|
235
|
-
error: {
|
|
236
|
-
type: 'object',
|
|
237
|
-
required: false,
|
|
238
|
-
},
|
|
239
|
-
onError: {
|
|
240
|
-
type: 'function',
|
|
241
|
-
required: true,
|
|
242
|
-
},
|
|
243
|
-
storeTransaction: {
|
|
244
|
-
type: 'function',
|
|
245
|
-
required: true,
|
|
246
|
-
},
|
|
247
|
-
theme: {
|
|
248
|
-
type: 'object',
|
|
249
|
-
required: false,
|
|
250
|
-
},
|
|
251
|
-
dictionary: {
|
|
252
|
-
type: 'object',
|
|
253
|
-
required: false,
|
|
254
|
-
},
|
|
255
|
-
transactionTypeAllowed: {
|
|
256
|
-
type: 'string',
|
|
257
|
-
required: false,
|
|
258
|
-
},
|
|
259
|
-
nonCustodialDeclarationType: {
|
|
260
|
-
type: 'string',
|
|
261
|
-
required: false,
|
|
262
|
-
},
|
|
263
|
-
beneficiaryDetails: {
|
|
264
|
-
type: 'array',
|
|
265
|
-
required: false,
|
|
266
|
-
},
|
|
267
|
-
},
|
|
148
|
+
props: widgetProps,
|
|
268
149
|
})({
|
|
269
150
|
vaspDID: this.config.vaspDID,
|
|
270
151
|
transaction: {},
|
|
@@ -318,59 +199,7 @@ export default class Notabene {
|
|
|
318
199
|
width: '100%',
|
|
319
200
|
height: '100%',
|
|
320
201
|
},
|
|
321
|
-
props:
|
|
322
|
-
vaspDID: {
|
|
323
|
-
type: 'string',
|
|
324
|
-
required: true,
|
|
325
|
-
},
|
|
326
|
-
transaction: {
|
|
327
|
-
type: 'object',
|
|
328
|
-
required: false,
|
|
329
|
-
},
|
|
330
|
-
storeTransaction: {
|
|
331
|
-
type: 'function',
|
|
332
|
-
required: true,
|
|
333
|
-
},
|
|
334
|
-
close: {
|
|
335
|
-
type: 'function',
|
|
336
|
-
},
|
|
337
|
-
theme: {
|
|
338
|
-
type: 'object',
|
|
339
|
-
required: false,
|
|
340
|
-
},
|
|
341
|
-
dictionary: {
|
|
342
|
-
type: 'object',
|
|
343
|
-
required: false,
|
|
344
|
-
},
|
|
345
|
-
transactionTypeAllowed: {
|
|
346
|
-
type: 'string',
|
|
347
|
-
required: false,
|
|
348
|
-
},
|
|
349
|
-
nonCustodialDeclarationType: {
|
|
350
|
-
type: 'string',
|
|
351
|
-
required: false,
|
|
352
|
-
},
|
|
353
|
-
popupOpen: {
|
|
354
|
-
type: 'boolean',
|
|
355
|
-
required: true,
|
|
356
|
-
},
|
|
357
|
-
setPopupOpen: {
|
|
358
|
-
type: 'function',
|
|
359
|
-
required: true,
|
|
360
|
-
},
|
|
361
|
-
error: {
|
|
362
|
-
type: 'object',
|
|
363
|
-
required: false,
|
|
364
|
-
},
|
|
365
|
-
onError: {
|
|
366
|
-
type: 'function',
|
|
367
|
-
required: true,
|
|
368
|
-
},
|
|
369
|
-
beneficiaryDetails: {
|
|
370
|
-
type: 'array',
|
|
371
|
-
required: false,
|
|
372
|
-
},
|
|
373
|
-
},
|
|
202
|
+
props: popupProps,
|
|
374
203
|
containerTemplate: ({ uid, doc, frame, prerenderFrame }: any) => {
|
|
375
204
|
return node(
|
|
376
205
|
'div',
|
|
@@ -394,7 +223,6 @@ export default class Notabene {
|
|
|
394
223
|
background-color: rgba(0,0,0,0.5);
|
|
395
224
|
}
|
|
396
225
|
.nb-popup {
|
|
397
|
-
max-width: 608px;
|
|
398
226
|
width: 100%;
|
|
399
227
|
height: 100%;
|
|
400
228
|
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { DateAndPlaceOfBirth, NationalIdentification } from 'ivms/types';
|
|
2
|
+
|
|
3
|
+
export type Theme = {
|
|
4
|
+
primaryColor: string;
|
|
5
|
+
secondaryColor: string;
|
|
6
|
+
fontFamily: string;
|
|
7
|
+
logo: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type TransactionTypeAllowed =
|
|
11
|
+
| 'ALL'
|
|
12
|
+
| 'VASP_2_VASP_ONLY'
|
|
13
|
+
| 'SELF_TRANSACTION_ONLY';
|
|
14
|
+
|
|
15
|
+
export type NonCustodialDeclarationType =
|
|
16
|
+
| 'SIGNATURE'
|
|
17
|
+
| 'DECLARATION'
|
|
18
|
+
| 'SIGNATURE_AND_DECLARATION';
|
|
19
|
+
|
|
20
|
+
export type OwnershipProofInput = {
|
|
21
|
+
type?: string | null;
|
|
22
|
+
proof?: string | null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type TransactionBlockchainInfo = {
|
|
26
|
+
destination?: string | null;
|
|
27
|
+
origin?: string | null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type CountryType = {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type PersonType = 'natural' | 'legal';
|
|
36
|
+
|
|
37
|
+
export type OriginatorFields = {
|
|
38
|
+
originatorAccountNumber?: string;
|
|
39
|
+
originatorDid?: string;
|
|
40
|
+
originatorVASPname?: string;
|
|
41
|
+
originatorVASPdid?: string;
|
|
42
|
+
originatorName?: string;
|
|
43
|
+
originatorGeographicAddress?: string;
|
|
44
|
+
originatorNationalIdentification?: NationalIdentification;
|
|
45
|
+
originatorDateAndPlaceOfBirth?: DateAndPlaceOfBirth;
|
|
46
|
+
originatorPersonType?: PersonType;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type BeneficiaryFields = {
|
|
50
|
+
beneficiaryAccountNumber?: string;
|
|
51
|
+
beneficiaryDid?: string;
|
|
52
|
+
beneficiaryVASPname?: string;
|
|
53
|
+
beneficiaryVASPdid?: string;
|
|
54
|
+
beneficiaryName?: string;
|
|
55
|
+
beneficiaryGeographicAddress?: string;
|
|
56
|
+
beneficiaryNationalIdentification?: NationalIdentification;
|
|
57
|
+
beneficiaryDateAndPlaceOfBirth?: DateAndPlaceOfBirth;
|
|
58
|
+
beneficiaryPersonType?: PersonType;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type Transaction = OriginatorFields &
|
|
62
|
+
BeneficiaryFields & {
|
|
63
|
+
transactionAsset: string;
|
|
64
|
+
transactionAmount: string;
|
|
65
|
+
transactionBlockchainInfo?: TransactionBlockchainInfo;
|
|
66
|
+
isNonCustodial?: boolean;
|
|
67
|
+
originatorEqualsBeneficiary?: boolean;
|
|
68
|
+
beneficiaryProof?: OwnershipProofInput;
|
|
69
|
+
originatorProof?: OwnershipProofInput;
|
|
70
|
+
isValid?: boolean;
|
|
71
|
+
errors?: string[];
|
|
72
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const generalProps = {
|
|
2
|
+
vaspDID: {
|
|
3
|
+
type: 'string',
|
|
4
|
+
required: true,
|
|
5
|
+
},
|
|
6
|
+
transaction: {
|
|
7
|
+
type: 'object',
|
|
8
|
+
required: false,
|
|
9
|
+
},
|
|
10
|
+
error: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
required: false,
|
|
13
|
+
},
|
|
14
|
+
onError: {
|
|
15
|
+
type: 'function',
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
storeTransaction: {
|
|
19
|
+
type: 'function',
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
theme: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
required: false,
|
|
25
|
+
},
|
|
26
|
+
dictionary: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
required: false,
|
|
29
|
+
},
|
|
30
|
+
transactionTypeAllowed: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
required: false,
|
|
33
|
+
},
|
|
34
|
+
nonCustodialDeclarationType: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
required: false,
|
|
37
|
+
},
|
|
38
|
+
beneficiaryDetails: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
required: false,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const widgetProps = {
|
|
45
|
+
...generalProps,
|
|
46
|
+
onRequireAdditionalInformation: {
|
|
47
|
+
type: 'function',
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
50
|
+
onValidStateChange: {
|
|
51
|
+
type: 'function',
|
|
52
|
+
required: true,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const popupProps = {
|
|
57
|
+
...generalProps,
|
|
58
|
+
close: {
|
|
59
|
+
type: 'function',
|
|
60
|
+
},
|
|
61
|
+
popupOpen: {
|
|
62
|
+
type: 'boolean',
|
|
63
|
+
required: true,
|
|
64
|
+
},
|
|
65
|
+
setPopupOpen: {
|
|
66
|
+
type: 'function',
|
|
67
|
+
required: true,
|
|
68
|
+
},
|
|
69
|
+
};
|