@notabene/javascript-sdk 2.0.0-next.9 → 2.0.1
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/LICENSE.md +21 -0
- package/README.md +477 -111
- package/dist/js/notabene.js +1 -0
- package/dist/notabene.cjs +1 -1
- package/dist/notabene.js +286 -110
- package/package.json +34 -25
- package/src/__tests__/notabene.test.ts +113 -2
- package/src/arbitraries.ts +0 -13
- package/src/components/EmbeddedComponent.ts +125 -63
- package/src/components/__tests__/EmbeddedComponent.test.ts +402 -32
- package/src/ivms/types.ts +177 -140
- package/src/locales.ts +48 -0
- package/src/notabene.ts +199 -63
- package/src/types.ts +773 -150
- package/src/utils/MessageEventManager.ts +70 -9
- package/src/utils/__tests__/MessageEventManager.test.ts +29 -5
- package/src/utils/__tests__/urls.test.ts +112 -0
- package/src/utils/arbitraries.ts +219 -1
- package/src/utils/urls.ts +30 -5
- package/dist/notabene.d.ts +0 -780
- package/dist/tsdoc-metadata.json +0 -11
package/src/types.ts
CHANGED
|
@@ -1,32 +1,194 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Address,
|
|
2
3
|
Beneficiary,
|
|
3
|
-
|
|
4
|
+
ISOCountryCode,
|
|
5
|
+
ISODate,
|
|
4
6
|
IVMS101,
|
|
5
7
|
NationalIdentification,
|
|
6
8
|
Originator,
|
|
7
9
|
} from './ivms/types';
|
|
8
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
|
+
*/
|
|
9
29
|
export type { IVMS101 };
|
|
10
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
|
+
*/
|
|
11
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
|
+
*/
|
|
12
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
|
+
*/
|
|
13
91
|
export type CAIP19 = `${CAIP2}/${string}:${string}`;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Chain Agnostic Payload Identifier
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
14
97
|
export type CAIP220 = string;
|
|
15
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
|
+
|
|
16
117
|
export type DTI = string;
|
|
17
|
-
export type NotabeneAsset = string;
|
|
18
118
|
|
|
19
119
|
/**
|
|
20
|
-
*
|
|
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.
|
|
21
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
|
|
22
136
|
* @public
|
|
23
137
|
*/
|
|
24
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
|
+
*/
|
|
25
145
|
export type TransactionAsset = NotabeneAsset | CAIP19 | DTI;
|
|
26
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
|
+
|
|
27
166
|
export type BlockchainAddress = string;
|
|
28
|
-
|
|
29
|
-
|
|
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`;
|
|
30
192
|
|
|
31
193
|
/**
|
|
32
194
|
* The destination of a transaction either a blockchain address, a CAIP-19 address, or a travel address.
|
|
@@ -37,10 +199,37 @@ export type Destination =
|
|
|
37
199
|
| CAIP10
|
|
38
200
|
| CryptoCredential
|
|
39
201
|
| TravelAddress;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The source of a transaction
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
40
207
|
export type Source = BlockchainAddress | CAIP10;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A Uniform Resource Identifier
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
41
213
|
export type URI = string;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* A Decentralized Identifier
|
|
217
|
+
* @public
|
|
218
|
+
*/
|
|
42
219
|
export type DID = `did:${string}:${string}`;
|
|
43
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
|
+
|
|
44
233
|
/**
|
|
45
234
|
* The theme of the Notabene SDK
|
|
46
235
|
* @public
|
|
@@ -52,23 +241,10 @@ export type Theme = {
|
|
|
52
241
|
logo: string;
|
|
53
242
|
};
|
|
54
243
|
|
|
55
|
-
// export type TransactionType = 'VASP_2_VASP' | 'SELF_HOSTED';
|
|
56
|
-
|
|
57
|
-
// export type TransactionTypeAllowed =
|
|
58
|
-
// | 'ALL'
|
|
59
|
-
// | 'VASP_2_VASP_ONLY'
|
|
60
|
-
// | 'FIRST_PARTY_ONLY';
|
|
61
|
-
|
|
62
|
-
// export type NonCustodialDeclarationType =
|
|
63
|
-
// | 'SIGNATURE'
|
|
64
|
-
// | 'DECLARATION'
|
|
65
|
-
// | 'SIGNATURE_AND_DECLARATION';
|
|
66
|
-
|
|
67
244
|
/**
|
|
68
245
|
* The type of Agent. Either a wallet or a VASP
|
|
69
246
|
* @public
|
|
70
247
|
*/
|
|
71
|
-
|
|
72
248
|
export enum AgentType {
|
|
73
249
|
PRIVATE = 'WALLET',
|
|
74
250
|
VASP = 'VASP',
|
|
@@ -78,33 +254,36 @@ export enum AgentType {
|
|
|
78
254
|
* Who is the agent acting on behalf of the counterparty
|
|
79
255
|
* @public
|
|
80
256
|
*/
|
|
81
|
-
export
|
|
257
|
+
export interface Agent {
|
|
82
258
|
did: DID;
|
|
83
259
|
type: AgentType;
|
|
84
|
-
logo?:
|
|
85
|
-
url?:
|
|
260
|
+
logo?: URI;
|
|
261
|
+
url?: URI;
|
|
86
262
|
name?: string;
|
|
87
263
|
verified?: boolean;
|
|
88
264
|
}
|
|
89
|
-
export type OwnershipProofInput = {
|
|
90
|
-
type?: string | null;
|
|
91
|
-
proof?: string | null;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export type TransactionBlockchainInfo = {
|
|
95
|
-
destination?: string | null;
|
|
96
|
-
origin?: string | null;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export type CountryType = {
|
|
100
|
-
id: string;
|
|
101
|
-
name: string;
|
|
102
|
-
};
|
|
103
265
|
|
|
104
266
|
/**
|
|
105
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.
|
|
106
268
|
* @public
|
|
107
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
|
+
*/
|
|
108
287
|
export enum PersonType {
|
|
109
288
|
NATURAL = 'natural',
|
|
110
289
|
LEGAL = 'legal',
|
|
@@ -116,9 +295,12 @@ export enum PersonType {
|
|
|
116
295
|
* @public
|
|
117
296
|
*/
|
|
118
297
|
export interface VASP extends Agent {
|
|
119
|
-
|
|
120
|
-
|
|
298
|
+
lei?: LEI;
|
|
299
|
+
logo?: URI;
|
|
300
|
+
website?: URI;
|
|
301
|
+
countryOfRegistration?: ISOCountryCode;
|
|
121
302
|
}
|
|
303
|
+
|
|
122
304
|
/**
|
|
123
305
|
* A wallet agent acting on behalf of the counterparty
|
|
124
306
|
* @public
|
|
@@ -132,63 +314,219 @@ export interface Wallet extends Agent {
|
|
|
132
314
|
* The counterparty of a transaction.
|
|
133
315
|
* @public
|
|
134
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
|
+
*/
|
|
135
339
|
export interface Counterparty {
|
|
136
340
|
name?: string;
|
|
137
341
|
accountNumber?: string;
|
|
138
|
-
did?:
|
|
139
|
-
geographicAddress?: string;
|
|
342
|
+
did?: DID;
|
|
140
343
|
type?: PersonType;
|
|
141
344
|
verified?: boolean;
|
|
345
|
+
geographicAddress?: Address;
|
|
346
|
+
nationalIdentification?: NationalIdentification;
|
|
347
|
+
website?: URI;
|
|
348
|
+
phone?: string;
|
|
349
|
+
email?: string;
|
|
142
350
|
}
|
|
351
|
+
|
|
143
352
|
/**
|
|
144
|
-
*
|
|
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
|
|
145
369
|
* @public
|
|
146
370
|
*/
|
|
147
371
|
export interface NaturalPerson extends Counterparty {
|
|
148
372
|
type: PersonType.NATURAL;
|
|
149
|
-
|
|
150
|
-
|
|
373
|
+
dateOfBirth?: ISODate;
|
|
374
|
+
placeOfBirth?: string;
|
|
375
|
+
countryOfResidence?: ISOCountryCode;
|
|
151
376
|
name: string;
|
|
152
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;
|
|
399
|
+
};
|
|
153
400
|
|
|
154
401
|
/**
|
|
155
|
-
*
|
|
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
|
|
156
419
|
* @public
|
|
157
420
|
*/
|
|
158
421
|
export interface LegalPerson extends Counterparty {
|
|
159
422
|
type: PersonType.LEGAL;
|
|
160
423
|
name: string;
|
|
161
|
-
lei?:
|
|
162
|
-
|
|
163
|
-
|
|
424
|
+
lei?: LEI;
|
|
425
|
+
logo?: URI;
|
|
426
|
+
countryOfRegistration?: ISOCountryCode;
|
|
164
427
|
}
|
|
165
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
|
+
*/
|
|
166
451
|
type OriginatorFields = {
|
|
167
452
|
source?: Source;
|
|
168
453
|
};
|
|
169
454
|
|
|
455
|
+
/**
|
|
456
|
+
* Fields specific to the beneficiary of a transaction
|
|
457
|
+
* @public
|
|
458
|
+
*/
|
|
170
459
|
type BeneficiaryFields = {
|
|
171
460
|
destination?: Destination;
|
|
172
461
|
};
|
|
173
462
|
|
|
463
|
+
/**
|
|
464
|
+
* Fields specific to a deposit request
|
|
465
|
+
* @public
|
|
466
|
+
*/
|
|
174
467
|
type DepositRequestFields = {
|
|
175
|
-
|
|
468
|
+
destination: BlockchainAddress | CAIP10;
|
|
469
|
+
asset: TransactionAsset;
|
|
470
|
+
amountDecimal?: number;
|
|
471
|
+
travelAddress?: TravelAddress;
|
|
472
|
+
cryptoCredential?: CryptoCredential;
|
|
176
473
|
};
|
|
177
474
|
|
|
475
|
+
type RequestID = UUID;
|
|
476
|
+
|
|
178
477
|
/**
|
|
179
|
-
*
|
|
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
|
|
180
491
|
* @public
|
|
181
492
|
*/
|
|
182
|
-
export interface
|
|
183
|
-
|
|
493
|
+
export interface ComponentRequest {
|
|
494
|
+
requestId?: RequestID;
|
|
184
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;
|
|
185
523
|
counterparty: Counterparty;
|
|
186
524
|
asset: TransactionAsset;
|
|
187
525
|
amountDecimal: number;
|
|
188
|
-
|
|
189
|
-
|
|
526
|
+
proof?: OwnershipProof;
|
|
527
|
+
assetPrice?: {
|
|
190
528
|
price: number;
|
|
191
|
-
currency:
|
|
529
|
+
currency: ISOCurrency;
|
|
192
530
|
};
|
|
193
531
|
}
|
|
194
532
|
|
|
@@ -208,18 +546,36 @@ export interface Deposit extends OriginatorFields, Transaction {}
|
|
|
208
546
|
* An object representing a request for a deposit
|
|
209
547
|
* @public
|
|
210
548
|
*/
|
|
211
|
-
export interface DepositRequest
|
|
549
|
+
export interface DepositRequest
|
|
550
|
+
extends DepositRequestFields,
|
|
551
|
+
ComponentRequest {}
|
|
212
552
|
|
|
213
553
|
/**
|
|
214
|
-
*
|
|
554
|
+
* An object representing options for a Deposit Request
|
|
215
555
|
* @public
|
|
216
556
|
*/
|
|
557
|
+
export interface DepositRequestOptions {
|
|
558
|
+
showQrCode?: boolean; // Defaults to true
|
|
559
|
+
}
|
|
217
560
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
561
|
+
/**
|
|
562
|
+
* An object representing a connection request
|
|
563
|
+
* @public
|
|
564
|
+
*/
|
|
565
|
+
export interface ConnectionRequest extends ComponentRequest {
|
|
566
|
+
asset: TransactionAsset;
|
|
221
567
|
}
|
|
222
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
|
+
|
|
223
579
|
/**
|
|
224
580
|
* The verification status of a transaction
|
|
225
581
|
* @public
|
|
@@ -232,67 +588,188 @@ export enum Status {
|
|
|
232
588
|
BANNED = 'banned',
|
|
233
589
|
}
|
|
234
590
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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 };
|
|
240
606
|
|
|
241
607
|
/**
|
|
242
608
|
* Transaction payload suitable for calling Notabene v1 tx/create
|
|
243
609
|
* @public
|
|
244
610
|
*/
|
|
245
|
-
|
|
246
611
|
export type V1Transaction = {
|
|
247
612
|
transactionAsset: V1Asset;
|
|
248
613
|
transactionAmount: string;
|
|
249
614
|
originatorEqualsBeneficiary?: boolean;
|
|
250
615
|
originatorVASPdid: DID;
|
|
251
616
|
beneficiaryVASPdid: DID;
|
|
252
|
-
beneficiaryProof
|
|
253
|
-
originator
|
|
617
|
+
beneficiaryProof?: OwnershipProof;
|
|
618
|
+
originator?: Originator;
|
|
254
619
|
beneficiary: Beneficiary;
|
|
255
620
|
};
|
|
621
|
+
|
|
256
622
|
/**
|
|
257
|
-
*
|
|
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
|
|
258
639
|
* @public
|
|
259
640
|
*/
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
value: Transaction;
|
|
263
|
-
ivms: IVMS101;
|
|
264
|
-
proof?: OwnershipProof;
|
|
641
|
+
export interface ComponentResponse {
|
|
642
|
+
requestID: RequestID;
|
|
265
643
|
valid: boolean;
|
|
266
644
|
status: Status;
|
|
267
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;
|
|
268
670
|
txCreate?: V1Transaction;
|
|
269
|
-
}
|
|
671
|
+
}
|
|
270
672
|
|
|
673
|
+
/**
|
|
674
|
+
* Validation error
|
|
675
|
+
* @public
|
|
676
|
+
*/
|
|
271
677
|
export type ValidationError = {
|
|
272
678
|
attribute: string;
|
|
273
679
|
message: string;
|
|
274
680
|
};
|
|
275
681
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
+
*/
|
|
280
697
|
|
|
281
|
-
export type
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
| 'name'
|
|
286
|
-
| 'nationalIdentification'
|
|
287
|
-
| 'dateAndPlaceOfBirth';
|
|
698
|
+
export type FieldTypes = {
|
|
699
|
+
naturalPerson?: NaturalPersonFields;
|
|
700
|
+
legalPerson?: LegalPersonFields;
|
|
701
|
+
};
|
|
288
702
|
|
|
289
|
-
|
|
290
|
-
|
|
703
|
+
/**
|
|
704
|
+
* Options for which VASPs to be searchable
|
|
705
|
+
* @public
|
|
706
|
+
*/
|
|
707
|
+
export type VASPOptions = {
|
|
708
|
+
addUnknown?: boolean;
|
|
709
|
+
onlyActive?: boolean;
|
|
291
710
|
};
|
|
292
711
|
|
|
293
712
|
/**
|
|
294
|
-
*
|
|
295
|
-
*
|
|
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
|
+
*/
|
|
734
|
+
|
|
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
|
|
750
|
+
};
|
|
751
|
+
fallbacks?: ProofTypes[];
|
|
752
|
+
deminimis?: ThresholdOptions;
|
|
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
|
|
296
773
|
*/
|
|
297
774
|
export const enum CMType {
|
|
298
775
|
COMPLETE = 'complete',
|
|
@@ -300,109 +777,176 @@ export const enum CMType {
|
|
|
300
777
|
RESULT = 'result',
|
|
301
778
|
READY = 'ready',
|
|
302
779
|
INVALID = 'invalid',
|
|
303
|
-
MODAL = 'openModal',
|
|
304
780
|
ERROR = 'error',
|
|
305
|
-
CLOSE = 'closeModal',
|
|
306
781
|
CANCEL = 'cancel',
|
|
307
782
|
}
|
|
308
783
|
|
|
309
|
-
|
|
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> = {
|
|
310
791
|
type: CMType.COMPLETE;
|
|
311
|
-
response: TransactionResponse
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
export type Result = {
|
|
315
|
-
type: CMType.RESULT;
|
|
316
|
-
reqid: RequestID;
|
|
317
|
-
response: TransactionResponse;
|
|
792
|
+
response: TransactionResponse<T>;
|
|
318
793
|
};
|
|
319
794
|
|
|
795
|
+
/**
|
|
796
|
+
* Represents a ready component message
|
|
797
|
+
* @public
|
|
798
|
+
*/
|
|
320
799
|
export type Ready = {
|
|
321
800
|
type: CMType.READY;
|
|
322
801
|
};
|
|
323
802
|
|
|
803
|
+
/**
|
|
804
|
+
* Represents a resize request component message. This is handled by the library.
|
|
805
|
+
* @internal
|
|
806
|
+
*/
|
|
324
807
|
export type ResizeRequest = {
|
|
325
808
|
type: CMType.RESIZE;
|
|
326
809
|
height: number;
|
|
327
810
|
};
|
|
328
811
|
|
|
812
|
+
/**
|
|
813
|
+
* Represents an error component message
|
|
814
|
+
* @param message - Error message
|
|
815
|
+
* @public
|
|
816
|
+
*/
|
|
329
817
|
export type Error = {
|
|
330
818
|
type: CMType.ERROR;
|
|
331
819
|
message: string;
|
|
332
820
|
};
|
|
333
821
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
export type CloseModal = {
|
|
341
|
-
type: CMType.CLOSE;
|
|
342
|
-
reqid: RequestID;
|
|
343
|
-
};
|
|
344
|
-
|
|
822
|
+
/**
|
|
823
|
+
* Represents a cancel component message
|
|
824
|
+
* @internal
|
|
825
|
+
*/
|
|
345
826
|
export type Cancel = {
|
|
346
827
|
type: CMType.CANCEL;
|
|
347
828
|
};
|
|
348
829
|
|
|
349
|
-
|
|
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> = {
|
|
350
838
|
type: CMType.INVALID;
|
|
351
|
-
value:
|
|
839
|
+
value: Partial<T>;
|
|
352
840
|
errors: ValidationError[];
|
|
353
841
|
};
|
|
354
842
|
|
|
355
843
|
/**
|
|
356
|
-
*
|
|
357
|
-
*
|
|
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
|
|
358
865
|
*/
|
|
359
|
-
export type ComponentMessage =
|
|
360
|
-
| Completed
|
|
866
|
+
export type ComponentMessage<T> =
|
|
867
|
+
| Completed<T>
|
|
361
868
|
| Cancel
|
|
362
869
|
| Error
|
|
363
|
-
| Result
|
|
364
870
|
| Ready
|
|
365
871
|
| ResizeRequest
|
|
366
|
-
|
|
|
367
|
-
| InvalidValue
|
|
368
|
-
| CloseModal;
|
|
369
|
-
|
|
370
|
-
export type RequestID = string;
|
|
872
|
+
| InvalidValue<T>;
|
|
371
873
|
|
|
372
874
|
/**
|
|
373
|
-
* Host Message
|
|
374
|
-
*
|
|
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
|
|
375
882
|
*/
|
|
376
|
-
|
|
377
883
|
export const enum HMType {
|
|
378
884
|
UPDATE = 'update',
|
|
379
885
|
REQUEST_RESPONSE = 'requestResponse',
|
|
380
886
|
}
|
|
381
887
|
|
|
382
|
-
|
|
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> = {
|
|
383
908
|
type: HMType.UPDATE;
|
|
384
|
-
value: Partial<
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
export type RequestResponse = {
|
|
388
|
-
type: HMType.REQUEST_RESPONSE;
|
|
389
|
-
reqid: RequestID;
|
|
909
|
+
value: Partial<T>;
|
|
910
|
+
options?: O;
|
|
390
911
|
};
|
|
391
912
|
|
|
392
913
|
/**
|
|
393
|
-
*
|
|
394
|
-
*
|
|
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
|
|
395
928
|
*/
|
|
929
|
+
export type HostMessage<T, O> = UpdateValue<T, O>;
|
|
396
930
|
|
|
397
|
-
|
|
398
|
-
|
|
931
|
+
/**
|
|
932
|
+
* Options for callback and redirect URIs
|
|
933
|
+
* @public
|
|
934
|
+
*/
|
|
399
935
|
export interface CallbackOptions {
|
|
400
936
|
callback?: URI;
|
|
401
937
|
redirectUri?: URI;
|
|
402
938
|
}
|
|
403
939
|
|
|
404
940
|
/**
|
|
405
|
-
* Status of the proof
|
|
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
|
+
*
|
|
406
950
|
* @public
|
|
407
951
|
*/
|
|
408
952
|
export enum ProofStatus {
|
|
@@ -413,20 +957,59 @@ export enum ProofStatus {
|
|
|
413
957
|
}
|
|
414
958
|
|
|
415
959
|
/**
|
|
416
|
-
*
|
|
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
|
|
417
977
|
* @public
|
|
418
|
-
|
|
978
|
+
*/
|
|
419
979
|
export enum ProofTypes {
|
|
420
980
|
SelfDeclaration = 'self-declaration',
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
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',
|
|
425
989
|
MicroTransfer = 'microtransfer',
|
|
426
990
|
Screenshot = 'screenshot',
|
|
991
|
+
Connect = 'connect',
|
|
427
992
|
}
|
|
993
|
+
|
|
428
994
|
/**
|
|
429
|
-
*
|
|
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
|
|
430
1013
|
* @public
|
|
431
1014
|
*/
|
|
432
1015
|
export interface OwnershipProof {
|
|
@@ -437,15 +1020,33 @@ export interface OwnershipProof {
|
|
|
437
1020
|
}
|
|
438
1021
|
|
|
439
1022
|
/**
|
|
440
|
-
*
|
|
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
|
|
441
1037
|
* @public
|
|
442
1038
|
*/
|
|
443
1039
|
export interface SignatureProof extends OwnershipProof {
|
|
444
1040
|
type:
|
|
445
|
-
| ProofTypes.
|
|
446
|
-
| ProofTypes.
|
|
447
|
-
| ProofTypes.
|
|
448
|
-
| ProofTypes.
|
|
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;
|
|
1049
|
+
|
|
449
1050
|
proof: string;
|
|
450
1051
|
attestation: string;
|
|
451
1052
|
wallet_provider: string;
|
|
@@ -461,15 +1062,37 @@ export interface DeclarationProof extends OwnershipProof {
|
|
|
461
1062
|
confirmed: boolean;
|
|
462
1063
|
}
|
|
463
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
|
+
|
|
464
1085
|
/**
|
|
465
1086
|
* Ownership Proof using Micro Transfer
|
|
466
1087
|
* @public
|
|
467
1088
|
*/
|
|
468
1089
|
export interface MicroTransferProof extends OwnershipProof {
|
|
469
1090
|
type: ProofTypes.MicroTransfer;
|
|
470
|
-
|
|
1091
|
+
proof: string;
|
|
471
1092
|
chain: CAIP2;
|
|
472
|
-
|
|
1093
|
+
asset: CAIP19;
|
|
1094
|
+
destination: BlockchainAddress;
|
|
1095
|
+
amountSubunits: string;
|
|
473
1096
|
}
|
|
474
1097
|
|
|
475
1098
|
/**
|