@notabene/javascript-sdk 1.35.2 → 2.0.0-RC

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.
Files changed (46) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +498 -268
  3. package/dist/notabene.cjs +1 -0
  4. package/dist/notabene.d.ts +1565 -0
  5. package/dist/notabene.js +343 -0
  6. package/dist/tsdoc-metadata.json +11 -0
  7. package/package.json +50 -63
  8. package/src/__tests__/notabene.test.ts +270 -0
  9. package/src/components/EmbeddedComponent.ts +237 -0
  10. package/src/components/__tests__/EmbeddedComponent.test.ts +530 -0
  11. package/src/ivms/types.ts +232 -152
  12. package/src/locales.ts +47 -0
  13. package/src/notabene.ts +292 -293
  14. package/src/types.ts +1068 -78
  15. package/src/utils/MessageEventManager.ts +115 -0
  16. package/src/utils/__tests__/MessageEventManager.test.ts +119 -0
  17. package/src/utils/__tests__/urls.test.ts +112 -0
  18. package/src/utils/arbitraries.ts +244 -0
  19. package/src/utils/caip.ts +16 -0
  20. package/src/utils/urls.ts +40 -0
  21. package/.editorconfig +0 -10
  22. package/.envrc.template +0 -1
  23. package/.eslintignore +0 -3
  24. package/.eslintrc.js +0 -13
  25. package/.gitlab-ci.yml +0 -74
  26. package/.husky/commit-msg +0 -4
  27. package/.husky/pre-commit +0 -4
  28. package/.husky/pre-push +0 -4
  29. package/.nvmrc +0 -1
  30. package/.prettierrc +0 -4
  31. package/.releaserc.json +0 -16
  32. package/.tool-versions +0 -3
  33. package/.vscode/extensions.json +0 -7
  34. package/.vscode/settings.json +0 -11
  35. package/.yarn/releases/yarn-3.2.2.cjs +0 -783
  36. package/.yarnrc.yml +0 -5
  37. package/CODEOWNERS +0 -1
  38. package/dist/lib/index.js +0 -379
  39. package/jest.config.js +0 -5
  40. package/public/index.html +0 -93
  41. package/src/lib/index.ts +0 -2
  42. package/src/module/index.ts +0 -10
  43. package/src/zoidComponentProps.ts +0 -81
  44. package/tsconfig.json +0 -18
  45. /package/dist/{es/index.js → js/notabene.js} +0 -0
  46. /package/{public/js/.gitkeep → src/arbitraries.ts} +0 -0
package/src/types.ts CHANGED
@@ -1,5 +1,239 @@
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
+ export type {
12
+ BeneficiaryVASP,
13
+ OriginatingVASP,
14
+ PayloadMetadata,
15
+ TransferPath,
16
+ } from './ivms/types';
17
+ export type {
18
+ Address,
19
+ Beneficiary,
20
+ ISOCountryCode,
21
+ ISODate,
22
+ NationalIdentification,
23
+ Originator,
24
+ };
25
+ /**
26
+ * Interoperable Virtual Asset Service Provider (VASP) Messaging Standard
27
+ * @public
28
+ */
29
+ export type { IVMS101 };
30
+
31
+ /**
32
+ * UUID v4 string identifier
33
+ * A universally unique identifier that follows RFC 4122 format
34
+ * Format: 8-4-4-4-12 hexadecimal digits
35
+ * @example "550e8400-e29b-41d4-a716-446655440000"
36
+ * @see {@link https://tools.ietf.org/html/rfc4122 | RFC4122}
37
+ * @public
38
+ */
39
+ export type UUID = string;
40
+
41
+ /**
42
+ * Chain Agnostic Blockchain Identifier (CAIP-2)
43
+ * Represents a blockchain in a chain-agnostic way following the CAIP-2 specification.
44
+ * The identifier consists of a namespace and reference separated by a colon.
45
+ *
46
+ * Format: `namespace:reference`
47
+ * - namespace: Represents the blockchain namespace (e.g. 'eip155', 'bip122', 'cosmos')
48
+ * - reference: Chain-specific identifier within that namespace
49
+ *
50
+ * @example "eip155:1" // Ethereum Mainnet
51
+ * @example "bip122:000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" // Bitcoin Mainnet
52
+ * @example "cosmos:cosmoshub-3" // Cosmos Hub Mainnet
53
+ * @see {@link https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md | CAIP-2 Specification}
54
+ * @public
55
+ */
56
+ export type CAIP2 = `${string}:${string}`;
57
+
58
+ /**
59
+ * Chain Agnostic Account Identifier (CAIP-10)
60
+ * Represents an account/address on a specific blockchain following the CAIP-10 specification.
61
+ * Extends CAIP-2 by adding the account address specific to that chain.
62
+ *
63
+ * Format: `{caip2}:{address}`
64
+ * - caip2: The CAIP-2 chain identifier (e.g. 'eip155:1')
65
+ * - address: Chain-specific account address format
66
+ *
67
+ * @example "eip155:1:0x742d35Cc6634C0532925a3b844Bc454e4438f44e" // Ethereum account on mainnet
68
+ * @example "bip122:000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f:128Lkh3S7CkDTBZ8W7BbpsN3YYizJMp8p6" // Bitcoin account on mainnet
69
+ * @example "cosmos:cosmoshub-3:cosmos1t2uflqwqe0fsj0shcfkrvpukewcw40yjj6hdc0" // Cosmos account
70
+ * @see {@link https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md | CAIP-10 Specification}
71
+ * @public
72
+ */
73
+ export type CAIP10 = `${CAIP2}:${string}`;
74
+
75
+ /**
76
+ * Chain Agnostic Asset Identifier (CAIP-19)
77
+ * Represents an asset/token on a specific blockchain following the CAIP-19 specification.
78
+ * Extends CAIP-2 by adding asset type and identifier information.
79
+ *
80
+ * Format: `{caip2}/{asset_namespace}:{asset_reference}`
81
+ * - caip2: The CAIP-2 chain identifier (e.g. 'eip155:1')
82
+ * - asset_namespace: The asset standard (e.g. 'erc20', 'erc721', 'slip44')
83
+ * - asset_reference: Chain/standard-specific asset identifier
84
+ *
85
+ * @example "eip155:1/erc20:0x6b175474e89094c44da98b954eedeac495271d0f" // DAI token on Ethereum mainnet
86
+ * @example "eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d" // CryptoKitties NFT contract
87
+ * @example "cosmos:cosmoshub-3/slip44:118" // ATOM token on Cosmos Hub
88
+ * @see {@link https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-19.md | CAIP-19 Specification}
89
+ * @public
90
+ */
91
+ export type CAIP19 = `${CAIP2}/${string}:${string}`;
92
+
93
+ /**
94
+ * Chain Agnostic Payload Identifier
95
+ * @public
96
+ */
97
+ export type CAIP220 = string;
98
+
99
+ /**
100
+ * Digital Token Identifier (DTI) following ISO 24165 standard
101
+ *
102
+ * @remarks
103
+ * A standardized identifier for digital assets and cryptocurrencies. The DTI system
104
+ * provides unique and unambiguous identification of digital tokens, supporting interoperability
105
+ * and clarity in financial markets.
106
+ *
107
+ * Format: `DTI[NNNNN]` where N is a digit
108
+ *
109
+ * @example "DTI00001" // Example DTI for Bitcoin
110
+ * @example "DTI00002" // Example DTI for Ethereum
111
+ *
112
+ * @see {@link https://dtif.org/ | Digital Token Identifier Foundation}
113
+ * @see {@link https://www.iso.org/standard/77895.html | ISO 24165}
114
+ * @public
115
+ */
116
+
117
+ export type DTI = string;
118
+
119
+ /**
120
+ * Notabene Asset Identifier
121
+ * @public
122
+ */
123
+
124
+ /**
125
+ * Internal identifier for assets in the Notabene system
126
+ *
127
+ * @remarks
128
+ * A standardized string format used within Notabene to identify cryptocurrencies,
129
+ * tokens, and other digital assets. This is Notabene's legacy asset identification
130
+ * system that may be used alongside CAIP-19 and DTI identifiers.
131
+ *
132
+ * @example "ETH_USDT" // USDT token on Ethereum
133
+ * @example "BTC" // Bitcoin
134
+ * @see {@link CAIP19} For chain-agnostic asset identifiers
135
+ * @see {@link DTI} For ISO standardized identifiers
136
+ * @public
137
+ */
138
+
139
+ export type NotabeneAsset = string;
140
+
141
+ /**
142
+ * The asset of a transaction either a Notabene asset, a CAIP-19 asset, or a DTI.
143
+ * @public
144
+ */
145
+ export type TransactionAsset = NotabeneAsset | CAIP19 | DTI;
146
+
147
+ /**
148
+ * A blockchain address
149
+ * @public
150
+ */
151
+
152
+ /**
153
+ * A native blockchain address string
154
+ *
155
+ * @remarks
156
+ * Represents a blockchain address in the native format specific to a particular chain.
157
+ * This could be an Ethereum address, Bitcoin address, or other chain-specific format.
158
+ * The address format and validation rules depend on the underlying blockchain.
159
+ *
160
+ * @example "0x742d35Cc6634C0532925a3b844Bc454e4438f44e" // Ethereum address
161
+ * @example "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa" // Bitcoin address
162
+ * @example "cosmos1t2uflqwqe0fsj0shcfkrvpukewcw40yjj6hdc0" // Cosmos address
163
+ * @public
164
+ */
165
+
166
+ export type BlockchainAddress = string;
167
+
168
+ /**
169
+ * A travel address
170
+ * @public
171
+
172
+ * A standardized travel rule address format
173
+ *
174
+ * @remarks
175
+ * Represents a special address format used for travel rule compliance. Travel addresses
176
+ * are prefixed with 'ta' and contain encoded information about the transaction
177
+ * and counterparty details required for travel rule reporting.
178
+ *
179
+ * The format ensures consistent handling of travel rule data across different
180
+ * VASPs and blockchain networks while maintaining privacy.
181
+ *
182
+ * @example "ta1234abcd..." // Example travel rule address
183
+ * @see {@link BlockchainAddress} For native chain addresses
184
+ * @see {@link CAIP10} For chain-agnostic addresses
185
+
186
+ */ export type TravelAddress = `ta${string}`;
187
+
188
+ /**
189
+ * A crypto credential
190
+ * @public
191
+ */ export type CryptoCredential = `${string}.${string}.mastercard`;
192
+
193
+ /**
194
+ * The destination of a transaction either a blockchain address, a CAIP-19 address, or a travel address.
195
+ * @public
196
+ */
197
+ export type Destination =
198
+ | BlockchainAddress
199
+ | CAIP10
200
+ | CryptoCredential
201
+ | TravelAddress;
202
+
203
+ /**
204
+ * The source of a transaction
205
+ * @public
206
+ */
207
+ export type Source = BlockchainAddress | CAIP10;
208
+
209
+ /**
210
+ * A Uniform Resource Identifier
211
+ * @public
212
+ */
213
+ export type URI = string;
214
+
215
+ /**
216
+ * A Decentralized Identifier
217
+ * @public
218
+ */
219
+ export type DID = `did:${string}:${string}`;
220
+
221
+ /**
222
+ * A LEI Legal Entity Identifier
223
+ * @public
224
+ */
225
+ export type LEI = string;
226
+
227
+ /**
228
+ * 3 letter ISO currency code
229
+ * @public
230
+ */
231
+ export type ISOCurrency = string;
232
+
233
+ /**
234
+ * The theme of the Notabene SDK
235
+ * @public
236
+ */
3
237
  export type Theme = {
4
238
  primaryColor: string;
5
239
  secondaryColor: string;
@@ -7,109 +241,865 @@ export type Theme = {
7
241
  logo: string;
8
242
  };
9
243
 
10
- export enum WidgetType {
11
- WITHDRAWAL = 'WITHDRAWAL',
12
- POST_DEPOSIT = 'POST_DEPOSIT',
244
+ /**
245
+ * The type of Agent. Either a wallet or a VASP
246
+ * @public
247
+ */
248
+ export enum AgentType {
249
+ PRIVATE = 'WALLET',
250
+ VASP = 'VASP',
13
251
  }
14
252
 
15
- export type TransactionTypeAllowed =
16
- | 'ALL'
17
- | 'VASP_2_VASP_ONLY'
18
- | 'SELF_TRANSACTION_ONLY';
253
+ /**
254
+ * Who is the agent acting on behalf of the counterparty
255
+ * @public
256
+ */
257
+ export interface Agent {
258
+ did: DID;
259
+ type: AgentType;
260
+ logo?: URI;
261
+ url?: URI;
262
+ name?: string;
263
+ verified?: boolean;
264
+ }
19
265
 
20
- export type NonCustodialDeclarationType =
21
- | 'SIGNATURE'
22
- | 'DECLARATION'
23
- | 'SIGNATURE_AND_DECLARATION';
266
+ /**
267
+ * 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.
268
+ * @public
269
+ */
270
+ /**
271
+ * Enum defining the types of persons/entities in a transaction
272
+ *
273
+ * @remarks
274
+ * This classification system aligns with FATF travel rule requirements and defines:
275
+ * - NATURAL: Individual human persons acting in their own capacity
276
+ * - LEGAL: Registered organizations, companies, or other legal entities
277
+ * - SELF: When the counterparty is the same as the customer (first party transaction)
278
+ *
279
+ * The type affects what information must be collected and transmitted as part of
280
+ * travel rule compliance. Different verification and due diligence requirements
281
+ * apply to each type.
282
+ *
283
+ * @see {@link NaturalPerson} For natural person data requirements
284
+ * @see {@link LegalPerson} For legal person data requirements
285
+ * @public
286
+ */
287
+ export enum PersonType {
288
+ NATURAL = 'natural',
289
+ LEGAL = 'legal',
290
+ SELF = 'self', // first party
291
+ }
24
292
 
25
- export type OwnershipProofInput = {
26
- type?: string | null;
27
- proof?: string | null;
28
- };
293
+ /**
294
+ * A VASP agent acting on behalf of the counterparty
295
+ * @public
296
+ */
297
+ export interface VASP extends Agent {
298
+ lei?: LEI;
299
+ logo?: URI;
300
+ website?: URI;
301
+ countryOfRegistration?: ISOCountryCode;
302
+ }
29
303
 
30
- export type TransactionBlockchainInfo = {
31
- destination?: string | null;
32
- origin?: string | null;
304
+ /**
305
+ * A wallet agent acting on behalf of the counterparty
306
+ * @public
307
+ */
308
+ export interface Wallet extends Agent {
309
+ proof: OwnershipProof;
310
+ wallet_connect_id?: string;
311
+ }
312
+
313
+ /**
314
+ * The counterparty of a transaction.
315
+ * @public
316
+ */
317
+ /**
318
+ * Interface representing a party involved in a transaction other than the initiator
319
+ *
320
+ * @remarks
321
+ fines the core properties that identify and describe a counterparty:
322
+ * - name: The display or legal name of the counterparty
323
+ * - accountNumber: An account identifier/reference number
324
+ * - did: Decentralized identifier for the counterparty
325
+ * - type: Classification as natural person, legal entity, or self
326
+ * - verified: Whether the counterparty's identity has been verified
327
+ * - geographicAddress: Physical/mailing address information
328
+ * - nationalIdentification: Government-issued ID details
329
+ * - website: Official web presence
330
+ * - phone: Contact phone number
331
+ * - email: Contact email address
332
+ *
333
+ * This interface serves as the base for more specific counterparty types:
334
+ * @see {@link NaturalPerson} For individual person properties
335
+ * @see {@link LegalPerson} For organization/entity properties
336
+ *
337
+ * @public
338
+ */
339
+ export interface Counterparty {
340
+ name?: string;
341
+ accountNumber?: string;
342
+ did?: DID;
343
+ type?: PersonType;
344
+ verified?: boolean;
345
+ geographicAddress?: Address;
346
+ nationalIdentification?: NationalIdentification;
347
+ website?: URI;
348
+ phone?: string;
349
+ email?: string;
350
+ }
351
+
352
+ /**
353
+ * Interface representing a natural person (individual) involved in a transaction
354
+ *
355
+ * @remarks
356
+ * Extends the baseinterface to add properties specific to individual persons:
357
+ * - type: Must be PersonType.NATURAL to identify as an individual
358
+ * - dateOfBirth: Optional ISO format birth date for identity verification
359
+ * - placeOfBirth: Optional birth place for identity verification
360
+ * - countryOfResidence: Optional ISO country code of current residence
361
+ * - name: Required full legal name of the individual
362
+ *
363
+ * This interface captures the additional identifying information required for
364
+ * natural persons under FATF Travel Rule requirements. The properties align
365
+ * with standard KYC (Know Your Customer) data collection practices.
366
+ *
367
+ * @see {@link Counterparty} For base properties common to all counterparties
368
+ * @see {@link PersonType} For person type classification
369
+ * @public
370
+ */
371
+ export interface NaturalPerson extends Counterparty {
372
+ type: PersonType.NATURAL;
373
+ dateOfBirth?: ISODate;
374
+ placeOfBirth?: string;
375
+ countryOfResidence?: ISOCountryCode;
376
+ name: string;
377
+ }
378
+ /**
379
+ * Field names for NaturalPerson
380
+ * @public
381
+ */
382
+ export type NaturalPersonFieldName =
383
+ | 'name' // Full legal name
384
+ | 'website' // Primary website of entity
385
+ | 'email' // Contact email
386
+ | 'phone' // Contact mobile phone
387
+ | 'geographicAddress' // Address string
388
+ | 'nationalIdentification' // National Identification number
389
+ | 'dateOfBirth' // Date of Birty YYYY-MM-DD
390
+ | 'placeOfBirth' // Place of Birth
391
+ | 'countryOfResidence'; // ISO Country code of residence of Natural Person
392
+
393
+ /**
394
+ * Field properties by field name for Natural persons
395
+ * @public
396
+ */
397
+ export type NaturalPersonFields = {
398
+ [name in NaturalPersonFieldName]?: FieldOptions;
33
399
  };
34
400
 
35
- export type CountryType = {
36
- id: string;
401
+ /**
402
+ * Interface representing a legal entity (organization/company) involved in a transaction
403
+ *
404
+ * @remarks
405
+ * Extends the baseface to add properties specific to legal entities:
406
+ * - type: MustPersonType.LEGAL to identify as an organization
407
+ * - name: Required registered legal name of the entity
408
+ * - lei: Optional Legal Entity Identifier for regulated entities
409
+ * - logo: Optional URI to the organization's logo image
410
+ * - countryOfRegistration: Optional ISO country code where entity is registered
411
+ *
412
+ * This interface captures the additional identifying information required for
413
+ * legal persons under FATF Travel Rule requirements. The properties align with
414
+ * standard business KYC (Know Your Businessta collection practices.
415
+ *
416
+ * @see {@link Counterparty} For base properties common to all counterparties
417
+ * @see {@link PersonType} For person type classification
418
+ * @see {@link LEI} For Legal Entity Identifier format
419
+ * @public
420
+ */
421
+ export interface LegalPerson extends Counterparty {
422
+ type: PersonType.LEGAL;
37
423
  name: string;
424
+ lei?: LEI;
425
+ logo?: URI;
426
+ countryOfRegistration?: ISOCountryCode;
427
+ }
428
+
429
+ export type LegalPersonFieldName =
430
+ | 'name' // Full legal name
431
+ | 'lei' // Legal Entity Identifier
432
+ | 'website' // Primary website of entity
433
+ | 'email' // Contact email
434
+ | 'phone' // Contact mobile phone
435
+ | 'geographicAddress' // Address string
436
+ | 'nationalIdentification' // National Identification number
437
+ | 'countryOfRegistration'; // ISO Country code of registration of Legal Person
438
+
439
+ /**
440
+ * Field properties by field name
441
+ * @public
442
+ */
443
+ export type LegalPersonFields = {
444
+ [name in LegalPersonFieldName]?: FieldOptions;
445
+ };
446
+
447
+ /**
448
+ * Fields specific to the originator of a transaction
449
+ * @public
450
+ */
451
+ type OriginatorFields = {
452
+ source?: Source;
453
+ };
454
+
455
+ /**
456
+ * Fields specific to the beneficiary of a transaction
457
+ * @public
458
+ */
459
+ type BeneficiaryFields = {
460
+ destination?: Destination;
461
+ };
462
+
463
+ /**
464
+ * Fields specific to a deposit request
465
+ * @public
466
+ */
467
+ type DepositRequestFields = {
468
+ destination: BlockchainAddress | CAIP10;
469
+ asset: TransactionAsset;
470
+ amountDecimal?: number;
471
+ travelAddress?: TravelAddress;
472
+ cryptoCredential?: CryptoCredential;
473
+ };
474
+
475
+ type RequestID = UUID;
476
+
477
+ /**
478
+ * Base interface for requests sent to SDK components
479
+ *
480
+ * @remarks
481
+ * Defines core properties that all component requests share:
482
+ * - Optional unique request ID for tracking/correlating requests and responses
483
+ * - Optional customer detailsfor pre-filling component data
484
+ *
485
+ * This interface is extended by specific request types like:
486
+ * - Transaction requests for sending/receiving assets
487
+ * - Connection requests for establishing VASP to VASP communication
488
+ *
489
+ * @see {@link Transaction} For transaction-specific request properties
490
+ * @see {@link ConnectionRequest} For connection-specific request properties
491
+ * @public
492
+ */
493
+ export interface ComponentRequest {
494
+ requestId?: RequestID;
495
+ customer?: Counterparty;
496
+ }
497
+
498
+ /**
499
+ * Core transaction interface representing a crypto asset transfer between parties
500
+ *
501
+ * @remarks
502
+ * Extends ComponentRequest to add transaction-specific properties:
503
+ * - agent: The entity facilitating/executing the transaction
504
+ * - counterparty: The other party involved in the transaction
505
+ * - asset: The cryptocurrency or token being transferred
506
+ * - amountDecimal: The amount to transfer in decimal format
507
+ * - proof: Optional ownership proof verifying control of involved addresses
508
+ * - assetPrice: Optional price information in a fiat currency
509
+ *
510
+ * This interface serves as the base for specific transaction types like:
511
+ * - Withdrawals for sending assets out
512
+ * - Deposits for receiving assets
513
+ * - Deposit requests for requesting asset transfers
514
+ *
515
+ * @see {@link Withdrawal} For withdrawal-specific transaction properties
516
+ * @see {@link Deposit} For deposit-specific transaction properties
517
+ * @see {@link Agent} For agent details
518
+ * @see {@link Counterparty} For counterparty information
519
+ * @public
520
+ */
521
+ export interface Transaction extends ComponentRequest {
522
+ agent: Agent;
523
+ counterparty: Counterparty;
524
+ asset: TransactionAsset;
525
+ amountDecimal: number;
526
+ proof?: OwnershipProof;
527
+ assetPrice?: {
528
+ price: number;
529
+ currency: ISOCurrency;
530
+ };
531
+ }
532
+
533
+ /**
534
+ * An object representing a withdrawal transaction
535
+ * @public
536
+ */
537
+ export interface Withdrawal extends BeneficiaryFields, Transaction {}
538
+
539
+ /**
540
+ * An object representing a deposit transaction
541
+ * @public
542
+ */
543
+ export interface Deposit extends OriginatorFields, Transaction {}
544
+
545
+ /**
546
+ * An object representing a request for a deposit
547
+ * @public
548
+ */
549
+ export interface DepositRequest
550
+ extends DepositRequestFields,
551
+ ComponentRequest {}
552
+
553
+ /**
554
+ * An object representing options for a Deposit Request
555
+ * @public
556
+ */
557
+ export interface DepositRequestOptions {
558
+ showQrCode?: boolean; // Defaults to true
559
+ }
560
+
561
+ /**
562
+ * An object representing a connection request
563
+ * @public
564
+ */
565
+ export interface ConnectionRequest extends ComponentRequest {
566
+ asset: TransactionAsset;
567
+ }
568
+
569
+ /**
570
+ * An object representing options for a Connection Request
571
+ * @public
572
+ */
573
+
574
+ export type ConnectionOptions = Omit<
575
+ TransactionOptions,
576
+ 'allowedAgentTypes' | 'allowedCounterpartyTypes' | 'vasps' | 'fields' | 'hide'
577
+ >;
578
+
579
+ /**
580
+ * The verification status of a transaction
581
+ * @public
582
+ */
583
+ export enum Status {
584
+ EMPTY = 'empty',
585
+ VERIFY = 'verify',
586
+ PENDING = 'pending',
587
+ VERIFIED = 'verified',
588
+ BANNED = 'banned',
589
+ }
590
+
591
+ /**
592
+ * Represents a legacy V1 API asset format supporting both Notabene and CAIP-19 identifiers
593
+ *
594
+ * @remarks
595
+ * Used for backwards compatibility with V1 API transaction payloads:
596
+ * - Can be either a simple Notabene asset string
597
+ * - Or an object containing a CAIP-19 identifier
598
+ *
599
+ * @example "ETH_USDT" // Notabene asset format
600
+ * @example \{ caip19: "eip155:1/erc20:0x6b175474e89094c44da98b954eedeac495271d0f" \} // CAIP-19 format
601
+ * @see {@link NotabeneAsset} For Notabene asset format
602
+ * @see {@link CAIP19} For CAIP-19 asset format
603
+ * @public
604
+ */
605
+ export type V1Asset = NotabeneAsset | { caip19: CAIP19 };
606
+
607
+ /**
608
+ * Transaction payload suitable for calling Notabene v1 tx/create
609
+ * @public
610
+ */
611
+ export type V1Transaction = {
612
+ transactionAsset: V1Asset;
613
+ transactionAmount: string;
614
+ originatorEqualsBeneficiary?: boolean;
615
+ originatorVASPdid: DID;
616
+ beneficiaryVASPdid: DID;
617
+ beneficiaryProof?: OwnershipProof;
618
+ originator?: Originator;
619
+ beneficiary: Beneficiary;
38
620
  };
39
621
 
40
- export type PersonType = 'natural' | 'legal';
622
+ /**
623
+ * Base response interface for all SDK component operations
624
+ *
625
+ * @remarks
626
+ * Provides standardized response propertiesfor component interactions:
627
+ * - requestID: Links response back to the originating request
628
+ * - valid: Boolean indicating if the operation was valid/successful
629
+ * - status: Current verification status of the operation
630
+ * - errors: Array of validation errors if any occurred
631
+ *
632
+ * This interface is extended by specific response types like:
633
+ * - TransResponse for transaction operations
634
+ * - ConnectionResponse for VASP connection operations
635
+ *
636
+ * @see {@link Status} For possible status values
637
+ * @see {@link ValidationError} For error structure
638
+ * @see {@link TransactionResponse} For transaction-specific responses
639
+ * @public
640
+ */
641
+ export interface ComponentResponse {
642
+ requestID: RequestID;
643
+ valid: boolean;
644
+ status: Status;
645
+ errors: ValidationError[];
646
+ }
647
+
648
+ /**
649
+ * Response interface for transaction-related operations
650
+ *
651
+ * @remarks
652
+ * Extends ComponentResponse to add transaction-specific response data:
653
+ * - value: The resulting transaction value of generic type V
654
+ * - ivms101: IVMS 101 travel rule data for the transaction
655
+ * - proof: Optional ownership proof details if required
656
+ * - txCreate: Optional V1 transaction payload for legacy API compatibility
657
+ *
658
+ * @typeParam V - Type of the transaction value being returned
659
+ *
660
+ * @see {@link ComponentResponse} For base response properties
661
+ * @see {@link IVMS101} For travel rule data structure
662
+ * @see {@link OwnershipProof} For proof details
663
+ * @see {@link V1Transaction} For legacy transaction format
664
+ * @public
665
+ */
666
+ export interface TransactionResponse<V> extends ComponentResponse {
667
+ value: V;
668
+ ivms101: IVMS101;
669
+ proof?: OwnershipProof;
670
+ txCreate?: V1Transaction;
671
+ }
41
672
 
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;
673
+ /**
674
+ * Validation error
675
+ * @public
676
+ */
677
+ export type ValidationError = {
678
+ attribute: string;
679
+ message: string;
52
680
  };
53
681
 
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;
682
+ /**
683
+ * Field properties
684
+ * @public
685
+ */
686
+ export type FieldOptions =
687
+ | boolean
688
+ | {
689
+ optional: boolean; // Shown but optional
690
+ transmit: boolean; // Transmit as part of IVMS 101 to counterparty
691
+ };
692
+
693
+ /**
694
+ * Field type configuration
695
+ * @public
696
+ */
697
+
698
+ export type FieldTypes = {
699
+ naturalPerson?: NaturalPersonFields;
700
+ legalPerson?: LegalPersonFields;
64
701
  };
65
702
 
66
- export type CAIP19 = {
67
- caip19: string;
703
+ /**
704
+ * Options for which VASPs to be searchable
705
+ * @public
706
+ */
707
+ export type VASPOptions = {
708
+ addUnknown?: boolean;
709
+ onlyActive?: boolean;
68
710
  };
69
711
 
70
- export type CoingeckoIdAndNetwork = { coingeckoId: string; network: string };
712
+ /**
713
+ * Sections in a WithdrawalAssist screen
714
+ *
715
+ * @alpha
716
+ */
717
+ export enum ValidationSections {
718
+ ASSET = 'asset',
719
+ DESTINATION = 'destination',
720
+ COUNTERPARTY = 'counterparty',
721
+ AGENT = 'agent',
722
+ }
723
+ /**
724
+ * Specify what to do under the provided threshold.
725
+ *
726
+ * Eg. to allow self-declaration for all transactions under 1000 EUR
727
+ *
728
+ * Note to support threshold you MUST include the Asset Price in the Transaction
729
+ *
730
+ * @see {@link Transaction} Transaction object
731
+ *
732
+ * @public
733
+ */
71
734
 
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;
735
+ export interface ThresholdOptions {
736
+ threshold: number; // The threshold amount eg 1000
737
+ currency: ISOCurrency; // Currency of threshold
738
+ proofTypes?: ProofTypes[]; // If left empty no proof will be required under threshold
739
+ }
740
+ /**
741
+ * Configuration options for Transaction components
742
+ * @public
743
+ */
744
+ export interface TransactionOptions {
745
+ proofs?: {
746
+ microTransfer?: {
747
+ destination: BlockchainAddress;
748
+ amountSubunits: string;
749
+ timeout?: number; // Time to verify in seconds
81
750
  };
82
- isNonCustodial?: boolean;
83
- originatorEqualsBeneficiary?: boolean;
84
- beneficiaryProof?: OwnershipProofInput;
85
- originatorProof?: OwnershipProofInput;
86
- isValid?: boolean;
87
- errors?: string[];
751
+ fallbacks?: ProofTypes[];
752
+ deminimis?: ThresholdOptions;
88
753
  };
754
+ allowedAgentTypes?: AgentType[]; // Defaults to All
755
+ allowedCounterpartyTypes?: PersonType[]; // Defaults to All
756
+ fields?: FieldTypes;
757
+ vasps?: VASPOptions;
758
+ hide?: ValidationSections[]; // You can hide a specific section of the component by listing it here
759
+ }
760
+ /**
761
+ * Component Message Type enum representing different message types that can be sent
762
+ * between the host and component.
763
+ *
764
+ * @remarks
765
+ * - COMPLETE: Indicates a completed operation with response data
766
+ * - RESIZE: Request to adjust component size/dimensions
767
+ * - RESULT: Operation result notification
768
+ * - READY: Component is initialized and ready
769
+ * - INVALID: Validation failed with errors
770
+ * - ERROR: Operation encountered an error
771
+ * - CANCEL: Operation was cancelled
772
+ * @public
773
+ */
774
+ export const enum CMType {
775
+ COMPLETE = 'complete',
776
+ RESIZE = 'resize',
777
+ RESULT = 'result',
778
+ READY = 'ready',
779
+ INVALID = 'invalid',
780
+ ERROR = 'error',
781
+ CANCEL = 'cancel',
782
+ }
783
+
784
+ /**
785
+ * Represents a completed component message
786
+ * @typeParam T - The overall Value type being returned
787
+ * @param response - The Response object which wraps T
788
+ * @public
789
+ */
790
+ export type Completed<T> = {
791
+ type: CMType.COMPLETE;
792
+ response: TransactionResponse<T>;
793
+ };
89
794
 
90
- export type FieldProps = {
91
- forceDisplay?: boolean; // instead of beneficiaryDetails - defaults to false
92
- optional?: boolean; // bypass the jurisdiction rules validation - defaults to false
795
+ /**
796
+ * Represents a ready component message
797
+ * @public
798
+ */
799
+ export type Ready = {
800
+ type: CMType.READY;
93
801
  };
94
802
 
95
- export type FieldName =
96
- | 'counterparty'
97
- | 'geographicAddress'
98
- | 'firstName'
99
- | 'name'
100
- | 'nationalIdentification'
101
- | 'dateAndPlaceOfBirth';
803
+ /**
804
+ * Represents a resize request component message. This is handled by the library.
805
+ * @internal
806
+ */
807
+ export type ResizeRequest = {
808
+ type: CMType.RESIZE;
809
+ height: number;
810
+ };
811
+
812
+ /**
813
+ * Represents an error component message
814
+ * @param message - Error message
815
+ * @public
816
+ */
817
+ export type Error = {
818
+ type: CMType.ERROR;
819
+ message: string;
820
+ };
102
821
 
103
- export type FieldsProps = {
104
- [name in FieldName]?: FieldProps;
822
+ /**
823
+ * Represents a cancel component message
824
+ * @internal
825
+ */
826
+ export type Cancel = {
827
+ type: CMType.CANCEL;
105
828
  };
106
829
 
107
- type WalletNotSupportedFlow = {
108
- flow: 'WALLET_NOT_SUPPORTED';
109
- action: 'DECLARATION' | 'REJECT';
830
+ /**
831
+ * Represents an invalid value component message
832
+ * @typeParam T - The overall Value type being returned
833
+ * @param value - The current Partial value
834
+ * @param errors - Array of validation errors
835
+ * @internal
836
+ */
837
+ export type InvalidValue<T> = {
838
+ type: CMType.INVALID;
839
+ value: Partial<T>;
840
+ errors: ValidationError[];
110
841
  };
111
842
 
112
- // This is going to be union type
113
- export type Fallback = WalletNotSupportedFlow;
843
+ /**
844
+ * Union type representing all possible messages that can be sent from a component
845
+ *
846
+ * @remarks
847
+ * Components communicate their state and results back to the host application
848
+ * through these message types:
849
+ * - Completed: Operation finished successfully with response data
850
+ * - Cancel: User cancelled the operation
851
+ * - Error: Operation failed with error message
852
+ * - Ready: Component initialized and ready for use
853
+ * - ResizeRequest: Component needs to adjust its dimensions
854
+ * - InvalidValue: Validation failed with current partial value
855
+ *
856
+ * @typeParam T - The value type that will be returned in Completed messages
857
+ *
858
+ * @see {@link Completed} For successful completion message format
859
+ * @see {@link Cancel} For cancellation message format
860
+ * @see {@link Error} For error message format
861
+ * @see {@link Ready} For ready message format
862
+ * @see {@link ResizeRequest} For resize message format
863
+ * @see {@link InvalidValue} For validation failure message format
864
+ * @public
865
+ */
866
+ export type ComponentMessage<T> =
867
+ | Completed<T>
868
+ | Cancel
869
+ | Error
870
+ | Ready
871
+ | ResizeRequest
872
+ | InvalidValue<T>;
873
+
874
+ /**
875
+ * Host Message Type enum representing different message types that can be sent
876
+ * from the host application.
877
+ *
878
+ * @remarks
879
+ * - UPDATE: Message to update component value/state
880
+ * - REQUEST_RESPONSE: Message requesting a response from component
881
+ * @public
882
+ */
883
+ export const enum HMType {
884
+ UPDATE = 'update',
885
+ REQUEST_RESPONSE = 'requestResponse',
886
+ }
887
+
888
+ /**
889
+ * Message type for updating component state and configuration from host application
890
+ *
891
+ * @remarks
892
+ * Defines the structure of update messages sent from host to component:
893
+ * - type: Identifies this as an update message
894
+ * - value: New partial state/data to update the component with
895
+ * - options: Optional configuration parameters to modify component behavior
896
+ *
897
+ * The host can use this to dynamically update both the component's data
898
+ * and its configuration without requiring a full reload/reinitialize.
899
+ *
900
+ * @typeParam T - The type of the value being updated
901
+ * @typeParam O - The type of the optional configuration parameters
902
+ *
903
+ * @see {@link HMType} For message type constants
904
+ * @see {@link HostMessage} For full host message type union
905
+ * @public
906
+ */
907
+ export type UpdateValue<T, O> = {
908
+ type: HMType.UPDATE;
909
+ value: Partial<T>;
910
+ options?: O;
911
+ };
912
+
913
+ /**
914
+ * Union type representing all possible messages that can be sent from the host application
915
+ * to a component
916
+ *
917
+ * @remarks
918
+ * Currently only supports update messages which allow the host to modify component
919
+ * and configuration. The host uses these messages to communicate changes to the component
920
+ * without requiring full reinitialization.
921
+ *
922
+ * @typeParam T - The value type that components operate on
923
+ * @typeParam O - The options type used to configure component behavior
924
+ *
925
+ * @see {@link UpdateValue} For the structure of update messages
926
+ * @see {@link HMType} For message type constants
927
+ * @public
928
+ */
929
+ export type HostMessage<T, O> = UpdateValue<T, O>;
930
+
931
+ /**
932
+ * Options for callback and redirect URIs
933
+ * @public
934
+ */
935
+ export interface CallbackOptions {
936
+ callback?: URI;
937
+ redirectUri?: URI;
938
+ }
939
+
940
+ /**
941
+ * Status of the ownership proof verification process
942
+ *
943
+ * @remarks
944
+ * Represents the different states that an ownership proof can be in during and after verification:
945
+ * - PENDING: Initial state where verification is in progress or awaiting processing
946
+ * - FAILED: The proof was rejected due to failing verification checks
947
+ * - FLAGGED: The proof requires manual review due to suspicious or unclear verification results
948
+ * - VERIFIED: The proof has passed all verification checks successfully
949
+ *
950
+ * @public
951
+ */
952
+ export enum ProofStatus {
953
+ PENDING = 'pending', // Verification is pending
954
+ FAILED = 'rejected', // Rejected
955
+ FLAGGED = 'flagged', // Flagged for manual review
956
+ VERIFIED = 'verified', // Verified
957
+ }
958
+
959
+ /**
960
+ * Types of ownership proofs supported by the system
961
+ *
962
+ * @remarks
963
+ * Supported proof types:
964
+ * - SelfDeclaration: User self-declares ownership without cryptographic proof
965
+ * - EIP191: Ethereum personal signature following EIP-191 standard
966
+ * - SIWE: Sign-In with Ethereum message signature (EIP-4361)
967
+ * - EIP712: Ethereum typed data signature following EIP-712 standard
968
+ * - BIP137: Bitcoin message signature following BIP-137
969
+ * - XPUB: Extended public key signature for HD wallets
970
+ * - MicroTransfer: Proof via small blockchain transaction
971
+ * - Screenshot: Image proof of ownership/access
972
+ *
973
+ * @see {@link SignatureProof} For signature-based proofs
974
+ * @see {@link DeclarationProof} For self-declaration proofs
975
+ * @see {@link MicroTransferProof} For transaction-based proofs
976
+ * @see {@link ScreenshotProof} For screenshot proofs
977
+ * @public
978
+ */
979
+ export enum ProofTypes {
980
+ SelfDeclaration = 'self-declaration',
981
+ SIWE = 'siwe',
982
+ SIWX = 'siwx',
983
+ EIP191 = 'eip-191',
984
+ EIP712 = 'eip-712',
985
+ EIP1271 = 'eip-1271',
986
+ BIP137 = 'bip-137',
987
+ BIP137_XPUB = 'xpub',
988
+ ED25519 = 'ed25519',
989
+ MicroTransfer = 'microtransfer',
990
+ Screenshot = 'screenshot',
991
+ Connect = 'connect',
992
+ }
993
+
994
+ /**
995
+ * Base interface for proving ownership of an account or address
996
+ *
997
+ * @remarks
998
+ * TheOwnershipProof interface provides a common structure for different types of ownership verification:
999
+ * - All proofs must specify their type from the supported ProofTypes enum
1000
+ * - Current verification status is tracked via ProofStatus
1001
+ * - Links the proof to a decentralized identifier (DID)
1002
+ * - Specifies the blockchain account/address being proven using CAIP-10 format
1003
+ *
1004
+ * This interface is extended by specific proof types like:
1005
+ * - SignatureProof for cryptographic signatures
1006
+ * - DeclarationProof for self-declarations
1007
+ * - MicroTransferProof for transaction-based proof
1008
+ * - ScreenshotProof for image-based verification
1009
+ *
1010
+ * @see {@link ProofTypes} For supported proof methods
1011
+ * @see {@link ProofStatus} For possible verification states
1012
+ * @see {@link CAIP10} For address format specification
1013
+ * @public
1014
+ */
1015
+ export interface OwnershipProof {
1016
+ type: ProofTypes;
1017
+ status: ProofStatus;
1018
+ did: DID;
1019
+ address: CAIP10;
1020
+ }
1021
+
1022
+ /**
1023
+ * Interface for signature-based ownership proofs that use cryptographic message signing
1024
+ *
1025
+ * @remarks
1026
+ * Extends the base OwnershipProface to add signature-specific properties:
1027
+ * - Supports multiple signature standards like EIP-191, EIP-712, BIP-137, SIWE
1028
+ * - Includes the cryptographic proof signature string
1029
+ * - Contains an attestation message that was signed
1030
+ * - Records which wallet provider was used for signing
1031
+ *
1032
+ * The signature proves ownership by demonstrating control of the private keys
1033
+ * associated with the claimed address.
1034
+ *
1035
+ * @see {@link ProofTypes} For supported signature types
1036
+ * @see {@link OwnershipProof} For base proof properties
1037
+ * @public
1038
+ */
1039
+ export interface SignatureProof extends OwnershipProof {
1040
+ type:
1041
+ | ProofTypes.EIP191
1042
+ | ProofTypes.EIP712
1043
+ | ProofTypes.EIP1271
1044
+ | ProofTypes.BIP137
1045
+ | ProofTypes.BIP137_XPUB
1046
+ | ProofTypes.ED25519
1047
+ | ProofTypes.SIWX
1048
+ | ProofTypes.SIWE;
114
1049
 
115
- export type OptInFeature = 'REUSE_ADDRESS_OWNERSHIP_PROOF';
1050
+ proof: string;
1051
+ attestation: string;
1052
+ wallet_provider: string;
1053
+ }
1054
+
1055
+ /**
1056
+ * Ownership Proof using Self Declaration
1057
+ * @public
1058
+ */
1059
+ export interface DeclarationProof extends OwnershipProof {
1060
+ type: ProofTypes.SelfDeclaration;
1061
+ attestation: string;
1062
+ confirmed: boolean;
1063
+ }
1064
+
1065
+ /**
1066
+ * Interface for recording that user connected their wallet.
1067
+ *
1068
+ * @remarks
1069
+ * - Records which wallet provider was used to connect
1070
+ *
1071
+ * The signature proves ownership by demonstrating control of the private keys
1072
+ * associated with the claimed address.
1073
+ *
1074
+ * @see {@link ProofTypes} For supported signature types
1075
+ * @see {@link OwnershipProof} For base proof properties
1076
+ * @public
1077
+ */
1078
+ export interface ConnectionRecord extends OwnershipProof {
1079
+ type: ProofTypes.Connect;
1080
+ proof: string;
1081
+ attestation: string;
1082
+ wallet_provider: string;
1083
+ }
1084
+
1085
+ /**
1086
+ * Ownership Proof using Micro Transfer
1087
+ * @public
1088
+ */
1089
+ export interface MicroTransferProof extends OwnershipProof {
1090
+ type: ProofTypes.MicroTransfer;
1091
+ proof: string;
1092
+ chain: CAIP2;
1093
+ asset: CAIP19;
1094
+ destination: BlockchainAddress;
1095
+ amountSubunits: string;
1096
+ }
1097
+
1098
+ /**
1099
+ * Ownership Proof using Screenshot
1100
+ * @public
1101
+ */
1102
+ export interface ScreenshotProof extends OwnershipProof {
1103
+ type: ProofTypes.Screenshot;
1104
+ url: string;
1105
+ }