@trustvc/trustvc 0.0.0 → 1.0.0-alpha.10

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 (101) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +138 -0
  3. package/dist/config.d.mts +3 -0
  4. package/dist/config.d.ts +3 -0
  5. package/dist/config.js +5 -0
  6. package/dist/core/decrypt.d.mts +3 -0
  7. package/dist/core/decrypt.d.ts +3 -0
  8. package/dist/core/decrypt.js +22 -0
  9. package/dist/core/encrypt.d.mts +3 -0
  10. package/dist/core/encrypt.d.ts +3 -0
  11. package/dist/core/encrypt.js +22 -0
  12. package/dist/core/fragments/document-integrity/w3cSignatureIntegrity.d.mts +5 -0
  13. package/dist/core/fragments/document-integrity/w3cSignatureIntegrity.d.ts +5 -0
  14. package/dist/core/fragments/document-integrity/w3cSignatureIntegrity.js +48 -0
  15. package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.d.mts +7 -0
  16. package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.d.ts +7 -0
  17. package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.js +128 -0
  18. package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.types.d.mts +30 -0
  19. package/dist/core/fragments/document-status/transferableRecords/transferableRecordVerifier.types.d.ts +30 -0
  20. package/dist/core/fragments/document-status/transferableRecords/utils.d.mts +18 -0
  21. package/dist/core/fragments/document-status/transferableRecords/utils.d.ts +18 -0
  22. package/dist/core/fragments/document-status/transferableRecords/utils.js +75 -0
  23. package/dist/core/fragments/document-status/w3cCredentialStatus.d.mts +5 -0
  24. package/dist/core/fragments/document-status/w3cCredentialStatus.d.ts +5 -0
  25. package/dist/core/fragments/document-status/w3cCredentialStatus.js +54 -0
  26. package/dist/core/fragments/issuer-identity/w3cIssuerIdentity.d.mts +5 -0
  27. package/dist/core/fragments/issuer-identity/w3cIssuerIdentity.d.ts +5 -0
  28. package/dist/core/fragments/issuer-identity/w3cIssuerIdentity.js +74 -0
  29. package/dist/core/index.d.mts +5 -0
  30. package/dist/core/index.d.ts +5 -0
  31. package/dist/core/index.js +26 -0
  32. package/dist/core/verify.d.mts +6 -0
  33. package/dist/core/verify.d.ts +6 -0
  34. package/dist/core/verify.js +40 -0
  35. package/dist/esm/config.js +3 -0
  36. package/dist/esm/core/decrypt.js +20 -0
  37. package/dist/esm/core/encrypt.js +20 -0
  38. package/dist/esm/core/fragments/document-integrity/w3cSignatureIntegrity.js +46 -0
  39. package/dist/esm/core/fragments/document-status/transferableRecords/transferableRecordVerifier.js +105 -0
  40. package/dist/esm/core/fragments/document-status/transferableRecords/utils.js +72 -0
  41. package/dist/esm/core/fragments/document-status/w3cCredentialStatus.js +52 -0
  42. package/dist/esm/core/fragments/issuer-identity/w3cIssuerIdentity.js +72 -0
  43. package/dist/esm/core/index.js +3 -0
  44. package/dist/esm/core/verify.js +38 -0
  45. package/dist/esm/index.js +3 -1
  46. package/dist/esm/open-attestation/index.js +5 -0
  47. package/dist/esm/open-attestation/sign.js +15 -0
  48. package/dist/esm/open-attestation/types.js +1 -0
  49. package/dist/esm/open-attestation/utils.js +1 -0
  50. package/dist/esm/open-attestation/verify.js +13 -0
  51. package/dist/esm/open-attestation/wrap.js +33 -0
  52. package/dist/esm/utils/stringUtils.js +20 -0
  53. package/dist/esm/w3c/index.js +3 -0
  54. package/dist/esm/w3c/sign.js +9 -0
  55. package/dist/esm/w3c/types.js +2 -0
  56. package/dist/esm/w3c/verify.js +9 -0
  57. package/dist/index.d.mts +14 -2
  58. package/dist/index.d.ts +14 -2
  59. package/dist/index.js +24 -0
  60. package/dist/open-attestation/index.d.mts +6 -0
  61. package/dist/open-attestation/index.d.ts +6 -0
  62. package/dist/open-attestation/index.js +40 -0
  63. package/dist/open-attestation/sign.d.mts +8 -0
  64. package/dist/open-attestation/sign.d.ts +8 -0
  65. package/dist/open-attestation/sign.js +17 -0
  66. package/dist/open-attestation/types.d.mts +8 -0
  67. package/dist/open-attestation/types.d.ts +8 -0
  68. package/dist/open-attestation/types.js +18 -0
  69. package/dist/open-attestation/utils.d.mts +3 -0
  70. package/dist/open-attestation/utils.d.ts +3 -0
  71. package/dist/open-attestation/utils.js +10 -0
  72. package/dist/open-attestation/verify.d.mts +5 -0
  73. package/dist/open-attestation/verify.d.ts +5 -0
  74. package/dist/open-attestation/verify.js +15 -0
  75. package/dist/open-attestation/wrap.d.mts +9 -0
  76. package/dist/open-attestation/wrap.d.ts +9 -0
  77. package/dist/open-attestation/wrap.js +45 -0
  78. package/dist/utils/stringUtils.d.mts +5 -0
  79. package/dist/utils/stringUtils.d.ts +5 -0
  80. package/dist/utils/stringUtils.js +24 -0
  81. package/dist/w3c/index.d.mts +4 -0
  82. package/dist/w3c/index.d.ts +4 -0
  83. package/dist/w3c/index.js +26 -0
  84. package/dist/w3c/sign.d.mts +6 -0
  85. package/dist/w3c/sign.d.ts +6 -0
  86. package/dist/w3c/sign.js +11 -0
  87. package/dist/w3c/types.d.mts +2 -0
  88. package/dist/w3c/types.d.ts +2 -0
  89. package/dist/w3c/types.js +27 -0
  90. package/dist/w3c/verify.d.mts +5 -0
  91. package/dist/w3c/verify.d.ts +5 -0
  92. package/dist/w3c/verify.js +11 -0
  93. package/package.json +23 -3
  94. package/dist/.coverage/.tmp/coverage-0.json +0 -1
  95. package/dist/esm/.coverage/.tmp/coverage-0.json +0 -1
  96. package/dist/esm/node_modules/.vitest/vitest/results.json +0 -1
  97. package/dist/node_modules/.vitest/vitest/results.json +0 -1
  98. package/dist/types.d.mts +0 -2
  99. package/dist/types.d.ts +0 -2
  100. /package/dist/{types.js → core/fragments/document-status/transferableRecords/transferableRecordVerifier.types.js} +0 -0
  101. /package/dist/esm/{types.js → core/fragments/document-status/transferableRecords/transferableRecordVerifier.types.js} +0 -0
@@ -0,0 +1,72 @@
1
+ import { CodedError, OpenAttestationEthereumTokenRegistryStatusCode } from '@tradetrust-tt/tt-verify';
2
+ import { TradeTrustToken__factory } from '@tradetrust-tt/token-registry/dist/contracts';
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,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
+ export * from './encrypt';
3
+ export * from './decrypt';
@@ -0,0 +1,38 @@
1
+ import { utils } from '@tradetrust-tt/tradetrust';
2
+ import { verificationBuilder, openAttestationVerifiers, openAttestationDidIdentityProof } from '@tradetrust-tt/tt-verify';
3
+ import { ethers } from 'ethers';
4
+ import { w3cSignatureIntegrity } from './fragments/document-integrity/w3cSignatureIntegrity';
5
+ import { credentialStatusTransferableRecordVerifier } from './fragments/document-status/transferableRecords/transferableRecordVerifier';
6
+ import { w3cCredentialStatus } from './fragments/document-status/w3cCredentialStatus';
7
+ import { w3cIssuerIdentity } from './fragments/issuer-identity/w3cIssuerIdentity';
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ const verifyDocument = /* @__PURE__ */ __name(async (document, rpcProviderUrl) => {
12
+ if (utils.isWrappedV2Document(document) || utils.isWrappedV3Document(document)) {
13
+ const verify = verificationBuilder(
14
+ [...openAttestationVerifiers, openAttestationDidIdentityProof],
15
+ {
16
+ provider: new ethers.providers.JsonRpcProvider(rpcProviderUrl)
17
+ // Use user-provided provider URL
18
+ }
19
+ );
20
+ return verify(document);
21
+ } else {
22
+ const verify = verificationBuilder(
23
+ [
24
+ w3cSignatureIntegrity,
25
+ w3cCredentialStatus,
26
+ w3cIssuerIdentity,
27
+ credentialStatusTransferableRecordVerifier
28
+ ],
29
+ {
30
+ provider: new ethers.providers.JsonRpcProvider(rpcProviderUrl)
31
+ // Use user-provided provider URL
32
+ }
33
+ );
34
+ return verify(document);
35
+ }
36
+ }, "verifyDocument");
37
+
38
+ export { verifyDocument };
package/dist/esm/index.js CHANGED
@@ -1 +1,3 @@
1
-
1
+ export * from './open-attestation';
2
+ export * from './core';
3
+ export * from './w3c';
@@ -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
+ export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@tradetrust-tt/tradetrust';
@@ -0,0 +1 @@
1
+ export { utils } from '@tradetrust-tt/tradetrust';
@@ -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 as wrapDocument$1, wrapDocuments as wrapDocuments$1, 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__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ const wrapDocumentv2 = /* @__PURE__ */ __name(async (document) => {
7
+ return wrapDocument$1(document);
8
+ }, "wrapDocumentv2");
9
+ const wrapDocumentsv2 = /* @__PURE__ */ __name(async (documents) => {
10
+ return wrapDocuments$1(documents);
11
+ }, "wrapDocumentsv2");
12
+ async function wrapDocument(document) {
13
+ if (utils.isRawV2Document(document)) {
14
+ return wrapDocumentv2(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(wrapDocument, "wrapDocument");
22
+ async function wrapDocuments(documents) {
23
+ if (documents.every((s) => utils.isRawV2Document(s))) {
24
+ return wrapDocumentsv2(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(wrapDocuments, "wrapDocuments");
32
+
33
+ export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 };
@@ -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,3 @@
1
+ export * from './sign';
2
+ export * from './verify';
3
+ export * from './types';
@@ -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,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 };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,14 @@
1
-
2
- export { }
1
+ export { signOA } from './open-attestation/sign.mjs';
2
+ export { KeyPair } from './open-attestation/types.mjs';
3
+ export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument, utils, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
4
+ export { verifyOASignature } from './open-attestation/verify.mjs';
5
+ export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 } from './open-attestation/wrap.mjs';
6
+ export { verifyDocument } from './core/verify.mjs';
7
+ export { encrypt } from './core/encrypt.mjs';
8
+ export { decrypt } from './core/decrypt.mjs';
9
+ export { signW3C } from './w3c/sign.mjs';
10
+ export { verifyW3CSignature } from './w3c/verify.mjs';
11
+ export { RawVerifiableCredential, SignedVerifiableCredential, SigningResult, VerificationResult } from '@trustvc/w3c-vc';
12
+ export { PrivateKeyPair } from '@trustvc/w3c-issuer';
13
+ import '@ethersproject/abstract-signer';
14
+ import '@tradetrust-tt/tt-verify';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,14 @@
1
-
2
- export { }
1
+ export { signOA } from './open-attestation/sign.js';
2
+ export { KeyPair } from './open-attestation/types.js';
3
+ export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument, utils, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
4
+ export { verifyOASignature } from './open-attestation/verify.js';
5
+ export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 } from './open-attestation/wrap.js';
6
+ export { verifyDocument } from './core/verify.js';
7
+ export { encrypt } from './core/encrypt.js';
8
+ export { decrypt } from './core/decrypt.js';
9
+ export { signW3C } from './w3c/sign.js';
10
+ export { verifyW3CSignature } from './w3c/verify.js';
11
+ export { RawVerifiableCredential, SignedVerifiableCredential, SigningResult, VerificationResult } from '@trustvc/w3c-vc';
12
+ export { PrivateKeyPair } from '@trustvc/w3c-issuer';
13
+ import '@ethersproject/abstract-signer';
14
+ import '@tradetrust-tt/tt-verify';
package/dist/index.js CHANGED
@@ -1,2 +1,26 @@
1
1
  'use strict';
2
2
 
3
+ var openAttestation = require('./open-attestation');
4
+ var core = require('./core');
5
+ var w3c = require('./w3c');
6
+
7
+
8
+
9
+ Object.keys(openAttestation).forEach(function (k) {
10
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
11
+ enumerable: true,
12
+ get: function () { return openAttestation[k]; }
13
+ });
14
+ });
15
+ Object.keys(core).forEach(function (k) {
16
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
17
+ enumerable: true,
18
+ get: function () { return core[k]; }
19
+ });
20
+ });
21
+ Object.keys(w3c).forEach(function (k) {
22
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
23
+ enumerable: true,
24
+ get: function () { return w3c[k]; }
25
+ });
26
+ });
@@ -0,0 +1,6 @@
1
+ export { signOA } from './sign.mjs';
2
+ export { KeyPair } from './types.mjs';
3
+ export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument, utils, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
4
+ export { verifyOASignature } from './verify.mjs';
5
+ export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 } from './wrap.mjs';
6
+ import '@ethersproject/abstract-signer';
@@ -0,0 +1,6 @@
1
+ export { signOA } from './sign.js';
2
+ export { KeyPair } from './types.js';
3
+ export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument, utils, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
4
+ export { verifyOASignature } from './verify.js';
5
+ export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 } from './wrap.js';
6
+ import '@ethersproject/abstract-signer';
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ var sign = require('./sign');
4
+ var types = require('./types');
5
+ var utils = require('./utils');
6
+ var verify = require('./verify');
7
+ var wrap = require('./wrap');
8
+
9
+
10
+
11
+ Object.keys(sign).forEach(function (k) {
12
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
13
+ enumerable: true,
14
+ get: function () { return sign[k]; }
15
+ });
16
+ });
17
+ Object.keys(types).forEach(function (k) {
18
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
19
+ enumerable: true,
20
+ get: function () { return types[k]; }
21
+ });
22
+ });
23
+ Object.keys(utils).forEach(function (k) {
24
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
25
+ enumerable: true,
26
+ get: function () { return utils[k]; }
27
+ });
28
+ });
29
+ Object.keys(verify).forEach(function (k) {
30
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
31
+ enumerable: true,
32
+ get: function () { return verify[k]; }
33
+ });
34
+ });
35
+ Object.keys(wrap).forEach(function (k) {
36
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
37
+ enumerable: true,
38
+ get: function () { return wrap[k]; }
39
+ });
40
+ });
@@ -0,0 +1,8 @@
1
+ import { Signer } from '@ethersproject/abstract-signer';
2
+ import { v2, v3 } from '@tradetrust-tt/tradetrust';
3
+ import { KeyPair } from './types.mjs';
4
+
5
+ declare function signOA<T extends v2.WrappedDocument | v2.SignedWrappedDocument>(document: T, keyPair: KeyPair | Signer): Promise<v2.SignedWrappedDocument>;
6
+ declare function signOA<T extends v3.WrappedDocument | v3.SignedWrappedDocument>(document: T, keyPair: KeyPair | Signer): Promise<v3.SignedWrappedDocument>;
7
+
8
+ export { signOA };
@@ -0,0 +1,8 @@
1
+ import { Signer } from '@ethersproject/abstract-signer';
2
+ import { v2, v3 } from '@tradetrust-tt/tradetrust';
3
+ import { KeyPair } from './types.js';
4
+
5
+ declare function signOA<T extends v2.WrappedDocument | v2.SignedWrappedDocument>(document: T, keyPair: KeyPair | Signer): Promise<v2.SignedWrappedDocument>;
6
+ declare function signOA<T extends v3.WrappedDocument | v3.SignedWrappedDocument>(document: T, keyPair: KeyPair | Signer): Promise<v3.SignedWrappedDocument>;
7
+
8
+ export { signOA };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var tradetrust = require('@tradetrust-tt/tradetrust');
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ async function signOA(document, keyPair) {
8
+ return tradetrust.signDocument(
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ document,
11
+ tradetrust.SUPPORTED_SIGNING_ALGORITHM.Secp256k1VerificationKey2018,
12
+ keyPair
13
+ );
14
+ }
15
+ __name(signOA, "signOA");
16
+
17
+ exports.signOA = signOA;
@@ -0,0 +1,8 @@
1
+ export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@tradetrust-tt/tradetrust';
2
+
3
+ type KeyPair = {
4
+ public: string;
5
+ private: string;
6
+ };
7
+
8
+ export type { KeyPair };
@@ -0,0 +1,8 @@
1
+ export { OpenAttestationDocument, SignedWrappedDocument, WrappedDocument } from '@tradetrust-tt/tradetrust';
2
+
3
+ type KeyPair = {
4
+ public: string;
5
+ private: string;
6
+ };
7
+
8
+ export type { KeyPair };
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var tradetrust = require('@tradetrust-tt/tradetrust');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "OpenAttestationDocument", {
8
+ enumerable: true,
9
+ get: function () { return tradetrust.OpenAttestationDocument; }
10
+ });
11
+ Object.defineProperty(exports, "SignedWrappedDocument", {
12
+ enumerable: true,
13
+ get: function () { return tradetrust.SignedWrappedDocument; }
14
+ });
15
+ Object.defineProperty(exports, "WrappedDocument", {
16
+ enumerable: true,
17
+ get: function () { return tradetrust.WrappedDocument; }
18
+ });
@@ -0,0 +1,3 @@
1
+ export { utils } from '@tradetrust-tt/tradetrust';
2
+ import '@trustvc/w3c-vc';
3
+ import '@trustvc/w3c-issuer';
@@ -0,0 +1,3 @@
1
+ export { utils } from '@tradetrust-tt/tradetrust';
2
+ import '@trustvc/w3c-vc';
3
+ import '@trustvc/w3c-issuer';
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var tradetrust = require('@tradetrust-tt/tradetrust');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "utils", {
8
+ enumerable: true,
9
+ get: function () { return tradetrust.utils; }
10
+ });
@@ -0,0 +1,5 @@
1
+ import { v2, v3 } from '@tradetrust-tt/tradetrust';
2
+
3
+ declare const verifyOASignature: (document: v2.WrappedDocument | v3.WrappedDocument) => Promise<boolean>;
4
+
5
+ export { verifyOASignature };
@@ -0,0 +1,5 @@
1
+ import { v2, v3 } from '@tradetrust-tt/tradetrust';
2
+
3
+ declare const verifyOASignature: (document: v2.WrappedDocument | v3.WrappedDocument) => Promise<boolean>;
4
+
5
+ export { verifyOASignature };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var tradetrust = require('@tradetrust-tt/tradetrust');
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const verifyOASignature = /* @__PURE__ */ __name(async (document) => {
8
+ if (tradetrust.utils.isWrappedV2Document(document) || tradetrust.utils.isWrappedV3Document(document)) {
9
+ return tradetrust.verifySignature(document);
10
+ } else {
11
+ return false;
12
+ }
13
+ }, "verifyOASignature");
14
+
15
+ exports.verifyOASignature = verifyOASignature;
@@ -0,0 +1,9 @@
1
+ import { v2, OpenAttestationDocument, WrappedDocument } from '@tradetrust-tt/tradetrust';
2
+ export { __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
3
+
4
+ declare const wrapDocumentv2: <T extends v2.OpenAttestationDocument>(document: T) => Promise<v2.WrappedDocument<T>>;
5
+ declare const wrapDocumentsv2: <T extends v2.OpenAttestationDocument>(documents: T[]) => Promise<v2.WrappedDocument<T>[]>;
6
+ declare function wrapDocument<T extends OpenAttestationDocument>(document: T): Promise<WrappedDocument<T>>;
7
+ declare function wrapDocuments<T extends OpenAttestationDocument>(documents: T[]): Promise<WrappedDocument<T>[]>;
8
+
9
+ export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 };
@@ -0,0 +1,9 @@
1
+ import { v2, OpenAttestationDocument, WrappedDocument } from '@tradetrust-tt/tradetrust';
2
+ export { __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapDocumentsv3, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapDocumentv3 } from '@tradetrust-tt/tradetrust';
3
+
4
+ declare const wrapDocumentv2: <T extends v2.OpenAttestationDocument>(document: T) => Promise<v2.WrappedDocument<T>>;
5
+ declare const wrapDocumentsv2: <T extends v2.OpenAttestationDocument>(documents: T[]) => Promise<v2.WrappedDocument<T>[]>;
6
+ declare function wrapDocument<T extends OpenAttestationDocument>(document: T): Promise<WrappedDocument<T>>;
7
+ declare function wrapDocuments<T extends OpenAttestationDocument>(documents: T[]): Promise<WrappedDocument<T>[]>;
8
+
9
+ export { wrapDocument, wrapDocuments, wrapDocumentsv2, wrapDocumentv2 };