@notabene/javascript-sdk 1.14.3 → 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 -143
- 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 -184
- 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,35 +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
|
-
'beneficiaryPersonType',
|
|
149
|
-
'beneficiaryDid',
|
|
150
|
-
'isNonCustodial',
|
|
151
|
-
'originatorEqualsBeneficiary',
|
|
152
|
-
'beneficiaryProof',
|
|
153
|
-
'isValid',
|
|
154
|
-
'errors',
|
|
155
|
-
];
|
|
156
|
-
if (tx) {
|
|
157
|
-
Object.keys(tx).forEach((key) => {
|
|
158
|
-
if (!validProperties.includes(key)) {
|
|
159
|
-
throw new Error(`Notabene: Invalid transaction property ${key}`);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
92
|
this.tx = tx;
|
|
164
93
|
if (this.widgetRendered) {
|
|
165
94
|
this.widget.updateProps({
|
|
@@ -216,56 +145,7 @@ export default class Notabene {
|
|
|
216
145
|
width: '100%',
|
|
217
146
|
height: '280px',
|
|
218
147
|
},
|
|
219
|
-
props:
|
|
220
|
-
vaspDID: {
|
|
221
|
-
type: 'string',
|
|
222
|
-
required: true,
|
|
223
|
-
},
|
|
224
|
-
transaction: {
|
|
225
|
-
type: 'object',
|
|
226
|
-
required: false,
|
|
227
|
-
},
|
|
228
|
-
onRequireAdditionalInformation: {
|
|
229
|
-
type: 'function',
|
|
230
|
-
required: true,
|
|
231
|
-
},
|
|
232
|
-
onValidStateChange: {
|
|
233
|
-
type: 'function',
|
|
234
|
-
required: true,
|
|
235
|
-
},
|
|
236
|
-
error: {
|
|
237
|
-
type: 'object',
|
|
238
|
-
required: false,
|
|
239
|
-
},
|
|
240
|
-
onError: {
|
|
241
|
-
type: 'function',
|
|
242
|
-
required: true,
|
|
243
|
-
},
|
|
244
|
-
storeTransaction: {
|
|
245
|
-
type: 'function',
|
|
246
|
-
required: true,
|
|
247
|
-
},
|
|
248
|
-
theme: {
|
|
249
|
-
type: 'object',
|
|
250
|
-
required: false,
|
|
251
|
-
},
|
|
252
|
-
dictionary: {
|
|
253
|
-
type: 'object',
|
|
254
|
-
required: false,
|
|
255
|
-
},
|
|
256
|
-
transactionTypeAllowed: {
|
|
257
|
-
type: 'string',
|
|
258
|
-
required: false,
|
|
259
|
-
},
|
|
260
|
-
nonCustodialDeclarationType: {
|
|
261
|
-
type: 'string',
|
|
262
|
-
required: false,
|
|
263
|
-
},
|
|
264
|
-
beneficiaryDetails: {
|
|
265
|
-
type: 'array',
|
|
266
|
-
required: false,
|
|
267
|
-
},
|
|
268
|
-
},
|
|
148
|
+
props: widgetProps,
|
|
269
149
|
})({
|
|
270
150
|
vaspDID: this.config.vaspDID,
|
|
271
151
|
transaction: {},
|
|
@@ -319,59 +199,7 @@ export default class Notabene {
|
|
|
319
199
|
width: '100%',
|
|
320
200
|
height: '100%',
|
|
321
201
|
},
|
|
322
|
-
props:
|
|
323
|
-
vaspDID: {
|
|
324
|
-
type: 'string',
|
|
325
|
-
required: true,
|
|
326
|
-
},
|
|
327
|
-
transaction: {
|
|
328
|
-
type: 'object',
|
|
329
|
-
required: false,
|
|
330
|
-
},
|
|
331
|
-
storeTransaction: {
|
|
332
|
-
type: 'function',
|
|
333
|
-
required: true,
|
|
334
|
-
},
|
|
335
|
-
close: {
|
|
336
|
-
type: 'function',
|
|
337
|
-
},
|
|
338
|
-
theme: {
|
|
339
|
-
type: 'object',
|
|
340
|
-
required: false,
|
|
341
|
-
},
|
|
342
|
-
dictionary: {
|
|
343
|
-
type: 'object',
|
|
344
|
-
required: false,
|
|
345
|
-
},
|
|
346
|
-
transactionTypeAllowed: {
|
|
347
|
-
type: 'string',
|
|
348
|
-
required: false,
|
|
349
|
-
},
|
|
350
|
-
nonCustodialDeclarationType: {
|
|
351
|
-
type: 'string',
|
|
352
|
-
required: false,
|
|
353
|
-
},
|
|
354
|
-
popupOpen: {
|
|
355
|
-
type: 'boolean',
|
|
356
|
-
required: true,
|
|
357
|
-
},
|
|
358
|
-
setPopupOpen: {
|
|
359
|
-
type: 'function',
|
|
360
|
-
required: true,
|
|
361
|
-
},
|
|
362
|
-
error: {
|
|
363
|
-
type: 'object',
|
|
364
|
-
required: false,
|
|
365
|
-
},
|
|
366
|
-
onError: {
|
|
367
|
-
type: 'function',
|
|
368
|
-
required: true,
|
|
369
|
-
},
|
|
370
|
-
beneficiaryDetails: {
|
|
371
|
-
type: 'array',
|
|
372
|
-
required: false,
|
|
373
|
-
},
|
|
374
|
-
},
|
|
202
|
+
props: popupProps,
|
|
375
203
|
containerTemplate: ({ uid, doc, frame, prerenderFrame }: any) => {
|
|
376
204
|
return node(
|
|
377
205
|
'div',
|
|
@@ -395,7 +223,6 @@ export default class Notabene {
|
|
|
395
223
|
background-color: rgba(0,0,0,0.5);
|
|
396
224
|
}
|
|
397
225
|
.nb-popup {
|
|
398
|
-
max-width: 608px;
|
|
399
226
|
width: 100%;
|
|
400
227
|
height: 100%;
|
|
401
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
|
+
};
|