@trustvc/trustvc 1.4.2 → 1.4.4

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.
@@ -6,17 +6,21 @@ var verify = require('../verify');
6
6
 
7
7
  var __defProp = Object.defineProperty;
8
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- const verifyDocument = /* @__PURE__ */ __name(async (document, rpcProviderUrl) => {
9
+ const verifyDocument = /* @__PURE__ */ __name((document, options) => {
10
+ if (typeof options === "string") {
11
+ options = { rpcProviderUrl: options };
12
+ }
10
13
  if (tradetrust.utils.isWrappedV2Document(document) || tradetrust.utils.isWrappedV3Document(document)) {
11
14
  const verify$1 = verify.verificationBuilder(verify.openAttestationVerifiers, {
12
- provider: new ethers.ethers.providers.JsonRpcProvider(rpcProviderUrl)
15
+ provider: new ethers.ethers.providers.JsonRpcProvider(options?.rpcProviderUrl)
13
16
  // Use user-provided provider URL
14
17
  });
15
18
  return verify$1(document);
16
19
  } else {
17
20
  const verify$1 = verify.verificationBuilder(verify.w3cVerifiers, {
18
- provider: new ethers.ethers.providers.JsonRpcProvider(rpcProviderUrl)
21
+ provider: new ethers.ethers.providers.JsonRpcProvider(options?.rpcProviderUrl),
19
22
  // Use user-provided provider URL
23
+ documentLoader: options?.documentLoader
20
24
  });
21
25
  return verify$1(document);
22
26
  }
@@ -21,9 +21,9 @@ const w3cSignatureIntegrity = {
21
21
  const doc = document;
22
22
  return doc.proof?.type === "BbsBlsSignature2020";
23
23
  }, "test"),
24
- verify: /* @__PURE__ */ __name(async (document) => {
24
+ verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
25
25
  const doc = document;
26
- const verificationResult = await __.verifyW3CSignature(doc);
26
+ const verificationResult = await __.verifyW3CSignature(doc, verifierOptions);
27
27
  if (verificationResult.verified) {
28
28
  return {
29
29
  type: "DOCUMENT_INTEGRITY",
@@ -27,11 +27,13 @@ const w3cCredentialStatus = {
27
27
  return false;
28
28
  }
29
29
  }, "test"),
30
- verify: /* @__PURE__ */ __name(async (document) => {
30
+ verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
31
31
  const doc = document;
32
32
  const credentialStatuses = Array.isArray(doc.credentialStatus) ? doc.credentialStatus : [doc.credentialStatus];
33
33
  const verificationResult = await Promise.all(
34
- credentialStatuses.map((cs) => w3cVc.verifyCredentialStatus(cs, cs?.type))
34
+ credentialStatuses.map(
35
+ (cs) => w3cVc.verifyCredentialStatus(cs, cs?.type, verifierOptions)
36
+ )
35
37
  );
36
38
  if (verificationResult.some((r) => r.error)) {
37
39
  return {
@@ -23,9 +23,9 @@ const w3cEmptyCredentialStatus = {
23
23
  const doc = document;
24
24
  return !!doc.credentialStatus === false || Array.isArray(doc.credentialStatus) && doc.credentialStatus.length === 0 || Object.keys(doc.credentialStatus)?.length === 0;
25
25
  }, "test"),
26
- verify: /* @__PURE__ */ __name(async (document) => {
26
+ verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
27
27
  const doc = document;
28
- const verificationResult = await w3c.verifyW3CSignature(doc);
28
+ const verificationResult = await w3c.verifyW3CSignature(doc, verifierOptions);
29
29
  if (verificationResult.verified) {
30
30
  return {
31
31
  type,
@@ -2,8 +2,11 @@
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const checkDidWebResolve = /* @__PURE__ */ __name(async (did) => {
5
+ const checkDidWebResolve = /* @__PURE__ */ __name(async (did, documentLoader) => {
6
6
  try {
7
+ if (documentLoader) {
8
+ return !!(await documentLoader(did)).document;
9
+ }
7
10
  const { Resolver } = await import('did-resolver');
8
11
  const { getResolver: getWebDidResolver } = await import('web-did-resolver');
9
12
  const resolver = new Resolver({
@@ -35,7 +38,7 @@ const w3cIssuerIdentity = {
35
38
  const doc = document;
36
39
  return Boolean(doc.issuer);
37
40
  }, "test"),
38
- verify: /* @__PURE__ */ __name(async (document) => {
41
+ verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
39
42
  const doc = document;
40
43
  if (doc.proof?.verificationMethod?.split("#")[0] !== doc.issuer) {
41
44
  return {
@@ -48,7 +51,7 @@ const w3cIssuerIdentity = {
48
51
  status: "INVALID"
49
52
  };
50
53
  }
51
- const resolutionResult = await checkDidWebResolve(doc.issuer);
54
+ const resolutionResult = await checkDidWebResolve(doc.issuer, verifierOptions?.documentLoader);
52
55
  if (resolutionResult) {
53
56
  return {
54
57
  type: "ISSUER_IDENTITY",
@@ -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 verifyW3CSignature = /* @__PURE__ */ __name(async (credential) => {
8
- return w3cVc.verifyCredential(credential);
7
+ const verifyW3CSignature = /* @__PURE__ */ __name(async (credential, options) => {
8
+ return w3cVc.verifyCredential(credential, options);
9
9
  }, "verifyW3CSignature");
10
10
 
11
11
  exports.verifyW3CSignature = verifyW3CSignature;
@@ -4,17 +4,21 @@ import { verificationBuilder, openAttestationVerifiers, w3cVerifiers } from '../
4
4
 
5
5
  var __defProp = Object.defineProperty;
6
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- const verifyDocument = /* @__PURE__ */ __name(async (document, rpcProviderUrl) => {
7
+ const verifyDocument = /* @__PURE__ */ __name((document, options) => {
8
+ if (typeof options === "string") {
9
+ options = { rpcProviderUrl: options };
10
+ }
8
11
  if (utils.isWrappedV2Document(document) || utils.isWrappedV3Document(document)) {
9
12
  const verify = verificationBuilder(openAttestationVerifiers, {
10
- provider: new ethers.providers.JsonRpcProvider(rpcProviderUrl)
13
+ provider: new ethers.providers.JsonRpcProvider(options?.rpcProviderUrl)
11
14
  // Use user-provided provider URL
12
15
  });
13
16
  return verify(document);
14
17
  } else {
15
18
  const verify = verificationBuilder(w3cVerifiers, {
16
- provider: new ethers.providers.JsonRpcProvider(rpcProviderUrl)
19
+ provider: new ethers.providers.JsonRpcProvider(options?.rpcProviderUrl),
17
20
  // Use user-provided provider URL
21
+ documentLoader: options?.documentLoader
18
22
  });
19
23
  return verify(document);
20
24
  }
@@ -19,9 +19,9 @@ const w3cSignatureIntegrity = {
19
19
  const doc = document;
20
20
  return doc.proof?.type === "BbsBlsSignature2020";
21
21
  }, "test"),
22
- verify: /* @__PURE__ */ __name(async (document) => {
22
+ verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
23
23
  const doc = document;
24
- const verificationResult = await verifyW3CSignature(doc);
24
+ const verificationResult = await verifyW3CSignature(doc, verifierOptions);
25
25
  if (verificationResult.verified) {
26
26
  return {
27
27
  type: "DOCUMENT_INTEGRITY",
@@ -25,11 +25,13 @@ const w3cCredentialStatus = {
25
25
  return false;
26
26
  }
27
27
  }, "test"),
28
- verify: /* @__PURE__ */ __name(async (document) => {
28
+ verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
29
29
  const doc = document;
30
30
  const credentialStatuses = Array.isArray(doc.credentialStatus) ? doc.credentialStatus : [doc.credentialStatus];
31
31
  const verificationResult = await Promise.all(
32
- credentialStatuses.map((cs) => verifyCredentialStatus(cs, cs?.type))
32
+ credentialStatuses.map(
33
+ (cs) => verifyCredentialStatus(cs, cs?.type, verifierOptions)
34
+ )
33
35
  );
34
36
  if (verificationResult.some((r) => r.error)) {
35
37
  return {
@@ -21,9 +21,9 @@ const w3cEmptyCredentialStatus = {
21
21
  const doc = document;
22
22
  return !!doc.credentialStatus === false || Array.isArray(doc.credentialStatus) && doc.credentialStatus.length === 0 || Object.keys(doc.credentialStatus)?.length === 0;
23
23
  }, "test"),
24
- verify: /* @__PURE__ */ __name(async (document) => {
24
+ verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
25
25
  const doc = document;
26
- const verificationResult = await verifyW3CSignature(doc);
26
+ const verificationResult = await verifyW3CSignature(doc, verifierOptions);
27
27
  if (verificationResult.verified) {
28
28
  return {
29
29
  type,
@@ -1,7 +1,10 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const checkDidWebResolve = /* @__PURE__ */ __name(async (did) => {
3
+ const checkDidWebResolve = /* @__PURE__ */ __name(async (did, documentLoader) => {
4
4
  try {
5
+ if (documentLoader) {
6
+ return !!(await documentLoader(did)).document;
7
+ }
5
8
  const { Resolver } = await import('did-resolver');
6
9
  const { getResolver: getWebDidResolver } = await import('web-did-resolver');
7
10
  const resolver = new Resolver({
@@ -33,7 +36,7 @@ const w3cIssuerIdentity = {
33
36
  const doc = document;
34
37
  return Boolean(doc.issuer);
35
38
  }, "test"),
36
- verify: /* @__PURE__ */ __name(async (document) => {
39
+ verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
37
40
  const doc = document;
38
41
  if (doc.proof?.verificationMethod?.split("#")[0] !== doc.issuer) {
39
42
  return {
@@ -46,7 +49,7 @@ const w3cIssuerIdentity = {
46
49
  status: "INVALID"
47
50
  };
48
51
  }
49
- const resolutionResult = await checkDidWebResolve(doc.issuer);
52
+ const resolutionResult = await checkDidWebResolve(doc.issuer, verifierOptions?.documentLoader);
50
53
  if (resolutionResult) {
51
54
  return {
52
55
  type: "ISSUER_IDENTITY",
@@ -2,8 +2,8 @@ import { verifyCredential } 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 verifyW3CSignature = /* @__PURE__ */ __name(async (credential) => {
6
- return verifyCredential(credential);
5
+ const verifyW3CSignature = /* @__PURE__ */ __name(async (credential, options) => {
6
+ return verifyCredential(credential, options);
7
7
  }, "verifyW3CSignature");
8
8
 
9
9
  export { verifyW3CSignature };
@@ -1,6 +1,14 @@
1
- import { SignedVerifiableCredential } from '@trustvc/w3c-vc';
1
+ import { SignedVerifiableCredential, DocumentLoader } from '@trustvc/w3c-vc';
2
2
  import { DocumentsToVerify, VerificationFragment } from '@tradetrust-tt/tt-verify/dist/types/src/types/core';
3
3
 
4
- declare const verifyDocument: (document: DocumentsToVerify | SignedVerifiableCredential, rpcProviderUrl: string) => Promise<VerificationFragment[]>;
4
+ type VerificationBuilderOptions = {
5
+ rpcProviderUrl?: string;
6
+ documentLoader?: DocumentLoader;
7
+ };
8
+ interface VerifyDocumentParams {
9
+ (document: DocumentsToVerify | SignedVerifiableCredential, options: string): Promise<VerificationFragment[]>;
10
+ (document: DocumentsToVerify | SignedVerifiableCredential, options?: VerificationBuilderOptions): Promise<VerificationFragment[]>;
11
+ }
12
+ declare const verifyDocument: VerifyDocumentParams;
5
13
 
6
14
  export { verifyDocument };
@@ -1,5 +1,7 @@
1
- import { SignedVerifiableCredential, VerificationResult } from '@trustvc/w3c-vc';
1
+ import { SignedVerifiableCredential, DocumentLoader, VerificationResult } from '@trustvc/w3c-vc';
2
2
 
3
- declare const verifyW3CSignature: (credential: SignedVerifiableCredential) => Promise<VerificationResult>;
3
+ declare const verifyW3CSignature: (credential: SignedVerifiableCredential, options?: {
4
+ documentLoader?: DocumentLoader;
5
+ }) => Promise<VerificationResult>;
4
6
 
5
7
  export { verifyW3CSignature };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustvc/trustvc",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "TrustVC library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -110,19 +110,19 @@
110
110
  }
111
111
  },
112
112
  "dependencies": {
113
- "@tradetrust-tt/dnsprove": "^2.16.0",
113
+ "@tradetrust-tt/dnsprove": "^2.17.0",
114
114
  "@tradetrust-tt/token-registry-v4": "npm:@tradetrust-tt/token-registry@^4.15.2",
115
- "@tradetrust-tt/token-registry-v5": "npm:@tradetrust-tt/token-registry@^5.1.4",
115
+ "@tradetrust-tt/token-registry-v5": "npm:@tradetrust-tt/token-registry@^5.2.0",
116
116
  "@tradetrust-tt/tradetrust": "^6.10.1",
117
117
  "@tradetrust-tt/tradetrust-utils": "^2.2.1",
118
- "@tradetrust-tt/tt-verify": "^9.3.1",
119
- "@trustvc/w3c-context": "^1.2.2",
120
- "@trustvc/w3c-credential-status": "^1.2.2",
118
+ "@tradetrust-tt/tt-verify": "^9.3.3",
119
+ "@trustvc/w3c-context": "^1.2.4",
120
+ "@trustvc/w3c-credential-status": "^1.2.4",
121
121
  "@trustvc/w3c-issuer": "^1.2.1",
122
- "@trustvc/w3c-vc": "^1.2.4",
122
+ "@trustvc/w3c-vc": "^1.2.8",
123
123
  "did-resolver": "^4.1.0",
124
- "ethers": "^5.7.2",
125
- "ethersV6": "npm:ethers@^6.13.5",
124
+ "ethers": "^5.8.0",
125
+ "ethersV6": "npm:ethers@^6.13.6",
126
126
  "js-sha3": "^0.9.3",
127
127
  "ts-chacha20": "^1.2.0",
128
128
  "web-did-resolver": "^2.0.27"
@@ -162,10 +162,10 @@
162
162
  "vitest": "^1.6.0"
163
163
  },
164
164
  "overrides": {
165
- "ethers": "^5.7.2"
165
+ "ethers": "^5.8.0"
166
166
  },
167
167
  "peerDependencies": {
168
- "ethers": "^5.7.2"
168
+ "ethers": "^5.8.0"
169
169
  },
170
170
  "optionalDependencies": {
171
171
  "@rollup/rollup-linux-x64-gnu": "~4.28.0"