@trustvc/trustvc 2.0.4 → 2.0.6
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.
|
@@ -73,7 +73,7 @@ const getChainId = /* @__PURE__ */ __name((document) => {
|
|
|
73
73
|
return void 0;
|
|
74
74
|
}
|
|
75
75
|
}, "getChainId");
|
|
76
|
-
const isObfuscated = /* @__PURE__ */ __name((document) => {
|
|
76
|
+
const isObfuscated = /* @__PURE__ */ __name(async (document) => {
|
|
77
77
|
if (openAttestation.isWrappedV3Document(document)) {
|
|
78
78
|
return !!document.proof.privacy?.obfuscated?.length;
|
|
79
79
|
}
|
|
@@ -81,7 +81,7 @@ const isObfuscated = /* @__PURE__ */ __name((document) => {
|
|
|
81
81
|
return !!document.privacy?.obfuscatedData?.length;
|
|
82
82
|
}
|
|
83
83
|
if (vc.isSignedDocument(document)) {
|
|
84
|
-
return document
|
|
84
|
+
return await vc.isDerived(document);
|
|
85
85
|
}
|
|
86
86
|
throw new Error(
|
|
87
87
|
"Unsupported document type: Can only check if there are obfuscated data from wrapped OpenAttestation v2, v3 documents and signed verifiable credentials."
|
|
@@ -18,16 +18,28 @@ const w3cCredentialStatusSuspended = /* @__PURE__ */ __name((fragments) => {
|
|
|
18
18
|
return issuedFragment?.reason?.code === w3cCredentialStatus.W3CCredentialStatusCode.DOCUMENT_SUSPENDED || issuedFragment?.reason?.code === w3cCredentialStatus.W3CCredentialStatusCode.DOCUMENT_REVOKED_AND_SUSPENDED;
|
|
19
19
|
}, "w3cCredentialStatusSuspended");
|
|
20
20
|
const errorMessageHandling = /* @__PURE__ */ __name((fragments) => {
|
|
21
|
+
const { hashValid, issuedValid, identityValid } = tradetrustUtils.interpretFragments(fragments);
|
|
21
22
|
const errors = [];
|
|
22
23
|
const isW3cFragments = fragments.some(
|
|
23
24
|
(f) => f.name.startsWith("W3C") || f.name === "TransferableRecords"
|
|
24
25
|
);
|
|
25
26
|
if (isW3cFragments) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
switch (true) {
|
|
28
|
+
case w3cCredentialStatusRevoked(fragments):
|
|
29
|
+
errors.push(tradetrustUtils.CONSTANTS.TYPES.REVOKED);
|
|
30
|
+
break;
|
|
31
|
+
case w3cCredentialStatusSuspended(fragments):
|
|
32
|
+
errors.push(tradetrustUtils.CONSTANTS.TYPES.SUSPENDED);
|
|
33
|
+
break;
|
|
34
|
+
case !hashValid:
|
|
35
|
+
errors.push(tradetrustUtils.CONSTANTS.TYPES.HASH);
|
|
36
|
+
break;
|
|
37
|
+
case !identityValid:
|
|
38
|
+
errors.push(tradetrustUtils.CONSTANTS.TYPES.IDENTITY);
|
|
39
|
+
break;
|
|
40
|
+
case !issuedValid:
|
|
41
|
+
errors.push(tradetrustUtils.CONSTANTS.TYPES.INVALID);
|
|
42
|
+
break;
|
|
31
43
|
}
|
|
32
44
|
return errors;
|
|
33
45
|
} else return tradetrustUtils.errorMessageHandling(fragments);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isTransferableAsset, getIssuerAddress, getAssetId, isWrappedV2Document, getDataV2, isWrappedV3Document } from '../../open-attestation';
|
|
2
2
|
import { TRANSFERABLE_RECORDS_TYPE } from '../../verify/fragments';
|
|
3
|
-
import { isSignedDocument } from '../../w3c/vc';
|
|
3
|
+
import { isSignedDocument, isDerived } from '../../w3c/vc';
|
|
4
4
|
import { CHAIN_ID } from '../supportedChains';
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
@@ -71,7 +71,7 @@ const getChainId = /* @__PURE__ */ __name((document) => {
|
|
|
71
71
|
return void 0;
|
|
72
72
|
}
|
|
73
73
|
}, "getChainId");
|
|
74
|
-
const isObfuscated = /* @__PURE__ */ __name((document) => {
|
|
74
|
+
const isObfuscated = /* @__PURE__ */ __name(async (document) => {
|
|
75
75
|
if (isWrappedV3Document(document)) {
|
|
76
76
|
return !!document.proof.privacy?.obfuscated?.length;
|
|
77
77
|
}
|
|
@@ -79,7 +79,7 @@ const isObfuscated = /* @__PURE__ */ __name((document) => {
|
|
|
79
79
|
return !!document.privacy?.obfuscatedData?.length;
|
|
80
80
|
}
|
|
81
81
|
if (isSignedDocument(document)) {
|
|
82
|
-
return document
|
|
82
|
+
return await isDerived(document);
|
|
83
83
|
}
|
|
84
84
|
throw new Error(
|
|
85
85
|
"Unsupported document type: Can only check if there are obfuscated data from wrapped OpenAttestation v2, v3 documents and signed verifiable credentials."
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONSTANTS, errorMessageHandling as errorMessageHandling$1 } from '@tradetrust-tt/tradetrust-utils';
|
|
1
|
+
import { interpretFragments, CONSTANTS, errorMessageHandling as errorMessageHandling$1 } from '@tradetrust-tt/tradetrust-utils';
|
|
2
2
|
export { interpretFragments } from '@tradetrust-tt/tradetrust-utils';
|
|
3
3
|
import { utils } from '@tradetrust-tt/tt-verify';
|
|
4
4
|
import { W3CCredentialStatusCode } from '../../verify/fragments/document-status/w3cCredentialStatus';
|
|
@@ -17,16 +17,28 @@ const w3cCredentialStatusSuspended = /* @__PURE__ */ __name((fragments) => {
|
|
|
17
17
|
return issuedFragment?.reason?.code === W3CCredentialStatusCode.DOCUMENT_SUSPENDED || issuedFragment?.reason?.code === W3CCredentialStatusCode.DOCUMENT_REVOKED_AND_SUSPENDED;
|
|
18
18
|
}, "w3cCredentialStatusSuspended");
|
|
19
19
|
const errorMessageHandling = /* @__PURE__ */ __name((fragments) => {
|
|
20
|
+
const { hashValid, issuedValid, identityValid } = interpretFragments(fragments);
|
|
20
21
|
const errors = [];
|
|
21
22
|
const isW3cFragments = fragments.some(
|
|
22
23
|
(f) => f.name.startsWith("W3C") || f.name === "TransferableRecords"
|
|
23
24
|
);
|
|
24
25
|
if (isW3cFragments) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
switch (true) {
|
|
27
|
+
case w3cCredentialStatusRevoked(fragments):
|
|
28
|
+
errors.push(CONSTANTS.TYPES.REVOKED);
|
|
29
|
+
break;
|
|
30
|
+
case w3cCredentialStatusSuspended(fragments):
|
|
31
|
+
errors.push(CONSTANTS.TYPES.SUSPENDED);
|
|
32
|
+
break;
|
|
33
|
+
case !hashValid:
|
|
34
|
+
errors.push(CONSTANTS.TYPES.HASH);
|
|
35
|
+
break;
|
|
36
|
+
case !identityValid:
|
|
37
|
+
errors.push(CONSTANTS.TYPES.IDENTITY);
|
|
38
|
+
break;
|
|
39
|
+
case !issuedValid:
|
|
40
|
+
errors.push(CONSTANTS.TYPES.INVALID);
|
|
41
|
+
break;
|
|
30
42
|
}
|
|
31
43
|
return errors;
|
|
32
44
|
} else return errorMessageHandling$1(fragments);
|
|
@@ -9,7 +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
|
|
12
|
+
declare const isObfuscated: (document: WrappedDocument<OpenAttestationDocument> | SignedVerifiableCredential) => Promise<boolean>;
|
|
13
13
|
declare const getObfuscatedData: (document: WrappedDocument<OpenAttestationDocument>) => string[];
|
|
14
14
|
|
|
15
15
|
export { type WrappedOrSignedOpenAttestationDocument, getChainId, getObfuscatedData, getTokenId, getTokenRegistryAddress, getTransferableRecordsCredentialStatus, isObfuscated, isTransferableRecord };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trustvc/trustvc",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "TrustVC library",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
12
|
"test": "npx vitest --run --test-timeout=15000",
|
|
13
|
+
"test:watch": "npx vitest --test-timeout=15000",
|
|
13
14
|
"test:e2e": "concurrently -k \"npm run e2e:node\" \"npm run wait-and-test\"",
|
|
14
15
|
"e2e:node": "npx hardhat node",
|
|
15
16
|
"wait-and-test": "wait-on tcp:8545 && npm run e2e:test",
|
|
@@ -121,7 +122,7 @@
|
|
|
121
122
|
"@tradetrust-tt/tradetrust": "^6.10.2",
|
|
122
123
|
"@tradetrust-tt/tradetrust-utils": "^2.4.2",
|
|
123
124
|
"@tradetrust-tt/tt-verify": "^9.5.1",
|
|
124
|
-
"@trustvc/w3c": "^1.3.0-alpha.
|
|
125
|
+
"@trustvc/w3c": "^1.3.0-alpha.10",
|
|
125
126
|
"@trustvc/w3c-context": "^1.3.0-alpha.8",
|
|
126
127
|
"@trustvc/w3c-credential-status": "^1.3.0-alpha.8",
|
|
127
128
|
"@trustvc/w3c-issuer": "^1.3.0-alpha.6",
|