@trustvc/trustvc 1.8.1 → 2.0.0

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 (37) hide show
  1. package/README.md +144 -48
  2. package/dist/cjs/core/documentBuilder.js +38 -14
  3. package/dist/cjs/open-attestation/utils.js +0 -2
  4. package/dist/cjs/utils/documents/index.js +27 -0
  5. package/dist/cjs/verify/fragments/document-integrity/ecdsaW3CSignatureIntegrity.js +87 -0
  6. package/dist/cjs/verify/fragments/document-integrity/w3cSignatureIntegrity.js +2 -2
  7. package/dist/cjs/verify/fragments/index.js +5 -0
  8. package/dist/cjs/verify/verify.js +2 -0
  9. package/dist/cjs/w3c/derive.js +11 -0
  10. package/dist/cjs/w3c/index.js +7 -0
  11. package/dist/cjs/w3c/sign.js +2 -2
  12. package/dist/esm/core/documentBuilder.js +39 -15
  13. package/dist/esm/open-attestation/utils.js +1 -2
  14. package/dist/esm/utils/documents/index.js +26 -1
  15. package/dist/esm/verify/fragments/document-integrity/ecdsaW3CSignatureIntegrity.js +85 -0
  16. package/dist/esm/verify/fragments/document-integrity/w3cSignatureIntegrity.js +1 -1
  17. package/dist/esm/verify/fragments/index.js +1 -0
  18. package/dist/esm/verify/verify.js +2 -0
  19. package/dist/esm/w3c/derive.js +9 -0
  20. package/dist/esm/w3c/index.js +1 -0
  21. package/dist/esm/w3c/sign.js +2 -2
  22. package/dist/types/core/documentBuilder.d.ts +14 -4
  23. package/dist/types/core/index.d.ts +1 -1
  24. package/dist/types/{index-Bc5NlE8f.d.ts → index-1ws_BWZW.d.ts} +2 -2
  25. package/dist/types/{index-CRVFHzes.d.ts → index-LpXMEhhr.d.ts} +3 -1
  26. package/dist/types/index.d.ts +7 -5
  27. package/dist/types/open-attestation/index.d.ts +1 -2
  28. package/dist/types/open-attestation/utils.d.ts +1 -3
  29. package/dist/types/utils/documents/index.d.ts +4 -2
  30. package/dist/types/utils/index.d.ts +2 -2
  31. package/dist/types/verify/fragments/document-integrity/ecdsaW3CSignatureIntegrity.d.ts +5 -0
  32. package/dist/types/verify/fragments/index.d.ts +1 -0
  33. package/dist/types/verify/index.d.ts +2 -1
  34. package/dist/types/w3c/derive.d.ts +11 -0
  35. package/dist/types/w3c/index.d.ts +2 -1
  36. package/dist/types/w3c/sign.d.ts +7 -3
  37. package/package.json +6 -5
@@ -7,6 +7,7 @@ var sign = require('./sign');
7
7
  var types = require('./types');
8
8
  var vc = require('./vc');
9
9
  var verify = require('./verify');
10
+ var derive = require('./derive');
10
11
 
11
12
  function _interopNamespace(e) {
12
13
  if (e && e.__esModule) return e;
@@ -55,3 +56,9 @@ Object.keys(verify).forEach(function (k) {
55
56
  get: function () { return verify[k]; }
56
57
  });
57
58
  });
59
+ Object.keys(derive).forEach(function (k) {
60
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
61
+ enumerable: true,
62
+ get: function () { return derive[k]; }
63
+ });
64
+ });
@@ -4,8 +4,8 @@ var w3cVc = require('@trustvc/w3c-vc');
4
4
 
5
5
  var __defProp = Object.defineProperty;
6
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- const signW3C = /* @__PURE__ */ __name(async (credential, keyPair, cryptoSuite = "BbsBlsSignature2020") => {
8
- return w3cVc.signCredential(credential, keyPair, cryptoSuite);
7
+ const signW3C = /* @__PURE__ */ __name(async (credential, keyPair, cryptoSuite = "ecdsa-sd-2023", options) => {
8
+ return w3cVc.signCredential(credential, keyPair, cryptoSuite, options);
9
9
  }, "signW3C");
10
10
 
11
11
  exports.signW3C = signW3C;
@@ -1,4 +1,5 @@
1
- import { signW3C, verifyW3CSignature } from '../w3c';
1
+ import { CryptoSuite } from '@trustvc/w3c-issuer';
2
+ import { signW3C, deriveW3C, verifyW3CSignature } from '../w3c';
2
3
  import { assertCredentialStatus, assertTransferableRecords } from '@trustvc/w3c-credential-status';
3
4
  import { verifyCredentialStatus } from '@trustvc/w3c-vc';
4
5
  import { ethers } from 'ethers';
@@ -7,6 +8,7 @@ import { constants as constants$1 } from '@tradetrust-tt/token-registry-v5';
7
8
  import { v4Contracts } from '../token-registry-v4';
8
9
  import { v5Contracts } from '../token-registry-v5';
9
10
  import { SUPPORTED_CHAINS } from '../utils';
11
+ import { TR_CONTEXT_URL, RENDER_CONTEXT_V2_URL, QRCODE_CONTEXT_URL, DATA_INTEGRITY_V2_URL, BBS_V1_URL, VC_V1_URL, VC_V2_URL } from '@trustvc/w3c-context';
10
12
 
11
13
  var __defProp = Object.defineProperty;
12
14
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -28,6 +30,8 @@ class DocumentBuilder {
28
30
  // Required fields that must be present in the document.
29
31
  isSigned = false;
30
32
  // Tracks if a document is signed
33
+ isDerived = false;
34
+ // Tracks if a document is derived
31
35
  /**
32
36
  * Constructor to initialize the document builder.
33
37
  * @param {Partial<VerifiableCredential>} input - The input document.
@@ -61,18 +65,17 @@ class DocumentBuilder {
61
65
  tokenRegistry: config.tokenRegistry
62
66
  };
63
67
  this.rpcProviderUrl = config.rpcProviderUrl;
64
- this.addContext("https://trustvc.io/context/transferable-records-context.json");
68
+ this.addContext(TR_CONTEXT_URL);
65
69
  } else if (isVerifiable) {
66
70
  this.selectedStatusType = "verifiableDocument";
67
71
  this.statusConfig = {
68
72
  id: `${config.url}#${config.index}`,
69
- type: "StatusList2021Entry",
73
+ type: "BitstringStatusListEntry",
70
74
  statusPurpose: config.purpose || "revocation",
71
75
  // Set status purpose to "revocation" by default.
72
76
  statusListIndex: config.index,
73
77
  statusListCredential: config.url
74
78
  };
75
- this.addContext("https://w3id.org/vc/status-list/2021/v1");
76
79
  } else {
77
80
  throw new Error("Configuration Error: Missing required fields for credential status.");
78
81
  }
@@ -81,25 +84,25 @@ class DocumentBuilder {
81
84
  // Sets the expiration date of the document.
82
85
  expirationDate(date) {
83
86
  if (this.isSigned) throw new Error("Configuration Error: Document is already signed.");
84
- this.document.expirationDate = typeof date === "string" ? date : date.toISOString();
87
+ this.document.validUntil = typeof date === "string" ? date : date.toISOString();
85
88
  return this;
86
89
  }
87
90
  // Defines the rendering method for the document.
88
91
  renderMethod(method) {
89
92
  if (this.isSigned) throw new Error("Configuration Error: Document is already signed.");
90
93
  this.document.renderMethod = [method];
91
- this.addContext("https://trustvc.io/context/render-method-context.json");
94
+ this.addContext(RENDER_CONTEXT_V2_URL);
92
95
  return this;
93
96
  }
94
97
  // Defines the qrcode for the document.
95
98
  qrCode(method) {
96
99
  if (this.isSigned) throw new Error("Configuration Error: Document is already signed.");
97
100
  this.document.qrCode = method;
98
- this.addContext("https://trustvc.io/context/qrcode-context.json");
101
+ this.addContext(QRCODE_CONTEXT_URL);
99
102
  return this;
100
103
  }
101
104
  // Sign the document using the provided private key and an optional cryptographic suite.
102
- async sign(privateKey, cryptoSuite) {
105
+ async sign(privateKey, cryptoSuite, options) {
103
106
  if (this.isSigned) throw new Error("Configuration Error: Document is already signed.");
104
107
  if (this.selectedStatusType) {
105
108
  this.document.credentialStatus = this.statusConfig;
@@ -117,16 +120,36 @@ class DocumentBuilder {
117
120
  await this.verifyTokenRegistry();
118
121
  }
119
122
  this.document.issuer = privateKey.id.split("#")[0];
120
- this.document.issuanceDate = this.document.issuanceDate || (/* @__PURE__ */ new Date()).toISOString();
121
- this.addContext("https://w3id.org/security/bbs/v1");
122
- const signedVC = await signW3C(this.document, privateKey, cryptoSuite);
123
+ this.document.validFrom = this.document.validFrom || (/* @__PURE__ */ new Date()).toISOString();
124
+ if (!cryptoSuite || cryptoSuite === "ecdsa-sd-2023") {
125
+ this.addContext(DATA_INTEGRITY_V2_URL);
126
+ } else {
127
+ this.addContext(BBS_V1_URL);
128
+ }
129
+ const signedVC = await signW3C(this.document, privateKey, cryptoSuite, options);
123
130
  if (signedVC.error) throw new Error(`Signing Error: ${signedVC.error}`);
124
131
  this.isSigned = true;
125
132
  return signedVC.signed;
126
133
  }
134
+ async derive(revealedAttributes) {
135
+ if (!this.isSigned) throw new Error("Configuration Error: Document is not signed yet.");
136
+ if (this.isDerived) throw new Error("Configuration Error: Document is already derived.");
137
+ const derivedCredential = await deriveW3C(
138
+ this.document,
139
+ revealedAttributes
140
+ );
141
+ if (derivedCredential.error) throw new Error(`Derivation Error: ${derivedCredential.error}`);
142
+ this.document = derivedCredential.derived;
143
+ this.isDerived = true;
144
+ return derivedCredential.derived;
145
+ }
127
146
  // Verify the document.
128
147
  async verify() {
129
148
  if (!this.isSigned) throw new Error("Verification Error: Document is not signed yet.");
149
+ const cryptosuite = this.document?.proof?.cryptosuite;
150
+ if (cryptosuite === CryptoSuite.EcdsaSd2023 && !this.isDerived) {
151
+ throw new Error("Verification Error: Document is not derived yet. Use derive() first.");
152
+ }
130
153
  const verificationResult = await verifyW3CSignature(
131
154
  this.document
132
155
  );
@@ -165,10 +188,11 @@ class DocumentBuilder {
165
188
  }
166
189
  // Private helper method to build the context for the document, ensuring uniqueness and adding the default W3C context.
167
190
  buildContext(context) {
168
- return [
169
- "https://www.w3.org/2018/credentials/v1",
170
- ...Array.isArray(context) ? context : context ? [context] : []
171
- ].filter((v, i, a) => a.indexOf(v) === i);
191
+ const arrayContext = Array.isArray(context) ? context : context ? [context] : [];
192
+ if (arrayContext.includes(VC_V1_URL)) {
193
+ throw new Error("Document builder does not support data model v1.1.");
194
+ }
195
+ return [VC_V2_URL, ...arrayContext].filter((v, i, a) => a.indexOf(v) === i);
172
196
  }
173
197
  // Private helper method to add a new context to the document if it does not already exist.
174
198
  addContext(context) {
@@ -11,11 +11,10 @@ const {
11
11
  isSignedWrappedV3Document,
12
12
  isRawV2Document,
13
13
  isRawV3Document,
14
- isObfuscated,
15
14
  getDocumentData,
16
15
  getIssuerAddress,
17
16
  diagnose,
18
17
  getTemplateURL
19
18
  } = utils;
20
19
 
21
- export { diagnose, getAssetId, getDocumentData, getIssuerAddress, getTemplateURL, isDocumentRevokable, isObfuscated, isRawV2Document, isRawV3Document, isSignedWrappedV2Document, isSignedWrappedV3Document, isTransferableAsset, isWrappedV2Document, isWrappedV3Document };
20
+ export { diagnose, getAssetId, getDocumentData, getIssuerAddress, getTemplateURL, isDocumentRevokable, isRawV2Document, isRawV3Document, isSignedWrappedV2Document, isSignedWrappedV3Document, isTransferableAsset, isWrappedV2Document, isWrappedV3Document };
@@ -71,5 +71,30 @@ const getChainId = /* @__PURE__ */ __name((document) => {
71
71
  return void 0;
72
72
  }
73
73
  }, "getChainId");
74
+ const isObfuscated = /* @__PURE__ */ __name((document) => {
75
+ if (isWrappedV3Document(document)) {
76
+ return !!document.proof.privacy?.obfuscated?.length;
77
+ }
78
+ if (isWrappedV2Document(document)) {
79
+ return !!document.privacy?.obfuscatedData?.length;
80
+ }
81
+ if (isSignedDocument(document)) {
82
+ return document.proof?.type === "BbsBlsSignatureProof2020";
83
+ }
84
+ throw new Error(
85
+ "Unsupported document type: Can only check if there are obfuscated data from wrapped OpenAttestation v2, v3 documents and signed verifiable credentials."
86
+ );
87
+ }, "isObfuscated");
88
+ const getObfuscatedData = /* @__PURE__ */ __name((document) => {
89
+ if (isWrappedV3Document(document)) {
90
+ return document.proof.privacy?.obfuscated;
91
+ }
92
+ if (isWrappedV2Document(document)) {
93
+ return document.privacy?.obfuscatedData || [];
94
+ }
95
+ throw new Error(
96
+ "Unsupported document type: Can only retrieve obfuscated data from wrapped OpenAttestation v2 & v3 documents."
97
+ );
98
+ }, "getObfuscatedData");
74
99
 
75
- export { getChainId, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isTransferableRecord };
100
+ export { getChainId, getObfuscatedData, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isObfuscated, isTransferableRecord };
@@ -0,0 +1,85 @@
1
+ import { verifyW3CSignature } from '../../../w3c/verify';
2
+ import { deriveCredential } from '@trustvc/w3c-vc';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ const PROOF_TYPE = "DataIntegrityProof";
7
+ const CRYPTOSUITE = "ecdsa-sd-2023";
8
+ const DERIVE_CREDENTIAL_ERROR = "Use deriveCredential() first";
9
+ function isSignedVerifiableCredential(document) {
10
+ return typeof document === "object" && document !== null && "proof" in document;
11
+ }
12
+ __name(isSignedVerifiableCredential, "isSignedVerifiableCredential");
13
+ const ecdsaW3CSignatureIntegrity = {
14
+ skip: /* @__PURE__ */ __name(async () => {
15
+ return {
16
+ type: "DOCUMENT_INTEGRITY",
17
+ name: "EcdsaW3CSignatureIntegrity",
18
+ reason: {
19
+ code: 0,
20
+ codeString: "SKIPPED",
21
+ message: `Document either has no proof or proof type is not '${PROOF_TYPE}' or proof cryptosuite is not '${CRYPTOSUITE}'.`
22
+ },
23
+ status: "SKIPPED"
24
+ };
25
+ }, "skip"),
26
+ test: /* @__PURE__ */ __name((document) => {
27
+ const doc = document;
28
+ return doc.proof?.type === "DataIntegrityProof" && doc.proof?.cryptosuite === "ecdsa-sd-2023";
29
+ }, "test"),
30
+ verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
31
+ if (!isSignedVerifiableCredential(document)) {
32
+ return {
33
+ type: "DOCUMENT_INTEGRITY",
34
+ name: "EcdsaW3CSignatureIntegrity",
35
+ data: false,
36
+ reason: {
37
+ message: "Document is not a valid SignedVerifiableCredential"
38
+ },
39
+ status: "INVALID"
40
+ };
41
+ }
42
+ try {
43
+ let verificationResult = await verifyW3CSignature(document, verifierOptions);
44
+ let isDerived = true;
45
+ if (!verificationResult.verified && verificationResult.error?.includes(DERIVE_CREDENTIAL_ERROR)) {
46
+ const derivedCredential = await deriveCredential(document, []);
47
+ verificationResult = await verifyW3CSignature(derivedCredential.derived, verifierOptions);
48
+ isDerived = false;
49
+ }
50
+ if (verificationResult.verified) {
51
+ return {
52
+ type: "DOCUMENT_INTEGRITY",
53
+ name: "EcdsaW3CSignatureIntegrity",
54
+ data: true,
55
+ reason: {
56
+ message: isDerived ? "Document verified successfully" : "Document verified after derivation"
57
+ },
58
+ status: "VALID"
59
+ };
60
+ } else {
61
+ return {
62
+ type: "DOCUMENT_INTEGRITY",
63
+ name: "EcdsaW3CSignatureIntegrity",
64
+ data: false,
65
+ reason: {
66
+ message: verificationResult.error || "Verification failed"
67
+ },
68
+ status: "INVALID"
69
+ };
70
+ }
71
+ } catch (error) {
72
+ return {
73
+ type: "DOCUMENT_INTEGRITY",
74
+ name: "EcdsaW3CSignatureIntegrity",
75
+ data: false,
76
+ reason: {
77
+ message: error instanceof Error ? error.message : "Unknown verification error"
78
+ },
79
+ status: "INVALID"
80
+ };
81
+ }
82
+ }, "verify")
83
+ };
84
+
85
+ export { ecdsaW3CSignatureIntegrity };
@@ -1,4 +1,4 @@
1
- import { verifyW3CSignature } from '../../..';
1
+ import { verifyW3CSignature } from '../../../w3c/verify';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -1,5 +1,6 @@
1
1
  export { openAttestationDidIdentityProof, openAttestationDidSignedDocumentStatus, openAttestationDnsDidIdentityProof, openAttestationDnsTxtIdentityProof, openAttestationEthereumDocumentStoreStatus, openAttestationEthereumTokenRegistryStatus, openAttestationHash } from '@tradetrust-tt/tt-verify';
2
2
  export { w3cSignatureIntegrity } from './document-integrity/w3cSignatureIntegrity';
3
+ export { ecdsaW3CSignatureIntegrity } from './document-integrity/ecdsaW3CSignatureIntegrity';
3
4
  export { TRANSFERABLE_RECORDS_TYPE, credentialStatusTransferableRecordVerifier } from './document-status/transferableRecords/transferableRecordVerifier';
4
5
  export { w3cCredentialStatus } from './document-status/w3cCredentialStatus';
5
6
  export { w3cIssuerIdentity } from './issuer-identity/w3cIssuerIdentity';
@@ -1,6 +1,7 @@
1
1
  import { openAttestationVerifiers as openAttestationVerifiers$1, openAttestationDidIdentityProof, openAttestationDnsTxtIdentityProof, openAttestationDnsDidIdentityProof, openAttestationEthereumTokenRegistryStatus, openAttestationEthereumDocumentStoreStatus, openAttestationDidSignedDocumentStatus, openAttestationHash } from '@tradetrust-tt/tt-verify';
2
2
  export { createResolver, getIdentifier, isValid, openAttestationDidIdentityProof, utils, verificationBuilder, verify } from '@tradetrust-tt/tt-verify';
3
3
  import { w3cSignatureIntegrity } from './fragments/document-integrity/w3cSignatureIntegrity';
4
+ import { ecdsaW3CSignatureIntegrity } from './fragments/document-integrity/ecdsaW3CSignatureIntegrity';
4
5
  import { credentialStatusTransferableRecordVerifier } from './fragments/document-status/transferableRecords/transferableRecordVerifier';
5
6
  import { w3cCredentialStatus } from './fragments/document-status/w3cCredentialStatus';
6
7
  import { w3cIssuerIdentity } from './fragments/issuer-identity/w3cIssuerIdentity';
@@ -32,6 +33,7 @@ const openAttestationVerifiers = [
32
33
  ];
33
34
  const w3cVerifiers = [
34
35
  w3cSignatureIntegrity,
36
+ ecdsaW3CSignatureIntegrity,
35
37
  w3cCredentialStatus,
36
38
  credentialStatusTransferableRecordVerifier,
37
39
  w3cEmptyCredentialStatus,
@@ -0,0 +1,9 @@
1
+ import { deriveCredential } from '@trustvc/w3c-vc';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const deriveW3C = /* @__PURE__ */ __name(async (credential, revealedAttributes) => {
6
+ return deriveCredential(credential, revealedAttributes);
7
+ }, "deriveW3C");
8
+
9
+ export { deriveW3C };
@@ -9,3 +9,4 @@ export * from './types';
9
9
  import * as vc from './vc';
10
10
  export { vc };
11
11
  export * from './verify';
12
+ export * from './derive';
@@ -2,8 +2,8 @@ import { signCredential } from '@trustvc/w3c-vc';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
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);
5
+ const signW3C = /* @__PURE__ */ __name(async (credential, keyPair, cryptoSuite = "ecdsa-sd-2023", options) => {
6
+ return signCredential(credential, keyPair, cryptoSuite, options);
7
7
  }, "signW3C");
8
8
 
9
9
  export { signW3C };
@@ -1,5 +1,5 @@
1
1
  import { PrivateKeyPair } from '@trustvc/w3c-issuer';
2
- import { VerifiableCredential, SignedVerifiableCredential } from '@trustvc/w3c-vc';
2
+ import { VerifiableCredential, CryptoSuiteName, SignedVerifiableCredential, ContextDocument } from '@trustvc/w3c-vc';
3
3
 
4
4
  /**
5
5
  * Configuration for a W3C Verifiable Document using a Bitstring Status List.
@@ -39,7 +39,7 @@ interface RenderMethod {
39
39
  templateName: string;
40
40
  }
41
41
  /**
42
- * Configuration for the qrcoode used in a Verifiable Credential document.
42
+ * Configuration for the qrcode used in a Verifiable Credential document.
43
43
  * @property {string} uri - A unique identifier for the qrcode, typically a URL or URI.
44
44
  * @property {string} type - The type of the qrcode method (e.g., 'TrustVCQRCode').
45
45
  */
@@ -47,8 +47,16 @@ interface qrCode {
47
47
  uri: string;
48
48
  type: string;
49
49
  }
50
+ /**
51
+ * Options for signing a document.
52
+ * @property {string[]} mandatoryPointers - The mandatory pointers to be used for signing the document.
53
+ */
54
+ interface SignOptions {
55
+ mandatoryPointers?: string[];
56
+ }
50
57
  /**
51
58
  * Main class responsible for building, configuring, and signing documents with credential statuses.
59
+ * This class implements the W3C Verifiable Credentials Data Model 2.0 specification.
52
60
  */
53
61
  declare class DocumentBuilder {
54
62
  private document;
@@ -58,6 +66,7 @@ declare class DocumentBuilder {
58
66
  private rpcProviderUrl;
59
67
  private requiredFields;
60
68
  private isSigned;
69
+ private isDerived;
61
70
  /**
62
71
  * Constructor to initialize the document builder.
63
72
  * @param {Partial<VerifiableCredential>} input - The input document.
@@ -69,7 +78,8 @@ declare class DocumentBuilder {
69
78
  expirationDate(date: string | Date): this;
70
79
  renderMethod(method: RenderMethod): this;
71
80
  qrCode(method: qrCode): this;
72
- sign(privateKey: PrivateKeyPair, cryptoSuite?: string): Promise<SignedVerifiableCredential>;
81
+ sign(privateKey: PrivateKeyPair, cryptoSuite?: CryptoSuiteName, options?: SignOptions): Promise<SignedVerifiableCredential>;
82
+ derive(revealedAttributes: ContextDocument | string[]): Promise<SignedVerifiableCredential>;
73
83
  verify(): Promise<boolean>;
74
84
  toString(): string;
75
85
  private isTransferableRecordsConfig;
@@ -82,4 +92,4 @@ declare class DocumentBuilder {
82
92
  private supportsInterface;
83
93
  }
84
94
 
85
- export { DocumentBuilder, type RenderMethod, type W3CTransferableRecordsConfig, type W3CVerifiableDocumentConfig, type qrCode };
95
+ export { DocumentBuilder, type RenderMethod, type SignOptions, type W3CTransferableRecordsConfig, type W3CVerifiableDocumentConfig, type qrCode };
@@ -7,7 +7,7 @@ export { fetchEventTime, mergeTransfersV4, mergeTransfersV5, sortLogChain } from
7
7
  export { getEndorsementChain } from './endorsement-chain/retrieveEndorsementChain.js';
8
8
  export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './endorsement-chain/types.js';
9
9
  export { TitleEscrowInterface, checkSupportsInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './endorsement-chain/useEndorsementChain.js';
10
- export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig, qrCode } from './documentBuilder.js';
10
+ export { DocumentBuilder, RenderMethod, SignOptions, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig, qrCode } from './documentBuilder.js';
11
11
  import '@trustvc/w3c-vc';
12
12
  import 'ethers';
13
13
  import '@tradetrust-tt/tt-verify/dist/types/src/types/core';
@@ -1,4 +1,4 @@
1
- import * as _trustvc_w3c_vc from '@trustvc/w3c-vc';
1
+ import * as w3cVc from '@trustvc/w3c-vc';
2
2
 
3
3
  function _mergeNamespaces(n, m) {
4
4
  m.forEach(function (e) {
@@ -17,6 +17,6 @@ function _mergeNamespaces(n, m) {
17
17
 
18
18
  var index = /*#__PURE__*/_mergeNamespaces({
19
19
  __proto__: null
20
- }, [_trustvc_w3c_vc]);
20
+ }, [w3cVc]);
21
21
 
22
22
  export { index as i };
@@ -1,5 +1,6 @@
1
1
  import { openAttestationDidIdentityProof, openAttestationDidSignedDocumentStatus, openAttestationDnsDidIdentityProof, openAttestationDnsTxtIdentityProof, openAttestationEthereumDocumentStoreStatus, openAttestationEthereumTokenRegistryStatus, openAttestationHash } from '@tradetrust-tt/tt-verify';
2
2
  import { w3cSignatureIntegrity } from './verify/fragments/document-integrity/w3cSignatureIntegrity.js';
3
+ import { ecdsaW3CSignatureIntegrity } from './verify/fragments/document-integrity/ecdsaW3CSignatureIntegrity.js';
3
4
  import { TRANSFERABLE_RECORDS_TYPE, credentialStatusTransferableRecordVerifier } from './verify/fragments/document-status/transferableRecords/transferableRecordVerifier.js';
4
5
  import { w3cCredentialStatus } from './verify/fragments/document-status/w3cCredentialStatus.js';
5
6
  import { w3cIssuerIdentity } from './verify/fragments/issuer-identity/w3cIssuerIdentity.js';
@@ -7,6 +8,7 @@ import { w3cEmptyCredentialStatus } from './verify/fragments/document-status/w3c
7
8
 
8
9
  declare const index_TRANSFERABLE_RECORDS_TYPE: typeof TRANSFERABLE_RECORDS_TYPE;
9
10
  declare const index_credentialStatusTransferableRecordVerifier: typeof credentialStatusTransferableRecordVerifier;
11
+ declare const index_ecdsaW3CSignatureIntegrity: typeof ecdsaW3CSignatureIntegrity;
10
12
  declare const index_openAttestationDidIdentityProof: typeof openAttestationDidIdentityProof;
11
13
  declare const index_openAttestationDidSignedDocumentStatus: typeof openAttestationDidSignedDocumentStatus;
12
14
  declare const index_openAttestationDnsDidIdentityProof: typeof openAttestationDnsDidIdentityProof;
@@ -19,7 +21,7 @@ declare const index_w3cEmptyCredentialStatus: typeof w3cEmptyCredentialStatus;
19
21
  declare const index_w3cIssuerIdentity: typeof w3cIssuerIdentity;
20
22
  declare const index_w3cSignatureIntegrity: typeof w3cSignatureIntegrity;
21
23
  declare namespace index {
22
- export { index_TRANSFERABLE_RECORDS_TYPE as TRANSFERABLE_RECORDS_TYPE, 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_w3cEmptyCredentialStatus as w3cEmptyCredentialStatus, index_w3cIssuerIdentity as w3cIssuerIdentity, index_w3cSignatureIntegrity as w3cSignatureIntegrity };
24
+ export { index_TRANSFERABLE_RECORDS_TYPE as TRANSFERABLE_RECORDS_TYPE, index_credentialStatusTransferableRecordVerifier as credentialStatusTransferableRecordVerifier, index_ecdsaW3CSignatureIntegrity as ecdsaW3CSignatureIntegrity, 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_w3cEmptyCredentialStatus as w3cEmptyCredentialStatus, index_w3cIssuerIdentity as w3cIssuerIdentity, index_w3cSignatureIntegrity as w3cSignatureIntegrity };
23
25
  }
24
26
 
25
27
  export { index as i };
@@ -24,28 +24,29 @@ export { fetchEventTime, mergeTransfersV4, mergeTransfersV5, sortLogChain } from
24
24
  export { getEndorsementChain } from './core/endorsement-chain/retrieveEndorsementChain.js';
25
25
  export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './core/endorsement-chain/types.js';
26
26
  export { TitleEscrowInterface, checkSupportsInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './core/endorsement-chain/useEndorsementChain.js';
27
- export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig, qrCode } from './core/documentBuilder.js';
27
+ export { DocumentBuilder, RenderMethod, SignOptions, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig, qrCode } from './core/documentBuilder.js';
28
28
  export { signOA } from './open-attestation/sign.js';
29
29
  export { KeyPair } from './open-attestation/types.js';
30
- export { diagnose, getAssetId, getDocumentData, getIssuerAddress, getTemplateURL, isDocumentRevokable, isObfuscated, isRawV2Document, isRawV3Document, isSignedWrappedV2Document, isSignedWrappedV3Document, isTransferableAsset, isWrappedV2Document, isWrappedV3Document } from './open-attestation/utils.js';
30
+ export { diagnose, getAssetId, getDocumentData, getIssuerAddress, getTemplateURL, isDocumentRevokable, isRawV2Document, isRawV3Document, isSignedWrappedV2Document, isSignedWrappedV3Document, isTransferableAsset, isWrappedV2Document, isWrappedV3Document } from './open-attestation/utils.js';
31
31
  export { verifyOASignature } from './open-attestation/verify.js';
32
32
  export { wrapOADocument, wrapOADocumentV2, wrapOADocuments, wrapOADocumentsV2 } from './open-attestation/wrap.js';
33
33
  export { openAttestationVerifiers, verifiers, w3cVerifiers } from './verify/verify.js';
34
- export { i as fragments } from './index-CRVFHzes.js';
34
+ export { i as fragments } from './index-LpXMEhhr.js';
35
35
  export { i as context } from './index-DwAYXQn2.js';
36
36
  export { i as credentialStatus } from './index-CjwEVGoM.js';
37
37
  export { i as issuer } from './index-ClF4_Nqk.js';
38
38
  export { signW3C } from './w3c/sign.js';
39
39
  export { RawVerifiableCredential, SignedVerifiableCredential, SigningResult, VerificationResult } from '@trustvc/w3c-vc';
40
40
  export { PrivateKeyPair } from '@trustvc/w3c-issuer';
41
- export { i as vc } from './index-Bc5NlE8f.js';
41
+ export { i as vc } from './index-1ws_BWZW.js';
42
42
  export { verifyW3CSignature } from './w3c/verify.js';
43
+ export { deriveW3C } from './w3c/derive.js';
43
44
  export { errorMessageHandling, w3cCredentialStatusRevoked, w3cCredentialStatusSuspended } from './utils/fragment/index.js';
44
45
  export * from '@tradetrust-tt/tradetrust-utils/constants/network';
45
46
  export { generate12ByteNonce, generate32ByteKey, stringToUint8Array } from './utils/stringUtils/index.js';
46
47
  export * from '@tradetrust-tt/tradetrust-utils/constants/supportedChains';
47
48
  export { errorMessages } from './utils/errorMessages/index.js';
48
- export { WrappedOrSignedOpenAttestationDocument, getChainId, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isTransferableRecord } from './utils/documents/index.js';
49
+ export { WrappedOrSignedOpenAttestationDocument, getChainId, getObfuscatedData, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isObfuscated, isTransferableRecord } from './utils/documents/index.js';
49
50
  export { GasStationFeeData, GasStationFunction, calculateMaxFee, gasStation, interpretFragments, scaleBigNumber } from '@tradetrust-tt/tradetrust-utils';
50
51
  export { AwsKmsSigner, AwsKmsSignerCredentials } from '@tradetrust-tt/ethers-aws-kms-signer';
51
52
  export { CustomDnsResolver, IDNSQueryResponse, IDNSRecord, OpenAttestationDNSTextRecord, OpenAttestationDnsDidRecord, defaultDnsResolvers, getDnsDidRecords, getDocumentStoreRecords, parseDnsDidResults, parseDocumentStoreResults, parseOpenAttestationRecord, queryDns } from '@tradetrust-tt/dnsprove';
@@ -71,6 +72,7 @@ import '@tradetrust-tt/tradetrust/dist/types/__generated__/schema.2.0';
71
72
  import '@tradetrust-tt/tradetrust/dist/types/shared/utils/@types/diagnose';
72
73
  import './verify/fragments/document-status/transferableRecords/transferableRecordVerifier.types.js';
73
74
  import './verify/fragments/document-integrity/w3cSignatureIntegrity.js';
75
+ import './verify/fragments/document-integrity/ecdsaW3CSignatureIntegrity.js';
74
76
  import './verify/fragments/document-status/transferableRecords/transferableRecordVerifier.js';
75
77
  import './verify/fragments/document-status/w3cCredentialStatus.js';
76
78
  import './verify/fragments/issuer-identity/w3cIssuerIdentity.js';
@@ -1,12 +1,11 @@
1
1
  export { signOA } from './sign.js';
2
2
  export { KeyPair } from './types.js';
3
- export { diagnose, getAssetId, getDocumentData, getIssuerAddress, getTemplateURL, isDocumentRevokable, isObfuscated, isRawV2Document, isRawV3Document, isSignedWrappedV2Document, isSignedWrappedV3Document, isTransferableAsset, isWrappedV2Document, isWrappedV3Document } from './utils.js';
3
+ export { diagnose, getAssetId, getDocumentData, getIssuerAddress, getTemplateURL, isDocumentRevokable, isRawV2Document, isRawV3Document, isSignedWrappedV2Document, isSignedWrappedV3Document, isTransferableAsset, isWrappedV2Document, isWrappedV3Document } from './utils.js';
4
4
  export { verifyOASignature } from './verify.js';
5
5
  export { wrapOADocument, wrapOADocumentV2, wrapOADocuments, wrapOADocumentsV2 } from './wrap.js';
6
6
  export { OpenAttestationDocument, SUPPORTED_SIGNING_ALGORITHM, SchemaId, SignedWrappedDocument, WrappedDocument, getData as getDataV2, isSchemaValidationError, obfuscateDocument, v2, v3, validateSchema, __unsafe__use__it__at__your__own__risks__wrapDocument as wrapOADocumentV3, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapOADocumentsV3 } from '@tradetrust-tt/tradetrust';
7
7
  export { DiagnoseError } from '@tradetrust-tt/tradetrust/dist/types/shared/utils';
8
8
  import '@ethersproject/abstract-signer';
9
- import '@trustvc/w3c-vc';
10
9
  import '@tradetrust-tt/tradetrust/dist/types/3.0/types';
11
10
  import '@tradetrust-tt/tradetrust/dist/types/__generated__/schema.3.0';
12
11
  import '@tradetrust-tt/tradetrust/dist/types/2.0/types';
@@ -1,4 +1,3 @@
1
- import * as _trustvc_w3c_vc from '@trustvc/w3c-vc';
2
1
  import * as _tradetrust_tt_tradetrust_dist_types_3_0_types from '@tradetrust-tt/tradetrust/dist/types/3.0/types';
3
2
  import * as _tradetrust_tt_tradetrust_dist_types___generated___schema_3_0 from '@tradetrust-tt/tradetrust/dist/types/__generated__/schema.3.0';
4
3
  import * as _tradetrust_tt_tradetrust from '@tradetrust-tt/tradetrust';
@@ -29,7 +28,6 @@ declare const isRawV2Document: (document: any, { mode }?: {
29
28
  declare const isRawV3Document: (document: any, { mode }?: {
30
29
  mode: _tradetrust_tt_tradetrust_dist_types_shared_utils__types_diagnose.Mode;
31
30
  }) => document is _tradetrust_tt_tradetrust_dist_types___generated___schema_3_0.OpenAttestationDocument;
32
- declare const isObfuscated: (document: _tradetrust_tt_tradetrust_dist_types_3_0_types.WrappedDocument<_tradetrust_tt_tradetrust_dist_types___generated___schema_3_0.OpenAttestationDocument> | _tradetrust_tt_tradetrust_dist_types_2_0_types.WrappedDocument<_tradetrust_tt_tradetrust_dist_types___generated___schema_2_0.OpenAttestationDocument> | _trustvc_w3c_vc.SignedVerifiableCredential) => boolean;
33
31
  declare const getDocumentData: (document: _tradetrust_tt_tradetrust.WrappedDocument<_tradetrust_tt_tradetrust.OpenAttestationDocument>) => _tradetrust_tt_tradetrust.OpenAttestationDocument;
34
32
  declare const getIssuerAddress: typeof utils.getIssuerAddress;
35
33
  declare const diagnose: ({ version, kind, document, debug, mode, }: {
@@ -41,4 +39,4 @@ declare const diagnose: ({ version, kind, document, debug, mode, }: {
41
39
  }) => utils.DiagnoseError[];
42
40
  declare const getTemplateURL: (document: any) => string | undefined;
43
41
 
44
- export { diagnose, getAssetId, getDocumentData, getIssuerAddress, getTemplateURL, isDocumentRevokable, isObfuscated, isRawV2Document, isRawV3Document, isSignedWrappedV2Document, isSignedWrappedV3Document, isTransferableAsset, isWrappedV2Document, isWrappedV3Document };
42
+ export { diagnose, getAssetId, getDocumentData, getIssuerAddress, getTemplateURL, isDocumentRevokable, isRawV2Document, isRawV3Document, isSignedWrappedV2Document, isSignedWrappedV3Document, isTransferableAsset, isWrappedV2Document, isWrappedV3Document };
@@ -1,6 +1,6 @@
1
1
  import { WrappedDocument, OpenAttestationDocument } from '@tradetrust-tt/tradetrust';
2
- import { SignedVerifiableCredential } from '@trustvc/w3c-vc';
3
2
  import { TransferableRecordsCredentialStatus } from '@trustvc/w3c-credential-status';
3
+ import { SignedVerifiableCredential } from '@trustvc/w3c-vc';
4
4
  import { CHAIN_ID } from '@tradetrust-tt/tradetrust-utils/constants/supportedChains';
5
5
 
6
6
  type WrappedOrSignedOpenAttestationDocument = WrappedDocument<OpenAttestationDocument>;
@@ -9,5 +9,7 @@ declare const isTransferableRecord: (document: WrappedOrSignedOpenAttestationDoc
9
9
  declare const getTokenRegistryAddress: (document: WrappedOrSignedOpenAttestationDocument | SignedVerifiableCredential) => string | undefined;
10
10
  declare const getTokenId: (document: WrappedOrSignedOpenAttestationDocument | SignedVerifiableCredential) => string;
11
11
  declare const getChainId: (document: WrappedOrSignedOpenAttestationDocument | SignedVerifiableCredential) => CHAIN_ID | undefined;
12
+ declare const isObfuscated: (document: WrappedDocument<OpenAttestationDocument> | SignedVerifiableCredential) => boolean;
13
+ declare const getObfuscatedData: (document: WrappedDocument<OpenAttestationDocument>) => string[];
12
14
 
13
- export { type WrappedOrSignedOpenAttestationDocument, getChainId, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isTransferableRecord };
15
+ export { type WrappedOrSignedOpenAttestationDocument, getChainId, getObfuscatedData, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isObfuscated, isTransferableRecord };
@@ -3,11 +3,11 @@ export * from '@tradetrust-tt/tradetrust-utils/constants/network';
3
3
  export { generate12ByteNonce, generate32ByteKey, stringToUint8Array } from './stringUtils/index.js';
4
4
  export * from '@tradetrust-tt/tradetrust-utils/constants/supportedChains';
5
5
  export { errorMessages } from './errorMessages/index.js';
6
- export { WrappedOrSignedOpenAttestationDocument, getChainId, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isTransferableRecord } from './documents/index.js';
6
+ export { WrappedOrSignedOpenAttestationDocument, getChainId, getObfuscatedData, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isObfuscated, isTransferableRecord } from './documents/index.js';
7
7
  export { GasStationFeeData, GasStationFunction, calculateMaxFee, gasStation, interpretFragments, scaleBigNumber } from '@tradetrust-tt/tradetrust-utils';
8
8
  export { AwsKmsSigner, AwsKmsSignerCredentials } from '@tradetrust-tt/ethers-aws-kms-signer';
9
9
  export { ErrorMessage, ErrorMessageTypes, ErrorMessages, MessagesDictionary } from './errorMessages/types.js';
10
10
  import '@tradetrust-tt/tt-verify';
11
11
  import '@tradetrust-tt/tradetrust';
12
- import '@trustvc/w3c-vc';
13
12
  import '@trustvc/w3c-credential-status';
13
+ import '@trustvc/w3c-vc';
@@ -0,0 +1,5 @@
1
+ import { Verifier, VerificationFragment } from '@tradetrust-tt/tt-verify';
2
+
3
+ declare const ecdsaW3CSignatureIntegrity: Verifier<VerificationFragment>;
4
+
5
+ export { ecdsaW3CSignatureIntegrity };
@@ -1,5 +1,6 @@
1
1
  export { openAttestationDidIdentityProof, openAttestationDidSignedDocumentStatus, openAttestationDnsDidIdentityProof, openAttestationDnsTxtIdentityProof, openAttestationEthereumDocumentStoreStatus, openAttestationEthereumTokenRegistryStatus, openAttestationHash } from '@tradetrust-tt/tt-verify';
2
2
  export { w3cSignatureIntegrity } from './document-integrity/w3cSignatureIntegrity.js';
3
+ export { ecdsaW3CSignatureIntegrity } from './document-integrity/ecdsaW3CSignatureIntegrity.js';
3
4
  export { TRANSFERABLE_RECORDS_TYPE, credentialStatusTransferableRecordVerifier } from './document-status/transferableRecords/transferableRecordVerifier.js';
4
5
  export { w3cCredentialStatus } from './document-status/w3cCredentialStatus.js';
5
6
  export { w3cIssuerIdentity } from './issuer-identity/w3cIssuerIdentity.js';
@@ -1,9 +1,10 @@
1
1
  export { openAttestationVerifiers, verifiers, w3cVerifiers } from './verify.js';
2
- export { i as fragments } from '../index-CRVFHzes.js';
2
+ export { i as fragments } from '../index-LpXMEhhr.js';
3
3
  export { createResolver, getIdentifier, isValid, openAttestationDidIdentityProof, utils, verificationBuilder, verify } from '@tradetrust-tt/tt-verify';
4
4
  export { DocumentsToVerify, ErrorVerificationFragment, InvalidVerificationFragment, ProviderDetails, providerType as ProviderType, SkippedVerificationFragment, ValidVerificationFragment, VerificationBuilderOptions, VerificationFragment, VerificationFragmentStatus, VerificationFragmentType, VerificationFragmentWithData, Verifier, VerifierOptions } from '@tradetrust-tt/tt-verify/dist/types/src/types/core';
5
5
  import './fragments/document-status/transferableRecords/transferableRecordVerifier.types.js';
6
6
  import './fragments/document-integrity/w3cSignatureIntegrity.js';
7
+ import './fragments/document-integrity/ecdsaW3CSignatureIntegrity.js';
7
8
  import './fragments/document-status/transferableRecords/transferableRecordVerifier.js';
8
9
  import './fragments/document-status/w3cCredentialStatus.js';
9
10
  import './fragments/issuer-identity/w3cIssuerIdentity.js';
@@ -0,0 +1,11 @@
1
+ import { SignedVerifiableCredential, ContextDocument, DerivedResult } from '@trustvc/w3c-vc';
2
+
3
+ /**
4
+ * Derives a credential with selective disclosure based on revealed attributes.
5
+ * @param {object} credential - The verifiable credential to be selectively disclosed.
6
+ * @param {object|string[]} revealedAttributes - For BBS+: The attributes from the credential that should be revealed. For ECDSA-SD-2023: Array of selective pointers.
7
+ * @returns {Promise<DerivedResult>} A DerivedResult containing the derived proof or an error message.
8
+ */
9
+ declare const deriveW3C: (credential: SignedVerifiableCredential, revealedAttributes: ContextDocument | string[]) => Promise<DerivedResult>;
10
+
11
+ export { deriveW3C };