@trustvc/trustvc 2.12.3 → 2.12.5
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 +6 -6
- package/dist/cjs/open-attestation/wrap.js +7 -11
- package/dist/cjs/verify/fragments/issuer-identity/w3cIssuerIdentity.js +3 -2
- package/dist/esm/open-attestation/wrap.js +8 -5
- package/dist/esm/verify/fragments/issuer-identity/w3cIssuerIdentity.js +3 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/open-attestation/index.d.ts +1 -1
- package/dist/types/open-attestation/wrap.d.ts +6 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ TrustVC is a comprehensive wrapper library designed to simplify the signing and
|
|
|
14
14
|
- [a) wrapOADocument](#a-wrapoadocument)
|
|
15
15
|
- [b) wrapOADocuments](#b-wrapoadocuments)
|
|
16
16
|
- [2. **Signing**](#2-signing)
|
|
17
|
-
- [a) OpenAttestation Signing (signOA) v2
|
|
17
|
+
- [a) OpenAttestation Signing (signOA) v2](#a-openattestation-signing-signoa-v2)
|
|
18
18
|
- [b) TrustVC W3C Signing (signW3C)](#b-trustvc-w3c-signing-signw3c)
|
|
19
19
|
- [3. **Deriving (Selective Disclosure)**](#3-deriving-selective-disclosure)
|
|
20
20
|
- [4. **Verifying**](#4-verifying)
|
|
@@ -44,13 +44,13 @@ npm run test
|
|
|
44
44
|
|
|
45
45
|
### 1. **Wrapping**
|
|
46
46
|
|
|
47
|
-
> This module provides utility functions for wrapping OpenAttestation documents of version 2 (v2)
|
|
47
|
+
> This module provides utility functions for wrapping OpenAttestation documents of version 2 (v2). These functions validate the document version and apply the appropriate wrapping logic using the OpenAttestation library. Note that wrapping is not required for W3C-compliant documents, as they follow a different format and standard.
|
|
48
48
|
|
|
49
49
|
#### a) wrapOADocument
|
|
50
50
|
|
|
51
51
|
#### Description
|
|
52
52
|
|
|
53
|
-
> Wraps a single OpenAttestation document asynchronously
|
|
53
|
+
> Wraps a single OpenAttestation v2 document asynchronously.
|
|
54
54
|
|
|
55
55
|
#### Parameters
|
|
56
56
|
|
|
@@ -71,7 +71,7 @@ npm run test
|
|
|
71
71
|
import { wrapOADocument } from '@trustvc/trustvc';
|
|
72
72
|
|
|
73
73
|
const document = {
|
|
74
|
-
/* OpenAttestation
|
|
74
|
+
/* OpenAttestation v2 document */
|
|
75
75
|
};
|
|
76
76
|
const wrappedDocument = await wrapOADocument(document);
|
|
77
77
|
console.log(wrappedDocument);
|
|
@@ -81,7 +81,7 @@ console.log(wrappedDocument);
|
|
|
81
81
|
|
|
82
82
|
#### Description
|
|
83
83
|
|
|
84
|
-
> Wraps multiple OpenAttestation documents asynchronously
|
|
84
|
+
> Wraps multiple OpenAttestation v2 documents asynchronously.
|
|
85
85
|
|
|
86
86
|
#### Parameters
|
|
87
87
|
|
|
@@ -126,7 +126,7 @@ The signing functionality is split into two methods:
|
|
|
126
126
|
1. signOA: Designed specifically for signing OpenAttestation documents.
|
|
127
127
|
2. signW3C: Tailored for signing W3C-compliant verifiable credentials.
|
|
128
128
|
|
|
129
|
-
#### a) OpenAttestation Signing (signOA) [v2](https://github.com/Open-Attestation/open-attestation/tree/master/src/2.0)
|
|
129
|
+
#### a) OpenAttestation Signing (signOA) [v2](https://github.com/Open-Attestation/open-attestation/tree/master/src/2.0)
|
|
130
130
|
|
|
131
131
|
```ts
|
|
132
132
|
import { wrapOA, signOA } from '@trustvc/trustvc';
|
|
@@ -14,7 +14,9 @@ async function wrapOADocument(document) {
|
|
|
14
14
|
if (tradetrust.utils.isRawV2Document(document)) {
|
|
15
15
|
return wrapOADocumentV2(document);
|
|
16
16
|
} else if (tradetrust.utils.isRawV3Document(document)) {
|
|
17
|
-
|
|
17
|
+
throw new Error(
|
|
18
|
+
"OA v3 is deprecated in TrustVC as of 1 October 2025. Please switch over to W3C VC."
|
|
19
|
+
);
|
|
18
20
|
} else {
|
|
19
21
|
throw new Error("Unsupported document version");
|
|
20
22
|
}
|
|
@@ -23,22 +25,16 @@ __name(wrapOADocument, "wrapOADocument");
|
|
|
23
25
|
async function wrapOADocuments(documents) {
|
|
24
26
|
if (documents.every((s) => tradetrust.utils.isRawV2Document(s))) {
|
|
25
27
|
return wrapOADocumentsV2(documents);
|
|
26
|
-
} else if (documents.
|
|
27
|
-
|
|
28
|
+
} else if (documents.some((s) => tradetrust.utils.isRawV3Document(s))) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"OA v3 is deprecated in TrustVC as of 1 October 2025. Please switch over to W3C VC."
|
|
31
|
+
);
|
|
28
32
|
} else {
|
|
29
33
|
throw new Error("Unsupported documents version");
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
__name(wrapOADocuments, "wrapOADocuments");
|
|
33
37
|
|
|
34
|
-
Object.defineProperty(exports, "wrapOADocumentV3", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function () { return tradetrust.__unsafe__use__it__at__your__own__risks__wrapDocument; }
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(exports, "wrapOADocumentsV3", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () { return tradetrust.__unsafe__use__it__at__your__own__risks__wrapDocuments; }
|
|
41
|
-
});
|
|
42
38
|
exports.wrapOADocument = wrapOADocument;
|
|
43
39
|
exports.wrapOADocumentV2 = wrapOADocumentV2;
|
|
44
40
|
exports.wrapOADocuments = wrapOADocuments;
|
|
@@ -37,7 +37,8 @@ const w3cIssuerIdentity = {
|
|
|
37
37
|
}, "test"),
|
|
38
38
|
verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
|
|
39
39
|
const doc = document;
|
|
40
|
-
|
|
40
|
+
const issuerId = typeof doc.issuer === "string" ? doc.issuer : doc.issuer?.id;
|
|
41
|
+
if (doc.proof?.verificationMethod?.split("#")[0] !== issuerId) {
|
|
41
42
|
return {
|
|
42
43
|
type: "ISSUER_IDENTITY",
|
|
43
44
|
name: "W3CIssuerIdentity",
|
|
@@ -48,7 +49,7 @@ const w3cIssuerIdentity = {
|
|
|
48
49
|
status: "INVALID"
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
|
-
const resolutionResult = await checkDidWebResolve(
|
|
52
|
+
const resolutionResult = await checkDidWebResolve(issuerId, verifierOptions?.documentLoader);
|
|
52
53
|
if (resolutionResult) {
|
|
53
54
|
return {
|
|
54
55
|
type: "ISSUER_IDENTITY",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { wrapDocument, wrapDocuments, utils
|
|
2
|
-
export { __unsafe__use__it__at__your__own__risks__wrapDocument as wrapOADocumentV3, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapOADocumentsV3 } from '@tradetrust-tt/tradetrust';
|
|
1
|
+
import { wrapDocument, wrapDocuments, utils } from '@tradetrust-tt/tradetrust';
|
|
3
2
|
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -13,7 +12,9 @@ async function wrapOADocument(document) {
|
|
|
13
12
|
if (utils.isRawV2Document(document)) {
|
|
14
13
|
return wrapOADocumentV2(document);
|
|
15
14
|
} else if (utils.isRawV3Document(document)) {
|
|
16
|
-
|
|
15
|
+
throw new Error(
|
|
16
|
+
"OA v3 is deprecated in TrustVC as of 1 October 2025. Please switch over to W3C VC."
|
|
17
|
+
);
|
|
17
18
|
} else {
|
|
18
19
|
throw new Error("Unsupported document version");
|
|
19
20
|
}
|
|
@@ -22,8 +23,10 @@ __name(wrapOADocument, "wrapOADocument");
|
|
|
22
23
|
async function wrapOADocuments(documents) {
|
|
23
24
|
if (documents.every((s) => utils.isRawV2Document(s))) {
|
|
24
25
|
return wrapOADocumentsV2(documents);
|
|
25
|
-
} else if (documents.
|
|
26
|
-
|
|
26
|
+
} else if (documents.some((s) => utils.isRawV3Document(s))) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"OA v3 is deprecated in TrustVC as of 1 October 2025. Please switch over to W3C VC."
|
|
29
|
+
);
|
|
27
30
|
} else {
|
|
28
31
|
throw new Error("Unsupported documents version");
|
|
29
32
|
}
|
|
@@ -35,7 +35,8 @@ const w3cIssuerIdentity = {
|
|
|
35
35
|
}, "test"),
|
|
36
36
|
verify: /* @__PURE__ */ __name(async (document, verifierOptions) => {
|
|
37
37
|
const doc = document;
|
|
38
|
-
|
|
38
|
+
const issuerId = typeof doc.issuer === "string" ? doc.issuer : doc.issuer?.id;
|
|
39
|
+
if (doc.proof?.verificationMethod?.split("#")[0] !== issuerId) {
|
|
39
40
|
return {
|
|
40
41
|
type: "ISSUER_IDENTITY",
|
|
41
42
|
name: "W3CIssuerIdentity",
|
|
@@ -46,7 +47,7 @@ const w3cIssuerIdentity = {
|
|
|
46
47
|
status: "INVALID"
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
|
-
const resolutionResult = await checkDidWebResolve(
|
|
50
|
+
const resolutionResult = await checkDidWebResolve(issuerId, verifierOptions?.documentLoader);
|
|
50
51
|
if (resolutionResult) {
|
|
51
52
|
return {
|
|
52
53
|
type: "ISSUER_IDENTITY",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export { GasStationFeeData, GasStationFunction, calculateMaxFee, gasStation, sca
|
|
|
65
65
|
export { AwsKmsSigner, AwsKmsSignerCredentials } from '@tradetrust-tt/ethers-aws-kms-signer';
|
|
66
66
|
export { gaEvent, gaPageView, validateGaEvent, validateGtag, validatePageViewEvent } from './utils/analytics/analytics.js';
|
|
67
67
|
export { CustomDnsResolver, IDNSQueryResponse, IDNSRecord, OpenAttestationDNSTextRecord, OpenAttestationDnsDidRecord, defaultDnsResolvers, getDnsDidRecords, getDocumentStoreRecords, parseDnsDidResults, parseDocumentStoreResults, parseOpenAttestationRecord, queryDns } from '@tradetrust-tt/dnsprove';
|
|
68
|
-
export { OpenAttestationDocument, SUPPORTED_SIGNING_ALGORITHM, SchemaId, SignedWrappedDocument, WrappedDocument, getData as getDataV2, isSchemaValidationError, obfuscateDocument, v2, v3, validateSchema
|
|
68
|
+
export { OpenAttestationDocument, SUPPORTED_SIGNING_ALGORITHM, SchemaId, SignedWrappedDocument, WrappedDocument, getData as getDataV2, isSchemaValidationError, obfuscateDocument, v2, v3, validateSchema } from '@tradetrust-tt/tradetrust';
|
|
69
69
|
export { DiagnoseError } from '@tradetrust-tt/tradetrust/dist/types/shared/utils';
|
|
70
70
|
export { createResolver, getIdentifier, isValid, utils, verificationBuilder, verify } from '@tradetrust-tt/tt-verify';
|
|
71
71
|
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,7 +5,7 @@ export { verifyOASignature } from './verify.js';
|
|
|
5
5
|
export { wrapOADocument, wrapOADocumentV2, wrapOADocuments, wrapOADocumentsV2 } from './wrap.js';
|
|
6
6
|
export { encryptString } from './encrypt.js';
|
|
7
7
|
export { decryptString } from './decrypt.js';
|
|
8
|
-
export { OpenAttestationDocument, SUPPORTED_SIGNING_ALGORITHM, SchemaId, SignedWrappedDocument, WrappedDocument, getData as getDataV2, isSchemaValidationError, obfuscateDocument, v2, v3, validateSchema
|
|
8
|
+
export { OpenAttestationDocument, SUPPORTED_SIGNING_ALGORITHM, SchemaId, SignedWrappedDocument, WrappedDocument, getData as getDataV2, isSchemaValidationError, obfuscateDocument, v2, v3, validateSchema } from '@tradetrust-tt/tradetrust';
|
|
9
9
|
export { DiagnoseError } from '@tradetrust-tt/tradetrust/dist/types/shared/utils';
|
|
10
10
|
import '@ethersproject/abstract-signer';
|
|
11
11
|
import '@tradetrust-tt/tradetrust/dist/types/3.0/types';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { OpenAttestationDocument, WrappedDocument, v2 } from '@tradetrust-tt/tradetrust';
|
|
2
|
-
export { __unsafe__use__it__at__your__own__risks__wrapDocument as wrapOADocumentV3, __unsafe__use__it__at__your__own__risks__wrapDocuments as wrapOADocumentsV3 } from '@tradetrust-tt/tradetrust';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Asynchronously wraps a V2 OpenAttestation document.
|
|
@@ -25,25 +24,23 @@ declare const wrapOADocumentV2: <T extends v2.OpenAttestationDocument>(document:
|
|
|
25
24
|
*/
|
|
26
25
|
declare const wrapOADocumentsV2: <T extends v2.OpenAttestationDocument>(documents: T[]) => Promise<v2.WrappedDocument<T>[]>;
|
|
27
26
|
/**
|
|
28
|
-
* Asynchronously wraps a
|
|
27
|
+
* Asynchronously wraps a V2 OpenAttestation document.
|
|
29
28
|
*
|
|
30
29
|
* This function takes an OpenAttestation document and validates its version before wrapping it
|
|
31
|
-
* using the OpenAttestation library's `wrapOADocument` function.
|
|
32
|
-
* encountered during the wrapping process, as handled by the OpenAttestation library.
|
|
30
|
+
* using the OpenAttestation library's `wrapOADocument` function. Only V2 documents are supported.
|
|
33
31
|
* @param {OpenAttestationDocument} document - The OpenAttestation document to be wrapped.
|
|
34
32
|
* @returns {Promise<WrappedDocument>} - A promise that resolves to the wrapped document.
|
|
35
|
-
* @throws {Error} -
|
|
33
|
+
* @throws {Error} - Throws if the document is not a V2 document.
|
|
36
34
|
*/
|
|
37
35
|
declare function wrapOADocument<T extends OpenAttestationDocument>(document: T): Promise<WrappedDocument<T>>;
|
|
38
36
|
/**
|
|
39
|
-
* Asynchronously wraps multiple
|
|
37
|
+
* Asynchronously wraps multiple V2 OpenAttestation documents.
|
|
40
38
|
*
|
|
41
39
|
* This function takes an array of OpenAttestation documents and validates their versions before wrapping them
|
|
42
|
-
* using the OpenAttestation library's `wrapOADocuments` function.
|
|
43
|
-
* encountered during the wrapping process, as handled by the OpenAttestation library.
|
|
40
|
+
* using the OpenAttestation library's `wrapOADocuments` function. Only V2 documents are supported.
|
|
44
41
|
* @param {OpenAttestationDocument[]} documents - The OpenAttestation documents to be wrapped.
|
|
45
42
|
* @returns {Promise<WrappedDocument[]>} - A promise that resolves to the wrapped documents.
|
|
46
|
-
* @throws {Error} -
|
|
43
|
+
* @throws {Error} - Throws if any document is not a V2 document.
|
|
47
44
|
*/
|
|
48
45
|
declare function wrapOADocuments<T extends OpenAttestationDocument>(documents: T[]): Promise<WrappedDocument<T>[]>;
|
|
49
46
|
|