@trustvc/trustvc 1.0.0-alpha.1 → 1.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +138 -0
  2. package/dist/constants.d.mts +3 -0
  3. package/dist/constants.d.ts +3 -0
  4. package/dist/constants.js +5 -0
  5. package/dist/contracts-BsBT1cT2.d.mts +22 -0
  6. package/dist/contracts-BsBT1cT2.d.ts +22 -0
  7. package/dist/contracts-Cbud3a4b.d.mts +22 -0
  8. package/dist/contracts-Cbud3a4b.d.ts +22 -0
  9. package/dist/core/decrypt.d.mts +3 -0
  10. package/dist/core/decrypt.d.ts +3 -0
  11. package/dist/core/decrypt.js +22 -0
  12. package/dist/core/documentBuilder.d.mts +6 -0
  13. package/dist/core/documentBuilder.d.ts +6 -0
  14. package/dist/core/documentBuilder.js +13 -0
  15. package/dist/core/encrypt.d.mts +3 -0
  16. package/dist/core/encrypt.d.ts +3 -0
  17. package/dist/core/encrypt.js +22 -0
  18. package/dist/core/index.d.mts +5 -0
  19. package/dist/core/index.d.ts +5 -0
  20. package/dist/core/index.js +26 -0
  21. package/dist/core/verify.d.mts +6 -0
  22. package/dist/core/verify.d.ts +6 -0
  23. package/dist/core/verify.js +25 -0
  24. package/dist/dnsprove/index.d.mts +1 -0
  25. package/dist/dnsprove/index.d.ts +1 -0
  26. package/dist/dnsprove/index.js +12 -0
  27. package/dist/esm/constants.js +3 -0
  28. package/dist/esm/core/decrypt.js +20 -0
  29. package/dist/esm/core/documentBuilder.js +11 -0
  30. package/dist/esm/core/encrypt.js +20 -0
  31. package/dist/esm/core/index.js +3 -0
  32. package/dist/esm/core/verify.js +23 -0
  33. package/dist/esm/dnsprove/index.js +1 -0
  34. package/dist/esm/index.js +12 -0
  35. package/dist/esm/open-attestation/index.js +5 -0
  36. package/dist/esm/open-attestation/sign.js +15 -0
  37. package/dist/esm/open-attestation/types.js +1 -0
  38. package/dist/esm/open-attestation/utils.js +19 -0
  39. package/dist/esm/open-attestation/verify.js +13 -0
  40. package/dist/esm/open-attestation/wrap.js +33 -0
  41. package/dist/esm/token-registry-v4/contracts.js +1 -0
  42. package/dist/esm/token-registry-v4/index.js +1 -0
  43. package/dist/esm/token-registry-v4/supportInterfaceIds.js +5 -0
  44. package/dist/esm/token-registry-v5/contracts.js +1 -0
  45. package/dist/esm/token-registry-v5/index.js +1 -0
  46. package/dist/esm/token-registry-v5/supportInterfaceIds.js +5 -0
  47. package/dist/esm/utils/fragment/index.js +1 -0
  48. package/dist/esm/utils/index.js +4 -0
  49. package/dist/esm/utils/network/index.js +1 -0
  50. package/dist/esm/utils/stringUtils/index.js +20 -0
  51. package/dist/esm/utils/supportedChains/index.js +1 -0
  52. package/dist/esm/verify/fragments/document-integrity/w3cSignatureIntegrity.js +46 -0
  53. package/dist/esm/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.js +105 -0
  54. package/dist/esm/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.types.js +1 -0
  55. package/dist/esm/verify/fragments/document-status/transferableRecords/utils.js +72 -0
  56. package/dist/esm/verify/fragments/document-status/w3cCredentialStatus.js +52 -0
  57. package/dist/esm/verify/fragments/index.js +5 -0
  58. package/dist/esm/verify/fragments/issuer-identity/w3cIssuerIdentity.js +72 -0
  59. package/dist/esm/verify/index.js +3 -0
  60. package/dist/esm/verify/verify.js +38 -0
  61. package/dist/esm/w3c/context/index.js +1 -0
  62. package/dist/esm/w3c/credential-status/index.js +1 -0
  63. package/dist/esm/w3c/index.js +11 -0
  64. package/dist/esm/w3c/issuer/index.js +1 -0
  65. package/dist/esm/w3c/sign.js +9 -0
  66. package/dist/esm/w3c/types.js +2 -0
  67. package/dist/esm/w3c/vc/index.js +1 -0
  68. package/dist/esm/w3c/verify.js +9 -0
  69. package/dist/index-1ws_BWZW.d.mts +22 -0
  70. package/dist/index-1ws_BWZW.d.ts +22 -0
  71. package/dist/index-CUw8WpjA.d.mts +22 -0
  72. package/dist/index-CjwEVGoM.d.mts +22 -0
  73. package/dist/index-CjwEVGoM.d.ts +22 -0
  74. package/dist/index-ClF4_Nqk.d.mts +22 -0
  75. package/dist/index-ClF4_Nqk.d.ts +22 -0
  76. package/dist/index-DK8Em_TZ.d.ts +22 -0
  77. package/dist/index-DwAYXQn2.d.mts +22 -0
  78. package/dist/index-DwAYXQn2.d.ts +22 -0
  79. package/dist/index.d.mts +46 -0
  80. package/dist/index.d.ts +46 -0
  81. package/dist/index.js +82 -0
  82. package/dist/open-attestation/index.d.mts +13 -0
  83. package/dist/open-attestation/index.d.ts +13 -0
  84. package/dist/open-attestation/index.js +40 -0
  85. package/dist/open-attestation/sign.d.mts +9 -0
  86. package/dist/open-attestation/sign.d.ts +9 -0
  87. package/dist/open-attestation/sign.js +17 -0
  88. package/dist/open-attestation/types.d.mts +9 -0
  89. package/dist/open-attestation/types.d.ts +9 -0
  90. package/dist/open-attestation/types.js +2 -0
  91. package/dist/open-attestation/utils.d.mts +41 -0
  92. package/dist/open-attestation/utils.d.ts +41 -0
  93. package/dist/open-attestation/utils.js +55 -0
  94. package/dist/open-attestation/verify.d.mts +5 -0
  95. package/dist/open-attestation/verify.d.ts +5 -0
  96. package/dist/open-attestation/verify.js +15 -0
  97. package/dist/open-attestation/wrap.d.mts +9 -0
  98. package/dist/open-attestation/wrap.d.ts +9 -0
  99. package/dist/open-attestation/wrap.js +45 -0
  100. package/dist/token-registry-v4/contracts.d.mts +1 -0
  101. package/dist/token-registry-v4/contracts.d.ts +1 -0
  102. package/dist/token-registry-v4/contracts.js +12 -0
  103. package/dist/token-registry-v4/index.d.mts +1 -0
  104. package/dist/token-registry-v4/index.d.ts +1 -0
  105. package/dist/token-registry-v4/index.js +12 -0
  106. package/dist/token-registry-v4/supportInterfaceIds.d.mts +12 -0
  107. package/dist/token-registry-v4/supportInterfaceIds.d.ts +12 -0
  108. package/dist/token-registry-v4/supportInterfaceIds.js +7 -0
  109. package/dist/token-registry-v5/contracts.d.mts +1 -0
  110. package/dist/token-registry-v5/contracts.d.ts +1 -0
  111. package/dist/token-registry-v5/contracts.js +12 -0
  112. package/dist/token-registry-v5/index.d.mts +1 -0
  113. package/dist/token-registry-v5/index.d.ts +1 -0
  114. package/dist/token-registry-v5/index.js +12 -0
  115. package/dist/token-registry-v5/supportInterfaceIds.d.mts +12 -0
  116. package/dist/token-registry-v5/supportInterfaceIds.d.ts +12 -0
  117. package/dist/token-registry-v5/supportInterfaceIds.js +7 -0
  118. package/dist/utils/fragment/index.d.mts +1 -0
  119. package/dist/utils/fragment/index.d.ts +1 -0
  120. package/dist/utils/fragment/index.js +14 -0
  121. package/dist/utils/index.d.mts +4 -0
  122. package/dist/utils/index.d.ts +4 -0
  123. package/dist/utils/index.js +33 -0
  124. package/dist/utils/network/index.d.mts +1 -0
  125. package/dist/utils/network/index.d.ts +1 -0
  126. package/dist/utils/network/index.js +12 -0
  127. package/dist/utils/stringUtils/index.d.mts +9 -0
  128. package/dist/utils/stringUtils/index.d.ts +9 -0
  129. package/dist/utils/stringUtils/index.js +24 -0
  130. package/dist/utils/supportedChains/index.d.mts +1 -0
  131. package/dist/utils/supportedChains/index.d.ts +1 -0
  132. package/dist/utils/supportedChains/index.js +12 -0
  133. package/dist/verify/fragments/document-integrity/w3cSignatureIntegrity.d.mts +5 -0
  134. package/dist/verify/fragments/document-integrity/w3cSignatureIntegrity.d.ts +5 -0
  135. package/dist/verify/fragments/document-integrity/w3cSignatureIntegrity.js +48 -0
  136. package/dist/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.d.mts +7 -0
  137. package/dist/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.d.ts +7 -0
  138. package/dist/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.js +128 -0
  139. package/dist/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.types.d.mts +30 -0
  140. package/dist/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.types.d.ts +30 -0
  141. package/dist/verify/fragments/document-status/transferableRecords/transferableRecordVerifier.types.js +2 -0
  142. package/dist/verify/fragments/document-status/transferableRecords/utils.d.mts +18 -0
  143. package/dist/verify/fragments/document-status/transferableRecords/utils.d.ts +18 -0
  144. package/dist/verify/fragments/document-status/transferableRecords/utils.js +75 -0
  145. package/dist/verify/fragments/document-status/w3cCredentialStatus.d.mts +5 -0
  146. package/dist/verify/fragments/document-status/w3cCredentialStatus.d.ts +5 -0
  147. package/dist/verify/fragments/document-status/w3cCredentialStatus.js +54 -0
  148. package/dist/verify/fragments/index.d.mts +6 -0
  149. package/dist/verify/fragments/index.d.ts +6 -0
  150. package/dist/verify/fragments/index.js +54 -0
  151. package/dist/verify/fragments/issuer-identity/w3cIssuerIdentity.d.mts +5 -0
  152. package/dist/verify/fragments/issuer-identity/w3cIssuerIdentity.d.ts +5 -0
  153. package/dist/verify/fragments/issuer-identity/w3cIssuerIdentity.js +74 -0
  154. package/dist/verify/index.d.mts +9 -0
  155. package/dist/verify/index.d.ts +9 -0
  156. package/dist/verify/index.js +34 -0
  157. package/dist/verify/verify.d.mts +29 -0
  158. package/dist/verify/verify.d.ts +29 -0
  159. package/dist/verify/verify.js +53 -0
  160. package/dist/w3c/context/index.d.mts +1 -0
  161. package/dist/w3c/context/index.d.ts +1 -0
  162. package/dist/w3c/context/index.js +12 -0
  163. package/dist/w3c/credential-status/index.d.mts +1 -0
  164. package/dist/w3c/credential-status/index.d.ts +1 -0
  165. package/dist/w3c/credential-status/index.js +12 -0
  166. package/dist/w3c/index.d.mts +10 -0
  167. package/dist/w3c/index.d.ts +10 -0
  168. package/dist/w3c/index.js +57 -0
  169. package/dist/w3c/issuer/index.d.mts +1 -0
  170. package/dist/w3c/issuer/index.d.ts +1 -0
  171. package/dist/w3c/issuer/index.js +12 -0
  172. package/dist/w3c/sign.d.mts +6 -0
  173. package/dist/w3c/sign.d.ts +6 -0
  174. package/dist/w3c/sign.js +11 -0
  175. package/dist/w3c/types.d.mts +8 -0
  176. package/dist/w3c/types.d.ts +8 -0
  177. package/dist/w3c/types.js +27 -0
  178. package/dist/w3c/vc/index.d.mts +1 -0
  179. package/dist/w3c/vc/index.d.ts +1 -0
  180. package/dist/w3c/vc/index.js +12 -0
  181. package/dist/w3c/verify.d.mts +5 -0
  182. package/dist/w3c/verify.d.ts +5 -0
  183. package/dist/w3c/verify.js +11 -0
  184. package/package.json +101 -8
package/README.md CHANGED
@@ -0,0 +1,138 @@
1
+ # TrustVC
2
+
3
+ ## About
4
+ TrustVC is a wrapper library that facilitates the signing and verification of TrustVC W3C [Verifiable Credentials (VC)](https://github.com/TrustVC/w3c/tree/alpha) 1.0.0-alpha, adhering to the W3C [VC](https://www.w3.org/TR/vc-data-model/) Data Model v1.1 and OpenAttestation [Verifiable Documents (VD)](https://github.com/Open-Attestation/open-attestation/tree/beta) v6.10.0-beta.
5
+
6
+
7
+ ## Functions
8
+ ### 1. **Signing**
9
+
10
+ > Independent signing function for TrustVC W3C VC and OpenAttestation VD
11
+
12
+ 1. OpenAttestation Signing (signOA), supporting only OA Schema [v4](https://github.com/Open-Attestation/open-attestation/tree/beta/src/4.0)
13
+
14
+ > [!NOTE]
15
+ > Do not confuse OA Schema V4 with OA package version.
16
+
17
+ ```ts
18
+ import { wrapOA, signOA } from '@trustvc/trustvc';
19
+
20
+ const rawDocument = {
21
+ '@context': [
22
+ 'https://www.w3.org/ns/credentials/v2',
23
+ 'https://schemata.openattestation.com/com/openattestation/4.0/context.json',
24
+ ],
25
+ type: ['VerifiableCredential', 'OpenAttestationCredential'],
26
+ credentialSubject: {
27
+ id: '0x1234567890123456789012345678901234567890',
28
+ name: 'John Doe',
29
+ country: 'SG',
30
+ },
31
+ issuer: {
32
+ id: 'did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90',
33
+ type: 'OpenAttestationIssuer',
34
+ name: 'Government Technology Agency of Singapore (GovTech)',
35
+ identityProof: { identityProofType: 'DNS-DID', identifier: 'example.openattestation.com' },
36
+ },
37
+ }
38
+
39
+ const wrappedDocument = await wrapOA(rawDocument);
40
+
41
+ const signedWrappedDocument = await signOA(wrappedDocument, {
42
+ public: 'did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90#controller',
43
+ private: '<privateKey>',
44
+ });
45
+ ```
46
+
47
+ 2. TrustVC W3C Signing (signW3C)
48
+
49
+ ```ts
50
+ import { signW3C } from '@trustvc/trustvc';
51
+ import { VerificationType } from '@trustvc/w3c-issuer';
52
+
53
+ const rawDocument = {
54
+ '@context': [
55
+ 'https://www.w3.org/2018/credentials/v1',
56
+ 'https://w3c-ccg.github.io/citizenship-vocab/contexts/citizenship-v1.jsonld',
57
+ 'https://w3id.org/security/bbs/v1',
58
+ 'https://w3id.org/vc/status-list/2021/v1',
59
+ ],
60
+ credentialStatus: {
61
+ id: 'https://trustvc.github.io/did/credentials/statuslist/1#1',
62
+ type: 'StatusList2021Entry',
63
+ statusPurpose: 'revocation',
64
+ statusListIndex: '10',
65
+ statusListCredential: 'https://trustvc.github.io/did/credentials/statuslist/1',
66
+ },
67
+ credentialSubject: {
68
+ name: 'TrustVC',
69
+ birthDate: '2024-04-01T12:19:52Z',
70
+ type: ['PermanentResident', 'Person'],
71
+ },
72
+ expirationDate: '2029-12-03T12:19:52Z',
73
+ issuer: 'did:web:trustvc.github.io:did:1',
74
+ type: ['VerifiableCredential'],
75
+ issuanceDate: '2024-04-01T12:19:52Z'
76
+ }
77
+
78
+ const signingResult = await signW3C(rawDocument, {
79
+ id: 'did:web:trustvc.github.io:did:1#keys-1',
80
+ controller: 'did:web:trustvc.github.io:did:1',
81
+ type: VerificationType.Bls12381G2Key2020,
82
+ publicKeyBase58:
83
+ 'oRfEeWFresvhRtXCkihZbxyoi2JER7gHTJ5psXhHsdCoU1MttRMi3Yp9b9fpjmKh7bMgfWKLESiK2YovRd8KGzJsGuamoAXfqDDVhckxuc9nmsJ84skCSTijKeU4pfAcxeJ',
84
+ privateKeyBase58: '<privateKeyBase58>',
85
+ });
86
+ ```
87
+
88
+ ### 2. **Verifying**
89
+
90
+ > Single verifying function to simplify the process
91
+
92
+ 1. Verify
93
+
94
+ ```ts
95
+ import { verifyDocument } from '@trustvc/trustvc';
96
+
97
+ const signedDocument = {
98
+ '@context': [
99
+ 'https://www.w3.org/2018/credentials/v1',
100
+ 'https://w3c-ccg.github.io/citizenship-vocab/contexts/citizenship-v1.jsonld',
101
+ 'https://w3id.org/security/bbs/v1',
102
+ 'https://w3id.org/vc/status-list/2021/v1',
103
+ ],
104
+ credentialStatus: {
105
+ id: 'https://trustvc.github.io/did/credentials/statuslist/1#1',
106
+ type: 'StatusList2021Entry',
107
+ statusPurpose: 'revocation',
108
+ statusListIndex: '10',
109
+ statusListCredential: 'https://trustvc.github.io/did/credentials/statuslist/1',
110
+ },
111
+ credentialSubject: {
112
+ name: 'TrustVC',
113
+ birthDate: '2024-04-01T12:19:52Z',
114
+ type: ['PermanentResident', 'Person'],
115
+ },
116
+ expirationDate: '2029-12-03T12:19:52Z',
117
+ issuer: 'did:web:trustvc.github.io:did:1',
118
+ type: ['VerifiableCredential'],
119
+ issuanceDate: '2024-04-01T12:19:52Z',
120
+ proof: {
121
+ type: 'BbsBlsSignature2020',
122
+ created: '2024-10-14T04:11:49Z',
123
+ proofPurpose: 'assertionMethod',
124
+ proofValue:
125
+ 'l79dlFQMowalep+WCFqgCvpVBcCAr0GDEFUV6S7gRVY/TQ+sp/wcwaT61PaD19rJYUHlKfzccE4m7waZyoLEkBLFiK2g54Q2i+CdtYBgDdkUDsoULSBMcH1MwGHwdjfXpldFNFrHFx/IAvLVniyeMQ==',
126
+ verificationMethod: 'did:web:trustvc.github.io:did:1#keys-1',
127
+ },
128
+ }
129
+
130
+ const resultFragments = await verifyDocument(signedDocument);
131
+ ```
132
+
133
+ ## Running the code
134
+ ```
135
+ npm install
136
+ npm run build
137
+ npm run test
138
+ ```
@@ -0,0 +1,3 @@
1
+ declare const DEFAULT_KEY = "4d5a4e3f2f6d2b0a1f2e9b8f8a3c7a0b8d4f5c2e7b1a1c3f2e7b8c2d5a4f7e3e";
2
+
3
+ export { DEFAULT_KEY };
@@ -0,0 +1,3 @@
1
+ declare const DEFAULT_KEY = "4d5a4e3f2f6d2b0a1f2e9b8f8a3c7a0b8d4f5c2e7b1a1c3f2e7b8c2d5a4f7e3e";
2
+
3
+ export { DEFAULT_KEY };
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const DEFAULT_KEY = "4d5a4e3f2f6d2b0a1f2e9b8f8a3c7a0b8d4f5c2e7b1a1c3f2e7b8c2d5a4f7e3e";
4
+
5
+ exports.DEFAULT_KEY = DEFAULT_KEY;
@@ -0,0 +1,22 @@
1
+ import * as contracts$1 from '@tradetrust-tt/token-registry-v4/contracts';
2
+
3
+ function _mergeNamespaces(n, m) {
4
+ m.forEach(function (e) {
5
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
6
+ if (k !== 'default' && !(k in n)) {
7
+ var d = Object.getOwnPropertyDescriptor(e, k);
8
+ Object.defineProperty(n, k, d.get ? d : {
9
+ enumerable: true,
10
+ get: function () { return e[k]; }
11
+ });
12
+ }
13
+ });
14
+ });
15
+ return Object.freeze(n);
16
+ }
17
+
18
+ var contracts = /*#__PURE__*/_mergeNamespaces({
19
+ __proto__: null
20
+ }, [contracts$1]);
21
+
22
+ export { contracts as c };
@@ -0,0 +1,22 @@
1
+ import * as contracts$1 from '@tradetrust-tt/token-registry-v4/contracts';
2
+
3
+ function _mergeNamespaces(n, m) {
4
+ m.forEach(function (e) {
5
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
6
+ if (k !== 'default' && !(k in n)) {
7
+ var d = Object.getOwnPropertyDescriptor(e, k);
8
+ Object.defineProperty(n, k, d.get ? d : {
9
+ enumerable: true,
10
+ get: function () { return e[k]; }
11
+ });
12
+ }
13
+ });
14
+ });
15
+ return Object.freeze(n);
16
+ }
17
+
18
+ var contracts = /*#__PURE__*/_mergeNamespaces({
19
+ __proto__: null
20
+ }, [contracts$1]);
21
+
22
+ export { contracts as c };
@@ -0,0 +1,22 @@
1
+ import * as contracts$1 from '@tradetrust-tt/token-registry-v5/contracts';
2
+
3
+ function _mergeNamespaces(n, m) {
4
+ m.forEach(function (e) {
5
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
6
+ if (k !== 'default' && !(k in n)) {
7
+ var d = Object.getOwnPropertyDescriptor(e, k);
8
+ Object.defineProperty(n, k, d.get ? d : {
9
+ enumerable: true,
10
+ get: function () { return e[k]; }
11
+ });
12
+ }
13
+ });
14
+ });
15
+ return Object.freeze(n);
16
+ }
17
+
18
+ var contracts = /*#__PURE__*/_mergeNamespaces({
19
+ __proto__: null
20
+ }, [contracts$1]);
21
+
22
+ export { contracts as c };
@@ -0,0 +1,22 @@
1
+ import * as contracts$1 from '@tradetrust-tt/token-registry-v5/contracts';
2
+
3
+ function _mergeNamespaces(n, m) {
4
+ m.forEach(function (e) {
5
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
6
+ if (k !== 'default' && !(k in n)) {
7
+ var d = Object.getOwnPropertyDescriptor(e, k);
8
+ Object.defineProperty(n, k, d.get ? d : {
9
+ enumerable: true,
10
+ get: function () { return e[k]; }
11
+ });
12
+ }
13
+ });
14
+ });
15
+ return Object.freeze(n);
16
+ }
17
+
18
+ var contracts = /*#__PURE__*/_mergeNamespaces({
19
+ __proto__: null
20
+ }, [contracts$1]);
21
+
22
+ export { contracts as c };
@@ -0,0 +1,3 @@
1
+ declare function decrypt(encryptedMessage: string, key: string, nonce?: string): string;
2
+
3
+ export { decrypt };
@@ -0,0 +1,3 @@
1
+ declare function decrypt(encryptedMessage: string, key: string, nonce?: string): string;
2
+
3
+ export { decrypt };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var constants = require('../constants');
4
+ var stringUtils = require('../utils/stringUtils');
5
+ var tsChacha20 = require('ts-chacha20');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ function decrypt(encryptedMessage, key, nonce) {
10
+ key = key.length > 0 ? key : constants.DEFAULT_KEY;
11
+ key = stringUtils.generate32ByteKey(key);
12
+ nonce = stringUtils.generate12ByteNonce(nonce ?? "");
13
+ const keyBuffer = stringUtils.stringToUint8Array(key);
14
+ const nonceBuffer = stringUtils.stringToUint8Array(nonce);
15
+ const chacha20 = new tsChacha20.Chacha20(keyBuffer, nonceBuffer);
16
+ const encryptedBuffer = new Uint8Array(Buffer.from(encryptedMessage, "hex"));
17
+ const decrypted = chacha20.decrypt(encryptedBuffer);
18
+ return Buffer.from(decrypted).toString("utf-8");
19
+ }
20
+ __name(decrypt, "decrypt");
21
+
22
+ exports.decrypt = decrypt;
@@ -0,0 +1,6 @@
1
+ declare class DocumentBuilder {
2
+ document: DocumentBuilder;
3
+ constructor();
4
+ }
5
+
6
+ export { DocumentBuilder };
@@ -0,0 +1,6 @@
1
+ declare class DocumentBuilder {
2
+ document: DocumentBuilder;
3
+ constructor();
4
+ }
5
+
6
+ export { DocumentBuilder };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const _DocumentBuilder = class _DocumentBuilder {
6
+ constructor() {
7
+ this.document = new _DocumentBuilder();
8
+ }
9
+ };
10
+ __name(_DocumentBuilder, "DocumentBuilder");
11
+ let DocumentBuilder = _DocumentBuilder;
12
+
13
+ exports.DocumentBuilder = DocumentBuilder;
@@ -0,0 +1,3 @@
1
+ declare function encrypt(message: string, key: string, nonce?: string): string;
2
+
3
+ export { encrypt };
@@ -0,0 +1,3 @@
1
+ declare function encrypt(message: string, key: string, nonce?: string): string;
2
+
3
+ export { encrypt };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var constants = require('../constants');
4
+ var stringUtils = require('../utils/stringUtils');
5
+ var tsChacha20 = require('ts-chacha20');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ function encrypt(message, key, nonce) {
10
+ key = key.length > 0 ? key : constants.DEFAULT_KEY;
11
+ key = stringUtils.generate32ByteKey(key);
12
+ nonce = stringUtils.generate12ByteNonce(nonce ?? "");
13
+ const keyBuffer = stringUtils.stringToUint8Array(key);
14
+ const nonceBuffer = stringUtils.stringToUint8Array(nonce);
15
+ const chacha20 = new tsChacha20.Chacha20(keyBuffer, nonceBuffer);
16
+ const messageBuffer = stringUtils.stringToUint8Array(message);
17
+ const encrypted = chacha20.encrypt(messageBuffer);
18
+ return Buffer.from(encrypted).toString("hex");
19
+ }
20
+ __name(encrypt, "encrypt");
21
+
22
+ exports.encrypt = encrypt;
@@ -0,0 +1,5 @@
1
+ export { decrypt } from './decrypt.mjs';
2
+ export { encrypt } from './encrypt.mjs';
3
+ export { verifyDocument } from './verify.mjs';
4
+ import '@trustvc/w3c-vc';
5
+ import '@tradetrust-tt/tt-verify/dist/types/src/types/core';
@@ -0,0 +1,5 @@
1
+ export { decrypt } from './decrypt.js';
2
+ export { encrypt } from './encrypt.js';
3
+ export { verifyDocument } from './verify.js';
4
+ import '@trustvc/w3c-vc';
5
+ import '@tradetrust-tt/tt-verify/dist/types/src/types/core';
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var decrypt = require('./decrypt');
4
+ var encrypt = require('./encrypt');
5
+ var verify = require('./verify');
6
+
7
+
8
+
9
+ Object.keys(decrypt).forEach(function (k) {
10
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
11
+ enumerable: true,
12
+ get: function () { return decrypt[k]; }
13
+ });
14
+ });
15
+ Object.keys(encrypt).forEach(function (k) {
16
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
17
+ enumerable: true,
18
+ get: function () { return encrypt[k]; }
19
+ });
20
+ });
21
+ Object.keys(verify).forEach(function (k) {
22
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
23
+ enumerable: true,
24
+ get: function () { return verify[k]; }
25
+ });
26
+ });
@@ -0,0 +1,6 @@
1
+ import { SignedVerifiableCredential } from '@trustvc/w3c-vc';
2
+ import { DocumentsToVerify, VerificationFragment } from '@tradetrust-tt/tt-verify/dist/types/src/types/core';
3
+
4
+ declare const verifyDocument: (document: DocumentsToVerify | SignedVerifiableCredential, rpcProviderUrl: string) => Promise<VerificationFragment[]>;
5
+
6
+ export { verifyDocument };
@@ -0,0 +1,6 @@
1
+ import { SignedVerifiableCredential } from '@trustvc/w3c-vc';
2
+ import { DocumentsToVerify, VerificationFragment } from '@tradetrust-tt/tt-verify/dist/types/src/types/core';
3
+
4
+ declare const verifyDocument: (document: DocumentsToVerify | SignedVerifiableCredential, rpcProviderUrl: string) => Promise<VerificationFragment[]>;
5
+
6
+ export { verifyDocument };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var tradetrust = require('@tradetrust-tt/tradetrust');
4
+ var ethers = require('ethers');
5
+ var verify = require('../verify');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ const verifyDocument = /* @__PURE__ */ __name(async (document, rpcProviderUrl) => {
10
+ if (tradetrust.utils.isWrappedV2Document(document) || tradetrust.utils.isWrappedV3Document(document)) {
11
+ const verify$1 = verify.verificationBuilder(verify.openAttestationVerifiers, {
12
+ provider: new ethers.ethers.providers.JsonRpcProvider(rpcProviderUrl)
13
+ // Use user-provided provider URL
14
+ });
15
+ return verify$1(document);
16
+ } else {
17
+ const verify$1 = verify.verificationBuilder(verify.w3cVerifiers, {
18
+ provider: new ethers.ethers.providers.JsonRpcProvider(rpcProviderUrl)
19
+ // Use user-provided provider URL
20
+ });
21
+ return verify$1(document);
22
+ }
23
+ }, "verifyDocument");
24
+
25
+ exports.verifyDocument = verifyDocument;
@@ -0,0 +1 @@
1
+ export * from '@tradetrust-tt/dnsprove';
@@ -0,0 +1 @@
1
+ export * from '@tradetrust-tt/dnsprove';
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var dnsprove = require('@tradetrust-tt/dnsprove');
4
+
5
+
6
+
7
+ Object.keys(dnsprove).forEach(function (k) {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9
+ enumerable: true,
10
+ get: function () { return dnsprove[k]; }
11
+ });
12
+ });
@@ -0,0 +1,3 @@
1
+ const DEFAULT_KEY = "4d5a4e3f2f6d2b0a1f2e9b8f8a3c7a0b8d4f5c2e7b1a1c3f2e7b8c2d5a4f7e3e";
2
+
3
+ export { DEFAULT_KEY };
@@ -0,0 +1,20 @@
1
+ import { DEFAULT_KEY } from '../constants';
2
+ import { generate32ByteKey, generate12ByteNonce, stringToUint8Array } from '../utils/stringUtils';
3
+ import { Chacha20 } from 'ts-chacha20';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ function decrypt(encryptedMessage, key, nonce) {
8
+ key = key.length > 0 ? key : DEFAULT_KEY;
9
+ key = generate32ByteKey(key);
10
+ nonce = generate12ByteNonce(nonce ?? "");
11
+ const keyBuffer = stringToUint8Array(key);
12
+ const nonceBuffer = stringToUint8Array(nonce);
13
+ const chacha20 = new Chacha20(keyBuffer, nonceBuffer);
14
+ const encryptedBuffer = new Uint8Array(Buffer.from(encryptedMessage, "hex"));
15
+ const decrypted = chacha20.decrypt(encryptedBuffer);
16
+ return Buffer.from(decrypted).toString("utf-8");
17
+ }
18
+ __name(decrypt, "decrypt");
19
+
20
+ export { decrypt };
@@ -0,0 +1,11 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ const _DocumentBuilder = class _DocumentBuilder {
4
+ constructor() {
5
+ this.document = new _DocumentBuilder();
6
+ }
7
+ };
8
+ __name(_DocumentBuilder, "DocumentBuilder");
9
+ let DocumentBuilder = _DocumentBuilder;
10
+
11
+ export { DocumentBuilder };
@@ -0,0 +1,20 @@
1
+ import { DEFAULT_KEY } from '../constants';
2
+ import { generate32ByteKey, generate12ByteNonce, stringToUint8Array } from '../utils/stringUtils';
3
+ import { Chacha20 } from 'ts-chacha20';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ function encrypt(message, key, nonce) {
8
+ key = key.length > 0 ? key : DEFAULT_KEY;
9
+ key = generate32ByteKey(key);
10
+ nonce = generate12ByteNonce(nonce ?? "");
11
+ const keyBuffer = stringToUint8Array(key);
12
+ const nonceBuffer = stringToUint8Array(nonce);
13
+ const chacha20 = new Chacha20(keyBuffer, nonceBuffer);
14
+ const messageBuffer = stringToUint8Array(message);
15
+ const encrypted = chacha20.encrypt(messageBuffer);
16
+ return Buffer.from(encrypted).toString("hex");
17
+ }
18
+ __name(encrypt, "encrypt");
19
+
20
+ export { encrypt };
@@ -0,0 +1,3 @@
1
+ export * from './decrypt';
2
+ export * from './encrypt';
3
+ export * from './verify';
@@ -0,0 +1,23 @@
1
+ import { utils } from '@tradetrust-tt/tradetrust';
2
+ import { ethers } from 'ethers';
3
+ import { verificationBuilder, openAttestationVerifiers, w3cVerifiers } from '../verify';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const verifyDocument = /* @__PURE__ */ __name(async (document, rpcProviderUrl) => {
8
+ if (utils.isWrappedV2Document(document) || utils.isWrappedV3Document(document)) {
9
+ const verify = verificationBuilder(openAttestationVerifiers, {
10
+ provider: new ethers.providers.JsonRpcProvider(rpcProviderUrl)
11
+ // Use user-provided provider URL
12
+ });
13
+ return verify(document);
14
+ } else {
15
+ const verify = verificationBuilder(w3cVerifiers, {
16
+ provider: new ethers.providers.JsonRpcProvider(rpcProviderUrl)
17
+ // Use user-provided provider URL
18
+ });
19
+ return verify(document);
20
+ }
21
+ }, "verifyDocument");
22
+
23
+ export { verifyDocument };
@@ -0,0 +1 @@
1
+ export * from '@tradetrust-tt/dnsprove';
@@ -0,0 +1,12 @@
1
+ export { supportInterfaceIds as v4SupportInterfaceIds } from './token-registry-v4/supportInterfaceIds';
2
+ export { supportInterfaceIds as v5SupportInterfaceIds } from './token-registry-v5/supportInterfaceIds';
3
+ import * as contracts from './token-registry-v4/contracts';
4
+ export { contracts as v4Contracts };
5
+ import * as contracts$1 from './token-registry-v5/contracts';
6
+ export { contracts$1 as v5Contracts };
7
+ export * from './core';
8
+ export * from './open-attestation';
9
+ export * from './verify';
10
+ export * from './w3c';
11
+ export * from './utils';
12
+ export * from './dnsprove';
@@ -0,0 +1,5 @@
1
+ export * from './sign';
2
+ export * from './types';
3
+ export * from './utils';
4
+ export * from './verify';
5
+ export * from './wrap';
@@ -0,0 +1,15 @@
1
+ import { signDocument, SUPPORTED_SIGNING_ALGORITHM } from '@tradetrust-tt/tradetrust';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ async function signOA(document, keyPair) {
6
+ return signDocument(
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ document,
9
+ SUPPORTED_SIGNING_ALGORITHM.Secp256k1VerificationKey2018,
10
+ keyPair
11
+ );
12
+ }
13
+ __name(signOA, "signOA");
14
+
15
+ export { signOA };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,19 @@
1
+ import { utils } from '@tradetrust-tt/tradetrust';
2
+ export { SUPPORTED_SIGNING_ALGORITHM, SchemaId, getData as getDataV2, isSchemaValidationError, obfuscateDocument, validateSchema } from '@tradetrust-tt/tradetrust';
3
+
4
+ const {
5
+ isTransferableAsset,
6
+ getAssetId,
7
+ isWrappedV2Document,
8
+ isSignedWrappedV2Document,
9
+ isWrappedV3Document,
10
+ isSignedWrappedV3Document,
11
+ isRawV2Document,
12
+ isRawV3Document,
13
+ isObfuscated,
14
+ getDocumentData,
15
+ getIssuerAddress,
16
+ diagnose
17
+ } = utils;
18
+
19
+ export { diagnose, getAssetId, getDocumentData, getIssuerAddress, isObfuscated, isRawV2Document, isRawV3Document, isSignedWrappedV2Document, isSignedWrappedV3Document, isTransferableAsset, isWrappedV2Document, isWrappedV3Document };
@@ -0,0 +1,13 @@
1
+ import { utils, verifySignature } from '@tradetrust-tt/tradetrust';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const verifyOASignature = /* @__PURE__ */ __name(async (document) => {
6
+ if (utils.isWrappedV2Document(document) || utils.isWrappedV3Document(document)) {
7
+ return verifySignature(document);
8
+ } else {
9
+ return false;
10
+ }
11
+ }, "verifyOASignature");
12
+
13
+ export { verifyOASignature };
@@ -0,0 +1,33 @@
1
+ import { wrapDocument, wrapDocuments, utils, __unsafe__use__it__at__your__own__risks__wrapDocument, __unsafe__use__it__at__your__own__risks__wrapDocuments } from '@tradetrust-tt/tradetrust';
2
+ export { __unsafe__use__it__at__your__own__risks__wrapDocument as wrapOADocumentV3, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapOADocumentsV3 } from '@tradetrust-tt/tradetrust';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ const wrapOADocumentV2 = /* @__PURE__ */ __name(async (document) => {
7
+ return wrapDocument(document);
8
+ }, "wrapOADocumentV2");
9
+ const wrapOADocumentsV2 = /* @__PURE__ */ __name(async (documents) => {
10
+ return wrapDocuments(documents);
11
+ }, "wrapOADocumentsV2");
12
+ async function wrapOADocument(document) {
13
+ if (utils.isRawV2Document(document)) {
14
+ return wrapOADocumentV2(document);
15
+ } else if (utils.isRawV3Document(document)) {
16
+ return __unsafe__use__it__at__your__own__risks__wrapDocument(document);
17
+ } else {
18
+ throw new Error("Unsupported document version");
19
+ }
20
+ }
21
+ __name(wrapOADocument, "wrapOADocument");
22
+ async function wrapOADocuments(documents) {
23
+ if (documents.every((s) => utils.isRawV2Document(s))) {
24
+ return wrapOADocumentsV2(documents);
25
+ } else if (documents.every((s) => utils.isRawV3Document(s))) {
26
+ return __unsafe__use__it__at__your__own__risks__wrapDocuments(documents);
27
+ } else {
28
+ throw new Error("Unsupported documents version");
29
+ }
30
+ }
31
+ __name(wrapOADocuments, "wrapOADocuments");
32
+
33
+ export { wrapOADocument, wrapOADocumentV2, wrapOADocuments, wrapOADocumentsV2 };
@@ -0,0 +1 @@
1
+ export * from '@tradetrust-tt/token-registry-v4/contracts';