@notabene/javascript-sdk 1.34.0 → 2.0.0-next.11

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/src/types.ts CHANGED
@@ -1,5 +1,138 @@
1
- import { DateAndPlaceOfBirth, NationalIdentification } from 'ivms/types';
1
+ import {
2
+ Address,
3
+ Beneficiary,
4
+ ISOCountryCode,
5
+ ISODate,
6
+ IVMS101,
7
+ NationalIdentification,
8
+ Originator,
9
+ } from './ivms/types';
2
10
 
11
+ /**
12
+ * Interoperable Virtual Asset Service Provider (VASP) Messaging Standard
13
+ * @public
14
+ */
15
+ export type { IVMS101 };
16
+
17
+ /**
18
+ * UUID v4
19
+ * @public
20
+ */
21
+ export type UUID = string;
22
+
23
+ /**
24
+ * Chain Agnostic Blockchain Identifier
25
+ * Represents a blockchain in a chain-agnostic way
26
+ * Format: `namespace:reference`
27
+ * @example "eip155:1" for Ethereum Mainnet
28
+ * @public
29
+ */
30
+ export type CAIP2 = `${string}:${string}`;
31
+
32
+ /**
33
+ * Chain Agnostic Account Identifier
34
+ * Represents an account on a specific blockchain
35
+ * Format: `{caip2}:{address}`
36
+ * @example "eip155:1:0x742d35Cc6634C0532925a3b844Bc454e4438f44e" for an Ethereum account
37
+ * @public
38
+ */
39
+ export type CAIP10 = `${CAIP2}:${string}`;
40
+
41
+ /**
42
+ * Chain Agnostic Asset Identifier
43
+ * Represents an asset on a specific blockchain
44
+ * Format: `{caip2}/{asset_namespace}:{asset_reference}`
45
+ * @example "eip155:1/erc20:0x6b175474e89094c44da98b954eedeac495271d0f" for DAI on Ethereum
46
+ * @public
47
+ */
48
+ export type CAIP19 = `${CAIP2}/${string}:${string}`;
49
+
50
+ /**
51
+ * Chain Agnostic Payload Identifier
52
+ * @public
53
+ */
54
+ export type CAIP220 = string;
55
+
56
+ /**
57
+ * Digital Token Identifier
58
+ * @public
59
+ */
60
+ export type DTI = string;
61
+
62
+ /**
63
+ * Notabene Asset Identifier
64
+ * @public
65
+ */
66
+ export type NotabeneAsset = string;
67
+
68
+ /**
69
+ * The asset of a transaction either a Notabene asset, a CAIP-19 asset, or a DTI.
70
+ * @public
71
+ */
72
+ export type TransactionAsset = NotabeneAsset | CAIP19 | DTI;
73
+
74
+ /**
75
+ * A blockchain address
76
+ * @public
77
+ */
78
+ export type BlockchainAddress = string;
79
+
80
+ /**
81
+ * A travel address
82
+ * @public
83
+ */
84
+ export type TravelAddress = `ta${string}`;
85
+
86
+ /**
87
+ * A crypto credential
88
+ * @public
89
+ */
90
+ export type CryptoCredential = `${string}.${string}.mastercard`;
91
+
92
+ /**
93
+ * The destination of a transaction either a blockchain address, a CAIP-19 address, or a travel address.
94
+ * @public
95
+ */
96
+ export type Destination =
97
+ | BlockchainAddress
98
+ | CAIP10
99
+ | CryptoCredential
100
+ | TravelAddress;
101
+
102
+ /**
103
+ * The source of a transaction
104
+ * @public
105
+ */
106
+ export type Source = BlockchainAddress | CAIP10;
107
+
108
+ /**
109
+ * A Uniform Resource Identifier
110
+ * @public
111
+ */
112
+ export type URI = string;
113
+
114
+ /**
115
+ * A Decentralized Identifier
116
+ * @public
117
+ */
118
+ export type DID = `did:${string}:${string}`;
119
+
120
+ /**
121
+ * A LEI Legal Entity Identifier
122
+ * @public
123
+ */
124
+ export type LEI = string;
125
+
126
+ /**
127
+ * 3 letter ISO currency code
128
+ * @public
129
+ */
130
+ export type ISOCurrency = string;
131
+
132
+ /**
133
+ * The theme of the Notabene SDK
134
+ * @public
135
+ */
3
136
  export type Theme = {
4
137
  primaryColor: string;
5
138
  secondaryColor: string;
@@ -7,109 +140,507 @@ export type Theme = {
7
140
  logo: string;
8
141
  };
9
142
 
10
- export enum WidgetType {
11
- WITHDRAWAL = 'WITHDRAWAL',
12
- POST_DEPOSIT = 'POST_DEPOSIT',
143
+ /**
144
+ * The type of Agent. Either a wallet or a VASP
145
+ * @public
146
+ */
147
+ export enum AgentType {
148
+ PRIVATE = 'WALLET',
149
+ VASP = 'VASP',
13
150
  }
14
151
 
15
- export type TransactionTypeAllowed =
16
- | 'ALL'
17
- | 'VASP_2_VASP_ONLY'
18
- | 'SELF_TRANSACTION_ONLY';
152
+ /**
153
+ * Who is the agent acting on behalf of the counterparty
154
+ * @public
155
+ */
156
+ export interface Agent {
157
+ did: DID;
158
+ type: AgentType;
159
+ logo?: URI;
160
+ url?: URI;
161
+ name?: string;
162
+ verified?: boolean;
163
+ }
19
164
 
20
- export type NonCustodialDeclarationType =
21
- | 'SIGNATURE'
22
- | 'DECLARATION'
23
- | 'SIGNATURE_AND_DECLARATION';
165
+ /**
166
+ * The type of counterparty. Either a natural person or a legal person. If the customer is the same as the counterparty then the counterparty is a self.
167
+ * @public
168
+ */
169
+ export enum PersonType {
170
+ NATURAL = 'natural',
171
+ LEGAL = 'legal',
172
+ SELF = 'self', // first party
173
+ }
24
174
 
25
- export type OwnershipProofInput = {
26
- type?: string | null;
27
- proof?: string | null;
28
- };
175
+ /**
176
+ * A VASP agent acting on behalf of the counterparty
177
+ * @public
178
+ */
179
+ export interface VASP extends Agent {
180
+ lei?: LEI;
181
+ logo?: URI;
182
+ website?: URI;
183
+ countryOfRegistration?: ISOCountryCode;
184
+ }
185
+
186
+ /**
187
+ * A wallet agent acting on behalf of the counterparty
188
+ * @public
189
+ */
190
+ export interface Wallet extends Agent {
191
+ proof: OwnershipProof;
192
+ wallet_connect_id?: string;
193
+ }
29
194
 
30
- export type TransactionBlockchainInfo = {
31
- destination?: string | null;
32
- origin?: string | null;
195
+ /**
196
+ * The counterparty of a transaction.
197
+ * @public
198
+ */
199
+ export interface Counterparty {
200
+ name?: string;
201
+ accountNumber?: string;
202
+ did?: DID;
203
+ type?: PersonType;
204
+ verified?: boolean;
205
+ geographicAddress?: Address;
206
+ nationalIdentification?: NationalIdentification;
207
+ website?: URI;
208
+ phone?: string;
209
+ }
210
+
211
+ /**
212
+ * A counterparty object representing a natural person
213
+ * @public
214
+ */
215
+ export interface NaturalPerson extends Counterparty {
216
+ type: PersonType.NATURAL;
217
+ dateOfBirth?: ISODate;
218
+ placeOfBirth?: string;
219
+ countryOfResidence?: ISOCountryCode;
220
+ name: string;
221
+ }
222
+ /**
223
+ * Field names for NaturalPerson
224
+ * @public
225
+ */
226
+ export type NaturalPersonFieldName =
227
+ | 'name' // Full legal name
228
+ | 'website' // Primary website of entity
229
+ | 'email' // Contact email
230
+ | 'phone' // Contact mobile phone
231
+ | 'geographicAddress' // Address string
232
+ | 'nationalIdentification' // National Identification number
233
+ | 'dateOfBirth' // Date of Birty YYYY-MM-DD
234
+ | 'placeOfBirth' // Place of Birth
235
+ | 'countryOfResidence'; // ISO Country code of residence of Natural Person
236
+ /**
237
+ * Field properties by field name
238
+ * @public
239
+ */
240
+ export type NaturalPersonFields = {
241
+ [name in NaturalPersonFieldName]?: FieldOptions;
33
242
  };
34
243
 
35
- export type CountryType = {
36
- id: string;
244
+ /**
245
+ * A counterparty object representing a legal person
246
+ * @public
247
+ */
248
+ export interface LegalPerson extends Counterparty {
249
+ type: PersonType.LEGAL;
37
250
  name: string;
251
+ lei?: LEI;
252
+ logo?: URI;
253
+ countryOfRegistration?: ISOCountryCode;
254
+ }
255
+ /**
256
+ * Field names for LegalPerson
257
+ * @public
258
+ */
259
+
260
+ export type LegalPersonFieldName =
261
+ | 'name' // Full legal name
262
+ | 'lei' // Legal Entity Identifier
263
+ | 'website' // Primary website of entity
264
+ | 'email' // Contact email
265
+ | 'phone' // Contact mobile phone
266
+ | 'geographicAddress' // Address string
267
+ | 'nationalIdentification' // National Identification number
268
+ | 'countryOfRegistration'; // ISO Country code of registration of Legal Person
269
+
270
+ /**
271
+ * Field properties by field name
272
+ * @public
273
+ */
274
+ export type LegalPersonFields = {
275
+ [name in LegalPersonFieldName]?: FieldOptions;
38
276
  };
39
277
 
40
- export type PersonType = 'natural' | 'legal';
278
+ /**
279
+ * Fields specific to the originator of a transaction
280
+ * @public
281
+ */
282
+ type OriginatorFields = {
283
+ source?: Source;
284
+ };
41
285
 
42
- export type OriginatorFields = {
43
- originatorAccountNumber?: string;
44
- originatorDid?: string;
45
- originatorVASPname?: string;
46
- originatorVASPdid?: string;
47
- originatorName?: string;
48
- originatorGeographicAddress?: string;
49
- originatorNationalIdentification?: NationalIdentification;
50
- originatorDateAndPlaceOfBirth?: DateAndPlaceOfBirth;
51
- originatorPersonType?: PersonType;
286
+ /**
287
+ * Fields specific to the beneficiary of a transaction
288
+ * @public
289
+ */
290
+ type BeneficiaryFields = {
291
+ destination?: Destination;
52
292
  };
53
293
 
54
- export type BeneficiaryFields = {
55
- beneficiaryAccountNumber?: string;
56
- beneficiaryDid?: string;
57
- beneficiaryVASPname?: string;
58
- beneficiaryVASPdid?: string;
59
- beneficiaryName?: string;
60
- beneficiaryGeographicAddress?: string;
61
- beneficiaryNationalIdentification?: NationalIdentification;
62
- beneficiaryDateAndPlaceOfBirth?: DateAndPlaceOfBirth;
63
- beneficiaryPersonType?: PersonType;
294
+ /**
295
+ * Fields specific to a deposit request
296
+ * @public
297
+ */
298
+ type DepositRequestFields = {
299
+ destinations: Destination[];
64
300
  };
65
301
 
66
- export type CAIP19 = {
67
- caip19: string;
302
+ type RequestID = UUID;
303
+
304
+ /**
305
+ * An abstract request for communicating with a component
306
+ * @public
307
+ */
308
+ export interface ComponentRequest {
309
+ requestId?: RequestID;
310
+ customer?: Counterparty;
311
+ }
312
+
313
+ /**
314
+ * An abstract transaction object
315
+ * @public
316
+ */
317
+ export interface Transaction extends ComponentRequest {
318
+ agent: Agent;
319
+ counterparty: Counterparty;
320
+ asset: TransactionAsset;
321
+ amountDecimal: number;
322
+ proof?: OwnershipProof;
323
+ assetPrice?: {
324
+ price: number;
325
+ currency: ISOCurrency;
326
+ };
327
+ }
328
+
329
+ /**
330
+ * An object representing a withdrawal transaction
331
+ * @public
332
+ */
333
+ export interface Withdrawal extends BeneficiaryFields, Transaction {}
334
+
335
+ /**
336
+ * An object representing a deposit transaction
337
+ * @public
338
+ */
339
+ export interface Deposit extends OriginatorFields, Transaction {}
340
+
341
+ /**
342
+ * An object representing a request for a deposit
343
+ * @public
344
+ */
345
+ export interface DepositRequest extends DepositRequestFields, Transaction {}
346
+
347
+ /**
348
+ * An object representing a connection request
349
+ * @public
350
+ */
351
+ export interface ConnectionRequest extends ComponentRequest {
352
+ asset: TransactionAsset;
353
+ }
354
+
355
+ /**
356
+ * An object representing a connection response
357
+ * @public
358
+ */
359
+ export interface ConnectionResponse extends ComponentResponse {
360
+ value: ConnectionRequest;
361
+ ivms: IVMS101;
362
+ proof?: OwnershipProof;
363
+ txCreate?: V1Transaction;
364
+ }
365
+
366
+ /**
367
+ * The verification status of a transaction
368
+ * @public
369
+ */
370
+ export enum Status {
371
+ EMPTY = 'empty',
372
+ VERIFY = 'verify',
373
+ PENDING = 'pending',
374
+ VERIFIED = 'verified',
375
+ BANNED = 'banned',
376
+ }
377
+
378
+ type V1Asset = NotabeneAsset | { caip19: CAIP19 };
379
+ /**
380
+ * Transaction payload suitable for calling Notabene v1 tx/create
381
+ * @public
382
+ */
383
+ export type V1Transaction = {
384
+ transactionAsset: V1Asset;
385
+ transactionAmount: string;
386
+ originatorEqualsBeneficiary?: boolean;
387
+ originatorVASPdid: DID;
388
+ beneficiaryVASPdid: DID;
389
+ beneficiaryProof: OwnershipProof;
390
+ originator: Originator;
391
+ beneficiary: Beneficiary;
68
392
  };
69
393
 
70
- export type CoingeckoIdAndNetwork = { coingeckoId: string; network: string };
394
+ export interface ComponentResponse {
395
+ requestID: RequestID;
396
+ valid: boolean;
397
+ status: Status;
398
+ errors: ValidationError[];
399
+ }
400
+ /**
401
+ * The response of a transaction
402
+ * @public
403
+ */
404
+ export interface TransactionResponse<V> extends ComponentResponse {
405
+ value: V;
406
+ ivms: IVMS101;
407
+ proof?: OwnershipProof;
408
+ txCreate?: V1Transaction;
409
+ }
410
+
411
+ /**
412
+ * Validation error
413
+ * @public
414
+ */
415
+ export type ValidationError = {
416
+ attribute: string;
417
+ message: string;
418
+ };
71
419
 
72
- export type TransactionAsset = string | CAIP19 | CoingeckoIdAndNetwork;
73
- export type Transaction = OriginatorFields &
74
- BeneficiaryFields & {
75
- transactionAsset: TransactionAsset;
76
- transactionAmount: string;
77
- transactionBlockchainInfo?: TransactionBlockchainInfo;
78
- customAssetPrice?: {
79
- priceUSD: number;
80
- decimals: number;
420
+ /**
421
+ * Field properties
422
+ * @public
423
+ */
424
+ export type FieldOptions =
425
+ | boolean
426
+ | {
427
+ optional: boolean; // Shown but optional
428
+ transmit: boolean; // Transmit as part of IVMS 101 to counterparty
81
429
  };
82
- isNonCustodial?: boolean;
83
- originatorEqualsBeneficiary?: boolean;
84
- beneficiaryProof?: OwnershipProofInput;
85
- originatorProof?: OwnershipProofInput;
86
- isValid?: boolean;
87
- errors?: string[];
430
+
431
+ export type FieldTypes = {
432
+ naturalPerson?: NaturalPersonFields;
433
+ legalPerson?: LegalPersonFields;
434
+ };
435
+ /**
436
+ * Configuration options for Transaction components
437
+ * @public
438
+ */
439
+ export interface TransactionOptions {
440
+ proofs?: {
441
+ microTransfer?: {
442
+ destination: BlockchainAddress;
443
+ timeout?: number; // Time to verify in seconds
444
+ };
445
+ fallbacks?: ProofTypes[];
88
446
  };
447
+ allowedAgentTypes?: AgentType[]; // Defaults to All
448
+ allowedCounterpartyTypes?: PersonType[]; // Defaults to All
449
+ fields?: FieldTypes;
450
+ }
451
+
452
+ /**
453
+ * Component Message Types
454
+ * @public
455
+ */
456
+ export const enum CMType {
457
+ COMPLETE = 'complete',
458
+ RESIZE = 'resize',
459
+ RESULT = 'result',
460
+ READY = 'ready',
461
+ INVALID = 'invalid',
462
+ MODAL = 'openModal',
463
+ ERROR = 'error',
464
+ CLOSE = 'closeModal',
465
+ CANCEL = 'cancel',
466
+ }
467
+
468
+ /**
469
+ * Represents a completed component message
470
+ * @public
471
+ */
472
+ export type Completed = {
473
+ type: CMType.COMPLETE;
474
+ response: ComponentResponse;
475
+ };
89
476
 
90
- export type FieldProps = {
91
- forceDisplay?: boolean; // instead of beneficiaryDetails - defaults to false
92
- optional?: boolean; // bypass the jurisdiction rules validation - defaults to false
477
+ /**
478
+ * Represents a ready component message
479
+ * @public
480
+ */
481
+ export type Ready = {
482
+ type: CMType.READY;
93
483
  };
94
484
 
95
- export type FieldName =
96
- | 'counterparty'
97
- | 'geographicAddress'
98
- | 'firstName'
99
- | 'name'
100
- | 'nationalIdentification'
101
- | 'dateAndPlaceOfBirth';
485
+ /**
486
+ * Represents a resize request component message
487
+ * @public
488
+ */
489
+ export type ResizeRequest = {
490
+ type: CMType.RESIZE;
491
+ height: number;
492
+ };
102
493
 
103
- export type FieldsProps = {
104
- [name in FieldName]?: FieldProps;
494
+ /**
495
+ * Represents an error component message
496
+ * @public
497
+ */
498
+ export type Error = {
499
+ type: CMType.ERROR;
500
+ message: string;
105
501
  };
106
502
 
107
- type WalletNotSupportedFlow = {
108
- flow: 'WALLET_NOT_SUPPORTED';
109
- action: 'DECLARATION' | 'REJECT';
503
+ /**
504
+ * Represents a cancel component message
505
+ * @public
506
+ */
507
+ export type Cancel = {
508
+ type: CMType.CANCEL;
110
509
  };
111
510
 
112
- // This is going to be union type
113
- export type Fallback = WalletNotSupportedFlow;
511
+ /**
512
+ * Represents an invalid value component message
513
+ * @public
514
+ */
515
+ export type InvalidValue = {
516
+ type: CMType.INVALID;
517
+ value: any;
518
+ errors: ValidationError[];
519
+ };
520
+
521
+ /**
522
+ * Component Message
523
+ * @public
524
+ */
525
+ export type ComponentMessage =
526
+ | Completed
527
+ | Cancel
528
+ | Error
529
+ | Ready
530
+ | ResizeRequest
531
+ | InvalidValue;
532
+
533
+ /**
534
+ * Host Message Types
535
+ * @public
536
+ */
114
537
 
115
- export type OptInFeature = 'REUSE_ADDRESS_OWNERSHIP_PROOF';
538
+ export const enum HMType {
539
+ UPDATE = 'update',
540
+ REQUEST_RESPONSE = 'requestResponse',
541
+ }
542
+
543
+ /**
544
+ * Represents an update value host message
545
+ * @public
546
+ */
547
+ export type UpdateValue = {
548
+ type: HMType.UPDATE;
549
+ value: ComponentRequest;
550
+ };
551
+
552
+ /**
553
+ * Host Messages
554
+ * @public
555
+ */
556
+ export type HostMessage = UpdateValue;
557
+
558
+ /**
559
+ * Options for callback and redirect URIs
560
+ * @public
561
+ */
562
+ export interface CallbackOptions {
563
+ callback?: URI;
564
+ redirectUri?: URI;
565
+ }
566
+
567
+ /**
568
+ * Status of the proof
569
+ * @public
570
+ */
571
+ export enum ProofStatus {
572
+ PENDING = 'pending', // Verification is pending
573
+ FAILED = 'rejected', // Rejected
574
+ FLAGGED = 'flagged', // Flagged for manual review
575
+ VERIFIED = 'verified', // Verified
576
+ }
577
+
578
+ /**
579
+ * The type of Proofs supported
580
+ * @public
581
+ */
582
+ export enum ProofTypes {
583
+ SelfDeclaration = 'self-declaration',
584
+ PersonalSignEIP191 = 'eip-191',
585
+ PersonalSignEIP712 = 'eip-712',
586
+ PersonalSignBIP137 = 'bip-137',
587
+ PersonalSignXPUB = 'xpub',
588
+ MicroTransfer = 'microtransfer',
589
+ Screenshot = 'screenshot',
590
+ }
591
+
592
+ /**
593
+ * Ownership Proof
594
+ * @public
595
+ */
596
+ export interface OwnershipProof {
597
+ type: ProofTypes;
598
+ status: ProofStatus;
599
+ did: DID;
600
+ address: CAIP10;
601
+ }
602
+
603
+ /**
604
+ * Ownership Proof using Message Signature
605
+ * @public
606
+ */
607
+ export interface SignatureProof extends OwnershipProof {
608
+ type:
609
+ | ProofTypes.PersonalSignEIP191
610
+ | ProofTypes.PersonalSignEIP712
611
+ | ProofTypes.PersonalSignBIP137
612
+ | ProofTypes.PersonalSignXPUB;
613
+ proof: string;
614
+ attestation: string;
615
+ wallet_provider: string;
616
+ }
617
+
618
+ /**
619
+ * Ownership Proof using Self Declaration
620
+ * @public
621
+ */
622
+ export interface DeclarationProof extends OwnershipProof {
623
+ type: ProofTypes.SelfDeclaration;
624
+ attestation: string;
625
+ confirmed: boolean;
626
+ }
627
+
628
+ /**
629
+ * Ownership Proof using Micro Transfer
630
+ * @public
631
+ */
632
+ export interface MicroTransferProof extends OwnershipProof {
633
+ type: ProofTypes.MicroTransfer;
634
+ txhash: string;
635
+ chain: CAIP2;
636
+ amountSubunits: string;
637
+ }
638
+
639
+ /**
640
+ * Ownership Proof using Screenshot
641
+ * @public
642
+ */
643
+ export interface ScreenshotProof extends OwnershipProof {
644
+ type: ProofTypes.Screenshot;
645
+ url: string;
646
+ }