@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
@@ -0,0 +1 @@
1
+ export * from '@tradetrust-tt/token-registry-v4';
@@ -0,0 +1,5 @@
1
+ import { constants } from '@tradetrust-tt/token-registry-v4';
2
+
3
+ const supportInterfaceIds = constants.contractInterfaceId;
4
+
5
+ export { supportInterfaceIds };
@@ -0,0 +1 @@
1
+ export * from '@tradetrust-tt/token-registry-v5/contracts';
@@ -0,0 +1 @@
1
+ export * from '@tradetrust-tt/token-registry-v5';
@@ -0,0 +1,5 @@
1
+ import { constants } from '@tradetrust-tt/token-registry-v5';
2
+
3
+ const supportInterfaceIds = constants.contractInterfaceId;
4
+
5
+ export { supportInterfaceIds };
@@ -0,0 +1 @@
1
+ export { errorMessageHandling, interpretFragments } from '@tradetrust-tt/tradetrust-utils';
@@ -0,0 +1,4 @@
1
+ export * from './fragment';
2
+ export * from './network';
3
+ export * from './stringUtils';
4
+ export * from './supportedChains';
@@ -0,0 +1 @@
1
+ export * from '@tradetrust-tt/tradetrust-utils/constants/network';
@@ -0,0 +1,20 @@
1
+ import { shake256 } from 'js-sha3';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ function stringToUint8Array(str) {
6
+ return new Uint8Array(Buffer.from(str, "utf-8"));
7
+ }
8
+ __name(stringToUint8Array, "stringToUint8Array");
9
+ function generate32ByteKey(input) {
10
+ const hash = shake256(input, 128);
11
+ return hash;
12
+ }
13
+ __name(generate32ByteKey, "generate32ByteKey");
14
+ function generate12ByteNonce(input) {
15
+ const nonce = shake256(input, 48);
16
+ return nonce;
17
+ }
18
+ __name(generate12ByteNonce, "generate12ByteNonce");
19
+
20
+ export { generate12ByteNonce, generate32ByteKey, stringToUint8Array };
@@ -0,0 +1 @@
1
+ export * from '@tradetrust-tt/tradetrust-utils/constants/supportedChains';
@@ -0,0 +1,46 @@
1
+ import { verifyW3CSignature } from '../../..';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const w3cSignatureIntegrity = {
6
+ skip: /* @__PURE__ */ __name(async () => {
7
+ return {
8
+ type: "DOCUMENT_INTEGRITY",
9
+ name: "W3CSignatureIntegrity",
10
+ reason: {
11
+ code: 0,
12
+ codeString: "SKIPPED",
13
+ message: `Document either has no proof or proof.type is not 'BbsBlsSignature2020'.`
14
+ },
15
+ status: "SKIPPED"
16
+ };
17
+ }, "skip"),
18
+ test: /* @__PURE__ */ __name((document) => {
19
+ const doc = document;
20
+ return doc.proof?.type === "BbsBlsSignature2020";
21
+ }, "test"),
22
+ verify: /* @__PURE__ */ __name(async (document) => {
23
+ const doc = document;
24
+ const verificationResult = await verifyW3CSignature(doc);
25
+ if (verificationResult.verified) {
26
+ return {
27
+ type: "DOCUMENT_INTEGRITY",
28
+ name: "W3CSignatureIntegrity",
29
+ data: true,
30
+ status: "VALID"
31
+ };
32
+ } else {
33
+ return {
34
+ type: "DOCUMENT_INTEGRITY",
35
+ name: "W3CSignatureIntegrity",
36
+ data: false,
37
+ reason: {
38
+ message: verificationResult.error
39
+ },
40
+ status: "INVALID"
41
+ };
42
+ }
43
+ }, "verify")
44
+ };
45
+
46
+ export { w3cSignatureIntegrity };
@@ -0,0 +1,105 @@
1
+ import { OpenAttestationEthereumTokenRegistryStatusCode, CodedError, ValidTokenRegistryStatus } from '@tradetrust-tt/tt-verify';
2
+ import * as w3cVC from '@trustvc/w3c-vc';
3
+ import { isTokenMintedOnRegistry } from './utils';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const TRANSFERABLE_RECORDS_TYPE = "TransferableRecords";
8
+ const type = "DOCUMENT_STATUS";
9
+ const name = TRANSFERABLE_RECORDS_TYPE;
10
+ const verify = /* @__PURE__ */ __name(async (document, options) => {
11
+ let signedDocument;
12
+ let tokenId;
13
+ if (w3cVC.isSignedDocument(document)) {
14
+ signedDocument = document;
15
+ tokenId = "0x" + signedDocument?.credentialStatus?.tokenId;
16
+ }
17
+ const credentialStatus = signedDocument?.credentialStatus;
18
+ if (!credentialStatus?.tokenRegistry) {
19
+ throw new CodedError(
20
+ "Document's credentialStatus does not have tokenRegistry",
21
+ OpenAttestationEthereumTokenRegistryStatusCode.UNRECOGNIZED_DOCUMENT,
22
+ OpenAttestationEthereumTokenRegistryStatusCode[OpenAttestationEthereumTokenRegistryStatusCode.UNRECOGNIZED_DOCUMENT]
23
+ );
24
+ }
25
+ if (!credentialStatus?.tokenNetwork || !credentialStatus?.tokenNetwork?.chainId) {
26
+ throw new CodedError(
27
+ "Document's credentialStatus does not have tokenNetwork.chainId",
28
+ OpenAttestationEthereumTokenRegistryStatusCode.UNRECOGNIZED_DOCUMENT,
29
+ OpenAttestationEthereumTokenRegistryStatusCode[OpenAttestationEthereumTokenRegistryStatusCode.UNRECOGNIZED_DOCUMENT]
30
+ );
31
+ }
32
+ const { provider } = options;
33
+ const mintStatus = await isTokenMintedOnRegistry({
34
+ tokenRegistryAddress: credentialStatus?.tokenRegistry,
35
+ tokenId,
36
+ provider
37
+ });
38
+ const result = {
39
+ name,
40
+ type,
41
+ status: "INVALID",
42
+ data: {
43
+ tokenRegistry: credentialStatus.tokenRegistry
44
+ }
45
+ };
46
+ if (ValidTokenRegistryStatus.guard(mintStatus)) {
47
+ result.status = "VALID";
48
+ } else {
49
+ result.reason = mintStatus.reason;
50
+ }
51
+ return result;
52
+ }, "verify");
53
+ const skip = /* @__PURE__ */ __name(async () => {
54
+ return {
55
+ status: "SKIPPED",
56
+ type,
57
+ name,
58
+ reason: {
59
+ code: OpenAttestationEthereumTokenRegistryStatusCode.SKIPPED,
60
+ codeString: OpenAttestationEthereumTokenRegistryStatusCode[OpenAttestationEthereumTokenRegistryStatusCode.SKIPPED],
61
+ message: `Document does not have TransferableRecords status`
62
+ }
63
+ };
64
+ }, "skip");
65
+ const test = /* @__PURE__ */ __name((document) => {
66
+ if (document?.credentialStatus?.type === TRANSFERABLE_RECORDS_TYPE) {
67
+ return true;
68
+ }
69
+ return false;
70
+ }, "test");
71
+ const credentialStatusTransferableRecordVerifier = {
72
+ skip,
73
+ test,
74
+ verify: /* @__PURE__ */ __name(async (...args) => {
75
+ try {
76
+ return await verify(...args);
77
+ } catch (e) {
78
+ if (e instanceof CodedError) {
79
+ const err = {
80
+ name,
81
+ type,
82
+ status: "ERROR",
83
+ reason: {
84
+ code: e.code,
85
+ codeString: e.codeString,
86
+ message: e.message
87
+ }
88
+ };
89
+ return err;
90
+ }
91
+ return {
92
+ name,
93
+ type,
94
+ status: "ERROR",
95
+ reason: {
96
+ code: OpenAttestationEthereumTokenRegistryStatusCode.UNEXPECTED_ERROR,
97
+ codeString: OpenAttestationEthereumTokenRegistryStatusCode[OpenAttestationEthereumTokenRegistryStatusCode.UNEXPECTED_ERROR],
98
+ message: e instanceof Error ? e.message : "An unexpected error occurred"
99
+ }
100
+ };
101
+ }
102
+ }, "verify")
103
+ };
104
+
105
+ export { TRANSFERABLE_RECORDS_TYPE, credentialStatusTransferableRecordVerifier };
@@ -0,0 +1,72 @@
1
+ import { TradeTrustToken__factory } from '@tradetrust-tt/token-registry-v5/dist/contracts';
2
+ import { CodedError, OpenAttestationEthereumTokenRegistryStatusCode } from '@tradetrust-tt/tt-verify';
3
+ import { errors, constants } from 'ethers';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const isNonExistentToken = /* @__PURE__ */ __name((error) => {
8
+ const message = error.message;
9
+ if (!message) {
10
+ return error.data && error.data.slice(0, 10) === "0x7e273289";
11
+ }
12
+ return message.includes("owner query for nonexistent token");
13
+ }, "isNonExistentToken");
14
+ const isMissingTokenRegistry = /* @__PURE__ */ __name((error) => {
15
+ return !error.reason && error.method?.toLowerCase() === "ownerOf(uint256)".toLowerCase() && error.code === errors.CALL_EXCEPTION;
16
+ }, "isMissingTokenRegistry");
17
+ const decodeError = /* @__PURE__ */ __name((error) => {
18
+ const reason = error.reason && Array.isArray(error.reason) ? error.reason[0] : error.reason ?? "";
19
+ switch (true) {
20
+ case isNonExistentToken(error):
21
+ return `Document has not been issued under token registry`;
22
+ case isMissingTokenRegistry(error):
23
+ return `Token registry is not found`;
24
+ case (reason.toLowerCase() === "ENS name not configured".toLowerCase() && error.code === errors.UNSUPPORTED_OPERATION):
25
+ return "ENS name is not configured";
26
+ case (reason.toLowerCase() === "invalid address".toLowerCase() && error.code === errors.INVALID_ARGUMENT):
27
+ return `Invalid token registry address`;
28
+ case error.code === errors.INVALID_ARGUMENT:
29
+ return `Invalid contract arguments`;
30
+ case error.code === errors.SERVER_ERROR:
31
+ case error.code === errors.NETWORK_ERROR:
32
+ throw new CodedError(
33
+ "Unable to connect to the network, please try again later",
34
+ OpenAttestationEthereumTokenRegistryStatusCode.SERVER_ERROR,
35
+ OpenAttestationEthereumTokenRegistryStatusCode[OpenAttestationEthereumTokenRegistryStatusCode.SERVER_ERROR]
36
+ );
37
+ default:
38
+ throw error;
39
+ }
40
+ }, "decodeError");
41
+ const isTokenMintedOnRegistry = /* @__PURE__ */ __name(async ({
42
+ tokenRegistryAddress,
43
+ tokenId,
44
+ provider
45
+ }) => {
46
+ try {
47
+ const tokenRegistryContract = TradeTrustToken__factory.connect(tokenRegistryAddress, provider);
48
+ const minted = await tokenRegistryContract.ownerOf(tokenId).then((owner) => owner !== constants.AddressZero);
49
+ return minted ? { minted, address: tokenRegistryAddress } : {
50
+ minted,
51
+ address: tokenRegistryAddress,
52
+ reason: {
53
+ code: OpenAttestationEthereumTokenRegistryStatusCode.DOCUMENT_NOT_MINTED,
54
+ codeString: OpenAttestationEthereumTokenRegistryStatusCode[OpenAttestationEthereumTokenRegistryStatusCode.DOCUMENT_NOT_MINTED],
55
+ message: `Document ${tokenId} has not been issued under contract ${tokenRegistryAddress}`
56
+ }
57
+ };
58
+ } catch (error) {
59
+ return {
60
+ minted: false,
61
+ address: tokenRegistryAddress,
62
+ reason: {
63
+ message: decodeError(error),
64
+ // message: (error as Error).message,
65
+ code: OpenAttestationEthereumTokenRegistryStatusCode.DOCUMENT_NOT_MINTED,
66
+ codeString: OpenAttestationEthereumTokenRegistryStatusCode[OpenAttestationEthereumTokenRegistryStatusCode.DOCUMENT_NOT_MINTED]
67
+ }
68
+ };
69
+ }
70
+ }, "isTokenMintedOnRegistry");
71
+
72
+ export { decodeError, isTokenMintedOnRegistry };
@@ -0,0 +1,52 @@
1
+ import { verifyCredentialStatus } from '@trustvc/w3c-vc';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const w3cCredentialStatus = {
6
+ skip: /* @__PURE__ */ __name(async () => {
7
+ return {
8
+ type: "DOCUMENT_STATUS",
9
+ name: "W3CCredentialStatus",
10
+ reason: {
11
+ code: 0,
12
+ codeString: "SKIPPED",
13
+ message: `Document does not have a valid credentialStatus or type.`
14
+ },
15
+ status: "SKIPPED"
16
+ };
17
+ }, "skip"),
18
+ test: /* @__PURE__ */ __name((document) => {
19
+ const doc = document;
20
+ return doc.credentialStatus?.type === "StatusList2021Entry";
21
+ }, "test"),
22
+ verify: /* @__PURE__ */ __name(async (document) => {
23
+ const doc = document;
24
+ const verificationResult = await verifyCredentialStatus(doc.credentialStatus);
25
+ if (verificationResult.error) {
26
+ return {
27
+ type: "DOCUMENT_STATUS",
28
+ name: "W3CCredentialStatus",
29
+ reason: {
30
+ message: verificationResult.error
31
+ },
32
+ status: "ERROR"
33
+ };
34
+ } else if (verificationResult.status === true) {
35
+ return {
36
+ type: "DOCUMENT_STATUS",
37
+ name: "W3CCredentialStatus",
38
+ data: false,
39
+ status: "INVALID"
40
+ };
41
+ } else {
42
+ return {
43
+ type: "DOCUMENT_STATUS",
44
+ name: "W3CCredentialStatus",
45
+ data: true,
46
+ status: "VALID"
47
+ };
48
+ }
49
+ }, "verify")
50
+ };
51
+
52
+ export { w3cCredentialStatus };
@@ -0,0 +1,5 @@
1
+ export { openAttestationDidIdentityProof, openAttestationDidSignedDocumentStatus, openAttestationDnsDidIdentityProof, openAttestationDnsTxtIdentityProof, openAttestationEthereumDocumentStoreStatus, openAttestationEthereumTokenRegistryStatus, openAttestationHash } from '@tradetrust-tt/tt-verify';
2
+ export { w3cSignatureIntegrity } from './document-integrity/w3cSignatureIntegrity';
3
+ export { credentialStatusTransferableRecordVerifier } from './document-status/transferableRecords/transferableRecordVerifier';
4
+ export { w3cCredentialStatus } from './document-status/w3cCredentialStatus';
5
+ export { w3cIssuerIdentity } from './issuer-identity/w3cIssuerIdentity';
@@ -0,0 +1,72 @@
1
+ import { Resolver } from 'did-resolver';
2
+ import { getResolver } from 'web-did-resolver';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ const checkDidWebResolve = /* @__PURE__ */ __name(async (did) => {
7
+ try {
8
+ const resolver = new Resolver({
9
+ ...getResolver()
10
+ });
11
+ const didDocument = await resolver.resolve(did);
12
+ if (!didDocument || !didDocument.didDocument) {
13
+ throw new Error(`Failed to resolve DID: ${did}`);
14
+ }
15
+ return true;
16
+ } catch {
17
+ return false;
18
+ }
19
+ }, "checkDidWebResolve");
20
+ const w3cIssuerIdentity = {
21
+ skip: /* @__PURE__ */ __name(async () => {
22
+ return {
23
+ type: "ISSUER_IDENTITY",
24
+ name: "W3CIssuerIdentity",
25
+ reason: {
26
+ code: 0,
27
+ codeString: "SKIPPED",
28
+ message: `Document has no issuer field.`
29
+ },
30
+ status: "SKIPPED"
31
+ };
32
+ }, "skip"),
33
+ test: /* @__PURE__ */ __name((document) => {
34
+ const doc = document;
35
+ return Boolean(doc.issuer);
36
+ }, "test"),
37
+ verify: /* @__PURE__ */ __name(async (document) => {
38
+ const doc = document;
39
+ if (doc.proof?.verificationMethod?.split("#")[0] !== doc.issuer) {
40
+ return {
41
+ type: "ISSUER_IDENTITY",
42
+ name: "W3CIssuerIdentity",
43
+ data: false,
44
+ reason: {
45
+ message: `Issuer and verification method do not match.`
46
+ },
47
+ status: "INVALID"
48
+ };
49
+ }
50
+ const resolutionResult = await checkDidWebResolve(doc.issuer);
51
+ if (resolutionResult) {
52
+ return {
53
+ type: "ISSUER_IDENTITY",
54
+ name: "W3CIssuerIdentity",
55
+ data: true,
56
+ status: "VALID"
57
+ };
58
+ } else {
59
+ return {
60
+ type: "ISSUER_IDENTITY",
61
+ name: "W3CIssuerIdentity",
62
+ data: false,
63
+ reason: {
64
+ message: `The DID cannot be resolved.`
65
+ },
66
+ status: "INVALID"
67
+ };
68
+ }
69
+ }, "verify")
70
+ };
71
+
72
+ export { w3cIssuerIdentity };
@@ -0,0 +1,3 @@
1
+ export * from './verify';
2
+ import * as fragments from './fragments';
3
+ export { fragments };
@@ -0,0 +1,38 @@
1
+ import { openAttestationVerifiers as openAttestationVerifiers$1, openAttestationDidIdentityProof, openAttestationHash, openAttestationDidSignedDocumentStatus, openAttestationEthereumDocumentStoreStatus, openAttestationEthereumTokenRegistryStatus, openAttestationDnsDidIdentityProof, openAttestationDnsTxtIdentityProof } from '@tradetrust-tt/tt-verify';
2
+ export { isValid, verificationBuilder, verify } from '@tradetrust-tt/tt-verify';
3
+ import { w3cSignatureIntegrity } from './fragments/document-integrity/w3cSignatureIntegrity';
4
+ import { credentialStatusTransferableRecordVerifier } from './fragments/document-status/transferableRecords/transferableRecordVerifier';
5
+ import { w3cCredentialStatus } from './fragments/document-status/w3cCredentialStatus';
6
+ import { w3cIssuerIdentity } from './fragments/issuer-identity/w3cIssuerIdentity';
7
+
8
+ const verifiers = {
9
+ documentIntegrity: {
10
+ openAttestationHash,
11
+ w3cSignatureIntegrity
12
+ },
13
+ documentStatus: {
14
+ openAttestationDidSignedDocumentStatus,
15
+ openAttestationEthereumDocumentStoreStatus,
16
+ openAttestationEthereumTokenRegistryStatus,
17
+ w3cCredentialStatus,
18
+ credentialStatusTransferableRecordVerifier
19
+ },
20
+ issuerIdentity: {
21
+ openAttestationDidIdentityProof,
22
+ openAttestationDnsDidIdentityProof,
23
+ openAttestationDnsTxtIdentityProof,
24
+ w3cIssuerIdentity
25
+ }
26
+ };
27
+ const openAttestationVerifiers = [
28
+ ...openAttestationVerifiers$1,
29
+ openAttestationDidIdentityProof
30
+ ];
31
+ const w3cVerifiers = [
32
+ w3cSignatureIntegrity,
33
+ w3cCredentialStatus,
34
+ credentialStatusTransferableRecordVerifier,
35
+ w3cIssuerIdentity
36
+ ];
37
+
38
+ export { openAttestationVerifiers, verifiers, w3cVerifiers };
@@ -0,0 +1 @@
1
+ export * from '@trustvc/w3c-context';
@@ -0,0 +1 @@
1
+ export * from '@trustvc/w3c-credential-status';
@@ -0,0 +1,11 @@
1
+ import * as context from './context';
2
+ export { context };
3
+ import * as credentialStatus from './credential-status';
4
+ export { credentialStatus };
5
+ import * as issuer from './issuer';
6
+ export { issuer as isser };
7
+ export * from './sign';
8
+ export * from './types';
9
+ import * as vc from './vc';
10
+ export { vc };
11
+ export * from './verify';
@@ -0,0 +1 @@
1
+ export * from '@trustvc/w3c-issuer';
@@ -0,0 +1,9 @@
1
+ import { signCredential } from '@trustvc/w3c-vc';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const signW3C = /* @__PURE__ */ __name(async (credential, keyPair, cryptoSuite = "BbsBlsSignature2020") => {
6
+ return signCredential(credential, keyPair, cryptoSuite);
7
+ }, "signW3C");
8
+
9
+ export { signW3C };
@@ -0,0 +1,2 @@
1
+ export { RawVerifiableCredential, SignedVerifiableCredential, SigningResult, VerificationResult } from '@trustvc/w3c-vc';
2
+ export { PrivateKeyPair } from '@trustvc/w3c-issuer';
@@ -0,0 +1 @@
1
+ export * from '@trustvc/w3c-vc';
@@ -0,0 +1,9 @@
1
+ import { verifyCredential } from '@trustvc/w3c-vc';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const verifyW3CSignature = /* @__PURE__ */ __name(async (credential) => {
6
+ return verifyCredential(credential);
7
+ }, "verifyW3CSignature");
8
+
9
+ export { verifyW3CSignature };
@@ -0,0 +1,22 @@
1
+ import * as w3cVc from '@trustvc/w3c-vc';
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 index = /*#__PURE__*/_mergeNamespaces({
19
+ __proto__: null
20
+ }, [w3cVc]);
21
+
22
+ export { index as i };
@@ -0,0 +1,22 @@
1
+ import * as w3cVc from '@trustvc/w3c-vc';
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 index = /*#__PURE__*/_mergeNamespaces({
19
+ __proto__: null
20
+ }, [w3cVc]);
21
+
22
+ export { index as i };
@@ -0,0 +1,22 @@
1
+ import { openAttestationDidIdentityProof, openAttestationDidSignedDocumentStatus, openAttestationDnsDidIdentityProof, openAttestationDnsTxtIdentityProof, openAttestationEthereumDocumentStoreStatus, openAttestationEthereumTokenRegistryStatus, openAttestationHash } from '@tradetrust-tt/tt-verify';
2
+ import { w3cSignatureIntegrity } from './verify/fragments/document-integrity/w3cSignatureIntegrity.mjs';
3
+ import { credentialStatusTransferableRecordVerifier } from './verify/fragments/document-status/transferableRecords/transferableRecordVerifier.mjs';
4
+ import { w3cCredentialStatus } from './verify/fragments/document-status/w3cCredentialStatus.mjs';
5
+ import { w3cIssuerIdentity } from './verify/fragments/issuer-identity/w3cIssuerIdentity.mjs';
6
+
7
+ declare const index_credentialStatusTransferableRecordVerifier: typeof credentialStatusTransferableRecordVerifier;
8
+ declare const index_openAttestationDidIdentityProof: typeof openAttestationDidIdentityProof;
9
+ declare const index_openAttestationDidSignedDocumentStatus: typeof openAttestationDidSignedDocumentStatus;
10
+ declare const index_openAttestationDnsDidIdentityProof: typeof openAttestationDnsDidIdentityProof;
11
+ declare const index_openAttestationDnsTxtIdentityProof: typeof openAttestationDnsTxtIdentityProof;
12
+ declare const index_openAttestationEthereumDocumentStoreStatus: typeof openAttestationEthereumDocumentStoreStatus;
13
+ declare const index_openAttestationEthereumTokenRegistryStatus: typeof openAttestationEthereumTokenRegistryStatus;
14
+ declare const index_openAttestationHash: typeof openAttestationHash;
15
+ declare const index_w3cCredentialStatus: typeof w3cCredentialStatus;
16
+ declare const index_w3cIssuerIdentity: typeof w3cIssuerIdentity;
17
+ declare const index_w3cSignatureIntegrity: typeof w3cSignatureIntegrity;
18
+ declare namespace index {
19
+ export { index_credentialStatusTransferableRecordVerifier as credentialStatusTransferableRecordVerifier, index_openAttestationDidIdentityProof as openAttestationDidIdentityProof, index_openAttestationDidSignedDocumentStatus as openAttestationDidSignedDocumentStatus, index_openAttestationDnsDidIdentityProof as openAttestationDnsDidIdentityProof, index_openAttestationDnsTxtIdentityProof as openAttestationDnsTxtIdentityProof, index_openAttestationEthereumDocumentStoreStatus as openAttestationEthereumDocumentStoreStatus, index_openAttestationEthereumTokenRegistryStatus as openAttestationEthereumTokenRegistryStatus, index_openAttestationHash as openAttestationHash, index_w3cCredentialStatus as w3cCredentialStatus, index_w3cIssuerIdentity as w3cIssuerIdentity, index_w3cSignatureIntegrity as w3cSignatureIntegrity };
20
+ }
21
+
22
+ export { index as i };
@@ -0,0 +1,22 @@
1
+ import * as w3cCredentialStatus from '@trustvc/w3c-credential-status';
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 index = /*#__PURE__*/_mergeNamespaces({
19
+ __proto__: null
20
+ }, [w3cCredentialStatus]);
21
+
22
+ export { index as i };
@@ -0,0 +1,22 @@
1
+ import * as w3cCredentialStatus from '@trustvc/w3c-credential-status';
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 index = /*#__PURE__*/_mergeNamespaces({
19
+ __proto__: null
20
+ }, [w3cCredentialStatus]);
21
+
22
+ export { index as i };
@@ -0,0 +1,22 @@
1
+ import * as w3cIssuer from '@trustvc/w3c-issuer';
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 index = /*#__PURE__*/_mergeNamespaces({
19
+ __proto__: null
20
+ }, [w3cIssuer]);
21
+
22
+ export { index as i };