@notabene/javascript-sdk 2.8.0-next.3 → 2.8.0-next.5
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/dist/cjs/notabene.cjs +1 -1
- package/dist/cjs/notabene.d.ts +58 -1
- package/dist/cjs/package.json +1 -1
- package/dist/esm/notabene.d.ts +58 -1
- package/dist/esm/notabene.js +282 -137
- package/dist/esm/package.json +1 -1
- package/dist/notabene.d.ts +58 -1
- package/dist/notabene.js +282 -137
- package/docs/_media/TransactionOptions.md +6 -6
- package/docs/ivms/types/enumerations/PayloadVersionCode.md +2 -2
- package/docs/ivms/types/interfaces/PayloadMetadata.md +2 -2
- package/docs/ivms/types/type-aliases/Address.md +1 -1
- package/docs/ivms/types/type-aliases/AddressTypeCode.md +1 -1
- package/docs/ivms/types/type-aliases/Beneficiary.md +1 -1
- package/docs/ivms/types/type-aliases/BeneficiaryVASP.md +1 -1
- package/docs/ivms/types/type-aliases/DateAndPlaceOfBirth.md +1 -1
- package/docs/ivms/types/type-aliases/ISOCountryCode.md +1 -1
- package/docs/ivms/types/type-aliases/ISODate.md +1 -1
- package/docs/ivms/types/type-aliases/IVMS101.md +1 -1
- package/docs/ivms/types/type-aliases/IntermediaryVASP.md +1 -1
- package/docs/ivms/types/type-aliases/LegalPerson.md +1 -1
- package/docs/ivms/types/type-aliases/LegalPersonName.md +1 -1
- package/docs/ivms/types/type-aliases/LegalPersonNameID.md +1 -1
- package/docs/ivms/types/type-aliases/LegalPersonNameTypeCode.md +1 -1
- package/docs/ivms/types/type-aliases/LocalLegalPersonNameID.md +1 -1
- package/docs/ivms/types/type-aliases/LocalNaturalPersonNameID.md +1 -1
- package/docs/ivms/types/type-aliases/NationalIdentification.md +1 -1
- package/docs/ivms/types/type-aliases/NationalIdentifierTypeCode.md +1 -1
- package/docs/ivms/types/type-aliases/NaturalPerson.md +1 -1
- package/docs/ivms/types/type-aliases/NaturalPersonName.md +1 -1
- package/docs/ivms/types/type-aliases/NaturalPersonNameID.md +1 -1
- package/docs/ivms/types/type-aliases/NaturalPersonNameTypeCode.md +1 -1
- package/docs/ivms/types/type-aliases/OriginatingVASP.md +1 -1
- package/docs/ivms/types/type-aliases/Originator.md +1 -1
- package/docs/ivms/types/type-aliases/Person.md +1 -1
- package/docs/ivms/types/type-aliases/TransferPath.md +1 -1
- package/docs/ivms/types/type-aliases/TransliterationMethodCode.md +1 -1
- package/docs/notabene/README.md +30 -0
- package/docs/notabene/classes/EmbeddedComponent.md +17 -17
- package/docs/notabene/classes/default.md +7 -7
- package/docs/notabene/functions/decodeFragmentToObject.md +1 -1
- package/docs/notabene/interfaces/NotabeneConfig.md +5 -5
- package/docs/notabene/type-aliases/MessageCallback.md +1 -1
- package/docs/types/README.md +2 -0
- package/docs/types/enumerations/AgentType.md +2 -2
- package/docs/types/enumerations/CMType.md +7 -7
- package/docs/types/enumerations/ErrorIdentifierCode.md +4 -4
- package/docs/types/enumerations/HMType.md +2 -2
- package/docs/types/enumerations/PersonType.md +3 -3
- package/docs/types/enumerations/ProofStatus.md +4 -4
- package/docs/types/enumerations/ProofTypes.md +36 -14
- package/docs/types/enumerations/Status.md +5 -5
- package/docs/types/enumerations/VASPSearchControl.md +2 -2
- package/docs/types/enumerations/ValidationSections.md +4 -4
- package/docs/types/interfaces/Agent.md +6 -6
- package/docs/types/interfaces/CallbackOptions.md +2 -2
- package/docs/types/interfaces/ComponentRequest.md +2 -2
- package/docs/types/interfaces/ComponentResponse.md +4 -4
- package/docs/types/interfaces/ConnectionRecord.md +7 -7
- package/docs/types/interfaces/ConnectionRequest.md +3 -3
- package/docs/types/interfaces/Counterparty.md +10 -10
- package/docs/types/interfaces/DeclarationProof.md +6 -6
- package/docs/types/interfaces/Deposit.md +25 -11
- package/docs/types/interfaces/DepositRequest.md +7 -7
- package/docs/types/interfaces/DepositRequestOptions.md +1 -1
- package/docs/types/interfaces/DepositTransaction.md +9 -9
- package/docs/types/interfaces/LegalPerson.md +13 -13
- package/docs/types/interfaces/MicroTransferProof.md +9 -9
- package/docs/types/interfaces/NaturalPerson.md +13 -13
- package/docs/types/interfaces/OwnershipProof.md +4 -4
- package/docs/types/interfaces/RefreshSource.md +27 -0
- package/docs/types/interfaces/Refreshable.md +22 -0
- package/docs/types/interfaces/ScreenshotProof.md +5 -5
- package/docs/types/interfaces/SignatureProof.md +23 -9
- package/docs/types/interfaces/ThresholdOptions.md +3 -3
- package/docs/types/interfaces/Transaction.md +8 -8
- package/docs/types/interfaces/TransactionOptions.md +6 -6
- package/docs/types/interfaces/TransactionResponse.md +9 -9
- package/docs/types/interfaces/VASP.md +9 -9
- package/docs/types/interfaces/Wallet.md +8 -8
- package/docs/types/interfaces/Withdrawal.md +24 -10
- package/docs/types/type-aliases/BlockchainAddress.md +1 -1
- package/docs/types/type-aliases/CAIP10.md +1 -1
- package/docs/types/type-aliases/CAIP19.md +1 -1
- package/docs/types/type-aliases/CAIP2.md +1 -1
- package/docs/types/type-aliases/CAIP220.md +1 -1
- package/docs/types/type-aliases/Cancel.md +1 -1
- package/docs/types/type-aliases/Completed.md +1 -1
- package/docs/types/type-aliases/ComponentMessage.md +1 -1
- package/docs/types/type-aliases/ConnectionOptions.md +1 -1
- package/docs/types/type-aliases/CryptoCredential.md +1 -1
- package/docs/types/type-aliases/DID.md +1 -1
- package/docs/types/type-aliases/DTI.md +1 -1
- package/docs/types/type-aliases/Destination.md +1 -1
- package/docs/types/type-aliases/Error.md +1 -1
- package/docs/types/type-aliases/FieldOptions.md +2 -2
- package/docs/types/type-aliases/FieldTypes.md +1 -1
- package/docs/types/type-aliases/HostMessage.md +1 -1
- package/docs/types/type-aliases/ISOCurrency.md +1 -1
- package/docs/types/type-aliases/InvalidValue.md +1 -1
- package/docs/types/type-aliases/LEI.md +1 -1
- package/docs/types/type-aliases/LegalPersonFieldName.md +1 -1
- package/docs/types/type-aliases/LegalPersonFields.md +1 -1
- package/docs/types/type-aliases/NaturalPersonFieldName.md +1 -1
- package/docs/types/type-aliases/NaturalPersonFields.md +1 -1
- package/docs/types/type-aliases/NotabeneAsset.md +1 -1
- package/docs/types/type-aliases/Ready.md +1 -1
- package/docs/types/type-aliases/ResizeRequest.md +1 -1
- package/docs/types/type-aliases/Source.md +1 -1
- package/docs/types/type-aliases/Theme.md +1 -1
- package/docs/types/type-aliases/TransactionAsset.md +1 -1
- package/docs/types/type-aliases/TravelAddress.md +1 -1
- package/docs/types/type-aliases/URI.md +1 -1
- package/docs/types/type-aliases/UUID.md +1 -1
- package/docs/types/type-aliases/UpdateValue.md +1 -1
- package/docs/types/type-aliases/V1Asset.md +1 -1
- package/docs/types/type-aliases/V1Transaction.md +1 -1
- package/docs/types/type-aliases/VASPOptions.md +1 -1
- package/docs/types/type-aliases/ValidationError.md +1 -1
- package/package.json +1 -1
- package/src/notabene.ts +7 -0
- package/src/types.ts +1 -0
- package/src/utils/__tests__/connections.test.ts +284 -0
- package/src/utils/__tests__/encryption.test.ts +79 -0
- package/src/utils/connections.ts +174 -0
- package/src/utils/encryption.ts +111 -0
|
@@ -20,4 +20,4 @@ Represents a cancel component message
|
|
|
20
20
|
|
|
21
21
|
## Defined in
|
|
22
22
|
|
|
23
|
-
[types.ts:
|
|
23
|
+
[types.ts:885](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L885)
|
|
@@ -32,4 +32,4 @@ The Response object which wraps T
|
|
|
32
32
|
|
|
33
33
|
## Defined in
|
|
34
34
|
|
|
35
|
-
[types.ts:
|
|
35
|
+
[types.ts:834](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L834)
|
|
@@ -36,4 +36,4 @@ through these message types:
|
|
|
36
36
|
|
|
37
37
|
## Defined in
|
|
38
38
|
|
|
39
|
-
[types.ts:
|
|
39
|
+
[types.ts:923](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L923)
|
|
@@ -12,4 +12,4 @@ An object representing options for a Connection Request
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:
|
|
15
|
+
[types.ts:598](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L598)
|
|
@@ -12,4 +12,4 @@ A crypto credential
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:191](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:191](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L191)
|
|
@@ -12,4 +12,4 @@ A Decentralized Identifier
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:219](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:219](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L219)
|
|
@@ -35,4 +35,4 @@ Format: `DTI[NNNNN]` where N is a digit
|
|
|
35
35
|
|
|
36
36
|
## Defined in
|
|
37
37
|
|
|
38
|
-
[types.ts:117](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
38
|
+
[types.ts:117](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L117)
|
|
@@ -12,4 +12,4 @@ The destination of a transaction either a blockchain address, a CAIP-19 address,
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:197](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:197](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L197)
|
|
@@ -42,4 +42,4 @@ Identifier code of the error message
|
|
|
42
42
|
|
|
43
43
|
## Defined in
|
|
44
44
|
|
|
45
|
-
[types.ts:
|
|
45
|
+
[types.ts:874](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L874)
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
# Type Alias: FieldOptions
|
|
8
8
|
|
|
9
|
-
> **FieldOptions**: `boolean` \| \{ `optional`: `boolean`; `transmit`: `boolean`; \}
|
|
9
|
+
> **FieldOptions**: `boolean` \| `string`[] \| \{ `optional`: `boolean`; `transmit`: `boolean`; \}
|
|
10
10
|
|
|
11
11
|
Field properties
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:
|
|
15
|
+
[types.ts:714](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L714)
|
|
@@ -22,4 +22,4 @@ Field type configuration
|
|
|
22
22
|
|
|
23
23
|
## Defined in
|
|
24
24
|
|
|
25
|
-
[types.ts:
|
|
25
|
+
[types.ts:727](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L727)
|
|
@@ -34,4 +34,4 @@ without requiring full reinitialization.
|
|
|
34
34
|
|
|
35
35
|
## Defined in
|
|
36
36
|
|
|
37
|
-
[types.ts:
|
|
37
|
+
[types.ts:986](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L986)
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:231](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:231](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L231)
|
|
@@ -42,4 +42,4 @@ Array of validation errors
|
|
|
42
42
|
|
|
43
43
|
## Defined in
|
|
44
44
|
|
|
45
|
-
[types.ts:
|
|
45
|
+
[types.ts:896](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L896)
|
|
@@ -12,4 +12,4 @@ A LEI Legal Entity Identifier
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:225](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:225](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L225)
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
|
|
11
11
|
## Defined in
|
|
12
12
|
|
|
13
|
-
[types.ts:430](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
13
|
+
[types.ts:430](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L430)
|
|
@@ -12,4 +12,4 @@ Field properties by field name
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:444](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:444](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L444)
|
|
@@ -12,4 +12,4 @@ Field names for NaturalPerson
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:383](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:383](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L383)
|
|
@@ -12,4 +12,4 @@ Field properties by field name for Natural persons
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:398](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:398](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L398)
|
|
@@ -33,4 +33,4 @@ system that may be used alongside CAIP-19 and DTI identifiers.
|
|
|
33
33
|
|
|
34
34
|
## Defined in
|
|
35
35
|
|
|
36
|
-
[types.ts:139](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
36
|
+
[types.ts:139](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L139)
|
|
@@ -18,4 +18,4 @@ Represents a ready component message
|
|
|
18
18
|
|
|
19
19
|
## Defined in
|
|
20
20
|
|
|
21
|
-
[types.ts:
|
|
21
|
+
[types.ts:843](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L843)
|
|
@@ -24,4 +24,4 @@ Represents a resize request component message. This is handled by the library.
|
|
|
24
24
|
|
|
25
25
|
## Defined in
|
|
26
26
|
|
|
27
|
-
[types.ts:
|
|
27
|
+
[types.ts:851](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L851)
|
|
@@ -12,4 +12,4 @@ The source of a transaction
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:207](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:207](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L207)
|
|
@@ -34,4 +34,4 @@ The theme of the Notabene SDK
|
|
|
34
34
|
|
|
35
35
|
## Defined in
|
|
36
36
|
|
|
37
|
-
[types.ts:237](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
37
|
+
[types.ts:237](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L237)
|
|
@@ -12,4 +12,4 @@ The asset of a transaction either a Notabene asset, a CAIP-19 asset, or a DTI.
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:145](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:145](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L145)
|
|
@@ -34,4 +34,4 @@ VASPs and blockchain networks while maintaining privacy.
|
|
|
34
34
|
|
|
35
35
|
## Defined in
|
|
36
36
|
|
|
37
|
-
[types.ts:186](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
37
|
+
[types.ts:186](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L186)
|
|
@@ -12,4 +12,4 @@ A Uniform Resource Identifier
|
|
|
12
12
|
|
|
13
13
|
## Defined in
|
|
14
14
|
|
|
15
|
-
[types.ts:213](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
15
|
+
[types.ts:213](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L213)
|
|
@@ -24,4 +24,4 @@ Format: 8-4-4-4-12 hexadecimal digits
|
|
|
24
24
|
|
|
25
25
|
## Defined in
|
|
26
26
|
|
|
27
|
-
[types.ts:39](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/
|
|
27
|
+
[types.ts:39](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L39)
|
|
@@ -51,4 +51,4 @@ and its configuration without requiring a full reload/reinitialize.
|
|
|
51
51
|
|
|
52
52
|
## Defined in
|
|
53
53
|
|
|
54
|
-
[types.ts:
|
|
54
|
+
[types.ts:964](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L964)
|
|
@@ -33,4 +33,4 @@ Used for backwards compatibility with V1 API transaction payloads:
|
|
|
33
33
|
|
|
34
34
|
## Defined in
|
|
35
35
|
|
|
36
|
-
[types.ts:
|
|
36
|
+
[types.ts:629](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L629)
|
|
@@ -54,4 +54,4 @@ Transaction payload suitable for calling Notabene v1 tx/create
|
|
|
54
54
|
|
|
55
55
|
## Defined in
|
|
56
56
|
|
|
57
|
-
[types.ts:
|
|
57
|
+
[types.ts:635](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L635)
|
|
@@ -26,4 +26,4 @@ Options for which VASPs to be searchable
|
|
|
26
26
|
|
|
27
27
|
## Defined in
|
|
28
28
|
|
|
29
|
-
[types.ts:
|
|
29
|
+
[types.ts:749](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L749)
|
|
@@ -22,4 +22,4 @@ Validation error
|
|
|
22
22
|
|
|
23
23
|
## Defined in
|
|
24
24
|
|
|
25
|
-
[types.ts:
|
|
25
|
+
[types.ts:705](https://gitlab.com/notabene/open-source/javascript-sdk/-/blob/80aada173fac6a9b5f05869abafa3c1c6cc56aa9/src/types.ts#L705)
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "Notabene <developers@notabene.id>",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"packageManager": "yarn@4.5.1",
|
|
13
|
-
"version": "2.8.0-next.
|
|
13
|
+
"version": "2.8.0-next.5",
|
|
14
14
|
"source": "src/notabene.ts",
|
|
15
15
|
"main": "dist/cjs/notabene.cjs",
|
|
16
16
|
"module": "dist/esm/notabene.js",
|
package/src/notabene.ts
CHANGED
|
@@ -73,6 +73,13 @@ import { type MessageCallback } from './utils/MessageEventManager';
|
|
|
73
73
|
import { decodeFragmentToObject, encodeObjectToFragment } from './utils/urls';
|
|
74
74
|
// Must be exported for React Native SDK to use
|
|
75
75
|
export { default as EmbeddedComponent } from './components/EmbeddedComponent';
|
|
76
|
+
export {
|
|
77
|
+
ConnectionManager,
|
|
78
|
+
type ConnectionData,
|
|
79
|
+
type ConnectionMetadata,
|
|
80
|
+
type ConnectionResponse,
|
|
81
|
+
type TransactionType,
|
|
82
|
+
} from './utils/connections';
|
|
76
83
|
export {
|
|
77
84
|
AgentType,
|
|
78
85
|
CMType,
|
package/src/types.ts
CHANGED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import fc from 'fast-check';
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import type { DID } from '../../types';
|
|
4
|
+
import { ConnectionManager, TransactionType } from '../connections';
|
|
5
|
+
import { seal } from '../encryption';
|
|
6
|
+
|
|
7
|
+
// Mock fetch globally
|
|
8
|
+
const fetchMock = vi.fn();
|
|
9
|
+
global.fetch = fetchMock;
|
|
10
|
+
|
|
11
|
+
// Helper to generate valid DID strings
|
|
12
|
+
const arbDID = fc
|
|
13
|
+
.tuple(fc.string(), fc.string())
|
|
14
|
+
.map(([method, id]) => `did:${method}:${id}` as DID);
|
|
15
|
+
|
|
16
|
+
// Test helper to create arbitrary ComponentRequests
|
|
17
|
+
const arbComponentRequest = fc.record({
|
|
18
|
+
tx: fc.record({
|
|
19
|
+
requestId: fc.option(fc.uuid(), { nil: undefined }),
|
|
20
|
+
customer: fc.option(
|
|
21
|
+
fc.record({
|
|
22
|
+
name: fc.string(),
|
|
23
|
+
email: fc.option(fc.string(), { nil: undefined }),
|
|
24
|
+
phone: fc.option(fc.string(), { nil: undefined }),
|
|
25
|
+
type: fc.constant(undefined), // Optional PersonType
|
|
26
|
+
accountNumber: fc.option(fc.string(), { nil: undefined }),
|
|
27
|
+
did: fc.option(arbDID, { nil: undefined }),
|
|
28
|
+
verified: fc.option(fc.boolean(), { nil: undefined }),
|
|
29
|
+
website: fc.option(fc.webUrl(), { nil: undefined }),
|
|
30
|
+
geographicAddress: fc.option(fc.constant(undefined), {
|
|
31
|
+
nil: undefined,
|
|
32
|
+
}),
|
|
33
|
+
nationalIdentification: fc.option(fc.constant(undefined), {
|
|
34
|
+
nil: undefined,
|
|
35
|
+
}),
|
|
36
|
+
}),
|
|
37
|
+
{ nil: undefined },
|
|
38
|
+
),
|
|
39
|
+
}),
|
|
40
|
+
authToken: fc.option(fc.string(), { nil: undefined }),
|
|
41
|
+
txOptions: fc.option(fc.record({}), { nil: undefined }),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// New arbitrary for ConnectionMetadata
|
|
45
|
+
const arbConnectionMetadata = fc.record({
|
|
46
|
+
participants: fc.array(fc.string(), { minLength: 1 }), // At least one participant
|
|
47
|
+
nodeUrl: fc.webUrl(),
|
|
48
|
+
transactionType: fc.constantFrom<TransactionType>('withdraw', 'deposit'),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('ConnectionManager', () => {
|
|
52
|
+
let manager: ConnectionManager;
|
|
53
|
+
const testEndpoint = 'https://test-endpoint.com';
|
|
54
|
+
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
manager = new ConnectionManager(testEndpoint);
|
|
57
|
+
fetchMock.mockReset();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('create', () => {
|
|
61
|
+
it('should successfully create a new connection', async () => {
|
|
62
|
+
await fc.assert(
|
|
63
|
+
fc.asyncProperty(
|
|
64
|
+
arbComponentRequest,
|
|
65
|
+
arbConnectionMetadata,
|
|
66
|
+
async (request, metadata) => {
|
|
67
|
+
// Mock successful response
|
|
68
|
+
const mockResponse = {
|
|
69
|
+
id: 'test-id',
|
|
70
|
+
version: 1,
|
|
71
|
+
metadata,
|
|
72
|
+
sealed: ['encrypted-data'],
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
fetchMock.mockResolvedValueOnce({
|
|
76
|
+
ok: true,
|
|
77
|
+
json: async () => mockResponse,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const result = await manager.create(request, metadata);
|
|
81
|
+
|
|
82
|
+
// Verify fetch was called correctly
|
|
83
|
+
expect(fetchMock).toHaveBeenCalledWith(testEndpoint, {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
headers: {
|
|
86
|
+
'Content-Type': 'application/json',
|
|
87
|
+
},
|
|
88
|
+
body: expect.any(String),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Verify response structure
|
|
92
|
+
expect(result).toEqual({
|
|
93
|
+
id: mockResponse.id,
|
|
94
|
+
metadata: mockResponse.metadata,
|
|
95
|
+
version: mockResponse.version,
|
|
96
|
+
data: request,
|
|
97
|
+
key: expect.any(String),
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('should throw error on failed creation', async () => {
|
|
105
|
+
await fc.assert(
|
|
106
|
+
fc.asyncProperty(
|
|
107
|
+
arbComponentRequest,
|
|
108
|
+
arbConnectionMetadata,
|
|
109
|
+
async (request, metadata) => {
|
|
110
|
+
// Mock failed response
|
|
111
|
+
fetchMock.mockResolvedValueOnce({
|
|
112
|
+
ok: false,
|
|
113
|
+
text: async () => 'Creation failed',
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
await expect(manager.create(request, metadata)).rejects.toThrow(
|
|
117
|
+
'Failed to create connection',
|
|
118
|
+
);
|
|
119
|
+
},
|
|
120
|
+
),
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('update', () => {
|
|
126
|
+
it('should successfully update an existing connection', async () => {
|
|
127
|
+
await fc.assert(
|
|
128
|
+
fc.asyncProperty(
|
|
129
|
+
fc.uuid(),
|
|
130
|
+
arbComponentRequest,
|
|
131
|
+
fc.integer(),
|
|
132
|
+
async (id, request, version) => {
|
|
133
|
+
// Mock successful response
|
|
134
|
+
const mockResponse = {
|
|
135
|
+
id,
|
|
136
|
+
metadata: arbConnectionMetadata,
|
|
137
|
+
version: version + 1,
|
|
138
|
+
sealed: ['new-encrypted-data'],
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
fetchMock.mockResolvedValueOnce({
|
|
142
|
+
ok: true,
|
|
143
|
+
json: async () => mockResponse,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const result = await manager.update(id, request, version);
|
|
147
|
+
|
|
148
|
+
// Verify fetch was called correctly
|
|
149
|
+
expect(fetchMock).toHaveBeenCalledWith(`${testEndpoint}/${id}`, {
|
|
150
|
+
method: 'PATCH',
|
|
151
|
+
headers: {
|
|
152
|
+
'Content-Type': 'application/json',
|
|
153
|
+
},
|
|
154
|
+
body: expect.any(String),
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Verify response structure
|
|
158
|
+
expect(result).toEqual({
|
|
159
|
+
id: mockResponse.id,
|
|
160
|
+
version: mockResponse.version,
|
|
161
|
+
metadata: mockResponse.metadata,
|
|
162
|
+
data: request,
|
|
163
|
+
key: expect.any(String),
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
),
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should throw error on failed update', async () => {
|
|
171
|
+
await fc.assert(
|
|
172
|
+
fc.asyncProperty(
|
|
173
|
+
fc.uuid(),
|
|
174
|
+
arbComponentRequest,
|
|
175
|
+
fc.integer(),
|
|
176
|
+
async (id, request, version) => {
|
|
177
|
+
// Mock failed response
|
|
178
|
+
fetchMock.mockResolvedValueOnce({
|
|
179
|
+
ok: false,
|
|
180
|
+
text: async () => 'Update failed',
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
await expect(manager.update(id, request, version)).rejects.toThrow(
|
|
184
|
+
'Failed to update connection',
|
|
185
|
+
);
|
|
186
|
+
},
|
|
187
|
+
),
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
describe('get', () => {
|
|
193
|
+
it('should successfully retrieve and decrypt connection data', async () => {
|
|
194
|
+
// Create a real sealed object to use in our test
|
|
195
|
+
const testData = { requestId: 'test-123' };
|
|
196
|
+
const sealed = await seal(testData);
|
|
197
|
+
|
|
198
|
+
await fc.assert(
|
|
199
|
+
fc.asyncProperty(fc.uuid(), async (id) => {
|
|
200
|
+
// Mock successful response with real encrypted data
|
|
201
|
+
const mockResponse = {
|
|
202
|
+
id,
|
|
203
|
+
version: 1,
|
|
204
|
+
metadata: arbConnectionMetadata,
|
|
205
|
+
sealed: [sealed.ciphertext], // Use the real ciphertext
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
fetchMock.mockResolvedValueOnce({
|
|
209
|
+
ok: true,
|
|
210
|
+
json: async () => mockResponse,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const result = await manager.get(id, sealed.key); // Use the matching key
|
|
214
|
+
|
|
215
|
+
// Verify fetch was called correctly
|
|
216
|
+
expect(fetchMock).toHaveBeenCalledWith(`${testEndpoint}/${id}`, {
|
|
217
|
+
method: 'GET',
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// Verify response structure
|
|
221
|
+
expect(result).toEqual({
|
|
222
|
+
id: mockResponse.id,
|
|
223
|
+
version: mockResponse.version,
|
|
224
|
+
metadata: mockResponse.metadata,
|
|
225
|
+
data: testData, // Should match our original test data
|
|
226
|
+
key: sealed.key,
|
|
227
|
+
});
|
|
228
|
+
}),
|
|
229
|
+
);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('should throw error on failed retrieval', async () => {
|
|
233
|
+
await fc.assert(
|
|
234
|
+
fc.asyncProperty(fc.uuid(), fc.string(), async (id, key) => {
|
|
235
|
+
// Mock failed response
|
|
236
|
+
fetchMock.mockResolvedValueOnce({
|
|
237
|
+
ok: false,
|
|
238
|
+
text: async () => 'Retrieval failed',
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
await expect(manager.get(id, key)).rejects.toThrow(
|
|
242
|
+
'Failed to get connection',
|
|
243
|
+
);
|
|
244
|
+
}),
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
describe('close', () => {
|
|
250
|
+
it('should successfully close a connection', async () => {
|
|
251
|
+
await fc.assert(
|
|
252
|
+
fc.asyncProperty(fc.uuid(), async (id) => {
|
|
253
|
+
// Mock successful response
|
|
254
|
+
fetchMock.mockResolvedValueOnce({
|
|
255
|
+
ok: true,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
await manager.close(id);
|
|
259
|
+
|
|
260
|
+
// Verify fetch was called correctly
|
|
261
|
+
expect(fetchMock).toHaveBeenCalledWith(`${testEndpoint}/${id}`, {
|
|
262
|
+
method: 'DELETE',
|
|
263
|
+
});
|
|
264
|
+
}),
|
|
265
|
+
);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('should throw error on failed closure', async () => {
|
|
269
|
+
await fc.assert(
|
|
270
|
+
fc.asyncProperty(fc.uuid(), async (id) => {
|
|
271
|
+
// Mock failed response
|
|
272
|
+
fetchMock.mockResolvedValueOnce({
|
|
273
|
+
ok: false,
|
|
274
|
+
text: async () => 'Closure failed',
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
await expect(manager.close(id)).rejects.toThrow(
|
|
278
|
+
'Failed to close connection',
|
|
279
|
+
);
|
|
280
|
+
}),
|
|
281
|
+
);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as fc from 'fast-check';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { Agent, AgentType } from '../../types';
|
|
4
|
+
import { seal, unseal } from '../encryption';
|
|
5
|
+
|
|
6
|
+
// Helper to validate that two objects are deeply equal
|
|
7
|
+
function deepEqual(
|
|
8
|
+
obj1: Record<string, unknown>,
|
|
9
|
+
obj2: Record<string, unknown>,
|
|
10
|
+
): boolean {
|
|
11
|
+
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe('normal tests', () => {
|
|
15
|
+
it('should correctly seal and unseal a Javascript object', async () => {
|
|
16
|
+
const agent: Agent = { type: AgentType.VASP, did: 'did:web:hello.com' };
|
|
17
|
+
const sealed = await seal<Agent>(agent);
|
|
18
|
+
const unsealed = await unseal<Agent>(sealed);
|
|
19
|
+
expect(unsealed).toEqual(agent);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
describe('seal and unseal functions with combined IV and ciphertext', () => {
|
|
23
|
+
it('should correctly seal and unseal a JavaScript object', async () => {
|
|
24
|
+
await fc.assert(
|
|
25
|
+
fc.asyncProperty(
|
|
26
|
+
fc.object(), // Generate random objects
|
|
27
|
+
async (originalObject) => {
|
|
28
|
+
const { ciphertext, key } =
|
|
29
|
+
await seal<Record<string, unknown>>(originalObject); // Seal the object
|
|
30
|
+
const unsealedObject = await unseal<Record<string, unknown>>({
|
|
31
|
+
ciphertext,
|
|
32
|
+
key,
|
|
33
|
+
}); // Unseal the ciphertext
|
|
34
|
+
|
|
35
|
+
// Validate that the unsealed object matches the original
|
|
36
|
+
expect(deepEqual(originalObject, unsealedObject)).toBe(true);
|
|
37
|
+
},
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should throw an error if the key is invalid', async () => {
|
|
43
|
+
await fc.assert(
|
|
44
|
+
fc.asyncProperty(
|
|
45
|
+
fc.object(),
|
|
46
|
+
fc.string(), // Generate a random invalid key
|
|
47
|
+
async (originalObject, invalidKey) => {
|
|
48
|
+
const { ciphertext } =
|
|
49
|
+
await seal<Record<string, unknown>>(originalObject);
|
|
50
|
+
|
|
51
|
+
await expect(
|
|
52
|
+
unseal<Record<string, unknown>>({ ciphertext, key: invalidKey }),
|
|
53
|
+
).rejects.toThrowError();
|
|
54
|
+
},
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should throw an error if the ciphertext is tampered with', async () => {
|
|
60
|
+
await fc.assert(
|
|
61
|
+
fc.asyncProperty(fc.object(), async (originalObject) => {
|
|
62
|
+
const { ciphertext, key } =
|
|
63
|
+
await seal<Record<string, unknown>>(originalObject);
|
|
64
|
+
|
|
65
|
+
// Tamper with the ciphertext
|
|
66
|
+
const tamperedCiphertext =
|
|
67
|
+
ciphertext.slice(0, -1) + (ciphertext.at(-1) === 'A' ? 'B' : 'A');
|
|
68
|
+
|
|
69
|
+
// Expect decryption to fail
|
|
70
|
+
await expect(
|
|
71
|
+
unseal<Record<string, unknown>>({
|
|
72
|
+
ciphertext: tamperedCiphertext,
|
|
73
|
+
key,
|
|
74
|
+
}),
|
|
75
|
+
).rejects.toThrowError();
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
});
|