@notabene/javascript-sdk 2.9.3 → 2.10.0-next.4

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 (138) hide show
  1. package/README.md +22 -29
  2. package/dist/cjs/notabene.cjs +1 -1
  3. package/dist/cjs/notabene.d.ts +78 -26
  4. package/dist/cjs/package.json +2 -1
  5. package/dist/esm/notabene.d.ts +78 -26
  6. package/dist/esm/notabene.js +19 -13
  7. package/dist/esm/package.json +2 -1
  8. package/dist/notabene.d.ts +78 -26
  9. package/dist/notabene.js +19 -13
  10. package/docs/README.md +218 -47
  11. package/docs/_media/TransactionOptions.md +9 -9
  12. package/docs/_media/getRefreshResult.md +35 -0
  13. package/docs/ivms/types/enumerations/PayloadVersionCode.md +2 -2
  14. package/docs/ivms/types/interfaces/PayloadMetadata.md +2 -2
  15. package/docs/ivms/types/type-aliases/Address.md +1 -1
  16. package/docs/ivms/types/type-aliases/AddressTypeCode.md +1 -1
  17. package/docs/ivms/types/type-aliases/Beneficiary.md +1 -1
  18. package/docs/ivms/types/type-aliases/BeneficiaryVASP.md +1 -1
  19. package/docs/ivms/types/type-aliases/DateAndPlaceOfBirth.md +1 -1
  20. package/docs/ivms/types/type-aliases/ISOCountryCode.md +1 -1
  21. package/docs/ivms/types/type-aliases/ISODate.md +1 -1
  22. package/docs/ivms/types/type-aliases/IVMS101.md +1 -1
  23. package/docs/ivms/types/type-aliases/IntermediaryVASP.md +1 -1
  24. package/docs/ivms/types/type-aliases/LegalPerson.md +1 -1
  25. package/docs/ivms/types/type-aliases/LegalPersonName.md +1 -1
  26. package/docs/ivms/types/type-aliases/LegalPersonNameID.md +1 -1
  27. package/docs/ivms/types/type-aliases/LegalPersonNameTypeCode.md +1 -1
  28. package/docs/ivms/types/type-aliases/LocalLegalPersonNameID.md +1 -1
  29. package/docs/ivms/types/type-aliases/LocalNaturalPersonNameID.md +1 -1
  30. package/docs/ivms/types/type-aliases/NationalIdentification.md +1 -1
  31. package/docs/ivms/types/type-aliases/NationalIdentifierTypeCode.md +1 -1
  32. package/docs/ivms/types/type-aliases/NaturalPerson.md +1 -1
  33. package/docs/ivms/types/type-aliases/NaturalPersonName.md +1 -1
  34. package/docs/ivms/types/type-aliases/NaturalPersonNameID.md +1 -1
  35. package/docs/ivms/types/type-aliases/NaturalPersonNameTypeCode.md +1 -1
  36. package/docs/ivms/types/type-aliases/OriginatingVASP.md +1 -1
  37. package/docs/ivms/types/type-aliases/Originator.md +1 -1
  38. package/docs/ivms/types/type-aliases/Person.md +1 -1
  39. package/docs/ivms/types/type-aliases/TransferPath.md +1 -1
  40. package/docs/ivms/types/type-aliases/TransliterationMethodCode.md +1 -1
  41. package/docs/notabene/README.md +7 -1
  42. package/docs/notabene/classes/ConnectionManager.md +19 -5
  43. package/docs/notabene/classes/EmbeddedComponent.md +17 -17
  44. package/docs/notabene/classes/default.md +7 -7
  45. package/docs/notabene/functions/decodeFragmentToObject.md +1 -1
  46. package/docs/notabene/functions/getRefreshResult.md +11 -3
  47. package/docs/notabene/interfaces/ConnectionData.md +8 -8
  48. package/docs/notabene/interfaces/ConnectionMetadata.md +6 -6
  49. package/docs/notabene/interfaces/ConnectionResponse.md +12 -12
  50. package/docs/notabene/interfaces/NotabeneConfig.md +5 -5
  51. package/docs/notabene/type-aliases/ConnectionResult.md +17 -0
  52. package/docs/notabene/type-aliases/ConnectionStatus.md +1 -1
  53. package/docs/notabene/type-aliases/MessageCallback.md +1 -1
  54. package/docs/notabene/type-aliases/TransactionType.md +1 -1
  55. package/docs/types/README.md +1 -0
  56. package/docs/types/enumerations/AgentType.md +2 -2
  57. package/docs/types/enumerations/CMType.md +7 -7
  58. package/docs/types/enumerations/ErrorIdentifierCode.md +4 -4
  59. package/docs/types/enumerations/HMType.md +2 -2
  60. package/docs/types/enumerations/PersonType.md +3 -3
  61. package/docs/types/enumerations/ProofStatus.md +4 -4
  62. package/docs/types/enumerations/ProofTypes.md +27 -17
  63. package/docs/types/enumerations/Status.md +5 -5
  64. package/docs/types/enumerations/VASPSearchControl.md +2 -2
  65. package/docs/types/enumerations/ValidationSections.md +4 -4
  66. package/docs/types/interfaces/Account.md +59 -0
  67. package/docs/types/interfaces/Agent.md +6 -6
  68. package/docs/types/interfaces/CallbackOptions.md +2 -2
  69. package/docs/types/interfaces/ComponentRequest.md +2 -2
  70. package/docs/types/interfaces/ComponentResponse.md +4 -4
  71. package/docs/types/interfaces/ConnectionRecord.md +7 -7
  72. package/docs/types/interfaces/ConnectionRequest.md +3 -3
  73. package/docs/types/interfaces/Counterparty.md +10 -10
  74. package/docs/types/interfaces/DeclarationProof.md +6 -6
  75. package/docs/types/interfaces/Deposit.md +25 -11
  76. package/docs/types/interfaces/DepositRequest.md +9 -9
  77. package/docs/types/interfaces/DepositRequestOptions.md +1 -1
  78. package/docs/types/interfaces/DepositTransaction.md +23 -9
  79. package/docs/types/interfaces/LegalPerson.md +13 -13
  80. package/docs/types/interfaces/MicroTransferProof.md +9 -9
  81. package/docs/types/interfaces/NaturalPerson.md +13 -13
  82. package/docs/types/interfaces/OwnershipProof.md +4 -4
  83. package/docs/types/interfaces/RefreshSource.md +2 -2
  84. package/docs/types/interfaces/Refreshable.md +1 -1
  85. package/docs/types/interfaces/ScreenshotProof.md +5 -5
  86. package/docs/types/interfaces/SignatureProof.md +10 -10
  87. package/docs/types/interfaces/ThresholdOptions.md +3 -3
  88. package/docs/types/interfaces/Transaction.md +18 -8
  89. package/docs/types/interfaces/TransactionOptions.md +9 -9
  90. package/docs/types/interfaces/TransactionResponse.md +9 -9
  91. package/docs/types/interfaces/VASP.md +9 -9
  92. package/docs/types/interfaces/Wallet.md +8 -8
  93. package/docs/types/interfaces/Withdrawal.md +24 -10
  94. package/docs/types/type-aliases/BlockchainAddress.md +1 -1
  95. package/docs/types/type-aliases/CAIP10.md +1 -1
  96. package/docs/types/type-aliases/CAIP19.md +1 -1
  97. package/docs/types/type-aliases/CAIP2.md +1 -1
  98. package/docs/types/type-aliases/CAIP220.md +1 -1
  99. package/docs/types/type-aliases/Cancel.md +1 -1
  100. package/docs/types/type-aliases/Completed.md +1 -1
  101. package/docs/types/type-aliases/ComponentMessage.md +1 -1
  102. package/docs/types/type-aliases/ConnectionOptions.md +1 -1
  103. package/docs/types/type-aliases/CounterpartyAssistConfig.md +2 -2
  104. package/docs/types/type-aliases/CryptoCredential.md +1 -1
  105. package/docs/types/type-aliases/DID.md +1 -1
  106. package/docs/types/type-aliases/DTI.md +1 -1
  107. package/docs/types/type-aliases/Destination.md +1 -1
  108. package/docs/types/type-aliases/Error.md +1 -1
  109. package/docs/types/type-aliases/FieldOptions.md +1 -1
  110. package/docs/types/type-aliases/FieldTypes.md +1 -1
  111. package/docs/types/type-aliases/HostMessage.md +1 -1
  112. package/docs/types/type-aliases/ISOCurrency.md +1 -1
  113. package/docs/types/type-aliases/InvalidValue.md +1 -1
  114. package/docs/types/type-aliases/LEI.md +1 -1
  115. package/docs/types/type-aliases/LegalPersonFieldName.md +1 -1
  116. package/docs/types/type-aliases/LegalPersonFields.md +1 -1
  117. package/docs/types/type-aliases/NationalIdentifierTypeFieldOptions.md +1 -1
  118. package/docs/types/type-aliases/NaturalPersonFieldName.md +1 -1
  119. package/docs/types/type-aliases/NaturalPersonFields.md +1 -1
  120. package/docs/types/type-aliases/NotabeneAsset.md +1 -1
  121. package/docs/types/type-aliases/Ready.md +1 -1
  122. package/docs/types/type-aliases/ResizeRequest.md +1 -1
  123. package/docs/types/type-aliases/Source.md +1 -1
  124. package/docs/types/type-aliases/Theme.md +1 -1
  125. package/docs/types/type-aliases/TransactionAsset.md +1 -1
  126. package/docs/types/type-aliases/TravelAddress.md +1 -1
  127. package/docs/types/type-aliases/URI.md +1 -1
  128. package/docs/types/type-aliases/UUID.md +1 -1
  129. package/docs/types/type-aliases/UpdateValue.md +1 -1
  130. package/docs/types/type-aliases/V1Asset.md +1 -1
  131. package/docs/types/type-aliases/V1Transaction.md +1 -1
  132. package/docs/types/type-aliases/VASPOptions.md +1 -1
  133. package/docs/types/type-aliases/ValidationError.md +1 -1
  134. package/package.json +2 -1
  135. package/src/types.ts +36 -2
  136. package/src/utils/connections.ts +47 -21
  137. package/src/utils/encryption.ts +13 -6
  138. package/docs/notabene/interfaces/ConnectionResult.md +0 -61
package/src/types.ts CHANGED
@@ -301,6 +301,7 @@ export interface VASP extends Agent {
301
301
  logo?: URI;
302
302
  website?: URI;
303
303
  countryOfRegistration?: ISOCountryCode;
304
+ jurisdictions?: string;
304
305
  }
305
306
 
306
307
  /**
@@ -757,7 +758,6 @@ export type FieldOptions =
757
758
  | string[] // fields to show
758
759
  | {
759
760
  optional: boolean; // Shown but optional
760
- transmit: boolean; // Transmit as part of IVMS 101 to counterparty
761
761
  };
762
762
 
763
763
  /**
@@ -850,6 +850,7 @@ export interface TransactionOptions {
850
850
  fallbacks?: ProofTypes[];
851
851
  deminimis?: ThresholdOptions;
852
852
  };
853
+ jurisdiction?: string;
853
854
  allowedAgentTypes?: AgentType[]; // Defaults to All
854
855
  allowedCounterpartyTypes?: PersonType[]; // Defaults to All
855
856
  fields?: FieldTypes;
@@ -879,6 +880,8 @@ export enum CMType {
879
880
  INVALID = 'invalid',
880
881
  ERROR = 'error',
881
882
  CANCEL = 'cancel',
883
+ WARNING = 'warning',
884
+ INFO = 'info',
882
885
  }
883
886
 
884
887
  /**
@@ -955,6 +958,30 @@ export type InvalidValue<T> = {
955
958
  errors: ValidationError[];
956
959
  };
957
960
 
961
+ /**
962
+ * Represents a warning component message
963
+ * @param message - Warning message
964
+ * @param description - Description of the warning message
965
+ * @public
966
+ */
967
+ export type Warning = {
968
+ type: CMType.WARNING;
969
+ message: string;
970
+ description?: string;
971
+ };
972
+
973
+ /**
974
+ * Represents an info component message
975
+ * @param message - Info message
976
+ * @param description - Description of the info message
977
+ * @public
978
+ */
979
+ export type Info = {
980
+ type: CMType.INFO;
981
+ message: string;
982
+ description?: string;
983
+ };
984
+
958
985
  /**
959
986
  * Union type representing all possible messages that can be sent from a component
960
987
  *
@@ -972,8 +999,11 @@ export type InvalidValue<T> = {
972
999
  * @see {@link Completed} For successful completion message format
973
1000
  * @see {@link Cancel} For cancellation message format
974
1001
  * @see {@link Error} For error message format
1002
+ * @see {@link Ready} For ready message format
975
1003
  * @see {@link ResizeRequest} For resize message format
976
1004
  * @see {@link InvalidValue} For validation failure message format
1005
+ * @see {@link Warning} For warning message format
1006
+ * @see {@link Info} For info message format
977
1007
  * @public
978
1008
  */
979
1009
  export type ComponentMessage<T> =
@@ -982,7 +1012,9 @@ export type ComponentMessage<T> =
982
1012
  | Error
983
1013
  | Ready
984
1014
  | ResizeRequest
985
- | InvalidValue<T>;
1015
+ | InvalidValue<T>
1016
+ | Warning
1017
+ | Info;
986
1018
 
987
1019
  /**
988
1020
  * Host Message Type enum representing different message types that can be sent
@@ -1113,6 +1145,7 @@ export enum ProofTypes {
1113
1145
  MicroTransfer = 'microtransfer',
1114
1146
  Screenshot = 'screenshot',
1115
1147
  Connect = 'connect',
1148
+ CONCORDIUM = 'concordium',
1116
1149
  }
1117
1150
 
1118
1151
  /**
@@ -1174,6 +1207,7 @@ export interface SignatureProof extends OwnershipProof {
1174
1207
  | ProofTypes.SIWE
1175
1208
  | ProofTypes.CIP8
1176
1209
  | ProofTypes.XRP_ED25519
1210
+ | ProofTypes.CONCORDIUM
1177
1211
  | ProofTypes.XLM_ED25519;
1178
1212
 
1179
1213
  proof: string;
@@ -9,35 +9,55 @@ import { seal, unseal } from './encryption';
9
9
 
10
10
  export type TransactionType = 'withdraw' | 'deposit';
11
11
  export type ConnectionStatus = 'active' | 'completed' | 'closed';
12
+
12
13
  export interface ConnectionData<T extends ComponentRequest> {
13
- tx: T;
14
- authToken?: string;
15
- txOptions?: TransactionOptions;
16
- result?: TransactionResponse<T>;
14
+ readonly tx: T;
15
+ readonly authToken?: string;
16
+ readonly txOptions?: TransactionOptions;
17
+ readonly result?: TransactionResponse<T>;
17
18
  }
18
19
 
19
20
  export interface ConnectionMetadata {
20
- nodeUrl?: string;
21
- participants: string[];
22
- transactionType: TransactionType;
21
+ readonly nodeUrl?: string;
22
+ readonly participants: readonly string[];
23
+ readonly transactionType: TransactionType;
24
+ readonly locale?: string;
23
25
  }
26
+
24
27
  export interface ConnectionResponse<T extends ComponentRequest> {
25
- id: UUID;
26
- version: number;
27
- status: ConnectionStatus;
28
- metadata: ConnectionMetadata;
29
- data: ConnectionData<T>;
30
- key: string;
28
+ readonly id: UUID;
29
+ readonly version: number;
30
+ readonly status: ConnectionStatus;
31
+ readonly metadata: ConnectionMetadata;
32
+ readonly data: ConnectionData<T>;
33
+ readonly key: string;
31
34
  }
32
35
 
33
- export interface ConnectionResult<T extends ComponentRequest> {
34
- id: UUID;
35
- metadata: ConnectionMetadata;
36
- status: ConnectionStatus;
37
- tx?: T;
38
- result?: TransactionResponse<T>;
39
- }
36
+ export type ConnectionResult<T extends ComponentRequest> =
37
+ | {
38
+ readonly id: UUID;
39
+ readonly metadata: ConnectionMetadata;
40
+ readonly status: 'closed';
41
+ }
42
+ | {
43
+ readonly id: UUID;
44
+ readonly metadata: ConnectionMetadata;
45
+ readonly status: 'completed';
46
+ readonly result: TransactionResponse<T>;
47
+ }
48
+ | {
49
+ readonly id: UUID;
50
+ readonly metadata: ConnectionMetadata;
51
+ readonly status: 'active';
52
+ readonly tx: T;
53
+ };
40
54
 
55
+ /**
56
+ * Retrieves and processes connection refresh data
57
+ * @template T Type of component request
58
+ * @param refreshSource Source information for the refresh operation
59
+ * @returns Promise resolving to connection result with decrypted data
60
+ */
41
61
  export async function getRefreshResult<T extends ComponentRequest>(
42
62
  refreshSource: RefreshSource,
43
63
  ): Promise<ConnectionResult<T>> {
@@ -99,8 +119,9 @@ export class ConnectionManager {
99
119
 
100
120
  /**
101
121
  * Creates a new encrypted connection
122
+ * @template T Type of component request
102
123
  * @param data The component request data to encrypt and store
103
- * @param participants Array of participant identifiers
124
+ * @param metadata Connection metadata including participants and transaction type
104
125
  * @returns Promise resolving to connection details including ID, version, and encryption key
105
126
  */
106
127
  async create<T extends ComponentRequest>(
@@ -143,9 +164,12 @@ export class ConnectionManager {
143
164
 
144
165
  /**
145
166
  * Updates an existing connection with new encrypted data
167
+ * @template T Type of component request
146
168
  * @param id Connection ID
147
169
  * @param data New data to encrypt and store
148
170
  * @param version Current version number
171
+ * @param status New connection status
172
+ * @param key Current encryption key
149
173
  * @returns Promise resolving to updated connection details including new encryption key
150
174
  */
151
175
  async update<T extends ComponentRequest>(
@@ -192,6 +216,7 @@ export class ConnectionManager {
192
216
 
193
217
  /**
194
218
  * Retrieves and decrypts connection data
219
+ * @template T Type of component request
195
220
  * @param id Connection ID
196
221
  * @param key Encryption key from previous create/update operation
197
222
  * @returns Promise resolving to connection details including decrypted data
@@ -233,6 +258,7 @@ export class ConnectionManager {
233
258
  /**
234
259
  * Closes a connection
235
260
  * @param id Connection ID
261
+ * @returns Promise resolving when the connection is closed
236
262
  */
237
263
  async close(id: UUID): Promise<void> {
238
264
  const response = await fetch(`${this.endpoint}/${id}`, {
@@ -3,15 +3,16 @@
3
3
  */
4
4
  export interface Sealed {
5
5
  /** Base64-encoded ciphertext combined with initialization vector (IV) */
6
- ciphertext: string;
6
+ readonly ciphertext: string;
7
7
  /** Base64-encoded encryption key */
8
- key: string;
8
+ readonly key: string;
9
9
  }
10
10
 
11
11
  /**
12
12
  * Encrypts an object using AES-GCM encryption.
13
13
  * @template T Type of data to encrypt
14
14
  * @param data Data to encrypt
15
+ * @param existingKey Optional existing key to use for encryption
15
16
  * @returns Promise resolving to a Sealed object containing ciphertext and key
16
17
  */
17
18
  export async function seal<T>(data: T, existingKey?: string): Promise<Sealed> {
@@ -56,7 +57,6 @@ export async function seal<T>(data: T, existingKey?: string): Promise<Sealed> {
56
57
  * @param sealed Sealed object containing ciphertext and key
57
58
  * @returns Promise resolving to the original decrypted data
58
59
  */
59
-
60
60
  export async function unseal<T>({ ciphertext, key }: Sealed): Promise<T> {
61
61
  // Split the IV and the ciphertext
62
62
  const [ivBase64, ciphertextBase64] = ciphertext.split('-');
@@ -91,7 +91,11 @@ export async function unseal<T>({ ciphertext, key }: Sealed): Promise<T> {
91
91
  return JSON.parse(decoder.decode(plaintextBuffer));
92
92
  }
93
93
 
94
- // Utility function to convert ArrayBuffer to Base64
94
+ /**
95
+ * Converts an ArrayBuffer to a Base64 string
96
+ * @param buffer The ArrayBuffer to convert
97
+ * @returns Base64 encoded string
98
+ */
95
99
  function arrayBufferToBase64(buffer: ArrayBuffer): string {
96
100
  const uint8Array = new Uint8Array(buffer);
97
101
  let binary = '';
@@ -101,8 +105,11 @@ function arrayBufferToBase64(buffer: ArrayBuffer): string {
101
105
  return btoa(binary);
102
106
  }
103
107
 
104
- // Utility function to convert Base64 to ArrayBuffer
105
-
108
+ /**
109
+ * Converts a Base64 string to a Uint8Array
110
+ * @param base64 The Base64 string to convert
111
+ * @returns Uint8Array containing the decoded data
112
+ */
106
113
  function base64ToUint8Array(base64: string): Uint8Array {
107
114
  const binary = atob(base64);
108
115
  const buffer = new Uint8Array(binary.length);
@@ -1,61 +0,0 @@
1
- [**@notabene/javascript-sdk**](../../README.md)
2
-
3
- ***
4
-
5
- [@notabene/javascript-sdk](../../modules.md) / [notabene](../README.md) / ConnectionResult
6
-
7
- # Interface: ConnectionResult\<T\>
8
-
9
- ## Type Parameters
10
-
11
- • **T** *extends* [`ComponentRequest`](../../types/interfaces/ComponentRequest.md)
12
-
13
- ## Properties
14
-
15
- ### id
16
-
17
- > **id**: `string`
18
-
19
- #### Defined in
20
-
21
- [utils/connections.ts:34](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/f6a0825d098b61a3bc31d6c197072643eb78a452/src/utils/connections.ts#L34)
22
-
23
- ***
24
-
25
- ### metadata
26
-
27
- > **metadata**: [`ConnectionMetadata`](ConnectionMetadata.md)
28
-
29
- #### Defined in
30
-
31
- [utils/connections.ts:35](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/f6a0825d098b61a3bc31d6c197072643eb78a452/src/utils/connections.ts#L35)
32
-
33
- ***
34
-
35
- ### result?
36
-
37
- > `optional` **result**: [`TransactionResponse`](../../types/interfaces/TransactionResponse.md)\<`T`\>
38
-
39
- #### Defined in
40
-
41
- [utils/connections.ts:38](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/f6a0825d098b61a3bc31d6c197072643eb78a452/src/utils/connections.ts#L38)
42
-
43
- ***
44
-
45
- ### status
46
-
47
- > **status**: [`ConnectionStatus`](../type-aliases/ConnectionStatus.md)
48
-
49
- #### Defined in
50
-
51
- [utils/connections.ts:36](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/f6a0825d098b61a3bc31d6c197072643eb78a452/src/utils/connections.ts#L36)
52
-
53
- ***
54
-
55
- ### tx?
56
-
57
- > `optional` **tx**: `T`
58
-
59
- #### Defined in
60
-
61
- [utils/connections.ts:37](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/f6a0825d098b61a3bc31d6c197072643eb78a452/src/utils/connections.ts#L37)