@trustvc/trustvc 1.4.6 → 1.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -666,6 +666,16 @@ builder.renderMethod({
666
666
  });
667
667
  ```
668
668
 
669
+ ##### Define QR Code Method
670
+ Set the qrcode method to be used for the document.
671
+
672
+ ```ts
673
+ builder.qrCode({
674
+ uri: 'https://example.com/qrcode',
675
+ type: 'TrustVCQRCode',
676
+ });
677
+ ```
678
+
669
679
  ##### Sign the Document
670
680
  To sign the document, provide a `PrivateKeyPair` from `@trustvc/trustvc`.
671
681
 
@@ -690,6 +700,7 @@ Example Output After Signing
690
700
  "https://w3c-ccg.github.io/citizenship-vocab/contexts/citizenship-v1.jsonld",
691
701
  "https://w3id.org/vc/status-list/2021/v1",
692
702
  "https://trustvc.io/context/render-method-context.json",
703
+ "https://trustvc.io/context/qrcode-context.json",
693
704
  "https://w3id.org/security/bbs/v1"
694
705
  ],
695
706
  "type": ["VerifiableCredential"],
@@ -705,6 +716,10 @@ Example Output After Signing
705
716
  "templateName": "BILL_OF_LADING"
706
717
  }
707
718
  ],
719
+ "qrCode": {
720
+ "uri": "https://example.com/qrcode",
721
+ "type": "TrustVCQRCode"
722
+ },
708
723
  "credentialStatus": {
709
724
  "id": "https://example.com/status-list#<placeholder>",
710
725
  "type": "StatusList2021Entry",
@@ -93,6 +93,13 @@ class DocumentBuilder {
93
93
  this.addContext("https://trustvc.io/context/render-method-context.json");
94
94
  return this;
95
95
  }
96
+ // Defines the qrcode for the document.
97
+ qrCode(method) {
98
+ if (this.isSigned) throw new Error("Configuration Error: Document is already signed.");
99
+ this.document.qrCode = method;
100
+ this.addContext("https://trustvc.io/context/qrcode-context.json");
101
+ return this;
102
+ }
96
103
  // Sign the document using the provided private key and an optional cryptographic suite.
97
104
  async sign(privateKey, cryptoSuite) {
98
105
  if (this.isSigned) throw new Error("Configuration Error: Document is already signed.");
@@ -141,7 +141,7 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, tit
141
141
  remark: event.args?.remark
142
142
  };
143
143
  } else if (event?.name === "Nomination") {
144
- return undefined;
144
+ return void 0;
145
145
  } else if (event?.name === "RejectTransferOwners") {
146
146
  return {
147
147
  type: "REJECT_TRANSFER_OWNERS",
@@ -177,8 +177,8 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, tit
177
177
  remark: event.args?.remark
178
178
  };
179
179
  }
180
- return undefined;
181
- }).filter((event) => event !== undefined);
180
+ return void 0;
181
+ }).filter((event) => event !== void 0);
182
182
  }, "fetchAllTransfers");
183
183
  function identifyTokenReceivedType(event) {
184
184
  if (event.args.isMinting) {
@@ -53,7 +53,7 @@ function processOAChainId(document) {
53
53
  console.warn(
54
54
  "You are using an older version of Open-Attestation Document, to use the auto network feature, please use an updated version. Otherwise, please make sure that you select the correct network."
55
55
  );
56
- return undefined;
56
+ return void 0;
57
57
  }
58
58
  __name(processOAChainId, "processOAChainId");
59
59
  const getChainId = /* @__PURE__ */ __name((document) => {
@@ -63,14 +63,14 @@ const getChainId = /* @__PURE__ */ __name((document) => {
63
63
  } else if (openAttestation.isWrappedV2Document(document)) {
64
64
  const documentData = openAttestation.getDataV2(document);
65
65
  const identityProofType = documentData?.issuers?.[0]?.identityProof?.type;
66
- if (identityProofType === "DNS-DID" || identityProofType === "DID") return undefined;
66
+ if (identityProofType === "DNS-DID" || identityProofType === "DID") return void 0;
67
67
  return processOAChainId(documentData);
68
68
  } else if (openAttestation.isWrappedV3Document(document)) {
69
69
  const identityProofType = document?.openAttestationMetadata?.identityProof?.type;
70
- if (identityProofType === "DNS-DID" || identityProofType === "DID") return undefined;
70
+ if (identityProofType === "DNS-DID" || identityProofType === "DID") return void 0;
71
71
  return processOAChainId(document);
72
72
  } else {
73
- return undefined;
73
+ return void 0;
74
74
  }
75
75
  }, "getChainId");
76
76
 
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var w3cIssuer = require('@trustvc/w3c-issuer');
4
+
3
5
  var __defProp = Object.defineProperty;
4
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
7
  const checkDidWebResolve = /* @__PURE__ */ __name(async (did, documentLoader) => {
@@ -7,13 +9,8 @@ const checkDidWebResolve = /* @__PURE__ */ __name(async (did, documentLoader) =>
7
9
  if (documentLoader) {
8
10
  return !!(await documentLoader(did)).document;
9
11
  }
10
- const { Resolver } = await import('did-resolver');
11
- const { getResolver: getWebDidResolver } = await import('web-did-resolver');
12
- const resolver = new Resolver({
13
- ...getWebDidResolver()
14
- });
15
- const didDocument = await resolver.resolve(did);
16
- if (!didDocument || !didDocument.didDocument) {
12
+ const { wellKnownDid } = await w3cIssuer.queryDidDocument({ did });
13
+ if (!wellKnownDid) {
17
14
  throw new Error(`Failed to resolve DID: ${did}`);
18
15
  }
19
16
  return true;
@@ -91,6 +91,13 @@ class DocumentBuilder {
91
91
  this.addContext("https://trustvc.io/context/render-method-context.json");
92
92
  return this;
93
93
  }
94
+ // Defines the qrcode for the document.
95
+ qrCode(method) {
96
+ if (this.isSigned) throw new Error("Configuration Error: Document is already signed.");
97
+ this.document.qrCode = method;
98
+ this.addContext("https://trustvc.io/context/qrcode-context.json");
99
+ return this;
100
+ }
94
101
  // Sign the document using the provided private key and an optional cryptographic suite.
95
102
  async sign(privateKey, cryptoSuite) {
96
103
  if (this.isSigned) throw new Error("Configuration Error: Document is already signed.");
@@ -139,7 +139,7 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, tit
139
139
  remark: event.args?.remark
140
140
  };
141
141
  } else if (event?.name === "Nomination") {
142
- return undefined;
142
+ return void 0;
143
143
  } else if (event?.name === "RejectTransferOwners") {
144
144
  return {
145
145
  type: "REJECT_TRANSFER_OWNERS",
@@ -175,8 +175,8 @@ const fetchAllTransfers = /* @__PURE__ */ __name(async (titleEscrowContract, tit
175
175
  remark: event.args?.remark
176
176
  };
177
177
  }
178
- return undefined;
179
- }).filter((event) => event !== undefined);
178
+ return void 0;
179
+ }).filter((event) => event !== void 0);
180
180
  }, "fetchAllTransfers");
181
181
  function identifyTokenReceivedType(event) {
182
182
  if (event.args.isMinting) {
@@ -51,7 +51,7 @@ function processOAChainId(document) {
51
51
  console.warn(
52
52
  "You are using an older version of Open-Attestation Document, to use the auto network feature, please use an updated version. Otherwise, please make sure that you select the correct network."
53
53
  );
54
- return undefined;
54
+ return void 0;
55
55
  }
56
56
  __name(processOAChainId, "processOAChainId");
57
57
  const getChainId = /* @__PURE__ */ __name((document) => {
@@ -61,14 +61,14 @@ const getChainId = /* @__PURE__ */ __name((document) => {
61
61
  } else if (isWrappedV2Document(document)) {
62
62
  const documentData = getDataV2(document);
63
63
  const identityProofType = documentData?.issuers?.[0]?.identityProof?.type;
64
- if (identityProofType === "DNS-DID" || identityProofType === "DID") return undefined;
64
+ if (identityProofType === "DNS-DID" || identityProofType === "DID") return void 0;
65
65
  return processOAChainId(documentData);
66
66
  } else if (isWrappedV3Document(document)) {
67
67
  const identityProofType = document?.openAttestationMetadata?.identityProof?.type;
68
- if (identityProofType === "DNS-DID" || identityProofType === "DID") return undefined;
68
+ if (identityProofType === "DNS-DID" || identityProofType === "DID") return void 0;
69
69
  return processOAChainId(document);
70
70
  } else {
71
- return undefined;
71
+ return void 0;
72
72
  }
73
73
  }, "getChainId");
74
74
 
@@ -1,3 +1,5 @@
1
+ import { queryDidDocument } from '@trustvc/w3c-issuer';
2
+
1
3
  var __defProp = Object.defineProperty;
2
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
5
  const checkDidWebResolve = /* @__PURE__ */ __name(async (did, documentLoader) => {
@@ -5,13 +7,8 @@ const checkDidWebResolve = /* @__PURE__ */ __name(async (did, documentLoader) =>
5
7
  if (documentLoader) {
6
8
  return !!(await documentLoader(did)).document;
7
9
  }
8
- const { Resolver } = await import('did-resolver');
9
- const { getResolver: getWebDidResolver } = await import('web-did-resolver');
10
- const resolver = new Resolver({
11
- ...getWebDidResolver()
12
- });
13
- const didDocument = await resolver.resolve(did);
14
- if (!didDocument || !didDocument.didDocument) {
10
+ const { wellKnownDid } = await queryDidDocument({ did });
11
+ if (!wellKnownDid) {
15
12
  throw new Error(`Failed to resolve DID: ${did}`);
16
13
  }
17
14
  return true;
@@ -38,6 +38,15 @@ interface RenderMethod {
38
38
  type: string;
39
39
  templateName: string;
40
40
  }
41
+ /**
42
+ * Configuration for the qrcoode used in a Verifiable Credential document.
43
+ * @property {string} uri - A unique identifier for the qrcode, typically a URL or URI.
44
+ * @property {string} type - The type of the qrcode method (e.g., 'TrustVCQRCode').
45
+ */
46
+ interface qrCode {
47
+ uri: string;
48
+ type: string;
49
+ }
41
50
  /**
42
51
  * Main class responsible for building, configuring, and signing documents with credential statuses.
43
52
  */
@@ -59,6 +68,7 @@ declare class DocumentBuilder {
59
68
  credentialStatus(config: W3CTransferableRecordsConfig | W3CVerifiableDocumentConfig): this;
60
69
  expirationDate(date: string | Date): this;
61
70
  renderMethod(method: RenderMethod): this;
71
+ qrCode(method: qrCode): this;
62
72
  sign(privateKey: PrivateKeyPair, cryptoSuite?: string): Promise<SignedVerifiableCredential>;
63
73
  verify(): Promise<boolean>;
64
74
  toString(): string;
@@ -72,4 +82,4 @@ declare class DocumentBuilder {
72
82
  private supportsInterface;
73
83
  }
74
84
 
75
- export { DocumentBuilder, type RenderMethod, type W3CTransferableRecordsConfig, type W3CVerifiableDocumentConfig };
85
+ export { DocumentBuilder, type RenderMethod, 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, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './endorsement-chain/useEndorsementChain.js';
10
- export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig } from './documentBuilder.js';
10
+ export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig, qrCode } from './documentBuilder.js';
11
11
  import '@trustvc/w3c-vc';
12
12
  import '@tradetrust-tt/tt-verify/dist/types/src/types/core';
13
13
  import 'ethersV6';
@@ -19,7 +19,7 @@ export { fetchEventTime, mergeTransfersV4, mergeTransfersV5, sortLogChain } from
19
19
  export { getEndorsementChain } from './core/endorsement-chain/retrieveEndorsementChain.js';
20
20
  export { EndorsementChain, ParsedLog, TitleEscrowTransferEvent, TitleEscrowTransferEventType, TokenTransferEvent, TokenTransferEventType, TradeTrustTokenEventType, TransferBaseEvent, TransferEvent, TransferEventType, TypedEvent } from './core/endorsement-chain/types.js';
21
21
  export { TitleEscrowInterface, fetchEndorsementChain, getDocumentOwner, getTitleEscrowAddress, isTitleEscrowVersion } from './core/endorsement-chain/useEndorsementChain.js';
22
- export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig } from './core/documentBuilder.js';
22
+ export { DocumentBuilder, RenderMethod, W3CTransferableRecordsConfig, W3CVerifiableDocumentConfig, qrCode } from './core/documentBuilder.js';
23
23
  export { signOA } from './open-attestation/sign.js';
24
24
  export { KeyPair } from './open-attestation/types.js';
25
25
  export { diagnose, getAssetId, getDocumentData, getIssuerAddress, getTemplateURL, isObfuscated, isRawV2Document, isRawV3Document, isSignedWrappedV2Document, isSignedWrappedV3Document, isTransferableAsset, isWrappedV2Document, isWrappedV3Document } from './open-attestation/utils.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustvc/trustvc",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "description": "TrustVC library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -114,52 +114,50 @@
114
114
  "@tradetrust-tt/token-registry-v4": "npm:@tradetrust-tt/token-registry@^4.15.2",
115
115
  "@tradetrust-tt/token-registry-v5": "npm:@tradetrust-tt/token-registry@^5.2.0",
116
116
  "@tradetrust-tt/tradetrust": "^6.10.1",
117
- "@tradetrust-tt/tradetrust-utils": "^2.2.1",
118
- "@tradetrust-tt/tt-verify": "^9.3.3",
119
- "@trustvc/w3c-context": "^1.2.4",
120
- "@trustvc/w3c-credential-status": "^1.2.4",
121
- "@trustvc/w3c-issuer": "^1.2.1",
122
- "@trustvc/w3c-vc": "^1.2.8",
123
- "did-resolver": "^4.1.0",
117
+ "@tradetrust-tt/tradetrust-utils": "^2.3.0",
118
+ "@tradetrust-tt/tt-verify": "^9.4.0",
119
+ "@trustvc/w3c-context": "^1.2.8",
120
+ "@trustvc/w3c-credential-status": "^1.2.8",
121
+ "@trustvc/w3c-issuer": "^1.2.2",
122
+ "@trustvc/w3c-vc": "^1.2.12",
124
123
  "ethers": "^5.8.0",
125
124
  "ethersV6": "npm:ethers@^6.13.6",
126
125
  "js-sha3": "^0.9.3",
127
- "ts-chacha20": "^1.2.0",
128
- "web-did-resolver": "^2.0.27"
126
+ "ts-chacha20": "^1.2.0"
129
127
  },
130
128
  "devDependencies": {
131
- "@commitlint/cli": "^19.6.0",
132
- "@commitlint/config-conventional": "^19.6.0",
133
- "@commitlint/config-nx-scopes": "^19.5.0",
134
- "@commitlint/prompt": "^19.6.0",
129
+ "@commitlint/cli": "^19.8.0",
130
+ "@commitlint/config-conventional": "^19.8.0",
131
+ "@commitlint/config-nx-scopes": "^19.8.0",
132
+ "@commitlint/prompt": "^19.8.0",
135
133
  "@semantic-release/changelog": "^6.0.3",
136
134
  "@semantic-release/git": "^10.0.1",
137
135
  "@semantic-release/npm": "^9.0.2",
138
136
  "@types/conventional-commits-parser": "^5.0.1",
139
- "@types/lodash": "^4.17.13",
140
- "@types/node": "^18.19.67",
141
- "@vitest/coverage-v8": "^1.6.0",
137
+ "@types/lodash": "^4.17.16",
138
+ "@types/node": "^18.19.86",
139
+ "@vitest/coverage-v8": "^1.6.1",
142
140
  "cpy": "^11.1.0",
143
- "dotenv": "^16.4.7",
144
- "eslint": "^9.16.0",
141
+ "dotenv": "^16.5.0",
142
+ "eslint": "^9.25.1",
145
143
  "eslint-config-prettier": "^9.1.0",
146
144
  "eslint-formatter-table": "^7.32.1",
147
- "eslint-plugin-jsdoc": "^50.6.3",
145
+ "eslint-plugin-jsdoc": "^50.6.9",
148
146
  "eslint-plugin-node": "^11.1.0",
149
- "eslint-plugin-prettier": "^5.2.1",
147
+ "eslint-plugin-prettier": "^5.2.6",
150
148
  "eslint-plugin-promise": "^7.2.1",
151
- "execa": "^9.5.1",
149
+ "execa": "^9.5.2",
152
150
  "husky": "^9.1.7",
153
- "lint-staged": "^15.2.10",
154
- "prettier": "^3.4.2",
151
+ "lint-staged": "^15.5.1",
152
+ "prettier": "^3.5.3",
155
153
  "rimraf": "^5.0.10",
156
154
  "semantic-release": "^20.1.3",
157
155
  "ts-node": "^10.9.2",
158
- "tsup": "^8.3.5",
159
- "typescript": "^5.7.2",
160
- "typescript-eslint": "^8.17.0",
156
+ "tsup": "^8.4.0",
157
+ "typescript": "^5.8.3",
158
+ "typescript-eslint": "^8.31.0",
161
159
  "vite-plugin-dts": "^3.9.1",
162
- "vitest": "^1.6.0"
160
+ "vitest": "^1.6.1"
163
161
  },
164
162
  "overrides": {
165
163
  "ethers": "^5.8.0"
@@ -168,7 +166,7 @@
168
166
  "ethers": "^5.8.0"
169
167
  },
170
168
  "optionalDependencies": {
171
- "@rollup/rollup-linux-x64-gnu": "~4.28.0"
169
+ "@rollup/rollup-linux-x64-gnu": "~4.40.0"
172
170
  },
173
171
  "lint-staged": {
174
172
  "*.{js,ts}": [